Understanding pinctrl driver

Pinctrl to use the whole process, for example, briefly summarize pinctrl subsystem.

  1. pinctrl driver pin controller according to the actual situation, to achieve struct pinctrl_desc (including pin / pin group abstract, function abstract, pinconf, pinmux the operation API implementation to achieve dt_node_to_map, and the like), and the registration to the kernel.
  1. In pinctrl driver dts node pin controller, the format according to their definition, all describe the pin state for each device. Substantially has the form:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    pinctrl_xxx {                               

    ...

    xxx_state_xxx: xxx_xxx { /* dts node for xxx device's "xxx state" */

    xxx_pinmux { /* pinmux entry */

    xxx = xxxx;

    xxx = xxxxxxx;

    ...

    };

    xxx_pinconf { /* pinconf entry */

    xxx = xxxx;

    xxx = xxxxxxx;

    ...

    };

    xxx_pinconf {

    xxx = xxxx;

    xxx = xxxxxxx;
    large column   Understanding pinctrl Driver S = "Line">
    ...

    };

    ...

    };

    ...

    };
  2. The corresponding consumer driver may own dts node, a reference pin state pinctrl driver as defined, for example:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    xxx_device: xxx@xxxxxxxx {

    compatible = "xxx,xxxx";

    ...

    pinctrl-names = "default";

    pinctrl-0 = <&xxx_state_xxx>;

    ...

    };
  3. consumer driver when needed, can call pinctrl_get / devm_pinctrl_get interface to obtain a pinctrl handle (struct pinctrl type of pointer).

    pinctrl subsystem during pinctrl get in, resolve dts node consumer device, and find the corresponding pin state, were dt_node_to_map API calls pinctrl driver provided analytical pin state and converted to pin map.

    When the driver probe to an example, the call is as follows:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    probe

    devm_pinctrl_get or pinctrl_get

    create_pinctrl(drivers/pinctrl/core.c)

    pinctrl_dt_to_map(drivers/pinctrl/devicetree.c)

    dt_to_map_one_config

    pctlops->dt_node_to_map
  4. consumer 获得 pinctrl handle 之后,可以调用 pinctrl subsystem 提供的 API(例如pinctrl_select_state),使自己的某个 pin state 生效。pinctrl subsystem 进而调用 pinctrl driver提供的各种回调函数,配置pin controller的硬件。

Guess you like

Origin www.cnblogs.com/dajunjun/p/11711103.html