All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
To: Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Subject: Re: [PATCH] of: support an enumerated-bus compatible value
Date: Mon, 2 Jul 2012 15:45:29 -0600	[thread overview]
Message-ID: <CACxGe6tAfpRsEeALsHi=Y+RXjuqyCzrbwxULH-443y4OaSdLRQ@mail.gmail.com> (raw)
In-Reply-To: <4FF1F955.6030204-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>

On Mon, Jul 2, 2012 at 1:41 PM, Stephen Warren <swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org> wrote:
> On 07/02/2012 12:36 PM, Mitch Bradley wrote:
>> On 7/2/2012 7:43 AM, Stephen Warren wrote:
>>> On 07/02/2012 11:23 AM, Mitch Bradley wrote:
>>>> On 7/2/2012 5:59 AM, Stephen Warren wrote:
>>>>> On 07/01/2012 01:36 PM, Rob Herring wrote:
>>>>>> On 06/28/2012 06:05 PM, Stephen Warren wrote:
>>>>>>> From: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>>>>>>>
>>>>>>> An "enumerated" bus is one that is not memory-mapped, hence hence
>>>>>>> typically has #address-cells=1, and #size-cells=0. Such buses
>>>>>>> would be
>>>>>>> used to group related non-memory-mapped nodes together, often just
>>>>>>> under
>>>>>>> the top-level of the device tree. The ability to group nodes into a
>>>>>>> non-
>>>>>>> memory-mapped subnode of the root is important, since if nodes
>>>>>>> exist to
>>>>>>> describe multiple entities of the same type, the nodes will have the
>>>>>>> same name, and hence require a unit address to differentiate them. It
>>>>>>> doesn't make sense to assign bogus unit addresses from the CPU's own
>>>>>>> address space for this purpose. An example:
>>>>>>>
>>>>>>>      regulators {
>>>>>>>          compatible = "enumerated-bus";
>>>>>>>          #address-cells = <1>;
>>>>>>>          #size-cells = <0>;
>>>>>>>
>>>>>>>          regulator@0 {
>>>>>>>              compatible = "regulator-fixed";
>>>>>>>              reg = <0>;
>>>>>>>          };
>>>>>>>
>>>>>>>          regulator@1 {
>>>>>>>              compatible = "regulator-fixed";
>>>>>>>              reg = <1>;
>>>>>>>          };
>>>>>>>      };
>>>>>>>
>>>>>>> Finally, because such buses are not memory-mapped, we avoid creating
>>>>>>> any IO/memory resources for the device.
>>>>>>
>>>>>> This seems like a work-around to use reg instead of using cell-index
>>>>>> (which is discouraged). reg in this case is really not a hardware
>>>>>> description. Do you have an intended use or just trying to fix the
>>>>>> error
>>>>>> messages?
>>>>>
>>>>> I'm not familiar with cell-index; can you please describe it some more.
>>>>> Looking at some existing files in arch/powerpc/boot/dts, it looks like
>>>>> something that exists alongside reg rather than replacing it, so I
>>>>> don't
>>>>> see how it'd solve the problem.
>>>>>
>>>>> The portion of .dts file quoted above is the use-case. In more general
>>>>> terms, I need to add a bunch of non-memory-mapped devices to DT. There
>>>>> are multiple devices of a given type. The DT node names should be named
>>>>> after the class of device not the instance, and hence all get named the
>>>>> same. Hence, I need a unit address to differentiate the node names.
>>>>> Hence I need to use the reg property in order that the unit address
>>>>> matches the reg property. Is there some other way of solving these
>>>>> requirements other than using a unit address to make the node names
>>>>> unique?
>>>>
>>>> One of Rob's objections was that, in this case, the reg property is not
>>>> a hardware description.  That's an interesting point.  If in fact
>>>> numerous such devices exist, there must be some mechanism for software
>>>> to choose which device to talk to, typically a number.  Is that the case
>>>> for these devices?  If so, that number is a perfectly valid "reg"
>>>> property value.  If not, how does software choose to talk to a specific
>>>> device?
>>>
>>> Yes, the reg value is purely a unique ID that exists to satisfy DT
>>> semantics.
>>>
>>> These regulators will eventually be referenced by phandles from the
>>> drivers that use them, just like interrupts/GPIOs/... I just haven't
>>> hooked up any clients that do so yet.
>>
>> I'm still confused.  Are you saying that the regulators cannot be
>> controlled by software?
>
> They can in general be controlled by SW yes.
>
> Given regulator@0 above, assuming it's labelled reg0, another device
> node might contain:
>
> vin-supply = <&reg0>;
>
> the driver would then do roughtly:
>
> struct regulator *r = regulator_get(dev, "vin");
> regulator_enable(r);
> ...
> regulator_disable(r);
>
> which would end up toggling the GPIO that controls the regulator (the
> property that defines the GPIO was omitted from the DT examples above
> for brevity).
>
> But don't get too hung up on regulators; there are plenty of other
> devices that can exist in DT that aren't memory-mapped; GPIO-keys,
> aggregate sound complexes, perhaps WiFi/rfkill nodes, etc. All are
> affected by the same DT representation issue.

