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/irda.h>
37 #include <asm/arch/mmc.h>
38 #include <asm/arch/ohci.h>
39 #include <asm/arch/udc.h>
40 #include <asm/arch/pxafb.h>
41 #include <asm/arch/akita.h>
42 #include <asm/arch/spitz.h>
43 #include <asm/arch/sharpsl.h>
45 #include <asm/mach/sharpsl_param.h>
46 #include <asm/hardware/scoop.h>
52 * Spitz SCOOP Device #1
54 static struct resource spitz_scoop_resources[] = {
58 .flags = IORESOURCE_MEM,
62 static 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,
69 struct platform_device spitzscoop_device = {
70 .name = "sharp-scoop",
73 .platform_data = &spitz_scoop_setup,
75 .num_resources = ARRAY_SIZE(spitz_scoop_resources),
76 .resource = spitz_scoop_resources,
80 * Spitz SCOOP Device #2
82 static struct resource spitz_scoop2_resources[] = {
86 .flags = IORESOURCE_MEM,
90 static 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,
97 struct platform_device spitzscoop2_device = {
98 .name = "sharp-scoop",
101 .platform_data = &spitz_scoop2_setup,
103 .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
104 .resource = spitz_scoop2_resources,
107 #define SPITZ_PWR_SD 0x01
108 #define SPITZ_PWR_CF 0x02
110 /* Power control is shared with between one of the CF slots and SD */
111 static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
113 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
115 if (new_cpr & 0x0007) {
116 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
117 if (!(cpr & 0x0002) && !(cpr & 0x0004))
119 if (device == SPITZ_PWR_CF)
121 if (device == SPITZ_PWR_SD)
123 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
125 if (device == SPITZ_PWR_CF)
127 if (device == SPITZ_PWR_SD)
129 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
130 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
132 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
134 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
139 static void spitz_pcmcia_init(void)
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);
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);
160 static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
162 /* Only need to override behaviour for slot 0 */
164 spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
166 write_scoop_reg(scoop, SCOOP_CPR, cpr);
169 static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
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",
176 .dev = &spitzscoop2_device.dev,
177 .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
182 static struct scoop_pcmcia_config spitz_pcmcia_config = {
183 .devs = &spitz_pcmcia_scoop[0],
185 .pcmcia_init = spitz_pcmcia_init,
186 .power_ctrl = spitz_pcmcia_pwr,
189 EXPORT_SYMBOL(spitzscoop_device);
190 EXPORT_SYMBOL(spitzscoop2_device);
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
200 struct platform_device spitzssp_device = {
203 .parent = &spitzscoop_device.dev,
208 struct corgissp_machinfo spitz_ssp_machinfo = {
210 .cs_lcdcon = SPITZ_GPIO_LCDCON_CS,
211 .cs_ads7846 = SPITZ_GPIO_ADS7846_CS,
212 .cs_max1111 = SPITZ_GPIO_MAX1111_CS,
220 * Spitz Backlight Device
222 static struct corgibl_machinfo spitz_bl_machinfo = {
223 .default_intensity = 0x1f,
225 .max_intensity = 0x2f,
228 static struct platform_device spitzbl_device = {
231 .platform_data = &spitz_bl_machinfo,
238 * Spitz Keyboard Device
240 static struct platform_device spitzkbd_device = {
241 .name = "spitz-keyboard",
249 static struct platform_device spitzled_device = {
255 * Spitz Touch Screen Device
257 static struct resource spitzts_resources[] = {
259 .start = SPITZ_IRQ_GPIO_TP_INT,
260 .end = SPITZ_IRQ_GPIO_TP_INT,
261 .flags = IORESOURCE_IRQ,
265 static struct corgits_machinfo spitz_ts_machinfo = {
266 .get_hsync_len = spitz_get_hsync_len,
267 .put_hsync = spitz_put_hsync,
268 .wait_hsync = spitz_wait_hsync,
271 static struct platform_device spitzts_device = {
274 .parent = &spitzssp_device.dev,
275 .platform_data = &spitz_ts_machinfo,
278 .num_resources = ARRAY_SIZE(spitzts_resources),
279 .resource = spitzts_resources,
286 * The card detect interrupt isn't debounced so we delay it by 250ms
287 * to give the card a chance to fully insert/eject.
290 static struct pxamci_platform_data spitz_mci_platform_data;
292 static int spitz_mci_init(struct device *dev, irqreturn_t (*spitz_detect_int)(int, void *, struct pt_regs *), void *data)
296 /* setup GPIO for PXA27x MMC controller */
297 pxa_gpio_mode(GPIO32_MMCCLK_MD);
298 pxa_gpio_mode(GPIO112_MMCCMD_MD);
299 pxa_gpio_mode(GPIO92_MMCDAT0_MD);
300 pxa_gpio_mode(GPIO109_MMCDAT1_MD);
301 pxa_gpio_mode(GPIO110_MMCDAT2_MD);
302 pxa_gpio_mode(GPIO111_MMCDAT3_MD);
303 pxa_gpio_mode(SPITZ_GPIO_nSD_DETECT | GPIO_IN);
304 pxa_gpio_mode(SPITZ_GPIO_nSD_WP | GPIO_IN);
306 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
308 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int,
309 SA_INTERRUPT | SA_TRIGGER_RISING | SA_TRIGGER_FALLING,
310 "MMC card detect", data);
312 printk(KERN_ERR "spitz_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
319 static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
321 struct pxamci_platform_data* p_d = dev->platform_data;
323 if (( 1 << vdd) & p_d->ocr_mask)
324 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
326 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
329 static int spitz_mci_get_ro(struct device *dev)
331 return GPLR(SPITZ_GPIO_nSD_WP) & GPIO_bit(SPITZ_GPIO_nSD_WP);
334 static void spitz_mci_exit(struct device *dev, void *data)
336 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
339 static struct pxamci_platform_data spitz_mci_platform_data = {
340 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
341 .init = spitz_mci_init,
342 .get_ro = spitz_mci_get_ro,
343 .setpower = spitz_mci_setpower,
344 .exit = spitz_mci_exit,
351 static int spitz_ohci_init(struct device *dev)
353 /* Only Port 2 is connected */
354 pxa_gpio_mode(SPITZ_GPIO_USB_CONNECT | GPIO_IN);
355 pxa_gpio_mode(SPITZ_GPIO_USB_HOST | GPIO_OUT);
356 pxa_gpio_mode(SPITZ_GPIO_USB_DEVICE | GPIO_IN);
358 /* Setup USB Port 2 Output Control Register */
359 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
361 GPSR(SPITZ_GPIO_USB_HOST) = GPIO_bit(SPITZ_GPIO_USB_HOST);
364 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
366 UHCRHDA |= UHCRHDA_NOCP;
371 static struct pxaohci_platform_data spitz_ohci_platform_data = {
372 .port_mode = PMM_NPS_MODE,
373 .init = spitz_ohci_init,
380 static void spitz_irda_transceiver_mode(struct device *dev, int mode)
383 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
385 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
388 #ifdef CONFIG_MACH_AKITA
389 static void akita_irda_transceiver_mode(struct device *dev, int mode)
392 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
394 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
398 static struct pxaficp_platform_data spitz_ficp_platform_data = {
399 .transceiver_cap = IR_SIRMODE | IR_OFF,
400 .transceiver_mode = spitz_irda_transceiver_mode,
405 * Spitz PXA Framebuffer
407 static struct pxafb_mach_info spitz_pxafb_info __initdata = {
419 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM,
420 .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH,
421 .pxafb_lcd_power = spitz_lcd_power,
425 static struct platform_device *devices[] __initdata = {
434 static void __init common_init(void)
438 /* setup sleep mode values */
446 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
449 corgi_ssp_set_machinfo(&spitz_ssp_machinfo);
451 pxa_gpio_mode(SPITZ_GPIO_HSYNC | GPIO_IN);
453 platform_add_devices(devices, ARRAY_SIZE(devices));
454 pxa_set_mci_info(&spitz_mci_platform_data);
455 pxa_set_ohci_info(&spitz_ohci_platform_data);
456 pxa_set_ficp_info(&spitz_ficp_platform_data);
457 set_pxa_fb_parent(&spitzssp_device.dev);
458 set_pxa_fb_info(&spitz_pxafb_info);
461 static void __init spitz_init(void)
463 platform_scoop_config = &spitz_pcmcia_config;
465 spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity;
469 platform_device_register(&spitzscoop2_device);
472 #ifdef CONFIG_MACH_AKITA
476 struct platform_device akitaioexp_device = {
477 .name = "akita-ioexp",
481 EXPORT_SYMBOL_GPL(akitaioexp_device);
483 static void __init akita_init(void)
485 spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
487 /* We just pretend the second element of the array doesn't exist */
488 spitz_pcmcia_config.num_devs = 1;
489 platform_scoop_config = &spitz_pcmcia_config;
490 spitz_bl_machinfo.set_bl_intensity = akita_bl_set_intensity;
492 platform_device_register(&akitaioexp_device);
494 spitzscoop_device.dev.parent = &akitaioexp_device.dev;
500 static void __init fixup_spitz(struct machine_desc *desc,
501 struct tag *tags, char **cmdline, struct meminfo *mi)
503 sharpsl_save_param();
505 mi->bank[0].start = 0xa0000000;
506 mi->bank[0].node = 0;
507 mi->bank[0].size = (64*1024*1024);
510 #ifdef CONFIG_MACH_SPITZ
511 MACHINE_START(SPITZ, "SHARP Spitz")
512 .phys_io = 0x40000000,
513 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
514 .fixup = fixup_spitz,
515 .map_io = pxa_map_io,
516 .init_irq = pxa_init_irq,
517 .init_machine = spitz_init,
522 #ifdef CONFIG_MACH_BORZOI
523 MACHINE_START(BORZOI, "SHARP Borzoi")
524 .phys_io = 0x40000000,
525 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
526 .fixup = fixup_spitz,
527 .map_io = pxa_map_io,
528 .init_irq = pxa_init_irq,
529 .init_machine = spitz_init,
534 #ifdef CONFIG_MACH_AKITA
535 MACHINE_START(AKITA, "SHARP Akita")
536 .phys_io = 0x40000000,
537 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
538 .fixup = fixup_spitz,
539 .map_io = pxa_map_io,
540 .init_irq = pxa_init_irq,
541 .init_machine = akita_init,