diff options
author | Bryan O'Donoghue <bryan.odonoghue@linaro.org> | 2021-10-24 14:51:21 +0100 |
---|---|---|
committer | Bryan O'Donoghue <bryan.odonoghue@linaro.org> | 2022-04-08 16:33:34 +0100 |
commit | b4bf00dc2dc41bd6f2eedbae0aa6dbabcedc860d (patch) | |
tree | a986c539a244328edb84d8d10c73ebb9c5c3aea8 | |
parent | f34ed4c35e217c8d7bb84e600614cd84a2351b6c (diff) |
media: i2c: imx412: Add bulk regulator supportbr-v5.19b-sm8250-sensor
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
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
-rw-r--r-- | drivers/media/i2c/imx412.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/media/i2c/imx412.c b/drivers/media/i2c/imx412.c index a1aeff1f48c2..5dee2d23f3fe 100644 --- a/drivers/media/i2c/imx412.c +++ b/drivers/media/i2c/imx412.c @@ -16,6 +16,8 @@ #include <media/v4l2-fwnode.h> #include <media/v4l2-subdev.h> +#include <linux/regulator/consumer.h> + /* Streaming Mode */ #define IMX412_REG_MODE_SELECT 0x0100 #define IMX412_MODE_STANDBY 0x00 @@ -101,6 +103,12 @@ struct imx412_mode { struct imx412_reg_list reg_list; }; +static const char * const imx412_supply_names [] = { + "dovdd", /* Digital I/O power */ + "avdd", /* Analog power */ + "dvdd", /* Digital core power */ +}; + /** * struct imx412 - imx412 sensor device structure * @dev: Pointer to generic device @@ -128,6 +136,7 @@ struct imx412 { struct media_pad pad; struct gpio_desc *reset_gpio; struct clk *inclk; + struct regulator_bulk_data supplies[ARRAY_SIZE(imx412_supply_names)]; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_ctrl *link_freq_ctrl; struct v4l2_ctrl *pclk_ctrl; @@ -956,6 +965,18 @@ static int imx412_parse_hw_config(struct imx412 *imx412) return -EINVAL; } + if (!is_acpi_node(fwnode)) { + /* Get DT defined regulators */ + for (i = 0; i < ARRAY_SIZE(imx412_supply_names); i++) + imx412->supplies[i].supply = imx412_supply_names[i]; + + ret = devm_regulator_bulk_get(imx412->dev, + ARRAY_SIZE(imx412_supply_names), + imx412->supplies); + if (ret) + return ret; + } + ep = fwnode_graph_get_next_endpoint(fwnode, NULL); if (!ep) return -ENXIO; @@ -1021,6 +1042,15 @@ static int imx412_power_on(struct device *dev) struct imx412 *imx412 = to_imx412(sd); int ret; + ret = regulator_bulk_enable(ARRAY_SIZE(imx412_supply_names), + imx412->supplies); + if (ret < 0) { + dev_err(dev, "failed to enable regulators\n"); + goto error_reset; + } + + usleep_range(400, 600); + gpiod_set_value_cansleep(imx412->reset_gpio, 1); ret = clk_prepare_enable(imx412->inclk); @@ -1054,6 +1084,9 @@ static int imx412_power_off(struct device *dev) clk_disable_unprepare(imx412->inclk); + regulator_bulk_disable(ARRAY_SIZE(imx412_supply_names), + imx412->supplies); + return 0; } |