From: Serge Semin <Sergey.Semin@baikalelectronics.ru>
To: Serge Semin <fancer.lancer@gmail.com>,
Mark Brown <broonie@kernel.org>,
Nandhini Srikandan <nandhini.srikandan@intel.com>
Cc: Serge Semin <Sergey.Semin@baikalelectronics.ru>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Andy Shevchenko <andy@kernel.org>, <linux-spi@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH 4/4] spi: dw: Add Synopsys Component version reading and parsing
Date: Fri, 12 Nov 2021 23:49:27 +0300 [thread overview]
Message-ID: <20211112204927.8830-5-Sergey.Semin@baikalelectronics.ru> (raw)
In-Reply-To: <20211112204927.8830-1-Sergey.Semin@baikalelectronics.ru>
Each Synopsys DWC SSI controller is equipped with a Synopsys Component
version register, which encodes a version ID of an IP-core the
controller has been synthesized from. That can be useful in future for the
version-based conditional features implementation in the driver.
Note the component version is encoded as an ASCII string so we need to
convert it from the string to a normal unsigned integer to be easily used
then in the driver statements.
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
---
drivers/spi/spi-dw-core.c | 18 ++++++++++++++++++
drivers/spi/spi-dw.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c
index b4cbcd38eaba..1766a29ca790 100644
--- a/drivers/spi/spi-dw-core.c
+++ b/drivers/spi/spi-dw-core.c
@@ -823,6 +823,24 @@ static void dw_spi_hw_init(struct device *dev, struct dw_spi *dws)
{
dw_spi_reset_chip(dws);
+ /*
+ * Retrieve the Synopsys component version if it hasn't been specified
+ * by the platform. Note the CoreKit version ID is encoded as a 4bytes
+ * ASCII string enclosed with '*' symbol.
+ */
+ if (!dws->ver) {
+ u32 comp;
+
+ comp = dw_readl(dws, DW_SPI_VERSION);
+ dws->ver = (DW_SPI_GET_BYTE(comp, 3) - '0') * 100;
+ dws->ver += (DW_SPI_GET_BYTE(comp, 2) - '0') * 10;
+ dws->ver += (DW_SPI_GET_BYTE(comp, 1) - '0');
+
+ dev_dbg(dev, "Synopsys DWC%sSSI v%u.%02u\n",
+ (dws->caps & DW_SPI_CAP_DWC_HSSI) ? " " : " APB ",
+ dws->ver / 100, dws->ver % 100);
+ }
+
/*
* Try to detect the FIFO depth if not set by interface driver,
* the depth could be from 2 to 256 from HW spec
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index 634085eadad1..d06857d8d173 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -149,6 +149,7 @@ struct dw_spi {
u32 max_mem_freq; /* max mem-ops bus freq */
u32 max_freq; /* max bus freq supported */
+ u32 ver; /* Synopsys component version */
u32 caps; /* DW SPI capabilities */
u32 reg_io_width; /* DR I/O width in bytes */
--
2.33.0
next prev parent reply other threads:[~2021-11-12 20:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-12 20:49 [PATCH 0/4] spi: dw: Cleanup macros/funcs naming and add IP-core version support Serge Semin
2021-11-12 20:49 ` [PATCH 1/4] spi: dw: Discard redundant DW SSI Frame Formats enumeration Serge Semin
2021-11-12 20:49 ` [PATCH 2/4] spi: dw: Put the driver entities naming in order Serge Semin
2021-11-12 21:22 ` Andy Shevchenko
2021-11-12 21:30 ` Serge Semin
2021-11-12 20:49 ` [PATCH 3/4] spi: dw: Convert to using the Bitfield access macros Serge Semin
2021-11-12 21:23 ` Andy Shevchenko
2021-11-12 21:43 ` Serge Semin
2021-11-12 20:49 ` Serge Semin [this message]
2021-11-12 21:27 ` [PATCH 4/4] spi: dw: Add Synopsys Component version reading and parsing Andy Shevchenko
2021-11-12 21:37 ` Andy Shevchenko
2021-11-12 22:05 ` Serge Semin
[not found] ` <CAHp75VdP6WL=cFn2eaDC8VH7C+fd11xKxp5_qrFuArubD4KgEQ@mail.gmail.com>
2021-11-13 0:19 ` Serge Semin
2021-11-13 13:15 ` Andy Shevchenko
2021-11-13 21:30 ` Serge Semin
2021-11-12 21:30 ` [PATCH 0/4] spi: dw: Cleanup macros/funcs naming and add IP-core version support Andy Shevchenko
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=20211112204927.8830-5-Sergey.Semin@baikalelectronics.ru \
--to=sergey.semin@baikalelectronics.ru \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=broonie@kernel.org \
--cc=fancer.lancer@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=nandhini.srikandan@intel.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
all inboxes | Powered by JetHome®