]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-overo.c
4e2781a019f33a76583e975585648e9c2efa0e26
[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/i2c/twl4030.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/hsmmc.h>
48 #include <mach/nand.h>
49 #include <mach/usb-ehci.h>
50 #include <mach/usb-musb.h>
51
52 #include "sdram-micron-mt46h32m32lf-6.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 static struct twl4030_gpio_platform_data overo_gpio_data = {
149         .gpio_base      = OMAP_MAX_GPIO_LINES,
150         .irq_base       = TWL4030_GPIO_IRQ_BASE,
151         .irq_end        = TWL4030_GPIO_IRQ_END,
152 };
153
154 static struct twl4030_usb_data overo_usb_data = {
155         .usb_mode       = T2_USB_MODE_ULPI,
156 };
157
158 static struct twl4030_platform_data overo_twldata = {
159         .irq_base       = TWL4030_IRQ_BASE,
160         .irq_end        = TWL4030_IRQ_END,
161         .gpio           = &overo_gpio_data,
162         .usb            = &overo_usb_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