From af36b297359a839323f2a9d04625c32d2a3c1437 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Sun, 7 Jun 2020 18:01:56 +0200 Subject: [PATCH] include/device/pci_ops.h: Add bitwise AND ops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For the sake of completeness, we should provide these operations. Change-Id: Ia28af94ec86319c7380d8377f7e24e5cdf55dd9c Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/42145 Reviewed-by: Nico Huber Reviewed-by: Kyösti Mälkki Reviewed-by: Paul Menzel Tested-by: build bot (Jenkins) --- src/include/device/pci_ops.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) 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 @@ -80,6 +80,42 @@ void pci_write_config32(const struct device *dev, u16 reg, u32 val) #endif +#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)