initial commit with v2.6.9
[linux-2.6.9-moxart.git] / arch / arm / mach-pxa / generic.c
blob3f4755f70b5b69e91e40a5c1a846cb051fa819a4
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_MD_MASK_DIR)
53 GPDR(gpio) |= GPIO_bit(gpio);
54 else
55 GPDR(gpio) &= ~GPIO_bit(gpio);
56 gafr = GAFR(gpio) & ~(0x3 << (((gpio) & 0xf)*2));
57 GAFR(gpio) = gafr | (fn << (((gpio) & 0xf)*2));
58 local_irq_restore(flags);
61 EXPORT_SYMBOL(pxa_gpio_mode);
64 * Routine to safely enable or disable a clock in the CKEN
66 void pxa_set_cken(int clock, int enable)
68 unsigned long flags;
69 local_irq_save(flags);
71 if (enable)
72 CKEN |= clock;
73 else
74 CKEN &= ~clock;
76 local_irq_restore(flags);
79 EXPORT_SYMBOL(pxa_set_cken);
82 * Intel PXA2xx internal register mapping.
84 * Note 1: not all PXA2xx variants implement all those addresses.
86 * Note 2: virtual 0xfffe0000-0xffffffff is reserved for the vector table
87 * and cache flush area.
89 static struct map_desc standard_io_desc[] __initdata = {
90 /* virtual physical length type */
91 { 0xf2000000, 0x40000000, 0x01800000, MT_DEVICE }, /* Devs */
92 { 0xf4000000, 0x44000000, 0x00100000, MT_DEVICE }, /* LCD */
93 { 0xf6000000, 0x48000000, 0x00100000, MT_DEVICE }, /* Mem Ctl */
94 { 0xf8000000, 0x4c000000, 0x00100000, MT_DEVICE }, /* USB host */
95 { 0xfa000000, 0x50000000, 0x00100000, MT_DEVICE }, /* Camera */
96 { 0xfe000000, 0x58000000, 0x00100000, MT_DEVICE }, /* IMem ctl */
97 { 0xff000000, 0x00000000, 0x00100000, MT_DEVICE } /* UNCACHED_PHYS_0 */
100 void __init pxa_map_io(void)
102 iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
103 get_clk_frequency_khz(1);
107 static struct resource pxamci_resources[] = {
108 [0] = {
109 .start = 0x41100000,
110 .end = 0x41100fff,
111 .flags = IORESOURCE_MEM,
113 [1] = {
114 .start = IRQ_MMC,
115 .end = IRQ_MMC,
116 .flags = IORESOURCE_IRQ,
120 static u64 pxamci_dmamask = 0xffffffffUL;
122 static struct platform_device pxamci_device = {
123 .name = "pxa2xx-mci",
124 .id = -1,
125 .dev = {
126 .dma_mask = &pxamci_dmamask,
127 .coherent_dma_mask = 0xffffffff,
129 .num_resources = ARRAY_SIZE(pxamci_resources),
130 .resource = pxamci_resources,
133 void __init pxa_set_mci_info(struct pxamci_platform_data *info)
135 pxamci_device.dev.platform_data = info;
137 EXPORT_SYMBOL(pxa_set_mci_info);
140 static struct pxa2xx_udc_mach_info pxa_udc_info;
142 void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info)
144 memcpy(&pxa_udc_info, info, sizeof *info);
146 EXPORT_SYMBOL(pxa_set_udc_info);
148 static struct resource pxa2xx_udc_resources[] = {
149 [0] = {
150 .start = 0x40600000,
151 .end = 0x4060ffff,
152 .flags = IORESOURCE_MEM,
154 [1] = {
155 .start = IRQ_USB,
156 .end = IRQ_USB,
157 .flags = IORESOURCE_IRQ,
161 static u64 udc_dma_mask = ~(u32)0;
163 static struct platform_device udc_device = {
164 .name = "pxa2xx-udc",
165 .id = -1,
166 .resource = pxa2xx_udc_resources,
167 .num_resources = ARRAY_SIZE(pxa2xx_udc_resources),
168 .dev = {
169 .platform_data = &pxa_udc_info,
170 .dma_mask = &udc_dma_mask,
174 static struct pxafb_mach_info pxa_fb_info;
176 void __init set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info)
178 memcpy(&pxa_fb_info,hard_pxa_fb_info,sizeof(struct pxafb_mach_info));
180 EXPORT_SYMBOL(set_pxa_fb_info);
182 static struct resource pxafb_resources[] = {
183 [0] = {
184 .start = 0x44000000,
185 .end = 0x4400ffff,
186 .flags = IORESOURCE_MEM,
188 [1] = {
189 .start = IRQ_LCD,
190 .end = IRQ_LCD,
191 .flags = IORESOURCE_IRQ,
195 static u64 fb_dma_mask = ~(u64)0;
197 static struct platform_device pxafb_device = {
198 .name = "pxa2xx-fb",
199 .id = -1,
200 .dev = {
201 .platform_data = &pxa_fb_info,
202 .dma_mask = &fb_dma_mask,
203 .coherent_dma_mask = 0xffffffff,
205 .num_resources = ARRAY_SIZE(pxafb_resources),
206 .resource = pxafb_resources,
209 static struct platform_device ffuart_device = {
210 .name = "pxa2xx-uart",
211 .id = 0,
213 static struct platform_device btuart_device = {
214 .name = "pxa2xx-uart",
215 .id = 1,
217 static struct platform_device stuart_device = {
218 .name = "pxa2xx-uart",
219 .id = 2,
222 static struct platform_device *devices[] __initdata = {
223 &pxamci_device,
224 &udc_device,
225 &pxafb_device,
226 &ffuart_device,
227 &btuart_device,
228 &stuart_device,
231 static int __init pxa_init(void)
233 return platform_add_devices(devices, ARRAY_SIZE(devices));
236 subsys_initcall(pxa_init);