ARM: pxa: Push Colibri evalboard MFP into module files
[pandora-kernel.git] / arch / arm / mach-pxa / colibri-pxa320.c
1 /*
2  *  arch/arm/mach-pxa/colibri-pxa320.c
3  *
4  *  Support for Toradex PXA320/310 based Colibri module
5  *
6  *  Daniel Mack <daniel@caiaq.de>
7  *  Matthias Meier <matthias.j.meier@gmx.net>
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License version 2 as
11  *  published by the Free Software Foundation.
12  */
13
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/platform_device.h>
17 #include <linux/gpio.h>
18 #include <linux/interrupt.h>
19 #include <linux/usb/gpio_vbus.h>
20
21 #include <asm/mach-types.h>
22 #include <asm/sizes.h>
23 #include <asm/mach/arch.h>
24 #include <asm/mach/irq.h>
25
26 #include <mach/pxa3xx-regs.h>
27 #include <mach/mfp-pxa320.h>
28 #include <mach/colibri.h>
29 #include <mach/pxafb.h>
30 #include <mach/ohci.h>
31 #include <mach/audio.h>
32 #include <mach/pxa27x-udc.h>
33 #include <mach/udc.h>
34
35 #include "generic.h"
36 #include "devices.h"
37
38 #ifdef  CONFIG_MACH_COLIBRI_PXA270_EVALBOARD
39 static mfp_cfg_t colibri_pxa320_evalboard_pin_config[] __initdata = {
40         /* MMC */
41         GPIO22_MMC1_CLK,
42         GPIO23_MMC1_CMD,
43         GPIO18_MMC1_DAT0,
44         GPIO19_MMC1_DAT1,
45         GPIO20_MMC1_DAT2,
46         GPIO21_MMC1_DAT3,
47         GPIO28_GPIO,    /* SD detect */
48
49         /* UART 1 configuration (may be set by bootloader) */
50         GPIO99_UART1_CTS,
51         GPIO104_UART1_RTS,
52         GPIO97_UART1_RXD,
53         GPIO98_UART1_TXD,
54         GPIO101_UART1_DTR,
55         GPIO103_UART1_DSR,
56         GPIO100_UART1_DCD,
57         GPIO102_UART1_RI,
58
59         /* UART 2 configuration */
60         GPIO109_UART2_CTS,
61         GPIO112_UART2_RTS,
62         GPIO110_UART2_RXD,
63         GPIO111_UART2_TXD,
64
65         /* UART 3 configuration */
66         GPIO30_UART3_RXD,
67         GPIO31_UART3_TXD,
68
69         /* UHC */
70         GPIO2_2_USBH_PEN,
71         GPIO3_2_USBH_PWR,
72 };
73 #else
74 static mfp_cfg_t colibri_pxa320_evalboard_pin_config[] __initdata = {};
75 #endif
76
77 #if defined(CONFIG_AX88796)
78 #define COLIBRI_ETH_IRQ_GPIO    mfp_to_gpio(GPIO36_GPIO)
79 /*
80  * Asix AX88796 Ethernet
81  */
82 static struct ax_plat_data colibri_asix_platdata = {
83         .flags          = 0, /* defined later */
84         .wordlength     = 2,
85 };
86
87 static struct resource colibri_asix_resource[] = {
88         [0] = {
89                 .start = PXA3xx_CS2_PHYS,
90                 .end   = PXA3xx_CS2_PHYS + (0x20 * 2) - 1,
91                 .flags = IORESOURCE_MEM,
92         },
93         [1] = {
94                 .start = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO),
95                 .end   = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO),
96                 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
97         }
98 };
99
100 static struct platform_device asix_device = {
101         .name           = "ax88796",
102         .id             = 0,
103         .num_resources  = ARRAY_SIZE(colibri_asix_resource),
104         .resource       = colibri_asix_resource,
105         .dev            = {
106                 .platform_data = &colibri_asix_platdata
107         }
108 };
109
110 static mfp_cfg_t colibri_pxa320_eth_pin_config[] __initdata = {
111         GPIO3_nCS2,                     /* AX88796 chip select */
112         GPIO36_GPIO | MFP_PULL_HIGH     /* AX88796 IRQ */
113 };
114
115 static void __init colibri_pxa320_init_eth(void)
116 {
117         colibri_pxa3xx_init_eth(&colibri_asix_platdata);
118         pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_eth_pin_config));
119         platform_device_register(&asix_device);
120 }
121 #else
122 static inline void __init colibri_pxa320_init_eth(void) {}
123 #endif /* CONFIG_AX88796 */
124
125 #if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
126 static struct gpio_vbus_mach_info colibri_pxa320_gpio_vbus_info = {
127         .gpio_vbus              = mfp_to_gpio(MFP_PIN_GPIO96),
128         .gpio_pullup            = -1,
129 };
130
131 static struct platform_device colibri_pxa320_gpio_vbus = {
132         .name   = "gpio-vbus",
133         .id     = -1,
134         .dev    = {
135                 .platform_data  = &colibri_pxa320_gpio_vbus_info,
136         },
137 };
138
139 static void colibri_pxa320_udc_command(int cmd)
140 {
141         if (cmd == PXA2XX_UDC_CMD_CONNECT)
142                 UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE;
143         else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
144                 UP2OCR = UP2OCR_HXOE;
145 }
146
147 static struct pxa2xx_udc_mach_info colibri_pxa320_udc_info __initdata = {
148         .udc_command            = colibri_pxa320_udc_command,
149         .gpio_pullup            = -1,
150 };
151
152 static void __init colibri_pxa320_init_udc(void)
153 {
154         pxa_set_udc_info(&colibri_pxa320_udc_info);
155         platform_device_register(&colibri_pxa320_gpio_vbus);
156 }
157 #else
158 static inline void colibri_pxa320_init_udc(void) {}
159 #endif
160
161 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
162 static mfp_cfg_t colibri_pxa320_lcd_pin_config[] __initdata = {
163         GPIO6_2_LCD_LDD_0,
164         GPIO7_2_LCD_LDD_1,
165         GPIO8_2_LCD_LDD_2,
166         GPIO9_2_LCD_LDD_3,
167         GPIO10_2_LCD_LDD_4,
168         GPIO11_2_LCD_LDD_5,
169         GPIO12_2_LCD_LDD_6,
170         GPIO13_2_LCD_LDD_7,
171         GPIO63_LCD_LDD_8,
172         GPIO64_LCD_LDD_9,
173         GPIO65_LCD_LDD_10,
174         GPIO66_LCD_LDD_11,
175         GPIO67_LCD_LDD_12,
176         GPIO68_LCD_LDD_13,
177         GPIO69_LCD_LDD_14,
178         GPIO70_LCD_LDD_15,
179         GPIO71_LCD_LDD_16,
180         GPIO72_LCD_LDD_17,
181         GPIO73_LCD_CS_N,
182         GPIO74_LCD_VSYNC,
183         GPIO14_2_LCD_FCLK,
184         GPIO15_2_LCD_LCLK,
185         GPIO16_2_LCD_PCLK,
186         GPIO17_2_LCD_BIAS,
187 };
188
189 static void __init colibri_pxa320_init_lcd(void)
190 {
191         pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_lcd_pin_config));
192 }
193 #else
194 static inline void colibri_pxa320_init_lcd(void) {}
195 #endif
196
197 #if     defined(CONFIG_SND_AC97_CODEC) || \
198         defined(CONFIG_SND_AC97_CODEC_MODULE)
199 static mfp_cfg_t colibri_pxa320_ac97_pin_config[] __initdata = {
200         GPIO34_AC97_SYSCLK,
201         GPIO35_AC97_SDATA_IN_0,
202         GPIO37_AC97_SDATA_OUT,
203         GPIO38_AC97_SYNC,
204         GPIO39_AC97_BITCLK,
205         GPIO40_AC97_nACRESET
206 };
207
208 static inline void __init colibri_pxa320_init_ac97(void)
209 {
210         pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_ac97_pin_config));
211         pxa_set_ac97_info(NULL);
212 }
213 #else
214 static inline void colibri_pxa320_init_ac97(void) {}
215 #endif
216
217 void __init colibri_pxa320_init(void)
218 {
219         colibri_pxa320_init_eth();
220         colibri_pxa3xx_init_nand();
221         colibri_pxa320_init_lcd();
222         colibri_pxa3xx_init_lcd(mfp_to_gpio(GPIO49_GPIO));
223         colibri_pxa320_init_ac97();
224         colibri_pxa320_init_udc();
225
226         /* Evalboard init */
227         pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_evalboard_pin_config));
228         colibri_pxa270_evalboard_init();
229 }
230
231 MACHINE_START(COLIBRI320, "Toradex Colibri PXA320")
232         .boot_params    = COLIBRI_SDRAM_BASE + 0x100,
233         .init_machine   = colibri_pxa320_init,
234         .map_io         = pxa3xx_map_io,
235         .init_irq       = pxa3xx_init_irq,
236         .timer          = &pxa_timer,
237 MACHINE_END
238