2 * linux/arch/arm/mach-pxa/generic.c
4 * Author: Nicolas Pitre
5 * Created: Jun 15, 2001
6 * Copyright: MontaVista Software Inc.
8 * Code common to all PXA machines.
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.
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
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>
27 #include <asm/hardware.h>
29 #include <asm/system.h>
30 #include <asm/pgtable.h>
31 #include <asm/mach/map.h>
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>
37 #include <asm/arch/irda.h>
38 #include <asm/arch/i2c.h>
43 * Handy function to set GPIO alternate functions
46 void pxa_gpio_mode(int gpio_mode
)
49 int gpio
= gpio_mode
& GPIO_MD_MASK_NR
;
50 int fn
= (gpio_mode
& GPIO_MD_MASK_FN
) >> 8;
53 local_irq_save(flags
);
54 if (gpio_mode
& GPIO_DFLT_LOW
)
55 GPCR(gpio
) = GPIO_bit(gpio
);
56 else if (gpio_mode
& GPIO_DFLT_HIGH
)
57 GPSR(gpio
) = GPIO_bit(gpio
);
58 if (gpio_mode
& GPIO_MD_MASK_DIR
)
59 GPDR(gpio
) |= GPIO_bit(gpio
);
61 GPDR(gpio
) &= ~GPIO_bit(gpio
);
62 gafr
= GAFR(gpio
) & ~(0x3 << (((gpio
) & 0xf)*2));
63 GAFR(gpio
) = gafr
| (fn
<< (((gpio
) & 0xf)*2));
64 local_irq_restore(flags
);
67 EXPORT_SYMBOL(pxa_gpio_mode
);
70 * Routine to safely enable or disable a clock in the CKEN
72 void pxa_set_cken(int clock
, int enable
)
75 local_irq_save(flags
);
82 local_irq_restore(flags
);
85 EXPORT_SYMBOL(pxa_set_cken
);
88 * Intel PXA2xx internal register mapping.
90 * Note 1: not all PXA2xx variants implement all those addresses.
92 * Note 2: virtual 0xfffe0000-0xffffffff is reserved for the vector table
93 * and cache flush area.
95 static struct map_desc standard_io_desc
[] __initdata
= {
97 .virtual = 0xf2000000,
98 .pfn
= __phys_to_pfn(0x40000000),
102 .virtual = 0xf4000000,
103 .pfn
= __phys_to_pfn(0x44000000),
104 .length
= 0x00100000,
107 .virtual = 0xf6000000,
108 .pfn
= __phys_to_pfn(0x48000000),
109 .length
= 0x00100000,
112 .virtual = 0xf8000000,
113 .pfn
= __phys_to_pfn(0x4c000000),
114 .length
= 0x00100000,
117 .virtual = 0xfa000000,
118 .pfn
= __phys_to_pfn(0x50000000),
119 .length
= 0x00100000,
122 .virtual = 0xfe000000,
123 .pfn
= __phys_to_pfn(0x58000000),
124 .length
= 0x00100000,
126 }, { /* UNCACHED_PHYS_0 */
127 .virtual = 0xff000000,
128 .pfn
= __phys_to_pfn(0x00000000),
129 .length
= 0x00100000,
134 void __init
pxa_map_io(void)
136 iotable_init(standard_io_desc
, ARRAY_SIZE(standard_io_desc
));
137 get_clk_frequency_khz(1);
141 static struct resource pxamci_resources
[] = {
145 .flags
= IORESOURCE_MEM
,
150 .flags
= IORESOURCE_IRQ
,
154 static u64 pxamci_dmamask
= 0xffffffffUL
;
156 static struct platform_device pxamci_device
= {
157 .name
= "pxa2xx-mci",
160 .dma_mask
= &pxamci_dmamask
,
161 .coherent_dma_mask
= 0xffffffff,
163 .num_resources
= ARRAY_SIZE(pxamci_resources
),
164 .resource
= pxamci_resources
,
167 void __init
pxa_set_mci_info(struct pxamci_platform_data
*info
)
169 pxamci_device
.dev
.platform_data
= info
;
173 static struct pxa2xx_udc_mach_info pxa_udc_info
;
175 void __init
pxa_set_udc_info(struct pxa2xx_udc_mach_info
*info
)
177 memcpy(&pxa_udc_info
, info
, sizeof *info
);
180 static struct resource pxa2xx_udc_resources
[] = {
184 .flags
= IORESOURCE_MEM
,
189 .flags
= IORESOURCE_IRQ
,
193 static u64 udc_dma_mask
= ~(u32
)0;
195 static struct platform_device udc_device
= {
196 .name
= "pxa2xx-udc",
198 .resource
= pxa2xx_udc_resources
,
199 .num_resources
= ARRAY_SIZE(pxa2xx_udc_resources
),
201 .platform_data
= &pxa_udc_info
,
202 .dma_mask
= &udc_dma_mask
,
206 static struct pxafb_mach_info pxa_fb_info
;
208 void __init
set_pxa_fb_info(struct pxafb_mach_info
*hard_pxa_fb_info
)
210 memcpy(&pxa_fb_info
,hard_pxa_fb_info
,sizeof(struct pxafb_mach_info
));
213 static struct resource pxafb_resources
[] = {
217 .flags
= IORESOURCE_MEM
,
222 .flags
= IORESOURCE_IRQ
,
226 static u64 fb_dma_mask
= ~(u64
)0;
228 static struct platform_device pxafb_device
= {
232 .platform_data
= &pxa_fb_info
,
233 .dma_mask
= &fb_dma_mask
,
234 .coherent_dma_mask
= 0xffffffff,
236 .num_resources
= ARRAY_SIZE(pxafb_resources
),
237 .resource
= pxafb_resources
,
240 void __init
set_pxa_fb_parent(struct device
*parent_dev
)
242 pxafb_device
.dev
.parent
= parent_dev
;
245 static struct platform_device ffuart_device
= {
246 .name
= "pxa2xx-uart",
249 static struct platform_device btuart_device
= {
250 .name
= "pxa2xx-uart",
253 static struct platform_device stuart_device
= {
254 .name
= "pxa2xx-uart",
257 static struct platform_device hwuart_device
= {
258 .name
= "pxa2xx-uart",
262 static struct resource i2c_resources
[] = {
266 .flags
= IORESOURCE_MEM
,
270 .flags
= IORESOURCE_IRQ
,
274 static struct platform_device i2c_device
= {
275 .name
= "pxa2xx-i2c",
277 .resource
= i2c_resources
,
278 .num_resources
= ARRAY_SIZE(i2c_resources
),
281 void __init
pxa_set_i2c_info(struct i2c_pxa_platform_data
*info
)
283 i2c_device
.dev
.platform_data
= info
;
286 static struct resource i2s_resources
[] = {
290 .flags
= IORESOURCE_MEM
,
294 .flags
= IORESOURCE_IRQ
,
298 static struct platform_device i2s_device
= {
299 .name
= "pxa2xx-i2s",
301 .resource
= i2s_resources
,
302 .num_resources
= ARRAY_SIZE(i2s_resources
),
305 static u64 pxaficp_dmamask
= ~(u32
)0;
307 static struct platform_device pxaficp_device
= {
311 .dma_mask
= &pxaficp_dmamask
,
312 .coherent_dma_mask
= 0xffffffff,
316 void __init
pxa_set_ficp_info(struct pxaficp_platform_data
*info
)
318 pxaficp_device
.dev
.platform_data
= info
;
321 static struct platform_device
*devices
[] __initdata
= {
333 static int __init
pxa_init(void)
337 ret
= platform_add_devices(devices
, ARRAY_SIZE(devices
));
341 /* Only add HWUART for PXA255/26x; PXA210/250/27x do not have it. */
342 cpuid
= read_cpuid(CPUID_ID
);
343 if (((cpuid
>> 4) & 0xfff) == 0x2d0 ||
344 ((cpuid
>> 4) & 0xfff) == 0x290)
345 ret
= platform_device_register(&hwuart_device
);
350 subsys_initcall(pxa_init
);