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