From patchwork Fri Jan 16 01:44:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 429679 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 03FE6140273 for ; Fri, 16 Jan 2015 14:48:04 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756098AbbAPDrj (ORCPT ); Thu, 15 Jan 2015 22:47:39 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:41180 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754210AbbAPDra (ORCPT ); Thu, 15 Jan 2015 22:47:30 -0500 Received: from 172.24.2.119 (EHLO szxeml407-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CHY77882; Fri, 16 Jan 2015 11:47:26 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml407-hub.china.huawei.com (10.82.67.94) with Microsoft SMTP Server id 14.3.158.1; Fri, 16 Jan 2015 11:47:14 +0800 From: Yijing Wang To: Bjorn Helgaas CC: Jiang Liu , , Yinghai Lu , , Marc Zyngier , , Russell King , , Thomas Gleixner , Tony Luck , , "David S. Miller" , "Guan Xuetao" , , , Liviu Dudau , "Arnd Bergmann" , Geert Uytterhoeven , "Yijing Wang" Subject: [PATCH 16/28] PCI/powerpc: Use pci_scan_root_bridge() for simplicity Date: Fri, 16 Jan 2015 09:44:14 +0800 Message-ID: <1421372666-12288-17-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1421372666-12288-1-git-send-email-wangyijing@huawei.com> References: <1421372666-12288-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Now we could use pci_scan_root_bridge() to scan pci buses, provide powerpc specific pci_host_bridge_ops. Signed-off-by: Yijing Wang --- arch/powerpc/kernel/pci-common.c | 57 ++++++++++++++++++++++++-------------- 1 files changed, 36 insertions(+), 21 deletions(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 2cf941e..0c7fb81 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -767,7 +767,8 @@ int pci_proc_domain(struct pci_bus *bus) return 1; } -int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) +static int pci_host_bridge_set_root_bus_speed( + struct pci_host_bridge *bridge) { if (ppc_md.pcibios_set_root_bus_speed) return ppc_md.pcibios_set_root_bus_speed(bridge); @@ -775,6 +776,27 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge) return 0; } +static void pci_host_bridge_probe_mode(struct pci_host_bridge *host) +{ + int mode = PCI_PROBE_NORMAL; + struct pci_bus *bus = host->bus; + struct pci_controller *hose = dev_get_drvdata(&host->dev); + + /* Get probe mode and perform scan */ + if (hose->dn && ppc_md.pci_probe_mode) + mode = ppc_md.pci_probe_mode(bus); + + pr_debug(" probe mode: %d\n", mode); + if (mode == PCI_PROBE_DEVTREE) + host->of_scan = true; +} + +static void pci_host_bridge_of_scan_bus(struct pci_host_bridge *host) +{ + struct pci_controller *hose = dev_get_drvdata(&host->dev); + + of_scan_bus(host->dn, bus); +} /* This header fixup will do the resource fixup for all devices as they are * probed, but not for bridge ranges */ @@ -1577,6 +1599,12 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) return of_node_get(hose->dn); } +static struct pci_host_bridge_ops *phb_ops = { + .phb_set_root_bus_speed = pci_host_bridge_set_root_bus_speed, + .phb_probe_mode = pci_host_bridge_probe_mode, + .phb_of_scan_bus = pci_host_bridge_of_scan_bus, +}; + /** * pci_scan_phb - Given a pci_controller, setup and scan the PCI bus * @hose: Pointer to the PCI host controller instance structure @@ -1584,9 +1612,9 @@ struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus) void pcibios_scan_phb(struct pci_controller *hose) { LIST_HEAD(resources); + struct pci_host_bridge *host; struct pci_bus *bus; struct device_node *node = hose->dn; - int mode; pr_debug("PCI: Scanning PHB %s\n", of_node_full_name(node)); @@ -1602,30 +1630,17 @@ void pcibios_scan_phb(struct pci_controller *hose) pci_add_resource(&resources, &hose->busn); /* Create an empty bus for the toplevel */ - bus = pci_create_root_bus(hose->parent, + host = pci_scan_root_bridge(hose->parent, PCI_DOMBUS(hose->global_number, hose->first_busno), - hose->ops, hose, &resources); - if (bus == NULL) { - pr_err("Failed to create bus for PCI domain %04x\n", + hose->ops, hose, &resources, &phb_ops); + if (host == NULL) { + pr_err("Failed to create host bridge for PCI domain %04x\n", hose->global_number); pci_free_resource_list(&resources); return; } - hose->bus = bus; - - /* Get probe mode and perform scan */ - mode = PCI_PROBE_NORMAL; - if (node && ppc_md.pci_probe_mode) - mode = ppc_md.pci_probe_mode(bus); - pr_debug(" probe mode: %d\n", mode); - if (mode == PCI_PROBE_DEVTREE) - of_scan_bus(node, bus); - - if (mode == PCI_PROBE_NORMAL) { - pci_bus_update_busn_res_end(bus, 255); - hose->last_busno = pci_scan_child_bus(bus); - pci_bus_update_busn_res_end(bus, hose->last_busno); - } + hose->bus = host->bus; + hose->last_busno = host->bus->busn_res.end; /* Platform gets a chance to do some global fixups before * we proceed to resource allocation