[Skiboot] [RFC PATCH 13/23] hw/phb3: Add phb3_assert_perst()
Oliver O'Halloran
oohall at gmail.com
Wed Apr 3 20:09:10 AEDT 2019
Wire it up.
Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
hw/phb3.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/hw/phb3.c b/hw/phb3.c
index ee98fd51dd79..095fc3153378 100644
--- a/hw/phb3.c
+++ b/hw/phb3.c
@@ -2399,11 +2399,29 @@ static int64_t phb3_hreset(struct pci_slot *slot)
return OPAL_HARDWARE;
}
+static int64_t phb3_assert_perst(struct pci_slot *slot, bool assert)
+{
+ struct phb3 *p = phb_to_phb3(slot->phb);
+ uint64_t reg;
+
+ /*
+ * PPCBIT(2) of PHB_RESET drives PERST directly so we *clear*
+ * it to assert PERST.
+ */
+ reg = in_be64(p->regs + PHB_RESET);
+ if (assert)
+ reg &= ~0x2000000000000000ul;
+ else
+ reg |= 0x2000000000000000ul;
+ out_be64(p->regs + PHB_RESET, reg);
+
+ return OPAL_SUCCESS;
+}
+
static int64_t phb3_freset(struct pci_slot *slot)
{
struct phb3 *p = phb_to_phb3(slot->phb);
uint8_t presence = 1;
- uint64_t reg;
switch(slot->state) {
case PHB3_SLOT_NORMAL:
@@ -2425,9 +2443,7 @@ static int64_t phb3_freset(struct pci_slot *slot)
case PHB3_SLOT_FRESET_START:
if (!p->skip_perst) {
PHBDBG(p, "FRESET: Assert\n");
- reg = in_be64(p->regs + PHB_RESET);
- reg &= ~0x2000000000000000ul;
- out_be64(p->regs + PHB_RESET, reg);
+ phb3_assert_perst(slot, true);
pci_slot_set_state(slot,
PHB3_SLOT_FRESET_ASSERT_DELAY);
return pci_slot_set_sm_timeout(slot, secs_to_tb(1));
@@ -2440,9 +2456,7 @@ static int64_t phb3_freset(struct pci_slot *slot)
/* fall through */
case PHB3_SLOT_FRESET_ASSERT_DELAY:
PHBDBG(p, "FRESET: Deassert\n");
- reg = in_be64(p->regs + PHB_RESET);
- reg |= 0x2000000000000000ul;
- out_be64(p->regs + PHB_RESET, reg);
+ phb3_assert_perst(slot, false);
pci_slot_set_state(slot,
PHB3_SLOT_FRESET_DEASSERT_DELAY);
--
2.20.1
More information about the Skiboot
mailing list