1
0
Fork 0
forked from len0rd/rockbox

Enable/disable second pll dynamically on usb plugin/remove.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26145 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Tobias Diedrich 2010-05-18 16:23:11 +00:00
parent 681cedb4d8
commit 0f6b5f03d9
3 changed files with 41 additions and 8 deletions

View file

@ -242,6 +242,13 @@ CE lines
#define CGU_TIMER2_CLOCK_ENABLE ( 1 << 8 ) /* timer 2 */
#define CGU_TIMERIF_CLOCK_ENABLE ( 1 << 7 ) /* timer interface */
/* CGU_PLL[AB]SUP bits */
#define CGU_PLL_POWERDOWN ( 1 << 3 )
/* CGU_INTCTRL bits */
#define CGU_PLLA_LOCK ( 1 << 0 )
#define CGU_PLLB_LOCK ( 1 << 1 )
/** ------------------------------------------------------------------
* Number of cycles to wait before cgu is safely locked.
**/

View file

@ -320,16 +320,16 @@ void system_init(void)
"mcr p15, 0, r0, c1, c0 \n"
: : : "r0" );
CGU_COUNTA = 0xff;
CGU_COUNTA = CGU_LOCK_CNT;
CGU_PLLA = AS3525_PLLA_SETTING;
CGU_PLLASUP = 0; /* enable PLLA */
while(!(CGU_INTCTRL & (1<<0))); /* wait until PLLA is locked */
#if (defined(USE_ROCKBOX_USB) && CONFIG_CPU==AS3525) || (AS3525_MCLK_SEL == AS3525_CLK_PLLB)
CGU_COUNTB = 0xff;
CGU_PLLASUP = 0; /* enable PLLA */
while(!(CGU_INTCTRL & CGU_PLLA_LOCK)); /* wait until PLLA is locked */
#if AS3525_MCLK_SEL == AS3525_CLK_PLLB
CGU_COUNTB = CGU_LOCK_CNT;
CGU_PLLB = AS3525_PLLB_SETTING;
CGU_PLLBSUP = 0; /* enable PLLB */
while(!(CGU_INTCTRL & (1<<1))); /* wait until PLLB is locked */
CGU_PLLBSUP = 0; /* enable PLLB */
while(!(CGU_INTCTRL & CGU_PLLB_LOCK)); /* wait until PLLB is locked */
#endif
/* Set FCLK frequency */

View file

@ -306,6 +306,29 @@ static struct usb_dev_setup_buf dummy __attribute__((unused));
static char rx_buf[1024];
static char tx_buf[1024];
#if AS3525_MCLK_SEL != AS3525_CLK_PLLB
static inline void usb_enable_pll(void)
{
CGU_COUNTB = CGU_LOCK_CNT;
CGU_PLLB = AS3525_PLLB_SETTING;
CGU_PLLBSUP = 0; /* enable PLLB */
while(!(CGU_INTCTRL & CGU_PLLB_LOCK)); /* wait until PLLB is locked */
}
static inline void usb_disable_pll(void)
{
CGU_PLLBSUP = CGU_PLL_POWERDOWN;
}
#else
static inline void usb_enable_pll(void)
{
}
static inline void usb_disable_pll(void)
{
}
#endif /* AS3525_MCLK_SEL != AS3525_CLK_PLLB */
void usb_attach(void)
{
usb_enable(true);
@ -448,6 +471,8 @@ void usb_drv_init(void)
{
logf("usb_drv_init() !!!!\n");
usb_enable_pll();
/* length regulator: normal operation */
ascodec_write(AS3514_CVDD_DCDC3, ascodec_read(AS3514_CVDD_DCDC3) | 1<<2);
@ -524,6 +549,7 @@ void usb_drv_exit(void)
CGU_PERI &= ~CGU_USB_CLOCK_ENABLE;
/* Disable UVDD generating LDO */
ascodec_write(AS3515_USB_UTIL, ascodec_read(AS3515_USB_UTIL) & ~(1<<4));
usb_disable_pll();
logf("usb_drv_exit() !!!!\n");
}