Linux-RISC-V Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@riscstar.com>
To: Frank Li <Frank.li@nxp.com>
Cc: han.xu@nxp.com, broonie@kernel.org, dlan@gentoo.org,
	guodong@riscstar.com, linux-spi@vger.kernel.org,
	imx@lists.linux.dev, spacemit@lists.linux.dev,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/8] spi: fsl-qspi: add a clock disable quirk
Date: Tue, 21 Oct 2025 23:34:23 -0500	[thread overview]
Message-ID: <d13590f1-937d-4ef6-8d2f-d0647557b695@riscstar.com> (raw)
In-Reply-To: <aPaJ479zH/90fJ2d@lizhi-Precision-Tower-5810>

On 10/20/25 2:13 PM, Frank Li wrote:
> On Mon, Oct 20, 2025 at 11:51:47AM -0500, Alex Elder wrote:
>> The SpacemiT K1 SoC QSPI implementation needs to avoid shutting
>> off the clock when changing its rate.  Add a new quirk to indicate
>> the clock should not be disabled/enabled when changing its rate
>> for operations.
>>
>> Signed-off-by: Alex Elder <elder@riscstar.com>
>> ---
>>   drivers/spi/spi-fsl-qspi.c | 21 +++++++++++++++++----
>>   1 file changed, 17 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/spi/spi-fsl-qspi.c b/drivers/spi/spi-fsl-qspi.c
>> index 1e27647dd2a09..703a7df394c00 100644
>> --- a/drivers/spi/spi-fsl-qspi.c
>> +++ b/drivers/spi/spi-fsl-qspi.c
>> @@ -197,6 +197,11 @@
>>    */
>>   #define QUADSPI_QUIRK_USE_TDH_SETTING	BIT(5)
>>
>> +/*
>> + * Do not disable the "qspi" clock when changing its rate.
>> + */
>> +#define QUADSPI_QUIRK_NO_CLK_DISABLE	BIT(6)
> 
> NO_CLK_DISALBE look likes not clk disable capability. Maybe
> 
> QUADSPI_QUIRK_SKIP_CLK_DISABLE

OK, that's better.

> 
>> +
>>   struct fsl_qspi_devtype_data {
>>   	unsigned int rxfifo;
>>   	unsigned int txfifo;
>> @@ -306,6 +311,11 @@ static inline int needs_tdh_setting(struct fsl_qspi *q)
>>   	return q->devtype_data->quirks & QUADSPI_QUIRK_USE_TDH_SETTING;
>>   }
>>
>> +static inline int needs_clk_disable(struct fsl_qspi *q)
> 
> bool type?

Yes I agree with this suggestion.  However all of the other
needs_*() functions return int and are marked inline (neither
of which I would normally do).

You want me to add a patch to update the others too?  If I
do that it will look more like this:

static bool needs_swap_endian(struct fsl_qspi *q)
{
         return !!(q->devtype_data->quirks & QUADSPI_QUIRK_SWAP_ENDIAN);
}


					-Alex

> 
> Frank
> 
>> +{
>> +	return !(q->devtype_data->quirks & QUADSPI_QUIRK_NO_CLK_DISABLE);
>> +}
>> +
>>   /*
>>    * An IC bug makes it necessary to rearrange the 32-bit data.
>>    * Later chips, such as IMX6SLX, have fixed this bug.
>> @@ -536,15 +546,18 @@ static void fsl_qspi_select_mem(struct fsl_qspi *q, struct spi_device *spi,
>>   	if (needs_4x_clock(q))
>>   		rate *= 4;
>>
>> -	fsl_qspi_clk_disable_unprep(q);
>> +	if (needs_clk_disable(q))
>> +		fsl_qspi_clk_disable_unprep(q);
>>
>>   	ret = clk_set_rate(q->clk, rate);
>>   	if (ret)
>>   		return;
>>
>> -	ret = fsl_qspi_clk_prep_enable(q);
>> -	if (ret)
>> -		return;
>> +	if (needs_clk_disable(q)) {
>> +		ret = fsl_qspi_clk_prep_enable(q);
>> +		if (ret)
>> +			return;
>> +	}
>>
>>   	q->selected = spi_get_chipselect(spi, 0);
>>
>> --
>> 2.48.1
>>


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2025-10-22  4:34 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-20 16:51 [PATCH 0/8] spi: enable the SpacemiT K1 SoC QSPI Alex Elder
2025-10-20 16:51 ` [PATCH 1/8] dt-bindings: spi: fsl-qspi: add optional resets Alex Elder
2025-10-20 17:44   ` Conor Dooley
2025-10-20 18:06     ` Alex Elder
2025-10-20 16:51 ` [PATCH 2/8] dt-bindings: spi: fsl-qspi: support SpacemiT K1 Alex Elder
2025-10-20 17:39   ` Conor Dooley
2025-10-20 18:06     ` Alex Elder
2025-10-20 18:26       ` Mark Brown
2025-10-20 18:37         ` Alex Elder
2025-10-20 18:39         ` Conor Dooley
2025-10-22  4:34           ` Alex Elder
2025-10-20 17:41   ` Conor Dooley
2025-10-20 18:06     ` Alex Elder
2025-10-20 18:41       ` Conor Dooley
2025-10-20 16:51 ` [PATCH 3/8] spi: fsl-qspi: add optional reset support Alex Elder
2025-10-20 19:07   ` Frank Li
2025-10-22  4:34     ` Alex Elder
2025-10-20 16:51 ` [PATCH 4/8] spi: fsl-qspi: add a clock disable quirk Alex Elder
2025-10-20 19:13   ` Frank Li
2025-10-22  4:34     ` Alex Elder [this message]
2025-10-20 16:51 ` [PATCH 5/8] spi: fsl-qspi: allot 1KB per chip Alex Elder
2025-10-20 19:20   ` Frank Li
2025-10-22  4:34     ` Alex Elder
2025-10-20 16:51 ` [PATCH 6/8] spi: fsl-qspi: support the SpacemiT K1 SoC Alex Elder
2025-10-20 19:23   ` Frank Li
2025-10-22  4:34     ` Alex Elder
2025-10-20 16:51 ` [PATCH 7/8] riscv: dts: spacemit: enable K1 SoC QSPI on BPI-F3 Alex Elder
2025-10-20 16:51 ` [PATCH 8/8] riscv: defconfig: enable SPI_FSL_QUADSPI as a module 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=d13590f1-937d-4ef6-8d2f-d0647557b695@riscstar.com \
    --to=elder@riscstar.com \
    --cc=Frank.li@nxp.com \
    --cc=broonie@kernel.org \
    --cc=dlan@gentoo.org \
    --cc=guodong@riscstar.com \
    --cc=han.xu@nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=spacemit@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox