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.

Re-worked for eeprom.c changes and only patched the address code
This commit is contained in:
Holger Hans Peter Freyther 2012-12-18 14:40:09 +01:00 committed by Holger Hans Peter Freyther
parent 8c0c131d00
commit 7fa3734927
4 changed files with 62 additions and 14 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_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();

View File

@ -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;

View File

@ -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

View File

@ -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 */
/*=================*/