2 * drivers/net/phy/lxt.c
4 * Driver for Intel LXT PHYs
8 * Copyright (c) 2004 Freescale Semiconductor, Inc.
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the
12 * Free Software Foundation; either version 2 of the License, or (at your
13 * option) any later version.
16 #include <linux/kernel.h>
17 #include <linux/sched.h>
18 #include <linux/string.h>
19 #include <linux/errno.h>
20 #include <linux/unistd.h>
21 #include <linux/slab.h>
22 #include <linux/interrupt.h>
23 #include <linux/init.h>
24 #include <linux/delay.h>
25 #include <linux/netdevice.h>
26 #include <linux/etherdevice.h>
27 #include <linux/skbuff.h>
28 #include <linux/spinlock.h>
30 #include <linux/module.h>
31 #include <linux/mii.h>
32 #include <linux/ethtool.h>
33 #include <linux/phy.h>
37 #include <asm/uaccess.h>
39 /* The Level one LXT970 is used by many boards */
41 #define MII_LXT970_IER 17 /* Interrupt Enable Register */
43 #define MII_LXT970_IER_IEN 0x0002
45 #define MII_LXT970_ISR 18 /* Interrupt Status Register */
47 #define MII_LXT970_CONFIG 19 /* Configuration Register */
49 /* ------------------------------------------------------------------------- */
50 /* The Level one LXT971 is used on some of my custom boards */
52 /* register definitions for the 971 */
53 #define MII_LXT971_IER 18 /* Interrupt Enable Register */
54 #define MII_LXT971_IER_IEN 0x00f2
56 #define MII_LXT971_ISR 19 /* Interrupt Status Register */
59 MODULE_DESCRIPTION("Intel LXT PHY driver");
60 MODULE_AUTHOR("Andy Fleming");
61 MODULE_LICENSE("GPL");
63 static int lxt970_ack_interrupt(struct phy_device *phydev)
67 err = phy_read(phydev, MII_BMSR);
72 err = phy_read(phydev, MII_LXT970_ISR);
80 static int lxt970_config_intr(struct phy_device *phydev)
84 if(phydev->interrupts == PHY_INTERRUPT_ENABLED)
85 err = phy_write(phydev, MII_LXT970_IER, MII_LXT970_IER_IEN);
87 err = phy_write(phydev, MII_LXT970_IER, 0);
92 static int lxt970_config_init(struct phy_device *phydev)
96 err = phy_write(phydev, MII_LXT970_CONFIG, 0);
102 static int lxt971_ack_interrupt(struct phy_device *phydev)
104 int err = phy_read(phydev, MII_LXT971_ISR);
112 static int lxt971_config_intr(struct phy_device *phydev)
116 if(phydev->interrupts == PHY_INTERRUPT_ENABLED)
117 err = phy_write(phydev, MII_LXT971_IER, MII_LXT971_IER_IEN);
119 err = phy_write(phydev, MII_LXT971_IER, 0);
124 static struct phy_driver lxt970_driver = {
125 .phy_id = 0x78100000,
127 .phy_id_mask = 0xfffffff0,
128 .features = PHY_BASIC_FEATURES,
129 .flags = PHY_HAS_INTERRUPT,
130 .config_init = lxt970_config_init,
131 .config_aneg = genphy_config_aneg,
132 .read_status = genphy_read_status,
133 .ack_interrupt = lxt970_ack_interrupt,
134 .config_intr = lxt970_config_intr,
135 .driver = { .owner = THIS_MODULE,},
138 static struct phy_driver lxt971_driver = {
139 .phy_id = 0x001378e0,
141 .phy_id_mask = 0xfffffff0,
142 .features = PHY_BASIC_FEATURES,
143 .flags = PHY_HAS_INTERRUPT,
144 .config_aneg = genphy_config_aneg,
145 .read_status = genphy_read_status,
146 .ack_interrupt = lxt971_ack_interrupt,
147 .config_intr = lxt971_config_intr,
148 .driver = { .owner = THIS_MODULE,},
151 static int __init lxt_init(void)
155 ret = phy_driver_register(&lxt970_driver);
159 ret = phy_driver_register(&lxt971_driver);
165 phy_driver_unregister(&lxt970_driver);
170 static void __exit lxt_exit(void)
172 phy_driver_unregister(&lxt970_driver);
173 phy_driver_unregister(&lxt971_driver);
176 module_init(lxt_init);
177 module_exit(lxt_exit);