From patchwork Fri Jan 4 02:26:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ernest Zhang(WH)" X-Patchwork-Id: 10747901 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80A5491E for ; Fri, 4 Jan 2019 02:26:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7046B283AF for ; Fri, 4 Jan 2019 02:26:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 64719283BD; Fri, 4 Jan 2019 02:26:54 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 E732E283AF for ; Fri, 4 Jan 2019 02:26:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726437AbfADC0x (ORCPT ); Thu, 3 Jan 2019 21:26:53 -0500 Received: from mail-eopbgr810133.outbound.protection.outlook.com ([40.107.81.133]:20800 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726036AbfADC0x (ORCPT ); Thu, 3 Jan 2019 21:26:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=towerbridgetechnology.onmicrosoft.com; s=selector1-bayhubtech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5IBqzbKM+29Jrr8xG7by8Xhms9ag2qE5Z30WO+O/kVw=; b=QqR6Y9GiBrNyf5Y3Jikoul9wOst9uyZAQzf5xkhpmQ0a43tnLyAgBkybZLLQBV9y7npELPEBzuk9dKchiHJ5CXWWgCskuMHv2qrojtdXUbVA3Mc1jIPPg+X+1cfA2pwRj1qWmUJ18+hX/zhagv5vNHHwSzEjBpZWZKtiFBxn1C8= Received: from SN6PR16MB2542.namprd16.prod.outlook.com (52.135.125.202) by SN6PR16MB2431.namprd16.prod.outlook.com (20.176.241.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1495.6; Fri, 4 Jan 2019 02:26:11 +0000 Received: from SN6PR16MB2542.namprd16.prod.outlook.com ([fe80::bd52:244b:836b:883d]) by SN6PR16MB2542.namprd16.prod.outlook.com ([fe80::bd52:244b:836b:883d%3]) with mapi id 15.20.1495.005; Fri, 4 Jan 2019 02:26:11 +0000 From: "Ernest Zhang(WH)" To: Adrian Hunter , Ulf Hansson , "linux-mmc@vger.kernel.org" CC: "Xiaoguang Yu (WH)" , "Andy Dai (WH)" , "Shirley Her (SC)" , "Mike Li (WH)" , "Ernest Zhang(WH)" Subject: [PATCH V4 1/2] mmc: sdhci: Moving sdhci_o2 into sdhci-pci-o2micro.c Thread-Topic: [PATCH V4 1/2] mmc: sdhci: Moving sdhci_o2 into sdhci-pci-o2micro.c Thread-Index: AQHUo9TbXLM9FuWlFUiiDkMmacQQqg== Date: Fri, 4 Jan 2019 02:26:10 +0000 Message-ID: <20190104022502.31873-1-ernest.zhang@bayhubtech.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR03CA0080.apcprd03.prod.outlook.com (2603:1096:203:72::20) To SN6PR16MB2542.namprd16.prod.outlook.com (2603:10b6:805:d3::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ernest.zhang@bayhubtech.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [117.136.52.201] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;SN6PR16MB2431;6:x0Jauj7f4IIXWC+T8jcdnn84sHAtiaj1k296HoPLZ75sZ2sqvK/iSQ/CIp/71SY57FHezdcEhpvC36FSGMalqxl3Hcj8E9OeTcvOruJTdgxlkRZMcd+NFJaBWAK7exHDYf+8uYpNb5C355xUUFcLgxBNpNqQCeQdWDCNNhf8jFTZAo7v5Ryck/uv830lmMmqXHPOHOVIXSG3kAE8dwyoxb0nqNTkjT5IND44VMJusPo2Fd/B34LvcJbS4Urpq5zwZhWCGyjLT15RT1zVUSMr6beRriqvvt01jUTeCNoJAf8o2XKV54Ry37/uW7lNgKFX5QUtL/Udlw6aFcrlQGQGbQfMw7ttdY3frbSdOez5Hb+nI/p2TXyDHtZuvmpWGlEdTzLbkYiSQM8xCx0LUhZ29jGRhiZsoj1asoZscsCTRAQ+4AZtj6IDZOzeZVEj8pgfEVxRq3l1NsJldKo+6OpFVA==;5:F0g2uK576431chf0YpXwZ9E11oXnI0aTJZh9XNqN8+aAEYEBGgdUuLroZC3awoXXxGGoVUSGXlfIb5lCOfEysblEBJCUfMEuA6+LtqWgHKvT0o11ErfB6sUypHe34VzYPw9J/gFLVFP0VqHW6Z1bFHL4KRM4Jnji5i0wnWFdTwLIGxP2aeiZIk4QschlUREeckjJi36XztbTksuQ2HMdow==;7:EyufkhM8/ZdwUJKAu6FXbezGqwCkU7vHI2H1p0GtRBbn4huLVIK1GJFP5CvGYqw8e5D2YrPqNym/v+W6gFnlJfaCCZlxJORKcHLxTzJs/pecdOu+PW4TTB/wc5MamOxVAXCeBgX0fMEgVBP6PBplkw== x-ms-office365-filtering-correlation-id: 6ba8b68b-e944-4fbb-88ff-08d671ebfd79 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(7021145)(8989299)(4534185)(7022145)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600109)(711020)(2017052603328)(7153060)(7193020);SRVR:SN6PR16MB2431; x-ms-traffictypediagnostic: SN6PR16MB2431: x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(3230021)(908002)(999002)(5005026)(6040522)(8220060)(2401047)(8121501046)(93006095)(93001095)(10201501046)(3231475)(944501520)(52105112)(3002001)(6041310)(20161123564045)(20161123558120)(20161123560045)(2016111802025)(20161123562045)(6043046)(201708071742011)(7699051)(76991095);SRVR:SN6PR16MB2431;BCL:0;PCL:0;RULEID:;SRVR:SN6PR16MB2431; x-forefront-prvs: 0907F58A24 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39830400003)(376002)(396003)(136003)(346002)(366004)(189003)(199004)(99286004)(6506007)(102836004)(6486002)(186003)(386003)(25786009)(6512007)(2501003)(53936002)(4326008)(71200400001)(7736002)(71190400001)(8936002)(508600001)(107886003)(3846002)(14444005)(81156014)(6436002)(575784001)(486006)(26005)(2906002)(54906003)(81166006)(110136005)(2616005)(256004)(476003)(86362001)(52116002)(6116002)(8676002)(305945005)(1076003)(97736004)(5660300001)(68736007)(14454004)(66066001)(106356001)(105586002)(36756003)(316002);DIR:OUT;SFP:1102;SCL:1;SRVR:SN6PR16MB2431;H:SN6PR16MB2542.namprd16.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: bayhubtech.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: JkslHMT8yvNG0HDtWw0diQMQVSuOnHxyZRkSXcQFrTWduOogUotHqogh3zNvNgDBD8cnNb7aRZQY2MKNM20xezaEulqXLoyV48wRnnkzGpdkDP9zZHas+5eIp3Y99QQEncGlma6PpdubiAIYmvr8CMWUJ/jR3DhRMaCR9Jx0k55QN8oA7LK1C3e4EcemJiVGPVxRkGVG3o/6xjlCwuCp3WtPv+tV0K2kj+Xs/GiSIJvll5WQL1o0yNX4buXYxvzQ3feGpyRRAhLuDmYjTpJqcnbduYgbKIGC5q5gziIU54WR2Ia66iyZlLKIm1KVVof9 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: bayhubtech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ba8b68b-e944-4fbb-88ff-08d671ebfd79 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jan 2019 02:26:10.7732 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0a7aae2b-8f2e-44df-ba2f-42de7f93c642 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR16MB2431 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 Moving sdhci_o2 into sdhci-pci-o2micro.c Signed-off-by: Ernest Zhang Acked-by: Adrian Hunter --- Change in V4: Fix compile error by move sdhci_o2 declaration to the end of file Change in V3: 1. Change the patches order to make this the first patch 2. Remove the other unneeded o2 declarations in sdhci-pci.h Change in V2: 1. Moving sdhci_o2 into sdhci-pci-o2micro.c Change in V1: N/A --- drivers/mmc/host/sdhci-pci-core.c | 10 ---------- drivers/mmc/host/sdhci-pci-o2micro.c | 10 ++++++++++ drivers/mmc/host/sdhci-pci.h | 6 +----- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c index 2a6eba74b94e..99b0fec2836b 100644 --- a/drivers/mmc/host/sdhci-pci-core.c +++ b/drivers/mmc/host/sdhci-pci-core.c @@ -1257,16 +1257,6 @@ static int jmicron_resume(struct sdhci_pci_chip *chip) } #endif -static const struct sdhci_pci_fixes sdhci_o2 = { - .probe = sdhci_pci_o2_probe, - .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, - .quirks2 = SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD, - .probe_slot = sdhci_pci_o2_probe_slot, -#ifdef CONFIG_PM_SLEEP - .resume = sdhci_pci_o2_resume, -#endif -}; - static const struct sdhci_pci_fixes sdhci_jmicron = { .probe = jmicron_probe, diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c index cc3ffeffd7a2..c91bd55080c9 100644 --- a/drivers/mmc/host/sdhci-pci-o2micro.c +++ b/drivers/mmc/host/sdhci-pci-o2micro.c @@ -550,3 +550,13 @@ int sdhci_pci_o2_resume(struct sdhci_pci_chip *chip) return sdhci_pci_resume_host(chip); } #endif + +const struct sdhci_pci_fixes sdhci_o2 = { + .probe = sdhci_pci_o2_probe, + .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, + .quirks2 = SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD, + .probe_slot = sdhci_pci_o2_probe_slot, +#ifdef CONFIG_PM_SLEEP + .resume = sdhci_pci_o2_resume, +#endif +}; diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h index 2ef0bdca9197..4ddb69a15cd7 100644 --- a/drivers/mmc/host/sdhci-pci.h +++ b/drivers/mmc/host/sdhci-pci.h @@ -179,13 +179,9 @@ static inline void *sdhci_pci_priv(struct sdhci_pci_slot *slot) int sdhci_pci_resume_host(struct sdhci_pci_chip *chip); #endif int sdhci_pci_enable_dma(struct sdhci_host *host); -int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot); -int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip); -#ifdef CONFIG_PM_SLEEP -int sdhci_pci_o2_resume(struct sdhci_pci_chip *chip); -#endif extern const struct sdhci_pci_fixes sdhci_arasan; extern const struct sdhci_pci_fixes sdhci_snps; +extern const struct sdhci_pci_fixes sdhci_o2; #endif /* __SDHCI_PCI_H */ From patchwork Fri Jan 4 02:26:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ernest Zhang(WH)" X-Patchwork-Id: 10747899 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5C0C26C2 for ; Fri, 4 Jan 2019 02:26:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4942F283AD for ; Fri, 4 Jan 2019 02:26:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A05A283B2; Fri, 4 Jan 2019 02:26:50 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham 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 5A40E283AD for ; Fri, 4 Jan 2019 02:26:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726497AbfADC0s (ORCPT ); Thu, 3 Jan 2019 21:26:48 -0500 Received: from mail-eopbgr800127.outbound.protection.outlook.com ([40.107.80.127]:46000 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726437AbfADC0s (ORCPT ); Thu, 3 Jan 2019 21:26:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=towerbridgetechnology.onmicrosoft.com; s=selector1-bayhubtech-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t/j/WyEpbK+UX9qQ9KpYUIzUtqSViGLPhVts3aM4N+4=; b=DDudrySOe9dqwXctvby0GArCicQa3Bh7WbTimAAKFIEd8Rm3YynSfyFAitnvnMnDj8tc1LSkIyvXUfRn+bVYLfRqlImZgHNFeyhY71/Q2niKxcIgA5GIlJPxdK6vjrPdy8yVD6U7NealMoECcjMbgWAxGR0fabKd4TR6arDwvSU= Received: from SN6PR16MB2542.namprd16.prod.outlook.com (52.135.125.202) by SN6PR16MB2431.namprd16.prod.outlook.com (20.176.241.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1495.6; Fri, 4 Jan 2019 02:26:13 +0000 Received: from SN6PR16MB2542.namprd16.prod.outlook.com ([fe80::bd52:244b:836b:883d]) by SN6PR16MB2542.namprd16.prod.outlook.com ([fe80::bd52:244b:836b:883d%3]) with mapi id 15.20.1495.005; Fri, 4 Jan 2019 02:26:13 +0000 From: "Ernest Zhang(WH)" To: Adrian Hunter , Ulf Hansson , "linux-mmc@vger.kernel.org" CC: "Xiaoguang Yu (WH)" , "Andy Dai (WH)" , "Shirley Her (SC)" , "Mike Li (WH)" , "Ernest Zhang(WH)" Subject: [PATCH V4 2/2] mmc: sdhci: Fix O2 Host PLL and card detect issue Thread-Topic: [PATCH V4 2/2] mmc: sdhci: Fix O2 Host PLL and card detect issue Thread-Index: AQHUo9TdvJs2Fqn26kuQe3kik/s1yg== Date: Fri, 4 Jan 2019 02:26:13 +0000 Message-ID: <20190104022502.31873-2-ernest.zhang@bayhubtech.com> References: <20190104022502.31873-1-ernest.zhang@bayhubtech.com> In-Reply-To: <20190104022502.31873-1-ernest.zhang@bayhubtech.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HK0PR03CA0080.apcprd03.prod.outlook.com (2603:1096:203:72::20) To SN6PR16MB2542.namprd16.prod.outlook.com (2603:10b6:805:d3::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=ernest.zhang@bayhubtech.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [117.136.52.201] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;SN6PR16MB2431;6:yo4/XhZ4fDI/hWvLRgPF0YYjfHz8aQqLFrSVQvGMxW+t7cPVw+rRkgLrDWmyoR4xnH1S5I1ZHvc21X4EFOKxGBDg3s/Unw9ckA+iFUC9AmuSqpY3L4cW9g3qgxQEyWQ2cUy8zq6i6/QzcT/cXRAb2MLhxE2Mha5p7xpWAPAFb4Dh3usotWx98SMbypXmyFsHeLG+eWCIm+LmJXjx7maU/+byvfdPCzg+67g9kxzP8eTKW0JfOkxB9zWXcqSSFDubMCdAkMcKKLP/pB+v6C++/E6Pof0NKF8PwcUwfnMBYc1AwBSThcdwI5JdI9Q/8BR8giCxratjdm4vjy1hq0KcHReIrlLb9v60D/kFihiRfrIak5RS9xisr5dFwFWcqirOVmv5Ns0fMvm+4E29MHb9Yu9tdjREbq9Q5x0sng7/Nr5BO0N/Y9pYry6GNgN2z1Ss/Ppgebmn1Q5VOaVLwuhG3w==;5:txXdmtJomJISSBMTdxcJ+04sm7oyt+GswyZ3NgiO8clBsT7jvZuopgRK3VISO6a8eeZNkAd5dM0rBWtl3RGG71OeYTTnS3f3te32BNmApJt9N991D5K1WwEud72BfR0lx7xhQKNPvRmpILs6BluNmjPvhLcwSG5Z5xvye3iA4p87cA2Kp1yolaoq6XESkirwaz0Z38aVXzyAfIS9jZ+1wA==;7:tjdGcfmYx6/8EyPvfZqeypGLq1TcXa+pGUIuKql1qrYNUcXCzxp2ZUhKtCfNuVxcia9lYQzstgieBkA/77rNVqojPs2oMOr74uZne5ljknNQZi88Eo2Ulz1Lia/qRicSJ8MJvw4OTak6n8iPzw7ixA== x-ms-office365-filtering-correlation-id: fcecc481-efdb-4e61-9bd2-08d671ebff51 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(7021145)(8989299)(4534185)(7022145)(4603075)(4627221)(201702281549075)(8990200)(7048125)(7024125)(7027125)(7023125)(5600109)(711020)(2017052603328)(7153060)(7193020);SRVR:SN6PR16MB2431; x-ms-traffictypediagnostic: SN6PR16MB2431: x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(3230021)(908002)(999002)(5005026)(6040522)(8220060)(2401047)(8121501046)(93006095)(93001095)(10201501046)(3231475)(944501520)(52105112)(3002001)(6041310)(20161123564045)(20161123558120)(20161123560045)(2016111802025)(20161123562045)(6043046)(201708071742011)(7699051)(76991095);SRVR:SN6PR16MB2431;BCL:0;PCL:0;RULEID:;SRVR:SN6PR16MB2431; x-forefront-prvs: 0907F58A24 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39830400003)(376002)(396003)(136003)(346002)(366004)(189003)(199004)(446003)(99286004)(6506007)(102836004)(6486002)(186003)(11346002)(386003)(25786009)(6512007)(2501003)(53936002)(4326008)(71200400001)(7736002)(71190400001)(8936002)(508600001)(107886003)(3846002)(14444005)(81156014)(6436002)(575784001)(486006)(26005)(2906002)(54906003)(81166006)(110136005)(2616005)(256004)(476003)(86362001)(52116002)(76176011)(6116002)(8676002)(305945005)(1076003)(97736004)(5660300001)(68736007)(14454004)(66066001)(106356001)(105586002)(36756003)(316002);DIR:OUT;SFP:1102;SCL:1;SRVR:SN6PR16MB2431;H:SN6PR16MB2542.namprd16.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: bayhubtech.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: k6zhnYR1Y+M2DfF6TQpMmTaIIF6p9K2g1Sd78N03X25K6vwDT956fA+vBJIgos8mTIiggEnaZHtzZ/TGQokTBER5GAr3YPQcjWHledbtan/gqQuj6KogWYbI8uy/lVHULu6llNDz8OdIRmIlA2WKOaZGEbDfTCRjJiCwsgQ6GhHqlqhDWaUz0roPloYczGMfR3THwh+xwRvxi3KPWOUg2YahLBhJKQSgLrtf0CcUGCGZnZPiBKeCZUet89dOn/IzYuqltcuaehN9jiPJXT03x6VKIut2RfxLFu3x+23C8bPixzSfz3OzxOI45dzuatF7 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: bayhubtech.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcecc481-efdb-4e61-9bd2-08d671ebff51 X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jan 2019 02:26:13.7264 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0a7aae2b-8f2e-44df-ba2f-42de7f93c642 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR16MB2431 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 1. O2 Host Controller PLL lock status is not in compliance with CLOCK_CONTROL register bit 1 2. O2 Host Controller card detect function only work when PLL is enabled and locked Signed-off-by: Ernest Zhang Acked-by: Adrian Hunter --- Change in V4: After fix patch 1/2 compile error, this patch need some modifies Change in V3: Change to patches order to make this the second patch Change in V2: 1. Remove unused sdhci_ops function pointer 2. Change kind of timeout check, get the time first 3. Rename CARD PRESENT register bit16 and bit 18 macro Change in V1: N/A --- drivers/mmc/host/sdhci-pci-o2micro.c | 130 ++++++++++++++++++++++++++- drivers/mmc/host/sdhci.h | 4 + 2 files changed, 131 insertions(+), 3 deletions(-) diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c index c91bd55080c9..7f11cee71db1 100644 --- a/drivers/mmc/host/sdhci-pci-o2micro.c +++ b/drivers/mmc/host/sdhci-pci-o2micro.c @@ -60,6 +60,13 @@ #define O2_SD_VENDOR_SETTING2 0x1C8 #define O2_SD_HW_TUNING_DISABLE BIT(4) +#define O2_PLL_WDT_CONTROL1 0x1CC +#define O2_PLL_FORCE_ACTIVE BIT(18) +#define O2_PLL_LOCK_STATUS BIT(14) +#define O2_PLL_SOFT_RESET BIT(12) + +#define O2_SD_DETECT_SETTING 0x324 + static void sdhci_o2_set_tuning_mode(struct sdhci_host *host) { u16 reg; @@ -283,6 +290,113 @@ static void sdhci_pci_o2_enable_msi(struct sdhci_pci_chip *chip, host->irq = pci_irq_vector(chip->pdev, 0); } +static void sdhci_o2_wait_card_detect_stable(struct sdhci_host *host) +{ + ktime_t timeout; + u32 scratch32; + + /* Wait max 50 ms */ + timeout = ktime_add_ms(ktime_get(), 50); + while (1) { + bool timedout = ktime_after(ktime_get(), timeout); + + scratch32 = sdhci_readl(host, SDHCI_PRESENT_STATE); + if ((scratch32 & SDHCI_CARD_PRESENT) >> SDHCI_CARD_PRES_SHIFT + == (scratch32 & SDHCI_CD_LVL) >> SDHCI_CD_LVL_SHIFT) + break; + + if (timedout) { + pr_err("%s: Card Detect debounce never finished.\n", + mmc_hostname(host->mmc)); + sdhci_dumpregs(host); + return; + } + udelay(10); + } +} + +static void sdhci_o2_enable_internal_clock(struct sdhci_host *host) +{ + ktime_t timeout; + u16 scratch; + u32 scratch32; + + /* PLL software reset */ + scratch32 = sdhci_readl(host, O2_PLL_WDT_CONTROL1); + scratch32 |= O2_PLL_SOFT_RESET; + sdhci_writel(host, scratch32, O2_PLL_WDT_CONTROL1); + udelay(1); + scratch32 &= ~(O2_PLL_SOFT_RESET); + sdhci_writel(host, scratch32, O2_PLL_WDT_CONTROL1); + + /* PLL force active */ + scratch32 |= O2_PLL_FORCE_ACTIVE; + sdhci_writel(host, scratch32, O2_PLL_WDT_CONTROL1); + + /* Wait max 20 ms */ + timeout = ktime_add_ms(ktime_get(), 20); + while (1) { + bool timedout = ktime_after(ktime_get(), timeout); + + scratch = sdhci_readw(host, O2_PLL_WDT_CONTROL1); + if (scratch & O2_PLL_LOCK_STATUS) + break; + if (timedout) { + pr_err("%s: Internal clock never stabilised.\n", + mmc_hostname(host->mmc)); + sdhci_dumpregs(host); + goto out; + } + udelay(10); + } + + /* Wait for card detect finish */ + udelay(1); + sdhci_o2_wait_card_detect_stable(host); + +out: + /* Cancel PLL force active */ + scratch32 = sdhci_readl(host, O2_PLL_WDT_CONTROL1); + scratch32 &= ~O2_PLL_FORCE_ACTIVE; + sdhci_writel(host, scratch32, O2_PLL_WDT_CONTROL1); +} + +static int sdhci_o2_get_cd(struct mmc_host *mmc) +{ + struct sdhci_host *host = mmc_priv(mmc); + + sdhci_o2_enable_internal_clock(host); + + return !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT); +} + +static void sdhci_o2_enable_clk(struct sdhci_host *host, u16 clk) +{ + /* Enable internal clock */ + clk |= SDHCI_CLOCK_INT_EN; + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); + + if (sdhci_o2_get_cd(host->mmc)) { + clk |= SDHCI_CLOCK_CARD_EN; + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); + } +} + +void sdhci_pci_o2_set_clock(struct sdhci_host *host, unsigned int clock) +{ + u16 clk; + + host->mmc->actual_clock = 0; + + sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL); + + if (clock == 0) + return; + + clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock); + sdhci_o2_enable_clk(host, clk); +} + int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot) { struct sdhci_pci_chip *chip; @@ -316,7 +430,11 @@ int sdhci_pci_o2_probe_slot(struct sdhci_pci_slot *slot) host->flags |= SDHCI_SIGNALING_180; host->mmc->caps2 |= MMC_CAP2_NO_SD; host->mmc->caps2 |= MMC_CAP2_NO_SDIO; + pci_write_config_dword(chip->pdev, + O2_SD_DETECT_SETTING, 3); } + + slot->host->mmc_host_ops.get_cd = sdhci_o2_get_cd; } host->mmc_host_ops.execute_tuning = sdhci_o2_execute_tuning; @@ -490,9 +608,6 @@ int sdhci_pci_o2_probe(struct sdhci_pci_chip *chip) pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); break; case PCI_DEVICE_ID_O2_SEABIRD0: - if (chip->pdev->revision == 0x01) - chip->quirks |= SDHCI_QUIRK_DELAY_AFTER_POWER; - /* fall through */ case PCI_DEVICE_ID_O2_SEABIRD1: /* UnLock WP */ ret = pci_read_config_byte(chip->pdev, @@ -551,6 +666,14 @@ int sdhci_pci_o2_resume(struct sdhci_pci_chip *chip) } #endif +static const struct sdhci_ops sdhci_pci_o2_ops = { + .set_clock = sdhci_pci_o2_set_clock, + .enable_dma = sdhci_pci_enable_dma, + .set_bus_width = sdhci_set_bus_width, + .reset = sdhci_reset, + .set_uhs_signaling = sdhci_set_uhs_signaling, +}; + const struct sdhci_pci_fixes sdhci_o2 = { .probe = sdhci_pci_o2_probe, .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, @@ -559,4 +682,5 @@ const struct sdhci_pci_fixes sdhci_o2 = { #ifdef CONFIG_PM_SLEEP .resume = sdhci_pci_o2_resume, #endif + .ops = &sdhci_pci_o2_ops, }; diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 6cc9a3c2ac66..924e03332cf7 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -73,6 +73,10 @@ #define SDHCI_SPACE_AVAILABLE 0x00000400 #define SDHCI_DATA_AVAILABLE 0x00000800 #define SDHCI_CARD_PRESENT 0x00010000 +#define SDHCI_CARD_PRES_SHIFT 16 +#define SDHCI_CD_STABLE 0x00020000 +#define SDHCI_CD_LVL 0x00040000 +#define SDHCI_CD_LVL_SHIFT 18 #define SDHCI_WRITE_PROTECT 0x00080000 #define SDHCI_DATA_LVL_MASK 0x00F00000 #define SDHCI_DATA_LVL_SHIFT 20