blob: 5d34abc64af7780902018bf9be18c67ddde3ac7f [file] [log] [blame]
Richard Purdie0dd28f12005-09-13 01:25:34 -07001/*
2 * Support for Sharp SL-Cxx00 Series of PDAs
3 * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi)
4 *
5 * Copyright (c) 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>
Richard Purdie0dd28f12005-09-13 01:25:34 -070018#include <linux/delay.h>
19#include <linux/major.h>
20#include <linux/fs.h>
21#include <linux/interrupt.h>
22#include <linux/mmc/host.h>
23
24#include <asm/setup.h>
25#include <asm/memory.h>
26#include <asm/mach-types.h>
27#include <asm/hardware.h>
28#include <asm/irq.h>
29#include <asm/io.h>
30
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33#include <asm/mach/irq.h>
34
35#include <asm/arch/pxa-regs.h>
36#include <asm/arch/irq.h>
Richard Purdiedc078452005-10-30 14:50:25 +000037#include <asm/arch/irda.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070038#include <asm/arch/mmc.h>
Richard Purdie3125c682006-01-05 20:44:52 +000039#include <asm/arch/ohci.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070040#include <asm/arch/udc.h>
Richard Purdie0dd28f12005-09-13 01:25:34 -070041#include <asm/arch/pxafb.h>
42#include <asm/arch/akita.h>
43#include <asm/arch/spitz.h>
44#include <asm/arch/sharpsl.h>
45
46#include <asm/mach/sharpsl_param.h>
47#include <asm/hardware/scoop.h>
48
49#include "generic.h"
50#include "sharpsl.h"
51
52/*
53 * Spitz SCOOP Device #1
54 */
55static struct resource spitz_scoop_resources[] = {
56 [0] = {
57 .start = 0x10800000,
58 .end = 0x10800fff,
59 .flags = IORESOURCE_MEM,
60 },
61};
62
63static struct scoop_config spitz_scoop_setup = {
64 .io_dir = SPITZ_SCP_IO_DIR,
65 .io_out = SPITZ_SCP_IO_OUT,
66 .suspend_clr = SPITZ_SCP_SUS_CLR,
67 .suspend_set = SPITZ_SCP_SUS_SET,
68};
69
70struct platform_device spitzscoop_device = {
71 .name = "sharp-scoop",
72 .id = 0,
73 .dev = {
74 .platform_data = &spitz_scoop_setup,
75 },
76 .num_resources = ARRAY_SIZE(spitz_scoop_resources),
77 .resource = spitz_scoop_resources,
78};
79
80/*
81 * Spitz SCOOP Device #2
82 */
83static struct resource spitz_scoop2_resources[] = {
84 [0] = {
85 .start = 0x08800040,
86 .end = 0x08800fff,
87 .flags = IORESOURCE_MEM,
88 },
89};
90
91static struct scoop_config spitz_scoop2_setup = {
92 .io_dir = SPITZ_SCP2_IO_DIR,
93 .io_out = SPITZ_SCP2_IO_OUT,
94 .suspend_clr = SPITZ_SCP2_SUS_CLR,
95 .suspend_set = SPITZ_SCP2_SUS_SET,
96};
97
98struct platform_device spitzscoop2_device = {
99 .name = "sharp-scoop",
100 .id = 1,
101 .dev = {
102 .platform_data = &spitz_scoop2_setup,
103 },
104 .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
105 .resource = spitz_scoop2_resources,
106};
107
Richard Purdiea63ae442005-11-08 19:15:43 +0000108#define SPITZ_PWR_SD 0x01
109#define SPITZ_PWR_CF 0x02
110
111/* Power control is shared with between one of the CF slots and SD */
112static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
113{
114 unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
115
116 if (new_cpr & 0x0007) {
117 set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
118 if (!(cpr & 0x0002) && !(cpr & 0x0004))
119 mdelay(5);
120 if (device == SPITZ_PWR_CF)
121 cpr |= 0x0002;
122 if (device == SPITZ_PWR_SD)
123 cpr |= 0x0004;
124 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
125 } else {
126 if (device == SPITZ_PWR_CF)
127 cpr &= ~0x0002;
128 if (device == SPITZ_PWR_SD)
129 cpr &= ~0x0004;
130 write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
131 if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
132 mdelay(1);
133 reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER);
134 }
135 }
136}
137
138static void spitz_pcmcia_init(void)
139{
140 /* Setup default state of GPIO outputs
141 before we enable them as outputs. */
142 GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nPOE) |
143 GPIO_bit(GPIO49_nPWE) | GPIO_bit(GPIO50_nPIOR) |
144 GPIO_bit(GPIO51_nPIOW) | GPIO_bit(GPIO54_nPCE_2);
145 GPSR(GPIO85_nPCE_1) = GPIO_bit(GPIO85_nPCE_1);
146
147 pxa_gpio_mode(GPIO48_nPOE_MD);
148 pxa_gpio_mode(GPIO49_nPWE_MD);
149 pxa_gpio_mode(GPIO50_nPIOR_MD);
150 pxa_gpio_mode(GPIO51_nPIOW_MD);
151 pxa_gpio_mode(GPIO55_nPREG_MD);
152 pxa_gpio_mode(GPIO56_nPWAIT_MD);
153 pxa_gpio_mode(GPIO57_nIOIS16_MD);
154 pxa_gpio_mode(GPIO85_nPCE_1_MD);
155 pxa_gpio_mode(GPIO54_nPCE_2_MD);
156 pxa_gpio_mode(GPIO104_pSKTSEL_MD);
157}
158
159static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
160{
161 /* Only need to override behaviour for slot 0 */
162 if (nr == 0)
163 spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
164 else
165 write_scoop_reg(scoop, SCOOP_CPR, cpr);
166}
167
Richard Purdie0dd28f12005-09-13 01:25:34 -0700168static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
169{
170 .dev = &spitzscoop_device.dev,
171 .irq = SPITZ_IRQ_GPIO_CF_IRQ,
172 .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
173 .cd_irq_str = "PCMCIA0 CD",
174},{
175 .dev = &spitzscoop2_device.dev,
176 .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
177 .cd_irq = -1,
178},
179};
180
Richard Purdiea63ae442005-11-08 19:15:43 +0000181static struct scoop_pcmcia_config spitz_pcmcia_config = {
182 .devs = &spitz_pcmcia_scoop[0],
183 .num_devs = 2,
184 .pcmcia_init = spitz_pcmcia_init,
185 .power_ctrl = spitz_pcmcia_pwr,
186};
187
188EXPORT_SYMBOL(spitzscoop_device);
189EXPORT_SYMBOL(spitzscoop2_device);
190
Richard Purdie0dd28f12005-09-13 01:25:34 -0700191
192/*
193 * Spitz SSP Device
194 *
195 * Set the parent as the scoop device because a lot of SSP devices
196 * also use scoop functions and this makes the power up/down order
197 * work correctly.
198 */
199struct platform_device spitzssp_device = {
200 .name = "corgi-ssp",
201 .dev = {
202 .parent = &spitzscoop_device.dev,
203 },
204 .id = -1,
205};
206
207struct corgissp_machinfo spitz_ssp_machinfo = {
208 .port = 2,
209 .cs_lcdcon = SPITZ_GPIO_LCDCON_CS,
210 .cs_ads7846 = SPITZ_GPIO_ADS7846_CS,
211 .cs_max1111 = SPITZ_GPIO_MAX1111_CS,
212 .clk_lcdcon = 520,
213 .clk_ads7846 = 14,
214 .clk_max1111 = 56,
215};
216
217
218/*
219 * Spitz Backlight Device
220 */
221static struct corgibl_machinfo spitz_bl_machinfo = {
222 .max_intensity = 0x2f,
223};
224
225static struct platform_device spitzbl_device = {
226 .name = "corgi-bl",
227 .dev = {
228 .platform_data = &spitz_bl_machinfo,
229 },
230 .id = -1,
231};
232
233
234/*
235 * Spitz Keyboard Device
236 */
237static struct platform_device spitzkbd_device = {
238 .name = "spitz-keyboard",
239 .id = -1,
240};
241
242
243/*
244 * Spitz Touch Screen Device
245 */
246static struct resource spitzts_resources[] = {
247 [0] = {
248 .start = SPITZ_IRQ_GPIO_TP_INT,
249 .end = SPITZ_IRQ_GPIO_TP_INT,
250 .flags = IORESOURCE_IRQ,
251 },
252};
253
254static struct corgits_machinfo spitz_ts_machinfo = {
255 .get_hsync_len = spitz_get_hsync_len,
256 .put_hsync = spitz_put_hsync,
257 .wait_hsync = spitz_wait_hsync,
258};
259
260static struct platform_device spitzts_device = {
261 .name = "corgi-ts",
262 .dev = {
263 .parent = &spitzssp_device.dev,
264 .platform_data = &spitz_ts_machinfo,
265 },
266 .id = -1,
267 .num_resources = ARRAY_SIZE(spitzts_resources),
268 .resource = spitzts_resources,
269};
270
271
272/*
273 * MMC/SD Device
274 *
275 * The card detect interrupt isn't debounced so we delay it by 250ms
276 * to give the card a chance to fully insert/eject.
277 */
278
279static struct pxamci_platform_data spitz_mci_platform_data;
280
281static int spitz_mci_init(struct device *dev, irqreturn_t (*spitz_detect_int)(int, void *, struct pt_regs *), void *data)
282{
283 int err;
284
285 /* setup GPIO for PXA27x MMC controller */
286 pxa_gpio_mode(GPIO32_MMCCLK_MD);
287 pxa_gpio_mode(GPIO112_MMCCMD_MD);
288 pxa_gpio_mode(GPIO92_MMCDAT0_MD);
289 pxa_gpio_mode(GPIO109_MMCDAT1_MD);
290 pxa_gpio_mode(GPIO110_MMCDAT2_MD);
291 pxa_gpio_mode(GPIO111_MMCDAT3_MD);
292 pxa_gpio_mode(SPITZ_GPIO_nSD_DETECT | GPIO_IN);
293 pxa_gpio_mode(SPITZ_GPIO_nSD_WP | GPIO_IN);
294
295 spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
296
297 err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int, SA_INTERRUPT,
298 "MMC card detect", data);
299 if (err) {
300 printk(KERN_ERR "spitz_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
301 return -1;
302 }
303
304 set_irq_type(SPITZ_IRQ_GPIO_nSD_DETECT, IRQT_BOTHEDGE);
305
306 return 0;
307}
308
Richard Purdie0dd28f12005-09-13 01:25:34 -0700309static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
310{
311 struct pxamci_platform_data* p_d = dev->platform_data;
312
Richard Purdiea63ae442005-11-08 19:15:43 +0000313 if (( 1 << vdd) & p_d->ocr_mask)
314 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
315 else
316 spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700317}
318
319static int spitz_mci_get_ro(struct device *dev)
320{
321 return GPLR(SPITZ_GPIO_nSD_WP) & GPIO_bit(SPITZ_GPIO_nSD_WP);
322}
323
324static void spitz_mci_exit(struct device *dev, void *data)
325{
326 free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
327}
328
329static struct pxamci_platform_data spitz_mci_platform_data = {
330 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
331 .init = spitz_mci_init,
332 .get_ro = spitz_mci_get_ro,
333 .setpower = spitz_mci_setpower,
334 .exit = spitz_mci_exit,
335};
336
337
338/*
Richard Purdie3125c682006-01-05 20:44:52 +0000339 * USB Host (OHCI)
340 */
341static int spitz_ohci_init(struct device *dev)
342{
343 /* Only Port 2 is connected */
344 pxa_gpio_mode(SPITZ_GPIO_USB_CONNECT | GPIO_IN);
345 pxa_gpio_mode(SPITZ_GPIO_USB_HOST | GPIO_OUT);
346 pxa_gpio_mode(SPITZ_GPIO_USB_DEVICE | GPIO_IN);
347
348 /* Setup USB Port 2 Output Control Register */
349 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
350
351 GPSR(SPITZ_GPIO_USB_HOST) = GPIO_bit(SPITZ_GPIO_USB_HOST);
352
353 UHCHR = (UHCHR) &
354 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE);
355
356 UHCRHDA |= UHCRHDA_NOCP;
357
358 return 0;
359}
360
361static struct pxaohci_platform_data spitz_ohci_platform_data = {
362 .port_mode = PMM_NPS_MODE,
363 .init = spitz_ohci_init,
364};
365
366
367/*
Richard Purdiedc078452005-10-30 14:50:25 +0000368 * Irda
369 */
370static void spitz_irda_transceiver_mode(struct device *dev, int mode)
371{
372 if (mode & IR_OFF)
373 set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
374 else
375 reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON);
376}
377
Richard Purdie94cabd02005-11-12 18:53:48 +0000378#ifdef CONFIG_MACH_AKITA
379static void akita_irda_transceiver_mode(struct device *dev, int mode)
380{
381 if (mode & IR_OFF)
382 akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
383 else
384 akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON);
385}
386#endif
387
Richard Purdiedc078452005-10-30 14:50:25 +0000388static struct pxaficp_platform_data spitz_ficp_platform_data = {
389 .transceiver_cap = IR_SIRMODE | IR_OFF,
390 .transceiver_mode = spitz_irda_transceiver_mode,
391};
392
393
394/*
Richard Purdie0dd28f12005-09-13 01:25:34 -0700395 * Spitz PXA Framebuffer
396 */
397static struct pxafb_mach_info spitz_pxafb_info __initdata = {
398 .pixclock = 19231,
399 .xres = 480,
400 .yres = 640,
401 .bpp = 16,
402 .hsync_len = 40,
403 .left_margin = 46,
404 .right_margin = 125,
405 .vsync_len = 3,
406 .upper_margin = 1,
407 .lower_margin = 0,
408 .sync = 0,
409 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act | LCCR0_LDDALT | LCCR0_OUC | LCCR0_CMDIM | LCCR0_RDSTM,
410 .lccr3 = LCCR3_PixRsEdg | LCCR3_OutEnH,
411 .pxafb_lcd_power = spitz_lcd_power,
412};
413
414
415static struct platform_device *devices[] __initdata = {
416 &spitzscoop_device,
417 &spitzssp_device,
418 &spitzkbd_device,
419 &spitzts_device,
420 &spitzbl_device,
Richard Purdie0dd28f12005-09-13 01:25:34 -0700421};
422
423static void __init common_init(void)
424{
425 PMCR = 0x00;
426
427 /* setup sleep mode values */
428 PWER = 0x00000002;
429 PFER = 0x00000000;
430 PRER = 0x00000002;
431 PGSR0 = 0x0158C000;
432 PGSR1 = 0x00FF0080;
433 PGSR2 = 0x0001C004;
434
435 /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
436 PCFR |= PCFR_OPDE;
437
438 corgi_ssp_set_machinfo(&spitz_ssp_machinfo);
439
440 pxa_gpio_mode(SPITZ_GPIO_HSYNC | GPIO_IN);
441
442 platform_add_devices(devices, ARRAY_SIZE(devices));
443 pxa_set_mci_info(&spitz_mci_platform_data);
Richard Purdie3125c682006-01-05 20:44:52 +0000444 pxa_set_ohci_info(&spitz_ohci_platform_data);
Richard Purdiedc078452005-10-30 14:50:25 +0000445 pxa_set_ficp_info(&spitz_ficp_platform_data);
Richard Purdiecb38c562005-10-14 16:07:25 +0100446 set_pxa_fb_parent(&spitzssp_device.dev);
Richard Purdie0dd28f12005-09-13 01:25:34 -0700447 set_pxa_fb_info(&spitz_pxafb_info);
448}
449
450static void __init spitz_init(void)
451{
Richard Purdiea63ae442005-11-08 19:15:43 +0000452 platform_scoop_config = &spitz_pcmcia_config;
453
Richard Purdie0dd28f12005-09-13 01:25:34 -0700454 spitz_bl_machinfo.set_bl_intensity = spitz_bl_set_intensity;
455
456 common_init();
457
458 platform_device_register(&spitzscoop2_device);
459}
460
Richard Purdie94cabd02005-11-12 18:53:48 +0000461#ifdef CONFIG_MACH_AKITA
462/*
463 * Akita IO Expander
464 */
465struct platform_device akitaioexp_device = {
466 .name = "akita-ioexp",
467 .id = -1,
468};
469
470static void __init akita_init(void)
471{
472 spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
473
474 /* We just pretend the second element of the array doesn't exist */
475 spitz_pcmcia_config.num_devs = 1;
476 platform_scoop_config = &spitz_pcmcia_config;
477 spitz_bl_machinfo.set_bl_intensity = akita_bl_set_intensity;
478
479 platform_device_register(&akitaioexp_device);
480
481 spitzscoop_device.dev.parent = &akitaioexp_device.dev;
482 common_init();
483}
484#endif
485
486
Richard Purdie0dd28f12005-09-13 01:25:34 -0700487static void __init fixup_spitz(struct machine_desc *desc,
488 struct tag *tags, char **cmdline, struct meminfo *mi)
489{
490 sharpsl_save_param();
491 mi->nr_banks = 1;
492 mi->bank[0].start = 0xa0000000;
493 mi->bank[0].node = 0;
494 mi->bank[0].size = (64*1024*1024);
495}
496
497#ifdef CONFIG_MACH_SPITZ
498MACHINE_START(SPITZ, "SHARP Spitz")
499 .phys_ram = 0xa0000000,
500 .phys_io = 0x40000000,
501 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
502 .fixup = fixup_spitz,
503 .map_io = pxa_map_io,
504 .init_irq = pxa_init_irq,
505 .init_machine = spitz_init,
506 .timer = &pxa_timer,
507MACHINE_END
508#endif
509
510#ifdef CONFIG_MACH_BORZOI
511MACHINE_START(BORZOI, "SHARP Borzoi")
512 .phys_ram = 0xa0000000,
513 .phys_io = 0x40000000,
514 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
515 .fixup = fixup_spitz,
516 .map_io = pxa_map_io,
517 .init_irq = pxa_init_irq,
518 .init_machine = spitz_init,
519 .timer = &pxa_timer,
520MACHINE_END
521#endif
Richard Purdie94cabd02005-11-12 18:53:48 +0000522
523#ifdef CONFIG_MACH_AKITA
524MACHINE_START(AKITA, "SHARP Akita")
525 .phys_ram = 0xa0000000,
526 .phys_io = 0x40000000,
527 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
528 .fixup = fixup_spitz,
529 .map_io = pxa_map_io,
530 .init_irq = pxa_init_irq,
531 .init_machine = akita_init,
532 .timer = &pxa_timer,
533MACHINE_END
534#endif