summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxiong.huang <xiong.huang@bitland.corp-partner.google.com>2019-08-02 17:14:52 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-16 06:41:16 +0000
commit090c47f8f16588f5e216804f890e1f94009b6ddc (patch)
tree63d0df486a2ffb980b62a8ba755d6eb9a127670b
parent226a468ebcbc4f690d5f9c34f4912e8c046c17af (diff)
downloadchrome-ec-stabilize-12428.B.tar.gz
kodama: Support smart batterystabilize-12428.B
Provide SMP and Celxpert smart battery initial files. BUG=b:136977971, b:138826367 BRANCH=master TEST=boot ec, verify that ec console prints 'found batt:SMP' or 'found batt:Celxpert'. Cq-Depend:chromium:1730377 Change-Id: I607fc41c51e8b27acddefda4dcd2ea02a7597a0f Signed-off-by: Xiong Huang <xiong.huang@bitland.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1731211 Reviewed-by: Yilun Lin <yllin@chromium.org> Commit-Queue: Paul Ma <magf@bitland.corp-partner.google.com> Tested-by: Paul Ma <magf@bitland.corp-partner.google.com>
-rw-r--r--baseboard/kukui/charger_mt6370.c3
-rw-r--r--board/kodama/battery.c105
-rw-r--r--board/kodama/board.c1
-rw-r--r--board/kodama/board.h19
-rw-r--r--board/kodama/build.mk2
-rw-r--r--board/kodama/gpio.inc8
6 files changed, 121 insertions, 17 deletions
diff --git a/baseboard/kukui/charger_mt6370.c b/baseboard/kukui/charger_mt6370.c
index b64d29a009..4752afbce8 100644
--- a/baseboard/kukui/charger_mt6370.c
+++ b/baseboard/kukui/charger_mt6370.c
@@ -16,6 +16,7 @@
#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
+#ifndef CONFIG_BATTERY_SMART
int board_cut_off_battery(void)
{
/* The cut-off procedure is recommended by Richtek. b/116682788 */
@@ -25,6 +26,7 @@ int board_cut_off_battery(void)
return EC_SUCCESS;
}
+#endif
void mt6370_charger_profile_override(struct charge_state_data *curr)
{
@@ -79,4 +81,3 @@ static void board_charge_termination(void)
DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE,
board_charge_termination,
HOOK_PRIO_DEFAULT);
-
diff --git a/board/kodama/battery.c b/board/kodama/battery.c
new file mode 100644
index 0000000000..28086d317b
--- /dev/null
+++ b/board/kodama/battery.c
@@ -0,0 +1,105 @@
+/* Copyright 2019 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_fuel_gauge.h"
+#include "charge_state.h"
+#include "charger_mt6370.h"
+#include "console.h"
+#include "driver/charger/rt946x.h"
+#include "gpio.h"
+#include "power.h"
+#include "usb_pd.h"
+#include "util.h"
+
+#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ## args)
+
+#define BAT_LEVEL_PD_LIMIT 85
+
+const struct board_batt_params board_battery_info[] = {
+ [BATTERY_SIMPLO] = {
+ .fuel_gauge = {
+ .manuf_name = "SMP",
+ .device_name = "L19M3PG0",
+ .ship_mode = {
+ .reg_addr = 0x34,
+ .reg_data = { 0x0000, 0x1000 },
+ },
+ .fet = {
+ .reg_addr = 0x34,
+ .reg_mask = 0x0100,
+ .disconnect_val = 0x0100,
+ }
+ },
+ .batt_info = {
+ .voltage_max = 4400,
+ .voltage_normal = 3840,
+ .voltage_min = 3000,
+ .precharge_current = 256,
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 45,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = -20,
+ .discharging_max_c = 60,
+ },
+ },
+ [BATTERY_CELXPERT] = {
+ .fuel_gauge = {
+ .manuf_name = "Celxpert",
+ .device_name = "L19C3PG0",
+ .ship_mode = {
+ .reg_addr = 0x34,
+ .reg_data = { 0x0000, 0x1000 },
+ },
+ .fet = {
+ .reg_addr = 0x34,
+ .reg_mask = 0x0100,
+ .disconnect_val = 0x0100,
+ }
+ },
+ .batt_info = {
+ .voltage_max = 4400,
+ .voltage_normal = 3840,
+ .voltage_min = 3000,
+ .precharge_current = 256,
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 45,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = -20,
+ .discharging_max_c = 60,
+ },
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT);
+
+const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_SIMPLO;
+
+enum battery_present battery_hw_present(void)
+{
+ return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES;
+}
+
+int charger_profile_override(struct charge_state_data *curr)
+{
+#ifdef VARIANT_KUKUI_CHARGER_MT6370
+ mt6370_charger_profile_override(curr);
+#endif /* CONFIG_CHARGER_MT6370 */
+
+ return 0;
+}
+
+enum ec_status charger_profile_override_get_param(uint32_t param,
+ uint32_t *value)
+{
+ return EC_RES_INVALID_PARAM;
+}
+
+enum ec_status charger_profile_override_set_param(uint32_t param,
+ uint32_t value)
+{
+ return EC_RES_INVALID_PARAM;
+}
diff --git a/board/kodama/board.c b/board/kodama/board.c
index a4a45bdb77..4580970249 100644
--- a/board/kodama/board.c
+++ b/board/kodama/board.c
@@ -54,7 +54,6 @@ static void tcpc_alert_event(enum gpio_signal signal)
const struct adc_t adc_channels[] = {
[ADC_BOARD_ID] = {"BOARD_ID", 3300, 4096, 0, STM32_AIN(10)},
[ADC_EC_SKU_ID] = {"EC_SKU_ID", 3300, 4096, 0, STM32_AIN(8)},
- [ADC_BATT_ID] = {"BATT_ID", 3300, 4096, 0, STM32_AIN(7)},
[ADC_POGO_ADC_INT_L] = {"POGO_ADC_INT_L", 3300, 4096, 0, STM32_AIN(6)},
};
BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
diff --git a/board/kodama/board.h b/board/kodama/board.h
index 9903e3ec14..4e12a2b3f7 100644
--- a/board/kodama/board.h
+++ b/board/kodama/board.h
@@ -8,12 +8,7 @@
#ifndef __CROS_EC_BOARD_H
#define __CROS_EC_BOARD_H
-#ifdef BOARD_KRANE
-#define VARIANT_KUKUI_BATTERY_MM8013
-#else
-#define VARIANT_KUKUI_BATTERY_MAX17055
-#endif
-
+#define VARIANT_KUKUI_BATTERY_SMART
#define VARIANT_KUKUI_CHARGER_MT6370
#define VARIANT_KUKUI_DP_MUX_GPIO
@@ -26,6 +21,8 @@
#define CONFIG_LED_ONOFF_STATES
#define CONFIG_LED_POWER_LED
+#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
+
/* Battery */
#ifdef BOARD_KRANE
#define BATTERY_DESIRED_CHARGING_CURRENT 3500 /* mA */
@@ -57,9 +54,6 @@
#define I2C_PORT_VIRTUAL_BATTERY I2C_PORT_BATTERY
#define I2C_PORT_ACCEL 1
-/* Route sbs host requests to virtual battery driver */
-#define VIRTUAL_BATTERY_ADDR_FLAGS 0x0B
-
/* Define the host events which are allowed to wakeup AP in S3. */
#define CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK \
(EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN) |\
@@ -71,7 +65,6 @@ enum adc_channel {
/* Real ADC channels begin here */
ADC_BOARD_ID = 0,
ADC_EC_SKU_ID,
- ADC_BATT_ID,
ADC_POGO_ADC_INT_L,
ADC_CH_COUNT
};
@@ -97,6 +90,12 @@ enum charge_port {
CHARGE_PORT_USB_C,
};
+enum battery_type {
+ BATTERY_SIMPLO,
+ BATTERY_CELXPERT,
+ BATTERY_TYPE_COUNT,
+};
+
#include "gpio_signal.h"
#include "registers.h"
diff --git a/board/kodama/build.mk b/board/kodama/build.mk
index 9391e6933b..72d5a37433 100644
--- a/board/kodama/build.mk
+++ b/board/kodama/build.mk
@@ -12,4 +12,4 @@ CHIP_FAMILY:=stm32f0
CHIP_VARIANT:=stm32f09x
BASEBOARD:=kukui
-board-y=base_detect_kodama.o board.o led.o
+board-y=base_detect_kodama.o battery.o board.o led.o
diff --git a/board/kodama/gpio.inc b/board/kodama/gpio.inc
index c648d6b5a7..9345c3d27a 100644
--- a/board/kodama/gpio.inc
+++ b/board/kodama/gpio.inc
@@ -65,7 +65,6 @@ GPIO(I2C2_SCL, PIN(A, 11), GPIO_INPUT)
GPIO(I2C2_SDA, PIN(A, 12), GPIO_INPUT)
/* Analog pins */
-GPIO(BATT_ID, PIN(A, 7), GPIO_ANALOG)
GPIO(BOARD_ID, PIN(C, 0), GPIO_ANALOG)
GPIO(EC_SKU_ID, PIN(B, 0), GPIO_ANALOG)
@@ -73,6 +72,7 @@ GPIO(EC_SKU_ID, PIN(B, 0), GPIO_ANALOG)
GPIO(WP_L, PIN(C, 8), GPIO_INPUT) /* EC_FLASH_WP_ODL */
GPIO(BOOT0, PIN(F, 11), GPIO_INPUT)
GPIO(CCD_MODE_ODL, PIN(A, 5), GPIO_INPUT)
+GPIO(EC_BATT_PRES_ODL, PIN(A, 7), GPIO_INPUT)
/* Other output pins */
GPIO(ENTERING_RW, PIN(C, 6), GPIO_ODR_HIGH) /* EC_ENTERING_RW_ODL */
@@ -82,9 +82,9 @@ GPIO(USB_C0_DP_POLARITY, PIN(C, 14), GPIO_OUT_LOW)
GPIO(USB_C0_HPD_OD, PIN(F, 1), GPIO_ODR_LOW)
GPIO(BOOTBLOCK_EN_L, PIN(C, 1), GPIO_ODR_HIGH)
GPIO(USB_C0_DP_OE_L, PIN(A, 1), GPIO_OUT_HIGH)
-GPIO(EN_PP3300_POGO, PIN(A, 13), GPIO_OUT_LOW)
-GPIO(EN_POGO_CHARGE_L, PIN(B, 6), GPIO_OUT_HIGH)
-GPIO(BC12_DET_EN, PIN(C, 4), GPIO_OUT_LOW)
+GPIO(EN_PP3300_POGO, PIN(A, 13), GPIO_OUT_LOW)
+GPIO(EN_POGO_CHARGE_L, PIN(B, 6), GPIO_OUT_HIGH)
+GPIO(BC12_DET_EN, PIN(C, 4), GPIO_OUT_LOW)
UNIMPLEMENTED(EN_PP5000_USBC)
UNIMPLEMENTED(EN_USBC_CHARGE_L)