diff mbox series

[linux,dev-6.6,v1] spi: npcm-fiu: add dual and quad write support

Message ID 20240709184813.1946724-1-tmaimon77@gmail.com
State New
Headers show
Series [linux,dev-6.6,v1] spi: npcm-fiu: add dual and quad write support | expand

Commit Message

Tomer Maimon July 9, 2024, 6:48 p.m. UTC
Add dual and quad write support by writing the command write in the UMA
register first and then write the data in chunks of 16 bytes.

Signed-off-by: Stanley Chu <yschu@nuvoton.com>
Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
---
 drivers/spi/spi-npcm-fiu.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Andrew Jeffery July 16, 2024, 3:24 a.m. UTC | #1
On Tue, 2024-07-09 at 21:48 +0300, Tomer Maimon wrote:
> Add dual and quad write support by writing the command write in the UMA
> register first and then write the data in chunks of 16 bytes.
> 
> Signed-off-by: Stanley Chu <yschu@nuvoton.com>
> Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
> ---
>  drivers/spi/spi-npcm-fiu.c | 15 ++++++++-------
>  1 file changed, 8 insertions(+), 7 deletions(-)

What's the state of this patch with respect to upstream? Is this
something specific to the openbmc/linux dev-6.6 tree, or is there an
upstream equivalent? If the latter, can you please link to the relevant
patch?

Andrew
Tomer Maimon July 16, 2024, 2:04 p.m. UTC | #2
Hi Andrew,

On Tue, 16 Jul 2024 at 06:24, Andrew Jeffery
<andrew@codeconstruct.com.au> wrote:
>
> On Tue, 2024-07-09 at 21:48 +0300, Tomer Maimon wrote:
> > Add dual and quad write support by writing the command write in the UMA
> > register first and then write the data in chunks of 16 bytes.
> >
> > Signed-off-by: Stanley Chu <yschu@nuvoton.com>
> > Signed-off-by: Tomer Maimon <tmaimon77@gmail.com>
> > ---
> >  drivers/spi/spi-npcm-fiu.c | 15 ++++++++-------
> >  1 file changed, 8 insertions(+), 7 deletions(-)
>
> What's the state of this patch with respect to upstream? Is this
> something specific to the openbmc/linux dev-6.6 tree, or is there an
> upstream equivalent? If the latter, can you please link to the relevant
> patch?
This patch set hasn't been upstream yet to OpenBMC vanilla and it is
not specific to openbmc/linux dev-6.6 tree.
We will do our best to upstream this patch in kernel 6.11 (We already
have a lot of patches to handle in the next kernel version :-)).
since we need to upgrade the NPCM from dev-6.1 to dev-6.6, we would
appreciate it if you could add it now to dev-6.6.
>
> Andrew

Thanks,

Tomer
diff mbox series

Patch

diff --git a/drivers/spi/spi-npcm-fiu.c b/drivers/spi/spi-npcm-fiu.c
index e42248519688..a999614340d6 100644
--- a/drivers/spi/spi-npcm-fiu.c
+++ b/drivers/spi/spi-npcm-fiu.c
@@ -392,7 +392,7 @@  static int npcm_fiu_uma_write(struct spi_mem *mem,
 {
 	struct npcm_fiu_spi *fiu =
 		spi_controller_get_devdata(mem->spi->controller);
-	u32 uma_cfg = BIT(10);
+	u32 uma_cfg = cmd ? BIT(10) : 0;
 	u32 data_reg[4] = {0};
 	u32 val;
 	u32 i;
@@ -402,8 +402,11 @@  static int npcm_fiu_uma_write(struct spi_mem *mem,
 			   (spi_get_chipselect(mem->spi, 0) <<
 			    NPCM_FIU_UMA_CTS_DEV_NUM_SHIFT));
 
-	regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CMD,
-			   NPCM_FIU_UMA_CMD_CMD, cmd);
+	if (cmd)
+		regmap_update_bits(fiu->regmap, NPCM_FIU_UMA_CMD,
+				   NPCM_FIU_UMA_CMD_CMD, cmd);
+	else
+		uma_cfg |= ilog2(op->data.buswidth) << NPCM_FIU_UMA_CFG_WDBPCK_SHIFT;
 
 	if (data_size) {
 		memcpy(data_reg, data, data_size);
@@ -463,8 +466,7 @@  static int npcm_fiu_manualwrite(struct spi_mem *mem,
 
 	/* Starting the data writing loop in multiples of 8 */
 	for (idx = 0; idx < num_data_chunks; ++idx) {
-		ret = npcm_fiu_uma_write(mem, op, data[0], false,
-					 &data[1], CHUNK_SIZE - 1);
+		ret = npcm_fiu_uma_write(mem, op, 0, false, &data[0], CHUNK_SIZE);
 		if (ret)
 			return ret;
 
@@ -473,8 +475,7 @@  static int npcm_fiu_manualwrite(struct spi_mem *mem,
 
 	/* Handling chunk remains */
 	if (remain_data > 0) {
-		ret = npcm_fiu_uma_write(mem, op, data[0], false,
-					 &data[1], remain_data - 1);
+		ret = npcm_fiu_uma_write(mem, op, 0, false, &data[0], remain_data);
 		if (ret)
 			return ret;
 	}