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: 1637469 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=SQPmOS4c; 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 4LCHMC4l5bz9s0w for ; Wed, 1 Jun 2022 02:11:03 +1000 (AEST) 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-Google-Smtp-Source: ABdhPJz/uH8rSkhwr6RgeIQ89v7zf2fMvIYms8uQzSCSjPtMEHX80dPbDWIH9QBvkO0D/+7BAbzRkg== 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, };