From nobody Fri Dec 19 19:01:37 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 967CC2FE059; Tue, 14 Oct 2025 15:14:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760454882; cv=pass; b=LoKHrVpoYBUUaFtLxMGWQZvv6Qrq8f46G2rdGzMl0YVuL2myMZBvGQTP09C7ssZvEDxBILZxsOyU5ACz843X0f4ZMjbCWQQACmh/fTAjWGwxAa7AX6TaPe/5vY2AxQaJ9egEMk8ly7cRfSZIfen4dMvqiqVWL8vLSfNpJ56OSDU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760454882; c=relaxed/simple; bh=4iA4BVkEFseFO+a9FqRbLGiXmYUQ246lOovlRlDNWdg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kNpTwEEEBhT2lA6itRol1M/czhT7kfQ301mS8Ph/JEtzmvFsxV1s75ZrSGQ4mSa+SHJgl6UYqoN0ghIN6YGXDkirnCKy9W7iqabuCrrZz7H0EPP80nunyR7YVI7acA4aTh9j2P8uF3WVX7C1nW9VeVriKT76P4GtuEkgdQbJREU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b=L5hwE4P9; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b="L5hwE4P9" ARC-Seal: i=1; a=rsa-sha256; t=1760454628; cv=none; d=zohomail.com; s=zohoarc; b=nLN6ADu8nqiOQ2MThJFvzdjYEYgskAVqgDSLkFK3jHJvD2uFb5t8UzfG1qVS3P0l76aNj1FnI6rIP1EtS60XLrlIU6cJeRBUzYRg43OZVGJGmLVl3ZzDmVHRebOMdzR4FgQ5BO3ae3yE1z52BVLlR6dzMx7YqLH5qlvkiWvW8RI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760454628; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=rEepjpoQHsg1UgdPFotNZVd0m8loLoC8YXtD9n1Hdes=; b=mCUz9X8K/deAwwgetutsjw3tg3344u6RuPdiumDdUWBEnC5qVLQTOWjYrsNOWexkH7cihKUhNkPV0ovMvPRguMVCkeokYf+iD0zXq10jPctqQjZzgSEPNYG/vRsP/EBxKpEWNT5Im1wIunEbtz35Sv45CYBsY6d8dU6sgh6Ne/A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1760454628; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=rEepjpoQHsg1UgdPFotNZVd0m8loLoC8YXtD9n1Hdes=; b=L5hwE4P9r77pCUiLinc7iXSGRLbgqmsp4/X7do6pJDcjRDQ2288roi4W4iDAq9Ac ObW4r3mngAzhkugIqfy0LQi1mmEvNtDD8+0dev61WmwoXWZ38+bMAbHykve2/CGmi2j IGflJxGr26WmW5MiUcfZfYdFuzhbOP24vYq8uHWs= Received: by mx.zohomail.com with SMTPS id 1760454626724250.19910245942265; Tue, 14 Oct 2025 08:10:26 -0700 (PDT) From: Nicolas Frattaroli Date: Tue, 14 Oct 2025 17:10:05 +0200 Subject: [PATCH 1/5] dt-bindings: ufs: mediatek,ufs: Add mt8196-ufshci variant Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251014-mt8196-ufs-v1-1-195dceb83bc8@collabora.com> References: <20251014-mt8196-ufs-v1-0-195dceb83bc8@collabora.com> In-Reply-To: <20251014-mt8196-ufs-v1-0-195dceb83bc8@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Stanley Chu , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel Cc: Louis-Alexis Eyraud , kernel@collabora.com, linux-scsi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 The MediaTek MT8196 SoC contains the same UFS host controller interface hardware as the MT8195 SoC. Add it as a variant of MT8195, and extend its list of allowed clocks, as well as give it the previously absent resets property. Also add examples for both MT8195 and the new MT8196, so that the binding can be verified against examples for these two variants. Signed-off-by: Nicolas Frattaroli --- .../devicetree/bindings/ufs/mediatek,ufs.yaml | 134 +++++++++++++++++= ++-- 1 file changed, 123 insertions(+), 11 deletions(-) diff --git a/Documentation/devicetree/bindings/ufs/mediatek,ufs.yaml b/Docu= mentation/devicetree/bindings/ufs/mediatek,ufs.yaml index 1dec54fb00f3..070ae0982591 100644 --- a/Documentation/devicetree/bindings/ufs/mediatek,ufs.yaml +++ b/Documentation/devicetree/bindings/ufs/mediatek,ufs.yaml @@ -11,18 +11,30 @@ maintainers: =20 properties: compatible: - enum: - - mediatek,mt8183-ufshci - - mediatek,mt8192-ufshci - - mediatek,mt8195-ufshci + oneOf: + - enum: + - mediatek,mt8183-ufshci + - mediatek,mt8195-ufshci + - items: + - enum: + - mediatek,mt8192-ufshci + - const: mediatek,mt8183-ufshci + - items: + - enum: + - mediatek,mt8196-ufshci + - const: mediatek,mt8195-ufshci =20 clocks: minItems: 1 - maxItems: 8 + maxItems: 16 =20 clock-names: minItems: 1 - maxItems: 8 + maxItems: 16 + + freq-table-hz: true + + interrupts: true =20 phys: maxItems: 1 @@ -30,7 +42,15 @@ properties: reg: maxItems: 1 =20 + resets: + maxItems: 3 + + reset-names: + maxItems: 3 + vcc-supply: true + vccq-supply: true + vccq2-supply: true =20 mediatek,ufs-disable-mcq: $ref: /schemas/types.yaml#/definitions/flag @@ -44,22 +64,19 @@ required: - reg - vcc-supply =20 -unevaluatedProperties: false - allOf: - $ref: ufs-common.yaml - - if: properties: compatible: contains: - enum: - - mediatek,mt8195-ufshci + const: mediatek,mt8195-ufshci then: properties: clocks: minItems: 8 clock-names: + minItems: 8 items: - const: ufs - const: ufs_aes @@ -69,6 +86,19 @@ allOf: - const: unipro_mp_bclk - const: ufs_tx_symbol - const: ufs_mem_sub + - const: crypt_mux + - const: crypt_lp + - const: crypt_perf + - const: ufs_sel + - const: ufs_sel_min_src + - const: ufs_sel_max_src + - const: ufs_rx_symbol0 + - const: ufs_rx_symbol1 + reset-names: + items: + - const: unipro_rst + - const: crypto_rst + - const: hci_rst else: properties: clocks: @@ -76,6 +106,10 @@ allOf: clock-names: items: - const: ufs + resets: false + reset-names: false + +unevaluatedProperties: false =20 examples: - | @@ -99,3 +133,81 @@ examples: vcc-supply =3D <&mt_pmic_vemc_ldo_reg>; }; }; + - | + ufshci@11270000 { + compatible =3D "mediatek,mt8195-ufshci"; + reg =3D <0x11270000 0x2300>; + interrupts =3D ; + phys =3D <&ufsphy>; + clocks =3D <&infracfg_ao 63>, <&infracfg_ao 64>, <&infracfg_ao 65>, + <&infracfg_ao 54>, <&infracfg_ao 55>, + <&infracfg_ao 56>, <&infracfg_ao 90>, + <&infracfg_ao 93>; + clock-names =3D "ufs", "ufs_aes", "ufs_tick", + "unipro_sysclk", "unipro_tick", + "unipro_mp_bclk", "ufs_tx_symbol", + "ufs_mem_sub"; + freq-table-hz =3D <0 0>, <0 0>, <0 0>, + <0 0>, <0 0>, <0 0>, + <0 0>, <0 0>; + vcc-supply =3D <&mt6359_vemc_1_ldo_reg>; + mediatek,ufs-disable-mcq; + }; + - | + #include + #include + + ufshci@16810000 { + compatible =3D "mediatek,mt8196-ufshci", "mediatek,mt8195-ufshci"; + reg =3D <0x16810000 0x2a00>; + interrupts =3D ; + + clocks =3D <&ufs_ao_clk 6>, + <&ufs_ao_clk 7>, + <&clk26m>, + <&ufs_ao_clk 3>, + <&clk26m>, + <&ufs_ao_clk 4>, + <&ufs_ao_clk 0>, + <&topckgen 7>, + <&topckgen 41>, + <&topckgen 105>, + <&topckgen 83>, + <&topckgen 42>, + <&topckgen 84>, + <&topckgen 102>, + <&ufs_ao_clk 1>, + <&ufs_ao_clk 2>; + clock-names =3D "ufs", + "ufs_aes", + "ufs_tick", + "unipro_sysclk", + "unipro_tick", + "unipro_mp_bclk", + "ufs_tx_symbol", + "ufs_mem_sub", + "crypt_mux", + "crypt_lp", + "crypt_perf", + "ufs_sel", + "ufs_sel_min_src", + "ufs_sel_max_src", + "ufs_rx_symbol0", + "ufs_rx_symbol1"; + + freq-table-hz =3D <273000000 499200000>, <0 0>, <0 0>, <0 0>, <0 0= >, + <0 0>, <0 0>, <0 0>, <0 0>, <0 0>, <0 0>, <0 0>, <= 0 0>, + <0 0>; + + phys =3D <&ufsphy>; + + vcc-supply =3D <&mt6363_vemc>; + vccq-supply =3D <&mt6363_vufs12>; + vccq2-supply =3D <&mt6363_vufs18>; + + resets =3D <&ufs_ao_clk MT8196_UFSAO_RST1_UFS_UNIPRO>, + <&ufs_ao_clk MT8196_UFSAO_RST1_UFS_CRYPTO>, + <&ufs_ao_clk MT8196_UFSAO_RST1_UFSHCI>; + reset-names =3D "unipro_rst", "crypto_rst", "hci_rst"; + mediatek,ufs-disable-mcq; + }; --=20 2.51.0 From nobody Fri Dec 19 19:01:37 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F49F293B75; Tue, 14 Oct 2025 15:13:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760454783; cv=pass; b=apL0CTZj4RMecrdqnBGDeDlH6E59Xcs/U8Uz2FmDAAXJzFHuR8YafCx+Ue3BHPQq2vog6El2MYVxownFW9iH9JKN4W1w+eq5JOnhvWTkffvU8SUyGUQolWXh0geX01gDzDTam12Eb+5JuvUK4MuLPYtHYvMh9Ekmsja506Qixhg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760454783; c=relaxed/simple; bh=sOK0treD2Cs2K5bgcmg+JxqQwU93mbWRtjbQCZCe8M0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SKmcABW1CIHeuuKHHc5Q0F3bOjorCWEymmB/kdP865XUS9UGIvkMUWgkmRCJrIdPHxrp8GdSQjmBNyxyCNbitKjFowNJunlJjSwI4xlSzVXjoCABspcq0b1Ko/k07fNdQy1hkCmxAsJLnhqYiXh/DGJTjx58XTWzWhiuqGyETvU= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b=SkvXYBaC; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b="SkvXYBaC" ARC-Seal: i=1; a=rsa-sha256; t=1760454634; cv=none; d=zohomail.com; s=zohoarc; b=YFesbeUwlkzD1QphTliZ9lmVeXUHPW9hLQj9rgLnOw0yoDOOfrclGyZGyp4vrXoT+lGGBz6cohrQH2R0rABTY8Nlkp+s4NQ3zr56+pdVuVnC7o/x14M3HzU3EhXzCZ+y2XR4E3uw7MFs6iJjLpk2C876kO+IsW1itFUuZ1Kblbk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760454634; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=6Gff7G1g/GqG8/Cg1a6daJvkf1hEhtYTLHsqf3G+mlM=; b=bK1Jys7bgxokaalWMIKr5axRapsTOsIDtb0wd+gEyRjBYPRbpV4MAFcxt/+ZLV4c/aJGsW0WgCEOw9TFpc2p+2XQSX7RoSxrSXi+nYwIkCfuu8rIlMpJxj/N8rjsSrh+dsBBEZk6gt3K5cBSsFDwsVbBobxR8mykXbVD2cfDYMw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1760454634; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=6Gff7G1g/GqG8/Cg1a6daJvkf1hEhtYTLHsqf3G+mlM=; b=SkvXYBaC48Q1+OmzERbolE3fIu4xG1Ao/KReZN4R1gLtO/KsGKyA7GSd6r7SBEMj f5lElPmfYtPM0SHn/o2Vvrc2iTA5jxn8cUaXJCxGQKsrL9iANW/QvIBOFJkfW1TYKRq 3KCAIw5OIPcDsLKEOnTWjk9FWEBXD0kC1+nH2ACg= Received: by mx.zohomail.com with SMTPS id 1760454632840287.65577737972126; Tue, 14 Oct 2025 08:10:32 -0700 (PDT) From: Nicolas Frattaroli Date: Tue, 14 Oct 2025 17:10:06 +0200 Subject: [PATCH 2/5] dt-bindings: phy: Add mediatek,mt8196-ufsphy variant Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251014-mt8196-ufs-v1-2-195dceb83bc8@collabora.com> References: <20251014-mt8196-ufs-v1-0-195dceb83bc8@collabora.com> In-Reply-To: <20251014-mt8196-ufs-v1-0-195dceb83bc8@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Stanley Chu , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel Cc: Louis-Alexis Eyraud , kernel@collabora.com, linux-scsi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 The MediaTek MT8196 SoC includes an M-PHY compatible with the already existing mt8183 binding. However, one omission from the original binding was that all of these variants may have an optional reset. Add the new compatible, and also the resets property, with an example. Signed-off-by: Nicolas Frattaroli Reviewed-by: Peter Wang --- .../devicetree/bindings/phy/mediatek,ufs-phy.yaml | 16 ++++++++++++= ++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/devicetree/bindings/phy/mediatek,ufs-phy.yaml b/= Documentation/devicetree/bindings/phy/mediatek,ufs-phy.yaml index 3e62b5d4da61..f414aaa18997 100644 --- a/Documentation/devicetree/bindings/phy/mediatek,ufs-phy.yaml +++ b/Documentation/devicetree/bindings/phy/mediatek,ufs-phy.yaml @@ -26,6 +26,7 @@ properties: - items: - enum: - mediatek,mt8195-ufsphy + - mediatek,mt8196-ufsphy - const: mediatek,mt8183-ufsphy - const: mediatek,mt8183-ufsphy =20 @@ -42,6 +43,10 @@ properties: - const: unipro - const: mp =20 + resets: + items: + - description: Optional UFS M-PHY reset. + "#phy-cells": const: 0 =20 @@ -65,5 +70,16 @@ examples: clock-names =3D "unipro", "mp"; #phy-cells =3D <0>; }; + - | + #include + ufs-phy@16800000 { + compatible =3D "mediatek,mt8196-ufsphy", "mediatek,mt8183-ufsphy"; + reg =3D <0x16800000 0x10000>; + clocks =3D <&ufs_ao_clk 3>, + <&ufs_ao_clk 5>; + clock-names =3D "unipro", "mp"; + resets =3D <&ufs_ao_clk MT8196_UFSAO_RST0_UFS_MPHY>; + #phy-cells =3D <0>; + }; =20 ... --=20 2.51.0 From nobody Fri Dec 19 19:01:37 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 070552F2617; Tue, 14 Oct 2025 15:11:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760454693; cv=pass; b=Ch+lHZdp6ruQMmd3n9u0EoCniap3p905ZLj8YCJ0sgPd4khaBEYUNNrqiKFRXpWI7cPVPJAaPdyDgJgyQSHr38U+FV46RvHvFtU6u0JMKRF2YNgaM8GbEFLeARr+5xNfyXPtIjn3TnM6dGOt5h1mYwsRZ3I4Ghr+L4DH47fJqPI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760454693; c=relaxed/simple; bh=OYR1u37Tb3XWCZR66Y6xfFqJUVVXVJmKVxKvbzycF0s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QirytmNTXST+GeZ+s7a6foY17Xo8XuiQ0OtAAsSCT7R5DfZ9ZMW81+ZDzoJcjOc8FYMmE1TVl/9aNmRrWvOafRfWGubtki7lDqgFN+Gmg9ABvxd+J0rEk6bLX3UfJvzPSMIfOwLI4FrN2TDMmrPGx0yjJ64uTXonBUa4tBDA+xY= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b=lQHwgqCA; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b="lQHwgqCA" ARC-Seal: i=1; a=rsa-sha256; t=1760454640; cv=none; d=zohomail.com; s=zohoarc; b=EhK8NFG8ZYrA1NULgL/6B9R4BgOOuBqSodKvMH2ggz5BbFLTYvQ/UNgfgmsJzXg82pbnSP4Xb1YCTaAyvtp2B7QPaTNyr7jvtYSqXB3Qb3lJK9VQncMGXoFWG5+UaDo2bmzuvvbCVYiuNqdSyp3UOvUDASIg/3VHLiolODOoYj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760454640; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=IaZjyVgZLuZuUtVnxGG37OKipwDbPrdj2yM2vX3Sqjw=; b=RAtV+qcdaWlzJIsmdOC4L1BBxSFXJQLhG35qNIFanGdgPzCKyNrF83Ybsb94fvnu/DRvoRPXyMfMiIql5ygDdz15p76n4eg0XY1y3LNE8fdSXHIUagrrqSCaeednZow+hDSNm0m9mVXE1l66k2jfXO1ePfJqZ6jjiZFuE8rVKzw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1760454640; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=IaZjyVgZLuZuUtVnxGG37OKipwDbPrdj2yM2vX3Sqjw=; b=lQHwgqCA135N4a61mEhq1P61Zld0tISGXCENHxAZKdiBBNbEGytoWcapDtgho3Mw zaUlC+15AmsSfa5tW6rnQ5XF+eh7onovN+Dy8ud1FaIwPfAJDtifUHitqTZmjYJGAHM 07A0PMDXjlwKA+KcDKBLHje/ahCFhCvz1sHEhAg8= Received: by mx.zohomail.com with SMTPS id 1760454638875336.50108320974346; Tue, 14 Oct 2025 08:10:38 -0700 (PDT) From: Nicolas Frattaroli Date: Tue, 14 Oct 2025 17:10:07 +0200 Subject: [PATCH 3/5] scsi: ufs: mediatek: Move MTK_SIP_UFS_CONTROL to mtk_sip_svc.h Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251014-mt8196-ufs-v1-3-195dceb83bc8@collabora.com> References: <20251014-mt8196-ufs-v1-0-195dceb83bc8@collabora.com> In-Reply-To: <20251014-mt8196-ufs-v1-0-195dceb83bc8@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Stanley Chu , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel Cc: Louis-Alexis Eyraud , kernel@collabora.com, linux-scsi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 SMC commands used by multiple drivers need to live in a shared header file somewhere to avoid code duplication. In order to rework the MPHY reset control to be in the phy-mtk-ufs.c driver, both ufs-mediatek and the phy driver need access to this command. Move it to mtk_sip_svc.h, where other such command definitions already live. Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek-sip.h | 1 - include/linux/soc/mediatek/mtk_sip_svc.h | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/ufs/host/ufs-mediatek-sip.h b/drivers/ufs/host/ufs-med= iatek-sip.h index 7d17aedf6fb8..d627dfb4a766 100644 --- a/drivers/ufs/host/ufs-mediatek-sip.h +++ b/drivers/ufs/host/ufs-mediatek-sip.h @@ -11,7 +11,6 @@ /* * SiP (Slicon Partner) commands */ -#define MTK_SIP_UFS_CONTROL MTK_SIP_SMC_CMD(0x276) #define UFS_MTK_SIP_VA09_PWR_CTRL BIT(0) #define UFS_MTK_SIP_DEVICE_RESET BIT(1) #define UFS_MTK_SIP_CRYPTO_CTRL BIT(2) diff --git a/include/linux/soc/mediatek/mtk_sip_svc.h b/include/linux/soc/m= ediatek/mtk_sip_svc.h index abe24a73ee19..9a6866912e81 100644 --- a/include/linux/soc/mediatek/mtk_sip_svc.h +++ b/include/linux/soc/mediatek/mtk_sip_svc.h @@ -28,4 +28,7 @@ /* IOMMU related SMC call */ #define MTK_SIP_KERNEL_IOMMU_CONTROL MTK_SIP_SMC_CMD(0x514) =20 +/* UFS related SMC call */ +#define MTK_SIP_UFS_CONTROL MTK_SIP_SMC_CMD(0x276) + #endif --=20 2.51.0 From nobody Fri Dec 19 19:01:37 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A2952FD7D2; Tue, 14 Oct 2025 15:14:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760454846; cv=pass; b=ICDvZknkE8DVZWvftRHfiZfVhm+9s8dph12frj6SkvhfAAjtSdzFfHLCFRMqJsNx9rJdhTyokZePIEiq/HDbI2G/eOQ4CBufYDiK1zpXu6WlCOT5xQtj2+HPAsSdFIuCibKmPoYlJJCbykUgSvdzIhMc8FkdIYCLIJz4Rq2r64g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760454846; c=relaxed/simple; bh=f97ySkmH27TQZ5dnuAar65600J4WxMEGon4F5OUmPw0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mrZDAm3Ld8W7O1BLqXGLgd2y0IsmFlutbVg17nMGS9dvXwmkoJjMMGZ0HyOq41rdIlI4im+tku4w6GMJQY4NrRBlgQ1MpYRVNERMLY/T8S8mWQbF7J0EcV+cZpu98NliqAeEvMDZzKjL/O/P81OCuRXomfdD1hjJLRWbs2TtNBM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b=Iku4pBRO; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b="Iku4pBRO" ARC-Seal: i=1; a=rsa-sha256; t=1760454646; cv=none; d=zohomail.com; s=zohoarc; b=KMACuvpQzCefnrI3b1YfrnL+lK+MEgP3Cq03wKR81NLcBZQ2ReaMHtGI2NaGGp0C01f9dyP9xs1OlAehWuZ7jSXxoZNBekMxj/NEzHJ8C7aRgYi3Q8yPJX5CCrM+csgd9rWUu60STVPB1yYyJOYtEIiGjIig1dcvDQM3tRSTndM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760454646; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=ELRxhcckH/K4X4xPLZVCnB+NvfeZkGFUnfudFxrDDVs=; b=JaYWzaYsnpFb47EMfzR91c52eKAPOCgVVzOUXvwkrmOUAfcQAjss4IyTvK4CVR0GQuHNyGvI7nduXteB6efMe7pLSx03lHjI37xnIIu66xn+WLvO5G4YhWSliz4PZDtWLJIrbIo6HF2pKAnBdHx9CfIwElt9tQlHoOSnwxiDiKE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1760454646; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=ELRxhcckH/K4X4xPLZVCnB+NvfeZkGFUnfudFxrDDVs=; b=Iku4pBROLwirKXBOAcGAIsS9GZLRz1kRnghtJyFLHXv/OtdZp9+CyhuT5C/LDtog bLrmF1j+3laSyrh7FWo+dAIjF0j2VVM4YrHdgVWCjpcwUN/Hy3JyXcrF0nHlnGaRuMn dpFv8uOGcCvtTrvdr4yP+JhL59lzkvof4Cu64PNc= Received: by mx.zohomail.com with SMTPS id 1760454644892798.4521273218037; Tue, 14 Oct 2025 08:10:44 -0700 (PDT) From: Nicolas Frattaroli Date: Tue, 14 Oct 2025 17:10:08 +0200 Subject: [PATCH 4/5] phy: mediatek: ufs: Add support for resets Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251014-mt8196-ufs-v1-4-195dceb83bc8@collabora.com> References: <20251014-mt8196-ufs-v1-0-195dceb83bc8@collabora.com> In-Reply-To: <20251014-mt8196-ufs-v1-0-195dceb83bc8@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Stanley Chu , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel Cc: Louis-Alexis Eyraud , kernel@collabora.com, linux-scsi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 The MediaTek UFS PHY supports PHY resets. Until now, they've been implemented in the UFS host driver. Since they were never documented in the UFS HCI node's DT bindings, and no mainline DT uses it, it's fine if it's moved to the correct location, which is the PHY driver. Implement the MPHY reset logic in this driver and expose it through the phy subsystem's reset op. The reset itself is optional, as judging by other mainline devices that use this hardware, it's not required for the device to function. If no reset is present, the reset op returns -EOPNOTSUPP, which means that the ufshci driver can detect it's present and not double sleep in its own reset function, where it will call the phy reset. Signed-off-by: Nicolas Frattaroli --- drivers/phy/mediatek/phy-mtk-ufs.c | 71 ++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 71 insertions(+) diff --git a/drivers/phy/mediatek/phy-mtk-ufs.c b/drivers/phy/mediatek/phy-= mtk-ufs.c index 0cb5a25b1b7a..d77ba689ebc8 100644 --- a/drivers/phy/mediatek/phy-mtk-ufs.c +++ b/drivers/phy/mediatek/phy-mtk-ufs.c @@ -4,6 +4,7 @@ * Author: Stanley Chu */ =20 +#include #include #include #include @@ -11,6 +12,8 @@ #include #include #include +#include +#include =20 #include "phy-mtk-io.h" =20 @@ -36,9 +39,17 @@ =20 #define UFSPHY_CLKS_CNT 2 =20 +#define UFS_MTK_SIP_MPHY_CTRL BIT(8) + +enum ufs_mtk_mphy_op { + UFS_MPHY_BACKUP =3D 0, + UFS_MPHY_RESTORE +}; + struct ufs_mtk_phy { struct device *dev; void __iomem *mmio; + struct reset_control *reset; struct clk_bulk_data clks[UFSPHY_CLKS_CNT]; }; =20 @@ -141,9 +152,59 @@ static int ufs_mtk_phy_power_off(struct phy *generic_p= hy) return 0; } =20 +static int ufs_mtk_phy_ctrl(struct ufs_mtk_phy *phy, enum ufs_mtk_mphy_op = op) +{ + struct arm_smccc_res res; + + arm_smccc_smc(MTK_SIP_UFS_CONTROL, UFS_MTK_SIP_MPHY_CTRL, op, + 0, 0, 0, 0, 0, &res); + + switch (res.a0) { + case SMCCC_RET_NOT_SUPPORTED: + return -EOPNOTSUPP; + case SMCCC_RET_INVALID_PARAMETER: + return -EINVAL; + default: + return 0; + } +} + +static int ufs_mtk_phy_reset(struct phy *generic_phy) +{ + struct ufs_mtk_phy *phy =3D get_ufs_mtk_phy(generic_phy); + int ret; + + if (!phy->reset) + return -EOPNOTSUPP; + + ret =3D reset_control_assert(phy->reset); + if (ret) + return ret; + + usleep_range(100, 110); + + ret =3D reset_control_deassert(phy->reset); + if (ret) + return ret; + + /* + * To avoid double-sleep and other unintended side-effects in the ufshci + * driver, don't return the phy_ctrl retval here, but just return -EPROTO. + */ + ret =3D ufs_mtk_phy_ctrl(phy, UFS_MPHY_RESTORE); + if (ret) { + dev_err(phy->dev, "UFS_MPHY_RESTORE SMC command failed: %pe\n", + ERR_PTR(ret)); + return -EPROTO; + } + + return 0; +} + static const struct phy_ops ufs_mtk_phy_ops =3D { .power_on =3D ufs_mtk_phy_power_on, .power_off =3D ufs_mtk_phy_power_off, + .reset =3D ufs_mtk_phy_reset, .owner =3D THIS_MODULE, }; =20 @@ -163,8 +224,18 @@ static int ufs_mtk_phy_probe(struct platform_device *p= dev) if (IS_ERR(phy->mmio)) return PTR_ERR(phy->mmio); =20 + phy->reset =3D devm_reset_control_get_optional(dev, NULL); + if (IS_ERR(phy->reset)) + return dev_err_probe(dev, PTR_ERR(phy->reset), "Failed to get reset\n"); + phy->dev =3D dev; =20 + if (phy->reset) { + ret =3D ufs_mtk_phy_ctrl(phy, UFS_MPHY_BACKUP); + if (ret) + return dev_err_probe(dev, ret, "Failed to back up MPHY\n"); + } + ret =3D ufs_mtk_phy_clk_init(phy); if (ret) return ret; --=20 2.51.0 From nobody Fri Dec 19 19:01:37 2025 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 05BED2FF65A; Tue, 14 Oct 2025 15:13:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760454822; cv=pass; b=OelX96zzH4IVE65L6v9/u8S2hHYP6/xQ1hXm7v7cdm4/a+jeO2MyXXg1ZCphUJgCG7plvF7JMYVOnh0S9wEmzbwPVGOGA3AQVIGuz550svEpUYf32shWDh9Vj6qAsbvIoxb1GrrinssCKkBdgruzf33U/MvCjyTHgy/TC/ibeCw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760454822; c=relaxed/simple; bh=ZoBWVENKC8bPtFQSfKS6zeGQ+CyKx+/t0ZMvJMoFv98=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=h3x+tKR3Ab4RG8BEI950tfcJjAdhze/FXeV21pzNAVLkjjlKysi3KAY46q5DjFq14wLTRULLXwhPqtQMJGaVUJp7v84urX6xoYYPF5kEG0uPEFCTuxVdgXOwyI41FNna+TV5idBrPRxFr8yZVcip696wj05JUpZwytFmlXJbUWc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b=d9GVtVEN; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=nicolas.frattaroli@collabora.com header.b="d9GVtVEN" ARC-Seal: i=1; a=rsa-sha256; t=1760454652; cv=none; d=zohomail.com; s=zohoarc; b=CiuqWR2ZZlUhRzSdVwTeRuN3iwz5IpWLxexEnP8fiGfANThuTjYNGS2X6TpNQsU99z8iBxva7mnh5dSNM8OF8DPk6kwwNkRjnjBtirMEE7EcOTaxkkbdeDKiFl/e8xQJMnq+ecOynYhSeNynF/umnlE7x2FhRBKelahog71qeVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760454652; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=7jkM8YOO8pprHHZutGv60L6EyLB0fCheY+VPh3UUMEs=; b=Z4GCPKO5LrA8hscwHINGC1AvqSn9Ry8P/pbxZ5ChU73Wd69TqA4Fj2dCJn5UHkKKUZXYdoOlpyZ6d5MvsZL+2vxaPvqlF27xo8f+szdbqB1Xgw0KjonPWf4wAgPO4OzM7ePFFYPBXin6WA3kRoZWnJyiH9nC1CyOz5ZPUy4mv94= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=nicolas.frattaroli@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1760454652; s=zohomail; d=collabora.com; i=nicolas.frattaroli@collabora.com; h=From:From:Date:Date:Subject:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Message-Id:References:In-Reply-To:To:To:Cc:Cc:Reply-To; bh=7jkM8YOO8pprHHZutGv60L6EyLB0fCheY+VPh3UUMEs=; b=d9GVtVENKD3dzplgKPP92f8YaZg0NVzqreE1ArmQK2JoLprb8kKbYTT5s8UUv2ek 98DErOnDVOPPPOZfSqpOx05MOiCsaR3dEKSkp37AbmKtDOgIjiy/PQfiIg++TQYTOfe bNAUD+RS8dIWGfElvqK+PwYmBDljeqkL2noxKbCQ= Received: by mx.zohomail.com with SMTPS id 1760454650860592.8317711169478; Tue, 14 Oct 2025 08:10:50 -0700 (PDT) From: Nicolas Frattaroli Date: Tue, 14 Oct 2025 17:10:09 +0200 Subject: [PATCH 5/5] scsi: ufs: mediatek: Rework resets Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251014-mt8196-ufs-v1-5-195dceb83bc8@collabora.com> References: <20251014-mt8196-ufs-v1-0-195dceb83bc8@collabora.com> In-Reply-To: <20251014-mt8196-ufs-v1-0-195dceb83bc8@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Stanley Chu , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel Cc: Louis-Alexis Eyraud , kernel@collabora.com, linux-scsi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-phy@lists.infradead.org, Nicolas Frattaroli X-Mailer: b4 0.14.3 Rework the reset control getting in the driver's probe function to use the "_optional" function instead of defaulting to NULL on IS_ERR, so that actual real errors (as opposed to missing resets) can be handled as errors in the probe function. Also move the MPHY reset into the PHY driver, where it should live, and remove all remnants of it ever having been in this driver. Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek-sip.h | 8 ----- drivers/ufs/host/ufs-mediatek.c | 67 +++++++++++++++++++++------------= ---- drivers/ufs/host/ufs-mediatek.h | 1 - 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek-sip.h b/drivers/ufs/host/ufs-med= iatek-sip.h index d627dfb4a766..256598cc3b5b 100644 --- a/drivers/ufs/host/ufs-mediatek-sip.h +++ b/drivers/ufs/host/ufs-mediatek-sip.h @@ -31,11 +31,6 @@ enum ufs_mtk_vcc_num { UFS_VCC_MAX }; =20 -enum ufs_mtk_mphy_op { - UFS_MPHY_BACKUP =3D 0, - UFS_MPHY_RESTORE -}; - /* * SMC call wrapper function */ @@ -84,9 +79,6 @@ static inline void _ufs_mtk_smc(struct ufs_mtk_smc_arg s) #define ufs_mtk_device_pwr_ctrl(on, ufs_version, res) \ ufs_mtk_smc(UFS_MTK_SIP_DEVICE_PWR_CTRL, &(res), on, ufs_version) =20 -#define ufs_mtk_mphy_ctrl(op, res) \ - ufs_mtk_smc(UFS_MTK_SIP_MPHY_CTRL, &(res), op) - #define ufs_mtk_mtcmos_ctrl(op, res) \ ufs_mtk_smc(UFS_MTK_SIP_MTCMOS_CTRL, &(res), op) =20 diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index 758a393a9de1..ac40d4a3a800 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -204,49 +204,60 @@ 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 =3D ufshcd_get_variant(hba); - struct arm_smccc_res res; + int ret; =20 reset_control_assert(host->hci_reset); reset_control_assert(host->crypto_reset); reset_control_assert(host->unipro_reset); - reset_control_assert(host->mphy_reset); =20 - usleep_range(100, 110); + ret =3D phy_reset(host->mphy); + + /* + * Only sleep if MPHY doesn't have a reset implemented (which already + * sleeps) or the PHY reset function failed somehow, just to be safe + */ + if (ret) { + usleep_range(100, 110); + if (ret !=3D -EOPNOTSUPP) + dev_warn(hba->dev, "PHY reset failed: %pe\n", ERR_PTR(ret)); + } =20 reset_control_deassert(host->unipro_reset); reset_control_deassert(host->crypto_reset); reset_control_deassert(host->hci_reset); - reset_control_deassert(host->mphy_reset); - - /* restore mphy setting aftre mphy reset */ - if (host->mphy_reset) - ufs_mtk_mphy_ctrl(UFS_MPHY_RESTORE, res); } =20 -static void ufs_mtk_init_reset_control(struct ufs_hba *hba, - struct reset_control **rc, - char *str) +static int ufs_mtk_init_reset_control(struct ufs_hba *hba, + struct reset_control **rc, + const char *str) { - *rc =3D devm_reset_control_get(hba->dev, str); + *rc =3D devm_reset_control_get_optional(hba->dev, str); if (IS_ERR(*rc)) { - dev_info(hba->dev, "Failed to get reset control %s: %ld\n", - str, PTR_ERR(*rc)); - *rc =3D NULL; + dev_err(hba->dev, "Failed to get reset control %s: %pe\n", str, *rc); + return PTR_ERR(*rc); } + + return 0; } =20 -static void ufs_mtk_init_reset(struct ufs_hba *hba) +static int ufs_mtk_init_reset(struct ufs_hba *hba) { struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); + int ret; + + ret =3D ufs_mtk_init_reset_control(hba, &host->hci_reset, "hci_rst"); + if (ret) + return ret; + + ret =3D ufs_mtk_init_reset_control(hba, &host->unipro_reset, "unipro_rst"= ); + if (ret) + return ret; + + ret =3D ufs_mtk_init_reset_control(hba, &host->crypto_reset, "crypto_rst"= ); + if (ret) + return ret; =20 - 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"); - ufs_mtk_init_reset_control(hba, &host->mphy_reset, - "mphy_rst"); + return 0; } =20 static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba, @@ -1238,11 +1249,9 @@ static int ufs_mtk_init(struct ufs_hba *hba) if (err) goto out_variant_clear; =20 - ufs_mtk_init_reset(hba); - - /* backup mphy setting if mphy can reset */ - if (host->mphy_reset) - ufs_mtk_mphy_ctrl(UFS_MPHY_BACKUP, res); + err =3D ufs_mtk_init_reset(hba); + if (err) + goto out_variant_clear; =20 /* Enable runtime autosuspend */ hba->caps |=3D UFSHCD_CAP_RPM_AUTOSUSPEND; diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediate= k.h index dfbf78bd8664..4a8a8dc2ab1e 100644 --- a/drivers/ufs/host/ufs-mediatek.h +++ b/drivers/ufs/host/ufs-mediatek.h @@ -174,7 +174,6 @@ struct ufs_mtk_host { struct reset_control *hci_reset; struct reset_control *unipro_reset; struct reset_control *crypto_reset; - struct reset_control *mphy_reset; struct ufs_hba *hba; struct ufs_mtk_crypt_cfg *crypt; struct ufs_mtk_clk mclk; --=20 2.51.0