From patchwork Mon May 30 14:57:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9141591 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 51F4360754 for ; Mon, 30 May 2016 14:58:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 437FC2819E for ; Mon, 30 May 2016 14:58:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 381EC28222; Mon, 30 May 2016 14:58:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACD542819E for ; Mon, 30 May 2016 14:58:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754998AbcE3O60 (ORCPT ); Mon, 30 May 2016 10:58:26 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:55083 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754874AbcE3O6X (ORCPT ); Mon, 30 May 2016 10:58:23 -0400 Received: from wuerfel.localnet ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0MAMbS-1bEahz1HKM-00Bf2I; Mon, 30 May 2016 16:57:33 +0200 From: Arnd Bergmann To: linuxppc-dev@lists.ozlabs.org Cc: Ulf Hansson , Yangbo Lu , Mark Rutland , Xiaobo Xie , "linux-i2c@vger.kernel.org" , "linux-clk@vger.kernel.org" , Qiang Zhao , Russell King , Bhupesh Sharma , Joerg Roedel , Claudiu Manoil , "devicetree@vger.kernel.org" , Scott Wood , Rob Herring , Santosh Shilimkar , "linux-arm-kernel@lists.infradead.org" , "netdev@vger.kernel.org" , "linux-mmc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Yang-Leo Li , "iommu@lists.linux-foundation.org" , Kumar Gala Subject: Re: [PATCH 1/4] base: soc: introduce soc_device_match() interface Date: Mon, 30 May 2016 16:57:55 +0200 Message-ID: <4811326.1KLIei2jcl@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-22-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <6032641.cjSseEG2PF@wuerfel> References: <1462417950-46796-1-git-send-email-yangbo.lu@nxp.com> <6032641.cjSseEG2PF@wuerfel> MIME-Version: 1.0 X-Provags-ID: V03:K0:NiNCT8a1ACbrVMAilAB+QmYFLh8tm2CSPukATaxxCYKwxRCRdbM 904UnoJo17D3cZtV7jpiJ0yqaglZK6e67fYkCKMd+MBYJJOIsil0PGE9SKHKZnrkxAKoA56 meWFbUbRw6cgeFztDDyXrmZNB5OPGjf8LipYk8zM00UF6ymIAR2yPe7wqA6stVawa+BFPCg IIbU5VVu4iCtygJXaUuMQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:3X1IVAj/LdQ=:mGpOEvyC54yrZI0lcaCosE 3NvLo66JtYZnsyA0VvbpJvfbrv87Xd4yQn4R0qhtEgALVDaWIB5sTRKN68BUHmECC0rqgzw6w A0svShg4pwE4CdrF/4otwAcutODl6k7f/WGPof0+0ywmrhcT4XjsX4BTht2krWeZfHlZAQX9o QlqAqvee21By9kq+SWaHdMQDCCyY6p/A7AF6XGGESebvUPJwQNSzD9avFaFoSegFGHf1atpRI F/mBw9MsSWvGDQ/6dcqheKgeBUDD3g7oQaRrX8/El1RHL7hROsTDCeZ2SyT+C8ZKbR9T5HQ9H lCdAKgRGHCp1GjYGMCx91YcuDWm2rQYMLmiwaXnAnzRp7TxBehLCHBBFjiVAhuEkvCP6JaMWr 4n9z1+JWiYT4BksTvzpJBo1tID/yJsT2Ph8Ye5gC1dIaXwrq6h3UbioU5VghqL4Kp71rSLScl YsDBCpl16f/d5F5ArQ0u1N/1NRPFIQIhZa4n6CNSDfsoZBuNi81IVQySwY4Kik2/UUaabzRZP M/XQ56fsgsLtWRvt0FNPLANVkUN6kV4hVDF1U2ewlLUHokuAcQE8BsFn/qXGtCTqEwTsYPLfj 0MJoJqDkJPu7eC0hiZEVrwckEi5HX7Wj8Ib63X2z0RGTe2A6S4dkAhQQliAhaxwUIJNPiOnj7 EJk7dW4h/s5YDfhEjOo/Q6f4a6915GNe/3tatOv7IEM1qNPIMQLHXMXzZcL9OybbYC5uxqxpc IU7RccV87Uc997Vj Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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 #include #include +#include + #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 */