2021-01-03 11:19:11

by Samuel Holland

[permalink] [raw]
Subject: [PATCH 0/4] bus: sunxi-rsb: Implement power managment

This series adds system (complete power down) and runtime (clock gate)
PM hooks to the RSB controller driver. Tested on A64 and H6.

Samuel Holland (4):
bus: sunxi-rsb: Move OF match table
bus: sunxi-rsb: Split out controller init/exit functions
bus: sunxi-rsb: Implement suspend/resume/shutdown callbacks
bus: sunxi-rsb: Implement runtime power management

drivers/bus/sunxi-rsb.c | 211 ++++++++++++++++++++++++++++------------
1 file changed, 150 insertions(+), 61 deletions(-)

--
2.26.2


2021-01-03 11:19:32

by Samuel Holland

[permalink] [raw]
Subject: [PATCH 3/4] bus: sunxi-rsb: Implement suspend/resume/shutdown callbacks

Since system firmware is likely to use the RSB bus to communicate with a
PMIC while the system is suspended, we cannot make any assumptions about
the controller state after resuming. Thus it is important to completely
reinitialize the controller.

The RSB bus needs to be ready as soon as IRQs are enabled, to handle
wakeup event IRQs coming from the PMIC. Thus it uses NOIRQ callbacks.

Signed-off-by: Samuel Holland <[email protected]>
---
drivers/bus/sunxi-rsb.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c
index 3f290da45619..efd222f36cdc 100644
--- a/drivers/bus/sunxi-rsb.c
+++ b/drivers/bus/sunxi-rsb.c
@@ -45,6 +45,7 @@
#include <linux/of_irq.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
+#include <linux/pm.h>
#include <linux/regmap.h>
#include <linux/reset.h>
#include <linux/slab.h>
@@ -675,6 +676,22 @@ static void sunxi_rsb_hw_exit(struct sunxi_rsb *rsb)
clk_disable_unprepare(rsb->clk);
}

+static int __maybe_unused sunxi_rsb_suspend(struct device *dev)
+{
+ struct sunxi_rsb *rsb = dev_get_drvdata(dev);
+
+ sunxi_rsb_hw_exit(rsb);
+
+ return 0;
+}
+
+static int __maybe_unused sunxi_rsb_resume(struct device *dev)
+{
+ struct sunxi_rsb *rsb = dev_get_drvdata(dev);
+
+ return sunxi_rsb_hw_init(rsb);
+}
+
static int sunxi_rsb_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -756,6 +773,17 @@ static int sunxi_rsb_remove(struct platform_device *pdev)
return 0;
}

+static void sunxi_rsb_shutdown(struct platform_device *pdev)
+{
+ struct sunxi_rsb *rsb = platform_get_drvdata(pdev);
+
+ sunxi_rsb_hw_exit(rsb);
+}
+
+static const struct dev_pm_ops sunxi_rsb_dev_pm_ops = {
+ SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sunxi_rsb_suspend, sunxi_rsb_resume)
+};
+
static const struct of_device_id sunxi_rsb_of_match_table[] = {
{ .compatible = "allwinner,sun8i-a23-rsb" },
{}
@@ -765,9 +793,11 @@ MODULE_DEVICE_TABLE(of, sunxi_rsb_of_match_table);
static struct platform_driver sunxi_rsb_driver = {
.probe = sunxi_rsb_probe,
.remove = sunxi_rsb_remove,
+ .shutdown = sunxi_rsb_shutdown,
.driver = {
.name = RSB_CTRL_NAME,
.of_match_table = sunxi_rsb_of_match_table,
+ .pm = &sunxi_rsb_dev_pm_ops,
},
};

--
2.26.2

2021-01-03 11:19:41

by Samuel Holland

[permalink] [raw]
Subject: [PATCH 1/4] bus: sunxi-rsb: Move OF match table

For some reason, this driver's OF match table was placed above the
probe/remove functions, far away from the platform_driver definition.
Adding device PM ops would move the table even farther away. Let's move
it to the usual place, right before the platform_driver.

Signed-off-by: Samuel Holland <[email protected]>
---
drivers/bus/sunxi-rsb.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/sunxi-rsb.c b/drivers/bus/sunxi-rsb.c
index 1bb00a959c67..c13340cab27a 100644
--- a/drivers/bus/sunxi-rsb.c
+++ b/drivers/bus/sunxi-rsb.c
@@ -614,12 +614,6 @@ static int of_rsb_register_devices(struct sunxi_rsb *rsb)
return 0;
}

