pinctrl-spear.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*
  2. * Driver header file for the ST Microelectronics SPEAr pinmux
  3. *
  4. * Copyright (C) 2012 ST Microelectronics
  5. * Viresh Kumar <viresh.kumar@st.com>
  6. *
  7. * This file is licensed under the terms of the GNU General Public
  8. * License version 2. This program is licensed "as is" without any
  9. * warranty of any kind, whether express or implied.
  10. */
  11. #ifndef __PINMUX_SPEAR_H__
  12. #define __PINMUX_SPEAR_H__
  13. #include <linux/pinctrl/pinctrl.h>
  14. #include <linux/types.h>
  15. struct platform_device;
  16. struct device;
  17. /**
  18. * struct spear_pmx_mode - SPEAr pmx mode
  19. * @name: name of pmx mode
  20. * @mode: mode id
  21. * @reg: register for configuring this mode
  22. * @mask: mask of this mode in reg
  23. * @val: val to be configured at reg after doing (val & mask)
  24. */
  25. struct spear_pmx_mode {
  26. const char *const name;
  27. u16 mode;
  28. u16 reg;
  29. u16 mask;
  30. u32 val;
  31. };
  32. /**
  33. * struct spear_muxreg - SPEAr mux reg configuration
  34. * @reg: register offset
  35. * @mask: mask bits
  36. * @val: val to be written on mask bits
  37. */
  38. struct spear_muxreg {
  39. u16 reg;
  40. u32 mask;
  41. u32 val;
  42. };
  43. /**
  44. * struct spear_modemux - SPEAr mode mux configuration
  45. * @modes: mode ids supported by this group of muxregs
  46. * @nmuxregs: number of muxreg configurations to be done for modes
  47. * @muxregs: array of muxreg configurations to be done for modes
  48. */
  49. struct spear_modemux {
  50. u16 modes;
  51. u8 nmuxregs;
  52. struct spear_muxreg *muxregs;
  53. };
  54. /**
  55. * struct spear_pingroup - SPEAr pin group configurations
  56. * @name: name of pin group
  57. * @pins: array containing pin numbers
  58. * @npins: size of pins array
  59. * @modemuxs: array of modemux configurations for this pin group
  60. * @nmodemuxs: size of array modemuxs
  61. *
  62. * A representation of a group of pins in the SPEAr pin controller. Each group
  63. * allows some parameter or parameters to be configured.
  64. */
  65. struct spear_pingroup {
  66. const char *name;
  67. const unsigned *pins;
  68. unsigned npins;
  69. struct spear_modemux *modemuxs;
  70. unsigned nmodemuxs;
  71. };
  72. /**
  73. * struct spear_function - SPEAr pinctrl mux function
  74. * @name: The name of the function, exported to pinctrl core.
  75. * @groups: An array of pin groups that may select this function.
  76. * @ngroups: The number of entries in @groups.
  77. */
  78. struct spear_function {
  79. const char *name;
  80. const char *const *groups;
  81. unsigned ngroups;
  82. };
  83. /**
  84. * struct spear_pinctrl_machdata - SPEAr pin controller machine driver
  85. * configuration
  86. * @pins: An array describing all pins the pin controller affects.
  87. * All pins which are also GPIOs must be listed first within the *array,
  88. * and be numbered identically to the GPIO controller's *numbering.
  89. * @npins: The numbmer of entries in @pins.
  90. * @functions: An array describing all mux functions the SoC supports.
  91. * @nfunctions: The numbmer of entries in @functions.
  92. * @groups: An array describing all pin groups the pin SoC supports.
  93. * @ngroups: The numbmer of entries in @groups.
  94. *
  95. * @modes_supported: Does SoC support modes
  96. * @mode: mode configured from probe
  97. * @pmx_modes: array of modes supported by SoC
  98. * @npmx_modes: number of entries in pmx_modes.
  99. */
  100. struct spear_pinctrl_machdata {
  101. const struct pinctrl_pin_desc *pins;
  102. unsigned npins;
  103. struct spear_function **functions;
  104. unsigned nfunctions;
  105. struct spear_pingroup **groups;
  106. unsigned ngroups;
  107. bool modes_supported;
  108. u16 mode;
  109. struct spear_pmx_mode **pmx_modes;
  110. unsigned npmx_modes;
  111. };
  112. /**
  113. * struct spear_pmx - SPEAr pinctrl mux
  114. * @dev: pointer to struct dev of platform_device registered
  115. * @pctl: pointer to struct pinctrl_dev
  116. * @machdata: pointer to SoC or machine specific structure
  117. * @vbase: virtual base address of pinmux controller
  118. */
  119. struct spear_pmx {
  120. struct device *dev;
  121. struct pinctrl_dev *pctl;
  122. struct spear_pinctrl_machdata *machdata;
  123. void __iomem *vbase;
  124. };
  125. /* exported routines */
  126. void __devinit pmx_init_addr(struct spear_pinctrl_machdata *machdata, u16 reg);
  127. int __devinit spear_pinctrl_probe(struct platform_device *pdev,
  128. struct spear_pinctrl_machdata *machdata);
  129. int __devexit spear_pinctrl_remove(struct platform_device *pdev);
  130. #endif /* __PINMUX_SPEAR_H__ */