blob: f25082c53c678d9c9c15e0333ff63b8940b1a40f [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
Tony Lindgren145d9c92009-01-15 13:09:53 +020031#include <linux/i2c/twl4030.h>
32
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +030033#include <mach/hardware.h>
34#include <asm/mach-types.h>
35#include <asm/mach/arch.h>
36#include <asm/mach/map.h>
37#include <asm/mach/flash.h>
38
39#include <mach/board.h>
40#include <mach/common.h>
41#include <mach/gpmc.h>
42#include <mach/nand.h>
Tony Lindgren90c62bf2008-12-10 17:37:17 -080043#include <mach/mux.h>
Felipe Balbi18cb7ac2009-03-23 18:34:06 -070044#include <mach/usb.h>
Paul Walmsleyf2480762009-04-23 21:11:10 -060045#include <mach/timer-gp.h>
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +030046
Tony Lindgren90c62bf2008-12-10 17:37:17 -080047#include "mmc-twl4030.h"
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +030048
49#define GPMC_CS0_BASE 0x60
50#define GPMC_CS_SIZE 0x30
51
52#define NAND_BLOCK_SIZE SZ_128K
53
54static struct mtd_partition omap3beagle_nand_partitions[] = {
55 /* All the partition sizes are listed in terms of NAND block size */
56 {
57 .name = "X-Loader",
58 .offset = 0,
59 .size = 4 * NAND_BLOCK_SIZE,
60 .mask_flags = MTD_WRITEABLE, /* force read-only */
61 },
62 {
63 .name = "U-Boot",
64 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
65 .size = 15 * NAND_BLOCK_SIZE,
66 .mask_flags = MTD_WRITEABLE, /* force read-only */
67 },
68 {
69 .name = "U-Boot Env",
70 .offset = MTDPART_OFS_APPEND, /* Offset = 0x260000 */
71 .size = 1 * NAND_BLOCK_SIZE,
72 },
73 {
74 .name = "Kernel",
75 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
76 .size = 32 * NAND_BLOCK_SIZE,
77 },
78 {
79 .name = "File System",
80 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
81 .size = MTDPART_SIZ_FULL,
82 },
83};
84
85static struct omap_nand_platform_data omap3beagle_nand_data = {
86 .options = NAND_BUSWIDTH_16,
87 .parts = omap3beagle_nand_partitions,
88 .nr_parts = ARRAY_SIZE(omap3beagle_nand_partitions),
89 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
90 .nand_setup = NULL,
91 .dev_ready = NULL,
92};
93
94static struct resource omap3beagle_nand_resource = {
95 .flags = IORESOURCE_MEM,
96};
97
98static struct platform_device omap3beagle_nand_device = {
99 .name = "omap2-nand",
100 .id = -1,
101 .dev = {
102 .platform_data = &omap3beagle_nand_data,
103 },
104 .num_resources = 1,
105 .resource = &omap3beagle_nand_resource,
106};
107
Paul Walmsley2e12bd72009-05-28 14:03:59 -0700108#include "sdram-micron-mt46h32m32lf-6.h"
109
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300110static struct omap_uart_config omap3_beagle_uart_config __initdata = {
111 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
112};
113
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800114static struct twl4030_hsmmc_info mmc[] = {
115 {
116 .mmc = 1,
117 .wires = 8,
118 .gpio_wp = 29,
119 },
120 {} /* Terminator */
121};
122
123static struct gpio_led gpio_leds[];
124
125static int beagle_twl_gpio_setup(struct device *dev,
126 unsigned gpio, unsigned ngpio)
127{
128 /* gpio + 0 is "mmc0_cd" (input/IRQ) */
Tony Lindgren145d9c92009-01-15 13:09:53 +0200129 omap_cfg_reg(AH8_34XX_GPIO29);
130 mmc[0].gpio_cd = gpio + 0;
131 twl4030_mmc_init(mmc);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800132
133 /* REVISIT: need ehci-omap hooks for external VBUS
134 * power switch and overcurrent detect
135 */
136
137 gpio_request(gpio + 1, "EHCI_nOC");
138 gpio_direction_input(gpio + 1);
139
140 /* TWL4030_GPIO_MAX + 0 == ledA, EHCI nEN_USB_PWR (out, active low) */
141 gpio_request(gpio + TWL4030_GPIO_MAX, "nEN_USB_PWR");
142 gpio_direction_output(gpio + TWL4030_GPIO_MAX, 1);
143
144 /* TWL4030_GPIO_MAX + 1 == ledB, PMU_STAT (out, active low LED) */
145 gpio_leds[2].gpio = gpio + TWL4030_GPIO_MAX + 1;
146
147 return 0;
148}
149
150static struct twl4030_gpio_platform_data beagle_gpio_data = {
151 .gpio_base = OMAP_MAX_GPIO_LINES,
152 .irq_base = TWL4030_GPIO_IRQ_BASE,
153 .irq_end = TWL4030_GPIO_IRQ_END,
154 .use_leds = true,
155 .pullups = BIT(1),
156 .pulldowns = BIT(2) | BIT(6) | BIT(7) | BIT(8) | BIT(13)
157 | BIT(15) | BIT(16) | BIT(17),
158 .setup = beagle_twl_gpio_setup,
159};
160
161static struct twl4030_platform_data beagle_twldata = {
162 .irq_base = TWL4030_IRQ_BASE,
163 .irq_end = TWL4030_IRQ_END,
164
165 /* platform_data for children goes here */
166 .gpio = &beagle_gpio_data,
167};
168
169static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = {
170 {
171 I2C_BOARD_INFO("twl4030", 0x48),
172 .flags = I2C_CLIENT_WAKE,
173 .irq = INT_34XX_SYS_NIRQ,
174 .platform_data = &beagle_twldata,
175 },
176};
177
178static int __init omap3_beagle_i2c_init(void)
179{
180 omap_register_i2c_bus(1, 2600, beagle_i2c_boardinfo,
181 ARRAY_SIZE(beagle_i2c_boardinfo));
Koen Kooi8ca7fe22009-03-04 10:07:42 -0800182 /* Bus 3 is attached to the DVI port where devices like the pico DLP
183 * projector don't work reliably with 400kHz */
184 omap_register_i2c_bus(3, 100, NULL, 0);
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800185 return 0;
186}
187
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300188static void __init omap3_beagle_init_irq(void)
189{
Paul Walmsley2e12bd72009-05-28 14:03:59 -0700190 omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300191 omap_init_irq();
Paul Walmsleyf2480762009-04-23 21:11:10 -0600192#ifdef CONFIG_OMAP_32K_TIMER
193 omap2_gp_clockevent_set_gptimer(12);
194#endif
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300195 omap_gpio_init();
196}
197
198static struct platform_device omap3_beagle_lcd_device = {
199 .name = "omap3beagle_lcd",
200 .id = -1,
201};
202
203static struct omap_lcd_config omap3_beagle_lcd_config __initdata = {
204 .ctrl_name = "internal",
205};
206
207static struct gpio_led gpio_leds[] = {
208 {
209 .name = "beagleboard::usr0",
210 .default_trigger = "heartbeat",
211 .gpio = 150,
212 },
213 {
214 .name = "beagleboard::usr1",
215 .default_trigger = "mmc0",
216 .gpio = 149,
217 },
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800218 {
219 .name = "beagleboard::pmu_stat",
220 .gpio = -EINVAL, /* gets replaced */
221 .active_low = true,
222 },
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300223};
224
225static struct gpio_led_platform_data gpio_led_info = {
226 .leds = gpio_leds,
227 .num_leds = ARRAY_SIZE(gpio_leds),
228};
229
230static struct platform_device leds_gpio = {
231 .name = "leds-gpio",
232 .id = -1,
233 .dev = {
234 .platform_data = &gpio_led_info,
235 },
236};
237
238static struct gpio_keys_button gpio_buttons[] = {
239 {
240 .code = BTN_EXTRA,
241 .gpio = 7,
242 .desc = "user",
243 .wakeup = 1,
244 },
245};
246
247static struct gpio_keys_platform_data gpio_key_info = {
248 .buttons = gpio_buttons,
249 .nbuttons = ARRAY_SIZE(gpio_buttons),
250};
251
252static struct platform_device keys_gpio = {
253 .name = "gpio-keys",
254 .id = -1,
255 .dev = {
256 .platform_data = &gpio_key_info,
257 },
258};
259
260static struct omap_board_config_kernel omap3_beagle_config[] __initdata = {
261 { OMAP_TAG_UART, &omap3_beagle_uart_config },
262 { OMAP_TAG_LCD, &omap3_beagle_lcd_config },
263};
264
265static struct platform_device *omap3_beagle_devices[] __initdata = {
266 &omap3_beagle_lcd_device,
267 &leds_gpio,
268 &keys_gpio,
269};
270
271static void __init omap3beagle_flash_init(void)
272{
273 u8 cs = 0;
274 u8 nandcs = GPMC_CS_NUM + 1;
275
276 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
277
278 /* find out the chip-select on which NAND exists */
279 while (cs < GPMC_CS_NUM) {
280 u32 ret = 0;
281 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
282
283 if ((ret & 0xC00) == 0x800) {
284 printk(KERN_INFO "Found NAND on CS%d\n", cs);
285 if (nandcs > GPMC_CS_NUM)
286 nandcs = cs;
287 }
288 cs++;
289 }
290
291 if (nandcs > GPMC_CS_NUM) {
292 printk(KERN_INFO "NAND: Unable to find configuration "
293 "in GPMC\n ");
294 return;
295 }
296
297 if (nandcs < GPMC_CS_NUM) {
298 omap3beagle_nand_data.cs = nandcs;
299 omap3beagle_nand_data.gpmc_cs_baseaddr = (void *)
300 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
301 omap3beagle_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
302
303 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
304 if (platform_device_register(&omap3beagle_nand_device) < 0)
305 printk(KERN_ERR "Unable to register NAND device\n");
306 }
307}
308
309static void __init omap3_beagle_init(void)
310{
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800311 omap3_beagle_i2c_init();
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300312 platform_add_devices(omap3_beagle_devices,
313 ARRAY_SIZE(omap3_beagle_devices));
314 omap_board_config = omap3_beagle_config;
315 omap_board_config_size = ARRAY_SIZE(omap3_beagle_config);
316 omap_serial_init();
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800317
Tony Lindgren90c62bf2008-12-10 17:37:17 -0800318 omap_cfg_reg(J25_34XX_GPIO170);
319 gpio_request(170, "DVI_nPD");
320 /* REVISIT leave DVI powered down until it's needed ... */
321 gpio_direction_output(170, true);
322
Felipe Balbi18cb7ac2009-03-23 18:34:06 -0700323 usb_musb_init();
Syed Mohammed, Khasim2885f002008-10-09 17:51:42 +0300324 omap3beagle_flash_init();
325}
326
327static void __init omap3_beagle_map_io(void)
328{
329 omap2_set_globals_343x();
330 omap2_map_common_io();
331}
332
333MACHINE_START(OMAP3_BEAGLE, "OMAP3 Beagle Board")
334 /* Maintainer: Syed Mohammed Khasim - http://beagleboard.org */
335 .phys_io = 0x48000000,
336 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
337 .boot_params = 0x80000100,
338 .map_io = omap3_beagle_map_io,
339 .init_irq = omap3_beagle_init_irq,
340 .init_machine = omap3_beagle_init,
341 .timer = &omap_timer,
342MACHINE_END