* [PATCH v3 0/5] power/reset: at91: cleanups and slow clock
@ 2015-08-11 9:12 Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 1/5] power/reset: at91-reset: remove useless at91_reset_platform_probe() Alexandre Belloni
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Alexandre Belloni @ 2015-08-11 9:12 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
As discussed this series is now removing non DT initialization, allowing to
compile the drivers as modules and finally adding slow clock support to the
drivers.
Alexandre Belloni (5):
power/reset: at91-reset: remove useless at91_reset_platform_probe()
power/reset: at91-reset: allow compiling as a module
power/reset: at91-reset: get and use slow clock
power/reset: at91-poweroff: allow compiling as a module
power/reset: at91-poweroff: get and use slow clock
drivers/power/reset/Kconfig | 4 +--
drivers/power/reset/at91-poweroff.c | 33 ++++++++++++++++--
drivers/power/reset/at91-reset.c | 67 ++++++++++++++-----------------------
3 files changed, 58 insertions(+), 46 deletions(-)
--
2.1.4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 1/5] power/reset: at91-reset: remove useless at91_reset_platform_probe()
2015-08-11 9:12 [PATCH v3 0/5] power/reset: at91: cleanups and slow clock Alexandre Belloni
@ 2015-08-11 9:12 ` Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 2/5] power/reset: at91-reset: allow compiling as a module Alexandre Belloni
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2015-08-11 9:12 UTC (permalink / raw)
To: linux-arm-kernel
Since all the at91 platforms are now DT only, at91_reset_platform_probe()
is now useless, remove it.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/power/reset/at91-reset.c | 47 +++-------------------------------------
1 file changed, 3 insertions(+), 44 deletions(-)
diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
index 36dc52fb2ec8..3225c8590ed0 100644
--- a/drivers/power/reset/at91-reset.c
+++ b/drivers/power/reset/at91-reset.c
@@ -169,11 +169,11 @@ static struct notifier_block at91_restart_nb = {
.priority = 192,
};
-static int at91_reset_of_probe(struct platform_device *pdev)
+static int at91_reset_probe(struct platform_device *pdev)
{
const struct of_device_id *match;
struct device_node *np;
- int idx = 0;
+ int ret, idx = 0;
at91_rstc_base = of_iomap(pdev->dev.of_node, 0);
if (!at91_rstc_base) {
@@ -192,49 +192,8 @@ static int at91_reset_of_probe(struct platform_device *pdev)
match = of_match_node(at91_reset_of_match, pdev->dev.of_node);
at91_restart_nb.notifier_call = match->data;
- return register_restart_handler(&at91_restart_nb);
-}
-
-static int at91_reset_platform_probe(struct platform_device *pdev)
-{
- const struct platform_device_id *match;
- struct resource *res;
- int idx = 0;
-
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- at91_rstc_base = devm_ioremap_resource(&pdev->dev, res);
- if (IS_ERR(at91_rstc_base)) {
- dev_err(&pdev->dev, "Could not map reset controller address\n");
- return PTR_ERR(at91_rstc_base);
- }
-
- for (idx = 0; idx < 2; idx++) {
- res = platform_get_resource(pdev, IORESOURCE_MEM, idx + 1 );
- at91_ramc_base[idx] = devm_ioremap(&pdev->dev, res->start,
- resource_size(res));
- if (!at91_ramc_base[idx]) {
- dev_err(&pdev->dev, "Could not map ram controller address\n");
- return -ENOMEM;
- }
- }
-
- match = platform_get_device_id(pdev);
- at91_restart_nb.notifier_call =
- (int (*)(struct notifier_block *,
- unsigned long, void *)) match->driver_data;
-
- return register_restart_handler(&at91_restart_nb);
-}
-
-static int at91_reset_probe(struct platform_device *pdev)
-{
- int ret;
-
- if (pdev->dev.of_node)
- ret = at91_reset_of_probe(pdev);
- else
- ret = at91_reset_platform_probe(pdev);
+ ret = register_restart_handler(&at91_restart_nb);
if (ret)
return ret;
--
2.1.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 2/5] power/reset: at91-reset: allow compiling as a module
2015-08-11 9:12 [PATCH v3 0/5] power/reset: at91: cleanups and slow clock Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 1/5] power/reset: at91-reset: remove useless at91_reset_platform_probe() Alexandre Belloni
@ 2015-08-11 9:12 ` Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 3/5] power/reset: at91-reset: get and use slow clock Alexandre Belloni
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2015-08-11 9:12 UTC (permalink / raw)
To: linux-arm-kernel
It was not possible to compile at91-reset as a module. Implement .remove()
to allow it. Also switch to module_platform_driver_probe() as it is not
hotpluggable.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/power/reset/Kconfig | 2 +-
drivers/power/reset/at91-reset.c | 17 ++++++++++++++---
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index 17d93a73c513..e41da4a80a05 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -23,7 +23,7 @@ config POWER_RESET_AT91_POWEROFF
SoCs
config POWER_RESET_AT91_RESET
- bool "Atmel AT91 reset driver"
+ tristate "Atmel AT91 reset driver"
depends on ARCH_AT91
default SOC_AT91SAM9 || SOC_SAMA5
help
diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
index 3225c8590ed0..120f3dec9574 100644
--- a/drivers/power/reset/at91-reset.c
+++ b/drivers/power/reset/at91-reset.c
@@ -169,7 +169,7 @@ static struct notifier_block at91_restart_nb = {
.priority = 192,
};
-static int at91_reset_probe(struct platform_device *pdev)
+static int __init at91_reset_probe(struct platform_device *pdev)
{
const struct of_device_id *match;
struct device_node *np;
@@ -202,6 +202,13 @@ static int at91_reset_probe(struct platform_device *pdev)
return 0;
}
+static int __exit at91_reset_remove(struct platform_device *pdev)
+{
+ unregister_restart_handler(&at91_restart_nb);
+
+ return 0;
+}
+
static const struct platform_device_id at91_reset_plat_match[] = {
{ "at91-sam9260-reset", (unsigned long)at91sam9260_restart },
{ "at91-sam9g45-reset", (unsigned long)at91sam9g45_restart },
@@ -209,11 +216,15 @@ static const struct platform_device_id at91_reset_plat_match[] = {
};
static struct platform_driver at91_reset_driver = {
- .probe = at91_reset_probe,
+ .remove = __exit_p(at91_reset_remove),
.driver = {
.name = "at91-reset",
.of_match_table = at91_reset_of_match,
},
.id_table = at91_reset_plat_match,
};
-module_platform_driver(at91_reset_driver);
+module_platform_driver_probe(at91_reset_driver, at91_reset_probe);
+
+MODULE_AUTHOR("Atmel Corporation");
+MODULE_DESCRIPTION("Reset driver for Atmel SoCs");
+MODULE_LICENSE("GPL v2");
--
2.1.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 3/5] power/reset: at91-reset: get and use slow clock
2015-08-11 9:12 [PATCH v3 0/5] power/reset: at91: cleanups and slow clock Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 1/5] power/reset: at91-reset: remove useless at91_reset_platform_probe() Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 2/5] power/reset: at91-reset: allow compiling as a module Alexandre Belloni
@ 2015-08-11 9:12 ` Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 4/5] power/reset: at91-poweroff: allow compiling as a module Alexandre Belloni
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2015-08-11 9:12 UTC (permalink / raw)
To: linux-arm-kernel
Commit dca1a4b5ff6e ("clk: at91: keep slow clk enabled to prevent system
hang") added a workaround for the slow clock as it is not properly handled
by its users.
Get and use the slow clock as it is necessary for the at91 reset
controller.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/power/reset/at91-reset.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c
index 120f3dec9574..8f0bcb232149 100644
--- a/drivers/power/reset/at91-reset.c
+++ b/drivers/power/reset/at91-reset.c
@@ -11,6 +11,7 @@
* warranty of any kind, whether express or implied.
*/
+#include <linux/clk.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of_address.h>
@@ -46,6 +47,7 @@ enum reset_type {
};
static void __iomem *at91_ramc_base[2], *at91_rstc_base;
+static struct clk *sclk;
/*
* unless the SDRAM is cleanly shutdown before we hit the
@@ -193,9 +195,21 @@ static int __init at91_reset_probe(struct platform_device *pdev)
match = of_match_node(at91_reset_of_match, pdev->dev.of_node);
at91_restart_nb.notifier_call = match->data;
+ sclk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(sclk))
+ return PTR_ERR(sclk);
+
+ ret = clk_prepare_enable(sclk);
+ if (ret) {
+ dev_err(&pdev->dev, "Could not enable slow clock\n");
+ return ret;
+ }
+
ret = register_restart_handler(&at91_restart_nb);
- if (ret)
+ if (ret) {
+ clk_disable_unprepare(sclk);
return ret;
+ }
at91_reset_status(pdev);
@@ -205,6 +219,7 @@ static int __init at91_reset_probe(struct platform_device *pdev)
static int __exit at91_reset_remove(struct platform_device *pdev)
{
unregister_restart_handler(&at91_restart_nb);
+ clk_disable_unprepare(sclk);
return 0;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 4/5] power/reset: at91-poweroff: allow compiling as a module
2015-08-11 9:12 [PATCH v3 0/5] power/reset: at91: cleanups and slow clock Alexandre Belloni
` (2 preceding siblings ...)
2015-08-11 9:12 ` [PATCH v3 3/5] power/reset: at91-reset: get and use slow clock Alexandre Belloni
@ 2015-08-11 9:12 ` Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 5/5] power/reset: at91-poweroff: get and use slow clock Alexandre Belloni
2015-09-22 15:13 ` [PATCH v3 0/5] power/reset: at91: cleanups and " Sebastian Reichel
5 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2015-08-11 9:12 UTC (permalink / raw)
To: linux-arm-kernel
It was not possible to compile at91-poweroff as a module. Implement
.remove() to allow it. Also switch to module_platform_driver_probe() as it
is not hotpluggable.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/power/reset/Kconfig | 2 +-
drivers/power/reset/at91-poweroff.c | 18 +++++++++++++++---
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index e41da4a80a05..b3c6191d1847 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -15,7 +15,7 @@ config POWER_RESET_AS3722
This driver supports turning off board via a ams AS3722 power-off.
config POWER_RESET_AT91_POWEROFF
- bool "Atmel AT91 poweroff driver"
+ tristate "Atmel AT91 poweroff driver"
depends on ARCH_AT91
default SOC_AT91SAM9 || SOC_SAMA5
help
diff --git a/drivers/power/reset/at91-poweroff.c b/drivers/power/reset/at91-poweroff.c
index 9847cfb7e23d..3e698d916c4f 100644
--- a/drivers/power/reset/at91-poweroff.c
+++ b/drivers/power/reset/at91-poweroff.c
@@ -119,7 +119,7 @@ static void at91_poweroff_dt_set_wakeup_mode(struct platform_device *pdev)
writel(wakeup_mode | mode, at91_shdwc_base + AT91_SHDW_MR);
}
-static int at91_poweroff_probe(struct platform_device *pdev)
+static int __init at91_poweroff_probe(struct platform_device *pdev)
{
struct resource *res;
@@ -140,6 +140,14 @@ static int at91_poweroff_probe(struct platform_device *pdev)
return 0;
}
+static int __exit at91_poweroff_remove(struct platform_device *pdev)
+{
+ if (pm_power_off == at91_poweroff)
+ pm_power_off = NULL;
+
+ return 0;
+}
+
static const struct of_device_id at91_poweroff_of_match[] = {
{ .compatible = "atmel,at91sam9260-shdwc", },
{ .compatible = "atmel,at91sam9rl-shdwc", },
@@ -148,10 +156,14 @@ static const struct of_device_id at91_poweroff_of_match[] = {
};
static struct platform_driver at91_poweroff_driver = {
- .probe = at91_poweroff_probe,
+ .remove = __exit_p(at91_poweroff_remove),
.driver = {
.name = "at91-poweroff",
.of_match_table = at91_poweroff_of_match,
},
};
-module_platform_driver(at91_poweroff_driver);
+module_platform_driver_probe(at91_poweroff_driver, at91_poweroff_probe);
+
+MODULE_AUTHOR("Atmel Corporation");
+MODULE_DESCRIPTION("Shutdown driver for Atmel SoCs");
+MODULE_LICENSE("GPL v2");
--
2.1.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 5/5] power/reset: at91-poweroff: get and use slow clock
2015-08-11 9:12 [PATCH v3 0/5] power/reset: at91: cleanups and slow clock Alexandre Belloni
` (3 preceding siblings ...)
2015-08-11 9:12 ` [PATCH v3 4/5] power/reset: at91-poweroff: allow compiling as a module Alexandre Belloni
@ 2015-08-11 9:12 ` Alexandre Belloni
2015-09-22 15:13 ` [PATCH v3 0/5] power/reset: at91: cleanups and " Sebastian Reichel
5 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2015-08-11 9:12 UTC (permalink / raw)
To: linux-arm-kernel
Commit dca1a4b5ff6e ("clk: at91: keep slow clk enabled to prevent system
hang") added a workaround for the slow clock as it is not properly handled
by its users.
Get and use the slow clock as it is necessary for the at91 shutdown
controller.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/power/reset/at91-poweroff.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/drivers/power/reset/at91-poweroff.c b/drivers/power/reset/at91-poweroff.c
index 3e698d916c4f..e9e24df35f26 100644
--- a/drivers/power/reset/at91-poweroff.c
+++ b/drivers/power/reset/at91-poweroff.c
@@ -10,6 +10,7 @@
* warranty of any kind, whether express or implied.
*/
+#include <linux/clk.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
@@ -48,6 +49,7 @@ static const char *shdwc_wakeup_modes[] = {
};
static void __iomem *at91_shdwc_base;
+static struct clk *sclk;
static void __init at91_wakeup_status(void)
{
@@ -122,6 +124,7 @@ static void at91_poweroff_dt_set_wakeup_mode(struct platform_device *pdev)
static int __init at91_poweroff_probe(struct platform_device *pdev)
{
struct resource *res;
+ int ret;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
at91_shdwc_base = devm_ioremap_resource(&pdev->dev, res);
@@ -130,6 +133,16 @@ static int __init at91_poweroff_probe(struct platform_device *pdev)
return PTR_ERR(at91_shdwc_base);
}
+ sclk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(sclk))
+ return PTR_ERR(sclk);
+
+ ret = clk_prepare_enable(sclk);
+ if (ret) {
+ dev_err(&pdev->dev, "Could not enable slow clock\n");
+ return ret;
+ }
+
at91_wakeup_status();
if (pdev->dev.of_node)
@@ -145,6 +158,8 @@ static int __exit at91_poweroff_remove(struct platform_device *pdev)
if (pm_power_off == at91_poweroff)
pm_power_off = NULL;
+ clk_disable_unprepare(sclk);
+
return 0;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v3 0/5] power/reset: at91: cleanups and slow clock
2015-08-11 9:12 [PATCH v3 0/5] power/reset: at91: cleanups and slow clock Alexandre Belloni
` (4 preceding siblings ...)
2015-08-11 9:12 ` [PATCH v3 5/5] power/reset: at91-poweroff: get and use slow clock Alexandre Belloni
@ 2015-09-22 15:13 ` Sebastian Reichel
2015-09-22 15:35 ` Alexandre Belloni
5 siblings, 1 reply; 8+ messages in thread
From: Sebastian Reichel @ 2015-09-22 15:13 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On Tue, Aug 11, 2015 at 11:12:45AM +0200, Alexandre Belloni wrote:
> As discussed this series is now removing non DT initialization, allowing to
> compile the drivers as modules and finally adding slow clock support to the
> drivers.
>
> [...]
>
> power/reset: at91-reset: remove useless at91_reset_platform_probe()
> power/reset: at91-reset: allow compiling as a module
> power/reset: at91-reset: get and use slow clock
> power/reset: at91-poweroff: allow compiling as a module
> power/reset: at91-poweroff: get and use slow clock
Thanks, queued for 4.4. You may want to add another patch adding
MODULE_DEVICE_TABLE(of, xxx_of_match);
-- Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150922/444bb3a7/attachment.sig>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 0/5] power/reset: at91: cleanups and slow clock
2015-09-22 15:13 ` [PATCH v3 0/5] power/reset: at91: cleanups and " Sebastian Reichel
@ 2015-09-22 15:35 ` Alexandre Belloni
0 siblings, 0 replies; 8+ messages in thread
From: Alexandre Belloni @ 2015-09-22 15:35 UTC (permalink / raw)
To: linux-arm-kernel
On 22/09/2015 at 17:13:35 +0200, Sebastian Reichel wrote :
> Thanks, queued for 4.4. You may want to add another patch adding
>
> MODULE_DEVICE_TABLE(of, xxx_of_match);
>
Sure, I will do.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2015-09-22 15:35 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-11 9:12 [PATCH v3 0/5] power/reset: at91: cleanups and slow clock Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 1/5] power/reset: at91-reset: remove useless at91_reset_platform_probe() Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 2/5] power/reset: at91-reset: allow compiling as a module Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 3/5] power/reset: at91-reset: get and use slow clock Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 4/5] power/reset: at91-poweroff: allow compiling as a module Alexandre Belloni
2015-08-11 9:12 ` [PATCH v3 5/5] power/reset: at91-poweroff: get and use slow clock Alexandre Belloni
2015-09-22 15:13 ` [PATCH v3 0/5] power/reset: at91: cleanups and " Sebastian Reichel
2015-09-22 15:35 ` Alexandre Belloni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).