LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Murali Karicheri <m-karicheri2@ti.com>
To: <robh+dt@kernel.org>, <mark.rutland@arm.com>,
	<ssantosh@kernel.org>, <malat@debian.org>, <w-kwok2@ti.com>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>, <davem@davemloft.net>,
	<netdev@vger.kernel.org>, <grygorii.strashko@ti.com>,
	<nsekhar@ti.com>
Subject: [net-next PATCH v4 06/13] net: netcp: ethss: use rgmii link status for 2u cpsw hardware
Date: Tue, 17 Apr 2018 17:30:35 -0400	[thread overview]
Message-ID: <1524000642-23944-7-git-send-email-m-karicheri2@ti.com> (raw)
In-Reply-To: <1524000642-23944-1-git-send-email-m-karicheri2@ti.com>

Introduce rgmii link status to handle link state events for 2u
cpsw hardware on K2G.

Signed-off-by: Murali Karicheri <m-karicheri2@ti.com>
---
 drivers/net/ethernet/ti/netcp_ethss.c | 34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c
index 68b10b5..83acb72 100644
--- a/drivers/net/ethernet/ti/netcp_ethss.c
+++ b/drivers/net/ethernet/ti/netcp_ethss.c
@@ -171,6 +171,11 @@
 #define	GBE_RXHOOK_ORDER			0
 #define GBE_DEFAULT_ALE_AGEOUT			30
 #define SLAVE_LINK_IS_XGMII(s) ((s)->link_interface >= XGMII_LINK_MAC_PHY)
+#define SLAVE_LINK_IS_RGMII(s) \
+	(((s)->link_interface >= RGMII_LINK_MAC_PHY) && \
+	 ((s)->link_interface <= RGMII_LINK_MAC_PHY_NO_MDIO))
+#define SLAVE_LINK_IS_SGMII(s) \
+	((s)->link_interface <= SGMII_LINK_MAC_PHY_NO_MDIO)
 #define NETCP_LINK_STATE_INVALID		-1
 
 #define GBE_SET_REG_OFS(p, rb, rn) p->rb##_ofs.rn = \
@@ -554,6 +559,7 @@ struct gbe_ss_regs {
 struct gbe_ss_regs_ofs {
 	u16	id_ver;
 	u16	control;
+	u16	rgmii_status; /* 2U */
 };
 
 struct gbe_switch_regs {
@@ -2122,23 +2128,35 @@ static bool gbe_phy_link_status(struct gbe_slave *slave)
 	 return !slave->phy || slave->phy->link;
 }
 
+#define RGMII_REG_STATUS_LINK	BIT(0)
+
+static void netcp_2u_rgmii_get_port_link(struct gbe_priv *gbe_dev, bool *status)
+{
+	u32 val = 0;
+
+	val = readl(GBE_REG_ADDR(gbe_dev, ss_regs, rgmii_status));
+	*status = !!(val & RGMII_REG_STATUS_LINK);
+}
+
 static void netcp_ethss_update_link_state(struct gbe_priv *gbe_dev,
 					  struct gbe_slave *slave,
 					  struct net_device *ndev)
 {
-	int sp = slave->slave_num;
-	int phy_link_state, sgmii_link_state = 1, link_state;
+	bool sw_link_state = true, phy_link_state;
+	int sp = slave->slave_num, link_state;
 
 	if (!slave->open)
 		return;
 
-	if (!SLAVE_LINK_IS_XGMII(slave)) {
-		sgmii_link_state =
-			netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);
-	}
+	if (SLAVE_LINK_IS_RGMII(slave))
+		netcp_2u_rgmii_get_port_link(gbe_dev,
+					     &sw_link_state);
+	if (SLAVE_LINK_IS_SGMII(slave))
+		sw_link_state =
+		netcp_sgmii_get_port_link(SGMII_BASE(gbe_dev, sp), sp);
 
 	phy_link_state = gbe_phy_link_status(slave);
-	link_state = phy_link_state & sgmii_link_state;
+	link_state = phy_link_state & sw_link_state;
 
 	if (atomic_xchg(&slave->link_state, link_state) != link_state)
 		netcp_ethss_link_state_action(gbe_dev, ndev, slave,
@@ -3437,6 +3455,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
 
 	/* Subsystem registers */
 	GBENU_SET_REG_OFS(gbe_dev, ss_regs, id_ver);
+	/* ok to set for MU, but used by 2U only */
+	GBENU_SET_REG_OFS(gbe_dev, ss_regs, rgmii_status);
 
 	/* Switch module registers */
 	GBENU_SET_REG_OFS(gbe_dev, switch_regs, id_ver);
-- 
1.9.1

  parent reply	other threads:[~2018-04-17 21:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-17 21:30 [net-next PATCH v4 00/13] Add support for netcp driver on K2G SoC Murali Karicheri
2018-04-17 21:30 ` [net-next PATCH v4 01/13] soc: ti: K2G: enhancement to support QMSS in K2G NAVSS Murali Karicheri
2018-04-17 21:30 ` [net-next PATCH v4 02/13] soc: ti: K2G: provide APIs to support driver probe deferral Murali Karicheri
2018-04-17 21:30 ` [net-next PATCH v4 03/13] net: netcp: ethss: use macro for checking ss_version consistently Murali Karicheri
2018-04-17 21:30 ` [net-next PATCH v4 04/13] net: netcp: ethss: make sgmii configuration conditional Murali Karicheri
2018-04-17 21:30 ` [net-next PATCH v4 05/13] net: netcp: ethss: add support for handling rgmii link interface Murali Karicheri
2018-04-17 21:30 ` Murali Karicheri [this message]
2018-04-17 21:30 ` [net-next PATCH v4 07/13] net: netcp: ethss: map vlan priorities to zero flow Murali Karicheri
2018-04-17 21:30 ` [net-next PATCH v4 08/13] net: netcp: ethss: re-use stats handling code for 2u hardware Murali Karicheri
2018-04-17 21:30 ` [net-next PATCH v4 09/13] net: netcp: ethss: use of_get_phy_mode() to support different RGMII modes Murali Karicheri
2018-04-17 21:30 ` [net-next PATCH v4 10/13] Revert "net: netcp: remove dead code from the driver" Murali Karicheri
2018-04-17 21:30 ` [net-next PATCH v4 11/13] net: netcp: support probe deferral Murali Karicheri
2018-04-17 21:30 ` [net-next PATCH v4 12/13] net: netcp: add api to support set rx mode in netcp modules Murali Karicheri
2018-04-17 21:30 ` [net-next PATCH v4 13/13] net: netcp: ethss: k2g: add promiscuous mode support Murali Karicheri
2018-04-19  1:07 ` [net-next PATCH v4 00/13] Add support for netcp driver on K2G SoC 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=1524000642-23944-7-git-send-email-m-karicheri2@ti.com \
    --to=m-karicheri2@ti.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=grygorii.strashko@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=malat@debian.org \
    --cc=mark.rutland@arm.com \
    --cc=netdev@vger.kernel.org \
    --cc=nsekhar@ti.com \
    --cc=robh+dt@kernel.org \
    --cc=ssantosh@kernel.org \
    --cc=w-kwok2@ti.com \
    --subject='Re: [net-next PATCH v4 06/13] net: netcp: ethss: use rgmii link status for 2u cpsw hardware' \
    /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

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).