blob: f1f24869c03d376c0f119dc094dc9d8a482de14f [file] [log] [blame]
Daniel Mack5fc9f9a2009-03-13 16:37:09 +01001/*
2 * arch/arm/mach-pxa/colibri-pxa300.c
3 *
4 * Support for Toradex PXA300 based Colibri module
5 * Daniel Mack <daniel@caiaq.de>
6 *
7 * 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
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/init.h>
13#include <linux/kernel.h>
14#include <linux/platform_device.h>
15#include <linux/gpio.h>
16#include <net/ax88796.h>
17
18#include <asm/mach-types.h>
19#include <asm/mach/arch.h>
20#include <asm/mach/irq.h>
21
22#include <mach/pxa300.h>
23#include <mach/colibri.h>
Daniel Mackebc046c2009-03-13 16:37:10 +010024#include <mach/mmc.h>
Daniel Mack42e07ad2009-03-13 16:37:11 +010025#include <mach/ohci.h>
Daniel Mack5fc9f9a2009-03-13 16:37:09 +010026
27#include "generic.h"
28#include "devices.h"
29
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 */
Daniel Mackebc046c2009-03-13 16:37:10 +010036
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
Daniel Mack42e07ad2009-03-13 16:37:11 +010045
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
Daniel Mack5fc9f9a2009-03-13 16:37:09 +010050};
51
52#if defined(CONFIG_AX88796)
53/*
54 * Asix AX88796 Ethernet
55 */
56static struct ax_plat_data colibri_asix_platdata = {
57 .flags = AXFLG_MAC_FROMDEV,
58 .wordlength = 2,
59 .dcr_val = 0x01,
60 .rcr_val = 0x0e,
61 .gpoc_val = 0x19
62};
63
64static struct resource colibri_asix_resource[] = {
65 [0] = {
66 .start = PXA3xx_CS2_PHYS,
67 .end = PXA3xx_CS2_PHYS + (0x18 * 0x2) - 1,
68 .flags = IORESOURCE_MEM,
69 },
70 [1] = {
71 .start = PXA3xx_CS2_PHYS + (1 << 11),
72 .end = PXA3xx_CS2_PHYS + (1 << 11) + 0x3fff,
73 .flags = IORESOURCE_MEM,
74 },
75 [2] = {
76 .start = COLIBRI_PXA300_ETH_IRQ,
77 .end = COLIBRI_PXA300_ETH_IRQ,
78 .flags = IORESOURCE_IRQ
79 }
80};
81
82static struct platform_device asix_device = {
83 .name = "ax88796",
84 .id = 0,
85 .num_resources = ARRAY_SIZE(colibri_asix_resource),
86 .resource = colibri_asix_resource,
87 .dev = {
88 .platform_data = &colibri_asix_platdata
89 }
90};
91#endif /* CONFIG_AX88796 */
92
93static struct platform_device *colibri_pxa300_devices[] __initdata = {
94#if defined(CONFIG_AX88796)
95 &asix_device
96#endif
97};
98
Daniel Mackebc046c2009-03-13 16:37:10 +010099#if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
100#define MMC_DETECT_PIN mfp_to_gpio(MFP_PIN_GPIO13)
101
102static int colibri_pxa300_mci_init(struct device *dev,
103 irq_handler_t colibri_mmc_detect_int,
104 void *data)
105{
106 int ret;
107
108 ret = gpio_request(MMC_DETECT_PIN, "mmc card detect");
109 if (ret)
110 return ret;
111
112 gpio_direction_input(MMC_DETECT_PIN);
113 ret = request_irq(gpio_to_irq(MMC_DETECT_PIN), colibri_mmc_detect_int,
114 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
115 "MMC card detect", data);
116 if (ret) {
117 gpio_free(MMC_DETECT_PIN);
118 return ret;
119 }
120
121 return 0;
122}
123
124static void colibri_pxa300_mci_exit(struct device *dev, void *data)
125{
126 free_irq(MMC_DETECT_PIN, data);
127 gpio_free(gpio_to_irq(MMC_DETECT_PIN));
128}
129
130static struct pxamci_platform_data colibri_pxa300_mci_platform_data = {
131 .detect_delay = 20,
132 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
133 .init = colibri_pxa300_mci_init,
134 .exit = colibri_pxa300_mci_exit,
135};
136
137static void __init colibri_pxa300_init_mmc(void)
138{
139 pxa_set_mci_info(&colibri_pxa300_mci_platform_data);
140}
141
142#else
143static inline void colibri_pxa300_init_mmc(void) {}
144#endif /* CONFIG_MMC_PXA */
145
Daniel Mack42e07ad2009-03-13 16:37:11 +0100146#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
147static struct pxaohci_platform_data colibri_pxa300_ohci_info = {
148 .port_mode = PMM_GLOBAL_MODE,
149 .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
150};
151
152static void __init colibri_pxa300_init_ohci(void)
153{
154 pxa_set_ohci_info(&colibri_pxa300_ohci_info);
155}
156#else
157static inline void colibri_pxa300_init_ohci(void) {}
158#endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */
159
Daniel Mack5fc9f9a2009-03-13 16:37:09 +0100160static void __init colibri_pxa300_init(void)
161{
162 set_irq_type(COLIBRI_PXA300_ETH_IRQ, IRQ_TYPE_EDGE_FALLING);
163 pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_pin_config));
164 platform_add_devices(ARRAY_AND_SIZE(colibri_pxa300_devices));
Daniel Mackebc046c2009-03-13 16:37:10 +0100165 colibri_pxa300_init_mmc();
Daniel Mack42e07ad2009-03-13 16:37:11 +0100166 colibri_pxa300_init_ohci();
Daniel Mack5fc9f9a2009-03-13 16:37:09 +0100167}
168
169MACHINE_START(COLIBRI300, "Toradex Colibri PXA300")
170 .phys_io = 0x40000000,
171 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
172 .boot_params = COLIBRI_SDRAM_BASE + 0x100,
173 .init_machine = colibri_pxa300_init,
174 .map_io = pxa_map_io,
175 .init_irq = pxa3xx_init_irq,
176 .timer = &pxa_timer,
177MACHINE_END
178