From 49c25816f0b76fe71f5efcc38523900bf1429b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Thu, 14 May 2009 09:36:56 +0000 Subject: Sansa AMS i2c : fix 2 problems identified by Jack Halpin & Bertrik Sikken i2c clock frequency uses pclk as reference, not plla i2c clock divider is only 10 bits, not 16 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20929 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/as3525/ascodec-as3525.c | 4 ++-- firmware/target/arm/as3525/clock-target.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'firmware/target') diff --git a/firmware/target/arm/as3525/ascodec-as3525.c b/firmware/target/arm/as3525/ascodec-as3525.c index 4f13dd6300..43a982f454 100644 --- a/firmware/target/arm/as3525/ascodec-as3525.c +++ b/firmware/target/arm/as3525/ascodec-as3525.c @@ -72,8 +72,8 @@ void ascodec_init(void) /* prescaler for i2c clock */ prescaler = CLK_DIV(AS3525_PCLK_FREQ, AS3525_I2C_FREQ); - I2C2_CPSR0 = prescaler & 0xFF; - I2C2_CPSR1 = (prescaler >> 8) & 0xFF; + I2C2_CPSR0 = prescaler & 0xFF; /* 8 lsb */ + I2C2_CPSR1 = (prescaler >> 8) & 0x3; /* 2 msb */ /* set i2c slave address of codec part */ I2C2_SLAD0 = AS3514_I2C_ADDR << 1; diff --git a/firmware/target/arm/as3525/clock-target.h b/firmware/target/arm/as3525/clock-target.h index f4b223cdff..49308ce9ea 100644 --- a/firmware/target/arm/as3525/clock-target.h +++ b/firmware/target/arm/as3525/clock-target.h @@ -53,7 +53,7 @@ #endif #define AS3525_I2C_FREQ 400000 -#if (CLK_DIV(AS3525_PLLA_FREQ, AS3525_I2C_FREQ)) >= (1<<16) /* 2*8 bits */ +#if (CLK_DIV(AS3525_PCLK_FREQ, AS3525_I2C_FREQ)) >= (1<<10) /* 2+8 bits */ #error I2C frequency is too low : clock divider will not fit ! #endif -- cgit v1.2.3