devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
To: Viresh Kumar <viresh.kumar-qxv4g6HH51o@public.gmane.org>
Cc: spear-devel <spear-devel-nkJGhpqTU55BDgjK7y7TUQ@public.gmane.org>,
	Stefan Roese <sr-ynQEQJNshbs@public.gmane.org>,
	viresh kumar
	<viresh.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org"
	<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
	"devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org"
	<devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH] ARM: SPEAr600: Add device-tree support to SPEAr600 boards
Date: Tue, 27 Mar 2012 11:15:07 +0000	[thread overview]
Message-ID: <201203271115.07805.arnd@arndb.de> (raw)
In-Reply-To: <4F71961E.2080208-qxv4g6HH51o@public.gmane.org>

On Tuesday 27 March 2012, Viresh Kumar wrote:
> On 3/22/2012 7:50 PM, Arnd Bergmann wrote:
> > The direct replacement is of_machine_is_compatible(), but there are a lot
> > of cases where it's better to have a local property in the device node
> > that a driver is using.
> 
> Hey Arnd,
> 
> I used of_machine_is_compatible() at several places, where it is not working :(
> Actually all these usages are before a call to of_platform_populate() and
> it looks the tree is not up by this time.
> 
> So, of_machine_is_compatible() always fails. The places where i am using this
> routine are:
> - spear3xx_dt_init(): to call SoC specific of_platform_populate()
> - spear3xx_clk_init(): to call SoC specific clk_register()
> 
> Can you please suggest what should i do here?

The normal way is to turn around the logic so you don't have to include this test
at all. Just have one soc-specific init_machine and map_io function, that calls
both soc-specific and shared soc functions, e.g.

void __init spear3xx_clk_init(void)
{
	int i;
	struct clk_lookup *lookups;

	for (i = 0; i < ARRAY_SIZE(spear3xx_clk_lookups); i++) 
		clk_register(&spear3xx_clk_lookups[i])
}

void __init spear300_clk_init(void)
{
	int i;
	struct clk_lookup *lookups;

	spear3xx_clk_init();

	for (i = 0; i < ARRAY_SIZE(spear300_clk_lookups); i++) 
		clk_register(&spear300_clk_lookups[i])

	clk_init();
}

void __init spear300_map_io(void)
{
	spear3xx_map_io();
	spear300_clk_init();
}

The other option would be to try to move stuff to a later point, e.g. don't
initialize the clocks until the basic device tree is set up.
of_machine_is_compatible() should work at init_early() time, but not at
map_io() time. Other platforms set up the clocks at init_early() time.
The spear3xx_dt_init function should be called from init_machine(), which
happens much later, so I'm pretty sure you can use of_machine_is_compatible()
if you can't just avoid it.

In the long run, I would hope that a lot of the differences go away anyway
as information that is now hardcoded just moves into the device tree.
At that point, you should no longer need to care which soc you are running
on. I realize that there is still significant amount of work to be done
until you get there.

In case of the clocks, I think you could already merge all the clk_lookup
arrays into one, which would result in a larger kernel image but should
do no harm otherwise.

	Arnd

  parent reply	other threads:[~2012-03-27 11:15 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-13 14:47 [PATCH] ARM: SPEAr600: Add device-tree support to SPEAr600 boards Stefan Roese
2012-03-13 16:44 ` Arnd Bergmann
     [not found]   ` <201203131644.12048.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-14  7:08     ` Viresh Kumar
     [not found]       ` <4F604400.1040805-qxv4g6HH51o@public.gmane.org>
2012-03-14  9:58         ` Arnd Bergmann
     [not found]           ` <201203140958.27289.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-14 10:02             ` Viresh Kumar
2012-03-14  7:40     ` Stefan Roese
2012-03-14  9:48       ` Arnd Bergmann
     [not found]         ` <201203140948.44823.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-14 10:36           ` Stefan Roese
     [not found]             ` <201203141136.48513.sr-ynQEQJNshbs@public.gmane.org>
2012-03-14 13:27               ` Arnd Bergmann
     [not found]                 ` <201203141327.01038.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-14 13:43                   ` Stefan Roese
     [not found]                     ` <201203141443.57221.sr-ynQEQJNshbs@public.gmane.org>
2012-03-14 14:09                       ` Arnd Bergmann
2012-03-14 13:44                   ` Rob Herring
     [not found] ` <1331650032-15274-1-git-send-email-sr-ynQEQJNshbs@public.gmane.org>
2012-03-14  7:05   ` Viresh Kumar
2012-03-14  7:20     ` Stefan Roese
     [not found]     ` <4F604321.9000204-qxv4g6HH51o@public.gmane.org>
2012-03-15  8:48       ` Stefan Roese
     [not found]         ` <201203150948.27918.sr-ynQEQJNshbs@public.gmane.org>
2012-03-15  9:00           ` Viresh Kumar
     [not found]             ` <4F61AFAB.6080301-qxv4g6HH51o@public.gmane.org>
2012-03-15 10:38               ` Stefan Roese
     [not found]                 ` <201203151138.51508.sr-ynQEQJNshbs@public.gmane.org>
2012-03-15 10:40                   ` Viresh Kumar
2012-03-15 13:39                   ` Arnd Bergmann
     [not found]                     ` <201203151339.36173.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-21 11:32                       ` Viresh Kumar
     [not found]                         ` <4F69BC35.4010400-qxv4g6HH51o@public.gmane.org>
2012-03-21 12:36                           ` Arnd Bergmann
2012-03-21 13:28                             ` viresh kumar
2012-03-21 14:04                               ` Arnd Bergmann
2012-03-21 14:18                                 ` viresh kumar
     [not found]                                   ` <CAOh2x=mtjvitkhz=BXOZPAaKZ2i3QQuKrYA3HcHNERHhF5xFoA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-21 14:42                                     ` Arnd Bergmann
     [not found]                                 ` <201203211404.35847.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-21 18:26                                   ` Arnd Bergmann
2012-03-22  0:45                                     ` viresh kumar
     [not found]                                       ` <CAOh2x=nZUobbRJo7kdAwmEG+s51BabxPwUVz=S3oNJyTpuRpCQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-22  8:10                                         ` Arnd Bergmann
     [not found]                                           ` <201203220810.00628.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-22  8:51                                             ` viresh kumar
     [not found]                             ` <201203211236.37891.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-22 13:46                               ` viresh kumar
     [not found]                                 ` <CAOh2x=k6ZfamB8DnPgVPjxZ7E1gTuHOQYg6s1Nd1ybA+TSquWA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-22 14:20                                   ` Arnd Bergmann
     [not found]                                     ` <201203221420.10127.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-22 14:53                                       ` viresh kumar
2012-03-27 10:27                                       ` Viresh Kumar
     [not found]                                         ` <4F71961E.2080208-qxv4g6HH51o@public.gmane.org>
2012-03-27 11:15                                           ` Arnd Bergmann [this message]
     [not found]                                             ` <201203271115.07805.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-27 11:27                                               ` Viresh Kumar
     [not found]                                                 ` <4F71A42C.3090108-qxv4g6HH51o@public.gmane.org>
2012-03-27 11:45                                                   ` Viresh Kumar
2012-03-27 11:59                                                   ` Arnd Bergmann
     [not found]                                                     ` <201203271159.35306.arnd-r2nGTMty4D4@public.gmane.org>
2012-03-27 13:44                                                       ` viresh kumar
2012-03-27 13:59                                                         ` Arnd Bergmann
2012-03-28  5:03                                                           ` Viresh Kumar
     [not found]                                                             ` <4F729B99.4020909-qxv4g6HH51o@public.gmane.org>
2012-03-28  8:13                                                               ` Arnd Bergmann
2012-03-14  8:48 ` Jean-Christophe PLAGNIOL-VILLARD

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=201203271115.07805.arnd@arndb.de \
    --to=arnd-r2ngtmty4d4@public.gmane.org \
    --cc=devicetree-discuss-mnsaURCQ41sdnm+yROfE0A@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=spear-devel-nkJGhpqTU55BDgjK7y7TUQ@public.gmane.org \
    --cc=sr-ynQEQJNshbs@public.gmane.org \
    --cc=viresh.kumar-qxv4g6HH51o@public.gmane.org \
    --cc=viresh.linux-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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).