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

2010-05-22 Thread Kumar Gala
On May 21, 2010, at 3:16 PM, Wolfgang Denk wrote: Dear Timur Tabi, In message 4bf6e5df.5020...@freescale.com you wrote: So here's a better version of that function that rounds to the nearest MHz and is of a proper coding style: Why do we need that? Um, because you complained about

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

2010-05-22 Thread Kumar Gala
On May 21, 2010, at 1:42 PM, Timur Tabi wrote: On Fri, May 21, 2010 at 4:18 AM, Kumar Gala ga...@kernel.crashing.org wrote: +COBJS-$(CONFIG_P2020DS)+= ics307_clk.o How about changing this to: COBJS-$(CONFIG_ICS307_REFCLK_HZ) += ics307_clk.o I'd rather it be board

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

2010-05-21 Thread Kumar Gala
We have several boards that use the same ICS307 CLK chip to drive the System clock and DDR clock. Move the code into a common location so we share it. Convert the P2020DS board as the first to use the new common ICS307 code. Signed-off-by: Kumar Gala ga...@kernel.crashing.org ---

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

2010-05-21 Thread Timur Tabi
On Fri, May 21, 2010 at 4:18 AM, Kumar Gala ga...@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        

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

2010-05-21 Thread Timur Tabi
On Fri, May 21, 2010 at 4:18 AM, Kumar Gala ga...@kernel.crashing.org wrote: +COBJS-$(CONFIG_P2020DS)                += ics307_clk.o How about changing this to: COBJS-$(CONFIG_ICS307_REFCLK_HZ) += ics307_clk.o -- Timur Tabi Linux kernel developer at Freescale

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

2010-05-21 Thread Timur Tabi
On Fri, May 21, 2010 at 4:18 AM, Kumar Gala ga...@kernel.crashing.org wrote: +        * Adding 1 to get a nicely rounded number, but this needs +        * more tweaking to get a properly rounded number. +        */ + +       freq = 1 + (input_freq * 2 * (VDW + 8) / ((RDW + 2) * OD)); Is

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

2010-05-21 Thread Timur Tabi
On Fri, May 21, 2010 at 1:59 PM, Timur Tabi timur.t...@gmail.com wrote: Is this rounding algorithm the reason why I get output like this: Clock Configuration:       CPU0:799.992 MHz, CPU1:799.992 MHz,       CCB:399.996 MHz,       DDR:299.997 MHz (599.994 MT/s data rate) (Asynchronous),

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

2010-05-21 Thread Wolfgang Denk
Dear Timur Tabi, In message aanlktilji5knon3qd_58dy7xpegviiibe1qy0gxoq...@mail.gmail.com you wrote: So here's a better version of that function that rounds to the nearest MHz and is of a proper coding style: Why do we need that? And the result: Clock Configuration: CPU0:800

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

2010-05-21 Thread Timur Tabi
Wolfgang Denk wrote: So here's a better version of that function that rounds to the nearest MHz and is of a proper coding style: Why do we need that? Um, because you complained about it? +static unsigned long ics307_clk_freq(unsigned char cw0, unsigned char cw1, +

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

2010-05-21 Thread Wolfgang Denk
Dear Timur Tabi, In message 4bf6e5df.5020...@freescale.com you wrote: So here's a better version of that function that rounds to the nearest MHz and is of a proper coding style: Why do we need that? Um, because you complained about it? I mean, why do we need that function? strmhz()

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

2010-05-21 Thread Timur Tabi
Wolfgang Denk wrote: 799.992 MHz seems to be 24 * 33,333,000 Hz. Are you sure this is the exact quartz frequency on your board? If yes, then the number printed should probably remain 799.992 MHz. Or is it 33,333,333 Hz? Or 33,000,000 ? Ok, I see your point. Technically, I am returning a

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

2010-05-21 Thread Wolfgang Denk
Dear Timur Tabi, In message 4bf6ecd0.4060...@freescale.com you wrote: However, the current code adds a 1 to the result, which is definitely wrong. On my board, for example, it returns 9001, which is not correct. So the existing rounding algorithm is broken. Agreed. However, I

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

2010-05-21 Thread Timur Tabi
Wolfgang Denk wrote: Well, the function is strMHZ, and it prints a frequency in MHz with exactly 3 digits precision - so rounding to the nearest kHz is exactly the right thing to do. Actually, it's not really three significant digits. 799.992 is six significant digits. If you you wanted

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

2010-05-21 Thread Kumar Gala
On May 21, 2010, at 10:57 AM, Timur Tabi wrote: On Fri, May 21, 2010 at 4:18 AM, Kumar Gala ga...@kernel.crashing.org wrote: +#ifdef CONFIG_FSL_NGPIXIS +#include ngpixis.h +#define PIXIS_VSYSCLK0 offsetof(struct ngpixis, sclk[0]) +#define PIXIS_VSYSCLK1 offsetof(struct

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

2010-05-21 Thread Kumar Gala
On May 21, 2010, at 10:57 AM, Timur Tabi wrote: On Fri, May 21, 2010 at 4:18 AM, Kumar Gala ga...@kernel.crashing.org wrote: +#ifdef CONFIG_FSL_NGPIXIS +#include ngpixis.h +#define PIXIS_VSYSCLK0 offsetof(struct ngpixis, sclk[0]) +#define PIXIS_VSYSCLK1 offsetof(struct

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

2010-05-21 Thread Wolfgang Denk
Dear Kumar Gala, In message fa771a99-42ea-4299-9de1-77afc3273...@kernel.crashing.org you wrote: +{ + const unsigned long input_freq = CONFIG_ICS307_REFCLK_HZ; + unsigned long VDW = ((cw1 1) 0x1FE) + ((cw2 7) 1); + unsigned long RDW = cw2 0x7F; + unsigned

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

2010-05-21 Thread Wolfgang Denk
Dear Kumar Gala, In message 7e86bc8f-7e3f-49b1-b1c5-b21991303...@kernel.crashing.org you wrote: ga...@kernel.crashing.org wrote: +#ifdef CONFIG_FSL_NGPIXIS +#include ngpixis.h +#define PIXIS_VSYSCLK0 offsetof(struct ngpixis, sclk[0]) +#define PIXIS_VSYSCLK1