diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2019-03-11 20:34:26 +0200 |
---|---|---|
committer | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2019-03-16 15:19:06 +0000 |
commit | 34cf5619f929775efd819468ba6036e637cfbd85 (patch) | |
tree | e6763075a5e36710977ae51fcfd4a67b9bf3fffe /src/include/device/pci_ops.h | |
parent | 74aa99a5435ce3a1b984a3e0e5a0b696d6f6165d (diff) |
device/pci_ops: Reuse romstage PCI config for ramstage
By changing the signatures we do not need to define
PCI config accessors separately for ramstage.
Change-Id: I9364cb34fe8127972c772516a0a0b1d281c5ed00
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/31685
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Diffstat (limited to 'src/include/device/pci_ops.h')
-rw-r--r-- | src/include/device/pci_ops.h | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/src/include/device/pci_ops.h b/src/include/device/pci_ops.h index 82f96584de..bb77754cb6 100644 --- a/src/include/device/pci_ops.h +++ b/src/include/device/pci_ops.h @@ -48,52 +48,58 @@ static __always_inline const struct pci_bus_operations *pci_bus_ops(void) void __noreturn pcidev_die(void); -static __always_inline void pcidev_assert(const struct device *dev) +static __always_inline pci_devfn_t pcidev_bdf(const struct device *dev) +{ + return (dev->path.pci.devfn << 12) | (dev->bus->secondary << 20); +} + +static __always_inline pci_devfn_t pcidev_assert(const struct device *dev) { if (!dev) pcidev_die(); + return pcidev_bdf(dev); } static __always_inline u8 pci_read_config8(const struct device *dev, u16 reg) { - pcidev_assert(dev); - return pci_bus_ops()->read8(dev, reg); + pci_devfn_t bdf = PCI_BDF(dev); + return pci_bus_ops()->read8(bdf, reg); } static __always_inline u16 pci_read_config16(const struct device *dev, u16 reg) { - pcidev_assert(dev); - return pci_bus_ops()->read16(dev, reg); + pci_devfn_t bdf = PCI_BDF(dev); + return pci_bus_ops()->read16(bdf, reg); } static __always_inline u32 pci_read_config32(const struct device *dev, u16 reg) { - pcidev_assert(dev); - return pci_bus_ops()->read32(dev, reg); + pci_devfn_t bdf = PCI_BDF(dev); + return pci_bus_ops()->read32(bdf, reg); } static __always_inline void pci_write_config8(const struct device *dev, u16 reg, u8 val) { - pcidev_assert(dev); - pci_bus_ops()->write8(dev, reg, val); + pci_devfn_t bdf = PCI_BDF(dev); + pci_bus_ops()->write8(bdf, reg, val); } static __always_inline void pci_write_config16(const struct device *dev, u16 reg, u16 val) { - pcidev_assert(dev); - pci_bus_ops()->write16(dev, reg, val); + pci_devfn_t bdf = PCI_BDF(dev); + pci_bus_ops()->write16(bdf, reg, val); } static __always_inline void pci_write_config32(const struct device *dev, u16 reg, u32 val) { - pcidev_assert(dev); - pci_bus_ops()->write32(dev, reg, val); + pci_devfn_t bdf = PCI_BDF(dev); + pci_bus_ops()->write32(bdf, reg, val); } #endif |