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 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
31 #include <asm/arch/hardware.h>
32 #include <asm/arch/gpio.h>
33 #include <asm/arch/emif_defs.h>
34 #include <asm/arch/emac_defs.h>
35 #include <asm/arch/pinmux_defs.h>
36 #include <asm/arch/davinci_misc.h>
37 #include <asm/arch/timer_defs.h>
39 DECLARE_GLOBAL_DATA_PTR;
41 #define CALIMAIN_HWVERSION_MASK 0x7f000000
42 #define CALIMAIN_HWVERSION_SHIFT 24
44 /* Hardware version pinmux settings */
45 const struct pinmux_config hwversion_pins[] = {
46 { pinmux(16), 8, 2 }, /* GP7[15] */
47 { pinmux(16), 8, 3 }, /* GP7[14] */
48 { pinmux(16), 8, 4 }, /* GP7[13] */
49 { pinmux(16), 8, 5 }, /* GP7[12] */
50 { pinmux(16), 8, 6 }, /* GP7[11] */
51 { pinmux(16), 8, 7 }, /* GP7[10] */
52 { pinmux(17), 8, 0 }, /* GP7[9] */
53 { pinmux(17), 8, 1 } /* GP7[8] */
56 const struct pinmux_resource pinmuxes[] = {
57 PINMUX_ITEM(uart2_pins_txrx),
58 PINMUX_ITEM(emac_pins_mii),
59 PINMUX_ITEM(emac_pins_mdio),
60 PINMUX_ITEM(emifa_pins_nor),
61 PINMUX_ITEM(emifa_pins_cs2),
62 PINMUX_ITEM(emifa_pins_cs3),
65 const int pinmuxes_size = ARRAY_SIZE(pinmuxes);
67 const struct lpsc_resource lpsc[] = {
68 { DAVINCI_LPSC_AEMIF }, /* NAND, NOR */
69 { DAVINCI_LPSC_EMAC }, /* image download */
70 { DAVINCI_LPSC_UART2 }, /* console */
71 { DAVINCI_LPSC_GPIO },
74 const int lpsc_size = ARRAY_SIZE(lpsc);
76 /* read board revision from GPIO7[8..14] */
77 u32 get_board_rev(void)
79 lpsc_on(DAVINCI_LPSC_GPIO);
80 if (davinci_configure_pin_mux(hwversion_pins,
81 ARRAY_SIZE(hwversion_pins)) != 0)
84 return (davinci_gpio_bank67->in_data & CALIMAIN_HWVERSION_MASK)
85 >> CALIMAIN_HWVERSION_SHIFT;
89 * determine the oscillator frequency depending on the board revision
91 * rev 0x00 ... 25 MHz oscillator
92 * rev 0x01 ... 24 MHz oscillator
94 int calimain_get_osc_freq(void)
99 rev = get_board_rev();
115 #ifndef CONFIG_USE_IRQ
119 /* address of boot parameters */
120 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
122 #ifdef CONFIG_DRIVER_TI_EMAC
123 /* select emac MII mode */
124 val = readl(&davinci_syscfg_regs->cfgchip3);
126 writel(val, &davinci_syscfg_regs->cfgchip3);
127 #endif /* CONFIG_DRIVER_TI_EMAC */
129 #ifdef CONFIG_HW_WATCHDOG
130 davinci_hw_watchdog_enable();
133 printf("Input clock frequency: %d Hz\n", calimain_get_osc_freq());
134 printf("Board revision: %d\n", get_board_rev());
139 #ifdef CONFIG_DRIVER_TI_EMAC
141 * Initializes on-board ethernet controllers.
143 int board_eth_init(bd_t *bis)
145 if (!davinci_emac_initialize()) {
146 printf("Error: Ethernet init failed!\n");
152 #endif /* CONFIG_DRIVER_TI_EMAC */
154 #ifdef CONFIG_HW_WATCHDOG
155 void hw_watchdog_reset(void)
157 davinci_hw_watchdog_reset();
161 #if defined(CONFIG_BOOTCOUNT_LIMIT)
162 void bootcount_store(ulong a)
164 struct davinci_rtc *reg =
165 (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
168 * write RTC kick register to enable write
169 * for RTC Scratch registers. Scratch0 and 1 are
170 * used for bootcount values.
172 writel(RTC_KICK0R_WE, ®->kick0r);
173 writel(RTC_KICK1R_WE, ®->kick1r);
174 writel(a, ®->scratch0);
175 writel(BOOTCOUNT_MAGIC, ®->scratch1);
178 ulong bootcount_load(void)
180 struct davinci_rtc *reg =
181 (struct davinci_rtc *)CONFIG_SYS_BOOTCOUNT_ADDR;
183 if (readl(®->scratch1) != BOOTCOUNT_MAGIC)
186 return readl(®->scratch0);