blob: fa903e7ae62492012063512c8210ccbfb863c68f [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>
Russell King905f1462006-06-20 23:27:37 +010029#include <linux/delay.h>
Dmitry Baryshkov93e9012f2008-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>
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>
43
44#include <asm/mach/arch.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000045#include <asm/arch/tosa.h>
46
47#include <asm/hardware/scoop.h>
48#include <asm/mach/sharpsl_param.h>
49
50#include "generic.h"
Russell King46c41e62007-05-15 15:39:36 +010051#include "devices.h"
Dirk Opfer8459c152005-11-06 14:27:52 +000052
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010053static unsigned long tosa_pin_config[] = {
54 GPIO78_nCS_2, /* Scoop */
55 GPIO80_nCS_4, /* tg6393xb */
56 GPIO33_nCS_5, /* Scoop */
57
58 // GPIO76 CARD_VCC_ON1
59
60 GPIO19_GPIO, /* Reset out */
61 GPIO1_RST | WAKEUP_ON_EDGE_FALL,
62
63 GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */
64 GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */
65 GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */
66 GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */
67 GPIO20_GPIO, /* EAR_IN */
68 GPIO22_GPIO, /* On */
69
70 GPIO5_GPIO, /* USB_IN */
71 GPIO32_GPIO, /* Pen IRQ */
72
73 GPIO7_GPIO, /* Jacket Detect */
74 GPIO14_GPIO, /* BAT0_CRG */
75 GPIO12_GPIO, /* BAT1_CRG */
76 GPIO17_GPIO, /* BAT0_LOW */
77 GPIO84_GPIO, /* BAT1_LOW */
78 GPIO38_GPIO, /* BAT_LOCK */
79
80 GPIO11_3_6MHz,
81 GPIO15_GPIO, /* TC6393XB IRQ */
82 GPIO18_RDY,
83 GPIO27_GPIO, /* LCD Sync */
84
85 /* MMC */
86 GPIO6_MMC_CLK,
87 GPIO8_MMC_CS0,
88 GPIO9_GPIO, /* Detect */
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +010089 GPIO10_GPIO, /* nSD_INT */
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010090
91 /* CF */
92 GPIO13_GPIO, /* CD_IRQ */
93 GPIO21_GPIO, /* Main Slot IRQ */
94 GPIO36_GPIO, /* Jacket Slot IRQ */
95 GPIO48_nPOE,
96 GPIO49_nPWE,
97 GPIO50_nPIOR,
98 GPIO51_nPIOW,
99 GPIO52_nPCE_1,
100 GPIO53_nPCE_2,
101 GPIO54_nPSKTSEL,
102 GPIO55_nPREG,
103 GPIO56_nPWAIT,
104 GPIO57_nIOIS16,
105
106 /* AC97 */
107 GPIO31_AC97_SYNC,
108 GPIO30_AC97_SDATA_OUT,
109 GPIO28_AC97_BITCLK,
110 GPIO29_AC97_SDATA_IN_0,
111 // GPIO79 nAUD_IRQ
112
113 /* FFUART */
114 GPIO34_FFUART_RXD,
115 GPIO35_FFUART_CTS,
116 GPIO37_FFUART_DSR,
117 GPIO39_FFUART_TXD,
118 GPIO40_FFUART_DTR,
119 GPIO41_FFUART_RTS,
120
121 /* BTUART */
122 GPIO42_BTUART_RXD,
123 GPIO43_BTUART_TXD,
124 GPIO44_BTUART_CTS,
125 GPIO45_BTUART_RTS,
126
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100127 /* Keybd */
eric miaoc8671552008-05-26 03:28:50 +0100128 GPIO58_GPIO | MFP_LPM_DRIVE_LOW,
129 GPIO59_GPIO | MFP_LPM_DRIVE_LOW,
130 GPIO60_GPIO | MFP_LPM_DRIVE_LOW,
131 GPIO61_GPIO | MFP_LPM_DRIVE_LOW,
132 GPIO62_GPIO | MFP_LPM_DRIVE_LOW,
133 GPIO63_GPIO | MFP_LPM_DRIVE_LOW,
134 GPIO64_GPIO | MFP_LPM_DRIVE_LOW,
135 GPIO65_GPIO | MFP_LPM_DRIVE_LOW,
136 GPIO66_GPIO | MFP_LPM_DRIVE_LOW,
137 GPIO67_GPIO | MFP_LPM_DRIVE_LOW,
138 GPIO68_GPIO | MFP_LPM_DRIVE_LOW,
139 GPIO69_GPIO | MFP_LPM_DRIVE_LOW,
140 GPIO70_GPIO | MFP_LPM_DRIVE_LOW,
141 GPIO71_GPIO | MFP_LPM_DRIVE_LOW,
142 GPIO72_GPIO | MFP_LPM_DRIVE_LOW,
143 GPIO73_GPIO | MFP_LPM_DRIVE_LOW,
144 GPIO74_GPIO | MFP_LPM_DRIVE_LOW,
145 GPIO75_GPIO | MFP_LPM_DRIVE_LOW,
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100146
147 /* SPI */
148 GPIO81_SSP2_CLK_OUT,
149 GPIO82_SSP2_FRM_OUT,
150 GPIO83_SSP2_TXD,
151};
152
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100153static unsigned long tosa_pin_irda_off[] = {
154 GPIO46_STUART_RXD,
155 GPIO47_GPIO | MFP_LPM_DRIVE_LOW,
156};
157
158static unsigned long tosa_pin_irda_on[] = {
159 GPIO46_STUART_RXD,
160 GPIO47_STUART_TXD,
161};
162
163
Dirk Opfer8459c152005-11-06 14:27:52 +0000164/*
165 * SCOOP Device
166 */
167static struct resource tosa_scoop_resources[] = {
168 [0] = {
169 .start = TOSA_CF_PHYS,
170 .end = TOSA_CF_PHYS + 0xfff,
171 .flags = IORESOURCE_MEM,
172 },
173};
174
175static struct scoop_config tosa_scoop_setup = {
176 .io_dir = TOSA_SCOOP_IO_DIR,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100177 .gpio_base = TOSA_SCOOP_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000178};
179
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100180static struct platform_device tosascoop_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000181 .name = "sharp-scoop",
182 .id = 0,
183 .dev = {
184 .platform_data = &tosa_scoop_setup,
185 },
186 .num_resources = ARRAY_SIZE(tosa_scoop_resources),
187 .resource = tosa_scoop_resources,
188};
189
190
191/*
192 * SCOOP Device Jacket
193 */
194static struct resource tosa_scoop_jc_resources[] = {
195 [0] = {
196 .start = TOSA_SCOOP_PHYS + 0x40,
197 .end = TOSA_SCOOP_PHYS + 0xfff,
198 .flags = IORESOURCE_MEM,
199 },
200};
201
202static struct scoop_config tosa_scoop_jc_setup = {
203 .io_dir = TOSA_SCOOP_JC_IO_DIR,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100204 .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000205};
206
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100207static struct platform_device tosascoop_jc_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000208 .name = "sharp-scoop",
209 .id = 1,
210 .dev = {
211 .platform_data = &tosa_scoop_jc_setup,
212 .parent = &tosascoop_device.dev,
213 },
214 .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
215 .resource = tosa_scoop_jc_resources,
216};
217
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000218/*
219 * PCMCIA
220 */
Dirk Opfer8459c152005-11-06 14:27:52 +0000221static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
222{
223 .dev = &tosascoop_device.dev,
224 .irq = TOSA_IRQ_GPIO_CF_IRQ,
225 .cd_irq = TOSA_IRQ_GPIO_CF_CD,
226 .cd_irq_str = "PCMCIA0 CD",
227},{
228 .dev = &tosascoop_jc_device.dev,
229 .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
230 .cd_irq = -1,
231},
232};
233
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000234static struct scoop_pcmcia_config tosa_pcmcia_config = {
235 .devs = &tosa_pcmcia_scoop[0],
236 .num_devs = 2,
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000237};
238
Dirk Opfera93876c2005-11-08 19:15:30 +0000239/*
240 * USB Device Controller
241 */
Dirk Opfera93876c2005-11-08 19:15:30 +0000242static struct pxa2xx_udc_mach_info udc_info __initdata = {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100243 .gpio_pullup = TOSA_GPIO_USB_PULLUP,
Dmitry Baryshkov487dc922007-12-21 12:18:01 +0300244 .gpio_vbus = TOSA_GPIO_USB_IN,
245 .gpio_vbus_inverted = 1,
Dirk Opfera93876c2005-11-08 19:15:30 +0000246};
247
248/*
249 * MMC/SD Device
250 */
251static struct pxamci_platform_data tosa_mci_platform_data;
252
David Howells40220c12006-10-09 12:19:47 +0100253static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
Dirk Opfera93876c2005-11-08 19:15:30 +0000254{
255 int err;
256
Dirk Opfera93876c2005-11-08 19:15:30 +0000257 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
258
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100259 err = gpio_request(TOSA_GPIO_nSD_DETECT, "MMC/SD card detect");
260 if (err) {
261 printk(KERN_ERR "tosa_mci_init: can't request nSD_DETECT gpio\n");
262 goto err_gpio_detect;
263 }
264 err = gpio_direction_input(TOSA_GPIO_nSD_DETECT);
265 if (err)
266 goto err_gpio_detect_dir;
267
Russell King2687bd32008-01-23 14:05:58 +0000268 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
269 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Dirk Opfera93876c2005-11-08 19:15:30 +0000270 "MMC/SD card detect", data);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100271 if (err) {
Dirk Opfera93876c2005-11-08 19:15:30 +0000272 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100273 goto err_irq;
274 }
Dirk Opfera93876c2005-11-08 19:15:30 +0000275
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100276 err = gpio_request(TOSA_GPIO_SD_WP, "SD Write Protect");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100277 if (err) {
278 printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n");
279 goto err_gpio_wp;
280 }
281 err = gpio_direction_input(TOSA_GPIO_SD_WP);
282 if (err)
283 goto err_gpio_wp_dir;
284
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100285 err = gpio_request(TOSA_GPIO_PWR_ON, "SD Power");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100286 if (err) {
287 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
288 goto err_gpio_pwr;
289 }
290 err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0);
291 if (err)
292 goto err_gpio_pwr_dir;
293
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100294 err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
295 if (err) {
296 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
297 goto err_gpio_int;
298 }
299 err = gpio_direction_input(TOSA_GPIO_nSD_INT);
300 if (err)
301 goto err_gpio_int_dir;
302
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100303 return 0;
304
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100305err_gpio_int_dir:
306 gpio_free(TOSA_GPIO_nSD_INT);
307err_gpio_int:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100308err_gpio_pwr_dir:
309 gpio_free(TOSA_GPIO_PWR_ON);
310err_gpio_pwr:
311err_gpio_wp_dir:
312 gpio_free(TOSA_GPIO_SD_WP);
313err_gpio_wp:
314 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
315err_irq:
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100316err_gpio_detect_dir:
317 gpio_free(TOSA_GPIO_nSD_DETECT);
318err_gpio_detect:
Russell King2687bd32008-01-23 14:05:58 +0000319 return err;
Dirk Opfera93876c2005-11-08 19:15:30 +0000320}
321
322static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
323{
324 struct pxamci_platform_data* p_d = dev->platform_data;
325
326 if (( 1 << vdd) & p_d->ocr_mask) {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100327 gpio_set_value(TOSA_GPIO_PWR_ON, 1);
Dirk Opfera93876c2005-11-08 19:15:30 +0000328 } else {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100329 gpio_set_value(TOSA_GPIO_PWR_ON, 0);
Dirk Opfera93876c2005-11-08 19:15:30 +0000330 }
331}
332
333static int tosa_mci_get_ro(struct device *dev)
334{
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100335 return gpio_get_value(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000336}
337
338static void tosa_mci_exit(struct device *dev, void *data)
339{
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100340 gpio_free(TOSA_GPIO_nSD_INT);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100341 gpio_free(TOSA_GPIO_PWR_ON);
342 gpio_free(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000343 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100344 gpio_free(TOSA_GPIO_nSD_DETECT);
Dirk Opfera93876c2005-11-08 19:15:30 +0000345}
346
347static struct pxamci_platform_data tosa_mci_platform_data = {
348 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
349 .init = tosa_mci_init,
350 .get_ro = tosa_mci_get_ro,
351 .setpower = tosa_mci_setpower,
352 .exit = tosa_mci_exit,
353};
354
355/*
356 * Irda
357 */
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100358static void tosa_irda_transceiver_mode(struct device *dev, int mode)
359{
360 if (mode & IR_OFF) {
361 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
362 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_off));
363 gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
364 } else {
365 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_on));
366 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
367 }
368}
369
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100370static int tosa_irda_startup(struct device *dev)
371{
372 int ret;
373
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100374 ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
375 if (ret)
376 goto err_tx;
377 ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
378 if (ret)
379 goto err_tx_dir;
380
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100381 ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
382 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100383 goto err_pwr;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100384
385 ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
386 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100387 goto err_pwr_dir;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100388
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100389 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
390
391 return 0;
392
393err_pwr_dir:
394 gpio_free(TOSA_GPIO_IR_POWERDWN);
395err_pwr:
396err_tx_dir:
397 gpio_free(TOSA_GPIO_IRDA_TX);
398err_tx:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100399 return ret;
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100400}
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100401
402static void tosa_irda_shutdown(struct device *dev)
403{
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100404 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100405 gpio_free(TOSA_GPIO_IR_POWERDWN);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100406 gpio_free(TOSA_GPIO_IRDA_TX);
Dirk Opfera93876c2005-11-08 19:15:30 +0000407}
408
409static struct pxaficp_platform_data tosa_ficp_platform_data = {
410 .transceiver_cap = IR_SIRMODE | IR_OFF,
411 .transceiver_mode = tosa_irda_transceiver_mode,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100412 .startup = tosa_irda_startup,
413 .shutdown = tosa_irda_shutdown,
Dirk Opfera93876c2005-11-08 19:15:30 +0000414};
415
416/*
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100417 * Tosa AC IN
418 */
419static int tosa_power_init(struct device *dev)
420{
421 int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
422 if (ret)
423 goto err_gpio_req;
424
425 ret = gpio_direction_input(TOSA_GPIO_AC_IN);
426 if (ret)
427 goto err_gpio_in;
428
429 return 0;
430
431err_gpio_in:
432 gpio_free(TOSA_GPIO_AC_IN);
433err_gpio_req:
434 return ret;
435}
436
437static void tosa_power_exit(struct device *dev)
438{
439 gpio_free(TOSA_GPIO_AC_IN);
440}
441
442static int tosa_power_ac_online(void)
443{
444 return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
445}
446
447static char *tosa_ac_supplied_to[] = {
448 "main-battery",
449 "backup-battery",
450 "jacket-battery",
451};
452
453static struct pda_power_pdata tosa_power_data = {
454 .init = tosa_power_init,
455 .is_ac_online = tosa_power_ac_online,
456 .exit = tosa_power_exit,
457 .supplied_to = tosa_ac_supplied_to,
458 .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
459};
460
461static struct resource tosa_power_resource[] = {
462 {
463 .name = "ac",
464 .start = gpio_to_irq(TOSA_GPIO_AC_IN),
465 .end = gpio_to_irq(TOSA_GPIO_AC_IN),
466 .flags = IORESOURCE_IRQ |
467 IORESOURCE_IRQ_HIGHEDGE |
468 IORESOURCE_IRQ_LOWEDGE,
469 },
470};
471
472static struct platform_device tosa_power_device = {
473 .name = "pda-power",
474 .id = -1,
475 .dev.platform_data = &tosa_power_data,
476 .resource = tosa_power_resource,
477 .num_resources = ARRAY_SIZE(tosa_power_resource),
478};
479
480/*
Dirk Opfera93876c2005-11-08 19:15:30 +0000481 * Tosa Keyboard
482 */
483static struct platform_device tosakbd_device = {
484 .name = "tosa-keyboard",
485 .id = -1,
486};
Dirk Opfer8459c152005-11-06 14:27:52 +0000487
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500488static struct gpio_keys_button tosa_gpio_keys[] = {
Dmitry Baryshkov0aa975612008-04-12 20:02:50 +0100489 /*
490 * Two following keys are directly tied to "ON" button of tosa. Why?
491 * The first one can be used as a wakeup source, the second can't;
492 * also the first one is OR of ac_powered and on_button.
493 */
494 {
495 .type = EV_PWR,
496 .code = KEY_RESERVED,
497 .gpio = TOSA_GPIO_POWERON,
498 .desc = "Poweron",
499 .wakeup = 1,
500 .active_low = 1,
501 },
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500502 {
503 .type = EV_PWR,
504 .code = KEY_SUSPEND,
505 .gpio = TOSA_GPIO_ON_KEY,
506 .desc = "On key",
Dmitry Baryshkov0aa975612008-04-12 20:02:50 +0100507 /*
508 * can't be used as wakeup
509 * .wakeup = 1,
510 */
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500511 .active_low = 1,
512 },
513 {
514 .type = EV_KEY,
515 .code = TOSA_KEY_RECORD,
516 .gpio = TOSA_GPIO_RECORD_BTN,
517 .desc = "Record Button",
518 .wakeup = 1,
519 .active_low = 1,
520 },
521 {
522 .type = EV_KEY,
523 .code = TOSA_KEY_SYNC,
524 .gpio = TOSA_GPIO_SYNC,
525 .desc = "Sync Button",
526 .wakeup = 1,
527 .active_low = 1,
528 },
529};
530
531static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
532 .buttons = tosa_gpio_keys,
533 .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
534};
535
536static struct platform_device tosa_gpio_keys_device = {
537 .name = "gpio-keys",
538 .id = -1,
539 .dev = {
540 .platform_data = &tosa_gpio_keys_platform_data,
541 },
542};
543
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800544/*
545 * Tosa LEDs
546 */
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100547static struct gpio_led tosa_gpio_leds[] = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100548 {
549 .name = "tosa:amber:charge",
550 .default_trigger = "main-battery-charging",
551 .gpio = TOSA_GPIO_CHRG_ERR_LED,
552 },
553 {
554 .name = "tosa:green:mail",
555 .default_trigger = "nand-disk",
556 .gpio = TOSA_GPIO_NOTE_LED,
557 },
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100558 {
559 .name = "tosa:dual:wlan",
560 .default_trigger = "none",
561 .gpio = TOSA_GPIO_WLAN_LED,
562 },
563 {
564 .name = "tosa:blue:bluetooth",
565 .default_trigger = "none",
566 .gpio = TOSA_GPIO_BT_LED,
567 },
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100568};
569
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100570static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100571 .leds = tosa_gpio_leds,
572 .num_leds = ARRAY_SIZE(tosa_gpio_leds),
573};
574
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800575static struct platform_device tosaled_device = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100576 .name = "leds-gpio",
577 .id = -1,
578 .dev = {
579 .platform_data = &tosa_gpio_leds_platform_data,
580 },
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800581};
582
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100583/*
584 * Toshiba Mobile IO Controller
585 */
586static struct resource tc6393xb_resources[] = {
587 [0] = {
588 .start = TOSA_LCDC_PHYS,
589 .end = TOSA_LCDC_PHYS + 0x3ffffff,
590 .flags = IORESOURCE_MEM,
591 },
592
593 [1] = {
594 .start = TOSA_IRQ_GPIO_TC6393XB_INT,
595 .end = TOSA_IRQ_GPIO_TC6393XB_INT,
596 .flags = IORESOURCE_IRQ,
597 },
598};
599
600
601static int tosa_tc6393xb_enable(struct platform_device *dev)
602{
603 int rc;
604
605 rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
606 if (rc)
607 goto err_req_pclr;
608 rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
609 if (rc)
610 goto err_req_suspend;
611 rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "l3v");
612 if (rc)
613 goto err_req_l3v;
614 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
615 if (rc)
616 goto err_dir_l3v;
617 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
618 if (rc)
619 goto err_dir_suspend;
620 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
621 if (rc)
622 goto err_dir_pclr;
623
624 mdelay(1);
625
626 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
627
628 mdelay(10);
629
630 gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
631 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
632
633 return 0;
634err_dir_pclr:
635err_dir_suspend:
636err_dir_l3v:
637 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
638err_req_l3v:
639 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
640err_req_suspend:
641 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
642err_req_pclr:
643 return rc;
644}
645
646static int tosa_tc6393xb_disable(struct platform_device *dev)
647{
648 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
649 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
650 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
651
652 return 0;
653}
654
655static int tosa_tc6393xb_resume(struct platform_device *dev)
656{
657 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
658 mdelay(10);
659 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
660 mdelay(10);
661
662 return 0;
663}
664
665static int tosa_tc6393xb_suspend(struct platform_device *dev)
666{
667 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
668 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
669 return 0;
670}
671
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100672static struct mtd_partition tosa_nand_partition[] = {
673 {
674 .name = "smf",
675 .offset = 0,
676 .size = 7 * 1024 * 1024,
677 },
678 {
679 .name = "root",
680 .offset = MTDPART_OFS_APPEND,
681 .size = 28 * 1024 * 1024,
682 },
683 {
684 .name = "home",
685 .offset = MTDPART_OFS_APPEND,
686 .size = MTDPART_SIZ_FULL,
687 },
688};
689
690static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
691
692static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = {
693 .options = 0,
694 .offs = 4,
695 .len = 2,
696 .pattern = scan_ff_pattern
697};
698
699static struct tmio_nand_data tosa_tc6393xb_nand_config = {
700 .num_partitions = ARRAY_SIZE(tosa_nand_partition),
701 .partition = tosa_nand_partition,
702 .badblock_pattern = &tosa_tc6393xb_nand_bbt,
703};
704
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100705static struct tc6393xb_platform_data tosa_tc6393xb_setup = {
706 .scr_pll2cr = 0x0cc1,
707 .scr_gper = 0x3300,
708 .scr_gpo_dsr =
709 TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
710 .scr_gpo_doecr =
711 TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
712
713 .irq_base = IRQ_BOARD_START,
714 .gpio_base = TOSA_TC6393XB_GPIO_BASE,
715
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 Baryshkovbf0116e2008-06-14 11:42:02 +0100722};
723
724
725static struct platform_device tc6393xb_device = {
726 .name = "tc6393xb",
727 .id = -1,
728 .dev = {
729 .platform_data = &tosa_tc6393xb_setup,
730 },
731 .num_resources = ARRAY_SIZE(tc6393xb_resources),
732 .resource = tc6393xb_resources,
733};
734
Dirk Opfer8459c152005-11-06 14:27:52 +0000735static struct platform_device *devices[] __initdata = {
736 &tosascoop_device,
737 &tosascoop_jc_device,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100738 &tc6393xb_device,
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100739 &tosa_power_device,
Dirk Opfera93876c2005-11-08 19:15:30 +0000740 &tosakbd_device,
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500741 &tosa_gpio_keys_device,
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800742 &tosaled_device,
Dirk Opfer8459c152005-11-06 14:27:52 +0000743};
744
Richard Purdie74617fb2006-06-19 19:57:12 +0100745static void tosa_poweroff(void)
746{
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100747 arm_machine_restart('g');
Richard Purdie74617fb2006-06-19 19:57:12 +0100748}
749
750static void tosa_restart(char mode)
751{
752 /* Bootloader magic for a reboot */
753 if((MSC0 & 0xffff0000) == 0x7ff00000)
754 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
755
756 tosa_poweroff();
757}
758
Dirk Opfer8459c152005-11-06 14:27:52 +0000759static void __init tosa_init(void)
760{
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100761 int dummy;
762
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100763 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100764 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_off));
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100765 gpio_set_wake(MFP_PIN_GPIO1, 1);
766 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
767
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100768 init_gpio_reset(TOSA_GPIO_ON_RESET);
769
Richard Purdie74617fb2006-06-19 19:57:12 +0100770 pm_power_off = tosa_poweroff;
771 arm_pm_restart = tosa_restart;
772
Dirk Opfer8459c152005-11-06 14:27:52 +0000773 PCFR |= PCFR_OPDE;
774
Dirk Opfera93876c2005-11-08 19:15:30 +0000775 /* enable batt_fault */
Dirk Opfer8459c152005-11-06 14:27:52 +0000776 PMCR = 0x01;
777
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100778 dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
779 dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
780 dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
781
Dirk Opfera93876c2005-11-08 19:15:30 +0000782 pxa_set_mci_info(&tosa_mci_platform_data);
783 pxa_set_udc_info(&udc_info);
784 pxa_set_ficp_info(&tosa_ficp_platform_data);
Dmitry Baryshkov481ea5a2008-04-10 15:43:18 +0100785 pxa_set_i2c_info(NULL);
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000786 platform_scoop_config = &tosa_pcmcia_config;
Dirk Opfer8459c152005-11-06 14:27:52 +0000787
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000788 platform_add_devices(devices, ARRAY_SIZE(devices));
Dirk Opfer8459c152005-11-06 14:27:52 +0000789}
790
791static void __init fixup_tosa(struct machine_desc *desc,
792 struct tag *tags, char **cmdline, struct meminfo *mi)
793{
794 sharpsl_save_param();
795 mi->nr_banks=1;
796 mi->bank[0].start = 0xa0000000;
797 mi->bank[0].node = 0;
798 mi->bank[0].size = (64*1024*1024);
799}
800
801MACHINE_START(TOSA, "SHARP Tosa")
Dirk Opfer8459c152005-11-06 14:27:52 +0000802 .phys_io = 0x40000000,
803 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
804 .fixup = fixup_tosa,
805 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100806 .init_irq = pxa25x_init_irq,
Dirk Opfer8459c152005-11-06 14:27:52 +0000807 .init_machine = tosa_init,
808 .timer = &pxa_timer,
809MACHINE_END