Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Documentation: pinctrl: Describe PM helper functions for standard states.

Clarify documentation for predefined standard state names 'default',
'init', 'sleep', 'idle' and their associated PM API.

Signed-off-by: Christian Bruel <christian.bruel@foss.st.com>
Signed-off-by: Manivannan Sadhasivam <mani@kernel.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://patch.msgid.link/20250820075411.1178729-2-christian.bruel@foss.st.com

authored by

Christian Bruel and committed by
Manivannan Sadhasivam
272dad3f 8f5ae30d

+55 -2
+55 -2
Documentation/driver-api/pin-control.rst
··· 1162 1162 Pin control requests from drivers 1163 1163 ================================= 1164 1164 1165 - When a device driver is about to probe the device core will automatically 1166 - attempt to issue ``pinctrl_get_select_default()`` on these devices. 1165 + When a device driver is about to probe, the device core attaches the 1166 + standard states if they are defined in the device tree by calling 1167 + ``pinctrl_bind_pins()`` on these devices. 1168 + Possible standard state names are: "default", "init", "sleep" and "idle". 1169 + 1170 + - if ``default`` is defined in the device tree, it is selected before 1171 + device probe. 1172 + 1173 + - if ``init`` and ``default`` are defined in the device tree, the "init" 1174 + state is selected before the driver probe and the "default" state is 1175 + selected after the driver probe. 1176 + 1177 + - the ``sleep`` and ``idle`` states are for power management and can only 1178 + be selected with the PM API bellow. 1179 + 1180 + PM interfaces 1181 + ================= 1182 + PM runtime suspend/resume might need to execute the same init sequence as 1183 + during probe. Since the predefined states are already attached to the 1184 + device, the driver can activate these states explicitly with the 1185 + following helper functions: 1186 + 1187 + - ``pinctrl_pm_select_default_state()`` 1188 + - ``pinctrl_pm_select_init_state()`` 1189 + - ``pinctrl_pm_select_sleep_state()`` 1190 + - ``pinctrl_pm_select_idle_state()`` 1191 + 1192 + For example, if resuming the device depend on certain pinmux states 1193 + 1194 + .. code-block:: c 1195 + 1196 + foo_suspend() 1197 + { 1198 + /* suspend device */ 1199 + ... 1200 + 1201 + pinctrl_pm_select_sleep_state(dev); 1202 + } 1203 + 1204 + foo_resume() 1205 + { 1206 + pinctrl_pm_select_init_state(dev); 1207 + 1208 + /* resuming device */ 1209 + ... 1210 + 1211 + pinctrl_pm_select_default_state(dev); 1212 + } 1213 + 1167 1214 This way driver writers do not need to add any of the boilerplate code 1168 1215 of the type found below. However when doing fine-grained state selection 1169 1216 and not using the "default" state, you may have to do some device driver ··· 1231 1184 operation and going to sleep, moving from the ``PINCTRL_STATE_DEFAULT`` to 1232 1185 ``PINCTRL_STATE_SLEEP`` at runtime, re-biasing or even re-muxing pins to save 1233 1186 current in sleep mode. 1187 + 1188 + Another case is when the pinctrl needs to switch to a certain mode during 1189 + probe and then revert to the default state at the end of probe. For example 1190 + a PINMUX may need to be configured as a GPIO during probe. In this case, use 1191 + ``PINCTRL_STATE_INIT`` to switch state before probe, then move to 1192 + ``PINCTRL_STATE_DEFAULT`` at the end of probe for normal operation. 1234 1193 1235 1194 A driver may request a certain control state to be activated, usually just the 1236 1195 default state like this: