summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Mittelberg <bmbm@google.com>2022-04-08 14:44:55 -0700
committerBoris Mittelberg <bmbm@google.com>2022-04-08 14:44:55 -0700
commit10cb14ae7b35f4ad9eb37f58ba3c48d20649e35b (patch)
tree96593e82138d3abfbd7dea091a430b7fdb7566cb
parentb47f56d99b8986bbea363e809390e3789f2c5796 (diff)
parent699af58cf8ca13bc413d4741fd685e2deb402ae6 (diff)
downloadchrome-ec-10cb14ae7b35f4ad9eb37f58ba3c48d20649e35b.tar.gz
Merge remote-tracking branch cros/main into firmware-brya-14505.B-main
Generated by: util/update_release_branch.py --baseboard brya --relevant_paths_file baseboard/brya/relevant-paths.txt firmware-brya-14505.B-main Relevant changes: git log --oneline b47f56d99b..699af58cf8 -- baseboard/brya board/agah board/anahera board/banshee board/brya board/crota board/felwinter board/gimble board/kano board/primus board/redrix board/taeko board/taniks board/vell board/volmar driver/bc12/pi3usb9201_public.* driver/charger/bq25710.* driver/ppc/nx20p348x.* driver/ppc/syv682x_public.* driver/retimer/bb_retimer_public.* driver/tcpm/nct38xx.* driver/tcpm/ps8xxx_public.* driver/tcpm/tcpci.* include/power/alderlake* include/intel_x86.h power/alderlake* power/intel_x86.c util/getversion.sh 272b89865d Felwinter : Remove CONFIG_CMD_POWERINDEBUG. 906818f9bb gimble: fix unused gpio pin BRANCH=None BUG=b:216734502 b:224516847 TEST=`make -j buildall` Signed-off-by: Boris Mittelberg <bmbm@google.com> Change-Id: Ie92fefbb17a0d37ebade2305d0659b58645f0e3d
-rw-r--r--Makefile1
-rw-r--r--baseboard/dedede/baseboard.c7
-rw-r--r--board/felwinter/board.h3
-rw-r--r--board/gimble/gpio.inc2
-rw-r--r--board/hatch_fp/build.mk4
-rw-r--r--board/lantis/led.c52
-rw-r--r--board/nocturne_fp/build.mk4
-rw-r--r--chip/mt_scp/mt8195/video.c5
-rw-r--r--common/battery_v2.c7
-rw-r--r--common/test_util.c4
-rw-r--r--docs/zephyr/zephyr_i2c.md31
-rw-r--r--driver/bc12/pi3usb9201.c12
-rw-r--r--driver/retimer/bb_retimer.c8
-rw-r--r--driver/tcpm/rt1718s.c2
-rw-r--r--include/config.h3
-rw-r--r--test/build.mk4
-rwxr-xr-xtest/run_device_tests.py41
-rw-r--r--util/build.mk1
-rw-r--r--util/ectool.c5
-rw-r--r--zephyr/Kconfig84
-rw-r--r--zephyr/Kconfig.cbi8
-rw-r--r--zephyr/Kconfig.charger6
-rw-r--r--zephyr/Kconfig.i2c77
-rw-r--r--zephyr/Kconfig.retimer9
-rw-r--r--zephyr/Kconfig.usba10
-rw-r--r--zephyr/boards/arm/brya/Kconfig.board15
-rw-r--r--zephyr/boards/arm/brya/Kconfig.defconfig10
-rw-r--r--zephyr/boards/arm/brya/board.cmake6
-rw-r--r--zephyr/boards/arm/brya/brya.dts320
-rw-r--r--zephyr/boards/arm/brya/brya_defconfig49
-rw-r--r--zephyr/boards/riscv/it8xxx2/it8xxx2_defconfig2
-rw-r--r--zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb.dts23
-rw-r--r--zephyr/drivers/cros_rtc/Kconfig4
-rw-r--r--zephyr/dts/bindings/battery/battery-smart.yaml1
-rw-r--r--zephyr/dts/bindings/battery/panasonic,ap19a5k.yaml59
-rw-r--r--zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml13
-rw-r--r--zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml13
-rw-r--r--zephyr/projects/brya/BUILD.py49
-rw-r--r--zephyr/projects/brya/Kconfig11
-rw-r--r--zephyr/projects/brya/adc.dts35
-rw-r--r--zephyr/projects/brya/brya.dts18
-rw-r--r--zephyr/projects/brya/gpio.dts22
-rw-r--r--zephyr/projects/brya/i2c.dts138
-rw-r--r--zephyr/projects/brya/prj.conf5
-rw-r--r--zephyr/projects/brya/prj_brya.conf6
-rw-r--r--zephyr/projects/brya/temp_sensors.dts67
-rw-r--r--zephyr/projects/corsola/prj.conf3
-rw-r--r--zephyr/projects/corsola/prj_kingler.conf5
-rw-r--r--zephyr/projects/corsola/prj_krabby.conf1
-rw-r--r--zephyr/projects/herobrine/BUILD.py2
-rw-r--r--zephyr/projects/herobrine/battery_villager.dts5
-rw-r--r--zephyr/projects/herobrine/gpio_led_villager.dts30
-rw-r--r--zephyr/projects/herobrine/led_villager.dts92
-rw-r--r--zephyr/projects/herobrine/motionsense.dts98
-rw-r--r--zephyr/projects/herobrine/motionsense_hoglin.dts98
-rw-r--r--zephyr/projects/herobrine/prj.conf1
-rw-r--r--zephyr/projects/herobrine/prj_herobrine.conf7
-rw-r--r--zephyr/projects/herobrine/prj_hoglin.conf8
-rw-r--r--zephyr/projects/herobrine/prj_villager.conf1
-rw-r--r--zephyr/projects/intelrvp/prj.conf2
-rw-r--r--zephyr/projects/it8xxx2_evb/prj.conf2
-rw-r--r--zephyr/projects/nissa/CMakeLists.txt2
-rw-r--r--zephyr/projects/nissa/nereid_power_signals.dts54
-rw-r--r--zephyr/projects/nissa/nivviks_motionsense.dts10
-rw-r--r--zephyr/projects/nissa/nivviks_overlay.dts45
-rw-r--r--zephyr/projects/nissa/prj.conf6
-rw-r--r--zephyr/projects/nissa/prj_nereid.conf6
-rw-r--r--zephyr/projects/nissa/prj_nivviks.conf3
-rw-r--r--zephyr/projects/nissa/src/board_power.c13
-rw-r--r--zephyr/projects/nissa/src/nivviks/fan.c45
-rw-r--r--zephyr/projects/nissa/src/nivviks/form_factor.c45
-rw-r--r--zephyr/projects/posix-ec/prj.conf1
-rw-r--r--zephyr/projects/skyrim/BUILD.py2
-rw-r--r--zephyr/projects/skyrim/led.c73
-rw-r--r--zephyr/projects/skyrim/prj.conf5
-rw-r--r--zephyr/projects/skyrim/pwm.dts33
-rw-r--r--zephyr/projects/skyrim/pwm_leds.dts46
-rw-r--r--zephyr/projects/trogdor/lazor/gpio_led.dts2
-rw-r--r--zephyr/projects/trogdor/lazor/prj.conf5
-rw-r--r--zephyr/projects/trogdor/lazor/pwm_led.dts2
-rw-r--r--zephyr/shim/chip/npcx/shi.c4
-rw-r--r--zephyr/shim/include/config_chip.h11
-rw-r--r--zephyr/shim/include/motionsense_sensors.h18
-rw-r--r--zephyr/shim/src/fan.c2
-rw-r--r--zephyr/shim/src/led_driver/led.c18
-rw-r--r--zephyr/shim/src/led_driver/led.h5
-rw-r--r--zephyr/shim/src/led_driver/led_gpio.c40
-rw-r--r--zephyr/shim/src/led_driver/led_pwm.c40
-rw-r--r--zephyr/shim/src/motionsense_sensors.c4
-rw-r--r--zephyr/shim/src/tasks.c130
-rw-r--r--zephyr/test/drivers/CMakeLists.txt1
-rw-r--r--zephyr/test/drivers/prj.conf1
-rw-r--r--zephyr/test/drivers/src/bb_retimer.c5
-rw-r--r--zephyr/test/drivers/src/integration/usbc/usb_pd_ctrl_msg.c178
-rw-r--r--zephyr/test/i2c/prj.conf1
95 files changed, 1632 insertions, 835 deletions
diff --git a/Makefile b/Makefile
index 43712434a3..3a36b91125 100644
--- a/Makefile
+++ b/Makefile
@@ -150,6 +150,7 @@ endif
_tsk_lst_flags+=-I$(BDIR) -DBOARD_$(UC_BOARD)=$(EMPTY) -I$(BASEDIR) \
-DBASEBOARD_$(UC_BASEBOARD)=$(EMPTY) \
-D_MAKEFILE=$(EMPTY) -imacros $(_tsk_lst_file)
+-include private/task_list_flags.mk
_tsk_lst_ro:=$(shell $(CPP) -P -DSECTION_IS_RO=$(EMPTY) \
$(_tsk_lst_flags) include/task_filter.h)
diff --git a/baseboard/dedede/baseboard.c b/baseboard/dedede/baseboard.c
index 1986f58e34..60b3949e93 100644
--- a/baseboard/dedede/baseboard.c
+++ b/baseboard/dedede/baseboard.c
@@ -138,9 +138,12 @@ __override int intel_x86_get_pg_ec_dsw_pwrok(void)
* therefore this value may be stale. Assume that the PGOOD
* follows the enable signal for this case only.
*/
- if (!gpio_get_level(GPIO_EN_PP3300_A))
+ if (!gpio_get_level(GPIO_EN_PP3300_A)) {
CPRINTS("EN_PP3300_A is low, assuming PG is low!");
- return gpio_get_level(GPIO_EN_PP3300_A);
+ atomic_clear(&pp3300_a_pgood);
+ } else {
+ atomic_or(&pp3300_a_pgood, 1);
+ }
}
return pp3300_a_pgood;
}
diff --git a/board/felwinter/board.h b/board/felwinter/board.h
index 14c51e55d1..d8bcd11705 100644
--- a/board/felwinter/board.h
+++ b/board/felwinter/board.h
@@ -75,6 +75,9 @@
/* I2C control host command */
#define CONFIG_HOSTCMD_I2C_CONTROL
+/* Disable console commands to help save space */
+#undef CONFIG_CMD_POWERINDEBUG
+
#define CONFIG_USBC_PPC_SYV682X
#define CONFIG_USBC_PPC_NX20P3483
diff --git a/board/gimble/gpio.inc b/board/gimble/gpio.inc
index 680becac17..412673c227 100644
--- a/board/gimble/gpio.inc
+++ b/board/gimble/gpio.inc
@@ -102,7 +102,6 @@ ALTERNATE(PIN_MASK(1, 0x7f), 0, MODULE_KB, GPIO_ODR_HIGH) /* KSO06/GPO13/GP_S
ALTERNATE(PIN_MASK(2, 0xfc), 0, MODULE_KB, GPIO_INPUT | GPIO_PULL_UP) /* KSI2/GPIO27/TRACEDATA1, KSI3/GPIO26/TRACEDATA0, KSI4/GPIO25/TRACECLK/GP_SCLK, KSI5/GPIO24/GP_MISO, KSI6/GPIO23/S_SBUB, KSI7/GPIO22/S_SBUA */
ALTERNATE(PIN_MASK(2, 0x03), 0, MODULE_KB, GPIO_ODR_HIGH) /* KSO00/GPIO21/JTAG_TCK_SWCLK, KSO01/GPIO20/JTAG_TMS_SWIO */
ALTERNATE(PIN_MASK(3, 0x03), 0, MODULE_KB, GPIO_INPUT | GPIO_PULL_UP) /* KSI0/GPIO31/TRACEDATA3/GP_MOSI, KSI1/GPIO30/TRACEDATA2/GP_CS_L */
-ALTERNATE(PIN_MASK(8, 0x04), 0, MODULE_KB, GPIO_ODR_HIGH) /* KSO14/GPIO82 */
/* PMU alternate functions */
ALTERNATE(PIN_MASK(0, 0x01), 0, MODULE_PMU, GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH) /* PSL_IN2_L&GPI00/GPIO00 */
@@ -126,6 +125,7 @@ UNUSED(PIN(9, 6)) /* F_DIO1/GPIO96 */
UNUSED(PIN(7, 0)) /* GPIO70/PS2_DAT0 */
UNUSED(PIN(8, 1)) /* PECI DATA/GPIO81 */
UNUSED(PIN(5, 7)) /* GPIO57/SER_IRQ/ESPI_ALERT_L */
+UNUSED(PIN(8, 2)) /* KSO14/GPIO82 */
/* Pre-configured PSL balls: J8 K6 */
diff --git a/board/hatch_fp/build.mk b/board/hatch_fp/build.mk
index 97dc4e91e4..8986d3ee91 100644
--- a/board/hatch_fp/build.mk
+++ b/board/hatch_fp/build.mk
@@ -54,3 +54,7 @@ test-list-y=\
timer_dos \
utils \
utils_str \
+
+# Note that this variable includes the trailing "/"
+_hatch_fp_cur_dir:=$(dir $(lastword $(MAKEFILE_LIST)))
+-include $(_hatch_fp_cur_dir)../../private/board/hatch_fp/build.mk \ No newline at end of file
diff --git a/board/lantis/led.c b/board/lantis/led.c
index 57d537cf13..632f91e118 100644
--- a/board/lantis/led.c
+++ b/board/lantis/led.c
@@ -134,6 +134,23 @@ int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
}
/*
+ * lantis use old led policy.
+ * Use cbi fw_config to distinguish lantis from other boards.
+ * numeric_pad tablet mode
+ * lantis N N
+ * landrid Y N
+ * landia N Y
+ */
+static bool is_led_old_policy(void)
+{
+ if (get_cbi_fw_config_numeric_pad() == NUMERIC_PAD_ABSENT &&
+ get_cbi_fw_config_tablet_mode() == TABLET_MODE_ABSENT)
+ return 1;
+ else
+ return 0;
+}
+
+/*
* Set active charge port color to the parameter, turn off all others.
* If no port is active (-1), turn off all LEDs.
*/
@@ -190,18 +207,39 @@ static void led_set_battery(void)
/* Intentional fall-through */
case PWR_STATE_DISCHARGE:
/*
- * Blink white light (1 sec on, 1 sec off)
+ * Blink white/amber light (1 sec on, 1 sec off)
* when battery capacity is less than 10%
*/
- if (charge_get_percent() < 10)
- led_set_color_battery(RIGHT_PORT,
- (battery_ticks & 0x2) ? LED_WHITE : LED_OFF);
- else
+ if (charge_get_percent() < 10) {
+ if (is_led_old_policy()) {
+ led_set_color_battery(
+ RIGHT_PORT, (battery_ticks & 0x2) ?
+ LED_WHITE : LED_OFF);
+ } else {
+ if (led_auto_control_is_enabled(
+ EC_LED_ID_RIGHT_LED))
+ led_set_color_battery(
+ RIGHT_PORT,
+ (battery_ticks & 0x2) ?
+ LED_AMBER : LED_OFF);
+ if (led_auto_control_is_enabled(
+ EC_LED_ID_LEFT_LED))
+ led_set_color_battery(
+ LEFT_PORT,
+ (battery_ticks & 0x2) ?
+ LED_AMBER : LED_OFF);
+ }
+ } else {
set_active_port_color(LED_OFF);
+ }
break;
case PWR_STATE_ERROR:
- set_active_port_color(
- (battery_ticks % 0x2) ? LED_WHITE : LED_OFF);
+ if (is_led_old_policy())
+ set_active_port_color(
+ (battery_ticks % 0x2) ? LED_WHITE : LED_OFF);
+ else
+ set_active_port_color(
+ (battery_ticks % 0x2) ? LED_AMBER : LED_OFF);
break;
case PWR_STATE_CHARGE_NEAR_FULL:
set_active_port_color(LED_WHITE);
diff --git a/board/nocturne_fp/build.mk b/board/nocturne_fp/build.mk
index 6eff719d9b..cc985141d1 100644
--- a/board/nocturne_fp/build.mk
+++ b/board/nocturne_fp/build.mk
@@ -53,3 +53,7 @@ test-list-y=\
timer_dos \
utils \
utils_str \
+
+# Note that this variable includes the trailing "/"
+_nocturne_fp_cur_dir:=$(dir $(lastword $(MAKEFILE_LIST)))
+-include $(_nocturne_fp_cur_dir)../../private/board/nocturne_fp/build.mk
diff --git a/chip/mt_scp/mt8195/video.c b/chip/mt_scp/mt8195/video.c
index dc4b7b3397..cc62f051df 100644
--- a/chip/mt_scp/mt8195/video.c
+++ b/chip/mt_scp/mt8195/video.c
@@ -13,7 +13,6 @@ uint32_t video_get_enc_capability(void)
uint32_t video_get_dec_capability(void)
{
- return VDEC_CAP_MT21C | VDEC_CAP_MM21 |
- VDEC_CAP_H264_SLICE | VDEC_CAP_VP8_FRAME |
- VDEC_CAP_VP9_FRAME;
+ return VDEC_CAP_MM21 | VDEC_CAP_H264_SLICE |
+ VDEC_CAP_VP8_FRAME | VDEC_CAP_VP9_FRAME;
}
diff --git a/common/battery_v2.c b/common/battery_v2.c
index 77428b7bc9..27ae0285ac 100644
--- a/common/battery_v2.c
+++ b/common/battery_v2.c
@@ -11,6 +11,7 @@
#include "console.h"
#include "hooks.h"
#include "host_command.h"
+#include "math_util.h"
#include "printf.h"
#include "util.h"
@@ -68,7 +69,11 @@ static void battery_update(enum battery_index i)
batt_str[EC_MEMMAP_TEXT_MAX - 1] = 0;
*memmap_volt = battery_dynamic[i].actual_voltage;
- *memmap_rate = battery_dynamic[i].actual_current;
+ /*
+ * Rate must be absolute, flags will indicate whether
+ * the battery is charging or discharging.
+ */
+ *memmap_rate = ABS(battery_dynamic[i].actual_current);
*memmap_cap = battery_dynamic[i].remaining_capacity;
*memmap_lfcc = battery_dynamic[i].full_capacity;
*memmap_flags = battery_dynamic[i].flags;
diff --git a/common/test_util.c b/common/test_util.c
index 287bcbeddf..37cc42000c 100644
--- a/common/test_util.c
+++ b/common/test_util.c
@@ -225,7 +225,11 @@ void z_ztest_run_test_suite(const char *name, struct unit_test *suite)
suite++;
}
+ /* Sometimes the console task doesn't start until the test is done. */
+ sleep(1);
+
ccprintf("%s: ", name);
+
test_print_result();
}
#endif /* CONFIG_ZEPHYR */
diff --git a/docs/zephyr/zephyr_i2c.md b/docs/zephyr/zephyr_i2c.md
index 09c6473ea6..4f001e4408 100644
--- a/docs/zephyr/zephyr_i2c.md
+++ b/docs/zephyr/zephyr_i2c.md
@@ -9,21 +9,11 @@ USB-C chips, battery, charging IC, and sensors.
## Kconfig Options
-Kconfig Option | Default state | Documentation
-:--------------------------------- | :-----------: | :------------
-`CONFIG_PLATFORM_EC_I2C` | y | [EC I2C]
-
-The following options are available only when `CONFIG_PLATFORM_EC_I2C=y`.
-
-Kconfig sub-option | Default | Documentation
-:-------------------------------------------- | :-----: | :------------
-`CONFIG_I2C_SHELL` | y | [CONFIG_I2C_SHELL]
-`CONFIG_PLATFORM_EC_I2C_DEBUG` | n | [I2C Debug]
-`CONFIG_PLATFORM_EC_I2C_DEBUG_PASSTHRU` | n | [I2C Debug Passthru]
-`CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_PORTMAP` | n | [I2C Portmap]
-`CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED` | n | [I2C Speed]
-`CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL` | n | [I2C Control]
-`CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED` | n | [I2C Passthru Restricted]
+The Kconfig option [`CONFIG_I2C`] enables I2C support in the EC
+application. Refer to [Kconfig.i2c] for all sub-options related to I2C support.
+
+The upstream Zephyr I2C driver also provides I2C shell commands with the
+[`CONFIG_I2C_SHELL`] option.
## Devicetree Nodes
@@ -357,13 +347,8 @@ below:
[I2C]: ../ec_terms.md#i2c
[subcommands]: https://github.com/zephyrproject-rtos/zephyr/blob/f4a0ea7b43eee4d2ee735ab6beccc68c9d40a7d0/drivers/i2c/i2c_shell.c#L245
[I2C Example]: ../images/i2c_example.png
-[EC I2C]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/Kconfig;?q="config%20PLATFORM_EC_I2C"&ss=chromiumos
-[CONFIG_I2C_SHELL]: https://docs.zephyrproject.org/latest/kconfig.html#CONFIG_I2C_SHELL
-[I2C Debug]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/Kconfig;?q=PLATFORM_EC_I2C_DEBUG&sq=&ss=chromiumos
-[I2C Debug Passthru]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/Kconfig;?q=PLATFORM_EC_I2C_DEBUG_PASSTHRU&ss=chromiumos
-[I2C Portmap]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/Kconfig?q=PLATFORM_EC_CONSOLE_CMD_I2C_PORTMAP&ss=chromiumos%2Fchromiumos%2Fcodesearch
-[I2C Speed]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/Kconfig?q=PLATFORM_EC_CONSOLE_CMD_I2C_SPEED&ss=chromiumos
-[I2C Control]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/Kconfig?q=PLATFORM_EC_HOSTCMD_I2C_CONTROL&ss=chromiumos
-[I2C Passthru Restricted]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/Kconfig?q=PLATFORM_EC_I2C_PASSTHRU_RESTRICTED&ss=chromiumos
+[Kconfig.i2c]: ../../zephyr/Kconfig.i2c
+[`CONFIG_I2C`]: https://docs.zephyrproject.org/latest/kconfig.html#CONFIG_I2C
+[`CONFIG_I2C_SHELL`]: https://docs.zephyrproject.org/latest/kconfig.html#CONFIG_I2C_SHELL
[cros-ec-i2c-port-base.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml
[volteer.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/boards/arm/volteer/volteer.dts;
diff --git a/driver/bc12/pi3usb9201.c b/driver/bc12/pi3usb9201.c
index 2a9986f823..ac88e5c310 100644
--- a/driver/bc12/pi3usb9201.c
+++ b/driver/bc12/pi3usb9201.c
@@ -52,18 +52,7 @@ static const struct bc12_status bc12_chg_limits[] = {
[CHG_RESERVED] = {CHARGE_SUPPLIER_NONE, 0},
[CHG_CDP] = {CHARGE_SUPPLIER_BC12_CDP, USB_CHARGER_MAX_CURR_MA},
[CHG_SDP] = {CHARGE_SUPPLIER_BC12_SDP, 500},
-#if defined(CONFIG_CHARGE_RAMP_SW) || defined(CONFIG_CHARGE_RAMP_HW)
- /*
- * If ramping is supported, then for DCP set the current limit to be the
- * max supported for the port by the board or 1.5A (whichever is lower).
- * Although, the BC 1.2 specification allows DCP suppliers to ramp to
- * much higher currents, the USB Type-C specification limits the
- * maximum current allowed for BC 1.2 suppliers to 1.5A.
- */
[CHG_DCP] = {CHARGE_SUPPLIER_BC12_DCP, USB_CHARGER_MAX_CURR_MA},
-#else
- [CHG_DCP] = {CHARGE_SUPPLIER_BC12_DCP, 500},
-#endif
};
static inline int raw_read8(int port, int offset, int *value)
@@ -368,6 +357,7 @@ static int pi3usb9201_ramp_allowed(int supplier)
/* Don't allow ramp if charge supplier is OTHER, SDP, or NONE */
return !(supplier == CHARGE_SUPPLIER_OTHER ||
supplier == CHARGE_SUPPLIER_BC12_SDP ||
+ supplier == CHARGE_SUPPLIER_BC12_DCP ||
supplier == CHARGE_SUPPLIER_NONE);
}
diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c
index a95a711398..170aac6c23 100644
--- a/driver/retimer/bb_retimer.c
+++ b/driver/retimer/bb_retimer.c
@@ -226,7 +226,8 @@ static void retimer_set_state_dfp(int port, mux_state_t mux_state,
* 1 - vPro Dock or DP Overdrive
* detected
*/
- if (dev_resp.intel_spec_b0 == VENDOR_SPECIFIC_SUPPORTED ||
+ if ((IS_ENABLED(CONFIG_USBC_RETIMER_INTEL_BB_VPRO_CAPABLE) &&
+ dev_resp.intel_spec_b0 == VENDOR_SPECIFIC_SUPPORTED) ||
dev_resp.vendor_spec_b1 == VENDOR_SPECIFIC_SUPPORTED)
*set_retimer_con |= BB_RETIMER_VPRO_DOCK_DP_OVERDRIVE;
@@ -313,8 +314,9 @@ static void retimer_set_state_ufp(int port, mux_state_t mux_state,
*
* Set according to TBT3 Enter Mode bit 26 or bit 31
*/
- if (ufp_tbt_enter_mode.intel_spec_b0 ==
- VENDOR_SPECIFIC_SUPPORTED ||
+ if ((IS_ENABLED(CONFIG_USBC_RETIMER_INTEL_BB_VPRO_CAPABLE) &&
+ ufp_tbt_enter_mode.intel_spec_b0 ==
+ VENDOR_SPECIFIC_SUPPORTED) ||
ufp_tbt_enter_mode.vendor_spec_b1 ==
VENDOR_SPECIFIC_SUPPORTED)
*set_retimer_con |= BB_RETIMER_VPRO_DOCK_DP_OVERDRIVE;
diff --git a/driver/tcpm/rt1718s.c b/driver/tcpm/rt1718s.c
index a150f50a40..07ddc38ed3 100644
--- a/driver/tcpm/rt1718s.c
+++ b/driver/tcpm/rt1718s.c
@@ -331,7 +331,7 @@ static void rt1718s_bc12_usb_charger_task(const int port)
while (1) {
uint32_t evt = task_wait_event(-1);
bool is_non_pd_sink = !pd_capable(port) &&
- usb_charger_port_is_sourcing_vbus(port) &&
+ !usb_charger_port_is_sourcing_vbus(port) &&
pd_check_vbus_level(port, VBUS_PRESENT);
if (evt & USB_CHG_EVENT_VBUS) {
diff --git a/include/config.h b/include/config.h
index c6fc62c636..66bd05622c 100644
--- a/include/config.h
+++ b/include/config.h
@@ -4828,6 +4828,9 @@
/* Allow run-time configuration of the Burnside Bridge driver structure */
#undef CONFIG_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG
+/* Enable vPro support for Intel Burnside Bridge on vPro supported platform */
+#undef CONFIG_USBC_RETIMER_INTEL_BB_VPRO_CAPABLE
+
/* Require manual configuration of the KB800x crossbar mapping. */
#undef CONFIG_KB800X_CUSTOM_XBAR
diff --git a/test/build.mk b/test/build.mk
index b2295e8913..fd7f07920c 100644
--- a/test/build.mk
+++ b/test/build.mk
@@ -111,6 +111,7 @@ test-list-host += vboot
test-list-host += version
test-list-host += x25519
test-list-host += stillness_detector
+-include private/test/build.mk
endif
# Build up the list of coverage test targets based on test-list-host, but
@@ -132,7 +133,8 @@ cov-dont-test += version
cov-dont-test += interrupt
# Flaky tests. The number of covered lines changes from run to run
# b/213374060
-cov-dont-test += accel_cal entropy float kb_mkbp rsa
+cov-dont-test += accel_cal entropy flash float kb_mkbp kb_scan kb_scan_strict
+cov-dont-test += rsa
cov-test-list-host = $(filter-out $(cov-dont-test), $(test-list-host))
diff --git a/test/run_device_tests.py b/test/run_device_tests.py
index e138051d0c..fbe2ed31a5 100755
--- a/test/run_device_tests.py
+++ b/test/run_device_tests.py
@@ -26,7 +26,7 @@ import time
from concurrent.futures.thread import ThreadPoolExecutor
from enum import Enum
from pathlib import Path
-from typing import Optional, BinaryIO, List
+from typing import Optional, BinaryIO, List, Dict
# pylint: disable=import-error
import colorama # type: ignore[import]
@@ -139,7 +139,23 @@ class AllTests:
"""All possible tests."""
@staticmethod
- def get(board_config: BoardConfig):
+ def get(board_config: BoardConfig) -> Dict[str, TestConfig]:
+ public_tests = AllTests.get_public_tests(board_config)
+ private_tests = AllTests.get_private_tests()
+
+ # Make sure there are no conflicts
+ # pylint: disable=dict-keys-not-iterating
+ overwritten_tests = public_tests.keys() & private_tests.keys()
+ # pylint: enable=dict-keys-not-iterating
+ if overwritten_tests:
+ err = 'Public test overwritten by private one with the same name: '
+ err += str(overwritten_tests)
+ raise RuntimeError(err)
+
+ return {**public_tests, **private_tests}
+
+ @staticmethod
+ def get_public_tests(board_config: BoardConfig) -> Dict[str, TestConfig]:
tests = {
'aes':
TestConfig(name='aes'),
@@ -229,6 +245,27 @@ class AllTests:
return tests
+ @staticmethod
+ def get_private_tests() -> Dict[str, TestConfig]:
+ # Return all private tests, if the folder exists
+ tests = {}
+ try:
+ current_dir = os.path.dirname(__file__)
+ private_dir = os.path.join(current_dir, os.pardir, 'private/test')
+ have_private = os.path.isdir(private_dir)
+ if not have_private:
+ return {}
+ sys.path.append(private_dir)
+ import private_tests # pylint: disable=import-error
+ for test_id, test_args in private_tests.tests.items():
+ tests[test_id] = TestConfig(**test_args)
+ # Catch all exceptions to avoid disruptions in public repo
+ except BaseException as e:
+ logging.debug('Failed to get list of private tests: %s', str(e))
+ logging.debug('Ignore error and continue.')
+ return {}
+ return tests
+
BLOONCHIPPER_CONFIG = BoardConfig(
name=BLOONCHIPPER,
diff --git a/util/build.mk b/util/build.mk
index 757aa8d16c..2948bd9d91 100644
--- a/util/build.mk
+++ b/util/build.mk
@@ -24,6 +24,7 @@ $(out)/util/uartupdatetool: HOST_CFLAGS+=-Iutil/
ifneq ("$(wildcard util/private/build.mk)","")
include util/private/build.mk
endif
+-include private/util_flags.mk
comm-objs=$(util-lock-objs:%=lock/%) comm-host.o comm-dev.o
comm-objs+=comm-lpc.o comm-i2c.o misc_util.o comm-usb.o
diff --git a/util/ectool.c b/util/ectool.c
index 479e7096a9..af116160e5 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -8033,8 +8033,9 @@ int cmd_battery(int argc, char *argv[])
printf(" Present voltage %u mV\n", val);
val = read_mapped_mem32(EC_MEMMAP_BATT_RATE);
- /* Current can be negative */
- printf(" Present current %d mA\n", val);
+ if (!is_battery_range(val))
+ goto cmd_error;
+ printf(" Present current %u mA\n", val);
val = read_mapped_mem32(EC_MEMMAP_BATT_CAP);
if (!is_battery_range(val))
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index 5502ccf868..8b727e6aca 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -49,6 +49,7 @@ rsource "Kconfig.espi"
rsource "Kconfig.flash"
rsource "Kconfig.header"
rsource "Kconfig.host_interface"
+rsource "Kconfig.i2c"
rsource "Kconfig.init_priority"
rsource "Kconfig.ioex"
rsource "Kconfig.keyboard"
@@ -421,81 +422,6 @@ config HCDEBUG_PARAMS
endchoice # PLATFORM_EC_HOSTCMD_DEBUG_MODE
-config PLATFORM_EC_I2C
- bool "I2C shim"
- default n if ARCH_POSIX
- default y
- imply I2C
- help
- Enable compilation of the EC i2c module. Once enabled, it will be
- possible to make calls using the old platform/ec i2c APIs defined
- in include/i2c.h and implemented in common/i2c_controller.c. Doing so
- should make shimming other platform/ec modules which rely on i2c
- communication "just work" without requiring any further code changes.
-
-config PLATFORM_EC_I2C_DEBUG
- bool "I2C Tracing"
- default n if ARCH_POSIX
- depends on PLATFORM_EC_I2C
- help
- This option enables I2C bus communication tracing. Use the console
- command "i2ctrace" to enable and disable tracing on specific I2C
- peripherals.
-
- Please see the I2C debugging documentation for more details:
-
- https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/docs/i2c-debugging.md
-
-config PLATFORM_EC_I2C_DEBUG_PASSTHRU
- bool "I2C Passthru Debug"
- default n if ARCH_POSIX
- depends on PLATFORM_EC_I2C
- help
- This option enables extra debug for I2C passthru operations initiated
- by the AP.
-
-config PLATFORM_EC_CONSOLE_CMD_I2C_PORTMAP
- bool "Console command: i2c_portmap"
- default y
- depends on PLATFORM_EC_I2C
- help
- Enable the 'i2c_portmap' console command. This comamnd is used to
- display the mapping of the I2C ports defined by the named-i2c-ports
- node to the physical port and remote port indexes.
-
-config PLATFORM_EC_CONSOLE_CMD_I2C_SPEED
- bool "Console command: i2cspeed"
- default n
- depends on PLATFORM_EC_I2C
- help
- Enable the 'i2cspeed' console command. This comamnd is used to
- display an I2C port's bus speed. Additionally, for ports with
- the DYNAMIC_SPEED port flag set, the speed can be set. In all
- cases, the bus speed is in units of kHz.
-
-config PLATFORM_EC_HOSTCMD_I2C_CONTROL
- bool "Host command: i2c_control"
- default n
- depends on PLATFORM_EC_I2C
- help
- Enable the I2C_CONTROL host command. This comamnd is used to
- display an I2C port's bus speed. Additionally, for ports with
- the DYNAMIC_SPEED port flag set, the speed can be set. In all
- cases, the bus speed is in units of kHz. More functionality of
- the command may be added in the future.
-
-config PLATFORM_EC_SMBUS_PEC
- bool "Packet error checking support for SMBus"
- help
- If enabled, adds error checking support for i2c_readN, i2c_writeN,
- i2c_read_string and i2c_write_block. Where
- - write operation appends an error checking byte at end of transfer, and
- - read operatoin verifies the correctness of error checking byte from the
- peripheral.
- Set I2C_FLAG on addr_flags parameter to use this feature.
-
- This option also enables error checking function on smart batteries.
-
config PLATFORM_EC_LID_SWITCH
bool "Lid switch"
help
@@ -837,14 +763,6 @@ config PLATFORM_EC_CCD_USBC_PORT_NUMBER
help
USB port number of the CCD enabled USBC port.
-config PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
- bool "Restrict I2C PASSTHRU command"
- depends on PLATFORM_EC_I2C
- help
- Enables board-specific restrictions for the I2C PASSTHRU host command.
- Once enabled, board_allow_i2c_passthru function has to be implemented,
- which defines the allowed usage of the command.
-
config PLATFORM_EC_HOST_COMMAND_STATUS
bool "Return in-progress status for slow host commands"
default y if PLATFORM_EC_HOST_INTERFACE_SHI
diff --git a/zephyr/Kconfig.cbi b/zephyr/Kconfig.cbi
index 7236916938..0ab5025a97 100644
--- a/zephyr/Kconfig.cbi
+++ b/zephyr/Kconfig.cbi
@@ -34,12 +34,10 @@ choice PLATFORM_EC_CBI_STORAGE_TYPE
config PLATFORM_EC_CBI_EEPROM
bool "CBI EEPROM support"
- depends on PLATFORM_EC_I2C
+ depends on EEPROM
help
- Enables Chromium OS Board Info (CBI) from EEPROM.
-
- One must specify both I2C_PORT_EEPROM and I2C_ADDR_EEPROM_FLAGS to the
- CBI EEPROM's i2c port and 7-bit i2c address.
+ Enables full Chromium OS Board Info (CBI) support, with CBI data
+ stored in an on-board EEPROM.
config PLATFORM_EC_CBI_GPIO
bool "CBI GPIO support"
diff --git a/zephyr/Kconfig.charger b/zephyr/Kconfig.charger
index 232e3030df..8b1b15d4ff 100644
--- a/zephyr/Kconfig.charger
+++ b/zephyr/Kconfig.charger
@@ -9,8 +9,7 @@ menuconfig PLATFORM_EC_CHARGER
select PLATFORM_EC_EXTPOWER
depends on PLATFORM_EC_BATTERY
help
- Enable the EC charging task. This enables compilation of the
- charge_state_v2 code.
+ Enable the EC charging task.
if PLATFORM_EC_CHARGER
@@ -57,7 +56,8 @@ config PLATFORM_EC_CHARGE_MANAGER
barrel jack connector), BC1.2 (Battery Charging 1.2) sources, and
USB-C sources. When multiple charge sources are connected to a
Chromebook simultaneously, the charge manager is responsible for
- picking the best source.
+ picking the best source. This also enables compilation of the
+ charge_state_v2 code.
Note that the charge manager assumes that at least one USB-C power
source is available on the hardware, so cannot be built without
diff --git a/zephyr/Kconfig.i2c b/zephyr/Kconfig.i2c
new file mode 100644
index 0000000000..23ccf88bd0
--- /dev/null
+++ b/zephyr/Kconfig.i2c
@@ -0,0 +1,77 @@
+# Copyright 2022 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+config PLATFORM_EC_I2C
+ def_bool I2C
+ help
+ Enable compilation of the EC i2c module. Once enabled, it will be
+ possible to make calls using the old platform/ec i2c APIs defined
+ in include/i2c.h and implemented in common/i2c_controller.c. Doing so
+ should make shimming other platform/ec modules which rely on i2c
+ communication "just work" without requiring any further code changes.
+
+if PLATFORM_EC_I2C
+
+config PLATFORM_EC_I2C_DEBUG
+ bool "I2C Tracing"
+ help
+ This option enables I2C bus communication tracing. Use the console
+ command "i2ctrace" to enable and disable tracing on specific I2C
+ peripherals.
+
+ Please see the I2C debugging documentation for more details:
+
+ https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/docs/i2c-debugging.md
+
+config PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
+ bool "Restrict I2C PASSTHRU command"
+ help
+ Enables board-specific restrictions for the I2C PASSTHRU host command.
+ Once enabled, board_allow_i2c_passthru function has to be implemented,
+ which defines the allowed usage of the command.
+
+config PLATFORM_EC_I2C_DEBUG_PASSTHRU
+ bool "I2C Passthru Debug"
+ help
+ This option enables extra debug for I2C passthru operations initiated
+ by the AP.
+
+config PLATFORM_EC_CONSOLE_CMD_I2C_PORTMAP
+ bool "Console command: i2c_portmap"
+ default y
+ help
+ Enable the 'i2c_portmap' console command. This comamnd is used to
+ display the mapping of the I2C ports defined by the named-i2c-ports
+ node to the physical port and remote port indexes.
+
+config PLATFORM_EC_CONSOLE_CMD_I2C_SPEED
+ bool "Console command: i2cspeed"
+ help
+ Enable the 'i2cspeed' console command. This comamnd is used to
+ display an I2C port's bus speed. Additionally, for ports with
+ the DYNAMIC_SPEED port flag set, the speed can be set. In all
+ cases, the bus speed is in units of kHz.
+
+config PLATFORM_EC_HOSTCMD_I2C_CONTROL
+ bool "Host command: i2c_control"
+ help
+ Enable the I2C_CONTROL host command. This comamnd is used to
+ display an I2C port's bus speed. Additionally, for ports with
+ the DYNAMIC_SPEED port flag set, the speed can be set. In all
+ cases, the bus speed is in units of kHz. More functionality of
+ the command may be added in the future.
+
+config PLATFORM_EC_SMBUS_PEC
+ bool "Packet error checking support for SMBus"
+ help
+ If enabled, adds error checking support for i2c_readN, i2c_writeN,
+ i2c_read_string and i2c_write_block. Where
+ - write operation appends an error checking byte at end of transfer, and
+ - read operatoin verifies the correctness of error checking byte from the
+ peripheral.
+ Set I2C_FLAG on addr_flags parameter to use this feature.
+
+ This option also enables error checking function on smart batteries.
+
+endif # PLATFORM_EC_I2C
diff --git a/zephyr/Kconfig.retimer b/zephyr/Kconfig.retimer
index 8a69a64866..8233b6fe2b 100644
--- a/zephyr/Kconfig.retimer
+++ b/zephyr/Kconfig.retimer
@@ -39,6 +39,15 @@ config PLATFORM_EC_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG
factory. Without this, multiple EC images would need to be installed
depending on the board.
+config PLATFORM_EC_USBC_RETIMER_INTEL_BB_VPRO_CAPABLE
+ bool "Enable vPro support for Intel Burnside Bridge"
+ depends on PLATFORM_EC_USBC_RETIMER_INTEL_BB
+ default n
+ help
+ Enable this config for Intel vPro supported platforms. It allows to
+ configure the Burnside Bridge retimer to support vPro, when connected
+ dock supports vPro.
+
config PLATFORM_EC_USBC_RETIMER_ANX7451
bool "Support Analogix ANX7451 10G Active Mux and Retimer"
help
diff --git a/zephyr/Kconfig.usba b/zephyr/Kconfig.usba
index 1d7d9027d6..cca91ef787 100644
--- a/zephyr/Kconfig.usba
+++ b/zephyr/Kconfig.usba
@@ -15,18 +15,8 @@ menuconfig PLATFORM_EC_USBA
if PLATFORM_EC_USBA
-config PLATFORM_EC_USB_A_PORT_COUNT
- int "Number of USB-A ports"
- default 0
- help
- This sets the number of USB-A ports on the device. These ports do
- not support USB Power Delivery features but can be used to power
- external devices (according to the USB 3 spec, not the Battery Charger
- standard) and to charge devices slowly if power is enabled to them.
-
choice
prompt "Port power control mode"
- depends on PLATFORM_EC_USB_A_PORT_COUNT > 0
config PLATFORM_EC_USB_PORT_POWER_DUMB
bool "Dumb"
diff --git a/zephyr/boards/arm/brya/Kconfig.board b/zephyr/boards/arm/brya/Kconfig.board
deleted file mode 100644
index 8add483941..0000000000
--- a/zephyr/boards/arm/brya/Kconfig.board
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# "BOARD" below refers to a Zephyr board, which does not have a 1:1
-# mapping with the Chrome OS concept of a board. By Zephyr's
-# conventions, we'll still call it "BOARD_*" to make this more
-# applicable to be upstreamed, even though this code is shared by all
-# projects using Brya baseboard.
-config BOARD_BRYA
- bool "Google Brya Baseboard"
- depends on SOC_NPCX9M3F
- # NPCX doesn't actually have enough ram for coverage, but this will
- # allow generating initial 0 line coverage.
- select HAS_COVERAGE_SUPPORT
diff --git a/zephyr/boards/arm/brya/Kconfig.defconfig b/zephyr/boards/arm/brya/Kconfig.defconfig
deleted file mode 100644
index e4de179311..0000000000
--- a/zephyr/boards/arm/brya/Kconfig.defconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if BOARD_BRYA
-
-config BOARD
- default "brya"
-
-endif # BOARD_BRYA
diff --git a/zephyr/boards/arm/brya/board.cmake b/zephyr/boards/arm/brya/board.cmake
deleted file mode 100644
index 67ade59f57..0000000000
--- a/zephyr/boards/arm/brya/board.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-set(NPCX_IMAGE_FILE ${PROJECT_BINARY_DIR}/zephyr.npcx.bin)
-
diff --git a/zephyr/boards/arm/brya/brya.dts b/zephyr/boards/arm/brya/brya.dts
deleted file mode 100644
index 096aeab0ab..0000000000
--- a/zephyr/boards/arm/brya/brya.dts
+++ /dev/null
@@ -1,320 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/dts-v1/;
-
-#include <cros/nuvoton/npcx9.dtsi>
-#include <cros/thermistor/thermistor.dtsi>
-#include <dt-bindings/gpio_defines.h>
-#include <nuvoton/npcx9m3f.dtsi>
-
-/ {
- model = "Google Brya Baseboard";
-
- aliases {
- i2c-0 = &i2c0_0;
- i2c-1 = &i2c1_0;
- i2c-2 = &i2c2_0;
- i2c-3 = &i2c3_0;
- i2c-4 = &i2c4_1;
- i2c-5 = &i2c5_0;
- i2c-6 = &i2c6_1;
- i2c-7 = &i2c7_0;
- };
-
- chosen {
- zephyr,sram = &sram0;
- zephyr,console = &uart1;
- zephyr,shell-uart = &uart1;
- zephyr,flash = &flash0;
- zephyr,flash-controller = &int_flash;
- cros,rtc = &mtc;
- };
-
- ec-console {
- compatible = "ec-console";
- disabled = "events", "lpc", "hostcmd";
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
- i2c_sensor: sensor {
- i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_SENSOR";
- };
- tcpc0_2: tcpc0_2 {
- i2c-port = <&i2c1_0>;
- enum-name = "I2C_PORT_USB_C0_C2_TCPC";
- };
- tcpc1 {
- i2c-port = <&i2c4_1>;
- enum-name = "I2C_PORT_USB_C1_TCPC";
- dynamic-speed;
- };
- ppc0_2: ppc0_2 {
- i2c-port = <&i2c2_0>;
- enum-name = "I2C_PORT_USB_C0_C2_PPC";
- };
- ppc1: ppc1 {
- i2c-port = <&i2c6_1>;
- enum-name = "I2C_PORT_USB_C1_PPC";
- dynamic-speed;
- };
- retimer0_2 {
- i2c-port = <&i2c3_0>;
- enum-name = "I2C_PORT_USB_C0_C2_MUX";
- };
- battery {
- i2c-port = <&i2c5_0>;
- enum-name = "I2C_PORT_BATTERY";
- };
- eeprom {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_EEPROM";
- };
- charger {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_CHARGER";
- };
- c1_bc12: c1_bc12 {
- i2c-port = <&i2c6_1>;
- enum-name = "I2C_PORT_USB_C1_BC12";
- };
- c0_c2_bc12: c0_c2_bc12 {
- i2c-port = <&i2c2_0>;
- enum-name = "I2C_PORT_USB_C0_C2_BC12";
- };
- mp2964 {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_MP2964";
- };
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- adc_ddr_soc: ddr_soc {
- label = "TEMP_DDR_SOC";
- enum-name = "ADC_TEMP_SENSOR_1_DDR_SOC";
- io-channels = <&adc0 0>;
- };
- adc_ambient: ambient {
- label = "TEMP_AMBIENT";
- enum-name = "ADC_TEMP_SENSOR_2_AMBIENT";
- io-channels = <&adc0 1>;
- };
- adc_charger: charger {
- label = "TEMP_CHARGER";
- enum-name = "ADC_TEMP_SENSOR_3_CHARGER";
- io-channels = <&adc0 6>;
- };
- adc_wwan: wwan {
- label = "TEMP_WWAN";
- enum-name = "ADC_TEMP_SENSOR_4_WWAN";
- io-channels = <&adc0 7>;
- };
- };
-
- named-temp-sensors {
- ddr_soc {
- compatible = "cros-ec,temp-sensor-thermistor",
- "cros-ec,temp-sensor";
- thermistor = <&thermistor_3V3_30K9_47K_4050B>;
- label = "DDR and SOC";
- enum-name = "TEMP_SENSOR_1_DDR_SOC";
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- adc = <&adc_ddr_soc>;
- };
- ambient {
- compatible = "cros-ec,temp-sensor-thermistor",
- "cros-ec,temp-sensor";
- thermistor = <&thermistor_3V3_30K9_47K_4050B>;
- label = "Ambient";
- enum-name = "TEMP_SENSOR_2_AMBIENT";
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- adc = <&adc_ambient>;
- };
- charger {
- compatible = "cros-ec,temp-sensor-thermistor",
- "cros-ec,temp-sensor";
- thermistor = <&thermistor_3V3_30K9_47K_4050B>;
- label = "Charger";
- enum-name = "TEMP_SENSOR_3_CHARGER";
- temp_fan_off = <35>;
- temp_fan_max = <65>;
- temp_host_high = <105>;
- temp_host_halt = <120>;
- temp_host_release_high = <90>;
- adc = <&adc_charger>;
- };
- wwan {
- compatible = "cros-ec,temp-sensor-thermistor",
- "cros-ec,temp-sensor";
- thermistor = <&thermistor_3V3_30K9_47K_4050B>;
- label = "WWAN";
- enum-name = "TEMP_SENSOR_4_WWAN";
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <130>;
- temp_host_halt = <130>;
- temp_host_release_high = <100>;
- adc = <&adc_wwan>;
- };
- };
-
- vsby-psl-in-list {
- /* Use PSL_IN1/2/3 as detection pins from hibernate mode */
- psl-in-pads = <&psl_in1 &psl_in2 &psl_in3>;
- status = "okay";
- };
-
- def-lvol-io-list {
- compatible = "nuvoton,npcx-lvolctrl-def";
- };
-};
-
-&uart1 {
- status = "okay";
- current-speed = <115200>;
- pinctrl-0 = <&altj_cr_sin1_sl2 &altj_cr_sout1_sl2>;
-};
-
-&i2c0_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c1_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c2_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl2 {
- status = "okay";
-};
-
-&i2c3_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&i2c4_1 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl4 {
- status = "okay";
-};
-
-&i2c5_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c_ctrl5 {
- status = "okay";
-};
-
-&i2c6_1 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl6 {
- status = "okay";
-};
-
-&i2c7_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- pmic_mp2964: pmic_mp2964@20 {
- compatible = "mps,mp2964";
- reg = <0x20>;
- label = "I2C_ADDR_MP2964_FLAGS";
- };
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
-
-&cros_kb_raw {
- status = "okay";
- /* No KSO2 (it's inverted and implemented by GPIO) */
- pinctrl-0 = <&alt7_no_ksi0_sl
- &alt7_no_ksi1_sl
- &alt7_no_ksi2_sl
- &alt7_no_ksi3_sl
- &alt7_no_ksi4_sl
- &alt7_no_ksi5_sl
- &alt7_no_ksi6_sl
- &alt7_no_ksi7_sl
- &alt8_no_kso00_sl
- &alt8_no_kso01_sl
- &alt8_no_kso03_sl
- &alt8_no_kso04_sl
- &alt8_no_kso05_sl
- &alt8_no_kso06_sl
- &alt8_no_kso07_sl
- &alt9_no_kso08_sl
- &alt9_no_kso09_sl
- &alt9_no_kso10_sl
- &alt9_no_kso11_sl
- &alt9_no_kso12_sl
- &alt9_no_kso13_sl
- &alt9_no_kso14_sl
- >;
-};
-
-&adc0 {
- status = "okay";
-};
-
-/* Power switch logic input pads */
-/* LID_OPEN_OD */
-&psl_in1 {
- flag = <NPCX_PSL_RISING_EDGE>;
-};
-
-/* ACOK_EC_OD */
-&psl_in2 {
- flag = <NPCX_PSL_RISING_EDGE>;
-};
-
-/* GSC_EC_PWR_BTN_ODL */
-&psl_in3 {
- flag = <NPCX_PSL_FALLING_EDGE>;
-};
-
-&thermistor_3V3_30K9_47K_4050B {
- status = "okay";
-};
diff --git a/zephyr/boards/arm/brya/brya_defconfig b/zephyr/boards/arm/brya/brya_defconfig
deleted file mode 100644
index 16b0b44372..0000000000
--- a/zephyr/boards/arm/brya/brya_defconfig
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Kernel Configuration
-CONFIG_SOC_SERIES_NPCX9=y
-
-# Platform Configuration
-CONFIG_SOC_NPCX9M3F=y
-CONFIG_BOARD_BRYA=y
-
-# Serial Drivers
-CONFIG_SERIAL=y
-CONFIG_UART_INTERRUPT_DRIVEN=y
-
-# Enable console
-CONFIG_CONSOLE=y
-CONFIG_UART_CONSOLE=y
-
-# Pinmux Driver
-CONFIG_PINMUX=y
-
-# GPIO Controller
-CONFIG_GPIO=y
-
-# Clock configuration
-CONFIG_CLOCK_CONTROL=y
-
-# Power Management
-CONFIG_PM=y
-CONFIG_PM_DEVICE=y
-CONFIG_PM_POLICY_CUSTOM=y
-CONFIG_UART_CONSOLE_INPUT_EXPIRED=y
-CONFIG_NPCX_PM_TRACE=y
-
-# WATCHDOG configuration
-CONFIG_WATCHDOG=y
-
-# BBRAM
-CONFIG_BBRAM=y
-CONFIG_BBRAM_NPCX=y
-
-# SPI
-CONFIG_SPI=y
-
-# Flash
-CONFIG_FLASH=y
-CONFIG_SPI_NOR=y
-CONFIG_FLASH_JESD216_API=y
diff --git a/zephyr/boards/riscv/it8xxx2/it8xxx2_defconfig b/zephyr/boards/riscv/it8xxx2/it8xxx2_defconfig
index c370db274e..9650d50caf 100644
--- a/zephyr/boards/riscv/it8xxx2/it8xxx2_defconfig
+++ b/zephyr/boards/riscv/it8xxx2/it8xxx2_defconfig
@@ -44,8 +44,8 @@ CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=y
CONFIG_SOC_FLASH_ITE_IT8XXX2=y
# I2C
+CONFIG_I2C=y
CONFIG_I2C_ITE_IT8XXX2=y
-CONFIG_PLATFORM_EC_I2C=y
# Pinmux Driver
CONFIG_PINMUX=y
diff --git a/zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb.dts b/zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb.dts
index 1c24c1cf45..d106ece265 100644
--- a/zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb.dts
+++ b/zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb.dts
@@ -20,6 +20,15 @@
zephyr,flash-controller = &flashctrl;
};
+ pwmleds {
+ compatible = "pwm-leds";
+
+ /* NOTE: &pwm number needs same with channel number */
+ pwm_led_test: pwm_led_test {
+ pwms = <&pwm0 PWM_CHANNEL_0 PWM_POLARITY_NORMAL>;
+ };
+ };
+
aliases {
gpio-wp = &gpio_wp;
};
@@ -142,20 +151,6 @@
};
};
- named-pwms {
- compatible = "named-pwms";
-
- /* NOTE: &pwm number needs same with channel number */
- pwm_test: test {
- pwms = <&pwm0 PWM_CHANNEL_0 PWM_POLARITY_NORMAL>;
- /*
- * If we need pwm output in ITE chip power saving
- * mode, then we should set frequency <=324Hz.
- */
- frequency = <324>;
- };
- };
-
named-fans {
compatible = "named-fans";
diff --git a/zephyr/drivers/cros_rtc/Kconfig b/zephyr/drivers/cros_rtc/Kconfig
index 679728313b..99cdb6b47d 100644
--- a/zephyr/drivers/cros_rtc/Kconfig
+++ b/zephyr/drivers/cros_rtc/Kconfig
@@ -26,14 +26,14 @@ config CROS_RTC_XEC
config CROS_RTC_NXP_PCF85063A
bool "NXP PCF85063A Real-Time Clock (RTC) driver for the Zephyr shim"
- depends on PLATFORM_EC_I2C
+ depends on I2C
help
This option enables a driver for providing the support of NXP
Real-Time Clock (RTC) on the the I2C bus.
config CROS_RTC_RENESAS_IDT1337AG
bool "RENESAS IDT1337AG Real-Time Clock (RTC) driver for the Zephyr shim"
- depends on PLATFORM_EC_I2C
+ depends on I2C
help
This option enables a driver for providing the support of RENESAS
Real-Time Clock (RTC) on the the I2C bus.
diff --git a/zephyr/dts/bindings/battery/battery-smart.yaml b/zephyr/dts/bindings/battery/battery-smart.yaml
index dd0c30dfc3..8e97d010e0 100644
--- a/zephyr/dts/bindings/battery/battery-smart.yaml
+++ b/zephyr/dts/bindings/battery/battery-smart.yaml
@@ -23,6 +23,7 @@ properties:
- "murata,ap18c4k"
- "panasonic,ap16l5j"
- "panasonic,ap16l5j-009"
+ - "panasonic,ap19a5k"
- "powertech,batgqa05l22"
- "smp,l20m3pg0"
- "smp,l20m3pg1"
diff --git a/zephyr/dts/bindings/battery/panasonic,ap19a5k.yaml b/zephyr/dts/bindings/battery/panasonic,ap19a5k.yaml
new file mode 100644
index 0000000000..6da0cecf7c
--- /dev/null
+++ b/zephyr/dts/bindings/battery/panasonic,ap19a5k.yaml
@@ -0,0 +1,59 @@
+description: "Panasonic KT00305012 AP19A5K"
+compatible: "panasonic,ap19a5k"
+
+include: battery-smart.yaml
+
+properties:
+ enum-name:
+ type: string
+ default: "panasonic,ap19a5k"
+
+ # Fuel gauge
+ manuf_name:
+ default: "PANASONIC KT00305012"
+ device_name:
+ default: "AP19A5K"
+ ship_mode_reg_addr:
+ default: 0x3A
+ ship_mode_reg_data:
+ default: [ 0xC574, 0xC574 ]
+ # Documentation: b/224888442
+ # ManufacturerAccess() 0x00
+ # Bit14 Discharge FET status
+ # Set - Discharge FET is ON, Reset - Discharge FET is OFF
+ # Bit15 Charge FET status
+ # Set - Charge FET is ON, Reset - Charge FET is OFF
+ fet_mfgacc_support:
+ default: 0
+ fet_reg_addr:
+ default: 0x0
+ fet_reg_mask:
+ default: 0x4000
+ fet_disconnect_val:
+ default: 0x0000
+ fet_cfet_mask:
+ default: 0x8000
+ fet_cfet_off_val:
+ default: 0x0000
+
+ # Battery info
+ voltage_max:
+ default: 13200
+ voltage_normal:
+ default: 7700
+ voltage_min:
+ default: 6000
+ precharge_current:
+ default: 256
+ start_charging_min_c:
+ default: 0
+ start_charging_max_c:
+ default: 50
+ charging_min_c:
+ default: 0
+ charging_max_c:
+ default: 60
+ discharging_min_c:
+ default: -20
+ discharging_max_c:
+ default: 75
diff --git a/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml b/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml
index 238be08782..7c625bf401 100644
--- a/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml
+++ b/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml
@@ -20,6 +20,7 @@ child-binding:
led-color:
type: string
required: true
+ description: Used to link the color nodes with the pin nodes
enum:
- LED_OFF
- LED_RED
@@ -28,6 +29,18 @@ child-binding:
- LED_YELLOW
- LED_WHITE
- LED_AMBER
+ br-color:
+ type: string
+ required: false
+ description: This is used in the ectool brightness range APIs.
+ It needs to match the enum names defined in ec_commands.h
+ enum:
+ - EC_LED_COLOR_RED
+ - EC_LED_COLOR_GREEN
+ - EC_LED_COLOR_BLUE
+ - EC_LED_COLOR_YELLOW
+ - EC_LED_COLOR_WHITE
+ - EC_LED_COLOR_AMBER
led-pins:
type: phandle-array
required: false
diff --git a/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml b/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml
index deabf0227f..3b083fb79d 100644
--- a/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml
+++ b/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml
@@ -26,6 +26,7 @@ child-binding:
led-color:
type: string
required: true
+ description: Used to link the color nodes with the pin nodes
enum:
- LED_OFF
- LED_RED
@@ -34,6 +35,18 @@ child-binding:
- LED_YELLOW
- LED_WHITE
- LED_AMBER
+ br-color:
+ type: string
+ required: false
+ description: This is used in the ectool brightness range APIs.
+ It needs to match the enum names defined in ec_commands.h
+ enum:
+ - EC_LED_COLOR_RED
+ - EC_LED_COLOR_GREEN
+ - EC_LED_COLOR_BLUE
+ - EC_LED_COLOR_YELLOW
+ - EC_LED_COLOR_WHITE
+ - EC_LED_COLOR_AMBER
led-pins:
type: phandle-array
required: false
diff --git a/zephyr/projects/brya/BUILD.py b/zephyr/projects/brya/BUILD.py
index 4e2a556234..da7e8b1d49 100644
--- a/zephyr/projects/brya/BUILD.py
+++ b/zephyr/projects/brya/BUILD.py
@@ -2,21 +2,42 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-brya = register_npcx_project(
+
+def register_npcx9_variant(project_name, extra_dts_overlays=(), extra_kconfig_files=()):
+ return register_npcx_project(
+ project_name=project_name,
+ zephyr_board="npcx9",
+ dts_overlays=[
+ "adc.dts",
+ "battery.dts",
+ "bb_retimer.dts",
+ "cbi_eeprom.dts",
+ "fan.dts",
+ "gpio.dts",
+ "i2c.dts",
+ "interrupts.dts",
+ "keyboard.dts",
+ "motionsense.dts",
+ "pwm_leds.dts",
+ "temp_sensors.dts",
+ "usbc.dts",
+ # Project-specific DTS customization.
+ *extra_dts_overlays,
+ ],
+ kconfig_files=[
+ # Common to all projects.
+ here / "prj.conf",
+ # Project-specific KConfig customization.
+ *extra_kconfig_files,
+ ],
+ )
+
+
+brya = register_npcx9_variant(
project_name="brya",
- zephyr_board="brya",
- dts_overlays=[
- "battery.dts",
- "bb_retimer.dts",
- "cbi_eeprom.dts",
- "fan.dts",
- "gpio.dts",
- "interrupts.dts",
- "keyboard.dts",
- "motionsense.dts",
- "pwm_leds.dts",
- "usbc.dts",
- ],
+ extra_dts_overlays=[here / "brya.dts"],
+ extra_kconfig_files=[here / "prj_brya.conf"],
)
+
ghost = brya.variant(project_name="ghost")
diff --git a/zephyr/projects/brya/Kconfig b/zephyr/projects/brya/Kconfig
new file mode 100644
index 0000000000..111476eb42
--- /dev/null
+++ b/zephyr/projects/brya/Kconfig
@@ -0,0 +1,11 @@
+# Copyright 2022 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+config BOARD_BRYA
+ bool "Google Brya Baseboard"
+ help
+ Build Google Brya reference board. The board uses the Nuvuton NPCX9
+ chip as the EC.
+
+source "Kconfig.zephyr"
diff --git a/zephyr/projects/brya/adc.dts b/zephyr/projects/brya/adc.dts
new file mode 100644
index 0000000000..932aa59e9f
--- /dev/null
+++ b/zephyr/projects/brya/adc.dts
@@ -0,0 +1,35 @@
+/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ named-adc-channels {
+ compatible = "named-adc-channels";
+
+ adc_ddr_soc: ddr_soc {
+ label = "TEMP_DDR_SOC";
+ enum-name = "ADC_TEMP_SENSOR_1_DDR_SOC";
+ io-channels = <&adc0 0>;
+ };
+ adc_ambient: ambient {
+ label = "TEMP_AMBIENT";
+ enum-name = "ADC_TEMP_SENSOR_2_AMBIENT";
+ io-channels = <&adc0 1>;
+ };
+ adc_charger: charger {
+ label = "TEMP_CHARGER";
+ enum-name = "ADC_TEMP_SENSOR_3_CHARGER";
+ io-channels = <&adc0 6>;
+ };
+ adc_wwan: wwan {
+ label = "TEMP_WWAN";
+ enum-name = "ADC_TEMP_SENSOR_4_WWAN";
+ io-channels = <&adc0 7>;
+ };
+ };
+};
+
+&adc0 {
+ status = "okay";
+};
diff --git a/zephyr/projects/brya/brya.dts b/zephyr/projects/brya/brya.dts
new file mode 100644
index 0000000000..beac027083
--- /dev/null
+++ b/zephyr/projects/brya/brya.dts
@@ -0,0 +1,18 @@
+/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ model = "Google Brya Baseboard";
+
+ chosen {
+ cros,rtc = &mtc;
+ };
+
+ ec-console {
+ compatible = "ec-console";
+ disabled = "events", "lpc", "hostcmd";
+ };
+};
+
diff --git a/zephyr/projects/brya/gpio.dts b/zephyr/projects/brya/gpio.dts
index 2df6e38164..d4fb2d9d8a 100644
--- a/zephyr/projects/brya/gpio.dts
+++ b/zephyr/projects/brya/gpio.dts
@@ -304,6 +304,12 @@
compatible = "cros-ec,usba-port-enable-pins";
enable-pins = <&gpio_en_pp5000_usba_r>;
};
+
+ vsby-psl-in-list {
+ /* Use PSL_IN1/2/3 as detection pins from hibernate mode */
+ psl-in-pads = <&psl_in1 &psl_in2 &psl_in3>;
+ status = "okay";
+ };
};
&i2c1_0 {
@@ -354,3 +360,19 @@
label = "NCT3808_ALERT_1";
};
};
+
+/* Power switch logic input pads */
+/* LID_OPEN_OD */
+&psl_in1 {
+ flag = <NPCX_PSL_RISING_EDGE>;
+};
+
+/* ACOK_EC_OD */
+&psl_in2 {
+ flag = <NPCX_PSL_RISING_EDGE>;
+};
+
+/* GSC_EC_PWR_BTN_ODL */
+&psl_in3 {
+ flag = <NPCX_PSL_FALLING_EDGE>;
+};
diff --git a/zephyr/projects/brya/i2c.dts b/zephyr/projects/brya/i2c.dts
new file mode 100644
index 0000000000..86536d64aa
--- /dev/null
+++ b/zephyr/projects/brya/i2c.dts
@@ -0,0 +1,138 @@
+/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ named-i2c-ports {
+ compatible = "named-i2c-ports";
+ i2c_sensor: sensor {
+ i2c-port = <&i2c0_0>;
+ enum-name = "I2C_PORT_SENSOR";
+ };
+ tcpc0_2: tcpc0_2 {
+ i2c-port = <&i2c1_0>;
+ enum-name = "I2C_PORT_USB_C0_C2_TCPC";
+ };
+ tcpc1 {
+ i2c-port = <&i2c4_1>;
+ enum-name = "I2C_PORT_USB_C1_TCPC";
+ dynamic-speed;
+ };
+ ppc0_2: ppc0_2 {
+ i2c-port = <&i2c2_0>;
+ enum-name = "I2C_PORT_USB_C0_C2_PPC";
+ };
+ ppc1: ppc1 {
+ i2c-port = <&i2c6_1>;
+ enum-name = "I2C_PORT_USB_C1_PPC";
+ dynamic-speed;
+ };
+ retimer0_2 {
+ i2c-port = <&i2c3_0>;
+ enum-name = "I2C_PORT_USB_C0_C2_MUX";
+ };
+ battery {
+ i2c-port = <&i2c5_0>;
+ enum-name = "I2C_PORT_BATTERY";
+ };
+ eeprom {
+ i2c-port = <&i2c7_0>;
+ enum-name = "I2C_PORT_EEPROM";
+ };
+ charger {
+ i2c-port = <&i2c7_0>;
+ enum-name = "I2C_PORT_CHARGER";
+ };
+ c1_bc12: c1_bc12 {
+ i2c-port = <&i2c6_1>;
+ enum-name = "I2C_PORT_USB_C1_BC12";
+ };
+ c0_c2_bc12: c0_c2_bc12 {
+ i2c-port = <&i2c2_0>;
+ enum-name = "I2C_PORT_USB_C0_C2_BC12";
+ };
+ mp2964 {
+ i2c-port = <&i2c7_0>;
+ enum-name = "I2C_PORT_MP2964";
+ };
+ };
+};
+
+&i2c0_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+};
+
+&i2c_ctrl0 {
+ status = "okay";
+};
+
+&i2c1_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+};
+
+&i2c_ctrl1 {
+ status = "okay";
+};
+
+&i2c2_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+};
+
+&i2c_ctrl2 {
+ status = "okay";
+};
+
+&i2c3_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+};
+
+&i2c_ctrl3 {
+ status = "okay";
+};
+
+&i2c4_1 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+};
+
+&i2c_ctrl4 {
+ status = "okay";
+};
+
+&i2c5_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+};
+
+&i2c_ctrl5 {
+ status = "okay";
+};
+
+&i2c6_1 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+};
+
+&i2c_ctrl6 {
+ status = "okay";
+};
+
+&i2c7_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ pmic_mp2964: pmic_mp2964@20 {
+ compatible = "mps,mp2964";
+ reg = <0x20>;
+ label = "I2C_ADDR_MP2964_FLAGS";
+ };
+};
+
+&i2c_ctrl7 {
+ status = "okay";
+};
diff --git a/zephyr/projects/brya/prj.conf b/zephyr/projects/brya/prj.conf
index 3ad742028d..f4f7569458 100644
--- a/zephyr/projects/brya/prj.conf
+++ b/zephyr/projects/brya/prj.conf
@@ -15,7 +15,6 @@ CONFIG_PLATFORM_EC_VBOOT_EFS2=y
CONFIG_PLATFORM_EC_VBOOT_HASH=y
CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y
-CONFIG_PLATFORM_EC_I2C=y
CONFIG_PLATFORM_EC_ADC_CHANNELS_RUNTIME_CONFIG=y
@@ -39,6 +38,9 @@ CONFIG_ESPI=y
CONFIG_PLATFORM_EC_ESPI_VW_SLP_S4=y
CONFIG_PLATFORM_EC_ESPI_VW_SLP_S5=y
+# I2C
+CONFIG_I2C=y
+
# Power Sequencing
CONFIG_PLATFORM_EC_POWERSEQ=y
CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET=y
@@ -158,7 +160,6 @@ CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y
CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y
CONFIG_PLATFORM_EC_USBC_PPC_DEDICATED_INT=y
CONFIG_PLATFORM_EC_USBA=y
-CONFIG_PLATFORM_EC_USB_A_PORT_COUNT=1
CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB=y
CONFIG_PLATFORM_EC_CONSOLE_CMD_PPC_DUMP=n
CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n
diff --git a/zephyr/projects/brya/prj_brya.conf b/zephyr/projects/brya/prj_brya.conf
new file mode 100644
index 0000000000..48f98f479d
--- /dev/null
+++ b/zephyr/projects/brya/prj_brya.conf
@@ -0,0 +1,6 @@
+# Copyright 2022 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# BRYA-NPCX9 reference-board-specific Kconfig settings.
+CONFIG_BOARD_BRYA=y
diff --git a/zephyr/projects/brya/temp_sensors.dts b/zephyr/projects/brya/temp_sensors.dts
new file mode 100644
index 0000000000..f4505a3bc1
--- /dev/null
+++ b/zephyr/projects/brya/temp_sensors.dts
@@ -0,0 +1,67 @@
+/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <cros/thermistor/thermistor.dtsi>
+
+/ {
+ named-temp-sensors {
+ ddr_soc {
+ compatible = "cros-ec,temp-sensor-thermistor",
+ "cros-ec,temp-sensor";
+ thermistor = <&thermistor_3V3_30K9_47K_4050B>;
+ label = "DDR and SOC";
+ enum-name = "TEMP_SENSOR_1_DDR_SOC";
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ adc = <&adc_ddr_soc>;
+ };
+ ambient {
+ compatible = "cros-ec,temp-sensor-thermistor",
+ "cros-ec,temp-sensor";
+ thermistor = <&thermistor_3V3_30K9_47K_4050B>;
+ label = "Ambient";
+ enum-name = "TEMP_SENSOR_2_AMBIENT";
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ adc = <&adc_ambient>;
+ };
+ charger {
+ compatible = "cros-ec,temp-sensor-thermistor",
+ "cros-ec,temp-sensor";
+ thermistor = <&thermistor_3V3_30K9_47K_4050B>;
+ label = "Charger";
+ enum-name = "TEMP_SENSOR_3_CHARGER";
+ temp_fan_off = <35>;
+ temp_fan_max = <65>;
+ temp_host_high = <105>;
+ temp_host_halt = <120>;
+ temp_host_release_high = <90>;
+ adc = <&adc_charger>;
+ };
+ wwan {
+ compatible = "cros-ec,temp-sensor-thermistor",
+ "cros-ec,temp-sensor";
+ thermistor = <&thermistor_3V3_30K9_47K_4050B>;
+ label = "WWAN";
+ enum-name = "TEMP_SENSOR_4_WWAN";
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <130>;
+ temp_host_halt = <130>;
+ temp_host_release_high = <100>;
+ adc = <&adc_wwan>;
+ };
+ };
+};
+
+&thermistor_3V3_30K9_47K_4050B {
+ status = "okay";
+};
diff --git a/zephyr/projects/corsola/prj.conf b/zephyr/projects/corsola/prj.conf
index bf08abb714..1615aad9ad 100644
--- a/zephyr/projects/corsola/prj.conf
+++ b/zephyr/projects/corsola/prj.conf
@@ -6,6 +6,9 @@
# http://google3/hardware/standards/usb/
CONFIG_PLATFORM_EC_USB_PID=0x505C
+# I2C
+CONFIG_I2C=y
+
# Keyboard
CONFIG_PLATFORM_EC_KEYBOARD=y
CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y
diff --git a/zephyr/projects/corsola/prj_kingler.conf b/zephyr/projects/corsola/prj_kingler.conf
index 1ef4034049..8cdc8f7261 100644
--- a/zephyr/projects/corsola/prj_kingler.conf
+++ b/zephyr/projects/corsola/prj_kingler.conf
@@ -58,10 +58,6 @@ CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
# Host command
CONFIG_PLATFORM_EC_HOSTCMD=y
-# I2C
-CONFIG_I2C=y
-CONFIG_PLATFORM_EC_I2C=y
-
# PWM
CONFIG_PWM=y
CONFIG_PWM_SHELL=n
@@ -106,7 +102,6 @@ CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
# USBA
CONFIG_PLATFORM_EC_USBA=y
-CONFIG_PLATFORM_EC_USB_A_PORT_COUNT=1
CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB=y
# USBC
diff --git a/zephyr/projects/corsola/prj_krabby.conf b/zephyr/projects/corsola/prj_krabby.conf
index 562e615949..ebab7ce3bd 100644
--- a/zephyr/projects/corsola/prj_krabby.conf
+++ b/zephyr/projects/corsola/prj_krabby.conf
@@ -108,7 +108,6 @@ CONFIG_TASK_PD_STACK_SIZE=1280
# USB-A
CONFIG_PLATFORM_EC_USBA=y
-CONFIG_PLATFORM_EC_USB_A_PORT_COUNT=1
CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB=y
# USB-C
diff --git a/zephyr/projects/herobrine/BUILD.py b/zephyr/projects/herobrine/BUILD.py
index 3f55eda0b2..f2c86014ab 100644
--- a/zephyr/projects/herobrine/BUILD.py
+++ b/zephyr/projects/herobrine/BUILD.py
@@ -58,6 +58,8 @@ register_variant(
extra_dts_overlays=[
here / "battery_villager.dts",
here / "gpio_villager.dts",
+ here / "gpio_led_villager.dts",
+ here / "led_villager.dts",
here / "motionsense_villager.dts",
here / "switchcap.dts",
here / "usbc_villager.dts",
diff --git a/zephyr/projects/herobrine/battery_villager.dts b/zephyr/projects/herobrine/battery_villager.dts
index d5eecbccc6..2fe9a93774 100644
--- a/zephyr/projects/herobrine/battery_villager.dts
+++ b/zephyr/projects/herobrine/battery_villager.dts
@@ -5,7 +5,10 @@
/ {
batteries {
- default_battery: ap19a8k {
+ default_battery: ap19a5k {
+ compatible = "panasonic,ap19a5k", "battery-smart";
+ };
+ ap19a8k {
compatible = "lgc,ap19a8k", "battery-smart";
};
};
diff --git a/zephyr/projects/herobrine/gpio_led_villager.dts b/zephyr/projects/herobrine/gpio_led_villager.dts
new file mode 100644
index 0000000000..9f892025b0
--- /dev/null
+++ b/zephyr/projects/herobrine/gpio_led_villager.dts
@@ -0,0 +1,30 @@
+/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ gpio-led-pins {
+ compatible = "cros-ec,gpio-led-pins";
+
+ color-off {
+ led-color = "LED_OFF";
+ led-pins = <&gpio_ec_chg_led_y_c0 0>,
+ <&gpio_ec_chg_led_b_c0 0>;
+ };
+
+ color-amber {
+ led-color = "LED_AMBER";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pins = <&gpio_ec_chg_led_y_c0 1>,
+ <&gpio_ec_chg_led_b_c0 0>;
+ };
+
+ color-blue {
+ led-color = "LED_BLUE";
+ br-color = "EC_LED_COLOR_BLUE";
+ led-pins = <&gpio_ec_chg_led_y_c0 0>,
+ <&gpio_ec_chg_led_b_c0 1>;
+ };
+ };
+};
diff --git a/zephyr/projects/herobrine/led_villager.dts b/zephyr/projects/herobrine/led_villager.dts
new file mode 100644
index 0000000000..42fa446639
--- /dev/null
+++ b/zephyr/projects/herobrine/led_villager.dts
@@ -0,0 +1,92 @@
+/ {
+ led-colors {
+ compatible = "cros-ec,led-colors";
+
+ power-state-charge {
+ charge-state = "PWR_STATE_CHARGE";
+
+ color-0 {
+ led-color = "LED_AMBER";
+ };
+ };
+
+ power-state-discharge-s0 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+
+ color-0 {
+ led-color = "LED_BLUE";
+ };
+ };
+
+ power-state-discharge-s3 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S3";
+
+ /* Amber 1 sec, off 3 sec */
+ color-0 {
+ led-color = "LED_AMBER";
+ period = <1>;
+ };
+ color-1 {
+ led-color = "LED_OFF";
+ period = <3>;
+ };
+ };
+
+ power-state-discharge-s5 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S5";
+
+ color-0 {
+ led-color = "LED_OFF";
+ };
+ };
+
+ power-state-error {
+ charge-state = "PWR_STATE_ERROR";
+
+ /* Amber 1 sec, off 1 sec */
+ color-0 {
+ led-color = "LED_AMBER";
+ period = <1>;
+ };
+ color-1 {
+ led-color = "LED_OFF";
+ period = <1>;
+ };
+ };
+
+ power-state-near-full {
+ charge-state = "PWR_STATE_CHARGE_NEAR_FULL";
+
+ color-0 {
+ led-color = "LED_BLUE";
+ };
+ };
+
+ power-state-idle-forced {
+ charge-state = "PWR_STATE_IDLE";
+ extra-flag = "LED_CHFLAG_FORCE_IDLE";
+
+ /* Blue 2 sec, Amber 2 sec */
+ color-0 {
+ led-color = "LED_BLUE";
+ period = <2>;
+ };
+ color-1 {
+ led-color = "LED_AMBER";
+ period = <2>;
+ };
+ };
+
+ power-state-idle-default {
+ charge-state = "PWR_STATE_IDLE";
+ extra-flag = "LED_CHFLAG_DEFAULT";
+
+ color-0 {
+ led-color = "LED_BLUE";
+ };
+ };
+ };
+};
diff --git a/zephyr/projects/herobrine/motionsense.dts b/zephyr/projects/herobrine/motionsense.dts
index ef8c1ec87e..1d36fcbf47 100644
--- a/zephyr/projects/herobrine/motionsense.dts
+++ b/zephyr/projects/herobrine/motionsense.dts
@@ -14,6 +14,7 @@
* its own <>_INT_EVENT.
*/
bmi260-int = &base_accel;
+ tcs3400-int = &als_clear;
};
/*
@@ -69,6 +70,66 @@
compatible = "cros-ec,drvdata-bmi260";
status = "okay";
};
+
+ tcs_clear_data: tcs3400-clear-drv-data {
+ compatible = "cros-ec,drvdata-tcs3400-clear";
+ status = "okay";
+
+ als-drv-data {
+ compatible = "cros-ec,accelgyro-als-drv-data";
+ als-cal {
+ scale = <1>;
+ uscale = <0>;
+ offset = <0>;
+ als-channel-scale {
+ compatible = "cros-ec,accelgyro-als-channel-scale";
+ k-channel-scale = <1>;
+ cover-scale = <1>;
+ };
+ };
+ };
+ };
+
+ tcs_rgb_data: tcs3400-rgb-drv-data {
+ compatible = "cros-ec,drvdata-tcs3400-rgb";
+ status = "okay";
+
+ /* node for rgb_calibration_t defined in accelgyro.h */
+ rgb_calibration {
+ compatible =
+ "cros-ec,accelgyro-rgb-calibration";
+
+ irt = <1>;
+
+ rgb-cal-x {
+ offset = <0>;
+ coeff = <0 0 0 1>;
+ als-channel-scale {
+ compatible = "cros-ec,accelgyro-als-channel-scale";
+ k-channel-scale = <1>;
+ cover-scale = <1>;
+ };
+ };
+ rgb-cal-y {
+ offset = <0>;
+ coeff = <0 0 0 1>;
+ als-channel-scale {
+ compatible = "cros-ec,accelgyro-als-channel-scale";
+ k-channel-scale = <1>;
+ cover-scale = <1>;
+ };
+ };
+ rgb-cal-z {
+ offset = <0>;
+ coeff = <0 0 0 1>;
+ als-channel-scale {
+ compatible = "cros-ec,accelgyro-als-channel-scale";
+ k-channel-scale = <1>;
+ cover-scale = <1>;
+ };
+ };
+ };
+ };
};
/*
@@ -141,17 +202,52 @@
rot-standard-ref = <&base_rot_ref>;
drv-data = <&bmi260_data>;
};
+
+ als_clear: base-als-clear {
+ compatible = "cros-ec,tcs3400-clear";
+ status = "okay";
+
+ label = "Clear Light";
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_CAMERA";
+ port = <&i2c_sensor>;
+ default-range = <0x10000>;
+ drv-data = <&tcs_clear_data>;
+ i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS";
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ /* Run ALS sensor in S0 */
+ label = "SENSOR_CONFIG_EC_S0";
+ odr = <1000>;
+ };
+ };
+ };
+
+ base-als-rgb {
+ compatible = "cros-ec,tcs3400-rgb";
+ status = "okay";
+
+ label = "RGB Light";
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_CAMERA";
+ default-range = <0x10000>; /* scale = 1x, uscale = 0 */
+ drv-data = <&tcs_rgb_data>;
+ };
};
motionsense-sensor-info {
compatible = "cros-ec,motionsense-sensor-info";
+ /* list of entries for motion_als_sensors */
+ als-sensors = <&als_clear>;
/*
* list of GPIO interrupts that have to
* be enabled at initial stage
*/
sensor-irqs = <&int_accel_gyro>;
/* list of sensors in force mode */
- accel-force-mode-sensors = <&lid_accel>;
+ accel-force-mode-sensors = <&lid_accel &als_clear>;
};
};
diff --git a/zephyr/projects/herobrine/motionsense_hoglin.dts b/zephyr/projects/herobrine/motionsense_hoglin.dts
index 0d715711b2..3f67347e10 100644
--- a/zephyr/projects/herobrine/motionsense_hoglin.dts
+++ b/zephyr/projects/herobrine/motionsense_hoglin.dts
@@ -14,6 +14,7 @@
* its own <>_INT_EVENT.
*/
bmi260-int = &base_accel;
+ tcs3400-int = &als_clear;
};
/*
@@ -69,6 +70,66 @@
compatible = "cros-ec,drvdata-bmi260";
status = "okay";
};
+
+ tcs_clear_data: tcs3400-clear-drv-data {
+ compatible = "cros-ec,drvdata-tcs3400-clear";
+ status = "okay";
+
+ als-drv-data {
+ compatible = "cros-ec,accelgyro-als-drv-data";
+ als-cal {
+ scale = <1>;
+ uscale = <0>;
+ offset = <0>;
+ als-channel-scale {
+ compatible = "cros-ec,accelgyro-als-channel-scale";
+ k-channel-scale = <1>;
+ cover-scale = <1>;
+ };
+ };
+ };
+ };
+
+ tcs_rgb_data: tcs3400-rgb-drv-data {
+ compatible = "cros-ec,drvdata-tcs3400-rgb";
+ status = "okay";
+
+ /* node for rgb_calibration_t defined in accelgyro.h */
+ rgb_calibration {
+ compatible =
+ "cros-ec,accelgyro-rgb-calibration";
+
+ irt = <1>;
+
+ rgb-cal-x {
+ offset = <0>;
+ coeff = <0 0 0 1>;
+ als-channel-scale {
+ compatible = "cros-ec,accelgyro-als-channel-scale";
+ k-channel-scale = <1>;
+ cover-scale = <1>;
+ };
+ };
+ rgb-cal-y {
+ offset = <0>;
+ coeff = <0 0 0 1>;
+ als-channel-scale {
+ compatible = "cros-ec,accelgyro-als-channel-scale";
+ k-channel-scale = <1>;
+ cover-scale = <1>;
+ };
+ };
+ rgb-cal-z {
+ offset = <0>;
+ coeff = <0 0 0 1>;
+ als-channel-scale {
+ compatible = "cros-ec,accelgyro-als-channel-scale";
+ k-channel-scale = <1>;
+ cover-scale = <1>;
+ };
+ };
+ };
+ };
};
/*
@@ -141,17 +202,52 @@
rot-standard-ref = <&base_rot_ref>;
drv-data = <&bmi260_data>;
};
+
+ als_clear: base-als-clear {
+ compatible = "cros-ec,tcs3400-clear";
+ status = "okay";
+
+ label = "Clear Light";
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_CAMERA";
+ port = <&i2c_sensor>;
+ default-range = <0x10000>;
+ drv-data = <&tcs_clear_data>;
+ i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS";
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ /* Run ALS sensor in S0 */
+ label = "SENSOR_CONFIG_EC_S0";
+ odr = <1000>;
+ };
+ };
+ };
+
+ base-als-rgb {
+ compatible = "cros-ec,tcs3400-rgb";
+ status = "okay";
+
+ label = "RGB Light";
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_CAMERA";
+ default-range = <0x10000>; /* scale = 1x, uscale = 0 */
+ drv-data = <&tcs_rgb_data>;
+ };
};
motionsense-sensor-info {
compatible = "cros-ec,motionsense-sensor-info";
+ /* list of entries for motion_als_sensors */
+ als-sensors = <&als_clear>;
/*
* list of GPIO interrupts that have to
* be enabled at initial stage
*/
sensor-irqs = <&int_accel_gyro>;
/* list of sensors in force mode */
- accel-force-mode-sensors = <&lid_accel>;
+ accel-force-mode-sensors = <&lid_accel &als_clear>;
};
};
diff --git a/zephyr/projects/herobrine/prj.conf b/zephyr/projects/herobrine/prj.conf
index b5ae268ddd..99d2d8c067 100644
--- a/zephyr/projects/herobrine/prj.conf
+++ b/zephyr/projects/herobrine/prj.conf
@@ -100,7 +100,6 @@ CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y
# USB-A
CONFIG_PLATFORM_EC_USBA=y
-CONFIG_PLATFORM_EC_USB_A_PORT_COUNT=1
CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB=y
# USB-C
diff --git a/zephyr/projects/herobrine/prj_herobrine.conf b/zephyr/projects/herobrine/prj_herobrine.conf
index f65a44406d..3c7eddbae6 100644
--- a/zephyr/projects/herobrine/prj_herobrine.conf
+++ b/zephyr/projects/herobrine/prj_herobrine.conf
@@ -4,3 +4,10 @@
# Herobrine-NPCX9 reference-board-specific Kconfig settings.
CONFIG_BOARD_HEROBRINE=y
+
+# Sensors
+CONFIG_PLATFORM_EC_ALS=y
+
+# Sensor Drivers
+CONFIG_PLATFORM_EC_ALS_TCS3400=y
+CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y
diff --git a/zephyr/projects/herobrine/prj_hoglin.conf b/zephyr/projects/herobrine/prj_hoglin.conf
index b261c94169..f68d139b78 100644
--- a/zephyr/projects/herobrine/prj_hoglin.conf
+++ b/zephyr/projects/herobrine/prj_hoglin.conf
@@ -6,3 +6,11 @@
CONFIG_BOARD_HOGLIN=y
CONFIG_PLATFORM_EC_ACCEL_BMA255=n
CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y
+
+# Sensors
+CONFIG_PLATFORM_EC_ALS=y
+
+# Sensor Drivers
+CONFIG_PLATFORM_EC_ALS_TCS3400=y
+CONFIG_PLATFORM_EC_ALS_TCS3400_EMULATED_IRQ_EVENT=y
+
diff --git a/zephyr/projects/herobrine/prj_villager.conf b/zephyr/projects/herobrine/prj_villager.conf
index 35fe2d2502..a63e003788 100644
--- a/zephyr/projects/herobrine/prj_villager.conf
+++ b/zephyr/projects/herobrine/prj_villager.conf
@@ -6,5 +6,6 @@
CONFIG_BOARD_VILLAGER=y
# LED
+CONFIG_PLATFORM_EC_LED_DT=y
CONFIG_PLATFORM_EC_LED_COMMON=n
CONFIG_PLATFORM_EC_ACCEL_KX022=y
diff --git a/zephyr/projects/intelrvp/prj.conf b/zephyr/projects/intelrvp/prj.conf
index 014afe79bf..a4bca4bef9 100644
--- a/zephyr/projects/intelrvp/prj.conf
+++ b/zephyr/projects/intelrvp/prj.conf
@@ -27,7 +27,7 @@ CONFIG_PLATFORM_EC_USB_VID=0x18d1
CONFIG_PLATFORM_EC_USB_PID=0x8086
# I2C
-CONFIG_PLATFORM_EC_I2C=y
+CONFIG_I2C=y
# eSPI
CONFIG_ESPI=y
diff --git a/zephyr/projects/it8xxx2_evb/prj.conf b/zephyr/projects/it8xxx2_evb/prj.conf
index 8acc437c0d..c5e11967ce 100644
--- a/zephyr/projects/it8xxx2_evb/prj.conf
+++ b/zephyr/projects/it8xxx2_evb/prj.conf
@@ -14,7 +14,7 @@ CONFIG_AP_ARM_MTK_MT8192=y
CONFIG_PLATFORM_EC_ADC=y
# I2C
-CONFIG_PLATFORM_EC_I2C=y
+CONFIG_I2C=y
# Fan
CONFIG_PLATFORM_EC_FAN=y
diff --git a/zephyr/projects/nissa/CMakeLists.txt b/zephyr/projects/nissa/CMakeLists.txt
index b22422d4ef..0843170a41 100644
--- a/zephyr/projects/nissa/CMakeLists.txt
+++ b/zephyr/projects/nissa/CMakeLists.txt
@@ -14,6 +14,8 @@ zephyr_library_sources_ifdef(CONFIG_AP_PWRSEQ "src/board_power.c")
if(DEFINED CONFIG_BOARD_NIVVIKS)
project(nivviks)
+ zephyr_library_sources("src/nivviks/fan.c")
+ zephyr_library_sources("src/nivviks/form_factor.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/nivviks/usbc.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "src/nivviks/charger.c")
endif()
diff --git a/zephyr/projects/nissa/nereid_power_signals.dts b/zephyr/projects/nissa/nereid_power_signals.dts
index 95edfdddf5..cef6e17668 100644
--- a/zephyr/projects/nissa/nereid_power_signals.dts
+++ b/zephyr/projects/nissa/nereid_power_signals.dts
@@ -129,20 +129,21 @@
dbg-label = "Combined all power good";
enum-name = "PWR_ALL_SYS_PWRGD";
};
- /*
- * TODO: Add ADC comparators
- * Temporary board based signals.
- */
- pwr-dsw-pwrgd {
- compatible = "intel,ap-pwrseq-external";
- dbg-label = "ADC for 3.3V";
+ pwr-adc-pp3300 {
+ compatible = "intel,ap-pwrseq-adc";
+ dbg-label = "PP3300_PROC";
enum-name = "PWR_DSW_PWROK";
+ trigger-high = <&vcmp0>;
+ trigger-low = <&vcmp1>;
};
- pwr-pg-pp1p05 {
- compatible = "intel,ap-pwrseq-external";
- dbg-label = "ADC for 1.05V";
+ pwr-adc-pp1p05 {
+ compatible = "intel,ap-pwrseq-adc";
+ dbg-label = "PP1P05_PROC";
enum-name = "PWR_PG_PP1P05";
+ trigger-high = <&vcmp2>;
+ trigger-low = <&vcmp3>;
};
+
};
/*
@@ -188,3 +189,36 @@
&gpio_sys_rst_odl {
no-auto-init;
};
+&vcmp0 {
+ status = "okay";
+ scan-period = <IT8XXX2_VCMP_SCAN_PERIOD_600US>;
+ comparison = <IT8XXX2_VCMP_GREATER>;
+ /*
+ * This is 90% of nominal voltage considering voltage
+ * divider on ADC input.
+ */
+ threshold-mv = <2448>;
+ io-channels = <&adc0 0>;
+};
+&vcmp1 {
+ status = "okay";
+ scan-period = <IT8XXX2_VCMP_SCAN_PERIOD_600US>;
+ comparison = <IT8XXX2_VCMP_LESS_OR_EQUAL>;
+ threshold-mv = <2448>;
+ io-channels = <&adc0 0>;
+};
+&vcmp2 {
+ status = "okay";
+ scan-period = <IT8XXX2_VCMP_SCAN_PERIOD_600US>;
+ comparison = <IT8XXX2_VCMP_GREATER>;
+ /* Setting at 90% of nominal voltage */
+ threshold-mv = <945>;
+ io-channels = <&adc0 14>;
+};
+&vcmp3 {
+ status = "okay";
+ scan-period = <IT8XXX2_VCMP_SCAN_PERIOD_600US>;
+ comparison = <IT8XXX2_VCMP_LESS_OR_EQUAL>;
+ threshold-mv = <945>;
+ io-channels = <&adc0 14>;
+};
diff --git a/zephyr/projects/nissa/nivviks_motionsense.dts b/zephyr/projects/nissa/nivviks_motionsense.dts
index ac5d4c390c..f14cadcb3d 100644
--- a/zephyr/projects/nissa/nivviks_motionsense.dts
+++ b/zephyr/projects/nissa/nivviks_motionsense.dts
@@ -42,6 +42,12 @@
0 0 (-1)>;
};
+ base_rot_inverted: base-rot-inverted {
+ mat33 = <(-1) 0 0
+ 0 1 0
+ 0 0 (-1)>;
+ };
+
base_rot_ref: base-rotation-ref {
mat33 = <1 0 0
0 (-1) 0
@@ -85,6 +91,10 @@
location = "MOTIONSENSE_LOC_BASE";
mutex = <&base_mutex>;
port = <&i2c_ec_i2c_sensor>;
+ /*
+ * May be replaced by alternate depending
+ * on board config.
+ */
rot-standard-ref = <&base_rot_ref>;
drv-data = <&lsm6dso_data>;
configs {
diff --git a/zephyr/projects/nissa/nivviks_overlay.dts b/zephyr/projects/nissa/nivviks_overlay.dts
index c50b8d9032..ab34f1c985 100644
--- a/zephyr/projects/nissa/nivviks_overlay.dts
+++ b/zephyr/projects/nissa/nivviks_overlay.dts
@@ -101,6 +101,10 @@
gpios = <&gpiof 5 GPIO_INPUT>;
no-auto-init;
};
+ gpio_fan_enable: fan-enable {
+ gpios = <&gpio6 3 GPIO_OUTPUT>;
+ no-auto-init;
+ };
};
/*
@@ -198,6 +202,33 @@
};
};
};
+
+ named-fans {
+ compatible = "named-fans";
+
+ fan_0 {
+ label = "FAN_0";
+ pwms = <&pwm5 5 PWM_POLARITY_NORMAL>;
+ pwm-frequency = <1000>;
+ rpm_min = <2200>;
+ rpm_start = <2200>;
+ rpm_max = <4200>;
+ tach = <&tach2>;
+ enable_gpio = <&gpio_fan_enable>;
+ };
+ };
+
+ /*
+ * Set I2C pins for type C sub-board to be
+ * low voltage (I2C5_1).
+ * We do this for all boards, since the pins are
+ * 3.3V tolerant, and the only 2 types of sub-boards
+ * used on nivviks both have type-C ports on them.
+ */
+ def-lvol-io-list {
+ compatible = "nuvoton,npcx-lvolctrl-def";
+ lvol-io-pads = <&lvol_iof5 &lvol_iof4>;
+ };
};
&thermistor_3V3_51K1_47K_4050B {
@@ -282,3 +313,17 @@
&pwm2 {
clock-bus = "NPCX_CLOCK_BUS_LFCLK";
};
+
+&pwm5 {
+ status = "okay";
+ drive-open-drain;
+};
+
+/* Tachometer for fan speed measurement */
+&tach2 {
+ status = "okay";
+ pinctrl-0 = <&alt3_ta2_sl1>; /* Use TA2 as input pin */
+ port = <NPCX_TACH_PORT_A>; /* port-A is selected */
+ sample-clk = <NPCX_TACH_FREQ_LFCLK>; /* Use LFCLK as sampling clock */
+ pulses-per-round = <2>; /* number of pulses per round of encoder */
+};
diff --git a/zephyr/projects/nissa/prj.conf b/zephyr/projects/nissa/prj.conf
index 20736f5fd3..7ba18ccc6d 100644
--- a/zephyr/projects/nissa/prj.conf
+++ b/zephyr/projects/nissa/prj.conf
@@ -29,7 +29,6 @@ CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE=128
CONFIG_PLATFORM_EC_BACKLIGHT_LID=y
CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y
CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
-CONFIG_PLATFORM_EC_I2C=y
CONFIG_PLATFORM_EC_LID_SWITCH=y
CONFIG_PLATFORM_EC_POWER_BUTTON=y
CONFIG_PLATFORM_EC_SWITCH=y
@@ -56,6 +55,9 @@ CONFIG_AP_PWRSEQ=y
CONFIG_X86_NON_DSX_PWRSEQ_ADL=y
CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y
+# I2C
+CONFIG_I2C=y
+
# Keyboard support
CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y
CONFIG_PLATFORM_EC_KEYBOARD=y
@@ -98,7 +100,6 @@ CONFIG_PWM_SHELL=y
# TODO(b/188605676): bring these features up
CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-
# Sensors support
CONFIG_PLATFORM_EC_LID_ANGLE=y
CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
@@ -128,7 +129,6 @@ CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
# USB-A host ports
CONFIG_PLATFORM_EC_USBA=y
-CONFIG_PLATFORM_EC_USB_A_PORT_COUNT=2
# Both ports use a smart switch with CTL1..3 fixed high, for SDP2 or CDP only:
# either SLGC55545 or PI5USB2546.
CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART=y
diff --git a/zephyr/projects/nissa/prj_nereid.conf b/zephyr/projects/nissa/prj_nereid.conf
index 5a34b20929..af8f0baa3a 100644
--- a/zephyr/projects/nissa/prj_nereid.conf
+++ b/zephyr/projects/nissa/prj_nereid.conf
@@ -47,3 +47,9 @@ CONFIG_PLATFORM_EC_USB_PD_STARTUP_DELAY_MS=2000
# Charger driver and configuration
CONFIG_PLATFORM_EC_CHARGER_SM5803=y
CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS=21
+
+# VSENSE: PP3300_S5 & PP1050_PROC
+CONFIG_VCMP_IT8XXX2=y
+CONFIG_SENSOR=y
+CONFIG_SENSOR_SHELL=n
+CONFIG_TACH_IT8XXX2=n
diff --git a/zephyr/projects/nissa/prj_nivviks.conf b/zephyr/projects/nissa/prj_nivviks.conf
index 3e68eb3158..568a2461b1 100644
--- a/zephyr/projects/nissa/prj_nivviks.conf
+++ b/zephyr/projects/nissa/prj_nivviks.conf
@@ -9,6 +9,8 @@ CONFIG_CROS_SYSTEM_NPCX=y
CONFIG_SOC_SERIES_NPCX9=y
CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y
CONFIG_SYSCON=y
+CONFIG_PLATFORM_EC_FAN=y
+CONFIG_TACH_NPCX=y
# Sensor drivers
CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y
@@ -36,4 +38,3 @@ CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS=22
CONFIG_ADC_CMP_NPCX=y
CONFIG_SENSOR=y
CONFIG_SENSOR_SHELL=n
-CONFIG_TACH_NPCX=n
diff --git a/zephyr/projects/nissa/src/board_power.c b/zephyr/projects/nissa/src/board_power.c
index 78fd49cebc..6524fbec40 100644
--- a/zephyr/projects/nissa/src/board_power.c
+++ b/zephyr/projects/nissa/src/board_power.c
@@ -116,19 +116,6 @@ int board_power_signal_get(enum power_signal signal)
return 0;
}
return 1;
- /*
- * TODO: When upstreamed changes ready, remove.
- * Temporary workaround for ADC signal.
- * Assume always on.
- */
-
-#ifdef CONFIG_BOARD_NEREID
- case PWR_DSW_PWROK:
- return 1;
-
- case PWR_PG_PP1P05:
- return 1;
-#endif
}
}
diff --git a/zephyr/projects/nissa/src/nivviks/fan.c b/zephyr/projects/nissa/src/nivviks/fan.c
new file mode 100644
index 0000000000..ce5935e924
--- /dev/null
+++ b/zephyr/projects/nissa/src/nivviks/fan.c
@@ -0,0 +1,45 @@
+/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <devicetree.h>
+#include <drivers/gpio.h>
+#include <logging/log.h>
+
+#include "cros_cbi.h"
+#include "fan.h"
+#include "gpio/gpio.h"
+#include "hooks.h"
+
+#include "nissa_common.h"
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+/*
+ * Nirwen fan support
+ */
+static void fan_init(void)
+{
+ int ret;
+ uint32_t val;
+ /*
+ * Retrieve the fan config.
+ */
+ ret = cros_cbi_get_fw_config(FW_FAN, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d",
+ FW_FAN);
+ return;
+ }
+ if (val != FW_FAN_PRESENT) {
+ /* Disable the fan */
+ fan_set_count(0);
+ } else {
+ /* Configure the fan enable GPIO */
+ gpio_pin_configure_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_fan_enable),
+ GPIO_OUTPUT);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST);
diff --git a/zephyr/projects/nissa/src/nivviks/form_factor.c b/zephyr/projects/nissa/src/nivviks/form_factor.c
new file mode 100644
index 0000000000..8142a640bd
--- /dev/null
+++ b/zephyr/projects/nissa/src/nivviks/form_factor.c
@@ -0,0 +1,45 @@
+/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <devicetree.h>
+#include <logging/log.h>
+
+#include "accelgyro.h"
+#include "cros_cbi.h"
+#include "hooks.h"
+#include "motionsense_sensors.h"
+
+#include "nissa_common.h"
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+/*
+ * Mainboard orientation support.
+ */
+
+#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(base_rot_inverted))
+#define BASE_SENSOR SENSOR_ID(DT_NODELABEL(base_accel))
+
+static void form_factor_init(void)
+{
+ int ret;
+ uint32_t val;
+ /*
+ * If the firmware config indicates
+ * an inverted form factor, use the alternative
+ * rotation matrix.
+ */
+ ret = cros_cbi_get_fw_config(FW_BASE_INVERSION, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d",
+ FW_BASE_INVERSION);
+ return;
+ }
+ if (val == FW_BASE_INVERTED) {
+ LOG_INF("Switching to inverted base");
+ motion_sensors[BASE_SENSOR].rot_standard_ref = &ALT_MAT;
+ }
+}
+DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/projects/posix-ec/prj.conf b/zephyr/projects/posix-ec/prj.conf
index a3c507d13a..f6549c7839 100644
--- a/zephyr/projects/posix-ec/prj.conf
+++ b/zephyr/projects/posix-ec/prj.conf
@@ -9,4 +9,3 @@ CONFIG_PLATFORM_EC=y
CONFIG_SHIMMED_TASKS=n
CONFIG_PLATFORM_EC_KEYBOARD=n
CONFIG_PLATFORM_EC_HOSTCMD=n
-CONFIG_PLATFORM_EC_I2C=n
diff --git a/zephyr/projects/skyrim/BUILD.py b/zephyr/projects/skyrim/BUILD.py
index 21b4caded7..e206bdd0d5 100644
--- a/zephyr/projects/skyrim/BUILD.py
+++ b/zephyr/projects/skyrim/BUILD.py
@@ -17,7 +17,7 @@ def register_variant(project_name):
here / "interrupts.dts",
here / "keyboard.dts",
here / "motionsense.dts",
- here / "pwm.dts",
+ here / "pwm_leds.dts",
here / "usbc.dts",
# Project-specific DTS customizations.
here / f"{project_name}.dts",
diff --git a/zephyr/projects/skyrim/led.c b/zephyr/projects/skyrim/led.c
index 6924956273..88feb75b66 100644
--- a/zephyr/projects/skyrim/led.c
+++ b/zephyr/projects/skyrim/led.c
@@ -1,30 +1,15 @@
/* Copyright 2021 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
- *
- * Guybrush specific PWM LED settings.
*/
#include "common.h"
-#include "led_onoff_states.h"
#include "led_common.h"
-#include "hooks.h"
-#include "pwm.h"
-
-/* Note PWM LEDs are active low */
-#define LED_OFF_LVL 1
-#define LED_ON_LVL 0
-
-/* Define our PWM_CH values for zephyr */
-#define PWM_CH_LED_CHRG PWM_CHANNEL(DT_NODELABEL(led_charge))
-#define PWM_CH_LED_FULL PWM_CHANNEL(DT_NODELABEL(led_full))
-
-#define CPRINTS(format, args...) cprints(CC_PWM, format, ## args)
+#include "led_onoff_states.h"
+#include "led_pwm.h"
__override const int led_charge_lvl_1 = 5;
-
__override const int led_charge_lvl_2 = 97;
-
__override struct led_descriptor
led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = {
[STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} },
@@ -42,63 +27,17 @@ __override struct led_descriptor
{EC_LED_COLOR_WHITE, 2 * LED_ONE_SEC} },
};
-const enum ec_led_id supported_led_ids[] = {
- EC_LED_ID_BATTERY_LED,
-};
-
-const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-
__override void led_set_color_battery(enum ec_led_colors color)
{
switch (color) {
case EC_LED_COLOR_AMBER:
- pwm_enable(PWM_CH_LED_CHRG, LED_ON_LVL);
- pwm_enable(PWM_CH_LED_FULL, LED_OFF_LVL);
+ set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_AMBER);
break;
case EC_LED_COLOR_WHITE:
- pwm_enable(PWM_CH_LED_CHRG, LED_OFF_LVL);
- pwm_enable(PWM_CH_LED_FULL, LED_ON_LVL);
- break;
- case LED_OFF:
- pwm_enable(PWM_CH_LED_CHRG, LED_OFF_LVL);
- pwm_enable(PWM_CH_LED_FULL, LED_OFF_LVL);
+ set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_WHITE);
break;
- default: /* Unsupported colors */
- CPRINTS("Unsupported LED color: %d", color);
- pwm_enable(PWM_CH_LED_CHRG, LED_OFF_LVL);
- pwm_enable(PWM_CH_LED_FULL, LED_OFF_LVL);
+ default: /* OFF or unsupported colors */
+ set_pwm_led_color(EC_LED_ID_BATTERY_LED, -1);
break;
}
}
-
-void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
-{
- if (led_id == EC_LED_ID_BATTERY_LED) {
- brightness_range[EC_LED_COLOR_AMBER] = 1;
- brightness_range[EC_LED_COLOR_WHITE] = 1;
- }
-}
-
-int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
-{
- if (led_id == EC_LED_ID_BATTERY_LED) {
- if (brightness[EC_LED_COLOR_WHITE] != 0)
- led_set_color_battery(EC_LED_COLOR_WHITE);
- else if (brightness[EC_LED_COLOR_AMBER] != 0)
- led_set_color_battery(EC_LED_COLOR_AMBER);
- else
- led_set_color_battery(LED_OFF);
- } else {
- CPRINTS("Unsupported LED set: %d", led_id);
- return EC_ERROR_INVAL;
- }
-
- return EC_SUCCESS;
-}
-
-static void pwm_led_duty_init(void)
-{
- pwm_set_duty(PWM_CH_LED_CHRG, 100);
- pwm_set_duty(PWM_CH_LED_FULL, 100);
-}
-DECLARE_HOOK(HOOK_INIT, pwm_led_duty_init, HOOK_PRIO_POST_PWM);
diff --git a/zephyr/projects/skyrim/prj.conf b/zephyr/projects/skyrim/prj.conf
index 6ca2bc4c08..a9be70454b 100644
--- a/zephyr/projects/skyrim/prj.conf
+++ b/zephyr/projects/skyrim/prj.conf
@@ -28,6 +28,9 @@ CONFIG_PLATFORM_EC_POWER_BUTTON=y
# ADC
CONFIG_PLATFORM_EC_ADC=y
+# I2C
+CONFIG_I2C=y
+
# CBI
CONFIG_EEPROM=y
CONFIG_EEPROM_AT24=y
@@ -56,6 +59,7 @@ CONFIG_TACH_NPCX=y
# LEDs
CONFIG_PLATFORM_EC_LED_COMMON=y
CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y
+CONFIG_PLATFORM_EC_LED_PWM=y
# Lid switch
CONFIG_PLATFORM_EC_LID_ANGLE=y
@@ -92,7 +96,6 @@ CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000
# USB-A
CONFIG_PLATFORM_EC_USBA=y
-CONFIG_PLATFORM_EC_USB_A_PORT_COUNT=2
CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB=y
# USB-C
diff --git a/zephyr/projects/skyrim/pwm.dts b/zephyr/projects/skyrim/pwm.dts
deleted file mode 100644
index 4c52b04859..0000000000
--- a/zephyr/projects/skyrim/pwm.dts
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-pwms {
- compatible = "named-pwms";
-
- led_charge: ec_pwm_led_chrg_l {
- pwms = <&pwm2 0 PWM_POLARITY_NORMAL>;
- frequency = <100>;
- };
- led_full: ec_pwm_led_full_l {
- pwms = <&pwm3 0 PWM_POLARITY_NORMAL>;
- frequency = <100>;
- };
- };
-};
-
-/* Fan control */
-
-/* Amber charging LED */
-&pwm2 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
-};
-
-/* Green full LED */
-&pwm3 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
-};
diff --git a/zephyr/projects/skyrim/pwm_leds.dts b/zephyr/projects/skyrim/pwm_leds.dts
new file mode 100644
index 0000000000..951edb0f09
--- /dev/null
+++ b/zephyr/projects/skyrim/pwm_leds.dts
@@ -0,0 +1,46 @@
+/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ pwmleds {
+ compatible = "pwm-leds";
+ pwm_led0: pwm_led_0 {
+ pwms = <&pwm2 0 PWM_POLARITY_INVERTED
+ &pwm3 0 PWM_POLARITY_INVERTED>;
+ };
+ };
+
+ cros-pwmleds {
+ compatible = "cros-ec,pwm-leds";
+
+ leds = <&pwm_led0>;
+ frequency = <100>;
+
+ color-map-white = < 0 100>;
+ color-map-amber = <100 0>;
+
+ brightness-range = <0 0 0 0 255 255>;
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ pwm_led_0@0 {
+ reg = <0>;
+ ec-led-name = "EC_LED_ID_BATTERY_LED";
+ };
+ };
+};
+
+/* Amber "battery charging" LED */
+&pwm2 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+};
+
+/* White "battery full" LED */
+&pwm3 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+};
diff --git a/zephyr/projects/trogdor/lazor/gpio_led.dts b/zephyr/projects/trogdor/lazor/gpio_led.dts
index c7f3072c6e..7ee4ed45f5 100644
--- a/zephyr/projects/trogdor/lazor/gpio_led.dts
+++ b/zephyr/projects/trogdor/lazor/gpio_led.dts
@@ -15,12 +15,14 @@
color-amber {
led-color = "LED_AMBER";
+ br-color = "EC_LED_COLOR_AMBER";
led-pins = <&gpio_ec_chg_led_y_c1 1>,
<&gpio_ec_chg_led_b_c1 0>;
};
color-blue {
led-color = "LED_BLUE";
+ br-color = "EC_LED_COLOR_BLUE";
led-pins = <&gpio_ec_chg_led_y_c1 0>,
<&gpio_ec_chg_led_b_c1 1>;
};
diff --git a/zephyr/projects/trogdor/lazor/prj.conf b/zephyr/projects/trogdor/lazor/prj.conf
index 288c7960df..f95d5a4153 100644
--- a/zephyr/projects/trogdor/lazor/prj.conf
+++ b/zephyr/projects/trogdor/lazor/prj.conf
@@ -20,7 +20,9 @@ CONFIG_PLATFORM_EC_SWITCH=y
CONFIG_PLATFORM_EC_LID_SWITCH=y
CONFIG_PLATFORM_EC_BACKLIGHT_LID=y
CONFIG_PLATFORM_EC_POWER_BUTTON=y
-CONFIG_PLATFORM_EC_I2C=y
+
+# I2C
+CONFIG_I2C=y
# LED
CONFIG_PLATFORM_EC_LED_DT=y
@@ -94,7 +96,6 @@ CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y
# USB-A
CONFIG_PLATFORM_EC_USBA=y
-CONFIG_PLATFORM_EC_USB_A_PORT_COUNT=1
CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB=y
# USB-C
diff --git a/zephyr/projects/trogdor/lazor/pwm_led.dts b/zephyr/projects/trogdor/lazor/pwm_led.dts
index bcb36d5e6c..b69d7455ce 100644
--- a/zephyr/projects/trogdor/lazor/pwm_led.dts
+++ b/zephyr/projects/trogdor/lazor/pwm_led.dts
@@ -30,12 +30,14 @@
color-amber {
led-color = "LED_AMBER";
+ br-color = "EC_LED_COLOR_AMBER";
led-pins = <&pwm_y 100>,
<&pwm_b 0>;
};
color-blue {
led-color = "LED_BLUE";
+ br-color = "EC_LED_COLOR_BLUE";
led-pins = <&pwm_y 0>,
<&pwm_b 100>;
};
diff --git a/zephyr/shim/chip/npcx/shi.c b/zephyr/shim/chip/npcx/shi.c
index 3769b8a52b..4512e4ab9e 100644
--- a/zephyr/shim/chip/npcx/shi.c
+++ b/zephyr/shim/chip/npcx/shi.c
@@ -61,7 +61,7 @@ static void shi_power_change(struct ap_power_ev_callback *cb,
shi_enable();
break;
- case AP_POWER_SHUTDOWN_COMPLETE:
+ case AP_POWER_SUSPEND_COMPLETE:
shi_disable();
break;
#else
@@ -69,7 +69,7 @@ static void shi_power_change(struct ap_power_ev_callback *cb,
shi_enable();
break;
- case AP_POWER_SHUTDOWN:
+ case AP_POWER_SUSPEND:
shi_disable();
break;
#endif
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index c3266165c1..2900acd9aa 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -1053,7 +1053,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_USB_CHARGER
#endif
-#define USB_PORT_COUNT CONFIG_PLATFORM_EC_USB_A_PORT_COUNT
+#define USB_PORT_COUNT \
+ COND_CODE_1(DT_NODE_EXISTS(DT_INST(0, cros_ec_usba_port_enable_pins)), \
+ (DT_PROP_LEN(DT_INST(0, cros_ec_usba_port_enable_pins), \
+ enable_pins)), \
+ (0))
#undef CONFIG_USB_PORT_POWER_DUMB
#ifdef CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB
@@ -1516,6 +1520,11 @@ extern struct jump_data mock_jump_data;
#define CONFIG_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG
#endif
+#undef CONFIG_USBC_RETIMER_INTEL_BB_VPRO_CAPABLE
+#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB_VPRO_CAPABLE
+#define CONFIG_USBC_RETIMER_INTEL_BB_VPRO_CAPABLE
+#endif
+
#undef CONFIG_USBC_RETIMER_ANX7451
#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7451
#define CONFIG_USBC_RETIMER_ANX7451
diff --git a/zephyr/shim/include/motionsense_sensors.h b/zephyr/shim/include/motionsense_sensors.h
index e4ecf5d6de..0add50914a 100644
--- a/zephyr/shim/include/motionsense_sensors.h
+++ b/zephyr/shim/include/motionsense_sensors.h
@@ -12,6 +12,24 @@
extern struct motion_sensor_t motion_sensors_alt[];
/*
+ * Common macros.
+ */
+#define SENSOR_ROT_STD_REF_NAME(id) DT_CAT(ROT_REF_, id)
+#define SENSOR_ROT_REF_NODE DT_PATH(motionsense_rotation_ref)
+
+/*
+ * Declare rotation parameters, since they may be
+ * dynamically selected.
+ */
+#define DECLARE_EXTERN_SENSOR_ROT_REF(id) \
+ extern const mat33_fp_t SENSOR_ROT_STD_REF_NAME(id);
+
+#if DT_NODE_EXISTS(SENSOR_ROT_REF_NODE)
+DT_FOREACH_CHILD(SENSOR_ROT_REF_NODE, DECLARE_EXTERN_SENSOR_ROT_REF)
+#endif
+#undef DECLARE_EXTERN_SENSOR_ROT_REF
+
+/*
* Performs probing of an alternate sensor.
* @param alt_idx Index in motion_sensors_alt of the sensor to be probed.
* It should be gained with SENSOR_ID,
diff --git a/zephyr/shim/src/fan.c b/zephyr/shim/src/fan.c
index 3a46668400..8690dae135 100644
--- a/zephyr/shim/src/fan.c
+++ b/zephyr/shim/src/fan.c
@@ -312,7 +312,7 @@ void fan_tick_func(void)
{
int ch;
- for (ch = 0; ch < FAN_CH_COUNT; ch++) {
+ for (ch = 0; ch < fan_get_count(); ch++) {
switch (fan_data[ch].current_fan_mode) {
case FAN_RPM:
fan_tick_func_rpm(ch);
diff --git a/zephyr/shim/src/led_driver/led.c b/zephyr/shim/src/led_driver/led.c
index 1e97c98a86..edc4f9ce58 100644
--- a/zephyr/shim/src/led_driver/led.c
+++ b/zephyr/shim/src/led_driver/led.c
@@ -119,24 +119,6 @@ struct node_prop_t node_array[] = {
DT_FOREACH_CHILD(LED_COLOR_NODE, SET_LED_VALUES)
};
-void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
-{
- brightness_range[EC_LED_COLOR_AMBER] = 1;
- brightness_range[EC_LED_COLOR_BLUE] = 1;
-}
-
-int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
-{
- if (brightness[EC_LED_COLOR_BLUE] != 0)
- led_set_color(LED_BLUE);
- else if (brightness[EC_LED_COLOR_AMBER] != 0)
- led_set_color(LED_AMBER);
- else
- led_set_color(LED_OFF);
-
- return EC_SUCCESS;
-}
-
static enum power_state get_chipset_state(void)
{
enum power_state chipset_state = 0;
diff --git a/zephyr/shim/src/led_driver/led.h b/zephyr/shim/src/led_driver/led.h
index 4354df5125..53728609ed 100644
--- a/zephyr/shim/src/led_driver/led.h
+++ b/zephyr/shim/src/led_driver/led.h
@@ -14,6 +14,11 @@
(DT_STRING_UPPER_TOKEN(id, prop)), \
(0))
+#define GET_BR_COLOR(id, prop) \
+ COND_CODE_1(DT_NODE_HAS_PROP(id, prop), \
+ (DT_STRING_UPPER_TOKEN(id, prop)), \
+ (-1))
+
/* TODO(b/227798487): Use DT to generate this enum instead of hardcoding */
enum led_color {
LED_OFF = 0,
diff --git a/zephyr/shim/src/led_driver/led_gpio.c b/zephyr/shim/src/led_driver/led_gpio.c
index 46d94db4dc..85bdc2dd71 100644
--- a/zephyr/shim/src/led_driver/led_gpio.c
+++ b/zephyr/shim/src/led_driver/led_gpio.c
@@ -5,6 +5,7 @@
* GPIO LED control.
*/
+#include "ec_commands.h"
#include "led.h"
#include "util.h"
@@ -32,7 +33,13 @@ struct gpio_pin_t {
* to alter in order to enable the given color.
*/
struct led_pins_node_t {
+ /* Link between color and pins node */
int led_color;
+
+ /* Brightness Range color, only used by ectool funcs for testing */
+ enum ec_led_colors br_color;
+
+ /* Array of GPIO pins to set to enable particular color */
struct gpio_pin_t gpio_pins[LED_PIN_COUNT];
};
@@ -50,10 +57,11 @@ struct led_pins_node_t {
#define SET_PIN_NODE(node_id) \
{ \
.led_color = GET_PROP(node_id, led_color), \
+ .br_color = GET_BR_COLOR(node_id, br_color), \
.gpio_pins = SET_GPIO_PIN(node_id) \
},
-struct led_pins_node_t pins_node[LED_COLOR_COUNT] = {
+struct led_pins_node_t pins_node[] = {
DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, SET_PIN_NODE)
};
@@ -74,4 +82,34 @@ void led_set_color(enum led_color color)
}
}
}
+
+void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
+{
+ for (int i = 0; i < ARRAY_SIZE(pins_node); i++) {
+ int br_color = pins_node[i].br_color;
+
+ if (br_color != -1)
+ brightness_range[br_color] = 1;
+ }
+}
+
+int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
+{
+ bool color_set = false;
+
+ for (int i = 0; i < ARRAY_SIZE(pins_node); i++) {
+ int br_color = pins_node[i].br_color;
+
+ if ((br_color != -1) && (brightness[br_color] != 0)) {
+ color_set = true;
+ led_set_color(pins_node[i].led_color);
+ }
+ }
+
+ /* If no color was set, turn off the LED */
+ if (!color_set)
+ led_set_color(LED_OFF);
+
+ return EC_SUCCESS;
+}
#endif /* DT_HAS_COMPAT_STATUS_OKAY(COMPAT_GPIO_LED) */
diff --git a/zephyr/shim/src/led_driver/led_pwm.c b/zephyr/shim/src/led_driver/led_pwm.c
index 57cd6eb92f..d2605256a5 100644
--- a/zephyr/shim/src/led_driver/led_pwm.c
+++ b/zephyr/shim/src/led_driver/led_pwm.c
@@ -5,6 +5,7 @@
* PWM LED control.
*/
+#include "ec_commands.h"
#include "led.h"
#include "util.h"
@@ -34,7 +35,13 @@ struct pwm_pin_t {
* to alter in order to enable the given color.
*/
struct led_pins_node_t {
+ /* Link between color and pins node */
int led_color;
+
+ /* Brightness Range color, only used by ectool funcs for testing */
+ enum ec_led_colors br_color;
+
+ /* Array of PWM pins to set to enable particular color */
struct pwm_pin_t pwm_pins[LED_PIN_COUNT];
};
@@ -70,10 +77,11 @@ const uint32_t period_us =
#define SET_PIN_NODE(node_id) \
{ \
.led_color = GET_PROP(node_id, led_color), \
+ .br_color = GET_BR_COLOR(node_id, br_color), \
.pwm_pins = SET_PWM_PIN(node_id) \
},
-struct led_pins_node_t pins_node[LED_COLOR_COUNT] = {
+struct led_pins_node_t pins_node[] = {
DT_FOREACH_CHILD(PWM_LED_PINS_NODE, SET_PIN_NODE)
};
@@ -99,4 +107,34 @@ void led_set_color(enum led_color color)
}
}
}
+
+void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
+{
+ for (int i = 0; i < ARRAY_SIZE(pins_node); i++) {
+ int br_color = pins_node[i].br_color;
+
+ if (br_color != -1)
+ brightness_range[br_color] = 100;
+ }
+}
+
+int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
+{
+ bool color_set = false;
+
+ for (int i = 0; i < ARRAY_SIZE(pins_node); i++) {
+ int br_color = pins_node[i].br_color;
+
+ if ((br_color != -1) && (brightness[br_color] != 0)) {
+ color_set = true;
+ led_set_color(pins_node[i].led_color);
+ }
+ }
+
+ /* If no color was set, turn off the LED */
+ if (!color_set)
+ led_set_color(LED_OFF);
+
+ return EC_SUCCESS;
+}
#endif /* DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED) */
diff --git a/zephyr/shim/src/motionsense_sensors.c b/zephyr/shim/src/motionsense_sensors.c
index 0cc55339df..c720e8434e 100644
--- a/zephyr/shim/src/motionsense_sensors.c
+++ b/zephyr/shim/src/motionsense_sensors.c
@@ -28,11 +28,9 @@ LOG_MODULE_REGISTER(shim_cros_motionsense_sensors);
DT_FOREACH_CHILD(SENSOR_MUTEX_NODE, DECLARE_SENSOR_MUTEX)
#endif /* DT_NODE_EXISTS(SENSOR_MUTEX_NODE) */
-#define SENSOR_ROT_REF_NODE DT_PATH(motionsense_rotation_ref)
-#define SENSOR_ROT_STD_REF_NAME(id) DT_CAT(ROT_REF_, id)
#define MAT_ITEM(i, id) FLOAT_TO_FP((int32_t)(DT_PROP_BY_IDX(id, mat33, i)))
#define DECLARE_SENSOR_ROT_REF(id) \
- static const mat33_fp_t SENSOR_ROT_STD_REF_NAME(id) = { \
+ const mat33_fp_t SENSOR_ROT_STD_REF_NAME(id) = { \
{ \
FOR_EACH_FIXED_ARG(MAT_ITEM, (,), id, 0, 1, 2) \
}, \
diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c
index a2a4df8320..5b8fb502be 100644
--- a/zephyr/shim/src/tasks.c
+++ b/zephyr/shim/src/tasks.c
@@ -33,7 +33,7 @@ CROS_EC_TASK_LIST
#undef TASK_TEST
/** Context for each CROS EC task that is run in its own zephyr thread */
-struct task_ctx_static {
+struct task_ctx_cfg {
#ifdef CONFIG_THREAD_NAME
/** Name of thread (for debugging) */
const char *name;
@@ -48,7 +48,7 @@ struct task_ctx_static {
intptr_t parameter;
};
-struct task_ctx_dyn {
+struct task_ctx_data {
/** Zephyr thread structure that hosts EC tasks */
struct k_thread zephyr_thread;
/** Zephyr thread id for above thread */
@@ -64,36 +64,26 @@ struct task_ctx_dyn {
struct k_timer timer;
};
-#ifdef CONFIG_THREAD_NAME
-#define CROS_EC_TASK(_name, _entry, _parameter, _size) \
- { \
- .entry = _entry, \
- .parameter = _parameter, \
- .stack = _name##_STACK, \
- .stack_size = _size, \
- .name = #_name, \
- },
-#else
-#define CROS_EC_TASK(_name, _entry, _parameter, _size) \
- { \
- .entry = _entry, \
- .parameter = _parameter, \
- .stack = _name##_STACK, \
- .stack_size = _size, \
+#define CROS_EC_TASK(_name, _entry, _parameter, _size) \
+ { \
+ .entry = _entry, \
+ .parameter = _parameter, \
+ .stack = _name##_STACK, \
+ .stack_size = _size, \
+ COND_CODE_1(CONFIG_THREAD_NAME, (.name = #_name,), ()) \
},
-#endif /* CONFIG_THREAD_NAME */
#define TASK_TEST(_name, _entry, _parameter, _size) \
CROS_EC_TASK(_name, _entry, _parameter, _size)
/* Note: no static entry is required for sysworkq, as it isn't started here */
-const static struct task_ctx_static shimmed_tasks_static[TASK_ID_COUNT] = {
+const static struct task_ctx_cfg shimmed_tasks_cfg[TASK_ID_COUNT] = {
CROS_EC_TASK_LIST
#ifdef TEST_BUILD
[TASK_ID_TEST_RUNNER] = {},
#endif
};
-/* In dynamic tasks, allocate one extra spot for the sysworkq */
-static struct task_ctx_dyn shimmed_tasks_dyn[TASK_ID_COUNT + 1];
+/* In tasks data, allocate one extra spot for the sysworkq */
+static struct task_ctx_data shimmed_tasks_data[TASK_ID_COUNT + 1];
#define TASK_ID_SYSWORKQ TASK_ID_COUNT
@@ -105,7 +95,7 @@ task_id_t task_get_current(void)
{
/* Include sysworkq entry in search for the task ID */
for (size_t i = 0; i < TASK_ID_COUNT + 1; ++i) {
- if (shimmed_tasks_dyn[i].zephyr_tid == k_current_get())
+ if (shimmed_tasks_data[i].zephyr_tid == k_current_get())
return i;
}
@@ -115,29 +105,30 @@ task_id_t task_get_current(void)
__test_only k_tid_t task_get_zephyr_tid(size_t cros_tid)
{
- return shimmed_tasks_dyn[cros_tid].zephyr_tid;
+ return shimmed_tasks_data[cros_tid].zephyr_tid;
}
atomic_t *task_get_event_bitmap(task_id_t cros_task_id)
{
- struct task_ctx_dyn *const ctx = &shimmed_tasks_dyn[cros_task_id];
+ struct task_ctx_data *const data = &shimmed_tasks_data[cros_task_id];
- return &ctx->event_mask;
+ return &data->event_mask;
}
uint32_t task_set_event(task_id_t cros_task_id, uint32_t event)
{
- struct task_ctx_dyn *const ctx = &shimmed_tasks_dyn[cros_task_id];
+ struct task_ctx_data *const data = &shimmed_tasks_data[cros_task_id];
- atomic_or(&ctx->event_mask, event);
- k_poll_signal_raise(&ctx->new_event, 0);
+ atomic_or(&data->event_mask, event);
+ k_poll_signal_raise(&data->new_event, 0);
return 0;
}
uint32_t task_wait_event(int timeout_us)
{
- struct task_ctx_dyn *const ctx = &shimmed_tasks_dyn[task_get_current()];
+ struct task_ctx_data *const data =
+ &shimmed_tasks_data[task_get_current()];
const k_timeout_t timeout = (timeout_us == -1) ? K_FOREVER :
K_USEC(timeout_us);
const int64_t tick_deadline =
@@ -146,14 +137,14 @@ uint32_t task_wait_event(int timeout_us)
struct k_poll_event poll_events[1] = {
K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL,
K_POLL_MODE_NOTIFY_ONLY,
- &ctx->new_event),
+ &data->new_event),
};
/* Wait for signal, then clear it before reading events */
const int rv = k_poll(poll_events, ARRAY_SIZE(poll_events), timeout);
- k_poll_signal_reset(&ctx->new_event);
- uint32_t events = atomic_set(&ctx->event_mask, 0);
+ k_poll_signal_reset(&data->new_event);
+ uint32_t events = atomic_set(&data->event_mask, 0);
if (rv == -EAGAIN) {
events |= TASK_EVENT_TIMER;
@@ -179,7 +170,8 @@ uint32_t task_wait_event(int timeout_us)
uint32_t task_wait_event_mask(uint32_t event_mask, int timeout_us)
{
- struct task_ctx_dyn *const ctx = &shimmed_tasks_dyn[task_get_current()];
+ struct task_ctx_data *const data =
+ &shimmed_tasks_data[task_get_current()];
uint32_t events = 0;
const int64_t tick_deadline =
k_uptime_ticks() + k_us_to_ticks_near64(timeout_us);
@@ -198,37 +190,36 @@ uint32_t task_wait_event_mask(uint32_t event_mask, int timeout_us)
struct k_poll_event poll_events[1] = {
K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL,
K_POLL_MODE_NOTIFY_ONLY,
- &ctx->new_event),
+ &data->new_event),
};
/* Ensure to honor the -1 timeout as FOREVER */
k_poll(poll_events, ARRAY_SIZE(poll_events),
timeout_us == -1 ? K_FOREVER : K_TICKS(ticks_left));
- k_poll_signal_reset(&ctx->new_event);
- events |= atomic_set(&ctx->event_mask, 0);
+ k_poll_signal_reset(&data->new_event);
+ events |= atomic_set(&data->event_mask, 0);
}
/* Replace any events that weren't in the mask */
if (events & ~event_mask) {
- atomic_or(&ctx->event_mask, events & ~event_mask);
- k_poll_signal_raise(&ctx->new_event, 0);
+ atomic_or(&data->event_mask, events & ~event_mask);
+ k_poll_signal_raise(&data->new_event, 0);
}
return events & event_mask;
}
-static void task_entry(void *task_context_static,
- void *task_context_dyn,
+static void task_entry(void *task_context_cfg,
+ void *task_context_data,
void *unused1)
{
- ARG_UNUSED(task_context_dyn);
+ ARG_UNUSED(task_context_data);
ARG_UNUSED(unused1);
- struct task_ctx_static *const ctx_static =
- (struct task_ctx_static *)task_context_static;
+ struct task_ctx_cfg *const cfg = task_context_cfg;
/* Call into task entry point */
- ctx_static->entry((void *)ctx_static->parameter);
+ cfg->entry((void *)cfg->parameter);
}
/*
@@ -237,9 +228,9 @@ static void task_entry(void *task_context_static,
*/
static void timer_expire(struct k_timer *timer_id)
{
- struct task_ctx_dyn *const ctx =
- CONTAINER_OF(timer_id, struct task_ctx_dyn, timer);
- task_id_t cros_ec_task_id = ctx - shimmed_tasks_dyn;
+ struct task_ctx_data *const data =
+ CONTAINER_OF(timer_id, struct task_ctx_data, timer);
+ task_id_t cros_ec_task_id = data - shimmed_tasks_data;
task_set_event(cros_ec_task_id, TASK_EVENT_TIMER);
}
@@ -247,7 +238,7 @@ static void timer_expire(struct k_timer *timer_id)
int timer_arm(timestamp_t event, task_id_t cros_ec_task_id)
{
timestamp_t now = get_time();
- struct task_ctx_dyn *const ctx = &shimmed_tasks_dyn[cros_ec_task_id];
+ struct task_ctx_data *const data = &shimmed_tasks_data[cros_ec_task_id];
if (event.val <= now.val) {
/* Timer requested for now or in the past, fire right away */
@@ -256,24 +247,24 @@ int timer_arm(timestamp_t event, task_id_t cros_ec_task_id)
}
/* Check for a running timer */
- if (k_timer_remaining_get(&ctx->timer))
+ if (k_timer_remaining_get(&data->timer))
return EC_ERROR_BUSY;
- k_timer_start(&ctx->timer, K_USEC(event.val - now.val), K_NO_WAIT);
+ k_timer_start(&data->timer, K_USEC(event.val - now.val), K_NO_WAIT);
return EC_SUCCESS;
}
void timer_cancel(task_id_t cros_ec_task_id)
{
- struct task_ctx_dyn *const ctx = &shimmed_tasks_dyn[cros_ec_task_id];
+ struct task_ctx_data *const data = &shimmed_tasks_data[cros_ec_task_id];
- k_timer_stop(&ctx->timer);
+ k_timer_stop(&data->timer);
}
#ifdef TEST_BUILD
void set_test_runner_tid(void)
{
- shimmed_tasks_dyn[TASK_ID_TEST_RUNNER].zephyr_tid = k_current_get();
+ shimmed_tasks_data[TASK_ID_TEST_RUNNER].zephyr_tid = k_current_get();
}
#ifdef CONFIG_SET_TEST_RUNNER_TID_RULE
@@ -299,18 +290,17 @@ void start_ec_tasks(void)
/* Initialize all EC tasks, which does not include the sysworkq entry */
for (size_t i = 0; i < TASK_ID_COUNT; ++i) {
- struct task_ctx_dyn *const ctx_dyn = &shimmed_tasks_dyn[i];
- const struct task_ctx_static *const ctx_static =
- &shimmed_tasks_static[i];
+ struct task_ctx_data *const data = &shimmed_tasks_data[i];
+ const struct task_ctx_cfg *const cfg = &shimmed_tasks_cfg[i];
- k_timer_init(&ctx_dyn->timer, timer_expire, NULL);
+ k_timer_init(&data->timer, timer_expire, NULL);
priority = K_PRIO_PREEMPT(TASK_ID_COUNT - i - 1);
#ifdef TEST_BUILD
/* Do not create thread for test runner; it will be set later */
if (i == TASK_ID_TEST_RUNNER) {
- ctx_dyn->zephyr_tid = NULL;
+ data->zephyr_tid = NULL;
continue;
}
#endif
@@ -323,7 +313,7 @@ void start_ec_tasks(void)
* enabled cros-ec tasks.
*/
if (i == TASK_ID_CONSOLE_STUB) {
- ctx_dyn->zephyr_tid = NULL;
+ data->zephyr_tid = NULL;
uart_shell_set_priority(priority);
continue;
}
@@ -334,13 +324,13 @@ void start_ec_tasks(void)
* comment in config.h for CONFIG_TASK_LIST for existing flags
* implementation.
*/
- ctx_dyn->zephyr_tid = k_thread_create(
- &ctx_dyn->zephyr_thread,
- ctx_static->stack,
- ctx_static->stack_size,
+ data->zephyr_tid = k_thread_create(
+ &data->zephyr_thread,
+ cfg->stack,
+ cfg->stack_size,
task_entry,
- (void *)ctx_static,
- ctx_dyn,
+ (void *)cfg,
+ data,
NULL,
priority,
0,
@@ -348,12 +338,12 @@ void start_ec_tasks(void)
#ifdef CONFIG_THREAD_NAME
/* Name thread for debugging */
- k_thread_name_set(ctx_dyn->zephyr_tid, ctx_static->name);
+ k_thread_name_set(data->zephyr_tid, cfg->name);
#endif
}
/* Create an entry for sysworkq we can send events to */
- shimmed_tasks_dyn[TASK_ID_COUNT].zephyr_tid = &k_sys_work_q.thread;
+ shimmed_tasks_data[TASK_ID_COUNT].zephyr_tid = &k_sys_work_q.thread;
tasks_started = 1;
}
@@ -369,9 +359,9 @@ int init_signals(const struct device *unused)
/* Initialize event structures for all entries, including sysworkq */
for (size_t i = 0; i < TASK_ID_COUNT + 1; ++i) {
- struct task_ctx_dyn *const ctx = &shimmed_tasks_dyn[i];
+ struct task_ctx_data *const data = &shimmed_tasks_data[i];
- k_poll_signal_init(&ctx->new_event);
+ k_poll_signal_init(&data->new_event);
}
return 0;
diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt
index 2d1c8ee1f8..283593c53d 100644
--- a/zephyr/test/drivers/CMakeLists.txt
+++ b/zephyr/test/drivers/CMakeLists.txt
@@ -31,6 +31,7 @@ target_sources(app PRIVATE
src/integration/usbc/usb_5v_3a_pd_source.c
src/integration/usbc/usb_alt_mode.c
src/integration/usbc/usb_attach_src_snk.c
+ src/integration/usbc/usb_pd_ctrl_msg.c
src/i2c_passthru.c
src/isl923x.c
src/keyboard_scan.c
diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf
index e1832961a8..0f230410df 100644
--- a/zephyr/test/drivers/prj.conf
+++ b/zephyr/test/drivers/prj.conf
@@ -78,7 +78,6 @@ CONFIG_PLATFORM_EC_USB_CHARGER=y
CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
CONFIG_PLATFORM_EC_USB_POWER_DELIVERY=y
CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y
-CONFIG_PLATFORM_EC_I2C=y
CONFIG_PLATFORM_EC_BATTERY=y
CONFIG_PLATFORM_EC_BATTERY_SMART=y
CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
diff --git a/zephyr/test/drivers/src/bb_retimer.c b/zephyr/test/drivers/src/bb_retimer.c
index 82a50f5049..26a89860ff 100644
--- a/zephyr/test/drivers/src/bb_retimer.c
+++ b/zephyr/test/drivers/src/bb_retimer.c
@@ -411,8 +411,11 @@ ZTEST_USER(bb_retimer, test_bb_set_dfp_state)
conn = bb_emul_get_reg(emul, BB_RETIMER_REG_CONNECTION_STATE);
exp_conn = BB_RETIMER_DATA_CONNECTION_PRESENT |
BB_RETIMER_TBT_CONNECTION |
- BB_RETIMER_VPRO_DOCK_DP_OVERDRIVE |
BB_RETIMER_ACTIVE_PASSIVE;
+
+ if (IS_ENABLED(CONFIG_USBC_RETIMER_INTEL_BB_VPRO_CAPABLE))
+ exp_conn |= BB_RETIMER_VPRO_DOCK_DP_OVERDRIVE;
+
zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
exp_conn, conn);
diff --git a/zephyr/test/drivers/src/integration/usbc/usb_pd_ctrl_msg.c b/zephyr/test/drivers/src/integration/usbc/usb_pd_ctrl_msg.c
new file mode 100644
index 0000000000..cd884f26b8
--- /dev/null
+++ b/zephyr/test/drivers/src/integration/usbc/usb_pd_ctrl_msg.c
@@ -0,0 +1,178 @@
+/* Copyright 2022 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <stdint.h>
+#include <ztest.h>
+
+#include "common.h"
+#include "ec_tasks.h"
+#include "emul/emul_isl923x.h"
+#include "emul/tcpc/emul_tcpci_partner_drp.h"
+#include "tcpm/tcpci.h"
+#include "test/drivers/stubs.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+#include "usb_pd.h"
+
+#define SNK_PORT USBC_PORT_C0
+
+#define TCPCI_EMUL_LABEL DT_NODELABEL(tcpci_emul)
+
+struct usb_pd_ctrl_msg_test_fixture {
+ struct tcpci_drp_emul partner_emul;
+ const struct emul *tcpci_emul;
+ const struct emul *charger_emul;
+};
+
+static void connect_sink_to_port(struct usb_pd_ctrl_msg_test_fixture *fixture)
+{
+ /*
+ * TODO(b/221439302) Updating the TCPCI emulator registers, updating the
+ * vbus, as well as alerting should all be a part of the connect
+ * function.
+ */
+ isl923x_emul_set_adc_vbus(fixture->charger_emul, 0);
+ zassume_ok(tcpci_emul_set_reg(fixture->tcpci_emul,
+ TCPC_REG_POWER_STATUS,
+ TCPC_REG_POWER_STATUS_VBUS_DET),
+ NULL);
+ zassume_ok(tcpci_emul_set_reg(fixture->tcpci_emul, TCPC_REG_EXT_STATUS,
+ TCPC_REG_EXT_STATUS_SAFE0V),
+ NULL);
+ zassume_ok(tcpci_drp_emul_connect_to_tcpci(
+ &fixture->partner_emul.data,
+ &fixture->partner_emul.src_data,
+ &fixture->partner_emul.snk_data,
+ &fixture->partner_emul.common_data,
+ &fixture->partner_emul.ops, fixture->tcpci_emul),
+ NULL);
+
+ tcpci_tcpc_alert(SNK_PORT);
+ /* Wait for PD negotiation and current ramp.
+ * TODO(b/213906889): Check message timing and contents.
+ */
+ k_sleep(K_SECONDS(10));
+}
+
+static void
+disconnect_sink_from_port(struct usb_pd_ctrl_msg_test_fixture *fixture)
+{
+ zassume_ok(tcpci_emul_disconnect_partner(fixture->tcpci_emul), NULL);
+ k_sleep(K_SECONDS(1));
+}
+
+static void *usb_pd_ctrl_msg_setup(void)
+{
+ static struct usb_pd_ctrl_msg_test_fixture fixture;
+
+ /* Get references for the emulators */
+ fixture.tcpci_emul =
+ emul_get_binding(DT_LABEL(DT_NODELABEL(tcpci_emul)));
+ fixture.charger_emul =
+ emul_get_binding(DT_LABEL(DT_NODELABEL(isl923x_emul)));
+
+ tcpci_emul_set_rev(fixture.tcpci_emul, TCPCI_EMUL_REV2_0_VER1_1);
+
+ /* Turn TCPCI rev 2 ON */
+ tcpc_config[SNK_PORT].flags |= TCPC_FLAGS_TCPCI_REV2_0;
+
+ return &fixture;
+}
+
+static void usb_pd_ctrl_msg_before(void *data)
+{
+ struct usb_pd_ctrl_msg_test_fixture *fixture = data;
+
+ set_test_runner_tid();
+
+ test_set_chipset_to_g3();
+ k_sleep(K_SECONDS(1));
+
+ /* Set chipset to ON, this will set TCPM to DRP */
+ test_set_chipset_to_s0();
+
+ /* TODO(b/214401892): Check why need to give time TCPM to spin */
+ k_sleep(K_SECONDS(1));
+
+ /* Initialized the sink to request 5V and 3A */
+ tcpci_drp_emul_init(&fixture->partner_emul);
+
+ connect_sink_to_port(fixture);
+
+ k_sleep(K_SECONDS(10));
+}
+
+static void usb_pd_ctrl_msg_after(void *data)
+{
+ struct usb_pd_ctrl_msg_test_fixture *fixture = data;
+
+ disconnect_sink_from_port(fixture);
+}
+
+ZTEST_SUITE(usb_pd_ctrl_msg_test, drivers_predicate_post_main,
+ usb_pd_ctrl_msg_setup, NULL, usb_pd_ctrl_msg_after, NULL);
+
+ZTEST_F(usb_pd_ctrl_msg_test, verify_vconn_swap)
+{
+ struct ec_response_typec_status snk_resp = { 0 };
+ int rv = 0;
+
+ /* TODO(b/228593065): Revert this once ZTEST fix before ordering
+ * is pulled in
+ */
+ usb_pd_ctrl_msg_before(this);
+
+ snk_resp = host_cmd_typec_status(SNK_PORT);
+ zassert_equal(PD_ROLE_VCONN_SRC, snk_resp.vconn_role,
+ "SNK Returned vconn_role=%u", snk_resp.vconn_role);
+
+ /* Send VCONN_SWAP request */
+ rv = tcpci_partner_send_control_msg(&this->partner_emul.common_data,
+ PD_CTRL_VCONN_SWAP, 0);
+ zassert_ok(rv, "Failed to send VCONN_SWAP request, rv=%d", rv);
+
+ k_sleep(K_SECONDS(1));
+
+ snk_resp = host_cmd_typec_status(SNK_PORT);
+ zassert_equal(PD_ROLE_VCONN_OFF, snk_resp.vconn_role,
+ "SNK Returned vconn_role=%u", snk_resp.vconn_role);
+}
+
+ZTEST_F(usb_pd_ctrl_msg_test, verify_pr_swap)
+{
+ struct ec_response_typec_status snk_resp = { 0 };
+ int rv = 0;
+
+ /* TODO(b/228593065): Revert this once ZTEST fix before ordering
+ * is pulled in
+ */
+ usb_pd_ctrl_msg_before(this);
+
+ snk_resp = host_cmd_typec_status(SNK_PORT);
+ zassert_equal(PD_ROLE_SINK, snk_resp.power_role,
+ "SNK Returned power_role=%u", snk_resp.power_role);
+
+ /* Ignore ACCEPT in common handler for PR Swap request,
+ * causes soft reset
+ */
+ tcpci_partner_common_handler_mask_msg(&this->partner_emul.common_data,
+ PD_CTRL_ACCEPT, true);
+
+ /* Send PR_SWAP request */
+ rv = tcpci_partner_send_control_msg(&this->partner_emul.common_data,
+ PD_CTRL_PR_SWAP, 0);
+ zassert_ok(rv, "Failed to send PR_SWAP request, rv=%d", rv);
+
+ /* Send PS_RDY request */
+ rv = tcpci_partner_send_control_msg(&this->partner_emul.common_data,
+ PD_CTRL_PS_RDY, 15);
+ zassert_ok(rv, "Failed to send PS_RDY request, rv=%d", rv);
+
+ k_sleep(K_MSEC(20));
+
+ snk_resp = host_cmd_typec_status(SNK_PORT);
+ zassert_equal(PD_ROLE_SOURCE, snk_resp.power_role,
+ "SNK Returned power_role=%u", snk_resp.power_role);
+}
diff --git a/zephyr/test/i2c/prj.conf b/zephyr/test/i2c/prj.conf
index 8023c0492b..69c276712e 100644
--- a/zephyr/test/i2c/prj.conf
+++ b/zephyr/test/i2c/prj.conf
@@ -14,7 +14,6 @@ CONFIG_SENSOR=y
CONFIG_BMI160_TRIGGER_NONE=y
CONFIG_PLATFORM_EC=y
-CONFIG_PLATFORM_EC_I2C=y
CONFIG_CROS_EC=y
# TODO(b/173711210) figure out why SPI is required here when we're not using it.