summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Mittelberg <bmbm@google.com>2023-04-28 16:17:34 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-05-10 07:00:19 +0000
commitbe430430bbb9c28c43e3747168778be716232a67 (patch)
treeda9986cab75f8eb298894301c3e9dca11ace55bb
parent0fbfb5b1f045ba68eb6c15b553403325dff69de1 (diff)
downloadchrome-ec-be430430bbb9c28c43e3747168778be716232a67.tar.gz
myst: add daughter board configs
Adding devicetree for SKU A and SKU B BUG=b:275610001 BRANCH=none TEST=zmake build myst LOW_COVERAGE_REASON=this is still part of the initial image Change-Id: I5997ca139b26664e6215782c61b9bbe57262ac74 Signed-off-by: Boris Mittelberg <bmbm@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4492007 Reviewed-by: caveh jalali <caveh@chromium.org> Reviewed-by: Diana Z <dzigterman@chromium.org> Reviewed-by: Robert Zieba <robertzieba@google.com> Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--zephyr/program/myst/CMakeLists.txt1
-rw-r--r--zephyr/program/myst/i2c.dtsi28
-rw-r--r--zephyr/program/myst/include/usbc_config.h20
-rw-r--r--zephyr/program/myst/myst/CMakeLists.txt2
-rw-r--r--zephyr/program/myst/myst/include/usb_mux_config.h11
-rw-r--r--zephyr/program/myst/myst/src/ppc_config.c29
-rw-r--r--zephyr/program/myst/myst/src/usb_mux_config.c70
-rw-r--r--zephyr/program/myst/program.conf3
-rw-r--r--zephyr/program/myst/src/usbc_config.c38
-rw-r--r--zephyr/program/myst/usbc.dtsi2
10 files changed, 155 insertions, 49 deletions
diff --git a/zephyr/program/myst/CMakeLists.txt b/zephyr/program/myst/CMakeLists.txt
index c339dbeef7..ece440da75 100644
--- a/zephyr/program/myst/CMakeLists.txt
+++ b/zephyr/program/myst/CMakeLists.txt
@@ -5,6 +5,7 @@
cmake_minimum_required(VERSION 3.20.5)
find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+cros_ec_library_include_directories(include)
zephyr_library_sources("src/common.c")
zephyr_library_sources("src/power_signals.c")
diff --git a/zephyr/program/myst/i2c.dtsi b/zephyr/program/myst/i2c.dtsi
index 58ba31911b..905cbc7f80 100644
--- a/zephyr/program/myst/i2c.dtsi
+++ b/zephyr/program/myst/i2c.dtsi
@@ -76,15 +76,16 @@
tcpc_port0: rt1716@70 {
compatible = "richtek,rt1716";
reg = <0x70>;
- tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
- /* TBD */
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V)>;
irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>;
};
- ppc_port0: ktu1125@78 {
+ ppc_port0: ktu1125@38 {
compatible = "kinetic,ktu1125";
status = "okay";
- reg = <0x78>;
+ reg = <0x38>;
};
};
@@ -105,7 +106,7 @@
reg = <0x40>;
};
- tcpc_port1: rt1718s-tcpc@40 {
+ tcpc_rt1718_port1: rt1718s-tcpc@40 {
compatible = "richtek,rt1718s-tcpc";
reg = <0x40>;
tcpc-flags = <(
@@ -117,15 +118,28 @@
* the "named-gpios" node will be dealt with at a later date.
*/
irq-gpios = <&gpio3 4 GPIO_ACTIVE_LOW>;
+ is-alt;
};
- ppc_port1: nx20p348x@71 {
+ ppc_nx20p_port1: nx20p348x@71 {
compatible = "nxp,nx20p348x";
status = "okay";
reg = <0x71>;
+ is-alt;
+ };
+
+ tcpc_ps8815_port1: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ is-alt;
};
- /* TODO: add SKU-B DB b/275610001 */
+ ppc_ktu1125_port1: ktu1125@38 {
+ compatible = "kinetic,ktu1125";
+ status = "okay";
+ reg = <0x38>;
+ is-alt;
+ };
};
&i2c_ctrl1 {
diff --git a/zephyr/program/myst/include/usbc_config.h b/zephyr/program/myst/include/usbc_config.h
new file mode 100644
index 0000000000..1c983ba8e9
--- /dev/null
+++ b/zephyr/program/myst/include/usbc_config.h
@@ -0,0 +1,20 @@
+/* Copyright 2023 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Myst type-c definitions */
+
+#ifndef __CROS_EC_USBC_CONFIG_H
+#define __CROS_EC_USBC_CONFIG_H
+
+void ppc_interrupt(enum gpio_signal signal);
+
+/* USB-A ports */
+enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_A1, USBA_PORT_COUNT };
+
+/* USB-C ports */
+enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
+BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT);
+
+#endif /* __CROS_EC_USBC_CONFIG_H */
diff --git a/zephyr/program/myst/myst/CMakeLists.txt b/zephyr/program/myst/myst/CMakeLists.txt
index 9dc79f913e..09e319e8c4 100644
--- a/zephyr/program/myst/myst/CMakeLists.txt
+++ b/zephyr/program/myst/myst/CMakeLists.txt
@@ -4,6 +4,6 @@
cros_ec_library_include_directories_ifdef(CONFIG_BOARD_MYST include)
zephyr_library_sources(
- "src/ppc_config.c"
"src/keyboard.c"
+ "src/usb_mux_config.c"
)
diff --git a/zephyr/program/myst/myst/include/usb_mux_config.h b/zephyr/program/myst/myst/include/usb_mux_config.h
new file mode 100644
index 0000000000..848753ba67
--- /dev/null
+++ b/zephyr/program/myst/myst/include/usb_mux_config.h
@@ -0,0 +1,11 @@
+/* Copyright 2023 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __MYST_USB_MUX_CONFIG_H
+#define __MYST_USB_MUX_CONFIG_H
+
+uint32_t get_io_db_type_from_cached_cbi(void);
+
+#endif /* __MYST_USB_MUX_CONFIG_H */
diff --git a/zephyr/program/myst/myst/src/ppc_config.c b/zephyr/program/myst/myst/src/ppc_config.c
deleted file mode 100644
index a16e38a25d..0000000000
--- a/zephyr/program/myst/myst/src/ppc_config.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright 2023 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Myst board-specific PPC code */
-
-#include "driver/ppc/aoz1380_public.h"
-#include "driver/ppc/nx20p348x.h"
-#include "usbc_ppc.h"
-
-#include <zephyr/drivers/gpio.h>
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-void ppc_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_USB_C0_PPC_INT_ODL:
- break;
-
- case GPIO_USB_C1_PPC_INT_ODL:
- break;
-
- default:
- break;
- }
-}
diff --git a/zephyr/program/myst/myst/src/usb_mux_config.c b/zephyr/program/myst/myst/src/usb_mux_config.c
new file mode 100644
index 0000000000..19eacbf989
--- /dev/null
+++ b/zephyr/program/myst/myst/src/usb_mux_config.c
@@ -0,0 +1,70 @@
+/* Copyright 2023 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Myst board-specific USB-C mux configuration */
+
+#include "console.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "hooks.h"
+#include "usb_mux.h"
+#include "usb_mux_config.h"
+#include "usbc/ppc.h"
+#include "usbc/tcpci.h"
+#include "usbc/usb_muxes.h"
+#include "usbc_config.h"
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(myst, CONFIG_MYST_LOG_LEVEL);
+
+uint32_t get_io_db_type_from_cached_cbi(void)
+{
+ uint32_t io_db_type;
+ int ret = cros_cbi_get_fw_config(FW_IO_DB, &io_db_type);
+
+ if (ret != 0) {
+ io_db_type = FW_IO_DB_NONE;
+ LOG_ERR("Failed to get IO_DB value: %d", ret);
+ }
+
+ return io_db_type;
+}
+
+__override uint8_t board_get_usb_pd_port_count(void)
+{
+ if (get_io_db_type_from_cached_cbi() == FW_IO_DB_NONE)
+ return CONFIG_USB_PD_PORT_MAX_COUNT - 1;
+ else
+ return CONFIG_USB_PD_PORT_MAX_COUNT;
+}
+
+static void setup_mux(void)
+{
+ switch (get_io_db_type_from_cached_cbi()) {
+ default:
+ case FW_IO_DB_NONE:
+ LOG_INF("USB DB: not connected");
+ break;
+
+ case FW_IO_DB_SKU_A:
+ LOG_INF("USB DB: Setting SKU_A DB");
+ TCPC_ENABLE_ALTERNATE_BY_NODELABEL(USBC_PORT_C1,
+ tcpc_rt1718_port1);
+ PPC_ENABLE_ALTERNATE_BY_NODELABEL(USBC_PORT_C1,
+ ppc_nx20p_port1);
+ break;
+
+ case FW_IO_DB_SKU_B:
+ LOG_INF("USB DB: Setting SKU_B DB");
+ TCPC_ENABLE_ALTERNATE_BY_NODELABEL(USBC_PORT_C1,
+ tcpc_ps8815_port1);
+ PPC_ENABLE_ALTERNATE_BY_NODELABEL(USBC_PORT_C1,
+ ppc_ktu1125_port1);
+ break;
+ }
+}
+DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C);
diff --git a/zephyr/program/myst/program.conf b/zephyr/program/myst/program.conf
index 49d4cc00ad..0b275b16fa 100644
--- a/zephyr/program/myst/program.conf
+++ b/zephyr/program/myst/program.conf
@@ -78,6 +78,7 @@ CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000
# USB-C
CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815=y
+CONFIG_PLATFORM_EC_USBC_PPC=y
CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y
CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y
CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
@@ -90,7 +91,7 @@ CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
CONFIG_PLATFORM_EC_USB_PD_REV30=y
CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
-CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n
+CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=y
CONFIG_PLATFORM_EC_USB_PD_USB4=n
CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
diff --git a/zephyr/program/myst/src/usbc_config.c b/zephyr/program/myst/src/usbc_config.c
index c3aafd9da9..bc76a66be3 100644
--- a/zephyr/program/myst/src/usbc_config.c
+++ b/zephyr/program/myst/src/usbc_config.c
@@ -14,14 +14,18 @@
#include "cros_board_info.h"
#include "cros_cbi.h"
#include "driver/charger/isl9241.h"
+#include "driver/ppc/ktu1125_public.h"
+#include "driver/ppc/nx20p348x.h"
#include "driver/tcpm/rt1718s.h"
#include "driver/usb_mux/amd_fp6.h"
#include "gpio/gpio_int.h"
#include "hooks.h"
#include "power.h"
#include "usb_mux.h"
+#include "usb_mux_config.h"
#include "usb_pd_tcpm.h"
#include "usbc/usb_muxes.h"
+#include "usbc_config.h"
#include "usbc_ppc.h"
#include <zephyr/drivers/gpio.h>
@@ -29,13 +33,6 @@
#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-/* USB-A ports */
-enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_A1, USBA_PORT_COUNT };
-
-/* USB-C ports */
-enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
-BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT);
-
static void usbc_interrupt_init(void)
{
/* Enable PPC interrupts. */
@@ -57,7 +54,7 @@ int board_set_active_charge_port(int port)
CPRINTSUSB("Disabling all charger ports");
/* Disable all ports. */
- for (i = 0; i < ppc_cnt; i++) {
+ for (i = 0; i < board_get_usb_pd_port_count(); i++) {
/*
* Do not return early if one fails otherwise we can
* get into a boot loop assertion failure.
@@ -83,7 +80,7 @@ int board_set_active_charge_port(int port)
* Turn off the other ports' sink path FETs, before enabling the
* requested charge port.
*/
- for (i = 0; i < ppc_cnt; i++) {
+ for (i = 0; i < board_get_usb_pd_port_count(); i++) {
if (i == port)
continue;
@@ -121,6 +118,29 @@ void usb_pd_soc_interrupt(enum gpio_signal signal)
CPRINTSUSB("SOC PD Interrupt");
}
+void ppc_interrupt(enum gpio_signal signal)
+{
+ uint32_t io_db_type = get_io_db_type_from_cached_cbi();
+
+ switch (signal) {
+ case GPIO_USB_C0_PPC_INT_ODL:
+ ktu1125_interrupt(USBC_PORT_C0);
+ break;
+
+ case GPIO_USB_C1_PPC_INT_ODL:
+ if (io_db_type == FW_IO_DB_SKU_A) {
+ nx20p348x_interrupt(USBC_PORT_C1);
+ }
+ if (io_db_type == FW_IO_DB_SKU_B) {
+ ktu1125_interrupt(USBC_PORT_C1);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
/* Round up 3250 max current to multiple of 128mA for ISL9241 AC prochot. */
static void charger_prochot_init_isl9241(void)
{
diff --git a/zephyr/program/myst/usbc.dtsi b/zephyr/program/myst/usbc.dtsi
index 8e8579d328..b63c0347bd 100644
--- a/zephyr/program/myst/usbc.dtsi
+++ b/zephyr/program/myst/usbc.dtsi
@@ -24,8 +24,6 @@
compatible = "named-usbc-port";
reg = <1>;
bc12 = <&bc12_port1>;
- tcpc = <&tcpc_port1>;
- ppc = <&ppc_port1>;
usb-mux-chain-1-anx {
compatible = "cros-ec,usb-mux-chain";
usb-muxes = <&amd_fp6_port1>;