summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-05-03 17:46:26 +0200
committerHeiko Schocher <hs@denx.de>2014-05-14 12:58:55 +0200
commitfab356a0b87d57d474d6e87408f1ede98a503150 (patch)
treea1f3ffaae31c02683de01986589bb823b3fd2c56 /drivers/i2c
parent557a3319089499aa0e55d65a6b43b7137f362003 (diff)
downloadu-boot-imx-fab356a0b87d57d474d6e87408f1ede98a503150.zip
u-boot-imx-fab356a0b87d57d474d6e87408f1ede98a503150.tar.gz
u-boot-imx-fab356a0b87d57d474d6e87408f1ede98a503150.tar.bz2
mvtwsi: Fix clock programming
The TWSI_FREQUENCY macro was wrong in 2 ways: 1) It was casting the result of the calculations to an u8, while i2c clk rates are often >= 100Khz which won't fit in a u8, drop the cast. 2) It had an extra factor of 2 in the divider which neither the datasheet nor the Linux driver have. The comment for the default value was wrongly saying that m lives in bits 4-7, while in reality it is in bits 3-6, as can be seen from the correct shift by 3 used in i2c_init(). While at it remove the unused twsi_actual_speed variable. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/mvtwsi.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c
index 90c8387..b449443 100644
--- a/drivers/i2c/mvtwsi.c
+++ b/drivers/i2c/mvtwsi.c
@@ -216,7 +216,7 @@ static int twsi_stop(int status)
*/
#define TWSI_FREQUENCY(m, n) \
- ((u8) (CONFIG_SYS_TCLK / (10 * (m + 1) * 2 * (1 << n))))
+ (CONFIG_SYS_TCLK / (10 * (m + 1) * (1 << n)))
/*
* These are required to be reprogrammed before enabling the controller
@@ -225,10 +225,8 @@ static int twsi_stop(int status)
* twsi_slave_address left uninitialized lest checkpatch.pl complains.
*/
-/* Baudrate generator: m (bits 7..4) =4, n (bits 3..0) =4 */
+/* Baudrate generator: m (bits 6..3) = 8, n (bits 2..0) = 4 */
static u8 twsi_baud_rate = 0x44; /* baudrate at controller reset */
-/* Default frequency corresponding to default m=4, n=4 */
-static u8 twsi_actual_speed = TWSI_FREQUENCY(4, 4);
/* Default slave address is 0 (so is an uninitialized static) */
static u8 twsi_slave_address;
@@ -279,7 +277,6 @@ void i2c_init(int requested_speed, int slaveadd)
}
/* save baud rate and slave for later calls to twsi_reset */
twsi_baud_rate = baud;
- twsi_actual_speed = highest_speed;
twsi_slave_address = slaveadd;
/* reset controller */
twsi_reset();