summaryrefslogtreecommitdiff
path: root/zephyr/test/drivers/common/src/stubs.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/test/drivers/common/src/stubs.c')
-rw-r--r--zephyr/test/drivers/common/src/stubs.c88
1 files changed, 85 insertions, 3 deletions
diff --git a/zephyr/test/drivers/common/src/stubs.c b/zephyr/test/drivers/common/src/stubs.c
index 69993d8a89..d07683017f 100644
--- a/zephyr/test/drivers/common/src/stubs.c
+++ b/zephyr/test/drivers/common/src/stubs.c
@@ -7,11 +7,11 @@
#include "battery_fuel_gauge.h"
#include "bc12/pi3usb9201_public.h"
#include "charge_ramp.h"
-#include "charge_state_v2.h"
#include "charger.h"
#include "charger/isl923x_public.h"
#include "charger/isl9241_public.h"
#include "config.h"
+#include <zephyr/fff.h>
#include "gpio/gpio_int.h"
#include "hooks.h"
#include "i2c/i2c.h"
@@ -19,14 +19,14 @@
#include "ppc/sn5s330_public.h"
#include "ppc/syv682x_public.h"
#include "retimer/bb_retimer_public.h"
+#include "test/drivers/stubs.h"
#include "tcpm/ps8xxx_public.h"
#include "tcpm/tcpci.h"
-#include "test/drivers/stubs.h"
#include "usb_mux.h"
#include "usb_pd_tcpm.h"
#include "usbc_ppc.h"
+#include "charge_state_v2.h"
-#include <zephyr/fff.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(stubs);
@@ -40,6 +40,19 @@ LOG_MODULE_REGISTER(stubs);
* device tree.
*/
+/* BC1.2 charger detect configuration */
+const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = {
+ [USBC_PORT_C0] = {
+ .i2c_port = I2C_PORT_USB_C0,
+ .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
+ },
+ [USBC_PORT_C1] = {
+ .i2c_port = I2C_PORT_USB_C1,
+ .i2c_addr_flags = PI3USB9201_I2C_ADDR_1_FLAGS,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(pi3usb9201_bc12_chips) == USBC_PORT_COUNT);
+
int board_set_active_charge_port(int port)
{
int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
@@ -98,6 +111,13 @@ int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state)
return 0;
}
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
+ int charge_mv)
+{
+ charge_set_input_current_limit(
+ MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+}
+
BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT);
static uint16_t ps8xxx_product_id = PS8805_PRODUCT_ID;
@@ -128,6 +148,68 @@ int board_is_sourcing_vbus(int port)
return ppc_is_sourcing_vbus(port);
}
+/* TODO(b/239457738): Move to dts */
+struct usb_mux_chain usbc0_virtual_usb_mux_chain = {
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = USBC_PORT_C0,
+ .driver = &virtual_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
+ },
+};
+
+struct usb_mux usbc1_virtual_usb_mux = {
+ .usb_port = USBC_PORT_C1,
+ .driver = &virtual_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
+};
+
+struct usb_mux_chain usbc1_virtual_usb_mux_chain = {
+ .mux = &usbc1_virtual_usb_mux,
+};
+
+struct usb_mux usbc0_mux0 = {
+ .usb_port = USBC_PORT_C0,
+ .driver = &tcpci_tcpm_usb_mux_driver,
+ .i2c_port = I2C_PORT_USB_C0,
+ .i2c_addr_flags = DT_REG_ADDR(DT_NODELABEL(tcpci_emul)),
+};
+
+struct usb_mux_chain usb_muxes[] = {
+ [USBC_PORT_C0] = {
+ .mux = &usbc0_mux0,
+ .next = &usbc0_virtual_usb_mux_chain,
+ },
+ [USBC_PORT_C1] = {
+#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB
+ .mux = &(const struct usb_mux){
+ .usb_port = USBC_PORT_C1,
+ .driver = &bb_usb_retimer,
+ .hpd_update = bb_retimer_hpd_update,
+ .i2c_port = I2C_PORT_USB_C1,
+ .i2c_addr_flags = DT_REG_ADDR(DT_NODELABEL(
+ usb_c1_bb_retimer_emul)),
+ },
+ .next = &usbc1_virtual_usb_mux_chain,
+#endif
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
+
+#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB
+struct bb_usb_control bb_controls[] = {
+ [USBC_PORT_C0] = {
+ /* USB-C port 0 doesn't have a retimer */
+ },
+ [USBC_PORT_C1] = {
+ .usb_ls_en_gpio = GPIO_SIGNAL(DT_NODELABEL(usb_c1_ls_en)),
+ .retimer_rst_gpio =
+ GPIO_SIGNAL(DT_NODELABEL(usb_c1_rt_rst_odl)),
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(bb_controls) == USBC_PORT_COUNT);
+#endif
+
void pd_power_supply_reset(int port)
{
}