1
2
3
4
5
6
7
8
9
10
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/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>
26
27DECLARE_GLOBAL_DATA_PTR;
28
29#define CALIMAIN_HWVERSION_MASK 0x7f000000
30#define CALIMAIN_HWVERSION_SHIFT 24
31
32
33const struct pinmux_config hwversion_pins[] = {
34 { pinmux(16), 8, 2 },
35 { pinmux(16), 8, 3 },
36 { pinmux(16), 8, 4 },
37 { pinmux(16), 8, 5 },
38 { pinmux(16), 8, 6 },
39 { pinmux(16), 8, 7 },
40 { pinmux(17), 8, 0 },
41 { pinmux(17), 8, 1 }
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 },
57 { DAVINCI_LPSC_EMAC },
58 { DAVINCI_LPSC_UART2 },
59 { DAVINCI_LPSC_GPIO },
60};
61
62const int lpsc_size = ARRAY_SIZE(lpsc);
63
64
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
78
79
80
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 irq_init();
104
105
106 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
107
108#ifdef CONFIG_DRIVER_TI_EMAC
109
110 val = readl(&davinci_syscfg_regs->cfgchip3);
111 val &= ~(1 << 8);
112 writel(val, &davinci_syscfg_regs->cfgchip3);
113#endif
114
115#ifdef CONFIG_HW_WATCHDOG
116 davinci_hw_watchdog_enable();
117#endif
118
119 printf("Input clock frequency: %d Hz\n", calimain_get_osc_freq());
120 printf("Board revision: %d\n", get_board_rev());
121
122 return 0;
123}
124
125#ifdef CONFIG_DRIVER_TI_EMAC
126
127
128
129int board_eth_init(bd_t *bis)
130{
131 if (!davinci_emac_initialize()) {
132 printf("Error: Ethernet init failed!\n");
133 return -1;
134 }
135
136 return 0;
137}
138#endif
139
140#ifdef CONFIG_HW_WATCHDOG
141void hw_watchdog_reset(void)
142{
143 davinci_hw_watchdog_reset();
144}
145#endif
146