/* Helper function for exported configuration functions. Configuration access is not atomic, so spinlock to keep drivers from clobbering each other.  */
static void pcie_io_conf(pcie_bdf_t bdf, unsigned int reg, bool write, uint32_t *data)
/* Helper function for exported configuration functions. Configuration access is not atomic, so spinlock to keep drivers from clobbering each other.  */
static void pcie_io_conf(pcie_bdf_t bdf, unsigned int reg, bool write, uint32_t *data)
{
	static struct k_spinlock lock;
	k_spinlock_key_t k;
	bdf &= PCIE_X86_CAP_BDF_MASK;
	bdf |= PCIE_X86_CAP_EN;
	bdf |= (reg & PCIE_X86_CAP_WORD_MASK) << PCIE_X86_CAP_WORD_SHIFT;
	k = k_spin_lock(&lock);
	sys_out32(bdf, PCIE_X86_CAP);
	if (write) {
		sys_out32(*data, PCIE_X86_CDP);
	} else {
		*data = sys_in32(PCIE_X86_CDP);
	}
	sys_out32(0U, PCIE_X86_CAP);
	k_spin_unlock(&lock, k);
}