1# Copyright (c) 2022, Telink Semiconductor
2# SPDX-License-Identifier: Apache-2.0
3
4description: |
5    The Telink B91 pin controller is a singleton node responsible for
6    controlling pin function selection and pin properties. For example, you can
7    use this node to route UART0 TX to pin PB2 and enable the pull-up resistor
8    on the pin.
9
10    The node has the 'pinctrl' node label set in your SoC's devicetree,
11    so you can modify it like this:
12
13      &pinctrl {
14              /* your modifications go here */
15      };
16
17    All device pin configurations should be placed in child nodes of the
18    'pinctrl' node, as shown in this example:
19
20      /* You can put this in places like a board-pinctrl.dtsi file in
21       * your board directory, or a devicetree overlay in your application.
22       */
23
24      /* include pre-defined pins and functions for the SoC used by the board */
25      #include <dt-bindings/pinctrl/b91-pinctrl.h>
26
27      &pinctrl {
28        /* configuration for UART0 TX default state */
29        uart0_tx_pb2_default: uart0_tx_pb2_default {
30          /* configure PB2 as B91_FUNC_C */
31          pinmux = <B91_PINMUX_SET(B91_PORT_B, B91_PIN_2, B91_FUNC_C)>;
32        };
33        /* configuration for UART0 RX default state */
34        uart0_rx_pb3_default: uart0_rx_pb3_default {
35          /* configure PB2 as B91_FUNC_C */
36          pinmux = <B91_PINMUX_SET(B91_PORT_B, B91_PIN_3, B91_FUNC_C)>;
37        };
38      };
39
40    The 'uart0_tx_pb2_default' child node encodes the pin configurations
41    for a particular state of a device; in this case, the default
42    (that is, active) state. You would specify the low-power configuration for
43    the same device in a separate child node.
44
45    A pin configuration can also specify pin properties such as the
46    'bias-pull-up' property. Here is a list of supported standard pin
47    properties:
48
49    - bias-disable
50    - bias-pull-down
51    - bias-pull-up
52
53    To link pin configurations with a device, use a pinctrl-N property for some
54    number N, like this example you could place in your board's DTS file:
55
56      #include "board-pinctrl.dtsi"
57
58      &uart0 {
59        pinctrl-0 = <&uart0_tx_pb2_default &uart0_rx_pb3_default>;
60        pinctrl-1 = <&uart0_tx_pb2_sleep &uart0_rx_pb3_sleep>;
61        pinctrl-names = "default", "sleep";
62      };
63
64compatible: "telink,b91-pinctrl"
65
66include: base.yaml
67
68properties:
69  reg:
70    required: true
71
72  pad-mul-sel:
73    type: int
74    required: true
75    description: |
76        PinMux pad_mul_sel register value. Pin functions depend on it.
77
78        For instance:
79        Function C of PB2 configs the pin to UART0_TX if pad_mul_sel is set to <1>.
80        But, the same function configs the same pin to DAC_I_DAT2_I if pad_mul_sel is set to <0>.
81
82        Refer to the Telink TLSR9 specs to get more information about pins configuration.
83
84child-binding:
85  description: |
86      This binding gives a base representation of the Telink B91 pins configuration.
87
88  include:
89  - name: pincfg-node.yaml
90    property-allowlist:
91    - bias-disable
92    - bias-pull-down
93    - bias-pull-up
94
95  properties:
96    pinmux:
97      required: true
98      type: int
99      description: |
100          Telink B91 pin's configuration (port, pin and function).
101