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
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>
42 #include <mach/aemif.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[] = {
59 .mask_flags = MTD_WRITEABLE,
63 .offset = MTDPART_OFS_APPEND,
65 .mask_flags = MTD_WRITEABLE,
69 .offset = MTDPART_OFS_APPEND,
71 .mask_flags = MTD_WRITEABLE,
75 .offset = MTDPART_OFS_APPEND,
76 .size = SZ_2M + SZ_512K,
81 .offset = MTDPART_OFS_APPEND,
86 .name = "MAC-Address",
87 .offset = SZ_8M - SZ_64K,
89 .mask_flags = MTD_WRITEABLE,
93 static struct flash_platform_data da850evm_spiflash_data = {
95 .parts = da850evm_spiflash_part,
96 .nr_parts = ARRAY_SIZE(da850evm_spiflash_part),
100 static struct davinci_spi_config da850evm_spiflash_cfg = {
101 .io_type = SPI_IO_TYPE_DMA,
106 static struct spi_board_info da850evm_spi_info[] = {
108 .modalias = "m25p80",
109 .platform_data = &da850evm_spiflash_data,
110 .controller_data = &da850evm_spiflash_cfg,
112 .max_speed_hz = 30000000,
118 static struct mtd_partition da850_evm_norflash_partition[] = {
120 .name = "bootloaders + env",
123 .mask_flags = MTD_WRITEABLE,
127 .offset = MTDPART_OFS_APPEND,
132 .name = "filesystem",
133 .offset = MTDPART_OFS_APPEND,
134 .size = MTDPART_SIZ_FULL,
139 static struct physmap_flash_data da850_evm_norflash_data = {
141 .parts = da850_evm_norflash_partition,
142 .nr_parts = ARRAY_SIZE(da850_evm_norflash_partition),
145 static struct resource da850_evm_norflash_resource[] = {
147 .start = DA8XX_AEMIF_CS2_BASE,
148 .end = DA8XX_AEMIF_CS2_BASE + SZ_32M - 1,
149 .flags = IORESOURCE_MEM,
153 static struct platform_device da850_evm_norflash_device = {
154 .name = "physmap-flash",
157 .platform_data = &da850_evm_norflash_data,
160 .resource = da850_evm_norflash_resource,
163 static struct davinci_pm_config da850_pm_pdata = {
167 static struct platform_device da850_pm_device = {
168 .name = "pm-davinci",
170 .platform_data = &da850_pm_pdata,
175 /* DA850/OMAP-L138 EVM includes a 512 MByte large-page NAND flash
176 * (128K blocks). It may be used instead of the (default) SPI flash
177 * to boot, using TI's tools to install the secondary boot loader
180 static struct mtd_partition da850_evm_nandflash_partition[] = {
182 .name = "u-boot env",
185 .mask_flags = MTD_WRITEABLE,
189 .offset = MTDPART_OFS_APPEND,
191 .mask_flags = MTD_WRITEABLE,
195 .offset = MTDPART_OFS_APPEND,
197 .mask_flags = MTD_WRITEABLE,
206 .name = "filesystem",
207 .offset = MTDPART_OFS_APPEND,
208 .size = MTDPART_SIZ_FULL,
213 static struct davinci_aemif_timing da850_evm_nandflash_timing = {
223 static struct davinci_nand_pdata da850_evm_nandflash_data = {
224 .parts = da850_evm_nandflash_partition,
225 .nr_parts = ARRAY_SIZE(da850_evm_nandflash_partition),
226 .ecc_mode = NAND_ECC_HW,
228 .options = NAND_USE_FLASH_BBT,
229 .timing = &da850_evm_nandflash_timing,
232 static struct resource da850_evm_nandflash_resource[] = {
234 .start = DA8XX_AEMIF_CS3_BASE,
235 .end = DA8XX_AEMIF_CS3_BASE + SZ_512K + 2 * SZ_1K - 1,
236 .flags = IORESOURCE_MEM,
239 .start = DA8XX_AEMIF_CTL_BASE,
240 .end = DA8XX_AEMIF_CTL_BASE + SZ_32K - 1,
241 .flags = IORESOURCE_MEM,
245 static struct platform_device da850_evm_nandflash_device = {
246 .name = "davinci_nand",
249 .platform_data = &da850_evm_nandflash_data,
251 .num_resources = ARRAY_SIZE(da850_evm_nandflash_resource),
252 .resource = da850_evm_nandflash_resource,
255 static struct platform_device *da850_evm_devices[] __initdata = {
256 &da850_evm_nandflash_device,
257 &da850_evm_norflash_device,
260 #define DA8XX_AEMIF_CE2CFG_OFFSET 0x10
261 #define DA8XX_AEMIF_ASIZE_16BIT 0x1
263 static void __init da850_evm_init_nor(void)
265 void __iomem *aemif_addr;
267 aemif_addr = ioremap(DA8XX_AEMIF_CTL_BASE, SZ_32K);
269 /* Configure data bus width of CS2 to 16 bit */
270 writel(readl(aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET) |
271 DA8XX_AEMIF_ASIZE_16BIT,
272 aemif_addr + DA8XX_AEMIF_CE2CFG_OFFSET);
277 static const short da850_evm_nand_pins[] = {
278 DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3,
279 DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7,
280 DA850_EMA_A_1, DA850_EMA_A_2, DA850_NEMA_CS_3, DA850_NEMA_CS_4,
281 DA850_NEMA_WE, DA850_NEMA_OE,
285 static const short da850_evm_nor_pins[] = {
286 DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2,
287 DA850_NEMA_WE, DA850_NEMA_OE, DA850_EMA_D_0, DA850_EMA_D_1,
288 DA850_EMA_D_2, DA850_EMA_D_3, DA850_EMA_D_4, DA850_EMA_D_5,
289 DA850_EMA_D_6, DA850_EMA_D_7, DA850_EMA_D_8, DA850_EMA_D_9,
290 DA850_EMA_D_10, DA850_EMA_D_11, DA850_EMA_D_12, DA850_EMA_D_13,
291 DA850_EMA_D_14, DA850_EMA_D_15, DA850_EMA_A_0, DA850_EMA_A_1,
292 DA850_EMA_A_2, DA850_EMA_A_3, DA850_EMA_A_4, DA850_EMA_A_5,
293 DA850_EMA_A_6, DA850_EMA_A_7, DA850_EMA_A_8, DA850_EMA_A_9,
294 DA850_EMA_A_10, DA850_EMA_A_11, DA850_EMA_A_12, DA850_EMA_A_13,
295 DA850_EMA_A_14, DA850_EMA_A_15, DA850_EMA_A_16, DA850_EMA_A_17,
296 DA850_EMA_A_18, DA850_EMA_A_19, DA850_EMA_A_20, DA850_EMA_A_21,
297 DA850_EMA_A_22, DA850_EMA_A_23,
301 static u32 ui_card_detected;
303 #if defined(CONFIG_MMC_DAVINCI) || \
304 defined(CONFIG_MMC_DAVINCI_MODULE)
310 static inline void da850_evm_setup_nor_nand(void)
314 if (ui_card_detected & !HAS_MMC) {
315 ret = davinci_cfg_reg_list(da850_evm_nand_pins);
317 pr_warning("da850_evm_init: nand mux setup failed: "
320 ret = davinci_cfg_reg_list(da850_evm_nor_pins);
322 pr_warning("da850_evm_init: nor mux setup failed: %d\n",
325 da850_evm_init_nor();
327 platform_add_devices(da850_evm_devices,
328 ARRAY_SIZE(da850_evm_devices));
332 #ifdef CONFIG_DA850_UI_RMII
333 static inline void da850_evm_setup_emac_rmii(int rmii_sel)
335 struct davinci_soc_info *soc_info = &davinci_soc_info;
337 soc_info->emac_pdata->rmii_en = 1;
338 gpio_set_value_cansleep(rmii_sel, 0);
341 static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }
345 #define DA850_KEYS_DEBOUNCE_MS 10
347 * At 200ms polling interval it is possible to miss an
348 * event by tapping very lightly on the push button but most
349 * pushes do result in an event; longer intervals require the
350 * user to hold the button whereas shorter intervals require
351 * more CPU time for polling.
353 #define DA850_GPIO_KEYS_POLL_MS 200
355 enum da850_evm_ui_exp_pins {
356 DA850_EVM_UI_EXP_SEL_C = 5,
357 DA850_EVM_UI_EXP_SEL_B,
358 DA850_EVM_UI_EXP_SEL_A,
359 DA850_EVM_UI_EXP_PB8,
360 DA850_EVM_UI_EXP_PB7,
361 DA850_EVM_UI_EXP_PB6,
362 DA850_EVM_UI_EXP_PB5,
363 DA850_EVM_UI_EXP_PB4,
364 DA850_EVM_UI_EXP_PB3,
365 DA850_EVM_UI_EXP_PB2,
366 DA850_EVM_UI_EXP_PB1,
369 static const char const *da850_evm_ui_exp[] = {
370 [DA850_EVM_UI_EXP_SEL_C] = "sel_c",
371 [DA850_EVM_UI_EXP_SEL_B] = "sel_b",
372 [DA850_EVM_UI_EXP_SEL_A] = "sel_a",
373 [DA850_EVM_UI_EXP_PB8] = "pb8",
374 [DA850_EVM_UI_EXP_PB7] = "pb7",
375 [DA850_EVM_UI_EXP_PB6] = "pb6",
376 [DA850_EVM_UI_EXP_PB5] = "pb5",
377 [DA850_EVM_UI_EXP_PB4] = "pb4",
378 [DA850_EVM_UI_EXP_PB3] = "pb3",
379 [DA850_EVM_UI_EXP_PB2] = "pb2",
380 [DA850_EVM_UI_EXP_PB1] = "pb1",
383 #define DA850_N_UI_PB 8
385 static struct gpio_keys_button da850_evm_ui_keys[] = {
386 [0 ... DA850_N_UI_PB - 1] = {
390 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
391 .code = -1, /* assigned at runtime */
392 .gpio = -1, /* assigned at runtime */
393 .desc = NULL, /* assigned at runtime */
397 static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = {
398 .buttons = da850_evm_ui_keys,
399 .nbuttons = ARRAY_SIZE(da850_evm_ui_keys),
400 .poll_interval = DA850_GPIO_KEYS_POLL_MS,
403 static struct platform_device da850_evm_ui_keys_device = {
404 .name = "gpio-keys-polled",
407 .platform_data = &da850_evm_ui_keys_pdata
411 static void da850_evm_ui_keys_init(unsigned gpio)
414 struct gpio_keys_button *button;
416 for (i = 0; i < DA850_N_UI_PB; i++) {
417 button = &da850_evm_ui_keys[i];
418 button->code = KEY_F8 - i;
419 button->desc = (char *)
420 da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i];
421 button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i;
425 static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
426 unsigned ngpio, void *c)
428 int sel_a, sel_b, sel_c, ret;
430 sel_a = gpio + DA850_EVM_UI_EXP_SEL_A;
431 sel_b = gpio + DA850_EVM_UI_EXP_SEL_B;
432 sel_c = gpio + DA850_EVM_UI_EXP_SEL_C;
434 ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);
436 pr_warning("Cannot open UI expander pin %d\n", sel_a);
437 goto exp_setup_sela_fail;
440 ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);
442 pr_warning("Cannot open UI expander pin %d\n", sel_b);
443 goto exp_setup_selb_fail;
446 ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);
448 pr_warning("Cannot open UI expander pin %d\n", sel_c);
449 goto exp_setup_selc_fail;
452 /* deselect all functionalities */
453 gpio_direction_output(sel_a, 1);
454 gpio_direction_output(sel_b, 1);
455 gpio_direction_output(sel_c, 1);
457 da850_evm_ui_keys_init(gpio);
458 ret = platform_device_register(&da850_evm_ui_keys_device);
460 pr_warning("Could not register UI GPIO expander push-buttons");
461 goto exp_setup_keys_fail;
464 ui_card_detected = 1;
465 pr_info("DA850/OMAP-L138 EVM UI card detected\n");
467 da850_evm_setup_nor_nand();
469 da850_evm_setup_emac_rmii(sel_a);
483 static int da850_evm_ui_expander_teardown(struct i2c_client *client,
484 unsigned gpio, unsigned ngpio, void *c)
486 platform_device_unregister(&da850_evm_ui_keys_device);
488 /* deselect all functionalities */
489 gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1);
490 gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1);
491 gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1);
493 gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
494 gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
495 gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
500 /* assign the baseboard expander's GPIOs after the UI board's */
501 #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp)
502 #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS)
504 enum da850_evm_bb_exp_pins {
505 DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0,
506 DA850_EVM_BB_EXP_SW_RST,
507 DA850_EVM_BB_EXP_TP_23,
508 DA850_EVM_BB_EXP_TP_22,
509 DA850_EVM_BB_EXP_TP_21,
510 DA850_EVM_BB_EXP_USER_PB1,
511 DA850_EVM_BB_EXP_USER_LED2,
512 DA850_EVM_BB_EXP_USER_LED1,
513 DA850_EVM_BB_EXP_USER_SW1,
514 DA850_EVM_BB_EXP_USER_SW2,
515 DA850_EVM_BB_EXP_USER_SW3,
516 DA850_EVM_BB_EXP_USER_SW4,
517 DA850_EVM_BB_EXP_USER_SW5,
518 DA850_EVM_BB_EXP_USER_SW6,
519 DA850_EVM_BB_EXP_USER_SW7,
520 DA850_EVM_BB_EXP_USER_SW8
523 static const char const *da850_evm_bb_exp[] = {
524 [DA850_EVM_BB_EXP_DEEP_SLEEP_EN] = "deep_sleep_en",
525 [DA850_EVM_BB_EXP_SW_RST] = "sw_rst",
526 [DA850_EVM_BB_EXP_TP_23] = "tp_23",
527 [DA850_EVM_BB_EXP_TP_22] = "tp_22",
528 [DA850_EVM_BB_EXP_TP_21] = "tp_21",
529 [DA850_EVM_BB_EXP_USER_PB1] = "user_pb1",
530 [DA850_EVM_BB_EXP_USER_LED2] = "user_led2",
531 [DA850_EVM_BB_EXP_USER_LED1] = "user_led1",
532 [DA850_EVM_BB_EXP_USER_SW1] = "user_sw1",
533 [DA850_EVM_BB_EXP_USER_SW2] = "user_sw2",
534 [DA850_EVM_BB_EXP_USER_SW3] = "user_sw3",
535 [DA850_EVM_BB_EXP_USER_SW4] = "user_sw4",
536 [DA850_EVM_BB_EXP_USER_SW5] = "user_sw5",
537 [DA850_EVM_BB_EXP_USER_SW6] = "user_sw6",
538 [DA850_EVM_BB_EXP_USER_SW7] = "user_sw7",
539 [DA850_EVM_BB_EXP_USER_SW8] = "user_sw8",
542 #define DA850_N_BB_USER_SW 8
544 static struct gpio_keys_button da850_evm_bb_keys[] = {
549 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
551 .desc = NULL, /* assigned at runtime */
552 .gpio = -1, /* assigned at runtime */
554 [1 ... DA850_N_BB_USER_SW] = {
558 .debounce_interval = DA850_KEYS_DEBOUNCE_MS,
559 .code = -1, /* assigned at runtime */
560 .desc = NULL, /* assigned at runtime */
561 .gpio = -1, /* assigned at runtime */
565 static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = {
566 .buttons = da850_evm_bb_keys,
567 .nbuttons = ARRAY_SIZE(da850_evm_bb_keys),
568 .poll_interval = DA850_GPIO_KEYS_POLL_MS,
571 static struct platform_device da850_evm_bb_keys_device = {
572 .name = "gpio-keys-polled",
575 .platform_data = &da850_evm_bb_keys_pdata
579 static void da850_evm_bb_keys_init(unsigned gpio)
582 struct gpio_keys_button *button;
584 button = &da850_evm_bb_keys[0];
585 button->desc = (char *)
586 da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1];
587 button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1;
589 for (i = 0; i < DA850_N_BB_USER_SW; i++) {
590 button = &da850_evm_bb_keys[i + 1];
591 button->code = SW_LID + i;
592 button->desc = (char *)
593 da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i];
594 button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i;
598 #define DA850_N_BB_USER_LED 2
600 static struct gpio_led da850_evm_bb_leds[] = {
601 [0 ... DA850_N_BB_USER_LED - 1] = {
603 .gpio = -1, /* assigned at runtime */
604 .name = NULL, /* assigned at runtime */
608 static struct gpio_led_platform_data da850_evm_bb_leds_pdata = {
609 .leds = da850_evm_bb_leds,
610 .num_leds = ARRAY_SIZE(da850_evm_bb_leds),
613 static struct platform_device da850_evm_bb_leds_device = {
617 .platform_data = &da850_evm_bb_leds_pdata
621 static void da850_evm_bb_leds_init(unsigned gpio)
624 struct gpio_led *led;
626 for (i = 0; i < DA850_N_BB_USER_LED; i++) {
627 led = &da850_evm_bb_leds[i];
629 led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i;
631 da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i];
635 static int da850_evm_bb_expander_setup(struct i2c_client *client,
636 unsigned gpio, unsigned ngpio,
642 * Register the switches and pushbutton on the baseboard as a gpio-keys
645 da850_evm_bb_keys_init(gpio);
646 ret = platform_device_register(&da850_evm_bb_keys_device);
648 pr_warning("Could not register baseboard GPIO expander keys");
649 goto io_exp_setup_sw_fail;
652 da850_evm_bb_leds_init(gpio);
653 ret = platform_device_register(&da850_evm_bb_leds_device);
655 pr_warning("Could not register baseboard GPIO expander LEDS");
656 goto io_exp_setup_leds_fail;
661 io_exp_setup_leds_fail:
662 platform_device_unregister(&da850_evm_bb_keys_device);
663 io_exp_setup_sw_fail:
667 static int da850_evm_bb_expander_teardown(struct i2c_client *client,
668 unsigned gpio, unsigned ngpio, void *c)
670 platform_device_unregister(&da850_evm_bb_leds_device);
671 platform_device_unregister(&da850_evm_bb_keys_device);
676 static struct pca953x_platform_data da850_evm_ui_expander_info = {
677 .gpio_base = DAVINCI_N_GPIO,
678 .setup = da850_evm_ui_expander_setup,
679 .teardown = da850_evm_ui_expander_teardown,
680 .names = da850_evm_ui_exp,
683 static struct pca953x_platform_data da850_evm_bb_expander_info = {
684 .gpio_base = DA850_BB_EXPANDER_GPIO_BASE,
685 .setup = da850_evm_bb_expander_setup,
686 .teardown = da850_evm_bb_expander_teardown,
687 .names = da850_evm_bb_exp,
690 static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {
692 I2C_BOARD_INFO("tlv320aic3x", 0x18),
695 I2C_BOARD_INFO("tca6416", 0x20),
696 .platform_data = &da850_evm_ui_expander_info,
699 I2C_BOARD_INFO("tca6416", 0x21),
700 .platform_data = &da850_evm_bb_expander_info,
704 static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {
705 .bus_freq = 100, /* kHz */
706 .bus_delay = 0, /* usec */
709 static struct davinci_uart_config da850_evm_uart_config __initdata = {
710 .enabled_uarts = 0x7,
713 /* davinci da850 evm audio machine driver */
714 static u8 da850_iis_serializer_direction[] = {
715 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
716 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
717 INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE, TX_MODE,
718 RX_MODE, INACTIVE_MODE, INACTIVE_MODE, INACTIVE_MODE,
721 static struct snd_platform_data da850_evm_snd_data = {
722 .tx_dma_offset = 0x2000,
723 .rx_dma_offset = 0x2000,
724 .op_mode = DAVINCI_MCASP_IIS_MODE,
725 .num_serializer = ARRAY_SIZE(da850_iis_serializer_direction),
727 .serial_dir = da850_iis_serializer_direction,
728 .asp_chan_q = EVENTQ_1,
729 .version = MCASP_VERSION_2,
734 static const short da850_evm_mcasp_pins[] __initconst = {
735 DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
736 DA850_AHCLKR, DA850_ACLKR, DA850_AFSR, DA850_AMUTE,
737 DA850_AXR_11, DA850_AXR_12,
741 static int da850_evm_mmc_get_ro(int index)
743 return gpio_get_value(DA850_MMCSD_WP_PIN);
746 static int da850_evm_mmc_get_cd(int index)
748 return !gpio_get_value(DA850_MMCSD_CD_PIN);
751 static struct davinci_mmc_config da850_mmc_config = {
752 .get_ro = da850_evm_mmc_get_ro,
753 .get_cd = da850_evm_mmc_get_cd,
755 .max_freq = 50000000,
756 .caps = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED,
757 .version = MMC_CTLR_VERSION_2,
760 static const short da850_evm_mmcsd0_pins[] __initconst = {
761 DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2,
762 DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD,
763 DA850_GPIO4_0, DA850_GPIO4_1,
767 static void da850_panel_power_ctrl(int val)
770 gpio_set_value(DA850_LCD_BL_PIN, val);
773 gpio_set_value(DA850_LCD_PWR_PIN, val);
776 static int da850_lcd_hw_init(void)
780 status = gpio_request(DA850_LCD_BL_PIN, "lcd bl\n");
784 status = gpio_request(DA850_LCD_PWR_PIN, "lcd pwr\n");
786 gpio_free(DA850_LCD_BL_PIN);
790 gpio_direction_output(DA850_LCD_BL_PIN, 0);
791 gpio_direction_output(DA850_LCD_PWR_PIN, 0);
793 /* Switch off panel power and backlight */
794 da850_panel_power_ctrl(0);
796 /* Switch on panel power and backlight */
797 da850_panel_power_ctrl(1);
802 /* TPS65070 voltage regulator support */
805 static struct regulator_consumer_supply tps65070_dcdc1_consumers[] = {
807 .supply = "usb0_vdda33",
810 .supply = "usb1_vdda33",
815 static struct regulator_consumer_supply tps65070_dcdc2_consumers[] = {
817 .supply = "dvdd3318_a",
820 .supply = "dvdd3318_b",
823 .supply = "dvdd3318_c",
828 static struct regulator_consumer_supply tps65070_dcdc3_consumers[] = {
835 static struct regulator_consumer_supply tps65070_ldo1_consumers[] = {
837 .supply = "sata_vddr",
840 .supply = "usb0_vdda18",
843 .supply = "usb1_vdda18",
846 .supply = "ddr_dvdd18",
851 static struct regulator_consumer_supply tps65070_ldo2_consumers[] = {
853 .supply = "sata_vdd",
856 .supply = "pll0_vdda",
859 .supply = "pll1_vdda",
862 .supply = "usbs_cvdd",
865 .supply = "vddarnwa1",
869 /* We take advantage of the fact that both defdcdc{2,3} are tied high */
870 static struct tps6507x_reg_platform_data tps6507x_platform_data = {
871 .defdcdc_default = true,
874 static struct regulator_init_data tps65070_regulator_data[] = {
880 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
881 REGULATOR_CHANGE_STATUS),
884 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc1_consumers),
885 .consumer_supplies = tps65070_dcdc1_consumers,
893 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
894 REGULATOR_CHANGE_STATUS),
897 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc2_consumers),
898 .consumer_supplies = tps65070_dcdc2_consumers,
899 .driver_data = &tps6507x_platform_data,
907 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
908 REGULATOR_CHANGE_STATUS),
911 .num_consumer_supplies = ARRAY_SIZE(tps65070_dcdc3_consumers),
912 .consumer_supplies = tps65070_dcdc3_consumers,
913 .driver_data = &tps6507x_platform_data,
921 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
922 REGULATOR_CHANGE_STATUS),
925 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo1_consumers),
926 .consumer_supplies = tps65070_ldo1_consumers,
934 .valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |
935 REGULATOR_CHANGE_STATUS),
938 .num_consumer_supplies = ARRAY_SIZE(tps65070_ldo2_consumers),
939 .consumer_supplies = tps65070_ldo2_consumers,
943 static struct touchscreen_init_data tps6507x_touchscreen_data = {
944 .poll_period = 30, /* ms between touch samples */
945 .min_pressure = 0x30, /* minimum pressure to trigger touch */
946 .vref = 0, /* turn off vref when not using A/D */
947 .vendor = 0, /* /sys/class/input/input?/id/vendor */
948 .product = 65070, /* /sys/class/input/input?/id/product */
949 .version = 0x100, /* /sys/class/input/input?/id/version */
952 static struct tps6507x_board tps_board = {
953 .tps6507x_pmic_init_data = &tps65070_regulator_data[0],
954 .tps6507x_ts_init_data = &tps6507x_touchscreen_data,
957 static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {
959 I2C_BOARD_INFO("tps6507x", 0x48),
960 .platform_data = &tps_board,
964 static int __init pmic_tps65070_init(void)
966 return i2c_register_board_info(1, da850_evm_tps65070_info,
967 ARRAY_SIZE(da850_evm_tps65070_info));
970 static const short da850_evm_lcdc_pins[] = {
971 DA850_GPIO2_8, DA850_GPIO2_15,
975 static const short da850_evm_mii_pins[] = {
976 DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3,
977 DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER,
978 DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3,
979 DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK,
984 static const short da850_evm_rmii_pins[] = {
985 DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN,
986 DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1,
987 DA850_RMII_RXER, DA850_RMII_MHZ_50_CLK, DA850_MDIO_CLK,
992 static int __init da850_evm_config_emac(void)
994 void __iomem *cfg_chip3_base;
997 struct davinci_soc_info *soc_info = &davinci_soc_info;
998 u8 rmii_en = soc_info->emac_pdata->rmii_en;
1000 if (!machine_is_davinci_da850_evm())
1003 cfg_chip3_base = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
1005 val = __raw_readl(cfg_chip3_base);
1009 ret = davinci_cfg_reg_list(da850_evm_rmii_pins);
1010 pr_info("EMAC: RMII PHY configured, MII PHY will not be"
1014 ret = davinci_cfg_reg_list(da850_evm_mii_pins);
1015 pr_info("EMAC: MII PHY configured, RMII PHY will not be"
1020 pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
1023 /* configure the CFGCHIP3 register for RMII or MII */
1024 __raw_writel(val, cfg_chip3_base);
1026 ret = davinci_cfg_reg(DA850_GPIO2_6);
1028 pr_warning("da850_evm_init:GPIO(2,6) mux setup "
1031 ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");
1033 pr_warning("Cannot open GPIO %d\n",
1034 DA850_MII_MDIO_CLKEN_PIN);
1038 /* Enable/Disable MII MDIO clock */
1039 gpio_direction_output(DA850_MII_MDIO_CLKEN_PIN, rmii_en);
1041 soc_info->emac_pdata->phy_id = DA850_EVM_PHY_ID;
1043 ret = da8xx_register_emac();
1045 pr_warning("da850_evm_init: emac registration failed: %d\n",
1050 device_initcall(da850_evm_config_emac);
1053 * The following EDMA channels/slots are not being used by drivers (for
1054 * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM, hence
1055 * they are being reserved for codecs on the DSP side.
1057 static const s16 da850_dma0_rsv_chans[][2] = {
1058 /* (offset, number) */
1065 static const s16 da850_dma0_rsv_slots[][2] = {
1066 /* (offset, number) */
1073 static const s16 da850_dma1_rsv_chans[][2] = {
1074 /* (offset, number) */
1080 static const s16 da850_dma1_rsv_slots[][2] = {
1081 /* (offset, number) */
1087 static struct edma_rsv_info da850_edma_cc0_rsv = {
1088 .rsv_chans = da850_dma0_rsv_chans,
1089 .rsv_slots = da850_dma0_rsv_slots,
1092 static struct edma_rsv_info da850_edma_cc1_rsv = {
1093 .rsv_chans = da850_dma1_rsv_chans,
1094 .rsv_slots = da850_dma1_rsv_slots,
1097 static struct edma_rsv_info *da850_edma_rsv[2] = {
1098 &da850_edma_cc0_rsv,
1099 &da850_edma_cc1_rsv,
1102 #ifdef CONFIG_CPU_FREQ
1103 static __init int da850_evm_init_cpufreq(void)
1105 switch (system_rev & 0xF) {
1107 da850_max_speed = 456000;
1110 da850_max_speed = 408000;
1113 da850_max_speed = 372000;
1117 return da850_register_cpufreq("pll0_sysclk3");
1120 static __init int da850_evm_init_cpufreq(void) { return 0; }
1123 static __init void da850_evm_init(void)
1127 ret = pmic_tps65070_init();
1129 pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
1132 ret = da850_register_edma(da850_edma_rsv);
1134 pr_warning("da850_evm_init: edma registration failed: %d\n",
1137 ret = davinci_cfg_reg_list(da850_i2c0_pins);
1139 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
1142 ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);
1144 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
1148 ret = da8xx_register_watchdog();
1150 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
1154 ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);
1156 pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
1159 ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");
1161 pr_warning("da850_evm_init: can not open GPIO %d\n",
1162 DA850_MMCSD_CD_PIN);
1163 gpio_direction_input(DA850_MMCSD_CD_PIN);
1165 ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");
1167 pr_warning("da850_evm_init: can not open GPIO %d\n",
1168 DA850_MMCSD_WP_PIN);
1169 gpio_direction_input(DA850_MMCSD_WP_PIN);
1171 ret = da8xx_register_mmcsd0(&da850_mmc_config);
1173 pr_warning("da850_evm_init: mmcsd0 registration failed:"
1177 davinci_serial_init(&da850_evm_uart_config);
1179 i2c_register_board_info(1, da850_evm_i2c_devices,
1180 ARRAY_SIZE(da850_evm_i2c_devices));
1183 * shut down uart 0 and 1; they are not used on the board and
1184 * accessing them causes endless "too much work in irq53" messages
1187 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);
1188 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30);
1190 ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);
1192 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
1195 da8xx_register_mcasp(0, &da850_evm_snd_data);
1197 ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
1199 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
1202 /* Handle board specific muxing for LCD here */
1203 ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
1205 pr_warning("da850_evm_init: evm specific lcd mux setup "
1206 "failed: %d\n", ret);
1208 ret = da850_lcd_hw_init();
1210 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
1213 sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,
1214 ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);
1216 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
1219 ret = da8xx_register_rtc();
1221 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret);
1223 ret = da850_evm_init_cpufreq();
1225 pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
1228 ret = da8xx_register_cpuidle();
1230 pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
1233 ret = da850_register_pm(&da850_pm_device);
1235 pr_warning("da850_evm_init: suspend registration failed: %d\n",
1238 ret = da8xx_register_spi(1, da850evm_spi_info,
1239 ARRAY_SIZE(da850evm_spi_info));
1241 pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
1245 #ifdef CONFIG_SERIAL_8250_CONSOLE
1246 static int __init da850_evm_console_init(void)
1248 if (!machine_is_davinci_da850_evm())
1251 return add_preferred_console("ttyS", 2, "115200");
1253 console_initcall(da850_evm_console_init);
1256 static void __init da850_evm_map_io(void)
1261 MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM")
1262 .boot_params = (DA8XX_DDR_BASE + 0x100),
1263 .map_io = da850_evm_map_io,
1264 .init_irq = cp_intc_init,
1265 .timer = &davinci_timer,
1266 .init_machine = da850_evm_init,