aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/pinctrl.txt118
-rw-r--r--arch/arm/mach-u300/core.c34
-rw-r--r--drivers/pinctrl/core.c4
-rw-r--r--drivers/pinctrl/core.h8
-rw-r--r--drivers/pinctrl/pinctrl-coh901.c4
-rw-r--r--drivers/pinctrl/pinmux.c351
-rw-r--r--drivers/pinctrl/pinmux.h8
-rw-r--r--include/linux/pinctrl/consumer.h34
-rw-r--r--include/linux/pinctrl/machine.h26
9 files changed, 294 insertions, 293 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
diff --git a/arch/arm/mach-u300/core.c b/arch/arm/mach-u300/core.c
index 1429e5282198..bb1034f8c2f5 100644
--- a/arch/arm/mach-u300/core.c
+++ b/arch/arm/mach-u300/core.c
@@ -1605,21 +1605,21 @@ static struct platform_device pinmux_device = {
1605}; 1605};
1606 1606
1607/* Pinmux settings */ 1607/* Pinmux settings */
1608static struct pinmux_map __initdata u300_pinmux_map[] = { 1608static struct pinctrl_map __initdata u300_pinmux_map[] = {
1609 /* anonymous maps for chip power and EMIFs */ 1609 /* anonymous maps for chip power and EMIFs */
1610 PINMUX_MAP_SYS_HOG("POWER", "pinmux-u300", "power"), 1610 PIN_MAP_SYS_HOG("POWER", "pinmux-u300", "power"),
1611 PINMUX_MAP_SYS_HOG("EMIF0", "pinmux-u300", "emif0"), 1611 PIN_MAP_SYS_HOG("EMIF0", "pinmux-u300", "emif0"),
1612 PINMUX_MAP_SYS_HOG("EMIF1", "pinmux-u300", "emif1"), 1612 PIN_MAP_SYS_HOG("EMIF1", "pinmux-u300", "emif1"),
1613 /* per-device maps for MMC/SD, SPI and UART */ 1613 /* per-device maps for MMC/SD, SPI and UART */
1614 PINMUX_MAP("MMCSD", "pinmux-u300", "mmc0", "mmci"), 1614 PIN_MAP("MMCSD", "pinmux-u300", "mmc0", "mmci"),
1615 PINMUX_MAP("SPI", "pinmux-u300", "spi0", "pl022"), 1615 PIN_MAP("SPI", "pinmux-u300", "spi0", "pl022"),
1616 PINMUX_MAP("UART0", "pinmux-u300", "uart0", "uart0"), 1616 PIN_MAP("UART0", "pinmux-u300", "uart0", "uart0"),
1617}; 1617};
1618 1618
1619struct u300_mux_hog { 1619struct u300_mux_hog {
1620 const char *name; 1620 const char *name;
1621 struct device *dev; 1621 struct device *dev;
1622 struct pinmux *pmx; 1622 struct pinctrl *p;
1623}; 1623};
1624 1624
1625static struct u300_mux_hog u300_mux_hogs[] = { 1625static struct u300_mux_hog u300_mux_hogs[] = {
@@ -1637,31 +1637,31 @@ static struct u300_mux_hog u300_mux_hogs[] = {
1637 }, 1637 },
1638}; 1638};
1639 1639
1640static int __init u300_pinmux_fetch(void) 1640static int __init u300_pinctrl_fetch(void)
1641{ 1641{
1642 int i; 1642 int i;
1643 1643
1644 for (i = 0; i < ARRAY_SIZE(u300_mux_hogs); i++) { 1644 for (i = 0; i < ARRAY_SIZE(u300_mux_hogs); i++) {
1645 struct pinmux *pmx; 1645 struct pinctrl *p;
1646 int ret; 1646 int ret;
1647 1647
1648 pmx = pinmux_get(u300_mux_hogs[i].dev, NULL); 1648 p = pinctrl_get(u300_mux_hogs[i].dev, NULL);
1649 if (IS_ERR(pmx)) { 1649 if (IS_ERR(p)) {
1650 pr_err("u300: could not get pinmux hog %s\n", 1650 pr_err("u300: could not get pinmux hog %s\n",
1651 u300_mux_hogs[i].name); 1651 u300_mux_hogs[i].name);
1652 continue; 1652 continue;
1653 } 1653 }
1654 ret = pinmux_enable(pmx); 1654 ret = pinctrl_enable(p);
1655 if (ret) { 1655 if (ret) {
1656 pr_err("u300: could enable pinmux hog %s\n", 1656 pr_err("u300: could enable pinmux hog %s\n",
1657 u300_mux_hogs[i].name); 1657 u300_mux_hogs[i].name);
1658 continue; 1658 continue;
1659 } 1659 }
1660 u300_mux_hogs[i].pmx = pmx; 1660 u300_mux_hogs[i].p = p;
1661 } 1661 }
1662 return 0; 1662 return 0;
1663} 1663}
1664subsys_initcall(u300_pinmux_fetch); 1664subsys_initcall(u300_pinctrl_fetch);
1665 1665
1666/* 1666/*
1667 * Notice that AMBA devices are initialized before platform devices. 1667 * Notice that AMBA devices are initialized before platform devices.
@@ -1861,8 +1861,8 @@ void __init u300_init_devices(void)
1861 u300_assign_physmem(); 1861 u300_assign_physmem();
1862 1862
1863 /* Initialize pinmuxing */ 1863 /* Initialize pinmuxing */
1864 pinmux_register_mappings(u300_pinmux_map, 1864 pinctrl_register_mappings(u300_pinmux_map,
1865 ARRAY_SIZE(u300_pinmux_map)); 1865 ARRAY_SIZE(u300_pinmux_map));
1866 1866
1867 /* Register subdevices on the I2C buses */ 1867 /* Register subdevices on the I2C buses */
1868 u300_i2c_register_board_devices(); 1868 u300_i2c_register_board_devices();
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 4f10476cc1f2..75c6a6bb6c0a 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -624,7 +624,7 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
624 mutex_lock(&pinctrldev_list_mutex); 624 mutex_lock(&pinctrldev_list_mutex);
625 list_add(&pctldev->node, &pinctrldev_list); 625 list_add(&pctldev->node, &pinctrldev_list);
626 mutex_unlock(&pinctrldev_list_mutex); 626 mutex_unlock(&pinctrldev_list_mutex);
627 pinmux_hog_maps(pctldev); 627 pinctrl_hog_maps(pctldev);
628 return pctldev; 628 return pctldev;
629 629
630out_err: 630out_err:
@@ -645,7 +645,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev)
645 return; 645 return;
646 646
647 pinctrl_remove_device_debugfs(pctldev); 647 pinctrl_remove_device_debugfs(pctldev);
648 pinmux_unhog_maps(pctldev); 648 pinctrl_unhog_maps(pctldev);
649 /* TODO: check that no pinmuxes are still active? */ 649 /* TODO: check that no pinmuxes are still active? */
650 mutex_lock(&pinctrldev_list_mutex); 650 mutex_lock(&pinctrldev_list_mutex);
651 list_del(&pctldev->node); 651 list_del(&pctldev->node);
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 8a8b02e9c18e..7a89888fce94 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -28,8 +28,8 @@ struct pinctrl_gpio_range;
28 * @owner: module providing the pin controller, used for refcounting 28 * @owner: module providing the pin controller, used for refcounting
29 * @driver_data: driver data for drivers registering to the pin controller 29 * @driver_data: driver data for drivers registering to the pin controller
30 * subsystem 30 * subsystem
31 * @pinmux_hogs_lock: lock for the pinmux hog list 31 * @pinctrl_hogs_lock: lock for the pin control hog list
32 * @pinmux_hogs: list of pinmux maps hogged by this device 32 * @pinctrl_hogs: list of pin control maps hogged by this device
33 */ 33 */
34struct pinctrl_dev { 34struct pinctrl_dev {
35 struct list_head node; 35 struct list_head node;
@@ -45,8 +45,8 @@ struct pinctrl_dev {
45 struct dentry *device_root; 45 struct dentry *device_root;
46#endif 46#endif
47#ifdef CONFIG_PINMUX 47#ifdef CONFIG_PINMUX
48 struct mutex pinmux_hogs_lock; 48 struct mutex pinctrl_hogs_lock;
49 struct list_head pinmux_hogs; 49 struct list_head pinctrl_hogs;
50#endif 50#endif
51}; 51};
52 52
diff --git a/drivers/pinctrl/pinctrl-coh901.c b/drivers/pinctrl/pinctrl-coh901.c
index 8bac3f093d58..eba232a46a82 100644
--- a/drivers/pinctrl/pinctrl-coh901.c
+++ b/drivers/pinctrl/pinctrl-coh901.c
@@ -360,14 +360,14 @@ static int u300_gpio_request(struct gpio_chip *chip, unsigned offset)
360 */ 360 */
361 int gpio = chip->base + offset; 361 int gpio = chip->base + offset;
362 362
363 return pinmux_request_gpio(gpio); 363 return pinctrl_request_gpio(gpio);
364} 364}
365 365
366static void u300_gpio_free(struct gpio_chip *chip, unsigned offset) 366static void u300_gpio_free(struct gpio_chip *chip, unsigned offset)
367{ 367{
368 int gpio = chip->base + offset; 368 int gpio = chip->base + offset;
369 369
370 pinmux_free_gpio(gpio); 370 pinctrl_free_gpio(gpio);
371} 371}
372 372
373static int u300_gpio_get(struct gpio_chip *chip, unsigned offset) 373static int u300_gpio_get(struct gpio_chip *chip, unsigned offset)
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 1311f1d22002..773835d18f55 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Core driver for the pin muxing portions of the pin control subsystem 2 * Core driver for the pin muxing portions of the pin control subsystem
3 * 3 *
4 * Copyright (C) 2011 ST-Ericsson SA 4 * Copyright (C) 2011-2012 ST-Ericsson SA
5 * Written on behalf of Linaro for ST-Ericsson 5 * Written on behalf of Linaro for ST-Ericsson
6 * Based on bits of regulator core, gpio core and clk core 6 * Based on bits of regulator core, gpio core and clk core
7 * 7 *
@@ -29,13 +29,13 @@
29#include <linux/pinctrl/pinmux.h> 29#include <linux/pinctrl/pinmux.h>
30#include "core.h" 30#include "core.h"
31 31
32/* List of pinmuxes */ 32/* List of pin controller handles */
33static DEFINE_MUTEX(pinmux_list_mutex); 33static DEFINE_MUTEX(pinctrl_list_mutex);
34static LIST_HEAD(pinmux_list); 34static LIST_HEAD(pinctrl_list);
35 35
36/* Global pinmux maps */ 36/* Global pinctrl maps */
37static struct pinmux_map *pinmux_maps; 37static struct pinctrl_map *pinctrl_maps;
38static unsigned pinmux_maps_num; 38static unsigned pinctrl_maps_num;
39 39
40/** 40/**
41 * struct pinmux_group - group list item for pinmux groups 41 * struct pinmux_group - group list item for pinmux groups
@@ -48,12 +48,12 @@ struct pinmux_group {
48}; 48};
49 49
50/** 50/**
51 * struct pinmux - per-device pinmux state holder 51 * struct pinctrl - per-device pin control state holder
52 * @node: global list node 52 * @node: global list node
53 * @dev: the device using this pinmux 53 * @dev: the device using this pin control handle
54 * @usecount: the number of active users of this mux setting, used to keep 54 * @usecount: the number of active users of this pin controller setting, used
55 * track of nested use cases 55 * to keep track of nested use cases
56 * @pctldev: pin control device handling this pinmux 56 * @pctldev: pin control device handling this pin control handle
57 * @func_selector: the function selector for the pinmux device handling 57 * @func_selector: the function selector for the pinmux device handling
58 * this pinmux 58 * this pinmux
59 * @groups: the group selectors for the pinmux device and 59 * @groups: the group selectors for the pinmux device and
@@ -62,7 +62,7 @@ struct pinmux_group {
62 * get/put/enable/disable 62 * get/put/enable/disable
63 * @mutex: a lock for the pinmux state holder 63 * @mutex: a lock for the pinmux state holder
64 */ 64 */
65struct pinmux { 65struct pinctrl {
66 struct list_head node; 66 struct list_head node;
67 struct device *dev; 67 struct device *dev;
68 unsigned usecount; 68 unsigned usecount;
@@ -73,15 +73,15 @@ struct pinmux {
73}; 73};
74 74
75/** 75/**
76 * struct pinmux_hog - a list item to stash mux hogs 76 * struct pinctrl_hog - a list item to stash control hogs
77 * @node: pinmux hog list node 77 * @node: pin control hog list node
78 * @map: map entry responsible for this hogging 78 * @map: map entry responsible for this hogging
79 * @pmx: the pinmux hogged by this item 79 * @pmx: the pin control hogged by this item
80 */ 80 */
81struct pinmux_hog { 81struct pinctrl_hog {
82 struct list_head node; 82 struct list_head node;
83 struct pinmux_map const *map; 83 struct pinctrl_map const *map;
84 struct pinmux *pmx; 84 struct pinctrl *p;
85}; 85};
86 86
87/** 87/**
@@ -207,14 +207,14 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
207} 207}
208 208
209/** 209/**
210 * pinmux_request_gpio() - request a single pin to be muxed in as GPIO 210 * pinctrl_request_gpio() - request a single pin to be used in as GPIO
211 * @gpio: the GPIO pin number from the GPIO subsystem number space 211 * @gpio: the GPIO pin number from the GPIO subsystem number space
212 * 212 *
213 * This function should *ONLY* be used from gpiolib-based GPIO drivers, 213 * This function should *ONLY* be used from gpiolib-based GPIO drivers,
214 * as part of their gpio_request() semantics, platforms and individual drivers 214 * as part of their gpio_request() semantics, platforms and individual drivers
215 * shall *NOT* request GPIO pins to be muxed in. 215 * shall *NOT* request GPIO pins to be muxed in.
216 */ 216 */
217int pinmux_request_gpio(unsigned gpio) 217int pinctrl_request_gpio(unsigned gpio)
218{ 218{
219 char gpiostr[16]; 219 char gpiostr[16];
220 const char *function; 220 const char *function;
@@ -243,17 +243,17 @@ int pinmux_request_gpio(unsigned gpio)
243 243
244 return ret; 244 return ret;
245} 245}
246EXPORT_SYMBOL_GPL(pinmux_request_gpio); 246EXPORT_SYMBOL_GPL(pinctrl_request_gpio);
247 247
248/** 248/**
249 * pinmux_free_gpio() - free a single pin, currently used as GPIO 249 * pinctrl_free_gpio() - free control on a single pin, currently used as GPIO
250 * @gpio: the GPIO pin number from the GPIO subsystem number space 250 * @gpio: the GPIO pin number from the GPIO subsystem number space
251 * 251 *
252 * This function should *ONLY* be used from gpiolib-based GPIO drivers, 252 * This function should *ONLY* be used from gpiolib-based GPIO drivers,
253 * as part of their gpio_free() semantics, platforms and individual drivers 253 * as part of their gpio_free() semantics, platforms and individual drivers
254 * shall *NOT* request GPIO pins to be muxed out. 254 * shall *NOT* request GPIO pins to be muxed out.
255 */ 255 */
256void pinmux_free_gpio(unsigned gpio) 256void pinctrl_free_gpio(unsigned gpio)
257{ 257{
258 struct pinctrl_dev *pctldev; 258 struct pinctrl_dev *pctldev;
259 struct pinctrl_gpio_range *range; 259 struct pinctrl_gpio_range *range;
@@ -271,9 +271,9 @@ void pinmux_free_gpio(unsigned gpio)
271 func = pin_free(pctldev, pin, range); 271 func = pin_free(pctldev, pin, range);
272 kfree(func); 272 kfree(func);
273} 273}
274EXPORT_SYMBOL_GPL(pinmux_free_gpio); 274EXPORT_SYMBOL_GPL(pinctrl_free_gpio);
275 275
276static int pinmux_gpio_direction(unsigned gpio, bool input) 276static int pinctrl_gpio_direction(unsigned gpio, bool input)
277{ 277{
278 struct pinctrl_dev *pctldev; 278 struct pinctrl_dev *pctldev;
279 struct pinctrl_gpio_range *range; 279 struct pinctrl_gpio_range *range;
@@ -299,36 +299,36 @@ static int pinmux_gpio_direction(unsigned gpio, bool input)
299} 299}
300 300
301/** 301/**
302 * pinmux_gpio_direction_input() - request a GPIO pin to go into input mode 302 * pinctrl_gpio_direction_input() - request a GPIO pin to go into input mode
303 * @gpio: the GPIO pin number from the GPIO subsystem number space 303 * @gpio: the GPIO pin number from the GPIO subsystem number space
304 * 304 *
305 * This function should *ONLY* be used from gpiolib-based GPIO drivers, 305 * This function should *ONLY* be used from gpiolib-based GPIO drivers,
306 * as part of their gpio_direction_input() semantics, platforms and individual 306 * as part of their gpio_direction_input() semantics, platforms and individual
307 * drivers shall *NOT* touch pinmux GPIO calls. 307 * drivers shall *NOT* touch pin control GPIO calls.
308 */ 308 */
309int pinmux_gpio_direction_input(unsigned gpio) 309int pinctrl_gpio_direction_input(unsigned gpio)
310{ 310{
311 return pinmux_gpio_direction(gpio, true); 311 return pinctrl_gpio_direction(gpio, true);
312} 312}
313EXPORT_SYMBOL_GPL(pinmux_gpio_direction_input); 313EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_input);
314 314
315/** 315/**
316 * pinmux_gpio_direction_output() - request a GPIO pin to go into output mode 316 * pinctrl_gpio_direction_output() - request a GPIO pin to go into output mode
317 * @gpio: the GPIO pin number from the GPIO subsystem number space 317 * @gpio: the GPIO pin number from the GPIO subsystem number space
318 * 318 *
319 * This function should *ONLY* be used from gpiolib-based GPIO drivers, 319 * This function should *ONLY* be used from gpiolib-based GPIO drivers,
320 * as part of their gpio_direction_output() semantics, platforms and individual 320 * as part of their gpio_direction_output() semantics, platforms and individual
321 * drivers shall *NOT* touch pinmux GPIO calls. 321 * drivers shall *NOT* touch pin control GPIO calls.
322 */ 322 */
323int pinmux_gpio_direction_output(unsigned gpio) 323int pinctrl_gpio_direction_output(unsigned gpio)
324{ 324{
325 return pinmux_gpio_direction(gpio, false); 325 return pinctrl_gpio_direction(gpio, false);
326} 326}
327EXPORT_SYMBOL_GPL(pinmux_gpio_direction_output); 327EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_output);
328 328
329/** 329/**
330 * pinmux_register_mappings() - register a set of pinmux mappings 330 * pinctrl_register_mappings() - register a set of pin controller mappings
331 * @maps: the pinmux mappings table to register, this should be marked with 331 * @maps: the pincontrol mappings table to register, this should be marked with
332 * __initdata so it can be discarded after boot, this function will 332 * __initdata so it can be discarded after boot, this function will
333 * perform a shallow copy for the mapping entries. 333 * perform a shallow copy for the mapping entries.
334 * @num_maps: the number of maps in the mapping table 334 * @num_maps: the number of maps in the mapping table
@@ -338,8 +338,8 @@ EXPORT_SYMBOL_GPL(pinmux_gpio_direction_output);
338 * passed into this function will be owned by the pinmux core and cannot be 338 * passed into this function will be owned by the pinmux core and cannot be
339 * freed. 339 * freed.
340 */ 340 */
341int __init pinmux_register_mappings(struct pinmux_map const *maps, 341int __init pinctrl_register_mappings(struct pinctrl_map const *maps,
342 unsigned num_maps) 342 unsigned num_maps)
343{ 343{
344 void *tmp_maps; 344 void *tmp_maps;
345 int i; 345 int i;
@@ -380,26 +380,27 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps,
380 * Make a copy of the map array - string pointers will end up in the 380 * Make a copy of the map array - string pointers will end up in the
381 * kernel const section anyway so these do not need to be deep copied. 381 * kernel const section anyway so these do not need to be deep copied.
382 */ 382 */
383 if (!pinmux_maps_num) { 383 if (!pinctrl_maps_num) {
384 /* On first call, just copy them */ 384 /* On first call, just copy them */
385 tmp_maps = kmemdup(maps, 385 tmp_maps = kmemdup(maps,
386 sizeof(struct pinmux_map) * num_maps, 386 sizeof(struct pinctrl_map) * num_maps,
387 GFP_KERNEL); 387 GFP_KERNEL);
388 if (!tmp_maps) 388 if (!tmp_maps)
389 return -ENOMEM; 389 return -ENOMEM;
390 } else { 390 } else {
391 /* Subsequent calls, reallocate array to new size */ 391 /* Subsequent calls, reallocate array to new size */
392 size_t oldsize = sizeof(struct pinmux_map) * pinmux_maps_num; 392 size_t oldsize = sizeof(struct pinctrl_map) * pinctrl_maps_num;
393 size_t newsize = sizeof(struct pinmux_map) * num_maps; 393 size_t newsize = sizeof(struct pinctrl_map) * num_maps;
394 394
395 tmp_maps = krealloc(pinmux_maps, oldsize + newsize, GFP_KERNEL); 395 tmp_maps = krealloc(pinctrl_maps,
396 oldsize + newsize, GFP_KERNEL);
396 if (!tmp_maps) 397 if (!tmp_maps)
397 return -ENOMEM; 398 return -ENOMEM;
398 memcpy((tmp_maps + oldsize), maps, newsize); 399 memcpy((tmp_maps + oldsize), maps, newsize);
399 } 400 }
400 401
401 pinmux_maps = tmp_maps; 402 pinctrl_maps = tmp_maps;
402 pinmux_maps_num += num_maps; 403 pinctrl_maps_num += num_maps;
403 return 0; 404 return 0;
404} 405}
405 406
@@ -560,7 +561,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev,
560 * negative otherwise 561 * negative otherwise
561 */ 562 */
562static int pinmux_search_function(struct pinctrl_dev *pctldev, 563static int pinmux_search_function(struct pinctrl_dev *pctldev,
563 struct pinmux_map const *map, 564 struct pinctrl_map const *map,
564 unsigned *func_selector, 565 unsigned *func_selector,
565 unsigned *group_selector) 566 unsigned *group_selector)
566{ 567{
@@ -598,10 +599,10 @@ static int pinmux_search_function(struct pinctrl_dev *pctldev,
598 * pinmux_enable_muxmap() - enable a map entry for a certain pinmux 599 * pinmux_enable_muxmap() - enable a map entry for a certain pinmux
599 */ 600 */
600static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev, 601static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
601 struct pinmux *pmx, 602 struct pinctrl *p,
602 struct device *dev, 603 struct device *dev,
603 const char *devname, 604 const char *devname,
604 struct pinmux_map const *map) 605 struct pinctrl_map const *map)
605{ 606{
606 unsigned func_selector; 607 unsigned func_selector;
607 unsigned group_selector; 608 unsigned group_selector;
@@ -615,14 +616,14 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
615 * by anyone else. 616 * by anyone else.
616 */ 617 */
617 618
618 if (pmx->pctldev && pmx->pctldev != pctldev) { 619 if (p->pctldev && p->pctldev != pctldev) {
619 dev_err(pctldev->dev, 620 dev_err(pctldev->dev,
620 "different pin control devices given for device %s, function %s\n", 621 "different pin control devices given for device %s, function %s\n",
621 devname, map->function); 622 devname, map->function);
622 return -EINVAL; 623 return -EINVAL;
623 } 624 }
624 pmx->dev = dev; 625 p->dev = dev;
625 pmx->pctldev = pctldev; 626 p->pctldev = pctldev;
626 627
627 /* Now go into the driver and try to match a function and group */ 628 /* Now go into the driver and try to match a function and group */
628 ret = pinmux_search_function(pctldev, map, &func_selector, 629 ret = pinmux_search_function(pctldev, map, &func_selector,
@@ -635,14 +636,14 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
635 * we support several groups with one function but not several 636 * we support several groups with one function but not several
636 * functions with one or several groups in the same pinmux. 637 * functions with one or several groups in the same pinmux.
637 */ 638 */
638 if (pmx->func_selector != UINT_MAX && 639 if (p->func_selector != UINT_MAX &&
639 pmx->func_selector != func_selector) { 640 p->func_selector != func_selector) {
640 dev_err(pctldev->dev, 641 dev_err(pctldev->dev,
641 "dual function defines in the map for device %s\n", 642 "dual function defines in the map for device %s\n",
642 devname); 643 devname);
643 return -EINVAL; 644 return -EINVAL;
644 } 645 }
645 pmx->func_selector = func_selector; 646 p->func_selector = func_selector;
646 647
647 /* Now add this group selector, we may have many of them */ 648 /* Now add this group selector, we may have many of them */
648 grp = kmalloc(sizeof(struct pinmux_group), GFP_KERNEL); 649 grp = kmalloc(sizeof(struct pinmux_group), GFP_KERNEL);
@@ -654,38 +655,38 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
654 kfree(grp); 655 kfree(grp);
655 return ret; 656 return ret;
656 } 657 }
657 list_add(&grp->node, &pmx->groups); 658 list_add(&grp->node, &p->groups);
658 659
659 return 0; 660 return 0;
660} 661}
661 662
662static void pinmux_free_groups(struct pinmux *pmx) 663static void pinmux_free_groups(struct pinctrl *p)
663{ 664{
664 struct list_head *node, *tmp; 665 struct list_head *node, *tmp;
665 666
666 list_for_each_safe(node, tmp, &pmx->groups) { 667 list_for_each_safe(node, tmp, &p->groups) {
667 struct pinmux_group *grp = 668 struct pinmux_group *grp =
668 list_entry(node, struct pinmux_group, node); 669 list_entry(node, struct pinmux_group, node);
669 /* Release all pins taken by this group */ 670 /* Release all pins taken by this group */
670 release_pins(pmx->pctldev, grp->group_selector); 671 release_pins(p->pctldev, grp->group_selector);
671 list_del(node); 672 list_del(node);
672 kfree(grp); 673 kfree(grp);
673 } 674 }
674} 675}
675 676
676/** 677/**
677 * pinmux_get() - retrieves the pinmux for a certain device 678 * pinctrl_get() - retrieves the pin controller handle for a certain device
678 * @dev: the device to get the pinmux for 679 * @dev: the device to get the pin controller handle for
679 * @name: an optional specific mux mapping name or NULL, the name is only 680 * @name: an optional specific control mapping name or NULL, the name is only
680 * needed if you want to have more than one mapping per device, or if you 681 * needed if you want to have more than one mapping per device, or if you
681 * need an anonymous pinmux (not tied to any specific device) 682 * need an anonymous pin control (not tied to any specific device)
682 */ 683 */
683struct pinmux *pinmux_get(struct device *dev, const char *name) 684struct pinctrl *pinctrl_get(struct device *dev, const char *name)
684{ 685{
685 struct pinmux_map const *map = NULL; 686 struct pinctrl_map const *map = NULL;
686 struct pinctrl_dev *pctldev = NULL; 687 struct pinctrl_dev *pctldev = NULL;
687 const char *devname = NULL; 688 const char *devname = NULL;
688 struct pinmux *pmx; 689 struct pinctrl *p;
689 bool found_map; 690 bool found_map;
690 unsigned num_maps = 0; 691 unsigned num_maps = 0;
691 int ret = -ENODEV; 692 int ret = -ENODEV;
@@ -706,16 +707,16 @@ struct pinmux *pinmux_get(struct device *dev, const char *name)
706 * mapping, this is what consumers will get when requesting 707 * mapping, this is what consumers will get when requesting
707 * a pinmux handle with pinmux_get() 708 * a pinmux handle with pinmux_get()
708 */ 709 */
709 pmx = kzalloc(sizeof(struct pinmux), GFP_KERNEL); 710 p = kzalloc(sizeof(struct pinctrl), GFP_KERNEL);
710 if (pmx == NULL) 711 if (p == NULL)
711 return ERR_PTR(-ENOMEM); 712 return ERR_PTR(-ENOMEM);
712 mutex_init(&pmx->mutex); 713 mutex_init(&p->mutex);
713 pmx->func_selector = UINT_MAX; 714 p->func_selector = UINT_MAX;
714 INIT_LIST_HEAD(&pmx->groups); 715 INIT_LIST_HEAD(&p->groups);
715 716
716 /* Iterate over the pinmux maps to locate the right ones */ 717 /* Iterate over the pin control maps to locate the right ones */
717 for (i = 0; i < pinmux_maps_num; i++) { 718 for (i = 0; i < pinctrl_maps_num; i++) {
718 map = &pinmux_maps[i]; 719 map = &pinctrl_maps[i];
719 found_map = false; 720 found_map = false;
720 721
721 /* 722 /*
@@ -763,11 +764,11 @@ struct pinmux *pinmux_get(struct device *dev, const char *name)
763 764
764 /* If this map is applicable, then apply it */ 765 /* If this map is applicable, then apply it */
765 if (found_map) { 766 if (found_map) {
766 ret = pinmux_enable_muxmap(pctldev, pmx, dev, 767 ret = pinmux_enable_muxmap(pctldev, p, dev,
767 devname, map); 768 devname, map);
768 if (ret) { 769 if (ret) {
769 pinmux_free_groups(pmx); 770 pinmux_free_groups(p);
770 kfree(pmx); 771 kfree(p);
771 return ERR_PTR(ret); 772 return ERR_PTR(ret);
772 } 773 }
773 num_maps++; 774 num_maps++;
@@ -780,7 +781,7 @@ struct pinmux *pinmux_get(struct device *dev, const char *name)
780 pr_err("could not find any mux maps for device %s, ID %s\n", 781 pr_err("could not find any mux maps for device %s, ID %s\n",
781 devname ? devname : "(anonymous)", 782 devname ? devname : "(anonymous)",
782 name ? name : "(undefined)"); 783 name ? name : "(undefined)");
783 kfree(pmx); 784 kfree(p);
784 return ERR_PTR(-EINVAL); 785 return ERR_PTR(-EINVAL);
785 } 786 }
786 787
@@ -790,96 +791,96 @@ struct pinmux *pinmux_get(struct device *dev, const char *name)
790 name ? name : "(undefined)"); 791 name ? name : "(undefined)");
791 792
792 /* Add the pinmux to the global list */ 793 /* Add the pinmux to the global list */
793 mutex_lock(&pinmux_list_mutex); 794 mutex_lock(&pinctrl_list_mutex);
794 list_add(&pmx->node, &pinmux_list); 795 list_add(&p->node, &pinctrl_list);
795 mutex_unlock(&pinmux_list_mutex); 796 mutex_unlock(&pinctrl_list_mutex);
796 797
797 return pmx; 798 return p;
798} 799}
799EXPORT_SYMBOL_GPL(pinmux_get); 800EXPORT_SYMBOL_GPL(pinctrl_get);
800 801
801/** 802/**
802 * pinmux_put() - release a previously claimed pinmux 803 * pinctrl_put() - release a previously claimed pin control handle
803 * @pmx: a pinmux previously claimed by pinmux_get() 804 * @p: a pin control handle previously claimed by pinctrl_get()
804 */ 805 */
805void pinmux_put(struct pinmux *pmx) 806void pinctrl_put(struct pinctrl *p)
806{ 807{
807 if (pmx == NULL) 808 if (p == NULL)
808 return; 809 return;
809 810
810 mutex_lock(&pmx->mutex); 811 mutex_lock(&p->mutex);
811 if (pmx->usecount) 812 if (p->usecount)
812 pr_warn("releasing pinmux with active users!\n"); 813 pr_warn("releasing pin control handle with active users!\n");
813 /* Free the groups and all acquired pins */ 814 /* Free the groups and all acquired pins */
814 pinmux_free_groups(pmx); 815 pinmux_free_groups(p);
815 mutex_unlock(&pmx->mutex); 816 mutex_unlock(&p->mutex);
816 817
817 /* Remove from list */ 818 /* Remove from list */
818 mutex_lock(&pinmux_list_mutex); 819 mutex_lock(&pinctrl_list_mutex);
819 list_del(&pmx->node); 820 list_del(&p->node);
820 mutex_unlock(&pinmux_list_mutex); 821 mutex_unlock(&pinctrl_list_mutex);
821 822
822 kfree(pmx); 823 kfree(p);
823} 824}
824EXPORT_SYMBOL_GPL(pinmux_put); 825EXPORT_SYMBOL_GPL(pinctrl_put);
825 826
826/** 827/**
827 * pinmux_enable() - enable a certain pinmux setting 828 * pinctrl_enable() - enable a certain pin controller setting
828 * @pmx: the pinmux to enable, previously claimed by pinmux_get() 829 * @p: the pin control handle to enable, previously claimed by pinctrl_get()
829 */ 830 */
830int pinmux_enable(struct pinmux *pmx) 831int pinctrl_enable(struct pinctrl *p)
831{ 832{
832 int ret = 0; 833 int ret = 0;
833 834
834 if (pmx == NULL) 835 if (p == NULL)
835 return -EINVAL; 836 return -EINVAL;
836 mutex_lock(&pmx->mutex); 837 mutex_lock(&p->mutex);
837 if (pmx->usecount++ == 0) { 838 if (p->usecount++ == 0) {
838 struct pinctrl_dev *pctldev = pmx->pctldev; 839 struct pinctrl_dev *pctldev = p->pctldev;
839 const struct pinmux_ops *ops = pctldev->desc->pmxops; 840 const struct pinmux_ops *ops = pctldev->desc->pmxops;
840 struct pinmux_group *grp; 841 struct pinmux_group *grp;
841 842
842 list_for_each_entry(grp, &pmx->groups, node) { 843 list_for_each_entry(grp, &p->groups, node) {
843 ret = ops->enable(pctldev, pmx->func_selector, 844 ret = ops->enable(pctldev, p->func_selector,
844 grp->group_selector); 845 grp->group_selector);
845 if (ret) { 846 if (ret) {
846 /* 847 /*
847 * TODO: call disable() on all groups we called 848 * TODO: call disable() on all groups we called
848 * enable() on to this point? 849 * enable() on to this point?
849 */ 850 */
850 pmx->usecount--; 851 p->usecount--;
851 break; 852 break;
852 } 853 }
853 } 854 }
854 } 855 }
855 mutex_unlock(&pmx->mutex); 856 mutex_unlock(&p->mutex);
856 return ret; 857 return ret;
857} 858}
858EXPORT_SYMBOL_GPL(pinmux_enable); 859EXPORT_SYMBOL_GPL(pinctrl_enable);
859 860
860/** 861/**
861 * pinmux_disable() - disable a certain pinmux setting 862 * pinctrl_disable() - disable a certain pin control setting
862 * @pmx: the pinmux to disable, previously claimed by pinmux_get() 863 * @p: the pin control handle to disable, previously claimed by pinctrl_get()
863 */ 864 */
864void pinmux_disable(struct pinmux *pmx) 865void pinctrl_disable(struct pinctrl *p)
865{ 866{
866 if (pmx == NULL) 867 if (p == NULL)
867 return; 868 return;
868 869
869 mutex_lock(&pmx->mutex); 870 mutex_lock(&p->mutex);
870 if (--pmx->usecount == 0) { 871 if (--p->usecount == 0) {
871 struct pinctrl_dev *pctldev = pmx->pctldev; 872 struct pinctrl_dev *pctldev = p->pctldev;
872 const struct pinmux_ops *ops = pctldev->desc->pmxops; 873 const struct pinmux_ops *ops = pctldev->desc->pmxops;
873 struct pinmux_group *grp; 874 struct pinmux_group *grp;
874 875
875 list_for_each_entry(grp, &pmx->groups, node) { 876 list_for_each_entry(grp, &p->groups, node) {
876 ops->disable(pctldev, pmx->func_selector, 877 ops->disable(pctldev, p->func_selector,
877 grp->group_selector); 878 grp->group_selector);
878 } 879 }
879 } 880 }
880 mutex_unlock(&pmx->mutex); 881 mutex_unlock(&p->mutex);
881} 882}
882EXPORT_SYMBOL_GPL(pinmux_disable); 883EXPORT_SYMBOL_GPL(pinctrl_disable);
883 884
884int pinmux_check_ops(struct pinctrl_dev *pctldev) 885int pinmux_check_ops(struct pinctrl_dev *pctldev)
885{ 886{
@@ -910,11 +911,11 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev)
910} 911}
911 912
912/* Hog a single map entry and add to the hoglist */ 913/* Hog a single map entry and add to the hoglist */
913static int pinmux_hog_map(struct pinctrl_dev *pctldev, 914static int pinctrl_hog_map(struct pinctrl_dev *pctldev,
914 struct pinmux_map const *map) 915 struct pinctrl_map const *map)
915{ 916{
916 struct pinmux_hog *hog; 917 struct pinctrl_hog *hog;
917 struct pinmux *pmx; 918 struct pinctrl *p;
918 int ret; 919 int ret;
919 920
920 if (map->dev_name) { 921 if (map->dev_name) {
@@ -929,61 +930,61 @@ static int pinmux_hog_map(struct pinctrl_dev *pctldev,
929 return -EINVAL; 930 return -EINVAL;
930 } 931 }
931 932
932 hog = kzalloc(sizeof(struct pinmux_hog), GFP_KERNEL); 933 hog = kzalloc(sizeof(struct pinctrl_hog), GFP_KERNEL);
933 if (!hog) 934 if (!hog)
934 return -ENOMEM; 935 return -ENOMEM;
935 936
936 pmx = pinmux_get(NULL, map->name); 937 p = pinctrl_get(NULL, map->name);
937 if (IS_ERR(pmx)) { 938 if (IS_ERR(p)) {
938 kfree(hog); 939 kfree(hog);
939 dev_err(pctldev->dev, 940 dev_err(pctldev->dev,
940 "could not get the %s pinmux mapping for hogging\n", 941 "could not get the %s pin control mapping for hogging\n",
941 map->name); 942 map->name);
942 return PTR_ERR(pmx); 943 return PTR_ERR(p);
943 } 944 }
944 945
945 ret = pinmux_enable(pmx); 946 ret = pinctrl_enable(p);
946 if (ret) { 947 if (ret) {
947 pinmux_put(pmx); 948 pinctrl_put(p);
948 kfree(hog); 949 kfree(hog);
949 dev_err(pctldev->dev, 950 dev_err(pctldev->dev,
950 "could not enable the %s pinmux mapping for hogging\n", 951 "could not enable the %s pin control mapping for hogging\n",
951 map->name); 952 map->name);
952 return ret; 953 return ret;
953 } 954 }
954 955
955 hog->map = map; 956 hog->map = map;
956 hog->pmx = pmx; 957 hog->p = p;
957 958
958 dev_info(pctldev->dev, "hogged map %s, function %s\n", map->name, 959 dev_info(pctldev->dev, "hogged map %s, function %s\n", map->name,
959 map->function); 960 map->function);
960 mutex_lock(&pctldev->pinmux_hogs_lock); 961 mutex_lock(&pctldev->pinctrl_hogs_lock);
961 list_add(&hog->node, &pctldev->pinmux_hogs); 962 list_add(&hog->node, &pctldev->pinctrl_hogs);
962 mutex_unlock(&pctldev->pinmux_hogs_lock); 963 mutex_unlock(&pctldev->pinctrl_hogs_lock);
963 964
964 return 0; 965 return 0;
965} 966}
966 967
967/** 968/**
968 * pinmux_hog_maps() - hog specific map entries on controller device 969 * pinctrl_hog_maps() - hog specific map entries on controller device
969 * @pctldev: the pin control device to hog entries on 970 * @pctldev: the pin control device to hog entries on
970 * 971 *
971 * When the pin controllers are registered, there may be some specific pinmux 972 * When the pin controllers are registered, there may be some specific pinmux
972 * map entries that need to be hogged, i.e. get+enabled until the system shuts 973 * map entries that need to be hogged, i.e. get+enabled until the system shuts
973 * down. 974 * down.
974 */ 975 */
975int pinmux_hog_maps(struct pinctrl_dev *pctldev) 976int pinctrl_hog_maps(struct pinctrl_dev *pctldev)
976{ 977{
977 struct device *dev = pctldev->dev; 978 struct device *dev = pctldev->dev;
978 const char *devname = dev_name(dev); 979 const char *devname = dev_name(dev);
979 int ret; 980 int ret;
980 int i; 981 int i;
981 982
982 INIT_LIST_HEAD(&pctldev->pinmux_hogs); 983 INIT_LIST_HEAD(&pctldev->pinctrl_hogs);
983 mutex_init(&pctldev->pinmux_hogs_lock); 984 mutex_init(&pctldev->pinctrl_hogs_lock);
984 985
985 for (i = 0; i < pinmux_maps_num; i++) { 986 for (i = 0; i < pinctrl_maps_num; i++) {
986 struct pinmux_map const *map = &pinmux_maps[i]; 987 struct pinctrl_map const *map = &pinctrl_maps[i];
987 988
988 if (!map->hog_on_boot) 989 if (!map->hog_on_boot)
989 continue; 990 continue;
@@ -991,7 +992,7 @@ int pinmux_hog_maps(struct pinctrl_dev *pctldev)
991 if (map->ctrl_dev_name && 992 if (map->ctrl_dev_name &&
992 !strcmp(map->ctrl_dev_name, devname)) { 993 !strcmp(map->ctrl_dev_name, devname)) {
993 /* OK time to hog! */ 994 /* OK time to hog! */
994 ret = pinmux_hog_map(pctldev, map); 995 ret = pinctrl_hog_map(pctldev, map);
995 if (ret) 996 if (ret)
996 return ret; 997 return ret;
997 } 998 }
@@ -1000,23 +1001,23 @@ int pinmux_hog_maps(struct pinctrl_dev *pctldev)
1000} 1001}
1001 1002
1002/** 1003/**
1003 * pinmux_unhog_maps() - unhog specific map entries on controller device 1004 * pinctrl_unhog_maps() - unhog specific map entries on controller device
1004 * @pctldev: the pin control device to unhog entries on 1005 * @pctldev: the pin control device to unhog entries on
1005 */ 1006 */
1006void pinmux_unhog_maps(struct pinctrl_dev *pctldev) 1007void pinctrl_unhog_maps(struct pinctrl_dev *pctldev)
1007{ 1008{
1008 struct list_head *node, *tmp; 1009 struct list_head *node, *tmp;
1009 1010
1010 mutex_lock(&pctldev->pinmux_hogs_lock); 1011 mutex_lock(&pctldev->pinctrl_hogs_lock);
1011 list_for_each_safe(node, tmp, &pctldev->pinmux_hogs) { 1012 list_for_each_safe(node, tmp, &pctldev->pinctrl_hogs) {
1012 struct pinmux_hog *hog = 1013 struct pinctrl_hog *hog =
1013 list_entry(node, struct pinmux_hog, node); 1014 list_entry(node, struct pinctrl_hog, node);
1014 pinmux_disable(hog->pmx); 1015 pinctrl_disable(hog->p);
1015 pinmux_put(hog->pmx); 1016 pinctrl_put(hog->p);
1016 list_del(node); 1017 list_del(node);
1017 kfree(hog); 1018 kfree(hog);
1018 } 1019 }
1019 mutex_unlock(&pctldev->pinmux_hogs_lock); 1020 mutex_unlock(&pctldev->pinctrl_hogs_lock);
1020} 1021}
1021 1022
1022#ifdef CONFIG_DEBUG_FS 1023#ifdef CONFIG_DEBUG_FS
@@ -1085,11 +1086,11 @@ static int pinmux_pins_show(struct seq_file *s, void *what)
1085static int pinmux_hogs_show(struct seq_file *s, void *what) 1086static int pinmux_hogs_show(struct seq_file *s, void *what)
1086{ 1087{
1087 struct pinctrl_dev *pctldev = s->private; 1088 struct pinctrl_dev *pctldev = s->private;
1088 struct pinmux_hog *hog; 1089 struct pinctrl_hog *hog;
1089 1090
1090 seq_puts(s, "Pinmux map hogs held by device\n"); 1091 seq_puts(s, "Pin control map hogs held by device\n");
1091 1092
1092 list_for_each_entry(hog, &pctldev->pinmux_hogs, node) 1093 list_for_each_entry(hog, &pctldev->pinctrl_hogs, node)
1093 seq_printf(s, "%s\n", hog->map->name); 1094 seq_printf(s, "%s\n", hog->map->name);
1094 1095
1095 return 0; 1096 return 0;
@@ -1097,11 +1098,11 @@ static int pinmux_hogs_show(struct seq_file *s, void *what)
1097 1098
1098static int pinmux_show(struct seq_file *s, void *what) 1099static int pinmux_show(struct seq_file *s, void *what)
1099{ 1100{
1100 struct pinmux *pmx; 1101 struct pinctrl *p;
1101 1102
1102 seq_puts(s, "Requested pinmuxes and their maps:\n"); 1103 seq_puts(s, "Requested pinmuxes and their maps:\n");
1103 list_for_each_entry(pmx, &pinmux_list, node) { 1104 list_for_each_entry(p, &pinctrl_list, node) {
1104 struct pinctrl_dev *pctldev = pmx->pctldev; 1105 struct pinctrl_dev *pctldev = p->pctldev;
1105 const struct pinmux_ops *pmxops; 1106 const struct pinmux_ops *pmxops;
1106 const struct pinctrl_ops *pctlops; 1107 const struct pinctrl_ops *pctlops;
1107 struct pinmux_group *grp; 1108 struct pinmux_group *grp;
@@ -1115,13 +1116,13 @@ static int pinmux_show(struct seq_file *s, void *what)
1115 pctlops = pctldev->desc->pctlops; 1116 pctlops = pctldev->desc->pctlops;
1116 1117
1117 seq_printf(s, "device: %s function: %s (%u),", 1118 seq_printf(s, "device: %s function: %s (%u),",
1118 pinctrl_dev_get_name(pmx->pctldev), 1119 pinctrl_dev_get_name(p->pctldev),
1119 pmxops->get_function_name(pctldev, 1120 pmxops->get_function_name(pctldev,
1120 pmx->func_selector), 1121 p->func_selector),
1121 pmx->func_selector); 1122 p->func_selector);
1122 1123
1123 seq_printf(s, " groups: ["); 1124 seq_printf(s, " groups: [");
1124 list_for_each_entry(grp, &pmx->groups, node) { 1125 list_for_each_entry(grp, &p->groups, node) {
1125 seq_printf(s, " %s (%u)", 1126 seq_printf(s, " %s (%u)",
1126 pctlops->get_group_name(pctldev, 1127 pctlops->get_group_name(pctldev,
1127 grp->group_selector), 1128 grp->group_selector),
@@ -1130,21 +1131,21 @@ static int pinmux_show(struct seq_file *s, void *what)
1130 seq_printf(s, " ]"); 1131 seq_printf(s, " ]");
1131 1132
1132 seq_printf(s, " users: %u map-> %s\n", 1133 seq_printf(s, " users: %u map-> %s\n",
1133 pmx->usecount, 1134 p->usecount,
1134 pmx->dev ? dev_name(pmx->dev) : "(system)"); 1135 p->dev ? dev_name(p->dev) : "(system)");
1135 } 1136 }
1136 1137
1137 return 0; 1138 return 0;
1138} 1139}
1139 1140
1140static int pinmux_maps_show(struct seq_file *s, void *what) 1141static int pinctrl_maps_show(struct seq_file *s, void *what)
1141{ 1142{
1142 int i; 1143 int i;
1143 1144
1144 seq_puts(s, "Pinmux maps:\n"); 1145 seq_puts(s, "Pinctrl maps:\n");
1145 1146
1146 for (i = 0; i < pinmux_maps_num; i++) { 1147 for (i = 0; i < pinctrl_maps_num; i++) {
1147 struct pinmux_map const *map = &pinmux_maps[i]; 1148 struct pinctrl_map const *map = &pinctrl_maps[i];
1148 1149
1149 seq_printf(s, "%s:\n", map->name); 1150 seq_printf(s, "%s:\n", map->name);
1150 if (map->dev_name) 1151 if (map->dev_name)
@@ -1181,9 +1182,9 @@ static int pinmux_open(struct inode *inode, struct file *file)
1181 return single_open(file, pinmux_show, NULL); 1182 return single_open(file, pinmux_show, NULL);
1182} 1183}
1183 1184
1184static int pinmux_maps_open(struct inode *inode, struct file *file) 1185static int pinctrl_maps_open(struct inode *inode, struct file *file)
1185{ 1186{
1186 return single_open(file, pinmux_maps_show, NULL); 1187 return single_open(file, pinctrl_maps_show, NULL);
1187} 1188}
1188 1189
1189static const struct file_operations pinmux_functions_ops = { 1190static const struct file_operations pinmux_functions_ops = {
@@ -1214,8 +1215,8 @@ static const struct file_operations pinmux_ops = {
1214 .release = single_release, 1215 .release = single_release,
1215}; 1216};
1216 1217
1217static const struct file_operations pinmux_maps_ops = { 1218static const struct file_operations pinctrl_maps_ops = {
1218 .open = pinmux_maps_open, 1219 .open = pinctrl_maps_open,
1219 .read = seq_read, 1220 .read = seq_read,
1220 .llseek = seq_lseek, 1221 .llseek = seq_lseek,
1221 .release = single_release, 1222 .release = single_release,
@@ -1236,8 +1237,8 @@ void pinmux_init_debugfs(struct dentry *subsys_root)
1236{ 1237{
1237 debugfs_create_file("pinmuxes", S_IFREG | S_IRUGO, 1238 debugfs_create_file("pinmuxes", S_IFREG | S_IRUGO,
1238 subsys_root, NULL, &pinmux_ops); 1239 subsys_root, NULL, &pinmux_ops);
1239 debugfs_create_file("pinmux-maps", S_IFREG | S_IRUGO, 1240 debugfs_create_file("pinctrl-maps", S_IFREG | S_IRUGO,
1240 subsys_root, NULL, &pinmux_maps_ops); 1241 subsys_root, NULL, &pinctrl_maps_ops);
1241} 1242}
1242 1243
1243#endif /* CONFIG_DEBUG_FS */ 1244#endif /* CONFIG_DEBUG_FS */
diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h
index 97f52223fbc2..dfe81726965c 100644
--- a/drivers/pinctrl/pinmux.h
+++ b/drivers/pinctrl/pinmux.h
@@ -16,8 +16,8 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev);
16void pinmux_init_device_debugfs(struct dentry *devroot, 16void pinmux_init_device_debugfs(struct dentry *devroot,
17 struct pinctrl_dev *pctldev); 17 struct pinctrl_dev *pctldev);
18void pinmux_init_debugfs(struct dentry *subsys_root); 18void pinmux_init_debugfs(struct dentry *subsys_root);
19int pinmux_hog_maps(struct pinctrl_dev *pctldev); 19int pinctrl_hog_maps(struct pinctrl_dev *pctldev);
20void pinmux_unhog_maps(struct pinctrl_dev *pctldev); 20void pinctrl_unhog_maps(struct pinctrl_dev *pctldev);
21 21
22#else 22#else
23 23
@@ -35,12 +35,12 @@ static inline void pinmux_init_debugfs(struct dentry *subsys_root)
35{ 35{
36} 36}
37 37
38static inline int pinmux_hog_maps(struct pinctrl_dev *pctldev) 38static inline int pinctrl_hog_maps(struct pinctrl_dev *pctldev)
39{ 39{
40 return 0; 40 return 0;
41} 41}
42 42
43static inline void pinmux_unhog_maps(struct pinctrl_dev *pctldev) 43static inline void pinctrl_unhog_maps(struct pinctrl_dev *pctldev)
44{ 44{
45} 45}
46 46
diff --git a/include/linux/pinctrl/consumer.h b/include/linux/pinctrl/consumer.h
index 9c8513d5d0fb..c7d061776293 100644
--- a/include/linux/pinctrl/consumer.h
+++ b/include/linux/pinctrl/consumer.h
@@ -17,56 +17,56 @@
17#include "pinctrl.h" 17#include "pinctrl.h"
18 18
19/* This struct is private to the core and should be regarded as a cookie */ 19/* This struct is private to the core and should be regarded as a cookie */
20struct pinmux; 20struct pinctrl;
21 21
22#ifdef CONFIG_PINMUX 22#ifdef CONFIG_PINMUX
23 23
24/* External interface to pinmux */ 24/* External interface to pinmux */
25extern int pinmux_request_gpio(unsigned gpio); 25extern int pinctrl_request_gpio(unsigned gpio);
26extern void pinmux_free_gpio(unsigned gpio); 26extern void pinctrl_free_gpio(unsigned gpio);
27extern int pinmux_gpio_direction_input(unsigned gpio); 27extern int pinctrl_gpio_direction_input(unsigned gpio);
28extern int pinmux_gpio_direction_output(unsigned gpio); 28extern int pinctrl_gpio_direction_output(unsigned gpio);
29extern struct pinmux * __must_check pinmux_get(struct device *dev, const char *name); 29extern struct pinctrl * __must_check pinctrl_get(struct device *dev, const char *name);
30extern void pinmux_put(struct pinmux *pmx); 30extern void pinctrl_put(struct pinctrl *p);
31extern int pinmux_enable(struct pinmux *pmx); 31extern int pinctrl_enable(struct pinctrl *p);
32extern void pinmux_disable(struct pinmux *pmx); 32extern void pinctrl_disable(struct pinctrl *p);
33 33
34#else /* !CONFIG_PINMUX */ 34#else /* !CONFIG_PINMUX */
35 35
36static inline int pinmux_request_gpio(unsigned gpio) 36static inline int pinctrl_request_gpio(unsigned gpio)
37{ 37{
38 return 0; 38 return 0;
39} 39}
40 40
41static inline void pinmux_free_gpio(unsigned gpio) 41static inline void pinctrl_free_gpio(unsigned gpio)
42{ 42{
43} 43}
44 44
45static inline int pinmux_gpio_direction_input(unsigned gpio) 45static inline int pinctrl_gpio_direction_input(unsigned gpio)
46{ 46{
47 return 0; 47 return 0;
48} 48}
49 49
50static inline int pinmux_gpio_direction_output(unsigned gpio) 50static inline int pinctrl_gpio_direction_output(unsigned gpio)
51{ 51{
52 return 0; 52 return 0;
53} 53}
54 54
55static inline struct pinmux * __must_check pinmux_get(struct device *dev, const char *name) 55static inline struct pinctrl * __must_check pinctrl_get(struct device *dev, const char *name)
56{ 56{
57 return NULL; 57 return NULL;
58} 58}
59 59
60static inline void pinmux_put(struct pinmux *pmx) 60static inline void pinctrl_put(struct pinctrl *p)
61{ 61{
62} 62}
63 63
64static inline int pinmux_enable(struct pinmux *pmx) 64static inline int pinctrl_enable(struct pinctrl *p)
65{ 65{
66 return 0; 66 return 0;
67} 67}
68 68
69static inline void pinmux_disable(struct pinmux *pmx) 69static inline void pinctrl_disable(struct pinctrl *p)
70{ 70{
71} 71}
72 72
diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h
index f8593fdc6466..a2ab524a0106 100644
--- a/include/linux/pinctrl/machine.h
+++ b/include/linux/pinctrl/machine.h
@@ -9,11 +9,11 @@
9 * 9 *
10 * License terms: GNU General Public License (GPL) version 2 10 * License terms: GNU General Public License (GPL) version 2
11 */ 11 */
12#ifndef __LINUX_PINMUX_MACHINE_H 12#ifndef __LINUX_PINCTRL_MACHINE_H
13#define __LINUX_PINMUX_MACHINE_H 13#define __LINUX_PINCTRL_MACHINE_H
14 14
15/** 15/**
16 * struct pinmux_map - boards/machines shall provide this map for devices 16 * struct pinctrl_map - boards/machines shall provide this map for devices
17 * @name: the name of this specific map entry for the particular machine. 17 * @name: the name of this specific map entry for the particular machine.
18 * This is the second parameter passed to pinmux_get() when you want 18 * This is the second parameter passed to pinmux_get() when you want
19 * to have several mappings to the same device 19 * to have several mappings to the same device
@@ -34,7 +34,7 @@
34 * a pinmux device supporting it is registered. These maps will not be 34 * a pinmux device supporting it is registered. These maps will not be
35 * disabled and put until the system shuts down. 35 * disabled and put until the system shuts down.
36 */ 36 */
37struct pinmux_map { 37struct pinctrl_map {
38 const char *name; 38 const char *name;
39 const char *ctrl_dev_name; 39 const char *ctrl_dev_name;
40 const char *function; 40 const char *function;
@@ -47,41 +47,41 @@ struct pinmux_map {
47 * Convenience macro to set a simple map from a certain pin controller and a 47 * Convenience macro to set a simple map from a certain pin controller and a
48 * certain function to a named device 48 * certain function to a named device
49 */ 49 */
50#define PINMUX_MAP(a, b, c, d) \ 50#define PIN_MAP(a, b, c, d) \
51 { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d } 51 { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }
52 52
53/* 53/*
54 * Convenience macro to map a system function onto a certain pinctrl device. 54 * Convenience macro to map a system function onto a certain pinctrl device.
55 * System functions are not assigned to a particular device. 55 * System functions are not assigned to a particular device.
56 */ 56 */
57#define PINMUX_MAP_SYS(a, b, c) \ 57#define PIN_MAP_SYS(a, b, c) \
58 { .name = a, .ctrl_dev_name = b, .function = c } 58 { .name = a, .ctrl_dev_name = b, .function = c }
59 59
60/* 60/*
61 * Convenience macro to map a system function onto a certain pinctrl device, 61 * Convenience macro to map a system function onto a certain pinctrl device,
62 * to be hogged by the pinmux core until the system shuts down. 62 * to be hogged by the pin control core until the system shuts down.
63 */ 63 */
64#define PINMUX_MAP_SYS_HOG(a, b, c) \ 64#define PIN_MAP_SYS_HOG(a, b, c) \
65 { .name = a, .ctrl_dev_name = b, .function = c, \ 65 { .name = a, .ctrl_dev_name = b, .function = c, \
66 .hog_on_boot = true } 66 .hog_on_boot = true }
67 67
68/* 68/*
69 * Convenience macro to map a system function onto a certain pinctrl device 69 * Convenience macro to map a system function onto a certain pinctrl device
70 * using a specified group, to be hogged by the pinmux core until the system 70 * using a specified group, to be hogged by the pin control core until the
71 * shuts down. 71 * system shuts down.
72 */ 72 */
73#define PINMUX_MAP_SYS_HOG_GROUP(a, b, c, d) \ 73#define PIN_MAP_SYS_HOG_GROUP(a, b, c, d) \
74 { .name = a, .ctrl_dev_name = b, .function = c, .group = d, \ 74 { .name = a, .ctrl_dev_name = b, .function = c, .group = d, \
75 .hog_on_boot = true } 75 .hog_on_boot = true }
76 76
77#ifdef CONFIG_PINMUX 77#ifdef CONFIG_PINMUX
78 78
79extern int pinmux_register_mappings(struct pinmux_map const *map, 79extern int pinctrl_register_mappings(struct pinctrl_map const *map,
80 unsigned num_maps); 80 unsigned num_maps);
81 81
82#else 82#else
83 83
84static inline int pinmux_register_mappings(struct pinmux_map const *map, 84static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
85 unsigned num_maps) 85 unsigned num_maps)
86{ 86{
87 return 0; 87 return 0;