pinctrl-rtd.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (c) 2023 Realtek Semiconductor Corp.
  4. */
  5. #define NA 0xffffffff
  6. #define PADDRI_4_8 1
  7. #define PADDRI_2_4 0
  8. struct rtd_pin_group_desc {
  9. const char *name;
  10. const unsigned int *pins;
  11. unsigned int num_pins;
  12. };
  13. struct rtd_pin_func_desc {
  14. const char *name;
  15. const char * const *groups;
  16. unsigned int num_groups;
  17. };
  18. struct rtd_pin_mux_desc {
  19. const char *name;
  20. u32 mux_value;
  21. };
  22. struct rtd_pin_config_desc {
  23. const char *name;
  24. unsigned int reg_offset;
  25. unsigned int base_bit;
  26. unsigned int pud_en_offset;
  27. unsigned int pud_sel_offset;
  28. unsigned int curr_offset;
  29. unsigned int smt_offset;
  30. unsigned int power_offset;
  31. unsigned int curr_type;
  32. };
  33. struct rtd_pin_sconfig_desc {
  34. const char *name;
  35. unsigned int reg_offset;
  36. unsigned int dcycle_offset;
  37. unsigned int dcycle_maskbits;
  38. unsigned int ndrive_offset;
  39. unsigned int ndrive_maskbits;
  40. unsigned int pdrive_offset;
  41. unsigned int pdrive_maskbits;
  42. };
  43. struct rtd_pin_desc {
  44. const char *name;
  45. unsigned int mux_offset;
  46. u32 mux_mask;
  47. const struct rtd_pin_mux_desc *functions;
  48. };
  49. struct rtd_pin_reg_list {
  50. unsigned int reg_offset;
  51. unsigned int val;
  52. };
  53. #define SHIFT_LEFT(_val, _shift) ((_val) << (_shift))
  54. #define RTK_PIN_MUX(_name, _mux_off, _mux_mask, ...) \
  55. { \
  56. .name = # _name, \
  57. .mux_offset = _mux_off, \
  58. .mux_mask = _mux_mask, \
  59. .functions = (const struct rtd_pin_mux_desc []) { \
  60. __VA_ARGS__, { } \
  61. }, \
  62. }
  63. #define RTK_PIN_CONFIG(_name, _reg_off, _base_bit, _pud_en_off, \
  64. _pud_sel_off, _curr_off, _smt_off, _pow_off, _curr_type) \
  65. { \
  66. .name = # _name, \
  67. .reg_offset = _reg_off, \
  68. .base_bit = _base_bit, \
  69. .pud_en_offset = _pud_en_off, \
  70. .pud_sel_offset = _pud_sel_off, \
  71. .curr_offset = _curr_off, \
  72. .smt_offset = _smt_off, \
  73. .power_offset = _pow_off, \
  74. .curr_type = _curr_type, \
  75. }
  76. #define RTK_PIN_SCONFIG(_name, _reg_off, _d_offset, _d_mask, \
  77. _n_offset, _n_mask, _p_offset, _p_mask) \
  78. { \
  79. .name = # _name, \
  80. .reg_offset = _reg_off, \
  81. .dcycle_offset = _d_offset, \
  82. .dcycle_maskbits = _d_mask, \
  83. .ndrive_offset = _n_offset, \
  84. .ndrive_maskbits = _n_mask, \
  85. .pdrive_offset = _p_offset, \
  86. .pdrive_maskbits = _p_mask, \
  87. }
  88. #define RTK_PIN_FUNC(_mux_val, _name) \
  89. { \
  90. .name = _name, \
  91. .mux_value = _mux_val, \
  92. }
  93. struct rtd_pinctrl_desc {
  94. const struct pinctrl_pin_desc *pins;
  95. unsigned int num_pins;
  96. const struct rtd_pin_group_desc *groups;
  97. unsigned int num_groups;
  98. const struct rtd_pin_func_desc *functions;
  99. unsigned int num_functions;
  100. const struct rtd_pin_desc *muxes;
  101. unsigned int num_muxes;
  102. const struct rtd_pin_config_desc *configs;
  103. unsigned int num_configs;
  104. const struct rtd_pin_sconfig_desc *sconfigs;
  105. unsigned int num_sconfigs;
  106. struct rtd_pin_reg_list *lists;
  107. unsigned int num_regs;
  108. };
  109. int rtd_pinctrl_probe(struct platform_device *pdev, const struct rtd_pinctrl_desc *desc);