Commit 972412b6 authored by Mark A. Greer's avatar Mark A. Greer Committed by Kevin Hilman

davinci: Move emac platform_data to SoC-specific files

Since most of the emac platform_data is really SoC specific
and not board specific, move it to the SoC-specific files.
Put a pointer to the platform_data in the soc_info structure
so the board-specific code can set some of the platform_data
if it needs to.
Signed-off-by: default avatarMark A. Greer <mgreer@mvista.com>
Signed-off-by: default avatarKevin Hilman <khilman@deeprootsystems.com>
parent 65e866a9
......@@ -38,7 +38,6 @@
#include <mach/dm644x.h>
#include <mach/common.h>
#include <mach/emac.h>
#include <mach/i2c.h>
#include <mach/serial.h>
#include <mach/mux.h>
......@@ -61,11 +60,6 @@
#define LXT971_PHY_ID (0x001378e2)
#define LXT971_PHY_MASK (0xfffffff0)
static struct emac_platform_data dm644x_evm_emac_pdata = {
.phy_mask = DM644X_EVM_PHY_MASK,
.mdio_max_freq = DM644X_EVM_MDIO_FREQUENCY,
};
static struct mtd_partition davinci_evm_norflash_partitions[] = {
/* bootloader (UBL, U-Boot, etc) in first 5 sectors */
{
......@@ -448,6 +442,7 @@ static struct memory_accessor *at24_mem_acc;
static void at24_setup(struct memory_accessor *mem_acc, void *context)
{
char mac_addr[ETH_ALEN];
struct davinci_soc_info *soc_info = &davinci_soc_info;
at24_mem_acc = mem_acc;
......@@ -455,7 +450,7 @@ static void at24_setup(struct memory_accessor *mem_acc, void *context)
if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, ETH_ALEN) ==
ETH_ALEN) {
printk(KERN_INFO "Read MAC addr from EEPROM: %pM\n", mac_addr);
memcpy(dm644x_evm_emac_pdata.mac_addr, mac_addr, ETH_ALEN);
memcpy(soc_info->emac_pdata->mac_addr, mac_addr, ETH_ALEN);
}
}
......@@ -650,6 +645,7 @@ static int davinci_phy_fixup(struct phy_device *phydev)
static __init void davinci_evm_init(void)
{
struct clk *aemif_clk;
struct davinci_soc_info *soc_info = &davinci_soc_info;
aemif_clk = clk_get(NULL, "aemif");
clk_enable(aemif_clk);
......@@ -686,7 +682,9 @@ static __init void davinci_evm_init(void)
davinci_serial_init(&uart_config);
dm644x_init_emac(&dm644x_evm_emac_pdata);
soc_info->emac_pdata->phy_mask = DM644X_EVM_PHY_MASK;
soc_info->emac_pdata->mdio_max_freq = DM644X_EVM_MDIO_FREQUENCY;
dm644x_init_emac(soc_info->emac_pdata);
/* Register the fixup for PHY on DaVinci */
phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
......
......@@ -52,11 +52,6 @@
#define DM646X_EVM_PHY_MASK (0x2)
#define DM646X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
static struct emac_platform_data dm646x_evm_emac_pdata = {
.phy_mask = DM646X_EVM_PHY_MASK,
.mdio_max_freq = DM646X_EVM_MDIO_FREQUENCY,
};
static struct davinci_uart_config uart_config __initdata = {
.enabled_uarts = (1 << 0),
};
......@@ -208,6 +203,7 @@ static struct memory_accessor *at24_mem_acc;
static void at24_setup(struct memory_accessor *mem_acc, void *context)
{
char mac_addr[ETH_ALEN];
struct davinci_soc_info *soc_info = &davinci_soc_info;
at24_mem_acc = mem_acc;
......@@ -215,7 +211,7 @@ static void at24_setup(struct memory_accessor *mem_acc, void *context)
if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, ETH_ALEN) ==
ETH_ALEN) {
pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
memcpy(dm646x_evm_emac_pdata.mac_addr, mac_addr, ETH_ALEN);
memcpy(soc_info->emac_pdata->mac_addr, mac_addr, ETH_ALEN);
}
}
......@@ -271,9 +267,14 @@ static void __init davinci_map_io(void)
static __init void evm_init(void)
{
struct davinci_soc_info *soc_info = &davinci_soc_info;
evm_init_i2c();
davinci_serial_init(&uart_config);
dm646x_init_emac(&dm646x_evm_emac_pdata);
soc_info->emac_pdata->phy_mask = DM646X_EVM_PHY_MASK;
soc_info->emac_pdata->mdio_max_freq = DM646X_EVM_MDIO_FREQUENCY;
dm646x_init_emac(soc_info->emac_pdata);
}
static __init void davinci_dm646x_evm_irq_init(void)
......
......@@ -48,7 +48,6 @@
#include <mach/dm644x.h>
#include <mach/common.h>
#include <mach/emac.h>
#include <mach/i2c.h>
#include <mach/serial.h>
#include <mach/psc.h>
......@@ -158,11 +157,14 @@ static void __init davinci_sffsdr_map_io(void)
static __init void davinci_sffsdr_init(void)
{
struct davinci_soc_info *soc_info = &davinci_soc_info;
platform_add_devices(davinci_sffsdr_devices,
ARRAY_SIZE(davinci_sffsdr_devices));
sffsdr_init_i2c();
davinci_serial_init(&uart_config);
dm644x_init_emac(&sffsdr_emac_pdata);
soc_info->emac_pdata->phy_mask = SFFSDR_PHY_MASK;
soc_info->emac_pdata->mdio_max_freq = SFFSDR_MDIO_FREQUENCY;
setup_usb(0, 0); /* We support only peripheral mode. */
/* mux VLYNQ pins */
......
......@@ -260,11 +260,6 @@ void davinci_init_emac(struct emac_platform_data *pdata)
{
DECLARE_MAC_BUF(buf);
if (cpu_is_davinci_dm644x())
dm644x_init_emac(pdata);
else if (cpu_is_davinci_dm646x())
dm646x_init_emac(pdata);
/* if valid MAC exists, don't re-register */
if (is_valid_ether_addr(pdata->mac_addr))
return;
......
......@@ -319,7 +319,14 @@ struct davinci_clk dm644x_clks[] = {
CLK(NULL, NULL, NULL),
};
#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
static struct emac_platform_data dm644x_emac_pdata = {
.ctrl_reg_offset = DM644X_EMAC_CNTRL_OFFSET,
.ctrl_mod_reg_offset = DM644X_EMAC_CNTRL_MOD_OFFSET,
.ctrl_ram_offset = DM644X_EMAC_CNTRL_RAM_OFFSET,
.mdio_reg_offset = DM644X_EMAC_MDIO_OFFSET,
.ctrl_ram_size = DM644X_EMAC_CNTRL_RAM_SIZE,
.version = EMAC_VERSION_1,
};
static struct resource dm644x_emac_resources[] = {
{
......@@ -337,12 +344,13 @@ static struct resource dm644x_emac_resources[] = {
static struct platform_device dm644x_emac_device = {
.name = "davinci_emac",
.id = 1,
.dev = {
.platform_data = &dm644x_emac_pdata,
},
.num_resources = ARRAY_SIZE(dm644x_emac_resources),
.resource = dm644x_emac_resources,
};
#endif
/*
* Device specific mux setup
*
......@@ -520,24 +528,6 @@ static struct platform_device dm644x_edma_device = {
};
/*----------------------------------------------------------------------*/
#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
void dm644x_init_emac(struct emac_platform_data *pdata)
{
pdata->ctrl_reg_offset = DM644X_EMAC_CNTRL_OFFSET;
pdata->ctrl_mod_reg_offset = DM644X_EMAC_CNTRL_MOD_OFFSET;
pdata->ctrl_ram_offset = DM644X_EMAC_CNTRL_RAM_OFFSET;
pdata->mdio_reg_offset = DM644X_EMAC_MDIO_OFFSET;
pdata->ctrl_ram_size = DM644X_EMAC_CNTRL_RAM_SIZE;
pdata->version = EMAC_VERSION_1;
dm644x_emac_device.dev.platform_data = pdata;
platform_device_register(&dm644x_emac_device);
}
#else
void dm644x_init_emac(struct emac_platform_data *unused) {}
#endif
static struct map_desc dm644x_io_desc[] = {
{
......@@ -635,6 +625,7 @@ static struct davinci_soc_info davinci_soc_info_dm644x = {
.gpio_num = 71,
.gpio_irq = IRQ_GPIOBNK0,
.serial_dev = &dm644x_serial_device,
.emac_pdata = &dm644x_emac_pdata,
};
void __init dm644x_init(void)
......@@ -648,6 +639,7 @@ static int __init dm644x_init_devices(void)
return 0;
platform_device_register(&dm644x_edma_device);
platform_device_register(&dm644x_emac_device);
return 0;
}
postcore_initcall(dm644x_init_devices);
......@@ -286,7 +286,15 @@ struct davinci_clk dm646x_clks[] = {
CLK(NULL, NULL, NULL),
};
#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
static struct emac_platform_data dm646x_emac_pdata = {
.ctrl_reg_offset = DM646X_EMAC_CNTRL_OFFSET,
.ctrl_mod_reg_offset = DM646X_EMAC_CNTRL_MOD_OFFSET,
.ctrl_ram_offset = DM646X_EMAC_CNTRL_RAM_OFFSET,
.mdio_reg_offset = DM646X_EMAC_MDIO_OFFSET,
.ctrl_ram_size = DM646X_EMAC_CNTRL_RAM_SIZE,
.version = EMAC_VERSION_2,
};
static struct resource dm646x_emac_resources[] = {
{
.start = DM646X_EMAC_BASE,
......@@ -318,12 +326,13 @@ static struct resource dm646x_emac_resources[] = {
static struct platform_device dm646x_emac_device = {
.name = "davinci_emac",
.id = 1,
.dev = {
.platform_data = &dm646x_emac_pdata,
},
.num_resources = ARRAY_SIZE(dm646x_emac_resources),
.resource = dm646x_emac_resources,
};
#endif
/*
* Device specific mux setup
*
......@@ -499,25 +508,6 @@ static struct platform_device dm646x_edma_device = {
/*----------------------------------------------------------------------*/
#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
void dm646x_init_emac(struct emac_platform_data *pdata)
{
pdata->ctrl_reg_offset = DM646X_EMAC_CNTRL_OFFSET;
pdata->ctrl_mod_reg_offset = DM646X_EMAC_CNTRL_MOD_OFFSET;
pdata->ctrl_ram_offset = DM646X_EMAC_CNTRL_RAM_OFFSET;
pdata->mdio_reg_offset = DM646X_EMAC_MDIO_OFFSET;
pdata->ctrl_ram_size = DM646X_EMAC_CNTRL_RAM_SIZE;
pdata->version = EMAC_VERSION_2;
dm646x_emac_device.dev.platform_data = pdata;
platform_device_register(&dm646x_emac_device);
}
#else
void dm646x_init_emac(struct emac_platform_data *unused) {}
#endif
static struct map_desc dm646x_io_desc[] = {
{
.virtual = IO_VIRT,
......@@ -614,6 +604,7 @@ static struct davinci_soc_info davinci_soc_info_dm646x = {
.gpio_num = 43, /* Only 33 usable */
.gpio_irq = IRQ_DM646X_GPIOBNK0,
.serial_dev = &dm646x_serial_device,
.emac_pdata = &dm646x_emac_pdata,
};
void __init dm646x_init(void)
......@@ -627,6 +618,7 @@ static int __init dm646x_init_devices(void)
return 0;
platform_device_register(&dm646x_edma_device);
platform_device_register(&dm646x_emac_device);
return 0;
}
postcore_initcall(dm646x_init_devices);
......@@ -62,6 +62,7 @@ struct davinci_soc_info {
unsigned gpio_num;
unsigned gpio_irq;
struct platform_device *serial_dev;
struct emac_platform_data *emac_pdata;
};
extern struct davinci_soc_info davinci_soc_info;
......
......@@ -34,6 +34,5 @@
#define DM644X_EMAC_CNTRL_RAM_SIZE (0x2000)
void __init dm644x_init(void);
void dm644x_init_emac(struct emac_platform_data *pdata);
#endif /* __ASM_ARCH_DM644X_H */
......@@ -22,6 +22,5 @@
#define DM646X_EMAC_CNTRL_RAM_SIZE (0x2000)
void __init dm646x_init(void);
void dm646x_init_emac(struct emac_platform_data *pdata);
#endif /* __ASM_ARCH_DM646X_H */
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