ARM: davinci: da850 evm: change audio edma event queue to EVENTQ_0
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-davinci / board-da850-evm.c
blobf8936174ce812438923b617ed5c935eac00ab523
1 /*
2 * TI DA850/OMAP-L138 EVM board
4 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
6 * Derived from: arch/arm/mach-davinci/board-da830-evm.c
7 * Original Copyrights follow:
9 * 2007, 2009 (c) MontaVista Software, Inc. This file is licensed under
10 * the terms of the GNU General Public License version 2. This program
11 * is licensed "as is" without any warranty of any kind, whether express
12 * or implied.
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/console.h>
17 #include <linux/i2c.h>
18 #include <linux/i2c/at24.h>
19 #include <linux/i2c/pca953x.h>
20 #include <linux/input.h>
21 #include <linux/mfd/tps6507x.h>
22 #include <linux/gpio.h>
23 #include <linux/gpio_keys.h>
24 #include <linux/platform_device.h>
25 #include <linux/mtd/mtd.h>
26 #include <linux/mtd/nand.h>
27 #include <linux/mtd/partitions.h>
28 #include <linux/mtd/physmap.h>
29 #include <linux/regulator/machine.h>
30 #include <linux/regulator/tps6507x.h>
31 #include <linux/input/tps6507x-ts.h>
32 #include <linux/spi/spi.h>
33 #include <linux/spi/flash.h>
35 #include <asm/mach-types.h>
36 #include <asm/mach/arch.h>
38 #include <mach/cp_intc.h>
39 #include <mach/da8xx.h>
40 #include <mach/nand.h>
41 #include <mach/mux.h>
42 #include <mach/aemif.h>
43 #include <mach/spi.h>
45 #define DA850_EVM_PHY_ID "0:00"
46 #define DA850_LCD_PWR_PIN GPIO_TO_PIN(2, 8)
47 #define DA850_LCD_BL_PIN GPIO_TO_PIN(2, 15)
49 #define DA850_MMCSD_CD_PIN GPIO_TO_PIN(4, 0)
50 #define DA850_MMCSD_WP_PIN GPIO_TO_PIN(4, 1)
52 #define DA850_MII_MDIO_CLKEN_PIN GPIO_TO_PIN(2, 6)
54 static struct mtd_partition da850evm_spiflash_part[] = {
55 [0] = {
56 .name = "UBL",
57 .offset = 0,
58 .size = SZ_64K,
59 .mask_flags = MTD_WRITEABLE,
61 [1] = {
62 .name = "U-Boot",
63 .offset = MTDPART_OFS_APPEND,
64 .size = SZ_512K,
65 .mask_flags = MTD_WRITEABLE,
67 [2] = {
68 .name = "U-Boot-Env",
69 .offset = MTDPART_OFS_APPEND,
70 .size = SZ_64K,
71 .mask_flags = MTD_WRITEABLE,
73 [3] = {
74 .name = "Kernel",
75 .offset = MTDPART_OFS_APPEND,
76 .size = SZ_2M + SZ_512K,
77 .mask_flags = 0,
79 [4] = {
80 .name = "Filesystem",
81 .offset = MTDPART_OFS_APPEND,
82 .size = SZ_4M,
83 .mask_flags = 0,
85 [5] = {
86 .name = "MAC-Address",
87 .offset = SZ_8M - SZ_64K,
88 .size = SZ_64K,
89 .mask_flags = MTD_WRITEABLE,
93 static struct flash_platform_data da850evm_spiflash_data = {
94 .name = "m25p80",
95 .parts = da850evm_spiflash_part,
96 .nr_parts = ARRAY_SIZE(da850evm_spiflash_part),
97 .type = "m25p64",
100 static struct davinci_spi_config da850evm_spiflash_cfg = {
101 .io_type = SPI_IO_TYPE_DMA,
102 .c2tdelay = 8,
103 .t2cdelay = 8,
106 static struct spi_board_info da850evm_spi_info[] = {
108 .modalias = "m25p80",
109 .platform_data = &da850evm_spiflash_data,
110 .controller_data = &da850evm_spiflash_cfg,
111 .mode = SPI_MODE_0,
112 .max_speed_hz = 30000000,
113 .bus_num = 1,
114 .chip_select = 0,
118 #ifdef CONFIG_MTD
119 static void da850_evm_m25p80_notify_add(struct mtd_info *mtd)
121 char *mac_addr = davinci_soc_info.emac_pdata->mac_addr;
122 size_t retlen;
124 if (!strcmp(mtd->name, "MAC-Address")) {
125 mtd->read(mtd, 0, ETH_ALEN, &retlen, mac_addr);
126 if (retlen == ETH_ALEN)
127 pr_info("Read MAC addr from SPI Flash: %pM\n",
128 mac_addr);
132 static struct mtd_notifier da850evm_spi_notifier = {
133 .add = da850_evm_m25p80_notify_add,
136 static void da850_evm_setup_mac_addr(void)
138 register_mtd_user(&da850evm_spi_notifier);
140 #else
141 static void da850_evm_setup_mac_addr(void) { }
142 #endif
144 static struct mtd_partition da850_evm_norflash_partition[] = {
146 .name = "bootloaders + env",
147 .offset = 0,
148 .size = SZ_512K,
149 .mask_flags = MTD_WRITEABLE,
152 .name = "kernel",
153 .offset = MTDPART_OFS_APPEND,
154 .size = SZ_2M,
155 .mask_flags = 0,
158 .name = "filesystem",
159 .offset = MTDPART_OFS_APPEND,
160 .size = MTDPART_SIZ_FULL,
161 .mask_flags = 0,
165 static struct physmap_flash_data da850_evm_norflash_data = {
166 .width = 2,
167 .parts = da850_evm_norflash_partition,
168 .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
171 static struct resource da850_evm_norflash_resource[] = {
173 .start = DA8XX_AEMIF_CS2_BASE,
174 .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
175 .flags = IORESOURCE_MEM,
179 static struct platform_device da850_evm_norflash_device = {
180 .name = "physmap-flash",
181 .id = 0,
182 .dev = {
183 .platform_data = &da850_evm_norflash_data,
185 .num_resources = 1,
186 .resource = da850_evm_norflash_resource,
189 static struct davinci_pm_config da850_pm_pdata = {
190 .sleepcount = 128,
193 static struct platform_device da850_pm_device = {
194 .name = "pm-davinci",
195 .dev = {
196 .platform_data = &da850_pm_pdata,
198 .id = -1,
201 /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
202 * (128K blocks). It may be used instead of the (default) SPI flash
203 * to boot, using TI's tools to install the secondary boot loader
204 * (UBL) and U-Boot.
206 static struct mtd_partition da850_evm_nandflash_partition[] = {
208 .name = "u-boot env",
209 .offset = 0,
210 .size = SZ_128K,
211 .mask_flags = MTD_WRITEABLE,
214 .name = "UBL",
215 .offset = MTDPART_OFS_APPEND,
216 .size = SZ_128K,
217 .mask_flags = MTD_WRITEABLE,
220 .name = "u-boot",
221 .offset = MTDPART_OFS_APPEND,
222 .size = 4 * SZ_128K,
223 .mask_flags = MTD_WRITEABLE,
226 .name = "kernel",
227 .offset = 0x200000,
228 .size = SZ_2M,
229 .mask_flags = 0,
232 .name = "filesystem",
233 .offset = MTDPART_OFS_APPEND,
234 .size = MTDPART_SIZ_FULL,
235 .mask_flags = 0,
239 static struct davinci_aemif_timing da850_evm_nandflash_timing = {
240 .wsetup = 24,
241 .wstrobe = 21,
242 .whold = 14,
243 .rsetup = 19,
244 .rstrobe = 50,
245 .rhold = 0,
246 .ta = 20,
249 static struct davinci_nand_pdata da850_evm_nandflash_data = {
250 .parts = da850_evm_nandflash_partition,
251 .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
252 .ecc_mode = NAND_ECC_HW,
253 .ecc_bits = 4,
254 .options = NAND_USE_FLASH_BBT,
255 .timing = &da850_evm_nandflash_timing,
258 static struct resource da850_evm_nandflash_resource[] = {
260 .start = DA8XX_AEMIF_CS3_BASE,
261 .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
262 .flags = IORESOURCE_MEM,
265 .start = DA8XX_AEMIF_CTL_BASE,
266 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
267 .flags = IORESOURCE_MEM,
271 static struct platform_device da850_evm_nandflash_device = {
272 .name = "davinci_nand",
273 .id = 1,
274 .dev = {
275 .platform_data = &da850_evm_nandflash_data,
277 .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
278 .resource = da850_evm_nandflash_resource,
281 static struct platform_device *da850_evm_devices[] __initdata = {
282 &da850_evm_nandflash_device,
283 &da850_evm_norflash_device,
286 #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
287 #define DA8XX_AEMIF_ASIZE_16BIT 0x1
289 static void __init da850_evm_init_nor(void)
291 void __iomem *aemif_addr;
293 aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
295 /* Configure data bus width of CS2 to 16 bit */
296 writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
297 DA8XX_AEMIF_ASIZE_16BIT,
298 aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
300 iounmap(aemif_addr);
303 static const short da850_evm_nand_pins[] = {
304 DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
305 DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
306 DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
307 DA850_NEMA_WE, DA850_NEMA_OE,
311 static const short da850_evm_nor_pins[] = {
312 DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
313 DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
314 DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
315 DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
316 DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
317 DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
318 DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
319 DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
320 DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
321 DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
322 DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
323 DA850_EMA_A_22, DA850_EMA_A_23,
327 #if defined(CONFIG_MMC_DAVINCI) || \
328 defined(CONFIG_MMC_DAVINCI_MODULE)
329 #define HAS_MMC 1
330 #else
331 #define HAS_MMC 0
332 #endif
334 static inline void da850_evm_setup_nor_nand(void)
336 int ret = 0;
338 if (!HAS_MMC) {
339 ret = davinci_cfg_reg_list(da850_evm_nand_pins);
340 if (ret)
341 pr_warning("da850_evm_init: nand mux setup failed: "
342 "%d\n", ret);
344 ret = davinci_cfg_reg_list(da850_evm_nor_pins);
345 if (ret)
346 pr_warning("da850_evm_init: nor mux setup failed: %d\n",
347 ret);
349 da850_evm_init_nor();
351 platform_add_devices(da850_evm_devices,
352 ARRAY_SIZE(da850_evm_devices));
356 #ifdef CONFIG_DA850_UI_RMII
357 static inline void da850_evm_setup_emac_rmii(int rmii_sel)
359 struct davinci_soc_info *soc_info = &davinci_soc_info;
361 soc_info->emac_pdata->rmii_en = 1;
362 gpio_set_value_cansleep(rmii_sel, 0);
364 #else
365 static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
366 #endif
369 #define DA850_KEYS_DEBOUNCE_MS 10
371 * At 200ms polling interval it is possible to miss an
372 * event by tapping very lightly on the push button but most
373 * pushes do result in an event; longer intervals require the
374 * user to hold the button whereas shorter intervals require
375 * more CPU time for polling.
377 #define DA850_GPIO_KEYS_POLL_MS 200
379 enum da850_evm_ui_exp_pins {
380 DA850_EVM_UI_EXP_SEL_C = 5,
381 DA850_EVM_UI_EXP_SEL_B,
382 DA850_EVM_UI_EXP_SEL_A,
383 DA850_EVM_UI_EXP_PB8,
384 DA850_EVM_UI_EXP_PB7,
385 DA850_EVM_UI_EXP_PB6,
386 DA850_EVM_UI_EXP_PB5,
387 DA850_EVM_UI_EXP_PB4,
388 DA850_EVM_UI_EXP_PB3,
389 DA850_EVM_UI_EXP_PB2,
390 DA850_EVM_UI_EXP_PB1,
393 static const char const *da850_evm_ui_exp[] = {
394 [DA850_EVM_UI_EXP_SEL_C] = "sel_c",
395 [DA850_EVM_UI_EXP_SEL_B] = "sel_b",
396 [DA850_EVM_UI_EXP_SEL_A] = "sel_a",
397 [DA850_EVM_UI_EXP_PB8] = "pb8",
398 [DA850_EVM_UI_EXP_PB7] = "pb7",
399 [DA850_EVM_UI_EXP_PB6] = "pb6",
400 [DA850_EVM_UI_EXP_PB5] = "pb5",
401 [DA850_EVM_UI_EXP_PB4] = "pb4",
402 [DA850_EVM_UI_EXP_PB3] = "pb3",
403 [DA850_EVM_UI_EXP_PB2] = "pb2",
404 [DA850_EVM_UI_EXP_PB1] = "pb1",
407 #define DA850_N_UI_PB 8
409 static struct gpio_keys_button da850_evm_ui_keys[] = {
410 [0 ... DA850_N_UI_PB - 1] = {
411 .type = EV_KEY,
412 .active_low = 1,
413 .wakeup = 0,
414 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
415 .code = -1, /* assigned at runtime */
416 .gpio = -1, /* assigned at runtime */
417 .desc = NULL, /* assigned at runtime */
421 static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
422 .buttons = da850_evm_ui_keys,
423 .nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
424 .poll_interval = DA850_GPIO_KEYS_POLL_MS,
427 static struct platform_device da850_evm_ui_keys_device = {
428 .name = "gpio-keys-polled",
429 .id = 0,
430 .dev = {
431 .platform_data = &da850_evm_ui_keys_pdata
435 static void da850_evm_ui_keys_init(unsigned gpio)
437 int i;
438 struct gpio_keys_button *button;
440 for (i = 0; i < DA850_N_UI_PB; i++) {
441 button = &da850_evm_ui_keys[i];
442 button->code = KEY_F8 - i;
443 button->desc = (char *)
444 da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
445 button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
449 static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
450 unsigned ngpio, void *c)
452 int sel_a, sel_b, sel_c, ret;
454 sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
455 sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
456 sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
458 ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
459 if (ret) {
460 pr_warning("Cannot open UI expander pin %d\n", sel_a);
461 goto exp_setup_sela_fail;
464 ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
465 if (ret) {
466 pr_warning("Cannot open UI expander pin %d\n", sel_b);
467 goto exp_setup_selb_fail;
470 ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
471 if (ret) {
472 pr_warning("Cannot open UI expander pin %d\n", sel_c);
473 goto exp_setup_selc_fail;
476 /* deselect all functionalities */
477 gpio_direction_output(sel_a, 1);
478 gpio_direction_output(sel_b, 1);
479 gpio_direction_output(sel_c, 1);
481 da850_evm_ui_keys_init(gpio);
482 ret = platform_device_register(&da850_evm_ui_keys_device);
483 if (ret) {
484 pr_warning("Could not register UI GPIO expander push-buttons");
485 goto exp_setup_keys_fail;
488 pr_info("DA850/OMAP-L138 EVM UI card detected\n");
490 da850_evm_setup_nor_nand();
492 da850_evm_setup_emac_rmii(sel_a);
494 return 0;
496 exp_setup_keys_fail:
497 gpio_free(sel_c);
498 exp_setup_selc_fail:
499 gpio_free(sel_b);
500 exp_setup_selb_fail:
501 gpio_free(sel_a);
502 exp_setup_sela_fail:
503 return ret;
506 static int da850_evm_ui_expander_teardown(struct i2c_client *client,
507 unsigned gpio, unsigned ngpio, void *c)
509 platform_device_unregister(&da850_evm_ui_keys_device);
511 /* deselect all functionalities */
512 gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
513 gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
514 gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
516 gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
517 gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
518 gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
520 return 0;
523 /* assign the baseboard expander's GPIOs after the UI board's */
524 #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
525 #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
527 enum da850_evm_bb_exp_pins {
528 DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
529 DA850_EVM_BB_EXP_SW_RST,
530 DA850_EVM_BB_EXP_TP_23,
531 DA850_EVM_BB_EXP_TP_22,
532 DA850_EVM_BB_EXP_TP_21,
533 DA850_EVM_BB_EXP_USER_PB1,
534 DA850_EVM_BB_EXP_USER_LED2,
535 DA850_EVM_BB_EXP_USER_LED1,
536 DA850_EVM_BB_EXP_USER_SW1,
537 DA850_EVM_BB_EXP_USER_SW2,
538 DA850_EVM_BB_EXP_USER_SW3,
539 DA850_EVM_BB_EXP_USER_SW4,
540 DA850_EVM_BB_EXP_USER_SW5,
541 DA850_EVM_BB_EXP_USER_SW6,
542 DA850_EVM_BB_EXP_USER_SW7,
543 DA850_EVM_BB_EXP_USER_SW8
546 static const char const *da850_evm_bb_exp[] = {
547 [DA850_EVM_BB_EXP_DEEP_SLEEP_EN] = "deep_sleep_en",
548 [DA850_EVM_BB_EXP_SW_RST] = "sw_rst",
549 [DA850_EVM_BB_EXP_TP_23] = "tp_23",
550 [DA850_EVM_BB_EXP_TP_22] = "tp_22",
551 [DA850_EVM_BB_EXP_TP_21] = "tp_21",
552 [DA850_EVM_BB_EXP_USER_PB1] = "user_pb1",
553 [DA850_EVM_BB_EXP_USER_LED2] = "user_led2",
554 [DA850_EVM_BB_EXP_USER_LED1] = "user_led1",
555 [DA850_EVM_BB_EXP_USER_SW1] = "user_sw1",
556 [DA850_EVM_BB_EXP_USER_SW2] = "user_sw2",
557 [DA850_EVM_BB_EXP_USER_SW3] = "user_sw3",
558 [DA850_EVM_BB_EXP_USER_SW4] = "user_sw4",
559 [DA850_EVM_BB_EXP_USER_SW5] = "user_sw5",
560 [DA850_EVM_BB_EXP_USER_SW6] = "user_sw6",
561 [DA850_EVM_BB_EXP_USER_SW7] = "user_sw7",
562 [DA850_EVM_BB_EXP_USER_SW8] = "user_sw8",
565 #define DA850_N_BB_USER_SW 8
567 static struct gpio_keys_button da850_evm_bb_keys[] = {
568 [0] = {
569 .type = EV_KEY,
570 .active_low = 1,
571 .wakeup = 0,
572 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
573 .code = KEY_PROG1,
574 .desc = NULL, /* assigned at runtime */
575 .gpio = -1, /* assigned at runtime */
577 [1 ... DA850_N_BB_USER_SW] = {
578 .type = EV_SW,
579 .active_low = 1,
580 .wakeup = 0,
581 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
582 .code = -1, /* assigned at runtime */
583 .desc = NULL, /* assigned at runtime */
584 .gpio = -1, /* assigned at runtime */
588 static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
589 .buttons = da850_evm_bb_keys,
590 .nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
591 .poll_interval = DA850_GPIO_KEYS_POLL_MS,
594 static struct platform_device da850_evm_bb_keys_device = {
595 .name = "gpio-keys-polled",
596 .id = 1,
597 .dev = {
598 .platform_data = &da850_evm_bb_keys_pdata
602 static void da850_evm_bb_keys_init(unsigned gpio)
604 int i;
605 struct gpio_keys_button *button;
607 button = &da850_evm_bb_keys[0];
608 button->desc = (char *)
609 da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
610 button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
612 for (i = 0; i < DA850_N_BB_USER_SW; i++) {
613 button = &da850_evm_bb_keys[i + 1];
614 button->code = SW_LID + i;
615 button->desc = (char *)
616 da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
617 button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
621 #define DA850_N_BB_USER_LED 2
623 static struct gpio_led da850_evm_bb_leds[] = {
624 [0 ... DA850_N_BB_USER_LED - 1] = {
625 .active_low = 1,
626 .gpio = -1, /* assigned at runtime */
627 .name = NULL, /* assigned at runtime */
631 static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
632 .leds = da850_evm_bb_leds,
633 .num_leds = ARRAY_SIZE(da850_evm_bb_leds),
636 static struct platform_device da850_evm_bb_leds_device = {
637 .name = "leds-gpio",
638 .id = -1,
639 .dev = {
640 .platform_data = &da850_evm_bb_leds_pdata
644 static void da850_evm_bb_leds_init(unsigned gpio)
646 int i;
647 struct gpio_led *led;
649 for (i = 0; i < DA850_N_BB_USER_LED; i++) {
650 led = &da850_evm_bb_leds[i];
652 led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
653 led->name =
654 da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
658 static int da850_evm_bb_expander_setup(struct i2c_client *client,
659 unsigned gpio, unsigned ngpio,
660 void *c)
662 int ret;
665 * Register the switches and pushbutton on the baseboard as a gpio-keys
666 * device.
668 da850_evm_bb_keys_init(gpio);
669 ret = platform_device_register(&da850_evm_bb_keys_device);
670 if (ret) {
671 pr_warning("Could not register baseboard GPIO expander keys");
672 goto io_exp_setup_sw_fail;
675 da850_evm_bb_leds_init(gpio);
676 ret = platform_device_register(&da850_evm_bb_leds_device);
677 if (ret) {
678 pr_warning("Could not register baseboard GPIO expander LEDS");
679 goto io_exp_setup_leds_fail;
682 return 0;
684 io_exp_setup_leds_fail:
685 platform_device_unregister(&da850_evm_bb_keys_device);
686 io_exp_setup_sw_fail:
687 return ret;
690 static int da850_evm_bb_expander_teardown(struct i2c_client *client,
691 unsigned gpio, unsigned ngpio, void *c)
693 platform_device_unregister(&da850_evm_bb_leds_device);
694 platform_device_unregister(&da850_evm_bb_keys_device);
696 return 0;
699 static struct pca953x_platform_data da850_evm_ui_expander_info = {
700 .gpio_base = DAVINCI_N_GPIO,
701 .setup = da850_evm_ui_expander_setup,
702 .teardown = da850_evm_ui_expander_teardown,
703 .names = da850_evm_ui_exp,
706 static struct pca953x_platform_data da850_evm_bb_expander_info = {
707 .gpio_base = DA850_BB_EXPANDER_GPIO_BASE,
708 .setup = da850_evm_bb_expander_setup,
709 .teardown = da850_evm_bb_expander_teardown,
710 .names = da850_evm_bb_exp,
713 static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
715 I2C_BOARD_INFO("tlv320aic3x", 0x18),
718 I2C_BOARD_INFO("tca6416", 0x20),
719 .platform_data = &da850_evm_ui_expander_info,
722 I2C_BOARD_INFO("tca6416", 0x21),
723 .platform_data = &da850_evm_bb_expander_info,
727 static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
728 .bus_freq = 100, /* kHz */
729 .bus_delay = 0, /* usec */
732 static struct davinci_uart_config da850_evm_uart_config __initdata = {
733 .enabled_uarts = 0x7,
736 /* davinci da850 evm audio machine driver */
737 static u8 da850_iis_serializer_direction[] = {
738 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
739 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
740 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
741 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
744 static struct snd_platform_data da850_evm_snd_data = {
745 .tx_dma_offset = 0x2000,
746 .rx_dma_offset = 0x2000,
747 .op_mode = DAVINCI_MCASP_IIS_MODE,
748 .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
749 .tdm_slots = 2,
750 .serial_dir = da850_iis_serializer_direction,
751 .asp_chan_q = EVENTQ_0,
752 .version = MCASP_VERSION_2,
753 .txnumevt = 1,
754 .rxnumevt = 1,
757 static const short da850_evm_mcasp_pins[] __initconst = {
758 DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
759 DA850_AHCLKR, DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
760 DA850_AXR_11, DA850_AXR_12,
764 static int da850_evm_mmc_get_ro(int index)
766 return gpio_get_value(DA850_MMCSD_WP_PIN);
769 static int da850_evm_mmc_get_cd(int index)
771 return !gpio_get_value(DA850_MMCSD_CD_PIN);
774 static struct davinci_mmc_config da850_mmc_config = {
775 .get_ro = da850_evm_mmc_get_ro,
776 .get_cd = da850_evm_mmc_get_cd,
777 .wires = 4,
778 .max_freq = 50000000,
779 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
780 .version = MMC_CTLR_VERSION_2,
783 static const short da850_evm_mmcsd0_pins[] __initconst = {
784 DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
785 DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
786 DA850_GPIO4_0, DA850_GPIO4_1,
790 static void da850_panel_power_ctrl(int val)
792 /* lcd backlight */
793 gpio_set_value(DA850_LCD_BL_PIN, val);
795 /* lcd power */
796 gpio_set_value(DA850_LCD_PWR_PIN, val);
799 static int da850_lcd_hw_init(void)
801 int status;
803 status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
804 if (status < 0)
805 return status;
807 status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
808 if (status < 0) {
809 gpio_free(DA850_LCD_BL_PIN);
810 return status;
813 gpio_direction_output(DA850_LCD_BL_PIN, 0);
814 gpio_direction_output(DA850_LCD_PWR_PIN, 0);
816 /* Switch off panel power and backlight */
817 da850_panel_power_ctrl(0);
819 /* Switch on panel power and backlight */
820 da850_panel_power_ctrl(1);
822 return 0;
825 /* TPS65070 voltage regulator support */
827 /* 3.3V */
828 static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
830 .supply = "usb0_vdda33",
833 .supply = "usb1_vdda33",
837 /* 3.3V or 1.8V */
838 static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
840 .supply = "dvdd3318_a",
843 .supply = "dvdd3318_b",
846 .supply = "dvdd3318_c",
850 /* 1.2V */
851 static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
853 .supply = "cvdd",
857 /* 1.8V LDO */
858 static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
860 .supply = "sata_vddr",
863 .supply = "usb0_vdda18",
866 .supply = "usb1_vdda18",
869 .supply = "ddr_dvdd18",
873 /* 1.2V LDO */
874 static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
876 .supply = "sata_vdd",
879 .supply = "pll0_vdda",
882 .supply = "pll1_vdda",
885 .supply = "usbs_cvdd",
888 .supply = "vddarnwa1",
892 /* We take advantage of the fact that both defdcdc{2,3} are tied high */
893 static struct tps6507x_reg_platform_data tps6507x_platform_data = {
894 .defdcdc_default = true,
897 static struct regulator_init_data tps65070_regulator_data[] = {
898 /* dcdc1 */
900 .constraints = {
901 .min_uV = 3150000,
902 .max_uV = 3450000,
903 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
904 REGULATOR_CHANGE_STATUS),
905 .boot_on = 1,
907 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
908 .consumer_supplies = tps65070_dcdc1_consumers,
911 /* dcdc2 */
913 .constraints = {
914 .min_uV = 1710000,
915 .max_uV = 3450000,
916 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
917 REGULATOR_CHANGE_STATUS),
918 .boot_on = 1,
920 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
921 .consumer_supplies = tps65070_dcdc2_consumers,
922 .driver_data = &tps6507x_platform_data,
925 /* dcdc3 */
927 .constraints = {
928 .min_uV = 950000,
929 .max_uV = 1350000,
930 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
931 REGULATOR_CHANGE_STATUS),
932 .boot_on = 1,
934 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
935 .consumer_supplies = tps65070_dcdc3_consumers,
936 .driver_data = &tps6507x_platform_data,
939 /* ldo1 */
941 .constraints = {
942 .min_uV = 1710000,
943 .max_uV = 1890000,
944 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
945 REGULATOR_CHANGE_STATUS),
946 .boot_on = 1,
948 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
949 .consumer_supplies = tps65070_ldo1_consumers,
952 /* ldo2 */
954 .constraints = {
955 .min_uV = 1140000,
956 .max_uV = 1320000,
957 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
958 REGULATOR_CHANGE_STATUS),
959 .boot_on = 1,
961 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
962 .consumer_supplies = tps65070_ldo2_consumers,
966 static struct touchscreen_init_data tps6507x_touchscreen_data = {
967 .poll_period = 30, /* ms between touch samples */
968 .min_pressure = 0x30, /* minimum pressure to trigger touch */
969 .vref = 0, /* turn off vref when not using A/D */
970 .vendor = 0, /* /sys/class/input/input?/id/vendor */
971 .product = 65070, /* /sys/class/input/input?/id/product */
972 .version = 0x100, /* /sys/class/input/input?/id/version */
975 static struct tps6507x_board tps_board = {
976 .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
977 .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
980 static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
982 I2C_BOARD_INFO("tps6507x", 0x48),
983 .platform_data = &tps_board,
987 static int __init pmic_tps65070_init(void)
989 return i2c_register_board_info(1, da850_evm_tps65070_info,
990 ARRAY_SIZE(da850_evm_tps65070_info));
993 static const short da850_evm_lcdc_pins[] = {
994 DA850_GPIO2_8, DA850_GPIO2_15,
998 static const short da850_evm_mii_pins[] = {
999 DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
1000 DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
1001 DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
1002 DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
1003 DA850_MDIO_D,
1007 static const short da850_evm_rmii_pins[] = {
1008 DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
1009 DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
1010 DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
1011 DA850_MDIO_D,
1015 static int __init da850_evm_config_emac(void)
1017 void __iomem *cfg_chip3_base;
1018 int ret;
1019 u32 val;
1020 struct davinci_soc_info *soc_info = &davinci_soc_info;
1021 u8 rmii_en = soc_info->emac_pdata->rmii_en;
1023 if (!machine_is_davinci_da850_evm())
1024 return 0;
1026 cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
1028 val = __raw_readl(cfg_chip3_base);
1030 if (rmii_en) {
1031 val |= BIT(8);
1032 ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
1033 pr_info("EMAC: RMII PHY configured, MII PHY will not be"
1034 " functional\n");
1035 } else {
1036 val &= ~BIT(8);
1037 ret = davinci_cfg_reg_list(da850_evm_mii_pins);
1038 pr_info("EMAC: MII PHY configured, RMII PHY will not be"
1039 " functional\n");
1042 if (ret)
1043 pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
1044 ret);
1046 /* configure the CFGCHIP3 register for RMII or MII */
1047 __raw_writel(val, cfg_chip3_base);
1049 ret = davinci_cfg_reg(DA850_GPIO2_6);
1050 if (ret)
1051 pr_warning("da850_evm_init:GPIO(2,6) mux setup "
1052 "failed\n");
1054 ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
1055 if (ret) {
1056 pr_warning("Cannot open GPIO %d\n",
1057 DA850_MII_MDIO_CLKEN_PIN);
1058 return ret;
1061 /* Enable/Disable MII MDIO clock */
1062 gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
1064 soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
1066 ret = da8xx_register_emac();
1067 if (ret)
1068 pr_warning("da850_evm_init: emac registration failed: %d\n",
1069 ret);
1071 return 0;
1073 device_initcall(da850_evm_config_emac);
1076 * The following EDMA channels/slots are not being used by drivers (for
1077 * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
1078 * they are being reserved for codecs on the DSP side.
1080 static const s16 da850_dma0_rsv_chans[][2] = {
1081 /* (offset, number) */
1082 { 8, 6},
1083 {24, 4},
1084 {30, 2},
1085 {-1, -1}
1088 static const s16 da850_dma0_rsv_slots[][2] = {
1089 /* (offset, number) */
1090 { 8, 6},
1091 {24, 4},
1092 {30, 50},
1093 {-1, -1}
1096 static const s16 da850_dma1_rsv_chans[][2] = {
1097 /* (offset, number) */
1098 { 0, 28},
1099 {30, 2},
1100 {-1, -1}
1103 static const s16 da850_dma1_rsv_slots[][2] = {
1104 /* (offset, number) */
1105 { 0, 28},
1106 {30, 90},
1107 {-1, -1}
1110 static struct edma_rsv_info da850_edma_cc0_rsv = {
1111 .rsv_chans = da850_dma0_rsv_chans,
1112 .rsv_slots = da850_dma0_rsv_slots,
1115 static struct edma_rsv_info da850_edma_cc1_rsv = {
1116 .rsv_chans = da850_dma1_rsv_chans,
1117 .rsv_slots = da850_dma1_rsv_slots,
1120 static struct edma_rsv_info *da850_edma_rsv[2] = {
1121 &da850_edma_cc0_rsv,
1122 &da850_edma_cc1_rsv,
1125 #ifdef CONFIG_CPU_FREQ
1126 static __init int da850_evm_init_cpufreq(void)
1128 switch (system_rev & 0xF) {
1129 case 3:
1130 da850_max_speed = 456000;
1131 break;
1132 case 2:
1133 da850_max_speed = 408000;
1134 break;
1135 case 1:
1136 da850_max_speed = 372000;
1137 break;
1140 return da850_register_cpufreq("pll0_sysclk3");
1142 #else
1143 static __init int da850_evm_init_cpufreq(void) { return 0; }
1144 #endif
1146 static __init void da850_evm_init(void)
1148 int ret;
1150 ret = pmic_tps65070_init();
1151 if (ret)
1152 pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
1153 ret);
1155 ret = da850_register_edma(da850_edma_rsv);
1156 if (ret)
1157 pr_warning("da850_evm_init: edma registration failed: %d\n",
1158 ret);
1160 ret = davinci_cfg_reg_list(da850_i2c0_pins);
1161 if (ret)
1162 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
1163 ret);
1165 ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
1166 if (ret)
1167 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
1168 ret);
1171 ret = da8xx_register_watchdog();
1172 if (ret)
1173 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
1174 ret);
1176 if (HAS_MMC) {
1177 ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
1178 if (ret)
1179 pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
1180 " %d\n", ret);
1182 ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
1183 if (ret)
1184 pr_warning("da850_evm_init: can not open GPIO %d\n",
1185 DA850_MMCSD_CD_PIN);
1186 gpio_direction_input(DA850_MMCSD_CD_PIN);
1188 ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
1189 if (ret)
1190 pr_warning("da850_evm_init: can not open GPIO %d\n",
1191 DA850_MMCSD_WP_PIN);
1192 gpio_direction_input(DA850_MMCSD_WP_PIN);
1194 ret = da8xx_register_mmcsd0(&da850_mmc_config);
1195 if (ret)
1196 pr_warning("da850_evm_init: mmcsd0 registration failed:"
1197 " %d\n", ret);
1200 davinci_serial_init(&da850_evm_uart_config);
1202 i2c_register_board_info(1, da850_evm_i2c_devices,
1203 ARRAY_SIZE(da850_evm_i2c_devices));
1206 * shut down uart 0 and 1; they are not used on the board and
1207 * accessing them causes endless "too much work in irq53" messages
1208 * with arago fs
1210 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
1211 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
1213 ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
1214 if (ret)
1215 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
1216 ret);
1218 da8xx_register_mcasp(0, &da850_evm_snd_data);
1220 ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
1221 if (ret)
1222 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
1223 ret);
1225 /* Handle board specific muxing for LCD here */
1226 ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
1227 if (ret)
1228 pr_warning("da850_evm_init: evm specific lcd mux setup "
1229 "failed: %d\n", ret);
1231 ret = da850_lcd_hw_init();
1232 if (ret)
1233 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
1234 ret);
1236 sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
1237 ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
1238 if (ret)
1239 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
1240 ret);
1242 ret = da8xx_register_rtc();
1243 if (ret)
1244 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
1246 ret = da850_evm_init_cpufreq();
1247 if (ret)
1248 pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
1249 ret);
1251 ret = da8xx_register_cpuidle();
1252 if (ret)
1253 pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
1254 ret);
1256 ret = da850_register_pm(&da850_pm_device);
1257 if (ret)
1258 pr_warning("da850_evm_init: suspend registration failed: %d\n",
1259 ret);
1261 ret = da8xx_register_spi(1, da850evm_spi_info,
1262 ARRAY_SIZE(da850evm_spi_info));
1263 if (ret)
1264 pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
1265 ret);
1267 da850_evm_setup_mac_addr();
1270 #ifdef CONFIG_SERIAL_8250_CONSOLE
1271 static int __init da850_evm_console_init(void)
1273 if (!machine_is_davinci_da850_evm())
1274 return 0;
1276 return add_preferred_console("ttyS", 2, "115200");
1278 console_initcall(da850_evm_console_init);
1279 #endif
1281 static void __init da850_evm_map_io(void)
1283 da850_init();
1286 MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
1287 .boot_params = (DA8XX_DDR_BASE + 0x100),
1288 .map_io = da850_evm_map_io,
1289 .init_irq = cp_intc_init,
1290 .timer = &davinci_timer,
1291 .init_machine = da850_evm_init,
1292 MACHINE_END