Enumeration - Read capability list as dwords, not bytes (Sean O. Stalley) Resource management - Don't check for PNP overlaps with unassigned PCI BARs (Bjorn Helgaas) - Mark invalid BARs as unassigned (Bjorn Helgaas) - Show driver, BAR#, and resource on pci_ioremap_bar() failure (Bjorn Helgaas) - Fail pci_ioremap_bar() on unassigned resources (Bjorn Helgaas) - Assign resources before drivers claim devices (Yijing Wang) - Claim bus resources before pci_bus_add_devices() (Yijing Wang) Power management - Optimize device state transition delays (Aaron Lu) - Don't clear ASPM bits when the FADT declares it's unsupported (Matthew Garrett) Virtualization - Add ACS quirks for Intel 1G NICs (Alex Williamson) IOMMU - Add ptr to OF node arg to of_iommu_configure() (Murali Karicheri) - Move of_dma_configure() to device.c to help re-use (Murali Karicheri) - Fix size when dma-range is not used (Murali Karicheri) - Add helper functions pci_get[put]_host_bridge_device() (Murali Karicheri) - Add of_pci_dma_configure() to update DMA configuration (Murali Karicheri) - Update DMA configuration from DT (Murali Karicheri) - dma-mapping: limit IOMMU mapping size (Murali Karicheri) - Calculate device DMA masks based on DT dma-range size (Murali Karicheri) ARM Versatile host bridge driver - Check for devm_ioremap_resource() failures (Jisheng Zhang) Broadcom iProc host bridge driver - Add Broadcom iProc PCIe driver (Ray Jui) Marvell MVEBU host bridge driver - Add suspend/resume support (Thomas Petazzoni) Renesas R-Car host bridge driver - Fix position of MSI enable bit (Nobuhiro Iwamatsu) - Write zeroes to reserved PCIEPARL bits (Nobuhiro Iwamatsu) - Change PCIEPARL and PCIEPARH to PCIEPALR and PCIEPAUR (Nobuhiro Iwamatsu) - Verify that mem_res is 64K-aligned (Nobuhiro Iwamatsu) Samsung Exynos host bridge driver - Fix INTx enablement statement termination error (Jaehoon Chung) Miscellaneous - Make a shareable UUID for PCI firmware ACPI _DSM (Aaron Lu) - Clarify policy for vendor IDs in pci.txt (Michael S. Tsirkin) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJVK/X+AAoJEFmIoMA60/r8hlkP/0e1GhAWA3DGR/+O2OPIkJ2w dQVgv5IN5KXGExT9RHiDL/Ib2PhDvdVI26sinjtkw/FcjyzoWVsPDUzCYudQaPSr zwzZto7dBzfv+exDN2LOqoSscCORAehApmTgYVg29cofJmKlO2ctDtpem1OT0MQ9 CMRMoBHhRe4FF3VJPOBPDXYpS89TObrY600aMDGk4S2uBboZI3aeYiTNLXJyh6fX vRg3TWnTfQHoZINW/YOqao/WbrRixZbO6q4n2IqhI6i/uaAc1IEALk9im8/2ri/s mgb/K5Elq+j4yUGnbFRz62pj/YxwnQKwVO4Nc7P66zENgoOXtv+OGRhlS4+d00/n ux0+BkoxJdaL8HQ/b7+uPydiD85lbERM+B2+LQQ7JN+HI+UEcQ0PsK2hSQKb3njD uEkktlKZViiqALijpL+vKRFe8U4GRE4KUfVsKHhhPPvY5sQTAZ3DrR36e1zKz2pA YJjtaHYW0S/tfoEzi3EnPistbJw5sT0/Waj31QTKb/P0Fr7pHnJfcwV7+unXbKla Osz8m6ELIqxhnuzhjlbayh4MKn49n1ZlwkwCnBdjgLQy0KZtxsWZoBg8LeGU077c TJXukRfl3H8LvpqGMYaxOyw7yUeKobEWy+Ylo5asFnfFw9h6zvW+Sc97jtBCrm4/ OZa7rKdPQGGMbQFMvDc2 =vEVs -----END PGP SIGNATURE----- Merge tag 'pci-v4.1-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci Pull PCI changes from Bjorn Helgaas: "Enumeration - Read capability list as dwords, not bytes (Sean O. Stalley) Resource management - Don't check for PNP overlaps with unassigned PCI BARs (Bjorn Helgaas) - Mark invalid BARs as unassigned (Bjorn Helgaas) - Show driver, BAR#, and resource on pci_ioremap_bar() failure (Bjorn Helgaas) - Fail pci_ioremap_bar() on unassigned resources (Bjorn Helgaas) - Assign resources before drivers claim devices (Yijing Wang) - Claim bus resources before pci_bus_add_devices() (Yijing Wang) Power management - Optimize device state transition delays (Aaron Lu) - Don't clear ASPM bits when the FADT declares it's unsupported (Matthew Garrett) Virtualization - Add ACS quirks for Intel 1G NICs (Alex Williamson) IOMMU - Add ptr to OF node arg to of_iommu_configure() (Murali Karicheri) - Move of_dma_configure() to device.c to help re-use (Murali Karicheri) - Fix size when dma-range is not used (Murali Karicheri) - Add helper functions pci_get[put]_host_bridge_device() (Murali Karicheri) - Add of_pci_dma_configure() to update DMA configuration (Murali Karicheri) - Update DMA configuration from DT (Murali Karicheri) - dma-mapping: limit IOMMU mapping size (Murali Karicheri) - Calculate device DMA masks based on DT dma-range size (Murali Karicheri) ARM Versatile host bridge driver - Check for devm_ioremap_resource() failures (Jisheng Zhang) Broadcom iProc host bridge driver - Add Broadcom iProc PCIe driver (Ray Jui) Marvell MVEBU host bridge driver - Add suspend/resume support (Thomas Petazzoni) Renesas R-Car host bridge driver - Fix position of MSI enable bit (Nobuhiro Iwamatsu) - Write zeroes to reserved PCIEPARL bits (Nobuhiro Iwamatsu) - Change PCIEPARL and PCIEPARH to PCIEPALR and PCIEPAUR (Nobuhiro Iwamatsu) - Verify that mem_res is 64K-aligned (Nobuhiro Iwamatsu) Samsung Exynos host bridge driver - Fix INTx enablement statement termination error (Jaehoon Chung) Miscellaneous - Make a shareable UUID for PCI firmware ACPI _DSM (Aaron Lu) - Clarify policy for vendor IDs in pci.txt (Michael S. Tsirkin)" * tag 'pci-v4.1-changes' of git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci: (36 commits) PCI: Read capability list as dwords, not bytes PCI: layerscape: Simplify platform_get_resource_byname() failure checking PCI: keystone: Don't dereference possible NULL pointer PCI: versatile: Check for devm_ioremap_resource() failures PCI: Don't clear ASPM bits when the FADT declares it's unsupported PCI: Clarify policy for vendor IDs in pci.txt PCI/ACPI: Optimize device state transition delays PCI: Export pci_find_host_bridge() for use inside PCI core PCI: Make a shareable UUID for PCI firmware ACPI _DSM PCI: Fix typo in Thunderbolt kernel message PCI: exynos: Fix INTx enablement statement termination error PCI: iproc: Add Broadcom iProc PCIe support PCI: iproc: Add DT docs for Broadcom iProc PCIe driver PCI: Export symbols required for loadable host driver modules PCI: Add ACS quirks for Intel 1G NICs PCI: mvebu: Add suspend/resume support PCI: Cleanup control flow sparc/PCI: Claim bus resources before pci_bus_add_devices() PCI: Assign resources before drivers claim devices (pci_scan_root_bus()) PCI: Fail pci_ioremap_bar() on unassigned resources ...tirimbino
commit
3be1b98e07
@ -0,0 +1,63 @@ |
||||
* Broadcom iProc PCIe controller with the platform bus interface |
||||
|
||||
Required properties: |
||||
- compatible: Must be "brcm,iproc-pcie" |
||||
- reg: base address and length of the PCIe controller I/O register space |
||||
- #interrupt-cells: set to <1> |
||||
- interrupt-map-mask and interrupt-map, standard PCI properties to define the |
||||
mapping of the PCIe interface to interrupt numbers |
||||
- linux,pci-domain: PCI domain ID. Should be unique for each host controller |
||||
- bus-range: PCI bus numbers covered |
||||
- #address-cells: set to <3> |
||||
- #size-cells: set to <2> |
||||
- device_type: set to "pci" |
||||
- ranges: ranges for the PCI memory and I/O regions |
||||
|
||||
Optional properties: |
||||
- phys: phandle of the PCIe PHY device |
||||
- phy-names: must be "pcie-phy" |
||||
|
||||
Example: |
||||
pcie0: pcie@18012000 { |
||||
compatible = "brcm,iproc-pcie"; |
||||
reg = <0x18012000 0x1000>; |
||||
|
||||
#interrupt-cells = <1>; |
||||
interrupt-map-mask = <0 0 0 0>; |
||||
interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_NONE>; |
||||
|
||||
linux,pci-domain = <0>; |
||||
|
||||
bus-range = <0x00 0xff>; |
||||
|
||||
#address-cells = <3>; |
||||
#size-cells = <2>; |
||||
device_type = "pci"; |
||||
ranges = <0x81000000 0 0 0x28000000 0 0x00010000 |
||||
0x82000000 0 0x20000000 0x20000000 0 0x04000000>; |
||||
|
||||
phys = <&phy 0 5>; |
||||
phy-names = "pcie-phy"; |
||||
}; |
||||
|
||||
pcie1: pcie@18013000 { |
||||
compatible = "brcm,iproc-pcie"; |
||||
reg = <0x18013000 0x1000>; |
||||
|
||||
#interrupt-cells = <1>; |
||||
interrupt-map-mask = <0 0 0 0>; |
||||
interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_NONE>; |
||||
|
||||
linux,pci-domain = <1>; |
||||
|
||||
bus-range = <0x00 0xff>; |
||||
|
||||
#address-cells = <3>; |
||||
#size-cells = <2>; |
||||
device_type = "pci"; |
||||
ranges = <0x81000000 0 0 0x48000000 0 0x00010000 |
||||
0x82000000 0 0x40000000 0x40000000 0 0x04000000>; |
||||
|
||||
phys = <&phy 1 6>; |
||||
phy-names = "pcie-phy"; |
||||
}; |
@ -0,0 +1,108 @@ |
||||
/*
|
||||
* Copyright (C) 2015 Broadcom Corporation |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License as |
||||
* published by the Free Software Foundation version 2. |
||||
* |
||||
* This program is distributed "as is" WITHOUT ANY WARRANTY of any |
||||
* kind, whether express or implied; without even the implied warranty |
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
*/ |
||||
|
||||
#include <linux/kernel.h> |
||||
#include <linux/pci.h> |
||||
#include <linux/clk.h> |
||||
#include <linux/module.h> |
||||
#include <linux/slab.h> |
||||
#include <linux/interrupt.h> |
||||
#include <linux/platform_device.h> |
||||
#include <linux/of_address.h> |
||||
#include <linux/of_pci.h> |
||||
#include <linux/of_irq.h> |
||||
#include <linux/of_platform.h> |
||||
#include <linux/phy/phy.h> |
||||
|
||||
#include "pcie-iproc.h" |
||||
|
||||
static int iproc_pcie_pltfm_probe(struct platform_device *pdev) |
||||
{ |
||||
struct iproc_pcie *pcie; |
||||
struct device_node *np = pdev->dev.of_node; |
||||
struct resource reg; |
||||
resource_size_t iobase = 0; |
||||
LIST_HEAD(res); |
||||
int ret; |
||||
|
||||
pcie = devm_kzalloc(&pdev->dev, sizeof(struct iproc_pcie), GFP_KERNEL); |
||||
if (!pcie) |
||||
return -ENOMEM; |
||||
|
||||
pcie->dev = &pdev->dev; |
||||
platform_set_drvdata(pdev, pcie); |
||||
|
||||
ret = of_address_to_resource(np, 0, ®); |
||||
if (ret < 0) { |
||||
dev_err(pcie->dev, "unable to obtain controller resources\n"); |
||||
return ret; |
||||
} |
||||
|
||||
pcie->base = devm_ioremap(pcie->dev, reg.start, resource_size(®)); |
||||
if (!pcie->base) { |
||||
dev_err(pcie->dev, "unable to map controller registers\n"); |
||||
return -ENOMEM; |
||||
} |
||||
|
||||
/* PHY use is optional */ |
||||
pcie->phy = devm_phy_get(&pdev->dev, "pcie-phy"); |
||||
if (IS_ERR(pcie->phy)) { |
||||
if (PTR_ERR(pcie->phy) == -EPROBE_DEFER) |
||||
return -EPROBE_DEFER; |
||||
pcie->phy = NULL; |
||||
} |
||||
|
||||
ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res, &iobase); |
||||
if (ret) { |
||||
dev_err(pcie->dev, |
||||
"unable to get PCI host bridge resources\n"); |
||||
return ret; |
||||
} |
||||
|
||||
pcie->resources = &res; |
||||
|
||||
ret = iproc_pcie_setup(pcie); |
||||
if (ret) { |
||||
dev_err(pcie->dev, "PCIe controller setup failed\n"); |
||||
return ret; |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
static int iproc_pcie_pltfm_remove(struct platform_device *pdev) |
||||
{ |
||||
struct iproc_pcie *pcie = platform_get_drvdata(pdev); |
||||
|
||||
return iproc_pcie_remove(pcie); |
||||
} |
||||
|
||||
static const struct of_device_id iproc_pcie_of_match_table[] = { |
||||
{ .compatible = "brcm,iproc-pcie", }, |
||||
{ /* sentinel */ } |
||||
}; |
||||
MODULE_DEVICE_TABLE(of, iproc_pcie_of_match_table); |
||||
|
||||
static struct platform_driver iproc_pcie_pltfm_driver = { |
||||
.driver = { |
||||
.name = "iproc-pcie", |
||||
.of_match_table = of_match_ptr(iproc_pcie_of_match_table), |
||||
}, |
||||
.probe = iproc_pcie_pltfm_probe, |
||||
.remove = iproc_pcie_pltfm_remove, |
||||
}; |
||||
module_platform_driver(iproc_pcie_pltfm_driver); |
||||
|
||||
MODULE_AUTHOR("Ray Jui <rjui@broadcom.com>"); |
||||
MODULE_DESCRIPTION("Broadcom iPROC PCIe platform driver"); |
||||
MODULE_LICENSE("GPL v2"); |
@ -0,0 +1,268 @@ |
||||
/*
|
||||
* Copyright (C) 2014 Hauke Mehrtens <hauke@hauke-m.de> |
||||
* Copyright (C) 2015 Broadcom Corporatcommon ion |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License as |
||||
* published by the Free Software Foundation version 2. |
||||
* |
||||
* This program is distributed "as is" WITHOUT ANY WARRANTY of any |
||||
* kind, whether express or implied; without even the implied warranty |
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
*/ |
||||
|
||||
#include <linux/kernel.h> |
||||
#include <linux/pci.h> |
||||
#include <linux/msi.h> |
||||
#include <linux/clk.h> |
||||
#include <linux/module.h> |
||||
#include <linux/mbus.h> |
||||
#include <linux/slab.h> |
||||
#include <linux/delay.h> |
||||
#include <linux/interrupt.h> |
||||
#include <linux/platform_device.h> |
||||
#include <linux/of_address.h> |
||||
#include <linux/of_pci.h> |
||||
#include <linux/of_irq.h> |
||||
#include <linux/of_platform.h> |
||||
#include <linux/phy/phy.h> |
||||
|
||||
#include "pcie-iproc.h" |
||||
|
||||
#define CLK_CONTROL_OFFSET 0x000 |
||||
#define EP_MODE_SURVIVE_PERST_SHIFT 1 |
||||
#define EP_MODE_SURVIVE_PERST BIT(EP_MODE_SURVIVE_PERST_SHIFT) |
||||
#define RC_PCIE_RST_OUTPUT_SHIFT 0 |
||||
#define RC_PCIE_RST_OUTPUT BIT(RC_PCIE_RST_OUTPUT_SHIFT) |
||||
|
||||
#define CFG_IND_ADDR_OFFSET 0x120 |
||||
#define CFG_IND_ADDR_MASK 0x00001ffc |
||||
|
||||
#define CFG_IND_DATA_OFFSET 0x124 |
||||
|
||||
#define CFG_ADDR_OFFSET 0x1f8 |
||||
#define CFG_ADDR_BUS_NUM_SHIFT 20 |
||||
#define CFG_ADDR_BUS_NUM_MASK 0x0ff00000 |
||||
#define CFG_ADDR_DEV_NUM_SHIFT 15 |
||||
#define CFG_ADDR_DEV_NUM_MASK 0x000f8000 |
||||
#define CFG_ADDR_FUNC_NUM_SHIFT 12 |
||||
#define CFG_ADDR_FUNC_NUM_MASK 0x00007000 |
||||
#define CFG_ADDR_REG_NUM_SHIFT 2 |
||||
#define CFG_ADDR_REG_NUM_MASK 0x00000ffc |
||||
#define CFG_ADDR_CFG_TYPE_SHIFT 0 |
||||
#define CFG_ADDR_CFG_TYPE_MASK 0x00000003 |
||||
|
||||
#define CFG_DATA_OFFSET 0x1fc |
||||
|
||||
#define SYS_RC_INTX_EN 0x330 |
||||
#define SYS_RC_INTX_MASK 0xf |
||||
|
||||
static inline struct iproc_pcie *sys_to_pcie(struct pci_sys_data *sys) |
||||
{ |
||||
return sys->private_data; |
||||
} |
||||
|
||||
/**
|
||||
* Note access to the configuration registers are protected at the higher layer |
||||
* by 'pci_lock' in drivers/pci/access.c |
||||
*/ |
||||
static void __iomem *iproc_pcie_map_cfg_bus(struct pci_bus *bus, |
||||
unsigned int devfn, |
||||
int where) |
||||
{ |
||||
struct pci_sys_data *sys = bus->sysdata; |
||||
struct iproc_pcie *pcie = sys_to_pcie(sys); |
||||
unsigned slot = PCI_SLOT(devfn); |
||||
unsigned fn = PCI_FUNC(devfn); |
||||
unsigned busno = bus->number; |
||||
u32 val; |
||||
|
||||
/* root complex access */ |
||||
if (busno == 0) { |
||||
if (slot >= 1) |
||||
return NULL; |
||||
writel(where & CFG_IND_ADDR_MASK, |
||||
pcie->base + CFG_IND_ADDR_OFFSET); |
||||
return (pcie->base + CFG_IND_DATA_OFFSET); |
||||
} |
||||
|
||||
if (fn > 1) |
||||
return NULL; |
||||
|
||||
/* EP device access */ |
||||
val = (busno << CFG_ADDR_BUS_NUM_SHIFT) | |
||||
(slot << CFG_ADDR_DEV_NUM_SHIFT) | |
||||
(fn << CFG_ADDR_FUNC_NUM_SHIFT) | |
||||
(where & CFG_ADDR_REG_NUM_MASK) | |
||||
(1 & CFG_ADDR_CFG_TYPE_MASK); |
||||
writel(val, pcie->base + CFG_ADDR_OFFSET); |
||||
|
||||
return (pcie->base + CFG_DATA_OFFSET); |
||||
} |
||||
|
||||
static struct pci_ops iproc_pcie_ops = { |
||||
.map_bus = iproc_pcie_map_cfg_bus, |
||||
.read = pci_generic_config_read32, |
||||
.write = pci_generic_config_write32, |
||||
}; |
||||
|
||||
static void iproc_pcie_reset(struct iproc_pcie *pcie) |
||||
{ |
||||
u32 val; |
||||
|
||||
/*
|
||||
* Configure the PCIe controller as root complex and send a downstream |
||||
* reset |
||||
*/ |
||||
val = EP_MODE_SURVIVE_PERST | RC_PCIE_RST_OUTPUT; |
||||
writel(val, pcie->base + CLK_CONTROL_OFFSET); |
||||
udelay(250); |
||||
val &= ~EP_MODE_SURVIVE_PERST; |
||||
writel(val, pcie->base + CLK_CONTROL_OFFSET); |
||||
msleep(250); |
||||
} |
||||
|
||||
static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) |
||||
{ |
||||
u8 hdr_type; |
||||
u32 link_ctrl; |
||||
u16 pos, link_status; |
||||
int link_is_active = 0; |
||||
|
||||
/* make sure we are not in EP mode */ |
||||
pci_bus_read_config_byte(bus, 0, PCI_HEADER_TYPE, &hdr_type); |
||||
if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) { |
||||
dev_err(pcie->dev, "in EP mode, hdr=%#02x\n", hdr_type); |
||||
return -EFAULT; |
||||
} |
||||
|
||||
/* force class to PCI_CLASS_BRIDGE_PCI (0x0604) */ |
||||
pci_bus_write_config_word(bus, 0, PCI_CLASS_DEVICE, |
||||
PCI_CLASS_BRIDGE_PCI); |
||||
|
||||
/* check link status to see if link is active */ |
||||
pos = pci_bus_find_capability(bus, 0, PCI_CAP_ID_EXP); |
||||
pci_bus_read_config_word(bus, 0, pos + PCI_EXP_LNKSTA, &link_status); |
||||
if (link_status & PCI_EXP_LNKSTA_NLW) |
||||
link_is_active = 1; |
||||
|
||||
if (!link_is_active) { |
||||
/* try GEN 1 link speed */ |
||||
#define PCI_LINK_STATUS_CTRL_2_OFFSET 0x0dc |
||||
#define PCI_TARGET_LINK_SPEED_MASK 0xf |
||||
#define PCI_TARGET_LINK_SPEED_GEN2 0x2 |
||||
#define PCI_TARGET_LINK_SPEED_GEN1 0x1 |
||||
pci_bus_read_config_dword(bus, 0, |
||||
PCI_LINK_STATUS_CTRL_2_OFFSET, |
||||
&link_ctrl); |
||||
if ((link_ctrl & PCI_TARGET_LINK_SPEED_MASK) == |
||||
PCI_TARGET_LINK_SPEED_GEN2) { |
||||
link_ctrl &= ~PCI_TARGET_LINK_SPEED_MASK; |
||||
link_ctrl |= PCI_TARGET_LINK_SPEED_GEN1; |
||||
pci_bus_write_config_dword(bus, 0, |
||||
PCI_LINK_STATUS_CTRL_2_OFFSET, |
||||
link_ctrl); |
||||
msleep(100); |
||||
|
||||
pos = pci_bus_find_capability(bus, 0, PCI_CAP_ID_EXP); |
||||
pci_bus_read_config_word(bus, 0, pos + PCI_EXP_LNKSTA, |
||||
&link_status); |
||||
if (link_status & PCI_EXP_LNKSTA_NLW) |
||||
link_is_active = 1; |
||||
} |
||||
} |
||||
|
||||
dev_info(pcie->dev, "link: %s\n", link_is_active ? "UP" : "DOWN"); |
||||
|
||||
return link_is_active ? 0 : -ENODEV; |
||||
} |
||||
|
||||
static void iproc_pcie_enable(struct iproc_pcie *pcie) |
||||
{ |
||||
writel(SYS_RC_INTX_MASK, pcie->base + SYS_RC_INTX_EN); |
||||
} |
||||
|
||||
int iproc_pcie_setup(struct iproc_pcie *pcie) |
||||
{ |
||||
int ret; |
||||
struct pci_bus *bus; |
||||
|
||||
if (!pcie || !pcie->dev || !pcie->base) |
||||
return -EINVAL; |
||||
|
||||
if (pcie->phy) { |
||||
ret = phy_init(pcie->phy); |
||||
if (ret) { |
||||
dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); |
||||
return ret; |
||||
} |
||||
|
||||
ret = phy_power_on(pcie->phy); |
||||
if (ret) { |
||||
dev_err(pcie->dev, "unable to power on PCIe PHY\n"); |
||||
goto err_exit_phy; |
||||
} |
||||
|
||||
} |
||||
|
||||
iproc_pcie_reset(pcie); |
||||
|
||||
pcie->sysdata.private_data = pcie; |
||||
|
||||
bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops, |
||||
&pcie->sysdata, pcie->resources); |
||||
if (!bus) { |
||||
dev_err(pcie->dev, "unable to create PCI root bus\n"); |
||||
ret = -ENOMEM; |
||||
goto err_power_off_phy; |
||||
} |
||||
pcie->root_bus = bus; |
||||
|
||||
ret = iproc_pcie_check_link(pcie, bus); |
||||
if (ret) { |
||||
dev_err(pcie->dev, "no PCIe EP device detected\n"); |
||||
goto err_rm_root_bus; |
||||
} |
||||
|
||||
iproc_pcie_enable(pcie); |
||||
|
||||
pci_scan_child_bus(bus); |
||||
pci_assign_unassigned_bus_resources(bus); |
||||
pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci); |
||||
pci_bus_add_devices(bus); |
||||
|
||||
return 0; |
||||
|
||||
err_rm_root_bus: |
||||
pci_stop_root_bus(bus); |
||||
pci_remove_root_bus(bus); |
||||
|
||||
err_power_off_phy: |
||||
if (pcie->phy) |
||||
phy_power_off(pcie->phy); |
||||
err_exit_phy: |
||||
if (pcie->phy) |
||||
phy_exit(pcie->phy); |
||||
|
||||
return ret; |
||||
} |
||||
EXPORT_SYMBOL(iproc_pcie_setup); |
||||
|
||||
int iproc_pcie_remove(struct iproc_pcie *pcie) |
||||
{ |
||||
pci_stop_root_bus(pcie->root_bus); |
||||
pci_remove_root_bus(pcie->root_bus); |
||||
|
||||
if (pcie->phy) { |
||||
phy_power_off(pcie->phy); |
||||
phy_exit(pcie->phy); |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
EXPORT_SYMBOL(iproc_pcie_remove); |
||||
|
||||
MODULE_AUTHOR("Ray Jui <rjui@broadcom.com>"); |
||||
MODULE_DESCRIPTION("Broadcom iPROC PCIe common driver"); |
||||
MODULE_LICENSE("GPL v2"); |
@ -0,0 +1,42 @@ |
||||
/*
|
||||
* Copyright (C) 2014-2015 Broadcom Corporation |
||||
* |
||||
* This program is free software; you can redistribute it and/or |
||||
* modify it under the terms of the GNU General Public License as |
||||
* published by the Free Software Foundation version 2. |
||||
* |
||||
* This program is distributed "as is" WITHOUT ANY WARRANTY of any |
||||
* kind, whether express or implied; without even the implied warranty |
||||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
*/ |
||||
|
||||
#ifndef _PCIE_IPROC_H |
||||
#define _PCIE_IPROC_H |
||||
|
||||
#define IPROC_PCIE_MAX_NUM_IRQS 6 |
||||
|
||||
/**
|
||||
* iProc PCIe device |
||||
* @dev: pointer to device data structure |
||||
* @base: PCIe host controller I/O register base |
||||
* @resources: linked list of all PCI resources |
||||
* @sysdata: Per PCI controller data |
||||
* @root_bus: pointer to root bus |
||||
* @phy: optional PHY device that controls the Serdes |
||||
* @irqs: interrupt IDs |
||||
*/ |
||||
struct iproc_pcie { |
||||
struct device *dev; |
||||
void __iomem *base; |
||||
struct list_head *resources; |
||||
struct pci_sys_data sysdata; |
||||
struct pci_bus *root_bus; |
||||
struct phy *phy; |
||||
int irqs[IPROC_PCIE_MAX_NUM_IRQS]; |
||||
}; |
||||
|
||||
int iproc_pcie_setup(struct iproc_pcie *pcie); |
||||
int iproc_pcie_remove(struct iproc_pcie *pcie); |
||||
|
||||
#endif /* _PCIE_IPROC_H */ |
Loading…
Reference in new issue