From: wdenk Date: Thu, 14 Mar 2002 10:29:08 +0000 (+0000) Subject: * Misc fixes to the I2C subsystem X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=925f50e97a3dce11fb62e5356fb900e20bf884b3;p=users%2Frw%2Fppcboot.git * Misc fixes to the I2C subsystem * Patch by Miguel Bello, 20 Feb 2002 Add support for Prime View V16C6448AC LCD --- diff --git a/CHANGELOG b/CHANGELOG index 6b4c3fb..05c3b4b 100644 --- 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 diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 5d9a391..d856760 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -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 */ diff --git a/common/soft_i2c.c b/common/soft_i2c.c index 6afddfb..c8d823d 100644 --- a/common/soft_i2c.c +++ b/common/soft_i2c.c @@ -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, diff --git a/config.mk b/config.mk index 229d4be..82e0362 100644 --- 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) \ diff --git a/cpu/mpc824x/drivers/i2c/i2c1.c b/cpu/mpc824x/drivers/i2c/i2c1.c index 4a97301..0c723ef 100644 --- a/cpu/mpc824x/drivers/i2c/i2c1.c +++ b/cpu/mpc824x/drivers/i2c/i2c1.c @@ -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 back. + */ + return i2c_read (chip, 0, 1, &tmp, 0); } -#endif int i2c_read (uchar chip, uint addr, int alen, uchar * buffer, int len) { diff --git a/cpu/mpc8260/i2c.c b/cpu/mpc8260/i2c.c index d3f8fe6..bab8d7c 100644 --- a/cpu/mpc8260/i2c.c +++ b/cpu/mpc8260/i2c.c @@ -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); diff --git a/cpu/mpc8xx/i2c.c b/cpu/mpc8xx/i2c.c index bd4009b..5d816d4 100644 --- a/cpu/mpc8xx/i2c.c +++ b/cpu/mpc8xx/i2c.c @@ -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); diff --git a/cpu/mpc8xx/lcd.c b/cpu/mpc8xx/lcd.c index c634439..e38f9be 100644 --- a/cpu/mpc8xx/lcd.c +++ b/cpu/mpc8xx/lcd.c @@ -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 diff --git a/cpu/ppc4xx/i2c.c b/cpu/ppc4xx/i2c.c index 82f442b..6f78fe3 100644 --- a/cpu/ppc4xx/i2c.c +++ b/cpu/ppc4xx/i2c.c @@ -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 */ diff --git a/cpu/ppc4xx/spd_sdram.c b/cpu/ppc4xx/spd_sdram.c index f249390..e275211 100644 --- a/cpu/ppc4xx/spd_sdram.c +++ b/cpu/ppc4xx/spd_sdram.c @@ -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; } diff --git a/dtt/lm75.c b/dtt/lm75.c index d2b9517..f5d4ea8 100644 --- a/dtt/lm75.c +++ b/dtt/lm75.c @@ -31,16 +31,6 @@ #include #include -/* - * 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; diff --git a/include/cmd_confdefs.h b/include/cmd_confdefs.h index 15a172f..0688754 100644 --- a/include/cmd_confdefs.h +++ b/include/cmd_confdefs.h @@ -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 | \ diff --git a/include/cmd_i2c.h b/include/cmd_i2c.h index 4ec4e6c..3645086 100644 --- a/include/cmd_i2c.h +++ b/include/cmd_i2c.h @@ -68,12 +68,16 @@ "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[]); diff --git a/include/config_ppmc8260.h b/include/config_ppmc8260.h index ec65ce9..c5aa79c 100644 --- a/include/config_ppmc8260.h +++ b/include/config_ppmc8260.h @@ -280,7 +280,6 @@ CFG_CMD_ELF | \ CFG_CMD_ASKENV | \ CFG_CMD_ECHO | \ - CFG_CMD_I2C | \ CFG_CMD_REGINFO | \ CFG_CMD_MEMTEST | \ CFG_CMD_MII | \ diff --git a/tools/Makefile b/tools/Makefile index 36f4698..ef3b57f 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -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 diff --git a/tools/bmp_logo.c b/tools/bmp_logo.c index cae96da..54fdcff 100755 --- a/tools/bmp_logo.c +++ b/tools/bmp_logo.c @@ -4,8 +4,12 @@ #if defined(__linux__) #include #else +#ifdef __CYGWIN__ +#include "elf.h" +#else #include #endif +#endif #ifdef __CYGWIN__ typedef unsigned short ushort;