[RFC 2/7] pwm: Allow chips to support multiple PWMs.

Stephen Warren swarren at nvidia.com
Thu Dec 22 03:55:20 EST 2011


Thierry Reding wrote at Wednesday, December 21, 2011 7:10 AM:
> * Thierry Reding wrote:
> > * Stephen Warren wrote:
> > > In other words, can you do away with NR_PWM, and make it completely
> > > dynamic?
> >
> > IRQ can be configured to use a radix tree if CONFIG_SPARSE_IRQ=y. I guess it
> > doesn't hurt to always use a radix tree for PWM, so I'll read up on it and
> > will try to address that in the next version.
> 
> I guess something like idr/ida can be used to dynamically assign a PWM ID,
> which would allow us to get rid of the bitmap. Then again, ida itself is not
> much more than a bitmap either. It would complicate things a little in that
> the ID assignment could no longer be assumed to be sequential for one given
> PWM chip, so the lookup (or rather mapping the ID to a chip-relative number)
> will be trickier to do.

You can support both dynamic assignment of IDs, and assigning each PWM
chip's IDs in a contiguous block. Just search for n contiguous free IDs
instead of looping n times looking for 1 free ID.

...
> pinctrl doesn't solve this because it uses statically allocated pin numbers.

Well, they're per-device IDs, so the issue doesn't really come up.

> Interestingly though it uses per-device numbering as well, which would be
> fine for PWM as well if we had only device tree based probing. In order to
> support other devices, we'll still need a global namespace.

Yes, that's probably true. I guess a global namespace is reasonable for
now. If you do plan to rework the API though, the sooner the better since
the tree will grow fewer users before it's done:-)

-- 
nvpublic



More information about the devicetree-discuss mailing list