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/config.h>
17 #include <linux/kernel.h>
18 #include <linux/sched.h>
19 #include <linux/string.h>
20 #include <linux/errno.h>
21 #include <linux/unistd.h>
22 #include <linux/slab.h>
23 #include <linux/interrupt.h>
24 #include <linux/init.h>
25 #include <linux/delay.h>
26 #include <linux/netdevice.h>
27 #include <linux/etherdevice.h>
28 #include <linux/skbuff.h>
29 #include <linux/spinlock.h>
31 #include <linux/module.h>
32 #include <linux/version.h>
33 #include <linux/mii.h>
34 #include <linux/ethtool.h>
35 #include <linux/phy.h>
39 #include <asm/uaccess.h>
41 /* The Level one LXT970 is used by many boards */
43 #define MII_LXT970_IER 17 /* Interrupt Enable Register */
45 #define MII_LXT970_IER_IEN 0x0002
47 #define MII_LXT970_ISR 18 /* Interrupt Status Register */
49 #define MII_LXT970_CONFIG 19 /* Configuration Register */
51 /* ------------------------------------------------------------------------- */
52 /* The Level one LXT971 is used on some of my custom boards */
54 /* register definitions for the 971 */
55 #define MII_LXT971_IER 18 /* Interrupt Enable Register */
56 #define MII_LXT971_IER_IEN 0x00f2
58 #define MII_LXT971_ISR 19 /* Interrupt Status Register */
61 MODULE_DESCRIPTION("Intel LXT PHY driver");
62 MODULE_AUTHOR("Andy Fleming");
63 MODULE_LICENSE("GPL");
65 static int lxt970_ack_interrupt(struct phy_device *phydev)
69 err = phy_read(phydev, MII_BMSR);
74 err = phy_read(phydev, MII_LXT970_ISR);
82 static int lxt970_config_intr(struct phy_device *phydev)
86 if(phydev->interrupts == PHY_INTERRUPT_ENABLED)
87 err = phy_write(phydev, MII_LXT970_IER, MII_LXT970_IER_IEN);
89 err = phy_write(phydev, MII_LXT970_IER, 0);
94 static int lxt970_config_init(struct phy_device *phydev)
98 err = phy_write(phydev, MII_LXT970_CONFIG, 0);
104 static int lxt971_ack_interrupt(struct phy_device *phydev)
106 int err = phy_read(phydev, MII_LXT971_ISR);
114 static int lxt971_config_intr(struct phy_device *phydev)
118 if(phydev->interrupts == PHY_INTERRUPT_ENABLED)
119 err = phy_write(phydev, MII_LXT971_IER, MII_LXT971_IER_IEN);
121 err = phy_write(phydev, MII_LXT971_IER, 0);
126 static struct phy_driver lxt970_driver = {
127 .phy_id = 0x07810000,
129 .phy_id_mask = 0x0fffffff,
130 .features = PHY_BASIC_FEATURES,
131 .flags = PHY_HAS_INTERRUPT,
132 .config_init = lxt970_config_init,
133 .config_aneg = genphy_config_aneg,
134 .read_status = genphy_read_status,
135 .ack_interrupt = lxt970_ack_interrupt,
136 .config_intr = lxt970_config_intr,
137 .driver = { .owner = THIS_MODULE,},
140 static struct phy_driver lxt971_driver = {
141 .phy_id = 0x0001378e,
143 .phy_id_mask = 0x0fffffff,
144 .features = PHY_BASIC_FEATURES,
145 .flags = PHY_HAS_INTERRUPT,
146 .config_aneg = genphy_config_aneg,
147 .read_status = genphy_read_status,
148 .ack_interrupt = lxt971_ack_interrupt,
149 .config_intr = lxt971_config_intr,
150 .driver = { .owner = THIS_MODULE,},
153 static int __init lxt_init(void)
157 ret = phy_driver_register(&lxt970_driver);
161 ret = phy_driver_register(&lxt971_driver);
167 phy_driver_unregister(&lxt970_driver);
172 static void __exit lxt_exit(void)
174 phy_driver_unregister(&lxt970_driver);
175 phy_driver_unregister(&lxt971_driver);
178 module_init(lxt_init);
179 module_exit(lxt_exit);