From owner-p4-projects@FreeBSD.ORG Sun Feb 19 07:46:49 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6187816A423; Sun, 19 Feb 2006 07:46:48 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 164FC16A422 for ; Sun, 19 Feb 2006 07:46:48 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6C6A943D6B for ; Sun, 19 Feb 2006 07:46:44 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k1J7khQ6008976 for ; Sun, 19 Feb 2006 07:46:44 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k1J7kh6U008973 for perforce@freebsd.org; Sun, 19 Feb 2006 07:46:43 GMT (envelope-from imp@freebsd.org) Date: Sun, 19 Feb 2006 07:46:43 GMT Message-Id: <200602190746.k1J7kh6U008973@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 92030 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Feb 2006 07:46:49 -0000 http://perforce.freebsd.org/chv.cgi?CH=92030 Change 92030 by imp@imp_plunger on 2006/02/19 07:45:44 Use better defines instead of magic constants. Affected files ... .. //depot/projects/arm/src/sys/arm/at91/at91_pmc.c#5 edit .. //depot/projects/arm/src/sys/arm/at91/at91_pmcreg.h#2 edit Differences ... ==== //depot/projects/arm/src/sys/arm/at91/at91_pmc.c#5 (text+ko) ==== @@ -206,21 +206,17 @@ int32_t diff1; uint32_t input, mul1; - /* - * PLL input between 1MHz and 32MHz per spec, but lower - * frequences seem necessary in some cases so allow 100K. - */ input = main_freq / i; - if (input < 100000) - continue; - if (input > 32000000) + if (input < PMC_PLL_MIN_IN_FREQ) + break; + if (input > PMC_PLL_MAX_IN_FREQ) continue; mul1 = out_freq / input; - if (mul1 > 2048) + if (mul1 > PMC_PLL_MULT_MAX) continue; - if (mul1 < 2) - goto fail; + if (mul1 < PMC_PLL_MULT_MIN) + break; diff1 = out_freq - input * mul1; if (diff1 < 0) @@ -233,7 +229,7 @@ break; } } - if (i == 256 && diff > (out_freq >> 5)) + if (diff > (out_freq >> PMC_PLL_SHIFT_TOL)) goto fail; return ret | ((mul - 1) << 16) | div; fail: ==== //depot/projects/arm/src/sys/arm/at91/at91_pmcreg.h#2 (text+ko) ==== @@ -96,4 +96,17 @@ #define PMC_IER_PCK2RDY (1UL << 10) /* Programmable Clock 2 Ready */ #define PMC_IER_PCK3RDY (1UL << 11) /* Programmable Clock 3 Ready */ +/* + * PLL input frequency spec sheet says it must be between 1MHz and 32MHz, + * but it works down as low as 100kHz, a frequency necessary for some + * output frequencies to work. + */ +#define PMC_PLL_MIN_IN_FREQ 100000 +#define PMC_PLL_MAX_IN_FREQ 32000000 + +#define PMC_PLL_MULT_MIN 2 +#define PMC_PLL_MULT_MAX 2048 + +#define PMC_PLL_SHIFT_TOL 5 /* Allow errors 1 part in 32 */ + #endif /* ARM_AT91_AT91_PMCREG_H */