diff options
author | Mary Ruthven <mruthven@chromium.org> | 2021-01-05 15:24:32 -0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-01-06 23:06:06 +0000 |
commit | f5cfb505dc2f0123fdc053c100ce634b89036f8c (patch) | |
tree | 800e6dbf1b296c7b8a7bc73becfc0aecdc86ee78 /include | |
parent | 2c29f2e7d758771d18a0ea0639778f2e4ca0867f (diff) | |
download | chrome-ec-f5cfb505dc2f0123fdc053c100ce634b89036f8c.tar.gz |
coil: remove charge_state_v2
This code uses coil terms we're removing, but we don't use it in
platform/cr50. Remove the code instead of replacing the terms.
BUG=b:175244613
TEST=make buildall -j
Change-Id: I6b6004255f951497c5fc3d61e40b67433498a9d6
Signed-off-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2613139
Reviewed-by: Namyoon Woo <namyoon@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/charge_ramp.h | 89 | ||||
-rw-r--r-- | include/charge_state.h | 154 | ||||
-rw-r--r-- | include/charge_state_v2.h | 134 | ||||
-rw-r--r-- | include/charger.h | 162 | ||||
-rw-r--r-- | include/charger_detect.h | 17 | ||||
-rw-r--r-- | include/charger_profile_override.h | 86 |
6 files changed, 0 insertions, 642 deletions
diff --git a/include/charge_ramp.h b/include/charge_ramp.h deleted file mode 100644 index c4082fdbf2..0000000000 --- a/include/charge_ramp.h +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright 2015 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Charge input current limit ramp header for Chrome EC */ - -#ifndef __CROS_EC_CHARGE_RAMP_H -#define __CROS_EC_CHARGE_RAMP_H - -#include "timer.h" - -/* Charge ramp state used for checking VBUS */ -enum chg_ramp_vbus_state { - CHG_RAMP_VBUS_RAMPING, - CHG_RAMP_VBUS_STABLE -}; - -/** - * Check if VBUS is too low - * - * @param port Charge ramp port - * @param ramp_state Current ramp state - * - * @return VBUS is sagging low - */ -int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state); - -/** - * Check if ramping is allowed for given supplier - * - * @supplier Supplier to check - * - * @return Ramping is allowed for given supplier - */ -int chg_ramp_allowed(int supplier); - -/** - * Get the maximum current limit that we are allowed to ramp to - * - * @supplier Active supplier type - * @sup_curr Input current limit based on supplier - * - * @return Maximum current in mA - */ -int chg_ramp_max(int supplier, int sup_curr); - -/** - * Get the input current limit set by ramp module - * - * Active input current limit (mA) - */ -int chg_ramp_get_current_limit(void); - -/** - * Return if charge ramping has reached stable state - * - * @return 1 if stable, 0 otherwise - */ -int chg_ramp_is_stable(void); - -/** - * Return if charge ramping has reached detected state - * - * @return 1 if detected, 0 otherwise - */ -int chg_ramp_is_detected(void); - -#ifdef HAS_TASK_CHG_RAMP -/** - * Notify charge ramp module of supplier type change on a port. If port - * is CHARGE_PORT_NONE, the call indicates the last charge supplier went - * away. - * - * @port Active charging port - * @supplier Active charging supplier - * @current Minimum input current limit - * @registration_time Timestamp of when the supplier is registered - * @voltage Negotiated charge voltage. - */ -void chg_ramp_charge_supplier_change(int port, int supplier, int current, - timestamp_t registration_time, int voltage); - -#else -static inline void chg_ramp_charge_supplier_change( - int port, int supplier, timestamp_t registration_time) { } -#endif - -#endif /* __CROS_EC_CHARGE_RAMP_H */ diff --git a/include/charge_state.h b/include/charge_state.h deleted file mode 100644 index 66fa84aa3c..0000000000 --- a/include/charge_state.h +++ /dev/null @@ -1,154 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#ifndef __CROS_EC_CHARGE_STATE_H -#define __CROS_EC_CHARGE_STATE_H - -#include "common.h" -#include "timer.h" - -/* Stuff that's common to all charger implementations can go here. */ - -/* Seconds to spend trying to wake a non-responsive battery */ -#define PRECHARGE_TIMEOUT CONFIG_BATTERY_PRECHARGE_TIMEOUT - -/* Power state task polling periods in usec */ -#define CHARGE_POLL_PERIOD_VERY_LONG MINUTE -#define CHARGE_POLL_PERIOD_LONG (MSEC * 500) -#define CHARGE_POLL_PERIOD_CHARGE (MSEC * 250) -#define CHARGE_POLL_PERIOD_SHORT (MSEC * 100) -#define CHARGE_MIN_SLEEP_USEC (MSEC * 50) -/* If a board hasn't provided a max sleep, use 1 minute as default */ -#ifndef CHARGE_MAX_SLEEP_USEC -#define CHARGE_MAX_SLEEP_USEC MINUTE -#endif - -/* Power states */ -enum charge_state { - /* Meta-state; unchanged from previous time through task loop */ - PWR_STATE_UNCHANGE = 0, - /* Initializing charge state machine at boot */ - PWR_STATE_INIT, - /* Re-initializing charge state machine */ - PWR_STATE_REINIT, - /* Just transitioned from init to idle */ - PWR_STATE_IDLE0, - /* Idle; AC present */ - PWR_STATE_IDLE, - /* Discharging */ - PWR_STATE_DISCHARGE, - /* Discharging and fully charged */ - PWR_STATE_DISCHARGE_FULL, - /* Charging */ - PWR_STATE_CHARGE, - /* Charging, almost fully charged */ - PWR_STATE_CHARGE_NEAR_FULL, - /* Charging state machine error */ - PWR_STATE_ERROR -}; - -/* Charge state flags */ -/* Forcing idle state */ -#define CHARGE_FLAG_FORCE_IDLE BIT(0) -/* External (AC) power is present */ -#define CHARGE_FLAG_EXTERNAL_POWER BIT(1) -/* Battery is responsive */ -#define CHARGE_FLAG_BATT_RESPONSIVE BIT(2) - -/* Debugging constants, in the same order as enum charge_state. This string - * table was moved here to sync with enum above. - */ -#define CHARGE_STATE_NAME_TABLE { \ - "unchange", \ - "init", \ - "reinit", \ - "idle0", \ - "idle", \ - "discharge", \ - "discharge_full", \ - "charge", \ - "charge_near_full", \ - "error" \ - } - /* End of CHARGE_STATE_NAME_TABLE macro */ - - -/** - * Return current charge state. - */ -enum charge_state charge_get_state(void); - -/** - * Return non-zero if battery is so low we want to keep AP off. - */ -int charge_keep_power_off(void); - -/** - * Return current charge state flags (CHARGE_FLAG_*) - */ -uint32_t charge_get_flags(void); - -#if defined(CONFIG_CHARGER) -/** - * Return current battery charge percentage. - */ -int charge_get_percent(void); -#elif defined(CONFIG_BATTERY) -/** - * Return current battery charge if not using charge manager sub-system. - */ -int board_get_battery_soc(void); -#endif - -/** - * Return current display charge in 10ths of a percent (e.g. 1000 = 100.0%) - */ -int charge_get_display_charge(void); - -/** - * Check if board is consuming full input current - * - * This returns true if the battery charge percentage is between 2% and 95% - * exclusive. - * - * @return Board is consuming full input current - */ -int charge_is_consuming_full_input_current(void); - -/** - * Return non-zero if discharging and battery so low we should shut down. - */ -int charge_want_shutdown(void); - -/** - * Return non-zero if the battery level is too low to allow power on, even if - * a charger is attached. - * - * @param power_button_pressed True if the power-up attempt is caused by a - * power button press. - */ -int charge_prevent_power_on(int power_button_pressed); - -/** - * Get the last polled battery/charger temperature. - * - * @param idx Sensor index to read. - * @param temp_ptr Destination for temperature in K. - * - * @return EC_SUCCESS if successful, non-zero if error. - */ -int charge_get_battery_temp(int idx, int *temp_ptr); - -/** - * Get the pointer to the battery parameters we saved in charge state. - * - * Use this carefully. Other threads can modify data while you are reading. - */ -const struct batt_params *charger_current_battery_params(void); - - -/* Config Charger */ -#include "charge_state_v2.h" - -#endif /* __CROS_EC_CHARGE_STATE_H */ diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h deleted file mode 100644 index c958c0ed7c..0000000000 --- a/include/charge_state_v2.h +++ /dev/null @@ -1,134 +0,0 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "battery.h" -#include "battery_smart.h" -#include "charger.h" -#include "chipset.h" -#include "ec_ec_comm_master.h" -#include "timer.h" - -#ifndef __CROS_EC_CHARGE_STATE_V2_H -#define __CROS_EC_CHARGE_STATE_V2_H - -#if defined(CONFIG_I2C_VIRTUAL_BATTERY) && defined(CONFIG_BATTERY_SMART) -#define VIRTUAL_BATTERY_ADDR_FLAGS BATTERY_ADDR_FLAGS -#endif -/* - * The values exported by charge_get_state() and charge_get_flags() are used - * only to control the LEDs (with one not-quite-correct exception). For V2 - * we use a different set of states internally. - */ -enum charge_state_v2 { - ST_IDLE = 0, - ST_DISCHARGE, - ST_CHARGE, - ST_PRECHARGE, - - NUM_STATES_V2 -}; - -struct charge_state_data { - timestamp_t ts; - int ac; - int batt_is_charging; - struct charger_params chg; - struct batt_params batt; - enum charge_state_v2 state; - int requested_voltage; - int requested_current; - int desired_input_current; -#ifdef CONFIG_CHARGER_OTG - int output_current; -#endif -#ifdef CONFIG_EC_EC_COMM_BATTERY_MASTER - int input_voltage; -#endif -}; - -/** - * Set the output current limit and voltage. This is used to provide power from - * the charger chip ("OTG" mode). - * - * @param ma Maximum current to provide in mA (0 to disable output). - * @param mv Voltage in mV (ignored if ma == 0). - * @return EC_SUCCESS or error - */ -int charge_set_output_current_limit(int ma, int mv); - -/** - * Set the charge input current limit. This value is stored and sent every - * time AC is applied. - * - * @param ma New input current limit in mA - * @param mv Negotiated charge voltage in mV. - * @return EC_SUCCESS or error - */ -int charge_set_input_current_limit(int ma, int mv); - -/* - * Expose charge/battery related state - * - * @param param command to get corresponding data - * @param value the corresponding data - * @return EC_SUCCESS or error - */ -#ifdef CONFIG_CHARGE_STATE_DEBUG -int charge_get_charge_state_debug(int param, uint32_t *value); -#endif /* CONFIG_CHARGE_STATE_DEBUG */ - -/** - * Set the desired manual charge current when in idle mode. - * - * @param curr_ma: Charge current in mA. - */ -void chgstate_set_manual_current(int curr_ma); - -/** - * Set the desired manual charge voltage when in idle mode. - * - * @param volt_mv: Charge voltage in mV. - */ -void chgstate_set_manual_voltage(int volt_mv); - -/** - * Board-specific routine to indicate if the base is connected. - */ -int board_is_base_connected(void); - -/** - * Board-specific routine to enable power distribution between lid and base - * (current can flow both ways). - */ -void board_enable_base_power(int enable); - -/** - * Board-specific routine to reset the base (in case it is unresponsive, e.g. - * if we told it to hibernate). - */ -void board_base_reset(void); - -/** - * Callback with which boards determine action on critical low battery - * - * The default implementation is provided in charge_state_v2.c. Overwrite it - * to customize it. - * - * @param curr Pointer to struct charge_state_data - * @return Action to take. - */ -enum critical_shutdown board_critical_shutdown_check( - struct charge_state_data *curr); - -/** - * Callback to set battery level for shutdown - * - * A board can implement this to customize shutdown battery level at runtime. - * - * @return battery level for shutdown - */ -uint8_t board_set_battery_level_shutdown(void); - -#endif /* __CROS_EC_CHARGE_STATE_V2_H */ diff --git a/include/charger.h b/include/charger.h deleted file mode 100644 index 342f6a7b48..0000000000 --- a/include/charger.h +++ /dev/null @@ -1,162 +0,0 @@ -/* Copyright 2012 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Charger/battery debug command module for Chrome EC */ - -#ifndef __CROS_EC_CHARGER_H -#define __CROS_EC_CHARGER_H - -#include "common.h" - -/* Charger information - * voltage unit: mV - * current unit: mA - */ -struct charger_info { - const char *name; - uint16_t voltage_max; - uint16_t voltage_min; - uint16_t voltage_step; - uint16_t current_max; - uint16_t current_min; - uint16_t current_step; - uint16_t input_current_max; - uint16_t input_current_min; - uint16_t input_current_step; -}; - -/* - * Parameters common to all chargers. Current is in mA, voltage in mV. - * The status and option values are charger-specific. - */ -struct charger_params { - int current; - int voltage; - int input_current; - int status; - int option; - int flags; -}; - -/* Get the current charger_params. Failures are reported in .flags */ -void charger_get_params(struct charger_params *chg); - -/* Bits to indicate which fields of struct charger_params could not be read */ -#define CHG_FLAG_BAD_CURRENT 0x00000001 -#define CHG_FLAG_BAD_VOLTAGE 0x00000002 -#define CHG_FLAG_BAD_INPUT_CURRENT 0x00000004 -#define CHG_FLAG_BAD_STATUS 0x00000008 -#define CHG_FLAG_BAD_OPTION 0x00000010 -/* All of the above CHG_FLAG_BAD_* bits */ -#define CHG_FLAG_BAD_ANY 0x0000001f - -/* Power state machine post init */ -int charger_post_init(void); - -/* Get charger information. */ -const struct charger_info *charger_get_info(void); - -/* Get smart battery charger status. Supported flags may vary. */ -int charger_get_status(int *status); - -/* Set smart battery charger mode. Supported modes may vary. */ -int charger_set_mode(int mode); - -/** - * For chargers that are able to supply output power for OTG dongle, this - * function enables or disables power output. - */ -int charger_enable_otg_power(int enabled); - -/** - * Sets OTG current limit and voltage (independent of whether OTG power is - * currently enabled). - * - * Depending on the charger and use case, one needs to be careful about - * changing the current/voltage while OTG power is enabled, and it might be wise - * to reset the value before enabling OTG power to ensure one does not provide - * excessive voltage to a device. - * - * @param output_current Requested current limit in mA, driver should - * round the value up. - * @param output_voltage Requested voltage in mV, driver should round the - * the value down. - * - * @return EC_SUCCESS on success, an error otherwise. - */ -int charger_set_otg_current_voltage(int output_current, int output_voltage); - -/** - * Is the charger sourcing VBUS / OTG power? - * - * @param port The Type-C port number. - * @return 1 if sourcing VBUS, 0 if not. - */ -int charger_is_sourcing_otg_power(int port); - -/** - * Return the closest match the charger can supply to the requested current. - * - * @param current Requested current in mA. - * - * @return Current the charger will actually supply if <current> is requested. - */ -int charger_closest_current(int current); - -/** - * Return the closest match the charger can supply to the requested voltage. - * - * @param voltage Requested voltage in mV. - * - * @return Voltage the charger will actually supply if <voltage> is requested. - */ -int charger_closest_voltage(int voltage); - -/* Get/set charge current limit in mA */ -int charger_get_current(int *current); -int charger_set_current(int current); - -/* Get/set charge voltage limit in mV */ -int charger_get_voltage(int *voltage); -int charger_set_voltage(int voltage); - -/* Discharge battery when on AC power. */ -int charger_discharge_on_ac(int enable); - -/* Get the VBUS voltage (mV) from the charger */ -int charger_get_vbus_voltage(int port); - -/* Custom board function to discharge battery when on AC power */ -int board_discharge_on_ac(int enable); - -/* - * Read the current total system power in uW (usually from PSYS). - * Can be negative if the PSYS output is not currently enabled (e.g. AP is off). - */ -int charger_get_system_power(void); - -/* Other parameters that may be charger-specific, but are common so far. */ - -/* Set desired input current value */ -int charger_set_input_current(int input_current); - -/* - * Get actual input current value. - * Actual input current may be less than the desired input current set - * due to current ratings of the wall adapter. - */ -int charger_get_input_current(int *input_current); - -int charger_manufacturer_id(int *id); -int charger_device_id(int *id); -int charger_get_option(int *option); -int charger_set_option(int option); -int charger_set_hw_ramp(int enable); - -/* Print all charger info for debugging purposes */ -void print_charger_debug(void); - -#endif /* __CROS_EC_CHARGER_H */ - diff --git a/include/charger_detect.h b/include/charger_detect.h deleted file mode 100644 index ae2001e418..0000000000 --- a/include/charger_detect.h +++ /dev/null @@ -1,17 +0,0 @@ -/* Copyright 2016 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -/* Detect what adapter is connected */ - -#ifndef __CROS_CHARGER_DETECT_H -#define __CROS_CHARGER_DETECT_H - -/* - * Get attached device type. - * - * @return CHARGE_SUPPLIER_BC12_* or 0 if the device type was not detected - */ -int charger_detect_get_device_type(void); - -#endif /* __CROS_CHARGER_DETECT_H */ diff --git a/include/charger_profile_override.h b/include/charger_profile_override.h deleted file mode 100644 index 091eb11946..0000000000 --- a/include/charger_profile_override.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright 2016 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - * - * Charger profile override for fast charging - */ - -#ifndef __CROS_EC_CHARGER_PROFILE_OVERRIDE_H -#define __CROS_EC_CHARGER_PROFILE_OVERRIDE_H - -#include "charge_state_v2.h" - -#define TEMPC_TENTHS_OF_DEG(c) ((c) * 10) - -#define CHARGER_PROF_TEMP_C_LAST_RANGE 0xFFFF - -#define CHARGER_PROF_VOLTAGE_MV_LAST_RANGE 0xFFFF - -/* Charge profile override info */ -struct fast_charge_profile { - /* temperature in 10ths of a degree C */ - const int temp_c; - /* charge current for respective battery voltage ranges in mA. */ - const int current_mA[CONFIG_CHARGER_PROFILE_VOLTAGE_RANGES]; -}; - -/* Charge profile override parameters */ -struct fast_charge_params { - /* Total temperature ranges of the charge profile */ - const int total_temp_ranges; - /* Default temperature range of the charge profile */ - const int default_temp_range_profile; - /* - * Battery voltage ranges in mV. - * It is assumed that these values are added in ascending order in the - * board battery file. - */ - const int voltage_mV[CONFIG_CHARGER_PROFILE_VOLTAGE_RANGES]; - const struct fast_charge_profile *chg_profile_info; -}; - -/** - * Optional customization of charger profile override for fast charging. - * - * On input, the struct reflects the default behavior. The function can make - * changes to the state, requested_voltage, or requested_current. - * - * @param curr Charge state machine data. - * - * @return - * >0 Desired time in usec for this poll period. - * 0 Use the default poll period (which varies with the state). - * <0 An error occurred. The poll time will be shorter than usual. - * Too many errors in a row may trigger some corrective action. - */ -int charger_profile_override(struct charge_state_data *curr); - -/** - * Common code of charger profile override for fast charging. - * - * @param curr Charge state machine data. - * @param fast_chg_params Fast charge profile parameters. - * @param prev_chg_prof_info Previous charge profile info. - * @param batt_vtg_max Maximum battery voltage. - * - * @return - * >0 Desired time in usec for this poll period. - * 0 Use the default poll period (which varies with the state). - * <0 An error occurred. The poll time will be shorter than usual. - * Too many errors in a row may trigger some corrective action. - */ -int charger_profile_override_common(struct charge_state_data *curr, - const struct fast_charge_params *fast_chg_params, - const struct fast_charge_profile **prev_chg_prof_info, - int batt_vtg_max); - -/* - * Access to custom profile params through host commands. - * What this does is up to the implementation. - */ -enum ec_status charger_profile_override_get_param(uint32_t param, - uint32_t *value); -enum ec_status charger_profile_override_set_param(uint32_t param, - uint32_t value); - -#endif /* __CROS_EC_CHARGER_PROFILE_OVERRIDE_H */ |