From patchwork Tue Aug 23 02:06:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hao X-Patchwork-Id: 661684 X-Patchwork-Delegate: scottwood@freescale.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sJDWS3ngKz9sDf for ; Tue, 23 Aug 2016 12:13:40 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=PtH1blMi; dkim-atps=neutral Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3sJDWS2gbTzDrcv for ; Tue, 23 Aug 2016 12:13:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=PtH1blMi; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-yw0-x243.google.com (mail-yw0-x243.google.com [IPv6:2607:f8b0:4002:c05::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3sJDNF4SKlzDrcT for ; Tue, 23 Aug 2016 12:07:25 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=PtH1blMi; dkim-atps=neutral Received: by mail-yw0-x243.google.com with SMTP id r9so4420971ywg.2 for ; Mon, 22 Aug 2016 19:07:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cSuqOAl4foCT7CkBs5vGfIxpsAhPjC7PakKxf+dxvIA=; b=PtH1blMi5gPCGOZX+EUCdoNvTOmlA7oRKd2h8CDepyRpxMcm3o/DUAsRYq+UgspFl7 aaSva+IgMYElPxxHurlb/4s3GktDnVi/FyDfPG963v1waW5wyVbHz6OdwEpZHcJYQdPc jffDRqnHUN6KWdlL2pi/LHc+60j3JSeuLBO8QFFttqWSKsdNOCJwOEkTn8OEwTepQrrW c8rCOVZxZ3S5sgiXASMJ0e9uBIbx8sKwVGR8kLKitwHMArV/sjzfPR6d4oHSl4C727yo BTD7AwxZR8C2xI8Y6CvwQcLT0G96iL9AGDjsUbPUGVxCAHFclTTBcCy3abvmwxo6rk5q OvnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cSuqOAl4foCT7CkBs5vGfIxpsAhPjC7PakKxf+dxvIA=; b=WOsAd6QuqGgjRr7qCFLryL1f112IaCHXMyIclI4DFTpVeSaaRLM3ppQ/RWU7QDZY1l +1YgnZqyX4W9T3dG/BJVPSAg4t4T4vUrSOpHOJf78VcLseOCIxjiaI6RbP07AgaUpfM6 Wv19aGUVX/yWzojONlKCZWi8F6gqYJ6qFbcjprzem6mtz/gGCehJmLaz+RoNyE4jTd3Y BhuPJNeev5TikETgsC7Hp+Noqo7J3xO27RrX2/3e6UQ6usM1aP9aAIZF96gDluIddcPp lYhXfGyAd/H36bkW9xeoF9rQhqNgY/npahpEnQ0+1l7gAtyoqPZfMuT2+F5OpnsgkaKj o44g== X-Gm-Message-State: AEkoouuMpH2JLvF28B+8SO94Dtt4+FnI5czJkZrOkBZU4DqfbITVY/OlGfSUzZdmIhlx9w== X-Received: by 10.129.78.147 with SMTP id c141mr19432034ywb.57.1471918043776; Mon, 22 Aug 2016 19:07:23 -0700 (PDT) Received: from pek-khao-d1.wrs.com (unknown-178-22.windriver.com. [147.11.178.22]) by smtp.gmail.com with ESMTPSA id u187sm533582ywu.27.2016.08.22.19.07.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Aug 2016 19:07:23 -0700 (PDT) From: Kevin Hao To: linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.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 Message-Id: <1471918019-19472-4-git-send-email-haokexin@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1471918019-19472-1-git-send-email-haokexin@gmail.com> References: <1471918019-19472-1-git-send-email-haokexin@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Herring , Arnd Bergmann Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" 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 --- 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 #include +#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,