i2c: mvtwsi.c: Fix set speed
PATCH 1/1 i2c: mvtwsi.c: Fix set speed
Previous patch for this driver breaks i2c initialization.
commit 8bcf12ccce89 ("i2c: mvtwsi.c: Avoid NULL dereference")
If actual_speed is passed as NULL in this function:
static void __twsi_i2c_init(struct mvtwsi_registers *twsi, int speed,
int slaveadd, uint *actual_speed)
than __twsi_i2c_set_bus_speed never get called. This causes i2c clock to run on default speed - 2MHz (measured with oscilloscope). This is issue on some boards, sunxi for example, since on I2C0 bus PMU is connected.
The bootlogs with and without the patch are as follows:
Wihtout the patch:
U-Boot SPL 2018.03-rc2 (Feb 13 2018 - 09:23:17 +0200)
DRAM: 1024 MiB
Failed to set core voltage! Can't set CPU frequency Trying to boot from FEL
U-Boot 2018.03-rc2 (Feb 13 2018 - 09:23:17 +0200) Allwinner Technology
CPU: Allwinner A20 (SUN7I) Model: Olimex A20-OLinuXino-LIME2 I2C: ready DRAM: 1 GiB MMC: SUNXI SD/MMC: 0
With the patch:
U-Boot SPL 2018.03-rc2-00001-g838ff85 (Feb 13 2018 - 09:24:34 +0200)
DRAM: 1024 MiB
CPU: 912000000Hz, AXI/AHB/APB: 3/2/2
Trying to boot from FEL
U-Boot 2018.03-rc2-00001-g838ff85 (Feb 13 2018 - 09:24:34 +0200) Allwinner Technology
CPU: Allwinner A20 (SUN7I) Model: Olimex A20-OLinuXino-LIME2 I2C: ready DRAM: 1 GiB MMC: SUNXI SD/MMC: 0
--- drivers/i2c/mvtwsi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/i2c/mvtwsi.c +4 -1
@@ -487,11 +487,14 @@ static uint __twsi_i2c_set_bus_speed(struct mvtwsi_registers *twsi,static void __twsi_i2c_init (struct mvtwsi_registers *twsi,int speed,int slaveadd,uint *actual_speed) { +uint tmp_speed; +/* Reset controller */ twsi_reset (twsi);/* Set speed */ + tmp_speed =__twsi_i2c_set_bus_speed (twsi, speed);if (actual_speed) - *actual_speed =__twsi_i2c_set_bus_speed (twsi, speed); + *actual_speed = tmp_speed;/* Set slave address; even though we don't use it */ writel (slaveadd, &twsi->slave_address);writel (0 , &twsi->xtnd_slave_addr);
Signature · 1 line
2.7.4
PATCH 1/1 i2c: mvtwsi.c: Fix set speed
Hello Stefan,
Am 13.02.2018 um 08:27 schrieb Stefan Mavrodiev:
Quoted 41 lines
Previous patch for this driver breaks i2c initialization.
commit
8bcf12ccce89("i2c:mvtwsi.c: Avoid NULL dereference")If
actual_speedis passed as NULL in this function:
static void __twsi_i2c_init(structmvtwsi_registers*twsi, int speed,
int slaveadd, uint*actual_speed)
than__twsi_i2c_set_bus_speednever get called. This causes i2c clock to run on default speed - 2MHz (measured with oscilloscope). This is issue on some boards, sunxi for example, since on I2C0 bus PMU is connected.The bootlogs with and without the patch are as follows:
Wihtout the patch:
U-Boot SPL 2018.03-rc2 (Feb 13 2018 - 09:23:17 +0200)
DRAM: 1024 MiB
Failed to set core voltage! Can't set CPU frequency Trying to boot from FELU-Boot 2018.03-rc2 (Feb 13 2018 - 09:23:17 +0200) Allwinner Technology
CPU: Allwinner A20 (SUN7I) Model: Olimex A20-OLinuXino-LIME2 I2C: ready DRAM: 1 GiB MMC: SUNXI SD/MMC: 0With the patch:
U-Boot SPL 2018.03-rc2-00001-g838ff85 (Feb 13 2018 - 09:24:34 +0200)
DRAM: 1024 MiBCPU: 912000000Hz, AXI/AHB/APB: 3/2/2Trying to boot from FEL
U-Boot 2018.03-rc2-00001-g838ff85 (Feb 13 2018 - 09:24:34 +0200) Allwinner Technology
CPU: Allwinner A20 (SUN7I) Model: Olimex A20-OLinuXino-LIME2 I2C: ready DRAM: 1 GiB MMC: SUNXI SD/MMC: 0
Quoted 4 lines
Signed-off-by Stefan Mavrodiev <[email protected]>--- drivers/i2c/mvtwsi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Thanks for testing!
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH 1/1 i2c: mvtwsi.c: Fix set speed
In reply to Stefan MavrodievHello Stefan,
Am 13.02.2018 um 08:27 schrieb Stefan Mavrodiev:
Quoted 41 lines
Previous patch for this driver breaks i2c initialization.
commit
8bcf12ccce89("i2c:mvtwsi.c: Avoid NULL dereference")If
actual_speedis passed as NULL in this function:
static void __twsi_i2c_init(structmvtwsi_registers*twsi, int speed,
int slaveadd, uint*actual_speed)
than__twsi_i2c_set_bus_speednever get called. This causes i2c clock to run on default speed - 2MHz (measured with oscilloscope). This is issue on some boards, sunxi for example, since on I2C0 bus PMU is connected.The bootlogs with and without the patch are as follows:
Wihtout the patch:
U-Boot SPL 2018.03-rc2 (Feb 13 2018 - 09:23:17 +0200)
DRAM: 1024 MiB
Failed to set core voltage! Can't set CPU frequency Trying to boot from FELU-Boot 2018.03-rc2 (Feb 13 2018 - 09:23:17 +0200) Allwinner Technology
CPU: Allwinner A20 (SUN7I) Model: Olimex A20-OLinuXino-LIME2 I2C: ready DRAM: 1 GiB MMC: SUNXI SD/MMC: 0With the patch:
U-Boot SPL 2018.03-rc2-00001-g838ff85 (Feb 13 2018 - 09:24:34 +0200)
DRAM: 1024 MiBCPU: 912000000Hz, AXI/AHB/APB: 3/2/2Trying to boot from FEL
U-Boot 2018.03-rc2-00001-g838ff85 (Feb 13 2018 - 09:24:34 +0200) Allwinner Technology
CPU: Allwinner A20 (SUN7I) Model: Olimex A20-OLinuXino-LIME2 I2C: ready DRAM: 1 GiB MMC: SUNXI SD/MMC: 0
Quoted 4 lines
Signed-off-by Stefan Mavrodiev <[email protected]>--- drivers/i2c/mvtwsi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Thanks for fixing. Applied to u-boot-i2c master
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de