Re: [RESEND RFC 2/3] nvmem: Add 'nvmem-blob' driver
From: Maxime Ripard
Date: Wed Mar 09 2016 - 05:13:58 EST
On Tue, Mar 08, 2016 at 11:24:33PM +0000, Trent Piepho wrote:
> On Tue, 2016-03-08 at 14:46 -0800, Andrey Smirnov wrote:
> > >> I don't think I understand what you mean, could you give me an example
> > >> of how I'd use local-mac-address property for that use case? AFAIK,
> > >> local-mac-address is just an array of bytes embedded into device tree,
> > >
> > > Well, yeah, but the nvmem-blob is also just an array of bytes embedded
> > > into the DT, right?
> > One is accessible via "nvmem" API and the other one isn't.
> > >
> > >> how would it get populated with data from OTP memory of SoC?
> > >
> > > In the bootloader, or Linux, read the OTP, patch the DT to add that
> > > node, done.
> > No, it's not really "done", because if you read my previous messages,
> > "read the OTP, patch the DT" is exactly the problem I am trying to
> > solve. The overall goal is to be able to read a certain "nvmem" cell
> > and patch DT with that data as MAC address, however in it's current
> > incarnation "nvmem" doesn't have provisions to make cells that are
> > just combination of other cells (patch #3) and to embed certain data
> So I did something that solved this a few years ago for another board
> and embedded the data into the local-mac-address property.
> I think maybe the problem isn't here isn't clear. For some boards
> (mxs), only part of a MAC address is stored in nvmem while the rest of
> the address is fixed data. Currently embedded in the kernel source,
> though embedded in the device tree would clearly be better. While
> splitting the MAC into two locations like this is not, at least in my
> opinion, the best design, it's burned into the one time programmable
> memory so there's not much that can be done.
> The kernel looks for 'mac-address' and then 'local-mac-address', with
> the former having precedence.
> So what I did was embed the fixed portion in 'local-mac-address', have
> the bootloader extract the variable part from nvmem, and then combine
> the two and place it into 'mac-address' for the kernel to use.
I guess another solution would be to deal with that at the driver
level. Read the 3 last bytes from the OTP, add the MAC prefix and give
that to the net framework without looking it up in the DT. The MAC
prefix could even be changed then through a kernel parameter, which is
not possible currently.
> My DT binding that described the placement of data from nvmem into the
> MAC used a permutation list instead of a series of ranges. So a list
> like [0 0 0 1 2 3] could be used to specify the first three bytes of the
> mac address do not come from nvmem. This also allows changing byte
> order concisely. But doesn't scale well to larger regions.
Is your code / binding doc somewhere for reference ?
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
Description: Digital signature