blob: 243e0802b5f4259aa48f429a185c1b3412dfc28e [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 Rapoport28c88042008-12-03 09:38:10 +020033
34#include <media/soc_camera.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010035
36#include <asm/mach-types.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010037#include <asm/mach/arch.h>
38
Eric Miao51c62982009-01-02 23:17:22 +080039#include <mach/pxa27x.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010040#include <mach/pxa27x-udc.h>
41#include <mach/audio.h>
42#include <mach/pxafb.h>
43#include <mach/ohci.h>
44#include <mach/mmc.h>
45#include <mach/pxa27x_keypad.h>
Eric Miaof0a83702009-04-13 15:03:11 +080046#include <plat/i2c.h>
Mike Rapoport28c88042008-12-03 09:38:10 +020047#include <mach/camera.h>
48#include <mach/pxa2xx_spi.h>
Mike Rapoport3d505272007-07-18 11:31:46 +010049
50#include "generic.h"
Mike Rapoport6432f462009-02-02 08:57:51 +020051#include "devices.h"
Mike Rapoport3d505272007-07-18 11:31:46 +010052
Mike Rapoport7f14a782009-02-02 08:57:55 +020053/* EM-X270 specific GPIOs */
Mike Rapoport3c85bce2008-06-16 08:16:46 +010054#define GPIO13_MMC_CD (13)
Mike Rapoport6432f462009-02-02 08:57:51 +020055#define GPIO95_MMC_WP (95)
Mike Rapoport7f14a782009-02-02 08:57:55 +020056#define GPIO56_NAND_RB (56)
Mike Rapoport76e3fc32009-05-12 16:31:13 +030057#define GPIO93_CAM_RESET (93)
Mike Rapoport128d88b2009-05-12 16:31:16 +030058#define GPIO16_USB_HUB_RESET (16)
Mike Rapoport7f14a782009-02-02 08:57:55 +020059
60/* eXeda specific GPIOs */
61#define GPIO114_MMC_CD (114)
62#define GPIO20_NAND_RB (20)
63#define GPIO38_SD_PWEN (38)
Mike Rapoport76e3fc32009-05-12 16:31:13 +030064#define GPIO37_WLAN_RST (37)
65#define GPIO95_TOUCHPAD_INT (95)
66#define GPIO130_CAM_RESET (130)
Mike Rapoport128d88b2009-05-12 16:31:16 +030067#define GPIO10_USB_HUB_RESET (10)
Mike Rapoport7f14a782009-02-02 08:57:55 +020068
69/* common GPIOs */
70#define GPIO11_NAND_CS (11)
Mike Rapoport7f14a782009-02-02 08:57:55 +020071#define GPIO41_ETHIRQ (41)
72#define EM_X270_ETHIRQ IRQ_GPIO(GPIO41_ETHIRQ)
Mike Rapoportc9be0e32009-02-03 09:15:30 +020073#define GPIO115_WLAN_PWEN (115)
74#define GPIO19_WLAN_STRAP (19)
Mike Rapoport128d88b2009-05-12 16:31:16 +030075#define GPIO9_USB_VBUS_EN (9)
Mike Rapoport28c88042008-12-03 09:38:10 +020076
Mike Rapoport4a697e82009-02-02 08:57:54 +020077static int mmc_cd;
78static int nand_rb;
79static int dm9000_flags;
Mike Rapoport76e3fc32009-05-12 16:31:13 +030080static int cam_reset;
Mike Rapoport128d88b2009-05-12 16:31:16 +030081static int usb_hub_reset;
Mike Rapoport4a697e82009-02-02 08:57:54 +020082
83static unsigned long common_pin_config[] = {
Mike Rapoport3c85bce2008-06-16 08:16:46 +010084 /* AC'97 */
85 GPIO28_AC97_BITCLK,
86 GPIO29_AC97_SDATA_IN_0,
87 GPIO30_AC97_SDATA_OUT,
88 GPIO31_AC97_SYNC,
89 GPIO98_AC97_SYSCLK,
90 GPIO113_AC97_nRESET,
91
92 /* BTUART */
93 GPIO42_BTUART_RXD,
94 GPIO43_BTUART_TXD,
95 GPIO44_BTUART_CTS,
96 GPIO45_BTUART_RTS,
97
98 /* STUART */
99 GPIO46_STUART_RXD,
100 GPIO47_STUART_TXD,
101
102 /* MCI controller */
103 GPIO32_MMC_CLK,
104 GPIO112_MMC_CMD,
105 GPIO92_MMC_DAT_0,
106 GPIO109_MMC_DAT_1,
107 GPIO110_MMC_DAT_2,
108 GPIO111_MMC_DAT_3,
109
110 /* LCD */
111 GPIO58_LCD_LDD_0,
112 GPIO59_LCD_LDD_1,
113 GPIO60_LCD_LDD_2,
114 GPIO61_LCD_LDD_3,
115 GPIO62_LCD_LDD_4,
116 GPIO63_LCD_LDD_5,
117 GPIO64_LCD_LDD_6,
118 GPIO65_LCD_LDD_7,
119 GPIO66_LCD_LDD_8,
120 GPIO67_LCD_LDD_9,
121 GPIO68_LCD_LDD_10,
122 GPIO69_LCD_LDD_11,
123 GPIO70_LCD_LDD_12,
124 GPIO71_LCD_LDD_13,
125 GPIO72_LCD_LDD_14,
126 GPIO73_LCD_LDD_15,
127 GPIO74_LCD_FCLK,
128 GPIO75_LCD_LCLK,
129 GPIO76_LCD_PCLK,
130 GPIO77_LCD_BIAS,
131
132 /* QCI */
133 GPIO84_CIF_FV,
134 GPIO25_CIF_LV,
135 GPIO53_CIF_MCLK,
136 GPIO54_CIF_PCLK,
137 GPIO81_CIF_DD_0,
138 GPIO55_CIF_DD_1,
139 GPIO51_CIF_DD_2,
140 GPIO50_CIF_DD_3,
141 GPIO52_CIF_DD_4,
142 GPIO48_CIF_DD_5,
143 GPIO17_CIF_DD_6,
144 GPIO12_CIF_DD_7,
145
146 /* I2C */
147 GPIO117_I2C_SCL,
148 GPIO118_I2C_SDA,
149
150 /* Keypad */
151 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
152 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
153 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
154 GPIO34_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
155 GPIO39_KP_MKIN_4 | WAKEUP_ON_LEVEL_HIGH,
156 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
157 GPIO91_KP_MKIN_6 | WAKEUP_ON_LEVEL_HIGH,
158 GPIO36_KP_MKIN_7 | WAKEUP_ON_LEVEL_HIGH,
159 GPIO103_KP_MKOUT_0,
160 GPIO104_KP_MKOUT_1,
161 GPIO105_KP_MKOUT_2,
162 GPIO106_KP_MKOUT_3,
163 GPIO107_KP_MKOUT_4,
164 GPIO108_KP_MKOUT_5,
165 GPIO96_KP_MKOUT_6,
166 GPIO22_KP_MKOUT_7,
167
168 /* SSP1 */
169 GPIO26_SSP1_RXD,
170 GPIO23_SSP1_SCLK,
171 GPIO24_SSP1_SFRM,
172 GPIO57_SSP1_TXD,
173
174 /* SSP2 */
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200175 GPIO19_GPIO, /* SSP2 clock is used as GPIO for Libertas pin-strap */
176 GPIO14_GPIO,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100177 GPIO89_SSP2_TXD,
178 GPIO88_SSP2_RXD,
179
180 /* SDRAM and local bus */
181 GPIO15_nCS_1,
182 GPIO78_nCS_2,
183 GPIO79_nCS_3,
184 GPIO80_nCS_4,
185 GPIO49_nPWE,
186 GPIO18_RDY,
187
188 /* GPIO */
Mike Rapoport6432f462009-02-02 08:57:51 +0200189 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* sleep/resume button */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100190
191 /* power controls */
192 GPIO20_GPIO | MFP_LPM_DRIVE_LOW, /* GPRS_PWEN */
193 GPIO115_GPIO | MFP_LPM_DRIVE_LOW, /* WLAN_PWEN */
194
195 /* NAND controls */
196 GPIO11_GPIO | MFP_LPM_DRIVE_HIGH, /* NAND CE# */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100197
198 /* interrupts */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100199 GPIO41_GPIO, /* DM9000 interrupt */
200};
201
Mike Rapoport4a697e82009-02-02 08:57:54 +0200202static unsigned long em_x270_pin_config[] = {
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300203 GPIO13_GPIO, /* MMC card detect */
Mike Rapoport128d88b2009-05-12 16:31:16 +0300204 GPIO16_GPIO, /* USB hub reset */
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300205 GPIO56_GPIO, /* NAND Ready/Busy */
206 GPIO93_GPIO | MFP_LPM_DRIVE_LOW, /* Camera reset */
207 GPIO95_GPIO, /* MMC Write protect */
Mike Rapoport4a697e82009-02-02 08:57:54 +0200208};
209
Mike Rapoport7f14a782009-02-02 08:57:55 +0200210static unsigned long exeda_pin_config[] = {
Mike Rapoport128d88b2009-05-12 16:31:16 +0300211 GPIO10_GPIO, /* USB hub reset */
Mike Rapoport7f14a782009-02-02 08:57:55 +0200212 GPIO20_GPIO, /* NAND Ready/Busy */
213 GPIO38_GPIO | MFP_LPM_DRIVE_LOW, /* SD slot power */
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300214 GPIO95_GPIO, /* touchpad IRQ */
Mike Rapoport7f14a782009-02-02 08:57:55 +0200215 GPIO114_GPIO, /* MMC card detect */
216};
217
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100218#if defined(CONFIG_DM9000) || defined(CONFIG_DM9000_MODULE)
219static struct resource em_x270_dm9000_resource[] = {
Mike Rapoport3d505272007-07-18 11:31:46 +0100220 [0] = {
221 .start = PXA_CS2_PHYS,
222 .end = PXA_CS2_PHYS + 3,
223 .flags = IORESOURCE_MEM,
224 },
225 [1] = {
226 .start = PXA_CS2_PHYS + 8,
227 .end = PXA_CS2_PHYS + 8 + 0x3f,
228 .flags = IORESOURCE_MEM,
229 },
230 [2] = {
231 .start = EM_X270_ETHIRQ,
232 .end = EM_X270_ETHIRQ,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100233 .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
Mike Rapoport3d505272007-07-18 11:31:46 +0100234 }
235};
236
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100237static struct dm9000_plat_data em_x270_dm9000_platdata = {
Mike Rapoport4a697e82009-02-02 08:57:54 +0200238 .flags = DM9000_PLATF_NO_EEPROM,
Mike Rapoport3d505272007-07-18 11:31:46 +0100239};
240
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100241static struct platform_device em_x270_dm9000 = {
Mike Rapoport3d505272007-07-18 11:31:46 +0100242 .name = "dm9000",
243 .id = 0,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100244 .num_resources = ARRAY_SIZE(em_x270_dm9000_resource),
245 .resource = em_x270_dm9000_resource,
Mike Rapoport3d505272007-07-18 11:31:46 +0100246 .dev = {
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100247 .platform_data = &em_x270_dm9000_platdata,
Mike Rapoport3d505272007-07-18 11:31:46 +0100248 }
249};
250
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100251static void __init em_x270_init_dm9000(void)
252{
Mike Rapoport4a697e82009-02-02 08:57:54 +0200253 em_x270_dm9000_platdata.flags |= dm9000_flags;
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100254 platform_device_register(&em_x270_dm9000);
255}
256#else
257static inline void em_x270_init_dm9000(void) {}
258#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100259
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100260/* V3020 RTC */
261#if defined(CONFIG_RTC_DRV_V3020) || defined(CONFIG_RTC_DRV_V3020_MODULE)
Mike Rapoport3d505272007-07-18 11:31:46 +0100262static struct resource em_x270_v3020_resource[] = {
263 [0] = {
264 .start = PXA_CS4_PHYS,
265 .end = PXA_CS4_PHYS + 3,
266 .flags = IORESOURCE_MEM,
267 },
268};
269
270static struct v3020_platform_data em_x270_v3020_platdata = {
271 .leftshift = 0,
272};
273
274static struct platform_device em_x270_rtc = {
275 .name = "v3020",
276 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
277 .resource = em_x270_v3020_resource,
278 .id = -1,
279 .dev = {
280 .platform_data = &em_x270_v3020_platdata,
281 }
282};
283
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100284static void __init em_x270_init_rtc(void)
285{
286 platform_device_register(&em_x270_rtc);
287}
288#else
289static inline void em_x270_init_rtc(void) {}
290#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100291
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100292/* NAND flash */
293#if defined(CONFIG_MTD_NAND_PLATFORM) || defined(CONFIG_MTD_NAND_PLATFORM_MODULE)
Mike Rapoport3d505272007-07-18 11:31:46 +0100294static inline void nand_cs_on(void)
295{
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100296 gpio_set_value(GPIO11_NAND_CS, 0);
Mike Rapoport3d505272007-07-18 11:31:46 +0100297}
298
299static void nand_cs_off(void)
300{
301 dsb();
302
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100303 gpio_set_value(GPIO11_NAND_CS, 1);
Mike Rapoport3d505272007-07-18 11:31:46 +0100304}
305
306/* hardware specific access to control-lines */
307static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
308 unsigned int ctrl)
309{
310 struct nand_chip *this = mtd->priv;
311 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
312
313 dsb();
314
315 if (ctrl & NAND_CTRL_CHANGE) {
316 if (ctrl & NAND_ALE)
317 nandaddr |= (1 << 3);
318 else
319 nandaddr &= ~(1 << 3);
320 if (ctrl & NAND_CLE)
321 nandaddr |= (1 << 2);
322 else
323 nandaddr &= ~(1 << 2);
324 if (ctrl & NAND_NCE)
325 nand_cs_on();
326 else
327 nand_cs_off();
328 }
329
330 dsb();
331 this->IO_ADDR_W = (void __iomem *)nandaddr;
332 if (dat != NAND_CMD_NONE)
333 writel(dat, this->IO_ADDR_W);
334
335 dsb();
336}
337
338/* read device ready pin */
339static int em_x270_nand_device_ready(struct mtd_info *mtd)
340{
341 dsb();
342
Mike Rapoport4a697e82009-02-02 08:57:54 +0200343 return gpio_get_value(nand_rb);
Mike Rapoport3d505272007-07-18 11:31:46 +0100344}
345
346static struct mtd_partition em_x270_partition_info[] = {
347 [0] = {
348 .name = "em_x270-0",
349 .offset = 0,
350 .size = SZ_4M,
351 },
352 [1] = {
353 .name = "em_x270-1",
354 .offset = MTDPART_OFS_APPEND,
355 .size = MTDPART_SIZ_FULL
356 },
357};
358
359static const char *em_x270_part_probes[] = { "cmdlinepart", NULL };
360
361struct platform_nand_data em_x270_nand_platdata = {
362 .chip = {
363 .nr_chips = 1,
364 .chip_offset = 0,
365 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
366 .partitions = em_x270_partition_info,
367 .chip_delay = 20,
368 .part_probe_types = em_x270_part_probes,
369 },
370 .ctrl = {
371 .hwcontrol = 0,
372 .dev_ready = em_x270_nand_device_ready,
373 .select_chip = 0,
374 .cmd_ctrl = em_x270_nand_cmd_ctl,
375 },
376};
377
378static struct resource em_x270_nand_resource[] = {
379 [0] = {
380 .start = PXA_CS1_PHYS,
381 .end = PXA_CS1_PHYS + 12,
382 .flags = IORESOURCE_MEM,
383 },
384};
385
386static struct platform_device em_x270_nand = {
387 .name = "gen_nand",
388 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
389 .resource = em_x270_nand_resource,
390 .id = -1,
391 .dev = {
392 .platform_data = &em_x270_nand_platdata,
393 }
394};
395
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100396static void __init em_x270_init_nand(void)
397{
398 int err;
Mike Rapoport3d505272007-07-18 11:31:46 +0100399
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100400 err = gpio_request(GPIO11_NAND_CS, "NAND CS");
401 if (err) {
402 pr_warning("EM-X270: failed to request NAND CS gpio\n");
403 return;
404 }
405
406 gpio_direction_output(GPIO11_NAND_CS, 1);
407
Mike Rapoport4a697e82009-02-02 08:57:54 +0200408 err = gpio_request(nand_rb, "NAND R/B");
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100409 if (err) {
410 pr_warning("EM-X270: failed to request NAND R/B gpio\n");
411 gpio_free(GPIO11_NAND_CS);
412 return;
413 }
414
Mike Rapoport4a697e82009-02-02 08:57:54 +0200415 gpio_direction_input(nand_rb);
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100416
417 platform_device_register(&em_x270_nand);
418}
419#else
420static inline void em_x270_init_nand(void) {}
421#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100422
Mike Rapoport28c88042008-12-03 09:38:10 +0200423#if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
424static struct mtd_partition em_x270_nor_parts[] = {
425 {
426 .name = "Bootloader",
427 .offset = 0x00000000,
428 .size = 0x00050000,
429 .mask_flags = MTD_WRITEABLE /* force read-only */
430 }, {
431 .name = "Environment",
432 .offset = 0x00050000,
433 .size = 0x00010000,
434 }, {
435 .name = "Reserved",
436 .offset = 0x00060000,
437 .size = 0x00050000,
438 .mask_flags = MTD_WRITEABLE /* force read-only */
439 }, {
440 .name = "Splashscreen",
441 .offset = 0x000b0000,
442 .size = 0x00050000,
443 }
444};
445
446static struct physmap_flash_data em_x270_nor_data[] = {
447 [0] = {
448 .width = 2,
449 .parts = em_x270_nor_parts,
450 .nr_parts = ARRAY_SIZE(em_x270_nor_parts),
451 },
452};
453
454static struct resource em_x270_nor_flash_resource = {
455 .start = PXA_CS0_PHYS,
456 .end = PXA_CS0_PHYS + SZ_1M - 1,
457 .flags = IORESOURCE_MEM,
458};
459
460static struct platform_device em_x270_physmap_flash = {
461 .name = "physmap-flash",
462 .id = 0,
463 .num_resources = 1,
464 .resource = &em_x270_nor_flash_resource,
465 .dev = {
466 .platform_data = &em_x270_nor_data,
467 },
468};
469
470static void __init em_x270_init_nor(void)
471{
472 platform_device_register(&em_x270_physmap_flash);
473}
474#else
475static inline void em_x270_init_nor(void) {}
476#endif
477
Mike Rapoport3d505272007-07-18 11:31:46 +0100478/* PXA27x OHCI controller setup */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100479#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
Mike Rapoport128d88b2009-05-12 16:31:16 +0300480static struct regulator *em_x270_usb_ldo;
481
482static int em_x270_usb_hub_init(void)
483{
484 int err;
485
486 em_x270_usb_ldo = regulator_get(NULL, "vcc usb");
487 if (IS_ERR(em_x270_usb_ldo))
488 return PTR_ERR(em_x270_usb_ldo);
489
490 err = gpio_request(GPIO9_USB_VBUS_EN, "vbus en");
491 if (err)
492 goto err_free_usb_ldo;
493
494 err = gpio_request(usb_hub_reset, "hub rst");
495 if (err)
496 goto err_free_vbus_gpio;
497
498 /* USB Hub power-on and reset */
499 gpio_direction_output(usb_hub_reset, 0);
500 regulator_enable(em_x270_usb_ldo);
501 gpio_set_value(usb_hub_reset, 1);
502 gpio_set_value(usb_hub_reset, 0);
503 regulator_disable(em_x270_usb_ldo);
504 regulator_enable(em_x270_usb_ldo);
505 gpio_set_value(usb_hub_reset, 1);
506
507 /* enable VBUS */
508 gpio_direction_output(GPIO9_USB_VBUS_EN, 1);
509
510 return 0;
511
512err_free_vbus_gpio:
513 gpio_free(GPIO9_USB_VBUS_EN);
514err_free_usb_ldo:
515 regulator_put(em_x270_usb_ldo);
516
517 return err;
518}
519
Mike Rapoport3d505272007-07-18 11:31:46 +0100520static int em_x270_ohci_init(struct device *dev)
521{
Mike Rapoport128d88b2009-05-12 16:31:16 +0300522 int err;
523
524 /* we don't want to entirely disable USB if the HUB init failed */
525 err = em_x270_usb_hub_init();
526 if (err)
527 pr_err("USB Hub initialization failed: %d\n", err);
528
Mike Rapoport3d505272007-07-18 11:31:46 +0100529 /* enable port 2 transiever */
530 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
531
532 return 0;
533}
534
Mike Rapoport128d88b2009-05-12 16:31:16 +0300535static void em_x270_ohci_exit(struct device *dev)
536{
537 gpio_free(usb_hub_reset);
538 gpio_free(GPIO9_USB_VBUS_EN);
539
540 if (!IS_ERR(em_x270_usb_ldo)) {
541 if (regulator_is_enabled(em_x270_usb_ldo))
542 regulator_disable(em_x270_usb_ldo);
543
544 regulator_put(em_x270_usb_ldo);
545 }
546}
547
Mike Rapoport3d505272007-07-18 11:31:46 +0100548static struct pxaohci_platform_data em_x270_ohci_platform_data = {
549 .port_mode = PMM_PERPORT_MODE,
Eric Miao097b5332008-09-27 15:49:57 +0800550 .flags = ENABLE_PORT1 | ENABLE_PORT2 | POWER_CONTROL_LOW,
Mike Rapoport3d505272007-07-18 11:31:46 +0100551 .init = em_x270_ohci_init,
Mike Rapoport128d88b2009-05-12 16:31:16 +0300552 .exit = em_x270_ohci_exit,
Mike Rapoport3d505272007-07-18 11:31:46 +0100553};
554
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100555static void __init em_x270_init_ohci(void)
556{
557 pxa_set_ohci_info(&em_x270_ohci_platform_data);
558}
559#else
560static inline void em_x270_init_ohci(void) {}
561#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100562
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100563/* MCI controller setup */
564#if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE)
Mike Rapoport6432f462009-02-02 08:57:51 +0200565static struct regulator *em_x270_sdio_ldo;
566
Mike Rapoport3d505272007-07-18 11:31:46 +0100567static int em_x270_mci_init(struct device *dev,
568 irq_handler_t em_x270_detect_int,
569 void *data)
570{
Mike Rapoport6432f462009-02-02 08:57:51 +0200571 int err;
572
573 em_x270_sdio_ldo = regulator_get(dev, "vcc sdio");
574 if (IS_ERR(em_x270_sdio_ldo)) {
575 dev_err(dev, "can't request SDIO power supply: %ld\n",
576 PTR_ERR(em_x270_sdio_ldo));
577 return PTR_ERR(em_x270_sdio_ldo);
Mike Rapoport3d505272007-07-18 11:31:46 +0100578 }
579
Mike Rapoport4a697e82009-02-02 08:57:54 +0200580 err = request_irq(gpio_to_irq(mmc_cd), em_x270_detect_int,
Mike Rapoport6432f462009-02-02 08:57:51 +0200581 IRQF_DISABLED | IRQF_TRIGGER_RISING |
582 IRQF_TRIGGER_FALLING,
583 "MMC card detect", data);
584 if (err) {
585 dev_err(dev, "can't request MMC card detect IRQ: %d\n", err);
586 goto err_irq;
587 }
588
Mike Rapoport7f14a782009-02-02 08:57:55 +0200589 if (machine_is_em_x270()) {
590 err = gpio_request(GPIO95_MMC_WP, "MMC WP");
591 if (err) {
592 dev_err(dev, "can't request MMC write protect: %d\n",
593 err);
594 goto err_gpio_wp;
595 }
596 gpio_direction_input(GPIO95_MMC_WP);
597 } else {
598 err = gpio_request(GPIO38_SD_PWEN, "sdio power");
599 if (err) {
600 dev_err(dev, "can't request MMC power control : %d\n",
601 err);
602 goto err_gpio_wp;
603 }
604 gpio_direction_output(GPIO38_SD_PWEN, 1);
Mike Rapoport6432f462009-02-02 08:57:51 +0200605 }
606
Mike Rapoport3d505272007-07-18 11:31:46 +0100607 return 0;
Mike Rapoport6432f462009-02-02 08:57:51 +0200608
609err_gpio_wp:
Mike Rapoport4a697e82009-02-02 08:57:54 +0200610 free_irq(gpio_to_irq(mmc_cd), data);
Mike Rapoport6432f462009-02-02 08:57:51 +0200611err_irq:
612 regulator_put(em_x270_sdio_ldo);
613
614 return err;
Mike Rapoport3d505272007-07-18 11:31:46 +0100615}
616
617static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
618{
Mike Rapoport6432f462009-02-02 08:57:51 +0200619 struct pxamci_platform_data* p_d = dev->platform_data;
620
621 if ((1 << vdd) & p_d->ocr_mask) {
622 int vdd_uV = (2000 + (vdd - __ffs(MMC_VDD_20_21)) * 100) * 1000;
623
624 regulator_set_voltage(em_x270_sdio_ldo, vdd_uV, vdd_uV);
625 regulator_enable(em_x270_sdio_ldo);
626 } else {
627 regulator_disable(em_x270_sdio_ldo);
628 }
Mike Rapoport3d505272007-07-18 11:31:46 +0100629}
630
631static void em_x270_mci_exit(struct device *dev, void *data)
632{
Mike Rapoport4a697e82009-02-02 08:57:54 +0200633 free_irq(gpio_to_irq(mmc_cd), data);
Mike Rapoport7f14a782009-02-02 08:57:55 +0200634 regulator_put(em_x270_sdio_ldo);
635
636 if (machine_is_em_x270())
637 gpio_free(GPIO95_MMC_WP);
638 else
639 gpio_free(GPIO38_SD_PWEN);
Mike Rapoport6432f462009-02-02 08:57:51 +0200640}
641
642static int em_x270_mci_get_ro(struct device *dev)
643{
644 return gpio_get_value(GPIO95_MMC_WP);
Mike Rapoport3d505272007-07-18 11:31:46 +0100645}
646
647static struct pxamci_platform_data em_x270_mci_platform_data = {
Mike Rapoport6432f462009-02-02 08:57:51 +0200648 .ocr_mask = MMC_VDD_20_21|MMC_VDD_21_22|MMC_VDD_22_23|
649 MMC_VDD_24_25|MMC_VDD_25_26|MMC_VDD_26_27|
650 MMC_VDD_27_28|MMC_VDD_28_29|MMC_VDD_29_30|
651 MMC_VDD_30_31|MMC_VDD_31_32,
Mike Rapoport3d505272007-07-18 11:31:46 +0100652 .init = em_x270_mci_init,
653 .setpower = em_x270_mci_setpower,
654 .exit = em_x270_mci_exit,
655};
656
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100657static void __init em_x270_init_mmc(void)
658{
Mike Rapoport7f14a782009-02-02 08:57:55 +0200659 if (machine_is_em_x270())
660 em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro;
661
Mike Rapoport6432f462009-02-02 08:57:51 +0200662 em_x270_mci_platform_data.detect_delay = msecs_to_jiffies(250);
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100663 pxa_set_mci_info(&em_x270_mci_platform_data);
664}
665#else
666static inline void em_x270_init_mmc(void) {}
667#endif
668
Mike Rapoport28c88042008-12-03 09:38:10 +0200669/* LCD */
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100670#if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
Mike Rapoport28c88042008-12-03 09:38:10 +0200671static struct pxafb_mode_info em_x270_lcd_modes[] = {
672 [0] = {
673 .pixclock = 38250,
674 .bpp = 16,
675 .xres = 480,
676 .yres = 640,
677 .hsync_len = 8,
678 .vsync_len = 2,
679 .left_margin = 8,
680 .upper_margin = 2,
681 .right_margin = 24,
682 .lower_margin = 4,
683 .sync = 0,
684 },
685 [1] = {
686 .pixclock = 153800,
687 .bpp = 16,
688 .xres = 240,
689 .yres = 320,
690 .hsync_len = 8,
691 .vsync_len = 2,
692 .left_margin = 8,
693 .upper_margin = 2,
694 .right_margin = 88,
695 .lower_margin = 2,
696 .sync = 0,
697 },
Mike Rapoport3d505272007-07-18 11:31:46 +0100698};
699
700static struct pxafb_mach_info em_x270_lcd = {
Mike Rapoport28c88042008-12-03 09:38:10 +0200701 .modes = em_x270_lcd_modes,
702 .num_modes = 2,
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100703 .lcd_conn = LCD_COLOR_TFT_16BPP,
Mike Rapoport3d505272007-07-18 11:31:46 +0100704};
Mike Rapoport28c88042008-12-03 09:38:10 +0200705
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100706static void __init em_x270_init_lcd(void)
707{
708 set_pxa_fb_info(&em_x270_lcd);
709}
710#else
711static inline void em_x270_init_lcd(void) {}
712#endif
713
Mike Rapoport28c88042008-12-03 09:38:10 +0200714#if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
715static struct pxa2xx_spi_master em_x270_spi_info = {
716 .num_chipselect = 1,
717};
718
719static struct pxa2xx_spi_chip em_x270_tdo24m_chip = {
Mike Rapoportbd9d0742009-04-14 08:32:55 +0300720 .rx_threshold = 1,
721 .tx_threshold = 1,
722 .gpio_cs = -1,
Mike Rapoport28c88042008-12-03 09:38:10 +0200723};
724
725static struct tdo24m_platform_data em_x270_tdo24m_pdata = {
726 .model = TDO35S,
727};
728
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200729static struct pxa2xx_spi_master em_x270_spi_2_info = {
730 .num_chipselect = 1,
731 .enable_dma = 1,
732};
733
734static struct pxa2xx_spi_chip em_x270_libertas_chip = {
735 .rx_threshold = 1,
736 .tx_threshold = 1,
737 .timeout = 1000,
738};
739
740static unsigned long em_x270_libertas_pin_config[] = {
741 /* SSP2 */
742 GPIO19_SSP2_SCLK,
743 GPIO14_GPIO,
744 GPIO89_SSP2_TXD,
745 GPIO88_SSP2_RXD,
746};
747
748static int em_x270_libertas_setup(struct spi_device *spi)
749{
750 int err = gpio_request(GPIO115_WLAN_PWEN, "WLAN PWEN");
751 if (err)
752 return err;
753
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300754 err = gpio_request(GPIO19_WLAN_STRAP, "WLAN STRAP");
755 if (err)
756 goto err_free_pwen;
757
758 if (machine_is_exeda()) {
759 err = gpio_request(GPIO37_WLAN_RST, "WLAN RST");
760 if (err)
761 goto err_free_strap;
762
763 gpio_direction_output(GPIO37_WLAN_RST, 1);
764 msleep(100);
765 }
766
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200767 gpio_direction_output(GPIO19_WLAN_STRAP, 1);
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300768 msleep(100);
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200769
770 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_libertas_pin_config));
771
772 gpio_direction_output(GPIO115_WLAN_PWEN, 0);
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300773 msleep(100);
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200774 gpio_set_value(GPIO115_WLAN_PWEN, 1);
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300775 msleep(100);
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200776
777 spi->bits_per_word = 16;
778 spi_setup(spi);
779
780 return 0;
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300781
782err_free_strap:
783 gpio_free(GPIO19_WLAN_STRAP);
784err_free_pwen:
785 gpio_free(GPIO115_WLAN_PWEN);
786
787 return err;
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200788}
789
790static int em_x270_libertas_teardown(struct spi_device *spi)
791{
792 gpio_set_value(GPIO115_WLAN_PWEN, 0);
793 gpio_free(GPIO115_WLAN_PWEN);
Mike Rapoport2f15cb52009-05-12 16:31:14 +0300794 gpio_free(GPIO19_WLAN_STRAP);
795
796 if (machine_is_exeda()) {
797 gpio_set_value(GPIO37_WLAN_RST, 0);
798 gpio_free(GPIO37_WLAN_RST);
799 }
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200800
801 return 0;
802}
803
804struct libertas_spi_platform_data em_x270_libertas_pdata = {
805 .use_dummy_writes = 1,
806 .gpio_cs = 14,
807 .setup = em_x270_libertas_setup,
808 .teardown = em_x270_libertas_teardown,
809};
810
Mike Rapoport28c88042008-12-03 09:38:10 +0200811static struct spi_board_info em_x270_spi_devices[] __initdata = {
812 {
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200813 .modalias = "tdo24m",
814 .max_speed_hz = 1000000,
815 .bus_num = 1,
816 .chip_select = 0,
817 .controller_data = &em_x270_tdo24m_chip,
818 .platform_data = &em_x270_tdo24m_pdata,
819 },
820 {
821 .modalias = "libertas_spi",
822 .max_speed_hz = 13000000,
823 .bus_num = 2,
824 .irq = IRQ_GPIO(116),
825 .chip_select = 0,
826 .controller_data = &em_x270_libertas_chip,
827 .platform_data = &em_x270_libertas_pdata,
Mike Rapoport28c88042008-12-03 09:38:10 +0200828 },
829};
830
831static void __init em_x270_init_spi(void)
832{
833 pxa2xx_set_spi_info(1, &em_x270_spi_info);
Mike Rapoportc9be0e32009-02-03 09:15:30 +0200834 pxa2xx_set_spi_info(2, &em_x270_spi_2_info);
Mike Rapoport28c88042008-12-03 09:38:10 +0200835 spi_register_board_info(ARRAY_AND_SIZE(em_x270_spi_devices));
836}
837#else
838static inline void em_x270_init_spi(void) {}
839#endif
840
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100841#if defined(CONFIG_SND_PXA2XX_AC97) || defined(CONFIG_SND_PXA2XX_AC97_MODULE)
842static void __init em_x270_init_ac97(void)
843{
844 pxa_set_ac97_info(NULL);
845}
846#else
847static inline void em_x270_init_ac97(void) {}
848#endif
849
850#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
Mike Rapoport7f14a782009-02-02 08:57:55 +0200851static unsigned int em_x270_module_matrix_keys[] = {
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100852 KEY(0, 0, KEY_A), KEY(1, 0, KEY_UP), KEY(2, 1, KEY_B),
853 KEY(0, 2, KEY_LEFT), KEY(1, 1, KEY_ENTER), KEY(2, 0, KEY_RIGHT),
854 KEY(0, 1, KEY_C), KEY(1, 2, KEY_DOWN), KEY(2, 2, KEY_D),
855};
856
Mike Rapoport7f14a782009-02-02 08:57:55 +0200857struct pxa27x_keypad_platform_data em_x270_module_keypad_info = {
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100858 /* code map for the matrix keys */
859 .matrix_key_rows = 3,
860 .matrix_key_cols = 3,
Mike Rapoport7f14a782009-02-02 08:57:55 +0200861 .matrix_key_map = em_x270_module_matrix_keys,
862 .matrix_key_map_size = ARRAY_SIZE(em_x270_module_matrix_keys),
863};
864
865static unsigned int em_x270_exeda_matrix_keys[] = {
866 KEY(0, 0, KEY_RIGHTSHIFT), KEY(0, 1, KEY_RIGHTCTRL),
867 KEY(0, 2, KEY_RIGHTALT), KEY(0, 3, KEY_SPACE),
868 KEY(0, 4, KEY_LEFTALT), KEY(0, 5, KEY_LEFTCTRL),
869 KEY(0, 6, KEY_ENTER), KEY(0, 7, KEY_SLASH),
870
871 KEY(1, 0, KEY_DOT), KEY(1, 1, KEY_M),
872 KEY(1, 2, KEY_N), KEY(1, 3, KEY_B),
873 KEY(1, 4, KEY_V), KEY(1, 5, KEY_C),
874 KEY(1, 6, KEY_X), KEY(1, 7, KEY_Z),
875
876 KEY(2, 0, KEY_LEFTSHIFT), KEY(2, 1, KEY_SEMICOLON),
877 KEY(2, 2, KEY_L), KEY(2, 3, KEY_K),
878 KEY(2, 4, KEY_J), KEY(2, 5, KEY_H),
879 KEY(2, 6, KEY_G), KEY(2, 7, KEY_F),
880
881 KEY(3, 0, KEY_D), KEY(3, 1, KEY_S),
882 KEY(3, 2, KEY_A), KEY(3, 3, KEY_TAB),
883 KEY(3, 4, KEY_BACKSPACE), KEY(3, 5, KEY_P),
884 KEY(3, 6, KEY_O), KEY(3, 7, KEY_I),
885
886 KEY(4, 0, KEY_U), KEY(4, 1, KEY_Y),
887 KEY(4, 2, KEY_T), KEY(4, 3, KEY_R),
888 KEY(4, 4, KEY_E), KEY(4, 5, KEY_W),
889 KEY(4, 6, KEY_Q), KEY(4, 7, KEY_MINUS),
890
891 KEY(5, 0, KEY_0), KEY(5, 1, KEY_9),
892 KEY(5, 2, KEY_8), KEY(5, 3, KEY_7),
893 KEY(5, 4, KEY_6), KEY(5, 5, KEY_5),
894 KEY(5, 6, KEY_4), KEY(5, 7, KEY_3),
895
896 KEY(6, 0, KEY_2), KEY(6, 1, KEY_1),
897 KEY(6, 2, KEY_ENTER), KEY(6, 3, KEY_END),
898 KEY(6, 4, KEY_DOWN), KEY(6, 5, KEY_UP),
899 KEY(6, 6, KEY_MENU), KEY(6, 7, KEY_F1),
900
901 KEY(7, 0, KEY_LEFT), KEY(7, 1, KEY_RIGHT),
902 KEY(7, 2, KEY_BACK), KEY(7, 3, KEY_HOME),
903 KEY(7, 4, 0), KEY(7, 5, 0),
904 KEY(7, 6, 0), KEY(7, 7, 0),
905};
906
907struct pxa27x_keypad_platform_data em_x270_exeda_keypad_info = {
908 /* code map for the matrix keys */
909 .matrix_key_rows = 8,
910 .matrix_key_cols = 8,
911 .matrix_key_map = em_x270_exeda_matrix_keys,
912 .matrix_key_map_size = ARRAY_SIZE(em_x270_exeda_matrix_keys),
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100913};
914
915static void __init em_x270_init_keypad(void)
916{
Mike Rapoport7f14a782009-02-02 08:57:55 +0200917 if (machine_is_em_x270())
918 pxa_set_keypad_info(&em_x270_module_keypad_info);
919 else
920 pxa_set_keypad_info(&em_x270_exeda_keypad_info);
Mike Rapoport3c85bce2008-06-16 08:16:46 +0100921}
922#else
923static inline void em_x270_init_keypad(void) {}
924#endif
925
926#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
927static struct gpio_keys_button gpio_keys_button[] = {
928 [0] = {
929 .desc = "sleep/wakeup",
930 .code = KEY_SUSPEND,
931 .type = EV_PWR,
932 .gpio = 1,
933 .wakeup = 1,
934 },
935};
936
937static struct gpio_keys_platform_data em_x270_gpio_keys_data = {
938 .buttons = gpio_keys_button,
939 .nbuttons = 1,
940};
941
942static struct platform_device em_x270_gpio_keys = {
943 .name = "gpio-keys",
944 .id = -1,
945 .dev = {
946 .platform_data = &em_x270_gpio_keys_data,
947 },
948};
949
950static void __init em_x270_init_gpio_keys(void)
951{
952 platform_device_register(&em_x270_gpio_keys);
953}
954#else
955static inline void em_x270_init_gpio_keys(void) {}
956#endif
Mike Rapoport3d505272007-07-18 11:31:46 +0100957
Mike Rapoport28c88042008-12-03 09:38:10 +0200958/* Quick Capture Interface and sensor setup */
959#if defined(CONFIG_VIDEO_PXA27x) || defined(CONFIG_VIDEO_PXA27x_MODULE)
960static struct regulator *em_x270_camera_ldo;
961
962static int em_x270_sensor_init(struct device *dev)
963{
964 int ret;
965
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300966 ret = gpio_request(cam_reset, "camera reset");
Mike Rapoport28c88042008-12-03 09:38:10 +0200967 if (ret)
968 return ret;
969
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300970 gpio_direction_output(cam_reset, 0);
Mike Rapoport28c88042008-12-03 09:38:10 +0200971
972 em_x270_camera_ldo = regulator_get(NULL, "vcc cam");
973 if (em_x270_camera_ldo == NULL) {
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300974 gpio_free(cam_reset);
Mike Rapoport28c88042008-12-03 09:38:10 +0200975 return -ENODEV;
976 }
977
978 ret = regulator_enable(em_x270_camera_ldo);
979 if (ret) {
980 regulator_put(em_x270_camera_ldo);
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300981 gpio_free(cam_reset);
Mike Rapoport28c88042008-12-03 09:38:10 +0200982 return ret;
983 }
984
Mike Rapoport76e3fc32009-05-12 16:31:13 +0300985 gpio_set_value(cam_reset, 1);
Mike Rapoport28c88042008-12-03 09:38:10 +0200986
987 return 0;
988}
989
990struct pxacamera_platform_data em_x270_camera_platform_data = {
991 .init = em_x270_sensor_init,
992 .flags = PXA_CAMERA_MASTER | PXA_CAMERA_DATAWIDTH_8 |
993 PXA_CAMERA_PCLK_EN | PXA_CAMERA_MCLK_EN,
994 .mclk_10khz = 2600,
995};
996
997static int em_x270_sensor_power(struct device *dev, int on)
998{
999 int ret;
1000 int is_on = regulator_is_enabled(em_x270_camera_ldo);
1001
1002 if (on == is_on)
1003 return 0;
1004
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001005 gpio_set_value(cam_reset, !on);
Mike Rapoport28c88042008-12-03 09:38:10 +02001006
1007 if (on)
1008 ret = regulator_enable(em_x270_camera_ldo);
1009 else
1010 ret = regulator_disable(em_x270_camera_ldo);
1011
1012 if (ret)
1013 return ret;
1014
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001015 gpio_set_value(cam_reset, on);
Mike Rapoport28c88042008-12-03 09:38:10 +02001016
1017 return 0;
1018}
1019
1020static struct soc_camera_link iclink = {
1021 .bus_id = 0,
1022 .power = em_x270_sensor_power,
1023};
1024
1025static struct i2c_board_info em_x270_i2c_cam_info[] = {
1026 {
1027 I2C_BOARD_INFO("mt9m111", 0x48),
1028 .platform_data = &iclink,
1029 },
1030};
1031
Mike Rapoport28c88042008-12-03 09:38:10 +02001032static void __init em_x270_init_camera(void)
1033{
Mike Rapoport28c88042008-12-03 09:38:10 +02001034 i2c_register_board_info(0, ARRAY_AND_SIZE(em_x270_i2c_cam_info));
1035 pxa_set_camera_info(&em_x270_camera_platform_data);
1036}
1037#else
1038static inline void em_x270_init_camera(void) {}
1039#endif
1040
1041/* DA9030 related initializations */
Mike Rapoport432adf12009-02-02 08:57:52 +02001042#define REGULATOR_CONSUMER(_name, _dev, _supply) \
1043 static struct regulator_consumer_supply _name##_consumers[] = { \
1044 { \
1045 .dev = _dev, \
1046 .supply = _supply, \
1047 }, \
1048 }
Mike Rapoport28c88042008-12-03 09:38:10 +02001049
Mike Rapoport432adf12009-02-02 08:57:52 +02001050REGULATOR_CONSUMER(ldo3, NULL, "vcc gps");
1051REGULATOR_CONSUMER(ldo5, NULL, "vcc cam");
1052REGULATOR_CONSUMER(ldo10, &pxa_device_mci.dev, "vcc sdio");
1053REGULATOR_CONSUMER(ldo12, NULL, "vcc usb");
1054REGULATOR_CONSUMER(ldo19, NULL, "vcc gprs");
Mike Rapoport28c88042008-12-03 09:38:10 +02001055
Mike Rapoport432adf12009-02-02 08:57:52 +02001056#define REGULATOR_INIT(_ldo, _min_uV, _max_uV, _ops_mask) \
1057 static struct regulator_init_data _ldo##_data = { \
1058 .constraints = { \
1059 .min_uV = _min_uV, \
1060 .max_uV = _max_uV, \
1061 .state_mem = { \
1062 .enabled = 0, \
1063 }, \
1064 .valid_ops_mask = _ops_mask, \
1065 }, \
1066 .num_consumer_supplies = ARRAY_SIZE(_ldo##_consumers), \
1067 .consumer_supplies = _ldo##_consumers, \
1068 };
Mike Rapoport6432f462009-02-02 08:57:51 +02001069
Mike Rapoport432adf12009-02-02 08:57:52 +02001070REGULATOR_INIT(ldo3, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
1071REGULATOR_INIT(ldo5, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1072REGULATOR_INIT(ldo10, 2000000, 3200000,
1073 REGULATOR_CHANGE_STATUS | REGULATOR_CHANGE_VOLTAGE);
1074REGULATOR_INIT(ldo12, 3000000, 3000000, REGULATOR_CHANGE_STATUS);
1075REGULATOR_INIT(ldo19, 3200000, 3200000, REGULATOR_CHANGE_STATUS);
Mike Rapoport28c88042008-12-03 09:38:10 +02001076
1077struct led_info em_x270_led_info = {
1078 .name = "em-x270:orange",
1079 .default_trigger = "battery-charging-or-full",
1080};
1081
Mike Rapoport9f055c42009-02-02 08:57:53 +02001082struct power_supply_info em_x270_psy_info = {
Mike Rapoport3690a0f2009-05-12 16:31:15 +03001083 .name = "battery",
Mike Rapoport9f055c42009-02-02 08:57:53 +02001084 .technology = POWER_SUPPLY_TECHNOLOGY_LIPO,
1085 .voltage_max_design = 4200000,
1086 .voltage_min_design = 3000000,
1087 .use_for_apm = 1,
1088};
1089
1090static void em_x270_battery_low(void)
1091{
1092 apm_queue_event(APM_LOW_BATTERY);
1093}
1094
1095static void em_x270_battery_critical(void)
1096{
1097 apm_queue_event(APM_CRITICAL_SUSPEND);
1098}
1099
1100struct da9030_battery_info em_x270_batterty_info = {
1101 .battery_info = &em_x270_psy_info,
1102
1103 .charge_milliamp = 1000,
1104 .charge_millivolt = 4200,
1105
1106 .vbat_low = 3600,
1107 .vbat_crit = 3400,
1108 .vbat_charge_start = 4100,
1109 .vbat_charge_stop = 4200,
1110 .vbat_charge_restart = 4000,
1111
1112 .vcharge_min = 3200,
1113 .vcharge_max = 5500,
1114
1115 .tbat_low = 197,
1116 .tbat_high = 78,
1117 .tbat_restart = 100,
1118
1119 .batmon_interval = 0,
1120
1121 .battery_low = em_x270_battery_low,
1122 .battery_critical = em_x270_battery_critical,
1123};
1124
Mike Rapoport432adf12009-02-02 08:57:52 +02001125#define DA9030_SUBDEV(_name, _id, _pdata) \
1126 { \
1127 .name = "da903x-" #_name, \
1128 .id = DA9030_ID_##_id, \
1129 .platform_data = _pdata, \
Mike Rapoport28c88042008-12-03 09:38:10 +02001130 }
Mike Rapoport432adf12009-02-02 08:57:52 +02001131
1132#define DA9030_LDO(num) DA9030_SUBDEV(regulator, LDO##num, &ldo##num##_data)
1133
1134struct da903x_subdev_info em_x270_da9030_subdevs[] = {
1135 DA9030_LDO(3),
1136 DA9030_LDO(5),
1137 DA9030_LDO(10),
1138 DA9030_LDO(12),
1139 DA9030_LDO(19),
1140
1141 DA9030_SUBDEV(led, LED_PC, &em_x270_led_info),
1142 DA9030_SUBDEV(backlight, WLED, &em_x270_led_info),
Mike Rapoport9f055c42009-02-02 08:57:53 +02001143 DA9030_SUBDEV(battery, BAT, &em_x270_batterty_info),
Mike Rapoport28c88042008-12-03 09:38:10 +02001144};
1145
1146static struct da903x_platform_data em_x270_da9030_info = {
1147 .num_subdevs = ARRAY_SIZE(em_x270_da9030_subdevs),
1148 .subdevs = em_x270_da9030_subdevs,
1149};
1150
1151static struct i2c_board_info em_x270_i2c_pmic_info = {
1152 I2C_BOARD_INFO("da9030", 0x49),
1153 .irq = IRQ_GPIO(0),
1154 .platform_data = &em_x270_da9030_info,
1155};
1156
1157static struct i2c_pxa_platform_data em_x270_pwr_i2c_info = {
1158 .use_pio = 1,
1159};
1160
1161static void __init em_x270_init_da9030(void)
1162{
1163 pxa27x_set_i2c_power_info(&em_x270_pwr_i2c_info);
1164 i2c_register_board_info(1, &em_x270_i2c_pmic_info, 1);
1165}
1166
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001167static struct pca953x_platform_data exeda_gpio_ext_pdata = {
1168 .gpio_base = 128,
1169};
1170
1171static struct i2c_board_info exeda_i2c_info[] = {
1172 {
1173 I2C_BOARD_INFO("pca9555", 0x21),
1174 .platform_data = &exeda_gpio_ext_pdata,
1175 },
1176};
1177
1178static struct i2c_pxa_platform_data em_x270_i2c_info = {
1179 .fast_mode = 1,
1180};
1181
1182static void __init em_x270_init_i2c(void)
1183{
1184 pxa_set_i2c_info(&em_x270_i2c_info);
1185
1186 if (machine_is_exeda())
1187 i2c_register_board_info(0, ARRAY_AND_SIZE(exeda_i2c_info));
1188}
1189
Mike Rapoport4a697e82009-02-02 08:57:54 +02001190static void __init em_x270_module_init(void)
Mike Rapoport3d505272007-07-18 11:31:46 +01001191{
Mike Rapoport7f14a782009-02-02 08:57:55 +02001192 pr_info("%s\n", __func__);
Mike Rapoport3c85bce2008-06-16 08:16:46 +01001193 pxa2xx_mfp_config(ARRAY_AND_SIZE(em_x270_pin_config));
Mike Rapoport3d505272007-07-18 11:31:46 +01001194
Mike Rapoport4a697e82009-02-02 08:57:54 +02001195 mmc_cd = GPIO13_MMC_CD;
1196 nand_rb = GPIO56_NAND_RB;
1197 dm9000_flags = DM9000_PLATF_32BITONLY;
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001198 cam_reset = GPIO93_CAM_RESET;
Mike Rapoport128d88b2009-05-12 16:31:16 +03001199 usb_hub_reset = GPIO16_USB_HUB_RESET;
Mike Rapoport4a697e82009-02-02 08:57:54 +02001200}
1201
Mike Rapoport7f14a782009-02-02 08:57:55 +02001202static void __init em_x270_exeda_init(void)
1203{
1204 pr_info("%s\n", __func__);
1205 pxa2xx_mfp_config(ARRAY_AND_SIZE(exeda_pin_config));
1206
1207 mmc_cd = GPIO114_MMC_CD;
1208 nand_rb = GPIO20_NAND_RB;
1209 dm9000_flags = DM9000_PLATF_16BITONLY;
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001210 cam_reset = GPIO130_CAM_RESET;
Mike Rapoport128d88b2009-05-12 16:31:16 +03001211 usb_hub_reset = GPIO10_USB_HUB_RESET;
Mike Rapoport7f14a782009-02-02 08:57:55 +02001212}
1213
Mike Rapoport4a697e82009-02-02 08:57:54 +02001214static void __init em_x270_init(void)
1215{
1216 pxa2xx_mfp_config(ARRAY_AND_SIZE(common_pin_config));
1217
Mike Rapoport9599d1d2009-05-26 09:41:46 +03001218#ifdef CONFIG_PM
1219 pxa27x_set_pwrmode(PWRMODE_DEEPSLEEP);
1220#endif
1221
Mike Rapoport7f14a782009-02-02 08:57:55 +02001222 if (machine_is_em_x270())
1223 em_x270_module_init();
1224 else if (machine_is_exeda())
1225 em_x270_exeda_init();
1226 else
1227 panic("Unsupported machine: %d\n", machine_arch_type);
Mike Rapoport4a697e82009-02-02 08:57:54 +02001228
Mike Rapoport28c88042008-12-03 09:38:10 +02001229 em_x270_init_da9030();
Mike Rapoport3c85bce2008-06-16 08:16:46 +01001230 em_x270_init_dm9000();
1231 em_x270_init_rtc();
1232 em_x270_init_nand();
Mike Rapoport28c88042008-12-03 09:38:10 +02001233 em_x270_init_nor();
Mike Rapoport3c85bce2008-06-16 08:16:46 +01001234 em_x270_init_lcd();
1235 em_x270_init_mmc();
1236 em_x270_init_ohci();
1237 em_x270_init_keypad();
1238 em_x270_init_gpio_keys();
1239 em_x270_init_ac97();
Mike Rapoport28c88042008-12-03 09:38:10 +02001240 em_x270_init_spi();
Mike Rapoport76e3fc32009-05-12 16:31:13 +03001241 em_x270_init_i2c();
1242 em_x270_init_camera();
Mike Rapoport3d505272007-07-18 11:31:46 +01001243}
1244
Mike Rapoport3c85bce2008-06-16 08:16:46 +01001245MACHINE_START(EM_X270, "Compulab EM-X270")
Mike Rapoport3d505272007-07-18 11:31:46 +01001246 .boot_params = 0xa0000100,
1247 .phys_io = 0x40000000,
1248 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1249 .map_io = pxa_map_io,
1250 .init_irq = pxa27x_init_irq,
1251 .timer = &pxa_timer,
1252 .init_machine = em_x270_init,
1253MACHINE_END
Mike Rapoport7f14a782009-02-02 08:57:55 +02001254
1255MACHINE_START(EXEDA, "Compulab eXeda")
1256 .boot_params = 0xa0000100,
1257 .phys_io = 0x40000000,
1258 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
1259 .map_io = pxa_map_io,
1260 .init_irq = pxa27x_init_irq,
1261 .timer = &pxa_timer,
1262 .init_machine = em_x270_init,
1263MACHINE_END