[alsa-devel] [PATCHv4 7/7] ASoC: TWL6030: Detect power-up sequence completion

Olaya, Margarita magi.olaya at ti.com
Fri Feb 26 22:04:22 CET 2010


On Thursday, February 25, 2010 2:42 AM  Mark Brown wrote: 

>>> On Tue, Feb 23, 2010 at 06:10:54PM -0600, Olaya, Margarita wrote:
>>> 
>>>> +    if (naudint) {
>>>> +        /* wait for ready interrupt with 48 ms timeout */
>>>> +        time_left = wait_for_completion_timeout(&priv->ready,
>>>> +                    msecs_to_jiffies(48));

Phoenix manages automatic and manual power on sequences. READYINT
indicates the completion of power up sequence, Phoenix audio drives
the NAUDINT line low when an interrupt is internally detected, when
automatic power on sequence is used, the state of READYINIT is verified
through the interrupt handler using wait_for_completion.

>>>> +    } else {
>>>> +        /* retry 3 times only */
>>>> +        for (time_left = 3; time_left > 0; time_left--) { +    
>>>> mdelay(16); +           
>>>> twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &intid, +           
>>>> TWL6030_REG_INTID); +            if (intid & TWL6030_READYINT)
>>>> +                break;
>>>> +        }

When manual power on sequence is used the driver verifies the status of 
READYINIT by polling.

In both cases if READYINIT is not set before the timeout runs out it means
the codec is not powering on and the driver reports an error.

- Margarita

>>>> +    }
>>> 



>>> It strikes me that you could combine these two cases - the
>>> wait_for_completion_timeout() will function just as well as a
>>> delay. I'd also expect to see an error reported if the device
>>> doesn't report as ready one way or another.
>> 
>> It is split to prevent the case of none valid irq line connected,
>> in such case, wait_for_completion won't work
> 
> It will - you can specify a timeout so if the interrupt doesn't
> happen all that happens is that you delay for the specified timeout.



More information about the Alsa-devel mailing list