1 // SPDX-License-Identifier: GPL-2.0-only
3 * arch/arm/mach-pxa/colibri-pxa320.c
5 * Support for Toradex PXA320/310 based Colibri module
7 * Daniel Mack <daniel@caiaq.de>
8 * Matthias Meier <matthias.j.meier@gmx.net>
11 #include <linux/init.h>
12 #include <linux/kernel.h>
13 #include <linux/platform_device.h>
14 #include <linux/gpio/machine.h>
15 #include <linux/gpio.h>
16 #include <linux/interrupt.h>
18 #include <asm/mach-types.h>
19 #include <linux/sizes.h>
20 #include <asm/mach/arch.h>
21 #include <asm/mach/irq.h>
25 #include <linux/platform_data/video-pxafb.h>
26 #include <linux/platform_data/usb-ohci-pxa27x.h>
27 #include <mach/audio.h>
28 #include "pxa27x-udc.h"
34 #ifdef CONFIG_MACH_COLIBRI_EVALBOARD
35 static mfp_cfg_t colibri_pxa320_evalboard_pin_config
[] __initdata
= {
43 GPIO28_GPIO
, /* SD detect */
45 /* UART 1 configuration (may be set by bootloader) */
55 /* UART 2 configuration */
61 /* UART 3 configuration */
74 MFP_CFG(GPIO59
, AF7
), /* PRST ; AF7 to tristate */
75 MFP_CFG(GPIO61
, AF7
), /* PCE1 ; AF7 to tristate */
76 MFP_CFG(GPIO60
, AF7
), /* PCE2 ; AF7 to tristate */
77 MFP_CFG(GPIO62
, AF7
), /* PCD ; AF7 to tristate */
78 MFP_CFG(GPIO56
, AF7
), /* PSKTSEL ; AF7 to tristate */
79 GPIO27_GPIO
, /* RDnWR ; input/tristate */
80 GPIO50_GPIO
, /* PREG ; input/tristate */
86 GPIO29_GPIO
, /* PRDY (READY GPIO) */
87 GPIO57_GPIO
, /* PPEN (POWER GPIO) */
88 GPIO81_GPIO
, /* PCD (DETECT GPIO) */
89 GPIO77_GPIO
, /* PRST (RESET GPIO) */
90 GPIO53_GPIO
, /* PBVD1 */
91 GPIO79_GPIO
, /* PBVD2 */
92 GPIO54_GPIO
, /* POE */
95 static mfp_cfg_t colibri_pxa320_evalboard_pin_config
[] __initdata
= {};
98 #if defined(CONFIG_AX88796)
99 #define COLIBRI_ETH_IRQ_GPIO mfp_to_gpio(GPIO36_GPIO)
101 * Asix AX88796 Ethernet
103 static struct ax_plat_data colibri_asix_platdata
= {
104 .flags
= 0, /* defined later */
108 static struct resource colibri_asix_resource
[] = {
110 .start
= PXA3xx_CS2_PHYS
,
111 .end
= PXA3xx_CS2_PHYS
+ (0x20 * 2) - 1,
112 .flags
= IORESOURCE_MEM
,
115 .start
= PXA_GPIO_TO_IRQ(COLIBRI_ETH_IRQ_GPIO
),
116 .end
= PXA_GPIO_TO_IRQ(COLIBRI_ETH_IRQ_GPIO
),
117 .flags
= IORESOURCE_IRQ
| IRQF_TRIGGER_FALLING
,
121 static struct platform_device asix_device
= {
124 .num_resources
= ARRAY_SIZE(colibri_asix_resource
),
125 .resource
= colibri_asix_resource
,
127 .platform_data
= &colibri_asix_platdata
131 static mfp_cfg_t colibri_pxa320_eth_pin_config
[] __initdata
= {
132 GPIO3_nCS2
, /* AX88796 chip select */
133 GPIO36_GPIO
| MFP_PULL_HIGH
/* AX88796 IRQ */
136 static void __init
colibri_pxa320_init_eth(void)
138 colibri_pxa3xx_init_eth(&colibri_asix_platdata
);
139 pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_eth_pin_config
));
140 platform_device_register(&asix_device
);
143 static inline void __init
colibri_pxa320_init_eth(void) {}
144 #endif /* CONFIG_AX88796 */
146 #if defined(CONFIG_USB_PXA27X)||defined(CONFIG_USB_PXA27X_MODULE)
147 static struct gpiod_lookup_table gpio_vbus_gpiod_table
= {
148 .dev_id
= "gpio-vbus",
150 GPIO_LOOKUP("gpio-pxa", MFP_PIN_GPIO96
,
151 "vbus", GPIO_ACTIVE_HIGH
),
156 static struct platform_device colibri_pxa320_gpio_vbus
= {
161 static void colibri_pxa320_udc_command(int cmd
)
163 if (cmd
== PXA2XX_UDC_CMD_CONNECT
)
164 UP2OCR
= UP2OCR_HXOE
| UP2OCR_DPPUE
;
165 else if (cmd
== PXA2XX_UDC_CMD_DISCONNECT
)
166 UP2OCR
= UP2OCR_HXOE
;
169 static struct pxa2xx_udc_mach_info colibri_pxa320_udc_info __initdata
= {
170 .udc_command
= colibri_pxa320_udc_command
,
174 static void __init
colibri_pxa320_init_udc(void)
176 pxa_set_udc_info(&colibri_pxa320_udc_info
);
177 gpiod_add_lookup_table(&gpio_vbus_gpiod_table
);
178 platform_device_register(&colibri_pxa320_gpio_vbus
);
181 static inline void colibri_pxa320_init_udc(void) {}
184 #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
185 static mfp_cfg_t colibri_pxa320_lcd_pin_config
[] __initdata
= {
212 static void __init
colibri_pxa320_init_lcd(void)
214 pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_lcd_pin_config
));
217 static inline void colibri_pxa320_init_lcd(void) {}
220 #if defined(CONFIG_SND_AC97_CODEC) || \
221 defined(CONFIG_SND_AC97_CODEC_MODULE)
222 static mfp_cfg_t colibri_pxa320_ac97_pin_config
[] __initdata
= {
224 GPIO35_AC97_SDATA_IN_0
,
225 GPIO37_AC97_SDATA_OUT
,
231 static inline void __init
colibri_pxa320_init_ac97(void)
233 pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_ac97_pin_config
));
234 pxa_set_ac97_info(NULL
);
237 static inline void colibri_pxa320_init_ac97(void) {}
240 void __init
colibri_pxa320_init(void)
242 colibri_pxa320_init_eth();
243 colibri_pxa3xx_init_nand();
244 colibri_pxa320_init_lcd();
245 colibri_pxa3xx_init_lcd(mfp_to_gpio(GPIO49_GPIO
));
246 colibri_pxa320_init_ac97();
247 colibri_pxa320_init_udc();
250 pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_evalboard_pin_config
));
251 colibri_evalboard_init();
254 MACHINE_START(COLIBRI320
, "Toradex Colibri PXA320")
255 .atag_offset
= 0x100,
256 .init_machine
= colibri_pxa320_init
,
257 .map_io
= pxa3xx_map_io
,
258 .nr_irqs
= PXA_NR_IRQS
,
259 .init_irq
= pxa3xx_init_irq
,
260 .handle_irq
= pxa3xx_handle_irq
,
261 .init_time
= pxa_timer_init
,
262 .restart
= pxa_restart
,