blob: f2007db0cda5aebe5ad398a3909f8ddecd1f688f [file] [log] [blame]
Richard Purdie0dd28f12005-09-13 01:25:34 -07001/*
2 * Support for Sharp SL-Cxx00 Series of PDAs
3 * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi)
4 *
5 * Copyright (c) 2005 Richard Purdie
6 *
7 * Based on Sharp's 2.4 kernel patches/lubbock.c
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 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
Russell Kingd052d1b2005-10-29 19:07:23 +010017#include <linux/platform_device.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070018#include <linux/delay.h>
19#include <linux/major.h>
20#include <linux/fs.h>
21#include <linux/interrupt.h>
22#include <linux/mmc/host.h>
23
24#include <asm/setup.h>
25#include <asm/memory.h>
26#include <asm/mach-types.h>
27#include <asm/hardware.h>
28#include <asm/irq.h>
29#include <asm/io.h>
30
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33#include <asm/mach/irq.h>
34
35#include <asm/arch/pxa-regs.h>
36#include <asm/arch/irq.h>
Richard Purdiedc078452005-10-30 14:50:25 +000037#include <asm/arch/irda.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070038#include <asm/arch/mmc.h>
Richard Purdie3125c682006-01-05 20:44:52 +000039#include <asm/arch/ohci.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070040#include <asm/arch/udc.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070041#include <asm/arch/pxafb.h>
42#include <asm/arch/akita.h>
43#include <asm/arch/spitz.h>
44#include <asm/arch/sharpsl.h>
45
46#include <asm/mach/sharpsl_param.h>
47#include <asm/hardware/scoop.h>
48
49#include "generic.h"
50#include "sharpsl.h"
51
52/*
53 * Spitz SCOOP Device #1
54 */
55static struct resource spitz_scoop_resources[] = {
56 [0] = {
57 .start = 0x10800000,
58 .end = 0x10800fff,
59 .flags = IORESOURCE_MEM,
60 },
61};
62
63static struct scoop_config spitz_scoop_setup = {
64 .io_dir = SPITZ_SCP_IO_DIR,
65 .io_out = SPITZ_SCP_IO_OUT,
66 .suspend_clr = SPITZ_SCP_SUS_CLR,
67 .suspend_set = SPITZ_SCP_SUS_SET,
68};
69
70struct platform_device spitzscoop_device = {
71 .name = "sharp-scoop",
72 .id = 0,
73 .dev = {
74 .platform_data = &spitz_scoop_setup,
75 },
76 .num_resources = ARRAY_SIZE(spitz_scoop_resources),
77 .resource = spitz_scoop_resources,
78};
79
80/*
81 * Spitz SCOOP Device #2
82 */
83static struct resource spitz_scoop2_resources[] = {
84 [0] = {
85 .start = 0x08800040,
86 .end = 0x08800fff,
87 .flags = IORESOURCE_MEM,
88 },
89};
90
91static struct scoop_config spitz_scoop2_setup = {
92 .io_dir = SPITZ_SCP2_IO_DIR,
93 .io_out = SPITZ_SCP2_IO_OUT,
94 .suspend_clr = SPITZ_SCP2_SUS_CLR,
95 .suspend_set = SPITZ_SCP2_SUS_SET,
96};
97
98struct platform_device spitzscoop2_device = {
99 .name = "sharp-scoop",
100 .id = 1,
101 .dev = {
102 .platform_data = &spitz_scoop2_setup,
103 },
104 .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
105 .resource = spitz_scoop2_resources,
106};
107
Richard Purdiea63ae442005-11-08 19:15:43 +0000108#define SPITZ_PWR_SD 0x01
109#define SPITZ_PWR_CF 0x02
110
111/* Power control is shared with between one of the CF slots and SD */
112static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
113{
114 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
115
116 if (new_cpr & 0x0007) {
117 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
118 if (!(cpr & 0x0002) && !(cpr & 0x0004))
119 mdelay(5);
120 if (device == SPITZ_PWR_CF)
121 cpr |= 0x0002;
122 if (device == SPITZ_PWR_SD)
123 cpr |= 0x0004;
124 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
125 } else {
126 if (device == SPITZ_PWR_CF)
127 cpr &= ~0x0002;
128 if (device == SPITZ_PWR_SD)
129 cpr &= ~0x0004;
Richard Purdiea63ae442005-11-08 19:15:43 +0000130 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
Richard Purdie945b9572006-01-05 20:44:57 +0000131 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
Richard Purdiea63ae442005-11-08 19:15:43 +0000132 mdelay(1);
133 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
Richard Purdie945b9572006-01-05 20:44:57 +0000134 } else {
135 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
Richard Purdiea63ae442005-11-08 19:15:43 +0000136 }
137 }
138}
139
140static void spitz_pcmcia_init(void)
141{
142 /* Setup default state of GPIO outputs
143 before we enable them as outputs. */
144 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
145 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
146 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO54_nPCE_2);
147 GPSR(GPIO85_nPCE_1) = GPIO_bit(GPIO85_nPCE_1);
148
149 pxa_gpio_mode(GPIO48_nPOE_MD);
150 pxa_gpio_mode(GPIO49_nPWE_MD);
151 pxa_gpio_mode(GPIO50_nPIOR_MD);
152 pxa_gpio_mode(GPIO51_nPIOW_MD);
153 pxa_gpio_mode(GPIO55_nPREG_MD);
154 pxa_gpio_mode(GPIO56_nPWAIT_MD);
155 pxa_gpio_mode(GPIO57_nIOIS16_MD);
156 pxa_gpio_mode(GPIO85_nPCE_1_MD);
157 pxa_gpio_mode(GPIO54_nPCE_2_MD);
158 pxa_gpio_mode(GPIO104_pSKTSEL_MD);
159}
160
161static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
162{
163 /* Only need to override behaviour for slot 0 */
164 if (nr == 0)
165 spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
166 else
167 write_scoop_reg(scoop, SCOOP_CPR, cpr);
168}
169
Richard Purdie0dd28f12005-09-13 01:25:34 -0700170static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
171{
172 .dev = &spitzscoop_device.dev,
173 .irq = SPITZ_IRQ_GPIO_CF_IRQ,
174 .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
175 .cd_irq_str = "PCMCIA0 CD",
176},{
177 .dev = &spitzscoop2_device.dev,
178 .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
179 .cd_irq = -1,
180},
181};
182
Richard Purdiea63ae442005-11-08 19:15:43 +0000183static struct scoop_pcmcia_config spitz_pcmcia_config = {
184 .devs = &spitz_pcmcia_scoop[0],
185 .num_devs = 2,
186 .pcmcia_init = spitz_pcmcia_init,
187 .power_ctrl = spitz_pcmcia_pwr,
188};
189
190EXPORT_SYMBOL(spitzscoop_device);
191EXPORT_SYMBOL(spitzscoop2_device);
192
Richard Purdie0dd28f12005-09-13 01:25:34 -0700193
194/*
195 * Spitz SSP Device
196 *
197 * Set the parent as the scoop device because a lot of SSP devices
198 * also use scoop functions and this makes the power up/down order
199 * work correctly.
200 */
201struct platform_device spitzssp_device = {
202 .name = "corgi-ssp",
203 .dev = {
204 .parent = &spitzscoop_device.dev,
205 },
206 .id = -1,
207};
208
209struct corgissp_machinfo spitz_ssp_machinfo = {
210 .port = 2,
211 .cs_lcdcon = SPITZ_GPIO_LCDCON_CS,
212 .cs_ads7846 = SPITZ_GPIO_ADS7846_CS,
213 .cs_max1111 = SPITZ_GPIO_MAX1111_CS,
214 .clk_lcdcon = 520,
215 .clk_ads7846 = 14,
216 .clk_max1111 = 56,
217};
218
219
220/*
221 * Spitz Backlight Device
222 */
223static struct corgibl_machinfo spitz_bl_machinfo = {
224 .max_intensity = 0x2f,
225};
226
227static struct platform_device spitzbl_device = {
228 .name = "corgi-bl",
229 .dev = {
230 .platform_data = &spitz_bl_machinfo,
231 },
232 .id = -1,
233};
234
235
236/*
237 * Spitz Keyboard Device
238 */
239static struct platform_device spitzkbd_device = {
240 .name = "spitz-keyboard",
241 .id = -1,
242};
243
244
245/*
246 * Spitz Touch Screen Device
247 */
248static struct resource spitzts_resources[] = {
249 [0] = {
250 .start = SPITZ_IRQ_GPIO_TP_INT,
251 .end = SPITZ_IRQ_GPIO_TP_INT,
252 .flags = IORESOURCE_IRQ,
253 },
254};
255
256static struct corgits_machinfo spitz_ts_machinfo = {
257 .get_hsync_len = spitz_get_hsync_len,
258 .put_hsync = spitz_put_hsync,
259 .wait_hsync = spitz_wait_hsync,
260};
261
262static struct platform_device spitzts_device = {
263 .name = "corgi-ts",
264 .dev = {
265 .parent = &spitzssp_device.dev,
266 .platform_data = &spitz_ts_machinfo,
267 },
268 .id = -1,
269 .num_resources = ARRAY_SIZE(spitzts_resources),
270 .resource = spitzts_resources,
271};
272
273
274/*
275 * MMC/SD Device
276 *
277 * The card detect interrupt isn't debounced so we delay it by 250ms
278 * to give the card a chance to fully insert/eject.
279 */
280
281static struct pxamci_platform_data spitz_mci_platform_data;
282
283static int spitz_mci_init(struct device *dev, irqreturn_t (*spitz_detect_int)(int, void *, struct pt_regs *), void *data)
284{
285 int err;
286
287 /* setup GPIO for PXA27x MMC controller */
288 pxa_gpio_mode(GPIO32_MMCCLK_MD);
289 pxa_gpio_mode(GPIO112_MMCCMD_MD);
290 pxa_gpio_mode(GPIO92_MMCDAT0_MD);
291 pxa_gpio_mode(GPIO109_MMCDAT1_MD);
292 pxa_gpio_mode(GPIO110_MMCDAT2_MD);
293 pxa_gpio_mode(GPIO111_MMCDAT3_MD);
294 pxa_gpio_mode(SPITZ_GPIO_nSD_DETECT | GPIO_IN);
295 pxa_gpio_mode(SPITZ_GPIO_nSD_WP | GPIO_IN);
296
297 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
298
299 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int, SA_INTERRUPT,
300 "MMC card detect", data);
301 if (err) {
302 printk(KERN_ERR "spitz_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
303 return -1;
304 }
305
306 set_irq_type(SPITZ_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
307
308 return 0;
309}
310
Richard Purdie0dd28f12005-09-13 01:25:34 -0700311static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
312{
313 struct pxamci_platform_data* p_d = dev->platform_data;
314
Richard Purdiea63ae442005-11-08 19:15:43 +0000315 if (( 1 << vdd) & p_d->ocr_mask)
316 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
317 else
318 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700319}
320
321static int spitz_mci_get_ro(struct device *dev)
322{
323 return GPLR(SPITZ_GPIO_nSD_WP) & GPIO_bit(SPITZ_GPIO_nSD_WP);
324}
325
326static void spitz_mci_exit(struct device *dev, void *data)
327{
328 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
329}
330
331static struct pxamci_platform_data spitz_mci_platform_data = {
332 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
333 .init = spitz_mci_init,
334 .get_ro = spitz_mci_get_ro,
335 .setpower = spitz_mci_setpower,
336 .exit = spitz_mci_exit,
337};
338
339
340/*
Richard Purdie3125c682006-01-05 20:44:52 +0000341 * USB Host (OHCI)
342 */
343static int spitz_ohci_init(struct device *dev)
344{
345 /* Only Port 2 is connected */
346 pxa_gpio_mode(SPITZ_GPIO_USB_CONNECT | GPIO_IN);
347 pxa_gpio_mode(SPITZ_GPIO_USB_HOST | GPIO_OUT);
348 pxa_gpio_mode(SPITZ_GPIO_USB_DEVICE | GPIO_IN);
349
350 /* Setup USB Port 2 Output Control Register */
351 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
352
353 GPSR(SPITZ_GPIO_USB_HOST) = GPIO_bit(SPITZ_GPIO_USB_HOST);
354
355 UHCHR = (UHCHR) &
356 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
357
358 UHCRHDA |= UHCRHDA_NOCP;
359
360 return 0;
361}
362
363static struct pxaohci_platform_data spitz_ohci_platform_data = {
364 .port_mode = PMM_NPS_MODE,
365 .init = spitz_ohci_init,
366};
367
368
369/*
Richard Purdiedc078452005-10-30 14:50:25 +0000370 * Irda
371 */
372static void spitz_irda_transceiver_mode(struct device *dev, int mode)
373{
374 if (mode & IR_OFF)
375 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
376 else
377 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
378}
379
Richard Purdie94cabd02005-11-12 18:53:48 +0000380#ifdef CONFIG_MACH_AKITA
381static void akita_irda_transceiver_mode(struct device *dev, int mode)
382{
383 if (mode & IR_OFF)
384 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
385 else
386 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
387}
388#endif
389
Richard Purdiedc078452005-10-30 14:50:25 +0000390static struct pxaficp_platform_data spitz_ficp_platform_data = {
391 .transceiver_cap = IR_SIRMODE | IR_OFF,
392 .transceiver_mode = spitz_irda_transceiver_mode,
393};
394
395
396/*
Richard Purdie0dd28f12005-09-13 01:25:34 -0700397 * Spitz PXA Framebuffer
398 */
399static struct pxafb_mach_info spitz_pxafb_info __initdata = {
400 .pixclock = 19231,
401 .xres = 480,
402 .yres = 640,
403 .bpp = 16,
404 .hsync_len = 40,
405 .left_margin = 46,
406 .right_margin = 125,
407 .vsync_len = 3,
408 .upper_margin = 1,
409 .lower_margin = 0,
410 .sync = 0,
411 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM,
412 .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH,
413 .pxafb_lcd_power = spitz_lcd_power,
414};
415
416
417static struct platform_device *devices[] __initdata = {
418 &spitzscoop_device,
419 &spitzssp_device,
420 &spitzkbd_device,
421 &spitzts_device,
422 &spitzbl_device,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700423};
424
425static void __init common_init(void)
426{
427 PMCR = 0x00;
428
429 /* setup sleep mode values */
430 PWER = 0x00000002;
431 PFER = 0x00000000;
432 PRER = 0x00000002;
433 PGSR0 = 0x0158C000;
434 PGSR1 = 0x00FF0080;
435 PGSR2 = 0x0001C004;
436
437 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
438 PCFR |= PCFR_OPDE;
439
440 corgi_ssp_set_machinfo(&spitz_ssp_machinfo);
441
442 pxa_gpio_mode(SPITZ_GPIO_HSYNC | GPIO_IN);
443
444 platform_add_devices(devices, ARRAY_SIZE(devices));
445 pxa_set_mci_info(&spitz_mci_platform_data);
Richard Purdie3125c682006-01-05 20:44:52 +0000446 pxa_set_ohci_info(&spitz_ohci_platform_data);
Richard Purdiedc078452005-10-30 14:50:25 +0000447 pxa_set_ficp_info(&spitz_ficp_platform_data);
Richard Purdiecb38c562005-10-14 16:07:25 +0100448 set_pxa_fb_parent(&spitzssp_device.dev);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700449 set_pxa_fb_info(&spitz_pxafb_info);
450}
451
452static void __init spitz_init(void)
453{
Richard Purdiea63ae442005-11-08 19:15:43 +0000454 platform_scoop_config = &spitz_pcmcia_config;
455
Richard Purdie0dd28f12005-09-13 01:25:34 -0700456 spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity;
457
458 common_init();
459
460 platform_device_register(&spitzscoop2_device);
461}
462
Richard Purdie94cabd02005-11-12 18:53:48 +0000463#ifdef CONFIG_MACH_AKITA
464/*
465 * Akita IO Expander
466 */
467struct platform_device akitaioexp_device = {
468 .name = "akita-ioexp",
469 .id = -1,
470};
471
472static void __init akita_init(void)
473{
474 spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
475
476 /* We just pretend the second element of the array doesn't exist */
477 spitz_pcmcia_config.num_devs = 1;
478 platform_scoop_config = &spitz_pcmcia_config;
479 spitz_bl_machinfo.set_bl_intensity = akita_bl_set_intensity;
480
481 platform_device_register(&akitaioexp_device);
482
483 spitzscoop_device.dev.parent = &akitaioexp_device.dev;
484 common_init();
485}
486#endif
487
488
Richard Purdie0dd28f12005-09-13 01:25:34 -0700489static void __init fixup_spitz(struct machine_desc *desc,
490 struct tag *tags, char **cmdline, struct meminfo *mi)
491{
492 sharpsl_save_param();
493 mi->nr_banks = 1;
494 mi->bank[0].start = 0xa0000000;
495 mi->bank[0].node = 0;
496 mi->bank[0].size = (64*1024*1024);
497}
498
499#ifdef CONFIG_MACH_SPITZ
500MACHINE_START(SPITZ, "SHARP Spitz")
501 .phys_ram = 0xa0000000,
502 .phys_io = 0x40000000,
503 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
504 .fixup = fixup_spitz,
505 .map_io = pxa_map_io,
506 .init_irq = pxa_init_irq,
507 .init_machine = spitz_init,
508 .timer = &pxa_timer,
509MACHINE_END
510#endif
511
512#ifdef CONFIG_MACH_BORZOI
513MACHINE_START(BORZOI, "SHARP Borzoi")
514 .phys_ram = 0xa0000000,
515 .phys_io = 0x40000000,
516 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
517 .fixup = fixup_spitz,
518 .map_io = pxa_map_io,
519 .init_irq = pxa_init_irq,
520 .init_machine = spitz_init,
521 .timer = &pxa_timer,
522MACHINE_END
523#endif
Richard Purdie94cabd02005-11-12 18:53:48 +0000524
525#ifdef CONFIG_MACH_AKITA
526MACHINE_START(AKITA, "SHARP Akita")
527 .phys_ram = 0xa0000000,
528 .phys_io = 0x40000000,
529 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
530 .fixup = fixup_spitz,
531 .map_io = pxa_map_io,
532 .init_irq = pxa_init_irq,
533 .init_machine = akita_init,
534 .timer = &pxa_timer,
535MACHINE_END
536#endif