From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756619AbcHWDIC (ORCPT ); Mon, 22 Aug 2016 23:08:02 -0400 Received: from mail-db5eur01on0054.outbound.protection.outlook.com ([104.47.2.54]:8928 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755228AbcHWDIA (ORCPT ); Mon, 22 Aug 2016 23:08:00 -0400 From: Haibo Chen To: Zach Brown , "adrian.hunter@intel.com" CC: "ulf.hansson@linaro.org" , "mark.rutland@arm.com" , "robh+dt@kernel.org" , "linux-mmc@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] sdhci: Add quirk and device tree parameter to force SD test mode Thread-Topic: [PATCH] sdhci: Add quirk and device tree parameter to force SD test mode Thread-Index: AQHR/MvqQoWg4errV0miP11fO1rtaaBVwjwQ Date: Tue, 23 Aug 2016 01:34:20 +0000 Message-ID: References: <1471906531-28668-1-git-send-email-zach.brown@ni.com> In-Reply-To: <1471906531-28668-1-git-send-email-zach.brown@ni.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=haibo.chen@nxp.com; x-originating-ip: [199.59.231.64] x-ms-office365-filtering-correlation-id: a3969c6d-8558-429d-463b-08d3caf59b59 x-microsoft-exchange-diagnostics: 1;AM4PR0401MB2324;6:iVPN+oirBGyF1qcWWmZG9u77jdJ7GeNzVqrdXwSR9inAMsvnZiDS3wjb+ROOQ8EQ8kNhXGCDvVaR3wuoMHqJhMyMnZ+e/K1aOT4uFTXPh94AyJR7c2fD+yJF6Z5pzibXfD8irlLSYJjLgmwd/mQ6rICuoeEgFzk98v6OiQeso+leLcfV9xHQONa0SlyVEu103Na0CXQTaZQlIuOHtGAAEQkcX01Am4pn4fBWQc2iASnx8ijGo8gplJdP7/MVfHaq+i4lq0TORcehk4Bxko3t4JWDmXpz3l/3lfqz7SI/j4yOBX0WuQ2cZf5SU+kcZ1fRyAqROD4N9Lv+g+GlnVs8PA==;5:sE++yzMIfEUzNYwUWzN5CIKfkOB2HWkv9Phc/79ddlubpAMi+JnBDjziUAjib663GRFVOKxYBZ4o1IGo+/BrDyo7DZy4Ch0H4yuPmKfosixA+Wh5c953xpJaSzr0xFRh0skyQDzt3BzzyBg0oW4WdQ==;24:0G50Cc6gQxt0yg1GDewmoFCe+M9GC2nsXd0rNA5gs0VXwgH5ngB7YyINGgbFc13UQS7+5rXmZLDes5mCyFX2VT69S2Y3cWelA6wdQI64GGc=;7:jQPuRlzoKprZU1iR9ae2g38DOrXfZmBCfMKHddaxQ2nYkSMFKJU4dBIIUpP1gE3AIdyISyMe2iSSclT49L1DILhQnBEGp7twj0xvQOh3moLpn/htL+5cjtddwVYUOcAh7mkrcNLZ7otpswB0EjjW4ATkmwx60CgVAK6X+7bozBRnDkcJovq9P8o2UK55qTGQflz6n7mdPhuHdyxtu384p6R6jK3vsYMxT+GqaHDrJq3ZwDfeMSEDcd6NbadlG6j0 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM4PR0401MB2324; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(9452136761055)(228905959029699)(145744241990776); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026);SRVR:AM4PR0401MB2324;BCL:0;PCL:0;RULEID:;SRVR:AM4PR0401MB2324; x-forefront-prvs: 004395A01C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(13464003)(189002)(199003)(377454003)(8676002)(81156014)(76576001)(575784001)(9686002)(81166006)(86362001)(66066001)(11100500001)(2906002)(102836003)(586003)(8936002)(6116002)(3280700002)(3846002)(7846002)(68736007)(7696003)(7736002)(3660700001)(74316002)(19580405001)(305945005)(4326007)(19580395003)(101416001)(33656002)(2501003)(87936001)(5660300001)(122556002)(77096005)(2950100001)(2900100001)(97736004)(106356001)(106116001)(105586002)(10400500002)(50986999)(5002640100001)(54356999)(76176999)(92566002)(189998001)(5001770100001)(15975445007)(422495003);DIR:OUT;SFP:1101;SCL:1;SRVR:AM4PR0401MB2324;H:AM4PR0401MB2324.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A: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: 23 Aug 2016 01:34:20.8576 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR0401MB2324 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 u7N387rc020204 > -----Original Message----- > From: linux-mmc-owner@vger.kernel.org [mailto:linux-mmc- > owner@vger.kernel.org] On Behalf Of Zach Brown > Sent: Tuesday, August 23, 2016 6:56 AM > To: adrian.hunter@intel.com > Cc: ulf.hansson@linaro.org; mark.rutland@arm.com; robh+dt@kernel.org; > linux-mmc@vger.kernel.org; devicetree@vger.kernel.org; linux- > kernel@vger.kernel.org > Subject: [PATCH] sdhci: Add quirk and device tree parameter to force SD test > mode > > From: Jaeden Amero > > On some devices, CD is broken so that we must force the SDHCI into test mode > and set CD, so that it always detects an SD card as present. > > In order to get a device with broken CD working, we had previously always set > the SDHCI into test mode. Unfortunately, this had the side effect of making all > SD cards used with our Linux kernels undetectable and non-removable. Why not use the poll mode? You can set the flag MMC_CAP_NEEDS_POLL, then the mmc core will detect the card every second. > > By making this "SD test mode" setting optional via a quirk, we can avoid this > side effect for devices other than the device with broken CD. > Additionally, we add a device parameter to sdhci-pltfm to allow all SDHCI > drivers to enable this quirk. > > Signed-off-by: Jaeden Amero > Signed-off-by: Zach Brown > --- > Documentation/devicetree/bindings/mmc/mmc.txt | 2 ++ > drivers/mmc/host/sdhci-pltfm.c | 4 ++++ > drivers/mmc/host/sdhci.c | 9 +++++++++ > drivers/mmc/host/sdhci.h | 4 ++++ > 4 files changed, 19 insertions(+) > > diff --git a/Documentation/devicetree/bindings/mmc/mmc.txt > b/Documentation/devicetree/bindings/mmc/mmc.txt > index 22d1e1f..3a9be41 100644 > --- a/Documentation/devicetree/bindings/mmc/mmc.txt > +++ b/Documentation/devicetree/bindings/mmc/mmc.txt > @@ -52,6 +52,8 @@ Optional properties: > - no-sdio: controller is limited to send sdio cmd during initialization > - no-sd: controller is limited to send sd cmd during initialization > - no-mmc: controller is limited to send mmc cmd during initialization > +- force-sd-cd-test-mode: card detection is broken on device, force cd > +test > + enable and cd test inserted so host will always detect a card. > > *NOTE* on CD and WP polarity. To use common for all SD/MMC host > controllers line polarity properties, we have to fix the meaning of the "normal" > and "inverted" > diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c > index 1d17dcf..056d101 100644 > --- a/drivers/mmc/host/sdhci-pltfm.c > +++ b/drivers/mmc/host/sdhci-pltfm.c > @@ -87,6 +87,10 @@ void sdhci_get_of_property(struct platform_device > *pdev) > if (of_get_property(np, "broken-cd", NULL)) > host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION; > > + if (of_get_property(np, "force-sd-cd-test-mode", NULL)) > + host->quirks2 |= > + SDHCI_QUIRK2_MUST_FORCE_SD_CD_TEST_MODE; > + > if (of_get_property(np, "no-1-8-v", NULL)) > host->quirks2 |= SDHCI_QUIRK2_NO_1_8_V; > > diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index > cd65d47..2f4c6f9 100644 > --- a/drivers/mmc/host/sdhci.c > +++ b/drivers/mmc/host/sdhci.c > @@ -117,6 +117,15 @@ static inline bool sdhci_data_line_cmd(struct > mmc_command *cmd) static void sdhci_set_card_detection(struct sdhci_host > *host, bool enable) { > u32 present; > + u8 ctrl; > + > + if (host->quirks2 & SDHCI_QUIRK2_MUST_FORCE_SD_CD_TEST_MODE) > { > + /* Put the card in test mode, with card inserted */ > + ctrl = sdhci_readl(host, SDHCI_HOST_CONTROL); > + ctrl |= SDHCI_CTRL_CD_TEST_INSERTED | > + SDHCI_CTRL_CD_TEST_ENABLE; > + sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); > + } > > if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) || > !mmc_card_is_removable(host->mmc)) > diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index > 0411c9f..dd609b2 100644 > --- a/drivers/mmc/host/sdhci.h > +++ b/drivers/mmc/host/sdhci.h > @@ -84,6 +84,8 @@ > #define SDHCI_CTRL_ADMA32 0x10 > #define SDHCI_CTRL_ADMA64 0x18 > #define SDHCI_CTRL_8BITBUS 0x20 > +#define SDHCI_CTRL_CD_TEST_INSERTED 0x40 > +#define SDHCI_CTRL_CD_TEST_ENABLE 0x80 > > #define SDHCI_POWER_CONTROL 0x29 > #define SDHCI_POWER_ON 0x01 > @@ -422,6 +424,8 @@ struct sdhci_host { > #define SDHCI_QUIRK2_ACMD23_BROKEN (1<<14) > /* Broken Clock divider zero in controller */ > #define SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN (1<<15) > +/* Controller must support device with broken CD */ > +#define SDHCI_QUIRK2_MUST_FORCE_SD_CD_TEST_MODE (1<<16) > > int irq; /* Device IRQ */ > void __iomem *ioaddr; /* Mapped address */ > -- > 2.7.4 > > -- > 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