aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/board-rx51-peripherals.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/board-rx51-peripherals.c')
-rw-r--r--arch/arm/mach-omap2/board-rx51-peripherals.c204
1 files changed, 87 insertions, 117 deletions
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index a7381729645c..233c7454d84f 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -27,31 +27,11 @@
27#include <mach/dma.h> 27#include <mach/dma.h>
28#include <mach/gpmc.h> 28#include <mach/gpmc.h>
29#include <mach/keypad.h> 29#include <mach/keypad.h>
30#include <mach/onenand.h>
31#include <mach/gpmc-smc91x.h>
30 32
31#include "mmc-twl4030.h" 33#include "mmc-twl4030.h"
32 34
33
34#define SMC91X_CS 1
35#define SMC91X_GPIO_IRQ 54
36#define SMC91X_GPIO_RESET 164
37#define SMC91X_GPIO_PWRDWN 86
38
39static struct resource rx51_smc91x_resources[] = {
40 [0] = {
41 .flags = IORESOURCE_MEM,
42 },
43 [1] = {
44 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
45 },
46};
47
48static struct platform_device rx51_smc91x_device = {
49 .name = "smc91x",
50 .id = -1,
51 .num_resources = ARRAY_SIZE(rx51_smc91x_resources),
52 .resource = rx51_smc91x_resources,
53};
54
55static int rx51_keymap[] = { 35static int rx51_keymap[] = {
56 KEY(0, 0, KEY_Q), 36 KEY(0, 0, KEY_Q),
57 KEY(0, 1, KEY_W), 37 KEY(0, 1, KEY_W),
@@ -107,98 +87,6 @@ static struct twl4030_keypad_data rx51_kp_data = {
107 .rep = 1, 87 .rep = 1,
108}; 88};
109 89
110static struct platform_device *rx51_peripherals_devices[] = {
111 &rx51_smc91x_device,
112};
113
114/*
115 * Timings are taken from smsc-lan91c96-ms.pdf
116 */
117static int smc91x_init_gpmc(int cs)
118{
119 struct gpmc_timings t;
120 const int t2_r = 45; /* t2 in Figure 12.10 */
121 const int t2_w = 30; /* t2 in Figure 12.11 */
122 const int t3 = 15; /* t3 in Figure 12.10 */
123 const int t5_r = 0; /* t5 in Figure 12.10 */
124 const int t6_r = 45; /* t6 in Figure 12.10 */
125 const int t6_w = 0; /* t6 in Figure 12.11 */
126 const int t7_w = 15; /* t7 in Figure 12.11 */
127 const int t15 = 12; /* t15 in Figure 12.2 */
128 const int t20 = 185; /* t20 in Figure 12.2 */
129
130 memset(&t, 0, sizeof(t));
131
132 t.cs_on = t15;
133 t.cs_rd_off = t3 + t2_r + t5_r; /* Figure 12.10 */
134 t.cs_wr_off = t3 + t2_w + t6_w; /* Figure 12.11 */
135 t.adv_on = t3; /* Figure 12.10 */
136 t.adv_rd_off = t3 + t2_r; /* Figure 12.10 */
137 t.adv_wr_off = t3 + t2_w; /* Figure 12.11 */
138 t.oe_off = t3 + t2_r + t5_r; /* Figure 12.10 */
139 t.oe_on = t.oe_off - t6_r; /* Figure 12.10 */
140 t.we_off = t3 + t2_w + t6_w; /* Figure 12.11 */
141 t.we_on = t.we_off - t7_w; /* Figure 12.11 */
142 t.rd_cycle = t20; /* Figure 12.2 */
143 t.wr_cycle = t20; /* Figure 12.4 */
144 t.access = t3 + t2_r + t5_r; /* Figure 12.10 */
145 t.wr_access = t3 + t2_w + t6_w; /* Figure 12.11 */
146
147 gpmc_cs_write_reg(cs, GPMC_CS_CONFIG1, GPMC_CONFIG1_DEVICESIZE_16);
148
149 return gpmc_cs_set_timings(cs, &t);
150}
151
152static void __init rx51_init_smc91x(void)
153{
154 unsigned long cs_mem_base;
155 int ret;
156
157 omap_cfg_reg(U8_34XX_GPIO54_DOWN);
158 omap_cfg_reg(G25_34XX_GPIO86_OUT);
159 omap_cfg_reg(H19_34XX_GPIO164_OUT);
160
161 if (gpmc_cs_request(SMC91X_CS, SZ_16M, &cs_mem_base) < 0) {
162 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
163 return;
164 }
165
166 rx51_smc91x_resources[0].start = cs_mem_base + 0x300;
167 rx51_smc91x_resources[0].end = cs_mem_base + 0x30f;
168
169 smc91x_init_gpmc(SMC91X_CS);
170
171 if (gpio_request(SMC91X_GPIO_IRQ, "SMC91X irq") < 0)
172 goto free1;
173
174 gpio_direction_input(SMC91X_GPIO_IRQ);
175 rx51_smc91x_resources[1].start = gpio_to_irq(SMC91X_GPIO_IRQ);
176
177 ret = gpio_request(SMC91X_GPIO_PWRDWN, "SMC91X powerdown");
178 if (ret)
179 goto free2;
180 gpio_direction_output(SMC91X_GPIO_PWRDWN, 0);
181
182 ret = gpio_request(SMC91X_GPIO_RESET, "SMC91X reset");
183 if (ret)
184 goto free3;
185 gpio_direction_output(SMC91X_GPIO_RESET, 0);
186 gpio_set_value(SMC91X_GPIO_RESET, 1);
187 msleep(100);
188 gpio_set_value(SMC91X_GPIO_RESET, 0);
189
190 return;
191
192free3:
193 gpio_free(SMC91X_GPIO_PWRDWN);
194free2:
195 gpio_free(SMC91X_GPIO_IRQ);
196free1:
197 gpmc_cs_free(SMC91X_CS);
198
199 printk(KERN_ERR "Could not initialize smc91x\n");
200}
201
202static struct twl4030_madc_platform_data rx51_madc_data = { 90static struct twl4030_madc_platform_data rx51_madc_data = {
203 .irq_line = 1, 91 .irq_line = 1,
204}; 92};
@@ -408,12 +296,94 @@ static int __init rx51_i2c_init(void)
408 return 0; 296 return 0;
409} 297}
410 298
299#if defined(CONFIG_MTD_ONENAND_OMAP2) || \
300 defined(CONFIG_MTD_ONENAND_OMAP2_MODULE)
301
302static struct mtd_partition onenand_partitions[] = {
303 {
304 .name = "bootloader",
305 .offset = 0,
306 .size = 0x20000,
307 .mask_flags = MTD_WRITEABLE, /* Force read-only */
308 },
309 {
310 .name = "config",
311 .offset = MTDPART_OFS_APPEND,
312 .size = 0x60000,
313 },
314 {
315 .name = "log",
316 .offset = MTDPART_OFS_APPEND,
317 .size = 0x40000,
318 },
319 {
320 .name = "kernel",
321 .offset = MTDPART_OFS_APPEND,
322 .size = 0x200000,
323 },
324 {
325 .name = "initfs",
326 .offset = MTDPART_OFS_APPEND,
327 .size = 0x200000,
328 },
329 {
330 .name = "rootfs",
331 .offset = MTDPART_OFS_APPEND,
332 .size = MTDPART_SIZ_FULL,
333 },
334};
335
336static struct omap_onenand_platform_data board_onenand_data = {
337 .cs = 0,
338 .gpio_irq = 65,
339 .parts = onenand_partitions,
340 .nr_parts = ARRAY_SIZE(onenand_partitions),
341};
342
343static void __init board_onenand_init(void)
344{
345 gpmc_onenand_init(&board_onenand_data);
346}
347
348#else
349
350static inline void board_onenand_init(void)
351{
352}
353
354#endif
355
356#if defined(CONFIG_SMC91X) || defined(CONFIG_SMC91X_MODULE)
357
358static struct omap_smc91x_platform_data board_smc91x_data = {
359 .cs = 1,
360 .gpio_irq = 54,
361 .gpio_pwrdwn = 86,
362 .gpio_reset = 164,
363 .flags = GPMC_TIMINGS_SMC91C96 | IORESOURCE_IRQ_HIGHLEVEL,
364};
365
366static void __init board_smc91x_init(void)
367{
368 omap_cfg_reg(U8_34XX_GPIO54_DOWN);
369 omap_cfg_reg(G25_34XX_GPIO86_OUT);
370 omap_cfg_reg(H19_34XX_GPIO164_OUT);
371
372 gpmc_smc91x_init(&board_smc91x_data);
373}
374
375#else
376
377static inline void board_smc91x_init(void)
378{
379}
380
381#endif
411 382
412void __init rx51_peripherals_init(void) 383void __init rx51_peripherals_init(void)
413{ 384{
414 platform_add_devices(rx51_peripherals_devices,
415 ARRAY_SIZE(rx51_peripherals_devices));
416 rx51_i2c_init(); 385 rx51_i2c_init();
417 rx51_init_smc91x(); 386 board_onenand_init();
387 board_smc91x_init();
418} 388}
419 389