First Support on Ginger and OMAP TI
[linux-ginger.git] / arch / arm / mach-omap2 / board-omap3beagle.c
blobd0a95ea9c99e8eb8d2d062f98aec41503a987884
1 /*
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>
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>
27 #include <linux/mtd/mtd.h>
28 #include <linux/mtd/partitions.h>
29 #include <linux/mtd/nand.h>
31 #include <linux/regulator/machine.h>
32 #include <linux/i2c/twl4030.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 <plat/board.h>
41 #include <plat/common.h>
42 #include <plat/gpmc.h>
43 #include <plat/nand.h>
44 #include <plat/mux.h>
45 #include <plat/usb.h>
46 #include <plat/timer-gp.h>
47 #include <plat/clock.h>
48 #include <plat/omap-pm.h>
50 #include "mmc-twl4030.h"
51 #include "pm.h"
52 #include "omap3-opp.h"
54 #define GPMC_CS0_BASE 0x60
55 #define GPMC_CS_SIZE 0x30
57 #define NAND_BLOCK_SIZE SZ_128K
59 static struct mtd_partition omap3beagle_nand_partitions[] = {
60 /* All the partition sizes are listed in terms of NAND block size */
62 .name = "X-Loader",
63 .offset = 0,
64 .size = 4 * NAND_BLOCK_SIZE,
65 .mask_flags = MTD_WRITEABLE, /* force read-only */
68 .name = "U-Boot",
69 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
70 .size = 15 * NAND_BLOCK_SIZE,
71 .mask_flags = MTD_WRITEABLE, /* force read-only */
74 .name = "U-Boot Env",
75 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
76 .size = 1 * NAND_BLOCK_SIZE,
79 .name = "Kernel",
80 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
81 .size = 32 * NAND_BLOCK_SIZE,
84 .name = "File System",
85 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
86 .size = MTDPART_SIZ_FULL,
90 static struct omap_nand_platform_data omap3beagle_nand_data = {
91 .options = NAND_BUSWIDTH_16,
92 .parts = omap3beagle_nand_partitions,
93 .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions),
94 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
95 .nand_setup = NULL,
96 .dev_ready = NULL,
99 static struct resource omap3beagle_nand_resource = {
100 .flags = IORESOURCE_MEM,
103 static struct platform_device omap3beagle_nand_device = {
104 .name = "omap2-nand",
105 .id = -1,
106 .dev = {
107 .platform_data = &omap3beagle_nand_data,
109 .num_resources = 1,
110 .resource = &omap3beagle_nand_resource,
113 #include "sdram-micron-mt46h32m32lf-6.h"
115 static struct twl4030_hsmmc_info mmc[] = {
117 .mmc = 1,
118 .wires = 8,
119 .gpio_wp = 29,
121 {} /* Terminator */
124 static struct platform_device omap3_beagle_lcd_device = {
125 .name = "omap3beagle_lcd",
126 .id = -1,
129 static struct omap_lcd_config omap3_beagle_lcd_config __initdata = {
130 .ctrl_name = "internal",
133 static struct regulator_consumer_supply beagle_vmmc1_supply = {
134 .supply = "vmmc",
137 static struct regulator_consumer_supply beagle_vsim_supply = {
138 .supply = "vmmc_aux",
141 static struct gpio_led gpio_leds[];
143 static int beagle_twl_gpio_setup(struct device *dev,
144 unsigned gpio, unsigned ngpio)
146 if (system_rev >= 0x20 && system_rev <= 0x34301000) {
147 omap_cfg_reg(AG9_34XX_GPIO23);
148 mmc[0].gpio_wp = 23;
149 } else {
150 omap_cfg_reg(AH8_34XX_GPIO29);
152 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
153 mmc[0].gpio_cd = gpio + 0;
154 twl4030_mmc_init(mmc);
156 /* link regulators to MMC adapters */
157 beagle_vmmc1_supply.dev = mmc[0].dev;
158 beagle_vsim_supply.dev = mmc[0].dev;
160 /* REVISIT: need ehci-omap hooks for external VBUS
161 * power switch and overcurrent detect
164 gpio_request(gpio + 1, "EHCI_nOC");
165 gpio_direction_input(gpio + 1);
167 /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
168 gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
169 gpio_direction_output(gpio + TWL4030_GPIO_MAX, 1);
171 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
172 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
174 return 0;
177 static struct twl4030_gpio_platform_data beagle_gpio_data = {
178 .gpio_base = OMAP_MAX_GPIO_LINES,
179 .irq_base = TWL4030_GPIO_IRQ_BASE,
180 .irq_end = TWL4030_GPIO_IRQ_END,
181 .use_leds = true,
182 .pullups = BIT(1),
183 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
184 | BIT(15) | BIT(16) | BIT(17),
185 .setup = beagle_twl_gpio_setup,
188 static struct regulator_consumer_supply beagle_vdac_supply = {
189 .supply = "vdac",
190 .dev = &omap3_beagle_lcd_device.dev,
193 static struct regulator_consumer_supply beagle_vdvi_supply = {
194 .supply = "vdvi",
195 .dev = &omap3_beagle_lcd_device.dev,
198 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
199 static struct regulator_init_data beagle_vmmc1 = {
200 .constraints = {
201 .min_uV = 1850000,
202 .max_uV = 3150000,
203 .valid_modes_mask = REGULATOR_MODE_NORMAL
204 | REGULATOR_MODE_STANDBY,
205 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
206 | REGULATOR_CHANGE_MODE
207 | REGULATOR_CHANGE_STATUS,
209 .num_consumer_supplies = 1,
210 .consumer_supplies = &beagle_vmmc1_supply,
213 /* VSIM for MMC1 pins DAT4..DAT7 (2 mA, plus card == max 50 mA) */
214 static struct regulator_init_data beagle_vsim = {
215 .constraints = {
216 .min_uV = 1800000,
217 .max_uV = 3000000,
218 .valid_modes_mask = REGULATOR_MODE_NORMAL
219 | REGULATOR_MODE_STANDBY,
220 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE
221 | REGULATOR_CHANGE_MODE
222 | REGULATOR_CHANGE_STATUS,
224 .num_consumer_supplies = 1,
225 .consumer_supplies = &beagle_vsim_supply,
228 /* VDAC for DSS driving S-Video (8 mA unloaded, max 65 mA) */
229 static struct regulator_init_data beagle_vdac = {
230 .constraints = {
231 .min_uV = 1800000,
232 .max_uV = 1800000,
233 .valid_modes_mask = REGULATOR_MODE_NORMAL
234 | REGULATOR_MODE_STANDBY,
235 .valid_ops_mask = REGULATOR_CHANGE_MODE
236 | REGULATOR_CHANGE_STATUS,
238 .num_consumer_supplies = 1,
239 .consumer_supplies = &beagle_vdac_supply,
242 /* VPLL2 for digital video outputs */
243 static struct regulator_init_data beagle_vpll2 = {
244 .constraints = {
245 .name = "VDVI",
246 .min_uV = 1800000,
247 .max_uV = 1800000,
248 .valid_modes_mask = REGULATOR_MODE_NORMAL
249 | REGULATOR_MODE_STANDBY,
250 .valid_ops_mask = REGULATOR_CHANGE_MODE
251 | REGULATOR_CHANGE_STATUS,
253 .num_consumer_supplies = 1,
254 .consumer_supplies = &beagle_vdvi_supply,
257 static struct twl4030_usb_data beagle_usb_data = {
258 .usb_mode = T2_USB_MODE_ULPI,
261 static struct twl4030_platform_data beagle_twldata = {
262 .irq_base = TWL4030_IRQ_BASE,
263 .irq_end = TWL4030_IRQ_END,
265 /* platform_data for children goes here */
266 .usb = &beagle_usb_data,
267 .gpio = &beagle_gpio_data,
268 .vmmc1 = &beagle_vmmc1,
269 .vsim = &beagle_vsim,
270 .vdac = &beagle_vdac,
271 .vpll2 = &beagle_vpll2,
274 static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
276 I2C_BOARD_INFO("twl4030", 0x48),
277 .flags = I2C_CLIENT_WAKE,
278 .irq = INT_34XX_SYS_NIRQ,
279 .platform_data = &beagle_twldata,
283 static int __init omap3_beagle_i2c_init(void)
285 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
286 ARRAY_SIZE(beagle_i2c_boardinfo));
287 /* Bus 3 is attached to the DVI port where devices like the pico DLP
288 * projector don't work reliably with 400kHz */
289 omap_register_i2c_bus(3, 100, NULL, 0);
290 return 0;
293 static struct gpio_led gpio_leds[] = {
295 .name = "beagleboard::usr0",
296 .default_trigger = "heartbeat",
297 .gpio = 150,
300 .name = "beagleboard::usr1",
301 .default_trigger = "mmc0",
302 .gpio = 149,
305 .name = "beagleboard::pmu_stat",
306 .gpio = -EINVAL, /* gets replaced */
307 .active_low = true,
311 static struct gpio_led_platform_data gpio_led_info = {
312 .leds = gpio_leds,
313 .num_leds = ARRAY_SIZE(gpio_leds),
316 static struct platform_device leds_gpio = {
317 .name = "leds-gpio",
318 .id = -1,
319 .dev = {
320 .platform_data = &gpio_led_info,
324 static struct gpio_keys_button gpio_buttons[] = {
326 .code = BTN_EXTRA,
327 .gpio = 7,
328 .desc = "user",
329 .wakeup = 1,
333 static struct gpio_keys_platform_data gpio_key_info = {
334 .buttons = gpio_buttons,
335 .nbuttons = ARRAY_SIZE(gpio_buttons),
338 static struct platform_device keys_gpio = {
339 .name = "gpio-keys",
340 .id = -1,
341 .dev = {
342 .platform_data = &gpio_key_info,
346 static struct omap_board_config_kernel omap3_beagle_config[] __initdata = {
347 { OMAP_TAG_LCD, &omap3_beagle_lcd_config },
350 static void __init omap3_beagle_init_irq(void)
352 omap_board_config = omap3_beagle_config;
353 omap_board_config_size = ARRAY_SIZE(omap3_beagle_config);
354 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
355 mt46h32m32lf6_sdrc_params, omap3_mpu_rate_table,
356 omap3_dsp_rate_table, omap3_l3_rate_table);
357 omap_init_irq();
358 #ifdef CONFIG_OMAP_32K_TIMER
359 omap2_gp_clockevent_set_gptimer(12);
360 #endif
361 omap_gpio_init();
364 static struct platform_device *omap3_beagle_devices[] __initdata = {
365 &omap3_beagle_lcd_device,
366 &leds_gpio,
367 &keys_gpio,
370 static void __init omap3beagle_flash_init(void)
372 u8 cs = 0;
373 u8 nandcs = GPMC_CS_NUM + 1;
375 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
377 /* find out the chip-select on which NAND exists */
378 while (cs < GPMC_CS_NUM) {
379 u32 ret = 0;
380 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
382 if ((ret & 0xC00) == 0x800) {
383 printk(KERN_INFO "Found NAND on CS%d\n", cs);
384 if (nandcs > GPMC_CS_NUM)
385 nandcs = cs;
387 cs++;
390 if (nandcs > GPMC_CS_NUM) {
391 printk(KERN_INFO "NAND: Unable to find configuration "
392 "in GPMC\n ");
393 return;
396 if (nandcs < GPMC_CS_NUM) {
397 omap3beagle_nand_data.cs = nandcs;
398 omap3beagle_nand_data.gpmc_cs_baseaddr = (void *)
399 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
400 omap3beagle_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
402 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
403 if (platform_device_register(&omap3beagle_nand_device) < 0)
404 printk(KERN_ERR "Unable to register NAND device\n");
408 static struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
410 .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
411 .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
412 .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
414 .phy_reset = true,
415 .reset_gpio_port[0] = -EINVAL,
416 .reset_gpio_port[1] = 147,
417 .reset_gpio_port[2] = -EINVAL
420 static void __init omap3_beagle_init(void)
422 omap3_beagle_i2c_init();
423 platform_add_devices(omap3_beagle_devices,
424 ARRAY_SIZE(omap3_beagle_devices));
425 omap_serial_init();
427 omap_cfg_reg(J25_34XX_GPIO170);
428 gpio_request(170, "DVI_nPD");
429 /* REVISIT leave DVI powered down until it's needed ... */
430 gpio_direction_output(170, true);
432 usb_musb_init();
433 usb_ehci_init(&ehci_pdata);
434 omap3beagle_flash_init();
436 /* Ensure SDRC pins are mux'd for self-refresh */
437 omap_cfg_reg(H16_34XX_SDRC_CKE0);
438 omap_cfg_reg(H17_34XX_SDRC_CKE1);
441 static void __init omap3_beagle_map_io(void)
443 omap2_set_globals_343x();
444 omap2_map_common_io();
447 MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
448 /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
449 .phys_io = 0x48000000,
450 .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
451 .boot_params = 0x80000100,
452 .map_io = omap3_beagle_map_io,
453 .init_irq = omap3_beagle_init_irq,
454 .init_machine = omap3_beagle_init,
455 .timer = &omap_timer,
456 MACHINE_END