ax88796b.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #define PHY_ID_ASIX_AX88796B 0x003b1841
  13. MODULE_DESCRIPTION("Asix PHY driver");
  14. MODULE_AUTHOR("Michael Schmitz <schmitzmic@gmail.com>");
  15. MODULE_LICENSE("GPL");
  16. /**
  17. * asix_soft_reset - software reset the PHY via BMCR_RESET bit
  18. * @phydev: target phy_device struct
  19. *
  20. * Description: Perform a software PHY reset using the standard
  21. * BMCR_RESET bit and poll for the reset bit to be cleared.
  22. * Toggle BMCR_RESET bit off to accommodate broken AX8796B PHY implementation
  23. * such as used on the Individual Computers' X-Surf 100 Zorro card.
  24. *
  25. * Returns: 0 on success, < 0 on failure
  26. */
  27. static int asix_soft_reset(struct phy_device *phydev)
  28. {
  29. int ret;
  30. /* Asix PHY won't reset unless reset bit toggles */
  31. ret = phy_write(phydev, MII_BMCR, 0);
  32. if (ret < 0)
  33. return ret;
  34. return genphy_soft_reset(phydev);
  35. }
  36. static struct phy_driver asix_driver[] = { {
  37. .phy_id = PHY_ID_ASIX_AX88796B,
  38. .name = "Asix Electronics AX88796B",
  39. .phy_id_mask = 0xfffffff0,
  40. /* PHY_BASIC_FEATURES */
  41. .soft_reset = asix_soft_reset,
  42. } };
  43. module_phy_driver(asix_driver);
  44. static struct mdio_device_id __maybe_unused asix_tbl[] = {
  45. { PHY_ID_ASIX_AX88796B, 0xfffffff0 },
  46. { }
  47. };
  48. MODULE_DEVICE_TABLE(mdio, asix_tbl);