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: 1630513 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=S9a20Zxl; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KzzKb36Y1z9sG5 for ; Fri, 13 May 2022 16:30:27 +1000 (AEST) 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-Google-Smtp-Source: ABdhPJwB84rAN6J+f99RZpeRklW2KQ0e8fL581qVcKzqg0VIRhOwVD7SYSAeyQjLOrlSjw2NSWhrkg== 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, };