complier.h: add __always_inline and use it in code base
[coreboot.git] / src / include / device / pci_ops.h
blob9e9baa0d609025a951a83472b554e694d96807e4
1 #ifndef PCI_OPS_H
2 #define PCI_OPS_H
4 #include <compiler.h>
5 #include <stdint.h>
6 #include <device/device.h>
7 #include <arch/pci_ops.h>
9 #ifndef __SIMPLE_DEVICE__
10 u8 pci_read_config8(struct device *dev, unsigned int where);
11 u16 pci_read_config16(struct device *dev, unsigned int where);
12 u32 pci_read_config32(struct device *dev, unsigned int where);
13 void pci_write_config8(struct device *dev, unsigned int where, u8 val);
14 void pci_write_config16(struct device *dev, unsigned int where, u16 val);
15 void pci_write_config32(struct device *dev, unsigned int where, u32 val);
17 #endif
20 * Use device_t here as the functions are to be used with either
21 * __SIMPLE_DEVICE__ defined or undefined.
23 static __always_inline
24 void pci_or_config8(device_t dev, unsigned int where, u8 ormask)
26 u8 value = pci_read_config8(dev, where);
27 pci_write_config8(dev, where, value | ormask);
30 static __always_inline
31 void pci_or_config16(device_t dev, unsigned int where, u16 ormask)
33 u16 value = pci_read_config16(dev, where);
34 pci_write_config16(dev, where, value | ormask);
37 static __always_inline
38 void pci_or_config32(device_t dev, unsigned int where, u32 ormask)
40 u32 value = pci_read_config32(dev, where);
41 pci_write_config32(dev, where, value | ormask);
44 static __always_inline
45 void pci_update_config8(device_t dev, int reg, u8 mask, u8 or)
47 u8 reg8;
49 reg8 = pci_read_config8(dev, reg);
50 reg8 &= mask;
51 reg8 |= or;
52 pci_write_config8(dev, reg, reg8);
55 static __always_inline
56 void pci_update_config16(device_t dev, int reg, u16 mask, u16 or)
58 u16 reg16;
60 reg16 = pci_read_config16(dev, reg);
61 reg16 &= mask;
62 reg16 |= or;
63 pci_write_config16(dev, reg, reg16);
66 static __always_inline
67 void pci_update_config32(device_t dev, int reg, u32 mask, u32 or)
69 u32 reg32;
71 reg32 = pci_read_config32(dev, reg);
72 reg32 &= mask;
73 reg32 |= or;
74 pci_write_config32(dev, reg, reg32);
77 const struct pci_bus_operations *pci_bus_default_ops(struct device *dev);
79 #endif /* PCI_OPS_H */