From: Yangbo Lu <yangbo.lu@freescale.com>
To: scottwood@freescale.com, linux-mmc@vger.kernel.org,
ulf.hansson@linaro.org
Cc: Yangbo Lu <yangbo.lu@freescale.com>
Subject: [v2, 2/3] mmc: sdhci-of-esdhc: get SOC version and revision from GUTS_SVR
Date: Thu, 27 Aug 2015 17:29:02 +0800 [thread overview]
Message-ID: <1440667742-25424-1-git-send-email-yangbo.lu@freescale.com> (raw)
Freescale QorIQ SOCs have the SVR(System version register) containing
the system version number for the device. Sometimes the eSDHC driver
needs to know this information for some errata workaround. So, we read
SVR from the global utilities block of the chip.
Signed-off-by: Yangbo Lu <yangbo.lu@freescale.com>
---
drivers/mmc/host/sdhci-of-esdhc.c | 42 ++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index e26e7b3..20e0b9a 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -16,6 +16,7 @@
#include <linux/err.h>
#include <linux/io.h>
#include <linux/of.h>
+#include <linux/of_address.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/mmc/host.h>
@@ -24,6 +25,16 @@
#define VENDOR_V_22 0x12
#define VENDOR_V_23 0x13
+
+/* Global Utility Registers */
+#define GUTS_SVR 0xa4 /* System Version Register */
+/* SOC version definition */
+#define SVR_T4240 0x824000
+/* SOC version */
+static u32 soc_ver;
+/* SOC revision */
+static u8 soc_rev;
+
static u32 esdhc_readl(struct sdhci_host *host, int reg)
{
u32 ret;
@@ -354,10 +365,26 @@ static const struct sdhci_pltfm_data sdhci_esdhc_pdata = {
.ops = &sdhci_esdhc_ops,
};
+/*
+ * Table for matching compatible strings, for device tree
+ * guts node, for Freescale QorIQ SOCs.
+ * "fsl,qoriq-device-config-2.0" corresponds to T4 & B4
+ * SOCs. For the older SOCs "fsl,qoriq-device-config-1.0"
+ * string would be used.
+ */
+static const struct of_device_id guts_device_ids[] = {
+ { .compatible = "fsl,qoriq-device-config-1.0", },
+ { .compatible = "fsl,qoriq-device-config-2.0", },
+ {}
+};
+
static void esdhc_get_property(struct platform_device *pdev)
{
- struct device_node *np = pdev->dev.of_node;
struct sdhci_host *host = platform_get_drvdata(pdev);
+ struct device_node *np = pdev->dev.of_node;
+ struct device_node *guts_node;
+ void __iomem *guts_base;
+ u32 svr;
sdhci_get_of_property(pdev);
@@ -365,6 +392,19 @@ static void esdhc_get_property(struct platform_device *pdev)
mmc_of_parse(host->mmc);
mmc_of_parse_voltage(np, &host->ocr_mask);
+ /* Get SVR */
+ guts_node = of_find_matching_node(NULL, guts_device_ids);
+ if (guts_node) {
+ guts_base = of_iomap(guts_node, 0);
+ of_node_put(guts_node);
+ if (guts_base) {
+ svr = in_be32(guts_base + GUTS_SVR);
+ soc_ver = (svr >> 8) & 0xfff7ff;
+ soc_rev = svr & 0xff;
+ iounmap(guts_base);
+ }
+ }
+
if (of_device_is_compatible(np, "fsl,p5040-esdhc") ||
of_device_is_compatible(np, "fsl,p5020-esdhc") ||
of_device_is_compatible(np, "fsl,p4080-esdhc") ||
--
2.1.0.27.g96db324
next reply other threads:[~2015-08-27 9:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 9:29 Yangbo Lu [this message]
2015-09-02 0:23 ` [v2, 2/3] mmc: sdhci-of-esdhc: get SOC version and revision from GUTS_SVR Scott Wood
[not found] ` <BY1PR0301MB119212B35DBACE0D88F274D6F2450@BY1PR0301MB1192.namprd03.prod.outlook.com>
2015-09-22 15:35 ` Scott Wood
2015-09-02 12:04 ` Ulf Hansson
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=1440667742-25424-1-git-send-email-yangbo.lu@freescale.com \
--to=yangbo.lu@freescale.com \
--cc=linux-mmc@vger.kernel.org \
--cc=scottwood@freescale.com \
--cc=ulf.hansson@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox