From patchwork Mon Oct 31 07:38:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MD Danish Anwar X-Patchwork-Id: 13135 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2165816wru; Mon, 31 Oct 2022 00:41:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WB9mON5bnvaaQ+zuA9YU4iL8uZYKPkMFzfydgRLLi17e5mXHuFOyOOoKNhjY7UXUe5WpV X-Received: by 2002:a05:6402:b0e:b0:461:f7a8:3e3a with SMTP id bm14-20020a0564020b0e00b00461f7a83e3amr12304552edb.372.1667202105569; Mon, 31 Oct 2022 00:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667202105; cv=none; d=google.com; s=arc-20160816; b=vSXbbK9UbKo3oJ6pwbqBkP8kviolzMOX0AeVjPkvlV1DcNIH5z5eltJuHI5oaKlsq/ 0MFcxzJcPZl3fxIpNIlzAuVuH/4MDXnVKowLgyphFEWofBcW/QtYkNT8xGrZAJ3pdCaM Ly9m0b3O/iOJGTidjvCBVRdtVrnK9XCth5PDWSJUO/AMuK+YISdIg+iarllIvZPzCuOV o/gw7SHdPcg6VEDrL/6O8Qfiq5KEkS0P30bdXL7PErBy/M33CtYLxLMjnKkLAHXZkyFh EwFee4Wf0ynwlJY/oSaJEAmDeTbUEuW1J4Kd4sS/hRadPk1c+qkQ406dQ/L66dndF21y GRnA== 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=t9K0QbxgOgax5BPq1XYIr5+lmgQPmIw1A12iOBZ6gDWItmtT8IC7dDp4/R6laKMDtc 4aFsNC03hw13kJC7J8KwyoFXKGkoGgtp5Xj8Rf7eU2JzIXAhOgOA+HIwPoJjJN3MQcvW r2bx8EITcXEcMMvLXVWibrVCQ+Mc9iM7M83tZ3+JnMkwNXeYU78hinX2a04vQKHLGxUK A6RlhF9wo7NJVqOm/OTjlKI4oQRPMmW+0vJhBdWS5+uhAPmUySGTg8hEArTGifiJ4ttc TGJLVjtiMd4hFW5h57lk7dOm5cmwk2j90e2chKFRMRQeYb1QIoNiS8ntsYZ/5UcF4ODd dQoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=f4dit9c1; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c37-20020a509fa8000000b0045c7c7b95easi7020497edf.73.2022.10.31.00.41.21; Mon, 31 Oct 2022 00:41:45 -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=f4dit9c1; 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 S229695AbiJaHig (ORCPT + 99 others); Mon, 31 Oct 2022 03:38:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229728AbiJaHiZ (ORCPT ); Mon, 31 Oct 2022 03:38:25 -0400 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5B81224; Mon, 31 Oct 2022 00:38:24 -0700 (PDT) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 29V7cIV5045496; Mon, 31 Oct 2022 02:38:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1667201898; bh=aBZmix5mN78scg9hnkAbo7v44ywBJRDrxSXesTutH9k=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=f4dit9c1m4JcN7o+hJkHSxgEINtVl02oLqy+9zOcVgF6r6gAzYnL4yhxFrPMqIbeM ymfaxrsoGMbCBfP6D10jYEeD3AHrnDwHrVysv/REfKWdLmQgCUy2wTNBvhtQoG97o2 UtkqHExsPQH3Ka+Pqc9/vKUwfWGaDEindhJPtX7k= Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 29V7cIrI015546 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 31 Oct 2022 02:38:18 -0500 Received: from DFLE108.ent.ti.com (10.64.6.29) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.6; Mon, 31 Oct 2022 02:38:18 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE108.ent.ti.com (10.64.6.29) 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; Mon, 31 Oct 2022 02:38:18 -0500 Received: from fllv0122.itg.ti.com (fllv0122.itg.ti.com [10.247.120.72]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 29V7cIgL104913; Mon, 31 Oct 2022 02:38:18 -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 29V7cGJm004447; Mon, 31 Oct 2022 02:38:17 -0500 From: MD Danish Anwar To: Mathieu Poirier , Krzysztof Kozlowski , Rob Herring CC: Suman Anna , Roger Quadros , "Andrew F . Davis" , , , , , , , , MD Danish Anwar Subject: [PATCH v7 5/5] remoteproc: pru: Configure firmware based on client setup Date: Mon, 31 Oct 2022 13:08:01 +0530 Message-ID: <20221031073801.130541-6-danishanwar@ti.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221031073801.130541-1-danishanwar@ti.com> References: <20221031073801.130541-1-danishanwar@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-5.5 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748188115139956069?= X-GMAIL-MSGID: =?utf-8?q?1748188115139956069?= 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 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 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) {