-static const struct of_device_id sunxi_rsb_of_match_table[] = {
- { .compatible = "allwinner,sun8i-a23-rsb" },
- {}
-};
-MODULE_DEVICE_TABLE(of, sunxi_rsb_of_match_table);
-
static int sunxi_rsb_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -747,6 +741,12 @@ static int sunxi_rsb_remove(struct platform_device *pdev)
return 0;
}

+static const struct of_device_id sunxi_rsb_of_match_table[] = {
+ { .compatible = "allwinner,sun8i-a23-rsb" },
+ {}
+};
+MODULE_DEVICE_TABLE(of, sunxi_rsb_of_match_table);
+
static struct platform_driver sunxi_rsb_driver = {
.probe = sunxi_rsb_probe,
.remove = sunxi_rsb_remove,
--
2.26.2

2021-01-04 08:35:20

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH 0/4] bus: sunxi-rsb: Implement power managment

Hi,

On Sun, Jan 3, 2021 at 7:06 PM Samuel Holland <[email protected]> wrote:
>
> This series adds system (complete power down) and runtime (clock gate)
> PM hooks to the RSB controller driver. Tested on A64 and H6.
>
> Samuel Holland (4):
> bus: sunxi-rsb: Move OF match table
> bus: sunxi-rsb: Split out controller init/exit functions
> bus: sunxi-rsb: Implement suspend/resume/shutdown callbacks
> bus: sunxi-rsb: Implement runtime power management
>
> drivers/bus/sunxi-rsb.c | 211 ++++++++++++++++++++++++++++------------
> 1 file changed, 150 insertions(+), 61 deletions(-)

Looks good to me.

Acked-by: Chen-Yu Tsai <[email protected]>

I already queued them up locally, but I think it's best to give other
people some time to review as well.

ChenYu

2021-01-06 10:53:40

by Maxime Ripard

[permalink] [raw]
Subject: Re: [PATCH 0/4] bus: sunxi-rsb: Implement power managment

Hi!

On Sun, Jan 03, 2021 at 05:06:31AM -0600, Samuel Holland wrote:
> This series adds system (complete power down) and runtime (clock gate)
> PM hooks to the RSB controller driver. Tested on A64 and H6.
>
> Samuel Holland (4):
> bus: sunxi-rsb: Move OF match table
> bus: sunxi-rsb: Split out controller init/exit functions
> bus: sunxi-rsb: Implement suspend/resume/shutdown callbacks
> bus: sunxi-rsb: Implement runtime power management
>
> drivers/bus/sunxi-rsb.c | 211 ++++++++++++++++++++++++++++------------
> 1 file changed, 150 insertions(+), 61 deletions(-)

For the whole series,

Acked-by: Maxime Ripard <[email protected]>

Thanks!
Maxime


Attachments:
(No filename) (687.00 B)
signature.asc (235.00 B)
Download all attachments

2021-01-06 11:42:10

by Chen-Yu Tsai

[permalink] [raw]
Subject: Re: [PATCH 0/4] bus: sunxi-rsb: Implement power managment

On Wed, Jan 6, 2021 at 6:50 PM Maxime Ripard <[email protected]> wrote:
>
> Hi!
>
> On Sun, Jan 03, 2021 at 05:06:31AM -0600, Samuel Holland wrote:
> > This series adds system (complete power down) and runtime (clock gate)
> > PM hooks to the RSB controller driver. Tested on A64 and H6.
> >
> > Samuel Holland (4):
> > bus: sunxi-rsb: Move OF match table
> > bus: sunxi-rsb: Split out controller init/exit functions
> > bus: sunxi-rsb: Implement suspend/resume/shutdown callbacks
> > bus: sunxi-rsb: Implement runtime power management
> >
> > drivers/bus/sunxi-rsb.c | 211 ++++++++++++++++++++++++++++------------
> > 1 file changed, 150 insertions(+), 61 deletions(-)
>
> For the whole series,
>
> Acked-by: Maxime Ripard <[email protected]>

Thanks! Pushed out to kernel.org.