Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753600AbcKPIst (ORCPT ); Wed, 16 Nov 2016 03:48:49 -0500 Received: from mail-db5eur01on0077.outbound.protection.outlook.com ([104.47.2.77]:35623 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752375AbcKPIsq (ORCPT ); Wed, 16 Nov 2016 03:48:46 -0500 From: "Y.B. Lu" To: Michael Walle , "linux-kernel@vger.kernel.org" CC: "linux-mmc@vger.kernel.org" , Ulf Hansson , Adrian Hunter , yangbo lu Subject: RE: [PATCH v3] mmc: sdhci-of-esdhc: fixup PRESENT_STATE read Thread-Topic: [PATCH v3] mmc: sdhci-of-esdhc: fixup PRESENT_STATE read Thread-Index: AQHSPomORQYtD4omeUqW3Vjnt0QflaDZkExQ Date: Tue, 15 Nov 2016 06:12:01 +0000 Message-ID: References: <1479136348-30706-1-git-send-email-michael@walle.cc> In-Reply-To: <1479136348-30706-1-git-send-email-michael@walle.cc> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=yangbo.lu@nxp.com; x-originating-ip: [199.59.231.64] x-microsoft-exchange-diagnostics: 1;DB6PR0401MB2534;7:99jDBU6YhWhkhldk91P21tGzCSvq2JczVGLNv8AUjmxaUlnE8dOMZTZIdxFKT5HgZBgn8YhX//o64f151AakGA37oTbuHkIzqqmUKNTFH0WfaA1NJxOPtVNmoA5T68WN1iUiVCFbFb9c63gvrtjJyr1lUu3TC7NsAjGIzydYg4x/VYDWhtHANx7sscL5tNOHzB8wAQBpV+b2ViDAWc4b/q8eF9cchf7wPiTwOm/htRJXF5ryH56tjT4z/rVLoNbyTTBQgxTj/TABXQS2zfhThgfZMbBrL1+5Ylv6UP9Y/ZuZxN0fE/GMP7U9BAbOGkclmckFvRGqkpLmSzd1Q0q0PFt2Hjp+wneIo97bPjoGCdg= x-ms-office365-filtering-correlation-id: bf7ddd25-494d-4c67-9874-08d40d1e507b x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DB6PR0401MB2534; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055)(185117386973197); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6060326)(6045074)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6061324)(6046074);SRVR:DB6PR0401MB2534;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0401MB2534; x-forefront-prvs: 012792EC17 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(979002)(6009001)(7916002)(13464003)(377454003)(199003)(189002)(50986999)(54356999)(2906002)(74316002)(86362001)(76176999)(81156014)(9686002)(105586002)(7696004)(101416001)(76576001)(106116001)(4326007)(230783001)(229853002)(92566002)(106356001)(4001430100002)(6116002)(66066001)(2950100002)(122556002)(77096005)(3846002)(2900100001)(8676002)(81166006)(97736004)(305945005)(87936001)(7846002)(5001770100001)(5660300001)(68736007)(3660700001)(33656002)(7736002)(3280700002)(8936002)(107886002)(189998001)(102836003)(2501003)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0401MB2534;H:DB6PR0401MB2536.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Nov 2016 06:12:01.2176 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2534 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id uAG8mr47001333 Content-Length: 2328 Lines: 73 > -----Original Message----- > From: Michael Walle [mailto:michael@walle.cc] > Sent: Monday, November 14, 2016 11:12 PM > To: linux-kernel@vger.kernel.org > Cc: linux-mmc@vger.kernel.org; Ulf Hansson; Adrian Hunter; yangbo lu; > Michael Walle > Subject: [PATCH v3] mmc: sdhci-of-esdhc: fixup PRESENT_STATE read > > Since commit 87a18a6a5652 ("mmc: mmc: Use ->card_busy() to detect busy > cards in __mmc_switch()") the ESDHC driver is broken: > mmc0: Card stuck in programming state! __mmc_switch > mmc0: error -110 whilst initialising MMC card > > Since this commit __mmc_switch() uses ->card_busy(), which is > sdhci_card_busy() for the esdhc driver. sdhci_card_busy() uses the > PRESENT_STATE register, specifically the DAT0 signal level bit. But the > ESDHC uses a non-conformant PRESENT_STATE register, thus a read fixup is > required to make the driver work again. > > Signed-off-by: Michael Walle > Fixes: 87a18a6a5652 ("mmc: mmc: Use ->card_busy() to detect busy cards in > __mmc_switch()") > --- > v3: > - explain the bits in the comments > - use bits[19:0] from the original value, all other will be taken from > the > fixup value. > > v2: > - use lower bits of the original value (that was actually a typo) > - add fixes tag > - fix typo > > drivers/mmc/host/sdhci-of-esdhc.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci- > of-esdhc.c > index fb71c86..74cf3b1 100644 > --- a/drivers/mmc/host/sdhci-of-esdhc.c > +++ b/drivers/mmc/host/sdhci-of-esdhc.c > @@ -66,6 +66,19 @@ static u32 esdhc_readl_fixup(struct sdhci_host *host, > return ret; > } > } > + /* > + * The DAT[3:0] line signal levels and the CMD line signal level > are > + * not compatible with standard SDHC register. The line signal > levels > + * DAT[7:0] are at bits 31:24 and the line signal level is at bit > 23. > + * All other bits are the same as in the standard SDHC register. > + */ > + if (spec_reg == SDHCI_PRESENT_STATE) { > + ret = value & 0x000fffff; > + ret |= (value >> 4) & SDHCI_DATA_LVL_MASK; > + ret |= (value << 1) & 0x01000000; > + return ret; > + } > + [Lu Yangbo-B47093] This is the proper fix. Acked-by: Yangbo Lu > ret = value; > return ret; > } > -- > 2.1.4