Skip to contentSkip to conversation

introduce TI reset controller for MT8192 SoC

PATCH Superseded Crystal Guo 4 participants 27 messages Aug 17, 2020 – Sep 29, 2020 1 message not in the archive

Subsystems (3)

v4 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v4 cover introduce TI reset controller for MT8192 SoC

v4:
fix typos on v3 commit message.

v3:
1. revert v2 changes.
2. add 'reset-duration-us' property to declare a minimum delay, which needs to be waited between assert and deassert.
3. add 'mediatek,infra-reset' to compatible.

v2 changes:
https://patchwork.kernel.org/patch/11697371/
1. add 'assert-deassert-together' property to introduce a new reset handler, which allows device to do serialized assert and deassert operations in a single step by 'reset' method.
2. add 'update-force' property to introduce force-update method, which forces the write operation in case the read already happens to return the correct value.
3. add 'generic-reset' to compatible

v1 changes:
https://patchwork.kernel.org/patch/11690523/
https://patchwork.kernel.org/patch/11690527/

Crystal Guo (4):
dt-binding: reset-controller: ti: add reset-duration-us property
dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to
compatible
reset-controller: ti: introduce a new reset handler
arm64: dts: mt8192: add infracfg_rst node

 .../bindings/reset/ti-syscon-reset.txt        |  6 +++++
 arch/arm64/boot/dts/mediatek/mt8192.dtsi      | 11 +++++++-
 drivers/reset/reset-ti-syscon.c               | 26 +++++++++++++++++--
 3 files changed, 40 insertions(+), 3 deletions(-)
#1 lore raw

PATCH v4 1/4 dt-binding: reset-controller: ti: add reset-duration-us property

introduce 'reset' method to allow device do serialized assert and deassert operations in a single step, which needs a minimum delay to be waited between assert and deassert.

---
 Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +5 -0
index 86945502ccb5..ab041032339b 100644
@@ -59,6 +59,11 @@ Required properties:
 Please also refer to Documentation/devicetree/bindings/reset/reset.txt for
 common reset controller usage by consumers.
 
+Optional properties:
+- reset-duration-us: When do serialized assert and deassert operations, minimum delay in microseconds
+is needed to be waited between an assert and a deassert to reset the device. This value can be 0, 0 means
+that such a delay is not needed.
+
 Example:
 --------
 The following example demonstrates a syscon node, the reset controller node
Signature · 1 line
2.18.0
maintainer
#2 lore raw

Re: [v4,1/4] dt-binding: reset-controller: ti: add reset-duration-us property

Quoted 3 lines · Crystal Guo

introduce 'reset' method to allow device do serialized assert and deassert operations in a single step, which needs a minimum delay to be waited between assert and deassert.

Why is Mediatek adding to a TI binding?

Quoted 11 lines
---
 Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +0 -0
index 86945502ccb5..ab041032339b 100644

Documentation/devicetree/bindings/reset/ti-syscon-reset.txt Required properties: · line 65

Quoted 7 lines
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +4 -0
@@ -59,6 +59,11 @@ Required properties:
 Please also refer to Documentation/devicetree/bindings/reset/reset.txt for
 common reset controller usage by consumers.
 
+Optional properties:
+- reset-duration-us: When do serialized assert and deassert operations, minimum delay in microseconds
+is needed to be waited between an assert and a deassert to reset the device. This value can be 0, 0 means
+that such a delay is not needed.

This goes in the reset controller node or each consumer? For the latter, it should be a cell in 'resets' if you need this. But really, I think the reset controller should enforce some minimum time that works for all consumers. Surely having a minimum time per reset isn't really needed.

Rob

#3 lore raw

Re: [v4,1/4] dt-binding: reset-controller: ti: add reset-duration-us property

Quoted 6 lines · Rob Herring
Quoted 3 lines · Crystal Guo

introduce 'reset' method to allow device do serialized assert and deassert operations in a single step, which needs a minimum delay to be waited between assert and deassert.

Why is Mediatek adding to a TI binding?

TI reset-controller provides a common reset management, and is suitable for Mediatek SoCs, thus Mediatek wants to reuse this driver for reset.

Quoted 25 lines
Quoted 12 lines
---
 Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 5 +++++
 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +0 -0
index 86945502ccb5..ab041032339b 100644

Documentation/devicetree/bindings/reset/ti-syscon-reset.txt Required properties: · line 65

Quoted 7 lines
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +4 -0
@@ -59,6 +59,11 @@ Required properties:
 Please also refer to Documentation/devicetree/bindings/reset/reset.txt for
 common reset controller usage by consumers.
 
+Optional properties:
+- reset-duration-us: When do serialized assert and deassert operations, minimum delay in microseconds
+is needed to be waited between an assert and a deassert to reset the device. This value can be 0, 0 means
+that such a delay is not needed.

This goes in the reset controller node or each consumer? For the latter, it should be a cell in 'resets' if you need this. But really, I think the reset controller should enforce some minimum time that works for all consumers. Surely having a minimum time per reset isn't really needed.

Quoted 1 line

Rob

'reset-duration-us' will be in the reset controller node, and it's optional. If minimum delay is needed to be waited between an assert and a deassert to reset the device, this property will be set.Otherwise no need to set this property.

Best Regards
Crystal

#4 lore raw

PATCH v4 2/4 dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to compatible

In reply to Crystal Guo

The TI syscon reset controller provides a common reset management, and is suitable for MTK SoCs. Add compatible 'mediatek,infra-reset', which denotes to use ti reset-controller driver directly.

---
 Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +1 -0
index ab041032339b..5a0e9365b51b 100644
@@ -25,6 +25,7 @@ Required properties:
 			    "ti,k2l-pscrst"
 			    "ti,k2hk-pscrst"
 			    "ti,syscon-reset"
+			    "mediatek,infra-reset", "ti,syscon-reset"
  - #reset-cells		: Should be 1. Please see the reset consumer node below
 			  for usage details
  - ti,reset-bits	: Contains the reset control register information
Signature · 1 line
2.18.0
maintainer
#5 lore raw

Re: [v4,2/4] dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to compatible

Quoted 14 lines · Crystal Guo

The TI syscon reset controller provides a common reset management, and is suitable for MTK SoCs. Add compatible 'mediatek,infra-reset', which denotes to use ti reset-controller driver directly.

---
 Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +0 -0
index ab041032339b..5a0e9365b51b 100644

Documentation/devicetree/bindings/reset/ti-syscon-reset.txt Required properties: · line 28

Quoted 4 lines
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +1 -0
@@ -25,6 +25,7 @@ Required properties:
 			    "ti,k2l-pscrst"
 			    "ti,k2hk-pscrst"
 			    "ti,syscon-reset"
+			    "mediatek,infra-reset", "ti,syscon-reset"

You need your own binding doc. If you can use the same driver then fine, but that's a separate issue. There's also reset-simple driver if you have just array of 32-bit registers with a bit per reset.

Don't repeat 'ti,reset-bits' either.

Quoted 5 lines
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +0 -0
  - #reset-cells		: Should be 1. Please see the reset consumer node below
 			  for usage details
  - ti,reset-bits	: Contains the reset control register information
Signature · 1 line
2.18.0
#6 lore raw

Re: [v4,2/4] dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to compatible

Quoted 24 lines · Rob Herring
Quoted 14 lines · Crystal Guo

The TI syscon reset controller provides a common reset management, and is suitable for MTK SoCs. Add compatible 'mediatek,infra-reset', which denotes to use ti reset-controller driver directly.

---
 Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +0 -0
index ab041032339b..5a0e9365b51b 100644

Documentation/devicetree/bindings/reset/ti-syscon-reset.txt Required properties: · line 28

Quoted 4 lines
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +1 -0
@@ -25,6 +25,7 @@ Required properties:
 			    "ti,k2l-pscrst"
 			    "ti,k2hk-pscrst"
 			    "ti,syscon-reset"
+			    "mediatek,infra-reset", "ti,syscon-reset"

You need your own binding doc. If you can use the same driver then fine, but that's a separate issue. There's also reset-simple driver if you have just array of 32-bit registers with a bit per reset.

Quoted 1 line

Don't repeat 'ti,reset-bits' either.

Do you mean I should add a Mediatek reset binding doc, although Mediatek reuse the TI reset controller directly?

Best Regards
Crystal

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +0 -0
  - #reset-cells		: Should be 1. Please see the reset consumer node below
 			  for usage details
  - ti,reset-bits	: Contains the reset control register information
Signature · 1 line
2.18.0

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#7 lore raw

Re: [v4,2/4] dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to compatible

Hi Rob,

Quoted 25 lines · Crystal Guo
Quoted 24 lines · Rob Herring
Quoted 14 lines · Crystal Guo

The TI syscon reset controller provides a common reset management, and is suitable for MTK SoCs. Add compatible 'mediatek,infra-reset', which denotes to use ti reset-controller driver directly.

---
 Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +0 -0
index ab041032339b..5a0e9365b51b 100644

Documentation/devicetree/bindings/reset/ti-syscon-reset.txt Required properties: · line 28

Quoted 4 lines
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +1 -0
@@ -25,6 +25,7 @@ Required properties:
 			    "ti,k2l-pscrst"
 			    "ti,k2hk-pscrst"
 			    "ti,syscon-reset"
+			    "mediatek,infra-reset", "ti,syscon-reset"

You need your own binding doc. If you can use the same driver then fine, but that's a separate issue. There's also reset-simple driver if you have just array of 32-bit registers with a bit per reset.

Quoted 4 lines
Quoted 1 line

Don't repeat 'ti,reset-bits' either.

Do you mean I should add a Mediatek reset binding doc, although Mediatek reuse the TI reset controller directly?

Hmm, how do you envision not repeating the same bits in a separate binding? Does it help if I convert this to YAML first without a ti, prefix in the file name?

The usage philosophy definitely was to use a <soc-compatible> followed by the <generic-compatible>. This is how all of our reset nodes were added as well.

Looks like Andrew may have misinterpreted your comment [1] during the original binding and changed "syscon-reset" to "ti,syscon-reset" in the final version [2].

regards
Suman

[1] https://lore.kernel.org/patchwork/comment/876688/
[2] https://lore.kernel.org/patchwork/patch/693172/

Quoted 10 lines

Best Regards
Crystal

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +0 -0
  - #reset-cells		: Should be 1. Please see the reset consumer node below
 			  for usage details
  - ti,reset-bits	: Contains the reset control register information
Signature · 1 line
2.18.0
maintainer
#8 lore raw

Re: [v4,2/4] dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to compatible

Quoted 29 lines · Suman Anna

Hi Rob,

Quoted 25 lines · Crystal Guo
Quoted 24 lines · Rob Herring
Quoted 14 lines · Crystal Guo

The TI syscon reset controller provides a common reset management, and is suitable for MTK SoCs. Add compatible 'mediatek,infra-reset', which denotes to use ti reset-controller driver directly.

---
 Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +0 -0
index ab041032339b..5a0e9365b51b 100644

Documentation/devicetree/bindings/reset/ti-syscon-reset.txt Required properties: · line 28

Quoted 4 lines
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +1 -0
@@ -25,6 +25,7 @@ Required properties:
                        "ti,k2l-pscrst"
                        "ti,k2hk-pscrst"
                        "ti,syscon-reset"
+                       "mediatek,infra-reset", "ti,syscon-reset"

You need your own binding doc. If you can use the same driver then fine, but that's a separate issue. There's also reset-simple driver if you have just array of 32-bit registers with a bit per reset.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Don't repeat 'ti,reset-bits' either.

Do you mean I should add a Mediatek reset binding doc, although Mediatek reuse the TI reset controller directly?

Hmm, how do you envision not repeating the same bits in a separate binding?

I mean 'ti,reset-bits' isn't really something that should have been in DT in the first place, but rather implied by the compatible string.

Quoted 1 line

Does it help if I convert this to YAML first without a ti, prefix in the file name?

No, I don't think this should be a shared binding. The driver may be able to be shared, but that's independent from the binding.

Rob

#9 lore raw

Re: [v4,2/4] dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to compatible

Quoted 32 lines · Rob Herring
Quoted 31 lines · Suman Anna

Hi Rob,

Quoted 27 lines · Crystal Guo
Quoted 25 lines · Rob Herring
Quoted 14 lines · Crystal Guo

The TI syscon reset controller provides a common reset management, and is suitable for MTK SoCs. Add compatible 'mediatek,infra-reset', which denotes to use ti reset-controller driver directly.

---
 Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +0 -0
index ab041032339b..5a0e9365b51b 100644

Documentation/devicetree/bindings/reset/ti-syscon-reset.txt Required properties: · line 28

Quoted 4 lines
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +1 -0
@@ -25,6 +25,7 @@ Required properties:
                        "ti,k2l-pscrst"
                        "ti,k2hk-pscrst"
                        "ti,syscon-reset"
+                       "mediatek,infra-reset", "ti,syscon-reset"

You need your own binding doc. If you can use the same driver then fine, but that's a separate issue. There's also reset-simple driver if you have just array of 32-bit registers with a bit per reset.

Don't repeat 'ti,reset-bits' either.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Do you mean I should add a Mediatek reset binding doc, although Mediatek reuse the TI reset controller directly?

Hmm, how do you envision not repeating the same bits in a separate binding?

I mean 'ti,reset-bits' isn't really something that should have been in DT in the first place, but rather implied by the compatible string.

Ok, should I be deprecating this and move this data to driver then?

I am assuming that is how you are envisioning the new Mediatek binding to be atleast.

regards
Suman

Quoted 8 lines
Quoted 2 lines

Does it help if I convert this to YAML first without a ti, prefix in the file name?

No, I don't think this should be a shared binding. The driver may be able to be shared, but that's independent from the binding.

Rob

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

maintainer
#10 lore raw

Re: [v4,2/4] dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to compatible

Quoted 37 lines · Suman Anna
Quoted 35 lines · Rob Herring
Quoted 34 lines · Suman Anna

Hi Rob,

Quoted 29 lines · Crystal Guo
Quoted 24 lines · Rob Herring
Quoted 14 lines · Crystal Guo

The TI syscon reset controller provides a common reset management, and is suitable for MTK SoCs. Add compatible 'mediatek,infra-reset', which denotes to use ti reset-controller driver directly.

---
 Documentation/devicetree/bindings/reset/ti-syscon-reset.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +0 -0
index ab041032339b..5a0e9365b51b 100644

Documentation/devicetree/bindings/reset/ti-syscon-reset.txt Required properties: · line 28

Quoted 4 lines
Documentation/devicetree/bindings/reset/ti-syscon-reset.txt +1 -0
@@ -25,6 +25,7 @@ Required properties:
                        "ti,k2l-pscrst"
                        "ti,k2hk-pscrst"
                        "ti,syscon-reset"
+                       "mediatek,infra-reset", "ti,syscon-reset"

You need your own binding doc. If you can use the same driver then fine, but that's a separate issue. There's also reset-simple driver if you have just array of 32-bit registers with a bit per reset.

Quoted 1 line

Don't repeat 'ti,reset-bits' either.

Do you mean I should add a Mediatek reset binding doc, although Mediatek reuse the TI reset controller directly?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Hmm, how do you envision not repeating the same bits in a separate binding?

I mean 'ti,reset-bits' isn't really something that should have been in DT in the first place, but rather implied by the compatible string.

Ok, should I be deprecating this and move this data to driver then?

No, I'm just asking to not have new users.

Quoted 2 lines

I am assuming that is how you are envisioning the new Mediatek binding to be atleast.

Right.

Rob

#11 lore raw

PATCH v4 3/4 reset-controller: ti: introduce a new reset handler

In reply to Crystal Guo

Introduce ti_syscon_reset() to integrate assert and deassert together. If some modules need do serialized assert and deassert operations to reset itself, reset_control_reset can be called for convenience.

Such as reset-qcom-aoss.c, it integrates assert and deassert together by 'reset' method. MTK Socs also need this method to perform reset.

---
 drivers/reset/reset-ti-syscon.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/reset/reset-ti-syscon.c +24 -2
index a2635c21db7f..08289342f9af 100644
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -56,6 +57,7 @@ struct ti_syscon_reset_data {
 	struct regmap *regmap;
 	struct ti_syscon_reset_control *controls;
 	unsigned int nr_controls;
+	unsigned int reset_duration_us;
 };
 
 #define to_ti_syscon_reset_data(rcdev)	\
@@ -89,7 +91,7 @@ static int ti_syscon_reset_assert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->assert_bit);
 	value = (control->flags & ASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->assert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->assert_offset, mask, value);
 }
 
 /**
@@ -120,7 +122,7 @@ static int ti_syscon_reset_deassert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->deassert_bit);
 	value = (control->flags & DEASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->deassert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->deassert_offset, mask, value);
 }
 
 /**
@@ -158,9 +160,26 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev,
 		!(control->flags & STATUS_SET);
 }
 
+static int ti_syscon_reset(struct reset_controller_dev *rcdev,
+				  unsigned long id)
+{
+	struct ti_syscon_reset_data *data = to_ti_syscon_reset_data(rcdev);
+	int ret;
+
+	ret = ti_syscon_reset_assert(rcdev, id);
+	if (ret)
+		return ret;
+
+	if (data->reset_duration_us)
+		usleep_range(data->reset_duration_us, data->reset_duration_us * 2);
+
+	return ti_syscon_reset_deassert(rcdev, id);
+}
+
 static const struct reset_control_ops ti_syscon_reset_ops = {
 	.assert		= ti_syscon_reset_assert,
 	.deassert	= ti_syscon_reset_deassert,
+	.reset		= ti_syscon_reset,
 	.status		= ti_syscon_reset_status,
 };
 
@@ -204,6 +223,9 @@ static int ti_syscon_reset_probe(struct platform_device *pdev)
 		controls[i].flags = be32_to_cpup(list++);
 	}
 
+	of_property_read_u32(pdev->dev.of_node,	"reset-duration-us",
+				&data->reset_duration_us);
+
 	data->rcdev.ops = &ti_syscon_reset_ops;
 	data->rcdev.owner = THIS_MODULE;
 	data->rcdev.of_node = np;
Signature · 1 line
2.18.0
#12 lore raw

Re: [v4,3/4] reset-controller: ti: introduce a new reset handler

Hi Crystal,

Quoted 3 lines · Crystal Guo

Introduce ti_syscon_reset() to integrate assert and deassert together. If some modules need do serialized assert and deassert operations to reset itself, reset_control_reset can be called for convenience.

There are multiple changes in this same patch. I think you should split this functionality away from the change for the regmap_update_bits() to regmap_write_bits(), similar to what you have done in your v2 Patch 4.

Quoted 55 lines

Such as reset-qcom-aoss.c, it integrates assert and deassert together by 'reset' method. MTK Socs also need this method to perform reset.

---
 drivers/reset/reset-ti-syscon.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/reset/reset-ti-syscon.c +8 -2
index a2635c21db7f..08289342f9af 100644
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -56,6 +57,7 @@ struct ti_syscon_reset_data {
 	struct regmap *regmap;
 	struct ti_syscon_reset_control *controls;
 	unsigned int nr_controls;
+	unsigned int reset_duration_us;
 };
 
 #define to_ti_syscon_reset_data(rcdev)	\
@@ -89,7 +91,7 @@ static int ti_syscon_reset_assert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->assert_bit);
 	value = (control->flags & ASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->assert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->assert_offset, mask, value);
 }
 
 /**
@@ -120,7 +122,7 @@ static int ti_syscon_reset_deassert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->deassert_bit);
 	value = (control->flags & DEASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->deassert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->deassert_offset, mask, value);
 }
 
 /**
@@ -158,9 +160,26 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev,
 		!(control->flags & STATUS_SET);
 }
 
+static int ti_syscon_reset(struct reset_controller_dev *rcdev,
+				  unsigned long id)
+{
+	struct ti_syscon_reset_data *data = to_ti_syscon_reset_data(rcdev);

drivers/reset/reset-ti-syscon.c static int ti_syscon_reset_status(struct reset_controller_dev *rcdev, · line 176

Quoted 10 lines
drivers/reset/reset-ti-syscon.c +10 -0
+	int ret;
+
+	ret = ti_syscon_reset_assert(rcdev, id);
+	if (ret)
+		return ret;
+
+	if (data->reset_duration_us)
+		usleep_range(data->reset_duration_us, data->reset_duration_us * 2);
+
+	return ti_syscon_reset_deassert(rcdev, id);

I echo Philipp's comments [1] from your original v1 series about this. We don't need a property to distinguish this, but you could add a flag using match data and Mediatek compatible, and use that within this function, or optionally set this ops based on compatible (whatever is preferred by Philipp).

regards
Suman

[1] https://patchwork.kernel.org/comment/23519193/

Quoted 11 lines
drivers/reset/reset-ti-syscon.c +3 -0
+}
+
 static const struct reset_control_ops ti_syscon_reset_ops = {
 	.assert		= ti_syscon_reset_assert,
 	.deassert	= ti_syscon_reset_deassert,
+	.reset		= ti_syscon_reset,
 	.status		= ti_syscon_reset_status,
 };
 

drivers/reset/reset-ti-syscon.c static int ti_syscon_reset_probe(struct platform_device *pdev) · line 231

Quoted 9 lines
drivers/reset/reset-ti-syscon.c +3 -0
@@ -204,6 +223,9 @@ static int ti_syscon_reset_probe(struct platform_device *pdev)
 		controls[i].flags = be32_to_cpup(list++);
 	}
 
+	of_property_read_u32(pdev->dev.of_node,	"reset-duration-us",
+				&data->reset_duration_us);
+
 	data->rcdev.ops = &ti_syscon_reset_ops;
 	data->rcdev.owner = THIS_MODULE;
 	data->rcdev.of_node = np;

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#13 lore raw

Re: [v4,3/4] reset-controller: ti: introduce a new reset handler

Quoted 11 lines · Suman Anna

Hi Crystal,

Quoted 3 lines · Crystal Guo

Introduce ti_syscon_reset() to integrate assert and deassert together. If some modules need do serialized assert and deassert operations to reset itself, reset_control_reset can be called for convenience.

There are multiple changes in this same patch. I think you should split this functionality away from the change for the regmap_update_bits() to regmap_write_bits(), similar to what you have done in your v2 Patch 4.

Thanks for your suggestion.
I will split this patch in the next version.

Quoted 71 lines
Quoted 55 lines

Such as reset-qcom-aoss.c, it integrates assert and deassert together by 'reset' method. MTK Socs also need this method to perform reset.

---
 drivers/reset/reset-ti-syscon.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/reset/reset-ti-syscon.c +8 -2
index a2635c21db7f..08289342f9af 100644
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -56,6 +57,7 @@ struct ti_syscon_reset_data {
 	struct regmap *regmap;
 	struct ti_syscon_reset_control *controls;
 	unsigned int nr_controls;
+	unsigned int reset_duration_us;
 };
 
 #define to_ti_syscon_reset_data(rcdev)	\
@@ -89,7 +91,7 @@ static int ti_syscon_reset_assert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->assert_bit);
 	value = (control->flags & ASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->assert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->assert_offset, mask, value);
 }
 
 /**
@@ -120,7 +122,7 @@ static int ti_syscon_reset_deassert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->deassert_bit);
 	value = (control->flags & DEASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->deassert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->deassert_offset, mask, value);
 }
 
 /**
@@ -158,9 +160,26 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev,
 		!(control->flags & STATUS_SET);
 }
 
+static int ti_syscon_reset(struct reset_controller_dev *rcdev,
+				  unsigned long id)
+{
+	struct ti_syscon_reset_data *data = to_ti_syscon_reset_data(rcdev);

drivers/reset/reset-ti-syscon.c static int ti_syscon_reset_status(struct reset_controller_dev *rcdev, · line 176

Quoted 10 lines
drivers/reset/reset-ti-syscon.c +10 -0
+	int ret;
+
+	ret = ti_syscon_reset_assert(rcdev, id);
+	if (ret)
+		return ret;
+
+	if (data->reset_duration_us)
+		usleep_range(data->reset_duration_us, data->reset_duration_us * 2);
+
+	return ti_syscon_reset_deassert(rcdev, id);

I echo Philipp's comments [1] from your original v1 series about this. We don't need a property to distinguish this, but you could add a flag using match data and Mediatek compatible, and use that within this function, or optionally set this ops based on compatible (whatever is preferred by Philipp).

Quoted 5 lines

regards
Suman

[1] https://patchwork.kernel.org/comment/23519193/

Hi Suman, Philipp

Which method would you recommend more?
1. like v2 patch, but assign the flag "data->assert_deassert_together" directly (maybe rename "assert_deassert_together" to "reset_op_available")

2. use Mediatek compatible to decide the reset handler available or not.

Thanks
Crystal

Quoted 21 lines
Quoted 20 lines
drivers/reset/reset-ti-syscon.c +6 -0
+}
+
 static const struct reset_control_ops ti_syscon_reset_ops = {
 	.assert		= ti_syscon_reset_assert,
 	.deassert	= ti_syscon_reset_deassert,
+	.reset		= ti_syscon_reset,
 	.status		= ti_syscon_reset_status,
 };
 
@@ -204,6 +223,9 @@ static int ti_syscon_reset_probe(struct platform_device *pdev)
 		controls[i].flags = be32_to_cpup(list++);
 	}
 
+	of_property_read_u32(pdev->dev.of_node,	"reset-duration-us",
+				&data->reset_duration_us);
+
 	data->rcdev.ops = &ti_syscon_reset_ops;
 	data->rcdev.owner = THIS_MODULE;
 	data->rcdev.of_node = np;
#14 lore raw

Re: [v4,3/4] reset-controller: ti: introduce a new reset handler

Quoted 92 lines · Crystal Guo
Quoted 11 lines · Suman Anna

Hi Crystal,

Quoted 3 lines · Crystal Guo

Introduce ti_syscon_reset() to integrate assert and deassert together. If some modules need do serialized assert and deassert operations to reset itself, reset_control_reset can be called for convenience.

There are multiple changes in this same patch. I think you should split this functionality away from the change for the regmap_update_bits() to regmap_write_bits(), similar to what you have done in your v2 Patch 4.

Thanks for your suggestion.
I will split this patch in the next version.

Quoted 71 lines
Quoted 55 lines

Such as reset-qcom-aoss.c, it integrates assert and deassert together by 'reset' method. MTK Socs also need this method to perform reset.

---
 drivers/reset/reset-ti-syscon.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/reset/reset-ti-syscon.c +8 -2
index a2635c21db7f..08289342f9af 100644
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -56,6 +57,7 @@ struct ti_syscon_reset_data {
 	struct regmap *regmap;
 	struct ti_syscon_reset_control *controls;
 	unsigned int nr_controls;
+	unsigned int reset_duration_us;
 };
 
 #define to_ti_syscon_reset_data(rcdev)	\
@@ -89,7 +91,7 @@ static int ti_syscon_reset_assert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->assert_bit);
 	value = (control->flags & ASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->assert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->assert_offset, mask, value);
 }
 
 /**
@@ -120,7 +122,7 @@ static int ti_syscon_reset_deassert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->deassert_bit);
 	value = (control->flags & DEASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->deassert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->deassert_offset, mask, value);
 }
 
 /**
@@ -158,9 +160,26 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev,
 		!(control->flags & STATUS_SET);
 }
 
+static int ti_syscon_reset(struct reset_controller_dev *rcdev,
+				  unsigned long id)
+{
+	struct ti_syscon_reset_data *data = to_ti_syscon_reset_data(rcdev);

drivers/reset/reset-ti-syscon.c static int ti_syscon_reset_status(struct reset_controller_dev *rcdev, · line 176

Quoted 10 lines
drivers/reset/reset-ti-syscon.c +10 -0
+	int ret;
+
+	ret = ti_syscon_reset_assert(rcdev, id);
+	if (ret)
+		return ret;
+
+	if (data->reset_duration_us)
+		usleep_range(data->reset_duration_us, data->reset_duration_us * 2);
+
+	return ti_syscon_reset_deassert(rcdev, id);

I echo Philipp's comments [1] from your original v1 series about this. We don't need a property to distinguish this, but you could add a flag using match data and Mediatek compatible, and use that within this function, or optionally set this ops based on compatible (whatever is preferred by Philipp).

Quoted 5 lines

regards
Suman

[1] https://patchwork.kernel.org/comment/23519193/

Quoted 8 lines

Hi Suman, Philipp

Which method would you recommend more?
1. like v2 patch, but assign the flag "data->assert_deassert_together" directly (maybe rename "assert_deassert_together" to "reset_op_available")

2. use Mediatek compatible to decide the reset handler available or not.

I would go with this option. Anyway, I think you might have to add the reset SoC data as well, based on Rob's comment on the binding.

regards
Suman

Quoted 26 lines

Thanks
Crystal

Quoted 21 lines
Quoted 20 lines
drivers/reset/reset-ti-syscon.c +6 -0
+}
+
 static const struct reset_control_ops ti_syscon_reset_ops = {
 	.assert		= ti_syscon_reset_assert,
 	.deassert	= ti_syscon_reset_deassert,
+	.reset		= ti_syscon_reset,
 	.status		= ti_syscon_reset_status,
 };
 
@@ -204,6 +223,9 @@ static int ti_syscon_reset_probe(struct platform_device *pdev)
 		controls[i].flags = be32_to_cpup(list++);
 	}
 
+	of_property_read_u32(pdev->dev.of_node,	"reset-duration-us",
+				&data->reset_duration_us);
+
 	data->rcdev.ops = &ti_syscon_reset_ops;
 	data->rcdev.owner = THIS_MODULE;
 	data->rcdev.of_node = np;

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#15 lore raw

Re: [v4,3/4] reset-controller: ti: introduce a new reset handler

Quoted 100 lines · Suman Anna
Quoted 99 lines · Crystal Guo
Quoted 11 lines · Suman Anna

Hi Crystal,

Quoted 3 lines · Crystal Guo

Introduce ti_syscon_reset() to integrate assert and deassert together. If some modules need do serialized assert and deassert operations to reset itself, reset_control_reset can be called for convenience.

There are multiple changes in this same patch. I think you should split this functionality away from the change for the regmap_update_bits() to regmap_write_bits(), similar to what you have done in your v2 Patch 4.

Thanks for your suggestion.
I will split this patch in the next version.

Quoted 71 lines
Quoted 55 lines

Such as reset-qcom-aoss.c, it integrates assert and deassert together by 'reset' method. MTK Socs also need this method to perform reset.

---
 drivers/reset/reset-ti-syscon.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/reset/reset-ti-syscon.c +8 -2
index a2635c21db7f..08289342f9af 100644
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -56,6 +57,7 @@ struct ti_syscon_reset_data {
 	struct regmap *regmap;
 	struct ti_syscon_reset_control *controls;
 	unsigned int nr_controls;
+	unsigned int reset_duration_us;
 };
 
 #define to_ti_syscon_reset_data(rcdev)	\
@@ -89,7 +91,7 @@ static int ti_syscon_reset_assert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->assert_bit);
 	value = (control->flags & ASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->assert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->assert_offset, mask, value);
 }
 
 /**
@@ -120,7 +122,7 @@ static int ti_syscon_reset_deassert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->deassert_bit);
 	value = (control->flags & DEASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->deassert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->deassert_offset, mask, value);
 }
 
 /**
@@ -158,9 +160,26 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev,
 		!(control->flags & STATUS_SET);
 }
 
+static int ti_syscon_reset(struct reset_controller_dev *rcdev,
+				  unsigned long id)
+{
+	struct ti_syscon_reset_data *data = to_ti_syscon_reset_data(rcdev);

drivers/reset/reset-ti-syscon.c static int ti_syscon_reset_status(struct reset_controller_dev *rcdev, · line 176

Quoted 10 lines
drivers/reset/reset-ti-syscon.c +10 -0
+	int ret;
+
+	ret = ti_syscon_reset_assert(rcdev, id);
+	if (ret)
+		return ret;
+
+	if (data->reset_duration_us)
+		usleep_range(data->reset_duration_us, data->reset_duration_us * 2);
+
+	return ti_syscon_reset_deassert(rcdev, id);

I echo Philipp's comments [1] from your original v1 series about this. We don't need a property to distinguish this, but you could add a flag using match data and Mediatek compatible, and use that within this function, or optionally set this ops based on compatible (whatever is preferred by Philipp).

Quoted 5 lines

regards
Suman

[1] https://patchwork.kernel.org/comment/23519193/

Hi Suman, Philipp

Which method would you recommend more?
1. like v2 patch, but assign the flag "data->assert_deassert_together" directly (maybe rename "assert_deassert_together" to "reset_op_available")

Quoted 7 lines
Quoted 1 line

2. use Mediatek compatible to decide the reset handler available or not.

I would go with this option. Anyway, I think you might have to add the reset SoC data as well, based on Rob's comment on the binding.

regards
Suman

Thanks for your suggestions
I will add the following changes in the next version,
please correct me if there is any misunderstanding.
1). revert ti-syscon-reset.txt add a new mediatek reset binding doc. 2). split the patch [v4,3/4] with the change for the regmap_update_bits() to regmap_write_bits() and the change to integrate assert and deassert together.
3). add the reset SoC data, which contains the flag "reset_op_available" to decide the reset handler available or not.
4). separate the dts patch from this patch sets

Quoted 27 lines
Quoted 26 lines

Thanks
Crystal

Quoted 21 lines
Quoted 20 lines
drivers/reset/reset-ti-syscon.c +6 -0
+}
+
 static const struct reset_control_ops ti_syscon_reset_ops = {
 	.assert		= ti_syscon_reset_assert,
 	.deassert	= ti_syscon_reset_deassert,
+	.reset		= ti_syscon_reset,
 	.status		= ti_syscon_reset_status,
 };
 
@@ -204,6 +223,9 @@ static int ti_syscon_reset_probe(struct platform_device *pdev)
 		controls[i].flags = be32_to_cpup(list++);
 	}
 
+	of_property_read_u32(pdev->dev.of_node,	"reset-duration-us",
+				&data->reset_duration_us);
+
 	data->rcdev.ops = &ti_syscon_reset_ops;
 	data->rcdev.owner = THIS_MODULE;
 	data->rcdev.of_node = np;
#16 lore raw

Re: [v4,3/4] reset-controller: ti: introduce a new reset handler

Quoted 110 lines · Crystal Guo
Quoted 100 lines · Suman Anna
Quoted 99 lines · Crystal Guo
Quoted 11 lines · Suman Anna

Hi Crystal,

Quoted 3 lines · Crystal Guo

Introduce ti_syscon_reset() to integrate assert and deassert together. If some modules need do serialized assert and deassert operations to reset itself, reset_control_reset can be called for convenience.

There are multiple changes in this same patch. I think you should split this functionality away from the change for the regmap_update_bits() to regmap_write_bits(), similar to what you have done in your v2 Patch 4.

Thanks for your suggestion.
I will split this patch in the next version.

Quoted 71 lines
Quoted 55 lines

Such as reset-qcom-aoss.c, it integrates assert and deassert together by 'reset' method. MTK Socs also need this method to perform reset.

---
 drivers/reset/reset-ti-syscon.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/reset/reset-ti-syscon.c +8 -2
index a2635c21db7f..08289342f9af 100644
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -56,6 +57,7 @@ struct ti_syscon_reset_data {
 	struct regmap *regmap;
 	struct ti_syscon_reset_control *controls;
 	unsigned int nr_controls;
+	unsigned int reset_duration_us;
 };
 
 #define to_ti_syscon_reset_data(rcdev)	\
@@ -89,7 +91,7 @@ static int ti_syscon_reset_assert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->assert_bit);
 	value = (control->flags & ASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->assert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->assert_offset, mask, value);
 }
 
 /**
@@ -120,7 +122,7 @@ static int ti_syscon_reset_deassert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->deassert_bit);
 	value = (control->flags & DEASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->deassert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->deassert_offset, mask, value);
 }
 
 /**
@@ -158,9 +160,26 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev,
 		!(control->flags & STATUS_SET);
 }
 
+static int ti_syscon_reset(struct reset_controller_dev *rcdev,
+				  unsigned long id)
+{
+	struct ti_syscon_reset_data *data = to_ti_syscon_reset_data(rcdev);

drivers/reset/reset-ti-syscon.c static int ti_syscon_reset_status(struct reset_controller_dev *rcdev, · line 176

Quoted 10 lines
drivers/reset/reset-ti-syscon.c +10 -0
+	int ret;
+
+	ret = ti_syscon_reset_assert(rcdev, id);
+	if (ret)
+		return ret;
+
+	if (data->reset_duration_us)
+		usleep_range(data->reset_duration_us, data->reset_duration_us * 2);
+
+	return ti_syscon_reset_deassert(rcdev, id);

I echo Philipp's comments [1] from your original v1 series about this. We don't need a property to distinguish this, but you could add a flag using match data and Mediatek compatible, and use that within this function, or optionally set this ops based on compatible (whatever is preferred by Philipp).

Quoted 5 lines

regards
Suman

[1] https://patchwork.kernel.org/comment/23519193/

Hi Suman, Philipp

Which method would you recommend more?
1. like v2 patch, but assign the flag "data->assert_deassert_together" directly (maybe rename "assert_deassert_together" to "reset_op_available")

Quoted 7 lines
Quoted 1 line

2. use Mediatek compatible to decide the reset handler available or not.

I would go with this option. Anyway, I think you might have to add the reset SoC data as well, based on Rob's comment on the binding.

regards
Suman

Quoted 9 lines

Thanks for your suggestions
I will add the following changes in the next version,
please correct me if there is any misunderstanding.
1). revert ti-syscon-reset.txt add a new mediatek reset binding doc. 2). split the patch [v4,3/4] with the change for the regmap_update_bits() to regmap_write_bits() and the change to integrate assert and deassert together.
3). add the reset SoC data, which contains the flag "reset_op_available" to decide the reset handler available or not.

You would also need to add your SoC-specific data equivalent of the current ti,reset-bits in your infra node. Please see Rob's comments on patch 2. Also, your new Mediatek binding should be in YAML format.

regards
Suman

Quoted 30 lines

4). separate the dts patch from this patch sets

Quoted 27 lines
Quoted 26 lines

Thanks
Crystal

Quoted 21 lines
Quoted 20 lines
drivers/reset/reset-ti-syscon.c +6 -0
+}
+
 static const struct reset_control_ops ti_syscon_reset_ops = {
 	.assert		= ti_syscon_reset_assert,
 	.deassert	= ti_syscon_reset_deassert,
+	.reset		= ti_syscon_reset,
 	.status		= ti_syscon_reset_status,
 };
 
@@ -204,6 +223,9 @@ static int ti_syscon_reset_probe(struct platform_device *pdev)
 		controls[i].flags = be32_to_cpup(list++);
 	}
 
+	of_property_read_u32(pdev->dev.of_node,	"reset-duration-us",
+				&data->reset_duration_us);
+
 	data->rcdev.ops = &ti_syscon_reset_ops;
 	data->rcdev.owner = THIS_MODULE;
 	data->rcdev.of_node = np;
#17 lore raw

Re: [v4,3/4] reset-controller: ti: introduce a new reset handler

Quoted 121 lines · Suman Anna
Quoted 110 lines · Crystal Guo
Quoted 100 lines · Suman Anna
Quoted 99 lines · Crystal Guo
Quoted 11 lines · Suman Anna

Hi Crystal,

Quoted 3 lines · Crystal Guo

Introduce ti_syscon_reset() to integrate assert and deassert together. If some modules need do serialized assert and deassert operations to reset itself, reset_control_reset can be called for convenience.

There are multiple changes in this same patch. I think you should split this functionality away from the change for the regmap_update_bits() to regmap_write_bits(), similar to what you have done in your v2 Patch 4.

Thanks for your suggestion.
I will split this patch in the next version.

Quoted 71 lines
Quoted 55 lines

Such as reset-qcom-aoss.c, it integrates assert and deassert together by 'reset' method. MTK Socs also need this method to perform reset.

---
 drivers/reset/reset-ti-syscon.c | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/reset/reset-ti-syscon.c +8 -2
index a2635c21db7f..08289342f9af 100644
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/delay.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -56,6 +57,7 @@ struct ti_syscon_reset_data {
 	struct regmap *regmap;
 	struct ti_syscon_reset_control *controls;
 	unsigned int nr_controls;
+	unsigned int reset_duration_us;
 };
 
 #define to_ti_syscon_reset_data(rcdev)	\
@@ -89,7 +91,7 @@ static int ti_syscon_reset_assert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->assert_bit);
 	value = (control->flags & ASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->assert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->assert_offset, mask, value);
 }
 
 /**
@@ -120,7 +122,7 @@ static int ti_syscon_reset_deassert(struct reset_controller_dev *rcdev,
 	mask = BIT(control->deassert_bit);
 	value = (control->flags & DEASSERT_SET) ? mask : 0x0;
 
-	return regmap_update_bits(data->regmap, control->deassert_offset, mask, value);
+	return regmap_write_bits(data->regmap, control->deassert_offset, mask, value);
 }
 
 /**
@@ -158,9 +160,26 @@ static int ti_syscon_reset_status(struct reset_controller_dev *rcdev,
 		!(control->flags & STATUS_SET);
 }
 
+static int ti_syscon_reset(struct reset_controller_dev *rcdev,
+				  unsigned long id)
+{
+	struct ti_syscon_reset_data *data = to_ti_syscon_reset_data(rcdev);

drivers/reset/reset-ti-syscon.c static int ti_syscon_reset_status(struct reset_controller_dev *rcdev, · line 176

Quoted 10 lines
drivers/reset/reset-ti-syscon.c +10 -0
+	int ret;
+
+	ret = ti_syscon_reset_assert(rcdev, id);
+	if (ret)
+		return ret;
+
+	if (data->reset_duration_us)
+		usleep_range(data->reset_duration_us, data->reset_duration_us * 2);
+
+	return ti_syscon_reset_deassert(rcdev, id);

I echo Philipp's comments [1] from your original v1 series about this. We don't need a property to distinguish this, but you could add a flag using match data and Mediatek compatible, and use that within this function, or optionally set this ops based on compatible (whatever is preferred by Philipp).

Quoted 5 lines

regards
Suman

[1] https://patchwork.kernel.org/comment/23519193/

Hi Suman, Philipp

Which method would you recommend more?
1. like v2 patch, but assign the flag "data->assert_deassert_together" directly (maybe rename "assert_deassert_together" to "reset_op_available")

Quoted 7 lines
Quoted 1 line

2. use Mediatek compatible to decide the reset handler available or not.

I would go with this option. Anyway, I think you might have to add the reset SoC data as well, based on Rob's comment on the binding.

regards
Suman

Quoted 9 lines

Thanks for your suggestions
I will add the following changes in the next version,
please correct me if there is any misunderstanding.
1). revert ti-syscon-reset.txt add a new mediatek reset binding doc. 2). split the patch [v4,3/4] with the change for the regmap_update_bits() to regmap_write_bits() and the change to integrate assert and deassert together.
3). add the reset SoC data, which contains the flag "reset_op_available" to decide the reset handler available or not.

Quoted 7 lines

You would also need to add your SoC-specific data equivalent of the current ti,reset-bits in your infra node. Please see Rob's comments on patch 2. Also, your new Mediatek binding should be in YAML format.

regards
Suman

Should I add the SoC-specific data as follows? This may also modify the ti original code, is it OK?

+ data->reset_data = of_device_get_match_data(&pdev->dev);
+
+ list = of_get_property(np, data->reset_data->reset_bits, &size);

+static const struct common_reset_data ti_reset_data = {
+ .reset_op_available = false,
+ .reset_bits = "ti, reset-bits",
+};
+
+static const struct common_reset_data mediatek_reset_data = {
+ .reset_op_available = true,
+ .reset_bits = "mediatek, reset-bits",
+};
+
static const struct of_device_id ti_syscon_reset_of_match[] = {

-       { .compatible = "ti,syscon-reset", },
+       { .compatible = "ti,syscon-reset", .data = &ti_reset_data},
+       { .compatible = "mediatek,syscon-reset", .data =
&mediatek_reset_data},
        { /* sentinel */ },

};

