Changeset 4229


Ignore:
Timestamp:
03/20/08 02:04:37 (5 years ago)
Author:
werner
Message:

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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/u-boot/patches/wait-for-power-DONTUSE.patch

    r4189 r4229  
    66 
    77It makes the following changes: 
    8 - keeps the system from booting unless we have 500mA USB power (this is 
    9   for testing) 
     8- keeps the system from booting unless we have either good battery power, 
     9  500mA from USB, or the wall charger supplying power 
    1010- flashes the red (AUX) LED during this 
    1111- defers initialization of the video subsystem until we're about to 
     
    1414 
    1515Known issues: 
    16 - actually seems useless, because we don't seem to ever power up without 
    17   a battery present anyway 
    1816- still burns way too much power, see 
    1917  http://people.openmoko.org/werner/wait-for-power-try1/usb-batt.html 
     
    2321--- u-boot.orig/board/neo1973/gta02/gta02.c 
    2422+++ u-boot/board/neo1973/gta02/gta02.c 
    25 @@ -63,6 +63,8 @@ 
     23@@ -45,6 +45,9 @@ 
     24 /* That many seconds the power key needs to be pressed to power up */ 
     25 #define POWER_KEY_SECONDS      2 
     26  
     27+/* If the battery voltage is below this, we can't provide stable power */ 
     28+#define        SAVE_POWER_MILLIVOLT    3600 
     29+ 
     30 #if defined(CONFIG_ARCH_GTA02_v1) 
     31 //#define M_MDIV       0x7f            /* Fout = 405.00MHz */ 
     32 #define M_MDIV 0x7d            /* Fout = 399.00MHz */ 
     33@@ -63,6 +66,8 @@ 
    2634 #define U_M_SDIV 2 
    2735 #endif 
     
    3240 extern unsigned char booted_from_nand; 
    3341 extern unsigned char booted_from_nor; 
    34 @@ -229,6 +231,34 @@ 
     42@@ -229,6 +234,39 @@ 
    3543        return 0; 
    3644 } 
    3745  
     46+static void poll_charger(void) 
     47+{ 
     48+       if (pcf50633_read_charger_type() == 1000) 
     49+               pcf50633_usb_maxcurrent(1000); 
     50+} 
     51+ 
    3852+static void wait_for_power(void) 
    3953+{ 
     
    4155+ 
    4256+       while (1) { 
    43 +#if 0 
    4457+               /* battery is present -> try to boot */ 
    45 +               if (!(pcf50633_reg_read(PCF50633_REG_BVMCTL) & 1)) 
     58+               if (!(pcf50633_reg_read(PCF50633_REG_BVMCTL) & 1) && 
     59+                   pcf50633_read_battvolt() >= SAVE_POWER_MILLIVOLT) 
    4660+                       break; 
    47 +#endif 
    48 + 
    49 +               /* @@@FIXME: have to check ADC for external charger */ 
     61+ 
     62+               poll_charger(); 
    5063+ 
    5164+               /* we have plenty of external power -> try to boot */ 
     
    6780 { 
    6881        S3C24X0_GPIO * const gpio = S3C24X0_GetBase_GPIO(); 
    69 @@ -236,6 +266,7 @@ 
     82@@ -236,6 +274,7 @@ 
    7083        char buf[32]; 
    7184        int menu_vote = 0; /* <= 0: no, > 0: yes */ 
     
    7588        /* Initialize the Power Management Unit with a safe register set */ 
    7689        pcf50633_init(); 
    77 @@ -244,8 +275,7 @@ 
     90@@ -244,8 +283,7 @@ 
    7891        int1 = pcf50633_reg_read(PCF50633_REG_INT1); 
    7992        int2 = pcf50633_reg_read(PCF50633_REG_INT2); 
     
    8598        /* issue a short pulse with the vibrator */ 
    8699        neo1973_vibrator(1); 
    87 @@ -311,9 +341,15 @@ 
     100@@ -311,9 +349,15 @@ 
    88101        neo1973_poweroff(); 
    89102  
     
    101114 #if 0 
    102115        { 
    103 @@ -324,7 +360,7 @@ 
     116@@ -324,7 +368,7 @@ 
    104117        } 
    105118 #endif 
     
    127140--- u-boot.orig/drivers/misc/pcf50633.c 
    128141+++ u-boot/drivers/misc/pcf50633.c 
    129 @@ -175,10 +175,13 @@ 
     142@@ -111,18 +111,13 @@ 
     143        return 0; 
     144 } 
     145  
     146-/* figure out our charger situation */ 
     147-int pcf50633_read_charger_type(void) 
     148+static u_int16_t pcf50633_adc_read(u_int8_t channel, u_int8_t avg) 
     149 { 
     150        u_int16_t ret; 
     151  
     152-       /* kill ratiometric, but enable ACCSW biasing */ 
     153-       pcf50633_reg_write(PCF50633_REG_ADCC2, 0x00); 
     154-       pcf50633_reg_write(PCF50633_REG_ADCC3, 0x01); 
     155- 
     156        /* start ADC conversion of selected channel */ 
     157-       pcf50633_reg_write(PCF50633_REG_ADCC1, PCF50633_ADCC1_MUX_ADCIN1 | 
     158-                                              PCF50633_ADCC1_AVERAGE_16 | 
     159+       pcf50633_reg_write(PCF50633_REG_ADCC1, channel | 
     160+                                              avg | 
     161                                               PCF50633_ADCC1_ADCSTART | 
     162                                               PCF50633_ADCC1_RES_10BIT); 
     163  
     164@@ -135,18 +130,41 @@ 
     165              (pcf50633_reg_read(PCF50633_REG_ADCS3) & 
     166              PCF50633_ADCS3_ADCDAT1L_MASK); 
     167  
     168+       return ret; 
     169+} 
     170+ 
     171+/* figure out our charger situation */ 
     172+int pcf50633_read_charger_type(void) 
     173+{ 
     174+       u_int16_t ret; 
     175+ 
     176+       if ((pcf50633_reg_read(PCF50633_REG_MBCS1) & 0x3) != 0x3) 
     177+               return 0; /* no power, just battery */ 
     178+ 
     179+       /* kill ratiometric, but enable ACCSW biasing */ 
     180+       pcf50633_reg_write(PCF50633_REG_ADCC2, 0x00); 
     181+       pcf50633_reg_write(PCF50633_REG_ADCC3, 0x01); 
     182+ 
     183+       ret = pcf50633_adc_read(PCF50633_ADCC1_MUX_ADCIN1, 
     184+           PCF50633_ADCC1_AVERAGE_16); 
     185+ 
     186        /* well it is nearest to the 1A resistor */ 
     187        if (ret < ((ADC_NOMINAL_RES_1A + ADC_NOMINAL_RES_NC_R_USB) / 2)) 
     188                return 1000; 
     189  
     190-       /* ok all we know is there is no resistor, it can be USB pwr or none */ 
     191-       if ((pcf50633_reg_read(PCF50633_REG_MBCS1) & 0x3) == 0x3) 
     192-               return 100; /* USB power then */ 
     193+       /* there is no resistor, so it must be USB pwr */ 
     194+       return 100; /* USB power then */ 
     195  
     196-       return 0; /* nope, no power, just battery */ 
     197 } 
     198  
     199+u_int16_t pcf50633_read_battvolt(void) 
     200+{ 
     201+       u_int16_t ret; 
     202+ 
     203+       ret = pcf50633_adc_read(PCF50633_ADCC1_MUX_BATSNS_RES, 0); 
     204  
     205+       return (ret * 6000) / 1024; 
     206+} 
     207  
     208 /* initialize PCF50633 register set */ 
     209 void pcf50633_init(void) 
     210@@ -175,10 +193,13 @@ 
    130211        } 
    131212 } 
     
    167248  
    168249 u_int8_t pcf50633_reg_read(u_int8_t reg); 
     250@@ -399,5 +401,8 @@ 
     251  
     252 const char *pcf50633_charger_state(void); 
     253  
     254+int pcf50633_read_charger_type(void); 
     255+u_int16_t pcf50633_read_battvolt(void); 
     256+ 
     257 #endif /* _PCF50633_H */ 
     258  
Note: See TracChangeset for help on using the changeset viewer.