Skip to content

Commit 77a9939

Browse files
Zhao Qiangdavem330
authored andcommitted
phy/at8031: enable at8031 to work on interrupt mode
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> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 437de07 commit 77a9939

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

drivers/net/phy/at803x.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#define AT803X_MMD_ACCESS_CONTROL 0x0D
2828
#define AT803X_MMD_ACCESS_CONTROL_DATA 0x0E
2929
#define AT803X_FUNC_DATA 0x4003
30+
#define AT803X_INER 0x0012
31+
#define AT803X_INER_INIT 0xec00
32+
#define AT803X_INSR 0x0013
3033
#define AT803X_DEBUG_ADDR 0x1D
3134
#define AT803X_DEBUG_DATA 0x1E
3235
#define AT803X_DEBUG_SYSTEM_MODE_CTRL 0x05
@@ -191,6 +194,31 @@ static int at803x_config_init(struct phy_device *phydev)
191194
return 0;
192195
}
193196

197+
static int at803x_ack_interrupt(struct phy_device *phydev)
198+
{
199+
int err;
200+
201+
err = phy_read(phydev, AT803X_INSR);
202+
203+
return (err < 0) ? err : 0;
204+
}
205+
206+
static int at803x_config_intr(struct phy_device *phydev)
207+
{
208+
int err;
209+
int value;
210+
211+
value = phy_read(phydev, AT803X_INER);
212+
213+
if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
214+
err = phy_write(phydev, AT803X_INER,
215+
value | AT803X_INER_INIT);
216+
else
217+
err = phy_write(phydev, AT803X_INER, 0);
218+
219+
return err;
220+
}
221+
194222
static struct phy_driver at803x_driver[] = {
195223
{
196224
/* ATHEROS 8035 */
@@ -240,6 +268,8 @@ static struct phy_driver at803x_driver[] = {
240268
.flags = PHY_HAS_INTERRUPT,
241269
.config_aneg = genphy_config_aneg,
242270
.read_status = genphy_read_status,
271+
.ack_interrupt = &at803x_ack_interrupt,
272+
.config_intr = &at803x_config_intr,
243273
.driver = {
244274
.owner = THIS_MODULE,
245275
},

0 commit comments

Comments
 (0)