From: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
To: Ezequiel Garcia
<ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Wim Van Sebroeck <wim-IQzOog9fTRqzQB+pC5nmwQ@public.gmane.org>,
Jason Gunthorpe
<jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>,
Sebastian Hesselbarth
<sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
Daniel Lezcano
<daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Fabio Estevam <festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Andrew Lunn <andrew-g2DYL2Zd6BY@public.gmane.org>,
Thomas Petazzoni
<thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
Gregory Clement
<gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>,
Tawfik Bayouk <tawfik-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
Lior Amsalem <alior-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org>,
Jason Cooper <jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org>
Subject: Re: [PATCH v4 08/18] watchdog: orion: Make RSTOUT register a separate resource
Date: Sat, 25 Jan 2014 10:19:42 -0800 [thread overview]
Message-ID: <52E4003E.4070106@roeck-us.net> (raw)
In-Reply-To: <1390431915-5115-9-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
On 01/22/2014 03:05 PM, Ezequiel Garcia wrote:
> In order to support other SoC, it's required to distinguish
> the 'control' timer register, from the 'rstout' register
> that enables system reset on watchdog expiration.
>
> To prevent a compatibility break, this commit adds a fallback
> to a hardcoded RSTOUT address.
>
> Signed-off-by: Ezequiel Garcia <ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> ---
> .../devicetree/bindings/watchdog/marvel.txt | 6 ++-
> arch/arm/mach-dove/include/mach/bridge-regs.h | 1 +
> arch/arm/mach-kirkwood/include/mach/bridge-regs.h | 1 +
> arch/arm/mach-mv78xx0/include/mach/bridge-regs.h | 1 +
> arch/arm/mach-orion5x/include/mach/bridge-regs.h | 1 +
> arch/arm/plat-orion/common.c | 10 +++--
> drivers/watchdog/orion_wdt.c | 44 +++++++++++++++++++++-
> 7 files changed, 56 insertions(+), 8 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/watchdog/marvel.txt b/Documentation/devicetree/bindings/watchdog/marvel.txt
> index 0731fbd..1544fe9 100644
> --- a/Documentation/devicetree/bindings/watchdog/marvel.txt
> +++ b/Documentation/devicetree/bindings/watchdog/marvel.txt
> @@ -3,7 +3,9 @@
> Required Properties:
>
> - Compatibility : "marvell,orion-wdt"
> -- reg : Address of the timer registers
> +- reg : Should contain two entries: first one with the
> + timer control address, second one with the
> + rstout enable address.
>
> Optional properties:
>
> @@ -14,7 +16,7 @@ Example:
>
> wdt@20300 {
> compatible = "marvell,orion-wdt";
> - reg = <0x20300 0x28>;
> + reg = <0x20300 0x28>, <0x20108 0x4>;
> interrupts = <3>;
> timeout-sec = <10>;
> status = "okay";
> diff --git a/arch/arm/mach-dove/include/mach/bridge-regs.h b/arch/arm/mach-dove/include/mach/bridge-regs.h
> index 5362df3..f4a5b34 100644
> --- a/arch/arm/mach-dove/include/mach/bridge-regs.h
> +++ b/arch/arm/mach-dove/include/mach/bridge-regs.h
> @@ -21,6 +21,7 @@
> #define CPU_CTRL_PCIE1_LINK 0x00000008
>
> #define RSTOUTn_MASK (BRIDGE_VIRT_BASE + 0x0108)
> +#define RSTOUTn_MASK_PHYS (BRIDGE_PHYS_BASE + 0x0108)
> #define SOFT_RESET_OUT_EN 0x00000004
>
> #define SYSTEM_SOFT_RESET (BRIDGE_VIRT_BASE + 0x010c)
> diff --git a/arch/arm/mach-kirkwood/include/mach/bridge-regs.h b/arch/arm/mach-kirkwood/include/mach/bridge-regs.h
> index 8b9d1c9..60f6421 100644
> --- a/arch/arm/mach-kirkwood/include/mach/bridge-regs.h
> +++ b/arch/arm/mach-kirkwood/include/mach/bridge-regs.h
> @@ -21,6 +21,7 @@
> #define CPU_RESET 0x00000002
>
> #define RSTOUTn_MASK (BRIDGE_VIRT_BASE + 0x0108)
> +#define RSTOUTn_MASK_PHYS (BRIDGE_PHYS_BASE + 0x0108)
> #define SOFT_RESET_OUT_EN 0x00000004
>
> #define SYSTEM_SOFT_RESET (BRIDGE_VIRT_BASE + 0x010c)
> diff --git a/arch/arm/mach-mv78xx0/include/mach/bridge-regs.h b/arch/arm/mach-mv78xx0/include/mach/bridge-regs.h
> index 5f03484..e20d6da 100644
> --- a/arch/arm/mach-mv78xx0/include/mach/bridge-regs.h
> +++ b/arch/arm/mach-mv78xx0/include/mach/bridge-regs.h
> @@ -15,6 +15,7 @@
> #define L2_WRITETHROUGH 0x00020000
>
> #define RSTOUTn_MASK (BRIDGE_VIRT_BASE + 0x0108)
> +#define RSTOUTn_MASK_PHYS (BRIDGE_PHYS_BASE + 0x0108)
> #define SOFT_RESET_OUT_EN 0x00000004
>
> #define SYSTEM_SOFT_RESET (BRIDGE_VIRT_BASE + 0x010c)
> diff --git a/arch/arm/mach-orion5x/include/mach/bridge-regs.h b/arch/arm/mach-orion5x/include/mach/bridge-regs.h
> index f727d03..5766e3f 100644
> --- a/arch/arm/mach-orion5x/include/mach/bridge-regs.h
> +++ b/arch/arm/mach-orion5x/include/mach/bridge-regs.h
> @@ -18,6 +18,7 @@
> #define CPU_CTRL (ORION5X_BRIDGE_VIRT_BASE + 0x104)
>
> #define RSTOUTn_MASK (ORION5X_BRIDGE_VIRT_BASE + 0x108)
> +#define RSTOUTn_MASK_PHYS (ORION5X_BRIDGE_PHYS_BASE + 0x108)
>
> #define CPU_SOFT_RESET (ORION5X_BRIDGE_VIRT_BASE + 0x10c)
>
> diff --git a/arch/arm/plat-orion/common.c b/arch/arm/plat-orion/common.c
> index c66d163..3375037 100644
> --- a/arch/arm/plat-orion/common.c
> +++ b/arch/arm/plat-orion/common.c
> @@ -594,14 +594,16 @@ void __init orion_spi_1_init(unsigned long mapbase)
> /*****************************************************************************
> * Watchdog
> ****************************************************************************/
> -static struct resource orion_wdt_resource =
> - DEFINE_RES_MEM(TIMER_PHYS_BASE, 0x28);
> +static struct resource orion_wdt_resource[] = {
> + DEFINE_RES_MEM(TIMER_PHYS_BASE, 0x04),
> + DEFINE_RES_MEM(RSTOUTn_MASK_PHYS, 0x04),
> +};
>
> static struct platform_device orion_wdt_device = {
> .name = "orion_wdt",
> .id = -1,
> - .num_resources = 1,
> - .resource = &orion_wdt_resource,
> + .num_resources = ARRAY_SIZE(orion_wdt_resource),
> + .resource = orion_wdt_resource,
> };
>
> void __init orion_wdt_init(void)
> diff --git a/drivers/watchdog/orion_wdt.c b/drivers/watchdog/orion_wdt.c
> index f5e7b17..ba8eea9d 100644
> --- a/drivers/watchdog/orion_wdt.c
> +++ b/drivers/watchdog/orion_wdt.c
> @@ -26,6 +26,12 @@
> #include <linux/of.h>
> #include <mach/bridge-regs.h>
>
> +/* RSTOUT mask register physical address for Orion5x, Kirkwood and Dove */
> +#define ORION_RSTOUT_MASK_OFFSET 0x20108
> +
> +/* Internal registers can be configured at any 1 MiB aligned address */
> +#define INTERNAL_REGS_MASK ~(SZ_1M - 1)
> +
> /*
> * Watchdog timer block registers.
> */
> @@ -44,6 +50,7 @@ static unsigned int wdt_max_duration; /* (seconds) */
> static struct clk *clk;
> static unsigned int wdt_tclk;
> static void __iomem *wdt_reg;
> +static void __iomem *wdt_rstout;
>
> static int orion_wdt_ping(struct watchdog_device *wdt_dev)
> {
> @@ -64,14 +71,14 @@ static int orion_wdt_start(struct watchdog_device *wdt_dev)
> atomic_io_modify(wdt_reg + TIMER_CTRL, WDT_EN, WDT_EN);
>
> /* Enable reset on watchdog */
> - atomic_io_modify(RSTOUTn_MASK, WDT_RESET_OUT_EN, WDT_RESET_OUT_EN);
> + atomic_io_modify(wdt_rstout, WDT_RESET_OUT_EN, WDT_RESET_OUT_EN);
> return 0;
> }
>
> static int orion_wdt_stop(struct watchdog_device *wdt_dev)
> {
> /* Disable reset on watchdog */
> - atomic_io_modify(RSTOUTn_MASK, WDT_RESET_OUT_EN, 0);
> + atomic_io_modify(wdt_rstout, WDT_RESET_OUT_EN, 0);
>
> /* Disable watchdog timer */
> atomic_io_modify(wdt_reg + TIMER_CTRL, WDT_EN, 0);
> @@ -116,6 +123,33 @@ static irqreturn_t orion_wdt_irq(int irq, void *devid)
> return IRQ_HANDLED;
> }
>
> +/*
> + * The original devicetree binding for this driver specified only
> + * one memory resource, so in order to keep DT backwards compatibility
> + * we try to fallback to a hardcoded register address, if the resource
> + * is missing from the devicetree.
> + */
> +static void __iomem *try_rstout_ioremap(struct platform_device *pdev,
> + phys_addr_t internal_regs)
> +{
> + struct resource *res;
> + phys_addr_t rstout;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + if (res)
> + return devm_ioremap(&pdev->dev, res->start,
> + resource_size(res));
> +
> + /* This workaround works only for "orion-wdt", DT-enabled */
> + if (!of_device_is_compatible(pdev->dev.of_node, "marvell,orion-wdt"))
> + return NULL;
> +
> + rstout = internal_regs + ORION_RSTOUT_MASK_OFFSET;
> +
> + WARN(1, FW_BUG "falling back to harcoded RSTOUT reg 0x%x\n", rstout);
WARN seems to be a bit excessive here. Is that on purpose (sorry if that was discussed and I missed it) ?
Assuming it is on purpose
Reviewed-by: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-01-25 18:19 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-22 23:04 [PATCH v4 00/18] Armada 370/XP watchdog support Ezequiel Garcia
[not found] ` <1390431915-5115-1-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-22 23:04 ` [PATCH v4 01/18] ARM: Introduce atomic MMIO modify Ezequiel Garcia
[not found] ` <1390431915-5115-2-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 20:32 ` Jason Cooper
2014-01-22 23:04 ` [PATCH v4 02/18] clocksource: orion: Use atomic access for shared registers Ezequiel Garcia
2014-01-22 23:05 ` [PATCH v4 03/18] watchdog: orion: Add clock error handling Ezequiel Garcia
[not found] ` <1390431915-5115-4-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 18:12 ` Guenter Roeck
2014-01-22 23:05 ` [PATCH v4 04/18] watchdog: orion: Use atomic access for shared registers Ezequiel Garcia
[not found] ` <1390431915-5115-5-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 18:12 ` Guenter Roeck
2014-01-22 23:05 ` [PATCH v4 05/18] watchdog: orion: Remove unused macros Ezequiel Garcia
[not found] ` <1390431915-5115-6-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 18:13 ` Guenter Roeck
2014-01-22 23:05 ` [PATCH v4 06/18] watchdog: orion: Make sure the watchdog is initially stopped Ezequiel Garcia
[not found] ` <1390431915-5115-7-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 18:13 ` Guenter Roeck
2014-01-22 23:05 ` [PATCH v4 07/18] watchdog: orion: Handle IRQ Ezequiel Garcia
[not found] ` <1390431915-5115-8-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 18:15 ` Guenter Roeck
2014-01-26 8:04 ` Thomas Petazzoni
2014-01-26 13:14 ` Ezequiel Garcia
2014-01-26 14:57 ` Thomas Petazzoni
2014-01-22 23:05 ` [PATCH v4 08/18] watchdog: orion: Make RSTOUT register a separate resource Ezequiel Garcia
[not found] ` <1390431915-5115-9-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 18:19 ` Guenter Roeck [this message]
[not found] ` <52E4003E.4070106-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>
2014-01-26 13:20 ` Ezequiel Garcia
2014-01-26 8:17 ` Thomas Petazzoni
2014-01-26 13:18 ` Ezequiel Garcia
2014-01-22 23:05 ` [PATCH v4 09/18] watchdog: orion: Remove unneeded BRIDGE_CAUSE clear Ezequiel Garcia
[not found] ` <1390431915-5115-10-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 18:20 ` Guenter Roeck
2014-01-22 23:05 ` [PATCH v4 10/18] watchdog: orion: Introduce an orion_watchdog device structure Ezequiel Garcia
[not found] ` <1390431915-5115-11-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 18:21 ` Guenter Roeck
2014-01-22 23:05 ` [PATCH v4 11/18] watchdog: orion: Introduce per-compatible of_device_id data Ezequiel Garcia
[not found] ` <1390431915-5115-12-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 18:23 ` Guenter Roeck
2014-01-22 23:05 ` [PATCH v4 12/18] watchdog: orion: Add per-compatible clock initialization Ezequiel Garcia
[not found] ` <1390431915-5115-13-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 18:24 ` Guenter Roeck
2014-01-22 23:05 ` [PATCH v4 13/18] watchdog: orion: Add per-compatible watchdog start implementation Ezequiel Garcia
[not found] ` <1390431915-5115-14-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 18:24 ` Guenter Roeck
2014-01-22 23:05 ` [PATCH v4 14/18] watchdog: orion: Add support for Armada 370 and Armada XP SoC Ezequiel Garcia
[not found] ` <1390431915-5115-15-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-25 18:25 ` Guenter Roeck
2014-01-22 23:05 ` [PATCH v4 15/18] ARM: mvebu: Enable Armada 370/XP watchdog in the devicetree Ezequiel Garcia
2014-01-22 23:05 ` [PATCH v4 16/18] ARM: kirkwood: Add RSTOUT 'reg' entry to devicetree Ezequiel Garcia
2014-01-22 23:05 ` [PATCH v4 17/18] watchdog: orion: Enable the build on ARCH_MVEBU Ezequiel Garcia
2014-01-22 23:05 ` [PATCH v4 18/18] ARM: mvebu: Enable watchdog support in defconfig Ezequiel Garcia
2014-01-23 22:40 ` [PATCH v4 00/18] Armada 370/XP watchdog support Sebastian Hesselbarth
[not found] ` <52E19A44.7040308-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-25 17:09 ` Ezequiel Garcia
2014-01-27 14:49 ` Ezequiel Garcia
2014-01-25 16:57 ` Ezequiel Garcia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=52E4003E.4070106@roeck-us.net \
--to=linux-0h96xk9xttrk1umjsbkqmq@public.gmane.org \
--cc=alior-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
--cc=andrew-g2DYL2Zd6BY@public.gmane.org \
--cc=arnd-r2nGTMty4D4@public.gmane.org \
--cc=daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=festevam-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=gregory.clement-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=jason-NLaQJdtUoK4Be96aLqz0jA@public.gmane.org \
--cc=jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-watchdog-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=sebastian.hesselbarth-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=tawfik-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org \
--cc=thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=wim-IQzOog9fTRqzQB+pC5nmwQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).