]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-omap3pandora.c
edf5000be3d30a35e826332d6c09203a3f144a8e
[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/spi/spi.h>
29 #include <linux/spi/ads7846.h>
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.h>
42 #include <mach/common.h>
43 #include <mach/gpio.h>
44 #include <mach/gpmc.h>
45 #include <mach/hardware.h>
46 #include <mach/mmc.h>
47 #include <mach/nand.h>
48 #include <mach/usb-ehci.h>
49 #include <mach/usb-musb.h>
50 #include <mach/mcspi.h>
51
52 #include "sdram-micron-mt46h32m32lf-6.h"
53 #include "mmc-twl4030.h"
54
55
56 #define NAND_BLOCK_SIZE SZ_128K
57 #define GPMC_CS0_BASE  0x60
58 #define GPMC_CS_SIZE   0x30
59
60 #define OMAP3_PANDORA_TS_GPIO           94
61
62 static struct mtd_partition omap3pandora_nand_partitions[] = {
63         {
64                 .name           = "xloader",
65                 .offset         = 0,                    /* Offset = 0x00000 */
66                 .size           = 4 * NAND_BLOCK_SIZE,
67                 .mask_flags     = MTD_WRITEABLE
68         }, {
69                 .name           = "uboot",
70                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x80000 */
71                 .size           = 14 * NAND_BLOCK_SIZE,
72         }, {
73                 .name           = "uboot environment",
74                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x240000 */
75                 .size           = 2 * NAND_BLOCK_SIZE,
76         }, {
77                 .name           = "linux",
78                 .offset         = MTDPART_OFS_APPEND,   /* Offset = 0x280000 */
79                 .size           = 32 * NAND_BLOCK_SIZE,
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 omap3pandora_nand_data = {
88         .parts          = omap3pandora_nand_partitions,
89         .nr_parts       = ARRAY_SIZE(omap3pandora_nand_partitions),
90         .dma_channel    = -1,   /* disable DMA in OMAP NAND driver */
91 };
92
93 static struct resource omap3pandora_nand_resource[] = {
94         {
95                 .flags          = IORESOURCE_MEM,
96         },
97 };
98
99 static struct platform_device omap3pandora_nand_device = {
100         .name           = "omap2-nand",
101         .id             = -1,
102         .dev            = {
103                 .platform_data  = &omap3pandora_nand_data,
104         },
105         .num_resources  = ARRAY_SIZE(omap3pandora_nand_resource),
106         .resource       = omap3pandora_nand_resource,
107 };
108
109 static void __init omap3pandora_flash_init(void)
110 {
111         u8 cs = 0;
112         u8 nandcs = GPMC_CS_NUM + 1;
113
114         u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
115
116         /* find out the chip-select on which NAND exists */
117         while (cs < GPMC_CS_NUM) {
118                 u32 ret = 0;
119                 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
120
121                 if ((ret & 0xC00) == 0x800) {
122                         printk(KERN_INFO "Found NAND on CS%d\n", cs);
123                         if (nandcs > GPMC_CS_NUM)
124                                 nandcs = cs;
125                 }
126                 cs++;
127         }
128
129         if (nandcs > GPMC_CS_NUM) {
130                 printk(KERN_INFO "NAND: Unable to find configuration "
131                                  "in GPMC\n ");
132                 return;
133         }
134
135         if (nandcs < GPMC_CS_NUM) {
136                 omap3pandora_nand_data.cs = nandcs;
137                 omap3pandora_nand_data.gpmc_cs_baseaddr = (void *)
138                         (gpmc_base_add + GPMC_CS0_BASE + nandcs * GPMC_CS_SIZE);
139                 omap3pandora_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
140
141                 printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
142                 if (platform_device_register(&omap3pandora_nand_device) < 0)
143                         printk(KERN_ERR "Unable to register NAND device\n");
144         }
145 }
146
147 static struct twl4030_hsmmc_info omap3pandora_mmc[] = {
148         {
149                 .mmc            = 1,
150                 .wires          = 4,
151                 .gpio_cd        = -EINVAL,
152                 .gpio_wp        = 126,
153                 .ext_clock      = 0,
154         },
155         {
156                 .mmc            = 2,
157                 .wires          = 4,
158                 .gpio_cd        = -EINVAL,
159                 .gpio_wp        = 127,
160                 .ext_clock      = 1,
161         },
162         {}      /* Terminator */
163 };
164
165 static struct omap_uart_config omap3pandora_uart_config __initdata = {
166         .enabled_uarts  = (1 << 2), /* UART3 */
167 };
168
169 static int omap3pandora_twl_gpio_setup(struct device *dev,
170                 unsigned gpio, unsigned ngpio)
171 {
172         /* gpio + {0,1} is "mmc{0,1}_cd" (input/IRQ) */
173         omap3pandora_mmc[0].gpio_cd = gpio + 0;
174         omap3pandora_mmc[1].gpio_cd = gpio + 1;
175         hsmmc_init(omap3pandora_mmc);
176
177         return 0;
178 }
179
180 static struct twl4030_gpio_platform_data omap3pandora_gpio_data = {
181         .gpio_base      = OMAP_MAX_GPIO_LINES,
182         .irq_base       = TWL4030_GPIO_IRQ_BASE,
183         .irq_end        = TWL4030_GPIO_IRQ_END,
184         .setup          = omap3pandora_twl_gpio_setup,
185 };
186
187 static struct twl4030_usb_data omap3pandora_usb_data = {
188         .usb_mode       = T2_USB_MODE_ULPI,
189 };
190
191 static struct twl4030_platform_data omap3pandora_twldata = {
192         .irq_base       = TWL4030_IRQ_BASE,
193         .irq_end        = TWL4030_IRQ_END,
194         .gpio           = &omap3pandora_gpio_data,
195         .usb            = &omap3pandora_usb_data,
196 };
197
198 static struct i2c_board_info __initdata omap3pandora_i2c_boardinfo[] = {
199         {
200                 I2C_BOARD_INFO("tps65950", 0x48),
201                 .flags = I2C_CLIENT_WAKE,
202                 .irq = INT_34XX_SYS_NIRQ,
203                 .platform_data = &omap3pandora_twldata,
204         },
205 };
206
207 static int __init omap3pandora_i2c_init(void)
208 {
209         omap_register_i2c_bus(1, 2600, omap3pandora_i2c_boardinfo,
210                         ARRAY_SIZE(omap3pandora_i2c_boardinfo));
211         /* i2c2 pins are not connected */
212         omap_register_i2c_bus(3, 400, NULL, 0);
213         return 0;
214 }
215
216 static void __init omap3pandora_init_irq(void)
217 {
218         omap2_init_common_hw(mt46h32m32lf6_sdrc_params);
219         omap_init_irq();
220         omap_gpio_init();
221 }
222
223 static void __init omap3pandora_ads7846_init(void)
224 {
225         int gpio = OMAP3_PANDORA_TS_GPIO;
226         int ret;
227
228         ret = gpio_request(gpio, "ads7846_pen_down");
229         if (ret < 0) {
230                 printk(KERN_ERR "Failed to request GPIO %d for "
231                                 "ads7846 pen down IRQ\n", gpio);
232                 return;
233         }
234
235         gpio_direction_input(gpio);
236 }
237
238 static int ads7846_get_pendown_state(void)
239 {
240         return !gpio_get_value(OMAP3_PANDORA_TS_GPIO);
241 }
242
243 static struct ads7846_platform_data ads7846_config = {
244         .x_max                  = 0x0fff,
245         .y_max                  = 0x0fff,
246         .x_plate_ohms           = 180,
247         .pressure_max           = 255,
248         .debounce_max           = 10,
249         .debounce_tol           = 3,
250         .debounce_rep           = 1,
251         .get_pendown_state      = ads7846_get_pendown_state,
252         .keep_vref_on           = 1,
253 };
254
255 static struct omap2_mcspi_device_config ads7846_mcspi_config = {
256         .turbo_mode     = 0,
257         .single_channel = 1,  /* 0: slave, 1: master */
258 };
259
260 static struct spi_board_info omap3pandora_spi_board_info[] __initdata = {
261         {
262                 .modalias               = "ads7846",
263                 .bus_num                = 1,
264                 .chip_select            = 0,
265                 .max_speed_hz           = 1500000,
266                 .controller_data        = &ads7846_mcspi_config,
267                 .irq                    = OMAP_GPIO_IRQ(OMAP3_PANDORA_TS_GPIO),
268                 .platform_data          = &ads7846_config,
269         }
270 };
271
272 static struct platform_device omap3pandora_lcd_device = {
273         .name           = "pandora_lcd",
274         .id             = -1,
275 };
276
277 static struct omap_lcd_config omap3pandora_lcd_config __initdata = {
278         .ctrl_name      = "internal",
279 };
280
281 static struct omap_board_config_kernel omap3pandora_config[] __initdata = {
282         { OMAP_TAG_UART,        &omap3pandora_uart_config },
283         { OMAP_TAG_LCD,         &omap3pandora_lcd_config },
284 };
285
286 static struct platform_device *omap3pandora_devices[] __initdata = {
287         &omap3pandora_lcd_device,
288 };
289
290 static void __init omap3pandora_init(void)
291 {
292         omap3pandora_i2c_init();
293         platform_add_devices(omap3pandora_devices,
294                         ARRAY_SIZE(omap3pandora_devices));
295         omap_board_config = omap3pandora_config;
296         omap_board_config_size = ARRAY_SIZE(omap3pandora_config);
297         omap_serial_init();
298         spi_register_board_info(omap3pandora_spi_board_info,
299                         ARRAY_SIZE(omap3pandora_spi_board_info));
300         usb_musb_init();
301         usb_ehci_init();
302         omap3pandora_flash_init();
303         omap3pandora_ads7846_init();
304 }
305
306 static void __init omap3pandora_map_io(void)
307 {
308         omap2_set_globals_343x();
309         omap2_map_common_io();
310 }
311
312 MACHINE_START(OMAP3_PANDORA, "Pandora Handheld Console")
313         .phys_io        = 0x48000000,
314         .io_pg_offst    = ((0xd8000000) >> 18) & 0xfffc,
315         .boot_params    = 0x80000100,
316         .map_io         = omap3pandora_map_io,
317         .init_irq       = omap3pandora_init_irq,
318         .init_machine   = omap3pandora_init,
319         .timer          = &omap_timer,
320 MACHINE_END