Okay, fair enough.  I've done this myself for an audio complex.  The
only reason I push back on this is that the platform_bus_type does end
up being used as a catch-all without necessarily a lot of thought.
(read as: I'm not saying no; but rather make sure you've got a solid
argument)

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

  parent reply	other threads:[~2012-07-02 21:45 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-28 23:05 [PATCH] of: support an enumerated-bus compatible value Stephen Warren
     [not found] ` <1340924755-31447-1-git-send-email-swarren-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-07-01 19:36   ` Rob Herring
     [not found]     ` <4FF0A6B6.8040902-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-07-01 22:03       ` Grant Likely
2012-07-02 15:59       ` Stephen Warren
     [not found]         ` <4FF1C567.4060809-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-07-02 17:23           ` Mitch Bradley
     [not found]             ` <4FF1D8F9.9040005-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
2012-07-02 17:43               ` Stephen Warren
     [not found]                 ` <4FF1DDBD.9050106-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-07-02 18:36                   ` Mitch Bradley
     [not found]                     ` <4FF1EA1A.9030307-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
2012-07-02 19:41                       ` Stephen Warren
     [not found]                         ` <4FF1F955.6030204-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-07-02 21:44                           ` Segher Boessenkool
     [not found]                             ` <6BC22F77-77D7-45DF-821A-6CA2DBADEA59-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
2012-07-02 22:26                               ` Stephen Warren
     [not found]                                 ` <4FF22031.3060206-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-07-03  0:27                                   ` Segher Boessenkool
     [not found]                                     ` <FE3C6687-727E-4191-9D37-9E71EBFEF0AE-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
2012-07-03 10:47                                       ` Mark Brown
     [not found]                                         ` <20120703104720.GB25995-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-07-03 14:00                                           ` Segher Boessenkool
     [not found]                                             ` <F928AF0B-65CF-48D1-8DB5-4C27FD6AB82F-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
2012-07-03 14:42                                               ` Mark Brown
     [not found]                                                 ` <20120703144242.GE25995-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-07-03 15:43                                                   ` Segher Boessenkool
     [not found]                                                     ` <DF4AD962-D8A8-43AA-AF14-5DBF65505EDF-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
2012-07-03 15:45                                                       ` Stephen Warren
     [not found]                                                         ` <4FF3138F.9090800-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-07-03 19:02                                                           ` Mitch Bradley
     [not found]                                                             ` <4FF341B0.9090901-D5eQfiDGL7eakBO8gow8eQ@public.gmane.org>
2012-07-03 19:57                                                               ` Stephen Warren
     [not found]                                                                 ` <4FF34EC2.6040908-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-07-24 17:38                                                                   ` Stephen Warren
     [not found]                                                                     ` <500EDD8A.2010701-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-07-24 18:48                                                                       ` Arnd Bergmann
     [not found]                                                                         ` <201207241848.53308.arnd-r2nGTMty4D4@public.gmane.org>
2012-07-24 19:30                                                                           ` Stephen Warren
     [not found]                                                                             ` <500EF7C5.6060406-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-07-24 20:05                                                                               ` Arnd Bergmann
2012-07-03 15:43                                               ` Stephen Warren
2012-07-02 21:45                           ` Grant Likely [this message]
2012-07-02 21:43           ` Grant Likely
     [not found]             ` <CACxGe6ty5wU6Y+fuFYfBsM4HRLZaTff9EnzCP2FzmcQGOyJ=xQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-07-02 22:28               ` Stephen Warren
     [not found]                 ` <4FF22095.4030106-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-07-02 22:37                   ` Grant Likely
     [not found]                     ` <CACxGe6sexKHa65=EsLpTa9-JrSK-Ubbhz6MAmfGeSen9cHJhow-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-07-02 23:17                       ` Stephen Warren

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='CACxGe6tAfpRsEeALsHi=Y+RXjuqyCzrbwxULH-443y4OaSdLRQ@mail.gmail.com' \
    --to=grant.likely-s3s/wqlpoipyb63q8fvjnq@public.gmane.org \
    --cc=devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org \
    --cc=swarren-3lzwWm7+Weoh9ZMKESR00Q@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 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.