Commit c58ea6cb8c01b4e43e414cdc26bc29ad52284f21

Authored by Bin Meng
Committed by Simon Glass
1 parent a7c3d5e2a9

net: Update README.drivers.eth to mention latest APIs

README.drivers.eth still refers to the deprecated miiphy_register().
Update the doc to mention new APIs mdio_alloc() and mdio_register().

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>

Showing 1 changed file with 35 additions and 16 deletions Side-by-side Diff

doc/README.drivers.eth
... ... @@ -43,15 +43,16 @@
43 43 {
44 44 struct ape_priv *priv;
45 45 struct eth_device *dev;
  46 + struct mii_dev *bus;
46 47  
47 48 priv = malloc(sizeof(*priv));
48 49 if (priv == NULL)
49   - return 1;
  50 + return -ENOMEM;
50 51  
51 52 dev = malloc(sizeof(*dev));
52 53 if (dev == NULL) {
53 54 free(priv);
54   - return 1;
  55 + return -ENOMEM;
55 56 }
56 57  
57 58 /* setup whatever private state you need */
... ... @@ -59,7 +60,8 @@
59 60 memset(dev, 0, sizeof(*dev));
60 61 sprintf(dev->name, "APE");
61 62  
62   - /* if your device has dedicated hardware storage for the
  63 + /*
  64 + * if your device has dedicated hardware storage for the
63 65 * MAC, read it and initialize dev->enetaddr with it
64 66 */
65 67 ape_mac_read(dev->enetaddr);
... ... @@ -74,8 +76,17 @@
74 76  
75 77 eth_register(dev);
76 78  
77   -#ifdef CONFIG_CMD_MII)
78   - miiphy_register(dev->name, ape_mii_read, ape_mii_write);
  79 +#ifdef CONFIG_PHYLIB
  80 + bus = mdio_alloc();
  81 + if (!bus) {
  82 + free(priv);
  83 + free(dev);
  84 + return -ENOMEM;
  85 + }
  86 +
  87 + bus->read = ape_mii_read;
  88 + bus->write = ape_mii_write;
  89 + mdio_register(bus);
79 90 #endif
80 91  
81 92 return 1;
82 93  
83 94  
84 95  
85 96  
... ... @@ -166,26 +177,34 @@
166 177 eth_halt()
167 178 dev->halt()
168 179  
169   ------------------------------
170   - CONFIG_MII / CONFIG_CMD_MII
171   ------------------------------
  180 +--------------------------------
  181 + CONFIG_PHYLIB / CONFIG_CMD_MII
  182 +--------------------------------
172 183  
173 184 If your device supports banging arbitrary values on the MII bus (pretty much
174 185 every device does), you should add support for the mii command. Doing so is
175 186 fairly trivial and makes debugging mii issues a lot easier at runtime.
176 187  
177 188 After you have called eth_register() in your driver's register function, add
178   -a call to miiphy_register() like so:
179   -#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
180   - miiphy_register(dev->name, mii_read, mii_write);
181   -#endif
  189 +a call to mdio_alloc() and mdio_register() like so:
  190 + bus = mdio_alloc();
  191 + if (!bus) {
  192 + free(priv);
  193 + free(dev);
  194 + return -ENOMEM;
  195 + }
182 196  
  197 + bus->read = ape_mii_read;
  198 + bus->write = ape_mii_write;
  199 + mdio_register(bus);
  200 +
183 201 And then define the mii_read and mii_write functions if you haven't already.
184 202 Their syntax is straightforward:
185   - int mii_read(char *devname, uchar addr, uchar reg, ushort *val);
186   - int mii_write(char *devname, uchar addr, uchar reg, ushort val);
  203 + int mii_read(struct mii_dev *bus, int addr, int devad, int reg);
  204 + int mii_write(struct mii_dev *bus, int addr, int devad, int reg,
  205 + u16 val);
187 206  
188 207 The read function should read the register 'reg' from the phy at address 'addr'
189   -and store the result in the pointer 'val'. The implementation for the write
190   -function should logically follow.
  208 +and return the result to its caller. The implementation for the write function
  209 +should logically follow.