From patchwork Mon Sep 21 16:14:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Levinsky X-Patchwork-Id: 11790385 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0095359D for ; Mon, 21 Sep 2020 16:14:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1BDD206FB for ; Mon, 21 Sep 2020 16:14:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=xilinx.onmicrosoft.com header.i=@xilinx.onmicrosoft.com header.b="lnbpK6j8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728077AbgIUQOU (ORCPT ); Mon, 21 Sep 2020 12:14:20 -0400 Received: from mail-dm6nam10on2081.outbound.protection.outlook.com ([40.107.93.81]:12385 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727914AbgIUQOT (ORCPT ); Mon, 21 Sep 2020 12:14:19 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mw+CHosKTdehpQead/TLvQs7Fgtg3Z9rU2OKQ4EszWpEfCbQ4ImbSBoLXwP2inVGbX4rJoin8nOCclsBuferdwskKt/zXsjLx1+4PPHWJAHN8Lq1ZOdneGEaBS7NxpwMln7rV5l34BkACRKJqSqkYJbeSsMWnNqSQWDaPU4b5ni8MY2Kl68VY/Zrc+1BsUwZtIWYYJtQAABAnaIm0+lZlwdjiXkn9xmjZ90tuRzePuTVY/zB41bAhgGbtnBN5F6Ux60KOaCAs41/ycQT78wJVmZJt6ez32clrehizWJOancUvFlCrDhNsUM3p9BV/gJDU8tq811OruVE3RTya7nm4Q== 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-SenderADCheck; bh=ogHvixDvPvbJmCfm9PXktN6mt2iU69iG4kwJAU8l84s=; b=KMp3lBxkgMkzeenoUCCBPNEdYJQML+n/cOA/6d+VQt0CZEdEBb7ofgmHC/NV7zji9dCJpv/mqNcptyRErcQ9gm7heiBXgApQo5koCM9pzFjNk7+c1SDyMpx5I0qbQKu8o0xNA4kmfFyZ+J9oYNHUOOUCRzOFgvwC8lbG+roUHaD798ekmZ/ooUGL+WtnqVzUfECIj+xEd9y6nsHWey6vvcpLhJjpEnoaJ2ACqIXGrQy487S7PoBg5G1b1CxI2P6W6OtscPQDum0+ABKb9ud9XhsDIFyJ8mg7Sg3Y12dK0l9ovWq4P77kH6d+VCVdo7lEofBM2e1+zEgULOW1y5CKlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.60.83) smtp.rcpttodomain=lists.infradead.org smtp.mailfrom=xilinx.com; dmarc=bestguesspass 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=ogHvixDvPvbJmCfm9PXktN6mt2iU69iG4kwJAU8l84s=; b=lnbpK6j8yOe3t9XW+HiDHkDNciAgOgxSReEmi4iZHarNTFNUcgL5wvmSolnZyDzDtTHUMHEEdIKufUamp0GN2ksSx6kxLRuhd2vzJvwv1r86Z5XXa89T/pNhmVGu8rBh6kjH/oniOAuwqdfYMR8/H9XwD6tZsClCnq2kI/ML9Ho= Received: from SN4PR0501CA0038.namprd05.prod.outlook.com (2603:10b6:803:41::15) by SN6PR02MB5678.namprd02.prod.outlook.com (2603:10b6:805:e8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.17; Mon, 21 Sep 2020 16:14:16 +0000 Received: from SN1NAM02FT035.eop-nam02.prod.protection.outlook.com (2603:10b6:803:41:cafe::22) by SN4PR0501CA0038.outlook.office365.com (2603:10b6:803:41::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3412.9 via Frontend Transport; Mon, 21 Sep 2020 16:14:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; lists.infradead.org; dkim=none (message not signed) header.d=none;lists.infradead.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by SN1NAM02FT035.mail.protection.outlook.com (10.152.72.145) with Microsoft SMTP Server id 15.20.3391.15 via Frontend Transport; Mon, 21 Sep 2020 16:14:15 +0000 Received: from [149.199.38.66] (port=36692 helo=smtp.xilinx.com) by xsj-pvapsmtpgw01 with esmtp (Exim 4.90) (envelope-from ) id 1kKOS2-00058l-C1; Mon, 21 Sep 2020 09:14:02 -0700 Received: from [127.0.0.1] (helo=localhost) by smtp.xilinx.com with smtp (Exim 4.63) (envelope-from ) id 1kKOSF-0004ec-KA; Mon, 21 Sep 2020 09:14:15 -0700 Received: from xsj-pvapsmtp01 (smtp3.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id 08LGE6rt008432; Mon, 21 Sep 2020 09:14:06 -0700 Received: from [172.19.2.206] (helo=xsjblevinsk50.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1kKOS6-0004bU-I3; Mon, 21 Sep 2020 09:14:06 -0700 From: Ben Levinsky To: sunnyliangjy@gmail.com, punit1.agrawal@toshiba.co.jp, stefanos@xilinx.com, michals@xilinx.com, michael.auchter@ni.com Cc: devicetree@vger.kernel.org, mathieu.poirier@linaro.org, emooring@xilinx.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, robh+dt@kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v15 3/5] firmware: xilinx: Add RPU configuration APIs Date: Mon, 21 Sep 2020 09:14:04 -0700 Message-Id: <20200921161406.11929-4-ben.levinsky@xilinx.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200921161406.11929-1-ben.levinsky@xilinx.com> References: <20200921161406.11929-1-ben.levinsky@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.2.0.1013-23620.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 376507d0-70c4-4813-1bad-08d85e4962fb X-MS-TrafficTypeDiagnostic: SN6PR02MB5678: X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:179; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ac6Dc/sOa8/YvAlcXHQZDAJPSlJ/Yo5FpriisWp68zShM5Z4myLvff7sckcBmsMpIbDNb2aY5dgoPDhqLUcZzJ+K6Y3fs/HPdiNKgT0eiAPA8r/HstejVvlOKCZvRVDVhDiwlHCYFGdqOzIRxjqMjLXthnXF67xRL1PsAbk1GNnfaDyy/vfpOeyK07Z615xy7duf4SuR2M6ulRNy0Zeh/Hlf92xvwQpeOywwta0/QwAfZuPLiXcEJf2yCFaOel7qNkW/elUN44RqOLWkwjoKqxSogTvSygaySxjW1XQ8F+CQ8ZOFWQvOuguGcHNrJQaiPsFW4aqeNuTrbj/9OV9U4yS03XeMuW4Io27wYNYvTo1B9zUN+g+PHGOgE2+/RZFgktFxx1rKUnbEvNP02mDVyw== X-Forefront-Antispam-Report: CIP:149.199.60.83;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapsmtpgw01;PTR:unknown-60-83.xilinx.com;CAT:NONE;SFS:(396003)(136003)(39860400002)(346002)(376002)(46966005)(478600001)(8936002)(5660300002)(9786002)(81166007)(83380400001)(1076003)(356005)(316002)(70586007)(8676002)(4326008)(2906002)(70206006)(36756003)(82740400003)(186003)(7696005)(47076004)(44832011)(2616005)(336012)(26005)(82310400003)(426003);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2020 16:14:15.9062 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 376507d0-70c4-4813-1bad-08d85e4962fb X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.60.83];Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-AuthSource: SN1NAM02FT035.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR02MB5678 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org 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 --- v3: - add xilinx-related platform mgmt fn's instead of wrapping around function pointer in xilinx eemi ops struct v4: - add default values for enums v9: - update commit message - for zynqmp_pm_set_tcm_config and zynqmp_pm_get_rpu_mode update docs for expected output, arguments as well removing unused args - remove unused fn zynqmp_pm_get_node_status v11: - update usage of zynqmp_pm_get_rpu_mode to return rpu mode in enum - update zynqmp_pm_set_tcm_config and zynqmp_pm_set_rpu_mode arguments to remove unused args v12: - in drivers/firmware/zynqmp.c, update zynqmp_pm_set_rpu_mode so rpu_mode is only set if no error - update args for zynqmp_pm_set_rpu_mode, zynqmp_pm_set_tcm_config fn arg's to reflect what is expected in the function and the usage in zynqmp_r5_remoteproc accordingly - zynqmp_pm_get_rpu_mode argument zynqmp_pm_get_rpu_mode is only set if no error --- drivers/firmware/xilinx/zynqmp.c | 61 ++++++++++++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 18 ++++++++ 2 files changed, 79 insertions(+) diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c index a966ee956573..b390a00338d0 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c @@ -846,6 +846,67 @@ 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 + * @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 6241c5ac51b3..79aa2fcbcd54 100644 --- a/include/linux/firmware/xlnx-zynqmp.h +++ b/include/linux/firmware/xlnx-zynqmp.h @@ -385,6 +385,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 struct zynqmp_eemi_ops *zynqmp_pm_get_eemi_ops(void) { @@ -549,6 +552,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__ */