devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Mugunthan V N <mugunthanvnm@ti.com>,
	Karicheri Muralidharan <m-karicheri2@ti.com>,
	linux-kernel@vger.kernel.org, Eric Engestrom <eric@engestrom.ch>,
	netdev@vger.kernel.org, Kishon Vijay Abraham I <kishon@ti.com>,
	Grygorii Strashko <grygorii.strashko@ti.com>
Cc: devicetree@vger.kernel.org, Lukasz Majewski <lukma@denx.de>
Subject: [PATCH] net: phy: dp83867: Port mirroring support in the DP83867 TI's PHY driver
Date: Wed,  1 Feb 2017 15:43:35 +0100	[thread overview]
Message-ID: <1485960215-5148-1-git-send-email-lukma@denx.de> (raw)

This patch adds support for enabling or disabling the port mirroring
feature of the DP83867 TI's PHY device.

One use case is when bootstrap configuration enables this feature (because
of e.g. LED wiring) so then one needs to disable it in software
(u-boot/Linux).

Signed-off-by: Lukasz Majewski <lukma@denx.de>
---
 .../devicetree/bindings/net/ti,dp83867.txt         |  4 +++
 drivers/net/phy/dp83867.c                          | 40 ++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/ti,dp83867.txt b/Documentation/devicetree/bindings/net/ti,dp83867.txt
index afe9630..d1be241 100644
--- a/Documentation/devicetree/bindings/net/ti,dp83867.txt
+++ b/Documentation/devicetree/bindings/net/ti,dp83867.txt
@@ -18,6 +18,10 @@ Optional property:
 	- ti,max-output-impedance - MAC Interface Impedance control to set
 				    the programmable output impedance to
 				    maximum value (70 ohms).
+	- ti,port-mirroring - Set port mirroring. It is possible to overwrite -
+			      enable (by setting <1>) or disable
+			      (by setting <0>) the port mirroring feature set
+			      by bootstrap initial reading.
 
 Note: ti,min-output-impedance and ti,max-output-impedance are mutually
       exclusive. When both properties are present ti,max-output-impedance
diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
index ca1b462..98948bd 100644
--- a/drivers/net/phy/dp83867.c
+++ b/drivers/net/phy/dp83867.c
@@ -32,6 +32,7 @@
 #define DP83867_CFG3		0x1e
 
 /* Extended Registers */
+#define DP83867_CFG4            0x0031
 #define DP83867_RGMIICTL	0x0032
 #define DP83867_RGMIIDCTL	0x0086
 #define DP83867_IO_MUX_CFG	0x0170
@@ -70,11 +71,20 @@
 #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX	0x0
 #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN	0x1f
 
+/* CFG4 bits */
+#define DP83867_CFG4_PORT_MIRROR_EN              BIT(0)
+
+enum {
+	DP83867_PORT_MIRROING_EN = 1,
+	DP83867_PORT_MIRROING_DIS,
+};
+
 struct dp83867_private {
 	int rx_id_delay;
 	int tx_id_delay;
 	int fifo_depth;
 	int io_impedance;
+	int port_mirroring;
 };
 
 static int dp83867_ack_interrupt(struct phy_device *phydev)
@@ -111,6 +121,24 @@ static int dp83867_config_intr(struct phy_device *phydev)
 	return phy_write(phydev, MII_DP83867_MICR, micr_status);
 }
 
+static int dp83867_config_port_mirroring(struct phy_device *phydev)
+{
+	struct dp83867_private *dp83867 =
+		(struct dp83867_private *)phydev->priv;
+	u16 val;
+
+	val = phy_read_mmd_indirect(phydev, DP83867_CFG4, DP83867_DEVADDR);
+
+	if (dp83867->port_mirroring == DP83867_PORT_MIRROING_EN)
+		val |= DP83867_CFG4_PORT_MIRROR_EN;
+	else
+		val &= ~DP83867_CFG4_PORT_MIRROR_EN;
+
+	phy_write_mmd_indirect(phydev, DP83867_CFG4, DP83867_DEVADDR, val);
+
+	return 0;
+}
+
 #ifdef CONFIG_OF_MDIO
 static int dp83867_of_init(struct phy_device *phydev)
 {
@@ -118,6 +146,7 @@ static int dp83867_of_init(struct phy_device *phydev)
 	struct device *dev = &phydev->mdio.dev;
 	struct device_node *of_node = dev->of_node;
 	int ret;
+	u32 v;
 
 	if (!of_node)
 		return -ENODEV;
@@ -144,6 +173,14 @@ static int dp83867_of_init(struct phy_device *phydev)
 	     phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID))
 		return ret;
 
+	ret = of_property_read_u32(of_node, "ti,port-mirroring", &v);
+	if (!ret) {
+		if (v)
+			dp83867->port_mirroring = DP83867_PORT_MIRROING_EN;
+		else
+			dp83867->port_mirroring = DP83867_PORT_MIRROING_DIS;
+	}
+
 	return of_property_read_u32(of_node, "ti,fifo-depth",
 				   &dp83867->fifo_depth);
 }
@@ -228,6 +265,9 @@ static int dp83867_config_init(struct phy_device *phydev)
 		phy_write(phydev, DP83867_CFG3, val);
 	}
 
+	if (dp83867->port_mirroring)
+		dp83867_config_port_mirroring(phydev);
+
 	return 0;
 }
 
-- 
2.1.4

             reply	other threads:[~2017-02-01 14:43 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-01 14:43 Lukasz Majewski [this message]
     [not found] ` <1485960215-5148-1-git-send-email-lukma-ynQEQJNshbs@public.gmane.org>
2017-02-01 17:16   ` [PATCH] net: phy: dp83867: Port mirroring support in the DP83867 TI's PHY driver Andrew Lunn
     [not found]     ` <20170201171610.GC7395-g2DYL2Zd6BY@public.gmane.org>
2017-02-01 19:05       ` Florian Fainelli
     [not found]         ` <2f3766f0-42df-6aab-dda1-14022c57fb30-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-01 21:05           ` Lukasz Majewski
2017-02-01 21:12             ` Florian Fainelli
     [not found]               ` <a287bc1e-3693-02d3-4c58-f1369144efd1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-02-01 21:16                 ` Andrew Lunn
2017-02-01 21:14             ` Andrew Lunn
2017-02-01 22:13               ` Lukasz Majewski
2017-02-02  1:54                 ` Andrew Lunn
2017-02-02  9:17                   ` Lukasz Majewski
2017-02-02 13:11                     ` Andrew Lunn
     [not found]                       ` <20170202131112.GI4967-g2DYL2Zd6BY@public.gmane.org>
2017-02-02 15:22                         ` Lukasz Majewski

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=1485960215-5148-1-git-send-email-lukma@denx.de \
    --to=lukma@denx.de \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=eric@engestrom.ch \
    --cc=f.fainelli@gmail.com \
    --cc=grygorii.strashko@ti.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m-karicheri2@ti.com \
    --cc=mark.rutland@arm.com \
    --cc=mugunthanvnm@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@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).