pinctrl-uniphier.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef __PINCTRL_UNIPHIER_H__
  7. #define __PINCTRL_UNIPHIER_H__
  8. #include <linux/bug.h>
  9. #include <linux/kernel.h>
  10. #include <linux/types.h>
  11. #define UNIPHIER_PINCTRL_PINMUX_BASE 0x0
  12. #define UNIPHIER_PINCTRL_LOAD_PINMUX 0x700
  13. #define UNIPHIER_PINCTRL_IECTRL 0xd00
  14. #define UNIPHIER_PIN_ATTR_PACKED(iectrl) (iectrl)
  15. static inline unsigned int uniphier_pin_get_iectrl(unsigned long data)
  16. {
  17. return data;
  18. }
  19. /**
  20. * struct uniphier_pinctrl_pin - pin data for UniPhier SoC
  21. *
  22. * @number: pin number
  23. * @data: additional per-pin data
  24. */
  25. struct uniphier_pinctrl_pin {
  26. unsigned number;
  27. unsigned long data;
  28. };
  29. /**
  30. * struct uniphier_pinctrl_group - pin group data for UniPhier SoC
  31. *
  32. * @name: pin group name
  33. * @pins: array of pins that belong to the group
  34. * @num_pins: number of pins in the group
  35. * @muxvals: array of values to be set to pinmux registers
  36. */
  37. struct uniphier_pinctrl_group {
  38. const char *name;
  39. const unsigned *pins;
  40. unsigned num_pins;
  41. const unsigned *muxvals;
  42. };
  43. /**
  44. * struct uniphier_pinctrl_socdata - SoC data for UniPhier pin controller
  45. *
  46. * @pins: array of pin data
  47. * @pins_count: number of pin data
  48. * @groups: array of pin group data
  49. * @groups_count: number of pin group data
  50. * @functions: array of pinmux function names
  51. * @functions_count: number of pinmux functions
  52. * @mux_bits: bit width of each pinmux register
  53. * @reg_stride: stride of pinmux register address
  54. * @load_pinctrl: if true, LOAD_PINMUX register must be set to one for new
  55. * values in pinmux registers to become really effective
  56. */
  57. struct uniphier_pinctrl_socdata {
  58. const struct uniphier_pinctrl_pin *pins;
  59. int pins_count;
  60. const struct uniphier_pinctrl_group *groups;
  61. int groups_count;
  62. const char * const *functions;
  63. int functions_count;
  64. unsigned mux_bits;
  65. unsigned reg_stride;
  66. bool load_pinctrl;
  67. };
  68. #define UNIPHIER_PINCTRL_PIN(a, b) \
  69. { \
  70. .number = a, \
  71. .data = UNIPHIER_PIN_ATTR_PACKED(b), \
  72. }
  73. #define UNIPHIER_PINCTRL_GROUP(grp) \
  74. { \
  75. .name = #grp, \
  76. .pins = grp##_pins, \
  77. .num_pins = ARRAY_SIZE(grp##_pins), \
  78. .muxvals = grp##_muxvals + \
  79. BUILD_BUG_ON_ZERO(ARRAY_SIZE(grp##_pins) != \
  80. ARRAY_SIZE(grp##_muxvals)), \
  81. }
  82. /**
  83. * struct uniphier_pinctrl_priv - private data for UniPhier pinctrl driver
  84. *
  85. * @base: base address of the pinctrl device
  86. * @socdata: SoC specific data
  87. */
  88. struct uniphier_pinctrl_priv {
  89. void __iomem *base;
  90. struct uniphier_pinctrl_socdata *socdata;
  91. };
  92. extern const struct pinctrl_ops uniphier_pinctrl_ops;
  93. int uniphier_pinctrl_probe(struct udevice *dev,
  94. struct uniphier_pinctrl_socdata *socdata);
  95. int uniphier_pinctrl_remove(struct udevice *dev);
  96. #endif /* __PINCTRL_UNIPHIER_H__ */