6/14/2012

Sleep Mechanism in Qualcom msm8x55 chipset ---- Sleep in a Glance

The sleep mechanism in the mobile phone is devised to conserve the mobile's power. It accomplishes this goal by configuring the mobile to sleep and draw minimum current when the phone is in Idle mode and has no task to run. During deep sleep, most clocks and hardware blocks are put into rest, the microprocessor is halted, unused voltage regulators are shut off, the LPXO and XO are stopped, leaving the sleep crystal oscillator, which oscillates at approximately 32 kHz
and consumes considerably less power than the LPXO and XO, and MPM block still on to monitor any wakeup events. When appropriately designed, the sleep mechanism will result in considerable power saving, and the mobile's standby time can be lengthened significantly.

In AMSS, there is a sleep (idle) task that normally has the lowest priority among all tasks. When there is no other task to run, the sleep task will become active. It checks various signals to see whether it is okay to put the phone into sleep. If there is a consensus for sleep, it will figure out
the maximum possible duration of the sleep by checking the expiration time of active timers and the next wakeup point from the sleep controller. If the amount of time permits a deep sleep, the sleep task will proceed to turn off various clocks, halt ARM and shut down LPXO and XO.

When a wakeup interrupt fires during sleep, the system will wake up immediately to handle the pending request.

In other documents and source code, the deep sleep is often referred to as TCXO shutdown. This is because in earlier MSM chips, instead of LPXO and XO, there is a TCXO (Temperature Compensated Crystal Oscillator) that runs at 19.2 MHz and is used as the source of most MSM clock regimes. In MSM7x30, TCXO is replaced by LPXO and XO, so TCXO shutdown, which appears as a legacy term in MSM7x30, means deep sleep, in which both LPXO and XO are turned off.


1 General considerations

The design of the sleep mechanism is complicated by several requirements, and sometimes specialized hardware/software components are devised to address these complications.

Above all, the MSM in sleep must consume significantly less power than the MSM in Online mode to justify all of the complications of sleep design. This requirement naturally leads to
freezing as many unused hardware blocks as possible, designing a minimum power-consuming clock when the MSM is in sleep. In addition, due to the smaller and smaller transistor dimension,
leakage current accounts for a more significant portion of the quiescent current. As a result, besides shutting off clocks, we need to go to extra lengths applying power collapse and turning off unused Voltage Regulators (VREGs) to obtain as much power saving as possible. On the other hand, these measures generally have the adverse effect of increasing the warmup time, i.e., the time required for the MSM to recover from sleep and become fully online, and thus reduce the
benefit of sleep.



Even if the mobile phone is not engaged in an active call, the device needs to maintain a regular connection with the Base Station (BS) and check on the paging channel to see whether there are any incoming calls and messages. The CDMA protocols facilitate this operation by assigning a specific slot in the paging channel for each mobile when it camps on the BS. Hence, the mobile needs to be awake at its assigned time slot to listen to the BS so that it will not miss or delay any incoming calls. This requirement dictates that the CDMA searcher (the software component in AMSS that handles the task of maintaining the constant connection with the BS) plays a significant role in sleep design, and a hardware component called sleep controller is provided mainly for maintaining the CDMA sleep timeline so that the CDMA service will not be disrupted by the sleep mechanism. (In fact, there can be separate sleep controllers for CDMA, HDR, and GSM due to their distinct timing requirements.) Although today more and more functions, such as music, camera, games, etc., are attached to mobile phones, the CDMA sleep timeline is still onsidered the dominant factor in determining the sleep duration and hence the phone's standby time. To maximize the profit of sleep, it is necessary that the time spent on warmup and listening to the paging channel is minimized. Naturally, this leads to various optimizations on MSM/RF blocks to minimize the wakeup time, which makes up a major topic in its own right.

In addition to listening to the paging channel, the searcher software needs to periodically sample the signal strength of nearby BSs to ensure that the best BS in the neighborhood is selected for the mobile phone's connectivity. This has to be taken into account in the sleep timeline.

When the phone is not in the service range of any BS, it is generally advisable for the mobile to have longer sleeps and wake up less often to detect whether it has come into the range of a BS.

When there is no need to maintain regular connections with the BS, for instance, while using the phone on a airplane, the radio component of the phone can often be turned off by switching the phone into flight (or Airplane) mode. In this mode, since radio is turned off, the sleep time will be solely determined by software timers, and generally the time the device can stay in sleep is considerably longer.

Although some software tasks are not active, they may not agree to being suspended for the duration of a full sleep, e.g., the task may be suspended, but it is expecting an immediate response from an external device. Alternatively, software may initialize a hardware task that depends on the LPXO or XO, and will hold off sleep until the duration of this hardware event has expired. Hence, a voting mechanism is devised so that the mobile will enter sleep only when all tasks in voting have agreed to going into sleep.

In addition to the strict timing requirement posed by CDMA searcher, other tasks may have their own timers to which they need to respond. This requires the sleep task to survey the nearest expiration time of such timers. Due to the warmup time that must be endured when coming out of sleep, there is a minimum amount of time necessary in order to make the decision to sleep. If the sleep software initiates a shutdown of XO, only to be immediately followed by turning it back on, then there is no power savings, and in fact more power might be consumed during the process. Therefore, only when the amount of time permits an XO shutdown will the sleep task proceed to sleep and program the sleep duration accordingly.

During sleep Watchdog needs to be put on autokick to prevent it from triggering a reset.

While the phone is in sleep, it should still be responsive to certain interrupts, e.g., if the user presses the keypad, the mobile should come back into the Active state within a tolerable delay. In addition, when an interrupt is fired during the power-down sequence, the power-up procedure will take place right after power-down is finished, so that the interrupt is handled as early as possible.


The SDRAM will be put in self-refresh mode to maintain its content during deep sleep.

In a dual processor system, two processors need to be coordinated. In the MSM7x30, this is handled in a master-slave fashion. The modem processor (ARM11) acts as the power master, and
the apps (Scorpion) processor acts as the slave. When the apps processor decides to go into power collapse, the modem processor will be responsible for handling apps interrupts and turning off the apps power rail. Deep sleep (XO shutdown) process is also handled by the modem processor and it happens only when the apps processor is already in sleep. Essentially, the apps processor is one voter of the sleep (its vote is cast by the DEM task), and deep sleep can happen only when the apps processor is off.




2. tware and hardware components
The sleep mechanism involves almost all hardware/software components of the MSM. However, a few hardware/software components stand out with their active participation of the sleep process. In particular, the sleep controller, the MSM clock regimes, interrupt controllers, MPM block, and the sleep task are essential in the sleep mechanism, and these will be the focus of this document.

Many software tasks take part in the voting of sleep. No software tasks except for the sleep task can be in the Active state to allow the MSM chipset to enter sleep. Most hardware blocks are turned off during sleep. RF blocks are put into rest. PMIC is instructed to shut off unused VREGs and turn off XOs before entering sleep.

The rest of this document is structured as follows. Chapter 3 discusses the sleep task, which handles the deep sleep process. the SMSM (Shared Memory State Machine) and DEM (Dynamic Environment Manager) modules, which handle the handshaking between the modem and apps processors during the apps sleep process. Chapter 5 presents how interrupt is involved in the sleep process, as well as additional information on how to debug the sleep process.

No comments:

Post a Comment