#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-device.h>
#include <media/v4l2-fwnode.h>
},
};
+static const char * const ov13b10_supply_names[] = {
+ "dovdd", /* Digital I/O power */
+ "avdd", /* Analog power */
+ "dvdd", /* Digital core power */
+};
+
struct ov13b10 {
struct device *dev;
struct v4l2_ctrl_handler ctrl_handler;
struct clk *img_clk;
- struct regulator *avdd;
+ struct regulator_bulk_data supplies[ARRAY_SIZE(ov13b10_supply_names)];
struct gpio_desc *reset;
/* V4L2 Controls */
struct ov13b10 *ov13b10 = to_ov13b10(sd);
gpiod_set_value_cansleep(ov13b10->reset, 1);
-
- if (ov13b10->avdd)
- regulator_disable(ov13b10->avdd);
+ regulator_bulk_disable(ARRAY_SIZE(ov13b10_supply_names),
+ ov13b10->supplies);
clk_disable_unprepare(ov13b10->img_clk);
dev_err(dev, "failed to enable imaging clock: %d", ret);
return ret;
}
-
- if (ov13b10->avdd) {
- ret = regulator_enable(ov13b10->avdd);
- if (ret < 0) {
- dev_err(dev, "failed to enable avdd: %d", ret);
- clk_disable_unprepare(ov13b10->img_clk);
- return ret;
- }
+ ret = regulator_bulk_enable(ARRAY_SIZE(ov13b10_supply_names),
+ ov13b10->supplies);
+ if (ret < 0) {
+ dev_err(dev, "failed to enable regulators\n");
+ clk_disable_unprepare(ov13b10->img_clk);
+ return ret;
}
gpiod_set_value_cansleep(ov13b10->reset, 0);
unsigned long freq;
int ret;
- ov13b->reset = devm_gpiod_get_optional(ov13b->dev, "reset", GPIOD_OUT_LOW);
+ ov13b->reset = devm_gpiod_get_optional(ov13b->dev, "reset",
+ GPIOD_OUT_LOW);
if (IS_ERR(ov13b->reset))
return dev_err_probe(ov13b->dev, PTR_ERR(ov13b->reset),
"failed to get reset gpio\n");
"external clock %lu is not supported\n",
freq);
- ov13b->avdd = devm_regulator_get_optional(ov13b->dev, "avdd");
- if (IS_ERR(ov13b->avdd)) {
- ret = PTR_ERR(ov13b->avdd);
- ov13b->avdd = NULL;
- if (ret != -ENODEV)
- return dev_err_probe(ov13b->dev, ret,
- "failed to get avdd regulator\n");
- }
+ for (unsigned int i = 0; i < ARRAY_SIZE(ov13b10_supply_names); i++)
+ ov13b->supplies[i].supply = ov13b10_supply_names[i];
+ ret = devm_regulator_bulk_get(ov13b->dev,
+ ARRAY_SIZE(ov13b10_supply_names),
+ ov13b->supplies);
+ if (ret)
+ return dev_err_probe(ov13b->dev, ret,
+ "failed to get regulators\n");
return 0;
}