diff options
author | Tim Nordell <tim.nordell@logicpd.com> | 2010-09-27 12:05:49 -0400 |
---|---|---|
committer | Tony Lindgren <tony@atomide.com> | 2010-09-28 14:39:18 -0400 |
commit | cdd280b9958d71ccbaf7c00c0d63dab0a48c1db0 (patch) | |
tree | a38184e415d1f8bb09754f05566ade46dfb093da /arch/arm | |
parent | 8430281b0a909048cc0e38756b11ae309bb783cd (diff) |
ARM: OMAP3LOGIC: Add generic smsc911x support when connected to GPMC
Introduce of a generic way to setup smsc911x based Ethernet
controller connected to GPMC similar to gpmc-smc91x but without
timing setup.
Signed-off-by: Tim Nordell <tim.nordell@logicpd.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-omap2/Makefile | 3 | ||||
-rw-r--r-- | arch/arm/mach-omap2/gpmc-smsc911x.c | 113 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/plat/gpmc-smsc911x.h | 35 |
3 files changed, 151 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index 1c525a8b9c5f..9edacb0ab035 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile | |||
@@ -184,3 +184,6 @@ obj-y += $(nand-m) $(nand-y) | |||
184 | 184 | ||
185 | smc91x-$(CONFIG_SMC91X) := gpmc-smc91x.o | 185 | smc91x-$(CONFIG_SMC91X) := gpmc-smc91x.o |
186 | obj-y += $(smc91x-m) $(smc91x-y) | 186 | obj-y += $(smc91x-m) $(smc91x-y) |
187 | |||
188 | smsc911x-$(CONFIG_SMSC911X) := gpmc-smsc911x.o | ||
189 | obj-y += $(smsc911x-m) $(smsc911x-y) | ||
diff --git a/arch/arm/mach-omap2/gpmc-smsc911x.c b/arch/arm/mach-omap2/gpmc-smsc911x.c new file mode 100644 index 000000000000..703f150dd01d --- /dev/null +++ b/arch/arm/mach-omap2/gpmc-smsc911x.c | |||
@@ -0,0 +1,113 @@ | |||
1 | /* | ||
2 | * linux/arch/arm/mach-omap2/gpmc-smsc911x.c | ||
3 | * | ||
4 | * Copyright (C) 2009 Li-Pro.Net | ||
5 | * Stephan Linz <linz@li-pro.net> | ||
6 | * | ||
7 | * Modified from linux/arch/arm/mach-omap2/gpmc-smc91x.c | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/platform_device.h> | ||
16 | #include <linux/gpio.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/interrupt.h> | ||
19 | #include <linux/io.h> | ||
20 | #include <linux/smsc911x.h> | ||
21 | |||
22 | #include <plat/board.h> | ||
23 | #include <plat/gpmc.h> | ||
24 | #include <plat/gpmc-smsc911x.h> | ||
25 | |||
26 | static struct omap_smsc911x_platform_data *gpmc_cfg; | ||
27 | |||
28 | static struct resource gpmc_smsc911x_resources[] = { | ||
29 | [0] = { | ||
30 | .flags = IORESOURCE_MEM, | ||
31 | }, | ||
32 | [1] = { | ||
33 | .flags = IORESOURCE_IRQ, | ||
34 | }, | ||
35 | }; | ||
36 | |||
37 | static struct smsc911x_platform_config gpmc_smsc911x_config = { | ||
38 | .phy_interface = PHY_INTERFACE_MODE_MII, | ||
39 | .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW, | ||
40 | .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN, | ||
41 | .flags = SMSC911X_USE_16BIT, | ||
42 | }; | ||
43 | |||
44 | static struct platform_device gpmc_smsc911x_device = { | ||
45 | .name = "smsc911x", | ||
46 | .id = -1, | ||
47 | .num_resources = ARRAY_SIZE(gpmc_smsc911x_resources), | ||
48 | .resource = gpmc_smsc911x_resources, | ||
49 | .dev = { | ||
50 | .platform_data = &gpmc_smsc911x_config, | ||
51 | }, | ||
52 | }; | ||
53 | |||
54 | /* | ||
55 | * Initialize smsc911x device connected to the GPMC. Note that we | ||
56 | * assume that pin multiplexing is done in the board-*.c file, | ||
57 | * or in the bootloader. | ||
58 | */ | ||
59 | void __init gpmc_smsc911x_init(struct omap_smsc911x_platform_data *board_data) | ||
60 | { | ||
61 | unsigned long cs_mem_base; | ||
62 | int ret; | ||
63 | |||
64 | gpmc_cfg = board_data; | ||
65 | |||
66 | if (gpmc_cs_request(gpmc_cfg->cs, SZ_16M, &cs_mem_base) < 0) { | ||
67 | printk(KERN_ERR "Failed to request GPMC mem for smsc911x\n"); | ||
68 | return; | ||
69 | } | ||
70 | |||
71 | gpmc_smsc911x_resources[0].start = cs_mem_base + 0x0; | ||
72 | gpmc_smsc911x_resources[0].end = cs_mem_base + 0xff; | ||
73 | |||
74 | if (gpio_request(gpmc_cfg->gpio_irq, "smsc911x irq") < 0) { | ||
75 | printk(KERN_ERR "Failed to request GPIO%d for smsc911x IRQ\n", | ||
76 | gpmc_cfg->gpio_irq); | ||
77 | goto free1; | ||
78 | } | ||
79 | |||
80 | gpio_direction_input(gpmc_cfg->gpio_irq); | ||
81 | gpmc_smsc911x_resources[1].start = gpio_to_irq(gpmc_cfg->gpio_irq); | ||
82 | gpmc_smsc911x_resources[1].flags |= | ||
83 | (gpmc_cfg->flags & IRQF_TRIGGER_MASK); | ||
84 | |||
85 | if (gpio_is_valid(gpmc_cfg->gpio_reset)) { | ||
86 | ret = gpio_request(gpmc_cfg->gpio_reset, "smsc911x reset"); | ||
87 | if (ret) { | ||
88 | printk(KERN_ERR "Failed to request GPIO%d for smsc911x reset\n", | ||
89 | gpmc_cfg->gpio_reset); | ||
90 | goto free2; | ||
91 | } | ||
92 | |||
93 | gpio_direction_output(gpmc_cfg->gpio_reset, 1); | ||
94 | gpio_set_value(gpmc_cfg->gpio_reset, 0); | ||
95 | msleep(100); | ||
96 | gpio_set_value(gpmc_cfg->gpio_reset, 1); | ||
97 | } | ||
98 | |||
99 | if (platform_device_register(&gpmc_smsc911x_device) < 0) { | ||
100 | printk(KERN_ERR "Unable to register smsc911x device\n"); | ||
101 | gpio_free(gpmc_cfg->gpio_reset); | ||
102 | goto free2; | ||
103 | } | ||
104 | |||
105 | return; | ||
106 | |||
107 | free2: | ||
108 | gpio_free(gpmc_cfg->gpio_irq); | ||
109 | free1: | ||
110 | gpmc_cs_free(gpmc_cfg->cs); | ||
111 | |||
112 | printk(KERN_ERR "Could not initialize smsc911x\n"); | ||
113 | } | ||
diff --git a/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h b/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h new file mode 100644 index 000000000000..872de0bf1e6b --- /dev/null +++ b/arch/arm/plat-omap/include/plat/gpmc-smsc911x.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-omap/include/plat/gpmc-smsc911x.h | ||
3 | * | ||
4 | * Copyright (C) 2009 Li-Pro.Net | ||
5 | * Stephan Linz <linz@li-pro.net> | ||
6 | * | ||
7 | * Modified from arch/arm/plat-omap/include/plat/gpmc-smc91x.h | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License version 2 as | ||
11 | * published by the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #ifndef __ASM_ARCH_OMAP_GPMC_SMSC911X_H__ | ||
15 | |||
16 | struct omap_smsc911x_platform_data { | ||
17 | int cs; | ||
18 | int gpio_irq; | ||
19 | int gpio_reset; | ||
20 | u32 flags; | ||
21 | }; | ||
22 | |||
23 | #if defined(CONFIG_SMSC911X) || \ | ||
24 | defined(CONFIG_SMSC911X_MODULE) | ||
25 | |||
26 | extern void gpmc_smsc911x_init(struct omap_smsc911x_platform_data *d); | ||
27 | |||
28 | #else | ||
29 | |||
30 | static inline void gpmc_smsc911x_init(struct omap_smsc911x_platform_data *d) | ||
31 | { | ||
32 | } | ||
33 | |||
34 | #endif | ||
35 | #endif | ||