[Skiboot] [PATCH v9 17/22] hw/npu: Support PHB slot

Gavin Shan gwshan at linux.vnet.ibm.com
Thu Nov 12 13:33:24 AEDT 2015


This creates PCI slot before the PHB is registered. Nothing has
been done in the PCI slot operations except to keep the PCI probe
going.

Signed-off-by: Gavin Shan <gwshan at linux.vnet.ibm.com>
---
 hw/npu.c | 57 +++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 43 insertions(+), 14 deletions(-)

diff --git a/hw/npu.c b/hw/npu.c
index 9c8d73d..c28721c 100644
--- a/hw/npu.c
+++ b/hw/npu.c
@@ -18,6 +18,7 @@
 #include <timebase.h>
 #include <pci.h>
 #include <pci-cfg.h>
+#include <pci-slot.h>
 #include <interrupts.h>
 #include <opal.h>
 #include <opal-api.h>
@@ -962,20 +963,24 @@ static int64_t npu_set_pe(struct phb *phb,
 	return OPAL_SUCCESS;
 }
 
-static int64_t npu_link_state(struct phb *phb __unused)
+static int64_t npu_get_link_state(struct pci_slot *slot __unused,
+				  uint8_t *val)
 {
 	/* As we're emulating all PCI stuff, the link bandwidth
 	 * isn't big deal anyway.
 	 */
-	return OPAL_SHPC_LINK_UP_x1;
+	*val = OPAL_SHPC_LINK_UP_x1;
+	return OPAL_SUCCESS;
 }
 
-static int64_t npu_power_state(struct phb *phb __unused)
+static int64_t npu_get_power_state(struct pci_slot *slot __unused,
+				   uint8_t *val)
 {
-	return OPAL_SHPC_POWER_ON;
+	*val = OPAL_SHPC_POWER_ON;
+	return OPAL_SUCCESS;
 }
 
-static int64_t npu_freset(struct phb *phb __unused)
+static int64_t npu_freset(struct pci_slot *slot __unused)
 {
 	/* FIXME: PHB fundamental reset, which need to be
 	 * figured out later. It's used by EEH recovery
@@ -984,6 +989,33 @@ static int64_t npu_freset(struct phb *phb __unused)
 	return OPAL_SUCCESS;
 }
 
+static struct pci_slot *npu_slot_create(struct phb *phb)
+{
+	struct pci_slot *slot;
+
+	slot = pci_slot_alloc(phb, NULL);
+	if (!slot)
+		return slot;
+
+	/* Elementary functions */
+	slot->ops.get_presence_status  = NULL;
+	slot->ops.get_link_status      = npu_get_link_state;
+	slot->ops.get_power_status     = npu_get_power_state;
+	slot->ops.get_attention_status = NULL;
+	slot->ops.get_latch_status     = NULL;
+	slot->ops.set_power_status     = NULL;
+	slot->ops.set_attention_status = NULL;
+
+	slot->ops.prepare_link_change  = NULL;
+	slot->ops.poll_link            = NULL;
+	slot->ops.hreset               = NULL;
+	slot->ops.freset               = npu_freset;
+	slot->ops.pfreset              = NULL;
+	slot->ops.creset               = NULL;
+
+	return slot;
+}
+
 static int64_t npu_freeze_status(struct phb *phb __unused,
 				     uint64_t pe_number __unused,
 				     uint8_t *freeze_state,
@@ -1012,7 +1044,6 @@ static const struct phb_ops npu_ops = {
 	.choose_bus		= NULL,
 	.device_init		= NULL,
 	.device_node_fixup	= npu_dn_fixup,
-	.presence_detect	= NULL,
 	.ioda_reset		= npu_ioda_reset,
 	.papr_errinjct_reset	= NULL,
 	.pci_reinit		= NULL,
@@ -1027,14 +1058,6 @@ static const struct phb_ops npu_ops = {
 	.get_msi_64		= NULL,
 	.set_pe			= npu_set_pe,
 	.set_peltv		= NULL,
-	.link_state		= npu_link_state,
-	.power_state		= npu_power_state,
-	.slot_power_off		= NULL,
-	.slot_power_on		= NULL,
-	.hot_reset		= NULL,
-	.fundamental_reset	= npu_freset,
-	.complete_reset		= NULL,
-	.poll			= NULL,
 	.eeh_freeze_status	= npu_freeze_status,
 	.eeh_freeze_clear	= NULL,
 	.eeh_freeze_set		= NULL,
@@ -1650,6 +1673,7 @@ static void npu_create_phb(struct dt_node *dn)
 {
 	const struct dt_property *prop;
 	struct npu *p;
+	struct pci_slot *slot;
 	uint32_t links;
 	void *pmem;
 
@@ -1691,6 +1715,11 @@ static void npu_create_phb(struct dt_node *dn)
 	/* Populate extra properties */
 	npu_add_phb_properties(p);
 
+	/* Create PHB slot */
+	slot = npu_slot_create(&p->phb);
+	if (!slot)
+		return;
+
 	/* Register PHB */
 	pci_register_phb(&p->phb, -1);
 
-- 
2.1.0



More information about the Skiboot mailing list