[U-Boot] [PATCH 1/2] i.MX28: Fix ref_cpu clock setup

Marek Vasut marek.vasut at gmail.com
Fri Feb 3 15:09:03 CET 2012


> > Awesome. So after reading your replies, let's just rename mx28_reg to
> > mx28_reg_32 and introduce mx28_reg_8 for this particular problem.
> 
> You were probably already foreseeing this when you made your
> suggestion to use accessors, but now I'm working it I see introducing
> mx28_reg_8 may get too messy. The 4 byte-parts (name, name_set,
> name_clr and name_tog) of one register-set (cpu) are interleaved with
> the next set (emi), like this:
>         uint8_t hw_clkctrl_frac0_cpu;
>         uint8_t hw_clkctrl_frac0_emi;
>         uint8_t hw_clkctrl_frac0_io1;
>         uint8_t hw_clkctrl_frac0_io0;
>         uint8_t hw_clkctrl_frac0_cpu_set;
>         uint8_t hw_clkctrl_frac0_emi_set;
>         uint8_t hw_clkctrl_frac0_io1_set;
>         uint8_t hw_clkctrl_frac0_io0_set;
>         uint8_t hw_clkctrl_frac0_cpu_clr;
>         uint8_t hw_clkctrl_frac0_emi_clr;
>         uint8_t hw_clkctrl_frac0_io1_clr;
>         uint8_t hw_clkctrl_frac0_io0_clr;
>         uint8_t hw_clkctrl_frac0_cpu_tog;
>         uint8_t hw_clkctrl_frac0_emi_tog;
>         uint8_t hw_clkctrl_frac0_io1_tog;
>         uint8_t hw_clkctrl_frac0_io0_tog;
> 
> So this won't work due to overlap:
> #define __mx28_reg_8(name)              \
>         uint8_t name;                   \
>         uint8_t name##_set;             \
>         uint8_t name##_clr;             \
>         uint8_t name##_tog;
> 
> Instead I'd have to drop the byte-part names (cpu, emi, io1 and io0)
> and replace them with more generic names like b0 and b1 for byte 0
> and 1, and declare them all at once, like this:
> #define __mx28_reg_8(name)              \
>         uint8_t name##_b0;              \
>         uint8_t name##_b1;              \
>         uint8_t name##_b2;              \
>         uint8_t name##_b3;              \
>         uint8_t name##_b0_set;          \
>         uint8_t name##_b1_set;          \
>         uint8_t name##_b2_set;          \
>         uint8_t name##_b3_set;          \
>         uint8_t name##_b0_clr;          \
>         uint8_t name##_b1_clr;          \
>         uint8_t name##_b2_clr;          \
>         uint8_t name##_b3_clr;          \
>         uint8_t name##_b0_tog;          \
>         uint8_t name##_b1_tog;          \
>         uint8_t name##_b2_tog;          \
>         uint8_t name##_b3_tog;
> Besides b0 and b1 being confusing in endianity context, it's not a
> pretty solution.

Make it an array?

M
> 
> I'm going to try a couple of different things now, to find the least-
> ugly solution if I can't find a pretty one.


More information about the U-Boot mailing list