From e25c81318a06506c79423900b9592a7caa36cfed Mon Sep 17 00:00:00 2001 From: Ting Shen Date: Wed, 23 Oct 2019 20:02:29 +0800 Subject: kodama/jacuzzi: enable i2c bitbang - Enable bitbang driver - increase the console/hook stack size because accessing bitbang i2c bus requires more stack memory than before BUG=b:138161741,b:138415463 TEST=see CL:1765110 BRANCH=kukui Change-Id: I54aa0b5c37cd3fde497b552ea553e5542e594546 Signed-off-by: Ting Shen Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1876290 Reviewed-by: Alexandru M Stan Commit-Queue: Ting Shen Tested-by: Ting Shen --- board/jacuzzi/board.c | 15 +++++++++++++++ board/jacuzzi/board.h | 15 +++++++++++++-- board/jacuzzi/ec.tasklist | 2 +- board/jacuzzi/gpio.inc | 2 ++ 4 files changed, 31 insertions(+), 3 deletions(-) (limited to 'board/jacuzzi') diff --git a/board/jacuzzi/board.c b/board/jacuzzi/board.c index ec03ec7c5f..0238a19d9d 100644 --- a/board/jacuzzi/board.c +++ b/board/jacuzzi/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" @@ -68,10 +69,19 @@ BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT); /* I2C ports */ const struct i2c_port_t i2c_ports[] = { {"typec", 0, 400, GPIO_I2C1_SCL, GPIO_I2C1_SDA}, +#ifdef BOARD_JACUZZI {"other", 1, 100, GPIO_I2C2_SCL, GPIO_I2C2_SDA}, +#else /* Juniper */ + {"other", 1, 400, GPIO_I2C2_SCL, GPIO_I2C2_SDA}, +#endif }; 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. */ @@ -285,3 +295,8 @@ int board_get_charger_i2c(void) /* TODO(b:138415463): confirm the bus allocation for future builds */ return board_get_version() == 1 ? 2 : 1; } + +int board_get_battery_i2c(void) +{ + return board_get_version() >= 1 ? 2 : 1; +} diff --git a/board/jacuzzi/board.h b/board/jacuzzi/board.h index e9bf5b8a79..b2abf7bcb2 100644 --- a/board/jacuzzi/board.h +++ b/board/jacuzzi/board.h @@ -35,6 +35,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 @@ -65,10 +71,14 @@ #define I2C_PORT_BC12 0 #define I2C_PORT_TCPC0 0 #define I2C_PORT_USB_MUX 0 -#define I2C_PORT_BATTERY 1 #define I2C_PORT_CHARGER board_get_charger_i2c() #define I2C_PORT_IO_EXPANDER_IT8801 1 #define I2C_PORT_VIRTUAL_BATTERY I2C_PORT_BATTERY +#ifdef BOARD_JACUZZI +#define I2C_PORT_BATTERY 1 +#else /* Juniper */ +#define I2C_PORT_BATTERY 2 +#endif /* Enable Accel over SPI */ #define CONFIG_SPI_ACCEL_PORT 0 /* The first SPI master port (SPI2) */ @@ -143,8 +153,9 @@ void board_reset_pd_mcu(void); int board_get_version(void); int board_is_sourcing_vbus(int port); -/* returns the i2c port number of charger */ +/* returns the i2c port number of charger/battery */ int board_get_charger_i2c(void); +int board_get_battery_i2c(void); #endif /* !__ASSEMBLER__ */ diff --git a/board/jacuzzi/ec.tasklist b/board/jacuzzi/ec.tasklist index 283af8595a..a1e20808cc 100644 --- a/board/jacuzzi/ec.tasklist +++ b/board/jacuzzi/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/jacuzzi/gpio.inc b/board/jacuzzi/gpio.inc index fed96eda51..bb54bceab5 100644 --- a/board/jacuzzi/gpio.inc +++ b/board/jacuzzi/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) -- cgit v1.2.1