From: Kevin Hao <haokexin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Benjamin Herrenschmidt
<benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>,
Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>,
Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Subject: [PATCH 3/5] of/platform: introduce a generic way to declare a platform bus
Date: Tue, 23 Aug 2016 10:06:57 +0800 [thread overview]
Message-ID: <1471918019-19472-4-git-send-email-haokexin@gmail.com> (raw)
In-Reply-To: <1471918019-19472-1-git-send-email-haokexin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
The specific buses which need to be probed at boot time are different
between platforms. Instead of put all the buses into the default
of_default_bus_match_table[] match tables, this patch introduces a
general way to declare a platform bus.
Signed-off-by: Kevin Hao <haokexin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/of/platform.c | 12 +++++++++++-
include/asm-generic/vmlinux.lds.h | 2 ++
include/linux/of.h | 22 ++++++++++++++++++++++
include/linux/of_platform.h | 5 +++++
4 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 6aaa1438c9cd..a7bfe8504caa 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -488,11 +488,21 @@ int of_platform_populate(struct device_node *root,
}
EXPORT_SYMBOL_GPL(of_platform_populate);
+static const struct of_device_id __bus_of_table_sentinel
+ __used __section(__bus_of_table_end);
+
int of_platform_default_populate(struct device_node *root,
const struct of_dev_auxdata *lookup,
struct device *parent)
{
- return of_platform_populate(root, of_default_bus_match_table, lookup,
+ const struct of_device_id *matches;
+
+ if (__bus_of_table != &__bus_of_table_sentinel)
+ matches = __bus_of_table;
+ else
+ matches = of_default_bus_match_table;
+
+ return of_platform_populate(root, matches, lookup,
parent);
}
EXPORT_SYMBOL_GPL(of_platform_default_populate);
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 24563970ff7b..43aa725e86fa 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -179,6 +179,7 @@
#define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
#define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method)
#define CPUIDLE_METHOD_OF_TABLES() OF_TABLE(CONFIG_CPU_IDLE, cpuidle_method)
+#define BUS_OF_TABLES() OF_TABLE(CONFIG_OF, bus)
#ifdef CONFIG_ACPI
#define ACPI_PROBE_TABLE(name) \
@@ -542,6 +543,7 @@
IOMMU_OF_TABLES() \
CPU_METHOD_OF_TABLES() \
CPUIDLE_METHOD_OF_TABLES() \
+ BUS_OF_TABLES() \
KERNEL_DTB() \
IRQCHIP_OF_MATCH_TABLE() \
ACPI_PROBE_TABLE(irqchip) \
diff --git a/include/linux/of.h b/include/linux/of.h
index 3d9ff8e9d803..3a53c898cde9 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -1002,12 +1002,28 @@ static inline int of_get_available_child_count(const struct device_node *np)
__used __section(__##table##_of_table) \
= { .compatible = compat, \
.data = (fn == (fn_type)NULL) ? fn : fn }
+
+#define __OF_DECLARE_ALL(table, entry, _name, _type, _compat, _data) \
+ static const struct of_device_id __of_table_##entry \
+ __used __section(__##table##_of_table) \
+ = { .name = _name, \
+ .type = _type, \
+ .compatible = _compat, \
+ .data = _data }
#else
#define _OF_DECLARE(table, name, compat, fn, fn_type) \
static const struct of_device_id __of_table_##name \
__attribute__((unused)) \
= { .compatible = compat, \
.data = (fn == (fn_type)NULL) ? fn : fn }
+
+#define __OF_DECLARE_ALL(table, entry, _name, _type, _compat, _data) \
+ static const struct of_device_id __of_table_##_name \
+ __attribute__((unused)) \
+ = { .name = _name, \
+ .type = _type, \
+ .compatible = _compat, \
+ .data = _data }
#endif
typedef int (*of_init_fn_2)(struct device_node *, struct device_node *);
@@ -1020,6 +1036,12 @@ typedef void (*of_init_fn_1)(struct device_node *);
_OF_DECLARE(table, name, compat, fn, of_init_fn_1_ret)
#define OF_DECLARE_2(table, name, compat, fn) \
_OF_DECLARE(table, name, compat, fn, of_init_fn_2)
+#define OF_DECLARE_COMPAT(table, name, compat) \
+ __OF_DECLARE_ALL(table, name, "", "", compat, NULL)
+#define OF_DECLARE_TYPE(table, name, type) \
+ __OF_DECLARE_ALL(table, name, "", type, "", NULL)
+#define OF_DECLARE_NAME(table, name, node_name) \
+ __OF_DECLARE_ALL(table, name, node_name, "", "", NULL)
/**
* struct of_changeset_entry - Holds a changeset entry
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 02cf1fdaa3d0..35c5b66f61f0 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -17,6 +17,10 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>
+#define BUS_OF_DECLARE_COMPAT(name, compat) OF_DECLARE_COMPAT(bus, name, compat)
+#define BUS_OF_DECLARE_TYPE(name, type) OF_DECLARE_TYPE(bus, name, type)
+#define BUS_OF_DECLARE_NAME(name, node_name) OF_DECLARE_NAME(bus, name, node_name)
+
/**
* struct of_dev_auxdata - lookup table entry for device names & platform_data
* @compatible: compatible value of node to match against node
@@ -52,6 +56,7 @@ struct of_dev_auxdata {
.platform_data = _pdata }
extern const struct of_device_id of_default_bus_match_table[];
+extern const struct of_device_id __bus_of_table[];
/* Platform drivers register/unregister */
extern struct platform_device *of_device_alloc(struct device_node *np,
--
2.5.5
--
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 prev parent reply other threads:[~2016-08-23 2:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-23 2:06 [PATCH 0/5] ppc32: use the default of_platform_default_populate_init() for 83xx boards Kevin Hao
[not found] ` <1471918019-19472-1-git-send-email-haokexin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-23 2:06 ` [PATCH 1/5] of/platform: introduce arch_want_default_of_probe() Kevin Hao
2016-08-23 2:06 ` [PATCH 2/5] powerpc: introduce arch_enable_default_of_probe() Kevin Hao
2016-08-23 2:06 ` Kevin Hao [this message]
[not found] ` <1471918019-19472-4-git-send-email-haokexin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-08-25 13:44 ` [PATCH 3/5] of/platform: introduce a generic way to declare a platform bus Rob Herring
2016-08-27 7:40 ` Kevin Hao
2016-08-29 21:08 ` Rob Herring
2016-08-23 2:06 ` [PATCH 4/5] powerpc/83xx: factor out the common codes of setup arch functions Kevin Hao
2016-08-23 2:06 ` [PATCH 5/5] powerpc/83xx: enable the default of probe Kevin Hao
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=1471918019-19472-4-git-send-email-haokexin@gmail.com \
--to=haokexin-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
--cc=mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org \
--cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@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).