commit: http://blackfin.uclinux.org/git/?p=u-boot;a=commitdiff;h=4026b31099888953d85a0fcfbd18a18ab589297d
branch: http://blackfin.uclinux.org/git/?p=u-boot;a=shortlog;h=refs/heads/trunk

Signed-off-by: Sonic Zhang <sonic.zh...@analog.com>
---
 arch/blackfin/cpu/initcode.c      |    7 +++----
 arch/blackfin/include/asm/clock.h |   19 ++++++++-----------
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/arch/blackfin/cpu/initcode.c b/arch/blackfin/cpu/initcode.c
index 848ae56..2173b6b 100644
--- a/arch/blackfin/cpu/initcode.c
+++ b/arch/blackfin/cpu/initcode.c
@@ -733,11 +733,10 @@ update_serial_clocks(ADI_BOOT_DATA *bs, uint sdivB, uint divB, uint vcoB)
 	sdivR = bfin_read_PLL_DIV() & 0xf;
 	vcoR = (bfin_read_PLL_CTL() >> 9) & 0x3f;
 #endif
-	int dividend = sdivB * divB * vcoR;
-	int divisor = vcoB * sdivR;
+	unsigned int dividend = sdivB * divB * vcoR;
+	unsigned int divisor = vcoB * sdivR;
 	unsigned int quotient;
-	for (quotient = 0; dividend > 0; ++quotient)
-		dividend -= divisor;
+	quotient = early_division(dividend, divisor);
 	serial_early_put_div(quotient - ANOMALY_05000230);
 	serial_putc('c');
 }
diff --git a/arch/blackfin/include/asm/clock.h b/arch/blackfin/include/asm/clock.h
index dea324f..f1fcd40 100644
--- a/arch/blackfin/include/asm/clock.h
+++ b/arch/blackfin/include/asm/clock.h
@@ -24,21 +24,18 @@ __attribute__((always_inline))
 static inline uint32_t early_division(uint32_t dividend, uint32_t divisor)
 {
 	uint32_t quotient;
-	uint32_t i;
+	uint32_t i, j;
 
-	for (i = 0; i < 5; i++) {
-		if (divisor == (1 << i)) {
-			quotient = dividend >> i;
-			return quotient;
+	for (quotient = 1, i = 1; dividend > divisor; ++i) {
+		j = divisor << i;
+		if (j > dividend || (j & 0x80000000)) {
+			--i;
+			quotient += (1 << i);
+			dividend -= (divisor << i);
+			i = 0;
 		}
 	}
 
-	if (divisor) {
-		for (quotient = 0; dividend >= divisor; ++quotient)
-			dividend -= divisor;
-	} else
-		quotient = dividend;
-
 	return quotient;
 }
 
_______________________________________________
U-Boot-commits mailing list
U-Boot-commits@blackfin.uclinux.org
https://blackfin.uclinux.org/mailman/listinfo/u-boot-commits

Reply via email to