mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 21:22:39 -05:00
rk27xx: Turn off lsadc clock when not in use
Change-Id: Ic3f29e75aa5b894f17e289263a370fac13e2f1d8
This commit is contained in:
parent
ae27c331e1
commit
2b6886d107
1 changed files with 15 additions and 5 deletions
|
|
@ -28,6 +28,14 @@
|
|||
|
||||
unsigned short adc_read(int channel)
|
||||
{
|
||||
unsigned short result;
|
||||
|
||||
/* ungate lsadc clocks */
|
||||
SCU_CLKCFG &= ~(3<<23);
|
||||
|
||||
/* wait a bit for clock to stabilize */
|
||||
udelay(10);
|
||||
|
||||
ADC_CTRL = (1<<4)|(1<<3) | (channel & (NUM_ADC_CHANNELS - 1));
|
||||
|
||||
/* Wait for conversion ready.
|
||||
|
|
@ -38,16 +46,18 @@ unsigned short adc_read(int channel)
|
|||
* ~10us should be enough so we wait 20us to be on the safe side
|
||||
*/
|
||||
udelay(20);
|
||||
|
||||
|
||||
/* 10bits result */
|
||||
return (ADC_DATA & 0x3ff);
|
||||
result = (ADC_DATA & 0x3ff);
|
||||
|
||||
/* turn off lsadc clock when not in use */
|
||||
SCU_CLKCFG |= (3<<23);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void adc_init(void)
|
||||
{
|
||||
/* ADC clock divider to reach max 1MHz */
|
||||
SCU_DIVCON1 = (SCU_DIVCON1 & ~(0xff<<10)) | (49<<10);
|
||||
|
||||
/* enable clocks for ADC */
|
||||
SCU_CLKCFG &= ~(3<<23);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue