Commit 64a480601a5614b441de692ae15a62c51e0bb381
Committed by
Wolfgang Denk
1 parent
f3a7bddc06
Exists in
master
and in
54 other branches
smc91111_eeprom: drop CONFIG stub protection
Since the Makefile now controls the compilation of this, there is no need for CONFIG checking nor the stub function. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Showing 1 changed file with 0 additions and 12 deletions Inline Diff
examples/standalone/smc91111_eeprom.c
1 | /* | 1 | /* |
2 | * (C) Copyright 2004 | 2 | * (C) Copyright 2004 |
3 | * Robin Getz rgetz@blacfin.uclinux.org | 3 | * Robin Getz rgetz@blacfin.uclinux.org |
4 | * | 4 | * |
5 | * See file CREDITS for list of people who contributed to this | 5 | * See file CREDITS for list of people who contributed to this |
6 | * project. | 6 | * project. |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
9 | * modify it under the terms of the GNU General Public License as | 9 | * modify it under the terms of the GNU General Public License as |
10 | * published by the Free Software Foundation; either version 2 of | 10 | * published by the Free Software Foundation; either version 2 of |
11 | * the License, or (at your option) any later version. | 11 | * the License, or (at your option) any later version. |
12 | * | 12 | * |
13 | * This program is distributed in the hope that it will be useful, | 13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. |
17 | * | 17 | * |
18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software | 19 | * along with this program; if not, write to the Free Software |
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
21 | * MA 02111-1307 USA | 21 | * MA 02111-1307 USA |
22 | * | 22 | * |
23 | * Heavily borrowed from the following peoples GPL'ed software: | 23 | * Heavily borrowed from the following peoples GPL'ed software: |
24 | * - Wolfgang Denk, DENX Software Engineering, wd@denx.de | 24 | * - Wolfgang Denk, DENX Software Engineering, wd@denx.de |
25 | * Das U-boot | 25 | * Das U-boot |
26 | * - Ladislav Michl ladis@linux-mips.org | 26 | * - Ladislav Michl ladis@linux-mips.org |
27 | * A rejected patch on the U-Boot mailing list | 27 | * A rejected patch on the U-Boot mailing list |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <common.h> | 30 | #include <common.h> |
31 | #include <exports.h> | 31 | #include <exports.h> |
32 | /* the smc91111.h gets base addr through eth_device' iobase */ | 32 | /* the smc91111.h gets base addr through eth_device' iobase */ |
33 | struct eth_device { unsigned long iobase; }; | 33 | struct eth_device { unsigned long iobase; }; |
34 | #include "../drivers/net/smc91111.h" | 34 | #include "../drivers/net/smc91111.h" |
35 | 35 | ||
36 | #ifdef CONFIG_SMC91111 | ||
37 | |||
38 | #ifndef SMC91111_EEPROM_INIT | 36 | #ifndef SMC91111_EEPROM_INIT |
39 | # define SMC91111_EEPROM_INIT() | 37 | # define SMC91111_EEPROM_INIT() |
40 | #endif | 38 | #endif |
41 | 39 | ||
42 | #define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE | 40 | #define SMC_BASE_ADDRESS CONFIG_SMC91111_BASE |
43 | #define EEPROM 0x1 | 41 | #define EEPROM 0x1 |
44 | #define MAC 0x2 | 42 | #define MAC 0x2 |
45 | #define UNKNOWN 0x4 | 43 | #define UNKNOWN 0x4 |
46 | 44 | ||
47 | void dump_reg (struct eth_device *dev); | 45 | void dump_reg (struct eth_device *dev); |
48 | void dump_eeprom (struct eth_device *dev); | 46 | void dump_eeprom (struct eth_device *dev); |
49 | int write_eeprom_reg (struct eth_device *dev, int value, int reg); | 47 | int write_eeprom_reg (struct eth_device *dev, int value, int reg); |
50 | void copy_from_eeprom (struct eth_device *dev); | 48 | void copy_from_eeprom (struct eth_device *dev); |
51 | void print_MAC (struct eth_device *dev); | 49 | void print_MAC (struct eth_device *dev); |
52 | int read_eeprom_reg (struct eth_device *dev, int reg); | 50 | int read_eeprom_reg (struct eth_device *dev, int reg); |
53 | void print_macaddr (struct eth_device *dev); | 51 | void print_macaddr (struct eth_device *dev); |
54 | 52 | ||
55 | int smc91111_eeprom (int argc, char *argv[]) | 53 | int smc91111_eeprom (int argc, char *argv[]) |
56 | { | 54 | { |
57 | int c, i, j, done, line, reg, value, start, what; | 55 | int c, i, j, done, line, reg, value, start, what; |
58 | char input[50]; | 56 | char input[50]; |
59 | 57 | ||
60 | struct eth_device dev = { | 58 | struct eth_device dev = { |
61 | .iobase = CONFIG_SMC91111_BASE | 59 | .iobase = CONFIG_SMC91111_BASE |
62 | }; | 60 | }; |
63 | 61 | ||
64 | /* Print the ABI version */ | 62 | /* Print the ABI version */ |
65 | app_startup (argv); | 63 | app_startup (argv); |
66 | if (XF_VERSION != (int) get_version ()) { | 64 | if (XF_VERSION != (int) get_version ()) { |
67 | printf ("Expects ABI version %d\n", XF_VERSION); | 65 | printf ("Expects ABI version %d\n", XF_VERSION); |
68 | printf ("Actual U-Boot ABI version %d\n", | 66 | printf ("Actual U-Boot ABI version %d\n", |
69 | (int) get_version ()); | 67 | (int) get_version ()); |
70 | printf ("Can't run\n\n"); | 68 | printf ("Can't run\n\n"); |
71 | return (0); | 69 | return (0); |
72 | } | 70 | } |
73 | 71 | ||
74 | SMC91111_EEPROM_INIT(); | 72 | SMC91111_EEPROM_INIT(); |
75 | 73 | ||
76 | if ((SMC_inw (&dev, BANK_SELECT) & 0xFF00) != 0x3300) { | 74 | if ((SMC_inw (&dev, BANK_SELECT) & 0xFF00) != 0x3300) { |
77 | printf ("Can't find SMSC91111\n"); | 75 | printf ("Can't find SMSC91111\n"); |
78 | return (0); | 76 | return (0); |
79 | } | 77 | } |
80 | 78 | ||
81 | done = 0; | 79 | done = 0; |
82 | what = UNKNOWN; | 80 | what = UNKNOWN; |
83 | printf ("\n"); | 81 | printf ("\n"); |
84 | while (!done) { | 82 | while (!done) { |
85 | /* print the prompt */ | 83 | /* print the prompt */ |
86 | printf ("SMC91111> "); | 84 | printf ("SMC91111> "); |
87 | line = 0; | 85 | line = 0; |
88 | i = 0; | 86 | i = 0; |
89 | start = 1; | 87 | start = 1; |
90 | while (!line) { | 88 | while (!line) { |
91 | /* Wait for a keystroke */ | 89 | /* Wait for a keystroke */ |
92 | while (!tstc ()); | 90 | while (!tstc ()); |
93 | 91 | ||
94 | c = getc (); | 92 | c = getc (); |
95 | /* Make Uppercase */ | 93 | /* Make Uppercase */ |
96 | if (c >= 'Z') | 94 | if (c >= 'Z') |
97 | c -= ('a' - 'A'); | 95 | c -= ('a' - 'A'); |
98 | /* printf(" |%02x| ",c); */ | 96 | /* printf(" |%02x| ",c); */ |
99 | 97 | ||
100 | switch (c) { | 98 | switch (c) { |
101 | case '\r': /* Enter */ | 99 | case '\r': /* Enter */ |
102 | case '\n': | 100 | case '\n': |
103 | input[i] = 0; | 101 | input[i] = 0; |
104 | puts ("\r\n"); | 102 | puts ("\r\n"); |
105 | line = 1; | 103 | line = 1; |
106 | break; | 104 | break; |
107 | case '\0': /* nul */ | 105 | case '\0': /* nul */ |
108 | continue; | 106 | continue; |
109 | 107 | ||
110 | case 0x03: /* ^C - break */ | 108 | case 0x03: /* ^C - break */ |
111 | input[0] = 0; | 109 | input[0] = 0; |
112 | i = 0; | 110 | i = 0; |
113 | line = 1; | 111 | line = 1; |
114 | done = 1; | 112 | done = 1; |
115 | break; | 113 | break; |
116 | 114 | ||
117 | case 0x5F: | 115 | case 0x5F: |
118 | case 0x08: /* ^H - backspace */ | 116 | case 0x08: /* ^H - backspace */ |
119 | case 0x7F: /* DEL - backspace */ | 117 | case 0x7F: /* DEL - backspace */ |
120 | if (i > 0) { | 118 | if (i > 0) { |
121 | puts ("\b \b"); | 119 | puts ("\b \b"); |
122 | i--; | 120 | i--; |
123 | } | 121 | } |
124 | break; | 122 | break; |
125 | default: | 123 | default: |
126 | if (start) { | 124 | if (start) { |
127 | if ((c == 'W') || (c == 'D') | 125 | if ((c == 'W') || (c == 'D') |
128 | || (c == 'M') || (c == 'C') | 126 | || (c == 'M') || (c == 'C') |
129 | || (c == 'P')) { | 127 | || (c == 'P')) { |
130 | putc (c); | 128 | putc (c); |
131 | input[i] = c; | 129 | input[i] = c; |
132 | if (i <= 45) | 130 | if (i <= 45) |
133 | i++; | 131 | i++; |
134 | start = 0; | 132 | start = 0; |
135 | } | 133 | } |
136 | } else { | 134 | } else { |
137 | if ((c >= '0' && c <= '9') | 135 | if ((c >= '0' && c <= '9') |
138 | || (c >= 'A' && c <= 'F') | 136 | || (c >= 'A' && c <= 'F') |
139 | || (c == 'E') || (c == 'M') | 137 | || (c == 'E') || (c == 'M') |
140 | || (c == ' ')) { | 138 | || (c == ' ')) { |
141 | putc (c); | 139 | putc (c); |
142 | input[i] = c; | 140 | input[i] = c; |
143 | if (i <= 45) | 141 | if (i <= 45) |
144 | i++; | 142 | i++; |
145 | break; | 143 | break; |
146 | } | 144 | } |
147 | } | 145 | } |
148 | break; | 146 | break; |
149 | } | 147 | } |
150 | } | 148 | } |
151 | 149 | ||
152 | for (; i < 49; i++) | 150 | for (; i < 49; i++) |
153 | input[i] = 0; | 151 | input[i] = 0; |
154 | 152 | ||
155 | switch (input[0]) { | 153 | switch (input[0]) { |
156 | case ('W'): | 154 | case ('W'): |
157 | /* Line should be w reg value */ | 155 | /* Line should be w reg value */ |
158 | i = 0; | 156 | i = 0; |
159 | reg = 0; | 157 | reg = 0; |
160 | value = 0; | 158 | value = 0; |
161 | /* Skip to the next space or end) */ | 159 | /* Skip to the next space or end) */ |
162 | while ((input[i] != ' ') && (input[i] != 0)) | 160 | while ((input[i] != ' ') && (input[i] != 0)) |
163 | i++; | 161 | i++; |
164 | 162 | ||
165 | if (input[i] != 0) | 163 | if (input[i] != 0) |
166 | i++; | 164 | i++; |
167 | 165 | ||
168 | /* Are we writing to EEPROM or MAC */ | 166 | /* Are we writing to EEPROM or MAC */ |
169 | switch (input[i]) { | 167 | switch (input[i]) { |
170 | case ('E'): | 168 | case ('E'): |
171 | what = EEPROM; | 169 | what = EEPROM; |
172 | break; | 170 | break; |
173 | case ('M'): | 171 | case ('M'): |
174 | what = MAC; | 172 | what = MAC; |
175 | break; | 173 | break; |
176 | default: | 174 | default: |
177 | what = UNKNOWN; | 175 | what = UNKNOWN; |
178 | break; | 176 | break; |
179 | } | 177 | } |
180 | 178 | ||
181 | /* skip to the next space or end */ | 179 | /* skip to the next space or end */ |
182 | while ((input[i] != ' ') && (input[i] != 0)) | 180 | while ((input[i] != ' ') && (input[i] != 0)) |
183 | i++; | 181 | i++; |
184 | if (input[i] != 0) | 182 | if (input[i] != 0) |
185 | i++; | 183 | i++; |
186 | 184 | ||
187 | /* Find register to write into */ | 185 | /* Find register to write into */ |
188 | j = 0; | 186 | j = 0; |
189 | while ((input[i] != ' ') && (input[i] != 0)) { | 187 | while ((input[i] != ' ') && (input[i] != 0)) { |
190 | j = input[i] - 0x30; | 188 | j = input[i] - 0x30; |
191 | if (j >= 0xA) { | 189 | if (j >= 0xA) { |
192 | j -= 0x07; | 190 | j -= 0x07; |
193 | } | 191 | } |
194 | reg = (reg * 0x10) + j; | 192 | reg = (reg * 0x10) + j; |
195 | i++; | 193 | i++; |
196 | } | 194 | } |
197 | 195 | ||
198 | while ((input[i] != ' ') && (input[i] != 0)) | 196 | while ((input[i] != ' ') && (input[i] != 0)) |
199 | i++; | 197 | i++; |
200 | 198 | ||
201 | if (input[i] != 0) | 199 | if (input[i] != 0) |
202 | i++; | 200 | i++; |
203 | else | 201 | else |
204 | what = UNKNOWN; | 202 | what = UNKNOWN; |
205 | 203 | ||
206 | /* Get the value to write */ | 204 | /* Get the value to write */ |
207 | j = 0; | 205 | j = 0; |
208 | while ((input[i] != ' ') && (input[i] != 0)) { | 206 | while ((input[i] != ' ') && (input[i] != 0)) { |
209 | j = input[i] - 0x30; | 207 | j = input[i] - 0x30; |
210 | if (j >= 0xA) { | 208 | if (j >= 0xA) { |
211 | j -= 0x07; | 209 | j -= 0x07; |
212 | } | 210 | } |
213 | value = (value * 0x10) + j; | 211 | value = (value * 0x10) + j; |
214 | i++; | 212 | i++; |
215 | } | 213 | } |
216 | 214 | ||
217 | switch (what) { | 215 | switch (what) { |
218 | case 1: | 216 | case 1: |
219 | printf ("Writing EEPROM register %02x with %04x\n", reg, value); | 217 | printf ("Writing EEPROM register %02x with %04x\n", reg, value); |
220 | write_eeprom_reg (&dev, value, reg); | 218 | write_eeprom_reg (&dev, value, reg); |
221 | break; | 219 | break; |
222 | case 2: | 220 | case 2: |
223 | printf ("Writing MAC register bank %i, reg %02x with %04x\n", reg >> 4, reg & 0xE, value); | 221 | printf ("Writing MAC register bank %i, reg %02x with %04x\n", reg >> 4, reg & 0xE, value); |
224 | SMC_SELECT_BANK (&dev, reg >> 4); | 222 | SMC_SELECT_BANK (&dev, reg >> 4); |
225 | SMC_outw (&dev, value, reg & 0xE); | 223 | SMC_outw (&dev, value, reg & 0xE); |
226 | break; | 224 | break; |
227 | default: | 225 | default: |
228 | printf ("Wrong\n"); | 226 | printf ("Wrong\n"); |
229 | break; | 227 | break; |
230 | } | 228 | } |
231 | break; | 229 | break; |
232 | case ('D'): | 230 | case ('D'): |
233 | dump_eeprom (&dev); | 231 | dump_eeprom (&dev); |
234 | break; | 232 | break; |
235 | case ('M'): | 233 | case ('M'): |
236 | dump_reg (&dev); | 234 | dump_reg (&dev); |
237 | break; | 235 | break; |
238 | case ('C'): | 236 | case ('C'): |
239 | copy_from_eeprom (&dev); | 237 | copy_from_eeprom (&dev); |
240 | break; | 238 | break; |
241 | case ('P'): | 239 | case ('P'): |
242 | print_macaddr (&dev); | 240 | print_macaddr (&dev); |
243 | break; | 241 | break; |
244 | default: | 242 | default: |
245 | break; | 243 | break; |
246 | } | 244 | } |
247 | 245 | ||
248 | } | 246 | } |
249 | 247 | ||
250 | return (0); | 248 | return (0); |
251 | } | 249 | } |
252 | 250 | ||
253 | void copy_from_eeprom (struct eth_device *dev) | 251 | void copy_from_eeprom (struct eth_device *dev) |
254 | { | 252 | { |
255 | int i; | 253 | int i; |
256 | 254 | ||
257 | SMC_SELECT_BANK (dev, 1); | 255 | SMC_SELECT_BANK (dev, 1); |
258 | SMC_outw (dev, (SMC_inw (dev, CTL_REG) & !CTL_EEPROM_SELECT) | | 256 | SMC_outw (dev, (SMC_inw (dev, CTL_REG) & !CTL_EEPROM_SELECT) | |
259 | CTL_RELOAD, CTL_REG); | 257 | CTL_RELOAD, CTL_REG); |
260 | i = 100; | 258 | i = 100; |
261 | while ((SMC_inw (dev, CTL_REG) & CTL_RELOAD) && --i) | 259 | while ((SMC_inw (dev, CTL_REG) & CTL_RELOAD) && --i) |
262 | udelay (100); | 260 | udelay (100); |
263 | if (i == 0) { | 261 | if (i == 0) { |
264 | printf ("Timeout Refreshing EEPROM registers\n"); | 262 | printf ("Timeout Refreshing EEPROM registers\n"); |
265 | } else { | 263 | } else { |
266 | printf ("EEPROM contents copied to MAC\n"); | 264 | printf ("EEPROM contents copied to MAC\n"); |
267 | } | 265 | } |
268 | 266 | ||
269 | } | 267 | } |
270 | 268 | ||
271 | void print_macaddr (struct eth_device *dev) | 269 | void print_macaddr (struct eth_device *dev) |
272 | { | 270 | { |
273 | int i, j, k, mac[6]; | 271 | int i, j, k, mac[6]; |
274 | 272 | ||
275 | printf ("Current MAC Address in SMSC91111 "); | 273 | printf ("Current MAC Address in SMSC91111 "); |
276 | SMC_SELECT_BANK (dev, 1); | 274 | SMC_SELECT_BANK (dev, 1); |
277 | for (i = 0; i < 5; i++) { | 275 | for (i = 0; i < 5; i++) { |
278 | printf ("%02x:", SMC_inb (dev, ADDR0_REG + i)); | 276 | printf ("%02x:", SMC_inb (dev, ADDR0_REG + i)); |
279 | } | 277 | } |
280 | 278 | ||
281 | printf ("%02x\n", SMC_inb (dev, ADDR0_REG + 5)); | 279 | printf ("%02x\n", SMC_inb (dev, ADDR0_REG + 5)); |
282 | 280 | ||
283 | i = 0; | 281 | i = 0; |
284 | for (j = 0x20; j < 0x23; j++) { | 282 | for (j = 0x20; j < 0x23; j++) { |
285 | k = read_eeprom_reg (dev, j); | 283 | k = read_eeprom_reg (dev, j); |
286 | mac[i] = k & 0xFF; | 284 | mac[i] = k & 0xFF; |
287 | i++; | 285 | i++; |
288 | mac[i] = k >> 8; | 286 | mac[i] = k >> 8; |
289 | i++; | 287 | i++; |
290 | } | 288 | } |
291 | 289 | ||
292 | printf ("Current MAC Address in EEPROM "); | 290 | printf ("Current MAC Address in EEPROM "); |
293 | for (i = 0; i < 5; i++) | 291 | for (i = 0; i < 5; i++) |
294 | printf ("%02x:", mac[i]); | 292 | printf ("%02x:", mac[i]); |
295 | printf ("%02x\n", mac[5]); | 293 | printf ("%02x\n", mac[5]); |
296 | 294 | ||
297 | } | 295 | } |
298 | void dump_eeprom (struct eth_device *dev) | 296 | void dump_eeprom (struct eth_device *dev) |
299 | { | 297 | { |
300 | int j, k; | 298 | int j, k; |
301 | 299 | ||
302 | printf ("IOS2-0 "); | 300 | printf ("IOS2-0 "); |
303 | for (j = 0; j < 8; j++) { | 301 | for (j = 0; j < 8; j++) { |
304 | printf ("%03x ", j); | 302 | printf ("%03x ", j); |
305 | } | 303 | } |
306 | printf ("\n"); | 304 | printf ("\n"); |
307 | 305 | ||
308 | for (k = 0; k < 4; k++) { | 306 | for (k = 0; k < 4; k++) { |
309 | if (k == 0) | 307 | if (k == 0) |
310 | printf ("CONFIG "); | 308 | printf ("CONFIG "); |
311 | if (k == 1) | 309 | if (k == 1) |
312 | printf ("BASE "); | 310 | printf ("BASE "); |
313 | if ((k == 2) || (k == 3)) | 311 | if ((k == 2) || (k == 3)) |
314 | printf (" "); | 312 | printf (" "); |
315 | for (j = 0; j < 0x20; j += 4) { | 313 | for (j = 0; j < 0x20; j += 4) { |
316 | printf ("%02x:%04x ", j + k, | 314 | printf ("%02x:%04x ", j + k, |
317 | read_eeprom_reg (dev, j + k)); | 315 | read_eeprom_reg (dev, j + k)); |
318 | } | 316 | } |
319 | printf ("\n"); | 317 | printf ("\n"); |
320 | } | 318 | } |
321 | 319 | ||
322 | for (j = 0x20; j < 0x40; j++) { | 320 | for (j = 0x20; j < 0x40; j++) { |
323 | if ((j & 0x07) == 0) | 321 | if ((j & 0x07) == 0) |
324 | printf ("\n"); | 322 | printf ("\n"); |
325 | printf ("%02x:%04x ", j, read_eeprom_reg (dev, j)); | 323 | printf ("%02x:%04x ", j, read_eeprom_reg (dev, j)); |
326 | } | 324 | } |
327 | printf ("\n"); | 325 | printf ("\n"); |
328 | 326 | ||
329 | } | 327 | } |
330 | 328 | ||
331 | int read_eeprom_reg (struct eth_device *dev, int reg) | 329 | int read_eeprom_reg (struct eth_device *dev, int reg) |
332 | { | 330 | { |
333 | int timeout; | 331 | int timeout; |
334 | 332 | ||
335 | SMC_SELECT_BANK (dev, 2); | 333 | SMC_SELECT_BANK (dev, 2); |
336 | SMC_outw (dev, reg, PTR_REG); | 334 | SMC_outw (dev, reg, PTR_REG); |
337 | 335 | ||
338 | SMC_SELECT_BANK (dev, 1); | 336 | SMC_SELECT_BANK (dev, 1); |
339 | SMC_outw (dev, SMC_inw (dev, CTL_REG) | CTL_EEPROM_SELECT | | 337 | SMC_outw (dev, SMC_inw (dev, CTL_REG) | CTL_EEPROM_SELECT | |
340 | CTL_RELOAD, CTL_REG); | 338 | CTL_RELOAD, CTL_REG); |
341 | timeout = 100; | 339 | timeout = 100; |
342 | while ((SMC_inw (dev, CTL_REG) & CTL_RELOAD) && --timeout) | 340 | while ((SMC_inw (dev, CTL_REG) & CTL_RELOAD) && --timeout) |
343 | udelay (100); | 341 | udelay (100); |
344 | if (timeout == 0) { | 342 | if (timeout == 0) { |
345 | printf ("Timeout Reading EEPROM register %02x\n", reg); | 343 | printf ("Timeout Reading EEPROM register %02x\n", reg); |
346 | return 0; | 344 | return 0; |
347 | } | 345 | } |
348 | 346 | ||
349 | return SMC_inw (dev, GP_REG); | 347 | return SMC_inw (dev, GP_REG); |
350 | 348 | ||
351 | } | 349 | } |
352 | 350 | ||
353 | int write_eeprom_reg (struct eth_device *dev, int value, int reg) | 351 | int write_eeprom_reg (struct eth_device *dev, int value, int reg) |
354 | { | 352 | { |
355 | int timeout; | 353 | int timeout; |
356 | 354 | ||
357 | SMC_SELECT_BANK (dev, 2); | 355 | SMC_SELECT_BANK (dev, 2); |
358 | SMC_outw (dev, reg, PTR_REG); | 356 | SMC_outw (dev, reg, PTR_REG); |
359 | 357 | ||
360 | SMC_SELECT_BANK (dev, 1); | 358 | SMC_SELECT_BANK (dev, 1); |
361 | SMC_outw (dev, value, GP_REG); | 359 | SMC_outw (dev, value, GP_REG); |
362 | SMC_outw (dev, SMC_inw (dev, CTL_REG) | CTL_EEPROM_SELECT | | 360 | SMC_outw (dev, SMC_inw (dev, CTL_REG) | CTL_EEPROM_SELECT | |
363 | CTL_STORE, CTL_REG); | 361 | CTL_STORE, CTL_REG); |
364 | timeout = 100; | 362 | timeout = 100; |
365 | while ((SMC_inw (dev, CTL_REG) & CTL_STORE) && --timeout) | 363 | while ((SMC_inw (dev, CTL_REG) & CTL_STORE) && --timeout) |
366 | udelay (100); | 364 | udelay (100); |
367 | if (timeout == 0) { | 365 | if (timeout == 0) { |
368 | printf ("Timeout Writing EEPROM register %02x\n", reg); | 366 | printf ("Timeout Writing EEPROM register %02x\n", reg); |
369 | return 0; | 367 | return 0; |
370 | } | 368 | } |
371 | 369 | ||
372 | return 1; | 370 | return 1; |
373 | 371 | ||
374 | } | 372 | } |
375 | 373 | ||
376 | void dump_reg (struct eth_device *dev) | 374 | void dump_reg (struct eth_device *dev) |
377 | { | 375 | { |
378 | int i, j; | 376 | int i, j; |
379 | 377 | ||
380 | printf (" "); | 378 | printf (" "); |
381 | for (j = 0; j < 4; j++) { | 379 | for (j = 0; j < 4; j++) { |
382 | printf ("Bank%i ", j); | 380 | printf ("Bank%i ", j); |
383 | } | 381 | } |
384 | printf ("\n"); | 382 | printf ("\n"); |
385 | for (i = 0; i < 0xF; i += 2) { | 383 | for (i = 0; i < 0xF; i += 2) { |
386 | printf ("%02x ", i); | 384 | printf ("%02x ", i); |
387 | for (j = 0; j < 4; j++) { | 385 | for (j = 0; j < 4; j++) { |
388 | SMC_SELECT_BANK (dev, j); | 386 | SMC_SELECT_BANK (dev, j); |
389 | printf ("%04x ", SMC_inw (dev, i)); | 387 | printf ("%04x ", SMC_inw (dev, i)); |
390 | } | 388 | } |
391 | printf ("\n"); | 389 | printf ("\n"); |
392 | } | 390 | } |
393 | } | 391 | } |
394 | |||
395 | #else | ||
396 | |||
397 | int smc91111_eeprom (int argc, char *argv[]) | ||
398 | { | ||
399 | printf("Not supported for this board\n"); | ||
400 | return 1; | ||
401 | } | ||
402 | |||
403 | #endif | ||
404 | 392 |