Skip to content

Commit fd373fb

Browse files
6by9pelwell
authored andcommitted
regulator: rpi_panel_v2: Add remove and shutdown hooks
Add shutdown and remove hooks so that the panel gets powered off with the system. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
1 parent 384ad7f commit fd373fb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/regulator/rpi-panel-v2-regulator.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ static int rpi_panel_v2_i2c_probe(struct i2c_client *i2c)
104104
return -ENOMEM;
105105

106106
mutex_init(&state->lock);
107+
i2c_set_clientdata(i2c, state);
107108

108109
regmap = devm_regmap_init_i2c(i2c, &rpi_panel_regmap_config);
109110
if (IS_ERR(regmap)) {
@@ -168,6 +169,21 @@ static int rpi_panel_v2_i2c_probe(struct i2c_client *i2c)
168169
return ret;
169170
}
170171

172+
static void rpi_panel_v2_i2c_remove(struct i2c_client *client)
173+
{
174+
struct rpi_panel_v2_lcd *state = i2c_get_clientdata(client);
175+
176+
mutex_destroy(&state->lock);
177+
}
178+
179+
static void rpi_panel_v2_i2c_shutdown(struct i2c_client *client)
180+
{
181+
struct rpi_panel_v2_lcd *state = i2c_get_clientdata(client);
182+
183+
regmap_write(state->regmap, REG_PWM, 0);
184+
regmap_write(state->regmap, REG_POWERON, 0);
185+
}
186+
171187
static const struct of_device_id rpi_panel_v2_dt_ids[] = {
172188
{ .compatible = "raspberrypi,v2-touchscreen-panel-regulator" },
173189
{},
@@ -180,6 +196,8 @@ static struct i2c_driver rpi_panel_v2_regulator_driver = {
180196
.of_match_table = of_match_ptr(rpi_panel_v2_dt_ids),
181197
},
182198
.probe = rpi_panel_v2_i2c_probe,
199+
.remove = rpi_panel_v2_i2c_remove,
200+
.shutdown = rpi_panel_v2_i2c_shutdown,
183201
};
184202

185203
module_i2c_driver(rpi_panel_v2_regulator_driver);

0 commit comments

Comments
 (0)