1
0
Fork 0
forked from len0rd/rockbox

Improved handling of the ONKEY1S interrupt. Off for the remote must be explicitly mapped now.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10932 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Michael Sevakis 2006-09-12 14:20:29 +00:00
parent bc0943e922
commit 3bee89ed44
2 changed files with 36 additions and 15 deletions

View file

@ -59,6 +59,10 @@
#include <time.h> #include <time.h>
#endif #endif
#ifdef IAUDIO_X5
extern void pcf50606_reset_timeout(void);
#endif
/* /*
* Define DEBUG_FILE to create a csv (spreadsheet) with battery information * Define DEBUG_FILE to create a csv (spreadsheet) with battery information
* in it (one sample per minute). This is only for very low level debug. * in it (one sample per minute). This is only for very low level debug.
@ -1010,6 +1014,13 @@ void sys_poweroff(void)
void cancel_shutdown(void) void cancel_shutdown(void)
{ {
logf("sys_cancel_shutdown()"); logf("sys_cancel_shutdown()");
#ifdef IAUDIO_X5
/* TODO: Move some things to target/ tree */
if (shutdown_timeout)
pcf50606_reset_timeout();
#endif
shutdown_timeout = 0; shutdown_timeout = 0;
} }

View file

@ -26,6 +26,7 @@
#include "debug.h" #include "debug.h"
#include "string.h" #include "string.h"
#include "generic_i2c.h" #include "generic_i2c.h"
#include "powermgmt.h"
void pcf50606_sda_output(void) void pcf50606_sda_output(void)
{ {
@ -154,7 +155,13 @@ static void set_voltages(void)
void pcf50606_init(void) void pcf50606_init(void)
{ {
unsigned char read[3]; /* inital data is interrupt masks */
unsigned char data[3] =
{
~0x04, /* unmask ONKEY1S */
~0x00,
~0x00
};
/* Bit banged I2C */ /* Bit banged I2C */
or_l(0x00001000, &GPIO1_OUT); or_l(0x00001000, &GPIO1_OUT);
@ -169,10 +176,10 @@ void pcf50606_init(void)
/* make sure GPI0 interrupt is off before unmasking anything */ /* make sure GPI0 interrupt is off before unmasking anything */
and_l(~0xF, &INTPRI5); /* INT32 - Priority 0 (Off) */ and_l(~0xF, &INTPRI5); /* INT32 - Priority 0 (Off) */
/* unmask ONKEY1S - ONKEY held low for 1 second */ /* unmask the PMU interrupts we want to service */
pcf50606_write(0x05, ~0x04); pcf50606_write_multiple(0x05, data, 3);
/* clear INT1-3 as these are left set after standby */ /* clear INT1-3 as these are left set after standby */
pcf50606_read_multiple(0x02, read, 3); pcf50606_read_multiple(0x02, data, 3);
/* Set to read pcf50606 INT but keep GPI0 off until init completes */ /* Set to read pcf50606 INT but keep GPI0 off until init completes */
and_l(~0x00000001, &GPIO_ENABLE); and_l(~0x00000001, &GPIO_ENABLE);
@ -184,11 +191,6 @@ void pcf50606_init(void)
pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */ pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */
pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */ pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */
/* D305A datasheet says PWM clock frequency should be 400Hz - 2000Hz so
* I changed it from 7kHz to 512Hz. The lower frequency looks the same.
* GPO1 is also inverted so that display brightness increases with PWM
* cycle.
*/
pcf50606_write(0x35, 0x11); /* Backlight PWM = 512Hz, 8/16, Active */ pcf50606_write(0x35, 0x11); /* Backlight PWM = 512Hz, 8/16, Active */
#ifdef BOOTLOADER #ifdef BOOTLOADER
/* Backlight starts OFF in bootloader */ /* Backlight starts OFF in bootloader */
@ -199,7 +201,14 @@ void pcf50606_init(void)
#endif #endif
/* allow GPI0 interrupts from PMU now */ /* allow GPI0 interrupts from PMU now */
or_l(0x6, &INTPRI5); /* INT32 - Priority 6 */ or_l(0x3, &INTPRI5); /* INT32 - Priority 3 */
}
void pcf50606_reset_timeout(void)
{
int level = set_irq_level(HIGHEST_IRQ_LEVEL);
pcf50606_write(0x08, pcf50606_read(0x08) | 0x02); /* OOCC1 - TOTRST=1 */
set_irq_level(level);
} }
/* Handles interrupts generated by the pcf50606 */ /* Handles interrupts generated by the pcf50606 */
@ -208,15 +217,16 @@ void GPI0(void)
{ {
char read[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */ char read[3]; /* 0 = INT1, 1 = INT2, 2 = INT3 */
/* Clear pending interrupts from pcf50606 - reading all INT* registers /* clear pending interrupts from pcf50606 */
resets the INT pin to high */
pcf50606_read_multiple(0x02, read, 3); pcf50606_read_multiple(0x02, read, 3);
if (read[0] & 0x04) if (read[0] & 0x04)
{ {
/** ONKEY1S **/ /* ONKEY1S */
/* reset timeout or else pcf50606 will go into standby in 8s */ if (GPIO_READ & 0x02000000)
pcf50606_write(0x08, pcf50606_read(0x08) | 0x02); /* OOCC1 - TOTRST=1 */ sys_poweroff(); /* main ONKEY */
else
pcf50606_reset_timeout(); /* remote ONKEY */
} }
/* Clear pending GPI0 interrupts */ /* Clear pending GPI0 interrupts */