]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-overo.c
9995ac2ba1c12bc2efb2c29454083b1153dc67a0
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-overo.c
1 /*
2  * board-overo.c (Gumstix Overo)
3  *
4  * Initial code: Steve Sakoman <steve@sakoman.com>
5  *
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.
9  *
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.
14  *
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
19  *
20  */
21
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>
30
31 #include <linux/mtd/mtd.h>
32 #include <linux/mtd/nand.h>
33 #include <linux/mtd/partitions.h>
34
35 #include <asm/mach-types.h>
36 #include <asm/mach/arch.h>
37 #include <asm/mach/flash.h>
38 #include <asm/mach/map.h>
39
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>
47 #include <mach/usb-ehci.h>
48 #include <mach/usb-musb.h>
49
50 #include "sdram-micron-mt46h32m32lf-6.h"
51 #include "twl4030-generic-scripts.h"
52 #include "mmc-twl4030.h"
53
54 #define NAND_BLOCK_SIZE SZ_128K
55 #define GPMC_CS0_BASE  0x60
56 #define GPMC_CS_SIZE   0x30
57
58 static struct mtd_partition overo_nand_partitions[] = {
59         {
60                 .name           = "xloader",
61                 .offset         = 0,                    /* Offset = 0x00000 */
62                 .size           = 4 * NAND_BLOCK_SIZE,
63                 .mask_flags     = MTD_WRITEABLE
64         },
65         {
66                 .name           = "uboot",
67                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x80000 */
68                 .size           = 14 * NAND_BLOCK_SIZE,
69         },
70         {
71                 .name           = "uboot environment",
72                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x240000 */
73                 .size           = 2 * NAND_BLOCK_SIZE,
74         },
75         {
76                 .name           = "linux",
77                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x280000 */
78                 .size           = 32 * NAND_BLOCK_SIZE,
79         },
80         {
81                 .name           = "rootfs",
82                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x680000 */
83                 .size           = MTDPART_SIZ_FULL,
84         },
85 };
86
87 static struct omap_nand_platform_data overo_nand_data = {
88         .parts = overo_nand_partitions,
89         .nr_parts = ARRAY_SIZE(overo_nand_partitions),
90         .dma_channel = -1,      /* disable DMA in OMAP NAND driver */
91 };
92
93 static struct resource overo_nand_resource = {
94         .flags          = IORESOURCE_MEM,
95 };
96
97 static struct platform_device overo_nand_device = {
98         .name           = "omap2-nand",
99         .id             = -1,
100         .dev            = {
101                 .platform_data  = &overo_nand_data,
102         },
103         .num_resources  = 1,
104         .resource       = &overo_nand_resource,
105 };
106
107
108 static void __init overo_flash_init(void)
109 {
110         u8 cs = 0;
111         u8 nandcs = GPMC_CS_NUM + 1;
112
113         u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
114
115         /* find out the chip-select on which NAND exists */
116         while (cs < GPMC_CS_NUM) {
117                 u32 ret = 0;
118                 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
119
120                 if ((ret & 0xC00) == 0x800) {
121                         printk(KERN_INFO "Found NAND on CS%d\n", cs);
122                         if (nandcs > GPMC_CS_NUM)
123                                 nandcs = cs;
124                 }
125                 cs++;
126         }
127
128         if (nandcs > GPMC_CS_NUM) {
129                 printk(KERN_INFO "NAND: Unable to find configuration "
130                                  "in GPMC\n ");
131                 return;
132         }
133
134         if (nandcs < GPMC_CS_NUM) {
135                 overo_nand_data.cs = nandcs;
136                 overo_nand_data.gpmc_cs_baseaddr = (void *)
137                         (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
138                 overo_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
139
140                 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
141                 if (platform_device_register(&overo_nand_device) < 0)
142                         printk(KERN_ERR "Unable to register NAND device\n");
143         }
144 }
145 static struct omap_uart_config overo_uart_config __initdata = {
146         .enabled_uarts  = ((1 << 0) | (1 << 1) | (1 << 2)),
147 };
148
149 static struct twl4030_gpio_platform_data overo_gpio_data = {
150         .gpio_base      = OMAP_MAX_GPIO_LINES,
151         .irq_base       = TWL4030_GPIO_IRQ_BASE,
152         .irq_end        = TWL4030_GPIO_IRQ_END,
153 };
154
155 static struct twl4030_usb_data overo_usb_data = {
156         .usb_mode       = T2_USB_MODE_ULPI,
157 };
158
159 static struct twl4030_platform_data overo_twldata = {
160         .irq_base       = TWL4030_IRQ_BASE,
161         .irq_end        = TWL4030_IRQ_END,
162         .gpio           = &overo_gpio_data,
163         .usb            = &overo_usb_data,
164         .power          = GENERIC3430_T2SCRIPTS_DATA,
165 };
166
167 static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
168         {
169                 I2C_BOARD_INFO("tps65950", 0x48),
170                 .flags = I2C_CLIENT_WAKE,
171                 .irq = INT_34XX_SYS_NIRQ,
172                 .platform_data = &overo_twldata,
173         },
174 };
175
176 static int __init overo_i2c_init(void)
177 {
178         omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
179                         ARRAY_SIZE(overo_i2c_boardinfo));
180         /* i2c2 pins are used for gpio */
181         omap_register_i2c_bus(3, 400, NULL, 0);
182         return 0;
183 }
184
185 static void __init overo_init_irq(void)
186 {
187         omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
188         omap_init_irq();
189         omap_gpio_init();
190 }
191
192 static struct platform_device overo_lcd_device = {
193         .name           = "overo_lcd",
194         .id             = -1,
195 };
196
197 static struct omap_lcd_config overo_lcd_config __initdata = {
198         .ctrl_name      = "internal",
199 };
200
201 static struct omap_board_config_kernel overo_config[] __initdata = {
202         { OMAP_TAG_UART,        &overo_uart_config },
203         { OMAP_TAG_LCD,         &overo_lcd_config },
204 };
205
206 static struct platform_device *overo_devices[] __initdata = {
207         &overo_lcd_device,
208 };
209
210 static struct twl4030_hsmmc_info mmc[] __initdata = {
211         {
212                 .mmc            = 1,
213                 .wires          = 4,
214                 .gpio_cd        = -EINVAL,
215                 .gpio_wp        = -EINVAL,
216         },
217         {
218                 .mmc            = 2,
219                 .wires          = 4,
220                 .gpio_cd        = -EINVAL,
221                 .gpio_wp        = -EINVAL,
222         },
223         {}      /* Terminator */
224 };
225
226 static void __init overo_init(void)
227 {
228         overo_i2c_init();
229         platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
230         omap_board_config = overo_config;
231         omap_board_config_size = ARRAY_SIZE(overo_config);
232         omap_serial_init();
233         twl4030_mmc_init(mmc);
234         usb_musb_init();
235         usb_ehci_init();
236         overo_flash_init();
237
238         if ((gpio_request(OVERO_GPIO_W2W_NRESET,
239                           "OVERO_GPIO_W2W_NRESET") == 0) &&
240             (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
241                 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
242                 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
243                 udelay(10);
244                 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
245         } else {
246                 printk(KERN_ERR "could not obtain gpio for "
247                                         "OVERO_GPIO_W2W_NRESET\n");
248         }
249
250         if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
251             (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
252                 gpio_export(OVERO_GPIO_BT_XGATE, 0);
253         else
254                 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
255
256         if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
257             (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
258                 gpio_export(OVERO_GPIO_BT_NRESET, 0);
259                 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
260                 mdelay(6);
261                 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
262         } else {
263                 printk(KERN_ERR "could not obtain gpio for "
264                                         "OVERO_GPIO_BT_NRESET\n");
265         }
266
267         if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
268             (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
269                 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
270         else
271                 printk(KERN_ERR "could not obtain gpio for "
272                                         "OVERO_GPIO_USBH_CPEN\n");
273
274         if ((gpio_request(OVERO_GPIO_USBH_NRESET,
275                           "OVERO_GPIO_USBH_NRESET") == 0) &&
276             (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
277                 gpio_export(OVERO_GPIO_USBH_NRESET, 0);
278         else
279                 printk(KERN_ERR "could not obtain gpio for "
280                                         "OVERO_GPIO_USBH_NRESET\n");
281 }
282
283 static void __init overo_map_io(void)
284 {
285         omap2_set_globals_343x();
286         omap2_map_common_io();
287 }
288
289 MACHINE_START(OVERO, "Gumstix Overo")
290         .phys_io        = 0x48000000,
291         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
292         .boot_params    = 0x80000100,
293         .map_io         = overo_map_io,
294         .init_irq       = overo_init_irq,
295         .init_machine   = overo_init,
296         .timer          = &omap_timer,
297 MACHINE_END