aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/pinctrl.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/pinctrl.txt')
-rw-r--r--Documentation/pinctrl.txt48
1 files changed, 29 insertions, 19 deletions
diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt
index 4431c3e727ba..e40f4b4e1977 100644
--- a/Documentation/pinctrl.txt
+++ b/Documentation/pinctrl.txt
@@ -945,13 +945,13 @@ case), we define a mapping like this:
945The result of grabbing this mapping from the device with something like 945The result of grabbing this mapping from the device with something like
946this (see next paragraph): 946this (see next paragraph):
947 947
948 p = pinctrl_get(dev); 948 p = devm_pinctrl_get(dev);
949 s = pinctrl_lookup_state(p, "8bit"); 949 s = pinctrl_lookup_state(p, "8bit");
950 ret = pinctrl_select_state(p, s); 950 ret = pinctrl_select_state(p, s);
951 951
952or more simply: 952or more simply:
953 953
954 p = pinctrl_get_select(dev, "8bit"); 954 p = devm_pinctrl_get_select(dev, "8bit");
955 955
956Will be that you activate all the three bottom records in the mapping at 956Will be that you activate all the three bottom records in the mapping at
957once. Since they share the same name, pin controller device, function and 957once. Since they share the same name, pin controller device, function and
@@ -985,7 +985,7 @@ foo_probe()
985 /* Allocate a state holder named "foo" etc */ 985 /* Allocate a state holder named "foo" etc */
986 struct foo_state *foo = ...; 986 struct foo_state *foo = ...;
987 987
988 foo->p = pinctrl_get(&device); 988 foo->p = devm_pinctrl_get(&device);
989 if (IS_ERR(foo->p)) { 989 if (IS_ERR(foo->p)) {
990 /* FIXME: clean up "foo" here */ 990 /* FIXME: clean up "foo" here */
991 return PTR_ERR(foo->p); 991 return PTR_ERR(foo->p);
@@ -993,24 +993,17 @@ foo_probe()
993 993
994 foo->s = pinctrl_lookup_state(foo->p, PINCTRL_STATE_DEFAULT); 994 foo->s = pinctrl_lookup_state(foo->p, PINCTRL_STATE_DEFAULT);
995 if (IS_ERR(foo->s)) { 995 if (IS_ERR(foo->s)) {
996 pinctrl_put(foo->p);
997 /* FIXME: clean up "foo" here */ 996 /* FIXME: clean up "foo" here */
998 return PTR_ERR(s); 997 return PTR_ERR(s);
999 } 998 }
1000 999
1001 ret = pinctrl_select_state(foo->s); 1000 ret = pinctrl_select_state(foo->s);
1002 if (ret < 0) { 1001 if (ret < 0) {
1003 pinctrl_put(foo->p);
1004 /* FIXME: clean up "foo" here */ 1002 /* FIXME: clean up "foo" here */
1005 return ret; 1003 return ret;
1006 } 1004 }
1007} 1005}
1008 1006
1009foo_remove()
1010{
1011 pinctrl_put(state->p);
1012}
1013
1014This get/lookup/select/put sequence can just as well be handled by bus drivers 1007This get/lookup/select/put sequence can just as well be handled by bus drivers
1015if you don't want each and every driver to handle it and you know the 1008if you don't want each and every driver to handle it and you know the
1016arrangement on your bus. 1009arrangement on your bus.
@@ -1022,6 +1015,11 @@ The semantics of the pinctrl APIs are:
1022 kernel memory to hold the pinmux state. All mapping table parsing or similar 1015 kernel memory to hold the pinmux state. All mapping table parsing or similar
1023 slow operations take place within this API. 1016 slow operations take place within this API.
1024 1017
1018- devm_pinctrl_get() is a variant of pinctrl_get() that causes pinctrl_put()
1019 to be called automatically on the retrieved pointer when the associated
1020 device is removed. It is recommended to use this function over plain
1021 pinctrl_get().
1022
1025- pinctrl_lookup_state() is called in process context to obtain a handle to a 1023- pinctrl_lookup_state() is called in process context to obtain a handle to a
1026 specific state for a the client device. This operation may be slow too. 1024 specific state for a the client device. This operation may be slow too.
1027 1025
@@ -1034,14 +1032,25 @@ The semantics of the pinctrl APIs are:
1034 1032
1035- pinctrl_put() frees all information associated with a pinctrl handle. 1033- pinctrl_put() frees all information associated with a pinctrl handle.
1036 1034
1035- devm_pinctrl_put() is a variant of pinctrl_put() that may be used to
1036 explicitly destroy a pinctrl object returned by devm_pinctrl_get().
1037 However, use of this function will be rare, due to the automatic cleanup
1038 that will occur even without calling it.
1039
1040 pinctrl_get() must be paired with a plain pinctrl_put().
1041 pinctrl_get() may not be paired with devm_pinctrl_put().
1042 devm_pinctrl_get() can optionally be paired with devm_pinctrl_put().
1043 devm_pinctrl_get() may not be paired with plain pinctrl_put().
1044
1037Usually the pin control core handled the get/put pair and call out to the 1045Usually the pin control core handled the get/put pair and call out to the
1038device drivers bookkeeping operations, like checking available functions and 1046device drivers bookkeeping operations, like checking available functions and
1039the associated pins, whereas the enable/disable pass on to the pin controller 1047the associated pins, whereas the enable/disable pass on to the pin controller
1040driver which takes care of activating and/or deactivating the mux setting by 1048driver which takes care of activating and/or deactivating the mux setting by
1041quickly poking some registers. 1049quickly poking some registers.
1042 1050
1043The pins are allocated for your device when you issue the pinctrl_get() call, 1051The pins are allocated for your device when you issue the devm_pinctrl_get()
1044after this you should be able to see this in the debugfs listing of all pins. 1052call, after this you should be able to see this in the debugfs listing of all
1053pins.
1045 1054
1046NOTE: the pinctrl system will return -EPROBE_DEFER if it cannot find the 1055NOTE: the pinctrl system will return -EPROBE_DEFER if it cannot find the
1047requested pinctrl handles, for example if the pinctrl driver has not yet 1056requested pinctrl handles, for example if the pinctrl driver has not yet
@@ -1092,13 +1101,13 @@ it, disables and releases it, and muxes it in on the pins defined by group B:
1092 1101
1093#include <linux/pinctrl/consumer.h> 1102#include <linux/pinctrl/consumer.h>
1094 1103
1095foo_switch() 1104struct pinctrl *p;
1096{ 1105struct pinctrl_state *s1, *s2;
1097 struct pinctrl *p;
1098 struct pinctrl_state *s1, *s2;
1099 1106
1107foo_probe()
1108{
1100 /* Setup */ 1109 /* Setup */
1101 p = pinctrl_get(&device); 1110 p = devm_pinctrl_get(&device);
1102 if (IS_ERR(p)) 1111 if (IS_ERR(p))
1103 ... 1112 ...
1104 1113
@@ -1109,7 +1118,10 @@ foo_switch()
1109 s2 = pinctrl_lookup_state(foo->p, "pos-B"); 1118 s2 = pinctrl_lookup_state(foo->p, "pos-B");
1110 if (IS_ERR(s2)) 1119 if (IS_ERR(s2))
1111 ... 1120 ...
1121}
1112 1122
1123foo_switch()
1124{
1113 /* Enable on position A */ 1125 /* Enable on position A */
1114 ret = pinctrl_select_state(s1); 1126 ret = pinctrl_select_state(s1);
1115 if (ret < 0) 1127 if (ret < 0)
@@ -1123,8 +1135,6 @@ foo_switch()
1123 ... 1135 ...
1124 1136
1125 ... 1137 ...
1126
1127 pinctrl_put(p);
1128} 1138}
1129 1139
1130The above has to be done from process context. 1140The above has to be done from process context.