blob: 1a9c844ac7eb39e940903e8834a837513e2a9477 [file] [log] [blame]
Dirk Opfer8459c152005-11-06 14:27:52 +00001/*
2 * Support for Sharp SL-C6000x PDAs
3 * Model: (Tosa)
4 *
5 * Copyright (c) 2005 Dirk Opfer
6 *
7 * Based on code written by Sharp/Lineo for 2.4 kernels
8 *
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.
12 *
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
Dirk Opfer067c9042005-11-21 15:17:06 +000017#include <linux/platform_device.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000018#include <linux/major.h>
19#include <linux/fs.h>
20#include <linux/interrupt.h>
21#include <linux/mmc/host.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010022#include <linux/pm.h>
Russell King905f1462006-06-20 23:27:37 +010023#include <linux/delay.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000024
25#include <asm/setup.h>
26#include <asm/memory.h>
27#include <asm/mach-types.h>
28#include <asm/hardware.h>
29#include <asm/irq.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010030#include <asm/system.h>
Richard Purdie77483032007-03-07 00:02:15 +010031#include <asm/arch/pxa-regs.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000032#include <asm/arch/irda.h>
33#include <asm/arch/mmc.h>
34#include <asm/arch/udc.h>
35
36#include <asm/mach/arch.h>
37#include <asm/mach/map.h>
38#include <asm/mach/irq.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000039#include <asm/arch/tosa.h>
40
41#include <asm/hardware/scoop.h>
42#include <asm/mach/sharpsl_param.h>
43
44#include "generic.h"
Russell King46c41e62007-05-15 15:39:36 +010045#include "devices.h"
Dirk Opfer8459c152005-11-06 14:27:52 +000046
47/*
48 * SCOOP Device
49 */
50static struct resource tosa_scoop_resources[] = {
51 [0] = {
52 .start = TOSA_CF_PHYS,
53 .end = TOSA_CF_PHYS + 0xfff,
54 .flags = IORESOURCE_MEM,
55 },
56};
57
58static struct scoop_config tosa_scoop_setup = {
59 .io_dir = TOSA_SCOOP_IO_DIR,
60 .io_out = TOSA_SCOOP_IO_OUT,
61
62};
63
64struct platform_device tosascoop_device = {
65 .name = "sharp-scoop",
66 .id = 0,
67 .dev = {
68 .platform_data = &tosa_scoop_setup,
69 },
70 .num_resources = ARRAY_SIZE(tosa_scoop_resources),
71 .resource = tosa_scoop_resources,
72};
73
74
75/*
76 * SCOOP Device Jacket
77 */
78static struct resource tosa_scoop_jc_resources[] = {
79 [0] = {
80 .start = TOSA_SCOOP_PHYS + 0x40,
81 .end = TOSA_SCOOP_PHYS + 0xfff,
82 .flags = IORESOURCE_MEM,
83 },
84};
85
86static struct scoop_config tosa_scoop_jc_setup = {
87 .io_dir = TOSA_SCOOP_JC_IO_DIR,
88 .io_out = TOSA_SCOOP_JC_IO_OUT,
89};
90
91struct platform_device tosascoop_jc_device = {
92 .name = "sharp-scoop",
93 .id = 1,
94 .dev = {
95 .platform_data = &tosa_scoop_jc_setup,
96 .parent = &tosascoop_device.dev,
97 },
98 .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
99 .resource = tosa_scoop_jc_resources,
100};
101
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000102/*
103 * PCMCIA
104 */
Dirk Opfer8459c152005-11-06 14:27:52 +0000105static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
106{
107 .dev = &tosascoop_device.dev,
108 .irq = TOSA_IRQ_GPIO_CF_IRQ,
109 .cd_irq = TOSA_IRQ_GPIO_CF_CD,
110 .cd_irq_str = "PCMCIA0 CD",
111},{
112 .dev = &tosascoop_jc_device.dev,
113 .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
114 .cd_irq = -1,
115},
116};
117
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000118static void tosa_pcmcia_init(void)
119{
120 /* Setup default state of GPIO outputs
121 before we enable them as outputs. */
122 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
123 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
124 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
125 GPIO_bit(GPIO53_nPCE_2);
126
127 pxa_gpio_mode(GPIO48_nPOE_MD);
128 pxa_gpio_mode(GPIO49_nPWE_MD);
129 pxa_gpio_mode(GPIO50_nPIOR_MD);
130 pxa_gpio_mode(GPIO51_nPIOW_MD);
131 pxa_gpio_mode(GPIO55_nPREG_MD);
132 pxa_gpio_mode(GPIO56_nPWAIT_MD);
133 pxa_gpio_mode(GPIO57_nIOIS16_MD);
134 pxa_gpio_mode(GPIO52_nPCE_1_MD);
135 pxa_gpio_mode(GPIO53_nPCE_2_MD);
136 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
137}
138
139static struct scoop_pcmcia_config tosa_pcmcia_config = {
140 .devs = &tosa_pcmcia_scoop[0],
141 .num_devs = 2,
142 .pcmcia_init = tosa_pcmcia_init,
143};
144
Dirk Opfera93876c2005-11-08 19:15:30 +0000145/*
146 * USB Device Controller
147 */
148static void tosa_udc_command(int cmd)
149{
150 switch(cmd) {
151 case PXA2XX_UDC_CMD_CONNECT:
152 set_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
153 break;
154 case PXA2XX_UDC_CMD_DISCONNECT:
155 reset_scoop_gpio(&tosascoop_jc_device.dev,TOSA_SCOOP_JC_USB_PULLUP);
156 break;
157 }
158}
159
Dirk Opfera93876c2005-11-08 19:15:30 +0000160static struct pxa2xx_udc_mach_info udc_info __initdata = {
161 .udc_command = tosa_udc_command,
Dmitry Baryshkov487dc922007-12-21 12:18:01 +0300162 .gpio_vbus = TOSA_GPIO_USB_IN,
163 .gpio_vbus_inverted = 1,
Dirk Opfera93876c2005-11-08 19:15:30 +0000164};
165
166/*
167 * MMC/SD Device
168 */
169static struct pxamci_platform_data tosa_mci_platform_data;
170
David Howells40220c12006-10-09 12:19:47 +0100171static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
Dirk Opfera93876c2005-11-08 19:15:30 +0000172{
173 int err;
174
175 /* setup GPIO for PXA25x MMC controller */
176 pxa_gpio_mode(GPIO6_MMCCLK_MD);
177 pxa_gpio_mode(GPIO8_MMCCS0_MD);
178 pxa_gpio_mode(TOSA_GPIO_nSD_DETECT | GPIO_IN);
179
180 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
181
Russell King2687bd32008-01-23 14:05:58 +0000182 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
183 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Dirk Opfera93876c2005-11-08 19:15:30 +0000184 "MMC/SD card detect", data);
Russell King2687bd32008-01-23 14:05:58 +0000185 if (err)
Dirk Opfera93876c2005-11-08 19:15:30 +0000186 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
Dirk Opfera93876c2005-11-08 19:15:30 +0000187
Russell King2687bd32008-01-23 14:05:58 +0000188 return err;
Dirk Opfera93876c2005-11-08 19:15:30 +0000189}
190
191static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
192{
193 struct pxamci_platform_data* p_d = dev->platform_data;
194
195 if (( 1 << vdd) & p_d->ocr_mask) {
196 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
197 } else {
198 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_PWR_ON);
199 }
200}
201
202static int tosa_mci_get_ro(struct device *dev)
203{
204 return (read_scoop_reg(&tosascoop_device.dev, SCOOP_GPWR)&TOSA_SCOOP_SD_WP);
205}
206
207static void tosa_mci_exit(struct device *dev, void *data)
208{
209 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
210}
211
212static struct pxamci_platform_data tosa_mci_platform_data = {
213 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
214 .init = tosa_mci_init,
215 .get_ro = tosa_mci_get_ro,
216 .setpower = tosa_mci_setpower,
217 .exit = tosa_mci_exit,
218};
219
220/*
221 * Irda
222 */
223static void tosa_irda_transceiver_mode(struct device *dev, int mode)
224{
225 if (mode & IR_OFF) {
226 reset_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
227 pxa_gpio_mode(GPIO47_STTXD|GPIO_DFLT_LOW);
228 pxa_gpio_mode(GPIO47_STTXD|GPIO_OUT);
229 } else {
230 pxa_gpio_mode(GPIO47_STTXD_MD);
231 set_scoop_gpio(&tosascoop_device.dev,TOSA_SCOOP_IR_POWERDWN);
232 }
233}
234
235static struct pxaficp_platform_data tosa_ficp_platform_data = {
236 .transceiver_cap = IR_SIRMODE | IR_OFF,
237 .transceiver_mode = tosa_irda_transceiver_mode,
238};
239
240/*
241 * Tosa Keyboard
242 */
243static struct platform_device tosakbd_device = {
244 .name = "tosa-keyboard",
245 .id = -1,
246};
Dirk Opfer8459c152005-11-06 14:27:52 +0000247
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800248/*
249 * Tosa LEDs
250 */
251static struct platform_device tosaled_device = {
252 .name = "tosa-led",
253 .id = -1,
254};
255
Dirk Opfer8459c152005-11-06 14:27:52 +0000256static struct platform_device *devices[] __initdata = {
257 &tosascoop_device,
258 &tosascoop_jc_device,
Dirk Opfera93876c2005-11-08 19:15:30 +0000259 &tosakbd_device,
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800260 &tosaled_device,
Dirk Opfer8459c152005-11-06 14:27:52 +0000261};
262
Richard Purdie74617fb2006-06-19 19:57:12 +0100263static void tosa_poweroff(void)
264{
265 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
266
267 pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_OUT);
268 GPSR(TOSA_GPIO_ON_RESET) = GPIO_bit(TOSA_GPIO_ON_RESET);
269
270 mdelay(1000);
271 arm_machine_restart('h');
272}
273
274static void tosa_restart(char mode)
275{
276 /* Bootloader magic for a reboot */
277 if((MSC0 & 0xffff0000) == 0x7ff00000)
278 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
279
280 tosa_poweroff();
281}
282
Dirk Opfer8459c152005-11-06 14:27:52 +0000283static void __init tosa_init(void)
284{
Richard Purdie74617fb2006-06-19 19:57:12 +0100285 pm_power_off = tosa_poweroff;
286 arm_pm_restart = tosa_restart;
287
Dirk Opfer8459c152005-11-06 14:27:52 +0000288 pxa_gpio_mode(TOSA_GPIO_ON_RESET | GPIO_IN);
289 pxa_gpio_mode(TOSA_GPIO_TC6393_INT | GPIO_IN);
Dirk Opfera93876c2005-11-08 19:15:30 +0000290 pxa_gpio_mode(TOSA_GPIO_USB_IN | GPIO_IN);
Dirk Opfer8459c152005-11-06 14:27:52 +0000291
292 /* setup sleep mode values */
293 PWER = 0x00000002;
294 PFER = 0x00000000;
295 PRER = 0x00000002;
296 PGSR0 = 0x00000000;
297 PGSR1 = 0x00FF0002;
298 PGSR2 = 0x00014000;
299 PCFR |= PCFR_OPDE;
300
Dirk Opfera93876c2005-11-08 19:15:30 +0000301 /* enable batt_fault */
Dirk Opfer8459c152005-11-06 14:27:52 +0000302 PMCR = 0x01;
303
Dirk Opfera93876c2005-11-08 19:15:30 +0000304 pxa_set_mci_info(&tosa_mci_platform_data);
305 pxa_set_udc_info(&udc_info);
306 pxa_set_ficp_info(&tosa_ficp_platform_data);
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000307 platform_scoop_config = &tosa_pcmcia_config;
Dirk Opfer8459c152005-11-06 14:27:52 +0000308
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000309 platform_add_devices(devices, ARRAY_SIZE(devices));
Dirk Opfer8459c152005-11-06 14:27:52 +0000310}
311
312static void __init fixup_tosa(struct machine_desc *desc,
313 struct tag *tags, char **cmdline, struct meminfo *mi)
314{
315 sharpsl_save_param();
316 mi->nr_banks=1;
317 mi->bank[0].start = 0xa0000000;
318 mi->bank[0].node = 0;
319 mi->bank[0].size = (64*1024*1024);
320}
321
322MACHINE_START(TOSA, "SHARP Tosa")
Dirk Opfer8459c152005-11-06 14:27:52 +0000323 .phys_io = 0x40000000,
324 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
325 .fixup = fixup_tosa,
326 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100327 .init_irq = pxa25x_init_irq,
Dirk Opfer8459c152005-11-06 14:27:52 +0000328 .init_machine = tosa_init,
329 .timer = &pxa_timer,
330MACHINE_END