samsung-pinctrl.txt 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. Samsung GPIO and Pin Mux/Config controller
  2. Samsung's ARM based SoC's integrates a GPIO and Pin mux/config hardware
  3. controller. It controls the input/output settings on the available pads/pins
  4. and also provides ability to multiplex and configure the output of various
  5. on-chip controllers onto these pads.
  6. Required Properties:
  7. - compatible: should be one of the following.
  8. - "samsung,s3c64xx-pinctrl": for S3C64xx-compatible pin-controller,
  9. - "samsung,exynos4210-pinctrl": for Exynos4210 compatible pin-controller.
  10. - "samsung,exynos4x12-pinctrl": for Exynos4x12 compatible pin-controller.
  11. - "samsung,exynos5250-pinctrl": for Exynos5250 compatible pin-controller.
  12. - reg: Base address of the pin controller hardware module and length of
  13. the address space it occupies.
  14. - Pin banks as child nodes: Pin banks of the controller are represented by child
  15. nodes of the controller node. Bank name is taken from name of the node. Each
  16. bank node must contain following properties:
  17. - gpio-controller: identifies the node as a gpio controller and pin bank.
  18. - #gpio-cells: number of cells in GPIO specifier. Since the generic GPIO
  19. binding is used, the amount of cells must be specified as 2. See the below
  20. mentioned gpio binding representation for description of particular cells.
  21. Eg: <&gpx2 6 0>
  22. <[phandle of the gpio controller node]
  23. [pin number within the gpio controller]
  24. [flags]>
  25. Values for gpio specifier:
  26. - Pin number: is a value between 0 to 7.
  27. - Flags: 0 - Active High
  28. 1 - Active Low
  29. - Pin mux/config groups as child nodes: The pin mux (selecting pin function
  30. mode) and pin config (pull up/down, driver strength) settings are represented
  31. as child nodes of the pin-controller node. There should be atleast one
  32. child node and there is no limit on the count of these child nodes.
  33. The child node should contain a list of pin(s) on which a particular pin
  34. function selection or pin configuration (or both) have to applied. This
  35. list of pins is specified using the property name "samsung,pins". There
  36. should be atleast one pin specfied for this property and there is no upper
  37. limit on the count of pins that can be specified. The pins are specified
  38. using pin names which are derived from the hardware manual of the SoC. As
  39. an example, the pins in GPA0 bank of the pin controller can be represented
  40. as "gpa0-0", "gpa0-1", "gpa0-2" and so on. The names should be in lower case.
  41. The format of the pin names should be (as per the hardware manual)
  42. "[pin bank name]-[pin number within the bank]".
  43. The pin function selection that should be applied on the pins listed in the
  44. child node is specified using the "samsung,pin-function" property. The value
  45. of this property that should be applied to each of the pins listed in the
  46. "samsung,pins" property should be picked from the hardware manual of the SoC
  47. for the specified pin group. This property is optional in the child node if
  48. no specific function selection is desired for the pins listed in the child
  49. node. The value of this property is used as-is to program the pin-controller
  50. function selector register of the pin-bank.
  51. The child node can also optionally specify one or more of the pin
  52. configuration that should be applied on all the pins listed in the
  53. "samsung,pins" property of the child node. The following pin configuration
  54. properties are supported.
  55. - samsung,pin-pud: Pull up/down configuration.
  56. - samsung,pin-drv: Drive strength configuration.
  57. - samsung,pin-pud-pdn: Pull up/down configuration in power down mode.
  58. - samsung,pin-drv-pdn: Drive strength configuration in power down mode.
  59. The values specified by these config properties should be derived from the
  60. hardware manual and these values are programmed as-is into the pin
  61. pull up/down and driver strength register of the pin-controller.
  62. Note: A child should include atleast a pin function selection property or
  63. pin configuration property (one or more) or both.
  64. The client nodes that require a particular pin function selection and/or
  65. pin configuration should use the bindings listed in the "pinctrl-bindings.txt"
  66. file.
  67. External GPIO and Wakeup Interrupts:
  68. The controller supports two types of external interrupts over gpio. The first
  69. is the external gpio interrupt and second is the external wakeup interrupts.
  70. The difference between the two is that the external wakeup interrupts can be
  71. used as system wakeup events.
  72. A. External GPIO Interrupts: For supporting external gpio interrupts, the
  73. following properties should be specified in the pin-controller device node.
  74. - interrupt-parent: phandle of the interrupt parent to which the external
  75. GPIO interrupts are forwarded to.
  76. - interrupts: interrupt specifier for the controller. The format and value of
  77. the interrupt specifier depends on the interrupt parent for the controller.
  78. In addition, following properties must be present in node of every bank
  79. of pins supporting GPIO interrupts:
  80. - interrupt-controller: identifies the controller node as interrupt-parent.
  81. - #interrupt-cells: the value of this property should be 2.
  82. - First Cell: represents the external gpio interrupt number local to the
  83. external gpio interrupt space of the controller.
  84. - Second Cell: flags to identify the type of the interrupt
  85. - 1 = rising edge triggered
  86. - 2 = falling edge triggered
  87. - 3 = rising and falling edge triggered
  88. - 4 = high level triggered
  89. - 8 = low level triggered
  90. B. External Wakeup Interrupts: For supporting external wakeup interrupts, a
  91. child node representing the external wakeup interrupt controller should be
  92. included in the pin-controller device node. This child node should include
  93. the following properties.
  94. - compatible: identifies the type of the external wakeup interrupt controller
  95. The possible values are:
  96. - samsung,s3c64xx-wakeup-eint: represents wakeup interrupt controller
  97. found on Samsung S3C64xx SoCs,
  98. - samsung,exynos4210-wakeup-eint: represents wakeup interrupt controller
  99. found on Samsung Exynos4210 SoC.
  100. - interrupt-parent: phandle of the interrupt parent to which the external
  101. wakeup interrupts are forwarded to.
  102. - interrupts: interrupt used by multiplexed wakeup interrupts.
  103. In addition, following properties must be present in node of every bank
  104. of pins supporting wake-up interrupts:
  105. - interrupt-controller: identifies the node as interrupt-parent.
  106. - #interrupt-cells: the value of this property should be 2
  107. - First Cell: represents the external wakeup interrupt number local to
  108. the external wakeup interrupt space of the controller.
  109. - Second Cell: flags to identify the type of the interrupt
  110. - 1 = rising edge triggered
  111. - 2 = falling edge triggered
  112. - 3 = rising and falling edge triggered
  113. - 4 = high level triggered
  114. - 8 = low level triggered
  115. Node of every bank of pins supporting direct wake-up interrupts (without
  116. multiplexing) must contain following properties:
  117. - interrupt-parent: phandle of the interrupt parent to which the external
  118. wakeup interrupts are forwarded to.
  119. - interrupts: interrupts of the interrupt parent which are used for external
  120. wakeup interrupts from pins of the bank, must contain interrupts for all
  121. pins of the bank.
  122. Aliases:
  123. All the pin controller nodes should be represented in the aliases node using
  124. the following format 'pinctrl{n}' where n is a unique number for the alias.
  125. Example: A pin-controller node with pin banks:
  126. pinctrl_0: pinctrl@11400000 {
  127. compatible = "samsung,exynos4210-pinctrl";
  128. reg = <0x11400000 0x1000>;
  129. interrupts = <0 47 0>;
  130. /* ... */
  131. /* Pin bank without external interrupts */
  132. gpy0: gpy0 {
  133. gpio-controller;
  134. #gpio-cells = <2>;
  135. };
  136. /* ... */
  137. /* Pin bank with external GPIO or muxed wake-up interrupts */
  138. gpj0: gpj0 {
  139. gpio-controller;
  140. #gpio-cells = <2>;
  141. interrupt-controller;
  142. #interrupt-cells = <2>;
  143. };
  144. /* ... */
  145. /* Pin bank with external direct wake-up interrupts */
  146. gpx0: gpx0 {
  147. gpio-controller;
  148. #gpio-cells = <2>;
  149. interrupt-controller;
  150. interrupt-parent = <&gic>;
  151. interrupts = <0 16 0>, <0 17 0>, <0 18 0>, <0 19 0>,
  152. <0 20 0>, <0 21 0>, <0 22 0>, <0 23 0>;
  153. #interrupt-cells = <2>;
  154. };
  155. /* ... */
  156. };
  157. Example 1: A pin-controller node with pin groups.
  158. pinctrl_0: pinctrl@11400000 {
  159. compatible = "samsung,exynos4210-pinctrl";
  160. reg = <0x11400000 0x1000>;
  161. interrupts = <0 47 0>;
  162. /* ... */
  163. uart0_data: uart0-data {
  164. samsung,pins = "gpa0-0", "gpa0-1";
  165. samsung,pin-function = <2>;
  166. samsung,pin-pud = <0>;
  167. samsung,pin-drv = <0>;
  168. };
  169. uart0_fctl: uart0-fctl {
  170. samsung,pins = "gpa0-2", "gpa0-3";
  171. samsung,pin-function = <2>;
  172. samsung,pin-pud = <0>;
  173. samsung,pin-drv = <0>;
  174. };
  175. uart1_data: uart1-data {
  176. samsung,pins = "gpa0-4", "gpa0-5";
  177. samsung,pin-function = <2>;
  178. samsung,pin-pud = <0>;
  179. samsung,pin-drv = <0>;
  180. };
  181. uart1_fctl: uart1-fctl {
  182. samsung,pins = "gpa0-6", "gpa0-7";
  183. samsung,pin-function = <2>;
  184. samsung,pin-pud = <0>;
  185. samsung,pin-drv = <0>;
  186. };
  187. i2c2_bus: i2c2-bus {
  188. samsung,pins = "gpa0-6", "gpa0-7";
  189. samsung,pin-function = <3>;
  190. samsung,pin-pud = <3>;
  191. samsung,pin-drv = <0>;
  192. };
  193. };
  194. Example 2: A pin-controller node with external wakeup interrupt controller node.
  195. pinctrl_1: pinctrl@11000000 {
  196. compatible = "samsung,exynos4210-pinctrl";
  197. reg = <0x11000000 0x1000>;
  198. interrupts = <0 46 0>
  199. /* ... */
  200. wakeup-interrupt-controller {
  201. compatible = "samsung,exynos4210-wakeup-eint";
  202. interrupt-parent = <&gic>;
  203. interrupts = <0 32 0>;
  204. };
  205. };
  206. Example 3: A uart client node that supports 'default' and 'flow-control' states.
  207. uart@13800000 {
  208. compatible = "samsung,exynos4210-uart";
  209. reg = <0x13800000 0x100>;
  210. interrupts = <0 52 0>;
  211. pinctrl-names = "default", "flow-control;
  212. pinctrl-0 = <&uart0_data>;
  213. pinctrl-1 = <&uart0_data &uart0_fctl>;
  214. };
  215. Example 4: Set up the default pin state for uart controller.
  216. static int s3c24xx_serial_probe(struct platform_device *pdev) {
  217. struct pinctrl *pinctrl;
  218. /* ... */
  219. pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
  220. }
  221. Example 5: A display port client node that supports 'default' pinctrl state
  222. and gpio binding.
  223. display-port-controller {
  224. /* ... */
  225. samsung,hpd-gpio = <&gpx2 6 0>;
  226. pinctrl-names = "default";
  227. pinctrl-0 = <&dp_hpd>;
  228. };
  229. Example 6: Request the gpio for display port controller
  230. static int exynos_dp_probe(struct platform_device *pdev)
  231. {
  232. int hpd_gpio, ret;
  233. struct device *dev = &pdev->dev;
  234. struct device_node *dp_node = dev->of_node;
  235. /* ... */
  236. hpd_gpio = of_get_named_gpio(dp_node, "samsung,hpd-gpio", 0);
  237. /* ... */
  238. ret = devm_gpio_request_one(&pdev->dev, hpd_gpio, GPIOF_IN,
  239. "hpd_gpio");
  240. /* ... */
  241. }