summaryrefslogtreecommitdiff
path: root/zephyr/Kconfig.battery
blob: 2247e30cffa4c30bc90f553fcdc6ba98dd43043f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# Copyright 2020 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

menuconfig PLATFORM_EC_BATTERY
	bool "Battery support"
	default y
	depends on DT_HAS_BATTERY_SMART_ENABLED
	help
	  Enables battery support on the board. Requires selection of a battery
	  and a charger IC.

	  If using I2C batteries, you must define I2C_PORT_BATTERY in your
	  board's i2c_map.h file so that the EC code will know which I2C
	  port the battery is on.

if PLATFORM_EC_BATTERY

choice PLATFORM_EC_BATTERY_SELECT
	prompt "Select the battery to use"
	default PLATFORM_EC_BATTERY_SMART if DT_HAS_BATTERY_SMART_ENABLED
	help
	  Select the battery used on the board. If you are ensure, select the
	  smart battery option.

config PLATFORM_EC_BATTERY_SMART
	bool "Support a smart battery"
	select PLATFORM_EC_I2C
	help
	  Many batteries support the Smart Battery Specification and therefore
	  have common registers which can be accessed to control and monitor
	  the battery.

	  See here for the spec: http://sbs-forum.org/specs/sbdat110.pdf

endchoice # PLATFORM_EC_BATTERY_SELECT

choice PLATFORM_EC_BATTERY_PRESENT_MODE
	prompt "Method to use to detect the battery"
	default PLATFORM_EC_BATTERY_PRESENT_GPIO if $(dt_path_enabled,/named-gpios/ec_batt_pres_odl)
	help
	  This selects the method to use to detect the presence of a battery.

	  Battery detection is important since it can be used to indicate that
	  the case is open, so security features can be disabled. It is also
	  useful to report to the user when the battery is missing, e.g. with
	  a desktop icon.

config PLATFORM_EC_BATTERY_PRESENT_CUSTOM
	bool "Call a board-provided function"
	help
	  Use this method to provide a board-provided battery_is_present()
	  function to determine whether the battery is currently present.
	  This should be implemented in the board code and can use any
	  reasonable method to detect the battery.

config PLATFORM_EC_BATTERY_PRESENT_GPIO
	bool "Check a GPIO"
	help
	  Use this method if a GPIO signals whether the battery is present. The
	  GPIO should read low if the battery is present, high if absent.

	  The GPIO is hard-coded to GPIO_BATT_PRES_ODL so you should define this
	  in the device tree. The convention is to use the signal
	  name from schematic as both the node name and label for the GPIO. For
	  example:

	    /* gpio.dts */
	    ec_batt_pres_odl {
	    	gpios = <&gpioe 5 GPIO_INPUT>;
	    	enum-name = "EC_BATT_PRES_ODL";
		alias = "GPIO_BATT_PRES_ODL";
	    };

endchoice # PLATFORM_EC_BATTERY_PRESENT_MODE

config PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY
	bool "Provide information about battery chemistry"
	help
	  Enable this to specify the chemistry of the battery device. It is
	  only used for stress testing of reading the battery information over
	  I2C.

config PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY
	string "Battery-device chemistry"
	depends on PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY
	help
	  Specify the battery chemistry for use with the I2C stress test.
	  The value provided here must match what is read from the real
	  battery. This is used in sb_i2c_test_read() to check that the battery
	  is returning the right information. If it is not, there might be
	  something wrong with the I2C implementation.

config PLATFORM_EC_I2C_VIRTUAL_BATTERY
	bool "I2C virtual battery"
	help
	  Enables driver for a virtual battery. It is used to minimalize I2C
	  traffic which is generated by the I2C_PASSTHRU host command.
	  The battery parameters, which are already cached in EC are used to
	  return desired data to host instead of issuing I2C transaction every
	  time.

config PLATFORM_EC_I2C_VIRTUAL_BATTERY_ADDR
	hex "I2C virtual battery address"
	default 0x0B if PLATFORM_EC_BATTERY_SMART
	range 0x00 0x7f
	depends on PLATFORM_EC_I2C_VIRTUAL_BATTERY
	help
	  This config sets i2c address that will be intercepted by virtual
	  battery feature. All communication to this port will be cached
	  to decrease i2c communication traffic.
	  This should be equal to the address of real battery.

config PLATFORM_EC_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF
	bool "Enable battery cut off on critical power level"
	help
	  If this option is enabled, the battery will enter cut-off
	  mode in case of critical power level.

config PLATFORM_EC_BATTERY_CHECK_CHARGE_TEMP_LIMITS
	bool "Monitor battery temperature while charging"
	help
	  Enable monitoring of battery temperature while charging and
	  stop charging if is outside of the safe range.

config PLATFORM_EC_BATTERY_CUT_OFF
	bool "Host/Console command: battery cut-off"
	help
	  Enables support for disconnecting the battery using the "cutoff"
	  console command and the EC_CMD_BATTERY_CUT_OFF host command.
	  Once defined, a board specific board_cut_off_battery() function
	  has to be provided.

config PLATFORM_EC_BATTERY_FUEL_GAUGE
	bool "Board supplies battery info"
	help
	  The fuel gauge information is used to cut off the battery for shipping
	  mode and to check the charge/discharge FET status.  The battery
	  information is used to set voltage, current and temperature operating
	  limits for the battery.

config PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM
	bool "Hardware check of battery presence"
	help
	  Once defined, the charger will check a board specific function
	  battery_hw_present() for battery hw presence as an additional
	  condition to determine if power on is allowed for factory override,
	  where allowing booting of a bare board with no battery and no power
	  button press is required.

config PLATFORM_EC_BATTERY_REVIVE_DISCONNECT
	bool "Check battery disconnect state"
	help
	  Check for battery in disconnect state (similar to cut-off state).
	  If this battery is found to be in disconnect state, take it out of
	  this state by force-applying a charge current. Once defined,
	  a battery_get_disconnect_state() function has to be provided.

config PLATFORM_EC_BATTERY_MEASURE_IMBALANCE
	bool "Measure the battery cells imbalance"
	help
	  Smart battery driver should measure the voltage cell imbalance in the
	  battery pack.
	  This requires a battery driver capable of the measurement.
	  If enabled, the AP enabling may be prevented if battery is too
	  imbalanced.

config PLATFORM_EC_BATTERY_MAX_IMBALANCE_MV
	int "Max battery imbalance in millivolts"
	depends on PLATFORM_EC_BATTERY_MEASURE_IMBALANCE
	default 200
	help
	  Imbalanced battery packs in this situation appear to have balanced
	  charge very quickly after beginning the charging cycle, since dV/dQ
	  rapidly decreases as the cell is charged out of deep discharge.
	  Increasing the value of
	  CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_IMBALANCED_POWER_ON will make a
	  system tolerant of larger values of
	  CONFIG_PLATFORM_EC_BATTERY_MAX_IMBALANCE_MV.

config PLATFORM_EC_BATTERY_STBL_STAT
	bool "Check whether the battery is initialized and stable"
	help
	  Enables support for checking the specific battery status to
	  judge whether the battery is initialized and stable when the battery
	  wakes up from ship mode. Use two MASKs to provide logical AND and
	  logical OR options for different status.

	  For example:
	    STATUS_TERMINATE_CHARGE_ALARM(TCA):0x4000
	    STATUS_TERMINATE_DISCHARGE_ALARM(TDA):0x0800

	  Logical OR -- just check one of TCA/TDA mask:
	    CONFIG_PLATFORM_EC_BATT_ALARM_MASK1=(0x4000 | 0x0800)
	    CONFIG_PLATFORM_EC_BATT_ALARM_MASK2=0xFFFF

	  Logical AND -- check both TCA/TDA mask:
	    CONFIG_PLATFORM_EC_BATT_ALARM_MASK1=0x4000
	    CONFIG_PLATFORM_EC_BATT_ALARM_MASK2=0x0800

	  The default configuration is logical OR.

if PLATFORM_EC_BATTERY_STBL_STAT

