phye.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-10-24 GuEe-GUI first version
  9. */
  10. #ifndef __PHYE_H__
  11. #define __PHYE_H__
  12. #include <rtthread.h>
  13. #include <drivers/ofw.h>
  14. enum rt_phye_mode
  15. {
  16. RT_PHYE_MODE_INVALID,
  17. RT_PHYE_MODE_USB_HOST,
  18. RT_PHYE_MODE_USB_HOST_LS,
  19. RT_PHYE_MODE_USB_HOST_FS,
  20. RT_PHYE_MODE_USB_HOST_HS,
  21. RT_PHYE_MODE_USB_HOST_SS,
  22. RT_PHYE_MODE_USB_DEVICE,
  23. RT_PHYE_MODE_USB_DEVICE_LS,
  24. RT_PHYE_MODE_USB_DEVICE_FS,
  25. RT_PHYE_MODE_USB_DEVICE_HS,
  26. RT_PHYE_MODE_USB_DEVICE_SS,
  27. RT_PHYE_MODE_USB_OTG,
  28. RT_PHYE_MODE_UFS_HS_A,
  29. RT_PHYE_MODE_UFS_HS_B,
  30. RT_PHYE_MODE_PCIE,
  31. RT_PHYE_MODE_ETHERNET,
  32. RT_PHYE_MODE_MIPI_DPHY,
  33. RT_PHYE_MODE_SATA,
  34. RT_PHYE_MODE_LVDS,
  35. RT_PHYE_MODE_DP,
  36. RT_PHYE_MODE_MAX,
  37. /* PCIe */
  38. RT_PHYE_MODE_PCIE_RC = RT_PHYE_MODE_MAX,
  39. RT_PHYE_MODE_PCIE_EP,
  40. RT_PHYE_MODE_PCIE_BIFURCATION,
  41. };
  42. struct rt_phye_ops;
  43. struct rt_phye
  44. {
  45. struct rt_device *dev;
  46. const struct rt_phye_ops *ops;
  47. int init_count;
  48. int power_count;
  49. struct rt_spinlock lock;
  50. };
  51. struct rt_phye_ops
  52. {
  53. rt_err_t (*init)(struct rt_phye *phye);
  54. rt_err_t (*exit)(struct rt_phye *phye);
  55. rt_err_t (*reset)(struct rt_phye *phye);
  56. rt_err_t (*power_on)(struct rt_phye *phye);
  57. rt_err_t (*power_off)(struct rt_phye *phye);
  58. rt_err_t (*set_mode)(struct rt_phye *phye, enum rt_phye_mode mode, int submode);
  59. rt_err_t (*ofw_parse)(struct rt_phye *phye, struct rt_ofw_cell_args *phye_args);
  60. };
  61. rt_err_t rt_phye_register(struct rt_phye *phye);
  62. rt_err_t rt_phye_unregister(struct rt_phye *phye);
  63. rt_err_t rt_phye_init(struct rt_phye *phye);
  64. rt_err_t rt_phye_exit(struct rt_phye *phye);
  65. rt_err_t rt_phye_reset(struct rt_phye *phye);
  66. rt_err_t rt_phye_power_on(struct rt_phye *phye);
  67. rt_err_t rt_phye_power_off(struct rt_phye *phye);
  68. rt_err_t rt_phye_set_mode(struct rt_phye *phye, enum rt_phye_mode mode, int submode);
  69. rt_inline rt_err_t rt_phye_set_mode_simple(struct rt_phye *phye, enum rt_phye_mode mode)
  70. {
  71. return rt_phye_set_mode(phye, mode, RT_PHYE_MODE_INVALID);
  72. }
  73. struct rt_phye *rt_phye_get_by_index(struct rt_device *dev, int index);
  74. struct rt_phye *rt_phye_get_by_name(struct rt_device *dev, const char *id);
  75. void rt_phye_put(struct rt_phye *phye);
  76. #endif /* __PHYE_H__ */