diff options
author | Bjoern A. Zeeb <bz@FreeBSD.org> | 2022-09-21 19:39:01 +0000 |
---|---|---|
committer | Bjoern A. Zeeb <bz@FreeBSD.org> | 2022-09-22 15:10:03 +0000 |
commit | c41d83548b6cf18b48af974ad995354f38cf04a4 (patch) | |
tree | c4a5c080885b97d7510f8cefa1a7075b2129ae8f /sys/compat/linuxkpi | |
parent | e999fbf0776208f9ecbc2926fd088427d766b014 (diff) | |
download | src-c41d83548b6cf18b48af974ad995354f38cf04a4.tar.gz src-c41d83548b6cf18b48af974ad995354f38cf04a4.zip |
LinuxKPI: pci.h add more defines and functions
Add #defines for PCI_DEVICE_ID and repoint the PCI_VENDOR_ID one.
Add dev_is_pci().
Add pcie_capability_clear_word() according to similar implementations.
Sponsored by: The FreeBSD Foundation
MFC after: 7 days
Reviewed by: hselasky, emaste
Differential Revision: https://reviews.freebsd.org/D36653
Diffstat (limited to 'sys/compat/linuxkpi')
-rw-r--r-- | sys/compat/linuxkpi/common/include/linux/pci.h | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index 0652a250c697..1f41bdb5b1db 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -4,7 +4,7 @@ * Copyright (c) 2010 Panasas, Inc. * Copyright (c) 2013-2016 Mellanox Technologies, Ltd. * All rights reserved. - * Copyright (c) 2020-2021 The FreeBSD Foundation + * Copyright (c) 2020-2022 The FreeBSD Foundation * * Portions of this software were developed by Björn Zeeb * under sponsorship from the FreeBSD Foundation. @@ -106,7 +106,8 @@ MODULE_PNP_INFO("U32:vendor;U32:device;V32:subvendor;V32:subdevice", \ #define to_pci_dev(n) container_of(n, struct pci_dev, dev) -#define PCI_VENDOR_ID PCIR_DEVVENDOR +#define PCI_VENDOR_ID PCIR_VENDOR +#define PCI_DEVICE_ID PCIR_DEVICE #define PCI_COMMAND PCIR_COMMAND #define PCI_COMMAND_INTX_DISABLE PCIM_CMD_INTxDIS #define PCI_EXP_DEVCTL PCIER_DEVICE_CTL /* Device Control */ @@ -213,6 +214,7 @@ typedef int pci_power_t; #define PCI_IRQ_LEGACY 0x01 #define PCI_IRQ_MSI 0x02 #define PCI_IRQ_MSIX 0x04 +#define PCI_IRQ_ALL_TYPES (PCI_IRQ_MSIX|PCI_IRQ_MSI|PCI_IRQ_LEGACY) struct pci_dev; @@ -328,6 +330,13 @@ struct resource *_lkpi_pci_iomap(struct pci_dev *pdev, int bar, int mmio_size); struct pcim_iomap_devres *lkpi_pcim_iomap_devres_find(struct pci_dev *pdev); void lkpi_pcim_iomap_table_release(struct device *, void *); +static inline bool +dev_is_pci(struct device *dev) +{ + + return (device_get_devclass(dev->bsddev) == devclass_find("pci")); +} + static inline int pci_resource_type(struct pci_dev *pdev, int bar) { @@ -1159,6 +1168,22 @@ pcie_capability_set_word(struct pci_dev *dev, int pos, uint16_t val) return (error); } +static inline int +pcie_capability_clear_word(struct pci_dev *dev, int pos, uint16_t val) +{ + int error; + uint16_t v; + + error = pcie_capability_read_word(dev, pos, &v); + if (error != 0) + return (error); + + v &= ~val; + + error = pcie_capability_write_word(dev, pos, v); + return (error); +} + static inline int pcie_get_minimum_link(struct pci_dev *dev, enum pci_bus_speed *speed, enum pcie_link_width *width) { |