blob: 9a9fa87cea9fbcd6b839aa41313e78b0d65e4794 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
Russell Kingd052d1b2005-10-29 19:07:23 +010019#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <linux/fb.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010021#include <linux/pm.h>
Richard Purdie88660352006-06-19 19:58:51 +010022#include <linux/delay.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
24#include <asm/hardware.h>
25#include <asm/mach-types.h>
26#include <asm/irq.h>
27#include <asm/setup.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010028#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
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>
Richard Purdie13b9d472005-09-15 14:53:22 +010035#include <asm/arch/mmc.h>
36#include <asm/arch/udc.h>
Richard Purdie8e4b8712005-10-30 14:38:52 +000037#include <asm/arch/irda.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#include <asm/arch/poodle.h>
39#include <asm/arch/pxafb.h>
Richard Purdiefaed5682006-06-19 20:46:05 +010040#include <asm/arch/sharpsl.h>
41#include <asm/arch/ssp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
43#include <asm/hardware/scoop.h>
44#include <asm/hardware/locomo.h>
45#include <asm/mach/sharpsl_param.h>
46
47#include "generic.h"
Richard Purdiefaed5682006-06-19 20:46:05 +010048#include "sharpsl.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50static struct resource poodle_scoop_resources[] = {
51 [0] = {
52 .start = 0x10800000,
53 .end = 0x10800fff,
54 .flags = IORESOURCE_MEM,
55 },
56};
57
58static struct scoop_config poodle_scoop_setup = {
59 .io_dir = POODLE_SCOOP_IO_DIR,
60 .io_out = POODLE_SCOOP_IO_OUT,
61};
62
63struct platform_device poodle_scoop_device = {
64 .name = "sharp-scoop",
65 .id = -1,
66 .dev = {
67 .platform_data = &poodle_scoop_setup,
68 },
69 .num_resources = ARRAY_SIZE(poodle_scoop_resources),
70 .resource = poodle_scoop_resources,
71};
72
Richard Purdiea63ae442005-11-08 19:15:43 +000073static void poodle_pcmcia_init(void)
74{
75 /* Setup default state of GPIO outputs
76 before we enable them as outputs. */
77 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
78 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
79 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
80 GPIO_bit(GPIO53_nPCE_2);
81
82 pxa_gpio_mode(GPIO48_nPOE_MD);
83 pxa_gpio_mode(GPIO49_nPWE_MD);
84 pxa_gpio_mode(GPIO50_nPIOR_MD);
85 pxa_gpio_mode(GPIO51_nPIOW_MD);
86 pxa_gpio_mode(GPIO55_nPREG_MD);
87 pxa_gpio_mode(GPIO56_nPWAIT_MD);
88 pxa_gpio_mode(GPIO57_nIOIS16_MD);
89 pxa_gpio_mode(GPIO52_nPCE_1_MD);
90 pxa_gpio_mode(GPIO53_nPCE_2_MD);
91 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
92}
93
Richard Purdie0ce76252005-09-05 20:49:54 +010094static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
95{
96 .dev = &poodle_scoop_device.dev,
97 .irq = POODLE_IRQ_GPIO_CF_IRQ,
98 .cd_irq = POODLE_IRQ_GPIO_CF_CD,
99 .cd_irq_str = "PCMCIA0 CD",
100},
101};
102
Richard Purdiea63ae442005-11-08 19:15:43 +0000103static struct scoop_pcmcia_config poodle_pcmcia_config = {
104 .devs = &poodle_pcmcia_scoop[0],
105 .num_devs = 1,
106 .pcmcia_init = poodle_pcmcia_init,
107};
108
109EXPORT_SYMBOL(poodle_scoop_device);
110
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
112/* LoCoMo device */
113static struct resource locomo_resources[] = {
114 [0] = {
115 .start = 0x10000000,
116 .end = 0x10001fff,
117 .flags = IORESOURCE_MEM,
118 },
119 [1] = {
120 .start = IRQ_GPIO(10),
121 .end = IRQ_GPIO(10),
122 .flags = IORESOURCE_IRQ,
123 },
124};
125
Richard Purdiefaed5682006-06-19 20:46:05 +0100126struct platform_device poodle_locomo_device = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127 .name = "locomo",
128 .id = 0,
129 .num_resources = ARRAY_SIZE(locomo_resources),
130 .resource = locomo_resources,
131};
132
Richard Purdiefaed5682006-06-19 20:46:05 +0100133EXPORT_SYMBOL(poodle_locomo_device);
134
135/*
136 * Poodle SSP Device
137 */
138
139struct platform_device poodle_ssp_device = {
140 .name = "corgi-ssp",
141 .id = -1,
142};
143
144struct corgissp_machinfo poodle_ssp_machinfo = {
145 .port = 1,
146 .cs_lcdcon = -1,
147 .cs_ads7846 = -1,
148 .cs_max1111 = -1,
149 .clk_lcdcon = 2,
150 .clk_ads7846 = 36,
151 .clk_max1111 = 2,
152};
153
154
155/*
156 * Poodle Touch Screen Device
157 */
158static struct resource poodlets_resources[] = {
159 [0] = {
160 .start = POODLE_IRQ_GPIO_TP_INT,
161 .end = POODLE_IRQ_GPIO_TP_INT,
162 .flags = IORESOURCE_IRQ,
163 },
164};
165
166static unsigned long poodle_get_hsync_len(void)
167{
168 return 0;
169}
170
171static void poodle_null_hsync(void)
172{
173}
174
175static struct corgits_machinfo poodle_ts_machinfo = {
176 .get_hsync_len = poodle_get_hsync_len,
177 .put_hsync = poodle_null_hsync,
178 .wait_hsync = poodle_null_hsync,
179};
180
181static struct platform_device poodle_ts_device = {
182 .name = "corgi-ts",
183 .dev = {
184 .platform_data = &poodle_ts_machinfo,
185 },
186 .id = -1,
187 .num_resources = ARRAY_SIZE(poodlets_resources),
188 .resource = poodlets_resources,
189};
190
Richard Purdie13b9d472005-09-15 14:53:22 +0100191
192/*
193 * MMC/SD Device
194 *
195 * The card detect interrupt isn't debounced so we delay it by 250ms
196 * to give the card a chance to fully insert/eject.
197 */
198static struct pxamci_platform_data poodle_mci_platform_data;
199
200static int poodle_mci_init(struct device *dev, irqreturn_t (*poodle_detect_int)(int, void *, struct pt_regs *), void *data)
201{
202 int err;
203
204 /* setup GPIO for PXA25x MMC controller */
205 pxa_gpio_mode(GPIO6_MMCCLK_MD);
206 pxa_gpio_mode(GPIO8_MMCCS0_MD);
207 pxa_gpio_mode(POODLE_GPIO_nSD_DETECT | GPIO_IN);
Richard Purdie88660352006-06-19 19:58:51 +0100208 pxa_gpio_mode(POODLE_GPIO_nSD_WP | GPIO_IN);
Richard Purdie13b9d472005-09-15 14:53:22 +0100209 pxa_gpio_mode(POODLE_GPIO_SD_PWR | GPIO_OUT);
Richard Purdie88660352006-06-19 19:58:51 +0100210 pxa_gpio_mode(POODLE_GPIO_SD_PWR1 | GPIO_OUT);
Richard Purdie13b9d472005-09-15 14:53:22 +0100211
212 poodle_mci_platform_data.detect_delay = msecs_to_jiffies(250);
213
Russell King9ded96f2006-01-08 01:02:07 -0800214 err = request_irq(POODLE_IRQ_GPIO_nSD_DETECT, poodle_detect_int,
215 SA_INTERRUPT | SA_TRIGGER_RISING | SA_TRIGGER_FALLING,
216 "MMC card detect", data);
Richard Purdie13b9d472005-09-15 14:53:22 +0100217 if (err) {
218 printk(KERN_ERR "poodle_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
219 return -1;
220 }
221
Richard Purdie13b9d472005-09-15 14:53:22 +0100222 return 0;
223}
224
225static void poodle_mci_setpower(struct device *dev, unsigned int vdd)
226{
227 struct pxamci_platform_data* p_d = dev->platform_data;
228
Richard Purdie88660352006-06-19 19:58:51 +0100229 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 }
Richard Purdie13b9d472005-09-15 14:53:22 +0100237}
238
Richard Purdie88660352006-06-19 19:58:51 +0100239static 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
Richard Purdie13b9d472005-09-15 14:53:22 +0100245static void poodle_mci_exit(struct device *dev, void *data)
246{
247 free_irq(POODLE_IRQ_GPIO_nSD_DETECT, data);
248}
249
250static struct pxamci_platform_data poodle_mci_platform_data = {
251 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
252 .init = poodle_mci_init,
Richard Purdie88660352006-06-19 19:58:51 +0100253 .get_ro = poodle_mci_get_ro,
Richard Purdie13b9d472005-09-15 14:53:22 +0100254 .setpower = poodle_mci_setpower,
255 .exit = poodle_mci_exit,
256};
257
258
259/*
Richard Purdie8e4b8712005-10-30 14:38:52 +0000260 * Irda
261 */
262static 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
271static 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/*
Richard Purdie13b9d472005-09-15 14:53:22 +0100278 * USB Device Controller
279 */
280static 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
292static 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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298/* PXAFB device */
299static struct pxafb_mach_info poodle_fb_info __initdata = {
300 .pixclock = 144700,
301
302 .xres = 320,
303 .yres = 240,
304 .bpp = 16,
305
306 .hsync_len = 7,
307 .left_margin = 11,
308 .right_margin = 30,
309
310 .vsync_len = 2,
311 .upper_margin = 2,
312 .lower_margin = 0,
313 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
314
315 .lccr0 = LCCR0_Act | LCCR0_Sngl | LCCR0_Color,
316 .lccr3 = 0,
317
318 .pxafb_backlight_power = NULL,
319 .pxafb_lcd_power = NULL,
320};
321
322static struct platform_device *devices[] __initdata = {
Richard Purdiefaed5682006-06-19 20:46:05 +0100323 &poodle_locomo_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 &poodle_scoop_device,
Richard Purdiefaed5682006-06-19 20:46:05 +0100325 &poodle_ssp_device,
326 &poodle_ts_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327};
328
Richard Purdie74617fb2006-06-19 19:57:12 +0100329static void poodle_poweroff(void)
330{
331 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
332 arm_machine_restart('h');
333}
334
335static void poodle_restart(char mode)
336{
337 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
338 arm_machine_restart('h');
339}
340
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341static void __init poodle_init(void)
342{
343 int ret = 0;
344
Richard Purdie74617fb2006-06-19 19:57:12 +0100345 pm_power_off = poodle_poweroff;
346 arm_pm_restart = poodle_restart;
347
Richard Purdief29d2452005-09-15 14:53:22 +0100348 /* setup sleep mode values */
349 PWER = 0x00000002;
350 PFER = 0x00000000;
351 PRER = 0x00000002;
352 PGSR0 = 0x00008000;
353 PGSR1 = 0x003F0202;
354 PGSR2 = 0x0001C000;
355 PCFR |= PCFR_OPDE;
356
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 /* cpu initialize */
358 /* Pgsr Register */
359 PGSR0 = 0x0146dd80;
360 PGSR1 = 0x03bf0890;
361 PGSR2 = 0x0001c000;
362
363 /* Alternate Register */
364 GAFR0_L = 0x01001000;
365 GAFR0_U = 0x591a8010;
366 GAFR1_L = 0x900a8451;
367 GAFR1_U = 0xaaa5aaaa;
368 GAFR2_L = 0x8aaaaaaa;
369 GAFR2_U = 0x00000002;
370
371 /* Direction Register */
372 GPDR0 = 0xd3f0904c;
373 GPDR1 = 0xfcffb7d3;
374 GPDR2 = 0x0001ffff;
375
376 /* Output Register */
377 GPCR0 = 0x00000000;
378 GPCR1 = 0x00000000;
379 GPCR2 = 0x00000000;
380
381 GPSR0 = 0x00400000;
382 GPSR1 = 0x00000000;
383 GPSR2 = 0x00000000;
384
Richard Purdiefaed5682006-06-19 20:46:05 +0100385 set_pxa_fb_parent(&poodle_locomo_device.dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 set_pxa_fb_info(&poodle_fb_info);
Richard Purdie13b9d472005-09-15 14:53:22 +0100387 pxa_gpio_mode(POODLE_GPIO_USB_PULLUP | GPIO_OUT);
Richard Purdie8e4b8712005-10-30 14:38:52 +0000388 pxa_gpio_mode(POODLE_GPIO_IR_ON | GPIO_OUT);
Richard Purdie13b9d472005-09-15 14:53:22 +0100389 pxa_set_udc_info(&udc_info);
390 pxa_set_mci_info(&poodle_mci_platform_data);
Richard Purdie8e4b8712005-10-30 14:38:52 +0000391 pxa_set_ficp_info(&poodle_ficp_platform_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392
Richard Purdiea63ae442005-11-08 19:15:43 +0000393 platform_scoop_config = &poodle_pcmcia_config;
Richard Purdie0ce76252005-09-05 20:49:54 +0100394
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
396 if (ret) {
397 printk(KERN_WARNING "poodle: Unable to register LoCoMo device\n");
398 }
Richard Purdiefaed5682006-06-19 20:46:05 +0100399 corgi_ssp_set_machinfo(&poodle_ssp_machinfo);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400}
401
402static void __init fixup_poodle(struct machine_desc *desc,
403 struct tag *tags, char **cmdline, struct meminfo *mi)
404{
405 sharpsl_save_param();
Richard Purdieb2e6f752006-04-02 17:11:00 +0100406 mi->nr_banks=1;
407 mi->bank[0].start = 0xa0000000;
408 mi->bank[0].node = 0;
409 mi->bank[0].size = (32*1024*1024);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410}
411
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412MACHINE_START(POODLE, "SHARP Poodle")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100413 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100414 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100415 .fixup = fixup_poodle,
Richard Purdief29d2452005-09-15 14:53:22 +0100416 .map_io = pxa_map_io,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100417 .init_irq = pxa_init_irq,
418 .timer = &pxa_timer,
419 .init_machine = poodle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420MACHINE_END