summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2018-07-29 14:03:47 +0200
committerWilliam Wilgus <me.theuser@yahoo.com>2020-05-23 15:44:20 +0200
commit4f49d21992acd3054435aa8bc95dde8258e8d116 (patch)
tree14685e3a67e4928d52935113260f7cd92413b95e
parent6ed38c89aeb1b855fda1e09e999110deeda6ecd8 (diff)
downloadrockbox-4f49d21.tar.gz
rockbox-4f49d21.tar.bz2
rockbox-4f49d21.zip
Sansa AMS set I2C properly
Change-Id: I95c93933487c4260a7aa43ebed273ab2c05e55c1
-rw-r--r--firmware/target/arm/as3525/ascodec-as3525.c23
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)
/* required function but called too late for our needs */
}
+static void i2c_set_prescaler(unsigned int prescaler)
+{
+ int oldlevel = disable_interrupt_save(IRQ_FIQ_STATUS);
+ /* must be on to write regs */
+ bool i2c_enabled = bitset32(&CGU_PERI, CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE) &
+ CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE;
+
+ I2C2_CPSR0 = prescaler & 0xFF; /* 8 lsb */
+ I2C2_CPSR1 = (prescaler >> 8) & 0x3; /* 2 msb */
+
+ if (!i2c_enabled) /* put it back how we found it */
+ bitclr32(&CGU_PERI, CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE);
+
+ restore_irq(oldlevel);
+}
+
/* initialises the internal i2c bus and prepares for transfers to the codec */
void ascodec_init(void)
{
- int prescaler;
-
ll_init(&req_list);
mutex_init(&as_mtx);
ascodec_async_init(&as_audio_req, ascodec_int_audio_cb, 0);
@@ -637,9 +651,7 @@ void ascodec_init(void)
bitset32(&CGU_PERI, CGU_I2C_AUDIO_MASTER_CLOCK_ENABLE);
/* prescaler for i2c clock */
- prescaler = AS3525_I2C_PRESCALER;
- I2C2_CPSR0 = prescaler & 0xFF; /* 8 lsb */
- I2C2_CPSR1 = (prescaler >> 8) & 0x3; /* 2 msb */
+ i2c_set_prescaler(AS3525_I2C_PRESCALER);
/* set i2c slave address of codec part */
I2C2_SLAD0 = AS3514_I2C_ADDR << 1;
@@ -690,3 +702,4 @@ void ams_i2c_get_debug_cpsr(unsigned int *i2c_cpsr)
restore_irq(oldlevel);
}
+