sysmobts_v2: Add RevisionD for the sysmoBTSv2 hardware

The only ARM/kernel visible change is the change of the EEPROM. U-Boot
sadly does not support to select EEPROM with different page sizes and
address length. This is why we need to patch the common epprom code.

Introduce a new command to allow dynamic configuration of the EEPROM,
move the eeprom parameters into variables and change the code. This sadly
copies the SPI_X code as well. The address creation could be moved to
a different variable.

This code has been tested on RevC and RevD hardware and an IP address
could be obtained in both cases.
This commit is contained in:
Holger Hans Peter Freyther 2012-12-18 14:40:09 +01:00
parent d069eab228
commit 1528f96e4b
4 changed files with 96 additions and 25 deletions

View File

@ -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_ether_addr(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();

View File

@ -51,6 +51,13 @@ extern int eeprom_write (unsigned dev_addr, unsigned offset,
extern int eeprom_write_enable (unsigned dev_addr, int state);
#endif
#if !defined(CONFIG_SYS_EEPROM_DYNAMIC_SIZE)
static const unsigned eeprom_addr_len = CONFIG_SYS_I2C_EEPROM_ADDR_LEN;
static const unsigned eeprom_page_size = (1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS);
#else
static unsigned eeprom_addr_len = 0;
static unsigned eeprom_page_size = 0;
#endif
#if defined(CONFIG_SYS_EEPROM_X40430)
/* Maximum number of times to poll for acknowledge after write */
@ -59,6 +66,22 @@ extern int eeprom_write_enable (unsigned dev_addr, int state);
/* ------------------------------------------------------------------------- */
#if defined(CONFIG_SYS_EEPROM_DYNAMIC_SIZE)
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;
}
#endif
/* ------------------------------------------------------------------------- */
#if defined(CONFIG_CMD_EEPROM)
int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
{
@ -128,6 +151,7 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
unsigned end = offset + cnt;
unsigned blk_off;
int rcode = 0;
uchar addr[3];
/* Read data until done or would cross a page boundary.
* We must write the address again when changing pages
@ -139,24 +163,29 @@ int eeprom_read (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt
unsigned maxlen;
#endif
#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X)
uchar addr[2];
#if !defined(CONFIG_SPI_X)
if (eeprom_addr_len == 1) {
blk_off = offset & 0xFF; /* block offset */
blk_off = offset & 0xFF; /* block offset */
addr[0] = offset >> 8; /* block number */
addr[1] = blk_off; /* block offset */
alen = 2;
} else {
blk_off = offset & 0xFF; /* block offset */
addr[0] = offset >> 8; /* block number */
addr[1] = blk_off; /* block offset */
alen = 2;
addr[0] = offset >> 16; /* block number */
addr[1] = offset >> 8; /* upper address octet */
addr[2] = blk_off; /* lower address octet */
alen = 3;
}
#else
uchar addr[3];
blk_off = offset & 0xFF; /* block offset */
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, CONFIG_SPI_X */
#endif /* CONFIG_SPI_X */
addr[0] |= dev_addr; /* insert device address */
@ -221,28 +250,34 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
while (offset < end) {
unsigned alen, len;
uchar addr[3];
#if !defined(CONFIG_SYS_I2C_FRAM)
unsigned maxlen;
#endif
#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X)
uchar addr[2];
#if !defined(CONFIG_SPI_X)
if (eeprom_addr_len == 1) {
blk_off = offset & 0xFF; /* block offset */
blk_off = offset & 0xFF; /* block offset */
addr[0] = offset >> 8; /* block number */
addr[1] = blk_off; /* block offset */
alen = 2;
} else {
blk_off = offset & 0xFF; /* block offset */
addr[0] = offset >> 8; /* block number */
addr[1] = blk_off; /* block offset */
alen = 2;
addr[0] = offset >> 16; /* block number */
addr[1] = offset >> 8; /* upper address octet */
addr[2] = blk_off; /* lower address octet */
alen = 3;
}
#else
uchar addr[3];
blk_off = offset & 0xFF; /* block offset */
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, CONFIG_SPI_X */
#endif /* CONFIG_SPI_X */
addr[0] |= dev_addr; /* insert device address */
@ -257,10 +292,9 @@ int eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cn
#if defined(CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
#define EEPROM_PAGE_SIZE (1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
#define EEPROM_PAGE_OFFSET(x) ((x) & (EEPROM_PAGE_SIZE - 1))
#define EEPROM_PAGE_OFFSET(x) ((x) & (eeprom_page_size - 1))
maxlen = EEPROM_PAGE_SIZE - EEPROM_PAGE_OFFSET(blk_off);
maxlen = eeprom_page_size - EEPROM_PAGE_OFFSET(blk_off);
#else
maxlen = 0x100 - blk_off;
#endif
@ -381,11 +415,14 @@ eeprom_probe (unsigned dev_addr, unsigned offset)
/* Probe the chip address
*/
#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 && !defined(CONFIG_SPI_X)
chip = offset >> 8; /* block number */
#if !defined(CONFIG_SPI_X)
if (eeprom_addr_len == 1)
chip = offset >> 8; /* block number */
else
chip = offset >> 16; /* block number */
#else
chip = offset >> 16; /* block number */
#endif /* CONFIG_SYS_I2C_EEPROM_ADDR_LEN, CONFIG_SPI_X */
#endif /* CONFIG_SPI_X */
chip |= dev_addr; /* insert device address */

View File

@ -426,6 +426,8 @@ void fdc_hw_init (void);
/* $(BOARD)/eeprom.c */
void eeprom_init (void);
int eeprom_set_addr_len (unsigned len);
int eeprom_set_page_size (unsigned size);
#ifndef CONFIG_SPI
int eeprom_probe (unsigned dev_addr, unsigned offset);
#endif

View File

@ -40,6 +40,7 @@
/*====================*/
/* EEPROM definitions */
/*====================*/
#define CONFIG_SYS_EEPROM_DYNAMIC_SIZE 1
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50
#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3 /* 24xx02: 8 bytes / page */
@ -140,7 +141,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 */
/*=================*/