Commit 7afeca1a authored by Arnd Bergmann's avatar Arnd Bergmann

Merge branch 'spear/pinctrl' into next/pinctrl

* spear/pinctrl:
  pinctrl: (cosmetic) fix two entries in DocBook comments
  pinctrl: add more info to error msgs in pin_request
  CLKDEV: provide helpers for common clock framework
  pinctrl: add pinctrl-mxs support
  pinctrl: pinctrl-imx: add imx6q pinctrl driver
  pinctrl: pinctrl-imx: add imx pinctrl core driver
  dt: add of_get_child_count helper function
  pinctrl: support gpio request deferred probing
  pinctrl: add pinctrl_provide_dummies interface for platforms to use
  pinctrl: enhance reporting of errors when loading from DT
  pinctrl: add kerneldoc for pinctrl_ops device tree functions
  pinctrl: propagate map validation errors
  pinctrl: fix dangling comment
  pinctrl: fix signed vs unsigned conditionals inside pinmux_map_to_setting
  ARM: 7392/1: CLKDEV: Optimize clk_find()
  ARM: 7376/1: clkdev: Implement managed clk_get()

This just adds more dependencies that are required in order not to
break the spear pinctrl support.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parents 4a0dfe69 366695ff
* Freescale IOMUX Controller (IOMUXC) for i.MX
The IOMUX Controller (IOMUXC), together with the IOMUX, enables the IC
to share one PAD to several functional blocks. The sharing is done by
multiplexing the PAD input/output signals. For each PAD there are up to
8 muxing options (called ALT modes). Since different modules require
different PAD settings (like pull up, keeper, etc) the IOMUXC controls
also the PAD settings parameters.
Please refer to pinctrl-bindings.txt in this directory for details of the
common pinctrl bindings used by client devices, including the meaning of the
phrase "pin configuration node".
Freescale IMX pin configuration node is a node of a group of pins which can be
used for a specific device or function. This node represents both mux and config
of the pins in that group. The 'mux' selects the function mode(also named mux
mode) this pin can work on and the 'config' configures various pad settings
such as pull-up, open drain, drive strength, etc.
Required properties for iomux controller:
- compatible: "fsl,<soc>-iomuxc"
Please refer to each fsl,<soc>-pinctrl.txt binding doc for supported SoCs.
Required properties for pin configuration node:
- fsl,pins: two integers array, represents a group of pins mux and config
setting. The format is fsl,pins = <PIN_FUNC_ID CONFIG>, PIN_FUNC_ID is a
pin working on a specific function, CONFIG is the pad setting value like
pull-up on this pin. Please refer to fsl,<soc>-pinctrl.txt for the valid
pins and functions of each SoC.
Bits used for CONFIG:
NO_PAD_CTL(1 << 31): indicate this pin does not need config.
SION(1 << 30): Software Input On Field.
Force the selected mux mode input path no matter of MUX_MODE functionality.
By default the input path is determined by functionality of the selected
mux mode (regular).
Other bits are used for PAD setting.
Please refer to each fsl,<soc>-pinctrl,txt binding doc for SoC specific part
of bits definitions.
NOTE:
Some requirements for using fsl,imx-pinctrl binding:
1. We have pin function node defined under iomux controller node to represent
what pinmux functions this SoC supports.
2. The pin configuration node intends to work on a specific function should
to be defined under that specific function node.
The function node's name should represent well about what function
this group of pins in this pin configuration node are working on.
3. The driver can use the function node's name and pin configuration node's
name describe the pin function and group hierarchy.
For example, Linux IMX pinctrl driver takes the function node's name
as the function name and pin configuration node's name as group name to
create the map table.
4. Each pin configuration node should have a phandle, devices can set pins
configurations by referring to the phandle of that pin configuration node.
Examples:
usdhc@0219c000 { /* uSDHC4 */
fsl,card-wired;
vmmc-supply = <&reg_3p3v>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc4_1>;
};
iomuxc@020e0000 {
compatible = "fsl,imx6q-iomuxc";
reg = <0x020e0000 0x4000>;
/* shared pinctrl settings */
usdhc4 {
pinctrl_usdhc4_1: usdhc4grp-1 {
fsl,pins = <1386 0x17059 /* MX6Q_PAD_SD4_CMD__USDHC4_CMD */
1392 0x10059 /* MX6Q_PAD_SD4_CLK__USDHC4_CLK */
1462 0x17059 /* MX6Q_PAD_SD4_DAT0__USDHC4_DAT0 */
1470 0x17059 /* MX6Q_PAD_SD4_DAT1__USDHC4_DAT1 */
1478 0x17059 /* MX6Q_PAD_SD4_DAT2__USDHC4_DAT2 */
1486 0x17059 /* MX6Q_PAD_SD4_DAT3__USDHC4_DAT3 */
1493 0x17059 /* MX6Q_PAD_SD4_DAT4__USDHC4_DAT4 */
1501 0x17059 /* MX6Q_PAD_SD4_DAT5__USDHC4_DAT5 */
1509 0x17059 /* MX6Q_PAD_SD4_DAT6__USDHC4_DAT6 */
1517 0x17059>; /* MX6Q_PAD_SD4_DAT7__USDHC4_DAT7 */
};
};
....
};
Refer to the IOMUXC controller chapter in imx6q datasheet,
0x17059 means enable hysteresis, 47KOhm Pull Up, 50Mhz speed,
80Ohm driver strength and Fast Slew Rate.
User should refer to each SoC spec to set the correct value.
TODO: when dtc macro support is available, we can change above raw data
to dt macro which can get better readability in dts file.
This diff is collapsed.
...@@ -277,6 +277,10 @@ REGULATOR ...@@ -277,6 +277,10 @@ REGULATOR
devm_regulator_put() devm_regulator_put()
devm_regulator_bulk_get() devm_regulator_bulk_get()
CLOCK
devm_clk_get()
devm_clk_put()
PINCTRL PINCTRL
devm_pinctrl_get() devm_pinctrl_get()
devm_pinctrl_put() devm_pinctrl_put()
...@@ -35,7 +35,12 @@ static DEFINE_MUTEX(clocks_mutex); ...@@ -35,7 +35,12 @@ static DEFINE_MUTEX(clocks_mutex);
static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) static struct clk_lookup *clk_find(const char *dev_id, const char *con_id)
{ {
struct clk_lookup *p, *cl = NULL; struct clk_lookup *p, *cl = NULL;
int match, best = 0; int match, best_found = 0, best_possible = 0;
if (dev_id)
best_possible += 2;
if (con_id)
best_possible += 1;
list_for_each_entry(p, &clocks, node) { list_for_each_entry(p, &clocks, node) {
match = 0; match = 0;
...@@ -50,10 +55,10 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id) ...@@ -50,10 +55,10 @@ static struct clk_lookup *clk_find(const char *dev_id, const char *con_id)
match += 1; match += 1;
} }
if (match > best) { if (match > best_found) {
cl = p; cl = p;
if (match != 3) if (match != best_possible)
best = match; best_found = match;
else else
break; break;
} }
...@@ -89,6 +94,51 @@ void clk_put(struct clk *clk) ...@@ -89,6 +94,51 @@ void clk_put(struct clk *clk)
} }
EXPORT_SYMBOL(clk_put); EXPORT_SYMBOL(clk_put);
static void devm_clk_release(struct device *dev, void *res)
{
clk_put(*(struct clk **)res);
}
struct clk *devm_clk_get(struct device *dev, const char *id)
{
struct clk **ptr, *clk;
ptr = devres_alloc(devm_clk_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return ERR_PTR(-ENOMEM);
clk = clk_get(dev, id);
if (!IS_ERR(clk)) {
*ptr = clk;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return clk;
}
EXPORT_SYMBOL(devm_clk_get);
static int devm_clk_match(struct device *dev, void *res, void *data)
{
struct clk **c = res;
if (!c || !*c) {
WARN_ON(!c || !*c);
return 0;
}
return *c == data;
}
void devm_clk_put(struct device *dev, struct clk *clk)
{
int ret;
ret = devres_destroy(dev, devm_clk_release, devm_clk_match, clk);
WARN_ON(ret);
}
EXPORT_SYMBOL(devm_clk_put);
void clkdev_add(struct clk_lookup *cl) void clkdev_add(struct clk_lookup *cl)
{ {
mutex_lock(&clocks_mutex); mutex_lock(&clocks_mutex);
...@@ -116,8 +166,9 @@ struct clk_lookup_alloc { ...@@ -116,8 +166,9 @@ struct clk_lookup_alloc {
char con_id[MAX_CON_ID]; char con_id[MAX_CON_ID];
}; };
struct clk_lookup * __init_refok static struct clk_lookup * __init_refok
clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...) vclkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt,
va_list ap)
{ {
struct clk_lookup_alloc *cla; struct clk_lookup_alloc *cla;
...@@ -132,16 +183,25 @@ clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...) ...@@ -132,16 +183,25 @@ clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
} }
if (dev_fmt) { if (dev_fmt) {
va_list ap;
va_start(ap, dev_fmt);
vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap); vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
cla->cl.dev_id = cla->dev_id; cla->cl.dev_id = cla->dev_id;
va_end(ap);
} }
return &cla->cl; return &cla->cl;
} }
struct clk_lookup * __init_refok
clkdev_alloc(struct clk *clk, const char *con_id, const char *dev_fmt, ...)
{
struct clk_lookup *cl;
va_list ap;
va_start(ap, dev_fmt);
cl = vclkdev_alloc(clk, con_id, dev_fmt, ap);
va_end(ap);
return cl;
}
EXPORT_SYMBOL(clkdev_alloc); EXPORT_SYMBOL(clkdev_alloc);
int clk_add_alias(const char *alias, const char *alias_dev_name, char *id, int clk_add_alias(const char *alias, const char *alias_dev_name, char *id,
...@@ -173,3 +233,65 @@ void clkdev_drop(struct clk_lookup *cl) ...@@ -173,3 +233,65 @@ void clkdev_drop(struct clk_lookup *cl)
kfree(cl); kfree(cl);
} }
EXPORT_SYMBOL(clkdev_drop); EXPORT_SYMBOL(clkdev_drop);
/**
* clk_register_clkdev - register one clock lookup for a struct clk
* @clk: struct clk to associate with all clk_lookups
* @con_id: connection ID string on device
* @dev_id: format string describing device name
*
* con_id or dev_id may be NULL as a wildcard, just as in the rest of
* clkdev.
*
* To make things easier for mass registration, we detect error clks
* from a previous clk_register() call, and return the error code for
* those. This is to permit this function to be called immediately
* after clk_register().
*/
int clk_register_clkdev(struct clk *clk, const char *con_id,
const char *dev_fmt, ...)
{
struct clk_lookup *cl;
va_list ap;
if (IS_ERR(clk))
return PTR_ERR(clk);
va_start(ap, dev_fmt);
cl = vclkdev_alloc(clk, con_id, dev_fmt, ap);
va_end(ap);
if (!cl)
return -ENOMEM;
clkdev_add(cl);
return 0;
}
/**
* clk_register_clkdevs - register a set of clk_lookup for a struct clk
* @clk: struct clk to associate with all clk_lookups
* @cl: array of clk_lookup structures with con_id and dev_id pre-initialized
* @num: number of clk_lookup structures to register
*
* To make things easier for mass registration, we detect error clks
* from a previous clk_register() call, and return the error code for
* those. This is to permit this function to be called immediately
* after clk_register().
*/
int clk_register_clkdevs(struct clk *clk, struct clk_lookup *cl, size_t num)
{
unsigned i;
if (IS_ERR(clk))
return PTR_ERR(clk);
for (i = 0; i < num; i++, cl++) {
cl->clk = clk;
clkdev_add(cl);
}
return 0;
}
EXPORT_SYMBOL(clk_register_clkdevs);
...@@ -26,6 +26,19 @@ config DEBUG_PINCTRL ...@@ -26,6 +26,19 @@ config DEBUG_PINCTRL
help help
Say Y here to add some extra checks and diagnostics to PINCTRL calls. Say Y here to add some extra checks and diagnostics to PINCTRL calls.
config PINCTRL_IMX
bool
select PINMUX
select PINCONF
config PINCTRL_IMX6Q
bool "IMX6Q pinctrl driver"
depends on OF
depends on SOC_IMX6Q
select PINCTRL_IMX
help
Say Y here to enable the imx6q pinctrl driver
config PINCTRL_PXA3xx config PINCTRL_PXA3xx
bool bool
select PINMUX select PINMUX
...@@ -36,6 +49,21 @@ config PINCTRL_MMP2 ...@@ -36,6 +49,21 @@ config PINCTRL_MMP2
select PINCTRL_PXA3xx select PINCTRL_PXA3xx
select PINCONF select PINCONF
config PINCTRL_MXS
bool
config PINCTRL_IMX23
bool
select PINMUX
select PINCONF
select PINCTRL_MXS
config PINCTRL_IMX28
bool
select PINMUX
select PINCONF
select PINCTRL_MXS
config PINCTRL_PXA168 config PINCTRL_PXA168
bool "PXA168 pin controller driver" bool "PXA168 pin controller driver"
depends on ARCH_MMP depends on ARCH_MMP
......
...@@ -9,8 +9,13 @@ ifeq ($(CONFIG_OF),y) ...@@ -9,8 +9,13 @@ ifeq ($(CONFIG_OF),y)
obj-$(CONFIG_PINCTRL) += devicetree.o obj-$(CONFIG_PINCTRL) += devicetree.o
endif endif
obj-$(CONFIG_GENERIC_PINCONF) += pinconf-generic.o obj-$(CONFIG_GENERIC_PINCONF) += pinconf-generic.o
obj-$(CONFIG_PINCTRL_IMX) += pinctrl-imx.o
obj-$(CONFIG_PINCTRL_IMX6Q) += pinctrl-imx6q.o
obj-$(CONFIG_PINCTRL_PXA3xx) += pinctrl-pxa3xx.o obj-$(CONFIG_PINCTRL_PXA3xx) += pinctrl-pxa3xx.o
obj-$(CONFIG_PINCTRL_MMP2) += pinctrl-mmp2.o obj-$(CONFIG_PINCTRL_MMP2) += pinctrl-mmp2.o
obj-$(CONFIG_PINCTRL_MXS) += pinctrl-mxs.o
obj-$(CONFIG_PINCTRL_IMX23) += pinctrl-imx23.o
obj-$(CONFIG_PINCTRL_IMX28) += pinctrl-imx28.o
obj-$(CONFIG_PINCTRL_PXA168) += pinctrl-pxa168.o obj-$(CONFIG_PINCTRL_PXA168) += pinctrl-pxa168.o
obj-$(CONFIG_PINCTRL_PXA910) += pinctrl-pxa910.o obj-$(CONFIG_PINCTRL_PXA910) += pinctrl-pxa910.o
obj-$(CONFIG_PINCTRL_SIRF) += pinctrl-sirf.o obj-$(CONFIG_PINCTRL_SIRF) += pinctrl-sirf.o
......
...@@ -43,6 +43,8 @@ struct pinctrl_maps { ...@@ -43,6 +43,8 @@ struct pinctrl_maps {
unsigned num_maps; unsigned num_maps;
}; };
static bool pinctrl_dummy_state;
/* Mutex taken by all entry points */ /* Mutex taken by all entry points */
DEFINE_MUTEX(pinctrl_mutex); DEFINE_MUTEX(pinctrl_mutex);
...@@ -61,6 +63,19 @@ static LIST_HEAD(pinctrl_maps); ...@@ -61,6 +63,19 @@ static LIST_HEAD(pinctrl_maps);
_i_ < _maps_node_->num_maps; \ _i_ < _maps_node_->num_maps; \
i++, _map_ = &_maps_node_->maps[_i_]) i++, _map_ = &_maps_node_->maps[_i_])
/**
* pinctrl_provide_dummies() - indicate if pinctrl provides dummy state support
*
* Usually this function is called by platforms without pinctrl driver support
* but run with some shared drivers using pinctrl APIs.
* After calling this function, the pinctrl core will return successfully
* with creating a dummy state for the driver to keep going smoothly.
*/
void pinctrl_provide_dummies(void)
{
pinctrl_dummy_state = true;
}
const char *pinctrl_dev_get_name(struct pinctrl_dev *pctldev) const char *pinctrl_dev_get_name(struct pinctrl_dev *pctldev)
{ {
/* We're not allowed to register devices without name */ /* We're not allowed to register devices without name */
...@@ -276,7 +291,8 @@ pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, unsigned gpio) ...@@ -276,7 +291,8 @@ pinctrl_match_gpio_range(struct pinctrl_dev *pctldev, unsigned gpio)
* *
* Find the pin controller handling a certain GPIO pin from the pinspace of * Find the pin controller handling a certain GPIO pin from the pinspace of
* the GPIO subsystem, return the device and the matching GPIO range. Returns * the GPIO subsystem, return the device and the matching GPIO range. Returns
* negative if the GPIO range could not be found in any device. * -EPROBE_DEFER if the GPIO range could not be found in any device since it
* may still have not been registered.
*/ */
static int pinctrl_get_device_gpio_range(unsigned gpio, static int pinctrl_get_device_gpio_range(unsigned gpio,
struct pinctrl_dev **outdev, struct pinctrl_dev **outdev,
...@@ -296,7 +312,7 @@ static int pinctrl_get_device_gpio_range(unsigned gpio, ...@@ -296,7 +312,7 @@ static int pinctrl_get_device_gpio_range(unsigned gpio,
} }
} }
return -EINVAL; return -EPROBE_DEFER;
} }
/** /**
...@@ -382,7 +398,7 @@ int pinctrl_request_gpio(unsigned gpio) ...@@ -382,7 +398,7 @@ int pinctrl_request_gpio(unsigned gpio)
ret = pinctrl_get_device_gpio_range(gpio, &pctldev, &range); ret = pinctrl_get_device_gpio_range(gpio, &pctldev, &range);
if (ret) { if (ret) {
mutex_unlock(&pinctrl_mutex); mutex_unlock(&pinctrl_mutex);
return -EINVAL; return ret;
} }
/* Convert to the pin controllers number space */ /* Convert to the pin controllers number space */
...@@ -719,8 +735,18 @@ static struct pinctrl_state *pinctrl_lookup_state_locked(struct pinctrl *p, ...@@ -719,8 +735,18 @@ static struct pinctrl_state *pinctrl_lookup_state_locked(struct pinctrl *p,
struct pinctrl_state *state; struct pinctrl_state *state;
state = find_state(p, name); state = find_state(p, name);
if (!state) if (!state) {
return ERR_PTR(-ENODEV); if (pinctrl_dummy_state) {
/* create dummy state */
dev_dbg(p->dev, "using pinctrl dummy state (%s)\n",
name);
state = create_state(p, name);
if (IS_ERR(state))
return state;
} else {
return ERR_PTR(-ENODEV);
}
}
return state; return state;
} }
...@@ -911,13 +937,13 @@ int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps, ...@@ -911,13 +937,13 @@ int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps,
case PIN_MAP_TYPE_MUX_GROUP: case PIN_MAP_TYPE_MUX_GROUP:
ret = pinmux_validate_map(&maps[i], i); ret = pinmux_validate_map(&maps[i], i);
if (ret < 0) if (ret < 0)
return 0; return ret;
break; break;
case PIN_MAP_TYPE_CONFIGS_PIN: case PIN_MAP_TYPE_CONFIGS_PIN:
case PIN_MAP_TYPE_CONFIGS_GROUP: case PIN_MAP_TYPE_CONFIGS_GROUP:
ret = pinconf_validate_map(&maps[i], i); ret = pinconf_validate_map(&maps[i], i);
if (ret < 0) if (ret < 0)
return 0; return ret;
break; break;
default: default:
pr_err("failed to register map %s (%d): invalid type given\n", pr_err("failed to register map %s (%d): invalid type given\n",
...@@ -1391,37 +1417,29 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, ...@@ -1391,37 +1417,29 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
/* check core ops for sanity */ /* check core ops for sanity */
ret = pinctrl_check_ops(pctldev); ret = pinctrl_check_ops(pctldev);
if (ret) { if (ret) {
pr_err("%s pinctrl ops lacks necessary functions\n", dev_err(dev, "pinctrl ops lacks necessary functions\n");
pctldesc->name);
goto out_err; goto out_err;
} }
/* If we're implementing pinmuxing, check the ops for sanity */ /* If we're implementing pinmuxing, check the ops for sanity */
if (pctldesc->pmxops) { if (pctldesc->pmxops) {
ret = pinmux_check_ops(pctldev); ret = pinmux_check_ops(pctldev);
if (ret) { if (ret)
pr_err("%s pinmux ops lacks necessary functions\n",
pctldesc->name);
goto out_err; goto out_err;
}
} }
/* If we're implementing pinconfig, check the ops for sanity */ /* If we're implementing pinconfig, check the ops for sanity */
if (pctldesc->confops) { if (pctldesc->confops) {
ret = pinconf_check_ops(pctldev); ret = pinconf_check_ops(pctldev);
if (ret) { if (ret)
pr_err("%s pin config ops lacks necessary functions\n",
pctldesc->name);
goto out_err; goto out_err;
}
} }
/* Register all the pins */ /* Register all the pins */
pr_debug("try to register %d pins on %s...\n", dev_dbg(dev, "try to register %d pins ...\n", pctldesc->npins);
pctldesc->npins, pctldesc->name);
ret = pinctrl_register_pins(pctldev, pctldesc->pins, pctldesc->npins); ret = pinctrl_register_pins(pctldev, pctldesc->pins, pctldesc->npins);
if (ret) { if (ret) {
pr_err("error during pin registration\n"); dev_err(dev, "error during pin registration\n");
pinctrl_free_pindescs(pctldev, pctldesc->pins, pinctrl_free_pindescs(pctldev, pctldesc->pins,
pctldesc->npins); pctldesc->npins);
goto out_err; goto out_err;
...@@ -1436,8 +1454,15 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc, ...@@ -1436,8 +1454,15 @@ struct pinctrl_dev *pinctrl_register(struct pinctrl_desc *pctldesc,
struct pinctrl_state *s = struct pinctrl_state *s =
pinctrl_lookup_state_locked(pctldev->p, pinctrl_lookup_state_locked(pctldev->p,
PINCTRL_STATE_DEFAULT); PINCTRL_STATE_DEFAULT);
if (!IS_ERR(s)) if (IS_ERR(s)) {
pinctrl_select_state_locked(pctldev->p, s); dev_dbg(dev, "failed to lookup the default state\n");
} else {
ret = pinctrl_select_state_locked(pctldev->p, s);
if (ret) {
dev_err(dev,
"failed to select default state\n");
}
}
} }
mutex_unlock(&pinctrl_mutex); mutex_unlock(&pinctrl_mutex);
......
...@@ -28,11 +28,17 @@ int pinconf_check_ops(struct pinctrl_dev *pctldev) ...@@ -28,11 +28,17 @@ int pinconf_check_ops(struct pinctrl_dev *pctldev)
const struct pinconf_ops *ops = pctldev->desc->confops; const struct pinconf_ops *ops = pctldev->desc->confops;
/* We must be able to read out pin status */ /* We must be able to read out pin status */
if (!ops->pin_config_get && !ops->pin_config_group_get) if (!ops->pin_config_get && !ops->pin_config_group_get) {
dev_err(pctldev->dev,
"pinconf must be able to read out pin status\n");
return -EINVAL; return -EINVAL;
}
/* We have to be able to config the pins in SOME way */ /* We have to be able to config the pins in SOME way */
if (!ops->pin_config_set && !ops->pin_config_group_set) if (!ops->pin_config_set && !ops->pin_config_group_set) {
dev_err(pctldev->dev,
"pinconf has to be able to set a pins config\n");
return -EINVAL; return -EINVAL;
}
return 0; return 0;
} }
......
This diff is collapsed.
/*
* IMX pinmux core definitions
*
* Copyright (C) 2012 Freescale Semiconductor, Inc.
* Copyright (C) 2012 Linaro Ltd.
*
* Author: Dong Aisheng <dong.aisheng@linaro.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#ifndef __DRIVERS_PINCTRL_IMX_H
#define __DRIVERS_PINCTRL_IMX_H
struct platform_device;
/**
* struct imx_pin_group - describes an IMX pin group
* @name: the name of this specific pin group
* @pins: an array of discrete physical pins used in this group, taken
* from the driver-local pin enumeration space
* @npins: the number of pins in this group array, i.e. the number of
* elements in .pins so we can iterate over that array
* @mux_mode: the mux mode for each pin in this group. The size of this
* array is the same as pins.
* @configs: the config for each pin in this group. The size of this
* array is the same as pins.
*/
struct imx_pin_group {
const char *name;
unsigned int *pins;
unsigned npins;
unsigned int *mux_mode;
unsigned long *configs;
};
/**
* struct imx_pmx_func - describes IMX pinmux functions
* @name: the name of this specific function
* @groups: corresponding pin groups
* @num_groups: the number of groups
*/
struct imx_pmx_func {
const char *name;
const char **groups;
unsigned num_groups;
};
/**
* struct imx_pin_reg - describe a pin reg map
* The last 3 members are used for select input setting
* @pid: pin id
* @mux_reg: mux register offset
* @conf_reg: config register offset
* @mux_mode: mux mode
* @input_reg: select input register offset for this mux if any
* 0 if no select input setting needed.
* @input_val: the value set to select input register
*/
struct imx_pin_reg {
u16 pid;
u16 mux_reg;
u16 conf_reg;
u8 mux_mode;
u16 input_reg;
u8 input_val;
};
struct imx_pinctrl_soc_info {
struct device *dev;
const struct pinctrl_pin_desc *pins;
unsigned int npins;
const struct imx_pin_reg *pin_regs;
unsigned int npin_regs;
struct imx_pin_group *groups;
unsigned int ngroups;
struct imx_pmx_func *functions;
unsigned int nfunctions;
};
#define NO_MUX 0x0
#define NO_PAD 0x0
#define IMX_PIN_REG(id, conf, mux, mode, input, val) \
{ \
.pid = id, \
.conf_reg = conf, \
.mux_reg = mux, \
.mux_mode = mode, \
.input_reg = input, \
.input_val = val, \
}
#define IMX_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin)
#define PAD_CTL_MASK(len) ((1 << len) - 1)
#define IMX_MUX_MASK 0x7
#define IOMUXC_CONFIG_SION (0x1 << 4)
int imx_pinctrl_probe(struct platform_device *pdev,
struct imx_pinctrl_soc_info *info);
int imx_pinctrl_remove(struct platform_device *pdev);
#endif /* __DRIVERS_PINCTRL_IMX_H */
/*
* Copyright 2012 Freescale Semiconductor, Inc.
*
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
* Version 2 or later at the following locations:
*
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/pinctrl/pinctrl.h>
#include "pinctrl-mxs.h"
enum imx23_pin_enum {
GPMI_D00 = PINID(0, 0),
GPMI_D01 = PINID(0, 1),
GPMI_D02 = PINID(0, 2),
GPMI_D03 = PINID(0, 3),
GPMI_D04 = PINID(0, 4),
GPMI_D05 = PINID(0, 5),
GPMI_D06 = PINID(0, 6),
GPMI_D07 = PINID(0, 7),
GPMI_D08 = PINID(0, 8),
GPMI_D09 = PINID(0, 9),
GPMI_D10 = PINID(0, 10),
GPMI_D11 = PINID(0, 11),
GPMI_D12 = PINID(0, 12),
GPMI_D13 = PINID(0, 13),
GPMI_D14 = PINID(0, 14),
GPMI_D15 = PINID(0, 15),
GPMI_CLE = PINID(0, 16),
GPMI_ALE = PINID(0, 17),
GPMI_CE2N = PINID(0, 18),
GPMI_RDY0 = PINID(0, 19),
GPMI_RDY1 = PINID(0, 20),
GPMI_RDY2 = PINID(0, 21),
GPMI_RDY3 = PINID(0, 22),
GPMI_WPN = PINID(0, 23),
GPMI_WRN = PINID(0, 24),
GPMI_RDN = PINID(0, 25),
AUART1_CTS = PINID(0, 26),
AUART1_RTS = PINID(0, 27),
AUART1_RX = PINID(0, 28),
AUART1_TX = PINID(0, 29),
I2C_SCL = PINID(0, 30),
I2C_SDA = PINID(0, 31),
LCD_D00 = PINID(1, 0),
LCD_D01 = PINID(1, 1),
LCD_D02 = PINID(1, 2),
LCD_D03 = PINID(1, 3),
LCD_D04 = PINID(1, 4),
LCD_D05 = PINID(1, 5),
LCD_D06 = PINID(1, 6),
LCD_D07 = PINID(1, 7),
LCD_D08 = PINID(1, 8),
LCD_D09 = PINID(1, 9),
LCD_D10 = PINID(1, 10),
LCD_D11 = PINID(1, 11),
LCD_D12 = PINID(1, 12),
LCD_D13 = PINID(1, 13),
LCD_D14 = PINID(1, 14),
LCD_D15 = PINID(1, 15),
LCD_D16 = PINID(1, 16),
LCD_D17 = PINID(1, 17),
LCD_RESET = PINID(1, 18),
LCD_RS = PINID(1, 19),
LCD_WR = PINID(1, 20),
LCD_CS = PINID(1, 21),
LCD_DOTCK = PINID(1, 22),
LCD_ENABLE = PINID(1, 23),
LCD_HSYNC = PINID(1, 24),
LCD_VSYNC = PINID(1, 25),
PWM0 = PINID(1, 26),
PWM1 = PINID(1, 27),
PWM2 = PINID(1, 28),
PWM3 = PINID(1, 29),
PWM4 = PINID(1, 30),
SSP1_CMD = PINID(2, 0),
SSP1_DETECT = PINID(2, 1),
SSP1_DATA0 = PINID(2, 2),
SSP1_DATA1 = PINID(2, 3),
SSP1_DATA2 = PINID(2, 4),
SSP1_DATA3 = PINID(2, 5),
SSP1_SCK = PINID(2, 6),
ROTARYA = PINID(2, 7),
ROTARYB = PINID(2, 8),
EMI_A00 = PINID(2, 9),
EMI_A01 = PINID(2, 10),
EMI_A02 = PINID(2, 11),
EMI_A03 = PINID(2, 12),
EMI_A04 = PINID(2, 13),
EMI_A05 = PINID(2, 14),
EMI_A06 = PINID(2, 15),
EMI_A07 = PINID(2, 16),
EMI_A08 = PINID(2, 17),
EMI_A09 = PINID(2, 18),
EMI_A10 = PINID(2, 19),
EMI_A11 = PINID(2, 20),
EMI_A12 = PINID(2, 21),
EMI_BA0 = PINID(2, 22),
EMI_BA1 = PINID(2, 23),
EMI_CASN = PINID(2, 24),
EMI_CE0N = PINID(2, 25),
EMI_CE1N = PINID(2, 26),
GPMI_CE1N = PINID(2, 27),
GPMI_CE0N = PINID(2, 28),
EMI_CKE = PINID(2, 29),
EMI_RASN = PINID(2, 30),
EMI_WEN = PINID(2, 31),
EMI_D00 = PINID(3, 0),
EMI_D01 = PINID(3, 1),
EMI_D02 = PINID(3, 2),
EMI_D03 = PINID(3, 3),
EMI_D04 = PINID(3, 4),
EMI_D05 = PINID(3, 5),
EMI_D06 = PINID(3, 6),
EMI_D07 = PINID(3, 7),
EMI_D08 = PINID(3, 8),
EMI_D09 = PINID(3, 9),
EMI_D10 = PINID(3, 10),
EMI_D11 = PINID(3, 11),
EMI_D12 = PINID(3, 12),
EMI_D13 = PINID(3, 13),
EMI_D14 = PINID(3, 14),
EMI_D15 = PINID(3, 15),
EMI_DQM0 = PINID(3, 16),
EMI_DQM1 = PINID(3, 17),
EMI_DQS0 = PINID(3, 18),
EMI_DQS1 = PINID(3, 19),
EMI_CLK = PINID(3, 20),
EMI_CLKN = PINID(3, 21),
};
static const struct pinctrl_pin_desc imx23_pins[] = {
MXS_PINCTRL_PIN(GPMI_D00),
MXS_PINCTRL_PIN(GPMI_D01),
MXS_PINCTRL_PIN(GPMI_D02),
MXS_PINCTRL_PIN(GPMI_D03),
MXS_PINCTRL_PIN(GPMI_D04),
MXS_PINCTRL_PIN(GPMI_D05),
MXS_PINCTRL_PIN(GPMI_D06),
MXS_PINCTRL_PIN(GPMI_D07),
MXS_PINCTRL_PIN(GPMI_D08),
MXS_PINCTRL_PIN(GPMI_D09),
MXS_PINCTRL_PIN(GPMI_D10),
MXS_PINCTRL_PIN(GPMI_D11),
MXS_PINCTRL_PIN(GPMI_D12),
MXS_PINCTRL_PIN(GPMI_D13),
MXS_PINCTRL_PIN(GPMI_D14),
MXS_PINCTRL_PIN(GPMI_D15),
MXS_PINCTRL_PIN(GPMI_CLE),
MXS_PINCTRL_PIN(GPMI_ALE),
MXS_PINCTRL_PIN(GPMI_CE2N),
MXS_PINCTRL_PIN(GPMI_RDY0),
MXS_PINCTRL_PIN(GPMI_RDY1),
MXS_PINCTRL_PIN(GPMI_RDY2),
MXS_PINCTRL_PIN(GPMI_RDY3),
MXS_PINCTRL_PIN(GPMI_WPN),
MXS_PINCTRL_PIN(GPMI_WRN),
MXS_PINCTRL_PIN(GPMI_RDN),
MXS_PINCTRL_PIN(AUART1_CTS),
MXS_PINCTRL_PIN(AUART1_RTS),
MXS_PINCTRL_PIN(AUART1_RX),
MXS_PINCTRL_PIN(AUART1_TX),
MXS_PINCTRL_PIN(I2C_SCL),
MXS_PINCTRL_PIN(I2C_SDA),
MXS_PINCTRL_PIN(LCD_D00),
MXS_PINCTRL_PIN(LCD_D01),
MXS_PINCTRL_PIN(LCD_D02),
MXS_PINCTRL_PIN(LCD_D03),
MXS_PINCTRL_PIN(LCD_D04),
MXS_PINCTRL_PIN(LCD_D05),
MXS_PINCTRL_PIN(LCD_D06),
MXS_PINCTRL_PIN(LCD_D07),
MXS_PINCTRL_PIN(LCD_D08),
MXS_PINCTRL_PIN(LCD_D09),
MXS_PINCTRL_PIN(LCD_D10),
MXS_PINCTRL_PIN(LCD_D11),
MXS_PINCTRL_PIN(LCD_D12),
MXS_PINCTRL_PIN(LCD_D13),
MXS_PINCTRL_PIN(LCD_D14),
MXS_PINCTRL_PIN(LCD_D15),
MXS_PINCTRL_PIN(LCD_D16),
MXS_PINCTRL_PIN(LCD_D17),
MXS_PINCTRL_PIN(LCD_RESET),
MXS_PINCTRL_PIN(LCD_RS),
MXS_PINCTRL_PIN(LCD_WR),
MXS_PINCTRL_PIN(LCD_CS),
MXS_PINCTRL_PIN(LCD_DOTCK),
MXS_PINCTRL_PIN(LCD_ENABLE),
MXS_PINCTRL_PIN(LCD_HSYNC),
MXS_PINCTRL_PIN(LCD_VSYNC),
MXS_PINCTRL_PIN(PWM0),
MXS_PINCTRL_PIN(PWM1),
MXS_PINCTRL_PIN(PWM2),
MXS_PINCTRL_PIN(PWM3),
MXS_PINCTRL_PIN(PWM4),
MXS_PINCTRL_PIN(SSP1_CMD),
MXS_PINCTRL_PIN(SSP1_DETECT),
MXS_PINCTRL_PIN(SSP1_DATA0),
MXS_PINCTRL_PIN(SSP1_DATA1),
MXS_PINCTRL_PIN(SSP1_DATA2),
MXS_PINCTRL_PIN(SSP1_DATA3),
MXS_PINCTRL_PIN(SSP1_SCK),
MXS_PINCTRL_PIN(ROTARYA),
MXS_PINCTRL_PIN(ROTARYB),
MXS_PINCTRL_PIN(EMI_A00),
MXS_PINCTRL_PIN(EMI_A01),
MXS_PINCTRL_PIN(EMI_A02),
MXS_PINCTRL_PIN(EMI_A03),
MXS_PINCTRL_PIN(EMI_A04),
MXS_PINCTRL_PIN(EMI_A05),
MXS_PINCTRL_PIN(EMI_A06),
MXS_PINCTRL_PIN(EMI_A07),
MXS_PINCTRL_PIN(EMI_A08),
MXS_PINCTRL_PIN(EMI_A09),
MXS_PINCTRL_PIN(EMI_A10),
MXS_PINCTRL_PIN(EMI_A11),
MXS_PINCTRL_PIN(EMI_A12),
MXS_PINCTRL_PIN(EMI_BA0),
MXS_PINCTRL_PIN(EMI_BA1),
MXS_PINCTRL_PIN(EMI_CASN),
MXS_PINCTRL_PIN(EMI_CE0N),
MXS_PINCTRL_PIN(EMI_CE1N),
MXS_PINCTRL_PIN(GPMI_CE1N),
MXS_PINCTRL_PIN(GPMI_CE0N),
MXS_PINCTRL_PIN(EMI_CKE),
MXS_PINCTRL_PIN(EMI_RASN),
MXS_PINCTRL_PIN(EMI_WEN),
MXS_PINCTRL_PIN(EMI_D00),
MXS_PINCTRL_PIN(EMI_D01),
MXS_PINCTRL_PIN(EMI_D02),
MXS_PINCTRL_PIN(EMI_D03),
MXS_PINCTRL_PIN(EMI_D04),
MXS_PINCTRL_PIN(EMI_D05),
MXS_PINCTRL_PIN(EMI_D06),
MXS_PINCTRL_PIN(EMI_D07),
MXS_PINCTRL_PIN(EMI_D08),
MXS_PINCTRL_PIN(EMI_D09),
MXS_PINCTRL_PIN(EMI_D10),
MXS_PINCTRL_PIN(EMI_D11),
MXS_PINCTRL_PIN(EMI_D12),
MXS_PINCTRL_PIN(EMI_D13),
MXS_PINCTRL_PIN(EMI_D14),
MXS_PINCTRL_PIN(EMI_D15),
MXS_PINCTRL_PIN(EMI_DQM0),
MXS_PINCTRL_PIN(EMI_DQM1),
MXS_PINCTRL_PIN(EMI_DQS0),
MXS_PINCTRL_PIN(EMI_DQS1),
MXS_PINCTRL_PIN(EMI_CLK),
MXS_PINCTRL_PIN(EMI_CLKN),
};
static struct mxs_regs imx23_regs = {
.muxsel = 0x100,
.drive = 0x200,
.pull = 0x400,
};
static struct mxs_pinctrl_soc_data imx23_pinctrl_data = {
.regs = &imx23_regs,
.pins = imx23_pins,
.npins = ARRAY_SIZE(imx23_pins),
};
static int __devinit imx23_pinctrl_probe(struct platform_device *pdev)
{
return mxs_pinctrl_probe(pdev, &imx23_pinctrl_data);
}
static struct of_device_id imx23_pinctrl_of_match[] __devinitdata = {
{ .compatible = "fsl,imx23-pinctrl", },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, imx23_pinctrl_of_match);
static struct platform_driver imx23_pinctrl_driver = {
.driver = {
.name = "imx23-pinctrl",
.owner = THIS_MODULE,
.of_match_table = imx23_pinctrl_of_match,
},
.probe = imx23_pinctrl_probe,
.remove = __devexit_p(mxs_pinctrl_remove),
};
static int __init imx23_pinctrl_init(void)
{
return platform_driver_register(&imx23_pinctrl_driver);
}
arch_initcall(imx23_pinctrl_init);
static void __exit imx23_pinctrl_exit(void)
{
platform_driver_unregister(&imx23_pinctrl_driver);
}
module_exit(imx23_pinctrl_exit);
MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>");
MODULE_DESCRIPTION("Freescale i.MX23 pinctrl driver");
MODULE_LICENSE("GPL v2");
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* Copyright 2012 Freescale Semiconductor, Inc.
*
* The code contained herein is licensed under the GNU General Public
* License. You may obtain a copy of the GNU General Public License
* Version 2 or later at the following locations:
*
* http://www.opensource.org/licenses/gpl-license.html
* http://www.gnu.org/copyleft/gpl.html
*/
#ifndef __PINCTRL_MXS_H
#define __PINCTRL_MXS_H
#include <linux/platform_device.h>
#include <linux/pinctrl/pinctrl.h>
#define SET 0x4
#define CLR 0x8
#define TOG 0xc
#define MXS_PINCTRL_PIN(pin) PINCTRL_PIN(pin, #pin)
#define PINID(bank, pin) ((bank) * 32 + (pin))
/*
* pinmux-id bit field definitions
*
* bank: 15..12 (4)
* pin: 11..4 (8)
* muxsel: 3..0 (4)
*/
#define MUXID_TO_PINID(m) PINID((m) >> 12 & 0xf, (m) >> 4 & 0xff)
#define MUXID_TO_MUXSEL(m) ((m) & 0xf)
#define PINID_TO_BANK(p) ((p) >> 5)
#define PINID_TO_PIN(p) ((p) % 32)
/*
* pin config bit field definitions
*
* pull-up: 6..5 (2)
* voltage: 4..3 (2)
* mA: 2..0 (3)
*
* MSB of each field is presence bit for the config.
*/
#define PULL_PRESENT (1 << 6)
#define PULL_SHIFT 5
#define VOL_PRESENT (1 << 4)
#define VOL_SHIFT 3
#define MA_PRESENT (1 << 2)
#define MA_SHIFT 0
#define CONFIG_TO_PULL(c) ((c) >> PULL_SHIFT & 0x1)
#define CONFIG_TO_VOL(c) ((c) >> VOL_SHIFT & 0x1)
#define CONFIG_TO_MA(c) ((c) >> MA_SHIFT & 0x3)
struct mxs_function {
const char *name;
const char **groups;
unsigned ngroups;
};
struct mxs_group {
const char *name;
unsigned int *pins;
unsigned npins;
u8 *muxsel;
u8 config;
};
struct mxs_regs {
u16 muxsel;
u16 drive;
u16 pull;
};
struct mxs_pinctrl_soc_data {
const struct mxs_regs *regs;
const struct pinctrl_pin_desc *pins;
unsigned npins;
struct mxs_function *functions;
unsigned nfunctions;
struct mxs_group *groups;
unsigned ngroups;
};
int mxs_pinctrl_probe(struct platform_device *pdev,
struct mxs_pinctrl_soc_data *soc);
int mxs_pinctrl_remove(struct platform_device *pdev);
#endif /* __PINCTRL_MXS_H */
...@@ -42,9 +42,10 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev) ...@@ -42,9 +42,10 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev)
!ops->get_function_name || !ops->get_function_name ||
!ops->get_function_groups || !ops->get_function_groups ||
!ops->enable || !ops->enable ||
!ops->disable) !ops->disable) {
dev_err(pctldev->dev, "pinmux ops lacks necessary functions\n");
return -EINVAL; return -EINVAL;
}
/* Check that all functions registered have names */ /* Check that all functions registered have names */
nfuncs = ops->get_functions_count(pctldev); nfuncs = ops->get_functions_count(pctldev);
while (selector < nfuncs) { while (selector < nfuncs) {
...@@ -91,7 +92,8 @@ static int pin_request(struct pinctrl_dev *pctldev, ...@@ -91,7 +92,8 @@ static int pin_request(struct pinctrl_dev *pctldev,
desc = pin_desc_get(pctldev, pin); desc = pin_desc_get(pctldev, pin);
if (desc == NULL) { if (desc == NULL) {
dev_err(pctldev->dev, dev_err(pctldev->dev,
"pin is not registered so it cannot be requested\n"); "pin %d is not registered so it cannot be requested\n",
pin);
goto out; goto out;
} }
...@@ -102,7 +104,8 @@ static int pin_request(struct pinctrl_dev *pctldev, ...@@ -102,7 +104,8 @@ static int pin_request(struct pinctrl_dev *pctldev,
/* There's no need to support multiple GPIO requests */ /* There's no need to support multiple GPIO requests */
if (desc->gpio_owner) { if (desc->gpio_owner) {
dev_err(pctldev->dev, dev_err(pctldev->dev,
"pin already requested\n"); "pin %s already requested by %s; cannot claim for %s\n",
desc->name, desc->gpio_owner, owner);
goto out; goto out;
} }
...@@ -110,7 +113,8 @@ static int pin_request(struct pinctrl_dev *pctldev, ...@@ -110,7 +113,8 @@ static int pin_request(struct pinctrl_dev *pctldev,
} else { } else {
if (desc->mux_usecount && strcmp(desc->mux_owner, owner)) { if (desc->mux_usecount && strcmp(desc->mux_owner, owner)) {
dev_err(pctldev->dev, dev_err(pctldev->dev,
"pin already requested\n"); "pin %s already requested by %s; cannot claim for %s\n",
desc->name, desc->mux_owner, owner);
goto out; goto out;
} }
...@@ -143,8 +147,7 @@ static int pin_request(struct pinctrl_dev *pctldev, ...@@ -143,8 +147,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
status = 0; status = 0;
if (status) { if (status) {
dev_err(pctldev->dev, "->request on device %s failed for pin %d\n", dev_err(pctldev->dev, "request() failed for pin %d\n", pin);
pctldev->desc->name, pin);
module_put(pctldev->owner); module_put(pctldev->owner);
} }
...@@ -161,7 +164,7 @@ static int pin_request(struct pinctrl_dev *pctldev, ...@@ -161,7 +164,7 @@ static int pin_request(struct pinctrl_dev *pctldev,
out: out:
if (status) if (status)
dev_err(pctldev->dev, "pin-%d (%s) status %d\n", dev_err(pctldev->dev, "pin-%d (%s) status %d\n",
pin, owner, status); pin, owner, status);
return status; return status;
} }
...@@ -329,18 +332,27 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, ...@@ -329,18 +332,27 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
return -EINVAL; return -EINVAL;
} }
setting->data.mux.func = ret = pinmux_func_name_to_selector(pctldev, map->data.mux.function);
pinmux_func_name_to_selector(pctldev, map->data.mux.function); if (ret < 0) {
if (setting->data.mux.func < 0) dev_err(pctldev->dev, "invalid function %s in map table\n",
return setting->data.mux.func; map->data.mux.function);
return ret;
}
setting->data.mux.func = ret;
ret = pmxops->get_function_groups(pctldev, setting->data.mux.func, ret = pmxops->get_function_groups(pctldev, setting->data.mux.func,
&groups, &num_groups); &groups, &num_groups);
if (ret < 0) if (ret < 0) {
dev_err(pctldev->dev, "can't query groups for function %s\n",
map->data.mux.function);
return ret; return ret;
if (!num_groups) }
if (!num_groups) {
dev_err(pctldev->dev,
"function %s can't be selected on any group\n",
map->data.mux.function);
return -EINVAL; return -EINVAL;
}
if (map->data.mux.group) { if (map->data.mux.group) {
bool found = false; bool found = false;
group = map->data.mux.group; group = map->data.mux.group;
...@@ -350,15 +362,23 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, ...@@ -350,15 +362,23 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
break; break;
} }
} }
if (!found) if (!found) {
dev_err(pctldev->dev,
"invalid group \"%s\" for function \"%s\"\n",
group, map->data.mux.function);
return -EINVAL; return -EINVAL;
}
} else { } else {
group = groups[0]; group = groups[0];
} }
setting->data.mux.group = pinctrl_get_group_selector(pctldev, group); ret = pinctrl_get_group_selector(pctldev, group);
if (setting->data.mux.group < 0) if (ret < 0) {
return setting->data.mux.group; dev_err(pctldev->dev, "invalid group %s in map table\n",
map->data.mux.group);
return ret;
}
setting->data.mux.group = ret;
ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins, ret = pctlops->get_group_pins(pctldev, setting->data.mux.group, &pins,
&num_pins); &num_pins);
...@@ -374,7 +394,7 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, ...@@ -374,7 +394,7 @@ int pinmux_map_to_setting(struct pinctrl_map const *map,
ret = pin_request(pctldev, pins[i], map->dev_name, NULL); ret = pin_request(pctldev, pins[i], map->dev_name, NULL);
if (ret) { if (ret) {
dev_err(pctldev->dev, dev_err(pctldev->dev,
"could not get request pin %d on device %s\n", "could not request pin %d on device %s\n",
pins[i], pinctrl_dev_get_name(pctldev)); pins[i], pinctrl_dev_get_name(pctldev));
/* On error release all taken pins */ /* On error release all taken pins */
i--; /* this pin just failed */ i--; /* this pin just failed */
......
...@@ -100,6 +100,26 @@ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb); ...@@ -100,6 +100,26 @@ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb);
*/ */
struct clk *clk_get(struct device *dev, const char *id); struct clk *clk_get(struct device *dev, const char *id);
/**
* devm_clk_get - lookup and obtain a managed reference to a clock producer.
* @dev: device for clock "consumer"
* @id: clock comsumer ID
*
* Returns a struct clk corresponding to the clock producer, or
* valid IS_ERR() condition containing errno. The implementation
* uses @dev and @id to determine the clock consumer, and thereby
* the clock producer. (IOW, @id may be identical strings, but
* clk_get may return different clock producers depending on @dev.)
*
* Drivers must assume that the clock source is not enabled.
*
* devm_clk_get should not be called from within interrupt context.
*
* The clock will automatically be freed when the device is unbound
* from the bus.
*/
struct clk *devm_clk_get(struct device *dev, const char *id);
/** /**
* clk_prepare - prepare a clock source * clk_prepare - prepare a clock source
* @clk: clock source * @clk: clock source
...@@ -206,6 +226,18 @@ unsigned long clk_get_rate(struct clk *clk); ...@@ -206,6 +226,18 @@ unsigned long clk_get_rate(struct clk *clk);
*/ */
void clk_put(struct clk *clk); void clk_put(struct clk *clk);
/**
* devm_clk_put - "free" a managed clock source
* @dev: device used to acuqire the clock
* @clk: clock source acquired with devm_clk_get()
*
* Note: drivers must ensure that all clk_enable calls made on this
* clock source are balanced by clk_disable calls prior to calling
* this function.
*
* clk_put should not be called from within interrupt context.
*/
void devm_clk_put(struct device *dev, struct clk *clk);
/* /*
* The remaining APIs are optional for machine class support. * The remaining APIs are optional for machine class support.
......
...@@ -40,4 +40,7 @@ void clkdev_drop(struct clk_lookup *cl); ...@@ -40,4 +40,7 @@ void clkdev_drop(struct clk_lookup *cl);
void clkdev_add_table(struct clk_lookup *, size_t); void clkdev_add_table(struct clk_lookup *, size_t);
int clk_add_alias(const char *, const char *, char *, struct device *); int clk_add_alias(const char *, const char *, char *, struct device *);
int clk_register_clkdev(struct clk *, const char *, const char *, ...);
int clk_register_clkdevs(struct clk *, struct clk_lookup *, size_t);
#endif #endif
...@@ -193,6 +193,17 @@ extern struct device_node *of_get_next_child(const struct device_node *node, ...@@ -193,6 +193,17 @@ extern struct device_node *of_get_next_child(const struct device_node *node,
for (child = of_get_next_child(parent, NULL); child != NULL; \ for (child = of_get_next_child(parent, NULL); child != NULL; \
child = of_get_next_child(parent, child)) child = of_get_next_child(parent, child))
static inline int of_get_child_count(const struct device_node *np)
{
struct device_node *child;
int num = 0;
for_each_child_of_node(np, child)
num++;
return num;
}
extern struct device_node *of_find_node_with_property( extern struct device_node *of_find_node_with_property(
struct device_node *from, const char *prop_name); struct device_node *from, const char *prop_name);
#define for_each_node_with_property(dn, prop_name) \ #define for_each_node_with_property(dn, prop_name) \
...@@ -300,6 +311,11 @@ static inline bool of_have_populated_dt(void) ...@@ -300,6 +311,11 @@ static inline bool of_have_populated_dt(void)
#define for_each_child_of_node(parent, child) \ #define for_each_child_of_node(parent, child) \
while (0) while (0)
static inline int of_get_child_count(const struct device_node *np)
{
return 0;
}
static inline int of_device_is_compatible(const struct device_node *device, static inline int of_device_is_compatible(const struct device_node *device,
const char *name) const char *name)
{ {
......
...@@ -154,7 +154,7 @@ struct pinctrl_map { ...@@ -154,7 +154,7 @@ struct pinctrl_map {
extern int pinctrl_register_mappings(struct pinctrl_map const *map, extern int pinctrl_register_mappings(struct pinctrl_map const *map,
unsigned num_maps); unsigned num_maps);
extern void pinctrl_provide_dummies(void);
#else #else
static inline int pinctrl_register_mappings(struct pinctrl_map const *map, static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
...@@ -163,5 +163,8 @@ static inline int pinctrl_register_mappings(struct pinctrl_map const *map, ...@@ -163,5 +163,8 @@ static inline int pinctrl_register_mappings(struct pinctrl_map const *map,
return 0; return 0;
} }
#endif /* !CONFIG_PINMUX */ static inline void pinctrl_provide_dummies(void)
{
}
#endif /* !CONFIG_PINCTRL */
#endif #endif
...@@ -25,7 +25,6 @@ struct seq_file; ...@@ -25,7 +25,6 @@ struct seq_file;
* @pin_config_get: get the config of a certain pin, if the requested config * @pin_config_get: get the config of a certain pin, if the requested config
* is not available on this controller this should return -ENOTSUPP * is not available on this controller this should return -ENOTSUPP
* and if it is available but disabled it should return -EINVAL * and if it is available but disabled it should return -EINVAL
* @pin_config_get: get the config of a certain pin
* @pin_config_set: configure an individual pin * @pin_config_set: configure an individual pin
* @pin_config_group_get: get configurations for an entire pin group * @pin_config_group_get: get configurations for an entire pin group
* @pin_config_group_set: configure all pins in a group * @pin_config_group_set: configure all pins in a group
......
...@@ -72,6 +72,15 @@ struct pinctrl_gpio_range { ...@@ -72,6 +72,15 @@ struct pinctrl_gpio_range {
* group selector @pins, and the size of the array in @num_pins * group selector @pins, and the size of the array in @num_pins
* @pin_dbg_show: optional debugfs display hook that will provide per-device * @pin_dbg_show: optional debugfs display hook that will provide per-device
* info for a certain pin in debugfs * info for a certain pin in debugfs
* @dt_node_to_map: parse a device tree "pin configuration node", and create
* mapping table entries for it. These are returned through the @map and
* @num_maps output parameters. This function is optional, and may be
* omitted for pinctrl drivers that do not support device tree.
* @dt_free_map: free mapping table entries created via @dt_node_to_map. The
* top-level @map pointer must be freed, along with any dynamically
* allocated members of the mapping table entries themselves. This
* function is optional, and may be omitted for pinctrl drivers that do
* not support device tree.
*/ */
struct pinctrl_ops { struct pinctrl_ops {
int (*get_groups_count) (struct pinctrl_dev *pctldev); int (*get_groups_count) (struct pinctrl_dev *pctldev);
......
...@@ -23,7 +23,7 @@ struct pinctrl_dev; ...@@ -23,7 +23,7 @@ struct pinctrl_dev;
/** /**
* struct pinmux_ops - pinmux operations, to be implemented by pin controller * struct pinmux_ops - pinmux operations, to be implemented by pin controller
* drivers that support pinmuxing * drivers that support pinmuxing
* @request: called by the core to see if a certain pin can be made available * @request: called by the core to see if a certain pin can be made
* available for muxing. This is called by the core to acquire the pins * available for muxing. This is called by the core to acquire the pins
* before selecting any actual mux setting across a function. The driver * before selecting any actual mux setting across a function. The driver
* is allowed to answer "no" by returning a negative error code * is allowed to answer "no" by returning a negative error code
......
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