From 007563c93d6a00300323cff47f1a7fc30f94a890 Mon Sep 17 00:00:00 2001 From: Barry Wardell Date: Thu, 25 Oct 2007 09:03:47 +0000 Subject: [PATCH] FS#8023: Use of AS3514 #defines instead of magic values. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15297 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/rtc/rtc_as3514.c | 7 ++++--- firmware/export/as3514.h | 8 ++++++++ firmware/target/arm/i2c-pp.c | 3 ++- firmware/target/arm/sandisk/backlight-c200_e200.c | 5 +++-- firmware/target/arm/sandisk/power-c200_e200.c | 5 +++-- firmware/target/arm/system-pp502x.c | 3 ++- 6 files changed, 22 insertions(+), 9 deletions(-) diff --git a/firmware/drivers/rtc/rtc_as3514.c b/firmware/drivers/rtc/rtc_as3514.c index 2190b20a53..15d543ec3f 100644 --- a/firmware/drivers/rtc/rtc_as3514.c +++ b/firmware/drivers/rtc/rtc_as3514.c @@ -16,9 +16,10 @@ * KIND, either express or implied. * ****************************************************************************/ +#include #include "rtc.h" #include "i2c-pp.h" -#include +#include "as3514.h" #define MINUTE_SECONDS 60 #define HOUR_SECONDS 3600 @@ -54,7 +55,7 @@ int rtc_read_datetime(unsigned char* buf) /* RTC_AS3514's slave address is 0x46*/ for (i=0;i<4;i++){ - tmp[i] = i2c_readbyte(0x46,0x2a+i); + tmp[i] = i2c_readbyte(AS3514_I2C_ADDR, RTC_0 + i); } seconds = tmp[0] + (tmp[1]<<8) + (tmp[2]<<16) + (tmp[3]<<24); @@ -159,7 +160,7 @@ int rtc_write_datetime(unsigned char* buf) /* Send data to RTC */ for (i=0;i<4;i++){ - pp_i2c_send(0x46, 0x2a+i,((seconds>>(8*i)) & 0xff)); + pp_i2c_send(AS3514_I2C_ADDR, RTC_0 + i, ((seconds >> (8 * i)) & 0xff)); } return 1; } diff --git a/firmware/export/as3514.h b/firmware/export/as3514.h index 8df228f105..955019f0b1 100644 --- a/firmware/export/as3514.h +++ b/firmware/export/as3514.h @@ -59,10 +59,18 @@ extern void audiohw_set_monitor(int enable); #define AUDIOSET3 0x16 #define PLLMODE 0x1d +#define SYSTEM 0x20 +#define DCDC15 0x23 +#define SUPERVISOR 0x24 + #define IRQ_ENRD0 0x25 #define IRQ_ENRD1 0x26 #define IRQ_ENRD2 0x27 +#define RTC_0 0x2a +#define RTC_1 0x2b +#define RTC_2 0x2c +#define RTC_3 0x2d #define ADC_0 0x2e #define ADC_1 0x2f diff --git a/firmware/target/arm/i2c-pp.c b/firmware/target/arm/i2c-pp.c index e5813f9f9a..69bc60e672 100644 --- a/firmware/target/arm/i2c-pp.c +++ b/firmware/target/arm/i2c-pp.c @@ -30,6 +30,7 @@ #include "logf.h" #include "system.h" #include "i2c-pp.h" +#include "as3514.h" /* Local functions definitions */ @@ -217,7 +218,7 @@ void i2c_init(void) outl(0, 0x600060a4); outl(0x1e, 0x600060a4); - pp_i2c_send(0x46, 0x24, 5); + pp_i2c_send(AS3514_I2C_ADDR, SUPERVISOR, 5); #endif #endif diff --git a/firmware/target/arm/sandisk/backlight-c200_e200.c b/firmware/target/arm/sandisk/backlight-c200_e200.c index f7835e1bd9..a9fc862966 100644 --- a/firmware/target/arm/sandisk/backlight-c200_e200.c +++ b/firmware/target/arm/sandisk/backlight-c200_e200.c @@ -21,6 +21,7 @@ #include "lcd.h" #include "backlight.h" #include "i2c-pp.h" +#include "as3514.h" static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING; @@ -39,12 +40,12 @@ void __backlight_on(void) #ifdef HAVE_LCD_ENABLE lcd_enable(true); /* power on lcd */ #endif - pp_i2c_send( 0x46, 0x23, backlight_brightness); + pp_i2c_send(AS3514_I2C_ADDR, DCDC15, backlight_brightness); } void __backlight_off(void) { - pp_i2c_send( 0x46, 0x23, 0x0); + pp_i2c_send(AS3514_I2C_ADDR, DCDC15, 0x0); #ifdef HAVE_LCD_ENABLE lcd_enable(false); /* power off lcd */ #endif diff --git a/firmware/target/arm/sandisk/power-c200_e200.c b/firmware/target/arm/sandisk/power-c200_e200.c index 8745aa3fb6..da86d97d26 100644 --- a/firmware/target/arm/sandisk/power-c200_e200.c +++ b/firmware/target/arm/sandisk/power-c200_e200.c @@ -22,6 +22,7 @@ #include "cpu.h" #include "i2c-pp.h" #include "tuner.h" +#include "as3514.h" void power_init(void) { @@ -39,9 +40,9 @@ void power_off(void) COP_INT_CLR = -1; /* Send shutdown command to PMU */ - byte = i2c_readbyte(0x46, 0x20); + byte = i2c_readbyte(AS3514_I2C_ADDR, SYSTEM); byte &= ~0x1; - pp_i2c_send(0x46, 0x20, byte); + pp_i2c_send(AS3514_I2C_ADDR, SYSTEM, byte); /* Halt everything and wait for device to power off */ while (1) diff --git a/firmware/target/arm/system-pp502x.c b/firmware/target/arm/system-pp502x.c index 0882d9f212..8d253a70db 100644 --- a/firmware/target/arm/system-pp502x.c +++ b/firmware/target/arm/system-pp502x.c @@ -20,6 +20,7 @@ #include "thread.h" #include "i2s.h" #include "i2c-pp.h" +#include "as3514.h" #ifndef BOOTLOADER extern void TIMER1(void); @@ -310,7 +311,7 @@ void system_reboot(void) #ifdef SANSA_C200 CACHE_CTL &= ~CACHE_CTL_VECT_REMAP; - pp_i2c_send( 0x46, 0x23, 0x0); /* backlight off */ + pp_i2c_send(AS3514_I2C_ADDR, DCDC15, 0x0); /* backlight off */ /* Magic used by the c200 OF: 0x23066000 Magic used by the c200 BL: 0x23066b7b