blob: 366a533b33a985012b11672cf555fd186b79258c [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>
Richard Purdie74617fb2006-06-19 19:57:12 +010028#include <linux/pm.h>
Dmitry Baryshkov93e90122008-01-21 01:04:20 -050029#include <linux/gpio_keys.h>
30#include <linux/input.h>
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +010031#include <linux/gpio.h>
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +010032#include <linux/pda_power.h>
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +010033#include <linux/rfkill.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>
Russell Kinga09e64f2008-08-05 16:14:15 +010038#include <mach/pxa2xx-regs.h>
39#include <mach/mfp-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>
42#include <mach/i2c.h>
43#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>
Dirk Opfer8459c152005-11-06 14:27:52 +000047
48#include <asm/mach/arch.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010049#include <mach/tosa.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000050
51#include <asm/hardware/scoop.h>
52#include <asm/mach/sharpsl_param.h>
53
54#include "generic.h"
Dmitry Baryshkov7bdb22c2008-09-10 10:30:37 +010055#include "clock.h"
Russell King46c41e62007-05-15 15:39:36 +010056#include "devices.h"
Dirk Opfer8459c152005-11-06 14:27:52 +000057
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010058static 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 */
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +010094 GPIO10_GPIO, /* nSD_INT */
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010095
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
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100132 /* Keybd */
eric miaoc8671552008-05-26 03:28:50 +0100133 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,
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100151
152 /* SPI */
153 GPIO81_SSP2_CLK_OUT,
154 GPIO82_SSP2_FRM_OUT,
155 GPIO83_SSP2_TXD,
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100156
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100157 /* IrDA is managed in other way */
158 GPIO46_GPIO,
159 GPIO47_GPIO,
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100160};
161
Dirk Opfer8459c152005-11-06 14:27:52 +0000162/*
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,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100175 .gpio_base = TOSA_SCOOP_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000176};
177
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100178static struct platform_device tosascoop_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000179 .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,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100202 .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000203};
204
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100205static struct platform_device tosascoop_jc_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000206 .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
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000216/*
217 * PCMCIA
218 */
Dirk Opfer8459c152005-11-06 14:27:52 +0000219static 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
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000232static struct scoop_pcmcia_config tosa_pcmcia_config = {
233 .devs = &tosa_pcmcia_scoop[0],
234 .num_devs = 2,
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000235};
236
Dirk Opfera93876c2005-11-08 19:15:30 +0000237/*
238 * USB Device Controller
239 */
Dirk Opfera93876c2005-11-08 19:15:30 +0000240static struct pxa2xx_udc_mach_info udc_info __initdata = {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100241 .gpio_pullup = TOSA_GPIO_USB_PULLUP,
Dmitry Baryshkov487dc922007-12-21 12:18:01 +0300242 .gpio_vbus = TOSA_GPIO_USB_IN,
243 .gpio_vbus_inverted = 1,
Dirk Opfera93876c2005-11-08 19:15:30 +0000244};
245
246/*
247 * MMC/SD Device
248 */
249static struct pxamci_platform_data tosa_mci_platform_data;
250
David Howells40220c12006-10-09 12:19:47 +0100251static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
Dirk Opfera93876c2005-11-08 19:15:30 +0000252{
253 int err;
254
Dirk Opfera93876c2005-11-08 19:15:30 +0000255 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
256
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100257 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
Russell King2687bd32008-01-23 14:05:58 +0000266 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
267 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Dirk Opfera93876c2005-11-08 19:15:30 +0000268 "MMC/SD card detect", data);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100269 if (err) {
Dirk Opfera93876c2005-11-08 19:15:30 +0000270 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100271 goto err_irq;
272 }
Dirk Opfera93876c2005-11-08 19:15:30 +0000273
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100274 err = gpio_request(TOSA_GPIO_SD_WP, "SD Write Protect");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100275 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
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100283 err = gpio_request(TOSA_GPIO_PWR_ON, "SD Power");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100284 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;
291
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100292 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
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100301 return 0;
302
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100303err_gpio_int_dir:
304 gpio_free(TOSA_GPIO_nSD_INT);
305err_gpio_int:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100306err_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:
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100314err_gpio_detect_dir:
315 gpio_free(TOSA_GPIO_nSD_DETECT);
316err_gpio_detect:
Russell King2687bd32008-01-23 14:05:58 +0000317 return err;
Dirk Opfera93876c2005-11-08 19:15:30 +0000318}
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) {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100325 gpio_set_value(TOSA_GPIO_PWR_ON, 1);
Dirk Opfera93876c2005-11-08 19:15:30 +0000326 } else {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100327 gpio_set_value(TOSA_GPIO_PWR_ON, 0);
Dirk Opfera93876c2005-11-08 19:15:30 +0000328 }
329}
330
331static int tosa_mci_get_ro(struct device *dev)
332{
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100333 return gpio_get_value(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000334}
335
336static void tosa_mci_exit(struct device *dev, void *data)
337{
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100338 gpio_free(TOSA_GPIO_nSD_INT);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100339 gpio_free(TOSA_GPIO_PWR_ON);
340 gpio_free(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000341 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100342 gpio_free(TOSA_GPIO_nSD_DETECT);
Dirk Opfera93876c2005-11-08 19:15:30 +0000343}
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 */
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100356static 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);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100360 pxa2xx_transceiver_mode(dev, mode);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100361 gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
362 } else {
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100363 pxa2xx_transceiver_mode(dev, mode);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100364 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
365 }
366}
367
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100368static int tosa_irda_startup(struct device *dev)
369{
370 int ret;
371
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100372 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
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100379 ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
380 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100381 goto err_pwr;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100382
383 ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
384 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100385 goto err_pwr_dir;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100386
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100387 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
388
389 return 0;
390
391err_pwr_dir:
392 gpio_free(TOSA_GPIO_IR_POWERDWN);
393err_pwr:
394err_tx_dir:
395 gpio_free(TOSA_GPIO_IRDA_TX);
396err_tx:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100397 return ret;
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100398}
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100399
400static void tosa_irda_shutdown(struct device *dev)
401{
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100402 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100403 gpio_free(TOSA_GPIO_IR_POWERDWN);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100404 gpio_free(TOSA_GPIO_IRDA_TX);
Dirk Opfera93876c2005-11-08 19:15:30 +0000405}
406
407static struct pxaficp_platform_data tosa_ficp_platform_data = {
408 .transceiver_cap = IR_SIRMODE | IR_OFF,
409 .transceiver_mode = tosa_irda_transceiver_mode,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100410 .startup = tosa_irda_startup,
411 .shutdown = tosa_irda_shutdown,
Dirk Opfera93876c2005-11-08 19:15:30 +0000412};
413
414/*
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100415 * 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
478/*
Dirk Opfera93876c2005-11-08 19:15:30 +0000479 * Tosa Keyboard
480 */
481static struct platform_device tosakbd_device = {
482 .name = "tosa-keyboard",
483 .id = -1,
484};
Dirk Opfer8459c152005-11-06 14:27:52 +0000485
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500486static struct gpio_keys_button tosa_gpio_keys[] = {
Dmitry Baryshkov0aa97562008-04-12 20:02:50 +0100487 /*
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 },
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500500 {
501 .type = EV_PWR,
502 .code = KEY_SUSPEND,
503 .gpio = TOSA_GPIO_ON_KEY,
504 .desc = "On key",
Dmitry Baryshkov0aa97562008-04-12 20:02:50 +0100505 /*
506 * can't be used as wakeup
507 * .wakeup = 1,
508 */
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500509 .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 },
Dmitry Baryshkovc33de472008-09-11 01:28:51 +0100527 {
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 },
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500535};
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
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800550/*
551 * Tosa LEDs
552 */
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100553static struct gpio_led tosa_gpio_leds[] = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100554 {
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 },
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100564 {
565 .name = "tosa:dual:wlan",
566 .default_trigger = "none",
567 .gpio = TOSA_GPIO_WLAN_LED,
568 },
569 {
570 .name = "tosa:blue:bluetooth",
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100571 .default_trigger = "tosa-bt",
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100572 .gpio = TOSA_GPIO_BT_LED,
573 },
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100574};
575
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100576static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100577 .leds = tosa_gpio_leds,
578 .num_leds = ARRAY_SIZE(tosa_gpio_leds),
579};
580
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800581static struct platform_device tosaled_device = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100582 .name = "leds-gpio",
583 .id = -1,
584 .dev = {
585 .platform_data = &tosa_gpio_leds_platform_data,
586 },
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800587};
588
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100589/*
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;
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +0400617 rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "tc6393xb l3v");
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100618 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
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100678static 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
Dmitry Baryshkov1c1b6ff2008-09-24 23:36:23 +0200711static 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
Dmitry Baryshkov31c9b282008-10-28 18:40:37 +0300736static struct fb_videomode tosa_tc6393xb_lcd_mode[] = {
737 {
738 .xres = 480,
739 .yres = 640,
740 .pixclock = 0x002cdf00,/* PLL divisor */
741 .left_margin = 0x004c,
742 .right_margin = 0x005b,
743 .upper_margin = 0x0001,
744 .lower_margin = 0x000d,
745 .hsync_len = 0x0002,
746 .vsync_len = 0x0001,
747 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
748 .vmode = FB_VMODE_NONINTERLACED,
749 },{
750 .xres = 240,
751 .yres = 320,
752 .pixclock = 0x00e7f203,/* PLL divisor */
753 .left_margin = 0x0024,
754 .right_margin = 0x002f,
755 .upper_margin = 0x0001,
756 .lower_margin = 0x000d,
757 .hsync_len = 0x0002,
758 .vsync_len = 0x0001,
759 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
760 .vmode = FB_VMODE_NONINTERLACED,
761 }
762};
763
764static struct tmio_fb_data tosa_tc6393xb_fb_config = {
765 .lcd_set_power = tc6393xb_lcd_set_power,
766 .lcd_mode = tc6393xb_lcd_mode,
767 .num_modes = ARRAY_SIZE(tosa_tc6393xb_lcd_mode),
768 .modes = &tosa_tc6393xb_lcd_mode[0],
769 .height = 82,
770 .width = 60,
771};
772
Dmitry Baryshkov1c1b6ff2008-09-24 23:36:23 +0200773static struct tc6393xb_platform_data tosa_tc6393xb_data = {
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100774 .scr_pll2cr = 0x0cc1,
775 .scr_gper = 0x3300,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100776
777 .irq_base = IRQ_BOARD_START,
778 .gpio_base = TOSA_TC6393XB_GPIO_BASE,
Dmitry Baryshkov1c1b6ff2008-09-24 23:36:23 +0200779 .setup = tosa_tc6393xb_setup,
780 .teardown = tosa_tc6393xb_teardown,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100781
782 .enable = tosa_tc6393xb_enable,
783 .disable = tosa_tc6393xb_disable,
784 .suspend = tosa_tc6393xb_suspend,
785 .resume = tosa_tc6393xb_resume,
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100786
787 .nand_data = &tosa_tc6393xb_nand_config,
Dmitry Baryshkov31c9b282008-10-28 18:40:37 +0300788 .fb_data = &tosa_tc6393xb_fb_config,
Dmitry Baryshkovf98a0bd2008-09-24 23:46:10 +0200789
790 .resume_restore = 1,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100791};
792
793
794static struct platform_device tc6393xb_device = {
795 .name = "tc6393xb",
796 .id = -1,
797 .dev = {
Dmitry Baryshkov1c1b6ff2008-09-24 23:36:23 +0200798 .platform_data = &tosa_tc6393xb_data,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100799 },
800 .num_resources = ARRAY_SIZE(tc6393xb_resources),
801 .resource = tc6393xb_resources,
802};
803
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100804static struct tosa_bt_data tosa_bt_data = {
805 .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
806 .gpio_reset = TOSA_GPIO_BT_RESET,
807};
808
809static struct platform_device tosa_bt_device = {
810 .name = "tosa-bt",
811 .id = -1,
812 .dev.platform_data = &tosa_bt_data,
813};
814
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +0400815static struct pxa2xx_spi_master pxa_ssp_master_info = {
816 .num_chipselect = 1,
817};
818
819static struct spi_board_info spi_board_info[] __initdata = {
820 {
821 .modalias = "tosa-lcd",
822 // .platform_data
823 .max_speed_hz = 28750,
824 .bus_num = 2,
825 .chip_select = 0,
826 .mode = SPI_MODE_0,
827 },
828};
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100829
Dirk Opfer8459c152005-11-06 14:27:52 +0000830static struct platform_device *devices[] __initdata = {
831 &tosascoop_device,
832 &tosascoop_jc_device,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100833 &tc6393xb_device,
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100834 &tosa_power_device,
Dirk Opfera93876c2005-11-08 19:15:30 +0000835 &tosakbd_device,
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500836 &tosa_gpio_keys_device,
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800837 &tosaled_device,
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100838 &tosa_bt_device,
Dirk Opfer8459c152005-11-06 14:27:52 +0000839};
840
Richard Purdie74617fb2006-06-19 19:57:12 +0100841static void tosa_poweroff(void)
842{
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100843 arm_machine_restart('g');
Richard Purdie74617fb2006-06-19 19:57:12 +0100844}
845
846static void tosa_restart(char mode)
847{
848 /* Bootloader magic for a reboot */
849 if((MSC0 & 0xffff0000) == 0x7ff00000)
850 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
851
852 tosa_poweroff();
853}
854
Dirk Opfer8459c152005-11-06 14:27:52 +0000855static void __init tosa_init(void)
856{
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100857 int dummy;
858
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100859 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
860 gpio_set_wake(MFP_PIN_GPIO1, 1);
861 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
862
Dmitry Baryshkov69fc7ee2008-10-09 16:58:13 +0100863 init_gpio_reset(TOSA_GPIO_ON_RESET, 0);
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100864
Richard Purdie74617fb2006-06-19 19:57:12 +0100865 pm_power_off = tosa_poweroff;
866 arm_pm_restart = tosa_restart;
867
Dirk Opfer8459c152005-11-06 14:27:52 +0000868 PCFR |= PCFR_OPDE;
869
Dirk Opfera93876c2005-11-08 19:15:30 +0000870 /* enable batt_fault */
Dirk Opfer8459c152005-11-06 14:27:52 +0000871 PMCR = 0x01;
872
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100873 dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
874 dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
875 dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
876
Dirk Opfera93876c2005-11-08 19:15:30 +0000877 pxa_set_mci_info(&tosa_mci_platform_data);
878 pxa_set_udc_info(&udc_info);
879 pxa_set_ficp_info(&tosa_ficp_platform_data);
Dmitry Baryshkov481ea5a2008-04-10 15:43:18 +0100880 pxa_set_i2c_info(NULL);
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000881 platform_scoop_config = &tosa_pcmcia_config;
Dirk Opfer8459c152005-11-06 14:27:52 +0000882
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +0400883 pxa2xx_set_spi_info(2, &pxa_ssp_master_info);
884 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
885
Dmitry Baryshkov7bdb22c2008-09-10 10:30:37 +0100886 clk_add_alias("CLK_CK3P6MI", &tc6393xb_device.dev, "GPIO11_CLK", NULL);
887
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000888 platform_add_devices(devices, ARRAY_SIZE(devices));
Dirk Opfer8459c152005-11-06 14:27:52 +0000889}
890
891static void __init fixup_tosa(struct machine_desc *desc,
892 struct tag *tags, char **cmdline, struct meminfo *mi)
893{
894 sharpsl_save_param();
895 mi->nr_banks=1;
896 mi->bank[0].start = 0xa0000000;
897 mi->bank[0].node = 0;
898 mi->bank[0].size = (64*1024*1024);
899}
900
901MACHINE_START(TOSA, "SHARP Tosa")
Dirk Opfer8459c152005-11-06 14:27:52 +0000902 .phys_io = 0x40000000,
903 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
904 .fixup = fixup_tosa,
905 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100906 .init_irq = pxa25x_init_irq,
Dirk Opfer8459c152005-11-06 14:27:52 +0000907 .init_machine = tosa_init,
908 .timer = &pxa_timer,
909MACHINE_END