summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin Lu <devin.lu@quantatw.com>2019-12-25 15:18:24 +0800
committerCommit Bot <commit-bot@chromium.org>2020-01-10 07:17:45 +0000
commit12f506e782a08330a0a023055cebb0d15ede2dff (patch)
tree82126f5ed98d42ccb2e9a2b22a76697c2c191458
parentb5888e92487d846227ec048ea625ab0d099ff4fb (diff)
downloadchrome-ec-12f506e782a08330a0a023055cebb0d15ede2dff.tar.gz
kappa: enable i2c bitbang
Clone from CL:1876290 BUG=b:146504215 BRANCH=kukui TEST=use console command "battery" to read battery information. 2019-12-25 15:16:15 Status: 0x00c0 DCHG INIT 2019-12-25 15:16:15 Param flags:00000003 2019-12-25 15:16:15 Temp: 0x0b9f = 297.5 K (24.4 C) 2019-12-25 15:16:15 V: 0x20c9 = 8393 mV 2019-12-25 15:16:15 V-desired: 0x21fc = 8700 mV 2019-12-25 15:16:15 I: 0xfffd = -3 mA(DISCHG) 2019-12-25 15:16:15 I-desired: 0x09b0 = 2480 mA 2019-12-25 15:16:15 Charging: Allowed 2019-12-25 15:16:15 Charge: 91 % 2019-12-25 15:16:15 Manuf: 333-24-1C-A 2019-12-25 15:16:15 Device: FO02037XL 2019-12-25 15:16:15 Chem: LION 2019-12-25 15:16:15 Serial: 0x0001 2019-12-25 15:16:15 V-design: 0x1db0 = 7600 mV 2019-12-25 15:16:15 Mode: 0x6001 2019-12-25 15:16:15 Abs charge:88 % 2019-12-25 15:16:15 Remaining: 4323 mAh 2019-12-25 15:16:15 Cap-full: 4787 mAh (4691 mAh with 98 % compensation) 2019-12-25 15:16:15 Display: 0.0 % 2019-12-25 15:16:15 Design: 4960 mAh 2019-12-25 15:16:15 Time-full: 0h:0 2019-12-25 15:16:15 Empty: 0h:0 Change-Id: I5ae254ce8e9abccfda6ba9f07251ca7e2fe19ff4 Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1980405 Reviewed-by: Ting Shen <phoenixshen@chromium.org>
-rw-r--r--board/kappa/board.c6
-rw-r--r--board/kappa/board.h8
-rw-r--r--board/kappa/ec.tasklist2
-rw-r--r--board/kappa/gpio.inc2
4 files changed, 16 insertions, 2 deletions
diff --git a/board/kappa/board.c b/board/kappa/board.c
index 1b13fb18ee..6460579664 100644
--- a/board/kappa/board.c
+++ b/board/kappa/board.c
@@ -27,6 +27,7 @@
#include "hooks.h"
#include "host_command.h"
#include "i2c.h"
+#include "i2c_bitbang.h"
#include "it8801.h"
#include "keyboard_scan.h"
#include "lid_switch.h"
@@ -72,6 +73,11 @@ const struct i2c_port_t i2c_ports[] = {
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
+const struct i2c_port_t i2c_bitbang_ports[] = {
+ {"battery", 2, 100, GPIO_I2C3_SCL, GPIO_I2C3_SDA, .drv = &bitbang_drv},
+};
+const unsigned int i2c_bitbang_ports_used = ARRAY_SIZE(i2c_bitbang_ports);
+
#define BC12_I2C_ADDR PI3USB9201_I2C_ADDR_3
/* power signal list. Must match order of enum power_signal. */
diff --git a/board/kappa/board.h b/board/kappa/board.h
index 074264eb08..7d8e706dae 100644
--- a/board/kappa/board.h
+++ b/board/kappa/board.h
@@ -33,6 +33,12 @@
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
#define CONFIG_EXTPOWER_DEBOUNCE_MS 200
+#define CONFIG_I2C_BITBANG
+#define I2C_BITBANG_PORT_COUNT 1
+#undef CONFIG_I2C_NACK_RETRY_COUNT
+#define CONFIG_I2C_NACK_RETRY_COUNT 3
+#define CONFIG_SMBUS_PEC
+
#define CONFIG_USB_PD_TCPM_FUSB302
#define CONFIG_USB_PD_DISCHARGE_GPIO
#define CONFIG_USB_PD_TCPC_LOW_POWER
@@ -63,7 +69,7 @@
#define I2C_PORT_BC12 0
#define I2C_PORT_TCPC0 0
#define I2C_PORT_USB_MUX 0
-#define I2C_PORT_BATTERY 1
+#define I2C_PORT_BATTERY 2
#define I2C_PORT_CHARGER 1
#define I2C_PORT_IO_EXPANDER_IT8801 1
#define I2C_PORT_VIRTUAL_BATTERY I2C_PORT_BATTERY
diff --git a/board/kappa/ec.tasklist b/board/kappa/ec.tasklist
index 283af8595a..a1e20808cc 100644
--- a/board/kappa/ec.tasklist
+++ b/board/kappa/ec.tasklist
@@ -14,7 +14,7 @@
TASK_ALWAYS_RW(MOTIONSENSE, motion_sense_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_NOTEST(PDCMD, pd_command_task, NULL, 1024) \
TASK_ALWAYS(HOSTCMD, host_command_task, NULL, 1024) \
- TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(PD_C0, pd_task, NULL, 1280) \
TASK_ALWAYS(PD_INT_C0, pd_interrupt_handler_task, 0, 1024) \
diff --git a/board/kappa/gpio.inc b/board/kappa/gpio.inc
index 0f40c9cf19..6e80ff7290 100644
--- a/board/kappa/gpio.inc
+++ b/board/kappa/gpio.inc
@@ -53,6 +53,8 @@ GPIO(I2C1_SCL, PIN(B, 8), GPIO_INPUT)
GPIO(I2C1_SDA, PIN(B, 9), GPIO_INPUT)
GPIO(I2C2_SCL, PIN(A, 11), GPIO_INPUT)
GPIO(I2C2_SDA, PIN(A, 12), GPIO_INPUT)
+GPIO(I2C3_SCL, PIN(A, 5), GPIO_ODR_HIGH)
+GPIO(I2C3_SDA, PIN(C, 4), GPIO_ODR_HIGH)
/* Analog pins */
GPIO(BOARD_ID, PIN(C, 0), GPIO_ANALOG)