From: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
To: lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org
Cc: rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org,
pawel.moll-5wv7dgnIgG8@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org,
swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org,
rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
Laxman Dewangan
<ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH] mfd: core: introduce of_node_name for mfd sub devices
Date: Thu, 19 Sep 2013 13:59:52 +0530 [thread overview]
Message-ID: <1379579392-1794-1-git-send-email-ldewangan@nvidia.com> (raw)
Multi Function Devices (MFDs) have multiple sub module whose driver is
developed in different sub-system like GPIO, regulators, RTC, clock etc.
The device tree of such device contains multiple sub-node which contains
the properties of these sub-modules.
The sub module gets of_node handle either by the dev->of_node or by getting
the child node handle from parent DT handle by finding child name on parent's
of_node.
To provide the of_node of sub-module directly, currently there is only one
approach:
- Add compatible value when defining the sub-module in mfd core and
add this properties when adding DT.
Introduce the of_node_name of each sub devices which is set when defining
the mfd_cells of the sub devices and get the handle of these child node
when adding the mfd_devices by getting the sub-node handle with matching
the node name getting the sub-node handle with matching the node name.
Signed-off-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
Creating this patch based on the discussion on patch
[PATCH 1/4] mfd: add support for AMS AS3722 PMIC
The discussion on above patch is not concluded and want to have
further discussion on this patch.
Documentation/devicetree/bindings/mfd/mfd-core.txt | 57 ++++++++++++++++++++
drivers/mfd/mfd-core.c | 10 +++-
include/linux/mfd/core.h | 6 ++
3 files changed, 71 insertions(+), 2 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/mfd-core.txt
diff --git a/Documentation/devicetree/bindings/mfd/mfd-core.txt b/Documentation/devicetree/bindings/mfd/mfd-core.txt
new file mode 100644
index 0000000..d68c893
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/mfd-core.txt
@@ -0,0 +1,57 @@
+MFD DT binding document
+-----------------------
+
+Multi Function Devices (MFDs) have multiple sub module whose driver is developed
+in different sub-system like GPIO, regulators, RTC, clock etc. The device
+tree of such device contains multiple sub-node which contains the properties
+of these sub-modules.
+The sub modules get of_node handle either by the dev->of_node or by getting
+the child node handle from parent DT handle by finding child name on parent's
+of_node.
+To provide the of_node of sub-module directly, there is two approach:
+- Add compatible value when defining the sub-module in mfd core and
+ add this properties when adding DT.
+- Add the of_node_name when defining the sub-module in mfd core and
+ add keep same name of child node when adding DT.
+
+If none of above matches then sub-module driver will not get their of_node
+and they need to derive the method to get their node from parent node.
+
+Examples:
+DT file:
+--------
+ mfd_device_dt {
+ ....
+ gpio_child {
+ /* Properties which need by gpio sub module */
+ };
+
+ rtc_child {
+ /* Properties which need by rtc sub module */
+ };
+
+ regulator_child {
+ /* Properties which need by regulator sub module */
+ };
+ };
+
+
+Driver code:
+-----------
+static struct mfd_cell mfd_abc_devs[] = {
+ {
+ .name = "mfd-abc-gpio",
+ .of_node_name = "gpio_child";
+ },
+ {
+ .name = "mfd-abc-regulator",
+ .of_node_name = "regulator_child";
+ },
+ {
+ .name = "mfd-abc-rtc",
+ .of_node_name = "rtc_child";
+ },
+};
+
+Here sub-node names are gpio_child, rtc_child, regulator_child and it is same
+as of_node_name defined in the driver.
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c
index f421586..88836c2 100644
--- a/drivers/mfd/mfd-core.c
+++ b/drivers/mfd/mfd-core.c
@@ -99,9 +99,15 @@ static int mfd_add_device(struct device *parent, int id,
pdev->dev.dma_mask = parent->dma_mask;
pdev->dev.dma_parms = parent->dma_parms;
- if (parent->of_node && cell->of_compatible) {
+ if (parent->of_node && (cell->of_compatible || cell->of_node_name)) {
for_each_child_of_node(parent->of_node, np) {
- if (of_device_is_compatible(np, cell->of_compatible)) {
+ if (cell->of_compatible &&
+ of_device_is_compatible(np, cell->of_compatible)) {
+ pdev->dev.of_node = np;
+ break;
+ }
+ if (cell->of_node_name && np->name &&
+ !strcmp(cell->of_node_name, np->name)) {
pdev->dev.of_node = np;
break;
}
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
index cebe97e..4cf891f 100644
--- a/include/linux/mfd/core.h
+++ b/include/linux/mfd/core.h
@@ -45,6 +45,12 @@ struct mfd_cell {
const char *of_compatible;
/*
+ * Device tree sub-node name.
+ * See: Documentation/devicetree/bindings/mfd/mfd-core.txt
+ */
+ const char *of_node_name;
+
+ /*
* These resources can be specified relative to the parent device.
* For accessing hardware you should use resources from the platform dev
*/
--
1.7.1.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next reply other threads:[~2013-09-19 8:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-19 8:29 Laxman Dewangan [this message]
2013-09-19 8:30 ` [PATCH] mfd: core: introduce of_node_name for mfd sub devices Lee Jones
2013-09-19 8:57 ` Laxman Dewangan
2013-09-19 11:55 ` Mark Brown
[not found] ` <20130919115501.GM21013-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-09-19 12:00 ` Lee Jones
2013-09-19 12:28 ` Laxman Dewangan
[not found] ` <523AEE07.9090405-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-09-19 12:22 ` Lee Jones
2013-09-19 12:54 ` Laxman Dewangan
2013-09-23 20:46 ` Stephen Warren
2013-09-24 13:55 ` Lee Jones
[not found] ` <1379579392-1794-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2013-09-23 20:50 ` Stephen Warren
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=1379579392-1794-1-git-send-email-ldewangan@nvidia.com \
--to=ldewangan-ddmlm1+adcrqt0dzr+alfa@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg@public.gmane.org \
--cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
--cc=pawel.moll-5wv7dgnIgG8@public.gmane.org \
--cc=rob-VoJi6FS/r0vR7s880joybQ@public.gmane.org \
--cc=rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org \
--cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org \
/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).