From patchwork Fri Jul 17 15:42:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 235732 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp1853464ilg; Fri, 17 Jul 2020 09:23:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA7ZJmG7eypPXy0rOaYovGrIbWoRaxDaOUN+F72K7CY5wJQY3pJwbj3j7aXO3DU109QliL X-Received: by 2002:aa7:c80f:: with SMTP id a15mr9585880edt.299.1595003039604; Fri, 17 Jul 2020 09:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595003039; cv=none; d=google.com; s=arc-20160816; b=IP4wffYOK0QCCwN1HqT+ri+iUcSHUp4eUmjztRsaV9XCYHY3xAxMumj67l5rUhItHi PrmDxfpkjUp0KgBu2VKe5ztI2fzXLUY9KmG//0ODxY5xKe+oVSREnaV14F7beuxM3eQn 3C3jUY7LmhQBf495xQCIOzoHm4bBBJjzzS19T/gt4i5M3qInlY9qkCIal/eCUKWCihfg X8JsJMKT7L9Rho96I3ZHpoCZvrW99Jc0w0duRBnD+DLCXLgGV67cFZ8GxZn9u7B8Gzig HV5c52+HGnkHTOymzZKtyTZAjTq0UhM0BtF0travQ9hA4nE/aU06u21qoEKIBkFFK4wE hleQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=7KOQFWWWs3STYhqsXVOjepFXQSzAwuPSPtB5ZId/osU=; b=mlSDo2Q/FbZwZ4MhZNY+L06qacsYwWAGsFWK1rWv0kdF94AICxcoh0kNu6z3uxz0ni UNc//z74hcVDYNqTAb2Hj4Be5fP8voJ9cgh8HOoEk12+NpGxdwGNGE4VfermzEenGMH+ Jt6Z3DDkds8FFhm5HSMdu2W7zYGVEDin6BMHnhKxWG2KW3wqLIg8ukM/RFJwBd8HUiyK +MBAYMwYQYYDEjiKNsFSqpbOSkUpMblLsASPShBfjugCfsK8dq5gg3Jl4epzI4ozXuFr g81kIF1R8y65/qaV85/p4AbyGhF2DtPy8g4hfEuep9yTXCOUA8Uq4EBLfqIBK7EXgPMo 5TpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VRJrheF2; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id v27si4089958ejc.624.2020.07.17.09.23.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 09:23:59 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VRJrheF2; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C5D6181C24; Fri, 17 Jul 2020 18:23:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="VRJrheF2"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 07B7F81C18; Fri, 17 Jul 2020 17:43:49 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A4F3781BF7 for ; Fri, 17 Jul 2020 17:43:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=etienne.carriere@linaro.org Received: by mail-wm1-x341.google.com with SMTP id g75so15543239wme.5 for ; Fri, 17 Jul 2020 08:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7KOQFWWWs3STYhqsXVOjepFXQSzAwuPSPtB5ZId/osU=; b=VRJrheF2z8QhPvV5wWEpIqtFXuj2Z/nrej9g/QQ+tMhQZs7zYdi4kXUMUhLjBONR/m p5LRHCQzGm7qI1zjhRhrys+kwJuRz13vvns6Kdrqax9Acevgv7NCF/t8HdKk92xUnQG4 qoJhpUixKhZNGbveD5huj/1BFg7hPxBkh6G6thFrEIaIiP/Wvy1xqh8NXY7RE8OjAIlF GVP4ourPXgryC/60+ElBHBsNCP2nrvG4RCzH3gdfE28AsjU+tU8Au1IZNjV9DDnLn9+0 kBjtQKAF5IByT4D8nssisCLnIfRA/r+AaHRChANh+fnwfdi/QYDCBZreXINQz1Pxpa2U aO/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7KOQFWWWs3STYhqsXVOjepFXQSzAwuPSPtB5ZId/osU=; b=tH9jzEsORXtS3WlcQCSjyjXi6HFxxLRIEpu2okLvHKUo6SKcmwgTQW4EZTC6WO70CN VxzpIR7x/lHjuU7McrKPQZkGDkO5ULR9XD7I0OTAZUVuZnC8QrwfGzC8t67aXuxgQdPw fOx3RQy5EwgJVoT2Su13CbxwsfYwL0DG1sojexAhlxxMZNFqJF/DTOfJGO/Eok6aRhM9 Taj4UJgMtTJDyaa9mlxW4B9a9M14UgX57BWiToS3YodnWdrgAORWH2r09UttJY1yKZ36 tDDY2HuYJ0A26hk/9lFxnWodiDP/E8YUVBY21mAp94xMzPDkRBQ7mG/Jj77Fd/8UIdFj j2hg== X-Gm-Message-State: AOAM5307HyZl4yr2r7Co9X6wzDbhmqJVUv7pq+7tM4yEjbmSL9SjCBcy jj1J5QJ2eKGt9ZluBKRrlD/zrXdzDqP4Aw== X-Received: by 2002:a7b:c197:: with SMTP id y23mr10503516wmi.114.1595000624810; Fri, 17 Jul 2020 08:43:44 -0700 (PDT) Received: from lmecxl0524.lme.st.com ([2a04:cec0:1057:28c5:7db6:61b:9cd8:ab62]) by smtp.gmail.com with ESMTPSA id n3sm2345286wre.29.2020.07.17.08.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 08:43:44 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Bin Meng , Etienne Carriere , Fabio Estevam , Jagan Teki , Marek Szyprowski , Priyanka Jain , Simon Glass , Vignesh Raghavendra , Tom Rini , Lukasz Majewski , Matthias Brugger , Peng Fan , Trevor Woerner Subject: [PATCH 4/4] reset: add reset controller driver for SCMI agents Date: Fri, 17 Jul 2020 17:42:56 +0200 Message-Id: <20200717154256.11001-4-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200717154256.11001-1-etienne.carriere@linaro.org> References: <20200717154256.11001-1-etienne.carriere@linaro.org> X-Mailman-Approved-At: Fri, 17 Jul 2020 18:23:26 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean 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://developer.arm.com/architectures/system-architectures/software-standards/scmi Signed-off-by: Etienne Carriere --- 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 -- 2.17.1 Reviewed-by: Simon Glass 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 +#include +#include +#include +#include +#include + +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, +};