Re: I2C and devicetrees

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi everyone,

I have a similar question.
I'd like to "name" i2c devices so that a userspace application can somehow identify those devices with the same function across different boards (which may have different addresses or be connected to a different i2c bus, or be a physically different chip).

For instance "hwmon" devices get instantiated within sysfs under
/sys/class/hwmon/hwmonX

# cat /sys/class/hwmon/hwmon0/device/name
lm75

which I would like to be identified by the name "switch" (as in "switch temperature"). I was thinking about instantiating it as something like "lm75:switch" within i2c_board_info.type. For device-tree-less architectures, a trivial change within i2c_match_id() so to ignore the part following ":" seems to do the trick. Don't know about devicetree but I guess a similar approach could be imagined.

Another example would be given by EEPROMs: all boards are equipped with an EEPROM containing inventory management, which I would like to identify as "ivm". So something like "24c08:ivm". After all, I'd like to be able to achive something like "named MTD partitions" which you can identify by looking at "/proc/mtd".

Maybe some other symbol could be used instead of ":", but anyhow, does the above make any sense at all to you?

Thanks a lot!
Gerlando

On 12/14/2012 09:38 PM, Grant Likely wrote:
On Tue, 11 Dec 2012 13:56:08 -0700, Stephen Warren<swarren-3lzwWm7+Weoh9ZMKESR00Q@xxxxxxxxxxxxxxxx>  wrote:
On 12/11/2012 01:21 PM, Olof Johansson wrote:
[+devicetree-discuss]

On Wed, Dec 5, 2012 at 2:36 PM, Peter Huewe<PeterHuewe-Mmb7MZpHnFY@xxxxxxxxxxxxxxxx>  wrote:
Hi,

I have a short question about the relations between i2c and devicetrees.

I was wondering
is the device part of the compatible string of a (trivial) i2c device
instanciated via devicetree _always_ identical to name in i2c_client.name ?
Or can it be somehow different?

It can be different, but the driver will then need to add a OF table
that matches the probing. By default the i2c/dt core code will strip
off the vendor prefix (before ",") and try probing with the rest of
the device name. If that doesn't match the client name, that is when
you need the additional table.

While relying on the prefix stripping works, I think I recall Grant
mentioning that people shouldn't rely on it - namely that any I2C device
that gets instantiated from DT should contain the OF match table
explicitly. I CC'd Grant in case I'm mis-quoting him.

I'm not quite that strict about it. The behaviour described above is
based merely on a heuristic but for a lot of drivers that don't do
anything special it works just fine. The moment you need to identify a
specific device it becomes better to use an of match table.

g.


--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux