* [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement
@ 2025-12-18 12:54 Nicolas Frattaroli
2025-12-18 12:54 ` [PATCH v4 01/25] dt-bindings: phy: Add mediatek,mt8196-ufsphy variant Nicolas Frattaroli
` (25 more replies)
0 siblings, 26 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:54 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
In this series, the existing MediaTek UFS binding is expanded and
completed to correctly describe not just the existing compatibles, but
also to introduce a new compatible in the from of the MT8196 SoC.
The resets, which until now were completely absent from both the UFS
host controller binding and the UFS PHY binding, are introduced to both.
This also means the driver's undocumented and, in mainline, unused reset
logic is reworked. In particular, the PHY reset is no longer a reset of
the host controller node, but of the PHY node.
This means the host controller can reset the PHY through the common PHY
framework.
The resets remain optional.
Additionally, a massive number of driver cleanups are introduced. These
were prompted by me inspecting the driver more closely as I was
adjusting it to correspond to the binding.
The driver still implements vendor properties that are undocumented in
the binding. I did not touch most of those, as I neither want to
convince the bindings maintainers that they are needed without knowing
precisely what they're for, nor do I want to argue with the driver
authors when removing them.
Due to the "Marie Kondo with a chainsaw" nature of the driver cleanup
patches, I humbly request that reviewers do not comment on displeasing
code they see in the context portion of a patch before they've read the
whole patch series, as that displeasing code may in fact be reworked in
a subsequent patch of this series. Please keep comments focused on the
changed lines of the diff; I know there's more that can be done, but it
doesn't necessarily need to be part of this series.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
Changes in v4:
- bindings: Redo the supply situation, as the avdd pins don't describe
the vcc(q2) card supplies.
- bindings: format clock in mt8196 example more tersely.
- phy: use devm_reset_control_get_optional_exclusive directly
- driver: get and enable/disable the aforementioned avdd supplies.
- Link to v3: https://lore.kernel.org/r/20251023-mt8196-ufs-v3-0-0f04b4a795ff@collabora.com
Changes in v3:
- Split mediatek,ufs bindings change into two patches, one for
completing the existing binding, one for the MT8196
- Add over a dozen driver cleanup patches
- Add explicit support for the MT8196 compatible to the driver
- Note: next-20251023, on which I based this, currently has a broken
build due to an unrelated OPP core change that was merged with no
build testing. I can't use next-20251022 either, as that lacks the
recent mediatek UFS changes. It is what it is.
- Link to v2: https://lore.kernel.org/r/20251016-mt8196-ufs-v2-0-c373834c4e7a@collabora.com
Changes in v2:
- Reorder define in mtk_sip_svc.h
- Use bulk reset APIs in UFS host driver
- Link to v1: https://lore.kernel.org/r/20251014-mt8196-ufs-v1-0-195dceb83bc8@collabora.com
---
Nicolas Frattaroli (25):
dt-bindings: phy: Add mediatek,mt8196-ufsphy variant
dt-bindings: ufs: mediatek,ufs: Complete the binding
dt-bindings: ufs: mediatek,ufs: Add mt8196 variant
scsi: ufs: mediatek: Move MTK_SIP_UFS_CONTROL to mtk_sip_svc.h
phy: mediatek: ufs: Add support for resets
scsi: ufs: mediatek: Rework resets
scsi: ufs: mediatek: Rework 0.9V regulator
scsi: ufs: mediatek: Rework init function
scsi: ufs: mediatek: Rework the crypt-boost stuff
scsi: ufs: mediatek: Handle misc host voltage regulators
scsi: ufs: mediatek: Rework probe function
scsi: ufs: mediatek: Remove vendor kernel quirks cruft
scsi: ufs: mediatek: Use the common PHY framework
scsi: ufs: mediatek: Switch to newer PM ops helpers
scsi: ufs: mediatek: Remove mediatek,ufs-broken-rtc property
scsi: ufs: mediatek: Rework _ufs_mtk_clk_scale error paths
scsi: ufs: mediatek: Add vendor prefix to clk-scale-up-vcore-min
scsi: ufs: mediatek: Clean up logging prints
scsi: ufs: mediatek: Rework ufs_mtk_wait_idle_state
scsi: ufs: mediatek: Don't acquire dvfsrc-vcore twice
scsi: ufs: mediatek: Rework hardware version reading
scsi: ufs: mediatek: Back up idle timer in per-instance struct
scsi: ufs: mediatek: Make scale_us in setup_clk_gating const
scsi: ufs: mediatek: Remove ret local from link_startup_notify
scsi: ufs: mediatek: Add MT8196 compatible, update copyright
.../devicetree/bindings/phy/mediatek,ufs-phy.yaml | 16 +
.../devicetree/bindings/ufs/mediatek,ufs.yaml | 173 +++-
drivers/phy/mediatek/phy-mtk-ufs.c | 71 ++
drivers/ufs/host/ufs-mediatek-sip.h | 9 -
drivers/ufs/host/ufs-mediatek.c | 996 +++++++++------------
drivers/ufs/host/ufs-mediatek.h | 19 +-
include/linux/soc/mediatek/mtk_sip_svc.h | 3 +
7 files changed, 690 insertions(+), 597 deletions(-)
---
base-commit: 3e7f562e20ee87a25e104ef4fce557d39d62fa85
change-id: 20251014-mt8196-ufs-cec4b9a97e53
Best regards,
--
Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
^ permalink raw reply [flat|nested] 41+ messages in thread
* [PATCH v4 01/25] dt-bindings: phy: Add mediatek,mt8196-ufsphy variant
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
@ 2025-12-18 12:54 ` Nicolas Frattaroli
2025-12-18 19:25 ` Conor Dooley
2025-12-23 17:39 ` Vinod Koul
2025-12-18 12:54 ` [PATCH v4 02/25] dt-bindings: ufs: mediatek,ufs: Complete the binding Nicolas Frattaroli
` (24 subsequent siblings)
25 siblings, 2 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:54 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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 <angelogioacchino.delregno@collabora.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
.../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
@@ -43,6 +44,10 @@ properties:
- const: unipro
- const: mp
+ resets:
+ items:
+ - description: Optional UFS M-PHY reset.
+
"#phy-cells":
const: 0
@@ -66,5 +71,16 @@ examples:
clock-names = "unipro", "mp";
#phy-cells = <0>;
};
+ - |
+ #include <dt-bindings/reset/mediatek,mt8196-resets.h>
+ ufs-phy@16800000 {
+ compatible = "mediatek,mt8196-ufsphy", "mediatek,mt8183-ufsphy";
+ reg = <0x16800000 0x10000>;
+ clocks = <&ufs_ao_clk 3>,
+ <&ufs_ao_clk 5>;
+ clock-names = "unipro", "mp";
+ resets = <&ufs_ao_clk MT8196_UFSAO_RST0_UFS_MPHY>;
+ #phy-cells = <0>;
+ };
...
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 02/25] dt-bindings: ufs: mediatek,ufs: Complete the binding
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
2025-12-18 12:54 ` [PATCH v4 01/25] dt-bindings: phy: Add mediatek,mt8196-ufsphy variant Nicolas Frattaroli
@ 2025-12-18 12:54 ` Nicolas Frattaroli
2025-12-18 19:38 ` Conor Dooley
` (2 more replies)
2025-12-18 12:54 ` [PATCH v4 03/25] dt-bindings: ufs: mediatek,ufs: Add mt8196 variant Nicolas Frattaroli
` (23 subsequent siblings)
25 siblings, 3 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:54 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
.../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/Documentation/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:
clocks:
minItems: 1
- maxItems: 8
+ maxItems: 13
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
phys:
maxItems: 1
@@ -31,8 +48,36 @@ properties:
reg:
maxItems: 1
+ 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
+ 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 host.
@@ -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
examples:
- |
@@ -95,8 +152,34 @@ examples:
clocks = <&infracfg_ao CLK_INFRA_UFS>;
clock-names = "ufs";
- freq-table-hz = <0 0>;
vcc-supply = <&mt_pmic_vemc_ldo_reg>;
};
};
+ - |
+ ufshci@11270000 {
+ compatible = "mediatek,mt8195-ufshci";
+ reg = <0x11270000 0x2300>;
+ interrupts = <GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>;
+ phys = <&ufsphy>;
+ clocks = <&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 = "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 = <&ufs_opp_table>;
+
+ avdd12-supply = <&mt6359_vrf12_ldo_reg>;
+ avdd12-ckbuf-supply = <&mt6359_vbbck_ldo_reg>;
+ avdd18-supply = <&mt6359_vio18_ldo_reg>;
+ vcc-supply = <&mt6359_vemc_1_ldo_reg>;
+ vccq2-supply = <&mt6359_vufs_ldo_reg>;
+
+ mediatek,ufs-disable-mcq;
+ };
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 03/25] dt-bindings: ufs: mediatek,ufs: Add mt8196 variant
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
2025-12-18 12:54 ` [PATCH v4 01/25] dt-bindings: phy: Add mediatek,mt8196-ufsphy variant Nicolas Frattaroli
2025-12-18 12:54 ` [PATCH v4 02/25] dt-bindings: ufs: mediatek,ufs: Complete the binding Nicolas Frattaroli
@ 2025-12-18 12:54 ` Nicolas Frattaroli
2025-12-18 19:26 ` Conor Dooley
2025-12-23 17:39 ` Vinod Koul
2025-12-18 12:54 ` [PATCH v4 04/25] scsi: ufs: mediatek: Move MTK_SIP_UFS_CONTROL to mtk_sip_svc.h Nicolas Frattaroli
` (22 subsequent siblings)
25 siblings, 2 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:54 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
.../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/Documentation/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
clocks:
minItems: 1
- maxItems: 13
+ maxItems: 16
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
operating-points-v2: true
@@ -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
examples:
- |
@@ -183,3 +205,37 @@ examples:
mediatek,ufs-disable-mcq;
};
+ - |
+ #include <dt-bindings/reset/mediatek,mt8196-resets.h>
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+
+ ufshci@16810000 {
+ compatible = "mediatek,mt8196-ufshci";
+ reg = <0x16810000 0x2a00>;
+ interrupts = <GIC_SPI 320 IRQ_TYPE_LEVEL_HIGH>;
+
+ clocks = <&ufs_ao_clk 6>, <&ufs_ao_clk 7>, <&clk26m>, <&ufs_ao_clk 3>,
+ <&clk26m>, <&ufs_ao_clk 4>, <&ufs_ao_clk 0>,
+ <&topckgen 7>, <&topckgen 41>, <&topckgen 105>, <&topckgen 83>,
+ <&ufs_ao_clk 1>, <&ufs_ao_clk 2>, <&topckgen 42>,
+ <&topckgen 84>, <&topckgen 102>;
+ clock-names = "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 = <&ufs_opp_table>;
+
+ phys = <&ufsphy>;
+
+ avdd09-supply = <&mt6363_vsram_modem>;
+ vcc-supply = <&mt6363_vemc>;
+ vccq-supply = <&mt6363_vufs12>;
+
+ resets = <&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 = "unipro", "crypto", "hci";
+ mediatek,ufs-disable-mcq;
+ };
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 04/25] scsi: ufs: mediatek: Move MTK_SIP_UFS_CONTROL to mtk_sip_svc.h
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (2 preceding siblings ...)
2025-12-18 12:54 ` [PATCH v4 03/25] dt-bindings: ufs: mediatek,ufs: Add mt8196 variant Nicolas Frattaroli
@ 2025-12-18 12:54 ` Nicolas Frattaroli
2025-12-18 12:54 ` [PATCH v4 05/25] phy: mediatek: ufs: Add support for resets Nicolas Frattaroli
` (21 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:54 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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 <angelogioacchino.delregno@collabora.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek-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/mediatek/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)
+/* 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)
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 05/25] phy: mediatek: ufs: Add support for resets
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (3 preceding siblings ...)
2025-12-18 12:54 ` [PATCH v4 04/25] scsi: ufs: mediatek: Move MTK_SIP_UFS_CONTROL to mtk_sip_svc.h Nicolas Frattaroli
@ 2025-12-18 12:54 ` Nicolas Frattaroli
2025-12-23 17:39 ` Vinod Koul
2025-12-18 12:54 ` [PATCH v4 06/25] scsi: ufs: mediatek: Rework resets Nicolas Frattaroli
` (20 subsequent siblings)
25 siblings, 1 reply; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:54 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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 <p.zabel@pengutronix.de>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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 <stanley.chu@mediatek.com>
*/
+#include <linux/arm-smccc.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/io.h>
@@ -11,6 +12,8 @@
#include <linux/module.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
+#include <linux/reset.h>
+#include <linux/soc/mediatek/mtk_sip_svc.h>
#include "phy-mtk-io.h"
@@ -36,9 +39,17 @@
#define UFSPHY_CLKS_CNT 2
+#define UFS_MTK_SIP_MPHY_CTRL BIT(8)
+
+enum ufs_mtk_mphy_op {
+ UFS_MPHY_BACKUP = 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];
};
@@ -141,9 +152,59 @@ static int ufs_mtk_phy_power_off(struct phy *generic_phy)
return 0;
}
+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 = get_ufs_mtk_phy(generic_phy);
+ int ret;
+
+ if (!phy->reset)
+ return -EOPNOTSUPP;
+
+ ret = reset_control_assert(phy->reset);
+ if (ret)
+ return ret;
+
+ usleep_range(100, 110);
+
+ ret = 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 = 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 = {
.power_on = ufs_mtk_phy_power_on,
.power_off = ufs_mtk_phy_power_off,
+ .reset = ufs_mtk_phy_reset,
.owner = THIS_MODULE,
};
@@ -163,8 +224,18 @@ static int ufs_mtk_phy_probe(struct platform_device *pdev)
if (IS_ERR(phy->mmio))
return PTR_ERR(phy->mmio);
+ phy->reset = 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 = dev;
+ if (phy->reset) {
+ ret = ufs_mtk_phy_ctrl(phy, UFS_MPHY_BACKUP);
+ if (ret)
+ return dev_err_probe(dev, ret, "Failed to back up MPHY\n");
+ }
+
ret = ufs_mtk_phy_clk_init(phy);
if (ret)
return ret;
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 06/25] scsi: ufs: mediatek: Rework resets
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (4 preceding siblings ...)
2025-12-18 12:54 ` [PATCH v4 05/25] phy: mediatek: ufs: Add support for resets Nicolas Frattaroli
@ 2025-12-18 12:54 ` Nicolas Frattaroli
2025-12-18 12:54 ` [PATCH v4 07/25] scsi: ufs: mediatek: Rework 0.9V regulator Nicolas Frattaroli
` (19 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:54 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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 <angelogioacchino.delregno@collabora.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek-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
};
-enum ufs_mtk_mphy_op {
- UFS_MPHY_BACKUP = 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)
-#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)
diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index ecbbf52bf734..d1554701793e 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[] = {
"PA_INIT"
};
+static const char *const ufs_reset_names[] = {
+ "unipro",
+ "crypto",
+ "hci",
+};
+
static bool ufs_mtk_is_boost_crypt_enabled(struct ufs_hba *hba)
{
struct ufs_mtk_host *host = 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 = 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;
- 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 = 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));
- /* restore mphy setting aftre mphy reset */
- if (host->mphy_reset)
- ufs_mtk_mphy_ctrl(UFS_MPHY_RESTORE, res);
-}
+ ret = phy_reset(host->mphy);
-static void ufs_mtk_init_reset_control(struct ufs_hba *hba,
- struct reset_control **rc,
- char *str)
-{
- *rc = devm_reset_control_get(hba->dev, str);
- if (IS_ERR(*rc)) {
- dev_info(hba->dev, "Failed to get reset control %s: %ld\n",
- str, PTR_ERR(*rc));
- *rc = 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 != -EOPNOTSUPP)
+ dev_warn(hba->dev, "PHY reset failed: %pe\n", ERR_PTR(ret));
}
+
+ ret = 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));
}
-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 = ufshcd_get_variant(hba);
+ int ret, i;
+
+ for (i = 0; i < MTK_UFS_NUM_RESETS; i++)
+ host->resets[i].id = ufs_reset_names[i];
- 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 = 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;
}
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;
- 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 = ufs_mtk_init_reset(hba);
+ if (err)
+ goto out_variant_clear;
/* Enable runtime autosuspend */
hba->caps |= UFSHCD_CAP_RPM_AUTOSUSPEND;
diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediatek.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
#include <linux/bitops.h>
+#include <linux/reset.h>
/*
* MCQ define and struct
*/
#define UFSHCD_MAX_Q_NR 8
#define MTK_MCQ_INVALID_IRQ 0xFFFF
+#define MTK_UFS_NUM_RESETS 3
/* 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;
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 07/25] scsi: ufs: mediatek: Rework 0.9V regulator
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (5 preceding siblings ...)
2025-12-18 12:54 ` [PATCH v4 06/25] scsi: ufs: mediatek: Rework resets Nicolas Frattaroli
@ 2025-12-18 12:54 ` Nicolas Frattaroli
2025-12-23 9:35 ` Peter Wang (王信友)
2025-12-18 12:54 ` [PATCH v4 08/25] scsi: ufs: mediatek: Rework init function Nicolas Frattaroli
` (18 subsequent siblings)
25 siblings, 1 reply; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:54 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index d1554701793e..a7aab2332ef2 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)
+struct ufs_mtk_soc_data {
+ bool has_avdd09;
+};
+
static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = {
{ .wmanufacturerid = UFS_ANY_VENDOR,
.model = UFS_ANY_MODEL,
@@ -48,13 +52,6 @@ static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = {
{}
};
-static const struct of_device_id ufs_mtk_of_match[] = {
- { .compatible = "mediatek,mt8183-ufshci" },
- { .compatible = "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;
}
-static bool ufs_mtk_is_va09_supported(struct ufs_hba *hba)
-{
- struct ufs_mtk_host *host = 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 = ufshcd_get_variant(hba);
@@ -506,44 +496,70 @@ static int ufs_mtk_wait_link_state(struct ufs_hba *hba, u32 state,
return -ETIMEDOUT;
}
+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 = 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 = 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 = ufshcd_get_variant(hba);
struct phy *mphy = host->mphy;
- struct arm_smccc_res res;
- int ret = 0;
+ int ret;
- if (!mphy || !(on ^ host->mphy_powered_on))
+ if (!mphy || on == host->mphy_powered_on)
return 0;
if (on) {
- if (ufs_mtk_is_va09_supported(hba)) {
- ret = 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 = 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 = 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 = on;
+ ret = ufs_mtk_09v_off(host);
+ if (ret)
+ return ret;
}
- return ret;
+ host->mphy_powered_on = on;
+
+ return 0;
}
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 *hba)
return;
}
-static void ufs_mtk_init_va09_pwr_ctrl(struct ufs_hba *hba)
-{
- struct ufs_mtk_host *host = ufshcd_get_variant(hba);
-
- host->reg_va09 = regulator_get(hba->dev, "va09");
- if (IS_ERR(host->reg_va09))
- dev_info(hba->dev, "failed to get va09");
- else
- host->caps |= UFS_MTK_CAP_VA09_PWR_CTRL;
-}
-
static void ufs_mtk_init_host_caps(struct ufs_hba *hba)
{
struct ufs_mtk_host *host = 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);
- 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 |= UFS_MTK_CAP_DISABLE_AH8;
@@ -1205,6 +1207,35 @@ static void ufs_mtk_init_mcq_irq(struct ufs_hba *hba)
host->mcq_nr_intr = 0;
}
+/**
+ * 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 = host->hba->dev;
+ const struct ufs_mtk_soc_data *data = of_device_get_match_data(dev);
+
+ if (!data || !data->has_avdd09)
+ return 0;
+
+ host->reg_avdd09 = devm_regulator_get_optional(dev, "avdd09");
+ if (IS_ERR(host->reg_avdd09)) {
+ if (PTR_ERR(host->reg_avdd09) == -ENODEV) {
+ host->reg_avdd09 = 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)
ufs_mtk_init_clocks(hba);
+ err = 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 = {
.config_scsi_dev = ufs_mtk_config_scsi_dev,
};
+static const struct ufs_mtk_soc_data mt8183_data = {
+ .has_avdd09 = true,
+};
+
+static const struct of_device_id ufs_mtk_of_match[] = {
+ { .compatible = "mediatek,mt8183-ufshci", .data = &mt8183_data },
+ { .compatible = "mediatek,mt8192-ufshci" },
+ { .compatible = "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-mediatek.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 = 1 << 0,
- UFS_MTK_CAP_VA09_PWR_CTRL = 1 << 1,
UFS_MTK_CAP_DISABLE_AH8 = 1 << 2,
UFS_MTK_CAP_BROKEN_VCC = 1 << 3,
@@ -176,7 +175,7 @@ struct ufs_mtk_mcq_intr_info {
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;
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 08/25] scsi: ufs: mediatek: Rework init function
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (6 preceding siblings ...)
2025-12-18 12:54 ` [PATCH v4 07/25] scsi: ufs: mediatek: Rework 0.9V regulator Nicolas Frattaroli
@ 2025-12-18 12:54 ` Nicolas Frattaroli
2025-12-24 6:14 ` Peter Wang (王信友)
2025-12-18 12:54 ` [PATCH v4 09/25] scsi: ufs: mediatek: Rework the crypt-boost stuff Nicolas Frattaroli
` (17 subsequent siblings)
25 siblings, 1 reply; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:54 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index a7aab2332ef2..131f71145a12 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 = hba->dev;
struct ufs_mtk_host *host;
struct Scsi_Host *shost = hba->host;
- int err = 0;
+ int err;
struct arm_smccc_res res;
host = devm_kzalloc(dev, sizeof(*host), GFP_KERNEL);
- if (!host) {
- err = -ENOMEM;
- dev_info(dev, "%s: no memory for mtk ufs host\n", __func__);
- goto out;
- }
+ if (!host)
+ return -ENOMEM;
host->hba = hba;
ufshcd_set_variant(hba, host);
- id = of_match_device(ufs_mtk_of_match, dev);
- if (!id) {
- err = -EINVAL;
- goto out;
- }
-
/* Initialize host capability */
ufs_mtk_init_host_caps(hba);
@@ -1344,11 +1334,10 @@ static int ufs_mtk_init(struct ufs_hba *hba)
ufs_mtk_get_hw_ip_version(hba);
- goto out;
+ return 0;
out_variant_clear:
ufshcd_set_variant(hba, NULL);
-out:
return err;
}
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 09/25] scsi: ufs: mediatek: Rework the crypt-boost stuff
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (7 preceding siblings ...)
2025-12-18 12:54 ` [PATCH v4 08/25] scsi: ufs: mediatek: Rework init function Nicolas Frattaroli
@ 2025-12-18 12:54 ` Nicolas Frattaroli
2025-12-24 6:16 ` Peter Wang (王信友)
2025-12-18 12:55 ` [PATCH v4 10/25] scsi: ufs: mediatek: Handle misc host voltage regulators Nicolas Frattaroli
` (16 subsequent siblings)
25 siblings, 1 reply; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:54 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/ufs/host/ufs-mediatek.c | 91 +++++++++++++++--------------------------
1 file changed, 32 insertions(+), 59 deletions(-)
diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index 131f71145a12..9c0ac72d6e43 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;
}
-static int ufs_mtk_get_host_clk(struct device *dev, const char *name,
- struct clk **clk_out)
-{
- struct clk *clk;
- int err = 0;
-
- clk = devm_clk_get(dev, name);
- if (IS_ERR(clk))
- err = PTR_ERR(clk);
- else
- *clk_out = clk;
-
- return err;
-}
-
static void ufs_mtk_boost_crypt(struct ufs_hba *hba, bool boost)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
@@ -633,65 +618,53 @@ static void ufs_mtk_boost_crypt(struct ufs_hba *hba, bool boost)
clk_disable_unprepare(cfg->clk_crypt_mux);
}
-static int ufs_mtk_init_host_clk(struct ufs_hba *hba, const char *name,
- struct clk **clk)
-{
- int ret;
-
- ret = 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)
+static int ufs_mtk_init_boost_crypt(struct ufs_hba *hba)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
struct ufs_mtk_crypt_cfg *cfg;
struct device *dev = hba->dev;
- struct regulator *reg;
- u32 volt;
+ int ret;
- host->crypt = devm_kzalloc(dev, sizeof(*(host->crypt)),
- GFP_KERNEL);
- if (!host->crypt)
- goto disable_caps;
+ cfg = devm_kzalloc(dev, sizeof(*cfg), GFP_KERNEL);
+ if (!cfg)
+ return -ENOMEM;
- reg = 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 = 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 PTR_ERR(cfg->reg_vcore);
}
- 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 = of_property_read_u32(dev->of_node, "mediatek,boost-crypt-vcore-min",
+ &cfg->vcore_volt);
+ if (ret) {
+ dev_err(dev, "Failed to get mediatek,boost-crypt-vcore-min: %pe\n",
+ ERR_PTR(ret));
+ return ret;
}
- cfg = host->crypt;
- if (ufs_mtk_init_host_clk(hba, "crypt_mux",
- &cfg->clk_crypt_mux))
- goto disable_caps;
+ cfg->clk_crypt_mux = 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 PTR_ERR(cfg->clk_crypt_mux);
+ }
- if (ufs_mtk_init_host_clk(hba, "crypt_lp",
- &cfg->clk_crypt_lp))
- goto disable_caps;
+ cfg->clk_crypt_lp = 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 PTR_ERR(cfg->clk_crypt_lp);
+ }
- if (ufs_mtk_init_host_clk(hba, "crypt_perf",
- &cfg->clk_crypt_perf))
- goto disable_caps;
+ cfg->clk_crypt_perf = 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_perf);
+ return PTR_ERR(cfg->clk_crypt_perf);
+ }
- cfg->reg_vcore = reg;
- cfg->vcore_volt = volt;
+ host->crypt = cfg;
host->caps |= UFS_MTK_CAP_BOOST_CRYPT_ENGINE;
-disable_caps:
- return;
+ return 0;
}
static void ufs_mtk_init_host_caps(struct ufs_hba *hba)
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 10/25] scsi: ufs: mediatek: Handle misc host voltage regulators
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (8 preceding siblings ...)
2025-12-18 12:54 ` [PATCH v4 09/25] scsi: ufs: mediatek: Rework the crypt-boost stuff Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-24 5:34 ` Chaotian Jing (井朝天)
2025-12-18 12:55 ` [PATCH v4 11/25] scsi: ufs: mediatek: Rework probe function Nicolas Frattaroli
` (15 subsequent siblings)
25 siblings, 1 reply; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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, and disable/enable them during suspend/resume.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
drivers/ufs/host/ufs-mediatek.c | 61 ++++++++++++++++++++++++++++++++++++++---
drivers/ufs/host/ufs-mediatek.h | 2 ++
2 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
index 9c0ac72d6e43..10d6b69e91a5 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);
struct ufs_mtk_soc_data {
bool has_avdd09;
+ u8 num_reg_names;
+ const char *const *reg_names;
};
static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = {
@@ -1190,8 +1192,37 @@ static int ufs_mtk_get_supplies(struct ufs_mtk_host *host)
{
struct device *dev = host->hba->dev;
const struct ufs_mtk_soc_data *data = of_device_get_match_data(dev);
+ int ret;
- if (!data || !data->has_avdd09)
+ if (!data)
+ return 0;
+
+ if (data->num_reg_names) {
+ host->reg_misc = devm_kcalloc(dev, data->num_reg_names,
+ sizeof(*host->reg_misc), GFP_KERNEL);
+ if (!host->reg_misc)
+ return -ENOMEM;
+
+ regulator_bulk_set_supply_names(host->reg_misc, data->reg_names,
+ data->num_reg_names);
+
+ ret = devm_regulator_bulk_get(dev, data->num_reg_names, host->reg_misc);
+ if (ret) {
+ dev_err(dev, "Failed to get misc regulators: %pe\n", ERR_PTR(ret));
+ return ret;
+ }
+
+ host->num_reg_misc = data->num_reg_names;
+
+ ret = regulator_bulk_enable(host->num_reg_misc, host->reg_misc);
+ if (ret) {
+ dev_err(dev, "Failed to turn on misc regulators: %pe\n",
+ ERR_PTR(ret));
+ return ret;
+ }
+ }
+
+ if (!data->has_avdd09)
return 0;
host->reg_avdd09 = devm_regulator_get_optional(dev, "avdd09");
@@ -1833,7 +1864,9 @@ static int ufs_mtk_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
_ufs_mtk_clk_scale(hba, false);
}
- return 0;
+ err = regulator_bulk_disable(host->num_reg_misc, host->reg_misc);
+
+ return err;
fail:
/*
* Set link as off state enforcedly to trigger
@@ -1850,6 +1883,10 @@ static int ufs_mtk_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
struct arm_smccc_res res;
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
+ err = regulator_bulk_enable(host->num_reg_misc, host->reg_misc);
+ if (err)
+ return err;
+
if (hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL)
ufs_mtk_dev_vreg_set_lpm(hba, false);
@@ -2333,14 +2370,30 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = {
.config_scsi_dev = ufs_mtk_config_scsi_dev,
};
+static const char *const ufs_mtk_regs_avdd12_avdd18[] = {
+ "avdd12", "avdd18"
+};
+
+static const char *const ufs_mtk_regs_avdd12_ckbuf_avdd18[] = {
+ "avdd12", "avdd12-ckbuf", "avdd18"
+};
+
static const struct ufs_mtk_soc_data mt8183_data = {
.has_avdd09 = true,
+ .reg_names = ufs_mtk_regs_avdd12_avdd18,
+ .num_reg_names = ARRAY_SIZE(ufs_mtk_regs_avdd12_avdd18),
+};
+
+static const struct ufs_mtk_soc_data mt8192_8195_data = {
+ .has_avdd09 = false,
+ .reg_names = ufs_mtk_regs_avdd12_ckbuf_avdd18,
+ .num_reg_names = ARRAY_SIZE(ufs_mtk_regs_avdd12_ckbuf_avdd18),
};
static const struct of_device_id ufs_mtk_of_match[] = {
{ .compatible = "mediatek,mt8183-ufshci", .data = &mt8183_data },
- { .compatible = "mediatek,mt8192-ufshci" },
- { .compatible = "mediatek,mt8195-ufshci" },
+ { .compatible = "mediatek,mt8192-ufshci", .data = &mt8192_8195_data },
+ { .compatible = "mediatek,mt8195-ufshci", .data = &mt8192_8195_data },
{},
};
MODULE_DEVICE_TABLE(of, ufs_mtk_of_match);
diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediatek.h
index 24c8941f6b86..cb32fc987864 100644
--- a/drivers/ufs/host/ufs-mediatek.h
+++ b/drivers/ufs/host/ufs-mediatek.h
@@ -176,6 +176,8 @@ struct ufs_mtk_mcq_intr_info {
struct ufs_mtk_host {
struct phy *mphy;
struct regulator *reg_avdd09;
+ struct regulator_bulk_data *reg_misc;
+ u8 num_reg_misc;
struct reset_control_bulk_data resets[MTK_UFS_NUM_RESETS];
struct ufs_hba *hba;
struct ufs_mtk_crypt_cfg *crypt;
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 11/25] scsi: ufs: mediatek: Rework probe function
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (9 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 10/25] scsi: ufs: mediatek: Handle misc host voltage regulators Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 12/25] scsi: ufs: mediatek: Remove vendor kernel quirks cruft Nicolas Frattaroli
` (14 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index 10d6b69e91a5..cc6a3a4c9704 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -2406,74 +2406,49 @@ MODULE_DEVICE_TABLE(of, ufs_mtk_of_match);
*/
static int ufs_mtk_probe(struct platform_device *pdev)
{
- int err;
- struct device *dev = &pdev->dev, *phy_dev = NULL;
- struct device_node *reset_node, *phy_node = NULL;
- struct platform_device *reset_pdev, *phy_pdev = NULL;
- struct device_link *link;
- struct ufs_hba *hba;
+ struct platform_device *phy_pdev;
+ struct device *dev = &pdev->dev;
+ struct device_node *phy_node;
struct ufs_mtk_host *host;
+ struct device *phy_dev;
+ struct ufs_hba *hba;
+ int err;
- reset_node = 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 = of_find_device_by_node(reset_node);
- if (!reset_pdev) {
- dev_notice(dev, "find reset_pdev fail\n");
- goto skip_reset;
- }
- link = 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 == DL_STATE_DORMANT) {
- err = -EPROBE_DEFER;
- goto out;
- }
-
-skip_reset:
/* find phy node */
phy_node = of_parse_phandle(dev->of_node, "phys", 0);
+ if (!phy_node)
+ return dev_err_probe(dev, -ENOENT, "No PHY node found\n");
- if (phy_node) {
- phy_pdev = of_find_device_by_node(phy_node);
- if (!phy_pdev)
- goto skip_phy;
- phy_dev = &phy_pdev->dev;
+ phy_pdev = 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");
- pm_runtime_set_active(phy_dev);
- pm_runtime_enable(phy_dev);
- pm_runtime_get_sync(phy_dev);
+ phy_dev = &phy_pdev->dev;
- put_device(phy_dev);
- dev_info(dev, "phys node found\n");
- } else {
- dev_notice(dev, "phys node not found\n");
+ err = 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 = pm_runtime_get_sync(phy_dev);
+ if (err) {
+ dev_err_probe(dev, err, "Failed to power on PHY\n");
+ goto err_put_phy;
}
-skip_phy:
/* perform generic probe */
err = 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;
}
hba = platform_get_drvdata(pdev);
- if (!hba)
- goto out;
- if (phy_node && phy_dev) {
- host = ufshcd_get_variant(hba);
- host->phy_dev = phy_dev;
- }
+ host = ufshcd_get_variant(hba);
+ host->phy_dev = phy_dev;
/*
* Because the default power setting of VSx (the upper layer of
@@ -2482,9 +2457,11 @@ static int ufs_mtk_probe(struct platform_device *pdev)
*/
ufs_mtk_dev_vreg_set_lpm(hba, false);
-out:
- of_node_put(phy_node);
- of_node_put(reset_node);
+ return 0;
+
+err_put_phy:
+ put_device(phy_dev);
+
return err;
}
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 12/25] scsi: ufs: mediatek: Remove vendor kernel quirks cruft
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (10 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 11/25] scsi: ufs: mediatek: Rework probe function Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 13/25] scsi: ufs: mediatek: Use the common PHY framework Nicolas Frattaroli
` (13 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index cc6a3a4c9704..6385ebcc9142 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -1019,73 +1019,6 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba)
}
}
-#define MAX_VCC_NAME 30
-static int ufs_mtk_vreg_fix_vcc(struct ufs_hba *hba)
-{
- struct ufs_vreg_info *info = &hba->vreg_info;
- struct device_node *np = hba->dev->of_node;
- struct device *dev = 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 = (hba->dev_info.wspecversion & 0xF00) >> 8;
- snprintf(vcc_name, MAX_VCC_NAME, "vcc-ufs%u", ver);
- } else {
- return 0;
- }
-
- err = ufshcd_populate_vreg(dev, vcc_name, &info->vcc, false);
- if (err)
- return err;
-
- err = ufshcd_get_vreg(dev, info->vcc);
- if (err)
- return err;
-
- err = regulator_enable(info->vcc->reg);
- if (!err) {
- info->vcc->enabled = 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 = &hba->vreg_info;
- struct ufs_vreg **vreg_on, **vreg_off;
-
- if (hba->dev_info.wspecversion >= 0x0300) {
- vreg_on = &info->vccq;
- vreg_off = &info->vccq2;
- } else {
- vreg_on = &info->vccq2;
- vreg_off = &info->vccq;
- }
-
- if (*vreg_on)
- (*vreg_on)->always_on = true;
-
- if (*vreg_off) {
- regulator_disable((*vreg_off)->reg);
- devm_kfree(hba->dev, (*vreg_off)->name);
- devm_kfree(hba->dev, *vreg_off);
- *vreg_off = NULL;
- }
-}
-
static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)
{
unsigned long flags;
@@ -2005,8 +1938,6 @@ static void ufs_mtk_fixup_dev_quirks(struct ufs_hba *hba)
hba->dev_quirks &= ~UFS_DEVICE_QUIRK_DELAY_BEFORE_LPM;
}
- ufs_mtk_vreg_fix_vcc(hba);
- ufs_mtk_vreg_fix_vccqx(hba);
ufs_mtk_fix_ahit(hba);
ufs_mtk_fix_clock_scaling(hba);
}
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 13/25] scsi: ufs: mediatek: Use the common PHY framework
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (11 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 12/25] scsi: ufs: mediatek: Remove vendor kernel quirks cruft Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 14/25] scsi: ufs: mediatek: Switch to newer PM ops helpers Nicolas Frattaroli
` (12 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index 6385ebcc9142..b3fb87bd1c75 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 *hba,
return 0;
}
-static int ufs_mtk_bind_mphy(struct ufs_hba *hba)
-{
- struct ufs_mtk_host *host = ufshcd_get_variant(hba);
- struct device *dev = hba->dev;
- struct device_node *np = dev->of_node;
- int err = 0;
-
- host->mphy = devm_of_phy_get_by_index(dev, np, 0);
-
- if (host->mphy == 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 = -EPROBE_DEFER;
- dev_info(dev,
- "%s: required phy hasn't probed yet. err = %d\n",
- __func__, err);
- } else if (IS_ERR(host->mphy)) {
- err = PTR_ERR(host->mphy);
- if (err != -ENODEV) {
- dev_info(dev, "%s: PHY get failed %d\n", __func__,
- err);
- }
- }
-
- if (err)
- host->mphy = NULL;
- /*
- * Allow unbound mphy because not every platform needs specific
- * mphy control.
- */
- if (err == -ENODEV)
- err = 0;
-
- return err;
-}
-
static int ufs_mtk_setup_ref_clk(struct ufs_hba *hba, bool on)
{
struct ufs_mtk_host *host = ufshcd_get_variant(hba);
@@ -1203,13 +1165,21 @@ static int ufs_mtk_init(struct ufs_hba *hba)
ufs_mtk_init_mcq_irq(hba);
- err = ufs_mtk_bind_mphy(hba);
- if (err)
+ host->mphy = devm_phy_get(dev, NULL);
+ if (IS_ERR(host->mphy)) {
+ err = dev_err_probe(dev, PTR_ERR(host->mphy), "Failed to get PHY\n");
+ goto out_variant_clear;
+ }
+
+ err = phy_init(host->mphy);
+ if (err) {
+ dev_err_probe(dev, err, "Failed to initialize PHY\n");
goto out_variant_clear;
+ }
err = ufs_mtk_init_reset(hba);
if (err)
- goto out_variant_clear;
+ goto out_phy_exit;
/* Enable runtime autosuspend */
hba->caps |= UFSHCD_CAP_RPM_AUTOSUSPEND;
@@ -1248,7 +1218,7 @@ static int ufs_mtk_init(struct ufs_hba *hba)
err = ufs_mtk_get_supplies(host);
if (err)
- goto out_variant_clear;
+ goto out_phy_exit;
/*
* ufshcd_vops_init() is invoked after
@@ -1273,11 +1243,22 @@ static int ufs_mtk_init(struct ufs_hba *hba)
return 0;
+out_phy_exit:
+ phy_exit(host->mphy);
out_variant_clear:
ufshcd_set_variant(hba, NULL);
return err;
}
+static void ufs_mtk_exit(struct ufs_hba *hba)
+{
+ struct ufs_mtk_host *host = 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)
{
@@ -2279,6 +2260,7 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = {
.name = "mediatek.ufshci",
.max_num_rtt = MTK_MAX_NUM_RTT,
.init = ufs_mtk_init,
+ .exit = ufs_mtk_exit,
.get_ufs_hci_version = ufs_mtk_get_ufs_hci_version,
.setup_clocks = ufs_mtk_setup_clocks,
.hce_enable_notify = ufs_mtk_hce_enable_notify,
@@ -2337,50 +2319,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 = &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 = of_parse_phandle(dev->of_node, "phys", 0);
- if (!phy_node)
- return dev_err_probe(dev, -ENOENT, "No PHY node found\n");
-
- phy_pdev = 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 = &phy_pdev->dev;
-
- err = 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 = 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;
/* perform generic probe */
- err = 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 = ufshcd_pltfrm_init(pdev, &ufs_hba_mtk_vops);
+ if (ret)
+ return dev_err_probe(dev, ret, "Generic platform probe failed\n");
hba = platform_get_drvdata(pdev);
- host = ufshcd_get_variant(hba);
- host->phy_dev = phy_dev;
-
/*
* Because the default power setting of VSx (the upper layer of
* VCCQ/VCCQ2) is HWLP, we need to prevent VCCQ/VCCQ2 from
@@ -2389,18 +2338,11 @@ static int ufs_mtk_probe(struct platform_device *pdev)
ufs_mtk_dev_vreg_set_lpm(hba, false);
return 0;
-
-err_put_phy:
- put_device(phy_dev);
-
- return err;
}
/**
* 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)
{
@@ -2460,9 +2402,8 @@ static int ufs_mtk_system_resume(struct device *dev)
static int ufs_mtk_runtime_suspend(struct device *dev)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
- struct ufs_mtk_host *host = ufshcd_get_variant(hba);
struct arm_smccc_res res;
- int ret = 0;
+ int ret;
ret = ufshcd_runtime_suspend(dev);
if (ret)
@@ -2473,8 +2414,11 @@ static int ufs_mtk_runtime_suspend(struct device *dev)
if (ufs_mtk_is_rtff_mtcmos(hba))
ufs_mtk_mtcmos_ctrl(false, res);
- if (host->phy_dev)
- pm_runtime_put_sync(host->phy_dev);
+ ret = ufs_mtk_mphy_power_on(hba, false);
+ if (ret) {
+ dev_err(dev, "Failed to power off PHY: %pe\n", ERR_PTR(ret));
+ return ret;
+ }
return 0;
}
@@ -2482,14 +2426,17 @@ static int ufs_mtk_runtime_suspend(struct device *dev)
static int ufs_mtk_runtime_resume(struct device *dev)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
- struct ufs_mtk_host *host = ufshcd_get_variant(hba);
struct arm_smccc_res res;
+ int ret;
if (ufs_mtk_is_rtff_mtcmos(hba))
ufs_mtk_mtcmos_ctrl(true, res);
- if (host->phy_dev)
- pm_runtime_get_sync(host->phy_dev);
+ ret = ufs_mtk_mphy_power_on(hba, true);
+ if (ret) {
+ dev_err(dev, "Failed to power on PHY: %pe\n", ERR_PTR(ret));
+ return ret;
+ }
ufs_mtk_dev_vreg_set_lpm(hba, false);
diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediatek.h
index cb32fc987864..bf8122af69f0 100644
--- a/drivers/ufs/host/ufs-mediatek.h
+++ b/drivers/ufs/host/ufs-mediatek.h
@@ -197,7 +197,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;
};
/* MTK delay of autosuspend: 500 ms */
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 14/25] scsi: ufs: mediatek: Switch to newer PM ops helpers
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (12 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 13/25] scsi: ufs: mediatek: Use the common PHY framework Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 15/25] scsi: ufs: mediatek: Remove mediatek,ufs-broken-rtc property Nicolas Frattaroli
` (11 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index b3fb87bd1c75..89e3fa5d7d10 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -2349,7 +2349,6 @@ static void ufs_mtk_remove(struct platform_device *pdev)
ufshcd_pltfrm_remove(pdev);
}
-#ifdef CONFIG_PM_SLEEP
static int ufs_mtk_system_suspend(struct device *dev)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
@@ -2396,9 +2395,7 @@ static int ufs_mtk_system_resume(struct device *dev)
return ret;
}
-#endif
-#ifdef CONFIG_PM
static int ufs_mtk_runtime_suspend(struct device *dev)
{
struct ufs_hba *hba = dev_get_drvdata(dev);
@@ -2442,13 +2439,10 @@ static int ufs_mtk_runtime_resume(struct device *dev)
return ufshcd_runtime_resume(dev);
}
-#endif
static const struct dev_pm_ops ufs_mtk_pm_ops = {
- 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 = ufshcd_suspend_prepare,
.complete = ufshcd_resume_complete,
};
@@ -2458,7 +2452,7 @@ static struct platform_driver ufs_mtk_pltform = {
.remove = ufs_mtk_remove,
.driver = {
.name = "ufshcd-mtk",
- .pm = &ufs_mtk_pm_ops,
+ .pm = pm_ptr(&ufs_mtk_pm_ops),
.of_match_table = ufs_mtk_of_match,
},
};
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 15/25] scsi: ufs: mediatek: Remove mediatek,ufs-broken-rtc property
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (13 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 14/25] scsi: ufs: mediatek: Switch to newer PM ops helpers Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 16/25] scsi: ufs: mediatek: Rework _ufs_mtk_clk_scale error paths Nicolas Frattaroli
` (10 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index 89e3fa5d7d10..ffd52b8c295a 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -657,9 +657,6 @@ static void ufs_mtk_init_host_caps(struct ufs_hba *hba)
if (of_property_read_bool(np, "mediatek,ufs-rtff-mtcmos"))
host->caps |= UFS_MTK_CAP_RTFF_MTCMOS;
- if (of_property_read_bool(np, "mediatek,ufs-broken-rtc"))
- host->caps |= UFS_MTK_CAP_MCQ_BROKEN_RTC;
-
dev_info(hba->dev, "caps: 0x%x", host->caps);
}
@@ -1203,8 +1200,6 @@ static int ufs_mtk_init(struct ufs_hba *hba)
hba->quirks |= UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL;
hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_INTR;
- if (host->caps & UFS_MTK_CAP_MCQ_BROKEN_RTC)
- hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_RTC;
hba->vps->wb_flush_threshold = UFS_WB_BUF_REMAIN_PERCENT(80);
diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-mediatek.h
index bf8122af69f0..5f096ed3f850 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 = 1 << 8,
/* Control MTCMOS with RTFF */
UFS_MTK_CAP_RTFF_MTCMOS = 1 << 9,
-
- UFS_MTK_CAP_MCQ_BROKEN_RTC = 1 << 10,
};
struct ufs_mtk_crypt_cfg {
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 16/25] scsi: ufs: mediatek: Rework _ufs_mtk_clk_scale error paths
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (14 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 15/25] scsi: ufs: mediatek: Remove mediatek,ufs-broken-rtc property Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 17/25] scsi: ufs: mediatek: Add vendor prefix to clk-scale-up-vcore-min Nicolas Frattaroli
` (9 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index ffd52b8c295a..d72b6ab05a23 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -1985,16 +1985,16 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, bool scale_up)
ret = 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;
}
if (clk_fde_scale) {
ret = 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;
}
}
@@ -2003,51 +2003,48 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, bool scale_up)
if (clk_bind_vcore) {
ret = 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;
}
}
ret = clk_set_parent(clki->clk, mclk->ufs_sel_max_clki->clk);
if (ret) {
- dev_info(hba->dev, "Failed to set clk mux, ret = %d\n",
- ret);
+ dev_err(hba->dev, "%s: Failed to set clock mux: %pe\n",
+ __func__, ERR_PTR(ret));
+ goto out;
}
if (clk_fde_scale) {
- ret = clk_set_parent(fde_clki->clk,
- mclk->ufs_fde_max_clki->clk);
+ ret = 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 = %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 = clk_set_parent(fde_clki->clk,
- mclk->ufs_fde_min_clki->clk);
+ ret = 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 = %d\n",
- ret);
+ dev_err(hba->dev, "%s: Failed to set fde clock mux: %pe\n",
+ __func__, ERR_PTR(ret));
goto out;
}
}
ret = clk_set_parent(clki->clk, mclk->ufs_sel_min_clki->clk);
if (ret) {
- dev_info(hba->dev, "Failed to set clk mux, ret = %d\n",
- ret);
+ dev_err(hba->dev, "%s: Failed to set clock mux: %pe\n",
+ __func__, ERR_PTR(ret));
goto out;
}
if (clk_bind_vcore) {
ret = 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));
}
}
}
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 17/25] scsi: ufs: mediatek: Add vendor prefix to clk-scale-up-vcore-min
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (15 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 16/25] scsi: ufs: mediatek: Rework _ufs_mtk_clk_scale error paths Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 18/25] scsi: ufs: mediatek: Clean up logging prints Nicolas Frattaroli
` (8 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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).
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index d72b6ab05a23..a598019cb9ea 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -960,9 +960,9 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba)
return;
}
- 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;
}
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 18/25] scsi: ufs: mediatek: Clean up logging prints
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (16 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 17/25] scsi: ufs: mediatek: Add vendor prefix to clk-scale-up-vcore-min Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 19/25] scsi: ufs: mediatek: Rework ufs_mtk_wait_idle_state Nicolas Frattaroli
` (7 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index a598019cb9ea..8c9daf005e12 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)
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 &= ~UFSHCD_CAP_CRYPTO;
}
}
@@ -542,40 +542,38 @@ static void ufs_mtk_boost_crypt(struct ufs_hba *hba, bool boost)
ret = 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;
}
if (boost) {
ret = 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;
}
- ret = clk_set_parent(cfg->clk_crypt_mux,
- cfg->clk_crypt_perf);
+ ret = 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 = clk_set_parent(cfg->clk_crypt_mux,
- cfg->clk_crypt_lp);
+ ret = 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;
}
ret = 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:
@@ -765,10 +763,8 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
if (clk_pwr_off) {
ufs_mtk_pwr_ctrl(hba, false);
} else {
- dev_warn(hba->dev, "Clock is not turned off, hba->ahit = 0x%x, AHIT = 0x%x\n",
- hba->ahit,
- ufshcd_readl(hba,
- REG_AUTO_HIBERNATE_IDLE_TIMER));
+ dev_warn(hba->dev, "Clock isn't off, hba->ahit = 0x%x, AHIT = 0x%x\n",
+ hba->ahit, ufshcd_readl(hba, REG_AUTO_HIBERNATE_IDLE_TIMER));
}
ufs_mtk_mcq_disable_irq(hba);
} else if (on && status == POST_CHANGE) {
@@ -812,11 +808,11 @@ static void ufs_mtk_mcq_set_irq_affinity(struct ufs_hba *hba, unsigned int cpu)
_cpu = (cpu == 0) ? 3 : cpu;
ret = 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);
}
static bool ufs_mtk_is_legacy_chipset(struct ufs_hba *hba, u32 hw_ip_ver)
@@ -832,7 +828,8 @@ static bool ufs_mtk_is_legacy_chipset(struct ufs_hba *hba, 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 = %s", hw_ip_ver,
+ str_true_false(is_legacy));
return is_legacy;
}
@@ -937,15 +934,12 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba)
}
}
- 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);
if (!ufs_mtk_is_clk_scale_ready(hba)) {
hba->caps &= ~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;
}
@@ -955,8 +949,8 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba)
*/
reg = 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) != -ENODEV)
+ dev_err(dev, "Failed to get dvfsrc-vcore: %pe\n", reg);
return;
}
@@ -970,12 +964,9 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba)
host->mclk.vcore_volt = volt;
/* 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);
}
static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)
@@ -1062,7 +1053,7 @@ static void ufs_mtk_init_mcq_irq(struct ufs_hba *hba)
}
host->mcq_intr_info[i].hba = hba;
host->mcq_intr_info[i].irq = 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);
}
return;
@@ -1325,10 +1316,8 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
host_params.desired_working_mode = UFS_PWM_MODE;
ret = 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__);
if (ufs_mtk_pmc_via_fastauto(hba, dev_req_params)) {
ufs_mtk_adjust_sync_length(hba);
@@ -1374,10 +1363,9 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
ret = ufshcd_uic_change_pwr_mode(hba,
FASTAUTO_MODE << 4 | FASTAUTO_MODE);
- if (ret) {
- dev_err(hba->dev, "%s: HSG1B FASTAUTO failed ret=%d\n",
- __func__, ret);
- }
+ if (ret)
+ dev_err(hba->dev, "%s: HSG1B FASTAUTO failed: %pe\n",
+ __func__, ERR_PTR(ret));
}
/* if already configured to the requested pwr_mode, skip adapt */
@@ -1427,7 +1415,7 @@ static int ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
out:
if (ret) {
- dev_warn(hba->dev, "exit h8 state fail, ret=%d\n", ret);
+ dev_err(hba->dev, "Failed to exit h8 state: %pe\n", ERR_PTR(ret));
ufshcd_force_error_recovery(hba);
@@ -1589,7 +1577,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);
- dev_info(hba->dev, "device reset done\n");
+ dev_dbg(hba->dev, "device reset done\n");
return 0;
}
@@ -1625,12 +1613,12 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba)
/* Check link state to make sure exit h8 success */
err = ufs_mtk_wait_idle_state(hba, 5);
if (err) {
- dev_warn(hba->dev, "wait idle fail, err=%d\n", err);
+ dev_err(hba->dev, "Failed to wait for idle: %pe\n", ERR_PTR(err));
return err;
}
err = ufs_mtk_wait_link_state(hba, VS_LINK_UP, 100);
if (err) {
- dev_warn(hba->dev, "exit h8 state fail, err=%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);
@@ -1929,20 +1917,19 @@ static void ufs_mtk_event_notify(struct ufs_hba *hba,
/* Print details of UIC Errors */
if (evt <= 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 = val;
}
if (evt == 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]);
}
if (evt == 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]);
}
}
@@ -2147,7 +2134,7 @@ static int ufs_mtk_mcq_config_resource(struct ufs_hba *hba)
/* 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;
}
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 19/25] scsi: ufs: mediatek: Rework ufs_mtk_wait_idle_state
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (17 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 18/25] scsi: ufs: mediatek: Clean up logging prints Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 20/25] scsi: ufs: mediatek: Don't acquire dvfsrc-vcore twice Nicolas Frattaroli
` (6 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index 8c9daf005e12..b07776f45acb 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -10,6 +10,7 @@
#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/delay.h>
+#include <linux/iopoll.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
@@ -380,51 +381,39 @@ static void ufs_mtk_dbg_sel(struct ufs_hba *hba)
}
}
-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 = ufshcd_get_variant(hba);
-
- /* cannot use plain ktime_get() in suspend */
- timeout = ktime_get_mono_fast_ns() + retry_ms * 1000000UL;
-
- /* wait a specific time after check base */
- udelay(10);
- wait_idle = false;
+ u32 val;
- do {
- time_checked = ktime_get_mono_fast_ns();
- if (host->legacy_ip_ver || host->ip_ver < IP_VER_MT6899) {
- ufs_mtk_dbg_sel(hba);
- val = ufshcd_readl(hba, REG_UFS_PROBE);
- } else {
- val = ufshcd_readl(hba, REG_UFS_UFS_MMIO_OTSD_CTRL);
- val = val >> 16;
- }
+ if (old_style) {
+ ufs_mtk_dbg_sel(hba);
+ val = ufshcd_readl(hba, REG_UFS_PROBE);
+ } else {
+ val = ufshcd_readl(hba, REG_UFS_UFS_MMIO_OTSD_CTRL) >> 16;
+ }
- sm = val & 0x1f;
+ return FIELD_GET(0x1f, val);
+}
- /*
- * if state is in H8 enter and H8 enter confirm
- * wait until return to idle state.
- */
- if ((sm >= VS_HIB_ENTER) && (sm <= VS_HIB_EXIT)) {
- wait_idle = 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 = ufshcd_get_variant(hba);
+ bool old_style = (host->legacy_ip_ver || host->ip_ver < IP_VER_MT6899);
+ u32 val;
+ int ret;
- if (wait_idle && (sm == 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) == VS_HCE_BASE)
+ return 0;
- if (wait_idle && sm != VS_HCE_BASE) {
- dev_info(hba->dev, "wait idle tmo: 0x%x\n", val);
- return -ETIMEDOUT;
+ /* Poll to wait for idle */
+ ret = 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 = 0x%x\n", val);
+ return ret;
}
return 0;
@@ -1407,7 +1396,7 @@ static int ufs_mtk_auto_hibern8_disable(struct ufs_hba *hba)
ufshcd_writel(hba, 0, REG_AUTO_HIBERNATE_IDLE_TIMER);
/* wait host return to idle state when auto-hibern8 off */
- ret = ufs_mtk_wait_idle_state(hba, 5);
+ ret = ufs_mtk_wait_idle_state(hba);
if (ret)
goto out;
@@ -1611,7 +1600,7 @@ static int ufs_mtk_link_set_hpm(struct ufs_hba *hba)
return err;
/* Check link state to make sure exit h8 success */
- err = ufs_mtk_wait_idle_state(hba, 5);
+ err = ufs_mtk_wait_idle_state(hba);
if (err) {
dev_err(hba->dev, "Failed to wait for idle: %pe\n", ERR_PTR(err));
return err;
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 20/25] scsi: ufs: mediatek: Don't acquire dvfsrc-vcore twice
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (18 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 19/25] scsi: ufs: mediatek: Rework ufs_mtk_wait_idle_state Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 21/25] scsi: ufs: mediatek: Rework hardware version reading Nicolas Frattaroli
` (5 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index b07776f45acb..a54c3aeb7bab 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 = ufshcd_get_variant(hba);
struct ufs_mtk_crypt_cfg *cfg;
- struct regulator *reg;
int volt, ret;
- if (!ufs_mtk_is_boost_crypt_enabled(hba))
+ if (!ufs_mtk_is_boost_crypt_enabled(hba) || !host->reg_vcore)
return;
cfg = host->crypt;
volt = cfg->vcore_volt;
- reg = cfg->reg_vcore;
ret = clk_prepare_enable(cfg->clk_crypt_mux);
if (ret) {
@@ -537,7 +535,7 @@ static void ufs_mtk_boost_crypt(struct ufs_hba *hba, bool boost)
}
if (boost) {
- ret = regulator_set_voltage(reg, volt, INT_MAX);
+ ret = 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, bool 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, bool boost)
goto out;
}
- ret = regulator_set_voltage(reg, 0, INT_MAX);
+ ret = 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,16 +574,13 @@ static int ufs_mtk_init_boost_crypt(struct ufs_hba *hba)
struct device *dev = hba->dev;
int ret;
+ if (!host->reg_vcore)
+ return 0;
+
cfg = devm_kzalloc(dev, sizeof(*cfg), GFP_KERNEL);
if (!cfg)
return -ENOMEM;
- cfg->reg_vcore = 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 PTR_ERR(cfg->reg_vcore);
- }
-
ret = of_property_read_u32(dev->of_node, "mediatek,boost-crypt-vcore-min",
&cfg->vcore_volt);
if (ret) {
@@ -891,7 +886,6 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba)
struct list_head *head = &hba->clk_list_head;
struct ufs_clk_info *clki, *clki_tmp;
struct device *dev = hba->dev;
- struct regulator *reg;
u32 volt;
/*
@@ -932,16 +926,8 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba)
return;
}
- /*
- * Default get vcore if dts have these settings.
- * No matter clock scaling support or not. (may disable by customer)
- */
- reg = devm_regulator_get_optional(dev, "dvfsrc-vcore");
- if (IS_ERR(reg)) {
- if (PTR_ERR(reg) != -ENODEV)
- dev_err(dev, "Failed to get dvfsrc-vcore: %pe\n", reg);
+ if (!host->reg_vcore)
return;
- }
if (of_property_read_u32(dev->of_node, "mediatek,clk-scale-up-vcore-min",
&volt)) {
@@ -949,12 +935,11 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba)
return;
}
- host->mclk.reg_vcore = reg;
host->mclk.vcore_volt = volt;
/* 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);
}
@@ -1066,6 +1051,17 @@ static int ufs_mtk_get_supplies(struct ufs_mtk_host *host)
const struct ufs_mtk_soc_data *data = of_device_get_match_data(dev);
int ret;
+ host->reg_vcore = devm_regulator_get_optional(dev, "dvfsrc-vcore");
+ if (IS_ERR(host->reg_vcore)) {
+ if (PTR_ERR(host->reg_vcore) != -ENODEV) {
+ dev_err(dev, "Failed to get dvfsrc-vcore supply: %pe\n",
+ host->reg_vcore);
+ return PTR_ERR(host->reg_vcore);
+ }
+
+ host->reg_vcore = NULL;
+ }
+
if (!data)
return 0;
@@ -1099,14 +1095,13 @@ static int ufs_mtk_get_supplies(struct ufs_mtk_host *host)
host->reg_avdd09 = devm_regulator_get_optional(dev, "avdd09");
if (IS_ERR(host->reg_avdd09)) {
- if (PTR_ERR(host->reg_avdd09) == -ENODEV) {
- host->reg_avdd09 = NULL;
- return 0;
+ if (PTR_ERR(host->reg_avdd09) != -ENODEV) {
+ dev_err(dev, "Failed to get avdd09 regulator: %pe\n",
+ host->reg_avdd09);
+ return PTR_ERR(host->reg_avdd09);
}
- dev_err(dev, "Failed to get avdd09 regulator: %pe\n",
- host->reg_avdd09);
- return PTR_ERR(host->reg_avdd09);
+ host->reg_avdd09 = NULL;
}
return 0;
@@ -1137,6 +1132,10 @@ static int ufs_mtk_init(struct ufs_hba *hba)
host->hba = hba;
ufshcd_set_variant(hba, host);
+ err = ufs_mtk_get_supplies(host);
+ if (err)
+ goto out_variant_clear;
+
/* Initialize host capability */
ufs_mtk_init_host_caps(hba);
@@ -1191,10 +1190,6 @@ static int ufs_mtk_init(struct ufs_hba *hba)
ufs_mtk_init_clocks(hba);
- err = 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
@@ -1940,7 +1935,6 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, bool scale_up)
struct ufs_mtk_clk *mclk = &host->mclk;
struct ufs_clk_info *clki = mclk->ufs_sel_clki;
struct ufs_clk_info *fde_clki = mclk->ufs_fde_clki;
- struct regulator *reg;
int volt, ret = 0;
bool clk_bind_vcore = false;
bool clk_fde_scale = false;
@@ -1951,9 +1945,8 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, bool scale_up)
if (!clki || !fde_clki)
return;
- reg = host->mclk.reg_vcore;
volt = host->mclk.vcore_volt;
- if (reg && volt != 0)
+ if (host->reg_vcore && volt)
clk_bind_vcore = true;
if (mclk->ufs_fde_max_clki && mclk->ufs_fde_min_clki)
@@ -1977,7 +1970,7 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, bool scale_up)
if (scale_up) {
if (clk_bind_vcore) {
- ret = regulator_set_voltage(reg, volt, INT_MAX);
+ ret = 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;
@@ -2017,7 +2010,7 @@ static void _ufs_mtk_clk_scale(struct ufs_hba *hba, bool scale_up)
}
if (clk_bind_vcore) {
- ret = regulator_set_voltage(reg, 0, INT_MAX);
+ ret = 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-mediatek.h
index 5f096ed3f850..9586fe9c0441 100644
--- a/drivers/ufs/host/ufs-mediatek.h
+++ b/drivers/ufs/host/ufs-mediatek.h
@@ -141,7 +141,6 @@ enum ufs_mtk_host_caps {
};
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;
};
@@ -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 regulator_bulk_data *reg_misc;
u8 num_reg_misc;
struct reset_control_bulk_data resets[MTK_UFS_NUM_RESETS];
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 21/25] scsi: ufs: mediatek: Rework hardware version reading
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (19 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 20/25] scsi: ufs: mediatek: Don't acquire dvfsrc-vcore twice Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 22/25] scsi: ufs: mediatek: Back up idle timer in per-instance struct Nicolas Frattaroli
` (4 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index a54c3aeb7bab..4e545cc414ac 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -799,50 +799,47 @@ static void ufs_mtk_mcq_set_irq_affinity(struct ufs_hba *hba, unsigned int cpu)
dev_dbg(hba->dev, "set irq %d affinity to CPU %d\n", irq, _cpu);
}
-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 = 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 = true;
- break;
- default:
- break;
+ return true;
}
- dev_dbg(hba->dev, "IP version 0x%x, legacy = %s", hw_ip_ver,
- str_true_false(is_legacy));
- return is_legacy;
+ return false;
}
-/*
- * 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 1MMMmmmm.
+ * In order to support version comparisons across these different versioning
+ * 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 = ufshcd_get_variant(hba);
- u32 hw_ip_ver;
+ u32 version = ufshcd_readl(hba, REG_UFS_MTK_IP_VER);
+ u32 prefix = FIELD_GET(MTK_UFS_VER_PREFIX_M, version);
- hw_ip_ver = ufshcd_readl(hba, REG_UFS_MTK_IP_VER);
+ if (prefix <= 1)
+ FIELD_MODIFY(MTK_UFS_VER_PREFIX_M, &version, BIT(28));
- if (((hw_ip_ver & (0xFF << 24)) == (0x1 << 24)) ||
- ((hw_ip_ver & (0xFF << 24)) == 0)) {
- hw_ip_ver &= ~(0xFF << 24);
- hw_ip_ver |= (0x1 << 28);
- }
-
- host->ip_ver = hw_ip_ver;
-
- host->legacy_ip_ver = ufs_mtk_is_legacy_chipset(hba, hw_ip_ver);
+ return version;
}
static void ufs_mtk_get_controller_version(struct ufs_hba *hba)
@@ -1209,7 +1206,11 @@ static int ufs_mtk_init(struct ufs_hba *hba)
ufs_mtk_setup_clocks(hba, true, POST_CHANGE);
- ufs_mtk_get_hw_ip_version(hba);
+ host->ip_ver = ufs_mtk_get_hw_ip_version(hba);
+ host->legacy_ip_ver = ufs_mtk_is_legacy_chipset(host->ip_ver);
+
+ dev_dbg(hba->dev, "IP version 0x%x, legacy = %s", host->ip_ver,
+ str_true_false(host->legacy_ip_ver));
return 0;
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 22/25] scsi: ufs: mediatek: Back up idle timer in per-instance struct
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (20 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 21/25] scsi: ufs: mediatek: Rework hardware version reading Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 23/25] scsi: ufs: mediatek: Make scale_us in setup_clk_gating const Nicolas Frattaroli
` (3 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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 during power mode changes")
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index 4e545cc414ac..147beb46a447 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -1416,28 +1416,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 = 0;
- static u32 reg;
+ struct ufs_mtk_host *host = ufshcd_get_variant(hba);
switch (stage) {
case PRE_CHANGE:
if (ufshcd_is_auto_hibern8_supported(hba)) {
- reg = ufshcd_readl(hba, REG_AUTO_HIBERNATE_IDLE_TIMER);
+ host->hibernate_idle_timer = ufshcd_readl(
+ hba, REG_AUTO_HIBERNATE_IDLE_TIMER);
ufs_mtk_auto_hibern8_disable(hba);
}
- ret = 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 = -EINVAL;
- break;
+ ufshcd_writel(hba, host->hibernate_idle_timer,
+ REG_AUTO_HIBERNATE_IDLE_TIMER);
+ return 0;
}
- return ret;
+ return -EINVAL;
}
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-mediatek.h
index 9586fe9c0441..59fc432c84b5 100644
--- a/drivers/ufs/host/ufs-mediatek.h
+++ b/drivers/ufs/host/ufs-mediatek.h
@@ -189,6 +189,7 @@ struct ufs_mtk_host {
u16 ref_clk_gating_wait_us;
u32 ip_ver;
bool legacy_ip_ver;
+ u32 hibernate_idle_timer;
bool mcq_set_intr;
bool is_mcq_intr_enabled;
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 23/25] scsi: ufs: mediatek: Make scale_us in setup_clk_gating const
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (21 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 22/25] scsi: ufs: mediatek: Back up idle timer in per-instance struct Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 24/25] scsi: ufs: mediatek: Remove ret local from link_startup_notify Nicolas Frattaroli
` (2 subsequent siblings)
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
The scale_us values are constant, and should be declared as such. Do
this, and use ARRAY_SIZE instead of a fixed <= comparison before
accessing members of the array, to avoid possible future mistakes.
This results in the same assembly with clang, so there is no functional
change, but it makes me feel better.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index 147beb46a447..7c5d30a79456 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -942,10 +942,10 @@ static void ufs_mtk_init_clocks(struct ufs_hba *hba)
static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)
{
+ const u32 scale_us[] = {1, 10, 100, 1000, 10000, 100000};
unsigned long flags;
u32 ah_ms = 10;
u32 ah_scale, ah_timer;
- u32 scale_us[] = {1, 10, 100, 1000, 10000, 100000};
if (ufshcd_is_clkgating_allowed(hba)) {
if (ufshcd_is_auto_hibern8_supported(hba) && hba->ahit) {
@@ -953,7 +953,7 @@ static void ufs_mtk_setup_clk_gating(struct ufs_hba *hba)
hba->ahit);
ah_timer = FIELD_GET(UFSHCI_AHIBERN8_TIMER_MASK,
hba->ahit);
- if (ah_scale <= 5)
+ if (ah_scale < ARRAY_SIZE(scale_us))
ah_ms = ah_timer * scale_us[ah_scale] / 1000;
}
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 24/25] scsi: ufs: mediatek: Remove ret local from link_startup_notify
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (22 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 23/25] scsi: ufs: mediatek: Make scale_us in setup_clk_gating const Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 25/25] scsi: ufs: mediatek: Add MT8196 compatible, update copyright Nicolas Frattaroli
2025-12-23 12:04 ` [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement AngeloGioacchino Del Regno
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index 7c5d30a79456..bec726ea15b7 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -1518,21 +1518,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 = 0;
-
switch (stage) {
case PRE_CHANGE:
- ret = ufs_mtk_pre_link(hba);
- break;
+ return ufs_mtk_pre_link(hba);
case POST_CHANGE:
ufs_mtk_post_link(hba);
- break;
- default:
- ret = -EINVAL;
- break;
+ return 0;
}
- return ret;
+ return -EINVAL;
}
static int ufs_mtk_device_reset(struct ufs_hba *hba)
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* [PATCH v4 25/25] scsi: ufs: mediatek: Add MT8196 compatible, update copyright
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (23 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 24/25] scsi: ufs: mediatek: Remove ret local from link_startup_notify Nicolas Frattaroli
@ 2025-12-18 12:55 ` Nicolas Frattaroli
2025-12-23 12:04 ` [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement AngeloGioacchino Del Regno
25 siblings, 0 replies; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-18 12:55 UTC (permalink / raw)
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy, Nicolas Frattaroli
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.
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
---
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-mediatek.c
index bec726ea15b7..09be752c3c0f 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 <stanley.chu@mediatek.com>
- * Peter Wang <peter.wang@mediatek.com>
+ * Stanley Chu <stanley.chu@mediatek.com>
+ * Peter Wang <peter.wang@mediatek.com>
+ * Nicolas Frattaroli <nicolas.frattaroli@collabora.com> (Major cleanups)
*/
#include <linux/arm-smccc.h>
@@ -2243,6 +2245,10 @@ static const char *const ufs_mtk_regs_avdd12_ckbuf_avdd18[] = {
"avdd12", "avdd12-ckbuf", "avdd18"
};
+static const char *const ufs_mtk_regs_avdd12_ckbuf[] = {
+ "avdd12", "avdd12-ckbuf"
+};
+
static const struct ufs_mtk_soc_data mt8183_data = {
.has_avdd09 = true,
.reg_names = ufs_mtk_regs_avdd12_avdd18,
@@ -2255,10 +2261,17 @@ static const struct ufs_mtk_soc_data mt8192_8195_data = {
.num_reg_names = ARRAY_SIZE(ufs_mtk_regs_avdd12_ckbuf_avdd18),
};
+static const struct ufs_mtk_soc_data mt8196_data = {
+ .has_avdd09 = true,
+ .reg_names = ufs_mtk_regs_avdd12_ckbuf,
+ .num_reg_names = ARRAY_SIZE(ufs_mtk_regs_avdd12_ckbuf),
+};
+
static const struct of_device_id ufs_mtk_of_match[] = {
{ .compatible = "mediatek,mt8183-ufshci", .data = &mt8183_data },
{ .compatible = "mediatek,mt8192-ufshci", .data = &mt8192_8195_data },
{ .compatible = "mediatek,mt8195-ufshci", .data = &mt8192_8195_data },
+ { .compatible = "mediatek,mt8196-ufshci", .data = &mt8196_data },
{},
};
MODULE_DEVICE_TABLE(of, ufs_mtk_of_match);
--
2.52.0
^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: [PATCH v4 01/25] dt-bindings: phy: Add mediatek,mt8196-ufsphy variant
2025-12-18 12:54 ` [PATCH v4 01/25] dt-bindings: phy: Add mediatek,mt8196-ufsphy variant Nicolas Frattaroli
@ 2025-12-18 19:25 ` Conor Dooley
2025-12-23 17:39 ` Vinod Koul
1 sibling, 0 replies; 41+ messages in thread
From: Conor Dooley @ 2025-12-18 19:25 UTC (permalink / raw)
To: Nicolas Frattaroli
Cc: 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,
Louis-Alexis Eyraud, kernel, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy
[-- Attachment #1: Type: text/plain, Size: 75 bytes --]
Acked-by: Conor Dooley <conor.dooley@microchip.com>
pw-bot: not-applicable
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 03/25] dt-bindings: ufs: mediatek,ufs: Add mt8196 variant
2025-12-18 12:54 ` [PATCH v4 03/25] dt-bindings: ufs: mediatek,ufs: Add mt8196 variant Nicolas Frattaroli
@ 2025-12-18 19:26 ` Conor Dooley
2025-12-23 17:39 ` Vinod Koul
1 sibling, 0 replies; 41+ messages in thread
From: Conor Dooley @ 2025-12-18 19:26 UTC (permalink / raw)
To: Nicolas Frattaroli
Cc: 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,
Louis-Alexis Eyraud, kernel, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy
[-- Attachment #1: Type: text/plain, Size: 774 bytes --]
On Thu, Dec 18, 2025 at 01:54:53PM +0100, Nicolas Frattaroli wrote:
> 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.
>
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
pw-bot: not-applicable
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 02/25] dt-bindings: ufs: mediatek,ufs: Complete the binding
2025-12-18 12:54 ` [PATCH v4 02/25] dt-bindings: ufs: mediatek,ufs: Complete the binding Nicolas Frattaroli
@ 2025-12-18 19:38 ` Conor Dooley
2025-12-23 17:39 ` Vinod Koul
2025-12-24 5:33 ` Chaotian Jing (井朝天)
2 siblings, 0 replies; 41+ messages in thread
From: Conor Dooley @ 2025-12-18 19:38 UTC (permalink / raw)
To: Nicolas Frattaroli
Cc: 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,
Louis-Alexis Eyraud, kernel, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy
[-- Attachment #1: Type: text/plain, Size: 2262 bytes --]
On Thu, Dec 18, 2025 at 01:54:52PM +0100, Nicolas Frattaroli wrote:
> 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.
>
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
pw-bot: not-applicable
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 07/25] scsi: ufs: mediatek: Rework 0.9V regulator
2025-12-18 12:54 ` [PATCH v4 07/25] scsi: ufs: mediatek: Rework 0.9V regulator Nicolas Frattaroli
@ 2025-12-23 9:35 ` Peter Wang (王信友)
2025-12-23 16:13 ` Nicolas Frattaroli
0 siblings, 1 reply; 41+ messages in thread
From: Peter Wang (王信友) @ 2025-12-23 9:35 UTC (permalink / raw)
To: chu.stanley@gmail.com, robh@kernel.org,
Chunfeng Yun (云春峰), kishon@kernel.org,
James.Bottomley@HansenPartnership.com, bvanassche@acm.org,
AngeloGioacchino Del Regno, neil.armstrong@linaro.org,
conor+dt@kernel.org, Chaotian Jing (井朝天),
lgirdwood@gmail.com, nicolas.frattaroli@collabora.com,
vkoul@kernel.org, krzk+dt@kernel.org, p.zabel@pengutronix.de,
alim.akhtar@samsung.com, matthias.bgg@gmail.com,
avri.altman@wdc.com, martin.petersen@oracle.com,
broonie@kernel.org
Cc: linux-scsi@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-phy@lists.infradead.org, linux-mediatek@lists.infradead.org,
Louis-Alexis Eyraud, kernel@collabora.com
On Thu, 2025-12-18 at 13:54 +0100, Nicolas Frattaroli wrote:
>
> +static int ufs_mtk_get_supplies(struct ufs_mtk_host *host)
> +{
> + struct device *dev = host->hba->dev;
> + const struct ufs_mtk_soc_data *data =
> of_device_get_match_data(dev);
> +
> + if (!data || !data->has_avdd09)
> + return 0;
>
Hi Nicolas,
It seems that has_avdd09 is not necessary, because if the
platform does not support avdd09, it will return an error
(-ENODEV) and bypass the avdd09 flow, right?
Thanks
Peter
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
` (24 preceding siblings ...)
2025-12-18 12:55 ` [PATCH v4 25/25] scsi: ufs: mediatek: Add MT8196 compatible, update copyright Nicolas Frattaroli
@ 2025-12-23 12:04 ` AngeloGioacchino Del Regno
25 siblings, 0 replies; 41+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-12-23 12:04 UTC (permalink / raw)
To: Nicolas Frattaroli, Alim Akhtar, Avri Altman, Bart Van Assche,
Rob Herring, Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
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, linux-scsi, devicetree, linux-kernel,
linux-arm-kernel, linux-mediatek, linux-phy
Il 18/12/25 13:54, Nicolas Frattaroli ha scritto:
> In this series, the existing MediaTek UFS binding is expanded and
> completed to correctly describe not just the existing compatibles, but
> also to introduce a new compatible in the from of the MT8196 SoC.
>
> The resets, which until now were completely absent from both the UFS
> host controller binding and the UFS PHY binding, are introduced to both.
> This also means the driver's undocumented and, in mainline, unused reset
> logic is reworked. In particular, the PHY reset is no longer a reset of
> the host controller node, but of the PHY node.
>
> This means the host controller can reset the PHY through the common PHY
> framework.
>
> The resets remain optional.
>
> Additionally, a massive number of driver cleanups are introduced. These
> were prompted by me inspecting the driver more closely as I was
> adjusting it to correspond to the binding.
>
> The driver still implements vendor properties that are undocumented in
> the binding. I did not touch most of those, as I neither want to
> convince the bindings maintainers that they are needed without knowing
> precisely what they're for, nor do I want to argue with the driver
> authors when removing them.
>
> Due to the "Marie Kondo with a chainsaw" nature of the driver cleanup
> patches, I humbly request that reviewers do not comment on displeasing
> code they see in the context portion of a patch before they've read the
> whole patch series, as that displeasing code may in fact be reworked in
> a subsequent patch of this series. Please keep comments focused on the
> changed lines of the diff; I know there's more that can be done, but it
> doesn't necessarily need to be part of this series.
>
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> ---
> Changes in v4:
> - bindings: Redo the supply situation, as the avdd pins don't describe
> the vcc(q2) card supplies.
> - bindings: format clock in mt8196 example more tersely.
> - phy: use devm_reset_control_get_optional_exclusive directly
> - driver: get and enable/disable the aforementioned avdd supplies.
> - Link to v3: https://lore.kernel.org/r/20251023-mt8196-ufs-v3-0-0f04b4a795ff@collabora.com
>
> Changes in v3:
> - Split mediatek,ufs bindings change into two patches, one for
> completing the existing binding, one for the MT8196
> - Add over a dozen driver cleanup patches
> - Add explicit support for the MT8196 compatible to the driver
> - Note: next-20251023, on which I based this, currently has a broken
> build due to an unrelated OPP core change that was merged with no
> build testing. I can't use next-20251022 either, as that lacks the
> recent mediatek UFS changes. It is what it is.
> - Link to v2: https://lore.kernel.org/r/20251016-mt8196-ufs-v2-0-c373834c4e7a@collabora.com
>
> Changes in v2:
> - Reorder define in mtk_sip_svc.h
> - Use bulk reset APIs in UFS host driver
> - Link to v1: https://lore.kernel.org/r/20251014-mt8196-ufs-v1-0-195dceb83bc8@collabora.com
>
Whole series is
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 07/25] scsi: ufs: mediatek: Rework 0.9V regulator
2025-12-23 9:35 ` Peter Wang (王信友)
@ 2025-12-23 16:13 ` Nicolas Frattaroli
2025-12-24 6:13 ` Peter Wang (王信友)
0 siblings, 1 reply; 41+ messages in thread
From: Nicolas Frattaroli @ 2025-12-23 16:13 UTC (permalink / raw)
To: chu.stanley@gmail.com, robh@kernel.org,
Chunfeng Yun (云春峰), kishon@kernel.org,
James.Bottomley@HansenPartnership.com, bvanassche@acm.org,
AngeloGioacchino Del Regno, neil.armstrong@linaro.org,
conor+dt@kernel.org, Chaotian Jing (井朝天),
lgirdwood@gmail.com, vkoul@kernel.org, krzk+dt@kernel.org,
p.zabel@pengutronix.de, alim.akhtar@samsung.com,
matthias.bgg@gmail.com, avri.altman@wdc.com,
martin.petersen@oracle.com, broonie@kernel.org,
Peter Wang (王信友)
Cc: linux-scsi@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-phy@lists.infradead.org, linux-mediatek@lists.infradead.org,
Louis-Alexis Eyraud, kernel@collabora.com
On Tuesday, 23 December 2025 10:35:39 Central European Standard Time Peter Wang (王信友) wrote:
> On Thu, 2025-12-18 at 13:54 +0100, Nicolas Frattaroli wrote:
> >
> > +static int ufs_mtk_get_supplies(struct ufs_mtk_host *host)
> > +{
> > + struct device *dev = host->hba->dev;
> > + const struct ufs_mtk_soc_data *data =
> > of_device_get_match_data(dev);
> > +
> > + if (!data || !data->has_avdd09)
> > + return 0;
> >
>
>
> Hi Nicolas,
>
> It seems that has_avdd09 is not necessary, because if the
> platform does not support avdd09, it will return an error
> (-ENODEV) and bypass the avdd09 flow, right?
>
> Thanks
> Peter
>
>
>
>
Hi,
that would allow compatibles that are not allowed to have an avdd09
regulator by the binding (because the SoC doesn't have that pin) to
have one specified in the device tree get picked up. This would then
cause those devices with such a device tree to enter
ufs_mtk_va09_pwr_ctrl(), which is not what we want. While we could
blame this on the DT being wrong in that case, I think it's better
if we avoid such a situation entirely.
Kind regards,
Nicolas Frattaroli
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 01/25] dt-bindings: phy: Add mediatek,mt8196-ufsphy variant
2025-12-18 12:54 ` [PATCH v4 01/25] dt-bindings: phy: Add mediatek,mt8196-ufsphy variant Nicolas Frattaroli
2025-12-18 19:25 ` Conor Dooley
@ 2025-12-23 17:39 ` Vinod Koul
1 sibling, 0 replies; 41+ messages in thread
From: Vinod Koul @ 2025-12-23 17:39 UTC (permalink / raw)
To: Nicolas Frattaroli
Cc: Alim Akhtar, Avri Altman, Bart Van Assche, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Chunfeng Yun, 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, Louis-Alexis Eyraud, kernel, linux-scsi,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-phy
On 18-12-25, 13:54, Nicolas Frattaroli wrote:
> 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.
Acked-by: Vinod Koul <vkoul@kernel.org>
--
~Vinod
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 02/25] dt-bindings: ufs: mediatek,ufs: Complete the binding
2025-12-18 12:54 ` [PATCH v4 02/25] dt-bindings: ufs: mediatek,ufs: Complete the binding Nicolas Frattaroli
2025-12-18 19:38 ` Conor Dooley
@ 2025-12-23 17:39 ` Vinod Koul
2025-12-24 5:33 ` Chaotian Jing (井朝天)
2 siblings, 0 replies; 41+ messages in thread
From: Vinod Koul @ 2025-12-23 17:39 UTC (permalink / raw)
To: Nicolas Frattaroli
Cc: Alim Akhtar, Avri Altman, Bart Van Assche, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Chunfeng Yun, 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, Louis-Alexis Eyraud, kernel, linux-scsi,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-phy
On 18-12-25, 13:54, Nicolas Frattaroli wrote:
> 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.
Acked-by: Vinod Koul <vkoul@kernel.org>
--
~Vinod
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 03/25] dt-bindings: ufs: mediatek,ufs: Add mt8196 variant
2025-12-18 12:54 ` [PATCH v4 03/25] dt-bindings: ufs: mediatek,ufs: Add mt8196 variant Nicolas Frattaroli
2025-12-18 19:26 ` Conor Dooley
@ 2025-12-23 17:39 ` Vinod Koul
1 sibling, 0 replies; 41+ messages in thread
From: Vinod Koul @ 2025-12-23 17:39 UTC (permalink / raw)
To: Nicolas Frattaroli
Cc: Alim Akhtar, Avri Altman, Bart Van Assche, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Chunfeng Yun, 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, Louis-Alexis Eyraud, kernel, linux-scsi,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-phy
On 18-12-25, 13:54, Nicolas Frattaroli wrote:
> 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.
Acked-by: Vinod Koul <vkoul@kernel.org>
--
~Vinod
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 05/25] phy: mediatek: ufs: Add support for resets
2025-12-18 12:54 ` [PATCH v4 05/25] phy: mediatek: ufs: Add support for resets Nicolas Frattaroli
@ 2025-12-23 17:39 ` Vinod Koul
0 siblings, 0 replies; 41+ messages in thread
From: Vinod Koul @ 2025-12-23 17:39 UTC (permalink / raw)
To: Nicolas Frattaroli
Cc: Alim Akhtar, Avri Altman, Bart Van Assche, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Matthias Brugger,
AngeloGioacchino Del Regno, Chunfeng Yun, 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, Louis-Alexis Eyraud, kernel, linux-scsi,
devicetree, linux-kernel, linux-arm-kernel, linux-mediatek,
linux-phy
On 18-12-25, 13:54, Nicolas Frattaroli wrote:
> 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.
Acked-by: Vinod Koul <vkoul@kernel.org>
--
~Vinod
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 02/25] dt-bindings: ufs: mediatek,ufs: Complete the binding
2025-12-18 12:54 ` [PATCH v4 02/25] dt-bindings: ufs: mediatek,ufs: Complete the binding Nicolas Frattaroli
2025-12-18 19:38 ` Conor Dooley
2025-12-23 17:39 ` Vinod Koul
@ 2025-12-24 5:33 ` Chaotian Jing (井朝天)
2 siblings, 0 replies; 41+ messages in thread
From: Chaotian Jing (井朝天) @ 2025-12-24 5:33 UTC (permalink / raw)
To: Peter Wang (王信友),
Chunfeng Yun (云春峰),
nicolas.frattaroli@collabora.com, kishon@kernel.org,
avri.altman@wdc.com, bvanassche@acm.org,
martin.petersen@oracle.com, broonie@kernel.org,
alim.akhtar@samsung.com, chu.stanley@gmail.com,
conor+dt@kernel.org, p.zabel@pengutronix.de, robh@kernel.org,
James.Bottomley@HansenPartnership.com, lgirdwood@gmail.com,
vkoul@kernel.org, matthias.bgg@gmail.com,
neil.armstrong@linaro.org, krzk+dt@kernel.org,
AngeloGioacchino Del Regno
Cc: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
devicetree@vger.kernel.org, kernel@collabora.com,
Louis-Alexis Eyraud, linux-scsi@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-phy@lists.infradead.org
On Thu, 2025-12-18 at 13:54 +0100, Nicolas Frattaroli wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>
>
> 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.
>
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> ---
> .../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/Documentation/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:
>
> clocks:
> minItems: 1
> - maxItems: 8
> + maxItems: 13
>
> 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
>
> phys:
> maxItems: 1
> @@ -31,8 +48,36 @@ properties:
> reg:
> maxItems: 1
>
> + 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
>
> + 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 host.
> @@ -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
>
> examples:
> - |
> @@ -95,8 +152,34 @@ examples:
>
> clocks = <&infracfg_ao CLK_INFRA_UFS>;
> clock-names = "ufs";
> - freq-table-hz = <0 0>;
>
> vcc-supply = <&mt_pmic_vemc_ldo_reg>;
> };
> };
> + - |
> + ufshci@11270000 {
> + compatible = "mediatek,mt8195-ufshci";
> + reg = <0x11270000 0x2300>;
> + interrupts = <GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>;
> + phys = <&ufsphy>;
> + clocks = <&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 = "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 = <&ufs_opp_table>;
> +
> + avdd12-supply = <&mt6359_vrf12_ldo_reg>;
> + avdd12-ckbuf-supply = <&mt6359_vbbck_ldo_reg>;
> + avdd18-supply = <&mt6359_vio18_ldo_reg>;
Do not add the avdd12/avdd12-clkbuf/avdd18! these analog power cannot
be power off. even that the system is in suspend state!
> + vcc-supply = <&mt6359_vemc_1_ldo_reg>;
> + vccq2-supply = <&mt6359_vufs_ldo_reg>;
> +
> + mediatek,ufs-disable-mcq;
> + };
>
> --
> 2.52.0
>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 10/25] scsi: ufs: mediatek: Handle misc host voltage regulators
2025-12-18 12:55 ` [PATCH v4 10/25] scsi: ufs: mediatek: Handle misc host voltage regulators Nicolas Frattaroli
@ 2025-12-24 5:34 ` Chaotian Jing (井朝天)
0 siblings, 0 replies; 41+ messages in thread
From: Chaotian Jing (井朝天) @ 2025-12-24 5:34 UTC (permalink / raw)
To: Peter Wang (王信友),
Chunfeng Yun (云春峰),
nicolas.frattaroli@collabora.com, kishon@kernel.org,
avri.altman@wdc.com, bvanassche@acm.org,
martin.petersen@oracle.com, broonie@kernel.org,
alim.akhtar@samsung.com, chu.stanley@gmail.com,
conor+dt@kernel.org, p.zabel@pengutronix.de, robh@kernel.org,
James.Bottomley@HansenPartnership.com, lgirdwood@gmail.com,
vkoul@kernel.org, matthias.bgg@gmail.com,
neil.armstrong@linaro.org, krzk+dt@kernel.org,
AngeloGioacchino Del Regno
Cc: linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org,
devicetree@vger.kernel.org, kernel@collabora.com,
Louis-Alexis Eyraud, linux-scsi@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-phy@lists.infradead.org
On Thu, 2025-12-18 at 13:55 +0100, Nicolas Frattaroli wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>
>
> 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, and disable/enable them during suspend/resume.
>
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> ---
> drivers/ufs/host/ufs-mediatek.c | 61
> ++++++++++++++++++++++++++++++++++++++---
> drivers/ufs/host/ufs-mediatek.h | 2 ++
> 2 files changed, 59 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-
> mediatek.c
> index 9c0ac72d6e43..10d6b69e91a5 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);
>
> struct ufs_mtk_soc_data {
> bool has_avdd09;
> + u8 num_reg_names;
> + const char *const *reg_names;
> };
>
> static const struct ufs_dev_quirk ufs_mtk_dev_fixups[] = {
> @@ -1190,8 +1192,37 @@ static int ufs_mtk_get_supplies(struct
> ufs_mtk_host *host)
> {
> struct device *dev = host->hba->dev;
> const struct ufs_mtk_soc_data *data =
> of_device_get_match_data(dev);
> + int ret;
>
> - if (!data || !data->has_avdd09)
> + if (!data)
> + return 0;
> +
> + if (data->num_reg_names) {
> + host->reg_misc = devm_kcalloc(dev, data-
> >num_reg_names,
> + sizeof(*host-
> >reg_misc), GFP_KERNEL);
> + if (!host->reg_misc)
> + return -ENOMEM;
> +
> + regulator_bulk_set_supply_names(host->reg_misc, data-
> >reg_names,
> + data->num_reg_names);
> +
> + ret = devm_regulator_bulk_get(dev, data-
> >num_reg_names, host->reg_misc);
> + if (ret) {
> + dev_err(dev, "Failed to get misc regulators:
> %pe\n", ERR_PTR(ret));
> + return ret;
> + }
> +
> + host->num_reg_misc = data->num_reg_names;
> +
> + ret = regulator_bulk_enable(host->num_reg_misc, host-
> >reg_misc);
> + if (ret) {
> + dev_err(dev, "Failed to turn on misc
> regulators: %pe\n",
> + ERR_PTR(ret));
> + return ret;
> + }
> + }
> +
> + if (!data->has_avdd09)
> return 0;
>
> host->reg_avdd09 = devm_regulator_get_optional(dev,
> "avdd09");
> @@ -1833,7 +1864,9 @@ static int ufs_mtk_suspend(struct ufs_hba *hba,
> enum ufs_pm_op pm_op,
> _ufs_mtk_clk_scale(hba, false);
> }
>
> - return 0;
> + err = regulator_bulk_disable(host->num_reg_misc, host-
> >reg_misc);
> +
> + return err;
> fail:
> /*
> * Set link as off state enforcedly to trigger
> @@ -1850,6 +1883,10 @@ static int ufs_mtk_resume(struct ufs_hba *hba,
> enum ufs_pm_op pm_op)
> struct arm_smccc_res res;
> struct ufs_mtk_host *host = ufshcd_get_variant(hba);
>
> + err = regulator_bulk_enable(host->num_reg_misc, host-
> >reg_misc);
> + if (err)
> + return err;
> +
> if (hba->ufshcd_state != UFSHCD_STATE_OPERATIONAL)
> ufs_mtk_dev_vreg_set_lpm(hba, false);
>
> @@ -2333,14 +2370,30 @@ static const struct ufs_hba_variant_ops
> ufs_hba_mtk_vops = {
> .config_scsi_dev = ufs_mtk_config_scsi_dev,
> };
>
> +static const char *const ufs_mtk_regs_avdd12_avdd18[] = {
> + "avdd12", "avdd18"
> +};
> +
> +static const char *const ufs_mtk_regs_avdd12_ckbuf_avdd18[] = {
> + "avdd12", "avdd12-ckbuf", "avdd18"
> +};
> +
> static const struct ufs_mtk_soc_data mt8183_data = {
> .has_avdd09 = true,
> + .reg_names = ufs_mtk_regs_avdd12_avdd18,
> + .num_reg_names = ARRAY_SIZE(ufs_mtk_regs_avdd12_avdd18),
> +};
> +
> +static const struct ufs_mtk_soc_data mt8192_8195_data = {
> + .has_avdd09 = false,
> + .reg_names = ufs_mtk_regs_avdd12_ckbuf_avdd18,
> + .num_reg_names =
> ARRAY_SIZE(ufs_mtk_regs_avdd12_ckbuf_avdd18),
> };
These analog power cannot be powered off, even in suspend stage!
>
> static const struct of_device_id ufs_mtk_of_match[] = {
> { .compatible = "mediatek,mt8183-ufshci", .data =
> &mt8183_data },
> - { .compatible = "mediatek,mt8192-ufshci" },
> - { .compatible = "mediatek,mt8195-ufshci" },
> + { .compatible = "mediatek,mt8192-ufshci", .data =
> &mt8192_8195_data },
> + { .compatible = "mediatek,mt8195-ufshci", .data =
> &mt8192_8195_data },
> {},
> };
> MODULE_DEVICE_TABLE(of, ufs_mtk_of_match);
> diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-
> mediatek.h
> index 24c8941f6b86..cb32fc987864 100644
> --- a/drivers/ufs/host/ufs-mediatek.h
> +++ b/drivers/ufs/host/ufs-mediatek.h
> @@ -176,6 +176,8 @@ struct ufs_mtk_mcq_intr_info {
> struct ufs_mtk_host {
> struct phy *mphy;
> struct regulator *reg_avdd09;
> + struct regulator_bulk_data *reg_misc;
> + u8 num_reg_misc;
> struct reset_control_bulk_data resets[MTK_UFS_NUM_RESETS];
> struct ufs_hba *hba;
> struct ufs_mtk_crypt_cfg *crypt;
>
> --
> 2.52.0
>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 07/25] scsi: ufs: mediatek: Rework 0.9V regulator
2025-12-23 16:13 ` Nicolas Frattaroli
@ 2025-12-24 6:13 ` Peter Wang (王信友)
0 siblings, 0 replies; 41+ messages in thread
From: Peter Wang (王信友) @ 2025-12-24 6:13 UTC (permalink / raw)
To: chu.stanley@gmail.com, robh@kernel.org,
Chunfeng Yun (云春峰), kishon@kernel.org,
James.Bottomley@hansenpartnership.com, bvanassche@acm.org,
AngeloGioacchino Del Regno,
Chaotian Jing (井朝天), conor+dt@kernel.org,
lgirdwood@gmail.com, nicolas.frattaroli@collabora.com,
vkoul@kernel.org, krzk+dt@kernel.org, p.zabel@pengutronix.de,
alim.akhtar@samsung.com, neil.armstrong@linaro.org,
matthias.bgg@gmail.com, avri.altman@wdc.com, broonie@kernel.org,
martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-phy@lists.infradead.org, linux-mediatek@lists.infradead.org,
Louis-Alexis Eyraud, kernel@collabora.com
On Tue, 2025-12-23 at 17:13 +0100, Nicolas Frattaroli wrote:
>
>
> Hi,
>
> that would allow compatibles that are not allowed to have an avdd09
> regulator by the binding (because the SoC doesn't have that pin) to
> have one specified in the device tree get picked up. This would then
> cause those devices with such a device tree to enter
> ufs_mtk_va09_pwr_ctrl(), which is not what we want. While we could
> blame this on the DT being wrong in that case, I think it's better
> if we avoid such a situation entirely.
>
> Kind regards,
> Nicolas Frattaroli
>
>
Hi Nicolas,
Okay, this does help avoid issues caused by incorrect DTS
settings. Although it increases the complexity of the code,
it provides a mistake proofing.
Thanks.
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 08/25] scsi: ufs: mediatek: Rework init function
2025-12-18 12:54 ` [PATCH v4 08/25] scsi: ufs: mediatek: Rework init function Nicolas Frattaroli
@ 2025-12-24 6:14 ` Peter Wang (王信友)
0 siblings, 0 replies; 41+ messages in thread
From: Peter Wang (王信友) @ 2025-12-24 6:14 UTC (permalink / raw)
To: chu.stanley@gmail.com, robh@kernel.org,
Chunfeng Yun (云春峰), kishon@kernel.org,
James.Bottomley@HansenPartnership.com, bvanassche@acm.org,
AngeloGioacchino Del Regno, neil.armstrong@linaro.org,
conor+dt@kernel.org, Chaotian Jing (井朝天),
lgirdwood@gmail.com, nicolas.frattaroli@collabora.com,
vkoul@kernel.org, krzk+dt@kernel.org, p.zabel@pengutronix.de,
alim.akhtar@samsung.com, matthias.bgg@gmail.com,
avri.altman@wdc.com, martin.petersen@oracle.com,
broonie@kernel.org
Cc: linux-scsi@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-phy@lists.infradead.org, linux-mediatek@lists.infradead.org,
Louis-Alexis Eyraud, kernel@collabora.com
On Thu, 2025-12-18 at 13:54 +0100, Nicolas Frattaroli wrote:
> 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.
>
> Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: [PATCH v4 09/25] scsi: ufs: mediatek: Rework the crypt-boost stuff
2025-12-18 12:54 ` [PATCH v4 09/25] scsi: ufs: mediatek: Rework the crypt-boost stuff Nicolas Frattaroli
@ 2025-12-24 6:16 ` Peter Wang (王信友)
0 siblings, 0 replies; 41+ messages in thread
From: Peter Wang (王信友) @ 2025-12-24 6:16 UTC (permalink / raw)
To: chu.stanley@gmail.com, robh@kernel.org,
Chunfeng Yun (云春峰), kishon@kernel.org,
James.Bottomley@HansenPartnership.com, bvanassche@acm.org,
AngeloGioacchino Del Regno, neil.armstrong@linaro.org,
conor+dt@kernel.org, Chaotian Jing (井朝天),
lgirdwood@gmail.com, nicolas.frattaroli@collabora.com,
vkoul@kernel.org, krzk+dt@kernel.org, p.zabel@pengutronix.de,
alim.akhtar@samsung.com, matthias.bgg@gmail.com,
avri.altman@wdc.com, martin.petersen@oracle.com,
broonie@kernel.org
Cc: linux-scsi@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-phy@lists.infradead.org, linux-mediatek@lists.infradead.org,
Louis-Alexis Eyraud, kernel@collabora.com
On Thu, 2025-12-18 at 13:54 +0100, Nicolas Frattaroli wrote:
> -
> -static void ufs_mtk_init_boost_crypt(struct ufs_hba *hba)
> +static int ufs_mtk_init_boost_crypt(struct ufs_hba *hba)
>
Hi Nicolas,
Please do not change the return type if you are not checking the return
value.
> {
> struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> struct ufs_mtk_crypt_cfg *cfg;
> struct device *dev = hba->dev;
> - struct regulator *reg;
> - u32 volt;
> + int ret;
>
> - host->crypt = devm_kzalloc(dev, sizeof(*(host->crypt)),
> - GFP_KERNEL);
> - if (!host->crypt)
> - goto disable_caps;
> + cfg = devm_kzalloc(dev, sizeof(*cfg), GFP_KERNEL);
> + if (!cfg)
> + return -ENOMEM;
>
> - reg = 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 = 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);
>
Should free the cfg memory?
> + return PTR_ERR(cfg->reg_vcore);
> }
>
> - 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 = of_property_read_u32(dev->of_node, "mediatek,boost-
> crypt-vcore-min",
> + &cfg->vcore_volt);
> + if (ret) {
> + dev_err(dev, "Failed to get mediatek,boost-crypt-
> vcore-min: %pe\n",
> + ERR_PTR(ret));
> + return ret;
> }
>
> - cfg = host->crypt;
> - if (ufs_mtk_init_host_clk(hba, "crypt_mux",
> - &cfg->clk_crypt_mux))
> - goto disable_caps;
> + cfg->clk_crypt_mux = 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 PTR_ERR(cfg->clk_crypt_mux);
> + }
>
> - if (ufs_mtk_init_host_clk(hba, "crypt_lp",
> - &cfg->clk_crypt_lp))
> - goto disable_caps;
> + cfg->clk_crypt_lp = 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 PTR_ERR(cfg->clk_crypt_lp);
> + }
>
> - if (ufs_mtk_init_host_clk(hba, "crypt_perf",
> - &cfg->clk_crypt_perf))
> - goto disable_caps;
> + cfg->clk_crypt_perf = 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_perf);
> + return PTR_ERR(cfg->clk_crypt_perf);
> + }
>
> - cfg->reg_vcore = reg;
> - cfg->vcore_volt = volt;
> + host->crypt = cfg;
> host->caps |= UFS_MTK_CAP_BOOST_CRYPT_ENGINE;
>
> -disable_caps:
> - return;
> + return 0;
> }
>
> static void ufs_mtk_init_host_caps(struct ufs_hba *hba)
>
> --
> 2.52.0
>
^ permalink raw reply [flat|nested] 41+ messages in thread
end of thread, other threads:[~2025-12-24 6:16 UTC | newest]
Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-18 12:54 [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement Nicolas Frattaroli
2025-12-18 12:54 ` [PATCH v4 01/25] dt-bindings: phy: Add mediatek,mt8196-ufsphy variant Nicolas Frattaroli
2025-12-18 19:25 ` Conor Dooley
2025-12-23 17:39 ` Vinod Koul
2025-12-18 12:54 ` [PATCH v4 02/25] dt-bindings: ufs: mediatek,ufs: Complete the binding Nicolas Frattaroli
2025-12-18 19:38 ` Conor Dooley
2025-12-23 17:39 ` Vinod Koul
2025-12-24 5:33 ` Chaotian Jing (井朝天)
2025-12-18 12:54 ` [PATCH v4 03/25] dt-bindings: ufs: mediatek,ufs: Add mt8196 variant Nicolas Frattaroli
2025-12-18 19:26 ` Conor Dooley
2025-12-23 17:39 ` Vinod Koul
2025-12-18 12:54 ` [PATCH v4 04/25] scsi: ufs: mediatek: Move MTK_SIP_UFS_CONTROL to mtk_sip_svc.h Nicolas Frattaroli
2025-12-18 12:54 ` [PATCH v4 05/25] phy: mediatek: ufs: Add support for resets Nicolas Frattaroli
2025-12-23 17:39 ` Vinod Koul
2025-12-18 12:54 ` [PATCH v4 06/25] scsi: ufs: mediatek: Rework resets Nicolas Frattaroli
2025-12-18 12:54 ` [PATCH v4 07/25] scsi: ufs: mediatek: Rework 0.9V regulator Nicolas Frattaroli
2025-12-23 9:35 ` Peter Wang (王信友)
2025-12-23 16:13 ` Nicolas Frattaroli
2025-12-24 6:13 ` Peter Wang (王信友)
2025-12-18 12:54 ` [PATCH v4 08/25] scsi: ufs: mediatek: Rework init function Nicolas Frattaroli
2025-12-24 6:14 ` Peter Wang (王信友)
2025-12-18 12:54 ` [PATCH v4 09/25] scsi: ufs: mediatek: Rework the crypt-boost stuff Nicolas Frattaroli
2025-12-24 6:16 ` Peter Wang (王信友)
2025-12-18 12:55 ` [PATCH v4 10/25] scsi: ufs: mediatek: Handle misc host voltage regulators Nicolas Frattaroli
2025-12-24 5:34 ` Chaotian Jing (井朝天)
2025-12-18 12:55 ` [PATCH v4 11/25] scsi: ufs: mediatek: Rework probe function Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 12/25] scsi: ufs: mediatek: Remove vendor kernel quirks cruft Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 13/25] scsi: ufs: mediatek: Use the common PHY framework Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 14/25] scsi: ufs: mediatek: Switch to newer PM ops helpers Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 15/25] scsi: ufs: mediatek: Remove mediatek,ufs-broken-rtc property Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 16/25] scsi: ufs: mediatek: Rework _ufs_mtk_clk_scale error paths Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 17/25] scsi: ufs: mediatek: Add vendor prefix to clk-scale-up-vcore-min Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 18/25] scsi: ufs: mediatek: Clean up logging prints Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 19/25] scsi: ufs: mediatek: Rework ufs_mtk_wait_idle_state Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 20/25] scsi: ufs: mediatek: Don't acquire dvfsrc-vcore twice Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 21/25] scsi: ufs: mediatek: Rework hardware version reading Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 22/25] scsi: ufs: mediatek: Back up idle timer in per-instance struct Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 23/25] scsi: ufs: mediatek: Make scale_us in setup_clk_gating const Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 24/25] scsi: ufs: mediatek: Remove ret local from link_startup_notify Nicolas Frattaroli
2025-12-18 12:55 ` [PATCH v4 25/25] scsi: ufs: mediatek: Add MT8196 compatible, update copyright Nicolas Frattaroli
2025-12-23 12:04 ` [PATCH v4 00/25] MediaTek UFS Cleanup and MT8196 Enablement AngeloGioacchino Del Regno
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).