1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-26 15:07:11 +02:00

qi-gta02-no-inidcators-if-battery-low.patch

This patch turns on the SYS and BAT monitoring filters, and checks if the battery
meets the BAT OK threshold.  If it doesn't, which is the case if the battery is
not present, it disables the "indicator" (eg, LED, vibrator) stuff and holds the
CPU at 200MHz during the boot into Linux.

This allows the GTA02 A6 here to boot with no battery up to the point it is
going to bring up backlight, and this with 100mA limit on USB at PMU.  Enabling
the threshold filters for battery and SYS seems to have been critical in
getting any stability with this.

Signed-off-by: Andy Green <andy@openmoko.com>
This commit is contained in:
Andy Green 2008-12-01 01:26:07 +00:00 committed by Andy Green
parent 3867e3d4ce
commit 14acfb40af

View File

@ -35,6 +35,8 @@
#define PCF50633_I2C_ADS 0x73 #define PCF50633_I2C_ADS 0x73
#define BOOST_TO_400MHZ 1 #define BOOST_TO_400MHZ 1
static int battery_condition_reasonable = 0;
const struct pcf50633_init pcf50633_init[] = { const struct pcf50633_init pcf50633_init[] = {
{ PCF50633_REG_OOCWAKE, 0xd3 }, /* wake from ONKEY,EXTON!,RTC,USB,ADP */ { PCF50633_REG_OOCWAKE, 0xd3 }, /* wake from ONKEY,EXTON!,RTC,USB,ADP */
@ -43,8 +45,8 @@ const struct pcf50633_init pcf50633_init[] = {
{ PCF50633_REG_OOCMODE, 0x55 }, { PCF50633_REG_OOCMODE, 0x55 },
{ PCF50633_REG_OOCCTL, 0x47 }, { PCF50633_REG_OOCCTL, 0x47 },
{ PCF50633_REG_SVMCTL, 0x08 }, /* 3.10V SYS voltage thresh. */ { PCF50633_REG_SVMCTL, 0x18 }, /* 3.10V SYS vth, 62ms filter */
{ PCF50633_REG_BVMCTL, 0x02 }, /* 2.80V BAT voltage thresh. */ { PCF50633_REG_BVMCTL, 0x12 }, /* 2.80V BAT vth, 62ms filter */
{ PCF50633_REG_AUTOENA, 0x01 }, /* always on */ { PCF50633_REG_AUTOENA, 0x01 }, /* always on */
@ -95,11 +97,9 @@ static const struct board_variant board_variants[] = {
void port_init_gta02(void) void port_init_gta02(void)
{ {
#if BOOST_TO_400MHZ
unsigned int * MPLLCON = (unsigned int *)0x4c000004; unsigned int * MPLLCON = (unsigned int *)0x4c000004;
unsigned int * UPLLCON = (unsigned int *)0x4c000008; unsigned int * UPLLCON = (unsigned int *)0x4c000008;
unsigned int * CLKDIVN = (unsigned int *)0x4c000014; unsigned int * CLKDIVN = (unsigned int *)0x4c000014;
#endif
int n; int n;
//CAUTION:Follow the configuration order for setting the ports. //CAUTION:Follow the configuration order for setting the ports.
@ -229,7 +229,12 @@ void port_init_gta02(void)
i2c_write_sync(&bb_s3c24xx, PCF50633_I2C_ADS, i2c_write_sync(&bb_s3c24xx, PCF50633_I2C_ADS,
pcf50633_init[n].index, pcf50633_init[n].value); pcf50633_init[n].index, pcf50633_init[n].value);
#if BOOST_TO_400MHZ /* what does the battery monitoring unit say about the battery? */
battery_condition_reasonable = !(i2c_read_sync(&bb_s3c24xx,
PCF50633_I2C_ADS, PCF50633_REG_BVMCTL) & 1);
if (battery_condition_reasonable) {
/* change CPU clocking to 400MHz 1:4:8 */ /* change CPU clocking to 400MHz 1:4:8 */
/* clock divide 1:4:8 - do it first */ /* clock divide 1:4:8 - do it first */
@ -250,10 +255,10 @@ void port_init_gta02(void)
*MPLLCON = ((42 << 12) + (1 << 4) + 0); *MPLLCON = ((42 << 12) + (1 << 4) + 0);
/* get debug UART working at 115kbps */ /* get debug UART working at 115kbps */
serial_init_115200_s3c24xx(GTA02_DEBUG_UART, 50 /* 50MHz PCLK */); serial_init_115200_s3c24xx(GTA02_DEBUG_UART, 50 /* 50MHz */);
#else } else {
serial_init_115200_s3c24xx(GTA02_DEBUG_UART, 33 /* 33MHz PCLK */); serial_init_115200_s3c24xx(GTA02_DEBUG_UART, 33 /* 33MHz */);
#endif }
/* we're going to use Glamo for SD Card access, so we need to init the /* we're going to use Glamo for SD Card access, so we need to init the
* evil beast * evil beast
@ -399,6 +404,7 @@ static u8 get_ui_keys_gta02(void)
static void set_ui_indication_gta02(enum ui_indication ui_indication) static void set_ui_indication_gta02(enum ui_indication ui_indication)
{ {
switch (ui_indication) { switch (ui_indication) {
case UI_IND_UPDATE_ONLY: case UI_IND_UPDATE_ONLY:
break; break;
@ -406,6 +412,7 @@ static void set_ui_indication_gta02(enum ui_indication ui_indication)
case UI_IND_MOUNT_PART: case UI_IND_MOUNT_PART:
case UI_IND_KERNEL_PULL_OK: case UI_IND_KERNEL_PULL_OK:
case UI_IND_INITRAMFS_PULL_OK: case UI_IND_INITRAMFS_PULL_OK:
if (battery_condition_reasonable)
rGPBDAT |= 4; rGPBDAT |= 4;
break; break;
@ -414,10 +421,12 @@ static void set_ui_indication_gta02(enum ui_indication ui_indication)
case UI_IND_INITRAMFS_PULL_FAIL: case UI_IND_INITRAMFS_PULL_FAIL:
case UI_IND_MOUNT_FAIL: case UI_IND_MOUNT_FAIL:
rGPBDAT &= ~4; rGPBDAT &= ~4;
if (battery_condition_reasonable) {
rGPBDAT |= 8; rGPBDAT |= 8;
udelay(2000000); udelay(2000000);
rGPBDAT &= ~8; rGPBDAT &= ~8;
udelay(200000); udelay(200000);
}
break; break;
case UI_IND_KERNEL_START: case UI_IND_KERNEL_START: