Merge branch 'master' of git://git.denx.de/u-boot-mpc83xx
authorWolfgang Denk <wd@denx.de>
Sat, 8 May 2010 23:16:51 +0000 (01:16 +0200)
committerWolfgang Denk <wd@denx.de>
Sat, 8 May 2010 23:16:51 +0000 (01:16 +0200)
14 files changed:
Makefile
arch/.gitignore [new file with mode: 0644]
arch/powerpc/cpu/mpc5xxx/cpu.c
arch/powerpc/cpu/mpc8260/commproc.c
arch/powerpc/cpu/mpc83xx/cpu.c
arch/powerpc/cpu/mpc8xx/commproc.c
arch/powerpc/cpu/ppc4xx/commproc.c
arch/powerpc/lib/Makefile
arch/powerpc/lib/bootcount.c [new file with mode: 0644]
board/barco/barco.c
common/cmd_usb.c
drivers/i2c/bfin-twi_i2c.c
include/.gitignore
include/common.h

index 2d96574..82cbbf4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -38,9 +38,9 @@ HOSTARCH := $(shell uname -m | \
            -e s/sun4u/sparc64/ \
            -e s/arm.*/arm/ \
            -e s/sa110/arm/ \
-           -e s/powerpc/ppc/ \
-           -e s/ppc64/ppc/ \
-           -e s/macppc/ppc/)
+           -e s/ppc64/powerpc/ \
+           -e s/ppc/powerpc/ \
+           -e s/macppc/powerpc/)
 
 HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
            sed -e 's/\(cygwin\).*/cygwin/')
diff --git a/arch/.gitignore b/arch/.gitignore
new file mode 100644 (file)
index 0000000..a1fbe01
--- /dev/null
@@ -0,0 +1,2 @@
+/*/include/asm/arch
+/*/include/asm/proc
index b20234d..44b8a7a 100644 (file)
@@ -154,26 +154,6 @@ void ft_cpu_setup(void *blob, bd_t *bd)
 }
 #endif
 
-#ifdef CONFIG_BOOTCOUNT_LIMIT
-
-void bootcount_store (ulong a)
-{
-       volatile ulong *save_addr = (volatile ulong *) (MPC5XXX_CDM_BRDCRMB);
-
-       *save_addr = (BOOTCOUNT_MAGIC & 0xffff0000) | a;
-}
-
-ulong bootcount_load (void)
-{
-       volatile ulong *save_addr = (volatile ulong *) (MPC5XXX_CDM_BRDCRMB);
-
-       if ((*save_addr & 0xffff0000) != (BOOTCOUNT_MAGIC & 0xffff0000))
-               return 0;
-       else
-               return (*save_addr & 0x0000ffff);
-}
-#endif /* CONFIG_BOOTCOUNT_LIMIT */
-
 #ifdef CONFIG_MPC5xxx_FEC
 /* Default initializations for FEC controllers.  To override,
  * create a board-specific function called:
index 111a67c..c522bc5 100644 (file)
@@ -195,27 +195,3 @@ ulong post_word_load (void)
 }
 
 #endif /* CONFIG_POST || CONFIG_LOGBUFFER*/
-
-#ifdef CONFIG_BOOTCOUNT_LIMIT
-
-void bootcount_store (ulong a)
-{
-       volatile ulong *save_addr =
-               (volatile ulong *)(CONFIG_SYS_IMMR + CPM_BOOTCOUNT_ADDR);
-
-       save_addr[0] = a;
-       save_addr[1] = BOOTCOUNT_MAGIC;
-}
-
-ulong bootcount_load (void)
-{
-       volatile ulong *save_addr =
-               (volatile ulong *)(CONFIG_SYS_IMMR + CPM_BOOTCOUNT_ADDR);
-
-       if (save_addr[1] != BOOTCOUNT_MAGIC)
-               return 0;
-       else
-               return save_addr[0];
-}
-
-#endif /* CONFIG_BOOTCOUNT_LIMIT */
index 8b98a57..d3be909 100644 (file)
@@ -304,33 +304,3 @@ int cpu_mmc_init(bd_t *bis)
        return 0;
 #endif
 }
