Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2261260rwl; Fri, 6 Jan 2023 04:14:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXuftNHnUNZtG7JtbXKLcON2t36ry6J57xE2rQ0fx+9hFnJ9u3hMxY2mqPCTXm1gMTaxQ7Ul X-Received: by 2002:a17:907:d08d:b0:7aa:76a:fb3 with SMTP id vc13-20020a170907d08d00b007aa076a0fb3mr53354242ejc.66.1673007289960; Fri, 06 Jan 2023 04:14:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673007289; cv=none; d=google.com; s=arc-20160816; b=aNSiZkbG61C8cR3jKJt04UCbWxg/CyV1D2N2rGSWBRkMos3+L9jQl7CXIbJ1RKu7Ua dc+C0iFxFHexplr9OsuvqBe6w/z1rV4XvL6lS7os1mWMbreL+w5jIOVc+IwfXKLvZMAl Yb//S5RxDcGNUFatpLS7QRvf46gpV3meCKzfxl+1xwUQclFJykG6t5h79fbo0tmEUvLr 0acFCLxpvb5nFKtnrWSoRQ9bRC+RvQ7I5ZiBsn/fUNWxJlNkHaC5FMT/qc7fRlSgwUFF zN94bG8hwqmgcpcpforRXhqeZbMA55NdAUUa0vHcVi81mNeU8/SGNGYMmxiDQVDt+zt6 9Z8A== 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=uTiut5o/7iFdu8/u+NPuwcc+4LBeafBX8Rz7JMBS3zI=; b=eGevRLHz9V9bzi00cIBW333Mbj9rkEtoWEE58zdZIvlXATV3JsaXB8e8jFjs5sJ2kN wobP7kMmY062uKV75W3kYVlL3pN2cS7/DhE8N1y0o6gJSUgGvbgzlwjvZtmOZug4twtJ H9MLX/Q2ihXqAoVWqXZuWUb8+f6686RQVX40QLsm1W9jgw59oNkhFHc4LBJEtcllOcU+ Tf8A9fKNgAT0QXJCgqsFWEnsMzYK0GVrywKDxVUh0B2s+fGXBGdm23RQcBTgsAGT/Wbd yBVJarQevhtN67N5tvcD/i5PZ1ldBy61ssHwu6LHvr5H/KsPwkLiMtfCKNt8MZy6jvAN T/yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=YqaHGNAN; 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 gn11-20020a1709070d0b00b007c13387a548si1395164ejc.26.2023.01.06.04.14.36; Fri, 06 Jan 2023 04:14:49 -0800 (PST) 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=YqaHGNAN; 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 S233252AbjAFMLv (ORCPT + 54 others); Fri, 6 Jan 2023 07:11:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233101AbjAFMLS (ORCPT ); Fri, 6 Jan 2023 07:11:18 -0500 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D14B5736D9; Fri, 6 Jan 2023 04:11:15 -0800 (PST) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 306CB3ua099628; Fri, 6 Jan 2023 06:11:03 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1673007063; bh=uTiut5o/7iFdu8/u+NPuwcc+4LBeafBX8Rz7JMBS3zI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=YqaHGNANO0nf47w2o9bZFTYV56O/kDwGMct/9U1Bvh+U4T+QNEURqvREY6+rcHZnk OP8YziWpcx0FQi1Zk09iW98Rl5kZoJo0Vu/IAbKDzY6kUUizf2cun98aoutk9Ub9Iz j9gHhiO4Nyh/ga4sJ+aLGtpY1hIgB/8mpS36SPng= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 306CB39P119074 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 6 Jan 2023 06:11:03 -0600 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.2507.16; Fri, 6 Jan 2023 06:11:03 -0600 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.2507.16 via Frontend Transport; Fri, 6 Jan 2023 06:11:03 -0600 Received: from fllv0122.itg.ti.com (fllv0122.itg.ti.com [10.247.120.72]) by lelv0326.itg.ti.com (8.15.2/8.15.2) with ESMTP id 306CB3Lu020441; Fri, 6 Jan 2023 06:11:03 -0600 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 306CB2Z2028627; Fri, 6 Jan 2023 06:11:02 -0600 From: MD Danish Anwar To: Mathieu Poirier , Krzysztof Kozlowski , Rob Herring CC: Suman Anna , Roger Quadros , "Andrew F . Davis" , , , , , , , , MD Danish Anwar Subject: [PATCH v14 6/6] remoteproc: pru: Configure firmware based on client setup Date: Fri, 6 Jan 2023 17:40:46 +0530 Message-ID: <20230106121046.886863-7-danishanwar@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230106121046.886863-1-danishanwar@ti.com> References: <20230106121046.886863-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. Signed-off-by: Suman Anna Signed-off-by: Tero Kristo Signed-off-by: Grzegorz Jaszczyk Signed-off-by: MD Danish Anwar Reviewed-by: Roger Quadros --- 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 f6ea445d2fa2..b76db7fa693d 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; @@ -224,6 +241,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); @@ -249,11 +267,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); @@ -273,6 +305,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