mpc83xx: Fix dual I2C support for the MPC8349ITX, MPC8349EMDS, TQM834x, and MPC8360EMDS
This patch also adds an improved I2C set_speed(), which handles all clock
frequencies.
Signed-off-by: Timur Tabi <timur@freescale.com>
diff --git a/board/mpc8349emds/pci.c b/board/mpc8349emds/pci.c
index a916245..93827f1 100644
--- a/board/mpc8349emds/pci.c
+++ b/board/mpc8349emds/pci.c
@@ -75,10 +75,8 @@
/* Switch temporarily to I2C bus #2 */
orig_i2c_bus = i2c_get_bus_num();
- if(orig_i2c_bus != I2C_BUS_2)
- i2c_set_bus_num(I2C_BUS_2);
-
- i2c_init(CFG_I2C_SPEED, CFG_I2C_SLAVE);
+ if(orig_i2c_bus != 2)
+ i2c_set_bus_num(2);
val8 = 0;
i2c_write(0x23, 0x6, 1, &val8, 1);
@@ -124,7 +122,7 @@
printf("PCI2: 32-bit on PMC3\n");
#endif
/* Reset to original I2C bus */
- if(orig_i2c_bus != I2C_BUS_2)
+ if(orig_i2c_bus != 2)
i2c_set_bus_num(orig_i2c_bus);
}
diff --git a/board/mpc8349itx/mpc8349itx.c b/board/mpc8349itx/mpc8349itx.c
index 9a5cbec..4662645 100644
--- a/board/mpc8349itx/mpc8349itx.c
+++ b/board/mpc8349itx/mpc8349itx.c
@@ -259,7 +259,7 @@
puts("Board: Freescale MPC8349E-mITX");
#ifdef CONFIG_HARD_I2C
- i2c_set_bus_num(I2C_BUS_2);
+ i2c_set_bus_num(2);
if (i2c_read(CFG_I2C_8574A_ADDR2, 0, 0, &i2c_data, sizeof(i2c_data)) ==
0)
printf(" %u.%u (PCF8475A)", (i2c_data & 0x02) >> 1,
@@ -379,7 +379,7 @@
u8 data[sizeof(eeprom_data)];
- i2c_set_bus_num(I2C_BUS_1);
+ i2c_set_bus_num(1);
if (i2c_read(CFG_I2C_EEPROM_ADDR, 0, 2, data, sizeof(data)) == 0) {
if (memcmp(data, eeprom_data, sizeof(data)) != 0) {
@@ -397,7 +397,7 @@
#endif
#ifdef CFG_I2C_RTC_ADDR
- i2c_set_bus_num(I2C_BUS_2);
+ i2c_set_bus_num(2);
if (i2c_read(CFG_I2C_RTC_ADDR, 0, 1, ds1339_data, sizeof(ds1339_data))
== 0) {
diff --git a/board/mpc8349itx/pci.c b/board/mpc8349itx/pci.c
index acac185..cf07020 100644
--- a/board/mpc8349itx/pci.c
+++ b/board/mpc8349itx/pci.c
@@ -105,7 +105,7 @@
udelay(2000);
#ifdef CONFIG_HARD_I2C
- i2c_set_bus_num(I2C_BUS_2);
+ i2c_set_bus_num(2);
/* Read the PCI_M66EN jumper setting */
if ((i2c_read(CFG_I2C_8574_ADDR2, 0, 0, ®8, sizeof(reg8)) == 0) ||
(i2c_read(CFG_I2C_8574A_ADDR2, 0, 0, ®8, sizeof(reg8)) == 0)) {
diff --git a/board/mpc8360emds/pci.c b/board/mpc8360emds/pci.c
index 880b2ec..64ea509 100644
--- a/board/mpc8360emds/pci.c
+++ b/board/mpc8360emds/pci.c
@@ -198,8 +198,11 @@
* Assign PIB PMC slot to desired PCI bus
*/
- mpc83xx_i2c = (i2c_t *) (CFG_IMMRBAR + CFG_I2C2_OFFSET);
- i2c_init(CFG_I2C_SPEED, CFG_I2C_SLAVE);
+ /* Switch temporarily to I2C bus #2 */
+ orig_i2c_bus = i2c_get_bus_num();
+
+ if(orig_i2c_bus != 2)
+ i2c_set_bus_num(2);
val8 = 0;
i2c_write(0x23, 0x6, 1, &val8, 1);
@@ -227,6 +230,10 @@
i2c_write(0x27, 0x3, 1, &val8, 1);
asm("eieio");
+ /* Reset to original I2C bus */
+ if(orig_i2c_bus != 2)
+ i2c_set_bus_num(orig_i2c_bus);
+
/*
* Release PCI RST Output signal
*/