18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+ 28c2ecf20Sopenharmony_ci/* Driver for Asix PHYs 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Author: Michael Schmitz <schmitzmic@gmail.com> 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci#include <linux/kernel.h> 78c2ecf20Sopenharmony_ci#include <linux/errno.h> 88c2ecf20Sopenharmony_ci#include <linux/init.h> 98c2ecf20Sopenharmony_ci#include <linux/module.h> 108c2ecf20Sopenharmony_ci#include <linux/mii.h> 118c2ecf20Sopenharmony_ci#include <linux/phy.h> 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define PHY_ID_ASIX_AX88796B 0x003b1841 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Asix PHY driver"); 168c2ecf20Sopenharmony_ciMODULE_AUTHOR("Michael Schmitz <schmitzmic@gmail.com>"); 178c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL"); 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/** 208c2ecf20Sopenharmony_ci * asix_soft_reset - software reset the PHY via BMCR_RESET bit 218c2ecf20Sopenharmony_ci * @phydev: target phy_device struct 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci * Description: Perform a software PHY reset using the standard 248c2ecf20Sopenharmony_ci * BMCR_RESET bit and poll for the reset bit to be cleared. 258c2ecf20Sopenharmony_ci * Toggle BMCR_RESET bit off to accommodate broken AX8796B PHY implementation 268c2ecf20Sopenharmony_ci * such as used on the Individual Computers' X-Surf 100 Zorro card. 278c2ecf20Sopenharmony_ci * 288c2ecf20Sopenharmony_ci * Returns: 0 on success, < 0 on failure 298c2ecf20Sopenharmony_ci */ 308c2ecf20Sopenharmony_cistatic int asix_soft_reset(struct phy_device *phydev) 318c2ecf20Sopenharmony_ci{ 328c2ecf20Sopenharmony_ci int ret; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci /* Asix PHY won't reset unless reset bit toggles */ 358c2ecf20Sopenharmony_ci ret = phy_write(phydev, MII_BMCR, 0); 368c2ecf20Sopenharmony_ci if (ret < 0) 378c2ecf20Sopenharmony_ci return ret; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci return genphy_soft_reset(phydev); 408c2ecf20Sopenharmony_ci} 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistatic struct phy_driver asix_driver[] = { { 438c2ecf20Sopenharmony_ci .phy_id = PHY_ID_ASIX_AX88796B, 448c2ecf20Sopenharmony_ci .name = "Asix Electronics AX88796B", 458c2ecf20Sopenharmony_ci .phy_id_mask = 0xfffffff0, 468c2ecf20Sopenharmony_ci /* PHY_BASIC_FEATURES */ 478c2ecf20Sopenharmony_ci .soft_reset = asix_soft_reset, 488c2ecf20Sopenharmony_ci} }; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_cimodule_phy_driver(asix_driver); 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_cistatic struct mdio_device_id __maybe_unused asix_tbl[] = { 538c2ecf20Sopenharmony_ci { PHY_ID_ASIX_AX88796B, 0xfffffff0 }, 548c2ecf20Sopenharmony_ci { } 558c2ecf20Sopenharmony_ci}; 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(mdio, asix_tbl); 58