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/platform_device.h>
17 #include <linux/delay.h>
18 #include <linux/gpio.h>
19 #include <linux/leds.h>
20 #include <linux/mtd/physmap.h>
21 #include <linux/i2c.h>
22 #include <linux/i2c/pca953x.h>
23 #include <linux/spi/spi.h>
24 #include <linux/spi/ads7846.h>
25 #include <linux/spi/corgi_lcd.h>
26 #include <linux/mtd/sharpsl.h>
28 #include <asm/setup.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/sharpsl_param.h>
32 #include <asm/hardware/scoop.h>
35 #include <mach/pxa27x.h>
36 #include <mach/pxa27x-udc.h>
37 #include <mach/reset.h>
39 #include <mach/irda.h>
41 #include <mach/ohci.h>
42 #include <mach/pxafb.h>
43 #include <mach/pxa2xx_spi.h>
44 #include <mach/spitz.h>
50 static unsigned long spitz_pin_config[] __initdata = {
52 GPIO78_nCS_2, /* SCOOP #2 */
53 GPIO79_nCS_3, /* NAND */
54 GPIO80_nCS_4, /* SCOOP #1 */
56 /* LCD - 16bpp Active TFT */
90 GPIO28_I2S_BITCLK_OUT,
104 GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */
105 GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */
106 GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */
107 GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */
108 GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */
109 GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */
110 GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */
111 GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */
112 GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */
118 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
122 * Spitz SCOOP Device #1
124 static struct resource spitz_scoop_resources[] = {
128 .flags = IORESOURCE_MEM,
132 static struct scoop_config spitz_scoop_setup = {
133 .io_dir = SPITZ_SCP_IO_DIR,
134 .io_out = SPITZ_SCP_IO_OUT,
135 .suspend_clr = SPITZ_SCP_SUS_CLR,
136 .suspend_set = SPITZ_SCP_SUS_SET,
137 .gpio_base = SPITZ_SCP_GPIO_BASE,
140 struct platform_device spitzscoop_device = {
141 .name = "sharp-scoop",
144 .platform_data = &spitz_scoop_setup,
146 .num_resources = ARRAY_SIZE(spitz_scoop_resources),
147 .resource = spitz_scoop_resources,
151 * Spitz SCOOP Device #2
153 static struct resource spitz_scoop2_resources[] = {
157 .flags = IORESOURCE_MEM,
161 static struct scoop_config spitz_scoop2_setup = {
162 .io_dir = SPITZ_SCP2_IO_DIR,
163 .io_out = SPITZ_SCP2_IO_OUT,
164 .suspend_clr = SPITZ_SCP2_SUS_CLR,
165 .suspend_set = SPITZ_SCP2_SUS_SET,
166 .gpio_base = SPITZ_SCP2_GPIO_BASE,
169 struct platform_device spitzscoop2_device = {
170 .name = "sharp-scoop",
173 .platform_data = &spitz_scoop2_setup,
175 .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
176 .resource = spitz_scoop2_resources,
179 #define SPITZ_PWR_SD 0x01
180 #define SPITZ_PWR_CF 0x02
182 /* Power control is shared with between one of the CF slots and SD */
183 static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
185 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
187 if (new_cpr & 0x0007) {
188 gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
189 if (!(cpr & 0x0002) && !(cpr & 0x0004))
191 if (device == SPITZ_PWR_CF)
193 if (device == SPITZ_PWR_SD)
195 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
197 if (device == SPITZ_PWR_CF)
199 if (device == SPITZ_PWR_SD)
201 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
202 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
204 gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
206 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
211 static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
213 /* Only need to override behaviour for slot 0 */
215 spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
217 write_scoop_reg(scoop, SCOOP_CPR, cpr);
220 static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
222 .dev = &spitzscoop_device.dev,
223 .irq = SPITZ_IRQ_GPIO_CF_IRQ,
224 .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
225 .cd_irq_str = "PCMCIA0 CD",
227 .dev = &spitzscoop2_device.dev,
228 .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
233 static struct scoop_pcmcia_config spitz_pcmcia_config = {
234 .devs = &spitz_pcmcia_scoop[0],
236 .power_ctrl = spitz_pcmcia_pwr,
239 EXPORT_SYMBOL(spitzscoop_device);
240 EXPORT_SYMBOL(spitzscoop2_device);
243 * Spitz Keyboard Device
245 static struct platform_device spitzkbd_device = {
246 .name = "spitz-keyboard",
254 static struct gpio_led spitz_gpio_leds[] = {
256 .name = "spitz:amber:charge",
257 .default_trigger = "sharpsl-charge",
258 .gpio = SPITZ_GPIO_LED_ORANGE,
261 .name = "spitz:green:hddactivity",
262 .default_trigger = "ide-disk",
263 .gpio = SPITZ_GPIO_LED_GREEN,
267 static struct gpio_led_platform_data spitz_gpio_leds_info = {
268 .leds = spitz_gpio_leds,
269 .num_leds = ARRAY_SIZE(spitz_gpio_leds),
272 static struct platform_device spitzled_device = {
276 .platform_data = &spitz_gpio_leds_info,
280 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
281 static struct pxa2xx_spi_master spitz_spi_info = {
285 static void spitz_wait_for_hsync(void)
287 while (gpio_get_value(SPITZ_GPIO_HSYNC))
290 while (!gpio_get_value(SPITZ_GPIO_HSYNC))
294 static struct ads7846_platform_data spitz_ads7846_info = {
296 .vref_delay_usecs = 100,
299 .pressure_max = 1024,
300 .gpio_pendown = SPITZ_GPIO_TP_INT,
301 .wait_for_sync = spitz_wait_for_hsync,
304 static struct pxa2xx_spi_chip spitz_ads7846_chip = {
305 .gpio_cs = SPITZ_GPIO_ADS7846_CS,
308 static void spitz_bl_kick_battery(void)
310 void (*kick_batt)(void);
312 kick_batt = symbol_get(sharpsl_battery_kick);
315 symbol_put(sharpsl_battery_kick);
319 static struct corgi_lcd_platform_data spitz_lcdcon_info = {
320 .init_mode = CORGI_LCD_MODE_VGA,
321 .max_intensity = 0x2f,
322 .default_intensity = 0x1f,
324 .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT,
325 .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON,
326 .kick_battery = spitz_bl_kick_battery,
329 static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
330 .gpio_cs = SPITZ_GPIO_LCDCON_CS,
333 static struct pxa2xx_spi_chip spitz_max1111_chip = {
334 .gpio_cs = SPITZ_GPIO_MAX1111_CS,
337 static struct spi_board_info spitz_spi_devices[] = {
339 .modalias = "ads7846",
340 .max_speed_hz = 1200000,
343 .platform_data = &spitz_ads7846_info,
344 .controller_data= &spitz_ads7846_chip,
345 .irq = gpio_to_irq(SPITZ_GPIO_TP_INT),
347 .modalias = "corgi-lcd",
348 .max_speed_hz = 50000,
351 .platform_data = &spitz_lcdcon_info,
352 .controller_data= &spitz_lcdcon_chip,
354 .modalias = "max1111",
355 .max_speed_hz = 450000,
358 .controller_data= &spitz_max1111_chip,
362 static void __init spitz_init_spi(void)
364 if (machine_is_akita()) {
365 spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
366 spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
369 pxa2xx_set_spi_info(2, &spitz_spi_info);
370 spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
373 static inline void spitz_init_spi(void) {}
379 * The card detect interrupt isn't debounced so we delay it by 250ms
380 * to give the card a chance to fully insert/eject.
383 static struct pxamci_platform_data spitz_mci_platform_data;
385 static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, void *data)
389 err = gpio_request(SPITZ_GPIO_nSD_DETECT, "nSD_DETECT");
393 err = gpio_request(SPITZ_GPIO_nSD_WP, "nSD_WP");
397 gpio_direction_input(SPITZ_GPIO_nSD_DETECT);
398 gpio_direction_input(SPITZ_GPIO_nSD_WP);
400 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
402 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int,
403 IRQF_DISABLED | IRQF_TRIGGER_RISING |
404 IRQF_TRIGGER_FALLING,
405 "MMC card detect", data);
407 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
414 gpio_free(SPITZ_GPIO_nSD_WP);
416 gpio_free(SPITZ_GPIO_nSD_DETECT);
421 static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
423 struct pxamci_platform_data* p_d = dev->platform_data;
425 if (( 1 << vdd) & p_d->ocr_mask)
426 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
428 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
431 static int spitz_mci_get_ro(struct device *dev)
433 return gpio_get_value(SPITZ_GPIO_nSD_WP);
436 static void spitz_mci_exit(struct device *dev, void *data)
438 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
439 gpio_free(SPITZ_GPIO_nSD_WP);
440 gpio_free(SPITZ_GPIO_nSD_DETECT);
443 static struct pxamci_platform_data spitz_mci_platform_data = {
444 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
445 .init = spitz_mci_init,
446 .get_ro = spitz_mci_get_ro,
447 .setpower = spitz_mci_setpower,
448 .exit = spitz_mci_exit,
455 static int spitz_ohci_init(struct device *dev)
459 err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
463 /* Only Port 2 is connected
464 * Setup USB Port 2 Output Control Register
466 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
468 return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
471 static void spitz_ohci_exit(struct device *dev)
473 gpio_free(SPITZ_GPIO_USB_HOST);
476 static struct pxaohci_platform_data spitz_ohci_platform_data = {
477 .port_mode = PMM_NPS_MODE,
478 .init = spitz_ohci_init,
479 .exit = spitz_ohci_exit,
480 .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
488 static int spitz_irda_startup(struct device *dev)
492 rc = gpio_request(SPITZ_GPIO_IR_ON, "IrDA on");
496 rc = gpio_direction_output(SPITZ_GPIO_IR_ON, 1);
503 gpio_free(SPITZ_GPIO_IR_ON);
508 static void spitz_irda_shutdown(struct device *dev)
510 gpio_free(SPITZ_GPIO_IR_ON);
513 static void spitz_irda_transceiver_mode(struct device *dev, int mode)
515 gpio_set_value(SPITZ_GPIO_IR_ON, mode & IR_OFF);
516 pxa2xx_transceiver_mode(dev, mode);
519 #ifdef CONFIG_MACH_AKITA
520 static void akita_irda_transceiver_mode(struct device *dev, int mode)
522 gpio_set_value(AKITA_GPIO_IR_ON, mode & IR_OFF);
523 pxa2xx_transceiver_mode(dev, mode);
527 static struct pxaficp_platform_data spitz_ficp_platform_data = {
528 .transceiver_cap = IR_SIRMODE | IR_OFF,
529 .transceiver_mode = spitz_irda_transceiver_mode,
530 .startup = spitz_irda_startup,
531 .shutdown = spitz_irda_shutdown,
536 * Spitz PXA Framebuffer
539 static struct pxafb_mode_info spitz_pxafb_modes[] = {
567 static struct pxafb_mach_info spitz_pxafb_info = {
568 .modes = &spitz_pxafb_modes[0],
571 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
574 static struct mtd_partition sharpsl_nand_partitions[] = {
576 .name = "System Area",
578 .size = 7 * 1024 * 1024,
581 .name = "Root Filesystem",
582 .offset = 7 * 1024 * 1024,
585 .name = "Home Filesystem",
586 .offset = MTDPART_OFS_APPEND,
587 .size = MTDPART_SIZ_FULL,
591 static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
593 static struct nand_bbt_descr sharpsl_bbt = {
597 .pattern = scan_ff_pattern
600 static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
601 .badblock_pattern = &sharpsl_bbt,
602 .partitions = sharpsl_nand_partitions,
603 .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions),
606 static struct resource sharpsl_nand_resources[] = {
610 .flags = IORESOURCE_MEM,
614 static struct platform_device sharpsl_nand_device = {
615 .name = "sharpsl-nand",
617 .resource = sharpsl_nand_resources,
618 .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
619 .dev.platform_data = &sharpsl_nand_platform_data,
623 static struct mtd_partition sharpsl_rom_parts[] = {
625 .name ="Boot PROM Filesystem",
626 .offset = 0x00140000,
627 .size = MTDPART_SIZ_FULL,
631 static struct physmap_flash_data sharpsl_rom_data = {
633 .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
634 .parts = sharpsl_rom_parts,
637 static struct resource sharpsl_rom_resources[] = {
641 .flags = IORESOURCE_MEM,
645 static struct platform_device sharpsl_rom_device = {
646 .name = "physmap-flash",
648 .resource = sharpsl_rom_resources,
649 .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
650 .dev.platform_data = &sharpsl_rom_data,
653 static struct platform_device *devices[] __initdata = {
657 &sharpsl_nand_device,
661 static void spitz_poweroff(void)
663 arm_machine_restart('g', NULL);
666 static void spitz_restart(char mode, const char *cmd)
668 /* Bootloader magic for a reboot */
669 if((MSC0 & 0xffff0000) == 0x7ff00000)
670 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
675 static void __init common_init(void)
677 init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0);
678 pm_power_off = spitz_poweroff;
679 arm_pm_restart = spitz_restart;
681 if (machine_is_spitz()) {
682 sharpsl_nand_partitions[1].size = 5 * 1024 * 1024;
683 } else if (machine_is_akita()) {
684 sharpsl_nand_partitions[1].size = 58 * 1024 * 1024;
685 } else if (machine_is_borzoi()) {
686 sharpsl_nand_partitions[1].size = 32 * 1024 * 1024;
691 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
694 pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
698 platform_add_devices(devices, ARRAY_SIZE(devices));
699 pxa_set_mci_info(&spitz_mci_platform_data);
700 pxa_set_ohci_info(&spitz_ohci_platform_data);
701 pxa_set_ficp_info(&spitz_ficp_platform_data);
702 set_pxa_fb_info(&spitz_pxafb_info);
703 pxa_set_i2c_info(NULL);
706 #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
707 static void __init spitz_init(void)
709 platform_scoop_config = &spitz_pcmcia_config;
713 platform_device_register(&spitzscoop2_device);
717 #ifdef CONFIG_MACH_AKITA
721 static struct pca953x_platform_data akita_ioexp = {
722 .gpio_base = AKITA_IOEXP_GPIO_BASE,
725 static struct i2c_board_info akita_i2c_board_info[] = {
729 .platform_data = &akita_ioexp,
733 static struct nand_bbt_descr sharpsl_akita_bbt = {
737 .pattern = scan_ff_pattern
740 static struct nand_ecclayout akita_oobinfo = {
743 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11,
744 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23,
745 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37},
746 .oobfree = {{0x08, 0x09}}
749 static void __init akita_init(void)
751 spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
753 sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt;
754 sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo;
756 /* We just pretend the second element of the array doesn't exist */
757 spitz_pcmcia_config.num_devs = 1;
758 platform_scoop_config = &spitz_pcmcia_config;
760 i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
766 static void __init fixup_spitz(struct machine_desc *desc,
767 struct tag *tags, char **cmdline, struct meminfo *mi)
769 sharpsl_save_param();
771 mi->bank[0].start = 0xa0000000;
772 mi->bank[0].node = 0;
773 mi->bank[0].size = (64*1024*1024);
776 #ifdef CONFIG_MACH_SPITZ
777 MACHINE_START(SPITZ, "SHARP Spitz")
778 .phys_io = 0x40000000,
779 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
780 .fixup = fixup_spitz,
781 .map_io = pxa_map_io,
782 .init_irq = pxa27x_init_irq,
783 .init_machine = spitz_init,
788 #ifdef CONFIG_MACH_BORZOI
789 MACHINE_START(BORZOI, "SHARP Borzoi")
790 .phys_io = 0x40000000,
791 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
792 .fixup = fixup_spitz,
793 .map_io = pxa_map_io,
794 .init_irq = pxa27x_init_irq,
795 .init_machine = spitz_init,
800 #ifdef CONFIG_MACH_AKITA
801 MACHINE_START(AKITA, "SHARP Akita")
802 .phys_io = 0x40000000,
803 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
804 .fixup = fixup_spitz,
805 .map_io = pxa_map_io,
806 .init_irq = pxa27x_init_irq,
807 .init_machine = akita_init,