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>
27 #include <asm/setup.h>
28 #include <asm/memory.h>
29 #include <asm/mach-types.h>
30 #include <asm/hardware.h>
32 #include <asm/system.h>
33 #include <asm/arch/pxa-regs.h>
34 #include <asm/arch/pxa2xx-regs.h>
35 #include <asm/arch/mfp-pxa25x.h>
36 #include <asm/arch/irda.h>
37 #include <asm/arch/mmc.h>
38 #include <asm/arch/udc.h>
40 #include <asm/mach/arch.h>
41 #include <asm/mach/map.h>
42 #include <asm/mach/irq.h>
43 #include <asm/arch/tosa.h>
45 #include <asm/hardware/scoop.h>
46 #include <asm/mach/sharpsl_param.h>
51 static unsigned long tosa_pin_config
[] = {
52 GPIO78_nCS_2
, /* Scoop */
53 GPIO80_nCS_4
, /* tg6393xb */
54 GPIO33_nCS_5
, /* Scoop */
56 // GPIO76 CARD_VCC_ON1
58 GPIO19_GPIO
, /* Reset out */
59 GPIO1_RST
| WAKEUP_ON_EDGE_FALL
,
61 GPIO0_GPIO
| WAKEUP_ON_EDGE_FALL
, /* WAKE_UP */
62 GPIO2_GPIO
| WAKEUP_ON_EDGE_BOTH
, /* AC_IN */
63 GPIO3_GPIO
| WAKEUP_ON_EDGE_FALL
, /* RECORD */
64 GPIO4_GPIO
| WAKEUP_ON_EDGE_FALL
, /* SYNC */
65 GPIO20_GPIO
, /* EAR_IN */
68 GPIO5_GPIO
, /* USB_IN */
69 GPIO32_GPIO
, /* Pen IRQ */
71 GPIO7_GPIO
, /* Jacket Detect */
72 GPIO14_GPIO
, /* BAT0_CRG */
73 GPIO12_GPIO
, /* BAT1_CRG */
74 GPIO17_GPIO
, /* BAT0_LOW */
75 GPIO84_GPIO
, /* BAT1_LOW */
76 GPIO38_GPIO
, /* BAT_LOCK */
79 GPIO15_GPIO
, /* TC6393XB IRQ */
81 GPIO27_GPIO
, /* LCD Sync */
86 GPIO9_GPIO
, /* Detect */
90 GPIO13_GPIO
, /* CD_IRQ */
91 GPIO21_GPIO
, /* Main Slot IRQ */
92 GPIO36_GPIO
, /* Jacket Slot IRQ */
106 GPIO30_AC97_SDATA_OUT
,
108 GPIO29_AC97_SDATA_IN_0
,
158 static struct resource tosa_scoop_resources
[] = {
160 .start
= TOSA_CF_PHYS
,
161 .end
= TOSA_CF_PHYS
+ 0xfff,
162 .flags
= IORESOURCE_MEM
,
166 static struct scoop_config tosa_scoop_setup
= {
167 .io_dir
= TOSA_SCOOP_IO_DIR
,
168 .io_out
= TOSA_SCOOP_IO_OUT
,
172 struct platform_device tosascoop_device
= {
173 .name
= "sharp-scoop",
176 .platform_data
= &tosa_scoop_setup
,
178 .num_resources
= ARRAY_SIZE(tosa_scoop_resources
),
179 .resource
= tosa_scoop_resources
,
184 * SCOOP Device Jacket
186 static struct resource tosa_scoop_jc_resources
[] = {
188 .start
= TOSA_SCOOP_PHYS
+ 0x40,
189 .end
= TOSA_SCOOP_PHYS
+ 0xfff,
190 .flags
= IORESOURCE_MEM
,
194 static struct scoop_config tosa_scoop_jc_setup
= {
195 .io_dir
= TOSA_SCOOP_JC_IO_DIR
,
196 .io_out
= TOSA_SCOOP_JC_IO_OUT
,
199 struct platform_device tosascoop_jc_device
= {
200 .name
= "sharp-scoop",
203 .platform_data
= &tosa_scoop_jc_setup
,
204 .parent
= &tosascoop_device
.dev
,
206 .num_resources
= ARRAY_SIZE(tosa_scoop_jc_resources
),
207 .resource
= tosa_scoop_jc_resources
,
213 static struct scoop_pcmcia_dev tosa_pcmcia_scoop
[] = {
215 .dev
= &tosascoop_device
.dev
,
216 .irq
= TOSA_IRQ_GPIO_CF_IRQ
,
217 .cd_irq
= TOSA_IRQ_GPIO_CF_CD
,
218 .cd_irq_str
= "PCMCIA0 CD",
220 .dev
= &tosascoop_jc_device
.dev
,
221 .irq
= TOSA_IRQ_GPIO_JC_CF_IRQ
,
226 static struct scoop_pcmcia_config tosa_pcmcia_config
= {
227 .devs
= &tosa_pcmcia_scoop
[0],
232 * USB Device Controller
234 static void tosa_udc_command(int cmd
)
237 case PXA2XX_UDC_CMD_CONNECT
:
238 set_scoop_gpio(&tosascoop_jc_device
.dev
,TOSA_SCOOP_JC_USB_PULLUP
);
240 case PXA2XX_UDC_CMD_DISCONNECT
:
241 reset_scoop_gpio(&tosascoop_jc_device
.dev
,TOSA_SCOOP_JC_USB_PULLUP
);
246 static struct pxa2xx_udc_mach_info udc_info __initdata
= {
247 .udc_command
= tosa_udc_command
,
248 .gpio_vbus
= TOSA_GPIO_USB_IN
,
249 .gpio_vbus_inverted
= 1,
255 static struct pxamci_platform_data tosa_mci_platform_data
;
257 static int tosa_mci_init(struct device
*dev
, irq_handler_t tosa_detect_int
, void *data
)
261 tosa_mci_platform_data
.detect_delay
= msecs_to_jiffies(250);
263 err
= request_irq(TOSA_IRQ_GPIO_nSD_DETECT
, tosa_detect_int
,
264 IRQF_DISABLED
| IRQF_TRIGGER_RISING
| IRQF_TRIGGER_FALLING
,
265 "MMC/SD card detect", data
);
267 printk(KERN_ERR
"tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
272 static void tosa_mci_setpower(struct device
*dev
, unsigned int vdd
)
274 struct pxamci_platform_data
* p_d
= dev
->platform_data
;
276 if (( 1 << vdd
) & p_d
->ocr_mask
) {
277 set_scoop_gpio(&tosascoop_device
.dev
,TOSA_SCOOP_PWR_ON
);
279 reset_scoop_gpio(&tosascoop_device
.dev
,TOSA_SCOOP_PWR_ON
);
283 static int tosa_mci_get_ro(struct device
*dev
)
285 return (read_scoop_reg(&tosascoop_device
.dev
, SCOOP_GPWR
)&TOSA_SCOOP_SD_WP
);
288 static void tosa_mci_exit(struct device
*dev
, void *data
)
290 free_irq(TOSA_IRQ_GPIO_nSD_DETECT
, data
);
293 static struct pxamci_platform_data tosa_mci_platform_data
= {
294 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
295 .init
= tosa_mci_init
,
296 .get_ro
= tosa_mci_get_ro
,
297 .setpower
= tosa_mci_setpower
,
298 .exit
= tosa_mci_exit
,
304 static void tosa_irda_transceiver_mode(struct device
*dev
, int mode
)
307 reset_scoop_gpio(&tosascoop_device
.dev
,TOSA_SCOOP_IR_POWERDWN
);
309 set_scoop_gpio(&tosascoop_device
.dev
,TOSA_SCOOP_IR_POWERDWN
);
313 static struct pxaficp_platform_data tosa_ficp_platform_data
= {
314 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
315 .transceiver_mode
= tosa_irda_transceiver_mode
,
321 static struct platform_device tosakbd_device
= {
322 .name
= "tosa-keyboard",
326 static struct gpio_keys_button tosa_gpio_keys
[] = {
330 .gpio
= TOSA_GPIO_ON_KEY
,
337 .code
= TOSA_KEY_RECORD
,
338 .gpio
= TOSA_GPIO_RECORD_BTN
,
339 .desc
= "Record Button",
345 .code
= TOSA_KEY_SYNC
,
346 .gpio
= TOSA_GPIO_SYNC
,
347 .desc
= "Sync Button",
353 static struct gpio_keys_platform_data tosa_gpio_keys_platform_data
= {
354 .buttons
= tosa_gpio_keys
,
355 .nbuttons
= ARRAY_SIZE(tosa_gpio_keys
),
358 static struct platform_device tosa_gpio_keys_device
= {
362 .platform_data
= &tosa_gpio_keys_platform_data
,
369 static struct platform_device tosaled_device
= {
374 static struct platform_device
*devices
[] __initdata
= {
376 &tosascoop_jc_device
,
378 &tosa_gpio_keys_device
,
382 static void tosa_poweroff(void)
384 RCSR
= RCSR_HWR
| RCSR_WDR
| RCSR_SMR
| RCSR_GPR
;
386 pxa_gpio_mode(TOSA_GPIO_ON_RESET
| GPIO_OUT
);
387 GPSR(TOSA_GPIO_ON_RESET
) = GPIO_bit(TOSA_GPIO_ON_RESET
);
390 arm_machine_restart('h');
393 static void tosa_restart(char mode
)
395 /* Bootloader magic for a reboot */
396 if((MSC0
& 0xffff0000) == 0x7ff00000)
397 MSC0
= (MSC0
& 0xffff) | 0x7ee00000;
402 static void __init
tosa_init(void)
404 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config
));
405 gpio_set_wake(MFP_PIN_GPIO1
, 1);
406 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
408 pm_power_off
= tosa_poweroff
;
409 arm_pm_restart
= tosa_restart
;
413 /* enable batt_fault */
416 pxa_set_mci_info(&tosa_mci_platform_data
);
417 pxa_set_udc_info(&udc_info
);
418 pxa_set_ficp_info(&tosa_ficp_platform_data
);
419 platform_scoop_config
= &tosa_pcmcia_config
;
421 platform_add_devices(devices
, ARRAY_SIZE(devices
));
424 static void __init
fixup_tosa(struct machine_desc
*desc
,
425 struct tag
*tags
, char **cmdline
, struct meminfo
*mi
)
427 sharpsl_save_param();
429 mi
->bank
[0].start
= 0xa0000000;
430 mi
->bank
[0].node
= 0;
431 mi
->bank
[0].size
= (64*1024*1024);
434 MACHINE_START(TOSA
, "SHARP Tosa")
435 .phys_io
= 0x40000000,
436 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
438 .map_io
= pxa_map_io
,
439 .init_irq
= pxa25x_init_irq
,
440 .init_machine
= tosa_init
,