config PLATFORM_EC_BATT_ALARM_MASK1
	hex "The battery status mask"
	default 0x4800
	help
	  Use two MASKs to provide logical AND and logical OR options for different
	  status. Default mask 0x4800 means
	  (STATUS_TERMINATE_CHARGE_ALARM | STATUS_TERMINATE_DISCHARGE_ALARM),
	  any one of these two masks is set, the battery state can be considered
	  stable.

config PLATFORM_EC_BATT_ALARM_MASK2
	hex "The battery status mask"
	default 0xFFFF
	help
	  Use two MASKs to provide logical AND and logical OR options for different
	  status. Default mask 0xFFFF means do not use this mask.

endif # PLATFORM_EC_BATTERY_STBL_STAT

config PLATFORM_EC_CHARGER_MIN_BAT_PCT_IMBALANCED_POWER_ON
	int "Minimum battery percentage for power on with an imbalanced pack"
	depends on PLATFORM_EC_BATTERY_MEASURE_IMBALANCE
	default 5
	range 0 100
	help
	  If battery pack is in imbalanced state and current state of charge is
	  below this value, the AP won't be powered on.

config PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV
	int "Voltage limit in mV when battery is full and AP is off"
	depends on PLATFORM_EC_USB_PE_SM && PLATFORM_EC_CHARGE_MANAGER
	default -1
	help
	  If set to a non-negative value, input voltage will be reduced to given
	  value when chipset is in S5/G3 state and battery is fully charged.
	  This condition is checked on chipset shutdown and startup, AC change
	  and battery SOC change.

choice PLATFORM_EC_BATTERY_API
	prompt "Battery API version"
	default PLATFORM_EC_BATTERY_V2
	help
	  Select the battery API version. V2 is required on dual-battery-systems
	  and hostless bases with a battery. V1 should not be used except for
	  testing on legacy boards.

config PLATFORM_EC_BATTERY_V1
	bool "Enable battery API v1"
	depends on !PLATFORM_EC_BATTERY_V2
	help
	  This enables battery API version 1, with support for only a single
	  battery. Battery information strings are trimmed to 8 characters.

config PLATFORM_EC_BATTERY_V2
	bool "Enable battery API v2"
	help
	  This enables battery API version 2. This version can support multiple
	  batteries and full size string values in the battery information
	  including manufacturer, model, chemistry.

endchoice

if PLATFORM_EC_BATTERY_V2

config PLATFORM_EC_BATTERY_COUNT
	int "Battery count"
	default 1
	help
	  The number of batteries in the system. It matters only when
	  PLATFORM_EC_BATTERY_V2 is enabled. Note this is different from
	  BATTERY_TYPE_COUNT.

config PLATFORM_EC_HOSTCMD_BATTERY_V2
	bool "Enable host command battery API v2"
	default y
	help
	  Include host commands to fetch battery information from
	  ec_response_battery_static/dynamic_info structures, only make sense
	  when PLATFORM_EC_BATTERY_V2 is enabled.

endif # PLATFORM_EC_BATTERY_V2

config PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT
	bool "Disable battery auto detection"
	help
	  Enable this option when the battery type cannot be distinguished
	  based on only the manufacturer and device name. Your board code
	  must call battery_set_fixed_battery_type() to set the fixed battery
	  type, during board initialization.

if PLATFORM_EC_I2C_VIRTUAL_BATTERY

config PLATFORM_EC_SMART_BATTERY_OPTIONAL_MFG_FUNC
	bool "Support smart battery optional MFG function"
	help
	  Enable this option when need support smart battery optional commands.
	  Only make sense when PLATFORM_EC_I2C_VIRTUAL_BATTERY.

endif # PLATFORM_EC_I2C_VIRTUAL_BATTERY

config PLATFORM_EC_BATT_HOST_FULL_FACTOR
	int "This value is used by the host to calculate the ETA for full charge"
	default 97
	help
	  Today, EC's PLATFORM_EC_BATT_HOST_FULL_FACTOR is the source of truth.
	  Powerd gets the value from the EC over EC_CMD_DISPLAY_SOC.

endif # PLATFORM_EC_BATTERY