Linux MultiMedia Card development
 help / color / mirror / Atom feed
* [v2, 2/3] mmc: sdhci-of-esdhc: get SOC version and revision from GUTS_SVR
@ 2015-08-27  9:29 Yangbo Lu
  2015-09-02  0:23 ` Scott Wood
  2015-09-02 12:04 ` Ulf Hansson
  0 siblings, 2 replies; 4+ messages in thread
From: Yangbo Lu @ 2015-08-27  9:29 UTC (permalink / raw)
  To: scottwood, linux-mmc, ulf.hansson; +Cc: Yangbo Lu

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-09-22 15:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-27  9:29 [v2, 2/3] mmc: sdhci-of-esdhc: get SOC version and revision from GUTS_SVR Yangbo Lu
2015-09-02  0:23 ` Scott Wood
     [not found]   ` <BY1PR0301MB119212B35DBACE0D88F274D6F2450@BY1PR0301MB1192.namprd03.prod.outlook.com>
2015-09-22 15:35     ` Scott Wood
2015-09-02 12:04 ` Ulf Hansson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox