aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa
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
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')
-rw-r--r--arch/arm/mach-pxa/Kconfig2
-rw-r--r--arch/arm/mach-pxa/Makefile2
-rw-r--r--arch/arm/mach-pxa/colibri-pxa300.c116
-rw-r--r--arch/arm/mach-pxa/colibri-pxa3xx.c75
-rw-r--r--arch/arm/mach-pxa/include/mach/colibri.h18
5 files changed, 119 insertions, 94 deletions
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index 1a93888c68a8..142fd59a40b3 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -266,7 +266,7 @@ config MACH_COLIBRI
266 select PXA27x 266 select PXA27x
267 267
268config MACH_COLIBRI300 268config MACH_COLIBRI300
269 bool "Toradex Colibri PXA300" 269 bool "Toradex Colibri PXA300/310"
270 select PXA3xx 270 select PXA3xx
271 select CPU_PXA300 271 select CPU_PXA300
272 272
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index df6534b49e31..772569383b3b 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -36,7 +36,7 @@ obj-$(CONFIG_MACH_MP900C) += mp900.o
36obj-$(CONFIG_ARCH_PXA_IDP) += idp.o 36obj-$(CONFIG_ARCH_PXA_IDP) += idp.o
37obj-$(CONFIG_MACH_TRIZEPS4) += trizeps4.o 37obj-$(CONFIG_MACH_TRIZEPS4) += trizeps4.o
38obj-$(CONFIG_MACH_COLIBRI) += colibri-pxa270.o 38obj-$(CONFIG_MACH_COLIBRI) += colibri-pxa270.o
39obj-$(CONFIG_MACH_COLIBRI300) += colibri-pxa300.o 39obj-$(CONFIG_MACH_COLIBRI300) += colibri-pxa3xx.o colibri-pxa300.o
40obj-$(CONFIG_MACH_H5000) += h5000.o 40obj-$(CONFIG_MACH_H5000) += h5000.o
41obj-$(CONFIG_PXA_SHARP_C7xx) += corgi.o sharpsl_pm.o corgi_pm.o 41obj-$(CONFIG_PXA_SHARP_C7xx) += corgi.o sharpsl_pm.o corgi_pm.o
42obj-$(CONFIG_PXA_SHARP_Cxx00) += spitz.o sharpsl_pm.o spitz_pm.o 42obj-$(CONFIG_PXA_SHARP_Cxx00) += spitz.o sharpsl_pm.o spitz_pm.o
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")
diff --git a/arch/arm/mach-pxa/colibri-pxa3xx.c b/arch/arm/mach-pxa/colibri-pxa3xx.c
new file mode 100644
index 000000000000..cbaa8424fc86
--- /dev/null
+++ b/arch/arm/mach-pxa/colibri-pxa3xx.c
@@ -0,0 +1,75 @@
1/*
2 * arch/arm/mach-pxa/colibri-pxa3xx.c
3 *
4 * Common functions for all Toradex PXA3xx modules
5 *
6 * Daniel Mack <daniel@caiaq.de>
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/kernel.h>
15#include <linux/platform_device.h>
16#include <linux/gpio.h>
17#include <asm/mach-types.h>
18#include <mach/hardware.h>
19#include <asm/sizes.h>
20#include <asm/mach/arch.h>
21#include <asm/mach/irq.h>
22#include <mach/pxa3xx-regs.h>
23#include <mach/mfp-pxa300.h>
24#include <mach/colibri.h>
25#include <mach/mmc.h>
26
27#include "generic.h"
28#include "devices.h"
29
30#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
31static int mmc_detect_pin;
32
33static int colibri_pxa3xx_mci_init(struct device *dev,
34 irq_handler_t colibri_mmc_detect_int,
35 void *data)
36{
37 int ret;
38
39 ret = gpio_request(mmc_detect_pin, "mmc card detect");
40 if (ret)
41 return ret;
42
43 gpio_direction_input(mmc_detect_pin);
44 ret = request_irq(gpio_to_irq(mmc_detect_pin), colibri_mmc_detect_int,
45 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
46 "MMC card detect", data);
47 if (ret) {
48 gpio_free(mmc_detect_pin);
49 return ret;
50 }
51
52 return 0;
53}
54
55static void colibri_pxa3xx_mci_exit(struct device *dev, void *data)
56{
57 free_irq(mmc_detect_pin, data);
58 gpio_free(gpio_to_irq(mmc_detect_pin));
59}
60
61static struct pxamci_platform_data colibri_pxa3xx_mci_platform_data = {
62 .detect_delay = 20,
63 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
64 .init = colibri_pxa3xx_mci_init,
65 .exit = colibri_pxa3xx_mci_exit,
66};
67
68void __init colibri_pxa3xx_init_mmc(mfp_cfg_t *pins, int len, int detect_pin)
69{
70 pxa3xx_mfp_config(pins, len);
71 mmc_detect_pin = detect_pin;
72 pxa_set_mci_info(&colibri_pxa3xx_mci_platform_data);
73}
74#endif /* CONFIG_MMC_PXA || CONFIG_MMC_PXA_MODULE */
75
diff --git a/arch/arm/mach-pxa/include/mach/colibri.h b/arch/arm/mach-pxa/include/mach/colibri.h
index e295e8df8d64..0becf6215c1d 100644
--- a/arch/arm/mach-pxa/include/mach/colibri.h
+++ b/arch/arm/mach-pxa/include/mach/colibri.h
@@ -4,6 +4,12 @@
4 * common settings for all modules 4 * common settings for all modules
5 */ 5 */
6 6
7#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
8extern void colibri_pxa3xx_init_mmc(mfp_cfg_t *pins, int len, int detect_pin);
9#else
10static inline void colibri_pxa3xx_init_mmc(mfp_cfg_t *, int, int) {}
11#endif
12
7/* physical memory regions */ 13/* physical memory regions */
8#define COLIBRI_SDRAM_BASE 0xa0000000 /* SDRAM region */ 14#define COLIBRI_SDRAM_BASE 0xa0000000 /* SDRAM region */
9 15
@@ -15,17 +21,5 @@
15#define COLIBRI_PXA270_ETH_IRQ \ 21#define COLIBRI_PXA270_ETH_IRQ \
16 gpio_to_irq(mfp_to_gpio(COLIBRI_PXA270_ETH_IRQ_GPIO)) 22 gpio_to_irq(mfp_to_gpio(COLIBRI_PXA270_ETH_IRQ_GPIO))
17 23
18/* definitions for Colibri PXA300 */
19
20#define COLIBRI_PXA300_ETH_IRQ_GPIO 26
21#define COLIBRI_PXA300_ETH_IRQ \
22 gpio_to_irq(mfp_to_gpio(COLIBRI_PXA300_ETH_IRQ_GPIO))
23
24/* definitions for Colibri PXA320 */
25
26#define COLIBRI_PXA320_ETH_IRQ_GPIO 36
27#define COLIBRI_PXA320_ETH_IRQ \
28 gpio_to_irq(mfp_to_gpio(COLIBRI_PXA320_ETH_IRQ_GPIO))
29
30#endif /* _COLIBRI_H_ */ 24#endif /* _COLIBRI_H_ */
31 25