[Skiboot] [RFC PATCH 10/23] platform/firenze-pci: Convert to new power control API

Oliver O'Halloran oohall at gmail.com
Wed Apr 3 20:09:07 AEDT 2019


Convert firenze-pci slot control methods to use the new wait API.

Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 platforms/ibm-fsp/firenze-pci.c | 46 ++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 24 deletions(-)

diff --git a/platforms/ibm-fsp/firenze-pci.c b/platforms/ibm-fsp/firenze-pci.c
index 0ed53301485e..36414425e80d 100644
--- a/platforms/ibm-fsp/firenze-pci.c
+++ b/platforms/ibm-fsp/firenze-pci.c
@@ -363,18 +363,6 @@ bail:
 static int64_t __unused firenze_pci_slot_get_power_state(struct pci_slot *slot,
 						uint8_t *val)
 {
-	if (slot->state != FIRENZE_PCI_SLOT_NORMAL)
-	{
-		/**
-		 * @fwts-label FirenzePCISlotGPowerState
-		 * @fwts-advice Unexpected state in the FIRENZE PCI Slot
-		 * state machine. This could mean PCI is not functioning
-		 * correctly.
-		 */
-		prlog(PR_ERR, "%016llx GPOWER: Unexpected state %08x\n",
-		      slot->id, slot->state);
-	}
-
 	*val = slot->power_state;
 	return OPAL_SUCCESS;
 }
@@ -385,18 +373,27 @@ static int64_t __unused firenze_pci_slot_set_power_state(struct pci_slot *slot,
 	struct firenze_pci_slot *plat_slot = slot->data;
 	uint8_t *pval;
 
-	if (slot->state != FIRENZE_PCI_SLOT_NORMAL)
-	{
-		/**
-		 * @fwts-label FirenzePCISlotSPowerState
-		 * @fwts-advice Unexpected state in the FIRENZE PCI Slot
-		 * state machine. This could mean PCI is not functioning
-		 * correctly.
-		 */
-		prlog(PR_ERR, "%016llx SPOWER: Unexpected state %08x\n",
-		      slot->id, slot->state);
+	/* check if we have an in-progress i2c operation happening */
+	if (slot->power_ctl_state) {
+		struct i2c_request *req = plat_slot->req;
+
+		prerror("request state: %d\n", req->req_state);
+
+		switch (req->req_state) {
+		case i2c_req_done:
+			req->req_state = i2c_req_new;
+			slot->power_ctl_state = 0;
+			printf("req result: %d\n", req->result);
+			return req->result;
+		case i2c_req_queued:
+			return 10; // FIXME: Do proper timeout handling, christ
+		case i2c_req_new:
+			prerror("u wot m8?\n");
+		}
 	}
 
+	// otherwise, queue the i2c request to change the power state
+
 	if (val != PCI_SLOT_POWER_OFF && val != PCI_SLOT_POWER_ON)
 		return OPAL_PARAMETER;
 
@@ -416,7 +413,6 @@ static int64_t __unused firenze_pci_slot_set_power_state(struct pci_slot *slot,
 	}
 
 	slot->power_state = val;
-	pci_slot_set_state(slot, FIRENZE_PCI_SLOT_SPOWER_START);
 
 	plat_slot->req->op = SMBUS_WRITE;
 	pval = (uint8_t *)plat_slot->req->rw_buf;
@@ -436,7 +432,9 @@ static int64_t __unused firenze_pci_slot_set_power_state(struct pci_slot *slot,
 		plat_slot->req->timeout = 0ul;
 	i2c_queue_req(plat_slot->req);
 
-	return OPAL_ASYNC_COMPLETION;
+	slot->power_ctl_state = 1;
+
+	return 10;
 }
 
 static struct i2c_bus *firenze_pci_find_i2c_bus(uint8_t chip,
-- 
2.20.1



More information about the Skiboot mailing list