devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: Lokesh Vutla <lokeshvutla@ti.com>
Cc: Felipe Balbi <balbi@ti.com>, Tony Lindgren <tony@atomide.com>,
	"Kristo, Tero" <t-kristo@ti.com>,
	Linux ARM Kernel Mailing List
	<linux-arm-kernel@lists.infradead.org>,
	Linux OMAP Mailing List <linux-omap@vger.kernel.org>,
	Paul Walmsley <paul@pwsan.com>, Nishanth Menon <nm@ti.com>,
	devicetree@vger.kernel.org
Subject: Re: [RFC/PATCH 5/7] arm: omap: hwmod: allow for registration of class-less hwmods
Date: Wed, 10 Dec 2014 08:54:33 -0600	[thread overview]
Message-ID: <20141210145433.GC4602@saruman> (raw)
In-Reply-To: <54882576.8020609@ti.com>

[-- Attachment #1: Type: text/plain, Size: 4450 bytes --]

Hi,

(adding linux-omap back to the loop)

On Wed, Dec 10, 2014 at 04:20:30PM +0530, Lokesh Vutla wrote:
> Hi Felipe,
> 
> On Wednesday 10 December 2014 03:57 AM, Felipe Balbi wrote:
> > Before this patch, HWMOD requires the existence
> > of a struct omap_hwmod_class very early.
> Yes, hwmod code looks for omap_hwmod_class entry before registering any hwmod.
> 
> With the patch 4/7 omap_hwmod_class gets populated from dt very late after registration of the hwmod.
> So all the hwmod which gets class data from dt never gets registered and state is always UNKNOWN.
> Mostly making it unusable.
> IMO this patch just masks the problem.
> 
> In order to register hwmod we need to populate class data very early.
> We can populate at the same place as how reg property is being parsed.
> Call omap_hwmod_init_sysc() in _init() of the particular hwmod:
> The below diff will help:
>
> diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
> index cbb908d..05ecf8a 100644
> --- a/arch/arm/mach-omap2/omap_hwmod.c
> +++ b/arch/arm/mach-omap2/omap_hwmod.c
> @@ -2415,6 +2415,116 @@ static int __init _init_mpu_rt_base(struct omap_hwmod *oh, void *data,
>  	return 0;
>  }
>  
> +static int omap_hwmod_has_sysc_bindings(struct device_node *node)
> +{
> +	char *properties[] = {
> +		"ti,rev_offs",
> +		"ti,sysc_offs",
> +		"ti,syss_offs",
> +		"ti,sysc_flags",
> +		"ti,srst_udelay",
> +		"ti,idlemodes",
> +		"ti,clockact",
> +		"ti,sysc_type",
> +		NULL
> +	};
> +	char **tmp = properties;
> +
> +	while (*tmp) {
> +		if (of_property_read_bool(node, *tmp)) {
> +			return true;
> +		}
> +		tmp++;
> +	}
> +
> +	return 0;
> +}
> +
> +static int omap_hwmod_init_sysc(struct device_node *node,
> +		struct omap_hwmod *oh, int index)
> +{
> +	struct omap_hwmod_class *class = oh->class;
> +	struct omap_hwmod_class_sysconfig *sysc;
> +	int ret;
> +	int i;
> +	char name[128];
> +	const char *tmp = oh->name;
> +	u32 prop;
> +
> +	/* if data isn't provided by DT, skip */
> +	if ((class && class->sysc) || !omap_hwmod_has_sysc_bindings(node))
> +		return 0;
> +
> +	class = kzalloc(sizeof(*class), GFP_KERNEL);
> +	if (!class)
> +		return -ENOMEM;
> +
> +	i = 0;
> +	while (*tmp) {
> +		if (isalpha(*tmp))
> +			name[i++] = *tmp;
> +		tmp++;
> +	}
> +	name[i] = '\0';
> +
> +	class->name = kzalloc(sizeof(name), GFP_KERNEL);
> +	if (!class->name)
> +		return -ENOMEM;
> +	strncpy(class->name, name, sizeof(name) - 1);
> +
> +	sysc = kzalloc(sizeof(*sysc), GFP_KERNEL);
> +	if (!sysc)
> +		return -ENOMEM;
> +
> +	ret = of_property_read_u32_index(node, "ti,rev_offs", index, &prop);
> +	if (!ret)
> +		sysc->rev_offs = prop;
> +
> +	ret = of_property_read_u32_index(node, "ti,sysc_offs", index, &prop);
> +	if (!ret)
> +		sysc->sysc_offs = prop;
> +
> +	ret = of_property_read_u32_index(node, "ti,syss_offs", index, &prop);
> +	if (!ret)
> +		sysc->syss_offs = prop;
> +
> +	ret = of_property_read_u32_index(node, "ti,sysc_flags", index, &prop);
> +	if (!ret)
> +		sysc->sysc_flags = prop & 0xffff;
> +
> +	ret = of_property_read_u32_index(node, "ti,srst_udelay", index, &prop);
> +	if (!ret)
> +		sysc->srst_udelay = prop & 0xff;
> +
> +	ret = of_property_read_u32_index(node, "ti,idlemodes", index, &prop);
> +	if (!ret)
> +		sysc->idlemodes = prop & 0xff;
> +
> +	ret = of_property_read_u32_index(node, "ti,clockact", index, &prop);
> +	if (!ret)
> +		sysc->clockact = prop & 0xff;
> +
> +	ret = of_property_read_u32_index(node, "ti,sysc_type", index, &prop);
> +	if (ret)
> +		prop = 1;
> +
> +	switch (prop) {
> +	case 2:
> +		sysc->sysc_fields = &omap_hwmod_sysc_type2;
> +		break;
> +	case 3:
> +		sysc->sysc_fields = &omap_hwmod_sysc_type3;
> +		break;
> +	case 1:
> +	default:
> +		sysc->sysc_fields = &omap_hwmod_sysc_type1;
> +	}
> +	class->sysc = sysc;
> +	oh->class = class;
> +
> +	return 0;
> +}
> +
>  /**
>   * _init - initialize internal data for the hwmod @oh
>   * @oh: struct omap_hwmod *
> @@ -2449,6 +2559,12 @@ static int __init _init(struct omap_hwmod *oh, void *data)
>  		else if (np && index)
>  			pr_warn("omap_hwmod: %s using broken dt data from %s\n",
>  				oh->name, np->name);
> +
> +		if (np) {
> +			r = omap_hwmod_init_sysc(np, oh, 0);

this won't handle any binding which lists more than one hwmod on its
ti,hwmods property.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2014-12-10 14:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-09 22:27 [RFC/PATCH 0/7] arm: omap: move more HWMOD data to DT Felipe Balbi
2014-12-09 22:27 ` [RFC/PATCH 1/7] arm: omap: hwmod: add debugfs interface Felipe Balbi
2014-12-09 22:27 ` [RFC/PATCH 2/7] arm: omap: devicetree: add new properties for OMAP devices Felipe Balbi
2014-12-10 11:07   ` Lokesh Vutla
2014-12-10 15:00     ` Felipe Balbi
2014-12-11  0:46       ` Sebastian Reichel
2014-12-11 14:21         ` Felipe Balbi
2014-12-11 17:11           ` Tony Lindgren
2014-12-09 22:27 ` [RFC/PATCH 3/7] arm: omap: hwmod: drop 'const' qualifier from omap_hwmod_class name Felipe Balbi
2014-12-09 22:27 ` [RFC/PATCH 4/7] arm: omap: device: add support for generating sysconfig data from DT Felipe Balbi
     [not found]   ` <1418164072-19087-5-git-send-email-balbi-l0cyMroinI0@public.gmane.org>
2014-12-10 10:49     ` Lokesh Vutla
2014-12-10 14:48       ` Felipe Balbi
2014-12-09 22:27 ` [RFC/PATCH 5/7] arm: omap: hwmod: allow for registration of class-less hwmods Felipe Balbi
     [not found]   ` <1418164072-19087-6-git-send-email-balbi-l0cyMroinI0@public.gmane.org>
2014-12-10 10:50     ` Lokesh Vutla
2014-12-10 14:54       ` Felipe Balbi [this message]
2014-12-11  0:52         ` Sebastian Reichel
2014-12-11 14:23           ` Felipe Balbi
2014-12-11 17:44             ` Sebastian Reichel
2014-12-11 17:56               ` Tony Lindgren
2014-12-11 17:32           ` Tony Lindgren
2014-12-09 22:27 ` [RFC/PATCH 6/7] arm: boot: dts: am4372: add sysconfig data to all HWMODs Felipe Balbi
2014-12-09 22:27 ` [RFC/PATCH 7/7] arm: omap: hwmod: 43xx: remove sysc and class data Felipe Balbi
2014-12-09 22:30 ` [RFC/PATCH 0/7] arm: omap: move more HWMOD data to DT Felipe Balbi

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=20141210145433.GC4602@saruman \
    --to=balbi@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=lokeshvutla@ti.com \
    --cc=nm@ti.com \
    --cc=paul@pwsan.com \
    --cc=t-kristo@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 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).