From patchwork Wed Mar 16 13:58:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Gupta X-Patchwork-Id: 12782720 X-Patchwork-Delegate: viresh.linux@gmail.com 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 CA9C2C433EF for ; Wed, 16 Mar 2022 13:59:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356421AbiCPOAR (ORCPT ); Wed, 16 Mar 2022 10:00:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356355AbiCPOAK (ORCPT ); Wed, 16 Mar 2022 10:00:10 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2081.outbound.protection.outlook.com [40.107.237.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E06166CA0; Wed, 16 Mar 2022 06:58:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=btUNMUkSwgbhnYNoZXhBGvVpLKkXQZshA29sDySbNBcLIR6pYppXCSn2NtBvOnr9qRAfc6cO0VIeHMAwngL2nQoHfAB/PLRrqDUyFPlgyxTQ0Siz85LOQMDSim2ynsjb/Hw0TCp7xrISuLGl0duLYyDNJ8Obj68nXkwLM0qhiU+HXsD2IXxLL3gr5VemVwSNjtVQvdLjPDR3qizdHUxokf5l2dTSBB87kFap1o+SqRoQvZ9IkG9CTGqfU4qO4N+QdWoUSDjpl3CzVw4pq8So4Q92auksLdm4Ilvo7hkT3Ud3+UtR39RtqN7nxTzqAlIfSFEjE/5o0ZNSh0hXH3tEMg== 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=vaSt2YuyCgTMOz8xoVKQnbq/RKA9LOyWJI5LPUGvaFQ=; b=UkmBTUWsvUIUZ7O76mAZq3+aa9AvkPElM3q+FjSkwzXboHTMnG/f0e5i7FI8fkdnws1sz40H9B+bypZHFJJcnlKyTbJRUKKpImFX+75xjzFs4FyQiZ8nLlQ7cGRW+hC0MRN9X4D4WygV5ZNRTvlV88ygVyUFi8jM1pX0TW7aNwlt6cJZWjFoO+2gZtzB4/cLWwcqN43O4k/uSF1c975Xi7941Xvu3Ca3/eVUxpK7Ezp4xtdEwa3IXknyqFuZ3QDh/7VkY+xPzITFaaZuLUARFGpm6Jah+isaFykWToFpe+KoleRy5H0GqPBtn3Zz6diFSn7hlv0bbEb5PiF0BDf4Aw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vaSt2YuyCgTMOz8xoVKQnbq/RKA9LOyWJI5LPUGvaFQ=; b=oJInX4Tyl3+Q5WYvo3pdqxmp1v8Hs8I94nzEWs5qmqIoYeVmkqI8+EHWvLsTzJH9wE+kaq6kJCQU3/IzlPWvkzj6Ic7Kpt5Ktisj+0mCpbF18HsfSy4ySB1P7Vt3VIiqz7xjsZg/M7JiQHRkZXfhbc0VnY0Ew5tzHEDFlmhsKtX0YsBtm50ZAXqOIYjRrQACuHaaDC06/8HDf3xTwktsqVM/uf5c+tKriGl+y3MX2NGLXhEb/raJFSenlgsPgFxIpVbGvqDSFmHN9TkXW3JWk9Vljhcq3VUSAn4yuBvkI8Wf5b2LDkcdW13O42FxXdIYiJwcWwNQT0ADzvVKM2tLfw== Received: from MWHPR14CA0010.namprd14.prod.outlook.com (2603:10b6:300:ae::20) by CH2PR12MB4293.namprd12.prod.outlook.com (2603:10b6:610:7e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.14; Wed, 16 Mar 2022 13:58:49 +0000 Received: from CO1NAM11FT007.eop-nam11.prod.protection.outlook.com (2603:10b6:300:ae:cafe::f9) by MWHPR14CA0010.outlook.office365.com (2603:10b6:300:ae::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.14 via Frontend Transport; Wed, 16 Mar 2022 13:58:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by CO1NAM11FT007.mail.protection.outlook.com (10.13.174.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5081.14 via Frontend Transport; Wed, 16 Mar 2022 13:58:49 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 16 Mar 2022 13:58:48 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 16 Mar 2022 06:58:47 -0700 Received: from sumitg-l4t.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.22 via Frontend Transport; Wed, 16 Mar 2022 06:58:43 -0700 From: Sumit Gupta To: , , , , , , , , , CC: , , , Subject: [Patch v1 1/3] cpufreq: tegra194: add soc data to support multiple soc Date: Wed, 16 Mar 2022 19:28:29 +0530 Message-ID: <20220316135831.900-2-sumitg@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220316135831.900-1-sumitg@nvidia.com> References: <20220316135831.900-1-sumitg@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 36a8929f-2d4d-4d81-a2a7-08da075518b1 X-MS-TrafficTypeDiagnostic: CH2PR12MB4293:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b5nwtx+OxLUrtDRhHbHFSREN9LG/PmZ6NIrj/xH0zcP2aTnAbLJsGZOzzg1tfonFz+Qh8oCj29pDlFeifBoRlcoR5lwhv5dEhtkmhDsOqEW3yzChu9gR3D0xRSWyB2WUfq4JGtmCZ7dJHmAMxOWrt8fUrKgHx3hu560eRf2zdnIEXFqThvdulGtTpPslFqR2VhxpXj44F0wA1gaykvMHQbfMN9tcvFttE1Vg88/IrluUxxWCkM7wJuJReuAUt+WLmjFKu+wBoqCOvHU+0og+3mINsM4b5dcBRBd0v1OcdEDfnD+Ng7a8QUysDaNAj+bnO3VTN69juFeHe/gMMJETnmWkDTadaWWErrp6FhtJSQU13d4R+ZTsFg5dnkFOmjqtz44zNzD4doY+Qa2jiPnEEOcMKxRY5UHjeVqE86f2cju6nYzrAa0uadpwC9rcH+o9ClqhFjPwplhv7iMH4K0PLGvqp3TGQKR9MAJY1rJLE6jfTAnS2DdnlmwZanlLKM3qm3PtmPifZgQlsDJOH2xqKyZ02hqZ+Rxng45kCUbchyv9NOxhpu8AqiHFYJioZo+8nb5ZEBtQ6+rwEtE+Jj+030AJcf5MshZHjSz40A3VJKcDitiwO5Qud7I46cCyN8k3bmHF2Segv/mAAn2LvhLcQnxKiYzZE0c37Xw9tmlbPW4Kp3Gn1jD3NndNI/CFtB32fMLl7+dxwDqjlZxerMsmOPZyuLsJLQPr1VupMt5Y88M= X-Forefront-Antispam-Report: CIP:12.22.5.238;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(86362001)(110136005)(8936002)(921005)(316002)(356005)(2906002)(54906003)(81166007)(70206006)(70586007)(5660300002)(82310400004)(8676002)(4326008)(47076005)(6666004)(107886003)(26005)(186003)(336012)(426003)(1076003)(2616005)(83380400001)(40460700003)(36860700001)(508600001)(7696005)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2022 13:58:49.3005 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 36a8929f-2d4d-4d81-a2a7-08da075518b1 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.238];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT007.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4293 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Adding SoC data and ops to support multiple SoC's in same driver. Signed-off-by: Sumit Gupta --- drivers/cpufreq/tegra194-cpufreq.c | 142 +++++++++++++++++++++-------- 1 file changed, 105 insertions(+), 37 deletions(-) diff --git a/drivers/cpufreq/tegra194-cpufreq.c b/drivers/cpufreq/tegra194-cpufreq.c index ac381db25dbe..2d59b2bd0e1d 100644 --- a/drivers/cpufreq/tegra194-cpufreq.c +++ b/drivers/cpufreq/tegra194-cpufreq.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* - * Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved + * Copyright (c) 2020 - 2022, NVIDIA CORPORATION. All rights reserved */ #include @@ -35,12 +35,6 @@ enum cluster { MAX_CLUSTERS, }; -struct tegra194_cpufreq_data { - void __iomem *regs; - size_t num_clusters; - struct cpufreq_frequency_table **tables; -}; - struct tegra_cpu_ctr { u32 cpu; u32 coreclk_cnt, last_coreclk_cnt; @@ -52,13 +46,42 @@ struct read_counters_work { struct tegra_cpu_ctr c; }; +struct tegra_cpufreq_ops { + void (*read_counters)(struct tegra_cpu_ctr *c); + void (*set_cpu_ndiv)(struct cpufreq_policy *policy, u64 ndiv); + void (*get_cpu_cluster_id)(u32 cpu, u32 *cpuid, u32 *clusterid); + int (*get_cpu_ndiv)(u32 cpu, u32 cpuid, u32 clusterid, u64 *ndiv); +}; + +struct tegra_cpufreq_soc { + struct tegra_cpufreq_ops *ops; + int maxcpus_per_cluster; +}; + +struct tegra194_cpufreq_data { + void __iomem *regs; + size_t num_clusters; + struct cpufreq_frequency_table **tables; + const struct tegra_cpufreq_soc *soc; +}; + static struct workqueue_struct *read_counters_wq; -static void get_cpu_cluster(void *cluster) +static void tegra_get_cpu_mpidr(void *mpidr) { - u64 mpidr = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; + *((u64 *)mpidr) = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; +} + +static void tegra194_get_cpu_cluster_id(u32 cpu, u32 *cpuid, u32 *clusterid) +{ + u64 mpidr; + + smp_call_function_single(cpu, tegra_get_cpu_mpidr, &mpidr, true); - *((uint32_t *)cluster) = MPIDR_AFFINITY_LEVEL(mpidr, 1); + if (cpuid) + *cpuid = MPIDR_AFFINITY_LEVEL(mpidr, 0); + if (clusterid) + *clusterid = MPIDR_AFFINITY_LEVEL(mpidr, 1); } /* @@ -85,11 +108,24 @@ static inline u32 map_ndiv_to_freq(struct mrq_cpu_ndiv_limits_response return nltbl->ref_clk_hz / KHZ * ndiv / (nltbl->pdiv * nltbl->mdiv); } +static void tegra194_read_counters(struct tegra_cpu_ctr *c) +{ + u64 val; + + val = read_freq_feedback(); + c->last_refclk_cnt = lower_32_bits(val); + c->last_coreclk_cnt = upper_32_bits(val); + udelay(US_DELAY); + val = read_freq_feedback(); + c->refclk_cnt = lower_32_bits(val); + c->coreclk_cnt = upper_32_bits(val); +} + static void tegra_read_counters(struct work_struct *work) { + struct tegra194_cpufreq_data *data = cpufreq_get_driver_data(); struct read_counters_work *read_counters_work; struct tegra_cpu_ctr *c; - u64 val; /* * ref_clk_counter(32 bit counter) runs on constant clk, @@ -107,13 +143,7 @@ static void tegra_read_counters(struct work_struct *work) work); c = &read_counters_work->c; - val = read_freq_feedback(); - c->last_refclk_cnt = lower_32_bits(val); - c->last_coreclk_cnt = upper_32_bits(val); - udelay(US_DELAY); - val = read_freq_feedback(); - c->refclk_cnt = lower_32_bits(val); - c->coreclk_cnt = upper_32_bits(val); + data->soc->ops->read_counters(c); } /* @@ -177,7 +207,7 @@ static unsigned int tegra194_calculate_speed(u32 cpu) return (rate_mhz * KHZ); /* in KHz */ } -static void get_cpu_ndiv(void *ndiv) +static void tegra194_get_cpu_ndiv_sysreg(void *ndiv) { u64 ndiv_val; @@ -186,30 +216,43 @@ static void get_cpu_ndiv(void *ndiv) *(u64 *)ndiv = ndiv_val; } -static void set_cpu_ndiv(void *data) +static int tegra194_get_cpu_ndiv(u32 cpu, u32 cpuid, u32 clusterid, u64 *ndiv) +{ + int ret; + + ret = smp_call_function_single(cpu, tegra194_get_cpu_ndiv_sysreg, &ndiv, true); + + return ret; +} + +static void tegra194_set_cpu_ndiv_sysreg(void *data) { - struct cpufreq_frequency_table *tbl = data; - u64 ndiv_val = (u64)tbl->driver_data; + u64 ndiv_val = *(u64 *)data; asm volatile("msr s3_0_c15_c0_4, %0" : : "r" (ndiv_val)); } +static void tegra194_set_cpu_ndiv(struct cpufreq_policy *policy, u64 ndiv) +{ + on_each_cpu_mask(policy->cpus, tegra194_set_cpu_ndiv_sysreg, &ndiv, true); +} + static unsigned int tegra194_get_speed(u32 cpu) { struct tegra194_cpufreq_data *data = cpufreq_get_driver_data(); struct cpufreq_frequency_table *pos; + u32 cpuid, clusterid; unsigned int rate; u64 ndiv; int ret; - u32 cl; - smp_call_function_single(cpu, get_cpu_cluster, &cl, true); + data->soc->ops->get_cpu_cluster_id(cpu, &cpuid, &clusterid); /* reconstruct actual cpu freq using counters */ rate = tegra194_calculate_speed(cpu); /* get last written ndiv value */ - ret = smp_call_function_single(cpu, get_cpu_ndiv, &ndiv, true); + ret = data->soc->ops->get_cpu_ndiv(cpu, cpuid, clusterid, &ndiv); if (WARN_ON_ONCE(ret)) return rate; @@ -219,7 +262,7 @@ static unsigned int tegra194_get_speed(u32 cpu) * to the last written ndiv value from freq_table. This is * done to return consistent value. */ - cpufreq_for_each_valid_entry(pos, data->tables[cl]) { + cpufreq_for_each_valid_entry(pos, data->tables[clusterid]) { if (pos->driver_data != ndiv) continue; @@ -237,19 +280,22 @@ static unsigned int tegra194_get_speed(u32 cpu) static int tegra194_cpufreq_init(struct cpufreq_policy *policy) { struct tegra194_cpufreq_data *data = cpufreq_get_driver_data(); - u32 cpu; - u32 cl; + int maxcpus_per_cluster = data->soc->maxcpus_per_cluster; + u32 start_cpu, cpu; + u32 clusterid; - smp_call_function_single(policy->cpu, get_cpu_cluster, &cl, true); + data->soc->ops->get_cpu_cluster_id(policy->cpu, NULL, &clusterid); - if (cl >= data->num_clusters || !data->tables[cl]) + if (clusterid >= data->num_clusters || !data->tables[clusterid]) return -EINVAL; + start_cpu = rounddown(policy->cpu, maxcpus_per_cluster); /* set same policy for all cpus in a cluster */ - for (cpu = (cl * 2); cpu < ((cl + 1) * 2); cpu++) - cpumask_set_cpu(cpu, policy->cpus); - - policy->freq_table = data->tables[cl]; + for (cpu = start_cpu; cpu < (start_cpu + maxcpus_per_cluster); cpu++) { + if (cpu_possible(cpu)) + cpumask_set_cpu(cpu, policy->cpus); + } + policy->freq_table = data->tables[clusterid]; policy->cpuinfo.transition_latency = TEGRA_CPUFREQ_TRANSITION_LATENCY; return 0; @@ -259,13 +305,14 @@ static int tegra194_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int index) { struct cpufreq_frequency_table *tbl = policy->freq_table + index; + struct tegra194_cpufreq_data *data = cpufreq_get_driver_data(); /* * Each core writes frequency in per core register. Then both cores * in a cluster run at same frequency which is the maximum frequency * request out of the values requested by both cores in that cluster. */ - on_each_cpu_mask(policy->cpus, set_cpu_ndiv, tbl, true); + data->soc->ops->set_cpu_ndiv(policy, (u64)tbl->driver_data); return 0; } @@ -280,6 +327,18 @@ static struct cpufreq_driver tegra194_cpufreq_driver = { .attr = cpufreq_generic_attr, }; +static struct tegra_cpufreq_ops tegra194_cpufreq_ops = { + .read_counters = tegra194_read_counters, + .get_cpu_cluster_id = tegra194_get_cpu_cluster_id, + .get_cpu_ndiv = tegra194_get_cpu_ndiv, + .set_cpu_ndiv = tegra194_set_cpu_ndiv, +}; + +const struct tegra_cpufreq_soc tegra194_cpufreq_soc = { + .ops = &tegra194_cpufreq_ops, + .maxcpus_per_cluster = 2, +}; + static void tegra194_cpufreq_free_resources(void) { destroy_workqueue(read_counters_wq); @@ -359,6 +418,7 @@ init_freq_table(struct platform_device *pdev, struct tegra_bpmp *bpmp, static int tegra194_cpufreq_probe(struct platform_device *pdev) { + const struct tegra_cpufreq_soc *soc; struct tegra194_cpufreq_data *data; struct tegra_bpmp *bpmp; int err, i; @@ -367,6 +427,15 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev) if (!data) return -ENOMEM; + soc = of_device_get_match_data(&pdev->dev); + + if (soc->ops && soc->maxcpus_per_cluster) { + data->soc = soc; + } else { + dev_err(&pdev->dev, "soc data missing\n"); + return -EINVAL; + } + data->num_clusters = MAX_CLUSTERS; data->tables = devm_kcalloc(&pdev->dev, data->num_clusters, sizeof(*data->tables), GFP_KERNEL); @@ -416,10 +485,9 @@ static int tegra194_cpufreq_remove(struct platform_device *pdev) } static const struct of_device_id tegra194_cpufreq_of_match[] = { - { .compatible = "nvidia,tegra194-ccplex", }, + { .compatible = "nvidia,tegra194-ccplex", .data = &tegra194_cpufreq_soc }, { /* sentinel */ } }; -MODULE_DEVICE_TABLE(of, tegra194_cpufreq_of_match); static struct platform_driver tegra194_ccplex_driver = { .driver = { From patchwork Wed Mar 16 13:58:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Gupta X-Patchwork-Id: 12782721 X-Patchwork-Delegate: viresh.linux@gmail.com 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 2645DC433EF for ; Wed, 16 Mar 2022 13:59:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348968AbiCPOAZ (ORCPT ); Wed, 16 Mar 2022 10:00:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356407AbiCPOAM (ORCPT ); Wed, 16 Mar 2022 10:00:12 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2088.outbound.protection.outlook.com [40.107.244.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9F0766624; Wed, 16 Mar 2022 06:58:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ijHEP3ARVDga/ZGMPzTOgFREut/3MzwHlWegoiE04nbOdQbLloca4twr0K+6dWtXJtMlMiHIAJZIWzir0vVqob7K/gon53M4QaHdjsQO7Ril3IhHtS/XyvVchfWfEvZiZ0zzib6wUnaBEtHmPH/O80iXiHlNKiiEpNomb2LK/jIJLkBFaHnQH/ZNVjyzb8Xp0yyv46jEf9WZ+JRzhkMwFPaSTammIIWgyKoubXqp+57yrft2w2rajEpb8V6tV6X8x7Fy3aJP07VAzf0Ob3fJVzOKHuOJHYLHcb4ygIwYEoCgRfHAVwx/k5ygt5bqyKl2w+xCHiZB/MnVvC4pMDloWg== 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=0jiZqiuA4bL/Xl4sXyXV/fFxhFrzn1JlNSbgW6WB1YI=; b=VC+GsXrcnJk/pAFFsYLVy684Rht8xGjZD9YVDc57ufdrFQPkM7zYxgkiDhR5tGu2A0sZSDHmV6eMZZiM0LGJlgbTUSsXjcqDkM/c853p0G10nIsw9zj6CgxEw46O28YVGqwpb1q50qsTpcdOzpvo8kGUdpyhKi8tik/EI+0aYLUknUw5JP2+FkSu0DK9iHg2CPmQ+0Yp/gnv/MQMiyp3SbX0t/GXPGRi8ZJEcZJeM+p3qJTDaria9XuJXRIxjFBs7AlNQ+RHNDacKaUAaaqXThNjGb9C9ho6X+SW4GRme+gZ62hfIIHeFy/vpwYhhb/hEEN9sQ1AUpry8gaKTWFoHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0jiZqiuA4bL/Xl4sXyXV/fFxhFrzn1JlNSbgW6WB1YI=; b=fQfOb9brw3SlxmpvImteq6wUuHakZf5n/zwawX1KpnfknzW+Bk0DNMNU6mdyOn0ZUTW5/O0DDgzdLZuPRLVc1kx6AcQt6d8D87yuP8kvJ2AfoIm8LT/qeJ8o2+CVJ51GPtCVwSN6hOO3yIJSUOHl3LazKKAFCSADTL/SeVMn7urekxLe09qpgO/6Nx+hJTDDlDqEmaUtHMoqZliv+BvnDhoW84YwK+tbb/QpVFXLqR/qEX3HUCQsTmieUgcWkHy/QmmcQutI+CLjRQEUDqemDNT/e2Cc8r6B0i57+UjmpSA+TF4RtEvFxsOAVuPAUsnIU3PcF2GzLdwhuqNQPeUDIA== Received: from DM5PR19CA0067.namprd19.prod.outlook.com (2603:10b6:3:116::29) by DM5PR1201MB0058.namprd12.prod.outlook.com (2603:10b6:4:50::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.26; Wed, 16 Mar 2022 13:58:55 +0000 Received: from DM6NAM11FT064.eop-nam11.prod.protection.outlook.com (2603:10b6:3:116:cafe::ad) by DM5PR19CA0067.outlook.office365.com (2603:10b6:3:116::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.14 via Frontend Transport; Wed, 16 Mar 2022 13:58:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.236) by DM6NAM11FT064.mail.protection.outlook.com (10.13.172.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5081.14 via Frontend Transport; Wed, 16 Mar 2022 13:58:55 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 16 Mar 2022 13:58:54 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 16 Mar 2022 06:58:52 -0700 Received: from sumitg-l4t.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.22 via Frontend Transport; Wed, 16 Mar 2022 06:58:49 -0700 From: Sumit Gupta To: , , , , , , , , , CC: , , , Subject: [Patch v1 2/3] arm64: tegra: add node for tegra234 cpufreq Date: Wed, 16 Mar 2022 19:28:30 +0530 Message-ID: <20220316135831.900-3-sumitg@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220316135831.900-1-sumitg@nvidia.com> References: <20220316135831.900-1-sumitg@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cb2a28c9-1036-4265-1388-08da07551c32 X-MS-TrafficTypeDiagnostic: DM5PR1201MB0058:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WSBwKLZkiHAy/alBi5lNZjZ5HzgO1pxiC7/RwL/1WnK+W6+oaZzCjnVuLLzHF9rbUw/KrEd6lwn8UrQe2wio3R8facNgL8gj5tFAzlpoXdI2/XJJiDS9qHSn1XvLXHFbsh2CaksHwiZMmDBXbcvheZuuR+pWIG2ACt7klBsqZyBzKSmAB/zbJhy1sx0vVYrYC2N5koI4NJJFPekedeM+PyRcQKVugNJtxISYL7TeBwkR1dUv1DGcTCcACN7TAfOLG/FYo0rXTwBwlUFqi3dSDeByyCV1iUQKcjycaEi3GQ/N7hNifj++pY+mhUcnxLM7chJjy5/8CfV4MIQMsGFYv5QooISM+BswpJHoFOq5iygL2xP1jQnLchGbGIHk8gX+82GQ2so0qtMimahPKW4b/me7aTu5Mmk5jIsHk0zNfY8yL6n7+Q/Q26sdo4QPenLwjD7kVdiyb4gme6airz2A+VQBf3czQt4aeYnSs8d51m3LSjdJdqYQuoaYPs5M9/ANmkoUjdJEHmfxi/LRLSvP0hwX+ED8/Ji6AfMLIMGqzKP3oIfsm6hGEVKibjr4dy1pMCCPFjHBZWU9ksUu157l6V2KSdxlFJ/Wx3YAG987dT0njqqIu4og3bYc2XhooB+csNv1odAAO5LDEPH7diRfWCWjfA9r4t46LjkHE4mtrULbeowPFmEQdf6j8Ia9VEpukpohPS5LcBml6PkBnttoNRKQcStK8c9DH1/welIFkxE= X-Forefront-Antispam-Report: CIP:12.22.5.236;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(40470700004)(46966006)(82310400004)(26005)(4326008)(336012)(107886003)(2616005)(426003)(1076003)(186003)(70206006)(86362001)(83380400001)(70586007)(54906003)(508600001)(110136005)(921005)(36756003)(4744005)(356005)(2906002)(81166007)(7696005)(8936002)(8676002)(47076005)(36860700001)(40460700003)(6666004)(5660300002)(316002)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2022 13:58:55.1754 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cb2a28c9-1036-4265-1388-08da07551c32 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.236];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT064.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0058 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Adding cclpex node to represent Tegra234 cpufreq. Tegra234 uses some of the CRAB (Control Register Access Bus) registers for cpu frequency requests. These registers are memory mapped to CCPLEX_MMCRAB_ARM region. In this node, mapping the range of MMCRAB registers required only for cpu frequency info. Signed-off-by: Sumit Gupta --- arch/arm64/boot/dts/nvidia/tegra234.dtsi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/boot/dts/nvidia/tegra234.dtsi b/arch/arm64/boot/dts/nvidia/tegra234.dtsi index aaace605bdaa..610207f3f967 100644 --- a/arch/arm64/boot/dts/nvidia/tegra234.dtsi +++ b/arch/arm64/boot/dts/nvidia/tegra234.dtsi @@ -1258,6 +1258,13 @@ }; }; + ccplex@e000000 { + compatible = "nvidia,tegra234-ccplex-cluster"; + reg = <0x0 0x0e000000 0x0 0x5ffff>; + nvidia,bpmp = <&bpmp>; + status = "okay"; + }; + sram@40000000 { compatible = "nvidia,tegra234-sysram", "mmio-sram"; reg = <0x0 0x40000000 0x0 0x80000>; From patchwork Wed Mar 16 13:58:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Gupta X-Patchwork-Id: 12782722 X-Patchwork-Delegate: viresh.linux@gmail.com 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 B0EF2C43217 for ; Wed, 16 Mar 2022 13:59:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356311AbiCPOA3 (ORCPT ); Wed, 16 Mar 2022 10:00:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356395AbiCPOAT (ORCPT ); Wed, 16 Mar 2022 10:00:19 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2073.outbound.protection.outlook.com [40.107.93.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8800443F1; Wed, 16 Mar 2022 06:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iKh5jG+khcYfwkZqDM0NWMe6TlG16KK2Vv3RciOIZ+LyZfMZ4QZl9HEsh8E4N8UMKJM7FDbNvQ0XjxPerso/oBNObZ0SIWFCJaWpvsiQScZhQrUQlwUYyu64O+uS2yf1ExhbfR+2pRyety+6BgXsbqa6wajr6Htv2JSML1DPtYJZSKY+H8atOnQGSnrOFXIgU22H63AdV5GS8z0ohOETK2Dg/uyFdEZn2OnyUMm33HBkMIEC7B3jx34CVSLqZeslU5QXRL0xtUerBrPYYRoEeQ4aTsoffC3rP4qgEq7tWpqF/hFAU1afK7PWy22vqiEDJqL5OSKfLcQ/Xv/voju17w== 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=tjGna8v4bnh52VWGQIdvcj8kzLJ8QGi0ODbLx6zVlTY=; b=JGnjrL5dvvzeLKvoS4qJ+oJ8NCvice+vKS0Wm8qFS0bzGp7a9CjOet8slWiFFmGfbN2MYaw1PjJCO9Zq1KitpVMB1nM8huE/i2/Z+xXjCZm3dvfT8YRZw94N4MMzAyDsX8PskkBWA6l9bNFFd6+N5yVTE6nG6vett1fbbYZZMzJH22CZvfxJ9MwiB367rR3Y+8i29YI9e6Y7WeNmkxnmSp9gfTB3t+h58luxFZ3bWufCJNLZN3Jm6Dp84vNBlIVNF6mjpY6WOEV7021UOZfRe/3RC/BbdRorWhi95b+gYfsNWzhFSplDR0pWVm7o/5oQfua2brO3NWcQcXN968+hYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tjGna8v4bnh52VWGQIdvcj8kzLJ8QGi0ODbLx6zVlTY=; b=cFPoZjFIC24WVPDefknk+0yVMuPfj1yYuCNqW20q+7gJERh+Df2pCjR++D6RLvbBeRazMTfp/gzzPZ1NhP2v4KjLQv4aiJnTx29DLAe1n6qwxTyBzK3Gnq2Iq+DzteUMnejk1SaWsC4894adR2QxAObyjgCIZ1FNozL9iE9sICXLqhVK4rQenQg1FstlwuPMNvdvHUcszc7Y6/BXSUfmrej4dfWRcUJgBEi/DKCvMkg1U43AHrmfBw7toi0UgEn6s22J757qm5lnn942lMlm/kdWVxlWf1DSeyhAYNvipnB9ARMvl75M17mkcq/bKV5sf+qeo2S6+s34yfAlXlNtNg== Received: from DM5PR13CA0055.namprd13.prod.outlook.com (2603:10b6:3:117::17) by DM4PR12MB5119.namprd12.prod.outlook.com (2603:10b6:5:392::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.15; Wed, 16 Mar 2022 13:59:01 +0000 Received: from DM6NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:3:117:cafe::bb) by DM5PR13CA0055.outlook.office365.com (2603:10b6:3:117::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.7 via Frontend Transport; Wed, 16 Mar 2022 13:59:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT011.mail.protection.outlook.com (10.13.172.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5081.14 via Frontend Transport; Wed, 16 Mar 2022 13:59:00 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 16 Mar 2022 13:59:00 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 16 Mar 2022 06:58:58 -0700 Received: from sumitg-l4t.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.22 via Frontend Transport; Wed, 16 Mar 2022 06:58:54 -0700 From: Sumit Gupta To: , , , , , , , , , CC: , , , Subject: [Patch v1 3/3] cpufreq: tegra194: Add support for Tegra234 Date: Wed, 16 Mar 2022 19:28:31 +0530 Message-ID: <20220316135831.900-4-sumitg@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220316135831.900-1-sumitg@nvidia.com> References: <20220316135831.900-1-sumitg@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2c32d092-4ddc-432a-5f5f-08da07551f92 X-MS-TrafficTypeDiagnostic: DM4PR12MB5119:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3YvcD0gnT0WDBRAr94Os74WsaNdpud3yyQABynJIrQwbyDFW+TQ5umS+nXwUAEFW15pZ8lt5lCqxlK9b5hughOSlfwlnJLuqT7yQ5Ii+2nEd9lLPYc1iXS4EOmv9a1/yBZDLKPTnaRbfPr3wiDMWJtpXgjCLHJYfdexNw3COhm1sMr9miicO315IVSd0ktXzMUl3QZSbXiGE/r0LdBmFDSC1nVfSnL00+q25USVolDWhr2NecbH5wnvti0zfry9rFPHlU168NUi8uPXWO878O3pvTvmkhoL53RcHHWJ3h+sjhoq3L2aeMpRL+8JKQfpfp5hrrTyKjEXmActiNyh+sWW7QlNT1cGzXow8e29+TgiAzDZ+0JFCsLPdFlX6Qq0YW/m5r1tZSHod+qZ+ttKNqw4iubNW1qk3FNmnmwhamBY7BYTITF+pVUcEEOZA+Vqj0ZoPgyB2DTlrPG5IEKAfljtAcxbIsj6AOZ1FbEVaRkWwNHC7A+y+phdHfTMNDThUNtFl+orOW4IUMeQHiWdvtSK9rNhaQiQih4u7XZ3faigkg9ghiujxkXkpqwkCAviqE5+WNgeSZ4Ex888MB6Ip3qO9unvak/wmFEHV3PnY+38lVMHOMPJ6QiESXZBq/74/vAlMyTAVHH+6MqKj5ClCe5G9t4MBl3/c3xnhh58iyYYLc7VPiBbqlruxHvemE1FO6YqEAQPjUotsCgEzisXYDF4u93PmZsx3Tzd9kpJuZPE= X-Forefront-Antispam-Report: CIP:12.22.5.234;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:mail.nvidia.com;PTR:InfoNoRecords;CAT:NONE;SFS:(13230001)(4636009)(40470700004)(36840700001)(46966006)(2616005)(86362001)(110136005)(426003)(336012)(82310400004)(5660300002)(40460700003)(8936002)(107886003)(1076003)(54906003)(186003)(81166007)(921005)(356005)(4326008)(508600001)(26005)(70206006)(8676002)(70586007)(6666004)(316002)(7696005)(2906002)(83380400001)(36756003)(36860700001)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Mar 2022 13:59:00.8553 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2c32d092-4ddc-432a-5f5f-08da07551f92 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[12.22.5.234];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5119 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org This patch adds driver support for Tegra234 cpufreq. Tegra234 has per core MMIO registers instead of system registers for cpu frequency requests and to read the counters for re-constructing the cpu frequency. Also, MPIDR affinity info in Tegra234 is different from Tegra194. Added ops hooks and soc data for Tegra234. This will help to easily add variants of Tegra234 and future SoC's which use similar logic to {get|set} the cpu frequency. Signed-off-by: Sumit Gupta --- drivers/cpufreq/tegra194-cpufreq.c | 104 +++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/drivers/cpufreq/tegra194-cpufreq.c b/drivers/cpufreq/tegra194-cpufreq.c index 2d59b2bd0e1d..6b944d00c35a 100644 --- a/drivers/cpufreq/tegra194-cpufreq.c +++ b/drivers/cpufreq/tegra194-cpufreq.c @@ -24,6 +24,17 @@ #define CPUFREQ_TBL_STEP_HZ (50 * KHZ * KHZ) #define MAX_CNT ~0U +#define NDIV_MASK 0x1FF + +#define CORE_OFFSET(cpu) (cpu * 8) +#define CMU_CLKS_BASE 0x2000 +#define SCRATCH_FREQ_CORE_REG(data, cpu) (data->regs + CMU_CLKS_BASE + CORE_OFFSET(cpu)) + +#define MMCRAB_CLUSTER_BASE(cl) (0x30000 + (cl * 0x10000)) +#define CLUSTER_ACTMON_BASE(data, cl) \ + (data->regs + (MMCRAB_CLUSTER_BASE(cl) + data->soc->actmon_cntr_base)) +#define CORE_ACTMON_CNTR_REG(data, cl, cpu) (CLUSTER_ACTMON_BASE(data, cl) + CORE_OFFSET(cpu)) + /* cpufreq transisition latency */ #define TEGRA_CPUFREQ_TRANSITION_LATENCY (300 * 1000) /* unit in nanoseconds */ @@ -56,6 +67,7 @@ struct tegra_cpufreq_ops { struct tegra_cpufreq_soc { struct tegra_cpufreq_ops *ops; int maxcpus_per_cluster; + phys_addr_t actmon_cntr_base; }; struct tegra194_cpufreq_data { @@ -72,6 +84,90 @@ static void tegra_get_cpu_mpidr(void *mpidr) *((u64 *)mpidr) = read_cpuid_mpidr() & MPIDR_HWID_BITMASK; } +static void tegra234_get_cpu_cluster_id(u32 cpu, u32 *cpuid, u32 *clusterid) +{ + u64 mpidr; + + smp_call_function_single(cpu, tegra_get_cpu_mpidr, &mpidr, true); + + if (cpuid) + *cpuid = MPIDR_AFFINITY_LEVEL(mpidr, 1); + if (clusterid) + *clusterid = MPIDR_AFFINITY_LEVEL(mpidr, 2); +} + +static int tegra234_get_cpu_ndiv(u32 cpu, u32 cpuid, u32 clusterid, u64 *ndiv) +{ + struct tegra194_cpufreq_data *data = cpufreq_get_driver_data(); + void __iomem *freq_core_reg; + u64 mpidr_id; + + /* use physical id to get address of per core frequency register */ + mpidr_id = (clusterid * data->soc->maxcpus_per_cluster) + cpuid; + freq_core_reg = SCRATCH_FREQ_CORE_REG(data, mpidr_id); + + *ndiv = readl(freq_core_reg) & NDIV_MASK; + + return 0; +} + +static void tegra234_set_cpu_ndiv(struct cpufreq_policy *policy, u64 ndiv) +{ + struct tegra194_cpufreq_data *data = cpufreq_get_driver_data(); + void __iomem *freq_core_reg; + u32 cpu, cpuid, clusterid; + u64 mpidr_id; + + for_each_cpu_and(cpu, policy->cpus, cpu_online_mask) { + data->soc->ops->get_cpu_cluster_id(cpu, &cpuid, &clusterid); + + /* use physical id to get address of per core frequency register */ + mpidr_id = (clusterid * data->soc->maxcpus_per_cluster) + cpuid; + freq_core_reg = SCRATCH_FREQ_CORE_REG(data, mpidr_id); + + writel(ndiv, freq_core_reg); + } +} + +/* + * This register provides access to two counter values with a single + * 64-bit read. The counter values are used to determine the average + * actual frequency a core has run at over a period of time. + * [63:32] PLLP counter: Counts at fixed frequency (408 MHz) + * [31:0] Core clock counter: Counts on every core clock cycle + */ +static void tegra234_read_counters(struct tegra_cpu_ctr *c) +{ + struct tegra194_cpufreq_data *data = cpufreq_get_driver_data(); + void __iomem *actmon_reg; + u32 cpuid, clusterid; + u64 val; + + data->soc->ops->get_cpu_cluster_id(c->cpu, &cpuid, &clusterid); + actmon_reg = CORE_ACTMON_CNTR_REG(data, clusterid, cpuid); + + val = readq(actmon_reg); + c->last_refclk_cnt = upper_32_bits(val); + c->last_coreclk_cnt = lower_32_bits(val); + udelay(US_DELAY); + val = readq(actmon_reg); + c->refclk_cnt = upper_32_bits(val); + c->coreclk_cnt = lower_32_bits(val); +} + +static struct tegra_cpufreq_ops tegra234_cpufreq_ops = { + .read_counters = tegra234_read_counters, + .get_cpu_cluster_id = tegra234_get_cpu_cluster_id, + .get_cpu_ndiv = tegra234_get_cpu_ndiv, + .set_cpu_ndiv = tegra234_set_cpu_ndiv, +}; + +const struct tegra_cpufreq_soc tegra234_cpufreq_soc = { + .ops = &tegra234_cpufreq_ops, + .actmon_cntr_base = 0x9000, + .maxcpus_per_cluster = 4, +}; + static void tegra194_get_cpu_cluster_id(u32 cpu, u32 *cpuid, u32 *clusterid) { u64 mpidr; @@ -442,6 +538,13 @@ static int tegra194_cpufreq_probe(struct platform_device *pdev) if (!data->tables) return -ENOMEM; + if (of_device_is_compatible(pdev->dev.of_node, "nvidia,tegra234-ccplex-cluster")) { + /* mmio registers are used for frequency request and re-construction */ + data->regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(data->regs)) + return PTR_ERR(data->regs); + } + platform_set_drvdata(pdev, data); bpmp = tegra_bpmp_get(&pdev->dev); @@ -486,6 +589,7 @@ static int tegra194_cpufreq_remove(struct platform_device *pdev) static const struct of_device_id tegra194_cpufreq_of_match[] = { { .compatible = "nvidia,tegra194-ccplex", .data = &tegra194_cpufreq_soc }, + { .compatible = "nvidia,tegra234-ccplex-cluster", .data = &tegra234_cpufreq_soc }, { /* sentinel */ } };