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

static void scc_cleanup ( void   )  [static]

Perform cleanup before driver/module is unloaded by setting the machine state close to what it was when the driver was loaded. This function is called when the kernel is shutting down or when this driver is being unloaded.

A driver like this should probably never be unloaded, especially if there are other module relying upon the callback feature for monitoring the SCC status.

In any case, cleanup the callback table (by clearing out all of the pointers). Deregister the interrupt handler(s). Unmap SCC registers.

Note that this will not release any partitions that have been allocated.

Definition at line 682 of file scc2_driver.c.

References INT_SCC_SCM, INT_SCC_SMN, os_deregister_interrupt, os_lock_deallocate, scc_availability, scc_base, SCC_CALLBACK_SIZE, scc_callbacks, scc_callbacks_lock, scc_crypto_lock, SCC_STATUS_UNIMPLEMENTED, SCC_WRITE_REGISTER, SCM_INT_CTL_REG, scm_irq_set, SMN_COMMAND_CLEAR_INTERRUPT, SMN_COMMAND_REG, and smn_irq_set.

{
      int i;

    /******************************************************/

      /* Mark the driver / SCC as unusable. */
      scc_availability = SCC_STATUS_UNIMPLEMENTED;

      /* Clear out callback table */
      for (i = 0; i < SCC_CALLBACK_SIZE; i++) {
            scc_callbacks[i] = 0;
      }

      /* If SCC has been mapped in, clean it up and unmap it */
      if (scc_base) {
            /* For the SCM, disable interrupts. */
            SCC_WRITE_REGISTER(SCM_INT_CTL_REG, 0);

            /* For the SMN, clear and disable interrupts */
            SCC_WRITE_REGISTER(SMN_COMMAND_REG,
                           SMN_COMMAND_CLEAR_INTERRUPT);
      }

      /* Now that interrupts cannot occur, disassociate driver from the interrupt
       * lines.
       */

      /* Deregister SCM interrupt handler */
      if (scm_irq_set) {
            os_deregister_interrupt(INT_SCC_SCM);
      }

      /* Deregister SMN interrupt handler */
      if (smn_irq_set) {
#ifdef USE_SMN_INTERRUPT
            os_deregister_interrupt(INT_SCC_SMN);
#endif
      }

      /* Finally, release the mapped memory */
      iounmap(scm_ram_base);

      if (scc_callbacks_lock != NULL)
            os_lock_deallocate(scc_callbacks_lock);

      if (scc_crypto_lock != NULL)
            os_lock_deallocate(scc_crypto_lock);

    /*Disabling SCC Clock*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 18))
                  mxc_clks_disable(SCC_CLK);
#else
                  if (scc_clk != ERR_PTR(ENOENT))
                        clk_disable(scc_clk);
                  clk_put(scc_clk);
#endif
      pr_debug("SCC2 driver cleaned up.\n");

}                       /* scc_cleanup */


Generated by  Doxygen 1.6.0   Back to index