[<prev] [next>] [day] [month] [year] [list]
Message-ID: <09cdb0bd-56f6-d0fe-c35a-ed86c5919b4d@redhat.com>
Date: Thu, 25 Nov 2021 16:01:38 +0100
From: Hans de Goede <hdegoede@...hat.com>
To: Stephen Boyd <sboyd@...nel.org>,
Andy Shevchenko <andy@...radead.org>,
Daniel Scally <djrscally@...il.com>,
Laurent Pinchart <laurent.pinchart@...asonboard.com>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Mark Gross <markgross@...nel.org>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Michael Turquette <mturquette@...libre.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
"Rafael J.Wysocki" <rjw@...ysocki.net>,
Wolfram Sang <wsa@...-dreams.de>
Cc: Len Brown <lenb@...nel.org>, linux-acpi@...r.kernel.org,
platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-i2c@...r.kernel.org,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
Kate Hsuan <hpa@...hat.com>, linux-media@...r.kernel.org,
linux-clk@...r.kernel.org
Subject: Re:
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@...hat.com>
>> + * Zaikuo Wang <zaikuo.wang@...el.com>
>> + * Tianshu Qiu <tian.shu.qiu@...el.com>
>> + * Jian Xu Zheng <jian.xu.zheng@...el.com>
>> + * Yuning Pu <yuning.pu@...el.com>
>> + * Antti Laakso <antti.laakso@...el.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,
>> +};
>
Powered by blists - more mailing lists