spi: SPI core CS delay fixes and additions
Merge series from Hector Martin <marcan@marcan.st>: Commitsf6c911f330
("spi: dt-bindings: Introduce spi-cs-setup-ns property") and33a2fde5f7
("spi: Introduce spi-cs-setup-ns property") introduced a new property to represent the CS setup delay in the device tree, but they have some issues: - The property is only parsed as a 16-bit integer number of nanoseconds, which limits the maximum value to ~65us. This is not a reasonable upper limit, as some devices might need a lot more. - The property name is inconsistent with other delay properties, which use a "*-delay-ns" naming scheme. - Only the setup delay is introduced, but not the related hold and inactive delay times. This series fixes the issues and adds support for the two missing properties. Please pull in the first 3 patches as fixes for 6.2, to avoid introducing a problematic DT API in this release. The last two patches can wait until 6.3, though are probably harmless to throw in as fixes too, since they're trivial.
This commit is contained in:
commit
c5d808691c
@ -49,6 +49,16 @@ properties:
|
||||
Delay in nanoseconds to be introduced by the controller after CS is
|
||||
asserted.
|
||||
|
||||
spi-cs-hold-delay-ns:
|
||||
description:
|
||||
Delay in nanoseconds to be introduced by the controller before CS is
|
||||
de-asserted.
|
||||
|
||||
spi-cs-inactive-delay-ns:
|
||||
description:
|
||||
Delay in nanoseconds to be introduced by the controller after CS is
|
||||
de-asserted.
|
||||
|
||||
spi-rx-bus-width:
|
||||
description:
|
||||
Bus width to the SPI bus used for read transfers.
|
||||
|
@ -2220,11 +2220,26 @@ void spi_flush_queue(struct spi_controller *ctlr)
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
#if defined(CONFIG_OF)
|
||||
static void of_spi_parse_dt_cs_delay(struct device_node *nc,
|
||||
struct spi_delay *delay, const char *prop)
|
||||
{
|
||||
u32 value;
|
||||
|
||||
if (!of_property_read_u32(nc, prop, &value)) {
|
||||
if (value > U16_MAX) {
|
||||
delay->value = DIV_ROUND_UP(value, 1000);
|
||||
delay->unit = SPI_DELAY_UNIT_USECS;
|
||||
} else {
|
||||
delay->value = value;
|
||||
delay->unit = SPI_DELAY_UNIT_NSECS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
|
||||
struct device_node *nc)
|
||||
{
|
||||
u32 value;
|
||||
u16 cs_setup;
|
||||
int rc;
|
||||
|
||||
/* Mode (clock phase/polarity/etc.) */
|
||||
@ -2310,10 +2325,10 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
|
||||
if (!of_property_read_u32(nc, "spi-max-frequency", &value))
|
||||
spi->max_speed_hz = value;
|
||||
|
||||
if (!of_property_read_u16(nc, "spi-cs-setup-delay-ns", &cs_setup)) {
|
||||
spi->cs_setup.value = cs_setup;
|
||||
spi->cs_setup.unit = SPI_DELAY_UNIT_NSECS;
|
||||
}
|
||||
/* Device CS delays */
|
||||
of_spi_parse_dt_cs_delay(nc, &spi->cs_setup, "spi-cs-setup-delay-ns");
|
||||
of_spi_parse_dt_cs_delay(nc, &spi->cs_hold, "spi-cs-hold-delay-ns");
|
||||
of_spi_parse_dt_cs_delay(nc, &spi->cs_inactive, "spi-cs-inactive-delay-ns");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user