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