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