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