Re: [PATCH v6 1/8] power: sequencing: Add T-HEAD TH1520 GPU power sequencer driver
From: Michal Wilczynski
Date: Mon Jun 23 2025 - 13:21:10 EST
On 6/23/25 16:32, Bartosz Golaszewski wrote:
> On Mon, Jun 23, 2025 at 1:44 PM Michal Wilczynski
> <m.wilczynski@xxxxxxxxxxx> wrote:
>>
>> Introduce the pwrseq-thead-gpu driver, a power sequencer provider for
>> the Imagination BXM-4-64 GPU on the T-HEAD TH1520 SoC. This driver
>> controls an auxiliary device instantiated by the AON power domain.
>>
>> The TH1520 GPU requires a specific sequence to correctly initialize and
>> power down its resources:
>> - Enable GPU clocks (core and sys).
>> - De-assert the GPU clock generator reset (clkgen_reset).
>> - Introduce a short hardware-required delay.
>> - De-assert the GPU core reset. The power-down sequence performs these
>> steps in reverse.
>>
>> Implement this sequence via the pwrseq_power_on and pwrseq_power_off
>> callbacks.
>>
>> Crucially, the driver's match function is called when a consumer (the
>> Imagination GPU driver) requests the "gpu-power" target. During this
>> match, the sequencer uses clk_bulk_get() and
>> reset_control_get_exclusive() on the consumer's device to obtain handles
>> to the GPU's "core" and "sys" clocks, and the GPU core reset. These,
>> along with clkgen_reset obtained from parent aon node, allow it to
>> perform the complete sequence.
>>
>> Reviewed-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
>> Signed-off-by: Michal Wilczynski <m.wilczynski@xxxxxxxxxxx>
>> ---
>
> [snip]
>
>> +
>> + /* Additionally verify consumer device has AON as power-domain */
>> + if (pwr_spec.np != ctx->aon_node || pwr_spec.args[0] != TH1520_GPU_PD) {
>> + of_node_put(pwr_spec.np);
>> + return 0;
>> + }
>> +
>> + of_node_put(pwr_spec.np);
>> +
>> + /* If a consumer is already bound, only allow a re-match from it */
>> + if (ctx->consumer_node)
>> + return ctx->consumer_node == dev->of_node;
>> +
>
> That should be `!!(ctx->consumer_node == dev->of_node)` or preferably
> `ctx->consumer_node == dev->of_node ? 1 : 0`. I can amend it when
> applying if you have no objections. The rest looks good to me and I'd
> like to pick it up into pwrseq/for-next in the next two days.
Sure,
Thanks !
>
> Bart
>
> [snip]
>
Best regards,
--
Michal Wilczynski <m.wilczynski@xxxxxxxxxxx>