From patchwork Mon Jan 20 21:54:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 3514701 Return-Path: X-Original-To: patchwork-linux-arm@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 124979F1C3 for ; Mon, 20 Jan 2014 21:56:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 343E62015A for ; Mon, 20 Jan 2014 21:56:04 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 221A220122 for ; Mon, 20 Jan 2014 21:56:03 +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 1W5Moa-0000oN-3U; Mon, 20 Jan 2014 21:55:28 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W5MoF-0004ji-2o; Mon, 20 Jan 2014 21:55:07 +0000 Received: from mail-we0-f178.google.com ([74.125.82.178]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W5MoB-0004ip-VO for linux-arm-kernel@lists.infradead.org; Mon, 20 Jan 2014 21:55:04 +0000 Received: by mail-we0-f178.google.com with SMTP id t60so7332325wes.37 for ; Mon, 20 Jan 2014 13:54:41 -0800 (PST) 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; bh=y28tH8RAJwWdBuVRUbJ/SBG9+C0R4W8pq5VpFCRsyOA=; b=C6p14PXhpHWR1IP919EpJ11M/wVAOMkjMGEkSY/OIt2PCoZwr4hVScX+Y8z/N2R4sU 5vJtJXnSq8JiowroQkB1TdW8i3/ImCFwvSisZhwcEPXAQb2aXIWRNGDc/1s0KoQ1jjqt VYbHQTGDSmhkxrEu4F9P4IAbyiAeEt6+l1Bwdycf7gwtG3IV+CEnXO4rhtO7zKgUVdb7 JE+6S7MTuqy7mtqrwiB9B4Sii+16mgPQrb0Mag9cS5+x54XjLAnnep4Cjzp/zLnHCIRS ZCPoHRtt+S47RgoAlgyvkDLm0YDZLL1F1foK+eGixgFdhbKrBytWLioyok0V1ZlY8Qss dgdQ== X-Gm-Message-State: ALoCoQnAH4sqCAhr8Amt9tosm7FEG5oYnqRtHCKH3IvUoWj3yxOHap1JJd742g7I3O4T454esXpx X-Received: by 10.194.175.202 with SMTP id cc10mr7507408wjc.48.1390254881428; Mon, 20 Jan 2014 13:54:41 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id w1sm28509437wix.1.2014.01.20.13.54.39 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jan 2014 13:54:40 -0800 (PST) From: Linus Walleij To: linux-arm-kernel@lists.infradead.org, Mike Turquette Subject: [PATCH 5/5 v2] clk: versatile: respect parent rate in ICST clock Date: Mon, 20 Jan 2014 22:54:25 +0100 Message-Id: <1390254865-15488-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.4.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140120_165504_116145_5242286E X-CRM114-Status: GOOD ( 15.49 ) X-Spam-Score: -2.6 (--) Cc: Linus Walleij , Russell King 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: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 If the ICST clock has a parent, respect the rate of the parent when calculating the clock frequency. As this involves modifying the ICST parameter struct, make a cloned copy (the divisor arrays should be safe) so we can update the .ref field. Do not define the reference clock on the Integrator as we have the reference clock from the device tree. Keep it everywhere else. Cc: Mike Turquette Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - As Russell observed: the params are static objects, so if we want to alter them, we better make a copy of them. Hi Mike, looking for an ACK for this one as well. --- drivers/clk/versatile/clk-icst.c | 20 ++++++++++++++++---- drivers/clk/versatile/clk-integrator.c | 1 - 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/clk/versatile/clk-icst.c b/drivers/clk/versatile/clk-icst.c index c98adbe62733..a820b0cfcf57 100644 --- a/drivers/clk/versatile/clk-icst.c +++ b/drivers/clk/versatile/clk-icst.c @@ -33,7 +33,7 @@ struct clk_icst { struct clk_hw hw; void __iomem *vcoreg; void __iomem *lockreg; - const struct icst_params *params; + struct icst_params *params; unsigned long rate; }; @@ -84,6 +84,8 @@ static unsigned long icst_recalc_rate(struct clk_hw *hw, struct clk_icst *icst = to_icst(hw); struct icst_vco vco; + if (parent_rate) + icst->params->ref = parent_rate; vco = vco_get(icst->vcoreg); icst->rate = icst_hz(icst->params, vco); return icst->rate; @@ -105,6 +107,8 @@ static int icst_set_rate(struct clk_hw *hw, unsigned long rate, struct clk_icst *icst = to_icst(hw); struct icst_vco vco; + if (parent_rate) + icst->params->ref = parent_rate; vco = icst_hz_to_vco(icst->params, rate); icst->rate = icst_hz(icst->params, vco); vco_set(icst->lockreg, icst->vcoreg, vco); @@ -126,19 +130,27 @@ struct clk *icst_clk_register(struct device *dev, struct clk *clk; struct clk_icst *icst; struct clk_init_data init; + struct icst_params *pclone; icst = kzalloc(sizeof(struct clk_icst), GFP_KERNEL); if (!icst) { pr_err("could not allocate ICST clock!\n"); return ERR_PTR(-ENOMEM); } + + pclone = kmemdup(desc->params, sizeof(*pclone), GFP_KERNEL); + if (!pclone) { + pr_err("could not clone ICST params\n"); + return ERR_PTR(-ENOMEM); + } + init.name = name; init.ops = &icst_ops; init.flags = CLK_IS_ROOT; - init.parent_names = NULL; - init.num_parents = 0; + init.parent_names = (parent_name ? &parent_name : NULL); + init.num_parents = (parent_name ? 1 : 0); icst->hw.init = &init; - icst->params = desc->params; + icst->params = pclone; icst->vcoreg = base + desc->vco_offset; icst->lockreg = base + desc->lock_offset; diff --git a/drivers/clk/versatile/clk-integrator.c b/drivers/clk/versatile/clk-integrator.c index 5d36a719fefb..734c4b8fe6ab 100644 --- a/drivers/clk/versatile/clk-integrator.c +++ b/drivers/clk/versatile/clk-integrator.c @@ -21,7 +21,6 @@ static void __iomem *cm_base; static const struct icst_params cp_auxosc_params = { - .ref = 24000000, .vco_max = ICST525_VCO_MAX_5V, .vco_min = ICST525_VCO_MIN, .vd_min = 8,