Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp145923imd; Fri, 2 Nov 2018 20:06:51 -0700 (PDT) X-Google-Smtp-Source: AJdET5ehzeJ8SbYoss9kGMx2oCHN8WULJmlRof5z8I6WkhqGBwkEMQM8cTm81y2pP7VAmS2kvCd6 X-Received: by 2002:a62:2e04:: with SMTP id u4-v6mr14340577pfu.229.1541214411561; Fri, 02 Nov 2018 20:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541214411; cv=none; d=google.com; s=arc-20160816; b=jou3NNH5OqvowtIL7dGaDrYxBqZp4/PYPXpgea8tmk09WzJy9CegUBFrXKUGTuDpnV x2dWQovRaPRO+OOwirUEo+S/9WAmdk1QJT4NsXlx6QST/gY5Zq1OEMIvZeiYv7Csm18y ztDAMjZnXkY6I77XbMbvUUdeA4Wc/4iakUhAzFQsitFnPXRbrEaJevI6WNF4kg8dznkz IP0E+hysFBBc/9QQGulS5m1NqrXLkuYSZ1TZ8XZSV7kKBH/XguhmFEu4N0UBYrD9a7a7 flT+tae+jg59XU+T4qxBFFAyHDWjla5iK1gZEyLnNl97Xc3OnqJHND3SFMJ/8yr3Majj WT3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature; bh=vErE/lwXZZ1aknxF14rjOWekh6AGN4gFpzIce0MPu/4=; b=fhRSX0APbaigJnnhSFhGJN39K9ClWF/THy31di59KFzUjhQtt6k/ZobIiV8enFdmdq 52m9trLe3MobzmCGZ0ZZK8KLLSZ/MztjdYHmquKBCHoK5C6VB/eB6se7GNwLfAIYS438 Uu8RQcEnq2L7fy0fgpYrTatJu6QdKBKhbu9rmwg6S98Q15AMLwkfyNLH7XbIBFLDiJoG B+K58GV3oMnxlvM/+4kpjJwY0btUgJ6r5WUE5E2AGxvz79a4LNcqM+iLeiIPTbLvI3Lg gsPMwlM40umf5DcyO2YlbN5QT+Ec/RUYSN/edr4g5IHDTGawsm8gatD+iYrHpY7yM4hn yB2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=AbIIbZMy; dkim=pass header.i=@codeaurora.org header.s=default header.b=GwJfblY9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b3si8566581pgc.587.2018.11.02.20.06.35; Fri, 02 Nov 2018 20:06:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=AbIIbZMy; dkim=pass header.i=@codeaurora.org header.s=default header.b=GwJfblY9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726229AbeKCMQC (ORCPT + 99 others); Sat, 3 Nov 2018 08:16:02 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:57960 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725924AbeKCMQB (ORCPT ); Sat, 3 Nov 2018 08:16:01 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 2F9636086A; Sat, 3 Nov 2018 03:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541214375; bh=qJmM3OTPSqiuVzE88spQcCcQ9y6AUqu5CuInhuOTkoM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=AbIIbZMyQORab64QUEDNYSYoJfzH+GGR6a1HxmMqPXFMTdQKxjjKo7rCbZiCjQBCo FSitTLiQUxf7cDFuYKilnyug86o1cUn35Sw7E1ts/UpqlhMMYaB36Gfp+0pzWMGamR mC3/jvi8zg4TkCDfvI1+VisimLz53k8TEF5tDYBs= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from [10.79.172.169] (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tdas@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 46C916053B; Sat, 3 Nov 2018 03:06:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1541214374; bh=qJmM3OTPSqiuVzE88spQcCcQ9y6AUqu5CuInhuOTkoM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=GwJfblY9cbRPC3PpwlFyK4Nt/67htqbfrGefef5HmezG64wPZSfyIPQU0LeXbIkIF BMkr/OPdRZZHB+n8PJIcjDk1xn+HZb0F2WBV86HfUT3AcYQ1BMOIiPPfxHKw/f4Oi4 /QCcr2CoM+6SiNcCFlZj9iUi1a8+OgcUEYv51dfk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 46C916053B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=tdas@codeaurora.org Subject: Re: [PATCH 2/2] cpufreq: qcom-hw: Add support for QCOM cpufreq HW driver To: Stephen Boyd , "Rafael J. Wysocki" , Viresh Kumar , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org Cc: Rajendra Nayak , devicetree@vger.kernel.org, robh@kernel.org, skannan@codeaurora.org, linux-arm-msm@vger.kernel.org, amit.kucheria@linaro.org, evgreen@google.com References: <1539257761-23023-1-git-send-email-tdas@codeaurora.org> <1539257761-23023-3-git-send-email-tdas@codeaurora.org> <153981915373.5275.15971019914218464179@swboyd.mtv.corp.google.com> From: Taniya Das Message-ID: <0c51a12e-38d3-2df5-4f5f-6a687727e9bf@codeaurora.org> Date: Sat, 3 Nov 2018 08:36:00 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <153981915373.5275.15971019914218464179@swboyd.mtv.corp.google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Stephen, On 10/18/2018 5:02 AM, Stephen Boyd wrote: > Quoting Taniya Das (2018-10-11 04:36:01) >> --- a/drivers/cpufreq/Kconfig.arm >> +++ b/drivers/cpufreq/Kconfig.arm >> @@ -121,6 +121,17 @@ config ARM_QCOM_CPUFREQ_KRYO >> >> If in doubt, say N. >> >> +config ARM_QCOM_CPUFREQ_HW >> + bool "QCOM CPUFreq HW driver" > > Is there any reason this can't be a module? > We do not have any use cases where we need to support it as module. >> + depends on ARCH_QCOM || COMPILE_TEST >> + help >> + Support for the CPUFreq HW driver. >> + Some QCOM chipsets have a HW engine to offload the steps >> + necessary for changing the frequency of the CPUs. Firmware loaded >> + in this engine exposes a programming interface to the OS. >> + The driver implements the cpufreq interface for this HW engine. >> + Say Y if you want to support CPUFreq HW. >> + >> config ARM_S3C_CPUFREQ >> bool >> help >> diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c >> new file mode 100644 >> index 0000000..fe1c264 >> --- /dev/null >> +++ b/drivers/cpufreq/qcom-cpufreq-hw.c >> @@ -0,0 +1,354 @@ >> +// SPDX-License-Identifier: GPL-2.0 >> +/* >> + * Copyright (c) 2018, The Linux Foundation. All rights reserved. >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +#define LUT_MAX_ENTRIES 40U >> +#define CORE_COUNT_VAL(val) (((val) & (GENMASK(18, 16))) >> 16) >> +#define LUT_ROW_SIZE 32 >> +#define CLK_HW_DIV 2 >> + >> +enum { >> + REG_ENABLE, >> + REG_LUT_TABLE, >> + REG_PERF_STATE, >> + >> + REG_ARRAY_SIZE, >> +}; >> + >> +struct cpufreq_qcom { >> + struct cpufreq_frequency_table *table; >> + void __iomem *reg_bases[REG_ARRAY_SIZE]; >> + cpumask_t related_cpus; >> + unsigned int max_cores; >> + unsigned long xo_rate; >> + unsigned long cpu_hw_rate; >> +}; >> + >> +static const u16 cpufreq_qcom_std_offsets[REG_ARRAY_SIZE] = { > > Is this going to change in the future? > Yes, they could change and that was the reason to introduce the offsets. This was discussed earlier too with Sudeep and was to add them. >> + [REG_ENABLE] = 0x0, >> + [REG_LUT_TABLE] = 0x110, >> + [REG_PERF_STATE] = 0x920, >> +}; >> + >> +static struct cpufreq_qcom *qcom_freq_domain_map[NR_CPUS]; >> + >> +static int >> +qcom_cpufreq_hw_target_index(struct cpufreq_policy *policy, >> + unsigned int index) >> +{ >> + struct cpufreq_qcom *c = policy->driver_data; >> + >> + writel_relaxed(index, c->reg_bases[REG_PERF_STATE]); > > Why can't we avoid the indirection here and store the perf_state pointer > in probe? Then we don't have to indirect through a table to perform the > register write. > As the offsets could change and that was the reason to add this. >> + >> + return 0; >> +} >> + > [..] >> +static int qcom_resources_init(struct platform_device *pdev) >> +{ >> + struct device_node *cpu_np; >> + struct of_phandle_args args; >> + struct clk *clk; >> + unsigned int cpu; >> + unsigned long xo_rate, cpu_hw_rate; >> + int ret; >> + >> + clk = clk_get(&pdev->dev, "xo"); >> + if (IS_ERR(clk)) >> + return PTR_ERR(clk); >> + >> + xo_rate = clk_get_rate(clk); >> + >> + clk_put(clk); >> + >> + clk = clk_get(&pdev->dev, "cpu_clk"); > > Sad that the name is cpu_clk, instead of something like 'backup' or > whatever the name really is in hardware. > Sure, would update it. -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation. --