From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> To: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org, devicetree@vger.kernel.org Cc: Florian Fainelli <florian@openwrt.org>, Tawfik Bayouk <tawfik@marvell.com>, Nadav Haklai <nadavh@marvell.com>, Lior Amsalem <alior@marvell.com>, Gregory Clement <gregory.clement@free-electrons.com>, Ezequiel Garcia <ezequiel.garcia@free-electrons.com>, linux-arm-kernel@lists.infradead.org, Grant Likely <grant.likely@secretlab.ca>, Rob Herring <robh+dt@kernel.org>, Mark Rutland <mark.rutland@arm.com>, Sascha Hauer <s.hauer@pengutronix.de>, Christian Gmeiner <christian.gmeiner@gmail.com>, Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Subject: [PATCHv4 1/5] net: phy: decouple PHY id and PHY address in fixed PHY driver Date: Fri, 16 May 2014 16:14:03 +0200 [thread overview] Message-ID: <1400249647-4643-2-git-send-email-thomas.petazzoni@free-electrons.com> (raw) In-Reply-To: <1400249647-4643-1-git-send-email-thomas.petazzoni@free-electrons.com> Until now, the fixed_phy_add() function was taking as argument 'phy_id', which was used both as the PHY address on the fake fixed MDIO bus, and as the PHY id, as available in the MII_PHYSID1 and MII_PHYSID2 registers. However, those two informations are completely unrelated. This patch decouples them. The PHY id of fixed PHYs is hardcoded to be 0x0. Ideally, a really reserved value would be nicer, but there doesn't seem to be an easy of making sure a dummy value can be assigned to the Linux kernel for such usage. The PHY address remains passed by the caller of phy_fixed_add(). Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> --- drivers/net/phy/fixed.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c index ba55adf..e41546d 100644 --- a/drivers/net/phy/fixed.c +++ b/drivers/net/phy/fixed.c @@ -31,7 +31,7 @@ struct fixed_mdio_bus { }; struct fixed_phy { - int id; + int addr; u16 regs[MII_REGS_NUM]; struct phy_device *phydev; struct fixed_phy_status status; @@ -104,8 +104,8 @@ static int fixed_phy_update_regs(struct fixed_phy *fp) if (fp->status.asym_pause) lpa |= LPA_PAUSE_ASYM; - fp->regs[MII_PHYSID1] = fp->id >> 16; - fp->regs[MII_PHYSID2] = fp->id; + fp->regs[MII_PHYSID1] = 0; + fp->regs[MII_PHYSID2] = 0; fp->regs[MII_BMSR] = bmsr; fp->regs[MII_BMCR] = bmcr; @@ -115,7 +115,7 @@ static int fixed_phy_update_regs(struct fixed_phy *fp) return 0; } -static int fixed_mdio_read(struct mii_bus *bus, int phy_id, int reg_num) +static int fixed_mdio_read(struct mii_bus *bus, int phy_addr, int reg_num) { struct fixed_mdio_bus *fmb = bus->priv; struct fixed_phy *fp; @@ -124,7 +124,7 @@ static int fixed_mdio_read(struct mii_bus *bus, int phy_id, int reg_num) return -1; list_for_each_entry(fp, &fmb->phys, node) { - if (fp->id == phy_id) { + if (fp->addr == phy_addr) { /* Issue callback if user registered it. */ if (fp->link_update) { fp->link_update(fp->phydev->attached_dev, @@ -138,7 +138,7 @@ static int fixed_mdio_read(struct mii_bus *bus, int phy_id, int reg_num) return 0xFFFF; } -static int fixed_mdio_write(struct mii_bus *bus, int phy_id, int reg_num, +static int fixed_mdio_write(struct mii_bus *bus, int phy_addr, int reg_num, u16 val) { return 0; @@ -160,7 +160,7 @@ int fixed_phy_set_link_update(struct phy_device *phydev, return -EINVAL; list_for_each_entry(fp, &fmb->phys, node) { - if (fp->id == phydev->phy_id) { + if (fp->addr == phydev->addr) { fp->link_update = link_update; fp->phydev = phydev; return 0; @@ -171,7 +171,7 @@ int fixed_phy_set_link_update(struct phy_device *phydev, } EXPORT_SYMBOL_GPL(fixed_phy_set_link_update); -int fixed_phy_add(unsigned int irq, int phy_id, +int fixed_phy_add(unsigned int irq, int phy_addr, struct fixed_phy_status *status) { int ret; @@ -184,9 +184,9 @@ int fixed_phy_add(unsigned int irq, int phy_id, memset(fp->regs, 0xFF, sizeof(fp->regs[0]) * MII_REGS_NUM); - fmb->irqs[phy_id] = irq; + fmb->irqs[phy_addr] = irq; - fp->id = phy_id; + fp->addr = phy_addr; fp->status = *status; ret = fixed_phy_update_regs(fp); -- 1.9.3
WARNING: multiple messages have this Message-ID (diff)
From: thomas.petazzoni@free-electrons.com (Thomas Petazzoni) To: linux-arm-kernel@lists.infradead.org Subject: [PATCHv4 1/5] net: phy: decouple PHY id and PHY address in fixed PHY driver Date: Fri, 16 May 2014 16:14:03 +0200 [thread overview] Message-ID: <1400249647-4643-2-git-send-email-thomas.petazzoni@free-electrons.com> (raw) In-Reply-To: <1400249647-4643-1-git-send-email-thomas.petazzoni@free-electrons.com> Until now, the fixed_phy_add() function was taking as argument 'phy_id', which was used both as the PHY address on the fake fixed MDIO bus, and as the PHY id, as available in the MII_PHYSID1 and MII_PHYSID2 registers. However, those two informations are completely unrelated. This patch decouples them. The PHY id of fixed PHYs is hardcoded to be 0x0. Ideally, a really reserved value would be nicer, but there doesn't seem to be an easy of making sure a dummy value can be assigned to the Linux kernel for such usage. The PHY address remains passed by the caller of phy_fixed_add(). Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> --- drivers/net/phy/fixed.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/phy/fixed.c b/drivers/net/phy/fixed.c index ba55adf..e41546d 100644 --- a/drivers/net/phy/fixed.c +++ b/drivers/net/phy/fixed.c @@ -31,7 +31,7 @@ struct fixed_mdio_bus { }; struct fixed_phy { - int id; + int addr; u16 regs[MII_REGS_NUM]; struct phy_device *phydev; struct fixed_phy_status status; @@ -104,8 +104,8 @@ static int fixed_phy_update_regs(struct fixed_phy *fp) if (fp->status.asym_pause) lpa |= LPA_PAUSE_ASYM; - fp->regs[MII_PHYSID1] = fp->id >> 16; - fp->regs[MII_PHYSID2] = fp->id; + fp->regs[MII_PHYSID1] = 0; + fp->regs[MII_PHYSID2] = 0; fp->regs[MII_BMSR] = bmsr; fp->regs[MII_BMCR] = bmcr; @@ -115,7 +115,7 @@ static int fixed_phy_update_regs(struct fixed_phy *fp) return 0; } -static int fixed_mdio_read(struct mii_bus *bus, int phy_id, int reg_num) +static int fixed_mdio_read(struct mii_bus *bus, int phy_addr, int reg_num) { struct fixed_mdio_bus *fmb = bus->priv; struct fixed_phy *fp; @@ -124,7 +124,7 @@ static int fixed_mdio_read(struct mii_bus *bus, int phy_id, int reg_num) return -1; list_for_each_entry(fp, &fmb->phys, node) { - if (fp->id == phy_id) { + if (fp->addr == phy_addr) { /* Issue callback if user registered it. */ if (fp->link_update) { fp->link_update(fp->phydev->attached_dev, @@ -138,7 +138,7 @@ static int fixed_mdio_read(struct mii_bus *bus, int phy_id, int reg_num) return 0xFFFF; } -static int fixed_mdio_write(struct mii_bus *bus, int phy_id, int reg_num, +static int fixed_mdio_write(struct mii_bus *bus, int phy_addr, int reg_num, u16 val) { return 0; @@ -160,7 +160,7 @@ int fixed_phy_set_link_update(struct phy_device *phydev, return -EINVAL; list_for_each_entry(fp, &fmb->phys, node) { - if (fp->id == phydev->phy_id) { + if (fp->addr == phydev->addr) { fp->link_update = link_update; fp->phydev = phydev; return 0; @@ -171,7 +171,7 @@ int fixed_phy_set_link_update(struct phy_device *phydev, } EXPORT_SYMBOL_GPL(fixed_phy_set_link_update); -int fixed_phy_add(unsigned int irq, int phy_id, +int fixed_phy_add(unsigned int irq, int phy_addr, struct fixed_phy_status *status) { int ret; @@ -184,9 +184,9 @@ int fixed_phy_add(unsigned int irq, int phy_id, memset(fp->regs, 0xFF, sizeof(fp->regs[0]) * MII_REGS_NUM); - fmb->irqs[phy_id] = irq; + fmb->irqs[phy_addr] = irq; - fp->id = phy_id; + fp->addr = phy_addr; fp->status = *status; ret = fixed_phy_update_regs(fp); -- 1.9.3
next prev parent reply other threads:[~2014-05-16 14:14 UTC|newest] Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-05-16 14:14 [PATCHv4 0/5] Add DT support for fixed PHYs Thomas Petazzoni 2014-05-16 14:14 ` Thomas Petazzoni 2014-05-16 14:14 ` Thomas Petazzoni [this message] 2014-05-16 14:14 ` [PATCHv4 1/5] net: phy: decouple PHY id and PHY address in fixed PHY driver Thomas Petazzoni 2014-05-16 18:30 ` Florian Fainelli 2014-05-16 18:30 ` Florian Fainelli 2014-05-16 14:14 ` [PATCHv4 2/5] net: phy: extend fixed driver with fixed_phy_register() Thomas Petazzoni 2014-05-16 14:14 ` Thomas Petazzoni 2014-05-16 18:28 ` Florian Fainelli 2014-05-16 18:28 ` Florian Fainelli 2015-09-03 19:20 ` Sergei Shtylyov 2015-09-03 19:20 ` Sergei Shtylyov 2015-09-03 19:23 ` Florian Fainelli 2015-09-03 19:23 ` Florian Fainelli 2015-09-03 19:35 ` Sergei Shtylyov 2015-09-03 19:35 ` Sergei Shtylyov 2015-09-03 19:37 ` Sergei Shtylyov 2015-09-03 19:37 ` Sergei Shtylyov 2015-09-03 19:38 ` Florian Fainelli 2015-09-03 19:38 ` Florian Fainelli 2015-09-03 19:55 ` Sergei Shtylyov 2015-09-03 19:55 ` Sergei Shtylyov 2014-05-16 14:14 ` [PATCHv4 3/5] of: provide a binding for fixed link PHYs Thomas Petazzoni 2014-05-16 14:14 ` Thomas Petazzoni [not found] ` <1400249647-4643-4-git-send-email-thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> 2014-05-16 18:29 ` Florian Fainelli 2014-05-16 18:29 ` Florian Fainelli 2014-05-16 14:14 ` [PATCHv4 4/5] net: mvneta: add support for fixed links Thomas Petazzoni 2014-05-16 14:14 ` Thomas Petazzoni 2014-05-16 14:14 ` [PATCHv4 5/5] ARM: mvebu: use the fixed-link PHY DT binding for the Armada XP Matrix board Thomas Petazzoni 2014-05-16 14:14 ` Thomas Petazzoni [not found] ` <1400249647-4643-1-git-send-email-thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org> 2014-05-16 18:27 ` [PATCHv4 0/5] Add DT support for fixed PHYs Florian Fainelli 2014-05-16 18:27 ` Florian Fainelli 2014-05-16 20:46 ` Thomas Petazzoni 2014-05-16 20:46 ` Thomas Petazzoni 2014-05-16 21:20 ` David Miller 2014-05-16 21:20 ` David Miller 2014-05-18 10:18 ` Thomas Petazzoni 2014-05-18 10:18 ` Thomas Petazzoni 2014-05-18 17:21 ` Florian Fainelli 2014-05-18 17:21 ` Florian Fainelli 2014-05-18 17:46 ` Thomas Petazzoni 2014-05-18 17:46 ` Thomas Petazzoni 2014-05-18 23:07 ` Jason Cooper 2014-05-18 23:07 ` Jason Cooper
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=1400249647-4643-2-git-send-email-thomas.petazzoni@free-electrons.com \ --to=thomas.petazzoni@free-electrons.com \ --cc=alior@marvell.com \ --cc=christian.gmeiner@gmail.com \ --cc=davem@davemloft.net \ --cc=devicetree@vger.kernel.org \ --cc=ezequiel.garcia@free-electrons.com \ --cc=florian@openwrt.org \ --cc=grant.likely@secretlab.ca \ --cc=gregory.clement@free-electrons.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=mark.rutland@arm.com \ --cc=nadavh@marvell.com \ --cc=netdev@vger.kernel.org \ --cc=robh+dt@kernel.org \ --cc=s.hauer@pengutronix.de \ --cc=tawfik@marvell.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: linkBe 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.