Commit | Line | Data |
---|---|---|
5fc9f9a1 DM |
1 | /* |
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> | |
ebc046c2 | 24 | #include <mach/mmc.h> |
5fc9f9a1 DM |
25 | |
26 | #include "generic.h" | |
27 | #include "devices.h" | |
28 | ||
29 | /* | |
30 | * GPIO configuration | |
31 | */ | |
32 | static mfp_cfg_t colibri_pxa300_pin_config[] __initdata = { | |
33 | GPIO1_nCS2, /* AX88796 chip select */ | |
34 | GPIO26_GPIO | MFP_PULL_HIGH, /* AX88796 IRQ */ | |
ebc046c2 DM |
35 | |
36 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) | |
37 | GPIO7_MMC1_CLK, | |
38 | GPIO14_MMC1_CMD, | |
39 | GPIO3_MMC1_DAT0, | |
40 | GPIO4_MMC1_DAT1, | |
41 | GPIO5_MMC1_DAT2, | |
42 | GPIO6_MMC1_DAT3, | |
43 | #endif | |
5fc9f9a1 DM |
44 | }; |
45 | ||
46 | #if defined(CONFIG_AX88796) | |
47 | /* | |
48 | * Asix AX88796 Ethernet | |
49 | */ | |
50 | static struct ax_plat_data colibri_asix_platdata = { | |
51 | .flags = AXFLG_MAC_FROMDEV, | |
52 | .wordlength = 2, | |
53 | .dcr_val = 0x01, | |
54 | .rcr_val = 0x0e, | |
55 | .gpoc_val = 0x19 | |
56 | }; | |
57 | ||
58 | static struct resource colibri_asix_resource[] = { | |
59 | [0] = { | |
60 | .start = PXA3xx_CS2_PHYS, | |
61 | .end = PXA3xx_CS2_PHYS + (0x18 * 0x2) - 1, | |
62 | .flags = IORESOURCE_MEM, | |
63 | }, | |
64 | [1] = { | |
65 | .start = PXA3xx_CS2_PHYS + (1 << 11), | |
66 | .end = PXA3xx_CS2_PHYS + (1 << 11) + 0x3fff, | |
67 | .flags = IORESOURCE_MEM, | |
68 | }, | |
69 | [2] = { | |
70 | .start = COLIBRI_PXA300_ETH_IRQ, | |
71 | .end = COLIBRI_PXA300_ETH_IRQ, | |
72 | .flags = IORESOURCE_IRQ | |
73 | } | |
74 | }; | |
75 | ||
76 | static struct platform_device asix_device = { | |
77 | .name = "ax88796", | |
78 | .id = 0, | |
79 | .num_resources = ARRAY_SIZE(colibri_asix_resource), | |
80 | .resource = colibri_asix_resource, | |
81 | .dev = { | |
82 | .platform_data = &colibri_asix_platdata | |
83 | } | |
84 | }; | |
85 | #endif /* CONFIG_AX88796 */ | |
86 | ||
87 | static struct platform_device *colibri_pxa300_devices[] __initdata = { | |
88 | #if defined(CONFIG_AX88796) | |
89 | &asix_device | |
90 | #endif | |
91 | }; | |
92 | ||
ebc046c2 DM |
93 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) |
94 | #define MMC_DETECT_PIN mfp_to_gpio(MFP_PIN_GPIO13) | |
95 | ||
96 | static int colibri_pxa300_mci_init(struct device *dev, | |
97 | irq_handler_t colibri_mmc_detect_int, | |
98 | void *data) | |
99 | { | |
100 | int ret; | |
101 | ||
102 | ret = gpio_request(MMC_DETECT_PIN, "mmc card detect"); | |
103 | if (ret) | |
104 | return ret; | |
105 | ||
106 | gpio_direction_input(MMC_DETECT_PIN); | |
107 | ret = request_irq(gpio_to_irq(MMC_DETECT_PIN), colibri_mmc_detect_int, | |
108 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | |
109 | "MMC card detect", data); | |
110 | if (ret) { | |
111 | gpio_free(MMC_DETECT_PIN); | |
112 | return ret; | |
113 | } | |
114 | ||
115 | return 0; | |
116 | } | |
117 | ||
118 | static void colibri_pxa300_mci_exit(struct device *dev, void *data) | |
119 | { | |
120 | free_irq(MMC_DETECT_PIN, data); | |
121 | gpio_free(gpio_to_irq(MMC_DETECT_PIN)); | |
122 | } | |
123 | ||
124 | static struct pxamci_platform_data colibri_pxa300_mci_platform_data = { | |
125 | .detect_delay = 20, | |
126 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, | |
127 | .init = colibri_pxa300_mci_init, | |
128 | .exit = colibri_pxa300_mci_exit, | |
129 | }; | |
130 | ||
131 | static void __init colibri_pxa300_init_mmc(void) | |
132 | { | |
133 | pxa_set_mci_info(&colibri_pxa300_mci_platform_data); | |
134 | } | |
135 | ||
136 | #else | |
137 | static inline void colibri_pxa300_init_mmc(void) {} | |
138 | #endif /* CONFIG_MMC_PXA */ | |
139 | ||
5fc9f9a1 DM |
140 | static void __init colibri_pxa300_init(void) |
141 | { | |
142 | set_irq_type(COLIBRI_PXA300_ETH_IRQ, IRQ_TYPE_EDGE_FALLING); | |
143 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_pin_config)); | |
144 | platform_add_devices(ARRAY_AND_SIZE(colibri_pxa300_devices)); | |
ebc046c2 | 145 | colibri_pxa300_init_mmc(); |
5fc9f9a1 DM |
146 | } |
147 | ||
148 | MACHINE_START(COLIBRI300, "Toradex Colibri PXA300") | |
149 | .phys_io = 0x40000000, | |
150 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, | |
151 | .boot_params = COLIBRI_SDRAM_BASE + 0x100, | |
152 | .init_machine = colibri_pxa300_init, | |
153 | .map_io = pxa_map_io, | |
154 | .init_irq = pxa3xx_init_irq, | |
155 | .timer = &pxa_timer, | |
156 | MACHINE_END | |
157 |