]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-omap3pandora.c
HSMMC: Build fixes for earlier patches
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-omap3pandora.c
1 /*
2  * board-omap3pandora.c (Pandora Handheld Console)
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * version 2 as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
16  * 02110-1301 USA
17  *
18  */
19
20 #include <linux/clk.h>
21 #include <linux/delay.h>
22 #include <linux/err.h>
23 #include <linux/init.h>
24 #include <linux/io.h>
25 #include <linux/kernel.h>
26 #include <linux/platform_device.h>
27
28 #include <linux/i2c/twl4030.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.h>
40 #include <mach/common.h>
41 #include <mach/gpio.h>
42 #include <mach/gpmc.h>
43 #include <mach/hardware.h>
44 #include <mach/mmc.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 #include "mmc-twl4030.h"
51
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 omap3pandora_nand_partitions[] = {
58         {
59                 .name           = "xloader",
60                 .offset         = 0,                    /* Offset = 0x00000 */
61                 .size           = 4 * NAND_BLOCK_SIZE,
62                 .mask_flags     = MTD_WRITEABLE
63         }, {
64                 .name           = "uboot",
65                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x80000 */
66                 .size           = 14 * NAND_BLOCK_SIZE,
67         }, {
68                 .name           = "uboot environment",
69                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x240000 */
70                 .size           = 2 * NAND_BLOCK_SIZE,
71         }, {
72                 .name           = "linux",
73                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x280000 */
74                 .size           = 32 * NAND_BLOCK_SIZE,
75         }, {
76                 .name           = "rootfs",
77                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x680000 */
78                 .size           = MTDPART_SIZ_FULL,
79         },
80 };
81
82 static struct omap_nand_platform_data omap3pandora_nand_data = {
83         .parts          = omap3pandora_nand_partitions,
84         .nr_parts       = ARRAY_SIZE(omap3pandora_nand_partitions),
85         .dma_channel    = -1,   /* disable DMA in OMAP NAND driver */
86 };
87
88 static struct resource omap3pandora_nand_resource[] = {
89         {
90                 .flags          = IORESOURCE_MEM,
91         },
92 };
93
94 static struct platform_device omap3pandora_nand_device = {
95         .name           = "omap2-nand",
96         .id             = -1,
97         .dev            = {
98                 .platform_data  = &omap3pandora_nand_data,
99         },
100         .num_resources  = ARRAY_SIZE(omap3pandora_nand_resource),
101         .resource       = omap3pandora_nand_resource,
102 };
103
104 static void __init omap3pandora_flash_init(void)
105 {
106         u8 cs = 0;
107         u8 nandcs = GPMC_CS_NUM + 1;
108
109         u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
110
111         /* find out the chip-select on which NAND exists */
112         while (cs < GPMC_CS_NUM) {
113                 u32 ret = 0;
114                 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
115
116                 if ((ret & 0xC00) == 0x800) {
117                         printk(KERN_INFO "Found NAND on CS%d\n", cs);
118                         if (nandcs > GPMC_CS_NUM)
119                                 nandcs = cs;
120                 }
121                 cs++;
122         }
123
124         if (nandcs > GPMC_CS_NUM) {
125                 printk(KERN_INFO "NAND: Unable to find configuration "
126                                  "in GPMC\n ");
127                 return;
128         }
129
130         if (nandcs < GPMC_CS_NUM) {
131                 omap3pandora_nand_data.cs = nandcs;
132                 omap3pandora_nand_data.gpmc_cs_baseaddr = (void *)
133                         (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
134                 omap3pandora_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
135
136                 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
137                 if (platform_device_register(&omap3pandora_nand_device) < 0)
138                         printk(KERN_ERR "Unable to register NAND device\n");
139         }
140 }
141
142 static struct omap_uart_config omap3pandora_uart_config __initdata = {
143         .enabled_uarts  = (1 << 2), /* UART3 */
144 };
145
146 static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
147         .gpio_base      = OMAP_MAX_GPIO_LINES,
148         .irq_base       = TWL4030_GPIO_IRQ_BASE,
149         .irq_end        = TWL4030_GPIO_IRQ_END,
150 };
151
152 static struct twl4030_usb_data omap3pandora_usb_data = {
153         .usb_mode       = T2_USB_MODE_ULPI,
154 };
155
156 static struct twl4030_platform_data omap3pandora_twldata = {
157         .irq_base       = TWL4030_IRQ_BASE,
158         .irq_end        = TWL4030_IRQ_END,
159         .gpio           = &omap3pandora_gpio_data,
160         .usb            = &omap3pandora_usb_data,
161 };
162
163 static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
164         {
165                 I2C_BOARD_INFO("twl4030", 0x48),
166                 .flags = I2C_CLIENT_WAKE,
167                 .irq = INT_34XX_SYS_NIRQ,
168                 .platform_data = &omap3pandora_twldata,
169         },
170 };
171
172 static int __init omap3pandora_i2c_init(void)
173 {
174         omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
175                         ARRAY_SIZE(omap3pandora_i2c_boardinfo));
176         /* i2c2 pins are not connected */
177         omap_register_i2c_bus(3, 400, NULL, 0);
178         return 0;
179 }
180
181 static void __init omap3pandora_init_irq(void)
182 {
183         omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
184         omap_init_irq();
185         omap_gpio_init();
186 }
187
188 static struct platform_device omap3pandora_lcd_device = {
189         .name           = "pandora_lcd",
190         .id             = -1,
191 };
192
193 static struct omap_lcd_config omap3pandora_lcd_config __initdata = {
194         .ctrl_name      = "internal",
195 };
196
197 static struct omap_board_config_kernel omap3pandora_config[] __initdata = {
198         { OMAP_TAG_UART,        &omap3pandora_uart_config },
199         { OMAP_TAG_LCD,         &omap3pandora_lcd_config },
200 };
201
202 static struct platform_device *omap3pandora_devices[] __initdata = {
203         &omap3pandora_lcd_device,
204 };
205
206 static struct twl4030_hsmmc_info mmc[] __initdata = {
207         {
208                 .mmc            = 1,
209                 .wires          = 4,
210                 .gpio_cd        = -EINVAL,
211         },
212         {}      /* Terminator */
213 };
214
215 static void __init omap3pandora_init(void)
216 {
217         omap3pandora_i2c_init();
218         platform_add_devices(omap3pandora_devices, ARRAY_SIZE(omap3pandora_devices));
219         omap_board_config = omap3pandora_config;
220         omap_board_config_size = ARRAY_SIZE(omap3pandora_config);
221         omap_serial_init();
222         hsmmc_init(mmc);
223         usb_musb_init();
224         usb_ehci_init();
225         omap3pandora_flash_init();
226 }
227
228 static void __init omap3pandora_map_io(void)
229 {
230         omap2_set_globals_343x();
231         omap2_map_common_io();
232 }
233
234 MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
235         .phys_io        = 0x48000000,
236         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
237         .boot_params    = 0x80000100,
238         .map_io         = omap3pandora_map_io,
239         .init_irq       = omap3pandora_init_irq,
240         .init_machine   = omap3pandora_init,
241         .timer          = &omap_timer,
242 MACHINE_END