lkml.org 
[lkml]   [2021]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe:
From
Hi,

On 11/2/21 22:16, Stephen Boyd wrote:
> Quoting Hans de Goede (2021-11-02 02:49:01)
>> diff --git a/drivers/clk/clk-tps68470.c b/drivers/clk/clk-tps68470.c
>> new file mode 100644
>> index 000000000000..2ad0ac2f4096
>> --- /dev/null
>> +++ b/drivers/clk/clk-tps68470.c
>> @@ -0,0 +1,257 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/*
>> + * Clock driver for TPS68470 PMIC
>> + *
>> + * Copyright (c) 2021 Red Hat Inc.
>> + * Copyright (C) 2018 Intel Corporation
>> + *
>> + * Authors:
>> + * Hans de Goede <hdegoede@redhat.com>
>> + * Zaikuo Wang <zaikuo.wang@intel.com>
>> + * Tianshu Qiu <tian.shu.qiu@intel.com>
>> + * Jian Xu Zheng <jian.xu.zheng@intel.com>
>> + * Yuning Pu <yuning.pu@intel.com>
>> + * Antti Laakso <antti.laakso@intel.com>
>> + */
>> +
>> +#include <linux/clk-provider.h>
>> +#include <linux/clkdev.h>
>> +#include <linux/kernel.h>
>> +#include <linux/mfd/tps68470.h>
>> +#include <linux/module.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/platform_data/tps68470.h>
>> +#include <linux/regmap.h>
>> +
>> +#define TPS68470_CLK_NAME "tps68470-clk"
>> +
>> +#define to_tps68470_clkdata(clkd) \
>> + container_of(clkd, struct tps68470_clkdata, clkout_hw)
>> +
> [...]
>> +
>> +static int tps68470_clk_set_rate(struct clk_hw *hw, unsigned long rate,
>> + unsigned long parent_rate)
>> +{
>> + struct tps68470_clkdata *clkdata = to_tps68470_clkdata(hw);
>> + unsigned int idx = tps68470_clk_cfg_lookup(rate);
>> +
>> + if (rate != clk_freqs[idx].freq)
>> + return -EINVAL;
>> +
>> + clkdata->clk_cfg_idx = idx;
>
> It deserves a comment that set_rate can only be called when the clk is
> gated. We have CLK_SET_RATE_GATE flag as well that should be set if the
> clk can't support changing rate while enabled. With that flag set, this
> function should be able to actually change hardware with the assumption
> that the framework won't call down into this clk_op when the clk is
> enabled.

Ok for v6 I've added the CLK_SET_RATE_GATE flag + a comment why
it used and moved the divider programming to tps68470_clk_set_rate()m
while keeping the PLL_EN + output-enable writes in tps68470_clk_prepare()


>
>> +
>> + return 0;
>> +}
>> +
>> +static const struct clk_ops tps68470_clk_ops = {
>> + .is_prepared = tps68470_clk_is_prepared,
>> + .prepare = tps68470_clk_prepare,
>> + .unprepare = tps68470_clk_unprepare,
>> + .recalc_rate = tps68470_clk_recalc_rate,
>> + .round_rate = tps68470_clk_round_rate,
>> + .set_rate = tps68470_clk_set_rate,
>> +};
>> +
>> +static const struct clk_init_data tps68470_clk_initdata = {
>
> Is there a reason to make this a static global? It's probably better to
> throw it on the stack so that a structure isn't sitting around after
> driver probe being unused.

Fixed for v6.

Thanks & Regards,

Hans


>
>> + .name = TPS68470_CLK_NAME,
>> + .ops = &tps68470_clk_ops,
>> +};
>

\
 
 \ /
  Last update: 2021-11-25 16:04    [W:0.136 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site