diff options
author | Patrick Rudolph <patrick.rudolph@9elements.com> | 2018-04-18 10:11:59 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2018-04-20 13:03:54 +0000 |
commit | e56189cfd1d90a2ca13650a9d21ff82cb79ccda8 (patch) | |
tree | 0da4c1fec6bdb725e4065d4d687364ae5c63104d /src/include | |
parent | 6fcb9b00c8b7f820bb5ef81a83a24cd656654272 (diff) |
pci: Move inline PCI functions to pci_ops.h
Move inline function where they belong to. Fixes compilation
on non x86 platforms.
Change-Id: Ia05391c43b8d501bd68df5654bcfb587f8786f71
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/25720
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/device/device.h | 1 | ||||
-rw-r--r-- | src/include/device/pci_ops.h | 58 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/include/device/device.h b/src/include/device/device.h index 15e477afd6..02a933ecb8 100644 --- a/src/include/device/device.h +++ b/src/include/device/device.h @@ -19,6 +19,7 @@ struct device; #ifndef __SIMPLE_DEVICE__ typedef struct device *device_t; #endif +#include <arch/io.h> struct pci_operations; struct pci_bus_operations; diff --git a/src/include/device/pci_ops.h b/src/include/device/pci_ops.h index 3310e10bf4..358f92ddeb 100644 --- a/src/include/device/pci_ops.h +++ b/src/include/device/pci_ops.h @@ -15,4 +15,62 @@ void pci_write_config32(struct device *dev, unsigned int where, u32 val); #endif +/* + * Use device_t here as the functions are to be used with either + * __SIMPLE_DEVICE__ defined or undefined. + */ +static inline __attribute__((always_inline)) +void pci_or_config8(device_t dev, unsigned int where, u8 ormask) +{ + u8 value = pci_read_config8(dev, where); + pci_write_config8(dev, where, value | ormask); +} + +static inline __attribute__((always_inline)) +void pci_or_config16(device_t dev, unsigned int where, u16 ormask) +{ + u16 value = pci_read_config16(dev, where); + pci_write_config16(dev, where, value | ormask); +} + +static inline __attribute__((always_inline)) +void pci_or_config32(device_t dev, unsigned int where, u32 ormask) +{ + u32 value = pci_read_config32(dev, where); + pci_write_config32(dev, where, value | ormask); +} + +static inline __attribute__((always_inline)) +void pci_update_config8(device_t dev, int reg, u8 mask, u8 or) +{ + u8 reg8; + + reg8 = pci_read_config8(dev, reg); + reg8 &= mask; + reg8 |= or; + pci_write_config8(dev, reg, reg8); +} + +static inline __attribute__((always_inline)) +void pci_update_config16(device_t dev, int reg, u16 mask, u16 or) +{ + u16 reg16; + + reg16 = pci_read_config16(dev, reg); + reg16 &= mask; + reg16 |= or; + pci_write_config16(dev, reg, reg16); +} + +static inline __attribute__((always_inline)) +void pci_update_config32(device_t dev, int reg, u32 mask, u32 or) +{ + u32 reg32; + + reg32 = pci_read_config32(dev, reg); + reg32 &= mask; + reg32 |= or; + pci_write_config32(dev, reg, reg32); +} + #endif /* PCI_OPS_H */ |