From: wdenk Date: Sun, 14 Apr 2002 11:01:32 +0000 (+0000) Subject: * Patch by Dave Ellis, 13 Apr 2002: X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=266715126ae24f13e68ccb28088256d86a39dba9;p=users%2Frw%2Fppcboot.git * Patch by Dave Ellis, 13 Apr 2002: - fix debug print in common/soft_i2c.c - fix missing initialization of idata on 8xx - fix eeprom command for EEPROMS with 2 byte addresses - fix SXNI855T for improved flash_real_protect() parameters * Added M41T11 RTC driver Patch by Andrew May, 2 Apr 2002 * Changed MAC handling for Redundand Ethernet Interfaces; see README * Add DiskOnChip Support for PM826 --- diff --git a/CHANGELOG b/CHANGELOG index dbef022..7503317 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -14,6 +14,18 @@ Modifications for 1.1.6: ====================================================================== +* Patch by Dave Ellis, 13 Apr 2002: + - fix debug print in common/soft_i2c.c + - fix missing initialization of idata on 8xx + - fix eeprom command for EEPROMS with 2 byte addresses + +* Added M41T11 RTC driver + Patch by Andrew May, 2 Apr 2002 + +* Changed MAC handling for Redundand Ethernet Interfaces; see README + +* Add DiskOnChip Support for PM826 + * Fix I2C driver for PM826, CPU86, and TQM8260 * Add configuration options for PM826 and CPU86 boards to boot either diff --git a/MAINTAINERS b/MAINTAINERS index 64cd3e2..633e304 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -118,6 +118,10 @@ Oliver Brown sbc8260 MPC8260 gw8260 MPC8260 +Dave Ellis + + SXNI855T MPC8xx + ------------------------------------------------------------------------- Unknown / orphaned boards: @@ -133,7 +137,6 @@ Unknown / orphaned boards: NX823 MPC8xx RPXClassic MPC8xx RPXlite MPC8xx - SXNI855T MPC8xx CRAYL1 PPC4xx ERIC PPC4xx diff --git a/README b/README index 98513db..320bd03 100644 --- a/README +++ b/README @@ -1402,6 +1402,40 @@ Please note that changes to some configuration parameters may take only effect after the next boot (yes, that's just like Windoze :-). +Note for Redundand Ethernet Interfaces: +======================================= + +Some boards come with redundand ethernet interfaces; PPCBoot supports +such configurations and is capable of automatic selection of a +"working" interface when needed. MAC assignemnt works as follows: + +Network interfaces are numbered eth0, eth1, eth2, ... Corresponding +MAC addresses can be stored in the environment as "ethaddr" (=>eth0), +"eth1addr" (=>eth1), "eth2addr", ... + +If the network interface stores some valid MAC address (for instance +in SROM), this is used as default address if there is NO correspon- +ding setting in the environment; if the corresponding environment +variable is set, this overrides the settings in the card; that means: + +o If the SROM has a valid MAC address, and there is no address in the + environment, the SROM's address is used. + +o If there is no valid address in the SROM, and a definition in the + environment exists, then the value from the environment variable is + used. + +o If both the SROM and the environment contain a MAC address, and + both addresses are the same, this MAC address is used. + +o If both the SROM and the environment contain a MAC address, and the + addresses differ, the value from the environment is used and a + warning is printed. + +o If neither SROM nor the environment contain a MAC address, an error + is raised. + + Image Formats: ============== diff --git a/board/cpu86/flash.c b/board/cpu86/flash.c index 5786808..cc6b09e 100644 --- a/board/cpu86/flash.c +++ b/board/cpu86/flash.c @@ -187,20 +187,26 @@ unsigned long flash_init (void) /* Static FLASH Bank configuration here (only one bank) */ size_b0 = flash_int_get_size ((ulong *) CFG_FLASH_BASE, &flash_info[0]); - if (flash_info[0].flash_id == FLASH_UNKNOWN || size_b0 == 0) { - printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n", - size_b0, size_b0 >> 20); - } - size_b1 = flash_amd_get_size ((uchar *) CFG_BOOTROM_BASE, &flash_info[1]); - printf("(Bank#1 - %ld MB", size_b0 >> 20); + if (size_b0 > 0 || size_b1 > 0) { - if (size_b1 > 0) - printf(", Bank#2 - %ld kB", size_b1 >> 10); + printf("("); - printf(")"); + if (size_b0 > 0) + printf("Bank#1 - %ld MB", size_b0 >> 20); + if (size_b1 > 0) + printf("%sBank#2 - %ld kB", + (size_b0 > 0) ? ", " : "", + size_b1 >> 10); + + printf(") "); + } + else { + printf ("## No FLASH found.\n"); + return 0; + } /* protect monitor and environment sectors */ diff --git a/board/pm826/flash.c b/board/pm826/flash.c index bc40d25..35f2d77 100644 --- a/board/pm826/flash.c +++ b/board/pm826/flash.c @@ -125,24 +125,18 @@ unsigned long flash_init (void) /* protect monitor and environment sectors */ -#ifndef CONFIG_BOOT_BOOTROM - /* If PPCBoot is booted from ROM the CFG_MONITOR_BASE > CFG_FLASH0_BASE - * but we shouldn't protect it. - */ - #ifndef CONFIG_BOOT_ROM /* If PPCBoot is booted from ROM the CFG_MONITOR_BASE > CFG_FLASH0_BASE * but we shouldn't protect it. */ -#if CFG_MONITOR_BASE >= CFG_FLASH0_BASE +# if CFG_MONITOR_BASE >= CFG_FLASH0_BASE flash_protect (FLAG_PROTECT_SET, CFG_MONITOR_BASE, CFG_MONITOR_BASE + CFG_MONITOR_LEN - 1, &flash_info[0] ); -#endif -#endif -#endif +# endif +#endif /* CONFIG_BOOT_ROM */ #if (CFG_ENV_IS_IN_FLASH == 1) && defined(CFG_ENV_ADDR) # ifndef CFG_ENV_SIZE @@ -197,7 +191,7 @@ void flash_print_info (flash_info_t * info) printf ("\n "); printf (" %08lX%s", info->start[i], - info->protect[i] ? " (RO)" : " " + info->protect[i] ? " (RO)" : " " ); } printf ("\n"); diff --git a/board/pm826/pm826.c b/board/pm826/pm826.c index 150f676..2ff4ec3 100644 --- a/board/pm826/pm826.c +++ b/board/pm826/pm826.c @@ -333,3 +333,11 @@ long int initdram(int board_type) #endif return (psize); } + +#if (CONFIG_COMMANDS & CFG_CMD_DOC) +extern void doc_probe (ulong physadr); +void doc_init (void) +{ + doc_probe (CFG_DOC_BASE); +} +#endif diff --git a/board/sixnet/flash.c b/board/sixnet/flash.c index f50544a..3ae6983 100644 --- a/board/sixnet/flash.c +++ b/board/sixnet/flash.c @@ -683,27 +683,14 @@ static int write_word_intel (flash_info_t *info, FPWV *dest, FPW data) #ifdef CFG_FLASH_PROTECTION /*----------------------------------------------------------------------- - * FIXME - pass in sector index instead of sector address, would simplify - * this code a bit. w7o would need changing also. */ int flash_real_protect (flash_info_t * info, long sector, int prot) { - int rcode; - int sectindex = 0; - FPWV *addr = (FPWV *) sector; + int rcode = 0; /* assume success */ + FPWV *addr; /* address of sector */ FPW value; - int i; - - rcode = 1; /* assume fails */ - for (i = 0; rcode != 0 && i < info->sector_count; i++) { - if (info->start[i] == sector) { - sectindex = i; - rcode = 0; /* success so far */ - } - } - if (rcode) - return (rcode); + addr = (FPWV *) (info->start[sector]); switch (info->flash_id & FLASH_TYPEMASK) { case FLASH_28F800C3B: @@ -732,15 +719,15 @@ int flash_real_protect (flash_info_t * info, long sector, int prot) */ value = addr[2] & (FPW) 0x00010001; if (value == 0) - info->protect[sectindex] = 0; + info->protect[sector] = 0; else if (value == (FPW) 0x00010001) - info->protect[sectindex] = 1; + info->protect[sector] = 1; else { /* error, mixed protected and unprotected */ rcode = 1; - info->protect[sectindex] = 1; + info->protect[sector] = 1; } - if (info->protect[sectindex] != prot) + if (info->protect[sector] != prot) rcode = 1; /* failed to protect/unprotect as requested */ /* reload all protection bits from hardware for now */ @@ -750,7 +737,7 @@ int flash_real_protect (flash_info_t * info, long sector, int prot) case FLASH_AM640U: default: /* no hardware protect that we support */ - info->protect[sectindex] = prot; + info->protect[sector] = prot; break; } diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c index 0e5e12e..11a868d 100644 --- a/common/cmd_eeprom.c +++ b/common/cmd_eeprom.c @@ -100,15 +100,19 @@ int do_eeprom (cmd_tbl_t * cmdtp, bd_t * bd, int flag, int argc, /*----------------------------------------------------------------------- * - * for CONFIG_I2C_X defined (16-bit EEPROM address) offset is + * for CFG_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is * 0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM. * - * for CONFIG_I2C_X not defined (8-bit EEPROM page address) offset is + * for CFG_I2C_EEPROM_ADDR_LEN == 1 (8-bit EEPROM page address) offset is * 0x00000nxx for EEPROM address selectors and page number at n. */ #if (CONFIG_COMMANDS & CFG_CMD_EEPROM) || defined(CFG_ENV_IS_IN_EEPROM) +#if !defined(CFG_I2C_EEPROM_ADDR_LEN) || CFG_I2C_EEPROM_ADDR_LEN < 1 || CFG_I2C_EEPROM_ADDR_LEN > 2 +#error CFG_I2C_EEPROM_ADDR_LEN must be 1 or 2 +#endif + int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt) { unsigned end = offset + cnt; @@ -121,7 +125,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt */ while (offset < end) { unsigned alen, len, maxlen; -#if !defined(CONFIG_I2C_X) && !defined(CONFIG_SPI_X) +#if CFG_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X) uchar addr[2]; blk_off = offset & 0xFF; /* block offset */ @@ -138,7 +142,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt addr[1] = offset >> 8; /* upper address octet */ addr[2] = blk_off; /* lower address octet */ alen = 3; -#endif /* CONFIG_I2C_X, CONFIG_SPI_X */ +#endif /* CFG_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */ addr[0] |= dev_addr; /* insert device address */ @@ -162,10 +166,10 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt /*----------------------------------------------------------------------- * - * for CONFIG_I2C_X defined (16-bit EEPROM address) offset is + * for CFG_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is * 0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM. * - * for CONFIG_I2C_X not defined (8-bit EEPROM page address) offset is + * for CFG_I2C_EEPROM_ADDR_LEN == 1 (8-bit EEPROM page address) offset is * 0x00000nxx for EEPROM address selectors and page number at n. */ @@ -190,7 +194,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn while (offset < end) { unsigned alen, len, maxlen; -#if !defined(CONFIG_I2C_X) && !defined(CONFIG_SPI_X) +#if CFG_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X) uchar addr[2]; blk_off = offset & 0xFF; /* block offset */ @@ -207,7 +211,7 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn addr[1] = offset >> 8; /* upper address octet */ addr[2] = blk_off; /* lower address octet */ alen = 3; -#endif /* CONFIG_I2C_X, CONFIG_SPI_X */ +#endif /* CFG_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */ addr[0] |= dev_addr; /* insert device address */ diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index b99fcb9..38841d7 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -932,13 +932,9 @@ int saveenv(void) (CFG_CMD_ENV|CFG_CMD_FLASH)) int do_saveenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { - int rcode = 0; - puts (NVRAM_SAVESTR); - if (!saveenv()) - rcode = 1; - return rcode; + return (saveenv() ? 1 : 0); } #endif diff --git a/common/soft_i2c.c b/common/soft_i2c.c index 240c54c..ef13861 100644 --- a/common/soft_i2c.c +++ b/common/soft_i2c.c @@ -48,7 +48,11 @@ #ifdef DEBUG_I2C -#define PRINTD(fmt,args...) printf (fmt ,##args) +#define PRINTD(fmt,args...) do { \ + init_data_t *idata = (init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET); \ + if (idata->have_console) \ + printf (fmt ,##args); \ + } while (0) #else #define PRINTD(fmt,args...) #endif diff --git a/cpu/mpc8xx/cpu_init.c b/cpu/mpc8xx/cpu_init.c index 9caee67..52c7f86 100644 --- a/cpu/mpc8xx/cpu_init.c +++ b/cpu/mpc8xx/cpu_init.c @@ -211,6 +211,9 @@ cpu_init_f (volatile immap_t *immr) __asm__ ("eieio"); } while (immr->im_cpm.cp_cpcr & CPM_CR_FLG); + /* clear memory for idata */ + memset((init_data_t *)(CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET), 0, CFG_INIT_DATA_SIZE); + #ifdef CONFIG_MBX /* * on the MBX, things are a little bit different: diff --git a/cpu/mpc8xx/lcd.c b/cpu/mpc8xx/lcd.c index e38f9be..4ffa90c 100644 --- a/cpu/mpc8xx/lcd.c +++ b/cpu/mpc8xx/lcd.c @@ -151,7 +151,7 @@ typedef struct vidinfo { u_char vl_dp; /* Data polarity */ u_char vl_bpix; /* Bits per pixel, 0 = 1, 1 = 2, 2 = 4, 3 = 8 */ u_char vl_lbw; /* LCD Bus width, 0 = 4, 1 = 8 */ - u_char vl_splt; /* Split display, 0 = dual, 1 = single */ + u_char vl_splt; /* Split display, 0 = single-scan, 1 = dual-scan */ u_char vl_clor; /* Color, 0 = mono, 1 = color */ u_char vl_tft; /* 0 = passive, 1 = TFT */ diff --git a/drivers/dc2114x.c b/drivers/dc2114x.c index 8c03ec5..14c94e2 100644 --- a/drivers/dc2114x.c +++ b/drivers/dc2114x.c @@ -445,7 +445,7 @@ static void send_setup_frame(struct eth_device* dev, bd_t *bis) memset(pa, 0xff, SETUP_FRAME_LEN); for (i = 0; i < ETH_ALEN; i++) { - *(pa + (i & 1)) = bis->bi_enetaddr[i]; + *(pa + (i & 1)) = dev->enetaddr[i]; if (i & 0x01) { pa += 4; } @@ -659,30 +659,13 @@ static void read_hw_addr(struct eth_device *dev, bd_t *bis) } if ((j == 0) || (j == 0x2fffd)) { + memset (dev->enetaddr, 0, ETH_ALEN); +#ifdef DEBUG printf("Warning: can't read HW address from SROM.\n"); +#endif goto Done; } -#ifdef DEBUG - for (i = 0; i < ETH_ALEN; i++) { - if (dev->enetaddr[i] != bis->bi_enetaddr[i]) { - printf("Warning: HW addresses don't match:\n"); - printf("Address in SROM is " - "%02X:%02X:%02X:%02X:%02X:%02X\n", - dev->enetaddr[0], dev->enetaddr[1], - dev->enetaddr[2], dev->enetaddr[3], - dev->enetaddr[4], dev->enetaddr[5]); - printf("Address used by ppcboot is " - "%02X:%02X:%02X:%02X:%02X:%02X\n", - bis->bi_enetaddr[0], bis->bi_enetaddr[1], - bis->bi_enetaddr[2], bis->bi_enetaddr[3], - bis->bi_enetaddr[4], bis->bi_enetaddr[5]); - - goto Done; - } - } -#endif - return; Done: diff --git a/drivers/eepro100.c b/drivers/eepro100.c index 417da8d..e39be7e 100644 --- a/drivers/eepro100.c +++ b/drivers/eepro100.c @@ -682,34 +682,14 @@ static void read_hw_addr(struct eth_device* dev, bd_t *bis) } } + if (sum != 0xBABA) { + memset (dev->enetaddr, 0, ETH_ALEN); #ifdef DEBUG - if (sum != 0xBABA) printf("%s: Invalid EEPROM checksum %#4.4x, " "check settings before activating this device!\n", dev->name, sum); - - for (i=0;ienetaddr[i] != bis->bi_enetaddr[i]) - { - printf("Warning: HW address don't match:\n"); - printf("Address in SROM is " - "%02X:%02X:%02X:%02X:%02X:%02X\n", - dev->enetaddr[0], dev->enetaddr[1], - dev->enetaddr[2], dev->enetaddr[3], - dev->enetaddr[4], dev->enetaddr[5]); - printf("Address used by ppcboot is " - "%02X:%02X:%02X:%02X:%02X:%02X\n", - bis->bi_enetaddr[0], bis->bi_enetaddr[1], - bis->bi_enetaddr[2], bis->bi_enetaddr[3], - bis->bi_enetaddr[4], bis->bi_enetaddr[5]); - goto Done; - } - } - -Done: #endif - return; + } } #endif diff --git a/include/config_CPU86.h b/include/config_CPU86.h index 22f5cf1..7e07116 100644 --- a/include/config_CPU86.h +++ b/include/config_CPU86.h @@ -141,7 +141,7 @@ else iop->pdat &= ~0x00010000 #define I2C_SCL(bit) if(bit) iop->pdat |= 0x00020000; \ else iop->pdat &= ~0x00020000 -#define I2C_DELAY udelay(10) /* 1/4 I2C clock duration */ +#define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */ #define CONFIG_RTC_PCF8563 #define CFG_I2C_RTC_ADDR 0x51 diff --git a/include/config_DASA_SIM.h b/include/config_DASA_SIM.h index 227fccf..a2180b2 100644 --- a/include/config_DASA_SIM.h +++ b/include/config_DASA_SIM.h @@ -73,6 +73,7 @@ #if 0 /* Does not appear to be used?! If it is used, needs to be fixed */ #define CONFIG_SOFT_I2C /* Software I2C support enabled */ #endif +#define CFG_I2C_EEPROM_ADDR_LEN 1 /* Bytes of address */ /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */ #include diff --git a/include/config_ICU862.h b/include/config_ICU862.h index e6bb118..34ccb7a 100644 --- a/include/config_ICU862.h +++ b/include/config_ICU862.h @@ -95,6 +95,7 @@ # define CFG_I2C_SPEED 50000 # define CFG_I2C_SLAVE 0xFE # define CFG_I2C_EEPROM_ADDR 0x50 +# define CFG_I2C_EEPROM_ADDR_LEN 1 /* Bytes of address */ /* * Software (bit-bang) I2C driver configuration */ diff --git a/include/config_PM826.h b/include/config_PM826.h index 9508dc9..14b4fe9 100644 --- a/include/config_PM826.h +++ b/include/config_PM826.h @@ -40,11 +40,7 @@ #define CONFIG_CLOCKS_IN_MHZ 1 /* clocks passsed to Linux in MHz */ -#if 0 -#define CONFIG_BOOTDELAY -1 /* autoboot disabled */ -#else #define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */ -#endif #define CONFIG_PREBOOT "echo;echo Type \"run flash_nfs\" to mount root filesystem over NFS;echo" @@ -71,7 +67,7 @@ else iop->pdat &= ~0x00010000 #define I2C_SCL(bit) if(bit) iop->pdat |= 0x00020000; \ else iop->pdat &= ~0x00020000 -#define I2C_DELAY udelay(10) /* 1/4 I2C clock duration */ +#define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */ #define CONFIG_RTC_PCF8563 @@ -140,11 +136,21 @@ #define CONFIG_BOOTP_MASK (CONFIG_BOOTP_DEFAULT|CONFIG_BOOTP_BOOTFILESIZE) -#define CONFIG_COMMANDS (CONFIG_CMD_DFL | CFG_CMD_EEPROM | CFG_CMD_DATE) +#define CONFIG_COMMANDS (CONFIG_CMD_DFL | CFG_CMD_EEPROM | CFG_CMD_DATE | CFG_CMD_DOC) /* this must be included AFTER the definition of CONFIG_COMMANDS (if any) */ #include +/* + * Disk-On-Chip configuration + */ + +#define CFG_DOC_SHORT_TIMEOUT +#define CFG_MAX_DOC_DEVICE 1 /* Max number of DOC devices */ + +#define CFG_DOC_SUPPORT_2000 +#define CFG_DOC_SUPPORT_MILLENNIUM + /* * Miscellaneous configurable options */ @@ -185,6 +191,8 @@ #define CFG_BOOTROM_SIZE 0x00080000 #define CFG_FLASH0_BASE 0x40000000 #define CFG_FLASH0_SIZE 0x02000000 +#define CFG_DOC_BASE 0x60000000 +#define CFG_DOC_SIZE 0x00100000 /* Flash bank size (for preliminary settings) @@ -399,7 +407,7 @@ #if defined(CONFIG_BOOT_ROM) /* - * Bank 0 - BOOTROM + * Bank 0 - Boot ROM (8 bit wide) */ #define CFG_BR0_PRELIM ((CFG_BOOTROM_BASE & BRx_BA_MSK)|\ BRx_PS_8 |\ @@ -413,6 +421,9 @@ ORxG_EHTR |\ ORxG_TRLX) +/* + * Bank 1 - Flash (64 bit wide) + */ #define CFG_BR1_PRELIM ((CFG_FLASH_BASE & BRx_BA_MSK) |\ BRx_PS_64 |\ BRx_MS_GPCM_P |\ @@ -428,7 +439,7 @@ #else /* ! CONFIG_BOOT_ROM */ /* - * Bank 0 - FLASH + * Bank 0 - Flash (64 bit wide) */ #define CFG_BR0_PRELIM ((CFG_FLASH_BASE & BRx_BA_MSK) |\ BRx_PS_64 |\ @@ -441,6 +452,22 @@ ORxG_SCY_3_CLK |\ ORxG_EHTR |\ ORxG_TRLX) + +/* + * Bank 1 - Disk-On-Chip + */ +#define CFG_BR1_PRELIM ((CFG_DOC_BASE & BRx_BA_MSK) |\ + BRx_PS_8 |\ + BRx_MS_GPCM_P |\ + BRx_V) + +#define CFG_OR1_PRELIM (P2SZ_TO_AM(CFG_DOC_SIZE) |\ + ORxG_CSNT |\ + ORxG_ACS_DIV1 |\ + ORxG_SCY_3_CLK |\ + ORxG_EHTR |\ + ORxG_TRLX) + #endif /* CONFIG_BOOT_ROM */ /* Bank 2 - SDRAM diff --git a/include/config_Sandpoint8240.h b/include/config_Sandpoint8240.h index 2b08912..d22df0c 100644 --- a/include/config_Sandpoint8240.h +++ b/include/config_Sandpoint8240.h @@ -174,6 +174,7 @@ #define CFG_I2C_EEPROM_ADDR 0x57 /* EEPROM IS24C02 */ +#define CFG_I2C_EEPROM_ADDR_LEN 1 /* Bytes of address */ #define CFG_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 } #define CFG_FLASH_BANKS { FLASH_BASE0_PRELIM , FLASH_BASE1_PRELIM } diff --git a/include/config_Sandpoint8245.h b/include/config_Sandpoint8245.h index df20767..23fca50 100644 --- a/include/config_Sandpoint8245.h +++ b/include/config_Sandpoint8245.h @@ -172,6 +172,7 @@ #endif /* CONFIG_SOFT_I2C */ #define CFG_I2C_EEPROM_ADDR 0x57 /* EEPROM IS24C02 */ +#define CFG_I2C_EEPROM_ADDR_LEN 1 /* Bytes of address */ #define CFG_EEPROM_PAGE_WRITE_BITS 3 #define CFG_EEPROM_PAGE_WRITE_DELAY_MS 10 /* and takes up to 10 msec */ diff --git a/include/config_TQM8260.h b/include/config_TQM8260.h index 07e81cc..e9db27c 100644 --- a/include/config_TQM8260.h +++ b/include/config_TQM8260.h @@ -96,7 +96,7 @@ else iop->pdat &= ~0x00020000 #define I2C_SCL(bit) if(bit) iop->pdat |= 0x00010000; \ else iop->pdat &= ~0x00010000 -#define I2C_DELAY udelay(20) /* 1/4 I2C clock duration */ +#define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */ #else @@ -108,7 +108,7 @@ else iop->pdat &= ~0x00010000 #define I2C_SCL(bit) if(bit) iop->pdat |= 0x00020000; \ else iop->pdat &= ~0x00020000 -#define I2C_DELAY udelay(20) /* 1/4 I2C clock duration */ +#define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */ #endif #define CFG_I2C_EEPROM_ADDR 0x50 diff --git a/include/config_W7OLMG.h b/include/config_W7OLMG.h index 252c6de..9be8cdb 100644 --- a/include/config_W7OLMG.h +++ b/include/config_W7OLMG.h @@ -260,6 +260,7 @@ #define CFG_I2C_SLAVE 0x7F #define CFG_I2C_EEPROM_ADDR 0x50 /* EEPROM ATMEL 24C04N */ +#define CFG_I2C_EEPROM_ADDR_LEN 1 /* Bytes of address */ #define CFG_EEPROM_PAGE_WRITE_ENABLE #define CFG_EEPROM_PAGE_WRITE_BITS 3 #define CFG_I2C_MULTI_EEPROMS diff --git a/include/net.h b/include/net.h index 717e9e6..cd92a27 100644 --- a/include/net.h +++ b/include/net.h @@ -76,7 +76,7 @@ struct eth_device { extern int eth_initialize(bd_t *bis); /* Initialize network subsystem */ extern int eth_register(struct eth_device* dev);/* Register network device */ extern void eth_try_another(void); /* Change the device */ -extern char *eth_get_enetaddr(void); /* get the current device MAC */ +extern char *eth_get_enetaddr(void); /* get the current device MAC */ #endif extern int eth_init(bd_t *bis); /* Initialize the device */ diff --git a/net/eth.c b/net/eth.c index 0689622..506d1d8 100644 --- a/net/eth.c +++ b/net/eth.c @@ -41,7 +41,9 @@ int eth_register(struct eth_device* dev) int eth_initialize(bd_t *bis) { - int eth_number = 0; + unsigned char enetvar[32], env_enetaddr[6]; + int i, eth_number = 0; + char *tmp, *end; eth_devices = NULL; eth_current = NULL; @@ -63,9 +65,43 @@ int eth_initialize(bd_t *bis) struct eth_device *dev = eth_devices; do { - if (eth_number++) + if (eth_number) printf(", "); + printf("%s", dev->name); + + sprintf(enetvar, eth_number ? "eth%daddr" : "ethaddr", eth_number); + tmp = getenv (enetvar); + + for (i=0; i<6; i++) + { + env_enetaddr[i] = tmp ? simple_strtoul(tmp, &end, 16) : 0; + if (tmp) + tmp = (*end) ? end+1 : end; + } + + if (memcmp(env_enetaddr, "\0\0\0\0\0\0", 6)) + { + if (memcmp(dev->enetaddr, "\0\0\0\0\0\0", 6) && + memcmp(dev->enetaddr, env_enetaddr, 6)) + { + printf("\nWarning: %s HW address don't match:\n", dev->name); + printf("Address in SROM is " + "%02X:%02X:%02X:%02X:%02X:%02X\n", + dev->enetaddr[0], dev->enetaddr[1], + dev->enetaddr[2], dev->enetaddr[3], + dev->enetaddr[4], dev->enetaddr[5]); + printf("Address in environment is " + "%02X:%02X:%02X:%02X:%02X:%02X\n", + env_enetaddr[0], env_enetaddr[1], + env_enetaddr[2], env_enetaddr[3], + env_enetaddr[4], env_enetaddr[5]); + } + + memcpy(dev->enetaddr, env_enetaddr, 6); + } + + eth_number++; dev = dev->next; } while(dev != eth_devices); diff --git a/rtc/Makefile b/rtc/Makefile index 690fe21..4119adb 100644 --- a/rtc/Makefile +++ b/rtc/Makefile @@ -28,7 +28,8 @@ include $(TOPDIR)/config.mk LIB = librtc.a OBJS = date.o ds1302.o ds174x.o ds1306.o ds1556.o \ - m48t35ax.o mc146818.o mk48t59.o mpc8xx.o pcf8563.o + m41t11.o m48t35ax.o mc146818.o mk48t59.o \ + mpc8xx.o pcf8563.o all: $(LIB) diff --git a/rtc/m41t11.c b/rtc/m41t11.c new file mode 100644 index 0000000..cef9b41 --- /dev/null +++ b/rtc/m41t11.c @@ -0,0 +1,202 @@ +/* + * (C) Copyright 2002 + * Andrew May, Viasat Inc, amay@viasat.com + * + * 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 + */ + +/* + * M41T11 Serial Access Timekeeper(R) SRAM + * can you believe a trademark on that? + */ + +#include +#include +#include +#include + +/* + I Don't have an example config file but this + is what should be done. + +#define CONFIG_RTC_M41T11 1 +#define CFG_I2C_RTC_ADDR 0x68 +#if 0 +#define CFG_M41T11_EXT_CENTURY_DATA +#else +#define CFG_M41T11_BASE_YEAR 2000 +#endif +*/ + +#if defined(CONFIG_RTC_M41T11) && defined(CFG_I2C_RTC_ADDR) && (CONFIG_COMMANDS & CFG_CMD_DATE) + +#define DEBUG 1 + +static unsigned bcd2bin (uchar n) +{ + return ((((n >> 4) & 0x0F) * 10) + (n & 0x0F)); +} + +static unsigned char bin2bcd (unsigned int n) +{ + return (((n / 10) << 4) | (n % 10)); +} + + +/* ------------------------------------------------------------------------- */ +/* + these are simple defines for the chip local to here so they aren't too + verbose + DAY/DATE aren't nice but that is how they are on the data sheet +*/ +#define RTC_SEC_ADDR 0x0 +#define RTC_MIN_ADDR 0x1 +#define RTC_HOUR_ADDR 0x2 +#define RTC_DAY_ADDR 0x3 +#define RTC_DATE_ADDR 0x4 +#define RTC_MONTH_ADDR 0x5 +#define RTC_YEARS_ADDR 0x6 + +#define RTC_REG_CNT 7 + +#define RTC_CONTROL_ADDR 0x7 + + +#ifndef CFG_M41T11_EXT_CENTURY_DATA + +#define REG_CNT (RTC_REG_CNT+1) + +/* + you only get 00-99 for the year we will asume you + want from the year 2000 if you don't set the config +*/ +#ifndef CFG_M41T11_BASE_YEAR +#define CFG_M41T11_BASE_YEAR 2000 +#endif + +#else +/* we will store extra year info in byte 9*/ +#define M41T11_YEAR_DATA 0x8 +#define M41T11_YEAR_SIZE 1 +#define REG_CNT (RTC_REG_CNT+1+M41T11_YEAR_SIZE) +#endif + +#define M41T11_STORAGE_SZ (64-REG_CNT) + +void rtc_get (struct rtc_time *tmp) +{ + uchar data[RTC_REG_CNT]; + + i2c_read(CFG_I2C_RTC_ADDR, RTC_SEC_ADDR, 1, data, RTC_REG_CNT); + + if( data[RTC_SEC_ADDR] & 0x80 ){ + printf( "m41t11 RTC Clock stopped!!!\n" ); + } + tmp->tm_sec = bcd2bin (data[RTC_SEC_ADDR] & 0x7F); + tmp->tm_min = bcd2bin (data[RTC_MIN_ADDR] & 0x7F); + tmp->tm_hour = bcd2bin (data[RTC_HOUR_ADDR] & 0x3F); + tmp->tm_mday = bcd2bin (data[RTC_DATE_ADDR] & 0x3F); + tmp->tm_mon = bcd2bin (data[RTC_MONTH_ADDR]& 0x1F); +#ifndef CFG_M41T11_EXT_CENTURY_DATA + tmp->tm_year = CFG_M41T11_BASE_YEAR + + bcd2bin(data[RTC_YEARS_ADDR]) + + ((data[RTC_HOUR_ADDR]&0x40) ? 100 : 0); +#else + { + unsigned char cent; + i2c_read(CFG_I2C_RTC_ADDR, M41T11_YEAR_DATA, 1, ¢, M41T11_YEAR_SIZE); + if( !(data[RTC_HOUR_ADDR] & 0x80) ){ + printf( "m41t11 RTC: cann't keep track of years without CEB set\n" ); + } + if( (cent & 0x1) != ((data[RTC_HOUR_ADDR]&0x40)>>7) ){ + /*century flip store off new year*/ + cent += 1; + i2c_write(CFG_I2C_RTC_ADDR, M41T11_YEAR_DATA, 1, ¢, M41T11_YEAR_SIZE); + } + tmp->tm_year =((int)cent*100)+bcd2bin(data[RTC_YEARS_ADDR]); + } +#endif + tmp->tm_wday = bcd2bin (data[RTC_DAY_ADDR] & 0x07); + tmp->tm_yday = 0; + tmp->tm_isdst= 0; + + debug ( "Get DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", + tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, + tmp->tm_hour, tmp->tm_min, tmp->tm_sec); +} + +void rtc_set (struct rtc_time *tmp) +{ + uchar data[RTC_REG_CNT]; + + debug ( "Set DATE: %4d-%02d-%02d (wday=%d) TIME: %2d:%02d:%02d\n", + tmp->tm_year, tmp->tm_mon, tmp->tm_mday, tmp->tm_wday, + tmp->tm_hour, tmp->tm_min, tmp->tm_sec); + + data[RTC_SEC_ADDR] = bin2bcd(tmp->tm_sec) & 0x7F;/*just in case*/ + data[RTC_MIN_ADDR] = bin2bcd(tmp->tm_min); + data[RTC_HOUR_ADDR] = bin2bcd(tmp->tm_hour) & 0x3F;/*handle cent stuff later*/ + data[RTC_DATE_ADDR] = bin2bcd(tmp->tm_mday) & 0x3F; + data[RTC_MONTH_ADDR] = bin2bcd(tmp->tm_mon); + data[RTC_DAY_ADDR] = bin2bcd(tmp->tm_wday) & 0x07; + + data[RTC_HOUR_ADDR] |= 0x80;/*we will always use CEB*/ + + data[RTC_YEARS_ADDR] = bin2bcd(tmp->tm_year%100);/*same thing either way*/ +#ifndef CFG_M41T11_EXT_CENTURY_DATA + if( ((tmp->tm_year - CFG_M41T11_BASE_YEAR) > 200) || + (tmp->tm_year < CFG_M41T11_BASE_YEAR) ){ + printf( "m41t11 RTC setting year out of range!!need recompile\n" ); + } + data[RTC_HOUR_ADDR] |= (tmp->tm_year - CFG_M41T11_BASE_YEAR) > 100 ? 0x40 : 0; +#else + { + unsigned char cent; + cent = tmp->tm_year ? tmp->tm_year / 100 : 0; + data[RTC_HOUR_ADDR] |= (cent & 0x1) ? 0x40 : 0; + i2c_write(CFG_I2C_RTC_ADDR, M41T11_YEAR_DATA, 1, ¢, M41T11_YEAR_SIZE); + } +#endif + i2c_write(CFG_I2C_RTC_ADDR, RTC_SEC_ADDR, 1, data, RTC_REG_CNT); +} + +void rtc_reset (void) +{ + unsigned char val; + /* clear all control & status registers */ + i2c_read(CFG_I2C_RTC_ADDR, RTC_SEC_ADDR, 1, &val, 1); + val = val & 0x7F;/*make sure we are running*/ + i2c_write(CFG_I2C_RTC_ADDR, RTC_SEC_ADDR, 1, &val, RTC_REG_CNT); + + i2c_read(CFG_I2C_RTC_ADDR, RTC_CONTROL_ADDR, 1, &val, 1); + val = val & 0x3F;/*turn off freq test keep calibration*/ + i2c_write(CFG_I2C_RTC_ADDR, RTC_CONTROL_ADDR, 1, &val, 1); +} + +int rtc_store(int addr, unsigned char* data, int size) +{ + /*don't let things wrap onto the time on a write*/ + if( (addr+size) >= M41T11_STORAGE_SZ ) + return 1; + return i2c_write( CFG_I2C_RTC_ADDR, REG_CNT+addr, 1, data, size ); +} + +int rtc_recall(int addr, unsigned char* data, int size) +{ + return i2c_read( CFG_I2C_RTC_ADDR, REG_CNT+addr, 1, data, size ); +} + +#endif /* CONFIG_RTC_M41T11 && CFG_I2C_RTC_ADDR && CFG_CMD_DATE */