From patchwork Thu Jun 2 20:38:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tanmay Shah X-Patchwork-Id: 12868164 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCFDDC43334 for ; Thu, 2 Jun 2022 20:39:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239128AbiFBUjE (ORCPT ); Thu, 2 Jun 2022 16:39:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbiFBUi6 (ORCPT ); Thu, 2 Jun 2022 16:38:58 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2046.outbound.protection.outlook.com [40.107.94.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C87D657E; Thu, 2 Jun 2022 13:38:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S0WW/nmGrb89Qn0VFhW+p5U6XTnReK1huh5Qa8D13We5Ia4svlgeOryUFd3eP1F7AO++71b8mytlezfDlfUJ/AD6Qhz8JP7FKMJ89v2DVr7RexSdwl+cowyYrgNRxUqxIIrI48RBTa0QmOG1/AdqtkVVApJPjhdK5XPBcQELddYUp0qAR8HjeQvieemqossZPLjOare0+C+m9aUJJlvjEQjVLe0VOCPsZl8FI5FOZTGLLARTj8yTKkqij+ytGlzeq3TAhO7zygbLIB7Fhu1OJyRolgXCxH8iXXufjg17n6gyd6iQF5cvFw68SH6hPESfvXCZ29yw6DELlq/0OwSiqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o/QWFV8XMVSjrmQBPEZbtMKfLMpSxYQdqF7/+6fLjUc=; b=PlVFyRLWS5V3j2oVXKQQoFl8aQNSOrRIY0Kwl+iXqQpCJ0DskOKLm8QKql5SZ1/2U147T+HTYcweS5RxR3332lwMP0FqIlPLXfyurLXAu46kpCR+gCHJWKUgCqnvjXip5TMJd6edML+SDgdKUFfjXSnxihs5gQuiO/y3AAWzg2plDz6Livx/0inlpBIvGSqIBw929d1cPOhSNVofOsRDIlumABCmX/w0D1H8dxyTIuSHERqoprwpnRBol1lu5NLc6NF8Mv9gLehpjnF7rIzkD3Cl1k4Tns92tgWOYIT1/RRHwntTmHEz9OLeDghupOYX3bEkwmSuhumWvNhW1Kgv8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=linaro.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o/QWFV8XMVSjrmQBPEZbtMKfLMpSxYQdqF7/+6fLjUc=; b=bhMOnAWtwLapMsj+b3g2G97/smURXq3dBEICqQQgDBh2XtmPTxvCwyPZvpVm2z3VF8jc5IdK2UG/tZM+RjhwzwS/hH/d3rNTb6npOemEB0Tnp6AQEGfQSIqGRWD9EnFw2T3tKcT7wNzsugwCKUPkXfYWVwX+BeXm8loAK/ENMME= Received: from BN9PR03CA0345.namprd03.prod.outlook.com (2603:10b6:408:f6::20) by SA0PR02MB7163.namprd02.prod.outlook.com (2603:10b6:806:e1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Thu, 2 Jun 2022 20:38:53 +0000 Received: from BN1NAM02FT052.eop-nam02.prod.protection.outlook.com (2603:10b6:408:f6:cafe::e2) by BN9PR03CA0345.outlook.office365.com (2603:10b6:408:f6::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13 via Frontend Transport; Thu, 2 Jun 2022 20:38:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; pr=C Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT052.mail.protection.outlook.com (10.13.2.160) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5314.12 via Frontend Transport; Thu, 2 Jun 2022 20:38:53 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Thu, 2 Jun 2022 13:38:49 -0700 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Thu, 2 Jun 2022 13:38:49 -0700 Envelope-to: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, robh+dt@kernel.org, krzk+dt@kernel.org, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, openamp-system-reference@lists.openampproject.org Received: from [172.19.3.14] (port=53866 helo=xsjtanmays50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nwraj-0007MG-9v; Thu, 02 Jun 2022 13:38:49 -0700 From: Tanmay Shah To: , , , , , , CC: , , , , Subject: [PATCH v8 5/6] firmware: xilinx: Add RPU configuration APIs Date: Thu, 2 Jun 2022 13:38:33 -0700 Message-ID: <20220602203834.3675160-6-tanmay.shah@xilinx.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220602203834.3675160-1-tanmay.shah@xilinx.com> References: <20220602203834.3675160-1-tanmay.shah@xilinx.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fefd422f-fe5d-489a-03b3-08da44d7e899 X-MS-TrafficTypeDiagnostic: SA0PR02MB7163:EE_ X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OGi/iEcKiIl2jiK9bll24G0VgE7IiZK9abBj8EmuwkQ8HMNsYzbkAgyEs7QjHODDLphhVFALV3ZTBpuBs07L9OJFoC/j8WWZj8fOHcBcvpkqc4ckFovbiaqsxGwgd+QJEuzGB6rhT15K3nX8VUU8g/OgVlVdA+IeDyJg0mZXS4l984YaxMJAl3dgCS1RyaZDXorHR8r06WGPREt1aunmLewugY6UHqEN16JER5wZhbFfT4QU0jd9BNQSTOmPoYsLOLlyX628mcIkEeYS/yLhlZN65Zrgrmysx1fMYk/mTEJRbuxGF8qe8v7Qwlanw4r7F2aD0bKVsDuQqLTGGvoadkfij1fM5ftWt2rpDK2ttsDAKAW5XAjekD7BmfKj3EOjLIIxGYIfq9s/elRR6UKobBZ8j0Vi4rlsEsZYWPw1/U0LJ06nJu6sSVG5DIHqhtIhm3VgrUr1U/m6Ib6z4zBV01Cp1OrJkp9cpAqBFZt/IVBStQNmQGYQgFVUnTSxSMXOiwAZvceYMfbGj0q/tHZF2Od6xfncqKymNeeF+QXU1Hx+7k3iCjwnmTNcKkbMlFUNesl8qHNPCualxb4aGj4YF0HMUnB+jhYRq8iLrEq2AEAZ4AOStcvnuEE88lQhnUgQW7Y32EH5n3wLjeM/gafJhmyp+J3rFXbPPeQl8vwnZudd1lVOT6t0m5fpnaqb1vquRx80+nFQbTknDXPLDfrjYQ== X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(2616005)(44832011)(40460700003)(7049001)(316002)(26005)(110136005)(70586007)(70206006)(9786002)(36756003)(82310400005)(508600001)(5660300002)(2906002)(8936002)(7636003)(6666004)(7696005)(4326008)(8676002)(356005)(83380400001)(186003)(1076003)(426003)(336012)(47076005)(36860700001)(54906003)(102446001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2022 20:38:53.5783 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fefd422f-fe5d-489a-03b3-08da44d7e899 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT052.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR02MB7163 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org From: Ben Levinsky This patch adds APIs to access to configure RPU and its processor-specific memory. That is query the run-time mode of RPU as either split or lockstep as well as API to set this mode. In addition add APIs to access configuration of the RPUs' tightly coupled memory (TCM). Signed-off-by: Ben Levinsky Signed-off-by: Tanmay Shah --- Changes in v8: - None Changes in v7: - None Changes in v6: - None Changes in v5: - None Changes in v4: - None Changes in v3: - Add missing function argument documentation drivers/firmware/xilinx/zynqmp.c | 62 ++++++++++++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 18 ++++++++ 2 files changed, 80 insertions(+) diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c index fabdbac868f5..c66c9b48135a 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c @@ -1067,6 +1067,68 @@ int zynqmp_pm_release_node(const u32 node) } EXPORT_SYMBOL_GPL(zynqmp_pm_release_node); +/** + * zynqmp_pm_get_rpu_mode() - Get RPU mode + * @node_id: Node ID of the device + * @rpu_mode: return by reference value + * either split or lockstep + * + * Return: return 0 on success or error+reason. + * if success, then rpu_mode will be set + * to current rpu mode. + */ +int zynqmp_pm_get_rpu_mode(u32 node_id, enum rpu_oper_mode *rpu_mode) +{ + u32 ret_payload[PAYLOAD_ARG_CNT]; + int ret; + + ret = zynqmp_pm_invoke_fn(PM_IOCTL, node_id, + IOCTL_GET_RPU_OPER_MODE, 0, 0, ret_payload); + + /* only set rpu_mode if no error */ + if (ret == XST_PM_SUCCESS) + *rpu_mode = ret_payload[0]; + + return ret; +} +EXPORT_SYMBOL_GPL(zynqmp_pm_get_rpu_mode); + +/** + * zynqmp_pm_set_rpu_mode() - Set RPU mode + * @node_id: Node ID of the device + * @rpu_mode: Argument 1 to requested IOCTL call. either split or lockstep + * + * This function is used to set RPU mode to split or + * lockstep + * + * Return: Returns status, either success or error+reason + */ +int zynqmp_pm_set_rpu_mode(u32 node_id, enum rpu_oper_mode rpu_mode) +{ + return zynqmp_pm_invoke_fn(PM_IOCTL, node_id, + IOCTL_SET_RPU_OPER_MODE, (u32)rpu_mode, + 0, NULL); +} +EXPORT_SYMBOL_GPL(zynqmp_pm_set_rpu_mode); + +/** + * zynqmp_pm_set_tcm_config - configure TCM + * @node_id: Firmware specific TCM subsystem ID + * @tcm_mode: Argument 1 to requested IOCTL call + * either PM_RPU_TCM_COMB or PM_RPU_TCM_SPLIT + * + * This function is used to set RPU mode to split or combined + * + * Return: status: 0 for success, else failure + */ +int zynqmp_pm_set_tcm_config(u32 node_id, enum rpu_tcm_comb tcm_mode) +{ + return zynqmp_pm_invoke_fn(PM_IOCTL, node_id, + IOCTL_TCM_COMB_CONFIG, (u32)tcm_mode, 0, + NULL); +} +EXPORT_SYMBOL_GPL(zynqmp_pm_set_tcm_config); + /** * zynqmp_pm_force_pwrdwn - PM call to request for another PU or subsystem to * be powered down forcefully diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h index bce3465a70a4..ffc2cea7c604 100644 --- a/include/linux/firmware/xlnx-zynqmp.h +++ b/include/linux/firmware/xlnx-zynqmp.h @@ -490,6 +490,9 @@ int zynqmp_pm_request_wake(const u32 node, const bool set_addr, const u64 address, const enum zynqmp_pm_request_ack ack); +int zynqmp_pm_get_rpu_mode(u32 node_id, enum rpu_oper_mode *rpu_mode); +int zynqmp_pm_set_rpu_mode(u32 node_id, u32 arg1); +int zynqmp_pm_set_tcm_config(u32 node_id, u32 arg1); #else static inline int zynqmp_pm_get_api_version(u32 *version) { @@ -764,6 +767,21 @@ static inline int zynqmp_pm_request_wake(const u32 node, { return -ENODEV; } + +static inline int zynqmp_pm_get_rpu_mode(u32 node_id, enum rpu_oper_mode *rpu_mode) +{ + return -ENODEV; +} + +static inline int zynqmp_pm_set_rpu_mode(u32 node_id, u32 arg1) +{ + return -ENODEV; +} + +static inline int zynqmp_pm_set_tcm_config(u32 node_id, u32 arg1) +{ + return -ENODEV; +} #endif #endif /* __FIRMWARE_ZYNQMP_H__ */