Skip to content

Commit 1eb92b2

Browse files
Linus Walleijarndb
authored andcommitted
ARM: integrator: let pciv3 use mem/premem from device tree
Instead of relying on the hard-coded mem/premem bases for the PCI side, read in these from the device tree in the DT probe path. Hard-code the old values on the non-DT probe path. Introduce some static locals to hold these addresses instead of the earlier static #defines. Reported-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
1 parent 56ce3ff commit 1eb92b2

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

‎arch/arm/mach-integrator/pci_v3.c‎

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
* the V3 only has two windows (therefore we need to map stuff on the fly),
5353
* we maintain the same addresses, even if they're not mapped.
5454
*/
55-
#define PHYS_PCI_MEM_BASE 0x40000000 /* 512M */
55+
#define PHYS_PCI_MEM_BASE 0x40000000 /* 256M */
56+
#define PHYS_PCI_PRE_BASE 0x50000000 /* 256M */
5657
#define PHYS_PCI_IO_BASE 0x60000000 /* 16M */
5758
#define PHYS_PCI_CONFIG_BASE 0x61000000 /* 16M */
5859
#define PHYS_PCI_V3_BASE 0x62000000 /* 64K */
@@ -285,10 +286,16 @@
285286

286287
/* Filled in by probe */
287288
static void __iomem *pci_v3_base;
289+
/* CPU side memory ranges */
288290
static struct resource conf_mem; /* FIXME: remap this instead of static map */
289291
static struct resource io_mem;
290292
static struct resource non_mem;
291293
static struct resource pre_mem;
294+
/* PCI side memory ranges */
295+
static u64 non_mem_pci;
296+
static u64 non_mem_pci_sz;
297+
static u64 pre_mem_pci;
298+
static u64 pre_mem_pci_sz;
292299

293300
// V3 access routines
294301
#define v3_writeb(o,v) __raw_writeb(v, pci_v3_base + (unsigned int)(o))
@@ -354,19 +361,6 @@ static struct resource pre_mem;
354361
*/
355362
static DEFINE_RAW_SPINLOCK(v3_lock);
356363

357-
#define PCI_BUS_NONMEM_START 0x00000000
358-
#define PCI_BUS_NONMEM_SIZE SZ_256M
359-
360-
#define PCI_BUS_PREMEM_START PCI_BUS_NONMEM_START + PCI_BUS_NONMEM_SIZE
361-
#define PCI_BUS_PREMEM_SIZE SZ_256M
362-
363-
#if PCI_BUS_NONMEM_START & 0x000fffff
364-
#error PCI_BUS_NONMEM_START must be megabyte aligned
365-
#endif
366-
#if PCI_BUS_PREMEM_START & 0x000fffff
367-
#error PCI_BUS_PREMEM_START must be megabyte aligned
368-
#endif
369-
370364
#undef V3_LB_BASE_PREFETCH
371365
#define V3_LB_BASE_PREFETCH 0
372366

@@ -453,7 +447,7 @@ static void v3_close_config_window(void)
453447
v3_writel(V3_LB_BASE1, v3_addr_to_lb_base(pre_mem.start) |
454448
V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_PREFETCH |
455449
V3_LB_BASE_ENABLE);
456-
v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(PCI_BUS_PREMEM_START) |
450+
v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(pre_mem_pci) |
457451
V3_LB_MAP_TYPE_MEM_MULTIPLE);
458452

459453
/*
@@ -694,7 +688,7 @@ static void __init pci_v3_preinit(void)
694688
*/
695689
v3_writel(V3_LB_BASE0, v3_addr_to_lb_base(non_mem.start) |
696690
V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_ENABLE);
697-
v3_writew(V3_LB_MAP0, v3_addr_to_lb_map(PCI_BUS_NONMEM_START) |
691+
v3_writew(V3_LB_MAP0, v3_addr_to_lb_map(non_mem_pci) |
698692
V3_LB_MAP_TYPE_MEM);
699693

700694
/*
@@ -704,7 +698,7 @@ static void __init pci_v3_preinit(void)
704698
v3_writel(V3_LB_BASE1, v3_addr_to_lb_base(pre_mem.start) |
705699
V3_LB_BASE_ADR_SIZE_256MB | V3_LB_BASE_PREFETCH |
706700
V3_LB_BASE_ENABLE);
707-
v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(PCI_BUS_PREMEM_START) |
701+
v3_writew(V3_LB_MAP1, v3_addr_to_lb_map(pre_mem_pci) |
708702
V3_LB_MAP_TYPE_MEM_MULTIPLE);
709703

710704
/*
@@ -905,11 +899,15 @@ static int __init pci_v3_dtprobe(struct platform_device *pdev,
905899
}
906900
if ((range.flags & IORESOURCE_MEM) &&
907901
!(range.flags & IORESOURCE_PREFETCH)) {
902+
non_mem_pci = range.pci_addr;
903+
non_mem_pci_sz = range.size;
908904
of_pci_range_to_resource(&range, np, &non_mem);
909905
non_mem.name = "PCIv3 non-prefetched mem";
910906
}
911907
if ((range.flags & IORESOURCE_MEM) &&
912908
(range.flags & IORESOURCE_PREFETCH)) {
909+
pre_mem_pci = range.pci_addr;
910+
pre_mem_pci_sz = range.size;
913911
of_pci_range_to_resource(&range, np, &pre_mem);
914912
pre_mem.name = "PCIv3 prefetched mem";
915913
}
@@ -976,16 +974,18 @@ static int __init pci_v3_probe(struct platform_device *pdev)
976974
io_mem.end = PHYS_PCI_IO_BASE + SZ_16M - 1;
977975
io_mem.flags = IORESOURCE_MEM;
978976

977+
non_mem_pci = 0x00000000;
978+
non_mem_pci_sz = SZ_256M;
979979
non_mem.name = "PCIv3 non-prefetched mem";
980-
non_mem.start = PHYS_PCI_MEM_BASE + PCI_BUS_NONMEM_START;
981-
non_mem.end = PHYS_PCI_MEM_BASE + PCI_BUS_NONMEM_START +
982-
PCI_BUS_NONMEM_SIZE - 1;
980+
non_mem.start = PHYS_PCI_MEM_BASE;
981+
non_mem.end = PHYS_PCI_MEM_BASE + SZ_256M - 1;
983982
non_mem.flags = IORESOURCE_MEM;
984983

984+
pre_mem_pci = 0x10000000;
985+
pre_mem_pci_sz = SZ_256M;
985986
pre_mem.name = "PCIv3 prefetched mem";
986-
pre_mem.start = PHYS_PCI_MEM_BASE + PCI_BUS_PREMEM_START;
987-
pre_mem.end = PHYS_PCI_MEM_BASE + PCI_BUS_PREMEM_START +
988-
PCI_BUS_PREMEM_SIZE - 1;
987+
pre_mem.start = PHYS_PCI_PRE_BASE + SZ_256M;
988+
pre_mem.end = PHYS_PCI_PRE_BASE + SZ_256M - 1;
989989
pre_mem.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
990990

991991
pci_v3.map_irq = pci_v3_map_irq;

0 commit comments

Comments
 (0)