Update from upstream with manual merge of Yasunori Goto's
[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/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/poodle.h>
36 #include <asm/arch/pxafb.h>
37
38 #include <asm/hardware/scoop.h>
39 #include <asm/hardware/locomo.h>
40 #include <asm/mach/sharpsl_param.h>
41
42 #include "generic.h"
43
44 static struct resource poodle_scoop_resources[] = {
45         [0] = {
46                 .start          = 0x10800000,
47                 .end            = 0x10800fff,
48                 .flags          = IORESOURCE_MEM,
49         },
50 };
51
52 static struct scoop_config poodle_scoop_setup = {
53         .io_dir         = POODLE_SCOOP_IO_DIR,
54         .io_out         = POODLE_SCOOP_IO_OUT,
55 };
56
57 struct platform_device poodle_scoop_device = {
58         .name           = "sharp-scoop",
59         .id             = -1,
60         .dev            = {
61                 .platform_data  = &poodle_scoop_setup,
62         },
63         .num_resources  = ARRAY_SIZE(poodle_scoop_resources),
64         .resource       = poodle_scoop_resources,
65 };
66
67 static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
68 {
69         .dev        = &poodle_scoop_device.dev,
70         .irq        = POODLE_IRQ_GPIO_CF_IRQ,
71         .cd_irq     = POODLE_IRQ_GPIO_CF_CD,
72         .cd_irq_str = "PCMCIA0 CD",
73 },
74 };
75
76
77 /* LoCoMo device */
78 static struct resource locomo_resources[] = {
79         [0] = {
80                 .start          = 0x10000000,
81                 .end            = 0x10001fff,
82                 .flags          = IORESOURCE_MEM,
83         },
84         [1] = {
85                 .start          = IRQ_GPIO(10),
86                 .end            = IRQ_GPIO(10),
87                 .flags          = IORESOURCE_IRQ,
88         },
89 };
90
91 static struct platform_device locomo_device = {
92         .name           = "locomo",
93         .id             = 0,
94         .num_resources  = ARRAY_SIZE(locomo_resources),
95         .resource       = locomo_resources,
96 };
97
98
99 /*
100  * MMC/SD Device
101  *
102  * The card detect interrupt isn't debounced so we delay it by 250ms
103  * to give the card a chance to fully insert/eject.
104  */
105 static struct pxamci_platform_data poodle_mci_platform_data;
106
107 static int poodle_mci_init(struct device *dev, irqreturn_t (*poodle_detect_int)(int, void *, struct pt_regs *), void *data)
108 {
109         int err;
110
111         /* setup GPIO for PXA25x MMC controller */
112         pxa_gpio_mode(GPIO6_MMCCLK_MD);
113         pxa_gpio_mode(GPIO8_MMCCS0_MD);
114         pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN);
115         pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT);
116
117         poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
118
119         err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int, SA_INTERRUPT,
120                              "MMC card detect", data);
121         if (err) {
122                 printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
123                 return -1;
124         }
125
126         set_irq_type(POODLE_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
127
128         return 0;
129 }
130
131 static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
132 {
133         struct pxamci_platform_data* p_d = dev->platform_data;
134
135         if (( 1 << vdd) & p_d->ocr_mask)
136                 GPSR1 = GPIO_bit(POODLE_GPIO_SD_PWR);
137         else
138                 GPCR1 = GPIO_bit(POODLE_GPIO_SD_PWR);
139 }
140
141 static void poodle_mci_exit(struct device *dev, void *data)
142 {
143         free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
144 }
145
146 static struct pxamci_platform_data poodle_mci_platform_data = {
147         .ocr_mask       = MMC_VDD_32_33|MMC_VDD_33_34,
148         .init           = poodle_mci_init,
149         .setpower       = poodle_mci_setpower,
150         .exit           = poodle_mci_exit,
151 };
152
153
154 /*
155  * USB Device Controller
156  */
157 static void poodle_udc_command(int cmd)
158 {
159         switch(cmd)     {
160         case PXA2XX_UDC_CMD_CONNECT:
161                 GPSR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
162                 break;
163         case PXA2XX_UDC_CMD_DISCONNECT:
164                 GPCR(POODLE_GPIO_USB_PULLUP) = GPIO_bit(POODLE_GPIO_USB_PULLUP);
165                 break;
166         }
167 }
168
169 static struct pxa2xx_udc_mach_info udc_info __initdata = {
170         /* no connect GPIO; poodle can't tell connection status */
171         .udc_command            = poodle_udc_command,
172 };
173
174
175 /* PXAFB device */
176 static struct pxafb_mach_info poodle_fb_info __initdata = {
177         .pixclock       = 144700,
178
179         .xres           = 320,
180         .yres           = 240,
181         .bpp            = 16,
182
183         .hsync_len      = 7,
184         .left_margin    = 11,
185         .right_margin   = 30,
186
187         .vsync_len      = 2,
188         .upper_margin   = 2,
189         .lower_margin   = 0,
190         .sync           = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
191
192         .lccr0          = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
193         .lccr3          = 0,
194
195         .pxafb_backlight_power  = NULL,
196         .pxafb_lcd_power        = NULL,
197 };
198
199 static struct platform_device *devices[] __initdata = {
200         &locomo_device,
201         &poodle_scoop_device,
202 };
203
204 static void __init poodle_init(void)
205 {
206         int ret = 0;
207
208         /* setup sleep mode values */
209         PWER  = 0x00000002;
210         PFER  = 0x00000000;
211         PRER  = 0x00000002;
212         PGSR0 = 0x00008000;
213         PGSR1 = 0x003F0202;
214         PGSR2 = 0x0001C000;
215         PCFR |= PCFR_OPDE;
216
217         /* cpu initialize */
218         /* Pgsr Register */
219         PGSR0 = 0x0146dd80;
220         PGSR1 = 0x03bf0890;
221         PGSR2 = 0x0001c000;
222
223         /* Alternate Register */
224         GAFR0_L = 0x01001000;
225         GAFR0_U = 0x591a8010;
226         GAFR1_L = 0x900a8451;
227         GAFR1_U = 0xaaa5aaaa;
228         GAFR2_L = 0x8aaaaaaa;
229         GAFR2_U = 0x00000002;
230
231         /* Direction Register */
232         GPDR0 = 0xd3f0904c;
233         GPDR1 = 0xfcffb7d3;
234         GPDR2 = 0x0001ffff;
235
236         /* Output Register */
237         GPCR0 = 0x00000000;
238         GPCR1 = 0x00000000;
239         GPCR2 = 0x00000000;
240
241         GPSR0 = 0x00400000;
242         GPSR1 = 0x00000000;
243         GPSR2 = 0x00000000;
244
245         set_pxa_fb_info(&poodle_fb_info);
246         pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
247         pxa_set_udc_info(&udc_info);
248         pxa_set_mci_info(&poodle_mci_platform_data);
249
250         scoop_num = 1;
251         scoop_devs = &poodle_pcmcia_scoop[0];
252
253         ret = platform_add_devices(devices, ARRAY_SIZE(devices));
254         if (ret) {
255                 printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
256         }
257 }
258
259 static void __init fixup_poodle(struct machine_desc *desc,
260                 struct tag *tags, char **cmdline, struct meminfo *mi)
261 {
262         sharpsl_save_param();
263 }
264
265 MACHINE_START(POODLE, "SHARP Poodle")
266         .phys_ram       = 0xa0000000,
267         .phys_io        = 0x40000000,
268         .io_pg_offst    = (io_p2v(0x40000000) >> 18) & 0xfffc,
269         .fixup          = fixup_poodle,
270         .map_io         = pxa_map_io,
271         .init_irq       = pxa_init_irq,
272         .timer          = &pxa_timer,
273         .init_machine   = poodle_init,
274 MACHINE_END