Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1282364rdb; Mon, 19 Feb 2024 09:48:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLvYsrV8uy1hBGxeJd7RmuQ6mPHMSYX7VAftZ4U/PVXsxacA5mWAul+Y9QoflNFPZFQRW1243xktS8YDENQo2VLlZD16bm0618kdFwJQ== X-Google-Smtp-Source: AGHT+IEFqw1x0K0jGJetH89QZuWrUQxfN1SwkPISYLrnZ1yb6hfbhmBc+D3tpFNt6Rlt8R2eATnv X-Received: by 2002:a17:906:b81a:b0:a3e:8d17:ea94 with SMTP id dv26-20020a170906b81a00b00a3e8d17ea94mr2348652ejb.55.1708364921032; Mon, 19 Feb 2024 09:48:41 -0800 (PST) Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qf5-20020a1709077f0500b00a3ec9d2cdf5si551408ejc.452.2024.02.19.09.48.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:48:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71776-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=0CqQ10OD; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-71776-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 9A8D91F233BB for ; Mon, 19 Feb 2024 17:48:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA1364F1FE; Mon, 19 Feb 2024 17:46:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="0CqQ10OD" Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2068.outbound.protection.outlook.com [40.107.244.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB0FC4C3DB; Mon, 19 Feb 2024 17:46:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.68 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708364796; cv=fail; b=YO1aVmJqdtt146konyMjP7gmThsPHx07Uem7QLmERqsm35ZRfoZTYVS2O0PN50+HeL+p7MarvCg2EHVtHJE7F+upG1uj6yzsIGI3DRmg9mPmtzvu1QnORlLb6kA8OqFUyQZwGAfJJBJecEBtTH5kA9oqF2cdN3pi5ShouHFG/R4= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708364796; c=relaxed/simple; bh=5WkKrr5g217v7TIoQozlMStVoYW6tYiBnQucGNIpWEM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iwfGy27a9HM20JVI5YEeyICa/EGfS3/COJg3h/AGC1VKqtfnVQIEtXj/b2podZHbSHNP5jH02WcGAf6qG+Cs69A+TOUm0sxmOe8H8KkFG8WPmRjRb8NfJbFF5zkOrD8Qe2mJZ5gaJmmEGw7XuUrBkImkGnIbyuFOneqNnHAeEF0= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=0CqQ10OD; arc=fail smtp.client-ip=40.107.244.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VEeP1shtRRd7ab1b4kFCw7EEN39e6Ttamp8jplYijs1ACk/p/R43ethNharm/dRpKyjfpHxQV43EUSdIFp2ie60+E1n6dE10HluihAxcrSG41RZIgO3s+veEnSsMPnAC0/xXv6HOFVNnIQC2Lwb+F+1TPAjoob1pmYJQqSNiywLtthWjlKOBxUVeM/92pKD5AeY0SrIa33lZt2/omCd2bllorYuPM+mELG0ih/VjB11NV76lVpD9PWBAGPvjb1adia7anQebeL9bJb+NaHOF272qAlvNaYshq/z9v3VYaHOSZWcCf0ypILEgTQHA+QChnulLm120DEbzt28mQeHo1Q== 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=OCIlscyrZVP8ImE+qjqgUv5nqnzDxNC7BhEip53ddQ0=; b=lqqZ0aeV8Cz9+QEkMeMXV0dZ3g0uZTbGDxy5ZhptFQuQgtjWLgbfSYzIa4eiYxZdGwHgxCWL5Jp5fajCtDPpYqg6y4gs9OGsEKqTYARjiH1Z3sAfwSOFv75huan7kfck8fnoRyQPCbJ14gjsAST4rs4Ylh2fkbmwjSxkpg1pQbpbKZWJocLTJ4kt+QXy6fxPcaXEchIMs7YVGj/jKG6NcjfzDXDO5PoOsPT7/bk5zTo0pwQ7G3TmiVMJrnoGT2hD+sVsIvNVUi3P47ba381Dt99qPKTTOOalT3nyjIAvbw33LNsTVPkSDYA7/jXvabTL9pgJU8mlJOCvheScGusspw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OCIlscyrZVP8ImE+qjqgUv5nqnzDxNC7BhEip53ddQ0=; b=0CqQ10OD+OVmth0h/GKK+TlRJUJkJ5qc43IqG2lxc6kq/8MeyLb1WKc4HyUGj8RxvRDBu381RML6TPFlxpKu8jyEGHPP8UnPTgJCNcHmMeP9ABlZRF5lS52hhJJhjUWRlbfX/eLy1csUYPkeXVug2cm9/uRE9WKGKflGqlWWE/Q= Received: from DS7PR03CA0292.namprd03.prod.outlook.com (2603:10b6:5:3ad::27) by PH7PR12MB8108.namprd12.prod.outlook.com (2603:10b6:510:2bc::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.19; Mon, 19 Feb 2024 17:46:30 +0000 Received: from CY4PEPF0000EE32.namprd05.prod.outlook.com (2603:10b6:5:3ad:cafe::11) by DS7PR03CA0292.outlook.office365.com (2603:10b6:5:3ad::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.39 via Frontend Transport; Mon, 19 Feb 2024 17:46:30 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C Received: from SATLEXMB03.amd.com (165.204.84.17) by CY4PEPF0000EE32.mail.protection.outlook.com (10.167.242.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7292.25 via Frontend Transport; Mon, 19 Feb 2024 17:46:30 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 19 Feb 2024 11:46:28 -0600 Received: from xsjtanmays50.xilinx.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Mon, 19 Feb 2024 11:46:27 -0600 From: Tanmay Shah To: , , , , , , , CC: , , , Subject: [PATCH v11 4/4] remoteproc: zynqmp: parse TCM from device tree Date: Mon, 19 Feb 2024 09:44:37 -0800 Message-ID: <20240219174437.3722620-10-tanmay.shah@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240219174437.3722620-1-tanmay.shah@amd.com> References: <20240219174437.3722620-1-tanmay.shah@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE32:EE_|PH7PR12MB8108:EE_ X-MS-Office365-Filtering-Correlation-Id: 63389c6f-59ce-43a5-e4f2-08dc3172b460 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yQWg4Cs7Pw7oNJH8QMCG5TuMsroAaWCGgBl5RkqX8Xtwt0FDPbAWp5fmMgQogGvTvzmSjNFdPCg+GklLIWAY8DgjC/lbdJjapxRGFbpHfYK2PXshyyqntW8NriunZL+h1FtGr8FkqMIm0Q6Tiv5avlhfcnIGJa3Hh7JtJCfp50tRCyCaluI9Mhre94NQJyz8PRfjPiRhF6t0NiEjMhmuFcLYOGzuX0hOGlX1vVMRQ+sPAla1RnWCwoA/ya2z6rVzritR6abBlSTHDBQG3welxQV9ZOGK5EkyrrW8PTIgTiron2QK5wRPVeTEqRpLkU8L5QPNcVpKsHEUG1taxg7tUz25C8SgohbdRmlrXbtzmifotE+qeiQ1Hm3Ka8POYJGGa7XxChmdJRhKY8Gtj60hR5Adnbwi5nqBe4e5ef6wKz8Bjm24Zm3C8ZabHc3Pqbsz7d6OUYhHxWOK491C4a1I8t3EwDoFdRtZL0gqqIzTS3S7stuL9OmxVOtHMy6sXs/5+HOdGj3Xq1YBWaZhOaKbJovB3iBqtl8iwzG5q0lw15U0FbqnkEbueKvVV0bNcldCTrY9zRBozm9R1DdM/5tOE7chMq0viLDcGyEqIvcdvr2N265O3/l8tvIZFW/G23RC7S1X3AJf2UCQjssZE1SjS9+cgPOF788Kip9dUyefYhY= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(46966006)(40470700004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Feb 2024 17:46:30.0799 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 63389c6f-59ce-43a5-e4f2-08dc3172b460 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EE32.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8108 ZynqMP TCM information was fixed in driver. Now ZynqMP TCM information is available in device-tree. Parse TCM information in driver as per new bindings. Signed-off-by: Tanmay Shah --- Changes in v11: - Remove redundant initialization of the variable - return correct error code if memory allocation failed drivers/remoteproc/xlnx_r5_remoteproc.c | 112 ++++++++++++++++++++++-- 1 file changed, 107 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/xlnx_r5_remoteproc.c b/drivers/remoteproc/xlnx_r5_remoteproc.c index 42b0384d34f2..d4a22caebaad 100644 --- a/drivers/remoteproc/xlnx_r5_remoteproc.c +++ b/drivers/remoteproc/xlnx_r5_remoteproc.c @@ -74,8 +74,8 @@ struct mbox_info { }; /* - * Hardcoded TCM bank values. This will be removed once TCM bindings are - * accepted for system-dt specifications and upstreamed in linux kernel + * Hardcoded TCM bank values. This will stay in driver to maintain backward + * compatibility with device-tree that does not have TCM information. */ static const struct mem_bank_data zynqmp_tcm_banks_split[] = { {0xffe00000UL, 0x0, 0x10000UL, PD_R5_0_ATCM, "atcm0"}, /* TCM 64KB each */ @@ -757,6 +757,103 @@ static struct zynqmp_r5_core *zynqmp_r5_add_rproc_core(struct device *cdev) return ERR_PTR(ret); } +static int zynqmp_r5_get_tcm_node_from_dt(struct zynqmp_r5_cluster *cluster) +{ + int i, j, tcm_bank_count, ret, tcm_pd_idx, pd_count; + struct of_phandle_args out_args; + struct zynqmp_r5_core *r5_core; + struct platform_device *cpdev; + struct mem_bank_data *tcm; + struct device_node *np; + struct resource *res; + u64 abs_addr, size; + struct device *dev; + + for (i = 0; i < cluster->core_count; i++) { + r5_core = cluster->r5_cores[i]; + dev = r5_core->dev; + np = r5_core->np; + + pd_count = of_count_phandle_with_args(np, "power-domains", + "#power-domain-cells"); + + if (pd_count <= 0) { + dev_err(dev, "invalid power-domains property, %d\n", pd_count); + return -EINVAL; + } + + /* First entry in power-domains list is for r5 core, rest for TCM. */ + tcm_bank_count = pd_count - 1; + + if (tcm_bank_count <= 0) { + dev_err(dev, "invalid TCM count %d\n", tcm_bank_count); + return -EINVAL; + } + + r5_core->tcm_banks = devm_kcalloc(dev, tcm_bank_count, + sizeof(struct mem_bank_data *), + GFP_KERNEL); + if (!r5_core->tcm_banks) + return -ENOMEM; + + r5_core->tcm_bank_count = tcm_bank_count; + for (j = 0, tcm_pd_idx = 1; j < tcm_bank_count; j++, tcm_pd_idx++) { + tcm = devm_kzalloc(dev, sizeof(struct mem_bank_data), + GFP_KERNEL); + if (!tcm) + return -ENOMEM; + + r5_core->tcm_banks[j] = tcm; + + /* Get power-domains id of TCM. */ + ret = of_parse_phandle_with_args(np, "power-domains", + "#power-domain-cells", + tcm_pd_idx, &out_args); + if (ret) { + dev_err(r5_core->dev, + "failed to get tcm %d pm domain, ret %d\n", + tcm_pd_idx, ret); + return ret; + } + tcm->pm_domain_id = out_args.args[0]; + of_node_put(out_args.np); + + /* Get TCM address without translation. */ + ret = of_property_read_reg(np, j, &abs_addr, &size); + if (ret) { + dev_err(dev, "failed to get reg property\n"); + return ret; + } + + /* + * Remote processor can address only 32 bits + * so convert 64-bits into 32-bits. This will discard + * any unwanted upper 32-bits. + */ + tcm->da = (u32)abs_addr; + tcm->size = (u32)size; + + cpdev = to_platform_device(dev); + res = platform_get_resource(cpdev, IORESOURCE_MEM, j); + if (!res) { + dev_err(dev, "failed to get tcm resource\n"); + return -EINVAL; + } + + tcm->addr = (u32)res->start; + tcm->bank_name = (char *)res->name; + res = devm_request_mem_region(dev, tcm->addr, tcm->size, + tcm->bank_name); + if (!res) { + dev_err(dev, "failed to request tcm resource\n"); + return -EINVAL; + } + } + } + + return 0; +} + /** * zynqmp_r5_get_tcm_node() * Ideally this function should parse tcm node and store information @@ -835,9 +932,14 @@ static int zynqmp_r5_core_init(struct zynqmp_r5_cluster *cluster, struct zynqmp_r5_core *r5_core; int ret, i; - ret = zynqmp_r5_get_tcm_node(cluster); - if (ret < 0) { - dev_err(dev, "can't get tcm node, err %d\n", ret); + r5_core = cluster->r5_cores[0]; + if (of_find_property(r5_core->np, "reg", NULL)) + ret = zynqmp_r5_get_tcm_node_from_dt(cluster); + else + ret = zynqmp_r5_get_tcm_node(cluster); + + if (ret) { + dev_err(dev, "can't get tcm, err %d\n", ret); return ret; } -- 2.25.1