Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3195792imm; Fri, 24 Aug 2018 12:17:51 -0700 (PDT) X-Google-Smtp-Source: ANB0VdapMzHbMkwxaU5gblvAdjDg2zZMMZfqJVee+N+E9YrKd4PNB2Ck56H14YozF3MS2s44vW9b X-Received: by 2002:a17:902:2ac3:: with SMTP id j61-v6mr2834942plb.172.1535138271708; Fri, 24 Aug 2018 12:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535138271; cv=none; d=google.com; s=arc-20160816; b=y97hk8HJT3gnPQZDVUFizOHYiQwuS9m7hH2NHUw6RTTtbmU76UqIVMorzQliOZIimG HGP9dsCt/EQtH597sOQgA6V4Lhfs08xtuXdrn4/rCKnvq0ng3TrI7WF7gTnQUlvAsSrl AOHFZnpW8+OCF2xH022TeSnom9+YXknOo2lSz/93lY1f546rb3s9IhTX9ZhhO+ncwgpH 8/KuDgjNQAIEPtR5wZr+AQT33eAd1eYCuJ4lQo+P8NwY+g3lO7qXcITUC6t3zXi0hAgZ 2fBcqqjpMrrsGcs76Q4D9Sr+a4J650bYwjCw9zw1OYj/p0zBN+KGeT9xk6o2j47QP5vR mp5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=fi2uQLV5rH8UsXufimjpHsOjLcTER3hF40YbOm6le0U=; b=sjozCIDGJzYE5IYlkXLRgPw7cT1JlrAzvZ0ormjPJF1oNUW7yyhaxYnHXLC4KGez1T rGuGWxPIL2AvKjnYkgWoNE2FyCHCx5psMTVto2QusaGcMAdo5bPTXMFB79VdB2OgjKtD hh1FGDgAhaeuFB2MGP901mQx3xzwRRXnYljbnP4OqgOz+LTUdKCjEyxEPy/wIToJ2J/4 A9MHOv2N2KdosZ2Qi2Rg7tbM3urAyb8Vssrr1ai4/YmLNlvDbibvobZrgHawB0HFnRpX c0j7ZvE/sX9oeofbV4VL6Vvgn25zhv6BWz9HtDLuEGYnZll/9AXV2I4vWjvqL1PBrKE4 NbpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C9TEazcZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o3-v6si7250591plk.321.2018.08.24.12.17.35; Fri, 24 Aug 2018 12:17: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=@linaro.org header.s=google header.b=C9TEazcZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726943AbeHXWv7 (ORCPT + 99 others); Fri, 24 Aug 2018 18:51:59 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:46831 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726613AbeHXWv7 (ORCPT ); Fri, 24 Aug 2018 18:51:59 -0400 Received: by mail-lf1-f65.google.com with SMTP id e23-v6so7441617lfc.13 for ; Fri, 24 Aug 2018 12:16:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=fi2uQLV5rH8UsXufimjpHsOjLcTER3hF40YbOm6le0U=; b=C9TEazcZc55qssGoWaNnJEO1fzcPfiBS9hB3eB4RO0H9BuQSwMoi5aWgWvoxNurp/g rqAnK2qK6U7bevJvpca1+Ln9KPRpdGht+WT3Jg5LVb9cglef+Hl5Fvz8mr5HNZ3y6feJ brJFC7uUYo+3kwGfqLu1jgs/abV8mlfmYGvEM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=fi2uQLV5rH8UsXufimjpHsOjLcTER3hF40YbOm6le0U=; b=WpLM+ghuXosJVn++yLtZqOBBzjg559PrPgp5GPrxelsDnonD+V7AEDCrgZCvlGvSzf 42GrZcbs4PgmsvIU5qFe5trk29XLM1dYcMng8LnfBUxmrxnzYwqNeJGaL22ioCM1l6uB Di3Qyn2kvoetv72ZmKJ1ZTSttZMLs0G0OKOQzlVdQ8/xt8ODwlkQu9XWi3Pk2NT53mAI kEGKzWpxVopYFwjDROun+MrudiuwvfEcPG1dWhexK4QndKx4N7Ig+8AxHknldt1dMgt4 97jbMdZFN/tcp/ZNnYFKjD28UmgdVUYxsd9yryz+ydGuzB8kBCV18zwESTy9xBHkEkow 7MXw== X-Gm-Message-State: APzg51DG6Rl9I/dlrOU7R95hyXa0I/W+yIuHAY2cI4lgAIHKv5fl9iFx +kWe+N3OjDBpESSD3XPiIXhUIpNPAQQ= X-Received: by 2002:a19:53d6:: with SMTP id h83-v6mr2268338lfl.15.1535138161700; Fri, 24 Aug 2018 12:16:01 -0700 (PDT) Received: from centauri.lan (h-229-118.A785.priv.bahnhof.se. [5.150.229.118]) by smtp.gmail.com with ESMTPSA id z10-v6sm1317668ljh.57.2018.08.24.12.16.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 24 Aug 2018 12:16:01 -0700 (PDT) Date: Fri, 24 Aug 2018 21:15:58 +0200 From: Niklas Cassel To: Sricharan R Cc: mark.rutland@arm.com, robh@kernel.org, sudeep.holla@arm.com, linux@arm.linux.org.uk, ctatlor97@gmail.com, rjw@rjwysocki.net, viresh.kumar@linaro.org, mturquette@baylibre.com, linux-pm@vger.kernel.org, sboyd@codeaurora.org, linux@armlinux.org.uk, thierry.escande@linaro.org, linux-kernel@vger.kernel.org, david.brown@linaro.org, devicetree@vger.kernel.org, linux-arm-msm@vger.kernel.org, andy.gross@linaro.org, linux-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v12 14/14] cpufreq: qcom: Add support for krait based socs Message-ID: <20180824191558.GA13127@centauri.lan> References: <1534248753-2440-1-git-send-email-sricharan@codeaurora.org> <1534248753-2440-15-git-send-email-sricharan@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1534248753-2440-15-git-send-email-sricharan@codeaurora.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 14, 2018 at 05:42:33PM +0530, Sricharan R wrote: > In Certain QCOM SoCs like ipq8064, apq8064, msm8960, msm8974 > that has KRAIT processors the voltage/current value of each OPP > varies based on the silicon variant in use. > > The required OPP related data is determined based on > the efuse value. This is similar to the existing code for > kryo cores. So adding support for krait cores here. > > Signed-off-by: Sricharan R > --- > .../devicetree/bindings/opp/qcom-nvmem-cpufreq.txt | 3 +- > drivers/cpufreq/Kconfig.arm | 2 +- > drivers/cpufreq/cpufreq-dt-platdev.c | 5 + > drivers/cpufreq/qcom-cpufreq-nvmem.c | 151 +++++++++++++++++++-- > 4 files changed, 149 insertions(+), 12 deletions(-) > > diff --git a/Documentation/devicetree/bindings/opp/qcom-nvmem-cpufreq.txt b/Documentation/devicetree/bindings/opp/qcom-nvmem-cpufreq.txt > index 6dcdfcd..7bc0f1a 100644 > --- a/Documentation/devicetree/bindings/opp/qcom-nvmem-cpufreq.txt > +++ b/Documentation/devicetree/bindings/opp/qcom-nvmem-cpufreq.txt > @@ -19,7 +19,8 @@ In 'cpus' nodes: > > In 'operating-points-v2' table: > - compatible: Should be > - - 'operating-points-v2-qcom-cpu' for apq8096 and msm8996. > + - 'operating-points-v2-qcom-cpu' for apq8096, msm8996, msm8974, > + apq8064, msm8960 and ipq8074. > - nvmem-cells: A phandle pointing to a nvmem-cells node representing the > efuse registers that has information about the > speedbin that is used to select the right frequency/voltage > diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm > index 13fbd97..497ae89 100644 > --- a/drivers/cpufreq/Kconfig.arm > +++ b/drivers/cpufreq/Kconfig.arm > @@ -126,7 +126,7 @@ config ARM_OMAP2PLUS_CPUFREQ > > config ARM_QCOM_CPUFREQ_NVMEM > tristate "Qualcomm nvmem based CPUFreq" > - depends on ARM64 > + depends on ARCH_QCOM > depends on QCOM_QFPROM > depends on QCOM_SMEM > select PM_OPP > diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c > index fe14c57..917cdc2 100644 > --- a/drivers/cpufreq/cpufreq-dt-platdev.c > +++ b/drivers/cpufreq/cpufreq-dt-platdev.c > @@ -128,6 +128,11 @@ > { .compatible = "ti,am43", }, > { .compatible = "ti,dra7", }, > > + { .compatible = "qcom,ipq8064", }, > + { .compatible = "qcom,apq8064", }, > + { .compatible = "qcom,msm8974", }, > + { .compatible = "qcom,msm8960", }, > + > { } > }; > > diff --git a/drivers/cpufreq/qcom-cpufreq-nvmem.c b/drivers/cpufreq/qcom-cpufreq-nvmem.c > index 0ad8e5b..5f2add0 100644 > --- a/drivers/cpufreq/qcom-cpufreq-nvmem.c > +++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c > @@ -45,6 +45,82 @@ enum _msm8996_version { > > static struct platform_device *cpufreq_dt_pdev, *cpufreq_pdev; > > +static void __init get_krait_bin_format_a(int *speed, int *pvs, int *pvs_ver, > + struct nvmem_cell *pvs_nvmem, u8 *buf) Hello Sricharan, pvs_nvmem seems to be unused both here and in get_krait_bin_format_b(). Kind regards, Niklas > +{ > + u32 pte_efuse; > + > + pte_efuse = *((u32 *)buf); > + > + *speed = pte_efuse & 0xf; > + if (*speed == 0xf) > + *speed = (pte_efuse >> 4) & 0xf; > + > + if (*speed == 0xf) { > + *speed = 0; > + pr_warn("Speed bin: Defaulting to %d\n", *speed); > + } else { > + pr_info("Speed bin: %d\n", *speed); > + } > + > + *pvs = (pte_efuse >> 10) & 0x7; > + if (*pvs == 0x7) > + *pvs = (pte_efuse >> 13) & 0x7; > + > + if (*pvs == 0x7) { > + *pvs = 0; > + pr_warn("PVS bin: Defaulting to %d\n", *pvs); > + } else { > + pr_info("PVS bin: %d\n", *pvs); > + } > + > + kfree(buf); > +} > + > +static void __init get_krait_bin_format_b(int *speed, int *pvs, int *pvs_ver, > + struct nvmem_cell *pvs_nvmem, u8 *buf) > +{ > + u32 pte_efuse, redundant_sel; > + > + pte_efuse = *((u32 *)buf); > + redundant_sel = (pte_efuse >> 24) & 0x7; > + *speed = pte_efuse & 0x7; > + > + /* 4 bits of PVS are in efuse register bits 31, 8-6. */ > + *pvs = ((pte_efuse >> 28) & 0x8) | ((pte_efuse >> 6) & 0x7); > + *pvs_ver = (pte_efuse >> 4) & 0x3; > + > + switch (redundant_sel) { > + case 1: > + *speed = (pte_efuse >> 27) & 0xf; > + break; > + case 2: > + *pvs = (pte_efuse >> 27) & 0xf; > + break; > + } > + > + /* Check SPEED_BIN_BLOW_STATUS */ > + if (pte_efuse & BIT(3)) { > + pr_info("Speed bin: %d\n", *speed); > + } else { > + pr_warn("Speed bin not set. Defaulting to 0!\n"); > + *speed = 0; > + } > + > + /* Check PVS_BLOW_STATUS */ > + pte_efuse = *(((u32 *)buf) + 4); > + pte_efuse &= BIT(21); > + if (pte_efuse) { > + pr_info("PVS bin: %d\n", *pvs); > + } else { > + pr_warn("PVS bin not set. Defaulting to 0!\n"); > + *pvs = 0; > + } > + > + pr_info("PVS version: %d\n", *pvs_ver); > + kfree(buf); > +} > + > static enum _msm8996_version __init qcom_cpufreq_get_msm_id(void) > { > size_t len; > @@ -74,6 +150,35 @@ static enum _msm8996_version __init qcom_cpufreq_get_msm_id(void) > return version; > } > > +static int qcom_cpufreq_krait_name_version(struct device *cpu_dev, > + struct nvmem_cell *speedbin_nvmem, > + char **name, > + u32 *versions) > +{ > + int speed = 0, pvs = 0, pvs_ver = 0; > + u8 *buf; > + size_t len; > + > + buf = nvmem_cell_read(speedbin_nvmem, &len); > + if (len == 4) { > + get_krait_bin_format_a(&speed, &pvs, &pvs_ver, > + speedbin_nvmem, buf); > + } else if (len == 8) { > + get_krait_bin_format_b(&speed, &pvs, &pvs_ver, > + speedbin_nvmem, buf); > + } else { > + dev_err(cpu_dev, "Unable to read nvmem data. Defaulting to 0!\n"); > + return -ENODEV; > + } > + > + snprintf(*name, sizeof("speedXX-pvsXX-vXX"), "speed%d-pvs%d-v%d", > + speed, pvs, pvs_ver); > + > + *versions = (1 << speed); > + > + return 0; > +} > + > static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev, > struct nvmem_cell *speedbin_nvmem, > char **pvs_name, > @@ -83,6 +188,7 @@ static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev, > u8 *speedbin; > enum _msm8996_version msm8996_version; > > + *pvs_name = NULL; > msm8996_version = qcom_cpufreq_get_msm_id(); > if (NUM_OF_MSM8996_VERSIONS == msm8996_version) { > dev_err(cpu_dev, "Not Snapdragon 820/821!"); > @@ -111,7 +217,7 @@ static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev, > > static int qcom_cpufreq_probe(struct platform_device *pdev) > { > - struct opp_table *opp_tables[NR_CPUS] = { NULL }; > + struct opp_table *tbl1[NR_CPUS] = { NULL }, *tbl2[NR_CPUS] = { NULL }; > int (*get_version)(struct device *cpu_dev, > struct nvmem_cell *speedbin_nvmem, > char **name, int *versions); > @@ -120,8 +226,8 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) > struct device *cpu_dev; > unsigned cpu; > u32 versions; > - char *pvs_name = NULL; > const struct of_device_id *match; > + char *pvs_name = "speedXX-pvsXX-vXX"; > int ret; > > cpu_dev = get_cpu_device(0); > @@ -163,10 +269,19 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) > goto free_opp; > } > > - opp_tables[cpu] = dev_pm_opp_set_supported_hw(cpu_dev, > - &versions, 1); > - if (IS_ERR(opp_tables[cpu])) { > - ret = PTR_ERR(opp_tables[cpu]); > + if (pvs_name) { > + tbl1[cpu] = dev_pm_opp_set_prop_name(cpu_dev, pvs_name); > + if (IS_ERR(tbl1[cpu])) { > + ret = PTR_ERR(tbl1[cpu]); > + dev_err(cpu_dev, "Failed to add OPP name %s\n", > + pvs_name); > + goto free_opp; > + } > + } > + > + tbl2[cpu] = dev_pm_opp_set_supported_hw(cpu_dev, &versions, 1); > + if (IS_ERR(tbl2[cpu])) { > + ret = PTR_ERR(tbl2[cpu]); > dev_err(cpu_dev, "Failed to set supported hardware\n"); > goto free_opp; > } > @@ -182,9 +297,15 @@ static int qcom_cpufreq_probe(struct platform_device *pdev) > > free_opp: > for_each_possible_cpu(cpu) { > - if (IS_ERR_OR_NULL(opp_tables[cpu])) > + if (IS_ERR_OR_NULL(tbl1[cpu])) > + break; > + dev_pm_opp_put_prop_name(tbl1[cpu]); > + } > + > + for_each_possible_cpu(cpu) { > + if (IS_ERR_OR_NULL(tbl2[cpu])) > break; > - dev_pm_opp_put_supported_hw(opp_tables[cpu]); > + dev_pm_opp_put_supported_hw(tbl2[cpu]); > } > > return ret; > @@ -205,8 +326,18 @@ static int qcom_cpufreq_remove(struct platform_device *pdev) > }; > > static const struct of_device_id qcom_cpufreq_match_list[] __initconst = { > - { .compatible = "qcom,apq8096", .data = qcom_cpufreq_kryo_name_version}, > - { .compatible = "qcom,msm8996", .data = qcom_cpufreq_kryo_name_version}, > + { .compatible = "qcom,apq8096", > + .data = qcom_cpufreq_kryo_name_version}, > + { .compatible = "qcom,msm8996", > + .data = qcom_cpufreq_kryo_name_version}, > + { .compatible = "qcom,ipq8064", > + .data = qcom_cpufreq_krait_name_version }, > + { .compatible = "qcom,apq8064", > + .data = qcom_cpufreq_krait_name_version }, > + { .compatible = "qcom,msm8974", > + .data = qcom_cpufreq_krait_name_version }, > + { .compatible = "qcom,msm8960", > + .data = qcom_cpufreq_krait_name_version }, > {}, > }; > > -- > QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation >