"cell-index" vs. "index" vs. no index in I2C device nodes

David Gibson david at gibson.dropbear.id.au
Thu Jun 5 20:57:07 EST 2008


On Thu, Jun 05, 2008 at 10:45:42AM +0200, Stefan Roese wrote:
> On Thursday 05 June 2008, Jean Delvare wrote:
> > > > Maybe it is time to remove the index, or maybe we should go back to
> > > > using both a static and the index. But at the time we decided to
> > > > enforce an index.
> > >
> > > So what should we do now? Currently I2C doesn't work at all on 4xx since
> > > the driver expects the "index" property and no dts sets this property.
> > > Personally I would like to move to using cell-index here, since this
> > > seems to be more common. But I could also life with removing the index
> > > property and using the "static index" if this is preferred and/or
> > > acceptable.
> > >
> > > Please advise. Thanks.
> >
> > As far as I am concerned, it's really up to the maintainers and users
> > of this platform. All I am asking for is that you do not call
> > i2c_add_numbered_adapter() on an adapter with an automatically
> > generated number. This function must only be used for adapter's those
> > number is well defined. If an adapter doesn't have a well-defined
> > number then use i2c_add_adapter() (but then you can no longer declare
> > your I2C devices as part of the platform data.)
> 
> Full ack from me. So I suggest to use "cell-index" if available and otherwise 
> use an incremented number, same as the FSL i2c driver does now:
> 
> http://ozlabs.org/pipermail/linuxppc-dev/2008-June/057254.html
> 
> If nobody objects I'll send a patch to add the cell-index to all 4xx
> dts files in a short while.

Do *not* add cell-index unless it is used to correlate to a global
register somewhere.  Although, for the 4xx IIC adaptor, I think there
usually will be shared registers, and a cell-index property.

The proper device tree mechanism for providing a standard numbering
for similar devices is the /aliases node.  So instead, what you should
do is:
	- If a suitable alias exists pointing to this device, use that
number
	- Otherwise, if cell-index is present, use that (this is a
fallback heuristic, not recommended practice)
	- Otherwise, use i2c_add_adapter() instead of
i2c_add_numbered_adapter()

If a platform has a conventional way of numbering the i2c busses,
which you want to represent in the device tree, you should add
aliases, not cell-index.

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson



More information about the Linuxppc-dev mailing list