From patchwork Sun Sep 15 00:37:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Emilio_L=C3=B3pez?= X-Patchwork-Id: 2893951 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EBF64BFF05 for ; Sun, 15 Sep 2013 00:39:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EA099202C0 for ; Sun, 15 Sep 2013 00:39:21 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B05EF202BE for ; Sun, 15 Sep 2013 00:39:20 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VL0Mr-00029G-Mr; Sun, 15 Sep 2013 00:39:13 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VL0Mp-0005FS-LU; Sun, 15 Sep 2013 00:39:11 +0000 Received: from zetta.elopez.com.ar ([199.30.59.35]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VL0Mm-0005EI-1U for linux-arm-kernel@lists.infradead.org; Sun, 15 Sep 2013 00:39:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=elopez.com.ar; s=mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:Date:Subject:Cc:To:From; bh=OqO/SPy+KnQUSERRTjLNoSUXq34u2WkSlfSnCfH7vto=; b=vVkLXjjGkvxgTt+x5vhODoLomrGQe+1HdF+JOQ75ugZsyYpo+jrD0jQtpS+2UEML61QEX3Xc1xH4OATzHPwEIQWW6SEB74ykGMzy1dPwUHZBU6uEtgBI9j6d9WXjMhUkSNnWyjpzDqPo27dxU2iBBWZC+k2JI/5qj36tUxu1mrrgb54jinoMQBYTRt0K+yXfbWEH5SOwgfRUj9JG8Smiqb6Ak4JqT9QD2xrORNfVo2NP1hNt5D+vdCzsNYGU4EDL+RxRKfcuXreEb/SxwTfRK/tNZsAz1hvuik/qadrr4ljyF5ZBF1V4Opu69pUgLPpoqGY5Z3r+GGCDrzEfEO95vA==; Received: from 201-212-126-35.prima.net.ar ([201.212.126.35] helo=desktop.lan) by zetta.elopez.com.ar with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) id 1VL0MM-0003mp-1h; Sat, 14 Sep 2013 21:38:42 -0300 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= To: Mike Turquette Subject: [PATCH] clk: composite: .determine_rate support Date: Sat, 14 Sep 2013 21:37:59 -0300 Message-Id: <1379205479-26001-1-git-send-email-emilio@elopez.com.ar> X-Mailer: git-send-email 1.8.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130914_203908_206863_0932C35A X-CRM114-Status: GOOD ( 11.88 ) X-Spam-Score: -2.9 (--) Cc: =?UTF-8?q?Emilio=20L=C3=B3pez?= , pgaikwad@nvidia.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,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 This commit adds .determine_rate support to the composite clock. It will use the .determine_rate callback from the rate component if available, and fall back on the mux component otherwise. This allows composite clocks to enjoy the benefits of automatic clock reparenting. Signed-off-by: Emilio López --- Hi Mike, This is a prerequisite patch for the sunxi driver changes that I'll send shortly; I believe you already looked at this diff on IRC and agreed it was sensible, so I hope it can be merged early for the 3.13 cycle (unless someone else has any objections to the patch, that is). Cheers, Emilio drivers/clk/clk-composite.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c index a33f46f..753d0b7 100644 --- a/drivers/clk/clk-composite.c +++ b/drivers/clk/clk-composite.c @@ -55,6 +55,30 @@ static unsigned long clk_composite_recalc_rate(struct clk_hw *hw, return rate_ops->recalc_rate(rate_hw, parent_rate); } +static long clk_composite_determine_rate(struct clk_hw *hw, unsigned long rate, + unsigned long *best_parent_rate, + struct clk **best_parent_p) +{ + struct clk_composite *composite = to_clk_composite(hw); + const struct clk_ops *rate_ops = composite->rate_ops; + const struct clk_ops *mux_ops = composite->mux_ops; + struct clk_hw *rate_hw = composite->rate_hw; + struct clk_hw *mux_hw = composite->mux_hw; + + if (rate_hw && rate_ops && rate_ops->determine_rate) { + rate_hw->clk = hw->clk; + return rate_ops->determine_rate(rate_hw, rate, best_parent_rate, + best_parent_p); + } else if (mux_hw && mux_ops && mux_ops->determine_rate) { + mux_hw->clk = hw->clk; + return mux_ops->determine_rate(rate_hw, rate, best_parent_rate, + best_parent_p); + } else { + pr_err("clk: clk_composite_determine_rate function called, but no mux or rate callback set!\n"); + return 0; + } +} + static long clk_composite_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *prate) { @@ -147,6 +171,8 @@ struct clk *clk_register_composite(struct device *dev, const char *name, composite->mux_ops = mux_ops; clk_composite_ops->get_parent = clk_composite_get_parent; clk_composite_ops->set_parent = clk_composite_set_parent; + if (mux_ops->determine_rate) + clk_composite_ops->determine_rate = clk_composite_determine_rate; } if (rate_hw && rate_ops) { @@ -170,6 +196,8 @@ struct clk *clk_register_composite(struct device *dev, const char *name, composite->rate_hw = rate_hw; composite->rate_ops = rate_ops; clk_composite_ops->recalc_rate = clk_composite_recalc_rate; + if (rate_ops->determine_rate) + clk_composite_ops->determine_rate = clk_composite_determine_rate; } if (gate_hw && gate_ops) {