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/pxa2xx-gpio.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>
54 static struct resource tosa_scoop_resources[] = {
56 .start = TOSA_CF_PHYS,
57 .end = TOSA_CF_PHYS + 0xfff,
58 .flags = IORESOURCE_MEM,
62 static struct scoop_config tosa_scoop_setup = {
63 .io_dir = TOSA_SCOOP_IO_DIR,
64 .io_out = TOSA_SCOOP_IO_OUT,
68 struct platform_device tosascoop_device = {
69 .name = "sharp-scoop",
72 .platform_data = &tosa_scoop_setup,
74 .num_resources = ARRAY_SIZE(tosa_scoop_resources),
75 .resource = tosa_scoop_resources,
82 static struct resource tosa_scoop_jc_resources[] = {
84 .start = TOSA_SCOOP_PHYS + 0x40,
85 .end = TOSA_SCOOP_PHYS + 0xfff,
86 .flags = IORESOURCE_MEM,
90 static struct scoop_config tosa_scoop_jc_setup = {
91 .io_dir = TOSA_SCOOP_JC_IO_DIR,
92 .io_out = TOSA_SCOOP_JC_IO_OUT,
95 struct platform_device tosascoop_jc_device = {
96 .name = "sharp-scoop",
99 .platform_data = &tosa_scoop_jc_setup,
100 .parent = &tosascoop_device.dev,
102 .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
103 .resource = tosa_scoop_jc_resources,
109 static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
111 .dev = &tosascoop_device.dev,
112 .irq = TOSA_IRQ_GPIO_CF_IRQ,
113 .cd_irq = TOSA_IRQ_GPIO_CF_CD,
114 .cd_irq_str = "PCMCIA0 CD",
116 .dev = &tosascoop_jc_device.dev,
117 .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
122 static void tosa_pcmcia_init(void)
124 /* Setup default state of GPIO outputs
125 before we enable them as outputs. */
126 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
127 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
128 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
129 GPIO_bit(GPIO53_nPCE_2);
131 pxa_gpio_mode(GPIO48_nPOE_MD);
132 pxa_gpio_mode(GPIO49_nPWE_MD);
133 pxa_gpio_mode(GPIO50_nPIOR_MD);
134 pxa_gpio_mode(GPIO51_nPIOW_MD);
135 pxa_gpio_mode(GPIO55_nPREG_MD);
136 pxa_gpio_mode(GPIO56_nPWAIT_MD);
137 pxa_gpio_mode(GPIO57_nIOIS16_MD);
138 pxa_gpio_mode(GPIO52_nPCE_1_MD);
139 pxa_gpio_mode(GPIO53_nPCE_2_MD);
140 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
143 static struct scoop_pcmcia_config tosa_pcmcia_config = {
144 .devs = &tosa_pcmcia_scoop[0],
146 .pcmcia_init = tosa_pcmcia_init,
150 * USB Device Controller
152 static void tosa_udc_command(int cmd)
155 case PXA2XX_UDC_CMD_CONNECT:
156 set_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
158 case PXA2XX_UDC_CMD_DISCONNECT:
159 reset_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
164 static struct pxa2xx_udc_mach_info udc_info __initdata = {
165 .udc_command = tosa_udc_command,
166 .gpio_vbus = TOSA_GPIO_USB_IN,
167 .gpio_vbus_inverted = 1,
173 static struct pxamci_platform_data tosa_mci_platform_data;
175 static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
179 /* setup GPIO for PXA25x MMC controller */
180 pxa_gpio_mode(GPIO6_MMCCLK_MD);
181 pxa_gpio_mode(GPIO8_MMCCS0_MD);
182 pxa_gpio_mode(TOSA_GPIO_nSD_DETECT | GPIO_IN);
184 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
186 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
187 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
188 "MMC/SD card detect", data);
190 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
195 static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
197 struct pxamci_platform_data* p_d = dev->platform_data;
199 if (( 1 << vdd) & p_d->ocr_mask) {
200 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
202 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
206 static int tosa_mci_get_ro(struct device *dev)
208 return (read_scoop_reg(&tosascoop_device.dev, SCOOP_GPWR)&TOSA_SCOOP_SD_WP);
211 static void tosa_mci_exit(struct device *dev, void *data)
213 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
216 static struct pxamci_platform_data tosa_mci_platform_data = {
217 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
218 .init = tosa_mci_init,
219 .get_ro = tosa_mci_get_ro,
220 .setpower = tosa_mci_setpower,
221 .exit = tosa_mci_exit,
227 static void tosa_irda_transceiver_mode(struct device *dev, int mode)
230 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
231 pxa_gpio_mode(GPIO47_STTXD|GPIO_DFLT_LOW);
232 pxa_gpio_mode(GPIO47_STTXD|GPIO_OUT);
234 pxa_gpio_mode(GPIO47_STTXD_MD);
235 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
239 static struct pxaficp_platform_data tosa_ficp_platform_data = {
240 .transceiver_cap = IR_SIRMODE | IR_OFF,
241 .transceiver_mode = tosa_irda_transceiver_mode,
247 static struct platform_device tosakbd_device = {
248 .name = "tosa-keyboard",
252 static struct gpio_keys_button tosa_gpio_keys[] = {
256 .gpio = TOSA_GPIO_ON_KEY,
263 .code = TOSA_KEY_RECORD,
264 .gpio = TOSA_GPIO_RECORD_BTN,
265 .desc = "Record Button",
271 .code = TOSA_KEY_SYNC,
272 .gpio = TOSA_GPIO_SYNC,
273 .desc = "Sync Button",
279 static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
280 .buttons = tosa_gpio_keys,
281 .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
284 static struct platform_device tosa_gpio_keys_device = {
288 .platform_data = &tosa_gpio_keys_platform_data,
295 static struct platform_device tosaled_device = {
300 static struct platform_device *devices[] __initdata = {
302 &tosascoop_jc_device,
304 &tosa_gpio_keys_device,
308 static void tosa_poweroff(void)
310 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
312 pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_OUT);
313 GPSR(TOSA_GPIO_ON_RESET) = GPIO_bit(TOSA_GPIO_ON_RESET);
316 arm_machine_restart('h');
319 static void tosa_restart(char mode)
321 /* Bootloader magic for a reboot */
322 if((MSC0 & 0xffff0000) == 0x7ff00000)
323 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
328 static void __init tosa_init(void)
330 pm_power_off = tosa_poweroff;
331 arm_pm_restart = tosa_restart;
333 pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_IN);
334 pxa_gpio_mode(TOSA_GPIO_TC6393_INT | GPIO_IN);
335 pxa_gpio_mode(TOSA_GPIO_USB_IN | GPIO_IN);
337 /* setup sleep mode values */
346 /* enable batt_fault */
349 pxa_set_mci_info(&tosa_mci_platform_data);
350 pxa_set_udc_info(&udc_info);
351 pxa_set_ficp_info(&tosa_ficp_platform_data);
352 platform_scoop_config = &tosa_pcmcia_config;
354 platform_add_devices(devices, ARRAY_SIZE(devices));
357 static void __init fixup_tosa(struct machine_desc *desc,
358 struct tag *tags, char **cmdline, struct meminfo *mi)
360 sharpsl_save_param();
362 mi->bank[0].start = 0xa0000000;
363 mi->bank[0].node = 0;
364 mi->bank[0].size = (64*1024*1024);
367 MACHINE_START(TOSA, "SHARP Tosa")
368 .phys_io = 0x40000000,
369 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
371 .map_io = pxa_map_io,
372 .init_irq = pxa25x_init_irq,
373 .init_machine = tosa_init,