From patchwork Thu Feb 11 21:19:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Turquette X-Patchwork-Id: 61809 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp447889lbl; Thu, 11 Feb 2016 13:19:54 -0800 (PST) X-Received: by 10.98.33.131 with SMTP id o3mr69929984pfj.97.1455225594404; Thu, 11 Feb 2016 13:19:54 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id os9si14783693pab.169.2016.02.11.13.19.54; Thu, 11 Feb 2016 13:19:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751737AbcBKVTr (ORCPT + 30 others); Thu, 11 Feb 2016 16:19:47 -0500 Received: from mail-pf0-f176.google.com ([209.85.192.176]:32947 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751707AbcBKVTn (ORCPT ); Thu, 11 Feb 2016 16:19:43 -0500 Received: by mail-pf0-f176.google.com with SMTP id q63so35456976pfb.0 for ; Thu, 11 Feb 2016 13:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HrmuCyA/A/raEoSGJKhBxFUDpSRcz6iinFLcCOBCLOQ=; b=CEgBtg0yOy062gr+x82I086FUpyisc+8LRPS8XWQNeDJ7ebxa6xiYr6OsaZGuWR8rK gDle9oye3DKP5Wykj5MG9H6W9fLWCyQdLATgOuMoBnIs4b0rZcYlJpQxiCF2BYH5Uwfk HmbBikpMJv9DsVORMsjVP40UYArI+kGuwjjUrIrkhdMgqIcs/6yrMhVPks9jgm6EcROo yijefjDltX8mnooOZpXdlPAHMn+gzS0plgvDJ7V9shZo8P8dLcQdKIJptKAhLJ4+dNjC cgZD/WlLIaDYrDDZ1c7K5Pf96s0kxTYwoGz4+qtxi/2LOcd2BlfldHupe+0Gr9/92Nmq Pwqg== 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=HrmuCyA/A/raEoSGJKhBxFUDpSRcz6iinFLcCOBCLOQ=; b=kosU+6ozbylLgRGRK41N+tnt3gRpdew02jtOzFrrXAnW8OEX295142wSM47WNLgqRX sf0bZBGqHC87X8ILps/7z2UISFYAAwbqGXN+BQDU1ua6+QHtqAQGuKFgr06YaHHhj9/G 3mH/JMryaZJjpqNtGQkSXZusHfS0fOZD4iVys4VDM2CuZyg/HTcMrwL9kJyxi7wvjJbI hkzp5wVdTpxCrRfdXtCo8Wi03fascdGXpihyDhU9zn3UUiuNCMJYOqZLf6Ff+JZLY5CU vA42ydS7YLtST6yDx1OKdWXm+aVoQhPvdkfL724IdlHUV/ELXcPU6Mbmpmylj+JvMRQb vzug== X-Gm-Message-State: AG10YOQCzNxxHejxDqZusNHjJvIxgV6eacjQyZRyYAr37JJk1xu5ue0w9E/N9yZmrz96utQe X-Received: by 10.98.32.218 with SMTP id m87mr25163250pfj.48.1455225582997; Thu, 11 Feb 2016 13:19:42 -0800 (PST) Received: from localhost (cpe-172-248-200-249.socal.res.rr.com. [172.248.200.249]) by smtp.gmail.com with ESMTPSA id y86sm14381018pfa.26.2016.02.11.13.19.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 Feb 2016 13:19:41 -0800 (PST) From: Michael Turquette To: linux-clk@vger.kernel.org Cc: lee.jones@linaro.org, sboyd@codeaurora.org, maxime.ripard@free-electrons.com, maxime.coquelin@st.com, geert@linux-m68k.org, heiko@sntech.de, andre.przywara@arm.com, rklein@nvidia.com, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Michael Turquette Subject: [PATCH v42 3/6] clk: Provide OF helper to mark clocks as CRITICAL Date: Thu, 11 Feb 2016 13:19:11 -0800 Message-Id: <1455225554-13267-4-git-send-email-mturquette@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455225554-13267-1-git-send-email-mturquette@baylibre.com> References: <1455225554-13267-1-git-send-email-mturquette@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lee Jones This call matches clocks which have been marked as critical in DT and sets the appropriate flag. These flags can then be used to mark the clock core flags appropriately prior to registration. Legacy bindings requiring this feature must add the clock-critical property to their binding descriptions, as it is not a part of common-clock binding. Cc: devicetree@vger.kernel.org Signed-off-by: Lee Jones Signed-off-by: Michael Turquette --- Changed in vWhatever: * Added kerneldoc * Moved to clk.c, removed static inline * s/of_clk_mark_if_critical/of_clk_detect_critical/ * s/critical-clock/clock-critical/ drivers/clk/clk.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/clk-provider.h | 8 +++++++- 2 files changed, 42 insertions(+), 1 deletion(-) -- 2.1.4 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 39f9527..5181a15 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3202,6 +3202,41 @@ static int parent_ready(struct device_node *np) } /** + * of_clk_detect_critical() - set CLK_IS_CRITICAL flag from Device Tree + * @np: Device node pointer associated with clock provider + * @index: clock index + * @flags: pointer to clk_core->flags + * + * Detects if the clock-critical property exists and, if so, sets the + * corresponding CLK_IS_CRITICAL flag. + * + * Do not use this function. It exists only for legacy Device Tree + * bindings, such as the one-clock-per-node style that are outdated. + * Those bindings typically put all clock data into .dts and the Linux + * driver has no clock data, thus making it impossible to set this flag + * correctly from the driver. Only those drivers may call + * of_clk_detect_critical from their setup functions. + * + * Return: error code or zero on success + */ +int of_clk_mark_if_critical(struct device_node *np, + int index, unsigned long *flags) +{ + struct property *prop; + const __be32 *cur; + uint32_t idx; + + if (!np || !flags) + return -EINVAL; + + of_property_for_each_u32(np, "clock-critical", prop, cur, idx) + if (index == idx) + *flags |= CLK_IS_CRITICAL; + + return 0; +} + +/** * of_clk_init() - Scan and init clock providers from the DT * @matches: array of compatible values and init functions for providers. * diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 1d986ea..d15d3cc 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -705,7 +705,8 @@ int of_clk_get_parent_count(struct device_node *np); int of_clk_parent_fill(struct device_node *np, const char **parents, unsigned int size); const char *of_clk_get_parent_name(struct device_node *np, int index); - +int of_clk_mark_if_critical(struct device_node *np, int index, + unsigned long *flags); void of_clk_init(const struct of_device_id *matches); #else /* !CONFIG_OF */ @@ -742,6 +743,11 @@ static inline const char *of_clk_get_parent_name(struct device_node *np, { return NULL; } +static inline int of_clk_mark_if_critical(struct device_node *np, int index, + unsigned long *flags) +{ + return 0; +} static inline void of_clk_init(const struct of_device_id *matches) {} #endif /* CONFIG_OF */