-
-#ifdef CONFIG_BOOTCOUNT_LIMIT
-
-#if !defined(CONFIG_MPC8360)
-#error "CONFIG_BOOTCOUNT_LIMIT only for MPC8360 implemented"
-#endif
-
-#if !defined(CONFIG_BOOTCOUNT_ADDR)
-#define CONFIG_BOOTCOUNT_ADDR  (0x110000 + QE_MURAM_SIZE - 2 * sizeof(unsigned long))
-#endif
-
-#include <asm/io.h>
-
-void bootcount_store (ulong a)
-{
-       void *reg = (void *)(CONFIG_SYS_IMMR + CONFIG_BOOTCOUNT_ADDR);
-       out_be32 (reg, a);
-       out_be32 (reg + 4, BOOTCOUNT_MAGIC);
-}
-
-ulong bootcount_load (void)
-{
-       void *reg = (void *)(CONFIG_SYS_IMMR + CONFIG_BOOTCOUNT_ADDR);
-
-       if (in_be32 (reg + 4) != BOOTCOUNT_MAGIC)
-               return 0;
-       else
-               return in_be32 (reg);
-}
-#endif /* CONFIG_BOOTCOUNT_LIMIT */
index a87a0dc..2c85377 100644 (file)
@@ -103,29 +103,3 @@ ulong post_word_load (void)
 }
 
 #endif /* CONFIG_POST || CONFIG_LOGBUFFER*/
-
-#ifdef CONFIG_BOOTCOUNT_LIMIT
-
-void bootcount_store (ulong a)
-{
-       volatile ulong *save_addr =
-               (volatile ulong *)( ((immap_t *) CONFIG_SYS_IMMR)->im_cpm.cp_dpmem +
-                                   CPM_BOOTCOUNT_ADDR );
-
-       save_addr[0] = a;
-       save_addr[1] = BOOTCOUNT_MAGIC;
-}
-
-ulong bootcount_load (void)
-{
-       volatile ulong *save_addr =
-               (volatile ulong *)( ((immap_t *) CONFIG_SYS_IMMR)->im_cpm.cp_dpmem +
-                                   CPM_BOOTCOUNT_ADDR );
-
-       if (save_addr[1] != BOOTCOUNT_MAGIC)
-               return 0;
-       else
-               return save_addr[0];
-}
-
-#endif /* CONFIG_BOOTCOUNT_LIMIT */
index a1696d3..6bf95e6 100644 (file)
@@ -51,27 +51,3 @@ ulong post_word_load (void)
 }
 
 #endif /* CONFIG_POST || CONFIG_LOGBUFFER*/
-
-#ifdef CONFIG_BOOTCOUNT_LIMIT
-
-void bootcount_store (ulong a)
-{
-       volatile ulong *save_addr =
-               (volatile ulong *)(CONFIG_SYS_OCM_DATA_ADDR + CONFIG_SYS_BOOTCOUNT_ADDR);
-
-       save_addr[0] = a;
-       save_addr[1] = BOOTCOUNT_MAGIC;
-}
-
-ulong bootcount_load (void)
-{
-       volatile ulong *save_addr =
-               (volatile ulong *)(CONFIG_SYS_OCM_DATA_ADDR + CONFIG_SYS_BOOTCOUNT_ADDR);
-
-       if (save_addr[1] != BOOTCOUNT_MAGIC)
-               return 0;
-       else
-               return save_addr[0];
-}
-
-#endif /* CONFIG_BOOTCOUNT_LIMIT */
index 334e457..5f85502 100644 (file)
@@ -33,6 +33,7 @@ SOBJS-y       += reloc.o
 COBJS-y        += bat_rw.o
 COBJS-y        += board.o
 COBJS-y        += bootm.o
+COBJS-$(CONFIG_BOOTCOUNT_LIMIT) += bootcount.o
 COBJS-y        += cache.o
 COBJS-y        += extable.o
 COBJS-y        += interrupts.o
