diff --git a/board/davinci/sysmobts_v2/sysmobts_v2.c b/board/davinci/sysmobts_v2/sysmobts_v2.c index f727d66923..f74522e4cc 100644 --- a/board/davinci/sysmobts_v2/sysmobts_v2.c +++ b/board/davinci/sysmobts_v2/sysmobts_v2.c @@ -45,6 +45,12 @@ DECLARE_GLOBAL_DATA_PTR; +static int get_board_revision(void) +{ + unsigned *gpio01 = (unsigned *)(DAVINCI_GPIO_BASE + 0x20); + return (*gpio01 >> 15) & 0x0007; +} + /* Read ethernet MAC address from EEPROM. * Returns 1 if found, 0 otherwise. */ @@ -56,6 +62,17 @@ static int sysmobts_v2_read_mac_address(uint8_t *buf) (uint8_t *) &buf[0], 6)) goto i2cerr; + /* Revision A, B, C (64LC02) or Revision D (64LC64) */ + if (get_board_revision() <= 2) { + if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0x0000, 1, + (uint8_t *) &buf[0], 6)) + goto i2cerr; + } else { + if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, 0x0000, 2, + (uint8_t *) &buf[0], 6)) + goto i2cerr; + } + /* Check that MAC address is valid. */ if (!is_valid_ethaddr(buf)) goto err; @@ -109,6 +126,20 @@ int board_init(void) /* Power on required peripherals */ lpsc_on(DAVINCI_LPSC_GPIO); + /* + * U-Boot does not support more than one EEPROM and we need to + * set parameters depending on the actual hardware revision we + * run on. + * Revision A, B, C (64LC02), Revision D (64LC64) + */ + if (get_board_revision() <= 2) { + eeprom_set_addr_len(1); + eeprom_set_page_size(1 << 3); + } else { + eeprom_set_addr_len(2); + eeprom_set_page_size(1 << 5); + } + /* Powerup the DSP */ dsp_on(); diff --git a/cmd/eeprom.c b/cmd/eeprom.c index 0a0e4a2c1c..7b99b0ed8e 100644 --- a/cmd/eeprom.c +++ b/cmd/eeprom.c @@ -42,8 +42,10 @@ #define I2C_RXTX_LEN 128 #endif -#define EEPROM_PAGE_SIZE (1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS) -#define EEPROM_PAGE_OFFSET(x) ((x) & (EEPROM_PAGE_SIZE - 1)) +static unsigned eeprom_addr_len = CONFIG_SYS_I2C_EEPROM_ADDR_LEN; +static unsigned eeprom_page_size = (1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS); + +#define EEPROM_PAGE_OFFSET(x) ((x) & (eeprom_page_size - 1)) /* * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is @@ -60,6 +62,19 @@ #endif #endif + +int eeprom_set_addr_len (unsigned len) +{ + eeprom_addr_len = len; + return 0; +} + +int eeprom_set_page_size (unsigned size) +{ + eeprom_page_size = size; + return 0; +} + __weak int eeprom_write_enable(unsigned dev_addr, int state) { return 0; @@ -88,16 +103,16 @@ static int eeprom_addr(unsigned dev_addr, unsigned offset, uchar *addr) int alen; blk_off = offset & 0xff; /* block offset */ -#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 - addr[0] = offset >> 8; /* block number */ - addr[1] = blk_off; /* block offset */ - alen = 2; -#else - addr[0] = offset >> 16; /* block number */ - addr[1] = offset >> 8; /* upper address octet */ - addr[2] = blk_off; /* lower address octet */ - alen = 3; -#endif /* CONFIG_SYS_I2C_EEPROM_ADDR_LEN */ + if (eeprom_addr_len == 1) { + addr[0] = offset >> 8; /* block number */ + addr[1] = blk_off; /* block offset */ + alen = 2; + } else { + addr[0] = offset >> 16; /* block number */ + addr[1] = offset >> 8; /* upper address octet */ + addr[2] = blk_off; /* lower address octet */ + alen = 3; + } addr[0] |= dev_addr; /* insert device address */ @@ -115,7 +130,7 @@ static int eeprom_len(unsigned offset, unsigned end) */ #if !defined(CONFIG_SYS_I2C_FRAM) unsigned blk_off = offset & 0xff; - unsigned maxlen = EEPROM_PAGE_SIZE - EEPROM_PAGE_OFFSET(blk_off); + unsigned maxlen = eeprom_page_size - EEPROM_PAGE_OFFSET(blk_off); if (maxlen > I2C_RXTX_LEN) maxlen = I2C_RXTX_LEN; diff --git a/include/common.h b/include/common.h index fbbc2cbc52..35b8b700d2 100644 --- a/include/common.h +++ b/include/common.h @@ -475,6 +475,8 @@ void fdc_hw_init (void); void eeprom_init (int bus); int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt); int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt); +int eeprom_set_addr_len (unsigned len); +int eeprom_set_page_size (unsigned size); /* * Set this up regardless of board diff --git a/include/configs/davinci_sysmobts_v2.h b/include/configs/davinci_sysmobts_v2.h index 540d0488a9..254e36e81a 100644 --- a/include/configs/davinci_sysmobts_v2.h +++ b/include/configs/davinci_sysmobts_v2.h @@ -137,7 +137,7 @@ #define CONFIG_CMDLINE_TAG #define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_BOOTARGS "console=ttyS0,115200n8 root=ubi0:sysmobts-v2-rootfs ubi.mtd=3 rootfstype=ubifs rw noinitrd" -#define CONFIG_BOOTCOMMAND "mtdpart default;ubi part RootFs;ubifsmount sysmobts-v2-rootfs;ubifsload 85000000 /boot/uImage;bootm 85000000" +#define CONFIG_BOOTCOMMAND "mtdpart default;setenv bootargs ${bootargs} ${mtdparts};ubi part RootFs;ubifsmount sysmobts-v2-rootfs;ubifsload 85000000 /boot/uImage;bootm 85000000" /*=================*/ /* U-Boot commands */ /*=================*/