Re: [RFC PATCH] mfd: arizona: Update device tree regulator bindings

From: Mark Brown
Date: Sat Sep 28 2013 - 18:56:12 EST


On Sat, Sep 28, 2013 at 04:53:08PM +0100, Charles Keepax wrote:

> > I don't see why this would only be an issue for ASoC - it happens to

> > I would suggest that rather than unconditionally doing this on lookup
> > it'd be easier to do it the other way round and explicitly add mappings
> > from the parent to the child when registering the device. That doesn't
> > have the potential to explode and get the wrong thing like this does.

> Been a bit delayed on this as I have been investigating the
> situation a little further. Is it just moving the supplies of the
> parent node we object to? Or do we want to keep everything tidied

No, having the supplies bound to the parent is desired (especially given
that there isn't a child node) - it's the fact that you're bodging this
in the framework by just randomly peering at the parent device and
hoping it's an MFD parent when a lookup fails. That's not a safe thing
to do.

Like I said in the quote above trying to handle this in the child isn't
a good approach, it's both more idiomatic and more robust to put the
mappings from the parent device to the child devices in when creating
the child devices.

> onto the one device tree node? The reason I ask is because

Yes, for a device like this.

> looking at this further we run into other problems, the MFD
> framework is clearly intended to have a sub-node for each device.

No it isn't, see recent discussions on the list and look at the existing
drivers. This is supported because for some devices it makes sense to
split things up but it's not something that needs to be used for every
device, it's useful when for example a device embeds a reusable generic
IP. If you're ending up with the subdevices defined with the same level
of granularity as the parent device then that's not happening, and
remember that for these devices you do also need to support non-DT
systems.

> For example, the GPIO driver has a similar issue if anything else
> wishes to use an Arizona devices GPIO, because the GPIO driver
> is on a different device to the MFD so again it can't locate it.
> I haven't checked yet but I am guessing there will be similar
> issues with the interrupts.

No, this isn't an issue at all. Look at how the regulator API resolves
DT lookups for example, the structure of the driver offering the service
should have no impact on anything referencing it. The fact that Linux
happens to split things up into a particular set of subsystems at the
current time should have no bearing on the way that the DT bindings are
written since that's just a detail of how Linux works.

Linux (or any other operating system) can always decide to refactor
later on, something we take advantage of relatively often. For example
with these devices the clocks are currently described as part of the
audio CODEC but which should probably in future move over to the clock
API once that's generally available since they're shared within the
device and can be brought out of the device to other system components.
The device tree for a system using the device shouldn't need to change
when that happens since nothing about the hardware changed.

Attachment: signature.asc
Description: Digital signature