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
This commit is contained in:
parent
e999fbf077
commit
c41d83548b
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user