sunxi: i2c and pmic support
Subsystems (4)
cover sunxi: i2c and pmic support
Hi Albert, Heiko,
Here is a new attempt at getting i2c and pmic support added to the sunxi u-boot support.
Heiko, as you requested I've added a patch to convert the mvtwsi driver to CONFIG_SYS_I2C, can you please review this patch ?
Once this patch has been reviewed, I think it would be best for this series to go upstream through the u-boot-arm tree, since all the other changes are sunxi specific.
Note patch 5/5 is an unrelated sunxi bugfix for a bug I found while testing the i2c + pmic support.
Regards,
Hans
PATCH 1/5 mvtwsi: convert to CONFIG_SYS_I2C framework
Note this has only been tested on Allwinner sunxi devices (support for which gets introduced by a later patch).
The kirkwood changes have been compile tested using the wireless_space board config, the orion5x changes have been compile tested using the edminiv2 board config.
--- arch/arm/include/asm/arch-kirkwood/config.h | 3 +- drivers/i2c/Makefile | 2 +- drivers/i2c/mvtwsi.c | 69 +++++++++++++---------------- include/configs/edminiv2.h | 3 +- 4 files changed, 36 insertions(+), 41 deletions(-)
arch/arm/include/asm/arch-kirkwood/config.h +2 -1
@@ -129,7 +129,8 @@*/ #ifdef CONFIG_CMD_I2C #ifndef CONFIG_SYS_I2C_SOFT -#define CONFIG_I2C_MVTWSI +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MVTWSI #endif #define CONFIG_SYS_I2C_SLAVE 0x0#define CONFIG_SYS_I2C_SPEED 100000
drivers/i2c/Makefile +1 -1
@@ -7,7 +7,6 @@ obj-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o obj-$(CONFIG_DW_I2C) += designware_i2c.o -obj-$(CONFIG_I2C_MVTWSI) += mvtwsi.o obj-$(CONFIG_I2C_MV) += mv_i2c.o obj-$(CONFIG_I2C_MXS) += mxs_i2c.o obj-$(CONFIG_PCA9564_I2C) += pca9564_i2c.o
@@ -19,6 +18,7 @@ obj-$(CONFIG_SYS_I2C_DAVINCI) += davinci_i2c.o obj-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o obj-$(CONFIG_SYS_I2C_FTI2C010) += fti2c010.o obj-$(CONFIG_SYS_I2C_KONA) += kona_i2c.o +obj-$(CONFIG_SYS_I2C_MVTWSI) += mvtwsi.o obj-$(CONFIG_SYS_I2C_MXC) += mxc_i2c.o obj-$(CONFIG_SYS_I2C_OMAP24XX) += omap24xx_i2c.o obj-$(CONFIG_SYS_I2C_OMAP34XX) += omap24xx_i2c.o
drivers/i2c/mvtwsi.c +31 -38
132 lines not on this page · raw message
include/configs/edminiv2.h +2 -1
@@ -187,7 +187,8 @@* I2C related stuff */ #ifdef CONFIG_CMD_I2C -#define CONFIG_I2C_MVTWSI +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MVTWSI #define CONFIG_I2C_MVTWSI_BASE ORION5X_TWSI_BASE#define CONFIG_SYS_I2C_SLAVE 0x0#define CONFIG_SYS_I2C_SPEED 100000
Signature · 1 line
2.0.0
PATCH 1/5 mvtwsi: convert to CONFIG_SYS_I2C framework
Hello Hans,
Am 09.06.2014 17:15, schrieb Hans de Goede:
Quoted 7 lines
Note this has only been tested on Allwinner sunxi devices (support for which gets introduced by a later patch).
The kirkwood changes have been compile tested using the
wireless_spaceboard config, the orion5x changes have been compile tested using the edminiv2 board config.
Quoted 8 lines
Signed-off-by Hans de Goede<[email protected]>---
arch/arm/include/asm/arch-kirkwood/config.h| 3 +-drivers/i2c/Makefile | 2 +- drivers/i2c/mvtwsi.c | 69 +++++++++++++---------------- include/configs/edminiv2.h | 3 +- 4 files changed, 36 insertions(+), 41 deletions(-)
just a nitpick ...
[...]
Quoted 134 lines
drivers/i2c/mvtwsi.c +28
-31@@ -220,11 +220,10 @@ static int twsi_stop(int status)/* * Reset controller. -* Called at end of i2c_init unsuccessful i2c transactions. * Controller reset also resets the baud rate and slave address, so -* re-establish them. +* they must be re-established afterwards. */ -static void twsi_reset (u8 baud_rate,u8 slave_address) +static void twsi_reset (struct i2c_adapter *adap) {/* ensure controller will be enabled by any twsi*() function */ twsi_control_flags =MVTWSI_CONTROL_TWSIEN ;@@ -232,23 +231,17 @@ static void twsi_reset(u8 baud_rate, u8 slave_address)writel (0 ,&twsi->soft_reset);/* wait 2 ms -- this is what the Marvell LSP does */ udelay (20000 ); -/* set baud rate */ -writel (baud_rate,&twsi->baudrate); -/* set slave address even though we don't use it */ -writel (slave_address,&twsi->slave_address); -writel (0 ,&twsi->xtnd_slave_addr); -/* assert STOP but don't care for the result */ - (void )twsi_stop (0 ); }/* * I2C init called by cmd_i2c when doing 'i2c reset'. * Sets baud to the highest possible value not exceeding requested one. */ -void i2c_init (int requested_speed,int slaveadd) +static unsigned int twsi_i2c_set_bus_speed (struct i2c_adapter *adap, +unsigned int requested_speed) { -int tmp_speed, highest_speed, n, m; -int baud =0x44 ;/* baudrate at controller reset */ +unsigned int tmp_speed, highest_speed, n, m; +unsigned int baud =0x44 ;/* baudrate at controller reset */ /* use actual speed to collect progressively higher values */ highest_speed =0 ;@@ -263,8 +256,21 @@ void i2c_init(int requested_speed, int slaveadd) } } } +writel (baud,&twsi->baudrate); +return 0 ; +} + +static void twsi_i2c_init (struct i2c_adapter *adap,int speed,int slaveadd) +{/* reset controller */ -twsi_reset (baud, slaveadd); +twsi_reset (adap); +/* set speed */ +twsi_i2c_set_bus_speed (adap, speed); +/* set slave address even though we don't use it */ +writel (slaveadd,&twsi->slave_address); +writel (0 ,&twsi->xtnd_slave_addr); +/* assert STOP but don't care for the result */ + (void )twsi_stop (0 ); }/* @@ -294,7 +300,7 @@ static int i2c_begin(int expected_start_status, u8 addr)* I2C probe called by cmd_i2c when doing 'i2c probe'. * Begin read, nak data byte, end. */ -int i2c_probe (uchar chip) +static int twsi_i2c_probe (struct i2c_adapter *adap,uchar chip) {u8 dummy_byte;int status;@@ -320,12 +326,13 @@ int i2c_probe(uchar chip)* cmd_eeprom, so we have to choose here, and for the moment that'll be * a repeated start without a preceding stop. */ -int i2c_read (u8 dev,uint addr,int alen,u8 *data,int length) +static int twsi_i2c_read (struct i2c_adapter *adap,uchar chip,uint addr, +int alen,uchar *data,int length) {int status;/* begin i2c write to send the address bytes */ - status =i2c_begin (MVTWSI_STATUS_START , (dev<<1 )); + status =i2c_begin (MVTWSI_STATUS_START , (chip<<1 ));/* send addr bytes */ while ((status ==0 )&& alen--) status = twsi_send(addr>> (8*alen),@@ -333,7 +340,7 @@ int i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)/* begin i2c read to receive eeprom data bytes */ if (status ==0 ) status =i2c_begin ( -MVTWSI_STATUS_REPEATED_START , (dev<<1 ) |1 ); +MVTWSI_STATUS_REPEATED_START , (chip<<1 ) |1 );/* prepare ACK if at least one byte must be received */ if (length>0 ) twsi_control_flags |=MVTWSI_CONTROL_ACK ;@@ -355,12 +362,13 @@ int i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)* I2C write called by cmd_i2c when doing 'i2c write' and by cmd_eeprom.c * Begin write, send address byte(s), send data bytes, end. */ -int i2c_write (u8 dev,uint addr,int alen,u8 *data,int length) +static int twsi_i2c_write (struct i2c_adapter *adap,uchar chip,uint addr, +int alen,uchar *data,int length) {int status;/* begin i2c write to send the eeprom adress bytes then data bytes */ - status =i2c_begin (MVTWSI_STATUS_START , (dev<<1 )); + status =i2c_begin (MVTWSI_STATUS_START , (chip<<1 ));/* send addr bytes */ while ((status ==0 )&& alen--) status = twsi_send(addr>> (8*alen),@@ -374,21 +382,6 @@ int i2c_write(u8 dev, uint addr, int alen, u8 *data, int length)return status; } -/* -* Bus set routine: we only support bus 0. -*/ -int i2c_set_bus_num (unsigned int bus) -{ -if (bus>0 ) { -return -1 ; - } -return 0 ; -} -
drivers/i2c/mvtwsi.c int i2c_write(u8 dev, uint addr, int alen, u8 *data, int length) · line 387
Quoted 10 lines
drivers/i2c/mvtwsi.c +3
-7-/* -* Bus get routine: hard-return bus 0. -*/ -unsigned int i2c_get_bus_num (void ) -{ -return 0 ; -} +U_BOOT_I2C_ADAP_COMPLETE (twsi0, twsi_i2c_init, twsi_i2c_probe, + twsi_i2c_read, twsi_i2c_write, + twsi_i2c_set_bus_speed,100000 ,0 ,0 )
^
Should we have here defines for SPEED and SLAVE address ? ...
Quoted 5 lines
include/configs/edminiv2.h +0
-0
include/configs/edminiv2.h line 194
Quoted 9 lines
include/configs/edminiv2.h +2
-1@@ -187,7 +187,8 @@* I2C related stuff */ #ifdef CONFIG_CMD_I2C -#define CONFIG_I2C_MVTWSI +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MVTWSI #define CONFIG_I2C_MVTWSI_BASE ORION5X_TWSI_BASE#define CONFIG_SYS_I2C_SLAVE 0x0#define CONFIG_SYS_I2C_SPEED 100000
... and use them here instead CONFIG_SYS_I2C_SLAVE and CONFIG_SYS_I2C_SPEED ?
and please add a description for it in the README.
Beside of that, you can add my:
Thanks!
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 1/5 mvtwsi: convert to CONFIG_SYS_I2C framework
Hi,
Quoted 167 lines · Heiko Schocher
Hello Hans,
Am 09.06.2014 17:15, schrieb Hans de Goede:
Quoted 7 lines
Note this has only been tested on Allwinner sunxi devices (support for which gets introduced by a later patch).
The kirkwood changes have been compile tested using the
wireless_spaceboard config, the orion5x changes have been compile tested using the edminiv2 board config.Quoted 8 lines
Signed-off-by Hans de Goede<[email protected]>---
arch/arm/include/asm/arch-kirkwood/config.h| 3 +-drivers/i2c/Makefile | 2 +- drivers/i2c/mvtwsi.c | 69 +++++++++++++---------------- include/configs/edminiv2.h | 3 +- 4 files changed, 36 insertions(+), 41 deletions(-)just a nitpick ...
[...]
Quoted 134 lines
drivers/i2c/mvtwsi.c +28
-31@@ -220,11 +220,10 @@ static int twsi_stop(int status)/* * Reset controller. -* Called at end of i2c_init unsuccessful i2c transactions. * Controller reset also resets the baud rate and slave address, so -* re-establish them. +* they must be re-established afterwards. */ -static void twsi_reset (u8 baud_rate,u8 slave_address) +static void twsi_reset (struct i2c_adapter *adap) {/* ensure controller will be enabled by any twsi*() function */ twsi_control_flags =MVTWSI_CONTROL_TWSIEN ;@@ -232,23 +231,17 @@ static void twsi_reset(u8 baud_rate, u8 slave_address)writel (0 ,&twsi->soft_reset);/* wait 2 ms -- this is what the Marvell LSP does */ udelay (20000 ); -/* set baud rate */ -writel (baud_rate,&twsi->baudrate); -/* set slave address even though we don't use it */ -writel (slave_address,&twsi->slave_address); -writel (0 ,&twsi->xtnd_slave_addr); -/* assert STOP but don't care for the result */ - (void )twsi_stop (0 ); }/* * I2C init called by cmd_i2c when doing 'i2c reset'. * Sets baud to the highest possible value not exceeding requested one. */ -void i2c_init (int requested_speed,int slaveadd) +static unsigned int twsi_i2c_set_bus_speed (struct i2c_adapter *adap, +unsigned int requested_speed) { -int tmp_speed, highest_speed, n, m; -int baud =0x44 ;/* baudrate at controller reset */ +unsigned int tmp_speed, highest_speed, n, m; +unsigned int baud =0x44 ;/* baudrate at controller reset */ /* use actual speed to collect progressively higher values */ highest_speed =0 ;@@ -263,8 +256,21 @@ void i2c_init(int requested_speed, int slaveadd) } } } +writel (baud,&twsi->baudrate); +return 0 ; +} + +static void twsi_i2c_init (struct i2c_adapter *adap,int speed,int slaveadd) +{/* reset controller */ -twsi_reset (baud, slaveadd); +twsi_reset (adap); +/* set speed */ +twsi_i2c_set_bus_speed (adap, speed); +/* set slave address even though we don't use it */ +writel (slaveadd,&twsi->slave_address); +writel (0 ,&twsi->xtnd_slave_addr); +/* assert STOP but don't care for the result */ + (void )twsi_stop (0 ); }/* @@ -294,7 +300,7 @@ static int i2c_begin(int expected_start_status, u8 addr)* I2C probe called by cmd_i2c when doing 'i2c probe'. * Begin read, nak data byte, end. */ -int i2c_probe (uchar chip) +static int twsi_i2c_probe (struct i2c_adapter *adap,uchar chip) {u8 dummy_byte;int status;@@ -320,12 +326,13 @@ int i2c_probe(uchar chip)* cmd_eeprom, so we have to choose here, and for the moment that'll be * a repeated start without a preceding stop. */ -int i2c_read (u8 dev,uint addr,int alen,u8 *data,int length) +static int twsi_i2c_read (struct i2c_adapter *adap,uchar chip,uint addr, +int alen,uchar *data,int length) {int status;/* begin i2c write to send the address bytes */ - status =i2c_begin (MVTWSI_STATUS_START , (dev<<1 )); + status =i2c_begin (MVTWSI_STATUS_START , (chip<<1 ));/* send addr bytes */ while ((status ==0 )&& alen--) status = twsi_send(addr>> (8*alen),@@ -333,7 +340,7 @@ int i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)/* begin i2c read to receive eeprom data bytes */ if (status ==0 ) status =i2c_begin ( -MVTWSI_STATUS_REPEATED_START , (dev<<1 ) |1 ); +MVTWSI_STATUS_REPEATED_START , (chip<<1 ) |1 );/* prepare ACK if at least one byte must be received */ if (length>0 ) twsi_control_flags |=MVTWSI_CONTROL_ACK ;@@ -355,12 +362,13 @@ int i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)* I2C write called by cmd_i2c when doing 'i2c write' and by cmd_eeprom.c * Begin write, send address byte(s), send data bytes, end. */ -int i2c_write (u8 dev,uint addr,int alen,u8 *data,int length) +static int twsi_i2c_write (struct i2c_adapter *adap,uchar chip,uint addr, +int alen,uchar *data,int length) {int status;/* begin i2c write to send the eeprom adress bytes then data bytes */ - status =i2c_begin (MVTWSI_STATUS_START , (dev<<1 )); + status =i2c_begin (MVTWSI_STATUS_START , (chip<<1 ));/* send addr bytes */ while ((status ==0 )&& alen--) status = twsi_send(addr>> (8*alen),@@ -374,21 +382,6 @@ int i2c_write(u8 dev, uint addr, int alen, u8 *data, int length)return status; } -/* -* Bus set routine: we only support bus 0. -*/ -int i2c_set_bus_num (unsigned int bus) -{ -if (bus>0 ) { -return -1 ; - } -return 0 ; -} -drivers/i2c/mvtwsi.c int i2c_write(u8 dev, uint addr, int alen, u8 *data, int length) · line 387
Quoted 10 lines
drivers/i2c/mvtwsi.c +3
-7-/* -* Bus get routine: hard-return bus 0. -*/ -unsigned int i2c_get_bus_num (void ) -{ -return 0 ; -} +U_BOOT_I2C_ADAP_COMPLETE (twsi0, twsi_i2c_init, twsi_i2c_probe, + twsi_i2c_read, twsi_i2c_write, + twsi_i2c_set_bus_speed,100000 ,0 ,0 )^
Quoted 1 line
Should we have here defines for SPEED and SLAVE address ? ...
I copied this from tegra, but I see that all other converted drivers use CONFIG_SYS_I2C_SPEED and CONFIG_SYS_I2C_SLAVE here, will fix for v2.
Quoted 17 lines
Quoted 6 lines
include/configs/edminiv2.h +0
-0include/configs/edminiv2.h line 194
Quoted 9 lines
include/configs/edminiv2.h +2
-1@@ -187,7 +187,8 @@* I2C related stuff */ #ifdef CONFIG_CMD_I2C -#define CONFIG_I2C_MVTWSI +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MVTWSI #define CONFIG_I2C_MVTWSI_BASE ORION5X_TWSI_BASE#define CONFIG_SYS_I2C_SLAVE 0x0#define CONFIG_SYS_I2C_SPEED 100000... and use them here instead
CONFIG_SYS_I2C_SLAVEandCONFIG_SYS_I2C_SPEED?
Since mvtwsi.c only supports a single host (for now at least), and since the existing kirkwood and orion code already use the standard CONFIG_SYS_I2C_SLAVE and CONFIG_SYS_I2C_SPEED defines I've opted to simply go with those instead of adding mvtwsi specific defines.
v2 of this set coming up.
Quoted 5 lines
and please add a description for it in the README.
Beside of that, you can add my:
Acked-by Heiko Schocher <[email protected]>
Regards,
Hans
PATCH 1/5 mvtwsi: convert to CONFIG_SYS_I2C framework
In reply to Hans de GoedeQuoted 37 lines
-----Original Message-----
From: u-boot-bounces at lists.denx.de [mailto:u-boot- bounces at lists.denx.de] On Behalf Of Hans de Goede
Sent: 09 June 2014 20:45
To: Albert ARIBAUD; Heiko Schocher
Cc: u-boot at lists.denx.de; Ian Campbell
Subject: [U-Boot] [PATCH 1/5] mvtwsi: convert toCONFIG_SYS_I2CframeworkNote this has only been tested on Allwinner sunxi devices (support for which
gets introduced by a later patch).The kirkwood changes have been compile tested using the
wireless_spaceboard
config, the orion5x changes have been compile tested using the edminiv2 board
config.Signed-off-by Hans de Goede <[email protected]>--- arch/arm/include/asm/arch-kirkwood/config.h | 3 +- drivers/i2c/Makefile | 2 +- drivers/i2c/mvtwsi.c | 69 +++++++++++++---------------- include/configs/edminiv2.h | 3 +- 4 files changed, 36 insertions(+), 41 deletions(-)(quoted diff) +0
-0
kirkwood/config.hb/arch/arm/include/asm/arch-kirkwood/config.h
index 7a688e4..f7bfa0e 100644
arch/arm/include/asm/arch-kirkwood/config.h line 133
Quoted 6 lines
arch/arm/include/asm/arch-kirkwood/config.h +2
-1@@ -129,7 +129,8 @@*/ #ifdef CONFIG_CMD_I2C #ifndef CONFIG_SYS_I2C_SOFT -#define CONFIG_I2C_MVTWSI +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MVTWSI
These are bit risky changes, I hope it do not break the compatibility with other boards like guruplug, openrd and so on...
Unfortunately I do not have boards to validate..
So please kindly make sure you test them well.
Regards...
Prafulla . . .
Quoted 224 lines
arch/arm/include/asm/arch-kirkwood/config.h +0
-0#endif #define CONFIG_SYS_I2C_SLAVE 0x0#define CONFIG_SYS_I2C_SPEED 100000drivers/i2c/Makefile +0
-1@@ -7,7 +7,6 @@ obj-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o obj-$(CONFIG_DW_I2C) += designware_i2c.o -obj-$(CONFIG_I2C_MVTWSI) += mvtwsi.o obj-$(CONFIG_I2C_MV) += mv_i2c.o obj-$(CONFIG_I2C_MXS) += mxs_i2c.o obj-$(CONFIG_PCA9564_I2C) += pca9564_i2c.o@@ -19,6 +18,7 @@ obj-$(CONFIG_SYS_I2C_DAVINCI) +=davinci_i2c.o
obj-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o obj-$(CONFIG_SYS_I2C_FTI2C010) += fti2c010.o obj-$(CONFIG_SYS_I2C_KONA) += kona_i2c.odrivers/i2c/Makefile +1
-0+obj-$(CONFIG_SYS_I2C_MVTWSI) += mvtwsi.o obj-$(CONFIG_SYS_I2C_MXC) += mxc_i2c.o obj-$(CONFIG_SYS_I2C_OMAP24XX) += omap24xx_i2c.o obj-$(CONFIG_SYS_I2C_OMAP34XX) += omap24xx_i2c.odrivers/i2c/mvtwsi.c +0
-1@@ -220,11 +220,10 @@ static int twsi_stop(int status)/* * Reset controller. -* Called at end of i2c_init unsuccessful i2c transactions.
* Controller reset also resets the baud rate and
slave address, so
- * re-establish them.
+ * they must be re-established afterwards. */drivers/i2c/mvtwsi.c +1
-1-static void twsi_reset (u8 baud_rate,u8 slave_address) +static void twsi_reset (struct i2c_adapter *adap) {/* ensure controller will be enabled by any twsi*() function */
drivers/i2c/mvtwsi.c +0
-7twsi_control_flags =MVTWSI_CONTROL_TWSIEN ;@@ -232,23 +231,17 @@ static void twsi_reset(u8 baud_rate, u8 slave_address)writel (0 , &twsi->soft_reset);/* wait 2 ms -- this is what the Marvell LSP does */ udelay (20000 ); -/* set baud rate */ -writel (baud_rate, &twsi->baudrate); -/* set slave address even though we don't use it */ -writel (slave_address, &twsi->slave_address); -writel (0 , &twsi->xtnd_slave_addr); -/* assert STOP but don't care for the result */ - (void )twsi_stop (0 ); }/* * I2C init called by cmd_i2c when doing 'i2c reset'. * Sets baud to the highest possible value not exceeding requested one.
*/drivers/i2c/mvtwsi.c +1
-1-void i2c_init (int requested_speed,int slaveadd) +static unsigned int twsi_i2c_set_bus_speed(struct
i2c_adapter*adap,drivers/i2c/mvtwsi.c +3
-2+ unsigned int requested_speed) { -int tmp_speed, highest_speed, n, m; -int baud =0x44 ;/* baudrate at controller reset */ +unsigned int tmp_speed, highest_speed, n, m; +unsigned int baud =0x44 ;/* baudrate at controller reset */
/* use actual speed to collect progressively higher
values */drivers/i2c/mvtwsi.c +14
-1highest_speed =0 ;@@ -263,8 +256,21 @@ void i2c_init(int requested_speed, int slaveadd) } } } +writel (baud, &twsi->baudrate); +return 0 ; +} + +static void twsi_i2c_init (struct i2c_adapter *adap,int speed,int slaveadd) +{/* reset controller */ -twsi_reset (baud ,slaveadd ); +twsi_reset (adap); +/* set speed */ +twsi_i2c_set_bus_speed (adap, speed); +/* set slave address even though we don't use it */ +writel (slaveadd, &twsi->slave_address); +writel (0 , &twsi->xtnd_slave_addr); +/* assert STOP but don't care for the result */ + (void )twsi_stop (0 ); }/*
drivers/i2c/mvtwsi.c +1
-1@@ -294,7 +300,7 @@ static int i2c_begin(intexpected_start_status, u8 addr) * I2C probe called by cmd_i2c when doing 'i2c probe'. * Begin read, nak data byte, end. */ -int i2c_probe (uchar chip) +static int twsi_i2c_probe (struct i2c_adapter *adap,uchar chip) {drivers/i2c/mvtwsi.c +0
-0u8 dummy_byte;int status;@@ -320,12 +326,13 @@ int i2c_probe(uchar chip)* cmd_eeprom, so we have to choose here, and for the moment that'll be
* a repeated start without a preceding stop. */
-inti2c_read(u8 dev, uint addr, int alen, u8 *data, int length)
+static int twsi_i2c_read(structi2c_adapter*adap, uchar chip, uint addr,drivers/i2c/mvtwsi.c +1
-1+ int alen, uchar *data, int length) { int status;/* begin i2c write to send the address bytes */ - status = i2c_begin(MVTWSI_STATUS_START, (dev <<1));
drivers/i2c/mvtwsi.c +1
-0+ status = i2c_begin(MVTWSI_STATUS_START, (chip <<1));
drivers/i2c/mvtwsi.c +1
-1/* send addr bytes */ while ((status ==0 ) && alen--) status = twsi_send(addr >> (8*alen),@@ -333,7 +340,7 @@ int i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)/* begin i2c read to receive eeprom data bytes */ if (status ==0 ) status =i2c_begin ( -MVTWSI_STATUS_REPEATED_START , (dev <<1 ) |1 ); +MVTWSI_STATUS_REPEATED_START , (chip <<1 ) | 1);/* prepare ACK if at least one byte must be
received */drivers/i2c/mvtwsi.c +0
-0if (length >0 ) twsi_control_flags |=MVTWSI_CONTROL_ACK ;@@ -355,12 +362,13 @@ int i2c_read(u8 dev, uint addr, int alen, u8 *data, int length) * I2C write called by cmd_i2c when doing 'i2c write'and by
cmd_eeprom.c
* Begin write, send address byte(s), send data bytes,
end.
*/
-inti2c_write(u8 dev, uint addr, int alen, u8 *data, int length)
+static int twsi_i2c_write(structi2c_adapter*adap, uchar chip, uint addr,drivers/i2c/mvtwsi.c +1
-0+ int alen, uchar *data, int length) { int status;/* begin i2c write to send the eeprom adress bytes then data bytes */
drivers/i2c/mvtwsi.c +0
-1- status = i2c_begin(MVTWSI_STATUS_START, (dev <<1));
drivers/i2c/mvtwsi.c +1
-0+ status = i2c_begin(MVTWSI_STATUS_START, (chip <<1));
drivers/i2c/mvtwsi.c +1
-18/* send addr bytes */ while ((status ==0 ) && alen--) status = twsi_send(addr >> (8*alen),@@ -374,21 +382,6 @@ int i2c_write(u8 dev, uint addr, int alen, u8 *data, int length) return status; } -/* -* Bus set routine: we only support bus 0. -*/ -int i2c_set_bus_num (unsigned int bus) -{ -if (bus >0 ) { -return -1 ; - } -return 0 ; -} - -/* -* Bus get routine: hard-return bus 0. -*/ -unsigned int i2c_get_bus_num (void ) -{ -return 0 ; -} +U_BOOT_I2C_ADAP_COMPLETE(twsi0, twsi_i2c_init,
twsi_i2c_probe,drivers/i2c/mvtwsi.c +2
-0+ twsi_i2c_read, twsi_i2c_write, + twsi_i2c_set_bus_speed, 100000, 0, 0)include/configs/edminiv2.h +2
-2@@ -187,7 +187,8 @@* I2C related stuff */ #ifdef CONFIG_CMD_I2C -#define CONFIG_I2C_MVTWSI +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MVTWSI #define CONFIG_I2C_MVTWSI_BASE ORION5X_TWSI_BASE#define CONFIG_SYS_I2C_SLAVE 0x0#define CONFIG_SYS_I2C_SPEED 100000 --2.0.0
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH 2/5 sunxi: Add i2c support
In reply to Hans de GoedeAdd support for the i2c controller found on all Allwinner sunxi SoCs, this is the same controller as found on the Marvell orion5x and kirkwood SoC families, with a slightly different register layout, so this patch uses the existing mvtwsi code.
--- arch/arm/cpu/armv7/sunxi/board.c | 6 ++++++ arch/arm/cpu/armv7/sunxi/u-boot-spl.lds | 5 +++++ arch/arm/include/asm/arch-sunxi/i2c.h | 15 +++++++++++++++ board/sunxi/board.c | 7 +++++++ drivers/i2c/mvtwsi.c | 18 ++++++++++++++++++ include/configs/sunxi-common.h | 8 ++++++++ 6 files changed, 59 insertions(+) create mode 100644 arch/arm/include/asm/arch-sunxi/i2c.h
arch/arm/cpu/armv7/sunxi/board.c +6 -0
@@ -11,6 +11,7 @@*/ #include <common.h> +#include <i2c.h> #include <netdev.h> #include <miiphy.h> #include <serial.h>
@@ -91,11 +92,16 @@ void s_init(void)clock_init ();timer_init ();gpio_init (); +i2c_init_board ();#ifdef CONFIG_SPL_BUILD gd = &gdata;preloader_console_init (); +#ifdef CONFIG_SPL_I2C_SUPPORT +/* Needed early by sunxi_board_init if PMU is enabled */ +i2c_init (CONFIG_SYS_I2C_SPEED ,CONFIG_SYS_I2C_SLAVE ); +#endif sunxi_board_init ();#endif }
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +5 -0
@@ -39,6 +39,11 @@ SECTIONS .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram . = ALIGN(4); + .u_boot_list : { + KEEP(*(SORT(.u_boot_list*))); + } > .sram + + . = ALIGN(4); __image_copy_end = .; _end = .;
arch/arm/include/asm/arch-sunxi/i2c.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Copyright 2014 - Hans de Goede <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#ifndef _SUNXI_I2C_H_ +#define _SUNXI_I2C_H_ + +#include <asm/arch/cpu.h> + +#define CONFIG_I2C_MVTWSI_BASE SUNXI_TWI0_BASE +/* This is abp0-clk on sun4i/5i/7i / abp1-clk on sun6i/sun8i which is 24MHz */ +#define CONFIG_SYS_TCLK 24000000 + +#endif
board/sunxi/board.c +7 -0
@@ -106,6 +106,13 @@ int board_mmc_init(bd_t *bis) }#endif +void i2c_init_board (void ) +{ +sunxi_gpio_set_cfgpin (SUNXI_GPB (0 ),SUNXI_GPB0_TWI0 ); +sunxi_gpio_set_cfgpin (SUNXI_GPB (1 ),SUNXI_GPB0_TWI0 ); +clock_twi_onoff (0 ,1 ); +} +#ifdef CONFIG_SPL_BUILD void sunxi_board_init (void ) {
drivers/i2c/mvtwsi.c +18 -0
@@ -22,6 +22,8 @@#include <asm/arch/orion5x.h> #elif defined(CONFIG_KIRKWOOD )#include <asm/arch/kirkwood.h> +#elif defined(CONFIG_SUNXI ) +#include <asm/arch/i2c.h> #else #error Driver mvtwsi not supported by SoC or board#endif
@@ -30,6 +32,20 @@* TWSI register structure */ +#ifdef CONFIG_SUNXI + +struct mvtwsi_registers { + u32 slave_address; + u32 xtnd_slave_addr; + u32 data; + u32 control; + u32 status; + u32 baudrate; + u32 soft_reset; +}; + +#else + struct mvtwsi_registers { u32 slave_address; u32 data;
@@ -43,6 +59,8 @@ struct mvtwsi_registers { u32 soft_reset; }; +#endif +/* * Control register fields */
include/configs/sunxi-common.h +8 -0
@@ -161,6 +161,14 @@#undef CONFIG_CMD_NET#undef CONFIG_CMD_NFS +/* I2C */ +#define CONFIG_SPL_I2C_SUPPORT +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MVTWSI +#define CONFIG_SYS_I2C_SPEED 400000 +#define CONFIG_SYS_I2C_SLAVE 0x7f +#define CONFIG_CMD_I2C +#ifndef CONFIG_CONS_INDEX #define CONFIG_CONS_INDEX 1/* UART0 */ #endif
Signature · 1 line
2.0.0
PATCH 2/5 sunxi: Add i2c support
Hi Hans,
Quoted 4 lines · Hans de Goede
Add support for the i2c controller found on all Allwinner sunxi SoCs, this is the same controller as found on the Marvell orion5x and kirkwood SoC families, with a slightly different register layout, so this patch uses the existing mvtwsi code.
Should not affect orion or kirkwood, since you're just adding a variant to the "include switch case" where it was intended; but just in case, I'm Cc:ing Prafulla here.
Quoted 46 lines
Signed-off-by Hans de Goede <[email protected]>Acked-by Ian Campbell <[email protected]>--- arch/arm/cpu/armv7/sunxi/board.c | 6 ++++++ arch/arm/cpu/armv7/sunxi/u-boot-spl.lds | 5 +++++ arch/arm/include/asm/arch-sunxi/i2c.h | 15 +++++++++++++++ board/sunxi/board.c | 7 +++++++ drivers/i2c/mvtwsi.c | 18 ++++++++++++++++++ include/configs/sunxi-common.h | 8 ++++++++ 6 files changed, 59 insertions(+) create mode 100644 arch/arm/include/asm/arch-sunxi/i2c.harch/arm/cpu/armv7/sunxi/board.c +6
-0@@ -11,6 +11,7 @@*/ #include <common.h> +#include <i2c.h> #include <netdev.h> #include <miiphy.h> #include <serial.h> @@ -91,11 +92,16 @@ void s_init(void)clock_init ();timer_init ();gpio_init (); +i2c_init_board ();#ifdef CONFIG_SPL_BUILD gd = &gdata;preloader_console_init (); +#ifdef CONFIG_SPL_I2C_SUPPORT +/* Needed early by sunxi_board_init if PMU is enabled */ +i2c_init (CONFIG_SYS_I2C_SPEED ,CONFIG_SYS_I2C_SLAVE ); +#endif sunxi_board_init ();#endif }arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +0
-0
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds SECTIONS · line 46
Quoted 8 lines
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +5
-0@@ -39,6 +39,11 @@ SECTIONS .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram . = ALIGN(4); + .u_boot_list : { + KEEP(*(SORT(.u_boot_list*))); + } > .sram + + . = ALIGN(4);
This adds the U-Boot commands section to an SPL linker script, which seems to imply it was not there before. Are you actually adding command line to the SPL of this board family?
Quoted 94 lines
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +0
-0__image_copy_end = .; _end = .;arch/arm/include/asm/arch-sunxi/i2c.h new file +15
-0@@ -0,0 +1,15 @@ +/* +* Copyright 2014 - Hans de Goede <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#ifndef _SUNXI_I2C_H_ +#define _SUNXI_I2C_H_ + +#include <asm/arch/cpu.h> + +#define CONFIG_I2C_MVTWSI_BASE SUNXI_TWI0_BASE +/* This is abp0-clk on sun4i/5i/7i / abp1-clk on sun6i/sun8i which is 24MHz */ +#define CONFIG_SYS_TCLK 24000000 + +#endif board/sunxi/board.c +7
-0@@ -106,6 +106,13 @@ int board_mmc_init(bd_t *bis) }#endif +void i2c_init_board (void ) +{ +sunxi_gpio_set_cfgpin (SUNXI_GPB (0 ),SUNXI_GPB0_TWI0 ); +sunxi_gpio_set_cfgpin (SUNXI_GPB (1 ),SUNXI_GPB0_TWI0 ); +clock_twi_onoff (0 ,1 ); +} +#ifdef CONFIG_SPL_BUILD void sunxi_board_init (void ) {drivers/i2c/mvtwsi.c +18
-0@@ -22,6 +22,8 @@#include <asm/arch/orion5x.h> #elif defined(CONFIG_KIRKWOOD )#include <asm/arch/kirkwood.h> +#elif defined(CONFIG_SUNXI ) +#include <asm/arch/i2c.h> #else #error Driver mvtwsi not supported by SoC or board#endif @@ -30,6 +32,20 @@* TWSI register structure */ +#ifdef CONFIG_SUNXI + +struct mvtwsi_registers { + u32 slave_address; + u32 xtnd_slave_addr; + u32 data; + u32 control; + u32 status; + u32 baudrate; + u32 soft_reset; +}; + +#else + struct mvtwsi_registers { u32 slave_address; u32 data;@@ -43,6 +59,8 @@ struct mvtwsi_registers { u32 soft_reset; }; +#endif +/* * Control register fields */ include/configs/sunxi-common.h +1
-0@@ -161,6 +161,14 @@#undef CONFIG_CMD_NET#undef CONFIG_CMD_NFS +/* I2C */
include/configs/sunxi-common.h line 174
Quoted 10 lines
include/configs/sunxi-common.h +7
-0+#define CONFIG_SPL_I2C_SUPPORT +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MVTWSI +#define CONFIG_SYS_I2C_SPEED 400000 +#define CONFIG_SYS_I2C_SLAVE 0x7f +#define CONFIG_CMD_I2C +#ifndef CONFIG_CONS_INDEX #define CONFIG_CONS_INDEX 1/* UART0 */ #endif
Amicalement,
Signature · 1 line
Albert.
PATCH 2/5 sunxi: Add i2c support
Hi,
Quoted 5 lines · Albert ARIBAUD
Hi Hans,
On Mon, 9 Jun 2014 17:15:27 +0200, Hans de Goede <[email protected]> wrote:
Quoted 8 lines
Quoted 4 lines
Add support for the i2c controller found on all Allwinner sunxi SoCs, this is the same controller as found on the Marvell orion5x and kirkwood SoC families, with a slightly different register layout, so this patch uses the existing mvtwsi code.
Should not affect orion or kirkwood, since you're just adding a variant to the "include switch case" where it was intended; but just in case, I'm Cc:ing Prafulla here.
Ah, good idea, thanks. Prafulla, this patch indeed does not affect orion or kirkwood, but the previous patch in the series does, if you could review and/or test it that would be great. And sorry for not CC-ing you on that patch from the get go.
Regards,
Hans
Quoted 168 lines
Quoted 47 lines
Signed-off-by Hans de Goede <[email protected]>Acked-by Ian Campbell <[email protected]>--- arch/arm/cpu/armv7/sunxi/board.c | 6 ++++++ arch/arm/cpu/armv7/sunxi/u-boot-spl.lds | 5 +++++ arch/arm/include/asm/arch-sunxi/i2c.h | 15 +++++++++++++++ board/sunxi/board.c | 7 +++++++ drivers/i2c/mvtwsi.c | 18 ++++++++++++++++++ include/configs/sunxi-common.h | 8 ++++++++ 6 files changed, 59 insertions(+)create mode 100644
arch/arm/include/asm/arch-sunxi/i2c.harch/arm/cpu/armv7/sunxi/board.c +6
-0@@ -11,6 +11,7 @@*/ #include <common.h> +#include <i2c.h> #include <netdev.h> #include <miiphy.h> #include <serial.h> @@ -91,11 +92,16 @@ void s_init(void)clock_init ();timer_init ();gpio_init (); +i2c_init_board ();#ifdef CONFIG_SPL_BUILD gd = &gdata;preloader_console_init (); +#ifdef CONFIG_SPL_I2C_SUPPORT +/* Needed early by sunxi_board_init if PMU is enabled */ +i2c_init (CONFIG_SYS_I2C_SPEED ,CONFIG_SYS_I2C_SLAVE ); +#endif sunxi_board_init ();#endif }arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +0
-0arch/arm/cpu/armv7/sunxi/u-boot-spl.lds SECTIONS · line 46
Quoted 8 lines
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +5
-0@@ -39,6 +39,11 @@ SECTIONS .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sram . = ALIGN(4); + .u_boot_list : { + KEEP(*(SORT(.u_boot_list*))); + } > .sram + + . = ALIGN(4);This adds the U-Boot commands section to an SPL linker script, which seems to imply it was not there before. Are you actually adding command line to the SPL of this board family?
Quoted 94 lines
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +0
-0__image_copy_end = .; _end = .;arch/arm/include/asm/arch-sunxi/i2c.h new file +15
-0@@ -0,0 +1,15 @@ +/* +* Copyright 2014 - Hans de Goede <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#ifndef _SUNXI_I2C_H_ +#define _SUNXI_I2C_H_ + +#include <asm/arch/cpu.h> + +#define CONFIG_I2C_MVTWSI_BASE SUNXI_TWI0_BASE +/* This is abp0-clk on sun4i/5i/7i / abp1-clk on sun6i/sun8i which is 24MHz */ +#define CONFIG_SYS_TCLK 24000000 + +#endif board/sunxi/board.c +7
-0@@ -106,6 +106,13 @@ int board_mmc_init(bd_t *bis) }#endif +void i2c_init_board (void ) +{ +sunxi_gpio_set_cfgpin (SUNXI_GPB (0 ),SUNXI_GPB0_TWI0 ); +sunxi_gpio_set_cfgpin (SUNXI_GPB (1 ),SUNXI_GPB0_TWI0 ); +clock_twi_onoff (0 ,1 ); +} +#ifdef CONFIG_SPL_BUILD void sunxi_board_init (void ) {drivers/i2c/mvtwsi.c +18
-0@@ -22,6 +22,8 @@#include <asm/arch/orion5x.h> #elif defined(CONFIG_KIRKWOOD )#include <asm/arch/kirkwood.h> +#elif defined(CONFIG_SUNXI ) +#include <asm/arch/i2c.h> #else #error Driver mvtwsi not supported by SoC or board#endif @@ -30,6 +32,20 @@* TWSI register structure */ +#ifdef CONFIG_SUNXI + +struct mvtwsi_registers { + u32 slave_address; + u32 xtnd_slave_addr; + u32 data; + u32 control; + u32 status; + u32 baudrate; + u32 soft_reset; +}; + +#else + struct mvtwsi_registers { u32 slave_address; u32 data;@@ -43,6 +59,8 @@ struct mvtwsi_registers { u32 soft_reset; }; +#endif +/* * Control register fields */ include/configs/sunxi-common.h +1
-0@@ -161,6 +161,14 @@#undef CONFIG_CMD_NET#undef CONFIG_CMD_NFS +/* I2C */ include/configs/sunxi-common.h line 174
Quoted 10 lines
include/configs/sunxi-common.h +7
-0+#define CONFIG_SPL_I2C_SUPPORT +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MVTWSI +#define CONFIG_SYS_I2C_SPEED 400000 +#define CONFIG_SYS_I2C_SLAVE 0x7f +#define CONFIG_CMD_I2C +#ifndef CONFIG_CONS_INDEX #define CONFIG_CONS_INDEX 1/* UART0 */ #endif Amicalement,
PATCH 2/5 sunxi: Add i2c support
Quoted 33 lines
-----Original Message-----
From: Hans de Goede [mailto:hdegoede at redhat.com]
Sent: 09 June 2014 22:44
To: Albert ARIBAUD
Cc: Heiko Schocher; Henrik Nordstr?m; Ian Campbell; u- boot at lists.denx.de; Prafulla Wadaskar
Subject: Re: [PATCH 2/5] sunxi: Add i2c supportHi,
Quoted 3 lines · Albert ARIBAUD
Hi Hans,
On Mon, 9 Jun 2014 17:15:27 +0200, Hans de Goede
Quoted 3 lines
Quoted 1 line · wrote:
Add support for the i2c controller found on all
Allwinner sunxi SoCs,
Quoted 1 line
Quoted 1 line
this is the same controller as found on the Marvell
orion5x and kirkwood
Quoted 1 line
Quoted 1 line
SoC families, with a slightly different register
layout, so this patch uses
Quoted 3 lines
Quoted 1 line
the existing mvtwsi code.
Should not affect orion or kirkwood, since you're
just adding a
Quoted 1 line
variant to the "include switch case" where it was
intended; but just in
Quoted 1 line
case, I'm Cc:ing Prafulla here.
Quoted 7 lines
Ah, good idea, thanks. Prafulla, this patch indeed does not affect
orion or kirkwood, but the previous patch in the series does, if you
could review and/or test it that would be great. And sorry for not
CC-ing you on that patch from the get go.
That's okay Hans
Quoted 164 lines
Regards,
Hans
Quoted 5 lines
Quoted 5 lines
Signed-off-by Hans de Goede <[email protected]>Acked-by Ian Campbell <[email protected]>--- arch/arm/cpu/armv7/sunxi/board.c | 6++++++
Quoted 2 lines
Quoted 2 lines
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds | 5 +++++ arch/arm/include/asm/arch-sunxi/i2c.h | 15+++++++++++++++
Quoted 1 line
Quoted 1 line
board/sunxi/board.c | 7+++++++
Quoted 1 line
Quoted 1 line
drivers/i2c/mvtwsi.c | 18++++++++++++++++++
Quoted 1 line
Quoted 1 line
include/configs/sunxi-common.h | 8++++++++
Quoted 2 lines
Quoted 2 lines
6 files changed, 59 insertions(+)create mode 100644
arch/arm/include/asm/arch-
sunxi/i2c.hQuoted 2 lines
Review
Quoted 2 lines
(quoted diff) +0
-0
b/arch/arm/cpu/armv7/sunxi/board.cQuoted 17 lines
Quoted 17 lines
index 1e506b5..024c8c1 100644
arch/arm/cpu/armv7/sunxi/board.c +2
-0@@ -11,6 +11,7 @@*/ #include <common.h> +#include <i2c.h> #include <netdev.h> #include <miiphy.h> #include <serial.h> @@ -91,11 +92,16 @@ void s_init(void)clock_init ();timer_init ();gpio_init (); +i2c_init_board ();Quoted 6 lines
arch/arm/cpu/armv7/sunxi/board.c void s_init(void)
Quoted 6 lines
arch/arm/cpu/armv7/sunxi/board.c +2
-0#ifdef CONFIG_SPL_BUILD gd = &gdata;preloader_console_init (); +#ifdef CONFIG_SPL_I2C_SUPPORT +/* Needed early by sunxi_board_init if PMU is enabled */
Quoted 1 line
arch/arm/cpu/armv7/sunxi/board.c void s_init(void) · line 103
Quoted 1 line
arch/arm/cpu/armv7/sunxi/board.c +1
-0+ i2c_init(CONFIG_SYS_I2C_SPEED,
CONFIG_SYS_I2C_SLAVE);Quoted 5 lines
Review
Quoted 5 lines
arch/arm/cpu/armv7/sunxi/board.c +1
-0+#endif sunxi_board_init ();#endif }(quoted diff) +0
-0
b/arch/arm/cpu/armv7/sunxi/u-boot-spl.ldsQuoted 6 lines
Quoted 6 lines
index c1ae227..53f0cbd 100644
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +0
-0@@ -39,6 +39,11 @@ SECTIONS .data : { *(SORT_BY_ALIGNMENT(.data*)) } >.sramQuoted 8 lines
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds SECTIONS · line 46
Quoted 6 lines
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +5
-0. = ALIGN(4); + .u_boot_list : { + KEEP(*(SORT(.u_boot_list*))); + } > .sram + + . = ALIGN(4);This adds the U-Boot commands section to an SPL
linker script, which
Quoted 1 line
seems to imply it was not there before. Are you
actually adding command
Quoted 6 lines
line to the SPL of this board family?
Review
Quoted 4 lines
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +0
-0__image_copy_end = .; _end = .;(quoted diff) +0
-0
b/arch/arm/include/asm/arch-sunxi/i2c.hQuoted 7 lines
arch/arm/include/asm/arch-sunxi/i2c.h line 2
Quoted 7 lines
new file mode 100644
index 0000000..dc5406barch/arm/include/asm/arch-sunxi/i2c.h new file +2
-0@@ -0,0 +1,15 @@ +/* +* Copyright 2014 - Hans de Goede Quoted 10 lines
arch/arm/include/asm/arch-sunxi/i2c.h
Quoted 10 lines
arch/arm/include/asm/arch-sunxi/i2c.h new file +10
-0+* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#ifndef _SUNXI_I2C_H_ +#define _SUNXI_I2C_H_ + +#include <asm/arch/cpu.h> + +#define CONFIG_I2C_MVTWSI_BASE SUNXI_TWI0_BASE +/* This is abp0-clk on sun4i/5i/7i / abp1-clk on sun6i/sun8i which is 24MHz */
Quoted 4 lines
Review
Quoted 4 lines
arch/arm/include/asm/arch-sunxi/i2c.h new file +3
-0+#define CONFIG_SYS_TCLK 24000000 + +#endif (quoted diff) +0
-0
b/board/sunxi/board.cQuoted 10 lines
board/sunxi/board.c int board_mmc_init(bd_t *bis) · line 111
Quoted 10 lines
index b05d0b9..543b809 100644
board/sunxi/board.c +3
-0@@ -106,6 +106,13 @@ int board_mmc_init(bd_t *bis) }#endif +void i2c_init_board (void ) +{ + sunxi_gpio_set_cfgpin(SUNXI_GPB(0),
SUNXI_GPB0_TWI0);Quoted 1 line
board/sunxi/board.c int board_mmc_init(bd_t *bis) · line 112
Quoted 1 line
board/sunxi/board.c +1
-0+ sunxi_gpio_set_cfgpin(SUNXI_GPB(1),
SUNXI_GPB0_TWI0);Quoted 7 lines
Review
Quoted 7 lines
board/sunxi/board.c +3
-0+clock_twi_onoff (0 ,1 ); +} +#ifdef CONFIG_SPL_BUILD void sunxi_board_init (void ) {(quoted diff) +0
-0
b/drivers/i2c/mvtwsi.cQuoted 37 lines
Quoted 37 lines
index d3457b9..ad1ce8f 100644
drivers/i2c/mvtwsi.c +16
-0@@ -22,6 +22,8 @@#include <asm/arch/orion5x.h> #elif defined(CONFIG_KIRKWOOD )#include <asm/arch/kirkwood.h> +#elif defined(CONFIG_SUNXI ) +#include <asm/arch/i2c.h> #else #error Driver mvtwsi not supported by SoC or board#endif @@ -30,6 +32,20 @@* TWSI register structure */ +#ifdef CONFIG_SUNXI + +struct mvtwsi_registers { + u32 slave_address; + u32 xtnd_slave_addr; + u32 data; + u32 control; + u32 status; + u32 baudrate; + u32 soft_reset; +}; + +#else + struct mvtwsi_registers { u32 slave_address; u32 data;@@ -43,6 +59,8 @@ struct mvtwsi_registers {u32 soft_reset; };
Quoted 5 lines
Quoted 5 lines
drivers/i2c/mvtwsi.c struct mvtwsi_registers { · line 66
Quoted 5 lines
drivers/i2c/mvtwsi.c +2
-0+#endif +/* * Control register fields */
I ack the changes to this file in this patch.
Regards...
Prafulla . . .
PATCH 2/5 sunxi: Add i2c support
In reply to Hans de GoedeHello Hans,
Am 09.06.2014 17:15, schrieb Hans de Goede:
Quoted 8 lines
Add support for the i2c controller found on all Allwinner sunxi SoCs, this is the same controller as found on the Marvell orion5x and kirkwood SoC families, with a slightly different register layout, so this patch uses the existing mvtwsi code.
Signed-off-by Hans de Goede<[email protected]>Acked-by Ian Campbell<[email protected]>---
as this is a newer version, your commit subject should contain a "v2", and please add here a short info, what has changed ... look here for an explanation how this should look like:
http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versions
Quoted 44 lines
arch/arm/cpu/armv7/sunxi/board.c | 6 ++++++ arch/arm/cpu/armv7/sunxi/u-boot-spl.lds | 5 +++++ arch/arm/include/asm/arch-sunxi/i2c.h | 15 +++++++++++++++ board/sunxi/board.c | 7 +++++++ drivers/i2c/mvtwsi.c | 18 ++++++++++++++++++ include/configs/sunxi-common.h | 8 ++++++++ 6 files changed, 59 insertions(+)create mode 100644
arch/arm/include/asm/arch-sunxi/i2c.harch/arm/cpu/armv7/sunxi/board.c +6
-0@@ -11,6 +11,7 @@*/ #include <common.h> +#include <i2c.h> #include <netdev.h> #include <miiphy.h> #include <serial.h> @@ -91,11 +92,16 @@ void s_init(void)clock_init ();timer_init ();gpio_init (); +i2c_init_board ();#ifdef CONFIG_SPL_BUILD gd =&gdata;preloader_console_init (); +#ifdef CONFIG_SPL_I2C_SUPPORT +/* Needed early by sunxi_board_init if PMU is enabled */ +i2c_init (CONFIG_SYS_I2C_SPEED ,CONFIG_SYS_I2C_SLAVE ); +#endif sunxi_board_init ();#endif }arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +0
-0@@ -39,6 +39,11 @@ SECTIONS .data : { *(SORT_BY_ALIGNMENT(.data*)) }>.sram
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds SECTIONS · line 49
Quoted 10 lines
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +5
-0. = ALIGN(4); + .u_boot_list : { + KEEP(*(SORT(.u_boot_list*))); + }> .sram + + . = ALIGN(4); __image_copy_end = .; _end = .;
Do you really need this change?
[...]
Quoted 8 lines
board/sunxi/board.c +0
-0@@ -106,6 +106,13 @@ int board_mmc_init(bd_t *bis) }#endif
board/sunxi/board.c int board_mmc_init(bd_t *bis) · line 118
Quoted 10 lines
board/sunxi/board.c +7
-0+void i2c_init_board (void ) +{ +sunxi_gpio_set_cfgpin (SUNXI_GPB (0 ),SUNXI_GPB0_TWI0 ); +sunxi_gpio_set_cfgpin (SUNXI_GPB (1 ),SUNXI_GPB0_TWI0 ); +clock_twi_onoff (0 ,1 ); +} +#ifdef CONFIG_SPL_BUILD void sunxi_board_init (void ) {
I accept this here, but i2c_init_board() hysterically intention was to deblock the bus ... I think we need here another approach ... board specific initialization should be called from i2c_driver->init() when the bus is really used ... (and if not used longer a i2c_driver->deinit() should be called, so for example the pins could be used as gpio ... but this is a step, I would introduce, if all i2c drivers use the new framework ... or we have switched complete to the DM approach)
Quoted 35 lines
drivers/i2c/mvtwsi.c +16
-0@@ -22,6 +22,8 @@#include <asm/arch/orion5x.h> #elif defined(CONFIG_KIRKWOOD )#include <asm/arch/kirkwood.h> +#elif defined(CONFIG_SUNXI ) +#include <asm/arch/i2c.h> #else #error Driver mvtwsi not supported by SoC or board#endif @@ -30,6 +32,20 @@* TWSI register structure */ +#ifdef CONFIG_SUNXI + +struct mvtwsi_registers { + u32 slave_address; + u32 xtnd_slave_addr; + u32 data; + u32 control; + u32 status; + u32 baudrate; + u32 soft_reset; +}; + +#else + struct mvtwsi_registers { u32 slave_address; u32 data;
drivers/i2c/mvtwsi.c struct mvtwsi_registers { · line 66
Quoted 8 lines
drivers/i2c/mvtwsi.c +2
-0@@ -43,6 +59,8 @@ struct mvtwsi_registers { u32 soft_reset; }; +#endif +/* * Control register fields */
? Thats all? I thought you convert this driver to the new i2c framework?
At least, there should be a change from the i2c_xx() functions to static and a prefix add to them ... and a "U_BOOT_I2C_ADAP_COMPLETE" at the end ...
include/configs/sunxi-common.h line 167
Quoted 12 lines
include/configs/sunxi-common.h +4
-0@@ -161,6 +161,14 @@#undef CONFIG_CMD_NET#undef CONFIG_CMD_NFS +/* I2C */ +#define CONFIG_SPL_I2C_SUPPORT +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MVTWSI
This define is not in current ML, nor in your patch ... ?
Do this really work?
include/configs/sunxi-common.h line 174
Quoted 7 lines
include/configs/sunxi-common.h +4
-0+#define CONFIG_SYS_I2C_SPEED 400000 +#define CONFIG_SYS_I2C_SLAVE 0x7f +#define CONFIG_CMD_I2C +#ifndef CONFIG_CONS_INDEX #define CONFIG_CONS_INDEX 1/* UART0 */ #endif
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 2/5 sunxi: Add i2c support
Hi,
Quoted 8 lines · Heiko Schocher
Hello Hans,
Am 09.06.2014 17:15, schrieb Hans de Goede:
Quoted 5 lines
Add support for the i2c controller found on all Allwinner sunxi SoCs, this is the same controller as found on the Marvell orion5x and kirkwood SoC families, with a slightly different register layout, so this patch uses the existing mvtwsi code.
Quoted 8 lines
Quoted 3 lines
Signed-off-by Hans de Goede<[email protected]>Acked-by Ian Campbell<[email protected]>---
as this is a newer version, your commit subject should contain a "v2", and please add here a short info, what has changed ... look here for an explanation how this should look like:
http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versions
Ok, will do.
Quoted 46 lines
Quoted 46 lines
arch/arm/cpu/armv7/sunxi/board.c | 6 ++++++ arch/arm/cpu/armv7/sunxi/u-boot-spl.lds | 5 +++++ arch/arm/include/asm/arch-sunxi/i2c.h | 15 +++++++++++++++ board/sunxi/board.c | 7 +++++++ drivers/i2c/mvtwsi.c | 18 ++++++++++++++++++ include/configs/sunxi-common.h | 8 ++++++++ 6 files changed, 59 insertions(+)create mode 100644
arch/arm/include/asm/arch-sunxi/i2c.harch/arm/cpu/armv7/sunxi/board.c +6
-0@@ -11,6 +11,7 @@*/ #include <common.h> +#include <i2c.h> #include <netdev.h> #include <miiphy.h> #include <serial.h> @@ -91,11 +92,16 @@ void s_init(void)clock_init ();timer_init ();gpio_init (); +i2c_init_board ();#ifdef CONFIG_SPL_BUILD gd =&gdata;preloader_console_init (); +#ifdef CONFIG_SPL_I2C_SUPPORT +/* Needed early by sunxi_board_init if PMU is enabled */ +i2c_init (CONFIG_SYS_I2C_SPEED ,CONFIG_SYS_I2C_SLAVE ); +#endif sunxi_board_init ();#endif }arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +0
-0@@ -39,6 +39,11 @@ SECTIONS .data : { *(SORT_BY_ALIGNMENT(.data*)) }>.sram
Quoted 11 lines
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds SECTIONS · line 49
Quoted 9 lines
arch/arm/cpu/armv7/sunxi/u-boot-spl.lds +5
-0. = ALIGN(4); + .u_boot_list : { + KEEP(*(SORT(.u_boot_list*))); + }> .sram + + . = ALIGN(4); __image_copy_end = .; _end = .;Do you really need this change?
Yes, the sunxi spl uses the i2c bus to program the pmic voltages before enabling dram.
Quoted 67 lines
[...]
Quoted 8 lines
board/sunxi/board.c +0
-0@@ -106,6 +106,13 @@ int board_mmc_init(bd_t *bis) }#endif board/sunxi/board.c int board_mmc_init(bd_t *bis) · line 118
Quoted 10 lines
board/sunxi/board.c +7
-0+void i2c_init_board (void ) +{ +sunxi_gpio_set_cfgpin (SUNXI_GPB (0 ),SUNXI_GPB0_TWI0 ); +sunxi_gpio_set_cfgpin (SUNXI_GPB (1 ),SUNXI_GPB0_TWI0 ); +clock_twi_onoff (0 ,1 ); +} +#ifdef CONFIG_SPL_BUILD void sunxi_board_init (void ) {I accept this here, but
i2c_init_board()hysterically intention was to deblock the bus ... I think we need here another approach ... board specific initialization should be called fromi2c_driver->init()when the bus is really used ... (and if not used longer ai2c_driver->deinit()should be called, so for example the pins could be used as gpio ... but this is a step, I would introduce, if all i2c drivers use the new framework ... or we have switched complete to the DM approach)Quoted 38 lines
drivers/i2c/mvtwsi.c +16
-0@@ -22,6 +22,8 @@#include <asm/arch/orion5x.h> #elif defined(CONFIG_KIRKWOOD )#include <asm/arch/kirkwood.h> +#elif defined(CONFIG_SUNXI ) +#include <asm/arch/i2c.h> #else #error Driver mvtwsi not supported by SoC or board#endif @@ -30,6 +32,20 @@* TWSI register structure */ +#ifdef CONFIG_SUNXI + +struct mvtwsi_registers { + u32 slave_address; + u32 xtnd_slave_addr; + u32 data; + u32 control; + u32 status; + u32 baudrate; + u32 soft_reset; +}; + +#else + struct mvtwsi_registers { u32 slave_address; u32 data;@@ -43,6 +59,8 @@ struct mvtwsi_registers {u32 soft_reset; };
Quoted 7 lines
drivers/i2c/mvtwsi.c struct mvtwsi_registers { · line 66
Quoted 5 lines
drivers/i2c/mvtwsi.c +2
-0+#endif +/* * Control register fields */ ? Thats all? I thought you convert this driver to the new i2c framework?
I did a separate patch for that:
"[PATCH 1/5] mvtwsi: convert to CONFIG_SYS_I2C framework"
http://lists.denx.de/pipermail/u-boot/2014-June/181352.html
Which was also send directly to you.
Quoted 2 lines
At least, there should be a change from the
i2c_xx()functions to static and a prefix add to them ... and a "U_BOOT_I2C_ADAP_COMPLETE" at the end ...
Yes this is all done in the "[PATCH 1/5] mvtwsi: convert to CONFIG_SYS_I2C framework" patch.
Quoted 9 lines
Quoted 9 lines
include/configs/sunxi-common.h +0
-0@@ -161,6 +161,14 @@#undef CONFIG_CMD_NET#undef CONFIG_CMD_NFS
Quoted 6 lines
include/configs/sunxi-common.h line 167
Quoted 4 lines
include/configs/sunxi-common.h +4
-0+/* I2C */ +#define CONFIG_SPL_I2C_SUPPORT +#define CONFIG_SYS_I2C +#define CONFIG_SYS_I2C_MVTWSI This define is not in current ML, nor in your patch ... ?
"[PATCH 1/5] mvtwsi: convert to CONFIG_SYS_I2C framework"
Renames CONFIG_I2C_MVTWSI to CONFIG_SYS_I2C_MVTWSI
Quoted 1 line
Do this really work?
With the above patch applied first, yes it does.
Quoted 7 lines
include/configs/sunxi-common.h line 174
Quoted 7 lines
include/configs/sunxi-common.h +4
-0+#define CONFIG_SYS_I2C_SPEED 400000 +#define CONFIG_SYS_I2C_SLAVE 0x7f +#define CONFIG_CMD_I2C +#ifndef CONFIG_CONS_INDEX #define CONFIG_CONS_INDEX 1/* UART0 */ #endif
Regards,
Hans
PATCH 2/5 sunxi: Add i2c support
Hello Hans,
Am 10.06.2014 09:44, schrieb Hans de Goede:
Quoted 31 lines
Hi,
Quoted 8 lines · Heiko Schocher
Hello Hans,
Am 09.06.2014 17:15, schrieb Hans de Goede:
Quoted 5 lines
Add support for the i2c controller found on all Allwinner sunxi SoCs, this is the same controller as found on the Marvell orion5x and kirkwood SoC families, with a slightly different register layout, so this patch uses the existing mvtwsi code.
Quoted 8 lines
Quoted 3 lines
Signed-off-by Hans de Goede<[email protected]>Acked-by Ian Campbell<[email protected]>---
as this is a newer version, your commit subject should contain a "v2", and please add here a short info, what has changed ... look here for an explanation how this should look like:
http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versionsOk, will do.
Quoted 9 lines
Quoted 9 lines
arch/arm/cpu/armv7/sunxi/board.c | 6 ++++++ arch/arm/cpu/armv7/sunxi/u-boot-spl.lds | 5 +++++ arch/arm/include/asm/arch-sunxi/i2c.h | 15 +++++++++++++++ board/sunxi/board.c | 7 +++++++ drivers/i2c/mvtwsi.c | 18 ++++++++++++++++++ include/configs/sunxi-common.h | 8 ++++++++ 6 files changed, 59 insertions(+)create mode 100644
arch/arm/include/asm/arch-sunxi/i2c.h
[...]
Quoted 51 lines
Quoted 38 lines
Quoted 38 lines
drivers/i2c/mvtwsi.c +16
-0@@ -22,6 +22,8 @@#include <asm/arch/orion5x.h> #elif defined(CONFIG_KIRKWOOD )#include <asm/arch/kirkwood.h> +#elif defined(CONFIG_SUNXI ) +#include <asm/arch/i2c.h> #else #error Driver mvtwsi not supported by SoC or board#endif @@ -30,6 +32,20 @@* TWSI register structure */ +#ifdef CONFIG_SUNXI + +struct mvtwsi_registers { + u32 slave_address; + u32 xtnd_slave_addr; + u32 data; + u32 control; + u32 status; + u32 baudrate; + u32 soft_reset; +}; + +#else + struct mvtwsi_registers { u32 slave_address; u32 data;@@ -43,6 +59,8 @@ struct mvtwsi_registers {u32 soft_reset; };Quoted 7 lines
drivers/i2c/mvtwsi.c struct mvtwsi_registers { · line 66
Quoted 5 lines
drivers/i2c/mvtwsi.c +2
-0+#endif +/* * Control register fields */ ? Thats all? I thought you convert this driver to the new i2c framework?
I did a separate patch for that:
"[PATCH 1/5] mvtwsi: convert toCONFIG_SYS_I2Cframework"
Quoted 7 lines
Which was also send directly to you.
Quoted 2 lines
At least, there should be a change from the
i2c_xx()functions to static and a prefix add to them ... and a "U_BOOT_I2C_ADAP_COMPLETE" at the end ...Yes this is all done in the "[PATCH 1/5] mvtwsi: convert to
CONFIG_SYS_I2Cframework" patch.
Hups... Sorry ... I didn;t find it in my inbox ... so, this patch seems fine to me:
bye,
Heiko
Signature · 2 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
PATCH 3/5 sunxi: Add axp209 pmic support
In reply to Hans de GoedeFrom: Henrik Nordstrom <[email protected]>
Add support for the x-powers axp209 pmic which is found on most A10, A13 and A20 boards.
And enable AXP209 support for the Cubietruck and Cubieboard boards.
While changing the boards.cfg lines for the Cubietruck, add Ian and me as board maintainers for the Cubietruck.
--- board/sunxi/board.c | 22 ++++++ boards.cfg | 6 +- drivers/power/Makefile | 1 + drivers/power/axp209.c | 167 +++++++++++++++++++++++++++++++++++++++++ include/axp209.h | 14 ++++ include/configs/sun4i.h | 1 + include/configs/sun5i.h | 1 + include/configs/sun7i.h | 1 + include/configs/sunxi-common.h | 5 ++ 9 files changed, 215 insertions(+), 3 deletions(-) create mode 100644 drivers/power/axp209.c create mode 100644 include/axp209.h
board/sunxi/board.c +22 -0
@@ -12,6 +12,9 @@*/ #include <common.h> +#ifdef CONFIG_AXP209_POWER +#include <axp209.h> +#endif #include <asm/arch/clock.h> #include <asm/arch/dram.h> #include <asm/arch/gpio.h>
@@ -116,12 +119,31 @@ void i2c_init_board(void)#ifdef CONFIG_SPL_BUILD void sunxi_board_init (void ) { +int power_failed =0 ;unsigned long ramsize; +#ifdef CONFIG_AXP209_POWER + power_failed |=axp209_init (); + power_failed |=axp209_set_dcdc2 (1400 ); + power_failed |=axp209_set_dcdc3 (1250 ); + power_failed |=axp209_set_ldo2 (3000 ); + power_failed |=axp209_set_ldo3 (2800 ); + power_failed |=axp209_set_ldo4 (2800 ); +#endif +printf ("DRAM:" ); ramsize =sunxi_dram_init ();printf (" %lu MiB\n" , ramsize >>20 );if (!ramsize)hang (); + +/* +* Only clock up the CPU to full speed if we are reasonably +* assured it's being powered with suitable core voltage +*/ +if (!power_failed) +clock_set_pll1 (CONFIG_CLK_FULL_SPEED ); +else +printf ("Failed to set core voltage! Can't set CPU frequency\n" ); }#endif
boards.cfg +3 -3
@@ -375,9 +375,9 @@ Active arm armv7 s5pc1xx samsung goni Active arm armv7 s5pc1xx samsung smdkc100 smdkc100 - Minkyu Kang <[email protected]> Active arm armv7 socfpga altera socfpga socfpga_cyclone5 - - Active arm armv7 sunxi - sunxi A13-OLinuXinoM sun5i:A13_OLINUXINOM,SPL,CONS_INDEX=2 Hans de Goede <[email protected]> -Active arm armv7 sunxi - sunxi Cubieboard sun4i:CUBIEBOARD,SPL,SUNXI_EMAC Hans de Goede <[email protected]> -Active arm armv7 sunxi - sunxi Cubietruck sun7i:CUBIETRUCK,SPL,SUNXI_GMAC,RGMII Ian Campbell <[email protected]>:Hans de Goede <[email protected]> -Active arm armv7 sunxi - sunxi Cubietruck_FEL sun7i:CUBIETRUCK,SPL_FEL,SUNXI_GMAC,RGMII Ian Campbell <[email protected]>:Hans de Goede <[email protected]> +Active arm armv7 sunxi - sunxi Cubieboard sun4i:CUBIEBOARD,SPL,AXP209_POWER,SUNXI_EMAC Hans de Goede <[email protected]> +Active arm armv7 sunxi - sunxi Cubietruck sun7i:CUBIETRUCK,SPL,AXP209_POWER,SUNXI_GMAC,RGMII Ian Campbell <[email protected]>:Hans de Goede <[email protected]> +Active arm armv7 sunxi - sunxi Cubietruck_FEL sun7i:CUBIETRUCK,SPL_FEL,AXP209_POWER,SUNXI_GMAC,RGMII Ian Campbell <[email protected]>:Hans de Goede <[email protected]> Active arm armv7 sunxi - sunxi r7-tv-dongle sun5i:R7DONGLE,SPL Hans de Goede <[email protected]> Active arm armv7 u8500 st-ericsson snowball snowball - Mathieu Poirier <[email protected]> Active arm armv7 u8500 st-ericsson u8500 u8500_href - -
drivers/power/Makefile +1 -0
@@ -5,6 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ # +obj-$(CONFIG_AXP209_POWER) += axp209.o obj-$(CONFIG_EXYNOS_TMU) += exynos-tmu.o obj-$(CONFIG_FTPMU010_POWER) += ftpmu010.o obj-$(CONFIG_TPS6586X_POWER) += tps6586x.o
drivers/power/axp209.c new file +167 -0
167 lines not on this page · raw message
include/axp209.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* (C) Copyright 2012 Henrik Nordstrom <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + +extern int axp209_set_dcdc2 (int mvolt); +extern int axp209_set_dcdc3 (int mvolt); +extern int axp209_set_ldo2 (int mvolt); +extern int axp209_set_ldo3 (int mvolt); +extern int axp209_set_ldo4 (int mvolt); +extern int axp209_init (void ); +extern int axp209_poweron_by_dc (void ); +extern int axp209_power_button (void );
include/configs/sun4i.h +1 -0
@@ -12,6 +12,7 @@* A10 specific configuration */ #define CONFIG_SUN4I /* sun4i SoC generation */ +#define CONFIG_CLK_FULL_SPEED 1008000000#define CONFIG_SYS_PROMPT "sun4i# "
include/configs/sun5i.h +1 -0
@@ -12,6 +12,7 @@* High Level Configuration Options */ #define CONFIG_SUN5I /* sun5i SoC generation */ +#define CONFIG_CLK_FULL_SPEED 1008000000#define CONFIG_SYS_PROMPT "sun5i# "
include/configs/sun7i.h +1 -0
@@ -13,6 +13,7 @@* A20 specific configuration */ #define CONFIG_SUN7I /* sun7i SoC generation */ +#define CONFIG_CLK_FULL_SPEED 912000000#define CONFIG_SYS_PROMPT "sun7i# "
include/configs/sunxi-common.h +5 -0
@@ -169,6 +169,11 @@#define CONFIG_SYS_I2C_SLAVE 0x7f#define CONFIG_CMD_I2C +/* PMU */ +#if definedCONFIG_AXP152_POWER || definedCONFIG_AXP209_POWER || definedCONFIG_AXP221_POWER +#define CONFIG_SPL_POWER_SUPPORT +#endif +#ifndef CONFIG_CONS_INDEX #define CONFIG_CONS_INDEX 1/* UART0 */ #endif
Signature · 1 line
2.0.0
PATCH 3/5 sunxi: Add axp209 pmic support
Quoted 5 lines · Hans de Goede
From: Henrik Nordstrom <[email protected]>
Add support for the x-powers axp209 pmic which is found on most A10, A13 and A20 boards.
Quoted 7 lines
And enable AXP209 support for the Cubietruck and Cubieboard boards.
While changing the boards.cfg lines for the Cubietruck, add Ian and me as board maintainers for the Cubietruck.
Signed-off-by Henrik Nordstrom <[email protected]>Signed-off-by Hans de Goede <[email protected]>
PATCH 4/5 sunxi: Add axp152 pmic support
In reply to Hans de GoedeAdd support for the x-powers axp152 pmic which is found on most A10s boards and enable it for the r7-tv-dongle board.
--- board/sunxi/board.c | 10 ++++++ boards.cfg | 2 +- drivers/power/Makefile | 1 + drivers/power/axp152.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/axp152.h | 10 ++++++ 5 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 drivers/power/axp152.c create mode 100644 include/axp152.h
board/sunxi/board.c +10 -0
@@ -12,6 +12,9 @@*/ #include <common.h> +#ifdef CONFIG_AXP152_POWER +#include <axp152.h> +#endif #ifdef CONFIG_AXP209_POWER #include <axp209.h> #endif
@@ -122,6 +125,13 @@ void sunxi_board_init(void)int power_failed =0 ;unsigned long ramsize; +#ifdef CONFIG_AXP152_POWER + power_failed =axp152_init (); + power_failed |=axp152_set_dcdc2 (1400 ); + power_failed |=axp152_set_dcdc3 (1500 ); + power_failed |=axp152_set_dcdc4 (1250 ); + power_failed |=axp152_set_ldo2 (3000 ); +#endif #ifdef CONFIG_AXP209_POWER power_failed |=axp209_init (); power_failed |=axp209_set_dcdc2 (1400 );
boards.cfg +1 -1
@@ -378,7 +378,7 @@ Active arm armv7 sunxi - sunxi Active arm armv7 sunxi - sunxi Cubieboard sun4i:CUBIEBOARD,SPL,AXP209_POWER,SUNXI_EMAC Hans de Goede <[email protected]> Active arm armv7 sunxi - sunxi Cubietruck sun7i:CUBIETRUCK,SPL,AXP209_POWER,SUNXI_GMAC,RGMII Ian Campbell <[email protected]>:Hans de Goede <[email protected]> Active arm armv7 sunxi - sunxi Cubietruck_FEL sun7i:CUBIETRUCK,SPL_FEL,AXP209_POWER,SUNXI_GMAC,RGMII Ian Campbell <[email protected]>:Hans de Goede <[email protected]> -Active arm armv7 sunxi - sunxi r7-tv-dongle sun5i:R7DONGLE,SPL Hans de Goede <[email protected]> +Active arm armv7 sunxi - sunxi r7-tv-dongle sun5i:R7DONGLE,SPL,AXP152_POWER Hans de Goede <[email protected]> Active arm armv7 u8500 st-ericsson snowball snowball - Mathieu Poirier <[email protected]> Active arm armv7 u8500 st-ericsson u8500 u8500_href - - Active arm armv7 vf610 freescale vf610twr vf610twr vf610twr:IMX_CONFIG=board/freescale/vf610twr/imximage.cfg Alison Wang <[email protected]>
drivers/power/Makefile +1 -0
@@ -5,6 +5,7 @@ # SPDX-License-Identifier: GPL-2.0+ # +obj-$(CONFIG_AXP152_POWER) += axp152.o obj-$(CONFIG_AXP209_POWER) += axp209.o obj-$(CONFIG_EXYNOS_TMU) += exynos-tmu.o obj-$(CONFIG_FTPMU010_POWER) += ftpmu010.o
drivers/power/axp152.c new file +97 -0
97 lines not on this page · raw message
include/axp152.h new file +10 -0
@@ -0,0 +1,10 @@ +/* +* (C) Copyright 2012 Henrik Nordstrom <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +int axp152_set_dcdc2 (int mvolt); +int axp152_set_dcdc3 (int mvolt); +int axp152_set_dcdc4 (int mvolt); +int axp152_set_ldo2 (int mvolt); +int axp152_init (void );
Signature · 1 line
2.0.0
PATCH 4/5 sunxi: Add axp152 pmic support
Quoted 6 lines · Hans de Goede
Add support for the x-powers axp152 pmic which is found on most A10s boards and enable it for the r7-tv-dongle board.
Signed-off-by Henrik Nordstrom <[email protected]>Signed-off-by Ian Campbell <[email protected]>Signed-off-by Hans de Goede <[email protected]>
Looks good. Seems like my Ack would be redundant with my S-o-b but you can add it if you like...
Ian.
PATCH 5/5 sunxi: Fix reset hang on sun5i
In reply to Hans de GoedeDo the same as the Linux kernel does, this fixes the SoC hanging on reset about 50% of the time.
--- arch/arm/cpu/armv7/sunxi/board.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/arm/cpu/armv7/sunxi/board.c +5 -1
@@ -75,7 +75,11 @@ void reset_cpu(ulong addr)/* Set the watchdog for its shortest interval (.5s) and wait */ writel (WDT_MODE_RESET_EN |WDT_MODE_EN , &wdog->mode);writel (WDT_CTRL_KEY |WDT_CTRL_RESTART , &wdog->ctl); -while (1 ); + +while (1 ) { +/* sun5i sometimes gets stuck without this */ +writel (WDT_MODE_RESET_EN |WDT_MODE_EN , &wdog->mode); + } }/* do some early init */
Signature · 1 line
2.0.0
PATCH 5/5 sunxi: Fix reset hang on sun5i
Quoted 4 lines · Hans de Goede
Do the same as the Linux kernel does, this fixes the SoC hanging on reset about 50% of the time.
Signed-off-by Hans de Goede <[email protected]>