From: <Tristram.Ha@microchip.com>
To: Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Pavel Machek <pavel@ucw.cz>
Cc: Tristram Ha <Tristram.Ha@microchip.com>,
Ruediger Schmitt <ruediger.schmitt@philips.com>,
<UNGLinuxDriver@microchip.com>, <netdev@vger.kernel.org>
Subject: [PATCH v3 net-next 07/11] net: dsa: microchip: Prepare PHY for proper advertisement
Date: Mon, 22 Oct 2018 19:26:11 -0700 [thread overview]
Message-ID: <1540261575-1889-8-git-send-email-Tristram.Ha@microchip.com> (raw)
In-Reply-To: <1540261575-1889-1-git-send-email-Tristram.Ha@microchip.com>
From: Tristram Ha <Tristram.Ha@microchip.com>
Prepare PHY for proper advertisement and get link status for the port.
Signed-off-by: Tristram Ha <Tristram.Ha@microchip.com>
Reviewed-by: Woojung Huh <Woojung.Huh@microchip.com>
---
drivers/net/dsa/microchip/ksz9477.c | 13 +++++++++++++
drivers/net/dsa/microchip/ksz_common.c | 17 +++++++++++++++++
drivers/net/dsa/microchip/ksz_common.h | 2 ++
drivers/net/dsa/microchip/ksz_priv.h | 2 ++
4 files changed, 34 insertions(+)
diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
index df3a189..72042b0 100644
--- a/drivers/net/dsa/microchip/ksz9477.c
+++ b/drivers/net/dsa/microchip/ksz9477.c
@@ -981,6 +981,17 @@ static void ksz9477_port_mirror_del(struct dsa_switch *ds, int port,
PORT_MIRROR_SNIFFER, false);
}
+static void ksz9477_phy_setup(struct ksz_device *dev, int port,
+ struct phy_device *phy)
+{
+ if (port < dev->phy_port_cnt) {
+ /* SUPPORTED_Asym_Pause and SUPPORTED_Pause can be removed to
+ * disable flow control when rate limiting is used.
+ */
+ phy->advertising = phy->supported;
+ }
+}
+
static void ksz9477_port_setup(struct ksz_device *dev, int port, bool cpu_port)
{
u8 data8;
@@ -1163,6 +1174,7 @@ static int ksz9477_setup(struct dsa_switch *ds)
.setup = ksz9477_setup,
.phy_read = ksz9477_phy_read16,
.phy_write = ksz9477_phy_write16,
+ .adjust_link = ksz_adjust_link,
.port_enable = ksz_enable_port,
.port_disable = ksz_disable_port,
.get_strings = ksz9477_get_strings,
@@ -1314,6 +1326,7 @@ static void ksz9477_switch_exit(struct ksz_device *dev)
.get_port_addr = ksz9477_get_port_addr,
.cfg_port_member = ksz9477_cfg_port_member,
.flush_dyn_mac_table = ksz9477_flush_dyn_mac_table,
+ .phy_setup = ksz9477_phy_setup,
.port_setup = ksz9477_port_setup,
.shutdown = ksz9477_reset_switch,
.detect = ksz9477_switch_detect,
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 9130685..a2f06ef 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -73,6 +73,22 @@ int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val)
}
EXPORT_SYMBOL_GPL(ksz_phy_write16);
+void ksz_adjust_link(struct dsa_switch *ds, int port,
+ struct phy_device *phydev)
+{
+ struct ksz_device *dev = ds->priv;
+ struct ksz_port *p = &dev->ports[port];
+
+ if (phydev->link) {
+ dev->live_ports |= (1 << port) & dev->on_ports;
+ } else if (p->phydev.link) {
+ p->link_just_down = 1;
+ dev->live_ports &= ~(1 << port);
+ }
+ p->phydev = *phydev;
+}
+EXPORT_SYMBOL_GPL(ksz_adjust_link);
+
int ksz_sset_count(struct dsa_switch *ds, int port, int sset)
{
struct ksz_device *dev = ds->priv;
@@ -250,6 +266,7 @@ int ksz_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy)
/* setup slave port */
dev->dev_ops->port_setup(dev, port, false);
+ dev->dev_ops->phy_setup(dev, port, phy);
/* port_stp_state_set() will be called after to enable the port so
* there is no need to do anything.
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index 49638ce..e25a60b 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -26,6 +26,8 @@
int ksz_phy_read16(struct dsa_switch *ds, int addr, int reg);
int ksz_phy_write16(struct dsa_switch *ds, int addr, int reg, u16 val);
+void ksz_adjust_link(struct dsa_switch *ds, int port,
+ struct phy_device *phydev);
int ksz_sset_count(struct dsa_switch *ds, int port, int sset);
int ksz_port_bridge_join(struct dsa_switch *ds, int port,
struct net_device *br);
diff --git a/drivers/net/dsa/microchip/ksz_priv.h b/drivers/net/dsa/microchip/ksz_priv.h
index 1f20982..708eef4 100644
--- a/drivers/net/dsa/microchip/ksz_priv.h
+++ b/drivers/net/dsa/microchip/ksz_priv.h
@@ -147,6 +147,8 @@ struct ksz_dev_ops {
u32 (*get_port_addr)(int port, int offset);
void (*cfg_port_member)(struct ksz_device *dev, int port, u8 member);
void (*flush_dyn_mac_table)(struct ksz_device *dev, int port);
+ void (*phy_setup)(struct ksz_device *dev, int port,
+ struct phy_device *phy);
void (*port_setup)(struct ksz_device *dev, int port, bool cpu_port);
void (*r_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 *val);
void (*w_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 val);
--
1.9.1
next prev parent reply other threads:[~2018-10-23 10:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-23 2:26 [PATCH v3 net-next 00/11] net: dsa: microchip: Modify KSZ9477 DSA driver in preparation to add other KSZ switch drivers Tristram.Ha
2018-10-23 2:26 ` [PATCH v3 net-next 01/11] net: dsa: microchip: Replace license with GPL Tristram.Ha
2018-10-24 11:05 ` Pavel Machek
2018-10-23 2:26 ` [PATCH v3 net-next 03/11] net: dsa: microchip: Initialize mutex before use Tristram.Ha
2018-10-23 13:15 ` Andrew Lunn
2018-10-24 11:07 ` Pavel Machek
2018-10-23 2:26 ` [PATCH v3 net-next 04/11] net: dsa: microchip: Rename some functions with ksz9477 prefix Tristram.Ha
2018-10-23 2:26 ` [PATCH v3 net-next 05/11] net: dsa: microchip: Rename ksz_spi.c to ksz9477_spi.c Tristram.Ha
2018-10-23 2:26 ` [PATCH v3 net-next 06/11] net: dsa: microchip: Break KSZ9477 DSA driver into two files Tristram.Ha
2018-10-23 2:26 ` Tristram.Ha [this message]
2018-10-23 2:26 ` [PATCH v3 net-next 08/11] net: dsa: microchip: Rename ksz_9477_reg.h to ksz9477_reg.h Tristram.Ha
2018-10-23 2:26 ` [PATCH v3 net-next 09/11] net: dsa: microchip: Add MIB counter reading support Tristram.Ha
2018-10-23 2:26 ` [PATCH v3 net-next 10/11] net: dsa: microchip: Modify tag_ksz.c so that tail tag code can be used by other KSZ switch drivers Tristram.Ha
2018-10-23 2:26 ` [PATCH v3 net-next 11/11] net: dsa: microchip: Add switch offload forwarding support Tristram.Ha
2018-10-23 3:26 ` [PATCH v3 net-next 00/11] net: dsa: microchip: Modify KSZ9477 DSA driver in preparation to add other KSZ switch drivers 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=1540261575-1889-8-git-send-email-Tristram.Ha@microchip.com \
--to=tristram.ha@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=f.fainelli@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pavel@ucw.cz \
--cc=ruediger.schmitt@philips.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;
as well as URLs for NNTP newsgroup(s).