]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/omicron/calimain/calimain.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[people/ms/u-boot.git] / board / omicron / calimain / calimain.c
CommitLineData
9a3aae22
CR
1/*
2 * Copyright (C) 2011 OMICRON electronics GmbH
3 *
4 * Based on da850evm.c. Original Copyrights follow:
5 *
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>
9 *
1a459660 10 * SPDX-License-Identifier: GPL-2.0+
9a3aae22
CR
11 */
12
13#include <common.h>
14#include <i2c.h>
15#include <net.h>
16#include <netdev.h>
17#include <watchdog.h>
18#include <asm/io.h>
19#include <asm/arch/hardware.h>
20#include <asm/arch/gpio.h>
21#include <asm/arch/emif_defs.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>
26
27DECLARE_GLOBAL_DATA_PTR;
28
29#define CALIMAIN_HWVERSION_MASK 0x7f000000
30#define CALIMAIN_HWVERSION_SHIFT 24
31
32/* Hardware version pinmux settings */
33const 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] */
42};
43
44const 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),
51};
52
53const int pinmuxes_size = ARRAY_SIZE(pinmuxes);
54
55const 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 },
60};
61
62const int lpsc_size = ARRAY_SIZE(lpsc);
63
64/* read board revision from GPIO7[8..14] */
65u32 get_board_rev(void)
66{
67 lpsc_on(DAVINCI_LPSC_GPIO);
68 if (davinci_configure_pin_mux(hwversion_pins,
69 ARRAY_SIZE(hwversion_pins)) != 0)
70 return 0xffffffff;
71
72 return (davinci_gpio_bank67->in_data & CALIMAIN_HWVERSION_MASK)
73 >> CALIMAIN_HWVERSION_SHIFT;
74}
75
76/*
77 * determine the oscillator frequency depending on the board revision
78 *
79 * rev 0x00 ... 25 MHz oscillator
80 * rev 0x01 ... 24 MHz oscillator
81 */
82int calimain_get_osc_freq(void)
83{
84 u32 rev;
85 int freq;
86
87 rev = get_board_rev();
88 switch (rev) {
89 case 0x00:
90 freq = 25000000;
91 break;
92 default:
93 freq = 24000000;
94 break;
95 }
96 return freq;
97}
98
99int board_init(void)
100{
101 int val;
102
103#ifndef CONFIG_USE_IRQ
104 irq_init();
105#endif
106
107 /* address of boot parameters */
108 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
109
110#ifdef CONFIG_DRIVER_TI_EMAC
111 /* select emac MII mode */
112 val = readl(&davinci_syscfg_regs->cfgchip3);
113 val &= ~(1 << 8);
114 writel(val, &davinci_syscfg_regs->cfgchip3);
115#endif /* CONFIG_DRIVER_TI_EMAC */
116
117#ifdef CONFIG_HW_WATCHDOG
118 davinci_hw_watchdog_enable();
119#endif
120
121 printf("Input clock frequency: %d Hz\n", calimain_get_osc_freq());
122 printf("Board revision: %d\n", get_board_rev());
123
124 return 0;
125}
126
127#ifdef CONFIG_DRIVER_TI_EMAC
128/*
129 * Initializes on-board ethernet controllers.
130 */
131int board_eth_init(bd_t *bis)
132{
133 if (!davinci_emac_initialize()) {
134 printf("Error: Ethernet init failed!\n");
135 return -1;
136 }
137
138 return 0;
139}
140#endif /* CONFIG_DRIVER_TI_EMAC */
141
142#ifdef CONFIG_HW_WATCHDOG
143void hw_watchdog_reset(void)
144{
145 davinci_hw_watchdog_reset();
146}
147#endif