[PATCH] USB: Rename hcd->hub_suspend to hcd->bus_suspend
[linux/fpc-iii.git] / drivers / net / phy / lxt.c
blob4c840448ec8686918728023999bfcf669169de21
1 /*
2 * drivers/net/phy/lxt.c
4 * Driver for Intel LXT PHYs
6 * Author: Andy Fleming
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>
30 #include <linux/mm.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>
37 #include <asm/io.h>
38 #include <asm/irq.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)
67 int err;
69 err = phy_read(phydev, MII_BMSR);
71 if (err < 0)
72 return err;
74 err = phy_read(phydev, MII_LXT970_ISR);
76 if (err < 0)
77 return err;
79 return 0;
82 static int lxt970_config_intr(struct phy_device *phydev)
84 int err;
86 if(phydev->interrupts == PHY_INTERRUPT_ENABLED)
87 err = phy_write(phydev, MII_LXT970_IER, MII_LXT970_IER_IEN);
88 else
89 err = phy_write(phydev, MII_LXT970_IER, 0);
91 return err;
94 static int lxt970_config_init(struct phy_device *phydev)
96 int err;
98 err = phy_write(phydev, MII_LXT970_CONFIG, 0);
100 return err;
104 static int lxt971_ack_interrupt(struct phy_device *phydev)
106 int err = phy_read(phydev, MII_LXT971_ISR);
108 if (err < 0)
109 return err;
111 return 0;
114 static int lxt971_config_intr(struct phy_device *phydev)
116 int err;
118 if(phydev->interrupts == PHY_INTERRUPT_ENABLED)
119 err = phy_write(phydev, MII_LXT971_IER, MII_LXT971_IER_IEN);
120 else
121 err = phy_write(phydev, MII_LXT971_IER, 0);
123 return err;
126 static struct phy_driver lxt970_driver = {
127 .phy_id = 0x07810000,
128 .name = "LXT970",
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,
142 .name = "LXT971",
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)
155 int ret;
157 ret = phy_driver_register(&lxt970_driver);
158 if (ret)
159 goto err1;
161 ret = phy_driver_register(&lxt971_driver);
162 if (ret)
163 goto err2;
164 return 0;
166 err2:
167 phy_driver_unregister(&lxt970_driver);
168 err1:
169 return ret;
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);