mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-10 09:31:51 +00:00
sb_fw_update: Get rid of CONFIG_SB_FIRMWARE_UPDATE
CONFIG_SB_FIRMWARE_UPDATE is dead on ToT. So, get rid it completely. BUG=b:69695376 BRANCH=None TEST=make -j buildall Change-Id: Ic1eedff21d82f729a73ec9a7c1d554b6b571e827 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/792013 Reviewed-by: Shawn N <shawnn@chromium.org>
This commit is contained in:
committed by
chrome-bot
parent
c147530f10
commit
d33eb02aef
@@ -21,7 +21,6 @@
|
||||
#include "i2c.h"
|
||||
#include "math_util.h"
|
||||
#include "printf.h"
|
||||
#include "sb_fw_update.h"
|
||||
#include "system.h"
|
||||
#include "task.h"
|
||||
#include "timer.h"
|
||||
@@ -655,13 +654,6 @@ void charger_task(void *u)
|
||||
|
||||
while (1) {
|
||||
|
||||
#ifdef CONFIG_SB_FIRMWARE_UPDATE
|
||||
if (sb_fw_update_in_progress()) {
|
||||
task_wait_event(CHARGE_MAX_SLEEP_USEC);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Let's see what's going on... */
|
||||
curr.ts = get_time();
|
||||
sleep_usec = 0;
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
/* Copyright (c) 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.
|
||||
*
|
||||
* Smart battery Firmware Update driver.
|
||||
* Ref: Common Smart Battery System Interface Specification v8.0.
|
||||
*/
|
||||
|
||||
#include "battery.h"
|
||||
#include "battery_smart.h"
|
||||
#include "host_command.h"
|
||||
#include "i2c.h"
|
||||
#include "timer.h"
|
||||
#include "util.h"
|
||||
#include "ec_commands.h"
|
||||
#include "sb_fw_update.h"
|
||||
#include "console.h"
|
||||
#include "crc8.h"
|
||||
#include "smbus.h"
|
||||
|
||||
#define CPRINTF(fmt, args...) cprintf(CC_I2C, fmt, ## args)
|
||||
|
||||
static struct ec_sb_fw_update_header sb_fw_hdr;
|
||||
|
||||
static int i2c_access_enable;
|
||||
|
||||
static int get_state(void)
|
||||
{
|
||||
return sb_fw_hdr.subcmd;
|
||||
}
|
||||
|
||||
static void set_state(int subcmd)
|
||||
{
|
||||
sb_fw_hdr.subcmd = subcmd;
|
||||
}
|
||||
|
||||
int sb_fw_update_in_progress(void)
|
||||
{
|
||||
return i2c_access_enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Smart Battery Firmware Update is protected.
|
||||
*
|
||||
* @return 1 if YES, 0 if NO.
|
||||
*/
|
||||
static int is_protected(void)
|
||||
{
|
||||
int state = get_state();
|
||||
int vboot_mode = host_get_vboot_mode();
|
||||
|
||||
if (vboot_mode == VBOOT_MODE_DEVELOPER)
|
||||
return 1;
|
||||
|
||||
if (state == EC_SB_FW_UPDATE_PROTECT) {
|
||||
CPRINTF("firmware update is protected.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return !i2c_access_enable;
|
||||
}
|
||||
|
||||
static int prepare_update(struct host_cmd_handler_args *args)
|
||||
{
|
||||
int rv = EC_RES_SUCCESS;
|
||||
args->response_size = 0;
|
||||
|
||||
if (is_protected()) {
|
||||
CPRINTF("smbus cmd:%x data:%04x protect error\n",
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD,
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD_PREPARE);
|
||||
return EC_RES_INVALID_COMMAND;
|
||||
}
|
||||
|
||||
set_state(EC_SB_FW_UPDATE_PREPARE);
|
||||
|
||||
CPRINTF("smbus cmd:%x data:%04x\n",
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD,
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD_PREPARE);
|
||||
|
||||
rv = smbus_write_word(I2C_PORT_BATTERY, BATTERY_ADDR,
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD,
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD_PREPARE);
|
||||
if (rv) {
|
||||
CPRINTF("smbus cmd:%x data:%04x access error\n",
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD,
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD_PREPARE);
|
||||
return EC_RES_ERROR;
|
||||
}
|
||||
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
|
||||
static int begin_update(struct host_cmd_handler_args *args)
|
||||
{
|
||||
int rv = EC_RES_SUCCESS;
|
||||
args->response_size = 0;
|
||||
|
||||
if (is_protected()) {
|
||||
CPRINTF("smbus cmd:%x data:%04x protect error\n",
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD,
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD_UPDATE);
|
||||
return EC_RES_INVALID_COMMAND;
|
||||
}
|
||||
|
||||
if (!i2c_access_enable)
|
||||
return EC_RES_ERROR;
|
||||
|
||||
set_state(EC_SB_FW_UPDATE_BEGIN);
|
||||
|
||||
rv = smbus_write_word(I2C_PORT_BATTERY, BATTERY_ADDR,
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD,
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD_UPDATE);
|
||||
if (rv) {
|
||||
CPRINTF("smbus cmd:%x data:%04x access error\n",
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD,
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD_UPDATE);
|
||||
return EC_RES_ERROR;
|
||||
}
|
||||
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
|
||||
static int end_update(struct host_cmd_handler_args *args)
|
||||
{
|
||||
int rv = EC_RES_SUCCESS;
|
||||
set_state(EC_SB_FW_UPDATE_END);
|
||||
|
||||
args->response_size = 0;
|
||||
if (!i2c_access_enable)
|
||||
return EC_RES_ERROR;
|
||||
|
||||
rv = smbus_write_word(I2C_PORT_BATTERY, BATTERY_ADDR,
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD,
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD_END);
|
||||
if (rv) {
|
||||
CPRINTF("smbus cmd:%x data:%x access error\n",
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD,
|
||||
SB_FW_UPDATE_CMD_WRITE_WORD_END);
|
||||
return EC_RES_ERROR;
|
||||
}
|
||||
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int get_info(struct host_cmd_handler_args *args)
|
||||
{
|
||||
int rv = EC_RES_SUCCESS;
|
||||
uint8_t len = SB_FW_UPDATE_CMD_INFO_SIZE;
|
||||
|
||||
struct ec_response_sb_fw_update *resp =
|
||||
(struct ec_response_sb_fw_update *)args->response;
|
||||
|
||||
CPRINTF("smbus cmd:%x read battery info\n",
|
||||
SB_FW_UPDATE_CMD_READ_INFO);
|
||||
|
||||
args->response_size = len;
|
||||
|
||||
if (!i2c_access_enable) {
|
||||
CPRINTF("smbus cmd:%x rd info - protect error\n",
|
||||
SB_FW_UPDATE_CMD_READ_INFO);
|
||||
return EC_RES_ERROR;
|
||||
}
|
||||
|
||||
rv = smbus_read_block(I2C_PORT_BATTERY, BATTERY_ADDR,
|
||||
SB_FW_UPDATE_CMD_READ_INFO, resp->info.data, &len);
|
||||
if (rv) {
|
||||
CPRINTF("smbus cmd:%x rd info - access error\n",
|
||||
SB_FW_UPDATE_CMD_READ_INFO);
|
||||
rv = EC_RES_ERROR;
|
||||
}
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
|
||||
static int get_status(struct host_cmd_handler_args *args)
|
||||
{
|
||||
int rv = EC_RES_SUCCESS;
|
||||
|
||||
struct ec_response_sb_fw_update *resp =
|
||||
(struct ec_response_sb_fw_update *)args->response;
|
||||
|
||||
uint16_t *p16 = (uint16_t *) resp->status.data;
|
||||
|
||||
struct sb_fw_update_status *sts =
|
||||
(struct sb_fw_update_status *) resp->status.data;
|
||||
|
||||
/* Enable smart battery i2c access */
|
||||
i2c_access_enable = 1;
|
||||
|
||||
args->response_size = SB_FW_UPDATE_CMD_STATUS_SIZE;
|
||||
|
||||
rv = smbus_read_word(I2C_PORT_BATTERY, BATTERY_ADDR,
|
||||
SB_FW_UPDATE_CMD_READ_STATUS, p16);
|
||||
|
||||
if (rv == EC_ERROR_BUSY) {
|
||||
*p16 = 0;
|
||||
sts->busy = 1;
|
||||
return EC_RES_SUCCESS;
|
||||
} else if (rv) {
|
||||
CPRINTF("i2c cmd:%x read status error:0x%X\n",
|
||||
SB_FW_UPDATE_CMD_READ_STATUS, rv);
|
||||
return EC_RES_ERROR;
|
||||
}
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
|
||||
static int set_protect(struct host_cmd_handler_args *args)
|
||||
{
|
||||
set_state(EC_SB_FW_UPDATE_PROTECT);
|
||||
i2c_access_enable = 0;
|
||||
CPRINTF("firmware enter protect state !\n");
|
||||
args->response_size = 0;
|
||||
return EC_RES_SUCCESS;
|
||||
}
|
||||
|
||||
static int write_block(struct host_cmd_handler_args *args)
|
||||
{
|
||||
int rv = EC_RES_SUCCESS;
|
||||
struct ec_params_sb_fw_update *param =
|
||||
(struct ec_params_sb_fw_update *)args->params;
|
||||
|
||||
args->response_size = 0;
|
||||
|
||||
if (is_protected()) {
|
||||
CPRINTF("smbus write block protect error\n");
|
||||
return EC_RES_INVALID_COMMAND;
|
||||
}
|
||||
|
||||
set_state(EC_SB_FW_UPDATE_WRITE);
|
||||
|
||||
rv = smbus_write_block(I2C_PORT_BATTERY, BATTERY_ADDR,
|
||||
SB_FW_UPDATE_CMD_WRITE_BLOCK, param->write.data,
|
||||
SB_FW_UPDATE_CMD_WRITE_BLOCK_SIZE);
|
||||
if (rv) {
|
||||
CPRINTF("smbus write block access error\n");
|
||||
return EC_RES_ERROR;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
typedef int (*sb_fw_update_func)(struct host_cmd_handler_args *args);
|
||||
|
||||
static int sb_fw_update(struct host_cmd_handler_args *args)
|
||||
{
|
||||
struct ec_sb_fw_update_header *hdr =
|
||||
(struct ec_sb_fw_update_header *)args->params;
|
||||
|
||||
sb_fw_update_func sb_fw_update_tbl[] = {
|
||||
prepare_update,
|
||||
get_info,
|
||||
begin_update,
|
||||
write_block,
|
||||
end_update,
|
||||
get_status,
|
||||
set_protect
|
||||
};
|
||||
|
||||
if (hdr->subcmd < EC_SB_FW_UPDATE_MAX)
|
||||
return sb_fw_update_tbl[hdr->subcmd](args);
|
||||
else
|
||||
return EC_RES_INVALID_PARAM;
|
||||
}
|
||||
|
||||
DECLARE_HOST_COMMAND(EC_CMD_SB_FW_UPDATE,
|
||||
sb_fw_update,
|
||||
EC_VER_MASK(0));
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
/* Copyright (c) 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.
|
||||
*
|
||||
* Smart battery Firmware Update driver.
|
||||
* Ref: Common Smart Battery System Interface Specification v8.0.
|
||||
*
|
||||
* cmd.0x35, Write Word
|
||||
* 0x1000: Prepare to Update
|
||||
* 0x2000: End of Update
|
||||
* 0xF000: Update Firmware
|
||||
*
|
||||
* cmd.0x35, Read Word
|
||||
* Firmware Update Status
|
||||
*
|
||||
* cmd.0x36 Write Block
|
||||
* Send 32 byte firmware image
|
||||
*
|
||||
* cmd.0x37 Read Word
|
||||
* Get Battery Information
|
||||
* sequence:=b1,b0,b3,b2,b5,b5,b7,b6
|
||||
*
|
||||
* Command Sequence for Battery FW Update
|
||||
*
|
||||
* 0. cmd.0x35.read
|
||||
* 1. cmd.0x37.read
|
||||
* 2. cmd.0x35.write.0x1000
|
||||
* 3. cmd.0x35.read.status (optional)
|
||||
* 4. cmd.0x35.write.0xF000
|
||||
* 5. cmd.0x35.read.status
|
||||
* if bit8-0, go to step 2
|
||||
* 6. cmd.0x36.write.32byte
|
||||
* 7. cmd.0x35.read.status
|
||||
* if FEC.b13=1, go to step 6
|
||||
* if fatal.b12=1, go to step 2
|
||||
* if b11,b10,b9,b2,b1,b0; go to step 1
|
||||
* if b5,b3; go to step 8
|
||||
* (repeat 6,7)
|
||||
* 8. cmd.0x36.write.0x2000
|
||||
* 9. cmd.0x35.read.status
|
||||
*/
|
||||
|
||||
#ifndef __CROS_EC_SB_FW_UPDATE_H
|
||||
#define __CROS_EC_SB_FW_UPDATE_H
|
||||
|
||||
#define SB_FW_UPDATE_CMD_WRITE_WORD 0x35
|
||||
#define SB_FW_UPDATE_CMD_WRITE_WORD_PREPARE 0x1000
|
||||
#define SB_FW_UPDATE_CMD_WRITE_WORD_END 0x2000
|
||||
#define SB_FW_UPDATE_CMD_WRITE_WORD_UPDATE 0xF000
|
||||
|
||||
#define SB_FW_UPDATE_CMD_READ_STATUS 0x35 /* len:0+data:2+pec:1 */
|
||||
|
||||
#define SB_FW_UPDATE_CMD_WRITE_BLOCK 0x36 /* len:1+data:32+pec:1 */
|
||||
|
||||
#define SB_FW_UPDATE_CMD_READ_INFO 0x37 /* len:1+data:8+pec:1 */
|
||||
|
||||
/**
|
||||
* sb.fw.update.cmd.0x35, Read Word
|
||||
* Firmware Update Status
|
||||
*/
|
||||
struct sb_fw_update_status {
|
||||
uint16_t v_fail_maker_id:1; /* b0 */
|
||||
uint16_t v_fail_hw_id:1; /* b1 */
|
||||
uint16_t v_fail_fw_version:1; /* b2 */
|
||||
uint16_t v_fail_permanent:1; /* b3 */
|
||||
|
||||
uint16_t rsvd5:1; /* b4 */
|
||||
uint16_t permanent_failure:1; /* b5 */
|
||||
uint16_t abnormal_condition:1; /* b6 */
|
||||
uint16_t fw_update_supported:1; /* b7 */
|
||||
|
||||
uint16_t fw_update_mode:1; /* b8 */
|
||||
uint16_t fw_corrupted:1; /* b9 */
|
||||
uint16_t cmd_reject:1; /* b10 */
|
||||
uint16_t invalid_data:1; /* b11 */
|
||||
|
||||
uint16_t fw_fatal_error:1; /* b12 */
|
||||
uint16_t fec_error:1; /* b13 */
|
||||
uint16_t busy:1; /* b14 */
|
||||
uint16_t rsvd15:1; /* b15 */
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* sb.fw.update.cmd.0x37 Read Word
|
||||
* Get Battery Information
|
||||
* sequence:=b1,b0,b3,b2,b5,b5,b7,b6
|
||||
*/
|
||||
struct sb_fw_update_info {
|
||||
uint16_t maker_id; /* b0, b1 */
|
||||
uint16_t hardware_id; /* b2, b3 */
|
||||
uint16_t fw_version; /* b4, b5 */
|
||||
uint16_t data_version;/* b6, b7 */
|
||||
} __packed;
|
||||
|
||||
/**
|
||||
* smart.battery.maker.id
|
||||
*/
|
||||
enum sb_maker_id {
|
||||
sb_maker_id_lgc = 0x0001, /* b0=0; b1=1 */
|
||||
sb_maker_id_panasonic = 0x0002,
|
||||
sb_maker_id_sanyo = 0x0003,
|
||||
sb_maker_id_sony = 0x0004,
|
||||
sb_maker_id_simplo = 0x0005,
|
||||
sb_maker_id_celxpert = 0x0006,
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if a Smart Battery Firmware Update is inprogress.
|
||||
*
|
||||
* @return 1 if YES, 0 if NO.
|
||||
*/
|
||||
int sb_fw_update_in_progress(void);
|
||||
|
||||
#endif
|
||||
@@ -108,9 +108,6 @@ driver-$(CONFIG_USB_MUX_VIRTUAL)+=usb_mux_virtual.o
|
||||
# Type-C Power Path Controllers (PPC)
|
||||
driver-$(CONFIG_USBC_PPC_SN5S330)+=ppc/sn5s330.o
|
||||
|
||||
# Firmware Update
|
||||
driver-$(CONFIG_SB_FIRMWARE_UPDATE)+=battery/sb_fw_update.o
|
||||
|
||||
# video converters
|
||||
driver-$(CONFIG_MCDP28X0)+=mcdp28x0.o
|
||||
|
||||
|
||||
@@ -2127,9 +2127,6 @@
|
||||
*/
|
||||
#undef CONFIG_SAVE_VBOOT_HASH
|
||||
|
||||
/* Enable smart battery firmware update driver */
|
||||
#undef CONFIG_SB_FIRMWARE_UPDATE
|
||||
|
||||
/* Allow the board to use a GPIO for the SCI# signal. */
|
||||
#undef CONFIG_SCI_GPIO
|
||||
|
||||
|
||||
Reference in New Issue
Block a user