From patchwork Tue May 31 16:09:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 577453 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:330b:0:0:0:0 with SMTP id f11csp1301521mag; Tue, 31 May 2022 09:11:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmRdLGLYPBCzA0MDWTtyFeHe86U/2VoEAPRdjBQxizsdW7nyogGGurmtDJOoq5RJNHcekj X-Received: by 2002:a05:6638:1c15:b0:32e:de34:ccb3 with SMTP id ca21-20020a0566381c1500b0032ede34ccb3mr20914296jab.1.1654013476567; Tue, 31 May 2022 09:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654013476; cv=none; d=google.com; s=arc-20160816; b=b3MtsR0EQUc3le+jR1YVta2uN9JW88B+ULxT08rW1TfvQCajTw56s0/TZCXu/FPTNM qSg5wdsiERF/n3Dpiej1423G8jJjQUc8Hl59yNZOIPdfQr9QR4XMrpzfllERnHivTXFA Mc5QjSurwrKMul6rZCSw6ydXCJSJRwmHmGh+AIxyQqx+B5Y3B741Z92J6hLOezkwR77F LyTyz0zzzD8EhnztqThLyvzc6nH/7lx0faTQoLDq2bHKgVq/sLbT0tOnoXbeR7O6qyG7 8iIT31sCtftBgUDjnfcSHjinzAPn6XZ+QWGdoZrL+51v9d/gcPYw8hGvMv14Bcsr1rHg MtwA== 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=4/jLFRrMgeHr8IHmC/71VKUsz+84Tptcg+sRQiP2X4s=; b=LQ5rvw8LQnd7Um6RKozUaaxFODMnUE/EHYM9gkS5c5qaGIRsvBnc0yrkUYx8vBFNjF gKQOjg3xK8JT2N5lX3g90iOG1c96T23NNBuC3lOJ5K8V+oQExBBiJzO3X331ZrPFw2FV n9h2eODlPBxEutpKtqHaM/BXJtcNMx+5BsxCufHb5cGoVxeqAJepgdjZ3zo7nmbv4fRZ qIyvGPW/iU0WeOeHqMh3VxPcncfTv+DQbh3cCPilke0GOFGQxZ1yP+xJUJ+6YC7uHnUG 2NcA3ig4csgRaIxMkWvdxUkCsoqGx9OuZL0okOjNTeBuEzvC8jCYno7bdDMKJaoah4wQ cV8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=canr1x4l; 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 a124-20020a6bca82000000b0066880222ccasi10681871iog.99.2022.05.31.09.11.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:11:16 -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=canr1x4l; 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 4A1668429D; Tue, 31 May 2022 18:10:25 +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="canr1x4l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6C44D83F33; Tue, 31 May 2022 18:09:53 +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-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (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 36C2F841A5 for ; Tue, 31 May 2022 18:09:44 +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-x434.google.com with SMTP id h5so11265169wrb.0 for ; Tue, 31 May 2022 09:09:44 -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=4/jLFRrMgeHr8IHmC/71VKUsz+84Tptcg+sRQiP2X4s=; b=canr1x4lj6Da63sNiq+8CxSU/DyDBZsH0Tr6HHxKuqAcT8op09O1lwMTyGo9yfk+3/ K7F2hy6blZ3PNVX7aRVppVzhxgYBNeq4bpeug7vvMyyBMytN9f3o8AWZRF0EbKPtWGhP srPkE/eGekr0H+i+/bpjyIZXaBWxFZcBwbKjjFAnmRp1xgsfm7fuAKLQCZ10Thk29v1s oSv9saQ8515FbfDM1tVjky+1vs/hyLYPW4qGOItDI4mpCxcqOQ03Wnx2NRW51FFk/X7o 6j+McCy8ZDFJCKCO+VtcN6KCAo/21CEO1BbpGVvwNTtOjcmhJBsfWIomlU3WsLV5P5xt Oq/Q== 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=4/jLFRrMgeHr8IHmC/71VKUsz+84Tptcg+sRQiP2X4s=; b=zZncGPcXahOQXDMq/RxDdxVC/jEusDbd5EsR+0IXPnuo9LZZBLmL9HY8vaupsaFY5g cw8l+f8nGC7cXKtJOMzgJWk4mSgyHblYjYzJLWl93Mr/FOdGwrUH3/U7OzD81Vzcvly5 LXgo0C22tK5Mlfd8UoiW4rsfeT+rN5FV9Dj264SioIOAeztSjnI51k8pbrRzGhhAEZsn PREvx4/RbsNFwbUnr1mTEVcVwo1Jz1kG0diRuzv0+KRolKFq3NeyYmuja2UONesEdun/ 23OXAXbi6h7UeLEMy7hgnxPmJ2vLtmcteaYFZKm3OFth0loilB1CDTsPE4GTC7TTkLAA p/jw== X-Gm-Message-State: AOAM5333uwSgnc8MfRvLCy3JxpHfH3XiGpWHM7H+YfNRZ2bwAZYReVSa 8VC8Zxs5TcfsbfJnhlgtI/g9UB8yuSMiiA== X-Received: by 2002:a05:6000:1682:b0:20e:6de0:a566 with SMTP id y2-20020a056000168200b0020e6de0a566mr48330191wrd.91.1654013383693; Tue, 31 May 2022 09:09:43 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 May 2022 09:09:43 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , etienne.carriere@linaro.org Subject: [PATCH v2 07/14] firmware: scmi: mailbox transport: implement multi-channel Date: Tue, 31 May 2022 18:09:22 +0200 Message-Id: <20220531160929.931150-8-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 mailbox 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/mailbox_agent.c | 63 ++++++++++++++++++++++++--- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/scmi/mailbox_agent.c b/drivers/firmware/scmi/mailbox_agent.c index aa4929aafae..e63b67c5ee8 100644 --- a/drivers/firmware/scmi/mailbox_agent.c +++ b/drivers/firmware/scmi/mailbox_agent.c @@ -31,6 +31,14 @@ struct scmi_mbox_channel { ulong timeout_us; }; +/** + * struct scmi_channel - Channel instance referenced in SCMI drivers + * @ref: Reference to local channel instance + **/ +struct scmi_channel { + struct scmi_mbox_channel ref; +}; + static int scmi_mbox_process_msg(struct udevice *dev, struct scmi_channel *channel, struct scmi_msg *msg) @@ -38,6 +46,10 @@ static int scmi_mbox_process_msg(struct udevice *dev, struct scmi_mbox_channel *chan = dev_get_plat(dev); 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; @@ -64,13 +76,10 @@ out: return ret; } -int scmi_mbox_of_to_plat(struct udevice *dev) +static int setup_channel(struct udevice *dev, struct scmi_mbox_channel *chan) { - struct scmi_mbox_channel *chan = dev_get_plat(dev); int ret; - chan->timeout_us = TIMEOUT_US_10MS; - ret = mbox_get_by_index(dev, 0, &chan->mbox); if (ret) { dev_err(dev, "Failed to find mailbox: %d\n", ret); @@ -78,10 +87,51 @@ int scmi_mbox_of_to_plat(struct udevice *dev) } ret = scmi_dt_get_smt_buffer(dev, &chan->smt); - if (ret) + if (ret) { dev_err(dev, "Failed to get shm resources: %d\n", ret); + return ret; + } - return ret; + chan->timeout_us = TIMEOUT_US_10MS; + + return 0; +} + +static int scmi_mbox_get_channel(struct udevice *dev, + struct scmi_channel **channel) +{ + struct scmi_mbox_channel *base_chan = dev_get_plat(dev->parent); + struct scmi_mbox_channel *chan; + int ret; + + if (!dev_read_prop(dev, "shmem", NULL)) { + /* Uses agent base channel */ + *channel = container_of(base_chan, struct scmi_channel, ref); + + return 0; + } + + chan = calloc(1, sizeof(*chan)); + if (!chan) + return -ENOMEM; + + /* Setup a dedicated channel for the protocol */ + ret = setup_channel(dev, chan); + if (ret) { + free(chan); + return ret; + } + + *channel = (void *)chan; + + return 0; +} + +int scmi_mbox_of_to_plat(struct udevice *dev) +{ + struct scmi_mbox_channel *chan = dev_get_plat(dev); + + return setup_channel(dev, chan); } static const struct udevice_id scmi_mbox_ids[] = { @@ -90,6 +140,7 @@ static const struct udevice_id scmi_mbox_ids[] = { }; static const struct scmi_agent_ops scmi_mbox_ops = { + .of_get_channel = scmi_mbox_get_channel, .process_msg = scmi_mbox_process_msg, };