[PATCH 4/4] reset: add reset controller driver for SCMI agents
Peng Fan
peng.fan at nxp.com
Mon Jul 20 04:07:46 CEST 2020
> Subject: [PATCH 4/4] reset: add reset controller driver for SCMI agents
>
> This change introduces a reset controller driver for SCMI agent devices.
> When SCMI agent and SCMI reset domain drivers are enabled, SCMI agent
> binds a reset controller device for each SCMI reset domain protocol devices
> enabled in the FDT.
>
> SCMI reset driver is embedded upon CONFIG_RESET_SCMI=y. If enabled,
> CONFIG_SCMI_AGENT is also enabled.
>
> SCMI Reset Domain protocol is defined in the SCMI specification [1].
>
> Links: [1]
> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdevelo
> per.arm.com%2Farchitectures%2Fsystem-architectures%2Fsoftware-standar
> ds%2Fscmi&data=02%7C01%7Cpeng.fan%40nxp.com%7C68ec2a92529
> e49d46be608d82a6778a9%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%
> 7C0%7C637305971181000613&sdata=NWnJw%2BYBsbC1zBkBdq9Jxh9
> Crepk5JdxJlCxNl0diqA%3D&reserved=0
> Signed-off-by: Etienne Carriere <etienne.carriere at linaro.org>
> ---
>
> drivers/firmware/scmi.c | 3 ++
> drivers/reset/Kconfig | 8 ++++
> drivers/reset/Makefile | 1 +
> drivers/reset/reset-scmi.c | 86
> ++++++++++++++++++++++++++++++++++++++
> 4 files changed, 98 insertions(+)
> create mode 100644 drivers/reset/reset-scmi.c
>
> diff --git a/drivers/firmware/scmi.c b/drivers/firmware/scmi.c index
> 9f06718df51..9be53a9cf11 100644
> --- a/drivers/firmware/scmi.c
> +++ b/drivers/firmware/scmi.c
> @@ -402,6 +402,9 @@ static int scmi_bind(struct udevice *dev)
> case SCMI_PROTOCOL_ID_CLOCK:
> drv = DM_GET_DRIVER(scmi_clock);
> break;
> + case SCMI_PROTOCOL_ID_RESET_DOMAIN:
> + drv = DM_GET_DRIVER(scmi_reset_domain);
> + break;
> default:
> dev_info(dev, "Ignore unsupported SCMI protocol %u\n",
> protocol_id);
> diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig index
> 6d535612234..31bd4cd5b45 100644
> --- a/drivers/reset/Kconfig
> +++ b/drivers/reset/Kconfig
> @@ -164,4 +164,12 @@ config RESET_RASPBERRYPI
> relevant. This driver provides a reset controller capable of
> interfacing with RPi4's co-processor and model these firmware
> initialization routines as reset lines.
> +
> +config RESET_SCMI
> + bool "Enable SCMI reset domain driver"
> + select SCMI_FIRMWARE
> + help
> + Enable this option if you want to support reset controller
> + devices exposed by a SCMI agent based on SCMI reset domain
> + protocol communication with a SCMI server.
> endmenu
> diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile index
> 8e0124b8dee..f3c0fbfd8f3 100644
> --- a/drivers/reset/Makefile
> +++ b/drivers/reset/Makefile
> @@ -25,3 +25,4 @@ obj-$(CONFIG_RESET_HISILICON) += reset-hisilicon.o
> obj-$(CONFIG_RESET_IMX7) += reset-imx7.o
> obj-$(CONFIG_RESET_SYSCON) += reset-syscon.o
> obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o
> +obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
> diff --git a/drivers/reset/reset-scmi.c b/drivers/reset/reset-scmi.c new file
> mode 100644 index 00000000000..e664d91d865
> --- /dev/null
> +++ b/drivers/reset/reset-scmi.c
> @@ -0,0 +1,86 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (C) 2019-2020 Linaro Limited */ #include <common.h>
> +#include <dm.h> #include <errno.h> #include <reset-uclass.h> #include
> +<scmi.h> #include <asm/types.h>
> +
> +enum scmi_reset_domain_message_id {
> + SCMI_RESET_DOMAIN_RESET = 0x4,
> +};
> +
> +#define SCMI_RD_RESET_FLAG_ASSERT BIT(1)
> +#define SCMI_RD_RESET_FLAG_DEASSERT 0
> +
> +struct scmi_rd_reset_in {
> + u32 domain_id;
> + u32 flags;
> + u32 reset_state;
> +};
> +
> +struct scmi_rd_reset_out {
> + s32 status;
> +};
> +
> +static int scmi_reset_set_state(struct reset_ctl *rst, int
> +assert_not_deassert) {
> + struct scmi_rd_reset_in in = {
> + .domain_id = rst->id,
> + .flags = assert_not_deassert ? SCMI_RD_RESET_FLAG_ASSERT :
> + SCMI_RD_RESET_FLAG_DEASSERT,
> + .reset_state = 0,
> + };
> + struct scmi_rd_reset_out out;
> + struct scmi_msg scmi_msg = {
> + .protocol_id = SCMI_PROTOCOL_ID_RESET_DOMAIN,
> + .message_id = SCMI_RESET_DOMAIN_RESET,
> + .in_msg = (u8 *)&in,
> + .in_msg_sz = sizeof(in),
> + .out_msg = (u8 *)&out,
> + .out_msg_sz = sizeof(out),
> + };
> + int rc;
> +
> + rc = scmi_send_and_process_msg(rst->dev->parent, &scmi_msg);
> + if (rc)
> + return rc;
> +
> + return scmi_to_linux_errno(out.status); }
> +
> +static int scmi_reset_assert(struct reset_ctl *rst) {
> + return scmi_reset_set_state(rst, SCMI_RD_RESET_FLAG_ASSERT); }
> +
> +static int scmi_reset_deassert(struct reset_ctl *rst) {
> + return scmi_reset_set_state(rst, SCMI_RD_RESET_FLAG_DEASSERT); }
> +
> +static int scmi_reset_request(struct reset_ctl *reset_ctl) {
> + return 0;
> +}
> +
> +static int scmi_reset_rfree(struct reset_ctl *reset_ctl) {
> + return 0;
> +}
> +
> +static const struct reset_ops scmi_reset_domain_ops = {
> + .request = scmi_reset_request,
> + .rfree = scmi_reset_rfree,
> + .rst_assert = scmi_reset_assert,
> + .rst_deassert = scmi_reset_deassert,
> +};
> +
> +U_BOOT_DRIVER(scmi_reset_domain) = {
> + .name = "scmi_reset_domain",
> + .id = UCLASS_RESET,
> + .ops = &scmi_reset_domain_ops,
> +};
> --
Regards,
Peng.
> 2.17.1
More information about the U-Boot
mailing list