1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30#include <common.h>
31#include <i2c.h>
32#include <asm/arch/hardware.h>
33#include <asm/arch/emac_defs.h>
34#include "../common/psc.h"
35#include "../common/misc.h"
36
37#define DAVINCI_A3CR (0x01E00014)
38#define DAVINCI_A3CR_VAL (0x3FFFFFFD)
39
40#define INTEGRITY_SYSCFG_OFFSET 0x7E8
41#define INTEGRITY_CHECKWORD_OFFSET 0x7F8
42#define INTEGRITY_CHECKWORD_VALUE 0x10ADBEEF
43
44DECLARE_GLOBAL_DATA_PTR;
45
46int board_init(void)
47{
48
49 gd->bd->bi_arch_number = MACH_TYPE_SFFSDR;
50
51
52 gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
53
54
55 REG(PSC_SILVER_BULLET) = 0;
56
57
58 lpsc_on(DAVINCI_LPSC_EMAC);
59 lpsc_on(DAVINCI_LPSC_EMAC_WRAPPER);
60 lpsc_on(DAVINCI_LPSC_MDIO);
61 lpsc_on(DAVINCI_LPSC_I2C);
62 lpsc_on(DAVINCI_LPSC_UART0);
63 lpsc_on(DAVINCI_LPSC_TIMER1);
64 lpsc_on(DAVINCI_LPSC_GPIO);
65
66#if !defined(CONFIG_SYS_USE_DSPLINK)
67
68 dsp_on();
69#endif
70
71
72 REG(UART0_PWREMU_MGMT) = 0x0000e003;
73
74
75 REG(VDD3P3V_PWDN) = 0;
76
77
78 REG(PINMUX1) |= 1;
79
80
81 REG(PINMUX0) = 0x80000c1f;
82
83
84 REG(PINMUX1) |= (1 << 7);
85
86
87 REG(VBPR) = 0x20;
88
89 timer_init();
90
91 return(0);
92}
93
94
95
96
97static int sffsdr_read_mac_address(uint8_t *buf)
98{
99 u_int32_t value, mac[2], address;
100
101
102 if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, INTEGRITY_CHECKWORD_OFFSET,
103 CONFIG_SYS_I2C_EEPROM_ADDR_LEN, (uint8_t *) &value, 4))
104 goto err;
105 if (value != INTEGRITY_CHECKWORD_VALUE)
106 return 0;
107
108
109 if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, INTEGRITY_SYSCFG_OFFSET,
110 CONFIG_SYS_I2C_EEPROM_ADDR_LEN, (uint8_t *) &value, 4))
111 goto err;
112 address = 0x800 + (int) value;
113
114
115 if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, address,
116 CONFIG_SYS_I2C_EEPROM_ADDR_LEN, (uint8_t *) &value, 4))
117 goto err;
118 address = 0x800 + (int) value;
119 address += 12;
120
121
122 if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, address,
123 CONFIG_SYS_I2C_EEPROM_ADDR_LEN, (uint8_t *) &value, 4))
124 goto err;
125 address = 0x800 + 16 + (int) value;
126
127
128
129 if (i2c_read(CONFIG_SYS_I2C_EEPROM_ADDR, address,
130 CONFIG_SYS_I2C_EEPROM_ADDR_LEN, (uint8_t *) &mac[0], 8))
131 goto err;
132
133 buf[0] = mac[0] >> 24;
134 buf[1] = mac[0] >> 16;
135 buf[2] = mac[0] >> 8;
136 buf[3] = mac[0];
137 buf[4] = mac[1] >> 24;
138 buf[5] = mac[1] >> 16;
139
140 return 1;
141
142err:
143 printf("Read from EEPROM @ 0x%02x failed\n", CONFIG_SYS_I2C_EEPROM_ADDR);
144 return 0;
145}
146
147
148int misc_init_r(void)
149{
150 uint8_t i2cbuf;
151 uint8_t eeprom_enetaddr[6];
152
153
154 REG(DAVINCI_A3CR) = DAVINCI_A3CR_VAL;
155
156 dv_display_clk_infos();
157
158
159 i2cbuf = CONFIG_SYS_I2C_PCA9543_ENABLE_CH0;
160 if (i2c_write(CONFIG_SYS_I2C_PCA9543_ADDR, 0,
161 CONFIG_SYS_I2C_PCA9543_ADDR_LEN, &i2cbuf, 1)) {
162 printf("Write to MUX @ 0x%02x failed\n", CONFIG_SYS_I2C_PCA9543_ADDR);
163 return 1;
164 }
165
166
167 if (sffsdr_read_mac_address(eeprom_enetaddr))
168 dv_configure_mac_address(eeprom_enetaddr);
169
170 if (!eth_hw_init())
171 printf("Ethernet init failed\n");
172
173 return(0);
174}
175