From patchwork Mon May 30 13:16:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9141385 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 AE6A760759 for ; Mon, 30 May 2016 13:16:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A348228185 for ; Mon, 30 May 2016 13:16:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 982A828222; Mon, 30 May 2016 13:16:47 +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 269BF28185 for ; Mon, 30 May 2016 13:16:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161269AbcE3NQ0 (ORCPT ); Mon, 30 May 2016 09:16:26 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:60417 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161029AbcE3NQY (ORCPT ); Mon, 30 May 2016 09:16:24 -0400 Received: from wuerfel.localnet ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue001) with ESMTPSA (Nemesis) id 0LmzUL-1bi3Eb1ZwD-00hOB6; Mon, 30 May 2016 15:15:36 +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: [PATCH 3/4] mmc: sdhci-of-esdhc: fix host version for T4240-R1.0-R2.0 Date: Mon, 30 May 2016 15:16:03 +0200 Message-ID: <6110875.0k1HlSKhzn@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-22-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <1462417950-46796-1-git-send-email-yangbo.lu@nxp.com> MIME-Version: 1.0 X-Provags-ID: V03:K0:sSiyHKvfn8OwkNlghWrokZW42k2h0Yyu+sg0gfOE10VgcfCBFXY 24FzNW/9etvYaUjKcIqIN91KBtsI4pYAzZImjU8RtluO/xqXyJnDEal2AeLmR3+Gm/HWCGS D7k4aR2bbjAakRPHIBZSFKZ0Z3DZWaWSzTbdgmBZaEtzZ+/bAew8x8f/IIUOAvEKZUqZqEx H1Xsnjfa5aicICfq+Uz0Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:1+YnI9spbTU=:89dWD+wbgHxMm6BiC1sQSa whueVQKlVVD5cO9nN2AD3ZzTVbU+upfFIFVFs2/hMpcDeOtc+EGnSBNvXFesEo6Y7fOyozBn3 NJZg8+UjxtkUF3DdE4DWacbGKUWpAdXv0wwOszj5zWy/8xQAF6iWaYxG9aBH0Tp9kjjR3DXqq A/WedP9JR+O2dIOPBe5P3nD10AwMRu1x5oGS9pLK2nf68NBk5OxMJkr0BFrHbwodDP1+lD/IV gu1o+0kuMWEkWEYjc9P5JCVXWE7+So1n1fZTHIBmCg46z9oEGEXaaeZyIhlh6DOiN5qF48TA1 5DOTHsICIfMS37gZDVaDsv9KOEKAZHnSEisbf263PlTWaw1cL5/KtH7h3Cl28MwVKIYQ2Z1lp CjqYaHT89lBtn9wVDOqiC9ejCcgjFfo0NP3+uLOgApRwCHkZA5HyjKaoavDf6jPYptjRGkKS2 TfVCLnSdp7R5byOv0yOZ/hn7o2RdE+iZxhPiCkxaoHomX7yUoayKm0yyDNL7EvZ4sLNmz9T0v WNnLtdqLJ+bAt5DghzxWCS+5UXi3FlKtCaK0awfBz/CKsM7/7vhPCLYJ8K49jSnu/8yy0SV5k BDbolMLmo862VFm7GAdWvl14Y233iDbEICSk45R8IgPM6pu7L3UnC6K3RRLwfxOEixOLk2QUJ uunU4IzGmz355nY9Fa33iFoZ0rvu4mFeDqAfnxlmL1Y5yLssH7MuLNDwex7koiLKPQFhrz4Bh Dt6fxqFHNeKJivJ+ 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 This is a rewrite of an earlier patch from Yangbo Lu, adding a quirk for the NXP QorIQ T4240 in the detection of the host device version. Unfortunately, this device cannot be detected using the compatible string, as we have to support existing DTS files that use the generic "fsl,t4240-esdhc" identifier but that have other host versions that are correctly detected. Signed-off-by: Arnd Bergmann --- 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/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c index 3f34d354f1fc..1d4814fe4cb2 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c @@ -73,14 +73,16 @@ static u32 esdhc_readl_fixup(struct sdhci_host *host, static u16 esdhc_readw_fixup(struct sdhci_host *host, int spec_reg, u32 value) { + 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) - ret = value & 0xffff; - else - ret = (value >> shift) & 0xffff; - return ret; + return esdhc->vendor_ver << SDHCI_VENDOR_VER_SHIFT | + esdhc->spec_ver; + + return (value >> shift) & 0xffff; } static u8 esdhc_readb_fixup(struct sdhci_host *host, @@ -562,16 +564,32 @@ static const struct sdhci_pltfm_data sdhci_esdhc_le_pdata = { .ops = &sdhci_esdhc_le_ops, }; +#define T4240_HOST_VER ((VENDOR_V_23 << SDHCI_VENDOR_VER_SHIFT) | SDHCI_SPEC_200) +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) }, + { }, +}; + static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host) { struct sdhci_pltfm_host *pltfm_host; struct sdhci_esdhc *esdhc; - u16 host_ver; pltfm_host = sdhci_priv(host); esdhc = sdhci_pltfm_priv(pltfm_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; + + match = soc_device_match(&esdhc_t4240_quirk); + if (match) + host_ver = (uintptr_t)match->data; + } + esdhc->vendor_ver = (host_ver & SDHCI_VENDOR_VER_MASK) >> SDHCI_VENDOR_VER_SHIFT; esdhc->spec_ver = host_ver & SDHCI_SPEC_VER_MASK;