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 <asm/setup.h>
24 #include <asm/memory.h>
25 #include <asm/mach-types.h>
26 #include <asm/hardware.h>
28 #include <asm/arch/irda.h>
29 #include <asm/arch/mmc.h>
30 #include <asm/arch/udc.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34 #include <asm/mach/irq.h>
36 #include <asm/arch/pxa-regs.h>
37 #include <asm/arch/irq.h>
38 #include <asm/arch/tosa.h>
40 #include <asm/hardware/scoop.h>
41 #include <asm/mach/sharpsl_param.h>
49 static struct resource tosa_scoop_resources[] = {
51 .start = TOSA_CF_PHYS,
52 .end = TOSA_CF_PHYS + 0xfff,
53 .flags = IORESOURCE_MEM,
57 static struct scoop_config tosa_scoop_setup = {
58 .io_dir = TOSA_SCOOP_IO_DIR,
59 .io_out = TOSA_SCOOP_IO_OUT,
63 struct platform_device tosascoop_device = {
64 .name = "sharp-scoop",
67 .platform_data = &tosa_scoop_setup,
69 .num_resources = ARRAY_SIZE(tosa_scoop_resources),
70 .resource = tosa_scoop_resources,
77 static struct resource tosa_scoop_jc_resources[] = {
79 .start = TOSA_SCOOP_PHYS + 0x40,
80 .end = TOSA_SCOOP_PHYS + 0xfff,
81 .flags = IORESOURCE_MEM,
85 static struct scoop_config tosa_scoop_jc_setup = {
86 .io_dir = TOSA_SCOOP_JC_IO_DIR,
87 .io_out = TOSA_SCOOP_JC_IO_OUT,
90 struct platform_device tosascoop_jc_device = {
91 .name = "sharp-scoop",
94 .platform_data = &tosa_scoop_jc_setup,
95 .parent = &tosascoop_device.dev,
97 .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
98 .resource = tosa_scoop_jc_resources,
104 static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
106 .dev = &tosascoop_device.dev,
107 .irq = TOSA_IRQ_GPIO_CF_IRQ,
108 .cd_irq = TOSA_IRQ_GPIO_CF_CD,
109 .cd_irq_str = "PCMCIA0 CD",
111 .dev = &tosascoop_jc_device.dev,
112 .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
117 static void tosa_pcmcia_init(void)
119 /* Setup default state of GPIO outputs
120 before we enable them as outputs. */
121 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
122 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
123 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
124 GPIO_bit(GPIO53_nPCE_2);
126 pxa_gpio_mode(GPIO48_nPOE_MD);
127 pxa_gpio_mode(GPIO49_nPWE_MD);
128 pxa_gpio_mode(GPIO50_nPIOR_MD);
129 pxa_gpio_mode(GPIO51_nPIOW_MD);
130 pxa_gpio_mode(GPIO55_nPREG_MD);
131 pxa_gpio_mode(GPIO56_nPWAIT_MD);
132 pxa_gpio_mode(GPIO57_nIOIS16_MD);
133 pxa_gpio_mode(GPIO52_nPCE_1_MD);
134 pxa_gpio_mode(GPIO53_nPCE_2_MD);
135 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
138 static struct scoop_pcmcia_config tosa_pcmcia_config = {
139 .devs = &tosa_pcmcia_scoop[0],
141 .pcmcia_init = tosa_pcmcia_init,
145 * USB Device Controller
147 static void tosa_udc_command(int cmd)
150 case PXA2XX_UDC_CMD_CONNECT:
151 set_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
153 case PXA2XX_UDC_CMD_DISCONNECT:
154 reset_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
159 static int tosa_udc_is_connected(void)
161 return ((GPLR(TOSA_GPIO_USB_IN) & GPIO_bit(TOSA_GPIO_USB_IN)) == 0);
165 static struct pxa2xx_udc_mach_info udc_info __initdata = {
166 .udc_command = tosa_udc_command,
167 .udc_is_connected = tosa_udc_is_connected,
173 static struct pxamci_platform_data tosa_mci_platform_data;
175 static int tosa_mci_init(struct device *dev, irqreturn_t (*tosa_detect_int)(int, void *, struct pt_regs *), 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, SA_INTERRUPT,
187 "MMC/SD card detect", data);
189 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
193 set_irq_type(TOSA_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
198 static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
200 struct pxamci_platform_data* p_d = dev->platform_data;
202 if (( 1 << vdd) & p_d->ocr_mask) {
203 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
205 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
209 static int tosa_mci_get_ro(struct device *dev)
211 return (read_scoop_reg(&tosascoop_device.dev, SCOOP_GPWR)&TOSA_SCOOP_SD_WP);
214 static void tosa_mci_exit(struct device *dev, void *data)
216 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
219 static struct pxamci_platform_data tosa_mci_platform_data = {
220 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
221 .init = tosa_mci_init,
222 .get_ro = tosa_mci_get_ro,
223 .setpower = tosa_mci_setpower,
224 .exit = tosa_mci_exit,
230 static void tosa_irda_transceiver_mode(struct device *dev, int mode)
233 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
234 pxa_gpio_mode(GPIO47_STTXD|GPIO_DFLT_LOW);
235 pxa_gpio_mode(GPIO47_STTXD|GPIO_OUT);
237 pxa_gpio_mode(GPIO47_STTXD_MD);
238 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
242 static struct pxaficp_platform_data tosa_ficp_platform_data = {
243 .transceiver_cap = IR_SIRMODE | IR_OFF,
244 .transceiver_mode = tosa_irda_transceiver_mode,
250 static struct platform_device tosakbd_device = {
251 .name = "tosa-keyboard",
255 static struct platform_device *devices[] __initdata = {
257 &tosascoop_jc_device,
261 static void __init tosa_init(void)
263 pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_IN);
264 pxa_gpio_mode(TOSA_GPIO_TC6393_INT | GPIO_IN);
265 pxa_gpio_mode(TOSA_GPIO_USB_IN | GPIO_IN);
267 /* setup sleep mode values */
276 /* enable batt_fault */
279 pxa_set_mci_info(&tosa_mci_platform_data);
280 pxa_set_udc_info(&udc_info);
281 pxa_set_ficp_info(&tosa_ficp_platform_data);
282 platform_scoop_config = &tosa_pcmcia_config;
284 platform_add_devices(devices, ARRAY_SIZE(devices));
287 static void __init fixup_tosa(struct machine_desc *desc,
288 struct tag *tags, char **cmdline, struct meminfo *mi)
290 sharpsl_save_param();
292 mi->bank[0].start = 0xa0000000;
293 mi->bank[0].node = 0;
294 mi->bank[0].size = (64*1024*1024);
297 MACHINE_START(TOSA, "SHARP Tosa")
298 .phys_io = 0x40000000,
299 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
301 .map_io = pxa_map_io,
302 .init_irq = pxa_init_irq,
303 .init_machine = tosa_init,