1 // SPDX-License-Identifier: GPL-2.0
2 /* Driver for Asix PHYs
4 * Author: Michael Schmitz <schmitzmic@gmail.com>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
12 #include <linux/kernel.h>
13 #include <linux/errno.h>
14 #include <linux/init.h>
15 #include <linux/module.h>
16 #include <linux/mii.h>
17 #include <linux/phy.h>
19 #define PHY_ID_ASIX_AX88796B 0x003b1841
21 MODULE_DESCRIPTION("Asix PHY driver");
22 MODULE_AUTHOR("Michael Schmitz <schmitzmic@gmail.com>");
23 MODULE_LICENSE("GPL");
26 * asix_soft_reset - software reset the PHY via BMCR_RESET bit
27 * @phydev: target phy_device struct
29 * Description: Perform a software PHY reset using the standard
30 * BMCR_RESET bit and poll for the reset bit to be cleared.
31 * Toggle BMCR_RESET bit off to accommodate broken AX8796B PHY implementation
32 * such as used on the Individual Computers' X-Surf 100 Zorro card.
34 * Returns: 0 on success, < 0 on failure
36 static int asix_soft_reset(struct phy_device
*phydev
)
40 /* Asix PHY won't reset unless reset bit toggles */
41 ret
= phy_write(phydev
, MII_BMCR
, 0);
45 return genphy_soft_reset(phydev
);
48 static struct phy_driver asix_driver
[] = { {
49 .phy_id
= PHY_ID_ASIX_AX88796B
,
50 .name
= "Asix Electronics AX88796B",
51 .phy_id_mask
= 0xfffffff0,
52 .features
= PHY_BASIC_FEATURES
,
53 .soft_reset
= asix_soft_reset
,
56 module_phy_driver(asix_driver
);
58 static struct mdio_device_id __maybe_unused asix_tbl
[] = {
59 { PHY_ID_ASIX_AX88796B
, 0xfffffff0 },
63 MODULE_DEVICE_TABLE(mdio
, asix_tbl
);