Linux 2.6.13-rc4
[linux-2.6/next.git] / arch / arm / mach-pxa / generic.c
bloba45aaa115a76664bb81438455b06a6ff890886f7
1 /*
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
17 * need be.
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>
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>
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>
38 #include "generic.h"
41 * Handy function to set GPIO alternate functions
44 void pxa_gpio_mode(int gpio_mode)
46 unsigned long flags;
47 int gpio = gpio_mode & GPIO_MD_MASK_NR;
48 int fn = (gpio_mode & GPIO_MD_MASK_FN) >> 8;
49 int gafr;
51 local_irq_save(flags);
52 if (gpio_mode & GPIO_DFLT_LOW)
53 GPCR(gpio) = GPIO_bit(gpio);
54 else if (gpio_mode & GPIO_DFLT_HIGH)
55 GPSR(gpio) = GPIO_bit(gpio);
56 if (gpio_mode & GPIO_MD_MASK_DIR)
57 GPDR(gpio) |= GPIO_bit(gpio);
58 else
59 GPDR(gpio) &= ~GPIO_bit(gpio);
60 gafr = GAFR(gpio) & ~(0x3 << (((gpio) & 0xf)*2));
61 GAFR(gpio) = gafr | (fn << (((gpio) & 0xf)*2));
62 local_irq_restore(flags);
65 EXPORT_SYMBOL(pxa_gpio_mode);
68 * Routine to safely enable or disable a clock in the CKEN
70 void pxa_set_cken(int clock, int enable)
72 unsigned long flags;
73 local_irq_save(flags);
75 if (enable)
76 CKEN |= clock;
77 else
78 CKEN &= ~clock;
80 local_irq_restore(flags);
83 EXPORT_SYMBOL(pxa_set_cken);
86 * Intel PXA2xx internal register mapping.
88 * Note 1: not all PXA2xx variants implement all those addresses.
90 * Note 2: virtual 0xfffe0000-0xffffffff is reserved for the vector table
91 * and cache flush area.
93 static struct map_desc standard_io_desc[] __initdata = {
94 /* virtual physical length type */
95 { 0xf2000000, 0x40000000, 0x02000000, MT_DEVICE }, /* Devs */
96 { 0xf4000000, 0x44000000, 0x00100000, MT_DEVICE }, /* LCD */
97 { 0xf6000000, 0x48000000, 0x00100000, MT_DEVICE }, /* Mem Ctl */
98 { 0xf8000000, 0x4c000000, 0x00100000, MT_DEVICE }, /* USB host */
99 { 0xfa000000, 0x50000000, 0x00100000, MT_DEVICE }, /* Camera */
100 { 0xfe000000, 0x58000000, 0x00100000, MT_DEVICE }, /* IMem ctl */
101 { 0xff000000, 0x00000000, 0x00100000, MT_DEVICE } /* UNCACHED_PHYS_0 */
104 void __init pxa_map_io(void)
106 iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
107 get_clk_frequency_khz(1);
111 static struct resource pxamci_resources[] = {
112 [0] = {
113 .start = 0x41100000,
114 .end = 0x41100fff,
115 .flags = IORESOURCE_MEM,
117 [1] = {
118 .start = IRQ_MMC,
119 .end = IRQ_MMC,
120 .flags = IORESOURCE_IRQ,
124 static u64 pxamci_dmamask = 0xffffffffUL;
126 static struct platform_device pxamci_device = {
127 .name = "pxa2xx-mci",
128 .id = -1,
129 .dev = {
130 .dma_mask = &pxamci_dmamask,
131 .coherent_dma_mask = 0xffffffff,
133 .num_resources = ARRAY_SIZE(pxamci_resources),
134 .resource = pxamci_resources,
137 void __init pxa_set_mci_info(struct pxamci_platform_data *info)
139 pxamci_device.dev.platform_data = info;
143 static struct pxa2xx_udc_mach_info pxa_udc_info;
145 void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info)
147 memcpy(&pxa_udc_info, info, sizeof *info);
150 static struct resource pxa2xx_udc_resources[] = {
151 [0] = {
152 .start = 0x40600000,
153 .end = 0x4060ffff,
154 .flags = IORESOURCE_MEM,
156 [1] = {
157 .start = IRQ_USB,
158 .end = IRQ_USB,
159 .flags = IORESOURCE_IRQ,
163 static u64 udc_dma_mask = ~(u32)0;
165 static struct platform_device udc_device = {
166 .name = "pxa2xx-udc",
167 .id = -1,
168 .resource = pxa2xx_udc_resources,
169 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
170 .dev = {
171 .platform_data = &pxa_udc_info,
172 .dma_mask = &udc_dma_mask,
176 static struct pxafb_mach_info pxa_fb_info;
178 void __init set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info)
180 memcpy(&pxa_fb_info,hard_pxa_fb_info,sizeof(struct pxafb_mach_info));
183 static struct resource pxafb_resources[] = {
184 [0] = {
185 .start = 0x44000000,
186 .end = 0x4400ffff,
187 .flags = IORESOURCE_MEM,
189 [1] = {
190 .start = IRQ_LCD,
191 .end = IRQ_LCD,
192 .flags = IORESOURCE_IRQ,
196 static u64 fb_dma_mask = ~(u64)0;
198 static struct platform_device pxafb_device = {
199 .name = "pxa2xx-fb",
200 .id = -1,
201 .dev = {
202 .platform_data = &pxa_fb_info,
203 .dma_mask = &fb_dma_mask,
204 .coherent_dma_mask = 0xffffffff,
206 .num_resources = ARRAY_SIZE(pxafb_resources),
207 .resource = pxafb_resources,
210 static struct platform_device ffuart_device = {
211 .name = "pxa2xx-uart",
212 .id = 0,
214 static struct platform_device btuart_device = {
215 .name = "pxa2xx-uart",
216 .id = 1,
218 static struct platform_device stuart_device = {
219 .name = "pxa2xx-uart",
220 .id = 2,
223 static struct resource i2c_resources[] = {
225 .start = 0x40301680,
226 .end = 0x403016a3,
227 .flags = IORESOURCE_MEM,
228 }, {
229 .start = IRQ_I2C,
230 .end = IRQ_I2C,
231 .flags = IORESOURCE_IRQ,
235 static struct platform_device i2c_device = {
236 .name = "pxa2xx-i2c",
237 .id = 0,
238 .resource = i2c_resources,
239 .num_resources = ARRAY_SIZE(i2c_resources),
242 void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
244 i2c_device.dev.platform_data = info;
247 static struct platform_device *devices[] __initdata = {
248 &pxamci_device,
249 &udc_device,
250 &pxafb_device,
251 &ffuart_device,
252 &btuart_device,
253 &stuart_device,
254 &i2c_device,
257 static int __init pxa_init(void)
259 return platform_add_devices(devices, ARRAY_SIZE(devices));
262 subsys_initcall(pxa_init);