* [U-Boot] [PATCH V2] orion5x: optimize window size computation
@ 2010-10-06 14:46 Albert Aribaud
2010-10-06 18:01 ` Chris Moore
0 siblings, 1 reply; 5+ messages in thread
From: Albert Aribaud @ 2010-10-06 14:46 UTC (permalink / raw)
To: u-boot
Signed-off-by: Chris Moore <moore@free.fr>
Signed-off-by: Albert Aribaud <albert.aribaud@free.fr>
---
V1 Initial submission
V2 Double Signed-off-by as requested
arch/arm/cpu/arm926ejs/orion5x/cpu.c | 30 ++++++++++++++++++++----------
1 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/arch/arm/cpu/arm926ejs/orion5x/cpu.c b/arch/arm/cpu/arm926ejs/orion5x/cpu.c
index 260f88b..a49d926 100644
--- a/arch/arm/cpu/arm926ejs/orion5x/cpu.c
+++ b/arch/arm/cpu/arm926ejs/orion5x/cpu.c
@@ -48,24 +48,34 @@ void reset_cpu(unsigned long ignored)
}
/*
- * Window Size
+ * Compute Window Size field value from size expressed in bytes
* Used with the Base register to set the address window size and location.
* Must be programmed from LSB to MSB as sequence of ones followed by
* sequence of zeros. The number of ones specifies the size of the window in
* 64 KByte granularity (e.g., a value of 0x00FF specifies 256 = 16 MByte).
- * NOTE: A value of 0x0 specifies 64-KByte size.
+ * NOTES:
+ * 1) A sizeval equal to 0x0 specifies 4 TB.
+ * 2) A return value of 0x0 specifies 64 KB.
*/
unsigned int orion5x_winctrl_calcsize(unsigned int sizeval)
{
- int i;
- unsigned int j = 0;
- u32 val = sizeval >> 1;
-
- for (i = 0; val >= 0x10000; i++) {
- j |= (1 << i);
- val = val >> 1;
- }
- return 0x0000ffff & j;
+ /*
+ * Calculate the number of 64 KiB blocks needed minus one (rounding up).
+ * For sizeval > 0 this is equivalent to:
+ * sizeval = (u32) ceil((double) sizeval / 65536.0) - 1
+ */
+ sizeval = (sizeval - 1) >> 16;
+
+ /*
+ * Propagate 'one' bits to the right by 'oring' them.
+ * We need only treat bits 15-0.
+ */
+ sizeval |= sizeval >> 1; /* 'Or' bit 15 onto bit 14 */
+ sizeval |= sizeval >> 2; /* 'Or' bits 15-14 onto bits 13-12 */
+ sizeval |= sizeval >> 4; /* 'Or' bits 15-12 onto bits 11-8 */
+ sizeval |= sizeval >> 8; /* 'Or' bits 15-8 onto bits 7-0*/
+
+ return sizeval;
}
/*
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH V2] orion5x: optimize window size computation
2010-10-06 14:46 [U-Boot] [PATCH V2] orion5x: optimize window size computation Albert Aribaud
@ 2010-10-06 18:01 ` Chris Moore
2010-10-06 18:35 ` Albert ARIBAUD
2010-10-06 19:24 ` Wolfgang Denk
0 siblings, 2 replies; 5+ messages in thread
From: Chris Moore @ 2010-10-06 18:01 UTC (permalink / raw)
To: u-boot
Hi,
Sorry Albert I missed this one last time :(
Le 06/10/2010 16:46, Albert Aribaud a ?crit :
> + * 1) A sizeval equal to 0x0 specifies 4 TB
s/TB/GB/ or maybe even s/TB/GiB/
Question: are MB, GB, ... or MiB, GiB, ... preferred in U-Boot?
I generally try to use the "i" versions where appropriate.
In fact I used a KiB below:
> + * Calculate the number of 64 KiB blocks needed minus one (rounding up).
IMHO whatever the choice, it would be preferable to be consistent
throughout.
Cheers,
Chris
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH V2] orion5x: optimize window size computation
2010-10-06 18:01 ` Chris Moore
@ 2010-10-06 18:35 ` Albert ARIBAUD
2010-10-06 18:37 ` Albert ARIBAUD
2010-10-06 19:24 ` Wolfgang Denk
1 sibling, 1 reply; 5+ messages in thread
From: Albert ARIBAUD @ 2010-10-06 18:35 UTC (permalink / raw)
To: u-boot
Le 06/10/2010 20:01, Chris Moore a ?crit :
> Hi,
>
> Sorry Albert I missed this one last time :(
>
> Le 06/10/2010 16:46, Albert Aribaud a ?crit :
>> + * 1) A sizeval equal to 0x0 specifies 4 TB
>
> s/TB/GB/ or maybe even s/TB/GiB/
>
> Question: are MB, GB, ... or MiB, GiB, ... preferred in U-Boot?
/me slaps himself.
One day, I'll get this one right the first time around, you'll see.
> I generally try to use the "i" versions where appropriate.
> In fact I used a KiB below:
>
>> + * Calculate the number of 64 KiB blocks needed minus one (rounding up).
>
> IMHO whatever the choice, it would be preferable to be consistent
> throughout.
Indeed, and as always, I prefer the les ambiguous choice: 4 TiB it is.
> Cheers,
> Chris
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH V2] orion5x: optimize window size computation
2010-10-06 18:35 ` Albert ARIBAUD
@ 2010-10-06 18:37 ` Albert ARIBAUD
0 siblings, 0 replies; 5+ messages in thread
From: Albert ARIBAUD @ 2010-10-06 18:37 UTC (permalink / raw)
To: u-boot
Le 06/10/2010 20:35, Albert ARIBAUD a ?crit :
> Indeed, and as always, I prefer the les ambiguous choice: 4 TiB it is.
Argh!!! 4 *GiB* it is.
Amicalement,
--
Albert.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH V2] orion5x: optimize window size computation
2010-10-06 18:01 ` Chris Moore
2010-10-06 18:35 ` Albert ARIBAUD
@ 2010-10-06 19:24 ` Wolfgang Denk
1 sibling, 0 replies; 5+ messages in thread
From: Wolfgang Denk @ 2010-10-06 19:24 UTC (permalink / raw)
To: u-boot
Dear Chris Moore,
In message <4CACB95F.1000001@free.fr> you wrote:
>
> Question: are MB, GB, ... or MiB, GiB, ... preferred in U-Boot?
We try to use standard units, i. e. MiB, GiB
> I generally try to use the "i" versions where appropriate.
> In fact I used a KiB below:
ACK.
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
In the pitiful, multipage, connection-boxed form to which the flow-
chart has today been elaborated, it has proved to be useless as a
design tool -- programmers draw flowcharts after, not before, writing
the programs they describe. - Fred Brooks, Jr.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-10-06 19:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-06 14:46 [U-Boot] [PATCH V2] orion5x: optimize window size computation Albert Aribaud
2010-10-06 18:01 ` Chris Moore
2010-10-06 18:35 ` Albert ARIBAUD
2010-10-06 18:37 ` Albert ARIBAUD
2010-10-06 19:24 ` Wolfgang Denk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox