i2c: sunxi: Support every i2c controller on each supported platform
Subsystems (4)
v4 cover i2c: sunxi: Support every i2c controller on each supported platform
Changes since v3:
* Kconfig support for MVTWSI
* Only enable twsi0 by default for platforms that always use it for the AXP
* Remove enabling other I2C busses by default on boards that expose them on pin headers since those might be used for some other functionalities
Changes since v2:
* I2C/TWI busses enable for Cubietruck as well
Changes since v1:
* Kconfig option to enable I2C/TWI controllers 1-4 (when applicable)
* Following patch to enable exposed busses on a few community-supported single-board-computers
This series adds support for every i2c controller found on sun4i/sun5i/sun6i/sun7i/sun8i platforms and shouldn't break support for Marvell platforms (orion5x, kirkwood, armada xp) the driver was originally written for.
Regarding sunxi, I double-checked that this doesn't conflict with VIDEO_LCD_PANEL_I2C.
I would be interested in having this tested on sun8i (A23), since I changed TWI0 muxing (to PH2-PH3 instead of PB0-PB1), according to the user manual and what is being done on the upstream Linux kernel. I2C was either not working before, or it was being muxed correctly by the bootrom, probably to communicate with the AXP, which luckily made it work in U-Boot too, since the I/O base address was already correct.
My use case here is that I'm writing a slave-side bitbang i2c implementation (with an Arduino) for a school project, using a Cubieboard2 as master and U-Boot as POC. However, only TWI1 was available through the expansion pins, hence the need for this series.
PATCH v4 1/3 i2c: mvtwsi: Support for up to 4 different controllers
Orion5x, Kirkwood and Armada XP platforms come with a single TWSI (I2C) MVTWSI controller. However, other platforms using MVTWSI may come with more: this is the case on Allwinner (sunxi) platforms, where up to 4 controllers can be found on the same chip.
--- arch/arm/include/asm/arch-sunxi/i2c.h | 2 +- arch/arm/mach-kirkwood/include/mach/config.h | 2 +- drivers/i2c/mvtwsi.c | 124 ++++++++++++++++++++------- include/configs/db-mv784mp-gp.h | 2 +- include/configs/edminiv2.h | 2 +- include/configs/maxbcm.h | 2 +- 6 files changed, 100 insertions(+), 34 deletions(-)
arch/arm/include/asm/arch-sunxi/i2c.h +1 -1
@@ -8,7 +8,7 @@#include <asm/arch/cpu.h> -#define CONFIG_I2C_MVTWSI_BASE SUNXI_TWI0_BASE +#define CONFIG_I2C_MVTWSI_BASE0 SUNXI_TWI0_BASE/* This is abp0-clk on sun4i/5i/7i / abp1-clk on sun6i/sun8i which is 24MHz */ #define CONFIG_SYS_TCLK 24000000
arch/arm/mach-kirkwood/include/mach/config.h +1 -1
@@ -44,7 +44,7 @@#define CONFIG_SYS_INIT_SP_ADDR 0xC8012000#define CONFIG_NR_DRAM_BANKS_MAX 2 -#define CONFIG_I2C_MVTWSI_BASE KW_TWSI_BASE +#define CONFIG_I2C_MVTWSI_BASE0 KW_TWSI_BASE#define MV_UART_CONSOLE_BASE KW_UART0_BASE#define MV_SATA_BASE KW_SATA_BASE#define MV_SATA_PORT0_OFFSET KW_SATA_PORT0_OFFSET
drivers/i2c/mvtwsi.c +95 -29
269 lines not on this page · raw message
include/configs/db-mv784mp-gp.h +1 -1
@@ -37,7 +37,7 @@/* I2C */ #define CONFIG_SYS_I2C #define CONFIG_SYS_I2C_MVTWSI -#define CONFIG_I2C_MVTWSI_BASE MVEBU_TWSI_BASE +#define CONFIG_I2C_MVTWSI_BASE0 MVEBU_TWSI_BASE#define CONFIG_SYS_I2C_SLAVE 0x0#define CONFIG_SYS_I2C_SPEED 100000
include/configs/edminiv2.h +1 -1
@@ -208,7 +208,7 @@#ifdef CONFIG_CMD_I2C #define CONFIG_SYS_I2C #define CONFIG_SYS_I2C_MVTWSI -#define CONFIG_I2C_MVTWSI_BASE ORION5X_TWSI_BASE +#define CONFIG_I2C_MVTWSI_BASE0 ORION5X_TWSI_BASE#define CONFIG_SYS_I2C_SLAVE 0x0#define CONFIG_SYS_I2C_SPEED 100000#endif
include/configs/maxbcm.h +1 -1
@@ -35,7 +35,7 @@/* I2C */ #define CONFIG_SYS_I2C #define CONFIG_SYS_I2C_MVTWSI -#define CONFIG_I2C_MVTWSI_BASE MVEBU_TWSI_BASE +#define CONFIG_I2C_MVTWSI_BASE0 MVEBU_TWSI_BASE#define CONFIG_SYS_I2C_SLAVE 0x0#define CONFIG_SYS_I2C_SPEED 100000
Signature · 1 line
1.9.1
PATCH v4 2/3 i2c: MVTWSI driver Kconfig bindings
In reply to Paul KocialkowskiThis adds the MVTWSI I2C driver to Kconfig bindings, to allow flexible selection e.g. based on other Kconfig properties.
--- drivers/i2c/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/i2c/Kconfig +7 -0
@@ -22,6 +22,13 @@ config DM_I2C_COMPAT to convert all code for a board in a single commit. It should not be enabled for any board in an official release. +config SYS_I2C_MVTWSI + bool "MVTWSI I2C driver" + default n + help + Support for the MVTWSI I2C controller driver. This I2C controller is + used on Orion5x, Kirkwood, Armada XP and Sunxi SoCs. + config SYS_I2C_UNIPHIER bool "UniPhier I2C driver" depends on ARCH_UNIPHIER && DM_I2C
Signature · 1 line
1.9.1
PATCH v4 2/3 i2c: MVTWSI driver Kconfig bindings
Le mardi 07 avril 2015 ? 22:20 +0200, Paul Kocialkowski a ?crit :
Quoted 2 lines
This adds the MVTWSI I2C driver to
Kconfigbindings, to allow flexible selection e.g. based on otherKconfigproperties.
Oh and if you can, please make MVTWSI lowercase in the commit title, I'm just realizing now how bad it hurts my eyes.
Quoted 13 lines
Signed-off-by Paul Kocialkowski <[email protected]>--- drivers/i2c/Kconfig | 7 +++++++ 1 file changed, 7 insertions(+)drivers/i2c/Kconfig +0
-0@@ -22,6 +22,13 @@ config DM_I2C_COMPAT to convert all code for a board in a single commit. It should not be enabled for any board in an official release.
drivers/i2c/Kconfig config DM_I2C_COMPAT · line 34
Quoted 10 lines
drivers/i2c/Kconfig +7
-0+config SYS_I2C_MVTWSI + bool "MVTWSI I2C driver" + default n + help + Support for the MVTWSI I2C controller driver. This I2C controller is + used on Orion5x, Kirkwood, Armada XP and Sunxi SoCs. + config SYS_I2C_UNIPHIER bool "UniPhier I2C driver" depends on ARCH_UNIPHIER && DM_I2C
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150407/16b89bb8/attachment.sig>
PATCH v4 3/3 sunxi: Complete i2c support for each supported platform
In reply to Paul KocialkowskiSunxi platforms come with at least 3 TWI (I2C) controllers and some platforms even have up to 5. This adds support for every controller on each supported platform, which is especially useful when using expansion ports on single-board- computers.
--- arch/arm/include/asm/arch-sunxi/cpu_sun4i.h | 7 +++ arch/arm/include/asm/arch-sunxi/gpio.h | 15 +++++- arch/arm/include/asm/arch-sunxi/i2c.h | 15 ++++++ board/sunxi/Kconfig | 43 ++++++++++++++++ board/sunxi/board.c | 77 ++++++++++++++++++++++++++++- include/configs/sunxi-common.h | 1 - 6 files changed, 154 insertions(+), 4 deletions(-)
arch/arm/include/asm/arch-sunxi/cpu_sun4i.h +7 -0
@@ -94,6 +94,13 @@#define SUNXI_TWI0_BASE 0x01c2ac00#define SUNXI_TWI1_BASE 0x01c2b000#define SUNXI_TWI2_BASE 0x01c2b400 +#ifdef CONFIG_MACH_SUN6I +#define SUNXI_TWI3_BASE 0x01c0b800 +#endif +#ifdef CONFIG_MACH_SUN7I +#define SUNXI_TWI3_BASE 0x01c2b800 +#define SUNXI_TWI4_BASE 0x01c2c000 +#endif #define SUNXI_CAN_BASE 0x01c2bc00
arch/arm/include/asm/arch-sunxi/gpio.h +14 -1
@@ -148,7 +148,11 @@ enum sunxi_gpio_number {#define SUN6I_GPA_SDC2 5#define SUN6I_GPA_SDC3 4 -#define SUNXI_GPB_TWI0 2 +#define SUN4I_GPB_TWI0 2 +#define SUN4I_GPB_TWI1 2 +#define SUN5I_GPB_TWI1 2 +#define SUN4I_GPB_TWI2 2 +#define SUN5I_GPB_TWI2 2#define SUN4I_GPB_UART0 2#define SUN5I_GPB_UART0 2
@@ -160,6 +164,7 @@ enum sunxi_gpio_number {#define SUNXI_GPD_LVDS0 3#define SUN5I_GPE_SDC2 3 +#define SUN8I_GPE_TWI2 3#define SUNXI_GPF_SDC0 2#define SUNXI_GPF_UART0 4
@@ -169,12 +174,20 @@ enum sunxi_gpio_number {#define SUN5I_GPG_SDC1 2#define SUN6I_GPG_SDC1 2#define SUN8I_GPG_SDC1 2 +#define SUN6I_GPG_TWI3 2#define SUN5I_GPG_UART1 4#define SUN4I_GPH_SDC1 5 +#define SUN6I_GPH_TWI0 2 +#define SUN8I_GPH_TWI0 2 +#define SUN6I_GPH_TWI1 2 +#define SUN8I_GPH_TWI1 2 +#define SUN6I_GPH_TWI2 2#define SUN6I_GPH_UART0 2#define SUNXI_GPI_SDC3 2 +#define SUN7I_GPI_TWI3 3 +#define SUN7I_GPI_TWI4 3#define SUN6I_GPL0_R_P2WI_SCK 3#define SUN6I_GPL1_R_P2WI_SDA 3
arch/arm/include/asm/arch-sunxi/i2c.h +15 -0
@@ -8,7 +8,22 @@#include <asm/arch/cpu.h> +#ifdef CONFIG_I2C0_ENABLE #define CONFIG_I2C_MVTWSI_BASE0 SUNXI_TWI0_BASE +#endif +#ifdef CONFIG_I2C1_ENABLE +#define CONFIG_I2C_MVTWSI_BASE1 SUNXI_TWI1_BASE +#endif +#ifdef CONFIG_I2C2_ENABLE +#define CONFIG_I2C_MVTWSI_BASE2 SUNXI_TWI2_BASE +#endif +#ifdef CONFIG_I2C3_ENABLE +#define CONFIG_I2C_MVTWSI_BASE3 SUNXI_TWI3_BASE +#endif +#ifdef CONFIG_I2C4_ENABLE +#define CONFIG_I2C_MVTWSI_BASE4 SUNXI_TWI4_BASE +#endif +/* This is abp0-clk on sun4i/5i/7i / abp1-clk on sun6i/sun8i which is 24MHz */ #define CONFIG_SYS_TCLK 24000000
board/sunxi/Kconfig +43 -0
49 lines not on this page · raw message
board/sunxi/board.c +75 -2
84 lines not on this page · raw message
include/configs/sunxi-common.h +0 -1
@@ -197,7 +197,6 @@#endif #define CONFIG_SYS_I2C -#define CONFIG_SYS_I2C_MVTWSI #define CONFIG_SYS_I2C_SPEED 400000#define CONFIG_SYS_I2C_SLAVE 0x7f
Signature · 1 line
1.9.1
v4 cover i2c: sunxi: Support every i2c controller on each supported platform
In reply to Paul KocialkowskiActually, I'd prefer that you do not merge this since some ifdef logic around controller 0 is still missing and mvtwsi code still assumes that controller 0 will be defined. It may be the case that users wish to only enable controller [1-4]. I think the Kconfig logic is also not necessary and not a great addition to have since sunxi will be the sole user of it (while other boards will keep using the option defined in the config header). I'll work those issues out soon and provide a v5.
What do you think about all this?
Le mardi 07 avril 2015 ? 22:19 +0200, Paul Kocialkowski a ?crit :
Quoted 33 lines
Changes since v3:
*Kconfigsupport for MVTWSI
* Only enable twsi0 by default for platforms that always use it for the AXP
* Remove enabling other I2C busses by default on boards that expose them on pin headers since those might be used for some other functionalitiesChanges since v2:
* I2C/TWI busses enable for Cubietruck as wellChanges since v1:
*Kconfigoption to enable I2C/TWI controllers 1-4 (when applicable)
* Following patch to enable exposed busses on a few community-supported single-board-computersThis series adds support for every i2c controller found on sun4i/sun5i/sun6i/sun7i/sun8i platforms and shouldn't break support for Marvell platforms (orion5x, kirkwood, armada xp) the driver was originally written for.
Regarding sunxi, I double-checked that this doesn't conflict with
VIDEO_LCD_PANEL_I2C.I would be interested in having this tested on sun8i (A23), since I changed TWI0 muxing (to PH2-PH3 instead of PB0-PB1), according to the user manual and what is being done on the upstream Linux kernel. I2C was either not working before, or it was being muxed correctly by the bootrom, probably to communicate with the AXP, which luckily made it work in U-Boot too, since the I/O base address was already correct.
My use case here is that I'm writing a slave-side bitbang i2c implementation (with an Arduino) for a school project, using a Cubieboard2 as master and U-Boot as POC. However, only TWI1 was available through the expansion pins, hence the need for this series.
Quoted 4 lines
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150408/6262202c/attachment.sig>
v4 cover i2c: sunxi: Support every i2c controller on each supported platform
Hi,
Quoted 9 lines · Paul Kocialkowski
Actually, I'd prefer that you do not merge this since some ifdef logic around controller 0 is still missing and mvtwsi code still assumes that controller 0 will be defined. It may be the case that users wish to only enable controller [1-4]. I think the
Kconfiglogic is also not necessary and not a great addition to have since sunxi will be the sole user of it (while other boards will keep using the option defined in the config header). I'll work those issues out soon and provide a v5.What do you think about all this?
I've not yet had a chance to take a look at your V4, but reducing the amount of necessary conditionals sounds good, so go for it.
Regards,
Hans
Quoted 40 lines
Le mardi 07 avril 2015 ? 22:19 +0200, Paul Kocialkowski a ?crit :
Quoted 37 lines
Changes since v3:
*Kconfigsupport for MVTWSI
* Only enable twsi0 by default for platforms that always use it for the AXP
* Remove enabling other I2C busses by default on boards that expose them on pin headers since those might be used for some other functionalitiesChanges since v2:
* I2C/TWI busses enable for Cubietruck as wellChanges since v1:
*Kconfigoption to enable I2C/TWI controllers 1-4 (when applicable)
* Following patch to enable exposed busses on a few community-supported single-board-computersThis series adds support for every i2c controller found on sun4i/sun5i/sun6i/sun7i/sun8i platforms and shouldn't break support for Marvell platforms (orion5x, kirkwood, armada xp) the driver was originally written for.
Regarding sunxi, I double-checked that this doesn't conflict with
VIDEO_LCD_PANEL_I2C.I would be interested in having this tested on sun8i (A23), since I changed TWI0 muxing (to PH2-PH3 instead of PB0-PB1), according to the user manual and what is being done on the upstream Linux kernel. I2C was either not working before, or it was being muxed correctly by the bootrom, probably to communicate with the AXP, which luckily made it work in U-Boot too, since the I/O base address was already correct.
My use case here is that I'm writing a slave-side bitbang i2c implementation (with an Arduino) for a school project, using a Cubieboard2 as master and U-Boot as POC. However, only TWI1 was available through the expansion pins, hence the need for this series.
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot