Skip to contentSkip to conversation

Common code for detecting new mpc8xx core.

PATCH New David Ho 3 participants 3 messages Mar 30, 2006 – Apr 4, 2006

lore
Share & tools
lore

David Ho

author
#0 lore raw

PATCH 1/1 Common code for detecting new mpc8xx core.

This refines the routine for detecting new mpc8xx core.

This does however add a few bytes to the initial stack usage (Implemented as a function).

---

 cpu/mpc8xx/cpu.c      |   11 ++++++++++-
 cpu/mpc8xx/cpu_init.c |    2 +-
 include/common.h      |    3 +++
 include/mpc8xx.h      |    7 ++++---
 4 files changed, 18 insertions(+), 5 deletions(-)

f04a287d9a8f2e26d0b08f69e0f4884c8b382b6b

cpu/mpc8xx/cpu.c +10 -1
index 4a32986..2098256 100644
@@ -357,6 +357,15 @@ int checkcpu (void)
 	return check_CPU (clock, pvr, immr);
 }
 
+int mpc8xx_new_core (void)
+{
+        uint partnum = get_immr (PARTNUM_MASK);
+
+        return ((partnum == MPC866_FAMILY_PARTNUM) ||
+                (partnum == MPC885_FAMILY_PARTNUM)
+                );
+}
+
 /* ------------------------------------------------------------------------- */
 /* L1 i-cache                                                                */
 /* the standard 860 has 128 sets of 16 bytes in 2 ways (= 4 kB)              */
@@ -560,7 +569,7 @@ unsigned long get_tbclk (void)
 	 *
 	 * For older chips, it's just MF field of PLPRCR plus one.
 	 */
-	if ((immr & 0x0FFF) >= MPC8xx_NEW_CLK) { /* MPC866/87x/88x series */
+	if (mpc8xx_new_core()) { /* MPC866/87x/88x series */
 		factor = (PLPRCR_val(MFI) + PLPRCR_val(MFN)/(PLPRCR_val(MFD)+1))/
 			(PLPRCR_val(PDF)+1) / (1<<PLPRCR_val(S));
 	} else {
cpu/mpc8xx/cpu_init.c +1 -1
index b2c59c6..5cff8a6 100644
@@ -95,7 +95,7 @@ void cpu_init_f (volatile immap_t * immr
 	 * For newer (starting MPC866) chips PLPRCR layout is different.
 	 */
 #ifdef CFG_PLPRCR
-	if (get_immr(0xFFFF) >= MPC8xx_NEW_CLK)
+	if (mpc8xx_new_core())
 	   mfmask = PLPRCR_MFACT_MSK;
 	else
 	   mfmask = PLPRCR_MF_MSK;
include/common.h +3 -0
index d2570a8..00632e2 100644
@@ -389,6 +389,9 @@ int	checkdcache   (void);
 void	upmconfig     (unsigned int, unsigned int *, unsigned int);
 ulong	get_tbclk     (void);
 void	reset_cpu     (ulong addr);
+#if defined(CONFIG_8xx)
+int     mpc8xx_new_core (void);
+#endif
 
 /* $(CPU)/serial.c */
 int	serial_init   (void);
include/mpc8xx.h +4 -3
index 2911758..2cff376 100644
@@ -132,10 +132,11 @@
 #define RSR_ALLBITS	(RSR_JTRS|RSR_DBSRS|RSR_DBHRS|RSR_CSRS|RSR_SWRS|RSR_LLRS|RSR_ESRS|RSR_EHRS)
 
 /*-----------------------------------------------------------------------
- * Newer chips (MPC866 family and MPC87x/88x family) have different
- * clock distribution system. Their IMMR lower half is >= 0x0800
+ * Newer chips (MPC866 family and MPC87x/88x family)
  */
-#define MPC8xx_NEW_CLK 0x0800
+#define PARTNUM_MASK		0xFF00
+#define MPC866_FAMILY_PARTNUM	0x0800
+#define MPC885_FAMILY_PARTNUM	0x0900
 
 /*-----------------------------------------------------------------------
  * PLPRCR - PLL, Low-Power, and Reset Control Register			15-30
Signature · 1 line
1.2.4.g79f5-dirty
#1 lore raw

PATCH 1/1 Common code for detecting new mpc8xx core.

Quoted 4 lines · In message <[email protected]> you wrote:

This refines the routine for detecting new mpc8xx core.

This does however add a few bytes to the initial stack usage (Implemented as a function).

Is there any actual problem this patch is supposed to fix, or is it just implemented in a different style?

I don't see any immediate reason why I should like your code better than the existing one.

Also, you patch violates the Coding Style requirements (which, for example, requies to use TABs for indentation).

Best regards,

Wolfgang Denk

Signature · 4 lines
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Plan to throw one away.  You will anyway."
                              - Fred Brooks, "The Mythical Man Month"
#2 lore raw

PATCH 1/1 Common code for detecting new mpc8xx core.

Quoted 8 lines · Wolfgang Denk
Quoted 4 lines · In message <[email protected]> you wrote:

This refines the routine for detecting new mpc8xx core.

This does however add a few bytes to the initial stack usage (Implemented as a function).

Is there any actual problem this patch is supposed to fix, or is it just implemented in a different style?

The problem is that the current code makes (possibly incorrect) assumptions about how Motorola/Freescale uses of the PARTNUM field in the IMMR and is inconsistent as to how it checks it. There's a comment in include/mpc8xx.h
/*-----------------------------------------------------------------------
* Newer chips (MPC866 family and MPC87x/88x family) have different
* clock distribution system. Their IMMR lower half is >= 0x0800 */
Unfortunately some older parts without the newer clock distribution system also have a value >= 0x0800.
e.g. The MPC823 has 0x2001 or 0x2000

Someone must have noticed a problem because cpu/mpc8xx/cpu.c was updated to only look at the 12 low bits, however the corresponding code in cpu/mpc8xx/cpu_init.c was not updated

Quoted 2 lines

I don't see any immediate reason why I should like your code better than the existing one.

Someone might ask the same question as to why it was changed in the first place in commit 180d3f74e4738ee107e269cbb949481075dd789a (There's no mention in the changelog)
At first glance, the original code using preprocessor #if defined checks even seems more efficient.

Quoted 2 lines

Also, you patch violates the Coding Style requirements (which, for example, requies to use TABs for indentation).

--
Chris