From: Stephen Boyd <sboyd@codeaurora.org>
To: Sudeep Holla <sudeep.holla@arm.com>
Cc: linux-kernel@vger.kernel.org, Liviu Dudau <Liviu.Dudau@arm.com>,
Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
"Jon Medhurst (Tixy)" <tixy@linaro.org>,
Mike Turquette <mturquette@linaro.org>,
linux-clk@vger.kernel.org
Subject: Re: [PATCH 2/4] clk: add support for clocks provided by SCP(System Control Processor)
Date: Wed, 20 May 2015 16:43:11 -0700 [thread overview]
Message-ID: <20150520234311.GA31753@codeaurora.org> (raw)
In-Reply-To: <1430134846-24320-3-git-send-email-sudeep.holla@arm.com>
On 04/27, Sudeep Holla wrote:
> diff --git a/drivers/clk/Kconfig b/drivers/clk/Kconfig
> index 9897f353bf1a..906bf7dd72a2 100644
> --- a/drivers/clk/Kconfig
> +++ b/drivers/clk/Kconfig
> @@ -59,6 +59,16 @@ config COMMON_CLK_RK808
> clocked at 32KHz each. Clkout1 is always on, Clkout2 can off
> by control register.
>
> +config COMMON_CLK_SCPI
> + tristate "Clock driver controlled via SCPI interface"
> + depends on ARM_SCPI_PROTOCOL
|| COMPILE_TEST ?
> + ---help---
> + This driver provides support for clocks that are controlled
> + by firmware that implements the SCPI interface.
> +
> + This driver uses SCPI Message Protocol to interact with the
> + firware providing all the clock controls.
> +
> config COMMON_CLK_SI5351
> tristate "Clock driver for SiLabs 5351A/B/C"
> depends on I2C
> diff --git a/drivers/clk/clk-scpi.c b/drivers/clk/clk-scpi.c
> new file mode 100644
> index 000000000000..70a2d57da32d
> --- /dev/null
> +++ b/drivers/clk/clk-scpi.c
> @@ -0,0 +1,344 @@
> +#include <linux/clkdev.h>
Is clkdev used here?
> +#include <linux/clk-provider.h>
> +#include <linux/device.h>
> +#include <linux/err.h>
> +#include <linux/of.h>
> +#include <linux/module.h>
> +#include <linux/of_platform.h>
> +#include <linux/scpi_protocol.h>
> +
[...]
> +
> +static int scpi_dvfs_set_rate(struct clk_hw *hw, unsigned long rate,
> + unsigned long parent_rate)
> +{
> + struct scpi_clk *clk = to_scpi_clk(hw);
> + int ret = __scpi_find_dvfs_index(clk, rate);
> +
> + if (ret < 0)
> + return ret;
> + return scpi_ops->dvfs_set_idx(clk->id, (u8)ret);
> +}
> +
> +static struct clk_ops scpi_dvfs_ops = {
const?
> + .recalc_rate = scpi_dvfs_recalc_rate,
> + .round_rate = scpi_dvfs_round_rate,
> + .set_rate = scpi_dvfs_set_rate,
> +};
> +
> +static struct clk *
> +scpi_dvfs_ops_init(struct device *dev, struct device_node *np,
> + struct scpi_clk *sclk)
> +{
> + struct clk_init_data init;
> + struct scpi_dvfs_info *info;
> +
> + init.name = sclk->name;
> + init.flags = CLK_IS_ROOT;
> + init.num_parents = 0;
> + init.ops = &scpi_dvfs_ops;
> + sclk->hw.init = &init;
> +
> + info = scpi_ops->dvfs_get_info(sclk->id);
> + if (IS_ERR(info))
> + return (struct clk *)info;
return ERR_CAST(info)?
> +
> + sclk->info = info;
> +
> + return devm_clk_register(dev, &sclk->hw);
> +}
> +
> +
[...]
> +static int scpi_clk_probe(struct platform_device *pdev)
> +{
> + struct clk **clks;
> + int idx, count;
> + struct clk_onecell_data *clk_data;
> + struct device *dev = &pdev->dev;
> + struct device_node *np = dev->of_node;
> + struct clk *(*clk_ops_init)(struct device *, struct device_node *,
> + struct scpi_clk *);
> +
> + if (!of_device_is_available(np))
> + return -ENODEV;
Is this because of_platform_populate() populates disabled nodes?
> +
> + clk_ops_init = of_match_node(scpi_clk_match, np)->data;
> + if (!clk_ops_init)
> + return -ENODEV;
> +
> + count = of_property_count_strings(np, "clock-output-names");
> + if (count < 0) {
> + dev_err(dev, "%s: invalid clock output count\n", np->name);
> + return -EINVAL;
> + }
> +
> + clk_data = devm_kmalloc(dev, sizeof(*clk_data), GFP_KERNEL);
> + if (!clk_data) {
> + dev_err(dev, "failed to allocate clock provider data\n");
> + return -ENOMEM;
> + }
> +
> + clks = devm_kmalloc(dev, count * sizeof(*clks), GFP_KERNEL);
devm_kcalloc()?
> + if (!clks) {
> + dev_err(dev, "failed to allocate clock providers\n");
Error messages on allocation failures are useless. Please remove.
> + return -ENOMEM;
> + }
> +
> + for (idx = 0; idx < count; idx++) {
> + struct scpi_clk *sclk;
[...]
> +static int scpi_clk_remove(struct platform_device *pdev)
> +{
> + of_clk_del_provider(pdev->dev.of_node);
> + platform_set_drvdata(pdev, NULL);
We don't need to set platform_drvdata to NULL here.
> + return 0;
> +}
> +
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2015-05-20 23:43 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-27 11:40 [PATCH 0/4] ARM64: add SCPI mailbox protocol, clock and CPUFreq support Sudeep Holla
2015-04-27 11:40 ` [PATCH 1/4] mailbox: add support for System Control and Power Interface(SCPI) protocol Sudeep Holla
2015-04-28 7:36 ` Paul Bolle
2015-04-28 8:41 ` Sudeep Holla
2015-04-28 13:54 ` Jon Medhurst (Tixy)
2015-04-29 10:53 ` Sudeep Holla
2015-04-29 11:43 ` Jon Medhurst (Tixy)
2015-04-29 12:25 ` Jon Medhurst (Tixy)
2015-04-29 13:08 ` Sudeep Holla
2015-04-30 8:49 ` Jon Medhurst (Tixy)
2015-04-29 13:01 ` Sudeep Holla
2015-05-13 16:52 ` Jassi Brar
2015-05-13 17:09 ` Sudeep Holla
2015-05-14 7:02 ` Jassi Brar
2015-05-14 7:30 ` Jassi Brar
2015-05-14 8:25 ` Sudeep Holla
2015-04-27 11:40 ` [PATCH 2/4] clk: add support for clocks provided by SCP(System Control Processor) Sudeep Holla
2015-05-07 10:17 ` Lorenzo Pieralisi
2015-05-20 23:43 ` Stephen Boyd [this message]
2015-05-26 13:14 ` Sudeep Holla
2015-04-27 11:40 ` [PATCH 3/4] clk: scpi: add support for cpufreq virtual device Sudeep Holla
2015-05-20 23:45 ` Stephen Boyd
2015-05-26 13:25 ` Sudeep Holla
2015-04-27 11:40 ` [PATCH 4/4] cpufreq: arm_big_little: add SCPI interface driver Sudeep Holla
2015-04-29 5:44 ` Viresh Kumar
2015-04-29 9:39 ` Sudeep Holla
2015-05-01 13:19 ` Jon Medhurst (Tixy)
2015-05-01 13:32 ` Sudeep Holla
2015-05-01 14:12 ` Jon Medhurst (Tixy)
2015-05-01 14:15 ` Sudeep Holla
2015-05-01 17:10 ` Jon Medhurst (Tixy)
2015-05-01 17:14 ` Sudeep Holla
2015-04-27 18:11 ` [PATCH 0/4] ARM64: add SCPI mailbox protocol, clock and CPUFreq support Jon Medhurst (Tixy)
2015-04-28 8:47 ` Sudeep Holla
2015-04-28 14:21 ` Sudeep Holla
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=20150520234311.GA31753@codeaurora.org \
--to=sboyd@codeaurora.org \
--cc=Liviu.Dudau@arm.com \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mturquette@linaro.org \
--cc=sudeep.holla@arm.com \
--cc=tixy@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 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).