Commit e93bcee0 authored by Linus Walleij's avatar Linus Walleij

pinctrl: move generic functions to the pinctrl_ namespace

Since we want to use the former pinmux handles and mapping tables for
generic control involving both muxing and configuration we begin
refactoring by renaming them from pinmux_* to pinctrl_*.

ChangeLog v1->v2:
- Also rename the PINMUX_* macros in machine.h to PIN_ as indicated
  in the documentation so as to reflect the generic nature of these
  mapping entries from now on.
Acked-by: default avatarStephen Warren <swarren@nvidia.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 28a8d14c
...@@ -728,19 +728,19 @@ same time. ...@@ -728,19 +728,19 @@ same time.
All the above functions are mandatory to implement for a pinmux driver. All the above functions are mandatory to implement for a pinmux driver.
Pinmux interaction with the GPIO subsystem Pin control interaction with the GPIO subsystem
========================================== ===============================================
The public pinmux API contains two functions named pinmux_request_gpio() The public pinmux API contains two functions named pinctrl_request_gpio()
and pinmux_free_gpio(). These two functions shall *ONLY* be called from and pinctrl_free_gpio(). These two functions shall *ONLY* be called from
gpiolib-based drivers as part of their gpio_request() and gpiolib-based drivers as part of their gpio_request() and
gpio_free() semantics. Likewise the pinmux_gpio_direction_[input|output] gpio_free() semantics. Likewise the pinctrl_gpio_direction_[input|output]
shall only be called from within respective gpio_direction_[input|output] shall only be called from within respective gpio_direction_[input|output]
gpiolib implementation. gpiolib implementation.
NOTE that platforms and individual drivers shall *NOT* request GPIO pins to be NOTE that platforms and individual drivers shall *NOT* request GPIO pins to be
muxed in. Instead, implement a proper gpiolib driver and have that driver controlled e.g. muxed in. Instead, implement a proper gpiolib driver and have
request proper muxing for its pins. that driver request proper muxing and other control for its pins.
The function list could become long, especially if you can convert every The function list could become long, especially if you can convert every
individual pin into a GPIO pin independent of any other pins, and then try individual pin into a GPIO pin independent of any other pins, and then try
...@@ -749,7 +749,7 @@ the approach to define every pin as a function. ...@@ -749,7 +749,7 @@ the approach to define every pin as a function.
In this case, the function array would become 64 entries for each GPIO In this case, the function array would become 64 entries for each GPIO
setting and then the device functions. setting and then the device functions.
For this reason there are two functions a pinmux driver can implement For this reason there are two functions a pin control driver can implement
to enable only GPIO on an individual pin: .gpio_request_enable() and to enable only GPIO on an individual pin: .gpio_request_enable() and
.gpio_disable_free(). .gpio_disable_free().
...@@ -764,7 +764,7 @@ gpiolib driver and the affected GPIO range, pin offset and desired direction ...@@ -764,7 +764,7 @@ gpiolib driver and the affected GPIO range, pin offset and desired direction
will be passed along to this function. will be passed along to this function.
Alternatively to using these special functions, it is fully allowed to use Alternatively to using these special functions, it is fully allowed to use
named functions for each GPIO pin, the pinmux_request_gpio() will attempt to named functions for each GPIO pin, the pinctrl_request_gpio() will attempt to
obtain the function "gpioN" where "N" is the global GPIO pin number if no obtain the function "gpioN" where "N" is the global GPIO pin number if no
special GPIO-handler is registered. special GPIO-handler is registered.
...@@ -783,7 +783,7 @@ spi on the second function mapping: ...@@ -783,7 +783,7 @@ spi on the second function mapping:
#include <linux/pinctrl/machine.h> #include <linux/pinctrl/machine.h>
static const struct pinmux_map __initdata pmx_mapping[] = { static const struct pinctrl_map __initdata mapping[] = {
{ {
.ctrl_dev_name = "pinctrl-foo", .ctrl_dev_name = "pinctrl-foo",
.function = "spi0", .function = "spi0",
...@@ -811,14 +811,14 @@ to map. ...@@ -811,14 +811,14 @@ to map.
You register this pinmux mapping to the pinmux subsystem by simply: You register this pinmux mapping to the pinmux subsystem by simply:
ret = pinmux_register_mappings(pmx_mapping, ARRAY_SIZE(pmx_mapping)); ret = pinctrl_register_mappings(mapping, ARRAY_SIZE(mapping));
Since the above construct is pretty common there is a helper macro to make Since the above construct is pretty common there is a helper macro to make
it even more compact which assumes you want to use pinctrl-foo and position it even more compact which assumes you want to use pinctrl-foo and position
0 for mapping, for example: 0 for mapping, for example:
static struct pinmux_map __initdata pmx_mapping[] = { static struct pinctrl_map __initdata mapping[] = {
PINMUX_MAP("I2CMAP", "pinctrl-foo", "i2c0", "foo-i2c.0"), PIN_MAP("I2CMAP", "pinctrl-foo", "i2c0", "foo-i2c.0"),
}; };
...@@ -901,7 +901,7 @@ case), we define a mapping like this: ...@@ -901,7 +901,7 @@ case), we define a mapping like this:
The result of grabbing this mapping from the device with something like The result of grabbing this mapping from the device with something like
this (see next paragraph): this (see next paragraph):
pmx = pinmux_get(&device, "8bit"); p = pinctrl_get(&device, "8bit");
Will be that you activate all the three bottom records in the mapping at Will be that you activate all the three bottom records in the mapping at
once. Since they share the same name, pin controller device, funcion and once. Since they share the same name, pin controller device, funcion and
...@@ -913,44 +913,44 @@ pinmux core. ...@@ -913,44 +913,44 @@ pinmux core.
Pinmux requests from drivers Pinmux requests from drivers
============================ ============================
Generally it is discouraged to let individual drivers get and enable pinmuxes. Generally it is discouraged to let individual drivers get and enable pin
So if possible, handle the pinmuxes in platform code or some other place where control. So if possible, handle the pin control in platform code or some other
you have access to all the affected struct device * pointers. In some cases place where you have access to all the affected struct device * pointers. In
where a driver needs to switch between different mux mappings at runtime some cases where a driver needs to e.g. switch between different mux mappings
this is not possible. at runtime this is not possible.
A driver may request a certain mux to be activated, usually just the default A driver may request a certain control state to be activated, usually just the
mux like this: default state like this:
#include <linux/pinctrl/consumer.h> #include <linux/pinctrl/consumer.h>
struct foo_state { struct foo_state {
struct pinmux *pmx; struct pinctrl *p;
... ...
}; };
foo_probe() foo_probe()
{ {
/* Allocate a state holder named "state" etc */ /* Allocate a state holder named "state" etc */
struct pinmux pmx; struct pinctrl p;
pmx = pinmux_get(&device, NULL); p = pinctrl_get(&device, NULL);
if IS_ERR(pmx) if IS_ERR(p)
return PTR_ERR(pmx); return PTR_ERR(p);
pinmux_enable(pmx); pinctrl_enable(p);
state->pmx = pmx; state->p = p;
} }
foo_remove() foo_remove()
{ {
pinmux_disable(state->pmx); pinctrl_disable(state->p);
pinmux_put(state->pmx); pinctrl_put(state->p);
} }
If you want to grab a specific mux mapping and not just the first one found for If you want to grab a specific control mapping and not just the first one
this device you can specify a specific mapping name, for example in the above found for this device you can specify a specific mapping name, for example in
example the second i2c0 setting: pinmux_get(&device, "spi0-pos-B"); the above example the second i2c0 setting: pinctrl_get(&device, "spi0-pos-B");
This get/enable/disable/put sequence can just as well be handled by bus drivers This get/enable/disable/put sequence can just as well be handled by bus drivers
if you don't want each and every driver to handle it and you know the if you don't want each and every driver to handle it and you know the
...@@ -958,35 +958,35 @@ arrangement on your bus. ...@@ -958,35 +958,35 @@ arrangement on your bus.
The semantics of the get/enable respective disable/put is as follows: The semantics of the get/enable respective disable/put is as follows:
- pinmux_get() is called in process context to reserve the pins affected with - pinctrl_get() is called in process context to reserve the pins affected with
a certain mapping and set up the pinmux core and the driver. It will allocate a certain mapping and set up the pinmux core and the driver. It will allocate
a struct from the kernel memory to hold the pinmux state. a struct from the kernel memory to hold the pinmux state.
- pinmux_enable()/pinmux_disable() is quick and can be called from fastpath - pinctrl_enable()/pinctrl_disable() is quick and can be called from fastpath
(irq context) when you quickly want to set up/tear down the hardware muxing (irq context) when you quickly want to set up/tear down the hardware muxing
when running a device driver. Usually it will just poke some values into a when running a device driver. Usually it will just poke some values into a
register. register.
- pinmux_disable() is called in process context to tear down the pin requests - pinctrl_disable() is called in process context to tear down the pin requests
and release the state holder struct for the mux setting. and release the state holder struct for the mux setting etc.
Usually the pinmux core handled the get/put pair and call out to the device Usually the pin control core handled the get/put pair and call out to the
drivers bookkeeping operations, like checking available functions and the device drivers bookkeeping operations, like checking available functions and
associated pins, whereas the enable/disable pass on to the pin controller the associated pins, whereas the enable/disable pass on to the pin controller
driver which takes care of activating and/or deactivating the mux setting by driver which takes care of activating and/or deactivating the mux setting by
quickly poking some registers. quickly poking some registers.
The pins are allocated for your device when you issue the pinmux_get() call, The pins are allocated for your device when you issue the pinctrl_get() call,
after this you should be able to see this in the debugfs listing of all pins. after this you should be able to see this in the debugfs listing of all pins.
System pinmux hogging System pin control hogging
===================== ==========================
A system pinmux map entry, i.e. a pinmux setting that does not have a device A system pin control map entry, i.e. a pin control setting that does not have
associated with it, can be hogged by the core when the pin controller is a device associated with it, can be hogged by the core when the pin controller
registered. This means that the core will attempt to call pinmux_get() and is registered. This means that the core will attempt to call pinctrl_get() and
pinmux_enable() on it immediately after the pin control device has been pinctrl_enable() on it immediately after the pin control device has been
registered. registered.
This is enabled by simply setting the .hog_on_boot field in the map to true, This is enabled by simply setting the .hog_on_boot field in the map to true,
...@@ -1003,7 +1003,7 @@ Since it may be common to request the core to hog a few always-applicable ...@@ -1003,7 +1003,7 @@ Since it may be common to request the core to hog a few always-applicable
mux settings on the primary pin controller, there is a convenience macro for mux settings on the primary pin controller, there is a convenience macro for
this: this:
PINMUX_MAP_PRIMARY_SYS_HOG("POWERMAP", "power_func") PIN_MAP_PRIMARY_SYS_HOG("POWERMAP", "power_func")
This gives the exact same result as the above construction. This gives the exact same result as the above construction.
...@@ -1025,23 +1025,23 @@ it, disables and releases it, and muxes it in on the pins defined by group B: ...@@ -1025,23 +1025,23 @@ it, disables and releases it, and muxes it in on the pins defined by group B:
foo_switch() foo_switch()
{ {
struct pinmux *pmx; struct pinctrl *p;
/* Enable on position A */ /* Enable on position A */
pmx = pinmux_get(&device, "spi0-pos-A"); p = pinctrl_get(&device, "spi0-pos-A");
if IS_ERR(pmx) if IS_ERR(p)
return PTR_ERR(pmx); return PTR_ERR(p);
pinmux_enable(pmx); pinctrl_enable(p);
/* This releases the pins again */ /* This releases the pins again */
pinmux_disable(pmx); pinctrl_disable(p);
pinmux_put(pmx); pinctrl_put(p);
/* Enable on position B */ /* Enable on position B */
pmx = pinmux_get(&device, "spi0-pos-B"); p = pinctrl_get(&device, "spi0-pos-B");
if IS_ERR(pmx) if IS_ERR(p)
return PTR_ERR(pmx); return PTR_ERR(p);
pinmux_enable(pmx); pinctrl_enable(p);
... ...
} }
......
...@@ -1605,21 +1605,21 @@ static struct platform_device pinmux_device = { ...@@ -1605,21 +1605,21 @@ static struct platform_device pinmux_device = {
}; };
/* Pinmux settings */ /* Pinmux settings */
static struct pinmux_map __initdata u300_pinmux_map[] = { static struct pinctrl_map __initdata u300_pinmux_map[] = {
/* anonymous maps for chip power and EMIFs */ /* anonymous maps for chip power and EMIFs */
PINMUX_MAP_SYS_HOG("POWER", "pinmux-u300", "power"), PIN_MAP_SYS_HOG("POWER", "pinmux-u300", "power"),
PINMUX_MAP_SYS_HOG("EMIF0", "pinmux-u300", "emif0"), PIN_MAP_SYS_HOG("EMIF0", "pinmux-u300", "emif0"),
PINMUX_MAP_SYS_HOG("EMIF1", "pinmux-u300", "emif1"), PIN_MAP_SYS_HOG("EMIF1", "pinmux-u300", "emif1"),
/* per-device maps for MMC/SD, SPI and UART */ /* per-device maps for MMC/SD, SPI and UART */
PINMUX_MAP("MMCSD", "pinmux-u300", "mmc0", "mmci"), PIN_MAP("MMCSD", "pinmux-u300", "mmc0", "mmci"),
PINMUX_MAP("SPI", "pinmux-u300", "spi0", "pl022"), PIN_MAP("SPI", "pinmux-u300", "spi0", "pl022"),
PINMUX_MAP("UART0", "pinmux-u300", "uart0", "uart0"), PIN_MAP("UART0", "pinmux-u300", "uart0", "uart0"),
}; };
struct u300_mux_hog { struct u300_mux_hog {
const char *name; const char *name;
struct device *dev; struct device *dev;
struct pinmux *pmx; struct pinctrl *p;
}; };
static struct u300_mux_hog u300_mux_hogs[] = { static struct u300_mux_hog u300_mux_hogs[] = {
...@@ -1637,31 +1637,31 @@ static struct u300_mux_hog u300_mux_hogs[] = { ...@@ -1637,31 +1637,31 @@ static struct u300_mux_hog u300_mux_hogs[] = {
}, },
}; };
static int __init u300_pinmux_fetch(void) static int __init u300_pinctrl_fetch(void)
{ {
int i; int i;
for (i = 0; i < ARRAY_SIZE(u300_mux_hogs); i++) { for (i = 0; i < ARRAY_SIZE(u300_mux_hogs); i++) {
struct pinmux *pmx; struct pinctrl *p;
int ret; int ret;
pmx = pinmux_get(u300_mux_hogs[i].dev, NULL); p = pinctrl_get(u300_mux_hogs[i].dev, NULL);
if (IS_ERR(pmx)) { if (IS_ERR(p)) {
pr_err("u300: could not get pinmux hog %s\n", pr_err("u300: could not get pinmux hog %s\n",
u300_mux_hogs[i].name); u300_mux_hogs[i].name);
continue; continue;
} }
ret = pinmux_enable(pmx); ret = pinctrl_enable(p);
if (ret) { if (ret) {
pr_err("u300: could enable pinmux hog %s\n", pr_err("u300: could enable pinmux hog %s\n",
u300_mux_hogs[i].name); u300_mux_hogs[i].name);
continue; continue;
} }
u300_mux_hogs[i].pmx = pmx; u300_mux_hogs[i].p = p;
} }
return 0; return 0;
} }
subsys_initcall(u300_pinmux_fetch); subsys_initcall(u300_pinctrl_fetch);
/* /*
* Notice that AMBA devices are initialized before platform devices. * Notice that AMBA devices are initialized before platform devices.
...@@ -1861,8 +1861,8 @@ void __init u300_init_devices(void) ...@@ -1861,8 +1861,8 @@ void __init u300_init_devices(void)
u300_assign_physmem(); u300_assign_physmem();
/* Initialize pinmuxing */ /* Initialize pinmuxing */
pinmux_register_mappings(u300_pinmux_map, pinctrl_register_mappings(u300_pinmux_map,
ARRAY_SIZE(u300_pinmux_map)); ARRAY_SIZE(u300_pinmux_map));
/* Register subdevices on the I2C buses */ /* Register subdevices on the I2C buses */
u300_i2c_register_board_devices(); u300_i2c_register_board_devices();
......
...@@ -624,7 +624,7 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, ...@@ -624,7 +624,7 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
mutex_lock(&pinctrldev_list_mutex); mutex_lock(&pinctrldev_list_mutex);
list_add(&pctldev->node, &pinctrldev_list); list_add(&pctldev->node, &pinctrldev_list);
mutex_unlock(&pinctrldev_list_mutex); mutex_unlock(&pinctrldev_list_mutex);
pinmux_hog_maps(pctldev); pinctrl_hog_maps(pctldev);
return pctldev; return pctldev;
out_err: out_err:
...@@ -645,7 +645,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev) ...@@ -645,7 +645,7 @@ void pinctrl_unregister(struct pinctrl_dev *pctldev)
return; return;
pinctrl_remove_device_debugfs(pctldev); pinctrl_remove_device_debugfs(pctldev);
pinmux_unhog_maps(pctldev); pinctrl_unhog_maps(pctldev);
/* TODO: check that no pinmuxes are still active? */ /* TODO: check that no pinmuxes are still active? */
mutex_lock(&pinctrldev_list_mutex); mutex_lock(&pinctrldev_list_mutex);
list_del(&pctldev->node); list_del(&pctldev->node);
......
...@@ -28,8 +28,8 @@ struct pinctrl_gpio_range; ...@@ -28,8 +28,8 @@ struct pinctrl_gpio_range;
* @owner: module providing the pin controller, used for refcounting * @owner: module providing the pin controller, used for refcounting
* @driver_data: driver data for drivers registering to the pin controller * @driver_data: driver data for drivers registering to the pin controller
* subsystem * subsystem
* @pinmux_hogs_lock: lock for the pinmux hog list * @pinctrl_hogs_lock: lock for the pin control hog list
* @pinmux_hogs: list of pinmux maps hogged by this device * @pinctrl_hogs: list of pin control maps hogged by this device
*/ */
struct pinctrl_dev { struct pinctrl_dev {
struct list_head node; struct list_head node;
...@@ -45,8 +45,8 @@ struct pinctrl_dev { ...@@ -45,8 +45,8 @@ struct pinctrl_dev {
struct dentry *device_root; struct dentry *device_root;
#endif #endif
#ifdef CONFIG_PINMUX #ifdef CONFIG_PINMUX
struct mutex pinmux_hogs_lock; struct mutex pinctrl_hogs_lock;
struct list_head pinmux_hogs; struct list_head pinctrl_hogs;
#endif #endif
}; };
......
...@@ -360,14 +360,14 @@ static int u300_gpio_request(struct gpio_chip *chip, unsigned offset) ...@@ -360,14 +360,14 @@ static int u300_gpio_request(struct gpio_chip *chip, unsigned offset)
*/ */
int gpio = chip->base + offset; int gpio = chip->base + offset;
return pinmux_request_gpio(gpio); return pinctrl_request_gpio(gpio);
} }
static void u300_gpio_free(struct gpio_chip *chip, unsigned offset) static void u300_gpio_free(struct gpio_chip *chip, unsigned offset)
{ {
int gpio = chip->base + offset; int gpio = chip->base + offset;
pinmux_free_gpio(gpio); pinctrl_free_gpio(gpio);
} }
static int u300_gpio_get(struct gpio_chip *chip, unsigned offset) static int u300_gpio_get(struct gpio_chip *chip, unsigned offset)
......
/* /*
* Core driver for the pin muxing portions of the pin control subsystem * Core driver for the pin muxing portions of the pin control subsystem
* *
* Copyright (C) 2011 ST-Ericsson SA * Copyright (C) 2011-2012 ST-Ericsson SA
* Written on behalf of Linaro for ST-Ericsson * Written on behalf of Linaro for ST-Ericsson
* Based on bits of regulator core, gpio core and clk core * Based on bits of regulator core, gpio core and clk core
* *
...@@ -29,13 +29,13 @@ ...@@ -29,13 +29,13 @@
#include <linux/pinctrl/pinmux.h> #include <linux/pinctrl/pinmux.h>
#include "core.h" #include "core.h"
/* List of pinmuxes */ /* List of pin controller handles */
static DEFINE_MUTEX(pinmux_list_mutex); static DEFINE_MUTEX(pinctrl_list_mutex);
static LIST_HEAD(pinmux_list); static LIST_HEAD(pinctrl_list);
/* Global pinmux maps */ /* Global pinctrl maps */
static struct pinmux_map *pinmux_maps; static struct pinctrl_map *pinctrl_maps;
static unsigned pinmux_maps_num; static unsigned pinctrl_maps_num;
/** /**
* struct pinmux_group - group list item for pinmux groups * struct pinmux_group - group list item for pinmux groups
...@@ -48,12 +48,12 @@ struct pinmux_group { ...@@ -48,12 +48,12 @@ struct pinmux_group {
}; };
/** /**
* struct pinmux - per-device pinmux state holder * struct pinctrl - per-device pin control state holder
* @node: global list node * @node: global list node
* @dev: the device using this pinmux * @dev: the device using this pin control handle
* @usecount: the number of active users of this mux setting, used to keep * @usecount: the number of active users of this pin controller setting, used
* track of nested use cases * to keep track of nested use cases
* @pctldev: pin control device handling this pinmux * @pctldev: pin control device handling this pin control handle
* @func_selector: the function selector for the pinmux device handling * @func_selector: the function selector for the pinmux device handling
* this pinmux * this pinmux
* @groups: the group selectors for the pinmux device and * @groups: the group selectors for the pinmux device and
...@@ -62,7 +62,7 @@ struct pinmux_group { ...@@ -62,7 +62,7 @@ struct pinmux_group {
* get/put/enable/disable * get/put/enable/disable
* @mutex: a lock for the pinmux state holder * @mutex: a lock for the pinmux state holder
*/ */
struct pinmux { struct pinctrl {
struct list_head node; struct list_head node;
struct device *dev; struct device *dev;
unsigned usecount; unsigned usecount;
...@@ -73,15 +73,15 @@ struct pinmux { ...@@ -73,15 +73,15 @@ struct pinmux {
}; };
/** /**
* struct pinmux_hog - a list item to stash mux hogs * struct pinctrl_hog - a list item to stash control hogs
* @node: pinmux hog list node * @node: pin control hog list node
* @map: map entry responsible for this hogging * @map: map entry responsible for this hogging
* @pmx: the pinmux hogged by this item * @pmx: the pin control hogged by this item
*/ */
struct pinmux_hog { struct pinctrl_hog {
struct list_head node; struct list_head node;
struct pinmux_map const *map; struct pinctrl_map const *map;
struct pinmux *pmx; struct pinctrl *p;
}; };
/** /**
...@@ -207,14 +207,14 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin, ...@@ -207,14 +207,14 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin,
} }
/** /**
* pinmux_request_gpio() - request a single pin to be muxed in as GPIO * pinctrl_request_gpio() - request a single pin to be used in as GPIO
* @gpio: the GPIO pin number from the GPIO subsystem number space * @gpio: the GPIO pin number from the GPIO subsystem number space
* *
* This function should *ONLY* be used from gpiolib-based GPIO drivers, * This function should *ONLY* be used from gpiolib-based GPIO drivers,
* as part of their gpio_request() semantics, platforms and individual drivers * as part of their gpio_request() semantics, platforms and individual drivers
* shall *NOT* request GPIO pins to be muxed in. * shall *NOT* request GPIO pins to be muxed in.
*/ */
int pinmux_request_gpio(unsigned gpio) int pinctrl_request_gpio(unsigned gpio)
{ {
char gpiostr[16]; char gpiostr[16];
const char *function; const char *function;
...@@ -243,17 +243,17 @@ int pinmux_request_gpio(unsigned gpio) ...@@ -243,17 +243,17 @@ int pinmux_request_gpio(unsigned gpio)
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(pinmux_request_gpio); EXPORT_SYMBOL_GPL(pinctrl_request_gpio);
/** /**
* pinmux_free_gpio() - free a single pin, currently used as GPIO * pinctrl_free_gpio() - free control on a single pin, currently used as GPIO
* @gpio: the GPIO pin number from the GPIO subsystem number space * @gpio: the GPIO pin number from the GPIO subsystem number space
* *
* This function should *ONLY* be used from gpiolib-based GPIO drivers, * This function should *ONLY* be used from gpiolib-based GPIO drivers,
* as part of their gpio_free() semantics, platforms and individual drivers * as part of their gpio_free() semantics, platforms and individual drivers
* shall *NOT* request GPIO pins to be muxed out. * shall *NOT* request GPIO pins to be muxed out.
*/ */
void pinmux_free_gpio(unsigned gpio) void pinctrl_free_gpio(unsigned gpio)
{ {
struct pinctrl_dev *pctldev; struct pinctrl_dev *pctldev;
struct pinctrl_gpio_range *range; struct pinctrl_gpio_range *range;
...@@ -271,9 +271,9 @@ void pinmux_free_gpio(unsigned gpio) ...@@ -271,9 +271,9 @@ void pinmux_free_gpio(unsigned gpio)
func = pin_free(pctldev, pin, range); func = pin_free(pctldev, pin, range);
kfree(func); kfree(func);
} }
EXPORT_SYMBOL_GPL(pinmux_free_gpio); EXPORT_SYMBOL_GPL(pinctrl_free_gpio);
static int pinmux_gpio_direction(unsigned gpio, bool input) static int pinctrl_gpio_direction(unsigned gpio, bool input)
{ {
struct pinctrl_dev *pctldev; struct pinctrl_dev *pctldev;
struct pinctrl_gpio_range *range; struct pinctrl_gpio_range *range;
...@@ -299,36 +299,36 @@ static int pinmux_gpio_direction(unsigned gpio, bool input) ...@@ -299,36 +299,36 @@ static int pinmux_gpio_direction(unsigned gpio, bool input)
} }
/** /**
* pinmux_gpio_direction_input() - request a GPIO pin to go into input mode * pinctrl_gpio_direction_input() - request a GPIO pin to go into input mode
* @gpio: the GPIO pin number from the GPIO subsystem number space * @gpio: the GPIO pin number from the GPIO subsystem number space
* *
* This function should *ONLY* be used from gpiolib-based GPIO drivers, * This function should *ONLY* be used from gpiolib-based GPIO drivers,
* as part of their gpio_direction_input() semantics, platforms and individual * as part of their gpio_direction_input() semantics, platforms and individual
* drivers shall *NOT* touch pinmux GPIO calls. * drivers shall *NOT* touch pin control GPIO calls.
*/ */
int pinmux_gpio_direction_input(unsigned gpio) int pinctrl_gpio_direction_input(unsigned gpio)
{ {
return pinmux_gpio_direction(gpio, true); return pinctrl_gpio_direction(gpio, true);
} }
EXPORT_SYMBOL_GPL(pinmux_gpio_direction_input); EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_input);
/** /**
* pinmux_gpio_direction_output() - request a GPIO pin to go into output mode * pinctrl_gpio_direction_output() - request a GPIO pin to go into output mode
* @gpio: the GPIO pin number from the GPIO subsystem number space * @gpio: the GPIO pin number from the GPIO subsystem number space
* *
* This function should *ONLY* be used from gpiolib-based GPIO drivers, * This function should *ONLY* be used from gpiolib-based GPIO drivers,
* as part of their gpio_direction_output() semantics, platforms and individual * as part of their gpio_direction_output() semantics, platforms and individual
* drivers shall *NOT* touch pinmux GPIO calls. * drivers shall *NOT* touch pin control GPIO calls.
*/ */
int pinmux_gpio_direction_output(unsigned gpio) int pinctrl_gpio_direction_output(unsigned gpio)
{ {
return pinmux_gpio_direction(gpio, false); return pinctrl_gpio_direction(gpio, false);
} }
EXPORT_SYMBOL_GPL(pinmux_gpio_direction_output); EXPORT_SYMBOL_GPL(pinctrl_gpio_direction_output);
/** /**
* pinmux_register_mappings() - register a set of pinmux mappings * pinctrl_register_mappings() - register a set of pin controller mappings
* @maps: the pinmux mappings table to register, this should be marked with * @maps: the pincontrol mappings table to register, this should be marked with
* __initdata so it can be discarded after boot, this function will * __initdata so it can be discarded after boot, this function will
* perform a shallow copy for the mapping entries. * perform a shallow copy for the mapping entries.
* @num_maps: the number of maps in the mapping table * @num_maps: the number of maps in the mapping table
...@@ -338,8 +338,8 @@ EXPORT_SYMBOL_GPL(pinmux_gpio_direction_output); ...@@ -338,8 +338,8 @@ EXPORT_SYMBOL_GPL(pinmux_gpio_direction_output);
* passed into this function will be owned by the pinmux core and cannot be * passed into this function will be owned by the pinmux core and cannot be
* freed. * freed.
*/ */
int __init pinmux_register_mappings(struct pinmux_map const *maps, int __init pinctrl_register_mappings(struct pinctrl_map const *maps,
unsigned num_maps) unsigned num_maps)
{ {
void *tmp_maps; void *tmp_maps;
int i; int i;
...@@ -380,26 +380,27 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps, ...@@ -380,26 +380,27 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps,
* Make a copy of the map array - string pointers will end up in the * Make a copy of the map array - string pointers will end up in the
* kernel const section anyway so these do not need to be deep copied. * kernel const section anyway so these do not need to be deep copied.
*/ */
if (!pinmux_maps_num) { if (!pinctrl_maps_num) {
/* On first call, just copy them */ /* On first call, just copy them */
tmp_maps = kmemdup(maps, tmp_maps = kmemdup(maps,
sizeof(struct pinmux_map) * num_maps, sizeof(struct pinctrl_map) * num_maps,
GFP_KERNEL); GFP_KERNEL);
if (!tmp_maps) if (!tmp_maps)
return -ENOMEM; return -ENOMEM;
} else { } else {
/* Subsequent calls, reallocate array to new size */ /* Subsequent calls, reallocate array to new size */
size_t oldsize = sizeof(struct pinmux_map) * pinmux_maps_num; size_t oldsize = sizeof(struct pinctrl_map) * pinctrl_maps_num;
size_t newsize = sizeof(struct pinmux_map) * num_maps; size_t newsize = sizeof(struct pinctrl_map) * num_maps;
tmp_maps = krealloc(pinmux_maps, oldsize + newsize, GFP_KERNEL); tmp_maps = krealloc(pinctrl_maps,
oldsize + newsize, GFP_KERNEL);
if (!tmp_maps) if (!tmp_maps)
return -ENOMEM; return -ENOMEM;
memcpy((tmp_maps + oldsize), maps, newsize); memcpy((tmp_maps + oldsize), maps, newsize);
} }
pinmux_maps = tmp_maps; pinctrl_maps = tmp_maps;
pinmux_maps_num += num_maps; pinctrl_maps_num += num_maps;
return 0; return 0;
} }
...@@ -560,7 +561,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev, ...@@ -560,7 +561,7 @@ static int pinmux_check_pin_group(struct pinctrl_dev *pctldev,
* negative otherwise * negative otherwise
*/ */
static int pinmux_search_function(struct pinctrl_dev *pctldev, static int pinmux_search_function(struct pinctrl_dev *pctldev,
struct pinmux_map const *map, struct pinctrl_map const *map,
unsigned *func_selector, unsigned *func_selector,
unsigned *group_selector) unsigned *group_selector)
{ {
...@@ -598,10 +599,10 @@ static int pinmux_search_function(struct pinctrl_dev *pctldev, ...@@ -598,10 +599,10 @@ static int pinmux_search_function(struct pinctrl_dev *pctldev,
* pinmux_enable_muxmap() - enable a map entry for a certain pinmux * pinmux_enable_muxmap() - enable a map entry for a certain pinmux
*/ */
static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev, static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
struct pinmux *pmx, struct pinctrl *p,
struct device *dev, struct device *dev,
const char *devname, const char *devname,
struct pinmux_map const *map) struct pinctrl_map const *map)
{ {
unsigned func_selector; unsigned func_selector;
unsigned group_selector; unsigned group_selector;
...@@ -615,14 +616,14 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev, ...@@ -615,14 +616,14 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
* by anyone else. * by anyone else.
*/ */
if (pmx->pctldev && pmx->pctldev != pctldev) { if (p->pctldev && p->pctldev != pctldev) {
dev_err(pctldev->dev, dev_err(pctldev->dev,
"different pin control devices given for device %s, function %s\n", "different pin control devices given for device %s, function %s\n",
devname, map->function); devname, map->function);
return -EINVAL; return -EINVAL;
} }
pmx->dev = dev; p->dev = dev;
pmx->pctldev = pctldev; p->pctldev = pctldev;
/* Now go into the driver and try to match a function and group */ /* Now go into the driver and try to match a function and group */
ret = pinmux_search_function(pctldev, map, &func_selector, ret = pinmux_search_function(pctldev, map, &func_selector,
...@@ -635,14 +636,14 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev, ...@@ -635,14 +636,14 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
* we support several groups with one function but not several * we support several groups with one function but not several
* functions with one or several groups in the same pinmux. * functions with one or several groups in the same pinmux.
*/ */
if (pmx->func_selector != UINT_MAX && if (p->func_selector != UINT_MAX &&
pmx->func_selector != func_selector) { p->func_selector != func_selector) {
dev_err(pctldev->dev, dev_err(pctldev->dev,
"dual function defines in the map for device %s\n", "dual function defines in the map for device %s\n",
devname); devname);
return -EINVAL; return -EINVAL;
} }
pmx->func_selector = func_selector; p->func_selector = func_selector;
/* Now add this group selector, we may have many of them */ /* Now add this group selector, we may have many of them */
grp = kmalloc(sizeof(struct pinmux_group), GFP_KERNEL); grp = kmalloc(sizeof(struct pinmux_group), GFP_KERNEL);
...@@ -654,38 +655,38 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev, ...@@ -654,38 +655,38 @@ static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
kfree(grp); kfree(grp);
return ret; return ret;
} }
list_add(&grp->node, &pmx->groups); list_add(&grp->node, &p->groups);
return 0; return 0;
} }
static void pinmux_free_groups(struct pinmux *pmx) static void pinmux_free_groups(struct pinctrl *p)
{ {
struct list_head *node, *tmp; struct list_head *node, *tmp;
list_for_each_safe(node, tmp, &pmx->groups) { list_for_each_safe(node, tmp, &p->groups) {
struct pinmux_group *grp = struct pinmux_group *grp =
list_entry(node, struct pinmux_group, node); list_entry(node, struct pinmux_group, node);
/* Release all pins taken by this group */ /* Release all pins taken by this group */
release_pins(pmx->pctldev, grp->group_selector); release_pins(p->pctldev, grp->group_selector);
list_del(node); list_del(node);
kfree(grp); kfree(grp);
} }
} }
/** /**
* pinmux_get() - retrieves the pinmux for a certain device * pinctrl_get() - retrieves the pin controller handle for a certain device
* @dev: the device to get the pinmux for * @dev: the device to get the pin controller handle for
* @name: an optional specific mux mapping name or NULL, the name is only * @name: an optional specific control mapping name or NULL, the name is only
* needed if you want to have more than one mapping per device, or if you * needed if you want to have more than one mapping per device, or if you
* need an anonymous pinmux (not tied to any specific device) * need an anonymous pin control (not tied to any specific device)
*/ */
struct pinmux *pinmux_get(struct device *dev, const char *name) struct pinctrl *pinctrl_get(struct device *dev, const char *name)
{ {
struct pinmux_map const *map = NULL; struct pinctrl_map const *map = NULL;
struct pinctrl_dev *pctldev = NULL; struct pinctrl_dev *pctldev = NULL;
const char *devname = NULL; const char *devname = NULL;
struct pinmux *pmx; struct pinctrl *p;
bool found_map; bool found_map;
unsigned num_maps = 0; unsigned num_maps = 0;
int ret = -ENODEV; int ret = -ENODEV;
...@@ -706,16 +707,16 @@ struct pinmux *pinmux_get(struct device *dev, const char *name) ...@@ -706,16 +707,16 @@ struct pinmux *pinmux_get(struct device *dev, const char *name)
* mapping, this is what consumers will get when requesting * mapping, this is what consumers will get when requesting
* a pinmux handle with pinmux_get() * a pinmux handle with pinmux_get()
*/ */
pmx = kzalloc(sizeof(struct pinmux), GFP_KERNEL); p = kzalloc(sizeof(struct pinctrl), GFP_KERNEL);
if (pmx == NULL) if (p == NULL)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
mutex_init(&pmx->mutex); mutex_init(&p->mutex);
pmx->func_selector = UINT_MAX; p->func_selector = UINT_MAX;
INIT_LIST_HEAD(&pmx->groups); INIT_LIST_HEAD(&p->groups);
/* Iterate over the pinmux maps to locate the right ones */ /* Iterate over the pin control maps to locate the right ones */
for (i = 0; i < pinmux_maps_num; i++) { for (i = 0; i < pinctrl_maps_num; i++) {
map = &pinmux_maps[i]; map = &pinctrl_maps[i];
found_map = false; found_map = false;
/* /*
...@@ -763,11 +764,11 @@ struct pinmux *pinmux_get(struct device *dev, const char *name) ...@@ -763,11 +764,11 @@ struct pinmux *pinmux_get(struct device *dev, const char *name)
/* If this map is applicable, then apply it */ /* If this map is applicable, then apply it */
if (found_map) { if (found_map) {
ret = pinmux_enable_muxmap(pctldev, pmx, dev, ret = pinmux_enable_muxmap(pctldev, p, dev,
devname, map); devname, map);
if (ret) { if (ret) {
pinmux_free_groups(pmx); pinmux_free_groups(p);
kfree(pmx); kfree(p);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
num_maps++; num_maps++;
...@@ -780,7 +781,7 @@ struct pinmux *pinmux_get(struct device *dev, const char *name) ...@@ -780,7 +781,7 @@ struct pinmux *pinmux_get(struct device *dev, const char *name)
pr_err("could not find any mux maps for device %s, ID %s\n", pr_err("could not find any mux maps for device %s, ID %s\n",
devname ? devname : "(anonymous)", devname ? devname : "(anonymous)",
name ? name : "(undefined)"); name ? name : "(undefined)");
kfree(pmx); kfree(p);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
...@@ -790,96 +791,96 @@ struct pinmux *pinmux_get(struct device *dev, const char *name) ...@@ -790,96 +791,96 @@ struct pinmux *pinmux_get(struct device *dev, const char *name)
name ? name : "(undefined)"); name ? name : "(undefined)");
/* Add the pinmux to the global list */ /* Add the pinmux to the global list */
mutex_lock(&pinmux_list_mutex); mutex_lock(&pinctrl_list_mutex);
list_add(&pmx->node, &pinmux_list); list_add(&p->node, &pinctrl_list);
mutex_unlock(&pinmux_list_mutex); mutex_unlock(&pinctrl_list_mutex);
return pmx; return p;
} }
EXPORT_SYMBOL_GPL(pinmux_get); EXPORT_SYMBOL_GPL(pinctrl_get);
/** /**
* pinmux_put() - release a previously claimed pinmux * pinctrl_put() - release a previously claimed pin control handle
* @pmx: a pinmux previously claimed by pinmux_get() * @p: a pin control handle previously claimed by pinctrl_get()
*/ */
void pinmux_put(struct pinmux *pmx) void pinctrl_put(struct pinctrl *p)
{ {
if (pmx == NULL) if (p == NULL)
return; return;
mutex_lock(&pmx->mutex); mutex_lock(&p->mutex);
if (pmx->usecount) if (p->usecount)
pr_warn("releasing pinmux with active users!\n"); pr_warn("releasing pin control handle with active users!\n");
/* Free the groups and all acquired pins */ /* Free the groups and all acquired pins */
pinmux_free_groups(pmx); pinmux_free_groups(p);
mutex_unlock(&pmx->mutex); mutex_unlock(&p->mutex);
/* Remove from list */ /* Remove from list */
mutex_lock(&pinmux_list_mutex); mutex_lock(&pinctrl_list_mutex);
list_del(&pmx->node); list_del(&p->node);
mutex_unlock(&pinmux_list_mutex); mutex_unlock(&pinctrl_list_mutex);
kfree(pmx); kfree(p);
} }
EXPORT_SYMBOL_GPL(pinmux_put); EXPORT_SYMBOL_GPL(pinctrl_put);
/** /**
* pinmux_enable() - enable a certain pinmux setting * pinctrl_enable() - enable a certain pin controller setting
* @pmx: the pinmux to enable, previously claimed by pinmux_get() * @p: the pin control handle to enable, previously claimed by pinctrl_get()
*/ */
int pinmux_enable(struct pinmux *pmx) int pinctrl_enable(struct pinctrl *p)
{ {
int ret = 0; int ret = 0;
if (pmx == NULL) if (p == NULL)
return -EINVAL; return -EINVAL;
mutex_lock(&pmx->mutex); mutex_lock(&p->mutex);
if (pmx->usecount++ == 0) { if (p->usecount++ == 0) {
struct pinctrl_dev *pctldev = pmx->pctldev; struct pinctrl_dev *pctldev = p->pctldev;
const struct pinmux_ops *ops = pctldev->desc->pmxops; const struct pinmux_ops *ops = pctldev->desc->pmxops;
struct pinmux_group *grp; struct pinmux_group *grp;
list_for_each_entry(grp, &pmx->groups, node) { list_for_each_entry(grp, &p->groups, node) {
ret = ops->enable(pctldev, pmx->func_selector, ret = ops->enable(pctldev, p->func_selector,
grp->group_selector); grp->group_selector);
if (ret) { if (ret) {
/* /*
* TODO: call disable() on all groups we called * TODO: call disable() on all groups we called
* enable() on to this point? * enable() on to this point?
*/ */
pmx->usecount--; p->usecount--;
break; break;
} }
} }
} }
mutex_unlock(&pmx->mutex); mutex_unlock(&p->mutex);
return ret; return ret;
} }
EXPORT_SYMBOL_GPL(pinmux_enable); EXPORT_SYMBOL_GPL(pinctrl_enable);
/** /**
* pinmux_disable() - disable a certain pinmux setting * pinctrl_disable() - disable a certain pin control setting
* @pmx: the pinmux to disable, previously claimed by pinmux_get() * @p: the pin control handle to disable, previously claimed by pinctrl_get()
*/ */
void pinmux_disable(struct pinmux *pmx) void pinctrl_disable(struct pinctrl *p)
{ {
if (pmx == NULL) if (p == NULL)
return; return;
mutex_lock(&pmx->mutex); mutex_lock(&p->mutex);
if (--pmx->usecount == 0) { if (--p->usecount == 0) {
struct pinctrl_dev *pctldev = pmx->pctldev; struct pinctrl_dev *pctldev = p->pctldev;
const struct pinmux_ops *ops = pctldev->desc->pmxops; const struct pinmux_ops *ops = pctldev->desc->pmxops;
struct pinmux_group *grp; struct pinmux_group *grp;
list_for_each_entry(grp, &pmx->groups, node) { list_for_each_entry(grp, &p->groups, node) {
ops->disable(pctldev, pmx->func_selector, ops->disable(pctldev, p->func_selector,
grp->group_selector); grp->group_selector);
} }
} }
mutex_unlock(&pmx->mutex); mutex_unlock(&p->mutex);
} }
EXPORT_SYMBOL_GPL(pinmux_disable); EXPORT_SYMBOL_GPL(pinctrl_disable);
int pinmux_check_ops(struct pinctrl_dev *pctldev) int pinmux_check_ops(struct pinctrl_dev *pctldev)
{ {
...@@ -910,11 +911,11 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev) ...@@ -910,11 +911,11 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev)
} }
/* Hog a single map entry and add to the hoglist */ /* Hog a single map entry and add to the hoglist */
static int pinmux_hog_map(struct pinctrl_dev *pctldev, static int pinctrl_hog_map(struct pinctrl_dev *pctldev,
struct pinmux_map const *map) struct pinctrl_map const *map)
{ {
struct pinmux_hog *hog; struct pinctrl_hog *hog;
struct pinmux *pmx; struct pinctrl *p;
int ret; int ret;
if (map->dev_name) { if (map->dev_name) {
...@@ -929,61 +930,61 @@ static int pinmux_hog_map(struct pinctrl_dev *pctldev, ...@@ -929,61 +930,61 @@ static int pinmux_hog_map(struct pinctrl_dev *pctldev,
return -EINVAL; return -EINVAL;
} }
hog = kzalloc(sizeof(struct pinmux_hog), GFP_KERNEL); hog = kzalloc(sizeof(struct pinctrl_hog), GFP_KERNEL);
if (!hog) if (!hog)
return -ENOMEM; return -ENOMEM;
pmx = pinmux_get(NULL, map->name); p = pinctrl_get(NULL, map->name);
if (IS_ERR(pmx)) { if (IS_ERR(p)) {
kfree(hog); kfree(hog);
dev_err(pctldev->dev, dev_err(pctldev->dev,
"could not get the %s pinmux mapping for hogging\n", "could not get the %s pin control mapping for hogging\n",
map->name); map->name);
return PTR_ERR(pmx); return PTR_ERR(p);
} }
ret = pinmux_enable(pmx); ret = pinctrl_enable(p);
if (ret) { if (ret) {
pinmux_put(pmx); pinctrl_put(p);
kfree(hog); kfree(hog);
dev_err(pctldev->dev, dev_err(pctldev->dev,
"could not enable the %s pinmux mapping for hogging\n", "could not enable the %s pin control mapping for hogging\n",
map->name); map->name);
return ret; return ret;
} }
hog->map = map; hog->map = map;
hog->pmx = pmx; hog->p = p;
dev_info(pctldev->dev, "hogged map %s, function %s\n", map->name, dev_info(pctldev->dev, "hogged map %s, function %s\n", map->name,
map->function); map->function);
mutex_lock(&pctldev->pinmux_hogs_lock); mutex_lock(&pctldev->pinctrl_hogs_lock);
list_add(&hog->node, &pctldev->pinmux_hogs); list_add(&hog->node, &pctldev->pinctrl_hogs);
mutex_unlock(&pctldev->pinmux_hogs_lock); mutex_unlock(&pctldev->pinctrl_hogs_lock);
return 0; return 0;
} }
/** /**
* pinmux_hog_maps() - hog specific map entries on controller device * pinctrl_hog_maps() - hog specific map entries on controller device
* @pctldev: the pin control device to hog entries on * @pctldev: the pin control device to hog entries on
* *
* When the pin controllers are registered, there may be some specific pinmux * When the pin controllers are registered, there may be some specific pinmux
* map entries that need to be hogged, i.e. get+enabled until the system shuts * map entries that need to be hogged, i.e. get+enabled until the system shuts
* down. * down.
*/ */
int pinmux_hog_maps(struct pinctrl_dev *pctldev) int pinctrl_hog_maps(struct pinctrl_dev *pctldev)
{ {
struct device *dev = pctldev->dev; struct device *dev = pctldev->dev;
const char *devname = dev_name(dev); const char *devname = dev_name(dev);
int ret; int ret;
int i; int i;
INIT_LIST_HEAD(&pctldev->pinmux_hogs); INIT_LIST_HEAD(&pctldev->pinctrl_hogs);
mutex_init(&pctldev->pinmux_hogs_lock); mutex_init(&pctldev->pinctrl_hogs_lock);
for (i = 0; i < pinmux_maps_num; i++) { for (i = 0; i < pinctrl_maps_num; i++) {
struct pinmux_map const *map = &pinmux_maps[i]; struct pinctrl_map const *map = &pinctrl_maps[i];
if (!map->hog_on_boot) if (!map->hog_on_boot)
continue; continue;
...@@ -991,7 +992,7 @@ int pinmux_hog_maps(struct pinctrl_dev *pctldev) ...@@ -991,7 +992,7 @@ int pinmux_hog_maps(struct pinctrl_dev *pctldev)
if (map->ctrl_dev_name && if (map->ctrl_dev_name &&
!strcmp(map->ctrl_dev_name, devname)) { !strcmp(map->ctrl_dev_name, devname)) {
/* OK time to hog! */ /* OK time to hog! */
ret = pinmux_hog_map(pctldev, map); ret = pinctrl_hog_map(pctldev, map);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -1000,23 +1001,23 @@ int pinmux_hog_maps(struct pinctrl_dev *pctldev) ...@@ -1000,23 +1001,23 @@ int pinmux_hog_maps(struct pinctrl_dev *pctldev)
} }
/** /**
* pinmux_unhog_maps() - unhog specific map entries on controller device * pinctrl_unhog_maps() - unhog specific map entries on controller device
* @pctldev: the pin control device to unhog entries on * @pctldev: the pin control device to unhog entries on
*/ */
void pinmux_unhog_maps(struct pinctrl_dev *pctldev) void pinctrl_unhog_maps(struct pinctrl_dev *pctldev)
{ {
struct list_head *node, *tmp; struct list_head *node, *tmp;
mutex_lock(&pctldev->pinmux_hogs_lock); mutex_lock(&pctldev->pinctrl_hogs_lock);
list_for_each_safe(node, tmp, &pctldev->pinmux_hogs) { list_for_each_safe(node, tmp, &pctldev->pinctrl_hogs) {
struct pinmux_hog *hog = struct pinctrl_hog *hog =
list_entry(node, struct pinmux_hog, node); list_entry(node, struct pinctrl_hog, node);
pinmux_disable(hog->pmx); pinctrl_disable(hog->p);
pinmux_put(hog->pmx); pinctrl_put(hog->p);
list_del(node); list_del(node);
kfree(hog); kfree(hog);
} }
mutex_unlock(&pctldev->pinmux_hogs_lock); mutex_unlock(&pctldev->pinctrl_hogs_lock);
} }
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
...@@ -1085,11 +1086,11 @@ static int pinmux_pins_show(struct seq_file *s, void *what) ...@@ -1085,11 +1086,11 @@ static int pinmux_pins_show(struct seq_file *s, void *what)
static int pinmux_hogs_show(struct seq_file *s, void *what) static int pinmux_hogs_show(struct seq_file *s, void *what)
{ {
struct pinctrl_dev *pctldev = s->private; struct pinctrl_dev *pctldev = s->private;
struct pinmux_hog *hog; struct pinctrl_hog *hog;
seq_puts(s, "Pinmux map hogs held by device\n"); seq_puts(s, "Pin control map hogs held by device\n");
list_for_each_entry(hog, &pctldev->pinmux_hogs, node) list_for_each_entry(hog, &pctldev->pinctrl_hogs, node)
seq_printf(s, "%s\n", hog->map->name); seq_printf(s, "%s\n", hog->map->name);
return 0; return 0;
...@@ -1097,11 +1098,11 @@ static int pinmux_hogs_show(struct seq_file *s, void *what) ...@@ -1097,11 +1098,11 @@ static int pinmux_hogs_show(struct seq_file *s, void *what)
static int pinmux_show(struct seq_file *s, void *what) static int pinmux_show(struct seq_file *s, void *what)
{ {
struct pinmux *pmx; struct pinctrl *p;
seq_puts(s, "Requested pinmuxes and their maps:\n"); seq_puts(s, "Requested pinmuxes and their maps:\n");
list_for_each_entry(pmx, &pinmux_list, node) { list_for_each_entry(p, &pinctrl_list, node) {
struct pinctrl_dev *pctldev = pmx->pctldev; struct pinctrl_dev *pctldev = p->pctldev;
const struct pinmux_ops *pmxops; const struct pinmux_ops *pmxops;
const struct pinctrl_ops *pctlops; const struct pinctrl_ops *pctlops;
struct pinmux_group *grp; struct pinmux_group *grp;
...@@ -1115,13 +1116,13 @@ static int pinmux_show(struct seq_file *s, void *what) ...@@ -1115,13 +1116,13 @@ static int pinmux_show(struct seq_file *s, void *what)
pctlops = pctldev->desc->pctlops; pctlops = pctldev->desc->pctlops;
seq_printf(s, "device: %s function: %s (%u),", seq_printf(s, "device: %s function: %s (%u),",
pinctrl_dev_get_name(pmx->pctldev), pinctrl_dev_get_name(p->pctldev),
pmxops->get_function_name(pctldev, pmxops->get_function_name(pctldev,
pmx->func_selector), p->func_selector),
pmx->func_selector); p->func_selector);
seq_printf(s, " groups: ["); seq_printf(s, " groups: [");
list_for_each_entry(grp, &pmx->groups, node) { list_for_each_entry(grp, &p->groups, node) {
seq_printf(s, " %s (%u)", seq_printf(s, " %s (%u)",
pctlops->get_group_name(pctldev, pctlops->get_group_name(pctldev,
grp->group_selector), grp->group_selector),
...@@ -1130,21 +1131,21 @@ static int pinmux_show(struct seq_file *s, void *what) ...@@ -1130,21 +1131,21 @@ static int pinmux_show(struct seq_file *s, void *what)
seq_printf(s, " ]"); seq_printf(s, " ]");
seq_printf(s, " users: %u map-> %s\n", seq_printf(s, " users: %u map-> %s\n",
pmx->usecount, p->usecount,
pmx->dev ? dev_name(pmx->dev) : "(system)"); p->dev ? dev_name(p->dev) : "(system)");
} }
return 0; return 0;
} }
static int pinmux_maps_show(struct seq_file *s, void *what) static int pinctrl_maps_show(struct seq_file *s, void *what)
{ {
int i; int i;
seq_puts(s, "Pinmux maps:\n"); seq_puts(s, "Pinctrl maps:\n");
for (i = 0; i < pinmux_maps_num; i++) { for (i = 0; i < pinctrl_maps_num; i++) {
struct pinmux_map const *map = &pinmux_maps[i]; struct pinctrl_map const *map = &pinctrl_maps[i];
seq_printf(s, "%s:\n", map->name); seq_printf(s, "%s:\n", map->name);
if (map->dev_name) if (map->dev_name)
...@@ -1181,9 +1182,9 @@ static int pinmux_open(struct inode *inode, struct file *file) ...@@ -1181,9 +1182,9 @@ static int pinmux_open(struct inode *inode, struct file *file)
return single_open(file, pinmux_show, NULL); return single_open(file, pinmux_show, NULL);
} }
static int pinmux_maps_open(struct inode *inode, struct file *file) static int pinctrl_maps_open(struct inode *inode, struct file *file)
{ {
return single_open(file, pinmux_maps_show, NULL); return single_open(file, pinctrl_maps_show, NULL);
} }
static const struct file_operations pinmux_functions_ops = { static const struct file_operations pinmux_functions_ops = {
...@@ -1214,8 +1215,8 @@ static const struct file_operations pinmux_ops = { ...@@ -1214,8 +1215,8 @@ static const struct file_operations pinmux_ops = {
.release = single_release, .release = single_release,
}; };
static const struct file_operations pinmux_maps_ops = { static const struct file_operations pinctrl_maps_ops = {
.open = pinmux_maps_open, .open = pinctrl_maps_open,
.read = seq_read, .read = seq_read,
.llseek = seq_lseek, .llseek = seq_lseek,
.release = single_release, .release = single_release,
...@@ -1236,8 +1237,8 @@ void pinmux_init_debugfs(struct dentry *subsys_root) ...@@ -1236,8 +1237,8 @@ void pinmux_init_debugfs(struct dentry *subsys_root)
{ {
debugfs_create_file("pinmuxes", S_IFREG | S_IRUGO, debugfs_create_file("pinmuxes", S_IFREG | S_IRUGO,
subsys_root, NULL, &pinmux_ops); subsys_root, NULL, &pinmux_ops);
debugfs_create_file("pinmux-maps", S_IFREG | S_IRUGO, debugfs_create_file("pinctrl-maps", S_IFREG | S_IRUGO,
subsys_root, NULL, &pinmux_maps_ops); subsys_root, NULL, &pinctrl_maps_ops);
} }
#endif /* CONFIG_DEBUG_FS */ #endif /* CONFIG_DEBUG_FS */
...@@ -16,8 +16,8 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev); ...@@ -16,8 +16,8 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev);
void pinmux_init_device_debugfs(struct dentry *devroot, void pinmux_init_device_debugfs(struct dentry *devroot,
struct pinctrl_dev *pctldev); struct pinctrl_dev *pctldev);
void pinmux_init_debugfs(struct dentry *subsys_root); void pinmux_init_debugfs(struct dentry *subsys_root);
int pinmux_hog_maps(struct pinctrl_dev *pctldev); int pinctrl_hog_maps(struct pinctrl_dev *pctldev);
void pinmux_unhog_maps(struct pinctrl_dev *pctldev); void pinctrl_unhog_maps(struct pinctrl_dev *pctldev);
#else #else
...@@ -35,12 +35,12 @@ static inline void pinmux_init_debugfs(struct dentry *subsys_root) ...@@ -35,12 +35,12 @@ static inline void pinmux_init_debugfs(struct dentry *subsys_root)
{ {
} }
static inline int pinmux_hog_maps(struct pinctrl_dev *pctldev) static inline int pinctrl_hog_maps(struct pinctrl_dev *pctldev)
{ {
return 0; return 0;
} }
static inline void pinmux_unhog_maps(struct pinctrl_dev *pctldev) static inline void pinctrl_unhog_maps(struct pinctrl_dev *pctldev)
{ {
} }
......
...@@ -17,56 +17,56 @@ ...@@ -17,56 +17,56 @@
#include "pinctrl.h" #include "pinctrl.h"
/* This struct is private to the core and should be regarded as a cookie */ /* This struct is private to the core and should be regarded as a cookie */
struct pinmux; struct pinctrl;
#ifdef CONFIG_PINMUX #ifdef CONFIG_PINMUX
/* External interface to pinmux */ /* External interface to pinmux */
extern int pinmux_request_gpio(unsigned gpio); extern int pinctrl_request_gpio(unsigned gpio);
extern void pinmux_free_gpio(unsigned gpio); extern void pinctrl_free_gpio(unsigned gpio);
extern int pinmux_gpio_direction_input(unsigned gpio); extern int pinctrl_gpio_direction_input(unsigned gpio);
extern int pinmux_gpio_direction_output(unsigned gpio); extern int pinctrl_gpio_direction_output(unsigned gpio);
extern struct pinmux * __must_check pinmux_get(struct device *dev, const char *name); extern struct pinctrl * __must_check pinctrl_get(struct device *dev, const char *name);
extern void pinmux_put(struct pinmux *pmx); extern void pinctrl_put(struct pinctrl *p);
extern int pinmux_enable(struct pinmux *pmx); extern int pinctrl_enable(struct pinctrl *p);
extern void pinmux_disable(struct pinmux *pmx); extern void pinctrl_disable(struct pinctrl *p);
#else /* !CONFIG_PINMUX */ #else /* !CONFIG_PINMUX */
static inline int pinmux_request_gpio(unsigned gpio) static inline int pinctrl_request_gpio(unsigned gpio)
{ {
return 0; return 0;
} }
static inline void pinmux_free_gpio(unsigned gpio) static inline void pinctrl_free_gpio(unsigned gpio)
{ {
} }
static inline int pinmux_gpio_direction_input(unsigned gpio) static inline int pinctrl_gpio_direction_input(unsigned gpio)
{ {
return 0; return 0;
} }
static inline int pinmux_gpio_direction_output(unsigned gpio) static inline int pinctrl_gpio_direction_output(unsigned gpio)
{ {
return 0; return 0;
} }
static inline struct pinmux * __must_check pinmux_get(struct device *dev, const char *name) static inline struct pinctrl * __must_check pinctrl_get(struct device *dev, const char *name)
{ {
return NULL; return NULL;
} }
static inline void pinmux_put(struct pinmux *pmx) static inline void pinctrl_put(struct pinctrl *p)
{ {
} }
static inline int pinmux_enable(struct pinmux *pmx) static inline int pinctrl_enable(struct pinctrl *p)
{ {
return 0; return 0;
} }
static inline void pinmux_disable(struct pinmux *pmx) static inline void pinctrl_disable(struct pinctrl *p)
{ {
} }
......
...@@ -9,11 +9,11 @@ ...@@ -9,11 +9,11 @@
* *
* License terms: GNU General Public License (GPL) version 2 * License terms: GNU General Public License (GPL) version 2
*/ */
#ifndef __LINUX_PINMUX_MACHINE_H #ifndef __LINUX_PINCTRL_MACHINE_H
#define __LINUX_PINMUX_MACHINE_H #define __LINUX_PINCTRL_MACHINE_H
/** /**
* struct pinmux_map - boards/machines shall provide this map for devices * struct pinctrl_map - boards/machines shall provide this map for devices
* @name: the name of this specific map entry for the particular machine. * @name: the name of this specific map entry for the particular machine.
* This is the second parameter passed to pinmux_get() when you want * This is the second parameter passed to pinmux_get() when you want
* to have several mappings to the same device * to have several mappings to the same device
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
* a pinmux device supporting it is registered. These maps will not be * a pinmux device supporting it is registered. These maps will not be
* disabled and put until the system shuts down. * disabled and put until the system shuts down.
*/ */
struct pinmux_map { struct pinctrl_map {
const char *name; const char *name;
const char *ctrl_dev_name; const char *ctrl_dev_name;
const char *function; const char *function;
...@@ -47,41 +47,41 @@ struct pinmux_map { ...@@ -47,41 +47,41 @@ struct pinmux_map {
* Convenience macro to set a simple map from a certain pin controller and a * Convenience macro to set a simple map from a certain pin controller and a
* certain function to a named device * certain function to a named device
*/ */
#define PINMUX_MAP(a, b, c, d) \ #define PIN_MAP(a, b, c, d) \
{ .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d } { .name = a, .ctrl_dev_name = b, .function = c, .dev_name = d }
/* /*
* Convenience macro to map a system function onto a certain pinctrl device. * Convenience macro to map a system function onto a certain pinctrl device.
* System functions are not assigned to a particular device. * System functions are not assigned to a particular device.
*/ */
#define PINMUX_MAP_SYS(a, b, c) \ #define PIN_MAP_SYS(a, b, c) \
{ .name = a, .ctrl_dev_name = b, .function = c } { .name = a, .ctrl_dev_name = b, .function = c }
/* /*
* Convenience macro to map a system function onto a certain pinctrl device, * Convenience macro to map a system function onto a certain pinctrl device,
* to be hogged by the pinmux core until the system shuts down. * to be hogged by the pin control core until the system shuts down.
*/ */
#define PINMUX_MAP_SYS_HOG(a, b, c) \ #define PIN_MAP_SYS_HOG(a, b, c) \
{ .name = a, .ctrl_dev_name = b, .function = c, \ { .name = a, .ctrl_dev_name = b, .function = c, \
.hog_on_boot = true } .hog_on_boot = true }
/* /*
* Convenience macro to map a system function onto a certain pinctrl device * Convenience macro to map a system function onto a certain pinctrl device
* using a specified group, to be hogged by the pinmux core until the system * using a specified group, to be hogged by the pin control core until the
* shuts down. * system shuts down.
*/ */
#define PINMUX_MAP_SYS_HOG_GROUP(a, b, c, d) \ #define PIN_MAP_SYS_HOG_GROUP(a, b, c, d) \
{ .name = a, .ctrl_dev_name = b, .function = c, .group = d, \ { .name = a, .ctrl_dev_name = b, .function = c, .group = d, \
.hog_on_boot = true } .hog_on_boot = true }
#ifdef CONFIG_PINMUX #ifdef CONFIG_PINMUX
extern int pinmux_register_mappings(struct pinmux_map const *map, extern int pinctrl_register_mappings(struct pinctrl_map const *map,
unsigned num_maps); unsigned num_maps);
#else #else
static inline int pinmux_register_mappings(struct pinmux_map const *map, static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
unsigned num_maps) unsigned num_maps)
{ {
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment