
Date: Fri, 16 Mar 2012 18:19:13 +0900
Subject: [PATCH 4/5] ppc32: add E500 processor probe function

Current support is ppce500mc platform of Freescale BOOKE.
Wrote both PTE32and PTE64 according by kernel powerpc pgtable header.
 #elif defined(CONFIG_FSL_BOOKE) && defined(CONFIG_PTE_64BIT)
 #include <asm/pte-book3e.h>
 #elif defined(CONFIG_FSL_BOOKE)
 #include <asm/pte-fsl-booke.h>

Signed-off-by: Toshikazu Nakayama <nakayama.ts@ncos.nec.co.jp>
---
 defs.h |   33 +++++++++++++++++++++++++++++++++
 ppc.c  |   40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/defs.h b/defs.h
index 9bb2d84..2c8fae1 100755
--- a/defs.h
+++ b/defs.h
@@ -2674,6 +2674,9 @@ struct machine_specific {
 #define PTRS_PER_PGD		(1 << (32 - PGDIR_SHIFT))
 #define PTRS_PER_PTE		(1 << PTE_SHIFT)
 
+/* PFN shifts */
+#define BOOKE3E_PTE_RPN_SHIFT	(24)
+
 /* PAGE flags */
 #define _PAGE_PRESENT   (machdep->machspec->_page_present)	/* software: pte contains a translation */
 #define _PAGE_USER      (machdep->machspec->_page_user)		/* matches one of the PP bits */
@@ -2713,6 +2716,36 @@ struct machine_specific {
 #define PPC44x_PAGE_HWWRITE	0
 #define PPC44x_PAGE_SHARED	0
 
+/* BOOK3E */
+#define BOOK3E_PAGE_PRESENT	0x000001
+#define BOOK3E_PAGE_BAP_SR	0x000004
+#define BOOK3E_PAGE_BAP_UR	0x000008 /* User Readable */
+#define BOOK3E_PAGE_BAP_SW	0x000010
+#define BOOK3E_PAGE_BAP_UW	0x000020 /* User Writable */
+#define BOOK3E_PAGE_USER	BOOK3E_PAGE_BAP_SR | BOOK3E_PAGE_BAP_UR
+#define BOOK3E_PAGE_RW		BOOK3E_PAGE_BAP_SW | BOOK3E_PAGE_BAP_UW
+#define BOOK3E_PAGE_DIRTY	0x001000
+#define BOOK3E_PAGE_ACCESSED	0x040000
+#define BOOK3E_PAGE_GUARDED	0x100000
+#define BOOK3E_PAGE_COHERENT	0x200000
+#define BOOK3E_PAGE_NO_CACHE	0x400000
+#define BOOK3E_PAGE_WRITETHRU	0x800000
+#define BOOK3E_PAGE_HWWRITE	0
+#define BOOK3E_PAGE_SHARED	0
+
+/* FSL BOOKE */
+#define FSL_BOOKE_PAGE_PRESENT	0x00001
+#define FSL_BOOKE_PAGE_USER	0x00002
+#define FSL_BOOKE_PAGE_RW	0x00004
+#define FSL_BOOKE_PAGE_DIRTY	0x00008
+#define FSL_BOOKE_PAGE_ACCESSED	0x00020
+#define FSL_BOOKE_PAGE_GUARDED	0x00080
+#define FSL_BOOKE_PAGE_COHERENT	0x00100
+#define FSL_BOOKE_PAGE_NO_CACHE	0x00200
+#define FSL_BOOKE_PAGE_WRITETHRU	0x00400
+#define FSL_BOOKE_PAGE_HWWRITE	0
+#define FSL_BOOKE_PAGE_SHARED	0
+
 #define SWP_TYPE(entry) (((entry) >> 1) & 0x7f)
 #define SWP_OFFSET(entry) ((entry) >> 8)
 #define __swp_type(entry)   SWP_TYPE(entry)
diff --git a/ppc.c b/ppc.c
index 4bff189..d74957f 100755
--- a/ppc.c
+++ b/ppc.c
@@ -74,12 +74,14 @@ static struct line_number_hook ppc_line_number_hooks[];
 static struct machine_specific ppc_machine_specific = { 0 };
 static int probe_default_platform(char *);
 static int probe_ppc44x_platform(char *);
+static int probe_ppce500_platform(char *);
 static void ppc_probe_base_platform(void);
 
 typedef int (*probe_func_t) (char *);
 
 probe_func_t probe_platforms[] = {
 	probe_ppc44x_platform,	/* 44x chipsets */
+	probe_ppce500_platform, /* E500 chipsets */
 	probe_default_platform, /* This should be at the end */
 	NULL
 };
@@ -113,6 +115,44 @@ probe_ppc44x_platform(char *name)
 }
 
 static int
+probe_ppce500_platform(char *name)
+{
+	struct machine_specific *machspec = machdep->machspec;
+
+	if (STRNEQ(name, "ppce500mc")) {
+		machspec->platform = strdup(name);
+		if (machdep->flags & PAE) {
+			machspec->pte_rpn_shift = BOOKE3E_PTE_RPN_SHIFT;
+
+			machspec->_page_present = BOOK3E_PAGE_PRESENT;
+			machspec->_page_user = BOOK3E_PAGE_USER;
+			machspec->_page_rw = BOOK3E_PAGE_RW;
+			machspec->_page_dirty = BOOK3E_PAGE_DIRTY;
+			machspec->_page_accessed = BOOK3E_PAGE_ACCESSED;
+			machspec->_page_guarded = BOOK3E_PAGE_GUARDED;
+			machspec->_page_coherent = BOOK3E_PAGE_COHERENT;
+			machspec->_page_no_cache = BOOK3E_PAGE_NO_CACHE;
+			machspec->_page_writethru = BOOK3E_PAGE_WRITETHRU;
+		} else {
+			machspec->_page_present = FSL_BOOKE_PAGE_PRESENT;
+			machspec->_page_user = FSL_BOOKE_PAGE_USER;
+			machspec->_page_rw = FSL_BOOKE_PAGE_RW;
+			machspec->_page_dirty = FSL_BOOKE_PAGE_DIRTY;
+			machspec->_page_accessed = FSL_BOOKE_PAGE_ACCESSED;
+			machspec->_page_guarded = FSL_BOOKE_PAGE_GUARDED;
+			machspec->_page_coherent = FSL_BOOKE_PAGE_COHERENT;
+			machspec->_page_no_cache = FSL_BOOKE_PAGE_NO_CACHE;
+			machspec->_page_writethru = FSL_BOOKE_PAGE_WRITETHRU;
+		}
+		machspec->_page_hwwrite = 0;
+		machspec->_page_shared = 0;
+
+		return TRUE;
+	}
+	return FALSE;
+}
+
+static int
 probe_default_platform(char *name)
 {
 	struct machine_specific *machspec = machdep->machspec;
-- 
1.7.0.4


