[ARM] Orion: fix PCIe inbound window programming when RAM size is not a power of two
authorLennert Buytenhek <buytenh@wantstofly.org>
Wed, 23 Dec 2009 15:19:56 +0000 (16:19 +0100)
committerNicolas Pitre <nico@fluxnic.net>
Tue, 29 Dec 2009 04:50:49 +0000 (23:50 -0500)
The PCIe inbound window size is supposed to be a power of two.  If
the total amount of RAM installed in the system is not a power of two,
round it up such that it is.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Signed-off-by: Nicolas Pitre <nico@marvell.com>
arch/arm/plat-orion/pcie.c

index d41d41d..54c84a4 100644 (file)
@@ -133,6 +133,12 @@ static void __init orion_pcie_setup_wins(void __iomem *base,
        }
 
        /*
+        * Round up 'size' to the nearest power of two.
+        */
+       if ((size & (size - 1)) != 0)
+               size = 1 << fls(size);
+
+       /*
         * Setup BAR[1] to all DRAM banks.
         */
        writel(dram->cs[0].base, base + PCIE_BAR_LO_OFF(1));