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

Suraj Jitindar Singh sjitindarsingh at gmail.com
Mon Jul 18 15:26:13 AEST 2016


The power_ctl bit is used to represent if power management is available.
Use this bit when determining the slot reset method. If it is set then
we see if we can use fundamental reset, otherwise we try to use hot
reset.

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