Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3618920rwi; Wed, 12 Oct 2022 04:48:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5DcLS1K4FTQ+4pKGaSeffF+COHq2wH/Uell285OjVI6tApn00rbH4IDUPIbQVckvuBxkNE X-Received: by 2002:a17:902:e982:b0:17f:ca1f:aa44 with SMTP id f2-20020a170902e98200b0017fca1faa44mr28317480plb.76.1665575279937; Wed, 12 Oct 2022 04:47:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665575279; cv=none; d=google.com; s=arc-20160816; b=IQZ9ws8FwC63byTiibjKifo2JuoVrohTNF0yXiaa0ALzrNVo0DSnORmf5qJqubVFkH hug6MuzudQXmgk7W84g0yYvb5/Hj7IT2p682JJoCOE+uaBtfoOiNUNw1MwImDvnAf4KM oYCitXgJhDp1M+Li7dj1zsOY80WUUEZlea68zChcX9IlzYE2OalSJ9Of+e0t9sGdt25r GvI/1GA8On4P/x4487d66DBkyEDmJypwcR59IE56Hi03CxZXZpJ8eK+2PUiJnm2eU6OO QeTYNz9gkilRRtzAfdmxBidfsrXxEHMz0kYdm/BZ005gQ1wwwPu+qakF6FgSXdsIYkII f/fA== 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=aBZmix5mN78scg9hnkAbo7v44ywBJRDrxSXesTutH9k=; b=DNoU4swhLxv14+aTiYqoKNOjhZjSA8Qweo9dEgeIMk8A3CQvFdHfjAgVA+cq3KAjiM dfIBLdP2hNwsCv6eLXUj0fcc4l6osU5/p/BZLHLCPuOiOMk54aJJBmihmzgg+rvnbhFB 9HwwaE5U0RmaCjYf99DFwONrr8Js+KctaQCzFWp/WEpjTA/DAKG5hoHzpLkRRTe+be+S RvDdLyQIuGhIky8c43Ow+uu2zI2F3rsV6fCsruwAXWGmce81Qf8YsRWoEoLDkGWih55T oA4JcsGKmYul+3IYEg8pdcZqspKu/8KDY7H2FxOeOQZ6ap4J8xdcUR2ILf9Hca+RsmWY 4mEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=eJvr3WnN; 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 j15-20020a170903024f00b0017f61ac5a53si18418222plh.111.2022.10.12.04.47.47; Wed, 12 Oct 2022 04:47:59 -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=eJvr3WnN; 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 S229825AbiJLLpo (ORCPT + 99 others); Wed, 12 Oct 2022 07:45:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbiJLLp3 (ORCPT ); Wed, 12 Oct 2022 07:45:29 -0400 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2579240A2; Wed, 12 Oct 2022 04:45:10 -0700 (PDT) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 29CBivx7037778; Wed, 12 Oct 2022 06:44:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1665575097; bh=aBZmix5mN78scg9hnkAbo7v44ywBJRDrxSXesTutH9k=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=eJvr3WnNJ5zXpiLB0/oZbzrEgZOCPk0f5M7mjPgehpqHr12FYJuD6IvhilMpfPqKW WJCXhwRK1MnkhQzLUFMhFRV+3SH4ajWu+M81cIJt6b+feSdOK9uxOFMa0Ua11EgpQU 1A1vjJOtZdaoXt357wQtC6uwPvBq/oVQ1eosQpio= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 29CBivFR115992 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 12 Oct 2022 06:44:57 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.6; Wed, 12 Oct 2022 06:44:56 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) 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.2507.6 via Frontend Transport; Wed, 12 Oct 2022 06:44:56 -0500 Received: from fllv0122.itg.ti.com (fllv0122.itg.ti.com [10.247.120.72]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 29CBiuM7016488; Wed, 12 Oct 2022 06:44:56 -0500 Received: from localhost (a0501179-pc.dhcp.ti.com [10.24.69.114]) by fllv0122.itg.ti.com (8.14.7/8.14.7) with ESMTP id 29CBitJl003376; Wed, 12 Oct 2022 06:44:56 -0500 From: MD Danish Anwar To: Bjorn Andersson , Mathieu Poirier , Krzysztof Kozlowski CC: Suman Anna , Roger Quadros , , , , , , , , "MD Danish Anwar" , Tero Kristo , "Grzegorz Jaszczyk" , Puranjay Mohan Subject: [PATCH v6 5/5] remoteproc: pru: Configure firmware based on client setup Date: Wed, 12 Oct 2022 17:14:29 +0530 Message-ID: <20221012114429.2341215-6-danishanwar@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221012114429.2341215-1-danishanwar@ti.com> References: <20221012114429.2341215-1-danishanwar@ti.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-4.4 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 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 Signed-off-by: MD Danish Anwar --- drivers/remoteproc/pru_rproc.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/remoteproc/pru_rproc.c b/drivers/remoteproc/pru_rproc.c index 3d1870e6b13b..15ffaeddd963 100644 --- a/drivers/remoteproc/pru_rproc.c +++ b/drivers/remoteproc/pru_rproc.c @@ -172,6 +172,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 rproc *rproc; @@ -230,6 +247,7 @@ 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); @@ -256,11 +274,25 @@ 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_no_rproc_handle: rproc_put(rproc); return ERR_PTR(ret); + +err: + pru_rproc_put(rproc); + return ERR_PTR(ret); } EXPORT_SYMBOL_GPL(pru_rproc_get); @@ -280,6 +312,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.25.1