PERFORCE change 92030 for review

Warner Losh imp at FreeBSD.org
Sat Feb 18 23:46:49 PST 2006


http://perforce.freebsd.org/chv.cgi?CH=92030

Change 92030 by imp at 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 */


More information about the p4-projects mailing list