Merge branch 'for-3.0' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound...
[pandora-kernel.git] / arch / arm / mach-pxa / colibri-pxa270.c
1 /*
2  *  linux/arch/arm/mach-pxa/colibri-pxa270.c
3  *
4  *  Support for Toradex PXA270 based Colibri module
5  *  Daniel Mack <daniel@caiaq.de>
6  *  Marek Vasut <marek.vasut@gmail.com>
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License version 2 as
10  *  published by the Free Software Foundation.
11  */
12
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/kernel.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/partitions.h>
18 #include <linux/mtd/physmap.h>
19 #include <linux/platform_device.h>
20 #include <linux/ucb1400.h>
21
22 #include <asm/mach/arch.h>
23 #include <asm/mach/flash.h>
24 #include <asm/mach-types.h>
25 #include <asm/sizes.h>
26
27 #include <mach/audio.h>
28 #include <mach/colibri.h>
29 #include <mach/pxa27x.h>
30
31 #include "devices.h"
32 #include "generic.h"
33
34 /******************************************************************************
35  * Evaluation board MFP
36  ******************************************************************************/
37 #ifdef   CONFIG_MACH_COLIBRI_EVALBOARD
38 static mfp_cfg_t colibri_pxa270_evalboard_pin_config[] __initdata = {
39         /* MMC */
40         GPIO32_MMC_CLK,
41         GPIO92_MMC_DAT_0,
42         GPIO109_MMC_DAT_1,
43         GPIO110_MMC_DAT_2,
44         GPIO111_MMC_DAT_3,
45         GPIO112_MMC_CMD,
46         GPIO0_GPIO,     /* SD detect */
47
48         /* FFUART */
49         GPIO39_FFUART_TXD,
50         GPIO34_FFUART_RXD,
51
52         /* UHC */
53         GPIO88_USBH1_PWR,
54         GPIO89_USBH1_PEN,
55         GPIO119_USBH2_PWR,
56         GPIO120_USBH2_PEN,
57
58         /* PCMCIA */
59         GPIO85_nPCE_1,
60         GPIO54_nPCE_2,
61         GPIO55_nPREG,
62         GPIO50_nPIOR,
63         GPIO51_nPIOW,
64         GPIO49_nPWE,
65         GPIO48_nPOE,
66         GPIO57_nIOIS16,
67         GPIO56_nPWAIT,
68         GPIO104_PSKTSEL,
69         GPIO53_GPIO,    /* RESET */
70         GPIO83_GPIO,    /* BVD1 */
71         GPIO82_GPIO,    /* BVD2 */
72         GPIO1_GPIO,     /* READY */
73         GPIO84_GPIO,    /* DETECT */
74         GPIO107_GPIO,   /* PPEN */
75
76         /* I2C */
77         GPIO117_I2C_SCL,
78         GPIO118_I2C_SDA,
79 };
80 #else
81 static mfp_cfg_t colibri_pxa270_evalboard_pin_config[] __initdata = {};
82 #endif
83
84 #ifdef  CONFIG_MACH_COLIBRI_PXA270_INCOME
85 static mfp_cfg_t income_pin_config[] __initdata = {
86         /* MMC */
87         GPIO32_MMC_CLK,
88         GPIO92_MMC_DAT_0,
89         GPIO109_MMC_DAT_1,
90         GPIO110_MMC_DAT_2,
91         GPIO111_MMC_DAT_3,
92         GPIO112_MMC_CMD,
93         GPIO0_GPIO,     /* SD detect */
94         GPIO1_GPIO,     /* SD read-only */
95
96         /* FFUART */
97         GPIO39_FFUART_TXD,
98         GPIO34_FFUART_RXD,
99
100         /* BFUART */
101         GPIO42_BTUART_RXD,
102         GPIO43_BTUART_TXD,
103         GPIO45_BTUART_RTS,
104
105         /* STUART */
106         GPIO46_STUART_RXD,
107         GPIO47_STUART_TXD,
108
109         /* UHC */
110         GPIO88_USBH1_PWR,
111         GPIO89_USBH1_PEN,
112
113         /* LCD */
114         GPIOxx_LCD_TFT_16BPP,
115
116         /* PWM */
117         GPIO16_PWM0_OUT,
118
119         /* I2C */
120         GPIO117_I2C_SCL,
121         GPIO118_I2C_SDA,
122
123         /* LED */
124         GPIO54_GPIO,    /* LED A */
125         GPIO55_GPIO,    /* LED B */
126 };
127 #else
128 static mfp_cfg_t income_pin_config[] __initdata = {};
129 #endif
130
131 /******************************************************************************
132  * Pin configuration
133  ******************************************************************************/
134 static mfp_cfg_t colibri_pxa270_pin_config[] __initdata = {
135         /* Ethernet */
136         GPIO78_nCS_2,   /* Ethernet CS */
137         GPIO114_GPIO,   /* Ethernet IRQ */
138
139         /* AC97 */
140         GPIO28_AC97_BITCLK,
141         GPIO29_AC97_SDATA_IN_0,
142         GPIO30_AC97_SDATA_OUT,
143         GPIO31_AC97_SYNC,
144         GPIO95_AC97_nRESET,
145         GPIO98_AC97_SYSCLK,
146         GPIO113_GPIO,   /* Touchscreen IRQ */
147 };
148
149 /******************************************************************************
150  * NOR Flash
151  ******************************************************************************/
152 #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
153 static struct mtd_partition colibri_partitions[] = {
154         {
155                 .name =         "Bootloader",
156                 .offset =       0x00000000,
157                 .size =         0x00040000,
158                 .mask_flags =   MTD_WRITEABLE   /* force read-only */
159         }, {
160                 .name =         "Kernel",
161                 .offset =       0x00040000,
162                 .size =         0x00400000,
163                 .mask_flags =   0
164         }, {
165                 .name =         "Rootfs",
166                 .offset =       0x00440000,
167                 .size =         MTDPART_SIZ_FULL,
168                 .mask_flags =   0
169         }
170 };
171
172 static struct physmap_flash_data colibri_flash_data[] = {
173         {
174                 .width          = 4,                    /* bankwidth in bytes */
175                 .parts          = colibri_partitions,
176                 .nr_parts       = ARRAY_SIZE(colibri_partitions)
177         }
178 };
179
180 static struct resource colibri_pxa270_flash_resource = {
181         .start  = PXA_CS0_PHYS,
182         .end    = PXA_CS0_PHYS + SZ_32M - 1,
183         .flags  = IORESOURCE_MEM,
184 };
185
186 static struct platform_device colibri_pxa270_flash_device = {
187         .name   = "physmap-flash",
188         .id     = 0,
189         .dev    = {
190                 .platform_data = colibri_flash_data,
191         },
192         .resource = &colibri_pxa270_flash_resource,
193         .num_resources = 1,
194 };
195
196 static void __init colibri_pxa270_nor_init(void)
197 {
198         platform_device_register(&colibri_pxa270_flash_device);
199 }
200 #else
201 static inline void colibri_pxa270_nor_init(void) {}
202 #endif
203
204 /******************************************************************************
205  * Ethernet
206  ******************************************************************************/
207 #if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
208 static struct resource colibri_pxa270_dm9000_resources[] = {
209         {
210                 .start  = PXA_CS2_PHYS,
211                 .end    = PXA_CS2_PHYS + 3,
212                 .flags  = IORESOURCE_MEM,
213         },
214         {
215                 .start  = PXA_CS2_PHYS + 4,
216                 .end    = PXA_CS2_PHYS + 4 + 500,
217                 .flags  = IORESOURCE_MEM,
218         },
219         {
220                 .start  = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ),
221                 .end    = gpio_to_irq(GPIO114_COLIBRI_PXA270_ETH_IRQ),
222                 .flags  = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
223         },
224 };
225
226 static struct platform_device colibri_pxa270_dm9000_device = {
227         .name           = "dm9000",
228         .id             = -1,
229         .num_resources  = ARRAY_SIZE(colibri_pxa270_dm9000_resources),
230         .resource       = colibri_pxa270_dm9000_resources,
231 };
232
233 static void __init colibri_pxa270_eth_init(void)
234 {
235         platform_device_register(&colibri_pxa270_dm9000_device);
236 }
237 #else
238 static inline void colibri_pxa270_eth_init(void) {}
239 #endif
240
241 /******************************************************************************
242  * Audio and Touchscreen
243  ******************************************************************************/
244 #if     defined(CONFIG_TOUCHSCREEN_UCB1400) || \
245         defined(CONFIG_TOUCHSCREEN_UCB1400_MODULE)
246 static pxa2xx_audio_ops_t colibri_pxa270_ac97_pdata = {
247         .reset_gpio     = 95,
248 };
249
250 static struct ucb1400_pdata colibri_pxa270_ucb1400_pdata = {
251         .irq            = gpio_to_irq(GPIO113_COLIBRI_PXA270_TS_IRQ),
252 };
253
254 static struct platform_device colibri_pxa270_ucb1400_device = {
255         .name           = "ucb1400_core",
256         .id             = -1,
257         .dev            = {
258                 .platform_data = &colibri_pxa270_ucb1400_pdata,
259         },
260 };
261
262 static void __init colibri_pxa270_tsc_init(void)
263 {
264         pxa_set_ac97_info(&colibri_pxa270_ac97_pdata);
265         platform_device_register(&colibri_pxa270_ucb1400_device);
266 }
267 #else
268 static inline void colibri_pxa270_tsc_init(void) {}
269 #endif
270
271 static int colibri_pxa270_baseboard;
272 core_param(colibri_pxa270_baseboard, colibri_pxa270_baseboard, int, 0444);
273
274 static void __init colibri_pxa270_init(void)
275 {
276         pxa2xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa270_pin_config));
277
278         colibri_pxa270_nor_init();
279         colibri_pxa270_eth_init();
280         colibri_pxa270_tsc_init();
281
282         switch (colibri_pxa270_baseboard) {
283         case COLIBRI_EVALBOARD:
284                 pxa2xx_mfp_config(ARRAY_AND_SIZE(
285                         colibri_pxa270_evalboard_pin_config));
286                 colibri_evalboard_init();
287                 break;
288         case COLIBRI_PXA270_INCOME:
289                 pxa2xx_mfp_config(ARRAY_AND_SIZE(income_pin_config));
290                 colibri_pxa270_income_boardinit();
291                 break;
292         default:
293                 printk(KERN_ERR "Illegal colibri_pxa270_baseboard type %d\n",
294                                 colibri_pxa270_baseboard);
295         }
296 }
297
298 /* The "Income s.r.o. SH-Dmaster PXA270 SBC" board can be booted either
299  * with the INCOME mach type or with COLIBRI and the kernel parameter
300  * "colibri_pxa270_baseboard=1"
301  */
302 static void __init colibri_pxa270_income_init(void)
303 {
304         colibri_pxa270_baseboard = COLIBRI_PXA270_INCOME;
305         colibri_pxa270_init();
306 }
307
308 MACHINE_START(COLIBRI, "Toradex Colibri PXA270")
309         .boot_params    = COLIBRI_SDRAM_BASE + 0x100,
310         .init_machine   = colibri_pxa270_init,
311         .map_io         = pxa27x_map_io,
312         .init_irq       = pxa27x_init_irq,
313         .timer          = &pxa_timer,
314 MACHINE_END
315
316 MACHINE_START(INCOME, "Income s.r.o. SH-Dmaster PXA270 SBC")
317         .boot_params    = 0xa0000100,
318         .init_machine   = colibri_pxa270_income_init,
319         .map_io         = pxa27x_map_io,
320         .init_irq       = pxa27x_init_irq,
321         .timer          = &pxa_timer,
322 MACHINE_END
323