From patchwork Tue Apr 7 18:43:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 46845 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B2FCD20553 for ; Tue, 7 Apr 2015 18:44:29 +0000 (UTC) Received: by lbfb1 with SMTP id b1sf14755517lbf.2 for ; Tue, 07 Apr 2015 11:44:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=pisR6cTRo6rIaiUUCvi/GIDhlp6b89jK2bI15WPX+mg=; b=LKHtENYUFMhLbAJEaNS47SOnHkMqPj/3GWrwlnSVa+NHrkIY6HXT+rezLq5/hV9Fcu h67BsuuGruleB8Gbafwbla9uuERFzy3rN35EzyQeHSe5bRKzIYPjKb2I6kpiU3ViXUtA W/RuL/sclGhoLCBA5wWcn/78H8OMJejW59s5ZZ+WvnTqKmSxgB85YOdDkiaAqQCha5Zs eg3ZS6SOnxqfTbjXtCu1TNZZNgRCWQ+4vGNtuSKTxLnJZSsbX2yxrEXiov7EeB1Wz56W Rku105z78lZzIgCN6gsthkPwwoMTbpEoZaD6CWo4Cz5yr0Ypd1AWwNGJQP/lt3evTX7Z S76Q== X-Gm-Message-State: ALoCoQmhkYKSzfbZF2FqKNZ8NBBCCwAUY3VslUfviNSQXfRR6hgaFhl955SZoma4jA0E0FO5Fiyr X-Received: by 10.180.74.197 with SMTP id w5mr714315wiv.5.1428432268751; Tue, 07 Apr 2015 11:44:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.1 with SMTP id n1ls73428laa.87.gmail; Tue, 07 Apr 2015 11:44:28 -0700 (PDT) X-Received: by 10.112.212.106 with SMTP id nj10mr19512963lbc.36.1428432268421; Tue, 07 Apr 2015 11:44:28 -0700 (PDT) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com. [209.85.217.173]) by mx.google.com with ESMTPS id c5si6753491lag.135.2015.04.07.11.44.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Apr 2015 11:44:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) client-ip=209.85.217.173; Received: by lbbuc2 with SMTP id uc2so46289448lbb.2 for ; Tue, 07 Apr 2015 11:44:28 -0700 (PDT) X-Received: by 10.152.234.169 with SMTP id uf9mr19678308lac.88.1428432268276; Tue, 07 Apr 2015 11:44:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp597498lbt; Tue, 7 Apr 2015 11:44:27 -0700 (PDT) X-Received: by 10.66.221.8 with SMTP id qa8mr38493703pac.62.1428432260968; Tue, 07 Apr 2015 11:44:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fo3si12707374pad.17.2015.04.07.11.44.19; Tue, 07 Apr 2015 11:44:20 -0700 (PDT) Received-SPF: none (google.com: devicetree-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753453AbbDGSoP (ORCPT + 5 others); Tue, 7 Apr 2015 14:44:15 -0400 Received: from mail-wi0-f180.google.com ([209.85.212.180]:34150 "EHLO mail-wi0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750862AbbDGSoM (ORCPT ); Tue, 7 Apr 2015 14:44:12 -0400 Received: by widjs5 with SMTP id js5so17045052wid.1 for ; Tue, 07 Apr 2015 11:44:10 -0700 (PDT) X-Received: by 10.180.94.39 with SMTP id cz7mr1613017wib.66.1428432250794; Tue, 07 Apr 2015 11:44:10 -0700 (PDT) Received: from localhost.localdomain ([81.134.86.156]) by mx.google.com with ESMTPSA id di9sm8816057wib.16.2015.04.07.11.44.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Apr 2015 11:44:09 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, kernel@stlinux.com, mturquette@linaro.org, sboyd@codeaurora.org, devicetree@vger.kernel.org, geert@linux-m68k.org Subject: [PATCH v6 3/4] clk: Provide always-on clock support Date: Tue, 7 Apr 2015 19:43:58 +0100 Message-Id: <1428432239-4114-4-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428432239-4114-1-git-send-email-lee.jones@linaro.org> References: <1428432239-4114-1-git-send-email-lee.jones@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.173 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Lots of platforms contain clocks which if turned off would prove fatal. The only way to recover from these catastrophic failures is to restart the board(s). Now, when a clock provider is registered with the framework it is possible for a list of always-on clocks to be supplied which must be kept ungated. Each clock mentioned in the newly introduced 'clock-always-on' will be clk_prepare_enable()d where the normal references will be taken. This will prevent the common clk framework from attempting to gate them during the clk_disable_unused() and disable_clock() procedures. Signed-off-by: Lee Jones --- drivers/clk/clk-conf.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c index aad4796..a07aced 100644 --- a/drivers/clk/clk-conf.c +++ b/drivers/clk/clk-conf.c @@ -116,6 +116,43 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier) return 0; } +static int __set_clk_always_on(struct device_node *node, bool clk_supplier) +{ + struct of_phandle_args clkspec; + struct clk *clk; + struct property *prop; + const __be32 *cur; + uint32_t index; + int ret; + + if (!clk_supplier) + return 0; + + of_property_for_each_u32(node, "clock-always-on", prop, cur, index) { + clkspec.np = node; + clkspec.args_count = 1; + clkspec.args[0] = index; + + clk = of_clk_get_from_provider(&clkspec); + if (IS_ERR(clk)) { + pr_err("clk: couldn't get clock %u for %s\n", + index, node->full_name); + return PTR_ERR(clk); + } + + ret = clk_prepare_enable(clk); + if (ret) { + pr_err("Failed to enable clock %u for %s: %d\n", + index, node->full_name, ret); + return ret; + } + + pr_debug("Setting clock as always-on %pC\n", clk); + } + + return 0; +} + /** * of_clk_set_defaults() - parse and set assigned clocks configuration * @node: device node to apply clock settings for @@ -139,6 +176,10 @@ int of_clk_set_defaults(struct device_node *node, bool clk_supplier) if (rc < 0) return rc; - return __set_clk_rates(node, clk_supplier); + rc = __set_clk_rates(node, clk_supplier); + if (rc < 0) + return rc; + + return __set_clk_always_on(node, clk_supplier); } EXPORT_SYMBOL_GPL(of_clk_set_defaults);