Re: [PATCH 1/8] spi: dt-bindings: Introduce spi-cs-setup-ns property

From: Tudor Ambarus
Date: Mon Jan 02 2023 - 07:11:27 EST




On 02.01.2023 13:48, Michael Walle wrote:
Hi,

Hi,


Am 2023-01-02 10:37, schrieb Tudor Ambarus:
Hi,

On 18.11.2022 17:30, Mark Brown wrote:
On Fri, Nov 18, 2022 at 03:14:58PM +0100, Michael Walle wrote:
From: Tudor Ambarus <tudor.ambarus@xxxxxxxxxxxxx>

+  spi-cs-setup-ns:
+    description:
+      Delay in nanosecods to be introduced by the controller after CS is
+      asserted.

Does this need a type as the spi-cs-setup-ns is apparently just 16bit? At
least the driver uses it that way.

But IMHO this should just be a normal uint32 value to be consistent with
all the other properties. Also the max value with 16bit will be 'just'
65us.

Making it 32 bit does seem safer.  I've applied the series

Thanks. There are few implications to consider before making this prop a
u32, and I'd like to check them with you.

struct spi_delay will have to be updated to have a u32 value, now it's a
u16. This means that we'll have to update spi_delay_to_ns() to either
return a s64 or to add a u64 *delay parameter to the function so that we
can still handle the conversions from usecs and the error codes in the
SPI_DELAY_UNIT_SCK case. Then all its callers have to be updated to
consider the u64 delay.

I was talking about the device tree property. Even if the driver continue
to use just 16bit, the DT property could be 32bit IMHO.

but then you'll have an implicit cast to u16 at:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/spi/spi.c#n2314
which will make the u32 dt prop misleading.


At the moment, the schema says its 32bit (if I'm not mistaken, because
it doesn't have a type), but the driver will parse the property as
16bit and your device tree also has this /bits/ thingy. So regardless
if the driver is using 16bit or 32bit for the value, there seems to be
a discrepancy between the schema and the devicetree (and driver).

okay, thanks for pointing it out. Let's decide how we fix this.


All other properties are just the regular 32bit values, thus I was
suggesting to change the DT property to 32bit.

If we want to change the dt prop to 32bit I think we should also handle
the parsed value as u32, not as u16.