[PATCH rtems-libbsd 08/14] mpc85xx: Support P20XX Local Access Window regs

Christian Mauderer christian.mauderer at embedded-brains.de
Tue Jan 23 09:09:09 UTC 2024


From: Sebastian Huber <sebastian.huber at embedded-brains.de>

---
 freebsd/sys/powerpc/mpc85xx/mpc85xx.c | 38 +++++++++++++++++++++++++++
 freebsd/sys/powerpc/mpc85xx/mpc85xx.h |  2 ++
 2 files changed, 40 insertions(+)

diff --git a/freebsd/sys/powerpc/mpc85xx/mpc85xx.c b/freebsd/sys/powerpc/mpc85xx/mpc85xx.c
index ec7eaa3f..7f3df540 100644
--- a/freebsd/sys/powerpc/mpc85xx/mpc85xx.c
+++ b/freebsd/sys/powerpc/mpc85xx/mpc85xx.c
@@ -82,6 +82,29 @@ ccsr_write4(uintptr_t addr, uint32_t val)
 	powerpc_iomb();
 }
 
+static int
+mpc85xx_is_p20xx(void)
+{
+	uint32_t ver;
+	int is_p20xx;
+
+	ver = SVR_VER(mfspr(SPR_SVR));
+	switch (ver) {
+	case SVR_P2010:
+	case SVR_P2010E:
+	case SVR_P2020:
+	case SVR_P2020E:
+	case SVR_P2041:
+	case SVR_P2041E:
+		is_p20xx = 1;
+		break;
+	default:
+		is_p20xx = 0;
+	}
+
+	return (is_p20xx);
+}
+
 int
 law_getmax(void)
 {
@@ -100,6 +123,14 @@ law_getmax(void)
 	case SVR_MPC8548E:
 		law_max = 10;
 		break;
+	case SVR_P2010:
+	case SVR_P2010E:
+	case SVR_P2020:
+	case SVR_P2020E:
+	case SVR_P2041:
+	case SVR_P2041E:
+		law_max = 12;
+		break;
 	case SVR_P5020:
 	case SVR_P5020E:
 	case SVR_P5021:
@@ -124,6 +155,10 @@ law_write(uint32_t n, uint64_t bar, uint32_t sr)
 		ccsr_write4(OCP85XX_LAWBARL(n), bar);
 		ccsr_write4(OCP85XX_LAWSR_QORIQ(n), sr);
 		ccsr_read4(OCP85XX_LAWSR_QORIQ(n));
+	} else if (mpc85xx_is_p20xx()) {
+		ccsr_write4(OCP85XX_LAWBAR_P20XX(n), bar >> 12);
+		ccsr_write4(OCP85XX_LAWAR(n), sr);
+		ccsr_read4(OCP85XX_LAWAR(n));
 	} else {
 		ccsr_write4(OCP85XX_LAWBAR(n), bar >> 12);
 		ccsr_write4(OCP85XX_LAWSR_85XX(n), sr);
@@ -148,6 +183,9 @@ law_read(uint32_t n, uint64_t *bar, uint32_t *sr)
 		*bar = (uint64_t)ccsr_read4(OCP85XX_LAWBARH(n)) << 32 |
 		    ccsr_read4(OCP85XX_LAWBARL(n));
 		*sr = ccsr_read4(OCP85XX_LAWSR_QORIQ(n));
+	} else if (mpc85xx_is_p20xx()) {
+		*bar = (uint64_t)ccsr_read4(OCP85XX_LAWBAR_P20XX(n)) << 12;
+		*sr = ccsr_read4(OCP85XX_LAWAR(n));
 	} else {
 		*bar = (uint64_t)ccsr_read4(OCP85XX_LAWBAR(n)) << 12;
 		*sr = ccsr_read4(OCP85XX_LAWSR_85XX(n));
diff --git a/freebsd/sys/powerpc/mpc85xx/mpc85xx.h b/freebsd/sys/powerpc/mpc85xx/mpc85xx.h
index 1a0be6cb..0f1ee5cc 100644
--- a/freebsd/sys/powerpc/mpc85xx/mpc85xx.h
+++ b/freebsd/sys/powerpc/mpc85xx/mpc85xx.h
@@ -79,6 +79,8 @@ extern vm_size_t		ccsrbar_size;
 #define	OCP85XX_LAWSR_85XX(n)	(CCSRBAR_VA + 0xc10 + 0x10 * (n))
 #define	OCP85XX_LAWSR(n)	(mpc85xx_is_qoriq() ? OCP85XX_LAWSR_QORIQ(n) : \
 				 OCP85XX_LAWSR_85XX(n))
+#define	OCP85XX_LAWBAR_P20XX(n)	(CCSRBAR_VA + 0xc08 + 0x20 * (n))
+#define	OCP85XX_LAWAR(n)	(CCSRBAR_VA + 0xc10 + 0x20 * (n))
 
 /* Attribute register */
 #define	OCP85XX_ENA_MASK	0x80000000
-- 
2.35.3



More information about the devel mailing list