FreeBSD kernel amd64 PCI device code
|
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
#include <sys/proc.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/rman.h>
#include <machine/bus.h>
#include <machine/intr.h>
#include <machine/resource.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/ofw/ofw_pci.h>
#include <dev/ofw/ofwpci.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcib_private.h>
#include <dev/pci/pci_dw.h>
#include "pcib_if.h"
#include "pci_dw_if.h"
Go to the source code of this file.
Macros | |
#define | debugf(fmt, args...) |
#define | DBI_WR1(sc, reg, val) pci_dw_dbi_wr1((sc)->dev, reg, val) |
#define | DBI_WR2(sc, reg, val) pci_dw_dbi_wr2((sc)->dev, reg, val) |
#define | DBI_WR4(sc, reg, val) pci_dw_dbi_wr4((sc)->dev, reg, val) |
#define | DBI_RD1(sc, reg) pci_dw_dbi_rd1((sc)->dev, reg) |
#define | DBI_RD2(sc, reg) pci_dw_dbi_rd2((sc)->dev, reg) |
#define | DBI_RD4(sc, reg) pci_dw_dbi_rd4((sc)->dev, reg) |
#define | IATU_UR_WR4(sc, reg, val) bus_write_4((sc)->iatu_ur_res, (sc)->iatu_ur_offset + (reg), (val)) |
#define | IATU_UR_RD4(sc, reg) bus_read_4((sc)->iatu_ur_res, (sc)->iatu_ur_offset + (reg)) |
#define | PCI_BUS_SHIFT 20 |
#define | PCI_SLOT_SHIFT 15 |
#define | PCI_FUNC_SHIFT 12 |
#define | PCI_BUS_MASK 0xFF |
#define | PCI_SLOT_MASK 0x1F |
#define | PCI_FUNC_MASK 0x07 |
#define | PCI_REG_MASK 0xFFF |
#define | IATU_CFG_BUS(bus) ((uint64_t)((bus) & 0xff) << 24) |
#define | IATU_CFG_SLOT(slot) ((uint64_t)((slot) & 0x1f) << 19) |
#define | IATU_CFG_FUNC(func) ((uint64_t)((func) & 0x07) << 16) |
Functions | |
__FBSDID ("$FreeBSD$") | |
static uint32_t | pci_dw_dbi_read (device_t dev, u_int reg, int width) |
static void | pci_dw_dbi_write (device_t dev, u_int reg, uint32_t val, int width) |
static void | pci_dw_dbi_protect (struct pci_dw_softc *sc, bool protect) |
static bool | pci_dw_check_dev (struct pci_dw_softc *sc, u_int bus, u_int slot, u_int func, u_int reg) |
static bool | pci_dw_detect_atu_unroll (struct pci_dw_softc *sc) |
static int | pci_dw_detect_out_atu_regions_unroll (struct pci_dw_softc *sc) |
static int | pci_dw_detect_out_atu_regions_legacy (struct pci_dw_softc *sc) |
static int | pci_dw_detect_out_atu_regions (struct pci_dw_softc *sc) |
static int | pci_dw_map_out_atu_unroll (struct pci_dw_softc *sc, int idx, int type, uint64_t pa, uint64_t pci_addr, uint32_t size) |
static int | pci_dw_map_out_atu_legacy (struct pci_dw_softc *sc, int idx, int type, uint64_t pa, uint64_t pci_addr, uint32_t size) |
static int | pci_dw_map_out_atu (struct pci_dw_softc *sc, int idx, int type, uint64_t pa, uint64_t pci_addr, uint32_t size) |
static int | pci_dw_setup_hw (struct pci_dw_softc *sc) |
static int | pci_dw_decode_ranges (struct pci_dw_softc *sc, struct ofw_pci_range *ranges, int nranges) |
static uint32_t | pci_dw_read_config (device_t dev, u_int bus, u_int slot, u_int func, u_int reg, int bytes) |
static void | pci_dw_write_config (device_t dev, u_int bus, u_int slot, u_int func, u_int reg, uint32_t val, int bytes) |
static int | pci_dw_alloc_msi (device_t pci, device_t child, int count, int maxcount, int *irqs) |
static int | pci_dw_release_msi (device_t pci, device_t child, int count, int *irqs) |
static int | pci_dw_map_msi (device_t pci, device_t child, int irq, uint64_t *addr, uint32_t *data) |
static int | pci_dw_alloc_msix (device_t pci, device_t child, int *irq) |
static int | pci_dw_release_msix (device_t pci, device_t child, int irq) |
static int | pci_dw_get_id (device_t pci, device_t child, enum pci_id_type type, uintptr_t *id) |
static bus_dma_tag_t | pci_dw_get_dma_tag (device_t dev, device_t child) |
int | pci_dw_init (device_t dev) |
DEFINE_CLASS_1 (pcib, pci_dw_driver, pci_dw_methods, sizeof(struct pci_dw_softc), ofw_pcib_driver) | |
Variables | |
static device_method_t | pci_dw_methods [] |
__FBSDID | ( | "$FreeBSD$" | ) |
DEFINE_CLASS_1 | ( | pcib | , |
pci_dw_driver | , | ||
pci_dw_methods | , | ||
sizeof(struct pci_dw_softc) | , | ||
ofw_pcib_driver | |||
) |
|
static |
|
static |
|
static |
Definition at line 151 of file pci_dw.c.
References bus, pci_dw_softc::bus_end, pci_dw_softc::bus_start, pci_dw_softc::dev, func, PCI_FUNCMAX, PCI_SLOTMAX, PCIE_REGMAX, reg, pci_dw_softc::root_bus, slot, and status.
Referenced by pci_dw_read_config(), and pci_dw_write_config().
|
static |
Definition at line 138 of file pci_dw.c.
References DBI_RD4, DBI_RO_WR_EN, DBI_WR4, DW_MISC_CONTROL_1, and reg.
Referenced by pci_dw_setup_hw().
|
static |
Definition at line 93 of file pci_dw.c.
References pci_dw_softc::dbi_res, pci_dw_softc::dev, dev, reg, and width.
|
static |
Definition at line 114 of file pci_dw.c.
References pci_dw_softc::dbi_res, pci_dw_softc::dev, dev, reg, val, and width.
|
static |
Definition at line 434 of file pci_dw.c.
References pci_dw_softc::dev, pci_dw_softc::io_range, pci_dw_softc::mem_ranges, and pci_dw_softc::num_mem_ranges.
Referenced by pci_dw_init().
|
static |
Definition at line 176 of file pci_dw.c.
References DBI_RD4, and DW_IATU_VIEWPORT.
Referenced by pci_dw_init().
|
static |
Definition at line 238 of file pci_dw.c.
References pci_dw_softc::iatu_ur_res, pci_dw_detect_out_atu_regions_legacy(), and pci_dw_detect_out_atu_regions_unroll().
Referenced by pci_dw_init().
|
static |
Definition at line 203 of file pci_dw.c.
References DBI_RD4, DBI_WR4, pci_dw_softc::dev, DW_IATU_LWR_TARGET_ADDR, DW_IATU_VIEWPORT, IATU_REGION_INDEX, pci_dw_softc::num_out_regions, and reg.
Referenced by pci_dw_detect_out_atu_regions().
|
static |
Definition at line 182 of file pci_dw.c.
References DW_IATU_UR_REG, DW_IATU_UR_STEP, IATU_UR_RD4, pci_dw_softc::iatu_ur_size, IATU_UR_WR4, pci_dw_softc::num_out_regions, and reg.
Referenced by pci_dw_detect_out_atu_regions().
|
static |
Definition at line 696 of file pci_dw.c.
References dev, and pci_dw_softc::dmat.
|
static |
Definition at line 669 of file pci_dw.c.
References child, pci, PCI_ID_MSI, pcib_get_id, rid, and type.
int pci_dw_init | ( | device_t | dev | ) |
Definition at line 705 of file pci_dw.c.
References pci_dw_softc::bus_end, pci_dw_softc::bus_start, pci_dw_softc::cfg_pa, pci_dw_softc::cfg_res, pci_dw_softc::cfg_size, pci_dw_softc::coherent, pci_dw_softc::dbi_res, pci_dw_softc::dev, dev, pci_dw_softc::dmat, DW_DEFAULT_IATU_UR_DBI_OFFSET, DW_DEFAULT_IATU_UR_DBI_SIZE, pci_dw_softc::iatu_ur_offset, pci_dw_softc::iatu_ur_res, pci_dw_softc::iatu_ur_size, pci_dw_softc::mtx, pci_dw_softc::node, pci_dw_softc::num_lanes, pci_dw_softc::num_out_regions, pci_dw_softc::ofw_pci, pci_dw_decode_ranges(), pci_dw_detect_atu_unroll(), pci_dw_detect_out_atu_regions(), pci_dw_setup_hw(), rid, pci_dw_softc::root_bus, and pci_dw_softc::sub_bus.
Referenced by pci_mv_attach().
|
static |
|
static |
Definition at line 318 of file pci_dw.c.
References pci_dw_softc::iatu_ur_res, pci_dw_map_out_atu_legacy(), pci_dw_map_out_atu_unroll(), and type.
Referenced by pci_dw_read_config(), pci_dw_setup_hw(), and pci_dw_write_config().
|
static |
Definition at line 285 of file pci_dw.c.
References DBI_RD4, DBI_WR4, pci_dw_softc::dev, DW_IATU_CTRL1, DW_IATU_CTRL2, DW_IATU_LIMIT_ADDR, DW_IATU_LWR_BASE_ADDR, DW_IATU_LWR_TARGET_ADDR, DW_IATU_UPPER_BASE_ADDR, DW_IATU_UPPER_TARGET_ADDR, DW_IATU_VIEWPORT, IATU_CTRL1_TYPE, IATU_CTRL2_REGION_EN, IATU_REGION_INDEX, reg, and type.
Referenced by pci_dw_map_out_atu().
|
static |
Definition at line 247 of file pci_dw.c.
References pci_dw_softc::dev, DW_IATU_UR_REG, IATU_CTRL1_TYPE, IATU_CTRL2_REGION_EN, IATU_UR_RD4, IATU_UR_WR4, reg, and type.
Referenced by pci_dw_map_out_atu().
|
static |
Definition at line 506 of file pci_dw.c.
References addr, bus, pci_dw_softc::cfg_pa, pci_dw_softc::cfg_res, pci_dw_softc::cfg_size, data, pci_dw_softc::dbi_res, dev, func, IATU_CFG_BUS, IATU_CFG_FUNC, IATU_CFG_SLOT, IATU_CTRL1_TYPE_CFG0, IATU_CTRL1_TYPE_CFG1, pci_dw_check_dev(), pci_dw_map_out_atu(), reg, pci_dw_softc::root_bus, slot, pci_dw_softc::sub_bus, and type.
|
static |
|
static |
|
static |
Definition at line 330 of file pci_dw.c.
References pci_dw_softc::bus_end, DBI_RD4, DBI_WR1, DBI_WR2, DBI_WR4, pci_dw_softc::dev, DIRECT_SPEED_CHANGE, DW_GEN2_CTRL, DW_PORT_LINK_CTRL, GEN2_CTRL_NUM_OF_LANES, GEN2_CTRL_NUM_OF_LANES_1, GEN2_CTRL_NUM_OF_LANES_16, GEN2_CTRL_NUM_OF_LANES_2, GEN2_CTRL_NUM_OF_LANES_32, GEN2_CTRL_NUM_OF_LANES_4, GEN2_CTRL_NUM_OF_LANES_8, IATU_CTRL1_TYPE_IO, IATU_CTRL1_TYPE_MEM, pci_dw_softc::io_range, pci_dw_softc::mem_ranges, pci_dw_softc::num_lanes, pci_dw_softc::num_mem_ranges, pci_dw_softc::num_out_regions, pci_dw_dbi_protect(), pci_dw_map_out_atu(), PCIC_BRIDGE, PCIM_CMD_BUSMASTEREN, PCIM_CMD_MEMEN, PCIM_CMD_PORTEN, PCIM_CMD_SERRESPEN, PCIR_BAR, PCIR_CLASS, PCIR_COMMAND, PCIR_INTPIN, PCIR_PRIBUS_1, PCIR_SECBUS_1, PCIR_SUBBUS_1, PCIR_SUBCLASS, PCIS_BRIDGE_PCI, PORT_LINK_CAPABLE, PORT_LINK_CAPABLE_1, PORT_LINK_CAPABLE_16, PORT_LINK_CAPABLE_2, PORT_LINK_CAPABLE_32, PORT_LINK_CAPABLE_4, PORT_LINK_CAPABLE_8, reg, pci_dw_softc::root_bus, and pci_dw_softc::sub_bus.
Referenced by pci_dw_init().
|
static |
Definition at line 555 of file pci_dw.c.
References addr, bus, pci_dw_softc::cfg_pa, pci_dw_softc::cfg_res, pci_dw_softc::cfg_size, pci_dw_softc::dbi_res, dev, func, IATU_CFG_BUS, IATU_CFG_FUNC, IATU_CFG_SLOT, IATU_CTRL1_TYPE_CFG0, IATU_CTRL1_TYPE_CFG1, pci_dw_check_dev(), pci_dw_map_out_atu(), reg, pci_dw_softc::root_bus, slot, pci_dw_softc::sub_bus, type, and val.
|
static |