summaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2024-04-15 15:10:38 +0200
committerHans Verkuil <hverkuil-cisco@xs4all.nl>2024-04-22 11:41:06 +0200
commit901c9229172392a119f34aa94b95247a2574173e (patch)
treeb761aa417e053b677d2352ebb68f142457138043 /drivers/media/i2c
parentmedia: hi556: Add support for external clock (diff)
downloadlinux-901c9229172392a119f34aa94b95247a2574173e.tar.xz
linux-901c9229172392a119f34aa94b95247a2574173e.zip
media: hi556: Add support for avdd regulator
On some ACPI platforms, such as Chromebooks the ACPI methods to change the power-state (_PS0 and _PS3) fully take care of powering on/off the sensor. On other ACPI platforms, such as e.g. various HP models with IPU6 + hi556 sensor, the sensor driver must control the avdd regulator itself. Add support for having the driver control the sensor's avdd regulator. Note this relies on the regulator-core providing a dummy regulator (which it does by default) on platforms where Linux is not aware of the avdd regulator. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r--drivers/media/i2c/hi556.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/media/i2c/hi556.c b/drivers/media/i2c/hi556.c
index 235caadf02dc..b440f386f062 100644
--- a/drivers/media/i2c/hi556.c
+++ b/drivers/media/i2c/hi556.c
@@ -9,6 +9,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-device.h>
#include <media/v4l2-fwnode.h>
@@ -638,6 +639,7 @@ struct hi556 {
/* GPIOs, clocks, etc. */
struct gpio_desc *reset_gpio;
struct clk *clk;
+ struct regulator *avdd;
/* Current mode */
const struct hi556_mode *cur_mode;
@@ -1286,8 +1288,17 @@ static int hi556_suspend(struct device *dev)
{
struct v4l2_subdev *sd = dev_get_drvdata(dev);
struct hi556 *hi556 = to_hi556(sd);
+ int ret;
gpiod_set_value_cansleep(hi556->reset_gpio, 1);
+
+ ret = regulator_disable(hi556->avdd);
+ if (ret) {
+ dev_err(dev, "failed to disable avdd: %d\n", ret);
+ gpiod_set_value_cansleep(hi556->reset_gpio, 0);
+ return ret;
+ }
+
clk_disable_unprepare(hi556->clk);
return 0;
}
@@ -1302,6 +1313,13 @@ static int hi556_resume(struct device *dev)
if (ret)
return ret;
+ ret = regulator_enable(hi556->avdd);
+ if (ret) {
+ dev_err(dev, "failed to enable avdd: %d\n", ret);
+ clk_disable_unprepare(hi556->clk);
+ return ret;
+ }
+
gpiod_set_value_cansleep(hi556->reset_gpio, 0);
usleep_range(5000, 5500);
return 0;
@@ -1337,6 +1355,12 @@ static int hi556_probe(struct i2c_client *client)
return dev_err_probe(&client->dev, PTR_ERR(hi556->clk),
"failed to get clock\n");
+ /* The regulator core will provide a "dummy" regulator if necessary */
+ hi556->avdd = devm_regulator_get(&client->dev, "avdd");
+ if (IS_ERR(hi556->avdd))
+ return dev_err_probe(&client->dev, PTR_ERR(hi556->avdd),
+ "failed to get avdd regulator\n");
+
full_power = acpi_dev_state_d0(&client->dev);
if (full_power) {
/* Ensure non ACPI managed resources are enabled */