All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arkadiusz Kwiatkowski <arkadiusz.kwiatkowski@aptiv.com>
To: <vigneshr@ti.com>, <sourav.poddar@ti.com>, <broonie@kernel.org>
Cc: <linux-spi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	"Arkadiusz Kwiatkowski" <arkadiusz.kwiatkowski@aptiv.com>
Subject: [PATCH v2 2/2] spi: spi-ti-qspi: Add checking which flash chip has been mmap-ed
Date: Fri, 30 Mar 2018 11:41:24 +0200	[thread overview]
Message-ID: <1522402884-26790-2-git-send-email-arkadiusz.kwiatkowski@aptiv.com> (raw)
In-Reply-To: <1522402884-26790-1-git-send-email-arkadiusz.kwiatkowski@aptiv.com>

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

  reply	other threads:[~2018-03-30  9:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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     ` Arkadiusz Kwiatkowski [this message]
2018-04-03  6:03     ` Vignesh R
2018-04-03  9:09     ` Mark Brown
2018-04-16 16:58     ` Mark Brown

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=1522402884-26790-2-git-send-email-arkadiusz.kwiatkowski@aptiv.com \
    --to=arkadiusz.kwiatkowski@aptiv.com \
    --cc=broonie@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=sourav.poddar@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.