davinci: EMAC platform support

Add SoC and platform-specific data and init for DaVinci EMAC network
driver.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
This commit is contained in:
Kevin Hilman 2009-05-07 06:19:40 -07:00
parent 2dbf56aeb7
commit ac7b75b5bb
8 changed files with 161 additions and 27 deletions

View File

@ -16,12 +16,11 @@
#include <linux/gpio.h>
#include <linux/leds.h>
#include <linux/memory.h>
#include <linux/etherdevice.h>
#include <linux/i2c.h>
#include <linux/i2c/pcf857x.h>
#include <linux/i2c/at24.h>
#include <linux/etherdevice.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
@ -39,6 +38,7 @@
#include <mach/dm644x.h>
#include <mach/common.h>
#include <mach/emac.h>
#include <mach/i2c.h>
#include <mach/serial.h>
#include <mach/mux.h>
@ -60,6 +60,11 @@
#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 */
{
@ -441,15 +446,15 @@ static struct memory_accessor *at24_mem_acc;
static void at24_setup(struct memory_accessor *mem_acc, void *context)
{
DECLARE_MAC_BUF(mac_str);
char mac_addr[6];
char mac_addr[ETH_ALEN];
at24_mem_acc = mem_acc;
/* Read MAC addr from EEPROM */
if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, 6) == 6) {
printk(KERN_INFO "Read MAC addr from EEPROM: %s\n",
print_mac(mac_str, mac_addr));
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);
}
}
@ -460,22 +465,6 @@ static struct at24_platform_data eeprom_info = {
.setup = at24_setup,
};
int dm6446evm_eeprom_read(void *buf, off_t off, size_t count)
{
if (at24_mem_acc)
return at24_mem_acc->read(at24_mem_acc, buf, off, count);
return -ENODEV;
}
EXPORT_SYMBOL(dm6446evm_eeprom_read);
int dm6446evm_eeprom_write(void *buf, off_t off, size_t count)
{
if (at24_mem_acc)
return at24_mem_acc->write(at24_mem_acc, buf, off, count);
return -ENODEV;
}
EXPORT_SYMBOL(dm6446evm_eeprom_write);
/*
* MSP430 supports RTC, card detection, input from IR remote, and
* a bit more. It triggers interrupts on GPIO(7) from pressing
@ -697,6 +686,8 @@ static __init void davinci_evm_init(void)
davinci_serial_init(&uart_config);
dm644x_init_emac(&dm644x_evm_emac_pdata);
/* Register the fixup for PHY on DaVinci */
phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
davinci_phy_fixup);

View File

@ -45,6 +45,16 @@
#include <mach/psc.h>
#include <mach/serial.h>
#include <mach/i2c.h>
#include <mach/mmc.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 = {
.enabled_uarts = (1 << 0),
@ -196,14 +206,16 @@ static struct memory_accessor *at24_mem_acc;
static void at24_setup(struct memory_accessor *mem_acc, void *context)
{
char mac_addr[6];
char mac_addr[ETH_ALEN];
at24_mem_acc = mem_acc;
/* Read MAC addr from EEPROM */
if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, ETH_ALEN) ==
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);
}
}
static struct at24_platform_data eeprom_info = {
@ -261,6 +273,7 @@ static __init void evm_init(void)
{
evm_init_i2c();
davinci_serial_init(&uart_config);
dm646x_init_emac(&dm646x_evm_emac_pdata);
}
static __init void davinci_dm646x_evm_irq_init(void)

View File

@ -48,11 +48,15 @@
#include <mach/dm644x.h>
#include <mach/common.h>
#include <mach/emac.h>
#include <mach/i2c.h>
#include <mach/serial.h>
#include <mach/psc.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_DATA_CE0_BASE 0x02000000
@ -104,8 +108,10 @@ static struct platform_device davinci_sffsdr_nandflash_device = {
.resource = davinci_sffsdr_nandflash_resource,
};
/* Get Ethernet address from kernel boot params */
static u8 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 = {
.byte_len = (64*1024) / 8,
@ -156,6 +162,7 @@ static __init void davinci_sffsdr_init(void)
ARRAY_SIZE(davinci_sffsdr_devices));
sffsdr_init_i2c();
davinci_serial_init(&uart_config);
dm644x_init_emac(&sffsdr_emac_pdata);
setup_usb(0, 0); /* We support only peripheral mode. */
/* mux VLYNQ pins */

View File

@ -444,6 +444,25 @@ 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
void __init dm644x_init(void)
{
davinci_clk_init(dm644x_clks);

View File

@ -279,6 +279,44 @@ struct davinci_clk dm646x_clks[] = {
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
*
@ -385,6 +423,25 @@ 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
void __init dm646x_init(void)
{
davinci_clk_init(dm646x_clks);

View File

@ -24,6 +24,7 @@
#include <linux/platform_device.h>
#include <mach/hardware.h>
#include <mach/emac.h>
#define DM644X_EMAC_BASE (0x01C80000)
#define DM644X_EMAC_CNTRL_OFFSET (0x0000)
@ -33,5 +34,6 @@
#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 */

View File

@ -12,7 +12,16 @@
#define __ASM_ARCH_DM646X_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 dm646x_init_emac(struct emac_platform_data *pdata);
#endif /* __ASM_ARCH_DM646X_H */

View File

@ -0,0 +1,36 @@
/*
* TI DaVinci EMAC platform support
*
* Author: Kevin Hilman, Deep Root Systems, LLC
*
* 2007 (c) Deep Root Systems, LLC. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
#ifndef _MACH_DAVINCI_EMAC_H
#define _MACH_DAVINCI_EMAC_H
#include <linux/if_ether.h>
struct emac_platform_data {
char mac_addr[ETH_ALEN];
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;
u8 rmii_en;
u8 version;
};
enum {
EMAC_VERSION_1, /* DM644x */
EMAC_VERSION_2, /* DM646x */
};
void davinci_init_emac(struct emac_platform_data *pdata);
#endif