Re: [U-Boot] T1040RDB u-boot chain load u-boot

2018-06-13 Thread Radu-andrei Bulie
Hi,


The u-boot-spl.bin (written in nand) loads the u-boot.bin which was previously 
written in nand. When the board boots, this process is transparent to you. (The 
address for the u-boot.bin in nand is 0x4). The load process is done 
through the spl routines that are used by the u-boot-spl.bin image to load the 
u-boot from offset 0x4.

To summarize,  the boot process is like this: PBL > (NAND -RCW) > 
u-boot-spl --->u-boot.bin

From the booted u-boot if you try to launch u-boot.bin which was transferred in 
a memory location by you, you will for sure get a hang because the u-boot.bin 
will try to reinitialize some blocks that were already initialized. You could 
end up taking the carpet from underneath your feet.

If you want to load another u-boot instance you will have probably to make 
changes in the u-boot.bin image. 


Radu


-Original Message-
From: Chris Packham [mailto:judge.pack...@gmail.com] 
Sent: Friday, June 8, 2018 12:20 AM
To: nicolae.rosia@gmail.com
Cc: u-boot ; Priyanka Jain ; 
Radu-andrei Bulie 
Subject: Re: [U-Boot] T1040RDB u-boot chain load u-boot

On Thu, Jun 7, 2018 at 10:46 PM Nicolae Rosia  
wrote:


> Scenario 4:
> Remove RAMBOOT_PBL from defconfig:
> -CONFIG_SYS_EXTRA_OPTIONS="RAMBOOT_PBL,SPL_FSL_PBL"
> +CONFIG_SYS_EXTRA_OPTIONS="SPL_FSL_PBL"
>
> This results in a binary that is more than 3GB (??)
>
> Scenario 4.1:
> I noticed that CONFIG_SYS_TEXT_BASE affects the size of binary so I 
> thought I can fix this by placing it near RAM end, 4 GB - 8 MB:
> -CONFIG_SYS_TEXT_BASE=0x30001000
> +CONFIG_SYS_TEXT_BASE=0xFF80
> -CONFIG_SYS_EXTRA_OPTIONS="RAMBOOT_PBL,SPL_FSL_PBL"
> +CONFIG_SYS_EXTRA_OPTIONS="SPL_FSL_PBL"
>
> but the size of u-boot.bin is ~249 MB

That's probably because there's some other fixed address in use (probably the 
reset vector). You'll want to adjust that address to match your new location or 
maybe use something like SKIP_LOW_LEVEL_INIT assuming powerpc has such a thing.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3] drivers/net/vsc9953: Initialize action RAM in VCAP complex

2018-06-06 Thread radu-andrei . bulie
Hi Joe,

As a reminder, is there anything else that should
be done to push the patch forward?

Thanks,
Radu
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3] drivers/net/vsc9953: Initialize action RAM in VCAP complex

2018-05-21 Thread radu-andrei . bulie
From: Radu Bulie 

VCAP tables must be initialized even if no advanced classification
is used. If no initialization is performed, then ECC error will
be observed by the user when the first packet enters the l2switch.
The error is marked in MPIC_EISR0 -bit 29 which means - Internal RAM
multi-bit ECC error.
This patch fixes the aforementioned ECC error by performing the
initialization of VCAP tables.

Signed-off-by: Radu Bulie 
---
Changes for v2:
- removed magic numbers
- added standard BIT macro
- added descriptive params in macros instead of letters
- removed redundant macro for port numbers

Changes for v3:
- removed unused macro VSC9953_IO_OFFSET
- removed redundant offset from macro VSC9953_IO_ADDR
- added descriptive param for BITS_TO_DWORD


 drivers/net/vsc9953.c | 134 ++
 include/vsc9953.h |  70 ++
 2 files changed, 204 insertions(+)

diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c
index 2388438..64a2f1e 100644
--- a/drivers/net/vsc9953.c
+++ b/drivers/net/vsc9953.c
@@ -2469,6 +2469,139 @@ void vsc9953_default_configuration(void)
debug("VSC9953: failed to set default aggregation code mode\n");
 }
 
