From: Nishanth Menon <nm@ti.com>
To: Rajendra Nayak <rnayak@ti.com>,
linux-omap@vger.kernel.org, tony@atomide.com, paul@pwsan.com
Cc: mark.rutland@arm.com, mturquette@linaro.org,
linux-arm-kernel@lists.infradead.org, bcousson@baylibre.com
Subject: Re: [PATCH v2 2/3] ARM: OMAP2+: Add support to parse optional clk info from DT
Date: Thu, 9 Jan 2014 09:19:38 -0600 [thread overview]
Message-ID: <52CEBE0A.60007@ti.com> (raw)
In-Reply-To: <1386848309-14076-3-git-send-email-rnayak@ti.com>
On 12/12/2013 05:38 AM, Rajendra Nayak wrote:
> With clocks for OMAP moving to DT, its now possible to pass all optional clock
> data for each device from DT instead of having it in hwmod.
>
> Signed-off-by: Rajendra Nayak <rnayak@ti.com>
> ---
> arch/arm/mach-omap2/omap_hwmod.c | 65 ++++++++++++++++++++++++++++++++++++--
> 1 file changed, 63 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index f22bbbb..271634f 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -807,6 +807,64 @@ static int _init_interface_clks(struct omap_hwmod *oh)
> return ret;
> }
>
> +static const char **_parse_opt_clks_dt(struct omap_hwmod *oh,
> + struct device_node *np,
> + int *opt_clks_cnt)
> +{
> + int i, clks_cnt;
> + const char *clk_name;
> + const char **opt_clk_names;
> +
> + clks_cnt = of_property_count_strings(np, "clock-names");
> + if (!clks_cnt)
> + return NULL;
> +
> + opt_clk_names = kzalloc(sizeof(char *)*clks_cnt, GFP_KERNEL);
> + if (!opt_clk_names)
> + return NULL;
> +
> + for (i = 0; i < clks_cnt; i++) {
> + of_property_read_string_index(np, "clock-names", i, &clk_name);
> + if (!strcmp(clk_name, "fck"))
> + continue;
> + opt_clks_cnt++;
> + opt_clk_names[i] = clk_name;
This assumes that any clock-names entry which does not match "fck" is
an optional clock that should be controlled by hwmod -> this is not
always the case and in cases such as gpio or mmc, the optional
debounce clock is actually prefered to be controlled by the driver.
we wont have a way around that.
> + }
> + return opt_clk_names;
> +}
> +
> +static int _init_opt_clks_dt(struct omap_hwmod *oh, struct device_node *np)
> +{
> + struct clk *c;
> + int i, opt_clks_cnt = 0;
> + int ret = 0;
> + const char **opt_clk_names;
> +
> + opt_clk_names = _parse_opt_clks_dt(oh, np, &opt_clks_cnt);
> + if (!opt_clk_names)
> + return -EINVAL;
> +
> + oh->opt_clks = kzalloc(sizeof(struct omap_hwmod_opt_clk *)
> + * opt_clks_cnt, GFP_KERNEL);
> + if (!oh->opt_clks)
> + return -ENOMEM;
> +
> + oh->opt_clks_cnt = opt_clks_cnt;
> +
> + for (i = 0; i < oh->opt_clks_cnt; i++) {
> + c = of_clk_get_by_name(np, opt_clk_names[i]);
> + if (IS_ERR(c)) {
> + pr_warn("omap_hwmod: %s: cannot clk_get opt_clk %s\n",
> + oh->name, opt_clk_names[i]);
> + ret = -EINVAL;
> + }
> + oh->opt_clks[i]._clk = c;
> + oh->opt_clks[i].role = opt_clk_names[i];
> + clk_prepare(oh->opt_clks[i]._clk);
> + }
> + return ret;
> +}
> +
> /**
> * _init_opt_clk - get a struct clk * for the the hwmod's optional clocks
> * @oh: struct omap_hwmod *
> @@ -814,13 +872,16 @@ static int _init_interface_clks(struct omap_hwmod *oh)
> * Called from _init_clocks(). Populates the @oh omap_hwmod_opt_clk
> * clock pointers. Returns 0 on success or -EINVAL on error.
> */
> -static int _init_opt_clks(struct omap_hwmod *oh)
> +static int _init_opt_clks(struct omap_hwmod *oh, struct device_node *np)
> {
> struct omap_hwmod_opt_clk *oc;
> struct clk *c;
> int i;
> int ret = 0;
>
> + if (of_get_property(np, "clocks", NULL))
> + return _init_opt_clks_dt(oh, np);
> +
> for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) {
> c = clk_get(NULL, oc->clk);
> if (IS_ERR(c)) {
> @@ -1590,7 +1651,7 @@ static int _init_clocks(struct omap_hwmod *oh, void *data,
>
> ret |= _init_main_clk(oh, np);
> ret |= _init_interface_clks(oh);
> - ret |= _init_opt_clks(oh);
> + ret |= _init_opt_clks(oh, np);
>
> if (!ret)
> oh->_state = _HWMOD_STATE_CLKS_INITED;
>
--
Regards,
Nishanth Menon
WARNING: multiple messages have this Message-ID (diff)
From: nm@ti.com (Nishanth Menon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/3] ARM: OMAP2+: Add support to parse optional clk info from DT
Date: Thu, 9 Jan 2014 09:19:38 -0600 [thread overview]
Message-ID: <52CEBE0A.60007@ti.com> (raw)
In-Reply-To: <1386848309-14076-3-git-send-email-rnayak@ti.com>
On 12/12/2013 05:38 AM, Rajendra Nayak wrote:
> With clocks for OMAP moving to DT, its now possible to pass all optional clock
> data for each device from DT instead of having it in hwmod.
>
> Signed-off-by: Rajendra Nayak <rnayak@ti.com>
> ---
> arch/arm/mach-omap2/omap_hwmod.c | 65 ++++++++++++++++++++++++++++++++++++--
> 1 file changed, 63 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index f22bbbb..271634f 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -807,6 +807,64 @@ static int _init_interface_clks(struct omap_hwmod *oh)
> return ret;
> }
>
> +static const char **_parse_opt_clks_dt(struct omap_hwmod *oh,
> + struct device_node *np,
> + int *opt_clks_cnt)
> +{
> + int i, clks_cnt;
> + const char *clk_name;
> + const char **opt_clk_names;
> +
> + clks_cnt = of_property_count_strings(np, "clock-names");
> + if (!clks_cnt)
> + return NULL;
> +
> + opt_clk_names = kzalloc(sizeof(char *)*clks_cnt, GFP_KERNEL);
> + if (!opt_clk_names)
> + return NULL;
> +
> + for (i = 0; i < clks_cnt; i++) {
> + of_property_read_string_index(np, "clock-names", i, &clk_name);
> + if (!strcmp(clk_name, "fck"))
> + continue;
> + opt_clks_cnt++;
> + opt_clk_names[i] = clk_name;
This assumes that any clock-names entry which does not match "fck" is
an optional clock that should be controlled by hwmod -> this is not
always the case and in cases such as gpio or mmc, the optional
debounce clock is actually prefered to be controlled by the driver.
we wont have a way around that.
> + }
> + return opt_clk_names;
> +}
> +
> +static int _init_opt_clks_dt(struct omap_hwmod *oh, struct device_node *np)
> +{
> + struct clk *c;
> + int i, opt_clks_cnt = 0;
> + int ret = 0;
> + const char **opt_clk_names;
> +
> + opt_clk_names = _parse_opt_clks_dt(oh, np, &opt_clks_cnt);
> + if (!opt_clk_names)
> + return -EINVAL;
> +
> + oh->opt_clks = kzalloc(sizeof(struct omap_hwmod_opt_clk *)
> + * opt_clks_cnt, GFP_KERNEL);
> + if (!oh->opt_clks)
> + return -ENOMEM;
> +
> + oh->opt_clks_cnt = opt_clks_cnt;
> +
> + for (i = 0; i < oh->opt_clks_cnt; i++) {
> + c = of_clk_get_by_name(np, opt_clk_names[i]);
> + if (IS_ERR(c)) {
> + pr_warn("omap_hwmod: %s: cannot clk_get opt_clk %s\n",
> + oh->name, opt_clk_names[i]);
> + ret = -EINVAL;
> + }
> + oh->opt_clks[i]._clk = c;
> + oh->opt_clks[i].role = opt_clk_names[i];
> + clk_prepare(oh->opt_clks[i]._clk);
> + }
> + return ret;
> +}
> +
> /**
> * _init_opt_clk - get a struct clk * for the the hwmod's optional clocks
> * @oh: struct omap_hwmod *
> @@ -814,13 +872,16 @@ static int _init_interface_clks(struct omap_hwmod *oh)
> * Called from _init_clocks(). Populates the @oh omap_hwmod_opt_clk
> * clock pointers. Returns 0 on success or -EINVAL on error.
> */
> -static int _init_opt_clks(struct omap_hwmod *oh)
> +static int _init_opt_clks(struct omap_hwmod *oh, struct device_node *np)
> {
> struct omap_hwmod_opt_clk *oc;
> struct clk *c;
> int i;
> int ret = 0;
>
> + if (of_get_property(np, "clocks", NULL))
> + return _init_opt_clks_dt(oh, np);
> +
> for (i = oh->opt_clks_cnt, oc = oh->opt_clks; i > 0; i--, oc++) {
> c = clk_get(NULL, oc->clk);
> if (IS_ERR(c)) {
> @@ -1590,7 +1651,7 @@ static int _init_clocks(struct omap_hwmod *oh, void *data,
>
> ret |= _init_main_clk(oh, np);
> ret |= _init_interface_clks(oh);
> - ret |= _init_opt_clks(oh);
> + ret |= _init_opt_clks(oh, np);
>
> if (!ret)
> oh->_state = _HWMOD_STATE_CLKS_INITED;
>
--
Regards,
Nishanth Menon
next prev parent reply other threads:[~2014-01-09 15:19 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-12 11:38 [PATCH v2 0/3] OMAP2+: hwmod: Add support to parse clock info from DT Rajendra Nayak
2013-12-12 11:38 ` Rajendra Nayak
2013-12-12 11:38 ` [PATCH v2 1/3] ARM: OMAP2+: Add support to parse 'main_clk' " Rajendra Nayak
2013-12-12 11:38 ` Rajendra Nayak
2013-12-12 11:38 ` [PATCH v2 2/3] ARM: OMAP2+: Add support to parse optional clk " Rajendra Nayak
2013-12-12 11:38 ` Rajendra Nayak
2014-01-09 15:19 ` Nishanth Menon [this message]
2014-01-09 15:19 ` Nishanth Menon
2013-12-12 11:38 ` [PATCH v2 3/3] ARM: OMAP4: dts: Add main and optional clock data into DT Rajendra Nayak
2013-12-12 11:38 ` Rajendra Nayak
2013-12-15 3:40 ` Mike Turquette
2013-12-15 3:40 ` Mike Turquette
2013-12-13 17:31 ` [PATCH v2 0/3] OMAP2+: hwmod: Add support to parse clock info from DT Tony Lindgren
2013-12-13 17:31 ` Tony Lindgren
2014-02-28 21:56 ` Tony Lindgren
2014-02-28 21:56 ` Tony Lindgren
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=52CEBE0A.60007@ti.com \
--to=nm@ti.com \
--cc=bcousson@baylibre.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mturquette@linaro.org \
--cc=paul@pwsan.com \
--cc=rnayak@ti.com \
--cc=tony@atomide.com \
/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.