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 <command.h>
26#include <dm9000.h>
27
28static int do_read_dm9000_eeprom ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
29 unsigned int i;
30 u8 data[2];
31
32 for (i=0; i < 0x40; i++) {
33 if (!(i % 0x10))
34 printf("\n%08x:", i);
35 dm9000_read_srom_word(i, data);
36 printf(" %02x%02x", data[1], data[0]);
37 }
38 printf ("\n");
39 return (0);
40}
41
42static int do_write_dm9000_eeprom ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
43 int offset,value;
44
45 if (argc < 4)
46 return cmd_usage(cmdtp);
47
48 offset=simple_strtoul(argv[2],NULL,16);
49 value=simple_strtoul(argv[3],NULL,16);
50 if (offset > 0x40) {
51 printf("Wrong offset : 0x%x\n",offset);
52 return cmd_usage(cmdtp);
53 }
54 dm9000_write_srom_word(offset, value);
55 return (0);
56}
57
58int do_dm9000_eeprom ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) {
59 if (argc < 2)
60 return cmd_usage(cmdtp);
61
62 if (strcmp (argv[1],"read") == 0)
63 return (do_read_dm9000_eeprom(cmdtp,flag,argc,argv));
64 else if (strcmp (argv[1],"write") == 0)
65 return (do_write_dm9000_eeprom(cmdtp,flag,argc,argv));
66 else
67 return cmd_usage(cmdtp);
68}
69
70U_BOOT_CMD(
71 dm9000ee,4,1,do_dm9000_eeprom,
72 "Read/Write eeprom connected to Ethernet Controller",
73 "\ndm9000ee write <word offset> <value> \n"
74 "\tdm9000ee read \n"
75 "\tword:\t\t00-02 : MAC Address\n"
76 "\t\t\t03-07 : DM9000 Configuration\n"
77 "\t\t\t08-63 : User data"
78);
79