From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933154AbcHDDmP (ORCPT ); Wed, 3 Aug 2016 23:42:15 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34676 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751871AbcHDDmN (ORCPT ); Wed, 3 Aug 2016 23:42:13 -0400 Subject: Re: [RFC PATCH v2 1/4] Documentation: DT: net: Add Xilinx gmiitorgmii converter device tree binding documentation To: Andrew Lunn , Appana Durga Kedareswara Rao References: <1467623084-15471-1-git-send-email-appanad@xilinx.com> <1467623084-15471-2-git-send-email-appanad@xilinx.com> <20160704140458.GC3282@lunn.ch> <03CA77BA8AF6F1469AEDFBDA1322A7B74A193913@XAP-PVEXMBX02.xlnx.xilinx.com> <20160706142121.GI19800@lunn.ch> <03CA77BA8AF6F1469AEDFBDA1322A7B74A19393B@XAP-PVEXMBX02.xlnx.xilinx.com> <20160727080526.GH11538@lunn.ch> Cc: "robh+dt@kernel.org" , "mark.rutland@arm.com" , Michal Simek , Soren Brinkmann , "nicolas.ferre@atmel.com" , "netdev@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Punnaiah Choudary Kalluri From: Florian Fainelli Message-ID: <971c966a-5335-310b-0a1a-3f1b7ee2f841@gmail.com> Date: Wed, 3 Aug 2016 20:42:08 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160727080526.GH11538@lunn.ch> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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