]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-overo.c
ARM: OMAP: Clean-up MMC device init
[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 platform_device overo_twl4030rtc_device = {
162         .name           = "twl4030_rtc",
163         .id             = -1,
164 };
165
166 static struct platform_device overo_lcd_device = {
167         .name           = "overo_lcd",
168         .id             = -1,
169 };
170
171 static struct omap_lcd_config overo_lcd_config __initdata = {
172         .ctrl_name      = "internal",
173 };
174
175 static struct omap_board_config_kernel overo_config[] __initdata = {
176         { OMAP_TAG_UART,        &overo_uart_config },
177         { OMAP_TAG_LCD,         &overo_lcd_config },
178 };
179
180 static struct platform_device *overo_devices[] __initdata = {
181         &overo_lcd_device,
182 #ifdef CONFIG_RTC_DRV_TWL4030
183         &overo_twl4030rtc_device,
184 #endif
185 };
186
187 static void __init overo_init(void)
188 {
189         overo_i2c_init();
190         platform_add_devices(overo_devices, ARRAY_SIZE(overo_devices));
191         omap_board_config = overo_config;
192         omap_board_config_size = ARRAY_SIZE(overo_config);
193         omap_serial_init();
194         hsmmc_init();
195         usb_musb_init();
196         usb_ehci_init();
197         overo_flash_init();
198
199         if ((gpio_request(OVERO_GPIO_W2W_NRESET,
200                           "OVERO_GPIO_W2W_NRESET") == 0) &&
201             (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
202                 gpio_export(OVERO_GPIO_W2W_NRESET, 0);
203                 gpio_set_value(OVERO_GPIO_W2W_NRESET, 0);
204                 udelay(10);
205                 gpio_set_value(OVERO_GPIO_W2W_NRESET, 1);
206         } else {
207                 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_W2W_NRESET\n");
208         }
209
210         if ((gpio_request(OVERO_GPIO_BT_NRESET, "OVERO_GPIO_BT_NRESET") == 0) &&
211             (gpio_direction_output(OVERO_GPIO_BT_NRESET, 1) == 0)) {
212                 gpio_export(OVERO_GPIO_BT_NRESET, 0);
213                 gpio_set_value(OVERO_GPIO_BT_NRESET, 0);
214                 mdelay(6);
215                 gpio_set_value(OVERO_GPIO_BT_NRESET, 1);
216         } else {
217                 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_BT_NRESET\n");
218         }
219
220         if ((gpio_request(OVERO_GPIO_USBH_CPEN, "OVERO_GPIO_USBH_CPEN") == 0) &&
221             (gpio_direction_output(OVERO_GPIO_USBH_CPEN, 1) == 0))
222                 gpio_export(OVERO_GPIO_USBH_CPEN, 0);
223         else
224                 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_USBH_CPEN\n");
225
226         if ((gpio_request(OVERO_GPIO_USBH_NRESET,
227                           "OVERO_GPIO_USBH_NRESET") == 0) &&
228             (gpio_direction_output(OVERO_GPIO_USBH_NRESET, 1) == 0))
229                 gpio_export(OVERO_GPIO_USBH_NRESET, 0);
230         else
231                 printk(KERN_ERR "could not obtain gpio for OVERO_GPIO_USBH_NRESET\n");
232 }
233
234 static void __init overo_map_io(void)
235 {
236         omap2_set_globals_343x();
237         omap2_map_common_io();
238 }
239
240 MACHINE_START(OVERO, "Gumstix Overo")
241         .phys_io        = 0x48000000,
242         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
243         .boot_params    = 0x80000100,
244         .map_io         = overo_map_io,
245         .init_irq       = overo_init_irq,
246         .init_machine   = overo_init,
247         .timer          = &omap_timer,
248 MACHINE_END