[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aKL1sTutiMZPAd70@pie>
Date: Mon, 18 Aug 2025 09:43:13 +0000
From: Yao Zi <ziyao@...root.org>
To: Icenowy Zheng <uwu@...nowy.me>, Drew Fustini <fustini@...nel.org>,
Guo Ren <guoren@...nel.org>, Fu Wei <wefu@...hat.com>,
Michal Wilczynski <m.wilczynski@...sung.com>,
Ulf Hansson <ulf.hansson@...aro.org>,
Sebastian Reichel <sre@...nel.org>
Cc: Han Gao <rabenda.cn@...il.com>, linux-kernel@...r.kernel.org,
linux-riscv@...ts.infradead.org, linux-pm@...r.kernel.org
Subject: Re: [PATCH 1/2] driver: reset: th1520-aon: add driver for
poweroff/reboot via AON FW
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@...nowy.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@...nowy.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
Powered by blists - more mailing lists