summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2020-06-07 18:31:33 +0200
committerFelix Held <felix-coreboot@felixheld.de>2020-06-09 00:26:12 +0000
commit2f3456a8734d4fb9b4ab492f4bdd7f3b1885706c (patch)
tree88cf3833c72f93c67010b61d0327c24ac035e749
parentaf36b297359a839323f2a9d04625c32d2a3c1437 (diff)
pci_ops.h: Turn and/or ops into update wrappers
Tested with BUILD_TIMELESS=1, Asus P8Z77-V LX2 does not change. Change-Id: I2d3779967f357dd380928869c630a1996fdd60ec Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/42147 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
-rw-r--r--src/include/device/pci_ops.h90
1 files changed, 42 insertions, 48 deletions
diff --git a/src/include/device/pci_ops.h b/src/include/device/pci_ops.h
index 680deb9d35..cdf02d6a56 100644
--- a/src/include/device/pci_ops.h
+++ b/src/include/device/pci_ops.h
@@ -82,122 +82,116 @@ 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)
+void pci_update_config8(pci_devfn_t dev, u16 reg, u8 mask, u8 or)
#else
static __always_inline
-void pci_and_config8(const struct device *dev, u16 reg, u8 andmask)
+void pci_update_config8(const struct device *dev, u16 reg, u8 mask, u8 or)
#endif
{
- u8 value = pci_read_config8(dev, reg);
- pci_write_config8(dev, reg, value & andmask);
+ u8 reg8;
+
+ reg8 = pci_read_config8(dev, reg);
+ reg8 &= mask;
+ reg8 |= or;
+ pci_write_config8(dev, reg, reg8);
}
#if ENV_PCI_SIMPLE_DEVICE
static __always_inline
-void pci_and_config16(pci_devfn_t dev, u16 reg, u16 andmask)
+void pci_update_config16(pci_devfn_t dev, u16 reg, u16 mask, u16 or)
#else
static __always_inline
-void pci_and_config16(const struct device *dev, u16 reg, u16 andmask)
+void pci_update_config16(const struct device *dev, u16 reg, u16 mask, u16 or)
#endif
{
- u16 value = pci_read_config16(dev, reg);
- pci_write_config16(dev, reg, value & andmask);
+ u16 reg16;
+
+ reg16 = pci_read_config16(dev, reg);
+ reg16 &= mask;
+ reg16 |= or;
+ pci_write_config16(dev, reg, reg16);
}
#if ENV_PCI_SIMPLE_DEVICE
static __always_inline
-void pci_and_config32(pci_devfn_t dev, u16 reg, u32 andmask)
+void pci_update_config32(pci_devfn_t dev, u16 reg, u32 mask, u32 or)
#else
static __always_inline
-void pci_and_config32(const struct device *dev, u16 reg, u32 andmask)
+void pci_update_config32(const struct device *dev, u16 reg, u32 mask, u32 or)
#endif
{
- u32 value = pci_read_config32(dev, reg);
- pci_write_config32(dev, reg, value & andmask);
+ u32 reg32;
+
+ reg32 = pci_read_config32(dev, reg);
+ reg32 &= mask;
+ reg32 |= or;
+ pci_write_config32(dev, reg, reg32);
}
#if ENV_PCI_SIMPLE_DEVICE
static __always_inline
-void pci_or_config8(pci_devfn_t dev, u16 reg, u8 ormask)
+void pci_and_config8(pci_devfn_t dev, u16 reg, u8 andmask)
#else
static __always_inline
-void pci_or_config8(const struct device *dev, u16 reg, u8 ormask)
+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 | ormask);
+ pci_update_config8(dev, reg, andmask, 0);
}
#if ENV_PCI_SIMPLE_DEVICE
static __always_inline
-void pci_or_config16(pci_devfn_t dev, u16 reg, u16 ormask)
+void pci_and_config16(pci_devfn_t dev, u16 reg, u16 andmask)
#else
static __always_inline
-void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
+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 | ormask);
+ pci_update_config16(dev, reg, andmask, 0);
}
#if ENV_PCI_SIMPLE_DEVICE
static __always_inline
-void pci_or_config32(pci_devfn_t dev, u16 reg, u32 ormask)
+void pci_and_config32(pci_devfn_t dev, u16 reg, u32 andmask)
#else
static __always_inline
-void pci_or_config32(const struct device *dev, u16 reg, u32 ormask)
+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 | ormask);
+ pci_update_config32(dev, reg, andmask, 0);
}
#if ENV_PCI_SIMPLE_DEVICE
static __always_inline
-void pci_update_config8(pci_devfn_t dev, u16 reg, u8 mask, u8 or)
+void pci_or_config8(pci_devfn_t dev, u16 reg, u8 ormask)
#else
static __always_inline
-void pci_update_config8(const struct device *dev, u16 reg, u8 mask, u8 or)
+void pci_or_config8(const struct device *dev, u16 reg, u8 ormask)
#endif
{
- u8 reg8;
-
- reg8 = pci_read_config8(dev, reg);
- reg8 &= mask;
- reg8 |= or;
- pci_write_config8(dev, reg, reg8);
+ pci_update_config8(dev, reg, 0xff, ormask);
}
#if ENV_PCI_SIMPLE_DEVICE
static __always_inline
-void pci_update_config16(pci_devfn_t dev, u16 reg, u16 mask, u16 or)
+void pci_or_config16(pci_devfn_t dev, u16 reg, u16 ormask)
#else
static __always_inline
-void pci_update_config16(const struct device *dev, u16 reg, u16 mask, u16 or)
+void pci_or_config16(const struct device *dev, u16 reg, u16 ormask)
#endif
{
- u16 reg16;
-
- reg16 = pci_read_config16(dev, reg);
- reg16 &= mask;
- reg16 |= or;
- pci_write_config16(dev, reg, reg16);
+ pci_update_config16(dev, reg, 0xffff, ormask);
}
#if ENV_PCI_SIMPLE_DEVICE
static __always_inline
-void pci_update_config32(pci_devfn_t dev, u16 reg, u32 mask, u32 or)
+void pci_or_config32(pci_devfn_t dev, u16 reg, u32 ormask)
#else
static __always_inline
-void pci_update_config32(const struct device *dev, u16 reg, u32 mask, u32 or)
+void pci_or_config32(const struct device *dev, u16 reg, u32 ormask)
#endif
{
- u32 reg32;
-
- reg32 = pci_read_config32(dev, reg);
- reg32 &= mask;
- reg32 |= or;
- pci_write_config32(dev, reg, reg32);
+ pci_update_config32(dev, reg, 0xffffffff, ormask);
}
u16 pci_s_find_next_capability(pci_devfn_t dev, u16 cap, u16 last);