From patchwork Fri May 13 06:26:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Etienne Carriere X-Patchwork-Id: 572071 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:66c4:0:0:0:0 with SMTP id x4csp197887mal; Thu, 12 May 2022 23:29:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1uPkxhyrVdO56yP3zZDaNR/2dJRnIfV3hn+rAjK6px90Pjm+gJgkNA7GVGU3TtP0yTyWW X-Received: by 2002:a17:906:a383:b0:6f5:132c:1a14 with SMTP id k3-20020a170906a38300b006f5132c1a14mr2930859ejz.21.1652423390392; Thu, 12 May 2022 23:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652423390; cv=none; d=google.com; s=arc-20160816; b=HaTvhkooi7MmAB9dmfUCwpDJ0Ue1KsIUrJE98G2cEwCdeJfqQ1klEBFB84G5XSi+NQ LQJ6Lfdrvk55NfvlwafUbv5N3gWTlw4zHWPNaIE/e+WODncc2GlRsGDhFmDGkeNJz3CY K6kvga8BoNQ0FOJaADxqMQa4rmiyoxdh2m0VdfyAVu7PKH53BIlb2qO+wvISp7r7gD40 8VtwWc0gqWiWMSTZmFQMKQ7XDaiU+X3jbyvBwrmv9rRL5v+br6OdkKaS09fghKlXaNnX XP2aS22uLod0TfN6rzRkb5/H7UXEr+Km+vwTre1orqi6bKkPRx9OskV8yNaWfPlsN9AQ Vn0Q== 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=x4/6O7aGugEjAcYT4t+60iUD8Qi1BBUN+5oRpySZRDc=; b=RiEQmnQxt4ll0qHU9EFYO+XjsCHZgMywQ0o/pQzs6t9Z9X4AdgXCPTnZYWZx4xgjSf VHknEl64b+914UYODLNQ7v/N1E8t7yh01nKmEbxWkpHnAB3pvVYVPzPwNWAocQC2RrLV 0+TbaM8DYAOaamUON+Jg52sW+LWslofr2//rAve7a9vculbXq7+gi6So2Z6wbIxvlH6f LDpwB8VAslef3oh4k+AaQq8ANvtov1UGJpeMOM7C5U2pJh0XuyCgKxcxwvKOAfDRJCfh NzCbVbVfJiM6bHSytckTHFTvhamVG58ZEjo9PKTpf3qynt3ZZy6mOFHGoY+nnKs3Po5M Fy5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jmiFiHqa; 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 ht16-20020a170907609000b006e8cb75fd59si1332479ejc.723.2022.05.12.23.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:29:50 -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=jmiFiHqa; 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 3F48F83F39; Fri, 13 May 2022 08:28:55 +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="jmiFiHqa"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 385CC83EDD; Fri, 13 May 2022 08:28:37 +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-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (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 9F5E683B2F for ; Fri, 13 May 2022 08:28:32 +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-x432.google.com with SMTP id a5so6237258wrp.7 for ; Thu, 12 May 2022 23:28:32 -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=x4/6O7aGugEjAcYT4t+60iUD8Qi1BBUN+5oRpySZRDc=; b=jmiFiHqachl3UFa2Z6dxKmaLKQAa+SIXk1Dt3DNU+XDokhEt7xMLguBsYdanLMzJtI Q/yKfIZUHCBAW4IvnII7itIwUC/vO55c1s8zk14N1GF53okYk+ro3BaKXcuq/EGoRo19 BhL9WaZxA1jTxgfY135u/AdhhPcKqtGWhYSg/5EtHDuWdxS/1f+KMfWZbRbQrDakWA4Q TEnBQvOe44376F4wa0bSp6JZA1nsZclQoSxp07MQLfllEck4Ttu1/eLmVqIcgFk6LIDI LMYHHEyMgnDHMEKVRrSdvaL/VEnlrdysseTLJ2Jro7hj0ojuikSKmZGxF4vmGY484yuj +JYA== 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=x4/6O7aGugEjAcYT4t+60iUD8Qi1BBUN+5oRpySZRDc=; b=MWTvixX5qDhekpYnY05VmsN32HWz3GxJQ6sot1N3I3Ejvojcyr/cUMA8uUL5zgtcxk wIvzO3bQeUfTyY6VUzbXK06B99C8wo/ybaucV/m8kOpPGJU4/gms7VrWinGb+CB4Pn3C BfLk7PkH9jI3DM1j1MySkNSQZPfhyUiiqv5eDkFff9zfj7Ff4DA9ywWnOg4oB1VqmQKa c+wJPXnH1gC+TZ/uHinbvPoDpi7H2+pP2Xza9kdJtavZBoq1berrkpchJsAFcyZWyEg2 xQUZ6SemvzdiA4MAFMmSO3R4JxutWI6Uc46VIUzgF5vrZnNHaLZfjrPAlVgPaGDt++r0 84jw== X-Gm-Message-State: AOAM533heY8AB1HnqSmSEeeoHRzG9NmSpHkmCvyx3Inl1ipDExidV7U9 IfoLwWeRov7F+t5p/jTjB0AOZoDRn5FwGg== X-Received: by 2002:a05:6000:144f:b0:20c:6090:3040 with SMTP id v15-20020a056000144f00b0020c60903040mr2428350wrx.479.1652423311671; Thu, 12 May 2022 23:28:31 -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.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 23:28:31 -0700 (PDT) From: Etienne Carriere To: u-boot@lists.denx.de Cc: Patrick Delaunay , Patrice Chotard , Etienne Carriere Subject: [PATCH 07/14] firmware: scmi: mailbox transport: implement multi-channel Date: Fri, 13 May 2022 08:26:15 +0200 Message-Id: <20220513062622.155433-8-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 mailbox transport driver to get SCMI channel reference at initialization and use when posting SCMI messages. Signed-off-by: Etienne Carriere --- 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, };