diff --git a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c index d7f9e4f56..3c0d25d7c 100644 --- a/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c +++ b/slsDetectorServers/ctbDetectorServer/slsDetectorFunctionList.c @@ -15,6 +15,7 @@ #include "loadPattern.h" #include +#include #include #include #include // usleep @@ -93,6 +94,7 @@ void basictests() { LOG(logINFOBLUE, ("********* Chip Test Board Virtual Server *********\n")); #else LOG(logINFOBLUE, ("************* Chip Test Board Server *************\n")); + enableBlackfinAMCExternalAccessExtension(); initError = defineGPIOpins(initErrorMessage); if (initError == FAIL) { return; @@ -438,6 +440,33 @@ uint32_t getDetectorIP() { return res; } +void enableBlackfinAMCExternalAccessExtension() { + unsigned int value; + const char *file_path = "/sys/kernel/debug/blackfin/ebiu_amc/EBIU_AMBCTL1"; + + FILE *file = fopen(file_path, "r"); + if (!file) { + LOG(logERROR, ("Failed to read EBIU_AMBCTL1\n")); + return; + } + fscanf(file, "%x", &value); + fclose(file); + + // enable support for ARDY signal on interface to FPGA + // needed to properly translate avalon_mm_waitrequest in the CTB firmware + // https://www.analog.com/media/en/dsp-documentation/processor-manuals/bf537_hwr_Rev3.2.pdf + // page 274 + value |= 0x3; + + file = fopen(file_path, "w"); + if (!file) { + LOG(logERROR, ("Failed to enable blackfin AMC access extension\n")); + return; + } + fprintf(file, "0x%x", value); + fclose(file); +} + /* initialization */ void initControlServer() { diff --git a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h index f572252bd..80bad5898 100644 --- a/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h +++ b/slsDetectorServers/slsDetectorServer/include/slsDetectorFunctionList.h @@ -135,6 +135,7 @@ void setupDetector(); #if defined(CHIPTESTBOARDD) int updateDatabytesandAllocateRAM(); void updateDataBytes(); +void enableBlackfinAMCExternalAccessExtension(); #endif #if !defined(CHIPTESTBOARDD) && !defined(XILINX_CHIPTESTBOARDD)