diff mbox series

[01/12] libpdbg: Enable p10 host backend

Message ID 20210802054112.461728-2-jniethe5@gmail.com
State Superseded
Headers show
Series P10 HTM Support | expand

Commit Message

Jordan Niethe Aug. 2, 2021, 5:41 a.m. UTC
Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
---
 Makefile.am     |  2 +-
 libpdbg/dtb.c   | 16 +++++++++++++++-
 p10-host.dts.m4 | 25 +++++++++++++++++++++++++
 src/main.c      |  7 +++++++
 4 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 p10-host.dts.m4
diff mbox series

Patch

diff --git a/Makefile.am b/Makefile.am
index 5ae4cba00848..fafc43eaa47e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -63,7 +63,7 @@  DT = fake.dts fake-backend.dts fake2.dts fake2-backend.dts \
      p8-fsi.dts p8-i2c.dts p8-kernel.dts \
      p9w-fsi.dts p9r-fsi.dts p9z-fsi.dts bmc-kernel.dts \
      bmc-sbefifo.dts \
-     p8-host.dts p9-host.dts p8.dts p9.dts p10.dts
+     p8-host.dts p9-host.dts p10-host.dts p8.dts p9.dts p10.dts
 
 DT_sources = $(DT:.dts=.dtb.S)
 DT_headers = $(DT:.dts=.dt.h)
diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c
index 1ab6791ce13b..331bd2cabbb2 100644
--- a/libpdbg/dtb.c
+++ b/libpdbg/dtb.c
@@ -42,6 +42,7 @@ 
 #include "bmc-kernel.dt.h"
 #include "p8-host.dt.h"
 #include "p9-host.dt.h"
+#include "p10-host.dt.h"
 #include "p8-cronus.dt.h"
 #include "cronus.dt.h"
 #include "bmc-sbefifo.dt.h"
@@ -170,9 +171,15 @@  static void ppc_target(struct pdbg_dtb *dtb)
 				dtb->backend.fdt = &_binary_p9_host_dtb_o_start;
 			if (!dtb->system.fdt)
 				dtb->system.fdt = &_binary_p9_dtb_o_start;
+		} else if (!strcmp(pdbg_backend_option, "p10")) {
+			pdbg_proc = PDBG_PROC_P10;
+			if (!dtb->backend.fdt)
+				dtb->backend.fdt = &_binary_p10_host_dtb_o_start;
+			if (!dtb->system.fdt)
+				dtb->system.fdt = &_binary_p10_dtb_o_start;
 		} else {
 			pdbg_log(PDBG_ERROR, "Invalid system type %s\n", pdbg_backend_option);
-			pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9'\n");
+			pdbg_log(PDBG_ERROR, "Use 'p8' or 'p9' or 'p10'\n");
 		}
 
  		return;
@@ -215,6 +222,13 @@  static void ppc_target(struct pdbg_dtb *dtb)
 			dtb->backend.fdt = &_binary_p9_host_dtb_o_start;
 		if (!dtb->system.fdt)
 			dtb->system.fdt = &_binary_p9_dtb_o_start;
+	} else if (strncmp(pos, "POWER10", 7) == 0) {
+		pdbg_proc = PDBG_PROC_P10;
+		pdbg_log(PDBG_INFO, "Found a POWER10 PPC host system\n");
+		if (!dtb->backend.fdt)
+			dtb->backend.fdt = &_binary_p10_host_dtb_o_start;
+		if (!dtb->system.fdt)
+			dtb->system.fdt = &_binary_p10_dtb_o_start;
 	} else {
 		pdbg_log(PDBG_ERROR, "Unsupported CPU type '%s'\n", pos);
  	}
diff --git a/p10-host.dts.m4 b/p10-host.dts.m4
new file mode 100644
index 000000000000..3b4c2b267e1b
--- /dev/null
+++ b/p10-host.dts.m4
@@ -0,0 +1,25 @@ 
+/dts-v1/;
+
+/ {
+	#address-cells = <0x1>;
+	#size-cells = <0x0>;
+
+	/* Host based debugfs access */
+	pib@0 {
+	      #address-cells = <0x2>;
+	      #size-cells = <0x1>;
+	      compatible = "ibm,host-pib";
+	      reg = <0x0>;
+	      index = <0x0>;
+	      system-path = "/proc0/pib";
+	};
+
+	pib@8 {
+	      #address-cells = <0x2>;
+	      #size-cells = <0x1>;
+	      compatible = "ibm,host-pib";
+	      reg = <0x8>;
+	      index = <0x8>;
+	      system-path = "/proc1/pib";
+	};
+};
diff --git a/src/main.c b/src/main.c
index 1ecf3daf253a..5d16a7dbac18 100644
--- a/src/main.c
+++ b/src/main.c
@@ -195,6 +195,9 @@  out2:
 }
 
 /* Stolen from skiboot */
+#define P10_PIR2GCID(pir) (((pir) >> 8) & 0xf)
+#define P10_PIR2COREID(pir) (((pir) >> 2) & 0x3f)
+#define P10_PIR2THREADID(pir) ((pir) & 0x3)
 #define P9_PIR2GCID(pir) (((pir) >> 8) & 0x7f)
 #define P9_PIR2COREID(pir) (((pir) >> 2) & 0x3f)
 #define P9_PIR2THREADID(pir) ((pir) & 0x3)
@@ -214,6 +217,10 @@  void pir_map(int pir, int *chip, int *core, int *thread)
 		*chip = P8_PIR2GCID(pir);
 		*core = P8_PIR2COREID(pir);
 		*thread = P8_PIR2THREADID(pir);
+	} else if (!strncmp(device_node, "p10", 2)) {
+		*chip = P10_PIR2GCID(pir);
+		*core = P10_PIR2COREID(pir);
+		*thread = P10_PIR2THREADID(pir);
 	} else
 		assert(0);