aboutsummaryrefslogtreecommitdiff
path: root/arch/arm
diff options
context:
space:
mode:
authorDaniel Mack <daniel@caiaq.de>2009-03-23 02:04:17 +0100
committerEric Miao <eric.miao@marvell.com>2009-03-23 09:59:04 +0800
commitacb3655973de30cb74549986e5e118a374967702 (patch)
tree3ed765a1498c77c0dca59b0a2f82de1a96d1a5c7 /arch/arm
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')
-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 1a93888c68a..142fd59a40b 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -266,7 +266,7 @@ config MACH_COLIBRI
select PXA27x
config MACH_COLIBRI300
- bool "Toradex Colibri PXA300"
+ bool "Toradex Colibri PXA300/310"
select PXA3xx
select CPU_PXA300
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index df6534b49e3..772569383b3 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -36,7 +36,7 @@ obj-$(CONFIG_MACH_MP900C) += mp900.o
obj-$(CONFIG_ARCH_PXA_IDP) += idp.o
obj-$(CONFIG_MACH_TRIZEPS4) += trizeps4.o
obj-$(CONFIG_MACH_COLIBRI) += colibri-pxa270.o
-obj-$(CONFIG_MACH_COLIBRI300) += colibri-pxa300.o
+obj-$(CONFIG_MACH_COLIBRI300) += colibri-pxa3xx.o colibri-pxa300.o
obj-$(CONFIG_MACH_H5000) += h5000.o
obj-$(CONFIG_PXA_SHARP_C7xx) += corgi.o sharpsl_pm.o corgi_pm.o
obj-$(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 a5c1f72d88c..14ef9bf094f 100644
--- a/arch/arm/mach-pxa/colibri-pxa300.c
+++ b/arch/arm/mach-pxa/colibri-pxa300.c
@@ -1,8 +1,10 @@
/*
* arch/arm/mach-pxa/colibri-pxa300.c
*
- * Support for Toradex PXA300 based Colibri module
+ * Support for Toradex PXA300/310 based Colibri module
+ *
* Daniel Mack <daniel@caiaq.de>
+ * Matthias Meier <matthias.j.meier@gmx.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
@@ -16,40 +18,19 @@
#include <net/ax88796.h>
#include <asm/mach-types.h>
+#include <asm/sizes.h>
#include <asm/mach/arch.h>
#include <asm/mach/irq.h>
#include <mach/pxa300.h>
#include <mach/colibri.h>
-#include <mach/mmc.h>
#include <mach/ohci.h>
#include "generic.h"
#include "devices.h"
-/*
- * GPIO configuration
- */
-static mfp_cfg_t colibri_pxa300_pin_config[] __initdata = {
- GPIO1_nCS2, /* AX88796 chip select */
- GPIO26_GPIO | MFP_PULL_HIGH, /* AX88796 IRQ */
-
-#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
- GPIO7_MMC1_CLK,
- GPIO14_MMC1_CMD,
- GPIO3_MMC1_DAT0,
- GPIO4_MMC1_DAT1,
- GPIO5_MMC1_DAT2,
- GPIO6_MMC1_DAT3,
-#endif
-
-#if defined (CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
- GPIO0_2_USBH_PEN,
- GPIO1_2_USBH_PWR,
-#endif
-};
-
#if defined(CONFIG_AX88796)
+#define COLIBRI_ETH_IRQ_GPIO mfp_to_gpio(GPIO26_GPIO)
/*
* Asix AX88796 Ethernet
*/
@@ -65,8 +46,8 @@ static struct resource colibri_asix_resource[] = {
.flags = IORESOURCE_MEM,
},
[1] = {
- .start = COLIBRI_PXA300_ETH_IRQ,
- .end = COLIBRI_PXA300_ETH_IRQ,
+ .start = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO),
+ .end = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO),
.flags = IORESOURCE_IRQ
}
};
@@ -80,82 +61,57 @@ static struct platform_device asix_device = {
.platform_data = &colibri_asix_platdata
}
};
-#endif /* CONFIG_AX88796 */
-
-static struct platform_device *colibri_pxa300_devices[] __initdata = {
-#if defined(CONFIG_AX88796)
- &asix_device
-#endif
-};
-
-#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
-#define MMC_DETECT_PIN mfp_to_gpio(MFP_PIN_GPIO13)
-
-static int colibri_pxa300_mci_init(struct device *dev,
- irq_handler_t colibri_mmc_detect_int,
- void *data)
-{
- int ret;
-
- ret = gpio_request(MMC_DETECT_PIN, "mmc card detect");
- if (ret)
- return ret;
-
- gpio_direction_input(MMC_DETECT_PIN);
- ret = request_irq(gpio_to_irq(MMC_DETECT_PIN), colibri_mmc_detect_int,
- IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
- "MMC card detect", data);
- if (ret) {
- gpio_free(MMC_DETECT_PIN);
- return ret;
- }
-
- return 0;
-}
-
-static void colibri_pxa300_mci_exit(struct device *dev, void *data)
-{
- free_irq(MMC_DETECT_PIN, data);
- gpio_free(gpio_to_irq(MMC_DETECT_PIN));
-}
-static struct pxamci_platform_data colibri_pxa300_mci_platform_data = {
- .detect_delay = 20,
- .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
- .init = colibri_pxa300_mci_init,
- .exit = colibri_pxa300_mci_exit,
+static mfp_cfg_t colibri_pxa300_eth_pin_config[] __initdata = {
+ GPIO1_nCS2, /* AX88796 chip select */
+ GPIO26_GPIO | MFP_PULL_HIGH /* AX88796 IRQ */
};
-static void __init colibri_pxa300_init_mmc(void)
+static void __init colibri_pxa300_init_eth(void)
{
- pxa_set_mci_info(&colibri_pxa300_mci_platform_data);
+ pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_eth_pin_config));
+ set_irq_type(gpio_to_irq(COLIBRI_ETH_IRQ_GPIO), IRQ_TYPE_EDGE_FALLING);
+ platform_device_register(&asix_device);
}
-
#else
-static inline void colibri_pxa300_init_mmc(void) {}
-#endif /* CONFIG_MMC_PXA */
+static inline void __init colibri_pxa300_init_eth(void) {}
+#endif /* CONFIG_AX88796 */
#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
+static mfp_cfg_t colibri_pxa300_usb_pin_config[] __initdata = {
+ GPIO0_2_USBH_PEN,
+ GPIO1_2_USBH_PWR,
+};
+
static struct pxaohci_platform_data colibri_pxa300_ohci_info = {
.port_mode = PMM_GLOBAL_MODE,
.flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
};
-static void __init colibri_pxa300_init_ohci(void)
+void __init colibri_pxa300_init_ohci(void)
{
+ pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_usb_pin_config));
pxa_set_ohci_info(&colibri_pxa300_ohci_info);
}
#else
static inline void colibri_pxa300_init_ohci(void) {}
#endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */
-static void __init colibri_pxa300_init(void)
+static mfp_cfg_t colibri_pxa300_mmc_pin_config[] __initdata = {
+ GPIO7_MMC1_CLK,
+ GPIO14_MMC1_CMD,
+ GPIO3_MMC1_DAT0,
+ GPIO4_MMC1_DAT1,
+ GPIO5_MMC1_DAT2,
+ GPIO6_MMC1_DAT3,
+};
+
+void __init colibri_pxa300_init(void)
{
- set_irq_type(COLIBRI_PXA300_ETH_IRQ, IRQ_TYPE_EDGE_FALLING);
- pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_pin_config));
- platform_add_devices(ARRAY_AND_SIZE(colibri_pxa300_devices));
- colibri_pxa300_init_mmc();
+ colibri_pxa300_init_eth();
colibri_pxa300_init_ohci();
+ colibri_pxa3xx_init_mmc(ARRAY_AND_SIZE(colibri_pxa300_mmc_pin_config),
+ mfp_to_gpio(MFP_PIN_GPIO13));
}
MACHINE_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 00000000000..cbaa8424fc8
--- /dev/null
+++ b/arch/arm/mach-pxa/colibri-pxa3xx.c
@@ -0,0 +1,75 @@
+/*
+ * arch/arm/mach-pxa/colibri-pxa3xx.c
+ *
+ * Common functions for all Toradex PXA3xx modules
+ *
+ * Daniel Mack <daniel@caiaq.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/platform_device.h>
+#include <linux/gpio.h>
+#include <asm/mach-types.h>
+#include <mach/hardware.h>
+#include <asm/sizes.h>
+#include <asm/mach/arch.h>
+#include <asm/mach/irq.h>
+#include <mach/pxa3xx-regs.h>
+#include <mach/mfp-pxa300.h>
+#include <mach/colibri.h>
+#include <mach/mmc.h>
+
+#include "generic.h"
+#include "devices.h"
+
+#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
+static int mmc_detect_pin;
+
+static int colibri_pxa3xx_mci_init(struct device *dev,
+ irq_handler_t colibri_mmc_detect_int,
+ void *data)
+{
+ int ret;
+
+ ret = gpio_request(mmc_detect_pin, "mmc card detect");
+ if (ret)
+ return ret;
+
+ gpio_direction_input(mmc_detect_pin);
+ ret = request_irq(gpio_to_irq(mmc_detect_pin), colibri_mmc_detect_int,
+ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
+ "MMC card detect", data);
+ if (ret) {
+ gpio_free(mmc_detect_pin);
+ return ret;
+ }
+
+ return 0;
+}
+
+static void colibri_pxa3xx_mci_exit(struct device *dev, void *data)
+{
+ free_irq(mmc_detect_pin, data);
+ gpio_free(gpio_to_irq(mmc_detect_pin));
+}
+
+static struct pxamci_platform_data colibri_pxa3xx_mci_platform_data = {
+ .detect_delay = 20,
+ .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
+ .init = colibri_pxa3xx_mci_init,
+ .exit = colibri_pxa3xx_mci_exit,
+};
+
+void __init colibri_pxa3xx_init_mmc(mfp_cfg_t *pins, int len, int detect_pin)
+{
+ pxa3xx_mfp_config(pins, len);
+ mmc_detect_pin = detect_pin;
+ pxa_set_mci_info(&colibri_pxa3xx_mci_platform_data);
+}
+#endif /* CONFIG_MMC_PXA || CONFIG_MMC_PXA_MODULE */
+
diff --git a/arch/arm/mach-pxa/include/mach/colibri.h b/arch/arm/mach-pxa/include/mach/colibri.h
index e295e8df8d6..0becf6215c1 100644
--- a/arch/arm/mach-pxa/include/mach/colibri.h
+++ b/arch/arm/mach-pxa/include/mach/colibri.h
@@ -4,6 +4,12 @@
* common settings for all modules
*/
+#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
+extern void colibri_pxa3xx_init_mmc(mfp_cfg_t *pins, int len, int detect_pin);
+#else
+static inline void colibri_pxa3xx_init_mmc(mfp_cfg_t *, int, int) {}
+#endif
+
/* physical memory regions */
#define COLIBRI_SDRAM_BASE 0xa0000000 /* SDRAM region */
@@ -15,17 +21,5 @@
#define COLIBRI_PXA270_ETH_IRQ \
gpio_to_irq(mfp_to_gpio(COLIBRI_PXA270_ETH_IRQ_GPIO))
-/* definitions for Colibri PXA300 */
-
-#define COLIBRI_PXA300_ETH_IRQ_GPIO 26
-#define COLIBRI_PXA300_ETH_IRQ \
- gpio_to_irq(mfp_to_gpio(COLIBRI_PXA300_ETH_IRQ_GPIO))
-
-/* definitions for Colibri PXA320 */
-
-#define COLIBRI_PXA320_ETH_IRQ_GPIO 36
-#define COLIBRI_PXA320_ETH_IRQ \
- gpio_to_irq(mfp_to_gpio(COLIBRI_PXA320_ETH_IRQ_GPIO))
-
#endif /* _COLIBRI_H_ */