Trivial bug in(?) and proposed change to libi2c.h
Robert S. Grimes
rsg at alum.mit.edu
Wed May 14 20:24:28 UTC 2008
Till Straumann wrote:
>> That being said, how would that fit in with device major and minor
>> numbers? I am certainly unsure here, so let me restate my
>> configuration, which is more complex than some. I have several,
>> separate SPI IP peripherals - this would correspond to a traditional
>> microprocessor with multiple SPI controllers. Each SPI "bus" has
>> multiple devices attached to it. So, I was under the impression that a
>> major device number would be assigned to each instance of the SPI
>> controller driver, and a minor number to each SPI device driver.
>>
>> Is this correct?
>>
>> Or should the major number correspond to the SPI driver, the minor
>> number to a specific controller, and some new number (in the struct
>> under discussion) assigned for each SPI device.
>>
>>
> The latter. Traditionally, the major number is associated with a
> particular driver
> (registered with the OS) the minor number with a device instance;
> ultimately the semantics of the
> minor number are defined by the driver, the major number by the OS.
>
> libi2c registers itself with RTEMS under one major number and it uses
> specific
> semantics for the minor number. Basically, libi2c uses parts of the
> minor number
> to identify a 'low-level' aka 'bus' driver and dispatches read/write
> etc. to the
> 'bus' driver registered with libi2c under the 'bus' number (some bits or
> the minor number).
>
So the major number here is libi2c, and the minor number specifies both
a "controller" device (either i2c or spi, right?) and a "chip" device
(e.g. an I2C EEPROM, and SPI FRAM, etc.), right?
> Whatever you do, please do not break the current semantics for i2c devices
> where the bus number and device-address on the bus(es) are encoded in
> the minor number.
> The 'device address' on the bus which is also encoded in the minor number is
> used by libi2c to address a particular device on a 'bus' during the
> addressing phase
> which precedes every read/write operation.
>
Of course - my "off-topic" was meant as a request for explanation WRT
how things are done, with the implication that we maintain the same
approach.
> If you have multiple identical controllers you should be able to
> register them multiple times with libi2c under a different bus number.
>
...and the "different bus number" is used in the minor number, right?
Things are clearing up around these parts - thanks!
Take care,
-Bob
More information about the users
mailing list