forked from PAWPAW-Mirror/lib_xua
Reboot (for DFU) much nicer and more generic
This commit is contained in:
@@ -5,9 +5,14 @@
|
||||
|
||||
#define XS1_SU_PERIPH_USB_ID 0x1
|
||||
|
||||
/* Note, this function is prototyped in xs1.h only from 13 tools onwards */
|
||||
unsigned get_tile_id(tileref);
|
||||
|
||||
extern tileref tile[];
|
||||
|
||||
/* Reboots XMOS device by writing to the PLL config register */
|
||||
void device_reboot_implementation(chanend spare)
|
||||
{
|
||||
{
|
||||
#ifdef XUD_ON_U_SERIES
|
||||
/* Disconnect from bus */
|
||||
unsigned data[] = {4};
|
||||
@@ -17,21 +22,37 @@ void device_reboot_implementation(chanend spare)
|
||||
/* 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 localTileId = get_local_tile_id();
|
||||
unsigned int tileId;
|
||||
unsigned int tileArrayLength;
|
||||
|
||||
outct(spare, XS1_CT_END); // have to do this before freeing the chanend
|
||||
inct(spare); // Receive end ct from usb_buffer to close down in both directions
|
||||
|
||||
// Need a spare chanend so we can talk to the pll register
|
||||
/* Need a spare chanend so we can talk to the pll register */
|
||||
asm("freer res[%0]"::"r"(spare));
|
||||
|
||||
/* 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++)
|
||||
{
|
||||
unsigned int pllVal;
|
||||
unsigned int tile_id = get_local_tile_id();
|
||||
read_sswitch_reg(tile_id, 6, pllVal);
|
||||
/* Cannot cast tileref to unsigned! */
|
||||
tileId = get_tile_id(tile[i]);
|
||||
|
||||
/* Not this accounts for 2 tiles of an L2.. */
|
||||
write_sswitch_reg_no_ack(tile_id^0x8000, 6, pllVal);
|
||||
write_sswitch_reg_no_ack(tile_id, 6, pllVal);
|
||||
/* Do not reboot local tile yet! */
|
||||
if(localTileId != tileId)
|
||||
{
|
||||
read_sswitch_reg(tileId, 6, pllVal);
|
||||
write_sswitch_reg_no_ack(tileId, 6, pllVal);
|
||||
}
|
||||
}
|
||||
|
||||
/* Finally reboot this tile! */
|
||||
read_sswitch_reg(localTileId, 6, pllVal);
|
||||
write_sswitch_reg_no_ack(localTileId, 6, pllVal);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user