aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/colibri-pxa300.c
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2009-03-22 21:04:17 -0400
committerEric Miao <eric.miao@marvell.com>2009-03-22 21:59:04 -0400
commitacb3655973de30cb74549986e5e118a374967702 (patch)
tree3ed765a1498c77c0dca59b0a2f82de1a96d1a5c7 /arch/arm/mach-pxa/colibri-pxa300.c
parent626806d96fcfe355af5e1d299f651c774f68ead0 (diff)
[ARM] pxa: Refactor Colibri board support code
- Move common function for all Colibri PXA3xx boards to the newly added colibri-pxa3xx.c - Drop some unnecessary defines from colibri.h - Make Kconfig reflect the fact that code for colibri 300 module does also work for the 310 model - Give up on the huge pin config table which was messed up with lots of #ifdefs and switch over to locally defined tables for configured functions Cc: Matthias Meier <matthias.j.meier@gmx.net> Signed-off-by: Daniel Mack <daniel@caiaq.de> Signed-off-by: Eric Miao <eric.miao@marvell.com>
Diffstat (limited to 'arch/arm/mach-pxa/colibri-pxa300.c')
-rw-r--r--arch/arm/mach-pxa/colibri-pxa300.c116
1 files changed, 36 insertions, 80 deletions
diff --git a/arch/arm/mach-pxa/colibri-pxa300.c b/arch/arm/mach-pxa/colibri-pxa300.c
index a5c1f72d88c9..14ef9bf094fa 100644
--- a/arch/arm/mach-pxa/colibri-pxa300.c
+++ b/arch/arm/mach-pxa/colibri-pxa300.c
@@ -1,8 +1,10 @@
1/* 1/*
2 * arch/arm/mach-pxa/colibri-pxa300.c 2 * arch/arm/mach-pxa/colibri-pxa300.c
3 * 3 *
4 * Support for Toradex PXA300 based Colibri module 4 * Support for Toradex PXA300/310 based Colibri module
5 *
5 * Daniel Mack <daniel@caiaq.de> 6 * Daniel Mack <daniel@caiaq.de>
7 * Matthias Meier <matthias.j.meier@gmx.net>
6 * 8 *
7 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 10 * it under the terms of the GNU General Public License version 2 as
@@ -16,40 +18,19 @@
16#include <net/ax88796.h> 18#include <net/ax88796.h>
17 19
18#include <asm/mach-types.h> 20#include <asm/mach-types.h>
21#include <asm/sizes.h>
19#include <asm/mach/arch.h> 22#include <asm/mach/arch.h>
20#include <asm/mach/irq.h> 23#include <asm/mach/irq.h>
21 24
22#include <mach/pxa300.h> 25#include <mach/pxa300.h>
23#include <mach/colibri.h> 26#include <mach/colibri.h>
24#include <mach/mmc.h>
25#include <mach/ohci.h> 27#include <mach/ohci.h>
26 28
27#include "generic.h" 29#include "generic.h"
28#include "devices.h" 30#include "devices.h"
29 31
30/*
31 * GPIO configuration
32 */
33static mfp_cfg_t colibri_pxa300_pin_config[] __initdata = {
34 GPIO1_nCS2, /* AX88796 chip select */
35 GPIO26_GPIO | MFP_PULL_HIGH, /* AX88796 IRQ */
36
37#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
38 GPIO7_MMC1_CLK,
39 GPIO14_MMC1_CMD,
40 GPIO3_MMC1_DAT0,
41 GPIO4_MMC1_DAT1,
42 GPIO5_MMC1_DAT2,
43 GPIO6_MMC1_DAT3,
44#endif
45
46#if defined (CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
47 GPIO0_2_USBH_PEN,
48 GPIO1_2_USBH_PWR,
49#endif
50};
51
52#if defined(CONFIG_AX88796) 32#if defined(CONFIG_AX88796)
33#define COLIBRI_ETH_IRQ_GPIO mfp_to_gpio(GPIO26_GPIO)
53/* 34/*
54 * Asix AX88796 Ethernet 35 * Asix AX88796 Ethernet
55 */ 36 */
@@ -65,8 +46,8 @@ static struct resource colibri_asix_resource[] = {
65 .flags = IORESOURCE_MEM, 46 .flags = IORESOURCE_MEM,
66 }, 47 },
67 [1] = { 48 [1] = {
68 .start = COLIBRI_PXA300_ETH_IRQ, 49 .start = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO),
69 .end = COLIBRI_PXA300_ETH_IRQ, 50 .end = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO),
70 .flags = IORESOURCE_IRQ 51 .flags = IORESOURCE_IRQ
71 } 52 }
72}; 53};
@@ -80,82 +61,57 @@ static struct platform_device asix_device = {
80 .platform_data = &colibri_asix_platdata 61 .platform_data = &colibri_asix_platdata
81 } 62 }
82}; 63};
83#endif /* CONFIG_AX88796 */
84
85static struct platform_device *colibri_pxa300_devices[] __initdata = {
86#if defined(CONFIG_AX88796)
87 &asix_device
88#endif
89};
90
91#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
92#define MMC_DETECT_PIN mfp_to_gpio(MFP_PIN_GPIO13)
93
94static int colibri_pxa300_mci_init(struct device *dev,
95 irq_handler_t colibri_mmc_detect_int,
96 void *data)
97{
98 int ret;
99
100 ret = gpio_request(MMC_DETECT_PIN, "mmc card detect");
101 if (ret)
102 return ret;
103
104 gpio_direction_input(MMC_DETECT_PIN);
105 ret = request_irq(gpio_to_irq(MMC_DETECT_PIN), colibri_mmc_detect_int,
106 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
107 "MMC card detect", data);
108 if (ret) {
109 gpio_free(MMC_DETECT_PIN);
110 return ret;
111 }
112
113 return 0;
114}
115
116static void colibri_pxa300_mci_exit(struct device *dev, void *data)
117{
118 free_irq(MMC_DETECT_PIN, data);
119 gpio_free(gpio_to_irq(MMC_DETECT_PIN));
120}
121 64
122static struct pxamci_platform_data colibri_pxa300_mci_platform_data = { 65static mfp_cfg_t colibri_pxa300_eth_pin_config[] __initdata = {
123 .detect_delay = 20, 66 GPIO1_nCS2, /* AX88796 chip select */
124 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 67 GPIO26_GPIO | MFP_PULL_HIGH /* AX88796 IRQ */
125 .init = colibri_pxa300_mci_init,
126 .exit = colibri_pxa300_mci_exit,
127}; 68};
128 69
129static void __init colibri_pxa300_init_mmc(void) 70static void __init colibri_pxa300_init_eth(void)
130{ 71{
131 pxa_set_mci_info(&colibri_pxa300_mci_platform_data); 72 pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_eth_pin_config));
73 set_irq_type(gpio_to_irq(COLIBRI_ETH_IRQ_GPIO), IRQ_TYPE_EDGE_FALLING);
74 platform_device_register(&asix_device);
132} 75}
133
134#else 76#else
135static inline void colibri_pxa300_init_mmc(void) {} 77static inline void __init colibri_pxa300_init_eth(void) {}
136#endif /* CONFIG_MMC_PXA */ 78#endif /* CONFIG_AX88796 */
137 79
138#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 80#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
81static mfp_cfg_t colibri_pxa300_usb_pin_config[] __initdata = {
82 GPIO0_2_USBH_PEN,
83 GPIO1_2_USBH_PWR,
84};
85
139static struct pxaohci_platform_data colibri_pxa300_ohci_info = { 86static struct pxaohci_platform_data colibri_pxa300_ohci_info = {
140 .port_mode = PMM_GLOBAL_MODE, 87 .port_mode = PMM_GLOBAL_MODE,
141 .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW, 88 .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
142}; 89};
143 90
144static void __init colibri_pxa300_init_ohci(void) 91void __init colibri_pxa300_init_ohci(void)
145{ 92{
93 pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_usb_pin_config));
146 pxa_set_ohci_info(&colibri_pxa300_ohci_info); 94 pxa_set_ohci_info(&colibri_pxa300_ohci_info);
147} 95}
148#else 96#else
149static inline void colibri_pxa300_init_ohci(void) {} 97static inline void colibri_pxa300_init_ohci(void) {}
150#endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */ 98#endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */
151 99
152static void __init colibri_pxa300_init(void) 100static mfp_cfg_t colibri_pxa300_mmc_pin_config[] __initdata = {
101 GPIO7_MMC1_CLK,
102 GPIO14_MMC1_CMD,
103 GPIO3_MMC1_DAT0,
104 GPIO4_MMC1_DAT1,
105 GPIO5_MMC1_DAT2,
106 GPIO6_MMC1_DAT3,
107};
108
109void __init colibri_pxa300_init(void)
153{ 110{
154 set_irq_type(COLIBRI_PXA300_ETH_IRQ, IRQ_TYPE_EDGE_FALLING); 111 colibri_pxa300_init_eth();
155 pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_pin_config));
156 platform_add_devices(ARRAY_AND_SIZE(colibri_pxa300_devices));
157 colibri_pxa300_init_mmc();
158 colibri_pxa300_init_ohci(); 112 colibri_pxa300_init_ohci();
113 colibri_pxa3xx_init_mmc(ARRAY_AND_SIZE(colibri_pxa300_mmc_pin_config),
114 mfp_to_gpio(MFP_PIN_GPIO13));
159} 115}
160 116
161MACHINE_START(COLIBRI300, "Toradex Colibri PXA300") 117MACHINE_START(COLIBRI300, "Toradex Colibri PXA300")