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