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