Thanks
Crystal

Quoted 31 lines
Quoted 30 lines

4). separate the dts patch from this patch sets

Quoted 27 lines
Quoted 26 lines

Thanks
Crystal

Quoted 21 lines
Quoted 20 lines
drivers/reset/reset-ti-syscon.c +6 -0
+}
+
 static const struct reset_control_ops ti_syscon_reset_ops = {
 	.assert		= ti_syscon_reset_assert,
 	.deassert	= ti_syscon_reset_deassert,
+	.reset		= ti_syscon_reset,
 	.status		= ti_syscon_reset_status,
 };
 
@@ -204,6 +223,9 @@ static int ti_syscon_reset_probe(struct platform_device *pdev)
 		controls[i].flags = be32_to_cpup(list++);
 	}
 
+	of_property_read_u32(pdev->dev.of_node,	"reset-duration-us",
+				&data->reset_duration_us);
+
 	data->rcdev.ops = &ti_syscon_reset_ops;
 	data->rcdev.owner = THIS_MODULE;
 	data->rcdev.of_node = np;
maintainer
#18 lore raw

Re: [v4,3/4] reset-controller: ti: introduce a new reset handler

Hi Crystal,

On Fri, 2020-09-11 at 14:07 +0800, Crystal Guo wrote:
[...]

