From patchwork Wed Apr 1 12:28:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 46620 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7FE26216D1 for ; Wed, 1 Apr 2015 12:29:07 +0000 (UTC) Received: by wgua4 with SMTP id a4sf9738840wgu.2 for ; Wed, 01 Apr 2015 05:29:06 -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=LUfAWuneS8V4FusQro7nX+AQRz1ZTZwgyxWgU8PVhMU=; b=kvT98lU3BPECpzCxoykEqubh4zfq5A4CIR0Tj5c1XufsfiY0FRtxKANEKRdjCwfzUO O+z17n+fod892HL41a0niFTOLUrd3gEJ3W3FR1cMBXf2yTLwf0O+7jFoDIs4dka2N9qY Wup1Km4krvc8VrF8uXGExwU8gQ+0F+Phl9SXIHRBQJkKIS6G48VZd2OCs8kXXhCM7Cna aPrEPtIoD8xrtw1LYe/T5s6BFiXPhabS6O+HDi34ttmF/YEOPgotHzjYJlYu+qIy5/Kd veymJpB0WYltfwZ1q0bjhi25VoWAAOu/EnXAQghf+KTZNq7ynWTAZc7rAF5myunEV+OM 2EyA== X-Gm-Message-State: ALoCoQn3jBJEMwwqRpgouNxwQzSsdIOALdCaqDbr1n63tOpHCM0cFQuHTGwl7Abc4ZsDZtbSL3Cd X-Received: by 10.112.14.38 with SMTP id m6mr3610054lbc.12.1427891346795; Wed, 01 Apr 2015 05:29:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.67 with SMTP id o3ls57675laj.67.gmail; Wed, 01 Apr 2015 05:29:06 -0700 (PDT) X-Received: by 10.112.26.106 with SMTP id k10mr15481914lbg.23.1427891346649; Wed, 01 Apr 2015 05:29:06 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id f7si1479143lbs.25.2015.04.01.05.29.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Apr 2015 05:29:06 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by lajy8 with SMTP id y8so35169002laj.0 for ; Wed, 01 Apr 2015 05:29:06 -0700 (PDT) X-Received: by 10.152.8.161 with SMTP id s1mr26563281laa.41.1427891346205; Wed, 01 Apr 2015 05:29:06 -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.57.201 with SMTP id k9csp629634lbq; Wed, 1 Apr 2015 05:29:05 -0700 (PDT) X-Received: by 10.70.46.65 with SMTP id t1mr76351356pdm.128.1427891344173; Wed, 01 Apr 2015 05:29:04 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ep3si2648923pbd.133.2015.04.01.05.29.03; Wed, 01 Apr 2015 05:29:04 -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 S1753417AbbDAM2k (ORCPT + 5 others); Wed, 1 Apr 2015 08:28:40 -0400 Received: from mail-wg0-f41.google.com ([74.125.82.41]:34492 "EHLO mail-wg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753084AbbDAM2g (ORCPT ); Wed, 1 Apr 2015 08:28:36 -0400 Received: by wgbdm7 with SMTP id dm7so51563752wgb.1 for ; Wed, 01 Apr 2015 05:28:35 -0700 (PDT) X-Received: by 10.194.62.167 with SMTP id z7mr84454373wjr.106.1427891315635; Wed, 01 Apr 2015 05:28:35 -0700 (PDT) Received: from localhost.localdomain ([81.134.86.156]) by mx.google.com with ESMTPSA id lg18sm25254076wic.23.2015.04.01.05.28.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Apr 2015 05:28:34 -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 Subject: [PATCH v5 3/4] clk: Provide always-on clock support Date: Wed, 1 Apr 2015 13:28:23 +0100 Message-Id: <1427891304-20160-4-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1427891304-20160-1-git-send-email-lee.jones@linaro.org> References: <1427891304-20160-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.215.41 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..22b8fdd 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_by_clkspec(&clkspec); + if (IS_ERR(clk)) { + pr_err("clk: couldn't get clock %d for %s\n", + index, node->full_name); + return PTR_ERR(clk); + } + + ret = clk_prepare_enable(clk); + if (ret) { + pr_err("Failed to enable clock %d for %s: %d\n", + index, node->full_name, ret); + return ret; + } + + pr_debug("Set clock %s as always-on\n", __clk_get_name(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);