diff options
-rw-r--r-- | common/build.mk | 2 | ||||
-rw-r--r-- | common/ec_ec_comm_master.c | 370 | ||||
-rw-r--r-- | common/ec_ec_comm_slave.c | 327 | ||||
-rw-r--r-- | include/config.h | 32 | ||||
-rw-r--r-- | include/ec_ec_comm_master.h | 58 | ||||
-rw-r--r-- | include/ec_ec_comm_slave.h | 20 |
6 files changed, 0 insertions, 809 deletions
diff --git a/common/build.mk b/common/build.mk index 8fb1d2c61a..07ffc9f2b4 100644 --- a/common/build.mk +++ b/common/build.mk @@ -58,8 +58,6 @@ common-$(CONFIG_DEVICE_EVENT)+=device_event.o common-$(CONFIG_DEVICE_STATE)+=device_state.o common-$(CONFIG_DPTF)+=dptf.o common-$(CONFIG_EC_EFS_SUPPORT)+=ec_comm.o ec_efs.o -common-$(CONFIG_EC_EC_COMM_MASTER)+=ec_ec_comm_master.o -common-$(CONFIG_EC_EC_COMM_SLAVE)+=ec_ec_comm_slave.o common-$(CONFIG_EXTRACT_PRINTF_STRINGS)+=cmsg.o common-$(CONFIG_HOSTCMD_ESPI)+=espi.o common-$(CONFIG_EXTENSION_COMMAND)+=extension.o diff --git a/common/ec_ec_comm_master.c b/common/ec_ec_comm_master.c deleted file mode 100644 index 966e4c0f53..0000000000 --- a/common/ec_ec_comm_master.c +++ /dev/null @@ -1,370 +0,0 @@ -/* Copyright 2017 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. - * - * EC-EC communication, functions and definitions for master. - */ - -#include "battery.h" -#include "common.h" -#include "console.h" -#include "crc8.h" -#include "ec_commands.h" -#include "ec_ec_comm_master.h" -#include "timer.h" -#include "uart.h" -#include "util.h" - -/* Console output macros */ -#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ## args) - -/* - * TODO(b:65697962): The packed structures below do not play well if we force EC - * host commands structures to be aligned on 32-bit boundary. There are ways to - * fix that, possibly requiring copying data around, or modifying - * uart_alt_pad_write_read API to write the actual slave response to a separate - * buffer. - */ -#ifdef CONFIG_HOSTCMD_ALIGNED -#error "Cannot define CONFIG_HOSTCMD_ALIGNED with EC-EC communication master." -#endif - -#define EC_EC_HOSTCMD_VERSION 4 - -/* Print extra debugging information */ -#undef EXTRA_DEBUG - -/* - * During early debugging, we would like to check that the error rate does - * grow out of control. - */ -#define DEBUG_EC_COMM_STATS -#ifdef DEBUG_EC_COMM_STATS -struct { - int total; - int errtimeout; - int errbusy; - int errunknown; - int errdatacrc; - int errcrc; - int errinval; -} comm_stats; - -#define INCR_COMM_STATS(var) (comm_stats.var++) -#else -#define INCR_COMM_STATS(var) -#endif - -/** - * Write a command on the EC-EC communication UART channel. - * - * @param command One of EC_CMD_*. - * @param data Packed structure with this layout: - * struct { - * struct { - * struct ec_host_request4 head; - * struct ec_params_* param; - * uint8_t crc8; - * } req; - * struct { - * struct ec_host_response4 head; - * struct ec_response_* info; - * uint8_t crc8; - * } resp; - * } __packed data; - * - * Where req is the request to be transmitted (head and crc8 are computed by - * this function), and resp is the response to be received (head integrity and - * crc8 are verified by this function). - * - * This format is required as the EC-EC UART is half-duplex, and all the - * transmitted data is received back, i.e. the master writes req, then reads - * req, followed by resp. - * - * When a command does not take parameters, param/crc8 must be omitted in - * tx structure. The same applies to rx structure if the response does not - * include a payload: info/crc8 must be omitted. - * - * @param req_len size of req.param (0 if no parameter is passed). - * @param resp_len size of resp.info (0 if no information is returned). - * @param timeout_us timeout in microseconds for the transaction to complete. - * - * @return - * - EC_SUCCESS on success. - * - EC_ERROR_TIMEOUT when remote end times out replying. - * - EC_ERROR_BUSY when UART is busy and cannot transmit currently. - * - EC_ERROR_CRC when the header or data CRC is invalid. - * - EC_ERROR_INVAL when the received header is invalid. - * - EC_ERROR_UNKNOWN on other error. - */ -static int write_command(uint16_t command, - uint8_t *data, int req_len, int resp_len, - int timeout_us) -{ - /* Sequence number. */ - static uint8_t cur_seq; - int ret; - int hascrc, response_seq; - - struct ec_host_request4 *request_header = (void *)data; - /* Request (TX) length is header + (data + crc8), response follows. */ - int tx_length = - sizeof(*request_header) + ((req_len > 0) ? (req_len + 1) : 0); - - struct ec_host_response4 *response_header = - (void *)&data[tx_length]; - /* RX length is TX length + response from slave. */ - int rx_length = tx_length + - sizeof(*request_header) + ((resp_len > 0) ? (resp_len + 1) : 0); - - /* - * Make sure there is a gap between each command, so that the slave - * can recover its state machine after each command. - * - * TODO(b:65697962): We can be much smarter than this, and record the - * last transaction time instead of just sleeping blindly. - */ - usleep(10*MSEC); - -#ifdef DEBUG_EC_COMM_STATS - if ((comm_stats.total % 128) == 0) { - CPRINTF("UART %d (T%dB%d,U%dC%dD%dI%d)\n", comm_stats.total, - comm_stats.errtimeout, comm_stats.errbusy, - comm_stats.errunknown, comm_stats.errcrc, - comm_stats.errdatacrc, comm_stats.errinval); - } -#endif - - cur_seq = (cur_seq + 1) & - (EC_PACKET4_0_SEQ_NUM_MASK >> EC_PACKET4_0_SEQ_NUM_SHIFT); - - memset(request_header, 0, sizeof(*request_header)); - /* fields0: leave seq_dup and is_response as 0. */ - request_header->fields0 = - EC_EC_HOSTCMD_VERSION | /* version */ - (cur_seq << EC_PACKET4_0_SEQ_NUM_SHIFT); /* seq_num */ - /* fields1: leave command_version as 0. */ - if (req_len > 0) - request_header->fields1 |= EC_PACKET4_1_DATA_CRC_PRESENT_MASK; - request_header->command = command; - request_header->data_len = req_len; - request_header->header_crc = - crc8((uint8_t *)request_header, sizeof(*request_header)-1); - if (req_len > 0) - data[sizeof(*request_header) + req_len] = - crc8(&data[sizeof(*request_header)], req_len); - - ret = uart_alt_pad_write_read((void *)data, tx_length, - (void *)data, rx_length, timeout_us); - - INCR_COMM_STATS(total); - -#ifdef EXTRA_DEBUG - CPRINTF("EC-EC ret=%d/%d\n", ret, rx_length); -#endif - - if (ret != rx_length) { - if (ret == -EC_ERROR_TIMEOUT) { - INCR_COMM_STATS(errtimeout); - return EC_ERROR_TIMEOUT; - } - - if (ret == -EC_ERROR_BUSY) { - INCR_COMM_STATS(errbusy); - return EC_ERROR_BUSY; - } - - INCR_COMM_STATS(errunknown); - return EC_ERROR_UNKNOWN; - } - - if (response_header->header_crc != - crc8((uint8_t *)response_header, - sizeof(*response_header)-1)) { - INCR_COMM_STATS(errcrc); - return EC_ERROR_CRC; - } - - hascrc = response_header->fields1 & EC_PACKET4_1_DATA_CRC_PRESENT_MASK; - response_seq = (response_header->fields0 & EC_PACKET4_0_SEQ_NUM_MASK) >> - EC_PACKET4_0_SEQ_NUM_SHIFT; - - /* - * Validate received header. - * Note that we _require_ data crc to be present if there is data to be - * read back, else we would not know how many bytes to read exactly. - */ - if ((response_header->fields0 & EC_PACKET4_0_STRUCT_VERSION_MASK) - != EC_EC_HOSTCMD_VERSION || - !(response_header->fields0 & - EC_PACKET4_0_IS_RESPONSE_MASK) || - response_seq != cur_seq || - (response_header->data_len > 0 && !hascrc) || - response_header->data_len != resp_len) { - INCR_COMM_STATS(errinval); - return EC_ERROR_INVAL; - } - - /* Check data CRC. */ - if (hascrc && data[rx_length - 1] != - crc8(&data[tx_length + sizeof(*request_header)], - resp_len)) { - INCR_COMM_STATS(errdatacrc); - return EC_ERROR_CRC; - } - - return EC_SUCCESS; -} - -/** - * handle error from write_command - * - * @param ret is return value from write_command - * @param request_result is data.resp.head.result (response result value) - * - * @return EC_RES_ERROR if ret is not EC_SUCCESS, else request_result. - */ -static int handle_error(const char *func, int ret, int request_result) -{ - if (ret != EC_SUCCESS) { - /* Do not print busy errors as they just spam the console. */ - if (ret != EC_ERROR_BUSY) - CPRINTF("%s: tx error %d\n", func, ret); - return EC_RES_ERROR; - } - - if (request_result != EC_RES_SUCCESS) - CPRINTF("%s: cmd error %d\n", func, ret); - - return request_result; -} - -#ifdef CONFIG_EC_EC_COMM_BATTERY -int ec_ec_master_base_get_dynamic_info(void) -{ - int ret; - struct { - struct { - struct ec_host_request4 head; - struct ec_params_battery_dynamic_info param; - uint8_t crc8; - } req; - struct { - struct ec_host_response4 head; - struct ec_response_battery_dynamic_info info; - uint8_t crc8; - } resp; - } __packed data; - - data.req.param.index = 0; - - ret = write_command(EC_CMD_BATTERY_GET_DYNAMIC, - (void *)&data, sizeof(data.req.param), - sizeof(data.resp.info), 15 * MSEC); - ret = handle_error(__func__, ret, data.resp.head.result); - if (ret != EC_RES_SUCCESS) - return ret; - -#ifdef EXTRA_DEBUG - CPRINTF("V: %d mV\n", data.resp.info.actual_voltage); - CPRINTF("I: %d mA\n", data.resp.info.actual_current); - CPRINTF("Remaining: %d mAh\n", data.resp.info.remaining_capacity); - CPRINTF("Cap-full: %d mAh\n", data.resp.info.full_capacity); - CPRINTF("Flags: %04x\n", data.resp.info.flags); - CPRINTF("V-desired: %d mV\n", data.resp.info.desired_voltage); - CPRINTF("I-desired: %d mA\n", data.resp.info.desired_current); -#endif - - memcpy(&battery_dynamic[BATT_IDX_BASE], &data.resp.info, - sizeof(battery_dynamic[BATT_IDX_BASE])); - return EC_RES_SUCCESS; -} - -int ec_ec_master_base_get_static_info(void) -{ - int ret; - struct { - struct { - struct ec_host_request4 head; - struct ec_params_battery_static_info param; - uint8_t crc8; - } req; - struct { - struct ec_host_response4 head; - struct ec_response_battery_static_info info; - uint8_t crc8; - } resp; - } __packed data; - - data.req.param.index = 0; - - ret = write_command(EC_CMD_BATTERY_GET_STATIC, - (void *)&data, sizeof(data.req.param), - sizeof(data.resp.info), 15 * MSEC); - ret = handle_error(__func__, ret, data.resp.head.result); - if (ret != EC_RES_SUCCESS) - return ret; - -#ifdef EXTRA_DEBUG - CPRINTF("Cap-design: %d mAh\n", data.resp.info.design_capacity); - CPRINTF("V-design: %d mV\n", data.resp.info.design_voltage); - CPRINTF("Manuf: %s\n", data.resp.info.manufacturer); - CPRINTF("Model: %s\n", data.resp.info.model); - CPRINTF("Serial: %s\n", data.resp.info.serial); - CPRINTF("Type: %s\n", data.resp.info.type); - CPRINTF("C-count: %d\n", data.resp.info.cycle_count); -#endif - - memcpy(&battery_static[BATT_IDX_BASE], &data.resp.info, - sizeof(battery_static[BATT_IDX_BASE])); - return EC_RES_SUCCESS; -} - -int ec_ec_master_base_charge_control(int max_current, - int otg_voltage, - int allow_charging) -{ - int ret; - struct { - struct { - struct ec_host_request4 head; - struct ec_params_charger_control ctrl; - uint8_t crc8; - } req; - struct { - struct ec_host_response4 head; - } resp; - } __packed data; - - data.req.ctrl.allow_charging = allow_charging; - data.req.ctrl.max_current = max_current; - data.req.ctrl.otg_voltage = otg_voltage; - - ret = write_command(EC_CMD_CHARGER_CONTROL, - (void *)&data, sizeof(data.req.ctrl), 0, 30 * MSEC); - - return handle_error(__func__, ret, data.resp.head.result); -} - -int ec_ec_master_hibernate(void) -{ - int ret; - struct { - struct { - struct ec_host_request4 head; - struct ec_params_reboot_ec param; - } req; - struct { - struct ec_host_response4 head; - } resp; - } __packed data; - - data.req.param.cmd = EC_REBOOT_HIBERNATE; - data.req.param.flags = 0; - - ret = write_command(EC_CMD_REBOOT_EC, - (void *)&data, sizeof(data.req.param), 0, 30 * MSEC); - - return handle_error(__func__, ret, data.resp.head.result); -} -#endif /* CONFIG_EC_EC_COMM_BATTERY */ diff --git a/common/ec_ec_comm_slave.c b/common/ec_ec_comm_slave.c deleted file mode 100644 index 339f0f0490..0000000000 --- a/common/ec_ec_comm_slave.c +++ /dev/null @@ -1,327 +0,0 @@ -/* Copyright 2017 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. - * - * EC-EC communication, task and functions for slave. - */ - -#include "common.h" -#include "battery.h" -#include "charge_state_v2.h" -#include "console.h" -#include "crc8.h" -#include "ec_commands.h" -#include "ec_ec_comm_slave.h" -#include "extpower.h" -#include "hwtimer.h" -#include "hooks.h" -#include "queue.h" -#include "queue_policies.h" -#include "system.h" -#include "task.h" -#include "util.h" - -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) - -/* Print extra debugging information */ -#undef EXTRA_DEBUG - -/* Set if the master allows the slave to charge the battery. */ -static int charging_allowed; - -/* - * Our command parameter buffer must be big enough to fit any command - * parameter, and crc byte. - */ -#define LARGEST_PARAMS_SIZE 8 - -BUILD_ASSERT(LARGEST_PARAMS_SIZE >= - sizeof(struct ec_params_battery_static_info)); -BUILD_ASSERT(LARGEST_PARAMS_SIZE >= - sizeof(struct ec_params_battery_dynamic_info)); -BUILD_ASSERT(LARGEST_PARAMS_SIZE >= - sizeof(struct ec_params_charger_control)); - -#define COMMAND_BUFFER_PARAMS_SIZE (LARGEST_PARAMS_SIZE + 1) - -/* - * Maximum time needed to read a full command, commands are at most 17 bytes, so - * should not take more than 2ms to be sent at 115200 bps. - */ -#define COMMAND_TIMEOUT_US (5 * MSEC) - - -void ec_ec_comm_slave_written(struct consumer const *consumer, size_t count) -{ - task_wake(TASK_ID_ECCOMM); -} - -/* - * Discard all data from the input queue. - * - * Note that we always sleep for 1ms after clearing the queue, to make sure - * that we give enough time for the next byte to arrive. - */ -static void discard_queue(void) -{ - do { - queue_advance_head(&ec_ec_comm_slave_input, - queue_count(&ec_ec_comm_slave_input)); - usleep(1 * MSEC); - } while (queue_count(&ec_ec_comm_slave_input) > 0); -} - -/* Write response to master. */ -static void write_response(uint16_t res, int seq, const void *data, int len) -{ - struct ec_host_response4 header; - uint8_t crc; - - header.fields0 = - 4 | /* version */ - EC_PACKET4_0_IS_RESPONSE_MASK | /* is_response */ - (seq << EC_PACKET4_0_SEQ_NUM_SHIFT); /* seq_num */ - /* Set data_crc_present if there is data */ - header.fields1 = (len > 0) ? EC_PACKET4_1_DATA_CRC_PRESENT_MASK : 0; - header.result = res; - header.data_len = len; - header.reserved = 0; - header.header_crc = - crc8((uint8_t *)&header, sizeof(header)-1); - QUEUE_ADD_UNITS(&ec_ec_comm_slave_output, - (uint8_t *)&header, sizeof(header)); - - if (len > 0) { - QUEUE_ADD_UNITS(&ec_ec_comm_slave_output, data, len); - crc = crc8(data, len); - QUEUE_ADD_UNITS(&ec_ec_comm_slave_output, &crc, sizeof(crc)); - } -} - -/* - * Read len bytes into buffer. Waiting up to COMMAND_TIMEOUT_US after start. - * - * Returns EC_SUCCESS or EC_ERROR_TIMEOUT. - */ -static int read_data(void *buffer, size_t len, uint32_t start) -{ - uint32_t delta; - - while (queue_count(&ec_ec_comm_slave_input) < len) { - delta = __hw_clock_source_read() - start; - if (delta >= COMMAND_TIMEOUT_US) - return EC_ERROR_TIMEOUT; - - /* Every incoming byte wakes the task. */ - task_wait_event(COMMAND_TIMEOUT_US - delta); - } - - /* Fetch header */ - QUEUE_REMOVE_UNITS(&ec_ec_comm_slave_input, buffer, len); - - return EC_SUCCESS; -} - -static void handle_cmd_reboot_ec( - const struct ec_params_reboot_ec *params, - int data_len, int seq) -{ - int ret = EC_RES_SUCCESS; - - if (data_len != sizeof(*params)) { - ret = EC_RES_INVALID_COMMAND; - goto out; - } - - /* Only handle hibernate */ - if (params->cmd != EC_REBOOT_HIBERNATE) { - ret = EC_RES_INVALID_PARAM; - goto out; - } - - CPRINTS("Hibernating..."); - - system_hibernate(0, 0); - /* We should not be able to write back the response. */ - -out: - write_response(ret, seq, NULL, 0); -} - -#ifdef CONFIG_EC_EC_COMM_BATTERY -static void handle_cmd_charger_control( - const struct ec_params_charger_control *params, - int data_len, int seq) -{ - int ret = EC_RES_SUCCESS; - int prev_charging_allowed = charging_allowed; - - if (data_len != sizeof(*params)) { - ret = EC_RES_INVALID_COMMAND; - goto out; - } - - if (params->max_current >= 0) { - charge_set_output_current_limit(0, 0); - charge_set_input_current_limit( - MIN(MAX_CURRENT_MA, params->max_current), 0); - charging_allowed = params->allow_charging; - } else { - if (-params->max_current > MAX_OTG_CURRENT_MA || - params->otg_voltage > MAX_OTG_VOLTAGE_MV) { - ret = EC_RES_INVALID_PARAM; - goto out; - } - - /* Reset input current to minimum. */ - charge_set_input_current_limit(CONFIG_CHARGER_INPUT_CURRENT, 0); - /* Setup and enable "OTG". */ - charge_set_output_current_limit(-params->max_current, - params->otg_voltage); - charging_allowed = 0; - } - - if (prev_charging_allowed != charging_allowed) - hook_notify(HOOK_AC_CHANGE); - -out: - write_response(ret, seq, NULL, 0); -} - -/* - * On dual-battery slave, we use the charging allowed signal from master to - * indicate whether external power is present. - * - * In most cases, this actually matches the external power status of the master - * (slave battery charging when AC is connected, or discharging when slave - * battery still has enough capacity), with one exception: when we do master to - * slave battery charging (in this case the "external" power is the master). - */ -int extpower_is_present(void) -{ - return charging_allowed; -} -#endif - -void ec_ec_comm_slave_task(void *u) -{ - struct ec_host_request4 header; - /* - * If CONFIG_HOSTCMD_ALIGNED is set, it is important that params is - * aligned on a 32-bit boundary. - */ - uint8_t __aligned(4) params[COMMAND_BUFFER_PARAMS_SIZE]; - unsigned int len, seq = 0, hascrc, cmdver; - uint32_t start; - - while (1) { - task_wait_event(-1); - - if (queue_count(&ec_ec_comm_slave_input) == 0) - continue; - - /* We got some data, start timeout counter. */ - start = __hw_clock_source_read(); - - /* Wait for whole header to be available and read it. */ - if (read_data(&header, sizeof(header), start)) { - CPRINTS("%s timeout (header)", __func__); - goto discard; - } - -#ifdef EXTRA_DEBUG - CPRINTS("%s f0=%02x f1=%02x cmd=%02x, length=%d", __func__, - header.fields0, header.fields1, - header.command, header.data_len); -#endif - - /* Ignore response (we wrote that ourselves) */ - if (header.fields0 & EC_PACKET4_0_IS_RESPONSE_MASK) - goto discard; - - /* Validate version and crc. */ - if ((header.fields0 & EC_PACKET4_0_STRUCT_VERSION_MASK) != 4 || - header.header_crc != - crc8((uint8_t *)&header, sizeof(header)-1)) { - CPRINTS("%s header/crc error", __func__); - goto discard; - } - - len = header.data_len; - hascrc = header.fields1 & EC_PACKET4_1_DATA_CRC_PRESENT_MASK; - if (hascrc) - len += 1; - - /* - * Ignore commands that are too long to fit in our buffer. - */ - if (len > sizeof(params)) { - CPRINTS("%s len error (%d)", __func__, len); - /* Discard the data first, then write error back. */ - discard_queue(); - write_response(EC_RES_OVERFLOW, seq, NULL, 0); - goto discard; - } - - seq = (header.fields0 & EC_PACKET4_0_SEQ_NUM_MASK) >> - EC_PACKET4_0_SEQ_NUM_SHIFT; - - cmdver = header.fields1 & EC_PACKET4_1_COMMAND_VERSION_MASK; - - /* Wait for the rest of the data to be available and read it. */ - if (read_data(params, len, start)) { - CPRINTS("%s timeout (data)", __func__); - goto discard; - } - - /* Check data CRC */ - if (hascrc && params[len-1] != crc8(params, len-1)) { - CPRINTS("%s data crc error", __func__); - write_response(EC_RES_INVALID_CHECKSUM, seq, NULL, 0); - goto discard; - } - - /* For now, all commands have version 0. */ - if (cmdver != 0) { - CPRINTS("%s bad command version", __func__); - write_response(EC_RES_INVALID_VERSION, seq, NULL, 0); - continue; - } - - switch (header.command) { -#ifdef CONFIG_EC_EC_COMM_BATTERY - case EC_CMD_BATTERY_GET_STATIC: - /* Note that we ignore the battery index parameter. */ - write_response(EC_RES_SUCCESS, seq, - &battery_static[BATT_IDX_MAIN], - sizeof(battery_static[BATT_IDX_MAIN])); - break; - case EC_CMD_BATTERY_GET_DYNAMIC: - /* Note that we ignore the battery index parameter. */ - write_response(EC_RES_SUCCESS, seq, - &battery_dynamic[BATT_IDX_MAIN], - sizeof(battery_dynamic[BATT_IDX_MAIN])); - break; - case EC_CMD_CHARGER_CONTROL: - handle_cmd_charger_control((void *)params, - header.data_len, seq); - break; -#endif - case EC_CMD_REBOOT_EC: - handle_cmd_reboot_ec((void *)params, - header.data_len, seq); - break; - default: - write_response(EC_RES_INVALID_COMMAND, seq, - NULL, 0); - } - - continue; -discard: - /* - * Some error occurred: discard all data in the queue. - */ - discard_queue(); - } -} diff --git a/include/config.h b/include/config.h index 7da7477dfc..68a8e4160d 100644 --- a/include/config.h +++ b/include/config.h @@ -1317,20 +1317,6 @@ */ #undef CONFIG_EC_EFS_SUPPORT -/*****************************************************************************/ -/* Support for EC-EC communication */ - -/* - * Board is master or slave in EC-EC communication. - */ -#undef CONFIG_EC_EC_COMM_MASTER -#undef CONFIG_EC_EC_COMM_SLAVE - -/* - * Board support battery-related functions in EC-EC communication. - */ -#undef CONFIG_EC_EC_COMM_BATTERY - /* * Enable the experimental console. * @@ -4588,24 +4574,6 @@ #endif /*****************************************************************************/ -/* - * Define derived configuration options for EC-EC communication - */ -#ifdef CONFIG_EC_EC_COMM_BATTERY -#ifdef CONFIG_EC_EC_COMM_MASTER -#define CONFIG_EC_EC_COMM_BATTERY_MASTER -#define CONFIG_BATTERY_V2 -#define CONFIG_BATTERY_COUNT 2 -#endif - -#ifdef CONFIG_EC_EC_COMM_SLAVE -#define CONFIG_EC_EC_COMM_BATTERY_SLAVE -#define CONFIG_BATTERY_V2 -#define CONFIG_BATTERY_COUNT 1 -#endif -#endif /* CONFIG_EC_EC_COMM_BATTERY */ - -/*****************************************************************************/ /* Define derived USB PD Discharge common path */ #if defined(CONFIG_USB_PD_DISCHARGE_GPIO) || \ defined(CONFIG_USB_PD_DISCHARGE_TCPC) || \ diff --git a/include/ec_ec_comm_master.h b/include/ec_ec_comm_master.h deleted file mode 100644 index ccd46a9bc2..0000000000 --- a/include/ec_ec_comm_master.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright 2017 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. - * - * EC-EC communication, functions for master. - */ - -#ifndef EC_EC_COMM_MASTER_H_ -#define EC_EC_COMM_MASTER_H_ - -#include <stdint.h> -#include "config.h" - -/** - * Sends EC_CMD_BATTERY_GET_DYNAMIC command to slave, and writes the - * battery dynamic information into battery_dynamic[BATT_IDX_BASE]. - * - * Leaves battery_dynamic[BATT_IDX_BASE] intact on error: it is the callers - * responsibility to clear the data or ignore it. - - * @return EC_RES_SUCCESS on success, EC_RES_ERROR on communication error, - * else forwards the error code from the slave. - */ -int ec_ec_master_base_get_dynamic_info(void); - -/** - * Sends EC_CMD_BATTERY_GET_STATIC command to slave, and writes the - * battery static information into battery_static[BATT_IDX_BASE]. - * - * Leaves battery_static[BATT_IDX_BASE] intact on error: it is the callers - * responsibility to clear the data or ignore it. - * - * @return EC_RES_SUCCESS on success, EC_RES_ERROR on communication error, - * else forwards the error code from the slave. - */ -int ec_ec_master_base_get_static_info(void); - -/** - * Sends EC_CMD_CHARGER_CONTROL command to slave, with the given parameters - * (see ec_commands.h/ec_params_charger_control for description). - * - * @return EC_RES_SUCCESS on success, EC_RES_ERROR on communication error, - * else forwards the error code from the slave. - */ -int ec_ec_master_base_charge_control(int max_current, - int otg_voltage, - int allow_charging); - -/** - * Sends EC_CMD_REBOOT_EC command to slave, with EC_REBOOT_HIBERNATE parameter. - * - * @return EC_RES_ERROR on communication error (should always be the case if the - * slave successfully hibernates, as it will not be able to write back the - * response, else forwards the error code from the slave. - */ -int ec_ec_master_hibernate(void); - -#endif /* EC_EC_COMM_MASTER_H_ */ diff --git a/include/ec_ec_comm_slave.h b/include/ec_ec_comm_slave.h deleted file mode 100644 index 19e1912d94..0000000000 --- a/include/ec_ec_comm_slave.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright 2017 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. - * - * EC-EC communication, functions and definition for slave. - */ - -#ifndef EC_EC_COMM_SLAVE_H_ -#define EC_EC_COMM_SLAVE_H_ - -#include <stdint.h> -#include "consumer.h" -#include "queue.h" - -extern struct queue const ec_ec_comm_slave_input; -extern struct queue const ec_ec_comm_slave_output; - -void ec_ec_comm_slave_written(struct consumer const *consumer, size_t count); - -#endif /* EC_EC_COMM_SLAVE_H_ */ |