diff options
author | Jonathan Gray <jsg@cvs.openbsd.org> | 2018-01-30 09:57:59 +0000 |
---|---|---|
committer | Jonathan Gray <jsg@cvs.openbsd.org> | 2018-01-30 09:57:59 +0000 |
commit | b4ba8f3636dd2aed3de82c3b6ac26d61343fdc0f (patch) | |
tree | e5da0e6186062eb1c302adfd1aa43fefcb016e38 | |
parent | 003964acfaabbbb2a288f0f8940f0c4b0345c345 (diff) |
add more pci defines and pci_pcie_cap()/pcie_capability_read_dword()
-rw-r--r-- | sys/dev/pci/drm/drm_linux.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/sys/dev/pci/drm/drm_linux.h b/sys/dev/pci/drm/drm_linux.h index ad6ed22541b..87b11a0abbd 100644 --- a/sys/dev/pci/drm/drm_linux.h +++ b/sys/dev/pci/drm/drm_linux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: drm_linux.h,v 1.79 2018/01/30 09:05:23 jsg Exp $ */ +/* $OpenBSD: drm_linux.h,v 1.80 2018/01/30 09:57:58 jsg Exp $ */ /* * Copyright (c) 2013, 2014, 2015 Mark Kettenis * Copyright (c) 2017 Martin Pieuchot @@ -1455,6 +1455,7 @@ struct pci_dev { }; #define PCI_ANY_ID (uint16_t) (~0U) +#define PCI_VENDOR_ID_APPLE PCI_VENDOR_APPLE #define PCI_VENDOR_ID_ASUSTEK PCI_VENDOR_ASUSTEK #define PCI_VENDOR_ID_ATI PCI_VENDOR_ATI #define PCI_VENDOR_ID_DELL PCI_VENDOR_DELL @@ -1472,6 +1473,13 @@ struct pci_dev { #define pci_dev_put(x) +#define PCI_EXP_DEVSTA 0x0a +#define PCI_EXP_DEVSTA_TRPND 0x0020 +#define PCI_EXP_LNKCAP 0x0c +#define PCI_EXP_LNKCAP_CLKPM 0x00040000 +#define PCI_EXP_LNKCTL 0x10 +#define PCI_EXP_LNKCTL_HAWD 0x0200 +#define PCI_EXP_LNKCTL2 0x30 static inline int pci_read_config_dword(struct pci_dev *pdev, int reg, u32 *val) @@ -1557,6 +1565,29 @@ pci_bus_read_config_byte(struct pci_bus *bus, unsigned int devfn, return 0; } +static inline int +pci_pcie_cap(struct pci_dev *pdev) +{ + int pos; + if (!pci_get_capability(pdev->pc, pdev->tag, PCI_CAP_PCIEXPRESS, + &pos, NULL)) + return -EINVAL; + return pos; +} + +static inline int +pcie_capability_read_dword(struct pci_dev *pdev, int off, u32 *val) +{ + int pos; + if (!pci_get_capability(pdev->pc, pdev->tag, PCI_CAP_PCIEXPRESS, + &pos, NULL)) { + *val = 0; + return -EINVAL; + } + *val = pci_conf_read(pdev->pc, pdev->tag, pos + off); + return 0; +} + #define pci_set_master(x) #define pci_clear_master(x) |