From patchwork Fri Feb 20 18:01:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Coquelin X-Patchwork-Id: 442093 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3F56E140161 for ; Sat, 21 Feb 2015 05:06:53 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754788AbbBTSBu (ORCPT ); Fri, 20 Feb 2015 13:01:50 -0500 Received: from mail-wg0-f68.google.com ([74.125.82.68]:41901 "EHLO mail-wg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754805AbbBTSBr (ORCPT ); Fri, 20 Feb 2015 13:01:47 -0500 Received: by mail-wg0-f68.google.com with SMTP id y19so4330078wgg.3; Fri, 20 Feb 2015 10:01:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=o+/YwjjmmAVnYXUVv/chKebEB3ER/zpt7dAm/pUDfp8=; b=ML0cUaD3Cte0nS3NtXc2W8DuuA5LmNirhV6EqkC1vfznhoHFCPNLVF3AFt6stySv8X Miq2rZt+7KmY3gS5ghSKs22ghGVm1YiwP5/tqPcMdp2x79jLkMr78JUD+oIDcQ5x8MYe dsBNdfkKcLaUXZGI7IdCdHSA+z+ijVjVepNNmQ19VLvj8BtZGy+HxsXvdugLTsW0YSAT 7coNS9Jsf4zYYF5ZEZ4iBqHQ+Dbmi3Xkh7Bmlv9tWh7kmbMgg+BPNpZEkoT5Vi35k/wB UboO0Pe7qmIihMj0OIyDZVnAMVJOgxLC0c0PZQoMCjjYGt9Y3PlCUUxdJletFwilV4Zo ylDQ== X-Received: by 10.180.74.111 with SMTP id s15mr7736709wiv.61.1424455302841; Fri, 20 Feb 2015 10:01:42 -0800 (PST) Received: from lmecul0520.st.com. (169.20.90.92.rev.sfr.net. [92.90.20.169]) by mx.google.com with ESMTPSA id hs7sm3398370wib.4.2015.02.20.10.01.40 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Feb 2015 10:01:42 -0800 (PST) From: Maxime Coquelin To: u.kleine-koenig@pengutronix.de, afaerber@suse.de, geert@linux-m68k.org, Rob Herring , Philipp Zabel , Jonathan Corbet , Maxime Coquelin , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Russell King , Daniel Lezcano , Thomas Gleixner , Linus Walleij , Greg Kroah-Hartman , Jiri Slaby , Arnd Bergmann , Andrew Morton , "David S. Miller" , Mauro Carvalho Chehab , Joe Perches , Antti Palosaari , Tejun Heo , Will Deacon , Nikolay Borisov , Rusty Russell , Kees Cook , Michal Marek , linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, linux-serial@vger.kernel.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org Subject: [PATCH v2 05/18] reset: Add reset_controller_of_init() function Date: Fri, 20 Feb 2015 19:01:04 +0100 Message-Id: <1424455277-29983-6-git-send-email-mcoquelin.stm32@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424455277-29983-1-git-send-email-mcoquelin.stm32@gmail.com> References: <1424455277-29983-1-git-send-email-mcoquelin.stm32@gmail.com> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Some platforms need to initialize the reset controller before the timers. This patch introduces a reset_controller_of_init() function that can be called before the timers intialization. Signed-off-by: Maxime Coquelin --- drivers/reset/core.c | 27 +++++++++++++++++++++++++++ include/asm-generic/vmlinux.lds.h | 4 +++- include/linux/reset-controller.h | 6 ++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/reset/core.c b/drivers/reset/core.c index 7955e00..7eef63e 100644 --- a/drivers/reset/core.c +++ b/drivers/reset/core.c @@ -86,6 +86,33 @@ void reset_controller_unregister(struct reset_controller_dev *rcdev) } EXPORT_SYMBOL_GPL(reset_controller_unregister); +extern struct of_device_id __reset_ctrl_of_table[]; + +static const struct of_device_id __reset_ctrl_of_table_sentinel + __used __section(__reset_ctrl_of_table_end); + +/** + * reset_controller_of_init - scan and init reset controllers from the DT + * + * This function scas the device tree for matching reset controllers. It is + * used on machines that need reset controls at early stage. To use it, the + * controller driver has to be registred with RESET_CONTROLLER_OF_DECLARE(). + */ +void __init reset_controller_of_init(void) +{ + struct device_node *np; + const struct of_device_id *match; + of_init_fn_1 init_func; + + for_each_matching_node_and_match(np, __reset_ctrl_of_table, &match) { + if (!of_device_is_available(np)) + continue; + + init_func = match->data; + init_func(np); + } +} + /** * reset_control_reset - reset the controlled device * @rstc: reset controller diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index bee5d68..1f96365 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -168,6 +168,7 @@ #define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) #define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) #define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon) +#define RESET_CTRL_OF_TABLES() OF_TABLE(CONFIG_RESET_CONTROLLER, reset_ctrl) #define KERNEL_DTB() \ STRUCT_ALIGN(); \ @@ -502,7 +503,8 @@ CPU_METHOD_OF_TABLES() \ KERNEL_DTB() \ IRQCHIP_OF_MATCH_TABLE() \ - EARLYCON_OF_TABLES() + EARLYCON_OF_TABLES() \ + RESET_CTRL_OF_TABLES() #define INIT_TEXT \ *(.init.text) \ diff --git a/include/linux/reset-controller.h b/include/linux/reset-controller.h index ce6b962..f8a030a 100644 --- a/include/linux/reset-controller.h +++ b/include/linux/reset-controller.h @@ -51,4 +51,10 @@ struct reset_controller_dev { int reset_controller_register(struct reset_controller_dev *rcdev); void reset_controller_unregister(struct reset_controller_dev *rcdev); + +#define RESET_CONTROLLER_OF_DECLARE(name, compat, fn) \ + OF_DECLARE_1(reset_ctrl, name, compat, fn) + +void reset_controller_of_init(void); + #endif