From patchwork Thu Nov 12 02:33:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 543188 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C0F78141301 for ; Thu, 12 Nov 2015 13:36:10 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id A75181A0764 for ; Thu, 12 Nov 2015 13:36:10 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp03.au.ibm.com (e23smtp03.au.ibm.com [202.81.31.145]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id D42D51A0512 for ; Thu, 12 Nov 2015 13:35:18 +1100 (AEDT) Received: from localhost by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Nov 2015 12:35:18 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Nov 2015 12:35:17 +1000 X-IBM-Helo: d23dlp01.au.ibm.com X-IBM-MailFrom: gwshan@linux.vnet.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org Received: from d23relay09.au.ibm.com (d23relay09.au.ibm.com [9.185.63.181]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 3011D2CE8050 for ; Thu, 12 Nov 2015 13:35:17 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay09.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tAC2Z8mk59506890 for ; Thu, 12 Nov 2015 13:35:17 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tAC2YiWZ016796 for ; Thu, 12 Nov 2015 13:34:44 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tAC2YiLV016079; Thu, 12 Nov 2015 13:34:44 +1100 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id D3716A03F3; Thu, 12 Nov 2015 13:33:38 +1100 (AEDT) Received: from gwshan (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id C93FCE46AC; Thu, 12 Nov 2015 13:33:38 +1100 (AEDT) Received: by gwshan (Postfix, from userid 1000) id A386A94212B; Thu, 12 Nov 2015 13:33:38 +1100 (AEDT) From: Gavin Shan To: skiboot@lists.ozlabs.org Date: Thu, 12 Nov 2015 13:33:24 +1100 Message-Id: <1447295609-20446-18-git-send-email-gwshan@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1447295609-20446-1-git-send-email-gwshan@linux.vnet.ibm.com> References: <1447295609-20446-1-git-send-email-gwshan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15111202-0009-0000-0000-0000025B4877 Subject: [Skiboot] [PATCH v9 17/22] hw/npu: Support PHB slot X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This creates PCI slot before the PHB is registered. Nothing has been done in the PCI slot operations except to keep the PCI probe going. Signed-off-by: Gavin Shan --- hw/npu.c | 57 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/hw/npu.c b/hw/npu.c index 9c8d73d..c28721c 100644 --- a/hw/npu.c +++ b/hw/npu.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -962,20 +963,24 @@ static int64_t npu_set_pe(struct phb *phb, return OPAL_SUCCESS; } -static int64_t npu_link_state(struct phb *phb __unused) +static int64_t npu_get_link_state(struct pci_slot *slot __unused, + uint8_t *val) { /* As we're emulating all PCI stuff, the link bandwidth * isn't big deal anyway. */ - return OPAL_SHPC_LINK_UP_x1; + *val = OPAL_SHPC_LINK_UP_x1; + return OPAL_SUCCESS; } -static int64_t npu_power_state(struct phb *phb __unused) +static int64_t npu_get_power_state(struct pci_slot *slot __unused, + uint8_t *val) { - return OPAL_SHPC_POWER_ON; + *val = OPAL_SHPC_POWER_ON; + return OPAL_SUCCESS; } -static int64_t npu_freset(struct phb *phb __unused) +static int64_t npu_freset(struct pci_slot *slot __unused) { /* FIXME: PHB fundamental reset, which need to be * figured out later. It's used by EEH recovery @@ -984,6 +989,33 @@ static int64_t npu_freset(struct phb *phb __unused) return OPAL_SUCCESS; } +static struct pci_slot *npu_slot_create(struct phb *phb) +{ + struct pci_slot *slot; + + slot = pci_slot_alloc(phb, NULL); + if (!slot) + return slot; + + /* Elementary functions */ + slot->ops.get_presence_status = NULL; + slot->ops.get_link_status = npu_get_link_state; + slot->ops.get_power_status = npu_get_power_state; + slot->ops.get_attention_status = NULL; + slot->ops.get_latch_status = NULL; + slot->ops.set_power_status = NULL; + slot->ops.set_attention_status = NULL; + + slot->ops.prepare_link_change = NULL; + slot->ops.poll_link = NULL; + slot->ops.hreset = NULL; + slot->ops.freset = npu_freset; + slot->ops.pfreset = NULL; + slot->ops.creset = NULL; + + return slot; +} + static int64_t npu_freeze_status(struct phb *phb __unused, uint64_t pe_number __unused, uint8_t *freeze_state, @@ -1012,7 +1044,6 @@ static const struct phb_ops npu_ops = { .choose_bus = NULL, .device_init = NULL, .device_node_fixup = npu_dn_fixup, - .presence_detect = NULL, .ioda_reset = npu_ioda_reset, .papr_errinjct_reset = NULL, .pci_reinit = NULL, @@ -1027,14 +1058,6 @@ static const struct phb_ops npu_ops = { .get_msi_64 = NULL, .set_pe = npu_set_pe, .set_peltv = NULL, - .link_state = npu_link_state, - .power_state = npu_power_state, - .slot_power_off = NULL, - .slot_power_on = NULL, - .hot_reset = NULL, - .fundamental_reset = npu_freset, - .complete_reset = NULL, - .poll = NULL, .eeh_freeze_status = npu_freeze_status, .eeh_freeze_clear = NULL, .eeh_freeze_set = NULL, @@ -1650,6 +1673,7 @@ static void npu_create_phb(struct dt_node *dn) { const struct dt_property *prop; struct npu *p; + struct pci_slot *slot; uint32_t links; void *pmem; @@ -1691,6 +1715,11 @@ static void npu_create_phb(struct dt_node *dn) /* Populate extra properties */ npu_add_phb_properties(p); + /* Create PHB slot */ + slot = npu_slot_create(&p->phb); + if (!slot) + return; + /* Register PHB */ pci_register_phb(&p->phb, -1);