patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / arch / arm / mach-pxa / generic.c
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/udc.h>
34 #include <asm/arch/pxafb.h>
35
36 #include "generic.h"
37
38 /*
39  * Handy function to set GPIO alternate functions
40  */
41
42 void pxa_gpio_mode(int gpio_mode)
43 {
44         unsigned long flags;
45         int gpio = gpio_mode & GPIO_MD_MASK_NR;
46         int fn = (gpio_mode & GPIO_MD_MASK_FN) >> 8;
47         int gafr;
48
49         local_irq_save(flags);
50         if (gpio_mode & GPIO_MD_MASK_DIR)
51                 GPDR(gpio) |= GPIO_bit(gpio);
52         else
53                 GPDR(gpio) &= ~GPIO_bit(gpio);
54         gafr = GAFR(gpio) & ~(0x3 << (((gpio) & 0xf)*2));
55         GAFR(gpio) = gafr |  (fn  << (((gpio) & 0xf)*2));
56         local_irq_restore(flags);
57 }
58
59 EXPORT_SYMBOL(pxa_gpio_mode);
60
61 /*
62  * Intel PXA2xx internal register mapping.
63  *
64  * Note 1: not all PXA2xx variants implement all those addresses.
65  *
66  * Note 2: virtual 0xfffe0000-0xffffffff is reserved for the vector table
67  *         and cache flush area.
68  */
69 static struct map_desc standard_io_desc[] __initdata = {
70  /* virtual     physical    length      type */
71   { 0xf2000000, 0x40000000, 0x01800000, MT_DEVICE }, /* Devs */
72   { 0xf4000000, 0x44000000, 0x00100000, MT_DEVICE }, /* LCD */
73   { 0xf6000000, 0x48000000, 0x00100000, MT_DEVICE }, /* Mem Ctl */
74   { 0xf8000000, 0x4c000000, 0x00100000, MT_DEVICE }, /* USB host */
75   { 0xfa000000, 0x50000000, 0x00100000, MT_DEVICE }, /* Camera */
76   { 0xfe000000, 0x58000000, 0x00100000, MT_DEVICE }, /* IMem ctl */
77   { 0xff000000, 0x00000000, 0x00100000, MT_DEVICE }  /* UNCACHED_PHYS_0 */
78 };
79
80 void __init pxa_map_io(void)
81 {
82         iotable_init(standard_io_desc, ARRAY_SIZE(standard_io_desc));
83         get_clk_frequency_khz(1);
84 }
85
86
87 static struct resource pxamci_resources[] = {
88         [0] = {
89                 .start  = 0x41100000,
90                 .end    = 0x41100fff,
91                 .flags  = IORESOURCE_MEM,
92         },
93         [1] = {
94                 .start  = IRQ_MMC,
95                 .end    = IRQ_MMC,
96                 .flags  = IORESOURCE_IRQ,
97         },
98 };
99
100 static u64 pxamci_dmamask = 0xffffffffUL;
101
102 static struct platform_device pxamci_device = {
103         .name           = "pxamci",
104         .id             = 0,
105         .dev            = {
106                 .dma_mask = &pxamci_dmamask,
107                 .coherent_dma_mask = 0xffffffff,
108         },
109         .num_resources  = ARRAY_SIZE(pxamci_resources),
110         .resource       = pxamci_resources,
111 };
112
113
114 static struct pxa2xx_udc_mach_info pxa_udc_info;
115
116 void __init pxa_set_udc_info(struct pxa2xx_udc_mach_info *info)
117 {
118         memcpy(&pxa_udc_info, info, sizeof *info);
119 }
120 EXPORT_SYMBOL(pxa_set_udc_info);
121
122 static struct resource pxa2xx_udc_resources[] = {
123         [0] = {
124                 .start  = 0x40600000,
125                 .end    = 0x4060ffff,
126                 .flags  = IORESOURCE_MEM,
127         },
128         [1] = {
129                 .start  = IRQ_USB,
130                 .end    = IRQ_USB,
131                 .flags  = IORESOURCE_IRQ,
132         },
133 };
134
135 static u64 udc_dma_mask = ~(u32)0;
136
137 static struct platform_device udc_device = {
138         .name           = "pxa2xx_udc",
139         .id             = 0,
140         .resource       = pxa2xx_udc_resources,
141         .num_resources  = ARRAY_SIZE(pxa2xx_udc_resources),
142         .dev            =  {
143                 .platform_data  = &pxa_udc_info,
144                 .dma_mask       = &udc_dma_mask,
145         }
146 };
147
148 static struct pxafb_mach_info pxa_fb_info;
149
150 void __init set_pxa_fb_info(struct pxafb_mach_info *hard_pxa_fb_info)
151 {
152         memcpy(&pxa_fb_info,hard_pxa_fb_info,sizeof(struct pxafb_mach_info));
153 }
154 EXPORT_SYMBOL(set_pxa_fb_info);
155
156 static struct resource pxafb_resources[] = {
157         [0] = {
158                 .start  = 0x44000000,
159                 .end    = 0x4400ffff,
160                 .flags  = IORESOURCE_MEM,
161         },
162         [1] = {
163                 .start  = IRQ_LCD,
164                 .end    = IRQ_LCD,
165                 .flags  = IORESOURCE_IRQ,
166         },
167 };
168
169 static u64 fb_dma_mask = ~(u64)0;
170
171 static struct platform_device pxafb_device = {
172         .name           = "pxafb",
173         .id             = 0,
174         .dev            = {
175                 .platform_data  = &pxa_fb_info,
176                 .dma_mask       = &fb_dma_mask,
177                 .coherent_dma_mask = 0xffffffff,
178         },
179         .num_resources  = ARRAY_SIZE(pxafb_resources),
180         .resource       = pxafb_resources,
181 };
182
183 static struct platform_device *devices[] __initdata = {
184         &pxamci_device,
185         &udc_device,
186         &pxafb_device,
187 };
188
189 static int __init pxa_init(void)
190 {
191         return platform_add_devices(devices, ARRAY_SIZE(devices));
192 }
193
194 subsys_initcall(pxa_init);