7
7
#include <linux/gpio/consumer.h>
8
8
#include <linux/mod_devicetable.h>
9
9
#include <linux/module.h>
10
+ #include <linux/regulator/consumer.h>
10
11
11
12
#include <video/mipi_display.h>
12
13
@@ -19,6 +20,13 @@ struct td4310_tianma {
19
20
struct drm_panel panel ;
20
21
struct mipi_dsi_device * dsi ;
21
22
struct gpio_desc * reset_gpio ;
23
+ struct regulator_bulk_data * supplies ;
24
+ };
25
+
26
+ static const struct regulator_bulk_data td4310_tianma_supplies [] = {
27
+ { .supply = "vddio" },
28
+ { .supply = "vsn" },
29
+ { .supply = "vsp" },
22
30
};
23
31
24
32
static inline struct td4310_tianma * to_td4310_tianma (struct drm_panel * panel )
@@ -87,12 +95,19 @@ static int td4310_tianma_prepare(struct drm_panel *panel)
87
95
struct device * dev = & ctx -> dsi -> dev ;
88
96
int ret ;
89
97
98
+ ret = regulator_bulk_enable (ARRAY_SIZE (td4310_tianma_supplies ), ctx -> supplies );
99
+ if (ret < 0 ) {
100
+ dev_err (dev , "Failed to enable regulators: %d\n" , ret );
101
+ return ret ;
102
+ }
103
+
90
104
td4310_tianma_reset (ctx );
91
105
92
106
ret = td4310_tianma_on (ctx );
93
107
if (ret < 0 ) {
94
108
dev_err (dev , "Failed to initialize panel: %d\n" , ret );
95
109
gpiod_set_value_cansleep (ctx -> reset_gpio , 1 );
110
+ regulator_bulk_disable (ARRAY_SIZE (td4310_tianma_supplies ), ctx -> supplies );
96
111
return ret ;
97
112
}
98
113
@@ -110,6 +125,7 @@ static int td4310_tianma_unprepare(struct drm_panel *panel)
110
125
dev_err (dev , "Failed to un-initialize panel: %d\n" , ret );
111
126
112
127
gpiod_set_value_cansleep (ctx -> reset_gpio , 1 );
128
+ regulator_bulk_disable (ARRAY_SIZE (td4310_tianma_supplies ), ctx -> supplies );
113
129
114
130
return 0 ;
115
131
}
@@ -151,6 +167,11 @@ static int td4310_tianma_probe(struct mipi_dsi_device *dsi)
151
167
if (!ctx )
152
168
return - ENOMEM ;
153
169
170
+ ret = devm_regulator_bulk_get_const (dev ,
171
+ ARRAY_SIZE (td4310_tianma_supplies ),
172
+ td4310_tianma_supplies ,
173
+ & ctx -> supplies );
174
+
154
175
ctx -> reset_gpio = devm_gpiod_get (dev , "reset" , GPIOD_OUT_HIGH );
155
176
if (IS_ERR (ctx -> reset_gpio ))
156
177
return dev_err_probe (dev , PTR_ERR (ctx -> reset_gpio ),
0 commit comments