mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-07-20 08:26:59 +08:00
53 lines
1.6 KiB
Diff
53 lines
1.6 KiB
Diff
From 9bdcdedc55c469556ca5c21ae129bd3ec0b19762 Mon Sep 17 00:00:00 2001
|
|
From: Janne Grunau <j@jannau.net>
|
|
Date: Sat, 11 Dec 2021 12:21:04 +0100
|
|
Subject: [PATCH 115/171] spi: parse CS delay values from DT
|
|
|
|
Signed-off-by: Janne Grunau <j@jannau.net>
|
|
---
|
|
drivers/spi/spi.c | 21 +++++++++++++++++++++
|
|
1 file changed, 21 insertions(+)
|
|
|
|
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
|
|
index ea09d1b42bf6..c8342b950783 100644
|
|
--- a/drivers/spi/spi.c
|
|
+++ b/drivers/spi/spi.c
|
|
@@ -2059,6 +2059,22 @@ 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)
|
|
{
|
|
@@ -2148,6 +2164,11 @@ 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;
|
|
|
|
+ /* 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.34.1
|
|
|