From e66587495d75ad82c34e9f04af03d3c5741644d3 Mon Sep 17 00:00:00 2001 From: Michael Burr Date: Mon, 23 Sep 2013 22:35:45 +0000 Subject: i2c: Zynq: Support for TI PCA9548 bus multiplexer (Interface is not quite the same as Phillips PCA9547.) Signed-off-by: Michael Burr Cc: Heiko Schocher Cc: Michal Simek --- drivers/i2c/i2c_core.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/i2c/i2c_core.c') diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c index d1072e819b..b263562edf 100644 --- a/drivers/i2c/i2c_core.c +++ b/drivers/i2c/i2c_core.c @@ -138,6 +138,11 @@ static int i2c_mux_set(struct i2c_adapter *adap, int mux_id, int chip, return -1; buf = (uint8_t)((channel & 0x07) | (1 << 3)); break; + case I2C_MUX_PCA9548_ID: + if (channel > 7) + return -1; + buf = (uint8_t)(0x01 << channel); + break; default: printf("%s: wrong mux id: %d\n", __func__, mux_id); return -1; -- cgit From 13c2433ccb4d9a5efb95ad953c2b3a0eb1909988 Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Fri, 4 Oct 2013 07:36:34 +0200 Subject: i2c, core: optimze i2c_set_bus_num() check first, if we are on the bus, we want to enable. If so, return immediately, do not calc max adapter number, nor check other things. Signed-off-by: Heiko Schocher Cc: Lukasz Majewski Acked-by: Lukasz Majewski --- drivers/i2c/i2c_core.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'drivers/i2c/i2c_core.c') diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c index b263562edf..fe341cde64 100644 --- a/drivers/i2c/i2c_core.c +++ b/drivers/i2c/i2c_core.c @@ -283,20 +283,22 @@ unsigned int i2c_get_bus_num(void) */ int i2c_set_bus_num(unsigned int bus) { - int max = ll_entry_count(struct i2c_adapter, i2c); + int max; + + if ((bus == I2C_BUS) && (I2C_ADAP->init_done > 0)) + return 0; - if (I2C_ADAPTER(bus) >= max) { - printf("Error, wrong i2c adapter %d max %d possible\n", - I2C_ADAPTER(bus), max); - return -2; - } #ifndef CONFIG_SYS_I2C_DIRECT_BUS if (bus >= CONFIG_SYS_NUM_I2C_BUSES) return -1; #endif - if ((bus == I2C_BUS) && (I2C_ADAP->init_done > 0)) - return 0; + max = ll_entry_count(struct i2c_adapter, i2c); + if (I2C_ADAPTER(bus) >= max) { + printf("Error, wrong i2c adapter %d max %d possible\n", + I2C_ADAPTER(bus), max); + return -2; + } #ifndef CONFIG_SYS_I2C_DIRECT_BUS i2c_mux_disconnet_all(); -- cgit From 83d271b5ffc19e98098861dd21e940cf53545a43 Mon Sep 17 00:00:00 2001 From: "Jens Scharsig (BuS Elektronik)" Date: Mon, 14 Oct 2013 10:27:38 +0200 Subject: Fix: nommu I2C adapter relocation error NoMMU systems have a access violation problem with i2c_reloc_fixup. Blame for it is a double relocation of the adapter itself. The i2c_adap_p is already relocated, if i2c_reloc_fixup is called. This patch removes the relocation of i2c_adap_p from i2c_reloc_fixup to fix this. Signed-off-by: Jens Scharsig (BuS Elektronik) --- drivers/i2c/i2c_core.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/i2c/i2c_core.c') diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c index fe341cde64..b067b7c6ff 100644 --- a/drivers/i2c/i2c_core.c +++ b/drivers/i2c/i2c_core.c @@ -53,10 +53,6 @@ void i2c_reloc_fixup(void) return; for (i = 0; i < max; i++) { - /* adapter itself */ - addr = (unsigned long)i2c_adap_p; - addr += gd->reloc_off; - i2c_adap_p = (struct i2c_adapter *)addr; /* i2c_init() */ addr = (unsigned long)i2c_adap_p->init; addr += gd->reloc_off; -- cgit From 9a2a73d29fa395f42f3fb477ac99dda4d7f2f21f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 16 Oct 2013 13:53:02 +0900 Subject: i2c: eliminate warnings in i2c_reloc_fixup function The prototype of handlers had changed. This commit uses cast with (void *) rather than the handler-specific prototype. Signed-off-by: Masahiro Yamada --- drivers/i2c/i2c_core.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'drivers/i2c/i2c_core.c') diff --git a/drivers/i2c/i2c_core.c b/drivers/i2c/i2c_core.c index b067b7c6ff..e1767f4bd4 100644 --- a/drivers/i2c/i2c_core.c +++ b/drivers/i2c/i2c_core.c @@ -56,25 +56,23 @@ void i2c_reloc_fixup(void) /* i2c_init() */ addr = (unsigned long)i2c_adap_p->init; addr += gd->reloc_off; - i2c_adap_p->init = (void (*)(int, int))addr; + i2c_adap_p->init = (void *)addr; /* i2c_probe() */ addr = (unsigned long)i2c_adap_p->probe; addr += gd->reloc_off; - i2c_adap_p->probe = (int (*)(uint8_t))addr; + i2c_adap_p->probe = (void *)addr; /* i2c_read() */ addr = (unsigned long)i2c_adap_p->read; addr += gd->reloc_off; - i2c_adap_p->read = (int (*)(uint8_t, uint, int, uint8_t *, - int))addr; + i2c_adap_p->read = (void *)addr; /* i2c_write() */ addr = (unsigned long)i2c_adap_p->write; addr += gd->reloc_off; - i2c_adap_p->write = (int (*)(uint8_t, uint, int, uint8_t *, - int))addr; + i2c_adap_p->write = (void *)addr; /* i2c_set_bus_speed() */ addr = (unsigned long)i2c_adap_p->set_bus_speed; addr += gd->reloc_off; - i2c_adap_p->set_bus_speed = (uint (*)(uint))addr; + i2c_adap_p->set_bus_speed = (void *)addr; /* name */ addr = (unsigned long)i2c_adap_p->name; addr += gd->reloc_off; -- cgit