All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/4] net: Update README.drivers.eth to mention latest APIs
Date: Fri, 20 Mar 2015 17:12:19 +0800	[thread overview]
Message-ID: <1426842741-6033-3-git-send-email-bmeng.cn@gmail.com> (raw)
In-Reply-To: <1426842741-6033-1-git-send-email-bmeng.cn@gmail.com>

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>
---

 doc/README.drivers.eth | 51 ++++++++++++++++++++++++++++++++++----------------
 1 file changed, 35 insertions(+), 16 deletions(-)

diff --git a/doc/README.drivers.eth b/doc/README.drivers.eth
index eb83038..42af442 100644
--- a/doc/README.drivers.eth
+++ b/doc/README.drivers.eth
@@ -43,15 +43,16 @@ int ape_register(bd_t *bis, int iobase)
 {
 	struct ape_priv *priv;
 	struct eth_device *dev;
+	struct mii_dev *bus;
 
 	priv = malloc(sizeof(*priv));
 	if (priv == NULL)
-		return 1;
+		return -ENOMEM;
 
 	dev = malloc(sizeof(*dev));
 	if (dev == NULL) {
 		free(priv);
-		return 1;
+		return -ENOMEM;
 	}
 
 	/* setup whatever private state you need */
@@ -59,7 +60,8 @@ int ape_register(bd_t *bis, int iobase)
 	memset(dev, 0, sizeof(*dev));
 	sprintf(dev->name, "APE");
 
-	/* if your device has dedicated hardware storage for the
+	/*
+	 * if your device has dedicated hardware storage for the
 	 * MAC, read it and initialize dev->enetaddr with it
 	 */
 	ape_mac_read(dev->enetaddr);
@@ -74,8 +76,17 @@ int ape_register(bd_t *bis, int iobase)
 
 	eth_register(dev);
 
-#ifdef CONFIG_CMD_MII)
-	miiphy_register(dev->name, ape_mii_read, ape_mii_write);
+#ifdef CONFIG_PHYLIB
+	bus = mdio_alloc();
+	if (!bus) {
+		free(priv);
+		free(dev);
+		return -ENOMEM;
+	}
+
+	bus->read = ape_mii_read;
+	bus->write = ape_mii_write;
+	mdio_register(bus);
 #endif
 
 	return 1;
@@ -166,25 +177,33 @@ some net operation (ping / tftp / whatever...)
 	eth_halt()
 		dev->halt()
 
------------------------------
- CONFIG_MII / CONFIG_CMD_MII
------------------------------
+--------------------------------
+ CONFIG_PHYLIB / CONFIG_CMD_MII
+--------------------------------
 
 If your device supports banging arbitrary values on the MII bus (pretty much
 every device does), you should add support for the mii command.  Doing so is
 fairly trivial and makes debugging mii issues a lot easier at runtime.
 
 After you have called eth_register() in your driver's register function, add
-a call to miiphy_register() like so:
-#if defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
-	miiphy_register(dev->name, mii_read, mii_write);
-#endif
+a call to mdio_alloc() and mdio_register() like so:
+	bus = mdio_alloc();
+	if (!bus) {
+		free(priv);
+		free(dev);
+		return -ENOMEM;
+	}
+
+	bus->read = ape_mii_read;
+	bus->write = ape_mii_write;
+	mdio_register(bus);
 
 And then define the mii_read and mii_write functions if you haven't already.
 Their syntax is straightforward:
-	int mii_read(char *devname, uchar addr, uchar reg, ushort *val);
-	int mii_write(char *devname, uchar addr, uchar reg, ushort val);
+	int mii_read(struct mii_dev *bus, int addr, int devad, int reg);
+	int mii_write(struct mii_dev *bus, int addr, int devad, int reg,
+		      u16 val);
 
 The read function should read the register 'reg' from the phy at address 'addr'
-and store the result in the pointer 'val'.  The implementation for the write
-function should logically follow.
+and return the result to its caller.  The implementation for the write function
+should logically follow.
-- 
1.8.2.1

  parent reply	other threads:[~2015-03-20  9:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-20  9:12 [U-Boot] [PATCH 0/4] x86: Add Intel Topcliff PCH Gigabit Ethernet support Bin Meng
2015-03-20  9:12 ` [U-Boot] [PATCH 1/4] net: Add ethernet FCS length macro in net.h Bin Meng
2015-03-20 19:18   ` Joe Hershberger
2015-03-25 22:34     ` Simon Glass
2015-03-20  9:12 ` Bin Meng [this message]
2015-03-20 19:18   ` [U-Boot] [PATCH 2/4] net: Update README.drivers.eth to mention latest APIs Joe Hershberger
2015-03-25 22:34     ` Simon Glass
2015-03-20  9:12 ` [U-Boot] [PATCH 3/4] net: Add Intel Topcliff GMAC driver Bin Meng
2015-03-20 19:18   ` Joe Hershberger
2015-03-23 21:57     ` Simon Glass
2015-03-24  1:24       ` Bin Meng
2015-03-24  4:18         ` Simon Glass
2015-03-24  4:54           ` Bin Meng
2015-03-25 22:34             ` Simon Glass
2015-03-20  9:12 ` [U-Boot] [PATCH 4/4] x86: crownbay: Enable Intel Topcliff GMAC support Bin Meng
2015-03-20 19:18   ` Joe Hershberger
2015-03-25 22:35     ` Simon Glass
2015-03-20 19:18 ` [U-Boot] [PATCH 0/4] x86: Add Intel Topcliff PCH Gigabit Ethernet support Joe Hershberger
2015-03-20 19:58   ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1426842741-6033-3-git-send-email-bmeng.cn@gmail.com \
    --to=bmeng.cn@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.