From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 06/10] net: orion-gbe: use transparent-to-driver of mdio functions
Date: Wed, 21 May 2014 14:18:56 +0200 [thread overview]
Message-ID: <1400674740-6467-7-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1400674740-6467-1-git-send-email-s.hauer@pengutronix.de>
barebox can transparently handle phys specified in the devicetree.
Use this functionality in the orion-gbe driver. This requires:
- add a device to the orion-gbe ports. This has the port device_node
attached and is set as the parent of the ethernet device so that
the ethernet code finds the correct device_node
- In the mdio-mvebu driver attach the device_node of the mdio device
to the miibus device so that the phy code finds the correct node
- call phy_device_connect instead of of_phy_device_connect.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/net/orion-gbe.c | 62 ++++++++++++++++++++++++--------------------
drivers/net/phy/mdio-mvebu.c | 1 +
2 files changed, 35 insertions(+), 28 deletions(-)
diff --git a/drivers/net/orion-gbe.c b/drivers/net/orion-gbe.c
index 00f5e54..85db17c 100644
--- a/drivers/net/orion-gbe.c
+++ b/drivers/net/orion-gbe.c
@@ -56,6 +56,7 @@ struct txdesc {
};
struct port_priv {
+ struct device_d dev;
struct eth_device edev;
void __iomem *regs;
struct device_node *np;
@@ -64,6 +65,7 @@ struct port_priv {
struct rxdesc *rxdesc;
struct rxdesc *current_rxdesc;
u8 *rxbuf;
+ phy_interface_t intf;
};
struct orion_gbe {
@@ -351,16 +353,6 @@ static int port_get_ethaddr(struct eth_device *edev, unsigned char *mac)
return 0;
}
-static int port_open(struct eth_device *edev)
-{
- struct port_priv *port = edev->priv;
-
- /* enable receive queue */
- writel(BIT(URXQ), port->regs + PORT_RQC);
-
- return 0;
-}
-
static void port_adjust_link(struct eth_device *edev)
{
struct port_priv *port = edev->priv;
@@ -389,10 +381,25 @@ static void port_adjust_link(struct eth_device *edev)
writel(reg, port->regs + PORT_SC0);
}
+static int port_open(struct eth_device *edev)
+{
+ struct port_priv *port = edev->priv;
+ int ret;
+
+ ret = phy_device_connect(&port->edev, NULL, -1, port_adjust_link, 0,
+ port->intf);
+ if (ret)
+ return ret;
+
+ /* enable receive queue */
+ writel(BIT(URXQ), port->regs + PORT_RQC);
+
+ return 0;
+}
+
static int port_probe(struct device_d *parent, struct port_priv *port)
{
- struct device_node *phynp;
- phy_interface_t intf = PHY_INTERFACE_MODE_RGMII;
+ struct device_d *dev = &port->dev;
u32 reg;
int ret;
@@ -400,12 +407,11 @@ static int port_probe(struct device_d *parent, struct port_priv *port)
if (of_property_read_u32(port->np, "reg", &port->portno))
dev_warn(parent, "port node is missing reg property\n");
- phynp = of_parse_phandle(port->np, "phy-handle", 0);
- if (phynp) {
- ret = of_get_phy_mode(port->np);
- if (ret > 0)
- intf = ret;
- }
+ ret = of_get_phy_mode(port->np);
+ if (ret > 0)
+ port->intf = ret;
+ else
+ port->intf = PHY_INTERFACE_MODE_RGMII;
port->regs = dev_get_mem_region(parent, 0) + PORTn_REGS(port->portno);
@@ -440,10 +446,18 @@ static int port_probe(struct device_d *parent, struct port_priv *port)
reg = SC1_RESERVED;
reg |= DEFAULT_COL_LIMIT | COL_ON_BACKPRESS | INBAND_ANEG_BYPASS;
- if (intf == PHY_INTERFACE_MODE_RGMII)
+ if (port->intf == PHY_INTERFACE_MODE_RGMII)
reg |= RGMII_ENABLE;
writel(reg, port->regs + PORT_SC1);
+ sprintf(dev->name, "orion-gbe-port");
+ dev->id = port->portno;
+ dev->parent = parent;
+ dev->device_node = port->np;
+ ret = register_device(dev);
+ if (ret)
+ return ret;
+
/* register eth device */
port->edev.priv = port;
port->edev.open = port_open;
@@ -452,20 +466,12 @@ static int port_probe(struct device_d *parent, struct port_priv *port)
port->edev.halt = port_halt;
port->edev.set_ethaddr = port_set_ethaddr;
port->edev.get_ethaddr = port_get_ethaddr;
- port->edev.parent = parent;
+ port->edev.parent = dev;
ret = eth_register(&port->edev);
if (ret)
return ret;
- /* attach phy device */
- if (phynp) {
- ret = of_phy_device_connect(&port->edev, phynp,
- port_adjust_link, 0, intf);
- if (ret)
- return ret;
- }
-
return 0;
}
diff --git a/drivers/net/phy/mdio-mvebu.c b/drivers/net/phy/mdio-mvebu.c
index f8b492a..3dcf644 100644
--- a/drivers/net/phy/mdio-mvebu.c
+++ b/drivers/net/phy/mdio-mvebu.c
@@ -120,6 +120,7 @@ static int mvebu_mdio_probe(struct device_d *dev)
if (!IS_ERR(priv->clk))
clk_enable(priv->clk);
+ priv->miibus.dev.device_node = dev->device_node;
priv->miibus.priv = priv;
priv->miibus.parent = dev;
priv->miibus.read = mvebu_mdio_read;
--
2.0.0.rc0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-05-21 12:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-21 12:18 [PATCH] devicetree support for ethernet phys Sascha Hauer
2014-05-21 12:18 ` [PATCH 01/10] net: phy: factor out phy_device_attach function Sascha Hauer
2014-05-21 12:18 ` [PATCH 02/10] net: phy: move setting of phy_map to phy_register_device Sascha Hauer
2014-05-21 12:18 ` [PATCH 03/10] net: phy: register phys specified in devicetree Sascha Hauer
2014-05-21 12:18 ` [PATCH 04/10] net: phy: Support finding a phy in the devicetree Sascha Hauer
2014-05-21 12:18 ` [PATCH 05/10] net: phy: Support limiting phy speed " Sascha Hauer
2014-05-21 12:28 ` Sebastian Hesselbarth
2014-05-21 12:18 ` Sascha Hauer [this message]
2014-05-21 12:29 ` [PATCH 06/10] net: orion-gbe: use transparent-to-driver of mdio functions Sebastian Hesselbarth
2014-05-22 20:09 ` Sebastian Hesselbarth
2014-08-02 17:44 ` Ezequiel Garcia
2014-08-04 18:42 ` Sascha Hauer
2014-05-21 12:18 ` [PATCH 07/10] net: phy: remove now unused of_phy_device_connect Sascha Hauer
2014-05-21 12:18 ` [PATCH 08/10] net: phy: genphy: always write MII_CTRL1000 when available Sascha Hauer
2014-05-21 12:18 ` [PATCH 09/10] net: phy: genphy: Make it work with of_set_phy_supported Sascha Hauer
2014-05-21 12:19 ` [PATCH 10/10] net: fec_imx: Add devicetree support for mdio bus Sascha Hauer
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=1400674740-6467-7-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@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