1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <common.h>
25#include <asm/processor.h>
26#include <asm/io.h>
27#include <command.h>
28#include <malloc.h>
29
30DECLARE_GLOBAL_DATA_PTR;
31
32extern void lxt971_no_sleep(void);
33
34int board_early_init_f (void)
35{
36
37
38
39
40
41
42
43
44
45
46
47
48 mtdcr(UIC0SR, 0xFFFFFFFF);
49 mtdcr(UIC0ER, 0x00000000);
50 mtdcr(UIC0CR, 0x00000000);
51 mtdcr(UIC0PR, 0xFFFFFF80);
52 mtdcr(UIC0TR, 0x10000000);
53 mtdcr(UIC0VCR, 0x00000001);
54 mtdcr(UIC0SR, 0xFFFFFFFF);
55
56
57
58
59 mtebc (EBC0_CFG, 0xa8400000);
60
61
62
63
64 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_PLD_RESET);
65 udelay(1000);
66 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_PLD_RESET);
67 udelay(1000);
68
69 return 0;
70}
71
72int misc_init_r (void)
73{
74
75 gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
76 gd->bd->bi_flashoffset = 0;
77
78
79
80
81 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_EEPROM_WP);
82
83 return (0);
84}
85
86
87
88
89
90#define LED_REG (CONFIG_SYS_PLD_BASE + 0x1000)
91int checkboard (void)
92{
93 char str[64];
94 int flashcnt;
95 int delay;
96
97 puts ("Board: ");
98
99 if (getenv_f("serial#", str, sizeof(str)) == -1) {
100 puts ("### No HW ID - assuming CMS700");
101 } else {
102 puts(str);
103 }
104
105 printf(" (PLD-Version=%02d)\n",
106 in_8((void *)(CONFIG_SYS_PLD_BASE + 0x1001)));
107
108
109
110
111 for (flashcnt = 0; flashcnt < 3; flashcnt++) {
112 out_8((void *)LED_REG, 0x00);
113 for (delay = 0; delay < 100; delay++)
114 udelay(1000);
115 out_8((void *)LED_REG, 0x0f);
116 for (delay = 0; delay < 50; delay++)
117 udelay(1000);
118 }
119 out_8((void *)LED_REG, 0x70);
120
121 return 0;
122}
123
124
125
126#if defined(CONFIG_SYS_EEPROM_WREN)
127
128
129
130
131
132
133
134
135int eeprom_write_enable (unsigned dev_addr, int state)
136{
137 if (CONFIG_SYS_I2C_EEPROM_ADDR != dev_addr) {
138 return -1;
139 } else {
140 switch (state) {
141 case 1:
142
143 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) & ~CONFIG_SYS_EEPROM_WP);
144 state = 0;
145 break;
146 case 0:
147
148 out_be32((void *)GPIO0_OR, in_be32((void *)GPIO0_OR) | CONFIG_SYS_EEPROM_WP);
149 state = 0;
150 break;
151 default:
152
153 state = (0 == (in_be32((void *)GPIO0_OR) & CONFIG_SYS_EEPROM_WP));
154 break;
155 }
156 }
157 return state;
158}
159
160int do_eep_wren (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
161{
162 int query = argc == 1;
163 int state = 0;
164
165 if (query) {
166
167 state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, -1);
168 if (state < 0) {
169 puts ("Query of write access state failed.\n");
170 } else {
171 printf ("Write access for device 0x%0x is %sabled.\n",
172 CONFIG_SYS_I2C_EEPROM_ADDR, state ? "en" : "dis");
173 state = 0;
174 }
175 } else {
176 if ('0' == argv[1][0]) {
177
178 state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, 0);
179 } else {
180
181 state = eeprom_write_enable (CONFIG_SYS_I2C_EEPROM_ADDR, 1);
182 }
183 if (state < 0) {
184 puts ("Setup of write access state failed.\n");
185 }
186 }
187
188 return state;
189}
190
191U_BOOT_CMD(eepwren, 2, 0, do_eep_wren,
192 "Enable / disable / query EEPROM write access",
193 ""
194);
195#endif
196
197
198
199void reset_phy(void)
200{
201#ifdef CONFIG_LXT971_NO_SLEEP
202
203
204
205
206 lxt971_no_sleep();
207#endif
208}
209