+static void vcap_entry2cache_init(u32 target, u32 entry_words)
+{
+   int i;
+
+   for (i = 0; i < entry_words; i++) {
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+   VSC9953_VCAP_CACHE_ENTRY_DAT(target, i)), 0x00);
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+   VSC9953_VCAP_CACHE_MASK_DAT(target, i)), 0xFF);
+   }
+
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+   VSC9953_VCAP_CACHE_TG_DAT(target)), 0x00);
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+ VSC9953_VCAP_CFG_MV_CFG(target)),
+VSC9953_VCAP_CFG_MV_CFG_SIZE(entry_words));
+}
+
+static void vcap_action2cache_init(u32 target, u32 action_words,
+  u32 counter_words)
+{
+   int i;
+
+   for (i = 0; i < action_words; i++)
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+  VSC9953_VCAP_CACHE_ACTION_DAT(target, i)), 0x00);
+
+   for (i = 0; i < counter_words; i++)
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+ VSC9953_VCAP_CACHE_CNT_DAT(target, i)), 0x00);
+}
+
+static int vcap_cmd(u32 target, u16 ix, int cmd, int sel, int entry_count)
+{
+   u32 tgt = target;
+   u32 value = (VSC9953_VCAP_UPDATE_CTRL_UPDATE_CMD(cmd) |
+VSC9953_VCAP_UPDATE_CTRL_UPDATE_ADDR(ix) |
+VSC9953_VCAP_UPDATE_CTRL_UPDATE_SHOT);
+
+   if ((sel & TCAM_SEL_ENTRY) && ix >= entry_count)
+   return CMD_RET_FAILURE;
+
+   if (!(sel & TCAM_SEL_ENTRY))
+   value |= VSC9953_VCAP_UPDATE_CTRL_UPDATE_ENTRY_DIS;
+
+   if (!(sel & TCAM_SEL_ACTION))
+   value |= VSC9953_VCAP_UPDATE_CTRL_UPDATE_ACTION_DIS;
+
+   if (!(sel & TCAM_SEL_COUNTER))
+   value |= VSC9953_VCAP_UPDATE_CTRL_UPDATE_CNT_DIS;
+
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+   VSC9953_VCAP_CFG_UPDATE_CTRL(tgt)), value);
+
+   do {
+   value = in_le32((unsigned int *)(VSC9953_OFFSET +
+   VSC9953_VCAP_CFG_UPDATE_CTRL(tgt)));
+
+   } while (value & VSC9953_VCAP_UPDATE_CTRL_UPDATE_SHOT);
+
+   return CMD_RET_SUCCESS;
+}
+
+static void vsc9953_vcap_init(void)
+{
+   u32 tgt = VSC9953_ES0;
+   int cmd_ret;
+
+   /* write entries */
+   vcap_entry2cache_init(tgt, ENTRY_WORDS_ES0);
+   cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE, TCAM_SEL_ENTRY,
+  ENTRY_WORDS_ES0);
+   if (cmd_ret != CMD_RET_SUCCESS)
+   debug("VSC9953:%d invalid TCAM_SEL_ENTRY\n",
+ __LINE__);
+
+   /* write actions and counters */
+   vcap_action2cache_init(tgt, BITS_TO_DWORD(ES0_ACT_WIDTH),
+  BITS_TO_DWORD(ES0_CNT_WIDTH));
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+ VSC9953_VCAP_CFG_MV_CFG(tgt)),
+VSC9953_VCAP_CFG_MV_CFG_SIZE(ES0_ACT_COUNT));
+   cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE,
+  TCAM_SEL_ACTION | TCAM_SEL_COUNTER, ENTRY_WORDS_ES0);
+   if (cmd_ret != CMD_RET_SUCCESS)
+   debug("VSC9953:%d invalid TCAM_SEL_ACTION | TCAM_SEL_COUNTER\n",
+ __LINE__);
+
+   tgt = VSC9953_IS1;
+
+   /* write entries */
+   vcap_entry2cache_init(tgt, ENTRY_WORDS_IS1);
+   cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE, TCAM_SEL_ENTRY,
+  ENTRY_WORDS_IS1);
+   if (cmd_ret != CMD_RET_SUCCESS)
+   debug("VSC9953:%d 

[U-Boot] [PATCH v2] drivers/net/vsc9953: Initialize action RAM in VCAP complex

2018-05-21 Thread radu-andrei . bulie
From: Radu Bulie 

VCAP tables must be initialized even if no advanced classification
is used. If no initialization is performed, then ECC error will
be observed by the user when the first packet enters the l2switch.
The error is marked in MPIC_EISR0 -bit 29 which means - Internal RAM
multi-bit ECC error.
This patch fixes the aforementioned ECC error by performing the
initialization of VCAP tables.

Signed-off-by: Radu Bulie 
---
Changes for v2:
- removed magic numbers
- added standard BIT macro
- added descriptive params in macros instead of letters
- removed redundant macro for port numbers

 drivers/net/vsc9953.c | 134 ++
 include/vsc9953.h |  72 +++
 2 files changed, 206 insertions(+)

diff --git a/drivers/net/vsc9953.c b/drivers/net/vsc9953.c
index 2388438..64a2f1e 100644
--- a/drivers/net/vsc9953.c
+++ b/drivers/net/vsc9953.c
@@ -2469,6 +2469,139 @@ void vsc9953_default_configuration(void)
debug("VSC9953: failed to set default aggregation code mode\n");
 }
 
