aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2012-02-09 01:23:28 -0500
committerLinus Walleij <linus.walleij@linaro.org>2012-02-10 15:33:02 -0500
commite93bcee00c43e2bd4037291262111016f4c05793 (patch)
treee69b5f7ffffb36096949eabdc0526173b25f695d /Documentation
parent28a8d14cc74a0180323d9150c3d3dbf9dd60d55a (diff)
pinctrl: move generic functions to the pinctrl_ namespace
Since we want to use the former pinmux handles and mapping tables for generic control involving both muxing and configuration we begin refactoring by renaming them from pinmux_* to pinctrl_*. ChangeLog v1->v2: - Also rename the PINMUX_* macros in machine.h to PIN_ as indicated in the documentation so as to reflect the generic nature of these mapping entries from now on. Acked-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/pinctrl.txt118
1 files changed, 59 insertions, 59 deletions
diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt
index b268832c49d2..2e7132355db8 100644
--- a/Documentation/pinctrl.txt
+++ b/Documentation/pinctrl.txt
@@ -728,19 +728,19 @@ same time.
728All the above functions are mandatory to implement for a pinmux driver. 728All the above functions are mandatory to implement for a pinmux driver.
729 729
730 730
731Pinmux interaction with the GPIO subsystem 731Pin control interaction with the GPIO subsystem
732========================================== 732===============================================
733 733
734The public pinmux API contains two functions named pinmux_request_gpio() 734The public pinmux API contains two functions named pinctrl_request_gpio()
735and pinmux_free_gpio(). These two functions shall *ONLY* be called from 735and pinctrl_free_gpio(). These two functions shall *ONLY* be called from
736gpiolib-based drivers as part of their gpio_request() and 736gpiolib-based drivers as part of their gpio_request() and
737gpio_free() semantics. Likewise the pinmux_gpio_direction_[input|output] 737gpio_free() semantics. Likewise the pinctrl_gpio_direction_[input|output]
738shall only be called from within respective gpio_direction_[input|output] 738shall only be called from within respective gpio_direction_[input|output]
739gpiolib implementation. 739gpiolib implementation.
740 740
741NOTE that platforms and individual drivers shall *NOT* request GPIO pins to be 741NOTE that platforms and individual drivers shall *NOT* request GPIO pins to be
742muxed in. Instead, implement a proper gpiolib driver and have that driver 742controlled e.g. muxed in. Instead, implement a proper gpiolib driver and have
743request proper muxing for its pins. 743that driver request proper muxing and other control for its pins.
744 744
745The function list could become long, especially if you can convert every 745The function list could become long, especially if you can convert every
746individual pin into a GPIO pin independent of any other pins, and then try 746individual pin into a GPIO pin independent of any other pins, and then try
@@ -749,7 +749,7 @@ the approach to define every pin as a function.
749In this case, the function array would become 64 entries for each GPIO 749In this case, the function array would become 64 entries for each GPIO
750setting and then the device functions. 750setting and then the device functions.
751 751
752For this reason there are two functions a pinmux driver can implement 752For this reason there are two functions a pin control driver can implement
753to enable only GPIO on an individual pin: .gpio_request_enable() and 753to enable only GPIO on an individual pin: .gpio_request_enable() and
754.gpio_disable_free(). 754.gpio_disable_free().
755 755
@@ -764,7 +764,7 @@ gpiolib driver and the affected GPIO range, pin offset and desired direction
764will be passed along to this function. 764will be passed along to this function.
765 765
766Alternatively to using these special functions, it is fully allowed to use 766Alternatively to using these special functions, it is fully allowed to use
767named functions for each GPIO pin, the pinmux_request_gpio() will attempt to 767named functions for each GPIO pin, the pinctrl_request_gpio() will attempt to
768obtain the function "gpioN" where "N" is the global GPIO pin number if no 768obtain the function "gpioN" where "N" is the global GPIO pin number if no
769special GPIO-handler is registered. 769special GPIO-handler is registered.
770 770
@@ -783,7 +783,7 @@ spi on the second function mapping:
783 783
784#include <linux/pinctrl/machine.h> 784#include <linux/pinctrl/machine.h>
785 785
786static const struct pinmux_map __initdata pmx_mapping[] = { 786static const struct pinctrl_map __initdata mapping[] = {
787 { 787 {
788 .ctrl_dev_name = "pinctrl-foo", 788 .ctrl_dev_name = "pinctrl-foo",
789 .function = "spi0", 789 .function = "spi0",
@@ -811,14 +811,14 @@ to map.
811 811
812You register this pinmux mapping to the pinmux subsystem by simply: 812You register this pinmux mapping to the pinmux subsystem by simply:
813 813
814 ret = pinmux_register_mappings(pmx_mapping, ARRAY_SIZE(pmx_mapping)); 814 ret = pinctrl_register_mappings(mapping, ARRAY_SIZE(mapping));
815 815
816Since the above construct is pretty common there is a helper macro to make 816Since the above construct is pretty common there is a helper macro to make
817it even more compact which assumes you want to use pinctrl-foo and position 817it even more compact which assumes you want to use pinctrl-foo and position
8180 for mapping, for example: 8180 for mapping, for example:
819 819
820static struct pinmux_map __initdata pmx_mapping[] = { 820static struct pinctrl_map __initdata mapping[] = {
821 PINMUX_MAP("I2CMAP", "pinctrl-foo", "i2c0", "foo-i2c.0"), 821 PIN_MAP("I2CMAP", "pinctrl-foo", "i2c0", "foo-i2c.0"),
822}; 822};
823 823
824 824
@@ -901,7 +901,7 @@ case), we define a mapping like this:
901The result of grabbing this mapping from the device with something like 901The result of grabbing this mapping from the device with something like
902this (see next paragraph): 902this (see next paragraph):
903 903
904 pmx = pinmux_get(&device, "8bit"); 904 p = pinctrl_get(&device, "8bit");
905 905
906Will be that you activate all the three bottom records in the mapping at 906Will be that you activate all the three bottom records in the mapping at
907once. Since they share the same name, pin controller device, funcion and 907once. Since they share the same name, pin controller device, funcion and
@@ -913,44 +913,44 @@ pinmux core.
913Pinmux requests from drivers 913Pinmux requests from drivers
914============================ 914============================
915 915
916Generally it is discouraged to let individual drivers get and enable pinmuxes. 916Generally it is discouraged to let individual drivers get and enable pin
917So if possible, handle the pinmuxes in platform code or some other place where 917control. So if possible, handle the pin control in platform code or some other
918you have access to all the affected struct device * pointers. In some cases 918place where you have access to all the affected struct device * pointers. In
919where a driver needs to switch between different mux mappings at runtime 919some cases where a driver needs to e.g. switch between different mux mappings
920this is not possible. 920at runtime this is not possible.
921 921
922A driver may request a certain mux to be activated, usually just the default 922A driver may request a certain control state to be activated, usually just the
923mux like this: 923default state like this:
924 924
925#include <linux/pinctrl/consumer.h> 925#include <linux/pinctrl/consumer.h>
926 926
927struct foo_state { 927struct foo_state {
928 struct pinmux *pmx; 928 struct pinctrl *p;
929 ... 929 ...
930}; 930};
931 931
932foo_probe() 932foo_probe()
933{ 933{
934 /* Allocate a state holder named "state" etc */ 934 /* Allocate a state holder named "state" etc */
935 struct pinmux pmx; 935 struct pinctrl p;
936 936
937 pmx = pinmux_get(&device, NULL); 937 p = pinctrl_get(&device, NULL);
938 if IS_ERR(pmx) 938 if IS_ERR(p)
939 return PTR_ERR(pmx); 939 return PTR_ERR(p);
940 pinmux_enable(pmx); 940 pinctrl_enable(p);
941 941
942 state->pmx = pmx; 942 state->p = p;
943} 943}
944 944
945foo_remove() 945foo_remove()
946{ 946{
947 pinmux_disable(state->pmx); 947 pinctrl_disable(state->p);
948 pinmux_put(state->pmx); 948 pinctrl_put(state->p);
949} 949}
950 950
951If you want to grab a specific mux mapping and not just the first one found for 951If you want to grab a specific control mapping and not just the first one
952this device you can specify a specific mapping name, for example in the above 952found for this device you can specify a specific mapping name, for example in
953example the second i2c0 setting: pinmux_get(&device, "spi0-pos-B"); 953the above example the second i2c0 setting: pinctrl_get(&device, "spi0-pos-B");
954 954
955This get/enable/disable/put sequence can just as well be handled by bus drivers 955This get/enable/disable/put sequence can just as well be handled by bus drivers
956if you don't want each and every driver to handle it and you know the 956if you don't want each and every driver to handle it and you know the
@@ -958,35 +958,35 @@ arrangement on your bus.
958 958
959The semantics of the get/enable respective disable/put is as follows: 959The semantics of the get/enable respective disable/put is as follows:
960 960
961- pinmux_get() is called in process context to reserve the pins affected with 961- pinctrl_get() is called in process context to reserve the pins affected with
962 a certain mapping and set up the pinmux core and the driver. It will allocate 962 a certain mapping and set up the pinmux core and the driver. It will allocate
963 a struct from the kernel memory to hold the pinmux state. 963 a struct from the kernel memory to hold the pinmux state.
964 964
965- pinmux_enable()/pinmux_disable() is quick and can be called from fastpath 965- pinctrl_enable()/pinctrl_disable() is quick and can be called from fastpath
966 (irq context) when you quickly want to set up/tear down the hardware muxing 966 (irq context) when you quickly want to set up/tear down the hardware muxing
967 when running a device driver. Usually it will just poke some values into a 967 when running a device driver. Usually it will just poke some values into a
968 register. 968 register.
969 969
970- pinmux_disable() is called in process context to tear down the pin requests 970- pinctrl_disable() is called in process context to tear down the pin requests
971 and release the state holder struct for the mux setting. 971 and release the state holder struct for the mux setting etc.
972 972
973Usually the pinmux core handled the get/put pair and call out to the device 973Usually the pin control core handled the get/put pair and call out to the
974drivers bookkeeping operations, like checking available functions and the 974device drivers bookkeeping operations, like checking available functions and
975associated pins, whereas the enable/disable pass on to the pin controller 975the associated pins, whereas the enable/disable pass on to the pin controller
976driver which takes care of activating and/or deactivating the mux setting by 976driver which takes care of activating and/or deactivating the mux setting by
977quickly poking some registers. 977quickly poking some registers.
978 978
979The pins are allocated for your device when you issue the pinmux_get() call, 979The pins are allocated for your device when you issue the pinctrl_get() call,
980after this you should be able to see this in the debugfs listing of all pins. 980after this you should be able to see this in the debugfs listing of all pins.
981 981
982 982
983System pinmux hogging 983System pin control hogging
984===================== 984==========================
985 985
986A system pinmux map entry, i.e. a pinmux setting that does not have a device 986A system pin control map entry, i.e. a pin control setting that does not have
987associated with it, can be hogged by the core when the pin controller is 987a device associated with it, can be hogged by the core when the pin controller
988registered. This means that the core will attempt to call pinmux_get() and 988is registered. This means that the core will attempt to call pinctrl_get() and
989pinmux_enable() on it immediately after the pin control device has been 989pinctrl_enable() on it immediately after the pin control device has been
990registered. 990registered.
991 991
992This is enabled by simply setting the .hog_on_boot field in the map to true, 992This is enabled by simply setting the .hog_on_boot field in the map to true,
@@ -1003,7 +1003,7 @@ Since it may be common to request the core to hog a few always-applicable
1003mux settings on the primary pin controller, there is a convenience macro for 1003mux settings on the primary pin controller, there is a convenience macro for
1004this: 1004this:
1005 1005
1006PINMUX_MAP_PRIMARY_SYS_HOG("POWERMAP", "power_func") 1006PIN_MAP_PRIMARY_SYS_HOG("POWERMAP", "power_func")
1007 1007
1008This gives the exact same result as the above construction. 1008This gives the exact same result as the above construction.
1009 1009
@@ -1025,23 +1025,23 @@ it, disables and releases it, and muxes it in on the pins defined by group B:
1025 1025
1026foo_switch() 1026foo_switch()
1027{ 1027{
1028 struct pinmux *pmx; 1028 struct pinctrl *p;
1029 1029
1030 /* Enable on position A */ 1030 /* Enable on position A */
1031 pmx = pinmux_get(&device, "spi0-pos-A"); 1031 p = pinctrl_get(&device, "spi0-pos-A");
1032 if IS_ERR(pmx) 1032 if IS_ERR(p)
1033 return PTR_ERR(pmx); 1033 return PTR_ERR(p);
1034 pinmux_enable(pmx); 1034 pinctrl_enable(p);
1035 1035
1036 /* This releases the pins again */ 1036 /* This releases the pins again */
1037 pinmux_disable(pmx); 1037 pinctrl_disable(p);
1038 pinmux_put(pmx); 1038 pinctrl_put(p);
1039 1039
1040 /* Enable on position B */ 1040 /* Enable on position B */
1041 pmx = pinmux_get(&device, "spi0-pos-B"); 1041 p = pinctrl_get(&device, "spi0-pos-B");
1042 if IS_ERR(pmx) 1042 if IS_ERR(p)
1043 return PTR_ERR(pmx); 1043 return PTR_ERR(p);
1044 pinmux_enable(pmx); 1044 pinctrl_enable(p);
1045 ... 1045 ...
1046} 1046}
1047 1047