summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hill <ecgh@chromium.org>2019-07-30 11:14:35 -0600
committerCommit Bot <commit-bot@chromium.org>2019-07-31 22:11:00 +0000
commitfec7f289d57a4382fa508a8f66615d7f9767e99b (patch)
treef5344a04ebb466cd42219d16c33d0a2bdf2f1d35
parenta7f759a384ca2e1ff0daf559949a40d45aa76863 (diff)
downloadchrome-ec-fec7f289d57a4382fa508a8f66615d7f9767e99b.tar.gz
Trembyle: Add IO expanders
Add NCT3807 IO expander drivers and GPIO definitions. BUG=b:138599199 BRANCH=none TEST=make BOARD=trembyle Change-Id: I1257263225b4146a4a87d350921189b90a2b3901 Signed-off-by: Edward Hill <ecgh@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1726941 Reviewed-by: Keith Short <keithshort@chromium.org> Reviewed-by: Denis Brockus <dbrockus@chromium.org>
-rw-r--r--baseboard/zork/baseboard.c40
-rw-r--r--baseboard/zork/baseboard.h10
-rw-r--r--board/trembyle/gpio.inc11
3 files changed, 47 insertions, 14 deletions
diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c
index ecb5fde5df..fcf68a9778 100644
--- a/baseboard/zork/baseboard.c
+++ b/baseboard/zork/baseboard.c
@@ -25,6 +25,8 @@
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
+#include "ioexpander.h"
+#include "ioexpander_nct38xx.h"
#include "i2c.h"
#include "keyboard_scan.h"
#include "lid_switch.h"
@@ -165,11 +167,8 @@ const struct pwm_t pwm_channels[] = {
};
BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
-#define USB_PD_PORT_TCPC_0 0
-#define USB_PD_PORT_TCPC_1 1
-
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
- [USB_PD_PORT_TCPC_0] = {
+ [USBC_PORT_C0] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC0,
@@ -177,7 +176,7 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
},
.drv = &ps8xxx_tcpm_drv,
},
- [USB_PD_PORT_TCPC_1] = {
+ [USBC_PORT_C1] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_TCPC1,
@@ -186,18 +185,20 @@ const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_COUNT] = {
.drv = &ps8xxx_tcpm_drv,
},
};
+BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT);
const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = {
- [USB_PD_PORT_TCPC_0] = {
+ [USBC_PORT_C0] = {
.i2c_port = I2C_PORT_TCPC0,
.i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
},
- [USB_PD_PORT_TCPC_1] = {
+ [USBC_PORT_C1] = {
.i2c_port = I2C_PORT_TCPC1,
.i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
},
};
+BUILD_ASSERT(ARRAY_SIZE(pi3usb9201_bc12_chips) == USBC_PORT_COUNT);
void bc12_interrupt(enum gpio_signal signal)
{
@@ -216,21 +217,38 @@ void bc12_interrupt(enum gpio_signal signal)
}
struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_COUNT] = {
- [USB_PD_PORT_TCPC_0] = {
+ [USBC_PORT_C0] = {
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
- [USB_PD_PORT_TCPC_1] = {
+ [USBC_PORT_C1] = {
.driver = &tcpci_tcpm_usb_mux_driver,
.hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
};
+BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
+
+struct ioexpander_config_t ioex_config[CONFIG_IO_EXPANDER_PORT_COUNT] = {
+ [USBC_PORT_C0] = {
+ .i2c_host_port = I2C_PORT_TCPC0,
+ .i2c_slave_addr = NCT38xx_I2C_ADDR1_1_FLAGS,
+ .chip_info = -1,
+ .drv = &nct38xx_ioexpander_drv,
+ },
+ [USBC_PORT_C1] = {
+ .i2c_host_port = I2C_PORT_TCPC1,
+ .i2c_slave_addr = NCT38xx_I2C_ADDR1_1_FLAGS,
+ .chip_info = -1,
+ .drv = &nct38xx_ioexpander_drv,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(ioex_config) == USBC_PORT_COUNT);
static void baseboard_chipset_suspend(void)
{
/* Disable display and keyboard backlights. */
gpio_set_level(GPIO_ENABLE_BACKLIGHT_L, 1);
- /* TODO gpio_set_level(GPIO_KB_BL_EN, 0); */
+ ioex_set_level(IOEX_KB_BL_EN, 0);
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, baseboard_chipset_suspend,
HOOK_PRIO_DEFAULT);
@@ -239,7 +257,7 @@ static void baseboard_chipset_resume(void)
{
/* Enable display and keyboard backlights. */
gpio_set_level(GPIO_ENABLE_BACKLIGHT_L, 0);
- /* TODO gpio_set_level(GPIO_KB_BL_EN, 1); */
+ ioex_set_level(IOEX_KB_BL_EN, 1);
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, baseboard_chipset_resume, HOOK_PRIO_DEFAULT);
diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h
index ed5bd522ef..1fc3d8ab58 100644
--- a/baseboard/zork/baseboard.h
+++ b/baseboard/zork/baseboard.h
@@ -102,6 +102,10 @@
*/
#define CONFIG_GPIO_INIT_POWER_ON_DELAY_MS 100
+#define CONFIG_IO_EXPANDER
+#define CONFIG_IO_EXPANDER_NCT38XX
+#define CONFIG_IO_EXPANDER_PORT_COUNT USBC_PORT_COUNT
+
#define CONFIG_KEYBOARD_BOARD_CONFIG
#define CONFIG_KEYBOARD_COL2_INVERTED
#define CONFIG_KEYBOARD_PROTOCOL_8042
@@ -203,6 +207,12 @@ enum pwm_channel {
PWM_CH_COUNT
};
+enum usbc_port {
+ USBC_PORT_C0 = 0,
+ USBC_PORT_C1,
+ USBC_PORT_COUNT
+};
+
enum sensor_id {
LID_ACCEL,
BASE_ACCEL,
diff --git a/board/trembyle/gpio.inc b/board/trembyle/gpio.inc
index 4c9f0a2313..e83f035ee0 100644
--- a/board/trembyle/gpio.inc
+++ b/board/trembyle/gpio.inc
@@ -50,9 +50,14 @@ GPIO(USB_C1_TCPC_RST_L, PIN(F, 0), GPIO_OUT_HIGH) /* C1 TCPC Reset */
GPIO(LED_FULL_L, PIN(6, 0), GPIO_OUT_HIGH)
GPIO(LED_CHRG_L, PIN(C, 0), GPIO_OUT_HIGH)
-/* IOEX(EN_USB_A0_5V, EXPIN(0, 1, 5), GPIO_OUT_LOW) */ /* Enable A0 5V Charging */
-/* IOEX(EN_USB_A1_5V, EXPIN(1, 1, 6), GPIO_OUT_LOW) */ /* Enable A1 5V Charging */
-/* IOEX(KB_BL_EN, EXPIN(0, 1, 3), GPIO_OUT_LOW) */ /* Enable KB Backlight */
+IOEX(USB_C0_FAULT_ODL, EXPIN(USBC_PORT_C0, 1, 1), GPIO_ODR_HIGH) /* C0 Fault to SOC */
+IOEX(USB_C1_FAULT_ODL, EXPIN(USBC_PORT_C0, 1, 2), GPIO_ODR_HIGH) /* C1 Fault to SOC */
+IOEX(KB_BL_EN, EXPIN(USBC_PORT_C0, 1, 3), GPIO_OUT_LOW) /* KB Backlight Enable */
+IOEX(EN_USB_A0_5V, EXPIN(USBC_PORT_C0, 1, 5), GPIO_OUT_LOW) /* A0 5V Source Enable */
+IOEX(USB_A0_CHARGE_EN_L, EXPIN(USBC_PORT_C0, 1, 6), GPIO_OUT_HIGH) /* A0 5V High Current Enable */
+
+IOEX(EN_USB_A1_5V, EXPIN(USBC_PORT_C1, 1, 6), GPIO_OUT_LOW) /* A1 5V Source Enable */
+IOEX(USB_A1_CHARGE_EN_L, EXPIN(USBC_PORT_C1, 1, 7), GPIO_OUT_HIGH) /* A1 5V High Current Enable */
/*
* The NPCX LPC driver configures and controls SCI, so PCH_SCI_ODL [PIN(7, 6)]