blob: 5184a570ac5f33865c6a77b41e41ef48cefcf7b3 [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>
Mike Rapoport9f055c42009-02-02 08:57:53 +020029#include <linux/power_supply.h>
30#include <linux/apm-emulation.h>
Mike Rapoport76e3fc32009-05-12 16:31:13 +030031#include <linux/i2c.h>
32#include <linux/i2c/pca953x.h>
Mike Rapoporta37ed432009-05-18 08:53:56 +030033#include <linux/regulator/userspace-consumer.h>
Mike Rapoport28c88042008-12-03 09:38:10 +020034
35#include <media/soc_camera.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010036
37#include <asm/mach-types.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010038#include <asm/mach/arch.h>
39
Eric Miao51c62982009-01-02 23:17:22 +080040#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010041#include <mach/pxa27x-udc.h>
42#include <mach/audio.h>
43#include <mach/pxafb.h>
44#include <mach/ohci.h>
45#include <mach/mmc.h>
46#include <mach/pxa27x_keypad.h>
Eric Miaof0a83702009-04-13 15:03:11 +080047#include <plat/i2c.h>
Mike Rapoport28c88042008-12-03 09:38:10 +020048#include <mach/camera.h>
49#include <mach/pxa2xx_spi.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)
73#define EM_X270_ETHIRQ IRQ_GPIO(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 */
112 GPIO58_LCD_LDD_0,
113 GPIO59_LCD_LDD_1,
114 GPIO60_LCD_LDD_2,
115 GPIO61_LCD_LDD_3,
116 GPIO62_LCD_LDD_4,
117 GPIO63_LCD_LDD_5,
118 GPIO64_LCD_LDD_6,
119 GPIO65_LCD_LDD_7,
120 GPIO66_LCD_LDD_8,
121 GPIO67_LCD_LDD_9,
122 GPIO68_LCD_LDD_10,
123 GPIO69_LCD_LDD_11,
124 GPIO70_LCD_LDD_12,
125 GPIO71_LCD_LDD_13,
126 GPIO72_LCD_LDD_14,
127 GPIO73_LCD_LDD_15,
128 GPIO74_LCD_FCLK,
129 GPIO75_LCD_LCLK,
130 GPIO76_LCD_PCLK,
131 GPIO77_LCD_BIAS,
132
133 /* QCI */
134 GPIO84_CIF_FV,
135 GPIO25_CIF_LV,
136 GPIO53_CIF_MCLK,
137 GPIO54_CIF_PCLK,
138 GPIO81_CIF_DD_0,
139 GPIO55_CIF_DD_1,
140 GPIO51_CIF_DD_2,
141 GPIO50_CIF_DD_3,
142 GPIO52_CIF_DD_4,
143 GPIO48_CIF_DD_5,
144 GPIO17_CIF_DD_6,
145 GPIO12_CIF_DD_7,
146
147 /* I2C */
148 GPIO117_I2C_SCL,
149 GPIO118_I2C_SDA,
150
151 /* Keypad */
152 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
153 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
154 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
155 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
156 GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
157 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
158 GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
159 GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
160 GPIO103_KP_MKOUT_0,
161 GPIO104_KP_MKOUT_1,
162 GPIO105_KP_MKOUT_2,
163 GPIO106_KP_MKOUT_3,
164 GPIO107_KP_MKOUT_4,
165 GPIO108_KP_MKOUT_5,
166 GPIO96_KP_MKOUT_6,
167 GPIO22_KP_MKOUT_7,
168
169 /* SSP1 */
170 GPIO26_SSP1_RXD,
171 GPIO23_SSP1_SCLK,
172 GPIO24_SSP1_SFRM,
173 GPIO57_SSP1_TXD,
174
175 /* SSP2 */
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200176 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
177 GPIO14_GPIO,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100178 GPIO89_SSP2_TXD,
179 GPIO88_SSP2_RXD,
180
181 /* SDRAM and local bus */
182 GPIO15_nCS_1,
183 GPIO78_nCS_2,
184 GPIO79_nCS_3,
185 GPIO80_nCS_4,
186 GPIO49_nPWE,
187 GPIO18_RDY,
188
189 /* GPIO */
Mike Rapoport6432f462009-02-02 08:57:51 +0200190 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* sleep/resume button */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100191
192 /* power controls */
193 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
194 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
195
196 /* NAND controls */
197 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100198
199 /* interrupts */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100200 GPIO41_GPIO, /* DM9000 interrupt */
201};
202
Mike Rapoport4a697e82009-02-02 08:57:54 +0200203static unsigned long em_x270_pin_config[] = {
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300204 GPIO13_GPIO, /* MMC card detect */
Mike Rapoport128d88b2009-05-12 16:31:16 +0300205 GPIO16_GPIO, /* USB hub reset */
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300206 GPIO56_GPIO, /* NAND Ready/Busy */
207 GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
208 GPIO95_GPIO, /* MMC Write protect */
Mike Rapoport4a697e82009-02-02 08:57:54 +0200209};
210
Mike Rapoport7f14a782009-02-02 08:57:55 +0200211static unsigned long exeda_pin_config[] = {
Mike Rapoport128d88b2009-05-12 16:31:16 +0300212 GPIO10_GPIO, /* USB hub reset */
Mike Rapoport7f14a782009-02-02 08:57:55 +0200213 GPIO20_GPIO, /* NAND Ready/Busy */
214 GPIO38_GPIO | MFP_LPM_DRIVE_LOW, /* SD slot power */
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300215 GPIO95_GPIO, /* touchpad IRQ */
Mike Rapoport7f14a782009-02-02 08:57:55 +0200216 GPIO114_GPIO, /* MMC card detect */
217};
218
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100219#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
220static struct resource em_x270_dm9000_resource[] = {
Mike Rapoport3d505272007-07-18 11:31:46 +0100221 [0] = {
222 .start = PXA_CS2_PHYS,
223 .end = PXA_CS2_PHYS + 3,
224 .flags = IORESOURCE_MEM,
225 },
226 [1] = {
227 .start = PXA_CS2_PHYS + 8,
228 .end = PXA_CS2_PHYS + 8 + 0x3f,
229 .flags = IORESOURCE_MEM,
230 },
231 [2] = {
232 .start = EM_X270_ETHIRQ,
233 .end = EM_X270_ETHIRQ,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100234 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Mike Rapoport3d505272007-07-18 11:31:46 +0100235 }
236};
237
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100238static struct dm9000_plat_data em_x270_dm9000_platdata = {
Mike Rapoport4a697e82009-02-02 08:57:54 +0200239 .flags = DM9000_PLATF_NO_EEPROM,
Mike Rapoport3d505272007-07-18 11:31:46 +0100240};
241
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100242static struct platform_device em_x270_dm9000 = {
Mike Rapoport3d505272007-07-18 11:31:46 +0100243 .name = "dm9000",
244 .id = 0,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100245 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
246 .resource = em_x270_dm9000_resource,
Mike Rapoport3d505272007-07-18 11:31:46 +0100247 .dev = {
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100248 .platform_data = &em_x270_dm9000_platdata,
Mike Rapoport3d505272007-07-18 11:31:46 +0100249 }
250};
251
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100252static void __init em_x270_init_dm9000(void)
253{
Mike Rapoport4a697e82009-02-02 08:57:54 +0200254 em_x270_dm9000_platdata.flags |= dm9000_flags;
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100255 platform_device_register(&em_x270_dm9000);
256}
257#else
258static inline void em_x270_init_dm9000(void) {}
259#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100260
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100261/* V3020 RTC */
262#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
Mike Rapoport3d505272007-07-18 11:31:46 +0100263static struct resource em_x270_v3020_resource[] = {
264 [0] = {
265 .start = PXA_CS4_PHYS,
266 .end = PXA_CS4_PHYS + 3,
267 .flags = IORESOURCE_MEM,
268 },
269};
270
271static struct v3020_platform_data em_x270_v3020_platdata = {
272 .leftshift = 0,
273};
274
275static struct platform_device em_x270_rtc = {
276 .name = "v3020",
277 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
278 .resource = em_x270_v3020_resource,
279 .id = -1,
280 .dev = {
281 .platform_data = &em_x270_v3020_platdata,
282 }
283};
284
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100285static void __init em_x270_init_rtc(void)
286{
287 platform_device_register(&em_x270_rtc);
288}
289#else
290static inline void em_x270_init_rtc(void) {}
291#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100292
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100293/* NAND flash */
294#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
Mike Rapoport3d505272007-07-18 11:31:46 +0100295static inline void nand_cs_on(void)
296{
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100297 gpio_set_value(GPIO11_NAND_CS, 0);
Mike Rapoport3d505272007-07-18 11:31:46 +0100298}
299
300static void nand_cs_off(void)
301{
302 dsb();
303
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100304 gpio_set_value(GPIO11_NAND_CS, 1);
Mike Rapoport3d505272007-07-18 11:31:46 +0100305}
306
307/* hardware specific access to control-lines */
308static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
309 unsigned int ctrl)
310{
311 struct nand_chip *this = mtd->priv;
312 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
313
314 dsb();
315
316 if (ctrl & NAND_CTRL_CHANGE) {
317 if (ctrl & NAND_ALE)
318 nandaddr |= (1 << 3);
319 else
320 nandaddr &= ~(1 << 3);
321 if (ctrl & NAND_CLE)
322 nandaddr |= (1 << 2);
323 else
324 nandaddr &= ~(1 << 2);
325 if (ctrl & NAND_NCE)
326 nand_cs_on();
327 else
328 nand_cs_off();
329 }
330
331 dsb();
332 this->IO_ADDR_W = (void __iomem *)nandaddr;
333 if (dat != NAND_CMD_NONE)
334 writel(dat, this->IO_ADDR_W);
335
336 dsb();
337}
338
339/* read device ready pin */
340static int em_x270_nand_device_ready(struct mtd_info *mtd)
341{
342 dsb();
343
Mike Rapoport4a697e82009-02-02 08:57:54 +0200344 return gpio_get_value(nand_rb);
Mike Rapoport3d505272007-07-18 11:31:46 +0100345}
346
347static struct mtd_partition em_x270_partition_info[] = {
348 [0] = {
349 .name = "em_x270-0",
350 .offset = 0,
351 .size = SZ_4M,
352 },
353 [1] = {
354 .name = "em_x270-1",
355 .offset = MTDPART_OFS_APPEND,
356 .size = MTDPART_SIZ_FULL
357 },
358};
359
360static const char *em_x270_part_probes[] = { "cmdlinepart", NULL };
361
362struct platform_nand_data em_x270_nand_platdata = {
363 .chip = {
364 .nr_chips = 1,
365 .chip_offset = 0,
366 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
367 .partitions = em_x270_partition_info,
368 .chip_delay = 20,
369 .part_probe_types = em_x270_part_probes,
370 },
371 .ctrl = {
372 .hwcontrol = 0,
373 .dev_ready = em_x270_nand_device_ready,
374 .select_chip = 0,
375 .cmd_ctrl = em_x270_nand_cmd_ctl,
376 },
377};
378
379static struct resource em_x270_nand_resource[] = {
380 [0] = {
381 .start = PXA_CS1_PHYS,
382 .end = PXA_CS1_PHYS + 12,
383 .flags = IORESOURCE_MEM,
384 },
385};
386
387static struct platform_device em_x270_nand = {
388 .name = "gen_nand",
389 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
390 .resource = em_x270_nand_resource,
391 .id = -1,
392 .dev = {
393 .platform_data = &em_x270_nand_platdata,
394 }
395};
396
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100397static void __init em_x270_init_nand(void)
398{
399 int err;
Mike Rapoport3d505272007-07-18 11:31:46 +0100400
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100401 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
402 if (err) {
403 pr_warning("EM-X270: failed to request NAND CS gpio\n");
404 return;
405 }
406
407 gpio_direction_output(GPIO11_NAND_CS, 1);
408
Mike Rapoport4a697e82009-02-02 08:57:54 +0200409 err = gpio_request(nand_rb, "NAND R/B");
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100410 if (err) {
411 pr_warning("EM-X270: failed to request NAND R/B gpio\n");
412 gpio_free(GPIO11_NAND_CS);
413 return;
414 }
415
Mike Rapoport4a697e82009-02-02 08:57:54 +0200416 gpio_direction_input(nand_rb);
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100417
418 platform_device_register(&em_x270_nand);
419}
420#else
421static inline void em_x270_init_nand(void) {}
422#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100423
Mike Rapoport28c88042008-12-03 09:38:10 +0200424#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
425static struct mtd_partition em_x270_nor_parts[] = {
426 {
427 .name = "Bootloader",
428 .offset = 0x00000000,
429 .size = 0x00050000,
430 .mask_flags = MTD_WRITEABLE /* force read-only */
431 }, {
432 .name = "Environment",
433 .offset = 0x00050000,
434 .size = 0x00010000,
435 }, {
436 .name = "Reserved",
437 .offset = 0x00060000,
438 .size = 0x00050000,
439 .mask_flags = MTD_WRITEABLE /* force read-only */
440 }, {
441 .name = "Splashscreen",
442 .offset = 0x000b0000,
443 .size = 0x00050000,
444 }
445};
446
447static struct physmap_flash_data em_x270_nor_data[] = {
448 [0] = {
449 .width = 2,
450 .parts = em_x270_nor_parts,
451 .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
452 },
453};
454
455static struct resource em_x270_nor_flash_resource = {
456 .start = PXA_CS0_PHYS,
457 .end = PXA_CS0_PHYS + SZ_1M - 1,
458 .flags = IORESOURCE_MEM,
459};
460
461static struct platform_device em_x270_physmap_flash = {
462 .name = "physmap-flash",
463 .id = 0,
464 .num_resources = 1,
465 .resource = &em_x270_nor_flash_resource,
466 .dev = {
467 .platform_data = &em_x270_nor_data,
468 },
469};
470
471static void __init em_x270_init_nor(void)
472{
473 platform_device_register(&em_x270_physmap_flash);
474}
475#else
476static inline void em_x270_init_nor(void) {}
477#endif
478
Mike Rapoport3d505272007-07-18 11:31:46 +0100479/* PXA27x OHCI controller setup */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100480#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Mike Rapoport128d88b2009-05-12 16:31:16 +0300481static struct regulator *em_x270_usb_ldo;
482
483static int em_x270_usb_hub_init(void)
484{
485 int err;
486
487 em_x270_usb_ldo = regulator_get(NULL, "vcc usb");
488 if (IS_ERR(em_x270_usb_ldo))
489 return PTR_ERR(em_x270_usb_ldo);
490
491 err = gpio_request(GPIO9_USB_VBUS_EN, "vbus en");
492 if (err)
493 goto err_free_usb_ldo;
494
495 err = gpio_request(usb_hub_reset, "hub rst");
496 if (err)
497 goto err_free_vbus_gpio;
498
499 /* USB Hub power-on and reset */
500 gpio_direction_output(usb_hub_reset, 0);
501 regulator_enable(em_x270_usb_ldo);
502 gpio_set_value(usb_hub_reset, 1);
503 gpio_set_value(usb_hub_reset, 0);
504 regulator_disable(em_x270_usb_ldo);
505 regulator_enable(em_x270_usb_ldo);
506 gpio_set_value(usb_hub_reset, 1);
507
508 /* enable VBUS */
509 gpio_direction_output(GPIO9_USB_VBUS_EN, 1);
510
511 return 0;
512
513err_free_vbus_gpio:
514 gpio_free(GPIO9_USB_VBUS_EN);
515err_free_usb_ldo:
516 regulator_put(em_x270_usb_ldo);
517
518 return err;
519}
520
Mike Rapoport3d505272007-07-18 11:31:46 +0100521static int em_x270_ohci_init(struct device *dev)
522{
Mike Rapoport128d88b2009-05-12 16:31:16 +0300523 int err;
524
525 /* we don't want to entirely disable USB if the HUB init failed */
526 err = em_x270_usb_hub_init();
527 if (err)
528 pr_err("USB Hub initialization failed: %d\n", err);
529
Mike Rapoport3d505272007-07-18 11:31:46 +0100530 /* enable port 2 transiever */
531 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
532
533 return 0;
534}
535
Mike Rapoport128d88b2009-05-12 16:31:16 +0300536static void em_x270_ohci_exit(struct device *dev)
537{
538 gpio_free(usb_hub_reset);
539 gpio_free(GPIO9_USB_VBUS_EN);
540
541 if (!IS_ERR(em_x270_usb_ldo)) {
542 if (regulator_is_enabled(em_x270_usb_ldo))
543 regulator_disable(em_x270_usb_ldo);
544
545 regulator_put(em_x270_usb_ldo);
546 }
547}
548
Mike Rapoport3d505272007-07-18 11:31:46 +0100549static struct pxaohci_platform_data em_x270_ohci_platform_data = {
550 .port_mode = PMM_PERPORT_MODE,
Eric Miao097b5332008-09-27 15:49:57 +0800551 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
Mike Rapoport3d505272007-07-18 11:31:46 +0100552 .init = em_x270_ohci_init,
Mike Rapoport128d88b2009-05-12 16:31:16 +0300553 .exit = em_x270_ohci_exit,
Mike Rapoport3d505272007-07-18 11:31:46 +0100554};
555
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100556static void __init em_x270_init_ohci(void)
557{
558 pxa_set_ohci_info(&em_x270_ohci_platform_data);
559}
560#else
561static inline void em_x270_init_ohci(void) {}
562#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100563
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100564/* MCI controller setup */
565#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
Mike Rapoport6432f462009-02-02 08:57:51 +0200566static struct regulator *em_x270_sdio_ldo;
567
Mike Rapoport3d505272007-07-18 11:31:46 +0100568static int em_x270_mci_init(struct device *dev,
569 irq_handler_t em_x270_detect_int,
570 void *data)
571{
Mike Rapoport6432f462009-02-02 08:57:51 +0200572 int err;
573
574 em_x270_sdio_ldo = regulator_get(dev, "vcc sdio");
575 if (IS_ERR(em_x270_sdio_ldo)) {
576 dev_err(dev, "can't request SDIO power supply: %ld\n",
577 PTR_ERR(em_x270_sdio_ldo));
578 return PTR_ERR(em_x270_sdio_ldo);
Mike Rapoport3d505272007-07-18 11:31:46 +0100579 }
580
Mike Rapoport4a697e82009-02-02 08:57:54 +0200581 err = request_irq(gpio_to_irq(mmc_cd), em_x270_detect_int,
Mike Rapoport6432f462009-02-02 08:57:51 +0200582 IRQF_DISABLED | IRQF_TRIGGER_RISING |
583 IRQF_TRIGGER_FALLING,
584 "MMC card detect", data);
585 if (err) {
586 dev_err(dev, "can't request MMC card detect IRQ: %d\n", err);
587 goto err_irq;
588 }
589
Mike Rapoport7f14a782009-02-02 08:57:55 +0200590 if (machine_is_em_x270()) {
591 err = gpio_request(GPIO95_MMC_WP, "MMC WP");
592 if (err) {
593 dev_err(dev, "can't request MMC write protect: %d\n",
594 err);
595 goto err_gpio_wp;
596 }
597 gpio_direction_input(GPIO95_MMC_WP);
598 } else {
599 err = gpio_request(GPIO38_SD_PWEN, "sdio power");
600 if (err) {
601 dev_err(dev, "can't request MMC power control : %d\n",
602 err);
603 goto err_gpio_wp;
604 }
605 gpio_direction_output(GPIO38_SD_PWEN, 1);
Mike Rapoport6432f462009-02-02 08:57:51 +0200606 }
607
Mike Rapoport3d505272007-07-18 11:31:46 +0100608 return 0;
Mike Rapoport6432f462009-02-02 08:57:51 +0200609
610err_gpio_wp:
Mike Rapoport4a697e82009-02-02 08:57:54 +0200611 free_irq(gpio_to_irq(mmc_cd), data);
Mike Rapoport6432f462009-02-02 08:57:51 +0200612err_irq:
613 regulator_put(em_x270_sdio_ldo);
614
615 return err;
Mike Rapoport3d505272007-07-18 11:31:46 +0100616}
617
618static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
619{
Mike Rapoport6432f462009-02-02 08:57:51 +0200620 struct pxamci_platform_data* p_d = dev->platform_data;
621
622 if ((1 << vdd) & p_d->ocr_mask) {
623 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
624
625 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
626 regulator_enable(em_x270_sdio_ldo);
627 } else {
628 regulator_disable(em_x270_sdio_ldo);
629 }
Mike Rapoport3d505272007-07-18 11:31:46 +0100630}
631
632static void em_x270_mci_exit(struct device *dev, void *data)
633{
Mike Rapoport4a697e82009-02-02 08:57:54 +0200634 free_irq(gpio_to_irq(mmc_cd), data);
Mike Rapoport7f14a782009-02-02 08:57:55 +0200635 regulator_put(em_x270_sdio_ldo);
636
637 if (machine_is_em_x270())
638 gpio_free(GPIO95_MMC_WP);
639 else
640 gpio_free(GPIO38_SD_PWEN);
Mike Rapoport6432f462009-02-02 08:57:51 +0200641}
642
643static int em_x270_mci_get_ro(struct device *dev)
644{
645 return gpio_get_value(GPIO95_MMC_WP);
Mike Rapoport3d505272007-07-18 11:31:46 +0100646}
647
648static struct pxamci_platform_data em_x270_mci_platform_data = {
Mike Rapoport6432f462009-02-02 08:57:51 +0200649 .ocr_mask = MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23|
650 MMC_VDD_24_25|MMC_VDD_25_26|MMC_VDD_26_27|
651 MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
652 MMC_VDD_30_31|MMC_VDD_31_32,
Mike Rapoport3d505272007-07-18 11:31:46 +0100653 .init = em_x270_mci_init,
654 .setpower = em_x270_mci_setpower,
655 .exit = em_x270_mci_exit,
656};
657
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100658static void __init em_x270_init_mmc(void)
659{
Mike Rapoport7f14a782009-02-02 08:57:55 +0200660 if (machine_is_em_x270())
661 em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro;
662
Mike Rapoport6432f462009-02-02 08:57:51 +0200663 em_x270_mci_platform_data.detect_delay = msecs_to_jiffies(250);
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100664 pxa_set_mci_info(&em_x270_mci_platform_data);
665}
666#else
667static inline void em_x270_init_mmc(void) {}
668#endif
669
Mike Rapoport28c88042008-12-03 09:38:10 +0200670/* LCD */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100671#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
Mike Rapoport28c88042008-12-03 09:38:10 +0200672static struct pxafb_mode_info em_x270_lcd_modes[] = {
673 [0] = {
674 .pixclock = 38250,
675 .bpp = 16,
676 .xres = 480,
677 .yres = 640,
678 .hsync_len = 8,
679 .vsync_len = 2,
680 .left_margin = 8,
681 .upper_margin = 2,
682 .right_margin = 24,
683 .lower_margin = 4,
684 .sync = 0,
685 },
686 [1] = {
687 .pixclock = 153800,
688 .bpp = 16,
689 .xres = 240,
690 .yres = 320,
691 .hsync_len = 8,
692 .vsync_len = 2,
693 .left_margin = 8,
694 .upper_margin = 2,
695 .right_margin = 88,
696 .lower_margin = 2,
697 .sync = 0,
698 },
Mike Rapoport3d505272007-07-18 11:31:46 +0100699};
700
701static struct pxafb_mach_info em_x270_lcd = {
Mike Rapoport28c88042008-12-03 09:38:10 +0200702 .modes = em_x270_lcd_modes,
703 .num_modes = 2,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100704 .lcd_conn = LCD_COLOR_TFT_16BPP,
Mike Rapoport3d505272007-07-18 11:31:46 +0100705};
Mike Rapoport28c88042008-12-03 09:38:10 +0200706
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100707static void __init em_x270_init_lcd(void)
708{
709 set_pxa_fb_info(&em_x270_lcd);
710}
711#else
712static inline void em_x270_init_lcd(void) {}
713#endif
714
Mike Rapoport28c88042008-12-03 09:38:10 +0200715#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
716static struct pxa2xx_spi_master em_x270_spi_info = {
717 .num_chipselect = 1,
718};
719
720static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
Mike Rapoportbd9d0742009-04-14 08:32:55 +0300721 .rx_threshold = 1,
722 .tx_threshold = 1,
723 .gpio_cs = -1,
Mike Rapoport28c88042008-12-03 09:38:10 +0200724};
725
726static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
727 .model = TDO35S,
728};
729
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200730static struct pxa2xx_spi_master em_x270_spi_2_info = {
731 .num_chipselect = 1,
732 .enable_dma = 1,
733};
734
735static struct pxa2xx_spi_chip em_x270_libertas_chip = {
736 .rx_threshold = 1,
737 .tx_threshold = 1,
738 .timeout = 1000,
Mike Rapoport3cb05c92009-06-16 15:19:24 +0300739 .gpio_cs = 14,
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200740};
741
742static unsigned long em_x270_libertas_pin_config[] = {
743 /* SSP2 */
744 GPIO19_SSP2_SCLK,
745 GPIO14_GPIO,
746 GPIO89_SSP2_TXD,
747 GPIO88_SSP2_RXD,
748};
749
750static int em_x270_libertas_setup(struct spi_device *spi)
751{
752 int err = gpio_request(GPIO115_WLAN_PWEN, "WLAN PWEN");
753 if (err)
754 return err;
755
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300756 err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
757 if (err)
758 goto err_free_pwen;
759
760 if (machine_is_exeda()) {
761 err = gpio_request(GPIO37_WLAN_RST, "WLAN RST");
762 if (err)
763 goto err_free_strap;
764
765 gpio_direction_output(GPIO37_WLAN_RST, 1);
766 msleep(100);
767 }
768
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200769 gpio_direction_output(GPIO19_WLAN_STRAP, 1);
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300770 msleep(100);
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200771
772 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_libertas_pin_config));
773
774 gpio_direction_output(GPIO115_WLAN_PWEN, 0);
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300775 msleep(100);
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200776 gpio_set_value(GPIO115_WLAN_PWEN, 1);
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300777 msleep(100);
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200778
779 spi->bits_per_word = 16;
780 spi_setup(spi);
781
782 return 0;
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300783
784err_free_strap:
785 gpio_free(GPIO19_WLAN_STRAP);
786err_free_pwen:
787 gpio_free(GPIO115_WLAN_PWEN);
788
789 return err;
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200790}
791
792static int em_x270_libertas_teardown(struct spi_device *spi)
793{
794 gpio_set_value(GPIO115_WLAN_PWEN, 0);
795 gpio_free(GPIO115_WLAN_PWEN);
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300796 gpio_free(GPIO19_WLAN_STRAP);
797
798 if (machine_is_exeda()) {
799 gpio_set_value(GPIO37_WLAN_RST, 0);
800 gpio_free(GPIO37_WLAN_RST);
801 }
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200802
803 return 0;
804}
805
806struct libertas_spi_platform_data em_x270_libertas_pdata = {
807 .use_dummy_writes = 1,
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200808 .setup = em_x270_libertas_setup,
809 .teardown = em_x270_libertas_teardown,
810};
811
Mike Rapoport28c88042008-12-03 09:38:10 +0200812static struct spi_board_info em_x270_spi_devices[] __initdata = {
813 {
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200814 .modalias = "tdo24m",
815 .max_speed_hz = 1000000,
816 .bus_num = 1,
817 .chip_select = 0,
818 .controller_data = &em_x270_tdo24m_chip,
819 .platform_data = &em_x270_tdo24m_pdata,
820 },
821 {
822 .modalias = "libertas_spi",
823 .max_speed_hz = 13000000,
824 .bus_num = 2,
825 .irq = IRQ_GPIO(116),
826 .chip_select = 0,
827 .controller_data = &em_x270_libertas_chip,
828 .platform_data = &em_x270_libertas_pdata,
Mike Rapoport28c88042008-12-03 09:38:10 +0200829 },
830};
831
832static void __init em_x270_init_spi(void)
833{
834 pxa2xx_set_spi_info(1, &em_x270_spi_info);
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200835 pxa2xx_set_spi_info(2, &em_x270_spi_2_info);
Mike Rapoport28c88042008-12-03 09:38:10 +0200836 spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
837}
838#else
839static inline void em_x270_init_spi(void) {}
840#endif
841
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100842#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
843static void __init em_x270_init_ac97(void)
844{
845 pxa_set_ac97_info(NULL);
846}
847#else
848static inline void em_x270_init_ac97(void) {}
849#endif
850
851#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
Mike Rapoport7f14a782009-02-02 08:57:55 +0200852static unsigned int em_x270_module_matrix_keys[] = {
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100853 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
854 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
855 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
856};
857
Mike Rapoport7f14a782009-02-02 08:57:55 +0200858struct pxa27x_keypad_platform_data em_x270_module_keypad_info = {
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100859 /* code map for the matrix keys */
860 .matrix_key_rows = 3,
861 .matrix_key_cols = 3,
Mike Rapoport7f14a782009-02-02 08:57:55 +0200862 .matrix_key_map = em_x270_module_matrix_keys,
863 .matrix_key_map_size = ARRAY_SIZE(em_x270_module_matrix_keys),
864};
865
866static unsigned int em_x270_exeda_matrix_keys[] = {
867 KEY(0, 0, KEY_RIGHTSHIFT), KEY(0, 1, KEY_RIGHTCTRL),
868 KEY(0, 2, KEY_RIGHTALT), KEY(0, 3, KEY_SPACE),
869 KEY(0, 4, KEY_LEFTALT), KEY(0, 5, KEY_LEFTCTRL),
870 KEY(0, 6, KEY_ENTER), KEY(0, 7, KEY_SLASH),
871
872 KEY(1, 0, KEY_DOT), KEY(1, 1, KEY_M),
873 KEY(1, 2, KEY_N), KEY(1, 3, KEY_B),
874 KEY(1, 4, KEY_V), KEY(1, 5, KEY_C),
875 KEY(1, 6, KEY_X), KEY(1, 7, KEY_Z),
876
877 KEY(2, 0, KEY_LEFTSHIFT), KEY(2, 1, KEY_SEMICOLON),
878 KEY(2, 2, KEY_L), KEY(2, 3, KEY_K),
879 KEY(2, 4, KEY_J), KEY(2, 5, KEY_H),
880 KEY(2, 6, KEY_G), KEY(2, 7, KEY_F),
881
882 KEY(3, 0, KEY_D), KEY(3, 1, KEY_S),
883 KEY(3, 2, KEY_A), KEY(3, 3, KEY_TAB),
884 KEY(3, 4, KEY_BACKSPACE), KEY(3, 5, KEY_P),
885 KEY(3, 6, KEY_O), KEY(3, 7, KEY_I),
886
887 KEY(4, 0, KEY_U), KEY(4, 1, KEY_Y),
888 KEY(4, 2, KEY_T), KEY(4, 3, KEY_R),
889 KEY(4, 4, KEY_E), KEY(4, 5, KEY_W),
890 KEY(4, 6, KEY_Q), KEY(4, 7, KEY_MINUS),
891
892 KEY(5, 0, KEY_0), KEY(5, 1, KEY_9),
893 KEY(5, 2, KEY_8), KEY(5, 3, KEY_7),
894 KEY(5, 4, KEY_6), KEY(5, 5, KEY_5),
895 KEY(5, 6, KEY_4), KEY(5, 7, KEY_3),
896
897 KEY(6, 0, KEY_2), KEY(6, 1, KEY_1),
898 KEY(6, 2, KEY_ENTER), KEY(6, 3, KEY_END),
899 KEY(6, 4, KEY_DOWN), KEY(6, 5, KEY_UP),
900 KEY(6, 6, KEY_MENU), KEY(6, 7, KEY_F1),
901
902 KEY(7, 0, KEY_LEFT), KEY(7, 1, KEY_RIGHT),
903 KEY(7, 2, KEY_BACK), KEY(7, 3, KEY_HOME),
904 KEY(7, 4, 0), KEY(7, 5, 0),
905 KEY(7, 6, 0), KEY(7, 7, 0),
906};
907
908struct pxa27x_keypad_platform_data em_x270_exeda_keypad_info = {
909 /* code map for the matrix keys */
910 .matrix_key_rows = 8,
911 .matrix_key_cols = 8,
912 .matrix_key_map = em_x270_exeda_matrix_keys,
913 .matrix_key_map_size = ARRAY_SIZE(em_x270_exeda_matrix_keys),
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100914};
915
916static void __init em_x270_init_keypad(void)
917{
Mike Rapoport7f14a782009-02-02 08:57:55 +0200918 if (machine_is_em_x270())
919 pxa_set_keypad_info(&em_x270_module_keypad_info);
920 else
921 pxa_set_keypad_info(&em_x270_exeda_keypad_info);
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100922}
923#else
924static inline void em_x270_init_keypad(void) {}
925#endif
926
927#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
928static struct gpio_keys_button gpio_keys_button[] = {
929 [0] = {
930 .desc = "sleep/wakeup",
931 .code = KEY_SUSPEND,
932 .type = EV_PWR,
933 .gpio = 1,
934 .wakeup = 1,
935 },
936};
937
938static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
939 .buttons = gpio_keys_button,
940 .nbuttons = 1,
941};
942
943static struct platform_device em_x270_gpio_keys = {
944 .name = "gpio-keys",
945 .id = -1,
946 .dev = {
947 .platform_data = &em_x270_gpio_keys_data,
948 },
949};
950
951static void __init em_x270_init_gpio_keys(void)
952{
953 platform_device_register(&em_x270_gpio_keys);
954}
955#else
956static inline void em_x270_init_gpio_keys(void) {}
957#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100958
Mike Rapoport28c88042008-12-03 09:38:10 +0200959/* Quick Capture Interface and sensor setup */
960#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
961static struct regulator *em_x270_camera_ldo;
962
963static int em_x270_sensor_init(struct device *dev)
964{
965 int ret;
966
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300967 ret = gpio_request(cam_reset, "camera reset");
Mike Rapoport28c88042008-12-03 09:38:10 +0200968 if (ret)
969 return ret;
970
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300971 gpio_direction_output(cam_reset, 0);
Mike Rapoport28c88042008-12-03 09:38:10 +0200972
973 em_x270_camera_ldo = regulator_get(NULL, "vcc cam");
974 if (em_x270_camera_ldo == NULL) {
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300975 gpio_free(cam_reset);
Mike Rapoport28c88042008-12-03 09:38:10 +0200976 return -ENODEV;
977 }
978
979 ret = regulator_enable(em_x270_camera_ldo);
980 if (ret) {
981 regulator_put(em_x270_camera_ldo);
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300982 gpio_free(cam_reset);
Mike Rapoport28c88042008-12-03 09:38:10 +0200983 return ret;
984 }
985
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300986 gpio_set_value(cam_reset, 1);
Mike Rapoport28c88042008-12-03 09:38:10 +0200987
988 return 0;
989}
990
991struct pxacamera_platform_data em_x270_camera_platform_data = {
992 .init = em_x270_sensor_init,
993 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
994 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
995 .mclk_10khz = 2600,
996};
997
998static int em_x270_sensor_power(struct device *dev, int on)
999{
1000 int ret;
1001 int is_on = regulator_is_enabled(em_x270_camera_ldo);
1002
1003 if (on == is_on)
1004 return 0;
1005
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001006 gpio_set_value(cam_reset, !on);
Mike Rapoport28c88042008-12-03 09:38:10 +02001007
1008 if (on)
1009 ret = regulator_enable(em_x270_camera_ldo);
1010 else
1011 ret = regulator_disable(em_x270_camera_ldo);
1012
1013 if (ret)
1014 return ret;
1015
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001016 gpio_set_value(cam_reset, on);
Mike Rapoport28c88042008-12-03 09:38:10 +02001017
1018 return 0;
1019}
1020
1021static struct soc_camera_link iclink = {
1022 .bus_id = 0,
1023 .power = em_x270_sensor_power,
1024};
1025
1026static struct i2c_board_info em_x270_i2c_cam_info[] = {
1027 {
1028 I2C_BOARD_INFO("mt9m111", 0x48),
1029 .platform_data = &iclink,
1030 },
1031};
1032
Mike Rapoport28c88042008-12-03 09:38:10 +02001033static void __init em_x270_init_camera(void)
1034{
Mike Rapoport28c88042008-12-03 09:38:10 +02001035 i2c_register_board_info(0, ARRAY_AND_SIZE(em_x270_i2c_cam_info));
1036 pxa_set_camera_info(&em_x270_camera_platform_data);
1037}
1038#else
1039static inline void em_x270_init_camera(void) {}
1040#endif
1041
Mike Rapoporta37ed432009-05-18 08:53:56 +03001042static struct regulator_bulk_data em_x270_gps_consumer_supply = {
1043 .supply = "vcc gps",
1044};
1045
1046static struct regulator_userspace_consumer_data em_x270_gps_consumer_data = {
1047 .name = "vcc gps",
1048 .num_supplies = 1,
1049 .supplies = &em_x270_gps_consumer_supply,
1050};
1051
1052static struct platform_device em_x270_gps_userspace_consumer = {
1053 .name = "reg-userspace-consumer",
1054 .id = 0,
1055 .dev = {
1056 .platform_data = &em_x270_gps_consumer_data,
1057 },
1058};
1059
1060static struct regulator_bulk_data em_x270_gprs_consumer_supply = {
1061 .supply = "vcc gprs",
1062};
1063
1064static struct regulator_userspace_consumer_data em_x270_gprs_consumer_data = {
1065 .name = "vcc gprs",
1066 .num_supplies = 1,
1067 .supplies = &em_x270_gprs_consumer_supply
1068};
1069
1070static struct platform_device em_x270_gprs_userspace_consumer = {
1071 .name = "reg-userspace-consumer",
1072 .id = 1,
1073 .dev = {
1074 .platform_data = &em_x270_gprs_consumer_data,
1075 }
1076};
1077
1078static struct platform_device *em_x270_userspace_consumers[] = {
1079 &em_x270_gps_userspace_consumer,
1080 &em_x270_gprs_userspace_consumer,
1081};
1082
1083static void __init em_x270_userspace_consumers_init(void)
1084{
1085 platform_add_devices(ARRAY_AND_SIZE(em_x270_userspace_consumers));
1086}
1087
Mike Rapoport28c88042008-12-03 09:38:10 +02001088/* DA9030 related initializations */
Mike Rapoport432adf12009-02-02 08:57:52 +02001089#define REGULATOR_CONSUMER(_name, _dev, _supply) \
1090 static struct regulator_consumer_supply _name##_consumers[] = { \
1091 { \
1092 .dev = _dev, \
1093 .supply = _supply, \
1094 }, \
1095 }
Mike Rapoport28c88042008-12-03 09:38:10 +02001096
Mike Rapoporta37ed432009-05-18 08:53:56 +03001097REGULATOR_CONSUMER(ldo3, &em_x270_gps_userspace_consumer.dev, "vcc gps");
Mike Rapoport432adf12009-02-02 08:57:52 +02001098REGULATOR_CONSUMER(ldo5, NULL, "vcc cam");
1099REGULATOR_CONSUMER(ldo10, &pxa_device_mci.dev, "vcc sdio");
1100REGULATOR_CONSUMER(ldo12, NULL, "vcc usb");
Mike Rapoporta37ed432009-05-18 08:53:56 +03001101REGULATOR_CONSUMER(ldo19, &em_x270_gprs_userspace_consumer.dev, "vcc gprs");
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 Rapoport28c88042008-12-03 09:38:10 +02001124
1125struct led_info em_x270_led_info = {
1126 .name = "em-x270:orange",
1127 .default_trigger = "battery-charging-or-full",
1128};
1129
Mike Rapoport9f055c42009-02-02 08:57:53 +02001130struct power_supply_info em_x270_psy_info = {
Mike Rapoport3690a0f2009-05-12 16:31:15 +03001131 .name = "battery",
Mike Rapoport9f055c42009-02-02 08:57:53 +02001132 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
1133 .voltage_max_design = 4200000,
1134 .voltage_min_design = 3000000,
1135 .use_for_apm = 1,
1136};
1137
1138static void em_x270_battery_low(void)
1139{
1140 apm_queue_event(APM_LOW_BATTERY);
1141}
1142
1143static void em_x270_battery_critical(void)
1144{
1145 apm_queue_event(APM_CRITICAL_SUSPEND);
1146}
1147
1148struct da9030_battery_info em_x270_batterty_info = {
1149 .battery_info = &em_x270_psy_info,
1150
1151 .charge_milliamp = 1000,
1152 .charge_millivolt = 4200,
1153
1154 .vbat_low = 3600,
1155 .vbat_crit = 3400,
1156 .vbat_charge_start = 4100,
1157 .vbat_charge_stop = 4200,
1158 .vbat_charge_restart = 4000,
1159
1160 .vcharge_min = 3200,
1161 .vcharge_max = 5500,
1162
1163 .tbat_low = 197,
1164 .tbat_high = 78,
1165 .tbat_restart = 100,
1166
1167 .batmon_interval = 0,
1168
1169 .battery_low = em_x270_battery_low,
1170 .battery_critical = em_x270_battery_critical,
1171};
1172
Mike Rapoport432adf12009-02-02 08:57:52 +02001173#define DA9030_SUBDEV(_name, _id, _pdata) \
1174 { \
1175 .name = "da903x-" #_name, \
1176 .id = DA9030_ID_##_id, \
1177 .platform_data = _pdata, \
Mike Rapoport28c88042008-12-03 09:38:10 +02001178 }
Mike Rapoport432adf12009-02-02 08:57:52 +02001179
1180#define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
1181
1182struct da903x_subdev_info em_x270_da9030_subdevs[] = {
1183 DA9030_LDO(3),
1184 DA9030_LDO(5),
1185 DA9030_LDO(10),
1186 DA9030_LDO(12),
1187 DA9030_LDO(19),
1188
1189 DA9030_SUBDEV(led, LED_PC, &em_x270_led_info),
1190 DA9030_SUBDEV(backlight, WLED, &em_x270_led_info),
Mike Rapoport9f055c42009-02-02 08:57:53 +02001191 DA9030_SUBDEV(battery, BAT, &em_x270_batterty_info),
Mike Rapoport28c88042008-12-03 09:38:10 +02001192};
1193
1194static struct da903x_platform_data em_x270_da9030_info = {
1195 .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
1196 .subdevs = em_x270_da9030_subdevs,
1197};
1198
1199static struct i2c_board_info em_x270_i2c_pmic_info = {
1200 I2C_BOARD_INFO("da9030", 0x49),
1201 .irq = IRQ_GPIO(0),
1202 .platform_data = &em_x270_da9030_info,
1203};
1204
1205static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
1206 .use_pio = 1,
1207};
1208
1209static void __init em_x270_init_da9030(void)
1210{
1211 pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
1212 i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
1213}
1214
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001215static struct pca953x_platform_data exeda_gpio_ext_pdata = {
1216 .gpio_base = 128,
1217};
1218
1219static struct i2c_board_info exeda_i2c_info[] = {
1220 {
1221 I2C_BOARD_INFO("pca9555", 0x21),
1222 .platform_data = &exeda_gpio_ext_pdata,
1223 },
1224};
1225
1226static struct i2c_pxa_platform_data em_x270_i2c_info = {
1227 .fast_mode = 1,
1228};
1229
1230static void __init em_x270_init_i2c(void)
1231{
1232 pxa_set_i2c_info(&em_x270_i2c_info);
1233
1234 if (machine_is_exeda())
1235 i2c_register_board_info(0, ARRAY_AND_SIZE(exeda_i2c_info));
1236}
1237
Mike Rapoport4a697e82009-02-02 08:57:54 +02001238static void __init em_x270_module_init(void)
Mike Rapoport3d505272007-07-18 11:31:46 +01001239{
Mike Rapoport7f14a782009-02-02 08:57:55 +02001240 pr_info("%s\n", __func__);
Mike Rapoport3c85bce2008-06-16 08:16:46 +01001241 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
Mike Rapoport3d505272007-07-18 11:31:46 +01001242
Mike Rapoport4a697e82009-02-02 08:57:54 +02001243 mmc_cd = GPIO13_MMC_CD;
1244 nand_rb = GPIO56_NAND_RB;
1245 dm9000_flags = DM9000_PLATF_32BITONLY;
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001246 cam_reset = GPIO93_CAM_RESET;
Mike Rapoport128d88b2009-05-12 16:31:16 +03001247 usb_hub_reset = GPIO16_USB_HUB_RESET;
Mike Rapoport4a697e82009-02-02 08:57:54 +02001248}
1249
Mike Rapoport7f14a782009-02-02 08:57:55 +02001250static void __init em_x270_exeda_init(void)
1251{
1252 pr_info("%s\n", __func__);
1253 pxa2xx_mfp_config(ARRAY_AND_SIZE(exeda_pin_config));
1254
1255 mmc_cd = GPIO114_MMC_CD;
1256 nand_rb = GPIO20_NAND_RB;
1257 dm9000_flags = DM9000_PLATF_16BITONLY;
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001258 cam_reset = GPIO130_CAM_RESET;
Mike Rapoport128d88b2009-05-12 16:31:16 +03001259 usb_hub_reset = GPIO10_USB_HUB_RESET;
Mike Rapoport7f14a782009-02-02 08:57:55 +02001260}
1261
Mike Rapoport4a697e82009-02-02 08:57:54 +02001262static void __init em_x270_init(void)
1263{
1264 pxa2xx_mfp_config(ARRAY_AND_SIZE(common_pin_config));
1265
Mike Rapoport9599d1d2009-05-26 09:41:46 +03001266#ifdef CONFIG_PM
1267 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
1268#endif
1269
Mike Rapoport7f14a782009-02-02 08:57:55 +02001270 if (machine_is_em_x270())
1271 em_x270_module_init();
1272 else if (machine_is_exeda())
1273 em_x270_exeda_init();
1274 else
1275 panic("Unsupported machine: %d\n", machine_arch_type);
Mike Rapoport4a697e82009-02-02 08:57:54 +02001276
Mike Rapoport28c88042008-12-03 09:38:10 +02001277 em_x270_init_da9030();
Mike Rapoport3c85bce2008-06-16 08:16:46 +01001278 em_x270_init_dm9000();
1279 em_x270_init_rtc();
1280 em_x270_init_nand();
Mike Rapoport28c88042008-12-03 09:38:10 +02001281 em_x270_init_nor();
Mike Rapoport3c85bce2008-06-16 08:16:46 +01001282 em_x270_init_lcd();
1283 em_x270_init_mmc();
1284 em_x270_init_ohci();
1285 em_x270_init_keypad();
1286 em_x270_init_gpio_keys();
1287 em_x270_init_ac97();
Mike Rapoport28c88042008-12-03 09:38:10 +02001288 em_x270_init_spi();
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001289 em_x270_init_i2c();
1290 em_x270_init_camera();
Mike Rapoporta37ed432009-05-18 08:53:56 +03001291 em_x270_userspace_consumers_init();
Mike Rapoport3d505272007-07-18 11:31:46 +01001292}
1293
Mike Rapoport3c85bce2008-06-16 08:16:46 +01001294MACHINE_START(EM_X270, "Compulab EM-X270")
Mike Rapoport3d505272007-07-18 11:31:46 +01001295 .boot_params = 0xa0000100,
1296 .phys_io = 0x40000000,
1297 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1298 .map_io = pxa_map_io,
1299 .init_irq = pxa27x_init_irq,
1300 .timer = &pxa_timer,
1301 .init_machine = em_x270_init,
1302MACHINE_END
Mike Rapoport7f14a782009-02-02 08:57:55 +02001303
1304MACHINE_START(EXEDA, "Compulab eXeda")
1305 .boot_params = 0xa0000100,
1306 .phys_io = 0x40000000,
1307 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1308 .map_io = pxa_map_io,
1309 .init_irq = pxa27x_init_irq,
1310 .timer = &pxa_timer,
1311 .init_machine = em_x270_init,
1312MACHINE_END