linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fixes in TI QSPI driver to allow more than one flash chip
@ 2018-03-22 12:33 Kwiatkowski, Arkadiusz
  2018-03-27  4:00 ` Vignesh R
  0 siblings, 1 reply; 7+ messages in thread
From: Kwiatkowski, Arkadiusz @ 2018-03-22 12:33 UTC (permalink / raw)
  To: broonie, sourav.poddar, vigneshr; +Cc: linux-spi, linux-kernel

Add checking for which SPI device was memory-mapped to allow more than
one flash device being used on QSPI bus. Fix parameters order in
regmap_update_bits calls.

Signed-off-by: Arkadiusz Kwiatkowski <arkadiusz.kwiatkowski@aptiv.com>
---
 drivers/spi/spi-ti-qspi.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
index c24d9b4..3d1dc4f 100644
--- a/drivers/spi/spi-ti-qspi.c
+++ b/drivers/spi/spi-ti-qspi.c
@@ -66,7 +66,7 @@ struct ti_qspi {
 u32 cmd;
 u32 dc;

-bool mmap_enabled;
+struct spi_device*mmap_spi_device;
 };

 #define QSPI_PID(0x0)
@@ -490,10 +490,10 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi)
 ti_qspi_write(qspi, MM_SWITCH, QSPI_SPI_SWITCH_REG);
 if (qspi->ctrl_base) {
 regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
-   MEM_CS_EN(spi->chip_select),
-   MEM_CS_MASK);
+   MEM_CS_MASK,
+   MEM_CS_EN(spi->chip_select));
 }
-qspi->mmap_enabled = true;
+qspi->mmap_spi_device = spi;
 }

 static void ti_qspi_disable_memory_map(struct spi_device *spi)
@@ -503,8 +503,8 @@ static void ti_qspi_disable_memory_map(struct spi_device *spi)
 ti_qspi_write(qspi, 0, QSPI_SPI_SWITCH_REG);
 if (qspi->ctrl_base)
 regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
-   0, MEM_CS_MASK);
-qspi->mmap_enabled = false;
+   MEM_CS_MASK, 0);
+qspi->mmap_spi_device = NULL;
 }

 static void ti_qspi_setup_mmap_read(struct spi_device *spi,
@@ -544,8 +544,12 @@ static int ti_qspi_spi_flash_read(struct spi_device *spi,

 mutex_lock(&qspi->list_lock);

-if (!qspi->mmap_enabled)
+if (qspi->mmap_spi_device != spi) {
+if (qspi->mmap_spi_device != NULL)
+ti_qspi_disable_memory_map(qspi->mmap_spi_device);
 ti_qspi_enable_memory_map(spi);
+}
+
 ti_qspi_setup_mmap_read(spi, msg);

 if (qspi->rx_chan) {
@@ -600,7 +604,7 @@ static int ti_qspi_start_transfer_one(struct spi_master *master,

 mutex_lock(&qspi->list_lock);

-if (qspi->mmap_enabled)
+if (qspi->mmap_spi_device != NULL)
 ti_qspi_disable_memory_map(spi);

 list_for_each_entry(t, &m->transfers, transfer_list) {
@@ -787,7 +791,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
 master->spi_flash_read = NULL;
 }
 }
-qspi->mmap_enabled = false;
+qspi->mmap_spi_device = NULL;

 ret = devm_spi_register_master(&pdev->dev, master);
 if (!ret)
--
2.7.4
**************************************************************************************** Note: If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. ****************************************************************************************

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] Fixes in TI QSPI driver to allow more than one flash chip
  2018-03-22 12:33 [PATCH] Fixes in TI QSPI driver to allow more than one flash chip Kwiatkowski, Arkadiusz
@ 2018-03-27  4:00 ` Vignesh R
  2018-03-30  9:41   ` [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls Arkadiusz Kwiatkowski
  0 siblings, 1 reply; 7+ messages in thread
From: Vignesh R @ 2018-03-27  4:00 UTC (permalink / raw)
  To: Kwiatkowski, Arkadiusz, broonie; +Cc: linux-spi, linux-kernel



On Thursday 22 March 2018 06:03 PM, Kwiatkowski, Arkadiusz wrote:
> Add checking for which SPI device was memory-mapped to allow more than
> one flash device being used on QSPI bus. Fix parameters order in
> regmap_update_bits calls.
> 
> Signed-off-by: Arkadiusz Kwiatkowski <arkadiusz.kwiatkowski@aptiv.com>
> ---

Thanks for the patch! Fixes are legitimate but,
Your mailer has grabbled the patch (especially white spaces). Please use
git send-email to send patches.
Run scripts/checkpatch.pl --strict on the patch for kernel coding style
checks.
Please look at git log drivers/spi/spi-ti-qspi.c and fix up $subject
accordingly. Split this patch into two: One fixing up
regmap_update_bits() call and other fixing up mmap setup for more than
one CS.


>  drivers/spi/spi-ti-qspi.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
> index c24d9b4..3d1dc4f 100644
> --- a/drivers/spi/spi-ti-qspi.c
> +++ b/drivers/spi/spi-ti-qspi.c
> @@ -66,7 +66,7 @@ struct ti_qspi {
>  u32 cmd;
>  u32 dc;
> 
> -bool mmap_enabled;
> +struct spi_device*mmap_spi_device;
>  };
> 
>  #define QSPI_PID(0x0)
> @@ -490,10 +490,10 @@ static void ti_qspi_enable_memory_map(struct
> spi_device *spi)
>  ti_qspi_write(qspi, MM_SWITCH, QSPI_SPI_SWITCH_REG);
>  if (qspi->ctrl_base) {
>  regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
> -   MEM_CS_EN(spi->chip_select),
> -   MEM_CS_MASK);
> +   MEM_CS_MASK,
> +   MEM_CS_EN(spi->chip_select));
>  }
> -qspi->mmap_enabled = true;
> +qspi->mmap_spi_device = spi;
>  }
> 
>  static void ti_qspi_disable_memory_map(struct spi_device *spi)
> @@ -503,8 +503,8 @@ static void ti_qspi_disable_memory_map(struct
> spi_device *spi)
>  ti_qspi_write(qspi, 0, QSPI_SPI_SWITCH_REG);
>  if (qspi->ctrl_base)
>  regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
> -   0, MEM_CS_MASK);
> -qspi->mmap_enabled = false;
> +   MEM_CS_MASK, 0);
> +qspi->mmap_spi_device = NULL;
>  }
> 
>  static void ti_qspi_setup_mmap_read(struct spi_device *spi,
> @@ -544,8 +544,12 @@ static int ti_qspi_spi_flash_read(struct spi_device
> *spi,
> 
>  mutex_lock(&qspi->list_lock);
> 
> -if (!qspi->mmap_enabled)
> +if (qspi->mmap_spi_device != spi) {
> +if (qspi->mmap_spi_device != NULL)
> +ti_qspi_disable_memory_map(qspi->mmap_spi_device);
>  ti_qspi_enable_memory_map(spi);
> +}
> +
>  ti_qspi_setup_mmap_read(spi, msg);
> 
>  if (qspi->rx_chan) {
> @@ -600,7 +604,7 @@ static int ti_qspi_start_transfer_one(struct
> spi_master *master,
> 
>  mutex_lock(&qspi->list_lock);
> 
> -if (qspi->mmap_enabled)
> +if (qspi->mmap_spi_device != NULL)
>  ti_qspi_disable_memory_map(spi);
> 
>  list_for_each_entry(t, &m->transfers, transfer_list) {
> @@ -787,7 +791,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
>  master->spi_flash_read = NULL;
>  }
>  }
> -qspi->mmap_enabled = false;
> +qspi->mmap_spi_device = NULL;
> 
>  ret = devm_spi_register_master(&pdev->dev, master);
>  if (!ret)
> --
> 2.7.4
> ****************************************************************************************
> Note: If the reader of this message is not the intended recipient, or an
> employee or agent responsible for delivering this message to the
> intended recipient, you are hereby notified that any dissemination,
> distribution or copying of this communication is strictly prohibited. If
> you have received this communication in error, please notify us
> immediately by replying to the message and deleting it from your
> computer. Thank you.
> ****************************************************************************************

-- 
Regards
Vignesh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls
  2018-03-27  4:00 ` Vignesh R
