summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew McRae <amcrae@google.com>2022-01-12 01:37:15 +1100
committerCommit Bot <commit-bot@chromium.org>2022-01-13 00:18:02 +0000
commit2df72be11e7baf4c122b7d6550f1fbfd8f6c9a1c (patch)
treeb43959ca6675b5f3eb6622194625a02ab5fb840e
parentfb60471e222df8e5298336aff5c301994d66ce43 (diff)
downloadchrome-ec-2df72be11e7baf4c122b7d6550f1fbfd8f6c9a1c.tar.gz
nissa: Remove PPC, fix task event send
Remove PPC references. Fix task event send to charger task. Add support for checking port count in interrupts. Fix PPC config conditional so that other options are available. Sometimes there still seems to be a loop when the board is restarted with a battery and power from a servo on port 0, but this may be a servo issue. BUG=b:213835377 TEST=zmake configure -b nivviks; flash and run BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I3fcd53f32a9fba894018538e12458ec9ae811075 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3379790 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
-rw-r--r--zephyr/Kconfig.usbc4
-rw-r--r--zephyr/projects/nissa/nivviks_overlay.dts2
-rw-r--r--zephyr/projects/nissa/prj_nivviks.conf2
-rw-r--r--zephyr/projects/nissa/src/usbc.c31
4 files changed, 27 insertions, 12 deletions
diff --git a/zephyr/Kconfig.usbc b/zephyr/Kconfig.usbc
index f799a6cb05..bba5c18c56 100644
--- a/zephyr/Kconfig.usbc
+++ b/zephyr/Kconfig.usbc
@@ -951,6 +951,8 @@ config PLATFORM_EC_USBC_PPC_DEDICATED_INT
ppc_get_alert_status() to find out he interrupt status for a port.
This function should be provided by the board code.
+endif # PLATFORM_EC_USBC_PPC
+
config PLATFORM_EC_USB_PD_TCPC_LOW_POWER
bool "Allow Type-C Port Controller to enter low-power mode"
default y
@@ -1344,8 +1346,6 @@ config PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2
This supports up to two USB Type-C ports with Dual Role function
(provider and consumer) and Fast Role Swap detection.
-endif # PLATFORM_EC_USBC_PPC
-
config PLATFORM_EC_USB_PD_PULLUP
int "Default source Rp value"
default 1
diff --git a/zephyr/projects/nissa/nivviks_overlay.dts b/zephyr/projects/nissa/nivviks_overlay.dts
index bac45f91c1..9966473afb 100644
--- a/zephyr/projects/nissa/nivviks_overlay.dts
+++ b/zephyr/projects/nissa/nivviks_overlay.dts
@@ -28,7 +28,7 @@
*/
gpio_sub_usb_c1_int_odl: sub_usb_c1_int_odl {
#gpio-cells = <0>;
- gpios = <&gpio0 2 GPIO_INPUT>;
+ gpios = <&gpio0 2 GPIO_INPUT_PULL_UP>;
enum-name = "GPIO_USB_C1_PD_INT_ODL";
};
};
diff --git a/zephyr/projects/nissa/prj_nivviks.conf b/zephyr/projects/nissa/prj_nivviks.conf
index f74bb76c2c..6883065de5 100644
--- a/zephyr/projects/nissa/prj_nivviks.conf
+++ b/zephyr/projects/nissa/prj_nivviks.conf
@@ -85,6 +85,7 @@ CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
# USB-C/PD
CONFIG_PLATFORM_EC_USBC=y
+CONFIG_PLATFORM_EC_USBC_PPC=n
CONFIG_PLATFORM_EC_USB_VID=0x18d1
CONFIG_PLATFORM_EC_USB_PID=0x505a
CONFIG_PLATFORM_EC_USB_PD_PORT_MAX_COUNT=2
@@ -93,6 +94,7 @@ CONFIG_PLATFORM_EC_USB_PD_PORT_MAX_COUNT=2
CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=y
CONFIG_PLATFORM_EC_USB_PD_TCPM_RAA489000=y
CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y
CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
diff --git a/zephyr/projects/nissa/src/usbc.c b/zephyr/projects/nissa/src/usbc.c
index 1a869832ee..a1cfe0ba7a 100644
--- a/zephyr/projects/nissa/src/usbc.c
+++ b/zephyr/projects/nissa/src/usbc.c
@@ -7,16 +7,12 @@
#include "chipset.h"
#include "hooks.h"
#include "usb_mux.h"
-#include "usbc_ppc.h"
#include "driver/tcpm/tcpci.h"
#include "driver/tcpm/raa489000.h"
#include "sub_board.h"
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args)
-struct ppc_config_t ppc_chips[] = {};
-unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
-
struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
{
.bus_type = EC_BUS_TYPE_I2C,
@@ -53,17 +49,34 @@ struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
+static uint8_t cached_usb_pd_port_count;
+
__override uint8_t board_get_usb_pd_port_count(void)
{
+ if (cached_usb_pd_port_count == 0)
+ CPRINTS("USB PD Port count not initialized!");
+ return cached_usb_pd_port_count;
+}
+
+/*
+ * Initialise the USB PD port count, which
+ * depends on which sub-board is attached.
+ */
+static void init_usb_pd_port_count(void)
+{
switch (nissa_get_sb_type()) {
default:
- return 1;
+ cached_usb_pd_port_count = 1;
case NISSA_SB_C_A:
case NISSA_SB_C_LTE:
- return 2;
+ cached_usb_pd_port_count = 2;
}
}
+/*
+ * Make sure setup is done after EEPROM is readable.
+ */
+DECLARE_HOOK(HOOK_INIT, init_usb_pd_port_count, HOOK_PRIO_INIT_I2C + 1);
void board_set_charge_limit(int port, int supplier, int charge_ma,
int max_ma, int charge_mv)
@@ -171,8 +184,8 @@ uint16_t tcpc_get_alert_status(void)
}
}
- /* TODO(b:212490923) ignore C1 interrupts if port is not present. */
- if (!gpio_get_level(GPIO_USB_C1_PD_INT_ODL)) {
+ if (board_get_usb_pd_port_count() == 2 &&
+ !gpio_get_level(GPIO_USB_C1_PD_INT_ODL)) {
if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
/* TCPCI spec Rev 1.0 says to ignore bits 14:12. */
if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0))
@@ -255,7 +268,7 @@ DECLARE_DEFERRED(poll_c1_int);
static void usbc_interrupt_trigger(int port)
{
schedule_deferred_pd_interrupt(port);
- task_set_event(PD_PORT_TO_TASK_ID(port), USB_CHG_EVENT_BC12);
+ task_set_event(USB_CHG_PORT_TO_TASK_ID(port), USB_CHG_EVENT_BC12);
}
#define USBC_INT_POLL_DATA(port) poll_c ## port ## _int_data