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>
27 #include <linux/reboot.h>
29 #include <asm/setup.h>
30 #include <asm/memory.h>
31 #include <asm/mach-types.h>
32 #include <asm/hardware.h>
34 #include <asm/system.h>
35 #include <asm/arch/pxa-regs.h>
36 #include <asm/arch/pxa2xx-regs.h>
37 #include <asm/arch/mfp-pxa25x.h>
38 #include <asm/arch/irda.h>
39 #include <asm/arch/i2c.h>
40 #include <asm/arch/mmc.h>
41 #include <asm/arch/udc.h>
43 #include <asm/mach/arch.h>
44 #include <asm/mach/map.h>
45 #include <asm/mach/irq.h>
46 #include <asm/arch/tosa.h>
48 #include <asm/hardware/scoop.h>
49 #include <asm/mach/sharpsl_param.h>
54 static unsigned long tosa_pin_config
[] = {
55 GPIO78_nCS_2
, /* Scoop */
56 GPIO80_nCS_4
, /* tg6393xb */
57 GPIO33_nCS_5
, /* Scoop */
59 // GPIO76 CARD_VCC_ON1
61 GPIO19_GPIO
, /* Reset out */
62 GPIO1_RST
| WAKEUP_ON_EDGE_FALL
,
64 GPIO0_GPIO
| WAKEUP_ON_EDGE_FALL
, /* WAKE_UP */
65 GPIO2_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* AC_IN */
66 GPIO3_GPIO
| WAKEUP_ON_EDGE_FALL
, /* RECORD */
67 GPIO4_GPIO
| WAKEUP_ON_EDGE_FALL
, /* SYNC */
68 GPIO20_GPIO
, /* EAR_IN */
71 GPIO5_GPIO
, /* USB_IN */
72 GPIO32_GPIO
, /* Pen IRQ */
74 GPIO7_GPIO
, /* Jacket Detect */
75 GPIO14_GPIO
, /* BAT0_CRG */
76 GPIO12_GPIO
, /* BAT1_CRG */
77 GPIO17_GPIO
, /* BAT0_LOW */
78 GPIO84_GPIO
, /* BAT1_LOW */
79 GPIO38_GPIO
, /* BAT_LOCK */
82 GPIO15_GPIO
, /* TC6393XB IRQ */
84 GPIO27_GPIO
, /* LCD Sync */
89 GPIO9_GPIO
, /* Detect */
93 GPIO13_GPIO
, /* CD_IRQ */
94 GPIO21_GPIO
, /* Main Slot IRQ */
95 GPIO36_GPIO
, /* Jacket Slot IRQ */
109 GPIO30_AC97_SDATA_OUT
,
111 GPIO29_AC97_SDATA_IN_0
,
133 GPIO58_GPIO
| MFP_LPM_DRIVE_LOW
,
134 GPIO59_GPIO
| MFP_LPM_DRIVE_LOW
,
135 GPIO60_GPIO
| MFP_LPM_DRIVE_LOW
,
136 GPIO61_GPIO
| MFP_LPM_DRIVE_LOW
,
137 GPIO62_GPIO
| MFP_LPM_DRIVE_LOW
,
138 GPIO63_GPIO
| MFP_LPM_DRIVE_LOW
,
139 GPIO64_GPIO
| MFP_LPM_DRIVE_LOW
,
140 GPIO65_GPIO
| MFP_LPM_DRIVE_LOW
,
141 GPIO66_GPIO
| MFP_LPM_DRIVE_LOW
,
142 GPIO67_GPIO
| MFP_LPM_DRIVE_LOW
,
143 GPIO68_GPIO
| MFP_LPM_DRIVE_LOW
,
144 GPIO69_GPIO
| MFP_LPM_DRIVE_LOW
,
145 GPIO70_GPIO
| MFP_LPM_DRIVE_LOW
,
146 GPIO71_GPIO
| MFP_LPM_DRIVE_LOW
,
147 GPIO72_GPIO
| MFP_LPM_DRIVE_LOW
,
148 GPIO73_GPIO
| MFP_LPM_DRIVE_LOW
,
149 GPIO74_GPIO
| MFP_LPM_DRIVE_LOW
,
150 GPIO75_GPIO
| MFP_LPM_DRIVE_LOW
,
161 static struct resource tosa_scoop_resources
[] = {
163 .start
= TOSA_CF_PHYS
,
164 .end
= TOSA_CF_PHYS
+ 0xfff,
165 .flags
= IORESOURCE_MEM
,
169 static struct scoop_config tosa_scoop_setup
= {
170 .io_dir
= TOSA_SCOOP_IO_DIR
,
171 .gpio_base
= TOSA_SCOOP_GPIO_BASE
,
174 static struct platform_device tosascoop_device
= {
175 .name
= "sharp-scoop",
178 .platform_data
= &tosa_scoop_setup
,
180 .num_resources
= ARRAY_SIZE(tosa_scoop_resources
),
181 .resource
= tosa_scoop_resources
,
186 * SCOOP Device Jacket
188 static struct resource tosa_scoop_jc_resources
[] = {
190 .start
= TOSA_SCOOP_PHYS
+ 0x40,
191 .end
= TOSA_SCOOP_PHYS
+ 0xfff,
192 .flags
= IORESOURCE_MEM
,
196 static struct scoop_config tosa_scoop_jc_setup
= {
197 .io_dir
= TOSA_SCOOP_JC_IO_DIR
,
198 .gpio_base
= TOSA_SCOOP_JC_GPIO_BASE
,
201 static struct platform_device tosascoop_jc_device
= {
202 .name
= "sharp-scoop",
205 .platform_data
= &tosa_scoop_jc_setup
,
206 .parent
= &tosascoop_device
.dev
,
208 .num_resources
= ARRAY_SIZE(tosa_scoop_jc_resources
),
209 .resource
= tosa_scoop_jc_resources
,
215 static struct scoop_pcmcia_dev tosa_pcmcia_scoop
[] = {
217 .dev
= &tosascoop_device
.dev
,
218 .irq
= TOSA_IRQ_GPIO_CF_IRQ
,
219 .cd_irq
= TOSA_IRQ_GPIO_CF_CD
,
220 .cd_irq_str
= "PCMCIA0 CD",
222 .dev
= &tosascoop_jc_device
.dev
,
223 .irq
= TOSA_IRQ_GPIO_JC_CF_IRQ
,
228 static struct scoop_pcmcia_config tosa_pcmcia_config
= {
229 .devs
= &tosa_pcmcia_scoop
[0],
234 * USB Device Controller
236 static struct pxa2xx_udc_mach_info udc_info __initdata
= {
237 .gpio_pullup
= TOSA_GPIO_USB_PULLUP
,
238 .gpio_vbus
= TOSA_GPIO_USB_IN
,
239 .gpio_vbus_inverted
= 1,
245 static struct pxamci_platform_data tosa_mci_platform_data
;
247 static int tosa_mci_init(struct device
*dev
, irq_handler_t tosa_detect_int
, void *data
)
251 tosa_mci_platform_data
.detect_delay
= msecs_to_jiffies(250);
253 err
= request_irq(TOSA_IRQ_GPIO_nSD_DETECT
, tosa_detect_int
,
254 IRQF_DISABLED
| IRQF_TRIGGER_RISING
| IRQF_TRIGGER_FALLING
,
255 "MMC/SD card detect", data
);
257 printk(KERN_ERR
"tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
261 err
= gpio_request(TOSA_GPIO_SD_WP
, "sd_wp");
263 printk(KERN_ERR
"tosa_mci_init: can't request SD_WP gpio\n");
266 err
= gpio_direction_input(TOSA_GPIO_SD_WP
);
268 goto err_gpio_wp_dir
;
270 err
= gpio_request(TOSA_GPIO_PWR_ON
, "sd_pwr");
272 printk(KERN_ERR
"tosa_mci_init: can't request SD_PWR gpio\n");
275 err
= gpio_direction_output(TOSA_GPIO_PWR_ON
, 0);
277 goto err_gpio_pwr_dir
;
282 gpio_free(TOSA_GPIO_PWR_ON
);
285 gpio_free(TOSA_GPIO_SD_WP
);
287 free_irq(TOSA_IRQ_GPIO_nSD_DETECT
, data
);
292 static void tosa_mci_setpower(struct device
*dev
, unsigned int vdd
)
294 struct pxamci_platform_data
* p_d
= dev
->platform_data
;
296 if (( 1 << vdd
) & p_d
->ocr_mask
) {
297 gpio_set_value(TOSA_GPIO_PWR_ON
, 1);
299 gpio_set_value(TOSA_GPIO_PWR_ON
, 0);
303 static int tosa_mci_get_ro(struct device
*dev
)
305 return gpio_get_value(TOSA_GPIO_SD_WP
);
308 static void tosa_mci_exit(struct device
*dev
, void *data
)
310 gpio_free(TOSA_GPIO_PWR_ON
);
311 gpio_free(TOSA_GPIO_SD_WP
);
312 free_irq(TOSA_IRQ_GPIO_nSD_DETECT
, data
);
315 static struct pxamci_platform_data tosa_mci_platform_data
= {
316 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
317 .init
= tosa_mci_init
,
318 .get_ro
= tosa_mci_get_ro
,
319 .setpower
= tosa_mci_setpower
,
320 .exit
= tosa_mci_exit
,
326 static int tosa_irda_startup(struct device
*dev
)
330 ret
= gpio_request(TOSA_GPIO_IR_POWERDWN
, "IrDA powerdown");
334 ret
= gpio_direction_output(TOSA_GPIO_IR_POWERDWN
, 0);
336 gpio_free(TOSA_GPIO_IR_POWERDWN
);
341 static void tosa_irda_shutdown(struct device
*dev
)
343 gpio_free(TOSA_GPIO_IR_POWERDWN
);
346 static void tosa_irda_transceiver_mode(struct device
*dev
, int mode
)
348 gpio_set_value(TOSA_GPIO_IR_POWERDWN
, !(mode
& IR_OFF
));
351 static struct pxaficp_platform_data tosa_ficp_platform_data
= {
352 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
353 .transceiver_mode
= tosa_irda_transceiver_mode
,
354 .startup
= tosa_irda_startup
,
355 .shutdown
= tosa_irda_shutdown
,
361 static struct platform_device tosakbd_device
= {
362 .name
= "tosa-keyboard",
366 static struct gpio_keys_button tosa_gpio_keys
[] = {
368 * Two following keys are directly tied to "ON" button of tosa. Why?
369 * The first one can be used as a wakeup source, the second can't;
370 * also the first one is OR of ac_powered and on_button.
374 .code
= KEY_RESERVED
,
375 .gpio
= TOSA_GPIO_POWERON
,
383 .gpio
= TOSA_GPIO_ON_KEY
,
386 * can't be used as wakeup
393 .code
= TOSA_KEY_RECORD
,
394 .gpio
= TOSA_GPIO_RECORD_BTN
,
395 .desc
= "Record Button",
401 .code
= TOSA_KEY_SYNC
,
402 .gpio
= TOSA_GPIO_SYNC
,
403 .desc
= "Sync Button",
409 static struct gpio_keys_platform_data tosa_gpio_keys_platform_data
= {
410 .buttons
= tosa_gpio_keys
,
411 .nbuttons
= ARRAY_SIZE(tosa_gpio_keys
),
414 static struct platform_device tosa_gpio_keys_device
= {
418 .platform_data
= &tosa_gpio_keys_platform_data
,
425 static struct gpio_led tosa_gpio_leds
[] = {
427 .name
= "tosa:amber:charge",
428 .default_trigger
= "main-battery-charging",
429 .gpio
= TOSA_GPIO_CHRG_ERR_LED
,
432 .name
= "tosa:green:mail",
433 .default_trigger
= "nand-disk",
434 .gpio
= TOSA_GPIO_NOTE_LED
,
437 .name
= "tosa:dual:wlan",
438 .default_trigger
= "none",
439 .gpio
= TOSA_GPIO_WLAN_LED
,
442 .name
= "tosa:blue:bluetooth",
443 .default_trigger
= "none",
444 .gpio
= TOSA_GPIO_BT_LED
,
448 static struct gpio_led_platform_data tosa_gpio_leds_platform_data
= {
449 .leds
= tosa_gpio_leds
,
450 .num_leds
= ARRAY_SIZE(tosa_gpio_leds
),
453 static struct platform_device tosaled_device
= {
457 .platform_data
= &tosa_gpio_leds_platform_data
,
461 static struct platform_device
*devices
[] __initdata
= {
463 &tosascoop_jc_device
,
465 &tosa_gpio_keys_device
,
469 static void tosa_poweroff(void)
471 arm_machine_restart('g');
474 static void tosa_restart(char mode
)
476 /* Bootloader magic for a reboot */
477 if((MSC0
& 0xffff0000) == 0x7ff00000)
478 MSC0
= (MSC0
& 0xffff) | 0x7ee00000;
483 static void __init
tosa_init(void)
485 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config
));
486 gpio_set_wake(MFP_PIN_GPIO1
, 1);
487 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
489 init_gpio_reset(TOSA_GPIO_ON_RESET
);
491 pm_power_off
= tosa_poweroff
;
492 arm_pm_restart
= tosa_restart
;
496 /* enable batt_fault */
499 pxa_set_mci_info(&tosa_mci_platform_data
);
500 pxa_set_udc_info(&udc_info
);
501 pxa_set_ficp_info(&tosa_ficp_platform_data
);
502 pxa_set_i2c_info(NULL
);
503 platform_scoop_config
= &tosa_pcmcia_config
;
505 platform_add_devices(devices
, ARRAY_SIZE(devices
));
508 static void __init
fixup_tosa(struct machine_desc
*desc
,
509 struct tag
*tags
, char **cmdline
, struct meminfo
*mi
)
511 sharpsl_save_param();
513 mi
->bank
[0].start
= 0xa0000000;
514 mi
->bank
[0].node
= 0;
515 mi
->bank
[0].size
= (64*1024*1024);
518 MACHINE_START(TOSA
, "SHARP Tosa")
519 .phys_io
= 0x40000000,
520 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
522 .map_io
= pxa_map_io
,
523 .init_irq
= pxa25x_init_irq
,
524 .init_machine
= tosa_init
,