From: jsg Date: Tue, 30 Jan 2018 09:57:58 +0000 (+0000) Subject: add more pci defines and pci_pcie_cap()/pcie_capability_read_dword() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e9a8ebc7ed6d82723f04927ff1f2e04db6698b8b;p=openbsd add more pci defines and pci_pcie_cap()/pcie_capability_read_dword() --- 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)