[ARM] pxa/magician: remove unused forward declaration of pasic3
[deliverable/linux.git] / arch / arm / mach-pxa / em-x270.c
CommitLineData
3d50527b 1/*
3c85bce6 2 * Support for CompuLab EM-X270 platform
3d50527b 3 *
3c85bce6 4 * Copyright (C) 2007, 2008 CompuLab, Ltd.
3d50527b
MR
5 * Author: Mike Rapoport <mike@compulab.co.il>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/irq.h>
13#include <linux/platform_device.h>
7f14a787 14#include <linux/delay.h>
3d50527b
MR
15
16#include <linux/dm9000.h>
17#include <linux/rtc-v3020.h>
3d50527b
MR
18#include <linux/mtd/nand.h>
19#include <linux/mtd/partitions.h>
28c88046 20#include <linux/mtd/physmap.h>
3c85bce6
MR
21#include <linux/input.h>
22#include <linux/gpio_keys.h>
23#include <linux/gpio.h>
28c88046
MR
24#include <linux/mfd/da903x.h>
25#include <linux/regulator/machine.h>
26#include <linux/spi/spi.h>
27#include <linux/spi/tdo24m.h>
9f055c49
MR
28#include <linux/power_supply.h>
29#include <linux/apm-emulation.h>
28c88046
MR
30
31#include <media/soc_camera.h>
3d50527b
MR
32
33#include <asm/mach-types.h>
3d50527b
MR
34#include <asm/mach/arch.h>
35
a09e64fb
RK
36#include <mach/mfp-pxa27x.h>
37#include <mach/pxa-regs.h>
38#include <mach/pxa27x-udc.h>
39#include <mach/audio.h>
40#include <mach/pxafb.h>
41#include <mach/ohci.h>
42#include <mach/mmc.h>
43#include <mach/pxa27x_keypad.h>
28c88046
MR
44#include <mach/i2c.h>
45#include <mach/camera.h>
46#include <mach/pxa2xx_spi.h>
3d50527b
MR
47
48#include "generic.h"
6432f46c 49#include "devices.h"
3d50527b 50
7f14a787 51/* EM-X270 specific GPIOs */
3c85bce6 52#define GPIO13_MMC_CD (13)
7f14a787
MR
53#define GPIO95_MMC_WP (95)
54#define GPIO56_NAND_RB (56)
3c85bce6 55
7f14a787
MR
56/* eXeda specific GPIOs */
57#define GPIO114_MMC_CD (114)
58#define GPIO20_NAND_RB (20)
59#define GPIO38_SD_PWEN (38)
3c85bce6 60
7f14a787
MR
61/* common GPIOs */
62#define GPIO11_NAND_CS (11)
28c88046 63#define GPIO93_CAM_RESET (93)
7f14a787
MR
64#define GPIO41_ETHIRQ (41)
65#define EM_X270_ETHIRQ IRQ_GPIO(GPIO41_ETHIRQ)
28c88046 66
4a697e83
MR
67static int mmc_cd;
68static int nand_rb;
69static int dm9000_flags;
70
71static unsigned long common_pin_config[] = {
3c85bce6
MR
72 /* AC'97 */
73 GPIO28_AC97_BITCLK,
74 GPIO29_AC97_SDATA_IN_0,
75 GPIO30_AC97_SDATA_OUT,
76 GPIO31_AC97_SYNC,
77 GPIO98_AC97_SYSCLK,
78 GPIO113_AC97_nRESET,
79
80 /* BTUART */
81 GPIO42_BTUART_RXD,
82 GPIO43_BTUART_TXD,
83 GPIO44_BTUART_CTS,
84 GPIO45_BTUART_RTS,
85
86 /* STUART */
87 GPIO46_STUART_RXD,
88 GPIO47_STUART_TXD,
89
90 /* MCI controller */
91 GPIO32_MMC_CLK,
92 GPIO112_MMC_CMD,
93 GPIO92_MMC_DAT_0,
94 GPIO109_MMC_DAT_1,
95 GPIO110_MMC_DAT_2,
96 GPIO111_MMC_DAT_3,
97
98 /* LCD */
99 GPIO58_LCD_LDD_0,
100 GPIO59_LCD_LDD_1,
101 GPIO60_LCD_LDD_2,
102 GPIO61_LCD_LDD_3,
103 GPIO62_LCD_LDD_4,
104 GPIO63_LCD_LDD_5,
105 GPIO64_LCD_LDD_6,
106 GPIO65_LCD_LDD_7,
107 GPIO66_LCD_LDD_8,
108 GPIO67_LCD_LDD_9,
109 GPIO68_LCD_LDD_10,
110 GPIO69_LCD_LDD_11,
111 GPIO70_LCD_LDD_12,
112 GPIO71_LCD_LDD_13,
113 GPIO72_LCD_LDD_14,
114 GPIO73_LCD_LDD_15,
115 GPIO74_LCD_FCLK,
116 GPIO75_LCD_LCLK,
117 GPIO76_LCD_PCLK,
118 GPIO77_LCD_BIAS,
119
120 /* QCI */
121 GPIO84_CIF_FV,
122 GPIO25_CIF_LV,
123 GPIO53_CIF_MCLK,
124 GPIO54_CIF_PCLK,
125 GPIO81_CIF_DD_0,
126 GPIO55_CIF_DD_1,
127 GPIO51_CIF_DD_2,
128 GPIO50_CIF_DD_3,
129 GPIO52_CIF_DD_4,
130 GPIO48_CIF_DD_5,
131 GPIO17_CIF_DD_6,
132 GPIO12_CIF_DD_7,
133
134 /* I2C */
135 GPIO117_I2C_SCL,
136 GPIO118_I2C_SDA,
137
138 /* Keypad */
139 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
140 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
141 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
142 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
143 GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
144 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
145 GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
146 GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
147 GPIO103_KP_MKOUT_0,
148 GPIO104_KP_MKOUT_1,
149 GPIO105_KP_MKOUT_2,
150 GPIO106_KP_MKOUT_3,
151 GPIO107_KP_MKOUT_4,
152 GPIO108_KP_MKOUT_5,
153 GPIO96_KP_MKOUT_6,
154 GPIO22_KP_MKOUT_7,
155
156 /* SSP1 */
157 GPIO26_SSP1_RXD,
158 GPIO23_SSP1_SCLK,
159 GPIO24_SSP1_SFRM,
160 GPIO57_SSP1_TXD,
161
162 /* SSP2 */
163 GPIO19_SSP2_SCLK,
164 GPIO14_SSP2_SFRM,
165 GPIO89_SSP2_TXD,
166 GPIO88_SSP2_RXD,
167
168 /* SDRAM and local bus */
169 GPIO15_nCS_1,
170 GPIO78_nCS_2,
171 GPIO79_nCS_3,
172 GPIO80_nCS_4,
173 GPIO49_nPWE,
174 GPIO18_RDY,
175
176 /* GPIO */
6432f46c 177 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* sleep/resume button */
3c85bce6
MR
178
179 /* power controls */
180 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
28c88046 181 GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
3c85bce6
MR
182 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
183
184 /* NAND controls */
185 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
3c85bce6
MR
186
187 /* interrupts */
3c85bce6
MR
188 GPIO41_GPIO, /* DM9000 interrupt */
189};
3d50527b 190
4a697e83
MR
191static unsigned long em_x270_pin_config[] = {
192 GPIO13_GPIO, /* MMC card detect */
193 GPIO56_GPIO, /* NAND Ready/Busy */
194 GPIO95_GPIO, /* MMC Write protect */
195};
196
7f14a787
MR
197static unsigned long exeda_pin_config[] = {
198 GPIO20_GPIO, /* NAND Ready/Busy */
199 GPIO38_GPIO | MFP_LPM_DRIVE_LOW, /* SD slot power */
200 GPIO114_GPIO, /* MMC card detect */
201};
202
3c85bce6
MR
203#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
204static struct resource em_x270_dm9000_resource[] = {
3d50527b
MR
205 [0] = {
206 .start = PXA_CS2_PHYS,
207 .end = PXA_CS2_PHYS + 3,
208 .flags = IORESOURCE_MEM,
209 },
210 [1] = {
211 .start = PXA_CS2_PHYS + 8,
212 .end = PXA_CS2_PHYS + 8 + 0x3f,
213 .flags = IORESOURCE_MEM,
214 },
215 [2] = {
216 .start = EM_X270_ETHIRQ,
217 .end = EM_X270_ETHIRQ,
3c85bce6 218 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
3d50527b
MR
219 }
220};
221
3c85bce6 222static struct dm9000_plat_data em_x270_dm9000_platdata = {
4a697e83 223 .flags = DM9000_PLATF_NO_EEPROM,
3d50527b
MR
224};
225
3c85bce6 226static struct platform_device em_x270_dm9000 = {
3d50527b
MR
227 .name = "dm9000",
228 .id = 0,
3c85bce6
MR
229 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
230 .resource = em_x270_dm9000_resource,
3d50527b 231 .dev = {
3c85bce6 232 .platform_data = &em_x270_dm9000_platdata,
3d50527b
MR
233 }
234};
235
3c85bce6
MR
236static void __init em_x270_init_dm9000(void)
237{
4a697e83 238 em_x270_dm9000_platdata.flags |= dm9000_flags;
3c85bce6
MR
239 platform_device_register(&em_x270_dm9000);
240}
241#else
242static inline void em_x270_init_dm9000(void) {}
243#endif
3d50527b 244
3c85bce6
MR
245/* V3020 RTC */
246#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
3d50527b
MR
247static struct resource em_x270_v3020_resource[] = {
248 [0] = {
249 .start = PXA_CS4_PHYS,
250 .end = PXA_CS4_PHYS + 3,
251 .flags = IORESOURCE_MEM,
252 },
253};
254
255static struct v3020_platform_data em_x270_v3020_platdata = {
256 .leftshift = 0,
257};
258
259static struct platform_device em_x270_rtc = {
260 .name = "v3020",
261 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
262 .resource = em_x270_v3020_resource,
263 .id = -1,
264 .dev = {
265 .platform_data = &em_x270_v3020_platdata,
266 }
267};
268
3c85bce6
MR
269static void __init em_x270_init_rtc(void)
270{
271 platform_device_register(&em_x270_rtc);
272}
273#else
274static inline void em_x270_init_rtc(void) {}
275#endif
3d50527b 276
3c85bce6
MR
277/* NAND flash */
278#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
3d50527b
MR
279static inline void nand_cs_on(void)
280{
3c85bce6 281 gpio_set_value(GPIO11_NAND_CS, 0);
3d50527b
MR
282}
283
284static void nand_cs_off(void)
285{
286 dsb();
287
3c85bce6 288 gpio_set_value(GPIO11_NAND_CS, 1);
3d50527b
MR
289}
290
291/* hardware specific access to control-lines */
292static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
293 unsigned int ctrl)
294{
295 struct nand_chip *this = mtd->priv;
296 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
297
298 dsb();
299
300 if (ctrl & NAND_CTRL_CHANGE) {
301 if (ctrl & NAND_ALE)
302 nandaddr |= (1 << 3);
303 else
304 nandaddr &= ~(1 << 3);
305 if (ctrl & NAND_CLE)
306 nandaddr |= (1 << 2);
307 else
308 nandaddr &= ~(1 << 2);
309 if (ctrl & NAND_NCE)
310 nand_cs_on();
311 else
312 nand_cs_off();
313 }
314
315 dsb();
316 this->IO_ADDR_W = (void __iomem *)nandaddr;
317 if (dat != NAND_CMD_NONE)
318 writel(dat, this->IO_ADDR_W);
319
320 dsb();
321}
322
323/* read device ready pin */
324static int em_x270_nand_device_ready(struct mtd_info *mtd)
325{
326 dsb();
327
4a697e83 328 return gpio_get_value(nand_rb);
3d50527b
MR
329}
330
331static struct mtd_partition em_x270_partition_info[] = {
332 [0] = {
333 .name = "em_x270-0",
334 .offset = 0,
335 .size = SZ_4M,
336 },
337 [1] = {
338 .name = "em_x270-1",
339 .offset = MTDPART_OFS_APPEND,
340 .size = MTDPART_SIZ_FULL
341 },
342};
343
344static const char *em_x270_part_probes[] = { "cmdlinepart", NULL };
345
346struct platform_nand_data em_x270_nand_platdata = {
347 .chip = {
348 .nr_chips = 1,
349 .chip_offset = 0,
350 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
351 .partitions = em_x270_partition_info,
352 .chip_delay = 20,
353 .part_probe_types = em_x270_part_probes,
354 },
355 .ctrl = {
356 .hwcontrol = 0,
357 .dev_ready = em_x270_nand_device_ready,
358 .select_chip = 0,
359 .cmd_ctrl = em_x270_nand_cmd_ctl,
360 },
361};
362
363static struct resource em_x270_nand_resource[] = {
364 [0] = {
365 .start = PXA_CS1_PHYS,
366 .end = PXA_CS1_PHYS + 12,
367 .flags = IORESOURCE_MEM,
368 },
369};
370
371static struct platform_device em_x270_nand = {
372 .name = "gen_nand",
373 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
374 .resource = em_x270_nand_resource,
375 .id = -1,
376 .dev = {
377 .platform_data = &em_x270_nand_platdata,
378 }
379};
380
3c85bce6
MR
381static void __init em_x270_init_nand(void)
382{
383 int err;
3d50527b 384
3c85bce6
MR
385 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
386 if (err) {
387 pr_warning("EM-X270: failed to request NAND CS gpio\n");
388 return;
389 }
390
391 gpio_direction_output(GPIO11_NAND_CS, 1);
392
4a697e83 393 err = gpio_request(nand_rb, "NAND R/B");
3c85bce6
MR
394 if (err) {
395 pr_warning("EM-X270: failed to request NAND R/B gpio\n");
396 gpio_free(GPIO11_NAND_CS);
397 return;
398 }
399
4a697e83 400 gpio_direction_input(nand_rb);
3c85bce6
MR
401
402 platform_device_register(&em_x270_nand);
403}
404#else
405static inline void em_x270_init_nand(void) {}
406#endif
3d50527b 407
28c88046
MR
408#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
409static struct mtd_partition em_x270_nor_parts[] = {
410 {
411 .name = "Bootloader",
412 .offset = 0x00000000,
413 .size = 0x00050000,
414 .mask_flags = MTD_WRITEABLE /* force read-only */
415 }, {
416 .name = "Environment",
417 .offset = 0x00050000,
418 .size = 0x00010000,
419 }, {
420 .name = "Reserved",
421 .offset = 0x00060000,
422 .size = 0x00050000,
423 .mask_flags = MTD_WRITEABLE /* force read-only */
424 }, {
425 .name = "Splashscreen",
426 .offset = 0x000b0000,
427 .size = 0x00050000,
428 }
429};
430
431static struct physmap_flash_data em_x270_nor_data[] = {
432 [0] = {
433 .width = 2,
434 .parts = em_x270_nor_parts,
435 .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
436 },
437};
438
439static struct resource em_x270_nor_flash_resource = {
440 .start = PXA_CS0_PHYS,
441 .end = PXA_CS0_PHYS + SZ_1M - 1,
442 .flags = IORESOURCE_MEM,
443};
444
445static struct platform_device em_x270_physmap_flash = {
446 .name = "physmap-flash",
447 .id = 0,
448 .num_resources = 1,
449 .resource = &em_x270_nor_flash_resource,
450 .dev = {
451 .platform_data = &em_x270_nor_data,
452 },
453};
454
455static void __init em_x270_init_nor(void)
456{
457 platform_device_register(&em_x270_physmap_flash);
458}
459#else
460static inline void em_x270_init_nor(void) {}
461#endif
462
3d50527b 463/* PXA27x OHCI controller setup */
3c85bce6 464#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
3d50527b
MR
465static int em_x270_ohci_init(struct device *dev)
466{
3d50527b
MR
467 /* enable port 2 transiever */
468 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
469
470 return 0;
471}
472
473static struct pxaohci_platform_data em_x270_ohci_platform_data = {
474 .port_mode = PMM_PERPORT_MODE,
097b5334 475 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
3d50527b
MR
476 .init = em_x270_ohci_init,
477};
478
3c85bce6
MR
479static void __init em_x270_init_ohci(void)
480{
481 pxa_set_ohci_info(&em_x270_ohci_platform_data);
482}
483#else
484static inline void em_x270_init_ohci(void) {}
485#endif
3d50527b 486
3c85bce6
MR
487/* MCI controller setup */
488#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
6432f46c
MR
489static struct regulator *em_x270_sdio_ldo;
490
3d50527b
MR
491static int em_x270_mci_init(struct device *dev,
492 irq_handler_t em_x270_detect_int,
493 void *data)
494{
6432f46c
MR
495 int err;
496
497 em_x270_sdio_ldo = regulator_get(dev, "vcc sdio");
498 if (IS_ERR(em_x270_sdio_ldo)) {
499 dev_err(dev, "can't request SDIO power supply: %ld\n",
500 PTR_ERR(em_x270_sdio_ldo));
501 return PTR_ERR(em_x270_sdio_ldo);
502 }
503
4a697e83 504 err = request_irq(gpio_to_irq(mmc_cd), em_x270_detect_int,
6432f46c
MR
505 IRQF_DISABLED | IRQF_TRIGGER_RISING |
506 IRQF_TRIGGER_FALLING,
3c85bce6 507 "MMC card detect", data);
3d50527b 508 if (err) {
6432f46c
MR
509 dev_err(dev, "can't request MMC card detect IRQ: %d\n", err);
510 goto err_irq;
511 }
512
7f14a787
MR
513 if (machine_is_em_x270()) {
514 err = gpio_request(GPIO95_MMC_WP, "MMC WP");
515 if (err) {
516 dev_err(dev, "can't request MMC write protect: %d\n",
517 err);
518 goto err_gpio_wp;
519 }
520 gpio_direction_input(GPIO95_MMC_WP);
521 } else {
522 err = gpio_request(GPIO38_SD_PWEN, "sdio power");
523 if (err) {
524 dev_err(dev, "can't request MMC power control : %d\n",
525 err);
526 goto err_gpio_wp;
527 }
528 gpio_direction_output(GPIO38_SD_PWEN, 1);
3d50527b
MR
529 }
530
531 return 0;
6432f46c
MR
532
533err_gpio_wp:
4a697e83 534 free_irq(gpio_to_irq(mmc_cd), data);
6432f46c
MR
535err_irq:
536 regulator_put(em_x270_sdio_ldo);
537
538 return err;
3d50527b
MR
539}
540
541static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
542{
6432f46c
MR
543 struct pxamci_platform_data* p_d = dev->platform_data;
544
545 if ((1 << vdd) & p_d->ocr_mask) {
546 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
547
548 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
549 regulator_enable(em_x270_sdio_ldo);
550 } else {
551 regulator_disable(em_x270_sdio_ldo);
552 }
3d50527b
MR
553}
554
555static void em_x270_mci_exit(struct device *dev, void *data)
556{
4a697e83 557 free_irq(gpio_to_irq(mmc_cd), data);
7f14a787
MR
558 regulator_put(em_x270_sdio_ldo);
559
560 if (machine_is_em_x270())
561 gpio_free(GPIO95_MMC_WP);
562 else
563 gpio_free(GPIO38_SD_PWEN);
6432f46c
MR
564}
565
566static int em_x270_mci_get_ro(struct device *dev)
567{
568 return gpio_get_value(GPIO95_MMC_WP);
3d50527b
MR
569}
570
571static struct pxamci_platform_data em_x270_mci_platform_data = {
6432f46c
MR
572 .ocr_mask = MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23|
573 MMC_VDD_24_25|MMC_VDD_25_26|MMC_VDD_26_27|
574 MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
575 MMC_VDD_30_31|MMC_VDD_31_32,
3d50527b
MR
576 .init = em_x270_mci_init,
577 .setpower = em_x270_mci_setpower,
578 .exit = em_x270_mci_exit,
579};
580
3c85bce6
MR
581static void __init em_x270_init_mmc(void)
582{
7f14a787
MR
583 if (machine_is_em_x270())
584 em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro;
585
6432f46c 586 em_x270_mci_platform_data.detect_delay = msecs_to_jiffies(250);
3c85bce6
MR
587 pxa_set_mci_info(&em_x270_mci_platform_data);
588}
589#else
590static inline void em_x270_init_mmc(void) {}
591#endif
592
28c88046 593/* LCD */
3c85bce6 594#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
28c88046
MR
595static struct pxafb_mode_info em_x270_lcd_modes[] = {
596 [0] = {
597 .pixclock = 38250,
598 .bpp = 16,
599 .xres = 480,
600 .yres = 640,
601 .hsync_len = 8,
602 .vsync_len = 2,
603 .left_margin = 8,
604 .upper_margin = 2,
605 .right_margin = 24,
606 .lower_margin = 4,
607 .sync = 0,
608 },
609 [1] = {
610 .pixclock = 153800,
611 .bpp = 16,
612 .xres = 240,
613 .yres = 320,
614 .hsync_len = 8,
615 .vsync_len = 2,
616 .left_margin = 8,
617 .upper_margin = 2,
618 .right_margin = 88,
619 .lower_margin = 2,
620 .sync = 0,
621 },
3d50527b
MR
622};
623
624static struct pxafb_mach_info em_x270_lcd = {
28c88046
MR
625 .modes = em_x270_lcd_modes,
626 .num_modes = 2,
3c85bce6 627 .lcd_conn = LCD_COLOR_TFT_16BPP,
3d50527b 628};
28c88046 629
3c85bce6 630static void __init em_x270_init_lcd(void)
3d50527b 631{
3d50527b 632 set_pxa_fb_info(&em_x270_lcd);
3c85bce6
MR
633}
634#else
635static inline void em_x270_init_lcd(void) {}
636#endif
3d50527b 637
28c88046
MR
638#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
639static struct pxa2xx_spi_master em_x270_spi_info = {
640 .num_chipselect = 1,
641};
642
643static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
644 .rx_threshold = 1,
645 .tx_threshold = 1,
646};
647
648static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
649 .model = TDO35S,
650};
651
652static struct spi_board_info em_x270_spi_devices[] __initdata = {
653 {
654 .modalias = "tdo24m",
655 .max_speed_hz = 1000000,
656 .bus_num = 1,
657 .chip_select = 0,
658 .controller_data = &em_x270_tdo24m_chip,
659 .platform_data = &em_x270_tdo24m_pdata,
660 },
661};
662
663static void __init em_x270_init_spi(void)
664{
665 pxa2xx_set_spi_info(1, &em_x270_spi_info);
666 spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
667}
668#else
669static inline void em_x270_init_spi(void) {}
670#endif
671
3c85bce6
MR
672#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
673static void __init em_x270_init_ac97(void)
674{
9f19d638 675 pxa_set_ac97_info(NULL);
3c85bce6
MR
676}
677#else
678static inline void em_x270_init_ac97(void) {}
679#endif
680
681#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
7f14a787 682static unsigned int em_x270_module_matrix_keys[] = {
3c85bce6
MR
683 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
684 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
685 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
686};
3d50527b 687
7f14a787 688struct pxa27x_keypad_platform_data em_x270_module_keypad_info = {
3c85bce6
MR
689 /* code map for the matrix keys */
690 .matrix_key_rows = 3,
691 .matrix_key_cols = 3,
7f14a787
MR
692 .matrix_key_map = em_x270_module_matrix_keys,
693 .matrix_key_map_size = ARRAY_SIZE(em_x270_module_matrix_keys),
694};
695
696static unsigned int em_x270_exeda_matrix_keys[] = {
697 KEY(0, 0, KEY_RIGHTSHIFT), KEY(0, 1, KEY_RIGHTCTRL),
698 KEY(0, 2, KEY_RIGHTALT), KEY(0, 3, KEY_SPACE),
699 KEY(0, 4, KEY_LEFTALT), KEY(0, 5, KEY_LEFTCTRL),
700 KEY(0, 6, KEY_ENTER), KEY(0, 7, KEY_SLASH),
701
702 KEY(1, 0, KEY_DOT), KEY(1, 1, KEY_M),
703 KEY(1, 2, KEY_N), KEY(1, 3, KEY_B),
704 KEY(1, 4, KEY_V), KEY(1, 5, KEY_C),
705 KEY(1, 6, KEY_X), KEY(1, 7, KEY_Z),
706
707 KEY(2, 0, KEY_LEFTSHIFT), KEY(2, 1, KEY_SEMICOLON),
708 KEY(2, 2, KEY_L), KEY(2, 3, KEY_K),
709 KEY(2, 4, KEY_J), KEY(2, 5, KEY_H),
710 KEY(2, 6, KEY_G), KEY(2, 7, KEY_F),
711
712 KEY(3, 0, KEY_D), KEY(3, 1, KEY_S),
713 KEY(3, 2, KEY_A), KEY(3, 3, KEY_TAB),
714 KEY(3, 4, KEY_BACKSPACE), KEY(3, 5, KEY_P),
715 KEY(3, 6, KEY_O), KEY(3, 7, KEY_I),
716
717 KEY(4, 0, KEY_U), KEY(4, 1, KEY_Y),
718 KEY(4, 2, KEY_T), KEY(4, 3, KEY_R),
719 KEY(4, 4, KEY_E), KEY(4, 5, KEY_W),
720 KEY(4, 6, KEY_Q), KEY(4, 7, KEY_MINUS),
721
722 KEY(5, 0, KEY_0), KEY(5, 1, KEY_9),
723 KEY(5, 2, KEY_8), KEY(5, 3, KEY_7),
724 KEY(5, 4, KEY_6), KEY(5, 5, KEY_5),
725 KEY(5, 6, KEY_4), KEY(5, 7, KEY_3),
726
727 KEY(6, 0, KEY_2), KEY(6, 1, KEY_1),
728 KEY(6, 2, KEY_ENTER), KEY(6, 3, KEY_END),
729 KEY(6, 4, KEY_DOWN), KEY(6, 5, KEY_UP),
730 KEY(6, 6, KEY_MENU), KEY(6, 7, KEY_F1),
731
732 KEY(7, 0, KEY_LEFT), KEY(7, 1, KEY_RIGHT),
733 KEY(7, 2, KEY_BACK), KEY(7, 3, KEY_HOME),
734 KEY(7, 4, 0), KEY(7, 5, 0),
735 KEY(7, 6, 0), KEY(7, 7, 0),
736};
737
738struct pxa27x_keypad_platform_data em_x270_exeda_keypad_info = {
739 /* code map for the matrix keys */
740 .matrix_key_rows = 8,
741 .matrix_key_cols = 8,
742 .matrix_key_map = em_x270_exeda_matrix_keys,
743 .matrix_key_map_size = ARRAY_SIZE(em_x270_exeda_matrix_keys),
3c85bce6
MR
744};
745
746static void __init em_x270_init_keypad(void)
747{
7f14a787
MR
748 if (machine_is_em_x270())
749 pxa_set_keypad_info(&em_x270_module_keypad_info);
750 else
751 pxa_set_keypad_info(&em_x270_exeda_keypad_info);
3c85bce6
MR
752}
753#else
754static inline void em_x270_init_keypad(void) {}
755#endif
3d50527b 756
3c85bce6
MR
757#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
758static struct gpio_keys_button gpio_keys_button[] = {
759 [0] = {
760 .desc = "sleep/wakeup",
761 .code = KEY_SUSPEND,
762 .type = EV_PWR,
763 .gpio = 1,
764 .wakeup = 1,
765 },
766};
3d50527b 767
3c85bce6
MR
768static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
769 .buttons = gpio_keys_button,
770 .nbuttons = 1,
771};
3d50527b 772
3c85bce6
MR
773static struct platform_device em_x270_gpio_keys = {
774 .name = "gpio-keys",
775 .id = -1,
776 .dev = {
777 .platform_data = &em_x270_gpio_keys_data,
778 },
779};
780
781static void __init em_x270_init_gpio_keys(void)
782{
783 platform_device_register(&em_x270_gpio_keys);
784}
785#else
786static inline void em_x270_init_gpio_keys(void) {}
787#endif
788
28c88046
MR
789/* Quick Capture Interface and sensor setup */
790#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
791static struct regulator *em_x270_camera_ldo;
792
793static int em_x270_sensor_init(struct device *dev)
794{
795 int ret;
796
797 ret = gpio_request(GPIO93_CAM_RESET, "camera reset");
798 if (ret)
799 return ret;
800
801 gpio_direction_output(GPIO93_CAM_RESET, 0);
802
803 em_x270_camera_ldo = regulator_get(NULL, "vcc cam");
804 if (em_x270_camera_ldo == NULL) {
805 gpio_free(GPIO93_CAM_RESET);
806 return -ENODEV;
807 }
808
809 ret = regulator_enable(em_x270_camera_ldo);
810 if (ret) {
811 regulator_put(em_x270_camera_ldo);
812 gpio_free(GPIO93_CAM_RESET);
813 return ret;
814 }
815
816 gpio_set_value(GPIO93_CAM_RESET, 1);
817
818 return 0;
819}
820
821struct pxacamera_platform_data em_x270_camera_platform_data = {
822 .init = em_x270_sensor_init,
823 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
824 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
825 .mclk_10khz = 2600,
826};
827
828static int em_x270_sensor_power(struct device *dev, int on)
829{
830 int ret;
831 int is_on = regulator_is_enabled(em_x270_camera_ldo);
832
833 if (on == is_on)
834 return 0;
835
836 gpio_set_value(GPIO93_CAM_RESET, !on);
837
838 if (on)
839 ret = regulator_enable(em_x270_camera_ldo);
840 else
841 ret = regulator_disable(em_x270_camera_ldo);
842
843 if (ret)
844 return ret;
845
846 gpio_set_value(GPIO93_CAM_RESET, on);
847
848 return 0;
849}
850
851static struct soc_camera_link iclink = {
852 .bus_id = 0,
853 .power = em_x270_sensor_power,
854};
855
856static struct i2c_board_info em_x270_i2c_cam_info[] = {
857 {
858 I2C_BOARD_INFO("mt9m111", 0x48),
859 .platform_data = &iclink,
860 },
861};
862
863static struct i2c_pxa_platform_data em_x270_i2c_info = {
864 .fast_mode = 1,
865};
866
867static void __init em_x270_init_camera(void)
868{
869 pxa_set_i2c_info(&em_x270_i2c_info);
870 i2c_register_board_info(0, ARRAY_AND_SIZE(em_x270_i2c_cam_info));
871 pxa_set_camera_info(&em_x270_camera_platform_data);
872}
873#else
874static inline void em_x270_init_camera(void) {}
875#endif
876
877/* DA9030 related initializations */
432adf18
MR
878#define REGULATOR_CONSUMER(_name, _dev, _supply) \
879 static struct regulator_consumer_supply _name##_consumers[] = { \
880 { \
881 .dev = _dev, \
882 .supply = _supply, \
883 }, \
884 }
28c88046 885
432adf18
MR
886REGULATOR_CONSUMER(ldo3, NULL, "vcc gps");
887REGULATOR_CONSUMER(ldo5, NULL, "vcc cam");
888REGULATOR_CONSUMER(ldo10, &pxa_device_mci.dev, "vcc sdio");
889REGULATOR_CONSUMER(ldo12, NULL, "vcc usb");
890REGULATOR_CONSUMER(ldo19, NULL, "vcc gprs");
891
892#define REGULATOR_INIT(_ldo, _min_uV, _max_uV, _ops_mask) \
893 static struct regulator_init_data _ldo##_data = { \
894 .constraints = { \
895 .min_uV = _min_uV, \
896 .max_uV = _max_uV, \
897 .state_mem = { \
898 .enabled = 0, \
899 }, \
900 .valid_ops_mask = _ops_mask, \
901 }, \
902 .num_consumer_supplies = ARRAY_SIZE(_ldo##_consumers), \
903 .consumer_supplies = _ldo##_consumers, \
904 };
905
906REGULATOR_INIT(ldo3, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
907REGULATOR_INIT(ldo5, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
908REGULATOR_INIT(ldo10, 2000000, 3200000,
909 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE);
910REGULATOR_INIT(ldo12, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
911REGULATOR_INIT(ldo19, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
28c88046
MR
912
913struct led_info em_x270_led_info = {
914 .name = "em-x270:orange",
915 .default_trigger = "battery-charging-or-full",
916};
917
9f055c49
MR
918struct power_supply_info em_x270_psy_info = {
919 .name = "LP555597P6H-FPS",
920 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
921 .voltage_max_design = 4200000,
922 .voltage_min_design = 3000000,
923 .use_for_apm = 1,
924};
925
926static void em_x270_battery_low(void)
927{
928 apm_queue_event(APM_LOW_BATTERY);
929}
930
931static void em_x270_battery_critical(void)
932{
933 apm_queue_event(APM_CRITICAL_SUSPEND);
934}
935
936struct da9030_battery_info em_x270_batterty_info = {
937 .battery_info = &em_x270_psy_info,
938
939 .charge_milliamp = 1000,
940 .charge_millivolt = 4200,
941
942 .vbat_low = 3600,
943 .vbat_crit = 3400,
944 .vbat_charge_start = 4100,
945 .vbat_charge_stop = 4200,
946 .vbat_charge_restart = 4000,
947
948 .vcharge_min = 3200,
949 .vcharge_max = 5500,
950
951 .tbat_low = 197,
952 .tbat_high = 78,
953 .tbat_restart = 100,
954
955 .batmon_interval = 0,
956
957 .battery_low = em_x270_battery_low,
958 .battery_critical = em_x270_battery_critical,
959};
960
432adf18
MR
961#define DA9030_SUBDEV(_name, _id, _pdata) \
962 { \
963 .name = "da903x-" #_name, \
964 .id = DA9030_ID_##_id, \
965 .platform_data = _pdata, \
28c88046 966 }
432adf18
MR
967
968#define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
969
970struct da903x_subdev_info em_x270_da9030_subdevs[] = {
971 DA9030_LDO(3),
972 DA9030_LDO(5),
973 DA9030_LDO(10),
974 DA9030_LDO(12),
975 DA9030_LDO(19),
976
977 DA9030_SUBDEV(led, LED_PC, &em_x270_led_info),
978 DA9030_SUBDEV(backlight, WLED, &em_x270_led_info),
9f055c49 979 DA9030_SUBDEV(battery, BAT, &em_x270_batterty_info),
28c88046
MR
980};
981
982static struct da903x_platform_data em_x270_da9030_info = {
983 .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
984 .subdevs = em_x270_da9030_subdevs,
985};
986
987static struct i2c_board_info em_x270_i2c_pmic_info = {
988 I2C_BOARD_INFO("da9030", 0x49),
989 .irq = IRQ_GPIO(0),
990 .platform_data = &em_x270_da9030_info,
991};
992
993static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
994 .use_pio = 1,
995};
996
997static void __init em_x270_init_da9030(void)
998{
999 pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
1000 i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
1001}
1002
4a697e83 1003static void __init em_x270_module_init(void)
3c85bce6 1004{
7f14a787 1005 pr_info("%s\n", __func__);
3c85bce6
MR
1006 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
1007
4a697e83
MR
1008 mmc_cd = GPIO13_MMC_CD;
1009 nand_rb = GPIO56_NAND_RB;
1010 dm9000_flags = DM9000_PLATF_32BITONLY;
1011}
1012
7f14a787
MR
1013static void __init em_x270_exeda_init(void)
1014{
1015 pr_info("%s\n", __func__);
1016 pxa2xx_mfp_config(ARRAY_AND_SIZE(exeda_pin_config));
1017
1018 mmc_cd = GPIO114_MMC_CD;
1019 nand_rb = GPIO20_NAND_RB;
1020 dm9000_flags = DM9000_PLATF_16BITONLY;
1021}
1022
4a697e83
MR
1023static void __init em_x270_init(void)
1024{
1025 pxa2xx_mfp_config(ARRAY_AND_SIZE(common_pin_config));
1026
7f14a787
MR
1027 if (machine_is_em_x270())
1028 em_x270_module_init();
1029 else if (machine_is_exeda())
1030 em_x270_exeda_init();
1031 else
1032 panic("Unsupported machine: %d\n", machine_arch_type);
4a697e83 1033
28c88046 1034 em_x270_init_da9030();
3c85bce6
MR
1035 em_x270_init_dm9000();
1036 em_x270_init_rtc();
1037 em_x270_init_nand();
28c88046 1038 em_x270_init_nor();
3c85bce6
MR
1039 em_x270_init_lcd();
1040 em_x270_init_mmc();
1041 em_x270_init_ohci();
1042 em_x270_init_keypad();
1043 em_x270_init_gpio_keys();
1044 em_x270_init_ac97();
28c88046
MR
1045 em_x270_init_camera();
1046 em_x270_init_spi();
3d50527b
MR
1047}
1048
3c85bce6 1049MACHINE_START(EM_X270, "Compulab EM-X270")
3d50527b
MR
1050 .boot_params = 0xa0000100,
1051 .phys_io = 0x40000000,
1052 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1053 .map_io = pxa_map_io,
1054 .init_irq = pxa27x_init_irq,
1055 .timer = &pxa_timer,
1056 .init_machine = em_x270_init,
1057MACHINE_END
7f14a787
MR
1058
1059MACHINE_START(EXEDA, "Compulab eXeda")
1060 .boot_params = 0xa0000100,
1061 .phys_io = 0x40000000,
1062 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1063 .map_io = pxa_map_io,
1064 .init_irq = pxa27x_init_irq,
1065 .timer = &pxa_timer,
1066 .init_machine = em_x270_init,
1067MACHINE_END
This page took 0.191394 seconds and 5 git commands to generate.