@@ -1162,8 +1162,55 @@ pinmux core.
11621162Pin control requests from drivers
11631163=================================
11641164
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+
11671214 This way driver writers do not need to add any of the boilerplate code
11681215of the type found below. However when doing fine-grained state selection
11691216and not using the "default" state, you may have to do some device driver
@@ -1185,6 +1232,12 @@ operation and going to sleep, moving from the ``PINCTRL_STATE_DEFAULT`` to
11851232``PINCTRL_STATE_SLEEP `` at runtime, re-biasing or even re-muxing pins to save
11861233current in sleep mode.
11871234
1235+ Another case is when the pinctrl needs to switch to a certain mode during
1236+ probe and then revert to the default state at the end of probe. For example
1237+ a PINMUX may need to be configured as a GPIO during probe. In this case, use
1238+ ``PINCTRL_STATE_INIT `` to switch state before probe, then move to
1239+ ``PINCTRL_STATE_DEFAULT `` at the end of probe for normal operation.
1240+
11881241A driver may request a certain control state to be activated, usually just the
11891242default state like this:
11901243
0 commit comments