[Skiboot] [PATCH V2 2/2] platforms/ibm-fsp: Use power_ctl bit when determining slot reset method

Suraj Jitindar Singh sjitindarsingh at gmail.com
Tue Jul 19 11:18:26 AEST 2016


Previously the power_clt bit provided by the VPD was unused, now that we
are correctly assigning it we can use it when determining the slot reset
method.

The power_ctl bit is used to represent if power management is available.
If power_ctl is set to true, then the I2C based external power management
functionality will be populated on the PCI slot. Otherwise we will try to
use the inband PERST as the fundamental reset, as before.

While we are here we introduce a helper function to isolate the logic
initialisation for the I2C based external power management, to improve
readibility.

Signed-off-by: Suraj Jitindar Singh <sjitindarsingh at gmail.com>
Acked-by: Gavin Shan <gwshan at linux.vnet.ibm.com>

---

Change Log:

V1 -> V2:
	- Rewrite commit message

---
 platforms/ibm-fsp/firenze-pci.c | 83 +++++++++++++++++++++++------------------
 1 file changed, 46 insertions(+), 37 deletions(-)

diff --git a/platforms/ibm-fsp/firenze-pci.c b/platforms/ibm-fsp/firenze-pci.c
index 4416f1f..5dfda86 100644
--- a/platforms/ibm-fsp/firenze-pci.c
+++ b/platforms/ibm-fsp/firenze-pci.c
@@ -742,13 +742,56 @@ static struct i2c_bus *firenze_pci_find_i2c_bus(uint8_t chip,
 	return NULL;
 }
 
+static void firenze_pci_setup_power_mgt(struct pci_slot *slot,
+					struct firenze_pci_slot *plat_slot,
+					struct firenze_pci_slot_info *info)
+{
+	uint8_t buddy;
+
+	buddy = info->buddy;
+	plat_slot->i2c_bus = firenze_pci_find_i2c_bus(info->chip_id,
+						      info->master_id,
+						      info->port_id);
+	if (!plat_slot->i2c_bus) {
+		prlog(PR_WARNING, "%s: No I2C bus found for %x-%x-%x\n",
+		      __func__, info->chip_id, info->master_id, info->port_id);
+		return;
+	}
+
+	plat_slot->req = i2c_alloc_req(plat_slot->i2c_bus);
+	if (!plat_slot->req) {
+		prlog(PR_ERR, "%s: Cannot alloc I2C req\n", __func__);
+		return;
+	}
+
+	plat_slot->req->dev_addr	= info->slave_addr;
+	plat_slot->req->offset_bytes	= 1;
+	plat_slot->req->offset		= 0x69;
+	plat_slot->req->rw_buf		= plat_slot->i2c_rw_buf;
+	plat_slot->req->rw_len		= 1;
+	plat_slot->req->completion	= firenze_i2c_req_done;
+	plat_slot->req->user_data	= slot;
+	switch (info->channel) {
+	case 0:
+		plat_slot->power_status = &firenze_pci_slots[buddy].power_status;
+		plat_slot->power_mask = 0x33;
+		plat_slot->power_on   = 0x22;
+		plat_slot->power_off  = 0x33;
+		break;
+	case 1:
+		plat_slot->power_status = &firenze_pci_slots[buddy].power_status;
+		plat_slot->power_mask = 0xcc;
+		plat_slot->power_on   = 0x88;
+		plat_slot->power_off  = 0xcc;
+	}
+}
+
 static void firenze_pci_slot_init(struct pci_slot *slot)
 {
 	struct lxvpd_pci_slot *s = slot->data;
 	struct firenze_pci_slot *plat_slot = slot->data;
 	struct firenze_pci_slot_info *info = NULL;
 	uint32_t vdid;
-	uint8_t buddy;
 	int i;
 
 	/* Search for PCI slot info */
@@ -763,42 +806,8 @@ static void firenze_pci_slot_init(struct pci_slot *slot)
 		return;
 
 	/* Search I2C bus for external power mgt */
-	buddy = info->buddy;
-	plat_slot->i2c_bus = firenze_pci_find_i2c_bus(info->chip_id,
-						      info->master_id,
-						      info->port_id);
-	if (plat_slot->i2c_bus)
-		plat_slot->req = i2c_alloc_req(plat_slot->i2c_bus);
-	else
-		plat_slot->req = NULL;
-
-	if (plat_slot->req) {
-		plat_slot->req->dev_addr	= info->slave_addr;
-		plat_slot->req->offset_bytes	= 1;
-		plat_slot->req->offset		= 0x69;
-		plat_slot->req->rw_buf		= plat_slot->i2c_rw_buf;
-		plat_slot->req->rw_len		= 1;
-		plat_slot->req->completion	= firenze_i2c_req_done;
-		plat_slot->req->user_data	= slot;
-		switch (info->channel) {
-		case 0:
-			plat_slot->power_status = &firenze_pci_slots[buddy].power_status;
-			plat_slot->power_mask = 0x33;
-			plat_slot->power_on   = 0x22;
-			plat_slot->power_off  = 0x33;
-			break;
-		case 1:
-			plat_slot->power_status = &firenze_pci_slots[buddy].power_status;
-			plat_slot->power_mask = 0xcc;
-			plat_slot->power_on   = 0x88;
-			plat_slot->power_off  = 0xcc;
-			break;
-		default:
-			prlog(PR_DEBUG, "%016llx: Invalid channel %d\n",
-			      slot->id, info->channel);
-			plat_slot->i2c_bus = NULL;
-		}
-	}
+	if (slot->power_ctl)
+		firenze_pci_setup_power_mgt(slot, plat_slot, info);
 
 	/*
 	 * If the slot has external power logic, to override the
-- 
2.5.5



More information about the Skiboot mailing list