ARM: shmobile: rcar-gen2: Cache Mode Monitor Register Value
authorGeert Uytterhoeven <geert+renesas@linux-m68k.org>
Wed, 12 Mar 2014 18:44:49 +0000 (19:44 +0100)
committerSimon Horman <horms+renesas@verge.net.au>
Mon, 14 Apr 2014 02:28:42 +0000 (11:28 +0900)
The MD pins are sampled at reset time, hence the read value will always be
the same, and we can avoid the overhead of ioremapping the register on
every read.

Signed-off-by: Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
arch/arm/mach-shmobile/setup-rcar-gen2.c

index 1060448..542c5a4 100644 (file)
 
 u32 rcar_gen2_read_mode_pins(void)
 {
-       void __iomem *modemr = ioremap_nocache(MODEMR, 4);
-       u32 mode;
-
-       BUG_ON(!modemr);
-       mode = ioread32(modemr);
-       iounmap(modemr);
+       static u32 mode;
+       static bool mode_valid;
+
+       if (!mode_valid) {
+               void __iomem *modemr = ioremap_nocache(MODEMR, 4);
+               BUG_ON(!modemr);
+               mode = ioread32(modemr);
+               iounmap(modemr);
+               mode_valid = true;
+       }
 
        return mode;
 }