mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
Merge branch 'pci/controller/iproc-bcma'
- Expose devm_pci_alloc_host_bridge_release() so drivers can share a devm release function even if they don't need the device tree parsing done by devm_pci_alloc_host_bridge() (Bjorn Helgaas) - Request only the memory window from BCMA Enumeration ROM and warn if it doesn't match the one in DT (Semih Baskan) * pci/controller/iproc-bcma: PCI: iproc: Use the EROM outbound window on BCMA PCI: Expose devm_pci_alloc_host_bridge_release()
This commit is contained in:
commit
a26ee237c9
|
|
@ -11,7 +11,9 @@
|
|||
#include <linux/phy/phy.h>
|
||||
#include <linux/bcma/bcma.h>
|
||||
#include <linux/ioport.h>
|
||||
#include <linux/of_address.h>
|
||||
|
||||
#include "../pci.h"
|
||||
#include "pcie-iproc.h"
|
||||
|
||||
|
||||
|
|
@ -31,6 +33,29 @@ static int iproc_bcma_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
|
|||
return bcma_core_irq(bdev, 5);
|
||||
}
|
||||
|
||||
static void iproc_bcma_pcie_check_dt_window(struct iproc_pcie *pcie)
|
||||
{
|
||||
struct device_node *np = pcie->dev->of_node;
|
||||
struct of_pci_range_parser parser;
|
||||
struct of_pci_range range;
|
||||
struct resource res;
|
||||
|
||||
if (!np || of_pci_range_parser_init(&parser, np))
|
||||
return;
|
||||
|
||||
for_each_of_pci_range(&parser, &range) {
|
||||
if ((range.flags & IORESOURCE_TYPE_BITS) != IORESOURCE_MEM)
|
||||
continue;
|
||||
|
||||
if (of_pci_range_to_resource(&range, np, &res))
|
||||
continue;
|
||||
|
||||
if (res.start != pcie->mem.start || res.end != pcie->mem.end)
|
||||
dev_warn(pcie->dev, "DT window %pR does not match EROM window %pR, using EROM\n",
|
||||
&res, &pcie->mem);
|
||||
}
|
||||
}
|
||||
|
||||
static int iproc_bcma_pcie_probe(struct bcma_device *bdev)
|
||||
{
|
||||
struct device *dev = &bdev->dev;
|
||||
|
|
@ -38,10 +63,20 @@ static int iproc_bcma_pcie_probe(struct bcma_device *bdev)
|
|||
struct pci_host_bridge *bridge;
|
||||
int ret;
|
||||
|
||||
bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie));
|
||||
bridge = pci_alloc_host_bridge(sizeof(*pcie));
|
||||
if (!bridge)
|
||||
return -ENOMEM;
|
||||
|
||||
bridge->dev.parent = dev;
|
||||
|
||||
ret = devm_add_action_or_reset(dev, devm_pci_alloc_host_bridge_release,
|
||||
bridge);
|
||||
if (ret)
|
||||
return -ENOMEM;
|
||||
|
||||
bridge->swizzle_irq = pci_common_swizzle;
|
||||
bridge->map_irq = iproc_bcma_pcie_map_irq;
|
||||
|
||||
pcie = pci_host_bridge_priv(bridge);
|
||||
|
||||
pcie->dev = dev;
|
||||
|
|
@ -59,13 +94,12 @@ static int iproc_bcma_pcie_probe(struct bcma_device *bdev)
|
|||
pcie->mem.end = bdev->addr_s[0] + SZ_128M - 1;
|
||||
pcie->mem.name = "PCIe MEM space";
|
||||
pcie->mem.flags = IORESOURCE_MEM;
|
||||
iproc_bcma_pcie_check_dt_window(pcie);
|
||||
pci_add_resource(&bridge->windows, &pcie->mem);
|
||||
ret = devm_request_pci_bus_resources(dev, &bridge->windows);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
bridge->map_irq = iproc_bcma_pcie_map_irq;
|
||||
|
||||
bcma_set_drvdata(bdev, pcie);
|
||||
|
||||
return iproc_pcie_setup(pcie, &bridge->windows);
|
||||
|
|
|
|||
|
|
@ -502,6 +502,7 @@ enum pci_bar_type {
|
|||
pci_bar_mem64, /* A 64-bit memory BAR */
|
||||
};
|
||||
|
||||
void devm_pci_alloc_host_bridge_release(void *data);
|
||||
struct device *pci_get_host_bridge_device(struct pci_dev *dev);
|
||||
void pci_put_host_bridge_device(struct device *dev);
|
||||
|
||||
|
|
|
|||
|
|
@ -698,10 +698,11 @@ struct pci_host_bridge *pci_alloc_host_bridge(size_t priv)
|
|||
}
|
||||
EXPORT_SYMBOL(pci_alloc_host_bridge);
|
||||
|
||||
static void devm_pci_alloc_host_bridge_release(void *data)
|
||||
void devm_pci_alloc_host_bridge_release(void *data)
|
||||
{
|
||||
pci_free_host_bridge(data);
|
||||
}
|
||||
EXPORT_SYMBOL(devm_pci_alloc_host_bridge_release);
|
||||
|
||||
struct pci_host_bridge *devm_pci_alloc_host_bridge(struct device *dev,
|
||||
size_t priv)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user