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/memory.h>
30 #include <asm/mach-types.h>
31 #include <asm/hardware.h>
33 #include <asm/system.h>
34 #include <asm/arch/pxa-regs.h>
35 #include <asm/arch/pxa2xx-regs.h>
36 #include <asm/arch/mfp-pxa25x.h>
37 #include <asm/arch/irda.h>
38 #include <asm/arch/i2c.h>
39 #include <asm/arch/mmc.h>
40 #include <asm/arch/udc.h>
42 #include <asm/mach/arch.h>
43 #include <asm/mach/map.h>
44 #include <asm/mach/irq.h>
45 #include <asm/arch/tosa.h>
47 #include <asm/hardware/scoop.h>
48 #include <asm/mach/sharpsl_param.h>
53 static unsigned long tosa_pin_config
[] = {
54 GPIO78_nCS_2
, /* Scoop */
55 GPIO80_nCS_4
, /* tg6393xb */
56 GPIO33_nCS_5
, /* Scoop */
58 // GPIO76 CARD_VCC_ON1
60 GPIO19_GPIO
, /* Reset out */
61 GPIO1_RST
| WAKEUP_ON_EDGE_FALL
,
63 GPIO0_GPIO
| WAKEUP_ON_EDGE_FALL
, /* WAKE_UP */
64 GPIO2_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* AC_IN */
65 GPIO3_GPIO
| WAKEUP_ON_EDGE_FALL
, /* RECORD */
66 GPIO4_GPIO
| WAKEUP_ON_EDGE_FALL
, /* SYNC */
67 GPIO20_GPIO
, /* EAR_IN */
70 GPIO5_GPIO
, /* USB_IN */
71 GPIO32_GPIO
, /* Pen IRQ */
73 GPIO7_GPIO
, /* Jacket Detect */
74 GPIO14_GPIO
, /* BAT0_CRG */
75 GPIO12_GPIO
, /* BAT1_CRG */
76 GPIO17_GPIO
, /* BAT0_LOW */
77 GPIO84_GPIO
, /* BAT1_LOW */
78 GPIO38_GPIO
, /* BAT_LOCK */
81 GPIO15_GPIO
, /* TC6393XB IRQ */
83 GPIO27_GPIO
, /* LCD Sync */
88 GPIO9_GPIO
, /* Detect */
92 GPIO13_GPIO
, /* CD_IRQ */
93 GPIO21_GPIO
, /* Main Slot IRQ */
94 GPIO36_GPIO
, /* Jacket Slot IRQ */
108 GPIO30_AC97_SDATA_OUT
,
110 GPIO29_AC97_SDATA_IN_0
,
160 static struct resource tosa_scoop_resources
[] = {
162 .start
= TOSA_CF_PHYS
,
163 .end
= TOSA_CF_PHYS
+ 0xfff,
164 .flags
= IORESOURCE_MEM
,
168 static struct scoop_config tosa_scoop_setup
= {
169 .io_dir
= TOSA_SCOOP_IO_DIR
,
170 .gpio_base
= TOSA_SCOOP_GPIO_BASE
,
173 static struct platform_device tosascoop_device
= {
174 .name
= "sharp-scoop",
177 .platform_data
= &tosa_scoop_setup
,
179 .num_resources
= ARRAY_SIZE(tosa_scoop_resources
),
180 .resource
= tosa_scoop_resources
,
185 * SCOOP Device Jacket
187 static struct resource tosa_scoop_jc_resources
[] = {
189 .start
= TOSA_SCOOP_PHYS
+ 0x40,
190 .end
= TOSA_SCOOP_PHYS
+ 0xfff,
191 .flags
= IORESOURCE_MEM
,
195 static struct scoop_config tosa_scoop_jc_setup
= {
196 .io_dir
= TOSA_SCOOP_JC_IO_DIR
,
197 .gpio_base
= TOSA_SCOOP_JC_GPIO_BASE
,
200 static struct platform_device tosascoop_jc_device
= {
201 .name
= "sharp-scoop",
204 .platform_data
= &tosa_scoop_jc_setup
,
205 .parent
= &tosascoop_device
.dev
,
207 .num_resources
= ARRAY_SIZE(tosa_scoop_jc_resources
),
208 .resource
= tosa_scoop_jc_resources
,
214 static struct scoop_pcmcia_dev tosa_pcmcia_scoop
[] = {
216 .dev
= &tosascoop_device
.dev
,
217 .irq
= TOSA_IRQ_GPIO_CF_IRQ
,
218 .cd_irq
= TOSA_IRQ_GPIO_CF_CD
,
219 .cd_irq_str
= "PCMCIA0 CD",
221 .dev
= &tosascoop_jc_device
.dev
,
222 .irq
= TOSA_IRQ_GPIO_JC_CF_IRQ
,
227 static struct scoop_pcmcia_config tosa_pcmcia_config
= {
228 .devs
= &tosa_pcmcia_scoop
[0],
233 * USB Device Controller
235 static struct pxa2xx_udc_mach_info udc_info __initdata
= {
236 .gpio_pullup
= TOSA_GPIO_USB_PULLUP
,
237 .gpio_vbus
= TOSA_GPIO_USB_IN
,
238 .gpio_vbus_inverted
= 1,
244 static struct pxamci_platform_data tosa_mci_platform_data
;
246 static int tosa_mci_init(struct device
*dev
, irq_handler_t tosa_detect_int
, void *data
)
250 tosa_mci_platform_data
.detect_delay
= msecs_to_jiffies(250);
252 err
= request_irq(TOSA_IRQ_GPIO_nSD_DETECT
, tosa_detect_int
,
253 IRQF_DISABLED
| IRQF_TRIGGER_RISING
| IRQF_TRIGGER_FALLING
,
254 "MMC/SD card detect", data
);
256 printk(KERN_ERR
"tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
260 err
= gpio_request(TOSA_GPIO_SD_WP
, "sd_wp");
262 printk(KERN_ERR
"tosa_mci_init: can't request SD_WP gpio\n");
265 err
= gpio_direction_input(TOSA_GPIO_SD_WP
);
267 goto err_gpio_wp_dir
;
269 err
= gpio_request(TOSA_GPIO_PWR_ON
, "sd_pwr");
271 printk(KERN_ERR
"tosa_mci_init: can't request SD_PWR gpio\n");
274 err
= gpio_direction_output(TOSA_GPIO_PWR_ON
, 0);
276 goto err_gpio_pwr_dir
;
281 gpio_free(TOSA_GPIO_PWR_ON
);
284 gpio_free(TOSA_GPIO_SD_WP
);
286 free_irq(TOSA_IRQ_GPIO_nSD_DETECT
, data
);
291 static void tosa_mci_setpower(struct device
*dev
, unsigned int vdd
)
293 struct pxamci_platform_data
* p_d
= dev
->platform_data
;
295 if (( 1 << vdd
) & p_d
->ocr_mask
) {
296 gpio_set_value(TOSA_GPIO_PWR_ON
, 1);
298 gpio_set_value(TOSA_GPIO_PWR_ON
, 0);
302 static int tosa_mci_get_ro(struct device
*dev
)
304 return gpio_get_value(TOSA_GPIO_SD_WP
);
307 static void tosa_mci_exit(struct device
*dev
, void *data
)
309 gpio_free(TOSA_GPIO_PWR_ON
);
310 gpio_free(TOSA_GPIO_SD_WP
);
311 free_irq(TOSA_IRQ_GPIO_nSD_DETECT
, data
);
314 static struct pxamci_platform_data tosa_mci_platform_data
= {
315 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
316 .init
= tosa_mci_init
,
317 .get_ro
= tosa_mci_get_ro
,
318 .setpower
= tosa_mci_setpower
,
319 .exit
= tosa_mci_exit
,
325 static int tosa_irda_startup(struct device
*dev
)
329 ret
= gpio_request(TOSA_GPIO_IR_POWERDWN
, "IrDA powerdown");
333 ret
= gpio_direction_output(TOSA_GPIO_IR_POWERDWN
, 0);
335 gpio_free(TOSA_GPIO_IR_POWERDWN
);
340 static void tosa_irda_shutdown(struct device
*dev
)
342 gpio_free(TOSA_GPIO_IR_POWERDWN
);
345 static void tosa_irda_transceiver_mode(struct device
*dev
, int mode
)
347 gpio_set_value(TOSA_GPIO_IR_POWERDWN
, !(mode
& IR_OFF
));
350 static struct pxaficp_platform_data tosa_ficp_platform_data
= {
351 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
352 .transceiver_mode
= tosa_irda_transceiver_mode
,
353 .startup
= tosa_irda_startup
,
354 .shutdown
= tosa_irda_shutdown
,
360 static struct platform_device tosakbd_device
= {
361 .name
= "tosa-keyboard",
365 static struct gpio_keys_button tosa_gpio_keys
[] = {
367 * Two following keys are directly tied to "ON" button of tosa. Why?
368 * The first one can be used as a wakeup source, the second can't;
369 * also the first one is OR of ac_powered and on_button.
373 .code
= KEY_RESERVED
,
374 .gpio
= TOSA_GPIO_POWERON
,
382 .gpio
= TOSA_GPIO_ON_KEY
,
385 * can't be used as wakeup
392 .code
= TOSA_KEY_RECORD
,
393 .gpio
= TOSA_GPIO_RECORD_BTN
,
394 .desc
= "Record Button",
400 .code
= TOSA_KEY_SYNC
,
401 .gpio
= TOSA_GPIO_SYNC
,
402 .desc
= "Sync Button",
408 static struct gpio_keys_platform_data tosa_gpio_keys_platform_data
= {
409 .buttons
= tosa_gpio_keys
,
410 .nbuttons
= ARRAY_SIZE(tosa_gpio_keys
),
413 static struct platform_device tosa_gpio_keys_device
= {
417 .platform_data
= &tosa_gpio_keys_platform_data
,
424 static struct gpio_led tosa_gpio_leds
[] = {
426 .name
= "tosa:amber:charge",
427 .default_trigger
= "main-battery-charging",
428 .gpio
= TOSA_GPIO_CHRG_ERR_LED
,
431 .name
= "tosa:green:mail",
432 .default_trigger
= "nand-disk",
433 .gpio
= TOSA_GPIO_NOTE_LED
,
436 .name
= "tosa:dual:wlan",
437 .default_trigger
= "none",
438 .gpio
= TOSA_GPIO_WLAN_LED
,
441 .name
= "tosa:blue:bluetooth",
442 .default_trigger
= "none",
443 .gpio
= TOSA_GPIO_BT_LED
,
447 static struct gpio_led_platform_data tosa_gpio_leds_platform_data
= {
448 .leds
= tosa_gpio_leds
,
449 .num_leds
= ARRAY_SIZE(tosa_gpio_leds
),
452 static struct platform_device tosaled_device
= {
456 .platform_data
= &tosa_gpio_leds_platform_data
,
460 static struct platform_device
*devices
[] __initdata
= {
462 &tosascoop_jc_device
,
464 &tosa_gpio_keys_device
,
468 static void tosa_poweroff(void)
470 pxa_gpio_mode(TOSA_GPIO_ON_RESET
| GPIO_OUT
);
471 GPSR(TOSA_GPIO_ON_RESET
) = GPIO_bit(TOSA_GPIO_ON_RESET
);
474 arm_machine_restart('h');
477 static void tosa_restart(char mode
)
479 /* Bootloader magic for a reboot */
480 if((MSC0
& 0xffff0000) == 0x7ff00000)
481 MSC0
= (MSC0
& 0xffff) | 0x7ee00000;
486 static void __init
tosa_init(void)
488 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config
));
489 gpio_set_wake(MFP_PIN_GPIO1
, 1);
490 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
492 pm_power_off
= tosa_poweroff
;
493 arm_pm_restart
= tosa_restart
;
497 /* enable batt_fault */
500 pxa_set_mci_info(&tosa_mci_platform_data
);
501 pxa_set_udc_info(&udc_info
);
502 pxa_set_ficp_info(&tosa_ficp_platform_data
);
503 pxa_set_i2c_info(NULL
);
504 platform_scoop_config
= &tosa_pcmcia_config
;
506 platform_add_devices(devices
, ARRAY_SIZE(devices
));
509 static void __init
fixup_tosa(struct machine_desc
*desc
,
510 struct tag
*tags
, char **cmdline
, struct meminfo
*mi
)
512 sharpsl_save_param();
514 mi
->bank
[0].start
= 0xa0000000;
515 mi
->bank
[0].node
= 0;
516 mi
->bank
[0].size
= (64*1024*1024);
519 MACHINE_START(TOSA
, "SHARP Tosa")
520 .phys_io
= 0x40000000,
521 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
523 .map_io
= pxa_map_io
,
524 .init_irq
= pxa25x_init_irq
,
525 .init_machine
= tosa_init
,