From 62faabb61ae152e8289a00ffb3445f4c47777b33 Mon Sep 17 00:00:00 2001 From: Richard Oliver Date: Mon, 3 Jun 2024 16:02:41 +0100 Subject: [PATCH 1250/1350] media: i2c: imx500: Enable LED during SPI transfers The Raspberry Pi 'AI Camera' is equipped with an LED. Enable this LED during SPI transfers to indicate to the end-user that progress is being made during large tramsfers. Signed-off-by: Richard Oliver --- arch/arm/boot/dts/overlays/imx500-overlay.dts | 1 + arch/arm/boot/dts/overlays/imx500-pi5-overlay.dts | 1 + drivers/media/i2c/imx500.c | 6 ++++++ 3 files changed, 8 insertions(+) --- a/arch/arm/boot/dts/overlays/imx500-overlay.dts +++ b/arch/arm/boot/dts/overlays/imx500-overlay.dts @@ -105,6 +105,7 @@ &cam_node { status = "okay"; + led-gpios = <&spi_bridge 19 GPIO_ACTIVE_HIGH>; reset-gpios = <&spi_bridge 20 GPIO_ACTIVE_HIGH>; clocks = <&clk_aicam_gated>; spi = <&spi_bridgedev0>; --- a/arch/arm/boot/dts/overlays/imx500-pi5-overlay.dts +++ b/arch/arm/boot/dts/overlays/imx500-pi5-overlay.dts @@ -110,6 +110,7 @@ &cam_node { status = "okay"; + led-gpios = <&spi_bridge 19 GPIO_ACTIVE_HIGH>; reset-gpios = <&spi_bridge 20 GPIO_ACTIVE_HIGH>; clocks = <&clk_aicam_gated>; spi = <&spi_bridgedev0>; --- a/drivers/media/i2c/imx500.c +++ b/drivers/media/i2c/imx500.c @@ -965,6 +965,7 @@ struct imx500 { struct clk *xclk; u32 xclk_freq; + struct gpio_desc *led_gpio; struct gpio_desc *reset_gpio; struct regulator_bulk_data supplies[IMX500_NUM_SUPPLIES]; @@ -1990,7 +1991,10 @@ static int imx500_state_transition(struc } /* Do SPI transfer */ + gpiod_set_value_cansleep(imx500->led_gpio, 1); ret = imx500_spi_write(imx500, data, size); + gpiod_set_value_cansleep(imx500->led_gpio, 0); + imx500->fw_progress += size; if (ret < 0) @@ -2670,6 +2674,8 @@ static int imx500_probe(struct i2c_clien return ret; } + imx500->led_gpio = devm_gpiod_get_optional(dev, "led", GPIOD_OUT_LOW); + imx500->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);