From patchwork Thu Nov 13 13:20:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kever Yang X-Patchwork-Id: 5296921 Return-Path: X-Original-To: patchwork-linux-rockchip@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4B88A9F2F1 for ; Thu, 13 Nov 2014 13:21:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 77095201F5 for ; Thu, 13 Nov 2014 13:21:53 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6D8C5201C7 for ; Thu, 13 Nov 2014 13:21:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XouLG-0005kU-VJ; Thu, 13 Nov 2014 13:21:43 +0000 Received: from mail-pd0-x236.google.com ([2607:f8b0:400e:c02::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XouLF-0005L7-5p for linux-rockchip@lists.infradead.org; Thu, 13 Nov 2014 13:21:41 +0000 Received: by mail-pd0-f182.google.com with SMTP id fp1so14603308pdb.27 for ; Thu, 13 Nov 2014 05:21:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=If3P+uejz3lNqN+cKrYZmyI/7/u7N773VXWIppTG+3Q=; b=uYS2RufrE5t7DWo+qeOnavSZB40l022najyZIpqSsd51UimHDxlNK7pRy647pPf3rP UCzzmTwQPUtTlgtk/iBCgjKWFxYj77BAHB17iUGc8vGhsWo8mcONJtJveR6AwjNRFjIG Omcf/zhQnylacus90+qkE40GclLaf8x1WNvgTK86cgekWRD5b5gHbjaJSfRQHUiIJ/Te 4QauLnrP9K2XkyWhaScJmY8aP+lNpymRiWQZjKDl94Aa5z2phHvJC/tR57hp/sQyw73I sFu32gFBFV7MQBoFnI6UcL3NJQRtyEQLPRinOQfAUYw2m/+t9tquFT7d/kgXwix1Aotu 09Bg== X-Received: by 10.68.135.33 with SMTP id pp1mr2589975pbb.120.1415884880169; Thu, 13 Nov 2014 05:21:20 -0800 (PST) Received: from localhost.localdomain ([173.44.135.206]) by mx.google.com with ESMTPSA id r3sm24912122pds.57.2014.11.13.05.21.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 13 Nov 2014 05:21:18 -0800 (PST) From: Kever Yang To: Mike Turquette , Heiko Stuebner Subject: [RFC PATCH 1/2] clk: add property for force to update clock setting Date: Thu, 13 Nov 2014 21:20:25 +0800 Message-Id: <1415884826-7877-2-git-send-email-kever.yang@rock-chips.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415884826-7877-1-git-send-email-kever.yang@rock-chips.com> References: <1415884826-7877-1-git-send-email-kever.yang@rock-chips.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141113_052141_253005_4DA46E6D X-CRM114-Status: GOOD ( 13.50 ) X-Spam-Score: -0.7 (/) Cc: huangtao@rock-chips.com, dkl@rock-chips.com, addy.ke@rock-chips.com, linux-kernel@vger.kernel.org, dianders@chromium.org, Kever Yang , linux-rockchip@lists.infradead.org, cf@rock-chips.com, sonnyrao@chromium.org X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Usually we assigned a clock to a default rate in dts, there is a situation that the clock already initialized to the rate we intend to set before kernel(hardware default or init in uboot etc). For the PLLs we can get a rate from different PLL parameter configure, we can't change the PLL parameter if the rate is not changed by now. This patch adds a option property 'assigned-clock-force-rates' to make sure we update all the setting even if we don't need to update the clock rate. Signed-off-by: Kever Yang --- drivers/clk/clk-conf.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c index aad4796..0c9df48 100644 --- a/drivers/clk/clk-conf.c +++ b/drivers/clk/clk-conf.c @@ -84,7 +84,7 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier) struct clk *clk; u32 rate; - of_property_for_each_u32(node, "assigned-clock-rates", prop, cur, rate) { + of_property_for_each_u32(node, "assigned-force-rates", prop, cur, rate) { if (rate) { rc = of_parse_phandle_with_args(node, "assigned-clocks", "#clock-cells", index, &clkspec); @@ -104,7 +104,38 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier) index, node->full_name); return PTR_ERR(clk); } + /* change the old rate to 0 to make sure we can get into + * clk_change_rate */ + clk->rate = 0; + rc = clk_set_rate(clk, rate); + if (rc < 0) + pr_err("clk: couldn't set %s clock rate: %d\n", + __clk_get_name(clk), rc); + clk_put(clk); + } + index++; + } + of_property_for_each_u32(node, "assigned-clock-rates", prop, cur, rate) { + if (rate) { + rc = of_parse_phandle_with_args(node, "assigned-clocks", + "#clock-cells", index, &clkspec); + if (rc < 0) { + /* skip empty (null) phandles */ + if (rc == -ENOENT) + continue; + else + return rc; + } + if (clkspec.np == node && !clk_supplier) + return 0; + + clk = of_clk_get_by_clkspec(&clkspec); + if (IS_ERR(clk)) { + pr_warn("clk: couldn't get clock %d for %s\n", + index, node->full_name); + return PTR_ERR(clk); + } rc = clk_set_rate(clk, rate); if (rc < 0) pr_err("clk: couldn't set %s clock rate: %d\n",