File tree Expand file tree Collapse file tree 3 files changed +33
-7
lines changed Expand file tree Collapse file tree 3 files changed +33
-7
lines changed Original file line number Diff line number Diff line change @@ -80,19 +80,42 @@ __override void battery_charger_notify(uint8_t flag)
80
80
}
81
81
}
82
82
83
+ static int battery_check_disconnect (void )
84
+ {
85
+ int rv ;
86
+ uint8_t data [6 ];
87
+
88
+ /* Check if battery charging + discharging is disabled. */
89
+ rv = sb_read_mfgacc (PARAM_OPERATION_STATUS ,
90
+ SB_ALT_MANUFACTURER_ACCESS , data , sizeof (data ));
91
+ if (rv )
92
+ return BATTERY_DISCONNECT_ERROR ;
93
+
94
+ if (data [3 ] & BATTERY_DISCHARGING_DISABLED )
95
+ return BATTERY_DISCONNECTED ;
96
+
97
+
98
+ return BATTERY_NOT_DISCONNECTED ;
99
+ }
100
+
83
101
enum battery_present battery_is_present (void )
84
102
{
85
103
enum battery_present bp ;
86
104
int mv ;
87
105
88
106
mv = adc_read_channel (ADC_VCIN1_BATT_TEMP );
89
-
90
- if (mv == ADC_READ_ERROR )
91
- return -1 ;
92
-
93
107
bp = (mv < 3000 ? BP_YES : BP_NO );
94
108
95
- return bp ;
109
+ if (mv == ADC_READ_ERROR )
110
+ return BP_NO ;
111
+ else if (!bp )
112
+ return BP_NO ;
113
+ else if (!(charger_current_battery_params ()-> flags & BATT_FLAG_RESPONSIVE ))
114
+ return BP_NOT_SURE ;
115
+ else if (battery_check_disconnect () != BATTERY_NOT_DISCONNECTED )
116
+ return BP_NOT_SURE ;
117
+ else
118
+ return bp ;
96
119
}
97
120
98
121
#ifdef CONFIG_EMI_REGION1
Original file line number Diff line number Diff line change 161
161
162
162
#define CONFIG_BATTERY_CUT_OFF
163
163
#define CONFIG_BATTERY_SMART
164
+ #define CONFIG_BATTERY_PRESENT_CUSTOM
164
165
#define CONFIG_BOARD_VERSION_CUSTOM
165
166
#define CONFIG_CHARGE_MANAGER
166
167
/* #define CONFIG_CHARGE_RAMP_SW */
Original file line number Diff line number Diff line change @@ -358,7 +358,8 @@ void cypd_update_power(void)
358
358
359
359
if (extpower_is_present () ||
360
360
(charger_current_battery_params ()-> flags & BATT_FLAG_RESPONSIVE &&
361
- charger_current_battery_params ()-> state_of_charge > 0 ))
361
+ charger_current_battery_params ()-> state_of_charge > 0 &&
362
+ battery_is_present () == BP_YES ))
362
363
system_power_present = 1 ;
363
364
else
364
365
system_power_present = 0 ;
@@ -370,7 +371,8 @@ int cypd_update_power_status(void)
370
371
int rv = EC_SUCCESS ;
371
372
int power_stat = 0 ;
372
373
if (charger_current_battery_params ()-> flags & BATT_FLAG_RESPONSIVE &&
373
- charger_current_battery_params ()-> state_of_charge > 0 ) {
374
+ charger_current_battery_params ()-> state_of_charge > 0 &&
375
+ battery_is_present () == BP_YES ) {
374
376
power_stat |= BIT (3 );
375
377
}
376
378
if (extpower_is_present ()) {
You can’t perform that action at this time.
0 commit comments