asix.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // SPDX-License-Identifier: GPL-2.0
  2. /* Driver for Asix PHYs
  3. *
  4. * Author: Michael Schmitz <schmitzmic@gmail.com>
  5. *
  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.
  10. *
  11. */
  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>
  18. #define PHY_ID_ASIX_AX88796B 0x003b1841
  19. MODULE_DESCRIPTION("Asix PHY driver");
  20. MODULE_AUTHOR("Michael Schmitz <schmitzmic@gmail.com>");
  21. MODULE_LICENSE("GPL");
  22. /**
  23. * asix_soft_reset - software reset the PHY via BMCR_RESET bit
  24. * @phydev: target phy_device struct
  25. *
  26. * Description: Perform a software PHY reset using the standard
  27. * BMCR_RESET bit and poll for the reset bit to be cleared.
  28. * Toggle BMCR_RESET bit off to accommodate broken AX8796B PHY implementation
  29. * such as used on the Individual Computers' X-Surf 100 Zorro card.
  30. *
  31. * Returns: 0 on success, < 0 on failure
  32. */
  33. static int asix_soft_reset(struct phy_device *phydev)
  34. {
  35. int ret;
  36. /* Asix PHY won't reset unless reset bit toggles */
  37. ret = phy_write(phydev, MII_BMCR, 0);
  38. if (ret < 0)
  39. return ret;
  40. return genphy_soft_reset(phydev);
  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. .features = PHY_BASIC_FEATURES,
  47. .soft_reset = asix_soft_reset,
  48. } };
  49. module_phy_driver(asix_driver);
  50. static struct mdio_device_id __maybe_unused asix_tbl[] = {
  51. { PHY_ID_ASIX_AX88796B, 0xfffffff0 },
  52. { }
  53. };
  54. MODULE_DEVICE_TABLE(mdio, asix_tbl);