[U-Boot] [PATCH] Move ICS CLK chip frequenty calculation code into a common board library

Wolfgang Denk wd at denx.de
Sat May 22 00:35:29 CEST 2010


Dear Kumar Gala,

In message <7E86BC8F-7E3F-49B1-B1C5-B21991303AF5 at kernel.crashing.org> you wrote:
> 
> <galak at kernel.crashing.org> wrote:
> > 
> >> +#ifdef CONFIG_FSL_NGPIXIS
> >> +#include "ngpixis.h"
> >> +#define PIXIS_VSYSCLK0         offsetof(struct ngpixis, sclk[0])
> >> +#define PIXIS_VSYSCLK1         offsetof(struct ngpixis, sclk[1])
> >> +#define PIXIS_VSYSCLK2         offsetof(struct ngpixis, sclk[2])
> >> +#define PIXIS_VDDRCLK0         offsetof(struct ngpixis, dclk[0])
> >> +#define PIXIS_VDDRCLK1         offsetof(struct ngpixis, dclk[1])
> >> +#define PIXIS_VDDRCLK2         offsetof(struct ngpixis, dclk[2])
> >> +#endif
> > 
> > Yuck.  I specifically created the ngpixis_t structure because Wolfgang
> > objected to the use of macros for offsets.
> > 
> > But I understand why you did it.  It's the easiest way to maintain
> > compatibility between pixis and ngpixis.
>
> Wolfgang, is this an issue?

This, in itself, it not an issue. 

The issue comes when you wrote code like this:

+	return ics307_clk_freq (
+			in_8(pixis_base + PIXIS_VSYSCLK0),
+			in_8(pixis_base + PIXIS_VSYSCLK1),
+			in_8(pixis_base + PIXIS_VSYSCLK2)
+			);
+}
+
+unsigned long get_board_ddr_clk(void)
+{
+	u8 *pixis_base = (u8 *)PIXIS_BASE;
+
+	return ics307_clk_freq (
+			in_8(pixis_base + PIXIS_VDDRCLK0),
+			in_8(pixis_base + PIXIS_VDDRCLK1),
+			in_8(pixis_base + PIXIS_VDDRCLK2)
+			);

This clearly gets a NAK because you should use a struct, and not base
address + offset notation.

> The other option is have 3 different structs:
>
> On p2020: #define PIXIS_VSYSCLK0         offsetof(struct ngpixis, > sclk[0])
> on  8572: #define PIXIS_VSYSCLK0	0x1C
> on  8536: #define PIXIS_VSYSCLK0	0x1A

I see #defines here, no structs.

I'm not sure if you need different structs (haven't looked into
these), or if clever notation of the struct is sufficient.

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
A committee is a life form with six or more legs and no brain.
                              -- Lazarus Long, "Time Enough For Love"


More information about the U-Boot mailing list