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

2010-08-14 Thread Wolfgang Denk
Dear Reinhard Meyer,

In message <4c66eeca.5020...@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: w...@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.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


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

2010-08-14 Thread Mike Frysinger
On Sat, Aug 14, 2010 at 3:30 PM, Reinhard Meyer wrote:
> #define DBU_ADDR 0xsomething (in a SoC header file)
>
> dbu_t *dbu = (dbu_t *)DBU_ADDR; (in a function)

needs to be volatile ...
-mike
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


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

2010-08-14 Thread Reinhard Meyer
Dear Wolfgang Denk,
> 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...

> The wiki page does not talk about drivers... It's a general rule and
> applies to all sorts of code. Only add what is really used (this also
> refers, for example, to struct definitions for register blocks etc. -
> don't try to provide a complete description of your SoC; add only
> stuff that is actually used by the code).

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

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?

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

dbut_t *get_dbu_addr(void) {return (dbu_t *)DBU_ADDR;}


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.

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

Best Regards
Reinhard
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot