[PATCH v2 12/13] of: add barebox-serial driver
David Jander
david at protonic.nl
Tue Aug 11 05:52:53 EDT 2020
On Tue, 11 Aug 2020 10:58:47 +0200
Oleksij Rempel <o.rempel at pengutronix.de> wrote:
> On Tue, Aug 11, 2020 at 10:34:01AM +0200, Sascha Hauer wrote:
> > On Wed, Aug 05, 2020 at 12:16:27PM +0200, Oleksij Rempel wrote:
> > > Provide a driver which should act as nvmem consumer
> > > for board serial number information.
> > >
> > > To make use of this driver, DTS should contain a serial
> > > node with compatibe "barebox,serial" and nvmem-cell-names
> > > "serial-number":
> > >
> > > ...
> > > chosen {
> > > serial {
> > > compatible = "barebox,serial";
> > > nvmem-cell-names = "serial-number";
> > > nvmem-cells = &some_provider;
> > > };
> > > };
> >
> > This driver only works when the EEPROM or whatever provides the NVMEM
> > contains the serial number in exactly the same format as shall be added
> > to the /serial-number property. This seems to be a special case only and
> > doesn't seem to justify a generic driver.
>
> As with usual devicetree based solution we can add additional
> compatibles to better describe a variant or quirk which should be used
> to convert raw data to the serial number in usable for environment and
> device tree way. I hope, by having generic drivers other users will alight
> with it by making new products or extend existing driver by mainlining
> existing products.
Just for information, this is the layout used for I2C EEPROM contents in the
RFID chip (from I2C address 0x6000, device id 0x51):
struct rfid_contents {
u8 mac[6];
char serial[10];
u8 cs;
} __attribute__ ((packed));
The cs field is just the bit-inverted LSB of the sum of all bytes composing
the struct up to cs.
Note, that even boards without ethernet interface use the same struct, but the
MAC address field is ignored and can be anything. The design of this struct is
quite specific, inflexible and not at all future-proof. So maybe it shouldn't
go into a full-blown driver and instead stay hidden in the board code.
Best regards,
--
David Jander
Protonic Holland.
More information about the barebox
mailing list