diff options
author | Linus Walleij <linus.walleij@linaro.org> | 2012-02-09 01:23:28 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-02-10 15:33:02 -0500 |
commit | e93bcee00c43e2bd4037291262111016f4c05793 (patch) | |
tree | e69b5f7ffffb36096949eabdc0526173b25f695d /Documentation/pinctrl.txt | |
parent | 28a8d14cc74a0180323d9150c3d3dbf9dd60d55a (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/pinctrl.txt')
-rw-r--r-- | Documentation/pinctrl.txt | 118 |
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. | |||
728 | All the above functions are mandatory to implement for a pinmux driver. | 728 | All the above functions are mandatory to implement for a pinmux driver. |
729 | 729 | ||
730 | 730 | ||
731 | Pinmux interaction with the GPIO subsystem | 731 | Pin control interaction with the GPIO subsystem |
732 | ========================================== | 732 | =============================================== |
733 | 733 | ||
734 | The public pinmux API contains two functions named pinmux_request_gpio() | 734 | The public pinmux API contains two functions named pinctrl_request_gpio() |
735 | and pinmux_free_gpio(). These two functions shall *ONLY* be called from | 735 | and pinctrl_free_gpio(). These two functions shall *ONLY* be called from |
736 | gpiolib-based drivers as part of their gpio_request() and | 736 | gpiolib-based drivers as part of their gpio_request() and |
737 | gpio_free() semantics. Likewise the pinmux_gpio_direction_[input|output] | 737 | gpio_free() semantics. Likewise the pinctrl_gpio_direction_[input|output] |
738 | shall only be called from within respective gpio_direction_[input|output] | 738 | shall only be called from within respective gpio_direction_[input|output] |
739 | gpiolib implementation. | 739 | gpiolib implementation. |
740 | 740 | ||
741 | NOTE that platforms and individual drivers shall *NOT* request GPIO pins to be | 741 | NOTE that platforms and individual drivers shall *NOT* request GPIO pins to be |
742 | muxed in. Instead, implement a proper gpiolib driver and have that driver | 742 | controlled e.g. muxed in. Instead, implement a proper gpiolib driver and have |
743 | request proper muxing for its pins. | 743 | that driver request proper muxing and other control for its pins. |
744 | 744 | ||
745 | The function list could become long, especially if you can convert every | 745 | The function list could become long, especially if you can convert every |
746 | individual pin into a GPIO pin independent of any other pins, and then try | 746 | individual 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. | |||
749 | In this case, the function array would become 64 entries for each GPIO | 749 | In this case, the function array would become 64 entries for each GPIO |
750 | setting and then the device functions. | 750 | setting and then the device functions. |
751 | 751 | ||
752 | For this reason there are two functions a pinmux driver can implement | 752 | For this reason there are two functions a pin control driver can implement |
753 | to enable only GPIO on an individual pin: .gpio_request_enable() and | 753 | to 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 | |||
764 | will be passed along to this function. | 764 | will be passed along to this function. |
765 | 765 | ||
766 | Alternatively to using these special functions, it is fully allowed to use | 766 | Alternatively to using these special functions, it is fully allowed to use |
767 | named functions for each GPIO pin, the pinmux_request_gpio() will attempt to | 767 | named functions for each GPIO pin, the pinctrl_request_gpio() will attempt to |
768 | obtain the function "gpioN" where "N" is the global GPIO pin number if no | 768 | obtain the function "gpioN" where "N" is the global GPIO pin number if no |
769 | special GPIO-handler is registered. | 769 | special 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 | ||
786 | static const struct pinmux_map __initdata pmx_mapping[] = { | 786 | static 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 | ||
812 | You register this pinmux mapping to the pinmux subsystem by simply: | 812 | You 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 | ||
816 | Since the above construct is pretty common there is a helper macro to make | 816 | Since the above construct is pretty common there is a helper macro to make |
817 | it even more compact which assumes you want to use pinctrl-foo and position | 817 | it even more compact which assumes you want to use pinctrl-foo and position |
818 | 0 for mapping, for example: | 818 | 0 for mapping, for example: |
819 | 819 | ||
820 | static struct pinmux_map __initdata pmx_mapping[] = { | 820 | static 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: | |||
901 | The result of grabbing this mapping from the device with something like | 901 | The result of grabbing this mapping from the device with something like |
902 | this (see next paragraph): | 902 | this (see next paragraph): |
903 | 903 | ||
904 | pmx = pinmux_get(&device, "8bit"); | 904 | p = pinctrl_get(&device, "8bit"); |
905 | 905 | ||
906 | Will be that you activate all the three bottom records in the mapping at | 906 | Will be that you activate all the three bottom records in the mapping at |
907 | once. Since they share the same name, pin controller device, funcion and | 907 | once. Since they share the same name, pin controller device, funcion and |
@@ -913,44 +913,44 @@ pinmux core. | |||
913 | Pinmux requests from drivers | 913 | Pinmux requests from drivers |
914 | ============================ | 914 | ============================ |
915 | 915 | ||
916 | Generally it is discouraged to let individual drivers get and enable pinmuxes. | 916 | Generally it is discouraged to let individual drivers get and enable pin |
917 | So if possible, handle the pinmuxes in platform code or some other place where | 917 | control. So if possible, handle the pin control in platform code or some other |
918 | you have access to all the affected struct device * pointers. In some cases | 918 | place where you have access to all the affected struct device * pointers. In |
919 | where a driver needs to switch between different mux mappings at runtime | 919 | some cases where a driver needs to e.g. switch between different mux mappings |
920 | this is not possible. | 920 | at runtime this is not possible. |
921 | 921 | ||
922 | A driver may request a certain mux to be activated, usually just the default | 922 | A driver may request a certain control state to be activated, usually just the |
923 | mux like this: | 923 | default state like this: |
924 | 924 | ||
925 | #include <linux/pinctrl/consumer.h> | 925 | #include <linux/pinctrl/consumer.h> |
926 | 926 | ||
927 | struct foo_state { | 927 | struct foo_state { |
928 | struct pinmux *pmx; | 928 | struct pinctrl *p; |
929 | ... | 929 | ... |
930 | }; | 930 | }; |
931 | 931 | ||
932 | foo_probe() | 932 | foo_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 | ||
945 | foo_remove() | 945 | foo_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 | ||
951 | If you want to grab a specific mux mapping and not just the first one found for | 951 | If you want to grab a specific control mapping and not just the first one |
952 | this device you can specify a specific mapping name, for example in the above | 952 | found for this device you can specify a specific mapping name, for example in |
953 | example the second i2c0 setting: pinmux_get(&device, "spi0-pos-B"); | 953 | the above example the second i2c0 setting: pinctrl_get(&device, "spi0-pos-B"); |
954 | 954 | ||
955 | This get/enable/disable/put sequence can just as well be handled by bus drivers | 955 | This get/enable/disable/put sequence can just as well be handled by bus drivers |
956 | if you don't want each and every driver to handle it and you know the | 956 | if 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 | ||
959 | The semantics of the get/enable respective disable/put is as follows: | 959 | The 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 | ||
973 | Usually the pinmux core handled the get/put pair and call out to the device | 973 | Usually the pin control core handled the get/put pair and call out to the |
974 | drivers bookkeeping operations, like checking available functions and the | 974 | device drivers bookkeeping operations, like checking available functions and |
975 | associated pins, whereas the enable/disable pass on to the pin controller | 975 | the associated pins, whereas the enable/disable pass on to the pin controller |
976 | driver which takes care of activating and/or deactivating the mux setting by | 976 | driver which takes care of activating and/or deactivating the mux setting by |
977 | quickly poking some registers. | 977 | quickly poking some registers. |
978 | 978 | ||
979 | The pins are allocated for your device when you issue the pinmux_get() call, | 979 | The pins are allocated for your device when you issue the pinctrl_get() call, |
980 | after this you should be able to see this in the debugfs listing of all pins. | 980 | after this you should be able to see this in the debugfs listing of all pins. |
981 | 981 | ||
982 | 982 | ||
983 | System pinmux hogging | 983 | System pin control hogging |
984 | ===================== | 984 | ========================== |
985 | 985 | ||
986 | A system pinmux map entry, i.e. a pinmux setting that does not have a device | 986 | A system pin control map entry, i.e. a pin control setting that does not have |
987 | associated with it, can be hogged by the core when the pin controller is | 987 | a device associated with it, can be hogged by the core when the pin controller |
988 | registered. This means that the core will attempt to call pinmux_get() and | 988 | is registered. This means that the core will attempt to call pinctrl_get() and |
989 | pinmux_enable() on it immediately after the pin control device has been | 989 | pinctrl_enable() on it immediately after the pin control device has been |
990 | registered. | 990 | registered. |
991 | 991 | ||
992 | This is enabled by simply setting the .hog_on_boot field in the map to true, | 992 | This 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 | |||
1003 | mux settings on the primary pin controller, there is a convenience macro for | 1003 | mux settings on the primary pin controller, there is a convenience macro for |
1004 | this: | 1004 | this: |
1005 | 1005 | ||
1006 | PINMUX_MAP_PRIMARY_SYS_HOG("POWERMAP", "power_func") | 1006 | PIN_MAP_PRIMARY_SYS_HOG("POWERMAP", "power_func") |
1007 | 1007 | ||
1008 | This gives the exact same result as the above construction. | 1008 | This 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 | ||
1026 | foo_switch() | 1026 | foo_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 | ||