aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Mavrodiev <stefan@olimex.com>2018-02-13 09:27:40 +0200
committerHeiko Schocher <hs@denx.de>2018-02-19 08:21:38 +0100
commit004b4cdaeca45d4702f0494f517b6fc472ccf4a1 (patch)
tree20fe7b54a167010128620c830f18033ed8e223fb
parent02b0895c215e252cff50d9edf53a972d2bbbfd30 (diff)
downloadu-boot-004b4cdaeca45d4702f0494f517b6fc472ccf4a1.zip
u-boot-004b4cdaeca45d4702f0494f517b6fc472ccf4a1.tar.gz
u-boot-004b4cdaeca45d4702f0494f517b6fc472ccf4a1.tar.bz2
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 Signed-off-by: Stefan Mavrodiev <stefan@olimex.com> Reviewed-by: Heiko Schocher <hs@denx.de>
-rw-r--r--drivers/i2c/mvtwsi.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index 30bee0d..38bca89 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -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);