linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: arnd@arndb.de (Arnd Bergmann)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/4] ARM: CSR: add PM sleep entry for SiRFprimaII
Date: Thu, 25 Aug 2011 17:56:54 +0200	[thread overview]
Message-ID: <201108251756.54254.arnd@arndb.de> (raw)
In-Reply-To: <20110825082151.GB17748@S2100-06.ap.freescale.net>

On Thursday 25 August 2011, Shawn Guo wrote:
> > > To me, it seems that the above code snippet can be as simply as the
> > > following.
> > >
> > >        np = of_find_compatible_node(NULL, NULL, "sirf,prima2-pwrc");
> > >        sirfsoc_pwrc_base = of_iomap(np, 0);
> > >        if (!sirfsoc_pwrc_base)
> > >                return -ENOMEM;
> > 
> > you might want to read earlier thread in v1. PWRC is not in memory space.
> > 
> Ah, just read.  Then you at least should be able to use
> of_property_read_u32().

I think of_get_address would be even more appropriate, but I could
be misreading that function.

> > >> +
> > >> +static int __init sirfsoc_memc_init(void)
> > >> +{
> > >> +     return platform_driver_register(&sirfsoc_memc_driver);
> > >> +}
> > >> +postcore_initcall(sirfsoc_memc_init);
> > >
> > > Doing the same thing - mapping address, why sirfsoc_pwrc_base uses
> > > a function, while sirfsoc_memc_base needs a platform_driver?  You
> > > will have more stuff about memc to add there?
> > 
> > memc is in memory space, actually simple_bus, then a platform device
> > has existed for it.
> > pwrc is now not compitable with simple_bus. it looks like not worth a
> > platform for the moment too.
> > 
> It seems a little complicated to register a platform_driver just for
> getting an address.  I'm not sure how hard Arnd is on this position.
> I'm going to send a patch to test it :)

I think it's a grey area. In general, I always recommend a device
driver unless the mapping is absolutely needed at boot time before
we bring up the driver subsystem.
This enforces an object-oriented mental model about the building
blocks: Everything you want to talk to has to export its own functions
and we can stack modules on top of other modules. Clearly there are
a few cases where this is not possible or only adds complexity without
any benefit, but I would like to see the model of having a device
driver for each device be the rule, with few exceptions.

One argument that I can accept for this specific case is that the
power management code has to be written in assembly and doesn't
really understand the device object model anyway, so we just end
up exporting the base address, which is not something that proper
drivers are doing. However, as soon as more functionality gets added
that uses the memc register space, my preference would increasingly
lean towards doing a device driver here.

	Arnd

  parent reply	other threads:[~2011-08-25 15:56 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-23  6:15 [PATCH v2 0/4] ARM: CSR: add rtciobrg and PM support Barry Song
2011-08-23  6:15 ` [PATCH v2 1/4] ARM: CSR: add rtc i/o bridge interface for SiRFprimaII Barry Song
2011-08-23  8:48   ` Jamie Iles
2011-08-23  9:33     ` Barry Song
2011-08-23  9:53       ` Jamie Iles
2011-08-23 15:59         ` Arnd Bergmann
2011-08-24  1:45           ` Barry Song
2011-08-23 16:01   ` Arnd Bergmann
2011-08-23 16:15     ` Arnd Bergmann
2011-08-24  1:43       ` Barry Song
2011-08-24  1:42     ` Barry Song
2011-08-23  6:15 ` [PATCH v2 2/4] ARM: CSR: add PM sleep entry " Barry Song
2011-08-23  8:50   ` Jamie Iles
2011-08-23  9:08     ` Barry Song
2011-08-23  9:41   ` Russell King - ARM Linux
2011-08-27  9:53     ` Barry Song
2011-08-25  7:27   ` Shawn Guo
2011-08-25  7:30     ` Barry Song
2011-08-25  8:21       ` Shawn Guo
2011-08-25  8:21         ` Barry Song
2011-08-25  8:33           ` Barry Song
2011-08-25 15:56         ` Arnd Bergmann [this message]
2011-08-25 22:58           ` Barry Song
2011-08-23  6:15 ` [PATCH v2 3/4] ARM: L2X0: move l2x0_init out of .init section Barry Song
2011-08-23  6:15 ` [PATCH v2 4/4] ARM: CSR: add PM suspend/resume entries for SiRFprimaII L2 cache Barry Song

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=201108251756.54254.arnd@arndb.de \
    --to=arnd@arndb.de \
    --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).