Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c4f3836 authored by Yue Ma's avatar Yue Ma Committed by Nirav Shah
Browse files

cnss2: Make sure the write to remap window register take effect



Since PCIe remap window register access and actual PCIe device
register access may go through different NoCs, read it back after
writing to remap window register to make sure it has taken effect.
This is able to avoid NOC errors when accessing the actual device
register which the remap window value applies to.

Change-Id: I65848758250fb9e6e1cbe513932c64b8303a8e98
Signed-off-by: default avatarYue Ma <yuem@codeaurora.org>
parent a4341e9d
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -426,15 +426,24 @@ int cnss_pci_check_link_status(struct cnss_pci_data *pci_priv)
static void cnss_pci_select_window(struct cnss_pci_data *pci_priv, u32 offset)
{
	u32 window = (offset >> WINDOW_SHIFT) & WINDOW_VALUE_MASK;
	u32 window_enable = WINDOW_ENABLE_BIT | window;
	u32 val;

	writel_relaxed(WINDOW_ENABLE_BIT | window,
		       QCA6390_PCIE_REMAP_BAR_CTRL_OFFSET +
		       pci_priv->bar);
	writel_relaxed(window_enable, pci_priv->bar +
		       QCA6390_PCIE_REMAP_BAR_CTRL_OFFSET);

	if (window != pci_priv->remap_window) {
		pci_priv->remap_window = window;
		cnss_pr_dbg("Config PCIe remap window register to 0x%x\n",
			    WINDOW_ENABLE_BIT | window);
			    window_enable);
	}

	/* Read it back to make sure the write has taken effect */
	val = readl_relaxed(pci_priv->bar + QCA6390_PCIE_REMAP_BAR_CTRL_OFFSET);
	if (val != window_enable) {
		cnss_pr_err("Failed to config window register to 0x%x, current value: 0x%x\n",
			    window_enable, val);
		CNSS_ASSERT(0);
	}
}