2 * Driver for Aquantia PHY
4 * Author: Shaohui Xie <Shaohui.Xie@freescale.com>
6 * Copyright 2015 Freescale Semiconductor, Inc.
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of any
10 * kind, whether express or implied.
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/delay.h>
16 #include <linux/mii.h>
17 #include <linux/ethtool.h>
18 #include <linux/phy.h>
19 #include <linux/mdio.h>
21 #define PHY_ID_AQ1202 0x03a1b445
22 #define PHY_ID_AQ2104 0x03a1b460
23 #define PHY_ID_AQR105 0x03a1b4a2
24 #define PHY_ID_AQR106 0x03a1b4d0
25 #define PHY_ID_AQR107 0x03a1b4e0
26 #define PHY_ID_AQR405 0x03a1b4b0
28 static int aquantia_config_aneg(struct phy_device *phydev)
30 linkmode_copy(phydev->supported, phy_10gbit_features);
31 linkmode_copy(phydev->advertising, phydev->supported);
36 static int aquantia_config_intr(struct phy_device *phydev)
40 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
41 err = phy_write_mmd(phydev, MDIO_MMD_AN, 0xd401, 1);
45 err = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xff00, 1);
49 err = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xff01, 0x1001);
51 err = phy_write_mmd(phydev, MDIO_MMD_AN, 0xd401, 0);
55 err = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xff00, 0);
59 err = phy_write_mmd(phydev, MDIO_MMD_VEND1, 0xff01, 0);
65 static int aquantia_ack_interrupt(struct phy_device *phydev)
69 reg = phy_read_mmd(phydev, MDIO_MMD_AN, 0xcc01);
70 return (reg < 0) ? reg : 0;
73 static int aquantia_read_status(struct phy_device *phydev)
77 reg = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1);
78 reg = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_STAT1);
79 if (reg & MDIO_STAT1_LSTATUS)
84 reg = phy_read_mmd(phydev, MDIO_MMD_AN, 0xc800);
86 reg = phy_read_mmd(phydev, MDIO_MMD_AN, 0xc800);
90 phydev->speed = SPEED_2500;
93 phydev->speed = SPEED_1000;
96 phydev->speed = SPEED_100;
100 phydev->speed = SPEED_10000;
103 phydev->duplex = DUPLEX_FULL;
108 static struct phy_driver aquantia_driver[] = {
110 .phy_id = PHY_ID_AQ1202,
111 .phy_id_mask = 0xfffffff0,
112 .name = "Aquantia AQ1202",
113 .features = PHY_10GBIT_FULL_FEATURES,
114 .aneg_done = genphy_c45_aneg_done,
115 .config_aneg = aquantia_config_aneg,
116 .config_intr = aquantia_config_intr,
117 .ack_interrupt = aquantia_ack_interrupt,
118 .read_status = aquantia_read_status,
121 .phy_id = PHY_ID_AQ2104,
122 .phy_id_mask = 0xfffffff0,
123 .name = "Aquantia AQ2104",
124 .features = PHY_10GBIT_FULL_FEATURES,
125 .aneg_done = genphy_c45_aneg_done,
126 .config_aneg = aquantia_config_aneg,
127 .config_intr = aquantia_config_intr,
128 .ack_interrupt = aquantia_ack_interrupt,
129 .read_status = aquantia_read_status,
132 .phy_id = PHY_ID_AQR105,
133 .phy_id_mask = 0xfffffff0,
134 .name = "Aquantia AQR105",
135 .features = PHY_10GBIT_FULL_FEATURES,
136 .aneg_done = genphy_c45_aneg_done,
137 .config_aneg = aquantia_config_aneg,
138 .config_intr = aquantia_config_intr,
139 .ack_interrupt = aquantia_ack_interrupt,
140 .read_status = aquantia_read_status,
143 .phy_id = PHY_ID_AQR106,
144 .phy_id_mask = 0xfffffff0,
145 .name = "Aquantia AQR106",
146 .features = PHY_10GBIT_FULL_FEATURES,
147 .aneg_done = genphy_c45_aneg_done,
148 .config_aneg = aquantia_config_aneg,
149 .config_intr = aquantia_config_intr,
150 .ack_interrupt = aquantia_ack_interrupt,
151 .read_status = aquantia_read_status,
154 .phy_id = PHY_ID_AQR107,
155 .phy_id_mask = 0xfffffff0,
156 .name = "Aquantia AQR107",
157 .features = PHY_10GBIT_FULL_FEATURES,
158 .aneg_done = genphy_c45_aneg_done,
159 .config_aneg = aquantia_config_aneg,
160 .config_intr = aquantia_config_intr,
161 .ack_interrupt = aquantia_ack_interrupt,
162 .read_status = aquantia_read_status,
165 .phy_id = PHY_ID_AQR405,
166 .phy_id_mask = 0xfffffff0,
167 .name = "Aquantia AQR405",
168 .features = PHY_10GBIT_FULL_FEATURES,
169 .aneg_done = genphy_c45_aneg_done,
170 .config_aneg = aquantia_config_aneg,
171 .config_intr = aquantia_config_intr,
172 .ack_interrupt = aquantia_ack_interrupt,
173 .read_status = aquantia_read_status,
177 module_phy_driver(aquantia_driver);
179 static struct mdio_device_id __maybe_unused aquantia_tbl[] = {
180 { PHY_ID_AQ1202, 0xfffffff0 },
181 { PHY_ID_AQ2104, 0xfffffff0 },
182 { PHY_ID_AQR105, 0xfffffff0 },
183 { PHY_ID_AQR106, 0xfffffff0 },
184 { PHY_ID_AQR107, 0xfffffff0 },
185 { PHY_ID_AQR405, 0xfffffff0 },
189 MODULE_DEVICE_TABLE(mdio, aquantia_tbl);
191 MODULE_DESCRIPTION("Aquantia PHY driver");
192 MODULE_AUTHOR("Shaohui Xie <Shaohui.Xie@freescale.com>");
193 MODULE_LICENSE("GPL v2");