diff options
author | Edward Hill <ecgh@chromium.org> | 2020-04-28 13:38:26 -0600 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-04-29 01:41:26 +0000 |
commit | 2d5c4544f118037a7eb2cfcc42a9919fe756f445 (patch) | |
tree | b8abe320940da806c6b6b8ed2b024d9f6039595f /baseboard/zork | |
parent | df4ef3ce0cf24574a90a2e5be1b23bd11dbe3875 (diff) | |
download | chrome-ec-2d5c4544f118037a7eb2cfcc42a9919fe756f445.tar.gz |
Zork: Move charger I2C to match HW change
Split chg_chips[] into Trembyle and Dalboz variants.
Change I2C_PORT_CHARGER to I2C4_1 for Trembyle V1 HW.
Check for V0 HW on boot to re-map back to I2C2_0.
BUG=b:155156669
BRANCH=none
TEST=charger still works on V0 HW
Signed-off-by: Edward Hill <ecgh@chromium.org>
Change-Id: Ia90b9ed34551b2fea72b921bbdffe8e1a9249188
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2171044
Reviewed-by: Aaron Durbin <adurbin@google.com>
Reviewed-by: Martin Roth <martinroth@google.com>
Commit-Queue: Martin Roth <martinroth@google.com>
Diffstat (limited to 'baseboard/zork')
-rw-r--r-- | baseboard/zork/baseboard.c | 10 | ||||
-rw-r--r-- | baseboard/zork/baseboard.h | 5 | ||||
-rw-r--r-- | baseboard/zork/variant_dalboz.c | 15 | ||||
-rw-r--r-- | baseboard/zork/variant_trembyle.c | 46 |
4 files changed, 59 insertions, 17 deletions
diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c index 9816209f91..438dafc22d 100644 --- a/baseboard/zork/baseboard.c +++ b/baseboard/zork/baseboard.c @@ -18,7 +18,6 @@ #include "cros_board_info.h" #include "driver/accelgyro_bmi_common.h" #include "driver/bc12/pi3usb9201.h" -#include "driver/charger/isl9241.h" #include "driver/ppc/aoz1380.h" #include "driver/ppc/nx20p348x.h" #include "driver/tcpm/nct38xx.h" @@ -121,15 +120,6 @@ struct ppc_config_t ppc_chips[] = { BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == USBC_PORT_COUNT); unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); -const struct charger_config_t chg_chips[] = { - { - .i2c_port = I2C_PORT_CHARGER, - .i2c_addr_flags = ISL9241_ADDR_FLAGS, - .drv = &isl9241_drv, - }, -}; -const unsigned int chg_cnt = ARRAY_SIZE(chg_chips); - void ppc_interrupt(enum gpio_signal signal) { switch (signal) { diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h index 7a691ebe0a..789c7f8327 100644 --- a/baseboard/zork/baseboard.h +++ b/baseboard/zork/baseboard.h @@ -218,7 +218,6 @@ #define I2C_PORT_USBA0 NPCX_I2C_PORT0_0 #define I2C_PORT_TCPC1 NPCX_I2C_PORT1_0 #define I2C_PORT_USBA1 NPCX_I2C_PORT1_0 -#define I2C_PORT_CHARGER NPCX_I2C_PORT2_0 #define I2C_PORT_USB_AP_MUX NPCX_I2C_PORT3_0 #define I2C_PORT_THERMAL_AP NPCX_I2C_PORT4_1 #define I2C_PORT_SENSOR NPCX_I2C_PORT5_0 @@ -227,11 +226,15 @@ #define I2C_PORT_AP_AUDIO NPCX_I2C_PORT6_1 #if defined(VARIANT_ZORK_TREMBYLE) + #define CONFIG_CHARGER_RUNTIME_CONFIG #define I2C_PORT_BATTERY NPCX_I2C_PORT2_0 + #define I2C_PORT_CHARGER_V0 NPCX_I2C_PORT2_0 + #define I2C_PORT_CHARGER_V1 NPCX_I2C_PORT4_1 #define I2C_PORT_AP_HDMI NPCX_I2C_PORT7_0 #elif defined(VARIANT_ZORK_DALBOZ) #define I2C_PORT_BATTERY_V0 NPCX_I2C_PORT2_0 #define I2C_PORT_BATTERY_V1 NPCX_I2C_PORT7_0 + #define I2C_PORT_CHARGER NPCX_I2C_PORT2_0 #endif #define I2C_ADDR_EEPROM_FLAGS 0x50 diff --git a/baseboard/zork/variant_dalboz.c b/baseboard/zork/variant_dalboz.c index 40ec020e55..de662d69cf 100644 --- a/baseboard/zork/variant_dalboz.c +++ b/baseboard/zork/variant_dalboz.c @@ -3,8 +3,10 @@ * found in the LICENSE file. */ +#include "charger.h" #include "common.h" #include "console.h" +#include "driver/charger/isl9241.h" #include "driver/ioexpander/pcal6408.h" #include "driver/tcpm/nct38xx.h" #include "driver/usb_mux/amd_fp5.h" @@ -76,6 +78,19 @@ const struct i2c_port_t i2c_ports[] = { const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /***************************************************************************** + * Charger + */ + +const struct charger_config_t chg_chips[] = { + { + .i2c_port = I2C_PORT_CHARGER, + .i2c_addr_flags = ISL9241_ADDR_FLAGS, + .drv = &isl9241_drv, + }, +}; +const unsigned int chg_cnt = ARRAY_SIZE(chg_chips); + +/***************************************************************************** * IO expander */ diff --git a/baseboard/zork/variant_trembyle.c b/baseboard/zork/variant_trembyle.c index 231d8d8338..eb26ac4199 100644 --- a/baseboard/zork/variant_trembyle.c +++ b/baseboard/zork/variant_trembyle.c @@ -3,9 +3,11 @@ * found in the LICENSE file. */ +#include "charger.h" #include "chipset.h" #include "common.h" #include "console.h" +#include "driver/charger/isl9241.h" #include "driver/retimer/ps8802.h" #include "driver/retimer/ps8818.h" #include "driver/retimer/tusb544.h" @@ -39,11 +41,11 @@ const struct i2c_port_t i2c_ports[] = { .sda = GPIO_EC_I2C_USB_A1_C1_SDA, }, { - .name = "power", + .name = "battery", .port = I2C_PORT_BATTERY, .kbps = 100, - .scl = GPIO_EC_I2C_POWER_SCL, - .sda = GPIO_EC_I2C_POWER_SDA, + .scl = GPIO_EC_I2C_BATT_SCL, + .sda = GPIO_EC_I2C_BATT_SDA, }, { .name = "ap_mux", @@ -53,11 +55,11 @@ const struct i2c_port_t i2c_ports[] = { .sda = GPIO_EC_I2C_USBC_AP_MUX_SDA, }, { - .name = "thermal", + .name = "therm_chg", .port = I2C_PORT_THERMAL_AP, .kbps = 400, - .scl = GPIO_FCH_SIC, - .sda = GPIO_FCH_SID, + .scl = GPIO_FCH_SIC_POWER_SCL, + .sda = GPIO_FCH_SID_POWER_SDA, }, { .name = "sensor", @@ -84,6 +86,38 @@ const struct i2c_port_t i2c_ports[] = { const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); /***************************************************************************** + * Charger + */ + +struct charger_config_t chg_chips[] = { + { + .i2c_port = I2C_PORT_CHARGER_V1, + .i2c_addr_flags = ISL9241_ADDR_FLAGS, + .drv = &isl9241_drv, + }, +}; +const unsigned int chg_cnt = ARRAY_SIZE(chg_chips); + +/* + * If the charger is found on the V0 I2C port then re-map the port. + * Use HOOK_PRIO_INIT_I2C so we re-map before charger_chips_init() + * talks to the charger. This relies on the V1 HW not using the ISL9241 address + * on the V0 I2C port. + * TODO(b/155214765): Remove this check once V0 HW is no longer used. + */ +static void check_v0_charger(void) +{ + int id; + + if (i2c_read16(I2C_PORT_CHARGER_V0, ISL9241_ADDR_FLAGS, + ISL9241_REG_MANUFACTURER_ID, &id) == EC_SUCCESS) { + ccprints("V0 charger HW detected"); + chg_chips[0].i2c_port = I2C_PORT_CHARGER_V0; + } +} +DECLARE_HOOK(HOOK_INIT, check_v0_charger, HOOK_PRIO_INIT_I2C); + +/***************************************************************************** * TCPC */ |