Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755245AbcKNIdw (ORCPT ); Mon, 14 Nov 2016 03:33:52 -0500 Received: from mail-db5eur01on0079.outbound.protection.outlook.com ([104.47.2.79]:10956 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752250AbcKNIdt (ORCPT ); Mon, 14 Nov 2016 03:33:49 -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 v2] mmc: sdhci-of-esdhc: fixup PRESENT_STATE read Thread-Topic: [PATCH v2] mmc: sdhci-of-esdhc: fixup PRESENT_STATE read Thread-Index: AQHSPDVTBG4SLl+7XESjMdt6TgROCqDXzJ0A Date: Mon, 14 Nov 2016 03:00:03 +0000 Message-ID: References: <1478880259-24943-1-git-send-email-michael@walle.cc> In-Reply-To: <1478880259-24943-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: [192.158.241.86] x-microsoft-exchange-diagnostics: 1;DB6PR0401MB2535;7:8cs7gX6eM3jLQE9iDjIrYVCKiVn3h/VgGeInBJwnuXNsWkMJEPybq+I4YUdVfEWbSxwy06LDYDPIteuT01NcMNC61QgY0+uXxiJ9vtibxRqtn047v5Fp5c72Mteh0XcEbOfHU1KBUjgxeBxFobUuDnNNwYHkC6W76aIYLRdHMeSWyeP0Zl/WeLBkwFgBblmADV3LVGT8F7OQ2ezMfyM5PhHFUy6PEX2GD1S0d9a2MmkM17KHgy0Gne+LiNXcGMpM+YlERG3u2bSIaiMZjUD4xdqHlCENP0SZxV5Sz68CgnhEWx0j4a2rIR4GnAg3bVppJdVw/8GFpzFCchfzk/P+2s6nOgcCd3vQV6rv7FqqrWs= x-ms-office365-filtering-correlation-id: 70a467f5-39e5-41af-f7cd-08d40c3a54b9 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DB6PR0401MB2535; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6045074)(6060316)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026)(6046074)(6061311);SRVR:DB6PR0401MB2535;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0401MB2535; x-forefront-prvs: 0126A32F74 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(336003)(199003)(189002)(13464003)(377454003)(33656002)(77096005)(92566002)(2900100001)(7696004)(76176999)(87936001)(54356999)(81156014)(81166006)(50986999)(101416001)(122556002)(2501003)(230783001)(105586002)(3280700002)(2950100002)(74316002)(68736007)(2906002)(7846002)(8676002)(107886002)(3660700001)(4326007)(106356001)(106116001)(8936002)(97736004)(5001770100001)(305945005)(189998001)(9686002)(86362001)(7736002)(4001430100002)(5660300001)(66066001)(76576001)(6116002)(3846002)(586003)(102836003)(229853002);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0401MB2535;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: 14 Nov 2016 03:00:03.2780 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0401MB2535 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 uAE8XvfK017967 Content-Length: 2096 Lines: 63 > -----Original Message----- > From: Michael Walle [mailto:michael@walle.cc] > Sent: Saturday, November 12, 2016 12:04 AM > To: linux-kernel@vger.kernel.org > Cc: linux-mmc@vger.kernel.org; Ulf Hansson; Adrian Hunter; yangbo lu; > Michael Walle > Subject: [PATCH v2] 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()") > --- > 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 | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci- > of-esdhc.c > index fb71c86..f9c84bb 100644 > --- a/drivers/mmc/host/sdhci-of-esdhc.c > +++ b/drivers/mmc/host/sdhci-of-esdhc.c > @@ -66,6 +66,18 @@ static u32 esdhc_readl_fixup(struct sdhci_host *host, > return ret; > } > } > + /* > + * The DAT[3:0] line signal levels and the CMD line signal level is > + * not compatible with standard SDHC register. Move the > corresponding > + * bits around. > + */ > + if (spec_reg == SDHCI_PRESENT_STATE) { > + ret = value & ~0xf8000000; [Lu Yangbo-B47093] I think the bits which should be cleaned before following '|=' are 0x01f00000 not 0xf8000000, right? :) > + ret |= (value >> 4) & SDHCI_DATA_LVL_MASK; > + ret |= (value << 1) & 0x01000000; > + return ret; > + } > + > ret = value; > return ret; > } > -- > 2.1.4