blob: b56cc5667bb4931266a7cd47610552d1acff808e [file] [log] [blame]
Dirk Opfer8459c152005-11-06 14:27:52 +00001/*
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>
Dirk Opfer067c9042005-11-21 15:17:06 +000017#include <linux/platform_device.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000018#include <linux/major.h>
19#include <linux/fs.h>
20#include <linux/interrupt.h>
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +010021#include <linux/delay.h>
22#include <linux/fb.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000023#include <linux/mmc/host.h>
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +010024#include <linux/mfd/tc6393xb.h>
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +010025#include <linux/mfd/tmio.h>
26#include <linux/mtd/nand.h>
27#include <linux/mtd/partitions.h>
Dmitry Baryshkovf34ee792008-11-25 00:57:27 +030028#include <linux/mtd/physmap.h>
Richard Purdie74617fb2006-06-19 19:57:12 +010029#include <linux/pm.h>
Dmitry Baryshkov93e90122008-01-21 01:04:20 -050030#include <linux/gpio_keys.h>
31#include <linux/input.h>
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +010032#include <linux/gpio.h>
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +010033#include <linux/pda_power.h>
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +040034#include <linux/spi/spi.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000035
36#include <asm/setup.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000037#include <asm/mach-types.h>
Eric Miao51c62982009-01-02 23:17:22 +080038
39#include <mach/pxa25x.h>
Russell Kingafd2fc02008-08-07 11:05:25 +010040#include <mach/reset.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010041#include <mach/irda.h>
Eric Miaof0a83702009-04-13 15:03:11 +080042#include <plat/i2c.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010043#include <mach/mmc.h>
44#include <mach/udc.h>
45#include <mach/tosa_bt.h>
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +040046#include <mach/pxa2xx_spi.h>
Mark Brown80748fb2009-04-03 12:45:49 +010047#include <mach/audio.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000048
49#include <asm/mach/arch.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010050#include <mach/tosa.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000051
52#include <asm/hardware/scoop.h>
53#include <asm/mach/sharpsl_param.h>
54
55#include "generic.h"
Dmitry Baryshkov7bdb22c2008-09-10 10:30:37 +010056#include "clock.h"
Russell King46c41e62007-05-15 15:39:36 +010057#include "devices.h"
Dirk Opfer8459c152005-11-06 14:27:52 +000058
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010059static unsigned long tosa_pin_config[] = {
60 GPIO78_nCS_2, /* Scoop */
61 GPIO80_nCS_4, /* tg6393xb */
62 GPIO33_nCS_5, /* Scoop */
63
64 // GPIO76 CARD_VCC_ON1
65
66 GPIO19_GPIO, /* Reset out */
67 GPIO1_RST | WAKEUP_ON_EDGE_FALL,
68
69 GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */
70 GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */
71 GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */
72 GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */
73 GPIO20_GPIO, /* EAR_IN */
74 GPIO22_GPIO, /* On */
75
76 GPIO5_GPIO, /* USB_IN */
77 GPIO32_GPIO, /* Pen IRQ */
78
79 GPIO7_GPIO, /* Jacket Detect */
80 GPIO14_GPIO, /* BAT0_CRG */
81 GPIO12_GPIO, /* BAT1_CRG */
82 GPIO17_GPIO, /* BAT0_LOW */
83 GPIO84_GPIO, /* BAT1_LOW */
84 GPIO38_GPIO, /* BAT_LOCK */
85
86 GPIO11_3_6MHz,
87 GPIO15_GPIO, /* TC6393XB IRQ */
88 GPIO18_RDY,
89 GPIO27_GPIO, /* LCD Sync */
90
91 /* MMC */
92 GPIO6_MMC_CLK,
93 GPIO8_MMC_CS0,
94 GPIO9_GPIO, /* Detect */
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +010095 GPIO10_GPIO, /* nSD_INT */
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010096
97 /* CF */
98 GPIO13_GPIO, /* CD_IRQ */
99 GPIO21_GPIO, /* Main Slot IRQ */
100 GPIO36_GPIO, /* Jacket Slot IRQ */
101 GPIO48_nPOE,
102 GPIO49_nPWE,
103 GPIO50_nPIOR,
104 GPIO51_nPIOW,
105 GPIO52_nPCE_1,
106 GPIO53_nPCE_2,
107 GPIO54_nPSKTSEL,
108 GPIO55_nPREG,
109 GPIO56_nPWAIT,
110 GPIO57_nIOIS16,
111
112 /* AC97 */
113 GPIO31_AC97_SYNC,
114 GPIO30_AC97_SDATA_OUT,
115 GPIO28_AC97_BITCLK,
116 GPIO29_AC97_SDATA_IN_0,
117 // GPIO79 nAUD_IRQ
118
119 /* FFUART */
120 GPIO34_FFUART_RXD,
121 GPIO35_FFUART_CTS,
122 GPIO37_FFUART_DSR,
123 GPIO39_FFUART_TXD,
124 GPIO40_FFUART_DTR,
125 GPIO41_FFUART_RTS,
126
127 /* BTUART */
128 GPIO42_BTUART_RXD,
129 GPIO43_BTUART_TXD,
130 GPIO44_BTUART_CTS,
131 GPIO45_BTUART_RTS,
132
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100133 /* Keybd */
eric miaoc8671552008-05-26 03:28:50 +0100134 GPIO58_GPIO | MFP_LPM_DRIVE_LOW,
135 GPIO59_GPIO | MFP_LPM_DRIVE_LOW,
136 GPIO60_GPIO | MFP_LPM_DRIVE_LOW,
137 GPIO61_GPIO | MFP_LPM_DRIVE_LOW,
138 GPIO62_GPIO | MFP_LPM_DRIVE_LOW,
139 GPIO63_GPIO | MFP_LPM_DRIVE_LOW,
140 GPIO64_GPIO | MFP_LPM_DRIVE_LOW,
141 GPIO65_GPIO | MFP_LPM_DRIVE_LOW,
142 GPIO66_GPIO | MFP_LPM_DRIVE_LOW,
143 GPIO67_GPIO | MFP_LPM_DRIVE_LOW,
144 GPIO68_GPIO | MFP_LPM_DRIVE_LOW,
145 GPIO69_GPIO | MFP_LPM_DRIVE_LOW,
146 GPIO70_GPIO | MFP_LPM_DRIVE_LOW,
147 GPIO71_GPIO | MFP_LPM_DRIVE_LOW,
148 GPIO72_GPIO | MFP_LPM_DRIVE_LOW,
149 GPIO73_GPIO | MFP_LPM_DRIVE_LOW,
150 GPIO74_GPIO | MFP_LPM_DRIVE_LOW,
151 GPIO75_GPIO | MFP_LPM_DRIVE_LOW,
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100152
153 /* SPI */
154 GPIO81_SSP2_CLK_OUT,
155 GPIO82_SSP2_FRM_OUT,
156 GPIO83_SSP2_TXD,
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100157
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100158 /* IrDA is managed in other way */
159 GPIO46_GPIO,
160 GPIO47_GPIO,
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100161};
162
Dirk Opfer8459c152005-11-06 14:27:52 +0000163/*
164 * SCOOP Device
165 */
166static struct resource tosa_scoop_resources[] = {
167 [0] = {
168 .start = TOSA_CF_PHYS,
169 .end = TOSA_CF_PHYS + 0xfff,
170 .flags = IORESOURCE_MEM,
171 },
172};
173
174static struct scoop_config tosa_scoop_setup = {
175 .io_dir = TOSA_SCOOP_IO_DIR,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100176 .gpio_base = TOSA_SCOOP_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000177};
178
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100179static struct platform_device tosascoop_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000180 .name = "sharp-scoop",
181 .id = 0,
182 .dev = {
183 .platform_data = &tosa_scoop_setup,
184 },
185 .num_resources = ARRAY_SIZE(tosa_scoop_resources),
186 .resource = tosa_scoop_resources,
187};
188
189
190/*
191 * SCOOP Device Jacket
192 */
193static struct resource tosa_scoop_jc_resources[] = {
194 [0] = {
195 .start = TOSA_SCOOP_PHYS + 0x40,
196 .end = TOSA_SCOOP_PHYS + 0xfff,
197 .flags = IORESOURCE_MEM,
198 },
199};
200
201static struct scoop_config tosa_scoop_jc_setup = {
202 .io_dir = TOSA_SCOOP_JC_IO_DIR,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100203 .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000204};
205
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100206static struct platform_device tosascoop_jc_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000207 .name = "sharp-scoop",
208 .id = 1,
209 .dev = {
210 .platform_data = &tosa_scoop_jc_setup,
211 .parent = &tosascoop_device.dev,
212 },
213 .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
214 .resource = tosa_scoop_jc_resources,
215};
216
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000217/*
218 * PCMCIA
219 */
Dirk Opfer8459c152005-11-06 14:27:52 +0000220static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
221{
222 .dev = &tosascoop_device.dev,
223 .irq = TOSA_IRQ_GPIO_CF_IRQ,
224 .cd_irq = TOSA_IRQ_GPIO_CF_CD,
225 .cd_irq_str = "PCMCIA0 CD",
226},{
227 .dev = &tosascoop_jc_device.dev,
228 .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
229 .cd_irq = -1,
230},
231};
232
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000233static struct scoop_pcmcia_config tosa_pcmcia_config = {
234 .devs = &tosa_pcmcia_scoop[0],
235 .num_devs = 2,
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000236};
237
Dirk Opfera93876c2005-11-08 19:15:30 +0000238/*
239 * USB Device Controller
240 */
Dirk Opfera93876c2005-11-08 19:15:30 +0000241static struct pxa2xx_udc_mach_info udc_info __initdata = {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100242 .gpio_pullup = TOSA_GPIO_USB_PULLUP,
Dmitry Baryshkov487dc922007-12-21 12:18:01 +0300243 .gpio_vbus = TOSA_GPIO_USB_IN,
244 .gpio_vbus_inverted = 1,
Dirk Opfera93876c2005-11-08 19:15:30 +0000245};
246
247/*
248 * MMC/SD Device
249 */
David Howells40220c12006-10-09 12:19:47 +0100250static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
Dirk Opfera93876c2005-11-08 19:15:30 +0000251{
252 int err;
253
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100254 err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
255 if (err) {
256 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
257 goto err_gpio_int;
258 }
259 err = gpio_direction_input(TOSA_GPIO_nSD_INT);
260 if (err)
261 goto err_gpio_int_dir;
262
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100263 return 0;
264
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100265err_gpio_int_dir:
266 gpio_free(TOSA_GPIO_nSD_INT);
267err_gpio_int:
Russell King2687bd32008-01-23 14:05:58 +0000268 return err;
Dirk Opfera93876c2005-11-08 19:15:30 +0000269}
270
Dirk Opfera93876c2005-11-08 19:15:30 +0000271static void tosa_mci_exit(struct device *dev, void *data)
272{
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100273 gpio_free(TOSA_GPIO_nSD_INT);
Dirk Opfera93876c2005-11-08 19:15:30 +0000274}
275
276static struct pxamci_platform_data tosa_mci_platform_data = {
Robert Jarzmik7a648252009-07-06 22:16:42 +0200277 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
278 .init = tosa_mci_init,
279 .exit = tosa_mci_exit,
280 .gpio_card_detect = TOSA_GPIO_nSD_DETECT,
281 .gpio_card_ro = TOSA_GPIO_SD_WP,
282 .gpio_power = TOSA_GPIO_PWR_ON,
Dirk Opfera93876c2005-11-08 19:15:30 +0000283};
284
285/*
286 * Irda
287 */
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100288static void tosa_irda_transceiver_mode(struct device *dev, int mode)
289{
290 if (mode & IR_OFF) {
291 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100292 pxa2xx_transceiver_mode(dev, mode);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100293 gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
294 } else {
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100295 pxa2xx_transceiver_mode(dev, mode);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100296 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
297 }
298}
299
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100300static int tosa_irda_startup(struct device *dev)
301{
302 int ret;
303
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100304 ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
305 if (ret)
306 goto err_tx;
307 ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
308 if (ret)
309 goto err_tx_dir;
310
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100311 ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
312 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100313 goto err_pwr;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100314
315 ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
316 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100317 goto err_pwr_dir;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100318
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100319 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
320
321 return 0;
322
323err_pwr_dir:
324 gpio_free(TOSA_GPIO_IR_POWERDWN);
325err_pwr:
326err_tx_dir:
327 gpio_free(TOSA_GPIO_IRDA_TX);
328err_tx:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100329 return ret;
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100330}
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100331
332static void tosa_irda_shutdown(struct device *dev)
333{
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100334 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100335 gpio_free(TOSA_GPIO_IR_POWERDWN);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100336 gpio_free(TOSA_GPIO_IRDA_TX);
Dirk Opfera93876c2005-11-08 19:15:30 +0000337}
338
339static struct pxaficp_platform_data tosa_ficp_platform_data = {
340 .transceiver_cap = IR_SIRMODE | IR_OFF,
341 .transceiver_mode = tosa_irda_transceiver_mode,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100342 .startup = tosa_irda_startup,
343 .shutdown = tosa_irda_shutdown,
Dirk Opfera93876c2005-11-08 19:15:30 +0000344};
345
346/*
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100347 * Tosa AC IN
348 */
349static int tosa_power_init(struct device *dev)
350{
351 int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
352 if (ret)
353 goto err_gpio_req;
354
355 ret = gpio_direction_input(TOSA_GPIO_AC_IN);
356 if (ret)
357 goto err_gpio_in;
358
359 return 0;
360
361err_gpio_in:
362 gpio_free(TOSA_GPIO_AC_IN);
363err_gpio_req:
364 return ret;
365}
366
367static void tosa_power_exit(struct device *dev)
368{
369 gpio_free(TOSA_GPIO_AC_IN);
370}
371
372static int tosa_power_ac_online(void)
373{
374 return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
375}
376
377static char *tosa_ac_supplied_to[] = {
378 "main-battery",
379 "backup-battery",
380 "jacket-battery",
381};
382
383static struct pda_power_pdata tosa_power_data = {
384 .init = tosa_power_init,
385 .is_ac_online = tosa_power_ac_online,
386 .exit = tosa_power_exit,
387 .supplied_to = tosa_ac_supplied_to,
388 .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
389};
390
391static struct resource tosa_power_resource[] = {
392 {
393 .name = "ac",
394 .start = gpio_to_irq(TOSA_GPIO_AC_IN),
395 .end = gpio_to_irq(TOSA_GPIO_AC_IN),
396 .flags = IORESOURCE_IRQ |
397 IORESOURCE_IRQ_HIGHEDGE |
398 IORESOURCE_IRQ_LOWEDGE,
399 },
400};
401
402static struct platform_device tosa_power_device = {
403 .name = "pda-power",
404 .id = -1,
405 .dev.platform_data = &tosa_power_data,
406 .resource = tosa_power_resource,
407 .num_resources = ARRAY_SIZE(tosa_power_resource),
408};
409
410/*
Dirk Opfera93876c2005-11-08 19:15:30 +0000411 * Tosa Keyboard
412 */
413static struct platform_device tosakbd_device = {
414 .name = "tosa-keyboard",
415 .id = -1,
416};
Dirk Opfer8459c152005-11-06 14:27:52 +0000417
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500418static struct gpio_keys_button tosa_gpio_keys[] = {
Dmitry Baryshkov0aa97562008-04-12 20:02:50 +0100419 /*
420 * Two following keys are directly tied to "ON" button of tosa. Why?
421 * The first one can be used as a wakeup source, the second can't;
422 * also the first one is OR of ac_powered and on_button.
423 */
424 {
425 .type = EV_PWR,
426 .code = KEY_RESERVED,
427 .gpio = TOSA_GPIO_POWERON,
428 .desc = "Poweron",
429 .wakeup = 1,
430 .active_low = 1,
431 },
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500432 {
433 .type = EV_PWR,
434 .code = KEY_SUSPEND,
435 .gpio = TOSA_GPIO_ON_KEY,
436 .desc = "On key",
Dmitry Baryshkov0aa97562008-04-12 20:02:50 +0100437 /*
438 * can't be used as wakeup
439 * .wakeup = 1,
440 */
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500441 .active_low = 1,
442 },
443 {
444 .type = EV_KEY,
445 .code = TOSA_KEY_RECORD,
446 .gpio = TOSA_GPIO_RECORD_BTN,
447 .desc = "Record Button",
448 .wakeup = 1,
449 .active_low = 1,
450 },
451 {
452 .type = EV_KEY,
453 .code = TOSA_KEY_SYNC,
454 .gpio = TOSA_GPIO_SYNC,
455 .desc = "Sync Button",
456 .wakeup = 1,
457 .active_low = 1,
458 },
Dmitry Baryshkovc33de472008-09-11 01:28:51 +0100459 {
460 .type = EV_SW,
461 .code = SW_HEADPHONE_INSERT,
462 .gpio = TOSA_GPIO_EAR_IN,
463 .desc = "HeadPhone insert",
464 .active_low = 1,
465 .debounce_interval = 300,
466 },
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500467};
468
469static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
470 .buttons = tosa_gpio_keys,
471 .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
472};
473
474static struct platform_device tosa_gpio_keys_device = {
475 .name = "gpio-keys",
476 .id = -1,
477 .dev = {
478 .platform_data = &tosa_gpio_keys_platform_data,
479 },
480};
481
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800482/*
483 * Tosa LEDs
484 */
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100485static struct gpio_led tosa_gpio_leds[] = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100486 {
487 .name = "tosa:amber:charge",
488 .default_trigger = "main-battery-charging",
489 .gpio = TOSA_GPIO_CHRG_ERR_LED,
490 },
491 {
492 .name = "tosa:green:mail",
493 .default_trigger = "nand-disk",
494 .gpio = TOSA_GPIO_NOTE_LED,
495 },
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100496 {
497 .name = "tosa:dual:wlan",
498 .default_trigger = "none",
499 .gpio = TOSA_GPIO_WLAN_LED,
500 },
501 {
502 .name = "tosa:blue:bluetooth",
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100503 .default_trigger = "tosa-bt",
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100504 .gpio = TOSA_GPIO_BT_LED,
505 },
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100506};
507
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100508static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100509 .leds = tosa_gpio_leds,
510 .num_leds = ARRAY_SIZE(tosa_gpio_leds),
511};
512
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800513static struct platform_device tosaled_device = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100514 .name = "leds-gpio",
515 .id = -1,
516 .dev = {
517 .platform_data = &tosa_gpio_leds_platform_data,
518 },
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800519};
520
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100521/*
522 * Toshiba Mobile IO Controller
523 */
524static struct resource tc6393xb_resources[] = {
525 [0] = {
526 .start = TOSA_LCDC_PHYS,
527 .end = TOSA_LCDC_PHYS + 0x3ffffff,
528 .flags = IORESOURCE_MEM,
529 },
530
531 [1] = {
532 .start = TOSA_IRQ_GPIO_TC6393XB_INT,
533 .end = TOSA_IRQ_GPIO_TC6393XB_INT,
534 .flags = IORESOURCE_IRQ,
535 },
536};
537
538
539static int tosa_tc6393xb_enable(struct platform_device *dev)
540{
541 int rc;
542
543 rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
544 if (rc)
545 goto err_req_pclr;
546 rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
547 if (rc)
548 goto err_req_suspend;
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +0400549 rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "tc6393xb l3v");
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100550 if (rc)
551 goto err_req_l3v;
552 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
553 if (rc)
554 goto err_dir_l3v;
555 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
556 if (rc)
557 goto err_dir_suspend;
558 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
559 if (rc)
560 goto err_dir_pclr;
561
562 mdelay(1);
563
564 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
565
566 mdelay(10);
567
568 gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
569 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
570
571 return 0;
572err_dir_pclr:
573err_dir_suspend:
574err_dir_l3v:
575 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
576err_req_l3v:
577 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
578err_req_suspend:
579 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
580err_req_pclr:
581 return rc;
582}
583
584static int tosa_tc6393xb_disable(struct platform_device *dev)
585{
586 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
587 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
588 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
589
590 return 0;
591}
592
593static int tosa_tc6393xb_resume(struct platform_device *dev)
594{
595 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
596 mdelay(10);
597 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
598 mdelay(10);
599
600 return 0;
601}
602
603static int tosa_tc6393xb_suspend(struct platform_device *dev)
604{
605 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
606 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
607 return 0;
608}
609
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100610static struct mtd_partition tosa_nand_partition[] = {
611 {
612 .name = "smf",
613 .offset = 0,
614 .size = 7 * 1024 * 1024,
615 },
616 {
617 .name = "root",
618 .offset = MTDPART_OFS_APPEND,
619 .size = 28 * 1024 * 1024,
620 },
621 {
622 .name = "home",
623 .offset = MTDPART_OFS_APPEND,
624 .size = MTDPART_SIZ_FULL,
625 },
626};
627
628static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
629
630static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = {
631 .options = 0,
632 .offs = 4,
633 .len = 2,
634 .pattern = scan_ff_pattern
635};
636
637static struct tmio_nand_data tosa_tc6393xb_nand_config = {
638 .num_partitions = ARRAY_SIZE(tosa_nand_partition),
639 .partition = tosa_nand_partition,
640 .badblock_pattern = &tosa_tc6393xb_nand_bbt,
641};
642
Dmitry Baryshkov1c1b6ff2008-09-24 23:36:23 +0200643static int tosa_tc6393xb_setup(struct platform_device *dev)
644{
645 int rc;
646
647 rc = gpio_request(TOSA_GPIO_CARD_VCC_ON, "CARD_VCC_ON");
648 if (rc)
649 goto err_req;
650
651 rc = gpio_direction_output(TOSA_GPIO_CARD_VCC_ON, 1);
652 if (rc)
653 goto err_dir;
654
655 return rc;
656
657err_dir:
658 gpio_free(TOSA_GPIO_CARD_VCC_ON);
659err_req:
660 return rc;
661}
662
663static void tosa_tc6393xb_teardown(struct platform_device *dev)
664{
665 gpio_free(TOSA_GPIO_CARD_VCC_ON);
666}
667
Dmitry Baryshkovddfb33c2008-11-27 01:25:09 +0300668#ifdef CONFIG_MFD_TC6393XB
Dmitry Baryshkov31c9b282008-10-28 18:40:37 +0300669static struct fb_videomode tosa_tc6393xb_lcd_mode[] = {
670 {
671 .xres = 480,
672 .yres = 640,
673 .pixclock = 0x002cdf00,/* PLL divisor */
674 .left_margin = 0x004c,
675 .right_margin = 0x005b,
676 .upper_margin = 0x0001,
677 .lower_margin = 0x000d,
678 .hsync_len = 0x0002,
679 .vsync_len = 0x0001,
680 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
681 .vmode = FB_VMODE_NONINTERLACED,
682 },{
683 .xres = 240,
684 .yres = 320,
685 .pixclock = 0x00e7f203,/* PLL divisor */
686 .left_margin = 0x0024,
687 .right_margin = 0x002f,
688 .upper_margin = 0x0001,
689 .lower_margin = 0x000d,
690 .hsync_len = 0x0002,
691 .vsync_len = 0x0001,
692 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
693 .vmode = FB_VMODE_NONINTERLACED,
694 }
695};
696
697static struct tmio_fb_data tosa_tc6393xb_fb_config = {
698 .lcd_set_power = tc6393xb_lcd_set_power,
699 .lcd_mode = tc6393xb_lcd_mode,
700 .num_modes = ARRAY_SIZE(tosa_tc6393xb_lcd_mode),
701 .modes = &tosa_tc6393xb_lcd_mode[0],
702 .height = 82,
703 .width = 60,
704};
Dmitry Baryshkovddfb33c2008-11-27 01:25:09 +0300705#endif
Dmitry Baryshkov31c9b282008-10-28 18:40:37 +0300706
Dmitry Baryshkov1c1b6ff2008-09-24 23:36:23 +0200707static struct tc6393xb_platform_data tosa_tc6393xb_data = {
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100708 .scr_pll2cr = 0x0cc1,
709 .scr_gper = 0x3300,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100710
711 .irq_base = IRQ_BOARD_START,
712 .gpio_base = TOSA_TC6393XB_GPIO_BASE,
Dmitry Baryshkov1c1b6ff2008-09-24 23:36:23 +0200713 .setup = tosa_tc6393xb_setup,
714 .teardown = tosa_tc6393xb_teardown,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100715
716 .enable = tosa_tc6393xb_enable,
717 .disable = tosa_tc6393xb_disable,
718 .suspend = tosa_tc6393xb_suspend,
719 .resume = tosa_tc6393xb_resume,
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100720
721 .nand_data = &tosa_tc6393xb_nand_config,
Dmitry Baryshkovddfb33c2008-11-27 01:25:09 +0300722#ifdef CONFIG_MFD_TC6393XB
Dmitry Baryshkov31c9b282008-10-28 18:40:37 +0300723 .fb_data = &tosa_tc6393xb_fb_config,
Dmitry Baryshkovddfb33c2008-11-27 01:25:09 +0300724#endif
Dmitry Baryshkovf98a0bd2008-09-24 23:46:10 +0200725
726 .resume_restore = 1,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100727};
728
729
730static struct platform_device tc6393xb_device = {
731 .name = "tc6393xb",
732 .id = -1,
733 .dev = {
Dmitry Baryshkov1c1b6ff2008-09-24 23:36:23 +0200734 .platform_data = &tosa_tc6393xb_data,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100735 },
736 .num_resources = ARRAY_SIZE(tc6393xb_resources),
737 .resource = tc6393xb_resources,
738};
739
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100740static struct tosa_bt_data tosa_bt_data = {
741 .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
742 .gpio_reset = TOSA_GPIO_BT_RESET,
743};
744
745static struct platform_device tosa_bt_device = {
746 .name = "tosa-bt",
747 .id = -1,
748 .dev.platform_data = &tosa_bt_data,
749};
750
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +0400751static struct pxa2xx_spi_master pxa_ssp_master_info = {
752 .num_chipselect = 1,
753};
754
755static struct spi_board_info spi_board_info[] __initdata = {
756 {
757 .modalias = "tosa-lcd",
758 // .platform_data
759 .max_speed_hz = 28750,
760 .bus_num = 2,
761 .chip_select = 0,
762 .mode = SPI_MODE_0,
763 },
764};
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100765
Dmitry Baryshkovf34ee792008-11-25 00:57:27 +0300766static struct mtd_partition sharpsl_rom_parts[] = {
767 {
768 .name ="Boot PROM Filesystem",
769 .offset = 0x00160000,
770 .size = MTDPART_SIZ_FULL,
771 },
772};
773
774static struct physmap_flash_data sharpsl_rom_data = {
775 .width = 2,
776 .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
777 .parts = sharpsl_rom_parts,
778};
779
780static struct resource sharpsl_rom_resources[] = {
781 {
782 .start = 0x00000000,
783 .end = 0x007fffff,
784 .flags = IORESOURCE_MEM,
785 },
786};
787
788static struct platform_device sharpsl_rom_device = {
789 .name = "physmap-flash",
790 .id = -1,
791 .resource = sharpsl_rom_resources,
792 .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
793 .dev.platform_data = &sharpsl_rom_data,
794};
795
Dirk Opfer8459c152005-11-06 14:27:52 +0000796static struct platform_device *devices[] __initdata = {
797 &tosascoop_device,
798 &tosascoop_jc_device,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100799 &tc6393xb_device,
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100800 &tosa_power_device,
Dirk Opfera93876c2005-11-08 19:15:30 +0000801 &tosakbd_device,
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500802 &tosa_gpio_keys_device,
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800803 &tosaled_device,
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100804 &tosa_bt_device,
Dmitry Baryshkovf34ee792008-11-25 00:57:27 +0300805 &sharpsl_rom_device,
Dirk Opfer8459c152005-11-06 14:27:52 +0000806};
807
Richard Purdie74617fb2006-06-19 19:57:12 +0100808static void tosa_poweroff(void)
809{
Russell Kingbe093be2009-03-19 16:20:24 +0000810 arm_machine_restart('g', NULL);
Richard Purdie74617fb2006-06-19 19:57:12 +0100811}
812
Russell Kingbe093be2009-03-19 16:20:24 +0000813static void tosa_restart(char mode, const char *cmd)
Richard Purdie74617fb2006-06-19 19:57:12 +0100814{
815 /* Bootloader magic for a reboot */
816 if((MSC0 & 0xffff0000) == 0x7ff00000)
817 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
818
819 tosa_poweroff();
820}
821
Dirk Opfer8459c152005-11-06 14:27:52 +0000822static void __init tosa_init(void)
823{
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100824 int dummy;
825
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100826 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
827 gpio_set_wake(MFP_PIN_GPIO1, 1);
828 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
829
Daniel Ribeiro216e3b72009-05-05 22:43:18 -0300830 init_gpio_reset(TOSA_GPIO_ON_RESET, 0, 0);
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100831
Richard Purdie74617fb2006-06-19 19:57:12 +0100832 pm_power_off = tosa_poweroff;
833 arm_pm_restart = tosa_restart;
834
Dirk Opfer8459c152005-11-06 14:27:52 +0000835 PCFR |= PCFR_OPDE;
836
Dirk Opfera93876c2005-11-08 19:15:30 +0000837 /* enable batt_fault */
Dirk Opfer8459c152005-11-06 14:27:52 +0000838 PMCR = 0x01;
839
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100840 dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
841 dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
842 dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
843
Robert Jarzmik7a648252009-07-06 22:16:42 +0200844 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
Dirk Opfera93876c2005-11-08 19:15:30 +0000845 pxa_set_mci_info(&tosa_mci_platform_data);
846 pxa_set_udc_info(&udc_info);
847 pxa_set_ficp_info(&tosa_ficp_platform_data);
Dmitry Baryshkov481ea5a2008-04-10 15:43:18 +0100848 pxa_set_i2c_info(NULL);
Mark Brown80748fb2009-04-03 12:45:49 +0100849 pxa_set_ac97_info(NULL);
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000850 platform_scoop_config = &tosa_pcmcia_config;
Dirk Opfer8459c152005-11-06 14:27:52 +0000851
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +0400852 pxa2xx_set_spi_info(2, &pxa_ssp_master_info);
853 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
854
Dmitry Eremin-Solenikovc68ffdd2009-03-05 18:17:53 +0300855 clk_add_alias("CLK_CK3P6MI", tc6393xb_device.name, "GPIO11_CLK", NULL);
Dmitry Baryshkov7bdb22c2008-09-10 10:30:37 +0100856
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000857 platform_add_devices(devices, ARRAY_SIZE(devices));
Dirk Opfer8459c152005-11-06 14:27:52 +0000858}
859
860static void __init fixup_tosa(struct machine_desc *desc,
861 struct tag *tags, char **cmdline, struct meminfo *mi)
862{
863 sharpsl_save_param();
864 mi->nr_banks=1;
865 mi->bank[0].start = 0xa0000000;
866 mi->bank[0].node = 0;
867 mi->bank[0].size = (64*1024*1024);
868}
869
870MACHINE_START(TOSA, "SHARP Tosa")
Dirk Opfer8459c152005-11-06 14:27:52 +0000871 .phys_io = 0x40000000,
872 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
873 .fixup = fixup_tosa,
874 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100875 .init_irq = pxa25x_init_irq,
Dirk Opfer8459c152005-11-06 14:27:52 +0000876 .init_machine = tosa_init,
877 .timer = &pxa_timer,
878MACHINE_END