+static void vcap_entry2cache_init(u32 target, u32 entry_words)
+{
+   int i;
+
+   for (i = 0; i < entry_words; i++) {
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+   VSC9953_VCAP_CACHE_ENTRY_DAT(target, i)), 0x00);
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+   VSC9953_VCAP_CACHE_MASK_DAT(target, i)), 0xFF);
+   }
+
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+   VSC9953_VCAP_CACHE_TG_DAT(target)), 0x00);
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+ VSC9953_VCAP_CFG_MV_CFG(target)),
+VSC9953_VCAP_CFG_MV_CFG_SIZE(entry_words));
+}
+
+static void vcap_action2cache_init(u32 target, u32 action_words,
+  u32 counter_words)
+{
+   int i;
+
+   for (i = 0; i < action_words; i++)
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+  VSC9953_VCAP_CACHE_ACTION_DAT(target, i)), 0x00);
+
+   for (i = 0; i < counter_words; i++)
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+ VSC9953_VCAP_CACHE_CNT_DAT(target, i)), 0x00);
+}
+
+static int vcap_cmd(u32 target, u16 ix, int cmd, int sel, int entry_count)
+{
+   u32 tgt = target;
+   u32 value = (VSC9953_VCAP_UPDATE_CTRL_UPDATE_CMD(cmd) |
+VSC9953_VCAP_UPDATE_CTRL_UPDATE_ADDR(ix) |
+VSC9953_VCAP_UPDATE_CTRL_UPDATE_SHOT);
+
+   if ((sel & TCAM_SEL_ENTRY) && ix >= entry_count)
+   return CMD_RET_FAILURE;
+
+   if (!(sel & TCAM_SEL_ENTRY))
+   value |= VSC9953_VCAP_UPDATE_CTRL_UPDATE_ENTRY_DIS;
+
+   if (!(sel & TCAM_SEL_ACTION))
+   value |= VSC9953_VCAP_UPDATE_CTRL_UPDATE_ACTION_DIS;
+
+   if (!(sel & TCAM_SEL_COUNTER))
+   value |= VSC9953_VCAP_UPDATE_CTRL_UPDATE_CNT_DIS;
+
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+   VSC9953_VCAP_CFG_UPDATE_CTRL(tgt)), value);
+
+   do {
+   value = in_le32((unsigned int *)(VSC9953_OFFSET +
+   VSC9953_VCAP_CFG_UPDATE_CTRL(tgt)));
+
+   } while (value & VSC9953_VCAP_UPDATE_CTRL_UPDATE_SHOT);
+
+   return CMD_RET_SUCCESS;
+}
+
+static void vsc9953_vcap_init(void)
+{
+   u32 tgt = VSC9953_ES0;
+   int cmd_ret;
+
+   /* write entries */
+   vcap_entry2cache_init(tgt, ENTRY_WORDS_ES0);
+   cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE, TCAM_SEL_ENTRY,
+  ENTRY_WORDS_ES0);
+   if (cmd_ret != CMD_RET_SUCCESS)
+   debug("VSC9953:%d invalid TCAM_SEL_ENTRY\n",
+ __LINE__);
+
+   /* write actions and counters */
+   vcap_action2cache_init(tgt, BITS_TO_DWORD(ES0_ACT_WIDTH),
+  BITS_TO_DWORD(ES0_CNT_WIDTH));
+   out_le32((unsigned int *)(VSC9953_OFFSET +
+ VSC9953_VCAP_CFG_MV_CFG(tgt)),
+VSC9953_VCAP_CFG_MV_CFG_SIZE(ES0_ACT_COUNT));
+   cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE,
+  TCAM_SEL_ACTION | TCAM_SEL_COUNTER, ENTRY_WORDS_ES0);
+   if (cmd_ret != CMD_RET_SUCCESS)
+   debug("VSC9953:%d invalid TCAM_SEL_ACTION | TCAM_SEL_COUNTER\n",
+ __LINE__);
+
+   tgt = VSC9953_IS1;
+
+   /* write entries */
+   vcap_entry2cache_init(tgt, ENTRY_WORDS_IS1);
+   cmd_ret = vcap_cmd(tgt, 0, TCAM_CMD_INITIALIZE, TCAM_SEL_ENTRY,
+  ENTRY_WORDS_IS1);
+   if (cmd_ret != CMD_RET_SUCCESS)
+   debug("VSC9953:%d invalid TCAM_SEL_ENTRY\n",
+ __LINE__);
+
+   /* write actions and counters */
+   vcap_action2cache_init(tgt,