Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp125012iof; Sun, 5 Jun 2022 23:06:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywuXCG5Ql9dFq77rVMoIODIAV6/Nz7CWN36siDJKyaa4AAvRZMR2ASTDt0ZonBEeiZolfQ X-Received: by 2002:a17:902:7088:b0:167:78c0:e05e with SMTP id z8-20020a170902708800b0016778c0e05emr5106340plk.149.1654495610018; Sun, 05 Jun 2022 23:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654495610; cv=none; d=google.com; s=arc-20160816; b=FmOvkj9W59ux22vyGLJQNCyPL0JLDTtVP07wnwn7hmszSx79RLEjm3q9NQM1HWaKdg yUMmOWAXyftRMi6QfhNkjeI29U61V7lcN1gakkXVWsGb/YzNbD1dzJfxSj5W7VHcmA0d NfFSz03Fwx/BzQmupgmjBNzpNIrPCPUrqXo2l/O+7PdQj3OlFASiQ/r88gyMBIEKVyv9 husJAqq+AlqB/nBRJ9/8h8t4RWj1Bqxo+hqRCaSPr6E2KbK277Uy3vPlg9purhARW1Bf rg9xweczvv0WFSipUWeZZac09n1/EFcOykJdwZzE5HlaNEg5C/sL8TFW9DKmSPwwz9y5 MaTg== 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=CqLSV29OBgII/BZeccelCD97lBnrJ1x/n8Lt2OWvLUrviAkQurtVR+/ufpt49ocHbG ciDubz2i5YIRfec+7uVQ61bwMSkX3Ub2l4RicHImMmO/CrEVI08QLJOV93do9KGTNLJg cEx282e8Oo4So7N7RAJS1qiQ6fiQy1QbdH8z0VwWSeJbTgeWk0h+KeE4W/C+IB6mqLuf IOWO4jRf863JYtGvPdVPrBmZ6XRKS1Bx92y2yJ/6O09TuIR922CEl5Hyfx3qwy3cUq3c IlF937lBozquVV1TippT2R0go7FQwNU7qFYKgJGGYFTQVGMwJHHHBSQz4a0cH/zhJGry EXHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=Hxsj1qCz; 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 bc14-20020a656d8e000000b003fba60e01e1si21977737pgb.546.2022.06.05.23.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 23:06:50 -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=Hxsj1qCz; 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 57AD6E3DE5; Sun, 5 Jun 2022 21:56:20 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244239AbiFCMPy (ORCPT + 99 others); Fri, 3 Jun 2022 08:15:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244206AbiFCMPm (ORCPT ); Fri, 3 Jun 2022 08:15:42 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0C6239826; Fri, 3 Jun 2022 05:15:41 -0700 (PDT) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 253CFakr054419; Fri, 3 Jun 2022 07:15:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1654258536; bh=zgzNCrg2jxb2fMhf7Xl7w052aCeYSvcx7BoVAy9SRiQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=Hxsj1qCzX2GqdP3jxvNvtWROGAm4rIR52j805Lu1I0imP+D/AwQEKOnYsRWTyM/Oz BKt4M2sE0HwPPAJChR/KNaSbLc3tD6OvaHiPCYW6VLBW7Qm1HN8+XznKkB9502bk0N 8tFZPRIVue84hOiO8OOTa+y2PlDoNDslihsq7VPU= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 253CFa2x031518 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Jun 2022 07:15:36 -0500 Received: from DLEE102.ent.ti.com (157.170.170.32) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Fri, 3 Jun 2022 07:15:35 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE102.ent.ti.com (157.170.170.32) 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; Fri, 3 Jun 2022 07:15:33 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 253CFW5q121332; Fri, 3 Jun 2022 07:15:33 -0500 From: Puranjay Mohan To: CC: , , , , , , , , , , , , , , Subject: [PATCH v4 5/6] remoteproc: pru: Configure firmware based on client setup Date: Fri, 3 Jun 2022 17:45:19 +0530 Message-ID: <20220603121520.13730-6-p-mohan@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220603121520.13730-1-p-mohan@ti.com> References: <20220603121520.13730-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=-3.1 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=unavailable 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