Review

Quoted 10 lines

Should I add the SoC-specific data as follows? This may also modify the ti original code, is it OK?

(quoted diff) +6 -0
+       data->reset_data = of_device_get_match_data(&pdev->dev);
+
+       list = of_get_property(np, data->reset_data->reset_bits, &size);
 
+static const struct common_reset_data ti_reset_data = {
+       .reset_op_available = false,
+       .reset_bits = "ti, reset-bits",
                            ^

That space doesn't belong there.

Review

Quoted 6 lines
(quoted diff) +6 -0
+};
+
+static const struct common_reset_data mediatek_reset_data = {
+       .reset_op_available = true,
+       .reset_bits = "mediatek, reset-bits",
+};

I understand Robs comments as meaning "ti,reset-bits" should have been called "reset-bits" in the first place, and you shouldn't repeat adding the vendor prefix, as that is implied by the compatible. So this should probably be just "reset-bits".

Otherwise this looks like it should work.

regards
Philipp

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#19 lore raw

Re: [v4,3/4] reset-controller: ti: introduce a new reset handler

Quoted 17 lines · Philipp Zabel

Hi Crystal,

On Fri, 2020-09-11 at 14:07 +0800, Crystal Guo wrote:
[...]

Review

Quoted 10 lines

Should I add the SoC-specific data as follows? This may also modify the ti original code, is it OK?

