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/i2c.h>
42 * Handy function to set GPIO alternate functions
45 void pxa_gpio_mode(int gpio_mode)
48 int gpio = gpio_mode & GPIO_MD_MASK_NR;
49 int fn = (gpio_mode & GPIO_MD_MASK_FN) >> 8;
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);
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);
66 EXPORT_SYMBOL(pxa_gpio_mode);
69 * Routine to safely enable or disable a clock in the CKEN
71 void pxa_set_cken(int clock, int enable)
74 local_irq_save(flags);
81 local_irq_restore(flags);
84 EXPORT_SYMBOL(pxa_set_cken);
87 * Intel PXA2xx internal register mapping.
89 * Note 1: not all PXA2xx variants implement all those addresses.
91 * Note 2: virtual 0xfffe0000-0xffffffff is reserved for the vector table
92 * and cache flush area.
94 static struct map_desc standard_io_desc[] __initdata = {
95 /* virtual physical length type */
96 { 0xf2000000, 0x40000000, 0x02000000, MT_DEVICE }, /* Devs */
97 { 0xf4000000, 0x44000000, 0x00100000, MT_DEVICE }, /* LCD */
98 { 0xf6000000, 0x48000000, 0x00100000, MT_DEVICE }, /* Mem Ctl */
99 { 0xf8000000, 0x4c000000, 0x00100000, MT_DEVICE }, /* USB host */
100 { 0xfa000000, 0x50000000, 0x00100000, MT_DEVICE }, /* Camera */
101 { 0xfe000000, 0x58000000, 0x00100000, MT_DEVICE }, /* IMem ctl */
102 { 0xff000000, 0x00000000, 0x00100000, MT_DEVICE } /* UNCACHED_PHYS_0 */
105 void __init pxa_map_io(void)
107 iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
108 get_clk_frequency_khz(1);
112 static struct resource pxamci_resources[] = {
116 .flags = IORESOURCE_MEM,
121 .flags = IORESOURCE_IRQ,
125 static u64 pxamci_dmamask = 0xffffffffUL;
127 static struct platform_device pxamci_device = {
128 .name = "pxa2xx-mci",
131 .dma_mask = &pxamci_dmamask,
132 .coherent_dma_mask = 0xffffffff,
134 .num_resources = ARRAY_SIZE(pxamci_resources),
135 .resource = pxamci_resources,
138 void __init pxa_set_mci_info(struct pxamci_platform_data *info)
140 pxamci_device.dev.platform_data = info;
144 static struct pxa2xx_udc_mach_info pxa_udc_info;
146 void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info)
148 memcpy(&pxa_udc_info, info, sizeof *info);
151 static struct resource pxa2xx_udc_resources[] = {
155 .flags = IORESOURCE_MEM,
160 .flags = IORESOURCE_IRQ,
164 static u64 udc_dma_mask = ~(u32)0;
166 static struct platform_device udc_device = {
167 .name = "pxa2xx-udc",
169 .resource = pxa2xx_udc_resources,
170 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
172 .platform_data = &pxa_udc_info,
173 .dma_mask = &udc_dma_mask,
177 static struct pxafb_mach_info pxa_fb_info;
179 void __init set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info)
181 memcpy(&pxa_fb_info,hard_pxa_fb_info,sizeof(struct pxafb_mach_info));
184 static struct resource pxafb_resources[] = {
188 .flags = IORESOURCE_MEM,
193 .flags = IORESOURCE_IRQ,
197 static u64 fb_dma_mask = ~(u64)0;
199 static struct platform_device pxafb_device = {
203 .platform_data = &pxa_fb_info,
204 .dma_mask = &fb_dma_mask,
205 .coherent_dma_mask = 0xffffffff,
207 .num_resources = ARRAY_SIZE(pxafb_resources),
208 .resource = pxafb_resources,
211 void __init set_pxa_fb_parent(struct device *parent_dev)
213 pxafb_device.dev.parent = parent_dev;
216 static struct platform_device ffuart_device = {
217 .name = "pxa2xx-uart",
220 static struct platform_device btuart_device = {
221 .name = "pxa2xx-uart",
224 static struct platform_device stuart_device = {
225 .name = "pxa2xx-uart",
229 static struct resource i2c_resources[] = {
233 .flags = IORESOURCE_MEM,
237 .flags = IORESOURCE_IRQ,
241 static struct platform_device i2c_device = {
242 .name = "pxa2xx-i2c",
244 .resource = i2c_resources,
245 .num_resources = ARRAY_SIZE(i2c_resources),
248 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
250 i2c_device.dev.platform_data = info;
253 static struct platform_device *devices[] __initdata = {
263 static int __init pxa_init(void)
265 return platform_add_devices(devices, ARRAY_SIZE(devices));
268 subsys_initcall(pxa_init);