netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net-next v2 6/8] net: dsa: allow switch drivers to specify phy_device::dev_flags
Date: Fri, 19 Sep 2014 13:07:54 -0700	[thread overview]
Message-ID: <1411157276-18260-7-git-send-email-f.fainelli@gmail.com> (raw)
In-Reply-To: <1411157276-18260-1-git-send-email-f.fainelli@gmail.com>

Some switch drivers (e.g: bcm_sf2) may have to communicate specific
workarounds or flags towards the PHY device driver. Allow switches
driver to be delegated that task by introducing a get_phy_flags()
callback which will do just that.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
Changes in v2:
- fixed the build failure, use 'p->port' instead of 'port'

 include/net/dsa.h | 1 +
 net/dsa/slave.c   | 9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/include/net/dsa.h b/include/net/dsa.h
index c779e9bba1b3..e020b8a12b7d 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -181,6 +181,7 @@ struct dsa_switch_driver {
 	char	*(*probe)(struct device *host_dev, int sw_addr);
 	int	(*setup)(struct dsa_switch *ds);
 	int	(*set_addr)(struct dsa_switch *ds, u8 *addr);
+	u32	(*get_phy_flags)(struct dsa_switch *ds, int port);
 
 	/*
 	 * Access to the switch's PHY registers.
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 90c9689ed362..a7997265019a 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -371,6 +371,7 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
 	struct dsa_chip_data *cd = ds->pd;
 	struct device_node *phy_dn, *port_dn;
 	bool phy_is_fixed = false;
+	u32 phy_flags = 0;
 	int ret;
 
 	port_dn = cd->port_dn[p->port];
@@ -390,9 +391,12 @@ static void dsa_slave_phy_setup(struct dsa_slave_priv *p,
 		phy_dn = port_dn;
 	}
 
+	if (ds->drv->get_phy_flags)
+		phy_flags = ds->drv->get_phy_flags(ds, p->port);
+
 	if (phy_dn)
 		p->phy = of_phy_connect(slave_dev, phy_dn,
-					dsa_slave_adjust_link, 0,
+					dsa_slave_adjust_link, phy_flags,
 					p->phy_interface);
 
 	if (p->phy && phy_is_fixed)
@@ -480,6 +484,9 @@ dsa_slave_create(struct dsa_switch *ds, struct device *parent,
 	netif_carrier_off(slave_dev);
 
 	if (p->phy != NULL) {
+		if (ds->drv->get_phy_flags(ds, port))
+			p->phy->dev_flags |= ds->drv->get_phy_flags(ds, port);
+
 		phy_attach(slave_dev, dev_name(&p->phy->dev),
 			   PHY_INTERFACE_MODE_GMII);
 
-- 
1.9.1

  parent reply	other threads:[~2014-09-19 20:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-19 20:07 [PATCH net-next v2 0/8] net: phy: Broadcom BCM7xxx PHY workaround update Florian Fainelli
2014-09-19 20:07 ` [PATCH net-next v2 1/8] of: mdio: honor flags passed to of_phy_connect Florian Fainelli
2014-09-19 20:07 ` [PATCH net-next v2 2/8] net: phy: broadcom: add helper for PHY revision and patch level Florian Fainelli
2014-09-19 20:07 ` [PATCH net-next v2 3/8] net: phy: bcm7xxx: do not use PHY_BRCM_100MBPS_WAR Florian Fainelli
2014-09-19 20:07 ` [PATCH net-next v2 4/8] net: bcmgenet: remove PHY_BRCM_100MBPS_WAR Florian Fainelli
2014-09-19 20:07 ` [PATCH net-next v2 5/8] net: bcmgenet: communicate integrated PHY revision to PHY driver Florian Fainelli
2014-09-19 20:07 ` Florian Fainelli [this message]
2014-09-19 20:07 ` [PATCH net-next v2 7/8] net: dsa: bcm_sf2: " Florian Fainelli
2014-09-19 20:07 ` [PATCH net-next v2 8/8] net: phy: bcm7xxx: utilize PHY revision in config_init Florian Fainelli
2014-09-19 20:27 ` [PATCH net-next v2 0/8] net: phy: Broadcom BCM7xxx PHY workaround update David Miller

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=1411157276-18260-7-git-send-email-f.fainelli@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).