(quoted diff) +6 -0
+       data->reset_data = of_device_get_match_data(&pdev->dev);
+
+       list = of_get_property(np, data->reset_data->reset_bits, &size);
 
+static const struct common_reset_data ti_reset_data = {
+       .reset_op_available = false,
+       .reset_bits = "ti, reset-bits",
                            ^

That space doesn't belong there.

Quoted 11 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+};
+
+static const struct common_reset_data mediatek_reset_data = {
+       .reset_op_available = true,
+       .reset_bits = "mediatek, reset-bits",
+};

I understand Robs comments as meaning "ti,reset-bits" should have been called "reset-bits" in the first place, and you shouldn't repeat adding the vendor prefix, as that is implied by the compatible. So this should probably be just "reset-bits".

Hmm, not sure about that. I think Rob wants the reset data itself to be added in the driver as is being done on some other SoCs (eg: like in reset-qcom-pdc.c).

regards
Suman

Quoted 6 lines

Otherwise this looks like it should work.

regards
Philipp

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#20 lore raw

Re: [v4,3/4] reset-controller: ti: introduce a new reset handler

Quoted 30 lines · Suman Anna
Quoted 17 lines · Philipp Zabel

Hi Crystal,

On Fri, 2020-09-11 at 14:07 +0800, Crystal Guo wrote:
[...]

Review

Quoted 10 lines

Should I add the SoC-specific data as follows? This may also modify the ti original code, is it OK?

(quoted diff) +6 -0
+       data->reset_data = of_device_get_match_data(&pdev->dev);
+
+       list = of_get_property(np, data->reset_data->reset_bits, &size);
 
+static const struct common_reset_data ti_reset_data = {
+       .reset_op_available = false,
+       .reset_bits = "ti, reset-bits",
                            ^

That space doesn't belong there.

Quoted 11 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+};
+
+static const struct common_reset_data mediatek_reset_data = {
+       .reset_op_available = true,
+       .reset_bits = "mediatek, reset-bits",
+};

I understand Robs comments as meaning "ti,reset-bits" should have been called "reset-bits" in the first place, and you shouldn't repeat adding the vendor prefix, as that is implied by the compatible. So this should probably be just "reset-bits".

Quoted 6 lines

Hmm, not sure about that. I think Rob wants the reset data itself to be added in the driver as is being done on some other SoCs (eg: like in reset-qcom-pdc.c).

regards
Suman

Hi Rob,

Can you help to comment about this point?
Modify "ti,reset-bits" to "reset-bits" or add "mediatek,reset-bits" ?

Many thanks~
Crystal

Quoted 7 lines
Quoted 6 lines

Otherwise this looks like it should work.

regards
Philipp

#21 lore raw

Re: [v4,3/4] reset-controller: ti: introduce a new reset handler

Quoted 37 lines · Crystal Guo
Quoted 30 lines · Suman Anna
Quoted 17 lines · Philipp Zabel

Hi Crystal,

On Fri, 2020-09-11 at 14:07 +0800, Crystal Guo wrote:
[...]

Review

Quoted 10 lines

Should I add the SoC-specific data as follows? This may also modify the ti original code, is it OK?

(quoted diff) +6 -0
+       data->reset_data = of_device_get_match_data(&pdev->dev);
+
+       list = of_get_property(np, data->reset_data->reset_bits, &size);
 
+static const struct common_reset_data ti_reset_data = {
+       .reset_op_available = false,
+       .reset_bits = "ti, reset-bits",
                            ^

That space doesn't belong there.

Quoted 11 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+};
+
+static const struct common_reset_data mediatek_reset_data = {
+       .reset_op_available = true,
+       .reset_bits = "mediatek, reset-bits",
+};

I understand Robs comments as meaning "ti,reset-bits" should have been called "reset-bits" in the first place, and you shouldn't repeat adding the vendor prefix, as that is implied by the compatible. So this should probably be just "reset-bits".

Quoted 6 lines

Hmm, not sure about that. I think Rob wants the reset data itself to be added in the driver as is being done on some other SoCs (eg: like in reset-qcom-pdc.c).

regards
Suman

Quoted 15 lines

Hi Rob,

Can you help to comment about this point?
Modify "ti,reset-bits" to "reset-bits" or add "mediatek,reset-bits" ?

Many thanks~
Crystal

Quoted 7 lines
Quoted 6 lines

Otherwise this looks like it should work.

regards
Philipp

Dears,

I have uploaded the changes at
https://patchwork.kernel.org/cover/11805937/
Please help me to review, many thanks~~

regards
Crystal

Quoted 1 line
#22 lore raw

PATCH v4 4/4 arm64: dts: mt8192: add infracfg_rst node

In reply to Crystal Guo

add infracfg_rst node which is for MT8192 platform

---
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8192.dtsi +10 -1
index 931e1ca17220..a0cb9904706b 100644
@@ -10,6 +10,7 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/mt8192-pinfunc.h>
 #include <dt-bindings/power/mt8192-power.h>
