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