]>
git.ipfire.org Git - people/ms/u-boot.git/blob - common/cmd_mii.c
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,
33 #if (CONFIG_COMMANDS & CFG_CMD_MII)
36 * Display values from last command.
47 * mii read {addr} {reg}
48 * mii write {addr} {reg} {data}
51 int do_mii (cmd_tbl_t
* cmdtp
, int flag
, int argc
, char *argv
[])
54 unsigned char addr
, reg
;
63 * We use the last specified parameters, unless new ones are
71 if ((flag
& CMD_FLAG_REPEAT
) == 0) {
74 addr
= simple_strtoul (argv
[2], NULL
, 16);
76 reg
= simple_strtoul (argv
[3], NULL
, 16);
78 data
= simple_strtoul (argv
[4], NULL
, 16);
82 * check info/read/write.
91 * Look for any and all PHYs. Valid addresses are 0..31.
93 for (j
= 0; j
< 32; j
++) {
94 if (miiphy_info (j
, &oui
, &model
, &rev
) == 0) {
95 printf ("PHY 0x%02X: "
101 miiphy_speed (j
) == _100BASET
? 100 : 10,
102 miiphy_duplex (j
) == FULL
? "FDX" : "HDX");
105 } else if (op
== 'r') {
106 if (miiphy_read (addr
, reg
, &data
) != 0) {
107 printf ("Error reading from the PHY\n");
110 printf ("%04X\n", data
& 0x0000FFFF);
111 } else if (op
== 'w') {
112 if (miiphy_write (addr
, reg
, data
) != 0) {
113 printf ("Error writing to the PHY\n");
117 printf ("Usage:\n%s\n", cmdtp
->usage
);
122 * Save the parameters for repeats.
131 #endif /* CFG_CMD_MII */