/* 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_ti *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_ti *pcie, pci_dev_t d, uint where)
{
	int bus = PCI_BUS(d) - pcie->first_busno;
	uintptr_t va_address;
	u32 atu_type;
	if (!bus) {
		va_address = (uintptr_t)pcie->dbi_base;
		goto out;
	}
	if (bus == 1)
		atu_type = PCIE_ATU_TYPE_CFG0;
	else
		atu_type = PCIE_ATU_TYPE_CFG1;
	d = PCI_MASK_BUS(d);
	d = PCI_ADD_BUS(bus, d);
	pcie_dw_prog_outbound_atu_unroll(pcie, PCIE_ATU_REGION_INDEX1,
					 atu_type, (u64)pcie->cfg_base,
					 d << 8, pcie->cfg_size);
	va_address = (uintptr_t)pcie->cfg_base;
out:
	va_address += where & ~0x3;
	return va_address;
}