diff options
-rw-r--r-- | baseboard/zork/baseboard.c | 60 | ||||
-rw-r--r-- | baseboard/zork/baseboard.h | 12 | ||||
-rw-r--r-- | baseboard/zork/variant_dalboz.c | 60 | ||||
-rw-r--r-- | baseboard/zork/variant_trembyle.c | 60 | ||||
-rw-r--r-- | board/dalboz/board.c | 23 | ||||
-rw-r--r-- | board/dalboz/board.h | 3 | ||||
-rw-r--r-- | board/dalboz/gpio.inc | 8 |
7 files changed, 157 insertions, 69 deletions
diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c index bdcb25cb76..ba7b55ed19 100644 --- a/baseboard/zork/baseboard.c +++ b/baseboard/zork/baseboard.c @@ -105,66 +105,6 @@ const struct power_signal_info power_signal_list[] = { }; BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT); -const struct i2c_port_t i2c_ports[] = { - { - .name = "tcpc0", - .port = I2C_PORT_TCPC0, - .kbps = 400, - .scl = GPIO_EC_I2C_USB_A0_C0_SCL, - .sda = GPIO_EC_I2C_USB_A0_C0_SDA, - }, - { - .name = "tcpc1", - .port = I2C_PORT_TCPC1, - .kbps = 400, - .scl = GPIO_EC_I2C_USB_A1_C1_SCL, - .sda = GPIO_EC_I2C_USB_A1_C1_SDA, - }, - { - .name = "power", - .port = I2C_PORT_BATTERY, - .kbps = 100, - .scl = GPIO_EC_I2C_POWER_SCL, - .sda = GPIO_EC_I2C_POWER_SDA, - }, - { - .name = "ap_mux", - .port = I2C_PORT_USB_AP_MUX, - .kbps = 400, - .scl = GPIO_EC_I2C_USBC_AP_MUX_SCL, - .sda = GPIO_EC_I2C_USBC_AP_MUX_SDA, - }, - { - .name = "thermal", - .port = I2C_PORT_THERMAL, - .kbps = 400, - .scl = GPIO_FCH_SIC, - .sda = GPIO_FCH_SID, - }, - { - .name = "sensor", - .port = I2C_PORT_SENSOR, - .kbps = 400, - .scl = GPIO_EC_I2C_SENSOR_CBI_SCL, - .sda = GPIO_EC_I2C_SENSOR_CBI_SDA, - }, - { - .name = "ap_audio", - .port = I2C_PORT_AP_AUDIO, - .kbps = 400, - .scl = GPIO_FCH_I2C_AUDIO_SCL, - .sda = GPIO_FCH_I2C_AUDIO_SDA, - }, - { - .name = "ap_hdmi", - .port = I2C_PORT_AP_HDMI, - .kbps = 400, - .scl = GPIO_FCH_I2C_HDMI_HUB_3V3_SCL, - .sda = GPIO_FCH_I2C_HDMI_HUB_3V3_SDA, - }, -}; -const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); - struct ppc_config_t ppc_chips[] = { [USBC_PORT_C0] = { /* Device does not talk I2C */ diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h index 4780a70f97..e8bf12fdf4 100644 --- a/baseboard/zork/baseboard.h +++ b/baseboard/zork/baseboard.h @@ -218,15 +218,21 @@ #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_BATTERY NPCX_I2C_PORT2_0 -#define I2C_PORT_CHARGER I2C_PORT_BATTERY +#define I2C_PORT_CHARGER NPCX_I2C_PORT2_0 #define I2C_PORT_USB_AP_MUX NPCX_I2C_PORT3_0 #define I2C_PORT_THERMAL NPCX_I2C_PORT4_1 #define I2C_PORT_SENSOR NPCX_I2C_PORT5_0 #define I2C_PORT_ACCEL I2C_PORT_SENSOR #define I2C_PORT_EEPROM I2C_PORT_SENSOR #define I2C_PORT_AP_AUDIO NPCX_I2C_PORT6_1 -#define I2C_PORT_AP_HDMI NPCX_I2C_PORT7_0 + +#if defined(VARIANT_ZORK_TREMBYLE) + #define I2C_PORT_BATTERY NPCX_I2C_PORT2_0 + #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 +#endif #define I2C_ADDR_EEPROM_FLAGS 0x50 #define PS8743_I2C_ADDR_FLAGS 0x11 diff --git a/baseboard/zork/variant_dalboz.c b/baseboard/zork/variant_dalboz.c index 01a30ab19c..41307d6da4 100644 --- a/baseboard/zork/variant_dalboz.c +++ b/baseboard/zork/variant_dalboz.c @@ -14,6 +14,66 @@ #include "ioexpander.h" #include "usb_mux.h" +const struct i2c_port_t i2c_ports[] = { + { + .name = "tcpc0", + .port = I2C_PORT_TCPC0, + .kbps = 400, + .scl = GPIO_EC_I2C_USB_A0_C0_SCL, + .sda = GPIO_EC_I2C_USB_A0_C0_SDA, + }, + { + .name = "tcpc1", + .port = I2C_PORT_TCPC1, + .kbps = 400, + .scl = GPIO_EC_I2C_USB_A1_C1_SCL, + .sda = GPIO_EC_I2C_USB_A1_C1_SDA, + }, + { + .name = "charger", + .port = I2C_PORT_CHARGER, + .kbps = 100, + .scl = GPIO_EC_I2C_POWER_SCL, + .sda = GPIO_EC_I2C_POWER_SDA, + }, + { + .name = "ap_mux", + .port = I2C_PORT_USB_AP_MUX, + .kbps = 400, + .scl = GPIO_EC_I2C_USBC_AP_MUX_SCL, + .sda = GPIO_EC_I2C_USBC_AP_MUX_SDA, + }, + { + .name = "thermal", + .port = I2C_PORT_THERMAL, + .kbps = 400, + .scl = GPIO_FCH_SIC, + .sda = GPIO_FCH_SID, + }, + { + .name = "sensor", + .port = I2C_PORT_SENSOR, + .kbps = 400, + .scl = GPIO_EC_I2C_SENSOR_CBI_SCL, + .sda = GPIO_EC_I2C_SENSOR_CBI_SDA, + }, + { + .name = "ap_audio", + .port = I2C_PORT_AP_AUDIO, + .kbps = 400, + .scl = GPIO_I2C_AUDIO_USB_HUB_SCL, + .sda = GPIO_I2C_AUDIO_USB_HUB_SDA, + }, + { + .name = "battery", + .port = I2C_PORT_BATTERY_V1, + .kbps = 100, + .scl = GPIO_EC_I2C_BATT_SCL, + .sda = GPIO_EC_I2C_BATT_SDA, + }, +}; +const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); + /***************************************************************************** * IO expander */ diff --git a/baseboard/zork/variant_trembyle.c b/baseboard/zork/variant_trembyle.c index 75dce91948..c58b9bbeee 100644 --- a/baseboard/zork/variant_trembyle.c +++ b/baseboard/zork/variant_trembyle.c @@ -24,6 +24,66 @@ #define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ## args) #define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ## args) +const struct i2c_port_t i2c_ports[] = { + { + .name = "tcpc0", + .port = I2C_PORT_TCPC0, + .kbps = 400, + .scl = GPIO_EC_I2C_USB_A0_C0_SCL, + .sda = GPIO_EC_I2C_USB_A0_C0_SDA, + }, + { + .name = "tcpc1", + .port = I2C_PORT_TCPC1, + .kbps = 400, + .scl = GPIO_EC_I2C_USB_A1_C1_SCL, + .sda = GPIO_EC_I2C_USB_A1_C1_SDA, + }, + { + .name = "power", + .port = I2C_PORT_BATTERY, + .kbps = 100, + .scl = GPIO_EC_I2C_POWER_SCL, + .sda = GPIO_EC_I2C_POWER_SDA, + }, + { + .name = "ap_mux", + .port = I2C_PORT_USB_AP_MUX, + .kbps = 400, + .scl = GPIO_EC_I2C_USBC_AP_MUX_SCL, + .sda = GPIO_EC_I2C_USBC_AP_MUX_SDA, + }, + { + .name = "thermal", + .port = I2C_PORT_THERMAL, + .kbps = 400, + .scl = GPIO_FCH_SIC, + .sda = GPIO_FCH_SID, + }, + { + .name = "sensor", + .port = I2C_PORT_SENSOR, + .kbps = 400, + .scl = GPIO_EC_I2C_SENSOR_CBI_SCL, + .sda = GPIO_EC_I2C_SENSOR_CBI_SDA, + }, + { + .name = "ap_audio", + .port = I2C_PORT_AP_AUDIO, + .kbps = 400, + .scl = GPIO_FCH_I2C_AUDIO_SCL, + .sda = GPIO_FCH_I2C_AUDIO_SDA, + }, + { + .name = "ap_hdmi", + .port = I2C_PORT_AP_HDMI, + .kbps = 400, + .scl = GPIO_FCH_I2C_HDMI_HUB_3V3_SCL, + .sda = GPIO_FCH_I2C_HDMI_HUB_3V3_SDA, + }, +}; +const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); + /***************************************************************************** * TCPC */ diff --git a/board/dalboz/board.c b/board/dalboz/board.c index d44f5ea6f7..52dff12e83 100644 --- a/board/dalboz/board.c +++ b/board/dalboz/board.c @@ -3,8 +3,7 @@ * found in the LICENSE file. */ -/* Trembyle board configuration */ - +#include "battery_smart.h" #include "button.h" #include "driver/accel_lis2dw12.h" #include "driver/accelgyro_lsm6dsm.h" @@ -25,6 +24,9 @@ #include "task.h" #include "usb_charge.h" +/* This I2C moved. Temporarily detect and support the V0 HW. */ +int I2C_PORT_BATTERY = I2C_PORT_BATTERY_V1; + /* Interrupt handler varies with DB option. */ void (*c1_tcpc_config_interrupt)(enum gpio_signal signal) = tcpc_alert_event; @@ -207,3 +209,20 @@ const struct pwm_t pwm_channels[] = { }, }; BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT); + +/* + * If the battery is found on the V0 I2C port then re-map the battery port. + * Use HOOK_PRIO_INIT_I2C so we re-map before init_battery_type() and + * charger_chips_init() want to talk to the battery. + */ +static void check_v0_battery(void) +{ + int status; + + if (i2c_read16(I2C_PORT_BATTERY_V0, BATTERY_ADDR_FLAGS, + SB_BATTERY_STATUS, &status) == EC_SUCCESS) { + ccprints("V0 HW detected"); + I2C_PORT_BATTERY = I2C_PORT_BATTERY_V0; + } +} +DECLARE_HOOK(HOOK_INIT, check_v0_battery, HOOK_PRIO_INIT_I2C); diff --git a/board/dalboz/board.h b/board/dalboz/board.h index 2a9db57ccc..f1bca86904 100644 --- a/board/dalboz/board.h +++ b/board/dalboz/board.h @@ -66,6 +66,9 @@ #ifndef __ASSEMBLER__ +/* This I2C moved. Temporarily detect and support the V0 HW. */ +extern int I2C_PORT_BATTERY; + enum battery_type { BATTERY_SMP, BATTERY_LGC, diff --git a/board/dalboz/gpio.inc b/board/dalboz/gpio.inc index f55565866e..a6b539ee41 100644 --- a/board/dalboz/gpio.inc +++ b/board/dalboz/gpio.inc @@ -103,10 +103,10 @@ GPIO(FCH_SIC, PIN(F, 3), GPIO_INPUT) GPIO(FCH_SID, PIN(F, 2), GPIO_INPUT) GPIO(EC_I2C_SENSOR_CBI_SCL, PIN(3, 3), GPIO_INPUT) GPIO(EC_I2C_SENSOR_CBI_SDA, PIN(3, 6), GPIO_INPUT) -GPIO(FCH_I2C_AUDIO_SCL, PIN(E, 4), GPIO_INPUT | GPIO_SEL_1P8V) -GPIO(FCH_I2C_AUDIO_SDA, PIN(E, 3), GPIO_INPUT | GPIO_SEL_1P8V) -GPIO(FCH_I2C_HDMI_HUB_3V3_SCL, PIN(B, 3), GPIO_INPUT) -GPIO(FCH_I2C_HDMI_HUB_3V3_SDA, PIN(B, 2), GPIO_INPUT) +GPIO(I2C_AUDIO_USB_HUB_SCL, PIN(E, 4), GPIO_INPUT | GPIO_SEL_1P8V) +GPIO(I2C_AUDIO_USB_HUB_SDA, PIN(E, 3), GPIO_INPUT | GPIO_SEL_1P8V) +GPIO(EC_I2C_BATT_SCL, PIN(B, 3), GPIO_INPUT) +GPIO(EC_I2C_BATT_SDA, PIN(B, 2), GPIO_INPUT) ALTERNATE(PIN_MASK(6, BIT(4) | BIT(5)), 0, MODULE_UART, 0) /* Cr50 requires no pullups. */ |