From: Jan Luebbe <jlu@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH v2 3/3] davinci_emac: get rid of mdio wrapper functions
Date: Fri, 28 Sep 2012 17:00:50 +0200 [thread overview]
Message-ID: <1348844450-26842-4-git-send-email-jlu@pengutronix.de> (raw)
In-Reply-To: <1348844450-26842-1-git-send-email-jlu@pengutronix.de>
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
---
drivers/net/davinci_emac.c | 51 +++++++++++++++++---------------------------
1 file changed, 19 insertions(+), 32 deletions(-)
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 52786e0..997dc7b 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -122,64 +122,51 @@ static void davinci_eth_mdio_enable(struct davinci_emac_priv *priv)
while (readl(priv->adap_mdio + EMAC_MDIO_CONTROL) & MDIO_CONTROL_IDLE);
}
-/* Read a PHY register via MDIO inteface. Returns 1 on success, 0 otherwise */
-static int davinci_eth_phy_read(struct davinci_emac_priv *priv, uint8_t phy_addr, uint8_t reg_num, uint16_t *data)
+static int davinci_miibus_read(struct mii_bus *bus, int addr, int reg)
{
- int tmp;
+ struct davinci_emac_priv *priv = bus->priv;
+ uint16_t value;
+ int tmp;
while (readl(priv->adap_mdio + EMAC_MDIO_USERACCESS0) & MDIO_USERACCESS0_GO);
writel(MDIO_USERACCESS0_GO |
MDIO_USERACCESS0_WRITE_READ |
- ((reg_num & 0x1f) << 21) |
- ((phy_addr & 0x1f) << 16),
+ ((reg & 0x1f) << 21) |
+ ((addr & 0x1f) << 16),
priv->adap_mdio + EMAC_MDIO_USERACCESS0);
/* Wait for command to complete */
while ((tmp = readl(priv->adap_mdio + EMAC_MDIO_USERACCESS0)) & MDIO_USERACCESS0_GO);
if (tmp & MDIO_USERACCESS0_ACK) {
- *data = tmp & 0xffff;
- dev_dbg(priv->dev, "emac_phy_read: addr=0x%02x reg=0x%02x data=0x%04x\n",
- phy_addr, reg_num, *data);
- return 1;
+ value = tmp & 0xffff;
+ dev_dbg(priv->dev, "davinci_miibus_read: addr=0x%02x reg=0x%02x value=0x%04x\n",
+ addr, reg, value);
+ return value;
}
- *data = -1;
- return 0;
+ return -1;
}
-/* Write to a PHY register via MDIO inteface. Blocks until operation is complete. */
-static int davinci_eth_phy_write(struct davinci_emac_priv *priv, uint8_t phy_addr, uint8_t reg_num, uint16_t data)
+static int davinci_miibus_write(struct mii_bus *bus, int addr, int reg, u16 value)
{
+ struct davinci_emac_priv *priv = bus->priv;
while (readl(priv->adap_mdio + EMAC_MDIO_USERACCESS0) & MDIO_USERACCESS0_GO);
- dev_dbg(priv->dev, "emac_phy_write: addr=0x%02x reg=0x%02x data=0x%04x\n",
- phy_addr, reg_num, data);
+ dev_dbg(priv->dev, "davinci_miibus_write: addr=0x%02x reg=0x%02x value=0x%04x\n",
+ addr, reg, value);
writel(MDIO_USERACCESS0_GO |
MDIO_USERACCESS0_WRITE_WRITE |
- ((reg_num & 0x1f) << 21) |
- ((phy_addr & 0x1f) << 16) |
- (data & 0xffff),
+ ((reg & 0x1f) << 21) |
+ ((addr & 0x1f) << 16) |
+ (value & 0xffff),
priv->adap_mdio + EMAC_MDIO_USERACCESS0);
/* Wait for command to complete */
while (readl(priv->adap_mdio + EMAC_MDIO_USERACCESS0) & MDIO_USERACCESS0_GO);
- return 1;
-}
-
-static int davinci_miibus_read(struct mii_bus *bus, int addr, int reg)
-{
- struct davinci_emac_priv *priv = bus->priv;
- uint16_t value = 0;
- return davinci_eth_phy_read(priv, addr, reg, &value) ? value : -1;
-}
-
-static int davinci_miibus_write(struct mii_bus *bus, int addr, int reg, u16 value)
-{
- struct davinci_emac_priv *priv = (struct davinci_emac_priv *)bus->priv;
- return davinci_eth_phy_write(priv, addr, reg, value) ? 0 : -1;
+ return 0;
}
static int davinci_emac_get_ethaddr(struct eth_device *edev, unsigned char *adr)
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2012-09-28 15:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-28 15:00 davinci_emac: follow phylib changes Jan Luebbe
2012-09-28 15:00 ` [PATCH v2 1/3] davinci_emac: return 0 on successful transmit Jan Luebbe
2012-09-28 15:00 ` [PATCH v2 2/3] davinci_emac: adjust to new phylib framework Jan Luebbe
2012-09-28 15:33 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-28 15:00 ` Jan Luebbe [this message]
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=1348844450-26842-4-git-send-email-jlu@pengutronix.de \
--to=jlu@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox