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,
119 static void da850_evm_m25p80_notify_add(struct mtd_info
*mtd
)
121 char *mac_addr
= davinci_soc_info
.emac_pdata
->mac_addr
;
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",
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
);
141 static void da850_evm_setup_mac_addr(void) { }
144 static struct mtd_partition da850_evm_norflash_partition
[] = {
146 .name
= "bootloaders + env",
149 .mask_flags
= MTD_WRITEABLE
,
153 .offset
= MTDPART_OFS_APPEND
,
158 .name
= "filesystem",
159 .offset
= MTDPART_OFS_APPEND
,
160 .size
= MTDPART_SIZ_FULL
,
165 static struct physmap_flash_data da850_evm_norflash_data
= {
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",
183 .platform_data
= &da850_evm_norflash_data
,
186 .resource
= da850_evm_norflash_resource
,
189 static struct davinci_pm_config da850_pm_pdata
= {
193 static struct platform_device da850_pm_device
= {
194 .name
= "pm-davinci",
196 .platform_data
= &da850_pm_pdata
,
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
206 static struct mtd_partition da850_evm_nandflash_partition
[] = {
208 .name
= "u-boot env",
211 .mask_flags
= MTD_WRITEABLE
,
215 .offset
= MTDPART_OFS_APPEND
,
217 .mask_flags
= MTD_WRITEABLE
,
221 .offset
= MTDPART_OFS_APPEND
,
223 .mask_flags
= MTD_WRITEABLE
,
232 .name
= "filesystem",
233 .offset
= MTDPART_OFS_APPEND
,
234 .size
= MTDPART_SIZ_FULL
,
239 static struct davinci_aemif_timing da850_evm_nandflash_timing
= {
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
,
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",
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
);
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)
334 static inline void da850_evm_setup_nor_nand(void)
339 ret
= davinci_cfg_reg_list(da850_evm_nand_pins
);
341 pr_warning("da850_evm_init: nand mux setup failed: "
344 ret
= davinci_cfg_reg_list(da850_evm_nor_pins
);
346 pr_warning("da850_evm_init: nor mux setup failed: %d\n",
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);
365 static inline void da850_evm_setup_emac_rmii(int rmii_sel
) { }
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] = {
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",
431 .platform_data
= &da850_evm_ui_keys_pdata
435 static void da850_evm_ui_keys_init(unsigned gpio
)
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
]);
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
]);
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
]);
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
);
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
);
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
);
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
[] = {
572 .debounce_interval
= DA850_KEYS_DEBOUNCE_MS
,
574 .desc
= NULL
, /* assigned at runtime */
575 .gpio
= -1, /* assigned at runtime */
577 [1 ... DA850_N_BB_USER_SW
] = {
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",
598 .platform_data
= &da850_evm_bb_keys_pdata
602 static void da850_evm_bb_keys_init(unsigned gpio
)
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] = {
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
= {
640 .platform_data
= &da850_evm_bb_leds_pdata
644 static void da850_evm_bb_leds_init(unsigned gpio
)
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
;
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
,
665 * Register the switches and pushbutton on the baseboard as a gpio-keys
668 da850_evm_bb_keys_init(gpio
);
669 ret
= platform_device_register(&da850_evm_bb_keys_device
);
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
);
678 pr_warning("Could not register baseboard GPIO expander LEDS");
679 goto io_exp_setup_leds_fail
;
684 io_exp_setup_leds_fail
:
685 platform_device_unregister(&da850_evm_bb_keys_device
);
686 io_exp_setup_sw_fail
:
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
);
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
),
750 .serial_dir
= da850_iis_serializer_direction
,
751 .asp_chan_q
= EVENTQ_1
,
752 .version
= MCASP_VERSION_2
,
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
,
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
)
793 gpio_set_value(DA850_LCD_BL_PIN
, val
);
796 gpio_set_value(DA850_LCD_PWR_PIN
, val
);
799 static int da850_lcd_hw_init(void)
803 status
= gpio_request(DA850_LCD_BL_PIN
, "lcd bl\n");
807 status
= gpio_request(DA850_LCD_PWR_PIN
, "lcd pwr\n");
809 gpio_free(DA850_LCD_BL_PIN
);
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);
825 /* TPS65070 voltage regulator support */
828 static struct regulator_consumer_supply tps65070_dcdc1_consumers
[] = {
830 .supply
= "usb0_vdda33",
833 .supply
= "usb1_vdda33",
838 static struct regulator_consumer_supply tps65070_dcdc2_consumers
[] = {
840 .supply
= "dvdd3318_a",
843 .supply
= "dvdd3318_b",
846 .supply
= "dvdd3318_c",
851 static struct regulator_consumer_supply tps65070_dcdc3_consumers
[] = {
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",
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
[] = {
903 .valid_ops_mask
= (REGULATOR_CHANGE_VOLTAGE
|
904 REGULATOR_CHANGE_STATUS
),
907 .num_consumer_supplies
= ARRAY_SIZE(tps65070_dcdc1_consumers
),
908 .consumer_supplies
= tps65070_dcdc1_consumers
,
916 .valid_ops_mask
= (REGULATOR_CHANGE_VOLTAGE
|
917 REGULATOR_CHANGE_STATUS
),
920 .num_consumer_supplies
= ARRAY_SIZE(tps65070_dcdc2_consumers
),
921 .consumer_supplies
= tps65070_dcdc2_consumers
,
922 .driver_data
= &tps6507x_platform_data
,
930 .valid_ops_mask
= (REGULATOR_CHANGE_VOLTAGE
|
931 REGULATOR_CHANGE_STATUS
),
934 .num_consumer_supplies
= ARRAY_SIZE(tps65070_dcdc3_consumers
),
935 .consumer_supplies
= tps65070_dcdc3_consumers
,
936 .driver_data
= &tps6507x_platform_data
,
944 .valid_ops_mask
= (REGULATOR_CHANGE_VOLTAGE
|
945 REGULATOR_CHANGE_STATUS
),
948 .num_consumer_supplies
= ARRAY_SIZE(tps65070_ldo1_consumers
),
949 .consumer_supplies
= tps65070_ldo1_consumers
,
957 .valid_ops_mask
= (REGULATOR_CHANGE_VOLTAGE
|
958 REGULATOR_CHANGE_STATUS
),
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
,
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
,
1015 static int __init
da850_evm_config_emac(void)
1017 void __iomem
*cfg_chip3_base
;
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())
1026 cfg_chip3_base
= DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG
);
1028 val
= __raw_readl(cfg_chip3_base
);
1032 ret
= davinci_cfg_reg_list(da850_evm_rmii_pins
);
1033 pr_info("EMAC: RMII PHY configured, MII PHY will not be"
1037 ret
= davinci_cfg_reg_list(da850_evm_mii_pins
);
1038 pr_info("EMAC: MII PHY configured, RMII PHY will not be"
1043 pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n",
1046 /* configure the CFGCHIP3 register for RMII or MII */
1047 __raw_writel(val
, cfg_chip3_base
);
1049 ret
= davinci_cfg_reg(DA850_GPIO2_6
);
1051 pr_warning("da850_evm_init:GPIO(2,6) mux setup "
1054 ret
= gpio_request(DA850_MII_MDIO_CLKEN_PIN
, "mdio_clk_en");
1056 pr_warning("Cannot open GPIO %d\n",
1057 DA850_MII_MDIO_CLKEN_PIN
);
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();
1068 pr_warning("da850_evm_init: emac registration failed: %d\n",
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) */
1088 static const s16 da850_dma0_rsv_slots
[][2] = {
1089 /* (offset, number) */
1096 static const s16 da850_dma1_rsv_chans
[][2] = {
1097 /* (offset, number) */
1103 static const s16 da850_dma1_rsv_slots
[][2] = {
1104 /* (offset, number) */
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) {
1130 da850_max_speed
= 456000;
1133 da850_max_speed
= 408000;
1136 da850_max_speed
= 372000;
1140 return da850_register_cpufreq("pll0_sysclk3");
1143 static __init
int da850_evm_init_cpufreq(void) { return 0; }
1146 #define DA850EVM_SATA_REFCLKPN_RATE (100 * 1000 * 1000)
1148 static __init
void da850_evm_init(void)
1152 ret
= pmic_tps65070_init();
1154 pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n",
1157 ret
= da850_register_edma(da850_edma_rsv
);
1159 pr_warning("da850_evm_init: edma registration failed: %d\n",
1162 ret
= davinci_cfg_reg_list(da850_i2c0_pins
);
1164 pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n",
1167 ret
= da8xx_register_i2c(0, &da850_evm_i2c_0_pdata
);
1169 pr_warning("da850_evm_init: i2c0 registration failed: %d\n",
1173 ret
= da8xx_register_watchdog();
1175 pr_warning("da830_evm_init: watchdog registration failed: %d\n",
1179 ret
= davinci_cfg_reg_list(da850_evm_mmcsd0_pins
);
1181 pr_warning("da850_evm_init: mmcsd0 mux setup failed:"
1184 ret
= gpio_request(DA850_MMCSD_CD_PIN
, "MMC CD\n");
1186 pr_warning("da850_evm_init: can not open GPIO %d\n",
1187 DA850_MMCSD_CD_PIN
);
1188 gpio_direction_input(DA850_MMCSD_CD_PIN
);
1190 ret
= gpio_request(DA850_MMCSD_WP_PIN
, "MMC WP\n");
1192 pr_warning("da850_evm_init: can not open GPIO %d\n",
1193 DA850_MMCSD_WP_PIN
);
1194 gpio_direction_input(DA850_MMCSD_WP_PIN
);
1196 ret
= da8xx_register_mmcsd0(&da850_mmc_config
);
1198 pr_warning("da850_evm_init: mmcsd0 registration failed:"
1202 davinci_serial_init(&da850_evm_uart_config
);
1204 i2c_register_board_info(1, da850_evm_i2c_devices
,
1205 ARRAY_SIZE(da850_evm_i2c_devices
));
1208 * shut down uart 0 and 1; they are not used on the board and
1209 * accessing them causes endless "too much work in irq53" messages
1212 __raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE
) + 0x30);
1213 __raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE
) + 0x30);
1215 ret
= davinci_cfg_reg_list(da850_evm_mcasp_pins
);
1217 pr_warning("da850_evm_init: mcasp mux setup failed: %d\n",
1220 da8xx_register_mcasp(0, &da850_evm_snd_data
);
1222 ret
= davinci_cfg_reg_list(da850_lcdcntl_pins
);
1224 pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
1227 /* Handle board specific muxing for LCD here */
1228 ret
= davinci_cfg_reg_list(da850_evm_lcdc_pins
);
1230 pr_warning("da850_evm_init: evm specific lcd mux setup "
1231 "failed: %d\n", ret
);
1233 ret
= da850_lcd_hw_init();
1235 pr_warning("da850_evm_init: lcd initialization failed: %d\n",
1238 sharp_lk043t1dg01_pdata
.panel_power_ctrl
= da850_panel_power_ctrl
,
1239 ret
= da8xx_register_lcdc(&sharp_lk043t1dg01_pdata
);
1241 pr_warning("da850_evm_init: lcdc registration failed: %d\n",
1244 ret
= da8xx_register_rtc();
1246 pr_warning("da850_evm_init: rtc setup failed: %d\n", ret
);
1248 ret
= da850_evm_init_cpufreq();
1250 pr_warning("da850_evm_init: cpufreq registration failed: %d\n",
1253 ret
= da8xx_register_cpuidle();
1255 pr_warning("da850_evm_init: cpuidle registration failed: %d\n",
1258 ret
= da850_register_pm(&da850_pm_device
);
1260 pr_warning("da850_evm_init: suspend registration failed: %d\n",
1263 ret
= da8xx_register_spi(1, da850evm_spi_info
,
1264 ARRAY_SIZE(da850evm_spi_info
));
1266 pr_warning("da850_evm_init: spi 1 registration failed: %d\n",
1269 ret
= da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE
);
1271 pr_warning("da850_evm_init: sata registration failed: %d\n",
1274 da850_evm_setup_mac_addr();
1277 #ifdef CONFIG_SERIAL_8250_CONSOLE
1278 static int __init
da850_evm_console_init(void)
1280 if (!machine_is_davinci_da850_evm())
1283 return add_preferred_console("ttyS", 2, "115200");
1285 console_initcall(da850_evm_console_init
);
1288 static void __init
da850_evm_map_io(void)
1293 MACHINE_START(DAVINCI_DA850_EVM
, "DaVinci DA850/OMAP-L138/AM18x EVM")
1294 .boot_params
= (DA8XX_DDR_BASE
+ 0x100),
1295 .map_io
= da850_evm_map_io
,
1296 .init_irq
= cp_intc_init
,
1297 .timer
= &davinci_timer
,
1298 .init_machine
= da850_evm_init
,
1299 .dma_zone_size
= SZ_128M
,