From: Stephen Boyd <sboyd@codeaurora.org>
To: Abhishek Sahu <absahu@codeaurora.org>, mturquette@baylibre.com
Cc: andy.gross@linaro.org, david.brown@linaro.org,
rnayak@codeaurora.org, linux-arm-msm@vger.kernel.org,
linux-soc@vger.kernel.org, linux-clk@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC 01/12] clk: qcom: support for register offsets from rcg2 clock node
Date: Thu, 27 Jul 2017 11:44:55 -0700 [thread overview]
Message-ID: <4b660d7f-17ba-e5a6-3f48-13eeb1d9f02c@codeaurora.org> (raw)
In-Reply-To: <1501153825-5181-2-git-send-email-absahu@codeaurora.org>
On 07/27/2017 04:10 AM, Abhishek Sahu wrote:
> The current driver hardcodes the RCG2 register offsets. Some of
> the RCG2’s use different offsets from the default one.
>
> This patch adds the support to provide the register offsets array in
> RCG2 clock node. If RCG2 clock node contains the register offsets
> then this will be used instead of default one.
>
> Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
> ---
> drivers/clk/qcom/clk-rcg.h | 11 +++++++
> drivers/clk/qcom/clk-rcg2.c | 78 ++++++++++++++++++++++++++++-----------------
> 2 files changed, 60 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/clk/qcom/clk-rcg.h b/drivers/clk/qcom/clk-rcg.h
> index 1b3e8d2..54add3b 100644
> --- a/drivers/clk/qcom/clk-rcg.h
> +++ b/drivers/clk/qcom/clk-rcg.h
> @@ -17,6 +17,14 @@
> #include <linux/clk-provider.h>
> #include "clk-regmap.h"
>
> +enum {
> + CLK_RCG2_CMD,
> + CLK_RCG2_CFG,
> + CLK_RCG2_M,
> + CLK_RCG2_N,
> + CLK_RCG2_D,
> +};
> +
> struct freq_tbl {
> unsigned long freq;
> u8 src;
> @@ -154,6 +162,8 @@ struct clk_dyn_rcg {
> * @cmd_rcgr: corresponds to *_CMD_RCGR
> * @mnd_width: number of bits in m/n/d values
> * @hid_width: number of bits in half integer divider
> + * @offsets: offsets of RCG2 register from cmd_rcgr.
> + * default will be used in case of null
> * @parent_map: map from software's parent index to hardware's src_sel field
> * @freq_tbl: frequency table
> * @current_freq: last cached frequency when using branches with shared RCGs
> @@ -164,6 +174,7 @@ struct clk_rcg2 {
> u32 cmd_rcgr;
> u8 mnd_width;
> u8 hid_width;
> + const u8 *offsets;
> const struct parent_map *parent_map;
> const struct freq_tbl *freq_tbl;
> unsigned long current_freq;
> diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
> index 1a0985a..7e1c8aa 100644
> --- a/drivers/clk/qcom/clk-rcg2.c
> +++ b/drivers/clk/qcom/clk-rcg2.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright (c) 2013, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
> *
> * This software is licensed under the terms of the GNU General Public
> * License version 2, as published by the Free Software Foundation, and
> @@ -26,7 +26,6 @@
> #include "clk-rcg.h"
> #include "common.h"
>
> -#define CMD_REG 0x0
> #define CMD_UPDATE BIT(0)
> #define CMD_ROOT_EN BIT(1)
> #define CMD_DIRTY_CFG BIT(4)
> @@ -35,7 +34,6 @@
> #define CMD_DIRTY_D BIT(7)
> #define CMD_ROOT_OFF BIT(31)
>
> -#define CFG_REG 0x4
> #define CFG_SRC_DIV_SHIFT 0
> #define CFG_SRC_SEL_SHIFT 8
> #define CFG_SRC_SEL_MASK (0x7 << CFG_SRC_SEL_SHIFT)
> @@ -43,22 +41,34 @@
> #define CFG_MODE_MASK (0x3 << CFG_MODE_SHIFT)
> #define CFG_MODE_DUAL_EDGE (0x2 << CFG_MODE_SHIFT)
>
> -#define M_REG 0x8
> -#define N_REG 0xc
> -#define D_REG 0x10
> +#define rcg2_cmd(rcg, offsets) (rcg->cmd_rcgr)
> +#define rcg2_cfg(rcg, offsets) (rcg->cmd_rcgr + offsets[CLK_RCG2_CFG])
> +#define rcg2_m(rcg, offsets) (rcg->cmd_rcgr + offsets[CLK_RCG2_M])
> +#define rcg2_n(rcg, offsets) (rcg->cmd_rcgr + offsets[CLK_RCG2_N])
> +#define rcg2_d(rcg, offsets) (rcg->cmd_rcgr + offsets[CLK_RCG2_D])
> +
> +#define to_rcg2_offsets(rcg) (rcg->offsets ? \
> + rcg->offsets : rcg2_default_offsets)
>
> enum freq_policy {
> FLOOR,
> CEIL,
> };
>
> +static const u8 rcg2_default_offsets[] = {
> + [CLK_RCG2_CFG] = 0x4,
> + [CLK_RCG2_M] = 0x8,
> + [CLK_RCG2_N] = 0xc,
> + [CLK_RCG2_D] = 0x10,
> +};
It looks like the two UBI clks that messed this up don't have an MN
counter, so instead of doing this maddness, just add a flag like
m_is_cfg and then make a rcg2_crmd() function that checks this flag and
returns cmd_rcg + CFG_REG or cmd_rgcr + M_REG depending on the flag. We
can also optimize further, and ifdef this whole branch out unless the
specific IPQ GCC driver is enabled. Also only update the generic RCG
code, and not the display/gpu specific ones. Then the diff is much
smaller, and we can go yell at hardware team to never do this again.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2017-07-27 18:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-27 11:10 [RFC 00/12] Misc patches for QCOM clocks Abhishek Sahu
2017-07-27 11:10 ` [RFC 01/12] clk: qcom: support for register offsets from rcg2 clock node Abhishek Sahu
2017-07-27 18:44 ` Stephen Boyd [this message]
2017-07-28 9:42 ` Abhishek Sahu
2017-07-28 17:55 ` Stephen Boyd
2017-07-30 12:57 ` Abhishek Sahu
2017-07-27 11:10 ` [RFC 02/12] clk: qcom: flag for 64 bit CONFIG_CTL Abhishek Sahu
2017-07-28 18:33 ` Stephen Boyd
2017-07-30 13:04 ` Abhishek Sahu
2017-08-01 21:17 ` Stephen Boyd
2017-07-27 11:10 ` [RFC 03/12] clk: qcom: support for alpha mode configuration Abhishek Sahu
2017-07-27 11:10 ` [RFC 04/12] clk: qcom: use offset from alpha pll node Abhishek Sahu
2017-07-30 13:26 ` Abhishek Sahu
2017-07-27 11:10 ` [RFC 05/12] clk: qcom: fix 16 bit alpha support calculation Abhishek Sahu
2017-07-27 11:10 ` [RFC 06/12] Clk: qcom: support for dynamic updating the PLL Abhishek Sahu
2017-07-28 18:34 ` Stephen Boyd
2017-07-30 13:57 ` Abhishek Sahu
2017-08-01 21:12 ` Stephen Boyd
2017-08-02 13:50 ` Abhishek Sahu
2017-07-27 11:10 ` [RFC 07/12] clk: qcom: add flag for VCO operation Abhishek Sahu
2017-07-27 11:10 ` [RFC 08/12] clk: qcom: support for Huayra PLL Abhishek Sahu
2017-07-27 11:10 ` [RFC 09/12] clk: qcom: support for Brammo PLL Abhishek Sahu
2017-07-27 11:10 ` [RFC 10/12] clk: qcom: add read-only divider operations Abhishek Sahu
2017-07-27 11:10 ` [RFC 11/12] clk: qcom: add read-only alpha pll post " Abhishek Sahu
2017-07-27 11:10 ` [RFC 12/12] clk: qcom: add parent map for regmap mux Abhishek Sahu
2017-07-27 18:39 ` [RFC 00/12] Misc patches for QCOM clocks Stephen Boyd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4b660d7f-17ba-e5a6-3f48-13eeb1d9f02c@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=absahu@codeaurora.org \
--cc=andy.gross@linaro.org \
--cc=david.brown@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-soc@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=rnayak@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome