336-MIPS-BCM63XX-dynamically-set-the-pcie-memory-windows.patch 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. From aa05464973bc176478af462ca7c53a9239c651d4 Mon Sep 17 00:00:00 2001
  2. From: Jonas Gorski <jogo@openwrt.org>
  3. Date: Sun, 8 Dec 2013 03:13:06 +0100
  4. Subject: [PATCH 46/53] MIPS: BCM63XX: dynamically set the pcie memory windows
  5. Different SoCs use different memory windows (and sizes), so don't
  6. hardcode it.
  7. ---
  8. arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h | 8 ++++----
  9. arch/mips/pci/pci-bcm63xx.c | 15 ++++++++++-----
  10. 2 files changed, 14 insertions(+), 9 deletions(-)
  11. --- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h
  12. +++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_io.h
  13. @@ -40,10 +40,10 @@
  14. #define BCM_CB_MEM_END_PA (BCM_CB_MEM_BASE_PA + \
  15. BCM_CB_MEM_SIZE - 1)
  16. -#define BCM_PCIE_MEM_BASE_PA 0x10f00000
  17. -#define BCM_PCIE_MEM_SIZE (1 * 1024 * 1024)
  18. -#define BCM_PCIE_MEM_END_PA (BCM_PCIE_MEM_BASE_PA + \
  19. - BCM_PCIE_MEM_SIZE - 1)
  20. +#define BCM_PCIE_MEM_BASE_PA_6328 0x10f00000
  21. +#define BCM_PCIE_MEM_SIZE_6328 (1 * 1024 * 1024)
  22. +#define BCM_PCIE_MEM_END_PA_6328 (BCM_PCIE_MEM_BASE_PA_6328 + \
  23. + BCM_PCIE_MEM_SIZE_6328 - 1)
  24. /*
  25. * Internal registers are accessed through KSEG3
  26. --- a/arch/mips/pci/pci-bcm63xx.c
  27. +++ b/arch/mips/pci/pci-bcm63xx.c
  28. @@ -77,8 +77,8 @@ struct pci_controller bcm63xx_cb_control
  29. static struct resource bcm_pcie_mem_resource = {
  30. .name = "bcm63xx PCIe memory space",
  31. - .start = BCM_PCIE_MEM_BASE_PA,
  32. - .end = BCM_PCIE_MEM_END_PA,
  33. + .start = 0,
  34. + .end = 0,
  35. .flags = IORESOURCE_MEM,
  36. };
  37. @@ -195,12 +195,12 @@ static int __init bcm63xx_register_pcie(
  38. bcm_pcie_writel(val, PCIE_CONFIG2_REG);
  39. /* set bar0 to little endian */
  40. - val = (BCM_PCIE_MEM_BASE_PA >> 20) << BASEMASK_BASE_SHIFT;
  41. - val |= (BCM_PCIE_MEM_BASE_PA >> 20) << BASEMASK_MASK_SHIFT;
  42. + val = (bcm_pcie_mem_resource.start >> 20) << BASEMASK_BASE_SHIFT;
  43. + val |= (bcm_pcie_mem_resource.end >> 20) << BASEMASK_MASK_SHIFT;
  44. val |= BASEMASK_REMAP_EN;
  45. bcm_pcie_writel(val, PCIE_BRIDGE_BAR0_BASEMASK_REG);
  46. - val = (BCM_PCIE_MEM_BASE_PA >> 20) << REBASE_ADDR_BASE_SHIFT;
  47. + val = (bcm_pcie_mem_resource.start >> 20) << REBASE_ADDR_BASE_SHIFT;
  48. bcm_pcie_writel(val, PCIE_BRIDGE_BAR0_REBASE_ADDR_REG);
  49. register_pci_controller(&bcm63xx_pcie_controller);
  50. @@ -334,6 +334,11 @@ static int __init bcm63xx_pci_init(void)
  51. if (!bcm63xx_pci_enabled)
  52. return -ENODEV;
  53. + if (BCMCPU_IS_6328() || BCMCPU_IS_6362()) {
  54. + bcm_pcie_mem_resource.start = BCM_PCIE_MEM_BASE_PA_6328;
  55. + bcm_pcie_mem_resource.end = BCM_PCIE_MEM_END_PA_6328;
  56. + }
  57. +
  58. switch (bcm63xx_get_cpu_id()) {
  59. case BCM6328_CPU_ID:
  60. case BCM6362_CPU_ID: