11
11
#include <linux/kernel.h>
12
12
#include <linux/module.h>
13
13
#include <linux/mutex.h>
14
+ #include <linux/regulator/consumer.h>
14
15
#include <linux/slab.h>
15
16
#include <linux/types.h>
16
17
#include <linux/workqueue.h>
@@ -875,12 +876,25 @@ static int sp_tx_edid_read(struct anx7625_data *ctx,
875
876
static void anx7625_power_on (struct anx7625_data * ctx )
876
877
{
877
878
struct device * dev = & ctx -> client -> dev ;
879
+ int ret , i ;
878
880
879
881
if (!ctx -> pdata .low_power_mode ) {
880
882
DRM_DEV_DEBUG_DRIVER (dev , "not low power mode!\n" );
881
883
return ;
882
884
}
883
885
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
+
884
898
/* Power on pin enable */
885
899
gpiod_set_value (ctx -> pdata .gpio_p_on , 1 );
886
900
usleep_range (10000 , 11000 );
@@ -889,11 +903,16 @@ static void anx7625_power_on(struct anx7625_data *ctx)
889
903
usleep_range (10000 , 11000 );
890
904
891
905
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 );
892
910
}
893
911
894
912
static void anx7625_power_standby (struct anx7625_data * ctx )
895
913
{
896
914
struct device * dev = & ctx -> client -> dev ;
915
+ int ret ;
897
916
898
917
if (!ctx -> pdata .low_power_mode ) {
899
918
DRM_DEV_DEBUG_DRIVER (dev , "not low power mode!\n" );
@@ -904,6 +923,12 @@ static void anx7625_power_standby(struct anx7625_data *ctx)
904
923
usleep_range (1000 , 1100 );
905
924
gpiod_set_value (ctx -> pdata .gpio_p_on , 0 );
906
925
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
+
907
932
DRM_DEV_DEBUG_DRIVER (dev , "power down\n" );
908
933
}
909
934
@@ -1742,6 +1767,15 @@ static int anx7625_i2c_probe(struct i2c_client *client,
1742
1767
platform -> client = client ;
1743
1768
i2c_set_clientdata (client , platform );
1744
1769
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
+ }
1745
1779
anx7625_init_gpio (platform );
1746
1780
1747
1781
atomic_set (& platform -> power_status , 0 );
0 commit comments