Skip to contentSkip to conversation

clk: sunxi-ng: Provide a default reset hook

PATCH New Maxime Ripard 5 participants 9 messages Aug 25, 2017 – Sep 1, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 clk: sunxi-ng: Provide a default reset hook

The reset hook was left implemented. Provide a dumb implementation so that client drivers can depend on it.

---
 drivers/clk/sunxi-ng/ccu_reset.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/clk/sunxi-ng/ccu_reset.c +12 -0
index 6c31d48783a7..1dc4e98ea802 100644
@@ -8,6 +8,7 @@
  * the License, or (at your option) any later version.
  */
 
+#include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/reset-controller.h>
 
@@ -49,7 +50,18 @@ static int ccu_reset_deassert(struct reset_controller_dev *rcdev,
 	return 0;
 }
 
+static int ccu_reset_reset(struct reset_controller_dev *rcdev,
+			   unsigned long id)
+{
+	ccu_reset_assert(rcdev, id);
+	udelay(10);
+	ccu_reset_deassert(rcdev, id);
+
+	return 0;
+}
+
 const struct reset_control_ops ccu_reset_ops = {
 	.assert		= ccu_reset_assert,
 	.deassert	= ccu_reset_deassert,
+	.reset		= ccu_reset_reset,
 };
Signature · 1 line
2.13.5
#1 lore raw

PATCH 2/2 mmc: sunxi: Reset the device at probe time

We might be into some troubles if the bootloader misconfigured the MMC controller.

We currently only de-assert the reset line at probe time, which means that if the device was already out of reset, we're going to keep whatever state was set already.

Switch to a reset instead of the deassert to have a device in a pristine state when we start operating.

---
 drivers/mmc/host/sunxi-mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sunxi-mmc.c +1 -1
