netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] phy/at8031: enable at8031 to work on interrupt mode
@ 2014-03-28  7:39 Zhao Qiang
  2014-03-29 22:20 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Zhao Qiang @ 2014-03-28  7:39 UTC (permalink / raw)
  To: linuxppc-dev, netdev, B07421
  Cc: linux-kernel, davem, mugunthanvnm, zonque, helmut.schaa, R63061,
	Zhao Qiang

The at8031 can work on polling mode and interrupt mode.
Add ack_interrupt and config intr funcs to enable
interrupt mode for it.

Signed-off-by: Zhao Qiang <B45475@freescale.com>
---
changes for v2:
	- when interrupt is not enabled, write 0 to interrupt enbale register
	- delete a inner parens not needed
 drivers/net/phy/at803x.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index bc71947..643464d 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -27,6 +27,9 @@
 #define AT803X_MMD_ACCESS_CONTROL		0x0D
 #define AT803X_MMD_ACCESS_CONTROL_DATA		0x0E
 #define AT803X_FUNC_DATA			0x4003
+#define AT803X_INER				0x0012
+#define AT803X_INER_INIT			0xec00
+#define AT803X_INSR				0x0013
 #define AT803X_DEBUG_ADDR			0x1D
 #define AT803X_DEBUG_DATA			0x1E
 #define AT803X_DEBUG_SYSTEM_MODE_CTRL		0x05
@@ -191,6 +194,31 @@ static int at803x_config_init(struct phy_device *phydev)
 	return 0;
 }
 
+static int at803x_ack_interrupt(struct phy_device *phydev)
+{
+	int err;
+
+	err = phy_read(phydev, AT803X_INSR);
+
+	return (err < 0) ? err : 0;
+}
+
+static int at803x_config_intr(struct phy_device *phydev)
+{
+	int err;
+	int value;
+
+	value = phy_read(phydev, AT803X_INER);
+
+	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
+		err = phy_write(phydev, AT803X_INER,
+				value | AT803X_INER_INIT);
+	else
+		err = phy_write(phydev, AT803X_INER, 0);
+
+	return err;
+}
+
 static struct phy_driver at803x_driver[] = {
 {
 	/* ATHEROS 8035 */
@@ -240,6 +268,8 @@ static struct phy_driver at803x_driver[] = {
 	.flags		= PHY_HAS_INTERRUPT,
 	.config_aneg	= genphy_config_aneg,
 	.read_status	= genphy_read_status,
+	.ack_interrupt  = &at803x_ack_interrupt,
+	.config_intr    = &at803x_config_intr,
 	.driver		= {
 		.owner = THIS_MODULE,
 	},
-- 
1.8.5

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

* Re: [PATCH v2] phy/at8031: enable at8031 to work on interrupt mode
  2014-03-28  7:39 [PATCH v2] phy/at8031: enable at8031 to work on interrupt mode Zhao Qiang
@ 2014-03-29 22:20 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-03-29 22:20 UTC (permalink / raw)
  To: B45475
  Cc: linuxppc-dev, netdev, B07421, linux-kernel, mugunthanvnm, zonque,
	helmut.schaa, R63061

From: Zhao Qiang <B45475@freescale.com>
Date: Fri, 28 Mar 2014 15:39:41 +0800

> The at8031 can work on polling mode and interrupt mode.
> Add ack_interrupt and config intr funcs to enable
> interrupt mode for it.
> 
> Signed-off-by: Zhao Qiang <B45475@freescale.com>
> ---
> changes for v2:
> 	- when interrupt is not enabled, write 0 to interrupt enbale register
> 	- delete a inner parens not needed

Applied to net-next, thanks.

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

end of thread, other threads:[~2014-03-29 22:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-28  7:39 [PATCH v2] phy/at8031: enable at8031 to work on interrupt mode Zhao Qiang
2014-03-29 22:20 ` David Miller

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