From bac6a70184b18ca17a46b3ed955944e1a4d3f032 Mon Sep 17 00:00:00 2001 From: Tomasz Moń Date: Mon, 5 Dec 2011 09:53:23 +0000 Subject: Sansa Connect: Revise codec initialization/shutdown. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31149 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/tms320dm320/i2c-dm320.c | 6 ++++ firmware/target/arm/tms320dm320/i2c-dm320.h | 12 ++++++++ .../tms320dm320/sansa-connect/avr-sansaconnect.c | 32 ++++++++++++++++++---- .../tms320dm320/sansa-connect/power-sansaconnect.c | 6 ++++ 4 files changed, 51 insertions(+), 5 deletions(-) (limited to 'firmware/target') diff --git a/firmware/target/arm/tms320dm320/i2c-dm320.c b/firmware/target/arm/tms320dm320/i2c-dm320.c index 990dad0721..2530209402 100644 --- a/firmware/target/arm/tms320dm320/i2c-dm320.c +++ b/firmware/target/arm/tms320dm320/i2c-dm320.c @@ -287,4 +287,10 @@ int i2c_read(unsigned short address, unsigned char* buf, int count) return i2c_read_data(dm320_i2c_bus, address, -1, buf, count); } +int i2c_read_bytes(unsigned short address, unsigned short reg, + unsigned char* buf, int count) +{ + return i2c_read_data(dm320_i2c_bus, address, reg, buf, count); +} + #endif diff --git a/firmware/target/arm/tms320dm320/i2c-dm320.h b/firmware/target/arm/tms320dm320/i2c-dm320.h index be7d02ed4d..7dfc19f046 100644 --- a/firmware/target/arm/tms320dm320/i2c-dm320.h +++ b/firmware/target/arm/tms320dm320/i2c-dm320.h @@ -19,6 +19,18 @@ * ****************************************************************************/ +#ifndef I2C_DM320_H +#define I2C_DM320_H + +#include "system.h" + void i2c_init(void); int i2c_write(unsigned short address, const unsigned char *data, int count); int i2c_read(unsigned short address, unsigned char* buf, int count); + +#ifdef HAVE_SOFTWARE_I2C +int i2c_read_bytes(unsigned short address, unsigned short reg, + unsigned char* buf, int count); +#endif + +#endif diff --git a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c index 036b7db127..dedd017cf7 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c +++ b/firmware/target/arm/tms320dm320/sansa-connect/avr-sansaconnect.c @@ -29,6 +29,7 @@ #include "button.h" #include "backlight.h" #include "powermgmt.h" +#include "aic3x.h" //#define BUTTON_DEBUG @@ -405,6 +406,26 @@ void GIO0(void) /* interrupt will be enabled back after button read */ queue_post(&btn_queue, BTN_INTERRUPT, 0); } + +void GIO2(void) __attribute__ ((section(".icode"))); +void GIO2(void) +{ + /* Clear interrupt */ + IO_INTC_IRQ1 = (1 << 7); + /* Disable interrupt */ + IO_INTC_EINT1 &= ~INTR_EINT1_EXT2; + + if (IO_GIO_BITSET0 & 0x04) + { + aic3x_switch_output(false); + } + else + { + aic3x_switch_output(true); + } + + IO_INTC_EINT1 |= INTR_EINT1_EXT2; +} #endif void button_init_device(void) @@ -425,12 +446,13 @@ void button_init_device(void) avr_hid_get_state(); #ifndef BOOTLOADER - IO_GIO_IRQPORT |= 0x01; /* Enable GIO0 external interrupt */ - IO_GIO_INV0 &= ~0x01; /* Clear INV for GIO0 (falling edge detection) */ - IO_GIO_IRQEDGE &= ~0x01; /* Set edge detection (falling) */ + IO_GIO_IRQPORT |= 0x05; /* Enable GIO0/GIO2 external interrupt */ + IO_GIO_INV0 &= ~0x05; /* Clear INV for GIO0/GIO2 */ + /* falling edge detection on GIO0, any edge on GIO2 */ + IO_GIO_IRQEDGE = (IO_GIO_IRQEDGE & ~0x01) | 0x04; - /* Enable GIO0 interrupt */ - IO_INTC_EINT1 |= INTR_EINT1_EXT0; + /* Enable GIO0 and GIO2 interrupts */ + IO_INTC_EINT1 |= INTR_EINT1_EXT0 | INTR_EINT1_EXT2; #endif } diff --git a/firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c index 07c80a07c3..f73df98641 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c +++ b/firmware/target/arm/tms320dm320/sansa-connect/power-sansaconnect.c @@ -49,6 +49,9 @@ static void tps65021_write_reg(unsigned reg, unsigned value) void power_init(void) { + /* Enable LDO */ + tps65021_write_reg(0x03, 0xFD); + /* PWM mode */ tps65021_write_reg(0x04, 0xB2); @@ -61,6 +64,9 @@ void power_init(void) void power_off(void) { + /* Disable GIO0 and GIO2 interrupts */ + IO_INTC_EINT1 &= ~(INTR_EINT1_EXT2 | INTR_EINT1_EXT0); + avr_hid_reset_codec(); avr_hid_power_off(); } -- cgit v1.2.3