From patchwork Wed Dec 16 16:52:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grzegorz Jaszczyk X-Patchwork-Id: 344516 Delivered-To: patch@linaro.org Received: by 2002:a17:906:4755:0:0:0:0 with SMTP id j21csp506533ejs; Wed, 16 Dec 2020 08:55:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpw4HsR3pnGcon+eSyIB+QqcBbE9f8bb+BxGZF1nvEfaYSYq1k7xC+m8/7STwnbu2MUNE6 X-Received: by 2002:a50:e68a:: with SMTP id z10mr7589682edm.66.1608137701504; Wed, 16 Dec 2020 08:55:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608137701; cv=none; d=google.com; s=arc-20160816; b=Q/IklNTXkKFIdxVBZbq3Ru8co9ChfRdLLoCb+1T7UszQDlMdRslkI6lmgLcuUWnn0U gcYZKM6q59Po4p8mpJ765Vu28QqYvop3g1mW6qe0CHoCkreXnRbWLFPlpMrfWBbYO5kO bCZW8Hafv3ocALmxtZ70GsT12kvJ4tXSWW7caFBS5jnBB9wXHFZlf07uGIE0cbY2KMeM BKUln38qGWLJITCGscMGkBEgbvu7bM4qTph8qd7+AYRLfxcUFNUzFUNmQqNw5vyqHu6n Fe2/Sm1U5JiCPTviT67n97d9NF1IngZnWJAM69pjtbQgXR3ya7VWGqXXGasVFGAVgc44 aYsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QN2ZDNaFP2aT/ClXBsxAgxKdaK3vIBmK5H4WTk/CkiE=; b=MLfFVb+UNGQqA5YH+n7Aav+z33l1n3TavGlWFhWEcvCCuZKsSr5bPQHmOdMhhLWXI6 jReTT0b4IznvPzC8VQojP1JGr42hA4ueaoL1uzfOkGijS/YlNuZE1twpjBgnbTQZCGD1 Mi/rFvfJVpOJWwpoawgFxuhWKu6kJQs3zHUUrt+BPQ2ox1U8KA+50DTS9cvKEOJ95sSs 6M799mjvde2y8hk/M7zDpRpodVJraCWXFA0GADirSoIPJyckey91Y8pehVxiB1Fgsbrd r11FwivtrdlChPv1YBvBUQYVUtE0wiEFERiwHLilamozB63dMRTDfg36FH48UbiyuMZ5 coew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F7PRpDU1; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ml22si1153631ejb.172.2020.12.16.08.55.01; Wed, 16 Dec 2020 08:55:01 -0800 (PST) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F7PRpDU1; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726877AbgLPQy4 (ORCPT + 7 others); Wed, 16 Dec 2020 11:54:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726882AbgLPQy4 (ORCPT ); Wed, 16 Dec 2020 11:54:56 -0500 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77E8CC0619D5 for ; Wed, 16 Dec 2020 08:53:02 -0800 (PST) Received: by mail-lf1-x131.google.com with SMTP id a12so50058102lfl.6 for ; Wed, 16 Dec 2020 08:53:01 -0800 (PST) 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=QN2ZDNaFP2aT/ClXBsxAgxKdaK3vIBmK5H4WTk/CkiE=; b=F7PRpDU16rzweD3c39edlX+7YkESCotZA/8lVuw7u0iyFp6lxPyNoIfl0Gmn0GfPRu OCGSXbVPuEVr40Ead0jo3k1yeY70xXijLUCaTjfVxqHvWPzP3fy4QAOjarCRXxazAJe8 cBhtLSxLpWkBBdgh1jN4e/08b0qSU+soXhcAIuMBp4olkK69NiLajmjSn24lGN9bQOw9 srP1jHf1P3c1pu0FMOabufaANlqPNlridBo3+jdRcJ2s1XvU+OyO+3h0y87Dy//Igqhv ZtRI+fAbOWMuf2iRmbKTalhDEDfkjZwfKtLksMmH330rgoqwGh6ySl5KYrSbBLFiRBDZ 8E4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QN2ZDNaFP2aT/ClXBsxAgxKdaK3vIBmK5H4WTk/CkiE=; b=I+iiA1aGjCl2PeB0Gll7L/Y7rNOhCHKh1mtwpvdk8rtP3ZehFVakbCPaD5MS3Jp9Ow 0QOyLyH/YY5X9x7a3H03FEifFGA4Senwlq848GPD9V0h1VTsKfmKSGuTPH1qZ19Hcwm8 3tny4z2qRWG3CStjg5KqVGuPqQbeJXDpN/JZVcOaVImJNMVh8TReDmTuELYrn5VDAKh/ fkvZqAfew5bqXnHGOGdcflFbveVGt+WU9KEXuGljZf8av4bKemvOQUzy/rCaO2GnwNGi zI/KLxXDIvJb/5UPEx3soJlzPCfnrJ27g9bc/N7syRyS7HB0XyEu1WMyNqKf687Oeo45 WcUw== X-Gm-Message-State: AOAM533MpQCuGjR3DG8OfwI+fwFWOY6D5L1yR2kbm8wRNjSzvc39clmW hSySPpKULLr6c7csDvAGOiq81Q== X-Received: by 2002:a2e:9f14:: with SMTP id u20mr5744528ljk.244.1608137579582; Wed, 16 Dec 2020 08:52:59 -0800 (PST) Received: from gilgamesh.semihalf.com (193-106-246-138.noc.fibertech.net.pl. [193.106.246.138]) by smtp.gmail.com with ESMTPSA id t3sm281645lfe.263.2020.12.16.08.52.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Dec 2020 08:52:58 -0800 (PST) From: Grzegorz Jaszczyk To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, robh+dt@kernel.org, s-anna@ti.com, ssantosh@kernel.org Cc: grzegorz.jaszczyk@linaro.org, linux-remoteproc@vger.kernel.org, lee.jones@linaro.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, praneeth@ti.com, rogerq@ti.com, t-kristo@ti.com Subject: [PATCH v2 5/5] remoteproc: pru: Configure firmware based on client setup Date: Wed, 16 Dec 2020 17:52:39 +0100 Message-Id: <20201216165239.2744-6-grzegorz.jaszczyk@linaro.org> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20201216165239.2744-1-grzegorz.jaszczyk@linaro.org> References: <20201216165239.2744-1-grzegorz.jaszczyk@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Tero Kristo Client device node property firmware-name is now used to configure firmware for the PRU instances. The default firmware is also restored once releasing the PRU resource. Co-developed-by: Suman Anna Signed-off-by: Suman Anna Signed-off-by: Tero Kristo Co-developed-by: Grzegorz Jaszczyk Signed-off-by: Grzegorz Jaszczyk --- drivers/remoteproc/pru_rproc.c | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) -- 2.29.0 diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c index a37c3f5838ea..4a9c7973bf3a 100644 --- a/drivers/remoteproc/pru_rproc.c +++ b/drivers/remoteproc/pru_rproc.c @@ -170,6 +170,23 @@ void pru_control_set_reg(struct pru_rproc *pru, unsigned int reg, spin_unlock_irqrestore(&pru->rmw_lock, flags); } +/** + * pru_rproc_set_firmware() - set firmware for a pru core + * @rproc: the rproc instance of the PRU + * @fw_name: the new firmware name, or NULL if default is desired + * + * Return: 0 on success, or errno in error case. + */ +static int pru_rproc_set_firmware(struct rproc *rproc, const char *fw_name) +{ + struct pru_rproc *pru = rproc->priv; + + if (!fw_name) + fw_name = pru->fw_name; + + return rproc_set_firmware(rproc, fw_name); +} + static struct rproc *__pru_rproc_get(struct device_node *np, int index) { struct device_node *rproc_np = NULL; @@ -230,6 +247,8 @@ struct rproc *pru_rproc_get(struct device_node *np, int index, struct rproc *rproc; struct pru_rproc *pru; struct device *dev; + const char *fw_name; + int ret; rproc = __pru_rproc_get(np, index); if (IS_ERR(rproc)) @@ -254,7 +273,21 @@ struct rproc *pru_rproc_get(struct device_node *np, int index, if (pru_id) *pru_id = pru->id; + ret = of_property_read_string_index(np, "firmware-name", index, + &fw_name); + if (!ret) { + ret = pru_rproc_set_firmware(rproc, fw_name); + if (ret) { + dev_err(dev, "failed to set firmware: %d\n", ret); + goto err; + } + } + return rproc; + +err: + pru_rproc_put(rproc); + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(pru_rproc_get); @@ -276,6 +309,8 @@ void pru_rproc_put(struct rproc *rproc) if (!pru->client_np) return; + pru_rproc_set_firmware(rproc, NULL); + mutex_lock(&pru->lock); pru->client_np = NULL; rproc->deny_sysfs_ops = false;