]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ARM: AT91: pm: Factorize standby function
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Wed, 16 Oct 2013 14:24:56 +0000 (16:24 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Wed, 16 Oct 2013 21:51:36 +0000 (23:51 +0200)
Detect presence of second bank. So we do not need to have on function per SoC

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
arch/arm/mach-at91/at91sam9260.c
arch/arm/mach-at91/at91sam9261.c
arch/arm/mach-at91/at91sam9263.c
arch/arm/mach-at91/at91sam9g45.c
arch/arm/mach-at91/at91sam9rl.c
arch/arm/mach-at91/pm.h

index ffe9ce70b53aef97f4529cf7c266c92e0ffb4703..3b43d562d79cf23d2335a243b0826ae7d9555fe4 100644 (file)
@@ -353,7 +353,7 @@ static void __init at91sam9260_initialize(void)
        /* Register GPIO subsystem */
        at91_gpio_init(at91sam9260_gpio, 3);
 
-       at91_pm_set_standby(at91sam9_standby);
+       at91_pm_set_standby(at91sam9_sdram_standby);
 }
 
 /* --------------------------------------------------------------------
index 1edbb6fd46366299225238548bfa9a242a8c8573..a0857c30a914995ed880cb1f03e5e36766699bde 100644 (file)
@@ -295,7 +295,7 @@ static void __init at91sam9261_initialize(void)
        /* Register GPIO subsystem */
        at91_gpio_init(at91sam9261_gpio, 3);
 
-       at91_pm_set_sandby(at91sam9_standby);
+       at91_pm_set_standby(at91sam9_sdram_standby);
 }
 
 /* --------------------------------------------------------------------
index 8c81c890618c086183e67f672a8932cd229429ca..103a95baa8e2501c640857fe8ae0b1b66dcac337 100644 (file)
@@ -332,7 +332,7 @@ static void __init at91sam9263_initialize(void)
        /* Register GPIO subsystem */
        at91_gpio_init(at91sam9263_gpio, 5);
 
-       at91_pm_set_standby(at91sam9263_standby);
+       at91_pm_set_standby(at91sam9_sdram_standby);
 }
 
 /* --------------------------------------------------------------------
index 8460f521c20b3b9fc29ff3f30854db70914b1281..f29731e9968c8de666bd6f05a910d3be3855fc2a 100644 (file)
@@ -381,7 +381,7 @@ static void __init at91sam9g45_initialize(void)
        /* Register GPIO subsystem */
        at91_gpio_init(at91sam9g45_gpio, 5);
 
-       at91_pm_set_standby(at91sam9g45_standby);
+       at91_pm_set_standby(at91_ddr_standby);
 }
 
 /* --------------------------------------------------------------------
index c7986e4f4e0e3d29b1dc8f58a1b56af5259eb90a..9e28f419f4143ce2e000c39f998adca67fc66530 100644 (file)
@@ -298,7 +298,7 @@ static void __init at91sam9rl_initialize(void)
        /* Register GPIO subsystem */
        at91_gpio_init(at91sam9rl_gpio, 4);
 
-       at91_pm_set_standby(at91sam9_standby);
+       at91_pm_set_standby(at91sam9_sdram_standby);
 }
 
 /* --------------------------------------------------------------------
index 76dd1a749ebdeef617c73313e24216415a6bd191..3ed190ce062bd5add5a426e07b1cf6c5d1e5b89a 100644 (file)
@@ -49,16 +49,18 @@ static inline void at91rm9200_standby(void)
 /* We manage both DDRAM/SDRAM controllers, we need more than one value to
  * remember.
  */
-static inline void at91sam9g45_standby(void)
+static inline void at91_ddr_standby(void)
 {
        /* Those two values allow us to delay self-refresh activation
         * to the maximum. */
-       u32 lpr0, lpr1;
-       u32 saved_lpr0, saved_lpr1;
+       u32 lpr0, lpr1 = 0;
+       u32 saved_lpr0, saved_lpr1 = 0;
 
-       saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
-       lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
-       lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
+       if (at91_ramc_base[1]) {
+               saved_lpr1 = at91_ramc_read(1, AT91_DDRSDRC_LPR);
+               lpr1 = saved_lpr1 & ~AT91_DDRSDRC_LPCB;
+               lpr1 |= AT91_DDRSDRC_LPCB_SELF_REFRESH;
+       }
 
        saved_lpr0 = at91_ramc_read(0, AT91_DDRSDRC_LPR);
        lpr0 = saved_lpr0 & ~AT91_DDRSDRC_LPCB;
@@ -66,25 +68,29 @@ static inline void at91sam9g45_standby(void)
 
        /* self-refresh mode now */
        at91_ramc_write(0, AT91_DDRSDRC_LPR, lpr0);
-       at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
+       if (at91_ramc_base[1])
+               at91_ramc_write(1, AT91_DDRSDRC_LPR, lpr1);
 
        cpu_do_idle();
 
        at91_ramc_write(0, AT91_DDRSDRC_LPR, saved_lpr0);
-       at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1);
+       if (at91_ramc_base[1])
+               at91_ramc_write(1, AT91_DDRSDRC_LPR, saved_lpr1);
 }
 
 /* We manage both DDRAM/SDRAM controllers, we need more than one value to
  * remember.
  */
-static inline void at91sam9263_standby(void)
+static inline void at91sam9_sdram_standby(void)
 {
-       u32 lpr0, lpr1;
-       u32 saved_lpr0, saved_lpr1;
+       u32 lpr0, lpr1 = 0;
+       u32 saved_lpr0, saved_lpr1 = 0;
 
-       saved_lpr1 = at91_ramc_read(1, AT91_SDRAMC_LPR);
-       lpr1 = saved_lpr1 & ~AT91_SDRAMC_LPCB;
-       lpr1 |= AT91_SDRAMC_LPCB_SELF_REFRESH;
+       if (at91_ramc_base[1]) {
+               saved_lpr1 = at91_ramc_read(1, AT91_SDRAMC_LPR);
+               lpr1 = saved_lpr1 & ~AT91_SDRAMC_LPCB;
+               lpr1 |= AT91_SDRAMC_LPCB_SELF_REFRESH;
+       }
 
        saved_lpr0 = at91_ramc_read(0, AT91_SDRAMC_LPR);
        lpr0 = saved_lpr0 & ~AT91_SDRAMC_LPCB;
@@ -92,27 +98,14 @@ static inline void at91sam9263_standby(void)
 
        /* self-refresh mode now */
        at91_ramc_write(0, AT91_SDRAMC_LPR, lpr0);
-       at91_ramc_write(1, AT91_SDRAMC_LPR, lpr1);
+       if (at91_ramc_base[1])
+               at91_ramc_write(1, AT91_SDRAMC_LPR, lpr1);
 
        cpu_do_idle();
 
        at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr0);
-       at91_ramc_write(1, AT91_SDRAMC_LPR, saved_lpr1);
-}
-
-static inline void at91sam9_standby(void)
-{
-       u32 saved_lpr, lpr;
-
-       saved_lpr = at91_ramc_read(0, AT91_SDRAMC_LPR);
-
-       lpr = saved_lpr & ~AT91_SDRAMC_LPCB;
-       at91_ramc_write(0, AT91_SDRAMC_LPR, lpr |
-                       AT91_SDRAMC_LPCB_SELF_REFRESH);
-
-       cpu_do_idle();
-
-       at91_ramc_write(0, AT91_SDRAMC_LPR, saved_lpr);
+       if (at91_ramc_base[1])
+               at91_ramc_write(1, AT91_SDRAMC_LPR, saved_lpr1);
 }
 
 #endif