mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Santhosh Kumar K <s-k6@ti.com>
To: <broonie@kernel.org>, <robh@kernel.org>, <krzk+dt@kernel.org>,
	<conor+dt@kernel.org>, <miquel.raynal@bootlin.com>,
	<richard@nod.at>, <vigneshr@ti.com>, <pratyush@kernel.org>,
	<mwalle@kernel.org>, <takahiro.kuwano@infineon.com>
Cc: <linux-spi@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-mtd@lists.infradead.org>,
	<praneeth@ti.com>, <u-kumar1@ti.com>, <a-dutta@ti.com>,
	<s-k6@ti.com>
Subject: [PATCH v3 03/13] spi: parse two-element spi-max-frequency property
Date: Wed, 27 May 2026 23:25:17 +0530	[thread overview]
Message-ID: <20260527175527.2247679-4-s-k6@ti.com> (raw)
In-Reply-To: <20260527175527.2247679-1-s-k6@ti.com>

Some SPI controllers support high-speed operating modes that require
controller-side configuration before the device can be driven at its
rated maximum. In such cases the device has two relevant speeds: a
conservative rate for baseline operation and a maximum rate achievable
once the controller is fully configured.

Extend struct spi_device with a base_speed_hz field. Update
of_spi_parse_dt() to populate base_speed_hz from the first element and
max_speed_hz from the second when spi-max-frequency carries two values.
A single-element property continues to populate only max_speed_hz,
preserving existing behaviour. base_speed_hz is zero when not set.

