3 * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com
5 * See file CREDITS for list of people who contributed to this
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
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
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
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
32 #if (CONFIG_COMMANDS & CFG_CMD_MII)
35 * Display values from last command.
46 * mii read {addr} {reg}
47 * mii write {addr} {reg} {data}
50 int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
53 unsigned char addr, reg;
57 #if defined(CONFIG_8xx) || defined(CONFIG_MCF52x2)
62 * We use the last specified parameters, unless new ones are
70 if ((flag & CMD_FLAG_REPEAT) == 0) {
73 addr = simple_strtoul (argv[2], NULL, 16);
75 reg = simple_strtoul (argv[3], NULL, 16);
77 data = simple_strtoul (argv[4], NULL, 16);
81 * check info/read/write.
84 unsigned char j, start, end;
90 * Look for any and all PHYs. Valid addresses are 0..31.
93 start = addr; end = addr + 1;
98 for (j = start; j < end; j++) {
99 if (miiphy_info (j, &oui, &model, &rev) == 0) {
100 printf ("PHY 0x%02X: "
106 miiphy_speed (j) == _100BASET ? 100 : 10,
107 miiphy_duplex (j) == FULL ? "FDX" : "HDX");
110 } else if (op == 'r') {
111 if (miiphy_read (addr, reg, &data) != 0) {
112 printf ("Error reading from the PHY\n");
115 printf ("%04X\n", data & 0x0000FFFF);
116 } else if (op == 'w') {
117 if (miiphy_write (addr, reg, data) != 0) {
118 printf ("Error writing to the PHY\n");
122 printf ("Usage:\n%s\n", cmdtp->usage);
127 * Save the parameters for repeats.
136 /***************************************************/
140 "mii - MII utility commands\n",
141 "info <addr> - display MII PHY info\n"
142 "mii read <addr> <reg> - read MII PHY <addr> register <reg>\n"
143 "mii write <addr> <reg> <data> - write MII PHY <addr> register <reg>\n"
147 #endif /* CFG_CMD_MII */