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/delay.h>
14 #include <linux/skbuff.h>
15 #include <linux/phy.h>
17 #define KSZ_REG_INT_CTRL 0x1b
19 #define KSZ_INT_LU_EN (1 << 8) /* enable Link Up interrupt */
20 #define KSZ_INT_RF_EN (1 << 9) /* enable Remote Fault interrupt */
21 #define KSZ_INT_LD_EN (1 << 10) /* enable Link Down interrupt */
23 #define KSZ_INT_INIT (KSZ_INT_LU_EN | KSZ_INT_LD_EN)
25 static int ksz8041_ack_interrupt(struct phy_device
*phydev
)
29 err
= phy_read(phydev
, KSZ_REG_INT_CTRL
);
31 return (err
< 0) ? err
: 0;
34 static int ksz8041_config_intr(struct phy_device
*phydev
)
38 if (phydev
->interrupts
== PHY_INTERRUPT_ENABLED
)
39 err
= phy_write(phydev
, KSZ_REG_INT_CTRL
,
42 err
= phy_write(phydev
, KSZ_REG_INT_CTRL
, 0);
47 static struct phy_driver ksz8041_phy_driver
= {
49 .name
= "Micrel KSZ8041",
50 .phy_id_mask
= 0x001fffff,
51 .features
= PHY_BASIC_FEATURES
,
52 .flags
= PHY_HAS_INTERRUPT
,
53 .config_aneg
= genphy_config_aneg
,
54 .read_status
= genphy_read_status
,
55 .ack_interrupt
= ksz8041_ack_interrupt
,
56 .config_intr
= ksz8041_config_intr
,
62 static int __init
micrel_phy_init(void)
64 return phy_driver_register(&ksz8041_phy_driver
);
67 static void __exit
micrel_phy_exit(void)
69 phy_driver_unregister(&ksz8041_phy_driver
);
73 module_init(micrel_phy_init
);
74 module_exit(micrel_phy_exit
);
76 subsys_initcall(micrel_phy_init
);
79 MODULE_DESCRIPTION("Micrel/Kendin PHY driver");
80 MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org>");
81 MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org>");
82 MODULE_LICENSE("GPL v2");