blob: 2d49de572ba1f14cd57fce9f430507569637266f [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 Baryshkov93e9012f2008-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>
Dirk Opfer8459c152005-11-06 14:27:52 +000034
35#include <asm/setup.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000036#include <asm/mach-types.h>
eric miaobb548dd2008-01-30 09:39:48 +010037#include <asm/arch/pxa2xx-regs.h>
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010038#include <asm/arch/mfp-pxa25x.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000039#include <asm/arch/irda.h>
Dmitry Baryshkov481ea5a2008-04-10 15:43:18 +010040#include <asm/arch/i2c.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000041#include <asm/arch/mmc.h>
42#include <asm/arch/udc.h>
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +010043#include <asm/arch/tosa_bt.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000044
45#include <asm/mach/arch.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000046#include <asm/arch/tosa.h>
47
48#include <asm/hardware/scoop.h>
49#include <asm/mach/sharpsl_param.h>
50
51#include "generic.h"
Russell King46c41e62007-05-15 15:39:36 +010052#include "devices.h"
Dirk Opfer8459c152005-11-06 14:27:52 +000053
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010054static unsigned long tosa_pin_config[] = {
55 GPIO78_nCS_2, /* Scoop */
56 GPIO80_nCS_4, /* tg6393xb */
57 GPIO33_nCS_5, /* Scoop */
58
59 // GPIO76 CARD_VCC_ON1
60
61 GPIO19_GPIO, /* Reset out */
62 GPIO1_RST | WAKEUP_ON_EDGE_FALL,
63
64 GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */
65 GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */
66 GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */
67 GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */
68 GPIO20_GPIO, /* EAR_IN */
69 GPIO22_GPIO, /* On */
70
71 GPIO5_GPIO, /* USB_IN */
72 GPIO32_GPIO, /* Pen IRQ */
73
74 GPIO7_GPIO, /* Jacket Detect */
75 GPIO14_GPIO, /* BAT0_CRG */
76 GPIO12_GPIO, /* BAT1_CRG */
77 GPIO17_GPIO, /* BAT0_LOW */
78 GPIO84_GPIO, /* BAT1_LOW */
79 GPIO38_GPIO, /* BAT_LOCK */
80
81 GPIO11_3_6MHz,
82 GPIO15_GPIO, /* TC6393XB IRQ */
83 GPIO18_RDY,
84 GPIO27_GPIO, /* LCD Sync */
85
86 /* MMC */
87 GPIO6_MMC_CLK,
88 GPIO8_MMC_CS0,
89 GPIO9_GPIO, /* Detect */
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +010090 GPIO10_GPIO, /* nSD_INT */
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010091
92 /* CF */
93 GPIO13_GPIO, /* CD_IRQ */
94 GPIO21_GPIO, /* Main Slot IRQ */
95 GPIO36_GPIO, /* Jacket Slot IRQ */
96 GPIO48_nPOE,
97 GPIO49_nPWE,
98 GPIO50_nPIOR,
99 GPIO51_nPIOW,
100 GPIO52_nPCE_1,
101 GPIO53_nPCE_2,
102 GPIO54_nPSKTSEL,
103 GPIO55_nPREG,
104 GPIO56_nPWAIT,
105 GPIO57_nIOIS16,
106
107 /* AC97 */
108 GPIO31_AC97_SYNC,
109 GPIO30_AC97_SDATA_OUT,
110 GPIO28_AC97_BITCLK,
111 GPIO29_AC97_SDATA_IN_0,
112 // GPIO79 nAUD_IRQ
113
114 /* FFUART */
115 GPIO34_FFUART_RXD,
116 GPIO35_FFUART_CTS,
117 GPIO37_FFUART_DSR,
118 GPIO39_FFUART_TXD,
119 GPIO40_FFUART_DTR,
120 GPIO41_FFUART_RTS,
121
122 /* BTUART */
123 GPIO42_BTUART_RXD,
124 GPIO43_BTUART_TXD,
125 GPIO44_BTUART_CTS,
126 GPIO45_BTUART_RTS,
127
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100128 /* Keybd */
eric miaoc8671552008-05-26 03:28:50 +0100129 GPIO58_GPIO | MFP_LPM_DRIVE_LOW,
130 GPIO59_GPIO | MFP_LPM_DRIVE_LOW,
131 GPIO60_GPIO | MFP_LPM_DRIVE_LOW,
132 GPIO61_GPIO | MFP_LPM_DRIVE_LOW,
133 GPIO62_GPIO | MFP_LPM_DRIVE_LOW,
134 GPIO63_GPIO | MFP_LPM_DRIVE_LOW,
135 GPIO64_GPIO | MFP_LPM_DRIVE_LOW,
136 GPIO65_GPIO | MFP_LPM_DRIVE_LOW,
137 GPIO66_GPIO | MFP_LPM_DRIVE_LOW,
138 GPIO67_GPIO | MFP_LPM_DRIVE_LOW,
139 GPIO68_GPIO | MFP_LPM_DRIVE_LOW,
140 GPIO69_GPIO | MFP_LPM_DRIVE_LOW,
141 GPIO70_GPIO | MFP_LPM_DRIVE_LOW,
142 GPIO71_GPIO | MFP_LPM_DRIVE_LOW,
143 GPIO72_GPIO | MFP_LPM_DRIVE_LOW,
144 GPIO73_GPIO | MFP_LPM_DRIVE_LOW,
145 GPIO74_GPIO | MFP_LPM_DRIVE_LOW,
146 GPIO75_GPIO | MFP_LPM_DRIVE_LOW,
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100147
148 /* SPI */
149 GPIO81_SSP2_CLK_OUT,
150 GPIO82_SSP2_FRM_OUT,
151 GPIO83_SSP2_TXD,
152};
153
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100154static unsigned long tosa_pin_irda_off[] = {
155 GPIO46_STUART_RXD,
156 GPIO47_GPIO | MFP_LPM_DRIVE_LOW,
157};
158
159static unsigned long tosa_pin_irda_on[] = {
160 GPIO46_STUART_RXD,
161 GPIO47_STUART_TXD,
162};
163
164
Dirk Opfer8459c152005-11-06 14:27:52 +0000165/*
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,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100178 .gpio_base = TOSA_SCOOP_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000179};
180
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100181static struct platform_device tosascoop_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000182 .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,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100205 .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000206};
207
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100208static struct platform_device tosascoop_jc_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000209 .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
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000219/*
220 * PCMCIA
221 */
Dirk Opfer8459c152005-11-06 14:27:52 +0000222static 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
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000235static struct scoop_pcmcia_config tosa_pcmcia_config = {
236 .devs = &tosa_pcmcia_scoop[0],
237 .num_devs = 2,
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000238};
239
Dirk Opfera93876c2005-11-08 19:15:30 +0000240/*
241 * USB Device Controller
242 */
Dirk Opfera93876c2005-11-08 19:15:30 +0000243static struct pxa2xx_udc_mach_info udc_info __initdata = {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100244 .gpio_pullup = TOSA_GPIO_USB_PULLUP,
Dmitry Baryshkov487dc922007-12-21 12:18:01 +0300245 .gpio_vbus = TOSA_GPIO_USB_IN,
246 .gpio_vbus_inverted = 1,
Dirk Opfera93876c2005-11-08 19:15:30 +0000247};
248
249/*
250 * MMC/SD Device
251 */
252static struct pxamci_platform_data tosa_mci_platform_data;
253
David Howells40220c12006-10-09 12:19:47 +0100254static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
Dirk Opfera93876c2005-11-08 19:15:30 +0000255{
256 int err;
257
Dirk Opfera93876c2005-11-08 19:15:30 +0000258 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
259
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100260 err = gpio_request(TOSA_GPIO_nSD_DETECT, "MMC/SD card detect");
261 if (err) {
262 printk(KERN_ERR "tosa_mci_init: can't request nSD_DETECT gpio\n");
263 goto err_gpio_detect;
264 }
265 err = gpio_direction_input(TOSA_GPIO_nSD_DETECT);
266 if (err)
267 goto err_gpio_detect_dir;
268
Russell King2687bd32008-01-23 14:05:58 +0000269 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
270 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Dirk Opfera93876c2005-11-08 19:15:30 +0000271 "MMC/SD card detect", data);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100272 if (err) {
Dirk Opfera93876c2005-11-08 19:15:30 +0000273 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100274 goto err_irq;
275 }
Dirk Opfera93876c2005-11-08 19:15:30 +0000276
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100277 err = gpio_request(TOSA_GPIO_SD_WP, "SD Write Protect");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100278 if (err) {
279 printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n");
280 goto err_gpio_wp;
281 }
282 err = gpio_direction_input(TOSA_GPIO_SD_WP);
283 if (err)
284 goto err_gpio_wp_dir;
285
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100286 err = gpio_request(TOSA_GPIO_PWR_ON, "SD Power");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100287 if (err) {
288 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
289 goto err_gpio_pwr;
290 }
291 err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0);
292 if (err)
293 goto err_gpio_pwr_dir;
294
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100295 err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
296 if (err) {
297 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
298 goto err_gpio_int;
299 }
300 err = gpio_direction_input(TOSA_GPIO_nSD_INT);
301 if (err)
302 goto err_gpio_int_dir;
303
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100304 return 0;
305
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100306err_gpio_int_dir:
307 gpio_free(TOSA_GPIO_nSD_INT);
308err_gpio_int:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100309err_gpio_pwr_dir:
310 gpio_free(TOSA_GPIO_PWR_ON);
311err_gpio_pwr:
312err_gpio_wp_dir:
313 gpio_free(TOSA_GPIO_SD_WP);
314err_gpio_wp:
315 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
316err_irq:
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100317err_gpio_detect_dir:
318 gpio_free(TOSA_GPIO_nSD_DETECT);
319err_gpio_detect:
Russell King2687bd32008-01-23 14:05:58 +0000320 return err;
Dirk Opfera93876c2005-11-08 19:15:30 +0000321}
322
323static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
324{
325 struct pxamci_platform_data* p_d = dev->platform_data;
326
327 if (( 1 << vdd) & p_d->ocr_mask) {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100328 gpio_set_value(TOSA_GPIO_PWR_ON, 1);
Dirk Opfera93876c2005-11-08 19:15:30 +0000329 } else {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100330 gpio_set_value(TOSA_GPIO_PWR_ON, 0);
Dirk Opfera93876c2005-11-08 19:15:30 +0000331 }
332}
333
334static int tosa_mci_get_ro(struct device *dev)
335{
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100336 return gpio_get_value(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000337}
338
339static void tosa_mci_exit(struct device *dev, void *data)
340{
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100341 gpio_free(TOSA_GPIO_nSD_INT);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100342 gpio_free(TOSA_GPIO_PWR_ON);
343 gpio_free(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000344 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100345 gpio_free(TOSA_GPIO_nSD_DETECT);
Dirk Opfera93876c2005-11-08 19:15:30 +0000346}
347
348static struct pxamci_platform_data tosa_mci_platform_data = {
349 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
350 .init = tosa_mci_init,
351 .get_ro = tosa_mci_get_ro,
352 .setpower = tosa_mci_setpower,
353 .exit = tosa_mci_exit,
354};
355
356/*
357 * Irda
358 */
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100359static void tosa_irda_transceiver_mode(struct device *dev, int mode)
360{
361 if (mode & IR_OFF) {
362 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
363 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_off));
364 gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
365 } else {
366 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_on));
367 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
368 }
369}
370
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100371static int tosa_irda_startup(struct device *dev)
372{
373 int ret;
374
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100375 ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
376 if (ret)
377 goto err_tx;
378 ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
379 if (ret)
380 goto err_tx_dir;
381
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100382 ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
383 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100384 goto err_pwr;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100385
386 ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
387 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100388 goto err_pwr_dir;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100389
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100390 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
391
392 return 0;
393
394err_pwr_dir:
395 gpio_free(TOSA_GPIO_IR_POWERDWN);
396err_pwr:
397err_tx_dir:
398 gpio_free(TOSA_GPIO_IRDA_TX);
399err_tx:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100400 return ret;
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100401}
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100402
403static void tosa_irda_shutdown(struct device *dev)
404{
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100405 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100406 gpio_free(TOSA_GPIO_IR_POWERDWN);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100407 gpio_free(TOSA_GPIO_IRDA_TX);
Dirk Opfera93876c2005-11-08 19:15:30 +0000408}
409
410static struct pxaficp_platform_data tosa_ficp_platform_data = {
411 .transceiver_cap = IR_SIRMODE | IR_OFF,
412 .transceiver_mode = tosa_irda_transceiver_mode,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100413 .startup = tosa_irda_startup,
414 .shutdown = tosa_irda_shutdown,
Dirk Opfera93876c2005-11-08 19:15:30 +0000415};
416
417/*
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100418 * Tosa AC IN
419 */
420static int tosa_power_init(struct device *dev)
421{
422 int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
423 if (ret)
424 goto err_gpio_req;
425
426 ret = gpio_direction_input(TOSA_GPIO_AC_IN);
427 if (ret)
428 goto err_gpio_in;
429
430 return 0;
431
432err_gpio_in:
433 gpio_free(TOSA_GPIO_AC_IN);
434err_gpio_req:
435 return ret;
436}
437
438static void tosa_power_exit(struct device *dev)
439{
440 gpio_free(TOSA_GPIO_AC_IN);
441}
442
443static int tosa_power_ac_online(void)
444{
445 return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
446}
447
448static char *tosa_ac_supplied_to[] = {
449 "main-battery",
450 "backup-battery",
451 "jacket-battery",
452};
453
454static struct pda_power_pdata tosa_power_data = {
455 .init = tosa_power_init,
456 .is_ac_online = tosa_power_ac_online,
457 .exit = tosa_power_exit,
458 .supplied_to = tosa_ac_supplied_to,
459 .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
460};
461
462static struct resource tosa_power_resource[] = {
463 {
464 .name = "ac",
465 .start = gpio_to_irq(TOSA_GPIO_AC_IN),
466 .end = gpio_to_irq(TOSA_GPIO_AC_IN),
467 .flags = IORESOURCE_IRQ |
468 IORESOURCE_IRQ_HIGHEDGE |
469 IORESOURCE_IRQ_LOWEDGE,
470 },
471};
472
473static struct platform_device tosa_power_device = {
474 .name = "pda-power",
475 .id = -1,
476 .dev.platform_data = &tosa_power_data,
477 .resource = tosa_power_resource,
478 .num_resources = ARRAY_SIZE(tosa_power_resource),
479};
480
481/*
Dirk Opfera93876c2005-11-08 19:15:30 +0000482 * Tosa Keyboard
483 */
484static struct platform_device tosakbd_device = {
485 .name = "tosa-keyboard",
486 .id = -1,
487};
Dirk Opfer8459c152005-11-06 14:27:52 +0000488
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500489static struct gpio_keys_button tosa_gpio_keys[] = {
Dmitry Baryshkov0aa975612008-04-12 20:02:50 +0100490 /*
491 * Two following keys are directly tied to "ON" button of tosa. Why?
492 * The first one can be used as a wakeup source, the second can't;
493 * also the first one is OR of ac_powered and on_button.
494 */
495 {
496 .type = EV_PWR,
497 .code = KEY_RESERVED,
498 .gpio = TOSA_GPIO_POWERON,
499 .desc = "Poweron",
500 .wakeup = 1,
501 .active_low = 1,
502 },
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500503 {
504 .type = EV_PWR,
505 .code = KEY_SUSPEND,
506 .gpio = TOSA_GPIO_ON_KEY,
507 .desc = "On key",
Dmitry Baryshkov0aa975612008-04-12 20:02:50 +0100508 /*
509 * can't be used as wakeup
510 * .wakeup = 1,
511 */
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500512 .active_low = 1,
513 },
514 {
515 .type = EV_KEY,
516 .code = TOSA_KEY_RECORD,
517 .gpio = TOSA_GPIO_RECORD_BTN,
518 .desc = "Record Button",
519 .wakeup = 1,
520 .active_low = 1,
521 },
522 {
523 .type = EV_KEY,
524 .code = TOSA_KEY_SYNC,
525 .gpio = TOSA_GPIO_SYNC,
526 .desc = "Sync Button",
527 .wakeup = 1,
528 .active_low = 1,
529 },
530};
531
532static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
533 .buttons = tosa_gpio_keys,
534 .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
535};
536
537static struct platform_device tosa_gpio_keys_device = {
538 .name = "gpio-keys",
539 .id = -1,
540 .dev = {
541 .platform_data = &tosa_gpio_keys_platform_data,
542 },
543};
544
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800545/*
546 * Tosa LEDs
547 */
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100548static struct gpio_led tosa_gpio_leds[] = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100549 {
550 .name = "tosa:amber:charge",
551 .default_trigger = "main-battery-charging",
552 .gpio = TOSA_GPIO_CHRG_ERR_LED,
553 },
554 {
555 .name = "tosa:green:mail",
556 .default_trigger = "nand-disk",
557 .gpio = TOSA_GPIO_NOTE_LED,
558 },
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100559 {
560 .name = "tosa:dual:wlan",
561 .default_trigger = "none",
562 .gpio = TOSA_GPIO_WLAN_LED,
563 },
564 {
565 .name = "tosa:blue:bluetooth",
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100566 .default_trigger = "tosa-bt",
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100567 .gpio = TOSA_GPIO_BT_LED,
568 },
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100569};
570
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100571static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100572 .leds = tosa_gpio_leds,
573 .num_leds = ARRAY_SIZE(tosa_gpio_leds),
574};
575
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800576static struct platform_device tosaled_device = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100577 .name = "leds-gpio",
578 .id = -1,
579 .dev = {
580 .platform_data = &tosa_gpio_leds_platform_data,
581 },
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800582};
583
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100584/*
585 * Toshiba Mobile IO Controller
586 */
587static struct resource tc6393xb_resources[] = {
588 [0] = {
589 .start = TOSA_LCDC_PHYS,
590 .end = TOSA_LCDC_PHYS + 0x3ffffff,
591 .flags = IORESOURCE_MEM,
592 },
593
594 [1] = {
595 .start = TOSA_IRQ_GPIO_TC6393XB_INT,
596 .end = TOSA_IRQ_GPIO_TC6393XB_INT,
597 .flags = IORESOURCE_IRQ,
598 },
599};
600
601
602static int tosa_tc6393xb_enable(struct platform_device *dev)
603{
604 int rc;
605
606 rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
607 if (rc)
608 goto err_req_pclr;
609 rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
610 if (rc)
611 goto err_req_suspend;
612 rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "l3v");
613 if (rc)
614 goto err_req_l3v;
615 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
616 if (rc)
617 goto err_dir_l3v;
618 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
619 if (rc)
620 goto err_dir_suspend;
621 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
622 if (rc)
623 goto err_dir_pclr;
624
625 mdelay(1);
626
627 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
628
629 mdelay(10);
630
631 gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
632 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
633
634 return 0;
635err_dir_pclr:
636err_dir_suspend:
637err_dir_l3v:
638 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
639err_req_l3v:
640 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
641err_req_suspend:
642 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
643err_req_pclr:
644 return rc;
645}
646
647static int tosa_tc6393xb_disable(struct platform_device *dev)
648{
649 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
650 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
651 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
652
653 return 0;
654}
655
656static int tosa_tc6393xb_resume(struct platform_device *dev)
657{
658 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
659 mdelay(10);
660 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
661 mdelay(10);
662
663 return 0;
664}
665
666static int tosa_tc6393xb_suspend(struct platform_device *dev)
667{
668 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
669 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
670 return 0;
671}
672
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100673static struct mtd_partition tosa_nand_partition[] = {
674 {
675 .name = "smf",
676 .offset = 0,
677 .size = 7 * 1024 * 1024,
678 },
679 {
680 .name = "root",
681 .offset = MTDPART_OFS_APPEND,
682 .size = 28 * 1024 * 1024,
683 },
684 {
685 .name = "home",
686 .offset = MTDPART_OFS_APPEND,
687 .size = MTDPART_SIZ_FULL,
688 },
689};
690
691static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
692
693static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = {
694 .options = 0,
695 .offs = 4,
696 .len = 2,
697 .pattern = scan_ff_pattern
698};
699
700static struct tmio_nand_data tosa_tc6393xb_nand_config = {
701 .num_partitions = ARRAY_SIZE(tosa_nand_partition),
702 .partition = tosa_nand_partition,
703 .badblock_pattern = &tosa_tc6393xb_nand_bbt,
704};
705
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100706static struct tc6393xb_platform_data tosa_tc6393xb_setup = {
707 .scr_pll2cr = 0x0cc1,
708 .scr_gper = 0x3300,
709 .scr_gpo_dsr =
710 TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
711 .scr_gpo_doecr =
712 TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
713
714 .irq_base = IRQ_BOARD_START,
715 .gpio_base = TOSA_TC6393XB_GPIO_BASE,
716
717 .enable = tosa_tc6393xb_enable,
718 .disable = tosa_tc6393xb_disable,
719 .suspend = tosa_tc6393xb_suspend,
720 .resume = tosa_tc6393xb_resume,
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100721
722 .nand_data = &tosa_tc6393xb_nand_config,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100723};
724
725
726static struct platform_device tc6393xb_device = {
727 .name = "tc6393xb",
728 .id = -1,
729 .dev = {
730 .platform_data = &tosa_tc6393xb_setup,
731 },
732 .num_resources = ARRAY_SIZE(tc6393xb_resources),
733 .resource = tc6393xb_resources,
734};
735
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100736static struct tosa_bt_data tosa_bt_data = {
737 .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
738 .gpio_reset = TOSA_GPIO_BT_RESET,
739};
740
741static struct platform_device tosa_bt_device = {
742 .name = "tosa-bt",
743 .id = -1,
744 .dev.platform_data = &tosa_bt_data,
745};
746
747
Dirk Opfer8459c152005-11-06 14:27:52 +0000748static struct platform_device *devices[] __initdata = {
749 &tosascoop_device,
750 &tosascoop_jc_device,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100751 &tc6393xb_device,
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100752 &tosa_power_device,
Dirk Opfera93876c2005-11-08 19:15:30 +0000753 &tosakbd_device,
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500754 &tosa_gpio_keys_device,
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800755 &tosaled_device,
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100756 &tosa_bt_device,
Dirk Opfer8459c152005-11-06 14:27:52 +0000757};
758
Richard Purdie74617fb2006-06-19 19:57:12 +0100759static void tosa_poweroff(void)
760{
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100761 arm_machine_restart('g');
Richard Purdie74617fb2006-06-19 19:57:12 +0100762}
763
764static void tosa_restart(char mode)
765{
766 /* Bootloader magic for a reboot */
767 if((MSC0 & 0xffff0000) == 0x7ff00000)
768 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
769
770 tosa_poweroff();
771}
772
Dirk Opfer8459c152005-11-06 14:27:52 +0000773static void __init tosa_init(void)
774{
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100775 int dummy;
776
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100777 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100778 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_off));
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100779 gpio_set_wake(MFP_PIN_GPIO1, 1);
780 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
781
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100782 init_gpio_reset(TOSA_GPIO_ON_RESET);
783
Richard Purdie74617fb2006-06-19 19:57:12 +0100784 pm_power_off = tosa_poweroff;
785 arm_pm_restart = tosa_restart;
786
Dirk Opfer8459c152005-11-06 14:27:52 +0000787 PCFR |= PCFR_OPDE;
788
Dirk Opfera93876c2005-11-08 19:15:30 +0000789 /* enable batt_fault */
Dirk Opfer8459c152005-11-06 14:27:52 +0000790 PMCR = 0x01;
791
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100792 dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
793 dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
794 dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
795
Dirk Opfera93876c2005-11-08 19:15:30 +0000796 pxa_set_mci_info(&tosa_mci_platform_data);
797 pxa_set_udc_info(&udc_info);
798 pxa_set_ficp_info(&tosa_ficp_platform_data);
Dmitry Baryshkov481ea5a2008-04-10 15:43:18 +0100799 pxa_set_i2c_info(NULL);
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000800 platform_scoop_config = &tosa_pcmcia_config;
Dirk Opfer8459c152005-11-06 14:27:52 +0000801
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000802 platform_add_devices(devices, ARRAY_SIZE(devices));
Dirk Opfer8459c152005-11-06 14:27:52 +0000803}
804
805static void __init fixup_tosa(struct machine_desc *desc,
806 struct tag *tags, char **cmdline, struct meminfo *mi)
807{
808 sharpsl_save_param();
809 mi->nr_banks=1;
810 mi->bank[0].start = 0xa0000000;
811 mi->bank[0].node = 0;
812 mi->bank[0].size = (64*1024*1024);
813}
814
815MACHINE_START(TOSA, "SHARP Tosa")
Dirk Opfer8459c152005-11-06 14:27:52 +0000816 .phys_io = 0x40000000,
817 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
818 .fixup = fixup_tosa,
819 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100820 .init_irq = pxa25x_init_irq,
Dirk Opfer8459c152005-11-06 14:27:52 +0000821 .init_machine = tosa_init,
822 .timer = &pxa_timer,
823MACHINE_END