/******************************************************************************* NAME psocDiag.c SUMMARY PSOC function diagnostics VERSION %version: 1 % UPDATE DATE %date_modified: May 11 19:15 2009 % PROGRAMMER %created_by: Jim Tu % Copyright 2009 Quanta Corporation. All Rights Reserved. DESCRIPTION: This file has code to test PSOC NOTES: REFERENCE: *******************************************************************************/ #include #include #include #include #include #include #include #include "fpgaRegLib.h" #include "fpgaIdReadDiag.h" EXTERN VOID fpgaPsocReset(BOOLEAN status); BOOLEAN gAlternatePsocResult; /******************************************************************************* * PROCEDURE * * NAME: psocRequestReceived * * SUMMARY: handle the PSOC diagnostics request from UUT * * SCOPE: public * * DESCRIPTION: verify if the UUT board ID is correct from fixture controller * through PSOC and sen the corresponding IPC message back to UUT * * RESTRICTIONS: * * RETURNS: */ VOID psocRequestReceived(VOID) { /*** Compare alternate board ID ***/ if( ((fpgaRegisterRead(FPGA_ALTERNATE_BOARD_ID) & PIKESPEAK_BOARD_ID) == PIKESPEAK_BOARD_ID) | ((fpgaRegisterRead(FPGA_ALTERNATE_BOARD_ID) & SOYUZ_BOARD_ID) == SOYUZ_BOARD_ID) ) { //if the UUT board ID is correct, send the response //ipcsend(ALTERNATE_PSOC_RESPONSE); printk("[psocRequestReceived] No function"); } } /******************************************************************************* * PROCEDURE * * NAME: psocResponseReceived * * SUMMARY: handle the PSOC diagnostics response from fixture controller * * SCOPE: public * * DESCRIPTION: verify if the UUT board ID is correct from fixture controller * through PSOC and sen the corresponding IPC message back to UUT * * RESTRICTIONS: * * RETURNS: */ VOID psocResponseReceived(VOID) { //get response, it means the UUT board ID is correct in fixture gAlternatePsocResult = TRUE; } /******************************************************************************* * PROCEDURE * * NAME: psocIdInDiag * * SUMMARY: test PSOC ID function (from altenate to local) * * SCOPE: private * * DESCRIPTION: verify if the alternate board ID is correct through PSOC * * RESTRICTIONS: * * RETURNS: TRUE: pass * FALSE: fail */ INT32 psocIdInDiag(VOID) { INT32 result = TRUE; /*** Compare alternate board ID ***/ if( ((fpgaRegisterRead(FPGA_ALTERNATE_BOARD_ID) & 0x1F) != (fpgaRegisterRead(FPGA_BOARD_ID) & 0x1F)) && ((fpgaRegisterRead(FPGA_ALTERNATE_BOARD_ID) & 0x1F) != 0x10) ) { fpgaPsocReset(TRUE); mdelay(10); fpgaPsocReset(FALSE); mdelay(1000); printk("[PSOC] WARNING!! Reset PSOC\n"); if( (fpgaRegisterRead(FPGA_ALTERNATE_BOARD_ID) & 0x1F) != (fpgaRegisterRead(FPGA_BOARD_ID) & 0x1F) && ((fpgaRegisterRead(FPGA_ALTERNATE_BOARD_ID) & 0x1F) != 0x10) ) { commReportError(MEC_PSOC, PSOC_ID_IN_MEC, PSOC_FIXTURE_BOARD_ID_ERROR, MSG_PSOC_FIXTURE_BOARD_ID_ERROR, 0, 0, 0, 0); printk("[PSOC] WARNING!! Alternate Controller ID: %02X\n", fpgaRegisterRead(FPGA_ALTERNATE_BOARD_ID)); //printk("[PSOC] WARNING!! Alternate Controller Inplace: %02X\n", // (fpgaRegisterRead(FPGA_SUBSYSTEM_STATUS_LINES_3) & ALT_INPL_BIT) >> 3); result = FALSE; } } return result; } /******************************************************************************* * PROCEDURE * * NAME: psocIdOutDiag * * SUMMARY: test PSOC ID function (from local to alternate) * * SCOPE: private * * DESCRIPTION: verify if the UUT board ID is correct from fixture controller * through PSOC * * RESTRICTIONS: * * RETURNS: TRUE: pass * FALSE: fail */ INT32 psocIdOutDiag(VOID) { INT32 result = TRUE; gAlternatePsocResult = FALSE; //IPC request to alternate controller to read the UUT board ID //ipcsend(ALTERNATE_PSOC_REQUEST); //wait for the response from alternate controller //mdelay(5000); //if alternate ID is not correct if(gAlternatePsocResult == TRUE) { commReportError(MEC_PSOC, PSOC_ID_OUT_MEC, PSOC_UUT_BOARD_ID_ERROR, MSG_PSOC_UUT_BOARD_ID_ERROR, 0, 0, 0, 0); result = FALSE; } return result; } /******************************************************************************* * PROCEDURE * * NAME: psocDiag * * SUMMARY: PSOC diagnositcs function * * SCOPE: public * * DESCRIPTION: PSOC diagnositcs function * * RESTRICTIONS: * * RETURNS: TRUE: pass * FALSE: fail */ INT32 psocDiag(VOID) { INT32 result = FALSE; if(psocIdInDiag() && psocIdOutDiag()) { result = TRUE; } return result; } /* for RD test */ VOID psocDiagLoop(UINT32 time) { int i; for(i = 0; i < time; i++) psocIdInDiag(); } //sysfs interface static ssize_t psocDiag_entry_show(struct kobject *kobject, struct kobj_attribute *attr, char *buf) { int result; result = psocDiag(); if(result) return sprintf(buf, "SUCCESSFULL"); else return sprintf(buf, "FAILED"); } static ssize_t psocDiag_entry_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { return count; } static struct kobject *p_psocDiag_kobj = NULL; static struct kobj_attribute psocDiag_entry_attribute = __ATTR(psocDiag_entry, 0660, psocDiag_entry_show, psocDiag_entry_store); static struct attribute *psocDiagAttrs[] = { &psocDiag_entry_attribute.attr, NULL, }; static struct attribute_group psocDiagAttrGroup = { .attrs = psocDiagAttrs, }; static int __init psocDiag_init(void) { p_psocDiag_kobj = kobject_create_and_add("psocDiag", firmware_kobj); if(NULL != p_psocDiag_kobj) { sysfs_create_group(p_psocDiag_kobj, &psocDiagAttrGroup); } printk(KERN_INFO "psoc Diagnostic Interface Driver\n"); return 0; } static void __exit psocDiag_exit(void) { if(p_psocDiag_kobj) { sysfs_remove_group(p_psocDiag_kobj, &psocDiagAttrGroup); kobject_put(p_psocDiag_kobj); } } module_init(psocDiag_init); module_exit(psocDiag_exit); MODULE_AUTHOR( "shawn.wang@netapp.com" ); MODULE_DESCRIPTION( "NetApp PSOC Diag Code" ); MODULE_LICENSE( "GPL" ); MODULE_VERSION( "0.1" );