All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Josua Mayer <josua@solid-run.com>
To: Michael Hennerich <michael.hennerich@analog.com>,
	 "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,  Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	 Conor Dooley <conor+dt@kernel.org>,
	 Alexandru Tachici <alexandru.tachici@analog.com>,
	 Andrew Lunn <andrew@lunn.ch>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	 Russell King <linux@armlinux.org.uk>
Cc: Jon Nettleton <jon@solid-run.com>,
	 Yazan Shhady <yazan.shhady@solid-run.com>,
	netdev@vger.kernel.org,  devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,  Josua Mayer <josua@solid-run.com>
Subject: [PATCH net-next v2 2/2] net: phy: adin: add support for setting link-status-pin polarity
Date: Sat, 20 Apr 2024 13:23:01 +0200	[thread overview]
Message-ID: <20240420-adin-pin-polarity-v2-2-bf9714da7648@solid-run.com> (raw)
In-Reply-To: <20240420-adin-pin-polarity-v2-0-bf9714da7648@solid-run.com>

ADIN1300/1200 support software control over pin polarity for LINK_ST
(link-status) pin.

Configure the polarity during config_init based on device-tree property.

Polarity is only set if specified in device-tree, otherwise the phy
defaults to active-high during reset.

Signed-off-by: Josua Mayer <josua@solid-run.com>
---
 drivers/net/phy/adin.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c
index 2e1a46e121d9..a533932afcb8 100644
--- a/drivers/net/phy/adin.c
+++ b/drivers/net/phy/adin.c
@@ -158,6 +158,9 @@
 #define ADIN1300_RMII_20_BITS			0x0004
 #define ADIN1300_RMII_24_BITS			0x0005
 
+#define ADIN1300_GE_LNK_STAT_INV_EN_REG		0xff3c
+#define   ADIN1300_GE_LNK_STAT_INV_EN		BIT(0)
+
 /**
  * struct adin_cfg_reg_map - map a config value to aregister value
  * @cfg:	value in device configuration
@@ -522,6 +525,28 @@ static int adin_config_clk_out(struct phy_device *phydev)
 			      ADIN1300_GE_CLK_CFG_MASK, sel);
 }
 
+static int adin_config_link_status_pin_polarity(struct phy_device *phydev)
+{
+	struct device *dev = &phydev->mdio.dev;
+	int ret;
+	u32 val;
+
+	if (!device_property_present(dev, "adi,link-st-polarity"))
+		return 0;
+
+	ret = device_property_read_u32(dev, "adi,link-st-polarity", &val);
+	if (ret) {
+		return ret;
+	} else if (val > 1) {
+		phydev_err(phydev, "invalid adi,link-st-polarity\n");
+		return -EINVAL;
+	}
+
+	return phy_modify_mmd(phydev, MDIO_MMD_VEND1,
+			     ADIN1300_GE_LNK_STAT_INV_EN_REG,
+			     ADIN1300_GE_LNK_STAT_INV_EN, val);
+}
+
 static int adin_config_init(struct phy_device *phydev)
 {
 	int rc;
@@ -548,6 +573,10 @@ static int adin_config_init(struct phy_device *phydev)
 	if (rc < 0)
 		return rc;
 
+	rc = adin_config_link_status_pin_polarity(phydev);
+	if (rc < 0)
+		return rc;
+
 	phydev_dbg(phydev, "PHY is using mode '%s'\n",
 		   phy_modes(phydev->interface));
 

-- 
2.35.3


      parent reply	other threads:[~2024-04-20 11:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-20 11:22 [PATCH net-next v2 0/2] net: phy: adin: add support for setting led-, link-status-pin polarity Josua Mayer
2024-04-20 11:23 ` [PATCH net-next v2 1/2] dt-bindings: net: adin: add property for link-status pin polarity Josua Mayer
2024-04-20 16:10   ` Andrew Lunn
2024-04-20 16:56     ` Josua Mayer
2024-04-20 17:09       ` Andrew Lunn
2024-04-21  9:07         ` Josua Mayer
2024-04-21 17:54           ` Andrew Lunn
2024-04-29  9:54             ` Josua Mayer
2024-04-20 11:23 ` Josua Mayer [this message]

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=20240420-adin-pin-polarity-v2-2-bf9714da7648@solid-run.com \
    --to=josua@solid-run.com \
    --cc=alexandru.tachici@analog.com \
    --cc=andrew@lunn.ch \
    --cc=conor+dt@kernel.org \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=jon@solid-run.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=michael.hennerich@analog.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=yazan.shhady@solid-run.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 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.