blob: 3332e5d0356c522b7c266995f5f88dd26e02342c [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 Baryshkov16b32fd2008-07-05 09:02:48 +010034#include <linux/rfkill.h>
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +040035#include <linux/spi/spi.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000036
37#include <asm/setup.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000038#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010039#include <mach/pxa2xx-regs.h>
40#include <mach/mfp-pxa25x.h>
Russell Kingafd2fc02008-08-07 11:05:25 +010041#include <mach/reset.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010042#include <mach/irda.h>
43#include <mach/i2c.h>
44#include <mach/mmc.h>
45#include <mach/udc.h>
46#include <mach/tosa_bt.h>
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +040047#include <mach/pxa2xx_spi.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 */
250static struct pxamci_platform_data tosa_mci_platform_data;
251
David Howells40220c12006-10-09 12:19:47 +0100252static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
Dirk Opfera93876c2005-11-08 19:15:30 +0000253{
254 int err;
255
Dirk Opfera93876c2005-11-08 19:15:30 +0000256 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
257
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100258 err = gpio_request(TOSA_GPIO_nSD_DETECT, "MMC/SD card detect");
259 if (err) {
260 printk(KERN_ERR "tosa_mci_init: can't request nSD_DETECT gpio\n");
261 goto err_gpio_detect;
262 }
263 err = gpio_direction_input(TOSA_GPIO_nSD_DETECT);
264 if (err)
265 goto err_gpio_detect_dir;
266
Russell King2687bd32008-01-23 14:05:58 +0000267 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
268 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Dirk Opfera93876c2005-11-08 19:15:30 +0000269 "MMC/SD card detect", data);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100270 if (err) {
Dirk Opfera93876c2005-11-08 19:15:30 +0000271 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100272 goto err_irq;
273 }
Dirk Opfera93876c2005-11-08 19:15:30 +0000274
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100275 err = gpio_request(TOSA_GPIO_SD_WP, "SD Write Protect");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100276 if (err) {
277 printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n");
278 goto err_gpio_wp;
279 }
280 err = gpio_direction_input(TOSA_GPIO_SD_WP);
281 if (err)
282 goto err_gpio_wp_dir;
283
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100284 err = gpio_request(TOSA_GPIO_PWR_ON, "SD Power");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100285 if (err) {
286 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
287 goto err_gpio_pwr;
288 }
289 err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0);
290 if (err)
291 goto err_gpio_pwr_dir;
292
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100293 err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
294 if (err) {
295 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
296 goto err_gpio_int;
297 }
298 err = gpio_direction_input(TOSA_GPIO_nSD_INT);
299 if (err)
300 goto err_gpio_int_dir;
301
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100302 return 0;
303
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100304err_gpio_int_dir:
305 gpio_free(TOSA_GPIO_nSD_INT);
306err_gpio_int:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100307err_gpio_pwr_dir:
308 gpio_free(TOSA_GPIO_PWR_ON);
309err_gpio_pwr:
310err_gpio_wp_dir:
311 gpio_free(TOSA_GPIO_SD_WP);
312err_gpio_wp:
313 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
314err_irq:
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100315err_gpio_detect_dir:
316 gpio_free(TOSA_GPIO_nSD_DETECT);
317err_gpio_detect:
Russell King2687bd32008-01-23 14:05:58 +0000318 return err;
Dirk Opfera93876c2005-11-08 19:15:30 +0000319}
320
321static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
322{
323 struct pxamci_platform_data* p_d = dev->platform_data;
324
325 if (( 1 << vdd) & p_d->ocr_mask) {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100326 gpio_set_value(TOSA_GPIO_PWR_ON, 1);
Dirk Opfera93876c2005-11-08 19:15:30 +0000327 } else {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100328 gpio_set_value(TOSA_GPIO_PWR_ON, 0);
Dirk Opfera93876c2005-11-08 19:15:30 +0000329 }
330}
331
332static int tosa_mci_get_ro(struct device *dev)
333{
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100334 return gpio_get_value(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000335}
336
337static void tosa_mci_exit(struct device *dev, void *data)
338{
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100339 gpio_free(TOSA_GPIO_nSD_INT);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100340 gpio_free(TOSA_GPIO_PWR_ON);
341 gpio_free(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000342 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100343 gpio_free(TOSA_GPIO_nSD_DETECT);
Dirk Opfera93876c2005-11-08 19:15:30 +0000344}
345
346static struct pxamci_platform_data tosa_mci_platform_data = {
347 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
348 .init = tosa_mci_init,
349 .get_ro = tosa_mci_get_ro,
350 .setpower = tosa_mci_setpower,
351 .exit = tosa_mci_exit,
352};
353
354/*
355 * Irda
356 */
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100357static void tosa_irda_transceiver_mode(struct device *dev, int mode)
358{
359 if (mode & IR_OFF) {
360 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100361 pxa2xx_transceiver_mode(dev, mode);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100362 gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
363 } else {
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100364 pxa2xx_transceiver_mode(dev, mode);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100365 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
366 }
367}
368
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100369static int tosa_irda_startup(struct device *dev)
370{
371 int ret;
372
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100373 ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
374 if (ret)
375 goto err_tx;
376 ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
377 if (ret)
378 goto err_tx_dir;
379
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100380 ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
381 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100382 goto err_pwr;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100383
384 ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
385 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100386 goto err_pwr_dir;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100387
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100388 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
389
390 return 0;
391
392err_pwr_dir:
393 gpio_free(TOSA_GPIO_IR_POWERDWN);
394err_pwr:
395err_tx_dir:
396 gpio_free(TOSA_GPIO_IRDA_TX);
397err_tx:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100398 return ret;
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100399}
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100400
401static void tosa_irda_shutdown(struct device *dev)
402{
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100403 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100404 gpio_free(TOSA_GPIO_IR_POWERDWN);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100405 gpio_free(TOSA_GPIO_IRDA_TX);
Dirk Opfera93876c2005-11-08 19:15:30 +0000406}
407
408static struct pxaficp_platform_data tosa_ficp_platform_data = {
409 .transceiver_cap = IR_SIRMODE | IR_OFF,
410 .transceiver_mode = tosa_irda_transceiver_mode,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100411 .startup = tosa_irda_startup,
412 .shutdown = tosa_irda_shutdown,
Dirk Opfera93876c2005-11-08 19:15:30 +0000413};
414
415/*
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100416 * Tosa AC IN
417 */
418static int tosa_power_init(struct device *dev)
419{
420 int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
421 if (ret)
422 goto err_gpio_req;
423
424 ret = gpio_direction_input(TOSA_GPIO_AC_IN);
425 if (ret)
426 goto err_gpio_in;
427
428 return 0;
429
430err_gpio_in:
431 gpio_free(TOSA_GPIO_AC_IN);
432err_gpio_req:
433 return ret;
434}
435
436static void tosa_power_exit(struct device *dev)
437{
438 gpio_free(TOSA_GPIO_AC_IN);
439}
440
441static int tosa_power_ac_online(void)
442{
443 return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
444}
445
446static char *tosa_ac_supplied_to[] = {
447 "main-battery",
448 "backup-battery",
449 "jacket-battery",
450};
451
452static struct pda_power_pdata tosa_power_data = {
453 .init = tosa_power_init,
454 .is_ac_online = tosa_power_ac_online,
455 .exit = tosa_power_exit,
456 .supplied_to = tosa_ac_supplied_to,
457 .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
458};
459
460static struct resource tosa_power_resource[] = {
461 {
462 .name = "ac",
463 .start = gpio_to_irq(TOSA_GPIO_AC_IN),
464 .end = gpio_to_irq(TOSA_GPIO_AC_IN),
465 .flags = IORESOURCE_IRQ |
466 IORESOURCE_IRQ_HIGHEDGE |
467 IORESOURCE_IRQ_LOWEDGE,
468 },
469};
470
471static struct platform_device tosa_power_device = {
472 .name = "pda-power",
473 .id = -1,
474 .dev.platform_data = &tosa_power_data,
475 .resource = tosa_power_resource,
476 .num_resources = ARRAY_SIZE(tosa_power_resource),
477};
478
479/*
Dirk Opfera93876c2005-11-08 19:15:30 +0000480 * Tosa Keyboard
481 */
482static struct platform_device tosakbd_device = {
483 .name = "tosa-keyboard",
484 .id = -1,
485};
Dirk Opfer8459c152005-11-06 14:27:52 +0000486
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500487static struct gpio_keys_button tosa_gpio_keys[] = {
Dmitry Baryshkov0aa97562008-04-12 20:02:50 +0100488 /*
489 * Two following keys are directly tied to "ON" button of tosa. Why?
490 * The first one can be used as a wakeup source, the second can't;
491 * also the first one is OR of ac_powered and on_button.
492 */
493 {
494 .type = EV_PWR,
495 .code = KEY_RESERVED,
496 .gpio = TOSA_GPIO_POWERON,
497 .desc = "Poweron",
498 .wakeup = 1,
499 .active_low = 1,
500 },
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500501 {
502 .type = EV_PWR,
503 .code = KEY_SUSPEND,
504 .gpio = TOSA_GPIO_ON_KEY,
505 .desc = "On key",
Dmitry Baryshkov0aa97562008-04-12 20:02:50 +0100506 /*
507 * can't be used as wakeup
508 * .wakeup = 1,
509 */
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500510 .active_low = 1,
511 },
512 {
513 .type = EV_KEY,
514 .code = TOSA_KEY_RECORD,
515 .gpio = TOSA_GPIO_RECORD_BTN,
516 .desc = "Record Button",
517 .wakeup = 1,
518 .active_low = 1,
519 },
520 {
521 .type = EV_KEY,
522 .code = TOSA_KEY_SYNC,
523 .gpio = TOSA_GPIO_SYNC,
524 .desc = "Sync Button",
525 .wakeup = 1,
526 .active_low = 1,
527 },
Dmitry Baryshkovc33de472008-09-11 01:28:51 +0100528 {
529 .type = EV_SW,
530 .code = SW_HEADPHONE_INSERT,
531 .gpio = TOSA_GPIO_EAR_IN,
532 .desc = "HeadPhone insert",
533 .active_low = 1,
534 .debounce_interval = 300,
535 },
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500536};
537
538static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
539 .buttons = tosa_gpio_keys,
540 .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
541};
542
543static struct platform_device tosa_gpio_keys_device = {
544 .name = "gpio-keys",
545 .id = -1,
546 .dev = {
547 .platform_data = &tosa_gpio_keys_platform_data,
548 },
549};
550
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800551/*
552 * Tosa LEDs
553 */
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100554static struct gpio_led tosa_gpio_leds[] = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100555 {
556 .name = "tosa:amber:charge",
557 .default_trigger = "main-battery-charging",
558 .gpio = TOSA_GPIO_CHRG_ERR_LED,
559 },
560 {
561 .name = "tosa:green:mail",
562 .default_trigger = "nand-disk",
563 .gpio = TOSA_GPIO_NOTE_LED,
564 },
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100565 {
566 .name = "tosa:dual:wlan",
567 .default_trigger = "none",
568 .gpio = TOSA_GPIO_WLAN_LED,
569 },
570 {
571 .name = "tosa:blue:bluetooth",
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100572 .default_trigger = "tosa-bt",
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100573 .gpio = TOSA_GPIO_BT_LED,
574 },
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100575};
576
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100577static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100578 .leds = tosa_gpio_leds,
579 .num_leds = ARRAY_SIZE(tosa_gpio_leds),
580};
581
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800582static struct platform_device tosaled_device = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100583 .name = "leds-gpio",
584 .id = -1,
585 .dev = {
586 .platform_data = &tosa_gpio_leds_platform_data,
587 },
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800588};
589
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100590/*
591 * Toshiba Mobile IO Controller
592 */
593static struct resource tc6393xb_resources[] = {
594 [0] = {
595 .start = TOSA_LCDC_PHYS,
596 .end = TOSA_LCDC_PHYS + 0x3ffffff,
597 .flags = IORESOURCE_MEM,
598 },
599
600 [1] = {
601 .start = TOSA_IRQ_GPIO_TC6393XB_INT,
602 .end = TOSA_IRQ_GPIO_TC6393XB_INT,
603 .flags = IORESOURCE_IRQ,
604 },
605};
606
607
608static int tosa_tc6393xb_enable(struct platform_device *dev)
609{
610 int rc;
611
612 rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
613 if (rc)
614 goto err_req_pclr;
615 rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
616 if (rc)
617 goto err_req_suspend;
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +0400618 rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "tc6393xb l3v");
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100619 if (rc)
620 goto err_req_l3v;
621 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
622 if (rc)
623 goto err_dir_l3v;
624 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
625 if (rc)
626 goto err_dir_suspend;
627 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
628 if (rc)
629 goto err_dir_pclr;
630
631 mdelay(1);
632
633 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
634
635 mdelay(10);
636
637 gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
638 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
639
640 return 0;
641err_dir_pclr:
642err_dir_suspend:
643err_dir_l3v:
644 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
645err_req_l3v:
646 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
647err_req_suspend:
648 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
649err_req_pclr:
650 return rc;
651}
652
653static int tosa_tc6393xb_disable(struct platform_device *dev)
654{
655 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
656 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
657 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
658
659 return 0;
660}
661
662static int tosa_tc6393xb_resume(struct platform_device *dev)
663{
664 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
665 mdelay(10);
666 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
667 mdelay(10);
668
669 return 0;
670}
671
672static int tosa_tc6393xb_suspend(struct platform_device *dev)
673{
674 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
675 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
676 return 0;
677}
678
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100679static struct mtd_partition tosa_nand_partition[] = {
680 {
681 .name = "smf",
682 .offset = 0,
683 .size = 7 * 1024 * 1024,
684 },
685 {
686 .name = "root",
687 .offset = MTDPART_OFS_APPEND,
688 .size = 28 * 1024 * 1024,
689 },
690 {
691 .name = "home",
692 .offset = MTDPART_OFS_APPEND,
693 .size = MTDPART_SIZ_FULL,
694 },
695};
696
697static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
698
699static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = {
700 .options = 0,
701 .offs = 4,
702 .len = 2,
703 .pattern = scan_ff_pattern
704};
705
706static struct tmio_nand_data tosa_tc6393xb_nand_config = {
707 .num_partitions = ARRAY_SIZE(tosa_nand_partition),
708 .partition = tosa_nand_partition,
709 .badblock_pattern = &tosa_tc6393xb_nand_bbt,
710};
711
Dmitry Baryshkov1c1b6ff2008-09-24 23:36:23 +0200712static int tosa_tc6393xb_setup(struct platform_device *dev)
713{
714 int rc;
715
716 rc = gpio_request(TOSA_GPIO_CARD_VCC_ON, "CARD_VCC_ON");
717 if (rc)
718 goto err_req;
719
720 rc = gpio_direction_output(TOSA_GPIO_CARD_VCC_ON, 1);
721 if (rc)
722 goto err_dir;
723
724 return rc;
725
726err_dir:
727 gpio_free(TOSA_GPIO_CARD_VCC_ON);
728err_req:
729 return rc;
730}
731
732static void tosa_tc6393xb_teardown(struct platform_device *dev)
733{
734 gpio_free(TOSA_GPIO_CARD_VCC_ON);
735}
736
Dmitry Baryshkovddfb33c2008-11-27 01:25:09 +0300737#ifdef CONFIG_MFD_TC6393XB
Dmitry Baryshkov31c9b282008-10-28 18:40:37 +0300738static struct fb_videomode tosa_tc6393xb_lcd_mode[] = {
739 {
740 .xres = 480,
741 .yres = 640,
742 .pixclock = 0x002cdf00,/* PLL divisor */
743 .left_margin = 0x004c,
744 .right_margin = 0x005b,
745 .upper_margin = 0x0001,
746 .lower_margin = 0x000d,
747 .hsync_len = 0x0002,
748 .vsync_len = 0x0001,
749 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
750 .vmode = FB_VMODE_NONINTERLACED,
751 },{
752 .xres = 240,
753 .yres = 320,
754 .pixclock = 0x00e7f203,/* PLL divisor */
755 .left_margin = 0x0024,
756 .right_margin = 0x002f,
757 .upper_margin = 0x0001,
758 .lower_margin = 0x000d,
759 .hsync_len = 0x0002,
760 .vsync_len = 0x0001,
761 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
762 .vmode = FB_VMODE_NONINTERLACED,
763 }
764};
765
766static struct tmio_fb_data tosa_tc6393xb_fb_config = {
767 .lcd_set_power = tc6393xb_lcd_set_power,
768 .lcd_mode = tc6393xb_lcd_mode,
769 .num_modes = ARRAY_SIZE(tosa_tc6393xb_lcd_mode),
770 .modes = &tosa_tc6393xb_lcd_mode[0],
771 .height = 82,
772 .width = 60,
773};
Dmitry Baryshkovddfb33c2008-11-27 01:25:09 +0300774#endif
Dmitry Baryshkov31c9b282008-10-28 18:40:37 +0300775
Dmitry Baryshkov1c1b6ff2008-09-24 23:36:23 +0200776static struct tc6393xb_platform_data tosa_tc6393xb_data = {
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100777 .scr_pll2cr = 0x0cc1,
778 .scr_gper = 0x3300,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100779
780 .irq_base = IRQ_BOARD_START,
781 .gpio_base = TOSA_TC6393XB_GPIO_BASE,
Dmitry Baryshkov1c1b6ff2008-09-24 23:36:23 +0200782 .setup = tosa_tc6393xb_setup,
783 .teardown = tosa_tc6393xb_teardown,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100784
785 .enable = tosa_tc6393xb_enable,
786 .disable = tosa_tc6393xb_disable,
787 .suspend = tosa_tc6393xb_suspend,
788 .resume = tosa_tc6393xb_resume,
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100789
790 .nand_data = &tosa_tc6393xb_nand_config,
Dmitry Baryshkovddfb33c2008-11-27 01:25:09 +0300791#ifdef CONFIG_MFD_TC6393XB
Dmitry Baryshkov31c9b282008-10-28 18:40:37 +0300792 .fb_data = &tosa_tc6393xb_fb_config,
Dmitry Baryshkovddfb33c2008-11-27 01:25:09 +0300793#endif
Dmitry Baryshkovf98a0bd2008-09-24 23:46:10 +0200794
795 .resume_restore = 1,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100796};
797
798
799static struct platform_device tc6393xb_device = {
800 .name = "tc6393xb",
801 .id = -1,
802 .dev = {
Dmitry Baryshkov1c1b6ff2008-09-24 23:36:23 +0200803 .platform_data = &tosa_tc6393xb_data,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100804 },
805 .num_resources = ARRAY_SIZE(tc6393xb_resources),
806 .resource = tc6393xb_resources,
807};
808
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100809static struct tosa_bt_data tosa_bt_data = {
810 .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
811 .gpio_reset = TOSA_GPIO_BT_RESET,
812};
813
814static struct platform_device tosa_bt_device = {
815 .name = "tosa-bt",
816 .id = -1,
817 .dev.platform_data = &tosa_bt_data,
818};
819
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +0400820static struct pxa2xx_spi_master pxa_ssp_master_info = {
821 .num_chipselect = 1,
822};
823
824static struct spi_board_info spi_board_info[] __initdata = {
825 {
826 .modalias = "tosa-lcd",
827 // .platform_data
828 .max_speed_hz = 28750,
829 .bus_num = 2,
830 .chip_select = 0,
831 .mode = SPI_MODE_0,
832 },
833};
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100834
Dmitry Baryshkovf34ee792008-11-25 00:57:27 +0300835static struct mtd_partition sharpsl_rom_parts[] = {
836 {
837 .name ="Boot PROM Filesystem",
838 .offset = 0x00160000,
839 .size = MTDPART_SIZ_FULL,
840 },
841};
842
843static struct physmap_flash_data sharpsl_rom_data = {
844 .width = 2,
845 .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
846 .parts = sharpsl_rom_parts,
847};
848
849static struct resource sharpsl_rom_resources[] = {
850 {
851 .start = 0x00000000,
852 .end = 0x007fffff,
853 .flags = IORESOURCE_MEM,
854 },
855};
856
857static struct platform_device sharpsl_rom_device = {
858 .name = "physmap-flash",
859 .id = -1,
860 .resource = sharpsl_rom_resources,
861 .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
862 .dev.platform_data = &sharpsl_rom_data,
863};
864
Dirk Opfer8459c152005-11-06 14:27:52 +0000865static struct platform_device *devices[] __initdata = {
866 &tosascoop_device,
867 &tosascoop_jc_device,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100868 &tc6393xb_device,
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100869 &tosa_power_device,
Dirk Opfera93876c2005-11-08 19:15:30 +0000870 &tosakbd_device,
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500871 &tosa_gpio_keys_device,
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800872 &tosaled_device,
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100873 &tosa_bt_device,
Dmitry Baryshkovf34ee792008-11-25 00:57:27 +0300874 &sharpsl_rom_device,
Dirk Opfer8459c152005-11-06 14:27:52 +0000875};
876
Richard Purdie74617fb2006-06-19 19:57:12 +0100877static void tosa_poweroff(void)
878{
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100879 arm_machine_restart('g');
Richard Purdie74617fb2006-06-19 19:57:12 +0100880}
881
882static void tosa_restart(char mode)
883{
884 /* Bootloader magic for a reboot */
885 if((MSC0 & 0xffff0000) == 0x7ff00000)
886 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
887
888 tosa_poweroff();
889}
890
Dirk Opfer8459c152005-11-06 14:27:52 +0000891static void __init tosa_init(void)
892{
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100893 int dummy;
894
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100895 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
896 gpio_set_wake(MFP_PIN_GPIO1, 1);
897 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
898
Dmitry Baryshkov69fc7ee2008-10-09 16:58:13 +0100899 init_gpio_reset(TOSA_GPIO_ON_RESET, 0);
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100900
Richard Purdie74617fb2006-06-19 19:57:12 +0100901 pm_power_off = tosa_poweroff;
902 arm_pm_restart = tosa_restart;
903
Dirk Opfer8459c152005-11-06 14:27:52 +0000904 PCFR |= PCFR_OPDE;
905
Dirk Opfera93876c2005-11-08 19:15:30 +0000906 /* enable batt_fault */
Dirk Opfer8459c152005-11-06 14:27:52 +0000907 PMCR = 0x01;
908
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100909 dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
910 dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
911 dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
912
Dirk Opfera93876c2005-11-08 19:15:30 +0000913 pxa_set_mci_info(&tosa_mci_platform_data);
914 pxa_set_udc_info(&udc_info);
915 pxa_set_ficp_info(&tosa_ficp_platform_data);
Dmitry Baryshkov481ea5a2008-04-10 15:43:18 +0100916 pxa_set_i2c_info(NULL);
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000917 platform_scoop_config = &tosa_pcmcia_config;
Dirk Opfer8459c152005-11-06 14:27:52 +0000918
Dmitry Baryshkov14b7b402008-09-13 21:06:41 +0400919 pxa2xx_set_spi_info(2, &pxa_ssp_master_info);
920 spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info));
921
Dmitry Baryshkov7bdb22c2008-09-10 10:30:37 +0100922 clk_add_alias("CLK_CK3P6MI", &tc6393xb_device.dev, "GPIO11_CLK", NULL);
923
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000924 platform_add_devices(devices, ARRAY_SIZE(devices));
Dirk Opfer8459c152005-11-06 14:27:52 +0000925}
926
927static void __init fixup_tosa(struct machine_desc *desc,
928 struct tag *tags, char **cmdline, struct meminfo *mi)
929{
930 sharpsl_save_param();
931 mi->nr_banks=1;
932 mi->bank[0].start = 0xa0000000;
933 mi->bank[0].node = 0;
934 mi->bank[0].size = (64*1024*1024);
935}
936
937MACHINE_START(TOSA, "SHARP Tosa")
Dirk Opfer8459c152005-11-06 14:27:52 +0000938 .phys_io = 0x40000000,
939 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
940 .fixup = fixup_tosa,
941 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100942 .init_irq = pxa25x_init_irq,
Dirk Opfer8459c152005-11-06 14:27:52 +0000943 .init_machine = tosa_init,
944 .timer = &pxa_timer,
945MACHINE_END