From: Sudeep KarkadaNagesha <Sudeep.KarkadaNagesha@arm.com>
To: Andrew Lunn <andrew@lunn.ch>,
Sebastian Hesselbarth <sebastian.hesselbarth@googlemail.com>,
Jason Cooper <jason@lakedaemon.net>,
"rjw@rjwysocki.net" <rjw@rjwysocki.net>,
"viresh.kumar@linaro.org" <viresh.kumar@linaro.org>
Cc: linux ARM <linux-arm-kernel@lists.infradead.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>
Subject: Re: [PATCH 1/4] cpufreq: Add a cpufreq driver for Marvell Dove
Date: Tue, 22 Oct 2013 11:19:51 +0100 [thread overview]
Message-ID: <52665147.8080307@arm.com> (raw)
In-Reply-To: <1382186261-14482-2-git-send-email-andrew@lunn.ch>
On 19/10/13 13:37, Andrew Lunn wrote:
> The Marvell Dove SoC can run the CPU at two frequencies. The high
> frequencey is from a PLL, while the lower is the same as the DDR
> clock. Add a cpufreq driver to swap between these frequences.
>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
> drivers/cpufreq/Kconfig.arm | 7 ++
> drivers/cpufreq/Makefile | 1 +
> drivers/cpufreq/dove-cpufreq.c | 276 +++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 284 insertions(+)
> create mode 100644 drivers/cpufreq/dove-cpufreq.c
>
[snip]
> +static int dove_cpufreq_probe(struct platform_device *pdev)
> +{
> + struct device_node *np;
> + struct resource *res;
> + int err;
> + int irq;
> +
> + priv.dev = &pdev->dev;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + priv.dfs = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(priv.dfs))
> + return PTR_ERR(priv.dfs);
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + priv.pmu_cr = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(priv.pmu_cr))
> + return PTR_ERR(priv.pmu_cr);
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
> + priv.pmu_clk_div = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(priv.pmu_clk_div))
> + return PTR_ERR(priv.pmu_clk_div);
> +
> + np = of_find_node_by_path("/cpus/cpu@0");
> + if (!np)
> + return -ENODEV;
> +
You need not search for cpu nodes. When the cpu are registered, their of_node
gets initialised. So you can just use:
np = of_cpu_device_node_get(0);
However I think its better to just get:
cpu_dev = get_cpu_device(0);
as clk APIs can use cpu_dev
> + priv.cpu_clk = of_clk_get_by_name(np, "cpu_clk");
Now this can be
priv.cpu_clk = devm_clk_get(cpu_dev, "cpu_clk");
> + if (IS_ERR(priv.cpu_clk)) {
> + dev_err(priv.dev, "Unable to get cpuclk");
> + return PTR_ERR(priv.cpu_clk);
> + }
> +
> + clk_prepare_enable(priv.cpu_clk);
> + dove_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
> +
> + priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");
Similarly priv.ddr_clk = devm_clk_get(cpu_dev, "ddrclk");
> + if (IS_ERR(priv.ddr_clk)) {
> + dev_err(priv.dev, "Unable to get ddrclk");
> + err = PTR_ERR(priv.ddr_clk);
> + goto out_cpu;
> + }
> +
> + clk_prepare_enable(priv.ddr_clk);
> + dove_freq_table[1].frequency = clk_get_rate(priv.ddr_clk) / 1000;
> +
> + irq = irq_of_parse_and_map(np, 0);
Here you can use cpu_dev->of_node
Regards,
Sudeep
WARNING: multiple messages have this Message-ID (diff)
From: Sudeep.KarkadaNagesha@arm.com (Sudeep KarkadaNagesha)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] cpufreq: Add a cpufreq driver for Marvell Dove
Date: Tue, 22 Oct 2013 11:19:51 +0100 [thread overview]
Message-ID: <52665147.8080307@arm.com> (raw)
In-Reply-To: <1382186261-14482-2-git-send-email-andrew@lunn.ch>
On 19/10/13 13:37, Andrew Lunn wrote:
> The Marvell Dove SoC can run the CPU at two frequencies. The high
> frequencey is from a PLL, while the lower is the same as the DDR
> clock. Add a cpufreq driver to swap between these frequences.
>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
> drivers/cpufreq/Kconfig.arm | 7 ++
> drivers/cpufreq/Makefile | 1 +
> drivers/cpufreq/dove-cpufreq.c | 276 +++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 284 insertions(+)
> create mode 100644 drivers/cpufreq/dove-cpufreq.c
>
[snip]
> +static int dove_cpufreq_probe(struct platform_device *pdev)
> +{
> + struct device_node *np;
> + struct resource *res;
> + int err;
> + int irq;
> +
> + priv.dev = &pdev->dev;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + priv.dfs = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(priv.dfs))
> + return PTR_ERR(priv.dfs);
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> + priv.pmu_cr = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(priv.pmu_cr))
> + return PTR_ERR(priv.pmu_cr);
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
> + priv.pmu_clk_div = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(priv.pmu_clk_div))
> + return PTR_ERR(priv.pmu_clk_div);
> +
> + np = of_find_node_by_path("/cpus/cpu at 0");
> + if (!np)
> + return -ENODEV;
> +
You need not search for cpu nodes. When the cpu are registered, their of_node
gets initialised. So you can just use:
np = of_cpu_device_node_get(0);
However I think its better to just get:
cpu_dev = get_cpu_device(0);
as clk APIs can use cpu_dev
> + priv.cpu_clk = of_clk_get_by_name(np, "cpu_clk");
Now this can be
priv.cpu_clk = devm_clk_get(cpu_dev, "cpu_clk");
> + if (IS_ERR(priv.cpu_clk)) {
> + dev_err(priv.dev, "Unable to get cpuclk");
> + return PTR_ERR(priv.cpu_clk);
> + }
> +
> + clk_prepare_enable(priv.cpu_clk);
> + dove_freq_table[0].frequency = clk_get_rate(priv.cpu_clk) / 1000;
> +
> + priv.ddr_clk = of_clk_get_by_name(np, "ddrclk");
Similarly priv.ddr_clk = devm_clk_get(cpu_dev, "ddrclk");
> + if (IS_ERR(priv.ddr_clk)) {
> + dev_err(priv.dev, "Unable to get ddrclk");
> + err = PTR_ERR(priv.ddr_clk);
> + goto out_cpu;
> + }
> +
> + clk_prepare_enable(priv.ddr_clk);
> + dove_freq_table[1].frequency = clk_get_rate(priv.ddr_clk) / 1000;
> +
> + irq = irq_of_parse_and_map(np, 0);
Here you can use cpu_dev->of_node
Regards,
Sudeep
next prev parent reply other threads:[~2013-10-22 10:19 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-19 12:37 [PATCH 0/4] Dove cpufreq driver Andrew Lunn
2013-10-19 12:37 ` Andrew Lunn
2013-10-19 12:37 ` [PATCH 1/4] cpufreq: Add a cpufreq driver for Marvell Dove Andrew Lunn
2013-10-19 12:37 ` Andrew Lunn
2013-10-19 23:09 ` Luka Perkov
2013-10-19 23:09 ` Luka Perkov
2013-10-20 8:42 ` Andrew Lunn
2013-10-20 8:42 ` Andrew Lunn
2013-10-21 10:42 ` Sebastian Hesselbarth
2013-10-21 10:42 ` Sebastian Hesselbarth
2013-10-21 15:42 ` Andrew Lunn
2013-10-21 15:42 ` Andrew Lunn
2013-10-21 16:38 ` Sebastian Hesselbarth
2013-10-21 16:38 ` Sebastian Hesselbarth
2013-10-22 9:01 ` Viresh Kumar
2013-10-22 9:01 ` Viresh Kumar
2013-10-22 15:57 ` Andrew Lunn
2013-10-22 15:57 ` Andrew Lunn
2013-10-23 4:29 ` Viresh Kumar
2013-10-23 4:29 ` Viresh Kumar
2013-10-22 10:19 ` Sudeep KarkadaNagesha [this message]
2013-10-22 10:19 ` Sudeep KarkadaNagesha
2013-10-19 12:37 ` [PATCH 2/4] mvebu: Dove: Instantiate cpufreq driver Andrew Lunn
2013-10-19 12:37 ` Andrew Lunn
2013-10-21 10:47 ` Sebastian Hesselbarth
2013-10-21 10:47 ` Sebastian Hesselbarth
2013-10-21 15:26 ` Andrew Lunn
2013-10-21 15:26 ` Andrew Lunn
2013-10-19 12:37 ` [PATCH 3/4] mvebu: Dove: Enable cpufreq driver in defconfig Andrew Lunn
2013-10-19 12:37 ` Andrew Lunn
2013-10-19 12:37 ` [PATCH 4/4] mvebu: Dove: Add clocks and DFS interrupt to cpu node in DT Andrew Lunn
2013-10-19 12:37 ` Andrew Lunn
-- strict thread matches above, loose matches on Subject: below --
2013-10-23 13:04 [PATCH 1/4] cpufreq: Add a cpufreq driver for Marvell Dove Andrew Lunn
2013-10-23 13:04 ` Andrew Lunn
2013-10-23 13:40 ` Viresh Kumar
2013-10-23 13:40 ` Viresh Kumar
2013-10-23 13:51 ` Andrew Lunn
2013-10-23 13:51 ` Andrew Lunn
2013-10-23 14:25 ` Viresh Kumar
2013-10-23 14:25 ` Viresh Kumar
2013-10-23 14:36 ` Andrew Lunn
2013-10-23 14:36 ` Andrew Lunn
2013-10-23 15:00 ` Viresh Kumar
2013-10-23 15:00 ` Viresh Kumar
2013-10-23 14:59 ` Andrew Lunn
2013-10-23 14:59 ` Andrew Lunn
2013-10-24 2:17 ` Viresh Kumar
2013-10-24 2:17 ` Viresh Kumar
2013-10-28 11:31 ` Andrew Lunn
2013-10-28 11:31 ` Andrew Lunn
2013-10-29 11:33 ` Viresh Kumar
2013-10-29 11:33 ` Viresh Kumar
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=52665147.8080307@arm.com \
--to=sudeep.karkadanagesha@arm.com \
--cc=andrew@lunn.ch \
--cc=jason@lakedaemon.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=sebastian.hesselbarth@googlemail.com \
--cc=viresh.kumar@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.