diff --git a/arch/powerpc/lib/bootcount.c b/arch/powerpc/lib/bootcount.c
new file mode 100644 (file)
index 0000000..6346527
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * (C) Copyright 2010
+ * Stefan Roese, DENX Software Engineering, sr@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <asm/io.h>
+
+/*
+ * Only override CONFIG_SYS_BOOTCOUNT_ADDR if not already defined. This
+ * way, some boards can define it directly in their config header.
+ */
+#if !defined(CONFIG_SYS_BOOTCOUNT_ADDR)
+
+#if defined(CONFIG_MPC5xxx)
+#define CONFIG_SYS_BOOTCOUNT_ADDR      (MPC5XXX_CDM_BRDCRMB)
+#define CONFIG_SYS_BOOTCOUNT_SINGLEWORD
+#endif /* defined(CONFIG_MPC5xxx) */
+
+#if defined(CONFIG_8xx)
+#define CONFIG_SYS_BOOTCOUNT_ADDR (((immap_t *)CONFIG_SYS_IMMR)->im_cpm.cp_dpmem + \
+                               CPM_BOOTCOUNT_ADDR)
+#endif /* defined(CONFIG_8xx) */
+
+#if defined(CONFIG_MPC8260)
+#include <asm/cpm_8260.h>
+
+#define CONFIG_SYS_BOOTCOUNT_ADDR      (CONFIG_SYS_IMMR + CPM_BOOTCOUNT_ADDR)
+#endif /* defined(CONFIG_MPC8260) */
+
+#if defined(CONFIG_MPC8360)
+#include <asm/immap_qe.h>
+
+#define CONFIG_SYS_BOOTCOUNT_ADDR      (CONFIG_SYS_IMMR + 0x110000 + \
+                                        QE_MURAM_SIZE - 2 * sizeof(u32))
+#endif /* defined(CONFIG_MPC8360) */
+
+#if defined(CONFIG_4xx)
+#define CONFIG_SYS_BOOTCOUNT_ADDR      (CONFIG_SYS_OCM_DATA_ADDR + \
+                               CONFIG_SYS_BOOTCOUNT_ADDR)
+#endif /* defined(CONFIG_4xx) */
+
+#endif /* !defined(CONFIG_SYS_BOOTCOUNT_ADDR) */
+
+void bootcount_store(ulong a)
+{
+       void *reg = (void *)CONFIG_SYS_BOOTCOUNT_ADDR;
+
+#if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD)
+       out_be32(reg, (BOOTCOUNT_MAGIC & 0xffff0000) | a);
+#else
+       out_be32(reg, a);
+       out_be32(reg + 4, BOOTCOUNT_MAGIC);
+#endif
+}
+
+ulong bootcount_load(void)
+{
+       void *reg = (void *)CONFIG_SYS_BOOTCOUNT_ADDR;
+
+#if defined(CONFIG_SYS_BOOTCOUNT_SINGLEWORD)
+       if (in_be16(reg + 2) != (BOOTCOUNT_MAGIC & 0xffff))
+               return 0;
+       else
+               return in_be16(reg);
+#else
+       if (in_be32(reg + 4) != BOOTCOUNT_MAGIC)
+               return 0;
+       else
+               return in_be32(reg);
+#endif
+}
index d7a0078..c5fe8c4 100644 (file)
@@ -340,10 +340,6 @@ void serial_puts (const char *c)
 {
        return;
 }
