samsung-pinctrl.txt 11 KB

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