Signed-off-by: Santhosh Kumar K <s-k6@ti.com>
---
 drivers/spi/spi.c       | 17 ++++++++++++++---
 include/linux/spi/spi.h |  2 ++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 76e3563c523f..a1050b1a1d4c 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2364,7 +2364,7 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
 			   struct device_node *nc)
 {
 	u32 value, cs[SPI_DEVICE_CS_CNT_MAX], map[SPI_DEVICE_DATA_LANE_CNT_MAX];
-	int rc, idx, max_num_data_lanes;
+	int rc, idx, max_num_data_lanes, nfreq;
 
 	/* Mode (clock phase/polarity/etc.) */
 	if (of_property_read_bool(nc, "spi-cpha"))
@@ -2596,9 +2596,20 @@ static int of_spi_parse_dt(struct spi_controller *ctlr, struct spi_device *spi,
 	 */
 	spi->cs_index_mask = BIT(0);
 
-	/* Device speed */
-	if (!of_property_read_u32(nc, "spi-max-frequency", &value))
+	/*
+	 * Device speed: a single value sets max_speed_hz; two values set
+	 * base_speed_hz (conservative) and max_speed_hz (maximum after
+	 * controller-side configuration).
+	 */
+	nfreq = of_property_count_u32_elems(nc, "spi-max-frequency");
+	if (nfreq == 2) {
+		of_property_read_u32_index(nc, "spi-max-frequency", 0,
+					   &spi->base_speed_hz);
+		of_property_read_u32_index(nc, "spi-max-frequency", 1,
+					   &spi->max_speed_hz);
+	} else 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");
diff --git a/include/linux/spi/spi.h b/include/linux/spi/spi.h
index f6ed93eff00b..e4fc8ac1c889 100644
--- a/include/linux/spi/spi.h
+++ b/include/linux/spi/spi.h
@@ -139,6 +139,7 @@ extern void spi_transfer_cs_change_delay_exec(struct spi_message *msg,
  * @max_speed_hz: Maximum clock rate to be used with this chip
  *	(on this board); may be changed by the device's driver.
  *	The spi_transfer.speed_hz can override this for each transfer.
+ * @base_speed_hz: Conservative clock rate for the device; zero when not set.
  * @bits_per_word: Data transfers involve one or more words; word sizes
  *	like eight or 12 bits are common.  In-memory wordsizes are
  *	powers of two bytes (e.g. 20 bit samples use 32 bits).
@@ -191,6 +192,7 @@ struct spi_device {
 	struct device		dev;
 	struct spi_controller	*controller;
 	u32			max_speed_hz;
+	u32			base_speed_hz;
 	u8			bits_per_word;
 	bool			rt;
 #define SPI_NO_TX		BIT(31)		/* No transmit wire */
-- 
2.34.1


  parent reply	other threads:[~2026-05-27 17:55 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27 17:55 [PATCH v3 00/13] spi: cadence-quadspi: add PHY tuning support Santhosh Kumar K
2026-05-27 17:55 ` [PATCH v3 01/13] spi: dt-bindings: allow spi-max-frequency to specify a frequency pair Santhosh Kumar K
2026-05-28  8:32   ` Miquel Raynal
2026-05-28 17:36   ` Conor Dooley
2026-05-30  8:54     ` Krzysztof Kozlowski
2026-06-01  7:45     ` Santhosh Kumar K
2026-06-02 12:05       ` Miquel Raynal
2026-06-02 16:18         ` Conor Dooley
2026-06-03 15:54           ` Miquel Raynal
2026-06-03 16:07             ` Conor Dooley
2026-06-03 16:29               ` Miquel Raynal
2026-06-03 16:40                 ` Conor Dooley
2026-06-04  7:14                   ` Miquel Raynal
2026-06-04  8:36                     ` Conor Dooley
2026-06-05  6:32                       ` Miquel Raynal
2026-06-05  7:17                         ` Conor Dooley
2026-06-05  7:26                           ` Miquel Raynal
2026-06-05 15:20                             ` Conor Dooley
2026-06-05 16:55                               ` Miquel Raynal
2026-05-27 17:55 ` [PATCH v3 02/13] spi: dt-bindings: cdns,qspi-nor: add PHY tuning pattern partition property Santhosh Kumar K
2026-05-28  8:34   ` Miquel Raynal
2026-05-30  8:52   ` Krzysztof Kozlowski
2026-06-01  8:26     ` Santhosh Kumar K
2026-06-01 11:26       ` Krzysztof Kozlowski
2026-06-01 11:47         ` Krzysztof Kozlowski
2026-06-02  6:30           ` Santhosh Kumar K
2026-06-02 12:08             ` Krzysztof Kozlowski
2026-06-02 12:36             ` Miquel Raynal
2026-06-02 12:48               ` Krzysztof Kozlowski
2026-06-04 12:01                 ` Santhosh Kumar K
2026-06-02 16:49   ` Rob Herring
2026-06-03 16:01     ` Miquel Raynal
2026-06-03 17:38       ` Rob Herring
2026-06-03 19:00         ` Michael Walle
2026-06-04 12:07           ` Santhosh Kumar K
2026-06-04  7:28         ` Miquel Raynal
2026-06-04 12:04           ` Santhosh Kumar K
2026-05-27 17:55 ` Santhosh Kumar K [this message]
2026-05-28  8:37   ` [PATCH v3 03/13] spi: parse two-element spi-max-frequency property Miquel Raynal
2026-05-27 17:55 ` [PATCH v3 04/13] spi: spi-mem: add spi_mem_apply_base_freq_cap() Santhosh Kumar K
2026-05-28  8:43   ` Miquel Raynal
2026-06-04 12:10     ` Santhosh Kumar K
2026-06-05  6:15       ` Miquel Raynal
2026-05-27 17:55 ` [PATCH v3 05/13] spi: spi-mem: add execute_tuning callback and spi_mem_execute_tuning() Santhosh Kumar K
2026-05-28  8:44   ` Miquel Raynal
2026-05-27 17:55 ` [PATCH v3 06/13] spi: cadence-quadspi: move cqspi_readdata_capture earlier Santhosh Kumar K
2026-05-27 17:55 ` [PATCH v3 07/13] spi: cadence-quadspi: add DQS support to read data capture Santhosh Kumar K
2026-05-27 17:55 ` [PATCH v3 08/13] spi: cadence-quadspi: add PHY tuning support Santhosh Kumar K
2026-05-28  8:54   ` Miquel Raynal
2026-06-01  8:44     ` Santhosh Kumar K
2026-05-27 17:55 ` [PATCH v3 09/13] spi: cadence-quadspi: reject 2-byte-address DDR ops on PHY-tunable hardware Santhosh Kumar K
2026-05-28  9:01   ` Miquel Raynal
2026-06-01  9:27     ` Santhosh Kumar K
2026-06-02 12:25       ` Miquel Raynal
2026-05-27 17:55 ` [PATCH v3 10/13] spi: cadence-quadspi: enable PHY for direct reads and indirect writes Santhosh Kumar K
2026-05-28  9:09   ` Miquel Raynal
2026-06-01  8:39     ` Santhosh Kumar K
2026-06-02 12:15       ` Miquel Raynal
2026-05-27 17:55 ` [PATCH v3 11/13] mtd: spinand: run PHY tuning after init and update dirmap frequencies Santhosh Kumar K
2026-05-28  9:27   ` Miquel Raynal
2026-06-01  9:16     ` Santhosh Kumar K
2026-06-02 12:18       ` Miquel Raynal
2026-05-27 17:55 ` [PATCH v3 12/13] mtd: spi-nor: extract read op template construction into helper Santhosh Kumar K
2026-05-27 17:55 ` [PATCH v3 13/13] mtd: spi-nor: run PHY tuning after init and update dirmap frequency Santhosh Kumar K
2026-05-28  8:30 ` [PATCH v3 00/13] spi: cadence-quadspi: add PHY tuning support Miquel Raynal
2026-06-01  8:02   ` Santhosh Kumar K

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260527175527.2247679-4-s-k6@ti.com \
    --to=s-k6@ti.com \
    --cc=a-dutta@ti.com \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=mwalle@kernel.org \
    --cc=praneeth@ti.com \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=robh@kernel.org \
    --cc=takahiro.kuwano@infineon.com \
    --cc=u-kumar1@ti.com \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®