blob: 5a9d329f504580aec1e6e47fed60a46232d35e09 [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>
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +010034#include <linux/rfkill.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000035
36#include <asm/setup.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000037#include <asm/mach-types.h>
eric miaobb548dd2008-01-30 09:39:48 +010038#include <asm/arch/pxa2xx-regs.h>
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010039#include <asm/arch/mfp-pxa25x.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000040#include <asm/arch/irda.h>
Dmitry Baryshkov481ea5a2008-04-10 15:43:18 +010041#include <asm/arch/i2c.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000042#include <asm/arch/mmc.h>
43#include <asm/arch/udc.h>
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +010044#include <asm/arch/tosa_bt.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000045
46#include <asm/mach/arch.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000047#include <asm/arch/tosa.h>
48
49#include <asm/hardware/scoop.h>
50#include <asm/mach/sharpsl_param.h>
51
52#include "generic.h"
Russell King46c41e62007-05-15 15:39:36 +010053#include "devices.h"
Dirk Opfer8459c152005-11-06 14:27:52 +000054
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010055static unsigned long tosa_pin_config[] = {
56 GPIO78_nCS_2, /* Scoop */
57 GPIO80_nCS_4, /* tg6393xb */
58 GPIO33_nCS_5, /* Scoop */
59
60 // GPIO76 CARD_VCC_ON1
61
62 GPIO19_GPIO, /* Reset out */
63 GPIO1_RST | WAKEUP_ON_EDGE_FALL,
64
65 GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */
66 GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */
67 GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */
68 GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */
69 GPIO20_GPIO, /* EAR_IN */
70 GPIO22_GPIO, /* On */
71
72 GPIO5_GPIO, /* USB_IN */
73 GPIO32_GPIO, /* Pen IRQ */
74
75 GPIO7_GPIO, /* Jacket Detect */
76 GPIO14_GPIO, /* BAT0_CRG */
77 GPIO12_GPIO, /* BAT1_CRG */
78 GPIO17_GPIO, /* BAT0_LOW */
79 GPIO84_GPIO, /* BAT1_LOW */
80 GPIO38_GPIO, /* BAT_LOCK */
81
82 GPIO11_3_6MHz,
83 GPIO15_GPIO, /* TC6393XB IRQ */
84 GPIO18_RDY,
85 GPIO27_GPIO, /* LCD Sync */
86
87 /* MMC */
88 GPIO6_MMC_CLK,
89 GPIO8_MMC_CS0,
90 GPIO9_GPIO, /* Detect */
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +010091 GPIO10_GPIO, /* nSD_INT */
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010092
93 /* CF */
94 GPIO13_GPIO, /* CD_IRQ */
95 GPIO21_GPIO, /* Main Slot IRQ */
96 GPIO36_GPIO, /* Jacket Slot IRQ */
97 GPIO48_nPOE,
98 GPIO49_nPWE,
99 GPIO50_nPIOR,
100 GPIO51_nPIOW,
101 GPIO52_nPCE_1,
102 GPIO53_nPCE_2,
103 GPIO54_nPSKTSEL,
104 GPIO55_nPREG,
105 GPIO56_nPWAIT,
106 GPIO57_nIOIS16,
107
108 /* AC97 */
109 GPIO31_AC97_SYNC,
110 GPIO30_AC97_SDATA_OUT,
111 GPIO28_AC97_BITCLK,
112 GPIO29_AC97_SDATA_IN_0,
113 // GPIO79 nAUD_IRQ
114
115 /* FFUART */
116 GPIO34_FFUART_RXD,
117 GPIO35_FFUART_CTS,
118 GPIO37_FFUART_DSR,
119 GPIO39_FFUART_TXD,
120 GPIO40_FFUART_DTR,
121 GPIO41_FFUART_RTS,
122
123 /* BTUART */
124 GPIO42_BTUART_RXD,
125 GPIO43_BTUART_TXD,
126 GPIO44_BTUART_CTS,
127 GPIO45_BTUART_RTS,
128
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100129 /* Keybd */
eric miaoc8671552008-05-26 03:28:50 +0100130 GPIO58_GPIO | MFP_LPM_DRIVE_LOW,
131 GPIO59_GPIO | MFP_LPM_DRIVE_LOW,
132 GPIO60_GPIO | MFP_LPM_DRIVE_LOW,
133 GPIO61_GPIO | MFP_LPM_DRIVE_LOW,
134 GPIO62_GPIO | MFP_LPM_DRIVE_LOW,
135 GPIO63_GPIO | MFP_LPM_DRIVE_LOW,
136 GPIO64_GPIO | MFP_LPM_DRIVE_LOW,
137 GPIO65_GPIO | MFP_LPM_DRIVE_LOW,
138 GPIO66_GPIO | MFP_LPM_DRIVE_LOW,
139 GPIO67_GPIO | MFP_LPM_DRIVE_LOW,
140 GPIO68_GPIO | MFP_LPM_DRIVE_LOW,
141 GPIO69_GPIO | MFP_LPM_DRIVE_LOW,
142 GPIO70_GPIO | MFP_LPM_DRIVE_LOW,
143 GPIO71_GPIO | MFP_LPM_DRIVE_LOW,
144 GPIO72_GPIO | MFP_LPM_DRIVE_LOW,
145 GPIO73_GPIO | MFP_LPM_DRIVE_LOW,
146 GPIO74_GPIO | MFP_LPM_DRIVE_LOW,
147 GPIO75_GPIO | MFP_LPM_DRIVE_LOW,
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100148
149 /* SPI */
150 GPIO81_SSP2_CLK_OUT,
151 GPIO82_SSP2_FRM_OUT,
152 GPIO83_SSP2_TXD,
153};
154
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100155static unsigned long tosa_pin_irda_off[] = {
156 GPIO46_STUART_RXD,
157 GPIO47_GPIO | MFP_LPM_DRIVE_LOW,
158};
159
160static unsigned long tosa_pin_irda_on[] = {
161 GPIO46_STUART_RXD,
162 GPIO47_STUART_TXD,
163};
164
165
Dirk Opfer8459c152005-11-06 14:27:52 +0000166/*
167 * SCOOP Device
168 */
169static struct resource tosa_scoop_resources[] = {
170 [0] = {
171 .start = TOSA_CF_PHYS,
172 .end = TOSA_CF_PHYS + 0xfff,
173 .flags = IORESOURCE_MEM,
174 },
175};
176
177static struct scoop_config tosa_scoop_setup = {
178 .io_dir = TOSA_SCOOP_IO_DIR,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100179 .gpio_base = TOSA_SCOOP_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000180};
181
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100182static struct platform_device tosascoop_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000183 .name = "sharp-scoop",
184 .id = 0,
185 .dev = {
186 .platform_data = &tosa_scoop_setup,
187 },
188 .num_resources = ARRAY_SIZE(tosa_scoop_resources),
189 .resource = tosa_scoop_resources,
190};
191
192
193/*
194 * SCOOP Device Jacket
195 */
196static struct resource tosa_scoop_jc_resources[] = {
197 [0] = {
198 .start = TOSA_SCOOP_PHYS + 0x40,
199 .end = TOSA_SCOOP_PHYS + 0xfff,
200 .flags = IORESOURCE_MEM,
201 },
202};
203
204static struct scoop_config tosa_scoop_jc_setup = {
205 .io_dir = TOSA_SCOOP_JC_IO_DIR,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100206 .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000207};
208
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100209static struct platform_device tosascoop_jc_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000210 .name = "sharp-scoop",
211 .id = 1,
212 .dev = {
213 .platform_data = &tosa_scoop_jc_setup,
214 .parent = &tosascoop_device.dev,
215 },
216 .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
217 .resource = tosa_scoop_jc_resources,
218};
219
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000220/*
221 * PCMCIA
222 */
Dirk Opfer8459c152005-11-06 14:27:52 +0000223static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
224{
225 .dev = &tosascoop_device.dev,
226 .irq = TOSA_IRQ_GPIO_CF_IRQ,
227 .cd_irq = TOSA_IRQ_GPIO_CF_CD,
228 .cd_irq_str = "PCMCIA0 CD",
229},{
230 .dev = &tosascoop_jc_device.dev,
231 .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
232 .cd_irq = -1,
233},
234};
235
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000236static struct scoop_pcmcia_config tosa_pcmcia_config = {
237 .devs = &tosa_pcmcia_scoop[0],
238 .num_devs = 2,
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000239};
240
Dirk Opfera93876c2005-11-08 19:15:30 +0000241/*
242 * USB Device Controller
243 */
Dirk Opfera93876c2005-11-08 19:15:30 +0000244static struct pxa2xx_udc_mach_info udc_info __initdata = {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100245 .gpio_pullup = TOSA_GPIO_USB_PULLUP,
Dmitry Baryshkov487dc922007-12-21 12:18:01 +0300246 .gpio_vbus = TOSA_GPIO_USB_IN,
247 .gpio_vbus_inverted = 1,
Dirk Opfera93876c2005-11-08 19:15:30 +0000248};
249
250/*
251 * MMC/SD Device
252 */
253static struct pxamci_platform_data tosa_mci_platform_data;
254
David Howells40220c12006-10-09 12:19:47 +0100255static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
Dirk Opfera93876c2005-11-08 19:15:30 +0000256{
257 int err;
258
Dirk Opfera93876c2005-11-08 19:15:30 +0000259 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
260
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100261 err = gpio_request(TOSA_GPIO_nSD_DETECT, "MMC/SD card detect");
262 if (err) {
263 printk(KERN_ERR "tosa_mci_init: can't request nSD_DETECT gpio\n");
264 goto err_gpio_detect;
265 }
266 err = gpio_direction_input(TOSA_GPIO_nSD_DETECT);
267 if (err)
268 goto err_gpio_detect_dir;
269
Russell King2687bd32008-01-23 14:05:58 +0000270 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
271 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Dirk Opfera93876c2005-11-08 19:15:30 +0000272 "MMC/SD card detect", data);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100273 if (err) {
Dirk Opfera93876c2005-11-08 19:15:30 +0000274 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100275 goto err_irq;
276 }
Dirk Opfera93876c2005-11-08 19:15:30 +0000277
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100278 err = gpio_request(TOSA_GPIO_SD_WP, "SD Write Protect");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100279 if (err) {
280 printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n");
281 goto err_gpio_wp;
282 }
283 err = gpio_direction_input(TOSA_GPIO_SD_WP);
284 if (err)
285 goto err_gpio_wp_dir;
286
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100287 err = gpio_request(TOSA_GPIO_PWR_ON, "SD Power");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100288 if (err) {
289 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
290 goto err_gpio_pwr;
291 }
292 err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0);
293 if (err)
294 goto err_gpio_pwr_dir;
295
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100296 err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
297 if (err) {
298 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
299 goto err_gpio_int;
300 }
301 err = gpio_direction_input(TOSA_GPIO_nSD_INT);
302 if (err)
303 goto err_gpio_int_dir;
304
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100305 return 0;
306
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100307err_gpio_int_dir:
308 gpio_free(TOSA_GPIO_nSD_INT);
309err_gpio_int:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100310err_gpio_pwr_dir:
311 gpio_free(TOSA_GPIO_PWR_ON);
312err_gpio_pwr:
313err_gpio_wp_dir:
314 gpio_free(TOSA_GPIO_SD_WP);
315err_gpio_wp:
316 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
317err_irq:
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100318err_gpio_detect_dir:
319 gpio_free(TOSA_GPIO_nSD_DETECT);
320err_gpio_detect:
Russell King2687bd32008-01-23 14:05:58 +0000321 return err;
Dirk Opfera93876c2005-11-08 19:15:30 +0000322}
323
324static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
325{
326 struct pxamci_platform_data* p_d = dev->platform_data;
327
328 if (( 1 << vdd) & p_d->ocr_mask) {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100329 gpio_set_value(TOSA_GPIO_PWR_ON, 1);
Dirk Opfera93876c2005-11-08 19:15:30 +0000330 } else {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100331 gpio_set_value(TOSA_GPIO_PWR_ON, 0);
Dirk Opfera93876c2005-11-08 19:15:30 +0000332 }
333}
334
335static int tosa_mci_get_ro(struct device *dev)
336{
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100337 return gpio_get_value(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000338}
339
340static void tosa_mci_exit(struct device *dev, void *data)
341{
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100342 gpio_free(TOSA_GPIO_nSD_INT);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100343 gpio_free(TOSA_GPIO_PWR_ON);
344 gpio_free(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000345 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100346 gpio_free(TOSA_GPIO_nSD_DETECT);
Dirk Opfera93876c2005-11-08 19:15:30 +0000347}
348
349static struct pxamci_platform_data tosa_mci_platform_data = {
350 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
351 .init = tosa_mci_init,
352 .get_ro = tosa_mci_get_ro,
353 .setpower = tosa_mci_setpower,
354 .exit = tosa_mci_exit,
355};
356
357/*
358 * Irda
359 */
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100360static void tosa_irda_transceiver_mode(struct device *dev, int mode)
361{
362 if (mode & IR_OFF) {
363 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
364 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_off));
365 gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
366 } else {
367 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_on));
368 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
369 }
370}
371
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100372static int tosa_irda_startup(struct device *dev)
373{
374 int ret;
375
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100376 ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
377 if (ret)
378 goto err_tx;
379 ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
380 if (ret)
381 goto err_tx_dir;
382
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100383 ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
384 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100385 goto err_pwr;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100386
387 ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
388 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100389 goto err_pwr_dir;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100390
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100391 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
392
393 return 0;
394
395err_pwr_dir:
396 gpio_free(TOSA_GPIO_IR_POWERDWN);
397err_pwr:
398err_tx_dir:
399 gpio_free(TOSA_GPIO_IRDA_TX);
400err_tx:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100401 return ret;
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100402}
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100403
404static void tosa_irda_shutdown(struct device *dev)
405{
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100406 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100407 gpio_free(TOSA_GPIO_IR_POWERDWN);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100408 gpio_free(TOSA_GPIO_IRDA_TX);
Dirk Opfera93876c2005-11-08 19:15:30 +0000409}
410
411static struct pxaficp_platform_data tosa_ficp_platform_data = {
412 .transceiver_cap = IR_SIRMODE | IR_OFF,
413 .transceiver_mode = tosa_irda_transceiver_mode,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100414 .startup = tosa_irda_startup,
415 .shutdown = tosa_irda_shutdown,
Dirk Opfera93876c2005-11-08 19:15:30 +0000416};
417
418/*
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100419 * Tosa AC IN
420 */
421static int tosa_power_init(struct device *dev)
422{
423 int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
424 if (ret)
425 goto err_gpio_req;
426
427 ret = gpio_direction_input(TOSA_GPIO_AC_IN);
428 if (ret)
429 goto err_gpio_in;
430
431 return 0;
432
433err_gpio_in:
434 gpio_free(TOSA_GPIO_AC_IN);
435err_gpio_req:
436 return ret;
437}
438
439static void tosa_power_exit(struct device *dev)
440{
441 gpio_free(TOSA_GPIO_AC_IN);
442}
443
444static int tosa_power_ac_online(void)
445{
446 return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
447}
448
449static char *tosa_ac_supplied_to[] = {
450 "main-battery",
451 "backup-battery",
452 "jacket-battery",
453};
454
455static struct pda_power_pdata tosa_power_data = {
456 .init = tosa_power_init,
457 .is_ac_online = tosa_power_ac_online,
458 .exit = tosa_power_exit,
459 .supplied_to = tosa_ac_supplied_to,
460 .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
461};
462
463static struct resource tosa_power_resource[] = {
464 {
465 .name = "ac",
466 .start = gpio_to_irq(TOSA_GPIO_AC_IN),
467 .end = gpio_to_irq(TOSA_GPIO_AC_IN),
468 .flags = IORESOURCE_IRQ |
469 IORESOURCE_IRQ_HIGHEDGE |
470 IORESOURCE_IRQ_LOWEDGE,
471 },
472};
473
474static struct platform_device tosa_power_device = {
475 .name = "pda-power",
476 .id = -1,
477 .dev.platform_data = &tosa_power_data,
478 .resource = tosa_power_resource,
479 .num_resources = ARRAY_SIZE(tosa_power_resource),
480};
481
482/*
Dirk Opfera93876c2005-11-08 19:15:30 +0000483 * Tosa Keyboard
484 */
485static struct platform_device tosakbd_device = {
486 .name = "tosa-keyboard",
487 .id = -1,
488};
Dirk Opfer8459c152005-11-06 14:27:52 +0000489
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500490static struct gpio_keys_button tosa_gpio_keys[] = {
Dmitry Baryshkov0aa975612008-04-12 20:02:50 +0100491 /*
492 * Two following keys are directly tied to "ON" button of tosa. Why?
493 * The first one can be used as a wakeup source, the second can't;
494 * also the first one is OR of ac_powered and on_button.
495 */
496 {
497 .type = EV_PWR,
498 .code = KEY_RESERVED,
499 .gpio = TOSA_GPIO_POWERON,
500 .desc = "Poweron",
501 .wakeup = 1,
502 .active_low = 1,
503 },
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500504 {
505 .type = EV_PWR,
506 .code = KEY_SUSPEND,
507 .gpio = TOSA_GPIO_ON_KEY,
508 .desc = "On key",
Dmitry Baryshkov0aa975612008-04-12 20:02:50 +0100509 /*
510 * can't be used as wakeup
511 * .wakeup = 1,
512 */
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500513 .active_low = 1,
514 },
515 {
516 .type = EV_KEY,
517 .code = TOSA_KEY_RECORD,
518 .gpio = TOSA_GPIO_RECORD_BTN,
519 .desc = "Record Button",
520 .wakeup = 1,
521 .active_low = 1,
522 },
523 {
524 .type = EV_KEY,
525 .code = TOSA_KEY_SYNC,
526 .gpio = TOSA_GPIO_SYNC,
527 .desc = "Sync Button",
528 .wakeup = 1,
529 .active_low = 1,
530 },
531};
532
533static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
534 .buttons = tosa_gpio_keys,
535 .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
536};
537
538static struct platform_device tosa_gpio_keys_device = {
539 .name = "gpio-keys",
540 .id = -1,
541 .dev = {
542 .platform_data = &tosa_gpio_keys_platform_data,
543 },
544};
545
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800546/*
547 * Tosa LEDs
548 */
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100549static struct gpio_led tosa_gpio_leds[] = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100550 {
551 .name = "tosa:amber:charge",
552 .default_trigger = "main-battery-charging",
553 .gpio = TOSA_GPIO_CHRG_ERR_LED,
554 },
555 {
556 .name = "tosa:green:mail",
557 .default_trigger = "nand-disk",
558 .gpio = TOSA_GPIO_NOTE_LED,
559 },
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100560 {
561 .name = "tosa:dual:wlan",
562 .default_trigger = "none",
563 .gpio = TOSA_GPIO_WLAN_LED,
564 },
565 {
566 .name = "tosa:blue:bluetooth",
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100567 .default_trigger = "tosa-bt",
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100568 .gpio = TOSA_GPIO_BT_LED,
569 },
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100570};
571
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100572static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100573 .leds = tosa_gpio_leds,
574 .num_leds = ARRAY_SIZE(tosa_gpio_leds),
575};
576
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800577static struct platform_device tosaled_device = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100578 .name = "leds-gpio",
579 .id = -1,
580 .dev = {
581 .platform_data = &tosa_gpio_leds_platform_data,
582 },
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800583};
584
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100585/*
586 * Toshiba Mobile IO Controller
587 */
588static struct resource tc6393xb_resources[] = {
589 [0] = {
590 .start = TOSA_LCDC_PHYS,
591 .end = TOSA_LCDC_PHYS + 0x3ffffff,
592 .flags = IORESOURCE_MEM,
593 },
594
595 [1] = {
596 .start = TOSA_IRQ_GPIO_TC6393XB_INT,
597 .end = TOSA_IRQ_GPIO_TC6393XB_INT,
598 .flags = IORESOURCE_IRQ,
599 },
600};
601
602
603static int tosa_tc6393xb_enable(struct platform_device *dev)
604{
605 int rc;
606
607 rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
608 if (rc)
609 goto err_req_pclr;
610 rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
611 if (rc)
612 goto err_req_suspend;
613 rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "l3v");
614 if (rc)
615 goto err_req_l3v;
616 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
617 if (rc)
618 goto err_dir_l3v;
619 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
620 if (rc)
621 goto err_dir_suspend;
622 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
623 if (rc)
624 goto err_dir_pclr;
625
626 mdelay(1);
627
628 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
629
630 mdelay(10);
631
632 gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
633 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
634
635 return 0;
636err_dir_pclr:
637err_dir_suspend:
638err_dir_l3v:
639 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
640err_req_l3v:
641 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
642err_req_suspend:
643 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
644err_req_pclr:
645 return rc;
646}
647
648static int tosa_tc6393xb_disable(struct platform_device *dev)
649{
650 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
651 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
652 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
653
654 return 0;
655}
656
657static int tosa_tc6393xb_resume(struct platform_device *dev)
658{
659 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
660 mdelay(10);
661 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
662 mdelay(10);
663
664 return 0;
665}
666
667static int tosa_tc6393xb_suspend(struct platform_device *dev)
668{
669 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
670 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
671 return 0;
672}
673
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100674static struct mtd_partition tosa_nand_partition[] = {
675 {
676 .name = "smf",
677 .offset = 0,
678 .size = 7 * 1024 * 1024,
679 },
680 {
681 .name = "root",
682 .offset = MTDPART_OFS_APPEND,
683 .size = 28 * 1024 * 1024,
684 },
685 {
686 .name = "home",
687 .offset = MTDPART_OFS_APPEND,
688 .size = MTDPART_SIZ_FULL,
689 },
690};
691
692static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
693
694static struct nand_bbt_descr tosa_tc6393xb_nand_bbt = {
695 .options = 0,
696 .offs = 4,
697 .len = 2,
698 .pattern = scan_ff_pattern
699};
700
701static struct tmio_nand_data tosa_tc6393xb_nand_config = {
702 .num_partitions = ARRAY_SIZE(tosa_nand_partition),
703 .partition = tosa_nand_partition,
704 .badblock_pattern = &tosa_tc6393xb_nand_bbt,
705};
706
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100707static struct tc6393xb_platform_data tosa_tc6393xb_setup = {
708 .scr_pll2cr = 0x0cc1,
709 .scr_gper = 0x3300,
710 .scr_gpo_dsr =
711 TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
712 .scr_gpo_doecr =
713 TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
714
715 .irq_base = IRQ_BOARD_START,
716 .gpio_base = TOSA_TC6393XB_GPIO_BASE,
717
718 .enable = tosa_tc6393xb_enable,
719 .disable = tosa_tc6393xb_disable,
720 .suspend = tosa_tc6393xb_suspend,
721 .resume = tosa_tc6393xb_resume,
Dmitry Baryshkov5289fec2008-06-27 10:38:44 +0100722
723 .nand_data = &tosa_tc6393xb_nand_config,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100724};
725
726
727static struct platform_device tc6393xb_device = {
728 .name = "tc6393xb",
729 .id = -1,
730 .dev = {
731 .platform_data = &tosa_tc6393xb_setup,
732 },
733 .num_resources = ARRAY_SIZE(tc6393xb_resources),
734 .resource = tc6393xb_resources,
735};
736
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100737static struct tosa_bt_data tosa_bt_data = {
738 .gpio_pwr = TOSA_GPIO_BT_PWR_EN,
739 .gpio_reset = TOSA_GPIO_BT_RESET,
740};
741
742static struct platform_device tosa_bt_device = {
743 .name = "tosa-bt",
744 .id = -1,
745 .dev.platform_data = &tosa_bt_data,
746};
747
748
Dirk Opfer8459c152005-11-06 14:27:52 +0000749static struct platform_device *devices[] __initdata = {
750 &tosascoop_device,
751 &tosascoop_jc_device,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100752 &tc6393xb_device,
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100753 &tosa_power_device,
Dirk Opfera93876c2005-11-08 19:15:30 +0000754 &tosakbd_device,
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500755 &tosa_gpio_keys_device,
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800756 &tosaled_device,
Dmitry Baryshkov16b32fd2008-07-05 09:02:48 +0100757 &tosa_bt_device,
Dirk Opfer8459c152005-11-06 14:27:52 +0000758};
759
Richard Purdie74617fb2006-06-19 19:57:12 +0100760static void tosa_poweroff(void)
761{
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100762 arm_machine_restart('g');
Richard Purdie74617fb2006-06-19 19:57:12 +0100763}
764
765static void tosa_restart(char mode)
766{
767 /* Bootloader magic for a reboot */
768 if((MSC0 & 0xffff0000) == 0x7ff00000)
769 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
770
771 tosa_poweroff();
772}
773
Dirk Opfer8459c152005-11-06 14:27:52 +0000774static void __init tosa_init(void)
775{
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100776 int dummy;
777
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100778 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100779 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_off));
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100780 gpio_set_wake(MFP_PIN_GPIO1, 1);
781 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
782
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100783 init_gpio_reset(TOSA_GPIO_ON_RESET);
784
Richard Purdie74617fb2006-06-19 19:57:12 +0100785 pm_power_off = tosa_poweroff;
786 arm_pm_restart = tosa_restart;
787
Dirk Opfer8459c152005-11-06 14:27:52 +0000788 PCFR |= PCFR_OPDE;
789
Dirk Opfera93876c2005-11-08 19:15:30 +0000790 /* enable batt_fault */
Dirk Opfer8459c152005-11-06 14:27:52 +0000791 PMCR = 0x01;
792
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100793 dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
794 dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
795 dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
796
Dirk Opfera93876c2005-11-08 19:15:30 +0000797 pxa_set_mci_info(&tosa_mci_platform_data);
798 pxa_set_udc_info(&udc_info);
799 pxa_set_ficp_info(&tosa_ficp_platform_data);
Dmitry Baryshkov481ea5a2008-04-10 15:43:18 +0100800 pxa_set_i2c_info(NULL);
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000801 platform_scoop_config = &tosa_pcmcia_config;
Dirk Opfer8459c152005-11-06 14:27:52 +0000802
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000803 platform_add_devices(devices, ARRAY_SIZE(devices));
Dirk Opfer8459c152005-11-06 14:27:52 +0000804}
805
806static void __init fixup_tosa(struct machine_desc *desc,
807 struct tag *tags, char **cmdline, struct meminfo *mi)
808{
809 sharpsl_save_param();
810 mi->nr_banks=1;
811 mi->bank[0].start = 0xa0000000;
812 mi->bank[0].node = 0;
813 mi->bank[0].size = (64*1024*1024);
814}
815
816MACHINE_START(TOSA, "SHARP Tosa")
Dirk Opfer8459c152005-11-06 14:27:52 +0000817 .phys_io = 0x40000000,
818 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
819 .fixup = fixup_tosa,
820 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100821 .init_irq = pxa25x_init_irq,
Dirk Opfer8459c152005-11-06 14:27:52 +0000822 .init_machine = tosa_init,
823 .timer = &pxa_timer,
824MACHINE_END