[U-Boot] Struct SoC access (was:Make preparatory patches that initially have no effect?)

Wolfgang Denk wd at denx.de
Sat Aug 14 21:41:17 CEST 2010


Dear Reinhard Meyer,

In message <4C66EECA.5020509 at emk-elektronik.de> you wrote:
>
> > Have the first add that file, and the second assume it comes later in
> > the sequence.
> 
> You don't mean by "sequence" PATCH 1/n, 2/n, etc? The drivers are so
> independent that that would not really make sense...

Then just write in the comment part of the second patch that the other
one has to be applied first...

> That's a thin line. Although I need only one register of the DBU (for
> example) I think its wise to define all registers in it, and not to
> _reserve[] the unused ones....

Right. If you add a function, add all the registers in it.
But don't bother to explain each and every bit in the registers you
never refer to, nor add completely unrelated blocks.

> Anyway, is the method of (for example!)
> 
> #define DBU_ADDR 0xsomething (in a SoC header file)
> 
> dbu_t *dbu = (dbu_t *)DBU_ADDR; (in a function)
> 
> OK?

Yes.

> Or do we need to further encapsulate that in a function like

No.

> I was even thinking of something like
> 
> struct soc {
> 	u32 xyz[0x80];	/* XYZ unit */
> 	u32 dbu[0x80];	/* Debug Unit */
> 	u32 rstc[0x80];	/* Reset Controller */
> and so on.

This is what PPC used to do; I like that - but ARM people always
explained to me that it makes no sense because address space on ARM
SoC is only sparely populated.

> Then in a driver one could write
> dbu_t *dbu = (dbu_t *)soc.dbu;
> or something along that line

I think this looks nice, but as mentioned before - I'm not an ARM
expert. They tend to do it differently.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Q:  How many DEC repairman does it take to fix a flat ?
A:  Five; four to hold the car up and one to swap tires.


More information about the U-Boot mailing list