Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: mobiveil: Fix the CPU base address setup in inbound window

Current code erroneously sets-up the CPU base address through the
parameter 'pci_addr', which is passed to initialize the CPU (AXI) base
address of the inbound window where the controller maps the PCI address
space into CPU physical address space; furthermore, it also truncates it
by programming only the lower 32-bit value into the inbound CPU address
register.

Fix both issues by introducing a new parameter 'u64 cpu_addr' to
initialize both lower 32-bit and upper 32-bit of the CPU physical
base address mapping PCI inbound transactions into CPU (AXI) ones.

Fixes: 9af6bcb11e12 ("PCI: mobiveil: Add Mobiveil PCIe Host Bridge IP driver")
Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Reviewed-by: Minghuan Lian <Minghuan.Lian@nxp.com>
Reviewed-by: Subrahmanya Lingappa <l.subrahmanya@mobiveil.co.in>

authored by

Hou Zhiqiang and committed by
Lorenzo Pieralisi
df901c85 5f9e832c

+7 -3
+7 -3
drivers/pci/controller/pcie-mobiveil.c
··· 88 88 #define AMAP_CTRL_TYPE_MASK 3 89 89 90 90 #define PAB_EXT_PEX_AMAP_SIZEN(win) PAB_EXT_REG_ADDR(0xbef0, win) 91 + #define PAB_EXT_PEX_AMAP_AXI_WIN(win) PAB_EXT_REG_ADDR(0xb4a0, win) 91 92 #define PAB_PEX_AMAP_AXI_WIN(win) PAB_REG_ADDR(0x4ba4, win) 92 93 #define PAB_PEX_AMAP_PEX_WIN_L(win) PAB_REG_ADDR(0x4ba8, win) 93 94 #define PAB_PEX_AMAP_PEX_WIN_H(win) PAB_REG_ADDR(0x4bac, win) ··· 463 462 } 464 463 465 464 static void program_ib_windows(struct mobiveil_pcie *pcie, int win_num, 466 - u64 pci_addr, u32 type, u64 size) 465 + u64 cpu_addr, u64 pci_addr, u32 type, u64 size) 467 466 { 468 467 u32 value; 469 468 u64 size64 = ~(size - 1); ··· 483 482 csr_writel(pcie, upper_32_bits(size64), 484 483 PAB_EXT_PEX_AMAP_SIZEN(win_num)); 485 484 486 - csr_writel(pcie, pci_addr, PAB_PEX_AMAP_AXI_WIN(win_num)); 485 + csr_writel(pcie, lower_32_bits(cpu_addr), 486 + PAB_PEX_AMAP_AXI_WIN(win_num)); 487 + csr_writel(pcie, upper_32_bits(cpu_addr), 488 + PAB_EXT_PEX_AMAP_AXI_WIN(win_num)); 487 489 488 490 csr_writel(pcie, lower_32_bits(pci_addr), 489 491 PAB_PEX_AMAP_PEX_WIN_L(win_num)); ··· 628 624 CFG_WINDOW_TYPE, resource_size(pcie->ob_io_res)); 629 625 630 626 /* memory inbound translation window */ 631 - program_ib_windows(pcie, WIN_NUM_0, 0, MEM_WINDOW_TYPE, IB_WIN_SIZE); 627 + program_ib_windows(pcie, WIN_NUM_0, 0, 0, MEM_WINDOW_TYPE, IB_WIN_SIZE); 632 628 633 629 /* Get the I/O and memory ranges from DT */ 634 630 resource_list_for_each_entry(win, &pcie->resources) {