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: 23422 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 08651203C6 for ; Mon, 20 Jan 2014 21:54:43 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id kq14sf18950324pab.5 for ; Mon, 20 Jan 2014 13:54:43 -0800 (PST) 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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=y28tH8RAJwWdBuVRUbJ/SBG9+C0R4W8pq5VpFCRsyOA=; b=isT+9CqLGspvg3moIOOGAW4pYbHH+l7Bd0/eZGoa/PTAvbEATnqMU6U3jZiO18SpwQ I7lQ4rw2vIPRmdwPm7AMmhN+eww9EWpWFG+UQdeyqOTu0EKPviTdXffGIqo/qVOWhhdE jGuanSZ4EBu/prdKvAnP7mrI7je9GcTboc1qOBd/yytLcbuvlDK13pXDvDvuWfYN3lKA QTrVFRw/UZmJVDsWAR25IFBdSMr8HMLu7j+mgMNz32yFIy5b2qMU7bvAyyuGbQBtloPy gqYaFu64ki515n/43YUdQ+8b2lggmHmBzoemKOy7+0grbUAiN9b1ggeQ5sv1YOvQFTlj Hxkw== X-Gm-Message-State: ALoCoQk2mGfgz7IptkHBdbI5BrRLFme6fNl53oI7zuEz3r5WnJ0sbrrXhveEHPTAon6iYEYI7U87 X-Received: by 10.66.6.1 with SMTP id w1mr7407449paw.6.1390254883286; Mon, 20 Jan 2014 13:54:43 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.14.4 with SMTP id l4ls490685qec.31.gmail; Mon, 20 Jan 2014 13:54:43 -0800 (PST) X-Received: by 10.58.37.232 with SMTP id b8mr1014664vek.27.1390254883068; Mon, 20 Jan 2014 13:54:43 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id dd4si820225vcb.145.2014.01.20.13.54.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 13:54:43 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so1160725veb.16 for ; Mon, 20 Jan 2014 13:54:43 -0800 (PST) X-Received: by 10.220.109.1 with SMTP id h1mr2901484vcp.20.1390254882925; Mon, 20 Jan 2014 13:54:42 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp78092vcz; Mon, 20 Jan 2014 13:54:42 -0800 (PST) X-Received: by 10.194.185.237 with SMTP id ff13mr200206wjc.64.1390254881908; Mon, 20 Jan 2014 13:54:41 -0800 (PST) Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46]) by mx.google.com with ESMTPS id p6si1836860wiw.65.2014.01.20.13.54.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jan 2014 13:54:41 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.46 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=74.125.82.46; Received: by mail-wg0-f46.google.com with SMTP id x12so7220310wgg.1 for ; Mon, 20 Jan 2014 13:54:41 -0800 (PST) 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 Cc: Russell King , Linus Walleij 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-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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,