[U-Boot] [PATCH 1/2] sunxi: fix i2c support for sunxi H3/H5

Jernej Škrabec jernej.skrabec at siol.net
Fri Jan 19 20:35:58 UTC 2018


Hi,

Dne petek, 19. januar 2018 ob 19:38:52 CET je Nuno Gonçalves napisal(a):
> Sorry, there is only 1 patch in this series.
> 
> I would like comments regarding removing DM_I2C for MACH_SUNXI_H3_H5,
> as I didn't found a reason for it to be defined.

there is good reason to be there. When H3/H5 board has DE2/HDMI enabled, 
warning is shown when configuring, if DM_I2C is not selected. Since there 
should be no warning, DM_I2C has to stay.

This means that whatever you want to have attached to I2C, you have to have an 
entry in DT for it. Since there is no DM pinctrl driver, you have to put code 
somewhere, like you already done.

Besides, U-Boot wants to migrate towards DM drivers, no other way around. Last 
time I checked, DM I2C driver for H3/H5 should work, although it wasn't 
thoroughly tested from my side. So if there are issues with DM I2C driver, you 
have to fix it.

Best regards,
Jernej

> 
> Thanks,
> Nuno
> 
> On Fri, Jan 19, 2018 at 7:35 PM, Nuno Goncalves <nunojpg at gmail.com> wrote:
> > Tested to work in a Orange Pi Zero (H2+/H3), and checked against H5
> > datasheet.
> > 
> > Signed-off-by: Nuno Goncalves <nunojpg at gmail.com>
> > ---
> > 
> >  arch/arm/include/asm/arch-sunxi/gpio.h |  2 ++
> >  arch/arm/mach-sunxi/Kconfig            |  1 -
> >  board/sunxi/board.c                    | 10 +++++++++-
> >  3 files changed, 11 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/include/asm/arch-sunxi/gpio.h
> > b/arch/arm/include/asm/arch-sunxi/gpio.h index 24f85206c8..52884886d7
> > 100644
> > --- a/arch/arm/include/asm/arch-sunxi/gpio.h
> > +++ b/arch/arm/include/asm/arch-sunxi/gpio.h
> > @@ -149,6 +149,8 @@ enum sunxi_gpio_number {
> > 
> >  #define SUN6I_GPA_SDC2         5
> >  #define SUN6I_GPA_SDC3         4
> >  #define SUN8I_H3_GPA_UART0     2
> > 
> > +#define SUN8I_H3_H5_GPA_TWI0   2
> > +#define SUN8I_H3_H5_GPA_TWI1   3
> > 
> >  #define SUN4I_GPB_PWM          2
> >  #define SUN4I_GPB_TWI0         2
> > 
> > diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
> > index 1fededd0a3..a2a8599165 100644
> > --- a/arch/arm/mach-sunxi/Kconfig
> > +++ b/arch/arm/mach-sunxi/Kconfig
> > @@ -56,7 +56,6 @@ endif
> > 
> >  config MACH_SUNXI_H3_H5
> >  
> >         bool
> > 
> > -       select DM_I2C
> > 
> >         select SUNXI_DE2
> >         select SUNXI_DRAM_DW
> >         select SUNXI_DRAM_DW_32BIT
> > 
> > diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> > index dcacdf3e62..6b55aef202 100644
> > --- a/board/sunxi/board.c
> > +++ b/board/sunxi/board.c
> > @@ -93,6 +93,10 @@ void i2c_init_board(void)
> > 
> >         sunxi_gpio_set_cfgpin(SUNXI_GPH(14), SUN6I_GPH_TWI0);
> >         sunxi_gpio_set_cfgpin(SUNXI_GPH(15), SUN6I_GPH_TWI0);
> >         clock_twi_onoff(0, 1);
> > 
> > +#elif defined(CONFIG_MACH_SUNXI_H3_H5)
> > +       sunxi_gpio_set_cfgpin(SUNXI_GPA(11), SUN8I_H3_H5_GPA_TWI0);
> > +       sunxi_gpio_set_cfgpin(SUNXI_GPA(12), SUN8I_H3_H5_GPA_TWI0);
> > +       clock_twi_onoff(0, 1);
> > 
> >  #elif defined(CONFIG_MACH_SUN8I)
> >  
> >         sunxi_gpio_set_cfgpin(SUNXI_GPH(2), SUN8I_GPH_TWI0);
> >         sunxi_gpio_set_cfgpin(SUNXI_GPH(3), SUN8I_GPH_TWI0);
> > 
> > @@ -115,6 +119,10 @@ void i2c_init_board(void)
> > 
> >         sunxi_gpio_set_cfgpin(SUNXI_GPH(16), SUN6I_GPH_TWI1);
> >         sunxi_gpio_set_cfgpin(SUNXI_GPH(17), SUN6I_GPH_TWI1);
> >         clock_twi_onoff(1, 1);
> > 
> > +#elif defined(CONFIG_MACH_SUNXI_H3_H5)
> > +       sunxi_gpio_set_cfgpin(SUNXI_GPA(18), SUN8I_H3_H5_GPA_TWI1);
> > +       sunxi_gpio_set_cfgpin(SUNXI_GPA(19), SUN8I_H3_H5_GPA_TWI1);
> > +       clock_twi_onoff(1, 1);
> > 
> >  #elif defined(CONFIG_MACH_SUN8I)
> >  
> >         sunxi_gpio_set_cfgpin(SUNXI_GPH(4), SUN8I_GPH_TWI1);
> >         sunxi_gpio_set_cfgpin(SUNXI_GPH(5), SUN8I_GPH_TWI1);
> > 
> > @@ -137,7 +145,7 @@ void i2c_init_board(void)
> > 
> >         sunxi_gpio_set_cfgpin(SUNXI_GPH(18), SUN6I_GPH_TWI2);
> >         sunxi_gpio_set_cfgpin(SUNXI_GPH(19), SUN6I_GPH_TWI2);
> >         clock_twi_onoff(2, 1);
> > 
> > -#elif defined(CONFIG_MACH_SUN8I)
> > +#elif defined(CONFIG_MACH_SUN8I) /* same for CONFIG_MACH_SUNXI_H3_H5 */
> > 
> >         sunxi_gpio_set_cfgpin(SUNXI_GPE(12), SUN8I_GPE_TWI2);
> >         sunxi_gpio_set_cfgpin(SUNXI_GPE(13), SUN8I_GPE_TWI2);
> >         clock_twi_onoff(2, 1);
> > 
> > --
> > 2.11.0






More information about the U-Boot mailing list