Message ID | 20180119183559.14430-1-nunojpg@gmail.com |
---|---|
State | New |
Headers | show |
Series | [1/2] sunxi: fix i2c support for sunxi H3/H5 | expand |
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. Thanks, Nuno On Fri, Jan 19, 2018 at 7:35 PM, Nuno Goncalves <nunojpg@gmail.com> wrote: > Tested to work in a Orange Pi Zero (H2+/H3), and checked against H5 datasheet. > > Signed-off-by: Nuno Goncalves <nunojpg@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 >
On Fri, Jan 19, 2018 at 07:35:59PM +0100, Nuno Goncalves wrote: > Tested to work in a Orange Pi Zero (H2+/H3), and checked against H5 datasheet. > > Signed-off-by: Nuno Goncalves <nunojpg@gmail.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Thanks! Maxime -- Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
On Fri, Jan 19, 2018 at 09:35:58PM +0100, Jernej Škrabec wrote: > 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. I should have looked closer, yes, you should keep the select on DM_I2C here. Maxime -- Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
On Fri, Jan 19, 2018 at 9:35 PM, Jernej Škrabec <jernej.skrabec@siol.net> wrote: > 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 Jernej. In fact I didn't manage to get it working with DM_I2C, even after adding the devices to the DT. Maybe you can give me some hints to bring it to work, as I am a uboot ousider. Is DM_I2C_COMPAT supposed to be defined? The i2c device should be in the DT but since there is no pinctrl driver I must also include the "sunxi_gpio_set_cfgpin()" already in my patch? Thanks, Nuno
I have tried for a while to make it work with DM_I2C but so far nothing. => i2c bus Bus -1: i2c@01c2ac00 Bus -1: i2c@01c2b000 => dm tree Class Probed Driver Name ---------------------------------------- root [ + ] root_drive root_driver simple_bus [ + ] generic_si `-- soc usb [ + ] ehci_sunxi |-- usb@01c1b000 usb_hub [ + ] usb_hub | `-- usb_hub usb [ + ] ohci_sunxi |-- usb@01c1b400 gpio [ + ] gpio_sunxi |-- pinctrl@01c20800 gpio [ + ] gpio_sunxi | |-- PA gpio [ + ] gpio_sunxi | |-- PB gpio [ + ] gpio_sunxi | |-- PC gpio [ + ] gpio_sunxi | |-- PD gpio [ + ] gpio_sunxi | |-- PE gpio [ + ] gpio_sunxi | |-- PF gpio [ + ] gpio_sunxi | |-- PG gpio [ + ] gpio_sunxi | |-- PH gpio [ + ] gpio_sunxi | `-- PI serial [ + ] ns16550_se |-- serial@01c28000 i2c [ ] i2c_mvtwsi |-- i2c@01c2ac00 i2c [ ] i2c_mvtwsi |-- i2c@01c2b000 eth [ + ] eth_sun8i_ |-- ethernet@1c30000 gpio [ + ] gpio_sunxi `-- pinctrl@01f02c00 gpio [ + ] gpio_sunxi `-- PL Is there any typical cause for this driver not to be probed? Thanks On Mon, Jan 22, 2018 at 10:18 AM, Nuno Gonçalves <nunojpg@gmail.com> wrote: > On Fri, Jan 19, 2018 at 9:35 PM, Jernej Škrabec <jernej.skrabec@siol.net> wrote: >> 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 Jernej. In fact I didn't manage to get it working with DM_I2C, > even after adding the devices to the DT. > > Maybe you can give me some hints to bring it to work, as I am a uboot ousider. > > Is DM_I2C_COMPAT supposed to be defined? > > The i2c device should be in the DT but since there is no pinctrl > driver I must also include the "sunxi_gpio_set_cfgpin()" already in > my patch? > > Thanks, > Nuno
Hi, Dne ponedeljek, 22. januar 2018 ob 19:41:31 CET je Nuno Gonçalves napisal(a): > I have tried for a while to make it work with DM_I2C but so far nothing. I'm not DM I2C expert, but if I recall correctly you have to have I2C child device defined in DT and successfully probed if you want I2C bus driver to be probed. Can you show your DT changes you made? Currently I don't remember any H3 or H5 board, which would have connected anything to I2C besides voltage regulator, which doesn't have DM aware driver in U-Boot. Best regards, Jernej > > => i2c bus > Bus -1: i2c@01c2ac00 > Bus -1: i2c@01c2b000 > => dm tree > Class Probed Driver Name > ---------------------------------------- > root [ + ] root_drive root_driver > simple_bus [ + ] generic_si `-- soc > usb [ + ] ehci_sunxi |-- usb@01c1b000 > usb_hub [ + ] usb_hub | `-- usb_hub > usb [ + ] ohci_sunxi |-- usb@01c1b400 > gpio [ + ] gpio_sunxi |-- pinctrl@01c20800 > gpio [ + ] gpio_sunxi | |-- PA > gpio [ + ] gpio_sunxi | |-- PB > gpio [ + ] gpio_sunxi | |-- PC > gpio [ + ] gpio_sunxi | |-- PD > gpio [ + ] gpio_sunxi | |-- PE > gpio [ + ] gpio_sunxi | |-- PF > gpio [ + ] gpio_sunxi | |-- PG > gpio [ + ] gpio_sunxi | |-- PH > gpio [ + ] gpio_sunxi | `-- PI > serial [ + ] ns16550_se |-- serial@01c28000 > i2c [ ] i2c_mvtwsi |-- i2c@01c2ac00 > i2c [ ] i2c_mvtwsi |-- i2c@01c2b000 > eth [ + ] eth_sun8i_ |-- ethernet@1c30000 > gpio [ + ] gpio_sunxi `-- pinctrl@01f02c00 > gpio [ + ] gpio_sunxi `-- PL > > Is there any typical cause for this driver not to be probed? > > Thanks > > On Mon, Jan 22, 2018 at 10:18 AM, Nuno Gonçalves <nunojpg@gmail.com> wrote: > > On Fri, Jan 19, 2018 at 9:35 PM, Jernej Škrabec <jernej.skrabec@siol.net> wrote: > >> 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 Jernej. In fact I didn't manage to get it working with DM_I2C, > > even after adding the devices to the DT. > > > > Maybe you can give me some hints to bring it to work, as I am a uboot > > ousider. > > > > Is DM_I2C_COMPAT supposed to be defined? > > > > The i2c device should be in the DT but since there is no pinctrl > > driver I must also include the "sunxi_gpio_set_cfgpin()" already in > > my patch? > > > > Thanks, > > Nuno
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);
Tested to work in a Orange Pi Zero (H2+/H3), and checked against H5 datasheet. Signed-off-by: Nuno Goncalves <nunojpg@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(-)