xref: /openbmc/linux/drivers/net/phy/ax88796b.c (revision 3a35093a)
1 // SPDX-License-Identifier: GPL-2.0+
2 /* Driver for Asix PHYs
3  *
4  * Author: Michael Schmitz <schmitzmic@gmail.com>
5  */
6 #include <linux/kernel.h>
7 #include <linux/errno.h>
8 #include <linux/init.h>
9 #include <linux/module.h>
10 #include <linux/mii.h>
11 #include <linux/phy.h>
12 
13 #define PHY_ID_ASIX_AX88796B		0x003b1841
14 
15 MODULE_DESCRIPTION("Asix PHY driver");
16 MODULE_AUTHOR("Michael Schmitz <schmitzmic@gmail.com>");
17 MODULE_LICENSE("GPL");
18 
19 /**
20  * asix_soft_reset - software reset the PHY via BMCR_RESET bit
21  * @phydev: target phy_device struct
22  *
23  * Description: Perform a software PHY reset using the standard
24  * BMCR_RESET bit and poll for the reset bit to be cleared.
25  * Toggle BMCR_RESET bit off to accommodate broken AX8796B PHY implementation
26  * such as used on the Individual Computers' X-Surf 100 Zorro card.
27  *
28  * Returns: 0 on success, < 0 on failure
29  */
30 static int asix_soft_reset(struct phy_device *phydev)
31 {
32 	int ret;
33 
34 	/* Asix PHY won't reset unless reset bit toggles */
35 	ret = phy_write(phydev, MII_BMCR, 0);
36 	if (ret < 0)
37 		return ret;
38 
39 	return genphy_soft_reset(phydev);
40 }
41 
42 static struct phy_driver asix_driver[] = { {
43 	.phy_id		= PHY_ID_ASIX_AX88796B,
44 	.name		= "Asix Electronics AX88796B",
45 	.phy_id_mask	= 0xfffffff0,
46 	/* PHY_BASIC_FEATURES */
47 	.soft_reset	= asix_soft_reset,
48 } };
49 
50 module_phy_driver(asix_driver);
51 
52 static struct mdio_device_id __maybe_unused asix_tbl[] = {
53 	{ PHY_ID_ASIX_AX88796B, 0xfffffff0 },
54 	{ }
55 };
56 
57 MODULE_DEVICE_TABLE(mdio, asix_tbl);
58