diff options
author | William Wilgus <me.theuser@yahoo.com> | 2018-07-29 14:03:47 +0200 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2020-05-23 15:44:20 +0200 |
commit | 4f49d21992acd3054435aa8bc95dde8258e8d116 (patch) | |
tree | 14685e3a67e4928d52935113260f7cd92413b95e | |
parent | 6ed38c89aeb1b855fda1e09e999110deeda6ecd8 (diff) | |
download | rockbox-4f49d21992acd3054435aa8bc95dde8258e8d116.tar.gz rockbox-4f49d21992acd3054435aa8bc95dde8258e8d116.zip |
Sansa AMS set I2C properly
Change-Id: I95c93933487c4260a7aa43ebed273ab2c05e55c1
-rw-r--r-- | firmware/target/arm/as3525/ascodec-as3525.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/firmware/target/arm/as3525/ascodec-as3525.c b/firmware/target/arm/as3525/ascodec-as3525.c index 14c3ee7a36..6076505acb 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 | ||
626 | static 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 */ |
627 | void ascodec_init(void) | 643 | void 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,4 @@ void ams_i2c_get_debug_cpsr(unsigned int *i2c_cpsr) | |||
690 | 702 | ||
691 | restore_irq(oldlevel); | 703 | restore_irq(oldlevel); |
692 | } | 704 | } |
705 | |||