On Fri, Jun 15, 2012 at 6:28 AM, Jean Pihet <jean.pihet@xxxxxxxxxxxxxx> wrote: > > " > 1. The while loops need optimization. - This can definitely be > simplified and made non-risky; this also needs some more error > handling If you are interested using something like the following static int _match_pwrst(u32 pwrsts, u8 pwrst, u8 default_pwrst) { bool found = true; int new_pwrst = pwrst; /* Search down */ while (!(pwrsts & (1 << new_pwrst))) { if (new_pwrst == PWRDM_POWER_OFF) { found = false; break; } new_pwrst--; } if (found) goto done; /* Search up */ new_pwrst = pwrst; while (!(pwrsts & (1 << new_pwrst))) { if (new_pwrst == default_pwrst) break; new_pwrst++; } done: return new_pwrst; } new_pwrst = _match_pwrst(pwrdm->pwrsts, pwrst, PWRDM_POWER_ON); new_logic = _match_pwrst(pwrdm->pwrsts_logic_ret, logic, PWRDM_POWER_RET); to achieve the same code.. > 2. About the power domains state machine: you have only one power > state to move in and out of: it is called ON. If you do ON->CSWR->ON > etc. attempting to program ON->CSWR->OSWR is NOT supported in OMAP and > is an invitation for production team to sit and debug for a while > before finding the use of invalid power states > " > > Point 2 is a good point. The solution would be to implement a state > machine in this function and/or omap_set_pwrdm_state, possibly using a > platform specific handling function. Point 2 is not completely accurate -> Lower pwr state transitions can indeed and is indeed supported on OMAP4+. CSWR->OSWR->OFF is possible and omap_setpwrdm_state does indeed handle this. however going to OSWR->CSWR is possible only by OSWR->ON->CSWR. this is again supported in code, however, in practice, we have found that certain IP blocks(in personal experience, it was DSS) need IP specific additional work which is not easily doable.. so when we come out of suspend state, if the IP block has achieved a lower powerstate than what was programmed, we just leave it as is. Regards, Nishanth Menon -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html