blob: 38bc59c441101324e94b668ee96ec57cf907366b [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>
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>
Russell Kinga09e64f2008-08-05 16:14:15 +010037#include <mach/pxa2xx-regs.h>
38#include <mach/mfp-pxa25x.h>
39#include <mach/irda.h>
40#include <mach/i2c.h>
41#include <mach/mmc.h>
42#include <mach/udc.h>
43#include <mach/tosa_bt.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000044
45#include <asm/mach/arch.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010046#include <mach/tosa.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000047
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,
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100152
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100153 /* IrDA is managed in other way */
154 GPIO46_GPIO,
155 GPIO47_GPIO,
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100156};
157
Dirk Opfer8459c152005-11-06 14:27:52 +0000158/*
159 * SCOOP Device
160 */
161static struct resource tosa_scoop_resources[] = {
162 [0] = {
163 .start = TOSA_CF_PHYS,
164 .end = TOSA_CF_PHYS + 0xfff,
165 .flags = IORESOURCE_MEM,
166 },
167};
168
169static struct scoop_config tosa_scoop_setup = {
170 .io_dir = TOSA_SCOOP_IO_DIR,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100171 .gpio_base = TOSA_SCOOP_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000172};
173
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100174static struct platform_device tosascoop_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000175 .name = "sharp-scoop",
176 .id = 0,
177 .dev = {
178 .platform_data = &tosa_scoop_setup,
179 },
180 .num_resources = ARRAY_SIZE(tosa_scoop_resources),
181 .resource = tosa_scoop_resources,
182};
183
184
185/*
186 * SCOOP Device Jacket
187 */
188static struct resource tosa_scoop_jc_resources[] = {
189 [0] = {
190 .start = TOSA_SCOOP_PHYS + 0x40,
191 .end = TOSA_SCOOP_PHYS + 0xfff,
192 .flags = IORESOURCE_MEM,
193 },
194};
195
196static struct scoop_config tosa_scoop_jc_setup = {
197 .io_dir = TOSA_SCOOP_JC_IO_DIR,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100198 .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000199};
200
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100201static struct platform_device tosascoop_jc_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000202 .name = "sharp-scoop",
203 .id = 1,
204 .dev = {
205 .platform_data = &tosa_scoop_jc_setup,
206 .parent = &tosascoop_device.dev,
207 },
208 .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
209 .resource = tosa_scoop_jc_resources,
210};
211
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000212/*
213 * PCMCIA
214 */
Dirk Opfer8459c152005-11-06 14:27:52 +0000215static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
216{
217 .dev = &tosascoop_device.dev,
218 .irq = TOSA_IRQ_GPIO_CF_IRQ,
219 .cd_irq = TOSA_IRQ_GPIO_CF_CD,
220 .cd_irq_str = "PCMCIA0 CD",
221},{
222 .dev = &tosascoop_jc_device.dev,
223 .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
224 .cd_irq = -1,
225},
226};
227
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000228static struct scoop_pcmcia_config tosa_pcmcia_config = {
229 .devs = &tosa_pcmcia_scoop[0],
230 .num_devs = 2,
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000231};
232
Dirk Opfera93876c2005-11-08 19:15:30 +0000233/*
234 * USB Device Controller
235 */
Dirk Opfera93876c2005-11-08 19:15:30 +0000236static struct pxa2xx_udc_mach_info udc_info __initdata = {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100237 .gpio_pullup = TOSA_GPIO_USB_PULLUP,
Dmitry Baryshkov487dc922007-12-21 12:18:01 +0300238 .gpio_vbus = TOSA_GPIO_USB_IN,
239 .gpio_vbus_inverted = 1,
Dirk Opfera93876c2005-11-08 19:15:30 +0000240};
241
242/*
243 * MMC/SD Device
244 */
245static struct pxamci_platform_data tosa_mci_platform_data;
246
David Howells40220c12006-10-09 12:19:47 +0100247static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
Dirk Opfera93876c2005-11-08 19:15:30 +0000248{
249 int err;
250
Dirk Opfera93876c2005-11-08 19:15:30 +0000251 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
252
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100253 err = gpio_request(TOSA_GPIO_nSD_DETECT, "MMC/SD card detect");
254 if (err) {
255 printk(KERN_ERR "tosa_mci_init: can't request nSD_DETECT gpio\n");
256 goto err_gpio_detect;
257 }
258 err = gpio_direction_input(TOSA_GPIO_nSD_DETECT);
259 if (err)
260 goto err_gpio_detect_dir;
261
Russell King2687bd32008-01-23 14:05:58 +0000262 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
263 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Dirk Opfera93876c2005-11-08 19:15:30 +0000264 "MMC/SD card detect", data);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100265 if (err) {
Dirk Opfera93876c2005-11-08 19:15:30 +0000266 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100267 goto err_irq;
268 }
Dirk Opfera93876c2005-11-08 19:15:30 +0000269
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100270 err = gpio_request(TOSA_GPIO_SD_WP, "SD Write Protect");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100271 if (err) {
272 printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n");
273 goto err_gpio_wp;
274 }
275 err = gpio_direction_input(TOSA_GPIO_SD_WP);
276 if (err)
277 goto err_gpio_wp_dir;
278
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100279 err = gpio_request(TOSA_GPIO_PWR_ON, "SD Power");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100280 if (err) {
281 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
282 goto err_gpio_pwr;
283 }
284 err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0);
285 if (err)
286 goto err_gpio_pwr_dir;
287
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100288 err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
289 if (err) {
290 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
291 goto err_gpio_int;
292 }
293 err = gpio_direction_input(TOSA_GPIO_nSD_INT);
294 if (err)
295 goto err_gpio_int_dir;
296
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100297 return 0;
298
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100299err_gpio_int_dir:
300 gpio_free(TOSA_GPIO_nSD_INT);
301err_gpio_int:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100302err_gpio_pwr_dir:
303 gpio_free(TOSA_GPIO_PWR_ON);
304err_gpio_pwr:
305err_gpio_wp_dir:
306 gpio_free(TOSA_GPIO_SD_WP);
307err_gpio_wp:
308 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
309err_irq:
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100310err_gpio_detect_dir:
311 gpio_free(TOSA_GPIO_nSD_DETECT);
312err_gpio_detect:
Russell King2687bd32008-01-23 14:05:58 +0000313 return err;
Dirk Opfera93876c2005-11-08 19:15:30 +0000314}
315
316static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
317{
318 struct pxamci_platform_data* p_d = dev->platform_data;
319
320 if (( 1 << vdd) & p_d->ocr_mask) {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100321 gpio_set_value(TOSA_GPIO_PWR_ON, 1);
Dirk Opfera93876c2005-11-08 19:15:30 +0000322 } else {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100323 gpio_set_value(TOSA_GPIO_PWR_ON, 0);
Dirk Opfera93876c2005-11-08 19:15:30 +0000324 }
325}
326
327static int tosa_mci_get_ro(struct device *dev)
328{
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100329 return gpio_get_value(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000330}
331
332static void tosa_mci_exit(struct device *dev, void *data)
333{
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100334 gpio_free(TOSA_GPIO_nSD_INT);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100335 gpio_free(TOSA_GPIO_PWR_ON);
336 gpio_free(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000337 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100338 gpio_free(TOSA_GPIO_nSD_DETECT);
Dirk Opfera93876c2005-11-08 19:15:30 +0000339}
340
341static struct pxamci_platform_data tosa_mci_platform_data = {
342 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
343 .init = tosa_mci_init,
344 .get_ro = tosa_mci_get_ro,
345 .setpower = tosa_mci_setpower,
346 .exit = tosa_mci_exit,
347};
348
349/*
350 * Irda
351 */
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100352static void tosa_irda_transceiver_mode(struct device *dev, int mode)
353{
354 if (mode & IR_OFF) {
355 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100356 pxa2xx_transceiver_mode(dev, mode);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100357 gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
358 } else {
Dmitry Baryshkov0fc3ff32008-07-02 13:54:46 +0100359 pxa2xx_transceiver_mode(dev, mode);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100360 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
361 }
362}
363
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100364static int tosa_irda_startup(struct device *dev)
365{
366 int ret;
367
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100368 ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
369 if (ret)
370 goto err_tx;
371 ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
372 if (ret)
373 goto err_tx_dir;
374
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100375 ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
376 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100377 goto err_pwr;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100378
379 ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
380 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100381 goto err_pwr_dir;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100382
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100383 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
384
385 return 0;
386
387err_pwr_dir:
388 gpio_free(TOSA_GPIO_IR_POWERDWN);
389err_pwr:
390err_tx_dir:
391 gpio_free(TOSA_GPIO_IRDA_TX);
392err_tx:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100393 return ret;
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100394}
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100395
396static void tosa_irda_shutdown(struct device *dev)
397{
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100398 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100399 gpio_free(TOSA_GPIO_IR_POWERDWN);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100400 gpio_free(TOSA_GPIO_IRDA_TX);
Dirk Opfera93876c2005-11-08 19:15:30 +0000401}
402
403static struct pxaficp_platform_data tosa_ficp_platform_data = {
404 .transceiver_cap = IR_SIRMODE | IR_OFF,
405 .transceiver_mode = tosa_irda_transceiver_mode,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100406 .startup = tosa_irda_startup,
407 .shutdown = tosa_irda_shutdown,
Dirk Opfera93876c2005-11-08 19:15:30 +0000408};
409
410/*
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100411 * Tosa AC IN
412 */
413static int tosa_power_init(struct device *dev)
414{
415 int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
416 if (ret)
417 goto err_gpio_req;
418
419 ret = gpio_direction_input(TOSA_GPIO_AC_IN);
420 if (ret)
421 goto err_gpio_in;
422
423 return 0;
424
425err_gpio_in:
426 gpio_free(TOSA_GPIO_AC_IN);
427err_gpio_req:
428 return ret;
429}
430
431static void tosa_power_exit(struct device *dev)
432{
433 gpio_free(TOSA_GPIO_AC_IN);
434}
435
436static int tosa_power_ac_online(void)
437{
438 return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
439}
440
441static char *tosa_ac_supplied_to[] = {
442 "main-battery",
443 "backup-battery",
444 "jacket-battery",
445};
446
447static struct pda_power_pdata tosa_power_data = {
448 .init = tosa_power_init,
449 .is_ac_online = tosa_power_ac_online,
450 .exit = tosa_power_exit,
451 .supplied_to = tosa_ac_supplied_to,
452 .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
453};
454
455static struct resource tosa_power_resource[] = {
456 {
457 .name = "ac",
458 .start = gpio_to_irq(TOSA_GPIO_AC_IN),
459 .end = gpio_to_irq(TOSA_GPIO_AC_IN),
460 .flags = IORESOURCE_IRQ |
461 IORESOURCE_IRQ_HIGHEDGE |
462 IORESOURCE_IRQ_LOWEDGE,
463 },
464};
465
466static struct platform_device tosa_power_device = {
467 .name = "pda-power",
468 .id = -1,
469 .dev.platform_data = &tosa_power_data,
470 .resource = tosa_power_resource,
471 .num_resources = ARRAY_SIZE(tosa_power_resource),
472};
473
474/*
Dirk Opfera93876c2005-11-08 19:15:30 +0000475 * Tosa Keyboard
476 */
477static struct platform_device tosakbd_device = {
478 .name = "tosa-keyboard",
479 .id = -1,
480};
Dirk Opfer8459c152005-11-06 14:27:52 +0000481
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500482static struct gpio_keys_button tosa_gpio_keys[] = {
Dmitry Baryshkov0aa97562008-04-12 20:02:50 +0100483 /*
484 * Two following keys are directly tied to "ON" button of tosa. Why?
485 * The first one can be used as a wakeup source, the second can't;
486 * also the first one is OR of ac_powered and on_button.
487 */
488 {
489 .type = EV_PWR,
490 .code = KEY_RESERVED,
491 .gpio = TOSA_GPIO_POWERON,
492 .desc = "Poweron",
493 .wakeup = 1,
494 .active_low = 1,
495 },
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500496 {
497 .type = EV_PWR,
498 .code = KEY_SUSPEND,
499 .gpio = TOSA_GPIO_ON_KEY,
500 .desc = "On key",
Dmitry Baryshkov0aa97562008-04-12 20:02:50 +0100501 /*
502 * can't be used as wakeup
503 * .wakeup = 1,
504 */
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500505 .active_low = 1,
506 },
507 {
508 .type = EV_KEY,
509 .code = TOSA_KEY_RECORD,
510 .gpio = TOSA_GPIO_RECORD_BTN,
511 .desc = "Record Button",
512 .wakeup = 1,
513 .active_low = 1,
514 },
515 {
516 .type = EV_KEY,
517 .code = TOSA_KEY_SYNC,
518 .gpio = TOSA_GPIO_SYNC,
519 .desc = "Sync Button",
520 .wakeup = 1,
521 .active_low = 1,
522 },
523};
524
525static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
526 .buttons = tosa_gpio_keys,
527 .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
528};
529
530static struct platform_device tosa_gpio_keys_device = {
531 .name = "gpio-keys",
532 .id = -1,
533 .dev = {
534 .platform_data = &tosa_gpio_keys_platform_data,
535 },
536};
537
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800538/*
539 * Tosa LEDs
540 */
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100541static struct gpio_led tosa_gpio_leds[] = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100542 {
543 .name = "tosa:amber:charge",
544 .default_trigger = "main-battery-charging",
545 .gpio = TOSA_GPIO_CHRG_ERR_LED,
546 },
547 {
548 .name = "tosa:green:mail",
549 .default_trigger = "nand-disk",
550 .gpio = TOSA_GPIO_NOTE_LED,
551 },
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100552 {
553 .name = "tosa:dual:wlan",
554 .default_trigger = "none",
555 .gpio = TOSA_GPIO_WLAN_LED,
556 },
557 {
558 .name = "tosa:blue:bluetooth",
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100559 .default_trigger = "tosa-bt",
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100560 .gpio = TOSA_GPIO_BT_LED,
561 },
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100562};
563
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100564static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100565 .leds = tosa_gpio_leds,
566 .num_leds = ARRAY_SIZE(tosa_gpio_leds),
567};
568
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800569static struct platform_device tosaled_device = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100570 .name = "leds-gpio",
571 .id = -1,
572 .dev = {
573 .platform_data = &tosa_gpio_leds_platform_data,
574 },
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800575};
576
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100577/*
578 * Toshiba Mobile IO Controller
579 */
580static struct resource tc6393xb_resources[] = {
581 [0] = {
582 .start = TOSA_LCDC_PHYS,
583 .end = TOSA_LCDC_PHYS + 0x3ffffff,
584 .flags = IORESOURCE_MEM,
585 },
586
587 [1] = {
588 .start = TOSA_IRQ_GPIO_TC6393XB_INT,
589 .end = TOSA_IRQ_GPIO_TC6393XB_INT,
590 .flags = IORESOURCE_IRQ,
591 },
592};
593
594
595static int tosa_tc6393xb_enable(struct platform_device *dev)
596{
597 int rc;
598
599 rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
600 if (rc)
601 goto err_req_pclr;
602 rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
603 if (rc)
604 goto err_req_suspend;
605 rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "l3v");
606 if (rc)
607 goto err_req_l3v;
608 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
609 if (rc)
610 goto err_dir_l3v;
611 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
612 if (rc)
613 goto err_dir_suspend;
614 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
615 if (rc)
616 goto err_dir_pclr;
617
618 mdelay(1);
619
620 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
621
622 mdelay(10);
623
624 gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
625 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
626
627 return 0;
628err_dir_pclr:
629err_dir_suspend:
630err_dir_l3v:
631 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
632err_req_l3v:
633 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
634err_req_suspend:
635 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
636err_req_pclr:
637 return rc;
638}
639
640static int tosa_tc6393xb_disable(struct platform_device *dev)
641{
642 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
643 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
644 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
645
646 return 0;
647}
648
649static int tosa_tc6393xb_resume(struct platform_device *dev)
650{
651 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
652 mdelay(10);
653 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
654 mdelay(10);
655
656 return 0;
657}
658
659static int tosa_tc6393xb_suspend(struct platform_device *dev)
660{
661 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
662 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
663 return 0;
664}
665
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100666static struct mtd_partition tosa_nand_partition[] = {
667 {
668 .name = "smf",
669 .offset = 0,
670 .size = 7 * 1024 * 1024,
671 },
672 {
673 .name = "root",
674 .offset = MTDPART_OFS_APPEND,
675 .size = 28 * 1024 * 1024,
676 },
677 {
678 .name = "home",
679 .offset = MTDPART_OFS_APPEND,
680 .size = MTDPART_SIZ_FULL,
681 },
682};
683
684static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
685
686static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = {
687 .options = 0,
688 .offs = 4,
689 .len = 2,
690 .pattern = scan_ff_pattern
691};
692
693static struct tmio_nand_data tosa_tc6393xb_nand_config = {
694 .num_partitions = ARRAY_SIZE(tosa_nand_partition),
695 .partition = tosa_nand_partition,
696 .badblock_pattern = &tosa_tc6393xb_nand_bbt,
697};
698
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100699static struct tc6393xb_platform_data tosa_tc6393xb_setup = {
700 .scr_pll2cr = 0x0cc1,
701 .scr_gper = 0x3300,
702 .scr_gpo_dsr =
703 TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
704 .scr_gpo_doecr =
705 TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
706
707 .irq_base = IRQ_BOARD_START,
708 .gpio_base = TOSA_TC6393XB_GPIO_BASE,
709
710 .enable = tosa_tc6393xb_enable,
711 .disable = tosa_tc6393xb_disable,
712 .suspend = tosa_tc6393xb_suspend,
713 .resume = tosa_tc6393xb_resume,
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100714
715 .nand_data = &tosa_tc6393xb_nand_config,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100716};
717
718
719static struct platform_device tc6393xb_device = {
720 .name = "tc6393xb",
721 .id = -1,
722 .dev = {
723 .platform_data = &tosa_tc6393xb_setup,
724 },
725 .num_resources = ARRAY_SIZE(tc6393xb_resources),
726 .resource = tc6393xb_resources,
727};
728
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100729static struct tosa_bt_data tosa_bt_data = {
730 .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
731 .gpio_reset = TOSA_GPIO_BT_RESET,
732};
733
734static struct platform_device tosa_bt_device = {
735 .name = "tosa-bt",
736 .id = -1,
737 .dev.platform_data = &tosa_bt_data,
738};
739
740
Dirk Opfer8459c152005-11-06 14:27:52 +0000741static struct platform_device *devices[] __initdata = {
742 &tosascoop_device,
743 &tosascoop_jc_device,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100744 &tc6393xb_device,
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100745 &tosa_power_device,
Dirk Opfera93876c2005-11-08 19:15:30 +0000746 &tosakbd_device,
Dmitry Baryshkov93e90122008-01-21 01:04:20 -0500747 &tosa_gpio_keys_device,
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800748 &tosaled_device,
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100749 &tosa_bt_device,
Dirk Opfer8459c152005-11-06 14:27:52 +0000750};
751
Richard Purdie74617fb2006-06-19 19:57:12 +0100752static void tosa_poweroff(void)
753{
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100754 arm_machine_restart('g');
Richard Purdie74617fb2006-06-19 19:57:12 +0100755}
756
757static void tosa_restart(char mode)
758{
759 /* Bootloader magic for a reboot */
760 if((MSC0 & 0xffff0000) == 0x7ff00000)
761 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
762
763 tosa_poweroff();
764}
765
Dirk Opfer8459c152005-11-06 14:27:52 +0000766static void __init tosa_init(void)
767{
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100768 int dummy;
769
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100770 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
771 gpio_set_wake(MFP_PIN_GPIO1, 1);
772 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
773
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100774 init_gpio_reset(TOSA_GPIO_ON_RESET);
775
Richard Purdie74617fb2006-06-19 19:57:12 +0100776 pm_power_off = tosa_poweroff;
777 arm_pm_restart = tosa_restart;
778
Dirk Opfer8459c152005-11-06 14:27:52 +0000779 PCFR |= PCFR_OPDE;
780
Dirk Opfera93876c2005-11-08 19:15:30 +0000781 /* enable batt_fault */
Dirk Opfer8459c152005-11-06 14:27:52 +0000782 PMCR = 0x01;
783
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100784 dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
785 dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
786 dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
787
Dirk Opfera93876c2005-11-08 19:15:30 +0000788 pxa_set_mci_info(&tosa_mci_platform_data);
789 pxa_set_udc_info(&udc_info);
790 pxa_set_ficp_info(&tosa_ficp_platform_data);
Dmitry Baryshkov481ea5a2008-04-10 15:43:18 +0100791 pxa_set_i2c_info(NULL);
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000792 platform_scoop_config = &tosa_pcmcia_config;
Dirk Opfer8459c152005-11-06 14:27:52 +0000793
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000794 platform_add_devices(devices, ARRAY_SIZE(devices));
Dirk Opfer8459c152005-11-06 14:27:52 +0000795}
796
797static void __init fixup_tosa(struct machine_desc *desc,
798 struct tag *tags, char **cmdline, struct meminfo *mi)
799{
800 sharpsl_save_param();
801 mi->nr_banks=1;
802 mi->bank[0].start = 0xa0000000;
803 mi->bank[0].node = 0;
804 mi->bank[0].size = (64*1024*1024);
805}
806
807MACHINE_START(TOSA, "SHARP Tosa")
Dirk Opfer8459c152005-11-06 14:27:52 +0000808 .phys_io = 0x40000000,
809 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
810 .fixup = fixup_tosa,
811 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100812 .init_irq = pxa25x_init_irq,
Dirk Opfer8459c152005-11-06 14:27:52 +0000813 .init_machine = tosa_init,
814 .timer = &pxa_timer,
815MACHINE_END