Merge tag 'riscv/for-v5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv...
[linux-2.6-block.git] / arch / arm / mach-pxa / tosa.c
CommitLineData
d2912cb1 1// SPDX-License-Identifier: GPL-2.0-only
8459c159
DO
2/*
3 * Support for Sharp SL-C6000x PDAs
4 * Model: (Tosa)
5 *
6 * Copyright (c) 2005 Dirk Opfer
7 *
8 * Based on code written by Sharp/Lineo for 2.4 kernels
8459c159
DO
9 */
10
2d34e507 11#include <linux/clkdev.h>
8459c159
DO
12#include <linux/kernel.h>
13#include <linux/init.h>
067c9048 14#include <linux/platform_device.h>
8459c159
DO
15#include <linux/major.h>
16#include <linux/fs.h>
17#include <linux/interrupt.h>
bf0116e5
DB
18#include <linux/delay.h>
19#include <linux/fb.h>
8459c159 20#include <linux/mmc/host.h>
bf0116e5 21#include <linux/mfd/tc6393xb.h>
5289fecd 22#include <linux/mfd/tmio.h>
d4092d76 23#include <linux/mtd/rawnand.h>
5289fecd 24#include <linux/mtd/partitions.h>
f34ee79a 25#include <linux/mtd/physmap.h>
74617fb6 26#include <linux/pm.h>
93e9012f
DB
27#include <linux/gpio_keys.h>
28#include <linux/input.h>
d4e7d09f 29#include <linux/gpio.h>
32d15448 30#include <linux/gpio/machine.h>
62a75757 31#include <linux/power/gpio-charger.h>
14b7b401 32#include <linux/spi/spi.h>
8348c259 33#include <linux/spi/pxa2xx_spi.h>
f69a6548 34#include <linux/input/matrix_keypad.h>
f15fc9b1 35#include <linux/platform_data/i2c-pxa.h>
ef8b3cc6 36#include <linux/usb/gpio_vbus.h>
7b6d864b 37#include <linux/reboot.h>
1c2f87c2 38#include <linux/memblock.h>
8459c159
DO
39
40#include <asm/setup.h>
8459c159 41#include <asm/mach-types.h>
51c62982 42
4c25c5d2 43#include "pxa25x.h"
afd2fc02 44#include <mach/reset.h>
293b2da1
AB
45#include <linux/platform_data/irda-pxaficp.h>
46#include <linux/platform_data/mmc-pxamci.h>
4c25c5d2
AB
47#include "udc.h"
48#include "tosa_bt.h"
80748fb8 49#include <mach/audio.h>
ad68bb9f 50#include <mach/smemc.h>
8459c159
DO
51
52#include <asm/mach/arch.h>
a09e64fb 53#include <mach/tosa.h>
8459c159
DO
54
55#include <asm/hardware/scoop.h>
56#include <asm/mach/sharpsl_param.h>
57
58#include "generic.h"
46c41e62 59#include "devices.h"
8459c159 60
2cb47342
DB
61static unsigned long tosa_pin_config[] = {
62 GPIO78_nCS_2, /* Scoop */
63 GPIO80_nCS_4, /* tg6393xb */
64 GPIO33_nCS_5, /* Scoop */
65
66 // GPIO76 CARD_VCC_ON1
67
68 GPIO19_GPIO, /* Reset out */
69 GPIO1_RST | WAKEUP_ON_EDGE_FALL,
70
71 GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */
72 GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */
73 GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */
74 GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */
75 GPIO20_GPIO, /* EAR_IN */
76 GPIO22_GPIO, /* On */
77
78 GPIO5_GPIO, /* USB_IN */
79 GPIO32_GPIO, /* Pen IRQ */
80
81 GPIO7_GPIO, /* Jacket Detect */
82 GPIO14_GPIO, /* BAT0_CRG */
83 GPIO12_GPIO, /* BAT1_CRG */
84 GPIO17_GPIO, /* BAT0_LOW */
85 GPIO84_GPIO, /* BAT1_LOW */
86 GPIO38_GPIO, /* BAT_LOCK */
87
88 GPIO11_3_6MHz,
89 GPIO15_GPIO, /* TC6393XB IRQ */
90 GPIO18_RDY,
91 GPIO27_GPIO, /* LCD Sync */
92
93 /* MMC */
94 GPIO6_MMC_CLK,
95 GPIO8_MMC_CS0,
96 GPIO9_GPIO, /* Detect */
c4d5f8d4 97 GPIO10_GPIO, /* nSD_INT */
2cb47342
DB
98
99 /* CF */
100 GPIO13_GPIO, /* CD_IRQ */
101 GPIO21_GPIO, /* Main Slot IRQ */
102 GPIO36_GPIO, /* Jacket Slot IRQ */
103 GPIO48_nPOE,
104 GPIO49_nPWE,
105 GPIO50_nPIOR,
106 GPIO51_nPIOW,
107 GPIO52_nPCE_1,
108 GPIO53_nPCE_2,
109 GPIO54_nPSKTSEL,
110 GPIO55_nPREG,
111 GPIO56_nPWAIT,
112 GPIO57_nIOIS16,
113
114 /* AC97 */
115 GPIO31_AC97_SYNC,
116 GPIO30_AC97_SDATA_OUT,
117 GPIO28_AC97_BITCLK,
118 GPIO29_AC97_SDATA_IN_0,
119 // GPIO79 nAUD_IRQ
120
121 /* FFUART */
122 GPIO34_FFUART_RXD,
123 GPIO35_FFUART_CTS,
124 GPIO37_FFUART_DSR,
125 GPIO39_FFUART_TXD,
126 GPIO40_FFUART_DTR,
127 GPIO41_FFUART_RTS,
128
129 /* BTUART */
130 GPIO42_BTUART_RXD,
131 GPIO43_BTUART_TXD,
132 GPIO44_BTUART_CTS,
133 GPIO45_BTUART_RTS,
134
2cb47342 135 /* Keybd */
f69a6548
EM
136 GPIO58_GPIO | MFP_LPM_DRIVE_LOW, /* Column 0 */
137 GPIO59_GPIO | MFP_LPM_DRIVE_LOW, /* Column 1 */
138 GPIO60_GPIO | MFP_LPM_DRIVE_LOW, /* Column 2 */
139 GPIO61_GPIO | MFP_LPM_DRIVE_LOW, /* Column 3 */
140 GPIO62_GPIO | MFP_LPM_DRIVE_LOW, /* Column 4 */
141 GPIO63_GPIO | MFP_LPM_DRIVE_LOW, /* Column 5 */
142 GPIO64_GPIO | MFP_LPM_DRIVE_LOW, /* Column 6 */
143 GPIO65_GPIO | MFP_LPM_DRIVE_LOW, /* Column 7 */
144 GPIO66_GPIO | MFP_LPM_DRIVE_LOW, /* Column 8 */
145 GPIO67_GPIO | MFP_LPM_DRIVE_LOW, /* Column 9 */
146 GPIO68_GPIO | MFP_LPM_DRIVE_LOW, /* Column 10 */
147 GPIO69_GPIO | MFP_LPM_DRIVE_LOW, /* Row 0 */
148 GPIO70_GPIO | MFP_LPM_DRIVE_LOW, /* Row 1 */
149 GPIO71_GPIO | MFP_LPM_DRIVE_LOW, /* Row 2 */
150 GPIO72_GPIO | MFP_LPM_DRIVE_LOW, /* Row 3 */
151 GPIO73_GPIO | MFP_LPM_DRIVE_LOW, /* Row 4 */
152 GPIO74_GPIO | MFP_LPM_DRIVE_LOW, /* Row 5 */
153 GPIO75_GPIO | MFP_LPM_DRIVE_LOW, /* Row 6 */
2cb47342
DB
154
155 /* SPI */
156 GPIO81_SSP2_CLK_OUT,
157 GPIO82_SSP2_FRM_OUT,
158 GPIO83_SSP2_TXD,
b032fccc 159
0fc3ff31
DB
160 /* IrDA is managed in other way */
161 GPIO46_GPIO,
162 GPIO47_GPIO,
b032fccc
DB
163};
164
8459c159
DO
165/*
166 * SCOOP Device
167 */
168static 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
176static struct scoop_config tosa_scoop_setup = {
177 .io_dir = TOSA_SCOOP_IO_DIR,
d4e7d09f 178 .gpio_base = TOSA_SCOOP_GPIO_BASE,
8459c159
DO
179};
180
ba4eb7e6 181static struct platform_device tosascoop_device = {
8459c159
DO
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 */
195static 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
203static struct scoop_config tosa_scoop_jc_setup = {
204 .io_dir = TOSA_SCOOP_JC_IO_DIR,
d4e7d09f 205 .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
8459c159
DO
206};
207
ba4eb7e6 208static struct platform_device tosascoop_jc_device = {
8459c159
DO
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
4c18ad20
DO
219/*
220 * PCMCIA
221 */
8459c159
DO
222static 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
4c18ad20
DO
235static struct scoop_pcmcia_config tosa_pcmcia_config = {
236 .devs = &tosa_pcmcia_scoop[0],
237 .num_devs = 2,
4c18ad20
DO
238};
239
a93876c1
DO
240/*
241 * USB Device Controller
242 */
ef8b3cc6 243static struct gpio_vbus_mach_info tosa_udc_info = {
d4e7d09f 244 .gpio_pullup = TOSA_GPIO_USB_PULLUP,
487dc922
DB
245 .gpio_vbus = TOSA_GPIO_USB_IN,
246 .gpio_vbus_inverted = 1,
a93876c1
DO
247};
248
ef8b3cc6
DES
249static struct platform_device tosa_gpio_vbus = {
250 .name = "gpio-vbus",
251 .id = -1,
252 .dev = {
253 .platform_data = &tosa_udc_info,
254 },
255};
256
a93876c1
DO
257/*
258 * MMC/SD Device
259 */
40220c1a 260static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
a93876c1
DO
261{
262 int err;
263
c4d5f8d4
DB
264 err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
265 if (err) {
266 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
267 goto err_gpio_int;
268 }
269 err = gpio_direction_input(TOSA_GPIO_nSD_INT);
270 if (err)
271 goto err_gpio_int_dir;
272
d4e7d09f
DB
273 return 0;
274
c4d5f8d4
DB
275err_gpio_int_dir:
276 gpio_free(TOSA_GPIO_nSD_INT);
277err_gpio_int:
2687bd38 278 return err;
a93876c1
DO
279}
280
a93876c1
DO
281static void tosa_mci_exit(struct device *dev, void *data)
282{
c4d5f8d4 283 gpio_free(TOSA_GPIO_nSD_INT);
a93876c1
DO
284}
285
286static struct pxamci_platform_data tosa_mci_platform_data = {
f97cab28 287 .detect_delay_ms = 250,
7a648256
RJ
288 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
289 .init = tosa_mci_init,
290 .exit = tosa_mci_exit,
a93876c1
DO
291};
292
32d15448
LW
293static struct gpiod_lookup_table tosa_mci_gpio_table = {
294 .dev_id = "pxa2xx-mci.0",
295 .table = {
296 GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_nSD_DETECT,
297 "cd", GPIO_ACTIVE_LOW),
298 GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_SD_WP,
299 "wp", GPIO_ACTIVE_LOW),
f54005b5
LW
300 GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_PWR_ON,
301 "power", GPIO_ACTIVE_HIGH),
32d15448
LW
302 { },
303 },
304};
305
a93876c1
DO
306/*
307 * Irda
308 */
b032fccc
DB
309static void tosa_irda_transceiver_mode(struct device *dev, int mode)
310{
311 if (mode & IR_OFF) {
312 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
0fc3ff31 313 pxa2xx_transceiver_mode(dev, mode);
b032fccc
DB
314 gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
315 } else {
0fc3ff31 316 pxa2xx_transceiver_mode(dev, mode);
b032fccc
DB
317 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
318 }
319}
320
d4e7d09f 321static int tosa_irda_startup(struct device *dev)
a93876c1 322{
d4e7d09f
DB
323 int ret;
324
b032fccc
DB
325 ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
326 if (ret)
327 goto err_tx;
328 ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
329 if (ret)
330 goto err_tx_dir;
331
d4e7d09f
DB
332 ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
333 if (ret)
b032fccc 334 goto err_pwr;
d4e7d09f
DB
335
336 ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
337 if (ret)
b032fccc 338 goto err_pwr_dir;
d4e7d09f 339
b032fccc 340 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
d4e7d09f 341
b032fccc
DB
342 return 0;
343
344err_pwr_dir:
d4e7d09f 345 gpio_free(TOSA_GPIO_IR_POWERDWN);
b032fccc
DB
346err_pwr:
347err_tx_dir:
348 gpio_free(TOSA_GPIO_IRDA_TX);
349err_tx:
350 return ret;
d4e7d09f
DB
351}
352
b032fccc 353static void tosa_irda_shutdown(struct device *dev)
d4e7d09f 354{
b032fccc
DB
355 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
356 gpio_free(TOSA_GPIO_IR_POWERDWN);
357 gpio_free(TOSA_GPIO_IRDA_TX);
a93876c1
DO
358}
359
360static struct pxaficp_platform_data tosa_ficp_platform_data = {
c4bd0172
MV
361 .gpio_pwdown = -1,
362 .transceiver_cap = IR_SIRMODE | IR_OFF,
363 .transceiver_mode = tosa_irda_transceiver_mode,
364 .startup = tosa_irda_startup,
365 .shutdown = tosa_irda_shutdown,
a93876c1
DO
366};
367
53b14ea3
DB
368/*
369 * Tosa AC IN
370 */
53b14ea3
DB
371static char *tosa_ac_supplied_to[] = {
372 "main-battery",
373 "backup-battery",
374 "jacket-battery",
375};
376
62a75757
DES
377static struct gpio_charger_platform_data tosa_power_data = {
378 .name = "charger",
379 .type = POWER_SUPPLY_TYPE_MAINS,
380 .gpio = TOSA_GPIO_AC_IN,
381 .gpio_active_low = 1,
53b14ea3
DB
382 .supplied_to = tosa_ac_supplied_to,
383 .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
384};
385
386static struct resource tosa_power_resource[] = {
387 {
388 .name = "ac",
4929f5a8
HZ
389 .start = PXA_GPIO_TO_IRQ(TOSA_GPIO_AC_IN),
390 .end = PXA_GPIO_TO_IRQ(TOSA_GPIO_AC_IN),
53b14ea3
DB
391 .flags = IORESOURCE_IRQ |
392 IORESOURCE_IRQ_HIGHEDGE |
393 IORESOURCE_IRQ_LOWEDGE,
394 },
395};
396
397static struct platform_device tosa_power_device = {
62a75757 398 .name = "gpio-charger",
53b14ea3
DB
399 .id = -1,
400 .dev.platform_data = &tosa_power_data,
401 .resource = tosa_power_resource,
402 .num_resources = ARRAY_SIZE(tosa_power_resource),
403};
404
a93876c1
DO
405/*
406 * Tosa Keyboard
407 */
f69a6548 408static const uint32_t tosakbd_keymap[] = {
506cac15
DES
409 KEY(0, 1, KEY_W),
410 KEY(0, 5, KEY_K),
411 KEY(0, 6, KEY_BACKSPACE),
412 KEY(0, 7, KEY_P),
413 KEY(1, 0, KEY_Q),
414 KEY(1, 1, KEY_E),
415 KEY(1, 2, KEY_T),
416 KEY(1, 3, KEY_Y),
417 KEY(1, 5, KEY_O),
418 KEY(1, 6, KEY_I),
419 KEY(1, 7, KEY_COMMA),
420 KEY(2, 0, KEY_A),
421 KEY(2, 1, KEY_D),
422 KEY(2, 2, KEY_G),
423 KEY(2, 3, KEY_U),
424 KEY(2, 5, KEY_L),
425 KEY(2, 6, KEY_ENTER),
426 KEY(2, 7, KEY_DOT),
427 KEY(3, 0, KEY_Z),
428 KEY(3, 1, KEY_C),
429 KEY(3, 2, KEY_V),
430 KEY(3, 3, KEY_J),
431 KEY(3, 4, TOSA_KEY_ADDRESSBOOK),
432 KEY(3, 5, TOSA_KEY_CANCEL),
433 KEY(3, 6, TOSA_KEY_CENTER),
434 KEY(3, 7, TOSA_KEY_OK),
435 KEY(3, 8, KEY_LEFTSHIFT),
436 KEY(4, 0, KEY_S),
437 KEY(4, 1, KEY_R),
438 KEY(4, 2, KEY_B),
439 KEY(4, 3, KEY_N),
440 KEY(4, 4, TOSA_KEY_CALENDAR),
441 KEY(4, 5, TOSA_KEY_HOMEPAGE),
442 KEY(4, 6, KEY_LEFTCTRL),
443 KEY(4, 7, TOSA_KEY_LIGHT),
444 KEY(4, 9, KEY_RIGHTSHIFT),
445 KEY(5, 0, KEY_TAB),
446 KEY(5, 1, KEY_SLASH),
447 KEY(5, 2, KEY_H),
448 KEY(5, 3, KEY_M),
449 KEY(5, 4, TOSA_KEY_MENU),
450 KEY(5, 6, KEY_UP),
451 KEY(5, 10, TOSA_KEY_FN),
452 KEY(6, 0, KEY_X),
453 KEY(6, 1, KEY_F),
454 KEY(6, 2, KEY_SPACE),
455 KEY(6, 3, KEY_APOSTROPHE),
456 KEY(6, 4, TOSA_KEY_MAIL),
457 KEY(6, 5, KEY_LEFT),
458 KEY(6, 6, KEY_DOWN),
459 KEY(6, 7, KEY_RIGHT),
f69a6548
EM
460};
461
462static struct matrix_keymap_data tosakbd_keymap_data = {
463 .keymap = tosakbd_keymap,
464 .keymap_size = ARRAY_SIZE(tosakbd_keymap),
465};
466
467static const int tosakbd_col_gpios[] =
468 { 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68 };
469static const int tosakbd_row_gpios[] =
470 { 69, 70, 71, 72, 73, 74, 75 };
471
472static struct matrix_keypad_platform_data tosakbd_pdata = {
473 .keymap_data = &tosakbd_keymap_data,
474 .row_gpios = tosakbd_row_gpios,
475 .col_gpios = tosakbd_col_gpios,
476 .num_row_gpios = ARRAY_SIZE(tosakbd_row_gpios),
477 .num_col_gpios = ARRAY_SIZE(tosakbd_col_gpios),
478 .col_scan_delay_us = 10,
479 .debounce_ms = 10,
480 .wakeup = 1,
481};
482
a93876c1 483static struct platform_device tosakbd_device = {
f69a6548 484 .name = "matrix-keypad",
a93876c1 485 .id = -1,
f69a6548
EM
486 .dev = {
487 .platform_data = &tosakbd_pdata,
488 },
a93876c1 489};
8459c159 490
93e9012f 491static struct gpio_keys_button tosa_gpio_keys[] = {
0aa97561
DB
492 /*
493 * Two following keys are directly tied to "ON" button of tosa. Why?
494 * The first one can be used as a wakeup source, the second can't;
495 * also the first one is OR of ac_powered and on_button.
496 */
497 {
498 .type = EV_PWR,
499 .code = KEY_RESERVED,
500 .gpio = TOSA_GPIO_POWERON,
501 .desc = "Poweron",
502 .wakeup = 1,
503 .active_low = 1,
504 },
93e9012f
DB
505 {
506 .type = EV_PWR,
507 .code = KEY_SUSPEND,
508 .gpio = TOSA_GPIO_ON_KEY,
509 .desc = "On key",
0aa97561
DB
510 /*
511 * can't be used as wakeup
512 * .wakeup = 1,
513 */
93e9012f
DB
514 .active_low = 1,
515 },
516 {
517 .type = EV_KEY,
518 .code = TOSA_KEY_RECORD,
519 .gpio = TOSA_GPIO_RECORD_BTN,
520 .desc = "Record Button",
521 .wakeup = 1,
522 .active_low = 1,
523 },
524 {
525 .type = EV_KEY,
526 .code = TOSA_KEY_SYNC,
527 .gpio = TOSA_GPIO_SYNC,
528 .desc = "Sync Button",
529 .wakeup = 1,
530 .active_low = 1,
531 },
c33de47b
DB
532 {
533 .type = EV_SW,
534 .code = SW_HEADPHONE_INSERT,
535 .gpio = TOSA_GPIO_EAR_IN,
536 .desc = "HeadPhone insert",
537 .active_low = 1,
538 .debounce_interval = 300,
539 },
93e9012f
DB
540};
541
542static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
543 .buttons = tosa_gpio_keys,
544 .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
545};
546
547static struct platform_device tosa_gpio_keys_device = {
548 .name = "gpio-keys",
549 .id = -1,
550 .dev = {
551 .platform_data = &tosa_gpio_keys_platform_data,
552 },
553};
554
6d0cf3e0
DO
555/*
556 * Tosa LEDs
557 */
ba4eb7e6 558static struct gpio_led tosa_gpio_leds[] = {
311c736c
DB
559 {
560 .name = "tosa:amber:charge",
561 .default_trigger = "main-battery-charging",
562 .gpio = TOSA_GPIO_CHRG_ERR_LED,
563 },
564 {
565 .name = "tosa:green:mail",
566 .default_trigger = "nand-disk",
567 .gpio = TOSA_GPIO_NOTE_LED,
568 },
c546106c
DB
569 {
570 .name = "tosa:dual:wlan",
571 .default_trigger = "none",
572 .gpio = TOSA_GPIO_WLAN_LED,
573 },
574 {
575 .name = "tosa:blue:bluetooth",
16b32fd0 576 .default_trigger = "tosa-bt",
c546106c
DB
577 .gpio = TOSA_GPIO_BT_LED,
578 },
311c736c
DB
579};
580
ba4eb7e6 581static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
311c736c
DB
582 .leds = tosa_gpio_leds,
583 .num_leds = ARRAY_SIZE(tosa_gpio_leds),
584};
585
6d0cf3e0 586static struct platform_device tosaled_device = {
311c736c
DB
587 .name = "leds-gpio",
588 .id = -1,
589 .dev = {
590 .platform_data = &tosa_gpio_leds_platform_data,
591 },
6d0cf3e0
DO
592};
593
bf0116e5
DB
594/*
595 * Toshiba Mobile IO Controller
596 */
597static struct resource tc6393xb_resources[] = {
598 [0] = {
599 .start = TOSA_LCDC_PHYS,
600 .end = TOSA_LCDC_PHYS + 0x3ffffff,
601 .flags = IORESOURCE_MEM,
602 },
603
604 [1] = {
605 .start = TOSA_IRQ_GPIO_TC6393XB_INT,
606 .end = TOSA_IRQ_GPIO_TC6393XB_INT,
607 .flags = IORESOURCE_IRQ,
608 },
609};
610
611
612static int tosa_tc6393xb_enable(struct platform_device *dev)
613{
614 int rc;
615
616 rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
617 if (rc)
618 goto err_req_pclr;
619 rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
620 if (rc)
621 goto err_req_suspend;
14b7b401 622 rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "tc6393xb l3v");
bf0116e5
DB
623 if (rc)
624 goto err_req_l3v;
625 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
626 if (rc)
627 goto err_dir_l3v;
628 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
629 if (rc)
630 goto err_dir_suspend;
631 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
632 if (rc)
633 goto err_dir_pclr;
634
635 mdelay(1);
636
637 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
638
639 mdelay(10);
640
641 gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
642 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
643
644 return 0;
645err_dir_pclr:
646err_dir_suspend:
647err_dir_l3v:
648 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
649err_req_l3v:
650 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
651err_req_suspend:
652 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
653err_req_pclr:
654 return rc;
655}
656
657static int tosa_tc6393xb_disable(struct platform_device *dev)
658{
659 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
660 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
661 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
662
663 return 0;
664}
665
666static int tosa_tc6393xb_resume(struct platform_device *dev)
667{
668 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
669 mdelay(10);
670 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
671 mdelay(10);
672
673 return 0;
674}
675
676static int tosa_tc6393xb_suspend(struct platform_device *dev)
677{
678 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
679 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
680 return 0;
681}
682
5289fecd
DB
683static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
684
685static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = {
686 .options = 0,
687 .offs = 4,
688 .len = 2,
689 .pattern = scan_ff_pattern
690};
691
b3bd8559
AA
692static const char * const probes[] = {
693 "cmdlinepart",
694 "ofpart",
695 "sharpslpart",
696 NULL,
697};
698
5289fecd 699static struct tmio_nand_data tosa_tc6393xb_nand_config = {
5289fecd 700 .badblock_pattern = &tosa_tc6393xb_nand_bbt,
b3bd8559 701 .part_parsers = probes,
5289fecd
DB
702};
703
1c1b6ffc
DB
704static int tosa_tc6393xb_setup(struct platform_device *dev)
705{
706 int rc;
707
708 rc = gpio_request(TOSA_GPIO_CARD_VCC_ON, "CARD_VCC_ON");
709 if (rc)
710 goto err_req;
711
712 rc = gpio_direction_output(TOSA_GPIO_CARD_VCC_ON, 1);
713 if (rc)
714 goto err_dir;
715
716 return rc;
717
718err_dir:
719 gpio_free(TOSA_GPIO_CARD_VCC_ON);
720err_req:
721 return rc;
722}
723
724static void tosa_tc6393xb_teardown(struct platform_device *dev)
725{
726 gpio_free(TOSA_GPIO_CARD_VCC_ON);
727}
728
ddfb33c0 729#ifdef CONFIG_MFD_TC6393XB
31c9b284
DB
730static struct fb_videomode tosa_tc6393xb_lcd_mode[] = {
731 {
732 .xres = 480,
733 .yres = 640,
734 .pixclock = 0x002cdf00,/* PLL divisor */
735 .left_margin = 0x004c,
736 .right_margin = 0x005b,
737 .upper_margin = 0x0001,
738 .lower_margin = 0x000d,
739 .hsync_len = 0x0002,
740 .vsync_len = 0x0001,
741 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
742 .vmode = FB_VMODE_NONINTERLACED,
743 },{
744 .xres = 240,
745 .yres = 320,
746 .pixclock = 0x00e7f203,/* PLL divisor */
747 .left_margin = 0x0024,
748 .right_margin = 0x002f,
749 .upper_margin = 0x0001,
750 .lower_margin = 0x000d,
751 .hsync_len = 0x0002,
752 .vsync_len = 0x0001,
753 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
754 .vmode = FB_VMODE_NONINTERLACED,
755 }
756};
757
758static struct tmio_fb_data tosa_tc6393xb_fb_config = {
759 .lcd_set_power = tc6393xb_lcd_set_power,
760 .lcd_mode = tc6393xb_lcd_mode,
761 .num_modes = ARRAY_SIZE(tosa_tc6393xb_lcd_mode),
762 .modes = &tosa_tc6393xb_lcd_mode[0],
763 .height = 82,
764 .width = 60,
765};
ddfb33c0 766#endif
31c9b284 767
1c1b6ffc 768static struct tc6393xb_platform_data tosa_tc6393xb_data = {
bf0116e5
DB
769 .scr_pll2cr = 0x0cc1,
770 .scr_gper = 0x3300,
bf0116e5
DB
771
772 .irq_base = IRQ_BOARD_START,
773 .gpio_base = TOSA_TC6393XB_GPIO_BASE,
1c1b6ffc
DB
774 .setup = tosa_tc6393xb_setup,
775 .teardown = tosa_tc6393xb_teardown,
bf0116e5
DB
776
777 .enable = tosa_tc6393xb_enable,
778 .disable = tosa_tc6393xb_disable,
779 .suspend = tosa_tc6393xb_suspend,
780 .resume = tosa_tc6393xb_resume,
5289fecd
DB
781
782 .nand_data = &tosa_tc6393xb_nand_config,
ddfb33c0 783#ifdef CONFIG_MFD_TC6393XB
31c9b284 784 .fb_data = &tosa_tc6393xb_fb_config,
ddfb33c0 785#endif
f98a0bd0
DB
786
787 .resume_restore = 1,
bf0116e5
DB
788};
789
790
791static struct platform_device tc6393xb_device = {
792 .name = "tc6393xb",
793 .id = -1,
794 .dev = {
1c1b6ffc 795 .platform_data = &tosa_tc6393xb_data,
bf0116e5
DB
796 },
797 .num_resources = ARRAY_SIZE(tc6393xb_resources),
798 .resource = tc6393xb_resources,
799};
800
16b32fd0
DB
801static struct tosa_bt_data tosa_bt_data = {
802 .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
803 .gpio_reset = TOSA_GPIO_BT_RESET,
804};
805
806static struct platform_device tosa_bt_device = {
807 .name = "tosa-bt",
808 .id = -1,
809 .dev.platform_data = &tosa_bt_data,
810};
811
51eea52d 812static struct pxa2xx_spi_controller pxa_ssp_master_info = {
14b7b401
DB
813 .num_chipselect = 1,
814};
815
816static struct spi_board_info spi_board_info[] __initdata = {
817 {
818 .modalias = "tosa-lcd",
819 // .platform_data
820 .max_speed_hz = 28750,
821 .bus_num = 2,
822 .chip_select = 0,
823 .mode = SPI_MODE_0,
824 },
825};
16b32fd0 826
f34ee79a
DB
827static struct mtd_partition sharpsl_rom_parts[] = {
828 {
829 .name ="Boot PROM Filesystem",
830 .offset = 0x00160000,
831 .size = MTDPART_SIZ_FULL,
832 },
833};
834
835static struct physmap_flash_data sharpsl_rom_data = {
836 .width = 2,
837 .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
838 .parts = sharpsl_rom_parts,
839};
840
841static struct resource sharpsl_rom_resources[] = {
842 {
843 .start = 0x00000000,
844 .end = 0x007fffff,
845 .flags = IORESOURCE_MEM,
846 },
847};
848
849static struct platform_device sharpsl_rom_device = {
850 .name = "physmap-flash",
851 .id = -1,
852 .resource = sharpsl_rom_resources,
853 .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
854 .dev.platform_data = &sharpsl_rom_data,
855};
856
fa4704fe
DES
857static struct platform_device wm9712_device = {
858 .name = "wm9712-codec",
859 .id = -1,
860};
861
f285b8c8
AL
862static struct platform_device tosa_audio_device = {
863 .name = "tosa-audio",
864 .id = -1,
865};
866
8459c159
DO
867static struct platform_device *devices[] __initdata = {
868 &tosascoop_device,
869 &tosascoop_jc_device,
bf0116e5 870 &tc6393xb_device,
53b14ea3 871 &tosa_power_device,
a93876c1 872 &tosakbd_device,
93e9012f 873 &tosa_gpio_keys_device,
6d0cf3e0 874 &tosaled_device,
16b32fd0 875 &tosa_bt_device,
f34ee79a 876 &sharpsl_rom_device,
fa4704fe 877 &wm9712_device,
ef8b3cc6 878 &tosa_gpio_vbus,
f285b8c8 879 &tosa_audio_device,
8459c159
DO
880};
881
74617fb6
RP
882static void tosa_poweroff(void)
883{
7b6d864b 884 pxa_restart(REBOOT_GPIO, NULL);
74617fb6
RP
885}
886
7b6d864b 887static void tosa_restart(enum reboot_mode mode, const char *cmd)
74617fb6 888{
ad68bb9f
MV
889 uint32_t msc0 = __raw_readl(MSC0);
890
74617fb6 891 /* Bootloader magic for a reboot */
ad68bb9f
MV
892 if((msc0 & 0xffff0000) == 0x7ff00000)
893 __raw_writel((msc0 & 0xffff) | 0x7ee00000, MSC0);
74617fb6
RP
894
895 tosa_poweroff();
896}
897
8459c159
DO
898static void __init tosa_init(void)
899{
2cb47342 900 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
cc155c6f
RK
901
902 pxa_set_ffuart_info(NULL);
903 pxa_set_btuart_info(NULL);
904 pxa_set_stuart_info(NULL);
905
2cb47342
DB
906 gpio_set_wake(MFP_PIN_GPIO1, 1);
907 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
908
216e3b7a 909 init_gpio_reset(TOSA_GPIO_ON_RESET, 0, 0);
86159a98 910
74617fb6 911 pm_power_off = tosa_poweroff;
74617fb6 912
8459c159
DO
913 PCFR |= PCFR_OPDE;
914
a93876c1 915 /* enable batt_fault */
8459c159
DO
916 PMCR = 0x01;
917
32d15448 918 gpiod_add_lookup_table(&tosa_mci_gpio_table);
a93876c1 919 pxa_set_mci_info(&tosa_mci_platform_data);
a93876c1 920 pxa_set_ficp_info(&tosa_ficp_platform_data);
481ea5a1 921 pxa_set_i2c_info(NULL);
80748fb8 922 pxa_set_ac97_info(NULL);
4c18ad20 923 platform_scoop_config = &tosa_pcmcia_config;
8459c159 924
14b7b401
DB
925 pxa2xx_set_spi_info(2, &pxa_ssp_master_info);
926 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
927
c68ffdda 928 clk_add_alias("CLK_CK3P6MI", tc6393xb_device.name, "GPIO11_CLK", NULL);
7bdb22c9 929
4c18ad20 930 platform_add_devices(devices, ARRAY_SIZE(devices));
8459c159
DO
931}
932
1c2f87c2 933static void __init fixup_tosa(struct tag *tags, char **cmdline)
8459c159
DO
934{
935 sharpsl_save_param();
1c2f87c2 936 memblock_add(0xa0000000, SZ_64M);
8459c159
DO
937}
938
939MACHINE_START(TOSA, "SHARP Tosa")
8459c159 940 .fixup = fixup_tosa,
851982c1 941 .map_io = pxa25x_map_io,
6ac6b817 942 .nr_irqs = TOSA_NR_IRQS,
cd49104d 943 .init_irq = pxa25x_init_irq,
8a97ae2f 944 .handle_irq = pxa25x_handle_irq,
8459c159 945 .init_machine = tosa_init,
6bb27d73 946 .init_time = pxa_timer_init,
271a74fc 947 .restart = tosa_restart,
8459c159 948MACHINE_END