From patchwork Tue May 31 16:09:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 577452 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:330b:0:0:0:0 with SMTP id f11csp1301270mag; Tue, 31 May 2022 09:11:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvI5ZmEmwB6iLegXKD4iYOzSuV8+vSoQfaTnHm7xCFE5yQjQH/RruPBFSu//EXfCJsl2QG X-Received: by 2002:a05:6602:3d2:b0:65d:c151:f29f with SMTP id g18-20020a05660203d200b0065dc151f29fmr27597438iov.28.1654013462522; Tue, 31 May 2022 09:11:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654013462; cv=none; d=google.com; s=arc-20160816; b=NJDis3NVqmh44v6EtzG5Z5JjWDW3P5IBaz0SW7PibHf3zQgnKMwEaybyeYq/lfZcP+ ZxGaZEPROVig8MKseEPce3TNfj6ry6wp6wiAdJ9x6qGv8qYyIXrO9VZLQMbEUjkb61qA zPQRpbMCf6s66Y6DhBg8z8QRcApQ72huII1oEcYu92f4ngv0K0mIzhPmLJR2Uh5BjawQ VYiQGZK4WjagEkKivIafKmY4uMzOb1L85ARc9LBtoEoSeQDlgf/ngbAWrlQJWt8QK6yQ MTD9ao0wz3x/kkqZL4syTtOV7S690tvuXQmcmY2FmPR8FsQbUG2nLB8PLZQmciR5mJ5/ lUMQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Ov8+U6N7p5wQlZ34HTCOUwzpfOCO33LzC2iQnp+jed0=; b=k1HWvZc4/0BZrAuEX2Czmh0upU8zfEYgO9MwTiBzHTNPTPv5xEv7GdQorrxb+j5Szd acUStnDE+08T3tCnT6mZHRkvXhw+D/9z+oU39sYRNH9qNqC0DN11HFaDP8R7DP+DP/lA 6ojOx81mEzsGS33h74yDmohkeB0bZCne8Ev8spvbUROvPjkk5Leny/NpG9iUNVoO8QPL FU0kFCdpqyr2DZ9E0rp5QJlwzEsZNAESfKGdJxjHY4tnw2ZOmcjCoFFSBT8W/02BLruT PaVs4NQIFW6F9fTGuNFyOHAmbAVXjoM+GXhUrUse4PPkm9ZNxknQhq0T8Qouo/D3j61N 0SlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SQPmOS4c; 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 b6-20020a92c566000000b002d100cccd4dsi13969298ilj.129.2022.05.31.09.11.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:11:02 -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=SQPmOS4c; 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 AC2E8842A6; Tue, 31 May 2022 18:10:21 +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="SQPmOS4c"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CBC3383F33; Tue, 31 May 2022 18:09:51 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) (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 1E3B583F40 for ; Tue, 31 May 2022 18:09:46 +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-wr1-x433.google.com with SMTP id u3so19341408wrg.3 for ; Tue, 31 May 2022 09:09:46 -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 :mime-version:content-transfer-encoding; bh=Ov8+U6N7p5wQlZ34HTCOUwzpfOCO33LzC2iQnp+jed0=; b=SQPmOS4cBJhaA2+ZkEmEKao+KBtgCQD6bAUvbX0XwO23KSCxnE0tGO5XvHGLrjV2ip Z2D6fWcel7V+C+N/MmZYu3FzF3TEwz7bG7OEUTwGM5ZF84qEqN0/abCncaRTTtgDATe4 FSY0yhTHgWy9aw5/1jzHYgIz2Bf8FnH/3AsNZL6V4zDL6cb82d72Y7+AuGdUOlPChGl+ HviH1PkRy6aevgn9qY7VdV1+YHZEz+Y0NO8MWcB8/2fJKZ/kUcr5na7D4+hYSpWMxf4Y IuMuxwx6C8XbPzNmHi9dwUpriiiz2Hwf9KsJ6UCi1nMyNnRZJ8exN9PcCw8V1SSxZRkA W0mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ov8+U6N7p5wQlZ34HTCOUwzpfOCO33LzC2iQnp+jed0=; b=YIgkWSwfYwbB0nsWdlcGHhoDVGx0nVMjSAo9f7w/jEhiAfFe0o7FXlsc1nUM4tmk1L RltVh/K5FjDO4bjhpHe+bm2wTeMqwhkynxYkEC/eI+4DK6731Yn2Md1Yr8HwJApK6kmW WLAlMA/oCQxSR0zsQJky8gdK6ISVr+EeCk/Q7SVhS3gQo+vbhJMoJxNiCRETr2l+VXuP 71Mj7maYPodv8YLBXMpPsXGOvHAgpynRcg6XJymUJleT2bhJTH14rVG78j/UELhVfqu/ 2lHJGX6Dptm7kj7MM8soguQIZ3K7Js6RdrJJT9wp0dGhqgz8vBR8oBOiq3drOW5ilHnk JWZQ== X-Gm-Message-State: AOAM5317V4RV6SLxu9pvy3AMEnAhpA7qjrpJAY+BpKMvKrg7AuLEXgly /WGYlNXFSNDtfYeDplz5mIaA8keoSM5tJg== X-Received: by 2002:adf:ebce:0:b0:20d:7859:494d with SMTP id v14-20020adfebce000000b0020d7859494dmr50491687wrn.590.1654013384750; Tue, 31 May 2022 09:09:44 -0700 (PDT) Received: from lmecxl1178.lme.st.com ([2a04:cec0:117a:a94e:9569:2e63:8a35:2cc5]) by smtp.gmail.com with ESMTPSA id r23-20020a05600c321700b0039aa4d054f8sm2884035wmp.5.2022.05.31.09.09.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:09:44 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , etienne.carriere@linaro.org Subject: [PATCH v2 08/14] firmware: scmi: smccc transport: implement multi-channel Date: Tue, 31 May 2022 18:09:23 +0200 Message-Id: <20220531160929.931150-9-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220531160929.931150-1-etienne.carriere@linaro.org> References: <20220531160929.931150-1-etienne.carriere@linaro.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean Updates SCMI SMCCC transport driver to get SCMI channel reference at initialization and use when posting SCMI messages. Signed-off-by: Etienne Carriere --- No change since v1. --- drivers/firmware/scmi/smccc_agent.c | 54 +++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/scmi/smccc_agent.c b/drivers/firmware/scmi/smccc_agent.c index b7a930b24df..73a7e0a844a 100644 --- a/drivers/firmware/scmi/smccc_agent.c +++ b/drivers/firmware/scmi/smccc_agent.c @@ -30,6 +30,14 @@ struct scmi_smccc_channel { struct scmi_smt smt; }; +/** + * struct scmi_channel - Channel instance referenced in SCMI drivers + * @ref: Reference to local channel instance + **/ +struct scmi_channel { + struct scmi_smccc_channel ref; +}; + static int scmi_smccc_process_msg(struct udevice *dev, struct scmi_channel *channel, struct scmi_msg *msg) @@ -38,6 +46,10 @@ static int scmi_smccc_process_msg(struct udevice *dev, struct arm_smccc_res res; int ret; + /* Support SCMI drivers upgraded to of_get_channel operator */ + if (channel) + chan = &channel->ref; + ret = scmi_write_msg_to_smt(dev, &chan->smt, msg); if (ret) return ret; @@ -53,9 +65,8 @@ static int scmi_smccc_process_msg(struct udevice *dev, return ret; } -static int scmi_smccc_of_to_plat(struct udevice *dev) +static int setup_channel(struct udevice *dev, struct scmi_smccc_channel *chan) { - struct scmi_smccc_channel *chan = dev_get_plat(dev); u32 func_id; int ret; @@ -73,12 +84,51 @@ static int scmi_smccc_of_to_plat(struct udevice *dev) return ret; } +static int scmi_smccc_get_channel(struct udevice *dev, + struct scmi_channel **channel) +{ + struct scmi_smccc_channel *base_chan = dev_get_plat(dev->parent); + struct scmi_smccc_channel *chan; + u32 func_id; + int ret; + + if (dev_read_u32(dev, "arm,smc-id", &func_id)) { + /* Uses agent base channel */ + *channel = container_of(base_chan, struct scmi_channel, ref); + + return 0; + } + + /* Setup a dedicated channel */ + chan = calloc(1, sizeof(*chan)); + if (!chan) + return -ENOMEM; + + ret = setup_channel(dev, chan); + if (ret) { + free(chan); + return ret; + } + + *channel = container_of(chan, struct scmi_channel, ref); + + return 0; +} + +static int scmi_smccc_of_to_plat(struct udevice *dev) +{ + struct scmi_smccc_channel *chan = dev_get_plat(dev); + + return setup_channel(dev, chan); +} + static const struct udevice_id scmi_smccc_ids[] = { { .compatible = "arm,scmi-smc" }, { } }; static const struct scmi_agent_ops scmi_smccc_ops = { + .of_get_channel = scmi_smccc_get_channel, .process_msg = scmi_smccc_process_msg, };