chry_phy_dp83848.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2024, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "chry_phy.h"
  7. #define DP83848_PHYSTS 0x10 /* PHY Status Register */
  8. #define DP83848_PHYSTS_LINK_STATUS (0x0001U)
  9. /*
  10. * SPEED_STATUS (RO)
  11. *
  12. * Speed10:
  13. * This bit indicates the status of the speed and is determined from Auto-Negotiation or Forced
  14. * Modes.
  15. * 1 = 10 Mb/s mode.
  16. * 0 = 100 Mb/s mode.
  17. * Note: This bit is only valid if Auto-Negotiation is enabled and complete and there is a valid
  18. * link or if Auto-Negotiation is disabled and there is a valid link.
  19. */
  20. #define DP83848_PHYSTS_SPEED_STATUS (0x0002U)
  21. #define DP83848_PHYSTS_DUPLEX_STATUS (0x0004U)
  22. void dp83848_phy_init(struct chry_phy_device *phydev, struct chry_phy_config *config)
  23. {
  24. }
  25. void dp83848_phy_get_status(struct chry_phy_device *phydev, struct chry_phy_status *status)
  26. {
  27. uint16_t regval;
  28. regval = phydev->mdio_read(phydev, phydev->phy_addr, DP83848_PHYSTS);
  29. status->link = regval & DP83848_PHYSTS_LINK_STATUS;
  30. if (status->link) {
  31. status->duplex = regval & DP83848_PHYSTS_DUPLEX_STATUS;
  32. status->speed = (regval & DP83848_PHYSTS_SPEED_STATUS) ? 10 : 100;
  33. }
  34. }
  35. const struct chry_phy_driver dp83848_driver = {
  36. .phy_id = 0x20005C90,
  37. .phy_id_mask = 0xFFFFFFF0,
  38. .phy_name = "DP83848",
  39. .phy_desc = "TI DP83848 Ethernet PHY",
  40. .phy_init = dp83848_phy_init,
  41. .phy_get_status = dp83848_phy_get_status,
  42. };