@ 2018-03-30  9:41   ` Arkadiusz Kwiatkowski
  2018-03-30  9:41     ` [PATCH v2 2/2] spi: spi-ti-qspi: Add checking which flash chip has been mmap-ed Arkadiusz Kwiatkowski
                       ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Arkadiusz Kwiatkowski @ 2018-03-30  9:41 UTC (permalink / raw)
  To: vigneshr, sourav.poddar, broonie
  Cc: linux-spi, linux-kernel, Arkadiusz Kwiatkowski

This commit fixes the order of parameters passed to regmap_update_bits
function inside spi-ti-qspi driver. Accidentally the code worked
correctly when cs=0, but it is not the case for other values.

Signed-off-by: Arkadiusz Kwiatkowski <arkadiusz.kwiatkowski@aptiv.com>
---
 drivers/spi/spi-ti-qspi.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
index c24d9b4..d0ea62d 100644
--- a/drivers/spi/spi-ti-qspi.c
+++ b/drivers/spi/spi-ti-qspi.c
@@ -490,8 +490,8 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi)
        ti_qspi_write(qspi, MM_SWITCH, QSPI_SPI_SWITCH_REG);
        if (qspi->ctrl_base) {
                regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
-                                  MEM_CS_EN(spi->chip_select),
-                                  MEM_CS_MASK);
+                                  MEM_CS_MASK,
+                                  MEM_CS_EN(spi->chip_select));
        }
        qspi->mmap_enabled = true;
 }
