omap: Beagle: no gpio_wp pin connection on xM
[deliverable/linux.git] / arch / arm / mach-omap2 / board-omap3beagle.c
CommitLineData
2885f000
SMK
1/*
2 * linux/arch/arm/mach-omap2/board-omap3beagle.c
3 *
4 * Copyright (C) 2008 Texas Instruments
5 *
6 * Modified from mach-omap2/board-3430sdp.c
7 *
8 * Initial code: Syed Mohammed Khasim
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/platform_device.h>
18#include <linux/delay.h>
19#include <linux/err.h>
20#include <linux/clk.h>
21#include <linux/io.h>
22#include <linux/leds.h>
23#include <linux/gpio.h>
24#include <linux/input.h>
25#include <linux/gpio_keys.h>
26
27#include <linux/mtd/mtd.h>
28#include <linux/mtd/partitions.h>
29#include <linux/mtd/nand.h>
30
bb3b9d8e 31#include <linux/regulator/machine.h>
b07682b6 32#include <linux/i2c/twl.h>
145d9c94 33
2885f000
SMK
34#include <mach/hardware.h>
35#include <asm/mach-types.h>
36#include <asm/mach/arch.h>
37#include <asm/mach/map.h>
38#include <asm/mach/flash.h>
39
ce491cf8
TL
40#include <plat/board.h>
41#include <plat/common.h>
044d32ff 42#include <plat/display.h>
ce491cf8
TL
43#include <plat/gpmc.h>
44#include <plat/nand.h>
ce491cf8
TL
45#include <plat/usb.h>
46#include <plat/timer-gp.h>
2885f000 47
ca5742bd 48#include "mux.h"
d02a900b 49#include "hsmmc.h"
2885f000 50
2885f000
SMK
51#define NAND_BLOCK_SIZE SZ_128K
52
954bed04
RN
53/*
54 * OMAP3 Beagle revision
55 * Run time detection of Beagle revision is done by reading GPIO.
56 * GPIO ID -
57 * AXBX = GPIO173, GPIO172, GPIO171: 1 1 1
58 * C1_3 = GPIO173, GPIO172, GPIO171: 1 1 0
59 * C4 = GPIO173, GPIO172, GPIO171: 1 0 1
60 * XM = GPIO173, GPIO172, GPIO171: 0 0 0
61 */
62enum {
63 OMAP3BEAGLE_BOARD_UNKN = 0,
64 OMAP3BEAGLE_BOARD_AXBX,
65 OMAP3BEAGLE_BOARD_C1_3,
66 OMAP3BEAGLE_BOARD_C4,
67 OMAP3BEAGLE_BOARD_XM,
68};
69
70static u8 omap3_beagle_version;
71
72static u8 omap3_beagle_get_rev(void)
73{
74 return omap3_beagle_version;
75}
76
77static void __init omap3_beagle_init_rev(void)
78{
79 int ret;
80 u16 beagle_rev = 0;
81
82 omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
83 omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
84 omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
85
86 ret = gpio_request(171, "rev_id_0");
87 if (ret < 0)
88 goto fail0;
89
90 ret = gpio_request(172, "rev_id_1");
91 if (ret < 0)
92 goto fail1;
93
94 ret = gpio_request(173, "rev_id_2");
95 if (ret < 0)
96 goto fail2;
97
98 gpio_direction_input(171);
99 gpio_direction_input(172);
100 gpio_direction_input(173);
101
102 beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
103 | (gpio_get_value(173) << 2);
104
105 switch (beagle_rev) {
106 case 7:
107 printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
108 omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
109 break;
110 case 6:
111 printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
112 omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
113 break;
114 case 5:
115 printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
116 omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
117 break;
118 case 0:
119 printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
120 omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
121 break;
122 default:
123 printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
124 omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
125 }
126
127 return;
128
129fail2:
130 gpio_free(172);
131fail1:
132 gpio_free(171);
133fail0:
134 printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
135 omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
136
137 return;
138}
139
2885f000
SMK
140static struct mtd_partition omap3beagle_nand_partitions[] = {
141 /* All the partition sizes are listed in terms of NAND block size */
142 {
143 .name = "X-Loader",
144 .offset = 0,
145 .size = 4 * NAND_BLOCK_SIZE,
146 .mask_flags = MTD_WRITEABLE, /* force read-only */
147 },
148 {
149 .name = "U-Boot",
150 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
151 .size = 15 * NAND_BLOCK_SIZE,
152 .mask_flags = MTD_WRITEABLE, /* force read-only */
153 },
154 {
155 .name = "U-Boot Env",
156 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
157 .size = 1 * NAND_BLOCK_SIZE,
158 },
159 {
160 .name = "Kernel",
161 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
162 .size = 32 * NAND_BLOCK_SIZE,
163 },
164 {
165 .name = "File System",
166 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
167 .size = MTDPART_SIZ_FULL,
168 },
169};
170
171static struct omap_nand_platform_data omap3beagle_nand_data = {
172 .options = NAND_BUSWIDTH_16,
173 .parts = omap3beagle_nand_partitions,
174 .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions),
175 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
176 .nand_setup = NULL,
177 .dev_ready = NULL,
178};
179
044d32ff
KK
180/* DSS */
181
182static int beagle_enable_dvi(struct omap_dss_device *dssdev)
183{
184 if (gpio_is_valid(dssdev->reset_gpio))
185 gpio_set_value(dssdev->reset_gpio, 1);
186
187 return 0;
188}
189
190static void beagle_disable_dvi(struct omap_dss_device *dssdev)
191{
192 if (gpio_is_valid(dssdev->reset_gpio))
193 gpio_set_value(dssdev->reset_gpio, 0);
194}
195
196static struct omap_dss_device beagle_dvi_device = {
197 .type = OMAP_DISPLAY_TYPE_DPI,
198 .name = "dvi",
199 .driver_name = "generic_panel",
200 .phy.dpi.data_lines = 24,
201 .reset_gpio = 170,
202 .platform_enable = beagle_enable_dvi,
203 .platform_disable = beagle_disable_dvi,
204};
205
206static struct omap_dss_device beagle_tv_device = {
207 .name = "tv",
208 .driver_name = "venc",
209 .type = OMAP_DISPLAY_TYPE_VENC,
210 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
211};
212
213static struct omap_dss_device *beagle_dss_devices[] = {
214 &beagle_dvi_device,
215 &beagle_tv_device,
216};
217
218static struct omap_dss_board_info beagle_dss_data = {
219 .num_devices = ARRAY_SIZE(beagle_dss_devices),
220 .devices = beagle_dss_devices,
221 .default_device = &beagle_dvi_device,
222};
223
224static struct platform_device beagle_dss_device = {
225 .name = "omapdss",
226 .id = -1,
227 .dev = {
228 .platform_data = &beagle_dss_data,
229 },
230};
231
232static struct regulator_consumer_supply beagle_vdac_supply =
233 REGULATOR_SUPPLY("vdda_dac", "omapdss");
234
235static struct regulator_consumer_supply beagle_vdvi_supply =
236 REGULATOR_SUPPLY("vdds_dsi", "omapdss");
237
238static void __init beagle_display_init(void)
239{
240 int r;
241
242 r = gpio_request(beagle_dvi_device.reset_gpio, "DVI reset");
243 if (r < 0) {
244 printk(KERN_ERR "Unable to get DVI reset GPIO\n");
245 return;
246 }
247
248 gpio_direction_output(beagle_dvi_device.reset_gpio, 0);
249}
250
2e12bd7e
PW
251#include "sdram-micron-mt46h32m32lf-6.h"
252
68ff0423 253static struct omap2_hsmmc_info mmc[] = {
90c62bf0
TL
254 {
255 .mmc = 1,
256 .wires = 8,
257 .gpio_wp = 29,
258 },
259 {} /* Terminator */
260};
261
bb3b9d8e
DB
262static struct regulator_consumer_supply beagle_vmmc1_supply = {
263 .supply = "vmmc",
264};
265
266static struct regulator_consumer_supply beagle_vsim_supply = {
267 .supply = "vmmc_aux",
268};
269
90c62bf0
TL
270static struct gpio_led gpio_leds[];
271
272static int beagle_twl_gpio_setup(struct device *dev,
273 unsigned gpio, unsigned ngpio)
274{
cf74d41e
RN
275 if (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_XM) {
276 mmc[0].gpio_wp = -EINVAL;
277 } else if ((omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C1_3) ||
e4916e11 278 (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C4)) {
4896e394 279 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
44e74840
JN
280 mmc[0].gpio_wp = 23;
281 } else {
4896e394 282 omap_mux_init_gpio(29, OMAP_PIN_INPUT);
44e74840 283 }
90c62bf0 284 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
145d9c94 285 mmc[0].gpio_cd = gpio + 0;
68ff0423 286 omap2_hsmmc_init(mmc);
90c62bf0 287
bb3b9d8e
DB
288 /* link regulators to MMC adapters */
289 beagle_vmmc1_supply.dev = mmc[0].dev;
290 beagle_vsim_supply.dev = mmc[0].dev;
291
90c62bf0
TL
292 /* REVISIT: need ehci-omap hooks for external VBUS
293 * power switch and overcurrent detect
294 */
295
296 gpio_request(gpio + 1, "EHCI_nOC");
297 gpio_direction_input(gpio + 1);
298
299 /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
300 gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
e9840dc0 301 gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0);
90c62bf0
TL
302
303 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
304 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
305
306 return 0;
307}
308
309static struct twl4030_gpio_platform_data beagle_gpio_data = {
310 .gpio_base = OMAP_MAX_GPIO_LINES,
311 .irq_base = TWL4030_GPIO_IRQ_BASE,
312 .irq_end = TWL4030_GPIO_IRQ_END,
313 .use_leds = true,
314 .pullups = BIT(1),
315 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
316 | BIT(15) | BIT(16) | BIT(17),
317 .setup = beagle_twl_gpio_setup,
318};
319
bb3b9d8e
DB
320/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
321static struct regulator_init_data beagle_vmmc1 = {
322 .constraints = {
323 .min_uV = 1850000,
324 .max_uV = 3150000,
325 .valid_modes_mask = REGULATOR_MODE_NORMAL
326 | REGULATOR_MODE_STANDBY,
327 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
328 | REGULATOR_CHANGE_MODE
329 | REGULATOR_CHANGE_STATUS,
330 },
331 .num_consumer_supplies = 1,
332 .consumer_supplies = &beagle_vmmc1_supply,
333};
334
335/* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
336static struct regulator_init_data beagle_vsim = {
337 .constraints = {
338 .min_uV = 1800000,
339 .max_uV = 3000000,
340 .valid_modes_mask = REGULATOR_MODE_NORMAL
341 | REGULATOR_MODE_STANDBY,
342 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
343 | REGULATOR_CHANGE_MODE
344 | REGULATOR_CHANGE_STATUS,
345 },
346 .num_consumer_supplies = 1,
347 .consumer_supplies = &beagle_vsim_supply,
348};
349
350/* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
351static struct regulator_init_data beagle_vdac = {
352 .constraints = {
353 .min_uV = 1800000,
354 .max_uV = 1800000,
355 .valid_modes_mask = REGULATOR_MODE_NORMAL
356 | REGULATOR_MODE_STANDBY,
357 .valid_ops_mask = REGULATOR_CHANGE_MODE
358 | REGULATOR_CHANGE_STATUS,
359 },
360 .num_consumer_supplies = 1,
361 .consumer_supplies = &beagle_vdac_supply,
362};
363
364/* VPLL2 for digital video outputs */
365static struct regulator_init_data beagle_vpll2 = {
366 .constraints = {
367 .name = "VDVI",
368 .min_uV = 1800000,
369 .max_uV = 1800000,
370 .valid_modes_mask = REGULATOR_MODE_NORMAL
371 | REGULATOR_MODE_STANDBY,
372 .valid_ops_mask = REGULATOR_CHANGE_MODE
373 | REGULATOR_CHANGE_STATUS,
374 },
375 .num_consumer_supplies = 1,
376 .consumer_supplies = &beagle_vdvi_supply,
377};
378
bd04e465
FB
379static struct twl4030_usb_data beagle_usb_data = {
380 .usb_mode = T2_USB_MODE_ULPI,
381};
382
e86fa0b4
PU
383static struct twl4030_codec_audio_data beagle_audio_data = {
384 .audio_mclk = 26000000,
385};
386
387static struct twl4030_codec_data beagle_codec_data = {
6df74efb 388 .audio_mclk = 26000000,
e86fa0b4
PU
389 .audio = &beagle_audio_data,
390};
391
90c62bf0
TL
392static struct twl4030_platform_data beagle_twldata = {
393 .irq_base = TWL4030_IRQ_BASE,
394 .irq_end = TWL4030_IRQ_END,
395
396 /* platform_data for children goes here */
bd04e465 397 .usb = &beagle_usb_data,
90c62bf0 398 .gpio = &beagle_gpio_data,
e86fa0b4 399 .codec = &beagle_codec_data,
bb3b9d8e
DB
400 .vmmc1 = &beagle_vmmc1,
401 .vsim = &beagle_vsim,
402 .vdac = &beagle_vdac,
403 .vpll2 = &beagle_vpll2,
90c62bf0
TL
404};
405
406static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
407 {
408 I2C_BOARD_INFO("twl4030", 0x48),
409 .flags = I2C_CLIENT_WAKE,
410 .irq = INT_34XX_SYS_NIRQ,
411 .platform_data = &beagle_twldata,
412 },
413};
414
415static int __init omap3_beagle_i2c_init(void)
416{
417 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
418 ARRAY_SIZE(beagle_i2c_boardinfo));
8ca7fe26
KK
419 /* Bus 3 is attached to the DVI port where devices like the pico DLP
420 * projector don't work reliably with 400kHz */
421 omap_register_i2c_bus(3, 100, NULL, 0);
90c62bf0
TL
422 return 0;
423}
424
2885f000
SMK
425static struct gpio_led gpio_leds[] = {
426 {
427 .name = "beagleboard::usr0",
428 .default_trigger = "heartbeat",
429 .gpio = 150,
430 },
431 {
432 .name = "beagleboard::usr1",
433 .default_trigger = "mmc0",
434 .gpio = 149,
435 },
90c62bf0
TL
436 {
437 .name = "beagleboard::pmu_stat",
438 .gpio = -EINVAL, /* gets replaced */
439 .active_low = true,
440 },
2885f000
SMK
441};
442
443static struct gpio_led_platform_data gpio_led_info = {
444 .leds = gpio_leds,
445 .num_leds = ARRAY_SIZE(gpio_leds),
446};
447
448static struct platform_device leds_gpio = {
449 .name = "leds-gpio",
450 .id = -1,
451 .dev = {
452 .platform_data = &gpio_led_info,
453 },
454};
455
456static struct gpio_keys_button gpio_buttons[] = {
457 {
458 .code = BTN_EXTRA,
459 .gpio = 7,
460 .desc = "user",
461 .wakeup = 1,
462 },
463};
464
465static struct gpio_keys_platform_data gpio_key_info = {
466 .buttons = gpio_buttons,
467 .nbuttons = ARRAY_SIZE(gpio_buttons),
468};
469
470static struct platform_device keys_gpio = {
471 .name = "gpio-keys",
472 .id = -1,
473 .dev = {
474 .platform_data = &gpio_key_info,
475 },
476};
477
b3c6df3a
PW
478static void __init omap3_beagle_init_irq(void)
479{
b3c6df3a
PW
480 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
481 mt46h32m32lf6_sdrc_params);
482 omap_init_irq();
483#ifdef CONFIG_OMAP_32K_TIMER
484 omap2_gp_clockevent_set_gptimer(12);
485#endif
486 omap_gpio_init();
487}
488
2885f000 489static struct platform_device *omap3_beagle_devices[] __initdata = {
2885f000
SMK
490 &leds_gpio,
491 &keys_gpio,
044d32ff 492 &beagle_dss_device,
2885f000
SMK
493};
494
495static void __init omap3beagle_flash_init(void)
496{
497 u8 cs = 0;
498 u8 nandcs = GPMC_CS_NUM + 1;
499
2885f000
SMK
500 /* find out the chip-select on which NAND exists */
501 while (cs < GPMC_CS_NUM) {
502 u32 ret = 0;
503 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
504
505 if ((ret & 0xC00) == 0x800) {
506 printk(KERN_INFO "Found NAND on CS%d\n", cs);
507 if (nandcs > GPMC_CS_NUM)
508 nandcs = cs;
509 }
510 cs++;
511 }
512
513 if (nandcs > GPMC_CS_NUM) {
514 printk(KERN_INFO "NAND: Unable to find configuration "
515 "in GPMC\n ");
516 return;
517 }
518
519 if (nandcs < GPMC_CS_NUM) {
520 omap3beagle_nand_data.cs = nandcs;
2885f000
SMK
521
522 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
f450d867 523 if (gpmc_nand_init(&omap3beagle_nand_data) < 0)
2885f000
SMK
524 printk(KERN_ERR "Unable to register NAND device\n");
525 }
526}
527
6f69a181 528static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
58a5491c
FB
529
530 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
531 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
532 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
533
534 .phy_reset = true,
535 .reset_gpio_port[0] = -EINVAL,
536 .reset_gpio_port[1] = 147,
537 .reset_gpio_port[2] = -EINVAL
538};
539
ca5742bd
TL
540#ifdef CONFIG_OMAP_MUX
541static struct omap_board_mux board_mux[] __initdata = {
542 { .reg_offset = OMAP_MUX_TERMINATOR },
543};
544#else
545#define board_mux NULL
546#endif
547
884b8369
MM
548static struct omap_musb_board_data musb_board_data = {
549 .interface_type = MUSB_INTERFACE_ULPI,
550 .mode = MUSB_OTG,
551 .power = 100,
552};
553
2885f000
SMK
554static void __init omap3_beagle_init(void)
555{
ca5742bd 556 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
954bed04 557 omap3_beagle_init_rev();
90c62bf0 558 omap3_beagle_i2c_init();
2885f000
SMK
559 platform_add_devices(omap3_beagle_devices,
560 ARRAY_SIZE(omap3_beagle_devices));
2885f000 561 omap_serial_init();
90c62bf0 562
4896e394 563 omap_mux_init_gpio(170, OMAP_PIN_INPUT);
90c62bf0
TL
564 gpio_request(170, "DVI_nPD");
565 /* REVISIT leave DVI powered down until it's needed ... */
566 gpio_direction_output(170, true);
567
884b8369 568 usb_musb_init(&musb_board_data);
58a5491c 569 usb_ehci_init(&ehci_pdata);
2885f000 570 omap3beagle_flash_init();
9fb97412
JP
571
572 /* Ensure SDRC pins are mux'd for self-refresh */
4896e394
TL
573 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
574 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
044d32ff
KK
575
576 beagle_display_init();
2885f000
SMK
577}
578
2885f000
SMK
579MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
580 /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
581 .phys_io = 0x48000000,
b4224b23 582 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
2885f000 583 .boot_params = 0x80000100,
869fef41 584 .map_io = omap3_map_io,
71ee7dad 585 .reserve = omap_reserve,
2885f000
SMK
586 .init_irq = omap3_beagle_init_irq,
587 .init_machine = omap3_beagle_init,
588 .timer = &omap_timer,
589MACHINE_END
This page took 0.187912 seconds and 5 git commands to generate.