]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-overo.c
twl4030: linkage fix for generic power scripts
[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/mmc.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 twl4030_platform_data overo_twldata = {
161         .irq_base       = TWL4030_IRQ_BASE,
162         .irq_end        = TWL4030_IRQ_END,
163         .gpio           = &overo_gpio_data,
164         .usb            = &overo_usb_data,
165         .power          = GENERIC3430_T2SCRIPTS_DATA,
166 };
167
168 static struct i2c_board_info __initdata overo_i2c_boardinfo[] = {
169         {
170                 I2C_BOARD_INFO("tps65950", 0x48),
171                 .flags = I2C_CLIENT_WAKE,
172                 .irq = INT_34XX_SYS_NIRQ,
173                 .platform_data = &overo_twldata,
174         },
175 };
176
177 static int __init overo_i2c_init(void)
178 {
179         omap_register_i2c_bus(1, 2600, overo_i2c_boardinfo,
180                         ARRAY_SIZE(overo_i2c_boardinfo));
181         /* i2c2 pins are used for gpio */
182         omap_register_i2c_bus(3, 400, NULL, 0);
183         return 0;
184 }
185
186 static void __init overo_init_irq(void)
187 {
188         omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
189         omap_init_irq();
190         omap_gpio_init();
191 }
192
193 static struct platform_device overo_lcd_device = {
194         .name           = "overo_lcd",
195         .id             = -1,
196 };
197
198 static struct omap_lcd_config overo_lcd_config __initdata = {
199         .ctrl_name      = "internal",
200 };
201
202 static struct omap_board_config_kernel overo_config[] __initdata = {
203         { OMAP_TAG_UART,        &overo_uart_config },
204         { OMAP_TAG_LCD,         &overo_lcd_config },
205 };
206
207 static struct platform_device *overo_devices[] __initdata = {
208         &overo_lcd_device,
209 };
210
211 static struct twl4030_hsmmc_info mmc[] __initdata = {
212         {
213                 .mmc            = 1,
214                 .wires          = 4,
215                 .gpio_cd        = -EINVAL,
216                 .gpio_wp        = -EINVAL,
217         },
218         {
219                 .mmc            = 2,
220                 .wires          = 4,
221                 .gpio_cd        = -EINVAL,
222                 .gpio_wp        = -EINVAL,
223         },
224         {}      /* Terminator */
225 };
226
227 static void __init overo_init(void)
228 {
229         overo_i2c_init();
230         platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
231         omap_board_config = overo_config;
232         omap_board_config_size = ARRAY_SIZE(overo_config);
233         omap_serial_init();
234         hsmmc_init(mmc);
235         usb_musb_init();
236         usb_ehci_init();
237         overo_flash_init();
238
239         if ((gpio_request(OVERO_GPIO_W2W_NRESET,
240                           "OVERO_GPIO_W2W_NRESET") == 0) &&
241             (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
242                 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
243                 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
244                 udelay(10);
245                 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
246         } else {
247                 printk(KERN_ERR "could not obtain gpio for "
248                                         "OVERO_GPIO_W2W_NRESET\n");
249         }
250
251         if ((gpio_request(OVERO_GPIO_BT_XGATE, "OVERO_GPIO_BT_XGATE") == 0) &&
252             (gpio_direction_output(OVERO_GPIO_BT_XGATE, 0) == 0))
253                 gpio_export(OVERO_GPIO_BT_XGATE, 0);
254         else
255                 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_XGATE\n");
256
257         if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
258             (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
259                 gpio_export(OVERO_GPIO_BT_NRESET, 0);
260                 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
261                 mdelay(6);
262                 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
263         } else {
264                 printk(KERN_ERR "could not obtain gpio for "
265                                         "OVERO_GPIO_BT_NRESET\n");
266         }
267
268         if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
269             (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
270                 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
271         else
272                 printk(KERN_ERR "could not obtain gpio for "
273                                         "OVERO_GPIO_USBH_CPEN\n");
274
275         if ((gpio_request(OVERO_GPIO_USBH_NRESET,
276                           "OVERO_GPIO_USBH_NRESET") == 0) &&
277             (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
278                 gpio_export(OVERO_GPIO_USBH_NRESET, 0);
279         else
280                 printk(KERN_ERR "could not obtain gpio for "
281                                         "OVERO_GPIO_USBH_NRESET\n");
282 }
283
284 static void __init overo_map_io(void)
285 {
286         omap2_set_globals_343x();
287         omap2_map_common_io();
288 }
289
290 MACHINE_START(OVERO, "Gumstix Overo")
291         .phys_io        = 0x48000000,
292         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
293         .boot_params    = 0x80000100,
294         .map_io         = overo_map_io,
295         .init_irq       = overo_init_irq,
296         .init_machine   = overo_init,
297         .timer          = &omap_timer,
298 MACHINE_END