Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * linux/arch/arm/mach-pxa/generic.c | |
3 | * | |
4 | * Author: Nicolas Pitre | |
5 | * Created: Jun 15, 2001 | |
6 | * Copyright: MontaVista Software Inc. | |
7 | * | |
8 | * Code common to all PXA machines. | |
9 | * | |
10 | * This program is free software; you can redistribute it and/or modify | |
11 | * it under the terms of the GNU General Public License version 2 as | |
12 | * published by the Free Software Foundation. | |
13 | * | |
14 | * Since this file should be linked before any other machine specific file, | |
15 | * the __initcall() here will be executed first. This serves as default | |
16 | * initialization stuff for PXA machines which can be overridden later if | |
17 | * need be. | |
18 | */ | |
19 | #include <linux/module.h> | |
20 | #include <linux/kernel.h> | |
21 | #include <linux/init.h> | |
22 | #include <linux/delay.h> | |
23 | #include <linux/device.h> | |
24 | #include <linux/ioport.h> | |
25 | #include <linux/pm.h> | |
26 | ||
27 | #include <asm/hardware.h> | |
28 | #include <asm/irq.h> | |
29 | #include <asm/system.h> | |
30 | #include <asm/pgtable.h> | |
31 | #include <asm/mach/map.h> | |
32 | ||
33 | #include <asm/arch/pxa-regs.h> | |
34 | #include <asm/arch/udc.h> | |
35 | #include <asm/arch/pxafb.h> | |
36 | #include <asm/arch/mmc.h> | |
eb9181a2 | 37 | #include <asm/arch/i2c.h> |
1da177e4 LT |
38 | |
39 | #include "generic.h" | |
40 | ||
41 | /* | |
42 | * Handy function to set GPIO alternate functions | |
43 | */ | |
44 | ||
45 | void pxa_gpio_mode(int gpio_mode) | |
46 | { | |
47 | unsigned long flags; | |
48 | int gpio = gpio_mode & GPIO_MD_MASK_NR; | |
49 | int fn = (gpio_mode & GPIO_MD_MASK_FN) >> 8; | |
50 | int gafr; | |
51 | ||
52 | local_irq_save(flags); | |
53 | if (gpio_mode & GPIO_DFLT_LOW) | |
54 | GPCR(gpio) = GPIO_bit(gpio); | |
55 | else if (gpio_mode & GPIO_DFLT_HIGH) | |
56 | GPSR(gpio) = GPIO_bit(gpio); | |
57 | if (gpio_mode & GPIO_MD_MASK_DIR) | |
58 | GPDR(gpio) |= GPIO_bit(gpio); | |
59 | else | |
60 | GPDR(gpio) &= ~GPIO_bit(gpio); | |
61 | gafr = GAFR(gpio) & ~(0x3 << (((gpio) & 0xf)*2)); | |
62 | GAFR(gpio) = gafr | (fn << (((gpio) & 0xf)*2)); | |
63 | local_irq_restore(flags); | |
64 | } | |
65 | ||
66 | EXPORT_SYMBOL(pxa_gpio_mode); | |
67 | ||
68 | /* | |
69 | * Routine to safely enable or disable a clock in the CKEN | |
70 | */ | |
71 | void pxa_set_cken(int clock, int enable) | |
72 | { | |
73 | unsigned long flags; | |
74 | local_irq_save(flags); | |
75 | ||
76 | if (enable) | |
77 | CKEN |= clock; | |
78 | else | |
79 | CKEN &= ~clock; | |
80 | ||
81 | local_irq_restore(flags); | |
82 | } | |
83 | ||
84 | EXPORT_SYMBOL(pxa_set_cken); | |
85 | ||
86 | /* | |
87 | * Intel PXA2xx internal register mapping. | |
88 | * | |
89 | * Note 1: not all PXA2xx variants implement all those addresses. | |
90 | * | |
91 | * Note 2: virtual 0xfffe0000-0xffffffff is reserved for the vector table | |
92 | * and cache flush area. | |
93 | */ | |
94 | static struct map_desc standard_io_desc[] __initdata = { | |
6f9182eb DS |
95 | { /* Devs */ |
96 | .virtual = 0xf2000000, | |
97 | .pfn = __phys_to_pfn(0x40000000), | |
98 | .length = 0x02000000, | |
99 | .type = MT_DEVICE | |
100 | }, { /* LCD */ | |
101 | .virtual = 0xf4000000, | |
102 | .pfn = __phys_to_pfn(0x44000000), | |
103 | .length = 0x00100000, | |
104 | .type = MT_DEVICE | |
105 | }, { /* Mem Ctl */ | |
106 | .virtual = 0xf6000000, | |
107 | .pfn = __phys_to_pfn(0x48000000), | |
108 | .length = 0x00100000, | |
109 | .type = MT_DEVICE | |
110 | }, { /* USB host */ | |
111 | .virtual = 0xf8000000, | |
112 | .pfn = __phys_to_pfn(0x4c000000), | |
113 | .length = 0x00100000, | |
114 | .type = MT_DEVICE | |
115 | }, { /* Camera */ | |
116 | .virtual = 0xfa000000, | |
117 | .pfn = __phys_to_pfn(0x50000000), | |
118 | .length = 0x00100000, | |
119 | .type = MT_DEVICE | |
120 | }, { /* IMem ctl */ | |
121 | .virtual = 0xfe000000, | |
122 | .pfn = __phys_to_pfn(0x58000000), | |
123 | .length = 0x00100000, | |
124 | .type = MT_DEVICE | |
125 | }, { /* UNCACHED_PHYS_0 */ | |
126 | .virtual = 0xff000000, | |
127 | .pfn = __phys_to_pfn(0x00000000), | |
128 | .length = 0x00100000, | |
129 | .type = MT_DEVICE | |
130 | } | |
1da177e4 LT |
131 | }; |
132 | ||
133 | void __init pxa_map_io(void) | |
134 | { | |
135 | iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc)); | |
136 | get_clk_frequency_khz(1); | |
137 | } | |
138 | ||
139 | ||
140 | static struct resource pxamci_resources[] = { | |
141 | [0] = { | |
142 | .start = 0x41100000, | |
143 | .end = 0x41100fff, | |
144 | .flags = IORESOURCE_MEM, | |
145 | }, | |
146 | [1] = { | |
147 | .start = IRQ_MMC, | |
148 | .end = IRQ_MMC, | |
149 | .flags = IORESOURCE_IRQ, | |
150 | }, | |
151 | }; | |
152 | ||
153 | static u64 pxamci_dmamask = 0xffffffffUL; | |
154 | ||
155 | static struct platform_device pxamci_device = { | |
156 | .name = "pxa2xx-mci", | |
157 | .id = -1, | |
158 | .dev = { | |
159 | .dma_mask = &pxamci_dmamask, | |
160 | .coherent_dma_mask = 0xffffffff, | |
161 | }, | |
162 | .num_resources = ARRAY_SIZE(pxamci_resources), | |
163 | .resource = pxamci_resources, | |
164 | }; | |
165 | ||
166 | void __init pxa_set_mci_info(struct pxamci_platform_data *info) | |
167 | { | |
168 | pxamci_device.dev.platform_data = info; | |
169 | } | |
170 | ||
171 | ||
172 | static struct pxa2xx_udc_mach_info pxa_udc_info; | |
173 | ||
174 | void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info) | |
175 | { | |
176 | memcpy(&pxa_udc_info, info, sizeof *info); | |
177 | } | |
178 | ||
179 | static struct resource pxa2xx_udc_resources[] = { | |
180 | [0] = { | |
181 | .start = 0x40600000, | |
182 | .end = 0x4060ffff, | |
183 | .flags = IORESOURCE_MEM, | |
184 | }, | |
185 | [1] = { | |
186 | .start = IRQ_USB, | |
187 | .end = IRQ_USB, | |
188 | .flags = IORESOURCE_IRQ, | |
189 | }, | |
190 | }; | |
191 | ||
192 | static u64 udc_dma_mask = ~(u32)0; | |
193 | ||
194 | static struct platform_device udc_device = { | |
195 | .name = "pxa2xx-udc", | |
196 | .id = -1, | |
197 | .resource = pxa2xx_udc_resources, | |
198 | .num_resources = ARRAY_SIZE(pxa2xx_udc_resources), | |
199 | .dev = { | |
200 | .platform_data = &pxa_udc_info, | |
201 | .dma_mask = &udc_dma_mask, | |
202 | } | |
203 | }; | |
204 | ||
205 | static struct pxafb_mach_info pxa_fb_info; | |
206 | ||
207 | void __init set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info) | |
208 | { | |
209 | memcpy(&pxa_fb_info,hard_pxa_fb_info,sizeof(struct pxafb_mach_info)); | |
210 | } | |
211 | ||
212 | static struct resource pxafb_resources[] = { | |
213 | [0] = { | |
214 | .start = 0x44000000, | |
215 | .end = 0x4400ffff, | |
216 | .flags = IORESOURCE_MEM, | |
217 | }, | |
218 | [1] = { | |
219 | .start = IRQ_LCD, | |
220 | .end = IRQ_LCD, | |
221 | .flags = IORESOURCE_IRQ, | |
222 | }, | |
223 | }; | |
224 | ||
225 | static u64 fb_dma_mask = ~(u64)0; | |
226 | ||
227 | static struct platform_device pxafb_device = { | |
228 | .name = "pxa2xx-fb", | |
229 | .id = -1, | |
230 | .dev = { | |
231 | .platform_data = &pxa_fb_info, | |
232 | .dma_mask = &fb_dma_mask, | |
233 | .coherent_dma_mask = 0xffffffff, | |
234 | }, | |
235 | .num_resources = ARRAY_SIZE(pxafb_resources), | |
236 | .resource = pxafb_resources, | |
237 | }; | |
238 | ||
cb38c569 RP |
239 | void __init set_pxa_fb_parent(struct device *parent_dev) |
240 | { | |
241 | pxafb_device.dev.parent = parent_dev; | |
242 | } | |
243 | ||
1da177e4 LT |
244 | static struct platform_device ffuart_device = { |
245 | .name = "pxa2xx-uart", | |
246 | .id = 0, | |
247 | }; | |
248 | static struct platform_device btuart_device = { | |
249 | .name = "pxa2xx-uart", | |
250 | .id = 1, | |
251 | }; | |
252 | static struct platform_device stuart_device = { | |
253 | .name = "pxa2xx-uart", | |
254 | .id = 2, | |
255 | }; | |
256 | ||
bb9bffcb RK |
257 | static struct resource i2c_resources[] = { |
258 | { | |
259 | .start = 0x40301680, | |
260 | .end = 0x403016a3, | |
261 | .flags = IORESOURCE_MEM, | |
262 | }, { | |
263 | .start = IRQ_I2C, | |
264 | .end = IRQ_I2C, | |
265 | .flags = IORESOURCE_IRQ, | |
266 | }, | |
267 | }; | |
268 | ||
269 | static struct platform_device i2c_device = { | |
270 | .name = "pxa2xx-i2c", | |
271 | .id = 0, | |
272 | .resource = i2c_resources, | |
273 | .num_resources = ARRAY_SIZE(i2c_resources), | |
274 | }; | |
275 | ||
276 | void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info) | |
277 | { | |
278 | i2c_device.dev.platform_data = info; | |
279 | } | |
280 | ||
b2640b42 MR |
281 | static struct resource i2s_resources[] = { |
282 | { | |
283 | .start = 0x40400000, | |
284 | .end = 0x40400083, | |
285 | .flags = IORESOURCE_MEM, | |
286 | }, { | |
287 | .start = IRQ_I2S, | |
288 | .end = IRQ_I2S, | |
289 | .flags = IORESOURCE_IRQ, | |
290 | }, | |
291 | }; | |
292 | ||
293 | static struct platform_device i2s_device = { | |
294 | .name = "pxa2xx-i2s", | |
295 | .id = -1, | |
296 | .resource = i2c_resources, | |
297 | .num_resources = ARRAY_SIZE(i2s_resources), | |
298 | }; | |
299 | ||
1da177e4 LT |
300 | static struct platform_device *devices[] __initdata = { |
301 | &pxamci_device, | |
302 | &udc_device, | |
303 | &pxafb_device, | |
304 | &ffuart_device, | |
305 | &btuart_device, | |
306 | &stuart_device, | |
bb9bffcb | 307 | &i2c_device, |
b2640b42 | 308 | &i2s_device, |
1da177e4 LT |
309 | }; |
310 | ||
311 | static int __init pxa_init(void) | |
312 | { | |
313 | return platform_add_devices(devices, ARRAY_SIZE(devices)); | |
314 | } | |
315 | ||
316 | subsys_initcall(pxa_init); |