]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
* Misc fixes to the I2C subsystem
authorwdenk <wdenk>
Thu, 14 Mar 2002 10:29:08 +0000 (10:29 +0000)
committerwdenk <wdenk>
Thu, 14 Mar 2002 10:29:08 +0000 (10:29 +0000)
* Patch by Miguel Bello, 20 Feb 2002
  Add support for Prime View V16C6448AC LCD

16 files changed:
CHANGELOG
common/cmd_i2c.c
common/soft_i2c.c
config.mk
cpu/mpc824x/drivers/i2c/i2c1.c
cpu/mpc8260/i2c.c
cpu/mpc8xx/i2c.c
cpu/mpc8xx/lcd.c
cpu/ppc4xx/i2c.c
cpu/ppc4xx/spd_sdram.c
dtt/lm75.c
include/cmd_confdefs.h
include/cmd_i2c.h
include/config_ppmc8260.h
tools/Makefile
tools/bmp_logo.c

index 6b4c3fbabd73d7c663bbd75d3deffa75f147a500..05c3b4b1376a373c8cc97b49e6df467bb4934bd1 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -14,6 +14,9 @@
 Modifications for 1.1.6:
 ======================================================================
 
+* Patch by Miguel Bello, 20 Feb 2002
+  Add support for Prime View V16C6448AC LCD
+
 * Add support for TTTech board (TQM823E + Sharp LQ104V7DS01 Display)
 
 * Patch by Stefan Roese, 11 Mar 2002
index 5d9a391f8ad83ee97e8dec58bbb32add5e8f416e..d856760796e760582325ac44718915688c25bd4a 100644 (file)
@@ -562,6 +562,13 @@ int do_i2c_loop(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
        return 0;
 }
 
+
+/*
+ * The SDRAM command is separately configured because many
+ * (most?) embedded boards don't use SDRAM DIMMs.
+ */
+#if (CONFIG_COMMANDS & CFG_CMD_SDRAM)
+
 /*
  * Syntax:
  *     sdram {i2c_chip}
@@ -782,5 +789,6 @@ int do_sdram(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 
        return 0;
 }
+#endif /* CFG_CMD_SDRAM */
 
 #endif /* CFG_CMD_I2C */
