Re: [PATCH 10/11] sunxi: video: Convert panel I2C to use DM_I2C

2021-08-22 Thread Heiko Schocher
Hello Samuel,

On 22.08.21 01:05, Samuel Holland wrote:
> Two displays supported by the sunxi display driver (each one used by a
> single board) require initialization over I2C. Both previously used
> i2c_soft; replace this with the i2c-gpio instance that already exists in
> those boards' device trees (sun5i-a13-utoo-p66 and sun6i-a31-colombus).
> 
> Since the i2c-gpio nodes are not referenced by any other node in the
> device trees (the device trees have no panel node), the I2C bus is
> selected by its node name.
> 
> This panel initialization code was the only i2c_soft user, so the
> i2c_soft GPIO setup code can be removed now as well.
> 
> Signed-off-by: Samuel Holland 
> ---
> 
>  arch/arm/mach-sunxi/Kconfig |  22 ++
>  board/sunxi/board.c |  44 +---
>  configs/Colombus_defconfig  |   6 --
>  configs/UTOO_P66_defconfig  |   3 -
>  drivers/video/anx9804.c | 107 ++--
>  drivers/video/anx9804.h |   5 +-
>  drivers/video/sunxi/sunxi_display.c |  55 +-
>  include/configs/sunxi-common.h  |  17 -
>  8 files changed, 102 insertions(+), 157 deletions(-)

Reviewed-by: Heiko Schocher 

bye,
Heiko

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de


[PATCH 10/11] sunxi: video: Convert panel I2C to use DM_I2C

2021-08-21 Thread Samuel Holland
Two displays supported by the sunxi display driver (each one used by a
single board) require initialization over I2C. Both previously used
i2c_soft; replace this with the i2c-gpio instance that already exists in
those boards' device trees (sun5i-a13-utoo-p66 and sun6i-a31-colombus).

Since the i2c-gpio nodes are not referenced by any other node in the
device trees (the device trees have no panel node), the I2C bus is
selected by its node name.

This panel initialization code was the only i2c_soft user, so the
i2c_soft GPIO setup code can be removed now as well.

Signed-off-by: Samuel Holland 
---

 arch/arm/mach-sunxi/Kconfig |  22 ++
 board/sunxi/board.c |  44 +---
 configs/Colombus_defconfig  |   6 --
 configs/UTOO_P66_defconfig  |   3 -
 drivers/video/anx9804.c | 107 ++--
 drivers/video/anx9804.h |   5 +-
 drivers/video/sunxi/sunxi_display.c |  55 +-
 include/configs/sunxi-common.h  |  17 -
 8 files changed, 102 insertions(+), 157 deletions(-)

diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index 4dd83a2280e..82b598e6e7f 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -929,28 +929,18 @@ config VIDEO_LCD_BL_PWM_ACTIVE_LOW
 config VIDEO_LCD_PANEL_I2C
bool "LCD panel needs to be configured via i2c"
depends on VIDEO_SUNXI
-   default n
-   select CMD_I2C
+   select DM_I2C
+   select DM_I2C_GPIO
---help---
Say y here if the LCD panel needs to be configured via i2c. This
will add a bitbang i2c controller using gpios to talk to the LCD.
 
-config VIDEO_LCD_PANEL_I2C_SDA
-   string "LCD panel i2c interface SDA pin"
+config VIDEO_LCD_PANEL_I2C_NAME
+   string "LCD panel i2c interface node name"
depends on VIDEO_LCD_PANEL_I2C
-   default "PG12"
+   default "i2c@0"
---help---
-   Set the SDA pin for the LCD i2c interface. 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_PANEL_I2C_SCL
-   string "LCD panel i2c interface SCL pin"
-   depends on VIDEO_LCD_PANEL_I2C
-   default "PG10"
-   ---help---
-   Set the SCL pin for the LCD i2c interface. This takes a string in the
-   format understood by sunxi_name_to_gpio, e.g. PH1 for pin 1 of port H.
-
+   Set the device tree node name for the LCD i2c interface.
 
 # Note only one of these may be selected at a time! But hidden choices are
 # not supported by Kconfig
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index 2b7d655678d..dabe6734b81 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -47,47 +47,6 @@
 #include 
 #include 
 
-#if defined(CONFIG_VIDEO_LCD_PANEL_I2C)
-/* So that we can use pin names in Kconfig and sunxi_name_to_gpio() */
-int soft_i2c_gpio_sda;
-int soft_i2c_gpio_scl;
-
-static int soft_i2c_board_init(void)
-{
-   int ret;
-
-   soft_i2c_gpio_sda = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_PANEL_I2C_SDA);
-   if (soft_i2c_gpio_sda < 0) {
-   printf("Error invalid soft i2c sda pin: '%s', err %d\n",
-  CONFIG_VIDEO_LCD_PANEL_I2C_SDA, soft_i2c_gpio_sda);
-   return soft_i2c_gpio_sda;
-   }
-   ret = gpio_request(soft_i2c_gpio_sda, "soft-i2c-sda");
-   if (ret) {
-   printf("Error requesting soft i2c sda pin: '%s', err %d\n",
-  CONFIG_VIDEO_LCD_PANEL_I2C_SDA, ret);
-   return ret;
-   }
-
-   soft_i2c_gpio_scl = sunxi_name_to_gpio(CONFIG_VIDEO_LCD_PANEL_I2C_SCL);
-   if (soft_i2c_gpio_scl < 0) {
-   printf("Error invalid soft i2c scl pin: '%s', err %d\n",
-  CONFIG_VIDEO_LCD_PANEL_I2C_SCL, soft_i2c_gpio_scl);
-   return soft_i2c_gpio_scl;
-   }
-   ret = gpio_request(soft_i2c_gpio_scl, "soft-i2c-scl");
-   if (ret) {
-   printf("Error requesting soft i2c scl pin: '%s', err %d\n",
-  CONFIG_VIDEO_LCD_PANEL_I2C_SCL, ret);
-   return ret;
-   }
-
-   return 0;
-}
-#else
-static int soft_i2c_board_init(void) { return 0; }
-#endif
-
 DECLARE_GLOBAL_DATA_PTR;
 
 void i2c_init_board(void)
@@ -312,8 +271,7 @@ int board_init(void)
 #endif
 #endif /* CONFIG_DM_MMC */
 
-   /* Uses dm gpio code so do this here and not in i2c_init_board() */
-   return soft_i2c_board_init();
+   return 0;
 }
 
 /*
diff --git a/configs/Colombus_defconfig b/configs/Colombus_defconfig
index 31541f898d4..270bd7d351a 100644
--- a/configs/Colombus_defconfig
+++ b/configs/Colombus_defconfig
@@ -13,15 +13,9 @@ CONFIG_VIDEO_LCD_DCLK_PHASE=0
 CONFIG_VIDEO_LCD_POWER="PH27"
 CONFIG_VIDEO_LCD_BL_EN="PM1"
 CONFIG_VIDEO_LCD_BL_PWM="PH13"
-CONFIG_VIDEO_LCD_PANEL_I2C_SDA="PA23"
-CONFIG_VIDEO_LCD_PANEL_I2C_SCL="PA24"
 CONFIG_VIDEO_LCD_PANEL_EDP_4_LANE_1620M_VIA_ANX9804=y
 #