From patchwork Wed Jan 2 14:48:49 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: 10746477 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 5C50417D2 for ; Wed, 2 Jan 2019 14:48:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 404D62785D for ; Wed, 2 Jan 2019 14:48:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3438D281F9; Wed, 2 Jan 2019 14:48:56 +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 B7F9D2785D for ; Wed, 2 Jan 2019 14:48:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728139AbfABOsy (ORCPT ); Wed, 2 Jan 2019 09:48:54 -0500 Received: from mail-eopbgr700099.outbound.protection.outlook.com ([40.107.70.99]:60748 "EHLO NAM04-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726855AbfABOsx (ORCPT ); Wed, 2 Jan 2019 09:48: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=puT6OQDjBHFtOU1eCUcjaJPXEGIru+b2aTVmOJaSFXI=; b=j4X2awmXafw3oV7UKIgll1U7B3ATg35U0dWZccMGEyxEHa+vTvxfN3DscozECTL0uFfp6kPo+vUE8dD1qCdzWyP9WoA54GBX1FHI1WSJeuTNGQCz/NZkbkQ8WcM9Nxz6zDbijNN2h9m824E4wqLEa5ylCxMacRwcD+g0vRW8Iv4= Received: from SN6PR16MB2542.namprd16.prod.outlook.com (52.135.125.202) by SN6PR16MB2621.namprd16.prod.outlook.com (52.135.126.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1471.20; Wed, 2 Jan 2019 14:48:50 +0000 Received: from SN6PR16MB2542.namprd16.prod.outlook.com ([fe80::8820:cbd3:3b2a:c3b2]) by SN6PR16MB2542.namprd16.prod.outlook.com ([fe80::8820:cbd3:3b2a:c3b2%3]) with mapi id 15.20.1471.019; Wed, 2 Jan 2019 14:48:50 +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 V3 1/2] mmc: sdhci: Moving sdhci_o2 into sdhci-pci-o2micro.c Thread-Topic: [PATCH V3 1/2] mmc: sdhci: Moving sdhci_o2 into sdhci-pci-o2micro.c Thread-Index: AQHUoqpFP5PZbn7H4UmRXAA66IiGVA== Date: Wed, 2 Jan 2019 14:48:49 +0000 Message-ID: <20190102144827.22930-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: HK2PR04CA0058.apcprd04.prod.outlook.com (2603:1096:202:14::26) 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: [221.235.47.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;SN6PR16MB2621;6:X1/ympaNrU/hSJGFxXjdKm36P0HohlN/JRk6/u5J9o4nc1z3guXO9zugk5F9AHY5lwpcvjW7UqFnN+weRlr9SXTSa3crL0Lk0PB5jUmD/eC6TT1K0QjmBb0iPWYcTesldu/IfZY0N/S1VVI/qD9TOZQG1gfHobQz/ETCoZexhnridissODqlvz9FTZH0EWnbq9Y2JAKA/2Rq6nKvVeC2eDxodPtGMIYz57A7E+MOAF7gP72cHt3XHEunt4y2LnTzwf28lqixJqwNCfaPpAhepz2kM9MLft/31zyG4+1YWIm/NDLCeO8SJKzZg7gsPpsuOgymaMIAtNPjvNM4fzA+TYWHSXuJ0nUH6fVQ1PVbR/H+4pypOoy+fds5pZPoHM+R6ZqrmHJ0PWaRGUpv4kHAtthVRPH8XrF1gJMkI7sBOsgqQOYG+e0QgJQSBXK1Xi/ihM2O+unJa08Rs+u6Rb2z9g==;5:VkH8TTG42pHSN0w14f7RX31BdTyq0bbo+rLApRyJ1cJwQn8EZfjsKm6jLYObYv+4Ui4DlrCbQhalAbw+dr0Rwwh/nbpCbK1Qt7LzZS3uY8sI1dB5ohOEz63A1l7lgbM4CqylXEbRHZYxNfUxzQPd3g3ppKDG9PYpay2gSYeVGUo=;7:O1nGTOn3YGNm6lwZYXapE+IlJJcBAfcTvtiY5bHUXS860k1GOKvZvlYlTJStrJA3/uRy5C5W7JP2yDVZo3ZHad+9An51g8BCwDvE+MOR+BLdLKKQafdlTjxTQCLCdGFXy+4s+pDf5m5H2RSiOvxiyA== x-ms-office365-filtering-correlation-id: bb446664-d2fd-4e0b-494d-08d670c16805 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:SN6PR16MB2621; x-ms-traffictypediagnostic: SN6PR16MB2621: x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(3230021)(908002)(999002)(5005026)(6040522)(8220060)(2401047)(8121501046)(3231475)(944501520)(52105112)(93006095)(93001095)(3002001)(10201501046)(6041310)(20161123562045)(20161123558120)(20161123564045)(2016111802025)(20161123560045)(6043046)(201708071742011)(7699051)(76991095);SRVR:SN6PR16MB2621;BCL:0;PCL:0;RULEID:;SRVR:SN6PR16MB2621; x-forefront-prvs: 0905A6B2C7 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39830400003)(136003)(346002)(376002)(396003)(366004)(189003)(199004)(2616005)(3846002)(508600001)(106356001)(107886003)(486006)(6116002)(97736004)(71200400001)(476003)(14454004)(25786009)(68736007)(71190400001)(105586002)(53936002)(316002)(86362001)(110136005)(575784001)(99286004)(6512007)(386003)(305945005)(2906002)(66066001)(52116002)(36756003)(81156014)(2501003)(1076003)(81166006)(256004)(14444005)(8936002)(5660300001)(102836004)(7736002)(4326008)(8676002)(6436002)(6506007)(6486002)(54906003)(186003)(26005);DIR:OUT;SFP:1102;SCL:1;SRVR:SN6PR16MB2621;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: 1jqMLPayEU01vi78CeRqhkjnfRe+MkkmBZ1xdZNaDBwHfBfH9Dnhm+jOBEte159qAGOq04VMxLMfTEX/MZjsC9PilFXd14opED9Wl/tMZnARoXFgBqDRzyCbYDhvLErcAMhrrXOVkynC+0PEuuzDGFui9ee2fhMWQx+TR5jOo8qytCjFGWPvjC2BrHDVtnfoEk/YhMqZGDw1GmhliwpfukIXGFqyOEacHTWxxwGG76NIpFrDuJZJP0y61xIkXczDE6k7JeCFotnGu35qHsxO4+HRD6yKMMdBuVOaYLlPtOfnLTFSGFX7MJbeCq7ZYV3q spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: bayhubtech.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb446664-d2fd-4e0b-494d-08d670c16805 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jan 2019 14:48:49.9382 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0a7aae2b-8f2e-44df-ba2f-42de7f93c642 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR16MB2621 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 --- 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..73b49efa2316 100644 --- a/drivers/mmc/host/sdhci-pci-o2micro.c +++ b/drivers/mmc/host/sdhci-pci-o2micro.c @@ -60,6 +60,16 @@ #define O2_SD_VENDOR_SETTING2 0x1C8 #define O2_SD_HW_TUNING_DISABLE BIT(4) +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 void sdhci_o2_set_tuning_mode(struct sdhci_host *host) { u16 reg; 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 Wed Jan 2 14:49:14 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: 10746479 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 07D88746 for ; Wed, 2 Jan 2019 14:49:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC9852858B for ; Wed, 2 Jan 2019 14:49:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0EF92868C; Wed, 2 Jan 2019 14:49:20 +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 C41AC2858B for ; Wed, 2 Jan 2019 14:49:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728567AbfABOtT (ORCPT ); Wed, 2 Jan 2019 09:49:19 -0500 Received: from mail-eopbgr780130.outbound.protection.outlook.com ([40.107.78.130]:12157 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726855AbfABOtT (ORCPT ); Wed, 2 Jan 2019 09:49:19 -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=PhlV2zj+qIP2NKx9sj7e1/upvETQBMSrw/lqhwCBUUo=; b=kldrA42QWwPRppJvVIWr7C1UfCIqJ6Upsh+pVuolXEKcX7YTPT+095k6F350A/gBI8OCHKz4GftCIz+DdPM7QXGTrQv+aSZlZ5v/+XAv+pIQe3pJh2yNtbB0W36Y+iNUywMpxtHvIDQ2hwesQJga/4QfQJa4G7Xp6nlWfbCHmas= Received: from SN6PR16MB2542.namprd16.prod.outlook.com (52.135.125.202) by SN6PR16MB2477.namprd16.prod.outlook.com (52.135.124.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1495.7; Wed, 2 Jan 2019 14:49:14 +0000 Received: from SN6PR16MB2542.namprd16.prod.outlook.com ([fe80::8820:cbd3:3b2a:c3b2]) by SN6PR16MB2542.namprd16.prod.outlook.com ([fe80::8820:cbd3:3b2a:c3b2%3]) with mapi id 15.20.1471.019; Wed, 2 Jan 2019 14:49:14 +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 V3 2/2] mmc: sdhci: Fix O2 Host PLL and card detect issue Thread-Topic: [PATCH V3 2/2] mmc: sdhci: Fix O2 Host PLL and card detect issue Thread-Index: AQHUoqpUOP2E0MevIUae/CVz0Y6Ohg== Date: Wed, 2 Jan 2019 14:49:14 +0000 Message-ID: <20190102144858.22980-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: HK2PR04CA0064.apcprd04.prod.outlook.com (2603:1096:202:14::32) 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: [221.235.47.164] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;SN6PR16MB2477;6:Tx2ejzgCn/LhYF6Q8KWJRR0rdqT0ChjaQw5px62vU7uC05HqXjfuoLrZ1oFYk/HGAirNE6fXYljgPJJdYuQkDiVjpJYA7s5avnbqBJTxr3DIpzG/+AELsSzBSh3QsNuizs1doCD98ILQfedROx/DlEcU+DZnm5O7WD0RiC7K9MAWLaPH1Qs/KTqXdZWuxTJCKwFg8sBMCkSRi4tRhQ2qU9RhiFPXG1C9PWTJp8vbffP14FhzQNVaKzofNpqyuFwOnHO4adoOQQBgxpjSia2iBCJOZbk6RHvNamjx2mjQsj+HVLxLHe8CMDJC05QKsm6VPUv+6n3nmtrb+Adhhq91VjnPI8hOlifmQJPD8EFnXrhR+ya5fzXqJ3kpTsPAzZP0kPAXiakXCFF5RJ1Z28hWNH9iDt76paOm9CXX1fWzC52eduzyHMFMfZd9OwmYhIRWJEUfYay5BuxrN+s+rZkL6A==;5:QIhDPMCdOqRBcOb2g536ITctwZsSbRcAgTeoQI0xXrmATrb3b6fyU1j0hmjE/2gcuGcSJj+2nwtumyinIQBhWuoTHSs0Eqw5IqSEY8dwjvf+cBefp/Pr712FKK1aB1aAzrUBYvAZIzTOlOfWrrOTeOGjXB0/hlZlCRZ1Hgzl9eEccfE81WORePjLtbOHIIWO9teq8GO1KYucA2FmmIF/Zg==;7:XgUGYFb+9T+hia1cDMa8F8lNXuijJc8Lwrmpj+aaZvlbD9ELHmxS3DWwMilEirPdXdEq3H7+sbr1Oum+8h1dEzCpmXopRIKx/A6lumRQ3HEPAqOFqf0OT7SXNrFXrDdBbc3giq9sbMk5vp3HfU4s0Q== x-ms-office365-filtering-correlation-id: 9301aa6d-fe14-4997-6976-08d670c176c7 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:SN6PR16MB2477; x-ms-traffictypediagnostic: SN6PR16MB2477: 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)(3231475)(944501520)(52105112)(3002001)(10201501046)(6041310)(20161123564045)(2016111802025)(20161123558120)(20161123560045)(20161123562045)(6043046)(201708071742011)(7699051)(76991095);SRVR:SN6PR16MB2477;BCL:0;PCL:0;RULEID:;SRVR:SN6PR16MB2477; x-forefront-prvs: 0905A6B2C7 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39830400003)(396003)(346002)(136003)(366004)(376002)(199004)(189003)(6512007)(36756003)(2906002)(14454004)(6116002)(3846002)(107886003)(4326008)(81166006)(81156014)(8936002)(110136005)(316002)(508600001)(53936002)(54906003)(106356001)(105586002)(2501003)(97736004)(6436002)(1076003)(575784001)(66066001)(68736007)(6486002)(386003)(6506007)(99286004)(52116002)(14444005)(256004)(25786009)(2616005)(102836004)(8676002)(186003)(476003)(26005)(71200400001)(305945005)(71190400001)(86362001)(7736002)(486006)(5660300001);DIR:OUT;SFP:1102;SCL:1;SRVR:SN6PR16MB2477;H:SN6PR16MB2542.namprd16.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX: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: C/WKB2ro4b+5mVrChYKQSGmYBNW8gMyWBV+fMOlOT+IigdkfmfTCzQWGta2cE08TNR66OYAdIp/HoFXMRL5HTFdhM1GL5NL1i9H6GojElJr4ZdN1WtF9JjarsmAKPNEsZ+1GK/DbHGiiAe9gRSVQgoM6iuu651wU4dXQn8ZXf6XCdlXDsx7Kq4Pk2OkELhQ+ozfGMIpchfXv7gt4H/G7qJhraImBEO9G8KqWFltP75jz9r+Y62gytn98nv2s8GRdoFUogI8l3YF0CCGo8fhsvdZbyX1mkdYnaq/5Hs2rATlHodURKH7a6d0N+n9Hrksb spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: bayhubtech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9301aa6d-fe14-4997-6976-08d670c176c7 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Jan 2019 14:49:14.6305 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0a7aae2b-8f2e-44df-ba2f-42de7f93c642 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR16MB2477 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 From: "ernest.zhang" 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 --- 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 | 148 ++++++++++++++++++++++++--- drivers/mmc/host/sdhci.h | 4 + 2 files changed, 140 insertions(+), 12 deletions(-) diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c index 73b49efa2316..0c52d25e5cd7 100644 --- a/drivers/mmc/host/sdhci-pci-o2micro.c +++ b/drivers/mmc/host/sdhci-pci-o2micro.c @@ -60,15 +60,12 @@ #define O2_SD_VENDOR_SETTING2 0x1C8 #define O2_SD_HW_TUNING_DISABLE BIT(4) -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 -}; +#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) { @@ -293,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; @@ -326,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; @@ -500,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, @@ -560,3 +665,22 @@ int sdhci_pci_o2_resume(struct sdhci_pci_chip *chip) return sdhci_pci_resume_host(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, + .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 + .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