-void serial_addr (unsigned int i)
-{
-       return;
-}
 int serial_getc (void)
 {
        return 0;
index ee3755c..fcb5f76 100644 (file)
@@ -516,6 +516,11 @@ int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        block_dev_desc_t *stor_dev;
 #endif
 
+       if (argc < 2) {
+               cmd_usage(cmdtp);
+               return 1;
+       }
+
        if ((strncmp(argv[1], "reset", 5) == 0) ||
                 (strncmp(argv[1], "start", 5) == 0)) {
                usb_stop();
index 73a78d2..b3a04d3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * i2c.c - driver for Blackfin on-chip TWI/I2C
  *
- * Copyright (c) 2006-2008 Analog Devices Inc.
+ * Copyright (c) 2006-2010 Analog Devices Inc.
  *
  * Licensed under the GPL-2 or later.
  */
 #include <asm/blackfin.h>
 #include <asm/mach-common/bits/twi.h>
 
+/* Every register is 32bit aligned, but only 16bits in size */
+#define ureg(name) u16 name; u16 __pad_##name;
+struct twi_regs {
+       ureg(clkdiv);
+       ureg(control);
+       ureg(slave_ctl);
+       ureg(slave_stat);
+       ureg(slave_addr);
+       ureg(master_ctl);
+       ureg(master_stat);
+       ureg(master_addr);
+       ureg(int_stat);
+       ureg(int_mask);
+       ureg(fifo_ctl);
+       ureg(fifo_stat);
+       char __pad[0x50];
+       ureg(xmt_data8);
+       ureg(xmt_data16);
+       ureg(rcv_data8);
+       ureg(rcv_data16);
+};
+#undef ureg
+
+/* U-Boot I2C framework allows only one active device at a time.  */
+#ifdef TWI_CLKDIV
+#define TWI0_CLKDIV TWI_CLKDIV
+#endif
+static volatile struct twi_regs *twi = (void *)TWI0_CLKDIV;
+
 #ifdef DEBUG
 # define dmemset(s, c, n) memset(s, c, n)
 #else
 #endif
 #define debugi(fmt, args...) \
        debug( \
-               "MSTAT:0x%03x FSTAT:0x%x ISTAT:0x%02x\t" \
-               "%-20s:%-3i: " fmt "\n", \
-               bfin_read_TWI_MASTER_STAT(), bfin_read_TWI_FIFO_STAT(), bfin_read_TWI_INT_STAT(), \
+               "MSTAT:0x%03x FSTAT:0x%x ISTAT:0x%02x\t%-20s:%-3i: " fmt "\n", \
+               twi->master_stat, twi->fifo_stat, twi->int_stat, \
                __func__, __LINE__, ## args)
 
-#ifdef TWI0_CLKDIV
-#define bfin_write_TWI_CLKDIV(val)           bfin_write_TWI0_CLKDIV(val)
-#define bfin_read_TWI_CLKDIV(val)            bfin_read_TWI0_CLKDIV(val)
-#define bfin_write_TWI_CONTROL(val)          bfin_write_TWI0_CONTROL(val)
-#define bfin_read_TWI_CONTROL(val)           bfin_read_TWI0_CONTROL(val)
-#define bfin_write_TWI_MASTER_ADDR(val)      bfin_write_TWI0_MASTER_ADDR(val)
-#define bfin_write_TWI_XMT_DATA8(val)        bfin_write_TWI0_XMT_DATA8(val)
-#define bfin_read_TWI_RCV_DATA8()            bfin_read_TWI0_RCV_DATA8()
-#define bfin_read_TWI_INT_STAT()             bfin_read_TWI0_INT_STAT()
-#define bfin_write_TWI_INT_STAT(val)         bfin_write_TWI0_INT_STAT(val)
-#define bfin_read_TWI_MASTER_STAT()          bfin_read_TWI0_MASTER_STAT()
-#define bfin_write_TWI_MASTER_STAT(val)      bfin_write_TWI0_MASTER_STAT(val)
-#define bfin_read_TWI_MASTER_CTL()           bfin_read_TWI0_MASTER_CTL()
-#define bfin_write_TWI_MASTER_CTL(val)       bfin_write_TWI0_MASTER_CTL(val)
-#define bfin_write_TWI_INT_MASK(val)         bfin_write_TWI0_INT_MASK(val)
-#define bfin_write_TWI_FIFO_CTL(val)         bfin_write_TWI0_FIFO_CTL(val)
-#endif
-
 #ifdef CONFIG_TWICLK_KHZ
 # error do not define CONFIG_TWICLK_KHZ ... use CONFIG_SYS_I2C_SPEED
 #endif
@@ -87,49 +97,48 @@ static int wait_for_completion(struct i2c_msg *msg)
        ulong timebase = get_timer(0);
 
        do {
-               int_stat = bfin_read_TWI_INT_STAT();
+               int_stat = twi->int_stat;
 
                if (int_stat & XMTSERV) {
                        debugi("processing XMTSERV");
-                       bfin_write_TWI_INT_STAT(XMTSERV);
+                       twi->int_stat = XMTSERV;
                        SSYNC();
                        if (msg->alen) {
-                               bfin_write_TWI_XMT_DATA8(*(msg->abuf++));
+                               twi->xmt_data8 = *(msg->abuf++);
                                --msg->alen;
                        } else if (!(msg->flags & I2C_M_COMBO) && msg->len) {
-                               bfin_write_TWI_XMT_DATA8(*(msg->buf++));
+                               twi->xmt_data8 = *(msg->buf++);
                                --msg->len;
                        } else {
-                               bfin_write_TWI_MASTER_CTL(bfin_read_TWI_MASTER_CTL() |
-                                       (msg->flags & I2C_M_COMBO ? RSTART | MDIR : STOP));
+                               twi->master_ctl |= (msg->flags & I2C_M_COMBO) ? RSTART | MDIR : STOP;
                                SSYNC();
                        }
                }
                if (int_stat & RCVSERV) {
                        debugi("processing RCVSERV");
-                       bfin_write_TWI_INT_STAT(RCVSERV);
+                       twi->int_stat = RCVSERV;
                        SSYNC();
                        if (msg->len) {
-                               *(msg->buf++) = bfin_read_TWI_RCV_DATA8();
+                               *(msg->buf++) = twi->rcv_data8;
                                --msg->len;
                        } else if (msg->flags & I2C_M_STOP) {
-                               bfin_write_TWI_MASTER_CTL(bfin_read_TWI_MASTER_CTL() | STOP);
+                               twi->master_ctl |= STOP;
                                SSYNC();
                        }
                }
                if (int_stat & MERR) {
                        debugi("processing MERR");
-                       bfin_write_TWI_INT_STAT(MERR);
+                       twi->int_stat = MERR;
                        SSYNC();
                        return msg->len;
                }
                if (int_stat & MCOMP) {
                        debugi("processing MCOMP");
-                       bfin_write_TWI_INT_STAT(MCOMP);
+                       twi->int_stat = MCOMP;
                        SSYNC();
                        if (msg->flags & I2C_M_COMBO && msg->len) {
-                               bfin_write_TWI_MASTER_CTL((bfin_read_TWI_MASTER_CTL() & ~RSTART) |
-                                       (min(msg->len, 0xff) << 6) | MEN | MDIR);
+                               twi->master_ctl = (twi->master_ctl & ~RSTART) |
+                                       (min(msg->len, 0xff) << 6) | MEN | MDIR;
                                SSYNC();
                        } else
                                break;
@@ -172,55 +181,54 @@ static int i2c_transfer(uchar chip, uint addr, int alen, uchar *buffer, int len,
                chip, addr, alen, buffer[0], len, flags, (flags & I2C_M_READ ? "rd" : "wr"));
 
        /* wait for things to settle */
-       while (bfin_read_TWI_MASTER_STAT() & BUSBUSY)
+       while (twi->master_stat & BUSBUSY)
                if (ctrlc())
                        return 1;
 
        /* Set Transmit device address */
-       bfin_write_TWI_MASTER_ADDR(chip);
+       twi->master_addr = chip;
 
        /* Clear the FIFO before starting things */
-       bfin_write_TWI_FIFO_CTL(XMTFLUSH | RCVFLUSH);
+       twi->fifo_ctl = XMTFLUSH | RCVFLUSH;
        SSYNC();
-       bfin_write_TWI_FIFO_CTL(0);
+       twi->fifo_ctl = 0;
        SSYNC();
 
        /* prime the pump */
        if (msg.alen) {
                len = (msg.flags & I2C_M_COMBO) ? msg.alen : msg.alen + len;
                debugi("first byte=0x%02x", *msg.abuf);
-               bfin_write_TWI_XMT_DATA8(*(msg.abuf++));
+               twi->xmt_data8 = *(msg.abuf++);
                --msg.alen;
        } else if (!(msg.flags & I2C_M_READ) && msg.len) {
                debugi("first byte=0x%02x", *msg.buf);
-               bfin_write_TWI_XMT_DATA8(*(msg.buf++));
+               twi->xmt_data8 = *(msg.buf++);
                --msg.len;
        }
 
        /* clear int stat */
-       bfin_write_TWI_MASTER_STAT(-1);
-       bfin_write_TWI_INT_STAT(-1);
-       bfin_write_TWI_INT_MASK(0);
+       twi->master_stat = -1;
+       twi->int_stat = -1;
+       twi->int_mask = 0;
        SSYNC();
 
        /* Master enable */
-       bfin_write_TWI_MASTER_CTL(
-                       (bfin_read_TWI_MASTER_CTL() & FAST) |
+       twi->master_ctl =
+                       (twi->master_ctl & FAST) |
                        (min(len, 0xff) << 6) | MEN |
-                       ((msg.flags & I2C_M_READ) ? MDIR : 0)
-       );
+                       ((msg.flags & I2C_M_READ) ? MDIR : 0);
        SSYNC();
-       debugi("CTL=0x%04x", bfin_read_TWI_MASTER_CTL());
+       debugi("CTL=0x%04x", twi->master_ctl);
 
        /* process the rest */
        ret = wait_for_completion(&msg);
        debugi("ret=%d", ret);
 
        if (ret) {
-               bfin_write_TWI_MASTER_CTL(bfin_read_TWI_MASTER_CTL() & ~MEN);
-               bfin_write_TWI_CONTROL(bfin_read_TWI_CONTROL() & ~TWI_ENA);
+               twi->master_ctl &= ~MEN;
+               twi->control &= ~TWI_ENA;
                SSYNC();
-               bfin_write_TWI_CONTROL(bfin_read_TWI_CONTROL() | TWI_ENA);
+               twi->control |= TWI_ENA;
                SSYNC();
        }
 
@@ -238,10 +246,10 @@ int i2c_set_bus_speed(unsigned int speed)
        /* Set TWI interface clock */
        if (clkdiv < I2C_DUTY_MAX || clkdiv > I2C_DUTY_MIN)
                return -1;
-       bfin_write_TWI_CLKDIV((clkdiv << 8) | (clkdiv & 0xff));
+       twi->clkdiv = (clkdiv << 8) | (clkdiv & 0xff);
 
        /* Don't turn it on */
-       bfin_write_TWI_MASTER_CTL(speed > 100000 ? FAST : 0);
+       twi->master_ctl = (speed > 100000 ? FAST : 0);
 
        return 0;
 }
@@ -253,7 +261,7 @@ int i2c_set_bus_speed(unsigned int speed)
 unsigned int i2c_get_bus_speed(void)
 {
        /* 10 MHz / (2 * CLKDIV) -> 5 MHz / CLKDIV */
-       return 5000000 / (bfin_read_TWI_CLKDIV() & 0xff);
+       return 5000000 / (twi->clkdiv & 0xff);
 }
 
 /**
@@ -269,24 +277,23 @@ void i2c_init(int speed, int slaveaddr)
        uint8_t prescale = ((get_sclk() / 1024 / 1024 + 5) / 10) & 0x7F;
 
        /* Set TWI internal clock as 10MHz */
-       bfin_write_TWI_CONTROL(prescale);
+       twi->control = prescale;
 
        /* Set TWI interface clock as specified */
        i2c_set_bus_speed(speed);
 
        /* Enable it */
-       bfin_write_TWI_CONTROL(TWI_ENA | prescale);
+       twi->control = TWI_ENA | prescale;
        SSYNC();
 
-       debugi("CONTROL:0x%04x CLKDIV:0x%04x",
-               bfin_read_TWI_CONTROL(), bfin_read_TWI_CLKDIV());
+       debugi("CONTROL:0x%04x CLKDIV:0x%04x", twi->control, twi->clkdiv);
 
 #if CONFIG_SYS_I2C_SLAVE
 # error I2C slave support not tested/supported
        /* If they want us as a slave, do it */
        if (slaveaddr) {
-               bfin_write_TWI_SLAVE_ADDR(slaveaddr);
-               bfin_write_TWI_SLAVE_CTL(SEN);
+               twi->slave_addr = slaveaddr;
+               twi->slave_ctl = SEN;
        }
 #endif
 }
@@ -329,3 +336,43 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
 {
        return i2c_transfer(chip, addr, alen, buffer, len, 0);
 }
+
+/**
+ * i2c_set_bus_num - change active I2C bus
+ *     @bus: bus index, zero based
+ *     @returns: 0 on success, non-0 on failure
+ */
+int i2c_set_bus_num(unsigned int bus)
+{
+       switch (bus) {
+#if CONFIG_SYS_MAX_I2C_BUS > 0
+               case 0: twi = (void *)TWI0_CLKDIV; return 0;
+#endif
+#if CONFIG_SYS_MAX_I2C_BUS > 1
+               case 1: twi = (void *)TWI1_CLKDIV; return 0;
+#endif
+#if CONFIG_SYS_MAX_I2C_BUS > 2
+               case 2: twi = (void *)TWI2_CLKDIV; return 0;
+#endif
+               default: return -1;
+       }
+}
+
+/**
+ * i2c_get_bus_num - returns index of active I2C bus
+ */
+unsigned int i2c_get_bus_num(void)
+{
+       switch ((unsigned long)twi) {
+#if CONFIG_SYS_MAX_I2C_BUS > 0
+               case TWI0_CLKDIV: return 0;
+#endif
+#if CONFIG_SYS_MAX_I2C_BUS > 1
+               case TWI1_CLKDIV: return 1;
+#endif
+#if CONFIG_SYS_MAX_I2C_BUS > 2
+               case TWI2_CLKDIV: return 2;
+#endif
+               default: return -1;
+       }
+}
index 4481412..77594e5 100644 (file)
@@ -1,7 +1,5 @@
 /autoconf.mk*
 /asm
-/asm-*/arch
-/asm-*/proc
 /bmp_logo.h
 /config.h
 /config.mk
index 5591e1d..8bca04f 100644 (file)
@@ -470,7 +470,6 @@ void ft_pci_setup(void *blob, bd_t *bd);
 /* $(CPU)/serial.c */
 int    serial_init   (void);
 void   serial_exit   (void);
-void   serial_addr   (unsigned int);
 void   serial_setbrg (void);
 void   serial_putc   (const char);
 void   serial_putc_raw(const char);