linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mauro Lima <mauro.lima@eclypsium.com>
To: broonie@kernel.org
Cc: mika.westerberg@linux.intel.com, linux-spi@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Mauro Lima <mauro.lima@eclypsium.com>
Subject: [PATCH 2/2] spi: intel-spi: build the driver with hardware sequencing by default
Date: Thu, 20 Oct 2022 13:45:08 -0300	[thread overview]
Message-ID: <20221020164508.29182-3-mauro.lima@eclypsium.com> (raw)
In-Reply-To: <20221020164508.29182-1-mauro.lima@eclypsium.com>

Add menuconfig option to build the driver with hardware sequencing by
default and another to specify software sequencing support if needed.
For the software sequencing functionality preserve the *DANGEROUS* tag.

Signed-off-by: Mauro Lima <mauro.lima@eclypsium.com>
---
 drivers/spi/Kconfig           | 15 +++++++++--
 drivers/spi/spi-intel-swseq.c | 50 +++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index d1bb62f7368b..aec095988ab7 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -448,7 +448,7 @@ config SPI_INTEL
 	tristate
 
 config SPI_INTEL_PCI
-	tristate "Intel PCH/PCU SPI flash PCI driver (DANGEROUS)"
+	tristate "Intel PCH/PCU SPI flash PCI driver"
 	depends on PCI
 	depends on X86 || COMPILE_TEST
 	depends on SPI_MEM
@@ -458,6 +458,8 @@ config SPI_INTEL_PCI
 	  master mode. This controller is present in modern Intel hardware
 	  and is used to hold BIOS and other persistent settings. Using
 	  this driver it is possible to upgrade BIOS directly from Linux.
+	  The driver will use hardware sequencing capabilities from the chip
+	  by default.
 
 	  Say N here unless you know what you are doing. Overwriting the
 	  SPI flash may render the system unbootable.
@@ -466,7 +468,7 @@ config SPI_INTEL_PCI
 	  will be called spi-intel-pci.
 
 config SPI_INTEL_PLATFORM
-	tristate "Intel PCH/PCU SPI flash platform driver (DANGEROUS)"
+	tristate "Intel PCH/PCU SPI flash platform driver"
 	depends on X86 || COMPILE_TEST
 	depends on SPI_MEM
 	select SPI_INTEL
@@ -476,6 +478,8 @@ config SPI_INTEL_PLATFORM
 	  Intel hardware and is used to hold BIOS and other persistent
 	  settings. Using this driver it is possible to upgrade BIOS
 	  directly from Linux.
+	  The driver will use hardware sequencing capabilities from the chip
+	  by default.
 
 	  Say N here unless you know what you are doing. Overwriting the
 	  SPI flash may render the system unbootable.
@@ -483,6 +487,13 @@ config SPI_INTEL_PLATFORM
 	  To compile this driver as a module, choose M here: the module
 	  will be called spi-intel-platform.
 
+config SPI_INTEL_SWSEQ
+	tristate "Intel SPI controller software sequencing support (DANGEROUS)"
+	depends on X86 || COMPILE_TEST
+	depends on SPI_MEM
+	help
+	  This enables software sequencing functionality to the SPI controller
+
 config SPI_JCORE
 	tristate "J-Core SPI Master"
 	depends on OF && (SUPERH || COMPILE_TEST)
diff --git a/drivers/spi/spi-intel-swseq.c b/drivers/spi/spi-intel-swseq.c
index 2597aa06a160..d7e4834be6db 100644
--- a/drivers/spi/spi-intel-swseq.c
+++ b/drivers/spi/spi-intel-swseq.c
@@ -12,6 +12,7 @@
 #include "spi-intel-common.h"
 #include "spi-intel-swseq.h"
 
+#if defined(CONFIG_SPI_INTEL_SWSEQ)
 bool mem_op_supported_on_spi_locked(const struct intel_spi *ispi,
 				    const struct spi_mem_op *op)
 {
@@ -178,4 +179,53 @@ void populate_opmenus(struct intel_spi *ispi, u32 *opmenu0, u32 *opmenu1)
 }
 EXPORT_SYMBOL(populate_opmenus);
 
+#else
+static inline void log_error_swseq_not_supported(const struct intel_spi *ispi)
+{
+	dev_err(ispi->dev, "SW sequencing is not enabled");
+}
+
+int handle_swseq_wren(struct intel_spi *ispi)
+{
+	log_error_swseq_not_supported(ispi);
+	return -EINVAL;
+}
+EXPORT_SYMBOL(handle_swseq_wren);
+
+bool mem_op_supported_on_spi_locked(const struct intel_spi *ispi,
+				    const struct spi_mem_op *op)
+{
+	log_error_swseq_not_supported(ispi);
+	return false;
+}
+EXPORT_SYMBOL(mem_op_supported_on_spi_locked);
+
+int intel_spi_sw_cycle(struct intel_spi *ispi, u8 opcode, size_t len,
+		       int optype)
+{
+	log_error_swseq_not_supported(ispi);
+	return -ENOTSUPP;
+}
+EXPORT_SYMBOL(intel_spi_sw_cycle);
+
+inline bool is_swseq_enabled(void)
+{
+	return false;
+}
+EXPORT_SYMBOL(is_swseq_enabled);
+
+void disable_smi_generation(const struct intel_spi *ispi)
+{
+	log_error_swseq_not_supported(ispi);
+}
+EXPORT_SYMBOL(disable_smi_generation);
+
+void populate_opmenus(struct intel_spi *ispi, u32 *opmenu0, u32 *opmenu1)
+{
+	log_error_swseq_not_supported(ispi);
+}
+EXPORT_SYMBOL(populate_opmenus);
+
+#endif
+
 MODULE_LICENSE("GPL v2");
-- 
2.34.3


  parent reply	other threads:[~2022-10-20 16:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20 16:45 [PATCH 0/2] intel-spi: Split hardware and software sequencing Mauro Lima
2022-10-20 16:45 ` [PATCH 1/2] spi: intel-spi: Move software sequencing logic outside the core Mauro Lima
2022-10-23  5:45   ` Mika Westerberg
2022-10-20 16:45 ` Mauro Lima [this message]
2022-10-25  6:09 ` [PATCH 0/2] intel-spi: Split hardware and software sequencing Mika Westerberg

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=20221020164508.29182-3-mauro.lima@eclypsium.com \
    --to=mauro.lima@eclypsium.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.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;
as well as URLs for NNTP newsgroup(s).