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