2 * Support for Sharp SL-Cxx00 Series of PDAs
3 * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi)
5 * Copyright (c) 2005 Richard Purdie
7 * Based on Sharp's 2.4 kernel patches/lubbock.c
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.
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/platform_device.h>
18 #include <linux/delay.h>
19 #include <linux/major.h>
21 #include <linux/interrupt.h>
22 #include <linux/mmc/host.h>
24 #include <asm/setup.h>
25 #include <asm/memory.h>
26 #include <asm/mach-types.h>
27 #include <asm/hardware.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
33 #include <asm/mach/irq.h>
35 #include <asm/arch/pxa-regs.h>
36 #include <asm/arch/irq.h>
37 #include <asm/arch/irda.h>
38 #include <asm/arch/mmc.h>
39 #include <asm/arch/ohci.h>
40 #include <asm/arch/udc.h>
41 #include <asm/arch/pxafb.h>
42 #include <asm/arch/akita.h>
43 #include <asm/arch/spitz.h>
44 #include <asm/arch/sharpsl.h>
46 #include <asm/mach/sharpsl_param.h>
47 #include <asm/hardware/scoop.h>
53 * Spitz SCOOP Device #1
55 static struct resource spitz_scoop_resources[] = {
59 .flags = IORESOURCE_MEM,
63 static 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,
70 struct platform_device spitzscoop_device = {
71 .name = "sharp-scoop",
74 .platform_data = &spitz_scoop_setup,
76 .num_resources = ARRAY_SIZE(spitz_scoop_resources),
77 .resource = spitz_scoop_resources,
81 * Spitz SCOOP Device #2
83 static struct resource spitz_scoop2_resources[] = {
87 .flags = IORESOURCE_MEM,
91 static 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,
98 struct platform_device spitzscoop2_device = {
99 .name = "sharp-scoop",
102 .platform_data = &spitz_scoop2_setup,
104 .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
105 .resource = spitz_scoop2_resources,
108 #define SPITZ_PWR_SD 0x01
109 #define SPITZ_PWR_CF 0x02
111 /* Power control is shared with between one of the CF slots and SD */
112 static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
114 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
116 if (new_cpr & 0x0007) {
117 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
118 if (!(cpr & 0x0002) && !(cpr & 0x0004))
120 if (device == SPITZ_PWR_CF)
122 if (device == SPITZ_PWR_SD)
124 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
126 if (device == SPITZ_PWR_CF)
128 if (device == SPITZ_PWR_SD)
130 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
131 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
133 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
135 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
140 static void spitz_pcmcia_init(void)
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);
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);
161 static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
163 /* Only need to override behaviour for slot 0 */
165 spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
167 write_scoop_reg(scoop, SCOOP_CPR, cpr);
170 static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
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",
177 .dev = &spitzscoop2_device.dev,
178 .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
183 static struct scoop_pcmcia_config spitz_pcmcia_config = {
184 .devs = &spitz_pcmcia_scoop[0],
186 .pcmcia_init = spitz_pcmcia_init,
187 .power_ctrl = spitz_pcmcia_pwr,
190 EXPORT_SYMBOL(spitzscoop_device);
191 EXPORT_SYMBOL(spitzscoop2_device);
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
201 struct platform_device spitzssp_device = {
204 .parent = &spitzscoop_device.dev,
209 struct corgissp_machinfo spitz_ssp_machinfo = {
211 .cs_lcdcon = SPITZ_GPIO_LCDCON_CS,
212 .cs_ads7846 = SPITZ_GPIO_ADS7846_CS,
213 .cs_max1111 = SPITZ_GPIO_MAX1111_CS,
221 * Spitz Backlight Device
223 static struct corgibl_machinfo spitz_bl_machinfo = {
224 .max_intensity = 0x2f,
227 static struct platform_device spitzbl_device = {
230 .platform_data = &spitz_bl_machinfo,
237 * Spitz Keyboard Device
239 static struct platform_device spitzkbd_device = {
240 .name = "spitz-keyboard",
246 * Spitz Touch Screen Device
248 static struct resource spitzts_resources[] = {
250 .start = SPITZ_IRQ_GPIO_TP_INT,
251 .end = SPITZ_IRQ_GPIO_TP_INT,
252 .flags = IORESOURCE_IRQ,
256 static 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,
262 static struct platform_device spitzts_device = {
265 .parent = &spitzssp_device.dev,
266 .platform_data = &spitz_ts_machinfo,
269 .num_resources = ARRAY_SIZE(spitzts_resources),
270 .resource = spitzts_resources,
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.
281 static struct pxamci_platform_data spitz_mci_platform_data;
283 static int spitz_mci_init(struct device *dev, irqreturn_t (*spitz_detect_int)(int, void *, struct pt_regs *), void *data)
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);
297 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
299 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int,
300 SA_INTERRUPT | SA_TRIGGER_RISING | SA_TRIGGER_FALLING,
301 "MMC card detect", data);
303 printk(KERN_ERR "spitz_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
310 static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
312 struct pxamci_platform_data* p_d = dev->platform_data;
314 if (( 1 << vdd) & p_d->ocr_mask)
315 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
317 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
320 static int spitz_mci_get_ro(struct device *dev)
322 return GPLR(SPITZ_GPIO_nSD_WP) & GPIO_bit(SPITZ_GPIO_nSD_WP);
325 static void spitz_mci_exit(struct device *dev, void *data)
327 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
330 static struct pxamci_platform_data spitz_mci_platform_data = {
331 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
332 .init = spitz_mci_init,
333 .get_ro = spitz_mci_get_ro,
334 .setpower = spitz_mci_setpower,
335 .exit = spitz_mci_exit,
342 static int spitz_ohci_init(struct device *dev)
344 /* Only Port 2 is connected */
345 pxa_gpio_mode(SPITZ_GPIO_USB_CONNECT | GPIO_IN);
346 pxa_gpio_mode(SPITZ_GPIO_USB_HOST | GPIO_OUT);
347 pxa_gpio_mode(SPITZ_GPIO_USB_DEVICE | GPIO_IN);
349 /* Setup USB Port 2 Output Control Register */
350 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
352 GPSR(SPITZ_GPIO_USB_HOST) = GPIO_bit(SPITZ_GPIO_USB_HOST);
355 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
357 UHCRHDA |= UHCRHDA_NOCP;
362 static struct pxaohci_platform_data spitz_ohci_platform_data = {
363 .port_mode = PMM_NPS_MODE,
364 .init = spitz_ohci_init,
371 static void spitz_irda_transceiver_mode(struct device *dev, int mode)
374 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
376 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
379 #ifdef CONFIG_MACH_AKITA
380 static void akita_irda_transceiver_mode(struct device *dev, int mode)
383 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
385 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
389 static struct pxaficp_platform_data spitz_ficp_platform_data = {
390 .transceiver_cap = IR_SIRMODE | IR_OFF,
391 .transceiver_mode = spitz_irda_transceiver_mode,
396 * Spitz PXA Framebuffer
398 static struct pxafb_mach_info spitz_pxafb_info __initdata = {
410 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM,
411 .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH,
412 .pxafb_lcd_power = spitz_lcd_power,
416 static struct platform_device *devices[] __initdata = {
424 static void __init common_init(void)
428 /* setup sleep mode values */
436 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
439 corgi_ssp_set_machinfo(&spitz_ssp_machinfo);
441 pxa_gpio_mode(SPITZ_GPIO_HSYNC | GPIO_IN);
443 platform_add_devices(devices, ARRAY_SIZE(devices));
444 pxa_set_mci_info(&spitz_mci_platform_data);
445 pxa_set_ohci_info(&spitz_ohci_platform_data);
446 pxa_set_ficp_info(&spitz_ficp_platform_data);
447 set_pxa_fb_parent(&spitzssp_device.dev);
448 set_pxa_fb_info(&spitz_pxafb_info);
451 static void __init spitz_init(void)
453 platform_scoop_config = &spitz_pcmcia_config;
455 spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity;
459 platform_device_register(&spitzscoop2_device);
462 #ifdef CONFIG_MACH_AKITA
466 struct platform_device akitaioexp_device = {
467 .name = "akita-ioexp",
471 static void __init akita_init(void)
473 spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
475 /* We just pretend the second element of the array doesn't exist */
476 spitz_pcmcia_config.num_devs = 1;
477 platform_scoop_config = &spitz_pcmcia_config;
478 spitz_bl_machinfo.set_bl_intensity = akita_bl_set_intensity;
480 platform_device_register(&akitaioexp_device);
482 spitzscoop_device.dev.parent = &akitaioexp_device.dev;
488 static void __init fixup_spitz(struct machine_desc *desc,
489 struct tag *tags, char **cmdline, struct meminfo *mi)
491 sharpsl_save_param();
493 mi->bank[0].start = 0xa0000000;
494 mi->bank[0].node = 0;
495 mi->bank[0].size = (64*1024*1024);
498 #ifdef CONFIG_MACH_SPITZ
499 MACHINE_START(SPITZ, "SHARP Spitz")
500 .phys_ram = 0xa0000000,
501 .phys_io = 0x40000000,
502 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
503 .fixup = fixup_spitz,
504 .map_io = pxa_map_io,
505 .init_irq = pxa_init_irq,
506 .init_machine = spitz_init,
511 #ifdef CONFIG_MACH_BORZOI
512 MACHINE_START(BORZOI, "SHARP Borzoi")
513 .phys_ram = 0xa0000000,
514 .phys_io = 0x40000000,
515 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
516 .fixup = fixup_spitz,
517 .map_io = pxa_map_io,
518 .init_irq = pxa_init_irq,
519 .init_machine = spitz_init,
524 #ifdef CONFIG_MACH_AKITA
525 MACHINE_START(AKITA, "SHARP Akita")
526 .phys_ram = 0xa0000000,
527 .phys_io = 0x40000000,
528 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
529 .fixup = fixup_spitz,
530 .map_io = pxa_map_io,
531 .init_irq = pxa_init_irq,
532 .init_machine = akita_init,