* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
@ 2009-07-16 8:01 Heiko Schocher
2009-07-16 8:52 ` Prafulla Wadaskar
` (2 more replies)
0 siblings, 3 replies; 20+ messages in thread
From: Heiko Schocher @ 2009-07-16 8:01 UTC (permalink / raw)
To: u-boot
added support for the Hardware I2C TWSI Interface on
kirkwood SOCs, based on the Linux driver, without IRQ
support.
Tested on a ARM926EJS (CPU Core Version FEROCEON_88FR131
SOC Family: KIRKWOOD, KW88F6281) based suen3 board
Signed-off-by: Heiko Schocher <hs@denx.de>
---
drivers/i2c/Makefile | 1 +
drivers/i2c/mv64xxx-i2c.c | 452 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 453 insertions(+), 0 deletions(-)
create mode 100644 drivers/i2c/mv64xxx-i2c.c
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index ef32f13..ce30111 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -33,6 +33,7 @@ COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o
COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
+COBJS-$(CONFIG_I2C_MV64xxx) += mv64xxx-i2c.o
COBJS-$(CONFIG_S3C44B0_I2C) += s3c44b0_i2c.o
COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o
COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
diff --git a/drivers/i2c/mv64xxx-i2c.c b/drivers/i2c/mv64xxx-i2c.c
new file mode 100644
index 0000000..6ba2782
--- /dev/null
+++ b/drivers/i2c/mv64xxx-i2c.c
@@ -0,0 +1,452 @@
+/*
+ * Driver for the i2c controller on the Marvell line of host bridges
+ * (e.g, gt642[46]0, mv643[46]0, mv644[46]0, and Orion SoC family).
+ *
+ * Based on:
+ * Author: Mark A. Greer <mgreer@mvista.com>
+ *
+ * 2005 (c) MontaVista, Software, Inc. This file is licensed under
+ * the terms of the GNU General Public License version 2. This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ *
+ * ported from Linux to u-boot
+ * (C) Copyright 2009
+ * Heiko Schocher, DENX Software Engineering, hs at denx.de.
+ *
+ */
+#include <common.h>
+#include <i2c.h>
+#include <asm/arch/kirkwood.h>
+#include <asm/errno.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = 0;
+#if defined(CONFIG_I2C_MUX)
+static unsigned int i2c_bus_num_mux __attribute__ ((section ("data"))) = 0;
+#endif
+
+/* Register defines */
+#define MV64XXX_I2C_REG_SLAVE_ADDR 0x00
+#define MV64XXX_I2C_REG_DATA 0x04
+#define MV64XXX_I2C_REG_CONTROL 0x08
+#define MV64XXX_I2C_REG_STATUS 0x0c
+#define MV64XXX_I2C_REG_BAUD 0x0c
+#define MV64XXX_I2C_REG_EXT_SLAVE_ADDR 0x10
+#define MV64XXX_I2C_REG_SOFT_RESET 0x1c
+
+#define MV64XXX_I2C_REG_CONTROL_ACK 0x00000004
+#define MV64XXX_I2C_REG_CONTROL_IFLG 0x00000008
+#define MV64XXX_I2C_REG_CONTROL_STOP 0x00000010
+#define MV64XXX_I2C_REG_CONTROL_START 0x00000020
+#define MV64XXX_I2C_REG_CONTROL_TWSIEN 0x00000040
+#define MV64XXX_I2C_REG_CONTROL_INTEN 0x00000080
+
+/* Ctlr status values */
+#define MV64XXX_I2C_STATUS_BUS_ERR 0x00
+#define MV64XXX_I2C_STATUS_MAST_START 0x08
+#define MV64XXX_I2C_STATUS_MAST_REPEAT_START 0x10
+#define MV64XXX_I2C_STATUS_MAST_WR_ADDR_ACK 0x18
+#define MV64XXX_I2C_STATUS_MAST_WR_ADDR_NO_ACK 0x20
+#define MV64XXX_I2C_STATUS_MAST_WR_ACK 0x28
+#define MV64XXX_I2C_STATUS_MAST_WR_NO_ACK 0x30
+#define MV64XXX_I2C_STATUS_MAST_LOST_ARB 0x38
+#define MV64XXX_I2C_STATUS_MAST_RD_ADDR_ACK 0x40
+#define MV64XXX_I2C_STATUS_MAST_RD_ADDR_NO_ACK 0x48
+#define MV64XXX_I2C_STATUS_MAST_RD_DATA_ACK 0x50
+#define MV64XXX_I2C_STATUS_MAST_RD_DATA_NO_ACK 0x58
+#define MV64XXX_I2C_STATUS_MAST_WR_ADDR_2_ACK 0xd0
+#define MV64XXX_I2C_STATUS_MAST_WR_ADDR_2_NO_ACK 0xd8
+#define MV64XXX_I2C_STATUS_MAST_RD_ADDR_2_ACK 0xe0
+#define MV64XXX_I2C_STATUS_MAST_RD_ADDR_2_NO_ACK 0xe8
+#define MV64XXX_I2C_STATUS_NO_STATUS 0xf8
+
+/* Driver states */
+enum {
+ MV64XXX_I2C_STATE_INVALID,
+ MV64XXX_I2C_STATE_IDLE,
+ MV64XXX_I2C_STATE_WAITING_FOR_START_COND,
+ MV64XXX_I2C_STATE_WAITING_FOR_ADDR_1_ACK,
+ MV64XXX_I2C_STATE_WAITING_FOR_ADDR_2_ACK,
+ MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_ACK,
+ MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_DATA,
+};
+
+/* Driver actions */
+enum {
+ MV64XXX_I2C_ACTION_INVALID,
+ MV64XXX_I2C_ACTION_CONTINUE,
+ MV64XXX_I2C_ACTION_SEND_START,
+ MV64XXX_I2C_ACTION_SEND_ADDR_1,
+ MV64XXX_I2C_ACTION_SEND_ADDR_2,
+ MV64XXX_I2C_ACTION_SEND_DATA,
+ MV64XXX_I2C_ACTION_RCV_DATA,
+ MV64XXX_I2C_ACTION_RCV_DATA_STOP,
+ MV64XXX_I2C_ACTION_SEND_STOP,
+};
+
+/* defines to get compatible with Linux driver */
+#define IRQ_NONE 0x0
+#define IRQ_HANDLED 0x01
+
+#define I2C_M_TEN 0x01
+#define I2C_M_RD 0x02
+#define I2C_M_REV_DIR_ADDR 0x04;
+
+struct i2c_msg {
+ u32 addr;
+ u32 flags;
+ u8 *buf;
+ u32 len;
+};
+
+struct mv64xxx_i2c_data {
+ int irq;
+ u32 state;
+ u32 action;
+ u32 aborting;
+ u32 cntl_bits;
+ void *reg_base;
+ u32 reg_base_p;
+ u32 reg_size;
+ u32 addr1;
+ u32 addr2;
+ u32 bytes_left;
+ u32 byte_posn;
+ u32 block;
+ int rc;
+ u32 freq_m;
+ u32 freq_n;
+ struct i2c_msg *msg;
+};
+
+static struct mv64xxx_i2c_data __drv_data __attribute__ ((section (".data")));
+static struct mv64xxx_i2c_data *drv_data = &__drv_data;
+static struct i2c_msg __i2c_msg __attribute__ ((section (".data")));
+static struct i2c_msg *mv64xxx_i2c_msg = &__i2c_msg;
+/*
+ *****************************************************************************
+ *
+ * Finite State Machine & Interrupt Routines
+ *
+ *****************************************************************************
+ */
+
+/* Reset hardware and initialize FSM */
+static void
+mv64xxx_i2c_hw_init(void)
+{
+ drv_data->state = MV64XXX_I2C_STATE_IDLE;
+ drv_data->freq_m = CONFIG_I2C_MV64xxx_FREQ_M;
+ drv_data->freq_n = CONFIG_I2C_MV64xxx_FREQ_N;
+
+ writel(0, CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_SOFT_RESET);
+ writel((((drv_data->freq_m & 0xf) << 3) | (drv_data->freq_n & 0x7)),
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_BAUD);
+ writel(0, CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_SLAVE_ADDR);
+ writel(0, CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_EXT_SLAVE_ADDR);
+ writel(MV64XXX_I2C_REG_CONTROL_TWSIEN | MV64XXX_I2C_REG_CONTROL_STOP,
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_CONTROL);
+}
+
+static void
+mv64xxx_i2c_fsm(u32 status)
+{
+ /*
+ * If state is idle, then this is likely the remnants of an old
+ * operation that driver has given up on or the user has killed.
+ * If so, issue the stop condition and go to idle.
+ */
+ if (drv_data->state == MV64XXX_I2C_STATE_IDLE) {
+ drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP;
+ return;
+ }
+
+ /* The status from the ctlr [mostly] tells us what to do next */
+ switch (status) {
+ /* Start condition interrupt */
+ case MV64XXX_I2C_STATUS_MAST_START: /* 0x08 */
+ case MV64XXX_I2C_STATUS_MAST_REPEAT_START: /* 0x10 */
+ drv_data->action = MV64XXX_I2C_ACTION_SEND_ADDR_1;
+ drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_ADDR_1_ACK;
+ break;
+
+ /* Performing a write */
+ case MV64XXX_I2C_STATUS_MAST_WR_ADDR_ACK: /* 0x18 */
+ if (drv_data->msg->flags & I2C_M_TEN) {
+ drv_data->action = MV64XXX_I2C_ACTION_SEND_ADDR_2;
+ drv_data->state =
+ MV64XXX_I2C_STATE_WAITING_FOR_ADDR_2_ACK;
+ break;
+ }
+ /* FALLTHRU */
+ case MV64XXX_I2C_STATUS_MAST_WR_ADDR_2_ACK: /* 0xd0 */
+ case MV64XXX_I2C_STATUS_MAST_WR_ACK: /* 0x28 */
+ if ((drv_data->bytes_left == 0)
+ || (drv_data->aborting
+ && (drv_data->byte_posn != 0))) {
+ drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP;
+ drv_data->state = MV64XXX_I2C_STATE_IDLE;
+ } else {
+ drv_data->action = MV64XXX_I2C_ACTION_SEND_DATA;
+ drv_data->state =
+ MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_ACK;
+ drv_data->bytes_left--;
+ }
+ break;
+
+ /* Performing a read */
+ case MV64XXX_I2C_STATUS_MAST_RD_ADDR_ACK: /* 40 */
+ if (drv_data->msg->flags & I2C_M_TEN) {
+ drv_data->action = MV64XXX_I2C_ACTION_SEND_ADDR_2;
+ drv_data->state =
+ MV64XXX_I2C_STATE_WAITING_FOR_ADDR_2_ACK;
+ break;
+ }
+ /* FALLTHRU */
+ case MV64XXX_I2C_STATUS_MAST_RD_ADDR_2_ACK: /* 0xe0 */
+ if (drv_data->bytes_left == 0) {
+ drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP;
+ drv_data->state = MV64XXX_I2C_STATE_IDLE;
+ break;
+ }
+ /* FALLTHRU */
+ case MV64XXX_I2C_STATUS_MAST_RD_DATA_ACK: /* 0x50 */
+ if (status != MV64XXX_I2C_STATUS_MAST_RD_DATA_ACK)
+ drv_data->action = MV64XXX_I2C_ACTION_CONTINUE;
+ else {
+ drv_data->action = MV64XXX_I2C_ACTION_RCV_DATA;
+ drv_data->bytes_left--;
+ }
+ drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_SLAVE_DATA;
+
+ if ((drv_data->bytes_left == 1) || drv_data->aborting)
+ drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_ACK;
+ break;
+
+ case MV64XXX_I2C_STATUS_MAST_RD_DATA_NO_ACK: /* 0x58 */
+ drv_data->action = MV64XXX_I2C_ACTION_RCV_DATA_STOP;
+ drv_data->state = MV64XXX_I2C_STATE_IDLE;
+ break;
+
+ case MV64XXX_I2C_STATUS_MAST_WR_ADDR_NO_ACK: /* 0x20 */
+ case MV64XXX_I2C_STATUS_MAST_WR_NO_ACK: /* 30 */
+ case MV64XXX_I2C_STATUS_MAST_RD_ADDR_NO_ACK: /* 48 */
+ /* Doesn't seem to be a device at other end */
+ drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP;
+ drv_data->state = MV64XXX_I2C_STATE_IDLE;
+ drv_data->rc = -ENODEV;
+ break;
+
+ default:
+ printf("mv64xxx_i2c_fsm: Ctlr Error -- state: 0x%x, "
+ "status: 0x%x, addr: 0x%x, flags: 0x%x\n",
+ drv_data->state, status, drv_data->msg->addr,
+ drv_data->msg->flags);
+ drv_data->action = MV64XXX_I2C_ACTION_SEND_STOP;
+ mv64xxx_i2c_hw_init();
+ drv_data->rc = -EIO;
+ }
+}
+
+static void
+mv64xxx_i2c_do_action(void)
+{
+ switch(drv_data->action) {
+ case MV64XXX_I2C_ACTION_CONTINUE:
+ writel(drv_data->cntl_bits,
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_CONTROL);
+ break;
+
+ case MV64XXX_I2C_ACTION_SEND_START:
+ writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_START,
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_CONTROL);
+ break;
+
+ case MV64XXX_I2C_ACTION_SEND_ADDR_1:
+ writel(drv_data->addr1,
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_DATA);
+ writel(drv_data->cntl_bits,
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_CONTROL);
+ break;
+
+ case MV64XXX_I2C_ACTION_SEND_ADDR_2:
+ writel(drv_data->addr2,
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_DATA);
+ writel(drv_data->cntl_bits,
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_CONTROL);
+ break;
+
+ case MV64XXX_I2C_ACTION_SEND_DATA:
+ writel(drv_data->msg->buf[drv_data->byte_posn++],
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_DATA);
+ writel(drv_data->cntl_bits,
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_CONTROL);
+ break;
+
+ case MV64XXX_I2C_ACTION_RCV_DATA:
+ drv_data->msg->buf[drv_data->byte_posn++] =
+ readl(CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_DATA);
+ writel(drv_data->cntl_bits,
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_CONTROL);
+ break;
+
+ case MV64XXX_I2C_ACTION_RCV_DATA_STOP:
+ drv_data->msg->buf[drv_data->byte_posn++] =
+ readl(CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_DATA);
+ drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_INTEN;
+ writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_STOP,
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_CONTROL);
+ drv_data->block = 0;
+ break;
+
+ case MV64XXX_I2C_ACTION_INVALID:
+ default:
+ printf("mv64xxx_i2c_do_action: Invalid action: %d\n",
+ drv_data->action);
+ drv_data->rc = -EIO;
+ /* FALLTHRU */
+ case MV64XXX_I2C_ACTION_SEND_STOP:
+ drv_data->cntl_bits &= ~MV64XXX_I2C_REG_CONTROL_INTEN;
+ writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_STOP,
+ CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_CONTROL);
+ drv_data->block = 0;
+ break;
+ }
+}
+
+static int
+mv64xxx_i2c_intr(void)
+{
+ u32 status;
+ u32 ctrl;
+ int rc = IRQ_NONE;
+
+ ctrl = readl(CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_CONTROL);
+ while ((ctrl & MV64XXX_I2C_REG_CONTROL_IFLG) &&
+ (drv_data->rc == 0)) {
+ status = readl(CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_STATUS);
+ mv64xxx_i2c_fsm(status);
+ mv64xxx_i2c_do_action();
+ rc = IRQ_HANDLED;
+ ctrl = readl(CONFIG_I2C_MV64xxx_REG_BASE + MV64XXX_I2C_REG_CONTROL);
+ udelay(1000);
+ }
+ return rc;
+}
+
+static void
+mv64xxx_i2c_doio(struct i2c_msg *msg)
+{
+ int ret;
+
+ while ((drv_data->rc == 0) && (drv_data->state != MV64XXX_I2C_STATE_IDLE)) {
+ /* poll Status register */
+ ret = mv64xxx_i2c_intr();
+ if (ret == IRQ_NONE)
+ udelay(10);
+ }
+}
+
+static void
+mv64xxx_i2c_prepare_for_io(struct i2c_msg *msg)
+{
+ u32 dir = 0;
+
+ drv_data->msg = msg;
+ drv_data->byte_posn = 0;
+ drv_data->bytes_left = msg->len;
+ drv_data->aborting = 0;
+ drv_data->rc = 0;
+ /* in u-boot we use no IRQs */
+ drv_data->cntl_bits = MV64XXX_I2C_REG_CONTROL_ACK | MV64XXX_I2C_REG_CONTROL_TWSIEN;
+
+ if (msg->flags & I2C_M_RD)
+ dir = 1;
+ if (msg->flags & I2C_M_TEN) {
+ drv_data->addr1 = 0xf0 | (((u32)msg->addr & 0x300) >> 7) | dir;
+ drv_data->addr2 = (u32)msg->addr & 0xff;
+ } else {
+ drv_data->addr1 = ((u32)msg->addr & 0x7f) << 1 | dir;
+ drv_data->addr2 = 0;
+ }
+ /* OK, no start it (from mv64xxx_i2c_execute_msg())*/
+ drv_data->action = MV64XXX_I2C_ACTION_SEND_START;
+ drv_data->state = MV64XXX_I2C_STATE_WAITING_FOR_START_COND;
+ drv_data->block = 1;
+ mv64xxx_i2c_do_action();
+}
+
+void
+i2c_init(int speed, int slaveadd)
+{
+ mv64xxx_i2c_hw_init();
+}
+
+int
+i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)
+{
+ mv64xxx_i2c_msg->buf = data;
+ mv64xxx_i2c_msg->len = length;
+ mv64xxx_i2c_msg->addr = dev;
+ mv64xxx_i2c_msg->flags = I2C_M_RD;
+
+ mv64xxx_i2c_prepare_for_io(mv64xxx_i2c_msg);
+ mv64xxx_i2c_doio(mv64xxx_i2c_msg);
+ return drv_data->rc;
+}
+
+int
+i2c_write(u8 dev, uint addr, int alen, u8 *data, int length)
+{
+ mv64xxx_i2c_msg->buf = data;
+ mv64xxx_i2c_msg->len = length;
+ mv64xxx_i2c_msg->addr = dev;
+ mv64xxx_i2c_msg->flags = 0;
+
+ mv64xxx_i2c_prepare_for_io(mv64xxx_i2c_msg);
+ mv64xxx_i2c_doio(mv64xxx_i2c_msg);
+ return drv_data->rc;
+}
+
+int
+i2c_probe(uchar chip)
+{
+ return i2c_read(chip, 0, 0, NULL, 0);
+}
+
+int i2c_set_bus_num(unsigned int bus)
+{
+#if defined(CONFIG_I2C_MUX)
+ if (bus < CONFIG_SYS_MAX_I2C_BUS) {
+ i2c_bus_num = bus;
+ } else {
+ int ret;
+
+ ret = i2x_mux_select_mux(bus);
+ if (ret)
+ return ret;
+ i2c_bus_num = 0;
+ }
+ i2c_bus_num_mux = bus;
+#else
+ if (bus > 0) {
+ return -1;
+ }
+
+ i2c_bus_num = bus;
+#endif
+ return 0;
+}
+
+unsigned int i2c_get_bus_num(void)
+{
+#if defined(CONFIG_I2C_MUX)
+ return i2c_bus_num_mux;
+#else
+ return i2c_bus_num;
+#endif
+}
+
--
1.6.0.6
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-16 8:01 [U-Boot] arm, i2c: added support for the TWSI I2C Interface Heiko Schocher
@ 2009-07-16 8:52 ` Prafulla Wadaskar
2009-07-16 10:03 ` Heiko Schocher
2009-07-18 10:55 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-18 10:56 ` [U-Boot] [PATCH] i2c: use for CONFIGs a common naming convention CONFIG_I2C Jean-Christophe PLAGNIOL-VILLARD
2 siblings, 1 reply; 20+ messages in thread
From: Prafulla Wadaskar @ 2009-07-16 8:52 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: Heiko Schocher [mailto:hs at denx.de]
> Sent: Thursday, July 16, 2009 1:31 PM
> To: Jean-Christophe PLAGNIOL-VILLARD; Prafulla Wadaskar
> Cc: U-Boot user list
> Subject: arm, i2c: added support for the TWSI I2C Interface
>
> added support for the Hardware I2C TWSI Interface on
> kirkwood SOCs, based on the Linux driver, without IRQ
> support.
>
> Tested on a ARM926EJS (CPU Core Version FEROCEON_88FR131
> SOC Family: KIRKWOOD, KW88F6281) based suen3 board
>
> Signed-off-by: Heiko Schocher <hs@denx.de>
> ---
> drivers/i2c/Makefile | 1 +
> drivers/i2c/mv64xxx-i2c.c | 452
Can you rename this?
> +++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 453 insertions(+), 0 deletions(-)
> create mode 100644 drivers/i2c/mv64xxx-i2c.c
>
> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
> index ef32f13..ce30111 100644
> --- a/drivers/i2c/Makefile
> +++ b/drivers/i2c/Makefile
> @@ -33,6 +33,7 @@ COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) +=
> omap1510_i2c.o
> COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
> COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
> COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
> +COBJS-$(CONFIG_I2C_MV64xxx) += mv64xxx-i2c.o
Put this in order
> COBJS-$(CONFIG_S3C44B0_I2C) += s3c44b0_i2c.o
> COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o
> COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
> diff --git a/drivers/i2c/mv64xxx-i2c.c b/drivers/i2c/mv64xxx-i2c.c
> new file mode 100644
> index 0000000..6ba2782
> --- /dev/null
> +++ b/drivers/i2c/mv64xxx-i2c.c
> @@ -0,0 +1,452 @@
> +/*
> + * Driver for the i2c controller on the Marvell line of host bridges
> + * (e.g, gt642[46]0, mv643[46]0, mv644[46]0, and Orion SoC family).
Pls add kirkwood too..
> + *
> + * Based on:
> + * Author: Mark A. Greer <mgreer@mvista.com>
> + *
> + * 2005 (c) MontaVista, Software, Inc. This file is licensed under
> + * the terms of the GNU General Public License version 2.
> This program
> + * is licensed "as is" without any warranty of any kind,
> whether express
> + * or implied.
> + *
> + * ported from Linux to u-boot
> + * (C) Copyright 2009
> + * Heiko Schocher, DENX Software Engineering, hs at denx.de.
> + *
> + */
> +#include <common.h>
> +#include <i2c.h>
> +#include <asm/arch/kirkwood.h>
> +#include <asm/errno.h>
> +#include <asm/io.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +static unsigned int i2c_bus_num __attribute__ ((section
> (".data"))) = 0;
> +#if defined(CONFIG_I2C_MUX)
> +static unsigned int i2c_bus_num_mux __attribute__ ((section
> ("data"))) = 0;
> +#endif
> +
> +/* Register defines */
> +#define MV64XXX_I2C_REG_SLAVE_ADDR 0x00
> +#define MV64XXX_I2C_REG_DATA 0x04
MV64XX does not sound generic supported SoCs,
Can you choose better name? like TWSI.
I will go through in details latter on
Regards..
Prafulla . .
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-16 8:52 ` Prafulla Wadaskar
@ 2009-07-16 10:03 ` Heiko Schocher
2009-07-16 10:06 ` Prafulla Wadaskar
0 siblings, 1 reply; 20+ messages in thread
From: Heiko Schocher @ 2009-07-16 10:03 UTC (permalink / raw)
To: u-boot
Hello Prafulla,
Prafulla Wadaskar wrote:
>> -----Original Message-----
>> From: Heiko Schocher [mailto:hs at denx.de]
>> Sent: Thursday, July 16, 2009 1:31 PM
>> To: Jean-Christophe PLAGNIOL-VILLARD; Prafulla Wadaskar
>> Cc: U-Boot user list
>> Subject: arm, i2c: added support for the TWSI I2C Interface
>>
>> added support for the Hardware I2C TWSI Interface on
>> kirkwood SOCs, based on the Linux driver, without IRQ
>> support.
>>
>> Tested on a ARM926EJS (CPU Core Version FEROCEON_88FR131
>> SOC Family: KIRKWOOD, KW88F6281) based suen3 board
>>
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>> ---
>> drivers/i2c/Makefile | 1 +
>> drivers/i2c/mv64xxx-i2c.c | 452
> Can you rename this?
Of course, what name do you prefer?
>> +++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 453 insertions(+), 0 deletions(-)
>> create mode 100644 drivers/i2c/mv64xxx-i2c.c
>>
>> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
>> index ef32f13..ce30111 100644
>> --- a/drivers/i2c/Makefile
>> +++ b/drivers/i2c/Makefile
>> @@ -33,6 +33,7 @@ COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) +=
>> omap1510_i2c.o
>> COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
>> COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
>> COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
>> +COBJS-$(CONFIG_I2C_MV64xxx) += mv64xxx-i2c.o
> Put this in order
What do you mean?
>> COBJS-$(CONFIG_S3C44B0_I2C) += s3c44b0_i2c.o
>> COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o
>> COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
>> diff --git a/drivers/i2c/mv64xxx-i2c.c b/drivers/i2c/mv64xxx-i2c.c
>> new file mode 100644
>> index 0000000..6ba2782
>> --- /dev/null
>> +++ b/drivers/i2c/mv64xxx-i2c.c
>> @@ -0,0 +1,452 @@
>> +/*
>> + * Driver for the i2c controller on the Marvell line of host bridges
>> + * (e.g, gt642[46]0, mv643[46]0, mv644[46]0, and Orion SoC family).
> Pls add kirkwood too..
OK.
>> + *
>> + * Based on:
>> + * Author: Mark A. Greer <mgreer@mvista.com>
>> + *
>> + * 2005 (c) MontaVista, Software, Inc. This file is licensed under
>> + * the terms of the GNU General Public License version 2.
>> This program
>> + * is licensed "as is" without any warranty of any kind,
>> whether express
>> + * or implied.
>> + *
>> + * ported from Linux to u-boot
>> + * (C) Copyright 2009
>> + * Heiko Schocher, DENX Software Engineering, hs at denx.de.
>> + *
>> + */
>> +#include <common.h>
>> +#include <i2c.h>
>> +#include <asm/arch/kirkwood.h>
>> +#include <asm/errno.h>
>> +#include <asm/io.h>
>> +
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +static unsigned int i2c_bus_num __attribute__ ((section
>> (".data"))) = 0;
>> +#if defined(CONFIG_I2C_MUX)
>> +static unsigned int i2c_bus_num_mux __attribute__ ((section
>> ("data"))) = 0;
>> +#endif
>> +
>> +/* Register defines */
>> +#define MV64XXX_I2C_REG_SLAVE_ADDR 0x00
>> +#define MV64XXX_I2C_REG_DATA 0x04
> MV64XX does not sound generic supported SoCs,
> Can you choose better name? like TWSI.
Ah, OK. Used the names from the Linux driver. So I think above define
for selecting this drivers should be something like that:
CONFIG_DRIVER_I2C_TWSI ... (I vote for using CONFIG_DRIVER_I2C_ for
new drivers and maybe I find some time renaming the existing drivers to
this format...)
and replace MV64xxx with TWSI ... right?
> I will go through in details latter on
OK, thanks in advance.
bye
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-16 10:03 ` Heiko Schocher
@ 2009-07-16 10:06 ` Prafulla Wadaskar
2009-07-16 10:17 ` Heiko Schocher
0 siblings, 1 reply; 20+ messages in thread
From: Prafulla Wadaskar @ 2009-07-16 10:06 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: Heiko Schocher [mailto:hs at denx.de]
> Sent: Thursday, July 16, 2009 3:34 PM
> To: Prafulla Wadaskar
> Cc: Jean-Christophe PLAGNIOL-VILLARD; U-Boot user list
> Subject: Re: arm, i2c: added support for the TWSI I2C Interface
>
> Hello Prafulla,
>
> Prafulla Wadaskar wrote:
> >> -----Original Message-----
> >> From: Heiko Schocher [mailto:hs at denx.de]
> >> Sent: Thursday, July 16, 2009 1:31 PM
> >> To: Jean-Christophe PLAGNIOL-VILLARD; Prafulla Wadaskar
> >> Cc: U-Boot user list
> >> Subject: arm, i2c: added support for the TWSI I2C Interface
> >>
> >> added support for the Hardware I2C TWSI Interface on
> >> kirkwood SOCs, based on the Linux driver, without IRQ
> >> support.
> >>
> >> Tested on a ARM926EJS (CPU Core Version FEROCEON_88FR131
> >> SOC Family: KIRKWOOD, KW88F6281) based suen3 board
> >>
> >> Signed-off-by: Heiko Schocher <hs@denx.de>
> >> ---
> >> drivers/i2c/Makefile | 1 +
> >> drivers/i2c/mv64xxx-i2c.c | 452
> > Can you rename this?
>
> Of course, what name do you prefer?
I will prefer a name kirkwood_i2c.c
>
> >> +++++++++++++++++++++++++++++++++++++++++++++
> >> 2 files changed, 453 insertions(+), 0 deletions(-)
> >> create mode 100644 drivers/i2c/mv64xxx-i2c.c
> >>
> >> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
> >> index ef32f13..ce30111 100644
> >> --- a/drivers/i2c/Makefile
> >> +++ b/drivers/i2c/Makefile
> >> @@ -33,6 +33,7 @@ COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) +=
> >> omap1510_i2c.o
> >> COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
> >> COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
> >> COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
> >> +COBJS-$(CONFIG_I2C_MV64xxx) += mv64xxx-i2c.o
> > Put this in order
>
> What do you mean?
Arrange them in alphabetical order, insert this line between "l" "m"
Regards..
Prafulla . .
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-16 10:06 ` Prafulla Wadaskar
@ 2009-07-16 10:17 ` Heiko Schocher
2009-07-16 10:19 ` Prafulla Wadaskar
0 siblings, 1 reply; 20+ messages in thread
From: Heiko Schocher @ 2009-07-16 10:17 UTC (permalink / raw)
To: u-boot
Hello Prafulla,
Prafulla Wadaskar wrote:
>> -----Original Message-----
>> From: Heiko Schocher [mailto:hs at denx.de]
>> Sent: Thursday, July 16, 2009 3:34 PM
>> To: Prafulla Wadaskar
>> Cc: Jean-Christophe PLAGNIOL-VILLARD; U-Boot user list
>> Subject: Re: arm, i2c: added support for the TWSI I2C Interface
>>
>> Hello Prafulla,
>>
>> Prafulla Wadaskar wrote:
>>>> -----Original Message-----
>>>> From: Heiko Schocher [mailto:hs at denx.de]
>>>> Sent: Thursday, July 16, 2009 1:31 PM
>>>> To: Jean-Christophe PLAGNIOL-VILLARD; Prafulla Wadaskar
>>>> Cc: U-Boot user list
>>>> Subject: arm, i2c: added support for the TWSI I2C Interface
>>>>
>>>> added support for the Hardware I2C TWSI Interface on
>>>> kirkwood SOCs, based on the Linux driver, without IRQ
>>>> support.
>>>>
>>>> Tested on a ARM926EJS (CPU Core Version FEROCEON_88FR131
>>>> SOC Family: KIRKWOOD, KW88F6281) based suen3 board
>>>>
>>>> Signed-off-by: Heiko Schocher <hs@denx.de>
>>>> ---
>>>> drivers/i2c/Makefile | 1 +
>>>> drivers/i2c/mv64xxx-i2c.c | 452
>>> Can you rename this?
>> Of course, what name do you prefer?
> I will prefer a name kirkwood_i2c.c
Hmm.. I thought twsi_i2c.c ...
>>>> +++++++++++++++++++++++++++++++++++++++++++++
>>>> 2 files changed, 453 insertions(+), 0 deletions(-)
>>>> create mode 100644 drivers/i2c/mv64xxx-i2c.c
>>>>
>>>> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
>>>> index ef32f13..ce30111 100644
>>>> --- a/drivers/i2c/Makefile
>>>> +++ b/drivers/i2c/Makefile
>>>> @@ -33,6 +33,7 @@ COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) +=
>>>> omap1510_i2c.o
>>>> COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
>>>> COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
>>>> COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
>>>> +COBJS-$(CONFIG_I2C_MV64xxx) += mv64xxx-i2c.o
>>> Put this in order
>> What do you mean?
> Arrange them in alphabetical order, insert this line between "l" "m"
I think the "alphabetical order" is for the CONFIG_ defines ...
so I used the right place for it ... but, if I rename this define
in CONFIG_DRIVER_I2C_TWSI, it gets another place (between
COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o
+COBJS-$(CONFIG_DRIVER_I2C_TWSI) += twsi_i2c.o
COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o)
bye
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-16 10:17 ` Heiko Schocher
@ 2009-07-16 10:19 ` Prafulla Wadaskar
2009-07-16 11:09 ` Heiko Schocher
0 siblings, 1 reply; 20+ messages in thread
From: Prafulla Wadaskar @ 2009-07-16 10:19 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: Heiko Schocher [mailto:hs at denx.de]
> Sent: Thursday, July 16, 2009 3:47 PM
> To: Prafulla Wadaskar
> Cc: Jean-Christophe PLAGNIOL-VILLARD; U-Boot user list
> Subject: Re: arm, i2c: added support for the TWSI I2C Interface
>
> Hello Prafulla,
>
> Prafulla Wadaskar wrote:
> >> -----Original Message-----
> >> From: Heiko Schocher [mailto:hs at denx.de]
> >> Sent: Thursday, July 16, 2009 3:34 PM
> >> To: Prafulla Wadaskar
> >> Cc: Jean-Christophe PLAGNIOL-VILLARD; U-Boot user list
> >> Subject: Re: arm, i2c: added support for the TWSI I2C Interface
> >>
> >> Hello Prafulla,
> >>
> >> Prafulla Wadaskar wrote:
> >>>> -----Original Message-----
> >>>> From: Heiko Schocher [mailto:hs at denx.de]
> >>>> Sent: Thursday, July 16, 2009 1:31 PM
> >>>> To: Jean-Christophe PLAGNIOL-VILLARD; Prafulla Wadaskar
> >>>> Cc: U-Boot user list
> >>>> Subject: arm, i2c: added support for the TWSI I2C Interface
> >>>>
> >>>> added support for the Hardware I2C TWSI Interface on
> kirkwood SOCs,
> >>>> based on the Linux driver, without IRQ support.
> >>>>
> >>>> Tested on a ARM926EJS (CPU Core Version FEROCEON_88FR131 SOC
> >>>> Family: KIRKWOOD, KW88F6281) based suen3 board
> >>>>
> >>>> Signed-off-by: Heiko Schocher <hs@denx.de>
> >>>> ---
> >>>> drivers/i2c/Makefile | 1 +
> >>>> drivers/i2c/mv64xxx-i2c.c | 452
> >>> Can you rename this?
> >> Of course, what name do you prefer?
> > I will prefer a name kirkwood_i2c.c
>
> Hmm.. I thought twsi_i2c.c ...
#include <asm/arch/Kirkwood.h> in your file indicate it is kirkwood low level driver
If you wish twsi_i2c.c is more generic name, but in that case you need to abstract arch specific support well.
>
> >>>> +++++++++++++++++++++++++++++++++++++++++++++
> >>>> 2 files changed, 453 insertions(+), 0 deletions(-) create mode
> >>>> 100644 drivers/i2c/mv64xxx-i2c.c
> >>>>
> >>>> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index
> >>>> ef32f13..ce30111 100644
> >>>> --- a/drivers/i2c/Makefile
> >>>> +++ b/drivers/i2c/Makefile
> >>>> @@ -33,6 +33,7 @@ COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) +=
> >>>> omap1510_i2c.o
> >>>> COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
> >>>> COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
> >>>> COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
> >>>> +COBJS-$(CONFIG_I2C_MV64xxx) += mv64xxx-i2c.o
> >>> Put this in order
> >> What do you mean?
> > Arrange them in alphabetical order, insert this line between "l" "m"
>
> I think the "alphabetical order" is for the CONFIG_ defines ...
> so I used the right place for it ... but, if I rename this
> define in CONFIG_DRIVER_I2C_TWSI, it gets another place (between
> COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o
> +COBJS-$(CONFIG_DRIVER_I2C_TWSI) += twsi_i2c.o
Also this could be CONFIG_I2C_KIRKWOOD or CONFIG_I2C_TWSI or CONFIG_TWSI_I2C
Regards..
Prafulla . .
> COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o)
>
> bye
> Heiko
> --
> DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-16 10:19 ` Prafulla Wadaskar
@ 2009-07-16 11:09 ` Heiko Schocher
0 siblings, 0 replies; 20+ messages in thread
From: Heiko Schocher @ 2009-07-16 11:09 UTC (permalink / raw)
To: u-boot
Hello Prafulla,
Prafulla Wadaskar wrote:
>> -----Original Message-----
>> From: Heiko Schocher [mailto:hs at denx.de]
>> Sent: Thursday, July 16, 2009 3:47 PM
>> To: Prafulla Wadaskar
>> Cc: Jean-Christophe PLAGNIOL-VILLARD; U-Boot user list
>> Subject: Re: arm, i2c: added support for the TWSI I2C Interface
>>
>> Hello Prafulla,
>>
>> Prafulla Wadaskar wrote:
>>>> -----Original Message-----
>>>> From: Heiko Schocher [mailto:hs at denx.de]
>>>> Sent: Thursday, July 16, 2009 3:34 PM
>>>> To: Prafulla Wadaskar
>>>> Cc: Jean-Christophe PLAGNIOL-VILLARD; U-Boot user list
>>>> Subject: Re: arm, i2c: added support for the TWSI I2C Interface
>>>>
>>>> Hello Prafulla,
>>>>
>>>> Prafulla Wadaskar wrote:
>>>>>> -----Original Message-----
>>>>>> From: Heiko Schocher [mailto:hs at denx.de]
>>>>>> Sent: Thursday, July 16, 2009 1:31 PM
>>>>>> To: Jean-Christophe PLAGNIOL-VILLARD; Prafulla Wadaskar
>>>>>> Cc: U-Boot user list
>>>>>> Subject: arm, i2c: added support for the TWSI I2C Interface
>>>>>>
>>>>>> added support for the Hardware I2C TWSI Interface on
>> kirkwood SOCs,
>>>>>> based on the Linux driver, without IRQ support.
>>>>>>
>>>>>> Tested on a ARM926EJS (CPU Core Version FEROCEON_88FR131 SOC
>>>>>> Family: KIRKWOOD, KW88F6281) based suen3 board
>>>>>>
>>>>>> Signed-off-by: Heiko Schocher <hs@denx.de>
>>>>>> ---
>>>>>> drivers/i2c/Makefile | 1 +
>>>>>> drivers/i2c/mv64xxx-i2c.c | 452
>>>>> Can you rename this?
>>>> Of course, what name do you prefer?
>>> I will prefer a name kirkwood_i2c.c
>> Hmm.. I thought twsi_i2c.c ...
> #include <asm/arch/Kirkwood.h> in your file indicate it is kirkwood low level driver
> If you wish twsi_i2c.c is more generic name, but in that case you need to abstract arch specific support well.
I have no idea, how generic this driver is, so I vote for
naming it in the first step as kirkwood_i2c.c as you suggested.
(Because I could not test it on another plattform)
If someone use it on another plattforms, we can do this step
later.
>>>>>> +++++++++++++++++++++++++++++++++++++++++++++
>>>>>> 2 files changed, 453 insertions(+), 0 deletions(-) create mode
>>>>>> 100644 drivers/i2c/mv64xxx-i2c.c
>>>>>>
>>>>>> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile index
>>>>>> ef32f13..ce30111 100644
>>>>>> --- a/drivers/i2c/Makefile
>>>>>> +++ b/drivers/i2c/Makefile
>>>>>> @@ -33,6 +33,7 @@ COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) +=
>>>>>> omap1510_i2c.o
>>>>>> COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
>>>>>> COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
>>>>>> COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
>>>>>> +COBJS-$(CONFIG_I2C_MV64xxx) += mv64xxx-i2c.o
>>>>> Put this in order
>>>> What do you mean?
>>> Arrange them in alphabetical order, insert this line between "l" "m"
>> I think the "alphabetical order" is for the CONFIG_ defines ...
>> so I used the right place for it ... but, if I rename this
>> define in CONFIG_DRIVER_I2C_TWSI, it gets another place (between
>> COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o
>> +COBJS-$(CONFIG_DRIVER_I2C_TWSI) += twsi_i2c.o
> Also this could be CONFIG_I2C_KIRKWOOD or CONFIG_I2C_TWSI or CONFIG_TWSI_I2C
Yep KIRKWOOD is what I prefer actual.
thanks
bye
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-16 8:01 [U-Boot] arm, i2c: added support for the TWSI I2C Interface Heiko Schocher
2009-07-16 8:52 ` Prafulla Wadaskar
@ 2009-07-18 10:55 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-18 12:42 ` Wolfgang Denk
` (2 more replies)
2009-07-18 10:56 ` [U-Boot] [PATCH] i2c: use for CONFIGs a common naming convention CONFIG_I2C Jean-Christophe PLAGNIOL-VILLARD
2 siblings, 3 replies; 20+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-07-18 10:55 UTC (permalink / raw)
To: u-boot
On 10:01 Thu 16 Jul , Heiko Schocher wrote:
> added support for the Hardware I2C TWSI Interface on
> kirkwood SOCs, based on the Linux driver, without IRQ
> support.
>
> Tested on a ARM926EJS (CPU Core Version FEROCEON_88FR131
> SOC Family: KIRKWOOD, KW88F6281) based suen3 board
>
> Signed-off-by: Heiko Schocher <hs@denx.de>
could apply the following CONFIG name convention cleanup before please
> ---
> drivers/i2c/Makefile | 1 +
> drivers/i2c/mv64xxx-i2c.c | 452 +++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 453 insertions(+), 0 deletions(-)
> create mode 100644 drivers/i2c/mv64xxx-i2c.c
>
> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
> index ef32f13..ce30111 100644
> --- a/drivers/i2c/Makefile
> +++ b/drivers/i2c/Makefile
> @@ -33,6 +33,7 @@ COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o
> COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
> COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
> COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
> +COBJS-$(CONFIG_I2C_MV64xxx) += mv64xxx-i2c.o
> COBJS-$(CONFIG_S3C44B0_I2C) += s3c44b0_i2c.o
> COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o
> COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
> diff --git a/drivers/i2c/mv64xxx-i2c.c b/drivers/i2c/mv64xxx-i2c.c
> new file mode 100644
> index 0000000..6ba2782
> --- /dev/null
> +++ b/drivers/i2c/mv64xxx-i2c.c
> @@ -0,0 +1,452 @@
> +/*
> + * Driver for the i2c controller on the Marvell line of host bridges
> + * (e.g, gt642[46]0, mv643[46]0, mv644[46]0, and Orion SoC family).
> + *
> + * Based on:
> + * Author: Mark A. Greer <mgreer@mvista.com>
> + *
> + * 2005 (c) MontaVista, Software, Inc. This file is licensed under
> + * the terms of the GNU General Public License version 2. This program
> + * is licensed "as is" without any warranty of any kind, whether express
> + * or implied.
> + *
> + * ported from Linux to u-boot
> + * (C) Copyright 2009
> + * Heiko Schocher, DENX Software Engineering, hs at denx.de.
> + *
> + */
> +#include <common.h>
> +#include <i2c.h>
> +#include <asm/arch/kirkwood.h>
> +#include <asm/errno.h>
> +#include <asm/io.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = 0;
> +#if defined(CONFIG_I2C_MUX)
> +static unsigned int i2c_bus_num_mux __attribute__ ((section ("data"))) = 0;
.data
> +#endif
no need of put it in section .data on arm
> +
<snip>
> +
> +void
> +i2c_init(int speed, int slaveadd)
> +{
> + mv64xxx_i2c_hw_init();
impossible to specify a speed?
or update it at runtime?
> +}
>
Best Regards,
J.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] [PATCH] i2c: use for CONFIGs a common naming convention CONFIG_I2C
2009-07-16 8:01 [U-Boot] arm, i2c: added support for the TWSI I2C Interface Heiko Schocher
2009-07-16 8:52 ` Prafulla Wadaskar
2009-07-18 10:55 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-07-18 10:56 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-18 12:49 ` Wolfgang Denk
2 siblings, 1 reply; 20+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-07-18 10:56 UTC (permalink / raw)
To: u-boot
instead have different naming convention CONFIG_I2C, CONFIG_xxxx_I2C
use the same CONFIG_I2C
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
due to ML limit size
you can find the patch here
http://git.denx.de/?p=u-boot/u-boot-arm.git;a=commitdiff_plain;h=debabbd27578e142d8361f8e266b89bb18c938d4;hp=dcf728a6afc3e5b6031c520f9393e860b732b2ea
or generate yourself with this commands
git grep -l CONFIG_BFIN_TWI_I2C | xargs sed -i -e "s:CONFIG_BFIN_TWI_I2C:CONFIG_I2C_BFIN_TWI:g"
git grep -l CONFIG_DRIVER_DAVINCI_I2C | xargs sed -i -e "s:CONFIG_DRIVER_DAVINCI_I2C:CONFIG_I2C_DAVINCI:g"
git grep -l CONFIG_FSL_I2C | xargs sed -i -e "s:CONFIG_FSL_I2C:CONFIG_I2C_FSL:g"
git grep -l CONFIG_DRIVER_OMAP1510_I2C | xargs sed -i -e "s:CONFIG_DRIVER_OMAP1510_I2C:CONFIG_I2C_OMAP1510:g"
git grep -l CONFIG_DRIVER_OMAP24XX_I2C | xargs sed -i -e "s:CONFIG_DRIVER_OMAP24XX_I2C:CONFIG_I2C_OMAP24XX:g"
git grep -l CONFIG_DRIVER_OMAP34XX_I2C | xargs sed -i -e "s:CONFIG_DRIVER_OMAP34XX_I2C:CONFIG_I2C_OMAP34XX:g"
git grep -l CONFIG_DRIVER_S3C24X0_I2C | xargs sed -i -e "s:CONFIG_DRIVER_S3C24X0_I2C:CONFIG_I2C_S3C24X0:g"
git grep -l CONFIG_SOFT_I2C | xargs sed -i -e "s:CONFIG_SOFT_I2C:CONFIG_I2C_SOFT:g"
git grep -l CONFIG_HARD_I2C | xargs sed -i -e "s:CONFIG_HARD_I2C:CONFIG_I2C_HARD:g"
git grep -l CONFIG_TSI108_I2C | xargs sed -i -e "s:CONFIG_TSI108_I2C:CONFIG_I2C_TSI108:g"
Best Regards,
J.
README | 18 +++++++++---------
board/atc/atc.c | 4 ++--
board/cm5200/cm5200.c | 4 ++--
board/cmc_pu2/load_sernum_ethaddr.c | 4 ++--
board/cpu86/cpu86.c | 4 ++--
board/cpu87/cpu87.c | 4 ++--
board/fads/fads.h | 2 +-
board/freescale/mpc8349itx/mpc8349itx.c | 2 +-
board/freescale/mpc8349itx/pci.c | 2 +-
board/ids8247/ids8247.c | 4 ++--
board/keymile/common/common.c | 8 ++++----
board/keymile/mgcoge/mgcoge.c | 4 ++--
board/m501sk/eeprom.c | 2 +-
board/muas3001/muas3001.c | 2 +-
board/omap3/common/power.c | 2 +-
board/omap3/evm/evm.c | 2 +-
board/pm826/pm826.c | 4 ++--
board/pm828/pm828.c | 4 ++--
board/sacsng/ioconfig.h | 4 ++--
board/sandburst/common/ppc440gx_i2c.h | 4 ++--
board/sbc8260/sbc8260.c | 4 ++--
board/siemens/SCM/scm.c | 4 ++--
board/tqc/tqm8260/tqm8260.c | 4 ++--
board/tqc/tqm8272/tqm8272.c | 4 ++--
board/trab/trab.c | 4 ++--
common/cmd_eeprom.c | 4 ++--
common/devices.c | 4 ++--
cpu/arm920t/at91rm9200/i2c.c | 4 ++--
cpu/arm926ejs/davinci/dm355.c | 2 +-
cpu/arm926ejs/davinci/dm644x.c | 2 +-
cpu/arm_cortexa8/omap3/clock.c | 2 +-
cpu/mcf5227x/cpu_init.c | 2 +-
cpu/mcf5227x/speed.c | 2 +-
cpu/mcf523x/cpu_init.c | 2 +-
cpu/mcf523x/speed.c | 2 +-
cpu/mcf52x2/cpu_init.c | 4 ++--
cpu/mcf52x2/speed.c | 2 +-
cpu/mcf532x/cpu_init.c | 4 ++--
cpu/mcf532x/speed.c | 2 +-
cpu/mcf5445x/cpu_init.c | 2 +-
cpu/mcf5445x/speed.c | 2 +-
cpu/mcf547x_8x/cpu_init.c | 2 +-
cpu/mcf547x_8x/speed.c | 2 +-
cpu/mpc512x/i2c.c | 4 ++--
cpu/mpc5xxx/i2c.c | 4 ++--
cpu/mpc8220/i2c.c | 4 ++--
cpu/mpc824x/drivers/i2c/i2c.c | 4 ++--
cpu/mpc8260/commproc.c | 2 +-
cpu/mpc8260/i2c.c | 4 ++--
cpu/mpc8xx/i2c.c | 4 ++--
cpu/ppc4xx/i2c.c | 4 ++--
cpu/pxa/i2c.c | 4 ++--
doc/README.m52277evb | 6 +++---
doc/README.m53017evb | 6 +++---
doc/README.m5373evb | 6 +++---
doc/README.m54455evb | 6 +++---
doc/README.m5475evb | 6 +++---
drivers/i2c/Makefile | 18 +++++++++---------
drivers/i2c/fsl_i2c.c | 4 ++--
drivers/i2c/mxc_i2c.c | 4 ++--
drivers/i2c/s3c24x0_i2c.c | 4 ++--
drivers/i2c/soft_i2c.c | 2 +-
include/asm-m68k/global_data.h | 2 +-
include/configs/A3000.h | 4 ++--
include/configs/APC405.h | 2 +-
include/configs/ASH405.h | 2 +-
include/configs/ATUM8548.h | 6 +++---
include/configs/Alaska8220.h | 2 +-
include/configs/B2.h | 2 +-
include/configs/BC3450.h | 2 +-
include/configs/CANBT.h | 2 +-
include/configs/CATcenter.h | 2 +-
include/configs/CMS700.h | 2 +-
include/configs/CPC45.h | 2 +-
include/configs/CPCI2DP.h | 2 +-
include/configs/CPCI405.h | 2 +-
include/configs/CPCI4052.h | 2 +-
include/configs/CPCI405AB.h | 2 +-
include/configs/CPCI405DT.h | 2 +-
include/configs/CPCIISER4.h | 2 +-
include/configs/CPU86.h | 2 +-
include/configs/CPU87.h | 2 +-
include/configs/CRAYL1.h | 2 +-
include/configs/DASA_SIM.h | 2 +-
include/configs/DP405.h | 2 +-
include/configs/DU405.h | 2 +-
include/configs/DU440.h | 4 ++--
include/configs/ERIC.h | 2 +-
include/configs/EXBITGEN.h | 2 +-
include/configs/FADS823.h | 2 +-
include/configs/G2000.h | 2 +-
include/configs/GEN860T.h | 8 ++++----
include/configs/GENIETV.h | 2 +-
include/configs/HH405.h | 2 +-
include/configs/HIDDEN_DRAGON.h | 8 ++++----
include/configs/HMI10.h | 4 ++--
include/configs/HUB405.h | 2 +-
include/configs/IAD210.h | 4 ++--
include/configs/ICU862.h | 4 ++--
include/configs/IDS8247.h | 4 ++--
include/configs/IP860.h | 4 ++--
include/configs/IPHASE4539.h | 8 ++++----
include/configs/IceCube.h | 2 +-
include/configs/JSE.h | 4 ++--
include/configs/KAREF.h | 4 ++--
include/configs/KUP4K.h | 8 ++++----
include/configs/KUP4X.h | 8 ++++----
include/configs/M52277EVB.h | 6 +++---
include/configs/M5235EVB.h | 6 +++---
include/configs/M5253DEMO.h | 4 ++--
include/configs/M5271EVB.h | 6 +++---
include/configs/M5275EVB.h | 6 +++---
include/configs/M53017EVB.h | 6 +++---
include/configs/M5329EVB.h | 6 +++---
include/configs/M5373EVB.h | 6 +++---
include/configs/M54451EVB.h | 6 +++---
include/configs/M54455EVB.h | 6 +++---
include/configs/M5475EVB.h | 6 +++---
include/configs/M5485EVB.h | 6 +++---
include/configs/METROBOX.h | 4 ++--
include/configs/MHPC.h | 4 ++--
include/configs/MIP405.h | 2 +-
include/configs/MPC8260ADS.h | 2 +-
include/configs/MPC8266ADS.h | 2 +-
include/configs/MPC8313ERDB.h | 4 ++--
include/configs/MPC8315ERDB.h | 4 ++--
include/configs/MPC8323ERDB.h | 6 +++---
include/configs/MPC832XEMDS.h | 6 +++---
include/configs/MPC8349EMDS.h | 6 +++---
include/configs/MPC8349ITX.h | 12 ++++++------
include/configs/MPC8360EMDS.h | 6 +++---
include/configs/MPC8360ERDK.h | 6 +++---
include/configs/MPC837XEMDS.h | 6 +++---
include/configs/MPC837XERDB.h | 6 +++---
include/configs/MPC8536DS.h | 6 +++---
include/configs/MPC8540ADS.h | 6 +++---
include/configs/MPC8540EVAL.h | 6 +++---
include/configs/MPC8541CDS.h | 6 +++---
include/configs/MPC8544DS.h | 6 +++---
include/configs/MPC8548CDS.h | 6 +++---
include/configs/MPC8555CDS.h | 6 +++---
include/configs/MPC8560ADS.h | 6 +++---
include/configs/MPC8568MDS.h | 6 +++---
include/configs/MPC8569MDS.h | 6 +++---
include/configs/MPC8572DS.h | 6 +++---
include/configs/MPC8610HPCD.h | 6 +++---
include/configs/MPC8641HPCN.h | 6 +++---
include/configs/MVBLM7.h | 6 +++---
include/configs/NC650.h | 4 ++--
include/configs/OCRTC.h | 2 +-
include/configs/ORSG.h | 2 +-
include/configs/OXC.h | 2 +-
include/configs/P2020DS.h | 6 +++---
include/configs/PCI405.h | 2 +-
include/configs/PIP405.h | 2 +-
include/configs/PLU405.h | 2 +-
include/configs/PM520.h | 2 +-
include/configs/PM826.h | 4 ++--
include/configs/PM828.h | 4 ++--
include/configs/PM854.h | 6 +++---
include/configs/PM856.h | 6 +++---
include/configs/PMC405.h | 2 +-
include/configs/PMC440.h | 4 ++--
include/configs/PPChameleonEVB.h | 2 +-
include/configs/R360MPI.h | 2 +-
include/configs/RBC823.h | 2 +-
include/configs/RPXClassic.h | 4 ++--
include/configs/RPXsuper.h | 2 +-
include/configs/RRvision.h | 8 ++++----
include/configs/SBC8540.h | 6 +++---
include/configs/SCM.h | 4 ++--
include/configs/SIMPC8313.h | 4 ++--
include/configs/SMN42.h | 8 ++++----
include/configs/SX1.h | 4 ++--
include/configs/SXNI855T.h | 2 +-
include/configs/Sandpoint8240.h | 8 ++++----
include/configs/Sandpoint8245.h | 8 ++++----
include/configs/TASREG.h | 4 ++--
include/configs/TB5200.h | 2 +-
include/configs/TK885D.h | 8 ++++----
include/configs/TOP5200.h | 8 ++++----
include/configs/TOP860.h | 4 ++--
include/configs/TQM5200.h | 2 +-
include/configs/TQM8260.h | 4 ++--
include/configs/TQM8272.h | 8 ++++----
include/configs/TQM834x.h | 6 +++---
include/configs/TQM855M.h | 8 ++++----
include/configs/TQM85xx.h | 6 +++---
include/configs/TQM866M.h | 8 ++++----
include/configs/TQM885D.h | 8 ++++----
include/configs/Total5200.h | 2 +-
include/configs/VCMA9.h | 4 ++--
include/configs/VOH405.h | 2 +-
include/configs/VOM405.h | 2 +-
include/configs/W7OLMC.h | 2 +-
include/configs/W7OLMG.h | 2 +-
include/configs/WUH405.h | 2 +-
include/configs/XPEDITE1K.h | 4 ++--
include/configs/XPEDITE5170.h | 4 ++--
include/configs/XPEDITE5200.h | 4 ++--
include/configs/XPEDITE5370.h | 4 ++--
include/configs/Yukon8220.h | 2 +-
include/configs/aev.h | 2 +-
include/configs/alpr.h | 4 ++--
include/configs/amcc-common.h | 2 +-
include/configs/aria.h | 4 ++--
include/configs/at91rm9200ek.h | 4 ++--
include/configs/barco.h | 8 ++++----
include/configs/bf518f-ezbrd.h | 4 ++--
include/configs/bf526-ezbrd.h | 4 ++--
include/configs/bf527-ezkit.h | 4 ++--
include/configs/bf533-ezkit.h | 4 ++--
include/configs/bf533-stamp.h | 4 ++--
include/configs/bf537-minotaur.h | 4 ++--
include/configs/bf537-pnav.h | 4 ++--
include/configs/bf537-srv1.h | 4 ++--
include/configs/bf537-stamp.h | 4 ++--
include/configs/bf538f-ezkit.h | 4 ++--
include/configs/bf548-ezkit.h | 4 ++--
include/configs/bf561-ezkit.h | 4 ++--
include/configs/bfin_adi_common.h | 2 +-
include/configs/blackstamp.h | 4 ++--
include/configs/cm-bf527.h | 4 ++--
include/configs/cm-bf537e.h | 4 ++--
include/configs/cm-bf548.h | 4 ++--
include/configs/cm5200.h | 2 +-
include/configs/cmc_pu2.h | 6 +++---
include/configs/cogent_mpc8xx.h | 2 +-
include/configs/cpci5200.h | 2 +-
include/configs/csb272.h | 2 +-
include/configs/csb472.h | 2 +-
include/configs/davinci_dm355evm.h | 4 ++--
include/configs/davinci_dvevm.h | 4 ++--
include/configs/davinci_schmoogie.h | 4 ++--
include/configs/davinci_sffsdr.h | 4 ++--
include/configs/davinci_sonata.h | 4 ++--
include/configs/debris.h | 8 ++++----
include/configs/delta.h | 2 +-
include/configs/digsy_mtc.h | 2 +-
include/configs/eXalion.h | 4 ++--
include/configs/ep8248.h | 2 +-
include/configs/ep8260.h | 8 ++++----
include/configs/ep82xxm.h | 2 +-
include/configs/hmi1001.h | 2 +-
include/configs/hymod.h | 2 +-
include/configs/ibf-dsp561.h | 4 ++--
include/configs/imx31_phycore.h | 2 +-
include/configs/innokom.h | 2 +-
include/configs/jupiter.h | 2 +-
include/configs/kb9202.h | 2 +-
include/configs/km8xx.h | 4 ++--
include/configs/kmeter1.h | 6 +++---
include/configs/korat.h | 4 ++--
include/configs/kvme080.h | 2 +-
include/configs/lwmon.h | 8 ++++----
include/configs/lwmon5.h | 4 ++--
include/configs/m501sk.h | 2 +-
include/configs/mcc200.h | 2 +-
include/configs/mecp5123.h | 4 ++--
include/configs/mecp5200.h | 2 +-
include/configs/mgcoge.h | 4 ++--
include/configs/motionpro.h | 2 +-
include/configs/mp2usb.h | 8 ++++----
include/configs/mpc5121ads.h | 4 ++--
include/configs/mpc7448hpc2.h | 2 +-
include/configs/muas3001.h | 2 +-
include/configs/mucmc52.h | 2 +-
include/configs/netstal-common.h | 2 +-
include/configs/netstar.h | 4 ++--
include/configs/o2dnt.h | 2 +-
include/configs/omap2420h4.h | 4 ++--
include/configs/omap3_beagle.h | 2 +-
include/configs/omap3_evm.h | 2 +-
include/configs/omap3_overo.h | 2 +-
include/configs/omap3_pandora.h | 2 +-
include/configs/omap3_zoom1.h | 2 +-
include/configs/omap3_zoom2.h | 2 +-
include/configs/p3p440.h | 4 ++--
include/configs/pcm030.h | 2 +-
include/configs/pcs440ep.h | 4 ++--
include/configs/pcu_e.h | 2 +-
include/configs/pdnb3.h | 4 ++--
include/configs/pf5200.h | 2 +-
include/configs/quad100hd.h | 4 ++--
include/configs/rmu.h | 4 ++--
include/configs/rsdproto.h | 2 +-
include/configs/sacsng.h | 8 ++++----
include/configs/sbc405.h | 4 ++--
include/configs/sbc8260.h | 8 ++++----
include/configs/sbc8349.h | 6 +++---
include/configs/sbc8548.h | 6 +++---
include/configs/sbc8560.h | 6 +++---
include/configs/sbc8641d.h | 6 +++---
include/configs/sc3.h | 4 ++--
include/configs/smmaco4.h | 2 +-
include/configs/socrates.h | 6 +++---
include/configs/sorcery.h | 2 +-
include/configs/spc1920.h | 8 ++++----
include/configs/spieval.h | 2 +-
include/configs/stxgp3.h | 6 +++---
include/configs/stxssa.h | 6 +++---
include/configs/tcm-bf537.h | 4 ++--
include/configs/trab.h | 6 +++---
include/configs/uc100.h | 8 ++++----
include/configs/uc101.h | 2 +-
include/configs/utx8245.h | 4 ++--
include/configs/v38b.h | 2 +-
include/configs/vct.h | 6 +++---
include/configs/voiceblue.h | 4 ++--
include/configs/xm250.h | 2 +-
include/configs/zeus.h | 4 ++--
lib_arm/board.c | 8 ++++----
lib_m68k/board.c | 8 ++++----
lib_ppc/board.c | 8 ++++----
314 files changed, 636 insertions(+), 636 deletions(-)
Best Regards,
J.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-18 10:55 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-07-18 12:42 ` Wolfgang Denk
2009-07-18 12:54 ` Heiko Schocher
2009-07-20 7:59 ` [U-Boot] [PATCH v3] " Heiko Schocher
2 siblings, 0 replies; 20+ messages in thread
From: Wolfgang Denk @ 2009-07-18 12:42 UTC (permalink / raw)
To: u-boot
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message <20090718105538.GC27443@game.jcrosoft.org> you wrote:
>
> > +static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = 0;
> > +#if defined(CONFIG_I2C_MUX)
> > +static unsigned int i2c_bus_num_mux __attribute__ ((section ("data"))) = 0;
> .data
> > +#endif
> no need of put it in section .data on arm
What makes you think so? I disagree. You don't have initialized BSS in
the early stages, so you are in the same situation as other
architectures.
And even if it was really not necessary, it doesn't hurt either.
Heiko, please do NOT change this.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I used to think that the brain was the most wonderful organ in my
body. Then I realized who was telling me this." - Emo Phillips
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] [PATCH] i2c: use for CONFIGs a common naming convention CONFIG_I2C
2009-07-18 10:56 ` [U-Boot] [PATCH] i2c: use for CONFIGs a common naming convention CONFIG_I2C Jean-Christophe PLAGNIOL-VILLARD
@ 2009-07-18 12:49 ` Wolfgang Denk
0 siblings, 0 replies; 20+ messages in thread
From: Wolfgang Denk @ 2009-07-18 12:49 UTC (permalink / raw)
To: u-boot
Dear Jean-Christophe PLAGNIOL-VILLARD,
In message <1247914560-30501-1-git-send-email-plagnioj@jcrosoft.com> you wrote:
> instead have different naming convention CONFIG_I2C, CONFIG_xxxx_I2C
> use the same CONFIG_I2C
>
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Please change the subject to:
"I2C: use CONFIG_I2C_* as common prefix for I2C related names"
Thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Go to Heaven for the climate, Hell for the company." - Mark Twain
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-18 10:55 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-18 12:42 ` Wolfgang Denk
@ 2009-07-18 12:54 ` Heiko Schocher
2009-07-18 12:57 ` Wolfgang Denk
2009-07-20 7:59 ` [U-Boot] [PATCH v3] " Heiko Schocher
2 siblings, 1 reply; 20+ messages in thread
From: Heiko Schocher @ 2009-07-18 12:54 UTC (permalink / raw)
To: u-boot
Hello Jean-Christophe,
Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 10:01 Thu 16 Jul , Heiko Schocher wrote:
>> added support for the Hardware I2C TWSI Interface on
>> kirkwood SOCs, based on the Linux driver, without IRQ
>> support.
>>
>> Tested on a ARM926EJS (CPU Core Version FEROCEON_88FR131
>> SOC Family: KIRKWOOD, KW88F6281) based suen3 board
>>
>> Signed-off-by: Heiko Schocher <hs@denx.de>
> could apply the following CONFIG name convention cleanup before please
I don;t understand you here. You have a "CONFIG name convention cleanup"
patch somewhere? Is this somewhere discussed, how this should
look like? (I think, a "CONFIG_DRIVER_I2C_xxx" would be good)
>> ---
>> drivers/i2c/Makefile | 1 +
>> drivers/i2c/mv64xxx-i2c.c | 452 +++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 453 insertions(+), 0 deletions(-)
>> create mode 100644 drivers/i2c/mv64xxx-i2c.c
>>
>> diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
>> index ef32f13..ce30111 100644
>> --- a/drivers/i2c/Makefile
>> +++ b/drivers/i2c/Makefile
>> @@ -33,6 +33,7 @@ COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o
>> COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
>> COBJS-$(CONFIG_DRIVER_OMAP34XX_I2C) += omap24xx_i2c.o
>> COBJS-$(CONFIG_DRIVER_S3C24X0_I2C) += s3c24x0_i2c.o
>> +COBJS-$(CONFIG_I2C_MV64xxx) += mv64xxx-i2c.o
>> COBJS-$(CONFIG_S3C44B0_I2C) += s3c44b0_i2c.o
>> COBJS-$(CONFIG_SOFT_I2C) += soft_i2c.o
>> COBJS-$(CONFIG_TSI108_I2C) += tsi108_i2c.o
>> diff --git a/drivers/i2c/mv64xxx-i2c.c b/drivers/i2c/mv64xxx-i2c.c
>> new file mode 100644
>> index 0000000..6ba2782
>> --- /dev/null
>> +++ b/drivers/i2c/mv64xxx-i2c.c
>> @@ -0,0 +1,452 @@
>> +/*
>> + * Driver for the i2c controller on the Marvell line of host bridges
>> + * (e.g, gt642[46]0, mv643[46]0, mv644[46]0, and Orion SoC family).
>> + *
>> + * Based on:
>> + * Author: Mark A. Greer <mgreer@mvista.com>
>> + *
>> + * 2005 (c) MontaVista, Software, Inc. This file is licensed under
>> + * the terms of the GNU General Public License version 2. This program
>> + * is licensed "as is" without any warranty of any kind, whether express
>> + * or implied.
>> + *
>> + * ported from Linux to u-boot
>> + * (C) Copyright 2009
>> + * Heiko Schocher, DENX Software Engineering, hs at denx.de.
>> + *
>> + */
>> +#include <common.h>
>> +#include <i2c.h>
>> +#include <asm/arch/kirkwood.h>
>> +#include <asm/errno.h>
>> +#include <asm/io.h>
>> +
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = 0;
>> +#if defined(CONFIG_I2C_MUX)
>> +static unsigned int i2c_bus_num_mux __attribute__ ((section ("data"))) = 0;
> .data
>> +#endif
> no need of put it in section .data on arm
Hmm.. I am not an arm expert ...
>> +
> <snip>
>> +
>> +void
>> +i2c_init(int speed, int slaveadd)
>> +{
>> + mv64xxx_i2c_hw_init();
> impossible to specify a speed?
> or update it at runtime?
This is configurable through the CONFIG_I2C_MV64xxx_FREQ_M and
CONFIG_I2C_MV64xxx_FREQ_N defines. Hmm... I ported this more or
less directly from Linux. But you are right, I looked in the
CPU manual, it should be easy to calculate this two values,
so I change this.
bye
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-18 12:54 ` Heiko Schocher
@ 2009-07-18 12:57 ` Wolfgang Denk
2009-07-18 13:21 ` Heiko Schocher
0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Denk @ 2009-07-18 12:57 UTC (permalink / raw)
To: u-boot
Dear Heiko Schocher,
In message <4A61C602.10904@denx.de> you wrote:
>
> I don;t understand you here. You have a "CONFIG name convention cleanup"
> patch somewhere? Is this somewhere discussed, how this should
> look like? (I think, a "CONFIG_DRIVER_I2C_xxx" would be good)
It never has been discussed or even mentioned before.
Jean-Christophe, I recommend you accept Heiko's patch as is (as it was
submitted before your patch), and then just regenerate your patch
(which is trivial for you to do as you have the script ready).
> >> +static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = 0;
> >> +#if defined(CONFIG_I2C_MUX)
> >> +static unsigned int i2c_bus_num_mux __attribute__ ((section ("data"))) = 0;
> > .data
> >> +#endif
> > no need of put it in section .data on arm
>
> Hmm.. I am not an arm expert ...
I disagree with Jean-Christophe here. Do not change this code.
> >> +void
> >> +i2c_init(int speed, int slaveadd)
> >> +{
> >> + mv64xxx_i2c_hw_init();
> > impossible to specify a speed?
> > or update it at runtime?
>
> This is configurable through the CONFIG_I2C_MV64xxx_FREQ_M and
> CONFIG_I2C_MV64xxx_FREQ_N defines. Hmm... I ported this more or
> less directly from Linux. But you are right, I looked in the
> CPU manual, it should be easy to calculate this two values,
> so I change this.
Thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
How much net work could a network work, if a network could net work?
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-18 12:57 ` Wolfgang Denk
@ 2009-07-18 13:21 ` Heiko Schocher
2009-07-18 13:50 ` Wolfgang Denk
0 siblings, 1 reply; 20+ messages in thread
From: Heiko Schocher @ 2009-07-18 13:21 UTC (permalink / raw)
To: u-boot
Hello Wolfgang,
Wolfgang Denk wrote:
> In message <4A61C602.10904@denx.de> you wrote:
>> I don;t understand you here. You have a "CONFIG name convention cleanup"
>> patch somewhere? Is this somewhere discussed, how this should
>> look like? (I think, a "CONFIG_DRIVER_I2C_xxx" would be good)
>
> It never has been discussed or even mentioned before.
>
> Jean-Christophe, I recommend you accept Heiko's patch as is (as it was
> submitted before your patch), and then just regenerate your patch
> (which is trivial for you to do as you have the script ready).
Hmm.. I have to fix some comments, which Prafulla suggested, also
to integrate the speed settings ...
So I don;t know, if this patch should go in mainline as it is ...
I think it is easier, if we integrate Jean-Christophes renaming
patch (the reposted version with correct subject ;-)
and then I can easy adapt "my" patch ...
>>>> +static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = 0;
>>>> +#if defined(CONFIG_I2C_MUX)
>>>> +static unsigned int i2c_bus_num_mux __attribute__ ((section ("data"))) = 0;
>>> .data
>>>> +#endif
>>> no need of put it in section .data on arm
>> Hmm.. I am not an arm expert ...
>
> I disagree with Jean-Christophe here. Do not change this code.
Ok. If Jean-Christophe accept it ...
bye
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-18 13:21 ` Heiko Schocher
@ 2009-07-18 13:50 ` Wolfgang Denk
2009-07-19 5:52 ` Heiko Schocher
0 siblings, 1 reply; 20+ messages in thread
From: Wolfgang Denk @ 2009-07-18 13:50 UTC (permalink / raw)
To: u-boot
Dear Heiko Schocher,
In message <4A61CC6B.3090603@denx.de> you wrote:
>
> > Jean-Christophe, I recommend you accept Heiko's patch as is (as it was
> > submitted before your patch), and then just regenerate your patch
> > (which is trivial for you to do as you have the script ready).
>
> Hmm.. I have to fix some comments, which Prafulla suggested, also
> to integrate the speed settings ...
>
> So I don;t know, if this patch should go in mainline as it is ...
> I think it is easier, if we integrate Jean-Christophes renaming
> patch (the reposted version with correct subject ;-)
> and then I can easy adapt "my" patch ...
Jean-Christophes renaming patch is at the very end of a prtty long
queue. I would not wait that long.
> > I disagree with Jean-Christophe here. Do not change this code.
>
> Ok. If Jean-Christophe accept it ...
I asked him to accept it.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Fascinating is a word I use for the unexpected.
-- Spock, "The Squire of Gothos", stardate 2124.5
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] arm, i2c: added support for the TWSI I2C Interface
2009-07-18 13:50 ` Wolfgang Denk
@ 2009-07-19 5:52 ` Heiko Schocher
0 siblings, 0 replies; 20+ messages in thread
From: Heiko Schocher @ 2009-07-19 5:52 UTC (permalink / raw)
To: u-boot
Hello Wolfgang,
Wolfgang Denk wrote:
> Dear Heiko Schocher,
>
> In message <4A61CC6B.3090603@denx.de> you wrote:
>>> Jean-Christophe, I recommend you accept Heiko's patch as is (as it was
>>> submitted before your patch), and then just regenerate your patch
>>> (which is trivial for you to do as you have the script ready).
>> Hmm.. I have to fix some comments, which Prafulla suggested, also
>> to integrate the speed settings ...
>>
>> So I don;t know, if this patch should go in mainline as it is ...
>> I think it is easier, if we integrate Jean-Christophes renaming
>> patch (the reposted version with correct subject ;-)
>> and then I can easy adapt "my" patch ...
>
> Jean-Christophes renaming patch is at the very end of a prtty long
> queue. I would not wait that long.
Ok. So I try to add the comments from Prafulla and Jean-Christophe
and post a new version.
bye
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] [PATCH v3] arm, i2c: added support for the TWSI I2C Interface
2009-07-18 10:55 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-18 12:42 ` Wolfgang Denk
2009-07-18 12:54 ` Heiko Schocher
@ 2009-07-20 7:59 ` Heiko Schocher
2009-07-22 21:46 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-28 7:31 ` Heiko Schocher
2 siblings, 2 replies; 20+ messages in thread
From: Heiko Schocher @ 2009-07-20 7:59 UTC (permalink / raw)
To: u-boot
Signed-off-by: Heiko Schocher <hs@denx.de>
---
- changes since v1:
added comments from Prafulla Wadaskar
- changes since v2
added comments from Jean-Christophe
- added speed setting
drivers/i2c/Makefile | 1 +
drivers/i2c/kirkwood_i2c.c | 484 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 485 insertions(+), 0 deletions(-)
create mode 100644 drivers/i2c/kirkwood_i2c.c
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index ef32f13..4a12976 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -28,6 +28,7 @@ LIB := $(obj)libi2c.a
COBJS-$(CONFIG_BFIN_TWI_I2C) += bfin-twi_i2c.o
COBJS-$(CONFIG_DRIVER_DAVINCI_I2C) += davinci_i2c.o
COBJS-$(CONFIG_FSL_I2C) += fsl_i2c.o
+COBJS-$(CONFIG_I2C_KIRKWOOD) += kirkwood_i2c.o
COBJS-$(CONFIG_I2C_MXC) += mxc_i2c.o
COBJS-$(CONFIG_DRIVER_OMAP1510_I2C) += omap1510_i2c.o
COBJS-$(CONFIG_DRIVER_OMAP24XX_I2C) += omap24xx_i2c.o
diff --git a/drivers/i2c/kirkwood_i2c.c b/drivers/i2c/kirkwood_i2c.c
new file mode 100644
index 0000000..dd30499
--- /dev/null
+++ b/drivers/i2c/kirkwood_i2c.c
@@ -0,0 +1,484 @@
+/*
+ * Driver for the i2c controller on the Marvell line of host bridges
+ * (e.g, gt642[46]0, mv643[46]0, mv644[46]0, Orion SoC family),
+ * and Kirkwood family.
+ *
+ * Based on:
+ * Author: Mark A. Greer <mgreer@mvista.com>
+ *
+ * 2005 (c) MontaVista, Software, Inc. This file is licensed under
+ * the terms of the GNU General Public License version 2. This program
+ * is licensed "as is" without any warranty of any kind, whether express
+ * or implied.
+ *
+ * ported from Linux to u-boot
+ * (C) Copyright 2009
+ * Heiko Schocher, DENX Software Engineering, hs at denx.de.
+ *
+ */
+#include <common.h>
+#include <i2c.h>
+#include <asm/arch/kirkwood.h>
+#include <asm/errno.h>
+#include <asm/io.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static unsigned int i2c_bus_num __attribute__ ((section (".data"))) = 0;
+#if defined(CONFIG_I2C_MUX)
+static unsigned int i2c_bus_num_mux __attribute__ ((section ("data"))) = 0;
+#endif
+
+/* Register defines */
+#define KW_I2C_REG_SLAVE_ADDR 0x00
+#define KW_I2C_REG_DATA 0x04
+#define KW_I2C_REG_CONTROL 0x08
+#define KW_I2C_REG_STATUS 0x0c
+#define KW_I2C_REG_BAUD 0x0c
+#define KW_I2C_REG_EXT_SLAVE_ADDR 0x10
+#define KW_I2C_REG_SOFT_RESET 0x1c
+
+#define KW_I2C_REG_CONTROL_ACK 0x00000004
+#define KW_I2C_REG_CONTROL_IFLG 0x00000008
+#define KW_I2C_REG_CONTROL_STOP 0x00000010
+#define KW_I2C_REG_CONTROL_START 0x00000020
+#define KW_I2C_REG_CONTROL_TWSIEN 0x00000040
+#define KW_I2C_REG_CONTROL_INTEN 0x00000080
+
+/* Ctlr status values */
+#define KW_I2C_STATUS_BUS_ERR 0x00
+#define KW_I2C_STATUS_MAST_START 0x08
+#define KW_I2C_STATUS_MAST_REPEAT_START 0x10
+#define KW_I2C_STATUS_MAST_WR_ADDR_ACK 0x18
+#define KW_I2C_STATUS_MAST_WR_ADDR_NO_ACK 0x20
+#define KW_I2C_STATUS_MAST_WR_ACK 0x28
+#define KW_I2C_STATUS_MAST_WR_NO_ACK 0x30
+#define KW_I2C_STATUS_MAST_LOST_ARB 0x38
+#define KW_I2C_STATUS_MAST_RD_ADDR_ACK 0x40
+#define KW_I2C_STATUS_MAST_RD_ADDR_NO_ACK 0x48
+#define KW_I2C_STATUS_MAST_RD_DATA_ACK 0x50
+#define KW_I2C_STATUS_MAST_RD_DATA_NO_ACK 0x58
+#define KW_I2C_STATUS_MAST_WR_ADDR_2_ACK 0xd0
+#define KW_I2C_STATUS_MAST_WR_ADDR_2_NO_ACK 0xd8
+#define KW_I2C_STATUS_MAST_RD_ADDR_2_ACK 0xe0
+#define KW_I2C_STATUS_MAST_RD_ADDR_2_NO_ACK 0xe8
+#define KW_I2C_STATUS_NO_STATUS 0xf8
+
+/* Driver states */
+enum {
+ KW_I2C_STATE_INVALID,
+ KW_I2C_STATE_IDLE,
+ KW_I2C_STATE_WAITING_FOR_START_COND,
+ KW_I2C_STATE_WAITING_FOR_ADDR_1_ACK,
+ KW_I2C_STATE_WAITING_FOR_ADDR_2_ACK,
+ KW_I2C_STATE_WAITING_FOR_SLAVE_ACK,
+ KW_I2C_STATE_WAITING_FOR_SLAVE_DATA,
+};
+
+/* Driver actions */
+enum {
+ KW_I2C_ACTION_INVALID,
+ KW_I2C_ACTION_CONTINUE,
+ KW_I2C_ACTION_SEND_START,
+ KW_I2C_ACTION_SEND_ADDR_1,
+ KW_I2C_ACTION_SEND_ADDR_2,
+ KW_I2C_ACTION_SEND_DATA,
+ KW_I2C_ACTION_RCV_DATA,
+ KW_I2C_ACTION_RCV_DATA_STOP,
+ KW_I2C_ACTION_SEND_STOP,
+};
+
+/* defines to get compatible with Linux driver */
+#define IRQ_NONE 0x0
+#define IRQ_HANDLED 0x01
+
+#define I2C_M_TEN 0x01
+#define I2C_M_RD 0x02
+#define I2C_M_REV_DIR_ADDR 0x04;
+
+struct i2c_msg {
+ u32 addr;
+ u32 flags;
+ u8 *buf;
+ u32 len;
+};
+
+struct kirkwood_i2c_data {
+ int irq;
+ u32 state;
+ u32 action;
+ u32 aborting;
+ u32 cntl_bits;
+ void *reg_base;
+ u32 reg_base_p;
+ u32 reg_size;
+ u32 addr1;
+ u32 addr2;
+ u32 bytes_left;
+ u32 byte_posn;
+ u32 block;
+ int rc;
+ u32 freq_m;
+ u32 freq_n;
+ struct i2c_msg *msg;
+};
+
+static struct kirkwood_i2c_data __drv_data __attribute__ ((section (".data")));
+static struct kirkwood_i2c_data *drv_data = &__drv_data;
+static struct i2c_msg __i2c_msg __attribute__ ((section (".data")));
+static struct i2c_msg *kirkwood_i2c_msg = &__i2c_msg;
+
+/*
+ *****************************************************************************
+ *
+ * Finite State Machine & Interrupt Routines
+ *
+ *****************************************************************************
+ */
+
+static inline int abs(int n)
+{
+ if(n >= 0)
+ return n;
+ else
+ return n * -1;
+}
+
+static void kirkwood_calculate_speed(int speed)
+{
+ int calcspeed;
+ int diff;
+ int best_diff = CONFIG_SYS_TCLK;
+ int best_speed = 0;
+ int m, n;
+ int tmp[8] = {2, 4, 8, 16, 32, 64, 128, 256};
+
+ for (n = 0; n < 8; n++) {
+ for (m = 0; m < 16; m++) {
+ calcspeed = CONFIG_SYS_TCLK / (10 * (m + 1) * tmp[n]);
+ diff = abs((speed - calcspeed));
+ if ( diff < best_diff) {
+ best_diff = diff;
+ best_speed = calcspeed;
+ drv_data->freq_m = m;
+ drv_data->freq_n = n;
+ }
+ }
+ }
+}
+
+/* Reset hardware and initialize FSM */
+static void
+kirkwood_i2c_hw_init(int speed, int slaveadd)
+{
+ drv_data->state = KW_I2C_STATE_IDLE;
+
+ kirkwood_calculate_speed(speed);
+ writel(0, CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_SOFT_RESET);
+ writel((((drv_data->freq_m & 0xf) << 3) | (drv_data->freq_n & 0x7)),
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_BAUD);
+ writel(slaveadd, CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_SLAVE_ADDR);
+ writel(0, CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_EXT_SLAVE_ADDR);
+ writel(KW_I2C_REG_CONTROL_TWSIEN | KW_I2C_REG_CONTROL_STOP,
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_CONTROL);
+}
+
+static void
+kirkwood_i2c_fsm(u32 status)
+{
+ /*
+ * If state is idle, then this is likely the remnants of an old
+ * operation that driver has given up on or the user has killed.
+ * If so, issue the stop condition and go to idle.
+ */
+ if (drv_data->state == KW_I2C_STATE_IDLE) {
+ drv_data->action = KW_I2C_ACTION_SEND_STOP;
+ return;
+ }
+
+ /* The status from the ctlr [mostly] tells us what to do next */
+ switch (status) {
+ /* Start condition interrupt */
+ case KW_I2C_STATUS_MAST_START: /* 0x08 */
+ case KW_I2C_STATUS_MAST_REPEAT_START: /* 0x10 */
+ drv_data->action = KW_I2C_ACTION_SEND_ADDR_1;
+ drv_data->state = KW_I2C_STATE_WAITING_FOR_ADDR_1_ACK;
+ break;
+
+ /* Performing a write */
+ case KW_I2C_STATUS_MAST_WR_ADDR_ACK: /* 0x18 */
+ if (drv_data->msg->flags & I2C_M_TEN) {
+ drv_data->action = KW_I2C_ACTION_SEND_ADDR_2;
+ drv_data->state =
+ KW_I2C_STATE_WAITING_FOR_ADDR_2_ACK;
+ break;
+ }
+ /* FALLTHRU */
+ case KW_I2C_STATUS_MAST_WR_ADDR_2_ACK: /* 0xd0 */
+ case KW_I2C_STATUS_MAST_WR_ACK: /* 0x28 */
+ if ((drv_data->bytes_left == 0)
+ || (drv_data->aborting
+ && (drv_data->byte_posn != 0))) {
+ drv_data->action = KW_I2C_ACTION_SEND_STOP;
+ drv_data->state = KW_I2C_STATE_IDLE;
+ } else {
+ drv_data->action = KW_I2C_ACTION_SEND_DATA;
+ drv_data->state =
+ KW_I2C_STATE_WAITING_FOR_SLAVE_ACK;
+ drv_data->bytes_left--;
+ }
+ break;
+
+ /* Performing a read */
+ case KW_I2C_STATUS_MAST_RD_ADDR_ACK: /* 40 */
+ if (drv_data->msg->flags & I2C_M_TEN) {
+ drv_data->action = KW_I2C_ACTION_SEND_ADDR_2;
+ drv_data->state =
+ KW_I2C_STATE_WAITING_FOR_ADDR_2_ACK;
+ break;
+ }
+ /* FALLTHRU */
+ case KW_I2C_STATUS_MAST_RD_ADDR_2_ACK: /* 0xe0 */
+ if (drv_data->bytes_left == 0) {
+ drv_data->action = KW_I2C_ACTION_SEND_STOP;
+ drv_data->state = KW_I2C_STATE_IDLE;
+ break;
+ }
+ /* FALLTHRU */
+ case KW_I2C_STATUS_MAST_RD_DATA_ACK: /* 0x50 */
+ if (status != KW_I2C_STATUS_MAST_RD_DATA_ACK)
+ drv_data->action = KW_I2C_ACTION_CONTINUE;
+ else {
+ drv_data->action = KW_I2C_ACTION_RCV_DATA;
+ drv_data->bytes_left--;
+ }
+ drv_data->state = KW_I2C_STATE_WAITING_FOR_SLAVE_DATA;
+
+ if ((drv_data->bytes_left == 1) || drv_data->aborting)
+ drv_data->cntl_bits &= ~KW_I2C_REG_CONTROL_ACK;
+ break;
+
+ case KW_I2C_STATUS_MAST_RD_DATA_NO_ACK: /* 0x58 */
+ drv_data->action = KW_I2C_ACTION_RCV_DATA_STOP;
+ drv_data->state = KW_I2C_STATE_IDLE;
+ break;
+
+ case KW_I2C_STATUS_MAST_WR_ADDR_NO_ACK: /* 0x20 */
+ case KW_I2C_STATUS_MAST_WR_NO_ACK: /* 30 */
+ case KW_I2C_STATUS_MAST_RD_ADDR_NO_ACK: /* 48 */
+ /* Doesn't seem to be a device at other end */
+ drv_data->action = KW_I2C_ACTION_SEND_STOP;
+ drv_data->state = KW_I2C_STATE_IDLE;
+ drv_data->rc = -ENODEV;
+ break;
+
+ default:
+ printf("kirkwood_i2c_fsm: Ctlr Error -- state: 0x%x, "
+ "status: 0x%x, addr: 0x%x, flags: 0x%x\n",
+ drv_data->state, status, drv_data->msg->addr,
+ drv_data->msg->flags);
+ drv_data->action = KW_I2C_ACTION_SEND_STOP;
+ kirkwood_i2c_hw_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
+ drv_data->rc = -EIO;
+ }
+}
+
+static void
+kirkwood_i2c_do_action(void)
+{
+ switch(drv_data->action) {
+ case KW_I2C_ACTION_CONTINUE:
+ writel(drv_data->cntl_bits,
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_CONTROL);
+ break;
+
+ case KW_I2C_ACTION_SEND_START:
+ writel(drv_data->cntl_bits | KW_I2C_REG_CONTROL_START,
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_CONTROL);
+ break;
+
+ case KW_I2C_ACTION_SEND_ADDR_1:
+ writel(drv_data->addr1,
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_DATA);
+ writel(drv_data->cntl_bits,
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_CONTROL);
+ break;
+
+ case KW_I2C_ACTION_SEND_ADDR_2:
+ writel(drv_data->addr2,
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_DATA);
+ writel(drv_data->cntl_bits,
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_CONTROL);
+ break;
+
+ case KW_I2C_ACTION_SEND_DATA:
+ writel(drv_data->msg->buf[drv_data->byte_posn++],
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_DATA);
+ writel(drv_data->cntl_bits,
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_CONTROL);
+ break;
+
+ case KW_I2C_ACTION_RCV_DATA:
+ drv_data->msg->buf[drv_data->byte_posn++] =
+ readl(CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_DATA);
+ writel(drv_data->cntl_bits,
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_CONTROL);
+ break;
+
+ case KW_I2C_ACTION_RCV_DATA_STOP:
+ drv_data->msg->buf[drv_data->byte_posn++] =
+ readl(CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_DATA);
+ drv_data->cntl_bits &= ~KW_I2C_REG_CONTROL_INTEN;
+ writel(drv_data->cntl_bits | KW_I2C_REG_CONTROL_STOP,
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_CONTROL);
+ drv_data->block = 0;
+ break;
+
+ case KW_I2C_ACTION_INVALID:
+ default:
+ printf("kirkwood_i2c_do_action: Invalid action: %d\n",
+ drv_data->action);
+ drv_data->rc = -EIO;
+ /* FALLTHRU */
+ case KW_I2C_ACTION_SEND_STOP:
+ drv_data->cntl_bits &= ~KW_I2C_REG_CONTROL_INTEN;
+ writel(drv_data->cntl_bits | KW_I2C_REG_CONTROL_STOP,
+ CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_CONTROL);
+ drv_data->block = 0;
+ break;
+ }
+}
+
+static int
+kirkwood_i2c_intr(void)
+{
+ u32 status;
+ u32 ctrl;
+ int rc = IRQ_NONE;
+
+ ctrl = readl(CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_CONTROL);
+ while ((ctrl & KW_I2C_REG_CONTROL_IFLG) &&
+ (drv_data->rc == 0)) {
+ status = readl(CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_STATUS);
+ kirkwood_i2c_fsm(status);
+ kirkwood_i2c_do_action();
+ rc = IRQ_HANDLED;
+ ctrl = readl(CONFIG_I2C_KW_REG_BASE + KW_I2C_REG_CONTROL);
+ udelay(1000);
+ }
+ return rc;
+}
+
+static void
+kirkwood_i2c_doio(struct i2c_msg *msg)
+{
+ int ret;
+
+ while ((drv_data->rc == 0) && (drv_data->state != KW_I2C_STATE_IDLE)) {
+ /* poll Status register */
+ ret = kirkwood_i2c_intr();
+ if (ret == IRQ_NONE)
+ udelay(10);
+ }
+}
+
+static void
+kirkwood_i2c_prepare_for_io(struct i2c_msg *msg)
+{
+ u32 dir = 0;
+
+ drv_data->msg = msg;
+ drv_data->byte_posn = 0;
+ drv_data->bytes_left = msg->len;
+ drv_data->aborting = 0;
+ drv_data->rc = 0;
+ /* in u-boot we use no IRQs */
+ drv_data->cntl_bits = KW_I2C_REG_CONTROL_ACK | KW_I2C_REG_CONTROL_TWSIEN;
+
+ if (msg->flags & I2C_M_RD)
+ dir = 1;
+ if (msg->flags & I2C_M_TEN) {
+ drv_data->addr1 = 0xf0 | (((u32)msg->addr & 0x300) >> 7) | dir;
+ drv_data->addr2 = (u32)msg->addr & 0xff;
+ } else {
+ drv_data->addr1 = ((u32)msg->addr & 0x7f) << 1 | dir;
+ drv_data->addr2 = 0;
+ }
+ /* OK, no start it (from kirkwood_i2c_execute_msg())*/
+ drv_data->action = KW_I2C_ACTION_SEND_START;
+ drv_data->state = KW_I2C_STATE_WAITING_FOR_START_COND;
+ drv_data->block = 1;
+ kirkwood_i2c_do_action();
+}
+
+void
+i2c_init(int speed, int slaveadd)
+{
+ kirkwood_i2c_hw_init(speed, slaveadd);
+}
+
+int
+i2c_read(u8 dev, uint addr, int alen, u8 *data, int length)
+{
+ kirkwood_i2c_msg->buf = data;
+ kirkwood_i2c_msg->len = length;
+ kirkwood_i2c_msg->addr = dev;
+ kirkwood_i2c_msg->flags = I2C_M_RD;
+
+ kirkwood_i2c_prepare_for_io(kirkwood_i2c_msg);
+ kirkwood_i2c_doio(kirkwood_i2c_msg);
+ return drv_data->rc;
+}
+
+int
+i2c_write(u8 dev, uint addr, int alen, u8 *data, int length)
+{
+ kirkwood_i2c_msg->buf = data;
+ kirkwood_i2c_msg->len = length;
+ kirkwood_i2c_msg->addr = dev;
+ kirkwood_i2c_msg->flags = 0;
+
+ kirkwood_i2c_prepare_for_io(kirkwood_i2c_msg);
+ kirkwood_i2c_doio(kirkwood_i2c_msg);
+ return drv_data->rc;
+}
+
+int
+i2c_probe(uchar chip)
+{
+ return i2c_read(chip, 0, 0, NULL, 0);
+}
+
+int i2c_set_bus_num(unsigned int bus)
+{
+#if defined(CONFIG_I2C_MUX)
+ if (bus < CONFIG_SYS_MAX_I2C_BUS) {
+ i2c_bus_num = bus;
+ } else {
+ int ret;
+
+ ret = i2x_mux_select_mux(bus);
+ if (ret)
+ return ret;
+ i2c_bus_num = 0;
+ }
+ i2c_bus_num_mux = bus;
+#else
+ if (bus > 0) {
+ return -1;
+ }
+
+ i2c_bus_num = bus;
+#endif
+ return 0;
+}
+
+unsigned int i2c_get_bus_num(void)
+{
+#if defined(CONFIG_I2C_MUX)
+ return i2c_bus_num_mux;
+#else
+ return i2c_bus_num;
+#endif
+}
+
--
1.6.0.GIT
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [U-Boot] [PATCH v3] arm, i2c: added support for the TWSI I2C Interface
2009-07-20 7:59 ` [U-Boot] [PATCH v3] " Heiko Schocher
@ 2009-07-22 21:46 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-23 5:09 ` Prafulla Wadaskar
2009-07-28 7:31 ` Heiko Schocher
1 sibling, 1 reply; 20+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-07-22 21:46 UTC (permalink / raw)
To: u-boot
On 09:59 Mon 20 Jul , Heiko Schocher wrote:
> Signed-off-by: Heiko Schocher <hs@denx.de>
> ---
> - changes since v1:
> added comments from Prafulla Wadaskar
> - changes since v2
> added comments from Jean-Christophe
> - added speed setting
>
> drivers/i2c/Makefile | 1 +
> drivers/i2c/kirkwood_i2c.c | 484 ++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 485 insertions(+), 0 deletions(-)
> create mode 100644 drivers/i2c/kirkwood_i2c.c
>
ok for me
Prafulla I guess it's ok for you too
Best Regards,
J.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] [PATCH v3] arm, i2c: added support for the TWSI I2C Interface
2009-07-22 21:46 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-07-23 5:09 ` Prafulla Wadaskar
0 siblings, 0 replies; 20+ messages in thread
From: Prafulla Wadaskar @ 2009-07-23 5:09 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: Jean-Christophe PLAGNIOL-VILLARD [mailto:plagnioj at jcrosoft.com]
> Sent: Thursday, July 23, 2009 3:17 AM
> To: Heiko Schocher
> Cc: Prafulla Wadaskar; U-Boot user list; Wolfgang Denk
> Subject: Re: [PATCH v3] arm, i2c: added support for the TWSI
> I2C Interface
>
> On 09:59 Mon 20 Jul , Heiko Schocher wrote:
> > Signed-off-by: Heiko Schocher <hs@denx.de>
> > ---
> > - changes since v1:
> > added comments from Prafulla Wadaskar
> > - changes since v2
> > added comments from Jean-Christophe
> > - added speed setting
> >
> > drivers/i2c/Makefile | 1 +
> > drivers/i2c/kirkwood_i2c.c | 484
> > ++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 485 insertions(+), 0 deletions(-) create mode
> > 100644 drivers/i2c/kirkwood_i2c.c
> >
> ok for me
> Prafulla I guess it's ok for you too
Dear Jean,
Yes, it's okay for me too.
Regards..
Prafulla . .
>
> Best Regards,
> J.
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [U-Boot] [PATCH v3] arm, i2c: added support for the TWSI I2C Interface
2009-07-20 7:59 ` [U-Boot] [PATCH v3] " Heiko Schocher
2009-07-22 21:46 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-07-28 7:31 ` Heiko Schocher
1 sibling, 0 replies; 20+ messages in thread
From: Heiko Schocher @ 2009-07-28 7:31 UTC (permalink / raw)
To: u-boot
Hello Heiko,
Heiko Schocher wrote:
> Signed-off-by: Heiko Schocher <hs@denx.de>
> ---
> - changes since v1:
> added comments from Prafulla Wadaskar
> - changes since v2
> added comments from Jean-Christophe
> - added speed setting
>
> drivers/i2c/Makefile | 1 +
> drivers/i2c/kirkwood_i2c.c | 484 ++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 485 insertions(+), 0 deletions(-)
> create mode 100644 drivers/i2c/kirkwood_i2c.c
Applied.
bye
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2009-07-28 7:31 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-16 8:01 [U-Boot] arm, i2c: added support for the TWSI I2C Interface Heiko Schocher
2009-07-16 8:52 ` Prafulla Wadaskar
2009-07-16 10:03 ` Heiko Schocher
2009-07-16 10:06 ` Prafulla Wadaskar
2009-07-16 10:17 ` Heiko Schocher
2009-07-16 10:19 ` Prafulla Wadaskar
2009-07-16 11:09 ` Heiko Schocher
2009-07-18 10:55 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-18 12:42 ` Wolfgang Denk
2009-07-18 12:54 ` Heiko Schocher
2009-07-18 12:57 ` Wolfgang Denk
2009-07-18 13:21 ` Heiko Schocher
2009-07-18 13:50 ` Wolfgang Denk
2009-07-19 5:52 ` Heiko Schocher
2009-07-20 7:59 ` [U-Boot] [PATCH v3] " Heiko Schocher
2009-07-22 21:46 ` Jean-Christophe PLAGNIOL-VILLARD
2009-07-23 5:09 ` Prafulla Wadaskar
2009-07-28 7:31 ` Heiko Schocher
2009-07-18 10:56 ` [U-Boot] [PATCH] i2c: use for CONFIGs a common naming convention CONFIG_I2C Jean-Christophe PLAGNIOL-VILLARD
2009-07-18 12:49 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox