2 * Copyright (C) 2011 OMICRON electronics GmbH
4 * Based on da850evm.c. Original Copyrights follow:
6 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
7 * Copyright (C) 2009 Nick Thompson, GE Fanuc, Ltd. <nick.thompson@gefanuc.com>
8 * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
10 * SPDX-License-Identifier: GPL-2.0+
19 #include <asm/arch/hardware.h>
20 #include <asm/arch/gpio.h>
21 #include <asm/ti-common/davinci_nand.h>
22 #include <asm/arch/emac_defs.h>
23 #include <asm/arch/pinmux_defs.h>
24 #include <asm/arch/davinci_misc.h>
25 #include <asm/arch/timer_defs.h>
27 DECLARE_GLOBAL_DATA_PTR;
29 #define CALIMAIN_HWVERSION_MASK 0x7f000000
30 #define CALIMAIN_HWVERSION_SHIFT 24
32 /* Hardware version pinmux settings */
33 const struct pinmux_config hwversion_pins[] = {
34 { pinmux(16), 8, 2 }, /* GP7[15] */
35 { pinmux(16), 8, 3 }, /* GP7[14] */
36 { pinmux(16), 8, 4 }, /* GP7[13] */
37 { pinmux(16), 8, 5 }, /* GP7[12] */
38 { pinmux(16), 8, 6 }, /* GP7[11] */
39 { pinmux(16), 8, 7 }, /* GP7[10] */
40 { pinmux(17), 8, 0 }, /* GP7[9] */
41 { pinmux(17), 8, 1 } /* GP7[8] */
44 const struct pinmux_resource pinmuxes[] = {
45 PINMUX_ITEM(uart2_pins_txrx),
46 PINMUX_ITEM(emac_pins_mii),
47 PINMUX_ITEM(emac_pins_mdio),
48 PINMUX_ITEM(emifa_pins_nor),
49 PINMUX_ITEM(emifa_pins_cs2),
50 PINMUX_ITEM(emifa_pins_cs3),
53 const int pinmuxes_size = ARRAY_SIZE(pinmuxes);
55 const struct lpsc_resource lpsc[] = {
56 { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
57 { DAVINCI_LPSC_EMAC }, /* image download */
58 { DAVINCI_LPSC_UART2 }, /* console */
59 { DAVINCI_LPSC_GPIO },
62 const int lpsc_size = ARRAY_SIZE(lpsc);
64 /* read board revision from GPIO7[8..14] */
65 u32 get_board_rev(void)
67 lpsc_on(DAVINCI_LPSC_GPIO);
68 if (davinci_configure_pin_mux(hwversion_pins,
69 ARRAY_SIZE(hwversion_pins)) != 0)
72 return (davinci_gpio_bank67->in_data & CALIMAIN_HWVERSION_MASK)
73 >> CALIMAIN_HWVERSION_SHIFT;
77 * determine the oscillator frequency depending on the board revision
79 * rev 0x00 ... 25 MHz oscillator
80 * rev 0x01 ... 24 MHz oscillator
82 int calimain_get_osc_freq(void)
87 rev = get_board_rev();
105 /* address of boot parameters */
106 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
108 #ifdef CONFIG_DRIVER_TI_EMAC
109 /* select emac MII mode */
110 val = readl(&davinci_syscfg_regs->cfgchip3);
112 writel(val, &davinci_syscfg_regs->cfgchip3);
113 #endif /* CONFIG_DRIVER_TI_EMAC */
115 #ifdef CONFIG_HW_WATCHDOG
116 davinci_hw_watchdog_enable();
119 printf("Input clock frequency: %d Hz\n", calimain_get_osc_freq());
120 printf("Board revision: %d\n", get_board_rev());
125 #ifdef CONFIG_DRIVER_TI_EMAC
127 * Initializes on-board ethernet controllers.
129 int board_eth_init(bd_t *bis)
131 if (!davinci_emac_initialize()) {
132 printf("Error: Ethernet init failed!\n");
138 #endif /* CONFIG_DRIVER_TI_EMAC */
140 #ifdef CONFIG_HW_WATCHDOG
141 void hw_watchdog_reset(void)
143 davinci_hw_watchdog_reset();