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

static uint32_t scc_update_state ( void   )  [static]

Make certain SCC is still running.

Side effect is to update scc_availability and, if the state goes to failed, run scc_perform_callbacks().

(If SCC_BRINGUP is defined, bring SCC to secure state if it is found to be in health check state)

Returns:
Current value of SMN_STATUS register.

Definition at line 1163 of file mxc_scc.c.

References os_printk, scc_availability, scc_perform_callbacks(), SCC_READ_REGISTER, SCC_STATUS_CHECKING, SCC_STATUS_FAILED, SCC_STATUS_OK, SCC_STATUS_UNIMPLEMENTED, SCC_WRITE_REGISTER, SMN_SEQUENCE_CHECK, SMN_SEQUENCE_END, SMN_SEQUENCE_START, SMN_STATE_FAIL, SMN_STATE_HEALTH_CHECK, SMN_STATE_NON_SECURE, SMN_STATE_SECURE, SMN_STATUS, and SMN_STATUS_STATE_MASK.

Referenced by OS_DEV_ISR(), scc_crypt(), scc_grab_config_values(), scc_read_register(), scc_set_sw_alarm(), and scc_write_register().

{
      uint32_t smn_status_register = SMN_STATE_FAIL;
      int smn_state;

      /* if FAIL or UNIMPLEMENTED, don't bother */
      if (scc_availability == SCC_STATUS_CHECKING ||
          scc_availability == SCC_STATUS_OK) {

            smn_status_register = SCC_READ_REGISTER(SMN_STATUS);
            smn_state = smn_status_register & SMN_STATUS_STATE_MASK;

#ifdef SCC_BRINGUP
            /* If in Health Check while booting, try to 'bringup' to Secure mode */
            if (scc_availability == SCC_STATUS_CHECKING &&
                smn_state == SMN_STATE_HEALTH_CHECK) {
                  /* Code up a simple algorithm for the ASC */
                  SCC_WRITE_REGISTER(SMN_SEQUENCE_START, 0xaaaa);
                  SCC_WRITE_REGISTER(SMN_SEQUENCE_END, 0x5555);
                  SCC_WRITE_REGISTER(SMN_SEQUENCE_CHECK, 0x5555);
                  /* State should be SECURE now */
                  smn_status_register = SCC_READ_REGISTER(SMN_STATUS);
                  smn_state = smn_status_register & SMN_STATUS_STATE_MASK;
            }
#endif

            /*
             * State should be SECURE or NON_SECURE for operation of the part.  If
             * FAIL, mark failed (i.e. limited access to registers).  Any other
             * state, mark unimplemented, as the SCC is unuseable.
             */
            if (smn_state == SMN_STATE_SECURE
                || smn_state == SMN_STATE_NON_SECURE) {
                  /* Healthy */
                  scc_availability = SCC_STATUS_OK;
            } else if (smn_state == SMN_STATE_FAIL) {
                  scc_availability = SCC_STATUS_FAILED;     /* uh oh - unhealthy */
                  scc_perform_callbacks();
                  os_printk(KERN_ERR "SCC: SCC went into FAILED mode\n");
            } else {
                  /* START, ZEROIZE RAM, HEALTH CHECK, or unknown */
                  scc_availability = SCC_STATUS_UNIMPLEMENTED;    /* unuseable */
                  os_printk(KERN_ERR "SCC: SCC declared UNIMPLEMENTED\n");
            }
      }
      /* if availability is initial or ok */
      return smn_status_register;
}


Generated by  Doxygen 1.6.0   Back to index