From nobody Sat Feb 7 07:24:36 2026 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 89D543EBF01; Sat, 24 Jan 2026 12:02:02 +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=1769256125; cv=pass; b=awgcQNaYVt2aysoDyLQ9ZvijuxHFwNW6bFJBz8m0R1NPRE7RXjRzpGbojcg6h/FxgerOKALrzubc5K2OcXAL3bc9j1TaSDX09gRatXIMjsR0H6vtxjUplTviBo/QVOiUBSPV44vwTE0Z527Us+upR0HDfn4UdYRKa3T5OtWRkEg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256125; c=relaxed/simple; bh=WNEhM1BJ5VBqtLc9zwYWrs8k9OBKuHWoDi6Ou2twFtA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TB+yvgZ0xMPzSAusxUyR51fOSt+IzWwluooMyqWKQ0N75CX9fxGe3hsgJZmEsbLIuumLrbBouY0dsMewqq+XOgs+iPly/oJPQcOACz7Fng9dSvKY8kgb+rP9CD4OxGKfO49M68jKcCq8pnQfifIe4JpNFrm2+R7AOPJpWhhck3A= 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=RS/dpmwe; 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="RS/dpmwe" ARC-Seal: i=1; a=rsa-sha256; t=1769256076; cv=none; d=zohomail.com; s=zohoarc; b=ijju7OV8cxjgH3elB2gmL1oMT+YbAPT86SPZdv4qjKZzAYG34gwvrb4ImQG4ByMicfXeZmRxnC58PYAvIH/6CVZAP0MjYOCTlwti2Kct3Czy+5+3BOVFkIs6h/8nT3v8sEMQi0u56iHtDEaoClVoVaweXlpAFwHzE0/o/Vbd6O0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256076; 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=q/ASY1Etp9IXhLYDc9pjizpkuHyRR0lGX8YLQb99GLU=; b=Fu4B3izq/WFA2pmjRbJ2Q8SrJhpLJQybY5cyWfzZN+8a4/fP4IyMlLo/5Cbmdl40pRq6P+7ob5+XMHRANLDWTPAmszx/kFkL6h8jB75Ce3iybSANQ4O+/qs4SFNiFGCcXrD+3aLba71N/C7nQH0+YPJllRUl9KPle8S8J8yiXFM= 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=1769256076; 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=q/ASY1Etp9IXhLYDc9pjizpkuHyRR0lGX8YLQb99GLU=; b=RS/dpmwe8GfuFCFuAgpBqm4xEciZszKvdqBxfFXKrtpfGgLk43AsbHOzHAKS3VG9 nABKL1+bN5mLh4SDYHdYbimPH5SXNW3vHK3NZtF4SOqLOi8dIa/G7RGlVz6uCyMyiBE U3i77DeYJQJJru9sKpLs56dC7GXfenHqOKEbFa8g= Received: by mx.zohomail.com with SMTPS id 1769256075449580.2925259520472; Sat, 24 Jan 2026 04:01:15 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:47 +0100 Subject: [PATCH v6 01/24] 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: <20260124-mt8196-ufs-v6-1-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 , Conor Dooley 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. Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Peter Wang Acked-by: Conor Dooley Acked-by: Vinod Koul Signed-off-by: Nicolas Frattaroli --- .../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 6e2edd43fc2a..ee71dfa4e0c0 100644 --- a/Documentation/devicetree/bindings/phy/mediatek,ufs-phy.yaml +++ b/Documentation/devicetree/bindings/phy/mediatek,ufs-phy.yaml @@ -27,6 +27,7 @@ properties: - items: - enum: - mediatek,mt8195-ufsphy + - mediatek,mt8196-ufsphy - const: mediatek,mt8183-ufsphy - const: mediatek,mt8183-ufsphy =20 @@ -43,6 +44,10 @@ properties: - const: unipro - const: mp =20 + resets: + items: + - description: Optional UFS M-PHY reset. + "#phy-cells": const: 0 =20 @@ -66,5 +71,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.52.0 From nobody Sat Feb 7 07:24:36 2026 Received: from sender4-pp-g124.zoho.com (sender4-pp-g124.zoho.com [136.143.188.124]) (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 43EE52DD5EF; Sat, 24 Jan 2026 12:02:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.124 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256126; cv=pass; b=YKbMtIHD8WesrFOSM+iNBbOaaoF+FBdxzLakN0/x64AG8Sse13ra9tZgaBwyvPUoNiW2accNrBG880Sa7zC+ot4xCHevCOjUvsxi+hjSWRM8yCjZ16ZSSJnNk2K4KKrelSuSaIK+pvM+W5zm1Kh77c+ZoOFfmB9WxjWdgYd7KE0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256126; c=relaxed/simple; bh=PbDJ2/6zTQ7CzKLtCppkJtHVPmZ7kWiye2El5FFPplw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dG+rc5sYuYh+LMcLr8AyqO74a9GOYKG7k9GnjE0jhgb3wIVSyEJjLPQZdEBNUiStqeXy8rt4qLqaDf+UqOguCR+gTdLdOZ8jtN+sh7G5v6xsmJic1XyuQwJrttoPKl5IlxQxhakWc1DnqPuYfeGrCQRJWsvXzwzVuPHtbSc2AYg= 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=BmXlExA5; arc=pass smtp.client-ip=136.143.188.124 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="BmXlExA5" ARC-Seal: i=1; a=rsa-sha256; t=1769256082; cv=none; d=zohomail.com; s=zohoarc; b=Zt8PCwpO58p/ek902QMnz8Cs8Y0novrJoZNn0aQvGkmghyifzOSVkuXgud1fh/AIShqVJc1Av6AXVVUEEObcyzTrEX3ATqAiI5RkDBXCXtfgjmjZ/RdCqrxNVn5jotnEPjkNgMVeohYBbNnteqijnWnPNDXgdSF6uhQCKVi+eNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256082; 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=B9peLc/i4yVEOAylnWct0p4B5tQsxTInKIXxsduKZSQ=; b=ClcieKG170C+d568HcwJ+7Sd8XYvjKB/ZkOfbKSOk/t4ZFbTkJ6Z3oRdas4eeCYjx+vQ1vtMr9iC+i5W1m3nZ0RY8JHHYLgZWxfqidr/wPUMVbr1IZ//Sg1nam3UCFzPwUgZf7sqEP/f4BrrlrcJmFpfn1OovOwecHDDh+fymZw= 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=1769256082; 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=B9peLc/i4yVEOAylnWct0p4B5tQsxTInKIXxsduKZSQ=; b=BmXlExA5VS+3KAyXzeJIfhWu4V1kLWJrFw1tJpMcOg2xPwHXRH9RLaPqu/7uYGLs 65LRbSPZ1jcwRvFXtd6/wqOCVl0CryiHBsrS7xK4WWzAS+jSxG3iIc+ARj3JeEPIzxY R39YHLge/+uKAmMVoDBsXAo8ppgG/qghp3yPtdvY= Received: by mx.zohomail.com with SMTPS id 1769256082054304.62902807114347; Sat, 24 Jan 2026 04:01:22 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:48 +0100 Subject: [PATCH v6 02/24] dt-bindings: ufs: mediatek,ufs: Complete the binding 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: <20260124-mt8196-ufs-v6-2-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 , Conor Dooley X-Mailer: b4 0.14.3 As it stands, the mediatek,ufs.yaml binding is startlingly incomplete. Its one example, which is the only real "user" of this binding in mainline, uses the deprecated freq-table-hz property. The resets, of which there are three optional ones, are completely absent. The clock description for MT8195 is incomplete, as is the one for MT8192. It's not known if the one clock binding for MT8183 is even correct, but I do not have access to the necessary code and documentation to find this out myself. The power supply situation is not much better; the binding describes one required power supply, but it's the UFS card supply, not any of the supplies feeding the controller silicon. No second example is present in the binding, making verification difficult. Disallow freq-table-hz and move to operating-points-v2. It's fine to break compatibility here, as the binding is currently unused and would be impossible to correctly use in its current state. Add the three resets and the corresponding reset-names property. These resets appear to be optional, i.e. not required for the functioning of the device. Move the list of clock names out of the if condition, and expand it for the confirmed clocks I could find by cross-referencing several clock drivers. For MT8195, increase the minimum number of clocks to include the crypt and rx_symbol ones, as they're internal to the SoC and should always be present, and should therefore not be omitted. MT8192 gets to have at least 3 clocks, as these were the ones I could quickly confirm from a glance at various trees. I can't say this was an exhaustive search though, but it's better than the current situation. Properly document all supplies, with which pin name on the SoCs they supply. Complete the example with them. Also add a MT8195 example to the binding, using supply labels that I am pretty sure would be the right ones for e.g. the Radxa NIO 12L. Reviewed-by: Conor Dooley Acked-by: Vinod Koul Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- .../devicetree/bindings/ufs/mediatek,ufs.yaml | 117 +++++++++++++++++= +--- 1 file changed, 100 insertions(+), 17 deletions(-) diff --git a/Documentation/devicetree/bindings/ufs/mediatek,ufs.yaml b/Docu= mentation/devicetree/bindings/ufs/mediatek,ufs.yaml index 15c347f5e660..e0aef3e5f56b 100644 --- a/Documentation/devicetree/bindings/ufs/mediatek,ufs.yaml +++ b/Documentation/devicetree/bindings/ufs/mediatek,ufs.yaml @@ -19,11 +19,28 @@ properties: =20 clocks: minItems: 1 - maxItems: 8 + maxItems: 13 =20 clock-names: minItems: 1 - maxItems: 8 + items: + - const: ufs + - const: ufs_aes + - const: ufs_tick + - const: unipro_sysclk + - const: unipro_tick + - const: unipro_mp_bclk + - const: ufs_tx_symbol + - const: ufs_mem_sub + - const: crypt_mux + - const: crypt_lp + - const: crypt_perf + - const: ufs_rx_symbol0 + - const: ufs_rx_symbol1 + + operating-points-v2: true + + freq-table-hz: false =20 phys: maxItems: 1 @@ -31,8 +48,36 @@ properties: reg: maxItems: 1 =20 + resets: + items: + - description: reset for the UniPro layer + - description: reset for the cryptography engine + - description: reset for the host controller + + reset-names: + items: + - const: unipro + - const: crypto + - const: hci + + avdd09-supply: + description: Phandle to the 0.9V supply powering the AVDD09_UFS pin + + avdd12-supply: + description: Phandle to the 1.2V supply powering the AVDD12_UFS pin + + avdd12-ckbuf-supply: + description: Phandle to the 1.2V supply powering the AVDD12_CKBUF_UFS = pin + + avdd18-supply: + description: Phandle to the 1.8V supply powering the AVDD18_UFS pin + vcc-supply: true =20 + vccq-supply: true + + vccq2-supply: true + mediatek,ufs-disable-mcq: $ref: /schemas/types.yaml#/definitions/flag description: The mask to disable MCQ (Multi-Circular Queue) for UFS ho= st. @@ -54,29 +99,41 @@ allOf: properties: compatible: contains: - enum: - - mediatek,mt8195-ufshci + const: mediatek,mt8183-ufshci then: properties: clocks: - minItems: 8 + maxItems: 1 clock-names: items: - const: ufs - - const: ufs_aes - - const: ufs_tick - - const: unipro_sysclk - - const: unipro_tick - - const: unipro_mp_bclk - - const: ufs_tx_symbol - - const: ufs_mem_sub - else: + avdd12-ckbuf-supply: false + - if: + properties: + compatible: + contains: + const: mediatek,mt8192-ufshci + then: properties: clocks: - maxItems: 1 + minItems: 3 + maxItems: 3 + clocks-names: + minItems: 3 + maxItems: 3 + avdd09-supply: false + - if: + properties: + compatible: + contains: + const: mediatek,mt8195-ufshci + then: + properties: + clocks: + minItems: 13 clock-names: - items: - - const: ufs + minItems: 13 + avdd09-supply: false =20 examples: - | @@ -95,8 +152,34 @@ examples: =20 clocks =3D <&infracfg_ao CLK_INFRA_UFS>; clock-names =3D "ufs"; - freq-table-hz =3D <0 0>; =20 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>, <&topckgen 60>, <&topckgen 152>, + <&topckgen 125>, <&topckgen 212>, <&topckgen 215>; + 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_rx_symbol0", "ufs_rx_symbol1"; + + operating-points-v2 =3D <&ufs_opp_table>; + + avdd12-supply =3D <&mt6359_vrf12_ldo_reg>; + avdd12-ckbuf-supply =3D <&mt6359_vbbck_ldo_reg>; + avdd18-supply =3D <&mt6359_vio18_ldo_reg>; + vcc-supply =3D <&mt6359_vemc_1_ldo_reg>; + vccq2-supply =3D <&mt6359_vufs_ldo_reg>; + + mediatek,ufs-disable-mcq; + }; --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 645BC2DC763; Sat, 24 Jan 2026 12:02:10 +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=1769256131; cv=pass; b=OC17JbbX13pqqIAGxnS0DXDYNh+a76HqDXUBqwATW15dPdZ7CdA7rEA6sxD8IXxqri0mKbivhBKqZRc2At1rM+jvk4WWzmbPshyLmt96zVpEHc2V/QUMjpoERiAtlnU63J3cTFuh46XWqg8EZ/iLUAW4ybpCcklguo1q/VSh7v8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256131; c=relaxed/simple; bh=Tk0oAS6OhREK6lUdo3KbLA7MC7i6rRFzjAfUWj2AeYk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DOsSsdZD5EwzuWIVBGRgj9jflfd5+ALfym+vl6WFaV30nxLyiOdFGPHjGPqOcfKFR7pu1qJfynJe21apdHJlCj4AsPQuXVY3nh+TJj3cnEC0cOAxEObQs03phkxNRcXjQi/jcAZzpQF6q5AVy2yQ7ZhxSOikQ7nFE1mFREqo1Dk= 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=TpyCgCS+; 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="TpyCgCS+" ARC-Seal: i=1; a=rsa-sha256; t=1769256090; cv=none; d=zohomail.com; s=zohoarc; b=id5lW9V5YFhUHsbFNwXzvjY4/Cnpl6LoWO54l0uo1hKOzc7GCjt3VeL3P0QAo5T7fa/gRt7BABubNRLPsOqaXljvRtrTzO3bpYGftStqgUCCSTC3EPTZpn8fRmXl6zxTpbeK2gaKbG6erAXH+8qNe9XJQgIBdOdLnollrqzWhuo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256090; 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=FX729w6H6Nqv4wBPOyEK7eBO51Uitkvy4i1Pv/OOpY4=; b=CLJPlYMuK+EBiiw/5qcvv/tHorMK7IhD6xID8pTBVWqCS4DML+HhaQRNoVTHl9xIqbE+ihOqv8grbM4GG8fjqss54/orXH4CLEj7299absbGhnXzU3s4aRyFEC35u/ktHRL0Bme9m7HvvbOOAJju02q8pFac/PzXb65BesudHI0= 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=1769256090; 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=FX729w6H6Nqv4wBPOyEK7eBO51Uitkvy4i1Pv/OOpY4=; b=TpyCgCS+399PKYIen3EuUrqU5ApCSqRLIBTANQKzf0zJIreYm5G2ENINfriZj2Vh r0LIxXoKYNvsBZgYAcc6MmYXGqbl4zdEDxe5YJ2P5ILqY94jpRUt+F8/2nxY1IMRlNo PnXzp1rxujYxJgGUgBmVfhM3WZAEP3iwGbGClX0M= Received: by mx.zohomail.com with SMTPS id 176925608864459.57718916928752; Sat, 24 Jan 2026 04:01:28 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:49 +0100 Subject: [PATCH v6 03/24] dt-bindings: ufs: mediatek,ufs: Add mt8196 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: <20260124-mt8196-ufs-v6-3-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 , Conor Dooley X-Mailer: b4 0.14.3 The MediaTek MT8196 SoC's UFS controller uses three additional clocks compared to the MT8195, and a different set of supplies. It is therefore not compatible with the MT8195. While it does have a AVDD09_UFS_1 pin in addition to the AVDD09_UFS pin, it appears that these two pins are commoned together, as the board schematic I have access to uses the same supply for both, and the downstream driver does not distinguish between the two supplies either. Add a compatible for it, and modify the binding correspondingly. Reviewed-by: Conor Dooley Acked-by: Vinod Koul Acked-by: Conor Dooley Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- .../devicetree/bindings/ufs/mediatek,ufs.yaml | 58 ++++++++++++++++++= +++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/ufs/mediatek,ufs.yaml b/Docu= mentation/devicetree/bindings/ufs/mediatek,ufs.yaml index e0aef3e5f56b..a82119ecbfe8 100644 --- a/Documentation/devicetree/bindings/ufs/mediatek,ufs.yaml +++ b/Documentation/devicetree/bindings/ufs/mediatek,ufs.yaml @@ -16,10 +16,11 @@ properties: - mediatek,mt8183-ufshci - mediatek,mt8192-ufshci - mediatek,mt8195-ufshci + - mediatek,mt8196-ufshci =20 clocks: minItems: 1 - maxItems: 13 + maxItems: 16 =20 clock-names: minItems: 1 @@ -37,6 +38,9 @@ properties: - const: crypt_perf - const: ufs_rx_symbol0 - const: ufs_rx_symbol1 + - const: ufs_sel + - const: ufs_sel_min_src + - const: ufs_sel_max_src =20 operating-points-v2: true =20 @@ -131,9 +135,27 @@ allOf: properties: clocks: minItems: 13 + maxItems: 13 clock-names: minItems: 13 + maxItems: 13 avdd09-supply: false + - if: + properties: + compatible: + contains: + const: mediatek,mt8196-ufshci + then: + properties: + clocks: + minItems: 16 + maxItems: 16 + clock-names: + minItems: 16 + maxItems: 16 + avdd18-supply: false + required: + - operating-points-v2 =20 examples: - | @@ -183,3 +205,37 @@ examples: =20 mediatek,ufs-disable-mcq; }; + - | + #include + #include + + ufshci@16810000 { + compatible =3D "mediatek,mt8196-ufshci"; + reg =3D <0x16810000 0x2a00>; + interrupts =3D ; + + clocks =3D <&ufs_ao_clk 6>, <&ufs_ao_clk 7>, <&clk26m>, <&ufs_ao_c= lk 3>, + <&clk26m>, <&ufs_ao_clk 4>, <&ufs_ao_clk 0>, + <&topckgen 7>, <&topckgen 41>, <&topckgen 105>, <&topckge= n 83>, + <&ufs_ao_clk 1>, <&ufs_ao_clk 2>, <&topckgen 42>, + <&topckgen 84>, <&topckgen 102>; + 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_rx_symbol0", "ufs_rx_symbol1", "ufs_sel", + "ufs_sel_min_src", "ufs_sel_max_src"; + + operating-points-v2 =3D <&ufs_opp_table>; + + phys =3D <&ufsphy>; + + avdd09-supply =3D <&mt6363_vsram_modem>; + vcc-supply =3D <&mt6363_vemc>; + vccq-supply =3D <&mt6363_vufs12>; + + 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", "crypto", "hci"; + mediatek,ufs-disable-mcq; + }; --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 825502F0C74; Sat, 24 Jan 2026 12:02:14 +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=1769256135; cv=pass; b=Ly+WGRWbn/ofhJFytXNu326vls5MERhQMC0lJprOHH95Q1W61ZlL3tiIvtP3j9zM6Z0sw2vfKcT4thF7ml6gtmxXKHTGKKFUv8qMlCVSNIQoXfKBLiS3PTh4tJenwa0gVj3KTXmQ/ZoxHd1psrwx0iRDKuf0+n6j2Xfx4ZmnS9Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256135; c=relaxed/simple; bh=OlZRisuq3ySMcEiykY74dOjKsIwvwBmncFo6AZmCPWo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KFxlS7s6s2x5vFCqXbRMG6Vvpk8BMvQ5olnnokOXriYhUZ8iCA/FzcfoJmwJaNxfRYU8H8An/JhxzQPxex9H8hD3Owx14eHYMTvvQ1/Y2Q2SUP5HZR5icFKZVumy66VHau1hLBj5WgKVTwJdlN552XeczZz6MSqDkap4707FRQs= 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=X6vd/hWg; 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="X6vd/hWg" ARC-Seal: i=1; a=rsa-sha256; t=1769256097; cv=none; d=zohomail.com; s=zohoarc; b=BLtov9Ru31AGToDVuDgmOqzObWEXyqmyCKqI9ASmyZqBoH5NTynKLiOySjR7Vxj1HZ0/joWs8Y2G1UFmYIzjghMlBY6MW7RN7shdYZRU7rBTUEGZTsjkL5CkvtX7S5hzyT8k4ux7s1lG0Ab0QGp3bkMK7FSNhU1DiTraEL7voOw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256097; 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=T8hnWoQrHUVWSELR0fhnAMNIimt4R4siWMW93SJdlZg=; b=bdQCzGvNZfIR5s9rxtZxlyJgpmhDqkypKiIhY7rYzySYuVFEZMmB5mHunqx5/+ZlsHvaFwAcWYZYfl7thT7JgDU4ge/PHFszSJl7xB7QeuD5KTI4TUMH8KvCnWsY9O/5f6dk0UtRs687z/GUoQOeEyoHaHQaAROWagfRbVwYKtI= 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=1769256096; 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=T8hnWoQrHUVWSELR0fhnAMNIimt4R4siWMW93SJdlZg=; b=X6vd/hWgRhT50laaXZAyXl1RgVA8SwJpUeLpnToWrNn2WstRw9kDa9BFVuj2lecg gtX6u+m6FX8jPlJZ9YelNwFeAnXKaOMxEHurgNLLg3a0uugwJzxEqxofXMzh5oKgvOA d1To7rt2IgfgCGohmO7noQbIcSBZ9237qmo41aak= Received: by mx.zohomail.com with SMTPS id 17692560951991008.3318130275699; Sat, 24 Jan 2026 04:01:35 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:50 +0100 Subject: [PATCH v6 04/24] 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: <20260124-mt8196-ufs-v6-4-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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. Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Peter Wang 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..7265ff2a6e2a 100644 --- a/include/linux/soc/mediatek/mtk_sip_svc.h +++ b/include/linux/soc/mediatek/mtk_sip_svc.h @@ -22,6 +22,9 @@ ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, MTK_SIP_SMC_CONVENTION, \ ARM_SMCCC_OWNER_SIP, fn_id) =20 +/* UFS related SMC call */ +#define MTK_SIP_UFS_CONTROL MTK_SIP_SMC_CMD(0x276) + /* DVFSRC SMC calls */ #define MTK_SIP_DVFSRC_VCOREFS_CONTROL MTK_SIP_SMC_CMD(0x506) =20 --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 E864B2DBF4B; Sat, 24 Jan 2026 12:02:09 +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=1769256131; cv=pass; b=gnCPlHGdCngg5qbnBkyigHlS2Skt479IK4y3kcRGc6SRwFrFpVgO2T/iisSUl/VCwHQef/+CaloynttXyIhcfTP1BwmXf21YZ7/jT6BV6/xNFCCTvh0hrH5EVcu6VFTOzng1HZaAE4h3qzVBGIe9I6uFUEv0I52Ju6kRhZTonY0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256131; c=relaxed/simple; bh=aKBv9dRlPqJEyB5f1AzJP5S1FvnsXLvudKhWsJblC2A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MiOL17b5TWacLN/LWHmOeHIWsn4vzU4Tr5+9EONbf+oUK9AyW9hRe3GS5jfjsrXN1ymSnEq6fkGs1w+iGM0M6nq1rNwM7l/F8Yfj1/0CSm/8Ym7224Pe1eU1Cgj55l1tPKdyB/4HXRtMa5+V/ooyvufenoNsyt4RihLnxaWDN2w= 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=hfl8zwFa; 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="hfl8zwFa" ARC-Seal: i=1; a=rsa-sha256; t=1769256102; cv=none; d=zohomail.com; s=zohoarc; b=NEP7rzGr9m6NvVSlNiNCzliDpUdCyxrwwO+wloILzHJbH+w9jACFimoGHuJFa6yA4ZoAq7RPh2QHWiOH8tLRnsECiHlIQUp39vfp5N2e0ElOIcAYBvo0KozDFdN3M4qtHK/LcF0bpSidOIL11xGk5mSWWPSjCuOwMSRdJdYzEVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256102; 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=k6vK7KNn0dooA0o4T40v3iTaTQUjchuIY4rvSJnYECk=; b=H5tjR7ptwsFDe6nKVuqm0AMfoyBffmlQ32BuHQVGRftQ8jLpvgLHS8EyCmsKmxykHZ55QajNfb+bfi5tPoknk6bHAG3+pjyjzWG4E9IyhYXNngiXj8+gITuQBP5D90nRNvRsrm4JSvHc9F+QVqFCs4xPddkGqmYGFhWCzYnsuIE= 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=1769256102; 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=k6vK7KNn0dooA0o4T40v3iTaTQUjchuIY4rvSJnYECk=; b=hfl8zwFayPE8rZ6IPezQ8cRmM0psH0jdAKJixnK+evu48Eh3muIsr2vOK97xWSVK HpFS6meANEgacu8labyOYPEktmSJP6Qt2MW7ci20UGAX0RPPKVPVx3muguJPLd1yvl/ AGDNhkzxJFK5NIIEoaSlGLbdkGvdC51g/LRquBIo= Received: by mx.zohomail.com with SMTPS id 1769256101593739.5738922352265; Sat, 24 Jan 2026 04:01:41 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:51 +0100 Subject: [PATCH v6 05/24] 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: <20260124-mt8196-ufs-v6-5-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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. Reviewed-by: Philipp Zabel Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Peter Wang Acked-by: Vinod Koul 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..48f8e4dbf928 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_exclusive(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.52.0 From nobody Sat Feb 7 07:24:36 2026 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 9BA162F25F3; Sat, 24 Jan 2026 12:02:16 +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=1769256138; cv=pass; b=QXXxLhvq/BaU/QOoi7np7qdUodwk8pHdZVjP8PYSn2aBdxASMLiKSWrDoNNf8BSsvVFbBz9NvplcjRZ+5gN8or9zQr4LKB3seAeI4fjdomk8KV4BuetqYOOGds3d/aTXNu2eSK0a5GxW5byI71MI3ZB3fZlV4J+pe1JPuHgg3fA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256138; c=relaxed/simple; bh=p7+Vi5iubKANhoOBt1NFsjMGZNLHOq9sA+9jnQexWmQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uzxkFwIYmmhAfToM0RHsZ41uXDbynepR4Eb3lxG9asSwYqKYVQnSkb/2aSBL4dNbk96KZYWZFR/bl4Vi/5mTZ4QwGGpyKdUgEiSibxODSqfHEigh8vJoGdaeP66yhQ5kCHW6vkf9ZJSWagMRDl0VDlmHPQ/LVodvvnxKDjl8LxY= 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=UFMjw+js; 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="UFMjw+js" ARC-Seal: i=1; a=rsa-sha256; t=1769256108; cv=none; d=zohomail.com; s=zohoarc; b=n9qAQJy5CDZdAXZ7Q4515UoT2y4sr52DtZ8FhSO/ZqJz1LMWMWrd6yFDhDDDq8h4EnqFnMtAiQ2L3rV/vbIn9OW1wSrF+JnpRfoUxrfLJ57iTAwsbDVqhAe52MXzTR0wQ1AkKD2qtHWcvr3Dqq4i8wfMvxLEIhe4g/fE72p53T8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256108; 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=p+pqVDFI4rAhqmLsEOA0+6bKRGO8Bu8OpZ3aN+j2yxw=; b=fzooNt5rxrg3WRz0tEnBTzYj4a54F23VIyfqDMQPEDqWIrU7wkDpuexs9Uh/Mv99UpmqYNFmZXdhgV3pr2Ur3FswWz1Oqh7Mknt5Bz+zG27q5bbgoi5pU342uPJYYOYzqH/nhIBYClp3mfXGS1Y+jZ0o9DAmRTNPn5lBymEmPjI= 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=1769256108; 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=p+pqVDFI4rAhqmLsEOA0+6bKRGO8Bu8OpZ3aN+j2yxw=; b=UFMjw+jsRbirwnJNfw5D7huM+HZpyIcF5HnfrUqQaBB1RTXYluEJbEOS01aLziBn Ym4jrr7B6uMwlRQgndCPT/PgvousUydQPvX4/wpVhz4ho0wjWyuW+mrlELGMlHz+Uy2 cBRMaoFv3XlnCLTYrJBtULfW9wsG76IuLHDHltxY= Received: by mx.zohomail.com with SMTPS id 17692561081031003.5184678776308; Sat, 24 Jan 2026 04:01:48 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:52 +0100 Subject: [PATCH v6 06/24] 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: <20260124-mt8196-ufs-v6-6-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 bulk reset APIs. Use the optional variant instead of defaulting to NULL if the resets fail, so that absent resets can be distinguished from erroneous resets. Also remove all remnants of the MPHY reset ever having lived in this driver. Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Peter Wang Reviewed-by: Philipp Zabel Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek-sip.h | 8 ---- drivers/ufs/host/ufs-mediatek.c | 78 ++++++++++++++++++---------------= ---- drivers/ufs/host/ufs-mediatek.h | 7 ++-- 3 files changed, 42 insertions(+), 51 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 66b11cc0703b..5cf5f4c94b8f 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -93,6 +93,12 @@ static const char *const ufs_uic_dl_err_str[] =3D { "PA_INIT" }; =20 +static const char *const ufs_reset_names[] =3D { + "unipro", + "crypto", + "hci", +}; + static bool ufs_mtk_is_boost_crypt_enabled(struct ufs_hba *hba) { struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); @@ -203,49 +209,45 @@ 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; - - reset_control_assert(host->hci_reset); - reset_control_assert(host->crypto_reset); - reset_control_assert(host->unipro_reset); - reset_control_assert(host->mphy_reset); - - usleep_range(100, 110); + int 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); + ret =3D reset_control_bulk_assert(MTK_UFS_NUM_RESETS, host->resets); + if (ret) + dev_warn(hba->dev, "Host reset assert failed: %pe\n", ERR_PTR(ret)); =20 - /* restore mphy setting aftre mphy reset */ - if (host->mphy_reset) - ufs_mtk_mphy_ctrl(UFS_MPHY_RESTORE, res); -} + ret =3D phy_reset(host->mphy); =20 -static void ufs_mtk_init_reset_control(struct ufs_hba *hba, - struct reset_control **rc, - char *str) -{ - *rc =3D devm_reset_control_get(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; + /* + * 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)); } + + ret =3D reset_control_bulk_deassert(MTK_UFS_NUM_RESETS, host->resets); + if (ret) + dev_warn(hba->dev, "Host reset deassert failed: %pe\n", ERR_PTR(ret)); } =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, i; + + for (i =3D 0; i < MTK_UFS_NUM_RESETS; i++) + host->resets[i].id =3D ufs_reset_names[i]; =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"); + ret =3D devm_reset_control_bulk_get_optional_exclusive(hba->dev, MTK_UFS_= NUM_RESETS, + host->resets); + if (ret) { + dev_err(hba->dev, "Failed to get resets: %pe\n", ERR_PTR(ret)); + return ret; + } + + return 0; } =20 static int ufs_mtk_hce_enable_notify(struct ufs_hba *hba, @@ -1247,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 9747277f11e8..4fce29d131d1 100644 --- a/drivers/ufs/host/ufs-mediatek.h +++ b/drivers/ufs/host/ufs-mediatek.h @@ -7,12 +7,14 @@ #define _UFS_MEDIATEK_H =20 #include +#include =20 /* * MCQ define and struct */ #define UFSHCD_MAX_Q_NR 8 #define MTK_MCQ_INVALID_IRQ 0xFFFF +#define MTK_UFS_NUM_RESETS 3 =20 /* REG_UFS_MMIO_OPT_CTRL_0 160h */ #define EHS_EN BIT(0) @@ -175,10 +177,7 @@ struct ufs_mtk_mcq_intr_info { struct ufs_mtk_host { struct phy *mphy; struct regulator *reg_va09; - struct reset_control *hci_reset; - struct reset_control *unipro_reset; - struct reset_control *crypto_reset; - struct reset_control *mphy_reset; + struct reset_control_bulk_data resets[MTK_UFS_NUM_RESETS]; struct ufs_hba *hba; struct ufs_mtk_crypt_cfg *crypt; struct ufs_mtk_clk mclk; --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 1DEB22E5418; Sat, 24 Jan 2026 12:02:22 +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=1769256144; cv=pass; b=GObwo77OHpfhoQjTnvPaIKYAhTTvgqZQZY89qJ8ls8gYj/jDkQkiE3Iq913TjDknOc/bRGVJgKP8mBV4QCtqq3USX2sBK7gKNMpdfG94rAs6kAgGuTyr+CLRypAnh+t+0FqVO0wg9lrIvHPAZ3gdDiU5pXZ/hsRQ4EP22KAYEX0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256144; c=relaxed/simple; bh=/Z/DE6ZocI0XfXPVllp5nVbpyPqQzUJMrQT8bH8A+U8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Zla1Iomv3v4XkYYEmRHQXtcCN5fH1jKjeHR7RQp1DpulMcdhovO7uPubwTUFKtYb3xZ/D1/EsY7A2gFQfa6OAdkD1ylQ/nS55zv0MZsPvB2LopsDOiMZCUitAXA+yPsNRiUykcdvzhWgsA96sGmZqCxv+GsGPKDyMIxyoRoHuxk= 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=PaLBEFlJ; 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="PaLBEFlJ" ARC-Seal: i=1; a=rsa-sha256; t=1769256117; cv=none; d=zohomail.com; s=zohoarc; b=jMCvXFkSrNIDzVIQlam3/MNoVaeG2J89k+lLga8DcrOwngDc7ypJEy9r6RW7FXQamk84Q8UCqZwlmhQWeuCvn4dtrkMz0dqgjbOKDuVANvWnoRpz2JnB7aFaltpHIbZAMIRN9lXxcpFWMja3ZeZSz3D+tcOws30vuMJXq8r4uCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256117; 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=mTFzbSzc3bOGqqfS2NiRWM2+n01ZbPaNCoS8FITbGLg=; b=LPOKssy20hava3s0l6BWsM8gwGcjOwnLhd7n8VEpX8fTq/BN4pKGWhPmTrIkNdxfZPUmxdSe9Sb0LwF/nls4QjDkQeKM+sUQyZjDbibom5RgmkYrdgU/G0oR84Q822fZoFIl+wAWFvTx1LJpoTjzGlNbx7gRtMdmTNcG65BwOO0= 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=1769256116; 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=mTFzbSzc3bOGqqfS2NiRWM2+n01ZbPaNCoS8FITbGLg=; b=PaLBEFlJlZg8rMfUrBtQF7PxaA9oQYebfk0tN2kTNQjsskj9ERh4SoltDhDGIxZ0 kMdrt1dTBlF450D5lHnj82lZxZcachJMIVWvZSwLIknRK8jIsjAezpFsoJ8Y9WpOISA qQlljZ//G3EAy2hLZ0FSymPphRbg26C3sc+MzQNA= Received: by mx.zohomail.com with SMTPS id 1769256114626347.97515531123327; Sat, 24 Jan 2026 04:01:54 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:53 +0100 Subject: [PATCH v6 07/24] scsi: ufs: mediatek: Rework 0.9V regulator 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: <20260124-mt8196-ufs-v6-7-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 host driver does some pretty bad stuff with regards to the 0.9V regulator. Instead of just checking for the presence of the regulator, it adds a cap if it's there, and then checks for the cap. It also sleeps to stabilise the supply after enabling the regulator, which is something that should be done by the regulator framework with the appropriate delay properties in the DTS instead of random sleeps in the driver code. Rework this code and rename it to the avdd09 name I've chosen in the binding for this supply name, instead of the downstream "va09" name that isn't used by the datasheets for any of these chips. Reviewed-by: Peter Wang Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 153 ++++++++++++++++++++++++++----------= ---- drivers/ufs/host/ufs-mediatek.h | 3 +- 2 files changed, 101 insertions(+), 55 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index 5cf5f4c94b8f..7fcf4ceeb56e 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -38,6 +38,10 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, bool= scale_up); #define MAX_SUPP_MAC 64 #define MCQ_QUEUE_OFFSET(c) ((((c) >> 16) & 0xFF) * 0x200) =20 +struct ufs_mtk_soc_data { + bool has_avdd09; +}; + static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] =3D { { .wmanufacturerid =3D UFS_ANY_VENDOR, .model =3D UFS_ANY_MODEL, @@ -48,13 +52,6 @@ static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = =3D { {} }; =20 -static const struct of_device_id ufs_mtk_of_match[] =3D { - { .compatible =3D "mediatek,mt8183-ufshci" }, - { .compatible =3D "mediatek,mt8195-ufshci" }, - {}, -}; -MODULE_DEVICE_TABLE(of, ufs_mtk_of_match); - /* * Details of UIC Errors */ @@ -106,13 +103,6 @@ static bool ufs_mtk_is_boost_crypt_enabled(struct ufs_= hba *hba) return host->caps & UFS_MTK_CAP_BOOST_CRYPT_ENGINE; } =20 -static bool ufs_mtk_is_va09_supported(struct ufs_hba *hba) -{ - struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); - - return host->caps & UFS_MTK_CAP_VA09_PWR_CTRL; -} - static bool ufs_mtk_is_broken_vcc(struct ufs_hba *hba) { struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); @@ -506,44 +496,70 @@ static int ufs_mtk_wait_link_state(struct ufs_hba *hb= a, u32 state, return -ETIMEDOUT; } =20 +static int ufs_mtk_09v_off(struct ufs_mtk_host *host) +{ + struct arm_smccc_res res; + int ret; + + if (!host->reg_avdd09) + return 0; + + ufs_mtk_va09_pwr_ctrl(res, 0); + ret =3D regulator_disable(host->reg_avdd09); + if (ret) { + dev_err(host->hba->dev, "Failed to disable avdd09-supply: %pe\n", + ERR_PTR(ret)); + ufs_mtk_va09_pwr_ctrl(res, 1); + return ret; + } + + return 0; +} + +static int ufs_mtk_09v_on(struct ufs_mtk_host *host) +{ + struct arm_smccc_res res; + int ret; + + if (!host->reg_avdd09) + return 0; + + ret =3D regulator_enable(host->reg_avdd09); + if (ret) { + dev_err(host->hba->dev, "Failed to enable avdd09-supply: %pe\n", + ERR_PTR(ret)); + return ret; + } + + ufs_mtk_va09_pwr_ctrl(res, 1); + + return 0; +} + static int ufs_mtk_mphy_power_on(struct ufs_hba *hba, bool on) { struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); struct phy *mphy =3D host->mphy; - struct arm_smccc_res res; - int ret =3D 0; + int ret; =20 - if (!mphy || !(on ^ host->mphy_powered_on)) + if (!mphy || on =3D=3D host->mphy_powered_on) return 0; =20 if (on) { - if (ufs_mtk_is_va09_supported(hba)) { - ret =3D regulator_enable(host->reg_va09); - if (ret < 0) - goto out; - /* wait 200 us to stablize VA09 */ - usleep_range(200, 210); - ufs_mtk_va09_pwr_ctrl(res, 1); - } + ret =3D ufs_mtk_09v_on(host); + if (ret) + return ret; phy_power_on(mphy); } else { phy_power_off(mphy); - if (ufs_mtk_is_va09_supported(hba)) { - ufs_mtk_va09_pwr_ctrl(res, 0); - ret =3D regulator_disable(host->reg_va09); - } - } -out: - if (ret) { - dev_info(hba->dev, - "failed to %s va09: %d\n", - on ? "enable" : "disable", - ret); - } else { - host->mphy_powered_on =3D on; + ret =3D ufs_mtk_09v_off(host); + if (ret) + return ret; } =20 - return ret; + host->mphy_powered_on =3D on; + + return 0; } =20 static int ufs_mtk_get_host_clk(struct device *dev, const char *name, @@ -678,17 +694,6 @@ static void ufs_mtk_init_boost_crypt(struct ufs_hba *h= ba) return; } =20 -static void ufs_mtk_init_va09_pwr_ctrl(struct ufs_hba *hba) -{ - struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); - - host->reg_va09 =3D regulator_get(hba->dev, "va09"); - if (IS_ERR(host->reg_va09)) - dev_info(hba->dev, "failed to get va09"); - else - host->caps |=3D UFS_MTK_CAP_VA09_PWR_CTRL; -} - static void ufs_mtk_init_host_caps(struct ufs_hba *hba) { struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); @@ -697,9 +702,6 @@ static void ufs_mtk_init_host_caps(struct ufs_hba *hba) if (of_property_read_bool(np, "mediatek,ufs-boost-crypt")) ufs_mtk_init_boost_crypt(hba); =20 - if (of_property_read_bool(np, "mediatek,ufs-support-va09")) - ufs_mtk_init_va09_pwr_ctrl(hba); - if (of_property_read_bool(np, "mediatek,ufs-disable-ah8")) host->caps |=3D UFS_MTK_CAP_DISABLE_AH8; =20 @@ -1205,6 +1207,35 @@ static void ufs_mtk_init_mcq_irq(struct ufs_hba *hba) host->mcq_nr_intr =3D 0; } =20 +/** + * ufs_mtk_get_supplies - acquire variant-specific supplies + * @host: pointer to driver's private &struct ufs_mtk_host instance + * + * Returns 0 on success, negative errno on error. + */ +static int ufs_mtk_get_supplies(struct ufs_mtk_host *host) +{ + struct device *dev =3D host->hba->dev; + const struct ufs_mtk_soc_data *data =3D of_device_get_match_data(dev); + + if (!data || !data->has_avdd09) + return 0; + + host->reg_avdd09 =3D devm_regulator_get_optional(dev, "avdd09"); + if (IS_ERR(host->reg_avdd09)) { + if (PTR_ERR(host->reg_avdd09) =3D=3D -ENODEV) { + host->reg_avdd09 =3D NULL; + return 0; + } + + dev_err(dev, "Failed to get avdd09 regulator: %pe\n", + host->reg_avdd09); + return PTR_ERR(host->reg_avdd09); + } + + return 0; +} + /** * ufs_mtk_init - find other essential mmio bases * @hba: host controller instance @@ -1288,6 +1319,10 @@ static int ufs_mtk_init(struct ufs_hba *hba) =20 ufs_mtk_init_clocks(hba); =20 + err =3D ufs_mtk_get_supplies(host); + if (err) + goto out_variant_clear; + /* * ufshcd_vops_init() is invoked after * ufshcd_setup_clock(true) in ufshcd_hba_init() thus @@ -2336,6 +2371,18 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_= vops =3D { .config_scsi_dev =3D ufs_mtk_config_scsi_dev, }; =20 +static const struct ufs_mtk_soc_data mt8183_data =3D { + .has_avdd09 =3D true, +}; + +static const struct of_device_id ufs_mtk_of_match[] =3D { + { .compatible =3D "mediatek,mt8183-ufshci", .data =3D &mt8183_data }, + { .compatible =3D "mediatek,mt8192-ufshci" }, + { .compatible =3D "mediatek,mt8195-ufshci" }, + {}, +}; +MODULE_DEVICE_TABLE(of, ufs_mtk_of_match); + /** * ufs_mtk_probe - probe routine of the driver * @pdev: pointer to Platform device handle diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediate= k.h index 4fce29d131d1..24c8941f6b86 100644 --- a/drivers/ufs/host/ufs-mediatek.h +++ b/drivers/ufs/host/ufs-mediatek.h @@ -125,7 +125,6 @@ enum { */ enum ufs_mtk_host_caps { UFS_MTK_CAP_BOOST_CRYPT_ENGINE =3D 1 << 0, - UFS_MTK_CAP_VA09_PWR_CTRL =3D 1 << 1, UFS_MTK_CAP_DISABLE_AH8 =3D 1 << 2, UFS_MTK_CAP_BROKEN_VCC =3D 1 << 3, =20 @@ -176,7 +175,7 @@ struct ufs_mtk_mcq_intr_info { =20 struct ufs_mtk_host { struct phy *mphy; - struct regulator *reg_va09; + struct regulator *reg_avdd09; struct reset_control_bulk_data resets[MTK_UFS_NUM_RESETS]; struct ufs_hba *hba; struct ufs_mtk_crypt_cfg *crypt; --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 Received: from sender4-pp-e108.zoho.com (sender4-pp-e108.zoho.com [136.143.188.108]) (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 8F43D2DE71B; Sat, 24 Jan 2026 12:02:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.108 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256154; cv=pass; b=DV1JwPwJUU35Ts5HvUGQAW0A5zaC0XXUyFxuCPvofViSF54JYv+LdcARHqWYfJdzEAoxZA1Qhhp/2ktXiezyoL+OXSIyOFBUt0vJeX2WO5r3DMPF9KsDiGsetX6jVlRdHVHPKM0T/JI8Myr/kicL+/JAU7zl6RpYDS1kzWbkfoo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256154; c=relaxed/simple; bh=VlDuvSAFYsYwBqBjSsyHGEnx0MllC37fVNB4u5/biYg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=D1cFw6PUxDDOCA4Xc08eNMQggiva4ItIAdPppAzREGH1TmSmpY0NYfY+irFBVxLmMlW+yQluGKrlaHmh28NdSmqIBqmDSYxJIiLCsuu+yI05SOWVz7sI1Wl86QCrcOvTyCuUgUPwr4W+O5vXMk5P2Qv1MBRXLa5cYaNc1unOVIg= 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=McNDXnTt; arc=pass smtp.client-ip=136.143.188.108 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="McNDXnTt" ARC-Seal: i=1; a=rsa-sha256; t=1769256122; cv=none; d=zohomail.com; s=zohoarc; b=eq+OkvkNsJV3BSoVPlC09XzubgO7Ou8LLoPCoud52tbUIc97OoawMmNj+hhtPnEKGI9s9aJtdzkyFwKcUl8mszAaa5mwSKj6q+RTXmTJ7Kb+qd70ot+m6NO2hINKpbmL8BSV/z+N/lbk2LxPuj8HCnHiY+VEq3sZ3iaPoHc5C2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256122; 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=Oa+opGGt7s/tPHlnUkQmx0naTPhUgBCi4cq0ey1VFNM=; b=hQHi+28fcHBRqZH0FrXn5JicZUgEmFfu9TJD50NXrn9ilVTQESKPmiizjPeyqjBYRKg2BpqGnaqFKQNWN6+K9hXASu+reyIBdGt25wu8oDzFpIkogYWPz/FIhWcZ03mx4nBsc+t9Or0jCmme+wZwaqAA3t59mVvD1UyQUI23auQ= 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=1769256122; 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=Oa+opGGt7s/tPHlnUkQmx0naTPhUgBCi4cq0ey1VFNM=; b=McNDXnTt3rLWn4qJ/gu2pxSelchIrAX0GEoDo4+qWPzXj5zKY0/vlnSucERZFRB9 98hnpCnJW58pNAFJlfyjKVAYzU6GMWGh9BFVV7sQSsX7QRnFhDtxCTI4CFf5CPjhY1Y GLLwkSyqfj7LogU599wWxweaNSR/LfVBPN5UbAm8= Received: by mx.zohomail.com with SMTPS id 1769256121173876.3310601277634; Sat, 24 Jan 2026 04:02:01 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:54 +0100 Subject: [PATCH v6 08/24] scsi: ufs: mediatek: Rework init function 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: <20260124-mt8196-ufs-v6-8-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 Printing an error message on ENOMEM is pointless. The print will not work because there is no memory. Adding an of_match_device to the init function is pointless. Why would a different device with a different probe function ever use the same init function? Get rid of it. zero-initialising an error variable just so you can then goto a bare return statement with that error variable to signal success is also pointless, just return directly, there's no unwind being done. Reviewed-by: Peter Wang Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index 7fcf4ceeb56e..4cb1a1b400ac 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1248,29 +1248,19 @@ static int ufs_mtk_get_supplies(struct ufs_mtk_host= *host) */ static int ufs_mtk_init(struct ufs_hba *hba) { - const struct of_device_id *id; struct device *dev =3D hba->dev; struct ufs_mtk_host *host; struct Scsi_Host *shost =3D hba->host; - int err =3D 0; + int err; struct arm_smccc_res res; =20 host =3D devm_kzalloc(dev, sizeof(*host), GFP_KERNEL); - if (!host) { - err =3D -ENOMEM; - dev_info(dev, "%s: no memory for mtk ufs host\n", __func__); - goto out; - } + if (!host) + return -ENOMEM; =20 host->hba =3D hba; ufshcd_set_variant(hba, host); =20 - id =3D of_match_device(ufs_mtk_of_match, dev); - if (!id) { - err =3D -EINVAL; - goto out; - } - /* Initialize host capability */ ufs_mtk_init_host_caps(hba); =20 @@ -1344,11 +1334,10 @@ static int ufs_mtk_init(struct ufs_hba *hba) =20 ufs_mtk_get_hw_ip_version(hba); =20 - goto out; + return 0; =20 out_variant_clear: ufshcd_set_variant(hba, NULL); -out: return err; } =20 --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 Received: from sender4-pp-f119.zoho.com (sender4-pp-f119.zoho.com [136.143.188.119]) (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 34D352E8B74; Sat, 24 Jan 2026 12:02:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.119 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256157; cv=pass; b=W9pWqu6z1aLbkWvLwOOlbPaSzauLsb1twuXm+PXkmj6/l9KJd4XeT6LLb4LRGwNa80Ye7RhmKDYAc+L7WgxwG/ilpXasGaPOm4f4An6U8LHb2GuKkTEmRUAXIMw2aj3Fyx6Hwh0NO8bD4NqZpmh7tPPAOv+6xG/5emsJy05n8tk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256157; c=relaxed/simple; bh=7rqevkmcYA1yLF7/xhPzfzPI81cortTnhV25h5gfo4E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KFNoTB4RzRVbtDuqzGYi7phEc/r2UefpItZfQ7ziN4lnLZ8qr8HR6WuRLs/FvyAuBPT6vkkektOOQkA/kgC4Oi3IMcXjY20YzkxiFzUk5Zgq9eIvBAAYO0UsDvvbxjyrHvb1+jN2BbVLo9yxmZ0hT2Dgb8bPM/2yy+nF0VgDyno= 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=Z+4yT40A; arc=pass smtp.client-ip=136.143.188.119 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="Z+4yT40A" ARC-Seal: i=1; a=rsa-sha256; t=1769256128; cv=none; d=zohomail.com; s=zohoarc; b=fHVk7A9L6UvKsRCiMN3vdc4LkkZAxJOwjMwyKc+WFgD0KMpQSgMTu3UksvOYlB8Ae3c0BsaGEGKW8P42i/zj0oJjUcA1MSZYv/m6JHv3ROD8jQ1Xz8o4GCMFWCoEWj84JiER+ViEg3jdvnyTbprrCu4wuugTYtC16cZ0o+F/cVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256128; 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=3Btq5ze3Dk+XwNnveSGIJE7cooTqyLjb6gxWgmCMTts=; b=YFcDZbSsA6XWvtNYQvNXCxVj4O7fuM5nngZ15rEG35SNifN7ae/VmZ4PZTqD6+raf23CEuXMgIx3c9TEDkrR8+f6A46V6psi32X/9Ya5z234mie6DBtcN7ylOUZBAxoWaeQi7AAhyPecVd8gSIVKKA9x668ocaCADJH/c0SxmUY= 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=1769256128; 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=3Btq5ze3Dk+XwNnveSGIJE7cooTqyLjb6gxWgmCMTts=; b=Z+4yT40AxDggUFGSx/3OHrwne+Ns84Hsk3zwO5gd+66/tDIc2WfE/+Ojwq94Lp8X IB3JbCWsmWtdzqq4vJ/MOBwZTUyKD83nAx0AsPrsi7gCZSO6WAWSARvX8RsKVM+g/gv ddJj09izv5Q2By9/zLoJUff3Lo9j1wHLBEyjUebw= Received: by mx.zohomail.com with SMTPS id 1769256127593665.8798652878884; Sat, 24 Jan 2026 04:02:07 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:55 +0100 Subject: [PATCH v6 09/24] scsi: ufs: mediatek: Rework the crypt-boost stuff 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: <20260124-mt8196-ufs-v6-9-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 I don't know whether the crypt-boost functionality as it is currently implemented is even appropriate for mainline. It might be better done in some generic way. But what I do know is that I can rework the code to make it less obtuse. Prefix the boost stuff with the appropriate vendor prefix, remove the pointless clock wrappers, and rework the function. Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Peter Wang (=E7=8E=8B=E4=BF=A1=E5=8F=8B) Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 89 ++++++++++++++-----------------------= ---- 1 file changed, 30 insertions(+), 59 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index 4cb1a1b400ac..0d8f4e542d47 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -562,21 +562,6 @@ static int ufs_mtk_mphy_power_on(struct ufs_hba *hba, = bool on) return 0; } =20 -static int ufs_mtk_get_host_clk(struct device *dev, const char *name, - struct clk **clk_out) -{ - struct clk *clk; - int err =3D 0; - - clk =3D devm_clk_get(dev, name); - if (IS_ERR(clk)) - err =3D PTR_ERR(clk); - else - *clk_out =3D clk; - - return err; -} - static void ufs_mtk_boost_crypt(struct ufs_hba *hba, bool boost) { struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); @@ -633,65 +618,51 @@ static void ufs_mtk_boost_crypt(struct ufs_hba *hba, = bool boost) clk_disable_unprepare(cfg->clk_crypt_mux); } =20 -static int ufs_mtk_init_host_clk(struct ufs_hba *hba, const char *name, - struct clk **clk) -{ - int ret; - - ret =3D ufs_mtk_get_host_clk(hba->dev, name, clk); - if (ret) { - dev_info(hba->dev, "%s: failed to get %s: %d", __func__, - name, ret); - } - - return ret; -} - static void ufs_mtk_init_boost_crypt(struct ufs_hba *hba) { struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); struct ufs_mtk_crypt_cfg *cfg; struct device *dev =3D hba->dev; - struct regulator *reg; - u32 volt; + int ret; =20 - host->crypt =3D devm_kzalloc(dev, sizeof(*(host->crypt)), - GFP_KERNEL); - if (!host->crypt) - goto disable_caps; + cfg =3D devm_kzalloc(dev, sizeof(*cfg), GFP_KERNEL); + if (!cfg) + return; =20 - reg =3D devm_regulator_get_optional(dev, "dvfsrc-vcore"); - if (IS_ERR(reg)) { - dev_info(dev, "failed to get dvfsrc-vcore: %ld", - PTR_ERR(reg)); - goto disable_caps; + cfg->reg_vcore =3D devm_regulator_get_optional(dev, "dvfsrc-vcore"); + if (IS_ERR(cfg->reg_vcore)) { + dev_err(dev, "Failed to get dvfsrc-vcore: %pe", cfg->reg_vcore); + return; } =20 - if (of_property_read_u32(dev->of_node, "boost-crypt-vcore-min", - &volt)) { - dev_info(dev, "failed to get boost-crypt-vcore-min"); - goto disable_caps; + ret =3D of_property_read_u32(dev->of_node, "mediatek,boost-crypt-vcore-mi= n", + &cfg->vcore_volt); + if (ret) { + dev_err(dev, "Failed to get mediatek,boost-crypt-vcore-min: %pe\n", + ERR_PTR(ret)); + return; } =20 - cfg =3D host->crypt; - if (ufs_mtk_init_host_clk(hba, "crypt_mux", - &cfg->clk_crypt_mux)) - goto disable_caps; + cfg->clk_crypt_mux =3D devm_clk_get(dev, "crypt_mux"); + if (IS_ERR(cfg->clk_crypt_mux)) { + dev_err(dev, "Failed to get clock crypt_mux: %pe\n", cfg->clk_crypt_mux); + return; + } =20 - if (ufs_mtk_init_host_clk(hba, "crypt_lp", - &cfg->clk_crypt_lp)) - goto disable_caps; + cfg->clk_crypt_lp =3D devm_clk_get(dev, "crypt_lp"); + if (IS_ERR(cfg->clk_crypt_lp)) { + dev_err(dev, "Failed to get clock crypt_lp: %pe\n", cfg->clk_crypt_lp); + return; + } =20 - if (ufs_mtk_init_host_clk(hba, "crypt_perf", - &cfg->clk_crypt_perf)) - goto disable_caps; + cfg->clk_crypt_perf =3D devm_clk_get(dev, "crypt_perf"); + if (IS_ERR(cfg->clk_crypt_perf)) { + dev_err(dev, "Failed to get clock crypt_perf: %pe\n", cfg->clk_crypt_per= f); + return; + } =20 - cfg->reg_vcore =3D reg; - cfg->vcore_volt =3D volt; + host->crypt =3D cfg; host->caps |=3D UFS_MTK_CAP_BOOST_CRYPT_ENGINE; - -disable_caps: - return; } =20 static void ufs_mtk_init_host_caps(struct ufs_hba *hba) --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 9155217B43F; Sat, 24 Jan 2026 12:02:54 +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=1769256175; cv=pass; b=M89FCrI7we0uBVpdgUytqT/x8kShCWL6AXt0L6rQiwZFj7vjlAV8sNDUEqbqPBEkYAraEtExOm4R5gLiqV0UNbqpfRV3RW628LrM7KPN3xUASes9yDTvLEEUnN2w+D+wWG9uGV3HG+U2q6sO/sEgpA2dL1FkdNaIXuB644L5iXc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256175; c=relaxed/simple; bh=JxwxF5D1QU5Nd7u0X2s5/Q8hB4vQB03K1hwfEfakVLs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=m5lJebYg5dEHUMSZGlzNigWUUdXWRoMMCZXaS4FyrEwPG8hg8nzDB/xW4U9W9TtcPF+JhSEgLTjcHGVIO870e/+kwg3/CTjAIw2E0JuIeBqnXRWc5vVpTA9fJVyYP76aijcC8dkLtFMx/p827jo60a+Jkls4RX2lduxxrosg0j8= 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=Srkyy5IV; 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="Srkyy5IV" ARC-Seal: i=1; a=rsa-sha256; t=1769256136; cv=none; d=zohomail.com; s=zohoarc; b=m9ushImwDIup/83e+boJLeAXmEG+dvPR/BnR2Aji4gnnHvT7vW1qGbGNWdq9nSm60BV7zHhtT4oDlAWthQqbK2TNIPihMxWw/O1gd1b+3XBbXsnu2zVd3tyyQUGgMgU234rWm1vy5wK6hvAUr1I9znxFlLwPNXDH9EpCBbYFvac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256136; 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=sCiUsaJ5ZHVZt78QviQYZjXJJK23+TL1DLoI2BRnjWs=; b=En7wdVTfJS1yeA1fbA/wqLVCG26wHww8aeL+AgitZeSK4xx6R/bbFmkTcip/24l5o8xhJGHMiVS+7XSrBKvy2sikVOhoaBuU3pTOhRldjuhxgkEz+rgrdYodbWuMtwQxWlE2zk5PZTqXIwJcaFZgkAPBZOLA1n3SKRLn3alX5nI= 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=1769256136; 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=sCiUsaJ5ZHVZt78QviQYZjXJJK23+TL1DLoI2BRnjWs=; b=Srkyy5IVcdsfbTGYj4IXL9/1zJ1W2TeSbgs5D6ELUUUESRiWUusNk6JixqIE/NKB pLku0jK/GmBEnoUg+ENkZKtl+WLY74TKIzItHag6a3XvGiikdDdWrs5OHjkVKkV9Eai 5nJEwSf5PPKEp9DqB2MT6VOjhTD78iLM2B/Yv1RE= Received: by mx.zohomail.com with SMTPS id 176925613403524.45519582606289; Sat, 24 Jan 2026 04:02:14 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:56 +0100 Subject: [PATCH v6 10/24] scsi: ufs: mediatek: Handle misc host voltage regulators 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: <20260124-mt8196-ufs-v6-10-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 MediaTek SoCs handled by this driver contain a per-SoC specific set of miscellaneous supplies. These feed parts of the UFS controller silicon inside the SoC, as opposed to the UFS card. Add the necessary driver code to acquire these supplies using the regulator bulk API. They should be kept on during suspend, so enable them when acquiring. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index 0d8f4e542d47..954d6768aa64 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -40,6 +40,8 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, bool = scale_up); =20 struct ufs_mtk_soc_data { bool has_avdd09; + u8 num_reg_names; + const char *const *reg_names; }; =20 static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] =3D { @@ -1188,8 +1190,21 @@ static int ufs_mtk_get_supplies(struct ufs_mtk_host = *host) { struct device *dev =3D host->hba->dev; const struct ufs_mtk_soc_data *data =3D of_device_get_match_data(dev); + int ret; + + if (!data) + return 0; + + if (data->num_reg_names) { + ret =3D devm_regulator_bulk_get_enable(dev, data->num_reg_names, + data->reg_names); + if (ret) { + dev_err(dev, "Failed to get misc regulators: %pe\n", ERR_PTR(ret)); + return ret; + } + } =20 - if (!data || !data->has_avdd09) + if (!data->has_avdd09) return 0; =20 host->reg_avdd09 =3D devm_regulator_get_optional(dev, "avdd09"); @@ -2331,14 +2346,30 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk= _vops =3D { .config_scsi_dev =3D ufs_mtk_config_scsi_dev, }; =20 +static const char *const ufs_mtk_regs_avdd12_avdd18[] =3D { + "avdd12", "avdd18" +}; + +static const char *const ufs_mtk_regs_avdd12_ckbuf_avdd18[] =3D { + "avdd12", "avdd12-ckbuf", "avdd18" +}; + static const struct ufs_mtk_soc_data mt8183_data =3D { .has_avdd09 =3D true, + .reg_names =3D ufs_mtk_regs_avdd12_avdd18, + .num_reg_names =3D ARRAY_SIZE(ufs_mtk_regs_avdd12_avdd18), +}; + +static const struct ufs_mtk_soc_data mt8192_8195_data =3D { + .has_avdd09 =3D false, + .reg_names =3D ufs_mtk_regs_avdd12_ckbuf_avdd18, + .num_reg_names =3D ARRAY_SIZE(ufs_mtk_regs_avdd12_ckbuf_avdd18), }; =20 static const struct of_device_id ufs_mtk_of_match[] =3D { { .compatible =3D "mediatek,mt8183-ufshci", .data =3D &mt8183_data }, - { .compatible =3D "mediatek,mt8192-ufshci" }, - { .compatible =3D "mediatek,mt8195-ufshci" }, + { .compatible =3D "mediatek,mt8192-ufshci", .data =3D &mt8192_8195_data }, + { .compatible =3D "mediatek,mt8195-ufshci", .data =3D &mt8192_8195_data }, {}, }; MODULE_DEVICE_TABLE(of, ufs_mtk_of_match); --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 239682DEA8C; Sat, 24 Jan 2026 12:02:56 +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=1769256178; cv=pass; b=GO87JaluaMmCwLOHp41RudJQ4R+vlmOZl/0ifMrpq2KC2yFXsLvkCeCP6vZxmwrnnc/cM97ZHERoRECAJLRndnY7JAHLyjUYw7vRJVZbXzDiemaLRTffQCmnzF78q9gfonZ00VevYBp+qIkfA9vXhn/ElvjnFtmtvdtYgg8cOCE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256178; c=relaxed/simple; bh=Li2TtgPQCWGmlIMXsUike50fTShKhzRXfyS8CHvC6iE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cM7Sk06sGm1+qg6W+ojD47S7SDHXIImNzW4WJO00RtTWPeZKABf89cMlj7gyo4fxeZa3qnCtd420o3huwAJ7lCbAC2LAA+orNdU0gijvEPB0SfQQxtoidTX1kBvr4GKwWD23YTQwM5CCo1ArQ+q1C7gMX0iEaNdAlCOXYStEX6A= 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=Xjtgvgbr; 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="Xjtgvgbr" ARC-Seal: i=1; a=rsa-sha256; t=1769256142; cv=none; d=zohomail.com; s=zohoarc; b=A0DNq5Tu5vvecSc20JqO0j71kj0NsR3nB0SWkaRryZXHKYaG6/wxcUazOJG+lORN/JJGB84XjFfDx+lAOtHQyNlRhNVPfIk53oPoic8D1kYuib6CZ98/Gr1DTV9wSUBR0Yyl9b23geTFXqxFGNthCryi7Avq9GoMYoFP7PZIY98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256142; 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=TO3+E3gSmoEer+wUEBmMZcLhWnkiVKWQshWXIMoQP/o=; b=hO8wvBfvJqcN6UVYfowSDyxpznGyLluM63/5xoXVKetay2ODa+bitmoOUusCCaJUBMgNHzUuIQBPKFyLLmOPcq45zxzuIY4ES0eR2SCgQMGXlPPOobB7BD+dxaAObWWwNjdxbQFSpGfedWOR3iMNsHz4U0PAXwPlIQ/q9+N/TPk= 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=1769256142; 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=TO3+E3gSmoEer+wUEBmMZcLhWnkiVKWQshWXIMoQP/o=; b=Xjtgvgbrlo6sE6XbZ4LHciQwi9hs3LsC33/qRNeXwmcBki4ihhbLqpUSOe1IhD3f A0xiwu12sRiGEoQhLPxnHTg3kotLmR9N+aGt/CmnlgnUP5bg0KIQGL2MaMgsZho3JZa KdcwvjIZZQVu53M7/M57VgtMcRh9dZqJz681FfFo= Received: by mx.zohomail.com with SMTPS id 176925614141982.60531836079974; Sat, 24 Jan 2026 04:02:21 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:57 +0100 Subject: [PATCH v6 11/24] scsi: ufs: mediatek: Rework probe function 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: <20260124-mt8196-ufs-v6-11-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 Remove the ti,syscon-reset cruft, as it was never documented in the binding, and is not modelling the hardware correctly. Make PHY mandatory. All the compatibles supported by the binding make it mandatory. Entertain this driver's insistence on playing with the PHY's RPM, but at least fix the part where it doesn't increase the reference count, which would lead to use-after-free. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 87 +++++++++++++++----------------------= ---- 1 file changed, 32 insertions(+), 55 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index 954d6768aa64..fc72bf54ec2a 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -2382,74 +2382,49 @@ MODULE_DEVICE_TABLE(of, ufs_mtk_of_match); */ static int ufs_mtk_probe(struct platform_device *pdev) { - int err; - struct device *dev =3D &pdev->dev, *phy_dev =3D NULL; - struct device_node *reset_node, *phy_node =3D NULL; - struct platform_device *reset_pdev, *phy_pdev =3D NULL; - struct device_link *link; - struct ufs_hba *hba; + struct platform_device *phy_pdev; + struct device *dev =3D &pdev->dev; + struct device_node *phy_node; struct ufs_mtk_host *host; + struct device *phy_dev; + struct ufs_hba *hba; + int err; =20 - reset_node =3D of_find_compatible_node(NULL, NULL, - "ti,syscon-reset"); - if (!reset_node) { - dev_notice(dev, "find ti,syscon-reset fail\n"); - goto skip_reset; - } - reset_pdev =3D of_find_device_by_node(reset_node); - if (!reset_pdev) { - dev_notice(dev, "find reset_pdev fail\n"); - goto skip_reset; - } - link =3D device_link_add(dev, &reset_pdev->dev, - DL_FLAG_AUTOPROBE_CONSUMER); - put_device(&reset_pdev->dev); - if (!link) { - dev_notice(dev, "add reset device_link fail\n"); - goto skip_reset; - } - /* supplier is not probed */ - if (link->status =3D=3D DL_STATE_DORMANT) { - err =3D -EPROBE_DEFER; - goto out; - } - -skip_reset: /* find phy node */ phy_node =3D of_parse_phandle(dev->of_node, "phys", 0); + if (!phy_node) + return dev_err_probe(dev, -ENOENT, "No PHY node found\n"); =20 - if (phy_node) { - phy_pdev =3D of_find_device_by_node(phy_node); - if (!phy_pdev) - goto skip_phy; - phy_dev =3D &phy_pdev->dev; + phy_pdev =3D of_find_device_by_node(phy_node); + of_node_put(phy_node); + if (!phy_pdev) + return dev_err_probe(dev, -ENODEV, "No PHY device found\n"); =20 - pm_runtime_set_active(phy_dev); - pm_runtime_enable(phy_dev); - pm_runtime_get_sync(phy_dev); + phy_dev =3D &phy_pdev->dev; =20 - put_device(phy_dev); - dev_info(dev, "phys node found\n"); - } else { - dev_notice(dev, "phys node not found\n"); + err =3D pm_runtime_set_active(phy_dev); + if (err) { + dev_err_probe(dev, err, "Failed to activate PHY RPM\n"); + goto err_put_phy; + } + pm_runtime_enable(phy_dev); + err =3D pm_runtime_get_sync(phy_dev); + if (err) { + dev_err_probe(dev, err, "Failed to power on PHY\n"); + goto err_put_phy; } =20 -skip_phy: /* perform generic probe */ err =3D ufshcd_pltfrm_init(pdev, &ufs_hba_mtk_vops); if (err) { - dev_err(dev, "probe failed %d\n", err); - goto out; + dev_err_probe(dev, err, "Generic platform probe failed\n"); + goto err_put_phy; } =20 hba =3D platform_get_drvdata(pdev); - if (!hba) - goto out; =20 - if (phy_node && phy_dev) { - host =3D ufshcd_get_variant(hba); - host->phy_dev =3D phy_dev; - } + host =3D ufshcd_get_variant(hba); + host->phy_dev =3D phy_dev; =20 /* * Because the default power setting of VSx (the upper layer of @@ -2458,9 +2433,11 @@ static int ufs_mtk_probe(struct platform_device *pde= v) */ ufs_mtk_dev_vreg_set_lpm(hba, false); =20 -out: - of_node_put(phy_node); - of_node_put(reset_node); + return 0; + +err_put_phy: + put_device(phy_dev); + return err; } =20 --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 B99ED2DBF4B; Sat, 24 Jan 2026 12:03:08 +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=1769256190; cv=pass; b=ujDUlu5QJVEbflm40ZFeuhgGCDsdKv8sogLwjoClIhCWwOILXwp1qILiDkwcq8KY+yN17e08hi3QCCIjIP01xwC+xD/YPRwnJ8KU+QuD8OYOY41Qouby5B466tfCPaYIK1PVLbeoKYYkGU3XIq7Jjgv8XvrPCKavATRebneiDwY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256190; c=relaxed/simple; bh=YBeqx3mTla1Zq0Q5HgdPm2tm7MBoKnDDeSF3FciQ1ko=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Zt3ZkA5DrDL+wESvnqOJu+kKBCwMh1avXzCqDkyilr7kgTbaa8JSqMkVU/c6AVi+gT0awdlxN/Kc40iXoyuhoNKWYiJrLqk7+zb/TgXXHYEktU9n3KpYd2WoIWBi5+ppw8uYDUO1f1u323JFXKdZLnmb6DZ4Wa5qzXSSYpgJqx0= 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=akuPEzDJ; 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="akuPEzDJ" ARC-Seal: i=1; a=rsa-sha256; t=1769256148; cv=none; d=zohomail.com; s=zohoarc; b=FpfNY42imPkXVzeZwR8bAKwqZXllrQ3egOSQ/csPb+TPV162qMsw6BU5z3WAIhHvrx+PMj8x7cP09fn/Vsmfw5smDiYk/zOQO2+3udcGtUFBK6tJ4rWnG7Q3zv0FxxCzqYBBaFkqUockas4nmGqfnQPx7f5z4Fnhpvk8SIaoGc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256148; 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=2jPjjJAlxolJ5SZdAxCSvwzy43UK4mx+Q/TOpQ2kDsI=; b=aH6ykwc29GHMcbnk4AafhF2ZNMK5OCkfxThAPSOSAtN/gjsnCQJJxJC3eH01mQGWazHBtC7PeJbr1dGyaCHJc9ACq6O3oRE1o2dOlB83u7r2on787M2kmtjOv/pAPHuxI96aBVs/ese2RYOu1626iTONNwD/RB3vaCbzxE2+rZE= 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=1769256148; 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=2jPjjJAlxolJ5SZdAxCSvwzy43UK4mx+Q/TOpQ2kDsI=; b=akuPEzDJgbfu1oBEeq/Lz88adBEfrpODaE5p2O1QAfoRLdY0nAluaZf9U61wXJdl wPiZ8rAngUhosaSBBTL/4l8Ryn+PoxYSCCrMzcarDFz3apC0cao49InA2T30IYlqNZS 4rkSNVAQLztWSG8HjKmCDsituf8XF+XvuG74vJsk= Received: by mx.zohomail.com with SMTPS id 1769256148020941.2050961507542; Sat, 24 Jan 2026 04:02:28 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:58 +0100 Subject: [PATCH v6 12/24] scsi: ufs: mediatek: Remove vendor kernel quirks cruft 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: <20260124-mt8196-ufs-v6-12-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 , Krzysztof Kozlowski X-Mailer: b4 0.14.3 Both ufs_mtk_vreg_fix_vcc and ufs_mtk_vreg_fix_vccqx look like they are vendor kernel hacks to work around existing downstream device trees. Mainline does not need or want them, so remove them. Reviewed-by: AngeloGioacchino Del Regno Reviewed-by: Krzysztof Kozlowski Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 69 -------------------------------------= ---- 1 file changed, 69 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index fc72bf54ec2a..45e088f6e92e 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1017,73 +1017,6 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba) } } =20 -#define MAX_VCC_NAME 30 -static int ufs_mtk_vreg_fix_vcc(struct ufs_hba *hba) -{ - struct ufs_vreg_info *info =3D &hba->vreg_info; - struct device_node *np =3D hba->dev->of_node; - struct device *dev =3D hba->dev; - char vcc_name[MAX_VCC_NAME]; - struct arm_smccc_res res; - int err, ver; - - if (info->vcc) - return 0; - - if (of_property_read_bool(np, "mediatek,ufs-vcc-by-num")) { - ufs_mtk_get_vcc_num(res); - if (res.a1 > UFS_VCC_NONE && res.a1 < UFS_VCC_MAX) - snprintf(vcc_name, MAX_VCC_NAME, "vcc-opt%lu", res.a1); - else - return -ENODEV; - } else if (of_property_read_bool(np, "mediatek,ufs-vcc-by-ver")) { - ver =3D (hba->dev_info.wspecversion & 0xF00) >> 8; - snprintf(vcc_name, MAX_VCC_NAME, "vcc-ufs%u", ver); - } else { - return 0; - } - - err =3D ufshcd_populate_vreg(dev, vcc_name, &info->vcc, false); - if (err) - return err; - - err =3D ufshcd_get_vreg(dev, info->vcc); - if (err) - return err; - - err =3D regulator_enable(info->vcc->reg); - if (!err) { - info->vcc->enabled =3D true; - dev_info(dev, "%s: %s enabled\n", __func__, vcc_name); - } - - return err; -} - -static void ufs_mtk_vreg_fix_vccqx(struct ufs_hba *hba) -{ - struct ufs_vreg_info *info =3D &hba->vreg_info; - struct ufs_vreg **vreg_on, **vreg_off; - - if (hba->dev_info.wspecversion >=3D 0x0300) { - vreg_on =3D &info->vccq; - vreg_off =3D &info->vccq2; - } else { - vreg_on =3D &info->vccq2; - vreg_off =3D &info->vccq; - } - - if (*vreg_on) - (*vreg_on)->always_on =3D true; - - if (*vreg_off) { - regulator_disable((*vreg_off)->reg); - devm_kfree(hba->dev, (*vreg_off)->name); - devm_kfree(hba->dev, *vreg_off); - *vreg_off =3D NULL; - } -} - static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba) { unsigned long flags; @@ -1981,8 +1914,6 @@ static void ufs_mtk_fixup_dev_quirks(struct ufs_hba *= hba) hba->dev_quirks &=3D ~UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM; } =20 - ufs_mtk_vreg_fix_vcc(hba); - ufs_mtk_vreg_fix_vccqx(hba); ufs_mtk_fix_ahit(hba); ufs_mtk_fix_clock_scaling(hba); } --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 Received: from sender4-pp-g120.zoho.com (sender4-pp-g120.zoho.com [136.143.188.120]) (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 E040F2DCBF7; Sat, 24 Jan 2026 12:03:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.120 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256197; cv=pass; b=QdspG6IcM9ONEwCwHAnb46E7FR4mM38B7HGd1d0MYxQayDEUQqwWocYmTb2pnS0WPVUc9wY3FGimWsZKIbVQRgqD3ZNW7APhrSYjeiTjxtlpDhWprju3/OJGJIgbVRnaOB3KPOw93GEMwvrY94ikI7GOygpE+xB/XInLAwMkbUw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256197; c=relaxed/simple; bh=VeDzWlgAd5ceQT/aBFbD/UWPIZMAjbDEUzchKXtC9kE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y4/RagFV1Zbx+Z4Dy04PTEdy6r+mdDLitgorIb88cWEk/eP0u5BovD0Exnlcu7VB8NWkPSi8jzgXfJFxKEb2sY2MEuNhJZrbUF9Ym2SudCRus3Dt7fRmn53qneKM506SnyRbLnQVywJ2+ZuyQcyBGjyM5Grks9y5uWPk5zouhkU= 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=b7amaWWw; arc=pass smtp.client-ip=136.143.188.120 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="b7amaWWw" ARC-Seal: i=1; a=rsa-sha256; t=1769256157; cv=none; d=zohomail.com; s=zohoarc; b=Nun1IM9f5uL9PY5USQXHt69KLLDv/+iil6Plv9btKdQ8kDssFC5Q2Ka/6MQLkLVZ7nEjzySUkUa0Lpvs2L7rWrdaGpWlYqN5GF8KEr//f3JXfM6aMhS9xKmpejRdpARn9THnt6ywL+78Mp6ucvNcbtZS4GOxXVPMpnsQnQPHSf4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256157; 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=Zg4JugMOvR47jKqhhvWFECmWkPAevc7heF3j+ru8a6A=; b=iqva3E0f6SXHmCUPNLq/pcwTR1axs5bwbnlC7cE3yv/YdtTR8+LADY1TeGHoCZ0ZpJ4cBH/yPTfppvG5We4WsXIblyftq18HPuCPcFELVmuCZys0x4dXWKtHd0ns2l8jHUkbUTse0YcjD/9FBUes0YytcCYKUc1CdZbApmiq870= 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=1769256157; 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=Zg4JugMOvR47jKqhhvWFECmWkPAevc7heF3j+ru8a6A=; b=b7amaWWwldJd61CkKO8qIlemHohUKgvBhu4UmA3QfeVt2T0o80+rhF3pgdoks3Fs uxw8IKE396Czf3alFZK2vDIuG3lUMAwWhqn0FnqGTS16BPr70g5UOX8RuXu15gS3Xch bbwj+hPYfG13NoCgVlo+QOCxX519uKhBzdIjtjMc= Received: by mx.zohomail.com with SMTPS id 1769256154430532.4185308452687; Sat, 24 Jan 2026 04:02:34 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:00:59 +0100 Subject: [PATCH v6 13/24] scsi: ufs: mediatek: Use the common PHY framework 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: <20260124-mt8196-ufs-v6-13-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 There is no need to reinvent the PHY framework, especially not its OF parsing. Change the code to simply use the PHY framework to acquire the device's PHY in the ufshcd init, so that it's device linked to the right device. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 133 ++++++++++++------------------------= ---- drivers/ufs/host/ufs-mediatek.h | 1 - 2 files changed, 40 insertions(+), 94 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index 45e088f6e92e..3250c27cb91f 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -293,44 +293,6 @@ static int ufs_mtk_hce_enable_notify(struct ufs_hba *h= ba, return 0; } =20 -static int ufs_mtk_bind_mphy(struct ufs_hba *hba) -{ - struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); - struct device *dev =3D hba->dev; - struct device_node *np =3D dev->of_node; - int err =3D 0; - - host->mphy =3D devm_of_phy_get_by_index(dev, np, 0); - - if (host->mphy =3D=3D ERR_PTR(-EPROBE_DEFER)) { - /* - * UFS driver might be probed before the phy driver does. - * In that case we would like to return EPROBE_DEFER code. - */ - err =3D -EPROBE_DEFER; - dev_info(dev, - "%s: required phy hasn't probed yet. err =3D %d\n", - __func__, err); - } else if (IS_ERR(host->mphy)) { - err =3D PTR_ERR(host->mphy); - if (err !=3D -ENODEV) { - dev_info(dev, "%s: PHY get failed %d\n", __func__, - err); - } - } - - if (err) - host->mphy =3D NULL; - /* - * Allow unbound mphy because not every platform needs specific - * mphy control. - */ - if (err =3D=3D -ENODEV) - err =3D 0; - - return err; -} - static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on) { struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); @@ -1185,13 +1147,21 @@ static int ufs_mtk_init(struct ufs_hba *hba) =20 ufs_mtk_init_mcq_irq(hba); =20 - err =3D ufs_mtk_bind_mphy(hba); - if (err) + host->mphy =3D devm_phy_get(dev, NULL); + if (IS_ERR(host->mphy)) { + err =3D dev_err_probe(dev, PTR_ERR(host->mphy), "Failed to get PHY\n"); + goto out_variant_clear; + } + + err =3D phy_init(host->mphy); + if (err) { + dev_err_probe(dev, err, "Failed to initialize PHY\n"); goto out_variant_clear; + } =20 err =3D ufs_mtk_init_reset(hba); if (err) - goto out_variant_clear; + goto out_phy_exit; =20 /* Enable runtime autosuspend */ hba->caps |=3D UFSHCD_CAP_RPM_AUTOSUSPEND; @@ -1230,7 +1200,7 @@ static int ufs_mtk_init(struct ufs_hba *hba) =20 err =3D ufs_mtk_get_supplies(host); if (err) - goto out_variant_clear; + goto out_phy_exit; =20 /* * ufshcd_vops_init() is invoked after @@ -1255,11 +1225,22 @@ static int ufs_mtk_init(struct ufs_hba *hba) =20 return 0; =20 +out_phy_exit: + phy_exit(host->mphy); out_variant_clear: ufshcd_set_variant(hba, NULL); return err; } =20 +static void ufs_mtk_exit(struct ufs_hba *hba) +{ + struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); + + ufs_mtk_mphy_power_on(hba, false); + + phy_exit(host->mphy); +} + static bool ufs_mtk_pmc_via_fastauto(struct ufs_hba *hba, struct ufs_pa_layer_attr *dev_req_params) { @@ -2255,6 +2236,7 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_v= ops =3D { .name =3D "mediatek.ufshci", .max_num_rtt =3D MTK_MAX_NUM_RTT, .init =3D ufs_mtk_init, + .exit =3D ufs_mtk_exit, .get_ufs_hci_version =3D ufs_mtk_get_ufs_hci_version, .setup_clocks =3D ufs_mtk_setup_clocks, .hce_enable_notify =3D ufs_mtk_hce_enable_notify, @@ -2313,50 +2295,17 @@ MODULE_DEVICE_TABLE(of, ufs_mtk_of_match); */ static int ufs_mtk_probe(struct platform_device *pdev) { - struct platform_device *phy_pdev; struct device *dev =3D &pdev->dev; - struct device_node *phy_node; - struct ufs_mtk_host *host; - struct device *phy_dev; struct ufs_hba *hba; - int err; - - /* find phy node */ - phy_node =3D of_parse_phandle(dev->of_node, "phys", 0); - if (!phy_node) - return dev_err_probe(dev, -ENOENT, "No PHY node found\n"); - - phy_pdev =3D of_find_device_by_node(phy_node); - of_node_put(phy_node); - if (!phy_pdev) - return dev_err_probe(dev, -ENODEV, "No PHY device found\n"); - - phy_dev =3D &phy_pdev->dev; - - err =3D pm_runtime_set_active(phy_dev); - if (err) { - dev_err_probe(dev, err, "Failed to activate PHY RPM\n"); - goto err_put_phy; - } - pm_runtime_enable(phy_dev); - err =3D pm_runtime_get_sync(phy_dev); - if (err) { - dev_err_probe(dev, err, "Failed to power on PHY\n"); - goto err_put_phy; - } + int ret; =20 /* perform generic probe */ - err =3D ufshcd_pltfrm_init(pdev, &ufs_hba_mtk_vops); - if (err) { - dev_err_probe(dev, err, "Generic platform probe failed\n"); - goto err_put_phy; - } + ret =3D ufshcd_pltfrm_init(pdev, &ufs_hba_mtk_vops); + if (ret) + return dev_err_probe(dev, ret, "Generic platform probe failed\n"); =20 hba =3D platform_get_drvdata(pdev); =20 - host =3D ufshcd_get_variant(hba); - host->phy_dev =3D phy_dev; - /* * Because the default power setting of VSx (the upper layer of * VCCQ/VCCQ2) is HWLP, we need to prevent VCCQ/VCCQ2 from @@ -2365,18 +2314,11 @@ static int ufs_mtk_probe(struct platform_device *pd= ev) ufs_mtk_dev_vreg_set_lpm(hba, false); =20 return 0; - -err_put_phy: - put_device(phy_dev); - - return err; } =20 /** * ufs_mtk_remove - set driver_data of the device to NULL * @pdev: pointer to platform device handle - * - * Always return 0 */ static void ufs_mtk_remove(struct platform_device *pdev) { @@ -2436,9 +2378,8 @@ static int ufs_mtk_system_resume(struct device *dev) static int ufs_mtk_runtime_suspend(struct device *dev) { struct ufs_hba *hba =3D dev_get_drvdata(dev); - struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); struct arm_smccc_res res; - int ret =3D 0; + int ret; =20 ret =3D ufshcd_runtime_suspend(dev); if (ret) @@ -2449,8 +2390,11 @@ static int ufs_mtk_runtime_suspend(struct device *de= v) if (ufs_mtk_is_rtff_mtcmos(hba)) ufs_mtk_mtcmos_ctrl(false, res); =20 - if (host->phy_dev) - pm_runtime_put_sync(host->phy_dev); + ret =3D ufs_mtk_mphy_power_on(hba, false); + if (ret) { + dev_err(dev, "Failed to power off PHY: %pe\n", ERR_PTR(ret)); + return ret; + } =20 return 0; } @@ -2458,14 +2402,17 @@ static int ufs_mtk_runtime_suspend(struct device *d= ev) static int ufs_mtk_runtime_resume(struct device *dev) { struct ufs_hba *hba =3D dev_get_drvdata(dev); - struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); struct arm_smccc_res res; + int ret; =20 if (ufs_mtk_is_rtff_mtcmos(hba)) ufs_mtk_mtcmos_ctrl(true, res); =20 - if (host->phy_dev) - pm_runtime_get_sync(host->phy_dev); + ret =3D ufs_mtk_mphy_power_on(hba, true); + if (ret) { + dev_err(dev, "Failed to power on PHY: %pe\n", ERR_PTR(ret)); + return ret; + } =20 ufs_mtk_dev_vreg_set_lpm(hba, false); =20 diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediate= k.h index 24c8941f6b86..4e6a34f4ac39 100644 --- a/drivers/ufs/host/ufs-mediatek.h +++ b/drivers/ufs/host/ufs-mediatek.h @@ -195,7 +195,6 @@ struct ufs_mtk_host { bool is_mcq_intr_enabled; int mcq_nr_intr; struct ufs_mtk_mcq_intr_info mcq_intr_info[UFSHCD_MAX_Q_NR]; - struct device *phy_dev; }; =20 /* MTK delay of autosuspend: 500 ms */ --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 7D9DC2E093E; Sat, 24 Jan 2026 12:03:10 +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=1769256191; cv=pass; b=pw8lwrXnU+qVlolIyIjUQQiYAFhqNDVpAjieMtokFbERn6tqjg8HTe32iVt030nPLoiXG2uAoXfedHJVhHsT88YuAdfICKpjSHGIdA34U1/A7e72KUatDE+kvyivUqmUltJI7DUgnjGpTdzTJCZLJgkZk5GeXX8nuSMU+lOWhS8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256191; c=relaxed/simple; bh=UhtPaGwuFlEFDj2CCUlrPu8e8xx653WtlROBXEBmR68=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g4b0zR/khkTfqao8l4mL/jdCg9TGjjKZTBz0Cjcv0A8Sz0NUP7H9lLEqqXgcUfVfLfRUZHIfRGqecXBcmEoCmBnX6G/9eP6OBDvFIThv9rdb507DiiHkzlSkSti2j6NUA6/IbXVML7yMO/1o8ruvQtffZVshBAUs0k1toEJph98= 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=Zb/zwO13; 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="Zb/zwO13" ARC-Seal: i=1; a=rsa-sha256; t=1769256162; cv=none; d=zohomail.com; s=zohoarc; b=MuLglDE6SViM8d+o7LBUytg7HrRpvR6/J1Xho/A8IUnXrA9lcdIYWTo8Y//rdgelQ3RR+YSb6U3B3XJakKWRURJcCifoRqsiN5VqFPr7RQ2co7V5IHECG78JnigyUUhpm1kYU0+E+4yz7Y1JttSc3gwJ5rNeYyeh3K0Q5DG6p4A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256162; 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=QMwNSkM5XSH2k8a3Oq36FB58kMKzIsImX1FaHSGQhBs=; b=CD2ZV+6QyRXCgWbLzv/OODaDyFcarIlIs6D0/t7dJ1MRI6iFs/VMXnszDY+XO3EEahj2WFeNXWk38SUL5VB5taglbudwz9Za2ztemSB019JMSHAvOwChiSQGbLl3xrmLju9KlsnapwFAtf1SKz+RAJKpjMZ3x5Q60tOmKwbsIIE= 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=1769256162; 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=QMwNSkM5XSH2k8a3Oq36FB58kMKzIsImX1FaHSGQhBs=; b=Zb/zwO13Ip+tgDLIMu3QMDlAOe8uyk3mLGUPAqOx6hQv59MU4jN6FpO+7rxuKfdm jw7lLSX5OLmZXvgaD4tnNn6D5I4qT75FocDZEKzFg3/OHfVDUlpLYfHSBJFvUEWj9EJ PnFZT/IT3Gi4EPurYzKNlCtmjFpS6bxDwz1ASUbs= Received: by mx.zohomail.com with SMTPS id 1769256160863573.5722153832722; Sat, 24 Jan 2026 04:02:40 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:01:00 +0100 Subject: [PATCH v6 14/24] scsi: ufs: mediatek: Switch to newer PM ops helpers 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: <20260124-mt8196-ufs-v6-14-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 SET_SYSTEM_SLEEP_PM_OPS and SET_RUNTIME_PM_OPS are deprecated. Switch to the non-deprecated variants, and pm_ptr, removing the ifdeffery in the process. This allows the compiler visibility into those functions. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index 3250c27cb91f..230e11533eac 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -2325,7 +2325,6 @@ static void ufs_mtk_remove(struct platform_device *pd= ev) ufshcd_pltfrm_remove(pdev); } =20 -#ifdef CONFIG_PM_SLEEP static int ufs_mtk_system_suspend(struct device *dev) { struct ufs_hba *hba =3D dev_get_drvdata(dev); @@ -2372,9 +2371,7 @@ static int ufs_mtk_system_resume(struct device *dev) =20 return ret; } -#endif =20 -#ifdef CONFIG_PM static int ufs_mtk_runtime_suspend(struct device *dev) { struct ufs_hba *hba =3D dev_get_drvdata(dev); @@ -2418,13 +2415,10 @@ static int ufs_mtk_runtime_resume(struct device *de= v) =20 return ufshcd_runtime_resume(dev); } -#endif =20 static const struct dev_pm_ops ufs_mtk_pm_ops =3D { - SET_SYSTEM_SLEEP_PM_OPS(ufs_mtk_system_suspend, - ufs_mtk_system_resume) - SET_RUNTIME_PM_OPS(ufs_mtk_runtime_suspend, - ufs_mtk_runtime_resume, NULL) + SYSTEM_SLEEP_PM_OPS(ufs_mtk_system_suspend, ufs_mtk_system_resume) + RUNTIME_PM_OPS(ufs_mtk_runtime_suspend, ufs_mtk_runtime_resume, NULL) .prepare =3D ufshcd_suspend_prepare, .complete =3D ufshcd_resume_complete, }; @@ -2434,7 +2428,7 @@ static struct platform_driver ufs_mtk_pltform =3D { .remove =3D ufs_mtk_remove, .driver =3D { .name =3D "ufshcd-mtk", - .pm =3D &ufs_mtk_pm_ops, + .pm =3D pm_ptr(&ufs_mtk_pm_ops), .of_match_table =3D ufs_mtk_of_match, }, }; --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 CD18C2F0685; Sat, 24 Jan 2026 12:03:19 +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=1769256201; cv=pass; b=G5kKRuu/p8xW8UBJJWE1veWcQKmRxZbT4m0YEdkaZfS48ecwHVLwBPTyiMR7pcJW7szdzyOgYjCNhTvKYEcuGvVStZXA4P2HErMEELCKjneIfnEoG+y2AD80iIn9QehjLXeEDZS2PdMdgYErpLvQrSfqyk8nWDqNIWZUTmIWXbc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256201; c=relaxed/simple; bh=cHE1xwnUUAd8zCMwGUiQF2E5DMP6WCsn2qRVe3K9hiA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=riQ0Hx8p2SxW7gvR6gBwlbW7y+0Xvql+aEtWgRXiIqdfU4PNXubWFhmp0UvKYuFZvy8KS9qI49kg6HhO8JHW3AfF0shGKenU31dlO2OOkO1HhqDr/i2X1Xf+hlNd4N94J+yNh4QaAEDsS3IFWuU8hRc+yFJZgrMkGa0gnUpmOiA= 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=YB5+sv+X; 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="YB5+sv+X" ARC-Seal: i=1; a=rsa-sha256; t=1769256169; cv=none; d=zohomail.com; s=zohoarc; b=SDE7XVNRWroxkG9cvPT/ZJZBfnZILh3b9ekmgcxXJ2OZNAaKyCmn46sG5RIQVXNqE2Ys1Dxbg8OcjNRRrcvEcm2XstuPfvi74SGi9flYWxFqx79683k33olCWkiuXrvkxXthN0x6PCM9S5KCPg5/D4NNGQQRmGCnya85VHku2Sc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256169; 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=4rMHsJjiUV86PAj6jvywgEhs1dLS6nmBWhNCaoGf/Rw=; b=Jwpyj1NMVFmjyOxFjHnEvLR62uVVizzsE1lVL6h2nwSc+QudapMraI1cwaCSmAv71dSfdEpz1Qb97W9H/kIg9yHGDrhBFpqu1h8ET1Lw3B93NoGYsgLfldP0z0LYhD8Ap2d0asZPqadsvaXG4McSwybyNss9BwFmrTllrgcgEio= 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=1769256168; 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=4rMHsJjiUV86PAj6jvywgEhs1dLS6nmBWhNCaoGf/Rw=; b=YB5+sv+XP1dwR54zimMVRga5FuGwp5vwzWkoih6HGxxLFOA8st35JVzxROA9SNgZ zp/1fEe/x3O+x/jsFCsug0CEIW5xE4Wle8r19AgO/qP8m5WMAkivCb82idCofaDVRMl gC7TKkrtOcB3AsETmMd1JrFbdvT7k/90STmnfmZ0= Received: by mx.zohomail.com with SMTPS id 1769256167390589.2840656247615; Sat, 24 Jan 2026 04:02:47 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:01:01 +0100 Subject: [PATCH v6 15/24] scsi: ufs: mediatek: Remove mediatek,ufs-broken-rtc property 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: <20260124-mt8196-ufs-v6-15-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 This flag property was never described in the binding, and its capability wrapper seems pointless. If one of the MediaTek SoCs needs the ufshcd quirk applied, then this can be done per-compatible, without needing to give the device tree author the option to forget to set it. Remove it and the associated capability flag wrapping code. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 5 ----- drivers/ufs/host/ufs-mediatek.h | 2 -- 2 files changed, 7 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index 230e11533eac..424533538b90 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -655,9 +655,6 @@ static void ufs_mtk_init_host_caps(struct ufs_hba *hba) if (of_property_read_bool(np, "mediatek,ufs-rtff-mtcmos")) host->caps |=3D UFS_MTK_CAP_RTFF_MTCMOS; =20 - if (of_property_read_bool(np, "mediatek,ufs-broken-rtc")) - host->caps |=3D UFS_MTK_CAP_MCQ_BROKEN_RTC; - dev_info(hba->dev, "caps: 0x%x", host->caps); } =20 @@ -1185,8 +1182,6 @@ static int ufs_mtk_init(struct ufs_hba *hba) hba->quirks |=3D UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL; =20 hba->quirks |=3D UFSHCD_QUIRK_MCQ_BROKEN_INTR; - if (host->caps & UFS_MTK_CAP_MCQ_BROKEN_RTC) - hba->quirks |=3D UFSHCD_QUIRK_MCQ_BROKEN_RTC; =20 hba->vps->wb_flush_threshold =3D UFS_WB_BUF_REMAIN_PERCENT(80); =20 diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediate= k.h index 4e6a34f4ac39..9c377745f7a0 100644 --- a/drivers/ufs/host/ufs-mediatek.h +++ b/drivers/ufs/host/ufs-mediatek.h @@ -138,8 +138,6 @@ enum ufs_mtk_host_caps { UFS_MTK_CAP_DISABLE_MCQ =3D 1 << 8, /* Control MTCMOS with RTFF */ UFS_MTK_CAP_RTFF_MTCMOS =3D 1 << 9, - - UFS_MTK_CAP_MCQ_BROKEN_RTC =3D 1 << 10, }; =20 struct ufs_mtk_crypt_cfg { --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 96A872E0904; Sat, 24 Jan 2026 12:03:28 +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=1769256210; cv=pass; b=LS1QHphVGzEaU1sw3OW2aS9mI+YZKyDvde7GVbbv7Baedg3zdCJGlNsiYYZxauoqwlXjlwbIk9GihVgU0F2qwaedNlfQ3vc896lJ6WwTmZkZjYl021unqdBJV9LnEnxBD/LWVhYlhBVi6bo1cVtA1SkrlqAsbZzZZ6NEnd7vQWc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256210; c=relaxed/simple; bh=T4fM0HiKRgFW8PCxMAZHBV/qHMBU263KJMipbTBkRzk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BXAzUIqktGuWBDWWncSVq5nsPDYtfTlXhaY6+Jpyd7jDpXFBu8hh6Vm+9nqjP27Ni1l/QTWhDFWr8nUnyihWffkpdQyPj00uurS9OhADQt43grhw5QIJZKjtI742M1MpKHDCJIUtZtG1giuGGVA4HLHNNHmX2g02xwG1gur1YU0= 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=RgCcm0lA; 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="RgCcm0lA" ARC-Seal: i=1; a=rsa-sha256; t=1769256175; cv=none; d=zohomail.com; s=zohoarc; b=PVvH8+Fbk9o6HllUeV67zCCJn2l3gWmhCly34w6yXy8zu1ekwf2NBVTkGi9N9OF04mTQGYV1QgUcSBl0ZCizkc+2f1p+p0kzNAhbz8CcZ2AGiSh59kvGoyMpYuRXgmlKeSDP0CNU/rkVKAMMNNNoA4t4PnmLLjT1V/k4fTYVtwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256175; 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=JbLl5t3lLsbE+Fel9Gi/ogiICYhTLP9j7XRPqSlaRXo=; b=ntM2cKLbf0aWA4dEpfgmPCUIdsirIkWLgnI4jZpvyzxsqDnHryu1h23hTgsmikszAJSyj6dwSGIqwG9V2HL91alqDikNa60TDBuB5gQj511S1eEBwAB3BoSZEQbjzF2SalTtsUPor05EJzCwD9aWYYFPLD1Wo8KE7gXMaTisdsI= 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=1769256174; 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=JbLl5t3lLsbE+Fel9Gi/ogiICYhTLP9j7XRPqSlaRXo=; b=RgCcm0lAJbECocfJiEWyD+rYuYhWxkIfeGYcR+BYHbfUjFkeeuV9lxhkW/f+KzcD xb95HlK1/Vuhfi7Bb5/G61IZ9cT00DCp4cQCJgX3JchQLgiEUhRQRb3nM5TzzA7Qgrf 0Joy4v4JgbAY4IHxFptef42ZJqxitDgI/t3JdfuA= Received: by mx.zohomail.com with SMTPS id 1769256173982837.1385287953678; Sat, 24 Jan 2026 04:02:53 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:01:02 +0100 Subject: [PATCH v6 16/24] scsi: ufs: mediatek: Rework _ufs_mtk_clk_scale error paths 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: <20260124-mt8196-ufs-v6-16-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 Errors should be printed at the correct log level. Additionally, it looks like some "goto out"'s were omitted in the scale up case, which looks like a mistake, as the scale down branch of the code does use them. Rework the error messages to make them nicer and at the correct verbosity, and add the missing gotos. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 41 +++++++++++++++++++------------------= ---- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index 424533538b90..ecf16e82a326 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1961,16 +1961,16 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba,= bool scale_up) =20 ret =3D clk_prepare_enable(clki->clk); if (ret) { - dev_info(hba->dev, - "clk_prepare_enable() fail, ret: %d\n", ret); + dev_err(hba->dev, "%s: Failed to enable clock: %pe\n", __func__, ERR_PTR= (ret)); return; } =20 if (clk_fde_scale) { ret =3D clk_prepare_enable(fde_clki->clk); if (ret) { - dev_info(hba->dev, - "fde clk_prepare_enable() fail, ret: %d\n", ret); + dev_err(hba->dev, "%s: Failed to enable FDE clock: %pe\n", + __func__, ERR_PTR(ret)); + clk_disable_unprepare(clki->clk); return; } } @@ -1979,51 +1979,48 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba,= bool scale_up) if (clk_bind_vcore) { ret =3D regulator_set_voltage(reg, volt, INT_MAX); if (ret) { - dev_info(hba->dev, - "Failed to set vcore to %d\n", volt); + dev_err(hba->dev, "Failed to set vcore to %d\n", volt); goto out; } } =20 ret =3D clk_set_parent(clki->clk, mclk->ufs_sel_max_clki->clk); if (ret) { - dev_info(hba->dev, "Failed to set clk mux, ret =3D %d\n", - ret); + dev_err(hba->dev, "%s: Failed to set clock mux: %pe\n", + __func__, ERR_PTR(ret)); + goto out; } =20 if (clk_fde_scale) { - ret =3D clk_set_parent(fde_clki->clk, - mclk->ufs_fde_max_clki->clk); + ret =3D clk_set_parent(fde_clki->clk, mclk->ufs_fde_max_clki->clk); if (ret) { - dev_info(hba->dev, - "Failed to set fde clk mux, ret =3D %d\n", - ret); + dev_err(hba->dev, "%s: Failed to set fde clock mux: %pe\n", + __func__, ERR_PTR(ret)); + goto out; } } } else { if (clk_fde_scale) { - ret =3D clk_set_parent(fde_clki->clk, - mclk->ufs_fde_min_clki->clk); + ret =3D clk_set_parent(fde_clki->clk, mclk->ufs_fde_min_clki->clk); if (ret) { - dev_info(hba->dev, - "Failed to set fde clk mux, ret =3D %d\n", - ret); + dev_err(hba->dev, "%s: Failed to set fde clock mux: %pe\n", + __func__, ERR_PTR(ret)); goto out; } } =20 ret =3D clk_set_parent(clki->clk, mclk->ufs_sel_min_clki->clk); if (ret) { - dev_info(hba->dev, "Failed to set clk mux, ret =3D %d\n", - ret); + dev_err(hba->dev, "%s: Failed to set clock mux: %pe\n", + __func__, ERR_PTR(ret)); goto out; } =20 if (clk_bind_vcore) { ret =3D regulator_set_voltage(reg, 0, INT_MAX); if (ret) { - dev_info(hba->dev, - "failed to set vcore to MIN\n"); + dev_err(hba->dev, "%s: Failed to set vcore to minimum: %pe\n", + __func__, ERR_PTR(ret)); } } } --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 Received: from sender4-pp-e107.zoho.com (sender4-pp-e107.zoho.com [136.143.188.107]) (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 103152DD5EF; Sat, 24 Jan 2026 12:03:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.107 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256218; cv=pass; b=tv9MFr4o6+/fEf8EYCfBnvcsHr7DVwC5YBNH0fKnQgZx9btggasM70min/CMc8PkDcPiwADrT3jFmwa7EncDQB0fK1bhrB12mOKHLgCcSTo41qpYpMBQgszMu4/h8K5UZZnv34bxOXLPPNdfimh33a7jn7Xwg+9WxgWJQI/uQG8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256218; c=relaxed/simple; bh=Mi8U+TSW07Mvnh1jtT8tFBMPpVlekHOOjiDYD0jbmGc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Mwq1P6LwsubUR6IiVGI4RIdgGNGuJXdHzklISewCTWNO+YaVELjnvCLpzImdvJhjkwlKWqXMDDrdoVloVroQQAaYcPkd2yrSp9ZKMYr2xdwsgFosKeslbGg42hb3BOBe9bSyRyKD66bFXT3iMJs1XmD8oBAb8GXuv/t+t+nT6bA= 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=GRD66anO; arc=pass smtp.client-ip=136.143.188.107 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="GRD66anO" ARC-Seal: i=1; a=rsa-sha256; t=1769256183; cv=none; d=zohomail.com; s=zohoarc; b=B1zT1b0SP5dAlijEu0AfuINjiq6j+yqe7Z0ygV0JcpuF62FBdn8mjcX+GLL9fLXB7vgqOsZe+FHTQM7kzLx6o9qcTKnO0zmBZLtnVwjKVFE+jHTeKAQO3la6O8Os0Wwa6vdZOUwFt8K/c7pfcueNK95lQH71sXiSOHYjA9GB3ZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256183; 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=9hNURQTUxqgcuUFqpBTs6NSsr/6Pv8LJD3rvcmLMIT8=; b=iYEdemIetYNm2m8iytGZtqd6DFaL9hr+lRHFwxBlbjTcXuzUZ4RdA4wcSspZAehnekJ0tnGTiDMArdtl/ZYa1hDgL4xUN0vD5aJ3tA756afvleH8x+HvXTg4G4Hl+kYiVFcUygGFyP9hu9g4FR+Qn1OnAyJaN34Sx8X2MLC9JXE= 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=1769256183; 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=9hNURQTUxqgcuUFqpBTs6NSsr/6Pv8LJD3rvcmLMIT8=; b=GRD66anOwU7T8HsoRVc+P1XZ1kPY66v/Vh7IyMrHWBG4Tfad5iFEwqYwsnkHJofy 6BqoEcbSGwiGU0nX7ziKdGGkJBBtCsakST4atu/ehCXHCtOem6k7APV/FRU1DSQ57mt 9jDSMcxe5kegq3szXyFQpvBQhMc7rqP/TWhCy4/U= Received: by mx.zohomail.com with SMTPS id 1769256180642619.293278460438; Sat, 24 Jan 2026 04:03:00 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:01:03 +0100 Subject: [PATCH v6 17/24] scsi: ufs: mediatek: Clean up logging prints 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: <20260124-mt8196-ufs-v6-17-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 Linux kernel's log buffer provides many levels of verbosity, associated with different semantic meanings. Care should be taken to only log useful information to the info level, and log errors to the error level. The MediaTek UFS driver does not do this. It freely logs verbose debug information to the info level, errors to the info level, and sometimes errors to the warning level. Adjust all the wrapped kprintf invocations to rectify this situation. Use user-friendly %pe format codes for printing errors where possible. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 99 ++++++++++++++++++-------------------= ---- 1 file changed, 43 insertions(+), 56 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index ecf16e82a326..2b1f26b55782 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -192,8 +192,8 @@ static void ufs_mtk_crypto_enable(struct ufs_hba *hba) =20 ufs_mtk_crypto_ctrl(res, 1); if (res.a0) { - dev_info(hba->dev, "%s: crypto enable failed, err: %lu\n", - __func__, res.a0); + dev_err(hba->dev, "%s: crypto enable failed with error %lu, disabling\n", + __func__, res.a0); hba->caps &=3D ~UFSHCD_CAP_CRYPTO; } } @@ -542,40 +542,38 @@ static void ufs_mtk_boost_crypt(struct ufs_hba *hba, = bool boost) =20 ret =3D clk_prepare_enable(cfg->clk_crypt_mux); if (ret) { - dev_info(hba->dev, "clk_prepare_enable(): %d\n", - ret); + dev_err(hba->dev, "%s: Failed to enable clk_crypt_mux: %pe\n", + __func__, ERR_PTR(ret)); return; } =20 if (boost) { ret =3D regulator_set_voltage(reg, volt, INT_MAX); if (ret) { - dev_info(hba->dev, - "failed to set vcore to %d\n", volt); + dev_err(hba->dev, "%s: Failed to set vcore to %d: %pe\n", + __func__, volt, ERR_PTR(ret)); goto out; } =20 - ret =3D clk_set_parent(cfg->clk_crypt_mux, - cfg->clk_crypt_perf); + ret =3D clk_set_parent(cfg->clk_crypt_mux, cfg->clk_crypt_perf); if (ret) { - dev_info(hba->dev, - "failed to set clk_crypt_perf\n"); + dev_err(hba->dev, "%s: Failed to reparent clk_crypt_perf: %pe\n", + __func__, ERR_PTR(ret)); regulator_set_voltage(reg, 0, INT_MAX); goto out; } } else { - ret =3D clk_set_parent(cfg->clk_crypt_mux, - cfg->clk_crypt_lp); + ret =3D clk_set_parent(cfg->clk_crypt_mux, cfg->clk_crypt_lp); if (ret) { - dev_info(hba->dev, - "failed to set clk_crypt_lp\n"); + dev_err(hba->dev, "%s: Failed to reparent clk_crypt_lp: %pe\n", + __func__, ERR_PTR(ret)); goto out; } =20 ret =3D regulator_set_voltage(reg, 0, INT_MAX); if (ret) { - dev_info(hba->dev, - "failed to set vcore to MIN\n"); + dev_err(hba->dev, "%s: Failed to set vcore to minimum: %pe\n", + __func__, ERR_PTR(ret)); } } out: @@ -763,10 +761,8 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, b= ool on, if (clk_pwr_off) { ufs_mtk_pwr_ctrl(hba, false); } else { - dev_warn(hba->dev, "Clock is not turned off, hba->ahit =3D 0x%x, AHIT = =3D 0x%x\n", - hba->ahit, - ufshcd_readl(hba, - REG_AUTO_HIBERNATE_IDLE_TIMER)); + dev_warn(hba->dev, "Clock isn't off, hba->ahit =3D 0x%x, AHIT =3D 0x%x\= n", + hba->ahit, ufshcd_readl(hba, REG_AUTO_HIBERNATE_IDLE_TIMER)); } ufs_mtk_mcq_disable_irq(hba); } else if (on && status =3D=3D POST_CHANGE) { @@ -810,11 +806,11 @@ static void ufs_mtk_mcq_set_irq_affinity(struct ufs_h= ba *hba, unsigned int cpu) _cpu =3D (cpu =3D=3D 0) ? 3 : cpu; ret =3D irq_set_affinity(irq, cpumask_of(_cpu)); if (ret) { - dev_err(hba->dev, "set irq %d affinity to CPU %d failed\n", + dev_err(hba->dev, "setting irq %d affinity to CPU %d failed\n", irq, _cpu); return; } - dev_info(hba->dev, "set irq %d affinity to CPU: %d\n", irq, _cpu); + dev_dbg(hba->dev, "set irq %d affinity to CPU %d\n", irq, _cpu); } =20 static bool ufs_mtk_is_legacy_chipset(struct ufs_hba *hba, u32 hw_ip_ver) @@ -830,7 +826,8 @@ static bool ufs_mtk_is_legacy_chipset(struct ufs_hba *h= ba, u32 hw_ip_ver) default: break; } - dev_info(hba->dev, "legacy IP version - 0x%x, is legacy : %d", hw_ip_ver,= is_legacy); + dev_dbg(hba->dev, "IP version 0x%x, legacy =3D %s", hw_ip_ver, + str_true_false(is_legacy)); =20 return is_legacy; } @@ -935,15 +932,12 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba) } } =20 - list_for_each_entry(clki, head, list) { - dev_info(hba->dev, "clk \"%s\" present", clki->name); - } + list_for_each_entry(clki, head, list) + dev_dbg(hba->dev, "clk \"%s\" present", clki->name); =20 if (!ufs_mtk_is_clk_scale_ready(hba)) { hba->caps &=3D ~UFSHCD_CAP_CLK_SCALING; - dev_info(hba->dev, - "%s: Clk-scaling not ready. Feature disabled.", - __func__); + dev_info(hba->dev, "%s: Clock scaling unavailable", __func__); return; } =20 @@ -953,8 +947,8 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba) */ reg =3D devm_regulator_get_optional(dev, "dvfsrc-vcore"); if (IS_ERR(reg)) { - dev_info(dev, "failed to get dvfsrc-vcore: %ld", - PTR_ERR(reg)); + if (PTR_ERR(reg) !=3D -ENODEV) + dev_err(dev, "Failed to get dvfsrc-vcore: %pe\n", reg); return; } =20 @@ -968,12 +962,9 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba) host->mclk.vcore_volt =3D volt; =20 /* If default boot is max gear, request vcore */ - if (reg && volt && host->clk_scale_up) { - if (regulator_set_voltage(reg, volt, INT_MAX)) { - dev_info(hba->dev, - "Failed to set vcore to %d\n", volt); - } - } + if (reg && volt && host->clk_scale_up) + if (regulator_set_voltage(reg, volt, INT_MAX)) + dev_err(hba->dev, "Failed to set vcore to %d\n", volt); } =20 static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba) @@ -1060,7 +1051,7 @@ static void ufs_mtk_init_mcq_irq(struct ufs_hba *hba) } host->mcq_intr_info[i].hba =3D hba; host->mcq_intr_info[i].irq =3D irq; - dev_info(hba->dev, "get platform mcq irq: %d, %d\n", i, irq); + dev_dbg(hba->dev, "get platform mcq irq: %d, %d\n", i, irq); } =20 return; @@ -1307,10 +1298,8 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hb= a, host_params.desired_working_mode =3D UFS_PWM_MODE; =20 ret =3D ufshcd_negotiate_pwr_params(&host_params, dev_max_params, dev_req= _params); - if (ret) { - pr_info("%s: failed to determine capabilities\n", - __func__); - } + if (ret) + dev_warn(hba->dev, "%s: failed to determine capabilities\n", __func__); =20 if (ufs_mtk_pmc_via_fastauto(hba, dev_req_params)) { ufs_mtk_adjust_sync_length(hba); @@ -1356,10 +1345,9 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hb= a, ret =3D ufshcd_uic_change_pwr_mode(hba, FASTAUTO_MODE << 4 | FASTAUTO_MODE); =20 - if (ret) { - dev_err(hba->dev, "%s: HSG1B FASTAUTO failed ret=3D%d\n", - __func__, ret); - } + if (ret) + dev_err(hba->dev, "%s: HSG1B FASTAUTO failed: %pe\n", + __func__, ERR_PTR(ret)); } =20 /* if already configured to the requested pwr_mode, skip adapt */ @@ -1409,7 +1397,7 @@ static int ufs_mtk_auto_hibern8_disable(struct ufs_hb= a *hba) =20 out: if (ret) { - dev_warn(hba->dev, "exit h8 state fail, ret=3D%d\n", ret); + dev_err(hba->dev, "Failed to exit h8 state: %pe\n", ERR_PTR(ret)); =20 ufshcd_force_error_recovery(hba); =20 @@ -1571,7 +1559,7 @@ static int ufs_mtk_device_reset(struct ufs_hba *hba) /* Some devices may need time to respond to rst_n */ usleep_range(10000, 15000); =20 - dev_info(hba->dev, "device reset done\n"); + dev_dbg(hba->dev, "device reset done\n"); =20 return 0; } @@ -1607,12 +1595,12 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) /* Check link state to make sure exit h8 success */ err =3D ufs_mtk_wait_idle_state(hba, 5); if (err) { - dev_warn(hba->dev, "wait idle fail, err=3D%d\n", err); + dev_err(hba->dev, "Failed to wait for idle: %pe\n", ERR_PTR(err)); return err; } err =3D ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100); if (err) { - dev_warn(hba->dev, "exit h8 state fail, err=3D%d\n", err); + dev_err(hba->dev, "Failed to wait for link to be up: %pe\n", ERR_PTR(err= )); return err; } ufshcd_set_link_active(hba); @@ -1905,20 +1893,19 @@ static void ufs_mtk_event_notify(struct ufs_hba *hb= a, =20 /* Print details of UIC Errors */ if (evt <=3D UFS_EVT_DME_ERR) { - dev_info(hba->dev, - "Host UIC Error Code (%s): %08x\n", - ufs_uic_err_str[evt], val); + dev_err(hba->dev, "Host UIC Error Code (%s): %08x\n", + ufs_uic_err_str[evt], val); reg =3D val; } =20 if (evt =3D=3D UFS_EVT_PA_ERR) { for_each_set_bit(bit, ®, ARRAY_SIZE(ufs_uic_pa_err_str)) - dev_info(hba->dev, "%s\n", ufs_uic_pa_err_str[bit]); + dev_err(hba->dev, "%s\n", ufs_uic_pa_err_str[bit]); } =20 if (evt =3D=3D UFS_EVT_DL_ERR) { for_each_set_bit(bit, ®, ARRAY_SIZE(ufs_uic_dl_err_str)) - dev_info(hba->dev, "%s\n", ufs_uic_dl_err_str[bit]); + dev_err(hba->dev, "%s\n", ufs_uic_dl_err_str[bit]); } } =20 @@ -2123,7 +2110,7 @@ static int ufs_mtk_mcq_config_resource(struct ufs_hba= *hba) =20 /* fail mcq initialization if interrupt is not filled properly */ if (!host->mcq_nr_intr) { - dev_info(hba->dev, "IRQs not ready. MCQ disabled."); + dev_err(hba->dev, "IRQs not ready. MCQ disabled."); return -EINVAL; } =20 --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 D4FCE2DECC5; Sat, 24 Jan 2026 12:03:36 +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=1769256218; cv=pass; b=o2uQ/f6AvrGWbatIuXJybKEJOCg6sNiWAwjJGhILVStyKMTiYZ5pkVdVR6akToriWTkJaq0etPnntZYyP2jC025Md9tUFdXV9HDDgymzYL6b/he2aSgh1dhDbTyzA1+QiZbtfdLHoTR+If1PX15OX/KdSdep0GM3BjkNPPIRkZM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256218; c=relaxed/simple; bh=bKULkiSdnrA8nwen42fkkXB8yJm6JRElMRZ+goyqIQw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bRvI3isP5xr2TCjGrvPXC7hJElEphdbEhMx91ebUIfScy9SBUxwBFOShPi4cJtFaTaINURMZLrpKHZxAwwEjpq6rHXRHg6aPVWijhgXBs42K4qMxx3GSkNoJER6kxxP3oBCQg2VZ9OAKFtPLg0vcyvaTHt0KaINKEH+wqK9lUjA= 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=NHMrDp75; 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="NHMrDp75" ARC-Seal: i=1; a=rsa-sha256; t=1769256189; cv=none; d=zohomail.com; s=zohoarc; b=YbikC+ALrBSQocWHTuLrH23sKxTB+si5p4/aJtDHa77DggWIr9rsweZO3g9l8KG3U7OCZ7Cugrp2tqCKcRW6XS/QHA5hL58GQPVFdvnZGVx3SporTEkrO1HkDS0+esxIybHD88noWj6xgIYR9xpDfhQQsxuWH5Gu0HrqatM5iRQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256189; 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=gjSLvwTgrrP3mUBEhIBlXKbE0FaKi8bZDGULITLn1ns=; b=l/FsYEE+HjHR7XD4QA1Hqmg1Jxk6KdS8Y5U4ISPP0J8n2D4kgfAfK5c4jZkZaGs/6BqTaavnzx20DS7SoZk4CyZrD5s4zWFP807Qz3u96VQeqrCyKwx6qmjYZEGp6vO5uyhfXeX0eUYhQx1TwmSw+IHEmuZQ6GGmuNa3nj6KdVo= 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=1769256189; 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=gjSLvwTgrrP3mUBEhIBlXKbE0FaKi8bZDGULITLn1ns=; b=NHMrDp75Hd1Q6Crs52h7Cm902/BigAaK05tO1883aFNM/l6Gt8iXO5zaNYkZy8Bf wzvsyBO51fEIQVqQKkdVA0csvgxdrl4wyU36LjVNkPo3+/2PSg5f5fQbL/xJ+zCxKA8 YKSTQeY8wGkGJQ6ixwYX8YMiKaM3qhtFREn6suKc= Received: by mx.zohomail.com with SMTPS id 1769256187122724.0072043219542; Sat, 24 Jan 2026 04:03:07 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:01:04 +0100 Subject: [PATCH v6 18/24] scsi: ufs: mediatek: Rework ufs_mtk_wait_idle_state 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: <20260124-mt8196-ufs-v6-18-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 While ufs_mtk_wait_idle state has some code smells for me (the VS_HCE_BASE early exit seems racey at best), it can still benefit from some general cleanup to make the code flow less convoluted. Use the iopoll helpers, for one, and specifically the one that sleeps and does not busy delay, as it's being done for up to 5ms. The register read is split out to a helper function that branches between new and old style flow. Every called uses the same 5ms timeout value, so there is no point in making this a parameter. Just assume a 5ms timeout in the function. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 71 +++++++++++++++++--------------------= ---- 1 file changed, 30 insertions(+), 41 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index 2b1f26b55782..b5c75d228c85 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -380,51 +381,39 @@ static void ufs_mtk_dbg_sel(struct ufs_hba *hba) } } =20 -static int ufs_mtk_wait_idle_state(struct ufs_hba *hba, - unsigned long retry_ms) +static u32 ufs_mtk_read_state(struct ufs_hba *hba, bool old_style) { - u64 timeout, time_checked; - u32 val, sm; - bool wait_idle; - struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); - - /* cannot use plain ktime_get() in suspend */ - timeout =3D ktime_get_mono_fast_ns() + retry_ms * 1000000UL; - - /* wait a specific time after check base */ - udelay(10); - wait_idle =3D false; + u32 val; =20 - do { - time_checked =3D ktime_get_mono_fast_ns(); - if (host->legacy_ip_ver || host->ip_ver < IP_VER_MT6899) { - ufs_mtk_dbg_sel(hba); - val =3D ufshcd_readl(hba, REG_UFS_PROBE); - } else { - val =3D ufshcd_readl(hba, REG_UFS_UFS_MMIO_OTSD_CTRL); - val =3D val >> 16; - } + if (old_style) { + ufs_mtk_dbg_sel(hba); + val =3D ufshcd_readl(hba, REG_UFS_PROBE); + } else { + val =3D ufshcd_readl(hba, REG_UFS_UFS_MMIO_OTSD_CTRL) >> 16; + } =20 - sm =3D val & 0x1f; + return FIELD_GET(0x1f, val); +} =20 - /* - * if state is in H8 enter and H8 enter confirm - * wait until return to idle state. - */ - if ((sm >=3D VS_HIB_ENTER) && (sm <=3D VS_HIB_EXIT)) { - wait_idle =3D true; - udelay(50); - continue; - } else if (!wait_idle) - break; +static int ufs_mtk_wait_idle_state(struct ufs_hba *hba) +{ + struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); + bool old_style =3D (host->legacy_ip_ver || host->ip_ver < IP_VER_MT6899); + u32 val; + int ret; =20 - if (wait_idle && (sm =3D=3D VS_HCE_BASE)) - break; - } while (time_checked < timeout); + /* If the device is already in the base state after 10us, don't wait. */ + udelay(10); + if (ufs_mtk_read_state(hba, old_style) =3D=3D VS_HCE_BASE) + return 0; =20 - if (wait_idle && sm !=3D VS_HCE_BASE) { - dev_info(hba->dev, "wait idle tmo: 0x%x\n", val); - return -ETIMEDOUT; + /* Poll to wait for idle */ + ret =3D read_poll_timeout(ufs_mtk_read_state, val, + (val < VS_HIB_ENTER || val > VS_HIB_EXIT), 50, + 5 * USEC_PER_MSEC, false, hba, old_style); + if (ret) { + dev_err(hba->dev, "Timed out waiting for idle state, val =3D 0x%x\n", va= l); + return ret; } =20 return 0; @@ -1389,7 +1378,7 @@ static int ufs_mtk_auto_hibern8_disable(struct ufs_hb= a *hba) ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER); =20 /* wait host return to idle state when auto-hibern8 off */ - ret =3D ufs_mtk_wait_idle_state(hba, 5); + ret =3D ufs_mtk_wait_idle_state(hba); if (ret) goto out; =20 @@ -1593,7 +1582,7 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba) return err; =20 /* Check link state to make sure exit h8 success */ - err =3D ufs_mtk_wait_idle_state(hba, 5); + err =3D ufs_mtk_wait_idle_state(hba); if (err) { dev_err(hba->dev, "Failed to wait for idle: %pe\n", ERR_PTR(err)); return err; --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 EBA862F5A25; Sat, 24 Jan 2026 12:03:47 +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=1769256232; cv=pass; b=QhLauDu1y1z4t9fFv8qYiHL+6RbI1b25okInX+He8G6EETXDnEN3Qrym8HOcMwMx53JGIRX2rjS9SYsYluk/E27KUHRJaSBs+ZXEXrtuVNtJbi2XJbYpTZKbhO+6J7yceoXFjO6Go4ip85ptyrLHZU8ScMpFAOZWKPlHl/uUKHA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256232; c=relaxed/simple; bh=UAXdZyynbL4QsBYN/7vuMLRbSV+rmBOkWTauE1N5NEs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Laoe+ozlHiK10yT+yqMiwTWw/3Z2BTXz0AewMyCQ9TPtgpgLvtVnLuQB79kFbP2wmchLMiZvENussznIOMW/LrsZ7/bfGXyraiJdCf6RRPmI3HP3RGTwHUXS6hjRP8KuehHha2tj5fx4nFTqwY4E3CxrEC3okEMDyPyBlbH7Ec0= 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=ftnVI1Lk; 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="ftnVI1Lk" ARC-Seal: i=1; a=rsa-sha256; t=1769256195; cv=none; d=zohomail.com; s=zohoarc; b=KEj1ZU5W86aSR4W7J+DzyZZTfL+qOkmERLrhZAPlrupRBOZcixYZR/FTEvq/D1cT8FYnI7lu7+hW8x6pha01j2TvYXPU32itoG1ZMMieDkbuwc6YVLFq8+kMEkAwKNd2LfJSU0KsNeozkXszqVuKOpbaHahHQid4W1QjKQBprKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256195; 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=YtEMIzBSHQP/NjYhH6HlsQaqcPasbFghhR/CF/B/yaI=; b=M7bW94UcdqaSrcG8wfzaNMR68Y8Jw2pqQNn2mS1+YHNA7AkpLwq4DrtVWvjow0QX7W7/H8u8cEc4H5RQ4PufHgkBBH3q0JQl1VcQ0uFEN+qGFQVGhEltHuFoU6SKcGSwdiWPZ00X57s7ft1D006sTXGeTDrql3d2qJMnWVaHcUU= 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=1769256194; 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=YtEMIzBSHQP/NjYhH6HlsQaqcPasbFghhR/CF/B/yaI=; b=ftnVI1Lkw9HxUwyCO3rHSZeIDScb8q+SsXaSWdbddAE4w5ltKIeLDOi39sjIMdgN ZmXZZk9R45haoc8qbmuoZ80VroBie+Ek0KlWRWnXuTj4J4hokIIUmkcROJUTYv/27b0 bVdyGqXZT/u6CFFrj6Xu54fXpTQQdJ1MqbpLTEdc= Received: by mx.zohomail.com with SMTPS id 1769256193563277.28413923435426; Sat, 24 Jan 2026 04:03:13 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:01:05 +0100 Subject: [PATCH v6 19/24] scsi: ufs: mediatek: Don't acquire dvfsrc-vcore twice 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: <20260124-mt8196-ufs-v6-19-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 As part of its featureset, the ufs-mediatek driver needs to play with an optional dvfsrc-vcore regulator for some of them. However, it currently does this by acquiring two different references to it in two different places, needlessly duplicating logic. Move reg_vcore to the host struct, acquire it in the same function as avdd09 is acquired, and rework the users of reg_vcore. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 73 +++++++++++++++++++------------------= ---- drivers/ufs/host/ufs-mediatek.h | 3 +- 2 files changed, 34 insertions(+), 42 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index b5c75d228c85..e39412d59847 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -519,15 +519,13 @@ static void ufs_mtk_boost_crypt(struct ufs_hba *hba, = bool boost) { struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); struct ufs_mtk_crypt_cfg *cfg; - struct regulator *reg; int volt, ret; =20 - if (!ufs_mtk_is_boost_crypt_enabled(hba)) + if (!ufs_mtk_is_boost_crypt_enabled(hba) || !host->reg_vcore) return; =20 cfg =3D host->crypt; volt =3D cfg->vcore_volt; - reg =3D cfg->reg_vcore; =20 ret =3D clk_prepare_enable(cfg->clk_crypt_mux); if (ret) { @@ -537,7 +535,7 @@ static void ufs_mtk_boost_crypt(struct ufs_hba *hba, bo= ol boost) } =20 if (boost) { - ret =3D regulator_set_voltage(reg, volt, INT_MAX); + ret =3D regulator_set_voltage(host->reg_vcore, volt, INT_MAX); if (ret) { dev_err(hba->dev, "%s: Failed to set vcore to %d: %pe\n", __func__, volt, ERR_PTR(ret)); @@ -548,7 +546,7 @@ static void ufs_mtk_boost_crypt(struct ufs_hba *hba, bo= ol boost) if (ret) { dev_err(hba->dev, "%s: Failed to reparent clk_crypt_perf: %pe\n", __func__, ERR_PTR(ret)); - regulator_set_voltage(reg, 0, INT_MAX); + regulator_set_voltage(host->reg_vcore, 0, INT_MAX); goto out; } } else { @@ -559,7 +557,7 @@ static void ufs_mtk_boost_crypt(struct ufs_hba *hba, bo= ol boost) goto out; } =20 - ret =3D regulator_set_voltage(reg, 0, INT_MAX); + ret =3D regulator_set_voltage(host->reg_vcore, 0, INT_MAX); if (ret) { dev_err(hba->dev, "%s: Failed to set vcore to minimum: %pe\n", __func__, ERR_PTR(ret)); @@ -576,15 +574,12 @@ static void ufs_mtk_init_boost_crypt(struct ufs_hba *= hba) struct device *dev =3D hba->dev; int ret; =20 - cfg =3D devm_kzalloc(dev, sizeof(*cfg), GFP_KERNEL); - if (!cfg) + if (!host->reg_vcore) return; =20 - cfg->reg_vcore =3D devm_regulator_get_optional(dev, "dvfsrc-vcore"); - if (IS_ERR(cfg->reg_vcore)) { - dev_err(dev, "Failed to get dvfsrc-vcore: %pe", cfg->reg_vcore); + cfg =3D devm_kzalloc(dev, sizeof(*cfg), GFP_KERNEL); + if (!cfg) return; - } =20 ret =3D of_property_read_u32(dev->of_node, "mediatek,boost-crypt-vcore-mi= n", &cfg->vcore_volt); @@ -889,7 +884,6 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba) struct list_head *head =3D &hba->clk_list_head; struct ufs_clk_info *clki, *clki_tmp; struct device *dev =3D hba->dev; - struct regulator *reg; u32 volt; =20 /* @@ -930,16 +924,8 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba) return; } =20 - /* - * Default get vcore if dts have these settings. - * No matter clock scaling support or not. (may disable by customer) - */ - reg =3D devm_regulator_get_optional(dev, "dvfsrc-vcore"); - if (IS_ERR(reg)) { - if (PTR_ERR(reg) !=3D -ENODEV) - dev_err(dev, "Failed to get dvfsrc-vcore: %pe\n", reg); + if (!host->reg_vcore) return; - } =20 if (of_property_read_u32(dev->of_node, "clk-scale-up-vcore-min", &volt)) { @@ -947,12 +933,11 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba) return; } =20 - host->mclk.reg_vcore =3D reg; host->mclk.vcore_volt =3D volt; =20 /* If default boot is max gear, request vcore */ - if (reg && volt && host->clk_scale_up) - if (regulator_set_voltage(reg, volt, INT_MAX)) + if (volt && host->clk_scale_up) + if (regulator_set_voltage(host->reg_vcore, volt, INT_MAX)) dev_err(hba->dev, "Failed to set vcore to %d\n", volt); } =20 @@ -1064,6 +1049,17 @@ static int ufs_mtk_get_supplies(struct ufs_mtk_host = *host) const struct ufs_mtk_soc_data *data =3D of_device_get_match_data(dev); int ret; =20 + host->reg_vcore =3D devm_regulator_get_optional(dev, "dvfsrc-vcore"); + if (IS_ERR(host->reg_vcore)) { + if (PTR_ERR(host->reg_vcore) !=3D -ENODEV) { + dev_err(dev, "Failed to get dvfsrc-vcore supply: %pe\n", + host->reg_vcore); + return PTR_ERR(host->reg_vcore); + } + + host->reg_vcore =3D NULL; + } + if (!data) return 0; =20 @@ -1081,14 +1077,13 @@ static int ufs_mtk_get_supplies(struct ufs_mtk_host= *host) =20 host->reg_avdd09 =3D devm_regulator_get_optional(dev, "avdd09"); if (IS_ERR(host->reg_avdd09)) { - if (PTR_ERR(host->reg_avdd09) =3D=3D -ENODEV) { - host->reg_avdd09 =3D NULL; - return 0; + if (PTR_ERR(host->reg_avdd09) !=3D -ENODEV) { + dev_err(dev, "Failed to get avdd09 regulator: %pe\n", + host->reg_avdd09); + return PTR_ERR(host->reg_avdd09); } =20 - dev_err(dev, "Failed to get avdd09 regulator: %pe\n", - host->reg_avdd09); - return PTR_ERR(host->reg_avdd09); + host->reg_avdd09 =3D NULL; } =20 return 0; @@ -1119,6 +1114,10 @@ static int ufs_mtk_init(struct ufs_hba *hba) host->hba =3D hba; ufshcd_set_variant(hba, host); =20 + err =3D ufs_mtk_get_supplies(host); + if (err) + goto out_variant_clear; + /* Initialize host capability */ ufs_mtk_init_host_caps(hba); =20 @@ -1173,10 +1172,6 @@ static int ufs_mtk_init(struct ufs_hba *hba) =20 ufs_mtk_init_clocks(hba); =20 - err =3D ufs_mtk_get_supplies(host); - if (err) - goto out_phy_exit; - /* * ufshcd_vops_init() is invoked after * ufshcd_setup_clock(true) in ufshcd_hba_init() thus @@ -1916,7 +1911,6 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, b= ool scale_up) struct ufs_mtk_clk *mclk =3D &host->mclk; struct ufs_clk_info *clki =3D mclk->ufs_sel_clki; struct ufs_clk_info *fde_clki =3D mclk->ufs_fde_clki; - struct regulator *reg; int volt, ret =3D 0; bool clk_bind_vcore =3D false; bool clk_fde_scale =3D false; @@ -1927,9 +1921,8 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, b= ool scale_up) if (!clki || !fde_clki) return; =20 - reg =3D host->mclk.reg_vcore; volt =3D host->mclk.vcore_volt; - if (reg && volt !=3D 0) + if (host->reg_vcore && volt) clk_bind_vcore =3D true; =20 if (mclk->ufs_fde_max_clki && mclk->ufs_fde_min_clki) @@ -1953,7 +1946,7 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, b= ool scale_up) =20 if (scale_up) { if (clk_bind_vcore) { - ret =3D regulator_set_voltage(reg, volt, INT_MAX); + ret =3D regulator_set_voltage(host->reg_vcore, volt, INT_MAX); if (ret) { dev_err(hba->dev, "Failed to set vcore to %d\n", volt); goto out; @@ -1993,7 +1986,7 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, b= ool scale_up) } =20 if (clk_bind_vcore) { - ret =3D regulator_set_voltage(reg, 0, INT_MAX); + ret =3D regulator_set_voltage(host->reg_vcore, 0, INT_MAX); if (ret) { dev_err(hba->dev, "%s: Failed to set vcore to minimum: %pe\n", __func__, ERR_PTR(ret)); diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediate= k.h index 9c377745f7a0..fa27ab4d6d6c 100644 --- a/drivers/ufs/host/ufs-mediatek.h +++ b/drivers/ufs/host/ufs-mediatek.h @@ -141,7 +141,6 @@ enum ufs_mtk_host_caps { }; =20 struct ufs_mtk_crypt_cfg { - struct regulator *reg_vcore; struct clk *clk_crypt_perf; struct clk *clk_crypt_mux; struct clk *clk_crypt_lp; @@ -155,7 +154,6 @@ struct ufs_mtk_clk { struct ufs_clk_info *ufs_fde_clki; /* Mux */ struct ufs_clk_info *ufs_fde_max_clki; /* Max src */ struct ufs_clk_info *ufs_fde_min_clki; /* Min src */ - struct regulator *reg_vcore; int vcore_volt; }; =20 @@ -174,6 +172,7 @@ struct ufs_mtk_mcq_intr_info { struct ufs_mtk_host { struct phy *mphy; struct regulator *reg_avdd09; + struct regulator *reg_vcore; struct reset_control_bulk_data resets[MTK_UFS_NUM_RESETS]; struct ufs_hba *hba; struct ufs_mtk_crypt_cfg *crypt; --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 4CC4E3EBF01; Sat, 24 Jan 2026 12:04:13 +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=1769256254; cv=pass; b=XqvIVp7OepuujYc3FG3DRk7Pp/nUKRXLFtS7XpapDCqlHuWG3yNwCbc7u++K3ph9sD/F6zhdjkBg1pDVkTYrNun0MnOiD+rMgro8AqY/mfTNDtlVy84/q4Vdsl3aNXFBounpawNBzC3sxy5ZA1WR9xlC5XIafZaY7tNuwIRhm74= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256254; c=relaxed/simple; bh=SpGeLpEgyM07xuob8S2lBFWXcQOp0Zuis5EE9dPmPLs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WTwVh1xQ9dQExT2Icnqt2IiBEIlHc8G7hZK8chsaRKPkNOjflquRinqZ8L5mJCoIWR5bUvx63MmdiXmVkavtRtOeCUNNejgopbZ3jtfsDm5JpEn1XuY4Y4JPlnvMWnCUGgzxWulGtjTY1E9aOQ1nI6JVH1PE2v3ugJA4nQYygj0= 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=dDEGlqS+; 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="dDEGlqS+" ARC-Seal: i=1; a=rsa-sha256; t=1769256201; cv=none; d=zohomail.com; s=zohoarc; b=Bf/ocmWs9HP1P9OtBWNHkhKeeFJvpmRI8YvlzsbNb58YepZiz4uiBx1trH8DCupPehRMeHVILNawq0rZlg1li4zVecYWlnmvqVwr3c3S3BswNZQUWWoeSPx7Wvnh0a3tVq4XPqb6AyK2xVGcBNosFfSup18NKHZJtoB+FIOTNJI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256201; 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=65V7XTs18HNx4Cpt1KEkw3iYodmNCBJ2fw83o85Cefk=; b=dGFb8M04Lr+BIY0VXJLU5aW/neMnTiWxJMCHKvyLLzdhvUYUDhYOhOSKtvczgJ4a1lESP2/R8SjmCgIIN1GA0fuPQPBgETRkjdTZAsHySZ7CitLWR0yNOCIfKtsM0dhXEYMU2kDqYjgNR9gHW2VGpORgdJoEF/+Nvdn7+yd2MnA= 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=1769256201; 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=65V7XTs18HNx4Cpt1KEkw3iYodmNCBJ2fw83o85Cefk=; b=dDEGlqS+yJT0WMoShXq5kG57clbT6aytISf8hq6yDtKi/SSu1unt7au43kLNfVac U6NeVzjBLC6JrT/zPB3oGu1ehTFaK8jwAZOpta+s4wjTq+EovAmJ1Ns8cVU9rdC6C+3 MH6Ge4atiydsM5uNssnh/S0Sq2tdtCAJ3RJ7b4VA= Received: by mx.zohomail.com with SMTPS id 1769256200138453.012233039315; Sat, 24 Jan 2026 04:03:20 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:01:06 +0100 Subject: [PATCH v6 20/24] scsi: ufs: mediatek: Rework hardware version reading 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: <20260124-mt8196-ufs-v6-20-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 Split assignment to the host struct out from the read function, and utilise bitfield helpers to simplify the code. Also move the debug print out of the legacy version helper, which means it no longer has to take a struct ufs_hba as an input, and can be rewritten as a pure function. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 65 +++++++++++++++++++++----------------= ---- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index e39412d59847..ee677af6c700 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -797,50 +797,47 @@ static void ufs_mtk_mcq_set_irq_affinity(struct ufs_h= ba *hba, unsigned int cpu) dev_dbg(hba->dev, "set irq %d affinity to CPU %d\n", irq, _cpu); } =20 -static bool ufs_mtk_is_legacy_chipset(struct ufs_hba *hba, u32 hw_ip_ver) +static bool __pure ufs_mtk_is_legacy_chipset(u32 hw_ip_ver) { - bool is_legacy =3D false; - switch (hw_ip_ver) { case IP_LEGACY_VER_MT6893: case IP_LEGACY_VER_MT6781: /* can add other legacy chipset ID here accordingly */ - is_legacy =3D true; - break; - default: - break; + return true; } - dev_dbg(hba->dev, "IP version 0x%x, legacy =3D %s", hw_ip_ver, - str_true_false(is_legacy)); =20 - return is_legacy; + return false; } =20 -/* - * HW version format has been changed from 01MMmmmm to 1MMMmmmm, since - * project MT6878. In order to perform correct version comparison, - * version number is changed by SW for the following projects. - * IP_VER_MT6983 0x00360000 to 0x10360000 - * IP_VER_MT6897 0x01440000 to 0x10440000 - * IP_VER_MT6989 0x01450000 to 0x10450000 - * IP_VER_MT6991 0x01460000 to 0x10460000 +#define MTK_UFS_VER_PREFIX_M (0xFF << 24) + +/** + * ufs_mtk_get_hw_ip_version - read and return adjusted hardware version + * @hba: pointer to this device's &struct ufs_hba + * + * Reads, transforms and returns the hardware version. + * + * Since MT6878, the versioning scheme was changed from 01MMmmmm to 1MMMmm= mm. + * In order to support version comparisons across these different versioni= ng + * schemes, this function transforms the older style to the newer one. + * + * For example: + * MT6983 is transformed from 0x00360000 to 0x10360000 + * MT6897 is transformed from 0x01440000 to 0x10440000 + * MT6989 is transformed from 0x01450000 to 0x10450000 + * MT6991 is transformed from 0x01460000 to 0x10460000 + * + * Returns a u32 representing the hardware version. */ -static void ufs_mtk_get_hw_ip_version(struct ufs_hba *hba) +static u32 ufs_mtk_get_hw_ip_version(struct ufs_hba *hba) { - struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); - u32 hw_ip_ver; + u32 version =3D ufshcd_readl(hba, REG_UFS_MTK_IP_VER); + u32 prefix =3D FIELD_GET(MTK_UFS_VER_PREFIX_M, version); =20 - hw_ip_ver =3D ufshcd_readl(hba, REG_UFS_MTK_IP_VER); + if (prefix <=3D 1) + FIELD_MODIFY(MTK_UFS_VER_PREFIX_M, &version, BIT(28)); =20 - if (((hw_ip_ver & (0xFF << 24)) =3D=3D (0x1 << 24)) || - ((hw_ip_ver & (0xFF << 24)) =3D=3D 0)) { - hw_ip_ver &=3D ~(0xFF << 24); - hw_ip_ver |=3D (0x1 << 28); - } - - host->ip_ver =3D hw_ip_ver; - - host->legacy_ip_ver =3D ufs_mtk_is_legacy_chipset(hba, hw_ip_ver); + return version; } =20 static void ufs_mtk_get_controller_version(struct ufs_hba *hba) @@ -1191,7 +1188,11 @@ static int ufs_mtk_init(struct ufs_hba *hba) =20 ufs_mtk_setup_clocks(hba, true, POST_CHANGE); =20 - ufs_mtk_get_hw_ip_version(hba); + host->ip_ver =3D ufs_mtk_get_hw_ip_version(hba); + host->legacy_ip_ver =3D ufs_mtk_is_legacy_chipset(host->ip_ver); + + dev_dbg(hba->dev, "IP version 0x%x, legacy =3D %s", host->ip_ver, + str_true_false(host->legacy_ip_ver)); =20 return 0; =20 --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 EBB912DF132; Sat, 24 Jan 2026 12:04:23 +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=1769256266; cv=pass; b=OZZeLSAoCTCudvqR9KUcEiDcUTKIQzHhxZImsFlQ7E2y4q9HrrErbZ6j0v7axkAEnxLWeXO+11vRUq6msPEU7vZ0UbdUiY4qmuJgk4dvAUkiODChFbLLB7P7zTQXmtJABBmXTmYo2U5IZ8zWUpnVvsAvfmEaaQF7Mon8JsKOKRM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256266; c=relaxed/simple; bh=QCQ4hA87lx90cl5D2DflvZcY5lK3eiM9J/GSsCiR6W8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pawJ+khysN/7m76Cikex+Ms9lSYpo0kDVOywQ5sdEvToOh/XoZWtNxeM/fVAgjTKRvJVblFSBY4XysB16VSeR7P8mskmK2TVsgWfk5OYMDoUi/vWWVzSEBy19RgdQ2fP5mxbFzGPs0MC7jAbp6xm6CiMVd0NbsimCXUd2YGhBO8= 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=O5v/LPLk; 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="O5v/LPLk" ARC-Seal: i=1; a=rsa-sha256; t=1769256209; cv=none; d=zohomail.com; s=zohoarc; b=nIpbV4NroEGaItGJSYUe87CifTj6uMBapOjLHlBy5mqplweJ6PS9XWWBqLZzVmOftSQlwPBTCkHT3XhnstmaC7FkFgU+Uclyh9emk4dNln5kk0ij9X4b5PZgyhcrN4i/4XJ0AQ61O/5i+5nM/JIWpP4eHQGJsdnGvYP4ou3NiUw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256209; 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=zZyuoBxgTeDQ4X+4RS0Rrin+WSXPRF/Xps8zmpFmJ0o=; b=Fa/sXq+WJRgaQChLH1dNq5jh3+EhTG8mwAIE2VCy/b1JfuItMJttTltxaueqBe6Q4tFgE+2mrdT8I2E+ddeAyekalQq5ENu3Z3RpBbwpJyI3BqQyXGUhVJSeFlA7EGADntVYzVKKh1mulDIN89rM8OvWRfU13m3QRIQdHJI11EY= 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=1769256209; 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=zZyuoBxgTeDQ4X+4RS0Rrin+WSXPRF/Xps8zmpFmJ0o=; b=O5v/LPLkXx6gWRqbdIvyd+peBH94QHmsj4yK8Ey9HNGXQSKFS/v9F6BoVZVBcEBC xpOjOKhumM0sGd61W/0tksL9HOBtcXrs26BWMJtezD76bgOmqlOH3/c+6x8HCKY/c4J eC3+OOO11h414RYjbfL/JNKNTGhMiux04m/He/ZM= Received: by mx.zohomail.com with SMTPS id 1769256206837968.7228445455696; Sat, 24 Jan 2026 04:03:26 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:01:07 +0100 Subject: [PATCH v6 21/24] scsi: ufs: mediatek: Back up idle timer in per-instance struct 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: <20260124-mt8196-ufs-v6-21-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 driver uses a function-scope static variable to back up a hardware register across a power change in the ufs_mtk_pwr_change_notify function. This is dangerous, as it's only correct if only ever one instance of the driver is loaded, which isn't true if there's more than one device on a SoC that needs it, or it otherwise gets loaded a second time. Back it up into a member of the host struct instead, as this struct is per-instance. Rework the function to not use a pointless "ret" local as well. Fixes: f5ca8d0c7a63 ("scsi: ufs: host: mediatek: Disable auto-hibern8 durin= g power mode changes") Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 20 ++++++++------------ drivers/ufs/host/ufs-mediatek.h | 1 + 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index ee677af6c700..046e2f9bb6c7 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1398,28 +1398,24 @@ static int ufs_mtk_pwr_change_notify(struct ufs_hba= *hba, const struct ufs_pa_layer_attr *dev_max_params, struct ufs_pa_layer_attr *dev_req_params) { - int ret =3D 0; - static u32 reg; + struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); =20 switch (stage) { case PRE_CHANGE: if (ufshcd_is_auto_hibern8_supported(hba)) { - reg =3D ufshcd_readl(hba, REG_AUTO_HIBERNATE_IDLE_TIMER); + host->hibernate_idle_timer =3D ufshcd_readl( + hba, REG_AUTO_HIBERNATE_IDLE_TIMER); ufs_mtk_auto_hibern8_disable(hba); } - ret =3D ufs_mtk_pre_pwr_change(hba, dev_max_params, - dev_req_params); - break; + return ufs_mtk_pre_pwr_change(hba, dev_max_params, dev_req_params); case POST_CHANGE: if (ufshcd_is_auto_hibern8_supported(hba)) - ufshcd_writel(hba, reg, REG_AUTO_HIBERNATE_IDLE_TIMER); - break; - default: - ret =3D -EINVAL; - break; + ufshcd_writel(hba, host->hibernate_idle_timer, + REG_AUTO_HIBERNATE_IDLE_TIMER); + return 0; } =20 - return ret; + return -EINVAL; } =20 static int ufs_mtk_unipro_set_lpm(struct ufs_hba *hba, bool lpm) diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediate= k.h index fa27ab4d6d6c..e5a3f70e7024 100644 --- a/drivers/ufs/host/ufs-mediatek.h +++ b/drivers/ufs/host/ufs-mediatek.h @@ -187,6 +187,7 @@ struct ufs_mtk_host { u16 ref_clk_gating_wait_us; u32 ip_ver; bool legacy_ip_ver; + u32 hibernate_idle_timer; =20 bool mcq_set_intr; bool is_mcq_intr_enabled; --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 6EB4726F2A8; Sat, 24 Jan 2026 12:04:03 +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=1769256244; cv=pass; b=iC4qmUKp7nEe73Q5AQuZvMEpVqHs5kKm59X+3GukBmlNjsx6cXuh7oOFog2ZJTTNkeEY9Y6GbERhC0QJZ+mlpZnGAl6g/0zz72RXEgjP483HTVM/bkrbPTRnNRupvTMuDrKDalc0XCAX1C6a6sa8DI68alSfFSYnqZK5zGfYkmw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256244; c=relaxed/simple; bh=vobilx03E+xmFtwRk6hqTwjMLZi4UPmQi7pHjE2UKHA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sMhAvrKbqcbKnsCOPv4Cx+EAK21Em3P7h1t967VlqJeYGt59HVve4WImpi47eDWN9ve+6IIYj8t4hZs+CCtVoYhqRPv3jpu16o2jOScksFvb8OpLHPC5vSc8V7TitdH+bWU+Ge2BbvBUVMS1srbvxa2J6LITHYgZ/7vRIjXYQ8E= 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=T+UpmyHT; 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="T+UpmyHT" ARC-Seal: i=1; a=rsa-sha256; t=1769256215; cv=none; d=zohomail.com; s=zohoarc; b=lwFDECibAK1lHQRqIM08/FjRL9i5IJ4Q4UuLAc7XCAkDk3cirCk7OyLsUXq2Nt5KwyGOTglGDNXxXcDsapQzliyeVDs4wwvImeHjnhiw7NRh4471rlqX4jznuuVT4D84agR329mSnF3GB7cvDkznDVWsUoDugKASQQTtDxPEfNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256215; 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=IwwnmuAPN5C3mRg40eyyOITsRVUqtofDe576sNby2MQ=; b=QsZe1xEKvKTdz4tAOLB4qj4WAVIm+bv655YJSVDV4D09+n2m5I60mdsnhtndM7ppH/Bwx2L5dfwJ0vgAOnsQRZg+wcgVqXk+wvoQHLjnTrMuV/y20DO6HhlzOqGHzBRF3Q0Q8Yc0wBx6h8aPnueZH6V+72OiFXak+gbTLSWu3Do= 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=1769256215; 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=IwwnmuAPN5C3mRg40eyyOITsRVUqtofDe576sNby2MQ=; b=T+UpmyHThVANsaAZKUDKGfb+5S4zQDnrBRPog9OmrxsKp1py5ZGzJfxb92kjvGju TUnMe7os69Jw1RFT+BHLueZwfNeDm8DJNyw+UtIZxkcEb3NCvR3BufFtowM760bUOZg +F9h/ucFsDh9EqMDZ89SYwIqd65iJYTNJCzVwBvA= Received: by mx.zohomail.com with SMTPS id 1769256213273593.3161087498282; Sat, 24 Jan 2026 04:03:33 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:01:08 +0100 Subject: [PATCH v6 22/24] scsi: ufs: mediatek: Remove ret local from link_startup_notify 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: <20260124-mt8196-ufs-v6-22-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 Remove the "ret" local variable from ufs_mtk_link_startup_notify, as it's pointless; in all cases it is assigned, it is returned right after without being read first. Rework the code to just return directly, and get rid of the default branch while at it. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index 046e2f9bb6c7..e863e4f8af55 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1500,21 +1500,15 @@ static void ufs_mtk_post_link(struct ufs_hba *hba) static int ufs_mtk_link_startup_notify(struct ufs_hba *hba, enum ufs_notify_change_status stage) { - int ret =3D 0; - switch (stage) { case PRE_CHANGE: - ret =3D ufs_mtk_pre_link(hba); - break; + return ufs_mtk_pre_link(hba); case POST_CHANGE: ufs_mtk_post_link(hba); - break; - default: - ret =3D -EINVAL; - break; + return 0; } =20 - return ret; + return -EINVAL; } =20 static int ufs_mtk_device_reset(struct ufs_hba *hba) --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 C383E2F3C30; Sat, 24 Jan 2026 12:04:28 +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=1769256270; cv=pass; b=H7jYuhw/8J7EmRfQM7m4BJiebYGbMxv32A3WLpcjXXol9otsTVA3Jk5NaaebI08t2GyyPuW4Gs47g1zkpqsxff9KnnUZkiWB5TzWBMMQcpxU9lTUixeZram7binBlrtGOkGCXdtu1VAY8MmQZkGE/h0OkzZNlMojIeH2WN+Q6NY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256270; c=relaxed/simple; bh=vZ3LOu+wQWKPs2oaFOfd6lc4PTECPG7VVlUg0ftazfo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hkw54HFStsHzj+XBe7JLsQYKvl+ZK6+WTRZzFdd8F+pSbFHtRXc8v1phxVjpXHY/28Rsm9UdNeBiHBYCH3IbkRSpigBJ4KojqqsPDML1XbrDJR6w+ngW1+/mVK/u6tUFsoHNfMsM1dIH/ZUXqiQJ1T5Y6w4q25sLx44YPElmJJE= 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=NPkA+uq7; 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="NPkA+uq7" ARC-Seal: i=1; a=rsa-sha256; t=1769256221; cv=none; d=zohomail.com; s=zohoarc; b=gkvlXziP+lgOfKPzBoot3qqY3Nw2rn6fYHXYBSlEBNdlICA0ExaZRoK9SdLCbbq7lxYq/54OktdIa0QHhsuVltHgXgRV2JwGMqdVf8H3JE3CQe1ghXKLgTCrDLAj34emx6pIvP+KMcoFuyvwKXT6BxPp5S7Izx7kVH7LLq3gIF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256221; 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=d2ImRJ75pZduojZEXoZjZ2G3lk/uDGjJ8V1tW99jraA=; b=X7AHvEeT/KeUQNbUPTUCPSDxDKPbNiCy+X0tvK0R+Fj3ThWHjdfcLUO+qMvA1PLabu+b7Jj/2jLXiz12CTgmojR/gWmUYn4NqhMyAtZRSwVWSfWfoiJ+/YWUkSJVl7FWdJlx1M7005MU9aKEOIOO7q4i5DVQC7nTQ8ufN6f8jAs= 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=1769256221; 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=d2ImRJ75pZduojZEXoZjZ2G3lk/uDGjJ8V1tW99jraA=; b=NPkA+uq7VOYQMnrPLgNxDnMPFtUwLxyGCMXl1qAVTXxvmnpksVAo4z6/7tKIDoVN 2La/lY3Wnd9tDoCPWfli/KDA2eNOQLunuR3WRIWbxrnKKpaWgx2QISyxLgVvAKMnija U2foZIhOH/zSUpM7b+b+y5jmW+s+dBNnNSWnCtbQ= Received: by mx.zohomail.com with SMTPS id 1769256219717617.1320721102721; Sat, 24 Jan 2026 04:03:39 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:01:09 +0100 Subject: [PATCH v6 23/24] scsi: ufs: mediatek: Remove undocumented "clk-scale-up-vcore-min" 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: <20260124-mt8196-ufs-v6-23-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 driver contains support for an undocumented, non-vendor-prefixed u32 property named "clk-scale-up-vcore-min". Since it is not part of any binding, and would not pass a bindings review in its current form, remove it. To return this functionality, it needs to be resubmitted in a series that also introduces it to the binding, and justifies what it is used for. Compatibility with downstream device trees is not a valid justification for its existence. Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index e863e4f8af55..dfa104207cc6 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -880,8 +880,6 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba) struct ufs_mtk_host *host =3D ufshcd_get_variant(hba); struct list_head *head =3D &hba->clk_list_head; struct ufs_clk_info *clki, *clki_tmp; - struct device *dev =3D hba->dev; - u32 volt; =20 /* * Find private clocks and store them in struct ufs_mtk_clk. @@ -918,24 +916,7 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba) if (!ufs_mtk_is_clk_scale_ready(hba)) { hba->caps &=3D ~UFSHCD_CAP_CLK_SCALING; dev_info(hba->dev, "%s: Clock scaling unavailable", __func__); - return; - } - - if (!host->reg_vcore) - return; - - if (of_property_read_u32(dev->of_node, "clk-scale-up-vcore-min", - &volt)) { - dev_info(dev, "failed to get clk-scale-up-vcore-min"); - return; } - - host->mclk.vcore_volt =3D volt; - - /* If default boot is max gear, request vcore */ - if (volt && host->clk_scale_up) - if (regulator_set_voltage(host->reg_vcore, volt, INT_MAX)) - dev_err(hba->dev, "Failed to set vcore to %d\n", volt); } =20 static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba) --=20 2.52.0 From nobody Sat Feb 7 07:24:36 2026 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 DB1982FDC5C; Sat, 24 Jan 2026 12:04: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=1769256273; cv=pass; b=RGCWWK2PlnmehHjS80DEX8hsVhidlYdy1+Gvn2gdm6UDdzSYSFCnVUmg/va9cfs6TVK9Te5iPuX1uQyKVlYkixQOWw4hPIm3YPGJ+mBakjAZOhFh1KbEnnf/w1aS0EULClSPs3pNw8BGagwG+vGNBGMNtIU4Q/m8+UHg4E+M2AM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769256273; c=relaxed/simple; bh=ymW4BpyME1X2O1TrkGsy7Yvv62Hi7pyk1DGYNHJlEdc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=abrW0gshsQuUAnwK69STkza34z1QdHJ3zwdWDRoD3Ld+eEgDy1J4hYEzZtHR9XjfpGjlzMFrcbZyE3L3xeC6L6BdZAUXBXnsDwONi7tfTDh++wSqx6TBWc+qiGJSG4myCBoZIci1bEFhNRXa9ruQJEZ+h/q+gwZsNKaBshyflb4= 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=TcFOVL4X; 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="TcFOVL4X" ARC-Seal: i=1; a=rsa-sha256; t=1769256227; cv=none; d=zohomail.com; s=zohoarc; b=Clmph66c94IkTIeFRDIF8uqQCZD0OX5C0zjCSQHa+E8HMyrlBFuZIO55+iCftY2FNeBSohKO1e1M+pvXO90Z66QKDuW+K6OXWXD27kDHjcAZoJpPbbSwNypSKmM06FZI1hF/N+RH10DMfnZVP5+pZ47Mm1TMOKd4t6SnWAJDgKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769256227; 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=LSb03+iC1nJjGHi21/8jtlMcWILa2md04bWqw4bZO+g=; b=A7NzvSP43SjlBOsqyqsh6tWWEfIDkwKvQATp/CMxU93a8LNMMF+yHj7D8rC2PXpi5lxP8blrvQnK28TvgNlNmFU7WgVN7Fmjj2ilzulFZlqvrv/pwofSXTETTFdfJ63PDBBnTZoqdrn3LmT6XmE6VO7NM3mvIFIdwjHqKSRwOks= 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=1769256227; 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=LSb03+iC1nJjGHi21/8jtlMcWILa2md04bWqw4bZO+g=; b=TcFOVL4XNUY/+o8oOD0KIVHFBvmpnR947eGoY4oX42HJxfgpk0RuImS4IPSQLC6W 5oJxuaiJBeIgWNXJm2152499ITSDkK+nfEWGNan+Asnc3ywcpRcS6iqeXSqPpRqrSfm EaMg1JFRIbqJTQ0uDNXzCJ/D6acaqxHQl6+4KQ7g= Received: by mx.zohomail.com with SMTPS id 1769256226151691.4301652673644; Sat, 24 Jan 2026 04:03:46 -0800 (PST) From: Nicolas Frattaroli Date: Sat, 24 Jan 2026 13:01:10 +0100 Subject: [PATCH v6 24/24] scsi: ufs: mediatek: Add MT8196 compatible, update copyright 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: <20260124-mt8196-ufs-v6-24-e7c005b60028@collabora.com> References: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> In-Reply-To: <20260124-mt8196-ufs-v6-0-e7c005b60028@collabora.com> To: Alim Akhtar , Avri Altman , Bart Van Assche , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Chunfeng Yun , Vinod Koul , Kishon Vijay Abraham I , Peter Wang , Stanley Jhu , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel , Liam Girdwood , Mark Brown , Chaotian Jing , Neil Armstrong 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 MT8196's UFS controller has a new compatible. Add the necessary struct definitions to support it. Also update the copyrights and authors, without tabs following spaces to avoid checkpatch errors, to list myself as having contributed to this driver after the preceding rework patches. Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index dfa104207cc6..122bc741294d 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -1,9 +1,11 @@ // SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2019 MediaTek Inc. + * Copyright (C) 2025 Collabora Ltd. * Authors: - * Stanley Chu - * Peter Wang + * Stanley Chu + * Peter Wang + * Nicolas Frattaroli (Major clean= ups) */ =20 #include @@ -2200,6 +2202,10 @@ static const char *const ufs_mtk_regs_avdd12_ckbuf_a= vdd18[] =3D { "avdd12", "avdd12-ckbuf", "avdd18" }; =20 +static const char *const ufs_mtk_regs_avdd12_ckbuf[] =3D { + "avdd12", "avdd12-ckbuf" +}; + static const struct ufs_mtk_soc_data mt8183_data =3D { .has_avdd09 =3D true, .reg_names =3D ufs_mtk_regs_avdd12_avdd18, @@ -2212,10 +2218,17 @@ static const struct ufs_mtk_soc_data mt8192_8195_da= ta =3D { .num_reg_names =3D ARRAY_SIZE(ufs_mtk_regs_avdd12_ckbuf_avdd18), }; =20 +static const struct ufs_mtk_soc_data mt8196_data =3D { + .has_avdd09 =3D true, + .reg_names =3D ufs_mtk_regs_avdd12_ckbuf, + .num_reg_names =3D ARRAY_SIZE(ufs_mtk_regs_avdd12_ckbuf), +}; + static const struct of_device_id ufs_mtk_of_match[] =3D { { .compatible =3D "mediatek,mt8183-ufshci", .data =3D &mt8183_data }, { .compatible =3D "mediatek,mt8192-ufshci", .data =3D &mt8192_8195_data }, { .compatible =3D "mediatek,mt8195-ufshci", .data =3D &mt8192_8195_data }, + { .compatible =3D "mediatek,mt8196-ufshci", .data =3D &mt8196_data }, {}, }; MODULE_DEVICE_TABLE(of, ufs_mtk_of_match); --=20 2.52.0