mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>,
	Appana Durga Kedareswara Rao <appana.durga.rao@xilinx.com>
Cc: "robh+dt@kernel.org" <robh+dt@kernel.org>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	Michal Simek <michals@xilinx.com>,
	Soren Brinkmann <sorenb@xilinx.com>,
	"nicolas.ferre@atmel.com" <nicolas.ferre@atmel.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Punnaiah Choudary Kalluri <punnaia@xilinx.com>
Subject: Re: [RFC PATCH v2 1/4] Documentation: DT: net: Add Xilinx gmiitorgmii converter device tree binding documentation
Date: Wed, 3 Aug 2016 20:42:08 -0700	[thread overview]
Message-ID: <971c966a-5335-310b-0a1a-3f1b7ee2f841@gmail.com> (raw)
In-Reply-To: <20160727080526.GH11538@lunn.ch>

On 27/07/2016 01:05, Andrew Lunn wrote:
> Hi Appana
> 
> Here is roughly what i was thinking:
> 
> struct priv {
>        phy_device *master;
>        phy_device *slave;
>        struct phy_driver *slave_drv;
> };
> 
> phy_status_clone(phy_device *master, phy_device *slave)
> {
> 	master->speed = slave->speed;
> 	master->duplex = slave->duplex;
> 	master->pause = slave->pause;
> }
> 
> read_status(struct phy_device *phydev)
> {
> 	struct priv *priv = phydev->priv;
> 
> 	/* Get the status from the slave, and duplicate in into the
> 	 * master */
> 	 slave_drv->read_status(priv->slave);
> 	 phy_status_clone(priv->master, priv->slave);
> 
> 	 /* Update the gmiitorgmii with the current link parameters */
> 	 update_link(master);
> }
> 
> config_init(struct phy_device *phydev)
> {
> 	struct priv *priv = phydev->priv;
> 
> 	/* Configure the slave, and duplicate in into the master */
> 	slave_drv->config_init(priv->slave);
> 	phy_status_clone(priv->master, priv->slave);
> }
> 
> struct phy_driver master_drv = {
>        .read_status = read_status,
>        .config_init = config_init,
>        .soft_reset  = ...
>        .suspend = ...
> };
> 
> probe(mdio_device *mdio)
> {
> 	struct priv *priv = devm_alloc();
> 
> 	/* Use the phy-handle property to find the slave phy */
> 	node_phy = of_parse_phandle(mdio->of_node, "phy", 0);
> 	priv->slave = of_phy_find_device(node_phy);
> 
> 	/* Create the master phy on the control address. Use the phy
> 	   ID from the slave. */
> 	priv->master = phy_device_create(mdio->bus, mdio->addr,
> 	  				 phy->slave->phy_id,
> 					 phy->slave->is_c45,
> 					 phy->slave->c45_ids);
> 
> 	slave_dev_drv = phydev->mdio.dev.driver;
> 	priv->slave_drv = to_phy_driver(slave_dev_drv);
> 	priv->master->mdio.dev.driver = master_drv;

The key here is really that except for the phy_driver::read_status
callback, we want to defer every operation to the slave (full MDIO
register range compatible) PHY.

> }
> 
> It would however be nice to only have one phydev structure, so you are
> not copying status and settings backwards and forwards from one to the
> other all the time, and need a wrapper for every function in
> phy_driver. Studying the structures a bit, that might be possible. You
> would then only need to wrap the read_status(), so that when the link
> speed/duplex changes, you can configure the converter as appropriate.

Agreed.
--
Florian

  reply	other threads:[~2016-08-04  3:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-04  9:04 [RFC PATCH v2 0/4] net: ethernet: Add support for gmii2rgmii converter Kedareswara rao Appana
2016-07-04  9:04 ` [RFC PATCH v2 1/4] Documentation: DT: net: Add Xilinx gmiitorgmii converter device tree binding documentation Kedareswara rao Appana
2016-07-04 14:04   ` Andrew Lunn
2016-07-06 14:12     ` Punnaiah Choudary Kalluri
2016-07-06 14:21       ` Andrew Lunn
2016-07-06 14:51         ` Punnaiah Choudary Kalluri
2016-07-26 15:09           ` Appana Durga Kedareswara Rao
2016-07-27  8:05             ` Andrew Lunn
2016-08-04  3:42               ` Florian Fainelli [this message]
2016-08-04 10:34                 ` Appana Durga Kedareswara Rao
2016-07-04  9:04 ` [RFC PATCH v2 2/4] net: ethernet: xilinx: Add gmii2rgmii converter support Kedareswara rao Appana
2016-07-04  9:54   ` Nicolas Ferre
2016-07-04 11:47     ` Appana Durga Kedareswara Rao
2016-07-04 12:31       ` Nicolas Ferre
2016-07-04 12:36         ` Appana Durga Kedareswara Rao
2016-07-04  9:04 ` [RFC PATCH v2 3/4] Documentation: DT: net: Update binding doc for gmiitorgmii conveter Kedareswara rao Appana
2016-07-04  9:04 ` [RFC PATCH v2 4/4] net: macb: Add gmii2rgmii phy converter support Kedareswara rao Appana

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=971c966a-5335-310b-0a1a-3f1b7ee2f841@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=appana.durga.rao@xilinx.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=michals@xilinx.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@atmel.com \
    --cc=punnaia@xilinx.com \
    --cc=robh+dt@kernel.org \
    --cc=sorenb@xilinx.com \
    /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

all inboxes | Powered by JetHome®