aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2013-12-31pinctrl: add function to parse generic pinconfig properties from a dt nodeHeiko Stübner
pinconf_generic_parse_dt_config() takes a node as input and generates an array of generic pinconfig values from the properties of this node. As I couldn't find a mechanism to count the number of properties of a node the function uses internally an array to accept one of parameter and copies the real present options to a smaller variable at its end. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 7db9af4b6e41be599e0fcd50d687138a5add428c) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: generic: Fix compilation errorSachin Kamat
The function definition of pinconf_generic_dump_config is defined under CONFIG_DEBUG_FS macro. Define the declaration too under this macro. Without this patch we get the following build error: drivers/built-in.o: In function `pcs_pinconf_config_dbg_show': drivers/pinctrl/pinctrl-single.c:726: undefined reference to `pinconf_generic_dump_config' Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit bf4d7be57ba9040347065f48a60f895a254f6e28) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: generic: dump pin configurationHaojian Zhuang
Add the support of dumping pin configuration. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 9cfd1724f070ffce27861cb7dcfca6808fd722b8) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl/gpio: non-linear GPIO ranges accesible from gpiolibOng, Boon Leong
This patch adds the infrastructure required to register non-linear gpio ranges through gpiolib and the standard GPIO device tree bindings. Signed-off-by: Christian Ruppert <christian.ruppert@abilis.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 586a87e6edc936d6d3c3585af504b33b9c3f0a06) Conflicts: include/asm-generic/gpio.h - fix patch offset issue. Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31gpio: implement gpio-ranges binding document fixStephen Warren
Use the new of_parse_phandle_with_fixed_args() to implement the corrected gpio-ranges DT property definition. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Grant Likely <grant.likely@linaro.org> (cherry picked from commit d9fe0039c4247383c2783923a3860227813b4d82) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31gpio: gpiolib-of.c: make error message more meaningful by adding the node ↵Lothar Waßmann
name and index Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit eddf8176b57ddb8f960b188eb8796b9d13e4efc0) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31gpio: gpiolib-of.c: fix checkpatch errorLaurent Navet
Fix : gpio/gpiolib-of.c:64: ERROR: code indent should use tabs where possible Signed-off-by: Laurent Navet <laurent.navet@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 9ccb1a26cedf0a03a59f70f270565f3884ec08f6) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31gpio: add gpio offset in gpio range cells propertyOng, Boon Leong
Add gpio offset into "gpio-range-cells" property. It's used to support sparse pinctrl range in gpio chip. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 86853c83e33738397564e9377ceeff94d4bc041c) Conflicts: Documentation/devicetree/bindings/gpio/gpio.txt Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31gpio: use pinctrl device name for add rangeHaojian Zhuang
gpiochip_add_pin_range() needs pinctrl device name as parameter. Currently the parameter is pinctrl description name. So fix it. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit ef5e3eef6b6b22eb4ad7a893d2299418808667ba) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31gpio: clean up gpio-ranges documentationOng, Boon Leong
This change makes documentation of the the gpio-ranges property shorter and more succinct, more consistent with the style of the rest of the document, and not mention Linux-specifics such as the API pinctrl_request_gpio(); DT binding documents should be OS independant where at all possible. As part of this, the gpio-ranges property's format is described in BNF form, in order to match the rest of the document. This change also deprecates the #gpio-range-cells property. Such properties are useful when one node references a second node, and that second node dictates the format of the reference. However, that is not the case here; the definition of gpio-ranges itself always dictates its format entirely, and hence the value #gpio-range-cells must always be 3, and hence there is no point requiring any referenced node to include this property. The only remaining need for this property is to ensure compatibility of DTs with older SW that was written to support the previous version of the binding. v4: * Mention #gpio-range-cells as being deprecated, rather than removing all documentation of that property. This allows DTs to be written in a backwards-compatible way if desired, and also allows older DTs to be interpreted fully using the latest documentation. v3: * Mention BNF in commit description. * Fixed typo. * Dropped patch that removed the deprecated property from *.dts, since it's required to boot older kernels. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit a1bc260bb5f5d95da854be7898202d788e94448d) Conflicts: Documentation/devicetree/bindings/gpio/gpio.txt Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: core: Add proper mutex lock in pinctrl_request_gpioAxel Lin
This one is missed in commit 42fed7ba "pinctrl: move subsystem mutex to pinctrl_dev struct". I think this fixes the race between pin_free() and pin_request() calls. It protects accessing the members of pctldev->desc. (e.g. update desc->mux_usecount, desc->gpio_owner, desc->mux_owner, etc) Current code grabs pctldev->mutex before calling pinmux_free_gpio(), but did not grab the mutex while calling pinmux_request_gpio(). Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 9b77ace409e1419c331209c4c8eb2c8bc990e9fd) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: core: Remove unnecessary test for desc->nameAxel Lin
The implementation in pinctrl_register_one_pin() ensures pindesc->name is always not NULL before insert the pindesc to radix tree. If the desc return from pin_desc_get is not NULL, desc->name is always not NULL. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 6c325f874c9a4b5a783ed6c4a88fdddfc380acb1) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: core: Hold pctldev->mutex mutex lock while traversing gpio_ranges listAxel Lin
Hold pctldev->mutex mutex_lock when traverse the list. Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 5ffbe2e613873222474a0f575296187002a8995d) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: core: Hold pinctrldev_list_mutex mutex while traversing pinctrldev_listAxel Lin
This one is missed in commit 44d5f7bb "pinctrl: sink pinctrldev_list_mutex". Signed-off-by: Axel Lin <axel.lin@ingics.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit f0059021084137b4ffd2ffc7ee4b62a895c4c84a) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: fix a memleak when freeing mapsLinus Walleij
We forgot to free the node itself when free:ing a map. Reported-by: xulinuxkernel <xulinuxkernel@gmail.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit db6c2c69c27f2c4fd1e2a1c6b0b1119b1e885f8a) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: Remove duplicate code in pinctrl_pm_select_state functionsTony Lindgren
There's no need to duplicate essentially the same functions. Let's introduce static int pinctrl_pm_select_state() and make the other related functions call that. This allows us to add support later on for multiple active states, and more optimized dynamic remuxing. Note that we still need to export the various pinctrl_pm_select functions as we want to keep struct pinctrl_state private to the pinctrl code, and cannot replace those with inline functions. Cc: Felipe Balbi <balbi@ti.com> Cc: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit f33334978abd01cbf24d067977a25ad0abd047c8) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: Staticize local symbolsSachin Kamat
Symbols referenced only in this file are made static. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Cc: Patrice Chotard <patrice.chotard@st.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 843aec9653acbc636207467d2c17f3d5902172d3) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: core: fix missing unlock on error in pinctrl_find_gpio_range_from_pin()Wei Yongjun
Add the missing unlock before return from function pinctrl_find_gpio_range_from_pin() in the error handling case. Introduced by commit 2ff3477efd7086544b9e298fc63afab0645921b4. (pinctrl: add pin list based GPIO ranges) Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit c8f50e8657a6dd8d6b2a596e4b4659fd77dc1718) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: export pinctrl_pm_select_*_stateArnd Bergmann
The three functions pinctrl_pm_select_default_state, pinctrl_pm_select_sleep_state, and pinctrl_pm_select_idle_state are used in drivers that can be loadable modules, and should be exported. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit f472deadd541f35fb002c033b76b645130705e7d) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: add pin list based GPIO rangesChristian Ruppert
Traditionally, GPIO ranges are based on consecutive ranges of both GPIO and pin numbers. This patch allows for GPIO ranges with arbitrary lists of pin numbers. Signed-off-by: Christian Ruppert <christian.ruppert@abilis.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit c8587eeef8fc219e806e868c6f0c7170c769efab) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: sink pinctrldev_list_mutexLinus Walleij
The pinctrldev_list_mutex is sinked into the functions that actually traverse the list and lock it there. The code makes much more sense in this way. All the callers are in non-performance critical paths and the code is way more readable this way. Also refactor the function get_pinctrl_dev_from_devname() to follow the design pattern of get_pinctrl_dev_from_of_node() which is slightly simpler. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 44d5f7bbead9e7fbc8731322d5f595d28ad219e9) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: fix mutex deadlock in get_pinctrl_dev_from_of_node()Daniel Mack
This obvious bug was introduced by d755910b7 ("pinctrl: move subsystem mutex to pinctrl_dev struct"). Signed-off-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit d463f82d22f90096d1352de3837b1602a3410b5d) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: remove an unnecessary castDan Carpenter
sizeof() is already size_t so there is no need to cast here. Generally, casting inside the min() macro instead of using min_t() is considered bad style. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 81d36c4fff7401b099d98818a517ee6bc02e93f2) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: fix pinconf_dbg_config_write return typeVincent Stehlé
Have pinconf_dbg_config_write() return a ssize_t. This fixes the following compilation warning: drivers/pinctrl/pinconf.c:617:2: warning: initialization from incompatible pointer type [enabled by default] drivers/pinctrl/pinconf.c:617:2: warning: (near initialization for ‘pinconf_dbg_pinconfig_fops.write’) [enabled by default] Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net> Cc: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 3b59e432ec9c093311e0ad057e330e04feb79007) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: Pass all configs to driver on pin_config_set()Ong, Boon Leong
When setting pin configuration in the pinctrl framework, pin_config_set() or pin_config_group_set() is called in a loop to set one configuration at a time for the specified pin or group. This patch 1) removes the loop and 2) changes the API to pass the whole pin config array to the driver. It is now up to the driver to loop through the configs. This allows the driver to potentially combine configs and reduce the number of writes to pin config registers. All c files changed have been build-tested to verify the change compiles and that the corresponding .o is successfully generated. Signed-off-by: Sherman Yin <syin@broadcom.com> Reviewed-by: Christian Daudt <csd@broadcom.com> Reviewed-by: Matt Porter <matt.porter@linaro.org> Tested-by: Stephen Warren <swarren@nvidia.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 03b054e9696c3cbd3d5905ec96da15acd0a2fe8d) Conflicts: drivers/pinctrl/pinctrl-abx500.c drivers/pinctrl/pinctrl-imx.c drivers/pinctrl/pinctrl-nomadik.c drivers/pinctrl/pinctrl-palmas.c drivers/pinctrl/pinctrl-rockchip.c drivers/pinctrl/pinctrl-single.c drivers/pinctrl/pinctrl-st.c drivers/pinctrl/pinctrl-sunxi.c drivers/pinctrl/pinctrl-tz1090-pdc.c drivers/pinctrl/pinctrl-tz1090.c drivers/pinctrl/pinctrl-xway.c drivers/pinctrl/sh-pfc/pinctrl.c drivers/pinctrl/vt8500/pinctrl-wmt.c Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: pinconf: fix comparison of different typesJingoo Han
Fix the following sparse warning: drivers/pinctrl/pinconf.c:521:20: error: incompatible types in comparison expression (different type sizes) Signed-off-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 9b6803542e1bd544289d605c84233a0e0a46ac7d) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: shut up a couple of pinctrl warningsRussell King - ARM Linux
So, I notice that we get a couple of warnings from the pinctrl code: drivers/pinctrl/pinconf.c: In function 'pinconf_dbg_config_print': drivers/pinctrl/pinconf.c:433:36: warning: 'configs' may be used uninitialized in this function drivers/pinctrl/pinconf.c: In function 'pinconf_dbg_config_write': drivers/pinctrl/pinconf.c:511:36: warning: 'configs' may be used uninitialized in this function While the compiler might not be able to work out that "configs" is safe, the code doesn't lend itself very well to identifying that fact when reading it either. This can be trivially solved by a slight restructuring of the code - which also reduces the LOC. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 8a9dcc3ffed66bf6f66c45b11f34de02b0fda4a0) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: rip out the direct pinconf APILinus Walleij
From the inception ot the pin config API there has been the possibility to get a handle at a pin directly and configure its electrical characteristics. For this reason we had: int pin_config_get(const char *dev_name, const char *name, unsigned long *config); int pin_config_set(const char *dev_name, const char *name, unsigned long config); int pin_config_group_get(const char *dev_name, const char *pin_group, unsigned long *config); int pin_config_group_set(const char *dev_name, const char *pin_group, unsigned long config); After the introduction of the pin control states that will control pins associated with devices, and its subsequent introduction to the device core, as well as the introduction of pin control hogs that can set up states on boot and optionally also at sleep, this direct pin control API is a thing of the past. As could be expected, it has zero in-kernel users. Let's delete this API and make our world simpler. Reported-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Acked-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit ad42fc6c84795d19972e7f7dee70fe74bec4c2d8) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: move the pm state stubsLinus Walleij
The stubs for the !PINCTRL case were placed in the wrong part of the file, causing breakage in linux-next when compiling SH without pinctrl. Fix it up by moving the stubs to the right place. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit ff73ceed0b5a046468de20d3b014a8c59051f90a) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31drivers: pinctrl sleep and idle states in the coreLinus Walleij
If a device have sleep and idle states in addition to the default state, look up these in the core and stash them in the pinctrl state container. Add accessor functions for pinctrl consumers to put the pins into "default", "sleep" and "idle" states passing nothing but the struct device * affected. Solution suggested by Kevin Hilman, Mark Brown and Dmitry Torokhov in response to a patch series from Hebbar Gururaja. Cc: Hebbar Gururaja <gururaja.hebbar@ti.com> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: Stephen Warren <swarren@wwwdotorg.org> Acked-by: Wolfram Sang <wsa@the-dreams.de> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Mark Brown <broonie@kernel.org> Reviewed-by: Kevin Hilman <khilman@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 14005ee270cad7078adbce6b7f3687b992a8334e) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: pinconf: take the right mutexLinus Walleij
The pinconf_dgb_config_print() takes the per-pincontroller mutex, when what it wants to take is actually the pin maps mutex. Reported-by: James Hogan <james.hogan@imgtec.com> Cc: Patrice Chotard <patrice.chotard@st.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit a386267a2ceea33d76fa2b7f1c2e72a858fcb68e) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: remove minor dead codeMichael Opdenacker
This removes a test whether the 'desc' variable is NULL. This possibility has already been eliminated by the below test earlier in the loop: if (desc == NULL) { dev_warn(pctldev->dev, "could not get pin desc for pin %d\n", pins[i]); continue; } Found with Coverity: CID #1090078 Signed-off-by: Michael Opdenacker <michael.opdenacker@free-electrons.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 808e657c5c709844074d47a4284c746070b0772c) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: improve warning messagesLinus Walleij
Print out the affected group name on activation of pin mux settings, and warn if you cannot free a pin that should have been part of a certain setting. ChangeLog v1->v2: - Also print the pin name in the error messages. Cc: Sonic Zhang <sonic.zhang@analog.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 1c8e794432c2ee752599bf114f3e8bd683674e3d) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: pinmux: Don't free pins requested by other devices in ↵Sonic Zhang
pinmux_disable_setting. One peripheral may share part of its pins with the 2nd peripheral and the other pins with the 3rd. If it requests all pins when part of them has already be requested and owned by the 2nd peripheral, this request fails and pinmux_disable_setting() is called. The pinmux_disable_setting() frees all pins of the first peripheral without checking if the pin is owned by itself or the 2nd, which results in the malfunction of the 2nd peripheral driver. Signed-off-by: Sonic Zhang <sonic.zhang@analog.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 744f0a9adb6a3478c9753eef56b0614ee69f969e) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: move subsystem mutex to pinctrl_dev structPatrice Chotard
This mutex avoids deadlock in case of use of multiple pin controllers. Before this modification, by using a global mutex, deadlock appeared when, for example, a call to pinctrl_pins_show() locked the pinctrl_mutex, called the ops->pin_dbg_show of a particular pin controller. If this pin controller needs I2C access to retrieve configuration information and I2C driver is using pinctrl to drive its pins, a call to pinctrl_select_state() try to lock again pinctrl_mutex which leads to a deadlock. Notice that the mutex grab from the two direction functions was moved into pinctrl_gpio_direction(). For several cases, we can't replace pinctrl_mutex by pctldev->mutex, because at this stage, pctldev is not accessible : - pinctrl_get()/pinctrl_put() - pinctrl_register_maps() So add respectively pinctrl_list_mutex and pinctrl_maps_mutex in order to protect pinctrl_list and pinctrl_maps list instead. Reintroduce pinctrldev_list_mutex in find_pinctrl_by_of_node(), pinctrl_find_and_add_gpio_range() pinctrl_request_gpio(), pinctrl_free_gpio(), pinctrl_gpio_direction(), pinctrl_devices_show(), pinctrl_register() and pinctrl_unregister() to protect pinctrldev_list. Changes v2->v3: - Fix a missing EXPORT_SYMBOL_GPL() for pinctrl_select_state(). Changes v1->v2: - pinctrl_select_state_locked() is removed, all lock mechanism is located inside pinctrl_select_state(). When parsing the state->setting list, take the per-pin-controller driver lock. (Patrice). - Introduce pinctrldev_list_mutex to protect pinctrldev_list in all functions which parse or modify pictrldev_list. (Patrice). - move find_pinctrl_by_of_node() from pinctrl/devicetree.c to pinctrl/core.c in order to protect pinctrldev_list. (Patrice). - Sink mutex:es into some functions and remove some _locked variants down to where the lists are actually accessed to make things simpler. (Linus) - Drop *all* mutexes completely from pinctrl_lookup_state() and pinctrl_select_state() - no relevant mutex was taken and it was unclear what this was protecting against. (Linus) Reported by : Seraphin Bonnaffe <seraphin.bonnaffe@stericsson.com> Signed-off-by: Patrice Chotard <patrice.chotard@st.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 42fed7ba44e4e8c1fb27b28ad14490cb1daff3c7) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinmux: forbid mux_usecount to be set at UINT_MAXRichard Genoud
If pin_free is called on a pin already freed, mux_usecount is set to UINT_MAX which is really a bad idea. This will issue a warning, so that we can correct the code responsible for the double free. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 740924a267e85de09707ea158bbf594b4d8bae01) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: simplify the re-enable old state code in pinctrl_select_stateRichard Genoud
Instead of just enabling the settings that were disabled in the 1st loop, it's simpler to recall pinctrl_select_state with the old state. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 385d94246b05f7c06d7ecb5215087e5ebddbf1e6) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: select_state: don't call pinctrl_free_setting on errorRichard Genoud
As Stephen Warren pointed out, pinctrl_free_setting() was called instead of pinmux_disable_setting() on error. In this error code, we want to call pinmux_disable_setting() where pinmux_enable_setting() was called. And when pinconf_apply_setting() was called, we can't do much to undo the pin muxing (the closest thing I can think about for "unmuxing" a pin is muxing it as GPIO input). Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit af6061777131639d7d2687ce542b6052a6510c25) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: pinctrl_select_state: set the old_state back on errorRichard Genoud
In unapply_new_state, the old state is re-applied, but p->state is not set back as it should. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 175ca83c0b6ab3c2af2d9e1ffff4d274910bbc10) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: remove superfluous optimization in pinctrl_select_state_lockedRichard Genoud
As Stephen Warren suggested, checking first if the setting->node entry is the first in the list or not is superfluous, as it is checked again in the list_for_each_entry bellow. So, remove it, the code will be simpler and lighter ! Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 8009d5ff00df6ad595f2d389f2e32bd4b97aebf5) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: use dev_info instead of pr_info in pinctrl_select_state_lockedRichard Genoud
And remove superfluous brackets. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Reviewed-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit da58751ca2490d5de3a0f7753fd7078c4285c2bc) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: core: add dependence of GPIOLIBHaojian Zhuang
In file included from drivers/pinctrl/core.c:30:0: include/asm-generic/gpio.h: In function 'gpio_get_value_cansleep': include/asm-generic/gpio.h:270:2: error: implicit declaration of function '__gpio_get_value' [-Werror=implicit-function-declaration] include/asm-generic/gpio.h: In function 'gpio_set_value_cansleep': include/asm-generic/gpio.h:276:2: error: implicit declaration of function '__gpio_set_value' [-Werror=implicit-function-declaration] drivers/pinctrl/core.c: In function 'pinctrl_ready_for_gpio_range': drivers/pinctrl/core.c:297:9: error: implicit declaration of function 'gpio_to_chip' [-Werror=implicit-function-declaration] drivers/pinctrl/core.c:297:27: warning: initialization makes pointer from integer without a cast [enabled by default] drivers/pinctrl/core.c:304:45: error: dereferencing pointer to incomplete type drivers/pinctrl/core.c:305:26: error: dereferencing pointer to incomplete type drivers/pinctrl/core.c:305:39: error: dereferencing pointer to incomplete type cc1: some warnings being treated as errors make[2]: *** [drivers/pinctrl/core.o] Error 1 make[1]: *** [drivers/pinctrl] Error 2 make[1]: *** Waiting for unfinished jobs.... It's caused by CONFIG_GPIOLIB isn't enabled for some platform. So add the dependence on pinctrl_ready_for_gpio_range(). Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 2afe8229687ec24cbc07e78449a588bb8b68f858) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: re-enable old state in case of error in pinctrl_select_stateRichard Genoud
If a new state is applied, the groups configured in the old state but not in the new state are disabled. If something goes wrong and the new state can't be applied, we have to re-enable those groups. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 50cf7c8ab324de348990bb028ad9ed10872d527a) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: disable and free setting in select_state in case of errorRichard Genoud
If enabling a pin fails in pinctrl_select_state_locked(), all the previous enabled pins have to be disabled to get back to the previous state. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 3102a76cfbf9ac4ae0cf54c7452f7ba4292a4760) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: create pinctrl_free_setting functionRichard Genoud
This prepares the implementation of pinctrl_select_state_locked() free code. No functionnal change. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit d3cee8305b48316ea416a73c763be3cb04bbc82b) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: check pinctrl ready for gpio rangeHaojian Zhuang
pinctrl_get_device_gpio_range() only checks whether a certain GPIO pin is in gpio range. But maybe some GPIO pins don't have back-end pinctrl interface, it means that these pins are always configured as GPIO function. For example, gpio159 isn't related to back-end pinctrl device in Hi3620 while other GPIO pins are related to back-end pinctrl device. Append pinctrl_ready_for_gpio_range() that is used to check whether pinctrl device with GPIO range is ready. This function will be called after pinctrl_get_device_gpio_range() fails. If pinctrl device with GPIO range is found, it means that pinctrl device is already launched and a certain GPIO pin just don't have back-end pinctrl interface. Then pinctrl_request_gpio() shouldn't return -EPROBE_DEFER in this case. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 51e13c2475913d45a3ec546dee647538a9341d6a) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: core: use devres_release() instead of devres_destroy()Jingoo Han
devres_release() can simplify the code, because devres_release() will call the destructor for the resource as well as freeing the devres data. Signed-off-by: Jingoo Han <jg1.han@samsung.com> Acked-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit a72149e82b65b76d2dae5428a6b211eb43933529) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl: fix typo in headerRichard Genoud
Clearly, "node" was meant instead of "not" Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit 2c9abf808a81e2b2b61f6e05ec1554669aab3b19) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl/pinconfig: fix misplaced gotoLaurent Meunier
This update contains a basic fix that went unseen through test and review. Signed-off-by: Laurent Meunier <laurent.meunier@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit cb6d315dc36ce56bc017051befa9ac9391300eb9) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>
2013-12-31pinctrl/pinconfig: add debug interfaceLaurent Meunier
This update adds a debugfs interface to modify a pin configuration for a given state in the pinctrl map. This allows to modify the configuration for a non-active state, typically sleep state. This configuration is not applied right away, but only when the state will be entered. This solution is mandated for us by HW validation: in order to test and verify several pin configurations during sleep without recompiling the software. Change log in this patch set; Take into account latest feedback from Stephen Warren: - stale comments update - improved code efficiency and readibility - limit size of global variable pinconf_dbg_conf - remove req_type as it can easily be added later when add/delete requests support is implemented Signed-off-by: Laurent Meunier <laurent.meunier@st.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> (cherry picked from commit f07512e615dd8ebd0866efc38b39ccd41f1495d8) Signed-off-by: Ong, Boon Leong <boon.leong.ong@intel.com>