/* Return: Address that can be used to access the configation space of the requested device / offset  */
static uintptr_t set_cfg_address(struct pcie_dw_mvebu *pcie, pci_dev_t d, uint where)
/* Return: Address that can be used to access the configation space of the requested device / offset  */
static uintptr_t set_cfg_address(struct pcie_dw_mvebu *pcie, pci_dev_t d, uint where)
{
	uintptr_t va_address;
	u32 atu_type;
	if (PCI_BUS(d) == (pcie->first_busno + 1))
		atu_type = PCIE_ATU_TYPE_CFG0;
	else
		atu_type = PCIE_ATU_TYPE_CFG1;
	if (PCI_BUS(d) == pcie->first_busno) {
		va_address = (uintptr_t)pcie->ctrl_base;
	} else {
		d = PCI_MASK_BUS(d) | (PCI_BUS(d) - pcie->first_busno);
		pcie_dw_prog_outbound_atu(pcie, PCIE_ATU_REGION_INDEX0,
					  atu_type, (u64)pcie->cfg_base,
					  d << 8, pcie->cfg_size);
		va_address = (uintptr_t)pcie->cfg_base;
	}
	va_address += where & ~0x3;
	return va_address;
}