added 2.6.29.6 aldebaran kernel
[nao-ulib.git] / kernel / 2.6.29.6-aldebaran-rt / arch / arm / mach-omap2 / board-overo.c
blob82b3dc557c96736764f6fdbb235cf1f930a0a2a3
1 /*
2 * board-overo.c (Gumstix Overo)
4 * Initial code: Steve Sakoman <steve@sakoman.com>
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * version 2 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
22 #include <linux/clk.h>
23 #include <linux/delay.h>
24 #include <linux/err.h>
25 #include <linux/init.h>
26 #include <linux/io.h>
27 #include <linux/kernel.h>
28 #include <linux/platform_device.h>
29 #include <linux/i2c/twl4030.h>
31 #include <linux/mtd/mtd.h>
32 #include <linux/mtd/nand.h>
33 #include <linux/mtd/partitions.h>
35 #include <asm/mach-types.h>
36 #include <asm/mach/arch.h>
37 #include <asm/mach/flash.h>
38 #include <asm/mach/map.h>
40 #include <mach/board-overo.h>
41 #include <mach/board.h>
42 #include <mach/common.h>
43 #include <mach/gpio.h>
44 #include <mach/gpmc.h>
45 #include <mach/hardware.h>
46 #include <mach/nand.h>
48 #include "mmc-twl4030.h"
50 #define NAND_BLOCK_SIZE SZ_128K
51 #define GPMC_CS0_BASE 0x60
52 #define GPMC_CS_SIZE 0x30
54 static struct mtd_partition overo_nand_partitions[] = {
56 .name = "xloader",
57 .offset = 0, /* Offset = 0x00000 */
58 .size = 4 * NAND_BLOCK_SIZE,
59 .mask_flags = MTD_WRITEABLE
62 .name = "uboot",
63 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
64 .size = 14 * NAND_BLOCK_SIZE,
67 .name = "uboot environment",
68 .offset = MTDPART_OFS_APPEND, /* Offset = 0x240000 */
69 .size = 2 * NAND_BLOCK_SIZE,
72 .name = "linux",
73 .offset = MTDPART_OFS_APPEND, /* Offset = 0x280000 */
74 .size = 32 * NAND_BLOCK_SIZE,
77 .name = "rootfs",
78 .offset = MTDPART_OFS_APPEND, /* Offset = 0x680000 */
79 .size = MTDPART_SIZ_FULL,
83 static struct omap_nand_platform_data overo_nand_data = {
84 .parts = overo_nand_partitions,
85 .nr_parts = ARRAY_SIZE(overo_nand_partitions),
86 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
89 static struct resource overo_nand_resource = {
90 .flags = IORESOURCE_MEM,
93 static struct platform_device overo_nand_device = {
94 .name = "omap2-nand",
95 .id = -1,
96 .dev = {
97 .platform_data = &overo_nand_data,
99 .num_resources = 1,
100 .resource = &overo_nand_resource,
104 static void __init overo_flash_init(void)
106 u8 cs = 0;
107 u8 nandcs = GPMC_CS_NUM + 1;
109 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
111 /* find out the chip-select on which NAND exists */
112 while (cs < GPMC_CS_NUM) {
113 u32 ret = 0;
114 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
116 if ((ret & 0xC00) == 0x800) {
117 printk(KERN_INFO "Found NAND on CS%d\n", cs);
118 if (nandcs > GPMC_CS_NUM)
119 nandcs = cs;
121 cs++;
124 if (nandcs > GPMC_CS_NUM) {
125 printk(KERN_INFO "NAND: Unable to find configuration "
126 "in GPMC\n ");
127 return;
130 if (nandcs < GPMC_CS_NUM) {
131 overo_nand_data.cs = nandcs;
132 overo_nand_data.gpmc_cs_baseaddr = (void *)
133 (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
134 overo_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
136 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
137 if (platform_device_register(&overo_nand_device) < 0)
138 printk(KERN_ERR "Unable to register NAND device\n");
141 static struct omap_uart_config overo_uart_config __initdata = {
142 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
145 static struct twl4030_gpio_platform_data overo_gpio_data = {
146 .gpio_base = OMAP_MAX_GPIO_LINES,
147 .irq_base = TWL4030_GPIO_IRQ_BASE,
148 .irq_end = TWL4030_GPIO_IRQ_END,
151 static struct twl4030_platform_data overo_twldata = {
152 .irq_base = TWL4030_IRQ_BASE,
153 .irq_end = TWL4030_IRQ_END,
154 .gpio = &overo_gpio_data,
157 static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
159 I2C_BOARD_INFO("twl4030", 0x48),
160 .flags = I2C_CLIENT_WAKE,
161 .irq = INT_34XX_SYS_NIRQ,
162 .platform_data = &overo_twldata,
166 static int __init overo_i2c_init(void)
168 omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
169 ARRAY_SIZE(overo_i2c_boardinfo));
170 /* i2c2 pins are used for gpio */
171 omap_register_i2c_bus(3, 400, NULL, 0);
172 return 0;
175 static void __init overo_init_irq(void)
177 omap2_init_common_hw();
178 omap_init_irq();
179 omap_gpio_init();
182 static struct platform_device overo_lcd_device = {
183 .name = "overo_lcd",
184 .id = -1,
187 static struct omap_lcd_config overo_lcd_config __initdata = {
188 .ctrl_name = "internal",
191 static struct omap_board_config_kernel overo_config[] __initdata = {
192 { OMAP_TAG_UART, &overo_uart_config },
193 { OMAP_TAG_LCD, &overo_lcd_config },
196 static struct platform_device *overo_devices[] __initdata = {
197 &overo_lcd_device,
200 static struct twl4030_hsmmc_info mmc[] __initdata = {
202 .mmc = 1,
203 .wires = 4,
204 .gpio_cd = -EINVAL,
205 .gpio_wp = -EINVAL,
208 .mmc = 2,
209 .wires = 4,
210 .gpio_cd = -EINVAL,
211 .gpio_wp = -EINVAL,
213 {} /* Terminator */
216 static void __init overo_init(void)
218 overo_i2c_init();
219 platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
220 omap_board_config = overo_config;
221 omap_board_config_size = ARRAY_SIZE(overo_config);
222 omap_serial_init();
223 twl4030_mmc_init(mmc);
224 overo_flash_init();
226 if ((gpio_request(OVERO_GPIO_W2W_NRESET,
227 "OVERO_GPIO_W2W_NRESET") == 0) &&
228 (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
229 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
230 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
231 udelay(10);
232 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
233 } else {
234 printk(KERN_ERR "could not obtain gpio for "
235 "OVERO_GPIO_W2W_NRESET\n");
238 if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
239 (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
240 gpio_export(OVERO_GPIO_BT_XGATE, 0);
241 else
242 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
244 if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
245 (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
246 gpio_export(OVERO_GPIO_BT_NRESET, 0);
247 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
248 mdelay(6);
249 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
250 } else {
251 printk(KERN_ERR "could not obtain gpio for "
252 "OVERO_GPIO_BT_NRESET\n");
255 if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
256 (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
257 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
258 else
259 printk(KERN_ERR "could not obtain gpio for "
260 "OVERO_GPIO_USBH_CPEN\n");
262 if ((gpio_request(OVERO_GPIO_USBH_NRESET,
263 "OVERO_GPIO_USBH_NRESET") == 0) &&
264 (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
265 gpio_export(OVERO_GPIO_USBH_NRESET, 0);
266 else
267 printk(KERN_ERR "could not obtain gpio for "
268 "OVERO_GPIO_USBH_NRESET\n");
271 static void __init overo_map_io(void)
273 omap2_set_globals_343x();
274 omap2_map_common_io();
277 MACHINE_START(OVERO, "Gumstix Overo")
278 .phys_io = 0x48000000,
279 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
280 .boot_params = 0x80000100,
281 .map_io = overo_map_io,
282 .init_irq = overo_init_irq,
283 .init_machine = overo_init,
284 .timer = &omap_timer,
285 MACHINE_END