@@ -503,7 +503,7 @@ static void ti_qspi_disable_memory_map(struct spi_device *spi)
        ti_qspi_write(qspi, 0, QSPI_SPI_SWITCH_REG);
        if (qspi->ctrl_base)
                regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
-                                  0, MEM_CS_MASK);
+                                  MEM_CS_MASK, 0);
        qspi->mmap_enabled = false;
 }

--
2.7.4

**************************************************************************************** Note: If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. ****************************************************************************************

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/2] spi: spi-ti-qspi: Add checking which flash chip has been mmap-ed
  2018-03-30  9:41   ` [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls Arkadiusz Kwiatkowski
@ 2018-03-30  9:41     ` Arkadiusz Kwiatkowski
  2018-04-03  6:03     ` [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls Vignesh R
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Arkadiusz Kwiatkowski @ 2018-03-30  9:41 UTC (permalink / raw)
  To: vigneshr, sourav.poddar, broonie
  Cc: linux-spi, linux-kernel, Arkadiusz Kwiatkowski

This patch allows placing more than one flash chip on the qspi bus
by checking which spi device has been memory-mapped and remapping
if necessary.

Signed-off-by: Arkadiusz Kwiatkowski <arkadiusz.kwiatkowski@aptiv.com>
---
 drivers/spi/spi-ti-qspi.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
index d0ea62d..5b99a1e 100644
--- a/drivers/spi/spi-ti-qspi.c
+++ b/drivers/spi/spi-ti-qspi.c
@@ -66,7 +66,7 @@ struct ti_qspi {
        u32 cmd;
        u32 dc;

-       bool mmap_enabled;
+       struct spi_device       *mmap_spi_device;
 };

 #define QSPI_PID                       (0x0)
@@ -493,7 +493,7 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi)
                                   MEM_CS_MASK,
                                   MEM_CS_EN(spi->chip_select));
        }
-       qspi->mmap_enabled = true;
+       qspi->mmap_spi_device = spi;
 }

 static void ti_qspi_disable_memory_map(struct spi_device *spi)
@@ -504,7 +504,7 @@ static void ti_qspi_disable_memory_map(struct spi_device *spi)
        if (qspi->ctrl_base)
                regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
                                   MEM_CS_MASK, 0);
-       qspi->mmap_enabled = false;
+       qspi->mmap_spi_device = NULL;
 }

 static void ti_qspi_setup_mmap_read(struct spi_device *spi,
@@ -544,8 +544,12 @@ static int ti_qspi_spi_flash_read(struct spi_device *spi,

        mutex_lock(&qspi->list_lock);

-       if (!qspi->mmap_enabled)
+       if (qspi->mmap_spi_device != spi) {
+               if (qspi->mmap_spi_device)
+                       ti_qspi_disable_memory_map(qspi->mmap_spi_device);
                ti_qspi_enable_memory_map(spi);
+       }
+
        ti_qspi_setup_mmap_read(spi, msg);

        if (qspi->rx_chan) {
@@ -600,7 +604,7 @@ static int ti_qspi_start_transfer_one(struct spi_master *master,

        mutex_lock(&qspi->list_lock);

-       if (qspi->mmap_enabled)
+       if (qspi->mmap_spi_device)
                ti_qspi_disable_memory_map(spi);

        list_for_each_entry(t, &m->transfers, transfer_list) {
@@ -787,7 +791,7 @@ static int ti_qspi_probe(struct platform_device *pdev)
                        master->spi_flash_read = NULL;
                }
        }
-       qspi->mmap_enabled = false;
+       qspi->mmap_spi_device = NULL;

        ret = devm_spi_register_master(&pdev->dev, master);
        if (!ret)
--
2.7.4

**************************************************************************************** Note: If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. ****************************************************************************************

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls
  2018-03-30  9:41   ` [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls Arkadiusz Kwiatkowski
  2018-03-30  9:41     ` [PATCH v2 2/2] spi: spi-ti-qspi: Add checking which flash chip has been mmap-ed Arkadiusz Kwiatkowski
@ 2018-04-03  6:03     ` Vignesh R
  2018-04-03  9:09     ` Mark Brown
  2018-04-16 16:58     ` Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Vignesh R @ 2018-04-03  6:03 UTC (permalink / raw)
  To: Arkadiusz Kwiatkowski, broonie; +Cc: linux-spi, linux-kernel



On Friday 30 March 2018 03:11 PM, Arkadiusz Kwiatkowski wrote:
> This commit fixes the order of parameters passed to regmap_update_bits
> function inside spi-ti-qspi driver. Accidentally the code worked
> correctly when cs=0, but it is not the case for other values.
> 

Add:
Fixes: 4dea6c9b0b64 ("spi: spi-ti-qspi: add mmap mode read support")
before Signed-off-by

> Signed-off-by: Arkadiusz Kwiatkowski <arkadiusz.kwiatkowski@aptiv.com>
> ---

Unfortunately, your mail client is still mangling the patch and "git am"
 still fails to apply this from my inbox. Could you try using "git
send-email" to send patches? See
https://www.kernel.org/doc/Documentation/process/email-clients.rst for
more info

>  drivers/spi/spi-ti-qspi.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
> index c24d9b4..d0ea62d 100644
> --- a/drivers/spi/spi-ti-qspi.c
> +++ b/drivers/spi/spi-ti-qspi.c
> @@ -490,8 +490,8 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi)
>         ti_qspi_write(qspi, MM_SWITCH, QSPI_SPI_SWITCH_REG);
>         if (qspi->ctrl_base) {
>                 regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
> -                                  MEM_CS_EN(spi->chip_select),
> -                                  MEM_CS_MASK);
> +                                  MEM_CS_MASK,
> +                                  MEM_CS_EN(spi->chip_select));
>         }
>         qspi->mmap_enabled = true;
>  }
> @@ -503,7 +503,7 @@ static void ti_qspi_disable_memory_map(struct spi_device *spi)
>         ti_qspi_write(qspi, 0, QSPI_SPI_SWITCH_REG);
>         if (qspi->ctrl_base)
>                 regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
> -                                  0, MEM_CS_MASK);
> +                                  MEM_CS_MASK, 0);
>         qspi->mmap_enabled = false;
>  }
> 
> --
> 2.7.4
> 
> **************************************************************************************** Note: If the reader of this message is not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. ****************************************************************************************
> 

