summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/core.h
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2016-12-27 18:20:00 +0100
committerLinus Walleij <linus.walleij@linaro.org>2017-01-03 09:26:17 +0100
commitc7059c5ac70aea194b07b2d811df433eb0ca81b5 (patch)
tree5846f1f4a30c4d448e5848f307c6c44959eb9419 /drivers/pinctrl/core.h
parentpinctrl: add some comments to the hog/late init code (diff)
downloadlinux-c7059c5ac70aea194b07b2d811df433eb0ca81b5.tar.xz
linux-c7059c5ac70aea194b07b2d811df433eb0ca81b5.zip
pinctrl: core: Add generic pinctrl functions for managing groups
We can add generic helpers for pin group handling for cases where the pin controller driver does not need to use static arrays. Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/core.h')
-rw-r--r--drivers/pinctrl/core.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 722b2579166d..af98b6313902 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -24,6 +24,8 @@ struct pinctrl_gpio_range;
* controller
* @pin_desc_tree: each pin descriptor for this pin controller is stored in
* this radix tree
+ * @pin_group_tree: optionally each pin group can be stored in this radix tree
+ * @num_groups: optionally number of groups can be kept here
* @gpio_ranges: a list of GPIO ranges that is handled by this pin controller,
* ranges are added to this list at runtime
* @dev: the device entry for this pin controller
@@ -41,6 +43,8 @@ struct pinctrl_dev {
struct list_head node;
struct pinctrl_desc *desc;
struct radix_tree_root pin_desc_tree;
+ struct radix_tree_root pin_group_tree;
+ unsigned int num_groups;
struct list_head gpio_ranges;
struct device *dev;
struct module *owner;
@@ -162,6 +166,20 @@ struct pin_desc {
};
/**
+ * struct group_desc - generic pin group descriptor
+ * @name: name of the pin group
+ * @pins: array of pins that belong to the group
+ * @num_pins: number of pins in the group
+ * @data: pin controller driver specific data
+ */
+struct group_desc {
+ const char *name;
+ int *pins;
+ int num_pins;
+ void *data;
+};
+
+/**
* struct pinctrl_maps - a list item containing part of the mapping table
* @node: mapping table list node
* @maps: array of mapping table entries
@@ -173,6 +191,35 @@ struct pinctrl_maps {
unsigned num_maps;
};
+#ifdef CONFIG_GENERIC_PINCTRL
+
+int pinctrl_generic_get_group_count(struct pinctrl_dev *pctldev);
+
+const char *pinctrl_generic_get_group_name(struct pinctrl_dev *pctldev,
+ unsigned int group_selector);
+
+int pinctrl_generic_get_group_pins(struct pinctrl_dev *pctldev,
+ unsigned int group_selector,
+ const unsigned int **pins,
+ unsigned int *npins);
+
+struct group_desc *pinctrl_generic_get_group(struct pinctrl_dev *pctldev,
+ unsigned int group_selector);
+
+int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
+ int *gpins, int ngpins, void *data);
+
+int pinctrl_generic_remove_group(struct pinctrl_dev *pctldev,
+ unsigned int group_selector);
+
+static inline int
+pinctrl_generic_remove_last_group(struct pinctrl_dev *pctldev)
+{
+ return pinctrl_generic_remove_group(pctldev, pctldev->num_groups - 1);
+}
+
+#endif /* CONFIG_GENERIC_PINCTRL */
+
struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name);
struct pinctrl_dev *get_pinctrl_dev_from_of_node(struct device_node *np);
int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name);