From 32ba11f066688ac629cde6595372c40dbb0f0553 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sat, 9 Sep 2006 07:49:25 +0000 Subject: Fixed the problem on the x5 of spontaneous shutdown after holding the power key for 1s. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10904 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/coldfire/iaudio/x5/pcf50606-x5.c | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'firmware/target') diff --git a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c index 2f3ee2bc09..dde20d8b7c 100644 --- a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c +++ b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c @@ -154,6 +154,8 @@ static void set_voltages(void) void pcf50606_init(void) { + unsigned char read[3]; + /* Bit banged I2C */ or_l(0x00001000, &GPIO1_OUT); or_l(0x00000400, &GPIO_OUT); @@ -164,8 +166,19 @@ void pcf50606_init(void) i2c_add_node(&pcf50606_i2c); + /* unmask ONKEY1S - ONKEY held low for 1 second */ + pcf50606_write(0x05, ~0x04); + /* clear INT1-3 as these are left set after standby */ + pcf50606_read_multiple(0x02, read, 3); + set_voltages(); + /* enable GPI0 interrupts (pcf50606 IRQ) */ + and_l(~0x00000001, &GPIO_ENABLE); + or_l(0x00000001, &GPIO_FUNCTION); + or_l(0x00000100, &GPIO_INT_EN); /* GPI0 H-L */ + INTPRI5 |= 0x00000006; /* INT32 - Priority 6 */ + pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */ pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */ @@ -183,3 +196,24 @@ void pcf50606_init(void) pcf50606_write(0x38, 0xb0); /* Backlight ON, GPO1INV=1, GPO1ACT=011 */ #endif } + +/* Handles interrupts generated by the pcf50606 */ +void GPI0(void) __attribute__ ((interrupt_handler, section(".text"))); +void GPI0(void) +{ + char read[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ + + /* Clear pending interrupts from pcf50606 - reading all INT* registers + resets the INT pin to high */ + pcf50606_read_multiple(0x02, read, 3); + + if (read[0] & 0x04) + { + /** ONKEY1S **/ + /* reset timeout or else pcf50606 will go into standby in 8s */ + pcf50606_write(0x08, pcf50606_read(0x08) | 0x02); /* OOCC1 - TOTRST=1 */ + } + + /* Clear pending GPI0 interrupts */ + or_l(0x00000100, &GPIO_INT_CLEAR); +} -- cgit v1.2.3