Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

static uint32_t scc_do_crypto ( int  byte_count,
uint32_t  scm_command 
) [static]

Have the SCM perform the crypto function.

Set up length register, and the store scm_control into control register to kick off the operation. Wait for completion, gather status, clear interrupt / status.

Parameters:
byte_count number of bytes to perform in this operation
scm_command Bit values to be set in SCM_CCMD_REG register
Returns:
0 on success, value of SCM_ERR_STATUS_REG on failure

Definition at line 1294 of file scc2_driver.c.

References SCC_BLOCK_SIZE_BYTES, SCC_READ_REGISTER, scc_wait_completion(), SCC_WRITE_REGISTER, SCM_CCMD_LENGTH_SHIFT, SCM_CCMD_REG, SCM_ERR_STATUS_REG, SCM_ERRSTAT_ILM, SCM_STATUS_ERR, and SCM_STATUS_REG.

{
      int block_count = byte_count / SCC_BLOCK_SIZE_BYTES();
      uint32_t crypto_status;
      scc_return_t ret;

      /* This seems to be necessary in order to allow subsequent cipher
       * operations to succeed when a partition is deallocated/reallocated!
       */
      (void)SCC_READ_REGISTER(SCM_STATUS_REG);

      /* In length register, 0 means 1, etc. */
      scm_command |= (block_count - 1) << SCM_CCMD_LENGTH_SHIFT;

      /* set modes and kick off the operation */
      SCC_WRITE_REGISTER(SCM_CCMD_REG, scm_command);

      ret = scc_wait_completion(&crypto_status);

      /* Only done bit should be on */
      if (crypto_status & SCM_STATUS_ERR) {
            /* Replace with error status instead */
            crypto_status = SCC_READ_REGISTER(SCM_ERR_STATUS_REG);
            pr_debug("SCM Failure: 0x%x\n", crypto_status);
            if (crypto_status == 0) {
                  /* That came up 0.  Turn on arbitrary bit to signal error. */
                  crypto_status = SCM_ERRSTAT_ILM;
            }
      } else {
            crypto_status = 0;
      }
      pr_debug("SCC2: Done waiting.\n");

      return crypto_status;
}


Generated by  Doxygen 1.6.0   Back to index