From: Alex Elder <elder@riscstar.com>
To: Lorenzo Bianconi <lorenzo.bianconi@oss.qualcomm.com>
Cc: sboyd@kernel.org, bmasney+clk@redhat.com,
jbrunet+clk@baylibre.com, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, p.zabel@pengutronix.de,
andersson@kernel.org, konradybcio@kernel.org,
abelvesa@kernel.org, daniel@riscstar.com,
mohd.anwar@oss.qualcomm.com, fabrice.gasnier@foss.st.com,
alexandre.torgue@foss.st.com, marex@nabladev.com,
changhuang.liang@starfivetech.com, devicetree@vger.kernel.org,
linux-clk@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] clk: toshiba: introduce a TC9564 clock/reset driver
Date: Fri, 27 Nov 2026 13:20:56 -0600 [thread overview]
Message-ID: <5f389412-a036-4792-bdd9-e86377ee7e44@riscstar.com> (raw)
In-Reply-To: <awgCFMH6xerE510f@lore-desk>
On 11/26/26 3:55 AM, Lorenzo Bianconi wrote:
> On Nov 25, Alex Elder wrote:
>> Define a new platform driver that manages clocks and resets implemented
>> by the Toshiba TC9564 SoC. There are 21 gate clocks that can be enabled
>> and disabled, but currently only the clocks that are (or will soon be)
>> used are defined to be controllable. There are also 13 resets that can
>> be asserted or deasserted, but support for some of these is omitted as
>> well.
>>
>> Two registers manage the state of the clocks, and two others manage
>> the state of the resets. All four registers are found in a region
>> mapped for MMIO. The region is provided via a BAR on one of the PCI
>> functions embedded in the TC9564 SoC.
>>
>> The I2C and PCIE clocks and resets are treated as CRITICAL, meaning their
>> state should never be changed (and a warning is issued if changing their
>> state is attempted).
>>
>> Co-developed-by: Daniel Thompson <daniel@riscstar.com>
>> Signed-off-by: Daniel Thompson <daniel@riscstar.com>
>> Signed-off-by: Alex Elder <elder@riscstar.com>
>> ---
>> v3: - Fixed problems/garbage in the patch header
>> - The Kconfig option now depends on RESET_CONTROLLER, and can now
>> be enabled if COMPILE_TEST is enabled
>> - The generic gate clock controller code is now used rather than
>> implementing a custom one
>> - The PLL and internal fixed clocks IDs are no longer available
>> outside "clk-tc9564.c"
>> - The PLL is initialialized, followed by all fixed rate clocks,
>> followed by the gate clocks, to ensure each clock's parent is
>> initialized before the clock is
>> - Updating the reset registers (read/modify/write) is now protected
>> by a spinlock
>> - "Unnecessary newlines" have been removed
. . .
>> +struct tc9564_clock {
>> + void __iomem *ioaddr; /* Mapped clock/reset registers */
>> + spinlock_t lock; /* Protects reset register updates */
>> + struct clk_hw_onecell_data *clk_data;
>
> I think it would be more readable to have 3 different pointers here:
> - struct clk_hw_onecell_data *clk_pll_data;
> - struct clk_hw_onecell_data *clk_fixed_rate_data;
> - struct clk_hw_onecell_data *clk_gate_data;
>
> (using the same logic you implemented for fixed_init, gate_init stucts).
>
> Doing so, I guess the code that is allocating the clock data would be
> easier to manage.
I don't know that it's easier but it would avoid keeping
track of the difference between array indexes and identifiers.
I think I was trying to avoid registering three different
providers, but I think you're right, the result will be
simpler and more readable.
The PLL is a single clock, so it will be more like:
struct clk_hw *pll_hw;
So I will implement your suggestion.
>
>> + struct reset_controller_dev rcdev;
>> +};
>> +
>> +/* Indexes into the fixed_init[] array */
>> +enum fixed_clock {
>> + CLOCK_62_5M,
>> + CLOCK_125M,
>> + CLOCK_250M,
>> + CLOCK_312_5M,
>> +};
. . .
>> +/* Caller must free the returned pointer if non-null */
>> +static const char *clock_name(struct device *dev, const char *name)
>> +{
>> + return kasprintf(GFP_KERNEL, "%s-%s", dev_name(dev), name);
>> +}
>
> nit: clock_name() is running just during probe, I would prefer to use
> dev_kasprintf() instead and get rid of the related kfree(). Moreover,
> clock_name() is just a wrapper around kasprintf(), do we really need it?
I think you mean devm_kasprintf(), but I still don't like keeping
that allocated memory around for every clock for the entire life
of the device. It's just a waste.
What I'll do, to get rid of what seems like a weird kfree() call,
*and* avoid having the allocated memory hang on longer than needed
is have all the callers do something like this:
const char *name __free(kfree) = clock_name(dev, "pll");
I do agree it's a simple wrapper but it's used in three places to
create a consistent name, so I prefer to keep it.
>> +/* Initialize the PLL (parent is the input oscillator); called from probe */
>> +static int pll_init(struct device *dev, struct tc9564_clock *clock)
>> +{
>> + struct clk_hw *hw;
>> + const char *name;
>> +
>> + /* Initialize the PLL clock first (input oscillator is parent) */
>> + name = clock_name(dev, "pll");
>> + if (!name)
>> + return -ENOMEM;
>> +
>> + hw = devm_clk_hw_register_fixed_factor_index(dev, name, 0, 0, 50, 1);
>> + kfree(name);
>> + if (IS_ERR(hw))
>> + return dev_err_probe(dev, PTR_ERR(hw),
>> + "failed to register pll\n");
>> +
>> + clock->clk_data->hws[CLOCK_PLL] = hw;
>> +
>> + return 0;
>> +}
Thanks for the review.
-Alex
next prev parent reply other threads:[~2026-11-27 19:20 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 20:21 [PATCH v3 0/3] clk: tc9564: introduce a clock and reset driver Alex Elder
2026-11-25 20:21 ` [PATCH v3 1/3] dt-bindings: toshiba: introduce toshiba,tc9564-clock.yaml Alex Elder
2026-11-27 18:01 ` Jerome Brunet
2026-11-30 18:47 ` Alex Elder
2026-11-25 20:21 ` [PATCH v3 2/3] clk: toshiba: introduce a TC9564 clock/reset driver Alex Elder
2026-11-26 9:42 ` Philipp Zabel
2026-11-26 12:59 ` Alex Elder
2026-11-26 17:19 ` Philipp Zabel
2026-11-26 9:55 ` Lorenzo Bianconi
2026-11-27 19:20 ` Alex Elder [this message]
2026-11-27 18:01 ` Jerome Brunet
2026-11-30 18:47 ` Alex Elder
2026-11-25 20:21 ` [PATCH v3 3/3] arm64: dts: qcom: qcs6490-rb3gen2: add TC9564 clock node Alex Elder
2026-11-25 20:28 ` sashiko-bot
2026-11-25 21:51 ` Alex Elder
2026-11-26 10:01 ` Lorenzo Bianconi
2026-11-25 20:33 ` [PATCH v3 0/3] clk: tc9564: introduce a clock and reset driver Alex Elder
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=5f389412-a036-4792-bdd9-e86377ee7e44@riscstar.com \
--to=elder@riscstar.com \
--cc=abelvesa@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andersson@kernel.org \
--cc=bmasney+clk@redhat.com \
--cc=changhuang.liang@starfivetech.com \
--cc=conor+dt@kernel.org \
--cc=daniel@riscstar.com \
--cc=devicetree@vger.kernel.org \
--cc=fabrice.gasnier@foss.st.com \
--cc=jbrunet+clk@baylibre.com \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.bianconi@oss.qualcomm.com \
--cc=marex@nabladev.com \
--cc=mohd.anwar@oss.qualcomm.com \
--cc=p.zabel@pengutronix.de \
--cc=robh@kernel.org \
--cc=sboyd@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.