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

* Re: [v2, 2/3] mmc: sdhci-of-esdhc: get SOC version and revision from GUTS_SVR
  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-02 12:04 ` Ulf Hansson
  1 sibling, 1 reply; 4+ messages in thread
From: Scott Wood @ 2015-09-02  0:23 UTC (permalink / raw)
  To: Yangbo Lu; +Cc: linux-mmc, ulf.hansson

On Thu, 2015-08-27 at 17:29 +0800, Yangbo Lu wrote:
> @@ -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

Please do not redefine this stuff in each driver that needs to reference it.

-Scott


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

* Re: [v2, 2/3] mmc: sdhci-of-esdhc: get SOC version and revision from GUTS_SVR
  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
@ 2015-09-02 12:04 ` Ulf Hansson
  1 sibling, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2015-09-02 12:04 UTC (permalink / raw)
  To: Yangbo Lu; +Cc: Scott Wood, linux-mmc

On 27 August 2015 at 11:29, Yangbo Lu <yangbo.lu@freescale.com> wrote:
> 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);

The SVR registers etc, should be managed through a syscon driver
(drivers/mfd/syscon.c).
Each client that needs to read the SVR register shall then go via the
syscon driver to fetch a "regmap" and perform the relevant actions on
it.

> +               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
>

Kind regards
Uffe

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

* Re: [v2, 2/3] mmc: sdhci-of-esdhc: get SOC version and revision from GUTS_SVR
       [not found]   ` <BY1PR0301MB119212B35DBACE0D88F274D6F2450@BY1PR0301MB1192.namprd03.prod.outlook.com>
@ 2015-09-22 15:35     ` Scott Wood
  0 siblings, 0 replies; 4+ messages in thread
From: Scott Wood @ 2015-09-22 15:35 UTC (permalink / raw)
  To: Lu Yangbo-B47093; +Cc: ulf.hansson@linaro.org, linux-mmc@vger.kernel.org

On Tue, 2015-09-22 at 03:56 -0500, Lu Yangbo-B47093 wrote:
> > -----Original Message-----
> > From: Wood Scott-B07421
> > Sent: Wednesday, September 02, 2015 8:24 AM
> > To: Lu Yangbo-B47093
> > Cc: linux-mmc@vger.kernel.org; ulf.hansson@linaro.org
> > Subject: Re: [v2, 2/3] mmc: sdhci-of-esdhc: get SOC version and revision
> > from GUTS_SVR
> > 
> > On Thu, 2015-08-27 at 17:29 +0800, Yangbo Lu wrote:
> > > @@ -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
> > 
> > Please do not redefine this stuff in each driver that needs to reference
> > it.
> > 
> > -Scott
> 
> [Lu Yangbo-B47093] SOC version definition like SVR_T4240 is in 
> arch/powerpc/include/asm/mpc85xx.h
> It's only for PPC and Uffe thought it's not good to introduce non generic 
> header file.
> Is there any suggestion about this? 

Either use ifdefs or move it to include/linux/fsl-svr.h.

It's not only for PPC.  Our ARM QorIQ chips also have SVR (accessible only 
through MMIO).

-Scott



^ permalink raw reply	[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