From nobody Sun Feb 8 15:08:15 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 3C3612DA75C; Thu, 8 Jan 2026 10:50: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=1767869440; cv=pass; b=Bxx/K7H2Xb8fcqQifH5zRWCG8YBWDQbgw5OpYOtUmeLHRn6Ei3rHUqEgLGRVZvt+7VfF2BnyT/9YV9ka+WyZlim6G3Y8zPD7/ji8aLfblrOAae3Ke92s6wVtfTEAWpEEHfKNYiCfZ6B7U2zUVPVb6pEYwbisr8BaZvy859A8Fwk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869440; c=relaxed/simple; bh=WNEhM1BJ5VBqtLc9zwYWrs8k9OBKuHWoDi6Ou2twFtA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=onJuYY0Dp4fx4GfvuH1BaGj8wdrzkk7x5u63pLQtW3NVQwCBxvE8iveo0HjAltMkVrRHTea5lQ/beOfEbZKqN0RIQo9z8Q6g3+pPdubnlvAbPFSnnIchNnDA6Lao+lN349bTlYurgxe7tYFMvEA34PbqW25Qjbh9KhabMsW9I+E= 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=GvDAdSKP; 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="GvDAdSKP" ARC-Seal: i=1; a=rsa-sha256; t=1767869399; cv=none; d=zohomail.com; s=zohoarc; b=oEWONl57XBuz97zesnQfAjIh7Vl3/H90/FH4nOp8ji6s0nbFEMkoixJei+Yx+WG8JJWsWCTRPtjkFT3h+tvWWXqP5spxXzm0VigUI0mL1qNC0iGa16hKvthyYC7cFZOYhoonlEAEPUfWMA5WrkglZr5E/0aUEqg2C+z7bQArlTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869399; 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=oJn1wKo+Q6qpeDquB3GxZDp0b/7m47GEklHzn8KdBk8XNYHrMiwdSdRGOMJHWJf3E/D9efIsAe3Quz6iK7InHD6tSdTQ25AbDAz/DlXPaKST+m6El/qw5APspO1ZlK1lAcRcp+o+ILaB5Ov/XYruqAul1k/CtxoYibdNsp/jPDU= 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=1767869399; 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=GvDAdSKPnTiXg/odfQ49Z85YdhUSaPuWMhAx1TefItl6l6yCtGFR76ztsd6Qf7b/ iWV5P75SgucQzH+lMV1lZAplwrbFpu8qXU6d85s2i0ufgHdgFr35iexjvTbWUGLg3py qfNz5iR+jx9HzHEUtgPYbfffI4a4Uqjt5Lmw2liQ= Received: by mx.zohomail.com with SMTPS id 1767869396599127.73017578228576; Thu, 8 Jan 2026 02:49:56 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:20 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-1-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 35A003D666C; Thu, 8 Jan 2026 10:50:38 +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=1767869449; cv=pass; b=fyIkcqLf5bmuF8iUD6t8raBRSsBAXXdy3/Rtf7XM0redEXNu6+1Z4En9hCq9KA/9LLtJiFIFCoE7Qx9iRspPqK2QG7epLn9Vk8HEc4dLpSmW9KDvLxzZ3t5x2Le9Hiu+hTa6du0318mbUCXNO5dysUwbIg1MFWSEQrnXAxTKy9A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869449; c=relaxed/simple; bh=PbDJ2/6zTQ7CzKLtCppkJtHVPmZ7kWiye2El5FFPplw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Sujmyl+UzI512NcnAM5qN/8ZBY7i0eIbTP1/DrXNd/spu45D2Uh05uQbgUrzpvJn7M/seV+Jj8DTmLqWg1gGKShjjtQoYg1GuLwyW9uHfqOdnXllb/71onG1+09SE+OfNEBs/40tGotZ6FgW3wEVvB16ni8SjsJIXoFKmuPMhgQ= 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=W7K+nhcT; 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="W7K+nhcT" ARC-Seal: i=1; a=rsa-sha256; t=1767869404; cv=none; d=zohomail.com; s=zohoarc; b=QICFg/rcvGAEBawEOpaooyHJ0tAeKJmtud62grXe3m5g8zC77Oh7u3Jy2bSiLsUpWFB8mJh75PXtn5n8wYfvorWY5UgDlEW3YvSNzZP4zSBpqjp2OGait6s91EjYADsvqmHxe1C8u573f9uKdLzPf6zT7FsaJugxaQAzGxiCYBA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869404; 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=n1ZQdn7ccZFmnGGEpDqJkvWEKKv3sZN1zPI2+Bcnhr5vp68RaU8qqlTjz1UEduV/B0Fo0q+4z+UBiB4xRNYdeFNDfu4G2+12y6dr2Gdtf6rcX5L0OpPg0nujWS/bGgJUjY82tKhW8HUw1gbVt9kg2rBIWM0sbDn1Zaep6dBPqOo= 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=1767869404; 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=W7K+nhcT+6Mg68vnrsPyQIi4tuD5Yr7fuwazKoW0wOkMwIlJODoOWPFrJFxw14NW NQx+M/3Vtbc/W9ME4wh6xhf47ojHmnxSXFpm5ytulgABommtGJGgm6Lj5ZIBNXDoQcF mbgRUk4EzPfWIEhMquR+P89UhevQ5S4cPQxMnTsM= Received: by mx.zohomail.com with SMTPS id 1767869403096957.6193283099534; Thu, 8 Jan 2026 02:50:03 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:21 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-2-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 B5E534963B0; Thu, 8 Jan 2026 10:50:41 +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=1767869447; cv=pass; b=oG7cVZu91hAIgg4cHAQr2Rk3+CljJL39Tn1NDRWPdA+UfHIRP0W0lrYEd0QR7IAS8nxsmy5KAKa/pxStRIgkMR+g7EhEYzy04WnD5EVwhqAPILQQ4daRmoSuoyDVFCvzU6uqZMBqZCgyk101kYoRVBSUryragBmTro9Jz9LcPFk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869447; c=relaxed/simple; bh=Tk0oAS6OhREK6lUdo3KbLA7MC7i6rRFzjAfUWj2AeYk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HvWQNCjP0p4Oq3wo49tRvrKV0ZUWgyJl3NNnHOXZt9d6IlFfAEN29jozmhqRrj5xj3ACpe66skCUCl7X5SV+ouRVY0wr8kHHo1pFXPDnNTD8OCA5cUaBsHePNfBFKc+KChO9iWdLLpO2qhsqHWYMHjpGJqQjabcaU24yGow0mJ8= 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=Q1I0qCEr; 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="Q1I0qCEr" ARC-Seal: i=1; a=rsa-sha256; t=1767869410; cv=none; d=zohomail.com; s=zohoarc; b=Hb0bqOACXjW9nULnVnocMyiRCQLSdACvLmGVUeP96pi/m99TjeYW0aIa6ipT/vMV3tw6S8wkSnF9mfitRXouFzSKBE3o2WdKAEIJGKC6bhXMXbgjRzmAneWWoZL79UK7/XMdR+PCw8OtqpCryI2DwfIT2t7T0tuBYzrgETAkT2c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869410; 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=VRsgeL03VJ7TychzbYNgFfb4XfFb7Vx1XrQY5kmJvHzf+6/NjExH8kzIrRPNhP7JeOl7avJZpasa9tDyeRedWALX3w9+5oHfqYmo45HEyk60Lj2ReQjIHC27rnMVh3NacX0ChtB7qRMqJlthlPM4G4iUg+m0gGRWlGKwunUDzJc= 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=1767869410; 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=Q1I0qCEr7bO0oXKwQniaS9NDBRKW5ZbG8ynjk8r0WADRMmrMKwe2HWDkvW0BaLBN r85urNDLh0GngW5j6LXwHKQbXk1Pel/AWd4evVJQRfAgBToNz7Novgv8CSGWRoanZkR dmIDapDpEQyPlOvt+woyzUplixnygvfYWcbzAlEE= Received: by mx.zohomail.com with SMTPS id 1767869409673349.5310051421236; Thu, 8 Jan 2026 02:50:09 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:22 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-3-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 26AF43D649D; Thu, 8 Jan 2026 10:50:51 +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=1767869462; cv=pass; b=qYjuo5YJQcfn5htSvt6lxSTrnTYtDNwvzGNBNOX1LqbiBshxJ0faaZfu7H5DGXXSnpA+FdZJC/pdGSx3MJbQQjK0j/7KVzbRHD0G8RjhlfWFzFtOFi7TK4HQ0JNt8eiOhz2FI4ONCs00+T8ju/kZstsWsD0MEH42D2fZarAmhXQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869462; c=relaxed/simple; bh=OlZRisuq3ySMcEiykY74dOjKsIwvwBmncFo6AZmCPWo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UWX8WEuG+YlaSYL8+4nDIae5y7BaIRyJAd60osCMDRbEWQbQnJz5nnQE5IuvF4N6ck8fNCE1CVfuzONEAMmRK04rZDeDlchluV5WmmS/2SEMj9E5BwM8ALrddu3hOQnyJt8cO999qi3mQylm+LY1MoVVgzo9vSCYhGKj6az0fSA= 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=d2Av0B4M; 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="d2Av0B4M" ARC-Seal: i=1; a=rsa-sha256; t=1767869417; cv=none; d=zohomail.com; s=zohoarc; b=fejsO1jk7vNVgSseScmPLpKXfV6M/WIivyWKf2csa6iH0NjWxVSjERR3mH5z/M8WYiqWO6VIwv0Hw6hIaveGx7hr2hzH7Ep41TjKhJNCKz6gL45oIlDN1+XcNWulCS7HOkIf4+BjjFGL0X1QhsU5HBaZ7qvxbta1DJp0BfRaO10= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869417; 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=WRq+JO5hGgx+LnLuxpmj0W2Qy68LJsaUF+sYa4cfT+f++GzPCzzNeOKZO1pyKm7AuCHqOhoDU/ogv7YBbPZzhD4EIZ/EMfmYOfBuMl3PpA9YaSXuVD1LbFezkcNQOQVH5ucL7M/8bFDWuptAsbFpuwMv4F+ciMhedvltjI9HCb0= 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=1767869417; 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=d2Av0B4MWjOLTF3SwuilBU4luCP8wJHFoxKGk7DM/qDhlanBEgZ6mJ5mT9f1ew1w 7xkSFjtGGO9gg2Z9VWx7KAAngKWM8YUGBs/6+/pynFLHpqTY9ZTxxOUOALfI/cBtWwf 4p2yPZSbb9Xuq9a+aFRIn10lrlXukTO28kly6PA8= Received: by mx.zohomail.com with SMTPS id 1767869415991399.72992848391493; Thu, 8 Jan 2026 02:50:15 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:23 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-4-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 520F74B07C2; Thu, 8 Jan 2026 10:50:58 +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=1767869467; cv=pass; b=mwGa8Cve/m5FA7+gTfO9PVdQhY2zNhLSadzbU79DwoYxbOIggovTClajEWyO28nhzw3n4S5WHySFJHB9+wjep3QNiQQNizowliivWUNkw0j6K2hJcXgolBZad8oiLCg/1uuXvwUF6CrnDXWuokeY+yHecA9SY2wtLBpZJ6M/pOA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869467; c=relaxed/simple; bh=aKBv9dRlPqJEyB5f1AzJP5S1FvnsXLvudKhWsJblC2A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=TkQLc4UNQjXiVYo4vSwojcqYSEljlAgoeLxDxNJx2YfOMbMQj54iIEWkFtVsJ3x0bpKS2SEvNnCct1pqiIcuKJKqd1KBJF8/mspqp5danp8iLJn47nDpTUZmu/G6iMDS4nDa2+oad1fwIZFErlAM9Zngua/BzpKaekAoECoO7j0= 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=hlvb/t7S; 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="hlvb/t7S" ARC-Seal: i=1; a=rsa-sha256; t=1767869425; cv=none; d=zohomail.com; s=zohoarc; b=cux0KMqlmVv7vKde5vqDisuTGdPwvNCoSLe0Dl0Jx+qrSFCa27F21FMeYfCN/qdF4wvR0h+OZnf+oxXsK3nF9JiQfl1p7lgLcpuL4kzr56LyfuvQcfldZSlkxmRgSlZ3D3LVfGSqPZNleZo9RlFMtUL+49sSMJj0as04M+wGv7I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869425; 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=bEv9W6bEDq5kkxKMF42/yLwztoKcaL2HO4Bun/8g42BSB6YUsu78jNmIr9JJ9LRMQecEkQ4JartNIslDFMubhONPTw87RknACHXO9Hdy8yPSklfmJoJhPUwkhrj7YZcpG26rHWeuGaeSGerQoPSGRV8LRzPTDRGCUmr1KoPaXoQ= 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=1767869424; 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=hlvb/t7SLaF345p5VN3I83Zs04P2ZXLcs0Pu8pMAVZxU9RzMKxdLcO0GQPS39/il 7TWR4rGSoPr+mAn78DV5n4r+U/IKOJ3fzfA4DGuhS3e9F4iaJLsAFQVjqVi/8WlXsxS +wzrmP72u9b9mIudu6KpjU7Qc+veqp/PGv6D6rhM= Received: by mx.zohomail.com with SMTPS id 17678694224021002.9057402675504; Thu, 8 Jan 2026 02:50:22 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:24 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-5-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 AF4E83C1991; Thu, 8 Jan 2026 10:50:59 +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=1767869466; cv=pass; b=cKnhwlPGINOtriQ96KksGs5z7LeiNWM+QzYAosFg8u38GirzSl3+LAXimNOAwv793fIfPIo30jE3FNN0xQ5O1cujksF57e9cdA7bXrlEq5QKDsyWLhoYNpRGsAoHWgbTuoH7QuAD43teTW0vrvhgr06c+VAnLrON02jVv9d/sfo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869466; c=relaxed/simple; bh=p7+Vi5iubKANhoOBt1NFsjMGZNLHOq9sA+9jnQexWmQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=F7ymzC0jYI7XeuBX0sqK2xD6nz2G/hLOH2pInlOfYTyFoNKtML1aYkZZ+5oDcNb/YaXH3fN6QVSJTY6vgfC+wLj5NyHVJPGR8Pt9hLn7IFYAY0f9+LLIlUih2eQuO3iPN+Shf2KliRkL8jDiTTYFyAN+HbVzMra0xMgENhyghro= 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=LRfW9Q12; 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="LRfW9Q12" ARC-Seal: i=1; a=rsa-sha256; t=1767869431; cv=none; d=zohomail.com; s=zohoarc; b=kgg8MSvx6xNB/D5P9oKdpurrYymS1HnAYwM7eHUDFRO2I8tDfelcKKcaqC26TPr2QejbPNlokcD0/Fv194M1dgDsoqbiWW6xDdALtgbcE+oyjZ09wp8a81N/06sKi8hV6LPRLGgInqcbV3oQQQbn5V+UjcKK4hMKr1RF8ch+cCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869431; 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=HBTMdwwGhMbrjv7xvmKT208We5kZ6iJvEM+7mB0xdPCwQcrDt7Or1VrJzn1/u+10oAyPGXLVnH5YYbL8Q/8nagmBhyhfcpspasLD0TvwyUEtP23ScXToNOx3A/MyKyVJniMyLJBDkAUOvslJ/5JjaGMVZdMKjxl9Usk6xwc/4jk= 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=1767869430; 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=LRfW9Q12m8WCTkkSp7vDXhwtYCX0+RWQGkS2zHTlSwVEQy901fD7ef1PyLpY1tnh 4HwkQ4EvUcmigI3j05VuRKy76UZHybQr0gvzgFoie+sq+myoM8VjMfDp8uH2LsqGTNE 8N3IBBIEzaxil3EGrKAopmyoTQwWpXRIAml6NCHM= Received: by mx.zohomail.com with SMTPS id 1767869428849310.94216837879935; Thu, 8 Jan 2026 02:50:28 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:25 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-6-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 7801E49B412; Thu, 8 Jan 2026 10:51:18 +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=1767869485; cv=pass; b=EUeuqqIIMfKMQgvE0rh6BTp46qVsKnYi4j+08UweNrIycY9vNAMMLHbAUjZyZjZMxRowqUBQfvRXeV3Ybnug5HUF7WL6+d/cTZ9XyuhSf4qWzfsdaPMMQsjLCgEM48IFbIRLdYZXOI3yUA3fE+bue5USdSQk626GgOmgyKWzRjo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869485; c=relaxed/simple; bh=/Z/DE6ZocI0XfXPVllp5nVbpyPqQzUJMrQT8bH8A+U8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fZi5fV7LsjLkQ9XYBD7dajHVAjrIFj+8zso9QNA9wJvx6Y8V2TEBvHWdSbKxV9tPCJN+mSM3CH/bh0okhLjvbHRBxdWw7vIbhSx5FiUXBaRHIRgh0mO6BdFIUJLvU0XKXb1YMTinY5ZPohRmnrXg/RC1LALdhPV0jBeeAdbVdw4= 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=PO6EpxAz; 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="PO6EpxAz" ARC-Seal: i=1; a=rsa-sha256; t=1767869437; cv=none; d=zohomail.com; s=zohoarc; b=lj33BeylALJWzfHROBzgWAQLt0CZRVv35Z8E4/PHuvk1+/t3yFULL9KX+zXIGpNVamDAESQXdXRN8LmOFSCeXCpVv72L2n0EKUFAA2KvwnQxUiWNFhLk1TcPfdUh5YWPPyAR04voGjI/UkxyFjZgbSmZCu9ukmcWSIGEO4h88og= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869437; 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=Q3nAJRYNXjb5JA5aehuFSkBiDkgTjqf8pVKSaC/p/xMMGEWZlbL9V47i9PdXRbaOKjtr9qKWevfa2q/m2v7aH8rRtIVU8iTOJZb263n9gS7wO4sf4jxgbSgDdGmWzjl/pvOPl+3g7tyk3qm7n7vc+d4aQ2rN/jM2vn3CPR76vLM= 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=1767869437; 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=PO6EpxAzICCwclBQamIoWKV2TQRpnNdtl5WKYk9VJF1WEkJ4Jwo3rSzwJpHqdR7+ DK7ruqNpu7ZBVGOe+xINodL/kxWbi0xOoSi020MAsqt5unISjl38LSPAOu0TGhihXuF rwnc0iV6feYd9HX46hcV+GBp0MkY8aW6AVxTUYJw= Received: by mx.zohomail.com with SMTPS id 1767869435125786.9606603578055; Thu, 8 Jan 2026 02:50:35 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:26 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-7-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 0E3F749B3E7; Thu, 8 Jan 2026 10:51:15 +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=1767869480; cv=pass; b=ZdKwURBOpVYrOKj0tmjlEqX7PNJKV91L0qY/8f8wURS1zSlU/HKl50sRs2eJt/MB5PIzUOk+U95EM11+q1yaEpns06Fw6PerbNOTiu+oaP1sNveoTo31G1kOBsTunp0oau6N0xvfil0WuE+OVlOcjF/3mzOLWV97edZHbEXms3A= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869480; c=relaxed/simple; bh=VlDuvSAFYsYwBqBjSsyHGEnx0MllC37fVNB4u5/biYg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tsHodA8BxR3yWWDDuRMp1x+Iq12FG78WI6xYAeyBnPLfcuj223rycBdfbV/FdSsIP9YN4irMtxdLwzctNg0dIJ9ohqJO4PDhAc95fAJeZJtWmGMw1nLieSLvcB0htMHoM+3q4kbIg8PRAXP1lECJAHbFGeWELtbMXObTM7DYjkQ= 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=MtpRE6pm; 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="MtpRE6pm" ARC-Seal: i=1; a=rsa-sha256; t=1767869443; cv=none; d=zohomail.com; s=zohoarc; b=gnaegLFYTjzQb9w/KHBI69mSwoOHYp/AokFJbkkPULM/9p5PIrVtNjfBboA4045BWiHaGVrqbqUowlUOZeQOc/9TIFsR9cChbsrqdSKlw03Vo2Mwn5Cas4m/i3pTcFbcdKzZDN7jfhpxnjxiTUSoFR38KsiBuf7kkjDG/gpzWEE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869443; 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=ZJtIGpi9JbIPXUgPVSAEB369UyooCOq1u80MRSg67SvOmdcJoWyliwJsKQ8CvtYonfUP3IjprJpAusDCkIZT+3dMU0jVpRJJXnY+Ttpl/XyyBLZ6WP04Yik9pSmMtT7XnNM38ZCkuqFx5qcLbbAPxX+ckTzNeTlXqZKFy2U7zt0= 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=1767869443; 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=MtpRE6pmjgnky4tAzD7Xr4aNv4dWmVSDX67hWJb2pAyZN8JgVotTHRkCUtckJ02b o0s2KJTJ99eYvct6uaSjpwMCbJvuhhyhVlCzZd1KzQhL5IDU44a34KcgfSOG3qVOXhb YNiRqmiFgSoFCq7zjlB41cX2D5d8TQjM/pZXdwTw= Received: by mx.zohomail.com with SMTPS id 176786944147897.54331480220787; Thu, 8 Jan 2026 02:50:41 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:27 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-8-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 A820749C208; Thu, 8 Jan 2026 10:51:24 +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=1767869491; cv=pass; b=GdHsoF2T+6WmqslBf3/GfxNYtWwv9MpuIwPmDZ7lCS5UMl/brP843mazjjQz+oUIOJXBLJvmVcvK5h6k43PFN5Ubun7PVbSxdBOh+VECd/EgUo7Gv9loLRnKuPCD6YH9kTLQH/rlcp0Nyvuia8K5bM3vP1RlsylZvS2gqdPQCIk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869491; c=relaxed/simple; bh=7rqevkmcYA1yLF7/xhPzfzPI81cortTnhV25h5gfo4E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gwT2erDSW1uNqV6L0eF6AHku9p84vQ6AnvJDBGhpauggF3AZKYbJeNdwZNEUyXmNrVdsO3Z8z2cH39KPB1iNLPJqNlBSnvzRmdUO98WhQ3YLqOBj9m5LEXRtfDEzWarKYM7s8Bq2OPF3RuxYD1WtUUi8qHo3X/SyU/wJk6qwMa0= 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=IBVfvApm; 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="IBVfvApm" ARC-Seal: i=1; a=rsa-sha256; t=1767869449; cv=none; d=zohomail.com; s=zohoarc; b=HZpJzK7he38WDMsR6txOYANSg01It0c9FlaeBpXG8nRZPl7+gqeZLfEXBuBIerEzmqXkPJdcoMIbZ+7MAC8jcZxXKBniBAnnu538ShJMXfqWpqA64NGycXSoq/Nq/mjW6eZfTJ0EbxR33T1m2jxo0OkWUuexTgNR11Ygf75wAVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869449; 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=R+9w6mMkpGRRfK8oMuVayZ8dotGJl7rMDKB0sz0D5tw833WkXe95L3wSMjE0KwDRFQpQZCGRDWf73lZd5m9Ni+7edNmgnYLtwOHLH53ohnOuQECzNDxrHi2vx2Adg4cVOeTuMZUMHsF4OiuU8EMJlQyfX3d80t1cwTjlzXVjmlE= 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=1767869449; 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=IBVfvApm6rM1vutD2tIPjW6rdM4iRDoPS5/9nQOeV4AZSc5+Rmqm35+P8hr8yMDf WrnmMNsC0CG5xakk7vElvouxy76OZPKrrUMTIQ91TlFBCVfTQlmnD2806BDHIElP3Lf vqcSpC2vzffiY77HelWtsztDOoVhis13GujdmTpM= Received: by mx.zohomail.com with SMTPS id 1767869447792941.762730713929; Thu, 8 Jan 2026 02:50:47 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:28 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-9-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 4BE0149C203; Thu, 8 Jan 2026 10:51: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=1767869494; cv=pass; b=qbq8hHvgGcQcZoogipw7SIAkLK9/ULRSt3l5WSdWRNhzaE5bDovsG1kBGhhft0hSgj+KaUUdgLA9p3DbkS7J/I03luCh9VDafF6fa3v/ylH9xcJPifu2j4k8/kOdqsDjI3ezw5SLoXTJTi3MvkrbeRxBrCrQCcL3XHfsBG3JH7M= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869494; c=relaxed/simple; bh=JxwxF5D1QU5Nd7u0X2s5/Q8hB4vQB03K1hwfEfakVLs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OhgWJZIb1Qa01suIOAhWjfWMsn2/M2cZojXCqCrnLJd+AzXVnFBnWwXvmvS4TOjNRT/u3HfR89ykZbMCSxXHzuj0dJNwU1gQ6qlr5z+6+Nlx+1EdTQ7SoTCK1/rFg6M+fAGbF/u/QyUVBvx0TVRulPlx1VoFAEV0XbMSroKDJxo= 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=fibbHNzF; 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="fibbHNzF" ARC-Seal: i=1; a=rsa-sha256; t=1767869455; cv=none; d=zohomail.com; s=zohoarc; b=mgQcbEgGnS/pDcFbwHz2mUeKZLv6EXy5vHhzUm0/hOT+7f3PBXgLI4NIewi0IhKOfElW7/iuCeQULL5gcGTwESxUJyv1KzXeGybRYMpLG8wDRhznQ8b2zFGp1Xv9ZlNRRFMRZLuAD+oPjfyulwXAvqwAuO5Fcr7KKs6GQCvf70E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869455; 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=iwxqy8qKNVC0MpuSJl7zeOeO03MEdbrLWGOtUIkUDwNkycGa010nj3IPSHAK7rcih0c/fOgZ+DE2wseR6PPN/py1HCYKRFkqNd+ePxC9WZzv35OmRWYai7O5WanDiqtk7LfdLZiG051Ft03MqomzfwgX7Y+ZYMBmZnO++KuX6zI= 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=1767869455; 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=fibbHNzFJMIt+72dnVqMzeWn0+5th2SM4dhL2UdpNHJFXV2gTxhYvgWP1+PebVu0 Q1kcEh07egAogrjxvKQnJqzPO06o86HBpfwEJEq8HuyoOKcN9Za9U3ZzDN3jmO4eHcx w3LSwU4ArLJTqSGybS8TS46uU4nG4a81WoCZEFT0= Received: by mx.zohomail.com with SMTPS id 1767869454156541.967377557664; Thu, 8 Jan 2026 02:50:54 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:29 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-10-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 04EC3499C92; Thu, 8 Jan 2026 10:51:30 +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=1767869496; cv=pass; b=Zw/YE3q3b08YZi98c4HtGT7GLksjb4ch4UiBd2HG7zUSAC33xKW+aS+RRobadB63CWegupB869cWszXODNZcr8kR/LVg+oFTCrRo1XpqwQ81dlQ+RKj5EqOzNPC28Y4lJ5HRc4NgCd62SOjHIPhpcKXfJu9UqFXFTnnQWjFkWps= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869496; c=relaxed/simple; bh=cmfukz7fCvQy0ZuHqRc7829ZpMdStEGanbhMh/Q5suA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l/9ezgYNmLBqN9Aea9ccGpbytrukf3d6aIUokVrSUm+2IKr9Q0TnO9U8gOtl0HtFxdeRQftBBtIsmUmFkeh2H+KhxMQdUwroFDw6Ex/K3nJjHbk8Qh0T9i4fYsihyOJXqRFPMub/CR5XaAOt+K9HCxSfKKpPZKdq5JeU2DpjXfo= 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=JLZ41A3r; 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="JLZ41A3r" ARC-Seal: i=1; a=rsa-sha256; t=1767869461; cv=none; d=zohomail.com; s=zohoarc; b=Hky6toFLvCKiKnUr9sQdn8rh4okj2sc3GXEIJBviTKII4g36EOpihP4HeqijW0WUtEvPHUH+PId2RmQzb1d+QBfn2MNfizWWLI5IRk+zzHTzCryE2hrHg4CFwUOXYv19y7x9eboDZKTBYdL6qxlmGnpxk4mvQycjHT7w8wfQtIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869461; 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=dGUGAX5179S2XvQ8NVi+By/jVOa9HJpDvzmAhKT0VpE=; b=E58UxoOF18Xd+6PVQKdcK5sMJdp41f9Hjw+JY4c5mu/c3cGmmFWww0FP1olCBDPTf1jCkhFpz1wCU/2i3NdWDCdO0ouZVMObrVShWZ5jsF0/qWabUKpl46qHHhZ13WjM+NuKZcpNHBLDA6JUiQvNuyA/h5IHf39ad0Xxu2LhJpQ= 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=1767869461; 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=dGUGAX5179S2XvQ8NVi+By/jVOa9HJpDvzmAhKT0VpE=; b=JLZ41A3r9qarlb/CFVln1MjuKN8+IS4kfQ1RGC7poRysF21KecrlCKW478ck8vLx DjltfKYuS7ErmIl8I1XY3v6pEKcXhJwbexmyikFboOkNUQXmjTlau0Ai33Rtg9pVbVu zzgkPvHYyqs77xFNQlNOooh/3c5YcohB+6QJKooI= Received: by mx.zohomail.com with SMTPS id 1767869460439625.129815799547; Thu, 8 Jan 2026 02:51:00 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:30 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-11-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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. 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 Sun Feb 8 15:08:15 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 9474E3148C2; Thu, 8 Jan 2026 10:51:49 +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=1767869517; cv=pass; b=XhRY4I6v6XxvMPY/ByDGTulhyBe01XDrk2u7JIufhmhqXkcscHvZj4BIVYNACDycD7mi9VkJOGQA7RoIV/nJabF0uCOuZ2doTgulETematTM5YjAVLjWyAJNk4KujqDXE1+9SQpTxd7nkSixmVn7qg6h/Z/kdA+GeN8ACQtoFCE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869517; c=relaxed/simple; bh=Q0wiJIEFxJpZMu7Xbz19ZVCeDYvLHhWPyzlBkJPRkWs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HaWTpXJsjqT4E3MuqZIOd4wDwYNdFjEVaUS2/tLh1OIwwR3BKOuD7fS3ToIyMS1TdxqugdQJtjofwxOdZzt9+al088UIkZACUF2Xx6MCGehonnu68vQouFEjSGnkuEb0uQ7rXxHObUlQdptJiRst2EKHsLqCYeiZvIa+DZn90mo= 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=CYRQtpBP; 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="CYRQtpBP" ARC-Seal: i=1; a=rsa-sha256; t=1767869469; cv=none; d=zohomail.com; s=zohoarc; b=OMyDIfhHNjsrt1N3SG/uIxPiD4MxJUknKUE0JKNbKXzqeQDtuTuR6ikCw9U2nMSdN/w+IadihdRAYllL52ZZwdHiRPLbPVFmZoGW18JYN33eMjkGlI4K6KUK3lwHJoM6y8cx5hqV/YpLoEx6CEVWVA0CkBWXufkWKC5U+1dyfM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869469; 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=QD6W3wut0hyB1PiLK9xeahDwGtZQV1EDGh3AyMCGL3Y=; b=PQ3JR/gdskWqecphQcn2TsFpfgkzs0i/BnAo8vySOwafOMqPsGm4o72Gc9wlOpE3MIiPfLrosll1qAR6bxqSa5aLugwOTN3AqtN4Yo6nTlQfb1E9QmPTgRiYYv43AVBE7G2r4Qfn1d8LC9Oii9lFEF/CMFdf5tj0gpvv5jfQgY0= 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=1767869469; 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=QD6W3wut0hyB1PiLK9xeahDwGtZQV1EDGh3AyMCGL3Y=; b=CYRQtpBPaluld3LUWXdb+jzFSGEnXwrZnFNoev/gCW/VjxPjLlimb5a30osJkav5 C7QZ4cNtju6BzQ+WqDtaKH/FSH8nwx5BOHtoiqRKUtydja22dkXEEVK8ydKqOPS9QOI cr6ygcmsrvBAmsqX1LrlGwGiG5keg92yZz5UWrQo= Received: by mx.zohomail.com with SMTPS id 1767869466815654.0368379902727; Thu, 8 Jan 2026 02:51:06 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:31 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-12-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 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 Signed-off-by: Nicolas Frattaroli Reviewed-by: Krzysztof Kozlowski Reviewed-by: Peter Wang --- 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 Sun Feb 8 15:08:15 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 332EA49C23E; Thu, 8 Jan 2026 10:51:49 +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=1767869517; cv=pass; b=JdNo3ckMjQF17I1+oZ5cnhxBwUE5QRJChhZ3DYUIMX1xVn6Ujxxv573+rvZmgCJgfehrjjs8gNg89TJSv59h9dr/YDQH+JnfiR/IAaXnCtq8SKAnk29RM9ycVLMuPdu986PPU8pxKH3LyDYtNWgpSknUlTgwXnoFRlmRnM8HvXY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869517; c=relaxed/simple; bh=VeDzWlgAd5ceQT/aBFbD/UWPIZMAjbDEUzchKXtC9kE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fhvys3aWfksoGraZQNfT2E612oXKBKbrHHHJjUOQ+OyFgNPUKPdLXEvyrP7CxNKp24CDq1WYd3KnQ527blq8Yp/y3PbwjRHxAWUwpqqY/qYnsLSZe7YiAke5FbW5jWXaHAN1sa91D9m1nD9MoDekGAvePG7SpCKKkiDhiLIS62I= 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=Wda68j19; 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="Wda68j19" ARC-Seal: i=1; a=rsa-sha256; t=1767869475; cv=none; d=zohomail.com; s=zohoarc; b=OSBUocHWXOL3Uhr6RI+dooXCqdxvm8hYMW+0vp/veADAIFH5E6S/T9tIeHR7fFu163QOXkrP6U0jNKX6qooHniopMX7/ubxP6BWoGCZmnixKwOm5zB+TcOGEyzHNJynxA8UKckJSUgZ/JiS0Z1CU8VDYu8D4QpIxTOJ+1GiRe3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869475; 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=nL1QeB1Dl5Inq4okzpB1rPDEJ6ZLq3fTKmpS5XMKbQAI2UEPo7vzJQ0WEp6aX+NstDyGAyxU0tYOYPzFA85/WRKm4m7GXtV2pqamNOS0I/JXQcQx7CMGjwbnSfFDsn+ifB/zPREltSlynRuh1pbJJNoVnu1f/u3DnWswZ/dgXQo= 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=1767869475; 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=Wda68j19gYYd3931s7QNa/yJRRAMHmTyrXIPGA2O3prPy8N00rEYMIxT8ctyoI8V /nb7F1wyBUB8IxVoNonTpEJCW4CQoKR/8VlGj/3kxAfm3rsQ21mWFZf/vfjXyJZ1RSU imWZLqfqNwP+KgxXMGf9TxP3XvW7/lyAjjXPt2q8= Received: by mx.zohomail.com with SMTPS id 1767869473168183.15982009292327; Thu, 8 Jan 2026 02:51:13 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:32 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-13-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 F1236364E8A; Thu, 8 Jan 2026 10:51:52 +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=1767869519; cv=pass; b=M1GUsxVbew/sEX8R9kuC8D1Zb4zvbraymK9EJGLVALkARkKCzhzGGnEAcyJNNoEh9ldNxdOiI0vUG6BbdkLwKZ+fbga7ejXtVAou7Wqo7y+rSuRywqBK9nb9HMmPx3T+yWiovMixHrmuM1YIXOl9Yvsf3972LgkL9EC8yhsxtks= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869519; c=relaxed/simple; bh=UhtPaGwuFlEFDj2CCUlrPu8e8xx653WtlROBXEBmR68=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qZ2FNqrBP1E68QQnHk7ARi/8Rc+Nm4irEZuXuVQn8PmvhZ48xvm4cThpGuqMEDv1scNXh+4dBc2wmhSoltQHo/5ISVE0ulIhWA6EXNTQsi8AQYLfKOVKL4P6f1PXPaU2IGIMF/EqqSXE0P6pnj1stw86mANDrY65qkVrYYOoNPE= 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=ZKIYKlwG; 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="ZKIYKlwG" ARC-Seal: i=1; a=rsa-sha256; t=1767869481; cv=none; d=zohomail.com; s=zohoarc; b=HiV3nOJbOSyePZPF2aan+Y3WdRmtWJncRFz4/hdjovhOJTMNj4TQ2fq3JEwWOsIC+hwMFOxVrGxrr4X2g4+KW6GPodKwB08aLJc7Na+1Ozy9xknWW4LzLKZDnUzx+0zV/TslU27MOrHLABEB+L7ZTgmq7WqC3kmK3nnizFJ0oHw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869481; 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=NFIrzRxeyER08dnFudF9BU7FizaRiU7FM3s7Bhy20CTlzrZzTLyNDZX1Cc3JWzVAg8JJqB3djxgSKjDmCjqbmRImcudiVqyiM/reu2RrZPlCLPvfxACUuU4Tc2VsZSJGo3eMR6PV79LuaZZjRHWR5OV2MaaPAFH3OVsn9iXMneg= 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=1767869481; 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=ZKIYKlwGrGW1in365Z3vvayzCyHcVDGzLouN1wz2Az0Tw8nTsifo1lqnrwZ3nrKO BaOQfi08PmqwZSbpf4HoVuFTuPinUII2vqrLAAcvvsE8lPWMPT1tDhK6nJkYuh85cC/ GB69iijIu5r9bnAZiS65xCHCDO5Z9lQlNJmGmHWk= Received: by mx.zohomail.com with SMTPS id 1767869479482350.55806833022723; Thu, 8 Jan 2026 02:51:19 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:33 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-14-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 2313E49C227; Thu, 8 Jan 2026 10:51: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=1767869528; cv=pass; b=gsie7+lpkooe7AUF0WFHBR+ui0WX6T58L109E8xHFdC2C7P1se3iI5yZYQO4HLL2TXuI/PJWMEDn94jvJ9uPzyC3hz0kGYjTsgRJr7d6cA0VlIawK6KNpBNXD4LliNaguFKMyZPTmC8UB05qa5Mb+gd1Sqv71SoOm21pMowrPZU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869528; c=relaxed/simple; bh=cHE1xwnUUAd8zCMwGUiQF2E5DMP6WCsn2qRVe3K9hiA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FbN4Y5ij5Ga5vcQ4CHdiZEhizV4TQg06f3cEjTPpWzZ4oh4AguGhz1knRG16CXAN9L8vMrxNhXoPW0/FrozVFSq+O/wqjFxc1aLUIZnDV6CE9k9nwaUokWpFxnsbooZyJfoyNLblAD9jIooWFJN/C5ZoHGFuEarMV29Cc5NFIUU= 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=ECkDbJJW; 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="ECkDbJJW" ARC-Seal: i=1; a=rsa-sha256; t=1767869487; cv=none; d=zohomail.com; s=zohoarc; b=QDXPtw3rPiPWIHc9kLwJxjugFAKrnvXvPgr2AnLCUvar8InqE5gR8DoDEGayYtdNl1gX8bU9weULoa88t0RUW+Uiy8guEj1h3WtTMrxbghIjFto0h3zGT+rJ4P4LRuO9Fu9kAhvsIAeEXrHXTt64zhOfVGgsVIfgER+c9ZoQn5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869487; 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=It4X1hfSIhnlb3wLPsMxo7FA/C7q0hfY0Z5wIeFtWQis1BLpgZRqEcvRcXTRKPxngb9cNzDRnqADEdk4dNkUeRRmsMSmAJwm0UL2OnlqyG7mmIlx/T3dT3OhCjkSRqvTLrANP6ABINusfwryPzAcOh587IrsP5vsLuZ8FyrwXyU= 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=1767869487; 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=ECkDbJJWmvPzxcQ0Ux7cPXNmwWFDQhWmsq/lI3TCzxvzLMVEj6R9h0TUQDiHmEa0 BtqRtsaPw1nyZH2C8yzu25IeEvH15RUuezraKQJll+pBrUWNqfBdyNtXycvJHbmfoBF 0myuQmLdhpOOuKJTWGy2KIdALmNDv/YFEIq579fs= Received: by mx.zohomail.com with SMTPS id 1767869485778694.0441057375441; Thu, 8 Jan 2026 02:51:25 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:34 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-15-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 2026 Received: from sender4-pp-e103.zoho.com (sender4-pp-e103.zoho.com [136.143.188.103]) (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 F3ED437B3E0; Thu, 8 Jan 2026 10:52:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.103 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869547; cv=pass; b=XpDTJsuX0qGxHRaNdtOXfL0etPxnI+CNi81CW7rKaZ4cYSfVTYrkgj09OEnl1g9/bGEBhGbZAx2jqIzeYJLUaN9WrQDw6yTO0o84Iw8QqkqMTF099q7k7I3RLgRgkiBNxQif3zz4AWS8b6bTzIjjkscdg9LRDupyi2SdS0uB6Ko= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869547; c=relaxed/simple; bh=T4fM0HiKRgFW8PCxMAZHBV/qHMBU263KJMipbTBkRzk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tm7QPdXK07u3NqH3n/BvzAUVR9xIjafHDdS8awnmx9AGg0quJSIAeJQ0c8A10LzwYHHokIo1rpz7nNtNYxGVAfJNwIjdNfxReBLDpFsm/qe8hVmTwLm5uxUcxphrNfOTf+0ZyjDO99Qu6gAYA8NfhjM+o+auyb9SFPBbvi4Yj9o= 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=ZjACjFEQ; arc=pass smtp.client-ip=136.143.188.103 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="ZjACjFEQ" ARC-Seal: i=1; a=rsa-sha256; t=1767869493; cv=none; d=zohomail.com; s=zohoarc; b=CuIklVb1a3dOOscypZ6EtVRd9zdcVd9uI9/r5CPpqqwEEKUm8U/DynuF1K0HB5HCSLNPQtjRLQMw8EsUDn8Kz35eKvf6OKr3V9rVOijMFvRPV30slLj6m2w7m4hVtfVkVSdGdeQ4ogNTrH0vLW52+q8A/hTFoD+UKsWICvOjq1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869493; 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=JxiCnFEmrzXTnjdgWE2bMgNq2a8UlVMph46hhVY2s8q9vyrqLWGlXSXOTI9+4ANikuaFdRj8T26bmHgvCRdNxIMGvKMK0Zkift8eVr8MUfJxNyFJQbMu/v6MLCd1zXbFJHsifRE4UIxMNcyN6cnAce0lWL4rTOk2WHxc9EmaH6w= 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=1767869493; 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=ZjACjFEQzUX9r/MK3EoxXdcqaqDdPZE2ZsYC9owBFnhlmEBAeCIyWl5CY4pcU9tY 4us/dnPe+PLKsuKAe1ex6ybB5ssaHcO7mlY/8Kbjc+YK4jQTwwkjIz3+DoZ7e+CSPkx 6gPEYK05cXessWfZ1ZlMyHFxZDpFTyVIIMdCLLFM= Received: by mx.zohomail.com with SMTPS id 1767869492105386.5108336612607; Thu, 8 Jan 2026 02:51:32 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:35 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-16-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Sun Feb 8 15:08:15 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 1F4B94266A8; Thu, 8 Jan 2026 10:52:30 +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=1767869557; cv=pass; b=bqY8u84N4SxqJM7TUvdZoKF1M2zd8AOEZ58+jkT0Q7zZlsZ/GFqbN2dc6xw+lZ5yXADlSAMbDetm3yX0dPWtMvyBt8xrOsmMZjICck7JGR0Nh9gdcWvK9rN+n5TKL078rea6zeE5ZSJvRvfzmtxHcmiCImaJhb0fcgpf2N6fReI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869557; c=relaxed/simple; bh=8flzLAr2ahciWqtmUq9pfsvYe4poRPb0kY+uYAD3EHM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qPzSUvcB2JDTTvTqUk+CFiYIBhgVpr2w4XQK9/CKJxyhh+quX/2VU4Rnb8uEJqviNzyKlzdjZqgiQpupagcqNWWTrlobO0tpDrIuEnP+jiZ/yoZdKKcKlCuyKdNK6yail4XW1lOkePVSvi20rNLQ75ybcPhO5RpjW6ydWZam/1s= 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=FcC91bUt; 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="FcC91bUt" ARC-Seal: i=1; a=rsa-sha256; t=1767869499; cv=none; d=zohomail.com; s=zohoarc; b=BVxJ8F9zNdmqeGerP+D++ybHJZHF2c74BDKc5yj76qy71jkvIk8cQDEkL4pj6xBqHJLxeVauCfqrKzgUoav+CHRrjyxb+BAQRvWEeju5u0n2Nd2r1+jGoI7nU+Cj7hgIFiNwIYFtmx17q/Vogpvw0OzWApMEdw6soBGGbeygWsc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869499; 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=458Lt/Oh4ccoveskL5sbXfhVHUcBXn63m/yLt9UTlCk=; b=aHmiAjDJgZPKj4dZ/F2hyPUCI4eCr1An21GWtJdCjgo2CjQvrfJLZZoOhMNurT+M+fSlNO354NR76rxKFjybkkVMbKZKmLsh51sAxYEtblX8RcBzBhmebqR9wKN8ukD42PT4ipNrTtRMnOFOgBo1JisIMHbeG7vC0udzkaEilzk= 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=1767869499; 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=458Lt/Oh4ccoveskL5sbXfhVHUcBXn63m/yLt9UTlCk=; b=FcC91bUtXOvWkqUybO+QhFATu4UH3hTAd5jqnv5aK+Bq6f/s1f0PddMRgem9VPRa ZSFdKI0swW7euYsftVYg9kcDk6GfsbH8j8WpDc7sLmTpYtUU2FCOUvi/QqoTq3YTfWY YlW9npP9LYWzW6yhahao7Vm5i+i7K2qgfGmt2Lx8= Received: by mx.zohomail.com with SMTPS id 176786949840443.34294090996946; Thu, 8 Jan 2026 02:51:38 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:36 +0100 Subject: [PATCH v5 17/24] scsi: ufs: mediatek: Add vendor prefix to 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: <20260108-mt8196-ufs-v5-17-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 Device Tree properties other than the standard properties must be prefixed with the vendor's name. The "clk-scale-up-vcore-min" property, which this driver uses, and the binding did not previously document, lacked a vendor prefix. Add the missing "mediatek," vendor prefix and clean up the error print. No judgements are made regarding the use the property itself, it may turn out to be implementing something that it should do through a different way (e.g. OPPs). Reviewed-by: AngeloGioacchino Del Regno Signed-off-by: Nicolas Frattaroli --- drivers/ufs/host/ufs-mediatek.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediate= k.c index ecf16e82a326..2b7def2cde54 100644 --- a/drivers/ufs/host/ufs-mediatek.c +++ b/drivers/ufs/host/ufs-mediatek.c @@ -958,9 +958,9 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba) return; } =20 - if (of_property_read_u32(dev->of_node, "clk-scale-up-vcore-min", + if (of_property_read_u32(dev->of_node, "mediatek,clk-scale-up-vcore-min", &volt)) { - dev_info(dev, "failed to get clk-scale-up-vcore-min"); + dev_err(dev, "Failed to get mediatek,clk-scale-up-vcore-min\n"); return; } =20 --=20 2.52.0 From nobody Sun Feb 8 15:08:15 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 53DD8451052; Thu, 8 Jan 2026 10:52: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=1767869560; cv=pass; b=psoH0PGiOeI8ouATBxFEnPylq13iAUgwn4JTot/KeFiVWFPHfwGu59qQzGavMRTG18W2J3QQJDHGyppReLKPLI9Tim5EALFKuSdlwczJYkqOxbzM3+WN0S3KqVMitu8TMm9m1JeWbp6qZ4Sn5j4FyE95t7KEo1cheQVpFA3hCUw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869560; c=relaxed/simple; bh=kqIyQt7NEkQSlEqUmR6LqlqdjqrxdPqyl07sIWuuIqM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BI+/vYFTnYX5NfsJ3vlbGLW1CZTQ4fDY9OTa8jmr4AQZbyZgOrvbFRuTpzlZRhC8BRpdb824Zw87h16nQh8tO01GeppH3tSFfktI8k9PQPwvbpzBiB87mYgukflIlchckt8R7B8C+O6bo5Y5VlFUz2r1cbL1Bds6SYSU5MK48ak= 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=Wklxt5oS; 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="Wklxt5oS" ARC-Seal: i=1; a=rsa-sha256; t=1767869505; cv=none; d=zohomail.com; s=zohoarc; b=Y04e26l8tv6btNlc4maXiEVtZktoqYLvRsejC2ErC/WtYhrR9U1L74L2NXK2DpAQ49HJswaRJCudvqZ/NHC6spgaSPA+ws0z+/UBwYCLSb/jq8lYjZAP8YGKOMHUAVx0f37ssnbgX7zFsski3hW/yIDiyns5kA1zvgXHFjXN3dg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869505; 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=0zzshRGMTJOiW70/VRTeC7VSzPEBqleDsHFXVaWhQdo=; b=AvN/k4+pkszcTXW8VNo6qX0HiP12vLl9RFCT3UFuxOE5KbXIdpkMbyK6WhlW36wG9nDiNZxZdoe9FwrUYiLidqWAbPIqxLiY5dSbP7Q/jYbG7wNoEGdsJkkFUANt6Co89ps6cKlWj7o4W0pX/WmEWpOPhkP2h5op8k8RpkRioOQ= 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=1767869505; 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=0zzshRGMTJOiW70/VRTeC7VSzPEBqleDsHFXVaWhQdo=; b=Wklxt5oS7il6GjuOF4HvtBA5kILVWY/DGiVgDsfsv9tbZieF720Fo1LOjSdFHdy9 yX22r/Ov9zMCwzPsdCOZYmEBAeDLOcVXlzJc2N/JHLSKBMaZ9B2HyitR4C1rx75EiF9 JU1p82Wx9YRRsrSrO6ygzQxrXQKyQGvj6pSWOfvs= Received: by mx.zohomail.com with SMTPS id 1767869504677534.810494104054; Thu, 8 Jan 2026 02:51:44 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:37 +0100 Subject: [PATCH v5 18/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: <20260108-mt8196-ufs-v5-18-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 2b7def2cde54..566d61ff9faf 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 Sun Feb 8 15:08:15 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 6FE6347DF93; Thu, 8 Jan 2026 10:52:30 +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=1767869562; cv=pass; b=Z8SkVUAiOMPuugt96gcwT6bVf8oN1To8C0mxxvQ+k42l6la4jon6Ng5kisVGq40P+Jbi6iaxLi8U3uMiPFatJ+FkRFbxSPBkdAU30bsYbzMTGz7LA7JFiFP1egxiwa/MZUBzzG0/PF+LtuozVucjAbE7+83tbm5paznxLsqwg2o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869562; c=relaxed/simple; bh=p4kAAJoss4rWC9SZnRz9+xRAqxTzvMhFOPEjRY3Isv8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ogDfcKG0mhtuj7v7LLK5/aTzt5rfYbTsFk+VY711/DO+8MLNQuRra0MsdHLG6K2gFGDT5+l6LlUa/MZBKEuRX8wo7OXixxc4v6L5R7VNs2inpkJmufcEhkQZhSkYKrscHgLeuTurCsGgrGh1vkQ6fnXAbo63gbpSMIRAHHfaR9M= 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=iVfgYe7D; 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="iVfgYe7D" ARC-Seal: i=1; a=rsa-sha256; t=1767869513; cv=none; d=zohomail.com; s=zohoarc; b=K0g5R6IxazkTqcc64lrpZKUwDZW5UlYViTQpnmR/t8jzXMcMXAO7/acSTSVdFriLY16MdpNtYGbp2e7JZ8GoIyCfudJEyVoE2yDaCliCDwfQ8UsAwx8ibmhbXqocz8rjSqhwSACK6TXSZtmyI0DLEiDu/a5Q/sz2OcZP6byIuZY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869513; 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=tIdBiFKN1VLTCNy0dVr/09sPD7JKEvFNhatqSMTL2NE=; b=DGezRp11fudDB8JvXj+FyR6Q8VOmZhPSvAnBqlpPNFYZEMsmB8amXnXKOOv9CK5FchVkCBljJbWQwYqE5l3AYC4ihVlRfyWz8TyOr6hok0SUzhGVEbYmb/+tlfJ1WNf7DAeo/5yYxEIRNtqArXbIhTt/DtYiweyRUmRF1ickRDw= 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=1767869513; 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=tIdBiFKN1VLTCNy0dVr/09sPD7JKEvFNhatqSMTL2NE=; b=iVfgYe7DnClfsuthZvBs5khvDZEHmbBZNMTapPf3cbeY2XZ9Bi/JAqTSZNCOMBjT cb5lwiL/QfqImCVsgtp0JhTwSIg3JVFqgokhH0TkBaJ4z4ucbVV/7lG7qhCJw3KUTwA uzlfS1LGVFr/x1u1NSiGl/TjH0dhaRAftLK6eDv8= Received: by mx.zohomail.com with SMTPS id 1767869510966264.163712308419; Thu, 8 Jan 2026 02:51:50 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:38 +0100 Subject: [PATCH v5 19/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: <20260108-mt8196-ufs-v5-19-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 566d61ff9faf..f237070afaec 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 Sun Feb 8 15:08:15 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 4F115435639; Thu, 8 Jan 2026 10:52: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=1767869557; cv=pass; b=I0zYdWbz0JgRJ9J7CzqArGrCp/Umda7+lUHn00VtDJEYshTGPRX7OTPrGEwvtpyIR8Jif8F/GpEizQ6deGvV0viN2JEUQbVZJgo6dGOaxLY7HW0M6Lo/OpyrKO6bOrGI748vhy7OdiscuGrae0jjXCn2HzuUYyC+/YL5ZK7JQVs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869557; c=relaxed/simple; bh=4K/6fmSzkBARqiFe65BATy9aflVQLRo0A4hJZj8QDos=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NHR1ngndnK+qljrJLiulIzWJGVoICPGU/OnmPgFcw8U1Vi1DL9uBt6OmB2mA3CetKTEqyi4hEK2IgHKr+AfuzEdYs8aMXvScdNKVxVpViC+D1lRCQXe0I4TePpFcLq7+f+cNi/AEFkVkwyTSnoFab0GxjzrNr9rPk6RxBg3wDAw= 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=LoMoxkgR; 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="LoMoxkgR" ARC-Seal: i=1; a=rsa-sha256; t=1767869519; cv=none; d=zohomail.com; s=zohoarc; b=JSKwj7UDXQP4g9eeSYOh03viN2usAbddhGkPBJ00f9AyOBQNac89Kz6HivrbhU0gOiI/nj21Tb5UeVTCScuKLYHhWO/lrVUOmV5UCWW7YAk4DV5lyMpxsfIoKdp/aM0xIp3WfpXnFwLVq1C9a6WwhEkeu2Hj88QrfZRgh0OfBPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869519; 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=c8OqQt57bjAlQRy2v6V+j+4xlnwG1m1InwQbkoFH9vs=; b=XJWRJ15/iUG+tGD3syNdhDadnVCVxPoGUaenYY+K+pTeZAoX6WUaK/7NMollLVALDThEm4Uqp3rULK1tcervjoiT+lmKubltRwAJzKFGITGPI8+AGuBOyMm+p+COz6V6RoO+Wba028wcAu5WGpJmWBQJFGj8KmOV46liU0Flfek= 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=1767869519; 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=c8OqQt57bjAlQRy2v6V+j+4xlnwG1m1InwQbkoFH9vs=; b=LoMoxkgR1Ps+OvV2cI6EkVinWwxNb91g4eag2C1eSBWSLODlT18pJn08dG3ZlQ6o 438lzkqoLyzlMsg9nz5CQSjcqzLgIh12UfKCKB0N7mseGzwGzjJ0FINcw0iHabawtyx 4s1xA/bCgp8A+llEz6vVJZLTH8wg1C9WphJQpwgE= Received: by mx.zohomail.com with SMTPS id 1767869517335974.2391254740155; Thu, 8 Jan 2026 02:51:57 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:39 +0100 Subject: [PATCH v5 20/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: <20260108-mt8196-ufs-v5-20-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 f237070afaec..66bff5e623e9 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, "mediatek,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 Sun Feb 8 15:08:15 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 BEB5448AA93; Thu, 8 Jan 2026 10:52: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=1767869565; cv=pass; b=SA7TQNC3f4A4acm5/s2XDPyfT2GQb+uiGP2vk8yHa5sKbn9ZXwuqco01qCQNHObo5kmunUry1ESKoS1WFnQ48H95ZMakGbqbjrhE38sIkCSE5PPdCGCtuG72tEl48tUIiePVUGj6gFkau0p/Kn07S4xxuHe9ePtH5y3P57zlbG8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869565; c=relaxed/simple; bh=eztl3kg3Ogp8dBKoRRM5zaJ704CGMF31ieQhlOhdmpI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WDfQFlL/Rhq7ioOW2y1I+4IGwUERn/vtxsriH0aVaTju6d9b8xwefhHp04at9WQyi/t7ZMyvetYD1LeHeLW9PpuyQqlHApAoaaLjnRnsfRrE0qUKDS1+onpWx7ES0hIps6U3kvXYobWEea9p0leFWJtS1rYh+faz05QLpAilpVM= 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=AIOj9TMc; 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="AIOj9TMc" ARC-Seal: i=1; a=rsa-sha256; t=1767869525; cv=none; d=zohomail.com; s=zohoarc; b=V85e3k7s50vtPAK02iqpdOBRa2VXuLeIv0T9+4Pd62Sp/7ufkiBhcPwW3G3P67hwwZcR5QsI+P980ppzKrjekdVSJ6S59/vKoZ+NHo9hLn8f4sChht87KWeGi8LPFNQHMCI4XHnGE+YLVzikPL/BmogFaZtgmvAtGD/tM1Vi/Yw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869525; 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=WlI6u/5oNvVqPDYWnCWn3kBiMPmGfQfGJduj3SAQtlA=; b=SkPfKMY43paPpf2aPPrLhe95uJlf4I1G75sZdaaeTVsn3XHamOzDaC+BME4rH3e/VNgGN7ITErI8pa9uInQpY4eqHOBZZIttoi2rbP1auRnujFrY7023rHiQxeZIaCuHZprj1x/d5Gc9zZcbk5k05M7hiyGSccEEv16afXR+Ll0= 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=1767869525; 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=WlI6u/5oNvVqPDYWnCWn3kBiMPmGfQfGJduj3SAQtlA=; b=AIOj9TMcqaXrguE/eeM57X/Or1syMB71PNoISL67ecBQ4ZlQDXtAv5hIvjPacfSh OsGwuKKKP/pKaIl4UAe1JQ4P/E0vs9WY/GQAqKnqgC6qYUYCEYJOy0IjQwAbjTkbDvE 6hobMHiifz0TtekuRa8vP+EbmZWFk7B49u/p9aFM= Received: by mx.zohomail.com with SMTPS id 1767869523702213.87407455318748; Thu, 8 Jan 2026 02:52:03 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:40 +0100 Subject: [PATCH v5 21/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: <20260108-mt8196-ufs-v5-21-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 66bff5e623e9..fbfa23abbb87 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 Sun Feb 8 15:08:15 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 5EB543B8BAB; Thu, 8 Jan 2026 10:52:42 +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=1767869570; cv=pass; b=cvVMeIl+E6sTSEXoy7tS/Rp91tEwCgNZba3Mfuibp9DZnqAru4Whe9V878moX59Yf91M6X342AYjRaxjshA8XHfScXa4zByqWWtoBbgPOzB5MtWw9/gCgsIZuWn+tQw5cj+jTEuDrRbeMffBRNvObNdC3O+juhZUuO6v+sbmuz4= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869570; c=relaxed/simple; bh=ADDIXt09yqegDXFacn3Jte4aQPPiDQtClT7AhZQMkho=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ajb129lpkDDIIFZhcbU2uAIifvSZMvWXvLY1gJuYk9G7D1F9rIj+1cJ89WqeG/Xrarm6m3gIJ6zSrXPRRlQzrZZa1qyoHWHov1Dz2q22ZLYn3VjBIrEJK5atH3IOjIm+mSmfcjOdrBxIigZPPlbRjJLdQdB+vcMPHqmKObuouPk= 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=koZBo/bq; 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="koZBo/bq" ARC-Seal: i=1; a=rsa-sha256; t=1767869531; cv=none; d=zohomail.com; s=zohoarc; b=XN1eXPshnW4NHI2LlZN5ypia+4Sacq9/O2hkwYGDYVR/+c35HA01Lh2R4YPb/mT4MmNlLDmR/AFN7Uni+4JRTC+AgXCbUbJxxTCWW/m87gYLqIAWwhEcvVSyQ7Uek866fUlRTrctcMC2Utl3X1DPaWpHpem/+vn/I9cDxzqwphc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869531; 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=H+C+FMF5vbv2XWKxgnFrTmjORSNwgaOrPo2kBB0dXs8=; b=fUjxU+58kmRxFpEpoqqSteKEIUoRA+T/VCwgD/pce+dep6N9ZD8B9Q981PrV99eOgG+d4AA5dlMzmf9TiNzg6Keky3jgUleMiotQNZkzDiZSK6QRbFib8pX1v49jcexFVAydZ3MFHs0eldoLS954IB/vzkdnuXXBunpwFEALB60= 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=1767869531; 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=H+C+FMF5vbv2XWKxgnFrTmjORSNwgaOrPo2kBB0dXs8=; b=koZBo/bqK6kQ3LQOj1M438myE8aB90irpxquJr58HQH4DTXcPBRWb0ODxvd2h9gX wdZfZ9BJhhjqwhFxEJuEfvnmSNVpIL6iJjg+jgzjiU59y8LD9sf7HCYkKgq1E3ZTxmy Ba6ojwNMncUgrxwIHIS1qK3iqKjWd2CwKta85sZg= Received: by mx.zohomail.com with SMTPS id 1767869529991481.93318396021266; Thu, 8 Jan 2026 02:52:09 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:41 +0100 Subject: [PATCH v5 22/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: <20260108-mt8196-ufs-v5-22-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 fbfa23abbb87..5cddbdb1db40 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 Sun Feb 8 15:08:15 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 B6240499C85; Thu, 8 Jan 2026 10:52:53 +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=1767869580; cv=pass; b=leF1pgO74reAjyZZ2Sj3U4HiHepLNxnhrFzH2sLIWPyQJehBXv9409+4R8EVLBe08iqvlQNwA9G76ST5Tvz0oMpssRJoCeHVTP3h0Ef8oPcd/tKK+KY3hZxDx/FLoh7EEGAo0rVmFNY2MJkfqfRNsX5ufHN8DAWuHUgs1VkrnFU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869580; c=relaxed/simple; bh=8g/bYRmdTUoJlmrvwVKshVTrtzP8Rk2DkQWttsAGjvA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tpIVJfJd1nUSLgmfzVDju03b+lKnDxnnhMgjVDfKzoem1R3cWxeRjYmEZEiappzcRjzK7OG4Ul5sMSKCFvZ4vb/P1vPIrXMDHmS5wI+MXEfrH6GYOvkyn5EkY80QYkmVzjpciMeGqbXF9O3RhJzWWlw17DRwpAzErKvh7eGIHN8= 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=DdDL4nxI; 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="DdDL4nxI" ARC-Seal: i=1; a=rsa-sha256; t=1767869537; cv=none; d=zohomail.com; s=zohoarc; b=YmWcFSOC76fGbVOBvUJ21xVrxngjzaHvSQk1q5n+008+2y/t8l8NgKU9F4x/n/sKnfds0giPe/IOw40X137Qk7vsvNCiSagRvIRUcxNhKYfjQS8OBD6esLevcQcE4SfH9RRoF8ReY2a4mYa9bCQgT+QVXjq8GaUETts/+X+6urU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869537; 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=zOpG4ctuGxaFemqROhr+mYZ3twHePcGw1CvALVuGy0E=; b=ONgsnNYz3Ub5EX1fkAjjReXFd96MJVXxiVUPjhZ9TyjaW8IJlENXDkesHsTmvgJTzl4Dt6/r69VrX39A8jMVt6EJSyjN2pCjQdzgGmH1bjs9QHvEEAB7HxRBeHxTBXanrgsXOO2LML2YLNMl52MswsPzPgZr9Eo+O3S5l2yc3W4= 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=1767869537; 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=zOpG4ctuGxaFemqROhr+mYZ3twHePcGw1CvALVuGy0E=; b=DdDL4nxIvWZXSKg6opCkNkcq2KTiuPAho9N/PlSOgwPy7dRtcy4WX3glwVv/cKvR 8dxEg1uNAIg/j6MS+Vdeiut+8mPg1KJaAksNAcuz7+PPxhtMaqZagzmwW5cZyyfMxWz iKtCeK/lek77tCXlfQOWfuMUdO1f1Ar/ix7v0wew= Received: by mx.zohomail.com with SMTPS id 1767869536276411.19284101434323; Thu, 8 Jan 2026 02:52:16 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:42 +0100 Subject: [PATCH v5 23/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: <20260108-mt8196-ufs-v5-23-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 5cddbdb1db40..0842522cda51 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 Sun Feb 8 15:08:15 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 7E2FB49F0C5; Thu, 8 Jan 2026 10:53: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=1767869595; cv=pass; b=SukB5y4zFZD0tTrzF6NoQzJaCE9wtcVKb59E1JNRf0wdX8hj+D3YYYij7WmFEXRpTx969AYNQPFzihvpqDoc833Tzm+Fyh71M/LVP3PW6CubpL2SIdJGGzNHC2ZLmsMYDclAAWfU2u7uXiFyjro+5KIgqnTtC1uJoL9bL5eTX9c= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767869595; c=relaxed/simple; bh=QR58KU2cKj36N33d39Lwv6L3Uy/yzD7aQPT8HZM68fs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NU6ybmRYHFnOEbPym7YwbpZc7h1MKxxM2IaMCV5+Xqj5jdvTxNBObFvW0FXMOIo2tJH1JSE627nMP6BOwGUJgnbAzdijSTedKvVwDmLb+vj4CaBrRtPIOa/n0ipg/UN6lQnO6AguNc5hsSvx7oATLiLTp+3/lFfV1/0zqYw3e+k= 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=dKmfYAcV; 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="dKmfYAcV" ARC-Seal: i=1; a=rsa-sha256; t=1767869543; cv=none; d=zohomail.com; s=zohoarc; b=HDf91o4WTyeT2QKBGQV03+50pxRvA665m27VQVxguAA39DxuxAhriJD6xuYM93DrXxOOTGZHswyhhEZoQZYIkE1bBvdJrtrbqgCSJB//u7HtrSP2Mx3GTuw95i2sK5JVjSREe3F4nK432/xTDuwB8XvGReQcgyxlsjOSYSf87QM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767869543; 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=7XbznlTTcOfX8yLZgUHr2ZFUApk0sfdFJbqpCJdpj3o=; b=U6sTEm3/JAXOrCVE7Y0lMwJH08GiW+aP2ut+nIV+6/9XeGSknbV6pupK6yAH17ppLoSWuTxoUUHTYh33WunY7GVeGWuw0puE9x1lweyIbvM3IPjgxNWDvnyZ/ejnPUzMVeubFjca1Y4xyE/6oip8ZDBneX0rZVAW6rwNjSWA1BI= 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=1767869543; 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=7XbznlTTcOfX8yLZgUHr2ZFUApk0sfdFJbqpCJdpj3o=; b=dKmfYAcVYDXFCGz/0fMZ9sOEv6W0GVy4DR48qWTbVLtPTti9coRLAlHt6lJNeLV9 rpuib+jwx2ZKko9cVJDXngyEnI8iUTEj3h8jSsa/4rNSHrSPoKRiqe4C+dQ2epon7P/ z2BhacC5CkUwlrRGZ2pdtDOxBCdvIBt/HoseAobA= Received: by mx.zohomail.com with SMTPS id 1767869542597899.442829546703; Thu, 8 Jan 2026 02:52:22 -0800 (PST) From: Nicolas Frattaroli Date: Thu, 08 Jan 2026 11:49:43 +0100 Subject: [PATCH v5 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: <20260108-mt8196-ufs-v5-24-49215157ec41@collabora.com> References: <20260108-mt8196-ufs-v5-0-49215157ec41@collabora.com> In-Reply-To: <20260108-mt8196-ufs-v5-0-49215157ec41@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 0842522cda51..df712d432765 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 @@ -2219,6 +2221,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, @@ -2231,10 +2237,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