From: Neil Armstrong <narmstrong@baylibre.com>
To: broonie@kernel.org
Cc: Sunny Luo <sunny.luo@amlogic.com>,
linux-spi@vger.kernel.org, linux-amlogic@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Yixun Lan <yixun.lan@amlogic.com>,
Neil Armstrong <narmstrong@baylibre.com>
Subject: [PATCH 2/9] spi: meson-spicc: enhance output enable feature
Date: Thu, 12 Mar 2020 14:31:24 +0100 [thread overview]
Message-ID: <20200312133131.26430-3-narmstrong@baylibre.com> (raw)
In-Reply-To: <20200312133131.26430-1-narmstrong@baylibre.com>
From: Sunny Luo <sunny.luo@amlogic.com>
The SPICC controller in Meson-AXG is capable of driving the CLK/MOSI/SS
signal lines through the idle state (between two transmission operation),
which avoid the signals floating in unexpected state.
Signed-off-by: Sunny Luo <sunny.luo@amlogic.com>
Signed-off-by: Yixun Lan <yixun.lan@amlogic.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/spi/spi-meson-spicc.c | 53 +++++++++++++++++++++++++++++++++--
1 file changed, 51 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c
index 8425e5ae1273..ba70ef94a82a 100644
--- a/drivers/spi/spi-meson-spicc.c
+++ b/drivers/spi/spi-meson-spicc.c
@@ -9,11 +9,13 @@
#include <linux/bitfield.h>
#include <linux/clk.h>
+#include <linux/clk-provider.h>
#include <linux/device.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
#include <linux/types.h>
@@ -113,12 +115,23 @@
#define SPICC_DWADDR 0x24 /* Write Address of DMA */
+#define SPICC_ENH_CTL0 0x38 /* Enhanced Feature */
+#define SPICC_ENH_MOSI_OEN BIT(25)
+#define SPICC_ENH_CLK_OEN BIT(26)
+#define SPICC_ENH_CS_OEN BIT(27)
+#define SPICC_ENH_CLK_CS_DELAY_EN BIT(28)
+#define SPICC_ENH_MAIN_CLK_AO BIT(29)
+
#define writel_bits_relaxed(mask, val, addr) \
writel_relaxed((readl_relaxed(addr) & ~(mask)) | (val), addr)
#define SPICC_BURST_MAX 16
#define SPICC_FIFO_HALF 10
+struct meson_spicc_data {
+ bool has_oen;
+};
+
struct meson_spicc_device {
struct spi_master *master;
struct platform_device *pdev;
@@ -126,6 +139,7 @@ struct meson_spicc_device {
struct clk *core;
struct spi_message *message;
struct spi_transfer *xfer;
+ const struct meson_spicc_data *data;
u8 *tx_buf;
u8 *rx_buf;
unsigned int bytes_per_word;
@@ -136,6 +150,19 @@ struct meson_spicc_device {
bool is_last_burst;
};
+static void meson_spicc_oen_enable(struct meson_spicc_device *spicc)
+{
+ u32 conf;
+
+ if (!spicc->data->has_oen)
+ return;
+
+ conf = readl_relaxed(spicc->base + SPICC_ENH_CTL0) |
+ SPICC_ENH_MOSI_OEN | SPICC_ENH_CLK_OEN | SPICC_ENH_CS_OEN;
+
+ writel_relaxed(conf, spicc->base + SPICC_ENH_CTL0);
+}
+
static inline bool meson_spicc_txfull(struct meson_spicc_device *spicc)
{
return !!FIELD_GET(SPICC_TF,
@@ -489,6 +516,13 @@ static int meson_spicc_probe(struct platform_device *pdev)
spicc = spi_master_get_devdata(master);
spicc->master = master;
+ spicc->data = of_device_get_match_data(&pdev->dev);
+ if (!spicc->data) {
+ dev_err(&pdev->dev, "failed to get match data\n");
+ ret = -EINVAL;
+ goto out_master;
+ }
+
spicc->pdev = pdev;
platform_set_drvdata(pdev, spicc);
@@ -548,6 +582,8 @@ static int meson_spicc_probe(struct platform_device *pdev)
else
master->max_speed_hz = rate >> 2;
+ meson_spicc_oen_enable(spicc);
+
ret = devm_spi_register_master(&pdev->dev, master);
if (ret) {
dev_err(&pdev->dev, "spi master registration failed\n");
@@ -577,9 +613,22 @@ static int meson_spicc_remove(struct platform_device *pdev)
return 0;
}
+static const struct meson_spicc_data meson_spicc_gx_data = {
+};
+
+static const struct meson_spicc_data meson_spicc_axg_data = {
+ .has_oen = true,
+};
+
static const struct of_device_id meson_spicc_of_match[] = {
- { .compatible = "amlogic,meson-gx-spicc", },
- { .compatible = "amlogic,meson-axg-spicc", },
+ {
+ .compatible = "amlogic,meson-gx-spicc",
+ .data = &meson_spicc_gx_data,
+ },
+ {
+ .compatible = "amlogic,meson-axg-spicc",
+ .data = &meson_spicc_axg_data,
+ },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, meson_spicc_of_match);
--
2.22.0
next prev parent reply other threads:[~2020-03-12 13:31 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-12 13:31 [PATCH 0/9] spi: meson-spicc: add support for AXG and G12A variants Neil Armstrong
2020-03-12 13:31 ` [PATCH 1/9] spi: meson-spicc: remove unused variables Neil Armstrong
2020-03-12 17:39 ` Applied "spi: meson-spicc: remove unused variables" to the spi tree Mark Brown
2020-03-12 13:31 ` Neil Armstrong [this message]
2020-03-12 17:39 ` Applied "spi: meson-spicc: enhance output enable feature" " Mark Brown
2020-03-12 13:31 ` [PATCH 3/9] spi: meson-spicc: add a linear clock divider support Neil Armstrong
2020-03-12 17:39 ` Applied "spi: meson-spicc: add a linear clock divider support" to the spi tree Mark Brown
2020-03-12 13:31 ` [PATCH 4/9] spi: meson-spicc: support max 80MHz clock Neil Armstrong
2020-03-12 17:39 ` Applied "spi: meson-spicc: support max 80MHz clock" to the spi tree Mark Brown
2020-03-12 13:31 ` [PATCH 5/9] spi: meson-spicc: add min sclk for each compatible Neil Armstrong
2020-03-12 17:39 ` Applied "spi: meson-spicc: add min sclk for each compatible" to the spi tree Mark Brown
2020-03-12 13:31 ` [PATCH 6/9] spi: meson-spicc: setup IO line delay Neil Armstrong
2020-03-12 17:39 ` Applied "spi: meson-spicc: setup IO line delay" to the spi tree Mark Brown
2020-03-12 13:31 ` [PATCH 7/9] spi: meson-spicc: adapt burst handling for G12A support Neil Armstrong
2020-03-12 17:39 ` Applied "spi: meson-spicc: adapt burst handling for G12A support" to the spi tree Mark Brown
2020-03-12 13:31 ` [PATCH 8/9] dt-bindings: spi: amlogic,meson-gx-spicc: add Amlogic G12A compatible Neil Armstrong
2020-03-12 17:38 ` Applied "spi: dt-bindings: amlogic, meson-gx-spicc: add Amlogic G12A compatible" to the spi tree Mark Brown
2020-03-12 13:31 ` [PATCH 9/9] spi: meson-spicc: add support for Amlogic G12A Neil Armstrong
2020-03-12 17:39 ` Applied "spi: meson-spicc: add support for Amlogic G12A" to the spi tree 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=20200312133131.26430-3-narmstrong@baylibre.com \
--to=narmstrong@baylibre.com \
--cc=broonie@kernel.org \
--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 \
--cc=sunny.luo@amlogic.com \
--cc=yixun.lan@amlogic.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome