r4229 - trunk/src/target/u-boot/patches
werner at sita.openmoko.org
werner at sita.openmoko.org
Thu Mar 20 02:04:40 CET 2008
Author: werner
Date: 2008-03-20 02:04:37 +0100 (Thu, 20 Mar 2008)
New Revision: 4229
Modified:
trunk/src/target/u-boot/patches/wait-for-power-DONTUSE.patch
Log:
wait-for-power-DONTUSE.patch:
- drivers/misc/pcf50633.c (pcf50633_adc_read, pcf50633_read_charger_type):
applied the rest of Matt's 3.6V threshold changes
- board/neo1973/gta02/gta02.c (wait_for_power): added threshold checking, as
suggested by Matt
- board/neo1973/gta02/gta02.c (wait_for_power, poll_charger): look for the
charger and enable 1A charging if found
- drivers/misc/pcf50633.c (pcf50633_read_charger_type): test for charger/USB
power before looking for the ID resistor
- include/pcf50633.h: for a change, declare prototypes
Modified: trunk/src/target/u-boot/patches/wait-for-power-DONTUSE.patch
===================================================================
--- trunk/src/target/u-boot/patches/wait-for-power-DONTUSE.patch 2008-03-19 23:15:37 UTC (rev 4228)
+++ trunk/src/target/u-boot/patches/wait-for-power-DONTUSE.patch 2008-03-20 01:04:37 UTC (rev 4229)
@@ -5,16 +5,14 @@
This is work in progress. Don't use it.
It makes the following changes:
-- keeps the system from booting unless we have 500mA USB power (this is
- for testing)
+- keeps the system from booting unless we have either good battery power,
+ 500mA from USB, or the wall charger supplying power
- flashes the red (AUX) LED during this
- defers initialization of the video subsystem until we're about to
display something
- leaves the LED boost converter turned off until we actually need it
Known issues:
-- actually seems useless, because we don't seem to ever power up without
- a battery present anyway
- still burns way too much power, see
http://people.openmoko.org/werner/wait-for-power-try1/usb-batt.html
@@ -22,7 +20,17 @@
===================================================================
--- u-boot.orig/board/neo1973/gta02/gta02.c
+++ u-boot/board/neo1973/gta02/gta02.c
-@@ -63,6 +63,8 @@
+@@ -45,6 +45,9 @@
+ /* That many seconds the power key needs to be pressed to power up */
+ #define POWER_KEY_SECONDS 2
+
++/* If the battery voltage is below this, we can't provide stable power */
++#define SAVE_POWER_MILLIVOLT 3600
++
+ #if defined(CONFIG_ARCH_GTA02_v1)
+ //#define M_MDIV 0x7f /* Fout = 405.00MHz */
+ #define M_MDIV 0x7d /* Fout = 399.00MHz */
+@@ -63,6 +66,8 @@
#define U_M_SDIV 2
#endif
@@ -31,22 +39,27 @@
unsigned int neo1973_wakeup_cause;
extern unsigned char booted_from_nand;
extern unsigned char booted_from_nor;
-@@ -229,6 +231,34 @@
+@@ -229,6 +234,39 @@
return 0;
}
++static void poll_charger(void)
++{
++ if (pcf50633_read_charger_type() == 1000)
++ pcf50633_usb_maxcurrent(1000);
++}
++
+static void wait_for_power(void)
+{
+ int seconds = 0;
+
+ while (1) {
-+#if 0
+ /* battery is present -> try to boot */
-+ if (!(pcf50633_reg_read(PCF50633_REG_BVMCTL) & 1))
++ if (!(pcf50633_reg_read(PCF50633_REG_BVMCTL) & 1) &&
++ pcf50633_read_battvolt() >= SAVE_POWER_MILLIVOLT)
+ break;
-+#endif
+
-+ /* @@@FIXME: have to check ADC for external charger */
++ poll_charger();
+
+ /* we have plenty of external power -> try to boot */
+ if (pcf50633_usb_last_maxcurrent >= 500)
@@ -66,7 +79,7 @@
int board_late_init(void)
{
S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO();
-@@ -236,6 +266,7 @@
+@@ -236,6 +274,7 @@
char buf[32];
int menu_vote = 0; /* <= 0: no, > 0: yes */
int seconds = 0;
@@ -74,7 +87,7 @@
/* Initialize the Power Management Unit with a safe register set */
pcf50633_init();
-@@ -244,8 +275,7 @@
+@@ -244,8 +283,7 @@
int1 = pcf50633_reg_read(PCF50633_REG_INT1);
int2 = pcf50633_reg_read(PCF50633_REG_INT2);
@@ -84,7 +97,7 @@
/* issue a short pulse with the vibrator */
neo1973_vibrator(1);
-@@ -311,9 +341,15 @@
+@@ -311,9 +349,15 @@
neo1973_poweroff();
continue_boot:
@@ -100,7 +113,7 @@
#if 0
{
-@@ -324,7 +360,7 @@
+@@ -324,7 +368,7 @@
}
#endif
@@ -126,7 +139,75 @@
===================================================================
--- u-boot.orig/drivers/misc/pcf50633.c
+++ u-boot/drivers/misc/pcf50633.c
-@@ -175,10 +175,13 @@
+@@ -111,18 +111,13 @@
+ return 0;
+ }
+
+-/* figure out our charger situation */
+-int pcf50633_read_charger_type(void)
++static u_int16_t pcf50633_adc_read(u_int8_t channel, u_int8_t avg)
+ {
+ u_int16_t ret;
+
+- /* kill ratiometric, but enable ACCSW biasing */
+- pcf50633_reg_write(PCF50633_REG_ADCC2, 0x00);
+- pcf50633_reg_write(PCF50633_REG_ADCC3, 0x01);
+-
+ /* start ADC conversion of selected channel */
+- pcf50633_reg_write(PCF50633_REG_ADCC1, PCF50633_ADCC1_MUX_ADCIN1 |
+- PCF50633_ADCC1_AVERAGE_16 |
++ pcf50633_reg_write(PCF50633_REG_ADCC1, channel |
++ avg |
+ PCF50633_ADCC1_ADCSTART |
+ PCF50633_ADCC1_RES_10BIT);
+
+@@ -135,18 +130,41 @@
+ (pcf50633_reg_read(PCF50633_REG_ADCS3) &
+ PCF50633_ADCS3_ADCDAT1L_MASK);
+
++ return ret;
++}
++
++/* figure out our charger situation */
++int pcf50633_read_charger_type(void)
++{
++ u_int16_t ret;
++
++ if ((pcf50633_reg_read(PCF50633_REG_MBCS1) & 0x3) != 0x3)
++ return 0; /* no power, just battery */
++
++ /* kill ratiometric, but enable ACCSW biasing */
++ pcf50633_reg_write(PCF50633_REG_ADCC2, 0x00);
++ pcf50633_reg_write(PCF50633_REG_ADCC3, 0x01);
++
++ ret = pcf50633_adc_read(PCF50633_ADCC1_MUX_ADCIN1,
++ PCF50633_ADCC1_AVERAGE_16);
++
+ /* well it is nearest to the 1A resistor */
+ if (ret < ((ADC_NOMINAL_RES_1A + ADC_NOMINAL_RES_NC_R_USB) / 2))
+ return 1000;
+
+- /* ok all we know is there is no resistor, it can be USB pwr or none */
+- if ((pcf50633_reg_read(PCF50633_REG_MBCS1) & 0x3) == 0x3)
+- return 100; /* USB power then */
++ /* there is no resistor, so it must be USB pwr */
++ return 100; /* USB power then */
+
+- return 0; /* nope, no power, just battery */
+ }
+
++u_int16_t pcf50633_read_battvolt(void)
++{
++ u_int16_t ret;
++
++ ret = pcf50633_adc_read(PCF50633_ADCC1_MUX_BATSNS_RES, 0);
+
++ return (ret * 6000) / 1024;
++}
+
+ /* initialize PCF50633 register set */
+ void pcf50633_init(void)
+@@ -175,10 +193,13 @@
}
}
@@ -166,3 +247,12 @@
void pcf50633_reg_write(u_int8_t reg, u_int8_t val);
u_int8_t pcf50633_reg_read(u_int8_t reg);
+@@ -399,5 +401,8 @@
+
+ const char *pcf50633_charger_state(void);
+
++int pcf50633_read_charger_type(void);
++u_int16_t pcf50633_read_battvolt(void);
++
+ #endif /* _PCF50633_H */
+
More information about the commitlog
mailing list