aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorKevin Hilman <khilman@deeprootsystems.com>2009-05-07 09:19:40 -0400
committerKevin Hilman <khilman@deeprootsystems.com>2009-05-26 10:18:16 -0400
commitac7b75b5bbbfd60b752869a22daa3be99b5b4f99 (patch)
treedac2408210f9e815f98f67c7c6e32216db99fa73 /arch/arm
parent2dbf56aeb7986b54651c93ed171877e8179289bc (diff)
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>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/mach-davinci/board-dm644x-evm.c37
-rw-r--r--arch/arm/mach-davinci/board-dm646x-evm.c17
-rw-r--r--arch/arm/mach-davinci/board-sffsdr.c11
-rw-r--r--arch/arm/mach-davinci/dm644x.c19
-rw-r--r--arch/arm/mach-davinci/dm646x.c57
-rw-r--r--arch/arm/mach-davinci/include/mach/dm644x.h2
-rw-r--r--arch/arm/mach-davinci/include/mach/dm646x.h9
-rw-r--r--arch/arm/mach-davinci/include/mach/emac.h36
8 files changed, 161 insertions, 27 deletions
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index 9c3ce311d5d7..02e7cdaf8daa 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -16,12 +16,11 @@
16#include <linux/gpio.h> 16#include <linux/gpio.h>
17#include <linux/leds.h> 17#include <linux/leds.h>
18#include <linux/memory.h> 18#include <linux/memory.h>
19#include <linux/etherdevice.h>
20 19
21#include <linux/i2c.h> 20#include <linux/i2c.h>
22#include <linux/i2c/pcf857x.h> 21#include <linux/i2c/pcf857x.h>
23#include <linux/i2c/at24.h> 22#include <linux/i2c/at24.h>
24 23#include <linux/etherdevice.h>
25#include <linux/mtd/mtd.h> 24#include <linux/mtd/mtd.h>
26#include <linux/mtd/nand.h> 25#include <linux/mtd/nand.h>
27#include <linux/mtd/partitions.h> 26#include <linux/mtd/partitions.h>
@@ -39,6 +38,7 @@
39 38
40#include <mach/dm644x.h> 39#include <mach/dm644x.h>
41#include <mach/common.h> 40#include <mach/common.h>
41#include <mach/emac.h>
42#include <mach/i2c.h> 42#include <mach/i2c.h>
43#include <mach/serial.h> 43#include <mach/serial.h>
44#include <mach/mux.h> 44#include <mach/mux.h>
@@ -60,6 +60,11 @@
60#define LXT971_PHY_ID (0x001378e2) 60#define LXT971_PHY_ID (0x001378e2)
61#define LXT971_PHY_MASK (0xfffffff0) 61#define LXT971_PHY_MASK (0xfffffff0)
62 62
63static struct emac_platform_data dm644x_evm_emac_pdata = {
64 .phy_mask = DM644X_EVM_PHY_MASK,
65 .mdio_max_freq = DM644X_EVM_MDIO_FREQUENCY,
66};
67
63static struct mtd_partition davinci_evm_norflash_partitions[] = { 68static struct mtd_partition davinci_evm_norflash_partitions[] = {
64 /* bootloader (UBL, U-Boot, etc) in first 5 sectors */ 69 /* bootloader (UBL, U-Boot, etc) in first 5 sectors */
65 { 70 {
@@ -441,15 +446,15 @@ static struct memory_accessor *at24_mem_acc;
441 446
442static void at24_setup(struct memory_accessor *mem_acc, void *context) 447static void at24_setup(struct memory_accessor *mem_acc, void *context)
443{ 448{
444 DECLARE_MAC_BUF(mac_str); 449 char mac_addr[ETH_ALEN];
445 char mac_addr[6];
446 450
447 at24_mem_acc = mem_acc; 451 at24_mem_acc = mem_acc;
448 452
449 /* Read MAC addr from EEPROM */ 453 /* Read MAC addr from EEPROM */
450 if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, 6) == 6) { 454 if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, ETH_ALEN) ==
451 printk(KERN_INFO "Read MAC addr from EEPROM: %s\n", 455 ETH_ALEN) {
452 print_mac(mac_str, mac_addr)); 456 printk(KERN_INFO "Read MAC addr from EEPROM: %pM\n", mac_addr);
457 memcpy(dm644x_evm_emac_pdata.mac_addr, mac_addr, ETH_ALEN);
453 } 458 }
454} 459}
455 460
@@ -460,22 +465,6 @@ static struct at24_platform_data eeprom_info = {
460 .setup = at24_setup, 465 .setup = at24_setup,
461}; 466};
462 467
463int dm6446evm_eeprom_read(void *buf, off_t off, size_t count)
464{
465 if (at24_mem_acc)
466 return at24_mem_acc->read(at24_mem_acc, buf, off, count);
467 return -ENODEV;
468}
469EXPORT_SYMBOL(dm6446evm_eeprom_read);
470
471int dm6446evm_eeprom_write(void *buf, off_t off, size_t count)
472{
473 if (at24_mem_acc)
474 return at24_mem_acc->write(at24_mem_acc, buf, off, count);
475 return -ENODEV;
476}
477EXPORT_SYMBOL(dm6446evm_eeprom_write);
478
479/* 468/*
480 * MSP430 supports RTC, card detection, input from IR remote, and 469 * MSP430 supports RTC, card detection, input from IR remote, and
481 * a bit more. It triggers interrupts on GPIO(7) from pressing 470 * a bit more. It triggers interrupts on GPIO(7) from pressing
@@ -697,6 +686,8 @@ static __init void davinci_evm_init(void)
697 686
698 davinci_serial_init(&uart_config); 687 davinci_serial_init(&uart_config);
699 688
689 dm644x_init_emac(&dm644x_evm_emac_pdata);
690
700 /* Register the fixup for PHY on DaVinci */ 691 /* Register the fixup for PHY on DaVinci */
701 phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK, 692 phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK,
702 davinci_phy_fixup); 693 davinci_phy_fixup);
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index 94cb623b1ec9..aedde3cdb82f 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -45,6 +45,16 @@
45#include <mach/psc.h> 45#include <mach/psc.h>
46#include <mach/serial.h> 46#include <mach/serial.h>
47#include <mach/i2c.h> 47#include <mach/i2c.h>
48#include <mach/mmc.h>
49#include <mach/emac.h>
50
51#define DM646X_EVM_PHY_MASK (0x2)
52#define DM646X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
53
54static struct emac_platform_data dm646x_evm_emac_pdata = {
55 .phy_mask = DM646X_EVM_PHY_MASK,
56 .mdio_max_freq = DM646X_EVM_MDIO_FREQUENCY,
57};
48 58
49static struct davinci_uart_config uart_config __initdata = { 59static struct davinci_uart_config uart_config __initdata = {
50 .enabled_uarts = (1 << 0), 60 .enabled_uarts = (1 << 0),
@@ -196,14 +206,16 @@ static struct memory_accessor *at24_mem_acc;
196 206
197static void at24_setup(struct memory_accessor *mem_acc, void *context) 207static void at24_setup(struct memory_accessor *mem_acc, void *context)
198{ 208{
199 char mac_addr[6]; 209 char mac_addr[ETH_ALEN];
200 210
201 at24_mem_acc = mem_acc; 211 at24_mem_acc = mem_acc;
202 212
203 /* Read MAC addr from EEPROM */ 213 /* Read MAC addr from EEPROM */
204 if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, ETH_ALEN) == 214 if (at24_mem_acc->read(at24_mem_acc, mac_addr, 0x7f00, ETH_ALEN) ==
205 ETH_ALEN) 215 ETH_ALEN) {
206 pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr); 216 pr_info("Read MAC addr from EEPROM: %pM\n", mac_addr);
217 memcpy(dm646x_evm_emac_pdata.mac_addr, mac_addr, ETH_ALEN);
218 }
207} 219}
208 220
209static struct at24_platform_data eeprom_info = { 221static struct at24_platform_data eeprom_info = {
@@ -261,6 +273,7 @@ static __init void evm_init(void)
261{ 273{
262 evm_init_i2c(); 274 evm_init_i2c();
263 davinci_serial_init(&uart_config); 275 davinci_serial_init(&uart_config);
276 dm646x_init_emac(&dm646x_evm_emac_pdata);
264} 277}
265 278
266static __init void davinci_dm646x_evm_irq_init(void) 279static __init void davinci_dm646x_evm_irq_init(void)
diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c
index c6525e43ea33..913dad93540b 100644
--- a/arch/arm/mach-davinci/board-sffsdr.c
+++ b/arch/arm/mach-davinci/board-sffsdr.c
@@ -48,11 +48,15 @@
48 48
49#include <mach/dm644x.h> 49#include <mach/dm644x.h>
50#include <mach/common.h> 50#include <mach/common.h>
51#include <mach/emac.h>
51#include <mach/i2c.h> 52#include <mach/i2c.h>
52#include <mach/serial.h> 53#include <mach/serial.h>
53#include <mach/psc.h> 54#include <mach/psc.h>
54#include <mach/mux.h> 55#include <mach/mux.h>
55 56
57#define SFFSDR_PHY_MASK (0x2)
58#define SFFSDR_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
59
56#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000 60#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e00000
57#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000 61#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
58 62
@@ -104,8 +108,10 @@ static struct platform_device davinci_sffsdr_nandflash_device = {
104 .resource = davinci_sffsdr_nandflash_resource, 108 .resource = davinci_sffsdr_nandflash_resource,
105}; 109};
106 110
107/* Get Ethernet address from kernel boot params */ 111static struct emac_platform_data sffsdr_emac_pdata = {
108static u8 mac_addr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 112 .phy_mask = SFFSDR_PHY_MASK,
113 .mdio_max_freq = SFFSDR_MDIO_FREQUENCY,
114};
109 115
110static struct at24_platform_data eeprom_info = { 116static struct at24_platform_data eeprom_info = {
111 .byte_len = (64*1024) / 8, 117 .byte_len = (64*1024) / 8,
@@ -156,6 +162,7 @@ static __init void davinci_sffsdr_init(void)
156 ARRAY_SIZE(davinci_sffsdr_devices)); 162 ARRAY_SIZE(davinci_sffsdr_devices));
157 sffsdr_init_i2c(); 163 sffsdr_init_i2c();
158 davinci_serial_init(&uart_config); 164 davinci_serial_init(&uart_config);
165 dm644x_init_emac(&sffsdr_emac_pdata);
159 setup_usb(0, 0); /* We support only peripheral mode. */ 166 setup_usb(0, 0); /* We support only peripheral mode. */
160 167
161 /* mux VLYNQ pins */ 168 /* mux VLYNQ pins */
diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c
index d428ef192eac..0419d571bdca 100644
--- a/arch/arm/mach-davinci/dm644x.c
+++ b/arch/arm/mach-davinci/dm644x.c
@@ -444,6 +444,25 @@ static struct platform_device dm644x_edma_device = {
444}; 444};
445 445
446/*----------------------------------------------------------------------*/ 446/*----------------------------------------------------------------------*/
447#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
448
449void dm644x_init_emac(struct emac_platform_data *pdata)
450{
451 pdata->ctrl_reg_offset = DM644X_EMAC_CNTRL_OFFSET;
452 pdata->ctrl_mod_reg_offset = DM644X_EMAC_CNTRL_MOD_OFFSET;
453 pdata->ctrl_ram_offset = DM644X_EMAC_CNTRL_RAM_OFFSET;
454 pdata->mdio_reg_offset = DM644X_EMAC_MDIO_OFFSET;
455 pdata->ctrl_ram_size = DM644X_EMAC_CNTRL_RAM_SIZE;
456 pdata->version = EMAC_VERSION_1;
457 dm644x_emac_device.dev.platform_data = pdata;
458 platform_device_register(&dm644x_emac_device);
459}
460#else
461
462void dm644x_init_emac(struct emac_platform_data *unused) {}
463
464#endif
465
447void __init dm644x_init(void) 466void __init dm644x_init(void)
448{ 467{
449 davinci_clk_init(dm644x_clks); 468 davinci_clk_init(dm644x_clks);
diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c
index 93443a6637ea..975ed062ce24 100644
--- a/arch/arm/mach-davinci/dm646x.c
+++ b/arch/arm/mach-davinci/dm646x.c
@@ -279,6 +279,44 @@ struct davinci_clk dm646x_clks[] = {
279 CLK(NULL, NULL, NULL), 279 CLK(NULL, NULL, NULL),
280}; 280};
281 281
282#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
283static struct resource dm646x_emac_resources[] = {
284 {
285 .start = DM646X_EMAC_BASE,
286 .end = DM646X_EMAC_BASE + 0x47ff,
287 .flags = IORESOURCE_MEM,
288 },
289 {
290 .start = IRQ_DM646X_EMACRXTHINT,
291 .end = IRQ_DM646X_EMACRXTHINT,
292 .flags = IORESOURCE_IRQ,
293 },
294 {
295 .start = IRQ_DM646X_EMACRXINT,
296 .end = IRQ_DM646X_EMACRXINT,
297 .flags = IORESOURCE_IRQ,
298 },
299 {
300 .start = IRQ_DM646X_EMACTXINT,
301 .end = IRQ_DM646X_EMACTXINT,
302 .flags = IORESOURCE_IRQ,
303 },
304 {
305 .start = IRQ_DM646X_EMACMISCINT,
306 .end = IRQ_DM646X_EMACMISCINT,
307 .flags = IORESOURCE_IRQ,
308 },
309};
310
311static struct platform_device dm646x_emac_device = {
312 .name = "davinci_emac",
313 .id = 1,
314 .num_resources = ARRAY_SIZE(dm646x_emac_resources),
315 .resource = dm646x_emac_resources,
316};
317
318#endif
319
282/* 320/*
283 * Device specific mux setup 321 * Device specific mux setup
284 * 322 *
@@ -385,6 +423,25 @@ static struct platform_device dm646x_edma_device = {
385 423
386/*----------------------------------------------------------------------*/ 424/*----------------------------------------------------------------------*/
387 425
426#if defined(CONFIG_TI_DAVINCI_EMAC) || defined(CONFIG_TI_DAVINCI_EMAC_MODULE)
427
428void dm646x_init_emac(struct emac_platform_data *pdata)
429{
430 pdata->ctrl_reg_offset = DM646X_EMAC_CNTRL_OFFSET;
431 pdata->ctrl_mod_reg_offset = DM646X_EMAC_CNTRL_MOD_OFFSET;
432 pdata->ctrl_ram_offset = DM646X_EMAC_CNTRL_RAM_OFFSET;
433 pdata->mdio_reg_offset = DM646X_EMAC_MDIO_OFFSET;
434 pdata->ctrl_ram_size = DM646X_EMAC_CNTRL_RAM_SIZE;
435 pdata->version = EMAC_VERSION_2;
436 dm646x_emac_device.dev.platform_data = pdata;
437 platform_device_register(&dm646x_emac_device);
438}
439#else
440
441void dm646x_init_emac(struct emac_platform_data *unused) {}
442
443#endif
444
388void __init dm646x_init(void) 445void __init dm646x_init(void)
389{ 446{
390 davinci_clk_init(dm646x_clks); 447 davinci_clk_init(dm646x_clks);
diff --git a/arch/arm/mach-davinci/include/mach/dm644x.h b/arch/arm/mach-davinci/include/mach/dm644x.h
index 3dcb9f4e58b4..ace167aec460 100644
--- a/arch/arm/mach-davinci/include/mach/dm644x.h
+++ b/arch/arm/mach-davinci/include/mach/dm644x.h
@@ -24,6 +24,7 @@
24 24
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <mach/hardware.h> 26#include <mach/hardware.h>
27#include <mach/emac.h>
27 28
28#define DM644X_EMAC_BASE (0x01C80000) 29#define DM644X_EMAC_BASE (0x01C80000)
29#define DM644X_EMAC_CNTRL_OFFSET (0x0000) 30#define DM644X_EMAC_CNTRL_OFFSET (0x0000)
@@ -33,5 +34,6 @@
33#define DM644X_EMAC_CNTRL_RAM_SIZE (0x2000) 34#define DM644X_EMAC_CNTRL_RAM_SIZE (0x2000)
34 35
35void __init dm644x_init(void); 36void __init dm644x_init(void);
37void dm644x_init_emac(struct emac_platform_data *pdata);
36 38
37#endif /* __ASM_ARCH_DM644X_H */ 39#endif /* __ASM_ARCH_DM644X_H */
diff --git a/arch/arm/mach-davinci/include/mach/dm646x.h b/arch/arm/mach-davinci/include/mach/dm646x.h
index d917939af158..ea7b28e112f6 100644
--- a/arch/arm/mach-davinci/include/mach/dm646x.h
+++ b/arch/arm/mach-davinci/include/mach/dm646x.h
@@ -12,7 +12,16 @@
12#define __ASM_ARCH_DM646X_H 12#define __ASM_ARCH_DM646X_H
13 13
14#include <mach/hardware.h> 14#include <mach/hardware.h>
15#include <mach/emac.h>
16
17#define DM646X_EMAC_BASE (0x01C80000)
18#define DM646X_EMAC_CNTRL_OFFSET (0x0000)
19#define DM646X_EMAC_CNTRL_MOD_OFFSET (0x1000)
20#define DM646X_EMAC_CNTRL_RAM_OFFSET (0x2000)
21#define DM646X_EMAC_MDIO_OFFSET (0x4000)
22#define DM646X_EMAC_CNTRL_RAM_SIZE (0x2000)
15 23
16void __init dm646x_init(void); 24void __init dm646x_init(void);
25void dm646x_init_emac(struct emac_platform_data *pdata);
17 26
18#endif /* __ASM_ARCH_DM646X_H */ 27#endif /* __ASM_ARCH_DM646X_H */
diff --git a/arch/arm/mach-davinci/include/mach/emac.h b/arch/arm/mach-davinci/include/mach/emac.h
new file mode 100644
index 000000000000..549fcced2175
--- /dev/null
+++ b/arch/arm/mach-davinci/include/mach/emac.h
@@ -0,0 +1,36 @@
1/*
2 * TI DaVinci EMAC platform support
3 *
4 * Author: Kevin Hilman, Deep Root Systems, LLC
5 *
6 * 2007 (c) Deep Root Systems, LLC. This file is licensed under
7 * the terms of the GNU General Public License version 2. This program
8 * is licensed "as is" without any warranty of any kind, whether express
9 * or implied.
10 */
11#ifndef _MACH_DAVINCI_EMAC_H
12#define _MACH_DAVINCI_EMAC_H
13
14#include <linux/if_ether.h>
15
16struct emac_platform_data {
17 char mac_addr[ETH_ALEN];
18 u32 ctrl_reg_offset;
19 u32 ctrl_mod_reg_offset;
20 u32 ctrl_ram_offset;
21 u32 mdio_reg_offset;
22 u32 ctrl_ram_size;
23 u32 phy_mask;
24 u32 mdio_max_freq;
25 u8 rmii_en;
26 u8 version;
27};
28
29enum {
30 EMAC_VERSION_1, /* DM644x */
31 EMAC_VERSION_2, /* DM646x */
32};
33void davinci_init_emac(struct emac_platform_data *pdata);
34#endif
35
36