2 * Driver for Micrel/Kendin PHYs
4 * Copyright (c) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
13 #include <linux/module.h>
14 #include <linux/delay.h>
15 #include <linux/skbuff.h>
16 #include <linux/phy.h>
18 #define KSZ_REG_INT_CTRL 0x1b
20 #define KSZ_INT_LU_EN (1 << 8) /* enable Link Up interrupt */
21 #define KSZ_INT_RF_EN (1 << 9) /* enable Remote Fault interrupt */
22 #define KSZ_INT_LD_EN (1 << 10) /* enable Link Down interrupt */
24 #define KSZ_INT_INIT (KSZ_INT_LU_EN | KSZ_INT_LD_EN)
26 static int ksz8041_ack_interrupt(struct phy_device
*phydev
)
30 err
= phy_read(phydev
, KSZ_REG_INT_CTRL
);
32 return (err
< 0) ? err
: 0;
35 static int ksz8041_config_intr(struct phy_device
*phydev
)
39 if (phydev
->interrupts
== PHY_INTERRUPT_ENABLED
)
40 err
= phy_write(phydev
, KSZ_REG_INT_CTRL
,
43 err
= phy_write(phydev
, KSZ_REG_INT_CTRL
, 0);
48 static struct phy_driver ksz8041_phy_driver
= {
50 .name
= "Micrel KSZ8041",
51 .phy_id_mask
= 0x001fffff,
52 .features
= PHY_BASIC_FEATURES
,
53 .flags
= PHY_HAS_INTERRUPT
,
54 .config_aneg
= genphy_config_aneg
,
55 .read_status
= genphy_read_status
,
56 .ack_interrupt
= ksz8041_ack_interrupt
,
57 .config_intr
= ksz8041_config_intr
,
63 static int __init
micrel_phy_init(void)
65 return phy_driver_register(&ksz8041_phy_driver
);
68 static void __exit
micrel_phy_exit(void)
70 phy_driver_unregister(&ksz8041_phy_driver
);
74 module_init(micrel_phy_init
);
75 module_exit(micrel_phy_exit
);
77 subsys_initcall(micrel_phy_init
);
80 MODULE_DESCRIPTION("Micrel/Kendin PHY driver");
81 MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
82 MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org>");
83 MODULE_LICENSE("GPL v2");