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/gpio.h>
23 #include <linux/leds.h>
24 #include <linux/mmc/host.h>
25 #include <linux/mtd/physmap.h>
27 #include <linux/backlight.h>
29 #include <linux/i2c.h>
30 #include <linux/i2c/pca953x.h>
31 #include <linux/spi/spi.h>
32 #include <linux/spi/ads7846.h>
33 #include <linux/spi/corgi_lcd.h>
35 #include <asm/setup.h>
36 #include <asm/memory.h>
37 #include <asm/mach-types.h>
38 #include <mach/hardware.h>
40 #include <asm/system.h>
42 #include <asm/mach/arch.h>
43 #include <asm/mach/map.h>
44 #include <asm/mach/irq.h>
46 #include <mach/pxa-regs.h>
47 #include <mach/pxa2xx-regs.h>
48 #include <mach/mfp-pxa27x.h>
49 #include <mach/pxa27x-udc.h>
50 #include <mach/reset.h>
52 #include <mach/irda.h>
54 #include <mach/ohci.h>
56 #include <mach/pxafb.h>
57 #include <mach/pxa2xx_spi.h>
58 #include <mach/spitz.h>
59 #include <mach/sharpsl.h>
61 #include <asm/mach/sharpsl_param.h>
62 #include <asm/hardware/scoop.h>
68 static unsigned long spitz_pin_config
[] __initdata
= {
70 GPIO78_nCS_2
, /* SCOOP #2 */
71 GPIO79_nCS_3
, /* NAND */
72 GPIO80_nCS_4
, /* SCOOP #1 */
74 /* LCD - 16bpp Active TFT */
116 GPIO9_GPIO
, /* SPITZ_GPIO_nSD_DETECT */
117 GPIO81_GPIO
, /* SPITZ_GPIO_nSD_WP */
118 GPIO41_GPIO
, /* SPITZ_GPIO_USB_CONNECT */
119 GPIO37_GPIO
, /* SPITZ_GPIO_USB_HOST */
120 GPIO35_GPIO
, /* SPITZ_GPIO_USB_DEVICE */
121 GPIO22_GPIO
, /* SPITZ_GPIO_HSYNC */
122 GPIO94_GPIO
, /* SPITZ_GPIO_CF_CD */
123 GPIO105_GPIO
, /* SPITZ_GPIO_CF_IRQ */
124 GPIO106_GPIO
, /* SPITZ_GPIO_CF2_IRQ */
130 GPIO1_GPIO
| WAKEUP_ON_EDGE_RISE
,
134 * Spitz SCOOP Device #1
136 static struct resource spitz_scoop_resources
[] = {
140 .flags
= IORESOURCE_MEM
,
144 static struct scoop_config spitz_scoop_setup
= {
145 .io_dir
= SPITZ_SCP_IO_DIR
,
146 .io_out
= SPITZ_SCP_IO_OUT
,
147 .suspend_clr
= SPITZ_SCP_SUS_CLR
,
148 .suspend_set
= SPITZ_SCP_SUS_SET
,
149 .gpio_base
= SPITZ_SCP_GPIO_BASE
,
152 struct platform_device spitzscoop_device
= {
153 .name
= "sharp-scoop",
156 .platform_data
= &spitz_scoop_setup
,
158 .num_resources
= ARRAY_SIZE(spitz_scoop_resources
),
159 .resource
= spitz_scoop_resources
,
163 * Spitz SCOOP Device #2
165 static struct resource spitz_scoop2_resources
[] = {
169 .flags
= IORESOURCE_MEM
,
173 static struct scoop_config spitz_scoop2_setup
= {
174 .io_dir
= SPITZ_SCP2_IO_DIR
,
175 .io_out
= SPITZ_SCP2_IO_OUT
,
176 .suspend_clr
= SPITZ_SCP2_SUS_CLR
,
177 .suspend_set
= SPITZ_SCP2_SUS_SET
,
178 .gpio_base
= SPITZ_SCP2_GPIO_BASE
,
181 struct platform_device spitzscoop2_device
= {
182 .name
= "sharp-scoop",
185 .platform_data
= &spitz_scoop2_setup
,
187 .num_resources
= ARRAY_SIZE(spitz_scoop2_resources
),
188 .resource
= spitz_scoop2_resources
,
191 #define SPITZ_PWR_SD 0x01
192 #define SPITZ_PWR_CF 0x02
194 /* Power control is shared with between one of the CF slots and SD */
195 static void spitz_card_pwr_ctrl(int device
, unsigned short new_cpr
)
197 unsigned short cpr
= read_scoop_reg(&spitzscoop_device
.dev
, SCOOP_CPR
);
199 if (new_cpr
& 0x0007) {
200 gpio_set_value(SPITZ_GPIO_CF_POWER
, 1);
201 if (!(cpr
& 0x0002) && !(cpr
& 0x0004))
203 if (device
== SPITZ_PWR_CF
)
205 if (device
== SPITZ_PWR_SD
)
207 write_scoop_reg(&spitzscoop_device
.dev
, SCOOP_CPR
, cpr
| new_cpr
);
209 if (device
== SPITZ_PWR_CF
)
211 if (device
== SPITZ_PWR_SD
)
213 if (!(cpr
& 0x0002) && !(cpr
& 0x0004)) {
214 write_scoop_reg(&spitzscoop_device
.dev
, SCOOP_CPR
, 0x0000);
216 gpio_set_value(SPITZ_GPIO_CF_POWER
, 0);
218 write_scoop_reg(&spitzscoop_device
.dev
, SCOOP_CPR
, cpr
| new_cpr
);
223 static void spitz_pcmcia_pwr(struct device
*scoop
, unsigned short cpr
, int nr
)
225 /* Only need to override behaviour for slot 0 */
227 spitz_card_pwr_ctrl(SPITZ_PWR_CF
, cpr
);
229 write_scoop_reg(scoop
, SCOOP_CPR
, cpr
);
232 static struct scoop_pcmcia_dev spitz_pcmcia_scoop
[] = {
234 .dev
= &spitzscoop_device
.dev
,
235 .irq
= SPITZ_IRQ_GPIO_CF_IRQ
,
236 .cd_irq
= SPITZ_IRQ_GPIO_CF_CD
,
237 .cd_irq_str
= "PCMCIA0 CD",
239 .dev
= &spitzscoop2_device
.dev
,
240 .irq
= SPITZ_IRQ_GPIO_CF2_IRQ
,
245 static struct scoop_pcmcia_config spitz_pcmcia_config
= {
246 .devs
= &spitz_pcmcia_scoop
[0],
248 .power_ctrl
= spitz_pcmcia_pwr
,
251 EXPORT_SYMBOL(spitzscoop_device
);
252 EXPORT_SYMBOL(spitzscoop2_device
);
255 * Spitz Keyboard Device
257 static struct platform_device spitzkbd_device
= {
258 .name
= "spitz-keyboard",
266 static struct gpio_led spitz_gpio_leds
[] = {
268 .name
= "spitz:amber:charge",
269 .default_trigger
= "sharpsl-charge",
270 .gpio
= SPITZ_GPIO_LED_ORANGE
,
273 .name
= "spitz:green:hddactivity",
274 .default_trigger
= "ide-disk",
275 .gpio
= SPITZ_GPIO_LED_GREEN
,
279 static struct gpio_led_platform_data spitz_gpio_leds_info
= {
280 .leds
= spitz_gpio_leds
,
281 .num_leds
= ARRAY_SIZE(spitz_gpio_leds
),
284 static struct platform_device spitzled_device
= {
288 .platform_data
= &spitz_gpio_leds_info
,
292 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
293 static struct pxa2xx_spi_master spitz_spi_info
= {
297 static struct ads7846_platform_data spitz_ads7846_info
= {
299 .vref_delay_usecs
= 100,
302 .gpio_pendown
= SPITZ_GPIO_TP_INT
,
305 static void spitz_ads7846_cs(u32 command
)
307 gpio_set_value(SPITZ_GPIO_ADS7846_CS
, !(command
== PXA2XX_CS_ASSERT
));
310 static struct pxa2xx_spi_chip spitz_ads7846_chip
= {
311 .cs_control
= spitz_ads7846_cs
,
314 static void spitz_bl_kick_battery(void)
316 void (*kick_batt
)(void);
318 kick_batt
= symbol_get(sharpsl_battery_kick
);
321 symbol_put(sharpsl_battery_kick
);
325 static struct corgi_lcd_platform_data spitz_lcdcon_info
= {
326 .init_mode
= CORGI_LCD_MODE_VGA
,
327 .max_intensity
= 0x2f,
328 .default_intensity
= 0x1f,
330 .gpio_backlight_cont
= SPITZ_GPIO_BACKLIGHT_CONT
,
331 .gpio_backlight_on
= SPITZ_GPIO_BACKLIGHT_ON
,
332 .kick_battery
= spitz_bl_kick_battery
,
335 static void spitz_lcdcon_cs(u32 command
)
337 gpio_set_value(SPITZ_GPIO_LCDCON_CS
, !(command
== PXA2XX_CS_ASSERT
));
340 static struct pxa2xx_spi_chip spitz_lcdcon_chip
= {
341 .cs_control
= spitz_lcdcon_cs
,
344 static void spitz_max1111_cs(u32 command
)
346 gpio_set_value(SPITZ_GPIO_MAX1111_CS
, !(command
== PXA2XX_CS_ASSERT
));
349 static struct pxa2xx_spi_chip spitz_max1111_chip
= {
350 .cs_control
= spitz_max1111_cs
,
353 static struct spi_board_info spitz_spi_devices
[] = {
355 .modalias
= "ads7846",
356 .max_speed_hz
= 1200000,
359 .platform_data
= &spitz_ads7846_info
,
360 .controller_data
= &spitz_ads7846_chip
,
361 .irq
= gpio_to_irq(SPITZ_GPIO_TP_INT
),
363 .modalias
= "corgi-lcd",
364 .max_speed_hz
= 50000,
367 .platform_data
= &spitz_lcdcon_info
,
368 .controller_data
= &spitz_lcdcon_chip
,
370 .modalias
= "max1111",
371 .max_speed_hz
= 450000,
374 .controller_data
= &spitz_max1111_chip
,
378 static void __init
spitz_init_spi(void)
382 err
= gpio_request(SPITZ_GPIO_ADS7846_CS
, "ADS7846_CS");
386 err
= gpio_request(SPITZ_GPIO_LCDCON_CS
, "LCDCON_CS");
390 err
= gpio_request(SPITZ_GPIO_MAX1111_CS
, "MAX1111_CS");
394 err
= gpio_direction_output(SPITZ_GPIO_ADS7846_CS
, 1);
397 err
= gpio_direction_output(SPITZ_GPIO_LCDCON_CS
, 1);
400 err
= gpio_direction_output(SPITZ_GPIO_MAX1111_CS
, 1);
404 if (machine_is_akita()) {
405 spitz_lcdcon_info
.gpio_backlight_cont
= AKITA_GPIO_BACKLIGHT_CONT
;
406 spitz_lcdcon_info
.gpio_backlight_on
= AKITA_GPIO_BACKLIGHT_ON
;
409 pxa2xx_set_spi_info(2, &spitz_spi_info
);
410 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices
));
414 gpio_free(SPITZ_GPIO_MAX1111_CS
);
416 gpio_free(SPITZ_GPIO_LCDCON_CS
);
418 gpio_free(SPITZ_GPIO_ADS7846_CS
);
421 static inline void spitz_init_spi(void) {}
427 * The card detect interrupt isn't debounced so we delay it by 250ms
428 * to give the card a chance to fully insert/eject.
431 static struct pxamci_platform_data spitz_mci_platform_data
;
433 static int spitz_mci_init(struct device
*dev
, irq_handler_t spitz_detect_int
, void *data
)
437 err
= gpio_request(SPITZ_GPIO_nSD_DETECT
, "nSD_DETECT");
441 err
= gpio_request(SPITZ_GPIO_nSD_WP
, "nSD_WP");
445 gpio_direction_input(SPITZ_GPIO_nSD_DETECT
);
446 gpio_direction_input(SPITZ_GPIO_nSD_WP
);
448 spitz_mci_platform_data
.detect_delay
= msecs_to_jiffies(250);
450 err
= request_irq(SPITZ_IRQ_GPIO_nSD_DETECT
, spitz_detect_int
,
451 IRQF_DISABLED
| IRQF_TRIGGER_RISING
|
452 IRQF_TRIGGER_FALLING
,
453 "MMC card detect", data
);
455 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
462 gpio_free(SPITZ_GPIO_nSD_WP
);
464 gpio_free(SPITZ_GPIO_nSD_DETECT
);
469 static void spitz_mci_setpower(struct device
*dev
, unsigned int vdd
)
471 struct pxamci_platform_data
* p_d
= dev
->platform_data
;
473 if (( 1 << vdd
) & p_d
->ocr_mask
)
474 spitz_card_pwr_ctrl(SPITZ_PWR_SD
, 0x0004);
476 spitz_card_pwr_ctrl(SPITZ_PWR_SD
, 0x0000);
479 static int spitz_mci_get_ro(struct device
*dev
)
481 return gpio_get_value(SPITZ_GPIO_nSD_WP
);
484 static void spitz_mci_exit(struct device
*dev
, void *data
)
486 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT
, data
);
487 gpio_free(SPITZ_GPIO_nSD_WP
);
488 gpio_free(SPITZ_GPIO_nSD_DETECT
);
491 static struct pxamci_platform_data spitz_mci_platform_data
= {
492 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
493 .init
= spitz_mci_init
,
494 .get_ro
= spitz_mci_get_ro
,
495 .setpower
= spitz_mci_setpower
,
496 .exit
= spitz_mci_exit
,
503 static int spitz_ohci_init(struct device
*dev
)
507 err
= gpio_request(SPITZ_GPIO_USB_HOST
, "USB_HOST");
511 /* Only Port 2 is connected
512 * Setup USB Port 2 Output Control Register
514 UP2OCR
= UP2OCR_HXS
| UP2OCR_HXOE
| UP2OCR_DPPDE
| UP2OCR_DMPDE
;
516 return gpio_direction_output(SPITZ_GPIO_USB_HOST
, 1);
519 static struct pxaohci_platform_data spitz_ohci_platform_data
= {
520 .port_mode
= PMM_NPS_MODE
,
521 .init
= spitz_ohci_init
,
522 .flags
= ENABLE_PORT_ALL
| NO_OC_PROTECTION
,
530 static int spitz_irda_startup(struct device
*dev
)
534 rc
= gpio_request(SPITZ_GPIO_IR_ON
, "IrDA on");
538 rc
= gpio_direction_output(SPITZ_GPIO_IR_ON
, 1);
545 gpio_free(SPITZ_GPIO_IR_ON
);
550 static void spitz_irda_shutdown(struct device
*dev
)
552 gpio_free(SPITZ_GPIO_IR_ON
);
555 static void spitz_irda_transceiver_mode(struct device
*dev
, int mode
)
557 gpio_set_value(SPITZ_GPIO_IR_ON
, mode
& IR_OFF
);
558 pxa2xx_transceiver_mode(dev
, mode
);
561 #ifdef CONFIG_MACH_AKITA
562 static void akita_irda_transceiver_mode(struct device
*dev
, int mode
)
564 gpio_set_value(AKITA_GPIO_IR_ON
, mode
& IR_OFF
);
565 pxa2xx_transceiver_mode(dev
, mode
);
569 static struct pxaficp_platform_data spitz_ficp_platform_data
= {
570 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
571 .transceiver_mode
= spitz_irda_transceiver_mode
,
572 .startup
= spitz_irda_startup
,
573 .shutdown
= spitz_irda_shutdown
,
578 * Spitz PXA Framebuffer
581 static struct pxafb_mode_info spitz_pxafb_modes
[] = {
609 static struct pxafb_mach_info spitz_pxafb_info
= {
610 .modes
= &spitz_pxafb_modes
[0],
613 .lcd_conn
= LCD_COLOR_TFT_16BPP
| LCD_ALTERNATE_MAPPING
,
617 static struct mtd_partition sharpsl_rom_parts
[] = {
619 .name
="Boot PROM Filesystem",
620 .offset
= 0x00140000,
621 .size
= MTDPART_SIZ_FULL
,
625 static struct physmap_flash_data sharpsl_rom_data
= {
627 .nr_parts
= ARRAY_SIZE(sharpsl_rom_parts
),
628 .parts
= sharpsl_rom_parts
,
631 static struct resource sharpsl_rom_resources
[] = {
635 .flags
= IORESOURCE_MEM
,
639 static struct platform_device sharpsl_rom_device
= {
640 .name
= "physmap-flash",
642 .resource
= sharpsl_rom_resources
,
643 .num_resources
= ARRAY_SIZE(sharpsl_rom_resources
),
644 .dev
.platform_data
= &sharpsl_rom_data
,
647 static struct platform_device
*devices
[] __initdata
= {
654 static void spitz_poweroff(void)
656 arm_machine_restart('g');
659 static void spitz_restart(char mode
)
661 /* Bootloader magic for a reboot */
662 if((MSC0
& 0xffff0000) == 0x7ff00000)
663 MSC0
= (MSC0
& 0xffff) | 0x7ee00000;
668 static void __init
common_init(void)
670 init_gpio_reset(SPITZ_GPIO_ON_RESET
, 1);
671 pm_power_off
= spitz_poweroff
;
672 arm_pm_restart
= spitz_restart
;
676 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
679 pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config
));
683 platform_add_devices(devices
, ARRAY_SIZE(devices
));
684 pxa_set_mci_info(&spitz_mci_platform_data
);
685 pxa_set_ohci_info(&spitz_ohci_platform_data
);
686 pxa_set_ficp_info(&spitz_ficp_platform_data
);
687 set_pxa_fb_info(&spitz_pxafb_info
);
688 pxa_set_i2c_info(NULL
);
691 #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
692 static void __init
spitz_init(void)
694 platform_scoop_config
= &spitz_pcmcia_config
;
698 platform_device_register(&spitzscoop2_device
);
702 #ifdef CONFIG_MACH_AKITA
706 static struct pca953x_platform_data akita_ioexp
= {
707 .gpio_base
= AKITA_IOEXP_GPIO_BASE
,
710 static struct i2c_board_info akita_i2c_board_info
[] = {
714 .platform_data
= &akita_ioexp
,
718 static void __init
akita_init(void)
720 spitz_ficp_platform_data
.transceiver_mode
= akita_irda_transceiver_mode
;
722 /* We just pretend the second element of the array doesn't exist */
723 spitz_pcmcia_config
.num_devs
= 1;
724 platform_scoop_config
= &spitz_pcmcia_config
;
726 i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info
));
732 static void __init
fixup_spitz(struct machine_desc
*desc
,
733 struct tag
*tags
, char **cmdline
, struct meminfo
*mi
)
735 sharpsl_save_param();
737 mi
->bank
[0].start
= 0xa0000000;
738 mi
->bank
[0].node
= 0;
739 mi
->bank
[0].size
= (64*1024*1024);
742 #ifdef CONFIG_MACH_SPITZ
743 MACHINE_START(SPITZ
, "SHARP Spitz")
744 .phys_io
= 0x40000000,
745 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
746 .fixup
= fixup_spitz
,
747 .map_io
= pxa_map_io
,
748 .init_irq
= pxa27x_init_irq
,
749 .init_machine
= spitz_init
,
754 #ifdef CONFIG_MACH_BORZOI
755 MACHINE_START(BORZOI
, "SHARP Borzoi")
756 .phys_io
= 0x40000000,
757 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
758 .fixup
= fixup_spitz
,
759 .map_io
= pxa_map_io
,
760 .init_irq
= pxa27x_init_irq
,
761 .init_machine
= spitz_init
,
766 #ifdef CONFIG_MACH_AKITA
767 MACHINE_START(AKITA
, "SHARP Akita")
768 .phys_io
= 0x40000000,
769 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
770 .fixup
= fixup_spitz
,
771 .map_io
= pxa_map_io
,
772 .init_irq
= pxa27x_init_irq
,
773 .init_machine
= akita_init
,