blob: 1aaae97de7d39d9b3b6fab6f2412aeb593be78a4 [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>
27
28#include <media/soc_camera.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010029
30#include <asm/mach-types.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010031#include <asm/mach/arch.h>
32
Russell Kinga09e64f2008-08-05 16:14:15 +010033#include <mach/mfp-pxa27x.h>
34#include <mach/pxa-regs.h>
35#include <mach/pxa27x-udc.h>
36#include <mach/audio.h>
37#include <mach/pxafb.h>
38#include <mach/ohci.h>
39#include <mach/mmc.h>
40#include <mach/pxa27x_keypad.h>
Mike Rapoport28c88042008-12-03 09:38:10 +020041#include <mach/i2c.h>
42#include <mach/camera.h>
43#include <mach/pxa2xx_spi.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010044
45#include "generic.h"
46
47/* GPIO IRQ usage */
Mike Rapoport3c85bce2008-06-16 08:16:46 +010048#define GPIO41_ETHIRQ (41)
49#define GPIO13_MMC_CD (13)
50#define EM_X270_ETHIRQ IRQ_GPIO(GPIO41_ETHIRQ)
51#define EM_X270_MMC_CD IRQ_GPIO(GPIO13_MMC_CD)
Mike Rapoport3d505272007-07-18 11:31:46 +010052
Mike Rapoport3c85bce2008-06-16 08:16:46 +010053/* NAND control GPIOs */
54#define GPIO11_NAND_CS (11)
55#define GPIO56_NAND_RB (56)
56
Mike Rapoport28c88042008-12-03 09:38:10 +020057/* Miscelaneous GPIOs */
58#define GPIO93_CAM_RESET (93)
59
Mike Rapoport3c85bce2008-06-16 08:16:46 +010060static unsigned long em_x270_pin_config[] = {
61 /* AC'97 */
62 GPIO28_AC97_BITCLK,
63 GPIO29_AC97_SDATA_IN_0,
64 GPIO30_AC97_SDATA_OUT,
65 GPIO31_AC97_SYNC,
66 GPIO98_AC97_SYSCLK,
67 GPIO113_AC97_nRESET,
68
69 /* BTUART */
70 GPIO42_BTUART_RXD,
71 GPIO43_BTUART_TXD,
72 GPIO44_BTUART_CTS,
73 GPIO45_BTUART_RTS,
74
75 /* STUART */
76 GPIO46_STUART_RXD,
77 GPIO47_STUART_TXD,
78
79 /* MCI controller */
80 GPIO32_MMC_CLK,
81 GPIO112_MMC_CMD,
82 GPIO92_MMC_DAT_0,
83 GPIO109_MMC_DAT_1,
84 GPIO110_MMC_DAT_2,
85 GPIO111_MMC_DAT_3,
86
87 /* LCD */
88 GPIO58_LCD_LDD_0,
89 GPIO59_LCD_LDD_1,
90 GPIO60_LCD_LDD_2,
91 GPIO61_LCD_LDD_3,
92 GPIO62_LCD_LDD_4,
93 GPIO63_LCD_LDD_5,
94 GPIO64_LCD_LDD_6,
95 GPIO65_LCD_LDD_7,
96 GPIO66_LCD_LDD_8,
97 GPIO67_LCD_LDD_9,
98 GPIO68_LCD_LDD_10,
99 GPIO69_LCD_LDD_11,
100 GPIO70_LCD_LDD_12,
101 GPIO71_LCD_LDD_13,
102 GPIO72_LCD_LDD_14,
103 GPIO73_LCD_LDD_15,
104 GPIO74_LCD_FCLK,
105 GPIO75_LCD_LCLK,
106 GPIO76_LCD_PCLK,
107 GPIO77_LCD_BIAS,
108
109 /* QCI */
110 GPIO84_CIF_FV,
111 GPIO25_CIF_LV,
112 GPIO53_CIF_MCLK,
113 GPIO54_CIF_PCLK,
114 GPIO81_CIF_DD_0,
115 GPIO55_CIF_DD_1,
116 GPIO51_CIF_DD_2,
117 GPIO50_CIF_DD_3,
118 GPIO52_CIF_DD_4,
119 GPIO48_CIF_DD_5,
120 GPIO17_CIF_DD_6,
121 GPIO12_CIF_DD_7,
122
123 /* I2C */
124 GPIO117_I2C_SCL,
125 GPIO118_I2C_SDA,
126
127 /* Keypad */
128 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
129 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
130 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
131 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
132 GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
133 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
134 GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
135 GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
136 GPIO103_KP_MKOUT_0,
137 GPIO104_KP_MKOUT_1,
138 GPIO105_KP_MKOUT_2,
139 GPIO106_KP_MKOUT_3,
140 GPIO107_KP_MKOUT_4,
141 GPIO108_KP_MKOUT_5,
142 GPIO96_KP_MKOUT_6,
143 GPIO22_KP_MKOUT_7,
144
145 /* SSP1 */
146 GPIO26_SSP1_RXD,
147 GPIO23_SSP1_SCLK,
148 GPIO24_SSP1_SFRM,
149 GPIO57_SSP1_TXD,
150
151 /* SSP2 */
152 GPIO19_SSP2_SCLK,
153 GPIO14_SSP2_SFRM,
154 GPIO89_SSP2_TXD,
155 GPIO88_SSP2_RXD,
156
157 /* SDRAM and local bus */
158 GPIO15_nCS_1,
159 GPIO78_nCS_2,
160 GPIO79_nCS_3,
161 GPIO80_nCS_4,
162 GPIO49_nPWE,
163 GPIO18_RDY,
164
165 /* GPIO */
166 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH,
167
168 /* power controls */
169 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
Mike Rapoport28c88042008-12-03 09:38:10 +0200170 GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100171 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
172
173 /* NAND controls */
174 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
175 GPIO56_GPIO, /* NAND Ready/Busy */
176
177 /* interrupts */
178 GPIO13_GPIO, /* MMC card detect */
179 GPIO41_GPIO, /* DM9000 interrupt */
180};
181
182#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
183static struct resource em_x270_dm9000_resource[] = {
Mike Rapoport3d505272007-07-18 11:31:46 +0100184 [0] = {
185 .start = PXA_CS2_PHYS,
186 .end = PXA_CS2_PHYS + 3,
187 .flags = IORESOURCE_MEM,
188 },
189 [1] = {
190 .start = PXA_CS2_PHYS + 8,
191 .end = PXA_CS2_PHYS + 8 + 0x3f,
192 .flags = IORESOURCE_MEM,
193 },
194 [2] = {
195 .start = EM_X270_ETHIRQ,
196 .end = EM_X270_ETHIRQ,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100197 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Mike Rapoport3d505272007-07-18 11:31:46 +0100198 }
199};
200
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100201static struct dm9000_plat_data em_x270_dm9000_platdata = {
Mike Rapoport3d505272007-07-18 11:31:46 +0100202 .flags = DM9000_PLATF_32BITONLY,
203};
204
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100205static struct platform_device em_x270_dm9000 = {
Mike Rapoport3d505272007-07-18 11:31:46 +0100206 .name = "dm9000",
207 .id = 0,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100208 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
209 .resource = em_x270_dm9000_resource,
Mike Rapoport3d505272007-07-18 11:31:46 +0100210 .dev = {
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100211 .platform_data = &em_x270_dm9000_platdata,
Mike Rapoport3d505272007-07-18 11:31:46 +0100212 }
213};
214
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100215static void __init em_x270_init_dm9000(void)
216{
217 platform_device_register(&em_x270_dm9000);
218}
219#else
220static inline void em_x270_init_dm9000(void) {}
221#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100222
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100223/* V3020 RTC */
224#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
Mike Rapoport3d505272007-07-18 11:31:46 +0100225static struct resource em_x270_v3020_resource[] = {
226 [0] = {
227 .start = PXA_CS4_PHYS,
228 .end = PXA_CS4_PHYS + 3,
229 .flags = IORESOURCE_MEM,
230 },
231};
232
233static struct v3020_platform_data em_x270_v3020_platdata = {
234 .leftshift = 0,
235};
236
237static struct platform_device em_x270_rtc = {
238 .name = "v3020",
239 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
240 .resource = em_x270_v3020_resource,
241 .id = -1,
242 .dev = {
243 .platform_data = &em_x270_v3020_platdata,
244 }
245};
246
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100247static void __init em_x270_init_rtc(void)
248{
249 platform_device_register(&em_x270_rtc);
250}
251#else
252static inline void em_x270_init_rtc(void) {}
253#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100254
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100255/* NAND flash */
256#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
Mike Rapoport3d505272007-07-18 11:31:46 +0100257static inline void nand_cs_on(void)
258{
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100259 gpio_set_value(GPIO11_NAND_CS, 0);
Mike Rapoport3d505272007-07-18 11:31:46 +0100260}
261
262static void nand_cs_off(void)
263{
264 dsb();
265
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100266 gpio_set_value(GPIO11_NAND_CS, 1);
Mike Rapoport3d505272007-07-18 11:31:46 +0100267}
268
269/* hardware specific access to control-lines */
270static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
271 unsigned int ctrl)
272{
273 struct nand_chip *this = mtd->priv;
274 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
275
276 dsb();
277
278 if (ctrl & NAND_CTRL_CHANGE) {
279 if (ctrl & NAND_ALE)
280 nandaddr |= (1 << 3);
281 else
282 nandaddr &= ~(1 << 3);
283 if (ctrl & NAND_CLE)
284 nandaddr |= (1 << 2);
285 else
286 nandaddr &= ~(1 << 2);
287 if (ctrl & NAND_NCE)
288 nand_cs_on();
289 else
290 nand_cs_off();
291 }
292
293 dsb();
294 this->IO_ADDR_W = (void __iomem *)nandaddr;
295 if (dat != NAND_CMD_NONE)
296 writel(dat, this->IO_ADDR_W);
297
298 dsb();
299}
300
301/* read device ready pin */
302static int em_x270_nand_device_ready(struct mtd_info *mtd)
303{
304 dsb();
305
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100306 return gpio_get_value(GPIO56_NAND_RB);
Mike Rapoport3d505272007-07-18 11:31:46 +0100307}
308
309static struct mtd_partition em_x270_partition_info[] = {
310 [0] = {
311 .name = "em_x270-0",
312 .offset = 0,
313 .size = SZ_4M,
314 },
315 [1] = {
316 .name = "em_x270-1",
317 .offset = MTDPART_OFS_APPEND,
318 .size = MTDPART_SIZ_FULL
319 },
320};
321
322static const char *em_x270_part_probes[] = { "cmdlinepart", NULL };
323
324struct platform_nand_data em_x270_nand_platdata = {
325 .chip = {
326 .nr_chips = 1,
327 .chip_offset = 0,
328 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
329 .partitions = em_x270_partition_info,
330 .chip_delay = 20,
331 .part_probe_types = em_x270_part_probes,
332 },
333 .ctrl = {
334 .hwcontrol = 0,
335 .dev_ready = em_x270_nand_device_ready,
336 .select_chip = 0,
337 .cmd_ctrl = em_x270_nand_cmd_ctl,
338 },
339};
340
341static struct resource em_x270_nand_resource[] = {
342 [0] = {
343 .start = PXA_CS1_PHYS,
344 .end = PXA_CS1_PHYS + 12,
345 .flags = IORESOURCE_MEM,
346 },
347};
348
349static struct platform_device em_x270_nand = {
350 .name = "gen_nand",
351 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
352 .resource = em_x270_nand_resource,
353 .id = -1,
354 .dev = {
355 .platform_data = &em_x270_nand_platdata,
356 }
357};
358
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100359static void __init em_x270_init_nand(void)
360{
361 int err;
Mike Rapoport3d505272007-07-18 11:31:46 +0100362
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100363 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
364 if (err) {
365 pr_warning("EM-X270: failed to request NAND CS gpio\n");
366 return;
367 }
368
369 gpio_direction_output(GPIO11_NAND_CS, 1);
370
371 err = gpio_request(GPIO56_NAND_RB, "NAND R/B");
372 if (err) {
373 pr_warning("EM-X270: failed to request NAND R/B gpio\n");
374 gpio_free(GPIO11_NAND_CS);
375 return;
376 }
377
378 gpio_direction_input(GPIO56_NAND_RB);
379
380 platform_device_register(&em_x270_nand);
381}
382#else
383static inline void em_x270_init_nand(void) {}
384#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100385
Mike Rapoport28c88042008-12-03 09:38:10 +0200386#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
387static struct mtd_partition em_x270_nor_parts[] = {
388 {
389 .name = "Bootloader",
390 .offset = 0x00000000,
391 .size = 0x00050000,
392 .mask_flags = MTD_WRITEABLE /* force read-only */
393 }, {
394 .name = "Environment",
395 .offset = 0x00050000,
396 .size = 0x00010000,
397 }, {
398 .name = "Reserved",
399 .offset = 0x00060000,
400 .size = 0x00050000,
401 .mask_flags = MTD_WRITEABLE /* force read-only */
402 }, {
403 .name = "Splashscreen",
404 .offset = 0x000b0000,
405 .size = 0x00050000,
406 }
407};
408
409static struct physmap_flash_data em_x270_nor_data[] = {
410 [0] = {
411 .width = 2,
412 .parts = em_x270_nor_parts,
413 .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
414 },
415};
416
417static struct resource em_x270_nor_flash_resource = {
418 .start = PXA_CS0_PHYS,
419 .end = PXA_CS0_PHYS + SZ_1M - 1,
420 .flags = IORESOURCE_MEM,
421};
422
423static struct platform_device em_x270_physmap_flash = {
424 .name = "physmap-flash",
425 .id = 0,
426 .num_resources = 1,
427 .resource = &em_x270_nor_flash_resource,
428 .dev = {
429 .platform_data = &em_x270_nor_data,
430 },
431};
432
433static void __init em_x270_init_nor(void)
434{
435 platform_device_register(&em_x270_physmap_flash);
436}
437#else
438static inline void em_x270_init_nor(void) {}
439#endif
440
Mike Rapoport3d505272007-07-18 11:31:46 +0100441/* PXA27x OHCI controller setup */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100442#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Mike Rapoport3d505272007-07-18 11:31:46 +0100443static int em_x270_ohci_init(struct device *dev)
444{
Mike Rapoport3d505272007-07-18 11:31:46 +0100445 /* enable port 2 transiever */
446 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
447
448 return 0;
449}
450
451static struct pxaohci_platform_data em_x270_ohci_platform_data = {
452 .port_mode = PMM_PERPORT_MODE,
Eric Miao097b5332008-09-27 15:49:57 +0800453 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
Mike Rapoport3d505272007-07-18 11:31:46 +0100454 .init = em_x270_ohci_init,
455};
456
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100457static void __init em_x270_init_ohci(void)
458{
459 pxa_set_ohci_info(&em_x270_ohci_platform_data);
460}
461#else
462static inline void em_x270_init_ohci(void) {}
463#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100464
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100465/* MCI controller setup */
466#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
Mike Rapoport3d505272007-07-18 11:31:46 +0100467static int em_x270_mci_init(struct device *dev,
468 irq_handler_t em_x270_detect_int,
469 void *data)
470{
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100471 int err = request_irq(EM_X270_MMC_CD, em_x270_detect_int,
472 IRQF_DISABLED | IRQF_TRIGGER_FALLING,
473 "MMC card detect", data);
Mike Rapoport3d505272007-07-18 11:31:46 +0100474 if (err) {
475 printk(KERN_ERR "%s: can't request MMC card detect IRQ: %d\n",
Harvey Harrison8e86f422008-03-04 15:08:02 -0800476 __func__, err);
Mike Rapoport3d505272007-07-18 11:31:46 +0100477 return err;
478 }
479
480 return 0;
481}
482
483static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
484{
485 /*
486 FIXME: current hardware implementation does not allow to
487 enable/disable MMC power. This will be fixed in next HW releases,
488 and we'll need to add implmentation here.
489 */
490 return;
491}
492
493static void em_x270_mci_exit(struct device *dev, void *data)
494{
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100495 int irq = gpio_to_irq(GPIO13_MMC_CD);
496 free_irq(irq, data);
Mike Rapoport3d505272007-07-18 11:31:46 +0100497}
498
499static struct pxamci_platform_data em_x270_mci_platform_data = {
500 .ocr_mask = MMC_VDD_28_29|MMC_VDD_29_30|MMC_VDD_30_31,
501 .init = em_x270_mci_init,
502 .setpower = em_x270_mci_setpower,
503 .exit = em_x270_mci_exit,
504};
505
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100506static void __init em_x270_init_mmc(void)
507{
508 pxa_set_mci_info(&em_x270_mci_platform_data);
509}
510#else
511static inline void em_x270_init_mmc(void) {}
512#endif
513
Mike Rapoport28c88042008-12-03 09:38:10 +0200514/* LCD */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100515#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
Mike Rapoport28c88042008-12-03 09:38:10 +0200516static struct pxafb_mode_info em_x270_lcd_modes[] = {
517 [0] = {
518 .pixclock = 38250,
519 .bpp = 16,
520 .xres = 480,
521 .yres = 640,
522 .hsync_len = 8,
523 .vsync_len = 2,
524 .left_margin = 8,
525 .upper_margin = 2,
526 .right_margin = 24,
527 .lower_margin = 4,
528 .sync = 0,
529 },
530 [1] = {
531 .pixclock = 153800,
532 .bpp = 16,
533 .xres = 240,
534 .yres = 320,
535 .hsync_len = 8,
536 .vsync_len = 2,
537 .left_margin = 8,
538 .upper_margin = 2,
539 .right_margin = 88,
540 .lower_margin = 2,
541 .sync = 0,
542 },
Mike Rapoport3d505272007-07-18 11:31:46 +0100543};
544
545static struct pxafb_mach_info em_x270_lcd = {
Mike Rapoport28c88042008-12-03 09:38:10 +0200546 .modes = em_x270_lcd_modes,
547 .num_modes = 2,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100548 .lcd_conn = LCD_COLOR_TFT_16BPP,
Mike Rapoport3d505272007-07-18 11:31:46 +0100549};
Mike Rapoport28c88042008-12-03 09:38:10 +0200550
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100551static void __init em_x270_init_lcd(void)
552{
553 set_pxa_fb_info(&em_x270_lcd);
554}
555#else
556static inline void em_x270_init_lcd(void) {}
557#endif
558
Mike Rapoport28c88042008-12-03 09:38:10 +0200559#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
560static struct pxa2xx_spi_master em_x270_spi_info = {
561 .num_chipselect = 1,
562};
563
564static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
565 .rx_threshold = 1,
566 .tx_threshold = 1,
567};
568
569static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
570 .model = TDO35S,
571};
572
573static struct spi_board_info em_x270_spi_devices[] __initdata = {
574 {
575 .modalias = "tdo24m",
576 .max_speed_hz = 1000000,
577 .bus_num = 1,
578 .chip_select = 0,
579 .controller_data = &em_x270_tdo24m_chip,
580 .platform_data = &em_x270_tdo24m_pdata,
581 },
582};
583
584static void __init em_x270_init_spi(void)
585{
586 pxa2xx_set_spi_info(1, &em_x270_spi_info);
587 spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
588}
589#else
590static inline void em_x270_init_spi(void) {}
591#endif
592
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100593#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
594static void __init em_x270_init_ac97(void)
595{
596 pxa_set_ac97_info(NULL);
597}
598#else
599static inline void em_x270_init_ac97(void) {}
600#endif
601
602#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
603static unsigned int em_x270_matrix_keys[] = {
604 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
605 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
606 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
607};
608
609struct pxa27x_keypad_platform_data em_x270_keypad_info = {
610 /* code map for the matrix keys */
611 .matrix_key_rows = 3,
612 .matrix_key_cols = 3,
613 .matrix_key_map = em_x270_matrix_keys,
614 .matrix_key_map_size = ARRAY_SIZE(em_x270_matrix_keys),
615};
616
617static void __init em_x270_init_keypad(void)
618{
619 pxa_set_keypad_info(&em_x270_keypad_info);
620}
621#else
622static inline void em_x270_init_keypad(void) {}
623#endif
624
625#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
626static struct gpio_keys_button gpio_keys_button[] = {
627 [0] = {
628 .desc = "sleep/wakeup",
629 .code = KEY_SUSPEND,
630 .type = EV_PWR,
631 .gpio = 1,
632 .wakeup = 1,
633 },
634};
635
636static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
637 .buttons = gpio_keys_button,
638 .nbuttons = 1,
639};
640
641static struct platform_device em_x270_gpio_keys = {
642 .name = "gpio-keys",
643 .id = -1,
644 .dev = {
645 .platform_data = &em_x270_gpio_keys_data,
646 },
647};
648
649static void __init em_x270_init_gpio_keys(void)
650{
651 platform_device_register(&em_x270_gpio_keys);
652}
653#else
654static inline void em_x270_init_gpio_keys(void) {}
655#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100656
Mike Rapoport28c88042008-12-03 09:38:10 +0200657/* Quick Capture Interface and sensor setup */
658#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
659static struct regulator *em_x270_camera_ldo;
660
661static int em_x270_sensor_init(struct device *dev)
662{
663 int ret;
664
665 ret = gpio_request(GPIO93_CAM_RESET, "camera reset");
666 if (ret)
667 return ret;
668
669 gpio_direction_output(GPIO93_CAM_RESET, 0);
670
671 em_x270_camera_ldo = regulator_get(NULL, "vcc cam");
672 if (em_x270_camera_ldo == NULL) {
673 gpio_free(GPIO93_CAM_RESET);
674 return -ENODEV;
675 }
676
677 ret = regulator_enable(em_x270_camera_ldo);
678 if (ret) {
679 regulator_put(em_x270_camera_ldo);
680 gpio_free(GPIO93_CAM_RESET);
681 return ret;
682 }
683
684 gpio_set_value(GPIO93_CAM_RESET, 1);
685
686 return 0;
687}
688
689struct pxacamera_platform_data em_x270_camera_platform_data = {
690 .init = em_x270_sensor_init,
691 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
692 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
693 .mclk_10khz = 2600,
694};
695
696static int em_x270_sensor_power(struct device *dev, int on)
697{
698 int ret;
699 int is_on = regulator_is_enabled(em_x270_camera_ldo);
700
701 if (on == is_on)
702 return 0;
703
704 gpio_set_value(GPIO93_CAM_RESET, !on);
705
706 if (on)
707 ret = regulator_enable(em_x270_camera_ldo);
708 else
709 ret = regulator_disable(em_x270_camera_ldo);
710
711 if (ret)
712 return ret;
713
714 gpio_set_value(GPIO93_CAM_RESET, on);
715
716 return 0;
717}
718
719static struct soc_camera_link iclink = {
720 .bus_id = 0,
721 .power = em_x270_sensor_power,
722};
723
724static struct i2c_board_info em_x270_i2c_cam_info[] = {
725 {
726 I2C_BOARD_INFO("mt9m111", 0x48),
727 .platform_data = &iclink,
728 },
729};
730
731static struct i2c_pxa_platform_data em_x270_i2c_info = {
732 .fast_mode = 1,
733};
734
735static void __init em_x270_init_camera(void)
736{
737 pxa_set_i2c_info(&em_x270_i2c_info);
738 i2c_register_board_info(0, ARRAY_AND_SIZE(em_x270_i2c_cam_info));
739 pxa_set_camera_info(&em_x270_camera_platform_data);
740}
741#else
742static inline void em_x270_init_camera(void) {}
743#endif
744
745/* DA9030 related initializations */
746static struct regulator_consumer_supply ldo3_consumers[] = {
747 {
748 .dev = NULL,
749 .supply = "vcc gps",
750 },
751};
752
753static struct regulator_consumer_supply ldo5_consumers[] = {
754 {
755 .dev = NULL,
756 .supply = "vcc cam",
757 },
758};
759
760static struct regulator_consumer_supply ldo12_consumers[] = {
761 {
762 .dev = NULL,
763 .supply = "vcc usb",
764 },
765};
766
767static struct regulator_consumer_supply ldo19_consumers[] = {
768 {
769 .dev = NULL,
770 .supply = "vcc gprs",
771 },
772};
773
774static struct regulator_init_data ldo3_data = {
775 .constraints = {
776 .min_uV = 3200000,
777 .max_uV = 3200000,
778 .state_mem = {
779 .enabled = 0,
780 },
781 },
782 .num_consumer_supplies = ARRAY_SIZE(ldo3_consumers),
783 .consumer_supplies = ldo3_consumers,
784};
785
786static struct regulator_init_data ldo5_data = {
787 .constraints = {
788 .min_uV = 3000000,
789 .max_uV = 3000000,
790 .state_mem = {
791 .enabled = 0,
792 },
793 },
794 .num_consumer_supplies = ARRAY_SIZE(ldo5_consumers),
795 .consumer_supplies = ldo5_consumers,
796};
797
798static struct regulator_init_data ldo12_data = {
799 .constraints = {
800 .min_uV = 3000000,
801 .max_uV = 3000000,
802 .state_mem = {
803 .enabled = 0,
804 },
805 },
806 .num_consumer_supplies = ARRAY_SIZE(ldo12_consumers),
807 .consumer_supplies = ldo12_consumers,
808};
809
810static struct regulator_init_data ldo19_data = {
811 .constraints = {
812 .min_uV = 3200000,
813 .max_uV = 3200000,
814 .state_mem = {
815 .enabled = 0,
816 },
817 },
818 .num_consumer_supplies = ARRAY_SIZE(ldo19_consumers),
819 .consumer_supplies = ldo19_consumers,
820};
821
822struct led_info em_x270_led_info = {
823 .name = "em-x270:orange",
824 .default_trigger = "battery-charging-or-full",
825};
826
827struct da903x_subdev_info em_x270_da9030_subdevs[] = {
828 {
829 .name = "da903x-regulator",
830 .id = DA9030_ID_LDO3,
831 .platform_data = &ldo3_data,
832 }, {
833 .name = "da903x-regulator",
834 .id = DA9030_ID_LDO5,
835 .platform_data = &ldo5_data,
836 }, {
837 .name = "da903x-regulator",
838 .id = DA9030_ID_LDO12,
839 .platform_data = &ldo12_data,
840 }, {
841 .name = "da903x-regulator",
842 .id = DA9030_ID_LDO19,
843 .platform_data = &ldo19_data,
844 }, {
845 .name = "da903x-led",
846 .id = DA9030_ID_LED_PC,
847 .platform_data = &em_x270_led_info,
848 }, {
849 .name = "da903x-backlight",
850 .id = DA9030_ID_WLED,
851 }
852};
853
854static struct da903x_platform_data em_x270_da9030_info = {
855 .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
856 .subdevs = em_x270_da9030_subdevs,
857};
858
859static struct i2c_board_info em_x270_i2c_pmic_info = {
860 I2C_BOARD_INFO("da9030", 0x49),
861 .irq = IRQ_GPIO(0),
862 .platform_data = &em_x270_da9030_info,
863};
864
865static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
866 .use_pio = 1,
867};
868
869static void __init em_x270_init_da9030(void)
870{
871 pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
872 i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
873}
874
Mike Rapoport3d505272007-07-18 11:31:46 +0100875static void __init em_x270_init(void)
876{
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100877 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
Mike Rapoport3d505272007-07-18 11:31:46 +0100878
Mike Rapoport28c88042008-12-03 09:38:10 +0200879 em_x270_init_da9030();
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100880 em_x270_init_dm9000();
881 em_x270_init_rtc();
882 em_x270_init_nand();
Mike Rapoport28c88042008-12-03 09:38:10 +0200883 em_x270_init_nor();
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100884 em_x270_init_lcd();
885 em_x270_init_mmc();
886 em_x270_init_ohci();
887 em_x270_init_keypad();
888 em_x270_init_gpio_keys();
889 em_x270_init_ac97();
Mike Rapoport28c88042008-12-03 09:38:10 +0200890 em_x270_init_camera();
891 em_x270_init_spi();
Mike Rapoport3d505272007-07-18 11:31:46 +0100892}
893
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100894MACHINE_START(EM_X270, "Compulab EM-X270")
Mike Rapoport3d505272007-07-18 11:31:46 +0100895 .boot_params = 0xa0000100,
896 .phys_io = 0x40000000,
897 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
898 .map_io = pxa_map_io,
899 .init_irq = pxa27x_init_irq,
900 .timer = &pxa_timer,
901 .init_machine = em_x270_init,
902MACHINE_END