From patchwork Thu Jun 29 10:18:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 9816345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 68AB76020A for ; Thu, 29 Jun 2017 10:19:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5CBAE285D9 for ; Thu, 29 Jun 2017 10:19:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 503882869C; Thu, 29 Jun 2017 10:19:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF1032869A for ; Thu, 29 Jun 2017 10:19:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752582AbdF2KTk (ORCPT ); Thu, 29 Jun 2017 06:19:40 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:36431 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752551AbdF2KTj (ORCPT ); Thu, 29 Jun 2017 06:19:39 -0400 Received: by mail-wr0-f195.google.com with SMTP id 77so36340365wrb.3; Thu, 29 Jun 2017 03:19:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DjB0TKJeu5xCtfXqaivIqBp6QAal/ckvUjxLilc5/Vk=; b=FH8YApE6opabh/8xBbUCdWS4P72TYLhhxMNWKooKxa8Eypyf2cvmPzXi6VfgTXkFqE sBolY3wUH8yq+sBdl49Y5+lOniuvAEtb5skNk3N9zRqNjGHsKJrYCJswMJ5SanG6pMIB fh/G/n3Qz7+A/P3LM4baDllpNJtbLK3kc9btWtKL9kfgpg0QtmzgS/f4wbypvgS0BMyu YXH3xUKUGbUezxxRlR7yeQka+xp071n8gTVFqzQtfhphpASyicnjIQDSUoXbpiWKO7YY xUlxpiKJhfGb2pBZLvvhIj9arbFpXBPxV98XTbJEszV2pK85GY90+ItotoyqUafih6tY UGrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DjB0TKJeu5xCtfXqaivIqBp6QAal/ckvUjxLilc5/Vk=; b=sAMQFrh9B5gHA3kNtXPAccRJ4ejRPLzlXvs0rnKzb4HlVk+eRBJnXGrcJYcTw8HqmP +pPvvQHetEjgHRM5gsvoD28/IvWBWPjm2F2xZOQ/Ca0GWaUdqeGRRB/RClU0XTGpMaBa VKuZ1pGYG2/CeBKyyXMczdGa5m+v4A7DBkw3bnHDobyyJIB3IQKF67NmA/l6UoaHvWdJ EIM1+/VFCUmAM5WqGLH6Pw9HJ/ATc+nby+ZejYSNv6JXr4uYwajJjA1u7TBxdASrm4t5 0sAqrjncnT7AftRftC1J7XcoIkk1rty61g446taQCNgwFg1sI4PHGCKsnexlIn2sMtuT X9kQ== X-Gm-Message-State: AKS2vOy7lDsw1Ks5qcx9EczUMlzCMNFVwxWKFdlHfeHvI635T63IsRUm /S8Z+JufpjN580+cE1M= X-Received: by 10.223.149.33 with SMTP id 30mr20821002wrs.186.1498731577333; Thu, 29 Jun 2017 03:19:37 -0700 (PDT) Received: from chi.lan (cst-prg-169-255.cust.vodafone.cz. [46.135.169.255]) by smtp.gmail.com with ESMTPSA id t74sm7623653wmt.19.2017.06.29.03.19.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Jun 2017 03:19:36 -0700 (PDT) From: Marek Vasut To: linux-clk@vger.kernel.org Cc: Marek Vasut , Stephen Boyd , Alexey Firago , Michael Turquette , Laurent Pinchart , linux-renesas-soc@vger.kernel.org Subject: [PATCH 5/8] clk: vc5: Split clock input mux and predivider Date: Thu, 29 Jun 2017 12:18:48 +0200 Message-Id: <20170629101851.23972-5-marek.vasut@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170629101851.23972-1-marek.vasut@gmail.com> References: <20170629101851.23972-1-marek.vasut@gmail.com> Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marek Vasut Split the VC5 clock input mux and the predivider to more accurately model the hardware and fix the previously incorrect assumption that both the OUT_SEL_I2CB and the PLL are fed from the predivider. It is in fact the clock input mux output which is directly feeding the clock into the OUT_SEL_I2CB output, while the clock input mux output first passes through the predivider before it is fed into the PLL. Signed-off-by: Marek Vasut Cc: Stephen Boyd Cc: Alexey Firago Cc: Michael Turquette Cc: Laurent Pinchart Cc: linux-renesas-soc@vger.kernel.org --- drivers/clk/clk-versaclock5.c | 46 ++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/drivers/clk/clk-versaclock5.c b/drivers/clk/clk-versaclock5.c index a5256f793627..fcde42393997 100644 --- a/drivers/clk/clk-versaclock5.c +++ b/drivers/clk/clk-versaclock5.c @@ -157,6 +157,7 @@ struct vc5_driver_data { struct clk *pin_clkin; unsigned char clk_mux_ins; struct clk_hw clk_mux; + struct clk_hw clk_pfd; struct vc5_hw_data clk_pll; struct vc5_hw_data clk_fod[VC5_MAX_FOD_NUM]; struct vc5_hw_data clk_out[VC5_MAX_CLK_OUT_NUM]; @@ -166,6 +167,10 @@ static const char * const vc5_mux_names[] = { "mux" }; +static const char * const vc5_pfd_names[] = { + "pfd" +}; + static const char * const vc5_pll_names[] = { "pll" }; @@ -254,11 +259,16 @@ static int vc5_mux_set_parent(struct clk_hw *hw, u8 index) return regmap_update_bits(vc5->regmap, VC5_PRIM_SRC_SHDN, mask, src); } -static unsigned long vc5_mux_recalc_rate(struct clk_hw *hw, +static const struct clk_ops vc5_mux_ops = { + .set_parent = vc5_mux_set_parent, + .get_parent = vc5_mux_get_parent, +}; + +static unsigned long vc5_pfd_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) { struct vc5_driver_data *vc5 = - container_of(hw, struct vc5_driver_data, clk_mux); + container_of(hw, struct vc5_driver_data, clk_pfd); unsigned int prediv, div; regmap_read(vc5->regmap, VC5_VCO_CTRL_AND_PREDIV, &prediv); @@ -276,7 +286,7 @@ static unsigned long vc5_mux_recalc_rate(struct clk_hw *hw, return parent_rate / VC5_REF_DIVIDER_REF_DIV(div); } -static long vc5_mux_round_rate(struct clk_hw *hw, unsigned long rate, +static long vc5_pfd_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long *parent_rate) { unsigned long idiv; @@ -296,11 +306,11 @@ static long vc5_mux_round_rate(struct clk_hw *hw, unsigned long rate, return *parent_rate / idiv; } -static int vc5_mux_set_rate(struct clk_hw *hw, unsigned long rate, +static int vc5_pfd_set_rate(struct clk_hw *hw, unsigned long rate, unsigned long parent_rate) { struct vc5_driver_data *vc5 = - container_of(hw, struct vc5_driver_data, clk_mux); + container_of(hw, struct vc5_driver_data, clk_pfd); unsigned long idiv; u8 div; @@ -328,12 +338,10 @@ static int vc5_mux_set_rate(struct clk_hw *hw, unsigned long rate, return 0; } -static const struct clk_ops vc5_mux_ops = { - .set_parent = vc5_mux_set_parent, - .get_parent = vc5_mux_get_parent, - .recalc_rate = vc5_mux_recalc_rate, - .round_rate = vc5_mux_round_rate, - .set_rate = vc5_mux_set_rate, +static const struct clk_ops vc5_pfd_ops = { + .recalc_rate = vc5_pfd_recalc_rate, + .round_rate = vc5_pfd_round_rate, + .set_rate = vc5_pfd_set_rate, }; /* @@ -699,12 +707,26 @@ static int vc5_probe(struct i2c_client *client, goto err_clk; } + /* Register PFD */ + memset(&init, 0, sizeof(init)); + init.name = vc5_pfd_names[0]; + init.ops = &vc5_pfd_ops; + init.flags = CLK_SET_RATE_PARENT; + init.parent_names = vc5_mux_names; + init.num_parents = 1; + vc5->clk_pfd.init = &init; + ret = devm_clk_hw_register(&client->dev, &vc5->clk_pfd); + if (ret) { + dev_err(&client->dev, "unable to register %s\n", init.name); + goto err_clk; + } + /* Register PLL */ memset(&init, 0, sizeof(init)); init.name = vc5_pll_names[0]; init.ops = &vc5_pll_ops; init.flags = CLK_SET_RATE_PARENT; - init.parent_names = vc5_mux_names; + init.parent_names = vc5_pfd_names; init.num_parents = 1; vc5->clk_pll.num = 0; vc5->clk_pll.vc5 = vc5;