From patchwork Sat Jul 1 20:04:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 9820961 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 4FE14603F2 for ; Sat, 1 Jul 2017 20:05:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 43CB42846A for ; Sat, 1 Jul 2017 20:05:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 269CF2844B; Sat, 1 Jul 2017 20:05: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=unavailable 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 9DF4C269E2 for ; Sat, 1 Jul 2017 20:05:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751998AbdGAUFj (ORCPT ); Sat, 1 Jul 2017 16:05:39 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:36737 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751919AbdGAUFh (ORCPT ); Sat, 1 Jul 2017 16:05:37 -0400 Received: by mail-wr0-f196.google.com with SMTP id 77so41606945wrb.3; Sat, 01 Jul 2017 13:05:37 -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=MIR+90VTotN37bu5k+O4AjMN5fRuK+qmtcYbxVXGqEU=; b=XU3iMoeRTKD8thWSlATdSiytv5dlqhpzCrB+UpforIjseLX4+uD+QlQdzCJHgE/082 57Az/qBAEJAgta/UuvNyTszxic79lIGK6M0MqxmBJip34KT9iyNjyLOtw1QsTdNTpVnN pA6fb8+0MZM3YyUPABrfl96zdDl9S2Aer3ILWVrcCDiRpexaailu5VtgMv24+Ge7siQH ErGbalQTRfYlOUB0DR8CO16E/FiLMStwDTgU/MhRpwNnwTT4KVlNyOzPn8Mo84/RDbHI rkGOjoDjajr8wjI3Rq/wxZQi5MvJfa8rPdthhL8lwpyA6n+YMR8/nw3J4dMxjIoiWMF+ 2lDA== 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=MIR+90VTotN37bu5k+O4AjMN5fRuK+qmtcYbxVXGqEU=; b=pFUynN+IztbLDaHgaUZx/0XKetZPymQJEH6Rcn7XaIYOkVv+uIRpikvwkZkFrUSIQ0 Jbq15aCMEAzxtDX3KnUocz9gvnr6wExU+RRTBPl6VDA75OFlCYyswndk+v+pP25r1AEO m6lc6HqUEXStTgJ5XtSPEIzKyY9k7+y9VEJcsglRzJO8WLuFg26fl4EvNx7OamsK3OV3 YhmR2bT8npB9cYOwqkQREnq9VXpiGPuU37Z5H0diz2HQ9lCZqx4SAJCTdJxCHASE4j+U d0pjZE1WXE01p+SgPnx1sWGrsVMfjx7nVg+GnfuNlbsxYeVfygEv7VpeaunO9xKBCOHy 7jNQ== X-Gm-Message-State: AKS2vOwyVWf4twR1W/NXjd5W9OntPY9QMOWBz1FpvLMYSb0kHLYo8Qnj R7C4kLNE7cuI7pFJ2Xs= X-Received: by 10.223.165.82 with SMTP id j18mr26956864wrb.45.1498939536064; Sat, 01 Jul 2017 13:05:36 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id s30sm18150137wrc.13.2017.07.01.13.05.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 01 Jul 2017 13:05:35 -0700 (PDT) From: Marek Vasut X-Google-Original-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: Sat, 1 Jul 2017 22:04:55 +0200 Message-Id: <20170701200459.11505-5-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170701200459.11505-1-marek.vasut+renesas@gmail.com> References: <20170701200459.11505-1-marek.vasut+renesas@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 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 Tested-by: Laurent Pinchart on Salvator-XS with the display LVDS output. --- 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 7bdfd34e8280..453c9f721b78 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, }; /* @@ -698,12 +706,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;