]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-omap3pandora.c
omap: Add basic support for Pandora handheld console
[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/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 omap3pandora_nand_partitions[] = {
56         {
57                 .name           = "xloader",
58                 .offset         = 0,                    /* Offset = 0x00000 */
59                 .size           = 4 * NAND_BLOCK_SIZE,
60                 .mask_flags     = MTD_WRITEABLE
61         }, {
62                 .name           = "uboot",
63                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x80000 */
64                 .size           = 14 * NAND_BLOCK_SIZE,
65         }, {
66                 .name           = "uboot environment",
67                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x240000 */
68                 .size           = 2 * NAND_BLOCK_SIZE,
69         }, {
70                 .name           = "linux",
71                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x280000 */
72                 .size           = 32 * NAND_BLOCK_SIZE,
73         }, {
74                 .name           = "rootfs",
75                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x680000 */
76                 .size           = MTDPART_SIZ_FULL,
77         },
78 };
79
80 static struct omap_nand_platform_data omap3pandora_nand_data = {
81         .parts          = omap3pandora_nand_partitions,
82         .nr_parts       = ARRAY_SIZE(omap3pandora_nand_partitions),
83         .dma_channel    = -1,   /* disable DMA in OMAP NAND driver */
84 };
85
86 static struct resource omap3pandora_nand_resource[] = {
87         {
88                 .flags          = IORESOURCE_MEM,
89         },
90 };
91
92 static struct platform_device omap3pandora_nand_device = {
93         .name           = "omap2-nand",
94         .id             = -1,
95         .dev            = {
96                 .platform_data  = &omap3pandora_nand_data,
97         },
98         .num_resources  = ARRAY_SIZE(omap3pandora_nand_resource),
99         .resource       = omap3pandora_nand_resource,
100 };
101
102 static void __init omap3pandora_flash_init(void)
103 {
104         u8 cs = 0;
105         u8 nandcs = GPMC_CS_NUM + 1;
106
107         u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
108
109         /* find out the chip-select on which NAND exists */
110         while (cs < GPMC_CS_NUM) {
111                 u32 ret = 0;
112                 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
113
114                 if ((ret & 0xC00) == 0x800) {
115                         printk(KERN_INFO "Found NAND on CS%d\n", cs);
116                         if (nandcs > GPMC_CS_NUM)
117                                 nandcs = cs;
118                 }
119                 cs++;
120         }
121
122         if (nandcs > GPMC_CS_NUM) {
123                 printk(KERN_INFO "NAND: Unable to find configuration "
124                                  "in GPMC\n ");
125                 return;
126         }
127
128         if (nandcs < GPMC_CS_NUM) {
129                 omap3pandora_nand_data.cs = nandcs;
130                 omap3pandora_nand_data.gpmc_cs_baseaddr = (void *)
131                         (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
132                 omap3pandora_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
133
134                 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
135                 if (platform_device_register(&omap3pandora_nand_device) < 0)
136                         printk(KERN_ERR "Unable to register NAND device\n");
137         }
138 }
139
140 static struct omap_uart_config omap3pandora_uart_config __initdata = {
141         .enabled_uarts  = (1 << 2), /* UART3 */
142 };
143
144 static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
145         .gpio_base      = OMAP_MAX_GPIO_LINES,
146         .irq_base       = TWL4030_GPIO_IRQ_BASE,
147         .irq_end        = TWL4030_GPIO_IRQ_END,
148 };
149
150 static struct twl4030_usb_data omap3pandora_usb_data = {
151         .usb_mode       = T2_USB_MODE_ULPI,
152 };
153
154 static struct twl4030_platform_data omap3pandora_twldata = {
155         .irq_base       = TWL4030_IRQ_BASE,
156         .irq_end        = TWL4030_IRQ_END,
157         .gpio           = &omap3pandora_gpio_data,
158         .usb            = &omap3pandora_usb_data,
159 };
160
161 static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
162         {
163                 I2C_BOARD_INFO("twl4030", 0x48),
164                 .flags = I2C_CLIENT_WAKE,
165                 .irq = INT_34XX_SYS_NIRQ,
166                 .platform_data = &omap3pandora_twldata,
167         },
168 };
169
170 static int __init omap3pandora_i2c_init(void)
171 {
172         omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
173                         ARRAY_SIZE(omap3pandora_i2c_boardinfo));
174         /* i2c2 pins are not connected */
175         omap_register_i2c_bus(3, 400, NULL, 0);
176         return 0;
177 }
178
179 static void __init omap3pandora_init_irq(void)
180 {
181         omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
182         omap_init_irq();
183         omap_gpio_init();
184 }
185
186 static struct platform_device omap3pandora_lcd_device = {
187         .name           = "pandora_lcd",
188         .id             = -1,
189 };
190
191 static struct omap_lcd_config omap3pandora_lcd_config __initdata = {
192         .ctrl_name      = "internal",
193 };
194
195 static struct omap_board_config_kernel omap3pandora_config[] __initdata = {
196         { OMAP_TAG_UART,        &omap3pandora_uart_config },
197         { OMAP_TAG_LCD,         &omap3pandora_lcd_config },
198 };
199
200 static struct platform_device *omap3pandora_devices[] __initdata = {
201         &omap3pandora_lcd_device,
202 };
203
204 static void __init omap3pandora_init(void)
205 {
206         omap3pandora_i2c_init();
207         platform_add_devices(omap3pandora_devices, ARRAY_SIZE(omap3pandora_devices));
208         omap_board_config = omap3pandora_config;
209         omap_board_config_size = ARRAY_SIZE(omap3pandora_config);
210         omap_serial_init();
211         hsmmc_init();
212         usb_musb_init();
213         usb_ehci_init();
214         omap3pandora_flash_init();
215 }
216
217 static void __init omap3pandora_map_io(void)
218 {
219         omap2_set_globals_343x();
220         omap2_map_common_io();
221 }
222
223 MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
224         .phys_io        = 0x48000000,
225         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
226         .boot_params    = 0x80000100,
227         .map_io         = omap3pandora_map_io,
228         .init_irq       = omap3pandora_init_irq,
229         .init_machine   = omap3pandora_init,
230         .timer          = &omap_timer,
231 MACHINE_END