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/irda.h>
35 #include <asm/arch/mmc.h>
36 #include <asm/arch/udc.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/map.h>
40 #include <asm/mach/irq.h>
41 #include <asm/arch/tosa.h>
43 #include <asm/hardware/scoop.h>
44 #include <asm/mach/sharpsl_param.h>
52 static struct resource tosa_scoop_resources
[] = {
54 .start
= TOSA_CF_PHYS
,
55 .end
= TOSA_CF_PHYS
+ 0xfff,
56 .flags
= IORESOURCE_MEM
,
60 static struct scoop_config tosa_scoop_setup
= {
61 .io_dir
= TOSA_SCOOP_IO_DIR
,
62 .io_out
= TOSA_SCOOP_IO_OUT
,
66 struct platform_device tosascoop_device
= {
67 .name
= "sharp-scoop",
70 .platform_data
= &tosa_scoop_setup
,
72 .num_resources
= ARRAY_SIZE(tosa_scoop_resources
),
73 .resource
= tosa_scoop_resources
,
80 static struct resource tosa_scoop_jc_resources
[] = {
82 .start
= TOSA_SCOOP_PHYS
+ 0x40,
83 .end
= TOSA_SCOOP_PHYS
+ 0xfff,
84 .flags
= IORESOURCE_MEM
,
88 static struct scoop_config tosa_scoop_jc_setup
= {
89 .io_dir
= TOSA_SCOOP_JC_IO_DIR
,
90 .io_out
= TOSA_SCOOP_JC_IO_OUT
,
93 struct platform_device tosascoop_jc_device
= {
94 .name
= "sharp-scoop",
97 .platform_data
= &tosa_scoop_jc_setup
,
98 .parent
= &tosascoop_device
.dev
,
100 .num_resources
= ARRAY_SIZE(tosa_scoop_jc_resources
),
101 .resource
= tosa_scoop_jc_resources
,
107 static struct scoop_pcmcia_dev tosa_pcmcia_scoop
[] = {
109 .dev
= &tosascoop_device
.dev
,
110 .irq
= TOSA_IRQ_GPIO_CF_IRQ
,
111 .cd_irq
= TOSA_IRQ_GPIO_CF_CD
,
112 .cd_irq_str
= "PCMCIA0 CD",
114 .dev
= &tosascoop_jc_device
.dev
,
115 .irq
= TOSA_IRQ_GPIO_JC_CF_IRQ
,
120 static void tosa_pcmcia_init(void)
122 /* Setup default state of GPIO outputs
123 before we enable them as outputs. */
124 GPSR(GPIO48_nPOE
) = GPIO_bit(GPIO48_nPOE
) |
125 GPIO_bit(GPIO49_nPWE
) | GPIO_bit(GPIO50_nPIOR
) |
126 GPIO_bit(GPIO51_nPIOW
) | GPIO_bit(GPIO52_nPCE_1
) |
127 GPIO_bit(GPIO53_nPCE_2
);
129 pxa_gpio_mode(GPIO48_nPOE_MD
);
130 pxa_gpio_mode(GPIO49_nPWE_MD
);
131 pxa_gpio_mode(GPIO50_nPIOR_MD
);
132 pxa_gpio_mode(GPIO51_nPIOW_MD
);
133 pxa_gpio_mode(GPIO55_nPREG_MD
);
134 pxa_gpio_mode(GPIO56_nPWAIT_MD
);
135 pxa_gpio_mode(GPIO57_nIOIS16_MD
);
136 pxa_gpio_mode(GPIO52_nPCE_1_MD
);
137 pxa_gpio_mode(GPIO53_nPCE_2_MD
);
138 pxa_gpio_mode(GPIO54_pSKTSEL_MD
);
141 static struct scoop_pcmcia_config tosa_pcmcia_config
= {
142 .devs
= &tosa_pcmcia_scoop
[0],
144 .pcmcia_init
= tosa_pcmcia_init
,
148 * USB Device Controller
150 static void tosa_udc_command(int cmd
)
153 case PXA2XX_UDC_CMD_CONNECT
:
154 set_scoop_gpio(&tosascoop_jc_device
.dev
,TOSA_SCOOP_JC_USB_PULLUP
);
156 case PXA2XX_UDC_CMD_DISCONNECT
:
157 reset_scoop_gpio(&tosascoop_jc_device
.dev
,TOSA_SCOOP_JC_USB_PULLUP
);
162 static int tosa_udc_is_connected(void)
164 return ((GPLR(TOSA_GPIO_USB_IN
) & GPIO_bit(TOSA_GPIO_USB_IN
)) == 0);
168 static struct pxa2xx_udc_mach_info udc_info __initdata
= {
169 .udc_command
= tosa_udc_command
,
170 .udc_is_connected
= tosa_udc_is_connected
,
176 static struct pxamci_platform_data tosa_mci_platform_data
;
178 static int tosa_mci_init(struct device
*dev
, irq_handler_t tosa_detect_int
, void *data
)
182 /* setup GPIO for PXA25x MMC controller */
183 pxa_gpio_mode(GPIO6_MMCCLK_MD
);
184 pxa_gpio_mode(GPIO8_MMCCS0_MD
);
185 pxa_gpio_mode(TOSA_GPIO_nSD_DETECT
| GPIO_IN
);
187 tosa_mci_platform_data
.detect_delay
= msecs_to_jiffies(250);
189 err
= request_irq(TOSA_IRQ_GPIO_nSD_DETECT
, tosa_detect_int
, IRQF_DISABLED
,
190 "MMC/SD card detect", data
);
192 printk(KERN_ERR
"tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
196 set_irq_type(TOSA_IRQ_GPIO_nSD_DETECT
, IRQT_BOTHEDGE
);
201 static void tosa_mci_setpower(struct device
*dev
, unsigned int vdd
)
203 struct pxamci_platform_data
* p_d
= dev
->platform_data
;
205 if (( 1 << vdd
) & p_d
->ocr_mask
) {
206 set_scoop_gpio(&tosascoop_device
.dev
,TOSA_SCOOP_PWR_ON
);
208 reset_scoop_gpio(&tosascoop_device
.dev
,TOSA_SCOOP_PWR_ON
);
212 static int tosa_mci_get_ro(struct device
*dev
)
214 return (read_scoop_reg(&tosascoop_device
.dev
, SCOOP_GPWR
)&TOSA_SCOOP_SD_WP
);
217 static void tosa_mci_exit(struct device
*dev
, void *data
)
219 free_irq(TOSA_IRQ_GPIO_nSD_DETECT
, data
);
222 static struct pxamci_platform_data tosa_mci_platform_data
= {
223 .ocr_mask
= MMC_VDD_32_33
|MMC_VDD_33_34
,
224 .init
= tosa_mci_init
,
225 .get_ro
= tosa_mci_get_ro
,
226 .setpower
= tosa_mci_setpower
,
227 .exit
= tosa_mci_exit
,
233 static void tosa_irda_transceiver_mode(struct device
*dev
, int mode
)
236 reset_scoop_gpio(&tosascoop_device
.dev
,TOSA_SCOOP_IR_POWERDWN
);
237 pxa_gpio_mode(GPIO47_STTXD
|GPIO_DFLT_LOW
);
238 pxa_gpio_mode(GPIO47_STTXD
|GPIO_OUT
);
240 pxa_gpio_mode(GPIO47_STTXD_MD
);
241 set_scoop_gpio(&tosascoop_device
.dev
,TOSA_SCOOP_IR_POWERDWN
);
245 static struct pxaficp_platform_data tosa_ficp_platform_data
= {
246 .transceiver_cap
= IR_SIRMODE
| IR_OFF
,
247 .transceiver_mode
= tosa_irda_transceiver_mode
,
253 static struct platform_device tosakbd_device
= {
254 .name
= "tosa-keyboard",
258 static struct gpio_keys_button tosa_gpio_keys
[] = {
262 .gpio
= TOSA_GPIO_ON_KEY
,
269 .code
= TOSA_KEY_RECORD
,
270 .gpio
= TOSA_GPIO_RECORD_BTN
,
271 .desc
= "Record Button",
277 .code
= TOSA_KEY_SYNC
,
278 .gpio
= TOSA_GPIO_SYNC
,
279 .desc
= "Sync Button",
285 static struct gpio_keys_platform_data tosa_gpio_keys_platform_data
= {
286 .buttons
= tosa_gpio_keys
,
287 .nbuttons
= ARRAY_SIZE(tosa_gpio_keys
),
290 static struct platform_device tosa_gpio_keys_device
= {
294 .platform_data
= &tosa_gpio_keys_platform_data
,
301 static struct platform_device tosaled_device
= {
306 static struct platform_device
*devices
[] __initdata
= {
308 &tosascoop_jc_device
,
310 &tosa_gpio_keys_device
,
314 static void tosa_poweroff(void)
316 RCSR
= RCSR_HWR
| RCSR_WDR
| RCSR_SMR
| RCSR_GPR
;
318 pxa_gpio_mode(TOSA_GPIO_ON_RESET
| GPIO_OUT
);
319 GPSR(TOSA_GPIO_ON_RESET
) = GPIO_bit(TOSA_GPIO_ON_RESET
);
322 arm_machine_restart('h');
325 static void tosa_restart(char mode
)
327 /* Bootloader magic for a reboot */
328 if((MSC0
& 0xffff0000) == 0x7ff00000)
329 MSC0
= (MSC0
& 0xffff) | 0x7ee00000;
334 static void __init
tosa_init(void)
336 pm_power_off
= tosa_poweroff
;
337 arm_pm_restart
= tosa_restart
;
339 pxa_gpio_mode(TOSA_GPIO_ON_RESET
| GPIO_IN
);
340 pxa_gpio_mode(TOSA_GPIO_TC6393_INT
| GPIO_IN
);
341 pxa_gpio_mode(TOSA_GPIO_USB_IN
| GPIO_IN
);
343 /* setup sleep mode values */
352 /* enable batt_fault */
355 pxa_set_mci_info(&tosa_mci_platform_data
);
356 pxa_set_udc_info(&udc_info
);
357 pxa_set_ficp_info(&tosa_ficp_platform_data
);
358 platform_scoop_config
= &tosa_pcmcia_config
;
360 platform_add_devices(devices
, ARRAY_SIZE(devices
));
363 static void __init
fixup_tosa(struct machine_desc
*desc
,
364 struct tag
*tags
, char **cmdline
, struct meminfo
*mi
)
366 sharpsl_save_param();
368 mi
->bank
[0].start
= 0xa0000000;
369 mi
->bank
[0].node
= 0;
370 mi
->bank
[0].size
= (64*1024*1024);
373 MACHINE_START(TOSA
, "SHARP Tosa")
374 .phys_io
= 0x40000000,
375 .io_pg_offst
= (io_p2v(0x40000000) >> 18) & 0xfffc,
377 .map_io
= pxa_map_io
,
378 .init_irq
= pxa25x_init_irq
,
379 .init_machine
= tosa_init
,