diff options
author | Angel Pons <th3fanbus@gmail.com> | 2020-06-07 18:01:56 +0200 |
---|---|---|
committer | Felix Held <felix-coreboot@felixheld.de> | 2020-06-09 00:23:19 +0000 |
commit | af36b297359a839323f2a9d04625c32d2a3c1437 (patch) | |
tree | 0052f5635ebb94ba9dcb88a2b65b462c9e0c0d2f /src/include/device/pci_ops.h | |
parent | 3e241f54d27592807d47ac4d0891d037a26f7015 (diff) |
include/device/pci_ops.h: Add bitwise AND ops
For the sake of completeness, we should provide these operations.
Change-Id: Ia28af94ec86319c7380d8377f7e24e5cdf55dd9c
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/42145
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/include/device/pci_ops.h')
-rw-r--r-- | src/include/device/pci_ops.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/include/device/pci_ops.h b/src/include/device/pci_ops.h index 3c28d48197..680deb9d35 100644 --- a/src/include/device/pci_ops.h +++ b/src/include/device/pci_ops.h @@ -82,6 +82,42 @@ void pci_write_config32(const struct device *dev, u16 reg, u32 val) #if ENV_PCI_SIMPLE_DEVICE static __always_inline +void pci_and_config8(pci_devfn_t dev, u16 reg, u8 andmask) +#else +static __always_inline +void pci_and_config8(const struct device *dev, u16 reg, u8 andmask) +#endif +{ + u8 value = pci_read_config8(dev, reg); + pci_write_config8(dev, reg, value & andmask); +} + +#if ENV_PCI_SIMPLE_DEVICE +static __always_inline +void pci_and_config16(pci_devfn_t dev, u16 reg, u16 andmask) +#else +static __always_inline +void pci_and_config16(const struct device *dev, u16 reg, u16 andmask) +#endif +{ + u16 value = pci_read_config16(dev, reg); + pci_write_config16(dev, reg, value & andmask); +} + +#if ENV_PCI_SIMPLE_DEVICE +static __always_inline +void pci_and_config32(pci_devfn_t dev, u16 reg, u32 andmask) +#else +static __always_inline +void pci_and_config32(const struct device *dev, u16 reg, u32 andmask) +#endif +{ + u32 value = pci_read_config32(dev, reg); + pci_write_config32(dev, reg, value & andmask); +} + +#if ENV_PCI_SIMPLE_DEVICE +static __always_inline void pci_or_config8(pci_devfn_t dev, u16 reg, u8 ormask) #else static __always_inline |