From: Yao Zi <ziyao@disroot.org>
To: Icenowy Zheng <uwu@icenowy.me>, Drew Fustini <fustini@kernel.org>,
Guo Ren <guoren@kernel.org>, Fu Wei <wefu@redhat.com>,
Michal Wilczynski <m.wilczynski@samsung.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
Sebastian Reichel <sre@kernel.org>
Cc: Han Gao <rabenda.cn@gmail.com>,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
linux-pm@vger.kernel.org
Subject: Re: [PATCH 1/2] driver: reset: th1520-aon: add driver for poweroff/reboot via AON FW
Date: Mon, 18 Aug 2025 09:43:13 +0000 [thread overview]
Message-ID: <aKL1sTutiMZPAd70@pie> (raw)
In-Reply-To: <20250818074906.2907277-2-uwu@icenowy.me>
On Mon, Aug 18, 2025 at 03:49:05PM +0800, Icenowy Zheng wrote:
> This driver implements poweroff/reboot support for T-Head TH1520 SoCs
> running the AON firmware by sending a message to the AON firmware's WDG
> part.
>
> This is a auxiliary device driver, and expects the AON channel to be
> passed via the platform_data of the auxiliary device.
>
> Signed-off-by: Icenowy Zheng <uwu@icenowy.me>
> ---
> MAINTAINERS | 1 +
> drivers/power/reset/Kconfig | 7 ++
> drivers/power/reset/Makefile | 1 +
> drivers/power/reset/th1520-aon-reboot.c | 98 +++++++++++++++++++++++++
> 4 files changed, 107 insertions(+)
> create mode 100644 drivers/power/reset/th1520-aon-reboot.c
...
> diff --git a/drivers/power/reset/th1520-aon-reboot.c b/drivers/power/reset/th1520-aon-reboot.c
> new file mode 100644
> index 0000000000000..8256c1703ebe8
> --- /dev/null
> +++ b/drivers/power/reset/th1520-aon-reboot.c
> @@ -0,0 +1,98 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * T-HEAD TH1520 AON Firmware Reboot Driver
> + *
> + * Copyright (c) 2025 Icenowy Zheng <uwu@icenowy.me>
> + */
> +
> +#include <linux/auxiliary_bus.h>
> +#include <linux/firmware/thead/thead,th1520-aon.h>
> +#include <linux/module.h>
> +#include <linux/notifier.h>
> +#include <linux/of.h>
> +#include <linux/reboot.h>
> +#include <linux/slab.h>
> +
> +#define TH1520_AON_REBOOT_PRIORITY 200
> +
> +struct th1520_aon_msg_empty_body {
> + struct th1520_aon_rpc_msg_hdr hdr;
> + u16 reserved[12];
> +} __packed __aligned(1);
> +
> +static int th1520_aon_pwroff_handler(struct sys_off_data *data)
> +{
> + struct th1520_aon_chan *aon_chan = data->cb_data;
> + struct th1520_aon_msg_empty_body msg = {};
> +
> + msg.hdr.svc = TH1520_AON_RPC_SVC_WDG;
> + msg.hdr.func = TH1520_AON_WDG_FUNC_POWER_OFF;
> + msg.hdr.size = TH1520_AON_RPC_MSG_NUM;
> +
> + th1520_aon_call_rpc(aon_chan, &msg);
It's possible for th1520_aon_call_rpc() to fail. Should we check for its
return value and emit a warning/error if it fails? Though in case of
failure there may not be much we could do...
> + return NOTIFY_DONE;
> +}
Best regards,
Yao Zi
next prev parent reply other threads:[~2025-08-18 9:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-18 7:49 [PATCH 0/2] Poweroff/reboot support for TH1520 via AON Icenowy Zheng
2025-08-18 7:49 ` [PATCH 1/2] driver: reset: th1520-aon: add driver for poweroff/reboot via AON FW Icenowy Zheng
2025-08-18 9:43 ` Yao Zi [this message]
2025-09-16 18:22 ` Sebastian Reichel
2025-09-16 19:28 ` Drew Fustini
2025-09-17 22:18 ` Sebastian Reichel
2025-09-18 15:37 ` Ulf Hansson
2025-08-18 7:49 ` [PATCH 2/2] pmdomain: thead: create auxiliary device for rebooting Icenowy Zheng
2025-08-18 9:55 ` Troy Mitchell
2025-09-04 10:14 ` Ulf Hansson
2025-09-18 15:44 ` Icenowy Zheng
2025-09-18 15:55 ` Ulf Hansson
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=aKL1sTutiMZPAd70@pie \
--to=ziyao@disroot.org \
--cc=fustini@kernel.org \
--cc=guoren@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=m.wilczynski@samsung.com \
--cc=rabenda.cn@gmail.com \
--cc=sre@kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=uwu@icenowy.me \
--cc=wefu@redhat.com \
/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