Merge branch 'eseries' into pxa
[deliverable/linux.git] / arch / arm / mach-pxa / tosa.c
1 /*
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>
17 #include <linux/platform_device.h>
18 #include <linux/major.h>
19 #include <linux/fs.h>
20 #include <linux/interrupt.h>
21 #include <linux/delay.h>
22 #include <linux/fb.h>
23 #include <linux/mmc/host.h>
24 #include <linux/mfd/tc6393xb.h>
25 #include <linux/mfd/tmio.h>
26 #include <linux/mtd/nand.h>
27 #include <linux/mtd/partitions.h>
28 #include <linux/pm.h>
29 #include <linux/gpio_keys.h>
30 #include <linux/input.h>
31 #include <linux/gpio.h>
32 #include <linux/pda_power.h>
33 #include <linux/rfkill.h>
34
35 #include <asm/setup.h>
36 #include <asm/mach-types.h>
37 #include <asm/arch/pxa2xx-regs.h>
38 #include <asm/arch/mfp-pxa25x.h>
39 #include <asm/arch/irda.h>
40 #include <asm/arch/i2c.h>
41 #include <asm/arch/mmc.h>
42 #include <asm/arch/udc.h>
43 #include <asm/arch/tosa_bt.h>
44
45 #include <asm/mach/arch.h>
46 #include <asm/arch/tosa.h>
47
48 #include <asm/hardware/scoop.h>
49 #include <asm/mach/sharpsl_param.h>
50
51 #include "generic.h"
52 #include "devices.h"
53
54 static unsigned long tosa_pin_config[] = {
55 GPIO78_nCS_2, /* Scoop */
56 GPIO80_nCS_4, /* tg6393xb */
57 GPIO33_nCS_5, /* Scoop */
58
59 // GPIO76 CARD_VCC_ON1
60
61 GPIO19_GPIO, /* Reset out */
62 GPIO1_RST | WAKEUP_ON_EDGE_FALL,
63
64 GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */
65 GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */
66 GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */
67 GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */
68 GPIO20_GPIO, /* EAR_IN */
69 GPIO22_GPIO, /* On */
70
71 GPIO5_GPIO, /* USB_IN */
72 GPIO32_GPIO, /* Pen IRQ */
73
74 GPIO7_GPIO, /* Jacket Detect */
75 GPIO14_GPIO, /* BAT0_CRG */
76 GPIO12_GPIO, /* BAT1_CRG */
77 GPIO17_GPIO, /* BAT0_LOW */
78 GPIO84_GPIO, /* BAT1_LOW */
79 GPIO38_GPIO, /* BAT_LOCK */
80
81 GPIO11_3_6MHz,
82 GPIO15_GPIO, /* TC6393XB IRQ */
83 GPIO18_RDY,
84 GPIO27_GPIO, /* LCD Sync */
85
86 /* MMC */
87 GPIO6_MMC_CLK,
88 GPIO8_MMC_CS0,
89 GPIO9_GPIO, /* Detect */
90 GPIO10_GPIO, /* nSD_INT */
91
92 /* CF */
93 GPIO13_GPIO, /* CD_IRQ */
94 GPIO21_GPIO, /* Main Slot IRQ */
95 GPIO36_GPIO, /* Jacket Slot IRQ */
96 GPIO48_nPOE,
97 GPIO49_nPWE,
98 GPIO50_nPIOR,
99 GPIO51_nPIOW,
100 GPIO52_nPCE_1,
101 GPIO53_nPCE_2,
102 GPIO54_nPSKTSEL,
103 GPIO55_nPREG,
104 GPIO56_nPWAIT,
105 GPIO57_nIOIS16,
106
107 /* AC97 */
108 GPIO31_AC97_SYNC,
109 GPIO30_AC97_SDATA_OUT,
110 GPIO28_AC97_BITCLK,
111 GPIO29_AC97_SDATA_IN_0,
112 // GPIO79 nAUD_IRQ
113
114 /* FFUART */
115 GPIO34_FFUART_RXD,
116 GPIO35_FFUART_CTS,
117 GPIO37_FFUART_DSR,
118 GPIO39_FFUART_TXD,
119 GPIO40_FFUART_DTR,
120 GPIO41_FFUART_RTS,
121
122 /* BTUART */
123 GPIO42_BTUART_RXD,
124 GPIO43_BTUART_TXD,
125 GPIO44_BTUART_CTS,
126 GPIO45_BTUART_RTS,
127
128 /* Keybd */
129 GPIO58_GPIO | MFP_LPM_DRIVE_LOW,
130 GPIO59_GPIO | MFP_LPM_DRIVE_LOW,
131 GPIO60_GPIO | MFP_LPM_DRIVE_LOW,
132 GPIO61_GPIO | MFP_LPM_DRIVE_LOW,
133 GPIO62_GPIO | MFP_LPM_DRIVE_LOW,
134 GPIO63_GPIO | MFP_LPM_DRIVE_LOW,
135 GPIO64_GPIO | MFP_LPM_DRIVE_LOW,
136 GPIO65_GPIO | MFP_LPM_DRIVE_LOW,
137 GPIO66_GPIO | MFP_LPM_DRIVE_LOW,
138 GPIO67_GPIO | MFP_LPM_DRIVE_LOW,
139 GPIO68_GPIO | MFP_LPM_DRIVE_LOW,
140 GPIO69_GPIO | MFP_LPM_DRIVE_LOW,
141 GPIO70_GPIO | MFP_LPM_DRIVE_LOW,
142 GPIO71_GPIO | MFP_LPM_DRIVE_LOW,
143 GPIO72_GPIO | MFP_LPM_DRIVE_LOW,
144 GPIO73_GPIO | MFP_LPM_DRIVE_LOW,
145 GPIO74_GPIO | MFP_LPM_DRIVE_LOW,
146 GPIO75_GPIO | MFP_LPM_DRIVE_LOW,
147
148 /* SPI */
149 GPIO81_SSP2_CLK_OUT,
150 GPIO82_SSP2_FRM_OUT,
151 GPIO83_SSP2_TXD,
152 };
153
154 static unsigned long tosa_pin_irda_off[] = {
155 GPIO46_STUART_RXD,
156 GPIO47_GPIO | MFP_LPM_DRIVE_LOW,
157 };
158
159 static unsigned long tosa_pin_irda_on[] = {
160 GPIO46_STUART_RXD,
161 GPIO47_STUART_TXD,
162 };
163
164
165 /*
166 * SCOOP Device
167 */
168 static struct resource tosa_scoop_resources[] = {
169 [0] = {
170 .start = TOSA_CF_PHYS,
171 .end = TOSA_CF_PHYS + 0xfff,
172 .flags = IORESOURCE_MEM,
173 },
174 };
175
176 static struct scoop_config tosa_scoop_setup = {
177 .io_dir = TOSA_SCOOP_IO_DIR,
178 .gpio_base = TOSA_SCOOP_GPIO_BASE,
179 };
180
181 static struct platform_device tosascoop_device = {
182 .name = "sharp-scoop",
183 .id = 0,
184 .dev = {
185 .platform_data = &tosa_scoop_setup,
186 },
187 .num_resources = ARRAY_SIZE(tosa_scoop_resources),
188 .resource = tosa_scoop_resources,
189 };
190
191
192 /*
193 * SCOOP Device Jacket
194 */
195 static struct resource tosa_scoop_jc_resources[] = {
196 [0] = {
197 .start = TOSA_SCOOP_PHYS + 0x40,
198 .end = TOSA_SCOOP_PHYS + 0xfff,
199 .flags = IORESOURCE_MEM,
200 },
201 };
202
203 static struct scoop_config tosa_scoop_jc_setup = {
204 .io_dir = TOSA_SCOOP_JC_IO_DIR,
205 .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
206 };
207
208 static struct platform_device tosascoop_jc_device = {
209 .name = "sharp-scoop",
210 .id = 1,
211 .dev = {
212 .platform_data = &tosa_scoop_jc_setup,
213 .parent = &tosascoop_device.dev,
214 },
215 .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
216 .resource = tosa_scoop_jc_resources,
217 };
218
219 /*
220 * PCMCIA
221 */
222 static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
223 {
224 .dev = &tosascoop_device.dev,
225 .irq = TOSA_IRQ_GPIO_CF_IRQ,
226 .cd_irq = TOSA_IRQ_GPIO_CF_CD,
227 .cd_irq_str = "PCMCIA0 CD",
228 },{
229 .dev = &tosascoop_jc_device.dev,
230 .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
231 .cd_irq = -1,
232 },
233 };
234
235 static struct scoop_pcmcia_config tosa_pcmcia_config = {
236 .devs = &tosa_pcmcia_scoop[0],
237 .num_devs = 2,
238 };
239
240 /*
241 * USB Device Controller
242 */
243 static struct pxa2xx_udc_mach_info udc_info __initdata = {
244 .gpio_pullup = TOSA_GPIO_USB_PULLUP,
245 .gpio_vbus = TOSA_GPIO_USB_IN,
246 .gpio_vbus_inverted = 1,
247 };
248
249 /*
250 * MMC/SD Device
251 */
252 static struct pxamci_platform_data tosa_mci_platform_data;
253
254 static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
255 {
256 int err;
257
258 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
259
260 err = gpio_request(TOSA_GPIO_nSD_DETECT, "MMC/SD card detect");
261 if (err) {
262 printk(KERN_ERR "tosa_mci_init: can't request nSD_DETECT gpio\n");
263 goto err_gpio_detect;
264 }
265 err = gpio_direction_input(TOSA_GPIO_nSD_DETECT);
266 if (err)
267 goto err_gpio_detect_dir;
268
269 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
270 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
271 "MMC/SD card detect", data);
272 if (err) {
273 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
274 goto err_irq;
275 }
276
277 err = gpio_request(TOSA_GPIO_SD_WP, "SD Write Protect");
278 if (err) {
279 printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n");
280 goto err_gpio_wp;
281 }
282 err = gpio_direction_input(TOSA_GPIO_SD_WP);
283 if (err)
284 goto err_gpio_wp_dir;
285
286 err = gpio_request(TOSA_GPIO_PWR_ON, "SD Power");
287 if (err) {
288 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
289 goto err_gpio_pwr;
290 }
291 err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0);
292 if (err)
293 goto err_gpio_pwr_dir;
294
295 err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
296 if (err) {
297 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
298 goto err_gpio_int;
299 }
300 err = gpio_direction_input(TOSA_GPIO_nSD_INT);
301 if (err)
302 goto err_gpio_int_dir;
303
304 return 0;
305
306 err_gpio_int_dir:
307 gpio_free(TOSA_GPIO_nSD_INT);
308 err_gpio_int:
309 err_gpio_pwr_dir:
310 gpio_free(TOSA_GPIO_PWR_ON);
311 err_gpio_pwr:
312 err_gpio_wp_dir:
313 gpio_free(TOSA_GPIO_SD_WP);
314 err_gpio_wp:
315 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
316 err_irq:
317 err_gpio_detect_dir:
318 gpio_free(TOSA_GPIO_nSD_DETECT);
319 err_gpio_detect:
320 return err;
321 }
322
323 static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
324 {
325 struct pxamci_platform_data* p_d = dev->platform_data;
326
327 if (( 1 << vdd) & p_d->ocr_mask) {
328 gpio_set_value(TOSA_GPIO_PWR_ON, 1);
329 } else {
330 gpio_set_value(TOSA_GPIO_PWR_ON, 0);
331 }
332 }
333
334 static int tosa_mci_get_ro(struct device *dev)
335 {
336 return gpio_get_value(TOSA_GPIO_SD_WP);
337 }
338
339 static void tosa_mci_exit(struct device *dev, void *data)
340 {
341 gpio_free(TOSA_GPIO_nSD_INT);
342 gpio_free(TOSA_GPIO_PWR_ON);
343 gpio_free(TOSA_GPIO_SD_WP);
344 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
345 gpio_free(TOSA_GPIO_nSD_DETECT);
346 }
347
348 static struct pxamci_platform_data tosa_mci_platform_data = {
349 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
350 .init = tosa_mci_init,
351 .get_ro = tosa_mci_get_ro,
352 .setpower = tosa_mci_setpower,
353 .exit = tosa_mci_exit,
354 };
355
356 /*
357 * Irda
358 */
359 static void tosa_irda_transceiver_mode(struct device *dev, int mode)
360 {
361 if (mode & IR_OFF) {
362 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
363 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_off));
364 gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
365 } else {
366 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_on));
367 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
368 }
369 }
370
371 static int tosa_irda_startup(struct device *dev)
372 {
373 int ret;
374
375 ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
376 if (ret)
377 goto err_tx;
378 ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
379 if (ret)
380 goto err_tx_dir;
381
382 ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
383 if (ret)
384 goto err_pwr;
385
386 ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
387 if (ret)
388 goto err_pwr_dir;
389
390 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
391
392 return 0;
393
394 err_pwr_dir:
395 gpio_free(TOSA_GPIO_IR_POWERDWN);
396 err_pwr:
397 err_tx_dir:
398 gpio_free(TOSA_GPIO_IRDA_TX);
399 err_tx:
400 return ret;
401 }
402
403 static void tosa_irda_shutdown(struct device *dev)
404 {
405 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
406 gpio_free(TOSA_GPIO_IR_POWERDWN);
407 gpio_free(TOSA_GPIO_IRDA_TX);
408 }
409
410 static struct pxaficp_platform_data tosa_ficp_platform_data = {
411 .transceiver_cap = IR_SIRMODE | IR_OFF,
412 .transceiver_mode = tosa_irda_transceiver_mode,
413 .startup = tosa_irda_startup,
414 .shutdown = tosa_irda_shutdown,
415 };
416
417 /*
418 * Tosa AC IN
419 */
420 static int tosa_power_init(struct device *dev)
421 {
422 int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
423 if (ret)
424 goto err_gpio_req;
425
426 ret = gpio_direction_input(TOSA_GPIO_AC_IN);
427 if (ret)
428 goto err_gpio_in;
429
430 return 0;
431
432 err_gpio_in:
433 gpio_free(TOSA_GPIO_AC_IN);
434 err_gpio_req:
435 return ret;
436 }
437
438 static void tosa_power_exit(struct device *dev)
439 {
440 gpio_free(TOSA_GPIO_AC_IN);
441 }
442
443 static int tosa_power_ac_online(void)
444 {
445 return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
446 }
447
448 static char *tosa_ac_supplied_to[] = {
449 "main-battery",
450 "backup-battery",
451 "jacket-battery",
452 };
453
454 static struct pda_power_pdata tosa_power_data = {
455 .init = tosa_power_init,
456 .is_ac_online = tosa_power_ac_online,
457 .exit = tosa_power_exit,
458 .supplied_to = tosa_ac_supplied_to,
459 .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
460 };
461
462 static struct resource tosa_power_resource[] = {
463 {
464 .name = "ac",
465 .start = gpio_to_irq(TOSA_GPIO_AC_IN),
466 .end = gpio_to_irq(TOSA_GPIO_AC_IN),
467 .flags = IORESOURCE_IRQ |
468 IORESOURCE_IRQ_HIGHEDGE |
469 IORESOURCE_IRQ_LOWEDGE,
470 },
471 };
472
473 static struct platform_device tosa_power_device = {
474 .name = "pda-power",
475 .id = -1,
476 .dev.platform_data = &tosa_power_data,
477 .resource = tosa_power_resource,
478 .num_resources = ARRAY_SIZE(tosa_power_resource),
479 };
480
481 /*
482 * Tosa Keyboard
483 */
484 static struct platform_device tosakbd_device = {
485 .name = "tosa-keyboard",
486 .id = -1,
487 };
488
489 static struct gpio_keys_button tosa_gpio_keys[] = {
490 /*
491 * Two following keys are directly tied to "ON" button of tosa. Why?
492 * The first one can be used as a wakeup source, the second can't;
493 * also the first one is OR of ac_powered and on_button.
494 */
495 {
496 .type = EV_PWR,
497 .code = KEY_RESERVED,
498 .gpio = TOSA_GPIO_POWERON,
499 .desc = "Poweron",
500 .wakeup = 1,
501 .active_low = 1,
502 },
503 {
504 .type = EV_PWR,
505 .code = KEY_SUSPEND,
506 .gpio = TOSA_GPIO_ON_KEY,
507 .desc = "On key",
508 /*
509 * can't be used as wakeup
510 * .wakeup = 1,
511 */
512 .active_low = 1,
513 },
514 {
515 .type = EV_KEY,
516 .code = TOSA_KEY_RECORD,
517 .gpio = TOSA_GPIO_RECORD_BTN,
518 .desc = "Record Button",
519 .wakeup = 1,
520 .active_low = 1,
521 },
522 {
523 .type = EV_KEY,
524 .code = TOSA_KEY_SYNC,
525 .gpio = TOSA_GPIO_SYNC,
526 .desc = "Sync Button",
527 .wakeup = 1,
528 .active_low = 1,
529 },
530 };
531
532 static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
533 .buttons = tosa_gpio_keys,
534 .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
535 };
536
537 static struct platform_device tosa_gpio_keys_device = {
538 .name = "gpio-keys",
539 .id = -1,
540 .dev = {
541 .platform_data = &tosa_gpio_keys_platform_data,
542 },
543 };
544
545 /*
546 * Tosa LEDs
547 */
548 static struct gpio_led tosa_gpio_leds[] = {
549 {
550 .name = "tosa:amber:charge",
551 .default_trigger = "main-battery-charging",
552 .gpio = TOSA_GPIO_CHRG_ERR_LED,
553 },
554 {
555 .name = "tosa:green:mail",
556 .default_trigger = "nand-disk",
557 .gpio = TOSA_GPIO_NOTE_LED,
558 },
559 {
560 .name = "tosa:dual:wlan",
561 .default_trigger = "none",
562 .gpio = TOSA_GPIO_WLAN_LED,
563 },
564 {
565 .name = "tosa:blue:bluetooth",
566 .default_trigger = "tosa-bt",
567 .gpio = TOSA_GPIO_BT_LED,
568 },
569 };
570
571 static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
572 .leds = tosa_gpio_leds,
573 .num_leds = ARRAY_SIZE(tosa_gpio_leds),
574 };
575
576 static struct platform_device tosaled_device = {
577 .name = "leds-gpio",
578 .id = -1,
579 .dev = {
580 .platform_data = &tosa_gpio_leds_platform_data,
581 },
582 };
583
584 /*
585 * Toshiba Mobile IO Controller
586 */
587 static struct resource tc6393xb_resources[] = {
588 [0] = {
589 .start = TOSA_LCDC_PHYS,
590 .end = TOSA_LCDC_PHYS + 0x3ffffff,
591 .flags = IORESOURCE_MEM,
592 },
593
594 [1] = {
595 .start = TOSA_IRQ_GPIO_TC6393XB_INT,
596 .end = TOSA_IRQ_GPIO_TC6393XB_INT,
597 .flags = IORESOURCE_IRQ,
598 },
599 };
600
601
602 static int tosa_tc6393xb_enable(struct platform_device *dev)
603 {
604 int rc;
605
606 rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
607 if (rc)
608 goto err_req_pclr;
609 rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
610 if (rc)
611 goto err_req_suspend;
612 rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "l3v");
613 if (rc)
614 goto err_req_l3v;
615 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
616 if (rc)
617 goto err_dir_l3v;
618 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
619 if (rc)
620 goto err_dir_suspend;
621 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
622 if (rc)
623 goto err_dir_pclr;
624
625 mdelay(1);
626
627 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
628
629 mdelay(10);
630
631 gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
632 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
633
634 return 0;
635 err_dir_pclr:
636 err_dir_suspend:
637 err_dir_l3v:
638 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
639 err_req_l3v:
640 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
641 err_req_suspend:
642 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
643 err_req_pclr:
644 return rc;
645 }
646
647 static int tosa_tc6393xb_disable(struct platform_device *dev)
648 {
649 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
650 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
651 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
652
653 return 0;
654 }
655
656 static int tosa_tc6393xb_resume(struct platform_device *dev)
657 {
658 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
659 mdelay(10);
660 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
661 mdelay(10);
662
663 return 0;
664 }
665
666 static int tosa_tc6393xb_suspend(struct platform_device *dev)
667 {
668 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
669 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
670 return 0;
671 }
672
673 static struct mtd_partition tosa_nand_partition[] = {
674 {
675 .name = "smf",
676 .offset = 0,
677 .size = 7 * 1024 * 1024,
678 },
679 {
680 .name = "root",
681 .offset = MTDPART_OFS_APPEND,
682 .size = 28 * 1024 * 1024,
683 },
684 {
685 .name = "home",
686 .offset = MTDPART_OFS_APPEND,
687 .size = MTDPART_SIZ_FULL,
688 },
689 };
690
691 static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
692
693 static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = {
694 .options = 0,
695 .offs = 4,
696 .len = 2,
697 .pattern = scan_ff_pattern
698 };
699
700 static struct tmio_nand_data tosa_tc6393xb_nand_config = {
701 .num_partitions = ARRAY_SIZE(tosa_nand_partition),
702 .partition = tosa_nand_partition,
703 .badblock_pattern = &tosa_tc6393xb_nand_bbt,
704 };
705
706 static struct tc6393xb_platform_data tosa_tc6393xb_setup = {
707 .scr_pll2cr = 0x0cc1,
708 .scr_gper = 0x3300,
709 .scr_gpo_dsr =
710 TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
711 .scr_gpo_doecr =
712 TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
713
714 .irq_base = IRQ_BOARD_START,
715 .gpio_base = TOSA_TC6393XB_GPIO_BASE,
716
717 .enable = tosa_tc6393xb_enable,
718 .disable = tosa_tc6393xb_disable,
719 .suspend = tosa_tc6393xb_suspend,
720 .resume = tosa_tc6393xb_resume,
721
722 .nand_data = &tosa_tc6393xb_nand_config,
723 };
724
725
726 static struct platform_device tc6393xb_device = {
727 .name = "tc6393xb",
728 .id = -1,
729 .dev = {
730 .platform_data = &tosa_tc6393xb_setup,
731 },
732 .num_resources = ARRAY_SIZE(tc6393xb_resources),
733 .resource = tc6393xb_resources,
734 };
735
736 static struct tosa_bt_data tosa_bt_data = {
737 .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
738 .gpio_reset = TOSA_GPIO_BT_RESET,
739 };
740
741 static struct platform_device tosa_bt_device = {
742 .name = "tosa-bt",
743 .id = -1,
744 .dev.platform_data = &tosa_bt_data,
745 };
746
747
748 static struct platform_device *devices[] __initdata = {
749 &tosascoop_device,
750 &tosascoop_jc_device,
751 &tc6393xb_device,
752 &tosa_power_device,
753 &tosakbd_device,
754 &tosa_gpio_keys_device,
755 &tosaled_device,
756 &tosa_bt_device,
757 };
758
759 static void tosa_poweroff(void)
760 {
761 arm_machine_restart('g');
762 }
763
764 static void tosa_restart(char mode)
765 {
766 /* Bootloader magic for a reboot */
767 if((MSC0 & 0xffff0000) == 0x7ff00000)
768 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
769
770 tosa_poweroff();
771 }
772
773 static void __init tosa_init(void)
774 {
775 int dummy;
776
777 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
778 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_off));
779 gpio_set_wake(MFP_PIN_GPIO1, 1);
780 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
781
782 init_gpio_reset(TOSA_GPIO_ON_RESET);
783
784 pm_power_off = tosa_poweroff;
785 arm_pm_restart = tosa_restart;
786
787 PCFR |= PCFR_OPDE;
788
789 /* enable batt_fault */
790 PMCR = 0x01;
791
792 dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
793 dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
794 dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
795
796 pxa_set_mci_info(&tosa_mci_platform_data);
797 pxa_set_udc_info(&udc_info);
798 pxa_set_ficp_info(&tosa_ficp_platform_data);
799 pxa_set_i2c_info(NULL);
800 platform_scoop_config = &tosa_pcmcia_config;
801
802 platform_add_devices(devices, ARRAY_SIZE(devices));
803 }
804
805 static void __init fixup_tosa(struct machine_desc *desc,
806 struct tag *tags, char **cmdline, struct meminfo *mi)
807 {
808 sharpsl_save_param();
809 mi->nr_banks=1;
810 mi->bank[0].start = 0xa0000000;
811 mi->bank[0].node = 0;
812 mi->bank[0].size = (64*1024*1024);
813 }
814
815 MACHINE_START(TOSA, "SHARP Tosa")
816 .phys_io = 0x40000000,
817 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
818 .fixup = fixup_tosa,
819 .map_io = pxa_map_io,
820 .init_irq = pxa25x_init_irq,
821 .init_machine = tosa_init,
822 .timer = &pxa_timer,
823 MACHINE_END
This page took 0.057615 seconds and 5 git commands to generate.