37#include <sys/devmap.h>
39#include <sys/kernel.h>
40#include <sys/malloc.h>
41#include <sys/module.h>
44#include <sys/sysctl.h>
46#include <machine/bus.h>
47#include <machine/intr.h>
48#include <machine/resource.h>
50#include <dev/extres/clk/clk.h>
51#include <dev/extres/phy/phy.h>
52#include <dev/ofw/ofw_bus.h>
53#include <dev/ofw/ofw_bus_subr.h>
54#include <dev/ofw/ofw_pci.h>
55#include <dev/ofw/ofwpci.h>
64#define MV_GLOBAL_CONTROL_REG 0x8000
65#define PCIE_APP_LTSSM_EN (1 << 2)
67#define MV_GLOBAL_STATUS_REG 0x8008
68#define MV_STATUS_RDLH_LINK_UP (1 << 1)
69#define MV_STATUS_PHY_LINK_UP (1 << 9)
71#define MV_INT_CAUSE1 0x801C
72#define MV_INT_MASK1 0x8020
73#define INT_A_ASSERT_MASK (1 << 9)
74#define INT_B_ASSERT_MASK (1 << 10)
75#define INT_C_ASSERT_MASK (1 << 11)
76#define INT_D_ASSERT_MASK (1 << 12)
78#define MV_INT_CAUSE2 0x8024
79#define MV_INT_MASK2 0x8028
80#define MV_ERR_INT_CAUSE 0x802C
81#define MV_ERR_INT_MASK 0x8030
83#define MV_ARCACHE_TRC_REG 0x8050
84#define MV_AWCACHE_TRC_REG 0x8054
85#define MV_ARUSER_REG 0x805C
86#define MV_AWUSER_REG 0x8060
102 {
"marvell,armada8k-pcie", 1},
112 rv = phy_get_by_ofw_idx(sc->
dev, sc->
node, i, &(sc->
phy[i]));
113 if (rv != 0 && rv != ENOENT) {
114 device_printf(sc->
dev,
"Cannot get phy[%d]\n", i);
122 if (sc->
phy[i] == NULL)
124 rv = phy_enable(sc->
phy[i]);
126 device_printf(sc->
dev,
"Cannot enable phy[%d]\n", i);
134 if (sc->
phy[i] == NULL)
136 phy_release(sc->
phy[i]);
181 uint32_t cause1, cause2;
189 return (FILTER_HANDLED);
211 if (!ofw_bus_status_okay(
dev))
217 device_set_desc(
dev,
"Marvell Armada8K PCI-E Controller");
218 return (BUS_PROBE_DEFAULT);
229 sc = device_get_softc(
dev);
238 device_printf(
dev,
"Cannot allocate DBI memory\n");
246 RF_ACTIVE | RF_SHAREABLE);
248 device_printf(
dev,
"Cannot allocate IRQ resources\n");
254 rv = clk_get_by_ofw_name(sc->
dev, 0,
"core", &sc->
clk_core);
256 device_printf(sc->
dev,
"Cannot get 'core' clock\n");
261 rv = clk_get_by_ofw_name(sc->
dev, 0,
"reg", &sc->
clk_reg);
263 device_printf(sc->
dev,
"Cannot get 'reg' clock\n");
270 device_printf(sc->
dev,
"Cannot enable 'core' clock\n");
277 device_printf(sc->
dev,
"Cannot enable 'reg' clock\n");
293 if (bus_setup_intr(
dev, sc->
irq_res, INTR_TYPE_MISC | INTR_MPSAFE,
295 device_printf(
dev,
"cannot setup interrupt handler\n");
300 return (bus_generic_attach(
dev));
int pci_dw_init(device_t dev)
#define DW_MSI_INTR0_MASK
static void pci_dw_dbi_wr4(device_t dev, u_int reg, uint32_t val)
static uint32_t pci_dw_dbi_rd4(device_t dev, u_int reg)
#define INT_B_ASSERT_MASK
static device_method_t pci_mv_methods[]
static int pci_mv_intr(void *arg)
#define INT_A_ASSERT_MASK
static void pci_mv_init(struct pci_mv_softc *sc)
#define MV_STATUS_RDLH_LINK_UP
static int pci_mv_phy_init(struct pci_mv_softc *sc)
DRIVER_MODULE(pci_mv, simplebus, pci_mv_driver, pci_mv_devclass, NULL, NULL)
static int pci_mv_probe(device_t dev)
DEFINE_CLASS_1(pcib, pci_mv_driver, pci_mv_methods, sizeof(struct pci_mv_softc), pci_dw_driver)
static devclass_t pci_mv_devclass
static int pci_mv_attach(device_t dev)
#define MV_GLOBAL_STATUS_REG
#define MV_ARCACHE_TRC_REG
#define INT_D_ASSERT_MASK
#define MV_AWCACHE_TRC_REG
#define MV_GLOBAL_CONTROL_REG
static struct ofw_compat_data compat_data[]
#define INT_C_ASSERT_MASK
#define MV_STATUS_PHY_LINK_UP
static int pci_mv_get_link(device_t dev, bool *status)
struct resource * dbi_res
struct resource * irq_res
struct pci_dw_softc dw_sc