aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/board-2430sdp.c
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2009-05-28 16:23:52 -0400
committerTony Lindgren <tony@atomide.com>2009-05-28 16:23:52 -0400
commit1a48e1575188d4023b3428b623caeefe8c599e79 (patch)
tree50bdac2821ab3c9f769c204cd15bc303f08d6670 /arch/arm/mach-omap2/board-2430sdp.c
parentaa62e90fe0700c037675926fff9f75b0b1c00d78 (diff)
ARM: OMAP2/3: Add generic smc91x support when connected to GPMC
Convert the board-rx51 smc91x code to be generic and make the boards to use it. This allows future recalculation of the timings when the source clock gets scaled. Also correct the rx51 interrupt to be IORESOURCE_IRQ_HIGHLEVEL. Thanks to Paul Walmsley <paul@pwsan.com> for better GPMC timing calculations. Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/board-2430sdp.c')
-rw-r--r--arch/arm/mach-omap2/board-2430sdp.c103
1 files changed, 22 insertions, 81 deletions
diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index 22143651037..ef70b79942c 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -36,14 +36,11 @@
36#include <mach/common.h> 36#include <mach/common.h>
37#include <mach/gpmc.h> 37#include <mach/gpmc.h>
38#include <mach/usb.h> 38#include <mach/usb.h>
39#include <mach/gpmc-smc91x.h>
39 40
40#include "mmc-twl4030.h" 41#include "mmc-twl4030.h"
41 42
42#define SDP2430_CS0_BASE 0x04000000 43#define SDP2430_CS0_BASE 0x04000000
43#define SDP2430_FLASH_CS 0
44#define SDP2430_SMC91X_CS 5
45
46#define SDP2430_ETHR_GPIO_IRQ 149
47 44
48static struct mtd_partition sdp2430_partitions[] = { 45static struct mtd_partition sdp2430_partitions[] = {
49 /* bootloader (U-Boot, etc) in first sector */ 46 /* bootloader (U-Boot, etc) in first sector */
@@ -99,100 +96,43 @@ static struct platform_device sdp2430_flash_device = {
99 .resource = &sdp2430_flash_resource, 96 .resource = &sdp2430_flash_resource,
100}; 97};
101 98
102static struct resource sdp2430_smc91x_resources[] = {
103 [0] = {
104 .start = SDP2430_CS0_BASE,
105 .end = SDP2430_CS0_BASE + SZ_64M - 1,
106 .flags = IORESOURCE_MEM,
107 },
108 [1] = {
109 .start = OMAP_GPIO_IRQ(SDP2430_ETHR_GPIO_IRQ),
110 .end = OMAP_GPIO_IRQ(SDP2430_ETHR_GPIO_IRQ),
111 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWLEVEL,
112 },
113};
114
115static struct platform_device sdp2430_smc91x_device = {
116 .name = "smc91x",
117 .id = -1,
118 .num_resources = ARRAY_SIZE(sdp2430_smc91x_resources),
119 .resource = sdp2430_smc91x_resources,
120};
121
122static struct platform_device *sdp2430_devices[] __initdata = { 99static struct platform_device *sdp2430_devices[] __initdata = {
123 &sdp2430_smc91x_device,
124 &sdp2430_flash_device, 100 &sdp2430_flash_device,
125}; 101};
126 102
127static inline void __init sdp2430_init_smc91x(void) 103#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91x_MODULE)
128{
129 int eth_cs;
130 unsigned long cs_mem_base;
131 unsigned int rate;
132 struct clk *gpmc_fck;
133
134 eth_cs = SDP2430_SMC91X_CS;
135 104
136 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */ 105static struct omap_smc91x_platform_data board_smc91x_data = {
137 if (IS_ERR(gpmc_fck)) { 106 .cs = 5,
138 WARN_ON(1); 107 .gpio_irq = 149,
139 return; 108 .flags = GPMC_MUX_ADD_DATA | GPMC_TIMINGS_SMC91C96 |
140 } 109 IORESOURCE_IRQ_LOWLEVEL,
141 110
142 clk_enable(gpmc_fck); 111};
143 rate = clk_get_rate(gpmc_fck);
144
145 /* Make sure CS1 timings are correct, for 2430 always muxed */
146 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
147
148 if (rate >= 160000000) {
149 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
150 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
151 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
152 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
153 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
154 } else if (rate >= 130000000) {
155 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
156 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
157 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
158 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
159 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
160 } else { /* rate = 100000000 */
161 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
162 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
163 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
164 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
165 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
166 }
167 112
168 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) { 113static void __init board_smc91x_init(void)
169 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n"); 114{
170 goto out; 115 if (omap_rev() > OMAP3430_REV_ES1_0)
171 } 116 board_smc91x_data.gpio_irq = 6;
117 else
118 board_smc91x_data.gpio_irq = 29;
172 119
173 sdp2430_smc91x_resources[0].start = cs_mem_base + 0x300; 120 gpmc_smc91x_init(&board_smc91x_data);
174 sdp2430_smc91x_resources[0].end = cs_mem_base + 0x30f; 121}
175 udelay(100);
176 122
177 if (gpio_request(SDP2430_ETHR_GPIO_IRQ, "SMC91x irq") < 0) { 123#else
178 printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
179 SDP2430_ETHR_GPIO_IRQ);
180 gpmc_cs_free(eth_cs);
181 goto out;
182 }
183 gpio_direction_input(SDP2430_ETHR_GPIO_IRQ);
184 124
185out: 125static inline void board_smc91x_init(void)
186 clk_disable(gpmc_fck); 126{
187 clk_put(gpmc_fck);
188} 127}
189 128
129#endif
130
190static void __init omap_2430sdp_init_irq(void) 131static void __init omap_2430sdp_init_irq(void)
191{ 132{
192 omap2_init_common_hw(NULL); 133 omap2_init_common_hw(NULL);
193 omap_init_irq(); 134 omap_init_irq();
194 omap_gpio_init(); 135 omap_gpio_init();
195 sdp2430_init_smc91x();
196} 136}
197 137
198static struct omap_uart_config sdp2430_uart_config __initdata = { 138static struct omap_uart_config sdp2430_uart_config __initdata = {
@@ -256,6 +196,7 @@ static void __init omap_2430sdp_init(void)
256 omap_serial_init(); 196 omap_serial_init();
257 twl4030_mmc_init(mmc); 197 twl4030_mmc_init(mmc);
258 usb_musb_init(); 198 usb_musb_init();
199 board_smc91x_init();
259} 200}
260 201
261static void __init omap_2430sdp_map_io(void) 202static void __init omap_2430sdp_map_io(void)