From: "qinjian[覃健]" <qinjian@cqplus1.com>
To: Stephen Boyd <sboyd@kernel.org>
Cc: "krzysztof.kozlowski@linaro.org" <krzysztof.kozlowski@linaro.org>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"mturquette@baylibre.com" <mturquette@baylibre.com>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"maz@kernel.org" <maz@kernel.org>,
"p.zabel@pengutronix.de" <p.zabel@pengutronix.de>,
"linux@armlinux.org.uk" <linux@armlinux.org.uk>,
"arnd@arndb.de" <arnd@arndb.de>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>
Subject: RE: [PATCH v15 05/10] clk: Add Sunplus SP7021 clock driver
Date: Tue, 17 May 2022 09:30:24 +0000 [thread overview]
Message-ID: <7febed72ae2747abb953a6f44a51102c@cqplus1.com> (raw)
In-Reply-To: <20220517021755.F1D05C385B8@smtp.kernel.org>
> > + nf = fvco * m_table[m];
> > + n = nf / F_27M;
> > + if ((n * F_27M) == nf)
> > + break;
> > + }
> > + m = m_table[m];
> > +
> > + if (!m) {
>
> This can be resolved with a 'return' from a subfunction or a goto.
Sorry, Could you explain more clear?
Did you means like:
If (!m) {
ret = -EINVAL;
goto err_not_found;
}
...
return freq;
err_not_found:
...
return ret;
}
>
> > + pr_err("%s: %s freq:%lu not found a valid setting\n",
> > + __func__, clk_hw_get_name(&clk->hw), freq);
> > + return -EINVAL;
> > + }
> > +
> > + /* save parameters */
> > + clk->p[SEL_FRA] = 0;
> > + clk->p[DIVR] = r;
> > + clk->p[DIVN] = n;
> > + clk->p[DIVM] = m;
> > +
> > + return freq;
> > +}
> > +
> > + df_quotient = df / m;
> > + df_remainder = ((df % m) * 1000) / m;
> > +
> > + if (freq > df_quotient) {
> > + df_quotient = freq - df_quotient - 1;
> > + df_remainder = 1000 - df_remainder;
>
> Where does 1000 come from?
1000 is come from "borrow 1" in last operation.
>
> > + } else {
> > + df_quotient = df_quotient - freq;
> > + }
> > +
> > +static int sp_pll_set_rate(struct clk_hw *hw, unsigned long rate,
> > + unsigned long prate)
> > +{
> > + struct sp_pll *clk = to_sp_pll(hw);
> > + unsigned long flags;
> > + u32 reg;
> > +
> > + spin_lock_irqsave(clk->lock, flags);
>
> Please push the lock down. Maybe that means having two conditionals?
> Either way, it is too large because it calls into plla_set_rate() and
> plltv_set_rate() with the lock held.
Sorry, I don't understand "push the lock down. Maybe that means having two conditionals?" what means.
The plla_set_rate() & plltv_set_rate() is only include simple operations & HW reg writes.
I think it should be called with lock held.
static void plla_set_rate(struct sp_pll *clk)
{
const u32 *pp = pa[clk->p[0]].regs;
int i;
for (i = 0; i < ARRAY_SIZE(pa->regs); i++)
writel(0xffff0000 | pp[i], clk->reg + (i * 4));
}
static void plltv_set_rate(struct sp_pll *clk)
{
u32 reg;
reg = HWM_FIELD_PREP(MASK_SEL_FRA, clk->p[SEL_FRA]);
reg |= HWM_FIELD_PREP(MASK_SDM_MOD, clk->p[SDM_MOD]);
reg |= HWM_FIELD_PREP(MASK_PH_SEL, clk->p[PH_SEL]);
reg |= HWM_FIELD_PREP(MASK_NFRA, clk->p[NFRA]);
writel(reg, clk->reg);
reg = HWM_FIELD_PREP(MASK_DIVR, clk->p[DIVR]);
writel(reg, clk->reg + 4);
reg = HWM_FIELD_PREP(MASK_DIVN, clk->p[DIVN] - 1);
reg |= HWM_FIELD_PREP(MASK_DIVM, clk->p[DIVM] - 1);
writel(reg, clk->reg + 8);
}
next prev parent reply other threads:[~2022-05-17 9:39 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-12 6:30 [PATCH v15 00/10] Add Sunplus SP7021 SoC Support Qin Jian
2022-05-12 6:30 ` [PATCH v15 01/10] dt-bindings: arm: sunplus: Add bindings for Sunplus SP7021 SoC boards Qin Jian
2022-05-16 18:29 ` Rob Herring
2022-05-12 6:30 ` [PATCH v15 02/10] dt-bindings: reset: Add bindings for SP7021 reset driver Qin Jian
2022-05-12 6:30 ` [PATCH v15 03/10] reset: Add Sunplus " Qin Jian
2022-05-12 6:30 ` [PATCH v15 04/10] dt-bindings: clock: Add bindings for SP7021 clock driver Qin Jian
2022-05-12 10:24 ` Krzysztof Kozlowski
2022-05-12 10:45 ` qinjian[覃健]
2022-05-12 10:54 ` Krzysztof Kozlowski
2022-05-13 3:22 ` qinjian[覃健]
2022-05-17 2:19 ` Stephen Boyd
2022-05-17 9:37 ` qinjian[覃健]
2022-05-12 6:31 ` [PATCH v15 05/10] clk: Add Sunplus " Qin Jian
2022-05-17 2:17 ` Stephen Boyd
2022-05-17 9:30 ` qinjian[覃健] [this message]
[not found] ` <20220518202049.6055BC385A9@smtp.kernel.org>
2022-05-19 2:16 ` qinjian[覃健]
2022-05-12 6:31 ` [PATCH v15 06/10] dt-bindings: interrupt-controller: Add bindings for SP7021 interrupt controller Qin Jian
2022-05-12 6:31 ` [PATCH v15 07/10] irqchip: Add Sunplus SP7021 interrupt controller driver Qin Jian
2022-05-12 6:31 ` [PATCH v15 08/10] ARM: sunplus: Add initial support for Sunplus SP7021 SoC Qin Jian
2022-05-12 6:31 ` [PATCH v15 09/10] ARM: sp7021_defconfig: Add Sunplus SP7021 defconfig Qin Jian
2022-05-13 11:27 ` Arnd Bergmann
2022-05-12 6:31 ` [PATCH v15 10/10] ARM: dts: Add Sunplus SP7021-Demo-V3 board device tree Qin Jian
2022-05-12 10:28 ` Krzysztof Kozlowski
2022-05-13 7:44 ` qinjian[覃健]
2022-05-13 8:10 ` Krzysztof Kozlowski
2022-05-13 9:47 ` qinjian[覃健]
2022-05-13 11:29 ` [PATCH v15 00/10] Add Sunplus SP7021 SoC Support Arnd Bergmann
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=7febed72ae2747abb953a6f44a51102c@cqplus1.com \
--to=qinjian@cqplus1.com \
--cc=arnd@arndb.de \
--cc=devicetree@vger.kernel.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=maz@kernel.org \
--cc=mturquette@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
--cc=sboyd@kernel.org \
--cc=tglx@linutronix.de \
/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