linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: t-kristo@ti.com (Tero Kristo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv2 5/9] ARM: OMAP2+: hwmod: assign main clock from DT if available
Date: Mon, 20 Mar 2017 15:23:27 +0200	[thread overview]
Message-ID: <95b7142f-8cc7-5909-764e-05dbad434298@ti.com> (raw)
In-Reply-To: <20170317221728.GX20572@atomide.com>

On 18/03/17 00:17, Tony Lindgren wrote:
> * Tero Kristo <t-kristo@ti.com> [170317 14:42]:
>> On 17/03/17 17:41, Tony Lindgren wrote:
>>> * Tero Kristo <t-kristo@ti.com> [170317 02:12]:
>>>> -static int _init_main_clk(struct omap_hwmod *oh)
>>>> +static int _init_main_clk(struct omap_hwmod *oh, struct device_node *np)
>>>>  {
>>>>  	int ret = 0;
>>>> -	char name[MOD_CLK_MAX_NAME_LEN];
>>>> -	struct clk *clk;
>>>> -	static const char modck[] = "_mod_ck";
>>>> -
>>>> -	if (strlen(oh->name) >= MOD_CLK_MAX_NAME_LEN - strlen(modck))
>>>> -		pr_warn("%s: warning: cropping name for %s\n", __func__,
>>>> -			oh->name);
>>>> +	struct clk *clk = NULL;
>>>> +	int i;
>>>> +	int count;
>>>> +	const char *name;
>>>> +	char clk_name[strlen("clkctrl-x") + 1];
>>>>
>>>> -	strlcpy(name, oh->name, MOD_CLK_MAX_NAME_LEN - strlen(modck));
>>>> -	strlcat(name, modck, MOD_CLK_MAX_NAME_LEN);
>>>> +	if (np) {
>>>> +		clk = of_clk_get_by_name(np, "clkctrl");
>>>> +		if (IS_ERR(clk)) {
>>>> +			/* Try matching by hwmod name */
>>>> +			count = of_property_count_strings(np, "ti,hwmods");
>>>> +			for (i = 0; i < count; i++) {
>>>> +				ret = of_property_read_string_index(np,
>>>> +								    "ti,hwmods",
>>>> +								    i, &name);
>>>> +				if (ret)
>>>> +					continue;
>>>> +				if (!strcmp(name, oh->name)) {
>>>> +					sprintf(clk_name, "clkctrl-%d", i);
>>>> +					clk = of_clk_get_by_name(np, clk_name);
>>>> +				}
>>>> +			}
>>>> +		}
>>>> +		if (!IS_ERR(clk)) {
>>>> +			pr_debug("%s: mapped main_clk %s for %s\n", __func__,
>>>> +				 __clk_get_name(clk), oh->name);
>>>> +			oh->main_clk = __clk_get_name(clk);
>>>> +			oh->_clk = clk;
>>>> +			soc_ops.disable_direct_prcm(oh);
>>>> +		}
>>>> +	}
>>>
>>> You should bail out and do nothing here if legacy "ti,hwmods" property is
>>> not found. Eventually it will be the interconnect target IP wrapper module
>>> that will manage the clock and populate the rest of the hwmod data
>>> dynamically.
>>
>> This is only for transitional support of hwmod, this patch will not be
>> needed for anything later on; or you probably need to do something similar
>> within the interconnect driver itself. The code still needs to care for the
>> cases where we want to find the main clock based on the clock link within
>> hwmod data, so bailing out early will break any boards that don't support
>> the new clkctrl clocks yet.
>
> Well we really don't want hwmod code parsing anything out of the dtb
> unless "ti,hwmods" property is set. That makes moving driver like features
> to live under drivers much harder.
>
> I don't quite follow you, what breaks if you fall back to the old clock
> lookup if no "ti,hwmods" is set?

I think I misunderstood your earlier comment. So basically the code 
already bails out early if ti,hwmods is not set. In this case, the 
earlier lookup done by hwmod core sets the node pointer for this code to 
be NULL, and this just parses the existing main_clk info.

-Tero

  reply	other threads:[~2017-03-20 13:23 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-17  9:09 [PATCHv2 0/9] clk: ti: add support for clkctrl clocks Tero Kristo
2017-03-17  9:09 ` [PATCHv2 1/9] Documentation: dt-bindings: Add binding documentation for TI " Tero Kristo
2017-03-17 14:18   ` Tony Lindgren
2017-03-17 15:01     ` Tero Kristo
2017-03-17  9:09 ` [PATCHv2 2/9] clk: ti: add support for " Tero Kristo
2017-03-17  9:09 ` [PATCHv2 3/9] dt-bindings: clk: add omap4 clkctrl definitions Tero Kristo
2017-04-24 21:49   ` Tony Lindgren
2017-03-17  9:09 ` [PATCHv2 4/9] clk: ti: omap4: add clkctrl clock data Tero Kristo
2017-03-17  9:09 ` [PATCHv2 5/9] ARM: OMAP2+: hwmod: assign main clock from DT if available Tero Kristo
2017-03-17 15:41   ` Tony Lindgren
2017-03-17 21:40     ` Tero Kristo
2017-03-17 22:17       ` Tony Lindgren
2017-03-20 13:23         ` Tero Kristo [this message]
2017-03-20 14:34           ` Tony Lindgren
2017-03-20 14:36             ` Tony Lindgren
2017-03-17  9:09 ` [PATCHv2 6/9] ARM: OMAP2+: timer: add support for fetching fck handle from DT Tero Kristo
2017-03-17 15:41   ` Tony Lindgren
2017-03-17  9:09 ` [PATCHv2 7/9] ARM: dts: omap4: add bus functionality to base PRCM nodes Tero Kristo
2017-03-17  9:09 ` [PATCHv2 8/9] ARM: dts: omap4: add clkctrl nodes Tero Kristo
2017-03-17 15:43   ` Tony Lindgren
2017-03-17 21:41     ` Tero Kristo
2017-03-20 13:25       ` Tero Kristo
2017-03-20 14:35         ` Tony Lindgren
2017-03-20 14:52           ` Tero Kristo
2017-03-20 15:07             ` Tony Lindgren
2017-03-17  9:09 ` [PATCHv2 9/9] ARM: dts: omap4: convert to use the new clkctrl clocks for the drivers Tero Kristo
2017-03-28  0:18   ` Tony Lindgren
2017-03-28  5:44     ` Tero Kristo
2017-03-28 15:03       ` Tony Lindgren
2017-03-30  7:33         ` Tero Kristo
2017-04-03 14:16           ` Tony Lindgren
2017-03-17 15:25 ` [PATCHv2 0/9] clk: ti: add support for clkctrl clocks Tony Lindgren
2017-03-17 21:37   ` Tero Kristo
2017-03-23  1:00     ` Tony Lindgren
2017-03-23 17:02       ` Tony Lindgren
2017-03-28  5:41         ` Tero Kristo
2017-03-30  7:18         ` Tero Kristo
2017-03-30 16:54           ` Tony Lindgren
2017-04-03 14:51             ` Tero Kristo
2017-04-03 15:36               ` Tony Lindgren
2017-04-05 16:59                 ` Tero Kristo
2017-04-06 16:49                 ` Tero Kristo
2017-04-07 16:47                   ` Tony Lindgren
2017-04-10  7:31                     ` Tero Kristo
2017-04-10 16:18                       ` Tony Lindgren
2017-04-10 18:33                         ` Tero Kristo
2017-04-11 16:24                           ` 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=95b7142f-8cc7-5909-764e-05dbad434298@ti.com \
    --to=t-kristo@ti.com \
    --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).