aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ath79
diff options
context:
space:
mode:
authorOskari Lemmela <oskari@lemmela.net>2022-01-26 08:38:43 +0200
committerHauke Mehrtens <hauke@hauke-m.de>2022-05-17 23:15:46 +0200
commit95c315f2001213b80c868f021df806adea236cb2 (patch)
treee20a53f95d43b965abf9a5ca8a328ded97139ef7 /target/linux/ath79
parent97a2012ecc245d4a3be07611e1ae7b7d5d6d4628 (diff)
downloadupstream-95c315f2001213b80c868f021df806adea236cb2.tar.gz
upstream-95c315f2001213b80c868f021df806adea236cb2.tar.bz2
upstream-95c315f2001213b80c868f021df806adea236cb2.zip
ath79: fix ar934x spi driver delays
Backport spi driver delay fixes from the 5.17-rc1 kernel. Signed-off-by: Oskari Lemmela <oskari@lemmela.net> [port also to kernel 5.15] Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com> (cherry picked from commit f8e65fecee1a60a5cde827d4f5df751a02916156)
Diffstat (limited to 'target/linux/ath79')
-rw-r--r--target/linux/ath79/patches-5.10/402-v5.17-spi-ar934x-fix-transfer-and-word-delays.patch27
-rw-r--r--target/linux/ath79/patches-5.10/403-v5.17-spi-ar934x-fix-transfer-size.patch62
2 files changed, 89 insertions, 0 deletions
diff --git a/target/linux/ath79/patches-5.10/402-v5.17-spi-ar934x-fix-transfer-and-word-delays.patch b/target/linux/ath79/patches-5.10/402-v5.17-spi-ar934x-fix-transfer-and-word-delays.patch
new file mode 100644
index 0000000000..7ce6df6d7b
--- /dev/null
+++ b/target/linux/ath79/patches-5.10/402-v5.17-spi-ar934x-fix-transfer-and-word-delays.patch
@@ -0,0 +1,27 @@
+From c70282457c380db7deb57c81a6894debc8f88efa Mon Sep 17 00:00:00 2001
+From: Oskari Lemmela <oskari@lemmela.net>
+Date: Wed, 22 Dec 2021 07:59:58 +0200
+Subject: [PATCH] spi: ar934x: fix transfer and word delays
+
+Add missing delay between transferred messages and words.
+
+Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
+Link: https://lore.kernel.org/r/20211222055958.1383233-3-oskari@lemmela.net
+Signed-off-by: Mark Brown <broonie@kernel.org>
+---
+ drivers/spi/spi-ar934x.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/drivers/spi/spi-ar934x.c
++++ b/drivers/spi/spi-ar934x.c
+@@ -137,8 +137,10 @@ static int ar934x_spi_transfer_one_messa
+ reg >>= 8;
+ }
+ }
++ spi_delay_exec(&t->word_delay, t);
+ }
+ m->actual_length += t->len;
++ spi_transfer_delay_exec(t);
+ }
+
+ msg_done:
diff --git a/target/linux/ath79/patches-5.10/403-v5.17-spi-ar934x-fix-transfer-size.patch b/target/linux/ath79/patches-5.10/403-v5.17-spi-ar934x-fix-transfer-size.patch
new file mode 100644
index 0000000000..87f5da2c60
--- /dev/null
+++ b/target/linux/ath79/patches-5.10/403-v5.17-spi-ar934x-fix-transfer-size.patch
@@ -0,0 +1,62 @@
+From ebe33e5a98dcf14a9630845f3f10c193584ac054 Mon Sep 17 00:00:00 2001
+From: Oskari Lemmela <oskari@lemmela.net>
+Date: Wed, 22 Dec 2021 07:59:57 +0200
+Subject: [PATCH] spi: ar934x: fix transfer size
+
+If bits_per_word is configured, transfer only word amount
+of data per iteration.
+
+Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
+Link: https://lore.kernel.org/r/20211222055958.1383233-2-oskari@lemmela.net
+Signed-off-by: Mark Brown <broonie@kernel.org>
+---
+ drivers/spi/spi-ar934x.c | 16 +++++++++++-----
+ 1 file changed, 11 insertions(+), 5 deletions(-)
+
+--- a/drivers/spi/spi-ar934x.c
++++ b/drivers/spi/spi-ar934x.c
+@@ -82,7 +82,7 @@ static int ar934x_spi_transfer_one_messa
+ struct spi_device *spi = m->spi;
+ unsigned long trx_done, trx_cur;
+ int stat = 0;
+- u8 term = 0;
++ u8 bpw, term = 0;
+ int div, i;
+ u32 reg;
+ const u8 *tx_buf;
+@@ -90,6 +90,11 @@ static int ar934x_spi_transfer_one_messa
+
+ m->actual_length = 0;
+ list_for_each_entry(t, &m->transfers, transfer_list) {
++ if (t->bits_per_word >= 8 && t->bits_per_word < 32)
++ bpw = t->bits_per_word >> 3;
++ else
++ bpw = 4;
++
+ if (t->speed_hz)
+ div = ar934x_spi_clk_div(sp, t->speed_hz);
+ else
+@@ -105,10 +110,10 @@ static int ar934x_spi_transfer_one_messa
+ iowrite32(reg, sp->base + AR934X_SPI_REG_CTRL);
+ iowrite32(0, sp->base + AR934X_SPI_DATAOUT);
+
+- for (trx_done = 0; trx_done < t->len; trx_done += 4) {
++ for (trx_done = 0; trx_done < t->len; trx_done += bpw) {
+ trx_cur = t->len - trx_done;
+- if (trx_cur > 4)
+- trx_cur = 4;
++ if (trx_cur > bpw)
++ trx_cur = bpw;
+ else if (list_is_last(&t->transfer_list, &m->transfers))
+ term = 1;
+
+@@ -193,7 +198,8 @@ static int ar934x_spi_probe(struct platf
+ ctlr->mode_bits = SPI_LSB_FIRST;
+ ctlr->setup = ar934x_spi_setup;
+ ctlr->transfer_one_message = ar934x_spi_transfer_one_message;
+- ctlr->bits_per_word_mask = SPI_BPW_MASK(8);
++ ctlr->bits_per_word_mask = SPI_BPW_MASK(32) | SPI_BPW_MASK(24) |
++ SPI_BPW_MASK(16) | SPI_BPW_MASK(8);
+ ctlr->dev.of_node = pdev->dev.of_node;
+ ctlr->num_chipselect = 3;
+