From patchwork Tue Sep 8 06:45:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanley Chu X-Patchwork-Id: 257706 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71E0BC43461 for ; Tue, 8 Sep 2020 06:45:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D8FE218AC for ; Tue, 8 Sep 2020 06:45:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="BHDKsJwh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728481AbgIHGpS (ORCPT ); Tue, 8 Sep 2020 02:45:18 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:59518 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726974AbgIHGpQ (ORCPT ); Tue, 8 Sep 2020 02:45:16 -0400 X-UUID: a610677484264359bbbd4fb373067e5d-20200908 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=2vPo2/6SWh33ktkAO3akjLdPD6CXJMF1HZ7GeTdKNVI=; b=BHDKsJwhismPLDdjnUL0WUichZGiN5ewYYgBkqHkaOH5U8S59oT75CPqUqloPqE/YQJrzb2AqK9WOLnlZBYVKR/1U/KuKImepV5vKzz6IapAs/e/sveFRjchGhyja6VgN3HcMseeiYPk/dfLp3LOzzvm934VKZcPvBnJU1Iiv0E=; X-UUID: a610677484264359bbbd4fb373067e5d-20200908 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 961924112; Tue, 08 Sep 2020 14:45:13 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 14:45:09 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 14:45:10 +0800 From: Stanley Chu To: , , , , CC: , , , , , , , , , , , Stanley Chu Subject: [PATCH 1/4] scsi: ufs-mediatek: Eliminate error message for unbound mphy Date: Tue, 8 Sep 2020 14:45:04 +0800 Message-ID: <20200908064507.30774-2-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200908064507.30774-1-stanley.chu@mediatek.com> References: <20200908064507.30774-1-stanley.chu@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 09CF89399DBA7DE7D6B84CA40E7393B33CDCBF42D6BC4B72E193E381E4D0D5B42000:8 X-MTK: N Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Some MediaTek platforms does not have to bind MPHY so users shall not see any unnecessary logs. Simply remove logs for this case. Fixes: fc4983018fea ("scsi: ufs-mediatek: Allow unbound mphy") Signed-off-by: Stanley Chu --- drivers/scsi/ufs/ufs-mediatek.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.18.0 Reviewed-by: Avri Altman diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 29cd017c1aa0..7487b25fa651 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -129,7 +129,10 @@ static int ufs_mtk_bind_mphy(struct ufs_hba *hba) __func__, err); } else if (IS_ERR(host->mphy)) { err = PTR_ERR(host->mphy); - dev_info(dev, "%s: PHY get failed %d\n", __func__, err); + if (err != -ENODEV) { + dev_info(dev, "%s: PHY get failed %d\n", __func__, + err); + } } if (err) From patchwork Tue Sep 8 06:45:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanley Chu X-Patchwork-Id: 257705 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D3B0C433E2 for ; Tue, 8 Sep 2020 06:45:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA5BF21D42 for ; Tue, 8 Sep 2020 06:45:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="HHJnF2BY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728705AbgIHGp1 (ORCPT ); Tue, 8 Sep 2020 02:45:27 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:59518 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728586AbgIHGpT (ORCPT ); Tue, 8 Sep 2020 02:45:19 -0400 X-UUID: 5aaac5c5280c461182145f93b2311d74-20200908 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=GsiSLSlMLBzu8jCR1E1cgx6iwjYy7jwBAV6+lW5fHzQ=; b=HHJnF2BYHhvzwAc3UFmOG0Q7h7U4S38jlwtV2c/gUH81t/dDEXBO1aQEF69C8gyqObwuSgX/BO9j+9Veys2KLsDAy7xRxWhCXZ+sd4dMLZrxTalbtn4LIDvB4KSTpmr9fotgXvip4JMisWpbhWdrn5XlqMDuVsIUE4KuSQtFhOE=; X-UUID: 5aaac5c5280c461182145f93b2311d74-20200908 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 694900447; Tue, 08 Sep 2020 14:45:11 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs02n1.mediatek.inc (172.21.101.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 14:45:09 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 14:45:10 +0800 From: Stanley Chu To: , , , , CC: , , , , , , , , , , , Stanley Chu Subject: [PATCH 2/4] scsi: ufs-mediatek: Fix HOST_PA_TACTIVATE quirk Date: Tue, 8 Sep 2020 14:45:05 +0800 Message-ID: <20200908064507.30774-3-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200908064507.30774-1-stanley.chu@mediatek.com> References: <20200908064507.30774-1-stanley.chu@mediatek.com> MIME-Version: 1.0 X-MTK: N Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Simply add HOST_PA_TACTIVATE quirk back since it was incorrectly removed before. Fixes: 47d054580a75 ("scsi: ufs-mediatek: fix HOST_PA_TACTIVATE quirk for Samsung UFS Devices") Signed-off-by: Stanley Chu --- drivers/scsi/ufs/ufs-mediatek.c | 6 ------ 1 file changed, 6 deletions(-) -- 2.18.0 Reviewed-by: Avri Altman diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 7487b25fa651..887c03e8bcc0 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -672,13 +672,7 @@ static int ufs_mtk_apply_dev_quirks(struct ufs_hba *hba) static void ufs_mtk_fixup_dev_quirks(struct ufs_hba *hba) { - struct ufs_dev_info *dev_info = &hba->dev_info; - u16 mid = dev_info->wmanufacturerid; - ufshcd_fixup_dev_quirks(hba, ufs_mtk_dev_fixups); - - if (mid == UFS_VENDOR_SAMSUNG) - hba->dev_quirks &= ~UFS_DEVICE_QUIRK_HOST_PA_TACTIVATE; } /** From patchwork Tue Sep 8 06:45:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanley Chu X-Patchwork-Id: 296827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 559D9C43461 for ; Tue, 8 Sep 2020 06:45:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2193321973 for ; Tue, 8 Sep 2020 06:45:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="LQ89IYxK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729104AbgIHGpn (ORCPT ); Tue, 8 Sep 2020 02:45:43 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:59518 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727898AbgIHGpR (ORCPT ); Tue, 8 Sep 2020 02:45:17 -0400 X-UUID: a965ba27aa94406e81943227f5c7e258-20200908 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Bjomsp98M5COQp7hU2i9F3nHqul1illrMLuipZ67MYo=; b=LQ89IYxKzSQVyLZ4NgSj+SZi5XEkCJPHTwrTZR27V5UoC2MDL8k4Vr06nvn8492Zele0qScmj4IcFU+lI2XlRvRQCXH/7IVwvSm7EAFtsjHpN6Vibdl1ed4pkr5MfFBpkkPw71tXg3ULA2C+oCa+56ZHRWYuwyL1OByJPLxe0hw=; X-UUID: a965ba27aa94406e81943227f5c7e258-20200908 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 66601205; Tue, 08 Sep 2020 14:45:13 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs02n2.mediatek.inc (172.21.101.101) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 14:45:09 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 14:45:10 +0800 From: Stanley Chu To: , , , , CC: , , , , , , , , , , , Stanley Chu Subject: [PATCH 3/4] scsi: ufs-mediatek: Fix flag of unipro low-power mode Date: Tue, 8 Sep 2020 14:45:06 +0800 Message-ID: <20200908064507.30774-4-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200908064507.30774-1-stanley.chu@mediatek.com> References: <20200908064507.30774-1-stanley.chu@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: A16BDD5A8366D066DA603CCA0A8A17BF6BFBBB21D4FA726657DD4C3FAA686DC52000:8 X-MTK: N Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Forcibly leave UniPro low-power mode if UIC commands is failed. This makes hba_enable_delay_us as correct (default) value for re-enabling the host. At the same time, change type of parameter "lpm" in function ufs_mtk_unipro_set_pm() to "bool". Signed-off-by: Stanley Chu --- drivers/scsi/ufs/ufs-mediatek.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) -- 2.18.0 diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 887c03e8bcc0..feba74a72309 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -419,7 +419,7 @@ static int ufs_mtk_pwr_change_notify(struct ufs_hba *hba, return ret; } -static int ufs_mtk_unipro_set_pm(struct ufs_hba *hba, u32 lpm) +static int ufs_mtk_unipro_set_pm(struct ufs_hba *hba, bool lpm) { int ret; struct ufs_mtk_host *host = ufshcd_get_variant(hba); @@ -427,8 +427,14 @@ static int ufs_mtk_unipro_set_pm(struct ufs_hba *hba, u32 lpm) ret = ufshcd_dme_set(hba, UIC_ARG_MIB_SEL(VS_UNIPROPOWERDOWNCONTROL, 0), lpm); - if (!ret) + if (!ret || !lpm) { + /* + * Forcibly set as non-LPM mode if UIC commands is failed + * to use default hba_enable_delay_us value for re-enabling + * the host. + */ host->unipro_lpm = lpm; + } return ret; } @@ -438,7 +444,9 @@ static int ufs_mtk_pre_link(struct ufs_hba *hba) int ret; u32 tmp; - ufs_mtk_unipro_set_pm(hba, 0); + ret = ufs_mtk_unipro_set_pm(hba, false); + if (ret) + return ret; /* * Setting PA_Local_TX_LCC_Enable to 0 before link startup @@ -546,7 +554,7 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) if (err) return err; - err = ufs_mtk_unipro_set_pm(hba, 0); + err = ufs_mtk_unipro_set_pm(hba, false); if (err) return err; @@ -567,10 +575,10 @@ static int ufs_mtk_link_set_lpm(struct ufs_hba *hba) { int err; - err = ufs_mtk_unipro_set_pm(hba, 1); + err = ufs_mtk_unipro_set_pm(hba, true); if (err) { /* Resume UniPro state for following error recovery */ - ufs_mtk_unipro_set_pm(hba, 0); + ufs_mtk_unipro_set_pm(hba, false); return err; } From patchwork Tue Sep 8 06:45:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanley Chu X-Patchwork-Id: 296828 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11A68C2BBD0 for ; Tue, 8 Sep 2020 06:45:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D478E218AC for ; Tue, 8 Sep 2020 06:45:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="tzjS+Klg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728908AbgIHGp1 (ORCPT ); Tue, 8 Sep 2020 02:45:27 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:2238 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728625AbgIHGpT (ORCPT ); Tue, 8 Sep 2020 02:45:19 -0400 X-UUID: f643ba82369d428ea25f684f86921498-20200908 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=vkAchY3C2WddVlo+HHoOzkA8z5hp05WmN9gYTWWqPaI=; b=tzjS+KlgCtKvL3faXFbkAS2GHYlMteLeI9tGWYxOF3Ht2By59bTEqreKQSp3vjPbLgHMZgVZU3zz16rdZOgkEPfyIZyRdGhdYa/kRFeQ0u3LVmDatHnAeU3KTq8ZnEwjHNhj0dq0IRztp5yScCllvXza3ugdVroXM9Ne9fXEOA8=; X-UUID: f643ba82369d428ea25f684f86921498-20200908 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (Cellopoint E-mail Firewall v4.1.14 Build 0819 with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 301193689; Tue, 08 Sep 2020 14:45:12 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs05n1.mediatek.inc (172.21.101.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 8 Sep 2020 14:45:10 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 8 Sep 2020 14:45:10 +0800 From: Stanley Chu To: , , , , CC: , , , , , , , , , , , Stanley Chu Subject: [PATCH 4/4] scsi: ufs-mediatek: Add host reset mechanism Date: Tue, 8 Sep 2020 14:45:07 +0800 Message-ID: <20200908064507.30774-5-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200908064507.30774-1-stanley.chu@mediatek.com> References: <20200908064507.30774-1-stanley.chu@mediatek.com> MIME-Version: 1.0 X-MTK: N Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Add host reset mechanism to try to recover host-side errors during recovery flow. Signed-off-by: Stanley Chu --- drivers/scsi/ufs/ufs-mediatek.c | 48 +++++++++++++++++++++++++++++++-- drivers/scsi/ufs/ufs-mediatek.h | 3 +++ 2 files changed, 49 insertions(+), 2 deletions(-) -- 2.18.0 diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index feba74a72309..1a9133ac6efb 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "ufshcd.h" @@ -91,16 +92,57 @@ static void ufs_mtk_crypto_enable(struct ufs_hba *hba) } } +static void ufs_mtk_host_reset(struct ufs_hba *hba) +{ + struct ufs_mtk_host *host = ufshcd_get_variant(hba); + + reset_control_assert(host->hci_reset); + reset_control_assert(host->crypto_reset); + reset_control_assert(host->unipro_reset); + + usleep_range(100, 110); + + reset_control_deassert(host->unipro_reset); + reset_control_deassert(host->crypto_reset); + reset_control_deassert(host->hci_reset); +} + +static void ufs_mtk_init_reset_control(struct ufs_hba *hba, + struct reset_control **rc, + char *str) +{ + *rc = devm_reset_control_get(hba->dev, str); + if (IS_ERR(*rc)) { + dev_info(hba->dev, "Failed to get reset control %s: %d\n", + str, PTR_ERR(*rc)); + *rc = NULL; + } +} + +static void ufs_mtk_init_reset(struct ufs_hba *hba) +{ + struct ufs_mtk_host *host = ufshcd_get_variant(hba); + + ufs_mtk_init_reset_control(hba, &host->hci_reset, + "hci_rst"); + ufs_mtk_init_reset_control(hba, &host->unipro_reset, + "unipro_rst"); + ufs_mtk_init_reset_control(hba, &host->crypto_reset, + "crypto_rst"); +} + static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba, enum ufs_notify_change_status status) { struct ufs_mtk_host *host = ufshcd_get_variant(hba); if (status == PRE_CHANGE) { - if (host->unipro_lpm) + if (host->unipro_lpm) { hba->vps->hba_enable_delay_us = 0; - else + } else { hba->vps->hba_enable_delay_us = 600; + ufs_mtk_host_reset(hba); + } if (hba->caps & UFSHCD_CAP_CRYPTO) ufs_mtk_crypto_enable(hba); @@ -335,6 +377,8 @@ static int ufs_mtk_init(struct ufs_hba *hba) if (err) goto out_variant_clear; + ufs_mtk_init_reset(hba); + /* Enable runtime autosuspend */ hba->caps |= UFSHCD_CAP_RPM_AUTOSUSPEND; diff --git a/drivers/scsi/ufs/ufs-mediatek.h b/drivers/scsi/ufs/ufs-mediatek.h index 87657376d27a..5c32d5f52759 100644 --- a/drivers/scsi/ufs/ufs-mediatek.h +++ b/drivers/scsi/ufs/ufs-mediatek.h @@ -92,6 +92,9 @@ enum { struct ufs_mtk_host { struct ufs_hba *hba; struct phy *mphy; + struct reset_control *hci_reset; + struct reset_control *unipro_reset; + struct reset_control *crypto_reset; bool mphy_powered_on; bool unipro_lpm; bool ref_clk_enabled;