Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp851238imm; Fri, 3 Aug 2018 12:43:08 -0700 (PDT) X-Google-Smtp-Source: AAOMgpchTEmYJP4L/681CMzkyNhOzPnJQpFgECd7Awu/SbgTPb/pdpqzLOFFwoXJYwf8OydV9n+F X-Received: by 2002:a65:6211:: with SMTP id d17-v6mr5221468pgv.450.1533325388271; Fri, 03 Aug 2018 12:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533325388; cv=none; d=google.com; s=arc-20160816; b=KEH34PBAbkTtze6ANkWS+Bs9qOhomrtdCRfI3MY06SOKqKlR3o8oGh9sltaJM1soa+ VWXHIg3azjOMMzPNzPIMj7ZPKVVSIZHzG+u+LT4/yC/p8DVC6fYjrnDMth2jElZDSesT x7ka/eZjEGt92+7CnU5NUFsfRDrHh0eCyMRAMwEc4aYjbgRRv/Br43sADJeSK1/cm4zg /UTQVzhmOcY/fUT2ek9SZoW7PlgdecQBkcPXosNe3aJLPgH88X8CwTU8Uayr0RX+M0h/ a9taOXuB2Flsh13w8+p/ImBE8FlpOnB5bEGb1XE81ejeeJkF8saonQR1NmkM4Z/8OQ9o OS2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=/G65AGOrfvruMssFYK33zUqOVJsOA+jofF11Fgshf54=; b=n6PUb9EHcd5qefj2QdzFvV0P5tRTtLYjWx7xDZy7YyOjm8KFVu+uzkfzypwSMf4kOW QvD3WcQYu970bnXQMmyjerKFH6M7CaT6xeoYIqwd4DkgQfoCW3IEIGsS5HIQlOamqSvn y8dakBsY5DXRTSXBhLn7nmiSX+qFYCf02obj/TPofnT+eXG2+HVWMDTqE64RleeDwwRf YTuQC9QuyQRMqJKeyuP2B8GuWKv+Mons+JvrwU0TItgywe9L4MoNVr4568ii6RAIONvq ADRhlj8lgGg1rq5fZkZJOATtBrmbPicTfyYrSugu4g6gAY275+woJumkclZ3FEZ/wCgZ pfPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=RE6SnWg7; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 20-v6si5979709pfr.242.2018.08.03.12.42.53; Fri, 03 Aug 2018 12:43:08 -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=@google.com header.s=20161025 header.b=RE6SnWg7; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731912AbeHCVjA (ORCPT + 99 others); Fri, 3 Aug 2018 17:39:00 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:40661 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727566AbeHCVjA (ORCPT ); Fri, 3 Aug 2018 17:39:00 -0400 Received: by mail-lj1-f193.google.com with SMTP id j19-v6so5822798ljc.7 for ; Fri, 03 Aug 2018 12:41:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/G65AGOrfvruMssFYK33zUqOVJsOA+jofF11Fgshf54=; b=RE6SnWg7/v4ZO01dgh0VRejcJJpuk6cj7zr0nkHc0Td9+W96srLB6m7v5R+88h4dgH Z+gG/SodWM/6K4hmqpbCZEZHinarxr/LjJkghYNl5vtn22NjQsF+uch13fxO5IyCoa5J Vb0AEuregqdZos004Yh/T5zzWNH6xNwTg0I3OjR2QN3R1IYVjoWMha8gv+wPMl2Le9Pk 8h18kMJuDGmBL7t26tOJTj+LhzSX1lbCbrai2nhPsrACbNUaApPWpWm68YSOn2TEhyj4 sQ50P9EL7eMz0oAOjd5cfxEyBXnBI6tobIH5WiBZhdqNE/0BY1byXOH4zDvPXW52RUk/ mXtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/G65AGOrfvruMssFYK33zUqOVJsOA+jofF11Fgshf54=; b=GaqtWJCKjysxfCw2Tel01MEaXjNnsJKCF/XB1GAc/SvYZ3QdXm2APgt8dc+67YIkIq /IRRXjW709Yn9kWQEohM4T+jwaRC2Jv1nvbJe+4MAnj6lB9Aw3rTEMDnnwaxc+K02m8L wJiDunYGJYzIrPI2En6VxSoiOqr38O3pyYGSWu09WqmiMwHEl9V8TIqbkXZ9Sw7FQMMU VyP8FKc3lypraxHGuIP1U6LPJ4H2UFukYWWePc2jRPOBRes1nHRR0aDQyP3/wH7hmp2g 9ouQyyWghJnSscCHarVlJ6FBH93O2O9bF6YZjaXKXsUCDE75PxBH9VW/Z1FGNAmePtFN wBtQ== X-Gm-Message-State: AOUpUlELsBOqrWkUB2ulg5vujLHaozNpk8l1gtcyg3vZzD6c7qU9b5/g dB2qRTkDDUDC2IpO8y2Ki/H9b58CklCNYDR1aW5SGg== X-Received: by 2002:a2e:1207:: with SMTP id t7-v6mr6079472lje.129.1533325277883; Fri, 03 Aug 2018 12:41:17 -0700 (PDT) MIME-Version: 1.0 References: <1532428970-18122-1-git-send-email-tdas@codeaurora.org> <1532428970-18122-3-git-send-email-tdas@codeaurora.org> In-Reply-To: <1532428970-18122-3-git-send-email-tdas@codeaurora.org> From: Evan Green Date: Fri, 3 Aug 2018 12:40:41 -0700 Message-ID: Subject: Re: [PATCH v7 2/2] cpufreq: qcom-hw: Add support for QCOM cpufreq HW driver To: tdas@codeaurora.org Cc: rjw@rjwysocki.net, Viresh Kumar , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, sboyd@kernel.org, Rajendra Nayak , anischal@codeaurora.org, devicetree@vger.kernel.org, robh@kernel.org, Saravana Kannan , amit.kucheria@linaro.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Taniya, On Tue, Jul 24, 2018 at 3:44 AM Taniya Das wrote: > > The CPUfreq HW present in some QCOM chipsets offloads the steps necessary > for changing the frequency of CPUs. The driver implements the cpufreq > driver interface for this hardware engine. > > Signed-off-by: Saravana Kannan > Signed-off-by: Taniya Das > --- > drivers/cpufreq/Kconfig.arm | 11 ++ > drivers/cpufreq/Makefile | 1 + > drivers/cpufreq/qcom-cpufreq-hw.c | 348 ++++++++++++++++++++++++++++++++++++++ > 3 files changed, 360 insertions(+) > create mode 100644 drivers/cpufreq/qcom-cpufreq-hw.c > ... > diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c > new file mode 100644 > index 0000000..ea8f7d1 > --- /dev/null > +++ b/drivers/cpufreq/qcom-cpufreq-hw.c ... > +static int qcom_cpufreq_hw_read_lut(struct platform_device *pdev, > + struct cpufreq_qcom *c) > +{ > + struct device *dev = &pdev->dev; > + void __iomem *base; > + u32 data, src, lval, i, core_count, prev_cc, prev_freq, cur_freq; > + > + c->table = devm_kcalloc(dev, LUT_MAX_ENTRIES + 1, > + sizeof(*c->table), GFP_KERNEL); > + if (!c->table) > + return -ENOMEM; > + > + base = c->reg_bases[REG_LUT_TABLE]; > + > + for (i = 0; i < LUT_MAX_ENTRIES; i++) { > + data = readl_relaxed(base + i * LUT_ROW_SIZE); > + src = (data & GENMASK(31, 30)) >> 30; > + lval = data & GENMASK(7, 0); > + core_count = CORE_COUNT_VAL(data); > + > + if (src) > + c->table[i].frequency = c->xo_rate * lval / 1000; > + else > + c->table[i].frequency = INIT_RATE / 1000; I don't know much about how this hardware works, but based on the mask, src has 4 possible values. So does 0 mean INIT_RATE, and 1, 2, and 3 all mean xo_rate? Also, is INIT_RATE really constant? It sounds like gpll0 (or gpll0_out_even?). You're already getting the xo clock, why not get gpll0's real rate as well?