2 * drivers/net/phy/smsc.c
6 * Author: Herbert Valerio Riedel
8 * Copyright (c) 2006 Herbert Valerio Riedel <hvr@gnu.org>
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.
15 * Support added for SMSC LAN8187 and LAN8700 by steve.glendinning@smsc.com
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/mii.h>
22 #include <linux/ethtool.h>
23 #include <linux/phy.h>
24 #include <linux/netdevice.h>
26 #define MII_LAN83C185_ISF 29 /* Interrupt Source Flags */
27 #define MII_LAN83C185_IM 30 /* Interrupt Mask */
29 #define MII_LAN83C185_ISF_INT1 (1<<1) /* Auto-Negotiation Page Received */
30 #define MII_LAN83C185_ISF_INT2 (1<<2) /* Parallel Detection Fault */
31 #define MII_LAN83C185_ISF_INT3 (1<<3) /* Auto-Negotiation LP Ack */
32 #define MII_LAN83C185_ISF_INT4 (1<<4) /* Link Down */
33 #define MII_LAN83C185_ISF_INT5 (1<<5) /* Remote Fault Detected */
34 #define MII_LAN83C185_ISF_INT6 (1<<6) /* Auto-Negotiation complete */
35 #define MII_LAN83C185_ISF_INT7 (1<<7) /* ENERGYON */
37 #define MII_LAN83C185_ISF_INT_ALL (0x0e)
39 #define MII_LAN83C185_ISF_INT_PHYLIB_EVENTS \
40 (MII_LAN83C185_ISF_INT6 | MII_LAN83C185_ISF_INT4)
43 static int smsc_phy_config_intr(struct phy_device *phydev)
45 int rc = phy_write (phydev, MII_LAN83C185_IM,
46 ((PHY_INTERRUPT_ENABLED == phydev->interrupts)
47 ? MII_LAN83C185_ISF_INT_PHYLIB_EVENTS
50 return rc < 0 ? rc : 0;
53 static int smsc_phy_ack_interrupt(struct phy_device *phydev)
55 int rc = phy_read (phydev, MII_LAN83C185_ISF);
57 return rc < 0 ? rc : 0;
60 static int smsc_phy_config_init(struct phy_device *phydev)
62 return smsc_phy_ack_interrupt (phydev);
66 static struct phy_driver lan83c185_driver = {
67 .phy_id = 0x0007c0a0, /* OUI=0x00800f, Model#=0x0a */
68 .phy_id_mask = 0xfffffff0,
69 .name = "SMSC LAN83C185",
71 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
72 | SUPPORTED_Asym_Pause),
73 .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
76 .config_aneg = genphy_config_aneg,
77 .read_status = genphy_read_status,
78 .config_init = smsc_phy_config_init,
81 .ack_interrupt = smsc_phy_ack_interrupt,
82 .config_intr = smsc_phy_config_intr,
84 .driver = { .owner = THIS_MODULE, }
87 static struct phy_driver lan8187_driver = {
88 .phy_id = 0x0007c0b0, /* OUI=0x00800f, Model#=0x0b */
89 .phy_id_mask = 0xfffffff0,
90 .name = "SMSC LAN8187",
92 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
93 | SUPPORTED_Asym_Pause),
94 .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
97 .config_aneg = genphy_config_aneg,
98 .read_status = genphy_read_status,
99 .config_init = smsc_phy_config_init,
102 .ack_interrupt = smsc_phy_ack_interrupt,
103 .config_intr = smsc_phy_config_intr,
105 .driver = { .owner = THIS_MODULE, }
108 static struct phy_driver lan8700_driver = {
109 .phy_id = 0x0007c0c0, /* OUI=0x00800f, Model#=0x0c */
110 .phy_id_mask = 0xfffffff0,
111 .name = "SMSC LAN8700",
113 .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause
114 | SUPPORTED_Asym_Pause),
115 .flags = PHY_HAS_INTERRUPT | PHY_HAS_MAGICANEG,
117 /* basic functions */
118 .config_aneg = genphy_config_aneg,
119 .read_status = genphy_read_status,
120 .config_init = smsc_phy_config_init,
123 .ack_interrupt = smsc_phy_ack_interrupt,
124 .config_intr = smsc_phy_config_intr,
126 .driver = { .owner = THIS_MODULE, }
129 static int __init smsc_init(void)
133 ret = phy_driver_register (&lan83c185_driver);
137 ret = phy_driver_register (&lan8187_driver);
141 ret = phy_driver_register (&lan8700_driver);
148 phy_driver_unregister (&lan8187_driver);
150 phy_driver_unregister (&lan83c185_driver);
155 static void __exit smsc_exit(void)
157 phy_driver_unregister (&lan8700_driver);
158 phy_driver_unregister (&lan8187_driver);
159 phy_driver_unregister (&lan83c185_driver);
162 MODULE_DESCRIPTION("SMSC PHY driver");
163 MODULE_AUTHOR("Herbert Valerio Riedel");
164 MODULE_LICENSE("GPL");
166 module_init(smsc_init);
167 module_exit(smsc_exit);