All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yao Zi <me@ziyao.cc>
To: hehongbo918@gmail.com, u-boot@lists.denx.de
Cc: Tom Rini <trini@konsulko.com>, Yao Zi <me@ziyao.cc>
Subject: Re: [PATCH] sysreset: esp32: add driver for esp32 series chips
Date: Fri, 24 Jul 2026 02:52:39 +0000	[thread overview]
Message-ID: <amLTd8Mau6tsV7o4@pie> (raw)
In-Reply-To: <20260712074817.18856-1-hehongbo918@gmail.com>

On Sun, Jul 12, 2026 at 03:48:16PM +0800, hehongbo918@gmail.com wrote:
> From: Honbo He <hehongbo918@gmail.com>
> 
> Add system reset driver for Espressif Gen3 and Gen4 RISC-V SoCs.
> The reset register base address, offset, and bit mask are read
> from the device tree to support different chip variants without
> code changes.
> 
> Signed-off-by: Honbo He <hehongbo918@gmail.com>
> ---
>  drivers/sysreset/Kconfig          |  9 ++++
>  drivers/sysreset/Makefile         |  1 +
>  drivers/sysreset/sysreset_esp32.c | 72 +++++++++++++++++++++++++++++++
>  3 files changed, 82 insertions(+)
>  create mode 100644 drivers/sysreset/sysreset_esp32.c

...

> diff --git a/drivers/sysreset/sysreset_esp32.c b/drivers/sysreset/sysreset_esp32.c
> new file mode 100644
> index 00000000000..3d4c619f44f
> --- /dev/null
> +++ b/drivers/sysreset/sysreset_esp32.c
> @@ -0,0 +1,72 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2026, Honbo He <hehongbo918@gmail.com>
> + *
> + * System reset driver for Espressif SoCs.
> + *
> + * Supported SoCs (Gen3/4):
> + *  ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2, ESP32-H21, ESP32-H4,
> + *  ESP32-P4, ESP32-S31
> + *
> + * On the unsupported chips(Gen1/2), the system reset logic resides inside the
> + * RTC_CNTL peripheral and is only accessible through the boot ROM function
> + * software_reset_cpu(). The register definitions are not exposed in the SoC headers,
> + * making it impractical to implement a direct register-based reset
> + * in U-Boot without reverse-engineering the ROM code.
> + */
> +
> +#include <dm.h>
> +#include <stdbool.h>

But you make no use of bool, so I guess this could be ommitted

> +#include <sysreset.h>
> +#include <wait_bit.h>

Not used, either.

> +#include <linux/io.h>
> +#include <linux/errno.h>

Could you please sort the headers, too?

> +
> +struct esp32_sysreset_priv {
> +	void __iomem *base;
> +	u32 offset;
> +	u32 mask;
> +};
> +
> +static int esp32_sysreset_request(struct udevice *dev, enum sysreset_t type)
> +{
> +	struct esp32_sysreset_priv *priv = dev_get_priv(dev);
> +
> +	setbits_le32(priv->base + priv->offset, priv->mask);

And this looks quite compatible with the generic syscon-reboot binding.
Why not re-use this driver instead?

> +
> +	return -EINPROGRESS;
> +}
> +
> +static struct sysreset_ops esp32_sysreset = {
> +	.request = esp32_sysreset_request,
> +};
> +
> +static int esp32_sysreset_probe(struct udevice *dev)
> +{
> +	struct esp32_sysreset_priv *priv = dev_get_priv(dev);
> +
> +	priv->base = dev_read_addr_ptr(dev);
> +	if (!priv->base)
> +		return -EINVAL;
> +
> +	priv->offset = dev_read_u32_default(dev, "offset", 0);
> +	priv->mask = dev_read_u32_default(dev, "mask", 0);
> +	if (priv->mask == 0)
> +		return -EINVAL;
> +
> +	return 0;
> +}
> +
> +static const struct udevice_id esp32s31_sysreset_ids[] = {
> +	{ .compatible = "esp,esp32-sysreset", },

Is the compatible documented anywhere so we could have a stable dt ABI
as reference? I searched current Linux master but got no luck.

Best regards,
Yao Zi

      reply	other threads:[~2026-07-24  2:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12  7:48 [PATCH] sysreset: esp32: add driver for esp32 series chips hehongbo918
2026-07-24  2:52 ` Yao Zi [this message]

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=amLTd8Mau6tsV7o4@pie \
    --to=me@ziyao.cc \
    --cc=hehongbo918@gmail.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /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.