From f799a0b3454120db4b26a9da10ca89d7ad19f005 Mon Sep 17 00:00:00 2001 From: Luciano Martin Date: Fri, 8 Dec 2017 15:12:02 +0000 Subject: [PATCH 1/5] - fixed reboot for XS2A and cleaned up reboot for XS1 --- lib_xua/src/core/support/reboot.xc | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/lib_xua/src/core/support/reboot.xc b/lib_xua/src/core/support/reboot.xc index 0087d84e..9d7583cf 100644 --- a/lib_xua/src/core/support/reboot.xc +++ b/lib_xua/src/core/support/reboot.xc @@ -32,7 +32,6 @@ void device_reboot_aux(void) write_node_config_reg(usb_tile, XS1_SU_CFG_RST_MISC_NUM,0b10); #else unsigned int pllVal; - unsigned int localTileId = get_local_tile_id(); unsigned int tileId; unsigned int tileArrayLength; @@ -45,25 +44,21 @@ void device_reboot_aux(void) /* Find size of tile array - note in future tools versions this will be available from platform.h */ asm volatile ("ldc %0, tile.globound":"=r"(tileArrayLength)); - /* Reset all remote tiles */ - for(int i = 0; i< tileArrayLength; i++) + /* Reset all tiles, starting from the remote ones */ + #ifndef __XS2A__ + for(int i = tileArrayLength-1; i>=0; i--) + #else + /* Reset all even tiles, starting from the remote ones */ + for(int i = tileArrayLength-2; i>=0; i=i-2) + #endif { /* Cannot cast tileref to unsigned! */ tileId = get_tile_id(tile[i]); - - /* Do not reboot local tile yet! */ - if(localTileId != tileId) - { - read_sswitch_reg(tileId, 6, pllVal); - pllVal &= PLL_MASK; - write_sswitch_reg_no_ack(tileId, 6, pllVal); - } + read_sswitch_reg(tileId, 6, pllVal); + pllVal &= PLL_MASK; + write_sswitch_reg_no_ack(tileId, 6, pllVal); } - /* Finally reboot this tile! */ - read_sswitch_reg(localTileId, 6, pllVal); - pllVal &= PLL_MASK; - write_sswitch_reg_no_ack(localTileId, 6, pllVal); #endif } From 00ccec07b4d11974ecd7d81ffe1645a5221ede21 Mon Sep 17 00:00:00 2001 From: Luciano Martin Date: Mon, 11 Dec 2017 11:34:00 +0000 Subject: [PATCH 2/5] - reintroduce localTileId final reset in reboot.xc --- lib_xua/src/core/support/reboot.xc | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib_xua/src/core/support/reboot.xc b/lib_xua/src/core/support/reboot.xc index 9d7583cf..5e495cab 100644 --- a/lib_xua/src/core/support/reboot.xc +++ b/lib_xua/src/core/support/reboot.xc @@ -20,6 +20,17 @@ unsigned get_tile_id(tileref); extern tileref tile[]; +/* Function to reset the given tile */ +void reset_tile(unsigned tileId) +{ + unsigned int pllVal; + + /* Cannot cast tileref to unsigned! */ + read_sswitch_reg(tileId, 6, pllVal); + pllVal &= PLL_MASK; + write_sswitch_reg_no_ack(tileId, 6, pllVal); +} + void device_reboot_aux(void) { #if (XUD_SERIES_SUPPORT == 1) @@ -31,8 +42,8 @@ void device_reboot_aux(void) /* Disable USB and issue reset to xcore only - not analogue chip */ write_node_config_reg(usb_tile, XS1_SU_CFG_RST_MISC_NUM,0b10); #else - unsigned int pllVal; unsigned int tileId; + unsigned int localTileId = get_local_tile_id(); unsigned int tileArrayLength; #if (XUD_SERIES_SUPPORT == 4) @@ -44,21 +55,22 @@ void device_reboot_aux(void) /* Find size of tile array - note in future tools versions this will be available from platform.h */ asm volatile ("ldc %0, tile.globound":"=r"(tileArrayLength)); - /* Reset all tiles, starting from the remote ones */ #ifndef __XS2A__ + /* Reset all tiles, starting from the remote ones */ for(int i = tileArrayLength-1; i>=0; i--) #else /* Reset all even tiles, starting from the remote ones */ for(int i = tileArrayLength-2; i>=0; i=i-2) #endif { - /* Cannot cast tileref to unsigned! */ - tileId = get_tile_id(tile[i]); - read_sswitch_reg(tileId, 6, pllVal); - pllVal &= PLL_MASK; - write_sswitch_reg_no_ack(tileId, 6, pllVal); + /* Do not reboot local tile yet! */ + if(localTileId != tileId) + { + reset_tile(tileId); + } } - + /* Finally reboot this tile! */ + reset_tile(localTileId); #endif } From 9e76d68aed58ef8f545335089c3cd180aa358fef Mon Sep 17 00:00:00 2001 From: Luciano Martin Date: Mon, 11 Dec 2017 11:42:51 +0000 Subject: [PATCH 3/5] - added missing changes --- lib_xua/src/core/support/reboot.xc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib_xua/src/core/support/reboot.xc b/lib_xua/src/core/support/reboot.xc index 5e495cab..c8674aef 100644 --- a/lib_xua/src/core/support/reboot.xc +++ b/lib_xua/src/core/support/reboot.xc @@ -25,7 +25,6 @@ void reset_tile(unsigned tileId) { unsigned int pllVal; - /* Cannot cast tileref to unsigned! */ read_sswitch_reg(tileId, 6, pllVal); pllVal &= PLL_MASK; write_sswitch_reg_no_ack(tileId, 6, pllVal); @@ -63,6 +62,10 @@ void device_reboot_aux(void) for(int i = tileArrayLength-2; i>=0; i=i-2) #endif { + + /* Cannot cast tileref to unsigned! */ + tileId = get_tile_id(tile[i]); + /* Do not reboot local tile yet! */ if(localTileId != tileId) { From 5edf0267168a7be1d1a5e49c42370d2d2d1c7a0c Mon Sep 17 00:00:00 2001 From: Luciano Martin Date: Mon, 11 Dec 2017 13:05:30 +0000 Subject: [PATCH 4/5] - don't reboot neither local tile nor the paired up tile in XS2A architectures --- lib_xua/src/core/support/reboot.xc | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib_xua/src/core/support/reboot.xc b/lib_xua/src/core/support/reboot.xc index c8674aef..7743bfae 100644 --- a/lib_xua/src/core/support/reboot.xc +++ b/lib_xua/src/core/support/reboot.xc @@ -41,9 +41,13 @@ void device_reboot_aux(void) /* Disable USB and issue reset to xcore only - not analogue chip */ write_node_config_reg(usb_tile, XS1_SU_CFG_RST_MISC_NUM,0b10); #else - unsigned int tileId; + unsigned int localTileId = get_local_tile_id(); + unsigned int tileId; unsigned int tileArrayLength; + #ifdef __XS2A__ + unsigned int localTileNum; + #endif #if (XUD_SERIES_SUPPORT == 4) /* Disconnect from bus */ @@ -54,6 +58,16 @@ void device_reboot_aux(void) /* Find size of tile array - note in future tools versions this will be available from platform.h */ asm volatile ("ldc %0, tile.globound":"=r"(tileArrayLength)); + #ifdef __XS2A__ + /* Find tile number of the local tile ID*/ + for(int i = 0; i=0; i--) @@ -67,11 +81,17 @@ void device_reboot_aux(void) tileId = get_tile_id(tile[i]); /* Do not reboot local tile yet! */ + #ifndef __XS2A__ if(localTileId != tileId) + #else + /* In XS2A the tile paired up with the local tile can't be rebooted either */ + if((localTileNum&0xFFFE) != (tileId&0xFFFE)) + #endif { reset_tile(tileId); } } + /* Finally reboot this tile! */ reset_tile(localTileId); #endif From 22bcce2e2fd9377079f8464bfdd14a8e23ee7a1d Mon Sep 17 00:00:00 2001 From: Luciano Martin Date: Mon, 11 Dec 2017 13:50:41 +0000 Subject: [PATCH 5/5] - fixed a bug and renamed generic iteration counter i as tileNum --- lib_xua/src/core/support/reboot.xc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_xua/src/core/support/reboot.xc b/lib_xua/src/core/support/reboot.xc index 7743bfae..a25fcbf3 100644 --- a/lib_xua/src/core/support/reboot.xc +++ b/lib_xua/src/core/support/reboot.xc @@ -60,9 +60,9 @@ void device_reboot_aux(void) #ifdef __XS2A__ /* Find tile number of the local tile ID*/ - for(int i = 0; i=0; i--) + for(int tileNum = tileArrayLength-1; tileNum>=0; tileNum--) #else /* Reset all even tiles, starting from the remote ones */ - for(int i = tileArrayLength-2; i>=0; i=i-2) + for(int tileNum = tileArrayLength-2; tileNum>=0; tileNum=tileNum-2) #endif { /* Cannot cast tileref to unsigned! */ - tileId = get_tile_id(tile[i]); + tileId = get_tile_id(tile[tileNum]); /* Do not reboot local tile yet! */ #ifndef __XS2A__ if(localTileId != tileId) #else /* In XS2A the tile paired up with the local tile can't be rebooted either */ - if((localTileNum&0xFFFE) != (tileId&0xFFFE)) + if((localTileNum|0x01) != (tileNum|0x01)) #endif { reset_tile(tileId);