Merge branch 'upstream'
[deliverable/linux.git] / arch / arm / mach-pxa / poodle.c
1 /*
2 * linux/arch/arm/mach-pxa/poodle.c
3 *
4 * Support for the SHARP Poodle Board.
5 *
6 * Based on:
7 * linux/arch/arm/mach-pxa/lubbock.c Author: Nicolas Pitre
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * Change Log
14 * 12-Dec-2002 Sharp Corporation for Poodle
15 * John Lenz <lenz@cs.wisc.edu> updates to 2.6
16 */
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/platform_device.h>
20 #include <linux/fb.h>
21
22 #include <asm/hardware.h>
23 #include <asm/mach-types.h>
24 #include <asm/irq.h>
25 #include <asm/setup.h>
26
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/irq.h>
30
31 #include <asm/arch/pxa-regs.h>
32 #include <asm/arch/irq.h>
33 #include <asm/arch/mmc.h>
34 #include <asm/arch/udc.h>
35 #include <asm/arch/irda.h>
36 #include <asm/arch/poodle.h>
37 #include <asm/arch/pxafb.h>
38
39 #include <asm/hardware/scoop.h>
40 #include <asm/hardware/locomo.h>
41 #include <asm/mach/sharpsl_param.h>
42
43 #include "generic.h"
44
45 static struct resource poodle_scoop_resources[] = {
46 [0] = {
47 .start = 0x10800000,
48 .end = 0x10800fff,
49 .flags = IORESOURCE_MEM,
50 },
51 };
52
53 static struct scoop_config poodle_scoop_setup = {
54 .io_dir = POODLE_SCOOP_IO_DIR,
55 .io_out = POODLE_SCOOP_IO_OUT,
56 };
57
58 struct platform_device poodle_scoop_device = {
59 .name = "sharp-scoop",
60 .id = -1,
61 .dev = {
62 .platform_data = &poodle_scoop_setup,
63 },
64 .num_resources = ARRAY_SIZE(poodle_scoop_resources),
65 .resource = poodle_scoop_resources,
66 };
67
68 static void poodle_pcmcia_init(void)
69 {
70 /* Setup default state of GPIO outputs
71 before we enable them as outputs. */
72 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
73 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
74 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
75 GPIO_bit(GPIO53_nPCE_2);
76
77 pxa_gpio_mode(GPIO48_nPOE_MD);
78 pxa_gpio_mode(GPIO49_nPWE_MD);
79 pxa_gpio_mode(GPIO50_nPIOR_MD);
80 pxa_gpio_mode(GPIO51_nPIOW_MD);
81 pxa_gpio_mode(GPIO55_nPREG_MD);
82 pxa_gpio_mode(GPIO56_nPWAIT_MD);
83 pxa_gpio_mode(GPIO57_nIOIS16_MD);
84 pxa_gpio_mode(GPIO52_nPCE_1_MD);
85 pxa_gpio_mode(GPIO53_nPCE_2_MD);
86 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
87 }
88
89 static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
90 {
91 .dev = &poodle_scoop_device.dev,
92 .irq = POODLE_IRQ_GPIO_CF_IRQ,
93 .cd_irq = POODLE_IRQ_GPIO_CF_CD,
94 .cd_irq_str = "PCMCIA0 CD",
95 },
96 };
97
98 static struct scoop_pcmcia_config poodle_pcmcia_config = {
99 .devs = &poodle_pcmcia_scoop[0],
100 .num_devs = 1,
101 .pcmcia_init = poodle_pcmcia_init,
102 };
103
104 EXPORT_SYMBOL(poodle_scoop_device);
105
106
107 /* LoCoMo device */
108 static struct resource locomo_resources[] = {
109 [0] = {
110 .start = 0x10000000,
111 .end = 0x10001fff,
112 .flags = IORESOURCE_MEM,
113 },
114 [1] = {
115 .start = IRQ_GPIO(10),
116 .end = IRQ_GPIO(10),
117 .flags = IORESOURCE_IRQ,
118 },
119 };
120
121 static struct platform_device locomo_device = {
122 .name = "locomo",
123 .id = 0,
124 .num_resources = ARRAY_SIZE(locomo_resources),
125 .resource = locomo_resources,
126 };
127
128
129 /*
130 * MMC/SD Device
131 *
132 * The card detect interrupt isn't debounced so we delay it by 250ms
133 * to give the card a chance to fully insert/eject.
134 */
135 static struct pxamci_platform_data poodle_mci_platform_data;
136
137 static int poodle_mci_init(struct device *dev, irqreturn_t (*poodle_detect_int)(int, void *, struct pt_regs *), void *data)
138 {
139 int err;
140
141 /* setup GPIO for PXA25x MMC controller */
142 pxa_gpio_mode(GPIO6_MMCCLK_MD);
143 pxa_gpio_mode(GPIO8_MMCCS0_MD);
144 pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN);
145 pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT);
146
147 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
148
149 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
150 SA_INTERRUPT | SA_TRIGGER_RISING | SA_TRIGGER_FALLING,
151 "MMC card detect", data);
152 if (err) {
153 printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
154 return -1;
155 }
156
157 return 0;
158 }
159
160 static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
161 {
162 struct pxamci_platform_data* p_d = dev->platform_data;
163
164 if (( 1 << vdd) & p_d->ocr_mask)
165 GPSR1 = GPIO_bit(POODLE_GPIO_SD_PWR);
166 else
167 GPCR1 = GPIO_bit(POODLE_GPIO_SD_PWR);
168 }
169
170 static void poodle_mci_exit(struct device *dev, void *data)
171 {
172 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
173 }
174
175 static struct pxamci_platform_data poodle_mci_platform_data = {
176 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
177 .init = poodle_mci_init,
178 .setpower = poodle_mci_setpower,
179 .exit = poodle_mci_exit,
180 };
181
182
183 /*
184 * Irda
185 */
186 static void poodle_irda_transceiver_mode(struct device *dev, int mode)
187 {
188 if (mode & IR_OFF) {
189 GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
190 } else {
191 GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
192 }
193 }
194
195 static struct pxaficp_platform_data poodle_ficp_platform_data = {
196 .transceiver_cap = IR_SIRMODE | IR_OFF,
197 .transceiver_mode = poodle_irda_transceiver_mode,
198 };
199
200
201 /*
202 * USB Device Controller
203 */
204 static void poodle_udc_command(int cmd)
205 {
206 switch(cmd) {
207 case PXA2XX_UDC_CMD_CONNECT:
208 GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
209 break;
210 case PXA2XX_UDC_CMD_DISCONNECT:
211 GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
212 break;
213 }
214 }
215
216 static struct pxa2xx_udc_mach_info udc_info __initdata = {
217 /* no connect GPIO; poodle can't tell connection status */
218 .udc_command = poodle_udc_command,
219 };
220
221
222 /* PXAFB device */
223 static struct pxafb_mach_info poodle_fb_info __initdata = {
224 .pixclock = 144700,
225
226 .xres = 320,
227 .yres = 240,
228 .bpp = 16,
229
230 .hsync_len = 7,
231 .left_margin = 11,
232 .right_margin = 30,
233
234 .vsync_len = 2,
235 .upper_margin = 2,
236 .lower_margin = 0,
237 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
238
239 .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
240 .lccr3 = 0,
241
242 .pxafb_backlight_power = NULL,
243 .pxafb_lcd_power = NULL,
244 };
245
246 static struct platform_device *devices[] __initdata = {
247 &locomo_device,
248 &poodle_scoop_device,
249 };
250
251 static void __init poodle_init(void)
252 {
253 int ret = 0;
254
255 /* setup sleep mode values */
256 PWER = 0x00000002;
257 PFER = 0x00000000;
258 PRER = 0x00000002;
259 PGSR0 = 0x00008000;
260 PGSR1 = 0x003F0202;
261 PGSR2 = 0x0001C000;
262 PCFR |= PCFR_OPDE;
263
264 /* cpu initialize */
265 /* Pgsr Register */
266 PGSR0 = 0x0146dd80;
267 PGSR1 = 0x03bf0890;
268 PGSR2 = 0x0001c000;
269
270 /* Alternate Register */
271 GAFR0_L = 0x01001000;
272 GAFR0_U = 0x591a8010;
273 GAFR1_L = 0x900a8451;
274 GAFR1_U = 0xaaa5aaaa;
275 GAFR2_L = 0x8aaaaaaa;
276 GAFR2_U = 0x00000002;
277
278 /* Direction Register */
279 GPDR0 = 0xd3f0904c;
280 GPDR1 = 0xfcffb7d3;
281 GPDR2 = 0x0001ffff;
282
283 /* Output Register */
284 GPCR0 = 0x00000000;
285 GPCR1 = 0x00000000;
286 GPCR2 = 0x00000000;
287
288 GPSR0 = 0x00400000;
289 GPSR1 = 0x00000000;
290 GPSR2 = 0x00000000;
291
292 set_pxa_fb_info(&poodle_fb_info);
293 pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
294 pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT);
295 pxa_set_udc_info(&udc_info);
296 pxa_set_mci_info(&poodle_mci_platform_data);
297 pxa_set_ficp_info(&poodle_ficp_platform_data);
298
299 platform_scoop_config = &poodle_pcmcia_config;
300
301 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
302 if (ret) {
303 printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
304 }
305 }
306
307 static void __init fixup_poodle(struct machine_desc *desc,
308 struct tag *tags, char **cmdline, struct meminfo *mi)
309 {
310 sharpsl_save_param();
311 }
312
313 MACHINE_START(POODLE, "SHARP Poodle")
314 .phys_io = 0x40000000,
315 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
316 .fixup = fixup_poodle,
317 .map_io = pxa_map_io,
318 .init_irq = pxa_init_irq,
319 .timer = &pxa_timer,
320 .init_machine = poodle_init,
321 MACHINE_END
This page took 0.081517 seconds and 6 git commands to generate.