Patchwork [U-Boot] omap: emif: configure emif only when required

login
register
mail settings
Submitter Lokesh Vutla
Date Nov. 14, 2012, 8:49 a.m.
Message ID <1352882943-14778-1-git-send-email-lokeshvutla@ti.com>
Download mbox | patch
Permalink /patch/198834/
State Superseded
Delegated to: Tom Rini
Headers show

Comments

Lokesh Vutla - Nov. 14, 2012, 8:49 a.m.
DMM_LISA_MAP registers program whether memory is mapped
on particular EMIF or not. Irrespective of these registers
EMIF is getting configured. Correcting the same.

Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
---
 arch/arm/cpu/armv7/omap-common/emif-common.c |   39 ++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 5 deletions(-)
SRICHARAN R - Nov. 14, 2012, 1:32 p.m.
On Wednesday 14 November 2012 02:19 PM, Lokesh Vutla wrote:
> DMM_LISA_MAP registers program whether memory is mapped
> on particular EMIF or not. Irrespective of these registers
> EMIF is getting configured. Correcting the same.
>
> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
> ---
>   arch/arm/cpu/armv7/omap-common/emif-common.c |   39 ++++++++++++++++++++++----
>   1 file changed, 34 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/cpu/armv7/omap-common/emif-common.c b/arch/arm/cpu/armv7/omap-common/emif-common.c
> index 30dcf1b..179525f 100644
> --- a/arch/arm/cpu/armv7/omap-common/emif-common.c
> +++ b/arch/arm/cpu/armv7/omap-common/emif-common.c
> @@ -33,6 +33,8 @@
>   #include <asm/utils.h>
>   #include <linux/compiler.h>
>
> +static int emif1_enabled = -1, emif2_enabled = -1;
> +
>   void set_lpmode_selfrefresh(u32 base)
>   {
>   	struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
> @@ -1218,6 +1220,27 @@ void dmm_init(u32 base)
>   	}
>   }
>
> +static void enable_emifs(void)
> +{
> +	u32 i, section, valid;
> +
> +	emif1_enabled = 0;
> +	emif2_enabled = 0;
> +	for (i = 0; i < 4; i++) {
> +		section	= __raw_readl(DMM_BASE + i*4);
> +		valid = (section & EMIF_SDRC_MAP_MASK) >>
> +			(EMIF_SDRC_MAP_SHIFT);
> +		if (valid == 1) {
> +			emif1_enabled = 1;
> +		} else if (valid == 2) {
> +			emif2_enabled = 1;
> +		} else if (valid == 3) {
> +			emif1_enabled = 1;
> +			emif2_enabled = 1;
> +			return;
> +		}
> +	}
> +}
>   /*
>    * SDRAM initialization:
>    * SDRAM initialization has two parts:
> @@ -1255,15 +1278,21 @@ void sdram_init(void)
>   			writel(CM_DLL_CTRL_NO_OVERRIDE, &prcm->cm_dll_ctrl);
>   	}
>
> -	do_sdram_init(EMIF1_BASE);
> -	do_sdram_init(EMIF2_BASE);
> -
>   	if (!in_sdram)
>   		dmm_init(DMM_BASE);
>
> +	enable_emifs();
  The function name is odd. It has got nothing to do with enabling 
EMIF's. It just identifies which is enabled ?. How about
set_enabled_emifs ?

Also this can done just when you are configuring the LISA registers.
That way a extra function is avoided.

Regards,
  Sricharan
Lokesh Vutla - Nov. 14, 2012, 4:44 p.m.
On Wednesday 14 November 2012 07:02 PM, R Sricharan wrote:
> On Wednesday 14 November 2012 02:19 PM, Lokesh Vutla wrote:
>> DMM_LISA_MAP registers program whether memory is mapped
>> on particular EMIF or not. Irrespective of these registers
>> EMIF is getting configured. Correcting the same.
>>
>> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
>> ---
>>   arch/arm/cpu/armv7/omap-common/emif-common.c |   39
>> ++++++++++++++++++++++----
>>   1 file changed, 34 insertions(+), 5 deletions(-)
>>
>> diff --git a/arch/arm/cpu/armv7/omap-common/emif-common.c
>> b/arch/arm/cpu/armv7/omap-common/emif-common.c
>> index 30dcf1b..179525f 100644
>> --- a/arch/arm/cpu/armv7/omap-common/emif-common.c
>> +++ b/arch/arm/cpu/armv7/omap-common/emif-common.c
>> @@ -33,6 +33,8 @@
>>   #include <asm/utils.h>
>>   #include <linux/compiler.h>
>>
>> +static int emif1_enabled = -1, emif2_enabled = -1;
>> +
>>   void set_lpmode_selfrefresh(u32 base)
>>   {
>>       struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
>> @@ -1218,6 +1220,27 @@ void dmm_init(u32 base)
>>       }
>>   }
>>
>> +static void enable_emifs(void)
>> +{
>> +    u32 i, section, valid;
>> +
>> +    emif1_enabled = 0;
>> +    emif2_enabled = 0;
>> +    for (i = 0; i < 4; i++) {
>> +        section    = __raw_readl(DMM_BASE + i*4);
>> +        valid = (section & EMIF_SDRC_MAP_MASK) >>
>> +            (EMIF_SDRC_MAP_SHIFT);
>> +        if (valid == 1) {
>> +            emif1_enabled = 1;
>> +        } else if (valid == 2) {
>> +            emif2_enabled = 1;
>> +        } else if (valid == 3) {
>> +            emif1_enabled = 1;
>> +            emif2_enabled = 1;
>> +            return;
>> +        }
>> +    }
>> +}
>>   /*
>>    * SDRAM initialization:
>>    * SDRAM initialization has two parts:
>> @@ -1255,15 +1278,21 @@ void sdram_init(void)
>>               writel(CM_DLL_CTRL_NO_OVERRIDE, &prcm->cm_dll_ctrl);
>>       }
>>
>> -    do_sdram_init(EMIF1_BASE);
>> -    do_sdram_init(EMIF2_BASE);
>> -
>>       if (!in_sdram)
>>           dmm_init(DMM_BASE);
>>
>> +    enable_emifs();
>   The function name is odd. It has got nothing to do with enabling
> EMIF's. It just identifies which is enabled ?. How about
> set_enabled_emifs ?
>
> Also this can done just when you are configuring the LISA registers.
> That way a extra function is avoided.
Yes you are right. Ill do this post it.

Thanks
Lokesh
>
> Regards,
>   Sricharan

Patch

diff --git a/arch/arm/cpu/armv7/omap-common/emif-common.c b/arch/arm/cpu/armv7/omap-common/emif-common.c
index 30dcf1b..179525f 100644
--- a/arch/arm/cpu/armv7/omap-common/emif-common.c
+++ b/arch/arm/cpu/armv7/omap-common/emif-common.c
@@ -33,6 +33,8 @@ 
 #include <asm/utils.h>
 #include <linux/compiler.h>
 
+static int emif1_enabled = -1, emif2_enabled = -1;
+
 void set_lpmode_selfrefresh(u32 base)
 {
 	struct emif_reg_struct *emif = (struct emif_reg_struct *)base;
@@ -1218,6 +1220,27 @@  void dmm_init(u32 base)
 	}
 }
 
+static void enable_emifs(void)
+{
+	u32 i, section, valid;
+
+	emif1_enabled = 0;
+	emif2_enabled = 0;
+	for (i = 0; i < 4; i++) {
+		section	= __raw_readl(DMM_BASE + i*4);
+		valid = (section & EMIF_SDRC_MAP_MASK) >>
+			(EMIF_SDRC_MAP_SHIFT);
+		if (valid == 1) {
+			emif1_enabled = 1;
+		} else if (valid == 2) {
+			emif2_enabled = 1;
+		} else if (valid == 3) {
+			emif1_enabled = 1;
+			emif2_enabled = 1;
+			return;
+		}
+	}
+}
 /*
  * SDRAM initialization:
  * SDRAM initialization has two parts:
@@ -1255,15 +1278,21 @@  void sdram_init(void)
 			writel(CM_DLL_CTRL_NO_OVERRIDE, &prcm->cm_dll_ctrl);
 	}
 
-	do_sdram_init(EMIF1_BASE);
-	do_sdram_init(EMIF2_BASE);
-
 	if (!in_sdram)
 		dmm_init(DMM_BASE);
 
+	enable_emifs();
+	if (emif1_enabled)
+		do_sdram_init(EMIF1_BASE);
+
+	if (emif2_enabled)
+		do_sdram_init(EMIF2_BASE);
+
 	if (!(in_sdram || warm_reset())) {
-		emif_post_init_config(EMIF1_BASE);
-		emif_post_init_config(EMIF2_BASE);
+		if (emif1_enabled)
+			emif_post_init_config(EMIF1_BASE);
+		if (emif2_enabled)
+			emif_post_init_config(EMIF2_BASE);
 	}
 
 	/* for the shadow registers to take effect */