Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzi...
[pandora-kernel.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 #include <linux/pm.h>
22 #include <linux/delay.h>
23
24 #include <asm/hardware.h>
25 #include <asm/mach-types.h>
26 #include <asm/irq.h>
27 #include <asm/setup.h>
28 #include <asm/system.h>
29
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32 #include <asm/mach/irq.h>
33
34 #include <asm/arch/pxa-regs.h>
35 #include <asm/arch/pxa2xx-gpio.h>
36 #include <asm/arch/mmc.h>
37 #include <asm/arch/udc.h>
38 #include <asm/arch/irda.h>
39 #include <asm/arch/poodle.h>
40 #include <asm/arch/pxafb.h>
41 #include <asm/arch/sharpsl.h>
42 #include <asm/arch/ssp.h>
43
44 #include <asm/hardware/scoop.h>
45 #include <asm/hardware/locomo.h>
46 #include <asm/mach/sharpsl_param.h>
47
48 #include "generic.h"
49 #include "devices.h"
50 #include "sharpsl.h"
51
52 static struct resource poodle_scoop_resources[] = {
53         [0] = {
54                 .start          = 0x10800000,
55                 .end            = 0x10800fff,
56                 .flags          = IORESOURCE_MEM,
57         },
58 };
59
60 static struct scoop_config poodle_scoop_setup = {
61         .io_dir         = POODLE_SCOOP_IO_DIR,
62         .io_out         = POODLE_SCOOP_IO_OUT,
63 };
64
65 struct platform_device poodle_scoop_device = {
66         .name           = "sharp-scoop",
67         .id             = -1,
68         .dev            = {
69                 .platform_data  = &poodle_scoop_setup,
70         },
71         .num_resources  = ARRAY_SIZE(poodle_scoop_resources),
72         .resource       = poodle_scoop_resources,
73 };
74
75 static void poodle_pcmcia_init(void)
76 {
77         /* Setup default state of GPIO outputs
78            before we enable them as outputs. */
79         GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
80                 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
81                 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
82                 GPIO_bit(GPIO53_nPCE_2);
83
84         pxa_gpio_mode(GPIO48_nPOE_MD);
85         pxa_gpio_mode(GPIO49_nPWE_MD);
86         pxa_gpio_mode(GPIO50_nPIOR_MD);
87         pxa_gpio_mode(GPIO51_nPIOW_MD);
88         pxa_gpio_mode(GPIO55_nPREG_MD);
89         pxa_gpio_mode(GPIO56_nPWAIT_MD);
90         pxa_gpio_mode(GPIO57_nIOIS16_MD);
91         pxa_gpio_mode(GPIO52_nPCE_1_MD);
92         pxa_gpio_mode(GPIO53_nPCE_2_MD);
93         pxa_gpio_mode(GPIO54_pSKTSEL_MD);
94 }
95
96 static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
97 {
98         .dev        = &poodle_scoop_device.dev,
99         .irq        = POODLE_IRQ_GPIO_CF_IRQ,
100         .cd_irq     = POODLE_IRQ_GPIO_CF_CD,
101         .cd_irq_str = "PCMCIA0 CD",
102 },
103 };
104
105 static struct scoop_pcmcia_config poodle_pcmcia_config = {
106         .devs         = &poodle_pcmcia_scoop[0],
107         .num_devs     = 1,
108         .pcmcia_init  = poodle_pcmcia_init,
109 };
110
111 EXPORT_SYMBOL(poodle_scoop_device);
112
113
114 /* LoCoMo device */
115 static struct resource locomo_resources[] = {
116         [0] = {
117                 .start          = 0x10000000,
118                 .end            = 0x10001fff,
119                 .flags          = IORESOURCE_MEM,
120         },
121         [1] = {
122                 .start          = IRQ_GPIO(10),
123                 .end            = IRQ_GPIO(10),
124                 .flags          = IORESOURCE_IRQ,
125         },
126 };
127
128 struct platform_device poodle_locomo_device = {
129         .name           = "locomo",
130         .id             = 0,
131         .num_resources  = ARRAY_SIZE(locomo_resources),
132         .resource       = locomo_resources,
133 };
134
135 EXPORT_SYMBOL(poodle_locomo_device);
136
137 /*
138  * Poodle SSP Device
139  */
140
141 struct platform_device poodle_ssp_device = {
142         .name           = "corgi-ssp",
143         .id             = -1,
144 };
145
146 struct corgissp_machinfo poodle_ssp_machinfo = {
147         .port           = 1,
148         .cs_lcdcon      = -1,
149         .cs_ads7846     = -1,
150         .cs_max1111     = -1,
151         .clk_lcdcon     = 2,
152         .clk_ads7846    = 36,
153         .clk_max1111    = 2,
154 };
155
156
157 /*
158  * Poodle Touch Screen Device
159  */
160 static struct resource poodlets_resources[] = {
161         [0] = {
162                 .start          = POODLE_IRQ_GPIO_TP_INT,
163                 .end            = POODLE_IRQ_GPIO_TP_INT,
164                 .flags          = IORESOURCE_IRQ,
165         },
166 };
167
168 static unsigned long poodle_get_hsync_invperiod(void)
169 {
170         return 0;
171 }
172
173 static void poodle_null_hsync(void)
174 {
175 }
176
177 static struct corgits_machinfo  poodle_ts_machinfo = {
178         .get_hsync_invperiod    = poodle_get_hsync_invperiod,
179         .put_hsync              = poodle_null_hsync,
180         .wait_hsync             = poodle_null_hsync,
181 };
182
183 static struct platform_device poodle_ts_device = {
184         .name           = "corgi-ts",
185         .dev            = {
186                 .platform_data  = &poodle_ts_machinfo,
187         },
188         .id             = -1,
189         .num_resources  = ARRAY_SIZE(poodlets_resources),
190         .resource       = poodlets_resources,
191 };
192
193
194 /*
195  * MMC/SD Device
196  *
197  * The card detect interrupt isn't debounced so we delay it by 250ms
198  * to give the card a chance to fully insert/eject.
199  */
200 static struct pxamci_platform_data poodle_mci_platform_data;
201
202 static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data)
203 {
204         int err;
205
206         /* setup GPIO for PXA25x MMC controller */
207         pxa_gpio_mode(GPIO6_MMCCLK_MD);
208         pxa_gpio_mode(GPIO8_MMCCS0_MD);
209         pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN);
210         pxa_gpio_mode(POODLE_GPIO_nSD_WP | GPIO_IN);
211         pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT);
212         pxa_gpio_mode(POODLE_GPIO_SD_PWR1 | GPIO_OUT);
213
214         poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
215
216         err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
217                           IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
218                           "MMC card detect", data);
219         if (err)
220                 printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
221
222         return err;
223 }
224
225 static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
226 {
227         struct pxamci_platform_data* p_d = dev->platform_data;
228
229         if (( 1 << vdd) & p_d->ocr_mask) {
230                 GPSR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR);
231                 mdelay(2);
232                 GPSR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1);
233         } else {
234                 GPCR(POODLE_GPIO_SD_PWR1) = GPIO_bit(POODLE_GPIO_SD_PWR1);
235                 GPCR(POODLE_GPIO_SD_PWR) = GPIO_bit(POODLE_GPIO_SD_PWR);
236         }
237 }
238
239 static int poodle_mci_get_ro(struct device *dev)
240 {
241         return GPLR(POODLE_GPIO_nSD_WP) & GPIO_bit(POODLE_GPIO_nSD_WP);
242 }
243
244
245 static void poodle_mci_exit(struct device *dev, void *data)
246 {
247         free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
248 }
249
250 static struct pxamci_platform_data poodle_mci_platform_data = {
251         .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
252         .init           = poodle_mci_init,
253         .get_ro         = poodle_mci_get_ro,
254         .setpower       = poodle_mci_setpower,
255         .exit           = poodle_mci_exit,
256 };
257
258
259 /*
260  * Irda
261  */
262 static void poodle_irda_transceiver_mode(struct device *dev, int mode)
263 {
264         if (mode & IR_OFF) {
265                 GPSR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
266         } else {
267                 GPCR(POODLE_GPIO_IR_ON) = GPIO_bit(POODLE_GPIO_IR_ON);
268         }
269 }
270
271 static struct pxaficp_platform_data poodle_ficp_platform_data = {
272         .transceiver_cap  = IR_SIRMODE | IR_OFF,
273         .transceiver_mode = poodle_irda_transceiver_mode,
274 };
275
276
277 /*
278  * USB Device Controller
279  */
280 static void poodle_udc_command(int cmd)
281 {
282         switch(cmd)     {
283         case PXA2XX_UDC_CMD_CONNECT:
284                 GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
285                 break;
286         case PXA2XX_UDC_CMD_DISCONNECT:
287                 GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
288                 break;
289         }
290 }
291
292 static struct pxa2xx_udc_mach_info udc_info __initdata = {
293         /* no connect GPIO; poodle can't tell connection status */
294         .udc_command            = poodle_udc_command,
295 };
296
297
298 /* PXAFB device */
299 static struct pxafb_mode_info poodle_fb_mode = {
300         .pixclock       = 144700,
301         .xres           = 320,
302         .yres           = 240,
303         .bpp            = 16,
304         .hsync_len      = 7,
305         .left_margin    = 11,
306         .right_margin   = 30,
307         .vsync_len      = 2,
308         .upper_margin   = 2,
309         .lower_margin   = 0,
310         .sync           = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
311 };
312
313 static struct pxafb_mach_info poodle_fb_info = {
314         .modes          = &poodle_fb_mode,
315         .num_modes      = 1,
316         .lccr0          = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
317         .lccr3          = 0,
318 };
319
320 static struct platform_device *devices[] __initdata = {
321         &poodle_locomo_device,
322         &poodle_scoop_device,
323         &poodle_ssp_device,
324         &poodle_ts_device,
325 };
326
327 static void poodle_poweroff(void)
328 {
329         arm_machine_restart('h');
330 }
331
332 static void poodle_restart(char mode)
333 {
334         arm_machine_restart('h');
335 }
336
337 static void __init poodle_init(void)
338 {
339         int ret = 0;
340
341         pm_power_off = poodle_poweroff;
342         arm_pm_restart = poodle_restart;
343
344         /* setup sleep mode values */
345         PWER  = 0x00000002;
346         PFER  = 0x00000000;
347         PRER  = 0x00000002;
348         PGSR0 = 0x00008000;
349         PGSR1 = 0x003F0202;
350         PGSR2 = 0x0001C000;
351         PCFR |= PCFR_OPDE;
352
353         /* cpu initialize */
354         /* Pgsr Register */
355         PGSR0 = 0x0146dd80;
356         PGSR1 = 0x03bf0890;
357         PGSR2 = 0x0001c000;
358
359         /* Alternate Register */
360         GAFR0_L = 0x01001000;
361         GAFR0_U = 0x591a8010;
362         GAFR1_L = 0x900a8451;
363         GAFR1_U = 0xaaa5aaaa;
364         GAFR2_L = 0x8aaaaaaa;
365         GAFR2_U = 0x00000002;
366
367         /* Direction Register */
368         GPDR0 = 0xd3f0904c;
369         GPDR1 = 0xfcffb7d3;
370         GPDR2 = 0x0001ffff;
371
372         /* Output Register */
373         GPCR0 = 0x00000000;
374         GPCR1 = 0x00000000;
375         GPCR2 = 0x00000000;
376
377         GPSR0 = 0x00400000;
378         GPSR1 = 0x00000000;
379         GPSR2 = 0x00000000;
380
381         set_pxa_fb_parent(&poodle_locomo_device.dev);
382         set_pxa_fb_info(&poodle_fb_info);
383         pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
384         pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT);
385         pxa_set_udc_info(&udc_info);
386         pxa_set_mci_info(&poodle_mci_platform_data);
387         pxa_set_ficp_info(&poodle_ficp_platform_data);
388
389         platform_scoop_config = &poodle_pcmcia_config;
390
391         ret = platform_add_devices(devices, ARRAY_SIZE(devices));
392         if (ret) {
393                 printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
394         }
395         corgi_ssp_set_machinfo(&poodle_ssp_machinfo);
396 }
397
398 static void __init fixup_poodle(struct machine_desc *desc,
399                 struct tag *tags, char **cmdline, struct meminfo *mi)
400 {
401         sharpsl_save_param();
402         mi->nr_banks=1;
403         mi->bank[0].start = 0xa0000000;
404         mi->bank[0].node = 0;
405         mi->bank[0].size = (32*1024*1024);
406 }
407
408 MACHINE_START(POODLE, "SHARP Poodle")
409         .phys_io        = 0x40000000,
410         .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
411         .fixup          = fixup_poodle,
412         .map_io         = pxa_map_io,
413         .init_irq       = pxa25x_init_irq,
414         .timer          = &pxa_timer,
415         .init_machine   = poodle_init,
416 MACHINE_END