platform/mihawk: add nvme devices slot table
diff mbox series

Message ID 1583396436-13899-1-git-send-email-joy_chu@wistron.com
State Under Review
Headers show
Series
  • platform/mihawk: add nvme devices slot table
Related show

Checks

Context Check Description
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot-dco success Signed-off-by present
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot fail Test snowpatch/job/snowpatch-skiboot on branch master
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (82aed17a5468aff6b600ee1694a10a60f942c018)

Commit Message

Joy Chu March 5, 2020, 8:20 a.m. UTC
Add nvme slot table for broadcom gen4 nvme hba card support.

Signed-off-by: Joy Chu <joy_chu@wistron.com>
---
 platforms/astbmc/mihawk.c | 92 ++++++++++++++++++++++++++++++++-------
 1 file changed, 76 insertions(+), 16 deletions(-)

Patch
diff mbox series

diff --git a/platforms/astbmc/mihawk.c b/platforms/astbmc/mihawk.c
index d33d16bb..a1a4385b 100644
--- a/platforms/astbmc/mihawk.c
+++ b/platforms/astbmc/mihawk.c
@@ -17,16 +17,52 @@ 
 
 #include "astbmc.h"
 
+#define OPAL_ID_SLOT2	0x01
+#define OPAL_ID_SLOT4	0x03
+#define OPAL_ID_SLOT7	0x31
+#define OPAL_ID_SLOT9	0x33
+
 /* nvme backplane slots */
-static const struct slot_table_entry hdd_bay_slots[] = {
-        SW_PLUGGABLE("hdd0", 0x0),
-        SW_PLUGGABLE("hdd1", 0x1),
-        SW_PLUGGABLE("hdd2", 0x2),
-        SW_PLUGGABLE("hdd3", 0x3),
-        SW_PLUGGABLE("hdd4", 0x4),
-        SW_PLUGGABLE("hdd5", 0x5),
-        SW_PLUGGABLE("hdd6", 0x6),
-        SW_PLUGGABLE("hdd7", 0x7),
+static const struct slot_table_entry hdd_bay_s2_slots[] = {
+        SW_PLUGGABLE("nvme13", 0x0),
+        SW_PLUGGABLE("nvme14", 0x1),
+        SW_PLUGGABLE("nvme15", 0x2),
+        SW_PLUGGABLE("nvme16", 0x3),
+
+        { .etype = st_end },
+};
+
+static const struct slot_table_entry hdd_bay_s4_slots[] = {
+        SW_PLUGGABLE("nvme17", 0x0),
+        SW_PLUGGABLE("nvme18", 0x1),
+        SW_PLUGGABLE("nvme19", 0x2),
+        SW_PLUGGABLE("nvme20", 0x3),
+        SW_PLUGGABLE("nvme21", 0x4),
+        SW_PLUGGABLE("nvme22", 0x5),
+        SW_PLUGGABLE("nvme23", 0x6),
+        SW_PLUGGABLE("nvme24", 0x7),
+
+        { .etype = st_end },
+};
+
+static const struct slot_table_entry hdd_bay_s7_slots[] = {
+        SW_PLUGGABLE("nvme9", 0x0),
+        SW_PLUGGABLE("nvme10", 0x1),
+        SW_PLUGGABLE("nvme11", 0x2),
+        SW_PLUGGABLE("nvme12", 0x3),
+
+        { .etype = st_end },
+};
+
+static const struct slot_table_entry hdd_bay_s9_slots[] = {
+        SW_PLUGGABLE("nvme1", 0x0),
+        SW_PLUGGABLE("nvme2", 0x1),
+        SW_PLUGGABLE("nvme3", 0x2),
+        SW_PLUGGABLE("nvme4", 0x3),
+        SW_PLUGGABLE("nvme5", 0x4),
+        SW_PLUGGABLE("nvme6", 0x5),
+        SW_PLUGGABLE("nvme7", 0x6),
+        SW_PLUGGABLE("nvme8", 0x7),
 
         { .etype = st_end },
 };
@@ -39,15 +75,39 @@  static void mihawk_get_slot_info(struct phb *phb, struct pci_device *pd)
 		return;
 
 	/*
-	 * If we find a 8533 switch then assume it's the HDD Rack. This might
-	 * break if we have another 8533 in the system for some reason. This is
-	 * a really dumb hack, but until we get query the BMC about wether we
-	 * have a HDD rack or not we don't have much of a choice.
+	 * If we find a 8533 or c012 switch then assume it's the NVMe Rack.
+	 * This might break if we have another switch with the same vdid in
+	 * the system for some reason. This is a really dumb hack, but until
+	 * we get query the BMC about wether we have a HDD rack or not we
+	 * don't have much of a choice.
 	 */
-	if (pd->dev_type == PCIE_TYPE_SWITCH_DNPORT && pd->vdid == 0x853311f8)
-		for (ent = hdd_bay_slots; ent->etype != st_end; ent++)
-			if (ent->location == (pd->bdfn & 0xff))
+	if (pd->dev_type == PCIE_TYPE_SWITCH_DNPORT) {
+		if (pd->vdid == 0x853311f8) { // for microsemi controller
+			for (ent=hdd_bay_s9_slots; ent->etype != st_end; ent++)
+				if (ent->location == (pd->bdfn & 0xff))
+					break;
+		} else if (pd->vdid == 0xc0121000) { // for broadcom nvme hba
+			switch (phb->opal_id) {
+			case OPAL_ID_SLOT2:
+				ent = hdd_bay_s2_slots;
+				break;
+			case OPAL_ID_SLOT4:
+				ent = hdd_bay_s4_slots;
+				break;
+			case OPAL_ID_SLOT7:
+				ent = hdd_bay_s7_slots;
 				break;
+			case OPAL_ID_SLOT9:
+			default:
+				ent = hdd_bay_s9_slots;
+				break;
+			}
+
+			for (ent; ent->etype != st_end; ent++)
+				if (ent->location == (pd->bdfn & 0xff))
+					break;
+		}
+	}
 
 	if (ent)
 		slot_table_add_slot_info(pd, ent);