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