blob: 7b95cc1273042ca80c3c30d681043b1156c48836 [file] [log] [blame]
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +03001/*
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
David Brownellbb3b9d82009-05-28 14:04:03 -070031#include <linux/regulator/machine.h>
Santosh Shilimkarb07682b2009-12-13 20:05:51 +010032#include <linux/i2c/twl.h>
Tony Lindgren145d9c92009-01-15 13:09:53 +020033
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +030034#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
Tony Lindgrence491cf2009-10-20 09:40:47 -070040#include <plat/board.h>
41#include <plat/common.h>
Koen Kooi044d32f2010-04-22 10:23:42 +020042#include <plat/display.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070043#include <plat/gpmc.h>
44#include <plat/nand.h>
Tony Lindgrence491cf2009-10-20 09:40:47 -070045#include <plat/usb.h>
46#include <plat/timer-gp.h>
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +030047
Tony Lindgrenca5742b2009-12-11 16:16:32 -080048#include "mux.h"
Adrian Hunterd02a900b2010-02-15 10:03:34 -080049#include "hsmmc.h"
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +030050
51#define GPMC_CS0_BASE 0x60
52#define GPMC_CS_SIZE 0x30
53
54#define NAND_BLOCK_SIZE SZ_128K
55
56static struct mtd_partition omap3beagle_nand_partitions[] = {
57 /* All the partition sizes are listed in terms of NAND block size */
58 {
59 .name = "X-Loader",
60 .offset = 0,
61 .size = 4 * NAND_BLOCK_SIZE,
62 .mask_flags = MTD_WRITEABLE, /* force read-only */
63 },
64 {
65 .name = "U-Boot",
66 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
67 .size = 15 * NAND_BLOCK_SIZE,
68 .mask_flags = MTD_WRITEABLE, /* force read-only */
69 },
70 {
71 .name = "U-Boot Env",
72 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
73 .size = 1 * NAND_BLOCK_SIZE,
74 },
75 {
76 .name = "Kernel",
77 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
78 .size = 32 * NAND_BLOCK_SIZE,
79 },
80 {
81 .name = "File System",
82 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
83 .size = MTDPART_SIZ_FULL,
84 },
85};
86
87static struct omap_nand_platform_data omap3beagle_nand_data = {
88 .options = NAND_BUSWIDTH_16,
89 .parts = omap3beagle_nand_partitions,
90 .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions),
91 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
92 .nand_setup = NULL,
93 .dev_ready = NULL,
94};
95
96static struct resource omap3beagle_nand_resource = {
97 .flags = IORESOURCE_MEM,
98};
99
100static struct platform_device omap3beagle_nand_device = {
101 .name = "omap2-nand",
102 .id = -1,
103 .dev = {
104 .platform_data = &omap3beagle_nand_data,
105 },
106 .num_resources = 1,
107 .resource = &omap3beagle_nand_resource,
108};
109
Koen Kooi044d32f2010-04-22 10:23:42 +0200110/* DSS */
111
112static int beagle_enable_dvi(struct omap_dss_device *dssdev)
113{
114 if (gpio_is_valid(dssdev->reset_gpio))
115 gpio_set_value(dssdev->reset_gpio, 1);
116
117 return 0;
118}
119
120static void beagle_disable_dvi(struct omap_dss_device *dssdev)
121{
122 if (gpio_is_valid(dssdev->reset_gpio))
123 gpio_set_value(dssdev->reset_gpio, 0);
124}
125
126static struct omap_dss_device beagle_dvi_device = {
127 .type = OMAP_DISPLAY_TYPE_DPI,
128 .name = "dvi",
129 .driver_name = "generic_panel",
130 .phy.dpi.data_lines = 24,
131 .reset_gpio = 170,
132 .platform_enable = beagle_enable_dvi,
133 .platform_disable = beagle_disable_dvi,
134};
135
136static struct omap_dss_device beagle_tv_device = {
137 .name = "tv",
138 .driver_name = "venc",
139 .type = OMAP_DISPLAY_TYPE_VENC,
140 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
141};
142
143static struct omap_dss_device *beagle_dss_devices[] = {
144 &beagle_dvi_device,
145 &beagle_tv_device,
146};
147
148static struct omap_dss_board_info beagle_dss_data = {
149 .num_devices = ARRAY_SIZE(beagle_dss_devices),
150 .devices = beagle_dss_devices,
151 .default_device = &beagle_dvi_device,
152};
153
154static struct platform_device beagle_dss_device = {
155 .name = "omapdss",
156 .id = -1,
157 .dev = {
158 .platform_data = &beagle_dss_data,
159 },
160};
161
162static struct regulator_consumer_supply beagle_vdac_supply =
163 REGULATOR_SUPPLY("vdda_dac", "omapdss");
164
165static struct regulator_consumer_supply beagle_vdvi_supply =
166 REGULATOR_SUPPLY("vdds_dsi", "omapdss");
167
168static void __init beagle_display_init(void)
169{
170 int r;
171
172 r = gpio_request(beagle_dvi_device.reset_gpio, "DVI reset");
173 if (r < 0) {
174 printk(KERN_ERR "Unable to get DVI reset GPIO\n");
175 return;
176 }
177
178 gpio_direction_output(beagle_dvi_device.reset_gpio, 0);
179}
180
Paul Walmsley2e12bd72009-05-28 14:03:59 -0700181#include "sdram-micron-mt46h32m32lf-6.h"
182
Adrian Hunter68ff0422010-02-15 10:03:34 -0800183static struct omap2_hsmmc_info mmc[] = {
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800184 {
185 .mmc = 1,
186 .wires = 8,
187 .gpio_wp = 29,
188 },
189 {} /* Terminator */
190};
191
David Brownellbb3b9d82009-05-28 14:04:03 -0700192static struct regulator_consumer_supply beagle_vmmc1_supply = {
193 .supply = "vmmc",
194};
195
196static struct regulator_consumer_supply beagle_vsim_supply = {
197 .supply = "vmmc_aux",
198};
199
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800200static struct gpio_led gpio_leds[];
201
202static int beagle_twl_gpio_setup(struct device *dev,
203 unsigned gpio, unsigned ngpio)
204{
Jarkko Nikula44e74842009-09-24 16:23:17 -0700205 if (system_rev >= 0x20 && system_rev <= 0x34301000) {
Tony Lindgren4896e392009-12-11 16:16:32 -0800206 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
Jarkko Nikula44e74842009-09-24 16:23:17 -0700207 mmc[0].gpio_wp = 23;
208 } else {
Tony Lindgren4896e392009-12-11 16:16:32 -0800209 omap_mux_init_gpio(29, OMAP_PIN_INPUT);
Jarkko Nikula44e74842009-09-24 16:23:17 -0700210 }
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800211 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
Tony Lindgren145d9c92009-01-15 13:09:53 +0200212 mmc[0].gpio_cd = gpio + 0;
Adrian Hunter68ff0422010-02-15 10:03:34 -0800213 omap2_hsmmc_init(mmc);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800214
David Brownellbb3b9d82009-05-28 14:04:03 -0700215 /* link regulators to MMC adapters */
216 beagle_vmmc1_supply.dev = mmc[0].dev;
217 beagle_vsim_supply.dev = mmc[0].dev;
218
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800219 /* REVISIT: need ehci-omap hooks for external VBUS
220 * power switch and overcurrent detect
221 */
222
223 gpio_request(gpio + 1, "EHCI_nOC");
224 gpio_direction_input(gpio + 1);
225
226 /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
227 gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
Jarkko Nikulae9840dc2009-11-11 11:00:36 -0800228 gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800229
230 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
231 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
232
233 return 0;
234}
235
236static struct twl4030_gpio_platform_data beagle_gpio_data = {
237 .gpio_base = OMAP_MAX_GPIO_LINES,
238 .irq_base = TWL4030_GPIO_IRQ_BASE,
239 .irq_end = TWL4030_GPIO_IRQ_END,
240 .use_leds = true,
241 .pullups = BIT(1),
242 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
243 | BIT(15) | BIT(16) | BIT(17),
244 .setup = beagle_twl_gpio_setup,
245};
246
David Brownellbb3b9d82009-05-28 14:04:03 -0700247/* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
248static struct regulator_init_data beagle_vmmc1 = {
249 .constraints = {
250 .min_uV = 1850000,
251 .max_uV = 3150000,
252 .valid_modes_mask = REGULATOR_MODE_NORMAL
253 | REGULATOR_MODE_STANDBY,
254 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
255 | REGULATOR_CHANGE_MODE
256 | REGULATOR_CHANGE_STATUS,
257 },
258 .num_consumer_supplies = 1,
259 .consumer_supplies = &beagle_vmmc1_supply,
260};
261
262/* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
263static struct regulator_init_data beagle_vsim = {
264 .constraints = {
265 .min_uV = 1800000,
266 .max_uV = 3000000,
267 .valid_modes_mask = REGULATOR_MODE_NORMAL
268 | REGULATOR_MODE_STANDBY,
269 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
270 | REGULATOR_CHANGE_MODE
271 | REGULATOR_CHANGE_STATUS,
272 },
273 .num_consumer_supplies = 1,
274 .consumer_supplies = &beagle_vsim_supply,
275};
276
277/* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
278static struct regulator_init_data beagle_vdac = {
279 .constraints = {
280 .min_uV = 1800000,
281 .max_uV = 1800000,
282 .valid_modes_mask = REGULATOR_MODE_NORMAL
283 | REGULATOR_MODE_STANDBY,
284 .valid_ops_mask = REGULATOR_CHANGE_MODE
285 | REGULATOR_CHANGE_STATUS,
286 },
287 .num_consumer_supplies = 1,
288 .consumer_supplies = &beagle_vdac_supply,
289};
290
291/* VPLL2 for digital video outputs */
292static struct regulator_init_data beagle_vpll2 = {
293 .constraints = {
294 .name = "VDVI",
295 .min_uV = 1800000,
296 .max_uV = 1800000,
297 .valid_modes_mask = REGULATOR_MODE_NORMAL
298 | REGULATOR_MODE_STANDBY,
299 .valid_ops_mask = REGULATOR_CHANGE_MODE
300 | REGULATOR_CHANGE_STATUS,
301 },
302 .num_consumer_supplies = 1,
303 .consumer_supplies = &beagle_vdvi_supply,
304};
305
Felipe Balbibd04e462009-08-28 11:24:15 -0700306static struct twl4030_usb_data beagle_usb_data = {
307 .usb_mode = T2_USB_MODE_ULPI,
308};
309
Peter Ujfalusie86fa0b2009-10-22 13:26:46 +0300310static struct twl4030_codec_audio_data beagle_audio_data = {
311 .audio_mclk = 26000000,
312};
313
314static struct twl4030_codec_data beagle_codec_data = {
Peter Ujfalusi6df74ef2009-11-04 09:58:18 +0200315 .audio_mclk = 26000000,
Peter Ujfalusie86fa0b2009-10-22 13:26:46 +0300316 .audio = &beagle_audio_data,
317};
318
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800319static struct twl4030_platform_data beagle_twldata = {
320 .irq_base = TWL4030_IRQ_BASE,
321 .irq_end = TWL4030_IRQ_END,
322
323 /* platform_data for children goes here */
Felipe Balbibd04e462009-08-28 11:24:15 -0700324 .usb = &beagle_usb_data,
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800325 .gpio = &beagle_gpio_data,
Peter Ujfalusie86fa0b2009-10-22 13:26:46 +0300326 .codec = &beagle_codec_data,
David Brownellbb3b9d82009-05-28 14:04:03 -0700327 .vmmc1 = &beagle_vmmc1,
328 .vsim = &beagle_vsim,
329 .vdac = &beagle_vdac,
330 .vpll2 = &beagle_vpll2,
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800331};
332
333static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
334 {
335 I2C_BOARD_INFO("twl4030", 0x48),
336 .flags = I2C_CLIENT_WAKE,
337 .irq = INT_34XX_SYS_NIRQ,
338 .platform_data = &beagle_twldata,
339 },
340};
341
342static int __init omap3_beagle_i2c_init(void)
343{
344 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
345 ARRAY_SIZE(beagle_i2c_boardinfo));
Koen Kooi8ca7fe22009-03-04 10:07:42 -0800346 /* Bus 3 is attached to the DVI port where devices like the pico DLP
347 * projector don't work reliably with 400kHz */
348 omap_register_i2c_bus(3, 100, NULL, 0);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800349 return 0;
350}
351
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300352static struct gpio_led gpio_leds[] = {
353 {
354 .name = "beagleboard::usr0",
355 .default_trigger = "heartbeat",
356 .gpio = 150,
357 },
358 {
359 .name = "beagleboard::usr1",
360 .default_trigger = "mmc0",
361 .gpio = 149,
362 },
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800363 {
364 .name = "beagleboard::pmu_stat",
365 .gpio = -EINVAL, /* gets replaced */
366 .active_low = true,
367 },
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300368};
369
370static struct gpio_led_platform_data gpio_led_info = {
371 .leds = gpio_leds,
372 .num_leds = ARRAY_SIZE(gpio_leds),
373};
374
375static struct platform_device leds_gpio = {
376 .name = "leds-gpio",
377 .id = -1,
378 .dev = {
379 .platform_data = &gpio_led_info,
380 },
381};
382
383static struct gpio_keys_button gpio_buttons[] = {
384 {
385 .code = BTN_EXTRA,
386 .gpio = 7,
387 .desc = "user",
388 .wakeup = 1,
389 },
390};
391
392static struct gpio_keys_platform_data gpio_key_info = {
393 .buttons = gpio_buttons,
394 .nbuttons = ARRAY_SIZE(gpio_buttons),
395};
396
397static struct platform_device keys_gpio = {
398 .name = "gpio-keys",
399 .id = -1,
400 .dev = {
401 .platform_data = &gpio_key_info,
402 },
403};
404
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300405static void __init omap3_beagle_init_irq(void)
406{
Paul Walmsleyb3c6df32009-09-03 20:14:02 +0300407 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
408 mt46h32m32lf6_sdrc_params);
409 omap_init_irq();
410#ifdef CONFIG_OMAP_32K_TIMER
411 omap2_gp_clockevent_set_gptimer(12);
412#endif
413 omap_gpio_init();
414}
415
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300416static struct platform_device *omap3_beagle_devices[] __initdata = {
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300417 &leds_gpio,
418 &keys_gpio,
Koen Kooi044d32f2010-04-22 10:23:42 +0200419 &beagle_dss_device,
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300420};
421
422static void __init omap3beagle_flash_init(void)
423{
424 u8 cs = 0;
425 u8 nandcs = GPMC_CS_NUM + 1;
426
427 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
428
429 /* find out the chip-select on which NAND exists */
430 while (cs < GPMC_CS_NUM) {
431 u32 ret = 0;
432 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
433
434 if ((ret & 0xC00) == 0x800) {
435 printk(KERN_INFO "Found NAND on CS%d\n", cs);
436 if (nandcs > GPMC_CS_NUM)
437 nandcs = cs;
438 }
439 cs++;
440 }
441
442 if (nandcs > GPMC_CS_NUM) {
443 printk(KERN_INFO "NAND: Unable to find configuration "
444 "in GPMC\n ");
445 return;
446 }
447
448 if (nandcs < GPMC_CS_NUM) {
449 omap3beagle_nand_data.cs = nandcs;
450 omap3beagle_nand_data.gpmc_cs_baseaddr = (void *)
451 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
452 omap3beagle_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
453
454 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
455 if (platform_device_register(&omap3beagle_nand_device) < 0)
456 printk(KERN_ERR "Unable to register NAND device\n");
457 }
458}
459
Felipe Balbi6f69a182010-03-04 09:45:53 +0200460static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
Felipe Balbi58a54912009-11-22 10:11:01 -0800461
462 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
463 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
464 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
465
466 .phy_reset = true,
467 .reset_gpio_port[0] = -EINVAL,
468 .reset_gpio_port[1] = 147,
469 .reset_gpio_port[2] = -EINVAL
470};
471
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800472#ifdef CONFIG_OMAP_MUX
473static struct omap_board_mux board_mux[] __initdata = {
474 { .reg_offset = OMAP_MUX_TERMINATOR },
475};
476#else
477#define board_mux NULL
478#endif
479
Maulik Mankad884b8362010-02-17 14:09:30 -0800480static struct omap_musb_board_data musb_board_data = {
481 .interface_type = MUSB_INTERFACE_ULPI,
482 .mode = MUSB_OTG,
483 .power = 100,
484};
485
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300486static void __init omap3_beagle_init(void)
487{
Tony Lindgrenca5742b2009-12-11 16:16:32 -0800488 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800489 omap3_beagle_i2c_init();
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300490 platform_add_devices(omap3_beagle_devices,
491 ARRAY_SIZE(omap3_beagle_devices));
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300492 omap_serial_init();
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800493
Tony Lindgren4896e392009-12-11 16:16:32 -0800494 omap_mux_init_gpio(170, OMAP_PIN_INPUT);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800495 gpio_request(170, "DVI_nPD");
496 /* REVISIT leave DVI powered down until it's needed ... */
497 gpio_direction_output(170, true);
498
Maulik Mankad884b8362010-02-17 14:09:30 -0800499 usb_musb_init(&musb_board_data);
Felipe Balbi58a54912009-11-22 10:11:01 -0800500 usb_ehci_init(&ehci_pdata);
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300501 omap3beagle_flash_init();
Jean Pihet9fb97412009-07-24 19:43:25 -0600502
503 /* Ensure SDRC pins are mux'd for self-refresh */
Tony Lindgren4896e392009-12-11 16:16:32 -0800504 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
505 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
Koen Kooi044d32f2010-04-22 10:23:42 +0200506
507 beagle_display_init();
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300508}
509
510static void __init omap3_beagle_map_io(void)
511{
Sergio Aguirrec573bcf2010-08-04 14:43:18 +0300512 omap2_set_globals_3xxx();
Tony Lindgren6fbd55d2010-02-12 12:26:47 -0800513 omap34xx_map_common_io();
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300514}
515
516MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
517 /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
518 .phys_io = 0x48000000,
Santosh Shilimkarb4224b22009-10-19 17:25:55 -0700519 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300520 .boot_params = 0x80000100,
521 .map_io = omap3_beagle_map_io,
Russell King71ee7da2010-05-23 10:18:16 +0100522 .reserve = omap_reserve,
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300523 .init_irq = omap3_beagle_init_irq,
524 .init_machine = omap3_beagle_init,
525 .timer = &omap_timer,
526MACHINE_END