On 14/08/2025 7:31 pm, Frank Li wrote:
> On Thu, Aug 14, 2025 at 05:06:49PM +0100, James Clark wrote:
>> To avoid adding more string matching here for every new device, move
>> this property into devtype data.
>
> Add query_hw_for_num_cs in devtype to avoid directly check compatible
> "fsl,imx93-spi".
>
> No functionaltiy change.
>
> Frank
Ack
>>
>> Signed-off-by: James Clark <james.clark@linaro.org>
>> ---
>> drivers/spi/spi-fsl-lpspi.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
>> index 1013d5c994e9..6d0138b27785 100644
>> --- a/drivers/spi/spi-fsl-lpspi.c
>> +++ b/drivers/spi/spi-fsl-lpspi.c
>> @@ -97,6 +97,7 @@ static const char * const pincfgs[] = {
>>
>> struct fsl_lpspi_devtype_data {
>> bool prescale_err : 1;
>> + bool query_hw_for_num_cs : 1;
>> };
>>
>> struct lpspi_config {
>> @@ -150,10 +151,12 @@ struct fsl_lpspi_data {
>> */
>> static const struct fsl_lpspi_devtype_data imx93_lpspi_devtype_data = {
>> .prescale_err = true,
>> + .query_hw_for_num_cs = true,
>> };
>>
>> static const struct fsl_lpspi_devtype_data imx7ulp_lpspi_devtype_data = {
>> .prescale_err = false,
>> + .query_hw_for_num_cs = false,
>> };
>>
>> static const struct of_device_id fsl_lpspi_dt_ids[] = {
>> @@ -960,7 +963,7 @@ static int fsl_lpspi_probe(struct platform_device *pdev)
>> fsl_lpspi->rxfifosize = 1 << ((temp >> 8) & 0x0f);
>> if (of_property_read_u32((&pdev->dev)->of_node, "num-cs",
>> &num_cs)) {
>> - if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx93-spi"))
>> + if (devtype_data->query_hw_for_num_cs)
>> num_cs = ((temp >> 16) & 0xf);
>> else
>> num_cs = 1;
>>
>> --
>> 2.34.1
>>