sunxi: fix i2c support for sunxi H3/H5
Subsystems (3)
PATCH 1/2 sunxi: fix i2c support for sunxi H3/H5
Tested to work in a Orange Pi Zero (H2+/H3), and checked against H5 datasheet.
--- 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(-)
arch/arm/include/asm/arch-sunxi/gpio.h +2 -0
@@ -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
arch/arm/mach-sunxi/Kconfig +0 -1
@@ -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
board/sunxi/board.c +9 -1
@@ -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 );
Signature · 1 line
2.11.0
PATCH 1/2 sunxi: fix i2c support for sunxi H3/H5
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
Quoted 72 lines · Nuno Goncalves
Tested to work in a Orange Pi Zero (H2+/H3), and checked against H5 datasheet.
Signed-off-by Nuno Goncalves <[email protected]>--- 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(-)arch/arm/include/asm/arch-sunxi/gpio.h +2
-0@@ -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 2arch/arm/mach-sunxi/Kconfig +0
-1@@ -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_32BITboard/sunxi/board.c +9
-2@@ -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
PATCH 1/2 sunxi: fix i2c support for sunxi H3/H5
Hi,
Dne petek, 19. januar 2018 ob 19:38:52 CET je Nuno Gonçalves napisal(a):
Quoted 4 lines
Sorry, there is only 1 patch in this series.
I would like comments regarding removing
DM_I2CforMACH_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
Quoted 100 lines
Thanks,
NunoQuoted 95 lines · Nuno Goncalves
Tested to work in a Orange Pi Zero (H2+/H3), and checked against H5 datasheet.
Signed-off-by Nuno Goncalves <[email protected]>---
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(-)(quoted diff) +0
-0
b/arch/arm/include/asm/arch-sunxi/gpio.hindex24f85206c8..52884886d7100644arch/arm/include/asm/arch-sunxi/gpio.h +2
-0@@ -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_PWM2
#defineSUN4I_GPB_TWI02arch/arm/mach-sunxi/Kconfig +0
-1@@ -56,7 +56,6 @@ endif config MACH_SUNXI_H3_H5 bool - select DM_I2Cselect
SUNXI_DE2
selectSUNXI_DRAM_DW
selectSUNXI_DRAM_DW_32BITboard/sunxi/board.c +4
-0@@ -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);board/sunxi/board.c +4
-0@@ -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);board/sunxi/board.c +1
-1@@ -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
PATCH 1/2 sunxi: fix i2c support for sunxi H3/H5
Quoted 12 lines · Jernej Škrabec
Hi,
Dne petek, 19. januar 2018 ob 19:38:52 CET je Nuno Gonçalves napisal(a):
Quoted 4 lines
Sorry, there is only 1 patch in this series.
I would like comments regarding removing
DM_I2CforMACH_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_I2Cis not selected. Since there should be no warning,DM_I2Chas to stay.
Quoted 8 lines
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
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180122/39b3db04/attachment.sig>
PATCH 1/2 sunxi: fix i2c support for sunxi H3/H5
In reply to Jernej ŠkrabecQuoted 16 lines · Jernej Škrabec
Hi,
Dne petek, 19. januar 2018 ob 19:38:52 CET je Nuno Gonçalves napisal(a):
Quoted 4 lines
Sorry, there is only 1 patch in this series.
I would like comments regarding removing
DM_I2CforMACH_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_I2Cis not selected. Since there should be no warning,DM_I2Chas 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.
Quoted 8 lines
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
PATCH 1/2 sunxi: fix i2c support for sunxi H3/H5
I have tried for a while to make it work with DM_I2C but so far nothing.
=> i2c bus
Bus -1: i2c at 01c2ac00
Bus -1: i2c at 01c2b000
=> dm tree
Class Probed Driver Name
----------------------------------------
root [ + ] root_drive root_driver simple_bus [ + ] generic_si `-- soc usb [ + ] ehci_sunxi |-- usb at 01c1b000 usb_hub [ + ] usb_hub | `-- usb_hub usb [ + ] ohci_sunxi |-- usb at 01c1b400 gpio [ + ] gpio_sunxi |-- pinctrl at 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 at 01c28000 i2c [ ] i2c_mvtwsi |-- i2c at 01c2ac00 i2c [ ] i2c_mvtwsi |-- i2c at 01c2b000 eth [ + ] eth_sun8i_ |-- ethernet at 1c30000 gpio [ + ] gpio_sunxi `-- pinctrl at 01f02c00 gpio [ + ] gpio_sunxi `-- PL
Is there any typical cause for this driver not to be probed?
Thanks
Quoted 39 lines · Nuno Gonçalves
Quoted 16 lines · Jernej Škrabec
Hi,
Dne petek, 19. januar 2018 ob 19:38:52 CET je Nuno Gonçalves napisal(a):
Quoted 4 lines
Sorry, there is only 1 patch in this series.
I would like comments regarding removing
DM_I2CforMACH_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_I2Cis not selected. Since there should be no warning,DM_I2Chas 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.
Quoted 8 lines
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,
JernejThanks 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_COMPATsupposed 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
PATCH 1/2 sunxi: fix i2c support for sunxi H3/H5
Hi,
Dne ponedeljek, 22. januar 2018 ob 19:41:31 CET je Nuno Gonçalves napisal(a):
Quoted 1 line
I have tried for a while to make it work with
DM_I2Cbut 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
Quoted 35 lines
=> i2c bus
Bus -1: i2c at01c2ac00
Bus -1: i2c at01c2b000
=> dm tree
Class Probed Driver Name
----------------------------------------root [ + ] root_drive root_driver simple_bus [ + ] generic_si `-- soc usb [ + ] ehci_sunxi |-- usb at 01c1b000 usb_hub [ + ] usb_hub | `-- usb_hub usb [ + ] ohci_sunxi |-- usb at 01c1b400 gpio [ + ] gpio_sunxi |-- pinctrl at 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 at 01c28000 i2c [ ] i2c_mvtwsi |-- i2c at 01c2ac00 i2c [ ] i2c_mvtwsi |-- i2c at 01c2b000 eth [ + ] eth_sun8i_ |-- ethernet at 1c30000 gpio [ + ] gpio_sunxi `-- pinctrl at 01f02c00 gpio [ + ] gpio_sunxi `-- PLIs there any typical cause for this driver not to be probed?
Thanks
Quoted 1 line · Nuno Gonçalves
On Fri, Jan 19, 2018 at 9:35 PM, Jernej Škrabec <[email protected]>
Quoted 38 lines · wrote:
Quoted 38 lines
Quoted 16 lines
Hi,
Dne petek, 19. januar 2018 ob 19:38:52 CET je Nuno Gonçalves napisal(a):
Quoted 4 lines
Sorry, there is only 1 patch in this series.
I would like comments regarding removing
DM_I2CforMACH_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_I2Cis not selected. Since there should be no warning,DM_I2Chas 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.
Quoted 7 lines
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,
JernejThanks 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_COMPATsupposed 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
PATCH 1/2 sunxi: fix i2c support for sunxi H3/H5
In reply to Nuno GoncalvesQuoted 3 lines · Nuno Goncalves
Tested to work in a Orange Pi Zero (H2+/H3), and checked against H5 datasheet.
Signed-off-by Nuno Goncalves <[email protected]>
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180122/204cac90/attachment.sig>