index 6afddfbc6dd24a458ebd495bbc3c7d6a5b9a42b9..c8d823dcca32a502cf5d035d5c6ee25fd391dff5 100644 (file)
@@ -252,6 +252,21 @@ int i2c_probe(uchar addr)
  */
 int  i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
 {
+#ifdef CFG_I2C_EEPROM_ADDR_OVERFLOW
+       /*
+        * EEPROM chips that implement "address overflow" are ones
+        * like Catalyst 24WC04/08/16 which has 9/10/11 bits of
+        * address and the extra bits end up in the "chip address"
+        * bit slots. This makes a 24WC08 (1Kbyte) chip look like
+        * four 256 byte chips.
+        *
+        * Note that we consider the length of the address field to
+        * still be one byte because the extra address bits are
+        * hidden in the chip address.
+        */
+       chip |= ((addr >> (alen * 8)) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
+#endif
+
        /*
         * Do the addressing portion of a write cycle to set the
         * chip's address pointer.  If the address length is zero,
index 229d4be82ffc9d2f3a056ffefe406ddb756a9465..82e0362f5bde8aac0102296cc86628cdb4b70db1 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -86,7 +86,7 @@ RELFLAGS= $(PLATFORM_RELFLAGS)
 DBGFLAGS= -g #-DDEBUG
 OPTFLAGS= -Os -fomit-frame-pointer
 #LDSCRIPT := board/$(BOARDDIR)/ppcboot.lds.debug
-LDSCRIPT := board/$(BOARDDIR)/ppcboot.lds
+LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/ppcboot.lds
 OBJCFLAGS := --gap-fill=0xff
 
 CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)                        \
index 4a97301b9aaa6c9fdd5bd43ecf4ddc61cce3d7f2..0c723ef8cf572c0c87649fa277a9927101c04774 100644 (file)
@@ -1133,28 +1133,15 @@ void i2c_init (int speed, int slaveadd)
 
 int i2c_probe (uchar chip)
 {
-       return 0;
-}
-
-#if 0
-int i2c_receive (unsigned char address,
-                unsigned char secondary_address,
-                unsigned short size_to_expect, unsigned char *datain)
-{
-       return I2C_do_transaction (0, I2C_MASTER_RCV, address,
-                                  secondary_address, size_to_expect,
-                                  datain, I2C_STOP, 1, I2C_NO_RESTART);
-}
+       int tmp;
 
-int i2c_send (unsigned char address,
-             unsigned char secondary_address,
-             unsigned short size_to_send, unsigned char *dataout)
-{
-       return I2C_do_transaction (0, I2C_MASTER_XMIT, address,
-                                  secondary_address, size_to_send,
-                                  dataout, I2C_STOP, 1, I2C_NO_RESTART);
+       /*
+        * Try to read the first location of the chip.  The underlying
+        * driver doesn't appear to support sending just the chip address
+        * and looking for an <ACK> back.
+        */
+       return i2c_read (chip, 0, 1, &tmp, 0);
 }
-#endif
 
 int i2c_read (uchar chip, uint addr, int alen, uchar * buffer, int len)
 {
index d3f8fe6a5e937625c4ab45ac15fab6a518ad4f9f..bab8d7c3c0482854b629556b21c2e8a95360aa3c 100644 (file)
@@ -489,6 +489,8 @@ int i2c_doio(i2c_state_t *state)
 
        PRINTD(("[I2C] i2c_doio\n"));
 
+        timeout = TOUT_LOOP * 256;     /* arbitrarily long */
+
        if (state->tx_idx <= 0 && state->rx_idx <= 0) {
                PRINTD(("[I2C] No I/O is queued\n"));
                return I2CERR_QUEUE_EMPTY;
@@ -508,9 +510,9 @@ int i2c_doio(i2c_state_t *state)
 
        /* Loop until transmit & receive completed */
 
+       txbd = ((I2C_BD*)state->txbd) - 1;
+       j = 0;
        if (state->tx_idx > 0) {
-               txbd = ((I2C_BD*)state->txbd) - 1;
-               j = 0;
                timeout = TOUT_LOOP * txbd->length;
 
                PRINTD(("[I2C] Transmitting...(txbd=0x%08lx)\n", (ulong)txbd));
@@ -523,9 +525,9 @@ int i2c_doio(i2c_state_t *state)
                }
        }
 
+       rxbd = ((I2C_BD*)state->rxbd) - 1;
+       j = 0;
        if ((state->rx_idx > 0) && (j < timeout)) {
-               rxbd = ((I2C_BD*)state->rxbd) - 1;
-               j = 0;
                timeout = TOUT_LOOP * rxbd->length;
                PRINTD(("[I2C] Receiving...(rxbd=0x%08lx)\n", (ulong)rxbd));
                udelay(START_DELAY_US); /* give it time to start */
@@ -637,7 +639,7 @@ i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
          * be one byte because the extra address bits are hidden in the
          * chip address.
          */
-       chip |= ((addr >> alen) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
+       chip |= ((addr >> (alen * 8)) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
 #endif
 
        i2c_newio(&state);
@@ -686,7 +688,7 @@ i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
          * be one byte because the extra address bits are hidden in the
          * chip address.
          */
-       chip |= ((addr >> alen) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
+       chip |= ((addr >> (alen * 8)) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
 #endif
 
        i2c_newio(&state);
index bd4009b785bec10d84b318c0f49dd8aa5de0dc89..5d816d4ccee0b4798d57c104ef9abe7725bf7cbe 100644 (file)
@@ -633,7 +633,7 @@ int i2c_read(uchar chip, uint addr, int alen, uchar *buffer, int len)
         * be one byte because the extra address bits are hidden in the
         * chip address.
         */
-        chip |= ((addr >> alen) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
+        chip |= ((addr >> (alen * 8)) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
 #endif
 
        i2c_newio(&state);
@@ -685,7 +685,7 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
         * be one byte because the extra address bits are hidden in the
         * chip address.
         */
-        chip |= ((addr >> alen) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
+        chip |= ((addr >> (alen * 8)) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
 #endif
 
        i2c_newio(&state);
index c63443940456f7b0e2a73d29469f02498286e646..e38f9bedef1039504f014cc47845bc6638ee5dfd 100644 (file)
@@ -239,6 +239,19 @@ static vidinfo_t panel_info = {
 #endif /* CONFIG_HLD1045 */
 /*----------------------------------------------------------------------*/
 
+#ifdef CONFIG_PRIMEVIEW_V16C6448AC
+/*
+ * Prime View V16C6448AC
+ */
+static vidinfo_t panel_info = {
+    640, 480, 130, 98, CFG_HIGH, CFG_HIGH, CFG_LOW, CFG_LOW, CFG_HIGH,
+    3, 0, 0, 1, 1, 144, 2, 0, 35
+               /* wbl, vpw, lcdac, wbf */
+};
+#endif /* CONFIG_PRIMEVIEW_V16C6448AC */
+
+/*----------------------------------------------------------------------*/
+
 #ifdef CONFIG_OPTREX_BW
 /*
  * Optrex   CBL50840-2 NF-FW 99 22 M5
index 82f442bc3b9e66f21f64d817101e92f0c58565e0..6f78fe3a3df7d30215c33a7c226cc9c87affdbff 100644 (file)
@@ -350,7 +350,7 @@ int i2c_read (uchar chip, uint addr, int alen, uchar * buffer, int len)
          * still be one byte because the extra address bits are
          * hidden in the chip address.
         */
-       chip |= ((addr >> alen) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
+       chip |= ((addr >> (alen * 8)) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
 #endif
 
        if (i2c_send (chip << 1, alen, &xaddr[4 - alen]) != 0)
@@ -382,7 +382,7 @@ int i2c_write (uchar chip, uint addr, int alen, uchar * buffer, int len)
          * still be one byte because the extra address bits are
          * hidden in the chip address.
         */
-       chip |= ((addr >> alen) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
+       chip |= ((addr >> (alen * 8)) & CFG_I2C_EEPROM_ADDR_OVERFLOW);
 #endif
 
        /* write with ack polling */
index f249390daf20262e2ceaffe5412b55d66df4d19b..e275211a3fff625772c053fe3729e55cd997e035 100644 (file)
@@ -432,12 +432,9 @@ long int spd_sdram(void)
 }
 
 int spd_read( int x ){
-       char addr[2];
        char data[2];
-       
-       addr[0]=0x50;
-       addr[1]=(char)x;
-       if (i2c_read(addr,2,data,1) == 0) return (int)data[0];
+
+       if (i2c_read(0x50,x,1,data,1) == 0) return (int)data[0];
        else return 0;
 }
        
index d2b9517be411461656676ebb2d495c6373ee1ee5..f5d4ea88e787e2806c3edf860548f6f861dd29e8 100644 (file)
 #include <i2c.h>
 #include <dtt.h>
 
-/*
- * Handle 4xx differences.
- */
-#if defined(CONFIG_4xx)
-#define I2C_WRITER(addr, addrlen, data, datalen, pgsize) \
-                  i2c_wr_page(addr, addrlen, data, datalen, pgsize)
-#else
-#define I2C_WRITER(addr, addrlen, data, datalen, pgsize) \
-                  i2c_write(addr, addrlen, data, datalen)
-#endif
 
 /*
  * Device code
@@ -50,7 +40,6 @@
 int dtt_read(int sensor, int reg)
 {
     int dlen;
-    uchar addr[2];
     uchar data[2];
 
     /*
@@ -63,8 +52,6 @@ int dtt_read(int sensor, int reg)
      * Calculate sensor address and register.
      */
     sensor &= 0x07;                            /* only allow sensor 0-7 */
-    addr[0] = DTT_I2C_DEV_CODE + sensor;       /* calculate address of lm75 */
-    addr[1] = reg;                             /* address of reg */
 
     /*
      * Prepare to handle 2 byte result.
@@ -79,7 +66,7 @@ int dtt_read(int sensor, int reg)
     /*
      * Now try to read the register.
      */
-    if (i2c_read(addr, 2, data, dlen) != 0)
+    if (i2c_read(DTT_I2C_DEV_CODE + sensor, reg, 1, data, dlen) != 0)
        return -1;
 
     /*
@@ -96,7 +83,6 @@ int dtt_read(int sensor, int reg)
 int dtt_write(int sensor, int reg, int val)
 {
     int dlen;
-    uchar addr;
     uchar data[3];
 
     /*
@@ -107,11 +93,8 @@ int dtt_write(int sensor, int reg, int val)
 
     /*
      * Calculate sensor address and register.
-     *
      */
     sensor &= 0x07;                            /* only allow sensor 0-7 */
-    addr = DTT_I2C_DEV_CODE + (sensor);                /* calculate address of lm75 */
-    data[0] = reg;                             /* address of reg */
 
     /*
      * Handle 2 byte values.
@@ -119,18 +102,18 @@ int dtt_write(int sensor, int reg, int val)
     if ((reg == DTT_READ_TEMP) ||
        (reg == DTT_TEMP_HYST) ||
        (reg == DTT_TEMP_SET)) {
-       dlen = 3;
-       data[1] = (char)((val >> 8) & 0xff);    /* MSB first */
-       data[2] = (char)(val & 0xff);
-    } else {
        dlen = 2;
+       data[0] = (char)((val >> 8) & 0xff);    /* MSB first */
        data[1] = (char)(val & 0xff);
+    } else {
+       dlen = 1;
+       data[0] = (char)(val & 0xff);
     }
 
     /*
      * Write value to register.
      */
-    if (I2C_WRITER(&addr, 1, data, dlen, 0) != 0)
+    if (i2c_write(DTT_I2C_DEV_CODE + (sensor), reg, 1, data, dlen) != 0)
        return 1;
 
     return 0;
index 15a172f9498a64a0069adb8f5cd82a3ac2218cc2..0688754e34c7b7911b0ecb46292d3d07e2b0f2da 100644 (file)
@@ -30,7 +30,6 @@
 /*
  * Configurable monitor commands
  */
-#define CFG_CMD_unused 0x00010000      /* was EEPROM, superceeded by I2C       */
 #define CFG_CMD_BDI            0x00000001      /* bdinfo                       */
 #define CFG_CMD_LOADS          0x00000002      /* loads                        */
 #define CFG_CMD_LOADB          0x00000004      /* loadb                        */
@@ -71,6 +70,7 @@
 #define CFG_CMD_DOC    0x0000000800000000      /* Disk-On-Chip Support         */
 #define CFG_CMD_JFFS2  0x0000001000000000      /* JFFS2 Support                */
 #define CFG_CMD_DTT    0x0000002000000000      /* Digital Therm and Thermostat */
+#define CFG_CMD_SDRAM  0x0000004000000000      /* SDRAM DIMM SPD info printout */
 
 #define CFG_CMD_ALL    0xFFFFFFFFFFFFFFFF      /* ALL commands                 */
 
@@ -90,6 +90,7 @@
                        CFG_CMD_ELF     | \
                        CFG_CMD_FDC     | \
                        CFG_CMD_I2C     | \
+                       CFG_CMD_SDRAM   | \
                        CFG_CMD_IDE     | \
                        CFG_CMD_IMMAP   | \
                        CFG_CMD_IRQ     | \
index 4ec4e6cbc4f1b10066cfb3dd25155c838f1097ad..3645086be85dd227efd1c5145d2228faa6ddcc0d 100644 (file)
        "chip address[.0, .1, .2] [# of objects]\n"                     \
        "    - loop, reading a set of addresses\n"                      \
 ),
+#if (CONFIG_COMMANDS & CFG_CMD_SDRAM)
 #define CMD_TBL_ISDRAM MK_CMD_TBL_ENTRY(                               \
        "isdram",       6,      2,      1,      do_sdram,               \
        "isdram  - print SDRAM configuration information\n",            \
        "chip\n    - print SDRAM configuration information\n"           \
        "      (valid chip values 50..57)\n"                            \
 ),
+#else
+#define CMD_TBL_ISDRAM
+#endif
 
 
 int do_i2c_md(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
index ec65ce9f4ef458963de49fe7bd03510db0408e83..c5aa79c15e076fac5fd01364d9efb387b07cfa0a 100644 (file)
                                CFG_CMD_ELF     | \
                                CFG_CMD_ASKENV  | \
                                CFG_CMD_ECHO    | \
-                               CFG_CMD_I2C     | \
                                CFG_CMD_REGINFO | \
                                CFG_CMD_MEMTEST | \
                                CFG_CMD_MII     | \
index 36f4698b4e664855cd1d03fee1ce56975fd038e6..ef3b57ff5ed65bc7af5ef4aa1e29778b3e016096 100644 (file)
@@ -21,7 +21,7 @@
 # MA 02111-1307 USA
 #
 
-BINS   = img2srec mkimage envcrc gen_eth_addr bmp_logo
+BINS   = img2srec$(SFX) mkimage$(SFX) envcrc$(SFX) gen_eth_addr$(SFX) bmp_logo$(SFX)
 
 OBJS   = environment.o img2srec.o mkimage.o crc32.o envcrc.o gen_eth_addr.o bmp_logo.o
 
index cae96dae31e47d41bd30a5b28388fa525aa49d1f..54fdcffbaff40b1a6592e7652e3c953c4a347065 100755 (executable)
@@ -4,8 +4,12 @@
 #if defined(__linux__)
 #include <stdint.h>
 #else
+#ifdef __CYGWIN__
+#include "elf.h"
+#else
 #include <inttypes.h>
 #endif
+#endif
 
 #ifdef __CYGWIN__
 typedef unsigned short ushort;