Date: Sun, 19 Feb 2006 07:46:43 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 92030 for review Message-ID: <200602190746.k1J7kh6U008973@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200602190746.k1J7kh6U008973>