pinctrl-uniphier.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright (C) 2015-2016 Socionext Inc.
  3. * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ifndef __PINCTRL_UNIPHIER_H__
  8. #define __PINCTRL_UNIPHIER_H__
  9. #include <linux/bitops.h>
  10. #include <linux/bug.h>
  11. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #define UNIPHIER_PIN_ATTR_PACKED(iectrl) (iectrl)
  14. static inline unsigned int uniphier_pin_get_iectrl(unsigned long data)
  15. {
  16. return data;
  17. }
  18. /**
  19. * struct uniphier_pinctrl_pin - pin data for UniPhier SoC
  20. *
  21. * @number: pin number
  22. * @data: additional per-pin data
  23. */
  24. struct uniphier_pinctrl_pin {
  25. unsigned number;
  26. unsigned long data;
  27. };
  28. /**
  29. * struct uniphier_pinctrl_group - pin group data for UniPhier SoC
  30. *
  31. * @name: pin group name
  32. * @pins: array of pins that belong to the group
  33. * @num_pins: number of pins in the group
  34. * @muxvals: array of values to be set to pinmux registers
  35. */
  36. struct uniphier_pinctrl_group {
  37. const char *name;
  38. const unsigned *pins;
  39. unsigned num_pins;
  40. const int *muxvals;
  41. };
  42. /**
  43. * struct uniphier_pinctrl_socdata - SoC data for UniPhier pin controller
  44. *
  45. * @pins: array of pin data
  46. * @pins_count: number of pin data
  47. * @groups: array of pin group data
  48. * @groups_count: number of pin group data
  49. * @functions: array of pinmux function names
  50. * @functions_count: number of pinmux functions
  51. * @mux_bits: bit width of each pinmux register
  52. * @reg_stride: stride of pinmux register address
  53. * @caps: SoC-specific capability flag
  54. */
  55. struct uniphier_pinctrl_socdata {
  56. const struct uniphier_pinctrl_pin *pins;
  57. int pins_count;
  58. const struct uniphier_pinctrl_group *groups;
  59. int groups_count;
  60. const char * const *functions;
  61. int functions_count;
  62. unsigned caps;
  63. #define UNIPHIER_PINCTRL_CAPS_PERPIN_IECTRL BIT(2)
  64. #define UNIPHIER_PINCTRL_CAPS_DBGMUX_SEPARATE BIT(1)
  65. #define UNIPHIER_PINCTRL_CAPS_MUX_4BIT BIT(0)
  66. };
  67. #define UNIPHIER_PINCTRL_PIN(a, b) \
  68. { \
  69. .number = a, \
  70. .data = UNIPHIER_PIN_ATTR_PACKED(b), \
  71. }
  72. #define __UNIPHIER_PINCTRL_GROUP(grp) \
  73. { \
  74. .name = #grp, \
  75. .pins = grp##_pins, \
  76. .num_pins = ARRAY_SIZE(grp##_pins), \
  77. .muxvals = grp##_muxvals + \
  78. BUILD_BUG_ON_ZERO(ARRAY_SIZE(grp##_pins) != \
  79. ARRAY_SIZE(grp##_muxvals)), \
  80. }
  81. #define __UNIPHIER_PINMUX_FUNCTION(func) #func
  82. #ifdef CONFIG_SPL_BUILD
  83. /*
  84. * a tricky way to drop unneeded *_pins and *_muxvals arrays from SPL,
  85. * suppressing "defined but not used" warnings.
  86. */
  87. #define UNIPHIER_PINCTRL_GROUP(grp) \
  88. { .num_pins = ARRAY_SIZE(grp##_pins) + ARRAY_SIZE(grp##_muxvals) }
  89. #define UNIPHIER_PINMUX_FUNCTION(func) NULL
  90. #else
  91. #define UNIPHIER_PINCTRL_GROUP(grp) __UNIPHIER_PINCTRL_GROUP(grp)
  92. #define UNIPHIER_PINMUX_FUNCTION(func) __UNIPHIER_PINMUX_FUNCTION(func)
  93. #endif
  94. #define UNIPHIER_PINCTRL_GROUP_SPL(grp) __UNIPHIER_PINCTRL_GROUP(grp)
  95. #define UNIPHIER_PINMUX_FUNCTION_SPL(func) __UNIPHIER_PINMUX_FUNCTION(func)
  96. /**
  97. * struct uniphier_pinctrl_priv - private data for UniPhier pinctrl driver
  98. *
  99. * @base: base address of the pinctrl device
  100. * @socdata: SoC specific data
  101. */
  102. struct uniphier_pinctrl_priv {
  103. void __iomem *base;
  104. struct uniphier_pinctrl_socdata *socdata;
  105. };
  106. extern const struct pinctrl_ops uniphier_pinctrl_ops;
  107. int uniphier_pinctrl_probe(struct udevice *dev,
  108. struct uniphier_pinctrl_socdata *socdata);
  109. #endif /* __PINCTRL_UNIPHIER_H__ */