diff options
| author | Keith Packard <keithp@keithp.com> | 2013-06-17 14:00:11 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2013-06-17 14:00:11 -0700 | 
| commit | 298e54856b5f8809b43f24407caa4a6be60822f3 (patch) | |
| tree | 670b834a18ff24f4d35d2c0d171dc9324d52a886 /src/lpc/ao_timer_lpc.c | |
| parent | b3ad488477def157e277e239e81f164b49725925 (diff) | |
altos/lpc: Get the IRC turned off after boot time
This involved carefully moving the USB away from the IRC before
turning it off.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/lpc/ao_timer_lpc.c')
| -rw-r--r-- | src/lpc/ao_timer_lpc.c | 17 | 
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lpc/ao_timer_lpc.c b/src/lpc/ao_timer_lpc.c index 62235d1e..c0de90a3 100644 --- a/src/lpc/ao_timer_lpc.c +++ b/src/lpc/ao_timer_lpc.c @@ -106,12 +106,18 @@ ao_clock_init(void)  	/* Switch to the IRC clock */  	lpc_scb.mainclksel = LPC_SCB_MAINCLKSEL_SEL_IRC << LPC_SCB_MAINCLKSEL_SEL; -	lpc_scb.mainclkuen = (1 << LPC_SCB_MAINCLKUEN_ENA);  	lpc_scb.mainclkuen = (0 << LPC_SCB_MAINCLKUEN_ENA);  	lpc_scb.mainclkuen = (1 << LPC_SCB_MAINCLKUEN_ENA);  	while (!(lpc_scb.mainclkuen & (1 << LPC_SCB_MAINCLKUEN_ENA)))  		; +	/* Switch USB to the main clock */ +	lpc_scb.usbclksel = (LPC_SCB_USBCLKSEL_SEL_MAIN_CLOCK << LPC_SCB_USBCLKSEL_SEL); +	lpc_scb.usbclkuen = (0 << LPC_SCB_USBCLKUEN_ENA); +	lpc_scb.usbclkuen = (1 << LPC_SCB_USBCLKUEN_ENA); +	while (!(lpc_scb.usbclkuen & (1 << LPC_SCB_USBCLKUEN_ENA))) +		; +	  	/* Find a PLL post divider ratio that gets the FCCO in range */  	for (p = 0; p < 4; p++)  		if (AO_LPC_CLKOUT << (1 + p) >= AO_LPC_FCCO_MIN) @@ -178,7 +184,13 @@ ao_clock_init(void)  	lpc_scb.usbclkdiv = 0;  	lpc_scb.clkoutdiv = 0; -#if 0 +	/* Switch USB PLL source to system osc so we can power down the IRC */ +	lpc_scb.usbpllclksel = (LPC_SCB_USBPLLCLKSEL_SEL_SYSOSC << LPC_SCB_USBPLLCLKSEL_SEL); +	lpc_scb.usbpllclkuen = (0 << LPC_SCB_USBPLLCLKUEN_ENA); +	lpc_scb.usbpllclkuen = (1 << LPC_SCB_USBPLLCLKUEN_ENA); +	while (!(lpc_scb.usbpllclkuen & (1 << LPC_SCB_USBPLLCLKUEN_ENA))) +		; +	  	/* Power down everything we don't need */  	lpc_scb.pdruncfg = ((1 << LPC_SCB_PDRUNCFG_IRCOUT_PD) |  			    (1 << LPC_SCB_PDRUNCFG_IRC_PD) | @@ -189,5 +201,4 @@ ao_clock_init(void)  			    (1 << LPC_SCB_PDRUNCFG_USBPAD_PD) |  			    (1 << 11) |  			    (7 << 13)); -#endif  }  | 
