From: Vinod Koul <vkoul@kernel.org>
To: Stephen Boyd <sboyd@kernel.org>
Cc: Michael Turquette <mturquette@baylibre.com>,
Khasim Syed Mohammed <khasim.mohammed@linaro.org>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Taniya Das <tdas@codeaurora.org>,
Andy Gross <andy.gross@linaro.org>,
David Brown <david.brown@linaro.org>,
linux-arm-msm@vger.kernel.org, linux-clk@vger.kernel.org,
Anu Ramanathan <anur@codeaurora.org>,
Shawn Guo <shawn.guo@linaro.org>
Subject: Re: [PATCH 1/2] clk: qcom: clk-rcg2: Introduce a cfg offset for RCGs
Date: Wed, 30 Jan 2019 10:04:43 +0530 [thread overview]
Message-ID: <20190130043443.GD4635@vkoul-mobl> (raw)
In-Reply-To: <154880173887.136743.11486618909610624058@swboyd.mtv.corp.google.com>
On 29-01-19, 14:42, Stephen Boyd wrote:
> Quoting Vinod Koul (2019-01-28 03:53:58)
> > diff --git a/drivers/clk/qcom/clk-rcg.h b/drivers/clk/qcom/clk-rcg.h
> > index e5eca8a1abe4..f06783c20688 100644
> > --- a/drivers/clk/qcom/clk-rcg.h
> > +++ b/drivers/clk/qcom/clk-rcg.h
> > @@ -140,6 +140,7 @@ extern const struct clk_ops clk_dyn_rcg_ops;
> > * @parent_map: map from software's parent index to hardware's src_sel field
> > * @freq_tbl: frequency table
> > * @clkr: regmap clock handle
> > + * @cfg_off: defines the cfg register offset from the CMD_RCGR
> > *
>
> Please remove this extra line here. Also, shouldn't it say offset from
> CMD_RCGR + CFG_REG?
Sure but I dont like to mix so will send that as a separate patch :)
and will update the comment too.
>
>
> > */
> > struct clk_rcg2 {
> > @@ -150,6 +151,7 @@ struct clk_rcg2 {
> > const struct parent_map *parent_map;
> > const struct freq_tbl *freq_tbl;
> > struct clk_regmap clkr;
> > + u8 cfg_off;
> > };
> >
> > #define to_clk_rcg2(_hw) container_of(to_clk_regmap(_hw), struct clk_rcg2, clkr)
> > diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c
> > index 6e3bd195d012..106848e3313f 100644
> > --- a/drivers/clk/qcom/clk-rcg2.c
> > +++ b/drivers/clk/qcom/clk-rcg2.c
> > @@ -74,7 +74,8 @@ static u8 clk_rcg2_get_parent(struct clk_hw *hw)
> > u32 cfg;
> > int i, ret;
> >
> > - ret = regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + CFG_REG, &cfg);
> > + ret = regmap_read(rcg->clkr.regmap,
> > + rcg->cmd_rcgr + rcg->cfg_off + CFG_REG, &cfg);
>
> Maybe we should define CFG_REG as CFG_REG(rcg) and then do the math
> there?
>
> #define CFG_REG(rcg) (rcg)->cfg_off + 0x4
Sure that looks better
>
> > if (ret)
> > goto err;
> >
> > @@ -263,17 +268,20 @@ static int __clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f)
> > if (rcg->mnd_width && f->n) {
> > mask = BIT(rcg->mnd_width) - 1;
> > ret = regmap_update_bits(rcg->clkr.regmap,
> > - rcg->cmd_rcgr + M_REG, mask, f->m);
> > + rcg->cmd_rcgr + rcg->cfg_off + M_REG,
> > + mask, f->m);
> > if (ret)
> > return ret;
> >
> > ret = regmap_update_bits(rcg->clkr.regmap,
> > - rcg->cmd_rcgr + N_REG, mask, ~(f->n - f->m));
> > + rcg->cmd_rcgr + rcg->cfg_off + N_REG,
> > + mask, ~(f->n - f->m));
> > if (ret)
> > return ret;
> >
> > ret = regmap_update_bits(rcg->clkr.regmap,
> > - rcg->cmd_rcgr + D_REG, mask, ~f->n);
> > + rcg->cmd_rcgr + rcg->cfg_off + D_REG,
> > + mask, ~f->n);
>
> Ah the MND registers also move. Wow that's so sad. Do a similar thing
> for all these too?
>
> #define D_REG(rcg) (rcg)->cfg_off + 0x8
> etc...
>
> All just to make things fit on the same number of lines as before! We
> could also throw the rcg->cmd_rcgr part into the register named macros
> to make things even shorter. It was mostly OK when it was just adding
> the offset to the base, but now we have another offset so I think we can
> roll it all into the macro so that we can just read "regmap_read
> FOO_REG" and ignore the rest.
Correct that will make it neater, will do so
--
~Vinod
prev parent reply other threads:[~2019-01-30 4:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-28 11:53 [PATCH 1/2] clk: qcom: clk-rcg2: Introduce a cfg offset for RCGs Vinod Koul
2019-01-28 11:53 ` [PATCH 2/2] clk: qcom: gcc-qcs404: Add cfg_offset for blsp1_uart3 clock Vinod Koul
2019-01-29 22:42 ` Stephen Boyd
2019-01-29 22:42 ` [PATCH 1/2] clk: qcom: clk-rcg2: Introduce a cfg offset for RCGs Stephen Boyd
2019-01-30 4:34 ` Vinod Koul [this message]
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=20190130043443.GD4635@vkoul-mobl \
--to=vkoul@kernel.org \
--cc=andy.gross@linaro.org \
--cc=anur@codeaurora.org \
--cc=bjorn.andersson@linaro.org \
--cc=david.brown@linaro.org \
--cc=khasim.mohammed@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
--cc=shawn.guo@linaro.org \
--cc=tdas@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;
as well as URLs for NNTP newsgroup(s).