pinctrl-lantiq.h 3.5 KB

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