From: Arnd Bergmann <arnd@arndb.de>
To: linuxppc-dev@lists.ozlabs.org
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
Yangbo Lu <yangbo.lu@nxp.com>,
Mark Rutland <mark.rutland@arm.com>,
Xiaobo Xie <xiaobo.xie@nxp.com>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
"linux-clk@vger.kernel.org" <linux-clk@vger.kernel.org>,
Qiang Zhao <qiang.zhao@nxp.com>,
Russell King <linux@arm.linux.org.uk>,
Bhupesh Sharma <bhupesh.sharma@freescale.com>,
Joerg Roedel <joro@8bytes.org>,
Claudiu Manoil <claudiu.manoil@freescale.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Scott Wood <oss@buserror.net>, Rob Herring <robh+dt@kernel.org>,
Santosh Shilimkar <ssantosh@kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Yang-Leo
Subject: Re: [PATCH 1/4] base: soc: introduce soc_device_match() interface
Date: Mon, 30 May 2016 16:57:55 +0200 [thread overview]
Message-ID: <4811326.1KLIei2jcl@wuerfel> (raw)
In-Reply-To: <6032641.cjSseEG2PF@wuerfel>
On Monday, May 30, 2016 3:14:38 PM CEST Arnd Bergmann wrote:
> We keep running into cases where device drivers want to know the exact
> version of the SoC a they are currently running on. In the past, this
> has usually been done through a vendor specific API that can be called
> by a driver, or by directly accessing some kind of version register
> that is not part of the device itself but that belongs to a global
> register area of the chip.
>
> Common reasons for doing this include:
>
> - A machine is not using devicetree or similar for passing data
> about on-chip devices, but just announces their presence using
> boot-time platform devices, and the machine code itself does
> not care about the revision.
>
> - There is existing firmware or boot loaders with existing DT
> binaries with generic compatible strings that do not identify
> the particular revision of each device, but the driver knows
> which SoC revisions include which part
>
> - A prerelease version of a chip has some quirks and we are
> using the same version of the bootloader and the DT blob
> on both the prerelease and the final version. An update of
> the DT binding seems inappropriate because that would involve
> maintaining multiple copies of the dts and/or bootloader.
>
> This introduces the soc_device_match() interface that is meant
> to work like of_match_node() but instead of identifying the
> version of a device, it identifies the SoC itself using a
> vendor-agnostic interface.
>
> Unlike soc_device_match(), we do not do an exact string compare
> but instead use glob_match() to allow wildcards in strings.
I'm sorry the series introduced build failures (I had done some changes
after testing), here is a quick fixup. I'll resend the whole thing
after someone has looked at it as none of the changes below should
have any influence on the review.
Arnd
diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index e9623c6674a5..c38573249777 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -173,7 +173,7 @@ module_exit(soc_bus_unregister);
static int soc_device_match_one(struct device *dev, void *arg)
{
struct soc_device *soc_dev = container_of(dev, struct soc_device, dev);
- struct soc_device_attribute *match = arg;
+ const struct soc_device_attribute *match = arg;
if (match->machine && !glob_match(match->machine, soc_dev->attr->machine))
return 0;
@@ -208,7 +208,7 @@ static int soc_device_match_one(struct device *dev, void *arg)
* soc_device_attribute to pass a structure or function pointer for
* each entry.
*/
-struct soc_device_attribute *soc_device_match(struct soc_device_attribute *matches)
+const struct soc_device_attribute *soc_device_match(const struct soc_device_attribute *matches)
{
struct device *dev;
int ret;
@@ -219,7 +219,7 @@ struct soc_device_attribute *soc_device_match(struct soc_device_attribute *match
return NULL;
dev = NULL;
- ret = bus_for_each_dev(&soc_bus_type, dev, matches,
+ ret = bus_for_each_dev(&soc_bus_type, dev, (void *)matches,
soc_device_match_one);
}
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 1d4814fe4cb2..a7b8b05a13e8 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -19,6 +19,8 @@
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/mmc/host.h>
+#include <linux/sys_soc.h>
+
#include "sdhci-pltfm.h"
#include "sdhci-esdhc.h"
@@ -75,7 +77,6 @@ static u16 esdhc_readw_fixup(struct sdhci_host *host,
{
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host);
- u16 ret;
int shift = (spec_reg & 0x2) * 8;
if (spec_reg == SDHCI_HOST_VERSION)
@@ -565,7 +566,7 @@ static const struct sdhci_pltfm_data sdhci_esdhc_le_pdata = {
};
#define T4240_HOST_VER ((VENDOR_V_23 << SDHCI_VENDOR_VER_SHIFT) | SDHCI_SPEC_200)
-static const struct soc_device_attribute esdhc_t4240_quirk = {
+static const struct soc_device_attribute esdhc_t4240_quirk[] = {
/* T4240 revision < 0x20 uses vendor version 23, SDHCI version 200 */
{ .soc_id = "T4*(0x824000)", .revision = "0x[01]?",
.data = (void *)(uintptr_t)(T4240_HOST_VER) },
@@ -576,6 +577,7 @@ static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host)
{
struct sdhci_pltfm_host *pltfm_host;
struct sdhci_esdhc *esdhc;
+ u32 host_ver;
pltfm_host = sdhci_priv(host);
esdhc = sdhci_pltfm_priv(pltfm_host);
@@ -583,9 +585,9 @@ static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host)
host_ver = sdhci_readw(host, SDHCI_HOST_VERSION);
if (of_device_is_compatible(pdev->dev.of_node, "fsl,t4240-esdhc")) {
- struct soc_device_attribute *match;
+ const struct soc_device_attribute *match;
- match = soc_device_match(&esdhc_t4240_quirk);
+ match = soc_device_match(esdhc_t4240_quirk);
if (match)
host_ver = (uintptr_t)match->data;
}
diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c
index 2f30698f5bcf..476969644bed 100644
--- a/drivers/soc/fsl/guts.c
+++ b/drivers/soc/fsl/guts.c
@@ -34,14 +34,6 @@ static u32 fsl_guts_get_svr(struct guts *guts)
return ioread32be(guts->regs + GUTS_SVR);
}
-static u32 fsl_guts_get_pvr(struct guts *guts)
-{
- if (guts->little_endian)
- return ioread32(guts->regs + GUTS_PVR);
- else
- return ioread32be(guts->regs + GUTS_PVR);
-}
-
/*
* Table for matching compatible strings, for device tree
* guts node, for Freescale QorIQ SOCs.
@@ -76,13 +68,15 @@ static const struct of_device_id fsl_guts_of_match[] = {
static void fsl_guts_init(struct device *dev, struct guts *guts)
{
- const struct of_device_id *id;
u32 svr = fsl_guts_get_svr(guts);
+ const struct of_device_id *id;
+ const char *socname;
guts->soc.family = "NXP QorIQ";
id = of_match_node(fsl_guts_of_match, dev->of_node);
- guts->soc.soc_id = devm_kasprintf(dev, "%s (ver 0x%06x)" id->data,
- svr >> 8;
+ socname = id->data;
+ guts->soc.soc_id = devm_kasprintf(dev, GFP_KERNEL, "%s (ver 0x%06x)",
+ socname, svr >> 8);
guts->soc.revision = devm_kasprintf(dev, GFP_KERNEL, "0x%02x",
svr & 0xff);
}
diff --git a/include/linux/sys_soc.h b/include/linux/sys_soc.h
index 02c48c76052b..3dfc8714a88c 100644
--- a/include/linux/sys_soc.h
+++ b/include/linux/sys_soc.h
@@ -36,6 +36,6 @@ void soc_device_unregister(struct soc_device *soc_dev);
*/
struct device *soc_device_to_device(struct soc_device *soc);
-struct soc_device_attribute *soc_device_match(struct soc_device_attribute *matches);
+const struct soc_device_attribute *soc_device_match(const struct soc_device_attribute *matches);
#endif /* __SOC_BUS_H */
next prev parent reply other threads:[~2016-05-30 14:57 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-05 3:12 [v10, 0/7] Fix eSDHC host version register bug Yangbo Lu
[not found] ` <1462417950-46796-1-git-send-email-yangbo.lu-3arQi8VN3Tc@public.gmane.org>
2016-05-05 3:12 ` [v10, 1/7] Documentation: DT: update Freescale DCFG compatible Yangbo Lu
2016-05-05 22:25 ` Rob Herring
2016-05-05 3:12 ` [v10, 2/7] ARM64: dts: ls2080a: add device configuration node Yangbo Lu
2016-05-05 3:12 ` [v10, 3/7] soc: fsl: add GUTS driver for QorIQ platforms Yangbo Lu
2016-07-15 16:43 ` Paul Gortmaker
2016-07-15 19:12 ` Scott Wood
2016-07-15 22:39 ` Paul Gortmaker
2016-05-05 3:12 ` [v10, 4/7] dt: move guts devicetree doc out of powerpc directory Yangbo Lu
2016-05-05 3:12 ` [v10, 5/7] powerpc/fsl: move mpc85xx.h to include/linux/fsl Yangbo Lu
2016-05-05 3:12 ` [v10, 6/7] MAINTAINERS: add entry for Freescale SoC drivers Yangbo Lu
2016-05-05 3:12 ` [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0 Yangbo Lu
[not found] ` <1462417950-46796-8-git-send-email-yangbo.lu-3arQi8VN3Tc@public.gmane.org>
2016-05-05 8:31 ` Arnd Bergmann
2016-05-05 9:41 ` Yangbo Lu
[not found] ` <HE1PR04MB0889B52134A43C0E7A452B7BF87C0-6LN7OEpIatX1kPMWxTxe+c9NdZoXdze2vxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-05-05 11:10 ` Arnd Bergmann
2016-05-11 3:26 ` Scott Wood
[not found] ` <1462937186.16584.77.camel-fOR+EgIDQEHk1uMJSBkQmQ@public.gmane.org>
2016-05-20 6:05 ` Yangbo Lu
2016-05-26 4:05 ` Yangbo Lu
2016-05-26 7:44 ` Ulf Hansson
2016-05-30 13:13 ` Arnd Bergmann
2016-05-30 13:14 ` [PATCH 1/4] base: soc: introduce soc_device_match() interface Arnd Bergmann
2016-05-30 14:57 ` Arnd Bergmann [this message]
2016-05-30 13:15 ` [PATCH 2/4] soc: fsl: add GUTS driver for QorIQ platforms Arnd Bergmann
2016-06-02 1:47 ` Scott Wood
2016-06-02 8:43 ` Arnd Bergmann
2016-06-11 1:50 ` Scott Wood
[not found] ` <1465609853.22191.151.camel-fOR+EgIDQEHk1uMJSBkQmQ@public.gmane.org>
2016-06-23 2:46 ` Yangbo Lu
2016-07-07 2:35 ` Yangbo Lu
[not found] ` <HE1PR04MB0889646206BFAD68046F3473F83B0-6LN7OEpIatX1kPMWxTxe+c9NdZoXdze2vxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2016-07-07 8:30 ` Arnd Bergmann
2016-07-07 20:42 ` Scott Wood
2016-07-08 3:05 ` Yangbo Lu
2016-05-30 13:16 ` [PATCH 3/4] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0 Arnd Bergmann
2016-06-02 1:11 ` Scott Wood
2016-06-02 8:52 ` Arnd Bergmann
2016-06-11 2:00 ` Scott Wood
2016-05-30 13:18 ` [PATCH 4/4] Revert "powerpc/fsl: Move fsl_guts.h out of arch/powerpc" Arnd Bergmann
2016-06-02 1:24 ` Scott Wood
[not found] ` <1464830660.22191.6.camel-fOR+EgIDQEHk1uMJSBkQmQ@public.gmane.org>
2016-06-02 9:01 ` Arnd Bergmann
2016-06-11 2:13 ` Scott Wood
2017-04-03 14:16 ` [v10, 7/7] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0 Kiran Kumar
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=4811326.1KLIei2jcl@wuerfel \
--to=arnd@arndb.de \
--cc=bhupesh.sharma@freescale.com \
--cc=claudiu.manoil@freescale.com \
--cc=devicetree@vger.kernel.org \
--cc=joro@8bytes.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mark.rutland@arm.com \
--cc=netdev@vger.kernel.org \
--cc=oss@buserror.net \
--cc=qiang.zhao@nxp.com \
--cc=robh+dt@kernel.org \
--cc=ssantosh@kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=xiaobo.xie@nxp.com \
--cc=yangbo.lu@nxp.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;
as well as URLs for NNTP newsgroup(s).