Re: [PATCH v1 1/5] media: lm3560: Add HWEN pin support

From: Sakari Ailus

Date: Fri Apr 17 2026 - 08:17:37 EST


Hi Svyatoslav,

On Fri, Apr 17, 2026 at 02:42:22PM +0300, Svyatoslav Ryhel wrote:
> Add HWEN - logic high hardware enable input found in LM3560 to ensure its
> proper operation.
>
> Signed-off-by: Svyatoslav Ryhel <clamor95@xxxxxxxxx>
> ---
> drivers/media/i2c/lm3560.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/drivers/media/i2c/lm3560.c b/drivers/media/i2c/lm3560.c
> index f4cc844f4e3c..e6af61415821 100644
> --- a/drivers/media/i2c/lm3560.c
> +++ b/drivers/media/i2c/lm3560.c
> @@ -11,6 +11,7 @@
>
> #include <linux/delay.h>
> #include <linux/module.h>
> +#include <linux/gpio.h>
> #include <linux/i2c.h>
> #include <linux/slab.h>
> #include <linux/mutex.h>
> @@ -45,6 +46,7 @@ enum led_enable {
> * @dev: pointer to &struct device
> * @pdata: platform data
> * @regmap: reg. map for i2c
> + * @hwen_gpio: line connected to hwen pin
> * @lock: muxtex for serial access.
> * @led_mode: V4L2 LED mode
> * @ctrls_led: V4L2 controls
> @@ -54,6 +56,7 @@ struct lm3560_flash {
> struct device *dev;
> struct lm3560_platform_data *pdata;
> struct regmap *regmap;
> + struct gpio_desc *hwen_gpio;
> struct mutex lock;
>
> enum v4l2_flash_led_mode led_mode;
> @@ -425,6 +428,12 @@ static int lm3560_probe(struct i2c_client *client)
> flash->dev = &client->dev;
> mutex_init(&flash->lock);
>
> + flash->hwen_gpio = devm_gpiod_get_optional(&client->dev, "enable",
> + GPIOD_OUT_HIGH);

Please add runtime PM support for this so it can be powered on when needed.

> + if (IS_ERR(flash->hwen_gpio))
> + return dev_err_probe(&client->dev, PTR_ERR(flash->hwen_gpio),
> + "failed to get hwen gpio\n");
> +
> rval = lm3560_subdev_init(flash, LM3560_LED0, "lm3560-led0");
> if (rval < 0)
> return rval;
> @@ -452,6 +461,8 @@ static void lm3560_remove(struct i2c_client *client)
> v4l2_ctrl_handler_free(&flash->ctrls_led[i]);
> media_entity_cleanup(&flash->subdev_led[i].entity);
> }
> +
> + gpiod_set_value_cansleep(flash->hwen_gpio, 0);
> }
>
> static const struct i2c_device_id lm3560_id_table[] = {

--
Kind regards,

Sakari Ailus