From patchwork Mon May 31 05:17:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanley Chu X-Patchwork-Id: 450663 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=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, 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 D1B35C4708F for ; Mon, 31 May 2021 05:18:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A4E9D61108 for ; Mon, 31 May 2021 05:18:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229970AbhEaFTn (ORCPT ); Mon, 31 May 2021 01:19:43 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:40406 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S229730AbhEaFTm (ORCPT ); Mon, 31 May 2021 01:19:42 -0400 X-UUID: efd1ff25b74f4e6fbe4e3f008422e862-20210531 X-UUID: efd1ff25b74f4e6fbe4e3f008422e862-20210531 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1055083393; Mon, 31 May 2021 13:17:59 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n1.mediatek.inc (172.21.101.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 31 May 2021 13:17:58 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 31 May 2021 13:17:58 +0800 From: Stanley Chu To: , , , , CC: , , , , , , , , Stanley Chu Subject: [PATCH v1] scsi: ufs-mediatek: Fix HCI version in some platforms Date: Mon, 31 May 2021 13:17:57 +0800 Message-ID: <20210531051757.11538-1-stanley.chu@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Some MediaTek platforms have incorrect UFSHCI versions showed in register map. Fix the version by referring to UniPro version which is always correct. Signed-off-by: Stanley Chu Reviewed-by: Alim Akhtar --- drivers/scsi/ufs/ufs-mediatek.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c index 9912e208c2a1..3d3605fd05b2 100644 --- a/drivers/scsi/ufs/ufs-mediatek.c +++ b/drivers/scsi/ufs/ufs-mediatek.c @@ -606,6 +606,16 @@ static void ufs_mtk_get_controller_version(struct ufs_hba *hba) if (ver >= UFS_UNIPRO_VER_1_8) host->hw_ver.major = 3; } + + /* Fix HCI version for some platforms with incorrect version */ + if (hba->ufs_version < ufshci_version(3, 0) && + host->hw_ver.major == 3) + hba->ufs_version = ufshci_version(3, 0); +} + +static u32 ufs_mtk_get_ufs_hci_version(struct ufs_hba *hba) +{ + return hba->ufs_version; } /** @@ -1042,6 +1052,7 @@ static void ufs_mtk_event_notify(struct ufs_hba *hba, static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = { .name = "mediatek.ufshci", .init = ufs_mtk_init, + .get_ufs_hci_version = ufs_mtk_get_ufs_hci_version, .setup_clocks = ufs_mtk_setup_clocks, .hce_enable_notify = ufs_mtk_hce_enable_notify, .link_startup_notify = ufs_mtk_link_startup_notify,