pinctrl-lantiq.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * linux/drivers/pinctrl/pinctrl-lantiq.h
  3. * based on linux/drivers/pinctrl/pinctrl-pxa3xx.h
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * publishhed by the Free Software Foundation.
  8. *
  9. * Copyright (C) 2012 John Crispin <blogic@openwrt.org>
  10. */
  11. #ifndef __PINCTRL_LANTIQ_H
  12. #define __PINCTRL_LANTIQ_H
  13. #include <linux/clkdev.h>
  14. #include <linux/pinctrl/pinctrl.h>
  15. #include <linux/pinctrl/pinconf.h>
  16. #include <linux/pinctrl/pinmux.h>
  17. #include <linux/pinctrl/consumer.h>
  18. #include <linux/pinctrl/machine.h>
  19. #include "core.h"
  20. #define ARRAY_AND_SIZE(x) (x), ARRAY_SIZE(x)
  21. #define LTQ_MAX_MUX 4
  22. #define MFPR_FUNC_MASK 0x3
  23. #define LTQ_PINCONF_PACK(param, arg) ((param) << 16 | (arg))
  24. #define LTQ_PINCONF_UNPACK_PARAM(conf) ((conf) >> 16)
  25. #define LTQ_PINCONF_UNPACK_ARG(conf) ((conf) & 0xffff)
  26. enum ltq_pinconf_param {
  27. LTQ_PINCONF_PARAM_PULL,
  28. LTQ_PINCONF_PARAM_OPEN_DRAIN,
  29. LTQ_PINCONF_PARAM_DRIVE_CURRENT,
  30. LTQ_PINCONF_PARAM_SLEW_RATE,
  31. LTQ_PINCONF_PARAM_OUTPUT,
  32. };
  33. struct ltq_cfg_param {
  34. const char *property;
  35. enum ltq_pinconf_param param;
  36. };
  37. struct ltq_mfp_pin {
  38. const char *name;
  39. const unsigned int pin;
  40. const unsigned short func[LTQ_MAX_MUX];
  41. };
  42. struct ltq_pin_group {
  43. const char *name;
  44. const unsigned mux;
  45. const unsigned *pins;
  46. const unsigned npins;
  47. };
  48. struct ltq_pmx_func {
  49. const char *name;
  50. const char * const *groups;
  51. const unsigned num_groups;
  52. };
  53. struct ltq_pinmux_info {
  54. struct device *dev;
  55. struct pinctrl_dev *pctrl;
  56. /* we need to manage up to 5 pad controllers */
  57. void __iomem *membase[5];
  58. /* the descriptor for the subsystem */
  59. struct pinctrl_desc *desc;
  60. /* we expose our pads to the subsystem */
  61. struct pinctrl_pin_desc *pads;
  62. /* the number of pads. this varies between socs */
  63. unsigned int num_pads;
  64. /* these are our multifunction pins */
  65. const struct ltq_mfp_pin *mfp;
  66. unsigned int num_mfp;
  67. /* a number of multifunction pins can be grouped together */
  68. const struct ltq_pin_group *grps;
  69. unsigned int num_grps;
  70. /* a mapping between function string and id */
  71. const struct ltq_pmx_func *funcs;
  72. unsigned int num_funcs;
  73. /* the pinconf options that we are able to read from the DT */
  74. const struct ltq_cfg_param *params;
  75. unsigned int num_params;
  76. /* the pad controller can have a irq mapping */
  77. const unsigned *exin;
  78. unsigned int num_exin;
  79. /* we need 5 clocks max */
  80. struct clk *clk[5];
  81. /* soc specific callback used to apply muxing */
  82. int (*apply_mux)(struct pinctrl_dev *pctrldev, int pin, int mux);
  83. };
  84. enum ltq_pin {
  85. GPIO0 = 0,
  86. GPIO1,
  87. GPIO2,
  88. GPIO3,
  89. GPIO4,
  90. GPIO5,
  91. GPIO6,
  92. GPIO7,
  93. GPIO8,
  94. GPIO9,
  95. GPIO10, /* 10 */
  96. GPIO11,
  97. GPIO12,
  98. GPIO13,
  99. GPIO14,
  100. GPIO15,
  101. GPIO16,
  102. GPIO17,
  103. GPIO18,
  104. GPIO19,
  105. GPIO20, /* 20 */
  106. GPIO21,
  107. GPIO22,
  108. GPIO23,
  109. GPIO24,
  110. GPIO25,
  111. GPIO26,
  112. GPIO27,
  113. GPIO28,
  114. GPIO29,
  115. GPIO30, /* 30 */
  116. GPIO31,
  117. GPIO32,
  118. GPIO33,
  119. GPIO34,
  120. GPIO35,
  121. GPIO36,
  122. GPIO37,
  123. GPIO38,
  124. GPIO39,
  125. GPIO40, /* 40 */
  126. GPIO41,
  127. GPIO42,
  128. GPIO43,
  129. GPIO44,
  130. GPIO45,
  131. GPIO46,
  132. GPIO47,
  133. GPIO48,
  134. GPIO49,
  135. GPIO50, /* 50 */
  136. GPIO51,
  137. GPIO52,
  138. GPIO53,
  139. GPIO54,
  140. GPIO55,
  141. GPIO56,
  142. GPIO57,
  143. GPIO58,
  144. GPIO59,
  145. GPIO60, /* 60 */
  146. GPIO61,
  147. GPIO62,
  148. GPIO63,
  149. GPIO64,
  150. GPIO65,
  151. GPIO66,
  152. GPIO67,
  153. GPIO68,
  154. GPIO69,
  155. GPIO70,
  156. GPIO71,
  157. GPIO72,
  158. GPIO73,
  159. GPIO74,
  160. GPIO75,
  161. GPIO76,
  162. GPIO77,
  163. GPIO78,
  164. GPIO79,
  165. GPIO80,
  166. GPIO81,
  167. GPIO82,
  168. GPIO83,
  169. GPIO84,
  170. GPIO85,
  171. GPIO86,
  172. GPIO87,
  173. GPIO88,
  174. };
  175. extern int ltq_pinctrl_register(struct platform_device *pdev,
  176. struct ltq_pinmux_info *info);
  177. extern int ltq_pinctrl_unregister(struct platform_device *pdev);
  178. #endif /* __PINCTRL_LANTIQ_H */