Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1082468pxb; Wed, 6 Apr 2022 08:17:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYT4PdQZOzOQQILRm/MX5C24ue7H41cX58Xya7vqrD6RFfhN4dfoLCZOJ0KZFuoMsFTJr2 X-Received: by 2002:a17:90b:3652:b0:1ca:b7d1:16b3 with SMTP id nh18-20020a17090b365200b001cab7d116b3mr10640845pjb.34.1649258263771; Wed, 06 Apr 2022 08:17:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649258263; cv=none; d=google.com; s=arc-20160816; b=I15/ioYGbbw6j4Qg1ocktQCTso7+xDPBgWOZgTTK7lVG+M4xmL1FWLvADQdjyCnVWi WLLuCpmyJ53wXK4VQuUJH1SaxRVvmpUfIq9a29AGTNX6heCGJFneqqvmDblwHTXNDnlJ +jXG5ssVBvBhJsLg0Bs5SD8RFfIVilw2IlyMiH/pYMXWKrOJz/4o+iyCGNFER/eZcjmw 5ihFL6YPlgWBDrCgk7WI21xliOKDCVbPwhi7iBamMEYsrswW7j1XgdCJ++KDgJWU7ccM uUlkC0QrUUHcBuLTvGLfN7ZkMAeCDOyadZVO69ZyAPI/QpEmN1Ucje6X+olFIUGhOj/3 wsLA== 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=nzFj7t/nhoeIiijjMNRaiZ7QGlYQYWUrF56KDxQNvJXl4gNMb2QaU3IbhhxFYtBU+G zjY5PP3UdBMzA07c7dyMDQMqaLY86Pirp6Tu4jHtbcvnkmQ7ScAANkS+fD1AMkhEbbLi i8lVuAdOAU1ZO86ylUF+sYUrQXJH3s6Z9me0v0jmFGtzCN4NaYsJ0iqBz2jGmHqCsH0I pzPLs3mviMIlEgLGk88cKyU2rYknMkP4HQsxbptfi9GrzmtFc0C7Mm56Tsg2unBvaXf3 KEAnqiwSe0SZq8Psjphsq3o3V/RIt9OVlGt7h3y0gHxio7RULGgqMZUn+dycFYIOKwSv vRfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="A/ceEQ1+"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k190-20020a6384c7000000b003816043ee2fsi722040pgd.36.2022.04.06.08.17.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 08:17:43 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="A/ceEQ1+"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DA96B4EBC16; Wed, 6 Apr 2022 06:12:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232782AbiDFNLL (ORCPT + 99 others); Wed, 6 Apr 2022 09:11:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232672AbiDFNK4 (ORCPT ); Wed, 6 Apr 2022 09:10:56 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBA095F38F1; Wed, 6 Apr 2022 02:45:37 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 2369iFWd108739; Wed, 6 Apr 2022 04:44:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1649238255; bh=zgzNCrg2jxb2fMhf7Xl7w052aCeYSvcx7BoVAy9SRiQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=A/ceEQ1+xCVGdMhG4IJWdicZYBXElFeYzWE175OdYmLX9imSiL6NsIx+50xmiNF5+ PKHdnXubjD7KJ5kZBoQr+d1VMAVMtlfyvR/80ZAToKlRuaJyGJSEFhLwFEHHqTU1yV r0oTS7WW+Ck1D/D5DovH55wjQGqLHUJcAG8x8tq8= Received: from DFLE111.ent.ti.com (dfle111.ent.ti.com [10.64.6.32]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 2369iFdg014796 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 6 Apr 2022 04:44:15 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Wed, 6 Apr 2022 04:44:15 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE105.ent.ti.com (10.64.6.26) 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; Wed, 6 Apr 2022 04:44:15 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 2369iDtw025691; Wed, 6 Apr 2022 04:44:14 -0500 From: Puranjay Mohan To: CC: , , , , , , , , , , , , , , Subject: [RFC 05/13] remoteproc: pru: Configure firmware based on client setup Date: Wed, 6 Apr 2022 15:13:50 +0530 Message-ID: <20220406094358.7895-6-p-mohan@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220406094358.7895-1-p-mohan@ti.com> References: <20220406094358.7895-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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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