blob: 2363cc64fe076b2a19268407f52e1f3bd11f6688 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Support for Sharp SL-C7xx PDAs
3 * Models: SL-C700 (Corgi), SL-C750 (Shepherd), SL-C760 (Husky)
4 *
5 * Copyright (c) 2004-2005 Richard Purdie
6 *
7 * Based on Sharp's 2.4 kernel patches/lubbock.c
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>
Russell Kingd052d1b2005-10-29 19:07:23 +010017#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#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>
Richard Purdiec3f8f652007-09-03 00:27:00 +010023#include <linux/backlight.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
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>
30#include <asm/io.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010031#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33#include <asm/mach/arch.h>
34#include <asm/mach/map.h>
35#include <asm/mach/irq.h>
36
37#include <asm/arch/pxa-regs.h>
Richard Purdieca1140b2005-10-30 14:38:53 +000038#include <asm/arch/irda.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <asm/arch/mmc.h>
40#include <asm/arch/udc.h>
41#include <asm/arch/corgi.h>
Richard Purdie10362602005-10-10 10:17:45 +010042#include <asm/arch/sharpsl.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
44#include <asm/mach/sharpsl_param.h>
45#include <asm/hardware/scoop.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47#include "generic.h"
Russell King46c41e62007-05-15 15:39:36 +010048#include "devices.h"
Richard Purdie50a5de42005-09-13 01:25:30 -070049#include "sharpsl.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51
52/*
53 * Corgi SCOOP Device
54 */
55static struct resource corgi_scoop_resources[] = {
56 [0] = {
57 .start = 0x10800000,
58 .end = 0x10800fff,
59 .flags = IORESOURCE_MEM,
60 },
61};
62
63static struct scoop_config corgi_scoop_setup = {
64 .io_dir = CORGI_SCOOP_IO_DIR,
65 .io_out = CORGI_SCOOP_IO_OUT,
66};
67
68struct platform_device corgiscoop_device = {
69 .name = "sharp-scoop",
70 .id = -1,
71 .dev = {
72 .platform_data = &corgi_scoop_setup,
73 },
74 .num_resources = ARRAY_SIZE(corgi_scoop_resources),
75 .resource = corgi_scoop_resources,
76};
77
Richard Purdiea63ae442005-11-08 19:15:43 +000078static void corgi_pcmcia_init(void)
79{
80 /* Setup default state of GPIO outputs
81 before we enable them as outputs. */
82 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
83 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
84 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO52_nPCE_1) |
85 GPIO_bit(GPIO53_nPCE_2);
86
87 pxa_gpio_mode(GPIO48_nPOE_MD);
88 pxa_gpio_mode(GPIO49_nPWE_MD);
89 pxa_gpio_mode(GPIO50_nPIOR_MD);
90 pxa_gpio_mode(GPIO51_nPIOW_MD);
91 pxa_gpio_mode(GPIO55_nPREG_MD);
92 pxa_gpio_mode(GPIO56_nPWAIT_MD);
93 pxa_gpio_mode(GPIO57_nIOIS16_MD);
94 pxa_gpio_mode(GPIO52_nPCE_1_MD);
95 pxa_gpio_mode(GPIO53_nPCE_2_MD);
96 pxa_gpio_mode(GPIO54_pSKTSEL_MD);
97}
98
99static struct scoop_pcmcia_dev corgi_pcmcia_scoop[] = {
100{
101 .dev = &corgiscoop_device.dev,
102 .irq = CORGI_IRQ_GPIO_CF_IRQ,
103 .cd_irq = CORGI_IRQ_GPIO_CF_CD,
104 .cd_irq_str = "PCMCIA0 CD",
105},
106};
107
108static struct scoop_pcmcia_config corgi_pcmcia_config = {
109 .devs = &corgi_pcmcia_scoop[0],
110 .num_devs = 1,
111 .pcmcia_init = corgi_pcmcia_init,
112};
113
114EXPORT_SYMBOL(corgiscoop_device);
115
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
117/*
118 * Corgi SSP Device
119 *
120 * Set the parent as the scoop device because a lot of SSP devices
121 * also use scoop functions and this makes the power up/down order
122 * work correctly.
123 */
Richard Purdie41b1bce2005-09-06 15:19:05 -0700124struct platform_device corgissp_device = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 .name = "corgi-ssp",
126 .dev = {
127 .parent = &corgiscoop_device.dev,
128 },
129 .id = -1,
130};
131
Richard Purdie50a5de42005-09-13 01:25:30 -0700132struct corgissp_machinfo corgi_ssp_machinfo = {
133 .port = 1,
134 .cs_lcdcon = CORGI_GPIO_LCDCON_CS,
135 .cs_ads7846 = CORGI_GPIO_ADS7846_CS,
136 .cs_max1111 = CORGI_GPIO_MAX1111_CS,
137 .clk_lcdcon = 76,
138 .clk_ads7846 = 2,
139 .clk_max1111 = 8,
140};
141
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
143/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 * Corgi Backlight Device
145 */
Richard Purdiec3f8f652007-09-03 00:27:00 +0100146static void corgi_bl_kick_battery(void)
147{
148 void (*kick_batt)(void);
149
150 kick_batt = symbol_get(sharpsl_battery_kick);
151 if (kick_batt) {
152 kick_batt();
153 symbol_put(sharpsl_battery_kick);
154 }
155}
156
157static struct generic_bl_info corgi_bl_machinfo = {
158 .name = "corgi-bl",
Richard Purdie1351e6e2005-09-13 01:25:33 -0700159 .max_intensity = 0x2f,
Richard Purdie2c0f5fb2006-03-31 02:31:51 -0800160 .default_intensity = 0x1f,
161 .limit_mask = 0x0b,
Richard Purdie1351e6e2005-09-13 01:25:33 -0700162 .set_bl_intensity = corgi_bl_set_intensity,
Richard Purdiec3f8f652007-09-03 00:27:00 +0100163 .kick_battery = corgi_bl_kick_battery,
Richard Purdie1351e6e2005-09-13 01:25:33 -0700164};
165
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166static struct platform_device corgibl_device = {
Richard Purdiec3f8f652007-09-03 00:27:00 +0100167 .name = "generic-bl",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 .dev = {
169 .parent = &corgifb_device.dev,
Richard Purdie1351e6e2005-09-13 01:25:33 -0700170 .platform_data = &corgi_bl_machinfo,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 },
172 .id = -1,
173};
174
175
176/*
Richard Purdief7ceff32005-09-06 15:19:07 -0700177 * Corgi Keyboard Device
178 */
179static struct platform_device corgikbd_device = {
180 .name = "corgi-keyboard",
181 .id = -1,
182};
183
184
185/*
Richard Purdie31791082006-03-31 02:31:09 -0800186 * Corgi LEDs
187 */
188static struct platform_device corgiled_device = {
189 .name = "corgi-led",
190 .id = -1,
191};
192
193/*
Richard Purdief7ceff32005-09-06 15:19:07 -0700194 * Corgi Touch Screen Device
195 */
Richard Purdie513b6e12005-09-13 01:25:33 -0700196static struct resource corgits_resources[] = {
197 [0] = {
198 .start = CORGI_IRQ_GPIO_TP_INT,
199 .end = CORGI_IRQ_GPIO_TP_INT,
200 .flags = IORESOURCE_IRQ,
201 },
202};
203
204static struct corgits_machinfo corgi_ts_machinfo = {
205 .get_hsync_len = corgi_get_hsync_len,
206 .put_hsync = corgi_put_hsync,
207 .wait_hsync = corgi_wait_hsync,
208};
209
Richard Purdief7ceff32005-09-06 15:19:07 -0700210static struct platform_device corgits_device = {
211 .name = "corgi-ts",
212 .dev = {
213 .parent = &corgissp_device.dev,
Richard Purdie513b6e12005-09-13 01:25:33 -0700214 .platform_data = &corgi_ts_machinfo,
Richard Purdief7ceff32005-09-06 15:19:07 -0700215 },
216 .id = -1,
Richard Purdie513b6e12005-09-13 01:25:33 -0700217 .num_resources = ARRAY_SIZE(corgits_resources),
218 .resource = corgits_resources,
Richard Purdief7ceff32005-09-06 15:19:07 -0700219};
220
221
222/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 * MMC/SD Device
224 *
Richard Purdieaa6c2e72005-09-09 18:54:03 +0100225 * The card detect interrupt isn't debounced so we delay it by 250ms
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 * to give the card a chance to fully insert/eject.
227 */
Richard Purdieaa6c2e72005-09-09 18:54:03 +0100228static struct pxamci_platform_data corgi_mci_platform_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
David Howells40220c12006-10-09 12:19:47 +0100230static int corgi_mci_init(struct device *dev, irq_handler_t corgi_detect_int, void *data)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231{
232 int err;
233
234 /* setup GPIO for PXA25x MMC controller */
235 pxa_gpio_mode(GPIO6_MMCCLK_MD);
236 pxa_gpio_mode(GPIO8_MMCCS0_MD);
237 pxa_gpio_mode(CORGI_GPIO_nSD_DETECT | GPIO_IN);
238 pxa_gpio_mode(CORGI_GPIO_SD_PWR | GPIO_OUT);
239
Richard Purdieaa6c2e72005-09-09 18:54:03 +0100240 corgi_mci_platform_data.detect_delay = msecs_to_jiffies(250);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241
Russell King9ded96f2006-01-08 01:02:07 -0800242 err = request_irq(CORGI_IRQ_GPIO_nSD_DETECT, corgi_detect_int,
Thomas Gleixner52e405e2006-07-03 02:20:05 +0200243 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Russell King9ded96f2006-01-08 01:02:07 -0800244 "MMC card detect", data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 if (err) {
246 printk(KERN_ERR "corgi_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
247 return -1;
248 }
249
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 return 0;
251}
252
253static void corgi_mci_setpower(struct device *dev, unsigned int vdd)
254{
255 struct pxamci_platform_data* p_d = dev->platform_data;
256
Richard Purdiefdce05b2005-09-15 14:53:21 +0100257 if (( 1 << vdd) & p_d->ocr_mask)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 GPSR1 = GPIO_bit(CORGI_GPIO_SD_PWR);
Richard Purdiefdce05b2005-09-15 14:53:21 +0100259 else
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 GPCR1 = GPIO_bit(CORGI_GPIO_SD_PWR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261}
262
Richard Purdie3870ee82005-09-06 15:19:07 -0700263static int corgi_mci_get_ro(struct device *dev)
264{
265 return GPLR(CORGI_GPIO_nSD_WP) & GPIO_bit(CORGI_GPIO_nSD_WP);
266}
267
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268static void corgi_mci_exit(struct device *dev, void *data)
269{
270 free_irq(CORGI_IRQ_GPIO_nSD_DETECT, data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271}
272
273static struct pxamci_platform_data corgi_mci_platform_data = {
274 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
275 .init = corgi_mci_init,
Richard Purdie3870ee82005-09-06 15:19:07 -0700276 .get_ro = corgi_mci_get_ro,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 .setpower = corgi_mci_setpower,
278 .exit = corgi_mci_exit,
279};
280
281
Richard Purdieca1140b2005-10-30 14:38:53 +0000282/*
283 * Irda
284 */
285static void corgi_irda_transceiver_mode(struct device *dev, int mode)
286{
287 if (mode & IR_OFF)
288 GPSR(CORGI_GPIO_IR_ON) = GPIO_bit(CORGI_GPIO_IR_ON);
289 else
290 GPCR(CORGI_GPIO_IR_ON) = GPIO_bit(CORGI_GPIO_IR_ON);
291}
292
293static struct pxaficp_platform_data corgi_ficp_platform_data = {
294 .transceiver_cap = IR_SIRMODE | IR_OFF,
295 .transceiver_mode = corgi_irda_transceiver_mode,
296};
297
Richard Purdief7ceff32005-09-06 15:19:07 -0700298
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299/*
300 * USB Device Controller
301 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302static struct pxa2xx_udc_mach_info udc_info __initdata = {
303 /* no connect GPIO; corgi can't tell connection status */
David Brownellb2bbb202006-06-29 12:25:39 -0700304 .gpio_pullup = CORGI_GPIO_USB_PULLUP,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305};
306
307
308static struct platform_device *devices[] __initdata = {
309 &corgiscoop_device,
310 &corgissp_device,
311 &corgifb_device,
Richard Purdief7ceff32005-09-06 15:19:07 -0700312 &corgikbd_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 &corgibl_device,
Richard Purdief7ceff32005-09-06 15:19:07 -0700314 &corgits_device,
Richard Purdie31791082006-03-31 02:31:09 -0800315 &corgiled_device,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316};
317
Richard Purdie74617fb2006-06-19 19:57:12 +0100318static void corgi_poweroff(void)
319{
320 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
321
322 if (!machine_is_corgi())
323 /* Green LED off tells the bootloader to halt */
324 reset_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
325 arm_machine_restart('h');
326}
327
328static void corgi_restart(char mode)
329{
330 RCSR = RCSR_HWR | RCSR_WDR | RCSR_SMR | RCSR_GPR;
331
332 if (!machine_is_corgi())
333 /* Green LED on tells the bootloader to reboot */
334 set_scoop_gpio(&corgiscoop_device.dev, CORGI_SCP_LED_GREEN);
335 arm_machine_restart('h');
336}
337
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338static void __init corgi_init(void)
339{
Richard Purdie74617fb2006-06-19 19:57:12 +0100340 pm_power_off = corgi_poweroff;
341 arm_pm_restart = corgi_restart;
342
Richard Purdiefdce05b2005-09-15 14:53:21 +0100343 /* setup sleep mode values */
344 PWER = 0x00000002;
345 PFER = 0x00000000;
346 PRER = 0x00000002;
347 PGSR0 = 0x0158C000;
348 PGSR1 = 0x00FF0080;
349 PGSR2 = 0x0001C004;
350 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
351 PCFR |= PCFR_OPDE;
352
Richard Purdie50a5de42005-09-13 01:25:30 -0700353 corgi_ssp_set_machinfo(&corgi_ssp_machinfo);
354
Richard Purdieca1140b2005-10-30 14:38:53 +0000355 pxa_gpio_mode(CORGI_GPIO_IR_ON | GPIO_OUT);
Richard Purdie513b6e12005-09-13 01:25:33 -0700356 pxa_gpio_mode(CORGI_GPIO_HSYNC | GPIO_IN);
Richard Purdieca1140b2005-10-30 14:38:53 +0000357
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 pxa_set_udc_info(&udc_info);
359 pxa_set_mci_info(&corgi_mci_platform_data);
Richard Purdieca1140b2005-10-30 14:38:53 +0000360 pxa_set_ficp_info(&corgi_ficp_platform_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361
Richard Purdiea63ae442005-11-08 19:15:43 +0000362 platform_scoop_config = &corgi_pcmcia_config;
Richard Purdie0ce76252005-09-05 20:49:54 +0100363
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 platform_add_devices(devices, ARRAY_SIZE(devices));
365}
366
367static void __init fixup_corgi(struct machine_desc *desc,
368 struct tag *tags, char **cmdline, struct meminfo *mi)
369{
370 sharpsl_save_param();
371 mi->nr_banks=1;
372 mi->bank[0].start = 0xa0000000;
373 mi->bank[0].node = 0;
374 if (machine_is_corgi())
375 mi->bank[0].size = (32*1024*1024);
376 else
377 mi->bank[0].size = (64*1024*1024);
378}
379
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380#ifdef CONFIG_MACH_CORGI
381MACHINE_START(CORGI, "SHARP Corgi")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100382 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100383 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100384 .fixup = fixup_corgi,
Richard Purdiefdce05b2005-09-15 14:53:21 +0100385 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100386 .init_irq = pxa25x_init_irq,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100387 .init_machine = corgi_init,
388 .timer = &pxa_timer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389MACHINE_END
390#endif
391
392#ifdef CONFIG_MACH_SHEPHERD
393MACHINE_START(SHEPHERD, "SHARP Shepherd")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100394 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100395 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100396 .fixup = fixup_corgi,
Richard Purdiefdce05b2005-09-15 14:53:21 +0100397 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100398 .init_irq = pxa25x_init_irq,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100399 .init_machine = corgi_init,
400 .timer = &pxa_timer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401MACHINE_END
402#endif
403
404#ifdef CONFIG_MACH_HUSKY
405MACHINE_START(HUSKY, "SHARP Husky")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100406 .phys_io = 0x40000000,
Russell King68070bd2005-07-04 10:44:34 +0100407 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100408 .fixup = fixup_corgi,
Richard Purdiefdce05b2005-09-15 14:53:21 +0100409 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100410 .init_irq = pxa25x_init_irq,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100411 .init_machine = corgi_init,
412 .timer = &pxa_timer,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413MACHINE_END
414#endif
415