blob: ff9ff5f4fc47e599f409c10935151e65621023e1 [file] [log] [blame]
Daniel Mackbac07ec2009-03-23 02:04:18 +01001/*
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>
Daniel Mack8a28b102009-04-02 08:33:15 +020018#include <linux/interrupt.h>
Marek Vasut11dd2d92010-06-24 16:02:10 +020019#include <linux/usb/gpio_vbus.h>
Daniel Mackbac07ec2009-03-23 02:04:18 +010020
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>
Daniel Mack91fcfb92009-03-23 02:04:19 +010029#include <mach/pxafb.h>
Daniel Mackbac07ec2009-03-23 02:04:18 +010030#include <mach/ohci.h>
Marek Vasut15f593c2009-11-08 03:05:11 +010031#include <mach/audio.h>
Marek Vasut11dd2d92010-06-24 16:02:10 +020032#include <mach/pxa27x-udc.h>
33#include <mach/udc.h>
Daniel Mackbac07ec2009-03-23 02:04:18 +010034
35#include "generic.h"
36#include "devices.h"
37
Marek Vasuta3172e52010-08-12 01:45:05 +020038#ifdef CONFIG_MACH_COLIBRI_EVALBOARD
Marek Vasut9b6956f2010-08-12 01:18:38 +020039static 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,
Marek Vasut072e1ae2010-08-12 01:30:39 +020072
73 /* I2C */
74 GPIO32_I2C_SCL,
75 GPIO33_I2C_SDA,
Marek Vasutfd629992010-08-11 05:04:53 +020076
77 /* PCMCIA */
78 MFP_CFG(GPIO59, AF7), /* PRST ; AF7 to tristate */
79 MFP_CFG(GPIO61, AF7), /* PCE1 ; AF7 to tristate */
80 MFP_CFG(GPIO60, AF7), /* PCE2 ; AF7 to tristate */
81 MFP_CFG(GPIO62, AF7), /* PCD ; AF7 to tristate */
82 MFP_CFG(GPIO56, AF7), /* PSKTSEL ; AF7 to tristate */
83 GPIO27_GPIO, /* RDnWR ; input/tristate */
84 GPIO50_GPIO, /* PREG ; input/tristate */
85 GPIO2_RDY,
86 GPIO5_NPIOR,
87 GPIO6_NPIOW,
88 GPIO7_NPIOS16,
89 GPIO8_NPWAIT,
90 GPIO29_GPIO, /* PRDY (READY GPIO) */
91 GPIO57_GPIO, /* PPEN (POWER GPIO) */
92 GPIO81_GPIO, /* PCD (DETECT GPIO) */
93 GPIO77_GPIO, /* PRST (RESET GPIO) */
94 GPIO53_GPIO, /* PBVD1 */
95 GPIO79_GPIO, /* PBVD2 */
96 GPIO54_GPIO, /* POE */
Marek Vasut9b6956f2010-08-12 01:18:38 +020097};
98#else
99static mfp_cfg_t colibri_pxa320_evalboard_pin_config[] __initdata = {};
100#endif
101
Daniel Mackbac07ec2009-03-23 02:04:18 +0100102#if defined(CONFIG_AX88796)
103#define COLIBRI_ETH_IRQ_GPIO mfp_to_gpio(GPIO36_GPIO)
Daniel Mackbac07ec2009-03-23 02:04:18 +0100104/*
105 * Asix AX88796 Ethernet
106 */
107static struct ax_plat_data colibri_asix_platdata = {
Daniel Mack22a02002009-04-02 08:33:14 +0200108 .flags = 0, /* defined later */
109 .wordlength = 2,
Daniel Mackbac07ec2009-03-23 02:04:18 +0100110};
111
112static struct resource colibri_asix_resource[] = {
113 [0] = {
114 .start = PXA3xx_CS2_PHYS,
115 .end = PXA3xx_CS2_PHYS + (0x20 * 2) - 1,
116 .flags = IORESOURCE_MEM,
117 },
118 [1] = {
119 .start = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO),
120 .end = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO),
Daniel Mack8a28b102009-04-02 08:33:15 +0200121 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_FALLING,
Daniel Mackbac07ec2009-03-23 02:04:18 +0100122 }
123};
124
125static struct platform_device asix_device = {
126 .name = "ax88796",
127 .id = 0,
128 .num_resources = ARRAY_SIZE(colibri_asix_resource),
129 .resource = colibri_asix_resource,
130 .dev = {
131 .platform_data = &colibri_asix_platdata
132 }
133};
134
135static mfp_cfg_t colibri_pxa320_eth_pin_config[] __initdata = {
136 GPIO3_nCS2, /* AX88796 chip select */
137 GPIO36_GPIO | MFP_PULL_HIGH /* AX88796 IRQ */
138};
139
140static void __init colibri_pxa320_init_eth(void)
141{
Daniel Mack22a02002009-04-02 08:33:14 +0200142 colibri_pxa3xx_init_eth(&colibri_asix_platdata);
Daniel Mackbac07ec2009-03-23 02:04:18 +0100143 pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_eth_pin_config));
Daniel Mackbac07ec2009-03-23 02:04:18 +0100144 platform_device_register(&asix_device);
145}
146#else
147static inline void __init colibri_pxa320_init_eth(void) {}
148#endif /* CONFIG_AX88796 */
149
Marek Vasut11dd2d92010-06-24 16:02:10 +0200150#if defined(CONFIG_USB_GADGET_PXA27X)||defined(CONFIG_USB_GADGET_PXA27X_MODULE)
151static struct gpio_vbus_mach_info colibri_pxa320_gpio_vbus_info = {
152 .gpio_vbus = mfp_to_gpio(MFP_PIN_GPIO96),
153 .gpio_pullup = -1,
154};
155
156static struct platform_device colibri_pxa320_gpio_vbus = {
157 .name = "gpio-vbus",
158 .id = -1,
159 .dev = {
160 .platform_data = &colibri_pxa320_gpio_vbus_info,
161 },
162};
163
164static void colibri_pxa320_udc_command(int cmd)
165{
166 if (cmd == PXA2XX_UDC_CMD_CONNECT)
167 UP2OCR = UP2OCR_HXOE | UP2OCR_DPPUE;
168 else if (cmd == PXA2XX_UDC_CMD_DISCONNECT)
169 UP2OCR = UP2OCR_HXOE;
170}
171
172static struct pxa2xx_udc_mach_info colibri_pxa320_udc_info __initdata = {
173 .udc_command = colibri_pxa320_udc_command,
174 .gpio_pullup = -1,
175};
176
177static void __init colibri_pxa320_init_udc(void)
178{
179 pxa_set_udc_info(&colibri_pxa320_udc_info);
180 platform_device_register(&colibri_pxa320_gpio_vbus);
181}
182#else
183static inline void colibri_pxa320_init_udc(void) {}
184#endif
185
Daniel Mack91fcfb92009-03-23 02:04:19 +0100186#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
187static mfp_cfg_t colibri_pxa320_lcd_pin_config[] __initdata = {
188 GPIO6_2_LCD_LDD_0,
189 GPIO7_2_LCD_LDD_1,
190 GPIO8_2_LCD_LDD_2,
191 GPIO9_2_LCD_LDD_3,
192 GPIO10_2_LCD_LDD_4,
193 GPIO11_2_LCD_LDD_5,
194 GPIO12_2_LCD_LDD_6,
195 GPIO13_2_LCD_LDD_7,
196 GPIO63_LCD_LDD_8,
197 GPIO64_LCD_LDD_9,
198 GPIO65_LCD_LDD_10,
199 GPIO66_LCD_LDD_11,
200 GPIO67_LCD_LDD_12,
201 GPIO68_LCD_LDD_13,
202 GPIO69_LCD_LDD_14,
203 GPIO70_LCD_LDD_15,
204 GPIO71_LCD_LDD_16,
205 GPIO72_LCD_LDD_17,
206 GPIO73_LCD_CS_N,
207 GPIO74_LCD_VSYNC,
208 GPIO14_2_LCD_FCLK,
209 GPIO15_2_LCD_LCLK,
210 GPIO16_2_LCD_PCLK,
211 GPIO17_2_LCD_BIAS,
212};
213
214static void __init colibri_pxa320_init_lcd(void)
215{
216 pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_lcd_pin_config));
217}
218#else
219static inline void colibri_pxa320_init_lcd(void) {}
220#endif
221
Marek Vasut15f593c2009-11-08 03:05:11 +0100222#if defined(CONFIG_SND_AC97_CODEC) || \
223 defined(CONFIG_SND_AC97_CODEC_MODULE)
Daniel Macke2bb5be2009-03-23 02:04:20 +0100224static mfp_cfg_t colibri_pxa320_ac97_pin_config[] __initdata = {
225 GPIO34_AC97_SYSCLK,
226 GPIO35_AC97_SDATA_IN_0,
227 GPIO37_AC97_SDATA_OUT,
228 GPIO38_AC97_SYNC,
229 GPIO39_AC97_BITCLK,
230 GPIO40_AC97_nACRESET
231};
232
233static inline void __init colibri_pxa320_init_ac97(void)
234{
235 pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_ac97_pin_config));
236 pxa_set_ac97_info(NULL);
237}
238#else
239static inline void colibri_pxa320_init_ac97(void) {}
240#endif
241
Daniel Mackbac07ec2009-03-23 02:04:18 +0100242void __init colibri_pxa320_init(void)
243{
244 colibri_pxa320_init_eth();
Daniel Mack53740df2009-06-17 10:32:54 +0200245 colibri_pxa3xx_init_nand();
Daniel Mack91fcfb92009-03-23 02:04:19 +0100246 colibri_pxa320_init_lcd();
Daniel Mackc9b78182009-03-27 22:00:09 +0100247 colibri_pxa3xx_init_lcd(mfp_to_gpio(GPIO49_GPIO));
Daniel Macke2bb5be2009-03-23 02:04:20 +0100248 colibri_pxa320_init_ac97();
Marek Vasut11dd2d92010-06-24 16:02:10 +0200249 colibri_pxa320_init_udc();
Marek Vasut9b6956f2010-08-12 01:18:38 +0200250
251 /* Evalboard init */
252 pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_evalboard_pin_config));
Marek Vasuta3172e52010-08-12 01:45:05 +0200253 colibri_evalboard_init();
Daniel Mackbac07ec2009-03-23 02:04:18 +0100254}
255
256MACHINE_START(COLIBRI320, "Toradex Colibri PXA320")
Daniel Mackbac07ec2009-03-23 02:04:18 +0100257 .boot_params = COLIBRI_SDRAM_BASE + 0x100,
258 .init_machine = colibri_pxa320_init,
Marek Vasut851982c2010-10-11 02:20:19 +0200259 .map_io = pxa3xx_map_io,
Daniel Mackbac07ec2009-03-23 02:04:18 +0100260 .init_irq = pxa3xx_init_irq,
261 .timer = &pxa_timer,
262MACHINE_END
263