2 * Support for Sharp SL-C7xx PDAs
3 * Models: SL-C700 (Corgi), SL-C750 (Shepherd), SL-C760 (Husky)
5 * Copyright (c) 2004-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/major.h>
20 #include <linux/interrupt.h>
21 #include <linux/mmc/host.h>
22 #include <linux/mtd/physmap.h>
24 #include <linux/gpio.h>
25 #include <linux/backlight.h>
27 #include <linux/spi/spi.h>
28 #include <linux/spi/ads7846.h>
29 #include <linux/spi/corgi_lcd.h>
30 #include <linux/mtd/sharpsl.h>
31 #include <video/w100fb.h>
33 #include <asm/setup.h>
34 #include <asm/memory.h>
35 #include <asm/mach-types.h>
36 #include <mach/hardware.h>
38 #include <asm/system.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach/map.h>
42 #include <asm/mach/irq.h>
44 #include <mach/pxa-regs.h>
45 #include <mach/pxa2xx-regs.h>
46 #include <mach/mfp-pxa25x.h>
48 #include <mach/irda.h>
51 #include <mach/pxa2xx_spi.h>
52 #include <mach/corgi.h>
53 #include <mach/sharpsl.h>
55 #include <asm/mach/sharpsl_param.h>
56 #include <asm/hardware/scoop.h>
62 static unsigned long corgi_pin_config[] __initdata = {
63 /* Static Memory I/O */
64 GPIO78_nCS_2, /* w100fb */
65 GPIO80_nCS_4, /* scoop */
71 GPIO24_GPIO, /* CORGI_GPIO_ADS7846_CS - SFRM as chip select */
74 GPIO28_I2S_BITCLK_OUT,
109 GPIO9_GPIO, /* CORGI_GPIO_nSD_DETECT */
110 GPIO7_GPIO, /* CORGI_GPIO_nSD_WP */
111 GPIO33_GPIO, /* CORGI_GPIO_SD_PWR */
112 GPIO22_GPIO, /* CORGI_GPIO_IR_ON */
113 GPIO44_GPIO, /* CORGI_GPIO_HSYNC */
115 GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
121 static struct resource corgi_scoop_resources[] = {
125 .flags = IORESOURCE_MEM,
129 static struct scoop_config corgi_scoop_setup = {
130 .io_dir = CORGI_SCOOP_IO_DIR,
131 .io_out = CORGI_SCOOP_IO_OUT,
132 .gpio_base = CORGI_SCOOP_GPIO_BASE,
135 struct platform_device corgiscoop_device = {
136 .name = "sharp-scoop",
139 .platform_data = &corgi_scoop_setup,
141 .num_resources = ARRAY_SIZE(corgi_scoop_resources),
142 .resource = corgi_scoop_resources,
145 static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
147 .dev = &corgiscoop_device.dev,
148 .irq = CORGI_IRQ_GPIO_CF_IRQ,
149 .cd_irq = CORGI_IRQ_GPIO_CF_CD,
150 .cd_irq_str = "PCMCIA0 CD",
154 static struct scoop_pcmcia_config corgi_pcmcia_config = {
155 .devs = &corgi_pcmcia_scoop[0],
159 EXPORT_SYMBOL(corgiscoop_device);
161 static struct w100_mem_info corgi_fb_mem = {
162 .ext_cntl = 0x00040003,
163 .sdram_mode_reg = 0x00650021,
164 .ext_timing_cntl = 0x10002a4a,
165 .io_cntl = 0x7ff87012,
169 static struct w100_gen_regs corgi_fb_regs = {
170 .lcd_format = 0x00000003,
171 .lcdd_cntl1 = 0x01CC0000,
172 .lcdd_cntl2 = 0x0003FFFF,
173 .genlcd_cntl1 = 0x00FFFF0D,
174 .genlcd_cntl2 = 0x003F3003,
175 .genlcd_cntl3 = 0x000102aa,
178 static struct w100_gpio_regs corgi_fb_gpio = {
179 .init_data1 = 0x000000bf,
180 .init_data2 = 0x00000000,
181 .gpio_dir1 = 0x00000000,
182 .gpio_oe1 = 0x03c0feff,
183 .gpio_dir2 = 0x00000000,
184 .gpio_oe2 = 0x00000000,
187 static struct w100_mode corgi_fb_modes[] = {
192 .right_margin = 0x55,
193 .upper_margin = 0x03,
194 .lower_margin = 0x00,
195 .crtc_ss = 0x82360056,
196 .crtc_ls = 0xA0280000,
197 .crtc_gs = 0x80280028,
198 .crtc_vpos_gs = 0x02830002,
199 .crtc_rev = 0x00400008,
200 .crtc_dclk = 0xA0000000,
201 .crtc_gclk = 0x8015010F,
202 .crtc_goe = 0x80100110,
203 .crtc_ps1_active = 0x41060010,
205 .fast_pll_freq = 100,
206 .sysclk_src = CLK_SRC_PLL,
208 .pixclk_src = CLK_SRC_PLL,
210 .pixclk_divider_rotated = 6,
215 .right_margin = 0x2e,
216 .upper_margin = 0x01,
217 .lower_margin = 0x00,
218 .crtc_ss = 0x81170027,
219 .crtc_ls = 0xA0140000,
220 .crtc_gs = 0xC0140014,
221 .crtc_vpos_gs = 0x00010141,
222 .crtc_rev = 0x00400008,
223 .crtc_dclk = 0xA0000000,
224 .crtc_gclk = 0x8015010F,
225 .crtc_goe = 0x80100110,
226 .crtc_ps1_active = 0x41060010,
229 .sysclk_src = CLK_SRC_XTAL,
231 .pixclk_src = CLK_SRC_XTAL,
233 .pixclk_divider_rotated = 1,
238 static struct w100fb_mach_info corgi_fb_info = {
239 .init_mode = INIT_MODE_ROTATED,
240 .mem = &corgi_fb_mem,
241 .regs = &corgi_fb_regs,
242 .modelist = &corgi_fb_modes[0],
244 .gpio = &corgi_fb_gpio,
245 .xtal_freq = 12500000,
249 static struct resource corgi_fb_resources[] = {
253 .flags = IORESOURCE_MEM,
257 static struct platform_device corgifb_device = {
260 .num_resources = ARRAY_SIZE(corgi_fb_resources),
261 .resource = corgi_fb_resources,
263 .platform_data = &corgi_fb_info,
269 * Corgi Keyboard Device
271 static struct platform_device corgikbd_device = {
272 .name = "corgi-keyboard",
279 static struct gpio_led corgi_gpio_leds[] = {
281 .name = "corgi:amber:charge",
282 .default_trigger = "sharpsl-charge",
283 .gpio = CORGI_GPIO_LED_ORANGE,
286 .name = "corgi:green:mail",
287 .default_trigger = "nand-disk",
288 .gpio = CORGI_GPIO_LED_GREEN,
292 static struct gpio_led_platform_data corgi_gpio_leds_info = {
293 .leds = corgi_gpio_leds,
294 .num_leds = ARRAY_SIZE(corgi_gpio_leds),
297 static struct platform_device corgiled_device = {
301 .platform_data = &corgi_gpio_leds_info,
308 * The card detect interrupt isn't debounced so we delay it by 250ms
309 * to give the card a chance to fully insert/eject.
311 static struct pxamci_platform_data corgi_mci_platform_data;
313 static int corgi_mci_init(struct device *dev, irq_handler_t corgi_detect_int, void *data)
317 err = gpio_request(CORGI_GPIO_nSD_DETECT, "nSD_DETECT");
321 err = gpio_request(CORGI_GPIO_nSD_WP, "nSD_WP");
325 err = gpio_request(CORGI_GPIO_SD_PWR, "SD_PWR");
329 gpio_direction_input(CORGI_GPIO_nSD_DETECT);
330 gpio_direction_input(CORGI_GPIO_nSD_WP);
331 gpio_direction_output(CORGI_GPIO_SD_PWR, 0);
333 corgi_mci_platform_data.detect_delay = msecs_to_jiffies(250);
335 err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_detect_int,
336 IRQF_DISABLED | IRQF_TRIGGER_RISING |
337 IRQF_TRIGGER_FALLING,
338 "MMC card detect", data);
340 pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
347 gpio_free(CORGI_GPIO_SD_PWR);
349 gpio_free(CORGI_GPIO_nSD_WP);
351 gpio_free(CORGI_GPIO_nSD_DETECT);
356 static void corgi_mci_setpower(struct device *dev, unsigned int vdd)
358 struct pxamci_platform_data* p_d = dev->platform_data;
360 gpio_set_value(CORGI_GPIO_SD_PWR, ((1 << vdd) & p_d->ocr_mask));
363 static int corgi_mci_get_ro(struct device *dev)
365 return gpio_get_value(CORGI_GPIO_nSD_WP);
368 static void corgi_mci_exit(struct device *dev, void *data)
370 free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data);
371 gpio_free(CORGI_GPIO_SD_PWR);
372 gpio_free(CORGI_GPIO_nSD_WP);
373 gpio_free(CORGI_GPIO_nSD_DETECT);
376 static struct pxamci_platform_data corgi_mci_platform_data = {
377 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
378 .init = corgi_mci_init,
379 .get_ro = corgi_mci_get_ro,
380 .setpower = corgi_mci_setpower,
381 .exit = corgi_mci_exit,
388 static void corgi_irda_transceiver_mode(struct device *dev, int mode)
390 gpio_set_value(CORGI_GPIO_IR_ON, mode & IR_OFF);
391 pxa2xx_transceiver_mode(dev, mode);
394 static int corgi_irda_startup(struct device *dev)
398 err = gpio_request(CORGI_GPIO_IR_ON, "IR_ON");
402 gpio_direction_output(CORGI_GPIO_IR_ON, 1);
406 static void corgi_irda_shutdown(struct device *dev)
408 gpio_free(CORGI_GPIO_IR_ON);
411 static struct pxaficp_platform_data corgi_ficp_platform_data = {
412 .transceiver_cap = IR_SIRMODE | IR_OFF,
413 .transceiver_mode = corgi_irda_transceiver_mode,
414 .startup = corgi_irda_startup,
415 .shutdown = corgi_irda_shutdown,
420 * USB Device Controller
422 static struct pxa2xx_udc_mach_info udc_info __initdata = {
423 /* no connect GPIO; corgi can't tell connection status */
424 .gpio_pullup = CORGI_GPIO_USB_PULLUP,
427 #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MASTER)
428 static struct pxa2xx_spi_master corgi_spi_info = {
432 static struct ads7846_platform_data corgi_ads7846_info = {
434 .vref_delay_usecs = 100,
437 .gpio_pendown = CORGI_GPIO_TP_INT,
440 static void corgi_ads7846_cs(u32 command)
442 gpio_set_value(CORGI_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT));
445 static struct pxa2xx_spi_chip corgi_ads7846_chip = {
446 .cs_control = corgi_ads7846_cs,
449 static void corgi_bl_kick_battery(void)
451 void (*kick_batt)(void);
453 kick_batt = symbol_get(sharpsl_battery_kick);
456 symbol_put(sharpsl_battery_kick);
460 static struct corgi_lcd_platform_data corgi_lcdcon_info = {
461 .init_mode = CORGI_LCD_MODE_VGA,
462 .max_intensity = 0x2f,
463 .default_intensity = 0x1f,
465 .gpio_backlight_cont = CORGI_GPIO_BACKLIGHT_CONT,
466 .gpio_backlight_on = -1,
467 .kick_battery = corgi_bl_kick_battery,
470 static void corgi_lcdcon_cs(u32 command)
472 gpio_set_value(CORGI_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT));
475 static struct pxa2xx_spi_chip corgi_lcdcon_chip = {
476 .cs_control = corgi_lcdcon_cs,
479 static void corgi_max1111_cs(u32 command)
481 gpio_set_value(CORGI_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT));
484 static struct pxa2xx_spi_chip corgi_max1111_chip = {
485 .cs_control = corgi_max1111_cs,
488 static struct spi_board_info corgi_spi_devices[] = {
490 .modalias = "ads7846",
491 .max_speed_hz = 1200000,
494 .platform_data = &corgi_ads7846_info,
495 .controller_data= &corgi_ads7846_chip,
496 .irq = gpio_to_irq(CORGI_GPIO_TP_INT),
498 .modalias = "corgi-lcd",
499 .max_speed_hz = 50000,
502 .platform_data = &corgi_lcdcon_info,
503 .controller_data= &corgi_lcdcon_chip,
505 .modalias = "max1111",
506 .max_speed_hz = 450000,
509 .controller_data= &corgi_max1111_chip,
513 static void __init corgi_init_spi(void)
517 err = gpio_request(CORGI_GPIO_ADS7846_CS, "ADS7846_CS");
521 err = gpio_request(CORGI_GPIO_LCDCON_CS, "LCDCON_CS");
525 err = gpio_request(CORGI_GPIO_MAX1111_CS, "MAX1111_CS");
529 gpio_direction_output(CORGI_GPIO_ADS7846_CS, 1);
530 gpio_direction_output(CORGI_GPIO_LCDCON_CS, 1);
531 gpio_direction_output(CORGI_GPIO_MAX1111_CS, 1);
533 pxa2xx_set_spi_info(1, &corgi_spi_info);
534 spi_register_board_info(ARRAY_AND_SIZE(corgi_spi_devices));
538 gpio_free(CORGI_GPIO_LCDCON_CS);
540 gpio_free(CORGI_GPIO_ADS7846_CS);
543 static inline void corgi_init_spi(void) {}
546 static struct mtd_partition sharpsl_nand_partitions[] = {
548 .name = "System Area",
550 .size = 7 * 1024 * 1024,
553 .name = "Root Filesystem",
554 .offset = 7 * 1024 * 1024,
555 .size = 25 * 1024 * 1024,
558 .name = "Home Filesystem",
559 .offset = MTDPART_OFS_APPEND,
560 .size = MTDPART_SIZ_FULL,
564 static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
566 static struct nand_bbt_descr sharpsl_bbt = {
570 .pattern = scan_ff_pattern
573 static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
574 .badblock_pattern = &sharpsl_bbt,
575 .partitions = sharpsl_nand_partitions,
576 .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions),
579 static struct resource sharpsl_nand_resources[] = {
583 .flags = IORESOURCE_MEM,
587 static struct platform_device sharpsl_nand_device = {
588 .name = "sharpsl-nand",
590 .resource = sharpsl_nand_resources,
591 .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
592 .dev.platform_data = &sharpsl_nand_platform_data,
595 static struct mtd_partition sharpsl_rom_parts[] = {
597 .name ="Boot PROM Filesystem",
598 .offset = 0x00120000,
599 .size = MTDPART_SIZ_FULL,
603 static struct physmap_flash_data sharpsl_rom_data = {
605 .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
606 .parts = sharpsl_rom_parts,
609 static struct resource sharpsl_rom_resources[] = {
613 .flags = IORESOURCE_MEM,
617 static struct platform_device sharpsl_rom_device = {
618 .name = "physmap-flash",
620 .resource = sharpsl_rom_resources,
621 .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
622 .dev.platform_data = &sharpsl_rom_data,
625 static struct platform_device *devices[] __initdata = {
630 &sharpsl_nand_device,
634 static void corgi_poweroff(void)
636 if (!machine_is_corgi())
637 /* Green LED off tells the bootloader to halt */
638 gpio_set_value(CORGI_GPIO_LED_GREEN, 0);
640 arm_machine_restart('h');
643 static void corgi_restart(char mode)
645 if (!machine_is_corgi())
646 /* Green LED on tells the bootloader to reboot */
647 gpio_set_value(CORGI_GPIO_LED_GREEN, 1);
649 arm_machine_restart('h');
652 static void __init corgi_init(void)
654 pm_power_off = corgi_poweroff;
655 arm_pm_restart = corgi_restart;
657 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
660 pxa2xx_mfp_config(ARRAY_AND_SIZE(corgi_pin_config));
664 pxa_set_udc_info(&udc_info);
665 pxa_set_mci_info(&corgi_mci_platform_data);
666 pxa_set_ficp_info(&corgi_ficp_platform_data);
667 pxa_set_i2c_info(NULL);
669 platform_scoop_config = &corgi_pcmcia_config;
671 if (machine_is_husky())
672 sharpsl_nand_partitions[1].size = 53 * 1024 * 1024;
674 platform_add_devices(devices, ARRAY_SIZE(devices));
677 static void __init fixup_corgi(struct machine_desc *desc,
678 struct tag *tags, char **cmdline, struct meminfo *mi)
680 sharpsl_save_param();
682 mi->bank[0].start = 0xa0000000;
683 mi->bank[0].node = 0;
684 if (machine_is_corgi())
685 mi->bank[0].size = (32*1024*1024);
687 mi->bank[0].size = (64*1024*1024);
690 #ifdef CONFIG_MACH_CORGI
691 MACHINE_START(CORGI, "SHARP Corgi")
692 .phys_io = 0x40000000,
693 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
694 .fixup = fixup_corgi,
695 .map_io = pxa_map_io,
696 .init_irq = pxa25x_init_irq,
697 .init_machine = corgi_init,
702 #ifdef CONFIG_MACH_SHEPHERD
703 MACHINE_START(SHEPHERD, "SHARP Shepherd")
704 .phys_io = 0x40000000,
705 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
706 .fixup = fixup_corgi,
707 .map_io = pxa_map_io,
708 .init_irq = pxa25x_init_irq,
709 .init_machine = corgi_init,
714 #ifdef CONFIG_MACH_HUSKY
715 MACHINE_START(HUSKY, "SHARP Husky")
716 .phys_io = 0x40000000,
717 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
718 .fixup = fixup_corgi,
719 .map_io = pxa_map_io,
720 .init_irq = pxa25x_init_irq,
721 .init_machine = corgi_init,