diff options
author | Kishon Vijay Abraham I <kishon@ti.com> | 2018-10-17 03:41:08 -0400 |
---|---|---|
committer | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | 2018-10-17 04:48:14 -0400 |
commit | e75043ad9792596916ed0e1910b44f34b181c3b7 (patch) | |
tree | 3ab8c25d0608e7cdad391208b0877ebdae5a3eff | |
parent | b4f1af8352fda6926831b52caff37709bc895d05 (diff) |
PCI: keystone: Cleanup outbound window configuration
Outbound translation window is configured in order to access the
PCIe card's MEM space. Cleanup outbound translation configuration
here by using BIT() macros, adding a macro for window size and
using lower_32_bits/upper_32_bits macros for configuring the 64 bit
offset in the outbound translation region.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
-rw-r--r-- | drivers/pci/controller/dwc/pci-keystone.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c index 608e40c4b991..3576a184b9eb 100644 --- a/drivers/pci/controller/dwc/pci-keystone.c +++ b/drivers/pci/controller/dwc/pci-keystone.c | |||
@@ -41,7 +41,7 @@ | |||
41 | #define LTSSM_STATE_MASK 0x1f | 41 | #define LTSSM_STATE_MASK 0x1f |
42 | #define LTSSM_STATE_L0 0x11 | 42 | #define LTSSM_STATE_L0 0x11 |
43 | #define DBI_CS2_EN_VAL 0x20 | 43 | #define DBI_CS2_EN_VAL 0x20 |
44 | #define OB_XLAT_EN_VAL 2 | 44 | #define OB_XLAT_EN_VAL BIT(1) |
45 | 45 | ||
46 | /* Application registers */ | 46 | /* Application registers */ |
47 | #define CMD_STATUS 0x004 | 47 | #define CMD_STATUS 0x004 |
@@ -53,10 +53,11 @@ | |||
53 | #define CFG_TYPE1 BIT(24) | 53 | #define CFG_TYPE1 BIT(24) |
54 | 54 | ||
55 | #define OB_SIZE 0x030 | 55 | #define OB_SIZE 0x030 |
56 | #define CFG_PCIM_WIN_SZ_IDX 3 | ||
57 | #define SPACE0_REMOTE_CFG_OFFSET 0x1000 | 56 | #define SPACE0_REMOTE_CFG_OFFSET 0x1000 |
58 | #define OB_OFFSET_INDEX(n) (0x200 + (8 * (n))) | 57 | #define OB_OFFSET_INDEX(n) (0x200 + (8 * (n))) |
59 | #define OB_OFFSET_HI(n) (0x204 + (8 * (n))) | 58 | #define OB_OFFSET_HI(n) (0x204 + (8 * (n))) |
59 | #define OB_ENABLEN BIT(0) | ||
60 | #define OB_WIN_SIZE 8 /* 8MB */ | ||
60 | 61 | ||
61 | /* IRQ register defines */ | 62 | /* IRQ register defines */ |
62 | #define IRQ_EOI 0x050 | 63 | #define IRQ_EOI 0x050 |
@@ -341,12 +342,13 @@ static void ks_pcie_clear_dbi_mode(struct keystone_pcie *ks_pcie) | |||
341 | 342 | ||
342 | static void ks_pcie_setup_rc_app_regs(struct keystone_pcie *ks_pcie) | 343 | static void ks_pcie_setup_rc_app_regs(struct keystone_pcie *ks_pcie) |
343 | { | 344 | { |
345 | u32 val; | ||
344 | u32 num_viewport = ks_pcie->num_viewport; | 346 | u32 num_viewport = ks_pcie->num_viewport; |
345 | struct dw_pcie *pci = ks_pcie->pci; | 347 | struct dw_pcie *pci = ks_pcie->pci; |
346 | struct pcie_port *pp = &pci->pp; | 348 | struct pcie_port *pp = &pci->pp; |
347 | u32 start = pp->mem->start, end = pp->mem->end; | 349 | u64 start = pp->mem->start; |
348 | int i, tr_size; | 350 | u64 end = pp->mem->end; |
349 | u32 val; | 351 | int i; |
350 | 352 | ||
351 | /* Disable BARs for inbound access */ | 353 | /* Disable BARs for inbound access */ |
352 | ks_pcie_set_dbi_mode(ks_pcie); | 354 | ks_pcie_set_dbi_mode(ks_pcie); |
@@ -354,21 +356,21 @@ static void ks_pcie_setup_rc_app_regs(struct keystone_pcie *ks_pcie) | |||
354 | dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_1, 0); | 356 | dw_pcie_writel_dbi(pci, PCI_BASE_ADDRESS_1, 0); |
355 | ks_pcie_clear_dbi_mode(ks_pcie); | 357 | ks_pcie_clear_dbi_mode(ks_pcie); |
356 | 358 | ||
357 | /* Set outbound translation size per window division */ | 359 | val = ilog2(OB_WIN_SIZE); |
358 | ks_pcie_app_writel(ks_pcie, OB_SIZE, CFG_PCIM_WIN_SZ_IDX & 0x7); | 360 | ks_pcie_app_writel(ks_pcie, OB_SIZE, val); |
359 | |||
360 | tr_size = (1 << (CFG_PCIM_WIN_SZ_IDX & 0x7)) * SZ_1M; | ||
361 | 361 | ||
362 | /* Using Direct 1:1 mapping of RC <-> PCI memory space */ | 362 | /* Using Direct 1:1 mapping of RC <-> PCI memory space */ |
363 | for (i = 0; (i < num_viewport) && (start < end); i++) { | 363 | for (i = 0; i < num_viewport && (start < end); i++) { |
364 | ks_pcie_app_writel(ks_pcie, OB_OFFSET_INDEX(i), start | 1); | 364 | ks_pcie_app_writel(ks_pcie, OB_OFFSET_INDEX(i), |
365 | ks_pcie_app_writel(ks_pcie, OB_OFFSET_HI(i), 0); | 365 | lower_32_bits(start) | OB_ENABLEN); |
366 | start += tr_size; | 366 | ks_pcie_app_writel(ks_pcie, OB_OFFSET_HI(i), |
367 | upper_32_bits(start)); | ||
368 | start += OB_WIN_SIZE; | ||
367 | } | 369 | } |
368 | 370 | ||
369 | /* Enable OB translation */ | ||
370 | val = ks_pcie_app_readl(ks_pcie, CMD_STATUS); | 371 | val = ks_pcie_app_readl(ks_pcie, CMD_STATUS); |
371 | ks_pcie_app_writel(ks_pcie, CMD_STATUS, OB_XLAT_EN_VAL | val); | 372 | val |= OB_XLAT_EN_VAL; |
373 | ks_pcie_app_writel(ks_pcie, CMD_STATUS, val); | ||
372 | } | 374 | } |
373 | 375 | ||
374 | static int ks_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus, | 376 | static int ks_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus, |