[Linux Basics] - One of the Pinctrl subsystems to understand the basic concepts

1. Introduction to Linux Pinctrl Subsystem

Many SOCs contain pin controllers. Through the pin controller registers, we can configure the functions and characteristics of one or a group of pins. In terms of software, the Linux kernel provides a pinctrl subsystem for the purpose of unifying the pin pin management of various soc vendors.

2. Functions provided by Linux Pinctrl subsystem

1. Manage all controllable pins in the system. When the system is initialized, enumerate all controllable pins and identify these pins.

2. Manage the multiplexing of these pins. For SOC, in addition to configuring its pins as ordinary GPIO, several pins can also form a pin group to form a specific function. The pin control subsystem must manage all pin groups.

3. Configure the characteristics of these pins. For example, enable or disable the pull-up and pull-down resistors on the pins, and configure the driver strength of the pins.

Three, Pinctrl related concepts

There are two main goals for the ordinary driver to call the pin control subsystem:

1. Set the function reuse of the device;

2. Set the electrical characteristics of the pin corresponding to the device.

To set the function reuse of the device, you need to understand two concepts, one is function and the other is pin group. function is a functional abstraction, corresponding to a HW logic block, such as SPI0. Although a specific function name is given, we are not sure of the pins used. For example, for design flexibility, the function of SPI0 inside the chip is derived to pin group {C6, C7, C8, C9}, or it may be derived to another pin group {C22, C23, C24, C25}, but there is no doubt that these two A pin group cannot be active at the same time. After all, there is only one logic function circuit of SPI0 inside the chip, so only the pin group sector with function selector and function can be set for function mux.

In addition, due to the requirements of power management, a certain device may be in a certain power management state, such as idle or sleep. At this time, all pins belonging to the device need to be in another state.

Based on the above requirements, the concept of pin control state is defined, which means that the device may be in one of many states, and the device driver can switch the state of the device. To facilitate the management of pin control state. There is the concept of pin control state holder, which is used to manage all pin control states of a device.

In summary, the ordinary driver calls the pin control subsystem interface with only three steps:

1. Get the handle of the pin control state holder when the driver is loading or running;

2. Set pin control status;

3. When the driver is unloaded or exited, release the pin control state holder de handle;

Guess you like

Origin blog.csdn.net/u014674293/article/details/105836432