All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] pwm: sunxi: enable pwm0 support on sun7i
@ 2022-11-22 20:57 Giulio Benetti
  2022-11-22 20:57 ` [PATCH 2/2] sunxi: video: Add support for active low LCD power pin Giulio Benetti
  0 siblings, 1 reply; 3+ messages in thread
From: Giulio Benetti @ 2022-11-22 20:57 UTC (permalink / raw)
  To: u-boot; +Cc: Jagan Teki, Andre Przywara, Anatolij Gustschin, Giulio Benetti

sun7i pwm is equal to sun4i and sun5i so enable pwm0 the same way for
sun7i.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 arch/arm/include/asm/arch-sunxi/pwm.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-sunxi/pwm.h b/arch/arm/include/asm/arch-sunxi/pwm.h
index b89bddd2e8..1a1c6e0c54 100644
--- a/arch/arm/include/asm/arch-sunxi/pwm.h
+++ b/arch/arm/include/asm/arch-sunxi/pwm.h
@@ -26,7 +26,8 @@
 
 #define SUNXI_PWM_PERIOD_80PCT		0x04af03c0
 
-#if defined CONFIG_MACH_SUN4I || defined CONFIG_MACH_SUN5I
+#if defined CONFIG_MACH_SUN4I || defined CONFIG_MACH_SUN5I || \
+    defined CONFIG_MACH_SUN7I
 #define SUNXI_PWM_PIN0			SUNXI_GPB(2)
 #define SUNXI_PWM_MUX			SUN4I_GPB_PWM
 #endif
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] sunxi: video: Add support for active low LCD power pin
  2022-11-22 20:57 [PATCH 1/2] pwm: sunxi: enable pwm0 support on sun7i Giulio Benetti
@ 2022-11-22 20:57 ` Giulio Benetti
  2022-11-23 21:30   ` Andre Przywara
  0 siblings, 1 reply; 3+ messages in thread
From: Giulio Benetti @ 2022-11-22 20:57 UTC (permalink / raw)
  To: u-boot; +Cc: Jagan Teki, Andre Przywara, Anatolij Gustschin, Giulio Benetti

On some board gpio to power LCD can be active low, so let's add
CONFIG_VIDEO_LCD_POWER_ACTIVE_LOW to allow this.

Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 arch/arm/mach-sunxi/Kconfig         | 7 +++++++
 drivers/video/sunxi/sunxi_display.c | 4 ++++
 2 files changed, 11 insertions(+)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index dbe6005daa..a7375b53a6 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -867,6 +867,13 @@ config VIDEO_LCD_POWER
 	Set the power enable pin for the LCD panel. This takes a string in the
 	format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H.
 
+config VIDEO_LCD_POWER_ACTIVE_LOW
+	bool "LCD panel power enable pin is inverted"
+	depends on VIDEO_SUNXI
+	default n
+	---help---
+	Set this if the lcd power pin is active low.
+
 config VIDEO_LCD_RESET
 	string "LCD panel reset pin"
 	depends on VIDEO_SUNXI
diff --git a/drivers/video/sunxi/sunxi_display.c b/drivers/video/sunxi/sunxi_display.c
index 2ee6212c58..12b542d65b 100644
--- a/drivers/video/sunxi/sunxi_display.c
+++ b/drivers/video/sunxi/sunxi_display.c
@@ -588,7 +588,11 @@ static void sunxi_lcdc_panel_enable(void)
 	pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_POWER);
 	if (pin >= 0) {
 		gpio_request(pin, "lcd_power");
+#ifdef CONFIG_VIDEO_LCD_POWER_ACTIVE_LOW
+		gpio_direction_output(pin, 0);
+#else
 		gpio_direction_output(pin, 1);
+#endif
 	}
 
 	if (reset_pin >= 0)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] sunxi: video: Add support for active low LCD power pin
  2022-11-22 20:57 ` [PATCH 2/2] sunxi: video: Add support for active low LCD power pin Giulio Benetti
@ 2022-11-23 21:30   ` Andre Przywara
  0 siblings, 0 replies; 3+ messages in thread
From: Andre Przywara @ 2022-11-23 21:30 UTC (permalink / raw)
  To: Giulio Benetti; +Cc: u-boot, Jagan Teki, Anatolij Gustschin

On Tue, 22 Nov 2022 21:57:03 +0100
Giulio Benetti <giulio.benetti@benettiengineering.com> wrote:

Hi,

> On some board gpio to power LCD can be active low, so let's add
> CONFIG_VIDEO_LCD_POWER_ACTIVE_LOW to allow this.

This is all so very sadly outdated code, which could be all solved
very nicely by just looking at the DT.
Do you describe the backlight in the DT, for Linux, by any chance?
Can we at least try to read that information from there, instead of
adding Kconfig parameters for every variation?

> Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
> ---
>  arch/arm/mach-sunxi/Kconfig         | 7 +++++++
>  drivers/video/sunxi/sunxi_display.c | 4 ++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
> index dbe6005daa..a7375b53a6 100644
> --- a/arch/arm/mach-sunxi/Kconfig
> +++ b/arch/arm/mach-sunxi/Kconfig
> @@ -867,6 +867,13 @@ config VIDEO_LCD_POWER
>  	Set the power enable pin for the LCD panel. This takes a string in the
>  	format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H.
>  
> +config VIDEO_LCD_POWER_ACTIVE_LOW
> +	bool "LCD panel power enable pin is inverted"
> +	depends on VIDEO_SUNXI
> +	default n
> +	---help---
> +	Set this if the lcd power pin is active low.
> +
>  config VIDEO_LCD_RESET
>  	string "LCD panel reset pin"
>  	depends on VIDEO_SUNXI
> diff --git a/drivers/video/sunxi/sunxi_display.c b/drivers/video/sunxi/sunxi_display.c
> index 2ee6212c58..12b542d65b 100644
> --- a/drivers/video/sunxi/sunxi_display.c
> +++ b/drivers/video/sunxi/sunxi_display.c
> @@ -588,7 +588,11 @@ static void sunxi_lcdc_panel_enable(void)
>  	pin = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_POWER);
>  	if (pin >= 0) {
>  		gpio_request(pin, "lcd_power");
> +#ifdef CONFIG_VIDEO_LCD_POWER_ACTIVE_LOW

At the very least that should be using IS_ENABLED() and proper C code.

Cheers,
Andre

> +		gpio_direction_output(pin, 0);
> +#else
>  		gpio_direction_output(pin, 1);
> +#endif
>  	}
>  
>  	if (reset_pin >= 0)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-23 21:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-22 20:57 [PATCH 1/2] pwm: sunxi: enable pwm0 support on sun7i Giulio Benetti
2022-11-22 20:57 ` [PATCH 2/2] sunxi: video: Add support for active low LCD power pin Giulio Benetti
2022-11-23 21:30   ` Andre Przywara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.