aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/pinctrl.txt
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2012-09-10 11:22:00 -0400
committerLinus Walleij <linus.walleij@linaro.org>2012-09-17 04:53:57 -0400
commitc31a00cd30b176e40e0378664bace6fd5e0417c8 (patch)
tree24aaa631eb8b7f33ef476eb08e3c9c01ce2f1718 /Documentation/pinctrl.txt
parent6fc84b841114da84da39594a3abbb2adf3db06d2 (diff)
pinctrl: document semantics vs GPIO
The semantics of the interactions between GPIO and pinctrl may be unclear, e.g. which one do you request first? This amends the documentation to make this clear. Reported-by: Domenico Andreoli <cavokz@gmail.com> Acked-by: Domenico Andreoli <domenico.andreoli@linux.com> Acked-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'Documentation/pinctrl.txt')
-rw-r--r--Documentation/pinctrl.txt60
1 files changed, 58 insertions, 2 deletions
diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt
index 1479aca23744..3b4ee5328868 100644
--- a/Documentation/pinctrl.txt
+++ b/Documentation/pinctrl.txt
@@ -289,6 +289,11 @@ Interaction with the GPIO subsystem
289The GPIO drivers may want to perform operations of various types on the same 289The GPIO drivers may want to perform operations of various types on the same
290physical pins that are also registered as pin controller pins. 290physical pins that are also registered as pin controller pins.
291 291
292First and foremost, the two subsystems can be used as completely orthogonal,
293see the section named "pin control requests from drivers" and
294"drivers needing both pin control and GPIOs" below for details. But in some
295situations a cross-subsystem mapping between pins and GPIOs is needed.
296
292Since the pin controller subsystem have its pinspace local to the pin 297Since the pin controller subsystem have its pinspace local to the pin
293controller we need a mapping so that the pin control subsystem can figure out 298controller we need a mapping so that the pin control subsystem can figure out
294which pin controller handles control of a certain GPIO pin. Since a single 299which pin controller handles control of a certain GPIO pin. Since a single
@@ -359,6 +364,7 @@ will get an pin number into its handled number range. Further it is also passed
359the range ID value, so that the pin controller knows which range it should 364the range ID value, so that the pin controller knows which range it should
360deal with. 365deal with.
361 366
367
362PINMUX interfaces 368PINMUX interfaces
363================= 369=================
364 370
@@ -960,8 +966,8 @@ all get selected, and they all get enabled and disable simultaneously by the
960pinmux core. 966pinmux core.
961 967
962 968
963Pinmux requests from drivers 969Pin control requests from drivers
964============================ 970=================================
965 971
966Generally it is discouraged to let individual drivers get and enable pin 972Generally it is discouraged to let individual drivers get and enable pin
967control. So if possible, handle the pin control in platform code or some other 973control. So if possible, handle the pin control in platform code or some other
@@ -969,6 +975,11 @@ place where you have access to all the affected struct device * pointers. In
969some cases where a driver needs to e.g. switch between different mux mappings 975some cases where a driver needs to e.g. switch between different mux mappings
970at runtime this is not possible. 976at runtime this is not possible.
971 977
978A typical case is if a driver needs to switch bias of pins from normal
979operation and going to sleep, moving from the PINCTRL_STATE_DEFAULT to
980PINCTRL_STATE_SLEEP at runtime, re-biasing or even re-muxing pins to save
981current in sleep mode.
982
972A driver may request a certain control state to be activated, usually just the 983A driver may request a certain control state to be activated, usually just the
973default state like this: 984default state like this:
974 985
@@ -1058,6 +1069,51 @@ registered. Thus make sure that the error path in your driver gracefully
1058cleans up and is ready to retry the probing later in the startup process. 1069cleans up and is ready to retry the probing later in the startup process.
1059 1070
1060 1071
1072Drivers needing both pin control and GPIOs
1073==========================================
1074
1075Again, it is discouraged to let drivers lookup and select pin control states
1076themselves, but again sometimes this is unavoidable.
1077
1078So say that your driver is fetching its resources like this:
1079
1080#include <linux/pinctrl/consumer.h>
1081#include <linux/gpio.h>
1082
1083struct pinctrl *pinctrl;
1084int gpio;
1085
1086pinctrl = devm_pinctrl_get_select_default(&dev);
1087gpio = devm_gpio_request(&dev, 14, "foo");
1088
1089Here we first request a certain pin state and then request GPIO 14 to be
1090used. If you're using the subsystems orthogonally like this, you should
1091nominally always get your pinctrl handle and select the desired pinctrl
1092state BEFORE requesting the GPIO. This is a semantic convention to avoid
1093situations that can be electrically unpleasant, you will certainly want to
1094mux in and bias pins in a certain way before the GPIO subsystems starts to
1095deal with them.
1096
1097The above can be hidden: using pinctrl hogs, the pin control driver may be
1098setting up the config and muxing for the pins when it is probing,
1099nevertheless orthogonal to the GPIO subsystem.
1100
1101But there are also situations where it makes sense for the GPIO subsystem
1102to communicate directly with with the pinctrl subsystem, using the latter
1103as a back-end. This is when the GPIO driver may call out to the functions
1104described in the section "Pin control interaction with the GPIO subsystem"
1105above. This only involves per-pin multiplexing, and will be completely
1106hidden behind the gpio_*() function namespace. In this case, the driver
1107need not interact with the pin control subsystem at all.
1108
1109If a pin control driver and a GPIO driver is dealing with the same pins
1110and the use cases involve multiplexing, you MUST implement the pin controller
1111as a back-end for the GPIO driver like this, unless your hardware design
1112is such that the GPIO controller can override the pin controller's
1113multiplexing state through hardware without the need to interact with the
1114pin control system.
1115
1116
1061System pin control hogging 1117System pin control hogging
1062========================== 1118==========================
1063 1119