Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1539806iof; Tue, 7 Jun 2022 07:26:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNsMgZc8cm7auykeZNomEFuvNgpDtSamvGmR8oTMLeDeJnhXadypHcz/FqP5ETJZCYuZC2 X-Received: by 2002:a17:906:2556:b0:70d:9052:fdec with SMTP id j22-20020a170906255600b0070d9052fdecmr22093065ejb.1.1654611978137; Tue, 07 Jun 2022 07:26:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654611978; cv=none; d=google.com; s=arc-20160816; b=MFiI/8P9o4EiKQvEnZ0+EX/AUAiLuCYWlzkggJkXOpjuhOrvaG3Atj7dOg4/FuQmpL 1X8OseWI4M637/xauOwKLRuXw/V1bqvSd60XwjSd0ICVvcM8/+zne4fqPhTTEi8A62Qu bwX5HJ0g8V6bUsZiY8OcLxLzFzP1CczVa/NnzH4GoOL7Woq+55TsjGG2TskdKfLtxxVt vbuYT+nTTl58PsLCIYd2uyskeIk/sq1AcNYdbIYrypYXu3peP5tDhl/KOJRUmnBmTXKm GMc0qE7walRuYmLXFDp/mWRf80UEoyYayaVd6RCnEdohj4/4KjNOtgXmt23eTfO4v36x x7JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zgzNCrg2jxb2fMhf7Xl7w052aCeYSvcx7BoVAy9SRiQ=; b=R8qeQxjFVyoldS2ZEJYOsYmPCZe6upXLB6jnDvTrT1+Xc68wr67cyb358P2Aw/mZsT uIOI4wvcOZnohMsBuP3zTv8n/aaKTQhCgC11/mqx6CsmxNdwCjxATIcOeV0doHA0hQ1w gq70jx3rwOVi1SrId4XfAd16b5skyR9A98k8zs1H1hE9gNOI4ia5S+/G6IcbSGYorRS8 fDr5XUPvsRN3Y+m+UIEFF6d55z4jcVYxvpatgeAVfi0oh0eUuB9ytl9HSRVS7v+N645i cr2SZ4e0CD6P+0XOSjSO9IVl/YjGjWhpaTHlACviUROxqKOXPFcjpOXHKtRcRm/MNLT4 hXuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=fhdvM5EV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x11-20020a05640226cb00b00430262e2b6dsi12485371edd.206.2022.06.07.07.25.48; Tue, 07 Jun 2022 07:26:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=fhdvM5EV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236564AbiFGE5Z (ORCPT + 99 others); Tue, 7 Jun 2022 00:57:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236675AbiFGE5L (ORCPT ); Tue, 7 Jun 2022 00:57:11 -0400 Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 057FE1C8; Mon, 6 Jun 2022 21:57:09 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 2574v5l4049056; Mon, 6 Jun 2022 23:57:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1654577825; bh=zgzNCrg2jxb2fMhf7Xl7w052aCeYSvcx7BoVAy9SRiQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=fhdvM5EV3iyA8qC8Zh7kpoJaINMEVYsuHWQ2cYuLMmz6EJS6vjhmrTTxk3qFLpAg7 k2tKH8yno/xvXpa5EVdEtsDE2vBASn2mKhScwSTMR4cbyW/3W58nu7mCJ7FSKEYFb2 rj1BYBAsZF2ymGjZxScbgdEtSfK20YaD18wUfhhI= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 2574v541081324 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 6 Jun 2022 23:57:05 -0500 Received: from DFLE114.ent.ti.com (10.64.6.35) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Mon, 6 Jun 2022 23:57:05 -0500 Received: from lelv0326.itg.ti.com (10.180.67.84) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Mon, 6 Jun 2022 23:57:05 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 2574v4hv025226; Mon, 6 Jun 2022 23:57:04 -0500 From: Puranjay Mohan To: CC: , , , , , , , , , , , , , , Subject: [PATCH v5 5/6] remoteproc: pru: Configure firmware based on client setup Date: Tue, 7 Jun 2022 10:26:49 +0530 Message-ID: <20220607045650.4999-6-p-mohan@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220607045650.4999-1-p-mohan@ti.com> References: <20220607045650.4999-1-p-mohan@ti.com> MIME-Version: 1.0 Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 Signed-off-by: Puranjay Mohan --- drivers/remoteproc/pru_rproc.c | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c index d06b763e995e..2977eb50631b 100644 --- a/drivers/remoteproc/pru_rproc.c +++ b/drivers/remoteproc/pru_rproc.c @@ -171,6 +171,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; @@ -231,6 +248,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; try_module_get(THIS_MODULE); @@ -257,7 +276,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); @@ -277,6 +310,8 @@ void pru_rproc_put(struct rproc *rproc) pru = rproc->priv; + pru_rproc_set_firmware(rproc, NULL); + mutex_lock(&pru->lock); if (!pru->client_np) { -- 2.17.1