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 <linux/backlight.h>
26 #include <asm/setup.h>
27 #include <asm/memory.h>
28 #include <asm/mach-types.h>
29 #include <asm/hardware.h>
32 #include <asm/system.h>
34 #include <asm/mach/arch.h>
35 #include <asm/mach/map.h>
36 #include <asm/mach/irq.h>
38 #include <asm/arch/pxa-regs.h>
39 #include <asm/arch/irda.h>
40 #include <asm/arch/mmc.h>
41 #include <asm/arch/ohci.h>
42 #include <asm/arch/udc.h>
43 #include <asm/arch/pxafb.h>
44 #include <asm/arch/akita.h>
45 #include <asm/arch/spitz.h>
46 #include <asm/arch/sharpsl.h>
48 #include <asm/mach/sharpsl_param.h>
49 #include <asm/hardware/scoop.h>
56 * Spitz SCOOP Device #1
58 static struct resource spitz_scoop_resources
[] = {
62 .flags
= IORESOURCE_MEM
,
66 static struct scoop_config spitz_scoop_setup
= {
67 .io_dir
= SPITZ_SCP_IO_DIR
,
68 .io_out
= SPITZ_SCP_IO_OUT
,
69 .suspend_clr
= SPITZ_SCP_SUS_CLR
,
70 .suspend_set
= SPITZ_SCP_SUS_SET
,
73 struct platform_device spitzscoop_device
= {
74 .name
= "sharp-scoop",
77 .platform_data
= &spitz_scoop_setup
,
79 .num_resources
= ARRAY_SIZE(spitz_scoop_resources
),
80 .resource
= spitz_scoop_resources
,
84 * Spitz SCOOP Device #2
86 static struct resource spitz_scoop2_resources
[] = {
90 .flags
= IORESOURCE_MEM
,
94 static struct scoop_config spitz_scoop2_setup
= {
95 .io_dir
= SPITZ_SCP2_IO_DIR
,
96 .io_out
= SPITZ_SCP2_IO_OUT
,
97 .suspend_clr
= SPITZ_SCP2_SUS_CLR
,
98 .suspend_set
= SPITZ_SCP2_SUS_SET
,
101 struct platform_device spitzscoop2_device
= {
102 .name
= "sharp-scoop",
105 .platform_data
= &spitz_scoop2_setup
,
107 .num_resources
= ARRAY_SIZE(spitz_scoop2_resources
),
108 .resource
= spitz_scoop2_resources
,
111 #define SPITZ_PWR_SD 0x01
112 #define SPITZ_PWR_CF 0x02
114 /* Power control is shared with between one of the CF slots and SD */
115 static void spitz_card_pwr_ctrl(int device
, unsigned short new_cpr
)
117 unsigned short cpr
= read_scoop_reg(&spitzscoop_device
.dev
, SCOOP_CPR
);
119 if (new_cpr
& 0x0007) {
120 set_scoop_gpio(&spitzscoop_device
.dev
, SPITZ_SCP_CF_POWER
);
121 if (!(cpr
& 0x0002) && !(cpr
& 0x0004))
123 if (device
== SPITZ_PWR_CF
)
125 if (device
== SPITZ_PWR_SD
)
127 write_scoop_reg(&spitzscoop_device
.dev
, SCOOP_CPR
, cpr
| new_cpr
);
129 if (device
== SPITZ_PWR_CF
)
131 if (device
== SPITZ_PWR_SD
)
133 if (!(cpr
& 0x0002) && !(cpr
& 0x0004)) {
134 write_scoop_reg(&spitzscoop_device
.dev
, SCOOP_CPR
, 0x0000);
136 reset_scoop_gpio(&spitzscoop_device
.dev
, SPITZ_SCP_CF_POWER
);
138 write_scoop_reg(&spitzscoop_device
.dev
, SCOOP_CPR
, cpr
| new_cpr
);
143 static void spitz_pcmcia_init(void)
145 /* Setup default state of GPIO outputs
146 before we enable them as outputs. */
147 GPSR(GPIO48_nPOE
) = GPIO_bit(GPIO48_nPOE
) |
148 GPIO_bit(GPIO49_nPWE
) | GPIO_bit(GPIO50_nPIOR
) |
149 GPIO_bit(GPIO51_nPIOW
) | GPIO_bit(GPIO54_nPCE_2
);
150 GPSR(GPIO85_nPCE_1
) = GPIO_bit(GPIO85_nPCE_1
);
152 pxa_gpio_mode(GPIO48_nPOE_MD
);
153 pxa_gpio_mode(GPIO49_nPWE_MD
);
154 pxa_gpio_mode(GPIO50_nPIOR_MD
);
155 pxa_gpio_mode(GPIO51_nPIOW_MD
);
156 pxa_gpio_mode(GPIO55_nPREG_MD
);
157 pxa_gpio_mode(GPIO56_nPWAIT_MD
);
158 pxa_gpio_mode(GPIO57_nIOIS16_MD
);
159 pxa_gpio_mode(GPIO85_nPCE_1_MD
);
160 pxa_gpio_mode(GPIO54_nPCE_2_MD
);
161 pxa_gpio_mode(GPIO104_pSKTSEL_MD
);
164 static void spitz_pcmcia_pwr(struct device
*scoop
, unsigned short cpr
, int nr
)
166 /* Only need to override behaviour for slot 0 */
168 spitz_card_pwr_ctrl(SPITZ_PWR_CF
, cpr
);
170 write_scoop_reg(scoop
, SCOOP_CPR
, cpr
);
173 static struct scoop_pcmcia_dev spitz_pcmcia_scoop
[] = {
175 .dev
= &spitzscoop_device
.dev
,
176 .irq
= SPITZ_IRQ_GPIO_CF_IRQ
,
177 .cd_irq
= SPITZ_IRQ_GPIO_CF_CD
,
178 .cd_irq_str
= "PCMCIA0 CD",
180 .dev
= &spitzscoop2_device
.dev
,
181 .irq
= SPITZ_IRQ_GPIO_CF2_IRQ
,
186 static struct scoop_pcmcia_config spitz_pcmcia_config
= {
187 .devs
= &spitz_pcmcia_scoop
[0],
189 .pcmcia_init
= spitz_pcmcia_init
,
190 .power_ctrl
= spitz_pcmcia_pwr
,
193 EXPORT_SYMBOL(spitzscoop_device
);
194 EXPORT_SYMBOL(spitzscoop2_device
);
200 * Set the parent as the scoop device because a lot of SSP devices
201 * also use scoop functions and this makes the power up/down order
204 struct platform_device spitzssp_device
= {
207 .parent
= &spitzscoop_device
.dev
,
212 struct corgissp_machinfo spitz_ssp_machinfo
= {
214 .cs_lcdcon
= SPITZ_GPIO_LCDCON_CS
,
215 .cs_ads7846
= SPITZ_GPIO_ADS7846_CS
,
216 .cs_max1111
= SPITZ_GPIO_MAX1111_CS
,
224 * Spitz Backlight Device
226 static void spitz_bl_kick_battery(void)
228 void (*kick_batt
)(void);
230 kick_batt
= symbol_get(sharpsl_battery_kick
);
233 symbol_put(sharpsl_battery_kick
);
237 static struct generic_bl_info spitz_bl_machinfo
= {
239 .default_intensity
= 0x1f,
241 .max_intensity
= 0x2f,
242 .kick_battery
= spitz_bl_kick_battery
,
245 static struct platform_device spitzbl_device
= {
246 .name
= "generic-bl",
248 .platform_data
= &spitz_bl_machinfo
,
255 * Spitz Keyboard Device
257 static struct platform_device spitzkbd_device
= {
258 .name
= "spitz-keyboard",
266 static struct platform_device spitzled_device
= {
272 * Spitz Touch Screen Device
274 static struct resource spitzts_resources
[] = {
276 .start
= SPITZ_IRQ_GPIO_TP_INT
,
277 .end
= SPITZ_IRQ_GPIO_TP_INT
,
278 .flags
= IORESOURCE_IRQ
,
282 static struct corgits_machinfo spitz_ts_machinfo
= {
283 .get_hsync_len
= spitz_get_hsync_len
,
284 .put_hsync
= spitz_put_hsync
,
285 .wait_hsync
= spitz_wait_hsync
,
288 static struct platform_device spitzts_device
= {
291 .parent
= &spitzssp_device
.dev
,
292 .platform_data
= &spitz_ts_machinfo
,
295 .num_resources
= ARRAY_SIZE(spitzts_resources
),
296 .resource
= spitzts_resources
,
303 * The card detect interrupt isn't debounced so we delay it by 250ms
304 * to give the card a chance to fully insert/eject.
307 static struct pxamci_platform_data spitz_mci_platform_data
;
309 static int spitz_mci_init(struct device
*dev
, irq_handler_t spitz_detect_int
, void *data
)
313 /* setup GPIO for PXA27x MMC controller */
314 pxa_gpio_mode(GPIO32_MMCCLK_MD
);
315 pxa_gpio_mode(GPIO112_MMCCMD_MD
);
316 pxa_gpio_mode(GPIO92_MMCDAT0_MD
);
317 pxa_gpio_mode(GPIO109_MMCDAT1_MD
);
318 pxa_gpio_mode(GPIO110_MMCDAT2_MD
);
319 pxa_gpio_mode(GPIO111_MMCDAT3_MD
);
320 pxa_gpio_mode(SPITZ_GPIO_nSD_DETECT
| GPIO_IN
);
321 pxa_gpio_mode(SPITZ_GPIO_nSD_WP
| GPIO_IN
);
323 spitz_mci_platform_data
.detect_delay
= msecs_to_jiffies(250);
325 err
= request_irq(SPITZ_IRQ_GPIO_nSD_DETECT
, spitz_detect_int
,
326 IRQF_DISABLED
| IRQF_TRIGGER_RISING
| IRQF_TRIGGER_FALLING
,
327 "MMC card detect", data
);
329 printk(KERN_ERR
"spitz_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
336 static void spitz_mci_setpower(struct device
*dev
, unsigned int vdd
)
338 struct pxamci_platform_data
* p_d
= dev
->platform_data
;
340 if (( 1 << vdd
) & p_d
->ocr_mask
)
341 spitz_card_pwr_ctrl(SPITZ_PWR_SD
, 0x0004);
343 spitz_card_pwr_ctrl(SPITZ_PWR_SD
, 0x0000);
346 static int spitz_mci_get_ro(struct device
*dev
)
348 return GPLR(SPITZ_GPIO_nSD_WP
) & GPIO_bit(SPITZ_GPIO_nSD_WP
);
351 static void spitz_mci_exit(struct device
*dev
, void *data
)
353 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT
, data
);
356 static struct pxamci_platform_data spitz_mci_platform_data
= {
357 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
358 .init
= spitz_mci_init
,
359 .get_ro
= spitz_mci_get_ro
,
360 .setpower
= spitz_mci_setpower
,
361 .exit
= spitz_mci_exit
,
368 static int spitz_ohci_init(struct device
*dev
)
370 /* Only Port 2 is connected */
371 pxa_gpio_mode(SPITZ_GPIO_USB_CONNECT
| GPIO_IN
);
372 pxa_gpio_mode(SPITZ_GPIO_USB_HOST
| GPIO_OUT
);
373 pxa_gpio_mode(SPITZ_GPIO_USB_DEVICE
| GPIO_IN
);
375 /* Setup USB Port 2 Output Control Register */
376 UP2OCR
= UP2OCR_HXS
| UP2OCR_HXOE
| UP2OCR_DPPDE
| UP2OCR_DMPDE
;
378 GPSR(SPITZ_GPIO_USB_HOST
) = GPIO_bit(SPITZ_GPIO_USB_HOST
);
381 ~(UHCHR_SSEP1
| UHCHR_SSEP2
| UHCHR_SSEP3
| UHCHR_SSE
);
383 UHCRHDA
|= UHCRHDA_NOCP
;
388 static struct pxaohci_platform_data spitz_ohci_platform_data
= {
389 .port_mode
= PMM_NPS_MODE
,
390 .init
= spitz_ohci_init
,
398 static void spitz_irda_transceiver_mode(struct device
*dev
, int mode
)
401 set_scoop_gpio(&spitzscoop2_device
.dev
, SPITZ_SCP2_IR_ON
);
403 reset_scoop_gpio(&spitzscoop2_device
.dev
, SPITZ_SCP2_IR_ON
);
406 #ifdef CONFIG_MACH_AKITA
407 static void akita_irda_transceiver_mode(struct device
*dev
, int mode
)
410 akita_set_ioexp(&akitaioexp_device
.dev
, AKITA_IOEXP_IR_ON
);
412 akita_reset_ioexp(&akitaioexp_device
.dev
, AKITA_IOEXP_IR_ON
);
416 static struct pxaficp_platform_data spitz_ficp_platform_data
= {
417 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
418 .transceiver_mode
= spitz_irda_transceiver_mode
,
423 * Spitz PXA Framebuffer
426 static struct pxafb_mode_info spitz_pxafb_modes
[] = {
454 static struct pxafb_mach_info spitz_pxafb_info
= {
455 .modes
= &spitz_pxafb_modes
[0],
458 .lccr0
= LCCR0_Color
| LCCR0_Sngl
| LCCR0_Act
| LCCR0_LDDALT
| LCCR0_OUC
| LCCR0_CMDIM
| LCCR0_RDSTM
,
459 .lccr3
= LCCR3_PixRsEdg
| LCCR3_OutEnH
,
460 .pxafb_lcd_power
= spitz_lcd_power
,
464 static struct platform_device
*devices
[] __initdata
= {
473 static void spitz_poweroff(void)
475 RCSR
= RCSR_HWR
| RCSR_WDR
| RCSR_SMR
| RCSR_GPR
;
477 pxa_gpio_mode(SPITZ_GPIO_ON_RESET
| GPIO_OUT
);
478 GPSR(SPITZ_GPIO_ON_RESET
) = GPIO_bit(SPITZ_GPIO_ON_RESET
);
481 arm_machine_restart('h');
484 static void spitz_restart(char mode
)
486 /* Bootloader magic for a reboot */
487 if((MSC0
& 0xffff0000) == 0x7ff00000)
488 MSC0
= (MSC0
& 0xffff) | 0x7ee00000;
493 static void __init
common_init(void)
495 pm_power_off
= spitz_poweroff
;
496 arm_pm_restart
= spitz_restart
;
500 /* setup sleep mode values */
508 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
511 corgi_ssp_set_machinfo(&spitz_ssp_machinfo
);
513 pxa_gpio_mode(SPITZ_GPIO_HSYNC
| GPIO_IN
);
515 platform_add_devices(devices
, ARRAY_SIZE(devices
));
516 pxa_set_mci_info(&spitz_mci_platform_data
);
517 pxa_set_ohci_info(&spitz_ohci_platform_data
);
518 pxa_set_ficp_info(&spitz_ficp_platform_data
);
519 set_pxa_fb_parent(&spitzssp_device
.dev
);
520 set_pxa_fb_info(&spitz_pxafb_info
);
523 static void __init
spitz_init(void)
525 platform_scoop_config
= &spitz_pcmcia_config
;
527 spitz_bl_machinfo
.set_bl_intensity
= spitz_bl_set_intensity
;
531 platform_device_register(&spitzscoop2_device
);
534 #ifdef CONFIG_MACH_AKITA
538 struct platform_device akitaioexp_device
= {
539 .name
= "akita-ioexp",
543 EXPORT_SYMBOL_GPL(akitaioexp_device
);
545 static void __init
akita_init(void)
547 spitz_ficp_platform_data
.transceiver_mode
= akita_irda_transceiver_mode
;
549 /* We just pretend the second element of the array doesn't exist */
550 spitz_pcmcia_config
.num_devs
= 1;
551 platform_scoop_config
= &spitz_pcmcia_config
;
552 spitz_bl_machinfo
.set_bl_intensity
= akita_bl_set_intensity
;
554 platform_device_register(&akitaioexp_device
);
556 spitzscoop_device
.dev
.parent
= &akitaioexp_device
.dev
;
562 static void __init
fixup_spitz(struct machine_desc
*desc
,
563 struct tag
*tags
, char **cmdline
, struct meminfo
*mi
)
565 sharpsl_save_param();
567 mi
->bank
[0].start
= 0xa0000000;
568 mi
->bank
[0].node
= 0;
569 mi
->bank
[0].size
= (64*1024*1024);
572 #ifdef CONFIG_MACH_SPITZ
573 MACHINE_START(SPITZ
, "SHARP Spitz")
574 .phys_io
= 0x40000000,
575 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
576 .fixup
= fixup_spitz
,
577 .map_io
= pxa_map_io
,
578 .init_irq
= pxa27x_init_irq
,
579 .init_machine
= spitz_init
,
584 #ifdef CONFIG_MACH_BORZOI
585 MACHINE_START(BORZOI
, "SHARP Borzoi")
586 .phys_io
= 0x40000000,
587 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
588 .fixup
= fixup_spitz
,
589 .map_io
= pxa_map_io
,
590 .init_irq
= pxa27x_init_irq
,
591 .init_machine
= spitz_init
,
596 #ifdef CONFIG_MACH_AKITA
597 MACHINE_START(AKITA
, "SHARP Akita")
598 .phys_io
= 0x40000000,
599 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
600 .fixup
= fixup_spitz
,
601 .map_io
= pxa_map_io
,
602 .init_irq
= pxa27x_init_irq
,
603 .init_machine
= akita_init
,