From: viresh.kumar@linaro.org (Viresh Kumar)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 14/15] cpufreq: Add module to register cpufreq on Krait CPUs
Date: Mon, 8 Sep 2014 10:16:19 +0530 [thread overview]
Message-ID: <CAKohpokLFMMK-h2657=_BCBr3oXCTiQDA+C-rDgorxfrPR-9YQ@mail.gmail.com> (raw)
In-Reply-To: <1409957256-23729-16-git-send-email-sboyd@codeaurora.org>
On 6 September 2014 04:17, Stephen Boyd <sboyd@codeaurora.org> wrote:
> diff --git a/drivers/cpufreq/qcom-cpufreq.c b/drivers/cpufreq/qcom-cpufreq.c
> new file mode 100644
> index 000000000000..aa8eb97144b6
> --- /dev/null
> +++ b/drivers/cpufreq/qcom-cpufreq.c
> @@ -0,0 +1,199 @@
> +/* Copyright (c) 2014, The Linux Foundation. All rights reserved.
Shouldn't this have Qcom instead?
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 and
> + * only version 2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/cpu.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +#include <linux/err.h>
> +#include <linux/io.h>
> +#include <linux/slab.h>
> +#include <linux/pm_opp.h>
> +#include <linux/init.h>
Would be good if these can be in alphanumeric order. That helps maintaining
them later on..
> +static void __init get_krait_bin_format_a(int *speed, int *pvs, int *pvs_ver)
> +{
> +}
> +
> +static void __init get_krait_bin_format_b(int *speed, int *pvs, int *pvs_ver)
> +{
> +}
To be honest, I didn't try to apply much brain on the above routines :)
> +static int __init qcom_cpufreq_populate_opps(void)
> +{
> + int len, num_rows, i, k;
> + char table_name[] = "qcom,speedXX-pvsXX-bin-vXX";
> + struct device_node *np;
> + struct device *dev;
> + int cpu = 0;
> + int speed, pvs, pvs_ver;
> + int cols;
All the 'int' declarations can be combined in a single line if you would like.
> + np = of_find_node_by_name(NULL, "qcom,pvs");
> + if (!np)
> + pr_warn("Can't find PVS node\n");
> +
> + if (of_property_read_bool(np, "qcom,pvs-format-a")) {
> + get_krait_bin_format_a(&speed, &pvs, &pvs_ver);
> + cols = 2;
> + } else {
> + get_krait_bin_format_b(&speed, &pvs, &pvs_ver);
> + cols = 3;
> + }
> +
> + snprintf(table_name, sizeof(table_name),
> + "qcom,speed%d-pvs%d-bin-v%d", speed, pvs, pvs_ver);
> +again:
> + dev = get_cpu_device(cpu);
> + if (!dev)
> + return -ENODEV;
> +
> + if (!of_find_property(np, table_name, &len))
> + return -EINVAL;
> +
> + len /= sizeof(u32);
> + if (len % cols || len == 0)
> + return -EINVAL;
> +
> + num_rows = len / cols;
> +
> + for (i = 0, k = 0; i < num_rows; i++) {
> + u32 freq, volt;
> +
> + of_property_read_u32_index(np, table_name, k++, &freq);
> + of_property_read_u32_index(np, table_name, k++, &volt);
> + while (k % cols)
> + k++; /* Skip uA entries if present */
> + if (dev_pm_opp_add(dev, freq, volt))
> + pr_warn("failed to add OPP %u\n", freq);
> + }
> +
> + if (cpu++ < num_possible_cpus())
> + goto again;
> +
> + return 0;
> +}
> +
> +static int __init qcom_cpufreq_driver_init(void)
> +{
> + struct platform_device_info devinfo = { .name = "cpufreq-generic", };
> + struct device *cpu_dev;
> + struct device_node *np;
> + struct platform_device *pdev;
> +
> + cpu_dev = get_cpu_device(0);
> + if (!cpu_dev)
> + return -ENODEV;
> +
> + np = of_node_get(cpu_dev->of_node);
> + if (!np)
> + return -ENOENT;
> +
> + if (!of_device_is_compatible(np, "qcom,krait")) {
> + of_node_put(np);
> + return -ENODEV;
> + }
> + of_node_put(np);
> +
> + qcom_cpufreq_populate_opps();
> + pdev = platform_device_register_full(&devinfo);
> +
> + return PTR_ERR_OR_ZERO(pdev);
> +}
> +module_init(qcom_cpufreq_driver_init);
> +
> +MODULE_DESCRIPTION("Qualcomm CPUfreq driver");
A module author as well?
> +MODULE_LICENSE("GPL v2");
Otherwise mostly good:
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
next prev parent reply other threads:[~2014-09-08 4:46 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-05 22:47 [PATCH v2 00/15] Krait clocks + Krait CPUfreq Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 01/15] clk: mux: Add unregistration API Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 02/15] clk: mux: Split out register accessors for reuse Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 03/15] clk: Add __clk_mux_determine_rate_closest Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 04/15] clk: divider: Make generic for usage elsewhere Stephen Boyd
2014-10-03 18:07 ` Stephen Boyd
2014-10-07 17:27 ` Srinivas Kandagatla
2014-10-07 18:26 ` Stephen Boyd
2014-10-07 19:28 ` Srinivas Kandagatla
2014-10-08 15:04 ` Srinivas Kandagatla
2014-09-05 22:47 ` Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 05/15] clk: Add safe switch hook Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 06/15] clk: Avoid sending high rates to downstream clocks during set_rate Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 07/15] clk: qcom: Add support for High-Frequency PLLs (HFPLLs) Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 08/15] clk: qcom: Add HFPLL driver Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 09/15] clk: qcom: Add MSM8960/APQ8064's HFPLLs Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 10/15] clk: qcom: Add IPQ806X's HFPLLs Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 11/15] clk: qcom: Add support for Krait clocks Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 12/15] clk: qcom: Add KPSS ACC/GCC driver Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 13/15] clk: qcom: Add Krait clock controller driver Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 14/15] cpufreq: Add module to register cpufreq on Krait CPUs Stephen Boyd
2014-09-08 4:46 ` Viresh Kumar [this message]
2014-09-08 17:15 ` Christopher Covington
2014-09-09 0:37 ` Stephen Boyd
2014-09-09 4:53 ` Viresh Kumar
2014-09-05 22:47 ` Stephen Boyd
2014-09-05 22:47 ` [PATCH v2 15/15] ARM: dts: qcom: Add necessary DT data for Krait cpufreq Stephen Boyd
2014-09-08 9:42 ` [PATCH v2 00/15] Krait clocks + Krait CPUfreq Pramod Gurav
2014-09-08 11:59 ` Pramod Gurav
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKohpokLFMMK-h2657=_BCBr3oXCTiQDA+C-rDgorxfrPR-9YQ@mail.gmail.com' \
--to=viresh.kumar@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).