+#include <dt-bindings/reset/ti-syscon.h>
 
 / {
 	compatible = "mediatek,mt8192";
@@ -219,9 +220,17 @@
 		};
 
 		infracfg: infracfg@10001000 {
-			compatible = "mediatek,mt8192-infracfg", "syscon";
+			compatible = "mediatek,mt8192-infracfg", "syscon", "simple-mfd";
 			reg = <0 0x10001000 0 0x1000>;
 			#clock-cells = <1>;
+
+			infracfg_rst: reset-controller {
+				compatible = "mediatek,infra-reset", "ti,syscon-reset";
+				#reset-cells = <1>;
+				ti,reset-bits = <
+					0x140 15 0x144 15 0 0 (ASSERT_SET | DEASSERT_SET | STATUS_NONE) /* 0: pcie */
+				>;
+			};
 		};
 
 		pericfg: pericfg@10003000 {
Signature · 1 line
2.18.0
#23 lore raw

Re: [v4,4/4] arm64: dts: mt8192: add infracfg_rst node

Hi Crystal,

Quoted 3 lines · Crystal Guo

add infracfg_rst node which is for MT8192 platform

I understand you are posting these together for complete reference, but driver subsystem maintainers typically don't pick dts patches. In anycase, can you clarify if your registers are self-clearing registers?

regards
Suman

Quoted 36 lines
---
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8192.dtsi +10 -1
index 931e1ca17220..a0cb9904706b 100644
@@ -10,6 +10,7 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/mt8192-pinfunc.h>
 #include <dt-bindings/power/mt8192-power.h>
+#include <dt-bindings/reset/ti-syscon.h>
 
 / {
 	compatible = "mediatek,mt8192";
@@ -219,9 +220,17 @@
 		};
 
 		infracfg: infracfg@10001000 {
-			compatible = "mediatek,mt8192-infracfg", "syscon";
+			compatible = "mediatek,mt8192-infracfg", "syscon", "simple-mfd";
 			reg = <0 0x10001000 0 0x1000>;
 			#clock-cells = <1>;
+
+			infracfg_rst: reset-controller {
+				compatible = "mediatek,infra-reset", "ti,syscon-reset";
+				#reset-cells = <1>;
+				ti,reset-bits = <
+					0x140 15 0x144 15 0 0 (ASSERT_SET | DEASSERT_SET | STATUS_NONE) /* 0: pcie */
+				>;
+			};
 		};
 
 		pericfg: pericfg@10003000 {
#24 lore raw

Re: [v4,4/4] arm64: dts: mt8192: add infracfg_rst node

Quoted 5 lines · Suman Anna

Hi Crystal,

Quoted 2 lines · Crystal Guo

add infracfg_rst node which is for MT8192 platform

Quoted 9 lines
Quoted 1 line

I understand you are posting these together for complete reference, but driver subsystem maintainers typically don't pick dts patches. In anycase, can you clarify if your registers are self-clearing registers?

regards
Suman

Hi Suman,

Thanks for your reply.
Our reset registers are not self-clearing, it needs to set the clear bit to 1 to clear the related bit.
And should I separate this dts patch from the patch sets?

regards
Crystal

Quoted 34 lines
Quoted 34 lines
---
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8192.dtsi +10 -1
index 931e1ca17220..a0cb9904706b 100644
@@ -10,6 +10,7 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/mt8192-pinfunc.h>
 #include <dt-bindings/power/mt8192-power.h>
+#include <dt-bindings/reset/ti-syscon.h>
 
 / {
 	compatible = "mediatek,mt8192";
@@ -219,9 +220,17 @@
 		};
 
 		infracfg: infracfg@10001000 {
-			compatible = "mediatek,mt8192-infracfg", "syscon";
+			compatible = "mediatek,mt8192-infracfg", "syscon", "simple-mfd";
 			reg = <0 0x10001000 0 0x1000>;
 			#clock-cells = <1>;
+
+			infracfg_rst: reset-controller {
+				compatible = "mediatek,infra-reset", "ti,syscon-reset";
+				#reset-cells = <1>;
+				ti,reset-bits = <
+					0x140 15 0x144 15 0 0 (ASSERT_SET | DEASSERT_SET | STATUS_NONE) /* 0: pcie */
+				>;
+			};
 		};
 
Quoted 3 lines

arch/arm64/boot/dts/mediatek/mt8192.dtsi line 236

Quoted 2 lines
arch/arm64/boot/dts/mediatek/mt8192.dtsi +0 -0
 		pericfg: pericfg@10003000 {

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#25 lore raw

Re: [v4,4/4] arm64: dts: mt8192: add infracfg_rst node

Quoted 15 lines · Crystal Guo
Quoted 5 lines · Suman Anna

Hi Crystal,

Quoted 2 lines · Crystal Guo

add infracfg_rst node which is for MT8192 platform

Quoted 9 lines
Quoted 1 line

I understand you are posting these together for complete reference, but driver subsystem maintainers typically don't pick dts patches. In anycase, can you clarify if your registers are self-clearing registers?

regards
Suman

Quoted 6 lines

Hi Suman,

Thanks for your reply.
Our reset registers are not self-clearing, it needs to set the clear bit to 1 to clear the related bit.
And should I separate this dts patch from the patch sets?

Typically yes, but will leave it upto Philipp and Mediatek DT maintainers.

regards
Suman

Quoted 41 lines

regards
Crystal

Quoted 37 lines
Quoted 36 lines
---
 arch/arm64/boot/dts/mediatek/mt8192.dtsi | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8192.dtsi +10 -1
index 931e1ca17220..a0cb9904706b 100644
@@ -10,6 +10,7 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/pinctrl/mt8192-pinfunc.h>
 #include <dt-bindings/power/mt8192-power.h>
+#include <dt-bindings/reset/ti-syscon.h>
 
 / {
 	compatible = "mediatek,mt8192";
@@ -219,9 +220,17 @@
 		};
 
 		infracfg: infracfg@10001000 {
-			compatible = "mediatek,mt8192-infracfg", "syscon";
+			compatible = "mediatek,mt8192-infracfg", "syscon", "simple-mfd";
 			reg = <0 0x10001000 0 0x1000>;
 			#clock-cells = <1>;
+
+			infracfg_rst: reset-controller {
+				compatible = "mediatek,infra-reset", "ti,syscon-reset";
+				#reset-cells = <1>;
+				ti,reset-bits = <
+					0x140 15 0x144 15 0 0 (ASSERT_SET | DEASSERT_SET | STATUS_NONE) /* 0: pcie */
+				>;
+			};
 		};
 
 		pericfg: pericfg@10003000 {

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#27 lore raw

Hi Rob, Philipp, Matthias and all

Gentle ping for this patch set.

Thanks
Crystal

Quoted 41 lines

-----Original Message-----
From: Crystal Guo [mailto:[email protected]]
Sent: Monday, August 17, 2020 11:03 AM
To: [email protected]; [email protected]; [email protected]
Cc: srv_heupstream; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Seiya Wang (王迺君); Stanley Chu (朱原陞); Yingjoe Chen (陳英洲); Fan Chen (陳凡); Yong Liang (梁勇)
Subject: [v4,0/4] introduce TI reset controller for MT8192 SoC

v4:
fix typos on v3 commit message.

v3:
1. revert v2 changes.
2. add 'reset-duration-us' property to declare a minimum delay, which needs to be waited between assert and deassert.
3. add 'mediatek,infra-reset' to compatible.

v2 changes:
https://patchwork.kernel.org/patch/11697371/
1. add 'assert-deassert-together' property to introduce a new reset handler, which allows device to do serialized assert and deassert operations in a single step by 'reset' method.
2. add 'update-force' property to introduce force-update method, which forces the write operation in case the read already happens to return the correct value.
3. add 'generic-reset' to compatible

v1 changes:
https://patchwork.kernel.org/patch/11690523/
https://patchwork.kernel.org/patch/11690527/

Crystal Guo (4):
dt-binding: reset-controller: ti: add reset-duration-us property
dt-binding: reset-controller: ti: add 'mediatek,infra-reset' to
compatible
reset-controller: ti: introduce a new reset handler
arm64: dts: mt8192: add infracfg_rst node

 .../bindings/reset/ti-syscon-reset.txt        |  6 +++++
 arch/arm64/boot/dts/mediatek/mt8192.dtsi      | 11 +++++++-
 drivers/reset/reset-ti-syscon.c               | 26 +++++++++++++++++--
 3 files changed, 40 insertions(+), 3 deletions(-)

*********************MEDIATEK Confidential/Internal Use*********************