Linux-Hwmon Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH V2] net: phy: tja11xx: Add IRQ support to the driver
@ 2019-05-28 19:23 Marek Vasut
  2019-05-28 19:28 ` Heiner Kallweit
  0 siblings, 1 reply; 14+ messages in thread
From: Marek Vasut @ 2019-05-28 19:23 UTC (permalink / raw)
  To: netdev
  Cc: Marek Vasut, Andrew Lunn, Florian Fainelli, Guenter Roeck,
	Heiner Kallweit, Jean Delvare, linux-hwmon

Add support for handling the TJA11xx PHY IRQ signal.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Jean Delvare <jdelvare@suse.com>
Cc: linux-hwmon@vger.kernel.org
---
V2: - Define each bit of the MII_INTEN register and a mask
    - Drop IRQ acking from tja11xx_config_intr()
---
 drivers/net/phy/nxp-tja11xx.c | 48 +++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c
index b705d0bd798b..b41af609607d 100644
--- a/drivers/net/phy/nxp-tja11xx.c
+++ b/drivers/net/phy/nxp-tja11xx.c
@@ -40,6 +40,29 @@
 #define MII_INTSRC_TEMP_ERR		BIT(1)
 #define MII_INTSRC_UV_ERR		BIT(3)
 
+#define MII_INTEN			22
+#define MII_INTEN_PWON_EN		BIT(15)
+#define MII_INTEN_WAKEUP_EN		BIT(14)
+#define MII_INTEN_PHY_INIT_FAIL_EN	BIT(11)
+#define MII_INTEN_LINK_STATUS_FAIL_EN	BIT(10)
+#define MII_INTEN_LINK_STATUS_UP_EN	BIT(9)
+#define MII_INTEN_SYM_ERR_EN		BIT(8)
+#define MII_INTEN_TRAINING_FAILED_EN	BIT(7)
+#define MII_INTEN_SQI_WARNING_EN	BIT(6)
+#define MII_INTEN_CONTROL_ERR_EN	BIT(5)
+#define MII_INTEN_UV_ERR_EN		BIT(3)
+#define MII_INTEN_UV_RECOVERY_EN	BIT(2)
+#define MII_INTEN_TEMP_ERR_EN		BIT(1)
+#define MII_INTEN_SLEEP_ABORT_EN	BIT(0)
+#define MII_INTEN_MASK							\
+	(MII_INTEN_PWON_EN | MII_INTEN_WAKEUP_EN |			\
+	MII_INTEN_PHY_INIT_FAIL_EN | MII_INTEN_LINK_STATUS_FAIL_EN |	\
+	MII_INTEN_LINK_STATUS_UP_EN | MII_INTEN_SYM_ERR_EN |		\
+	MII_INTEN_TRAINING_FAILED_EN | MII_INTEN_SQI_WARNING_EN |	\
+	MII_INTEN_CONTROL_ERR_EN | MII_INTEN_UV_ERR_EN |		\
+	MII_INTEN_UV_RECOVERY_EN | MII_INTEN_TEMP_ERR_EN |		\
+	MII_INTEN_SLEEP_ABORT_EN)
+
 #define MII_COMMSTAT			23
 #define MII_COMMSTAT_LINK_UP		BIT(15)
 
@@ -239,6 +262,25 @@ static int tja11xx_read_status(struct phy_device *phydev)
 	return 0;
 }
 
+static int tja11xx_config_intr(struct phy_device *phydev)
+{
+	int ret;
+
+	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
+		ret = phy_write(phydev, MII_INTEN, MII_INTEN_MASK);
+	else
+		ret = phy_write(phydev, MII_INTEN, 0);
+
+	return ret < 0 ? ret : 0;
+}
+
+static int tja11xx_ack_interrupt(struct phy_device *phydev)
+{
+	int ret = phy_read(phydev, MII_INTSRC);
+
+	return ret < 0 ? ret : 0;
+}
+
 static int tja11xx_get_sset_count(struct phy_device *phydev)
 {
 	return ARRAY_SIZE(tja11xx_hw_stats);
@@ -366,6 +408,9 @@ static struct phy_driver tja11xx_driver[] = {
 		.suspend	= genphy_suspend,
 		.resume		= genphy_resume,
 		.set_loopback   = genphy_loopback,
+		/* IRQ related */
+		.config_intr	= tja11xx_config_intr,
+		.ack_interrupt	= tja11xx_ack_interrupt,
 		/* Statistics */
 		.get_sset_count = tja11xx_get_sset_count,
 		.get_strings	= tja11xx_get_strings,
@@ -381,6 +426,9 @@ static struct phy_driver tja11xx_driver[] = {
 		.suspend	= genphy_suspend,
 		.resume		= genphy_resume,
 		.set_loopback   = genphy_loopback,
+		/* IRQ related */
+		.config_intr	= tja11xx_config_intr,
+		.ack_interrupt	= tja11xx_ack_interrupt,
 		/* Statistics */
 		.get_sset_count = tja11xx_get_sset_count,
 		.get_strings	= tja11xx_get_strings,
-- 
2.20.1


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, back to index

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-28 19:23 [PATCH V2] net: phy: tja11xx: Add IRQ support to the driver Marek Vasut
2019-05-28 19:28 ` Heiner Kallweit
2019-05-28 19:31   ` Marek Vasut
2019-05-28 19:35     ` Heiner Kallweit
2019-05-28 19:46       ` Marek Vasut
2019-05-28 19:58         ` Andrew Lunn
2019-05-28 20:00           ` Marek Vasut
2019-05-28 21:22             ` Andrew Lunn
2019-05-28 21:33               ` Marek Vasut
2019-05-29 23:29                 ` Andrew Lunn
2019-05-29 23:46                   ` Marek Vasut
2019-06-13 15:42                     ` Marek Vasut
2019-06-17 17:16                       ` Andrew Lunn
2019-06-17 17:43                         ` Marek Vasut

Linux-Hwmon Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-hwmon/0 linux-hwmon/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hwmon linux-hwmon/ https://lore.kernel.org/linux-hwmon \
		linux-hwmon@vger.kernel.org linux-hwmon@archiver.kernel.org
	public-inbox-index linux-hwmon


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hwmon


AGPL code for this site: git clone https://public-inbox.org/ public-inbox