-- 
Regards
Vignesh

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls
  2018-03-30  9:41   ` [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls Arkadiusz Kwiatkowski
  2018-03-30  9:41     ` [PATCH v2 2/2] spi: spi-ti-qspi: Add checking which flash chip has been mmap-ed Arkadiusz Kwiatkowski
  2018-04-03  6:03     ` [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls Vignesh R
@ 2018-04-03  9:09     ` Mark Brown
  2018-04-16 16:58     ` Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2018-04-03  9:09 UTC (permalink / raw)
  To: Arkadiusz Kwiatkowski; +Cc: vigneshr, sourav.poddar, linux-spi, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 342 bytes --]

On Fri, Mar 30, 2018 at 11:41:23AM +0200, Arkadiusz Kwiatkowski wrote:
> This commit fixes the order of parameters passed to regmap_update_bits
> function inside spi-ti-qspi driver. Accidentally the code worked
> correctly when cs=0, but it is not the case for other values.

This doesn't apply against current code, please check and resend.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls
  2018-03-30  9:41   ` [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls Arkadiusz Kwiatkowski
                       ` (2 preceding siblings ...)
  2018-04-03  9:09     ` Mark Brown
@ 2018-04-16 16:58     ` Mark Brown
  3 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2018-04-16 16:58 UTC (permalink / raw)
  To: Arkadiusz Kwiatkowski; +Cc: vigneshr, sourav.poddar, linux-spi, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 342 bytes --]

On Fri, Mar 30, 2018 at 11:41:23AM +0200, Arkadiusz Kwiatkowski wrote:
> This commit fixes the order of parameters passed to regmap_update_bits
> function inside spi-ti-qspi driver. Accidentally the code worked
> correctly when cs=0, but it is not the case for other values.

This doesn't apply against current code, please check and resend.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-04-16 16:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-22 12:33 [PATCH] Fixes in TI QSPI driver to allow more than one flash chip Kwiatkowski, Arkadiusz
2018-03-27  4:00 ` Vignesh R
2018-03-30  9:41   ` [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls Arkadiusz Kwiatkowski
2018-03-30  9:41     ` [PATCH v2 2/2] spi: spi-ti-qspi: Add checking which flash chip has been mmap-ed Arkadiusz Kwiatkowski
2018-04-03  6:03     ` [PATCH v2 1/2] spi: spi-ti-qspi: Fix parameters order in regmap_update_bits calls Vignesh R
2018-04-03  9:09     ` Mark Brown
2018-04-16 16:58     ` Mark Brown

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).