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