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/i2c/twl4030.h>
28 #include <linux/omapfb.h>
30 #include <linux/mtd/mtd.h>
31 #include <linux/mtd/partitions.h>
32 #include <linux/mtd/nand.h>
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>
40 #include <mach/board.h>
41 #include <mach/usb-musb.h>
42 #include <mach/usb-ehci.h>
43 #include <mach/hsmmc.h>
44 #include <mach/common.h>
45 #include <mach/gpmc.h>
46 #include <mach/nand.h>
48 #include <mach/display.h>
51 #define GPMC_CS0_BASE 0x60
52 #define GPMC_CS_SIZE 0x30
54 #define NAND_BLOCK_SIZE SZ_128K
56 static struct mtd_partition omap3beagle_nand_partitions[] = {
57 /* All the partition sizes are listed in terms of NAND block size */
61 .size = 4 * NAND_BLOCK_SIZE,
62 .mask_flags = MTD_WRITEABLE, /* force read-only */
66 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
67 .size = 15 * NAND_BLOCK_SIZE,
68 .mask_flags = MTD_WRITEABLE, /* force read-only */
72 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
73 .size = 1 * NAND_BLOCK_SIZE,
77 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
78 .size = 32 * NAND_BLOCK_SIZE,
81 .name = "File System",
82 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
83 .size = MTDPART_SIZ_FULL,
87 static 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 */
96 static struct resource omap3beagle_nand_resource = {
97 .flags = IORESOURCE_MEM,
100 static struct platform_device omap3beagle_nand_device = {
101 .name = "omap2-nand",
104 .platform_data = &omap3beagle_nand_data,
107 .resource = &omap3beagle_nand_resource,
110 #include "sdram-micron-mt46h32m32lf-6.h"
112 static struct omap_uart_config omap3_beagle_uart_config __initdata = {
113 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
116 static struct twl4030_usb_data beagle_usb_data = {
117 .usb_mode = T2_USB_MODE_ULPI,
120 static struct gpio_led gpio_leds[];
122 static int beagle_twl_gpio_setup(struct device *dev,
123 unsigned gpio, unsigned ngpio)
125 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
127 /* REVISIT: need ehci-omap hooks for external VBUS
128 * power switch and overcurrent detect
131 gpio_request(gpio + 1, "EHCI_nOC");
132 gpio_direction_input(gpio + 1);
134 /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
135 gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
136 gpio_direction_output(gpio + TWL4030_GPIO_MAX, 1);
138 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
139 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
144 static struct twl4030_gpio_platform_data beagle_gpio_data = {
145 .gpio_base = OMAP_MAX_GPIO_LINES,
146 .irq_base = TWL4030_GPIO_IRQ_BASE,
147 .irq_end = TWL4030_GPIO_IRQ_END,
150 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
151 | BIT(15) | BIT(16) | BIT(17),
152 .setup = beagle_twl_gpio_setup,
155 static struct twl4030_platform_data beagle_twldata = {
156 .irq_base = TWL4030_IRQ_BASE,
157 .irq_end = TWL4030_IRQ_END,
159 /* platform_data for children goes here */
160 .usb = &beagle_usb_data,
161 .gpio = &beagle_gpio_data,
164 static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
166 I2C_BOARD_INFO("twl4030", 0x48),
167 .flags = I2C_CLIENT_WAKE,
168 .irq = INT_34XX_SYS_NIRQ,
169 .platform_data = &beagle_twldata,
173 static int __init omap3_beagle_i2c_init(void)
175 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
176 ARRAY_SIZE(beagle_i2c_boardinfo));
177 #ifdef CONFIG_I2C2_OMAP_BEAGLE
178 omap_register_i2c_bus(2, 400, NULL, 0);
180 omap_register_i2c_bus(3, 400, NULL, 0);
184 static void __init omap3_beagle_init_irq(void)
186 omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
191 static struct platform_device omap3_beagle_lcd_device = {
192 .name = "omap3beagle_lcd",
196 static struct gpio_led gpio_leds[] = {
198 .name = "beagleboard::usr0",
199 .default_trigger = "heartbeat",
203 .name = "beagleboard::usr1",
204 .default_trigger = "mmc0",
208 .name = "beagleboard::pmu_stat",
209 .gpio = -EINVAL, /* gets replaced */
214 static struct gpio_led_platform_data gpio_led_info = {
216 .num_leds = ARRAY_SIZE(gpio_leds),
219 static struct platform_device leds_gpio = {
223 .platform_data = &gpio_led_info,
227 static struct gpio_keys_button gpio_buttons[] = {
236 static struct gpio_keys_platform_data gpio_key_info = {
237 .buttons = gpio_buttons,
238 .nbuttons = ARRAY_SIZE(gpio_buttons),
241 static struct platform_device keys_gpio = {
245 .platform_data = &gpio_key_info,
251 static int beagle_enable_dvi(struct omap_display *display)
253 if (display->hw_config.panel_reset_gpio != -1)
254 gpio_set_value(display->hw_config.panel_reset_gpio, 1);
259 static void beagle_disable_dvi(struct omap_display *display)
261 if (display->hw_config.panel_reset_gpio != -1)
262 gpio_set_value(display->hw_config.panel_reset_gpio, 0);
265 static struct omap_dss_display_config beagle_display_data_dvi = {
266 .type = OMAP_DISPLAY_TYPE_DPI,
268 .panel_name = "panel-generic",
269 .u.dpi.data_lines = 24,
270 .panel_reset_gpio = 170,
271 .panel_enable = beagle_enable_dvi,
272 .panel_disable = beagle_disable_dvi,
276 static int beagle_panel_enable_tv(struct omap_display *display)
278 #define ENABLE_VDAC_DEDICATED 0x03
279 #define ENABLE_VDAC_DEV_GRP 0x20
281 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
282 ENABLE_VDAC_DEDICATED,
283 TWL4030_VDAC_DEDICATED);
284 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER,
285 ENABLE_VDAC_DEV_GRP, TWL4030_VDAC_DEV_GRP);
290 static void beagle_panel_disable_tv(struct omap_display *display)
292 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x00,
293 TWL4030_VDAC_DEDICATED);
294 twl4030_i2c_write_u8(TWL4030_MODULE_PM_RECEIVER, 0x00,
295 TWL4030_VDAC_DEV_GRP);
298 static struct omap_dss_display_config beagle_display_data_tv = {
299 .type = OMAP_DISPLAY_TYPE_VENC,
301 .u.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
302 .panel_enable = beagle_panel_enable_tv,
303 .panel_disable = beagle_panel_disable_tv,
306 static struct omap_dss_board_info beagle_dss_data = {
309 &beagle_display_data_dvi,
310 &beagle_display_data_tv,
314 static struct platform_device beagle_dss_device = {
318 .platform_data = &beagle_dss_data,
322 static void __init beagle_display_init(void)
326 r = gpio_request(beagle_display_data_dvi.panel_reset_gpio, "DVI reset");
328 printk(KERN_ERR "Unable to get DVI reset GPIO\n");
332 gpio_direction_output(beagle_display_data_dvi.panel_reset_gpio, 0);
335 static struct omap_board_config_kernel omap3_beagle_config[] __initdata = {
336 { OMAP_TAG_UART, &omap3_beagle_uart_config },
339 static struct platform_device *omap3_beagle_devices[] __initdata = {
345 static void __init omap3beagle_flash_init(void)
348 u8 nandcs = GPMC_CS_NUM + 1;
350 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
352 /* find out the chip-select on which NAND exists */
353 while (cs < GPMC_CS_NUM) {
355 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
357 if ((ret & 0xC00) == 0x800) {
358 printk(KERN_INFO "Found NAND on CS%d\n", cs);
359 if (nandcs > GPMC_CS_NUM)
365 if (nandcs > GPMC_CS_NUM) {
366 printk(KERN_INFO "NAND: Unable to find configuration "
371 if (nandcs < GPMC_CS_NUM) {
372 omap3beagle_nand_data.cs = nandcs;
373 omap3beagle_nand_data.gpmc_cs_baseaddr = (void *)
374 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
375 omap3beagle_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
377 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
378 if (platform_device_register(&omap3beagle_nand_device) < 0)
379 printk(KERN_ERR "Unable to register NAND device\n");
383 static void __init omap3_beagle_init(void)
385 omap3_beagle_i2c_init();
386 platform_add_devices(omap3_beagle_devices,
387 ARRAY_SIZE(omap3_beagle_devices));
388 omap_board_config = omap3_beagle_config;
389 omap_board_config_size = ARRAY_SIZE(omap3_beagle_config);
392 omap_cfg_reg(AH8_34XX_GPIO29);
393 gpio_request(29, "mmc0_wp");
394 gpio_direction_input(29);
397 omap_cfg_reg(J25_34XX_GPIO170);
401 omap3beagle_flash_init();
402 beagle_display_init();
405 static void __init omap3_beagle_map_io(void)
407 omap2_set_globals_343x();
408 omap2_map_common_io();
411 MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
412 /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
413 .phys_io = 0x48000000,
414 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
415 .boot_params = 0x80000100,
416 .map_io = omap3_beagle_map_io,
417 .init_irq = omap3_beagle_init_irq,
418 .init_machine = omap3_beagle_init,
419 .timer = &omap_timer,