reset: mediatek: add syscon-based reset controller
Subsystems (3)
cover reset: mediatek: add syscon-based reset controller
From: Peter Wang <[email protected]>
This series adds support for a MediaTek SYSCON-based reset controller that manages reset lines through memory-mapped registers within a syscon MFD block.
Peter Wang (2):
Documentation: dt: reset: add mediatek,syscon-reset binding
reset: mediatek: add syscon-based reset controller driver
.../bindings/reset/mediatek,syscon-reset.yaml | 93 +++++++ drivers/reset/Kconfig | 10 + drivers/reset/Makefile | 1 + drivers/reset/reset-mediatek-syscon.c | 230 ++++++++++++++++++ 4 files changed, 334 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml create mode 100644 drivers/reset/reset-mediatek-syscon.c
Signature · 1 line
2.45.2
PATCH 1/2 Documentation: dt: reset: add mediatek,syscon-reset binding
From: Peter Wang <[email protected]>
Add Device Tree binding documentation for the MediaTek SYSCON reset controller (mediatek,syscon-reset). This binding describes a reset controller that is part of a MediaTek SYSCON MFD block and manages multiple reset lines within that block.
The reset lines are defined via the 'mediatek,reset-bits' property, where each entry is a five-cell tuple specifying the register offsets and bit positions for asserting and deasserting a reset line:
<set_offset set_bit clear_offset clear_bit delay_us>
Consumers reference individual reset lines by index into this list using the standard '#reset-cells = <1>' scheme.
An example is provided showing a UFS subsystem use case, where the reset controller is instantiated as a child node of the UFS syscon MFD node.
--- .../bindings/reset/mediatek,syscon-reset.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml new file +93 -0
@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek SYSCON Reset Controller + +maintainers: + - Peter Wang <[email protected]> + +description: | + This describes a reset controller which is part of a MediaTek SYSCON block + and is designed to manage multiple reset lines within that block. + + The node should be a child of a syscon MFD node; it uses the parent's + regmap and therefore does not require its own 'reg' property. + + The reset specifier for consumers is an index into the 'mediatek,reset-bits' + list. For example, to reference the second reset line: + + resets = <&ufs0cfgao_rst 1>; + reset-names = "hci_rst"; + +properties: + compatible: + const: mediatek,syscon-reset + + '#reset-cells': + const: 1 + description: + The cell should contain the index into the 'mediatek,reset-bits' + property to select the specific reset line. + + mediatek,reset-bits: + $ref: /schemas/types.yaml#/definitions/uint32-matrix + minItems: 1 + maxItems: 64 + description: | + A list of reset bit definitions. Each reset line is defined by a + five-cell entry: <set_offset set_bit clear_offset clear_bit delay_us>. + The reset specifier in the consumer driver will be an index into + this list. Up to 64 reset lines are supported per controller instance. + items: + items: + - description: > + Register offset from the parent syscon base for asserting + the reset. Must be 4-byte aligned. + minimum: 0 + multipleOf: 4 + - description: > + Bit index (0-based) within the register for asserting reset. + minimum: 0 + maximum: 31 + - description: > + Register offset from the parent syscon base for deasserting + the reset. Must be 4-byte aligned. + minimum: 0 + multipleOf: 4 + - description: > + Bit index (0-based) within the register for deasserting reset. + minimum: 0 + maximum: 31 + - description: > + Minimum delay in microseconds between assertion and deassertion + during a full reset cycle. Use 0 if no delay is required. + minimum: 0 + maximum: 1000000 + +required: + - compatible + - '#reset-cells' + - mediatek,reset-bits + +additionalProperties: false + +examples: + - | + ufs0cfg_ao: syscon@16840000 { + compatible = "mediatek,mt8183-ufs0cfg_ao", "syscon", "simple-mfd"; + reg = <0x16840000 0x1000>; + #address-cells = <1>; + #size-cells = <1>; + + ufs0cfgao_rst: reset-controller { + compatible = "mediatek,syscon-reset"; + #reset-cells = <1>; + mediatek,reset-bits = + <0x48 3 0x4c 3 100>, + <0x148 0 0x14c 0 100>, + <0x148 1 0x14c 1 100>, + <0x148 2 0x14c 2 0>; + }; + };
Signature · 1 line
2.45.2
[email protected]
AI reviewRe: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The YAML binding schema is missing the mandatory `$id` field. --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The YAML binding schema is missing the mandatory $id field.
--
commit 010ce9609c338d8282471debb7c3cd606956e201
Author: Peter Wang <[email protected]>
Documentation: dt: reset: add mediatek,syscon-reset binding
This commit adds Device Tree binding documentation for the MediaTek SYSCON reset controller. The binding describes a reset controller that is part of a MediaTek SYSCON MFD block and manages multiple reset lines via the mediatek,reset-bits property.
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml line 4
Quoted 9 lines
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml new file +4
-0@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$schema: http://devicetree.org/meta-schemas/core.yaml#
[Severity: Medium]
Is the mandatory $id field missing from this schema definition?
Without the $id field, the schema cross-reference system ($ref resolution) can break, and dt_binding_check might silently skip validation or report misleading errors. Should it be added to the top-level schema header?
Quoted 2 lines
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml new file +2
-0+ +title: MediaTek SYSCON Reset Controller
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Philipp Zabel
maintainerRe: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
In reply to [email protected]Quoted 101 lines · On Fr, 2026-06-26 at 15:46 +0800, [email protected] wrote:
From: Peter Wang <[email protected]>
Add Device Tree binding documentation for the MediaTek SYSCON reset controller (mediatek,syscon-reset). This binding describes a reset controller that is part of a MediaTek SYSCON MFD block and manages multiple reset lines within that block.
The reset lines are defined via the 'mediatek,reset-bits' property, where each entry is a five-cell tuple specifying the register offsets and bit positions for asserting and deasserting a reset line:
<
set_offsetset_bitclear_offsetclear_bitdelay_us>Consumers reference individual reset lines by index into this list using the standard '#reset-cells = <1>' scheme.
An example is provided showing a UFS subsystem use case, where the reset controller is instantiated as a child node of the UFS syscon MFD node.
Signed-off-by Peter Wang <[email protected]>--- .../bindings/reset/mediatek,syscon-reset.yaml | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yamlDocumentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml new file +69
-0@@ -0,0 +1,93 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MediaTek SYSCON Reset Controller + +maintainers: + - Peter Wang <[email protected]> + +description: | + This describes a reset controller which is part of a MediaTek SYSCON block + and is designed to manage multiple reset lines within that block. + + The node should be a child of a syscon MFD node; it uses the parent's + regmap and therefore does not require its own 'reg' property. + + The reset specifier for consumers is an index into the 'mediatek,reset-bits' + list. For example, to reference the second reset line: + + resets = <&ufs0cfgao_rst 1>; + reset-names = "hci_rst"; + +properties: + compatible: + const: mediatek,syscon-reset + + '#reset-cells': + const: 1 + description: + The cell should contain the index into the 'mediatek,reset-bits' + property to select the specific reset line. + + mediatek,reset-bits: + $ref: /schemas/types.yaml#/definitions/uint32-matrix + minItems: 1 + maxItems: 64 + description: | + A list of reset bit definitions. Each reset line is defined by a + five-cell entry: <set_offset set_bit clear_offset clear_bit delay_us>. + The reset specifier in the consumer driver will be an index into + this list. Up to 64 reset lines are supported per controller instance. + items: + items: + - description: > + Register offset from the parent syscon base for asserting + the reset. Must be 4-byte aligned. + minimum: 0 + multipleOf: 4 + - description: > + Bit index (0-based) within the register for asserting reset. + minimum: 0 + maximum: 31 + - description: > + Register offset from the parent syscon base for deasserting + the reset. Must be 4-byte aligned. + minimum: 0 + multipleOf: 4 + - description: > + Bit index (0-based) within the register for deasserting reset. + minimum: 0 + maximum: 31 + - description: > + Minimum delay in microseconds between assertion and deassertion + during a full reset cycle. Use 0 if no delay is required. + minimum: 0 + maximum: 1000000 + +required:
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml line 79
Quoted 10 lines
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml new file +10
-0+ - compatible + - '#reset-cells' + - mediatek,reset-bits + +additionalProperties: false + +examples: + - | + ufs0cfg_ao: syscon@16840000 { + compatible = "mediatek,mt8183-ufs0cfg_ao", "syscon", "simple-mfd";
Where is the binding doc for mediatek,mt8183-ufs0cfg_ao? Is this simple-mfd just to load the reset driver?
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml line 85
Quoted 6 lines
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml new file +6
-0+ reg = <0x16840000 0x1000>; + #address-cells = <1>; + #size-cells = <1>; + + ufs0cfgao_rst: reset-controller { + compatible = "mediatek,syscon-reset";
It looks to me like this is just two registers inside ufs0cfg_ao, not a separate device. Why don't you just add #reset-cells to the parent node?
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml line 92
Quoted 7 lines
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml new file +7
-0+ #reset-cells = <1>; + mediatek,reset-bits = + <0x48 3 0x4c 3 100>, + <0x148 0 0x14c 0 100>, + <0x148 1 0x14c 1 100>, + <0x148 2 0x14c 2 0>; + };
Why is this in DT? This should be a table in the reset driver.
regards
Philipp
Re: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
Quoted 9 lines · Philipp Zabel
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml line 79
Quoted 6 lines
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml new file +6
-0+additionalProperties: false + +examples: + - | + ufs0cfg_ao: syscon@16840000 { + compatible = "mediatek,mt8183-ufs0cfg_ao", "syscon", "simple-mfd";Where is the binding doc for mediatek,mt8183-ufs0cfg_ao? Is this simple-mfd just to load the reset driver?
It isn't going to exist, since we will chuck a fit at the underscore!
Quoted 11 lines
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml line 85
Quoted 7 lines
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml new file +6
-0+ reg = <0x16840000 0x1000>; + #address-cells = <1>; + #size-cells = <1>; + + ufs0cfgao_rst: reset-controller { + compatible = "mediatek,syscon-reset";It looks to me like this is just two registers inside
ufs0cfg_ao, not a separate device. Why don't you just add #reset-cells to the parent node?
I concur, seems like it should be in the parent.
pw-bot: changes-requested
Quoted 13 lines
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml line 92
Quoted 8 lines
Documentation/devicetree/bindings/reset/mediatek,syscon-reset.yaml new file +7
-0+ #reset-cells = <1>; + mediatek,reset-bits = + <0x48 3 0x4c 3 100>, + <0x148 0 0x14c 0 100>, + <0x148 1 0x14c 1 100>, + <0x148 2 0x14c 2 0>; + };Why is this in DT? This should be a table in the reset driver.
regards
Philipp
Re: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
Quoted 3 lines · Conor Dooley
It isn't going to exist, since we will chuck a fit at the underscore!
Hi Conor,
Thanks for the review.
I apologize for the mistake in using this bad examples. I will remove it in the next version.
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
+ reg = <
0x168400000x1000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ufs0cfgao_rst: reset-controller { + compatible = "mediatek,syscon-reset";
Quoted 9 lines
Quoted 4 lines
It looks to me like this is just two registers inside
ufs0cfg_ao, not a
separate device. Why don't you just add #reset-cells to the parent node?I concur, seems like it should be in the parent.
pw-bot: changes-requested
This is for flexibility in MediaTek SoCs, as described in the previous email.
Thanks
Peter
Re: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
In reply to Philipp ZabelOn Fri, 2026-06-26 at 10:33 +0200, Philipp Zabel wrote
Quoted 4 lines
Where is the binding doc for mediatek,mt8183-ufs0cfg_ao? Is this simple-mfd just to load the reset driver?
Hi Philipp,
Thanks for the review, and sorry for the late reply. Yes, "mediatek,mt8183-ufs0cfg_ao" should be removed. I will remove it in the next version.
Quoted 20 lines
Quoted 6 lines
+ reg = <
0x168400000x1000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ufs0cfgao_rst: reset-controller { + compatible = "mediatek,syscon-reset";It looks to me like this is just two registers inside
ufs0cfg_ao, not a
separate device. Why don't you just add #reset-cells to the parent node?Quoted 7 lines
+ #reset-cells = <1>;
+ mediatek,reset-bits =
+ <0x48 3 0x4c 3 100>,
+ <0x14800x14c0 100>,
+ <0x14810x14c1 100>,
+ <0x14820x14c2 0>;
+ };
Quoted 4 lines
Why is this in DT? This should be a table in the reset driver.
regards
Philipp
Regarding the child node and reset-bits in DT,
We chose the child node approach with 'mediatek,reset-bits' defined in DT to keep the reset line descriptions self-contained and reusable across different SoC variants. MediaTek has many SoCs (mt8183, mt6985, mt6989, ...) where the same UFS subsystem may have different register offsets for reset lines. By describing them in DT, we can support new SoC variants by updating the DT alone, without requiring a new driver patch for every new SoC.
This approach is also consistent with the existing 'ti,syscon-reset' binding, which uses a similar per-entry table property 'ti,reset-bits' to describe reset lines within a syscon block.
Thanks
Peter
Re: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
Quoted 37 lines · Peter Wang (王信友)
On Fri, 2026-06-26 at 10:33 +0200, Philipp Zabel wrote
Quoted 4 lines
Where is the binding doc for mediatek,mt8183-ufs0cfg_ao? Is this simple-mfd just to load the reset driver?
Hi Philipp,
Thanks for the review, and sorry for the late reply. Yes, "mediatek,mt8183-ufs0cfg_ao" should be removed. I will remove it in the next version.
Quoted 20 lines
Quoted 6 lines
+ reg = <
0x168400000x1000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ufs0cfgao_rst: reset-controller { + compatible = "mediatek,syscon-reset";It looks to me like this is just two registers inside
ufs0cfg_ao, not a
separate device. Why don't you just add #reset-cells to the parent node?Quoted 7 lines
+ #reset-cells = <1>;
+ mediatek,reset-bits =
+ <0x48 3 0x4c 3 100>,
+ <0x14800x14c0 100>,
+ <0x14810x14c1 100>,
+ <0x14820x14c2 0>;
+ };Quoted 4 lines
Why is this in DT? This should be a table in the reset driver.
regards
Philipp
Quoted 8 lines
Regarding the child node and reset-bits in DT,
We chose the child node approach with 'mediatek,reset-bits' defined in DT to keep the reset line descriptions self-contained and reusable across different SoC variants. MediaTek has many SoCs (mt8183, mt6985, mt6989, ...) where the same UFS subsystem may have different register offsets for reset lines. By describing them in DT, we can support new SoC variants by updating the DT alone, without requiring a new driver patch for every new SoC.
From what I recall, mediatek ufs is a mess with lots of vendor kernel type things slipping into mainline without proper review on the DT front.
Because of that, I at least am going to require that everything is done completely (and perhaps excessively) by the book here, including introducing complete bindings for syscon regions rather than partial bits for components like this one.
Quoted 3 lines
This approach is also consistent with the existing 'ti,syscon-reset' binding, which uses a similar per-entry table property 'ti,reset-bits' to describe reset lines within a syscon block.
This was done about 10 years ago, I would not consider it a guide for what's acceptable today.
Thanks,
Conor.
Re: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
Quoted 9 lines · Conor Dooley
From what I recall, mediatek ufs is a mess with lots of vendor kernel type things slipping into mainline without proper review on the DT front.
Because of that, I at least am going to require that everything is done
completely (and perhaps excessively) by the book here, including introducing complete bindings for syscon regions rather than partial bits for components like this one.
Hi Conor,
I am sorry for giving you that impression. Yes, it was our oversight due to a lack of experience, and we missed some binding-related documentation. We are working on completing them step by step, as we are doing now. We hope you can kindly allow us to address the missing parts gradually, instead of requiring everything to be completed all at once.
Quoted 11 lines
Quoted 5 lines
This approach is also consistent with the existing 'ti,syscon- reset'
binding, which uses a similar per-entry table property 'ti,reset- bits'
to describe reset lines within a syscon block.This was done about 10 years ago, I would not consider it a guide for what's acceptable today.
Thanks,
Conor.
This should simply be a difference in hardware design and usage, with software deciding whether to opt for flexibility or a fixed approach. And it's not that the previous method was 'correct' and the current one is 'incorrect,' is it?
Thanks
Peter
Re: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
Quoted 11 lines · Peter Wang (王信友)
Quoted 9 lines · Conor Dooley
From what I recall, mediatek ufs is a mess with lots of vendor kernel type things slipping into mainline without proper review on the DT front.
Because of that, I at least am going to require that everything is done
completely (and perhaps excessively) by the book here, including introducing complete bindings for syscon regions rather than partial bits for components like this one.
Quoted 8 lines
Hi Conor,
I am sorry for giving you that impression. Yes, it was our oversight due to a lack of experience, and we missed some binding-related documentation. We are working on completing them step by step, as we are doing now. We hope you can kindly allow us to address the missing parts gradually, instead of requiring everything to be completed all at once.
No, sorry. I expect to see a complete binding for this system added in one go.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
This approach is also consistent with the existing 'ti,syscon- reset'
binding, which uses a similar per-entry table property 'ti,reset- bits'
to describe reset lines within a syscon block.
Quoted 7 lines
Quoted 2 lines
This was done about 10 years ago, I would not consider it a guide for what's acceptable today.
This should simply be a difference in hardware design and usage, with software deciding whether to opt for flexibility or a fixed approach. And it's not that the previous method was 'correct' and the current one is 'incorrect,' is it?
I'm not sure what you mean here by "previous" and "current", since both approaches are the same just with different compatibles. Times change and so does the standard for what is acceptable.
AngeloGioacchino Del Regno
maintainerRe: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
In reply to Conor DooleyQuoted 47 lines · Conor Dooley
Quoted 37 lines · Peter Wang (王信友)
On Fri, 2026-06-26 at 10:33 +0200, Philipp Zabel wrote
Quoted 4 lines
Where is the binding doc for mediatek,mt8183-ufs0cfg_ao? Is this simple-mfd just to load the reset driver?
Hi Philipp,
Thanks for the review, and sorry for the late reply. Yes, "mediatek,mt8183-ufs0cfg_ao" should be removed. I will remove it in the next version.
Quoted 20 lines
Quoted 6 lines
+ reg = <
0x168400000x1000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ufs0cfgao_rst: reset-controller { + compatible = "mediatek,syscon-reset";It looks to me like this is just two registers inside
ufs0cfg_ao, not a
separate device. Why don't you just add #reset-cells to the parent node?Quoted 7 lines
+ #reset-cells = <1>;
+ mediatek,reset-bits =
+ <0x48 3 0x4c 3 100>,
+ <0x14800x14c0 100>,
+ <0x14810x14c1 100>,
+ <0x14820x14c2 0>;
+ };Quoted 4 lines
Why is this in DT? This should be a table in the reset driver.
regards
PhilippQuoted 8 lines
Regarding the child node and reset-bits in DT,
We chose the child node approach with 'mediatek,reset-bits' defined in DT to keep the reset line descriptions self-contained and reusable across different SoC variants. MediaTek has many SoCs (mt8183, mt6985, mt6989, ...) where the same UFS subsystem may have different register offsets for reset lines. By describing them in DT, we can support new SoC variants by updating the DT alone, without requiring a new driver patch for every new SoC.
Quoted 8 lines
From what I recall, mediatek ufs is a mess with lots of vendor kernel
type things slipping into mainline without proper review on the DT front.
Because of that, I at least am going to require that everything is done completely (and perhaps excessively) by the book here, including introducing complete bindings for syscon regions rather than partial bits for components like this one.
Conor, thanks for chiming in.
I would've done that earlier but I'm going through a bit of busy period here, so thanks x2.
Yes the UFS driver is quite a bit messy.
The latest version of our series that cleans it up is version 9, sent quite a while ago at this point:
https://patchwork.kernel.org/project/linux-scsi/cover/[email protected]/
...but anyway, during these months we kept going on with it and we do have a newer version of this series in our tree, which we're planning to send in a week or two.
That'll start fixing stuff around, at least, in both bindings and code.
Quoted 7 lines
Quoted 3 lines
This approach is also consistent with the existing 'ti,syscon-reset' binding, which uses a similar per-entry table property 'ti,reset-bits' to describe reset lines within a syscon block.
This was done about 10 years ago, I would not consider it a guide for what's acceptable today.
I completely agree about that. Honestly, I'm not even sure why MediaTek needs the resets in the ufscfg0-ao space (because I didn't do extensive research, but that might be rightful), but this is getting a bit annoying as they keep pushing for adding something similar to the TI syscon reset at least at every new chip that comes out (or every 6-8 months if I recall correctly), and we keep doing the same review over and over.
Please MediaTek, stop trying to add syscon-reset. Please!
I know that you're trying to do that because in your downstream you never stopped using ti,syscon-reset: if that works better for you in your downstream, that's ok as it's purely yours but, as a matter of fact, in this form, it's not upstreamable.
If you have to upstream a *pure* reset controller, make a reset controller driver and put it in the appropriate kernel subsystem - but I also want to remind you that I know MediaTek SoCs, and I know that up until MT8196 there shouldn't be any hardware that is purely a reset controller (as in, there's no IP that manages only resets).
Thanks everyone!
Angelo
Re: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
Quoted 31 lines · AngeloGioacchino Del Regno
I completely agree about that. Honestly, I'm not even sure why MediaTek needs the
resets in the ufscfg0-ao space (because I didn't do extensive research, but that
might be rightful), but this is getting a bit annoying as they keep pushing for
adding something similar to the TI syscon reset at least at every new chip that
comes out (or every 6-8 months if I recall correctly), and we keep doing the same
review over and over.Please MediaTek, stop trying to add syscon-reset. Please!
I know that you're trying to do that because in your downstream you never stopped
using ti,syscon-reset: if that works better for you in your downstream, that's ok
as it's purely yours but, as a matter of fact, in this form, it's not upstreamable.If you have to upstream a *pure* reset controller, make a reset controller driver
and put it in the appropriate kernel subsystem - but I also want to remind you
that I know MediaTek SoCs, and I know that up until MT8196 there shouldn't be any
hardware that is purely a reset controller (as in, there's no IP that manages only
resets).
Quoted 2 lines
Thanks everyone!
Angelo
Hi AngeloGioacchino,
Thank you for your review.
Indeed, you're right – we don't have any hardware that functions solely as a reset controller. Our hardware only provides partial reset capabilities, which necessitates a partial reset driver (responsible for managing just a few set/clear bits).
We are currently planning to remove the ti,syscon-reset implementation and utilize a MediaTek-specific syscon-reset instead. However, if you object, I will halt this plan, and we can adopt Philipp's proposed solution for handling the reset.
Thanks
Peter
Philipp Zabel
maintainerRe: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
In reply to Peter Wang (王信友)Quoted 37 lines · Peter Wang (王信友)
On Fri, 2026-06-26 at 10:33 +0200, Philipp Zabel wrote
Quoted 4 lines
Where is the binding doc for mediatek,mt8183-ufs0cfg_ao? Is this simple-mfd just to load the reset driver?
Hi Philipp,
Thanks for the review, and sorry for the late reply. Yes, "mediatek,mt8183-ufs0cfg_ao" should be removed. I will remove it in the next version.
Quoted 20 lines
Quoted 6 lines
+ reg = <
0x168400000x1000>;
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ufs0cfgao_rst: reset-controller { + compatible = "mediatek,syscon-reset";It looks to me like this is just two registers inside
ufs0cfg_ao, not a
separate device. Why don't you just add #reset-cells to the parent node?Quoted 7 lines
+ #reset-cells = <1>;
+ mediatek,reset-bits =
+ <0x48 3 0x4c 3 100>,
+ <0x14800x14c0 100>,
+ <0x14810x14c1 100>,
+ <0x14820x14c2 0>;
+ };Quoted 4 lines
Why is this in DT? This should be a table in the reset driver.
regards
Philipp
Quoted 8 lines
Regarding the child node and reset-bits in DT,
We chose the child node approach with 'mediatek,reset-bits' defined in DT to keep the reset line descriptions self-contained and reusable across different SoC variants. MediaTek has many SoCs (mt8183, mt6985, mt6989, ...) where the same UFS subsystem may have different register offsets for reset lines. By describing them in DT, we can support new SoC variants by updating the DT alone, without requiring a new driver patch for every new SoC.
This makes adding new SoCs that fit the binding convenient for a while but hurts maintainability in the long run.
These bindings seem to never be generic enough to last more than a few SoC generations, and then something different comes along. Case in point, your new binding is different from ti,reset-bits. So we'd just collect more and more of them over time.
Also it would be much harder to fix things that can not be expressed by the binding after the fact, for example when it turns out that a reset control bit is inverted.
Quoted 3 lines
This approach is also consistent with the existing 'ti,syscon-reset' binding, which uses a similar per-entry table property 'ti,reset-bits' to describe reset lines within a syscon block.
Note that I tried to gently pushed back against that when it was introduced. I now think having it let through was a mistake.
The argument back then was that listing resets in arrays in the driver would become unmaintainable, and so far I have seen no indication that this would have become true.
Also the idea was that this was generic enough to be reused for a lot of SoCs. That didn't happen either.
I'd prefer if you could just enumerate your resets and use the ids as an indices into arrays in the driver.
regards
Philipp
Re: [PATCH v1 1/2] Documentation: dt: reset: add mediatek,syscon-reset binding
Quoted 2 lines · Philipp Zabel
Also the idea was that this was generic enough to be reused for a lot of SoCs. That didn't happen either.
Hi Philipp,
Yes, it is generic enough to be reused across many SoCs. MediaTek previously used that approach, but was told it was not acceptable. I think that is why it did not happen.
I am also curious why hi3798cv200.dtsi#L134 is allowed to use this method?
Quoted 6 lines
I'd prefer if you could just enumerate your resets and use the ids as an indices into arrays in the driver.
regards
Philipp
Thank you for your suggestion.
I will hold off on this patch for now and follow your recommendation.
Thanks
Peter
PATCH 2/2 reset: mediatek: add syscon-based reset controller driver
In reply to [email protected]From: Peter Wang <[email protected]>
Add a new reset controller driver for MediaTek SoCs that expose reset lines through memory-mapped registers managed by a syscon node.
The driver reads reset line configurations from the device tree property "mediatek,reset-bits", which encodes each reset as a 5-tuple of:
<assert_offset, assert_bit, deassert_offset, deassert_bit, delay_us>
This allows support for hardware designs that use separate set/clear registers for assertion and deassertion. The regmap handle is obtained from the parent syscon node, and the driver registers itself with the kernel reset controller framework, providing assert, deassert, and reset operations.
The per-line pulse width between assert and deassert is configured via the 'delay_us' field in the 'mediatek,reset-bits' device tree property. If set to zero, no delay is inserted.
--- drivers/reset/Kconfig | 10 ++ drivers/reset/Makefile | 1 + drivers/reset/reset-mediatek-syscon.c | 230 ++++++++++++++++++++++++++ 3 files changed, 241 insertions(+) create mode 100644 drivers/reset/reset-mediatek-syscon.c
drivers/reset/Kconfig +10 -0
@@ -187,6 +187,16 @@ config RESET_MCHP_SPARX5 help This driver supports switch core reset for the Microchip Sparx5 SoC. +config RESET_MEDIATEK_SYSCON + tristate "MediaTek Syscon Reset Driver" + depends on (ARCH_MEDIATEK || COMPILE_TEST) && HAS_IOMEM && OF + select MFD_SYSCON + help + This enables reset driver support for MediaTek devices + that use memory-mapped reset registers as part of a syscon + device node. Say Y if you want to control reset signals + provided by this controller. Otherwise, say N. + config RESET_NPCM bool "NPCM BMC Reset Driver" if COMPILE_TEST default ARCH_NPCM
drivers/reset/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_RESET_K230) += reset-k230.o obj-$(CONFIG_RESET_LANTIQ) += reset-lantiq.o obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o obj-$(CONFIG_RESET_MCHP_SPARX5) += reset-microchip-sparx5.o +obj-$(CONFIG_RESET_MEDIATEK_SYSCON) += reset-mediatek-syscon.o obj-$(CONFIG_RESET_NPCM) += reset-npcm.o obj-$(CONFIG_RESET_NUVOTON_MA35D1) += reset-ma35d1.o obj-$(CONFIG_RESET_PISTACHIO) += reset-pistachio.o
drivers/reset/reset-mediatek-syscon.c new file +230 -0
230 lines not on this page · raw message
Signature · 1 line
2.45.2
[email protected]
AI reviewRe: [PATCH v1 2/2] reset: mediatek: add syscon-based reset controller driver
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] The driver incorrectly uses read-modify-write operations (`regmap_write_bits`) on dedicated…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The driver incorrectly uses read-modify-write operations (regmap_write_bits) on dedicated set/clear registers, causing spurious resets or clear operations on unrelated hardware lines.
- [Medium] The temporary array arr is allocated with devm_kcalloc, permanently wasting memory for the lifetime of the device.
--
commit 51d3326953762868e035e2bcec526fcc8e9e6083
Author: Peter Wang <[email protected]>
reset: mediatek: add syscon-based reset controller driver
Add a new reset controller driver for MediaTek SoCs that expose reset lines through memory-mapped registers managed by a syscon node. The driver reads reset configurations from the mediatek,reset-bits property.
Quoted 5 lines
drivers/reset/reset-mediatek-syscon.c new file +0
-0
[ ... ]
drivers/reset/reset-mediatek-syscon.c line 71
Quoted 9 lines
drivers/reset/reset-mediatek-syscon.c new file +9
-0+static int mediatek_syscon_reset_assert (struct reset_controller_dev *rcdev, +unsigned long id) +{ +struct mediatek_syscon_reset_data *data = + container_of(rcdev, struct mediatek_syscon_reset_data, rcdev); +struct mediatek_syscon_reset_control *rstc = &data->mrstc[id]; +unsigned int val =BIT (rstc->assert_bit); + +return regmap_write_bits (data->regmap, rstc->assert_offset, val, val);
[Severity: High]
Since the hardware uses separate set and clear registers, could using regmap_write_bits() here cause an unintended read-modify-write cycle?
If the register is Write-1-to-Set, reading it might return the current status, and writing that back will unintentionally write '1' to other active lines in the same register. Should this use a direct regmap_write() instead?
Quoted 4 lines
drivers/reset/reset-mediatek-syscon.c new file +4
-0+} + +/** +* mediatek_syscon_reset_deassert() - Deassert a specific reset line.
[ ... ]
drivers/reset/reset-mediatek-syscon.c line 94
Quoted 10 lines
+ */
drivers/reset/reset-mediatek-syscon.c new file +9
-0+static int mediatek_syscon_reset_deassert (struct reset_controller_dev *rcdev, +unsigned long id) +{ +struct mediatek_syscon_reset_data *data = + container_of(rcdev, struct mediatek_syscon_reset_data, rcdev); +struct mediatek_syscon_reset_control *rstc = &data->mrstc[id]; +unsigned int val =BIT (rstc->deassert_bit); + +return regmap_write_bits (data->regmap, rstc->deassert_offset, val, val);
[Severity: High]
Similarly, for the deassert (Write-1-to-Clear) register, does using a read-modify-write operation here risk unintentionally clearing other unrelated reset lines that happen to read back as '1'?
Quoted 1 line
+}
[ ... ]
Quoted 2 lines
drivers/reset/reset-mediatek-syscon.c new file +2
-0+static int mediatek_syscon_reset_probe (struct platform_device *pdev) +{
[ ... ]
drivers/reset/reset-mediatek-syscon.c line 168
Quoted 8 lines
drivers/reset/reset-mediatek-syscon.c new file +8
-0+if (count %5 !=0 ) { +dev_err (dev,"mediatek,reset-bits count (%d) must be a multiple of 5\n" , count); +return -EINVAL ; + } + + nr_resets = count /5 ; + + arr =devm_kcalloc (dev, count,sizeof (u32),GFP_KERNEL );
[Severity: Medium]
Since arr is only used temporarily during probe to parse the device tree properties and is not needed afterwards, does using devm_kcalloc() unnecessarily keep this memory allocated for the lifetime of the device?
Would a standard kcalloc() followed by a kfree() at the end of the function be more appropriate?
Quoted 4 lines
drivers/reset/reset-mediatek-syscon.c new file +4
-0+if (!arr) +return -ENOMEM ; + + ret =of_property_read_u32_array (np,"mediatek,reset-bits" , arr, count);
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2