Commit 782eddeb authored by Chaithrika U S's avatar Chaithrika U S Committed by Kevin Hilman

ARM: DaVinci: EMAC: Simplfiy resource structure, modify EMAC platform data

EMAC platform device definitions have been moved to the respective SoC specific
files, also the resource structures have been simplified to represent a single
contiguous memory region.

Platform data has been suitably modified to add module offsets. PHY
address mask and maximum MDIO clock value has also been included in the
platform data structure.

The EMAC init is done by the EVM/board init function and not by the EEPROM
setup.
Signed-off-by: default avatarChaithrika U S <chaithrika@ti.com>
Signed-off-by: default avatarKevin Hilman <khilman@deeprootsystems.com>
parent 4bbab93e
...@@ -45,6 +45,9 @@ ...@@ -45,6 +45,9 @@
#include <mach/nand.h> #include <mach/nand.h>
#include <mach/mmc.h> #include <mach/mmc.h>
#define DM644X_EVM_PHY_MASK (0x2)
#define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
#define DAVINCI_CFC_ATA_BASE 0x01C66000 #define DAVINCI_CFC_ATA_BASE 0x01C66000
#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000 #define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000
...@@ -56,6 +59,11 @@ ...@@ -56,6 +59,11 @@
#define LXT971_PHY_ID (0x001378e2) #define LXT971_PHY_ID (0x001378e2)
#define LXT971_PHY_MASK (0xfffffff0) #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[] = { static struct mtd_partition davinci_evm_norflash_partitions[] = {
/* bootloader (UBL, U-Boot, etc) in first 5 sectors */ /* bootloader (UBL, U-Boot, etc) in first 5 sectors */
{ {
...@@ -418,7 +426,7 @@ static int at24_setup(struct at24_iface *iface, void *context) ...@@ -418,7 +426,7 @@ static int at24_setup(struct at24_iface *iface, void *context)
printk(KERN_INFO "Read MAC addr from EEPROM: %s\n", printk(KERN_INFO "Read MAC addr from EEPROM: %s\n",
print_mac(mac_str, mac_addr)); print_mac(mac_str, mac_addr));
davinci_init_emac(mac_addr); memcpy(dm644x_evm_emac_pdata.mac_addr, mac_addr, 6);
} }
return 0; return 0;
...@@ -667,6 +675,7 @@ static __init void davinci_evm_init(void) ...@@ -667,6 +675,7 @@ static __init void davinci_evm_init(void)
davinci_setup_mmc(0, &dm6446evm_mmc_config); davinci_setup_mmc(0, &dm6446evm_mmc_config);
davinci_serial_init(&uart_config); davinci_serial_init(&uart_config);
davinci_init_emac(&dm644x_evm_emac_pdata);
/* Register the fixup for PHY on DaVinci */ /* Register the fixup for PHY on DaVinci */
phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK, phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
......
...@@ -46,6 +46,14 @@ ...@@ -46,6 +46,14 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <mach/emac.h> #include <mach/emac.h>
#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 = { static struct davinci_uart_config uart_config __initdata = {
.enabled_uarts = (1 << 0), .enabled_uarts = (1 << 0),
}; };
...@@ -68,7 +76,7 @@ static int at24_setup(struct at24_iface *iface, void *context) ...@@ -68,7 +76,7 @@ static int at24_setup(struct at24_iface *iface, void *context)
printk(KERN_INFO "Read MAC addr from EEPROM: %s\n", printk(KERN_INFO "Read MAC addr from EEPROM: %s\n",
print_mac(mac_str, mac_addr)); print_mac(mac_str, mac_addr));
davinci_init_emac(mac_addr); memcpy(dm646x_evm_emac_pdata.mac_addr, mac_addr, 6);
} }
return 0; return 0;
} }
...@@ -123,6 +131,7 @@ static __init void evm_init(void) ...@@ -123,6 +131,7 @@ static __init void evm_init(void)
{ {
evm_init_i2c(); evm_init_i2c();
davinci_serial_init(&uart_config); davinci_serial_init(&uart_config);
davinci_init_emac(&dm646x_evm_emac_pdata);
} }
static __init void davinci_dm646x_evm_irq_init(void) static __init void davinci_dm646x_evm_irq_init(void)
......
...@@ -54,6 +54,9 @@ ...@@ -54,6 +54,9 @@
#include <mach/psc.h> #include <mach/psc.h>
#include <mach/mux.h> #include <mach/mux.h>
#define SFFSDR_PHY_MASK (0x2)
#define SFFSDR_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000 #define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000
#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000 #define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
...@@ -108,6 +111,11 @@ static struct platform_device davinci_sffsdr_nandflash_device = { ...@@ -108,6 +111,11 @@ static struct platform_device davinci_sffsdr_nandflash_device = {
/* Get Ethernet address from kernel boot params */ /* Get Ethernet address from kernel boot params */
static u8 davinci_sffsdr_mac_addr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; static u8 davinci_sffsdr_mac_addr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
static struct emac_platform_data sffsdr_emac_pdata = {
.phy_mask = SFFSDR_PHY_MASK,
.mdio_max_freq = SFFSDR_MDIO_FREQUENCY,
};
static struct at24_platform_data eeprom_info = { static struct at24_platform_data eeprom_info = {
.byte_len = (64*1024) / 8, .byte_len = (64*1024) / 8,
.page_size = 32, .page_size = 32,
...@@ -157,7 +165,8 @@ static __init void davinci_sffsdr_init(void) ...@@ -157,7 +165,8 @@ static __init void davinci_sffsdr_init(void)
ARRAY_SIZE(davinci_sffsdr_devices)); ARRAY_SIZE(davinci_sffsdr_devices));
sffsdr_init_i2c(); sffsdr_init_i2c();
davinci_serial_init(&uart_config); davinci_serial_init(&uart_config);
davinci_init_emac(davinci_sffsdr_mac_addr); memcpy(sffsdr_emac_pdata.mac_addr, davinci_sffsdr_mac_addr, 6);
davinci_init_emac(&sffsdr_emac_pdata);
setup_usb(0, 0); /* We support only peripheral mode. */ setup_usb(0, 0); /* We support only peripheral mode. */
/* mux VLYNQ pins */ /* mux VLYNQ pins */
......
...@@ -29,15 +29,12 @@ ...@@ -29,15 +29,12 @@
#include <mach/cpu.h> #include <mach/cpu.h>
#include <mach/mux.h> #include <mach/mux.h>
#include <mach/mmc.h> #include <mach/mmc.h>
#include <mach/dm646x.h>
#include "clock.h" #include "clock.h"
#define DAVINCI_I2C_BASE 0x01C21000 #define DAVINCI_I2C_BASE 0x01C21000
#define DAVINCI_EMAC_CNTRL_REGS_BASE 0x01C80000
#define DAVINCI_EMAC_CNTRL_MOD_REGS_BASE 0x01C81000
#define DAVINCI_EMAC_CNTRL_RAM_BASE 0x01C82000
#define DAVINCI_EMAC_MDIO_REGS_BASE 0x01C84000
#define DAVINCI_MMCSD0_BASE 0x01E10000 #define DAVINCI_MMCSD0_BASE 0x01E10000
#define DM355_MMCSD0_BASE 0x01E11000 #define DM355_MMCSD0_BASE 0x01E11000
#define DM355_MMCSD1_BASE 0x01E00000 #define DM355_MMCSD1_BASE 0x01E00000
...@@ -248,136 +245,30 @@ static void davinci_init_wdt(void) ...@@ -248,136 +245,30 @@ static void davinci_init_wdt(void)
#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE) #if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
static struct resource emac_resources[] = { void davinci_init_emac(struct emac_platform_data *pdata)
{
.start = DAVINCI_EMAC_CNTRL_REGS_BASE,
.end = DAVINCI_EMAC_CNTRL_REGS_BASE + 0x0fff,
.flags = IORESOURCE_MEM,
.name = "ctrl_regs"
},
{
.start = DAVINCI_EMAC_CNTRL_MOD_REGS_BASE,
.end = DAVINCI_EMAC_CNTRL_MOD_REGS_BASE + 0x0fff,
.flags = IORESOURCE_MEM,
.name = "ctrl_module_regs"
},
{
.start = DAVINCI_EMAC_CNTRL_RAM_BASE,
.end = DAVINCI_EMAC_CNTRL_RAM_BASE + 0x1fff,
.flags = IORESOURCE_MEM,
.name = "ctrl_ram"
},
{
.start = DAVINCI_EMAC_MDIO_REGS_BASE,
.end = DAVINCI_EMAC_MDIO_REGS_BASE + 0x07ff,
.flags = IORESOURCE_MEM,
.name = "mdio_regs"
},
{
.start = IRQ_EMACINT,
.end = IRQ_EMACINT,
.flags = IORESOURCE_IRQ,
},
};
static struct emac_platform_data emac_pdata;
static struct platform_device davinci_emac_device = {
.name = "davinci_emac",
.id = 1,
.num_resources = ARRAY_SIZE(emac_resources),
.resource = emac_resources,
.dev = {
.platform_data = &emac_pdata,
}
};
static struct resource dm646x_emac_resources[] = {
{
.start = DAVINCI_EMAC_CNTRL_REGS_BASE,
.end = DAVINCI_EMAC_CNTRL_REGS_BASE + 0x0fff,
.flags = IORESOURCE_MEM,
.name = "ctrl_regs"
},
{
.start = DAVINCI_EMAC_CNTRL_MOD_REGS_BASE,
.end = DAVINCI_EMAC_CNTRL_MOD_REGS_BASE + 0x0fff,
.flags = IORESOURCE_MEM,
.name = "ctrl_module_regs"
},
{
.start = DAVINCI_EMAC_CNTRL_RAM_BASE,
.end = DAVINCI_EMAC_CNTRL_RAM_BASE + 0x1fff,
.flags = IORESOURCE_MEM,
.name = "ctrl_ram"
},
{
.start = DAVINCI_EMAC_MDIO_REGS_BASE,
.end = DAVINCI_EMAC_MDIO_REGS_BASE + 0x07ff,
.flags = IORESOURCE_MEM,
.name = "mdio_regs"
},
{
.start = IRQ_DM646X_EMACRXTHINT,
.end = IRQ_DM646X_EMACRXTHINT,
.flags = IORESOURCE_IRQ,
},
{
.start = IRQ_DM646X_EMACRXINT,
.end = IRQ_DM646X_EMACRXINT,
.flags = IORESOURCE_IRQ,
},
{
.start = IRQ_DM646X_EMACTXINT,
.end = IRQ_DM646X_EMACTXINT,
.flags = IORESOURCE_IRQ,
},
{
.start = IRQ_DM646X_EMACMISCINT,
.end = IRQ_DM646X_EMACMISCINT,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device dm646x_emac_device = {
.name = "davinci_emac",
.id = 1,
.num_resources = ARRAY_SIZE(dm646x_emac_resources),
.resource = dm646x_emac_resources,
.dev = {
.platform_data = &emac_pdata,
}
};
void davinci_init_emac(char *mac_addr)
{ {
DECLARE_MAC_BUF(buf); DECLARE_MAC_BUF(buf);
if (!(cpu_is_davinci_dm644x() || cpu_is_davinci_dm646x())) if (cpu_is_davinci_dm644x())
return; dm644x_init_emac(pdata);
else if (cpu_is_davinci_dm646x())
dm646x_init_emac(pdata);
/* if valid MAC exists, don't re-register */ /* if valid MAC exists, don't re-register */
if (is_valid_ether_addr(emac_pdata.mac_addr)) if (is_valid_ether_addr(pdata->mac_addr))
return; return;
if (mac_addr && is_valid_ether_addr(mac_addr))
memcpy(emac_pdata.mac_addr, mac_addr, 6);
else { else {
/* Use random MAC if none passed */ /* Use random MAC if none passed */
random_ether_addr(emac_pdata.mac_addr); random_ether_addr(pdata->mac_addr);
printk(KERN_WARNING "%s: using random MAC addr: %s\n", printk(KERN_WARNING "%s: using random MAC addr: %s\n",
__func__, print_mac(buf, emac_pdata.mac_addr)); __func__, print_mac(buf, pdata->mac_addr));
} }
if ((cpu_is_davinci_dm644x()))
(void) platform_device_register(&davinci_emac_device);
else
(void) platform_device_register(&dm646x_emac_device);
} }
#else #else
void davinci_init_emac(char *unused) {} void davinci_init_emac(struct emac_platform_data *unused) {}
#endif #endif
...@@ -394,11 +285,3 @@ static int __init davinci_init_devices(void) ...@@ -394,11 +285,3 @@ static int __init davinci_init_devices(void)
} }
arch_initcall(davinci_init_devices); arch_initcall(davinci_init_devices);
static int __init davinci_init_devices_late(void)
{
/* This is a backup call in case board code did not call init func */
davinci_init_emac(NULL);
return 0;
}
late_initcall(davinci_init_devices_late);
...@@ -312,6 +312,30 @@ struct davinci_clk dm644x_clks[] = { ...@@ -312,6 +312,30 @@ struct davinci_clk dm644x_clks[] = {
CLK(NULL, NULL, NULL), CLK(NULL, NULL, NULL),
}; };
#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
static struct resource dm644x_emac_resources[] = {
{
.start = DM644X_EMAC_BASE,
.end = DM644X_EMAC_BASE + 0x47ff,
.flags = IORESOURCE_MEM,
},
{
.start = IRQ_EMACINT,
.end = IRQ_EMACINT,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device dm644x_emac_device = {
.name = "davinci_emac",
.id = 1,
.num_resources = ARRAY_SIZE(dm644x_emac_resources),
.resource = dm644x_emac_resources,
};
#endif
/* /*
* Device specific mux setup * Device specific mux setup
* *
...@@ -420,6 +444,23 @@ static struct platform_device dm644x_edma_device = { ...@@ -420,6 +444,23 @@ 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;
dm644x_emac_device.dev.platform_data = pdata;
platform_device_register(&dm644x_emac_device);
}
#else
void dm644x_init_emac(struct emac_platform_data *unused) {}
#endif
void __init dm644x_init(void) void __init dm644x_init(void)
{ {
......
...@@ -263,6 +263,44 @@ struct davinci_clk dm646x_clks[] = { ...@@ -263,6 +263,44 @@ struct davinci_clk dm646x_clks[] = {
CLK(NULL, NULL, NULL), CLK(NULL, NULL, NULL),
}; };
#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
static struct resource dm646x_emac_resources[] = {
{
.start = DM646X_EMAC_BASE,
.end = DM646X_EMAC_BASE + 0x47ff,
.flags = IORESOURCE_MEM,
},
{
.start = IRQ_DM646X_EMACRXTHINT,
.end = IRQ_DM646X_EMACRXTHINT,
.flags = IORESOURCE_IRQ,
},
{
.start = IRQ_DM646X_EMACRXINT,
.end = IRQ_DM646X_EMACRXINT,
.flags = IORESOURCE_IRQ,
},
{
.start = IRQ_DM646X_EMACTXINT,
.end = IRQ_DM646X_EMACTXINT,
.flags = IORESOURCE_IRQ,
},
{
.start = IRQ_DM646X_EMACMISCINT,
.end = IRQ_DM646X_EMACMISCINT,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device dm646x_emac_device = {
.name = "davinci_emac",
.id = 1,
.num_resources = ARRAY_SIZE(dm646x_emac_resources),
.resource = dm646x_emac_resources,
};
#endif
/* /*
* Device specific mux setup * Device specific mux setup
* *
...@@ -347,6 +385,23 @@ static struct platform_device dm646x_edma_device = { ...@@ -347,6 +385,23 @@ 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;
dm646x_emac_device.dev.platform_data = pdata;
platform_device_register(&dm646x_emac_device);
}
#else
void dm646x_init_emac(struct emac_platform_data *unused) {}
#endif
void __init dm646x_init(void) void __init dm646x_init(void)
{ {
......
...@@ -22,8 +22,18 @@ ...@@ -22,8 +22,18 @@
#ifndef __ASM_ARCH_DM644X_H #ifndef __ASM_ARCH_DM644X_H
#define __ASM_ARCH_DM644X_H #define __ASM_ARCH_DM644X_H
#include <linux/platform_device.h>
#include <mach/hardware.h> #include <mach/hardware.h>
#include <mach/emac.h>
#define DM644X_EMAC_BASE (0x01C80000)
#define DM644X_EMAC_CNTRL_OFFSET (0x0000)
#define DM644X_EMAC_CNTRL_MOD_OFFSET (0x1000)
#define DM644X_EMAC_CNTRL_RAM_OFFSET (0x2000)
#define DM644X_EMAC_MDIO_OFFSET (0x4000)
#define DM644X_EMAC_CNTRL_RAM_SIZE (0x2000)
void __init dm644x_init(void); void __init dm644x_init(void);
void dm644x_init_emac(struct emac_platform_data *pdata);
#endif /* __ASM_ARCH_DM644X_H */ #endif /* __ASM_ARCH_DM644X_H */
...@@ -11,8 +11,18 @@ ...@@ -11,8 +11,18 @@
#ifndef __ASM_ARCH_DM646X_H #ifndef __ASM_ARCH_DM646X_H
#define __ASM_ARCH_DM646X_H #define __ASM_ARCH_DM646X_H
#include <linux/platform_device.h>
#include <mach/hardware.h> #include <mach/hardware.h>
#include <mach/emac.h>
#define DM646X_EMAC_BASE (0x01C80000)
#define DM646X_EMAC_CNTRL_OFFSET (0x0000)
#define DM646X_EMAC_CNTRL_MOD_OFFSET (0x1000)
#define DM646X_EMAC_CNTRL_RAM_OFFSET (0x2000)
#define DM646X_EMAC_MDIO_OFFSET (0x4000)
#define DM646X_EMAC_CNTRL_RAM_SIZE (0x2000)
void __init dm646x_init(void); void __init dm646x_init(void);
void dm646x_init_emac(struct emac_platform_data *pdata);
#endif /* __ASM_ARCH_DM646X_H */ #endif /* __ASM_ARCH_DM646X_H */
...@@ -13,9 +13,16 @@ ...@@ -13,9 +13,16 @@
struct emac_platform_data { struct emac_platform_data {
char mac_addr[6]; char mac_addr[6];
u32 ctrl_reg_offset;
u32 ctrl_mod_reg_offset;
u32 ctrl_ram_offset;
u32 mdio_reg_offset;
u32 ctrl_ram_size;
u32 phy_mask;
u32 mdio_max_freq;
}; };
void davinci_init_emac(char *mac_addr); void davinci_init_emac(struct emac_platform_data *pdata);
#endif #endif
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