2018-01-27 02:50:27 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
/*
|
|
|
|
* PCIe driver for Marvell Armada 370 and Armada XP SoCs
|
|
|
|
*
|
2016-07-03 07:13:28 +08:00
|
|
|
* Author: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/pci.h>
|
|
|
|
#include <linux/clk.h>
|
2013-08-13 20:25:23 +08:00
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/gpio.h>
|
2016-07-03 07:13:28 +08:00
|
|
|
#include <linux/init.h>
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
#include <linux/mbus.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/of_address.h>
|
|
|
|
#include <linux/of_irq.h>
|
2013-08-13 20:25:23 +08:00
|
|
|
#include <linux/of_gpio.h>
|
|
|
|
#include <linux/of_pci.h>
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
#include <linux/of_platform.h>
|
|
|
|
|
2018-05-12 01:15:30 +08:00
|
|
|
#include "../pci.h"
|
2018-10-18 23:37:18 +08:00
|
|
|
#include "../pci-bridge-emul.h"
|
2018-05-12 01:15:30 +08:00
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
/*
|
|
|
|
* PCIe unit register offsets.
|
|
|
|
*/
|
|
|
|
#define PCIE_DEV_ID_OFF 0x0000
|
|
|
|
#define PCIE_CMD_OFF 0x0004
|
|
|
|
#define PCIE_DEV_REV_OFF 0x0008
|
|
|
|
#define PCIE_BAR_LO_OFF(n) (0x0010 + ((n) << 3))
|
|
|
|
#define PCIE_BAR_HI_OFF(n) (0x0014 + ((n) << 3))
|
2015-10-04 02:13:33 +08:00
|
|
|
#define PCIE_CAP_PCIEXP 0x0060
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
#define PCIE_HEADER_LOG_4_OFF 0x0128
|
|
|
|
#define PCIE_BAR_CTRL_OFF(n) (0x1804 + (((n) - 1) * 4))
|
|
|
|
#define PCIE_WIN04_CTRL_OFF(n) (0x1820 + ((n) << 4))
|
|
|
|
#define PCIE_WIN04_BASE_OFF(n) (0x1824 + ((n) << 4))
|
|
|
|
#define PCIE_WIN04_REMAP_OFF(n) (0x182c + ((n) << 4))
|
|
|
|
#define PCIE_WIN5_CTRL_OFF 0x1880
|
|
|
|
#define PCIE_WIN5_BASE_OFF 0x1884
|
|
|
|
#define PCIE_WIN5_REMAP_OFF 0x188c
|
|
|
|
#define PCIE_CONF_ADDR_OFF 0x18f8
|
|
|
|
#define PCIE_CONF_ADDR_EN 0x80000000
|
|
|
|
#define PCIE_CONF_REG(r) ((((r) & 0xf00) << 16) | ((r) & 0xfc))
|
|
|
|
#define PCIE_CONF_BUS(b) (((b) & 0xff) << 16)
|
|
|
|
#define PCIE_CONF_DEV(d) (((d) & 0x1f) << 11)
|
|
|
|
#define PCIE_CONF_FUNC(f) (((f) & 0x7) << 8)
|
|
|
|
#define PCIE_CONF_ADDR(bus, devfn, where) \
|
|
|
|
(PCIE_CONF_BUS(bus) | PCIE_CONF_DEV(PCI_SLOT(devfn)) | \
|
|
|
|
PCIE_CONF_FUNC(PCI_FUNC(devfn)) | PCIE_CONF_REG(where) | \
|
|
|
|
PCIE_CONF_ADDR_EN)
|
|
|
|
#define PCIE_CONF_DATA_OFF 0x18fc
|
|
|
|
#define PCIE_MASK_OFF 0x1910
|
|
|
|
#define PCIE_MASK_ENABLE_INTS 0x0f000000
|
|
|
|
#define PCIE_CTRL_OFF 0x1a00
|
|
|
|
#define PCIE_CTRL_X1_MODE 0x0001
|
|
|
|
#define PCIE_STAT_OFF 0x1a04
|
|
|
|
#define PCIE_STAT_BUS 0xff00
|
pci: mvebu: no longer fake the slot location of downstream devices
By default, the Marvell hardware, for each PCIe interface, exhibits
the following devices:
* On slot 0, a "Marvell Memory controller", identical on all PCIe
interfaces, and which isn't useful when the Marvell SoC is the PCIe
root complex (i.e, the normal case when we run Linux on the Marvell
SoC).
* On slot 1, the real PCIe card connected into the PCIe slot of the
board.
So, what the Marvell PCIe driver was doing in its PCI-to-PCI bridge
emulation is that when the Linux PCI core was trying to access the
device in slot 0, we were in fact forwarding the configuration
transaction to the device in slot 1. For all other slots, we were
telling the Linux PCI core that there was no device connected.
However, new versions of bootloaders from Marvell change the default
PCIe configuration, and make the real device appear in slot 0, and the
"Marvell Memory controller" in slot 1.
Therefore, this commit modifies the Marvell PCIe driver to adjust the
PCIe hardware configuration to make sure that this behavior (real
device in slot 0, "Marvell Memory controller" in slot 1) is the one
we'll see regardless of what the bootloader has done. It allows to
remove the little hack that was forwarding configuration transactions
on slot 0 to slot 1, which is nice.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-23 22:32:51 +08:00
|
|
|
#define PCIE_STAT_DEV 0x1f0000
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
#define PCIE_STAT_LINK_DOWN BIT(0)
|
2015-10-04 02:13:33 +08:00
|
|
|
#define PCIE_RC_RTSTA 0x1a14
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
#define PCIE_DEBUG_CTRL 0x1a60
|
|
|
|
#define PCIE_DEBUG_SOFT_RESET BIT(20)
|
|
|
|
|
|
|
|
struct mvebu_pcie_port;
|
|
|
|
|
|
|
|
/* Structure representing all PCIe interfaces */
|
|
|
|
struct mvebu_pcie {
|
|
|
|
struct platform_device *pdev;
|
|
|
|
struct mvebu_pcie_port *ports;
|
|
|
|
struct resource io;
|
|
|
|
struct resource realio;
|
|
|
|
struct resource mem;
|
|
|
|
struct resource busn;
|
|
|
|
int nports;
|
|
|
|
};
|
|
|
|
|
2016-12-13 02:30:20 +08:00
|
|
|
struct mvebu_pcie_window {
|
|
|
|
phys_addr_t base;
|
|
|
|
phys_addr_t remap;
|
|
|
|
size_t size;
|
|
|
|
};
|
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
/* Structure representing one PCIe interface */
|
|
|
|
struct mvebu_pcie_port {
|
|
|
|
char *name;
|
|
|
|
void __iomem *base;
|
|
|
|
u32 port;
|
|
|
|
u32 lane;
|
|
|
|
int devfn;
|
2013-07-26 21:17:48 +08:00
|
|
|
unsigned int mem_target;
|
|
|
|
unsigned int mem_attr;
|
|
|
|
unsigned int io_target;
|
|
|
|
unsigned int io_attr;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
struct clk *clk;
|
2015-10-04 02:13:22 +08:00
|
|
|
struct gpio_desc *reset_gpio;
|
2013-08-13 20:25:23 +08:00
|
|
|
char *reset_name;
|
2018-10-18 23:37:18 +08:00
|
|
|
struct pci_bridge_emul bridge;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
struct device_node *dn;
|
|
|
|
struct mvebu_pcie *pcie;
|
2016-12-13 02:30:20 +08:00
|
|
|
struct mvebu_pcie_window memwin;
|
|
|
|
struct mvebu_pcie_window iowin;
|
2015-03-17 22:55:45 +08:00
|
|
|
u32 saved_pcie_stat;
|
2020-06-23 14:03:35 +08:00
|
|
|
struct resource regs;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
};
|
|
|
|
|
2013-10-04 17:58:15 +08:00
|
|
|
static inline void mvebu_writel(struct mvebu_pcie_port *port, u32 val, u32 reg)
|
|
|
|
{
|
|
|
|
writel(val, port->base + reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u32 mvebu_readl(struct mvebu_pcie_port *port, u32 reg)
|
|
|
|
{
|
|
|
|
return readl(port->base + reg);
|
|
|
|
}
|
|
|
|
|
2013-11-27 02:02:55 +08:00
|
|
|
static inline bool mvebu_has_ioport(struct mvebu_pcie_port *port)
|
|
|
|
{
|
|
|
|
return port->io_target != -1 && port->io_attr != -1;
|
|
|
|
}
|
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
static bool mvebu_pcie_link_up(struct mvebu_pcie_port *port)
|
|
|
|
{
|
2013-10-04 17:58:15 +08:00
|
|
|
return !(mvebu_readl(port, PCIE_STAT_OFF) & PCIE_STAT_LINK_DOWN);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mvebu_pcie_set_local_bus_nr(struct mvebu_pcie_port *port, int nr)
|
|
|
|
{
|
|
|
|
u32 stat;
|
|
|
|
|
2013-10-04 17:58:15 +08:00
|
|
|
stat = mvebu_readl(port, PCIE_STAT_OFF);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
stat &= ~PCIE_STAT_BUS;
|
|
|
|
stat |= nr << 8;
|
2013-10-04 17:58:15 +08:00
|
|
|
mvebu_writel(port, stat, PCIE_STAT_OFF);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
pci: mvebu: no longer fake the slot location of downstream devices
By default, the Marvell hardware, for each PCIe interface, exhibits
the following devices:
* On slot 0, a "Marvell Memory controller", identical on all PCIe
interfaces, and which isn't useful when the Marvell SoC is the PCIe
root complex (i.e, the normal case when we run Linux on the Marvell
SoC).
* On slot 1, the real PCIe card connected into the PCIe slot of the
board.
So, what the Marvell PCIe driver was doing in its PCI-to-PCI bridge
emulation is that when the Linux PCI core was trying to access the
device in slot 0, we were in fact forwarding the configuration
transaction to the device in slot 1. For all other slots, we were
telling the Linux PCI core that there was no device connected.
However, new versions of bootloaders from Marvell change the default
PCIe configuration, and make the real device appear in slot 0, and the
"Marvell Memory controller" in slot 1.
Therefore, this commit modifies the Marvell PCIe driver to adjust the
PCIe hardware configuration to make sure that this behavior (real
device in slot 0, "Marvell Memory controller" in slot 1) is the one
we'll see regardless of what the bootloader has done. It allows to
remove the little hack that was forwarding configuration transactions
on slot 0 to slot 1, which is nice.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-23 22:32:51 +08:00
|
|
|
static void mvebu_pcie_set_local_dev_nr(struct mvebu_pcie_port *port, int nr)
|
|
|
|
{
|
|
|
|
u32 stat;
|
|
|
|
|
2013-10-04 17:58:15 +08:00
|
|
|
stat = mvebu_readl(port, PCIE_STAT_OFF);
|
pci: mvebu: no longer fake the slot location of downstream devices
By default, the Marvell hardware, for each PCIe interface, exhibits
the following devices:
* On slot 0, a "Marvell Memory controller", identical on all PCIe
interfaces, and which isn't useful when the Marvell SoC is the PCIe
root complex (i.e, the normal case when we run Linux on the Marvell
SoC).
* On slot 1, the real PCIe card connected into the PCIe slot of the
board.
So, what the Marvell PCIe driver was doing in its PCI-to-PCI bridge
emulation is that when the Linux PCI core was trying to access the
device in slot 0, we were in fact forwarding the configuration
transaction to the device in slot 1. For all other slots, we were
telling the Linux PCI core that there was no device connected.
However, new versions of bootloaders from Marvell change the default
PCIe configuration, and make the real device appear in slot 0, and the
"Marvell Memory controller" in slot 1.
Therefore, this commit modifies the Marvell PCIe driver to adjust the
PCIe hardware configuration to make sure that this behavior (real
device in slot 0, "Marvell Memory controller" in slot 1) is the one
we'll see regardless of what the bootloader has done. It allows to
remove the little hack that was forwarding configuration transactions
on slot 0 to slot 1, which is nice.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-23 22:32:51 +08:00
|
|
|
stat &= ~PCIE_STAT_DEV;
|
|
|
|
stat |= nr << 16;
|
2013-10-04 17:58:15 +08:00
|
|
|
mvebu_writel(port, stat, PCIE_STAT_OFF);
|
pci: mvebu: no longer fake the slot location of downstream devices
By default, the Marvell hardware, for each PCIe interface, exhibits
the following devices:
* On slot 0, a "Marvell Memory controller", identical on all PCIe
interfaces, and which isn't useful when the Marvell SoC is the PCIe
root complex (i.e, the normal case when we run Linux on the Marvell
SoC).
* On slot 1, the real PCIe card connected into the PCIe slot of the
board.
So, what the Marvell PCIe driver was doing in its PCI-to-PCI bridge
emulation is that when the Linux PCI core was trying to access the
device in slot 0, we were in fact forwarding the configuration
transaction to the device in slot 1. For all other slots, we were
telling the Linux PCI core that there was no device connected.
However, new versions of bootloaders from Marvell change the default
PCIe configuration, and make the real device appear in slot 0, and the
"Marvell Memory controller" in slot 1.
Therefore, this commit modifies the Marvell PCIe driver to adjust the
PCIe hardware configuration to make sure that this behavior (real
device in slot 0, "Marvell Memory controller" in slot 1) is the one
we'll see regardless of what the bootloader has done. It allows to
remove the little hack that was forwarding configuration transactions
on slot 0 to slot 1, which is nice.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-23 22:32:51 +08:00
|
|
|
}
|
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
/*
|
|
|
|
* Setup PCIE BARs and Address Decode Wins:
|
2020-06-23 14:03:35 +08:00
|
|
|
* BAR[0] -> internal registers (needed for MSI)
|
|
|
|
* BAR[1] -> covers all DRAM banks
|
|
|
|
* BAR[2] -> Disabled
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
* WIN[0-3] -> DRAM bank[0-3]
|
|
|
|
*/
|
2013-08-13 20:25:22 +08:00
|
|
|
static void mvebu_pcie_setup_wins(struct mvebu_pcie_port *port)
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
{
|
|
|
|
const struct mbus_dram_target_info *dram;
|
|
|
|
u32 size;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dram = mv_mbus_dram_info();
|
|
|
|
|
|
|
|
/* First, disable and clear BARs and windows. */
|
|
|
|
for (i = 1; i < 3; i++) {
|
2013-10-04 17:58:15 +08:00
|
|
|
mvebu_writel(port, 0, PCIE_BAR_CTRL_OFF(i));
|
|
|
|
mvebu_writel(port, 0, PCIE_BAR_LO_OFF(i));
|
|
|
|
mvebu_writel(port, 0, PCIE_BAR_HI_OFF(i));
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++) {
|
2013-10-04 17:58:15 +08:00
|
|
|
mvebu_writel(port, 0, PCIE_WIN04_CTRL_OFF(i));
|
|
|
|
mvebu_writel(port, 0, PCIE_WIN04_BASE_OFF(i));
|
|
|
|
mvebu_writel(port, 0, PCIE_WIN04_REMAP_OFF(i));
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
2013-10-04 17:58:15 +08:00
|
|
|
mvebu_writel(port, 0, PCIE_WIN5_CTRL_OFF);
|
|
|
|
mvebu_writel(port, 0, PCIE_WIN5_BASE_OFF);
|
|
|
|
mvebu_writel(port, 0, PCIE_WIN5_REMAP_OFF);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
|
|
|
/* Setup windows for DDR banks. Count total DDR size on the fly. */
|
|
|
|
size = 0;
|
|
|
|
for (i = 0; i < dram->num_cs; i++) {
|
|
|
|
const struct mbus_dram_window *cs = dram->cs + i;
|
|
|
|
|
2013-10-04 17:58:15 +08:00
|
|
|
mvebu_writel(port, cs->base & 0xffff0000,
|
|
|
|
PCIE_WIN04_BASE_OFF(i));
|
|
|
|
mvebu_writel(port, 0, PCIE_WIN04_REMAP_OFF(i));
|
|
|
|
mvebu_writel(port,
|
|
|
|
((cs->size - 1) & 0xffff0000) |
|
|
|
|
(cs->mbus_attr << 8) |
|
|
|
|
(dram->mbus_dram_target_id << 4) | 1,
|
|
|
|
PCIE_WIN04_CTRL_OFF(i));
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
|
|
|
size += cs->size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Round up 'size' to the nearest power of two. */
|
|
|
|
if ((size & (size - 1)) != 0)
|
|
|
|
size = 1 << fls(size);
|
|
|
|
|
|
|
|
/* Setup BAR[1] to all DRAM banks. */
|
2013-10-04 17:58:15 +08:00
|
|
|
mvebu_writel(port, dram->cs[0].base, PCIE_BAR_LO_OFF(1));
|
|
|
|
mvebu_writel(port, 0, PCIE_BAR_HI_OFF(1));
|
|
|
|
mvebu_writel(port, ((size - 1) & 0xffff0000) | 1,
|
|
|
|
PCIE_BAR_CTRL_OFF(1));
|
2020-06-23 14:03:35 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Point BAR[0] to the device's internal registers.
|
|
|
|
*/
|
|
|
|
mvebu_writel(port, round_down(port->regs.start, SZ_1M), PCIE_BAR_LO_OFF(0));
|
|
|
|
mvebu_writel(port, 0, PCIE_BAR_HI_OFF(0));
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
2013-08-13 20:25:22 +08:00
|
|
|
static void mvebu_pcie_setup_hw(struct mvebu_pcie_port *port)
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
{
|
2013-10-04 17:58:15 +08:00
|
|
|
u32 cmd, mask;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
|
|
|
/* Point PCIe unit MBUS decode windows to DRAM space. */
|
|
|
|
mvebu_pcie_setup_wins(port);
|
|
|
|
|
|
|
|
/* Master + slave enable. */
|
2013-10-04 17:58:15 +08:00
|
|
|
cmd = mvebu_readl(port, PCIE_CMD_OFF);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
cmd |= PCI_COMMAND_IO;
|
|
|
|
cmd |= PCI_COMMAND_MEMORY;
|
|
|
|
cmd |= PCI_COMMAND_MASTER;
|
2013-10-04 17:58:15 +08:00
|
|
|
mvebu_writel(port, cmd, PCIE_CMD_OFF);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
|
|
|
/* Enable interrupt lines A-D. */
|
2013-10-04 17:58:15 +08:00
|
|
|
mask = mvebu_readl(port, PCIE_MASK_OFF);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
mask |= PCIE_MASK_ENABLE_INTS;
|
2013-10-04 17:58:15 +08:00
|
|
|
mvebu_writel(port, mask, PCIE_MASK_OFF);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mvebu_pcie_hw_rd_conf(struct mvebu_pcie_port *port,
|
|
|
|
struct pci_bus *bus,
|
|
|
|
u32 devfn, int where, int size, u32 *val)
|
|
|
|
{
|
PCI: mvebu: Use exact config access size; don't read/modify/write
The idea that you can arbitarily read 32-bits from PCI configuration space,
modify a sub-field (like the command register) and write it back without
consequence is deeply flawed.
Status registers (such as the status register, PCIe device status register,
etc) contain status bits which are read, write-one-to-clear.
What this means is that reading 32-bits from the command register,
modifying the command register, and then writing it back has the effect of
clearing any status bits that were indicating at that time. Same for the
PCIe device control register clearing bits in the PCIe device status
register.
Since the Armada chips support byte, 16-bit and 32-bit accesses to the
registers (unless otherwise stated) and the PCI configuration data register
does not specify otherwise, it seems logical that the chip can indeed
generate the proper configuration access cycles down to byte level.
Testing with an ASM1062 PCIe to SATA mini-PCIe card on Armada 388. PCIe
capability at 0x80, DevCtl at 0x88, DevSta at 0x8a.
Before:
/# setpci -s 1:0.0 0x88.l - DevSta: CorrErr+
00012810
/# setpci -s 1:0.0 0x88.w=0x2810 - Write DevCtl only
/# setpci -s 1:0.0 0x88.l - CorrErr cleared - FAIL
00002810
After:
/# setpci -s 1:0.0 0x88.l - DevSta: CorrErr+
00012810
/# setpci -s 1:0.0 0x88.w=0x2810 - check DevCtl only write
/# setpci -s 1:0.0 0x88.l - CorErr remains set
00012810
/# setpci -s 1:0.0 0x88.w=0x281f - check DevCtl write works
/# setpci -s 1:0.0 0x88.l - devctl field updated
0001281f
/# setpci -s 1:0.0 0x8a.w=0xffff - clear DevSta
/# setpci -s 1:0.0 0x88.l - CorrErr now cleared
0000281f
/# setpci -s 1:0.0 0x88.w=0x2810 - restore DevCtl
/# setpci -s 1:0.0 0x88.l - check
00002810
[bhelgaas: changelog]
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> (Armada XP GP)
Tested-by: Andrew Lunn <andrew@lunn.ch> (Kirkwood DIR665)
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2015-09-24 01:17:32 +08:00
|
|
|
void __iomem *conf_data = port->base + PCIE_CONF_DATA_OFF;
|
|
|
|
|
2013-10-04 17:58:15 +08:00
|
|
|
mvebu_writel(port, PCIE_CONF_ADDR(bus->number, devfn, where),
|
|
|
|
PCIE_CONF_ADDR_OFF);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
PCI: mvebu: Use exact config access size; don't read/modify/write
The idea that you can arbitarily read 32-bits from PCI configuration space,
modify a sub-field (like the command register) and write it back without
consequence is deeply flawed.
Status registers (such as the status register, PCIe device status register,
etc) contain status bits which are read, write-one-to-clear.
What this means is that reading 32-bits from the command register,
modifying the command register, and then writing it back has the effect of
clearing any status bits that were indicating at that time. Same for the
PCIe device control register clearing bits in the PCIe device status
register.
Since the Armada chips support byte, 16-bit and 32-bit accesses to the
registers (unless otherwise stated) and the PCI configuration data register
does not specify otherwise, it seems logical that the chip can indeed
generate the proper configuration access cycles down to byte level.
Testing with an ASM1062 PCIe to SATA mini-PCIe card on Armada 388. PCIe
capability at 0x80, DevCtl at 0x88, DevSta at 0x8a.
Before:
/# setpci -s 1:0.0 0x88.l - DevSta: CorrErr+
00012810
/# setpci -s 1:0.0 0x88.w=0x2810 - Write DevCtl only
/# setpci -s 1:0.0 0x88.l - CorrErr cleared - FAIL
00002810
After:
/# setpci -s 1:0.0 0x88.l - DevSta: CorrErr+
00012810
/# setpci -s 1:0.0 0x88.w=0x2810 - check DevCtl only write
/# setpci -s 1:0.0 0x88.l - CorErr remains set
00012810
/# setpci -s 1:0.0 0x88.w=0x281f - check DevCtl write works
/# setpci -s 1:0.0 0x88.l - devctl field updated
0001281f
/# setpci -s 1:0.0 0x8a.w=0xffff - clear DevSta
/# setpci -s 1:0.0 0x88.l - CorrErr now cleared
0000281f
/# setpci -s 1:0.0 0x88.w=0x2810 - restore DevCtl
/# setpci -s 1:0.0 0x88.l - check
00002810
[bhelgaas: changelog]
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> (Armada XP GP)
Tested-by: Andrew Lunn <andrew@lunn.ch> (Kirkwood DIR665)
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2015-09-24 01:17:32 +08:00
|
|
|
switch (size) {
|
|
|
|
case 1:
|
|
|
|
*val = readb_relaxed(conf_data + (where & 3));
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
*val = readw_relaxed(conf_data + (where & 2));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
*val = readl_relaxed(conf_data);
|
|
|
|
break;
|
|
|
|
}
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
|
|
|
return PCIBIOS_SUCCESSFUL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mvebu_pcie_hw_wr_conf(struct mvebu_pcie_port *port,
|
|
|
|
struct pci_bus *bus,
|
|
|
|
u32 devfn, int where, int size, u32 val)
|
|
|
|
{
|
PCI: mvebu: Use exact config access size; don't read/modify/write
The idea that you can arbitarily read 32-bits from PCI configuration space,
modify a sub-field (like the command register) and write it back without
consequence is deeply flawed.
Status registers (such as the status register, PCIe device status register,
etc) contain status bits which are read, write-one-to-clear.
What this means is that reading 32-bits from the command register,
modifying the command register, and then writing it back has the effect of
clearing any status bits that were indicating at that time. Same for the
PCIe device control register clearing bits in the PCIe device status
register.
Since the Armada chips support byte, 16-bit and 32-bit accesses to the
registers (unless otherwise stated) and the PCI configuration data register
does not specify otherwise, it seems logical that the chip can indeed
generate the proper configuration access cycles down to byte level.
Testing with an ASM1062 PCIe to SATA mini-PCIe card on Armada 388. PCIe
capability at 0x80, DevCtl at 0x88, DevSta at 0x8a.
Before:
/# setpci -s 1:0.0 0x88.l - DevSta: CorrErr+
00012810
/# setpci -s 1:0.0 0x88.w=0x2810 - Write DevCtl only
/# setpci -s 1:0.0 0x88.l - CorrErr cleared - FAIL
00002810
After:
/# setpci -s 1:0.0 0x88.l - DevSta: CorrErr+
00012810
/# setpci -s 1:0.0 0x88.w=0x2810 - check DevCtl only write
/# setpci -s 1:0.0 0x88.l - CorErr remains set
00012810
/# setpci -s 1:0.0 0x88.w=0x281f - check DevCtl write works
/# setpci -s 1:0.0 0x88.l - devctl field updated
0001281f
/# setpci -s 1:0.0 0x8a.w=0xffff - clear DevSta
/# setpci -s 1:0.0 0x88.l - CorrErr now cleared
0000281f
/# setpci -s 1:0.0 0x88.w=0x2810 - restore DevCtl
/# setpci -s 1:0.0 0x88.l - check
00002810
[bhelgaas: changelog]
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> (Armada XP GP)
Tested-by: Andrew Lunn <andrew@lunn.ch> (Kirkwood DIR665)
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2015-09-24 01:17:32 +08:00
|
|
|
void __iomem *conf_data = port->base + PCIE_CONF_DATA_OFF;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
2013-10-04 17:58:15 +08:00
|
|
|
mvebu_writel(port, PCIE_CONF_ADDR(bus->number, devfn, where),
|
|
|
|
PCIE_CONF_ADDR_OFF);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
PCI: mvebu: Use exact config access size; don't read/modify/write
The idea that you can arbitarily read 32-bits from PCI configuration space,
modify a sub-field (like the command register) and write it back without
consequence is deeply flawed.
Status registers (such as the status register, PCIe device status register,
etc) contain status bits which are read, write-one-to-clear.
What this means is that reading 32-bits from the command register,
modifying the command register, and then writing it back has the effect of
clearing any status bits that were indicating at that time. Same for the
PCIe device control register clearing bits in the PCIe device status
register.
Since the Armada chips support byte, 16-bit and 32-bit accesses to the
registers (unless otherwise stated) and the PCI configuration data register
does not specify otherwise, it seems logical that the chip can indeed
generate the proper configuration access cycles down to byte level.
Testing with an ASM1062 PCIe to SATA mini-PCIe card on Armada 388. PCIe
capability at 0x80, DevCtl at 0x88, DevSta at 0x8a.
Before:
/# setpci -s 1:0.0 0x88.l - DevSta: CorrErr+
00012810
/# setpci -s 1:0.0 0x88.w=0x2810 - Write DevCtl only
/# setpci -s 1:0.0 0x88.l - CorrErr cleared - FAIL
00002810
After:
/# setpci -s 1:0.0 0x88.l - DevSta: CorrErr+
00012810
/# setpci -s 1:0.0 0x88.w=0x2810 - check DevCtl only write
/# setpci -s 1:0.0 0x88.l - CorErr remains set
00012810
/# setpci -s 1:0.0 0x88.w=0x281f - check DevCtl write works
/# setpci -s 1:0.0 0x88.l - devctl field updated
0001281f
/# setpci -s 1:0.0 0x8a.w=0xffff - clear DevSta
/# setpci -s 1:0.0 0x88.l - CorrErr now cleared
0000281f
/# setpci -s 1:0.0 0x88.w=0x2810 - restore DevCtl
/# setpci -s 1:0.0 0x88.l - check
00002810
[bhelgaas: changelog]
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> (Armada XP GP)
Tested-by: Andrew Lunn <andrew@lunn.ch> (Kirkwood DIR665)
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2015-09-24 01:17:32 +08:00
|
|
|
switch (size) {
|
|
|
|
case 1:
|
|
|
|
writeb(val, conf_data + (where & 3));
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
writew(val, conf_data + (where & 2));
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
writel(val, conf_data);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return PCIBIOS_BAD_REGISTER_NUMBER;
|
|
|
|
}
|
2013-10-04 17:58:15 +08:00
|
|
|
|
|
|
|
return PCIBIOS_SUCCESSFUL;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
2014-04-18 20:19:53 +08:00
|
|
|
/*
|
|
|
|
* Remove windows, starting from the largest ones to the smallest
|
|
|
|
* ones.
|
|
|
|
*/
|
|
|
|
static void mvebu_pcie_del_windows(struct mvebu_pcie_port *port,
|
|
|
|
phys_addr_t base, size_t size)
|
|
|
|
{
|
|
|
|
while (size) {
|
|
|
|
size_t sz = 1 << (fls(size) - 1);
|
|
|
|
|
|
|
|
mvebu_mbus_del_window(base, sz);
|
|
|
|
base += sz;
|
|
|
|
size -= sz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MBus windows can only have a power of two size, but PCI BARs do not
|
|
|
|
* have this constraint. Therefore, we have to split the PCI BAR into
|
|
|
|
* areas each having a power of two size. We start from the largest
|
|
|
|
* one (i.e highest order bit set in the size).
|
|
|
|
*/
|
|
|
|
static void mvebu_pcie_add_windows(struct mvebu_pcie_port *port,
|
|
|
|
unsigned int target, unsigned int attribute,
|
|
|
|
phys_addr_t base, size_t size,
|
|
|
|
phys_addr_t remap)
|
|
|
|
{
|
|
|
|
size_t size_mapped = 0;
|
|
|
|
|
|
|
|
while (size) {
|
|
|
|
size_t sz = 1 << (fls(size) - 1);
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = mvebu_mbus_add_window_remap_by_id(target, attribute, base,
|
|
|
|
sz, remap);
|
|
|
|
if (ret) {
|
2014-04-29 20:58:07 +08:00
|
|
|
phys_addr_t end = base + sz - 1;
|
|
|
|
|
2014-04-18 20:19:53 +08:00
|
|
|
dev_err(&port->pcie->pdev->dev,
|
2014-04-29 20:58:07 +08:00
|
|
|
"Could not create MBus window at [mem %pa-%pa]: %d\n",
|
|
|
|
&base, &end, ret);
|
2014-04-18 20:19:53 +08:00
|
|
|
mvebu_pcie_del_windows(port, base - size_mapped,
|
|
|
|
size_mapped);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
size -= sz;
|
|
|
|
size_mapped += sz;
|
|
|
|
base += sz;
|
|
|
|
if (remap != MVEBU_MBUS_NO_REMAP)
|
|
|
|
remap += sz;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-13 02:30:20 +08:00
|
|
|
static void mvebu_pcie_set_window(struct mvebu_pcie_port *port,
|
|
|
|
unsigned int target, unsigned int attribute,
|
|
|
|
const struct mvebu_pcie_window *desired,
|
|
|
|
struct mvebu_pcie_window *cur)
|
|
|
|
{
|
|
|
|
if (desired->base == cur->base && desired->remap == cur->remap &&
|
|
|
|
desired->size == cur->size)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (cur->size != 0) {
|
|
|
|
mvebu_pcie_del_windows(port, cur->base, cur->size);
|
|
|
|
cur->size = 0;
|
|
|
|
cur->base = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If something tries to change the window while it is enabled
|
|
|
|
* the change will not be done atomically. That would be
|
|
|
|
* difficult to do in the general case.
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
if (desired->size == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mvebu_pcie_add_windows(port, target, attribute, desired->base,
|
|
|
|
desired->size, desired->remap);
|
|
|
|
*cur = *desired;
|
|
|
|
}
|
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
|
|
|
|
{
|
2016-12-13 02:30:20 +08:00
|
|
|
struct mvebu_pcie_window desired = {};
|
2018-10-18 23:37:18 +08:00
|
|
|
struct pci_bridge_emul_conf *conf = &port->bridge.conf;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
|
|
|
/* Are the new iobase/iolimit values invalid? */
|
2018-10-18 23:37:18 +08:00
|
|
|
if (conf->iolimit < conf->iobase ||
|
|
|
|
conf->iolimitupper < conf->iobaseupper ||
|
|
|
|
!(conf->command & PCI_COMMAND_IO)) {
|
2016-12-13 02:30:20 +08:00
|
|
|
mvebu_pcie_set_window(port, port->io_target, port->io_attr,
|
|
|
|
&desired, &port->iowin);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-11-27 02:02:55 +08:00
|
|
|
if (!mvebu_has_ioport(port)) {
|
|
|
|
dev_WARN(&port->pcie->pdev->dev,
|
|
|
|
"Attempt to set IO when IO is disabled\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
/*
|
|
|
|
* We read the PCI-to-PCI bridge emulated registers, and
|
|
|
|
* calculate the base address and size of the address decoding
|
|
|
|
* window to setup, according to the PCI-to-PCI bridge
|
|
|
|
* specifications. iobase is the bus address, port->iowin_base
|
|
|
|
* is the CPU address.
|
|
|
|
*/
|
2018-10-18 23:37:18 +08:00
|
|
|
desired.remap = ((conf->iobase & 0xF0) << 8) |
|
|
|
|
(conf->iobaseupper << 16);
|
2016-12-13 02:30:20 +08:00
|
|
|
desired.base = port->pcie->io.start + desired.remap;
|
2018-10-18 23:37:18 +08:00
|
|
|
desired.size = ((0xFFF | ((conf->iolimit & 0xF0) << 8) |
|
|
|
|
(conf->iolimitupper << 16)) -
|
2016-12-13 02:30:20 +08:00
|
|
|
desired.remap) +
|
|
|
|
1;
|
|
|
|
|
|
|
|
mvebu_pcie_set_window(port, port->io_target, port->io_attr, &desired,
|
|
|
|
&port->iowin);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port)
|
|
|
|
{
|
2016-12-13 02:30:20 +08:00
|
|
|
struct mvebu_pcie_window desired = {.remap = MVEBU_MBUS_NO_REMAP};
|
2018-10-18 23:37:18 +08:00
|
|
|
struct pci_bridge_emul_conf *conf = &port->bridge.conf;
|
2016-12-13 02:30:20 +08:00
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
/* Are the new membase/memlimit values invalid? */
|
2018-10-18 23:37:18 +08:00
|
|
|
if (conf->memlimit < conf->membase ||
|
|
|
|
!(conf->command & PCI_COMMAND_MEMORY)) {
|
2016-12-13 02:30:20 +08:00
|
|
|
mvebu_pcie_set_window(port, port->mem_target, port->mem_attr,
|
|
|
|
&desired, &port->memwin);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We read the PCI-to-PCI bridge emulated registers, and
|
|
|
|
* calculate the base address and size of the address decoding
|
|
|
|
* window to setup, according to the PCI-to-PCI bridge
|
|
|
|
* specifications.
|
|
|
|
*/
|
2018-10-18 23:37:18 +08:00
|
|
|
desired.base = ((conf->membase & 0xFFF0) << 16);
|
|
|
|
desired.size = (((conf->memlimit & 0xFFF0) << 16) | 0xFFFFF) -
|
2016-12-13 02:30:20 +08:00
|
|
|
desired.base + 1;
|
|
|
|
|
|
|
|
mvebu_pcie_set_window(port, port->mem_target, port->mem_attr, &desired,
|
|
|
|
&port->memwin);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
static pci_bridge_emul_read_status_t
|
|
|
|
mvebu_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge,
|
|
|
|
int reg, u32 *value)
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
{
|
2018-10-18 23:37:18 +08:00
|
|
|
struct mvebu_pcie_port *port = bridge->data;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
switch (reg) {
|
|
|
|
case PCI_EXP_DEVCAP:
|
2015-10-04 02:13:33 +08:00
|
|
|
*value = mvebu_readl(port, PCIE_CAP_PCIEXP + PCI_EXP_DEVCAP);
|
|
|
|
break;
|
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
case PCI_EXP_DEVCTL:
|
2015-10-04 02:13:33 +08:00
|
|
|
*value = mvebu_readl(port, PCIE_CAP_PCIEXP + PCI_EXP_DEVCTL) &
|
|
|
|
~(PCI_EXP_DEVCTL_URRE | PCI_EXP_DEVCTL_FERE |
|
|
|
|
PCI_EXP_DEVCTL_NFERE | PCI_EXP_DEVCTL_CERE);
|
|
|
|
break;
|
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
case PCI_EXP_LNKCAP:
|
2015-10-04 02:13:33 +08:00
|
|
|
/*
|
|
|
|
* PCIe requires the clock power management capability to be
|
|
|
|
* hard-wired to zero for downstream ports
|
|
|
|
*/
|
|
|
|
*value = mvebu_readl(port, PCIE_CAP_PCIEXP + PCI_EXP_LNKCAP) &
|
|
|
|
~PCI_EXP_LNKCAP_CLKPM;
|
|
|
|
break;
|
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
case PCI_EXP_LNKCTL:
|
2015-10-04 02:13:33 +08:00
|
|
|
*value = mvebu_readl(port, PCIE_CAP_PCIEXP + PCI_EXP_LNKCTL);
|
|
|
|
break;
|
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
case PCI_EXP_SLTCTL:
|
2015-10-04 02:13:33 +08:00
|
|
|
*value = PCI_EXP_SLTSTA_PDS << 16;
|
|
|
|
break;
|
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
case PCI_EXP_RTSTA:
|
2015-10-04 02:13:33 +08:00
|
|
|
*value = mvebu_readl(port, PCIE_RC_RTSTA);
|
|
|
|
break;
|
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
default:
|
2018-10-18 23:37:18 +08:00
|
|
|
return PCI_BRIDGE_EMUL_NOT_HANDLED;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
return PCI_BRIDGE_EMUL_HANDLED;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
static void
|
|
|
|
mvebu_pci_bridge_emul_base_conf_write(struct pci_bridge_emul *bridge,
|
|
|
|
int reg, u32 old, u32 new, u32 mask)
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
{
|
2018-10-18 23:37:18 +08:00
|
|
|
struct mvebu_pcie_port *port = bridge->data;
|
|
|
|
struct pci_bridge_emul_conf *conf = &bridge->conf;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
switch (reg) {
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
case PCI_COMMAND:
|
2013-11-27 02:02:54 +08:00
|
|
|
{
|
2013-11-27 02:02:55 +08:00
|
|
|
if (!mvebu_has_ioport(port))
|
2018-10-18 23:37:18 +08:00
|
|
|
conf->command &= ~PCI_COMMAND_IO;
|
2013-11-27 02:02:55 +08:00
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
if ((old ^ new) & PCI_COMMAND_IO)
|
2013-11-27 02:02:54 +08:00
|
|
|
mvebu_pcie_handle_iobase_change(port);
|
2018-10-18 23:37:18 +08:00
|
|
|
if ((old ^ new) & PCI_COMMAND_MEMORY)
|
2013-11-27 02:02:54 +08:00
|
|
|
mvebu_pcie_handle_membase_change(port);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
|
|
|
break;
|
2018-10-18 23:37:18 +08:00
|
|
|
}
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
|
|
|
case PCI_IO_BASE:
|
|
|
|
/*
|
2018-10-18 23:37:18 +08:00
|
|
|
* We keep bit 1 set, it is a read-only bit that
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
* indicates we support 32 bits addressing for the
|
|
|
|
* I/O
|
|
|
|
*/
|
2018-10-18 23:37:18 +08:00
|
|
|
conf->iobase |= PCI_IO_RANGE_TYPE_32;
|
|
|
|
conf->iolimit |= PCI_IO_RANGE_TYPE_32;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
mvebu_pcie_handle_iobase_change(port);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCI_MEMORY_BASE:
|
|
|
|
mvebu_pcie_handle_membase_change(port);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCI_IO_BASE_UPPER16:
|
|
|
|
mvebu_pcie_handle_iobase_change(port);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PCI_PRIMARY_BUS:
|
2018-10-18 23:37:18 +08:00
|
|
|
mvebu_pcie_set_local_bus_nr(port, conf->secondary_bus);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
break;
|
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
default:
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
break;
|
2018-10-18 23:37:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mvebu_pci_bridge_emul_pcie_conf_write(struct pci_bridge_emul *bridge,
|
|
|
|
int reg, u32 old, u32 new, u32 mask)
|
|
|
|
{
|
|
|
|
struct mvebu_pcie_port *port = bridge->data;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
switch (reg) {
|
|
|
|
case PCI_EXP_DEVCTL:
|
2015-10-04 02:13:33 +08:00
|
|
|
/*
|
|
|
|
* Armada370 data says these bits must always
|
|
|
|
* be zero when in root complex mode.
|
|
|
|
*/
|
2018-10-18 23:37:18 +08:00
|
|
|
new &= ~(PCI_EXP_DEVCTL_URRE | PCI_EXP_DEVCTL_FERE |
|
|
|
|
PCI_EXP_DEVCTL_NFERE | PCI_EXP_DEVCTL_CERE);
|
2015-10-04 02:13:33 +08:00
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
mvebu_writel(port, new, PCIE_CAP_PCIEXP + PCI_EXP_DEVCTL);
|
2015-10-04 02:13:33 +08:00
|
|
|
break;
|
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
case PCI_EXP_LNKCTL:
|
2015-10-04 02:13:33 +08:00
|
|
|
/*
|
|
|
|
* If we don't support CLKREQ, we must ensure that the
|
|
|
|
* CLKREQ enable bit always reads zero. Since we haven't
|
|
|
|
* had this capability, and it's dependent on board wiring,
|
|
|
|
* disable it for the time being.
|
|
|
|
*/
|
2018-10-18 23:37:18 +08:00
|
|
|
new &= ~PCI_EXP_LNKCTL_CLKREQ_EN;
|
2015-10-04 02:13:33 +08:00
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
mvebu_writel(port, new, PCIE_CAP_PCIEXP + PCI_EXP_LNKCTL);
|
2015-10-04 02:13:33 +08:00
|
|
|
break;
|
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
case PCI_EXP_RTSTA:
|
|
|
|
mvebu_writel(port, new, PCIE_RC_RTSTA);
|
2015-10-04 02:13:33 +08:00
|
|
|
break;
|
2018-10-18 23:37:18 +08:00
|
|
|
}
|
|
|
|
}
|
2015-10-04 02:13:33 +08:00
|
|
|
|
2019-10-16 00:09:30 +08:00
|
|
|
static struct pci_bridge_emul_ops mvebu_pci_bridge_emul_ops = {
|
2018-10-18 23:37:18 +08:00
|
|
|
.write_base = mvebu_pci_bridge_emul_base_conf_write,
|
|
|
|
.read_pcie = mvebu_pci_bridge_emul_pcie_conf_read,
|
|
|
|
.write_pcie = mvebu_pci_bridge_emul_pcie_conf_write,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the configuration space of the PCI-to-PCI bridge
|
|
|
|
* associated with the given PCIe interface.
|
|
|
|
*/
|
|
|
|
static void mvebu_pci_bridge_emul_init(struct mvebu_pcie_port *port)
|
|
|
|
{
|
|
|
|
struct pci_bridge_emul *bridge = &port->bridge;
|
|
|
|
|
|
|
|
bridge->conf.vendor = PCI_VENDOR_ID_MARVELL;
|
|
|
|
bridge->conf.device = mvebu_readl(port, PCIE_DEV_ID_OFF) >> 16;
|
|
|
|
bridge->conf.class_revision =
|
|
|
|
mvebu_readl(port, PCIE_DEV_REV_OFF) & 0xff;
|
|
|
|
|
|
|
|
if (mvebu_has_ioport(port)) {
|
|
|
|
/* We support 32 bits I/O addressing */
|
|
|
|
bridge->conf.iobase = PCI_IO_RANGE_TYPE_32;
|
|
|
|
bridge->conf.iolimit = PCI_IO_RANGE_TYPE_32;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
2018-10-18 23:37:18 +08:00
|
|
|
bridge->has_pcie = true;
|
|
|
|
bridge->data = port;
|
|
|
|
bridge->ops = &mvebu_pci_bridge_emul_ops;
|
|
|
|
|
2019-02-20 17:48:41 +08:00
|
|
|
pci_bridge_emul_init(bridge, PCI_BRIDGE_EMUL_NO_PREFETCHABLE_BAR);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct mvebu_pcie *sys_to_pcie(struct pci_sys_data *sys)
|
|
|
|
{
|
|
|
|
return sys->private_data;
|
|
|
|
}
|
|
|
|
|
2014-04-19 08:13:49 +08:00
|
|
|
static struct mvebu_pcie_port *mvebu_pcie_find_port(struct mvebu_pcie *pcie,
|
|
|
|
struct pci_bus *bus,
|
|
|
|
int devfn)
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < pcie->nports; i++) {
|
|
|
|
struct mvebu_pcie_port *port = &pcie->ports[i];
|
2014-11-12 11:27:54 +08:00
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
if (bus->number == 0 && port->devfn == devfn)
|
|
|
|
return port;
|
|
|
|
if (bus->number != 0 &&
|
2018-10-18 23:37:18 +08:00
|
|
|
bus->number >= port->bridge.conf.secondary_bus &&
|
|
|
|
bus->number <= port->bridge.conf.subordinate_bus)
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
return port;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PCI configuration space write function */
|
|
|
|
static int mvebu_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
|
|
|
|
int where, int size, u32 val)
|
|
|
|
{
|
2018-08-03 22:38:47 +08:00
|
|
|
struct mvebu_pcie *pcie = bus->sysdata;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
struct mvebu_pcie_port *port;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
port = mvebu_pcie_find_port(pcie, bus, devfn);
|
|
|
|
if (!port)
|
|
|
|
return PCIBIOS_DEVICE_NOT_FOUND;
|
|
|
|
|
|
|
|
/* Access the emulated PCI-to-PCI bridge */
|
|
|
|
if (bus->number == 0)
|
2018-10-18 23:37:18 +08:00
|
|
|
return pci_bridge_emul_conf_write(&port->bridge, where,
|
|
|
|
size, val);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
2013-10-02 01:58:00 +08:00
|
|
|
if (!mvebu_pcie_link_up(port))
|
pci: mvebu: allow the enumeration of devices beyond physical bridges
Until now, the Marvell PCIe driver was only allowing the enumeration
of the devices in the secondary bus of the emulated PCI-to-PCI
bridge. This works fine when a PCIe device is directly connected into
a PCIe slot of the Marvell board.
However, when the device connected in the PCIe slot is a physical PCIe
bridge, beyond which a real PCIe device is connected, it no longer
worked, as the driver was preventing the Linux PCI core from seeing
such devices.
This commit fixes that by ensuring that configuration transactions on
subordinate busses are properly forwarded on the right PCIe interface.
Thanks to this patch, a PCIe card beyond a PCIe bridge, itself beyond
the emulated PCI-to-PCI bridge is properly detected, with the
following layout:
-[0000:00]-+-01.0-[01]----00.0
+-09.0-[02-07]----00.0-[03-07]--+-01.0-[04]--
| +-05.0-[05]--
| +-07.0-[06]--
| \-09.0-[07]----00.0
\-0a.0-[08]----00.0
Where the PCIe interface that sits beyond the emulated PCI-to-PCI
bridge at 09.0 allows to access the secondary bus 02, on which there
is a PCIe bridge that allows to access the 3 to 7 busses, that are
subordinates to this bridge. And on one of this bus (bus 7), there is
one real PCIe device connected.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-23 22:32:52 +08:00
|
|
|
return PCIBIOS_DEVICE_NOT_FOUND;
|
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
/* Access the real PCIe interface */
|
pci: mvebu: no longer fake the slot location of downstream devices
By default, the Marvell hardware, for each PCIe interface, exhibits
the following devices:
* On slot 0, a "Marvell Memory controller", identical on all PCIe
interfaces, and which isn't useful when the Marvell SoC is the PCIe
root complex (i.e, the normal case when we run Linux on the Marvell
SoC).
* On slot 1, the real PCIe card connected into the PCIe slot of the
board.
So, what the Marvell PCIe driver was doing in its PCI-to-PCI bridge
emulation is that when the Linux PCI core was trying to access the
device in slot 0, we were in fact forwarding the configuration
transaction to the device in slot 1. For all other slots, we were
telling the Linux PCI core that there was no device connected.
However, new versions of bootloaders from Marvell change the default
PCIe configuration, and make the real device appear in slot 0, and the
"Marvell Memory controller" in slot 1.
Therefore, this commit modifies the Marvell PCIe driver to adjust the
PCIe hardware configuration to make sure that this behavior (real
device in slot 0, "Marvell Memory controller" in slot 1) is the one
we'll see regardless of what the bootloader has done. It allows to
remove the little hack that was forwarding configuration transactions
on slot 0 to slot 1, which is nice.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-23 22:32:51 +08:00
|
|
|
ret = mvebu_pcie_hw_wr_conf(port, bus, devfn,
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
where, size, val);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PCI configuration space read function */
|
|
|
|
static int mvebu_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
|
|
|
|
int size, u32 *val)
|
|
|
|
{
|
2018-08-03 22:38:47 +08:00
|
|
|
struct mvebu_pcie *pcie = bus->sysdata;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
struct mvebu_pcie_port *port;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
port = mvebu_pcie_find_port(pcie, bus, devfn);
|
|
|
|
if (!port) {
|
|
|
|
*val = 0xffffffff;
|
|
|
|
return PCIBIOS_DEVICE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Access the emulated PCI-to-PCI bridge */
|
|
|
|
if (bus->number == 0)
|
2018-10-18 23:37:18 +08:00
|
|
|
return pci_bridge_emul_conf_read(&port->bridge, where,
|
|
|
|
size, val);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
2013-10-02 01:58:00 +08:00
|
|
|
if (!mvebu_pcie_link_up(port)) {
|
pci: mvebu: allow the enumeration of devices beyond physical bridges
Until now, the Marvell PCIe driver was only allowing the enumeration
of the devices in the secondary bus of the emulated PCI-to-PCI
bridge. This works fine when a PCIe device is directly connected into
a PCIe slot of the Marvell board.
However, when the device connected in the PCIe slot is a physical PCIe
bridge, beyond which a real PCIe device is connected, it no longer
worked, as the driver was preventing the Linux PCI core from seeing
such devices.
This commit fixes that by ensuring that configuration transactions on
subordinate busses are properly forwarded on the right PCIe interface.
Thanks to this patch, a PCIe card beyond a PCIe bridge, itself beyond
the emulated PCI-to-PCI bridge is properly detected, with the
following layout:
-[0000:00]-+-01.0-[01]----00.0
+-09.0-[02-07]----00.0-[03-07]--+-01.0-[04]--
| +-05.0-[05]--
| +-07.0-[06]--
| \-09.0-[07]----00.0
\-0a.0-[08]----00.0
Where the PCIe interface that sits beyond the emulated PCI-to-PCI
bridge at 09.0 allows to access the secondary bus 02, on which there
is a PCIe bridge that allows to access the 3 to 7 busses, that are
subordinates to this bridge. And on one of this bus (bus 7), there is
one real PCIe device connected.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-23 22:32:52 +08:00
|
|
|
*val = 0xffffffff;
|
|
|
|
return PCIBIOS_DEVICE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
/* Access the real PCIe interface */
|
pci: mvebu: no longer fake the slot location of downstream devices
By default, the Marvell hardware, for each PCIe interface, exhibits
the following devices:
* On slot 0, a "Marvell Memory controller", identical on all PCIe
interfaces, and which isn't useful when the Marvell SoC is the PCIe
root complex (i.e, the normal case when we run Linux on the Marvell
SoC).
* On slot 1, the real PCIe card connected into the PCIe slot of the
board.
So, what the Marvell PCIe driver was doing in its PCI-to-PCI bridge
emulation is that when the Linux PCI core was trying to access the
device in slot 0, we were in fact forwarding the configuration
transaction to the device in slot 1. For all other slots, we were
telling the Linux PCI core that there was no device connected.
However, new versions of bootloaders from Marvell change the default
PCIe configuration, and make the real device appear in slot 0, and the
"Marvell Memory controller" in slot 1.
Therefore, this commit modifies the Marvell PCIe driver to adjust the
PCIe hardware configuration to make sure that this behavior (real
device in slot 0, "Marvell Memory controller" in slot 1) is the one
we'll see regardless of what the bootloader has done. It allows to
remove the little hack that was forwarding configuration transactions
on slot 0 to slot 1, which is nice.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-23 22:32:51 +08:00
|
|
|
ret = mvebu_pcie_hw_rd_conf(port, bus, devfn,
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
where, size, val);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pci_ops mvebu_pcie_ops = {
|
|
|
|
.read = mvebu_pcie_rd_conf,
|
|
|
|
.write = mvebu_pcie_wr_conf,
|
|
|
|
};
|
|
|
|
|
2013-09-17 13:26:46 +08:00
|
|
|
static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
|
2014-04-19 08:13:49 +08:00
|
|
|
const struct resource *res,
|
|
|
|
resource_size_t start,
|
|
|
|
resource_size_t size,
|
|
|
|
resource_size_t align)
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
{
|
|
|
|
if (dev->bus->number != 0)
|
|
|
|
return start;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* On the PCI-to-PCI bridge side, the I/O windows must have at
|
2014-04-18 20:19:53 +08:00
|
|
|
* least a 64 KB size and the memory windows must have at
|
|
|
|
* least a 1 MB size. Moreover, MBus windows need to have a
|
|
|
|
* base address aligned on their size, and their size must be
|
|
|
|
* a power of two. This means that if the BAR doesn't have a
|
|
|
|
* power of two size, several MBus windows will actually be
|
|
|
|
* created. We need to ensure that the biggest MBus window
|
|
|
|
* (which will be the first one) is aligned on its size, which
|
|
|
|
* explains the rounddown_pow_of_two() being done here.
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
*/
|
|
|
|
if (res->flags & IORESOURCE_IO)
|
2014-04-18 20:19:53 +08:00
|
|
|
return round_up(start, max_t(resource_size_t, SZ_64K,
|
|
|
|
rounddown_pow_of_two(size)));
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
else if (res->flags & IORESOURCE_MEM)
|
2014-04-18 20:19:53 +08:00
|
|
|
return round_up(start, max_t(resource_size_t, SZ_1M,
|
|
|
|
rounddown_pow_of_two(size)));
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
else
|
|
|
|
return start;
|
|
|
|
}
|
|
|
|
|
2013-08-13 20:25:22 +08:00
|
|
|
static void __iomem *mvebu_pcie_map_registers(struct platform_device *pdev,
|
2014-04-19 08:13:49 +08:00
|
|
|
struct device_node *np,
|
|
|
|
struct mvebu_pcie_port *port)
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2020-06-23 14:03:35 +08:00
|
|
|
ret = of_address_to_resource(np, 0, &port->regs);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
if (ret)
|
2019-10-16 00:11:48 +08:00
|
|
|
return (void __iomem *)ERR_PTR(ret);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
2020-06-23 14:03:35 +08:00
|
|
|
return devm_ioremap_resource(&pdev->dev, &port->regs);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
2013-07-26 21:17:48 +08:00
|
|
|
#define DT_FLAGS_TO_TYPE(flags) (((flags) >> 24) & 0x03)
|
|
|
|
#define DT_TYPE_IO 0x1
|
|
|
|
#define DT_TYPE_MEM32 0x2
|
|
|
|
#define DT_CPUADDR_TO_TARGET(cpuaddr) (((cpuaddr) >> 56) & 0xFF)
|
|
|
|
#define DT_CPUADDR_TO_ATTR(cpuaddr) (((cpuaddr) >> 48) & 0xFF)
|
|
|
|
|
|
|
|
static int mvebu_get_tgt_attr(struct device_node *np, int devfn,
|
2013-11-27 02:02:55 +08:00
|
|
|
unsigned long type,
|
|
|
|
unsigned int *tgt,
|
|
|
|
unsigned int *attr)
|
2013-07-26 21:17:48 +08:00
|
|
|
{
|
|
|
|
const int na = 3, ns = 2;
|
|
|
|
const __be32 *range;
|
|
|
|
int rlen, nranges, rangesz, pna, i;
|
|
|
|
|
2013-11-27 02:02:55 +08:00
|
|
|
*tgt = -1;
|
|
|
|
*attr = -1;
|
|
|
|
|
2013-07-26 21:17:48 +08:00
|
|
|
range = of_get_property(np, "ranges", &rlen);
|
|
|
|
if (!range)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
pna = of_n_addr_cells(np);
|
|
|
|
rangesz = pna + na + ns;
|
|
|
|
nranges = rlen / sizeof(__be32) / rangesz;
|
|
|
|
|
2014-09-17 23:58:27 +08:00
|
|
|
for (i = 0; i < nranges; i++, range += rangesz) {
|
2013-07-26 21:17:48 +08:00
|
|
|
u32 flags = of_read_number(range, 1);
|
2014-02-15 02:46:15 +08:00
|
|
|
u32 slot = of_read_number(range + 1, 1);
|
2013-07-26 21:17:48 +08:00
|
|
|
u64 cpuaddr = of_read_number(range + na, pna);
|
|
|
|
unsigned long rtype;
|
|
|
|
|
|
|
|
if (DT_FLAGS_TO_TYPE(flags) == DT_TYPE_IO)
|
|
|
|
rtype = IORESOURCE_IO;
|
|
|
|
else if (DT_FLAGS_TO_TYPE(flags) == DT_TYPE_MEM32)
|
|
|
|
rtype = IORESOURCE_MEM;
|
2014-09-17 23:58:27 +08:00
|
|
|
else
|
|
|
|
continue;
|
2013-07-26 21:17:48 +08:00
|
|
|
|
|
|
|
if (slot == PCI_SLOT(devfn) && type == rtype) {
|
|
|
|
*tgt = DT_CPUADDR_TO_TARGET(cpuaddr);
|
|
|
|
*attr = DT_CPUADDR_TO_ATTR(cpuaddr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
|
2016-03-16 17:59:41 +08:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
2015-03-17 22:55:45 +08:00
|
|
|
static int mvebu_pcie_suspend(struct device *dev)
|
|
|
|
{
|
|
|
|
struct mvebu_pcie *pcie;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
pcie = dev_get_drvdata(dev);
|
|
|
|
for (i = 0; i < pcie->nports; i++) {
|
|
|
|
struct mvebu_pcie_port *port = pcie->ports + i;
|
|
|
|
port->saved_pcie_stat = mvebu_readl(port, PCIE_STAT_OFF);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int mvebu_pcie_resume(struct device *dev)
|
|
|
|
{
|
|
|
|
struct mvebu_pcie *pcie;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
pcie = dev_get_drvdata(dev);
|
|
|
|
for (i = 0; i < pcie->nports; i++) {
|
|
|
|
struct mvebu_pcie_port *port = pcie->ports + i;
|
|
|
|
mvebu_writel(port, port->saved_pcie_stat, PCIE_STAT_OFF);
|
|
|
|
mvebu_pcie_setup_hw(port);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-03-16 17:59:41 +08:00
|
|
|
#endif
|
2015-03-17 22:55:45 +08:00
|
|
|
|
2015-10-04 02:13:02 +08:00
|
|
|
static void mvebu_pcie_port_clk_put(void *data)
|
|
|
|
{
|
|
|
|
struct mvebu_pcie_port *port = data;
|
|
|
|
|
|
|
|
clk_put(port->clk);
|
|
|
|
}
|
|
|
|
|
2015-10-04 02:12:57 +08:00
|
|
|
static int mvebu_pcie_parse_port(struct mvebu_pcie *pcie,
|
|
|
|
struct mvebu_pcie_port *port, struct device_node *child)
|
|
|
|
{
|
|
|
|
struct device *dev = &pcie->pdev->dev;
|
|
|
|
enum of_gpio_flags flags;
|
2015-10-04 02:13:22 +08:00
|
|
|
int reset_gpio, ret;
|
2015-10-04 02:12:57 +08:00
|
|
|
|
|
|
|
port->pcie = pcie;
|
|
|
|
|
|
|
|
if (of_property_read_u32(child, "marvell,pcie-port", &port->port)) {
|
2017-07-19 05:43:21 +08:00
|
|
|
dev_warn(dev, "ignoring %pOF, missing pcie-port property\n",
|
|
|
|
child);
|
2015-10-04 02:12:57 +08:00
|
|
|
goto skip;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (of_property_read_u32(child, "marvell,pcie-lane", &port->lane))
|
|
|
|
port->lane = 0;
|
|
|
|
|
2015-10-04 02:13:02 +08:00
|
|
|
port->name = devm_kasprintf(dev, GFP_KERNEL, "pcie%d.%d", port->port,
|
|
|
|
port->lane);
|
|
|
|
if (!port->name) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err;
|
|
|
|
}
|
2015-10-04 02:12:57 +08:00
|
|
|
|
|
|
|
port->devfn = of_pci_get_devfn(child);
|
|
|
|
if (port->devfn < 0)
|
|
|
|
goto skip;
|
|
|
|
|
|
|
|
ret = mvebu_get_tgt_attr(dev->of_node, port->devfn, IORESOURCE_MEM,
|
|
|
|
&port->mem_target, &port->mem_attr);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(dev, "%s: cannot get tgt/attr for mem window\n",
|
|
|
|
port->name);
|
|
|
|
goto skip;
|
|
|
|
}
|
|
|
|
|
2015-10-04 02:13:02 +08:00
|
|
|
if (resource_size(&pcie->io) != 0) {
|
2015-10-04 02:12:57 +08:00
|
|
|
mvebu_get_tgt_attr(dev->of_node, port->devfn, IORESOURCE_IO,
|
|
|
|
&port->io_target, &port->io_attr);
|
2015-10-04 02:13:02 +08:00
|
|
|
} else {
|
2015-10-04 02:12:57 +08:00
|
|
|
port->io_target = -1;
|
|
|
|
port->io_attr = -1;
|
|
|
|
}
|
|
|
|
|
2015-10-04 02:13:22 +08:00
|
|
|
reset_gpio = of_get_named_gpio_flags(child, "reset-gpios", 0, &flags);
|
|
|
|
if (reset_gpio == -EPROBE_DEFER) {
|
|
|
|
ret = reset_gpio;
|
2015-10-04 02:13:02 +08:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2015-10-04 02:13:22 +08:00
|
|
|
if (gpio_is_valid(reset_gpio)) {
|
|
|
|
unsigned long gpio_flags;
|
|
|
|
|
2015-10-04 02:13:02 +08:00
|
|
|
port->reset_name = devm_kasprintf(dev, GFP_KERNEL, "%s-reset",
|
|
|
|
port->name);
|
|
|
|
if (!port->reset_name) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto err;
|
|
|
|
}
|
2015-10-04 02:12:57 +08:00
|
|
|
|
2015-10-04 02:13:22 +08:00
|
|
|
if (flags & OF_GPIO_ACTIVE_LOW) {
|
2017-07-19 05:43:21 +08:00
|
|
|
dev_info(dev, "%pOF: reset gpio is active low\n",
|
|
|
|
child);
|
2015-10-04 02:13:22 +08:00
|
|
|
gpio_flags = GPIOF_ACTIVE_LOW |
|
|
|
|
GPIOF_OUT_INIT_LOW;
|
|
|
|
} else {
|
|
|
|
gpio_flags = GPIOF_OUT_INIT_HIGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = devm_gpio_request_one(dev, reset_gpio, gpio_flags,
|
|
|
|
port->reset_name);
|
2015-10-04 02:12:57 +08:00
|
|
|
if (ret) {
|
|
|
|
if (ret == -EPROBE_DEFER)
|
|
|
|
goto err;
|
|
|
|
goto skip;
|
|
|
|
}
|
2015-10-04 02:13:22 +08:00
|
|
|
|
|
|
|
port->reset_gpio = gpio_to_desc(reset_gpio);
|
2015-10-04 02:12:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
port->clk = of_clk_get_by_name(child, NULL);
|
|
|
|
if (IS_ERR(port->clk)) {
|
|
|
|
dev_err(dev, "%s: cannot get clock\n", port->name);
|
|
|
|
goto skip;
|
|
|
|
}
|
|
|
|
|
2015-10-04 02:13:02 +08:00
|
|
|
ret = devm_add_action(dev, mvebu_pcie_port_clk_put, port);
|
|
|
|
if (ret < 0) {
|
|
|
|
clk_put(port->clk);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2015-10-04 02:12:57 +08:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
skip:
|
|
|
|
ret = 0;
|
2015-10-04 02:13:02 +08:00
|
|
|
|
|
|
|
/* In the case of skipping, we need to free these */
|
|
|
|
devm_kfree(dev, port->reset_name);
|
|
|
|
port->reset_name = NULL;
|
|
|
|
devm_kfree(dev, port->name);
|
|
|
|
port->name = NULL;
|
|
|
|
|
2015-10-04 02:12:57 +08:00
|
|
|
err:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-10-04 02:13:27 +08:00
|
|
|
/*
|
|
|
|
* Power up a PCIe port. PCIe requires the refclk to be stable for 100µs
|
|
|
|
* prior to releasing PERST. See table 2-4 in section 2.6.2 AC Specifications
|
|
|
|
* of the PCI Express Card Electromechanical Specification, 1.1.
|
|
|
|
*/
|
|
|
|
static int mvebu_pcie_powerup(struct mvebu_pcie_port *port)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = clk_prepare_enable(port->clk);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (port->reset_gpio) {
|
2017-02-03 01:15:31 +08:00
|
|
|
u32 reset_udelay = PCI_PM_D3COLD_WAIT * 1000;
|
2015-10-04 02:13:27 +08:00
|
|
|
|
|
|
|
of_property_read_u32(port->dn, "reset-delay-us",
|
|
|
|
&reset_udelay);
|
|
|
|
|
|
|
|
udelay(100);
|
|
|
|
|
|
|
|
gpiod_set_value_cansleep(port->reset_gpio, 0);
|
|
|
|
msleep(reset_udelay / 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Power down a PCIe port. Strictly, PCIe requires us to place the card
|
|
|
|
* in D3hot state before asserting PERST#.
|
|
|
|
*/
|
|
|
|
static void mvebu_pcie_powerdown(struct mvebu_pcie_port *port)
|
|
|
|
{
|
2017-07-17 05:16:13 +08:00
|
|
|
gpiod_set_value_cansleep(port->reset_gpio, 1);
|
2015-10-04 02:13:27 +08:00
|
|
|
|
|
|
|
clk_disable_unprepare(port->clk);
|
|
|
|
}
|
|
|
|
|
2018-08-03 22:38:47 +08:00
|
|
|
/*
|
2020-10-23 22:52:52 +08:00
|
|
|
* devm_of_pci_get_host_bridge_resources() only sets up translateable resources,
|
|
|
|
* so we need extra resource setup parsing our special DT properties encoding
|
|
|
|
* the MEM and IO apertures.
|
2018-08-03 22:38:47 +08:00
|
|
|
*/
|
|
|
|
static int mvebu_pcie_parse_request_resources(struct mvebu_pcie *pcie)
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
{
|
2018-08-03 22:38:47 +08:00
|
|
|
struct device *dev = &pcie->pdev->dev;
|
2020-05-23 07:48:19 +08:00
|
|
|
struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie);
|
2018-08-03 22:38:47 +08:00
|
|
|
int ret;
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
2018-08-03 22:38:47 +08:00
|
|
|
/* Get the PCIe memory aperture */
|
2013-07-26 21:17:48 +08:00
|
|
|
mvebu_mbus_get_pcie_mem_aperture(&pcie->mem);
|
|
|
|
if (resource_size(&pcie->mem) == 0) {
|
2016-10-07 02:38:58 +08:00
|
|
|
dev_err(dev, "invalid memory aperture size\n");
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
return -EINVAL;
|
2013-07-26 21:17:48 +08:00
|
|
|
}
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
2018-08-03 22:38:47 +08:00
|
|
|
pcie->mem.name = "PCI MEM";
|
2020-05-23 07:48:19 +08:00
|
|
|
pci_add_resource(&bridge->windows, &pcie->mem);
|
2020-10-23 22:52:52 +08:00
|
|
|
ret = devm_request_resource(dev, &iomem_resource, &pcie->mem);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2018-08-03 22:38:47 +08:00
|
|
|
|
|
|
|
/* Get the PCIe IO aperture */
|
2013-07-26 21:17:48 +08:00
|
|
|
mvebu_mbus_get_pcie_io_aperture(&pcie->io);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
2013-11-27 02:02:55 +08:00
|
|
|
if (resource_size(&pcie->io) != 0) {
|
|
|
|
pcie->realio.flags = pcie->io.flags;
|
|
|
|
pcie->realio.start = PCIBIOS_MIN_IO;
|
|
|
|
pcie->realio.end = min_t(resource_size_t,
|
2018-08-03 22:38:46 +08:00
|
|
|
IO_SPACE_LIMIT - SZ_64K,
|
2018-08-03 22:38:44 +08:00
|
|
|
resource_size(&pcie->io) - 1);
|
2018-08-03 22:38:47 +08:00
|
|
|
pcie->realio.name = "PCI I/O";
|
2018-08-03 22:38:45 +08:00
|
|
|
|
2020-05-23 07:48:19 +08:00
|
|
|
pci_add_resource(&bridge->windows, &pcie->realio);
|
2020-10-23 22:52:52 +08:00
|
|
|
ret = devm_request_resource(dev, &ioport_resource, &pcie->realio);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2018-10-01 20:49:34 +08:00
|
|
|
}
|
|
|
|
|
2020-10-23 22:52:52 +08:00
|
|
|
return 0;
|
2018-10-01 20:49:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is a copy of pci_host_probe(), except that it does the I/O
|
|
|
|
* remap as the last step, once we are sure we won't fail.
|
|
|
|
*
|
|
|
|
* It should be removed once the I/O remap error handling issue has
|
|
|
|
* been sorted out.
|
|
|
|
*/
|
|
|
|
static int mvebu_pci_host_probe(struct pci_host_bridge *bridge)
|
|
|
|
{
|
|
|
|
struct mvebu_pcie *pcie;
|
|
|
|
struct pci_bus *bus, *child;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = pci_scan_root_bus_bridge(bridge);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(bridge->dev.parent, "Scanning root bridge failed");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
pcie = pci_host_bridge_priv(bridge);
|
|
|
|
if (resource_size(&pcie->io) != 0) {
|
|
|
|
unsigned int i;
|
|
|
|
|
2018-08-03 22:38:46 +08:00
|
|
|
for (i = 0; i < resource_size(&pcie->realio); i += SZ_64K)
|
2018-08-03 22:38:45 +08:00
|
|
|
pci_ioremap_io(i, pcie->io.start + i);
|
2018-10-01 20:49:34 +08:00
|
|
|
}
|
2013-07-26 21:17:48 +08:00
|
|
|
|
2018-10-01 20:49:34 +08:00
|
|
|
bus = bridge->bus;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We insert PCI resources into the iomem_resource and
|
|
|
|
* ioport_resource trees in either pci_bus_claim_resources()
|
|
|
|
* or pci_bus_assign_resources().
|
|
|
|
*/
|
|
|
|
if (pci_has_flag(PCI_PROBE_ONLY)) {
|
|
|
|
pci_bus_claim_resources(bus);
|
|
|
|
} else {
|
|
|
|
pci_bus_size_bridges(bus);
|
|
|
|
pci_bus_assign_resources(bus);
|
|
|
|
|
|
|
|
list_for_each_entry(child, &bus->children, node)
|
|
|
|
pcie_bus_configure_settings(child);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
2018-10-01 20:49:34 +08:00
|
|
|
pci_bus_add_devices(bus);
|
|
|
|
return 0;
|
2018-08-03 22:38:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int mvebu_pcie_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct device *dev = &pdev->dev;
|
|
|
|
struct mvebu_pcie *pcie;
|
|
|
|
struct pci_host_bridge *bridge;
|
|
|
|
struct device_node *np = dev->of_node;
|
|
|
|
struct device_node *child;
|
|
|
|
int num, i, ret;
|
|
|
|
|
|
|
|
bridge = devm_pci_alloc_host_bridge(dev, sizeof(struct mvebu_pcie));
|
|
|
|
if (!bridge)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
pcie = pci_host_bridge_priv(bridge);
|
|
|
|
pcie->pdev = pdev;
|
|
|
|
platform_set_drvdata(pdev, pcie);
|
|
|
|
|
|
|
|
ret = mvebu_pcie_parse_request_resources(pcie);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2016-10-12 12:19:05 +08:00
|
|
|
num = of_get_available_child_count(np);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
2016-10-07 02:38:58 +08:00
|
|
|
pcie->ports = devm_kcalloc(dev, num, sizeof(*pcie->ports), GFP_KERNEL);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
if (!pcie->ports)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
i = 0;
|
2016-10-12 12:19:05 +08:00
|
|
|
for_each_available_child_of_node(np, child) {
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
struct mvebu_pcie_port *port = &pcie->ports[i];
|
|
|
|
|
2015-10-04 02:12:57 +08:00
|
|
|
ret = mvebu_pcie_parse_port(pcie, port, child);
|
2015-10-04 02:13:02 +08:00
|
|
|
if (ret < 0) {
|
|
|
|
of_node_put(child);
|
2015-10-04 02:12:57 +08:00
|
|
|
return ret;
|
2015-10-04 02:13:02 +08:00
|
|
|
} else if (ret == 0) {
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
continue;
|
2015-10-04 02:13:02 +08:00
|
|
|
}
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
|
2015-10-04 02:13:07 +08:00
|
|
|
port->dn = child;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
pcie->nports = i;
|
|
|
|
|
|
|
|
for (i = 0; i < pcie->nports; i++) {
|
|
|
|
struct mvebu_pcie_port *port = &pcie->ports[i];
|
|
|
|
|
|
|
|
child = port->dn;
|
|
|
|
if (!child)
|
|
|
|
continue;
|
|
|
|
|
2015-10-04 02:13:27 +08:00
|
|
|
ret = mvebu_pcie_powerup(port);
|
|
|
|
if (ret < 0)
|
2013-08-13 20:25:20 +08:00
|
|
|
continue;
|
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
port->base = mvebu_pcie_map_registers(pdev, child, port);
|
2013-06-17 17:16:13 +08:00
|
|
|
if (IS_ERR(port->base)) {
|
2016-10-07 02:38:58 +08:00
|
|
|
dev_err(dev, "%s: cannot map registers\n", port->name);
|
2013-06-17 17:16:13 +08:00
|
|
|
port->base = NULL;
|
2015-10-04 02:13:27 +08:00
|
|
|
mvebu_pcie_powerdown(port);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-08-03 22:38:47 +08:00
|
|
|
mvebu_pcie_setup_hw(port);
|
pci: mvebu: no longer fake the slot location of downstream devices
By default, the Marvell hardware, for each PCIe interface, exhibits
the following devices:
* On slot 0, a "Marvell Memory controller", identical on all PCIe
interfaces, and which isn't useful when the Marvell SoC is the PCIe
root complex (i.e, the normal case when we run Linux on the Marvell
SoC).
* On slot 1, the real PCIe card connected into the PCIe slot of the
board.
So, what the Marvell PCIe driver was doing in its PCI-to-PCI bridge
emulation is that when the Linux PCI core was trying to access the
device in slot 0, we were in fact forwarding the configuration
transaction to the device in slot 1. For all other slots, we were
telling the Linux PCI core that there was no device connected.
However, new versions of bootloaders from Marvell change the default
PCIe configuration, and make the real device appear in slot 0, and the
"Marvell Memory controller" in slot 1.
Therefore, this commit modifies the Marvell PCIe driver to adjust the
PCIe hardware configuration to make sure that this behavior (real
device in slot 0, "Marvell Memory controller" in slot 1) is the one
we'll see regardless of what the bootloader has done. It allows to
remove the little hack that was forwarding configuration transactions
on slot 0 to slot 1, which is nice.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-23 22:32:51 +08:00
|
|
|
mvebu_pcie_set_local_dev_nr(port, 1);
|
2018-10-18 23:37:18 +08:00
|
|
|
mvebu_pci_bridge_emul_init(port);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
2013-08-13 20:25:21 +08:00
|
|
|
pcie->nports = i;
|
2013-12-26 23:52:41 +08:00
|
|
|
|
2018-08-03 22:38:47 +08:00
|
|
|
bridge->sysdata = pcie;
|
|
|
|
bridge->ops = &mvebu_pcie_ops;
|
|
|
|
bridge->align_resource = mvebu_pcie_align_resource;
|
|
|
|
|
2018-10-01 20:49:34 +08:00
|
|
|
return mvebu_pci_host_probe(bridge);
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct of_device_id mvebu_pcie_of_match_table[] = {
|
|
|
|
{ .compatible = "marvell,armada-xp-pcie", },
|
|
|
|
{ .compatible = "marvell,armada-370-pcie", },
|
2013-08-13 20:25:24 +08:00
|
|
|
{ .compatible = "marvell,dove-pcie", },
|
2013-05-15 21:36:54 +08:00
|
|
|
{ .compatible = "marvell,kirkwood-pcie", },
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
{},
|
|
|
|
};
|
|
|
|
|
2016-03-16 17:59:40 +08:00
|
|
|
static const struct dev_pm_ops mvebu_pcie_pm_ops = {
|
2016-03-16 17:59:41 +08:00
|
|
|
SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(mvebu_pcie_suspend, mvebu_pcie_resume)
|
2015-03-17 22:55:45 +08:00
|
|
|
};
|
|
|
|
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
static struct platform_driver mvebu_pcie_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = "mvebu-pcie",
|
2013-12-19 17:04:59 +08:00
|
|
|
.of_match_table = mvebu_pcie_of_match_table,
|
2013-08-13 20:25:22 +08:00
|
|
|
/* driver unloading/unbinding currently not supported */
|
|
|
|
.suppress_bind_attrs = true,
|
2015-03-17 22:55:45 +08:00
|
|
|
.pm = &mvebu_pcie_pm_ops,
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
},
|
2013-08-13 20:25:22 +08:00
|
|
|
.probe = mvebu_pcie_probe,
|
pci: PCIe driver for Marvell Armada 370/XP systems
This driver implements the support for the PCIe interfaces on the
Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to
cover earlier families of Marvell SoCs, such as Dove, Orion and
Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI
code to setup PCI devices and get their corresponding IRQs, and the
pci_ops operations that are used by the PCI core to read/write the
configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and
not linked together in a bus, this driver sets up an emulated PCI host
bridge, with one PCI-to-PCI bridge as child for each hardware PCIe
interface.
In addition, this driver enumerates the different PCIe slots, and for
those having a device plugged in, it sets up the necessary address
decoding windows, using the mvebu-mbus driver.
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jason Cooper <jason@lakedaemon.net>
2013-05-16 23:55:22 +08:00
|
|
|
};
|
2016-07-03 07:13:28 +08:00
|
|
|
builtin_platform_driver(mvebu_pcie_driver);
|