Commit db037cb1 authored by Chaithrika U.S's avatar Chaithrika U.S Committed by Kevin Hilman

ARM: DaVinci: Read MAC address from I2C EEPROM

Adds support for AT24 I2C EEPROM on DM646X
Signed-off-by: default avatarChaithrika U.S <chaithrika@ti.com>
parent 9ffd0b8e
......@@ -40,6 +40,12 @@
#include <mach/serial.h>
#include <mach/i2c.h>
#include <linux/platform_device.h>
#include <linux/i2c.h>
#include <linux/i2c/at24.h>
#include <linux/etherdevice.h>
#include <mach/emac.h>
static struct davinci_uart_config davinci_evm_uart_config __initdata = {
.enabled_uarts = (1 << 0),
};
......@@ -48,6 +54,58 @@ static struct davinci_board_config_kernel davinci_evm_config[] __initdata = {
{ DAVINCI_TAG_UART, &davinci_evm_uart_config },
};
/* Most of this EEPROM is unused, but U-Boot uses some data:
* - 0x7f00, 6 bytes Ethernet Address
* - ... newer boards may have more
*/
static struct at24_iface *at24_if;
static int at24_setup(struct at24_iface *iface, void *context)
{
DECLARE_MAC_BUF(mac_str);
char mac_addr[6];
at24_if = iface;
/* Read MAC addr from EEPROM */
if (at24_if->read(at24_if, mac_addr, 0x7f00, 6) == 6) {
printk(KERN_INFO "Read MAC addr from EEPROM: %s\n",
print_mac(mac_str, mac_addr));
davinci_init_emac(mac_addr);
}
return 0;
}
static struct at24_platform_data eeprom_info = {
.byte_len = (256*1024) / 8,
.page_size = 64,
.flags = AT24_FLAG_ADDR16,
.setup = at24_setup,
};
int dm646xevm_eeprom_read(void *buf, off_t off, size_t count)
{
if (at24_if)
return at24_if->read(at24_if, buf, off, count);
return -ENODEV;
}
EXPORT_SYMBOL(dm646xevm_eeprom_read);
int dm646xevm_eeprom_write(void *buf, off_t off, size_t count)
{
if (at24_if)
return at24_if->write(at24_if, buf, off, count);
return -ENODEV;
}
EXPORT_SYMBOL(dm646xevm_eeprom_write);
static struct i2c_board_info __initdata i2c_info[] = {
{
I2C_BOARD_INFO("24c256", 0x50),
.platform_data = &eeprom_info,
},
};
static struct davinci_i2c_platform_data i2c_pdata = {
.bus_freq = 100 /* kHz */,
.bus_delay = 0 /* usec */,
......@@ -56,6 +114,7 @@ static struct davinci_i2c_platform_data i2c_pdata = {
static void __init evm_init_i2c(void)
{
davinci_init_i2c(&i2c_pdata);
i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
}
#define UART_DM646X_SCR (DAVINCI_UART0_BASE + 0x40)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment