Lines Matching +full:axi +full:- +full:pcie +full:- +full:host +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0
3 * PCIe host controller driver for Mobiveil PCIe Host controller
18 #include "pcie-mobiveil.h"
21 * mobiveil_pcie_sel_page - routine to access paged register
28 static void mobiveil_pcie_sel_page(struct mobiveil_pcie *pcie, u8 pg_idx) in mobiveil_pcie_sel_page() argument
32 val = readl(pcie->csr_axi_slave_base + PAB_CTRL); in mobiveil_pcie_sel_page()
36 writel(val, pcie->csr_axi_slave_base + PAB_CTRL); in mobiveil_pcie_sel_page()
39 static void __iomem *mobiveil_pcie_comp_addr(struct mobiveil_pcie *pcie, in mobiveil_pcie_comp_addr() argument
44 mobiveil_pcie_sel_page(pcie, 0); in mobiveil_pcie_comp_addr()
45 return pcie->csr_axi_slave_base + off; in mobiveil_pcie_comp_addr()
48 mobiveil_pcie_sel_page(pcie, OFFSET_TO_PAGE_IDX(off)); in mobiveil_pcie_comp_addr()
49 return pcie->csr_axi_slave_base + OFFSET_TO_PAGE_ADDR(off); in mobiveil_pcie_comp_addr()
54 if ((uintptr_t)addr & (size - 1)) { in mobiveil_pcie_read()
66 case 1: in mobiveil_pcie_read()
79 if ((uintptr_t)addr & (size - 1)) in mobiveil_pcie_write()
89 case 1: in mobiveil_pcie_write()
99 u32 mobiveil_csr_read(struct mobiveil_pcie *pcie, u32 off, size_t size) in mobiveil_csr_read() argument
105 addr = mobiveil_pcie_comp_addr(pcie, off); in mobiveil_csr_read()
109 dev_err(&pcie->pdev->dev, "read CSR address failed\n"); in mobiveil_csr_read()
114 void mobiveil_csr_write(struct mobiveil_pcie *pcie, u32 val, u32 off, in mobiveil_csr_write() argument
120 addr = mobiveil_pcie_comp_addr(pcie, off); in mobiveil_csr_write()
124 dev_err(&pcie->pdev->dev, "write CSR address failed\n"); in mobiveil_csr_write()
127 bool mobiveil_pcie_link_up(struct mobiveil_pcie *pcie) in mobiveil_pcie_link_up() argument
129 if (pcie->ops->link_up) in mobiveil_pcie_link_up()
130 return pcie->ops->link_up(pcie); in mobiveil_pcie_link_up()
132 return (mobiveil_csr_readl(pcie, LTSSM_STATUS) & in mobiveil_pcie_link_up()
136 void program_ib_windows(struct mobiveil_pcie *pcie, int win_num, in program_ib_windows() argument
140 u64 size64 = ~(size - 1); in program_ib_windows()
142 if (win_num >= pcie->ppio_wins) { in program_ib_windows()
143 dev_err(&pcie->pdev->dev, in program_ib_windows()
148 value = mobiveil_csr_readl(pcie, PAB_PEX_AMAP_CTRL(win_num)); in program_ib_windows()
150 value |= type << AMAP_CTRL_TYPE_SHIFT | 1 << AMAP_CTRL_EN_SHIFT | in program_ib_windows()
152 mobiveil_csr_writel(pcie, value, PAB_PEX_AMAP_CTRL(win_num)); in program_ib_windows()
154 mobiveil_csr_writel(pcie, upper_32_bits(size64), in program_ib_windows()
157 mobiveil_csr_writel(pcie, lower_32_bits(cpu_addr), in program_ib_windows()
159 mobiveil_csr_writel(pcie, upper_32_bits(cpu_addr), in program_ib_windows()
162 mobiveil_csr_writel(pcie, lower_32_bits(pci_addr), in program_ib_windows()
164 mobiveil_csr_writel(pcie, upper_32_bits(pci_addr), in program_ib_windows()
167 pcie->ib_wins_configured++; in program_ib_windows()
173 void program_ob_windows(struct mobiveil_pcie *pcie, int win_num, in program_ob_windows() argument
177 u64 size64 = ~(size - 1); in program_ob_windows()
179 if (win_num >= pcie->apio_wins) { in program_ob_windows()
180 dev_err(&pcie->pdev->dev, in program_ob_windows()
186 * program Enable Bit to 1, Type Bit to (00) base 2, AXI Window Size Bit in program_ob_windows()
189 value = mobiveil_csr_readl(pcie, PAB_AXI_AMAP_CTRL(win_num)); in program_ob_windows()
191 value |= 1 << WIN_ENABLE_SHIFT | type << WIN_TYPE_SHIFT | in program_ob_windows()
193 mobiveil_csr_writel(pcie, value, PAB_AXI_AMAP_CTRL(win_num)); in program_ob_windows()
195 mobiveil_csr_writel(pcie, upper_32_bits(size64), in program_ob_windows()
199 * program AXI window base with appropriate value in in program_ob_windows()
202 mobiveil_csr_writel(pcie, in program_ob_windows()
205 mobiveil_csr_writel(pcie, upper_32_bits(cpu_addr), in program_ob_windows()
208 mobiveil_csr_writel(pcie, lower_32_bits(pci_addr), in program_ob_windows()
210 mobiveil_csr_writel(pcie, upper_32_bits(pci_addr), in program_ob_windows()
213 pcie->ob_wins_configured++; in program_ob_windows()
216 int mobiveil_bringup_link(struct mobiveil_pcie *pcie) in mobiveil_bringup_link() argument
222 if (mobiveil_pcie_link_up(pcie)) in mobiveil_bringup_link()
228 dev_err(&pcie->pdev->dev, "link never came up\n"); in mobiveil_bringup_link()
230 return -ETIMEDOUT; in mobiveil_bringup_link()