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