From: Neil Armstrong <narmstrong@baylibre.com>
To: broonie@kernel.org
Cc: Neil Armstrong <narmstrong@baylibre.com>,
linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org,
Da Xue <da@libre.computer>
Subject: [PATCH] spi: meson-spicc: save pow2 datarate between messages
Date: Tue, 9 Aug 2022 17:20:19 +0200 [thread overview]
Message-ID: <20220809152019.461741-1-narmstrong@baylibre.com> (raw)
At the end of a message, the HW gets a reset in meson_spicc_unprepare_transfer(),
this resets the SPICC_CONREG register and notably the value set by the
Common Clock Framework.
This saves the datarate dividor value between message to keep the last
set value by the Common Clock Framework.
This didn't appear before commit 3e0cf4d3fc29 ("spi: meson-spicc: add a linear clock divider support")
because we recalculated and wrote the rate for each xfer.
Fixes: 3e0cf4d3fc29 ("spi: meson-spicc: add a linear clock divider support")
Reported-by: Da Xue <da@libre.computer>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/spi/spi-meson-spicc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c
index 0bc7daa7afc8..e58686e28439 100644
--- a/drivers/spi/spi-meson-spicc.c
+++ b/drivers/spi/spi-meson-spicc.c
@@ -166,6 +166,7 @@ struct meson_spicc_device {
unsigned long tx_remain;
unsigned long rx_remain;
unsigned long xfer_remain;
+ unsigned int pow2_datarate;
};
static void meson_spicc_oen_enable(struct meson_spicc_device *spicc)
@@ -458,7 +459,8 @@ static int meson_spicc_prepare_message(struct spi_master *master,
/* Select CS */
conf |= FIELD_PREP(SPICC_CS_MASK, spi->chip_select);
- /* Default Clock rate core/4 */
+ /* Saved pow2 Clock rate */
+ conf |= FIELD_PREP(SPICC_DATARATE_MASK, spicc->pow2_datarate);
/* Default 8bit word */
conf |= FIELD_PREP(SPICC_BITLENGTH_MASK, 8 - 1);
@@ -480,6 +482,10 @@ static int meson_spicc_unprepare_transfer(struct spi_master *master)
/* Disable all IRQs */
writel(0, spicc->base + SPICC_INTREG);
+ /* Save last pow2 datarate before HW reset */
+ spicc->pow2_datarate = FIELD_GET(SPICC_DATARATE_MASK,
+ readl_relaxed(spicc->base + SPICC_CONREG));
+
device_reset_optional(&spicc->pdev->dev);
return 0;
--
2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Neil Armstrong <narmstrong@baylibre.com>
To: broonie@kernel.org
Cc: Neil Armstrong <narmstrong@baylibre.com>,
linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org,
Da Xue <da@libre.computer>
Subject: [PATCH] spi: meson-spicc: save pow2 datarate between messages
Date: Tue, 9 Aug 2022 17:20:19 +0200 [thread overview]
Message-ID: <20220809152019.461741-1-narmstrong@baylibre.com> (raw)
At the end of a message, the HW gets a reset in meson_spicc_unprepare_transfer(),
this resets the SPICC_CONREG register and notably the value set by the
Common Clock Framework.
This saves the datarate dividor value between message to keep the last
set value by the Common Clock Framework.
This didn't appear before commit 3e0cf4d3fc29 ("spi: meson-spicc: add a linear clock divider support")
because we recalculated and wrote the rate for each xfer.
Fixes: 3e0cf4d3fc29 ("spi: meson-spicc: add a linear clock divider support")
Reported-by: Da Xue <da@libre.computer>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/spi/spi-meson-spicc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c
index 0bc7daa7afc8..e58686e28439 100644
--- a/drivers/spi/spi-meson-spicc.c
+++ b/drivers/spi/spi-meson-spicc.c
@@ -166,6 +166,7 @@ struct meson_spicc_device {
unsigned long tx_remain;
unsigned long rx_remain;
unsigned long xfer_remain;
+ unsigned int pow2_datarate;
};
static void meson_spicc_oen_enable(struct meson_spicc_device *spicc)
@@ -458,7 +459,8 @@ static int meson_spicc_prepare_message(struct spi_master *master,
/* Select CS */
conf |= FIELD_PREP(SPICC_CS_MASK, spi->chip_select);
- /* Default Clock rate core/4 */
+ /* Saved pow2 Clock rate */
+ conf |= FIELD_PREP(SPICC_DATARATE_MASK, spicc->pow2_datarate);
/* Default 8bit word */
conf |= FIELD_PREP(SPICC_BITLENGTH_MASK, 8 - 1);
@@ -480,6 +482,10 @@ static int meson_spicc_unprepare_transfer(struct spi_master *master)
/* Disable all IRQs */
writel(0, spicc->base + SPICC_INTREG);
+ /* Save last pow2 datarate before HW reset */
+ spicc->pow2_datarate = FIELD_GET(SPICC_DATARATE_MASK,
+ readl_relaxed(spicc->base + SPICC_CONREG));
+
device_reset_optional(&spicc->pdev->dev);
return 0;
--
2.25.1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
WARNING: multiple messages have this Message-ID (diff)
From: Neil Armstrong <narmstrong@baylibre.com>
To: broonie@kernel.org
Cc: Neil Armstrong <narmstrong@baylibre.com>,
linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org,
Da Xue <da@libre.computer>
Subject: [PATCH] spi: meson-spicc: save pow2 datarate between messages
Date: Tue, 9 Aug 2022 17:20:19 +0200 [thread overview]
Message-ID: <20220809152019.461741-1-narmstrong@baylibre.com> (raw)
At the end of a message, the HW gets a reset in meson_spicc_unprepare_transfer(),
this resets the SPICC_CONREG register and notably the value set by the
Common Clock Framework.
This saves the datarate dividor value between message to keep the last
set value by the Common Clock Framework.
This didn't appear before commit 3e0cf4d3fc29 ("spi: meson-spicc: add a linear clock divider support")
because we recalculated and wrote the rate for each xfer.
Fixes: 3e0cf4d3fc29 ("spi: meson-spicc: add a linear clock divider support")
Reported-by: Da Xue <da@libre.computer>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/spi/spi-meson-spicc.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c
index 0bc7daa7afc8..e58686e28439 100644
--- a/drivers/spi/spi-meson-spicc.c
+++ b/drivers/spi/spi-meson-spicc.c
@@ -166,6 +166,7 @@ struct meson_spicc_device {
unsigned long tx_remain;
unsigned long rx_remain;
unsigned long xfer_remain;
+ unsigned int pow2_datarate;
};
static void meson_spicc_oen_enable(struct meson_spicc_device *spicc)
@@ -458,7 +459,8 @@ static int meson_spicc_prepare_message(struct spi_master *master,
/* Select CS */
conf |= FIELD_PREP(SPICC_CS_MASK, spi->chip_select);
- /* Default Clock rate core/4 */
+ /* Saved pow2 Clock rate */
+ conf |= FIELD_PREP(SPICC_DATARATE_MASK, spicc->pow2_datarate);
/* Default 8bit word */
conf |= FIELD_PREP(SPICC_BITLENGTH_MASK, 8 - 1);
@@ -480,6 +482,10 @@ static int meson_spicc_unprepare_transfer(struct spi_master *master)
/* Disable all IRQs */
writel(0, spicc->base + SPICC_INTREG);
+ /* Save last pow2 datarate before HW reset */
+ spicc->pow2_datarate = FIELD_GET(SPICC_DATARATE_MASK,
+ readl_relaxed(spicc->base + SPICC_CONREG));
+
device_reset_optional(&spicc->pdev->dev);
return 0;
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2022-08-09 15:20 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-09 15:20 Neil Armstrong [this message]
2022-08-09 15:20 ` [PATCH] spi: meson-spicc: save pow2 datarate between messages Neil Armstrong
2022-08-09 15:20 ` Neil Armstrong
2022-08-09 15:27 ` Mark Brown
2022-08-09 15:27 ` Mark Brown
2022-08-09 15:27 ` Mark Brown
2022-08-10 9:17 ` Neil Armstrong
2022-08-10 9:17 ` Neil Armstrong
2022-08-10 9:17 ` Neil Armstrong
2022-08-10 12:37 ` Mark Brown
2022-08-10 12:37 ` Mark Brown
2022-08-10 12:37 ` Mark Brown
2022-08-10 14:01 ` Neil Armstrong
2022-08-10 14:01 ` Neil Armstrong
2022-08-10 14:01 ` Neil Armstrong
2022-08-10 14:31 ` Mark Brown
2022-08-10 14:31 ` Mark Brown
2022-08-10 14:31 ` Mark Brown
2022-08-10 14:40 ` Neil Armstrong
2022-08-10 14:40 ` Neil Armstrong
2022-08-10 14:40 ` Neil Armstrong
2022-08-10 14:49 ` Mark Brown
2022-08-10 14:49 ` Mark Brown
2022-08-10 14:49 ` Mark Brown
2022-08-10 15:51 ` Neil Armstrong
2022-08-10 15:51 ` Neil Armstrong
2022-08-10 15:51 ` Neil Armstrong
2022-08-10 16:10 ` Mark Brown
2022-08-10 16:10 ` Mark Brown
2022-08-10 16:10 ` 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=20220809152019.461741-1-narmstrong@baylibre.com \
--to=narmstrong@baylibre.com \
--cc=broonie@kernel.org \
--cc=da@libre.computer \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
/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.