diff options
author | Bryan O'Donoghue <bryan.odonoghue@linaro.org> | 2022-09-07 12:13:55 +0100 |
---|---|---|
committer | Bryan O'Donoghue <bryan.odonoghue@linaro.org> | 2022-09-15 02:12:22 +0100 |
commit | ba451b9e0ef729d71e39b30235f6f371ff8bac47 (patch) | |
tree | e2b91121eff56941341dacd367192b464ec1105a | |
parent | aa5820aecaf84c6e54a257b9e1689ad92553a58d (diff) |
media: i2c: ov9282: Add bulk regulator supportlinux-stable-22-09-14-qrb5165-rb5-vision-mezzanine
Depending on the platform we may need to enable and disable three separate
regulators for the imx412.
- DOVDD
Digital I/O power
- AVDD
Analog power
- DVDD
Digital core power
The addition of these regulators shouldn't affect existing users using
fixed-on/firmware-controlled regulators.
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
-rw-r--r-- | drivers/media/i2c/ov9282.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index e3fa7bd558df..4684f8f82aac 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -11,6 +11,7 @@ #include <linux/i2c.h> #include <linux/module.h> #include <linux/pm_runtime.h> +#include <linux/regulator/consumer.h> #include <media/v4l2-ctrls.h> #include <media/v4l2-fwnode.h> @@ -101,6 +102,12 @@ struct ov9282_mode { struct ov9282_reg_list reg_list; }; +static const char * const ov9282_supply_names[] = { + "dovdd", /* Digital I/O power */ + "avdd", /* Analog power */ + "dvdd", /* Digital core power */ +}; + /** * struct ov9282 - ov9282 sensor device structure * @dev: Pointer to generic device @@ -109,6 +116,7 @@ struct ov9282_mode { * @pad: Media pad. Only one pad supported * @reset_gpio: Sensor reset gpio * @inclk: Sensor input clock + * @supplies: Regulator supplies * @ctrl_handler: V4L2 control handler * @link_freq_ctrl: Pointer to link frequency control * @pclk_ctrl: Pointer to pixel clock control @@ -128,6 +136,7 @@ struct ov9282 { struct media_pad pad; struct gpio_desc *reset_gpio; struct clk *inclk; + struct regulator_bulk_data supplies[ARRAY_SIZE(ov9282_supply_names)]; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *link_freq_ctrl; struct v4l2_ctrl *pclk_ctrl; @@ -809,6 +818,16 @@ static int ov9282_parse_hw_config(struct ov9282 *ov9282) return -EINVAL; } + /* Get optional DT defined regulators */ + for (i = 0; i < ARRAY_SIZE(ov9282_supply_names); i++) + ov9282->supplies[i].supply = ov9282_supply_names[i]; + + ret = devm_regulator_bulk_get(ov9282->dev, + ARRAY_SIZE(ov9282_supply_names), + ov9282->supplies); + if (ret) + return ret; + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); if (!ep) return -ENXIO; @@ -874,6 +893,13 @@ static int ov9282_power_on(struct device *dev) struct ov9282 *ov9282 = to_ov9282(sd); int ret; + ret = regulator_bulk_enable(ARRAY_SIZE(ov9282_supply_names), + ov9282->supplies); + if (ret < 0) { + dev_err(dev, "failed to enable regulators\n"); + return ret; + } + usleep_range(400, 600); gpiod_set_value_cansleep(ov9282->reset_gpio, 0); @@ -890,6 +916,8 @@ static int ov9282_power_on(struct device *dev) error_reset: gpiod_set_value_cansleep(ov9282->reset_gpio, 1); + regulator_bulk_disable(ARRAY_SIZE(ov9282_supply_names), + ov9282->supplies); return ret; } @@ -909,6 +937,9 @@ static int ov9282_power_off(struct device *dev) gpiod_set_value_cansleep(ov9282->reset_gpio, 1); + regulator_bulk_disable(ARRAY_SIZE(ov9282_supply_names), + ov9282->supplies); + return 0; } |