index da5f46a14497..53c970fe0873 100644
@@ -1242,7 +1242,7 @@ static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host,
 	}
 
 	if (!IS_ERR(host->reset)) {
-		ret = reset_control_deassert(host->reset);
+		ret = reset_control_reset(host->reset);
 		if (ret) {
 			dev_err(&pdev->dev, "reset err %d\n", ret);
 			goto error_disable_clk_sample;
Signature · 1 line
2.13.5
Applied
#2 lore raw

PATCH 2/2 mmc: sunxi: Reset the device at probe time

Quoted 11 lines · Maxime Ripard

We might be into some troubles if the bootloader misconfigured the MMC controller.

We currently only de-assert the reset line at probe time, which means that if the device was already out of reset, we're going to keep whatever state was set already.

Switch to a reset instead of the deassert to have a device in a pristine state when we start operating.

Thanks, applied for next!

Kind regards
Uffe

Quoted 20 lines
---
 drivers/mmc/host/sunxi-mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sunxi-mmc.c +1 -2
index da5f46a14497..53c970fe0873 100644
@@ -1242,7 +1242,7 @@ static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host,
        }
 
        if (!IS_ERR(host->reset)) {
-               ret = reset_control_deassert(host->reset);
+               ret = reset_control_reset(host->reset);
                if (ret) {
                        dev_err(&pdev->dev, "reset err %d\n", ret);
                        goto error_disable_clk_sample;
--

2.13.5

#3 lore raw

PATCH 1/2 clk: sunxi-ng: Provide a default reset hook

In reply to Maxime Ripard

? 2017-08-25 17:49?Maxime Ripard ???

Quoted 3 lines

The reset hook was left implemented. Provide a dumb implementation so that
client drivers can depend on it.

I think some clients should also convert to use this.

For example:

- The TCON driver in sun4i-drm. (It now uses reset_control_status, but this is also not implemented in CCU.)
- The EPHY in dwmac-sun8i driver. (It uses explicit assert then deassert)

P.S. maybe the status hook should also be implemented?

Quoted 39 lines
---
 drivers/clk/sunxi-ng/ccu_reset.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/clk/sunxi-ng/ccu_reset.c +12 -0
index 6c31d48783a7..1dc4e98ea802 100644
@@ -8,6 +8,7 @@
  * the License, or (at your option) any later version.
  */
 
+#include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/reset-controller.h>
 
@@ -49,7 +50,18 @@ static int ccu_reset_deassert(struct
 reset_controller_dev *rcdev,
 	return 0;
 }
 
+static int ccu_reset_reset(struct reset_controller_dev *rcdev,
+			   unsigned long id)
+{
+	ccu_reset_assert(rcdev, id);
+	udelay(10);
+	ccu_reset_deassert(rcdev, id);
+
+	return 0;
+}
+
 const struct reset_control_ops ccu_reset_ops = {
 	.assert		= ccu_reset_assert,
 	.deassert	= ccu_reset_deassert,
+	.reset		= ccu_reset_reset,

};

#4 lore raw

PATCH 1/2 clk: sunxi-ng: Provide a default reset hook

Quoted 6 lines · On Sun, Aug 27, 2017 at 9:01 PM, <[email protected]> wrote:

? 2017-08-25 17:49?Maxime Ripard ???

Quoted 3 lines

The reset hook was left implemented. Provide a dumb implementation so that client drivers can depend on it.

Quoted 6 lines

I think some clients should also convert to use this.

For example:

- The TCON driver in sun4i-drm. (It now uses reset_control_status, but this is also not implemented in CCU.)

I have patches for both sides of this.

Quoted 3 lines

- The EPHY in dwmac-sun8i driver. (It uses explicit assert then deassert)

P.S. maybe the status hook should also be implemented?

Yes.

ChenYu

#5 lore raw

PATCH 1/2 clk: sunxi-ng: Provide a default reset hook

In reply to Maxime Ripard
Quoted 4 lines · Maxime Ripard

The reset hook was left implemented. Provide a dumb implementation so that client drivers can depend on it.

Do you want me to pick this up via my mmc tree? If so, is that okay by the clock maintainers?

Kind regards
Uffe

Quoted 38 lines
---
 drivers/clk/sunxi-ng/ccu_reset.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
drivers/clk/sunxi-ng/ccu_reset.c +12 -1
index 6c31d48783a7..1dc4e98ea802 100644
@@ -8,6 +8,7 @@
  * the License, or (at your option) any later version.
  */
 
+#include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/reset-controller.h>
 
@@ -49,7 +50,18 @@ static int ccu_reset_deassert(struct reset_controller_dev *rcdev,
        return 0;
 }
 
+static int ccu_reset_reset(struct reset_controller_dev *rcdev,
+                          unsigned long id)
+{
+       ccu_reset_assert(rcdev, id);
+       udelay(10);
+       ccu_reset_deassert(rcdev, id);
+
+       return 0;
+}
+
 const struct reset_control_ops ccu_reset_ops = {
        .assert         = ccu_reset_assert,
        .deassert       = ccu_reset_deassert,
+       .reset          = ccu_reset_reset,
 };
--

2.13.5

#6 lore raw

PATCH 1/2 clk: sunxi-ng: Provide a default reset hook

Hi Ulf,

Quoted 9 lines · Ulf Hansson
Quoted 4 lines · Maxime Ripard

The reset hook was left implemented. Provide a dumb implementation so that client drivers can depend on it.

Do you want me to pick this up via my mmc tree? If so, is that okay by the clock maintainers?

I also happen to be the maintainer of that part of the kernel (reporting to Mike and Stephen of course). We don't have anything touching that file in next, so unless they feel like it should go through their tree, it would be easier to keep the two changes together and merge them through your tree.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170830/d85947be/attachment-0001.sig>
#7 lore raw

PATCH 1/2 clk: sunxi-ng: Provide a default reset hook

Quoted 10 lines · Maxime Ripard

Hi Ulf,

Quoted 7 lines · Ulf Hansson
Quoted 4 lines · Maxime Ripard

The reset hook was left implemented. Provide a dumb implementation so that client drivers can depend on it.

Quoted 8 lines
Quoted 2 lines

Do you want me to pick this up via my mmc tree? If so, is that okay by the clock maintainers?

I also happen to be the maintainer of that part of the kernel (reporting to Mike and Stephen of course). We don't have anything touching that file in next, so unless they feel like it should go through their tree, it would be easier to keep the two changes together and merge them through your tree.

Alright, I have picked it up for next!

Kind regards
Uffe

#8 lore raw

PATCH 1/2 clk: sunxi-ng: Provide a default reset hook

Quoted 15 lines · Ulf Hansson
Quoted 13 lines · Maxime Ripard

Hi Ulf,

Quoted 9 lines · Ulf Hansson
Quoted 4 lines · Maxime Ripard

The reset hook was left implemented. Provide a dumb implementation so that client drivers can depend on it.

Do you want me to pick this up via my mmc tree? If so, is that okay by the clock maintainers?

Quoted 8 lines
Quoted 5 lines

I also happen to be the maintainer of that part of the kernel (reporting to Mike and Stephen of course). We don't have anything touching that file in next, so unless they feel like it should go through their tree, it would be easier to keep the two changes together and merge them through your tree.

Alright, I have picked it up for next!

Thanks!

if that helps.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project