* [PATCH v2 0/3] SPI core CS delay fixes and additions
@ 2023-01-13 10:23 Hector Martin
2023-01-13 10:23 ` [PATCH v2 1/3] spi: Use a 32-bit DT property for spi-cs-setup-delay-ns Hector Martin
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Hector Martin @ 2023-01-13 10:23 UTC (permalink / raw)
To: Mark Brown
Cc: Rob Herring, Krzysztof Kozlowski, Tudor Ambarus, linux-spi,
devicetree, Janne Grunau, Alyssa Rosenzweig, asahi, linux-kernel,
Hector Martin
Commits f6c911f3308c ("spi: dt-bindings: Introduce
spi-cs-setup-ns property") and 33a2fde5f77b ("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.
v2: Removed a stray variable declaration that was triggering a warning,
and dropped the first two patches which have already been applied.
Janne Grunau (3):
spi: Use a 32-bit DT property for spi-cs-setup-delay-ns
spi: dt-bindings: Add hold/inactive CS delay peripheral properties
spi: Parse hold/inactive CS delay values from the DT
.../bindings/spi/spi-peripheral-props.yaml | 10 ++++++++
drivers/spi/spi.c | 25 +++++++++++++++----
2 files changed, 30 insertions(+), 5 deletions(-)
--
2.35.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2 1/3] spi: Use a 32-bit DT property for spi-cs-setup-delay-ns
2023-01-13 10:23 [PATCH v2 0/3] SPI core CS delay fixes and additions Hector Martin
@ 2023-01-13 10:23 ` Hector Martin
2023-01-13 10:23 ` [PATCH v2 2/3] spi: dt-bindings: Add hold/inactive CS delay peripheral properties Hector Martin
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Hector Martin @ 2023-01-13 10:23 UTC (permalink / raw)
To: Mark Brown
Cc: Rob Herring, Krzysztof Kozlowski, Tudor Ambarus, linux-spi,
devicetree, Janne Grunau, Alyssa Rosenzweig, asahi, linux-kernel,
Hector Martin
From: Janne Grunau <j@jannau.net>
65us is not a reasonable maximum for this property, as some devices
might need a much longer setup time (e.g. those driven by firmware on
the other end). Plus, device tree property values are in 32-bit cells
and smaller widths should not be used without good reason.
Also move the logic to a helper function, since this will later be used
to parse other CS delay properties too.
Fixes: 33a2fde5f77b ("spi: Introduce spi-cs-setup-ns property")
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Hector Martin <marcan@marcan.st>
---
drivers/spi/spi.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 15f174f4e056..3f33934f5429 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -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,8 @@ 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");
return 0;
}
--
2.35.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 2/3] spi: dt-bindings: Add hold/inactive CS delay peripheral properties
2023-01-13 10:23 [PATCH v2 0/3] SPI core CS delay fixes and additions Hector Martin
2023-01-13 10:23 ` [PATCH v2 1/3] spi: Use a 32-bit DT property for spi-cs-setup-delay-ns Hector Martin
@ 2023-01-13 10:23 ` Hector Martin
2023-01-13 10:23 ` [PATCH v2 3/3] spi: Parse hold/inactive CS delay values from the DT Hector Martin
2023-01-13 15:57 ` [PATCH v2 0/3] SPI core CS delay fixes and additions Mark Brown
3 siblings, 0 replies; 10+ messages in thread
From: Hector Martin @ 2023-01-13 10:23 UTC (permalink / raw)
To: Mark Brown
Cc: Rob Herring, Krzysztof Kozlowski, Tudor Ambarus, linux-spi,
devicetree, Janne Grunau, Alyssa Rosenzweig, asahi, linux-kernel,
Rob Herring, Hector Martin
From: Janne Grunau <j@jannau.net>
These two properties complete the bindings for the Linux spi_device cs
model, which includes cs_setup, cs_hold and cs_inactive delay values.
Signed-off-by: Janne Grunau <j@jannau.net>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Hector Martin <marcan@marcan.st>
---
.../devicetree/bindings/spi/spi-peripheral-props.yaml | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml
index 9a60c0664bbe..782a014b63a7 100644
--- a/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml
+++ b/Documentation/devicetree/bindings/spi/spi-peripheral-props.yaml
@@ -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.
--
2.35.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH v2 3/3] spi: Parse hold/inactive CS delay values from the DT
2023-01-13 10:23 [PATCH v2 0/3] SPI core CS delay fixes and additions Hector Martin
2023-01-13 10:23 ` [PATCH v2 1/3] spi: Use a 32-bit DT property for spi-cs-setup-delay-ns Hector Martin
2023-01-13 10:23 ` [PATCH v2 2/3] spi: dt-bindings: Add hold/inactive CS delay peripheral properties Hector Martin
@ 2023-01-13 10:23 ` Hector Martin
2023-01-13 15:57 ` [PATCH v2 0/3] SPI core CS delay fixes and additions Mark Brown
3 siblings, 0 replies; 10+ messages in thread
From: Hector Martin @ 2023-01-13 10:23 UTC (permalink / raw)
To: Mark Brown
Cc: Rob Herring, Krzysztof Kozlowski, Tudor Ambarus, linux-spi,
devicetree, Janne Grunau, Alyssa Rosenzweig, asahi, linux-kernel,
Hector Martin
From: Janne Grunau <j@jannau.net>
Now that we support parsing the setup time from the Device Tree, we can
also easily support the remaining hold and inactive time delay values.
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: Hector Martin <marcan@marcan.st>
---
drivers/spi/spi.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 3f33934f5429..fc4f6308efd8 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2327,6 +2327,8 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
/* 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;
}
--
2.35.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] SPI core CS delay fixes and additions
2023-01-13 10:23 [PATCH v2 0/3] SPI core CS delay fixes and additions Hector Martin
` (2 preceding siblings ...)
2023-01-13 10:23 ` [PATCH v2 3/3] spi: Parse hold/inactive CS delay values from the DT Hector Martin
@ 2023-01-13 15:57 ` Mark Brown
2023-02-14 18:52 ` Kazuki
3 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2023-01-13 15:57 UTC (permalink / raw)
To: Hector Martin
Cc: Rob Herring, Krzysztof Kozlowski, Tudor Ambarus, linux-spi,
devicetree, Janne Grunau, Alyssa Rosenzweig, asahi, linux-kernel
On Fri, 13 Jan 2023 19:23:07 +0900, Hector Martin wrote:
> Commits f6c911f3308c ("spi: dt-bindings: Introduce
> spi-cs-setup-ns property") and 33a2fde5f77b ("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.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/3] spi: Use a 32-bit DT property for spi-cs-setup-delay-ns
commit: f276aacf5d2f7fb57e400db44c807ea3b9525fd6
[2/3] spi: dt-bindings: Add hold/inactive CS delay peripheral properties
commit: 34f89f238c545d4fd0166e37c201d96c10443953
[3/3] spi: Parse hold/inactive CS delay values from the DT
commit: 5827b31d858e399e0ba9fbd33da7a39b31769e11
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] SPI core CS delay fixes and additions
2023-01-13 15:57 ` [PATCH v2 0/3] SPI core CS delay fixes and additions Mark Brown
@ 2023-02-14 18:52 ` Kazuki
2023-02-16 9:04 ` Janne Grunau
0 siblings, 1 reply; 10+ messages in thread
From: Kazuki @ 2023-02-14 18:52 UTC (permalink / raw)
To: Mark Brown
Cc: Rob Herring, Krzysztof Kozlowski, Tudor Ambarus, linux-spi,
devicetree, Janne Grunau, Alyssa Rosenzweig, asahi, linux-kernel,
Hector Martin
On Fri, Jan 13, 2023 at 03:57:26PM +0000, Mark Brown wrote:
> On Fri, 13 Jan 2023 19:23:07 +0900, Hector Martin wrote:
> > Commits f6c911f3308c ("spi: dt-bindings: Introduce
> > spi-cs-setup-ns property") and 33a2fde5f77b ("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.
> >
> > [...]
>
> Applied to
>
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
>
> Thanks!
>
> [1/3] spi: Use a 32-bit DT property for spi-cs-setup-delay-ns
> commit: f276aacf5d2f7fb57e400db44c807ea3b9525fd6
Hi,
Shouldn't this be sent to 6.2 before the property becomes a stable ABI?
Thanks,
Kazuki
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] SPI core CS delay fixes and additions
2023-02-14 18:52 ` Kazuki
@ 2023-02-16 9:04 ` Janne Grunau
2023-02-16 15:55 ` Mark Brown
0 siblings, 1 reply; 10+ messages in thread
From: Janne Grunau @ 2023-02-16 9:04 UTC (permalink / raw)
To: Mark Brown
Cc: Rob Herring, Krzysztof Kozlowski, Tudor Ambarus, linux-spi,
devicetree, Alyssa Rosenzweig, asahi, linux-kernel, Hector Martin,
Kazuki
Hej Mark,
On 2023-02-15 03:52:34 +0900, Kazuki wrote:
> On Fri, Jan 13, 2023 at 03:57:26PM +0000, Mark Brown wrote:
> > On Fri, 13 Jan 2023 19:23:07 +0900, Hector Martin wrote:
> > > Commits f6c911f3308c ("spi: dt-bindings: Introduce
> > > spi-cs-setup-ns property") and 33a2fde5f77b ("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.
> > >
> > > [...]
> >
> > Applied to
> >
> > https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
> >
> > Thanks!
> >
> > [1/3] spi: Use a 32-bit DT property for spi-cs-setup-delay-ns
> > commit: f276aacf5d2f7fb57e400db44c807ea3b9525fd6
>
> Shouldn't this be sent to 6.2 before the property becomes a stable ABI?
can we still get "spi: Use a 32-bit DT property for
spi-cs-setup-delay-ns" into 6.2?
If not I can send a single line patch which switches
of_property_read_u16() to of_property_read_u32() to avoid defining
"spi-cs-setup-delay-ns" to u16 as stable devicetree ABI.
sorry this comes so late before 6.2, we missed to track the patches.
Thanks,
Janne
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] SPI core CS delay fixes and additions
2023-02-16 9:04 ` Janne Grunau
@ 2023-02-16 15:55 ` Mark Brown
2023-02-16 16:21 ` Janne Grunau
0 siblings, 1 reply; 10+ messages in thread
From: Mark Brown @ 2023-02-16 15:55 UTC (permalink / raw)
To: Janne Grunau
Cc: Rob Herring, Krzysztof Kozlowski, Tudor Ambarus, linux-spi,
devicetree, Alyssa Rosenzweig, asahi, linux-kernel, Hector Martin,
Kazuki
[-- Attachment #1: Type: text/plain, Size: 208 bytes --]
On Thu, Feb 16, 2023 at 10:04:11AM +0100, Janne Grunau wrote:
> can we still get "spi: Use a 32-bit DT property for
> spi-cs-setup-delay-ns" into 6.2?
I think I sent a pull request for this already.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] SPI core CS delay fixes and additions
2023-02-16 15:55 ` Mark Brown
@ 2023-02-16 16:21 ` Janne Grunau
2023-02-16 16:25 ` Mark Brown
0 siblings, 1 reply; 10+ messages in thread
From: Janne Grunau @ 2023-02-16 16:21 UTC (permalink / raw)
To: Mark Brown
Cc: Rob Herring, Krzysztof Kozlowski, Tudor Ambarus, linux-spi,
devicetree, Alyssa Rosenzweig, asahi, linux-kernel, Hector Martin,
Kazuki
On 2023-02-16 15:55:52 +0000, Mark Brown wrote:
> On Thu, Feb 16, 2023 at 10:04:11AM +0100, Janne Grunau wrote:
>
> > can we still get "spi: Use a 32-bit DT property for
> > spi-cs-setup-delay-ns" into 6.2?
>
> I think I sent a pull request for this already.
I see today's "[GIT PULL] SPI updates for v6.2-rc8-abi"
https://lore.kernel.org/lkml/20230216131125.4A6FAC433D2@smtp.kernel.org/
but it was neither in "SPI fixes for v6.2-rc3" or "SPI fixes for
v6.2-rc7" or in Linus' tree as of today.
I think something went wrong with "[GIT PULL] SPI updates for
v6.2-rc8-abi". The message reads is if you intended to just send
"spi: Use a 32-bit DT property for spi-cs-setup-delay-ns" and not 62
commits.
Janne
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2 0/3] SPI core CS delay fixes and additions
2023-02-16 16:21 ` Janne Grunau
@ 2023-02-16 16:25 ` Mark Brown
0 siblings, 0 replies; 10+ messages in thread
From: Mark Brown @ 2023-02-16 16:25 UTC (permalink / raw)
To: Janne Grunau
Cc: Rob Herring, Krzysztof Kozlowski, Tudor Ambarus, linux-spi,
devicetree, Alyssa Rosenzweig, asahi, linux-kernel, Hector Martin,
Kazuki
[-- Attachment #1: Type: text/plain, Size: 322 bytes --]
On Thu, Feb 16, 2023 at 05:21:07PM +0100, Janne Grunau wrote:
> I think something went wrong with "[GIT PULL] SPI updates for
> v6.2-rc8-abi". The message reads is if you intended to just send
> "spi: Use a 32-bit DT property for spi-cs-setup-delay-ns" and not 62
> commits.
You're right, thanks for noticing.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-02-16 16:25 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-13 10:23 [PATCH v2 0/3] SPI core CS delay fixes and additions Hector Martin
2023-01-13 10:23 ` [PATCH v2 1/3] spi: Use a 32-bit DT property for spi-cs-setup-delay-ns Hector Martin
2023-01-13 10:23 ` [PATCH v2 2/3] spi: dt-bindings: Add hold/inactive CS delay peripheral properties Hector Martin
2023-01-13 10:23 ` [PATCH v2 3/3] spi: Parse hold/inactive CS delay values from the DT Hector Martin
2023-01-13 15:57 ` [PATCH v2 0/3] SPI core CS delay fixes and additions Mark Brown
2023-02-14 18:52 ` Kazuki
2023-02-16 9:04 ` Janne Grunau
2023-02-16 15:55 ` Mark Brown
2023-02-16 16:21 ` Janne Grunau
2023-02-16 16:25 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).