2 * Support for Sharp SL-C6000x PDAs
5 * Copyright (c) 2005 Dirk Opfer
7 * Based on code written by Sharp/Lineo for 2.4 kernels
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>
23 #include <linux/delay.h>
24 #include <linux/gpio_keys.h>
25 #include <linux/input.h>
26 #include <linux/gpio.h>
28 #include <asm/setup.h>
29 #include <asm/mach-types.h>
30 #include <asm/arch/pxa2xx-regs.h>
31 #include <asm/arch/mfp-pxa25x.h>
32 #include <asm/arch/irda.h>
33 #include <asm/arch/i2c.h>
34 #include <asm/arch/mmc.h>
35 #include <asm/arch/udc.h>
37 #include <asm/mach/arch.h>
38 #include <asm/arch/tosa.h>
40 #include <asm/hardware/scoop.h>
41 #include <asm/mach/sharpsl_param.h>
46 static unsigned long tosa_pin_config[] = {
47 GPIO78_nCS_2, /* Scoop */
48 GPIO80_nCS_4, /* tg6393xb */
49 GPIO33_nCS_5, /* Scoop */
51 // GPIO76 CARD_VCC_ON1
53 GPIO19_GPIO, /* Reset out */
54 GPIO1_RST | WAKEUP_ON_EDGE_FALL,
56 GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */
57 GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */
58 GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */
59 GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */
60 GPIO20_GPIO, /* EAR_IN */
63 GPIO5_GPIO, /* USB_IN */
64 GPIO32_GPIO, /* Pen IRQ */
66 GPIO7_GPIO, /* Jacket Detect */
67 GPIO14_GPIO, /* BAT0_CRG */
68 GPIO12_GPIO, /* BAT1_CRG */
69 GPIO17_GPIO, /* BAT0_LOW */
70 GPIO84_GPIO, /* BAT1_LOW */
71 GPIO38_GPIO, /* BAT_LOCK */
74 GPIO15_GPIO, /* TC6393XB IRQ */
76 GPIO27_GPIO, /* LCD Sync */
81 GPIO9_GPIO, /* Detect */
82 GPIO10_GPIO, /* nSD_INT */
85 GPIO13_GPIO, /* CD_IRQ */
86 GPIO21_GPIO, /* Main Slot IRQ */
87 GPIO36_GPIO, /* Jacket Slot IRQ */
101 GPIO30_AC97_SDATA_OUT,
103 GPIO29_AC97_SDATA_IN_0,
125 GPIO58_GPIO | MFP_LPM_DRIVE_LOW,
126 GPIO59_GPIO | MFP_LPM_DRIVE_LOW,
127 GPIO60_GPIO | MFP_LPM_DRIVE_LOW,
128 GPIO61_GPIO | MFP_LPM_DRIVE_LOW,
129 GPIO62_GPIO | MFP_LPM_DRIVE_LOW,
130 GPIO63_GPIO | MFP_LPM_DRIVE_LOW,
131 GPIO64_GPIO | MFP_LPM_DRIVE_LOW,
132 GPIO65_GPIO | MFP_LPM_DRIVE_LOW,
133 GPIO66_GPIO | MFP_LPM_DRIVE_LOW,
134 GPIO67_GPIO | MFP_LPM_DRIVE_LOW,
135 GPIO68_GPIO | MFP_LPM_DRIVE_LOW,
136 GPIO69_GPIO | MFP_LPM_DRIVE_LOW,
137 GPIO70_GPIO | MFP_LPM_DRIVE_LOW,
138 GPIO71_GPIO | MFP_LPM_DRIVE_LOW,
139 GPIO72_GPIO | MFP_LPM_DRIVE_LOW,
140 GPIO73_GPIO | MFP_LPM_DRIVE_LOW,
141 GPIO74_GPIO | MFP_LPM_DRIVE_LOW,
142 GPIO75_GPIO | MFP_LPM_DRIVE_LOW,
153 static struct resource tosa_scoop_resources[] = {
155 .start = TOSA_CF_PHYS,
156 .end = TOSA_CF_PHYS + 0xfff,
157 .flags = IORESOURCE_MEM,
161 static struct scoop_config tosa_scoop_setup = {
162 .io_dir = TOSA_SCOOP_IO_DIR,
163 .gpio_base = TOSA_SCOOP_GPIO_BASE,
166 static struct platform_device tosascoop_device = {
167 .name = "sharp-scoop",
170 .platform_data = &tosa_scoop_setup,
172 .num_resources = ARRAY_SIZE(tosa_scoop_resources),
173 .resource = tosa_scoop_resources,
178 * SCOOP Device Jacket
180 static struct resource tosa_scoop_jc_resources[] = {
182 .start = TOSA_SCOOP_PHYS + 0x40,
183 .end = TOSA_SCOOP_PHYS + 0xfff,
184 .flags = IORESOURCE_MEM,
188 static struct scoop_config tosa_scoop_jc_setup = {
189 .io_dir = TOSA_SCOOP_JC_IO_DIR,
190 .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
193 static struct platform_device tosascoop_jc_device = {
194 .name = "sharp-scoop",
197 .platform_data = &tosa_scoop_jc_setup,
198 .parent = &tosascoop_device.dev,
200 .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
201 .resource = tosa_scoop_jc_resources,
207 static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
209 .dev = &tosascoop_device.dev,
210 .irq = TOSA_IRQ_GPIO_CF_IRQ,
211 .cd_irq = TOSA_IRQ_GPIO_CF_CD,
212 .cd_irq_str = "PCMCIA0 CD",
214 .dev = &tosascoop_jc_device.dev,
215 .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
220 static struct scoop_pcmcia_config tosa_pcmcia_config = {
221 .devs = &tosa_pcmcia_scoop[0],
226 * USB Device Controller
228 static struct pxa2xx_udc_mach_info udc_info __initdata = {
229 .gpio_pullup = TOSA_GPIO_USB_PULLUP,
230 .gpio_vbus = TOSA_GPIO_USB_IN,
231 .gpio_vbus_inverted = 1,
237 static struct pxamci_platform_data tosa_mci_platform_data;
239 static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
243 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
245 err = gpio_request(TOSA_GPIO_nSD_DETECT, "MMC/SD card detect");
247 printk(KERN_ERR "tosa_mci_init: can't request nSD_DETECT gpio\n");
248 goto err_gpio_detect;
250 err = gpio_direction_input(TOSA_GPIO_nSD_DETECT);
252 goto err_gpio_detect_dir;
254 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
255 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
256 "MMC/SD card detect", data);
258 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
262 err = gpio_request(TOSA_GPIO_SD_WP, "SD Write Protect");
264 printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n");
267 err = gpio_direction_input(TOSA_GPIO_SD_WP);
269 goto err_gpio_wp_dir;
271 err = gpio_request(TOSA_GPIO_PWR_ON, "SD Power");
273 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
276 err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0);
278 goto err_gpio_pwr_dir;
280 err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
282 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
285 err = gpio_direction_input(TOSA_GPIO_nSD_INT);
287 goto err_gpio_int_dir;
292 gpio_free(TOSA_GPIO_nSD_INT);
295 gpio_free(TOSA_GPIO_PWR_ON);
298 gpio_free(TOSA_GPIO_SD_WP);
300 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
303 gpio_free(TOSA_GPIO_nSD_DETECT);
308 static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
310 struct pxamci_platform_data* p_d = dev->platform_data;
312 if (( 1 << vdd) & p_d->ocr_mask) {
313 gpio_set_value(TOSA_GPIO_PWR_ON, 1);
315 gpio_set_value(TOSA_GPIO_PWR_ON, 0);
319 static int tosa_mci_get_ro(struct device *dev)
321 return gpio_get_value(TOSA_GPIO_SD_WP);
324 static void tosa_mci_exit(struct device *dev, void *data)
326 gpio_free(TOSA_GPIO_nSD_INT);
327 gpio_free(TOSA_GPIO_PWR_ON);
328 gpio_free(TOSA_GPIO_SD_WP);
329 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
330 gpio_free(TOSA_GPIO_nSD_DETECT);
333 static struct pxamci_platform_data tosa_mci_platform_data = {
334 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
335 .init = tosa_mci_init,
336 .get_ro = tosa_mci_get_ro,
337 .setpower = tosa_mci_setpower,
338 .exit = tosa_mci_exit,
344 static int tosa_irda_startup(struct device *dev)
348 ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
352 ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
354 gpio_free(TOSA_GPIO_IR_POWERDWN);
359 static void tosa_irda_shutdown(struct device *dev)
361 gpio_free(TOSA_GPIO_IR_POWERDWN);
364 static void tosa_irda_transceiver_mode(struct device *dev, int mode)
366 gpio_set_value(TOSA_GPIO_IR_POWERDWN, !(mode & IR_OFF));
369 static struct pxaficp_platform_data tosa_ficp_platform_data = {
370 .transceiver_cap = IR_SIRMODE | IR_OFF,
371 .transceiver_mode = tosa_irda_transceiver_mode,
372 .startup = tosa_irda_startup,
373 .shutdown = tosa_irda_shutdown,
379 static struct platform_device tosakbd_device = {
380 .name = "tosa-keyboard",
384 static struct gpio_keys_button tosa_gpio_keys[] = {
386 * Two following keys are directly tied to "ON" button of tosa. Why?
387 * The first one can be used as a wakeup source, the second can't;
388 * also the first one is OR of ac_powered and on_button.
392 .code = KEY_RESERVED,
393 .gpio = TOSA_GPIO_POWERON,
401 .gpio = TOSA_GPIO_ON_KEY,
404 * can't be used as wakeup
411 .code = TOSA_KEY_RECORD,
412 .gpio = TOSA_GPIO_RECORD_BTN,
413 .desc = "Record Button",
419 .code = TOSA_KEY_SYNC,
420 .gpio = TOSA_GPIO_SYNC,
421 .desc = "Sync Button",
427 static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
428 .buttons = tosa_gpio_keys,
429 .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
432 static struct platform_device tosa_gpio_keys_device = {
436 .platform_data = &tosa_gpio_keys_platform_data,
443 static struct gpio_led tosa_gpio_leds[] = {
445 .name = "tosa:amber:charge",
446 .default_trigger = "main-battery-charging",
447 .gpio = TOSA_GPIO_CHRG_ERR_LED,
450 .name = "tosa:green:mail",
451 .default_trigger = "nand-disk",
452 .gpio = TOSA_GPIO_NOTE_LED,
455 .name = "tosa:dual:wlan",
456 .default_trigger = "none",
457 .gpio = TOSA_GPIO_WLAN_LED,
460 .name = "tosa:blue:bluetooth",
461 .default_trigger = "none",
462 .gpio = TOSA_GPIO_BT_LED,
466 static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
467 .leds = tosa_gpio_leds,
468 .num_leds = ARRAY_SIZE(tosa_gpio_leds),
471 static struct platform_device tosaled_device = {
475 .platform_data = &tosa_gpio_leds_platform_data,
479 static struct platform_device *devices[] __initdata = {
481 &tosascoop_jc_device,
483 &tosa_gpio_keys_device,
487 static void tosa_poweroff(void)
489 arm_machine_restart('g');
492 static void tosa_restart(char mode)
494 /* Bootloader magic for a reboot */
495 if((MSC0 & 0xffff0000) == 0x7ff00000)
496 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
501 static void __init tosa_init(void)
503 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
504 gpio_set_wake(MFP_PIN_GPIO1, 1);
505 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
507 init_gpio_reset(TOSA_GPIO_ON_RESET);
509 pm_power_off = tosa_poweroff;
510 arm_pm_restart = tosa_restart;
514 /* enable batt_fault */
517 pxa_set_mci_info(&tosa_mci_platform_data);
518 pxa_set_udc_info(&udc_info);
519 pxa_set_ficp_info(&tosa_ficp_platform_data);
520 pxa_set_i2c_info(NULL);
521 platform_scoop_config = &tosa_pcmcia_config;
523 platform_add_devices(devices, ARRAY_SIZE(devices));
526 static void __init fixup_tosa(struct machine_desc *desc,
527 struct tag *tags, char **cmdline, struct meminfo *mi)
529 sharpsl_save_param();
531 mi->bank[0].start = 0xa0000000;
532 mi->bank[0].node = 0;
533 mi->bank[0].size = (64*1024*1024);
536 MACHINE_START(TOSA, "SHARP Tosa")
537 .phys_io = 0x40000000,
538 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
540 .map_io = pxa_map_io,
541 .init_irq = pxa25x_init_irq,
542 .init_machine = tosa_init,