Re: [PATCH v4 5/7] clk: Introduce davinci clocks

From: Sekhar Nori
Date: Thu Jan 04 2018 - 07:29:45 EST


On Wednesday 03 January 2018 03:01 AM, David Lechner wrote:
> Forgot to cc linux-clk, so doing that now...
>
>
> On 12/31/2017 05:39 PM, David Lechner wrote:
>> This introduces new drivers for arch/arm/mach-davinci. The code is based
>> on the clock drivers from there and adapted to use the common clock
>> framework.
>>
>> Signed-off-by: David Lechner <david@xxxxxxxxxxxxxx>
>> ---
>> Â drivers/clk/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ |ÂÂ 1 +
>> Â drivers/clk/davinci/MakefileÂÂÂÂÂÂÂÂÂÂÂÂÂ |ÂÂ 3 +
>> Â drivers/clk/davinci/da8xx-cfgchip-clk.cÂÂ | 380
>> ++++++++++++++++++++++++++++++
>> Â drivers/clk/davinci/pll.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ | 333
>> ++++++++++++++++++++++++++
>> Â drivers/clk/davinci/psc.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ | 217 +++++++++++++++++
>> Â include/linux/clk/davinci.hÂÂÂÂÂÂÂÂÂÂÂÂÂÂ |Â 46 ++++
>> Â include/linux/platform_data/davinci_clk.h |Â 25 ++
>> Â 7 files changed, 1005 insertions(+)

This is a pretty huge patch and I think each of cfgchip, pll and PSC
clocks deserve a patch of their own.

On the PLL patch, please describe how the PLL implementation on DaVinci
is different from Keystone, so no reuse is really possible. Similarly
for the PSC patch (no non-DT support in keystone etc).

>> diff --git a/drivers/clk/davinci/psc.c b/drivers/clk/davinci/psc.c
>> new file mode 100644
>> index 0000000..8ae85ee
>> --- /dev/null
>> +++ b/drivers/clk/davinci/psc.c
>> @@ -0,0 +1,217 @@

>> +static void psc_config(struct davinci_psc_clk *psc,
>> +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ enum davinci_psc_state next_state)
>> +{
>> +ÂÂÂ u32 epcpr, ptcmd, pdstat, pdctl, mdstat, mdctl, ptstat;
>> +
>> +ÂÂÂ mdctl = readl(psc->base + MDCTL + 4 * psc->lpsc);
>> +ÂÂÂ mdctl &= ~MDSTAT_STATE_MASK;
>> +ÂÂÂ mdctl |= next_state;
>> +ÂÂÂ /* TODO: old davinci clocks for da850 set MDCTL_FORCE bit for
>> sata and
>> +ÂÂÂÂ * dsp here. Is this really needed?
>> +ÂÂÂÂ */
>> +ÂÂÂ writel(mdctl, psc->base + MDCTL + 4 * psc->lpsc);
>> +
>> +ÂÂÂ pdstat = readl(psc->base + PDSTAT + 4 * psc->pd);
>> +ÂÂÂ if ((pdstat & PDSTAT_STATE_MASK) == 0) {
>> +ÂÂÂÂÂÂÂ pdctl = readl(psc->base + PDSTAT + 4 * psc->pd);
>> +ÂÂÂÂÂÂÂ pdctl |= PDCTL_NEXT;
>> +ÂÂÂÂÂÂÂ writel(pdctl, psc->base + PDSTAT + 4 * psc->pd);
>> +
>> +ÂÂÂÂÂÂÂ ptcmd = BIT(psc->pd);
>> +ÂÂÂÂÂÂÂ writel(ptcmd, psc->base + PTCMD);
>> +
>> +ÂÂÂÂÂÂÂ do {
>> +ÂÂÂÂÂÂÂÂÂÂÂ epcpr = __raw_readl(psc->base + EPCPR);
>> +ÂÂÂÂÂÂÂ } while (!(epcpr & BIT(psc->pd)));
>> +
>> +ÂÂÂÂÂÂÂ pdctl = __raw_readl(psc->base + PDCTL + 4 * psc->pd);
>> +ÂÂÂÂÂÂÂ pdctl |= PDCTL_EPCGOOD;
>> +ÂÂÂÂÂÂÂ __raw_writel(pdctl, psc->base + PDCTL + 4 * psc->pd);

Can we shift to regmap here too? Then the polling loops like above can
be converted to regmap_read_poll_timeout() too like you have done elsewhere.

Thanks,
Sekhar