From: Dong Aisheng <b29396@freescale.com>
To: <linux-kernel@vger.kernel.org>
Cc: <linux-arm-kernel@lists.infradead.org>,
<linus.walleij@stericsson.com>, <s.hauer@pengutronix.de>,
<shawn.guo@freescale.com>, <kernel@pengutronix.de>,
<grant.likely@secretlab.ca>, <rob.herring@calxeda.com>,
<devicetree-discuss@lists.ozlabs.org>, <cjb@laptop.org>,
<w.sang@pengutronix.de>
Subject: [RFC PATCH v3 2/5] pinctrl: add dt binding support for pinmux mappings
Date: Wed, 21 Dec 2011 01:40:37 +0800 [thread overview]
Message-ID: <1324402840-32451-3-git-send-email-b29396@freescale.com> (raw)
In-Reply-To: <1324402840-32451-1-git-send-email-b29396@freescale.com>
From: Dong Aisheng <dong.aisheng@linaro.org>
This patch provies a common API for driver to use to register pinmux
mappings from dts file. It is needed for dt support.
Signed-off-by: Dong Aisheng <dong.aisheng@linaro.org>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Rob Herring <rob.herring@calxeda.com>
---
.../devicetree/bindings/pinctrl/pinctrl.txt | 33 +++++++
drivers/pinctrl/pinmux.c | 101 ++++++++++++++++++++
include/linux/pinctrl/machine.h | 6 +
3 files changed, 140 insertions(+), 0 deletions(-)
create mode 100644 Documentation/devicetree/bindings/pinctrl/pinctrl.txt
diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl.txt b/Documentation/devicetree/bindings/pinctrl/pinctrl.txt
new file mode 100644
index 0000000..a27a7ce
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/pinctrl.txt
@@ -0,0 +1,33 @@
+The pin control subsystem
+
+The pin control subsystem provides a common API to support parsing pinmux
+mappings data from device tree. Each board dts file should provide a device
+node of which all the child nodes are the corresponding pinmux mappings.
+
+The required properties for pinmux mapping are:
+- map-name: the name of this specific map entry
+- clk-dev-name: the name of the device controlling this specific mapping
+- funcion: a function in the driver to use for this mapping
+
+Optional properties:
+- group: a certain specific pin group to activate for the function
+- dev-name: the name of the device using this specific mapping
+- hog-on-boot: indicate wether hog the mappings(do not need to specify value)
+
+Examples:
+
+pinmux: imx6q-sabreauto-map {
+ map-sd4 {
+ map-name = "usdhc4";
+ ctrl-dev-name = "20e0000.iomuxc";
+ function = "sd4";
+ dev-name = "219c000.usdhc";
+ };
+ ...
+};
+
+Then calling pinmux_of_register_mappings() with the device node of
+imx6q-sabreauto-map as parameter to register pinmux mappings from dts.
+
+Usually user can get this device node via a phandle in driver then call
+the function to register maps. Please refer to pinctrl-imx.txt for example.
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
index 432feb6..3ac3098 100644
--- a/drivers/pinctrl/pinmux.c
+++ b/drivers/pinctrl/pinmux.c
@@ -20,6 +20,7 @@
#include <linux/err.h>
#include <linux/list.h>
#include <linux/mutex.h>
+#include <linux/of_device.h>
#include <linux/spinlock.h>
#include <linux/string.h>
#include <linux/sysfs.h>
@@ -410,6 +411,106 @@ int __init pinmux_register_mappings(struct pinmux_map const *maps,
return 0;
}
+static int __devinit pinmux_of_parse_mapping(struct device_node *np,
+ struct pinmux_map *maps, unsigned id)
+{
+ struct pinmux_map *map = &maps[id];
+ int ret = 0;
+
+ pr_debug("parse pinmux map %d\n", id + 1);
+
+ if (of_find_property(np, "map-name", NULL)) {
+ ret = of_property_read_string(np, "map-name", &map->name);
+ if (ret) {
+ pr_err("failed to get map-name");
+ return ret;
+ }
+ }
+
+ if (of_find_property(np, "ctrl-dev-name", NULL)) {
+ ret = of_property_read_string(np, "ctrl-dev-name",
+ &map->ctrl_dev_name);
+ if (ret) {
+ pr_err("failed to get ctrl-dev-name");
+ return ret;
+ }
+ }
+
+ if (of_find_property(np, "function", NULL)) {
+ ret = of_property_read_string(np, "function", &map->function);
+ if (ret) {
+ pr_err("failed to get function");
+ return ret;
+ }
+ }
+
+ if (of_find_property(np, "group", NULL)) {
+ ret = of_property_read_string(np, "group", &map->group);
+ if (ret) {
+ pr_err("failed to get group");
+ return ret;
+ }
+ }
+
+ if (of_find_property(np, "dev-name", NULL)) {
+ ret = of_property_read_string(np, "dev-name", &map->dev_name);
+ if (ret) {
+ pr_err("failed to get dev-name");
+ return ret;
+ }
+ }
+
+ if (of_find_property(np, "hog-on-boot", NULL))
+ map->hog_on_boot = true;
+
+ pr_debug("map-name: %s ctrl-dev-name: %s function: %s group: %s dev-name: %s hog-on-boot: %d\n",
+ map->name, map->ctrl_dev_name, map->function,
+ map->group, map->dev_name, map->hog_on_boot);
+
+ return 0;
+}
+
+/**
+ * pinmux_of_register_mappings() - parse and register pinmux mappings from dt
+ * &np: a device node containing pinmux map properties
+ *
+ * Like pinmux_register_mappings(), the memory of pinmux maps are owned by
+ * pinctrl core and can not be freed.
+ */
+int __devinit pinmux_of_register_mappings(struct device_node *np)
+{
+ struct pinmux_map *maps;
+ struct device_node *child = NULL;
+ int count, i;
+ int ret;
+
+ pr_debug("parse pinmux maps from device node %s\n", np->name);
+
+ if (!np)
+ return -EINVAL;
+
+ count = of_get_child_count(np);
+ if (!count) {
+ pr_err("no available pinmux maps found\n");
+ return -EINVAL;
+ }
+
+ maps = kzalloc(count * sizeof(struct pinmux_map), GFP_KERNEL);
+ if (!maps)
+ return -ENOMEM;
+
+ i = 0;
+ for_each_child_of_node(np, child) {
+ ret = pinmux_of_parse_mapping(child, maps, i++);
+ if (ret) {
+ pr_err("failed to parse pinmux map\n");
+ return ret;
+ }
+ }
+
+ return pinmux_register_mappings(maps, count);
+}
+
/**
* acquire_pins() - acquire all the pins for a certain funcion on a pinmux
* @pctldev: the device to take the pins on
diff --git a/include/linux/pinctrl/machine.h b/include/linux/pinctrl/machine.h
index ad430e0..74a695d 100644
--- a/include/linux/pinctrl/machine.h
+++ b/include/linux/pinctrl/machine.h
@@ -78,6 +78,7 @@ struct pinmux_map {
extern int pinmux_register_mappings(struct pinmux_map const *map,
unsigned num_maps);
+extern int pinmux_of_register_mappings(struct device_node *np);
#else
static inline int pinmux_register_mappings(struct pinmux_map const *map,
@@ -86,5 +87,10 @@ static inline int pinmux_register_mappings(struct pinmux_map const *map,
return 0;
}
+static inline int pinmux_of_register_mappings(struct device_node *np)
+{
+ return 0;
+}
+
#endif /* !CONFIG_PINMUX */
#endif
--
1.7.0.4
next prev parent reply other threads:[~2011-12-20 17:30 UTC|newest]
Thread overview: 98+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-20 17:40 [RFC PATCH v3 0/5] pinctrl: imx: add pinnmux support Dong Aisheng
2011-12-20 17:40 ` [RFC PATCH v3 1/5] dt: add of_get_child_count helper function Dong Aisheng
2011-12-20 18:35 ` Rob Herring
2011-12-21 2:56 ` Dong Aisheng-B29396
2012-01-01 13:58 ` Linus Walleij
2011-12-20 19:47 ` Marek Vasut
2011-12-21 3:27 ` Dong Aisheng-B29396
2011-12-21 6:05 ` Lothar Waßmann
2011-12-20 23:58 ` Stephen Warren
2011-12-21 3:18 ` Dong Aisheng-B29396
2011-12-20 17:40 ` Dong Aisheng [this message]
2011-12-20 19:48 ` [RFC PATCH v3 2/5] pinctrl: add dt binding support for pinmux mappings Marek Vasut
2011-12-21 0:39 ` Stephen Warren
2011-12-22 8:18 ` Dong Aisheng-B29396
2011-12-25 3:37 ` Stephen Warren
2011-12-27 14:41 ` Dong Aisheng-B29396
2011-12-29 2:46 ` Shawn Guo
2012-01-05 13:14 ` Dong Aisheng
2012-01-05 23:45 ` Stephen Warren
2012-01-06 6:21 ` Shawn Guo
2012-01-05 23:38 ` Stephen Warren
2012-01-06 10:51 ` Dong Aisheng-B29396
2012-01-06 17:23 ` Stephen Warren
2012-01-10 7:02 ` Dong Aisheng-B29396
2012-01-05 13:47 ` Dong Aisheng
2012-01-06 1:05 ` Stephen Warren
2012-01-06 5:27 ` Shawn Guo
2012-01-06 11:33 ` Dong Aisheng-B29396
2012-01-06 13:14 ` Shawn Guo
2012-01-06 18:03 ` Stephen Warren
2012-01-07 13:54 ` Shawn Guo
2012-01-08 12:51 ` Richard Zhao
2012-01-09 1:56 ` Shawn Guo
2012-01-09 6:18 ` Simon Glass
2012-01-10 11:30 ` Dong Aisheng-B29396
2012-01-11 19:19 ` Stephen Warren
2012-01-11 18:37 ` Stephen Warren
2012-01-11 23:56 ` Shawn Guo
2012-01-11 23:59 ` Stephen Warren
2012-01-12 4:03 ` Shawn Guo
2012-01-12 7:45 ` Dong Aisheng-B29396
2012-01-11 18:28 ` Stephen Warren
2012-01-11 18:17 ` Stephen Warren
2012-01-12 3:39 ` Shawn Guo
2012-01-12 7:40 ` Dong Aisheng-B29396
2012-01-12 20:46 ` Stephen Warren
2012-01-12 21:10 ` Stephen Warren
2012-01-13 3:46 ` Shawn Guo
2012-01-13 18:16 ` Stephen Warren
2012-01-14 1:22 ` Shawn Guo
2012-01-14 18:21 ` Dong Aisheng
2012-01-16 16:08 ` Linus Walleij
2012-01-17 2:32 ` Shawn Guo
2012-01-17 19:50 ` Stephen Warren
2012-01-18 2:30 ` Shawn Guo
2012-01-19 16:55 ` Linus Walleij
2012-01-19 19:30 ` Stephen Warren
2012-01-20 17:51 ` Linus Walleij
2012-01-10 8:21 ` Dong Aisheng-B29396
2012-01-10 13:05 ` Shawn Guo
2012-01-11 19:41 ` Stephen Warren
2012-01-11 23:01 ` Shawn Guo
2012-01-11 22:58 ` Stephen Warren
2012-01-11 20:17 ` Stephen Warren
2012-01-11 23:21 ` Shawn Guo
2012-01-12 8:36 ` Dong Aisheng-B29396
2012-01-12 20:56 ` Stephen Warren
2012-01-13 3:55 ` Shawn Guo
2012-01-13 8:07 ` Dong Aisheng-B29396
2012-01-13 13:35 ` Shawn Guo
2012-01-13 13:48 ` Linus Walleij
2012-01-13 14:23 ` Shawn Guo
2012-01-13 17:11 ` Dong Aisheng
2012-01-13 18:33 ` Stephen Warren
2012-01-14 1:10 ` Shawn Guo
2012-01-17 19:35 ` Stephen Warren
2012-01-17 19:48 ` Rob Herring
2012-01-14 17:58 ` Dong Aisheng
2012-01-17 19:44 ` Stephen Warren
2012-01-01 14:07 ` Linus Walleij
2012-01-01 15:22 ` Rob Herring
2012-01-05 13:59 ` Dong Aisheng
2011-12-20 17:40 ` [RFC PATCH v3 3/5] pinctrl: imx: add pinctrl imx driver Dong Aisheng
2011-12-20 19:50 ` Marek Vasut
2011-12-21 3:09 ` Dong Aisheng-B29396
2012-01-01 14:02 ` Linus Walleij
2012-01-08 13:05 ` Richard Zhao
2012-01-09 2:08 ` Shawn Guo
2012-01-09 2:17 ` Richard Zhao
2012-01-09 6:32 ` Shawn Guo
2012-01-10 8:38 ` Richard Zhao
2012-01-10 10:43 ` Linus Walleij
2012-01-10 10:55 ` Dong Aisheng-B29396
2012-01-10 13:51 ` Shawn Guo
2012-01-11 9:28 ` Linus Walleij
2011-12-20 17:40 ` [RFC PATCH v3 4/5] ARM: imx6q: using pinmux subsystem Dong Aisheng
2011-12-20 17:40 ` [RFC PATCH v3 5/5] mmc: sdhci-esdhc-imx: " Dong Aisheng
2012-01-01 13:54 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1324402840-32451-3-git-send-email-b29396@freescale.com \
--to=b29396@freescale.com \
--cc=cjb@laptop.org \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=kernel@pengutronix.de \
--cc=linus.walleij@stericsson.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rob.herring@calxeda.com \
--cc=s.hauer@pengutronix.de \
--cc=shawn.guo@freescale.com \
--cc=w.sang@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).