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()
-and pinmux_free_gpio(). These two functions shall *ONLY* be called from
+The public pinmux API contains two functions named pinctrl_request_gpio()
+and pinctrl_free_gpio(). These two functions shall *ONLY* be called from
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]
gpiolib implementation.
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
-request proper muxing for its pins.
+controlled e.g. muxed in. Instead, implement a proper gpiolib driver and have
+that driver request proper muxing and other control for its pins.
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
In this case, the function array would become 64 entries for each GPIO
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
.gpio_disable_free().
will be passed along to this function.
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
special GPIO-handler is registered.
#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",
.function = "spi0",
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
it even more compact which assumes you want to use pinctrl-foo and position
0 for mapping, for example:
-static struct pinmux_map __initdata pmx_mapping[] = {
- PINMUX_MAP("I2CMAP", "pinctrl-foo", "i2c0", "foo-i2c.0"),
+static struct pinctrl_map __initdata mapping[] = {
+ PIN_MAP("I2CMAP", "pinctrl-foo", "i2c0", "foo-i2c.0"),
};
The result of grabbing this mapping from the device with something like
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
once. Since they share the same name, pin controller device, funcion and
Pinmux requests from drivers
============================
-Generally it is discouraged to let individual drivers get and enable pinmuxes.
-So if possible, handle the pinmuxes in platform code or some other place where
-you have access to all the affected struct device * pointers. In some cases
-where a driver needs to switch between different mux mappings at runtime
-this is not possible.
+Generally it is discouraged to let individual drivers get and enable pin
+control. So if possible, handle the pin control in platform code or some other
+place where you have access to all the affected struct device * pointers. In
+some cases where a driver needs to e.g. switch between different mux mappings
+at runtime this is not possible.
-A driver may request a certain mux to be activated, usually just the default
-mux like this:
+A driver may request a certain control state to be activated, usually just the
+default state like this:
#include <linux/pinctrl/consumer.h>
struct foo_state {
- struct pinmux *pmx;
+ struct pinctrl *p;
...
};
foo_probe()
{
/* Allocate a state holder named "state" etc */
- struct pinmux pmx;
+ struct pinctrl p;
- pmx = pinmux_get(&device, NULL);
- if IS_ERR(pmx)
- return PTR_ERR(pmx);
- pinmux_enable(pmx);
+ p = pinctrl_get(&device, NULL);
+ if IS_ERR(p)
+ return PTR_ERR(p);
+ pinctrl_enable(p);
- state->pmx = pmx;
+ state->p = p;
}
foo_remove()
{
- pinmux_disable(state->pmx);
- pinmux_put(state->pmx);
+ pinctrl_disable(state->p);
+ pinctrl_put(state->p);
}
-If you want to grab a specific mux mapping and not just the first one found for
-this device you can specify a specific mapping name, for example in the above
-example the second i2c0 setting: pinmux_get(&device, "spi0-pos-B");
+If you want to grab a specific control mapping and not just the first one
+found for this device you can specify a specific mapping name, for example in
+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
if you don't want each and every driver to handle it and you know the
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 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
when running a device driver. Usually it will just poke some values into a
register.
-- pinmux_disable() is called in process context to tear down the pin requests
- and release the state holder struct for the mux setting.
+- pinctrl_disable() is called in process context to tear down the pin requests
+ 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
-drivers bookkeeping operations, like checking available functions and the
-associated pins, whereas the enable/disable pass on to the pin controller
+Usually the pin control core handled the get/put pair and call out to the
+device drivers bookkeeping operations, like checking available functions and
+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
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.
-System pinmux hogging
-=====================
+System pin control hogging
+==========================
-A system pinmux map entry, i.e. a pinmux setting that does not have a device
-associated with it, can be hogged by the core when the pin controller is
-registered. This means that the core will attempt to call pinmux_get() and
-pinmux_enable() on it immediately after the pin control device has been
+A system pin control map entry, i.e. a pin control setting that does not have
+a device associated with it, can be hogged by the core when the pin controller
+is registered. This means that the core will attempt to call pinctrl_get() and
+pinctrl_enable() on it immediately after the pin control device has been
registered.
This is enabled by simply setting the .hog_on_boot field in the map to true,
mux settings on the primary pin controller, there is a convenience macro for
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.
foo_switch()
{
- struct pinmux *pmx;
+ struct pinctrl *p;
/* Enable on position A */
- pmx = pinmux_get(&device, "spi0-pos-A");
- if IS_ERR(pmx)
- return PTR_ERR(pmx);
- pinmux_enable(pmx);
+ p = pinctrl_get(&device, "spi0-pos-A");
+ if IS_ERR(p)
+ return PTR_ERR(p);
+ pinctrl_enable(p);
/* This releases the pins again */
- pinmux_disable(pmx);
- pinmux_put(pmx);
+ pinctrl_disable(p);
+ pinctrl_put(p);
/* Enable on position B */
- pmx = pinmux_get(&device, "spi0-pos-B");
- if IS_ERR(pmx)
- return PTR_ERR(pmx);
- pinmux_enable(pmx);
+ p = pinctrl_get(&device, "spi0-pos-B");
+ if IS_ERR(p)
+ return PTR_ERR(p);
+ pinctrl_enable(p);
...
}
/*
* 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
* Based on bits of regulator core, gpio core and clk core
*
#include <linux/pinctrl/pinmux.h>
#include "core.h"
-/* List of pinmuxes */
-static DEFINE_MUTEX(pinmux_list_mutex);
-static LIST_HEAD(pinmux_list);
+/* List of pin controller handles */
+static DEFINE_MUTEX(pinctrl_list_mutex);
+static LIST_HEAD(pinctrl_list);
-/* Global pinmux maps */
-static struct pinmux_map *pinmux_maps;
-static unsigned pinmux_maps_num;
+/* Global pinctrl maps */
+static struct pinctrl_map *pinctrl_maps;
+static unsigned pinctrl_maps_num;
/**
* struct pinmux_group - group list item for pinmux groups
};
/**
- * struct pinmux - per-device pinmux state holder
+ * struct pinctrl - per-device pin control state holder
* @node: global list node
- * @dev: the device using this pinmux
- * @usecount: the number of active users of this mux setting, used to keep
- * track of nested use cases
- * @pctldev: pin control device handling this pinmux
+ * @dev: the device using this pin control handle
+ * @usecount: the number of active users of this pin controller setting, used
+ * to keep track of nested use cases
+ * @pctldev: pin control device handling this pin control handle
* @func_selector: the function selector for the pinmux device handling
* this pinmux
* @groups: the group selectors for the pinmux device and
* get/put/enable/disable
* @mutex: a lock for the pinmux state holder
*/
-struct pinmux {
+struct pinctrl {
struct list_head node;
struct device *dev;
unsigned usecount;
};
/**
- * struct pinmux_hog - a list item to stash mux hogs
- * @node: pinmux hog list node
+ * struct pinctrl_hog - a list item to stash control hogs
+ * @node: pin control hog list node
* @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 pinmux_map const *map;
- struct pinmux *pmx;
+ struct pinctrl_map const *map;
+ struct pinctrl *p;
};
/**
}
/**
- * 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
*
* This function should *ONLY* be used from gpiolib-based GPIO drivers,
* as part of their gpio_request() semantics, platforms and individual drivers
* shall *NOT* request GPIO pins to be muxed in.
*/
-int pinmux_request_gpio(unsigned gpio)
+int pinctrl_request_gpio(unsigned gpio)
{
char gpiostr[16];
const char *function;
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
*
* This function should *ONLY* be used from gpiolib-based GPIO drivers,
* as part of their gpio_free() semantics, platforms and individual drivers
* 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_gpio_range *range;
func = pin_free(pctldev, pin, range);
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_gpio_range *range;
}
/**
- * 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
*
* This function should *ONLY* be used from gpiolib-based GPIO drivers,
* 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
*
* This function should *ONLY* be used from gpiolib-based GPIO drivers,
* 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
- * @maps: the pinmux mappings table to register, this should be marked with
+ * pinctrl_register_mappings() - register a set of pin controller mappings
+ * @maps: the pincontrol mappings table to register, this should be marked with
* __initdata so it can be discarded after boot, this function will
* perform a shallow copy for the mapping entries.
* @num_maps: the number of maps in the mapping table
* passed into this function will be owned by the pinmux core and cannot be
* freed.
*/
-int __init pinmux_register_mappings(struct pinmux_map const *maps,
- unsigned num_maps)
+int __init pinctrl_register_mappings(struct pinctrl_map const *maps,
+ unsigned num_maps)
{
void *tmp_maps;
int i;
* 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.
*/
- if (!pinmux_maps_num) {
+ if (!pinctrl_maps_num) {
/* On first call, just copy them */
tmp_maps = kmemdup(maps,
- sizeof(struct pinmux_map) * num_maps,
+ sizeof(struct pinctrl_map) * num_maps,
GFP_KERNEL);
if (!tmp_maps)
return -ENOMEM;
} else {
/* Subsequent calls, reallocate array to new size */
- size_t oldsize = sizeof(struct pinmux_map) * pinmux_maps_num;
- size_t newsize = sizeof(struct pinmux_map) * num_maps;
+ size_t oldsize = sizeof(struct pinctrl_map) * pinctrl_maps_num;
+ 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)
return -ENOMEM;
memcpy((tmp_maps + oldsize), maps, newsize);
}
- pinmux_maps = tmp_maps;
- pinmux_maps_num += num_maps;
+ pinctrl_maps = tmp_maps;
+ pinctrl_maps_num += num_maps;
return 0;
}
* negative otherwise
*/
static int pinmux_search_function(struct pinctrl_dev *pctldev,
- struct pinmux_map const *map,
+ struct pinctrl_map const *map,
unsigned *func_selector,
unsigned *group_selector)
{
* pinmux_enable_muxmap() - enable a map entry for a certain pinmux
*/
static int pinmux_enable_muxmap(struct pinctrl_dev *pctldev,
- struct pinmux *pmx,
+ struct pinctrl *p,
struct device *dev,
const char *devname,
- struct pinmux_map const *map)
+ struct pinctrl_map const *map)
{
unsigned func_selector;
unsigned group_selector;
* by anyone else.
*/
- if (pmx->pctldev && pmx->pctldev != pctldev) {
+ if (p->pctldev && p->pctldev != pctldev) {
dev_err(pctldev->dev,
"different pin control devices given for device %s, function %s\n",
devname, map->function);
return -EINVAL;
}
- pmx->dev = dev;
- pmx->pctldev = pctldev;
+ p->dev = dev;
+ p->pctldev = pctldev;
/* Now go into the driver and try to match a function and group */
ret = pinmux_search_function(pctldev, map, &func_selector,
* we support several groups with one function but not several
* functions with one or several groups in the same pinmux.
*/
- if (pmx->func_selector != UINT_MAX &&
- pmx->func_selector != func_selector) {
+ if (p->func_selector != UINT_MAX &&
+ p->func_selector != func_selector) {
dev_err(pctldev->dev,
"dual function defines in the map for device %s\n",
devname);
return -EINVAL;
}
- pmx->func_selector = func_selector;
+ p->func_selector = func_selector;
/* Now add this group selector, we may have many of them */
grp = kmalloc(sizeof(struct pinmux_group), GFP_KERNEL);
kfree(grp);
return ret;
}
- list_add(&grp->node, &pmx->groups);
+ list_add(&grp->node, &p->groups);
return 0;
}
-static void pinmux_free_groups(struct pinmux *pmx)
+static void pinmux_free_groups(struct pinctrl *p)
{
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 =
list_entry(node, struct pinmux_group, node);
/* Release all pins taken by this group */
- release_pins(pmx->pctldev, grp->group_selector);
+ release_pins(p->pctldev, grp->group_selector);
list_del(node);
kfree(grp);
}
}
/**
- * pinmux_get() - retrieves the pinmux for a certain device
- * @dev: the device to get the pinmux for
- * @name: an optional specific mux mapping name or NULL, the name is only
+ * pinctrl_get() - retrieves the pin controller handle for a certain device
+ * @dev: the device to get the pin controller handle for
+ * @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
- * 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;
const char *devname = NULL;
- struct pinmux *pmx;
+ struct pinctrl *p;
bool found_map;
unsigned num_maps = 0;
int ret = -ENODEV;
* mapping, this is what consumers will get when requesting
* a pinmux handle with pinmux_get()
*/
- pmx = kzalloc(sizeof(struct pinmux), GFP_KERNEL);
- if (pmx == NULL)
+ p = kzalloc(sizeof(struct pinctrl), GFP_KERNEL);
+ if (p == NULL)
return ERR_PTR(-ENOMEM);
- mutex_init(&pmx->mutex);
- pmx->func_selector = UINT_MAX;
- INIT_LIST_HEAD(&pmx->groups);
+ mutex_init(&p->mutex);
+ p->func_selector = UINT_MAX;
+ INIT_LIST_HEAD(&p->groups);
- /* Iterate over the pinmux maps to locate the right ones */
- for (i = 0; i < pinmux_maps_num; i++) {
- map = &pinmux_maps[i];
+ /* Iterate over the pin control maps to locate the right ones */
+ for (i = 0; i < pinctrl_maps_num; i++) {
+ map = &pinctrl_maps[i];
found_map = false;
/*
/* If this map is applicable, then apply it */
if (found_map) {
- ret = pinmux_enable_muxmap(pctldev, pmx, dev,
+ ret = pinmux_enable_muxmap(pctldev, p, dev,
devname, map);
if (ret) {
- pinmux_free_groups(pmx);
- kfree(pmx);
+ pinmux_free_groups(p);
+ kfree(p);
return ERR_PTR(ret);
}
num_maps++;
pr_err("could not find any mux maps for device %s, ID %s\n",
devname ? devname : "(anonymous)",
name ? name : "(undefined)");
- kfree(pmx);
+ kfree(p);
return ERR_PTR(-EINVAL);
}
name ? name : "(undefined)");
/* Add the pinmux to the global list */
- mutex_lock(&pinmux_list_mutex);
- list_add(&pmx->node, &pinmux_list);
- mutex_unlock(&pinmux_list_mutex);
+ mutex_lock(&pinctrl_list_mutex);
+ list_add(&p->node, &pinctrl_list);
+ 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
- * @pmx: a pinmux previously claimed by pinmux_get()
+ * pinctrl_put() - release a previously claimed pin control handle
+ * @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;
- mutex_lock(&pmx->mutex);
- if (pmx->usecount)
- pr_warn("releasing pinmux with active users!\n");
+ mutex_lock(&p->mutex);
+ if (p->usecount)
+ pr_warn("releasing pin control handle with active users!\n");
/* Free the groups and all acquired pins */
- pinmux_free_groups(pmx);
- mutex_unlock(&pmx->mutex);
+ pinmux_free_groups(p);
+ mutex_unlock(&p->mutex);
/* Remove from list */
- mutex_lock(&pinmux_list_mutex);
- list_del(&pmx->node);
- mutex_unlock(&pinmux_list_mutex);
+ mutex_lock(&pinctrl_list_mutex);
+ list_del(&p->node);
+ 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
- * @pmx: the pinmux to enable, previously claimed by pinmux_get()
+ * pinctrl_enable() - enable a certain pin controller setting
+ * @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;
- if (pmx == NULL)
+ if (p == NULL)
return -EINVAL;
- mutex_lock(&pmx->mutex);
- if (pmx->usecount++ == 0) {
- struct pinctrl_dev *pctldev = pmx->pctldev;
+ mutex_lock(&p->mutex);
+ if (p->usecount++ == 0) {
+ struct pinctrl_dev *pctldev = p->pctldev;
const struct pinmux_ops *ops = pctldev->desc->pmxops;
struct pinmux_group *grp;
- list_for_each_entry(grp, &pmx->groups, node) {
- ret = ops->enable(pctldev, pmx->func_selector,
+ list_for_each_entry(grp, &p->groups, node) {
+ ret = ops->enable(pctldev, p->func_selector,
grp->group_selector);
if (ret) {
/*
* TODO: call disable() on all groups we called
* enable() on to this point?
*/
- pmx->usecount--;
+ p->usecount--;
break;
}
}
}
- mutex_unlock(&pmx->mutex);
+ mutex_unlock(&p->mutex);
return ret;
}
-EXPORT_SYMBOL_GPL(pinmux_enable);
+EXPORT_SYMBOL_GPL(pinctrl_enable);
/**
- * pinmux_disable() - disable a certain pinmux setting
- * @pmx: the pinmux to disable, previously claimed by pinmux_get()
+ * pinctrl_disable() - disable a certain pin control setting
+ * @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;
- mutex_lock(&pmx->mutex);
- if (--pmx->usecount == 0) {
- struct pinctrl_dev *pctldev = pmx->pctldev;
+ mutex_lock(&p->mutex);
+ if (--p->usecount == 0) {
+ struct pinctrl_dev *pctldev = p->pctldev;
const struct pinmux_ops *ops = pctldev->desc->pmxops;
struct pinmux_group *grp;
- list_for_each_entry(grp, &pmx->groups, node) {
- ops->disable(pctldev, pmx->func_selector,
+ list_for_each_entry(grp, &p->groups, node) {
+ ops->disable(pctldev, p->func_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)
{
}
/* Hog a single map entry and add to the hoglist */
-static int pinmux_hog_map(struct pinctrl_dev *pctldev,
- struct pinmux_map const *map)
+static int pinctrl_hog_map(struct pinctrl_dev *pctldev,
+ struct pinctrl_map const *map)
{
- struct pinmux_hog *hog;
- struct pinmux *pmx;
+ struct pinctrl_hog *hog;
+ struct pinctrl *p;
int ret;
if (map->dev_name) {
return -EINVAL;
}
- hog = kzalloc(sizeof(struct pinmux_hog), GFP_KERNEL);
+ hog = kzalloc(sizeof(struct pinctrl_hog), GFP_KERNEL);
if (!hog)
return -ENOMEM;
- pmx = pinmux_get(NULL, map->name);
- if (IS_ERR(pmx)) {
+ p = pinctrl_get(NULL, map->name);
+ if (IS_ERR(p)) {
kfree(hog);
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);
- return PTR_ERR(pmx);
+ return PTR_ERR(p);
}
- ret = pinmux_enable(pmx);
+ ret = pinctrl_enable(p);
if (ret) {
- pinmux_put(pmx);
+ pinctrl_put(p);
kfree(hog);
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);
return ret;
}
hog->map = map;
- hog->pmx = pmx;
+ hog->p = p;
dev_info(pctldev->dev, "hogged map %s, function %s\n", map->name,
map->function);
- mutex_lock(&pctldev->pinmux_hogs_lock);
- list_add(&hog->node, &pctldev->pinmux_hogs);
- mutex_unlock(&pctldev->pinmux_hogs_lock);
+ mutex_lock(&pctldev->pinctrl_hogs_lock);
+ list_add(&hog->node, &pctldev->pinctrl_hogs);
+ mutex_unlock(&pctldev->pinctrl_hogs_lock);
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
*
* 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
* down.
*/
-int pinmux_hog_maps(struct pinctrl_dev *pctldev)
+int pinctrl_hog_maps(struct pinctrl_dev *pctldev)
{
struct device *dev = pctldev->dev;
const char *devname = dev_name(dev);
int ret;
int i;
- INIT_LIST_HEAD(&pctldev->pinmux_hogs);
- mutex_init(&pctldev->pinmux_hogs_lock);
+ INIT_LIST_HEAD(&pctldev->pinctrl_hogs);
+ mutex_init(&pctldev->pinctrl_hogs_lock);
- for (i = 0; i < pinmux_maps_num; i++) {
- struct pinmux_map const *map = &pinmux_maps[i];
+ for (i = 0; i < pinctrl_maps_num; i++) {
+ struct pinctrl_map const *map = &pinctrl_maps[i];
if (!map->hog_on_boot)
continue;
if (map->ctrl_dev_name &&
!strcmp(map->ctrl_dev_name, devname)) {
/* OK time to hog! */
- ret = pinmux_hog_map(pctldev, map);
+ ret = pinctrl_hog_map(pctldev, map);
if (ret)
return ret;
}
}
/**
- * 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
*/
-void pinmux_unhog_maps(struct pinctrl_dev *pctldev)
+void pinctrl_unhog_maps(struct pinctrl_dev *pctldev)
{
struct list_head *node, *tmp;
- mutex_lock(&pctldev->pinmux_hogs_lock);
- list_for_each_safe(node, tmp, &pctldev->pinmux_hogs) {
- struct pinmux_hog *hog =
- list_entry(node, struct pinmux_hog, node);
- pinmux_disable(hog->pmx);
- pinmux_put(hog->pmx);
+ mutex_lock(&pctldev->pinctrl_hogs_lock);
+ list_for_each_safe(node, tmp, &pctldev->pinctrl_hogs) {
+ struct pinctrl_hog *hog =
+ list_entry(node, struct pinctrl_hog, node);
+ pinctrl_disable(hog->p);
+ pinctrl_put(hog->p);
list_del(node);
kfree(hog);
}
- mutex_unlock(&pctldev->pinmux_hogs_lock);
+ mutex_unlock(&pctldev->pinctrl_hogs_lock);
}
#ifdef CONFIG_DEBUG_FS
static int pinmux_hogs_show(struct seq_file *s, void *what)
{
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);
return 0;
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");
- list_for_each_entry(pmx, &pinmux_list, node) {
- struct pinctrl_dev *pctldev = pmx->pctldev;
+ list_for_each_entry(p, &pinctrl_list, node) {
+ struct pinctrl_dev *pctldev = p->pctldev;
const struct pinmux_ops *pmxops;
const struct pinctrl_ops *pctlops;
struct pinmux_group *grp;
pctlops = pctldev->desc->pctlops;
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,
- pmx->func_selector),
- pmx->func_selector);
+ p->func_selector),
+ p->func_selector);
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)",
pctlops->get_group_name(pctldev,
grp->group_selector),
seq_printf(s, " ]");
seq_printf(s, " users: %u map-> %s\n",
- pmx->usecount,
- pmx->dev ? dev_name(pmx->dev) : "(system)");
+ p->usecount,
+ p->dev ? dev_name(p->dev) : "(system)");
}
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;
- seq_puts(s, "Pinmux maps:\n");
+ seq_puts(s, "Pinctrl maps:\n");
- for (i = 0; i < pinmux_maps_num; i++) {
- struct pinmux_map const *map = &pinmux_maps[i];
+ for (i = 0; i < pinctrl_maps_num; i++) {
+ struct pinctrl_map const *map = &pinctrl_maps[i];
seq_printf(s, "%s:\n", map->name);
if (map->dev_name)
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 = {
.release = single_release,
};
-static const struct file_operations pinmux_maps_ops = {
- .open = pinmux_maps_open,
+static const struct file_operations pinctrl_maps_ops = {
+ .open = pinctrl_maps_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
{
debugfs_create_file("pinmuxes", S_IFREG | S_IRUGO,
subsys_root, NULL, &pinmux_ops);
- debugfs_create_file("pinmux-maps", S_IFREG | S_IRUGO,
- subsys_root, NULL, &pinmux_maps_ops);
+ debugfs_create_file("pinctrl-maps", S_IFREG | S_IRUGO,
+ subsys_root, NULL, &pinctrl_maps_ops);
}
#endif /* CONFIG_DEBUG_FS */