src/occ_gpe1/gpe1_dimm_read.c
/*
 * Function Specifications:
 *
 * Name: dimm_initiate_read
 *
 * Description:  Initiate the read of the temperature sensor
 *
 * Inputs:       cmd is a pointer to IPC msg's cmd and cmd_data struct
 *
 * Outputs:      error: sets rc, address, and ffdc in the cmd_data's
 *                      GpeErrorStruct
 *
 * End Function Specification
 */
Function Specifications:
Name: dimm_initiate_read

Initiate the read of the temperature sensor

cmd is a pointer to IPC msg's cmd and cmd_data struct

sets rc, address, and ffdc in the cmd_data's
GpeErrorStruct

End Function Specification
Function Specifications : Name : dimm_initiate_read Initiate the read of the temperature sensor cmd is a pointer to IPC msg ' s cmd and cmd_data struct sets rc address and ffdc in the cmd_data ' s GpeErrorStruct End Function Specification
void dimm_initiate_read(ipc_msg_t* cmd, void* arg)
{
    int      rc;
    uint32_t scomAddr;
    uint64_t regValue; 
    ipc_async_cmd_t *async_cmd = (ipc_async_cmd_t*)cmd;
    dimm_sm_args_t *args = (dimm_sm_args_t*)async_cmd->cmd_data;
    args->error.rc = GPE_RC_NOT_COMPLETE;
    scomAddr = I2C_STATUS_REG | SCOM_ENGINE_OFFSET(args->i2cEngine);
    rc = getscom_abs(scomAddr, &regValue);
    if(rc)
    {
        PK_TRACE("dimm_initiate_read: I2C_STATUS_REG getscom 0x%08X FAILED. rc = 0x%08x",
                 scomAddr, rc);
        gpe_set_ffdc(&(args->error), scomAddr, GPE_RC_SCOM_GET_FAILED, rc);
    }
    else
    {
        GPE1_DIMM_DBG("dimm_initiate_read: getscom(0x%08X) returned 0x%08X%08X - STATUS",
                      scomAddr, WORD_HIGH(regValue), WORD_LOW(regValue));
        if ((regValue & STATUS_ERROR_OR_COMPLETE_MASK) == STATUS_COMPLETE_MASK)
        {
            scomAddr = I2C_COMMAND_REG | SCOM_ENGINE_OFFSET(args->i2cEngine);
            regValue  = 0xD001000400000000;
            regValue |= ((uint64_t)args->i2cAddr << 48);
            rc = putscom_abs(scomAddr, regValue);
            if(rc)
            {
                PK_TRACE("dimm_initiate_read: I2C_COMMAND_REG putscom 0x%08X->0x%08X%08X FAILED. rc = 0x%08x",
                         scomAddr, WORD_HIGH(regValue), WORD_LOW(regValue), rc);
                gpe_set_ffdc(&(args->error), scomAddr, GPE_RC_SCOM_PUT_FAILED, rc);
            }
            else
            {
                GPE1_DIMM_DBG("dimm_initiate_read: putscom(0x%08X,0x%08X%08X) SUCCESS - COMMAND (read)",
                              scomAddr, WORD_HIGH(regValue), WORD_LOW(regValue));
                args->error.error = 0;
                args->error.rc = GPE_RC_SUCCESS;
                args->error.ffdc = 0;
            }
        }
        else
        {
            if ((regValue & STATUS_ERROR_OR_COMPLETE_MASK) != 0)
            {
                PK_TRACE("dimm_initiate_read: Error in status register: 0x%08X%08X",
                         WORD_HIGH(regValue), WORD_LOW(regValue));
                gpe_set_ffdc(&(args->error), scomAddr, GPE_RC_I2C_ERROR, regValue);
            }
            else
            {
                PK_TRACE("dimm_initiate_read: last command not complete yet...");
                gpe_set_ffdc(&(args->error), scomAddr, GPE_RC_NOT_COMPLETE, regValue);
            }
        }
    }
}
void dimm_initiate_read ( ipc_msg_t * cmd , void * arg ) { int rc ; uint32_t scomAddr ; uint64_t regValue ; ipc_async_cmd_t * async_cmd = ( ipc_async_cmd_t * ) cmd ; dimm_sm_args_t * args = ( dimm_sm_args_t * ) async_cmd -> cmd_data ; args -> error . rc = GPE_RC_NOT_COMPLETE ; scomAddr = I2C_STATUS_REG | SCOM_ENGINE_OFFSET ( args -> i2cEngine ) ; rc = getscom_abs ( scomAddr , & regValue ) ; if ( rc ) { PK_TRACE ( " " , scomAddr , rc ) ; gpe_set_ffdc ( & ( args -> error ) , scomAddr , GPE_RC_SCOM_GET_FAILED , rc ) ; } else { GPE1_DIMM_DBG ( " " , scomAddr , WORD_HIGH ( regValue ) , WORD_LOW ( regValue ) ) ; if ( ( regValue & STATUS_ERROR_OR_COMPLETE_MASK ) == STATUS_COMPLETE_MASK ) { scomAddr = I2C_COMMAND_REG | SCOM_ENGINE_OFFSET ( args -> i2cEngine ) ; regValue = 0xD001000400000000 ; regValue |= ( ( uint64_t ) args -> i2cAddr << 48 ) ; rc = putscom_abs ( scomAddr , regValue ) ; if ( rc ) { PK_TRACE ( " " , scomAddr , WORD_HIGH ( regValue ) , WORD_LOW ( regValue ) , rc ) ; gpe_set_ffdc ( & ( args -> error ) , scomAddr , GPE_RC_SCOM_PUT_FAILED , rc ) ; } else { GPE1_DIMM_DBG ( " " , scomAddr , WORD_HIGH ( regValue ) , WORD_LOW ( regValue ) ) ; args -> error . error = 0 ; args -> error . rc = GPE_RC_SUCCESS ; args -> error . ffdc = 0 ; } } else { if ( ( regValue & STATUS_ERROR_OR_COMPLETE_MASK ) != 0 ) { PK_TRACE ( " " , WORD_HIGH ( regValue ) , WORD_LOW ( regValue ) ) ; gpe_set_ffdc ( & ( args -> error ) , scomAddr , GPE_RC_I2C_ERROR , regValue ) ; } else { PK_TRACE ( " " ) ; gpe_set_ffdc ( & ( args -> error ) , scomAddr , GPE_RC_NOT_COMPLETE , regValue ) ; } } } }
Function Specifications:
 Name: dimm_initiate_read
Function Specifications : Name : dimm_initiate_read
// a pointer to hold the putscom_abs register value // Default the rc to NOT_COMPLETE (meaning the read was not initiated) // Read the I2c Status Register to ensure the TS address was written successfully // Status register indicates no errors and last command completed. // Write the I2C command register with a 2 byte read request. // Since FIFO4 can read 4 bytes in one operation, we will do a read of 4 bytes // and only look at first 2 bytes.  (FIFO4 will hang if only try to read 2 bytes) // start+address+stop + slave_address, rw=1=read, length=4 // The read command has been started, return success // I2C error was found // Last command (write TS address) has not completed yet // else, not complete yet