pinctrl-aspeed.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Copyright (C) 2016 IBM Corp.
  4. */
  5. #ifndef PINCTRL_ASPEED
  6. #define PINCTRL_ASPEED
  7. #include <linux/pinctrl/pinctrl.h>
  8. #include <linux/pinctrl/pinmux.h>
  9. #include <linux/pinctrl/pinconf.h>
  10. #include <linux/pinctrl/pinconf-generic.h>
  11. #include <linux/regmap.h>
  12. #include "pinmux-aspeed.h"
  13. /**
  14. * @param The pinconf parameter type
  15. * @pins The pin range this config struct covers, [low, high]
  16. * @reg The register housing the configuration bits
  17. * @mask The mask to select the bits of interest in @reg
  18. */
  19. struct aspeed_pin_config {
  20. enum pin_config_param param;
  21. unsigned int pins[2];
  22. unsigned int reg;
  23. u32 mask;
  24. };
  25. #define ASPEED_PINCTRL_PIN(name_) \
  26. [name_] = { \
  27. .number = name_, \
  28. .name = #name_, \
  29. .drv_data = (void *) &(PIN_SYM(name_)) \
  30. }
  31. #define ASPEED_SB_PINCONF(param_, pin0_, pin1_, reg_, bit_) { \
  32. .param = param_, \
  33. .pins = {pin0_, pin1_}, \
  34. .reg = reg_, \
  35. .mask = BIT_MASK(bit_) \
  36. }
  37. #define ASPEED_PULL_DOWN_PINCONF(pin_, reg_, bit_) \
  38. ASPEED_SB_PINCONF(PIN_CONFIG_BIAS_PULL_DOWN, pin_, pin_, reg_, bit_), \
  39. ASPEED_SB_PINCONF(PIN_CONFIG_BIAS_DISABLE, pin_, pin_, reg_, bit_)
  40. #define ASPEED_PULL_UP_PINCONF(pin_, reg_, bit_) \
  41. ASPEED_SB_PINCONF(PIN_CONFIG_BIAS_PULL_UP, pin_, pin_, reg_, bit_), \
  42. ASPEED_SB_PINCONF(PIN_CONFIG_BIAS_DISABLE, pin_, pin_, reg_, bit_)
  43. /*
  44. * Aspeed pin configuration description.
  45. *
  46. * @param: pinconf configuration parameter
  47. * @arg: The supported argument for @param, or -1 if any value is supported
  48. * @val: The register value to write to configure @arg for @param
  49. * @mask: The bitfield mask for @val
  50. *
  51. * The map is to be used in conjunction with the configuration array supplied
  52. * by the driver implementation.
  53. */
  54. struct aspeed_pin_config_map {
  55. enum pin_config_param param;
  56. s32 arg;
  57. u32 val;
  58. u32 mask;
  59. };
  60. struct aspeed_pinctrl_data {
  61. struct regmap *scu;
  62. const struct pinctrl_pin_desc *pins;
  63. const unsigned int npins;
  64. const struct aspeed_pin_config *configs;
  65. const unsigned int nconfigs;
  66. struct aspeed_pinmux_data pinmux;
  67. const struct aspeed_pin_config_map *confmaps;
  68. const unsigned int nconfmaps;
  69. };
  70. /* Aspeed pinctrl helpers */
  71. int aspeed_pinctrl_get_groups_count(struct pinctrl_dev *pctldev);
  72. const char *aspeed_pinctrl_get_group_name(struct pinctrl_dev *pctldev,
  73. unsigned int group);
  74. int aspeed_pinctrl_get_group_pins(struct pinctrl_dev *pctldev,
  75. unsigned int group, const unsigned int **pins,
  76. unsigned int *npins);
  77. void aspeed_pinctrl_pin_dbg_show(struct pinctrl_dev *pctldev,
  78. struct seq_file *s, unsigned int offset);
  79. int aspeed_pinmux_get_fn_count(struct pinctrl_dev *pctldev);
  80. const char *aspeed_pinmux_get_fn_name(struct pinctrl_dev *pctldev,
  81. unsigned int function);
  82. int aspeed_pinmux_get_fn_groups(struct pinctrl_dev *pctldev,
  83. unsigned int function, const char * const **groups,
  84. unsigned int * const num_groups);
  85. int aspeed_pinmux_set_mux(struct pinctrl_dev *pctldev, unsigned int function,
  86. unsigned int group);
  87. int aspeed_gpio_request_enable(struct pinctrl_dev *pctldev,
  88. struct pinctrl_gpio_range *range,
  89. unsigned int offset);
  90. int aspeed_pinctrl_probe(struct platform_device *pdev,
  91. struct pinctrl_desc *pdesc,
  92. struct aspeed_pinctrl_data *pdata);
  93. int aspeed_pin_config_get(struct pinctrl_dev *pctldev, unsigned int offset,
  94. unsigned long *config);
  95. int aspeed_pin_config_set(struct pinctrl_dev *pctldev, unsigned int offset,
  96. unsigned long *configs, unsigned int num_configs);
  97. int aspeed_pin_config_group_get(struct pinctrl_dev *pctldev,
  98. unsigned int selector,
  99. unsigned long *config);
  100. int aspeed_pin_config_group_set(struct pinctrl_dev *pctldev,
  101. unsigned int selector,
  102. unsigned long *configs,
  103. unsigned int num_configs);
  104. #endif /* PINCTRL_ASPEED */