summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/ascodec-as3525.c
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2018-07-27 23:56:32 +0200
committerWilliam Wilgus <me.theuser@yahoo.com>2018-07-27 23:56:32 +0200
commit6f0320a9535bc1aa81d83fa879ac14d5ee603658 (patch)
tree3b12fc361595ecd2249f391e114036cb30150105 /firmware/target/arm/as3525/ascodec-as3525.c
parent400603abdfb4ba7566e0cae8dbed9268f06716dc (diff)
downloadrockbox-6f0320a9535bc1aa81d83fa879ac14d5ee603658.tar.gz
rockbox-6f0320a9535bc1aa81d83fa879ac14d5ee603658.zip
As3525 v1/v2 Add power savings menu
Allow user to select cpu undervolt There have been quite a few issues across the SANSA AMS line related to CPU undervolting while most players show greatly increased runtime some crash. Rather than constanly upping the voltage we now have a setting with a safe value for all players and the option for lower voltages I plan to add a few other options here later such as disk timings and maybe some other clocks/experimental settings Added: Disk Low speed option for AS3525v2 devices cuts frequency to 12 MHz from 24 MHz Added: Disk Low speed option for AS3525v1 devices cuts frequency to 15.5 MHz from 31 MHz Added: I2c Low Speed AS3525 devices, should be bigger improvement for v1 devices Fixed: Debug menu for AS3525v2 No SDSLOT frequency, Showed IDE freq though it is unused Added: DBOP and SSP underclocking affects display on v1/v2 respectively Fixed: debug menu now has SSP frequency, and SSP_CPSR Update: made settings menu more generic Update: cleaned up code Added: Clip v1 & Fuze v1 didn't have HAVE_ADJUSTABLE_CPU_VOLTAGE. not sure why but, waiting on testing to confirm Added: C200v2 and E200v2 devices and HAVE_ADJUSTABLE_CPU_VOLTAGE. Fixed: v1 devices don't like display timing set lower (dbop) v1 devices don't have a divider set for ssp (causes divide by 0) Fixed: ClipZip display lags with Max SSP divider changed from 0xFE to 0x32 Fixed: v1 devices didn't work properly with highspeed sd cards Added code from http://gerrit.rockbox.org/r/#/c/1704/ Added powersave and IDE interface enable/disable Added: V2 devices now have powersave enabled on sd interface Update: cleaned up code, lang defines, added manual entries Update ssp clock mechanism added calculated ssp divider to clipzip Update turn display clock off when clip+ turns off display Fixed: clipzip wrong register for SSP clock Change-Id: I04137682243be92f0f8d8bf1cfa54fbb1965559b TODO: add other players?
Diffstat (limited to 'firmware/target/arm/as3525/ascodec-as3525.c')
-rw-r--r--firmware/target/arm/as3525/ascodec-as3525.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/firmware/target/arm/as3525/ascodec-as3525.c b/firmware/target/arm/as3525/ascodec-as3525.c
index 14c3ee7a36..d23859e420 100644
--- a/firmware/target/arm/as3525/ascodec-as3525.c
+++ b/firmware/target/arm/as3525/ascodec-as3525.c
@@ -623,11 +623,25 @@ void i2c_init(void)
623 /* required function but called too late for our needs */ 623 /* required function but called too late for our needs */
624} 624}
625 625
626static void i2c_set_prescaler(unsigned int prescaler)
627{
628 int oldlevel = disable_interrupt_save(IRQ_FIQ_STATUS);
629 /* must be on to write regs */
630 bool i2c_enabled = bitset32(&CGU_PERI, CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE) &
631 CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE;
632
633 I2C2_CPSR0 = prescaler & 0xFF; /* 8 lsb */
634 I2C2_CPSR1 = (prescaler >> 8) & 0x3; /* 2 msb */
635
636 if (!i2c_enabled) /* put it back how we found it */
637 bitclr32(&CGU_PERI, CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE);
638
639 restore_irq(oldlevel);
640}
641
626/* initialises the internal i2c bus and prepares for transfers to the codec */ 642/* initialises the internal i2c bus and prepares for transfers to the codec */
627void ascodec_init(void) 643void ascodec_init(void)
628{ 644{
629 int prescaler;
630
631 ll_init(&req_list); 645 ll_init(&req_list);
632 mutex_init(&as_mtx); 646 mutex_init(&as_mtx);
633 ascodec_async_init(&as_audio_req, ascodec_int_audio_cb, 0); 647 ascodec_async_init(&as_audio_req, ascodec_int_audio_cb, 0);
@@ -637,9 +651,7 @@ void ascodec_init(void)
637 bitset32(&CGU_PERI, CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE); 651 bitset32(&CGU_PERI, CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE);
638 652
639 /* prescaler for i2c clock */ 653 /* prescaler for i2c clock */
640 prescaler = AS3525_I2C_PRESCALER; 654 i2c_set_prescaler(AS3525_I2C_PRESCALER);
641 I2C2_CPSR0 = prescaler & 0xFF; /* 8 lsb */
642 I2C2_CPSR1 = (prescaler >> 8) & 0x3; /* 2 msb */
643 655
644 /* set i2c slave address of codec part */ 656 /* set i2c slave address of codec part */
645 I2C2_SLAD0 = AS3514_I2C_ADDR << 1; 657 I2C2_SLAD0 = AS3514_I2C_ADDR << 1;
@@ -690,3 +702,12 @@ void ams_i2c_get_debug_cpsr(unsigned int *i2c_cpsr)
690 702
691 restore_irq(oldlevel); 703 restore_irq(oldlevel);
692} 704}
705
706#if defined(CONFIG_POWER_SAVING) && (CONFIG_POWER_SAVING & POWERSV_I2C)
707/* declared in system-as3525.c */
708void ams_i2c_set_low_speed(bool slow)
709{
710 i2c_set_prescaler(slow ? AS3525_I2C_PRESCALER_MAX : AS3525_I2C_PRESCALER);
711}
712#endif
713