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