blob: f3b12d2897a63796934310e34de8e4f50c773883 [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>
Richard Purdie74617fb2006-06-19 19:57:12 +010025#include <linux/pm.h>
Russell King905f1462006-06-20 23:27:37 +010026#include <linux/delay.h>
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -050027#include <linux/gpio_keys.h>
28#include <linux/input.h>
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +010029#include <linux/gpio.h>
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +010030#include <linux/pda_power.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000031
32#include <asm/setup.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000033#include <asm/mach-types.h>
eric miaobb548dd2008-01-30 09:39:48 +010034#include <asm/arch/pxa2xx-regs.h>
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010035#include <asm/arch/mfp-pxa25x.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000036#include <asm/arch/irda.h>
Dmitry Baryshkov481ea5a2008-04-10 15:43:18 +010037#include <asm/arch/i2c.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000038#include <asm/arch/mmc.h>
39#include <asm/arch/udc.h>
40
41#include <asm/mach/arch.h>
Dirk Opfer8459c152005-11-06 14:27:52 +000042#include <asm/arch/tosa.h>
43
44#include <asm/hardware/scoop.h>
45#include <asm/mach/sharpsl_param.h>
46
47#include "generic.h"
Russell King46c41e62007-05-15 15:39:36 +010048#include "devices.h"
Dirk Opfer8459c152005-11-06 14:27:52 +000049
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010050static unsigned long tosa_pin_config[] = {
51 GPIO78_nCS_2, /* Scoop */
52 GPIO80_nCS_4, /* tg6393xb */
53 GPIO33_nCS_5, /* Scoop */
54
55 // GPIO76 CARD_VCC_ON1
56
57 GPIO19_GPIO, /* Reset out */
58 GPIO1_RST | WAKEUP_ON_EDGE_FALL,
59
60 GPIO0_GPIO | WAKEUP_ON_EDGE_FALL, /* WAKE_UP */
61 GPIO2_GPIO | WAKEUP_ON_EDGE_BOTH, /* AC_IN */
62 GPIO3_GPIO | WAKEUP_ON_EDGE_FALL, /* RECORD */
63 GPIO4_GPIO | WAKEUP_ON_EDGE_FALL, /* SYNC */
64 GPIO20_GPIO, /* EAR_IN */
65 GPIO22_GPIO, /* On */
66
67 GPIO5_GPIO, /* USB_IN */
68 GPIO32_GPIO, /* Pen IRQ */
69
70 GPIO7_GPIO, /* Jacket Detect */
71 GPIO14_GPIO, /* BAT0_CRG */
72 GPIO12_GPIO, /* BAT1_CRG */
73 GPIO17_GPIO, /* BAT0_LOW */
74 GPIO84_GPIO, /* BAT1_LOW */
75 GPIO38_GPIO, /* BAT_LOCK */
76
77 GPIO11_3_6MHz,
78 GPIO15_GPIO, /* TC6393XB IRQ */
79 GPIO18_RDY,
80 GPIO27_GPIO, /* LCD Sync */
81
82 /* MMC */
83 GPIO6_MMC_CLK,
84 GPIO8_MMC_CS0,
85 GPIO9_GPIO, /* Detect */
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +010086 GPIO10_GPIO, /* nSD_INT */
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +010087
88 /* CF */
89 GPIO13_GPIO, /* CD_IRQ */
90 GPIO21_GPIO, /* Main Slot IRQ */
91 GPIO36_GPIO, /* Jacket Slot IRQ */
92 GPIO48_nPOE,
93 GPIO49_nPWE,
94 GPIO50_nPIOR,
95 GPIO51_nPIOW,
96 GPIO52_nPCE_1,
97 GPIO53_nPCE_2,
98 GPIO54_nPSKTSEL,
99 GPIO55_nPREG,
100 GPIO56_nPWAIT,
101 GPIO57_nIOIS16,
102
103 /* AC97 */
104 GPIO31_AC97_SYNC,
105 GPIO30_AC97_SDATA_OUT,
106 GPIO28_AC97_BITCLK,
107 GPIO29_AC97_SDATA_IN_0,
108 // GPIO79 nAUD_IRQ
109
110 /* FFUART */
111 GPIO34_FFUART_RXD,
112 GPIO35_FFUART_CTS,
113 GPIO37_FFUART_DSR,
114 GPIO39_FFUART_TXD,
115 GPIO40_FFUART_DTR,
116 GPIO41_FFUART_RTS,
117
118 /* BTUART */
119 GPIO42_BTUART_RXD,
120 GPIO43_BTUART_TXD,
121 GPIO44_BTUART_CTS,
122 GPIO45_BTUART_RTS,
123
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100124 /* Keybd */
eric miaoc8671552008-05-26 03:28:50 +0100125 GPIO58_GPIO | MFP_LPM_DRIVE_LOW,
126 GPIO59_GPIO | MFP_LPM_DRIVE_LOW,
127 GPIO60_GPIO | MFP_LPM_DRIVE_LOW,
128 GPIO61_GPIO | MFP_LPM_DRIVE_LOW,
129 GPIO62_GPIO | MFP_LPM_DRIVE_LOW,
130 GPIO63_GPIO | MFP_LPM_DRIVE_LOW,
131 GPIO64_GPIO | MFP_LPM_DRIVE_LOW,
132 GPIO65_GPIO | MFP_LPM_DRIVE_LOW,
133 GPIO66_GPIO | MFP_LPM_DRIVE_LOW,
134 GPIO67_GPIO | MFP_LPM_DRIVE_LOW,
135 GPIO68_GPIO | MFP_LPM_DRIVE_LOW,
136 GPIO69_GPIO | MFP_LPM_DRIVE_LOW,
137 GPIO70_GPIO | MFP_LPM_DRIVE_LOW,
138 GPIO71_GPIO | MFP_LPM_DRIVE_LOW,
139 GPIO72_GPIO | MFP_LPM_DRIVE_LOW,
140 GPIO73_GPIO | MFP_LPM_DRIVE_LOW,
141 GPIO74_GPIO | MFP_LPM_DRIVE_LOW,
142 GPIO75_GPIO | MFP_LPM_DRIVE_LOW,
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100143
144 /* SPI */
145 GPIO81_SSP2_CLK_OUT,
146 GPIO82_SSP2_FRM_OUT,
147 GPIO83_SSP2_TXD,
148};
149
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100150static unsigned long tosa_pin_irda_off[] = {
151 GPIO46_STUART_RXD,
152 GPIO47_GPIO | MFP_LPM_DRIVE_LOW,
153};
154
155static unsigned long tosa_pin_irda_on[] = {
156 GPIO46_STUART_RXD,
157 GPIO47_STUART_TXD,
158};
159
160
Dirk Opfer8459c152005-11-06 14:27:52 +0000161/*
162 * SCOOP Device
163 */
164static struct resource tosa_scoop_resources[] = {
165 [0] = {
166 .start = TOSA_CF_PHYS,
167 .end = TOSA_CF_PHYS + 0xfff,
168 .flags = IORESOURCE_MEM,
169 },
170};
171
172static struct scoop_config tosa_scoop_setup = {
173 .io_dir = TOSA_SCOOP_IO_DIR,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100174 .gpio_base = TOSA_SCOOP_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000175};
176
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100177static struct platform_device tosascoop_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000178 .name = "sharp-scoop",
179 .id = 0,
180 .dev = {
181 .platform_data = &tosa_scoop_setup,
182 },
183 .num_resources = ARRAY_SIZE(tosa_scoop_resources),
184 .resource = tosa_scoop_resources,
185};
186
187
188/*
189 * SCOOP Device Jacket
190 */
191static struct resource tosa_scoop_jc_resources[] = {
192 [0] = {
193 .start = TOSA_SCOOP_PHYS + 0x40,
194 .end = TOSA_SCOOP_PHYS + 0xfff,
195 .flags = IORESOURCE_MEM,
196 },
197};
198
199static struct scoop_config tosa_scoop_jc_setup = {
200 .io_dir = TOSA_SCOOP_JC_IO_DIR,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100201 .gpio_base = TOSA_SCOOP_JC_GPIO_BASE,
Dirk Opfer8459c152005-11-06 14:27:52 +0000202};
203
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100204static struct platform_device tosascoop_jc_device = {
Dirk Opfer8459c152005-11-06 14:27:52 +0000205 .name = "sharp-scoop",
206 .id = 1,
207 .dev = {
208 .platform_data = &tosa_scoop_jc_setup,
209 .parent = &tosascoop_device.dev,
210 },
211 .num_resources = ARRAY_SIZE(tosa_scoop_jc_resources),
212 .resource = tosa_scoop_jc_resources,
213};
214
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000215/*
216 * PCMCIA
217 */
Dirk Opfer8459c152005-11-06 14:27:52 +0000218static struct scoop_pcmcia_dev tosa_pcmcia_scoop[] = {
219{
220 .dev = &tosascoop_device.dev,
221 .irq = TOSA_IRQ_GPIO_CF_IRQ,
222 .cd_irq = TOSA_IRQ_GPIO_CF_CD,
223 .cd_irq_str = "PCMCIA0 CD",
224},{
225 .dev = &tosascoop_jc_device.dev,
226 .irq = TOSA_IRQ_GPIO_JC_CF_IRQ,
227 .cd_irq = -1,
228},
229};
230
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000231static struct scoop_pcmcia_config tosa_pcmcia_config = {
232 .devs = &tosa_pcmcia_scoop[0],
233 .num_devs = 2,
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000234};
235
Dirk Opfera93876c2005-11-08 19:15:30 +0000236/*
237 * USB Device Controller
238 */
Dirk Opfera93876c2005-11-08 19:15:30 +0000239static struct pxa2xx_udc_mach_info udc_info __initdata = {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100240 .gpio_pullup = TOSA_GPIO_USB_PULLUP,
Dmitry Baryshkov487dc922007-12-21 12:18:01 +0300241 .gpio_vbus = TOSA_GPIO_USB_IN,
242 .gpio_vbus_inverted = 1,
Dirk Opfera93876c2005-11-08 19:15:30 +0000243};
244
245/*
246 * MMC/SD Device
247 */
248static struct pxamci_platform_data tosa_mci_platform_data;
249
David Howells40220c12006-10-09 12:19:47 +0100250static int tosa_mci_init(struct device *dev, irq_handler_t tosa_detect_int, void *data)
Dirk Opfera93876c2005-11-08 19:15:30 +0000251{
252 int err;
253
Dirk Opfera93876c2005-11-08 19:15:30 +0000254 tosa_mci_platform_data.detect_delay = msecs_to_jiffies(250);
255
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100256 err = gpio_request(TOSA_GPIO_nSD_DETECT, "MMC/SD card detect");
257 if (err) {
258 printk(KERN_ERR "tosa_mci_init: can't request nSD_DETECT gpio\n");
259 goto err_gpio_detect;
260 }
261 err = gpio_direction_input(TOSA_GPIO_nSD_DETECT);
262 if (err)
263 goto err_gpio_detect_dir;
264
Russell King2687bd32008-01-23 14:05:58 +0000265 err = request_irq(TOSA_IRQ_GPIO_nSD_DETECT, tosa_detect_int,
266 IRQF_DISABLED | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
Dirk Opfera93876c2005-11-08 19:15:30 +0000267 "MMC/SD card detect", data);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100268 if (err) {
Dirk Opfera93876c2005-11-08 19:15:30 +0000269 printk(KERN_ERR "tosa_mci_init: MMC/SD: can't request MMC card detect IRQ\n");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100270 goto err_irq;
271 }
Dirk Opfera93876c2005-11-08 19:15:30 +0000272
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100273 err = gpio_request(TOSA_GPIO_SD_WP, "SD Write Protect");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100274 if (err) {
275 printk(KERN_ERR "tosa_mci_init: can't request SD_WP gpio\n");
276 goto err_gpio_wp;
277 }
278 err = gpio_direction_input(TOSA_GPIO_SD_WP);
279 if (err)
280 goto err_gpio_wp_dir;
281
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100282 err = gpio_request(TOSA_GPIO_PWR_ON, "SD Power");
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100283 if (err) {
284 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
285 goto err_gpio_pwr;
286 }
287 err = gpio_direction_output(TOSA_GPIO_PWR_ON, 0);
288 if (err)
289 goto err_gpio_pwr_dir;
290
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100291 err = gpio_request(TOSA_GPIO_nSD_INT, "SD Int");
292 if (err) {
293 printk(KERN_ERR "tosa_mci_init: can't request SD_PWR gpio\n");
294 goto err_gpio_int;
295 }
296 err = gpio_direction_input(TOSA_GPIO_nSD_INT);
297 if (err)
298 goto err_gpio_int_dir;
299
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100300 return 0;
301
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100302err_gpio_int_dir:
303 gpio_free(TOSA_GPIO_nSD_INT);
304err_gpio_int:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100305err_gpio_pwr_dir:
306 gpio_free(TOSA_GPIO_PWR_ON);
307err_gpio_pwr:
308err_gpio_wp_dir:
309 gpio_free(TOSA_GPIO_SD_WP);
310err_gpio_wp:
311 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
312err_irq:
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100313err_gpio_detect_dir:
314 gpio_free(TOSA_GPIO_nSD_DETECT);
315err_gpio_detect:
Russell King2687bd32008-01-23 14:05:58 +0000316 return err;
Dirk Opfera93876c2005-11-08 19:15:30 +0000317}
318
319static void tosa_mci_setpower(struct device *dev, unsigned int vdd)
320{
321 struct pxamci_platform_data* p_d = dev->platform_data;
322
323 if (( 1 << vdd) & p_d->ocr_mask) {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100324 gpio_set_value(TOSA_GPIO_PWR_ON, 1);
Dirk Opfera93876c2005-11-08 19:15:30 +0000325 } else {
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100326 gpio_set_value(TOSA_GPIO_PWR_ON, 0);
Dirk Opfera93876c2005-11-08 19:15:30 +0000327 }
328}
329
330static int tosa_mci_get_ro(struct device *dev)
331{
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100332 return gpio_get_value(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000333}
334
335static void tosa_mci_exit(struct device *dev, void *data)
336{
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100337 gpio_free(TOSA_GPIO_nSD_INT);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100338 gpio_free(TOSA_GPIO_PWR_ON);
339 gpio_free(TOSA_GPIO_SD_WP);
Dirk Opfera93876c2005-11-08 19:15:30 +0000340 free_irq(TOSA_IRQ_GPIO_nSD_DETECT, data);
Dmitry Baryshkovc4d5f8d2008-06-09 13:23:50 +0100341 gpio_free(TOSA_GPIO_nSD_DETECT);
Dirk Opfera93876c2005-11-08 19:15:30 +0000342}
343
344static struct pxamci_platform_data tosa_mci_platform_data = {
345 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
346 .init = tosa_mci_init,
347 .get_ro = tosa_mci_get_ro,
348 .setpower = tosa_mci_setpower,
349 .exit = tosa_mci_exit,
350};
351
352/*
353 * Irda
354 */
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100355static void tosa_irda_transceiver_mode(struct device *dev, int mode)
356{
357 if (mode & IR_OFF) {
358 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 0);
359 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_off));
360 gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
361 } else {
362 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_on));
363 gpio_set_value(TOSA_GPIO_IR_POWERDWN, 1);
364 }
365}
366
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100367static int tosa_irda_startup(struct device *dev)
368{
369 int ret;
370
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100371 ret = gpio_request(TOSA_GPIO_IRDA_TX, "IrDA TX");
372 if (ret)
373 goto err_tx;
374 ret = gpio_direction_output(TOSA_GPIO_IRDA_TX, 0);
375 if (ret)
376 goto err_tx_dir;
377
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100378 ret = gpio_request(TOSA_GPIO_IR_POWERDWN, "IrDA powerdown");
379 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100380 goto err_pwr;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100381
382 ret = gpio_direction_output(TOSA_GPIO_IR_POWERDWN, 0);
383 if (ret)
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100384 goto err_pwr_dir;
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100385
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100386 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
387
388 return 0;
389
390err_pwr_dir:
391 gpio_free(TOSA_GPIO_IR_POWERDWN);
392err_pwr:
393err_tx_dir:
394 gpio_free(TOSA_GPIO_IRDA_TX);
395err_tx:
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100396 return ret;
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100397}
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100398
399static void tosa_irda_shutdown(struct device *dev)
400{
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100401 tosa_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100402 gpio_free(TOSA_GPIO_IR_POWERDWN);
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100403 gpio_free(TOSA_GPIO_IRDA_TX);
Dirk Opfera93876c2005-11-08 19:15:30 +0000404}
405
406static struct pxaficp_platform_data tosa_ficp_platform_data = {
407 .transceiver_cap = IR_SIRMODE | IR_OFF,
408 .transceiver_mode = tosa_irda_transceiver_mode,
Dmitry Baryshkovd4e7d092008-04-12 20:16:16 +0100409 .startup = tosa_irda_startup,
410 .shutdown = tosa_irda_shutdown,
Dirk Opfera93876c2005-11-08 19:15:30 +0000411};
412
413/*
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100414 * Tosa AC IN
415 */
416static int tosa_power_init(struct device *dev)
417{
418 int ret = gpio_request(TOSA_GPIO_AC_IN, "ac in");
419 if (ret)
420 goto err_gpio_req;
421
422 ret = gpio_direction_input(TOSA_GPIO_AC_IN);
423 if (ret)
424 goto err_gpio_in;
425
426 return 0;
427
428err_gpio_in:
429 gpio_free(TOSA_GPIO_AC_IN);
430err_gpio_req:
431 return ret;
432}
433
434static void tosa_power_exit(struct device *dev)
435{
436 gpio_free(TOSA_GPIO_AC_IN);
437}
438
439static int tosa_power_ac_online(void)
440{
441 return gpio_get_value(TOSA_GPIO_AC_IN) == 0;
442}
443
444static char *tosa_ac_supplied_to[] = {
445 "main-battery",
446 "backup-battery",
447 "jacket-battery",
448};
449
450static struct pda_power_pdata tosa_power_data = {
451 .init = tosa_power_init,
452 .is_ac_online = tosa_power_ac_online,
453 .exit = tosa_power_exit,
454 .supplied_to = tosa_ac_supplied_to,
455 .num_supplicants = ARRAY_SIZE(tosa_ac_supplied_to),
456};
457
458static struct resource tosa_power_resource[] = {
459 {
460 .name = "ac",
461 .start = gpio_to_irq(TOSA_GPIO_AC_IN),
462 .end = gpio_to_irq(TOSA_GPIO_AC_IN),
463 .flags = IORESOURCE_IRQ |
464 IORESOURCE_IRQ_HIGHEDGE |
465 IORESOURCE_IRQ_LOWEDGE,
466 },
467};
468
469static struct platform_device tosa_power_device = {
470 .name = "pda-power",
471 .id = -1,
472 .dev.platform_data = &tosa_power_data,
473 .resource = tosa_power_resource,
474 .num_resources = ARRAY_SIZE(tosa_power_resource),
475};
476
477/*
Dirk Opfera93876c2005-11-08 19:15:30 +0000478 * Tosa Keyboard
479 */
480static struct platform_device tosakbd_device = {
481 .name = "tosa-keyboard",
482 .id = -1,
483};
Dirk Opfer8459c152005-11-06 14:27:52 +0000484
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500485static struct gpio_keys_button tosa_gpio_keys[] = {
Dmitry Baryshkov0aa975612008-04-12 20:02:50 +0100486 /*
487 * Two following keys are directly tied to "ON" button of tosa. Why?
488 * The first one can be used as a wakeup source, the second can't;
489 * also the first one is OR of ac_powered and on_button.
490 */
491 {
492 .type = EV_PWR,
493 .code = KEY_RESERVED,
494 .gpio = TOSA_GPIO_POWERON,
495 .desc = "Poweron",
496 .wakeup = 1,
497 .active_low = 1,
498 },
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500499 {
500 .type = EV_PWR,
501 .code = KEY_SUSPEND,
502 .gpio = TOSA_GPIO_ON_KEY,
503 .desc = "On key",
Dmitry Baryshkov0aa975612008-04-12 20:02:50 +0100504 /*
505 * can't be used as wakeup
506 * .wakeup = 1,
507 */
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500508 .active_low = 1,
509 },
510 {
511 .type = EV_KEY,
512 .code = TOSA_KEY_RECORD,
513 .gpio = TOSA_GPIO_RECORD_BTN,
514 .desc = "Record Button",
515 .wakeup = 1,
516 .active_low = 1,
517 },
518 {
519 .type = EV_KEY,
520 .code = TOSA_KEY_SYNC,
521 .gpio = TOSA_GPIO_SYNC,
522 .desc = "Sync Button",
523 .wakeup = 1,
524 .active_low = 1,
525 },
526};
527
528static struct gpio_keys_platform_data tosa_gpio_keys_platform_data = {
529 .buttons = tosa_gpio_keys,
530 .nbuttons = ARRAY_SIZE(tosa_gpio_keys),
531};
532
533static struct platform_device tosa_gpio_keys_device = {
534 .name = "gpio-keys",
535 .id = -1,
536 .dev = {
537 .platform_data = &tosa_gpio_keys_platform_data,
538 },
539};
540
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800541/*
542 * Tosa LEDs
543 */
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100544static struct gpio_led tosa_gpio_leds[] = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100545 {
546 .name = "tosa:amber:charge",
547 .default_trigger = "main-battery-charging",
548 .gpio = TOSA_GPIO_CHRG_ERR_LED,
549 },
550 {
551 .name = "tosa:green:mail",
552 .default_trigger = "nand-disk",
553 .gpio = TOSA_GPIO_NOTE_LED,
554 },
Dmitry Baryshkovc5461062008-04-19 10:42:06 +0100555 {
556 .name = "tosa:dual:wlan",
557 .default_trigger = "none",
558 .gpio = TOSA_GPIO_WLAN_LED,
559 },
560 {
561 .name = "tosa:blue:bluetooth",
562 .default_trigger = "none",
563 .gpio = TOSA_GPIO_BT_LED,
564 },
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100565};
566
Dmitry Baryshkovba4eb7e2008-04-19 10:42:25 +0100567static struct gpio_led_platform_data tosa_gpio_leds_platform_data = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100568 .leds = tosa_gpio_leds,
569 .num_leds = ARRAY_SIZE(tosa_gpio_leds),
570};
571
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800572static struct platform_device tosaled_device = {
Dmitry Baryshkov311c7362008-04-12 20:17:02 +0100573 .name = "leds-gpio",
574 .id = -1,
575 .dev = {
576 .platform_data = &tosa_gpio_leds_platform_data,
577 },
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800578};
579
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100580/*
581 * Toshiba Mobile IO Controller
582 */
583static struct resource tc6393xb_resources[] = {
584 [0] = {
585 .start = TOSA_LCDC_PHYS,
586 .end = TOSA_LCDC_PHYS + 0x3ffffff,
587 .flags = IORESOURCE_MEM,
588 },
589
590 [1] = {
591 .start = TOSA_IRQ_GPIO_TC6393XB_INT,
592 .end = TOSA_IRQ_GPIO_TC6393XB_INT,
593 .flags = IORESOURCE_IRQ,
594 },
595};
596
597
598static int tosa_tc6393xb_enable(struct platform_device *dev)
599{
600 int rc;
601
602 rc = gpio_request(TOSA_GPIO_TC6393XB_REST_IN, "tc6393xb #pclr");
603 if (rc)
604 goto err_req_pclr;
605 rc = gpio_request(TOSA_GPIO_TC6393XB_SUSPEND, "tc6393xb #suspend");
606 if (rc)
607 goto err_req_suspend;
608 rc = gpio_request(TOSA_GPIO_TC6393XB_L3V_ON, "l3v");
609 if (rc)
610 goto err_req_l3v;
611 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_L3V_ON, 0);
612 if (rc)
613 goto err_dir_l3v;
614 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_SUSPEND, 0);
615 if (rc)
616 goto err_dir_suspend;
617 rc = gpio_direction_output(TOSA_GPIO_TC6393XB_REST_IN, 0);
618 if (rc)
619 goto err_dir_pclr;
620
621 mdelay(1);
622
623 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
624
625 mdelay(10);
626
627 gpio_set_value(TOSA_GPIO_TC6393XB_REST_IN, 1);
628 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
629
630 return 0;
631err_dir_pclr:
632err_dir_suspend:
633err_dir_l3v:
634 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
635err_req_l3v:
636 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
637err_req_suspend:
638 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
639err_req_pclr:
640 return rc;
641}
642
643static int tosa_tc6393xb_disable(struct platform_device *dev)
644{
645 gpio_free(TOSA_GPIO_TC6393XB_L3V_ON);
646 gpio_free(TOSA_GPIO_TC6393XB_SUSPEND);
647 gpio_free(TOSA_GPIO_TC6393XB_REST_IN);
648
649 return 0;
650}
651
652static int tosa_tc6393xb_resume(struct platform_device *dev)
653{
654 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 1);
655 mdelay(10);
656 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 1);
657 mdelay(10);
658
659 return 0;
660}
661
662static int tosa_tc6393xb_suspend(struct platform_device *dev)
663{
664 gpio_set_value(TOSA_GPIO_TC6393XB_L3V_ON, 0);
665 gpio_set_value(TOSA_GPIO_TC6393XB_SUSPEND, 0);
666 return 0;
667}
668
669static struct tc6393xb_platform_data tosa_tc6393xb_setup = {
670 .scr_pll2cr = 0x0cc1,
671 .scr_gper = 0x3300,
672 .scr_gpo_dsr =
673 TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
674 .scr_gpo_doecr =
675 TOSA_TC6393XB_GPIO_BIT(TOSA_GPIO_CARD_VCC_ON),
676
677 .irq_base = IRQ_BOARD_START,
678 .gpio_base = TOSA_TC6393XB_GPIO_BASE,
679
680 .enable = tosa_tc6393xb_enable,
681 .disable = tosa_tc6393xb_disable,
682 .suspend = tosa_tc6393xb_suspend,
683 .resume = tosa_tc6393xb_resume,
684};
685
686
687static struct platform_device tc6393xb_device = {
688 .name = "tc6393xb",
689 .id = -1,
690 .dev = {
691 .platform_data = &tosa_tc6393xb_setup,
692 },
693 .num_resources = ARRAY_SIZE(tc6393xb_resources),
694 .resource = tc6393xb_resources,
695};
696
Dirk Opfer8459c152005-11-06 14:27:52 +0000697static struct platform_device *devices[] __initdata = {
698 &tosascoop_device,
699 &tosascoop_jc_device,
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100700 &tc6393xb_device,
Dmitry Baryshkov53b14ea2008-06-14 11:43:36 +0100701 &tosa_power_device,
Dirk Opfera93876c2005-11-08 19:15:30 +0000702 &tosakbd_device,
Dmitry Baryshkov93e9012f2008-01-21 01:04:20 -0500703 &tosa_gpio_keys_device,
Dirk Opfer6d0cf3e2006-03-31 02:31:12 -0800704 &tosaled_device,
Dirk Opfer8459c152005-11-06 14:27:52 +0000705};
706
Richard Purdie74617fb2006-06-19 19:57:12 +0100707static void tosa_poweroff(void)
708{
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100709 arm_machine_restart('g');
Richard Purdie74617fb2006-06-19 19:57:12 +0100710}
711
712static void tosa_restart(char mode)
713{
714 /* Bootloader magic for a reboot */
715 if((MSC0 & 0xffff0000) == 0x7ff00000)
716 MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
717
718 tosa_poweroff();
719}
720
Dirk Opfer8459c152005-11-06 14:27:52 +0000721static void __init tosa_init(void)
722{
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100723 int dummy;
724
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100725 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_config));
Dmitry Baryshkovb032fcc2008-06-12 11:42:07 +0100726 pxa2xx_mfp_config(ARRAY_AND_SIZE(tosa_pin_irda_off));
Dmitry Baryshkov2cb47342008-04-10 11:00:32 +0100727 gpio_set_wake(MFP_PIN_GPIO1, 1);
728 /* We can't pass to gpio-keys since it will drop the Reset altfunc */
729
Dmitry Baryshkov86159a92008-05-22 16:21:48 +0100730 init_gpio_reset(TOSA_GPIO_ON_RESET);
731
Richard Purdie74617fb2006-06-19 19:57:12 +0100732 pm_power_off = tosa_poweroff;
733 arm_pm_restart = tosa_restart;
734
Dirk Opfer8459c152005-11-06 14:27:52 +0000735 PCFR |= PCFR_OPDE;
736
Dirk Opfera93876c2005-11-08 19:15:30 +0000737 /* enable batt_fault */
Dirk Opfer8459c152005-11-06 14:27:52 +0000738 PMCR = 0x01;
739
Dmitry Baryshkovbf0116e2008-06-14 11:42:02 +0100740 dummy = gpiochip_reserve(TOSA_SCOOP_GPIO_BASE, 12);
741 dummy = gpiochip_reserve(TOSA_SCOOP_JC_GPIO_BASE, 12);
742 dummy = gpiochip_reserve(TOSA_TC6393XB_GPIO_BASE, 16);
743
Dirk Opfera93876c2005-11-08 19:15:30 +0000744 pxa_set_mci_info(&tosa_mci_platform_data);
745 pxa_set_udc_info(&udc_info);
746 pxa_set_ficp_info(&tosa_ficp_platform_data);
Dmitry Baryshkov481ea5a2008-04-10 15:43:18 +0100747 pxa_set_i2c_info(NULL);
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000748 platform_scoop_config = &tosa_pcmcia_config;
Dirk Opfer8459c152005-11-06 14:27:52 +0000749
Dirk Opfer4c18ad22005-11-08 19:15:50 +0000750 platform_add_devices(devices, ARRAY_SIZE(devices));
Dirk Opfer8459c152005-11-06 14:27:52 +0000751}
752
753static void __init fixup_tosa(struct machine_desc *desc,
754 struct tag *tags, char **cmdline, struct meminfo *mi)
755{
756 sharpsl_save_param();
757 mi->nr_banks=1;
758 mi->bank[0].start = 0xa0000000;
759 mi->bank[0].node = 0;
760 mi->bank[0].size = (64*1024*1024);
761}
762
763MACHINE_START(TOSA, "SHARP Tosa")
Dirk Opfer8459c152005-11-06 14:27:52 +0000764 .phys_io = 0x40000000,
765 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
766 .fixup = fixup_tosa,
767 .map_io = pxa_map_io,
Eric Miaocd491042007-06-22 04:14:09 +0100768 .init_irq = pxa25x_init_irq,
Dirk Opfer8459c152005-11-06 14:27:52 +0000769 .init_machine = tosa_init,
770 .timer = &pxa_timer,
771MACHINE_END