aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Neuling <mikey@neuling.org>2017-09-12 14:56:16 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-09-12 23:04:07 -0500
commita321db713d059b2eb43118848ef7e9b2191fd0ff (patch)
tree40919e59c8ca44abbb012f2b6415d6e3b37b643e
parent906d25d864a1d72c948a475570c53ca88081afb3 (diff)
downloadskiboot-a321db713d059b2eb43118848ef7e9b2191fd0ff.zip
skiboot-a321db713d059b2eb43118848ef7e9b2191fd0ff.tar.gz
skiboot-a321db713d059b2eb43118848ef7e9b2191fd0ff.tar.bz2
phb4: Split phb4_get_link_state() into a new function
Split phb4_get_link_state() into a new function so that it can be reused to get info on the speed and width of the link. Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--hw/phb4.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/hw/phb4.c b/hw/phb4.c
index 39e1204..b8d8706 100644
--- a/hw/phb4.c
+++ b/hw/phb4.c
@@ -2201,17 +2201,21 @@ static int64_t phb4_get_presence_state(struct pci_slot *slot, uint8_t *val)
return OPAL_SUCCESS;
}
-static int64_t phb4_get_link_state(struct pci_slot *slot, uint8_t *val)
+static int64_t phb4_get_link_info(struct pci_slot *slot, uint8_t *speed,
+ uint8_t *width)
{
struct phb4 *p = phb_to_phb4(slot->phb);
uint64_t reg;
uint16_t state;
int64_t rc;
+ uint8_t s;
/* Link is up, let's find the actual speed */
reg = in_be64(p->regs + PHB_PCIE_DLP_TRAIN_CTL);
if (!(reg & PHB_PCIE_DLP_TL_LINKACT)) {
- *val = 0;
+ *width = 0;
+ if (speed)
+ *speed = 0;
return OPAL_SUCCESS;
}
@@ -2222,14 +2226,25 @@ static int64_t phb4_get_link_state(struct pci_slot *slot, uint8_t *val)
return OPAL_HARDWARE;
}
- if (state & PCICAP_EXP_LSTAT_DLLL_ACT)
- *val = ((state & PCICAP_EXP_LSTAT_WIDTH) >> 4);
- else
- *val = 0;
+ if (state & PCICAP_EXP_LSTAT_DLLL_ACT) {
+ *width = ((state & PCICAP_EXP_LSTAT_WIDTH) >> 4);
+ s = state & PCICAP_EXP_LSTAT_SPEED;
+ } else {
+ *width = 0;
+ s = 0;
+ }
+
+ if (speed)
+ *speed = s;
return OPAL_SUCCESS;
}
+static int64_t phb4_get_link_state(struct pci_slot *slot, uint8_t *val)
+{
+ return phb4_get_link_info(slot, NULL, val);
+}
+
static int64_t phb4_retry_state(struct pci_slot *slot)
{
struct phb4 *p = phb_to_phb4(slot->phb);