mirror of
https://github.com/armbian/linux.git
synced 2026-01-06 10:13:00 -08:00
pinctrl: factor pin control handles over to the core
This moves the per-devices struct pinctrl handles and device map over from the pinmux part of the subsystem to the core pinctrl part. This makes the device handles core infrastructure with the goal of using these handles also for pin configuration, so that device drivers (or boards etc) will need one and only one handle to the pin control core. Acked-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -30,6 +30,7 @@ struct pinctrl_gpio_range;
|
||||
* subsystem
|
||||
* @pinctrl_hogs_lock: lock for the pin control hog list
|
||||
* @pinctrl_hogs: list of pin control maps hogged by this device
|
||||
* @device_root: debugfs root for this device
|
||||
*/
|
||||
struct pinctrl_dev {
|
||||
struct list_head node;
|
||||
@@ -41,12 +42,37 @@ struct pinctrl_dev {
|
||||
struct device *dev;
|
||||
struct module *owner;
|
||||
void *driver_data;
|
||||
struct mutex pinctrl_hogs_lock;
|
||||
struct list_head pinctrl_hogs;
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
struct dentry *device_root;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* struct pinctrl - per-device pin control state holder
|
||||
* @node: global list node
|
||||
* @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
|
||||
* @mutex: a lock for the pin control state holder
|
||||
* @func_selector: the function selector for the pinmux device handling
|
||||
* this pinmux
|
||||
* @groups: the group selectors for the pinmux device and
|
||||
* selector combination handling this pinmux, this is a list that
|
||||
* will be traversed on all pinmux operations such as
|
||||
* get/put/enable/disable
|
||||
*/
|
||||
struct pinctrl {
|
||||
struct list_head node;
|
||||
struct device *dev;
|
||||
unsigned usecount;
|
||||
struct pinctrl_dev *pctldev;
|
||||
struct mutex mutex;
|
||||
#ifdef CONFIG_PINMUX
|
||||
struct mutex pinctrl_hogs_lock;
|
||||
struct list_head pinctrl_hogs;
|
||||
unsigned func_selector;
|
||||
struct list_head groups;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,9 +15,28 @@
|
||||
int pinmux_check_ops(struct pinctrl_dev *pctldev);
|
||||
void pinmux_init_device_debugfs(struct dentry *devroot,
|
||||
struct pinctrl_dev *pctldev);
|
||||
void pinmux_init_debugfs(struct dentry *subsys_root);
|
||||
int pinctrl_hog_maps(struct pinctrl_dev *pctldev);
|
||||
void pinctrl_unhog_maps(struct pinctrl_dev *pctldev);
|
||||
int pinmux_request_gpio(struct pinctrl_dev *pctldev,
|
||||
struct pinctrl_gpio_range *range,
|
||||
unsigned pin, unsigned gpio);
|
||||
void pinmux_free_gpio(struct pinctrl_dev *pctldev, unsigned pin,
|
||||
struct pinctrl_gpio_range *range);
|
||||
int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
|
||||
struct pinctrl_gpio_range *range,
|
||||
unsigned pin, bool input);
|
||||
static inline void pinmux_init_pinctrl_handle(struct pinctrl *p)
|
||||
{
|
||||
p->func_selector = UINT_MAX;
|
||||
INIT_LIST_HEAD(&p->groups);
|
||||
}
|
||||
int pinmux_apply_muxmap(struct pinctrl_dev *pctldev,
|
||||
struct pinctrl *p,
|
||||
struct device *dev,
|
||||
const char *devname,
|
||||
struct pinctrl_map const *map);
|
||||
void pinmux_put(struct pinctrl *p);
|
||||
int pinmux_enable(struct pinctrl *p);
|
||||
void pinmux_disable(struct pinctrl *p);
|
||||
void pinmux_dbg_show(struct seq_file *s, struct pinctrl *p);
|
||||
|
||||
#else
|
||||
|
||||
@@ -31,16 +50,52 @@ static inline void pinmux_init_device_debugfs(struct dentry *devroot,
|
||||
{
|
||||
}
|
||||
|
||||
static inline void pinmux_init_debugfs(struct dentry *subsys_root)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int pinctrl_hog_maps(struct pinctrl_dev *pctldev)
|
||||
static inline int pinmux_request_gpio(struct pinctrl_dev *pctldev,
|
||||
struct pinctrl_gpio_range *range,
|
||||
unsigned pin, unsigned gpio)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void pinctrl_unhog_maps(struct pinctrl_dev *pctldev)
|
||||
static inline void pinmux_free_gpio(struct pinctrl_dev *pctldev,
|
||||
unsigned pin,
|
||||
struct pinctrl_gpio_range *range)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int pinmux_gpio_direction(struct pinctrl_dev *pctldev,
|
||||
struct pinctrl_gpio_range *range,
|
||||
unsigned pin, bool input)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void pinmux_init_pinctrl_handle(struct pinctrl *p)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int pinmux_apply_muxmap(struct pinctrl_dev *pctldev,
|
||||
struct pinctrl *p,
|
||||
struct device *dev,
|
||||
const char *devname,
|
||||
struct pinctrl_map const *map)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void pinmux_put(struct pinctrl *p)
|
||||
{
|
||||
}
|
||||
|
||||
static inline int pinmux_enable(struct pinctrl *p)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void pinmux_disable(struct pinctrl *p)
|
||||
{
|
||||
}
|
||||
|
||||
void pinmux_dbg_show(struct seq_file *s, struct pinctrl *p)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
/* This struct is private to the core and should be regarded as a cookie */
|
||||
struct pinctrl;
|
||||
|
||||
#ifdef CONFIG_PINMUX
|
||||
#ifdef CONFIG_PINCTRL
|
||||
|
||||
/* External interface to pinmux */
|
||||
/* External interface to pin control */
|
||||
extern int pinctrl_request_gpio(unsigned gpio);
|
||||
extern void pinctrl_free_gpio(unsigned gpio);
|
||||
extern int pinctrl_gpio_direction_input(unsigned gpio);
|
||||
@@ -31,7 +31,7 @@ extern void pinctrl_put(struct pinctrl *p);
|
||||
extern int pinctrl_enable(struct pinctrl *p);
|
||||
extern void pinctrl_disable(struct pinctrl *p);
|
||||
|
||||
#else /* !CONFIG_PINMUX */
|
||||
#else /* !CONFIG_PINCTRL */
|
||||
|
||||
static inline int pinctrl_request_gpio(unsigned gpio)
|
||||
{
|
||||
@@ -70,7 +70,7 @@ static inline void pinctrl_disable(struct pinctrl *p)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* CONFIG_PINMUX */
|
||||
#endif /* CONFIG_PINCTRL */
|
||||
|
||||
#ifdef CONFIG_PINCONF
|
||||
|
||||
|
||||
Reference in New Issue
Block a user