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