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/gpmc.h>
45 #include <plat/nand.h>
52 #define NAND_BLOCK_SIZE SZ_128K
55 * OMAP3 Beagle revision
56 * Run time detection of Beagle revision is done by reading GPIO.
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
64 OMAP3BEAGLE_BOARD_UNKN
= 0,
65 OMAP3BEAGLE_BOARD_AXBX
,
66 OMAP3BEAGLE_BOARD_C1_3
,
71 static u8 omap3_beagle_version
;
73 static u8
omap3_beagle_get_rev(void)
75 return omap3_beagle_version
;
78 static void __init
omap3_beagle_init_rev(void)
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
);
87 ret
= gpio_request(171, "rev_id_0");
91 ret
= gpio_request(172, "rev_id_1");
95 ret
= gpio_request(173, "rev_id_2");
99 gpio_direction_input(171);
100 gpio_direction_input(172);
101 gpio_direction_input(173);
103 beagle_rev
= gpio_get_value(171) | (gpio_get_value(172) << 1)
104 | (gpio_get_value(173) << 2);
106 switch (beagle_rev
) {
108 printk(KERN_INFO
"OMAP3 Beagle Rev: Ax/Bx\n");
109 omap3_beagle_version
= OMAP3BEAGLE_BOARD_AXBX
;
112 printk(KERN_INFO
"OMAP3 Beagle Rev: C1/C2/C3\n");
113 omap3_beagle_version
= OMAP3BEAGLE_BOARD_C1_3
;
116 printk(KERN_INFO
"OMAP3 Beagle Rev: C4\n");
117 omap3_beagle_version
= OMAP3BEAGLE_BOARD_C4
;
120 printk(KERN_INFO
"OMAP3 Beagle Rev: xM\n");
121 omap3_beagle_version
= OMAP3BEAGLE_BOARD_XM
;
124 printk(KERN_INFO
"OMAP3 Beagle Rev: unknown %hd\n", beagle_rev
);
125 omap3_beagle_version
= OMAP3BEAGLE_BOARD_UNKN
;
135 printk(KERN_ERR
"Unable to get revision detection GPIO pins\n");
136 omap3_beagle_version
= OMAP3BEAGLE_BOARD_UNKN
;
141 static struct mtd_partition omap3beagle_nand_partitions
[] = {
142 /* All the partition sizes are listed in terms of NAND block size */
146 .size
= 4 * NAND_BLOCK_SIZE
,
147 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
151 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x80000 */
152 .size
= 15 * NAND_BLOCK_SIZE
,
153 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
156 .name
= "U-Boot Env",
157 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x260000 */
158 .size
= 1 * NAND_BLOCK_SIZE
,
162 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x280000 */
163 .size
= 32 * NAND_BLOCK_SIZE
,
166 .name
= "File System",
167 .offset
= MTDPART_OFS_APPEND
, /* Offset = 0x680000 */
168 .size
= MTDPART_SIZ_FULL
,
172 static 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 */
183 static int beagle_enable_dvi(struct omap_dss_device
*dssdev
)
185 if (gpio_is_valid(dssdev
->reset_gpio
))
186 gpio_set_value(dssdev
->reset_gpio
, 1);
191 static void beagle_disable_dvi(struct omap_dss_device
*dssdev
)
193 if (gpio_is_valid(dssdev
->reset_gpio
))
194 gpio_set_value(dssdev
->reset_gpio
, 0);
197 static struct omap_dss_device beagle_dvi_device
= {
198 .type
= OMAP_DISPLAY_TYPE_DPI
,
200 .driver_name
= "generic_panel",
201 .phy
.dpi
.data_lines
= 24,
203 .platform_enable
= beagle_enable_dvi
,
204 .platform_disable
= beagle_disable_dvi
,
207 static struct omap_dss_device beagle_tv_device
= {
209 .driver_name
= "venc",
210 .type
= OMAP_DISPLAY_TYPE_VENC
,
211 .phy
.venc
.type
= OMAP_DSS_VENC_TYPE_SVIDEO
,
214 static struct omap_dss_device
*beagle_dss_devices
[] = {
219 static 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
,
225 static struct platform_device beagle_dss_device
= {
229 .platform_data
= &beagle_dss_data
,
233 static struct regulator_consumer_supply beagle_vdac_supply
=
234 REGULATOR_SUPPLY("vdda_dac", "omapdss");
236 static struct regulator_consumer_supply beagle_vdvi_supply
=
237 REGULATOR_SUPPLY("vdds_dsi", "omapdss");
239 static void __init
beagle_display_init(void)
243 r
= gpio_request(beagle_dvi_device
.reset_gpio
, "DVI reset");
245 printk(KERN_ERR
"Unable to get DVI reset GPIO\n");
249 gpio_direction_output(beagle_dvi_device
.reset_gpio
, 0);
252 #include "sdram-micron-mt46h32m32lf-6.h"
254 static struct omap2_hsmmc_info mmc
[] = {
257 .caps
= MMC_CAP_4_BIT_DATA
| MMC_CAP_8_BIT_DATA
,
263 static struct regulator_consumer_supply beagle_vmmc1_supply
= {
267 static struct regulator_consumer_supply beagle_vsim_supply
= {
268 .supply
= "vmmc_aux",
271 static struct gpio_led gpio_leds
[];
273 static int beagle_twl_gpio_setup(struct device
*dev
,
274 unsigned gpio
, unsigned ngpio
)
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
) ||
279 (omap3_beagle_get_rev() == OMAP3BEAGLE_BOARD_C4
)) {
280 omap_mux_init_gpio(23, OMAP_PIN_INPUT
);
283 omap_mux_init_gpio(29, OMAP_PIN_INPUT
);
285 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
286 mmc
[0].gpio_cd
= gpio
+ 0;
287 omap2_hsmmc_init(mmc
);
289 /* link regulators to MMC adapters */
290 beagle_vmmc1_supply
.dev
= mmc
[0].dev
;
291 beagle_vsim_supply
.dev
= mmc
[0].dev
;
293 /* REVISIT: need ehci-omap hooks for external VBUS
294 * power switch and overcurrent detect
297 gpio_request(gpio
+ 1, "EHCI_nOC");
298 gpio_direction_input(gpio
+ 1);
300 /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
301 gpio_request(gpio
+ TWL4030_GPIO_MAX
, "nEN_USB_PWR");
302 gpio_direction_output(gpio
+ TWL4030_GPIO_MAX
, 0);
304 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
305 gpio_leds
[2].gpio
= gpio
+ TWL4030_GPIO_MAX
+ 1;
310 static struct twl4030_gpio_platform_data beagle_gpio_data
= {
311 .gpio_base
= OMAP_MAX_GPIO_LINES
,
312 .irq_base
= TWL4030_GPIO_IRQ_BASE
,
313 .irq_end
= TWL4030_GPIO_IRQ_END
,
316 .pulldowns
= BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
317 | BIT(15) | BIT(16) | BIT(17),
318 .setup
= beagle_twl_gpio_setup
,
321 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
322 static struct regulator_init_data beagle_vmmc1
= {
326 .valid_modes_mask
= REGULATOR_MODE_NORMAL
327 | REGULATOR_MODE_STANDBY
,
328 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
329 | REGULATOR_CHANGE_MODE
330 | REGULATOR_CHANGE_STATUS
,
332 .num_consumer_supplies
= 1,
333 .consumer_supplies
= &beagle_vmmc1_supply
,
336 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
337 static struct regulator_init_data beagle_vsim
= {
341 .valid_modes_mask
= REGULATOR_MODE_NORMAL
342 | REGULATOR_MODE_STANDBY
,
343 .valid_ops_mask
= REGULATOR_CHANGE_VOLTAGE
344 | REGULATOR_CHANGE_MODE
345 | REGULATOR_CHANGE_STATUS
,
347 .num_consumer_supplies
= 1,
348 .consumer_supplies
= &beagle_vsim_supply
,
351 /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
352 static struct regulator_init_data beagle_vdac
= {
356 .valid_modes_mask
= REGULATOR_MODE_NORMAL
357 | REGULATOR_MODE_STANDBY
,
358 .valid_ops_mask
= REGULATOR_CHANGE_MODE
359 | REGULATOR_CHANGE_STATUS
,
361 .num_consumer_supplies
= 1,
362 .consumer_supplies
= &beagle_vdac_supply
,
365 /* VPLL2 for digital video outputs */
366 static struct regulator_init_data beagle_vpll2
= {
371 .valid_modes_mask
= REGULATOR_MODE_NORMAL
372 | REGULATOR_MODE_STANDBY
,
373 .valid_ops_mask
= REGULATOR_CHANGE_MODE
374 | REGULATOR_CHANGE_STATUS
,
376 .num_consumer_supplies
= 1,
377 .consumer_supplies
= &beagle_vdvi_supply
,
380 static struct twl4030_usb_data beagle_usb_data
= {
381 .usb_mode
= T2_USB_MODE_ULPI
,
384 static struct twl4030_codec_audio_data beagle_audio_data
= {
385 .audio_mclk
= 26000000,
388 static struct twl4030_codec_data beagle_codec_data
= {
389 .audio_mclk
= 26000000,
390 .audio
= &beagle_audio_data
,
393 static struct twl4030_platform_data beagle_twldata
= {
394 .irq_base
= TWL4030_IRQ_BASE
,
395 .irq_end
= TWL4030_IRQ_END
,
397 /* platform_data for children goes here */
398 .usb
= &beagle_usb_data
,
399 .gpio
= &beagle_gpio_data
,
400 .codec
= &beagle_codec_data
,
401 .vmmc1
= &beagle_vmmc1
,
402 .vsim
= &beagle_vsim
,
403 .vdac
= &beagle_vdac
,
404 .vpll2
= &beagle_vpll2
,
407 static struct i2c_board_info __initdata beagle_i2c_boardinfo
[] = {
409 I2C_BOARD_INFO("twl4030", 0x48),
410 .flags
= I2C_CLIENT_WAKE
,
411 .irq
= INT_34XX_SYS_NIRQ
,
412 .platform_data
= &beagle_twldata
,
416 static struct i2c_board_info __initdata beagle_i2c_eeprom
[] = {
418 I2C_BOARD_INFO("eeprom", 0x50),
422 static int __init
omap3_beagle_i2c_init(void)
424 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo
,
425 ARRAY_SIZE(beagle_i2c_boardinfo
));
426 /* Bus 3 is attached to the DVI port where devices like the pico DLP
427 * projector don't work reliably with 400kHz */
428 omap_register_i2c_bus(3, 100, beagle_i2c_eeprom
, ARRAY_SIZE(beagle_i2c_eeprom
));
432 static struct gpio_led gpio_leds
[] = {
434 .name
= "beagleboard::usr0",
435 .default_trigger
= "heartbeat",
439 .name
= "beagleboard::usr1",
440 .default_trigger
= "mmc0",
444 .name
= "beagleboard::pmu_stat",
445 .gpio
= -EINVAL
, /* gets replaced */
450 static struct gpio_led_platform_data gpio_led_info
= {
452 .num_leds
= ARRAY_SIZE(gpio_leds
),
455 static struct platform_device leds_gpio
= {
459 .platform_data
= &gpio_led_info
,
463 static struct gpio_keys_button gpio_buttons
[] = {
472 static struct gpio_keys_platform_data gpio_key_info
= {
473 .buttons
= gpio_buttons
,
474 .nbuttons
= ARRAY_SIZE(gpio_buttons
),
477 static struct platform_device keys_gpio
= {
481 .platform_data
= &gpio_key_info
,
485 static void __init
omap3_beagle_init_irq(void)
487 omap2_init_common_hw(mt46h32m32lf6_sdrc_params
,
488 mt46h32m32lf6_sdrc_params
);
490 #ifdef CONFIG_OMAP_32K_TIMER
491 omap2_gp_clockevent_set_gptimer(12);
496 static struct platform_device
*omap3_beagle_devices
[] __initdata
= {
502 static void __init
omap3beagle_flash_init(void)
505 u8 nandcs
= GPMC_CS_NUM
+ 1;
507 /* find out the chip-select on which NAND exists */
508 while (cs
< GPMC_CS_NUM
) {
510 ret
= gpmc_cs_read_reg(cs
, GPMC_CS_CONFIG1
);
512 if ((ret
& 0xC00) == 0x800) {
513 printk(KERN_INFO
"Found NAND on CS%d\n", cs
);
514 if (nandcs
> GPMC_CS_NUM
)
520 if (nandcs
> GPMC_CS_NUM
) {
521 printk(KERN_INFO
"NAND: Unable to find configuration "
526 if (nandcs
< GPMC_CS_NUM
) {
527 omap3beagle_nand_data
.cs
= nandcs
;
529 printk(KERN_INFO
"Registering NAND on CS%d\n", nandcs
);
530 if (gpmc_nand_init(&omap3beagle_nand_data
) < 0)
531 printk(KERN_ERR
"Unable to register NAND device\n");
535 static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst
= {
537 .port_mode
[0] = EHCI_HCD_OMAP_MODE_PHY
,
538 .port_mode
[1] = EHCI_HCD_OMAP_MODE_PHY
,
539 .port_mode
[2] = EHCI_HCD_OMAP_MODE_UNKNOWN
,
542 .reset_gpio_port
[0] = -EINVAL
,
543 .reset_gpio_port
[1] = 147,
544 .reset_gpio_port
[2] = -EINVAL
547 #ifdef CONFIG_OMAP_MUX
548 static struct omap_board_mux board_mux
[] __initdata
= {
549 { .reg_offset
= OMAP_MUX_TERMINATOR
},
552 #define board_mux NULL
555 static struct omap_musb_board_data musb_board_data
= {
556 .interface_type
= MUSB_INTERFACE_ULPI
,
561 static void __init
omap3_beagle_init(void)
563 omap3_mux_init(board_mux
, OMAP_PACKAGE_CBB
);
564 omap3_beagle_init_rev();
565 omap3_beagle_i2c_init();
566 platform_add_devices(omap3_beagle_devices
,
567 ARRAY_SIZE(omap3_beagle_devices
));
570 omap_mux_init_gpio(170, OMAP_PIN_INPUT
);
571 gpio_request(170, "DVI_nPD");
572 /* REVISIT leave DVI powered down until it's needed ... */
573 gpio_direction_output(170, true);
575 usb_musb_init(&musb_board_data
);
576 usb_ehci_init(&ehci_pdata
);
577 omap3beagle_flash_init();
579 /* Ensure SDRC pins are mux'd for self-refresh */
580 omap_mux_init_signal("sdrc_cke0", OMAP_PIN_OUTPUT
);
581 omap_mux_init_signal("sdrc_cke1", OMAP_PIN_OUTPUT
);
583 beagle_display_init();
586 MACHINE_START(OMAP3_BEAGLE
, "OMAP3 Beagle Board")
587 /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
588 .boot_params
= 0x80000100,
589 .map_io
= omap3_map_io
,
590 .reserve
= omap_reserve
,
591 .init_irq
= omap3_beagle_init_irq
,
592 .init_machine
= omap3_beagle_init
,
593 .timer
= &omap_timer
,