* [PATCH v4 1/9] ARM: at91/dt: declare atmel,at91rm9200-st as a syscon
2015-03-05 15:49 [PATCH v4 0/9] Atmel System Timer cleanups Alexandre Belloni
@ 2015-03-05 15:49 ` Alexandre Belloni
2015-03-05 15:49 ` [PATCH v4 2/9] mfd: syscon: Add atmel system timer registers definition Alexandre Belloni
` (7 subsequent siblings)
8 siblings, 0 replies; 21+ messages in thread
From: Alexandre Belloni @ 2015-03-05 15:49 UTC (permalink / raw)
To: Nicolas Ferre, Daniel Lezcano
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm, Alexandre Belloni
The system timer register range is also used for the watchdog. Declare it as a
syscon to be able to get a regmap early enough in the boot process
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
Documentation/devicetree/bindings/arm/atmel-at91.txt | 2 +-
arch/arm/boot/dts/at91rm9200.dtsi | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/arm/atmel-at91.txt b/Documentation/devicetree/bindings/arm/atmel-at91.txt
index ad319f84f560..0fbb3582ec9d 100644
--- a/Documentation/devicetree/bindings/arm/atmel-at91.txt
+++ b/Documentation/devicetree/bindings/arm/atmel-at91.txt
@@ -46,7 +46,7 @@ PIT Timer required properties:
shared across all System Controller members.
System Timer (ST) required properties:
-- compatible: Should be "atmel,at91rm9200-st"
+- compatible: Should be "atmel,at91rm9200-st", "syscon"
- reg: Should contain registers location and length
- interrupts: Should contain interrupt for the ST which is the IRQ line
shared across all System Controller members.
diff --git a/arch/arm/boot/dts/at91rm9200.dtsi b/arch/arm/boot/dts/at91rm9200.dtsi
index 21c2b504f977..1b1c1ac2c4f6 100644
--- a/arch/arm/boot/dts/at91rm9200.dtsi
+++ b/arch/arm/boot/dts/at91rm9200.dtsi
@@ -356,7 +356,7 @@
};
st: timer@fffffd00 {
- compatible = "atmel,at91rm9200-st";
+ compatible = "atmel,at91rm9200-st", "syscon";
reg = <0xfffffd00 0x100>;
interrupts = <1 IRQ_TYPE_LEVEL_HIGH 7>;
};
--
2.1.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 2/9] mfd: syscon: Add atmel system timer registers definition
2015-03-05 15:49 [PATCH v4 0/9] Atmel System Timer cleanups Alexandre Belloni
2015-03-05 15:49 ` [PATCH v4 1/9] ARM: at91/dt: declare atmel,at91rm9200-st as a syscon Alexandre Belloni
@ 2015-03-05 15:49 ` Alexandre Belloni
2015-03-06 10:58 ` Lee Jones
2015-03-05 15:49 ` [PATCH v4 3/9] watchdog: at91rm9200: use the system timer syscon Alexandre Belloni
` (6 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Alexandre Belloni @ 2015-03-05 15:49 UTC (permalink / raw)
To: Nicolas Ferre, Daniel Lezcano
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm, Alexandre Belloni
AT91RM920 has a memory range reserved for timer and watchdog configuration.
Expose those registers so that drivers can make use of the system timer syscon
declared in at91 DTs.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
include/linux/mfd/syscon/atmel-st.h | 49 +++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 include/linux/mfd/syscon/atmel-st.h
diff --git a/include/linux/mfd/syscon/atmel-st.h b/include/linux/mfd/syscon/atmel-st.h
new file mode 100644
index 000000000000..93c7affc2809
--- /dev/null
+++ b/include/linux/mfd/syscon/atmel-st.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2005 Ivan Kokshaysky
+ * Copyright (C) SAN People
+ *
+ * System Timer (ST) - System peripherals registers.
+ * Based on AT91RM9200 datasheet revision E.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef _LINUX_MFD_SYSCON_ATMEL_ST_H
+#define _LINUX_MFD_SYSCON_ATMEL_ST_H
+
+#include <linux/bitops.h>
+
+#define AT91_ST_CR 0x00 /* Control Register */
+#define AT91_ST_WDRST BIT(0) /* Watchdog Timer Restart */
+
+#define AT91_ST_PIMR 0x04 /* Period Interval Mode Register */
+#define AT91_ST_PIV 0xffff /* Period Interval Value */
+
+#define AT91_ST_WDMR 0x08 /* Watchdog Mode Register */
+#define AT91_ST_WDV 0xffff /* Watchdog Counter Value */
+#define AT91_ST_RSTEN BIT(16) /* Reset Enable */
+#define AT91_ST_EXTEN BIT(17) /* External Signal Assertion Enable */
+
+#define AT91_ST_RTMR 0x0c /* Real-time Mode Register */
+#define AT91_ST_RTPRES 0xffff /* Real-time Prescalar Value */
+
+#define AT91_ST_SR 0x10 /* Status Register */
+#define AT91_ST_PITS BIT(0) /* Period Interval Timer Status */
+#define AT91_ST_WDOVF BIT(1) /* Watchdog Overflow */
+#define AT91_ST_RTTINC BIT(2) /* Real-time Timer Increment */
+#define AT91_ST_ALMS BIT(3) /* Alarm Status */
+
+#define AT91_ST_IER 0x14 /* Interrupt Enable Register */
+#define AT91_ST_IDR 0x18 /* Interrupt Disable Register */
+#define AT91_ST_IMR 0x1c /* Interrupt Mask Register */
+
+#define AT91_ST_RTAR 0x20 /* Real-time Alarm Register */
+#define AT91_ST_ALMV 0xfffff /* Alarm Value */
+
+#define AT91_ST_CRTR 0x24 /* Current Real-time Register */
+#define AT91_ST_CRTV 0xfffff /* Current Real-Time Value */
+
+#endif /* _LINUX_MFD_SYSCON_ATMEL_ST_H */
--
2.1.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 2/9] mfd: syscon: Add atmel system timer registers definition
2015-03-05 15:49 ` [PATCH v4 2/9] mfd: syscon: Add atmel system timer registers definition Alexandre Belloni
@ 2015-03-06 10:58 ` Lee Jones
0 siblings, 0 replies; 21+ messages in thread
From: Lee Jones @ 2015-03-06 10:58 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Nicolas Ferre, Daniel Lezcano, Boris Brezillon,
Jean-Christophe Plagniol-Villard, Thomas Gleixner,
Wim Van Sebroeck, Guenter Roeck, Sebastian Reichel,
Dmitry Eremin-Solenikov, linux-kernel, linux-arm-kernel,
linux-watchdog, linux-pm
On Thu, 05 Mar 2015, Alexandre Belloni wrote:
> AT91RM920 has a memory range reserved for timer and watchdog configuration.
> Expose those registers so that drivers can make use of the system timer syscon
> declared in at91 DTs.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> include/linux/mfd/syscon/atmel-st.h | 49 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 49 insertions(+)
> create mode 100644 include/linux/mfd/syscon/atmel-st.h
>
> diff --git a/include/linux/mfd/syscon/atmel-st.h b/include/linux/mfd/syscon/atmel-st.h
> new file mode 100644
> index 000000000000..93c7affc2809
> --- /dev/null
> +++ b/include/linux/mfd/syscon/atmel-st.h
> @@ -0,0 +1,49 @@
> +/*
> + * Copyright (C) 2005 Ivan Kokshaysky
> + * Copyright (C) SAN People
> + *
> + * System Timer (ST) - System peripherals registers.
> + * Based on AT91RM9200 datasheet revision E.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +
> +#ifndef _LINUX_MFD_SYSCON_ATMEL_ST_H
> +#define _LINUX_MFD_SYSCON_ATMEL_ST_H
> +
> +#include <linux/bitops.h>
> +
> +#define AT91_ST_CR 0x00 /* Control Register */
> +#define AT91_ST_WDRST BIT(0) /* Watchdog Timer Restart */
Sorry for the incremental reviews, I'm exceptionally busy of late.
The next white space character after #define should be a humble space.
... at least for the register defines. The bit assignments can be
tabbed out to denote what they are.
Once fixed, please resend with my:
Acked-by: Lee Jones <lee.jones@linaro.org>
> +#define AT91_ST_PIMR 0x04 /* Period Interval Mode Register */
> +#define AT91_ST_PIV 0xffff /* Period Interval Value */
> +
> +#define AT91_ST_WDMR 0x08 /* Watchdog Mode Register */
> +#define AT91_ST_WDV 0xffff /* Watchdog Counter Value */
> +#define AT91_ST_RSTEN BIT(16) /* Reset Enable */
> +#define AT91_ST_EXTEN BIT(17) /* External Signal Assertion Enable */
> +
> +#define AT91_ST_RTMR 0x0c /* Real-time Mode Register */
> +#define AT91_ST_RTPRES 0xffff /* Real-time Prescalar Value */
> +
> +#define AT91_ST_SR 0x10 /* Status Register */
> +#define AT91_ST_PITS BIT(0) /* Period Interval Timer Status */
> +#define AT91_ST_WDOVF BIT(1) /* Watchdog Overflow */
> +#define AT91_ST_RTTINC BIT(2) /* Real-time Timer Increment */
> +#define AT91_ST_ALMS BIT(3) /* Alarm Status */
> +
> +#define AT91_ST_IER 0x14 /* Interrupt Enable Register */
> +#define AT91_ST_IDR 0x18 /* Interrupt Disable Register */
> +#define AT91_ST_IMR 0x1c /* Interrupt Mask Register */
> +
> +#define AT91_ST_RTAR 0x20 /* Real-time Alarm Register */
> +#define AT91_ST_ALMV 0xfffff /* Alarm Value */
> +
> +#define AT91_ST_CRTR 0x24 /* Current Real-time Register */
> +#define AT91_ST_CRTV 0xfffff /* Current Real-Time Value */
> +
> +#endif /* _LINUX_MFD_SYSCON_ATMEL_ST_H */
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 3/9] watchdog: at91rm9200: use the system timer syscon
2015-03-05 15:49 [PATCH v4 0/9] Atmel System Timer cleanups Alexandre Belloni
2015-03-05 15:49 ` [PATCH v4 1/9] ARM: at91/dt: declare atmel,at91rm9200-st as a syscon Alexandre Belloni
2015-03-05 15:49 ` [PATCH v4 2/9] mfd: syscon: Add atmel system timer registers definition Alexandre Belloni
@ 2015-03-05 15:49 ` Alexandre Belloni
2015-03-09 15:33 ` [v4,3/9] " Guenter Roeck
2015-03-05 15:49 ` [PATCH v4 4/9] power: reset: Add AT91RM9200 reset driver Alexandre Belloni
` (5 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Alexandre Belloni @ 2015-03-05 15:49 UTC (permalink / raw)
To: Nicolas Ferre, Daniel Lezcano
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm, Alexandre Belloni
Use a syscon regmap to access the system timer registers.
Also, rename the driver atmel_st_watchdog to stop conflicting with
at91sam9_wdt.c
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/watchdog/Kconfig | 2 +-
drivers/watchdog/at91rm9200_wdt.c | 23 ++++++++++++++++-------
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index 16f202350997..ce4f3a7f95fd 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -154,7 +154,7 @@ config ARM_SP805_WATCHDOG
config AT91RM9200_WATCHDOG
tristate "AT91RM9200 watchdog"
- depends on SOC_AT91RM9200
+ depends on SOC_AT91RM9200 && MFD_SYSCON
help
Watchdog timer embedded into AT91RM9200 chips. This will reboot your
system when the timeout is reached.
diff --git a/drivers/watchdog/at91rm9200_wdt.c b/drivers/watchdog/at91rm9200_wdt.c
index d244112d5b6f..ad1294d1bb00 100644
--- a/drivers/watchdog/at91rm9200_wdt.c
+++ b/drivers/watchdog/at91rm9200_wdt.c
@@ -17,22 +17,25 @@
#include <linux/init.h>
#include <linux/io.h>
#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mfd/syscon/atmel-st.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/platform_device.h>
+#include <linux/regmap.h>
#include <linux/types.h>
#include <linux/watchdog.h>
#include <linux/uaccess.h>
#include <linux/of.h>
#include <linux/of_device.h>
-#include <mach/at91_st.h>
#define WDT_DEFAULT_TIME 5 /* seconds */
#define WDT_MAX_TIME 256 /* seconds */
static int wdt_time = WDT_DEFAULT_TIME;
static bool nowayout = WATCHDOG_NOWAYOUT;
+static struct regmap *regmap_st;
module_param(wdt_time, int, 0);
MODULE_PARM_DESC(wdt_time, "Watchdog time in seconds. (default="
@@ -55,7 +58,7 @@ static unsigned long at91wdt_busy;
*/
static inline void at91_wdt_stop(void)
{
- at91_st_write(AT91_ST_WDMR, AT91_ST_EXTEN);
+ regmap_write(regmap_st, AT91_ST_WDMR, AT91_ST_EXTEN);
}
/*
@@ -63,9 +66,9 @@ static inline void at91_wdt_stop(void)
*/
static inline void at91_wdt_start(void)
{
- at91_st_write(AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN |
+ regmap_write(regmap_st, AT91_ST_WDMR, AT91_ST_EXTEN | AT91_ST_RSTEN |
(((65536 * wdt_time) >> 8) & AT91_ST_WDV));
- at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
+ regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST);
}
/*
@@ -73,7 +76,7 @@ static inline void at91_wdt_start(void)
*/
static inline void at91_wdt_reload(void)
{
- at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
+ regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST);
}
/* ......................................................................... */
@@ -203,12 +206,17 @@ static struct miscdevice at91wdt_miscdev = {
static int at91wdt_probe(struct platform_device *pdev)
{
+ struct device_node *np = pdev->dev.of_node;
int res;
if (at91wdt_miscdev.parent)
return -EBUSY;
at91wdt_miscdev.parent = &pdev->dev;
+ regmap_st = syscon_node_to_regmap(np);
+ if (!regmap_st)
+ return -ENODEV;
+
res = misc_register(&at91wdt_miscdev);
if (res)
return res;
@@ -255,6 +263,7 @@ static int at91wdt_resume(struct platform_device *pdev)
#endif
static const struct of_device_id at91_wdt_dt_ids[] = {
+ { .compatible = "atmel,at91rm9200-st" },
{ .compatible = "atmel,at91rm9200-wdt" },
{ /* sentinel */ }
};
@@ -267,7 +276,7 @@ static struct platform_driver at91wdt_driver = {
.suspend = at91wdt_suspend,
.resume = at91wdt_resume,
.driver = {
- .name = "at91_wdt",
+ .name = "atmel_st_watchdog",
.of_match_table = at91_wdt_dt_ids,
},
};
@@ -296,4 +305,4 @@ module_exit(at91_wdt_exit);
MODULE_AUTHOR("Andrew Victor");
MODULE_DESCRIPTION("Watchdog driver for Atmel AT91RM9200");
MODULE_LICENSE("GPL");
-MODULE_ALIAS("platform:at91_wdt");
+MODULE_ALIAS("platform:atmel_st_watchdog");
--
2.1.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [v4,3/9] watchdog: at91rm9200: use the system timer syscon
2015-03-05 15:49 ` [PATCH v4 3/9] watchdog: at91rm9200: use the system timer syscon Alexandre Belloni
@ 2015-03-09 15:33 ` Guenter Roeck
0 siblings, 0 replies; 21+ messages in thread
From: Guenter Roeck @ 2015-03-09 15:33 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Nicolas Ferre, Daniel Lezcano, Boris Brezillon,
Jean-Christophe Plagniol-Villard, Thomas Gleixner, Lee Jones,
Wim Van Sebroeck, Sebastian Reichel, Dmitry Eremin-Solenikov,
linux-kernel, linux-arm-kernel, linux-watchdog, linux-pm
On Thu, Mar 05, 2015 at 04:49:48PM +0100, Alexandre Belloni wrote:
> Use a syscon regmap to access the system timer registers.
>
> Also, rename the driver atmel_st_watchdog to stop conflicting with
> at91sam9_wdt.c
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 4/9] power: reset: Add AT91RM9200 reset driver
2015-03-05 15:49 [PATCH v4 0/9] Atmel System Timer cleanups Alexandre Belloni
` (2 preceding siblings ...)
2015-03-05 15:49 ` [PATCH v4 3/9] watchdog: at91rm9200: use the system timer syscon Alexandre Belloni
@ 2015-03-05 15:49 ` Alexandre Belloni
2015-03-05 19:49 ` Paul Bolle
2015-03-05 15:49 ` [PATCH v4 5/9] ARM: at91: at91rm9200: remove deprecated arm_pm_restart Alexandre Belloni
` (4 subsequent siblings)
8 siblings, 1 reply; 21+ messages in thread
From: Alexandre Belloni @ 2015-03-05 15:49 UTC (permalink / raw)
To: Nicolas Ferre, Daniel Lezcano
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm, Alexandre Belloni
AT91RM9200 uses the watchdog from the system timer to reset.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/power/reset/Kconfig | 7 ++++
drivers/power/reset/Makefile | 1 +
drivers/power/reset/at91rm9200-reset.c | 72 ++++++++++++++++++++++++++++++++++
3 files changed, 80 insertions(+)
create mode 100644 drivers/power/reset/at91rm9200-reset.c
diff --git a/drivers/power/reset/Kconfig b/drivers/power/reset/Kconfig
index 27f6646731b0..8d79e45ae754 100644
--- a/drivers/power/reset/Kconfig
+++ b/drivers/power/reset/Kconfig
@@ -30,6 +30,13 @@ config POWER_RESET_AT91_RESET
This driver supports restart for Atmel AT91SAM9 and SAMA5
SoCs
+config POWER_RESET_AT91RM9200_RESET
+ bool "Atmel AT91RM9200 reset driver"
+ depends on ARCH_AT91 && MFD_SYSCON
+ default SOC_AT91RM9200
+ help
+ This driver supports restart for Atmel AT91RM9200.
+
config POWER_RESET_AXXIA
bool "LSI Axxia reset driver"
depends on ARCH_AXXIA
diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
index 11de15bae52e..96e972bbb922 100644
--- a/drivers/power/reset/Makefile
+++ b/drivers/power/reset/Makefile
@@ -1,6 +1,7 @@
obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o
obj-$(CONFIG_POWER_RESET_AT91_POWEROFF) += at91-poweroff.o
obj-$(CONFIG_POWER_RESET_AT91_RESET) += at91-reset.o
+obj-$(CONFIG_POWER_RESET_AT91RM9200_RESET) += at91rm9200-reset.o
obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o
obj-$(CONFIG_POWER_RESET_BRCMSTB) += brcmstb-reboot.o
obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
diff --git a/drivers/power/reset/at91rm9200-reset.c b/drivers/power/reset/at91rm9200-reset.c
new file mode 100644
index 000000000000..b739ac82b9c9
--- /dev/null
+++ b/drivers/power/reset/at91rm9200-reset.c
@@ -0,0 +1,72 @@
+/*
+ * Atmel AT91 RM9200 SoCs reset code
+ *
+ * Copyright (C) 2015 Atmel Corporation.
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mfd/syscon/atmel-st.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/reboot.h>
+#include <linux/regmap.h>
+
+static struct regmap *regmap_st;
+
+static int at91rm9200_restart(struct notifier_block *this,
+ unsigned long mode, void *cmd)
+{
+ /*
+ * Perform a hardware reset with the use of the Watchdog timer.
+ */
+ regmap_write(regmap_st, AT91_ST_WDMR,
+ AT91_ST_RSTEN | AT91_ST_EXTEN | 1);
+ regmap_write(regmap_st, AT91_ST_CR, AT91_ST_WDRST);
+
+ mdelay(2000);
+
+ pr_emerg("Unable to restart system\n");
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block at91rm9200_restart_nb = {
+ .notifier_call = at91rm9200_restart,
+ .priority = 192,
+};
+
+static int at91rm9200_reset_probe(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+
+ regmap_st = syscon_node_to_regmap(np);
+ if (!regmap_st)
+ return -ENODEV;
+
+ return register_restart_handler(&at91rm9200_restart_nb);
+}
+
+static const struct of_device_id at91rm9200_reset_of_match[] = {
+ { .compatible = "atmel,at91rm9200-st" },
+ { /* sentinel */ }
+};
+
+static struct platform_driver at91rm9200_reset_driver = {
+ .probe = at91rm9200_reset_probe,
+ .driver = {
+ .name = "at91rm9200-reset",
+ .of_match_table = at91rm9200_reset_of_match,
+ },
+};
+module_platform_driver(at91rm9200_reset_driver);
+
+MODULE_ALIAS("platform:at91rm9200-reset");
+MODULE_AUTHOR("Alexandre Belloni <alexandre.belloni@free-electrons.com>");
+MODULE_DESCRIPTION("Atmel at91rm9200 System Timer Reset driver");
+MODULE_LICENSE("GPL v2");
--
2.1.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 4/9] power: reset: Add AT91RM9200 reset driver
2015-03-05 15:49 ` [PATCH v4 4/9] power: reset: Add AT91RM9200 reset driver Alexandre Belloni
@ 2015-03-05 19:49 ` Paul Bolle
2015-03-05 20:34 ` Alexandre Belloni
0 siblings, 1 reply; 21+ messages in thread
From: Paul Bolle @ 2015-03-05 19:49 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Nicolas Ferre, Daniel Lezcano, Boris Brezillon,
Jean-Christophe Plagniol-Villard, Thomas Gleixner, Lee Jones,
Wim Van Sebroeck, Guenter Roeck, Sebastian Reichel,
Dmitry Eremin-Solenikov, linux-kernel, linux-arm-kernel,
linux-watchdog, linux-pm
On Thu, 2015-03-05 at 16:49 +0100, Alexandre Belloni wrote:
> --- a/drivers/power/reset/Kconfig
> +++ b/drivers/power/reset/Kconfig
> @@ -30,6 +30,13 @@ config POWER_RESET_AT91_RESET
> This driver supports restart for Atmel AT91SAM9 and SAMA5
> SoCs
>
> +config POWER_RESET_AT91RM9200_RESET
> + bool "Atmel AT91RM9200 reset driver"
This adds a bool symbol.
> + depends on ARCH_AT91 && MFD_SYSCON
> + default SOC_AT91RM9200
> + help
> + This driver supports restart for Atmel AT91RM9200.
> +
> config POWER_RESET_AXXIA
> bool "LSI Axxia reset driver"
> depends on ARCH_AXXIA
> diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
> index 11de15bae52e..96e972bbb922 100644
> --- a/drivers/power/reset/Makefile
> +++ b/drivers/power/reset/Makefile
> @@ -1,6 +1,7 @@
> obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o
> obj-$(CONFIG_POWER_RESET_AT91_POWEROFF) += at91-poweroff.o
> obj-$(CONFIG_POWER_RESET_AT91_RESET) += at91-reset.o
> +obj-$(CONFIG_POWER_RESET_AT91RM9200_RESET) += at91rm9200-reset.o
This objectfile will never be modular.
> obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o
> obj-$(CONFIG_POWER_RESET_BRCMSTB) += brcmstb-reboot.o
> obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
> diff --git a/drivers/power/reset/at91rm9200-reset.c b/drivers/power/reset/at91rm9200-reset.c
> new file mode 100644
> index 000000000000..b739ac82b9c9
> --- /dev/null
> +++ b/drivers/power/reset/at91rm9200-reset.c
> @@ -0,0 +1,72 @@
> +#include <linux/module.h>
Is this needed?
> +static struct platform_driver at91rm9200_reset_driver = {
> + .probe = at91rm9200_reset_probe,
> + .driver = {
> + .name = "at91rm9200-reset",
> + .of_match_table = at91rm9200_reset_of_match,
> + },
> +};
> +module_platform_driver(at91rm9200_reset_driver);
This should, perhaps, be replaced by a wrapper that calls
platform_driver_register(at91rm9200_reset_driver)
while that wrapper is, well, called through
device_initcall()
or something similar. I didn't test this suggestion.
> +MODULE_ALIAS("platform:at91rm9200-reset");
> +MODULE_AUTHOR("Alexandre Belloni <alexandre.belloni@free-electrons.com>");
> +MODULE_DESCRIPTION("Atmel at91rm9200 System Timer Reset driver");
> +MODULE_LICENSE("GPL v2");
All these macros will be, basically, preprocessed away.
Paul Bolle
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 4/9] power: reset: Add AT91RM9200 reset driver
2015-03-05 19:49 ` Paul Bolle
@ 2015-03-05 20:34 ` Alexandre Belloni
0 siblings, 0 replies; 21+ messages in thread
From: Alexandre Belloni @ 2015-03-05 20:34 UTC (permalink / raw)
To: Paul Bolle
Cc: Nicolas Ferre, Daniel Lezcano, Boris Brezillon,
Jean-Christophe Plagniol-Villard, Thomas Gleixner, Lee Jones,
Wim Van Sebroeck, Guenter Roeck, Sebastian Reichel,
Dmitry Eremin-Solenikov, linux-kernel, linux-arm-kernel,
linux-watchdog, linux-pm
On 05/03/2015 at 20:49:14 +0100, Paul Bolle wrote :
> On Thu, 2015-03-05 at 16:49 +0100, Alexandre Belloni wrote:
> > --- a/drivers/power/reset/Kconfig
> > +++ b/drivers/power/reset/Kconfig
> > @@ -30,6 +30,13 @@ config POWER_RESET_AT91_RESET
> > This driver supports restart for Atmel AT91SAM9 and SAMA5
> > SoCs
> >
> > +config POWER_RESET_AT91RM9200_RESET
> > + bool "Atmel AT91RM9200 reset driver"
>
> This adds a bool symbol.
>
> > + depends on ARCH_AT91 && MFD_SYSCON
> > + default SOC_AT91RM9200
> > + help
> > + This driver supports restart for Atmel AT91RM9200.
> > +
> > config POWER_RESET_AXXIA
> > bool "LSI Axxia reset driver"
> > depends on ARCH_AXXIA
> > diff --git a/drivers/power/reset/Makefile b/drivers/power/reset/Makefile
> > index 11de15bae52e..96e972bbb922 100644
> > --- a/drivers/power/reset/Makefile
> > +++ b/drivers/power/reset/Makefile
> > @@ -1,6 +1,7 @@
> > obj-$(CONFIG_POWER_RESET_AS3722) += as3722-poweroff.o
> > obj-$(CONFIG_POWER_RESET_AT91_POWEROFF) += at91-poweroff.o
> > obj-$(CONFIG_POWER_RESET_AT91_RESET) += at91-reset.o
> > +obj-$(CONFIG_POWER_RESET_AT91RM9200_RESET) += at91rm9200-reset.o
>
> This objectfile will never be modular.
>
> > obj-$(CONFIG_POWER_RESET_AXXIA) += axxia-reset.o
> > obj-$(CONFIG_POWER_RESET_BRCMSTB) += brcmstb-reboot.o
> > obj-$(CONFIG_POWER_RESET_GPIO) += gpio-poweroff.o
> > diff --git a/drivers/power/reset/at91rm9200-reset.c b/drivers/power/reset/at91rm9200-reset.c
> > new file mode 100644
> > index 000000000000..b739ac82b9c9
> > --- /dev/null
> > +++ b/drivers/power/reset/at91rm9200-reset.c
> > @@ -0,0 +1,72 @@
>
> > +#include <linux/module.h>
>
> Is this needed?
>
> > +static struct platform_driver at91rm9200_reset_driver = {
> > + .probe = at91rm9200_reset_probe,
> > + .driver = {
> > + .name = "at91rm9200-reset",
> > + .of_match_table = at91rm9200_reset_of_match,
> > + },
> > +};
> > +module_platform_driver(at91rm9200_reset_driver);
>
> This should, perhaps, be replaced by a wrapper that calls
> platform_driver_register(at91rm9200_reset_driver)
>
> while that wrapper is, well, called through
> device_initcall()
>
> or something similar. I didn't test this suggestion.
>
> > +MODULE_ALIAS("platform:at91rm9200-reset");
> > +MODULE_AUTHOR("Alexandre Belloni <alexandre.belloni@free-electrons.com>");
> > +MODULE_DESCRIPTION("Atmel at91rm9200 System Timer Reset driver");
> > +MODULE_LICENSE("GPL v2");
>
> All these macros will be, basically, preprocessed away.
>
>
Indeed, a lot got cargo culted/copy-pasted. I'll fix it and the
at91-reset driver too.
Thanks!
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 5/9] ARM: at91: at91rm9200: remove deprecated arm_pm_restart
2015-03-05 15:49 [PATCH v4 0/9] Atmel System Timer cleanups Alexandre Belloni
` (3 preceding siblings ...)
2015-03-05 15:49 ` [PATCH v4 4/9] power: reset: Add AT91RM9200 reset driver Alexandre Belloni
@ 2015-03-05 15:49 ` Alexandre Belloni
2015-03-05 15:49 ` [PATCH v4 6/9] ARM: at91: time: move the system timer driver to drivers/clocksource Alexandre Belloni
` (3 subsequent siblings)
8 siblings, 0 replies; 21+ messages in thread
From: Alexandre Belloni @ 2015-03-05 15:49 UTC (permalink / raw)
To: Nicolas Ferre, Daniel Lezcano
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm, Alexandre Belloni
Now that a proper driver is available, remove at91rm9200_restart.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
arch/arm/mach-at91/at91rm9200.c | 12 ------------
1 file changed, 12 deletions(-)
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index 8fcfb70f7124..2386d08d65e8 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -24,19 +24,8 @@
#include <asm/mach/irq.h>
#include <asm/system_misc.h>
-#include <mach/at91_st.h>
-
#include "generic.h"
-static void at91rm9200_restart(enum reboot_mode reboot_mode, const char *cmd)
-{
- /*
- * Perform a hardware reset with the use of the Watchdog timer.
- */
- at91_st_write(AT91_ST_WDMR, AT91_ST_RSTEN | AT91_ST_EXTEN | 1);
- at91_st_write(AT91_ST_CR, AT91_ST_WDRST);
-}
-
static void __init at91rm9200_dt_timer_init(void)
{
of_clk_init(NULL);
@@ -48,7 +37,6 @@ static void __init at91rm9200_dt_device_init(void)
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
arm_pm_idle = at91rm9200_idle;
- arm_pm_restart = at91rm9200_restart;
at91rm9200_pm_init();
}
--
2.1.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 6/9] ARM: at91: time: move the system timer driver to drivers/clocksource
2015-03-05 15:49 [PATCH v4 0/9] Atmel System Timer cleanups Alexandre Belloni
` (4 preceding siblings ...)
2015-03-05 15:49 ` [PATCH v4 5/9] ARM: at91: at91rm9200: remove deprecated arm_pm_restart Alexandre Belloni
@ 2015-03-05 15:49 ` Alexandre Belloni
2015-03-05 19:41 ` Paul Bolle
2015-03-06 8:36 ` Daniel Lezcano
2015-03-05 15:49 ` [PATCH v4 7/9] clocksource: atmel-st: properly initialize driver Alexandre Belloni
` (2 subsequent siblings)
8 siblings, 2 replies; 21+ messages in thread
From: Alexandre Belloni @ 2015-03-05 15:49 UTC (permalink / raw)
To: Nicolas Ferre, Daniel Lezcano
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm, Alexandre Belloni
Import at91rm9200_time.c from mach-at91 as timer-atmel-st.c. Further cleanup is
required to get rid of the mach-at91 headers.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
arch/arm/mach-at91/Makefile | 2 +-
drivers/clocksource/Kconfig | 4 ++++
drivers/clocksource/Makefile | 1 +
.../at91rm9200_time.c => drivers/clocksource/timer-atmel-st.c | 0
4 files changed, 6 insertions(+), 1 deletion(-)
rename arch/arm/mach-at91/at91rm9200_time.c => drivers/clocksource/timer-atmel-st.c (100%)
diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 827fdbcce1c7..963c29169242 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -7,7 +7,7 @@ obj-y := setup.o
obj-$(CONFIG_SOC_AT91SAM9) += sam9_smc.o
# CPU-specific support
-obj-$(CONFIG_SOC_AT91RM9200) += at91rm9200.o at91rm9200_time.o
+obj-$(CONFIG_SOC_AT91RM9200) += at91rm9200.o
obj-$(CONFIG_SOC_AT91SAM9) += at91sam9.o
obj-$(CONFIG_SOC_SAMA5) += sama5.o
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 1c2506f68122..d1d15985a4ec 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -138,6 +138,10 @@ config ATMEL_PIT
select CLKSRC_OF if OF
def_bool SOC_AT91SAM9 || SOC_SAMA5
+config ATMEL_ST
+ select CLKSRC_OF if OF
+ def_bool SOC_AT91RM9200
+
config CLKSRC_METAG_GENERIC
def_bool y if METAG
help
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 752d5c70b0ef..5b85f6adb258 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -1,5 +1,6 @@
obj-$(CONFIG_CLKSRC_OF) += clksrc-of.o
obj-$(CONFIG_ATMEL_PIT) += timer-atmel-pit.o
+obj-$(CONFIG_ATMEL_ST) += timer-atmel-st.o
obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o
obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o
diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/drivers/clocksource/timer-atmel-st.c
similarity index 100%
rename from arch/arm/mach-at91/at91rm9200_time.c
rename to drivers/clocksource/timer-atmel-st.c
--
2.1.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 6/9] ARM: at91: time: move the system timer driver to drivers/clocksource
2015-03-05 15:49 ` [PATCH v4 6/9] ARM: at91: time: move the system timer driver to drivers/clocksource Alexandre Belloni
@ 2015-03-05 19:41 ` Paul Bolle
2015-03-05 19:47 ` Alexandre Belloni
2015-03-06 8:36 ` Daniel Lezcano
1 sibling, 1 reply; 21+ messages in thread
From: Paul Bolle @ 2015-03-05 19:41 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Nicolas Ferre, Daniel Lezcano, Boris Brezillon,
Jean-Christophe Plagniol-Villard, Thomas Gleixner, Lee Jones,
Wim Van Sebroeck, Guenter Roeck, Sebastian Reichel,
Dmitry Eremin-Solenikov, linux-kernel, linux-arm-kernel,
linux-watchdog, linux-pm
On Thu, 2015-03-05 at 16:49 +0100, Alexandre Belloni wrote:
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 1c2506f68122..d1d15985a4ec 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -138,6 +138,10 @@ config ATMEL_PIT
> select CLKSRC_OF if OF
> def_bool SOC_AT91SAM9 || SOC_SAMA5
>
> +config ATMEL_ST
> + select CLKSRC_OF if OF
> + def_bool SOC_AT91RM9200
If you swap these two lines you'll make the set of people that probably
only includes me a bit happier.
> +
> config CLKSRC_METAG_GENERIC
> def_bool y if METAG
> help
Thanks,
Paul Bolle
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 6/9] ARM: at91: time: move the system timer driver to drivers/clocksource
2015-03-05 19:41 ` Paul Bolle
@ 2015-03-05 19:47 ` Alexandre Belloni
0 siblings, 0 replies; 21+ messages in thread
From: Alexandre Belloni @ 2015-03-05 19:47 UTC (permalink / raw)
To: Paul Bolle
Cc: Nicolas Ferre, Daniel Lezcano, Boris Brezillon,
Jean-Christophe Plagniol-Villard, Thomas Gleixner, Lee Jones,
Wim Van Sebroeck, Guenter Roeck, Sebastian Reichel,
Dmitry Eremin-Solenikov, linux-kernel, linux-arm-kernel,
linux-watchdog, linux-pm
On 05/03/2015 at 20:41:33 +0100, Paul Bolle wrote :
> On Thu, 2015-03-05 at 16:49 +0100, Alexandre Belloni wrote:
> > diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> > index 1c2506f68122..d1d15985a4ec 100644
> > --- a/drivers/clocksource/Kconfig
> > +++ b/drivers/clocksource/Kconfig
> > @@ -138,6 +138,10 @@ config ATMEL_PIT
> > select CLKSRC_OF if OF
> > def_bool SOC_AT91SAM9 || SOC_SAMA5
> >
> > +config ATMEL_ST
> > + select CLKSRC_OF if OF
> > + def_bool SOC_AT91RM9200
>
> If you swap these two lines you'll make the set of people that probably
> only includes me a bit happier.
>
I'm all for making you happier ;)
I'll respin next week, hopefully after getting more comments.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 6/9] ARM: at91: time: move the system timer driver to drivers/clocksource
2015-03-05 15:49 ` [PATCH v4 6/9] ARM: at91: time: move the system timer driver to drivers/clocksource Alexandre Belloni
2015-03-05 19:41 ` Paul Bolle
@ 2015-03-06 8:36 ` Daniel Lezcano
1 sibling, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2015-03-06 8:36 UTC (permalink / raw)
To: Alexandre Belloni, Nicolas Ferre
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm
On 03/05/2015 04:49 PM, Alexandre Belloni wrote:
> Import at91rm9200_time.c from mach-at91 as timer-atmel-st.c. Further cleanup is
> required to get rid of the mach-at91 headers.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> arch/arm/mach-at91/Makefile | 2 +-
> drivers/clocksource/Kconfig | 4 ++++
> drivers/clocksource/Makefile | 1 +
> .../at91rm9200_time.c => drivers/clocksource/timer-atmel-st.c | 0
> 4 files changed, 6 insertions(+), 1 deletion(-)
> rename arch/arm/mach-at91/at91rm9200_time.c => drivers/clocksource/timer-atmel-st.c (100%)
>
> diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
> index 827fdbcce1c7..963c29169242 100644
> --- a/arch/arm/mach-at91/Makefile
> +++ b/arch/arm/mach-at91/Makefile
> @@ -7,7 +7,7 @@ obj-y := setup.o
> obj-$(CONFIG_SOC_AT91SAM9) += sam9_smc.o
>
> # CPU-specific support
> -obj-$(CONFIG_SOC_AT91RM9200) += at91rm9200.o at91rm9200_time.o
> +obj-$(CONFIG_SOC_AT91RM9200) += at91rm9200.o
> obj-$(CONFIG_SOC_AT91SAM9) += at91sam9.o
> obj-$(CONFIG_SOC_SAMA5) += sama5.o
>
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
> index 1c2506f68122..d1d15985a4ec 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -138,6 +138,10 @@ config ATMEL_PIT
> select CLKSRC_OF if OF
> def_bool SOC_AT91SAM9 || SOC_SAMA5
>
> +config ATMEL_ST
> + select CLKSRC_OF if OF
> + def_bool SOC_AT91RM9200
> +
H Alexandre,
the global policy is to enable the timer from the platform Kconfig.
So it should be:
config ATMEL_ST
bool
select CLKSRC_OF if OF
and change the mach's Kconfig to select this driver for the
corresponding platform.
> config CLKSRC_METAG_GENERIC
> def_bool y if METAG
> help
> diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
> index 752d5c70b0ef..5b85f6adb258 100644
> --- a/drivers/clocksource/Makefile
> +++ b/drivers/clocksource/Makefile
> @@ -1,5 +1,6 @@
> obj-$(CONFIG_CLKSRC_OF) += clksrc-of.o
> obj-$(CONFIG_ATMEL_PIT) += timer-atmel-pit.o
> +obj-$(CONFIG_ATMEL_ST) += timer-atmel-st.o
> obj-$(CONFIG_ATMEL_TCB_CLKSRC) += tcb_clksrc.o
> obj-$(CONFIG_X86_PM_TIMER) += acpi_pm.o
> obj-$(CONFIG_SCx200HR_TIMER) += scx200_hrt.o
> diff --git a/arch/arm/mach-at91/at91rm9200_time.c b/drivers/clocksource/timer-atmel-st.c
> similarity index 100%
> rename from arch/arm/mach-at91/at91rm9200_time.c
> rename to drivers/clocksource/timer-atmel-st.c
>
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 7/9] clocksource: atmel-st: properly initialize driver
2015-03-05 15:49 [PATCH v4 0/9] Atmel System Timer cleanups Alexandre Belloni
` (5 preceding siblings ...)
2015-03-05 15:49 ` [PATCH v4 6/9] ARM: at91: time: move the system timer driver to drivers/clocksource Alexandre Belloni
@ 2015-03-05 15:49 ` Alexandre Belloni
2015-03-06 8:38 ` Daniel Lezcano
2015-03-05 15:49 ` [PATCH v4 8/9] clocksource: atmel-st: use syscon/regmap Alexandre Belloni
2015-03-05 15:49 ` [PATCH v4 9/9] ARM: at91: remove useless include Alexandre Belloni
8 siblings, 1 reply; 21+ messages in thread
From: Alexandre Belloni @ 2015-03-05 15:49 UTC (permalink / raw)
To: Nicolas Ferre, Daniel Lezcano
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm, Alexandre Belloni
Use clocksource_of_init to initialize the system timer instead of relying on a
custom function.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
arch/arm/mach-at91/at91rm9200.c | 7 -------
arch/arm/mach-at91/generic.h | 3 ---
drivers/clocksource/timer-atmel-st.c | 4 +++-
3 files changed, 3 insertions(+), 11 deletions(-)
diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index 2386d08d65e8..5efb075294e5 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -26,12 +26,6 @@
#include "generic.h"
-static void __init at91rm9200_dt_timer_init(void)
-{
- of_clk_init(NULL);
- at91rm9200_timer_init();
-}
-
static void __init at91rm9200_dt_device_init(void)
{
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
@@ -48,7 +42,6 @@ static const char *at91rm9200_dt_board_compat[] __initconst = {
};
DT_MACHINE_START(at91rm9200_dt, "Atmel AT91RM9200")
- .init_time = at91rm9200_dt_timer_init,
.map_io = at91_map_io,
.init_machine = at91rm9200_dt_device_init,
.dt_compat = at91rm9200_dt_board_compat,
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index 583369ffc284..6c953bff13d6 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -18,9 +18,6 @@
extern void __init at91_map_io(void);
extern void __init at91_alt_map_io(void);
- /* Timer */
-extern void at91rm9200_timer_init(void);
-
/* idle */
extern void at91rm9200_idle(void);
extern void at91sam9_idle(void);
diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
index b00d09555f2b..7d062ab32674 100644
--- a/drivers/clocksource/timer-atmel-st.c
+++ b/drivers/clocksource/timer-atmel-st.c
@@ -222,7 +222,7 @@ err:
/*
* ST (system timer) module supports both clockevents and clocksource.
*/
-void __init at91rm9200_timer_init(void)
+static void __init atmel_st_timer_init(struct device_node *node)
{
/* For device tree enabled device: initialize here */
of_at91rm9200_st_init();
@@ -249,3 +249,5 @@ void __init at91rm9200_timer_init(void)
/* register clocksource */
clocksource_register_hz(&clk32k, AT91_SLOW_CLOCK);
}
+CLOCKSOURCE_OF_DECLARE(atmel_st_timer, "atmel,at91rm9200-st",
+ atmel_st_timer_init);
--
2.1.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 7/9] clocksource: atmel-st: properly initialize driver
2015-03-05 15:49 ` [PATCH v4 7/9] clocksource: atmel-st: properly initialize driver Alexandre Belloni
@ 2015-03-06 8:38 ` Daniel Lezcano
0 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2015-03-06 8:38 UTC (permalink / raw)
To: Alexandre Belloni, Nicolas Ferre
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm
On 03/05/2015 04:49 PM, Alexandre Belloni wrote:
> Use clocksource_of_init to initialize the system timer instead of relying on a
> custom function.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
This patch should be before 6/9 but anyway ...
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
> arch/arm/mach-at91/at91rm9200.c | 7 -------
> arch/arm/mach-at91/generic.h | 3 ---
> drivers/clocksource/timer-atmel-st.c | 4 +++-
> 3 files changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
> index 2386d08d65e8..5efb075294e5 100644
> --- a/arch/arm/mach-at91/at91rm9200.c
> +++ b/arch/arm/mach-at91/at91rm9200.c
> @@ -26,12 +26,6 @@
>
> #include "generic.h"
>
> -static void __init at91rm9200_dt_timer_init(void)
> -{
> - of_clk_init(NULL);
> - at91rm9200_timer_init();
> -}
> -
> static void __init at91rm9200_dt_device_init(void)
> {
> of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> @@ -48,7 +42,6 @@ static const char *at91rm9200_dt_board_compat[] __initconst = {
> };
>
> DT_MACHINE_START(at91rm9200_dt, "Atmel AT91RM9200")
> - .init_time = at91rm9200_dt_timer_init,
> .map_io = at91_map_io,
> .init_machine = at91rm9200_dt_device_init,
> .dt_compat = at91rm9200_dt_board_compat,
> diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
> index 583369ffc284..6c953bff13d6 100644
> --- a/arch/arm/mach-at91/generic.h
> +++ b/arch/arm/mach-at91/generic.h
> @@ -18,9 +18,6 @@
> extern void __init at91_map_io(void);
> extern void __init at91_alt_map_io(void);
>
> - /* Timer */
> -extern void at91rm9200_timer_init(void);
> -
> /* idle */
> extern void at91rm9200_idle(void);
> extern void at91sam9_idle(void);
> diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
> index b00d09555f2b..7d062ab32674 100644
> --- a/drivers/clocksource/timer-atmel-st.c
> +++ b/drivers/clocksource/timer-atmel-st.c
> @@ -222,7 +222,7 @@ err:
> /*
> * ST (system timer) module supports both clockevents and clocksource.
> */
> -void __init at91rm9200_timer_init(void)
> +static void __init atmel_st_timer_init(struct device_node *node)
> {
> /* For device tree enabled device: initialize here */
> of_at91rm9200_st_init();
> @@ -249,3 +249,5 @@ void __init at91rm9200_timer_init(void)
> /* register clocksource */
> clocksource_register_hz(&clk32k, AT91_SLOW_CLOCK);
> }
> +CLOCKSOURCE_OF_DECLARE(atmel_st_timer, "atmel,at91rm9200-st",
> + atmel_st_timer_init);
>
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 8/9] clocksource: atmel-st: use syscon/regmap
2015-03-05 15:49 [PATCH v4 0/9] Atmel System Timer cleanups Alexandre Belloni
` (6 preceding siblings ...)
2015-03-05 15:49 ` [PATCH v4 7/9] clocksource: atmel-st: properly initialize driver Alexandre Belloni
@ 2015-03-05 15:49 ` Alexandre Belloni
2015-03-06 8:43 ` Daniel Lezcano
2015-03-05 15:49 ` [PATCH v4 9/9] ARM: at91: remove useless include Alexandre Belloni
8 siblings, 1 reply; 21+ messages in thread
From: Alexandre Belloni @ 2015-03-05 15:49 UTC (permalink / raw)
To: Nicolas Ferre, Daniel Lezcano
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm, Alexandre Belloni
The register range from the system timer is also used by the watchdog driver.
Use a regmap to handle concurrent accesses.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
drivers/clocksource/timer-atmel-st.c | 99 ++++++++++++++----------------------
1 file changed, 37 insertions(+), 62 deletions(-)
diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
index 7d062ab32674..c4a52e32675e 100644
--- a/drivers/clocksource/timer-atmel-st.c
+++ b/drivers/clocksource/timer-atmel-st.c
@@ -24,19 +24,19 @@
#include <linux/irq.h>
#include <linux/clockchips.h>
#include <linux/export.h>
-#include <linux/of.h>
-#include <linux/of_address.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mfd/syscon/atmel-st.h>
#include <linux/of_irq.h>
+#include <linux/regmap.h>
#include <asm/mach/time.h>
-#include <mach/at91_st.h>
-#include <mach/hardware.h>
-
static unsigned long last_crtr;
static u32 irqmask;
static struct clock_event_device clkevt;
+static struct regmap *regmap_st;
+#define AT91_SLOW_CLOCK 32768
#define RM9200_TIMER_LATCH ((AT91_SLOW_CLOCK + HZ/2) / HZ)
/*
@@ -46,11 +46,11 @@ static struct clock_event_device clkevt;
*/
static inline unsigned long read_CRTR(void)
{
- unsigned long x1, x2;
+ unsigned int x1, x2;
- x1 = at91_st_read(AT91_ST_CRTR);
+ regmap_read(regmap_st, AT91_ST_CRTR, &x1);
do {
- x2 = at91_st_read(AT91_ST_CRTR);
+ regmap_read(regmap_st, AT91_ST_CRTR, &x2);
if (x1 == x2)
break;
x1 = x2;
@@ -63,7 +63,10 @@ static inline unsigned long read_CRTR(void)
*/
static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
{
- u32 sr = at91_st_read(AT91_ST_SR) & irqmask;
+ u32 sr;
+
+ regmap_read(regmap_st, AT91_ST_SR, &sr);
+ sr &= irqmask;
/*
* irqs should be disabled here, but as the irq is shared they are only
@@ -96,7 +99,7 @@ static struct irqaction at91rm9200_timer_irq = {
.name = "at91_tick",
.flags = IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
.handler = at91rm9200_timer_interrupt,
- .irq = NR_IRQS_LEGACY + AT91_ID_SYS,
+ .irq = 0,
};
static cycle_t read_clk32k(struct clocksource *cs)
@@ -115,23 +118,25 @@ static struct clocksource clk32k = {
static void
clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
{
+ unsigned int val;
+
/* Disable and flush pending timer interrupts */
- at91_st_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS);
- at91_st_read(AT91_ST_SR);
+ regmap_write(regmap_st, AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS);
+ regmap_read(regmap_st, AT91_ST_SR, &val);
last_crtr = read_CRTR();
switch (mode) {
case CLOCK_EVT_MODE_PERIODIC:
/* PIT for periodic irqs; fixed rate of 1/HZ */
irqmask = AT91_ST_PITS;
- at91_st_write(AT91_ST_PIMR, RM9200_TIMER_LATCH);
+ regmap_write(regmap_st, AT91_ST_PIMR, RM9200_TIMER_LATCH);
break;
case CLOCK_EVT_MODE_ONESHOT:
/* ALM for oneshot irqs, set by next_event()
* before 32 seconds have passed
*/
irqmask = AT91_ST_ALMS;
- at91_st_write(AT91_ST_RTAR, last_crtr);
+ regmap_write(regmap_st, AT91_ST_RTAR, last_crtr);
break;
case CLOCK_EVT_MODE_SHUTDOWN:
case CLOCK_EVT_MODE_UNUSED:
@@ -139,7 +144,7 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
irqmask = 0;
break;
}
- at91_st_write(AT91_ST_IER, irqmask);
+ regmap_write(regmap_st, AT91_ST_IER, irqmask);
}
static int
@@ -147,6 +152,7 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)
{
u32 alm;
int status = 0;
+ unsigned int val;
BUG_ON(delta < 2);
@@ -162,12 +168,12 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)
alm = read_CRTR();
/* Cancel any pending alarm; flush any pending IRQ */
- at91_st_write(AT91_ST_RTAR, alm);
- at91_st_read(AT91_ST_SR);
+ regmap_write(regmap_st, AT91_ST_RTAR, alm);
+ regmap_read(regmap_st, AT91_ST_SR, &val);
/* Schedule alarm by writing RTAR. */
alm += delta;
- at91_st_write(AT91_ST_RTAR, alm);
+ regmap_write(regmap_st, AT91_ST_RTAR, alm);
return status;
}
@@ -180,57 +186,26 @@ static struct clock_event_device clkevt = {
.set_mode = clkevt32k_mode,
};
-void __iomem *at91_st_base;
-EXPORT_SYMBOL_GPL(at91_st_base);
-
-static const struct of_device_id at91rm9200_st_timer_ids[] = {
- { .compatible = "atmel,at91rm9200-st" },
- { /* sentinel */ }
-};
-
-static int __init of_at91rm9200_st_init(void)
-{
- struct device_node *np;
- int ret;
-
- np = of_find_matching_node(NULL, at91rm9200_st_timer_ids);
- if (!np)
- goto err;
-
- at91_st_base = of_iomap(np, 0);
- if (!at91_st_base)
- goto node_err;
-
- /* Get the interrupts property */
- ret = irq_of_parse_and_map(np, 0);
- if (!ret)
- goto ioremap_err;
- at91rm9200_timer_irq.irq = ret;
-
- of_node_put(np);
-
- return 0;
-
-ioremap_err:
- iounmap(at91_st_base);
-node_err:
- of_node_put(np);
-err:
- return -EINVAL;
-}
-
/*
* ST (system timer) module supports both clockevents and clocksource.
*/
static void __init atmel_st_timer_init(struct device_node *node)
{
- /* For device tree enabled device: initialize here */
- of_at91rm9200_st_init();
+ unsigned int val;
+
+ regmap_st = syscon_node_to_regmap(node);
+ if (IS_ERR(regmap_st))
+ panic(pr_fmt("Unable to get regmap\n"));
/* Disable all timer interrupts, and clear any pending ones */
- at91_st_write(AT91_ST_IDR,
+ regmap_write(regmap_st, AT91_ST_IDR,
AT91_ST_PITS | AT91_ST_WDOVF | AT91_ST_RTTINC | AT91_ST_ALMS);
- at91_st_read(AT91_ST_SR);
+ regmap_read(regmap_st, AT91_ST_SR, &val);
+
+ /* Get the interrupts property */
+ at91rm9200_timer_irq.irq = irq_of_parse_and_map(node, 0);
+ if (!at91rm9200_timer_irq.irq)
+ panic(pr_fmt("Unable to get IRQ from DT\n"));
/* Make IRQs happen for the system timer */
setup_irq(at91rm9200_timer_irq.irq, &at91rm9200_timer_irq);
@@ -239,7 +214,7 @@ static void __init atmel_st_timer_init(struct device_node *node)
* directly for the clocksource and all clockevents, after adjusting
* its prescaler from the 1 Hz default.
*/
- at91_st_write(AT91_ST_RTMR, 1);
+ regmap_write(regmap_st, AT91_ST_RTMR, 1);
/* Setup timer clockevent, with minimum of two ticks (important!!) */
clkevt.cpumask = cpumask_of(0);
--
2.1.0
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 8/9] clocksource: atmel-st: use syscon/regmap
2015-03-05 15:49 ` [PATCH v4 8/9] clocksource: atmel-st: use syscon/regmap Alexandre Belloni
@ 2015-03-06 8:43 ` Daniel Lezcano
2015-03-06 8:47 ` Alexandre Belloni
0 siblings, 1 reply; 21+ messages in thread
From: Daniel Lezcano @ 2015-03-06 8:43 UTC (permalink / raw)
To: Alexandre Belloni, Nicolas Ferre
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm
On 03/05/2015 04:49 PM, Alexandre Belloni wrote:
> The register range from the system timer is also used by the watchdog driver.
> Use a regmap to handle concurrent accesses.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> drivers/clocksource/timer-atmel-st.c | 99 ++++++++++++++----------------------
> 1 file changed, 37 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
> index 7d062ab32674..c4a52e32675e 100644
> --- a/drivers/clocksource/timer-atmel-st.c
> +++ b/drivers/clocksource/timer-atmel-st.c
> @@ -24,19 +24,19 @@
> #include <linux/irq.h>
> #include <linux/clockchips.h>
> #include <linux/export.h>
> -#include <linux/of.h>
> -#include <linux/of_address.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/mfd/syscon/atmel-st.h>
> #include <linux/of_irq.h>
> +#include <linux/regmap.h>
>
> #include <asm/mach/time.h>
>
> -#include <mach/at91_st.h>
> -#include <mach/hardware.h>
> -
> static unsigned long last_crtr;
> static u32 irqmask;
> static struct clock_event_device clkevt;
> +static struct regmap *regmap_st;
>
> +#define AT91_SLOW_CLOCK 32768
> #define RM9200_TIMER_LATCH ((AT91_SLOW_CLOCK + HZ/2) / HZ)
>
> /*
> @@ -46,11 +46,11 @@ static struct clock_event_device clkevt;
> */
> static inline unsigned long read_CRTR(void)
> {
> - unsigned long x1, x2;
> + unsigned int x1, x2;
>
> - x1 = at91_st_read(AT91_ST_CRTR);
> + regmap_read(regmap_st, AT91_ST_CRTR, &x1);
> do {
> - x2 = at91_st_read(AT91_ST_CRTR);
> + regmap_read(regmap_st, AT91_ST_CRTR, &x2);
> if (x1 == x2)
> break;
> x1 = x2;
> @@ -63,7 +63,10 @@ static inline unsigned long read_CRTR(void)
> */
> static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
> {
> - u32 sr = at91_st_read(AT91_ST_SR) & irqmask;
> + u32 sr;
> +
> + regmap_read(regmap_st, AT91_ST_SR, &sr);
> + sr &= irqmask;
>
> /*
> * irqs should be disabled here, but as the irq is shared they are only
> @@ -96,7 +99,7 @@ static struct irqaction at91rm9200_timer_irq = {
> .name = "at91_tick",
> .flags = IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
> .handler = at91rm9200_timer_interrupt,
> - .irq = NR_IRQS_LEGACY + AT91_ID_SYS,
> + .irq = 0,
Is this change related to regmap ?
By the way, perhaps take the opportunity to replace setup_irq by
request_irq (and check the return value) ?
> };
>
> static cycle_t read_clk32k(struct clocksource *cs)
> @@ -115,23 +118,25 @@ static struct clocksource clk32k = {
> static void
> clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
> {
> + unsigned int val;
> +
> /* Disable and flush pending timer interrupts */
> - at91_st_write(AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS);
> - at91_st_read(AT91_ST_SR);
> + regmap_write(regmap_st, AT91_ST_IDR, AT91_ST_PITS | AT91_ST_ALMS);
> + regmap_read(regmap_st, AT91_ST_SR, &val);
>
> last_crtr = read_CRTR();
> switch (mode) {
> case CLOCK_EVT_MODE_PERIODIC:
> /* PIT for periodic irqs; fixed rate of 1/HZ */
> irqmask = AT91_ST_PITS;
> - at91_st_write(AT91_ST_PIMR, RM9200_TIMER_LATCH);
> + regmap_write(regmap_st, AT91_ST_PIMR, RM9200_TIMER_LATCH);
> break;
> case CLOCK_EVT_MODE_ONESHOT:
> /* ALM for oneshot irqs, set by next_event()
> * before 32 seconds have passed
> */
> irqmask = AT91_ST_ALMS;
> - at91_st_write(AT91_ST_RTAR, last_crtr);
> + regmap_write(regmap_st, AT91_ST_RTAR, last_crtr);
> break;
> case CLOCK_EVT_MODE_SHUTDOWN:
> case CLOCK_EVT_MODE_UNUSED:
> @@ -139,7 +144,7 @@ clkevt32k_mode(enum clock_event_mode mode, struct clock_event_device *dev)
> irqmask = 0;
> break;
> }
> - at91_st_write(AT91_ST_IER, irqmask);
> + regmap_write(regmap_st, AT91_ST_IER, irqmask);
> }
>
> static int
> @@ -147,6 +152,7 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)
> {
> u32 alm;
> int status = 0;
> + unsigned int val;
>
> BUG_ON(delta < 2);
>
> @@ -162,12 +168,12 @@ clkevt32k_next_event(unsigned long delta, struct clock_event_device *dev)
> alm = read_CRTR();
>
> /* Cancel any pending alarm; flush any pending IRQ */
> - at91_st_write(AT91_ST_RTAR, alm);
> - at91_st_read(AT91_ST_SR);
> + regmap_write(regmap_st, AT91_ST_RTAR, alm);
> + regmap_read(regmap_st, AT91_ST_SR, &val);
>
> /* Schedule alarm by writing RTAR. */
> alm += delta;
> - at91_st_write(AT91_ST_RTAR, alm);
> + regmap_write(regmap_st, AT91_ST_RTAR, alm);
>
> return status;
> }
> @@ -180,57 +186,26 @@ static struct clock_event_device clkevt = {
> .set_mode = clkevt32k_mode,
> };
>
> -void __iomem *at91_st_base;
> -EXPORT_SYMBOL_GPL(at91_st_base);
> -
> -static const struct of_device_id at91rm9200_st_timer_ids[] = {
> - { .compatible = "atmel,at91rm9200-st" },
> - { /* sentinel */ }
> -};
> -
> -static int __init of_at91rm9200_st_init(void)
> -{
> - struct device_node *np;
> - int ret;
> -
> - np = of_find_matching_node(NULL, at91rm9200_st_timer_ids);
> - if (!np)
> - goto err;
> -
> - at91_st_base = of_iomap(np, 0);
> - if (!at91_st_base)
> - goto node_err;
> -
> - /* Get the interrupts property */
> - ret = irq_of_parse_and_map(np, 0);
> - if (!ret)
> - goto ioremap_err;
> - at91rm9200_timer_irq.irq = ret;
> -
> - of_node_put(np);
> -
> - return 0;
> -
> -ioremap_err:
> - iounmap(at91_st_base);
> -node_err:
> - of_node_put(np);
> -err:
> - return -EINVAL;
> -}
> -
> /*
> * ST (system timer) module supports both clockevents and clocksource.
> */
> static void __init atmel_st_timer_init(struct device_node *node)
> {
> - /* For device tree enabled device: initialize here */
> - of_at91rm9200_st_init();
> + unsigned int val;
> +
> + regmap_st = syscon_node_to_regmap(node);
> + if (IS_ERR(regmap_st))
> + panic(pr_fmt("Unable to get regmap\n"));
>
> /* Disable all timer interrupts, and clear any pending ones */
> - at91_st_write(AT91_ST_IDR,
> + regmap_write(regmap_st, AT91_ST_IDR,
> AT91_ST_PITS | AT91_ST_WDOVF | AT91_ST_RTTINC | AT91_ST_ALMS);
> - at91_st_read(AT91_ST_SR);
> + regmap_read(regmap_st, AT91_ST_SR, &val);
> +
> + /* Get the interrupts property */
> + at91rm9200_timer_irq.irq = irq_of_parse_and_map(node, 0);
> + if (!at91rm9200_timer_irq.irq)
> + panic(pr_fmt("Unable to get IRQ from DT\n"));
>
> /* Make IRQs happen for the system timer */
> setup_irq(at91rm9200_timer_irq.irq, &at91rm9200_timer_irq);
> @@ -239,7 +214,7 @@ static void __init atmel_st_timer_init(struct device_node *node)
> * directly for the clocksource and all clockevents, after adjusting
> * its prescaler from the 1 Hz default.
> */
> - at91_st_write(AT91_ST_RTMR, 1);
> + regmap_write(regmap_st, AT91_ST_RTMR, 1);
>
> /* Setup timer clockevent, with minimum of two ticks (important!!) */
> clkevt.cpumask = cpumask_of(0);
>
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 8/9] clocksource: atmel-st: use syscon/regmap
2015-03-06 8:43 ` Daniel Lezcano
@ 2015-03-06 8:47 ` Alexandre Belloni
2015-03-09 11:13 ` Daniel Lezcano
0 siblings, 1 reply; 21+ messages in thread
From: Alexandre Belloni @ 2015-03-06 8:47 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Nicolas Ferre, Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm
On 06/03/2015 at 09:43:02 +0100, Daniel Lezcano wrote :
> On 03/05/2015 04:49 PM, Alexandre Belloni wrote:
> >The register range from the system timer is also used by the watchdog driver.
> >Use a regmap to handle concurrent accesses.
> >
> >Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> >Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> >---
> > drivers/clocksource/timer-atmel-st.c | 99 ++++++++++++++----------------------
> > 1 file changed, 37 insertions(+), 62 deletions(-)
> >
> >diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
> >index 7d062ab32674..c4a52e32675e 100644
> >--- a/drivers/clocksource/timer-atmel-st.c
> >+++ b/drivers/clocksource/timer-atmel-st.c
> >@@ -24,19 +24,19 @@
> > #include <linux/irq.h>
> > #include <linux/clockchips.h>
> > #include <linux/export.h>
> >-#include <linux/of.h>
> >-#include <linux/of_address.h>
> >+#include <linux/mfd/syscon.h>
> >+#include <linux/mfd/syscon/atmel-st.h>
> > #include <linux/of_irq.h>
> >+#include <linux/regmap.h>
> >
> > #include <asm/mach/time.h>
> >
> >-#include <mach/at91_st.h>
> >-#include <mach/hardware.h>
> >-
> > static unsigned long last_crtr;
> > static u32 irqmask;
> > static struct clock_event_device clkevt;
> >+static struct regmap *regmap_st;
> >
> >+#define AT91_SLOW_CLOCK 32768
> > #define RM9200_TIMER_LATCH ((AT91_SLOW_CLOCK + HZ/2) / HZ)
> >
> > /*
> >@@ -46,11 +46,11 @@ static struct clock_event_device clkevt;
> > */
> > static inline unsigned long read_CRTR(void)
> > {
> >- unsigned long x1, x2;
> >+ unsigned int x1, x2;
> >
> >- x1 = at91_st_read(AT91_ST_CRTR);
> >+ regmap_read(regmap_st, AT91_ST_CRTR, &x1);
> > do {
> >- x2 = at91_st_read(AT91_ST_CRTR);
> >+ regmap_read(regmap_st, AT91_ST_CRTR, &x2);
> > if (x1 == x2)
> > break;
> > x1 = x2;
> >@@ -63,7 +63,10 @@ static inline unsigned long read_CRTR(void)
> > */
> > static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
> > {
> >- u32 sr = at91_st_read(AT91_ST_SR) & irqmask;
> >+ u32 sr;
> >+
> >+ regmap_read(regmap_st, AT91_ST_SR, &sr);
> >+ sr &= irqmask;
> >
> > /*
> > * irqs should be disabled here, but as the irq is shared they are only
> >@@ -96,7 +99,7 @@ static struct irqaction at91rm9200_timer_irq = {
> > .name = "at91_tick",
> > .flags = IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
> > .handler = at91rm9200_timer_interrupt,
> >- .irq = NR_IRQS_LEGACY + AT91_ID_SYS,
> >+ .irq = 0,
>
> Is this change related to regmap ?
>
It is related to the removing of hardware.h. I can do that in a separate
patch if you prefer.
> By the way, perhaps take the opportunity to replace setup_irq by request_irq
> (and check the return value) ?
>
I tried and it fails, I didn't investigate yet.
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH v4 8/9] clocksource: atmel-st: use syscon/regmap
2015-03-06 8:47 ` Alexandre Belloni
@ 2015-03-09 11:13 ` Daniel Lezcano
0 siblings, 0 replies; 21+ messages in thread
From: Daniel Lezcano @ 2015-03-09 11:13 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Nicolas Ferre, Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm
On 03/06/2015 09:47 AM, Alexandre Belloni wrote:
> On 06/03/2015 at 09:43:02 +0100, Daniel Lezcano wrote :
>> On 03/05/2015 04:49 PM, Alexandre Belloni wrote:
>>> The register range from the system timer is also used by the watchdog driver.
>>> Use a regmap to handle concurrent accesses.
>>>
>>> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
>>> Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
>>> ---
>>> drivers/clocksource/timer-atmel-st.c | 99 ++++++++++++++----------------------
>>> 1 file changed, 37 insertions(+), 62 deletions(-)
>>>
>>> diff --git a/drivers/clocksource/timer-atmel-st.c b/drivers/clocksource/timer-atmel-st.c
>>> index 7d062ab32674..c4a52e32675e 100644
>>> --- a/drivers/clocksource/timer-atmel-st.c
>>> +++ b/drivers/clocksource/timer-atmel-st.c
>>> @@ -24,19 +24,19 @@
>>> #include <linux/irq.h>
>>> #include <linux/clockchips.h>
>>> #include <linux/export.h>
>>> -#include <linux/of.h>
>>> -#include <linux/of_address.h>
>>> +#include <linux/mfd/syscon.h>
>>> +#include <linux/mfd/syscon/atmel-st.h>
>>> #include <linux/of_irq.h>
>>> +#include <linux/regmap.h>
>>>
>>> #include <asm/mach/time.h>
>>>
>>> -#include <mach/at91_st.h>
>>> -#include <mach/hardware.h>
>>> -
>>> static unsigned long last_crtr;
>>> static u32 irqmask;
>>> static struct clock_event_device clkevt;
>>> +static struct regmap *regmap_st;
>>>
>>> +#define AT91_SLOW_CLOCK 32768
>>> #define RM9200_TIMER_LATCH ((AT91_SLOW_CLOCK + HZ/2) / HZ)
>>>
>>> /*
>>> @@ -46,11 +46,11 @@ static struct clock_event_device clkevt;
>>> */
>>> static inline unsigned long read_CRTR(void)
>>> {
>>> - unsigned long x1, x2;
>>> + unsigned int x1, x2;
>>>
>>> - x1 = at91_st_read(AT91_ST_CRTR);
>>> + regmap_read(regmap_st, AT91_ST_CRTR, &x1);
>>> do {
>>> - x2 = at91_st_read(AT91_ST_CRTR);
>>> + regmap_read(regmap_st, AT91_ST_CRTR, &x2);
>>> if (x1 == x2)
>>> break;
>>> x1 = x2;
>>> @@ -63,7 +63,10 @@ static inline unsigned long read_CRTR(void)
>>> */
>>> static irqreturn_t at91rm9200_timer_interrupt(int irq, void *dev_id)
>>> {
>>> - u32 sr = at91_st_read(AT91_ST_SR) & irqmask;
>>> + u32 sr;
>>> +
>>> + regmap_read(regmap_st, AT91_ST_SR, &sr);
>>> + sr &= irqmask;
>>>
>>> /*
>>> * irqs should be disabled here, but as the irq is shared they are only
>>> @@ -96,7 +99,7 @@ static struct irqaction at91rm9200_timer_irq = {
>>> .name = "at91_tick",
>>> .flags = IRQF_SHARED | IRQF_TIMER | IRQF_IRQPOLL,
>>> .handler = at91rm9200_timer_interrupt,
>>> - .irq = NR_IRQS_LEGACY + AT91_ID_SYS,
>>> + .irq = 0,
>>
>> Is this change related to regmap ?
>>
>
> It is related to the removing of hardware.h. I can do that in a separate
> patch if you prefer.
Yeah, because it is not obvious to see a connection between the removal
of hardware.h and the syscon/regmap changes.
I would suggest you create a patch to replace setup_irq with
register_irq so that will remove this structure and the irq
initialization to zero.
>> By the way, perhaps take the opportunity to replace setup_irq by request_irq
>> (and check the return value) ?
>>
>
> I tried and it fails, I didn't investigate yet.
It shouldn't be a big deal, register_irq is more or less a wrapper to
setup_irq.
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH v4 9/9] ARM: at91: remove useless include
2015-03-05 15:49 [PATCH v4 0/9] Atmel System Timer cleanups Alexandre Belloni
` (7 preceding siblings ...)
2015-03-05 15:49 ` [PATCH v4 8/9] clocksource: atmel-st: use syscon/regmap Alexandre Belloni
@ 2015-03-05 15:49 ` Alexandre Belloni
8 siblings, 0 replies; 21+ messages in thread
From: Alexandre Belloni @ 2015-03-05 15:49 UTC (permalink / raw)
To: Nicolas Ferre, Daniel Lezcano
Cc: Boris Brezillon, Jean-Christophe Plagniol-Villard,
Thomas Gleixner, Lee Jones, Wim Van Sebroeck, Guenter Roeck,
Sebastian Reichel, Dmitry Eremin-Solenikov, linux-kernel,
linux-arm-kernel, linux-watchdog, linux-pm, Alexandre Belloni
Both drivers using the system timer are now converted to an MFD. mach/at91_st.h
is now useless.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
---
arch/arm/mach-at91/include/mach/at91_st.h | 61 -------------------------------
1 file changed, 61 deletions(-)
delete mode 100644 arch/arm/mach-at91/include/mach/at91_st.h
diff --git a/arch/arm/mach-at91/include/mach/at91_st.h b/arch/arm/mach-at91/include/mach/at91_st.h
deleted file mode 100644
index 67fdbd13c3ed..000000000000
--- a/arch/arm/mach-at91/include/mach/at91_st.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * arch/arm/mach-at91/include/mach/at91_st.h
- *
- * Copyright (C) 2005 Ivan Kokshaysky
- * Copyright (C) SAN People
- *
- * System Timer (ST) - System peripherals registers.
- * Based on AT91RM9200 datasheet revision E.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef AT91_ST_H
-#define AT91_ST_H
-
-#ifndef __ASSEMBLY__
-extern void __iomem *at91_st_base;
-
-#define at91_st_read(field) \
- __raw_readl(at91_st_base + field)
-
-#define at91_st_write(field, value) \
- __raw_writel(value, at91_st_base + field)
-#else
-.extern at91_st_base
-#endif
-
-#define AT91_ST_CR 0x00 /* Control Register */
-#define AT91_ST_WDRST (1 << 0) /* Watchdog Timer Restart */
-
-#define AT91_ST_PIMR 0x04 /* Period Interval Mode Register */
-#define AT91_ST_PIV (0xffff << 0) /* Period Interval Value */
-
-#define AT91_ST_WDMR 0x08 /* Watchdog Mode Register */
-#define AT91_ST_WDV (0xffff << 0) /* Watchdog Counter Value */
-#define AT91_ST_RSTEN (1 << 16) /* Reset Enable */
-#define AT91_ST_EXTEN (1 << 17) /* External Signal Assertion Enable */
-
-#define AT91_ST_RTMR 0x0c /* Real-time Mode Register */
-#define AT91_ST_RTPRES (0xffff << 0) /* Real-time Prescalar Value */
-
-#define AT91_ST_SR 0x10 /* Status Register */
-#define AT91_ST_PITS (1 << 0) /* Period Interval Timer Status */
-#define AT91_ST_WDOVF (1 << 1) /* Watchdog Overflow */
-#define AT91_ST_RTTINC (1 << 2) /* Real-time Timer Increment */
-#define AT91_ST_ALMS (1 << 3) /* Alarm Status */
-
-#define AT91_ST_IER 0x14 /* Interrupt Enable Register */
-#define AT91_ST_IDR 0x18 /* Interrupt Disable Register */
-#define AT91_ST_IMR 0x1c /* Interrupt Mask Register */
-
-#define AT91_ST_RTAR 0x20 /* Real-time Alarm Register */
-#define AT91_ST_ALMV (0xfffff << 0) /* Alarm Value */
-
-#define AT91_ST_CRTR 0x24 /* Current Real-time Register */
-#define AT91_ST_CRTV (0xfffff << 0) /* Current Real-Time Value */
-
-#endif
--
2.1.0
^ permalink raw reply [flat|nested] 21+ messages in thread