From: Corey Minyard <cminyard@mvista.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: xen-devel@lists.xenproject.org, roman@zededa.com, julien@xen.org,
Stefano Stabellini <stefano.stabellini@xilinx.com>,
tamas@tklengyel.com
Subject: Re: [PATCH] xen/rpi4: implement watchdog-based reset
Date: Wed, 3 Jun 2020 19:15:52 -0500 [thread overview]
Message-ID: <20200604001552.GC2903@minyard.net> (raw)
In-Reply-To: <20200603223156.12767-1-sstabellini@kernel.org>
On Wed, Jun 03, 2020 at 03:31:56PM -0700, Stefano Stabellini wrote:
> Touching the watchdog is required to be able to reboot the board.
>
> The implementation is based on
> drivers/watchdog/bcm2835_wdt.c:__bcm2835_restart in Linux.
Ah, I was looking at this just today, as it had been annoying me
greatly. This works for me, so:
Tested-by: Corey Minyard <cminyard@mvista.com>
However, I was wondering if it might be better to handle this by failing
the operation in xen and passing it back to dom0 to do. On the Pi you
send a firmware message to reboot, and that seems like too much to do in
Xen, but it would seem possible to send this back to dom0. Just a
thought, as it might be a more general fix for other devices in the same
situation.
Thanks,
-corey
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
> ---
> xen/arch/arm/platforms/brcm-raspberry-pi.c | 60 ++++++++++++++++++++++
> 1 file changed, 60 insertions(+)
>
> diff --git a/xen/arch/arm/platforms/brcm-raspberry-pi.c b/xen/arch/arm/platforms/brcm-raspberry-pi.c
> index f5ae58a7d5..0214ae2b3c 100644
> --- a/xen/arch/arm/platforms/brcm-raspberry-pi.c
> +++ b/xen/arch/arm/platforms/brcm-raspberry-pi.c
> @@ -18,6 +18,10 @@
> */
>
> #include <asm/platform.h>
> +#include <xen/delay.h>
> +#include <xen/mm.h>
> +#include <xen/vmap.h>
> +#include <asm/io.h>
>
> static const char *const rpi4_dt_compat[] __initconst =
> {
> @@ -37,12 +41,68 @@ static const struct dt_device_match rpi4_blacklist_dev[] __initconst =
> * The aux peripheral also shares a page with the aux UART.
> */
> DT_MATCH_COMPATIBLE("brcm,bcm2835-aux"),
> + /* Special device used for rebooting */
> + DT_MATCH_COMPATIBLE("brcm,bcm2835-pm"),
> { /* sentinel */ },
> };
>
> +
> +#define PM_PASSWORD 0x5a000000
> +#define PM_RSTC 0x1c
> +#define PM_WDOG 0x24
> +#define PM_RSTC_WRCFG_FULL_RESET 0x00000020
> +#define PM_RSTC_WRCFG_CLR 0xffffffcf
> +
> +static void __iomem *rpi4_map_watchdog(void)
> +{
> + void __iomem *base;
> + struct dt_device_node *node;
> + paddr_t start, len;
> + int ret;
> +
> + node = dt_find_compatible_node(NULL, NULL, "brcm,bcm2835-pm");
> + if ( !node )
> + return NULL;
> +
> + ret = dt_device_get_address(node, 0, &start, &len);
> + if ( ret )
> + {
> + dprintk(XENLOG_ERR, "Cannot read watchdog register address\n");
> + return NULL;
> + }
> +
> + base = ioremap_nocache(start & PAGE_MASK, PAGE_SIZE);
> + if ( !base )
> + {
> + dprintk(XENLOG_ERR, "Unable to map watchdog register!\n");
> + return NULL;
> + }
> +
> + return base;
> +}
> +
> +static void rpi4_reset(void)
> +{
> + u32 val;
> + void __iomem *base = rpi4_map_watchdog();
> + if ( !base )
> + return;
> +
> + /* use a timeout of 10 ticks (~150us) */
> + writel(10 | PM_PASSWORD, base + PM_WDOG);
> + val = readl(base + PM_RSTC);
> + val &= PM_RSTC_WRCFG_CLR;
> + val |= PM_PASSWORD | PM_RSTC_WRCFG_FULL_RESET;
> + writel(val, base + PM_RSTC);
> +
> + /* No sleeping, possibly atomic. */
> + mdelay(1);
> +}
> +
> PLATFORM_START(rpi4, "Raspberry Pi 4")
> .compatible = rpi4_dt_compat,
> .blacklist_dev = rpi4_blacklist_dev,
> + .reset = rpi4_reset,
> .dma_bitsize = 30,
> PLATFORM_END
>
> --
> 2.17.1
>
next prev parent reply other threads:[~2020-06-04 0:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-03 22:31 [PATCH] xen/rpi4: implement watchdog-based reset Stefano Stabellini
2020-06-03 23:21 ` Roman Shaposhnik
2020-06-04 0:09 ` Tamas K Lengyel
2020-06-04 0:15 ` Corey Minyard [this message]
2020-06-04 8:15 ` Julien Grall
2020-06-04 11:59 ` Corey Minyard
2020-06-04 12:07 ` Julien Grall
2020-06-04 8:48 ` Julien Grall
2020-06-04 8:59 ` André Przywara
2020-06-04 16:24 ` Stefano Stabellini
2020-06-04 16:36 ` Julien Grall
2020-06-04 16:48 ` Roman Shaposhnik
2020-06-04 16:54 ` Stefano Stabellini
2020-06-04 16:53 ` Stefano Stabellini
2020-06-04 16:37 ` André Przywara
2020-06-04 16:46 ` Stefano Stabellini
2020-06-04 17:12 ` André Przywara
2020-06-04 17:19 ` Julien Grall
2020-06-06 1:57 ` Stefano Stabellini
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=20200604001552.GC2903@minyard.net \
--to=cminyard@mvista.com \
--cc=julien@xen.org \
--cc=roman@zededa.com \
--cc=sstabellini@kernel.org \
--cc=stefano.stabellini@xilinx.com \
--cc=tamas@tklengyel.com \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.