blob: f6726bb4eb954bf1cdaf073b4940269137673916 [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>
Mike Rapoport7f14a782009-02-02 08:57:55 +020014#include <linux/delay.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010015
16#include <linux/dm9000.h>
17#include <linux/rtc-v3020.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010018#include <linux/mtd/nand.h>
19#include <linux/mtd/partitions.h>
Mike Rapoport28c88042008-12-03 09:38:10 +020020#include <linux/mtd/physmap.h>
Mike Rapoport3c85bce2008-06-16 08:16:46 +010021#include <linux/input.h>
22#include <linux/gpio_keys.h>
23#include <linux/gpio.h>
Mike Rapoport28c88042008-12-03 09:38:10 +020024#include <linux/mfd/da903x.h>
25#include <linux/regulator/machine.h>
26#include <linux/spi/spi.h>
27#include <linux/spi/tdo24m.h>
Mike Rapoportc9be0e32009-02-03 09:15:30 +020028#include <linux/spi/libertas_spi.h>
Sebastian Andrzej Siewior8348c252010-11-22 17:12:15 -080029#include <linux/spi/pxa2xx_spi.h>
Mike Rapoport9f055c42009-02-02 08:57:53 +020030#include <linux/power_supply.h>
31#include <linux/apm-emulation.h>
Mike Rapoport76e3fc32009-05-12 16:31:13 +030032#include <linux/i2c.h>
33#include <linux/i2c/pca953x.h>
Sebastian Andrzej Siewiorb4593962011-02-23 12:38:16 +010034#include <linux/i2c/pxa-i2c.h>
Mike Rapoporta37ed432009-05-18 08:53:56 +030035#include <linux/regulator/userspace-consumer.h>
Mike Rapoport28c88042008-12-03 09:38:10 +020036
37#include <media/soc_camera.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010038
39#include <asm/mach-types.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010040#include <asm/mach/arch.h>
41
Eric Miao51c62982009-01-02 23:17:22 +080042#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010043#include <mach/pxa27x-udc.h>
44#include <mach/audio.h>
Arnd Bergmann293b2da2012-08-24 15:16:48 +020045#include <linux/platform_data/video-pxafb.h>
46#include <linux/platform_data/usb-ohci-pxa27x.h>
47#include <linux/platform_data/mmc-pxamci.h>
48#include <linux/platform_data/keypad-pxa27x.h>
49#include <linux/platform_data/camera-pxa.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010050
51#include "generic.h"
Mike Rapoport6432f462009-02-02 08:57:51 +020052#include "devices.h"
Mike Rapoport3d505272007-07-18 11:31:46 +010053
Mike Rapoport7f14a782009-02-02 08:57:55 +020054/* EM-X270 specific GPIOs */
Mike Rapoport3c85bce2008-06-16 08:16:46 +010055#define GPIO13_MMC_CD (13)
Mike Rapoport6432f462009-02-02 08:57:51 +020056#define GPIO95_MMC_WP (95)
Mike Rapoport7f14a782009-02-02 08:57:55 +020057#define GPIO56_NAND_RB (56)
Mike Rapoport76e3fc32009-05-12 16:31:13 +030058#define GPIO93_CAM_RESET (93)
Mike Rapoport128d88b2009-05-12 16:31:16 +030059#define GPIO16_USB_HUB_RESET (16)
Mike Rapoport7f14a782009-02-02 08:57:55 +020060
61/* eXeda specific GPIOs */
62#define GPIO114_MMC_CD (114)
63#define GPIO20_NAND_RB (20)
64#define GPIO38_SD_PWEN (38)
Mike Rapoport76e3fc32009-05-12 16:31:13 +030065#define GPIO37_WLAN_RST (37)
66#define GPIO95_TOUCHPAD_INT (95)
67#define GPIO130_CAM_RESET (130)
Mike Rapoport128d88b2009-05-12 16:31:16 +030068#define GPIO10_USB_HUB_RESET (10)
Mike Rapoport7f14a782009-02-02 08:57:55 +020069
70/* common GPIOs */
71#define GPIO11_NAND_CS (11)
Mike Rapoport7f14a782009-02-02 08:57:55 +020072#define GPIO41_ETHIRQ (41)
Haojian Zhuang6384fda2011-10-10 14:21:08 +080073#define EM_X270_ETHIRQ PXA_GPIO_TO_IRQ(GPIO41_ETHIRQ)
Mike Rapoportc9be0e32009-02-03 09:15:30 +020074#define GPIO115_WLAN_PWEN (115)
75#define GPIO19_WLAN_STRAP (19)
Mike Rapoport128d88b2009-05-12 16:31:16 +030076#define GPIO9_USB_VBUS_EN (9)
Mike Rapoport28c88042008-12-03 09:38:10 +020077
Mike Rapoport4a697e82009-02-02 08:57:54 +020078static int mmc_cd;
79static int nand_rb;
80static int dm9000_flags;
Mike Rapoport76e3fc32009-05-12 16:31:13 +030081static int cam_reset;
Mike Rapoport128d88b2009-05-12 16:31:16 +030082static int usb_hub_reset;
Mike Rapoport4a697e82009-02-02 08:57:54 +020083
84static unsigned long common_pin_config[] = {
Mike Rapoport3c85bce2008-06-16 08:16:46 +010085 /* AC'97 */
86 GPIO28_AC97_BITCLK,
87 GPIO29_AC97_SDATA_IN_0,
88 GPIO30_AC97_SDATA_OUT,
89 GPIO31_AC97_SYNC,
90 GPIO98_AC97_SYSCLK,
91 GPIO113_AC97_nRESET,
92
93 /* BTUART */
94 GPIO42_BTUART_RXD,
95 GPIO43_BTUART_TXD,
96 GPIO44_BTUART_CTS,
97 GPIO45_BTUART_RTS,
98
99 /* STUART */
100 GPIO46_STUART_RXD,
101 GPIO47_STUART_TXD,
102
103 /* MCI controller */
104 GPIO32_MMC_CLK,
105 GPIO112_MMC_CMD,
106 GPIO92_MMC_DAT_0,
107 GPIO109_MMC_DAT_1,
108 GPIO110_MMC_DAT_2,
109 GPIO111_MMC_DAT_3,
110
111 /* LCD */
Eric Miaobedbda92010-01-04 11:37:14 +0800112 GPIOxx_LCD_TFT_16BPP,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100113
114 /* QCI */
115 GPIO84_CIF_FV,
116 GPIO25_CIF_LV,
117 GPIO53_CIF_MCLK,
118 GPIO54_CIF_PCLK,
119 GPIO81_CIF_DD_0,
120 GPIO55_CIF_DD_1,
121 GPIO51_CIF_DD_2,
122 GPIO50_CIF_DD_3,
123 GPIO52_CIF_DD_4,
124 GPIO48_CIF_DD_5,
125 GPIO17_CIF_DD_6,
126 GPIO12_CIF_DD_7,
127
128 /* I2C */
129 GPIO117_I2C_SCL,
130 GPIO118_I2C_SDA,
131
132 /* Keypad */
133 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
134 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
135 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
136 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
137 GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
138 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
139 GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
140 GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
141 GPIO103_KP_MKOUT_0,
142 GPIO104_KP_MKOUT_1,
143 GPIO105_KP_MKOUT_2,
144 GPIO106_KP_MKOUT_3,
145 GPIO107_KP_MKOUT_4,
146 GPIO108_KP_MKOUT_5,
147 GPIO96_KP_MKOUT_6,
148 GPIO22_KP_MKOUT_7,
149
150 /* SSP1 */
151 GPIO26_SSP1_RXD,
152 GPIO23_SSP1_SCLK,
153 GPIO24_SSP1_SFRM,
154 GPIO57_SSP1_TXD,
155
156 /* SSP2 */
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200157 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
158 GPIO14_GPIO,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100159 GPIO89_SSP2_TXD,
160 GPIO88_SSP2_RXD,
161
162 /* SDRAM and local bus */
163 GPIO15_nCS_1,
164 GPIO78_nCS_2,
165 GPIO79_nCS_3,
166 GPIO80_nCS_4,
167 GPIO49_nPWE,
168 GPIO18_RDY,
169
170 /* GPIO */
Mike Rapoport6432f462009-02-02 08:57:51 +0200171 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* sleep/resume button */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100172
173 /* power controls */
174 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
175 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
176
177 /* NAND controls */
178 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100179
180 /* interrupts */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100181 GPIO41_GPIO, /* DM9000 interrupt */
182};
183
Mike Rapoport4a697e82009-02-02 08:57:54 +0200184static unsigned long em_x270_pin_config[] = {
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300185 GPIO13_GPIO, /* MMC card detect */
Mike Rapoport128d88b2009-05-12 16:31:16 +0300186 GPIO16_GPIO, /* USB hub reset */
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300187 GPIO56_GPIO, /* NAND Ready/Busy */
188 GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
189 GPIO95_GPIO, /* MMC Write protect */
Mike Rapoport4a697e82009-02-02 08:57:54 +0200190};
191
Mike Rapoport7f14a782009-02-02 08:57:55 +0200192static unsigned long exeda_pin_config[] = {
Mike Rapoport128d88b2009-05-12 16:31:16 +0300193 GPIO10_GPIO, /* USB hub reset */
Mike Rapoport7f14a782009-02-02 08:57:55 +0200194 GPIO20_GPIO, /* NAND Ready/Busy */
195 GPIO38_GPIO | MFP_LPM_DRIVE_LOW, /* SD slot power */
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300196 GPIO95_GPIO, /* touchpad IRQ */
Mike Rapoport7f14a782009-02-02 08:57:55 +0200197 GPIO114_GPIO, /* MMC card detect */
198};
199
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100200#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
201static struct resource em_x270_dm9000_resource[] = {
Mike Rapoport3d505272007-07-18 11:31:46 +0100202 [0] = {
203 .start = PXA_CS2_PHYS,
204 .end = PXA_CS2_PHYS + 3,
205 .flags = IORESOURCE_MEM,
206 },
207 [1] = {
208 .start = PXA_CS2_PHYS + 8,
209 .end = PXA_CS2_PHYS + 8 + 0x3f,
210 .flags = IORESOURCE_MEM,
211 },
212 [2] = {
213 .start = EM_X270_ETHIRQ,
214 .end = EM_X270_ETHIRQ,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100215 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Mike Rapoport3d505272007-07-18 11:31:46 +0100216 }
217};
218
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100219static struct dm9000_plat_data em_x270_dm9000_platdata = {
Mike Rapoport4a697e82009-02-02 08:57:54 +0200220 .flags = DM9000_PLATF_NO_EEPROM,
Mike Rapoport3d505272007-07-18 11:31:46 +0100221};
222
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100223static struct platform_device em_x270_dm9000 = {
Mike Rapoport3d505272007-07-18 11:31:46 +0100224 .name = "dm9000",
225 .id = 0,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100226 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
227 .resource = em_x270_dm9000_resource,
Mike Rapoport3d505272007-07-18 11:31:46 +0100228 .dev = {
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100229 .platform_data = &em_x270_dm9000_platdata,
Mike Rapoport3d505272007-07-18 11:31:46 +0100230 }
231};
232
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100233static void __init em_x270_init_dm9000(void)
234{
Mike Rapoport4a697e82009-02-02 08:57:54 +0200235 em_x270_dm9000_platdata.flags |= dm9000_flags;
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100236 platform_device_register(&em_x270_dm9000);
237}
238#else
239static inline void em_x270_init_dm9000(void) {}
240#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100241
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100242/* V3020 RTC */
243#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
Mike Rapoport3d505272007-07-18 11:31:46 +0100244static struct resource em_x270_v3020_resource[] = {
245 [0] = {
246 .start = PXA_CS4_PHYS,
247 .end = PXA_CS4_PHYS + 3,
248 .flags = IORESOURCE_MEM,
249 },
250};
251
252static struct v3020_platform_data em_x270_v3020_platdata = {
253 .leftshift = 0,
254};
255
256static struct platform_device em_x270_rtc = {
257 .name = "v3020",
258 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
259 .resource = em_x270_v3020_resource,
260 .id = -1,
261 .dev = {
262 .platform_data = &em_x270_v3020_platdata,
263 }
264};
265
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100266static void __init em_x270_init_rtc(void)
267{
268 platform_device_register(&em_x270_rtc);
269}
270#else
271static inline void em_x270_init_rtc(void) {}
272#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100273
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100274/* NAND flash */
275#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
Mike Rapoport3d505272007-07-18 11:31:46 +0100276static inline void nand_cs_on(void)
277{
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100278 gpio_set_value(GPIO11_NAND_CS, 0);
Mike Rapoport3d505272007-07-18 11:31:46 +0100279}
280
281static void nand_cs_off(void)
282{
283 dsb();
284
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100285 gpio_set_value(GPIO11_NAND_CS, 1);
Mike Rapoport3d505272007-07-18 11:31:46 +0100286}
287
288/* hardware specific access to control-lines */
289static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
290 unsigned int ctrl)
291{
292 struct nand_chip *this = mtd->priv;
293 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
294
295 dsb();
296
297 if (ctrl & NAND_CTRL_CHANGE) {
298 if (ctrl & NAND_ALE)
299 nandaddr |= (1 << 3);
300 else
301 nandaddr &= ~(1 << 3);
302 if (ctrl & NAND_CLE)
303 nandaddr |= (1 << 2);
304 else
305 nandaddr &= ~(1 << 2);
306 if (ctrl & NAND_NCE)
307 nand_cs_on();
308 else
309 nand_cs_off();
310 }
311
312 dsb();
313 this->IO_ADDR_W = (void __iomem *)nandaddr;
314 if (dat != NAND_CMD_NONE)
315 writel(dat, this->IO_ADDR_W);
316
317 dsb();
318}
319
320/* read device ready pin */
321static int em_x270_nand_device_ready(struct mtd_info *mtd)
322{
323 dsb();
324
Mike Rapoport4a697e82009-02-02 08:57:54 +0200325 return gpio_get_value(nand_rb);
Mike Rapoport3d505272007-07-18 11:31:46 +0100326}
327
328static struct mtd_partition em_x270_partition_info[] = {
329 [0] = {
330 .name = "em_x270-0",
331 .offset = 0,
332 .size = SZ_4M,
333 },
334 [1] = {
335 .name = "em_x270-1",
336 .offset = MTDPART_OFS_APPEND,
337 .size = MTDPART_SIZ_FULL
338 },
339};
340
Mike Rapoport3d505272007-07-18 11:31:46 +0100341struct platform_nand_data em_x270_nand_platdata = {
342 .chip = {
343 .nr_chips = 1,
344 .chip_offset = 0,
345 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
346 .partitions = em_x270_partition_info,
347 .chip_delay = 20,
Mike Rapoport3d505272007-07-18 11:31:46 +0100348 },
349 .ctrl = {
350 .hwcontrol = 0,
351 .dev_ready = em_x270_nand_device_ready,
352 .select_chip = 0,
353 .cmd_ctrl = em_x270_nand_cmd_ctl,
354 },
355};
356
357static struct resource em_x270_nand_resource[] = {
358 [0] = {
359 .start = PXA_CS1_PHYS,
360 .end = PXA_CS1_PHYS + 12,
361 .flags = IORESOURCE_MEM,
362 },
363};
364
365static struct platform_device em_x270_nand = {
366 .name = "gen_nand",
367 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
368 .resource = em_x270_nand_resource,
369 .id = -1,
370 .dev = {
371 .platform_data = &em_x270_nand_platdata,
372 }
373};
374
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100375static void __init em_x270_init_nand(void)
376{
377 int err;
Mike Rapoport3d505272007-07-18 11:31:46 +0100378
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100379 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
380 if (err) {
381 pr_warning("EM-X270: failed to request NAND CS gpio\n");
382 return;
383 }
384
385 gpio_direction_output(GPIO11_NAND_CS, 1);
386
Mike Rapoport4a697e82009-02-02 08:57:54 +0200387 err = gpio_request(nand_rb, "NAND R/B");
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100388 if (err) {
389 pr_warning("EM-X270: failed to request NAND R/B gpio\n");
390 gpio_free(GPIO11_NAND_CS);
391 return;
392 }
393
Mike Rapoport4a697e82009-02-02 08:57:54 +0200394 gpio_direction_input(nand_rb);
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100395
396 platform_device_register(&em_x270_nand);
397}
398#else
399static inline void em_x270_init_nand(void) {}
400#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100401
Mike Rapoport28c88042008-12-03 09:38:10 +0200402#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
403static struct mtd_partition em_x270_nor_parts[] = {
404 {
405 .name = "Bootloader",
406 .offset = 0x00000000,
407 .size = 0x00050000,
408 .mask_flags = MTD_WRITEABLE /* force read-only */
409 }, {
410 .name = "Environment",
411 .offset = 0x00050000,
412 .size = 0x00010000,
413 }, {
414 .name = "Reserved",
415 .offset = 0x00060000,
416 .size = 0x00050000,
417 .mask_flags = MTD_WRITEABLE /* force read-only */
418 }, {
419 .name = "Splashscreen",
420 .offset = 0x000b0000,
421 .size = 0x00050000,
422 }
423};
424
425static struct physmap_flash_data em_x270_nor_data[] = {
426 [0] = {
427 .width = 2,
428 .parts = em_x270_nor_parts,
429 .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
430 },
431};
432
433static struct resource em_x270_nor_flash_resource = {
434 .start = PXA_CS0_PHYS,
435 .end = PXA_CS0_PHYS + SZ_1M - 1,
436 .flags = IORESOURCE_MEM,
437};
438
439static struct platform_device em_x270_physmap_flash = {
440 .name = "physmap-flash",
441 .id = 0,
442 .num_resources = 1,
443 .resource = &em_x270_nor_flash_resource,
444 .dev = {
445 .platform_data = &em_x270_nor_data,
446 },
447};
448
449static void __init em_x270_init_nor(void)
450{
451 platform_device_register(&em_x270_physmap_flash);
452}
453#else
454static inline void em_x270_init_nor(void) {}
455#endif
456
Mike Rapoport3d505272007-07-18 11:31:46 +0100457/* PXA27x OHCI controller setup */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100458#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Mike Rapoport128d88b2009-05-12 16:31:16 +0300459static struct regulator *em_x270_usb_ldo;
460
461static int em_x270_usb_hub_init(void)
462{
463 int err;
464
465 em_x270_usb_ldo = regulator_get(NULL, "vcc usb");
466 if (IS_ERR(em_x270_usb_ldo))
467 return PTR_ERR(em_x270_usb_ldo);
468
469 err = gpio_request(GPIO9_USB_VBUS_EN, "vbus en");
470 if (err)
471 goto err_free_usb_ldo;
472
473 err = gpio_request(usb_hub_reset, "hub rst");
474 if (err)
475 goto err_free_vbus_gpio;
476
477 /* USB Hub power-on and reset */
Igor Grinberg1b82e4c2009-12-06 15:45:43 +0200478 gpio_direction_output(usb_hub_reset, 1);
479 gpio_direction_output(GPIO9_USB_VBUS_EN, 0);
Mike Rapoport128d88b2009-05-12 16:31:16 +0300480 regulator_enable(em_x270_usb_ldo);
Mike Rapoport128d88b2009-05-12 16:31:16 +0300481 gpio_set_value(usb_hub_reset, 0);
Igor Grinberg1b82e4c2009-12-06 15:45:43 +0200482 gpio_set_value(usb_hub_reset, 1);
Mike Rapoport128d88b2009-05-12 16:31:16 +0300483 regulator_disable(em_x270_usb_ldo);
484 regulator_enable(em_x270_usb_ldo);
Igor Grinberg1b82e4c2009-12-06 15:45:43 +0200485 gpio_set_value(usb_hub_reset, 0);
486 gpio_set_value(GPIO9_USB_VBUS_EN, 1);
Mike Rapoport128d88b2009-05-12 16:31:16 +0300487
488 return 0;
489
490err_free_vbus_gpio:
491 gpio_free(GPIO9_USB_VBUS_EN);
492err_free_usb_ldo:
493 regulator_put(em_x270_usb_ldo);
494
495 return err;
496}
497
Mike Rapoport3d505272007-07-18 11:31:46 +0100498static int em_x270_ohci_init(struct device *dev)
499{
Mike Rapoport128d88b2009-05-12 16:31:16 +0300500 int err;
501
502 /* we don't want to entirely disable USB if the HUB init failed */
503 err = em_x270_usb_hub_init();
504 if (err)
505 pr_err("USB Hub initialization failed: %d\n", err);
506
Mike Rapoport3d505272007-07-18 11:31:46 +0100507 /* enable port 2 transiever */
508 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
509
510 return 0;
511}
512
Mike Rapoport128d88b2009-05-12 16:31:16 +0300513static void em_x270_ohci_exit(struct device *dev)
514{
515 gpio_free(usb_hub_reset);
516 gpio_free(GPIO9_USB_VBUS_EN);
517
518 if (!IS_ERR(em_x270_usb_ldo)) {
519 if (regulator_is_enabled(em_x270_usb_ldo))
520 regulator_disable(em_x270_usb_ldo);
521
522 regulator_put(em_x270_usb_ldo);
523 }
524}
525
Mike Rapoport3d505272007-07-18 11:31:46 +0100526static struct pxaohci_platform_data em_x270_ohci_platform_data = {
527 .port_mode = PMM_PERPORT_MODE,
Eric Miao097b5332008-09-27 15:49:57 +0800528 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
Mike Rapoport3d505272007-07-18 11:31:46 +0100529 .init = em_x270_ohci_init,
Mike Rapoport128d88b2009-05-12 16:31:16 +0300530 .exit = em_x270_ohci_exit,
Mike Rapoport3d505272007-07-18 11:31:46 +0100531};
532
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100533static void __init em_x270_init_ohci(void)
534{
535 pxa_set_ohci_info(&em_x270_ohci_platform_data);
536}
537#else
538static inline void em_x270_init_ohci(void) {}
539#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100540
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100541/* MCI controller setup */
542#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
Mike Rapoport6432f462009-02-02 08:57:51 +0200543static struct regulator *em_x270_sdio_ldo;
544
Mike Rapoport3d505272007-07-18 11:31:46 +0100545static int em_x270_mci_init(struct device *dev,
546 irq_handler_t em_x270_detect_int,
547 void *data)
548{
Mike Rapoport6432f462009-02-02 08:57:51 +0200549 int err;
550
551 em_x270_sdio_ldo = regulator_get(dev, "vcc sdio");
552 if (IS_ERR(em_x270_sdio_ldo)) {
553 dev_err(dev, "can't request SDIO power supply: %ld\n",
554 PTR_ERR(em_x270_sdio_ldo));
555 return PTR_ERR(em_x270_sdio_ldo);
Mike Rapoport3d505272007-07-18 11:31:46 +0100556 }
557
Mike Rapoport4a697e82009-02-02 08:57:54 +0200558 err = request_irq(gpio_to_irq(mmc_cd), em_x270_detect_int,
Mike Rapoport6432f462009-02-02 08:57:51 +0200559 IRQF_DISABLED | IRQF_TRIGGER_RISING |
560 IRQF_TRIGGER_FALLING,
561 "MMC card detect", data);
562 if (err) {
563 dev_err(dev, "can't request MMC card detect IRQ: %d\n", err);
564 goto err_irq;
565 }
566
Mike Rapoport7f14a782009-02-02 08:57:55 +0200567 if (machine_is_em_x270()) {
568 err = gpio_request(GPIO95_MMC_WP, "MMC WP");
569 if (err) {
570 dev_err(dev, "can't request MMC write protect: %d\n",
571 err);
572 goto err_gpio_wp;
573 }
574 gpio_direction_input(GPIO95_MMC_WP);
575 } else {
576 err = gpio_request(GPIO38_SD_PWEN, "sdio power");
577 if (err) {
578 dev_err(dev, "can't request MMC power control : %d\n",
579 err);
580 goto err_gpio_wp;
581 }
582 gpio_direction_output(GPIO38_SD_PWEN, 1);
Mike Rapoport6432f462009-02-02 08:57:51 +0200583 }
584
Mike Rapoport3d505272007-07-18 11:31:46 +0100585 return 0;
Mike Rapoport6432f462009-02-02 08:57:51 +0200586
587err_gpio_wp:
Mike Rapoport4a697e82009-02-02 08:57:54 +0200588 free_irq(gpio_to_irq(mmc_cd), data);
Mike Rapoport6432f462009-02-02 08:57:51 +0200589err_irq:
590 regulator_put(em_x270_sdio_ldo);
591
592 return err;
Mike Rapoport3d505272007-07-18 11:31:46 +0100593}
594
595static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
596{
Mike Rapoport6432f462009-02-02 08:57:51 +0200597 struct pxamci_platform_data* p_d = dev->platform_data;
598
599 if ((1 << vdd) & p_d->ocr_mask) {
600 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
601
602 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
603 regulator_enable(em_x270_sdio_ldo);
604 } else {
605 regulator_disable(em_x270_sdio_ldo);
606 }
Mike Rapoport3d505272007-07-18 11:31:46 +0100607}
608
609static void em_x270_mci_exit(struct device *dev, void *data)
610{
Mike Rapoport4a697e82009-02-02 08:57:54 +0200611 free_irq(gpio_to_irq(mmc_cd), data);
Mike Rapoport7f14a782009-02-02 08:57:55 +0200612 regulator_put(em_x270_sdio_ldo);
613
614 if (machine_is_em_x270())
615 gpio_free(GPIO95_MMC_WP);
616 else
617 gpio_free(GPIO38_SD_PWEN);
Mike Rapoport6432f462009-02-02 08:57:51 +0200618}
619
620static int em_x270_mci_get_ro(struct device *dev)
621{
622 return gpio_get_value(GPIO95_MMC_WP);
Mike Rapoport3d505272007-07-18 11:31:46 +0100623}
624
625static struct pxamci_platform_data em_x270_mci_platform_data = {
Eric Miaof97cab22010-04-14 07:00:42 +0800626 .detect_delay_ms = 250,
Robert Jarzmik7a648252009-07-06 22:16:42 +0200627 .ocr_mask = MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23|
628 MMC_VDD_24_25|MMC_VDD_25_26|MMC_VDD_26_27|
629 MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
630 MMC_VDD_30_31|MMC_VDD_31_32,
631 .init = em_x270_mci_init,
632 .setpower = em_x270_mci_setpower,
633 .exit = em_x270_mci_exit,
634 .gpio_card_detect = -1,
635 .gpio_card_ro = -1,
636 .gpio_power = -1,
Mike Rapoport3d505272007-07-18 11:31:46 +0100637};
638
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100639static void __init em_x270_init_mmc(void)
640{
Mike Rapoport7f14a782009-02-02 08:57:55 +0200641 if (machine_is_em_x270())
642 em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro;
643
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100644 pxa_set_mci_info(&em_x270_mci_platform_data);
645}
646#else
647static inline void em_x270_init_mmc(void) {}
648#endif
649
Mike Rapoport28c88042008-12-03 09:38:10 +0200650/* LCD */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100651#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
Mike Rapoport28c88042008-12-03 09:38:10 +0200652static struct pxafb_mode_info em_x270_lcd_modes[] = {
653 [0] = {
654 .pixclock = 38250,
655 .bpp = 16,
656 .xres = 480,
657 .yres = 640,
658 .hsync_len = 8,
659 .vsync_len = 2,
660 .left_margin = 8,
661 .upper_margin = 2,
662 .right_margin = 24,
663 .lower_margin = 4,
664 .sync = 0,
665 },
666 [1] = {
667 .pixclock = 153800,
668 .bpp = 16,
669 .xres = 240,
670 .yres = 320,
671 .hsync_len = 8,
672 .vsync_len = 2,
673 .left_margin = 8,
674 .upper_margin = 2,
675 .right_margin = 88,
676 .lower_margin = 2,
677 .sync = 0,
678 },
Mike Rapoport3d505272007-07-18 11:31:46 +0100679};
680
681static struct pxafb_mach_info em_x270_lcd = {
Mike Rapoport28c88042008-12-03 09:38:10 +0200682 .modes = em_x270_lcd_modes,
683 .num_modes = 2,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100684 .lcd_conn = LCD_COLOR_TFT_16BPP,
Mike Rapoport3d505272007-07-18 11:31:46 +0100685};
Mike Rapoport28c88042008-12-03 09:38:10 +0200686
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100687static void __init em_x270_init_lcd(void)
688{
Russell King - ARM Linux4321e1a2011-02-15 15:37:30 +0800689 pxa_set_fb_info(NULL, &em_x270_lcd);
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100690}
691#else
692static inline void em_x270_init_lcd(void) {}
693#endif
694
Mike Rapoport28c88042008-12-03 09:38:10 +0200695#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
696static struct pxa2xx_spi_master em_x270_spi_info = {
697 .num_chipselect = 1,
698};
699
700static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
Mike Rapoportbd9d0742009-04-14 08:32:55 +0300701 .rx_threshold = 1,
702 .tx_threshold = 1,
703 .gpio_cs = -1,
Mike Rapoport28c88042008-12-03 09:38:10 +0200704};
705
706static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
707 .model = TDO35S,
708};
709
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200710static struct pxa2xx_spi_master em_x270_spi_2_info = {
711 .num_chipselect = 1,
712 .enable_dma = 1,
713};
714
715static struct pxa2xx_spi_chip em_x270_libertas_chip = {
716 .rx_threshold = 1,
717 .tx_threshold = 1,
718 .timeout = 1000,
Mike Rapoport3cb05c92009-06-16 15:19:24 +0300719 .gpio_cs = 14,
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200720};
721
722static unsigned long em_x270_libertas_pin_config[] = {
723 /* SSP2 */
724 GPIO19_SSP2_SCLK,
725 GPIO14_GPIO,
726 GPIO89_SSP2_TXD,
727 GPIO88_SSP2_RXD,
728};
729
730static int em_x270_libertas_setup(struct spi_device *spi)
731{
732 int err = gpio_request(GPIO115_WLAN_PWEN, "WLAN PWEN");
733 if (err)
734 return err;
735
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300736 err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
737 if (err)
738 goto err_free_pwen;
739
740 if (machine_is_exeda()) {
741 err = gpio_request(GPIO37_WLAN_RST, "WLAN RST");
742 if (err)
743 goto err_free_strap;
744
745 gpio_direction_output(GPIO37_WLAN_RST, 1);
746 msleep(100);
747 }
748
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200749 gpio_direction_output(GPIO19_WLAN_STRAP, 1);
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300750 msleep(100);
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200751
752 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_libertas_pin_config));
753
754 gpio_direction_output(GPIO115_WLAN_PWEN, 0);
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300755 msleep(100);
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200756 gpio_set_value(GPIO115_WLAN_PWEN, 1);
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300757 msleep(100);
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200758
759 spi->bits_per_word = 16;
760 spi_setup(spi);
761
762 return 0;
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300763
764err_free_strap:
765 gpio_free(GPIO19_WLAN_STRAP);
766err_free_pwen:
767 gpio_free(GPIO115_WLAN_PWEN);
768
769 return err;
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200770}
771
772static int em_x270_libertas_teardown(struct spi_device *spi)
773{
774 gpio_set_value(GPIO115_WLAN_PWEN, 0);
775 gpio_free(GPIO115_WLAN_PWEN);
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300776 gpio_free(GPIO19_WLAN_STRAP);
777
778 if (machine_is_exeda()) {
779 gpio_set_value(GPIO37_WLAN_RST, 0);
780 gpio_free(GPIO37_WLAN_RST);
781 }
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200782
783 return 0;
784}
785
786struct libertas_spi_platform_data em_x270_libertas_pdata = {
787 .use_dummy_writes = 1,
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200788 .setup = em_x270_libertas_setup,
789 .teardown = em_x270_libertas_teardown,
790};
791
Mike Rapoport28c88042008-12-03 09:38:10 +0200792static struct spi_board_info em_x270_spi_devices[] __initdata = {
793 {
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200794 .modalias = "tdo24m",
795 .max_speed_hz = 1000000,
796 .bus_num = 1,
797 .chip_select = 0,
798 .controller_data = &em_x270_tdo24m_chip,
799 .platform_data = &em_x270_tdo24m_pdata,
800 },
801 {
802 .modalias = "libertas_spi",
803 .max_speed_hz = 13000000,
804 .bus_num = 2,
Haojian Zhuang6384fda2011-10-10 14:21:08 +0800805 .irq = PXA_GPIO_TO_IRQ(116),
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200806 .chip_select = 0,
807 .controller_data = &em_x270_libertas_chip,
808 .platform_data = &em_x270_libertas_pdata,
Mike Rapoport28c88042008-12-03 09:38:10 +0200809 },
810};
811
812static void __init em_x270_init_spi(void)
813{
814 pxa2xx_set_spi_info(1, &em_x270_spi_info);
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200815 pxa2xx_set_spi_info(2, &em_x270_spi_2_info);
Mike Rapoport28c88042008-12-03 09:38:10 +0200816 spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
817}
818#else
819static inline void em_x270_init_spi(void) {}
820#endif
821
Mike Rapoport303f2d72009-06-14 12:04:19 +0300822#if defined(CONFIG_SND_PXA2XX_LIB_AC97)
Mike Rapoportc63a5752009-05-11 15:06:16 +0300823static pxa2xx_audio_ops_t em_x270_ac97_info = {
824 .reset_gpio = 113,
825};
826
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100827static void __init em_x270_init_ac97(void)
828{
Mike Rapoportc63a5752009-05-11 15:06:16 +0300829 pxa_set_ac97_info(&em_x270_ac97_info);
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100830}
831#else
832static inline void em_x270_init_ac97(void) {}
833#endif
834
835#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
Chao Xie0a085a92013-05-05 20:24:58 -0700836static const unsigned int em_x270_module_matrix_keys[] = {
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100837 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
838 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
839 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
840};
841
Chao Xie0a085a92013-05-05 20:24:58 -0700842static struct matrix_keymap_data em_x270_matrix_keymap_data = {
843 .keymap = em_x270_module_matrix_keys,
844 .keymap_size = ARRAY_SIZE(em_x270_module_matrix_keys),
845};
846
Mike Rapoport7f14a782009-02-02 08:57:55 +0200847struct pxa27x_keypad_platform_data em_x270_module_keypad_info = {
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100848 /* code map for the matrix keys */
849 .matrix_key_rows = 3,
850 .matrix_key_cols = 3,
Chao Xie0a085a92013-05-05 20:24:58 -0700851 .matrix_keymap_data = &em_x270_matrix_keymap_data,
Mike Rapoport7f14a782009-02-02 08:57:55 +0200852};
853
Chao Xie0a085a92013-05-05 20:24:58 -0700854static const unsigned int em_x270_exeda_matrix_keys[] = {
Mike Rapoport7f14a782009-02-02 08:57:55 +0200855 KEY(0, 0, KEY_RIGHTSHIFT), KEY(0, 1, KEY_RIGHTCTRL),
856 KEY(0, 2, KEY_RIGHTALT), KEY(0, 3, KEY_SPACE),
857 KEY(0, 4, KEY_LEFTALT), KEY(0, 5, KEY_LEFTCTRL),
858 KEY(0, 6, KEY_ENTER), KEY(0, 7, KEY_SLASH),
859
860 KEY(1, 0, KEY_DOT), KEY(1, 1, KEY_M),
861 KEY(1, 2, KEY_N), KEY(1, 3, KEY_B),
862 KEY(1, 4, KEY_V), KEY(1, 5, KEY_C),
863 KEY(1, 6, KEY_X), KEY(1, 7, KEY_Z),
864
865 KEY(2, 0, KEY_LEFTSHIFT), KEY(2, 1, KEY_SEMICOLON),
866 KEY(2, 2, KEY_L), KEY(2, 3, KEY_K),
867 KEY(2, 4, KEY_J), KEY(2, 5, KEY_H),
868 KEY(2, 6, KEY_G), KEY(2, 7, KEY_F),
869
870 KEY(3, 0, KEY_D), KEY(3, 1, KEY_S),
871 KEY(3, 2, KEY_A), KEY(3, 3, KEY_TAB),
872 KEY(3, 4, KEY_BACKSPACE), KEY(3, 5, KEY_P),
873 KEY(3, 6, KEY_O), KEY(3, 7, KEY_I),
874
875 KEY(4, 0, KEY_U), KEY(4, 1, KEY_Y),
876 KEY(4, 2, KEY_T), KEY(4, 3, KEY_R),
877 KEY(4, 4, KEY_E), KEY(4, 5, KEY_W),
878 KEY(4, 6, KEY_Q), KEY(4, 7, KEY_MINUS),
879
880 KEY(5, 0, KEY_0), KEY(5, 1, KEY_9),
881 KEY(5, 2, KEY_8), KEY(5, 3, KEY_7),
882 KEY(5, 4, KEY_6), KEY(5, 5, KEY_5),
883 KEY(5, 6, KEY_4), KEY(5, 7, KEY_3),
884
885 KEY(6, 0, KEY_2), KEY(6, 1, KEY_1),
886 KEY(6, 2, KEY_ENTER), KEY(6, 3, KEY_END),
887 KEY(6, 4, KEY_DOWN), KEY(6, 5, KEY_UP),
888 KEY(6, 6, KEY_MENU), KEY(6, 7, KEY_F1),
889
890 KEY(7, 0, KEY_LEFT), KEY(7, 1, KEY_RIGHT),
891 KEY(7, 2, KEY_BACK), KEY(7, 3, KEY_HOME),
892 KEY(7, 4, 0), KEY(7, 5, 0),
893 KEY(7, 6, 0), KEY(7, 7, 0),
894};
895
Chao Xie0a085a92013-05-05 20:24:58 -0700896static struct matrix_keymap_data em_x270_exeda_matrix_keymap_data = {
897 .keymap = em_x270_exeda_matrix_keys,
898 .keymap_size = ARRAY_SIZE(em_x270_exeda_matrix_keys),
899};
900
Mike Rapoport7f14a782009-02-02 08:57:55 +0200901struct pxa27x_keypad_platform_data em_x270_exeda_keypad_info = {
902 /* code map for the matrix keys */
903 .matrix_key_rows = 8,
904 .matrix_key_cols = 8,
Chao Xie0a085a92013-05-05 20:24:58 -0700905 .matrix_keymap_data = &em_x270_exeda_matrix_keymap_data,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100906};
907
908static void __init em_x270_init_keypad(void)
909{
Mike Rapoport7f14a782009-02-02 08:57:55 +0200910 if (machine_is_em_x270())
911 pxa_set_keypad_info(&em_x270_module_keypad_info);
912 else
913 pxa_set_keypad_info(&em_x270_exeda_keypad_info);
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100914}
915#else
916static inline void em_x270_init_keypad(void) {}
917#endif
918
919#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
920static struct gpio_keys_button gpio_keys_button[] = {
921 [0] = {
922 .desc = "sleep/wakeup",
923 .code = KEY_SUSPEND,
924 .type = EV_PWR,
925 .gpio = 1,
926 .wakeup = 1,
927 },
928};
929
930static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
931 .buttons = gpio_keys_button,
932 .nbuttons = 1,
933};
934
935static struct platform_device em_x270_gpio_keys = {
936 .name = "gpio-keys",
937 .id = -1,
938 .dev = {
939 .platform_data = &em_x270_gpio_keys_data,
940 },
941};
942
943static void __init em_x270_init_gpio_keys(void)
944{
945 platform_device_register(&em_x270_gpio_keys);
946}
947#else
948static inline void em_x270_init_gpio_keys(void) {}
949#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100950
Mike Rapoport28c88042008-12-03 09:38:10 +0200951/* Quick Capture Interface and sensor setup */
952#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
953static struct regulator *em_x270_camera_ldo;
954
Antonio Ospitea7f2bdb32009-11-27 21:30:23 +0100955static int em_x270_sensor_init(void)
Mike Rapoport28c88042008-12-03 09:38:10 +0200956{
957 int ret;
958
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300959 ret = gpio_request(cam_reset, "camera reset");
Mike Rapoport28c88042008-12-03 09:38:10 +0200960 if (ret)
961 return ret;
962
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300963 gpio_direction_output(cam_reset, 0);
Mike Rapoport28c88042008-12-03 09:38:10 +0200964
965 em_x270_camera_ldo = regulator_get(NULL, "vcc cam");
966 if (em_x270_camera_ldo == NULL) {
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300967 gpio_free(cam_reset);
Mike Rapoport28c88042008-12-03 09:38:10 +0200968 return -ENODEV;
969 }
970
971 ret = regulator_enable(em_x270_camera_ldo);
972 if (ret) {
973 regulator_put(em_x270_camera_ldo);
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300974 gpio_free(cam_reset);
Mike Rapoport28c88042008-12-03 09:38:10 +0200975 return ret;
976 }
977
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300978 gpio_set_value(cam_reset, 1);
Mike Rapoport28c88042008-12-03 09:38:10 +0200979
980 return 0;
981}
982
983struct pxacamera_platform_data em_x270_camera_platform_data = {
Mike Rapoport28c88042008-12-03 09:38:10 +0200984 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
985 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
986 .mclk_10khz = 2600,
987};
988
989static int em_x270_sensor_power(struct device *dev, int on)
990{
991 int ret;
992 int is_on = regulator_is_enabled(em_x270_camera_ldo);
993
994 if (on == is_on)
995 return 0;
996
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300997 gpio_set_value(cam_reset, !on);
Mike Rapoport28c88042008-12-03 09:38:10 +0200998
999 if (on)
1000 ret = regulator_enable(em_x270_camera_ldo);
1001 else
1002 ret = regulator_disable(em_x270_camera_ldo);
1003
1004 if (ret)
1005 return ret;
1006
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001007 gpio_set_value(cam_reset, on);
Mike Rapoport28c88042008-12-03 09:38:10 +02001008
1009 return 0;
1010}
1011
Mike Rapoport28c88042008-12-03 09:38:10 +02001012static struct i2c_board_info em_x270_i2c_cam_info[] = {
1013 {
1014 I2C_BOARD_INFO("mt9m111", 0x48),
Guennadi Liakhovetski489db6a2009-05-12 18:12:29 +02001015 },
1016};
1017
1018static struct soc_camera_link iclink = {
1019 .bus_id = 0,
1020 .power = em_x270_sensor_power,
1021 .board_info = &em_x270_i2c_cam_info[0],
1022 .i2c_adapter_id = 0,
Guennadi Liakhovetski489db6a2009-05-12 18:12:29 +02001023};
1024
1025static struct platform_device em_x270_camera = {
1026 .name = "soc-camera-pdrv",
1027 .id = -1,
1028 .dev = {
Mike Rapoport28c88042008-12-03 09:38:10 +02001029 .platform_data = &iclink,
1030 },
1031};
1032
Mike Rapoport28c88042008-12-03 09:38:10 +02001033static void __init em_x270_init_camera(void)
1034{
Antonio Ospitea7f2bdb32009-11-27 21:30:23 +01001035 if (em_x270_sensor_init() == 0) {
1036 pxa_set_camera_info(&em_x270_camera_platform_data);
1037 platform_device_register(&em_x270_camera);
1038 }
Mike Rapoport28c88042008-12-03 09:38:10 +02001039}
1040#else
1041static inline void em_x270_init_camera(void) {}
1042#endif
1043
Mike Rapoporta37ed432009-05-18 08:53:56 +03001044static struct regulator_bulk_data em_x270_gps_consumer_supply = {
1045 .supply = "vcc gps",
1046};
1047
1048static struct regulator_userspace_consumer_data em_x270_gps_consumer_data = {
1049 .name = "vcc gps",
1050 .num_supplies = 1,
1051 .supplies = &em_x270_gps_consumer_supply,
1052};
1053
1054static struct platform_device em_x270_gps_userspace_consumer = {
1055 .name = "reg-userspace-consumer",
1056 .id = 0,
1057 .dev = {
1058 .platform_data = &em_x270_gps_consumer_data,
1059 },
1060};
1061
1062static struct regulator_bulk_data em_x270_gprs_consumer_supply = {
1063 .supply = "vcc gprs",
1064};
1065
1066static struct regulator_userspace_consumer_data em_x270_gprs_consumer_data = {
1067 .name = "vcc gprs",
1068 .num_supplies = 1,
1069 .supplies = &em_x270_gprs_consumer_supply
1070};
1071
1072static struct platform_device em_x270_gprs_userspace_consumer = {
1073 .name = "reg-userspace-consumer",
1074 .id = 1,
1075 .dev = {
1076 .platform_data = &em_x270_gprs_consumer_data,
1077 }
1078};
1079
1080static struct platform_device *em_x270_userspace_consumers[] = {
1081 &em_x270_gps_userspace_consumer,
1082 &em_x270_gprs_userspace_consumer,
1083};
1084
1085static void __init em_x270_userspace_consumers_init(void)
1086{
1087 platform_add_devices(ARRAY_AND_SIZE(em_x270_userspace_consumers));
1088}
1089
Mike Rapoport28c88042008-12-03 09:38:10 +02001090/* DA9030 related initializations */
Paul Gortmaker804d2312012-03-30 08:41:02 +08001091#define REGULATOR_CONSUMER(_name, _dev_name, _supply) \
Mike Rapoport432adf12009-02-02 08:57:52 +02001092 static struct regulator_consumer_supply _name##_consumers[] = { \
Axel Lin0bf189a2012-05-08 16:25:10 +08001093 REGULATOR_SUPPLY(_supply, _dev_name), \
Mike Rapoport432adf12009-02-02 08:57:52 +02001094 }
Mike Rapoport28c88042008-12-03 09:38:10 +02001095
Paul Gortmaker804d2312012-03-30 08:41:02 +08001096REGULATOR_CONSUMER(ldo3, "reg-userspace-consumer.0", "vcc gps");
Mike Rapoport432adf12009-02-02 08:57:52 +02001097REGULATOR_CONSUMER(ldo5, NULL, "vcc cam");
Paul Gortmaker804d2312012-03-30 08:41:02 +08001098REGULATOR_CONSUMER(ldo10, "pxa2xx-mci", "vcc sdio");
Mike Rapoport432adf12009-02-02 08:57:52 +02001099REGULATOR_CONSUMER(ldo12, NULL, "vcc usb");
Paul Gortmaker804d2312012-03-30 08:41:02 +08001100REGULATOR_CONSUMER(ldo19, "reg-userspace-consumer.1", "vcc gprs");
Mike Rapoport100a1d22009-07-26 13:48:40 +03001101REGULATOR_CONSUMER(buck2, NULL, "vcc_core");
Mike Rapoport28c88042008-12-03 09:38:10 +02001102
Mike Rapoport432adf12009-02-02 08:57:52 +02001103#define REGULATOR_INIT(_ldo, _min_uV, _max_uV, _ops_mask) \
1104 static struct regulator_init_data _ldo##_data = { \
1105 .constraints = { \
1106 .min_uV = _min_uV, \
1107 .max_uV = _max_uV, \
1108 .state_mem = { \
1109 .enabled = 0, \
1110 }, \
1111 .valid_ops_mask = _ops_mask, \
Mike Rapoporta37ed432009-05-18 08:53:56 +03001112 .apply_uV = 1, \
Mike Rapoport432adf12009-02-02 08:57:52 +02001113 }, \
1114 .num_consumer_supplies = ARRAY_SIZE(_ldo##_consumers), \
1115 .consumer_supplies = _ldo##_consumers, \
1116 };
Mike Rapoport6432f462009-02-02 08:57:51 +02001117
Mike Rapoport432adf12009-02-02 08:57:52 +02001118REGULATOR_INIT(ldo3, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
1119REGULATOR_INIT(ldo5, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1120REGULATOR_INIT(ldo10, 2000000, 3200000,
1121 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE);
1122REGULATOR_INIT(ldo12, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1123REGULATOR_INIT(ldo19, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
Mike Rapoport100a1d22009-07-26 13:48:40 +03001124REGULATOR_INIT(buck2, 1000000, 1650000, REGULATOR_CHANGE_VOLTAGE);
Mike Rapoport28c88042008-12-03 09:38:10 +02001125
1126struct led_info em_x270_led_info = {
1127 .name = "em-x270:orange",
1128 .default_trigger = "battery-charging-or-full",
1129};
1130
Mike Rapoport9f055c42009-02-02 08:57:53 +02001131struct power_supply_info em_x270_psy_info = {
Mike Rapoport3690a0f2009-05-12 16:31:15 +03001132 .name = "battery",
Mike Rapoport9f055c42009-02-02 08:57:53 +02001133 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
1134 .voltage_max_design = 4200000,
1135 .voltage_min_design = 3000000,
1136 .use_for_apm = 1,
1137};
1138
1139static void em_x270_battery_low(void)
1140{
Mike Rapoport1d3e2162009-07-21 17:09:52 +03001141#if defined(CONFIG_APM_EMULATION)
Mike Rapoport9f055c42009-02-02 08:57:53 +02001142 apm_queue_event(APM_LOW_BATTERY);
Mike Rapoport1d3e2162009-07-21 17:09:52 +03001143#endif
Mike Rapoport9f055c42009-02-02 08:57:53 +02001144}
1145
1146static void em_x270_battery_critical(void)
1147{
Mike Rapoport1d3e2162009-07-21 17:09:52 +03001148#if defined(CONFIG_APM_EMULATION)
Mike Rapoport9f055c42009-02-02 08:57:53 +02001149 apm_queue_event(APM_CRITICAL_SUSPEND);
Mike Rapoport1d3e2162009-07-21 17:09:52 +03001150#endif
Mike Rapoport9f055c42009-02-02 08:57:53 +02001151}
1152
1153struct da9030_battery_info em_x270_batterty_info = {
1154 .battery_info = &em_x270_psy_info,
1155
1156 .charge_milliamp = 1000,
1157 .charge_millivolt = 4200,
1158
1159 .vbat_low = 3600,
1160 .vbat_crit = 3400,
1161 .vbat_charge_start = 4100,
1162 .vbat_charge_stop = 4200,
1163 .vbat_charge_restart = 4000,
1164
1165 .vcharge_min = 3200,
1166 .vcharge_max = 5500,
1167
1168 .tbat_low = 197,
1169 .tbat_high = 78,
1170 .tbat_restart = 100,
1171
1172 .batmon_interval = 0,
1173
1174 .battery_low = em_x270_battery_low,
1175 .battery_critical = em_x270_battery_critical,
1176};
1177
Mike Rapoport432adf12009-02-02 08:57:52 +02001178#define DA9030_SUBDEV(_name, _id, _pdata) \
1179 { \
1180 .name = "da903x-" #_name, \
1181 .id = DA9030_ID_##_id, \
1182 .platform_data = _pdata, \
Mike Rapoport28c88042008-12-03 09:38:10 +02001183 }
Mike Rapoport432adf12009-02-02 08:57:52 +02001184
1185#define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
1186
1187struct da903x_subdev_info em_x270_da9030_subdevs[] = {
1188 DA9030_LDO(3),
1189 DA9030_LDO(5),
1190 DA9030_LDO(10),
1191 DA9030_LDO(12),
1192 DA9030_LDO(19),
1193
Mike Rapoport100a1d22009-07-26 13:48:40 +03001194 DA9030_SUBDEV(regulator, BUCK2, &buck2_data),
1195
Mike Rapoport432adf12009-02-02 08:57:52 +02001196 DA9030_SUBDEV(led, LED_PC, &em_x270_led_info),
1197 DA9030_SUBDEV(backlight, WLED, &em_x270_led_info),
Mike Rapoport9f055c42009-02-02 08:57:53 +02001198 DA9030_SUBDEV(battery, BAT, &em_x270_batterty_info),
Mike Rapoport28c88042008-12-03 09:38:10 +02001199};
1200
1201static struct da903x_platform_data em_x270_da9030_info = {
1202 .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
1203 .subdevs = em_x270_da9030_subdevs,
1204};
1205
1206static struct i2c_board_info em_x270_i2c_pmic_info = {
1207 I2C_BOARD_INFO("da9030", 0x49),
Haojian Zhuang6384fda2011-10-10 14:21:08 +08001208 .irq = PXA_GPIO_TO_IRQ(0),
Mike Rapoport28c88042008-12-03 09:38:10 +02001209 .platform_data = &em_x270_da9030_info,
1210};
1211
1212static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
1213 .use_pio = 1,
1214};
1215
1216static void __init em_x270_init_da9030(void)
1217{
1218 pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
1219 i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
1220}
1221
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001222static struct pca953x_platform_data exeda_gpio_ext_pdata = {
1223 .gpio_base = 128,
1224};
1225
1226static struct i2c_board_info exeda_i2c_info[] = {
1227 {
1228 I2C_BOARD_INFO("pca9555", 0x21),
1229 .platform_data = &exeda_gpio_ext_pdata,
1230 },
1231};
1232
1233static struct i2c_pxa_platform_data em_x270_i2c_info = {
1234 .fast_mode = 1,
1235};
1236
1237static void __init em_x270_init_i2c(void)
1238{
1239 pxa_set_i2c_info(&em_x270_i2c_info);
1240
1241 if (machine_is_exeda())
1242 i2c_register_board_info(0, ARRAY_AND_SIZE(exeda_i2c_info));
1243}
1244
Mike Rapoport4a697e82009-02-02 08:57:54 +02001245static void __init em_x270_module_init(void)
Mike Rapoport3d505272007-07-18 11:31:46 +01001246{
Mike Rapoport3c85bce2008-06-16 08:16:46 +01001247 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
Mike Rapoport3d505272007-07-18 11:31:46 +01001248
Mike Rapoport4a697e82009-02-02 08:57:54 +02001249 mmc_cd = GPIO13_MMC_CD;
1250 nand_rb = GPIO56_NAND_RB;
1251 dm9000_flags = DM9000_PLATF_32BITONLY;
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001252 cam_reset = GPIO93_CAM_RESET;
Mike Rapoport128d88b2009-05-12 16:31:16 +03001253 usb_hub_reset = GPIO16_USB_HUB_RESET;
Mike Rapoport4a697e82009-02-02 08:57:54 +02001254}
1255
Mike Rapoport7f14a782009-02-02 08:57:55 +02001256static void __init em_x270_exeda_init(void)
1257{
Mike Rapoport7f14a782009-02-02 08:57:55 +02001258 pxa2xx_mfp_config(ARRAY_AND_SIZE(exeda_pin_config));
1259
1260 mmc_cd = GPIO114_MMC_CD;
1261 nand_rb = GPIO20_NAND_RB;
1262 dm9000_flags = DM9000_PLATF_16BITONLY;
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001263 cam_reset = GPIO130_CAM_RESET;
Mike Rapoport128d88b2009-05-12 16:31:16 +03001264 usb_hub_reset = GPIO10_USB_HUB_RESET;
Mike Rapoport7f14a782009-02-02 08:57:55 +02001265}
1266
Mike Rapoport4a697e82009-02-02 08:57:54 +02001267static void __init em_x270_init(void)
1268{
1269 pxa2xx_mfp_config(ARRAY_AND_SIZE(common_pin_config));
1270
Russell Kingcc155c62009-11-09 13:34:08 +08001271 pxa_set_ffuart_info(NULL);
1272 pxa_set_btuart_info(NULL);
1273 pxa_set_stuart_info(NULL);
1274
Mike Rapoport9599d1d2009-05-26 09:41:46 +03001275#ifdef CONFIG_PM
1276 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
1277#endif
1278
Mike Rapoport7f14a782009-02-02 08:57:55 +02001279 if (machine_is_em_x270())
1280 em_x270_module_init();
1281 else if (machine_is_exeda())
1282 em_x270_exeda_init();
1283 else
1284 panic("Unsupported machine: %d\n", machine_arch_type);
Mike Rapoport4a697e82009-02-02 08:57:54 +02001285
Mike Rapoport28c88042008-12-03 09:38:10 +02001286 em_x270_init_da9030();
Mike Rapoport3c85bce2008-06-16 08:16:46 +01001287 em_x270_init_dm9000();
1288 em_x270_init_rtc();
1289 em_x270_init_nand();
Mike Rapoport28c88042008-12-03 09:38:10 +02001290 em_x270_init_nor();
Mike Rapoport3c85bce2008-06-16 08:16:46 +01001291 em_x270_init_lcd();
1292 em_x270_init_mmc();
1293 em_x270_init_ohci();
1294 em_x270_init_keypad();
1295 em_x270_init_gpio_keys();
1296 em_x270_init_ac97();
Mike Rapoport28c88042008-12-03 09:38:10 +02001297 em_x270_init_spi();
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001298 em_x270_init_i2c();
1299 em_x270_init_camera();
Mike Rapoporta37ed432009-05-18 08:53:56 +03001300 em_x270_userspace_consumers_init();
Mike Rapoport3d505272007-07-18 11:31:46 +01001301}
1302
Mike Rapoport3c85bce2008-06-16 08:16:46 +01001303MACHINE_START(EM_X270, "Compulab EM-X270")
Nicolas Pitre7375aba2011-07-05 22:38:15 -04001304 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +02001305 .map_io = pxa27x_map_io,
Rob Herring4e611092012-01-03 16:53:48 -06001306 .nr_irqs = PXA_NR_IRQS,
Mike Rapoport3d505272007-07-18 11:31:46 +01001307 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +08001308 .handle_irq = pxa27x_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -07001309 .init_time = pxa_timer_init,
Mike Rapoport3d505272007-07-18 11:31:46 +01001310 .init_machine = em_x270_init,
Russell King271a74f2011-11-04 14:15:53 +00001311 .restart = pxa_restart,
Mike Rapoport3d505272007-07-18 11:31:46 +01001312MACHINE_END
Mike Rapoport7f14a782009-02-02 08:57:55 +02001313
1314MACHINE_START(EXEDA, "Compulab eXeda")
Nicolas Pitre7375aba2011-07-05 22:38:15 -04001315 .atag_offset = 0x100,
Marek Vasut851982c2010-10-11 02:20:19 +02001316 .map_io = pxa27x_map_io,
Rob Herring4e611092012-01-03 16:53:48 -06001317 .nr_irqs = PXA_NR_IRQS,
Mike Rapoport7f14a782009-02-02 08:57:55 +02001318 .init_irq = pxa27x_init_irq,
Eric Miao8a97ae22011-05-18 21:30:04 +08001319 .handle_irq = pxa27x_handle_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -07001320 .init_time = pxa_timer_init,
Mike Rapoport7f14a782009-02-02 08:57:55 +02001321 .init_machine = em_x270_init,
Russell King271a74f2011-11-04 14:15:53 +00001322 .restart = pxa_restart,
Mike Rapoport7f14a782009-02-02 08:57:55 +02001323MACHINE_END