From patchwork Thu Nov 12 02:33:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gavin Shan X-Patchwork-Id: 543182 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 680B4141301 for ; Thu, 12 Nov 2015 13:35:28 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 522381A029B for ; Thu, 12 Nov 2015 13:35:28 +1100 (AEDT) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from e23smtp01.au.ibm.com (e23smtp01.au.ibm.com [202.81.31.143]) (using TLSv1 with cipher CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 9B0AE1A0279 for ; Thu, 12 Nov 2015 13:34:56 +1100 (AEDT) Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Nov 2015 12:34:55 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Nov 2015 12:34:53 +1000 X-IBM-Helo: d23dlp02.au.ibm.com X-IBM-MailFrom: gwshan@linux.vnet.ibm.com X-IBM-RcptTo: skiboot@lists.ozlabs.org Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 56B472BB005D for ; Thu, 12 Nov 2015 13:34:53 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tAC2Yii819923092 for ; Thu, 12 Nov 2015 13:34:53 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tAC2YKV9027375 for ; Thu, 12 Nov 2015 13:34:20 +1100 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tAC2YJ3S026530; Thu, 12 Nov 2015 13:34:20 +1100 Received: from bran.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) by ozlabs.au.ibm.com (Postfix) with ESMTP id DEFD5A03F9; Thu, 12 Nov 2015 13:33:39 +1100 (AEDT) Received: from gwshan (shangw.ozlabs.ibm.com [10.61.2.199]) by bran.ozlabs.ibm.com (Postfix) with ESMTP id D3F50E46AC; Thu, 12 Nov 2015 13:33:39 +1100 (AEDT) Received: by gwshan (Postfix, from userid 1000) id AE39994212B; Thu, 12 Nov 2015 13:33:39 +1100 (AEDT) From: Gavin Shan To: skiboot@lists.ozlabs.org Date: Thu, 12 Nov 2015 13:33:26 +1100 Message-Id: <1447295609-20446-20-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-1618-0000-0000-00000321288B Subject: [Skiboot] [PATCH v9 19/22] platforms/astbmc: Support PCI 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 reworks PCI stuff for astbmc platform to support PCI slot: * The PCI slot is created in slot_table_get_slot_info(). * There are no platform dependent operations provided to PCI slots at current stage. * The slot location code is populated accordingly. Signed-off-by: Gavin Shan --- platforms/astbmc/slots.c | 58 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/platforms/astbmc/slots.c b/platforms/astbmc/slots.c index 2144112..7ece836 100644 --- a/platforms/astbmc/slots.c +++ b/platforms/astbmc/slots.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "astbmc.h" @@ -50,7 +51,7 @@ static const struct slot_table_entry *match_slot_phb_entry(struct phb *phb) } static const struct slot_table_entry *match_slot_dev_entry(struct phb *phb, - struct pci_device *pd) + struct pci_device *pd) { const struct slot_table_entry *parent, *ent; @@ -75,26 +76,53 @@ static const struct slot_table_entry *match_slot_dev_entry(struct phb *phb, return NULL; } +static void add_slot_properties(struct pci_slot *slot, + struct dt_node *np) +{ + struct phb *phb = slot->phb; + struct slot_table_entry *ent = slot->data; + size_t base_loc_code_len, slot_label_len; + char loc_code[LOC_CODE_SIZE]; + + if (!np || !ent || !phb->base_loc_code) + return; + + base_loc_code_len = strlen(phb->base_loc_code); + slot_label_len = strlen(ent->name); + if ((base_loc_code_len + slot_label_len + 1) >= LOC_CODE_SIZE) + return; + + /* Location code */ + strcpy(loc_code, phb->base_loc_code); + strcat(loc_code, "-"); + strcat(loc_code, ent->name); + dt_add_property(np, "ibm,slot-location-code", + loc_code, strlen(loc_code) + 1); + dt_add_property_string(np, "ibm,slot-label", ent->name); +} + void slot_table_get_slot_info(struct phb *phb, struct pci_device * pd) { const struct slot_table_entry *ent; - struct pci_slot_info *si; + struct pci_slot *slot; - if (!pd || pd->slot_info) + if (!pd || pd->slot) return; ent = match_slot_dev_entry(phb, pd); if (!ent || !ent->name) return; - pd->slot_info = si = zalloc(sizeof(struct pci_slot_info)); - assert(pd->slot_info); - strncpy(si->label, ent->name, sizeof(si->label) - 1); - si->pluggable = ent->etype == st_pluggable_slot; - si->power_ctl = false; - si->wired_lanes = -1; - si->bus_clock = -1; - si->connector_type = -1; - si->card_desc = -1; - si->card_mech = -1; - si->pwr_led_ctl = -1; - si->attn_led_ctl = -1; + + slot = pcie_slot_create(phb, pd); + assert(slot); + slot->ops.add_properties = add_slot_properties; + slot->data = (void *)ent; + + slot->pluggable = ent->etype == st_pluggable_slot; + slot->power_ctl = false; + slot->wired_lanes = PCI_SLOT_WIRED_LANES_UNKNOWN; + slot->connector_type = PCI_SLOT_CONNECTOR_PCIE_NS; + slot->card_desc = PCI_SLOT_DESC_NON_STANDARD; + slot->card_mech = PCI_SLOT_MECH_NONE; + slot->power_led_ctl = PCI_SLOT_PWR_LED_CTL_NONE; + slot->attn_led_ctl = PCI_SLOT_ATTN_LED_CTL_NONE; }