2 * linux/arch/arm/mach-omap2/board-omap3beagle.c
4 * Copyright (C) 2008 Texas Instruments
6 * Modified from mach-omap2/board-3430sdp.c
8 * Initial code: Syed Mohammed Khasim
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.
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>
22 #include <linux/leds.h>
23 #include <linux/gpio.h>
24 #include <linux/input.h>
25 #include <linux/gpio_keys.h>
27 #include <linux/mtd/mtd.h>
28 #include <linux/mtd/partitions.h>
29 #include <linux/mtd/nand.h>
30 #include <linux/mmc/host.h>
32 #include <linux/regulator/machine.h>
33 #include <linux/i2c/twl.h>
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>
41 #include <plat/board.h>
42 #include <plat/common.h>
43 #include <plat/display.h>
44 #include <plat/panel-generic-dpi.h>
45 #include <plat/gpmc.h>
46 #include <plat/nand.h>
53 #define NAND_BLOCK_SIZE SZ_128K
56 * OMAP3 Beagle revision
57 * Run time detection of Beagle revision is done by reading GPIO.
59 * AXBX = GPIO173, GPIO172, GPIO171: 1 1 1
60 * C1_3 = GPIO173, GPIO172, GPIO171: 1 1 0
61 * C4 = GPIO173, GPIO172, GPIO171: 1 0 1
62 * XM = GPIO173, GPIO172, GPIO171: 0 0 0
65 OMAP3BEAGLE_BOARD_UNKN = 0,
66 OMAP3BEAGLE_BOARD_AXBX,
67 OMAP3BEAGLE_BOARD_C1_3,
72 static u8 omap3_beagle_version;
74 static u8 omap3_beagle_get_rev(void)
76 return omap3_beagle_version;
79 static void __init omap3_beagle_init_rev(void)
84 omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
85 omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
86 omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
88 ret = gpio_request(171, "rev_id_0");
92 ret = gpio_request(172, "rev_id_1");
96 ret = gpio_request(173, "rev_id_2");
100 gpio_direction_input(171);
101 gpio_direction_input(172);
102 gpio_direction_input(173);
104 beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
105 | (gpio_get_value(173) << 2);
107 switch (beagle_rev) {
109 printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
110 omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
113 printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
114 omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
117 printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
118 omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
121 printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
122 omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
125 printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
126 omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
136 printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
137 omap3_beagle_version = OMAP3BEAGLE_BOARD_UNKN;
142 static struct mtd_partition omap3beagle_nand_partitions[] = {
143 /* All the partition sizes are listed in terms of NAND block size */
147 .size = 4 * NAND_BLOCK_SIZE,
148 .mask_flags = MTD_WRITEABLE, /* force read-only */
152 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
153 .size = 15 * NAND_BLOCK_SIZE,
154 .mask_flags = MTD_WRITEABLE, /* force read-only */
157 .name = "U-Boot Env",
158 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
159 .size = 1 * NAND_BLOCK_SIZE,
163 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
164 .size = 32 * NAND_BLOCK_SIZE,
167 .name = "File System",
168 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
169 .size = MTDPART_SIZ_FULL,
173 static struct omap_nand_platform_data omap3beagle_nand_data = {
174 .options = NAND_BUSWIDTH_16,
175 .parts = omap3beagle_nand_partitions,
176 .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions),
177 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
184 static int beagle_enable_dvi(struct omap_dss_device *dssdev)
186 if (gpio_is_valid(dssdev->reset_gpio))
187 gpio_set_value(dssdev->reset_gpio, 1);
192 static void beagle_disable_dvi(struct omap_dss_device *dssdev)
194 if (gpio_is_valid(dssdev->reset_gpio))
195 gpio_set_value(dssdev->reset_gpio, 0);
198 static struct panel_generic_dpi_data dvi_panel = {
200 .platform_enable = beagle_enable_dvi,
201 .platform_disable = beagle_disable_dvi,
204 static struct omap_dss_device beagle_dvi_device = {
205 .type = OMAP_DISPLAY_TYPE_DPI,
207 .driver_name = "generic_dpi_panel",
209 .phy.dpi.data_lines = 24,
213 static struct omap_dss_device beagle_tv_device = {
215 .driver_name = "venc",
216 .type = OMAP_DISPLAY_TYPE_VENC,
217 .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
220 static struct omap_dss_device *beagle_dss_devices[] = {
225 static struct omap_dss_board_info beagle_dss_data = {
226 .num_devices = ARRAY_SIZE(beagle_dss_devices),
227 .devices = beagle_dss_devices,
228 .default_device = &beagle_dvi_device,
231 static struct platform_device beagle_dss_device = {
235 .platform_data = &beagle_dss_data,
239 static struct regulator_consumer_supply beagle_vdac_supply =
240 REGULATOR_SUPPLY("vdda_dac", "omapdss");
242 static struct regulator_consumer_supply beagle_vdvi_supply =
243 REGULATOR_SUPPLY("vdds_dsi", "omapdss");
245 static void __init beagle_display_init(void)
249 r = gpio_request(beagle_dvi_device.reset_gpio, "DVI reset");
251 printk(KERN_ERR "Unable to get DVI reset GPIO\n");
255 gpio_direction_output(beagle_dvi_device.reset_gpio, 0);
258 #include "sdram-micron-mt46h32m32lf-6.h"
260 static struct omap2_hsmmc_info mmc[] = {
263 .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
269 static struct regulator_consumer_supply beagle_vmmc1_supply = {
273 static struct regulator_consumer_supply beagle_vsim_supply = {
274 .supply = "vmmc_aux",
277 static struct gpio_led gpio_leds[];
279 static int beagle_twl_gpio_setup(struct device *dev,
280 unsigned gpio, unsigned ngpio)
282 if (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_XM) {
283 mmc[0].gpio_wp = -EINVAL;
284 } else if ((omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C1_3) ||
285 (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C4)) {
286 omap_mux_init_gpio(23, OMAP_PIN_INPUT);
289 omap_mux_init_gpio(29, OMAP_PIN_INPUT);
291 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
292 mmc[0].gpio_cd = gpio + 0;
293 omap2_hsmmc_init(mmc);
295 /* link regulators to MMC adapters */
296 beagle_vmmc1_supply.dev = mmc[0].dev;
297 beagle_vsim_supply.dev = mmc[0].dev;
299 /* REVISIT: need ehci-omap hooks for external VBUS
300 * power switch and overcurrent detect
303 gpio_request(gpio + 1, "EHCI_nOC");
304 gpio_direction_input(gpio + 1);
306 /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
307 gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
308 gpio_direction_output(gpio + TWL4030_GPIO_MAX, 0);
310 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
311 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
316 static struct twl4030_gpio_platform_data beagle_gpio_data = {
317 .gpio_base = OMAP_MAX_GPIO_LINES,
318 .irq_base = TWL4030_GPIO_IRQ_BASE,
319 .irq_end = TWL4030_GPIO_IRQ_END,
322 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
323 | BIT(15) | BIT(16) | BIT(17),
324 .setup = beagle_twl_gpio_setup,
327 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
328 static struct regulator_init_data beagle_vmmc1 = {
332 .valid_modes_mask = REGULATOR_MODE_NORMAL
333 | REGULATOR_MODE_STANDBY,
334 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
335 | REGULATOR_CHANGE_MODE
336 | REGULATOR_CHANGE_STATUS,
338 .num_consumer_supplies = 1,
339 .consumer_supplies = &beagle_vmmc1_supply,
342 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
343 static struct regulator_init_data beagle_vsim = {
347 .valid_modes_mask = REGULATOR_MODE_NORMAL
348 | REGULATOR_MODE_STANDBY,
349 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
350 | REGULATOR_CHANGE_MODE
351 | REGULATOR_CHANGE_STATUS,
353 .num_consumer_supplies = 1,
354 .consumer_supplies = &beagle_vsim_supply,
357 /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
358 static struct regulator_init_data beagle_vdac = {
362 .valid_modes_mask = REGULATOR_MODE_NORMAL
363 | REGULATOR_MODE_STANDBY,
364 .valid_ops_mask = REGULATOR_CHANGE_MODE
365 | REGULATOR_CHANGE_STATUS,
367 .num_consumer_supplies = 1,
368 .consumer_supplies = &beagle_vdac_supply,
371 /* VPLL2 for digital video outputs */
372 static struct regulator_init_data beagle_vpll2 = {
377 .valid_modes_mask = REGULATOR_MODE_NORMAL
378 | REGULATOR_MODE_STANDBY,
379 .valid_ops_mask = REGULATOR_CHANGE_MODE
380 | REGULATOR_CHANGE_STATUS,
382 .num_consumer_supplies = 1,
383 .consumer_supplies = &beagle_vdvi_supply,
386 static struct twl4030_usb_data beagle_usb_data = {
387 .usb_mode = T2_USB_MODE_ULPI,
390 static struct twl4030_codec_audio_data beagle_audio_data = {
391 .audio_mclk = 26000000,
394 static struct twl4030_codec_data beagle_codec_data = {
395 .audio_mclk = 26000000,
396 .audio = &beagle_audio_data,
399 static struct twl4030_platform_data beagle_twldata = {
400 .irq_base = TWL4030_IRQ_BASE,
401 .irq_end = TWL4030_IRQ_END,
403 /* platform_data for children goes here */
404 .usb = &beagle_usb_data,
405 .gpio = &beagle_gpio_data,
406 .codec = &beagle_codec_data,
407 .vmmc1 = &beagle_vmmc1,
408 .vsim = &beagle_vsim,
409 .vdac = &beagle_vdac,
410 .vpll2 = &beagle_vpll2,
413 static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
415 I2C_BOARD_INFO("twl4030", 0x48),
416 .flags = I2C_CLIENT_WAKE,
417 .irq = INT_34XX_SYS_NIRQ,
418 .platform_data = &beagle_twldata,
422 static struct i2c_board_info __initdata beagle_i2c_eeprom[] = {
424 I2C_BOARD_INFO("eeprom", 0x50),
428 static int __init omap3_beagle_i2c_init(void)
430 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
431 ARRAY_SIZE(beagle_i2c_boardinfo));
432 /* Bus 3 is attached to the DVI port where devices like the pico DLP
433 * projector don't work reliably with 400kHz */
434 omap_register_i2c_bus(3, 100, beagle_i2c_eeprom, ARRAY_SIZE(beagle_i2c_eeprom));
438 static struct gpio_led gpio_leds[] = {
440 .name = "beagleboard::usr0",
441 .default_trigger = "heartbeat",
445 .name = "beagleboard::usr1",
446 .default_trigger = "mmc0",
450 .name = "beagleboard::pmu_stat",
451 .gpio = -EINVAL, /* gets replaced */
456 static struct gpio_led_platform_data gpio_led_info = {
458 .num_leds = ARRAY_SIZE(gpio_leds),
461 static struct platform_device leds_gpio = {
465 .platform_data = &gpio_led_info,
469 static struct gpio_keys_button gpio_buttons[] = {
478 static struct gpio_keys_platform_data gpio_key_info = {
479 .buttons = gpio_buttons,
480 .nbuttons = ARRAY_SIZE(gpio_buttons),
483 static struct platform_device keys_gpio = {
487 .platform_data = &gpio_key_info,
491 static void __init omap3_beagle_init_irq(void)
493 omap2_init_common_infrastructure();
494 omap2_init_common_devices(mt46h32m32lf6_sdrc_params,
495 mt46h32m32lf6_sdrc_params);
497 #ifdef CONFIG_OMAP_32K_TIMER
498 omap2_gp_clockevent_set_gptimer(12);
502 static struct platform_device *omap3_beagle_devices[] __initdata = {
508 static void __init omap3beagle_flash_init(void)
511 u8 nandcs = GPMC_CS_NUM + 1;
513 /* find out the chip-select on which NAND exists */
514 while (cs < GPMC_CS_NUM) {
516 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
518 if ((ret & 0xC00) == 0x800) {
519 printk(KERN_INFO "Found NAND on CS%d\n", cs);
520 if (nandcs > GPMC_CS_NUM)
526 if (nandcs > GPMC_CS_NUM) {
527 printk(KERN_INFO "NAND: Unable to find configuration "
532 if (nandcs < GPMC_CS_NUM) {
533 omap3beagle_nand_data.cs = nandcs;
535 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
536 if (gpmc_nand_init(&omap3beagle_nand_data) < 0)
537 printk(KERN_ERR "Unable to register NAND device\n");
541 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
543 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
544 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
545 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
548 .reset_gpio_port[0] = -EINVAL,
549 .reset_gpio_port[1] = 147,
550 .reset_gpio_port[2] = -EINVAL
553 #ifdef CONFIG_OMAP_MUX
554 static struct omap_board_mux board_mux[] __initdata = {
555 { .reg_offset = OMAP_MUX_TERMINATOR },
559 static struct omap_musb_board_data musb_board_data = {
560 .interface_type = MUSB_INTERFACE_ULPI,
565 static void __init omap3_beagle_init(void)
567 omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
568 omap3_beagle_init_rev();
569 omap3_beagle_i2c_init();
570 platform_add_devices(omap3_beagle_devices,
571 ARRAY_SIZE(omap3_beagle_devices));
574 omap_mux_init_gpio(170, OMAP_PIN_INPUT);
575 gpio_request(170, "DVI_nPD");
576 /* REVISIT leave DVI powered down until it's needed ... */
577 gpio_direction_output(170, true);
579 usb_musb_init(&musb_board_data);
580 usb_ehci_init(&ehci_pdata);
581 omap3beagle_flash_init();
583 /* Ensure SDRC pins are mux'd for self-refresh */
584 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT);
585 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT);
587 beagle_display_init();
590 MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
591 /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
592 .boot_params = 0x80000100,
593 .map_io = omap3_map_io,
594 .reserve = omap_reserve,
595 .init_irq = omap3_beagle_init_irq,
596 .init_machine = omap3_beagle_init,
597 .timer = &omap_timer,