From patchwork Fri May 13 06:26:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 572074 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:66c4:0:0:0:0 with SMTP id x4csp198155mal; Thu, 12 May 2022 23:30:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykXnMMqe+vhxGEo48MKpMcsauxqnwZ9vtuTySlfM8nSsgAjZ8ORH+49+0EoQoUGDKQ8z6b X-Received: by 2002:a17:906:5cb:b0:6cf:954:d84d with SMTP id t11-20020a17090605cb00b006cf0954d84dmr3015000ejt.560.1652423425421; Thu, 12 May 2022 23:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652423425; cv=none; d=google.com; s=arc-20160816; b=wS8Vzr9W0hCkjMLoiEER7Xio4EGIFAaQNpcyC8i1oM7mo35ulblzewVChcGOVF+aNN zvvOYoEaXm7p1q0WVPGgIRFr0b0uTY6CXwaGlUdsu0VN13kZ3mZ/VclZEFEetIb56X4n uFbR03vD/B9SflcUIiAXzyV4giz0cmgn1fgj+4se76tLMUs5tS2K2dmPhqSPBqsjF+xM mGpMLdCcSf5roIymTpwa9N5Ckytqbk/zi2aB+RZywZ/tDuLbOyTqq8QKBGdDZK8Y4zSG skRJkVzy4U+LG9hNrd3hiujlIxcEAeMOdHcT/9e6wC9+zEtpfzVtta+TbYDDJwWQYcJL 8sJQ== 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=9jttvUYr6F4AjwMC4ongrei2VaauMhS/a1N5PQBi55M=; b=XV5Gnu7sxgjXv85fcYOfFhzZDtFwQqTj7CbOr3EiYFV0uEPlypu63nFJK6JcxlaRyL Aok2RzfH87jOcTUdJd3E9ZznPlM6LGp6Afm2L/AsRLvcwmsdz6tJ6mZRZhI/3B8/pVuq pcy/GiTm5hc77PgFzYej8lTTMmZ67TLR4dyiF8ft0T3pnJJsiDVMTTSdeQ4nfVkyJuia +KxvQJ8U7/OxPerI6zPtpTn6SFpIdiiudKIhz8xq41Svbyj45woqUeLIvRqVcby0NnXz c+RZNvSpe9NlN0OLy4ft0W1adftg1pmYRaEEb6eeu4Fz+wzqUkH8f9tx9ixzRWOpf4s0 83AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S9a20Zxl; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id qk20-20020a1709077f9400b006f387f81489si1350846ejc.302.2022.05.12.23.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:30:25 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S9a20Zxl; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 4FF2E840A2; Fri, 13 May 2022 08:29:12 +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="S9a20Zxl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D50B883E3C; Fri, 13 May 2022 08:28:39 +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-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (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 41C4983E92 for ; Fri, 13 May 2022 08:28:33 +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-x333.google.com with SMTP id c190-20020a1c35c7000000b0038e37907b5bso6375571wma.0 for ; Thu, 12 May 2022 23:28:33 -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=9jttvUYr6F4AjwMC4ongrei2VaauMhS/a1N5PQBi55M=; b=S9a20Zxl7fibXWD0ONHRmw6zayo6i6pbr0qLVMd98jV67jv37iPSVSA/NEXb0mi6Uh HSyFEy5O2X2/opbAr7x8wmsD1j0H3GgxttCF/2ekc1OMFXMwYzVgSMGWHbEo3/IfQCyn ZVeatdsqqgAv400mUS8tIxc1JAOGeWLiYNExTo/q8iIGwD6RIRmmIGaPemlkbQXvzw+l +ShoSvBFu8iFn8T2+SCMgs+li0gLJZrJyEfPPBiGtC36N2Q+XRZu/04YxiXrC+kNsWLk Hwasjpn9XKiVsrgM+/6EqbPIA8DVAyvwNCQwr8++h2TlagT1elUYpNiIRbIWZr0ewc0b /QPw== 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=9jttvUYr6F4AjwMC4ongrei2VaauMhS/a1N5PQBi55M=; b=PmP+M/GLAoDHm54Xbx2wNjuj+JCyzWsu8um+xRhVX27CJ3irJxRB48WARVEUkqbpVd pH1CxsuCVERfDph7YbxITsUofWkEPUatO3o5bcP6dcy3fDXzEDmx2U+GJ5Xd19uC/dE5 iwSIksH8DmdX2zSbrGNJX8l/R9mrjkrbbPlAfOeW13+K+3EVM9G8/nhXNK0OA6xeONTy 91JGU9Y1zv9fg4vT/3yvcc4XKDLBRKA4YrYxAPf39jgWr0WKLFJGaM0BTzSr/10Xq3EI eZ91VxYf8/Mq161Ln7E3IqfH6I/fB8pEgCm2IzYRLK/IpRrbGRlbgLt+NpYq0zHLVc4v ahkQ== X-Gm-Message-State: AOAM532R0GbEMPyRamf3NmbYuATNKJubulbQvlVVAhUQCRxBfntIjzuC vwgpdvOHXY25wY5NdWQ98qCrLstIvh/7ug== X-Received: by 2002:a1c:5415:0:b0:394:2c89:4f2a with SMTP id i21-20020a1c5415000000b003942c894f2amr13509268wmb.144.1652423312539; Thu, 12 May 2022 23:28:32 -0700 (PDT) Received: from lmecxl1178.lme.st.com ([2a04:cec0:1194:a3aa:dc31:6fc0:bd75:771a]) by smtp.gmail.com with ESMTPSA id s18-20020a7bc0d2000000b003942a244eebsm1414235wmh.48.2022.05.12.23.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:28:32 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , Etienne Carriere Subject: [PATCH 08/14] firmware: scmi: smccc transport: implement multi-channel Date: Fri, 13 May 2022 08:26:16 +0200 Message-Id: <20220513062622.155433-9-etienne.carriere@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220513062622.155433-1-etienne.carriere@linaro.org> References: <20220513062622.155433-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 --- 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, };