samsung-pinctrl.txt 11 KB

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