Skip to content

Commit 6c74498

Browse files
hsinyi527robertfoss
authored andcommitted
drm/bridge: anx7625: disable regulators when power off
When suspending the driver, anx7625_power_standby() will be called to turn off reset-gpios and enable-gpios. However, power supplies are not disabled. To save power, the driver can get the power supply regulators and turn off them in anx7625_power_standby(). Signed-off-by: Hsin-Yi Wang <[email protected]> Reviewed-by: Robert Foss <[email protected]> Reviewed-by: Xin Ji <[email protected]> Signed-off-by: Robert Foss <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 2f240cd commit 6c74498

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

drivers/gpu/drm/bridge/analogix/anx7625.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/kernel.h>
1212
#include <linux/module.h>
1313
#include <linux/mutex.h>
14+
#include <linux/regulator/consumer.h>
1415
#include <linux/slab.h>
1516
#include <linux/types.h>
1617
#include <linux/workqueue.h>
@@ -875,12 +876,25 @@ static int sp_tx_edid_read(struct anx7625_data *ctx,
875876
static void anx7625_power_on(struct anx7625_data *ctx)
876877
{
877878
struct device *dev = &ctx->client->dev;
879+
int ret, i;
878880

879881
if (!ctx->pdata.low_power_mode) {
880882
DRM_DEV_DEBUG_DRIVER(dev, "not low power mode!\n");
881883
return;
882884
}
883885

886+
for (i = 0; i < ARRAY_SIZE(ctx->pdata.supplies); i++) {
887+
ret = regulator_enable(ctx->pdata.supplies[i].consumer);
888+
if (ret < 0) {
889+
DRM_DEV_DEBUG_DRIVER(dev, "cannot enable supply %d: %d\n",
890+
i, ret);
891+
goto reg_err;
892+
}
893+
usleep_range(2000, 2100);
894+
}
895+
896+
usleep_range(4000, 4100);
897+
884898
/* Power on pin enable */
885899
gpiod_set_value(ctx->pdata.gpio_p_on, 1);
886900
usleep_range(10000, 11000);
@@ -889,11 +903,16 @@ static void anx7625_power_on(struct anx7625_data *ctx)
889903
usleep_range(10000, 11000);
890904

891905
DRM_DEV_DEBUG_DRIVER(dev, "power on !\n");
906+
return;
907+
reg_err:
908+
for (--i; i >= 0; i--)
909+
regulator_disable(ctx->pdata.supplies[i].consumer);
892910
}
893911

894912
static void anx7625_power_standby(struct anx7625_data *ctx)
895913
{
896914
struct device *dev = &ctx->client->dev;
915+
int ret;
897916

898917
if (!ctx->pdata.low_power_mode) {
899918
DRM_DEV_DEBUG_DRIVER(dev, "not low power mode!\n");
@@ -904,6 +923,12 @@ static void anx7625_power_standby(struct anx7625_data *ctx)
904923
usleep_range(1000, 1100);
905924
gpiod_set_value(ctx->pdata.gpio_p_on, 0);
906925
usleep_range(1000, 1100);
926+
927+
ret = regulator_bulk_disable(ARRAY_SIZE(ctx->pdata.supplies),
928+
ctx->pdata.supplies);
929+
if (ret < 0)
930+
DRM_DEV_DEBUG_DRIVER(dev, "cannot disable supplies %d\n", ret);
931+
907932
DRM_DEV_DEBUG_DRIVER(dev, "power down\n");
908933
}
909934

@@ -1742,6 +1767,15 @@ static int anx7625_i2c_probe(struct i2c_client *client,
17421767
platform->client = client;
17431768
i2c_set_clientdata(client, platform);
17441769

1770+
pdata->supplies[0].supply = "vdd10";
1771+
pdata->supplies[1].supply = "vdd18";
1772+
pdata->supplies[2].supply = "vdd33";
1773+
ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(pdata->supplies),
1774+
pdata->supplies);
1775+
if (ret) {
1776+
DRM_DEV_ERROR(dev, "fail to get power supplies: %d\n", ret);
1777+
return ret;
1778+
}
17451779
anx7625_init_gpio(platform);
17461780

17471781
atomic_set(&platform->power_status, 0);

drivers/gpu/drm/bridge/analogix/anx7625.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ struct s_edid_data {
350350
struct anx7625_platform_data {
351351
struct gpio_desc *gpio_p_on;
352352
struct gpio_desc *gpio_reset;
353+
struct regulator_bulk_data supplies[3];
353354
struct drm_bridge *panel_bridge;
354355
int intp_irq;
355356
u32 low_power_mode;

0 commit comments

Comments
 (0)