From: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
To: <broonie@kernel.org>, <tudor.ambarus@linaro.org>,
<pratyush@kernel.org>, <miquel.raynal@bootlin.com>,
<richard@nod.at>, <vigneshr@ti.com>,
<sbinding@opensource.cirrus.com>, <lee@kernel.org>,
<james.schulman@cirrus.com>, <david.rhodes@cirrus.com>,
<rf@opensource.cirrus.com>, <perex@perex.cz>, <tiwai@suse.com>
Cc: <linux-spi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<michael@walle.cc>, <linux-mtd@lists.infradead.org>,
<nicolas.ferre@microchip.com>, <alexandre.belloni@bootlin.com>,
<claudiu.beznea@tuxon.dev>, <michal.simek@amd.com>,
<linux-arm-kernel@lists.infradead.org>,
<alsa-devel@alsa-project.org>, <patches@opensource.cirrus.com>,
<linux-sound@vger.kernel.org>, <git@amd.com>,
<amitrkcian2002@gmail.com>,
Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
Subject: [PATCH v11 10/10] spi: spi-zynqmp-gqspi: Add parallel memories support in GQSPI driver
Date: Sat, 25 Nov 2023 14:51:37 +0530 [thread overview]
Message-ID: <20231125092137.2948-11-amit.kumar-mahapatra@amd.com> (raw)
In-Reply-To: <20231125092137.2948-1-amit.kumar-mahapatra@amd.com>
During probe GQSPI driver sets SPI_CONTROLLER_MULTI_CS bit in ctlr->flags
for notifying SPI core about multi CS capability of the controller.
In parallel mode the controller can either split the data between both the
flash or can send the same data to both the flashes, this is determined by
the STRIPE bit. While sending commands to the flashes the GQSPI driver
send the same command to both the flashes by resetting the STRIPE bit, but
while writing/reading data to & from the flash the GQSPI driver splits the
data evenly between both the flashes by setting the STRIPE bit.
Signed-off-by: Amit Kumar Mahapatra <amit.kumar-mahapatra@amd.com>
---
drivers/spi/spi-zynqmp-gqspi.c | 39 +++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-zynqmp-gqspi.c b/drivers/spi/spi-zynqmp-gqspi.c
index c5d12ddd4ab3..61e91d59014b 100644
--- a/drivers/spi/spi-zynqmp-gqspi.c
+++ b/drivers/spi/spi-zynqmp-gqspi.c
@@ -21,6 +21,7 @@
#include <linux/spinlock.h>
#include <linux/workqueue.h>
#include <linux/spi/spi-mem.h>
+#include <linux/mtd/spi-nor.h>
/* Generic QSPI register offsets */
#define GQSPI_CONFIG_OFST 0x00000100
@@ -190,6 +191,7 @@ struct qspi_platform_data {
* @op_lock: Operational lock
* @speed_hz: Current SPI bus clock speed in hz
* @has_tapdelay: Used for tapdelay register available in qspi
+ * @is_parallel: Used for multi CS support
*/
struct zynqmp_qspi {
struct spi_controller *ctlr;
@@ -212,8 +214,33 @@ struct zynqmp_qspi {
struct mutex op_lock;
u32 speed_hz;
bool has_tapdelay;
+ bool is_parallel;
};
+/**
+ * zynqmp_gqspi_update_stripe - For GQSPI controller data stripe capabilities
+ * @op: Pointer to mem ops
+ * Return: Status of the data stripe
+ *
+ * Returns true if data stripe need to be enabled, else returns false
+ */
+bool zynqmp_gqspi_update_stripe(const struct spi_mem_op *op)
+{
+ if (op->cmd.opcode == SPINOR_OP_BE_4K ||
+ op->cmd.opcode == SPINOR_OP_BE_32K ||
+ op->cmd.opcode == SPINOR_OP_CHIP_ERASE ||
+ op->cmd.opcode == SPINOR_OP_SE ||
+ op->cmd.opcode == SPINOR_OP_BE_32K_4B ||
+ op->cmd.opcode == SPINOR_OP_SE_4B ||
+ op->cmd.opcode == SPINOR_OP_BE_4K_4B ||
+ op->cmd.opcode == SPINOR_OP_WRSR ||
+ op->cmd.opcode == SPINOR_OP_BRWR ||
+ (op->cmd.opcode == SPINOR_OP_WRSR2 && !op->addr.nbytes))
+ return false;
+
+ return true;
+}
+
/**
* zynqmp_gqspi_read - For GQSPI controller read operation
* @xqspi: Pointer to the zynqmp_qspi structure
@@ -468,7 +495,14 @@ static void zynqmp_qspi_chipselect(struct spi_device *qspi, bool is_high)
genfifoentry |= GQSPI_GENFIFO_MODE_SPI;
- if (qspi->cs_index_mask & GQSPI_SELECT_UPPER_CS) {
+ if ((qspi->cs_index_mask & GQSPI_SELECT_LOWER_CS) &&
+ (qspi->cs_index_mask & GQSPI_SELECT_UPPER_CS)) {
+ zynqmp_gqspi_selectslave(xqspi,
+ GQSPI_SELECT_FLASH_CS_BOTH,
+ GQSPI_SELECT_FLASH_BUS_BOTH);
+ if (!xqspi->is_parallel)
+ xqspi->is_parallel = true;
+ } else if (qspi->cs_index_mask & GQSPI_SELECT_UPPER_CS) {
zynqmp_gqspi_selectslave(xqspi,
GQSPI_SELECT_FLASH_CS_UPPER,
GQSPI_SELECT_FLASH_BUS_LOWER);
@@ -1137,6 +1171,8 @@ static int zynqmp_qspi_exec_op(struct spi_mem *mem,
}
if (op->data.nbytes) {
+ if (xqspi->is_parallel && zynqmp_gqspi_update_stripe(op))
+ genfifoentry |= GQSPI_GENFIFO_STRIPE;
reinit_completion(&xqspi->data_completion);
if (op->data.dir == SPI_MEM_DATA_OUT) {
xqspi->txbuf = (u8 *)op->data.buf.out;
@@ -1332,6 +1368,7 @@ static int zynqmp_qspi_probe(struct platform_device *pdev)
ctlr->bits_per_word_mask = SPI_BPW_MASK(8);
ctlr->dev.of_node = np;
ctlr->auto_runtime_pm = true;
+ ctlr->flags |= SPI_CONTROLLER_MULTI_CS;
ret = devm_spi_register_controller(&pdev->dev, ctlr);
if (ret) {
--
2.17.1
next prev parent reply other threads:[~2023-11-25 9:23 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-25 9:21 [PATCH v11 00/10] spi: Add support for stacked/parallel memories Amit Kumar Mahapatra
2023-11-25 9:21 ` [PATCH v11 01/10] mfd: tps6594: Use set/get APIs to access spi->chip_select Amit Kumar Mahapatra
2023-12-01 9:57 ` (subset) " Lee Jones
2023-12-01 18:50 ` Mark Brown
2023-12-06 13:45 ` Lee Jones
2023-12-07 13:38 ` [GIT PULL] Immutable branch between MFD and SPI due for the v6.8 merge window Lee Jones
2023-12-07 16:20 ` Mark Brown
2023-11-25 9:21 ` [PATCH v11 02/10] ALSA: hda/cs35l56: Use set/get APIs to access spi->chip_select Amit Kumar Mahapatra
2023-11-25 9:21 ` [PATCH v11 03/10] spi: Add multi-cs memories support in SPI core Amit Kumar Mahapatra
2024-01-12 19:11 ` Guenter Roeck
2024-01-12 19:16 ` Mark Brown
2024-01-12 20:05 ` Guenter Roeck
2024-01-20 17:05 ` Guenter Roeck
2024-01-21 1:04 ` Mark Brown
2024-01-21 16:58 ` Guenter Roeck
2024-01-21 18:06 ` Michael Walle
2024-01-21 19:29 ` Guenter Roeck
2024-01-21 21:17 ` Mark Brown
2024-01-21 21:15 ` Mark Brown
2024-01-21 9:42 ` Linux regression tracking #adding (Thorsten Leemhuis)
2024-01-23 15:45 ` Linux regression tracking #update (Thorsten Leemhuis)
2023-11-25 9:21 ` [PATCH v11 04/10] mtd: spi-nor: Convert macros with inline functions Amit Kumar Mahapatra
2023-11-25 9:21 ` [PATCH v11 05/10] mtd: spi-nor: Add APIs to set/get nor->params Amit Kumar Mahapatra
2023-11-25 9:21 ` [PATCH v11 06/10] mtd: spi-nor: Move write enable inside specific write & erase APIs Amit Kumar Mahapatra
2023-11-25 9:21 ` [PATCH v11 07/10] mtd: spi-nor: Add stacked memories support in spi-nor Amit Kumar Mahapatra
2023-12-06 14:30 ` Tudor Ambarus
2023-12-06 14:43 ` Tudor Ambarus
2023-12-08 17:06 ` Mahapatra, Amit Kumar
2023-12-11 3:44 ` Tudor Ambarus
2023-12-08 17:05 ` Mahapatra, Amit Kumar
2023-12-11 3:33 ` Tudor Ambarus
2023-12-11 6:56 ` Mahapatra, Amit Kumar
2023-12-11 9:35 ` Tudor Ambarus
2023-12-11 13:37 ` Mahapatra, Amit Kumar
2023-12-12 15:02 ` Tudor Ambarus
2023-12-15 7:55 ` Mahapatra, Amit Kumar
2023-12-15 8:09 ` Tudor Ambarus
2023-12-15 10:02 ` Mahapatra, Amit Kumar
2023-12-15 10:33 ` Tudor Ambarus
2023-12-15 11:20 ` Mahapatra, Amit Kumar
2023-12-19 8:26 ` Tudor Ambarus
2023-12-21 6:54 ` Mahapatra, Amit Kumar
2024-02-09 11:06 ` Tudor Ambarus
2024-02-09 16:13 ` Tudor Ambarus
2024-03-13 16:03 ` Mahapatra, Amit Kumar
2024-07-26 12:35 ` Mahapatra, Amit Kumar
[not found] ` < <IA0PR12MB769944254171C39FF4171B52DCB42@IA0PR12MB7699.namprd12.prod.outlook.com>
2024-07-26 12:55 ` Michael Walle
2024-07-31 8:58 ` Michal Simek
2024-07-31 9:19 ` Michael Walle
2024-07-31 13:40 ` Michal Simek
2024-07-31 14:11 ` Michael Walle
2024-08-01 6:22 ` Michal Simek
2024-08-01 6:37 ` Frager, Neal
2024-08-01 9:28 ` Mahapatra, Amit Kumar
[not found] ` < <CH2PR12MB50044242FE253D7B0E3425ABF0B22@CH2PR12MB5004.namprd12.prod.outlook.com>
2024-08-05 8:14 ` Michael Walle
2024-08-05 8:27 ` Michael Walle
2024-08-05 11:00 ` Michal Simek
2024-08-07 13:21 ` Mahapatra, Amit Kumar
2024-08-12 7:29 ` Miquel Raynal
2024-08-12 7:37 ` Michael Walle
2024-08-12 8:39 ` Miquel Raynal
2024-08-12 8:38 ` Miquel Raynal
2024-08-12 9:45 ` Tudor Ambarus
2024-08-14 7:13 ` Mahapatra, Amit Kumar
2024-08-14 8:46 ` Miquel Raynal
2024-08-14 12:53 ` Mahapatra, Amit Kumar
2024-08-14 14:46 ` Miquel Raynal
2024-08-19 10:28 ` Mahapatra, Amit Kumar
2024-03-13 16:03 ` Mahapatra, Amit Kumar
2023-12-07 17:24 ` Tudor Ambarus
2023-11-25 9:21 ` [PATCH v11 08/10] spi: spi-zynqmp-gqspi: Add stacked memories support in GQSPI driver Amit Kumar Mahapatra
2023-11-25 9:21 ` [PATCH v11 09/10] mtd: spi-nor: Add parallel memories support in spi-nor Amit Kumar Mahapatra
2023-11-25 9:21 ` Amit Kumar Mahapatra [this message]
2023-12-07 22:35 ` (subset) [PATCH v11 00/10] spi: Add support for stacked/parallel memories Mark Brown
2023-12-12 12:34 ` Michael Walle
2023-12-15 7:28 ` Mahapatra, Amit Kumar
2023-12-18 22:10 ` Richard Weinberger
2023-12-19 8:12 ` Miquel Raynal
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=20231125092137.2948-11-amit.kumar-mahapatra@amd.com \
--to=amit.kumar-mahapatra@amd.com \
--cc=alexandre.belloni@bootlin.com \
--cc=alsa-devel@alsa-project.org \
--cc=amitrkcian2002@gmail.com \
--cc=broonie@kernel.org \
--cc=claudiu.beznea@tuxon.dev \
--cc=david.rhodes@cirrus.com \
--cc=git@amd.com \
--cc=james.schulman@cirrus.com \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-sound@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=michael@walle.cc \
--cc=michal.simek@amd.com \
--cc=miquel.raynal@bootlin.com \
--cc=nicolas.ferre@microchip.com \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=pratyush@kernel.org \
--cc=rf@opensource.cirrus.com \
--cc=richard@nod.at \
--cc=sbinding@opensource.cirrus.com \
--cc=tiwai@suse.com \
--cc=tudor.ambarus@linaro.org \
--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;
as well as URLs for NNTP newsgroup(s).