summaryrefslogtreecommitdiff
path: root/board/meep
diff options
context:
space:
mode:
authorDevin Lu <devin.lu@quantatw.com>2020-09-07 20:16:13 +0800
committerCommit Bot <commit-bot@chromium.org>2020-09-10 08:10:20 +0000
commit791c0ac14a8d3679b8c284cf9ecc294d23666bad (patch)
tree9eb05f65434c0e7cec3351d26a5916b3ccd0f285 /board/meep
parenta96a1570c41a745a95e3a187467a066a1f62c27b (diff)
downloadchrome-ec-791c0ac14a8d3679b8c284cf9ecc294d23666bad.tar.gz
Meep: Enable SSFC for PPC on C1 port
BRANCH=firmware-octopus-11297.B BUG=none TEST=Set SSFC value for SYV682x and NX20P348x for two daughterboards. Make sure port can be charged. Remove SSFC field and make sure board is able to recongize correct ppc type by PPC ID. Signed-off-by: Devin Lu <Devin.Lu@quantatw.com> Change-Id: I1be1c5cf23f1fd7f049fdc3879f16334547ec16a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2396097 Reviewed-by: Marco Chen <marcochen@chromium.org>
Diffstat (limited to 'board/meep')
-rw-r--r--board/meep/board.c67
-rw-r--r--board/meep/board.h6
2 files changed, 56 insertions, 17 deletions
diff --git a/board/meep/board.c b/board/meep/board.c
index 068d4140df..0577671755 100644
--- a/board/meep/board.c
+++ b/board/meep/board.c
@@ -33,7 +33,6 @@
#include "motion_sense.h"
#include "power.h"
#include "power_button.h"
-#include "stdbool.h"
#include "switch.h"
#include "system.h"
#include "tablet_mode.h"
@@ -58,20 +57,21 @@ should not be defined."
#endif
static uint8_t sku_id;
-static bool support_syv_ppc;
+static int c0_port_ppc;
+static int c1_port_ppc;
static void ppc_interrupt(enum gpio_signal signal)
{
switch (signal) {
case GPIO_USB_PD_C0_INT_ODL:
- if (support_syv_ppc)
+ if (c0_port_ppc == PPC_SYV682X)
syv682x_interrupt(0);
else
nx20p348x_interrupt(0);
break;
case GPIO_USB_PD_C1_INT_ODL:
- if (support_syv_ppc)
+ if (c1_port_ppc == PPC_SYV682X)
syv682x_interrupt(1);
else
nx20p348x_interrupt(1);
@@ -253,9 +253,38 @@ static void board_update_sensor_config_from_sku(void)
}
}
-static bool board_is_support_syv_ppc(uint32_t board_version)
+static int get_ppc_port_config(uint32_t board_version, int port)
{
- return ((board_version >= 6) && gpio_get_level(GPIO_PPC_ID));
+ switch (port) {
+ /*
+ * Meep C0 port PPC was configrated by PPC ID pin only.
+ */
+ case USB_PD_PORT_TCPC_0:
+ if ((board_version >= 6) && gpio_get_level(GPIO_PPC_ID))
+ return PPC_SYV682X;
+ else
+ return PPC_NX20P348X;
+ /*
+ * Meep C1 port PPC was configrated by PPC ID pin or SSFC,
+ * The first of all we should check SSFC with priority one,
+ * then check PPC ID if board is unalbe to get SSFC.
+ */
+ case USB_PD_PORT_TCPC_1:
+ switch (get_cbi_ssfc_ppc_p1()) {
+ case SSFC_PPC_P1_DEFAULT:
+ if ((board_version >= 6) && gpio_get_level(GPIO_PPC_ID))
+ return PPC_SYV682X;
+ else
+ return PPC_NX20P348X;
+ case SSFC_PPC_P1_SYV682X:
+ return PPC_SYV682X;
+ case SSFC_PPC_P1_NX20P348X:
+ default:
+ return PPC_NX20P348X;
+ }
+ default:
+ return PPC_NX20P348X;
+ }
}
static void cbi_init(void)
@@ -271,7 +300,8 @@ static void cbi_init(void)
if (cbi_get_board_version(&val) == EC_SUCCESS)
ccprints("Board Version: %d", val);
- support_syv_ppc = board_is_support_syv_ppc(val);
+ c0_port_ppc = get_ppc_port_config(val, USB_PD_PORT_TCPC_0);
+ c1_port_ppc = get_ppc_port_config(val, USB_PD_PORT_TCPC_1);
}
DECLARE_HOOK(HOOK_INIT, cbi_init, HOOK_PRIO_INIT_I2C + 1);
@@ -379,18 +409,21 @@ static const struct ppc_config_t ppc_syv682x_port1 = {
static void board_setup_ppc(void)
{
- if (!support_syv_ppc)
- return;
+ if (c0_port_ppc == PPC_SYV682X) {
+ memcpy(&ppc_chips[USB_PD_PORT_TCPC_0],
+ &ppc_syv682x_port0,
+ sizeof(struct ppc_config_t));
- memcpy(&ppc_chips[USB_PD_PORT_TCPC_0],
- &ppc_syv682x_port0,
- sizeof(struct ppc_config_t));
- memcpy(&ppc_chips[USB_PD_PORT_TCPC_1],
- &ppc_syv682x_port1,
- sizeof(struct ppc_config_t));
+ gpio_set_flags(GPIO_USB_PD_C0_INT_ODL, GPIO_INT_BOTH);
+ }
- gpio_set_flags(GPIO_USB_PD_C0_INT_ODL, GPIO_INT_BOTH);
- gpio_set_flags(GPIO_USB_PD_C1_INT_ODL, GPIO_INT_BOTH);
+ if (c1_port_ppc == PPC_SYV682X) {
+ memcpy(&ppc_chips[USB_PD_PORT_TCPC_1],
+ &ppc_syv682x_port1,
+ sizeof(struct ppc_config_t));
+
+ gpio_set_flags(GPIO_USB_PD_C1_INT_ODL, GPIO_INT_BOTH);
+ }
}
DECLARE_HOOK(HOOK_INIT, board_setup_ppc, HOOK_PRIO_INIT_I2C + 2);
diff --git a/board/meep/board.h b/board/meep/board.h
index cfd3d88b6d..570cbd5f7c 100644
--- a/board/meep/board.h
+++ b/board/meep/board.h
@@ -105,6 +105,12 @@ enum battery_type {
BATTERY_TYPE_COUNT,
};
+enum ppc_type {
+ PPC_NX20P348X,
+ PPC_SYV682X,
+ PPC_TYPE_COUNT,
+};
+
#ifdef CONFIG_KEYBOARD_FACTORY_TEST
extern const int keyboard_factory_scan_pins[][2];
extern const int keyboard_factory_scan_pins_used;