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

void mxc_cpu_lp_set ( enum mxc_cpu_pwr_mode  mode  ) 

This function is used to set cpu low power mode before WFI instruction

Parameters:
mode indicates different kinds of power modes

Definition at line 52 of file system.c.

Referenced by arch_idle().

{
      unsigned int lpm;
      unsigned long reg;
      unsigned int pmcr2, lpimr;
      unsigned int cgcr0, cgcr1, cgcr2;
      struct irq_desc *desc;
      int i;

      /*read CCTL value */
      reg = __raw_readl(MXC_CCM_CCTL);

      switch (mode) {
      case WAIT_UNCLOCKED_POWER_OFF:
            lpm = MX25_DOZE_MODE;
            break;

      case STOP_POWER_ON:
      case STOP_POWER_OFF:
            lpm = MX25_STOP_MODE;
            /* The clock of LCDC/SLCDC, SDMA, RTIC, RNGC, MAX, CAN
               and EMI needs to be gated on when entering Stop mode.
             */
            cgcr0 = __raw_readl(MXC_CCM_CGCR0);
            cgcr1 = __raw_readl(MXC_CCM_CGCR1);
            cgcr2 = __raw_readl(MXC_CCM_CGCR2);
            __raw_writel(cgcr0 | MXC_CCM_CGCR0_STOP_MODE_MASK,
                       MXC_CCM_CGCR0);
            __raw_writel(cgcr1 | MXC_CCM_CGCR1_STOP_MODE_MASK,
                       MXC_CCM_CGCR1);
            __raw_writel(cgcr2 | MXC_CCM_CGCR2_STOP_MODE_MASK,
                       MXC_CCM_CGCR2);
            /* The interrupts which are not wake-up sources need
               be mask when entering Stop mode.
             */
            lpimr = MXC_CCM_LPIMR0_MASK;
            for (i = 0; i < 32; i++) {
                  desc = irq_desc + i;
                  if ((desc->status & IRQ_WAKEUP) != 0)
                        lpimr &= ~(1 << i);
            }
            __raw_writel(lpimr, MXC_CCM_LPIMR0);
            lpimr = MXC_CCM_LPIMR1_MASK;
            for (i = 32; i < 64; i++) {
                  desc = irq_desc + i;
                  if ((desc->status & IRQ_WAKEUP) != 0)
                        lpimr &= ~(1 << (i - 32));
            }
            __raw_writel(lpimr, MXC_CCM_LPIMR1);

            if (mode == STOP_POWER_OFF) {
                  pmcr2 = __raw_readl(MXC_CCM_PMCR2);
                  pmcr2 |= (MXC_CCM_PMCR2_OSC24M_DOWN |
                          MXC_CCM_PMCR2_VSTBY);
                  __raw_writel(pmcr2, MXC_CCM_PMCR2);
            }
            break;

      case WAIT_CLOCKED:
      case WAIT_UNCLOCKED:
      default:
            /* Wait is the default mode used when idle. */
            lpm = MX25_WAIT_MODE;
            break;
      }

      /* program LP CTL bit */
      reg = ((reg & (~MXC_CCM_CCTL_LP_CTL_MASK)) |
             lpm << MXC_CCM_CCTL_LP_CTL_OFFSET);

      __raw_writel(reg, MXC_CCM_CCTL);
}


Generated by  Doxygen 1.6.0   Back to index