summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYH Lin <yueherngl@google.com>2022-11-30 21:44:08 +0000
committerYH Lin <yueherngl@google.com>2022-11-30 21:44:08 +0000
commitaf25602b15b22b9ef5821dcba9934311f2157c48 (patch)
treed0c89ae8814c2ba35c238c6c0644ec6b1602c63a
parent54462f034b635260dd09173b3d082e47fc960ef3 (diff)
parentaa40b859b3a73e5a205bc561c1a29eff38485461 (diff)
downloadchrome-ec-af25602b15b22b9ef5821dcba9934311f2157c48.tar.gz
Merge remote-tracking branch cros/main into factory-brya-14517.B-main
Generated by: util/update_release_branch.py --baseboard brya --relevant_paths_file baseboard/brya/relevant-paths.txt factory-brya-14517.B-main Relevant changes: git log --oneline 54462f034b..aa40b859b3 -- baseboard/brya board/agah board/anahera board/banshee board/brya board/crota board/felwinter board/gimble board/kano board/mithrax board/osiris 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 e6da633c38 driver: Sort header files 234a87ae2d tcpci: Add FRS enable to driver structure a56be59ccd tcpm_header: add test for tcpm_dump_registers 57b3256963 Rename CONFIG_CHARGER_INPUT_CURRENT to _CHARGER_DEFAULT_CURRENT_LIMIT e420c8ff9a marasov: Modify TypeC and TypeA configuration. 43b53e0045 Add default implementation of board_set_charge_limit b75dc90677 Add CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT f1b563c350 baseboard: Sort header files 7d01b1e58d driver/retimer/ps8818.h: Add I2C ADDR FLAGS 0x30, 0x58, 0x70 ec31407993 Add CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 8f89f69a5b crota: disable lid angle sensor for clamshell BRANCH=None BUG=b:259002141 b:255184961 b:247100970 b:259354679 b:260630630 BUG=b:163093572 b:254328661 TEST=`emerge-brya chromeos-ec` Force-Relevant-Builds: all Change-Id: Ia85a701fbf6b8e67ec214b9e25e0e55e980a6f47 Signed-off-by: YH Lin <yueherngl@google.com>
-rw-r--r--.gitlab-ci.yml23
-rw-r--r--CMakeLists.txt3
-rw-r--r--Makefile.toolchain12
-rw-r--r--PRESUBMIT.cfg1
-rw-r--r--baseboard/asurada/baseboard.c8
-rw-r--r--baseboard/asurada/baseboard.h5
-rw-r--r--baseboard/asurada/regulator.c2
-rw-r--r--baseboard/asurada/usbc_config.c18
-rw-r--r--baseboard/brask/baseboard.c1
-rw-r--r--baseboard/brask/baseboard.h8
-rw-r--r--baseboard/brask/cbi.c6
-rw-r--r--baseboard/brask/usb_pd_policy.c9
-rw-r--r--baseboard/brya/baseboard.h11
-rw-r--r--baseboard/brya/baseboard_usbc_config.h2
-rw-r--r--baseboard/brya/battery_presence.c4
-rw-r--r--baseboard/brya/cbi.c6
-rw-r--r--baseboard/brya/charger_bq25720.c12
-rw-r--r--baseboard/brya/usb_pd_policy.c9
-rw-r--r--baseboard/cherry/baseboard.c6
-rw-r--r--baseboard/cherry/baseboard.h5
-rw-r--r--baseboard/dedede/baseboard.c2
-rw-r--r--baseboard/dedede/baseboard.h3
-rw-r--r--baseboard/goroh/baseboard.c18
-rw-r--r--baseboard/goroh/baseboard.h5
-rw-r--r--baseboard/goroh/usbc_config.c16
-rw-r--r--baseboard/grunt/baseboard.c12
-rw-r--r--baseboard/grunt/baseboard.h22
-rw-r--r--baseboard/guybrush/baseboard.c17
-rw-r--r--baseboard/guybrush/baseboard.h3
-rw-r--r--baseboard/guybrush/cbi.c2
-rw-r--r--baseboard/hatch/baseboard.c7
-rw-r--r--baseboard/hatch/baseboard.h4
-rw-r--r--baseboard/herobrine/baseboard.h3
-rw-r--r--baseboard/herobrine/usbc_config.c2
-rw-r--r--baseboard/honeybuns/baseboard.c4
-rw-r--r--baseboard/honeybuns/baseboard.h1
-rw-r--r--baseboard/honeybuns/usb_pd_policy.c3
-rw-r--r--baseboard/honeybuns/usbc_support.c10
-rw-r--r--baseboard/intelrvp/adlrvp.c4
-rw-r--r--baseboard/intelrvp/baseboard.h3
-rw-r--r--baseboard/intelrvp/chg_usb_pd.c7
-rw-r--r--baseboard/intelrvp/chg_usb_pd_mecc_1_0.c2
-rw-r--r--baseboard/ite_evb/baseboard.c2
-rw-r--r--baseboard/ite_evb/usb_pd_policy.c4
-rw-r--r--baseboard/kalista/baseboard.c3
-rw-r--r--baseboard/kalista/usb_pd_policy.c4
-rw-r--r--baseboard/kukui/baseboard.h10
-rw-r--r--baseboard/kukui/charger_mt6370.c7
-rw-r--r--baseboard/kukui/emmc.c3
-rw-r--r--baseboard/kukui/emmc_ite.c3
-rw-r--r--baseboard/nucleo-f412zg/base-board.h1
-rw-r--r--baseboard/nucleo-h743zi/base-board.h1
-rw-r--r--baseboard/octopus/baseboard.c14
-rw-r--r--baseboard/octopus/baseboard.h8
-rw-r--r--baseboard/octopus/variant_usbc_ec_tcpcs.c2
-rw-r--r--baseboard/trogdor/baseboard.h3
-rw-r--r--baseboard/volteer/baseboard.c2
-rw-r--r--baseboard/volteer/baseboard.h7
-rw-r--r--baseboard/volteer/battery_presence.c4
-rw-r--r--baseboard/volteer/cbi.h2
-rw-r--r--baseboard/volteer/cbi_ec_fw_config.c2
-rw-r--r--baseboard/volteer/charger.c11
-rw-r--r--baseboard/volteer/usb_pd_policy.c4
-rw-r--r--baseboard/volteer/usbc_config.c15
-rw-r--r--baseboard/zork/baseboard.c9
-rw-r--r--baseboard/zork/baseboard.h21
-rw-r--r--baseboard/zork/cbi_ec_fw_config.c2
-rw-r--r--baseboard/zork/variant_trembyle.c2
-rw-r--r--board/adlrvpp_mchp1521/board.h3
-rw-r--r--board/agah/charger_isl9241.c7
-rw-r--r--board/agah/usbc_config.c2
-rw-r--r--board/ambassador/board.c4
-rw-r--r--board/anahera/board.c12
-rw-r--r--board/anahera/board.h2
-rw-r--r--board/anahera/charger.c7
-rw-r--r--board/atlas/board.c32
-rw-r--r--board/atlas/board.h4
-rw-r--r--board/banshee/charger.c7
-rw-r--r--board/beadrix/board.c13
-rw-r--r--board/beetley/board.c13
-rw-r--r--board/beetley/board.h5
-rw-r--r--board/bellis/board.c8
-rw-r--r--board/bellis/board.h1
-rw-r--r--board/blipper/board.c13
-rw-r--r--board/blipper/board.h5
-rw-r--r--board/boten/board.c13
-rw-r--r--board/boten/board.h5
-rw-r--r--board/brask/led.c4
-rw-r--r--board/brya/charger.c7
-rw-r--r--board/bugzzy/board.c13
-rw-r--r--board/bugzzy/board.h13
-rw-r--r--board/burnet/board.c8
-rw-r--r--board/burnet/board.h4
-rw-r--r--board/c2d2/board.h1
-rw-r--r--board/cappy2/board.c13
-rw-r--r--board/cappy2/board.h5
-rw-r--r--board/casta/board.c3
-rw-r--r--board/cerise/board.c8
-rw-r--r--board/cerise/board.h1
-rw-r--r--board/cherry/board.c7
-rw-r--r--board/chocodile_vpdmcu/board.h2
-rw-r--r--board/coachz/board.c9
-rw-r--r--board/coachz/board.h2
-rw-r--r--board/coffeecake/board.h1
-rw-r--r--board/coral/board.c8
-rw-r--r--board/coral/board.h4
-rw-r--r--board/corori/board.c13
-rw-r--r--board/corori/board.h5
-rw-r--r--board/corori2/board.c13
-rw-r--r--board/corori2/board.h8
-rw-r--r--board/cret/board.c13
-rw-r--r--board/cret/board.h5
-rw-r--r--board/crota/board.c2
-rw-r--r--board/crota/board.h2
-rw-r--r--board/crota/charger.c7
-rw-r--r--board/crota/sensors.c21
-rw-r--r--board/damu/board.c8
-rw-r--r--board/damu/board.h1
-rw-r--r--board/dibbi/board.c374
-rw-r--r--board/dibbi/board.h145
-rw-r--r--board/dibbi/build.mk14
-rw-r--r--board/dibbi/ec.tasklist16
-rw-r--r--board/dibbi/gpio.inc142
-rw-r--r--board/dibbi/led.c38
-rw-r--r--board/dibbi/usb_pd_policy.c69
-rw-r--r--board/dibbi/vif_override.xml3
-rw-r--r--board/dingdong/board.h1
-rw-r--r--board/discovery-stm32f072/board.h1
-rw-r--r--board/discovery/board.h11
-rw-r--r--board/dojo/board.c7
-rw-r--r--board/dooly/board.c4
-rw-r--r--board/drawcia/board.c10
-rw-r--r--board/drawcia_riscv/board.c10
-rw-r--r--board/driblee/board.c13
-rw-r--r--board/driblee/board.h5
-rw-r--r--board/drobit/board.c14
-rw-r--r--board/drobit/board.h1
-rw-r--r--board/eldrid/board.c9
-rw-r--r--board/eldrid/board.h2
-rw-r--r--board/elm/board.c9
-rw-r--r--board/elm/board.h5
-rw-r--r--board/eve/board.c8
-rw-r--r--board/eve/board.h4
-rw-r--r--board/ezkinil/board.c13
-rw-r--r--board/ezkinil/board.h3
-rw-r--r--board/felwinter/board.h1
-rw-r--r--board/felwinter/charger_isl9241.c8
-rw-r--r--board/fennel/board.c8
-rw-r--r--board/fennel/board.h1
-rw-r--r--board/fizz/board.c4
-rw-r--r--board/fluffy/board.h1
-rw-r--r--board/fusb307bgevb/board.h1
-rw-r--r--board/gaelin/board.c50
-rw-r--r--board/gaelin/board.h61
-rw-r--r--board/gaelin/build.mk1
-rw-r--r--board/gaelin/ec.tasklist5
-rw-r--r--board/gaelin/fans.c12
-rw-r--r--board/gaelin/gpio.inc91
-rw-r--r--board/gaelin/i2c.c52
-rw-r--r--board/gaelin/led.c4
-rw-r--r--board/gaelin/pwm.c4
-rw-r--r--board/gaelin/thermal.c140
-rw-r--r--board/gaelin/usbc_config.c289
-rw-r--r--board/gaelin/usbc_config.h9
-rw-r--r--board/galtic/board.c12
-rw-r--r--board/gelarshie/board.c9
-rw-r--r--board/gelarshie/board.h4
-rw-r--r--board/gimble/board.c13
-rw-r--r--board/gimble/board.h2
-rw-r--r--board/gimble/charger.c7
-rw-r--r--board/gooey/board.c13
-rw-r--r--board/gooey/board.h5
-rw-r--r--board/haboki/board.c10
-rw-r--r--board/hammer/board.h3
-rw-r--r--board/hatch_fp/board.h1
-rw-r--r--board/hatch_fp/build.mk4
-rw-r--r--board/herobrine/usbc_config.c8
-rw-r--r--board/hoho/board.h1
-rw-r--r--board/homestar/board.c9
-rw-r--r--board/homestar/board.h3
-rw-r--r--board/host/charger.c3
-rw-r--r--board/hyperdebug/board.c22
-rw-r--r--board/hyperdebug/board.h1
-rw-r--r--board/icarus/board.c8
-rw-r--r--board/icarus/board.h1
-rw-r--r--board/jacuzzi/board.c8
-rw-r--r--board/jacuzzi/board.h1
-rw-r--r--board/kano/charger.c7
-rw-r--r--board/kappa/board.c8
-rw-r--r--board/kappa/board.h1
-rw-r--r--board/kappa/led.c1
-rw-r--r--board/kingoftown/usbc_config.c8
-rw-r--r--board/kinox/board.c4
-rw-r--r--board/kracko/board.c10
-rw-r--r--board/kuldax/led.c4
-rw-r--r--board/kuldax/sensors.c6
-rw-r--r--board/lalala/board.c13
-rw-r--r--board/lalala/board.h5
-rw-r--r--board/lantis/board.c12
-rw-r--r--board/lazor/usbc_config.c8
-rw-r--r--board/lisbon/led.c4
-rw-r--r--board/madoo/board.c14
-rw-r--r--board/madoo/board.h5
-rw-r--r--board/magolor/board.c15
-rw-r--r--board/magolor/board.h5
-rw-r--r--board/makomo/board.c8
-rw-r--r--board/makomo/board.h1
-rw-r--r--board/marasov/battery.c77
-rw-r--r--board/marasov/board.c52
-rw-r--r--board/marasov/board.h217
-rw-r--r--board/marasov/build.mk25
-rw-r--r--board/marasov/charger.c83
-rw-r--r--board/marasov/ec.tasklist26
-rw-r--r--board/marasov/fans.c89
-rw-r--r--board/marasov/fw_config.c46
-rw-r--r--board/marasov/fw_config.h52
-rw-r--r--board/marasov/generated-gpio.inc127
-rw-r--r--board/marasov/gpio.inc38
-rw-r--r--board/marasov/i2c.c81
-rw-r--r--board/marasov/keyboard.c25
-rw-r--r--board/marasov/led.c101
-rw-r--r--board/marasov/pwm.c38
-rw-r--r--board/marasov/sensors.c187
-rw-r--r--board/marasov/usbc_config.c348
-rw-r--r--board/marasov/usbc_config.h17
-rw-r--r--board/marasov/vif_override.xml148
-rw-r--r--board/marzipan/board.c8
-rw-r--r--board/mchpevb1/board.c15
-rw-r--r--board/mchpevb1/board.h3
-rw-r--r--board/metaknight/board.c13
-rw-r--r--board/metaknight/board.h5
-rw-r--r--board/mithrax/board.h1
-rw-r--r--board/mithrax/charger_isl9241.c8
-rw-r--r--board/moli/board.c149
-rw-r--r--board/moli/board.h18
-rw-r--r--board/moli/build.mk1
-rw-r--r--board/moli/fw_config.c73
-rw-r--r--board/moli/fw_config.h53
-rw-r--r--board/moli/gpio.inc12
-rw-r--r--board/moli/led.c4
-rw-r--r--board/mrbland/board.c8
-rw-r--r--board/mrbland/board.h2
-rw-r--r--board/munna/board.c8
-rw-r--r--board/munna/board.h1
-rw-r--r--board/nami/board.c7
-rw-r--r--board/nami/board.h3
-rw-r--r--board/nautilus/board.c20
-rw-r--r--board/nautilus/board.h4
-rw-r--r--board/nocturne/board.c13
-rw-r--r--board/nocturne/board.h11
-rw-r--r--board/nocturne_fp/board.h1
-rw-r--r--board/nocturne_fp/build.mk4
-rw-r--r--board/nucleo-dartmonkey/build.mk2
-rw-r--r--board/nucleo-f072rb/board.h1
-rw-r--r--board/nucleo-f411re/board.h1
-rw-r--r--board/nucleo-f412zg/build.mk2
-rw-r--r--board/nucleo-g431rb/board.h1
-rw-r--r--board/nucleo-h743zi/build.mk2
-rw-r--r--board/oak/board.c7
-rw-r--r--board/oak/board.h5
-rw-r--r--board/osiris/charger.c7
-rw-r--r--board/pazquel/board.c8
-rw-r--r--board/pdeval-stm32f072/board.h1
-rw-r--r--board/pico/board.c8
-rw-r--r--board/pico/board.h1
-rw-r--r--board/pirika/board.c14
-rw-r--r--board/plankton/board.h1
-rw-r--r--board/polyberry/board.h1
-rw-r--r--board/pompom/board.c51
-rw-r--r--board/pompom/board.h3
-rw-r--r--board/poppy/board.c9
-rw-r--r--board/poppy/board.h3
-rw-r--r--board/primus/board.c7
-rw-r--r--board/primus/charger.c7
-rw-r--r--board/prism/board.h1
-rw-r--r--board/puff/board.c4
-rw-r--r--board/quackingstick/board.c8
-rw-r--r--board/quackingstick/board.h2
-rw-r--r--board/rainier/board.c4
-rw-r--r--board/rainier/board.h1
-rw-r--r--board/rammus/board.c20
-rw-r--r--board/rammus/board.h4
-rw-r--r--board/redrix/charger.c7
-rw-r--r--board/reef/board.c8
-rw-r--r--board/reef/board.h4
-rw-r--r--board/reef_it8320/board.c8
-rw-r--r--board/reef_it8320/board.h4
-rw-r--r--board/reef_mchp/board.c8
-rw-r--r--board/reef_mchp/board.h4
-rw-r--r--board/sasuke/board.c13
-rw-r--r--board/sasuke/board.h5
-rw-r--r--board/sasukette/board.c13
-rw-r--r--board/sasukette/board.h5
-rw-r--r--board/scarlet/board.c7
-rw-r--r--board/scarlet/board.h4
-rw-r--r--board/servo_micro/board.h1
-rw-r--r--board/servo_v4/board.h3
-rw-r--r--board/servo_v4/usb_pd_policy.c4
-rw-r--r--board/servo_v4p1/board.h1
-rw-r--r--board/servo_v4p1/usb_pd_policy.c4
-rw-r--r--board/shotzo/board.c4
-rw-r--r--board/stern/board.c8
-rw-r--r--board/stern/board.h1
-rw-r--r--board/stm32f446e-eval/board.h1
-rw-r--r--board/stm32l476g-eval/board.h1
-rw-r--r--board/storo/board.c13
-rw-r--r--board/storo/board.h5
-rw-r--r--board/sweetberry/board.h1
-rw-r--r--board/taeko/board.c13
-rw-r--r--board/taeko/board.h3
-rw-r--r--board/taeko/charger.c7
-rw-r--r--board/taniks/board.c13
-rw-r--r--board/taniks/board.h3
-rw-r--r--board/taniks/charger.c7
-rw-r--r--board/terrador/board.c1
-rw-r--r--board/tglrvp_ish/board.h5
-rw-r--r--board/tigertail/board.h1
-rw-r--r--board/trogdor/usbc_config.c8
-rw-r--r--board/twinkie/board.h3
-rw-r--r--board/vell/board.h2
-rw-r--r--board/vell/charger.c12
-rw-r--r--board/vilboz/board.c13
-rw-r--r--board/vilboz/board.h1
-rw-r--r--board/volmar/charger.c7
-rw-r--r--board/waddledee/board.c12
-rw-r--r--board/waddledoo/board.c13
-rw-r--r--board/waddledoo/board.h9
-rw-r--r--board/waddledoo2/board.c13
-rw-r--r--board/waddledoo2/board.h5
-rw-r--r--board/wheelie/board.c12
-rw-r--r--board/willow/board.c8
-rw-r--r--board/willow/board.h1
-rw-r--r--board/woomax/board.c2
-rw-r--r--board/wormdingler/board.c9
-rw-r--r--board/wormdingler/board.h2
-rw-r--r--builtin/assert.h14
-rw-r--r--builtin/inttypes.h2
-rw-r--r--builtin/math.h3
-rw-r--r--builtin/stdio.h6
-rw-r--r--chip/host/flash.c4
-rw-r--r--chip/host/gpio.c2
-rw-r--r--chip/host/persistence.c9
-rw-r--r--chip/host/reboot.c7
-rw-r--r--chip/host/spi_controller.c5
-rw-r--r--chip/host/trng.c4
-rw-r--r--chip/host/uart.c13
-rw-r--r--chip/ish/aontaskfw/ish_aontask.c73
-rw-r--r--chip/ish/clock.c2
-rw-r--r--chip/ish/dma.c42
-rw-r--r--chip/ish/hbm.h6
-rw-r--r--chip/ish/heci_client.h6
-rw-r--r--chip/ish/hid_device.h6
-rw-r--r--chip/ish/hwtimer.c2
-rw-r--r--chip/ish/i2c.c6
-rw-r--r--chip/ish/ipc_heci.c10
-rw-r--r--chip/ish/ipc_heci.h2
-rw-r--r--chip/ish/ish_dma.h41
-rw-r--r--chip/ish/ish_i2c.h3
-rw-r--r--chip/ish/ish_persistent_data.c4
-rw-r--r--chip/ish/power_mgt.c34
-rw-r--r--chip/ish/power_mgt.h4
-rw-r--r--chip/ish/registers.h78
-rw-r--r--chip/ish/system_state_subsys.c2
-rw-r--r--chip/ish/uart.c11
-rw-r--r--chip/ish/uart_defs.h5
-rw-r--r--chip/ish/watchdog.c2
-rw-r--r--chip/it83xx/adc.c2
-rw-r--r--chip/it83xx/adc_chip.h4
-rw-r--r--chip/it83xx/flash.c8
-rw-r--r--chip/it83xx/hwtimer.c2
-rw-r--r--chip/it83xx/i2c_peripheral.c3
-rw-r--r--chip/it83xx/keyboard_raw.c2
-rw-r--r--chip/it83xx/peci.c4
-rw-r--r--chip/it83xx/pwm.c2
-rw-r--r--chip/max32660/clock_chip.c6
-rw-r--r--chip/max32660/flash_chip.c8
-rw-r--r--chip/max32660/gpio_chip.c6
-rw-r--r--chip/max32660/hwtimer_chip.c6
-rw-r--r--chip/max32660/i2c_chip.c9
-rw-r--r--chip/max32660/system_chip.c4
-rw-r--r--chip/max32660/uart_chip.c15
-rw-r--r--chip/max32660/wdt_chip.c6
-rw-r--r--chip/mchp/adc.c2
-rw-r--r--chip/mchp/clock.c2
-rw-r--r--chip/mchp/dma.c2
-rw-r--r--chip/mchp/dma_chip.h2
-rw-r--r--chip/mchp/espi.c19
-rw-r--r--chip/mchp/fan.c2
-rw-r--r--chip/mchp/flash.c4
-rw-r--r--chip/mchp/gpio.c4
-rw-r--r--chip/mchp/gpio_chip.h6
-rw-r--r--chip/mchp/gpio_cmds.c4
-rw-r--r--chip/mchp/gpspi.c10
-rw-r--r--chip/mchp/gpspi_chip.h2
-rw-r--r--chip/mchp/hwtimer.c2
-rw-r--r--chip/mchp/keyboard_raw.c2
-rw-r--r--chip/mchp/lfw/ec_lfw.c27
-rw-r--r--chip/mchp/lfw/ec_lfw.h1
-rw-r--r--chip/mchp/lfw/ec_lfw.ld10
-rw-r--r--chip/mchp/lfw/ec_lfw_416kb.ld10
-rw-r--r--chip/mchp/lpc.c8
-rw-r--r--chip/mchp/pwm.c2
-rw-r--r--chip/mchp/qmspi.c12
-rw-r--r--chip/mchp/qmspi_chip.h2
-rw-r--r--chip/mchp/spi.c8
-rw-r--r--chip/mchp/spi_chip.h2
-rw-r--r--chip/mchp/system.c6
-rw-r--r--chip/mchp/uart.c2
-rw-r--r--chip/mchp/watchdog.c2
-rw-r--r--chip/mt_scp/mt818x/ipi.c2
-rw-r--r--chip/mt_scp/mt818x/memmap.c2
-rw-r--r--chip/mt_scp/mt8192/clock.c6
-rw-r--r--chip/mt_scp/mt8195/clock.c6
-rw-r--r--chip/npcx/adc.c2
-rw-r--r--chip/npcx/espi.c17
-rw-r--r--chip/npcx/fan.c13
-rw-r--r--chip/npcx/flash.c6
-rw-r--r--chip/npcx/gpio.c12
-rw-r--r--chip/npcx/header.c4
-rw-r--r--chip/npcx/hwtimer.c2
-rw-r--r--chip/npcx/keyboard_raw.c4
-rw-r--r--chip/npcx/lct.c2
-rw-r--r--chip/npcx/lpc.c4
-rw-r--r--chip/npcx/peci.c2
-rw-r--r--chip/npcx/ps2.c4
-rw-r--r--chip/npcx/registers.h2
-rw-r--r--chip/npcx/sha256_chip.c2
-rw-r--r--chip/npcx/shi.c2
-rw-r--r--chip/npcx/spi.c4
-rw-r--r--chip/npcx/spiflashfw/npcx_monitor.c3
-rw-r--r--chip/npcx/system-npcx7.c8
-rw-r--r--chip/npcx/system-npcx9.c8
-rw-r--r--chip/npcx/uart.c2
-rw-r--r--chip/npcx/uartn.c7
-rw-r--r--chip/npcx/watchdog.c8
-rw-r--r--chip/stm32/adc-stm32l.c2
-rw-r--r--chip/stm32/bkpdata.c4
-rw-r--r--chip/stm32/build.mk4
-rw-r--r--chip/stm32/clock-f.c2
-rw-r--r--chip/stm32/clock-stm32f0.c2
-rw-r--r--chip/stm32/clock-stm32f3.c2
-rw-r--r--chip/stm32/clock-stm32f4.c2
-rw-r--r--chip/stm32/clock-stm32g4.c2
-rw-r--r--chip/stm32/clock-stm32h7.c4
-rw-r--r--chip/stm32/clock-stm32l4.c2
-rw-r--r--chip/stm32/config-stm32l15x.h15
-rw-r--r--chip/stm32/flash-f.c9
-rw-r--r--chip/stm32/flash-stm32f3.c7
-rw-r--r--chip/stm32/flash-stm32f4.c7
-rw-r--r--chip/stm32/flash-stm32g4-l4.c4
-rw-r--r--chip/stm32/flash-stm32h7.c6
-rw-r--r--chip/stm32/hwtimer.c481
-rw-r--r--chip/stm32/hwtimer32.c2
-rw-r--r--chip/stm32/i2c-stm32l4.c3
-rw-r--r--chip/stm32/i2c_ite_flash_support.c2
-rw-r--r--chip/stm32/pwm.c2
-rw-r--r--chip/stm32/uart.c4
-rw-r--r--chip/stm32/ucpd-stm32gx.c2
-rw-r--r--chip/stm32/usart-stm32f0.c3
-rw-r--r--chip/stm32/usart-stm32f3.c3
-rw-r--r--chip/stm32/usart-stm32f4.c3
-rw-r--r--chip/stm32/usart-stm32l.c3
-rw-r--r--chip/stm32/usart-stm32l5.c3
-rw-r--r--chip/stm32/usart_host_command.c6
-rw-r--r--chip/stm32/usart_host_command.h3
-rw-r--r--chip/stm32/usart_rx_dma.c3
-rw-r--r--chip/stm32/usart_rx_dma.h2
-rw-r--r--chip/stm32/usart_rx_interrupt-stm32f0.c3
-rw-r--r--chip/stm32/usart_rx_interrupt-stm32f3.c3
-rw-r--r--chip/stm32/usart_rx_interrupt-stm32f4.c3
-rw-r--r--chip/stm32/usart_rx_interrupt-stm32l.c3
-rw-r--r--chip/stm32/usart_rx_interrupt.c3
-rw-r--r--chip/stm32/usart_tx_dma.c5
-rw-r--r--chip/stm32/usart_tx_interrupt.c3
-rw-r--r--chip/stm32/usb-stm32f3.c3
-rw-r--r--chip/stm32/usb-stream.c4
-rw-r--r--chip/stm32/usb.c2
-rw-r--r--chip/stm32/usb_console.c2
-rw-r--r--chip/stm32/usb_dwc.c4
-rw-r--r--chip/stm32/usb_dwc_console.c2
-rw-r--r--chip/stm32/usb_dwc_stream.c3
-rw-r--r--chip/stm32/usb_dwc_stream.h2
-rw-r--r--chip/stm32/usb_endpoints.c7
-rw-r--r--chip/stm32/usb_hid.c4
-rw-r--r--chip/stm32/usb_hid_hw.h2
-rw-r--r--chip/stm32/usb_hid_keyboard.c4
-rw-r--r--chip/stm32/usb_hid_touchpad.c4
-rw-r--r--chip/stm32/usb_isochronous.c4
-rw-r--r--chip/stm32/usb_pd_phy.c4
-rw-r--r--cmake/toolchain-armv7m.cmake38
-rw-r--r--common/accel_cal.c2
-rw-r--r--common/acpi.c8
-rw-r--r--common/base32.c2
-rw-r--r--common/base_state.c2
-rw-r--r--common/battery_fuel_gauge.c31
-rw-r--r--common/battery_v2.c4
-rw-r--r--common/bluetooth_le.c4
-rw-r--r--common/body_detection.c5
-rw-r--r--common/btle_hci_controller.c4
-rw-r--r--common/btle_ll.c4
-rw-r--r--common/button.c2
-rw-r--r--common/charge_manager.c16
-rw-r--r--common/charge_state_v2.c42
-rw-r--r--common/chargen.c4
-rw-r--r--common/charger.c13
-rw-r--r--common/chargesplash.c6
-rw-r--r--common/chipset.c18
-rw-r--r--common/dps.c14
-rw-r--r--common/ec_ec_comm_server.c9
-rw-r--r--common/ec_features.c8
-rw-r--r--common/espi.c2
-rw-r--r--common/flash.c63
-rw-r--r--common/fmap.c4
-rw-r--r--common/fpsensor/fpsensor_crypto.c6
-rw-r--r--common/gesture.c2
-rw-r--r--common/gpio_commands.c5
-rw-r--r--common/gyro_cal.c1
-rw-r--r--common/host_command_pd.c5
-rw-r--r--common/i2c_controller.c11
-rw-r--r--common/i2c_controller_cros_ec.c9
-rw-r--r--common/i2c_hid_touchpad.c3
-rw-r--r--common/i2c_trace.c4
-rw-r--r--common/init_rom.c2
-rw-r--r--common/kasa.c1
-rw-r--r--common/keyboard_8042.c115
-rw-r--r--common/keyboard_8042_sharedlib.c4
-rw-r--r--common/keyboard_scan.c14
-rw-r--r--common/keyboard_vivaldi.c7
-rw-r--r--common/led_common.c7
-rw-r--r--common/led_policy_std.c6
-rw-r--r--common/lightbar.c2
-rw-r--r--common/mag_cal.c1
-rw-r--r--common/mkbp_event.c9
-rw-r--r--common/mock/charge_manager_mock.c4
-rw-r--r--common/mock/dp_alt_mode_mock.c2
-rw-r--r--common/mock/fp_sensor_mock.c4
-rw-r--r--common/mock/fpsensor_crypto_mock.c9
-rw-r--r--common/mock/fpsensor_state_mock.c6
-rw-r--r--common/mock/mkbp_events_mock.c4
-rw-r--r--common/mock/rollback_latest_mock.c6
-rw-r--r--common/mock/rollback_mock.c8
-rw-r--r--common/mock/usb_mux_mock.c4
-rw-r--r--common/mock/usb_pd_dpm_mock.c10
-rw-r--r--common/mock/usb_pe_sm_mock.c6
-rw-r--r--common/mock/usb_prl_mock.c9
-rw-r--r--common/mock/usb_tc_sm_mock.c4
-rw-r--r--common/motion_lid.c4
-rw-r--r--common/motion_sense.c30
-rw-r--r--common/motion_sense_fifo.c6
-rw-r--r--common/newton_fit.c3
-rw-r--r--common/ocpc.c63
-rw-r--r--common/online_calibration.c14
-rw-r--r--common/panic_output.c16
-rw-r--r--common/power_button.c21
-rw-r--r--common/pwm_kblight.c6
-rw-r--r--common/rgb_keyboard.c5
-rw-r--r--common/shmalloc.c4
-rw-r--r--common/spi/flash_reg/CMakeLists.txt8
-rw-r--r--common/spi/flash_reg/src/spi_flash_reg_test.c4
-rw-r--r--common/spi_flash.c4
-rw-r--r--common/spi_nor.c8
-rw-r--r--common/stillness_detector.c1
-rw-r--r--common/system.c36
-rw-r--r--common/tablet_mode.c85
-rw-r--r--common/test_util.c3
-rw-r--r--common/timer.c2
-rw-r--r--common/uart_buffering.c4
-rw-r--r--common/uart_hostcmd.c2
-rw-r--r--common/uart_printf.c29
-rw-r--r--common/uptime.c6
-rw-r--r--common/usb_common.c24
-rw-r--r--common/usb_host_command.c4
-rw-r--r--common/usb_i2c.c12
-rw-r--r--common/usb_pd_alt_mode_dfp.c2
-rw-r--r--common/usb_pd_console_cmd.c2
-rw-r--r--common/usb_pd_host_cmd.c6
-rw-r--r--common/usb_pd_pdo.c2
-rw-r--r--common/usb_pd_policy.c2
-rw-r--r--common/usb_pd_protocol.c4
-rw-r--r--common/usb_pd_tcpc.c2
-rw-r--r--common/usb_update.c2
-rw-r--r--common/usbc/dp_alt_mode.c11
-rw-r--r--common/usbc/tbt_alt_mode.c5
-rw-r--r--common/usbc/usb_mode.c7
-rw-r--r--common/usbc/usb_pd_console.c6
-rw-r--r--common/usbc/usb_pd_dpm.c690
-rw-r--r--common/usbc/usb_pd_host.c36
-rw-r--r--common/usbc/usb_pe_ctvpd_sm.c7
-rw-r--r--common/usbc/usb_pe_drp_sm.c197
-rw-r--r--common/usbc/usb_prl_sm.c6
-rw-r--r--common/usbc/usb_retimer_fw_update.c6
-rw-r--r--common/usbc/usb_tc_drp_acc_trysrc_sm.c9
-rw-r--r--common/usbc/usb_tc_vpd_sm.c2
-rw-r--r--common/usbc/usbc_task.c10
-rw-r--r--common/usbc_intr_task.c4
-rw-r--r--common/usbc_ocp.c5
-rw-r--r--common/vboot/efs2.c2
-rw-r--r--common/vboot/vboot.c4
-rw-r--r--common/vec3.c2
-rw-r--r--common/version.c3
-rw-r--r--common/virtual_battery.c8
-rw-r--r--core/cortex-m/cpu.h3
-rw-r--r--core/cortex-m/ec.lds.S7
-rw-r--r--core/cortex-m/include/mpu_private.h4
-rw-r--r--core/cortex-m/llsr.c5
-rw-r--r--core/cortex-m/mpu.c18
-rw-r--r--core/cortex-m/panic.c2
-rw-r--r--core/cortex-m/vecttable.c1
-rw-r--r--core/cortex-m0/build.mk14
-rw-r--r--core/cortex-m0/config_core.h5
-rw-r--r--core/cortex-m0/cpu.h3
-rw-r--r--core/cortex-m0/panic.c2
-rw-r--r--core/cortex-m0/vecttable.c6
-rw-r--r--core/host/host_task.h4
-rw-r--r--core/host/panic.c10
-rw-r--r--core/host/stack_trace.c14
-rw-r--r--core/host/task.c19
-rw-r--r--core/host/timer.c6
-rw-r--r--core/minute-ia/mpu.c2
-rw-r--r--core/minute-ia/task.c6
-rw-r--r--core/riscv-rv32i/panic.c2
-rw-r--r--cts/common/th_common.c2
-rw-r--r--cts/gpio/dut.c5
-rw-r--r--cts/gpio/th.c5
-rw-r--r--cts/i2c/th.c3
-rw-r--r--cts/interrupt/dut.c3
-rw-r--r--cts/mutex/dut.c2
-rw-r--r--cts/mutex/th.c2
-rw-r--r--docs/code_coverage.md4
-rw-r--r--docs/gitlab.md71
-rw-r--r--docs/low_battery_startup.md35
-rw-r--r--docs/zephyr/README.md2
-rw-r--r--docs/zephyr/project_config.md460
-rw-r--r--docs/zephyr/zephyr_battery.md5
-rw-r--r--docs/zephyr/zephyr_charger.md6
-rw-r--r--docs/zephyr/zephyr_leds.md48
-rw-r--r--docs/zephyr/zephyr_mkbp.md2
-rw-r--r--docs/zephyr/zephyr_new_board_checklist.md2
-rw-r--r--docs/zephyr/zephyr_ssfc.md20
-rw-r--r--docs/zephyr/zephyr_temperature_sensor.md2
-rw-r--r--docs/zephyr/zephyr_troubleshooting.md8
-rw-r--r--docs/zephyr/ztest.md64
-rw-r--r--driver/accel_bma2x2.c2
-rw-r--r--driver/accel_bma4xx.c5
-rw-r--r--driver/accel_bma4xx.h7
-rw-r--r--driver/accel_kionix.c6
-rw-r--r--driver/accel_kionix.h2
-rw-r--r--driver/accel_lis2dh.c4
-rw-r--r--driver/accel_lis2dw12.c2
-rw-r--r--driver/accelgyro_bmi160.c6
-rw-r--r--driver/accelgyro_bmi260.c4
-rw-r--r--driver/accelgyro_bmi_common.c4
-rw-r--r--driver/accelgyro_icm42607.c2
-rw-r--r--driver/accelgyro_icm426xx.c2
-rw-r--r--driver/accelgyro_icm_common.c4
-rw-r--r--driver/accelgyro_icm_common.h6
-rw-r--r--driver/accelgyro_lsm6dsm.h4
-rw-r--r--driver/als_cm32183.c2
-rw-r--r--driver/als_tcs3400.c2
-rw-r--r--driver/amd_stt.c2
-rw-r--r--driver/battery/bq27621_g1.c2
-rw-r--r--driver/bc12/max14637.c2
-rw-r--r--driver/bc12/mt6360.c4
-rw-r--r--driver/bc12/pi3usb9201.c2
-rw-r--r--driver/charger/bd9995x.c13
-rw-r--r--driver/charger/bq24715.c6
-rw-r--r--driver/charger/bq24773.c2
-rw-r--r--driver/charger/bq25710.c6
-rw-r--r--driver/charger/isl923x.c8
-rw-r--r--driver/charger/isl9241.c8
-rw-r--r--driver/charger/rt946x.c4
-rw-r--r--driver/charger/rt9490.c10
-rw-r--r--driver/charger/rt9490.h7
-rw-r--r--driver/charger/sm5803.c4
-rw-r--r--driver/fingerprint/elan/elan_private.c16
-rw-r--r--driver/fingerprint/elan/elan_sensor_pal.c14
-rw-r--r--driver/fingerprint/fpc/bep/fpc_misc.c6
-rw-r--r--driver/fingerprint/fpc/bep/fpc_private.c7
-rw-r--r--driver/fingerprint/fpc/bep/fpc_private.h8
-rw-r--r--driver/fingerprint/fpc/bep/fpc_sensor_spi.c11
-rw-r--r--driver/fingerprint/fpc/bep/fpc_sensor_spi.h3
-rw-r--r--driver/fingerprint/fpc/bep/fpc_timebase.c4
-rw-r--r--driver/fingerprint/fpc/bep/fpc_timebase.h4
-rw-r--r--driver/fingerprint/fpc/fpc_sensor.c3
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h3
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_private.c7
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_private.h8
-rw-r--r--driver/fingerprint/fpc/libfp/fpc_sensor_pal.c2
-rw-r--r--driver/gl3590.c5
-rw-r--r--driver/ina2xx.c2
-rw-r--r--driver/ina3221.c2
-rw-r--r--driver/ioexpander/it8801.c8
-rw-r--r--driver/ioexpander/pcal6408.c2
-rw-r--r--driver/led/aw20198.c4
-rw-r--r--driver/led/is31fl3733b.c3
-rw-r--r--driver/led/is31fl3743b.c4
-rw-r--r--driver/led/lm3509.c11
-rw-r--r--driver/led/mp3385.h2
-rw-r--r--driver/led/oz554.h2
-rw-r--r--driver/led/tlc59116f.c4
-rw-r--r--driver/ln9310.c2
-rw-r--r--driver/mag_lis2mdl.c2
-rw-r--r--driver/mcdp28x0.c2
-rw-r--r--driver/nfc/ctn730.c8
-rw-r--r--driver/nfc/ctn730.h1
-rw-r--r--driver/nvidia_gpu.c4
-rw-r--r--driver/ppc/ktu1125.c4
-rw-r--r--driver/ppc/ktu1125.h1
-rw-r--r--driver/ppc/nx20p348x.c4
-rw-r--r--driver/ppc/sn5s330.c4
-rw-r--r--driver/ppc/sn5s330.h1
-rw-r--r--driver/ppc/syv682x.c4
-rw-r--r--driver/retimer/anx7483.c30
-rw-r--r--driver/retimer/anx7483.h3
-rw-r--r--driver/retimer/bb_retimer.c26
-rw-r--r--driver/retimer/nb7v904m.c3
-rw-r--r--driver/retimer/pi3dpx1207.c2
-rw-r--r--driver/sb_rmi.c2
-rw-r--r--driver/stm_mems_common.h4
-rw-r--r--driver/tcpm/anx7447.c2
-rw-r--r--driver/tcpm/anx7447.h2
-rw-r--r--driver/tcpm/anx74xx.c2
-rw-r--r--driver/tcpm/fusb302.c2
-rw-r--r--driver/tcpm/it83xx.c4
-rw-r--r--driver/tcpm/it83xx_pd.h4
-rw-r--r--driver/tcpm/it8xxx2.c4
-rw-r--r--driver/tcpm/nct38xx.c3
-rw-r--r--driver/tcpm/ps8xxx.h3
-rw-r--r--driver/tcpm/rt1718s.h2
-rw-r--r--driver/tcpm/stm32gx.c4
-rw-r--r--driver/tcpm/tcpci.c7
-rw-r--r--driver/tcpm/tusb422.c2
-rw-r--r--driver/temp_sensor/adt7481.c4
-rw-r--r--driver/temp_sensor/amd_r19me4070.c2
-rw-r--r--driver/temp_sensor/f75303.c4
-rw-r--r--driver/temp_sensor/g753.c2
-rw-r--r--driver/temp_sensor/g78x.c2
-rw-r--r--driver/temp_sensor/oti502.c4
-rw-r--r--driver/temp_sensor/pct2075.c15
-rw-r--r--driver/temp_sensor/tmp112.c15
-rw-r--r--driver/temp_sensor/tmp411.c4
-rw-r--r--driver/temp_sensor/tmp432.c4
-rw-r--r--driver/temp_sensor/tmp468.c7
-rw-r--r--driver/touchpad_elan.c6
-rw-r--r--driver/touchpad_gt7288.c4
-rw-r--r--driver/touchpad_st.c4
-rw-r--r--driver/touchpad_st.h4
-rw-r--r--driver/usb_mux/pi3usb3x532.h2
-rw-r--r--driver/usb_mux/tusb1064.h3
-rw-r--r--driver/usb_mux/usb_mux.c2
-rw-r--r--driver/wpc/p9221.h2
-rw-r--r--extra/ftdi_hostcmd/test_cmds.c8
-rw-r--r--extra/lightbar/input.c6
-rw-r--r--extra/lightbar/main.c9
-rw-r--r--extra/lightbar/simulation.h7
-rw-r--r--extra/lightbar/windows.c7
-rw-r--r--extra/rma_reset/rma_reset.c23
-rw-r--r--extra/sps_errs/prog.c8
-rw-r--r--extra/touchpad_updater/touchpad_updater.c8
-rw-r--r--extra/usb_console/usb_console.c8
-rw-r--r--extra/usb_gpio/usb_gpio.c3
-rw-r--r--extra/usb_updater/desc_parser.c7
-rw-r--r--extra/usb_updater/usb_updater2.c14
-rwxr-xr-xfirmware_builder.py14
-rw-r--r--fuzz/host_command_fuzz.c6
-rw-r--r--fuzz/pchg_fuzz.c3
-rw-r--r--fuzz/span.h3
-rw-r--r--fuzz/usb_pd_fuzz.c14
-rw-r--r--include/accelgyro.h2
-rw-r--r--include/base32.h2
-rw-r--r--include/battery.h2
-rw-r--r--include/battery_fuel_gauge.h1
-rw-r--r--include/benchmark.h157
-rw-r--r--include/bluetooth_le_ll.h2
-rw-r--r--include/body_detection.h2
-rw-r--r--include/button.h2
-rw-r--r--include/charge_manager.h9
-rw-r--r--include/charge_state.h13
-rw-r--r--include/charge_state_v2.h8
-rw-r--r--include/charger.h2
-rw-r--r--include/chipset.h16
-rw-r--r--include/common.h7
-rw-r--r--include/config.h52
-rw-r--r--include/console.h1
-rw-r--r--include/crc8.h2
-rw-r--r--include/dps.h4
-rw-r--r--include/driver/accel_lis2dw12_public.h1
-rw-r--r--include/driver/accelgyro_bmi260.h2
-rw-r--r--include/driver/accelgyro_bmi_common.h2
-rw-r--r--include/driver/retimer/anx7483_public.h13
-rw-r--r--include/driver/retimer/bb_retimer.h2
-rw-r--r--include/driver/retimer/ps8818_public.h5
-rw-r--r--include/driver/temp_sensor/pct2075.h5
-rw-r--r--include/driver/temp_sensor/thermistor.h2
-rw-r--r--include/driver/temp_sensor/tmp112.h4
-rw-r--r--include/ec_commands.h42
-rw-r--r--include/ec_ec_comm_client.h3
-rw-r--r--include/ec_ec_comm_server.h3
-rw-r--r--include/event_log.h2
-rw-r--r--include/fan.h5
-rw-r--r--include/flash_log.h2
-rw-r--r--include/fpsensor.h3
-rw-r--r--include/fpsensor_crypto.h4
-rw-r--r--include/fpsensor_state.h7
-rw-r--r--include/gpio.h13
-rw-r--r--include/gpio_list.h4
-rw-r--r--include/host_command.h2
-rw-r--r--include/hwtimer.h2
-rw-r--r--include/i2c_bitbang.h4
-rw-r--r--include/keyboard_8042.h2
-rw-r--r--include/keyboard_8042_sharedlib.h4
-rw-r--r--include/keyboard_backlight.h6
-rw-r--r--include/keyboard_protocol.h2
-rw-r--r--include/keyboard_raw.h10
-rw-r--r--include/mag_cal.h4
-rw-r--r--include/math_util.h4
-rw-r--r--include/mock/fpsensor_state_mock.h6
-rw-r--r--include/mock/tcpc_mock.h2
-rw-r--r--include/mock/usb_pd_dpm_mock.h2
-rw-r--r--include/mock/usb_pe_sm_mock.h2
-rw-r--r--include/mock/usb_prl_mock.h2
-rw-r--r--include/mock/usb_tc_sm_mock.h2
-rw-r--r--include/motion_sense.h10
-rw-r--r--include/newton_fit.h2
-rw-r--r--include/ocpc.h17
-rw-r--r--include/panic.h7
-rw-r--r--include/printf.h5
-rw-r--r--include/pwm.h4
-rw-r--r--include/queue_policies.h2
-rw-r--r--include/rgb_keyboard.h4
-rw-r--r--include/rma_auth.h4
-rw-r--r--include/shared_mem.h1
-rw-r--r--include/stillness_detector.h1
-rw-r--r--include/sysjump.h10
-rw-r--r--include/system.h6
-rw-r--r--include/task.h3
-rw-r--r--include/task_id.h2
-rw-r--r--include/test_util.h4
-rw-r--r--include/tests/enum_strings.h2
-rw-r--r--include/trng.h3
-rw-r--r--include/uart.h7
-rw-r--r--include/update_fw.h4
-rw-r--r--include/usb_common.h1
-rw-r--r--include/usb_dp_alt_mode.h6
-rw-r--r--include/usb_mode.h4
-rw-r--r--include/usb_pd.h13
-rw-r--r--include/usb_pd_dpm.h186
-rw-r--r--include/usb_pd_dpm_sm.h196
-rw-r--r--include/usb_pd_tcpc.h3
-rw-r--r--include/usb_pd_tcpm.h3
-rw-r--r--include/usb_pd_timer.h4
-rw-r--r--include/usb_prl_sm.h3
-rw-r--r--include/usb_tbt_alt_mode.h6
-rw-r--r--include/usb_tc_sm.h2
-rw-r--r--include/util.h1
-rw-r--r--include/vb21_struct.h4
-rw-r--r--include/vboot.h2
-rw-r--r--include/watchdog.h4
-rw-r--r--libc/syscalls.c16
-rw-r--r--power/amd_x86.c4
-rw-r--r--power/hibernate.c181
-rw-r--r--power/mt8186.c8
-rw-r--r--power/qcom.c1
-rw-r--r--power/rk3288.c2
-rw-r--r--test/abort.c4
-rw-r--r--test/accel_cal.c5
-rw-r--r--test/aes.c588
-rw-r--r--test/aes.cc601
-rw-r--r--test/always_memset.c5
-rw-r--r--test/base32.c5
-rw-r--r--test/benchmark.cc98
-rw-r--r--test/benchmark.tasklist9
-rw-r--r--test/build.mk7
-rw-r--r--test/button.c4
-rw-r--r--test/cec.c4
-rw-r--r--test/charge_manager.c4
-rw-r--r--test/charge_ramp.c4
-rw-r--r--test/compile_time_macros.c2
-rw-r--r--test/console_edit.c4
-rw-r--r--test/cortexm_fpu.c3
-rw-r--r--test/entropy.c2
-rw-r--r--test/fake_usbc.c8
-rw-r--r--test/fp.c1
-rw-r--r--test/fpsensor.c8
-rw-r--r--test/fpsensor_crypto.c4
-rw-r--r--test/fpsensor_hw.c39
-rw-r--r--test/fpsensor_hw.cc39
-rw-r--r--test/fpsensor_state.c4
-rw-r--r--test/ftrapv.c265
-rw-r--r--test/ftrapv.tasklist10
-rw-r--r--test/gyro_cal.c7
-rw-r--r--test/gyro_cal_init_for_test.c3
-rw-r--r--test/interrupt.c4
-rw-r--r--test/kasa.c3
-rw-r--r--test/kb_8042.c104
-rw-r--r--test/kb_scan.c3
-rw-r--r--test/libc_printf.c28
-rw-r--r--test/libc_printf.tasklist9
-rw-r--r--test/lightbar.c2
-rw-r--r--test/mag_cal.c1
-rw-r--r--test/math_util.c5
-rw-r--r--test/motion_angle.c6
-rw-r--r--test/motion_angle_tablet.c6
-rw-r--r--test/motion_lid.c6
-rw-r--r--test/motion_sense_fifo.c11
-rw-r--r--test/mpu.c26
-rw-r--r--test/mutex.c2
-rw-r--r--test/newton_fit.c3
-rw-r--r--test/nvidia_gpu.c5
-rw-r--r--test/online_calibration.c1
-rw-r--r--test/online_calibration_spoof.c5
-rw-r--r--test/panic_data.c3
-rw-r--r--test/powerdemo.c2
-rw-r--r--test/printf.c8
-rw-r--r--test/rgb_keyboard.c4
-rw-r--r--test/rng_benchmark.cc81
-rw-r--r--test/rng_benchmark.tasklist9
-rw-r--r--test/rollback.c3
-rw-r--r--test/rollback_secret.c4
-rw-r--r--test/rsa.c2
-rw-r--r--test/rtc.c2
-rwxr-xr-xtest/run_device_tests.py12
-rw-r--r--test/sha256.c2
-rw-r--r--test/shmalloc.c10
-rw-r--r--test/stdlib.c2
-rw-r--r--test/stillness_detector.c3
-rw-r--r--test/system_is_locked.c3
-rw-r--r--test/test_config.h8
-rw-r--r--test/uptime.c4
-rw-r--r--test/usb_pd_console.c4
-rw-r--r--test/usb_pd_int.c4
-rw-r--r--test/usb_pe_drp.c14
-rw-r--r--test/usb_pe_drp_noextended.c6
-rw-r--r--test/usb_pe_drp_old.c2
-rw-r--r--test/usb_prl_noextended.c2
-rw-r--r--test/usb_prl_old.c2
-rw-r--r--test/usb_sm_checks.c2
-rw-r--r--test/usb_sm_framework_h3.c2
-rw-r--r--test/usb_tcpmv2_compliance_common.c2
-rw-r--r--test/usb_tcpmv2_td_pd_ll_e3.c2
-rw-r--r--test/usb_tcpmv2_td_pd_ll_e4.c2
-rw-r--r--test/usb_tcpmv2_td_pd_ll_e5.c2
-rw-r--r--test/usb_tcpmv2_td_pd_other.c4
-rw-r--r--test/usb_tcpmv2_td_pd_src3_e1.c2
-rw-r--r--test/usb_tcpmv2_td_pd_src3_e7.c4
-rw-r--r--test/usb_tcpmv2_td_pd_src3_e8.c4
-rw-r--r--test/usb_tcpmv2_td_pd_src3_e9.c4
-rw-r--r--test/usb_tcpmv2_td_pd_src_e1.c2
-rw-r--r--test/usb_tcpmv2_td_pd_src_e2.c2
-rw-r--r--test/usb_tcpmv2_td_pd_src_e5.c2
-rw-r--r--test/usb_tcpmv2_td_pd_vndi3_e3.c2
-rw-r--r--test/usb_test/device_configuration.c5
-rw-r--r--test/usb_typec_ctvpd.c6
-rw-r--r--test/utils_str.c2
-rw-r--r--test/vboot.c4
-rw-r--r--test/version.c2
-rw-r--r--test/vpd_api.c4
-rw-r--r--util/build.mk8
-rwxr-xr-xutil/build_with_clang.py70
-rw-r--r--util/cbi-util.c15
-rwxr-xr-xutil/check_clang_format.py10
-rwxr-xr-xutil/clangd_config.py2
-rw-r--r--util/comm-dev.cc5
-rw-r--r--util/comm-host.h8
-rw-r--r--util/config_allowed.txt18
-rw-r--r--util/corsola-relevant-paths.txt32
-rwxr-xr-xutil/crash_analyzer.py18
-rw-r--r--util/cros_ec_dev.h3
-rw-r--r--util/ecst.h3
-rw-r--r--util/ectool.cc114
-rw-r--r--util/export_taskinfo.c4
-rw-r--r--util/flash_fp_mcu20
-rw-r--r--util/gen_emmc_transfer_data.c4
-rw-r--r--util/gen_touchpad_hash.c12
-rw-r--r--util/genvif.c24
-rw-r--r--util/gpios_to_zephyr_dts.c2
-rw-r--r--util/iteflash.c21
-rwxr-xr-xutil/kconfig_check.py4
-rwxr-xr-xutil/run_host_test84
-rwxr-xr-xutil/twister_launcher.py182
-rwxr-xr-xutil/twister_tags.py1
-rwxr-xr-xutil/uart_stress_tester.py11
-rwxr-xr-xutil/update_release_branch.py354
-rw-r--r--util/usb_if.c4
-rw-r--r--util/uut/com_port.h1
-rwxr-xr-xutil/zephyr_to_resultdb.py96
-rw-r--r--zephyr/CMakeLists.txt8
-rw-r--r--zephyr/Kconfig63
-rw-r--r--zephyr/Kconfig.adc4
-rw-r--r--zephyr/Kconfig.battery2
-rw-r--r--zephyr/Kconfig.body_detection97
-rw-r--r--zephyr/Kconfig.cbi16
-rw-r--r--zephyr/Kconfig.charger30
-rw-r--r--zephyr/Kconfig.defaults12
-rw-r--r--zephyr/Kconfig.i2c5
-rw-r--r--zephyr/Kconfig.ioex3
-rw-r--r--zephyr/Kconfig.keyboard37
-rw-r--r--zephyr/Kconfig.led5
-rw-r--r--zephyr/Kconfig.led_dt22
-rw-r--r--zephyr/Kconfig.motionsense10
-rw-r--r--zephyr/Kconfig.panic8
-rw-r--r--zephyr/Kconfig.pd23
-rw-r--r--zephyr/Kconfig.pmic4
-rw-r--r--zephyr/Kconfig.retimer4
-rw-r--r--zephyr/Kconfig.system36
-rw-r--r--zephyr/Kconfig.temperature18
-rw-r--r--zephyr/Kconfig.usb_charger2
-rw-r--r--zephyr/Kconfig.usb_mux1
-rw-r--r--zephyr/Kconfig.usba2
-rw-r--r--zephyr/Kconfig.usbc46
-rw-r--r--zephyr/app/ec/Kconfig26
-rw-r--r--zephyr/app/ec/chip/riscv/riscv-ite/it8xxx2-espi.c7
-rw-r--r--zephyr/app/ec/ec_app_main.c10
-rw-r--r--zephyr/app/ec/main_shim.c3
-rw-r--r--zephyr/boards/arm/mec1727/mec1727_defconfig4
-rw-r--r--zephyr/boards/arm/npcx7/npcx7.dts3
-rw-r--r--zephyr/boards/arm/npcx7/npcx7_defconfig4
-rw-r--r--zephyr/boards/arm/npcx9/npcx9.dtsi109
-rw-r--r--zephyr/boards/arm/npcx9/npcx9m3f_defconfig4
-rw-r--r--zephyr/boards/arm/npcx9/npcx9m7f_defconfig4
-rw-r--r--zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig8
-rw-r--r--zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig11
-rw-r--r--zephyr/boards/riscv/it8xxx2/it81202bx_defconfig4
-rw-r--r--zephyr/boards/riscv/it8xxx2/it81302bx_defconfig4
-rw-r--r--zephyr/boards/riscv/it8xxx2/it8xxx2.dts3
-rw-r--r--zephyr/cmake/compiler/clang/compiler_flags.cmake12
-rw-r--r--zephyr/cmake/compiler/clang/generic.cmake1
-rw-r--r--zephyr/cmake/compiler/gcc/compiler_flags.cmake3
-rw-r--r--zephyr/cmake/compiler/gcc/generic.cmake5
-rw-r--r--zephyr/cmake/linker/ld/clang/linker_flags.cmake7
-rw-r--r--zephyr/cmake/linker/ld/gcc/linker_flags.cmake4
-rw-r--r--zephyr/cmake/toolchain/host/generic.cmake18
-rw-r--r--zephyr/cmake/toolchain/host/target.cmake5
-rw-r--r--zephyr/cmake/toolchain/llvm/target.cmake4
-rw-r--r--zephyr/drivers/cros_displight/cros_displight.c21
-rw-r--r--zephyr/drivers/cros_flash/Kconfig4
-rw-r--r--zephyr/drivers/cros_flash/cros_flash_it8xxx2.c13
-rw-r--r--zephyr/drivers/cros_flash/cros_flash_npcx.c13
-rw-r--r--zephyr/drivers/cros_flash/cros_flash_xec.c13
-rw-r--r--zephyr/drivers/cros_kb_raw/Kconfig6
-rw-r--r--zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c17
-rw-r--r--zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c32
-rw-r--r--zephyr/drivers/cros_kb_raw/cros_kb_raw_xec.c17
-rw-r--r--zephyr/drivers/cros_kblight/pwm_kblight.c28
-rw-r--r--zephyr/drivers/cros_rtc/Kconfig14
-rw-r--r--zephyr/drivers/cros_rtc/cros_rtc_npcx.c22
-rw-r--r--zephyr/drivers/cros_rtc/cros_rtc_xec.c13
-rw-r--r--zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c21
-rw-r--r--zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h1
-rw-r--r--zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c11
-rw-r--r--zephyr/drivers/cros_shi/Kconfig11
-rw-r--r--zephyr/drivers/cros_shi/cros_shi_it8xxx2.c18
-rw-r--r--zephyr/drivers/cros_shi/cros_shi_npcx.c20
-rw-r--r--zephyr/drivers/cros_system/cros_system_it8xxx2.c11
-rw-r--r--zephyr/drivers/cros_system/cros_system_native_posix.c6
-rw-r--r--zephyr/drivers/cros_system/cros_system_npcx.c17
-rw-r--r--zephyr/drivers/cros_system/cros_system_xec.c15
-rw-r--r--zephyr/dts/bindings/battery/battery-fuel-gauge.yaml2
-rw-r--r--zephyr/dts/bindings/battery/battery-info.yaml2
-rw-r--r--zephyr/dts/bindings/battery/battery-smart.yaml1
-rw-r--r--zephyr/dts/bindings/battery/cosmx,ap20cbl-2.yaml12
-rw-r--r--zephyr/dts/bindings/battery/ganfeng,sg20.yaml53
-rw-r--r--zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc-value.yaml22
-rw-r--r--zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc.yaml56
-rw-r--r--zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml22
-rw-r--r--zephyr/dts/bindings/cbi/named-cbi-ssfc.yaml56
-rw-r--r--zephyr/dts/bindings/charger/richtek,rt9490.yaml11
-rw-r--r--zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8186-power-signal-list.yaml20
-rw-r--r--zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8192-power-signal-list.yaml19
-rw-r--r--zephyr/dts/bindings/cros_pwr_signal/mt8186,power-signal-list.yaml20
-rw-r--r--zephyr/dts/bindings/cros_pwr_signal/mt8192,power-signal-list.yaml19
-rw-r--r--zephyr/dts/bindings/emul/cros,anx7447-tcpc-emul.yaml16
-rw-r--r--zephyr/dts/bindings/emul/cros,anx7447-tcpc.yaml16
-rw-r--r--zephyr/dts/bindings/emul/cros,bb-retimer-emul.yaml30
-rw-r--r--zephyr/dts/bindings/emul/zephyr,bma255-emul.yaml83
-rw-r--r--zephyr/dts/bindings/emul/zephyr,bma255.yaml83
-rw-r--r--zephyr/dts/bindings/emul/zephyr,bmi-emul.yaml42
-rw-r--r--zephyr/dts/bindings/emul/zephyr,bmi.yaml42
-rw-r--r--zephyr/dts/bindings/emul/zephyr,pi3usb9201-emul.yaml9
-rw-r--r--zephyr/dts/bindings/emul/zephyr,smart-battery-emul.yaml161
-rw-r--r--zephyr/dts/bindings/emul/zephyr,smart-battery.yaml161
-rw-r--r--zephyr/dts/bindings/emul/zephyr,tcs3400-emul.yaml44
-rw-r--r--zephyr/dts/bindings/emul/zephyr,tcs3400.yaml44
-rw-r--r--zephyr/dts/bindings/emul/zephyr,tusb1064-emul.yaml (renamed from zephyr/dts/bindings/emul/zephyr,tusb1064.yaml)0
-rw-r--r--zephyr/dts/bindings/fan/cros-ec,fan-steps.yaml27
-rw-r--r--zephyr/dts/bindings/fan/cros-ec,fans.yaml6
-rw-r--r--zephyr/dts/bindings/gpio/gpio-enum-name.yaml1
-rw-r--r--zephyr/dts/bindings/gpio/named-gpios.yaml5
-rw-r--r--zephyr/dts/bindings/keyboard/cros-ec,keyscan.yaml82
-rw-r--r--zephyr/dts/bindings/keyboard/cros-keyscan.yaml82
-rw-r--r--zephyr/dts/bindings/led/maxim,max695x.yaml18
-rw-r--r--zephyr/dts/bindings/led/maxim,seven-seg-display.yaml19
-rw-r--r--zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml19
-rw-r--r--zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml21
-rw-r--r--zephyr/dts/bindings/leds/cros-ec,pwm-pin-config.yaml19
-rw-r--r--zephyr/dts/bindings/power/intel,ap-pwr-signal-emul.yaml124
-rw-r--r--zephyr/dts/bindings/power/intel,ap-pwr-test-platform.yaml18
-rw-r--r--zephyr/dts/bindings/switchcap/cros-ec,switchcap-gpio.yaml22
-rw-r--r--zephyr/dts/bindings/switchcap/lion,ln9310.yaml28
-rw-r--r--zephyr/dts/bindings/switchcap/switchcap-gpio.yaml22
-rw-r--r--zephyr/dts/bindings/switchcap/switchcap-ln9310.yaml28
-rw-r--r--zephyr/dts/bindings/usbc/bc12/richtek,rt9490-bc12.yaml15
-rw-r--r--zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml16
-rw-r--r--zephyr/dts/board-overlays/native_posix.dts3
-rw-r--r--zephyr/dts/it8xxx2_emul.dts10
-rw-r--r--zephyr/emul/CMakeLists.txt1
-rw-r--r--zephyr/emul/Kconfig35
-rw-r--r--zephyr/emul/emul_bb_retimer.c24
-rw-r--r--zephyr/emul/emul_bma255.c17
-rw-r--r--zephyr/emul/emul_bmi.c21
-rw-r--r--zephyr/emul/emul_bmi160.c15
-rw-r--r--zephyr/emul/emul_bmi260.c15
-rw-r--r--zephyr/emul/emul_clock_control.c8
-rw-r--r--zephyr/emul/emul_common_i2c.c52
-rw-r--r--zephyr/emul/emul_flash.c16
-rw-r--r--zephyr/emul/emul_isl923x.c23
-rw-r--r--zephyr/emul/emul_kb_raw.c11
-rw-r--r--zephyr/emul/emul_lis2dw12.c19
-rw-r--r--zephyr/emul/emul_ln9310.c17
-rw-r--r--zephyr/emul/emul_pct2075.c107
-rw-r--r--zephyr/emul/emul_pi3usb9201.c10
-rw-r--r--zephyr/emul/emul_rt9490.c4
-rw-r--r--zephyr/emul/emul_rtc.c14
-rw-r--r--zephyr/emul/emul_smart_battery.c25
-rw-r--r--zephyr/emul/emul_sn5s330.c25
-rw-r--r--zephyr/emul/emul_syv682x.c19
-rw-r--r--zephyr/emul/emul_tcs3400.c17
-rw-r--r--zephyr/emul/emul_tusb1064.c4
-rw-r--r--zephyr/emul/i2c_mock.c6
-rw-r--r--zephyr/emul/pwm_mock.c6
-rw-r--r--zephyr/emul/tcpc/CMakeLists.txt1
-rw-r--r--zephyr/emul/tcpc/Kconfig16
-rw-r--r--zephyr/emul/tcpc/emul_anx7447.c15
-rw-r--r--zephyr/emul/tcpc/emul_ps8xxx.c23
-rw-r--r--zephyr/emul/tcpc/emul_tcpci.c13
-rw-r--r--zephyr/emul/tcpc/emul_tcpci_generic.c15
-rw-r--r--zephyr/emul/tcpc/emul_tcpci_partner_common.c140
-rw-r--r--zephyr/emul/tcpc/emul_tcpci_partner_drp.c12
-rw-r--r--zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c12
-rw-r--r--zephyr/emul/tcpc/emul_tcpci_partner_snk.c12
-rw-r--r--zephyr/emul/tcpc/emul_tcpci_partner_src.c14
-rw-r--r--zephyr/emul/tcpc/emul_tcpci_partner_vpd.c125
-rw-r--r--zephyr/fake/include/system_fake.h4
-rw-r--r--zephyr/fake/system_fake.c4
-rwxr-xr-xzephyr/firmware_builder.py76
-rw-r--r--zephyr/include/drivers/cros_flash.h2
-rw-r--r--zephyr/include/drivers/cros_kb_raw.h42
-rw-r--r--zephyr/include/drivers/cros_rtc.h2
-rw-r--r--zephyr/include/drivers/cros_shi.h2
-rw-r--r--zephyr/include/drivers/cros_system.h2
-rw-r--r--zephyr/include/dt-bindings/native-posix-gpio.h12
-rw-r--r--zephyr/include/emul/emul_isl923x.h2
-rw-r--r--zephyr/include/emul/emul_kb_raw.h2
-rw-r--r--zephyr/include/emul/emul_ln9310.h4
-rw-r--r--zephyr/include/emul/emul_pct2075.h32
-rw-r--r--zephyr/include/emul/emul_power_signals.h49
-rw-r--r--zephyr/include/emul/emul_smart_battery.h7
-rw-r--r--zephyr/include/emul/emul_syv682x.h3
-rw-r--r--zephyr/include/emul/tcpc/emul_tcpci.h5
-rw-r--r--zephyr/include/emul/tcpc/emul_tcpci_partner_common.h21
-rw-r--r--zephyr/include/emul/tcpc/emul_tcpci_partner_drp.h3
-rw-r--r--zephyr/include/emul/tcpc/emul_tcpci_partner_faulty_ext.h3
-rw-r--r--zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h5
-rw-r--r--zephyr/include/emul/tcpc/emul_tcpci_partner_src.h5
-rw-r--r--zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h49
-rw-r--r--zephyr/linker/CMakeLists.txt4
-rw-r--r--zephyr/linker/end-of-ram.ld29
-rw-r--r--zephyr/mock/power.c7
-rw-r--r--zephyr/program/.pylintrc (renamed from zephyr/projects/.pylintrc)0
-rw-r--r--zephyr/program/brya/BUILD.py (renamed from zephyr/projects/brya/BUILD.py)0
-rw-r--r--zephyr/program/brya/CMakeLists.txt (renamed from zephyr/projects/brya/CMakeLists.txt)0
-rw-r--r--zephyr/program/brya/Kconfig (renamed from zephyr/projects/brya/Kconfig)0
-rw-r--r--zephyr/program/brya/adc.dts (renamed from zephyr/projects/brya/adc.dts)0
-rw-r--r--zephyr/program/brya/battery.dts (renamed from zephyr/projects/brya/battery.dts)0
-rw-r--r--zephyr/program/brya/battery_present.c21
-rw-r--r--zephyr/program/brya/brya.dts (renamed from zephyr/projects/brya/brya.dts)0
-rw-r--r--zephyr/program/brya/fan.dts (renamed from zephyr/projects/brya/fan.dts)0
-rw-r--r--zephyr/program/brya/gpio.dts (renamed from zephyr/projects/brya/gpio.dts)0
-rw-r--r--zephyr/program/brya/i2c.dts284
-rw-r--r--zephyr/program/brya/interrupts.dts (renamed from zephyr/projects/brya/interrupts.dts)0
-rw-r--r--zephyr/program/brya/kblight_hooks.c69
-rw-r--r--zephyr/program/brya/keyboard.dts (renamed from zephyr/projects/brya/keyboard.dts)0
-rw-r--r--zephyr/program/brya/motionsense.dts (renamed from zephyr/projects/brya/motionsense.dts)0
-rw-r--r--zephyr/program/brya/prj.conf175
-rw-r--r--zephyr/program/brya/prj_brya.conf (renamed from zephyr/projects/brya/prj_brya.conf)0
-rw-r--r--zephyr/program/brya/pwm_leds.dts (renamed from zephyr/projects/brya/pwm_leds.dts)0
-rw-r--r--zephyr/program/brya/temp_sensors.dts (renamed from zephyr/projects/brya/temp_sensors.dts)0
-rw-r--r--zephyr/program/brya/usbc.dts (renamed from zephyr/projects/brya/usbc.dts)0
-rw-r--r--zephyr/program/corsola/BUILD.py52
-rw-r--r--zephyr/program/corsola/CMakeLists.txt88
-rw-r--r--zephyr/program/corsola/Kconfig58
-rw-r--r--zephyr/program/corsola/adc_magikarp.dtsi (renamed from zephyr/projects/corsola/adc_magikarp.dts)0
-rw-r--r--zephyr/program/corsola/adc_tentacruel.dtsi72
-rw-r--r--zephyr/program/corsola/battery_krabby.dtsi (renamed from zephyr/projects/corsola/battery_krabby.dts)0
-rw-r--r--zephyr/program/corsola/battery_magikarp.dtsi (renamed from zephyr/projects/corsola/battery_magikarp.dts)0
-rw-r--r--zephyr/program/corsola/battery_tentacruel.dtsi (renamed from zephyr/projects/corsola/battery_tentacruel.dts)0
-rw-r--r--zephyr/program/corsola/cbi_magikarp.dtsi (renamed from zephyr/projects/corsola/cbi_magikarp.dts)0
-rw-r--r--zephyr/program/corsola/cbi_tentacruel.dtsi (renamed from zephyr/projects/corsola/cbi_tentacruel.dts)0
-rw-r--r--zephyr/program/corsola/common.dtsi (renamed from zephyr/projects/corsola/common.dts)0
-rw-r--r--zephyr/program/corsola/gpio_magikarp.dtsi (renamed from zephyr/projects/corsola/gpio_magikarp.dts)0
-rw-r--r--zephyr/program/corsola/gpio_tentacruel.dtsi (renamed from zephyr/projects/corsola/gpio_tentacruel.dts)0
-rw-r--r--zephyr/program/corsola/i2c_krabby.dtsi23
-rw-r--r--zephyr/program/corsola/i2c_magikarp.dtsi37
-rw-r--r--zephyr/program/corsola/i2c_tentacruel.dtsi39
-rw-r--r--zephyr/program/corsola/include/baseboard_usbc_config.h42
-rw-r--r--zephyr/program/corsola/include/variant_db_detection.h37
-rw-r--r--zephyr/program/corsola/interrupts_magikarp.dtsi (renamed from zephyr/projects/corsola/interrupts_magikarp.dts)0
-rw-r--r--zephyr/program/corsola/interrupts_tentacruel.dtsi (renamed from zephyr/projects/corsola/interrupts_tentacruel.dts)0
-rw-r--r--zephyr/program/corsola/ite_adc.dtsi (renamed from zephyr/projects/corsola/adc_krabby.dts)0
-rw-r--r--zephyr/program/corsola/ite_gpio.dtsi (renamed from zephyr/projects/corsola/gpio_krabby.dts)0
-rw-r--r--zephyr/program/corsola/ite_i2c.dtsi131
-rw-r--r--zephyr/program/corsola/ite_interrupts.dtsi (renamed from zephyr/projects/corsola/interrupts_krabby.dts)0
-rw-r--r--zephyr/program/corsola/ite_keyboard.dtsi28
-rw-r--r--zephyr/program/corsola/ite_motionsense.dtsi (renamed from zephyr/projects/corsola/motionsense_krabby.dts)0
-rw-r--r--zephyr/program/corsola/ite_program.conf85
-rw-r--r--zephyr/program/corsola/ite_usbc.dtsi59
-rw-r--r--zephyr/program/corsola/kingler/project.conf9
-rw-r--r--zephyr/program/corsola/kingler/project.overlay96
-rw-r--r--zephyr/program/corsola/krabby/project.conf (renamed from zephyr/projects/corsola/prj_krabby.conf)0
-rw-r--r--zephyr/program/corsola/krabby/project.overlay19
-rw-r--r--zephyr/program/corsola/led_it81202_base.dtsi174
-rw-r--r--zephyr/program/corsola/led_krabby.dtsi (renamed from zephyr/projects/corsola/led_krabby.dts)0
-rw-r--r--zephyr/program/corsola/led_magikarp.dtsi137
-rw-r--r--zephyr/program/corsola/led_tentacruel.dtsi119
-rw-r--r--zephyr/program/corsola/magikarp/project.conf22
-rw-r--r--zephyr/program/corsola/magikarp/project.overlay20
-rw-r--r--zephyr/program/corsola/motionsense_magikarp.dtsi (renamed from zephyr/projects/corsola/motionsense_magikarp.dts)0
-rw-r--r--zephyr/program/corsola/motionsense_tentacruel.dtsi (renamed from zephyr/projects/corsola/motionsense_tentacruel.dts)0
-rw-r--r--zephyr/program/corsola/npcx_adc.dtsi (renamed from zephyr/projects/corsola/adc_kingler.dts)0
-rw-r--r--zephyr/program/corsola/npcx_default_gpio_pinctrl.dtsi (renamed from zephyr/projects/corsola/default_gpio_pinctrl_kingler.dts)0
-rw-r--r--zephyr/program/corsola/npcx_gpio.dtsi (renamed from zephyr/projects/corsola/gpio_kingler.dts)0
-rw-r--r--zephyr/program/corsola/npcx_host_interface.dtsi (renamed from zephyr/projects/corsola/host_interface_npcx.dts)0
-rw-r--r--zephyr/program/corsola/npcx_i2c.dtsi (renamed from zephyr/projects/corsola/i2c_kingler.dts)0
-rw-r--r--zephyr/program/corsola/npcx_interrupts.dtsi (renamed from zephyr/projects/corsola/interrupts_kingler.dts)0
-rw-r--r--zephyr/program/corsola/npcx_keyboard.dtsi (renamed from zephyr/projects/corsola/npcx_keyboard.dts)0
-rw-r--r--zephyr/program/corsola/npcx_motionsense.dtsi (renamed from zephyr/projects/corsola/motionsense_kingler.dts)0
-rw-r--r--zephyr/program/corsola/npcx_program.conf84
-rw-r--r--zephyr/program/corsola/npcx_usbc.dtsi (renamed from zephyr/projects/corsola/usbc_kingler.dts)0
-rw-r--r--zephyr/program/corsola/power_signal.dtsi26
-rw-r--r--zephyr/program/corsola/program.conf96
-rw-r--r--zephyr/program/corsola/src/board.c36
-rw-r--r--zephyr/program/corsola/src/board_chipset.c51
-rw-r--r--zephyr/program/corsola/src/hibernate.c22
-rw-r--r--zephyr/program/corsola/src/kingler/board_steelix.c76
-rw-r--r--zephyr/program/corsola/src/kingler/button.c (renamed from zephyr/projects/corsola/src/kingler/button.c)0
-rw-r--r--zephyr/program/corsola/src/kingler/i2c.c21
-rw-r--r--zephyr/program/corsola/src/kingler/led.c (renamed from zephyr/projects/corsola/src/kingler/led.c)0
-rw-r--r--zephyr/program/corsola/src/kingler/led_steelix.c181
-rw-r--r--zephyr/program/corsola/src/kingler/usb_pd_policy.c73
-rw-r--r--zephyr/program/corsola/src/kingler/usbc_config.c317
-rw-r--r--zephyr/program/corsola/src/krabby/charger_workaround.c93
-rw-r--r--zephyr/program/corsola/src/krabby/hooks.c91
-rw-r--r--zephyr/program/corsola/src/krabby/i2c.c19
-rw-r--r--zephyr/program/corsola/src/krabby/keyboard_magikarp.c (renamed from zephyr/projects/corsola/src/krabby/keyboard_magikarp.c)0
-rw-r--r--zephyr/program/corsola/src/krabby/ppc_krabby.c31
-rw-r--r--zephyr/program/corsola/src/krabby/ppc_magikarp.c (renamed from zephyr/projects/corsola/src/krabby/ppc_magikarp.c)0
-rw-r--r--zephyr/program/corsola/src/krabby/ppc_tentacruel.c (renamed from zephyr/projects/corsola/src/krabby/ppc_tentacruel.c)0
-rw-r--r--zephyr/program/corsola/src/krabby/sensor_magikarp.c41
-rw-r--r--zephyr/program/corsola/src/krabby/sensor_tentacruel.c41
-rw-r--r--zephyr/program/corsola/src/krabby/temp_tentacruel.c129
-rw-r--r--zephyr/program/corsola/src/krabby/usb_pd_policy.c (renamed from zephyr/projects/corsola/src/krabby/usb_pd_policy.c)0
-rw-r--r--zephyr/program/corsola/src/krabby/usbc_config.c142
-rw-r--r--zephyr/program/corsola/src/usb_pd_policy.c225
-rw-r--r--zephyr/program/corsola/src/usbc_config.c247
-rw-r--r--zephyr/program/corsola/src/variant_db_detection.c210
-rw-r--r--zephyr/program/corsola/steelix/cbi.dtsi95
-rw-r--r--zephyr/program/corsola/steelix/interrupts.dtsi12
-rw-r--r--zephyr/program/corsola/steelix/project.conf34
-rw-r--r--zephyr/program/corsola/steelix/project.overlay298
-rw-r--r--zephyr/program/corsola/tentacruel/project.conf21
-rw-r--r--zephyr/program/corsola/tentacruel/project.overlay21
-rw-r--r--zephyr/program/corsola/thermistor_tentacruel.dtsi (renamed from zephyr/projects/corsola/thermistor_tentacruel.dts)0
-rw-r--r--zephyr/program/corsola/usba.dtsi (renamed from zephyr/projects/corsola/usba.dts)0
-rw-r--r--zephyr/program/corsola/usbc_magikarp.dtsi59
-rw-r--r--zephyr/program/corsola/usbc_tentacruel.dtsi60
-rw-r--r--zephyr/program/corsola/voltorb/project.conf41
-rw-r--r--zephyr/program/corsola/voltorb/project.overlay309
-rw-r--r--zephyr/program/herobrine/BUILD.py49
-rw-r--r--zephyr/program/herobrine/CMakeLists.txt36
-rw-r--r--zephyr/program/herobrine/Kconfig (renamed from zephyr/projects/herobrine/Kconfig)0
-rw-r--r--zephyr/program/herobrine/adc.dtsi (renamed from zephyr/projects/herobrine/adc.dts)0
-rw-r--r--zephyr/program/herobrine/common.dtsi (renamed from zephyr/projects/herobrine/common.dts)0
-rw-r--r--zephyr/program/herobrine/default_gpio_pinctrl.dtsi (renamed from zephyr/projects/herobrine/default_gpio_pinctrl.dts)0
-rw-r--r--zephyr/program/herobrine/display.dtsi (renamed from zephyr/projects/herobrine/display.dts)0
-rw-r--r--zephyr/program/herobrine/evoker/gpio.dtsi309
-rw-r--r--zephyr/program/herobrine/evoker/led_pins.dtsi64
-rw-r--r--zephyr/program/herobrine/evoker/led_policy.dtsi (renamed from zephyr/projects/herobrine/led_policy_evoker.dts)0
-rw-r--r--zephyr/program/herobrine/evoker/motionsense.dtsi (renamed from zephyr/projects/herobrine/motionsense_evoker.dts)0
-rw-r--r--zephyr/program/herobrine/evoker/project.conf22
-rw-r--r--zephyr/program/herobrine/evoker/project.overlay59
-rw-r--r--zephyr/program/herobrine/gpio.dtsi321
-rw-r--r--zephyr/program/herobrine/herobrine/CMakeLists.txt6
-rw-r--r--zephyr/program/herobrine/herobrine/led_pins.dtsi62
-rw-r--r--zephyr/program/herobrine/herobrine/led_policy.dtsi (renamed from zephyr/projects/herobrine/led_policy_herobrine.dts)0
-rw-r--r--zephyr/program/herobrine/herobrine/project.conf (renamed from zephyr/projects/herobrine/prj_herobrine.conf)0
-rw-r--r--zephyr/program/herobrine/herobrine/project.overlay64
-rw-r--r--zephyr/program/herobrine/herobrine/src/alt_dev_replacement.c37
-rw-r--r--zephyr/program/herobrine/hoglin/gpio.dtsi321
-rw-r--r--zephyr/program/herobrine/hoglin/led_pins.dtsi36
-rw-r--r--zephyr/program/herobrine/hoglin/led_policy.dtsi (renamed from zephyr/projects/herobrine/led_policy_hoglin.dts)0
-rw-r--r--zephyr/program/herobrine/hoglin/motionsense.dtsi (renamed from zephyr/projects/herobrine/motionsense_hoglin.dts)0
-rw-r--r--zephyr/program/herobrine/hoglin/project.conf (renamed from zephyr/projects/herobrine/prj_hoglin.conf)0
-rw-r--r--zephyr/program/herobrine/hoglin/project.overlay54
-rw-r--r--zephyr/program/herobrine/i2c.dtsi181
-rw-r--r--zephyr/program/herobrine/include/board_chipset.h13
-rw-r--r--zephyr/program/herobrine/interrupts.dtsi (renamed from zephyr/projects/herobrine/interrupts.dts)0
-rw-r--r--zephyr/program/herobrine/keyboard.dtsi (renamed from zephyr/projects/herobrine/keyboard.dts)0
-rw-r--r--zephyr/program/herobrine/motionsense.dtsi (renamed from zephyr/projects/herobrine/motionsense.dts)0
-rw-r--r--zephyr/program/herobrine/program.conf140
-rw-r--r--zephyr/program/herobrine/src/board_chipset.c82
-rw-r--r--zephyr/program/herobrine/src/i2c.c17
-rw-r--r--zephyr/program/herobrine/src/usb_pd_policy.c254
-rw-r--r--zephyr/program/herobrine/src/usbc_config.c282
-rw-r--r--zephyr/program/herobrine/switchcap.dtsi12
-rw-r--r--zephyr/program/herobrine/usbc.dtsi42
-rw-r--r--zephyr/program/herobrine/villager/gpio.dtsi317
-rw-r--r--zephyr/program/herobrine/villager/led_pins.dtsi36
-rw-r--r--zephyr/program/herobrine/villager/led_policy.dtsi (renamed from zephyr/projects/herobrine/led_policy_villager.dts)0
-rw-r--r--zephyr/program/herobrine/villager/motionsense.dtsi (renamed from zephyr/projects/herobrine/motionsense_villager.dts)0
-rw-r--r--zephyr/program/herobrine/villager/project.conf (renamed from zephyr/projects/herobrine/prj_villager.conf)0
-rw-r--r--zephyr/program/herobrine/villager/project.overlay33
-rw-r--r--zephyr/program/herobrine/zoglin/project.conf (renamed from zephyr/projects/herobrine/prj_zoglin.conf)0
-rw-r--r--zephyr/program/herobrine/zoglin/project.overlay6
-rw-r--r--zephyr/program/herobrine/zombie/gpio.dtsi317
-rw-r--r--zephyr/program/herobrine/zombie/led_pins.dtsi36
-rw-r--r--zephyr/program/herobrine/zombie/led_policy.dtsi (renamed from zephyr/projects/herobrine/led_policy_zombie.dts)0
-rw-r--r--zephyr/program/herobrine/zombie/motionsense.dtsi (renamed from zephyr/projects/herobrine/motionsense_zombie.dts)0
-rw-r--r--zephyr/program/herobrine/zombie/project.conf (renamed from zephyr/projects/herobrine/prj_zombie.conf)0
-rw-r--r--zephyr/program/herobrine/zombie/project.overlay30
-rw-r--r--zephyr/program/intelrvp/BUILD.py (renamed from zephyr/projects/intelrvp/BUILD.py)0
-rw-r--r--zephyr/program/intelrvp/CMakeLists.txt (renamed from zephyr/projects/intelrvp/CMakeLists.txt)0
-rw-r--r--zephyr/program/intelrvp/Kconfig (renamed from zephyr/projects/intelrvp/Kconfig)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/CMakeLists.txt (renamed from zephyr/projects/intelrvp/adlrvp/CMakeLists.txt)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts200
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts (renamed from zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_mchp/gpio.dts (renamed from zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/gpio.dts)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts (renamed from zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts31
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf75
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_mchp/usbc.dts (renamed from zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/usbc.dts)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts257
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_npcx/fan.dts (renamed from zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/fan.dts)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_npcx/gpio.dts (renamed from zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/gpio.dts)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts (renamed from zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts59
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf13
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts (renamed from zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts (renamed from zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/adlrvp_npcx/usbc.dts (renamed from zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/battery.dts (renamed from zephyr/projects/intelrvp/adlrvp/battery.dts)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/include/adlrvp_zephyr.h (renamed from zephyr/projects/intelrvp/adlrvp/include/adlrvp_zephyr.h)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/ioex.dts (renamed from zephyr/projects/intelrvp/adlrvp/ioex.dts)0
-rw-r--r--zephyr/program/intelrvp/adlrvp/prj.conf64
-rw-r--r--zephyr/program/intelrvp/adlrvp/src/adlrvp.c430
-rw-r--r--zephyr/program/intelrvp/include/intel_rvp_board_id.h (renamed from zephyr/projects/intelrvp/include/intel_rvp_board_id.h)0
-rw-r--r--zephyr/program/intelrvp/include/intelrvp.h (renamed from zephyr/projects/intelrvp/include/intelrvp.h)0
-rw-r--r--zephyr/program/intelrvp/led.md (renamed from zephyr/projects/intelrvp/led.md)0
-rw-r--r--zephyr/program/intelrvp/legacy_ec_pwrseq.conf (renamed from zephyr/projects/intelrvp/legacy_ec_pwrseq.conf)0
-rw-r--r--zephyr/program/intelrvp/mtlrvp/CMakeLists.txt (renamed from zephyr/projects/intelrvp/mtlrvp/CMakeLists.txt)0
-rw-r--r--zephyr/program/intelrvp/mtlrvp/ioex.dts (renamed from zephyr/projects/intelrvp/mtlrvp/ioex.dts)0
-rw-r--r--zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts (renamed from zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts)0
-rw-r--r--zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts (renamed from zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts)0
-rw-r--r--zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts65
-rw-r--r--zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts59
-rw-r--r--zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts272
-rw-r--r--zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts (renamed from zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts)0
-rw-r--r--zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf10
-rw-r--r--zephyr/program/intelrvp/mtlrvp/prj.conf67
-rw-r--r--zephyr/program/intelrvp/mtlrvp/src/board_power.c61
-rw-r--r--zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c334
-rw-r--r--zephyr/program/intelrvp/mtlrvp/usbc.dts (renamed from zephyr/projects/intelrvp/mtlrvp/usbc.dts)0
-rw-r--r--zephyr/program/intelrvp/prj.conf64
-rw-r--r--zephyr/program/intelrvp/src/chg_usb_pd.c122
-rw-r--r--zephyr/program/intelrvp/src/chg_usb_pd_mecc_1_1.c (renamed from zephyr/projects/intelrvp/src/chg_usb_pd_mecc_1_1.c)0
-rw-r--r--zephyr/program/intelrvp/src/intel_rvp_board_id.c31
-rw-r--r--zephyr/program/intelrvp/src/intel_rvp_led.c (renamed from zephyr/projects/intelrvp/src/intel_rvp_led.c)0
-rw-r--r--zephyr/program/intelrvp/src/intelrvp.c (renamed from zephyr/projects/intelrvp/src/intelrvp.c)0
-rw-r--r--zephyr/program/intelrvp/src/usb_pd_policy_mecc_1_1.c (renamed from zephyr/projects/intelrvp/src/usb_pd_policy_mecc_1_1.c)0
-rw-r--r--zephyr/program/intelrvp/zephyr_ap_pwrseq.conf10
-rw-r--r--zephyr/program/it8xxx2_evb/BUILD.py (renamed from zephyr/projects/it8xxx2_evb/BUILD.py)0
-rw-r--r--zephyr/program/it8xxx2_evb/CMakeLists.txt (renamed from zephyr/projects/it8xxx2_evb/CMakeLists.txt)0
-rw-r--r--zephyr/program/it8xxx2_evb/adc.dts (renamed from zephyr/projects/it8xxx2_evb/adc.dts)0
-rw-r--r--zephyr/program/it8xxx2_evb/fan.dts (renamed from zephyr/projects/it8xxx2_evb/fan.dts)0
-rw-r--r--zephyr/program/it8xxx2_evb/gpio.dts (renamed from zephyr/projects/it8xxx2_evb/gpio.dts)0
-rw-r--r--zephyr/program/it8xxx2_evb/i2c.dts (renamed from zephyr/projects/it8xxx2_evb/i2c.dts)0
-rw-r--r--zephyr/program/it8xxx2_evb/include/i2c_map.h16
-rw-r--r--zephyr/program/it8xxx2_evb/interrupts.dts (renamed from zephyr/projects/it8xxx2_evb/interrupts.dts)0
-rw-r--r--zephyr/program/it8xxx2_evb/prj.conf33
-rw-r--r--zephyr/program/it8xxx2_evb/pwm.dts (renamed from zephyr/projects/it8xxx2_evb/pwm.dts)0
-rw-r--r--zephyr/program/minimal/BUILD.py (renamed from zephyr/projects/minimal/BUILD.py)0
-rw-r--r--zephyr/program/minimal/CMakeLists.txt (renamed from zephyr/projects/minimal/CMakeLists.txt)0
-rw-r--r--zephyr/program/minimal/README.md (renamed from zephyr/projects/minimal/README.md)0
-rw-r--r--zephyr/program/minimal/it8xxx2.dts (renamed from zephyr/projects/minimal/it8xxx2.dts)0
-rw-r--r--zephyr/program/minimal/npcx9.dts (renamed from zephyr/projects/minimal/npcx9.dts)0
-rw-r--r--zephyr/program/minimal/prj.conf18
-rw-r--r--zephyr/program/nissa/BUILD.py71
-rw-r--r--zephyr/program/nissa/CMakeLists.txt99
-rw-r--r--zephyr/program/nissa/Kconfig67
-rw-r--r--zephyr/program/nissa/cbi.dtsi (renamed from zephyr/projects/nissa/cbi.dtsi)0
-rw-r--r--zephyr/program/nissa/craask/cbi.dtsi152
-rw-r--r--zephyr/program/nissa/craask/fan.dtsi38
-rw-r--r--zephyr/program/nissa/craask/generated.dtsi289
-rw-r--r--zephyr/program/nissa/craask/keyboard.dtsi54
-rw-r--r--zephyr/program/nissa/craask/motionsense.dtsi256
-rw-r--r--zephyr/program/nissa/craask/overlay.dtsi414
-rw-r--r--zephyr/program/nissa/craask/power_signals.dtsi (renamed from zephyr/projects/nissa/craask/power_signals.dtsi)0
-rw-r--r--zephyr/program/nissa/craask/project.conf17
-rw-r--r--zephyr/program/nissa/craask/project.overlay15
-rw-r--r--zephyr/program/nissa/craask/pwm_leds.dtsi (renamed from zephyr/projects/nissa/craask/pwm_leds.dtsi)0
-rw-r--r--zephyr/program/nissa/craask/src/charger.c56
-rw-r--r--zephyr/program/nissa/craask/src/fan.c37
-rw-r--r--zephyr/program/nissa/craask/src/form_factor.c133
-rw-r--r--zephyr/program/nissa/craask/src/kb_backlight.c34
-rw-r--r--zephyr/program/nissa/craask/src/keyboard.c45
-rw-r--r--zephyr/program/nissa/craask/src/led.c (renamed from zephyr/projects/nissa/craask/src/led.c)0
-rw-r--r--zephyr/program/nissa/craask/src/usbc.c251
-rw-r--r--zephyr/program/nissa/include/nissa_common.h (renamed from zephyr/projects/nissa/include/nissa_common.h)0
-rw-r--r--zephyr/program/nissa/include/nissa_hdmi.h (renamed from zephyr/projects/nissa/include/nissa_hdmi.h)0
-rw-r--r--zephyr/program/nissa/it8xxx2_program.conf65
-rw-r--r--zephyr/program/nissa/joxer/cbi.dtsi (renamed from zephyr/projects/nissa/joxer/cbi.dtsi)0
-rw-r--r--zephyr/program/nissa/joxer/generated.dtsi (renamed from zephyr/projects/nissa/joxer/generated.dtsi)0
-rw-r--r--zephyr/program/nissa/joxer/joxer_vif.xml (renamed from zephyr/projects/nissa/joxer/joxer_vif.xml)0
-rw-r--r--zephyr/program/nissa/joxer/keyboard.dtsi (renamed from zephyr/projects/nissa/joxer/keyboard.dtsi)0
-rw-r--r--zephyr/program/nissa/joxer/motionsense.dtsi148
-rw-r--r--zephyr/program/nissa/joxer/overlay.dtsi459
-rw-r--r--zephyr/program/nissa/joxer/power_signals.dtsi (renamed from zephyr/projects/nissa/joxer/power_signals.dtsi)0
-rw-r--r--zephyr/program/nissa/joxer/project.conf (renamed from zephyr/projects/nissa/joxer/project.conf)0
-rw-r--r--zephyr/program/nissa/joxer/project.overlay (renamed from zephyr/projects/nissa/craask/project.overlay)0
-rw-r--r--zephyr/program/nissa/joxer/pwm_leds.dtsi (renamed from zephyr/projects/nissa/joxer/pwm_leds.dtsi)0
-rw-r--r--zephyr/program/nissa/joxer/src/charger.c56
-rw-r--r--zephyr/program/nissa/joxer/src/fan.c42
-rw-r--r--zephyr/program/nissa/joxer/src/keyboard.c68
-rw-r--r--zephyr/program/nissa/joxer/src/led.c181
-rw-r--r--zephyr/program/nissa/joxer/src/usbc.c368
-rw-r--r--zephyr/program/nissa/nereid/generated.dtsi (renamed from zephyr/projects/nissa/nereid/generated.dtsi)0
-rw-r--r--zephyr/program/nissa/nereid/keyboard.dtsi (renamed from zephyr/projects/nissa/nereid/keyboard.dtsi)0
-rw-r--r--zephyr/program/nissa/nereid/motionsense.dtsi (renamed from zephyr/projects/nissa/nereid/motionsense.dtsi)0
-rw-r--r--zephyr/program/nissa/nereid/nereid_vif.xml (renamed from zephyr/projects/nissa/nereid/nereid_vif.xml)0
-rw-r--r--zephyr/program/nissa/nereid/overlay.dtsi409
-rw-r--r--zephyr/program/nissa/nereid/power_signals.dtsi (renamed from zephyr/projects/nissa/nereid/power_signals.dtsi)0
-rw-r--r--zephyr/program/nissa/nereid/project.conf (renamed from zephyr/projects/nissa/nereid/project.conf)0
-rw-r--r--zephyr/program/nissa/nereid/project.overlay (renamed from zephyr/projects/nissa/nereid/project.overlay)0
-rw-r--r--zephyr/program/nissa/nereid/pwm_leds.dtsi (renamed from zephyr/projects/nissa/nereid/pwm_leds.dtsi)0
-rw-r--r--zephyr/program/nissa/nereid/src/charger.c56
-rw-r--r--zephyr/program/nissa/nereid/src/hdmi.c29
-rw-r--r--zephyr/program/nissa/nereid/src/keyboard.c (renamed from zephyr/projects/nissa/nereid/src/keyboard.c)0
-rw-r--r--zephyr/program/nissa/nereid/src/usbc.c369
-rw-r--r--zephyr/program/nissa/nissa.csv (renamed from zephyr/projects/nissa/nissa.csv)0
-rw-r--r--zephyr/program/nissa/nivviks/cbi.dtsi (renamed from zephyr/projects/nissa/nivviks/cbi.dtsi)0
-rw-r--r--zephyr/program/nissa/nivviks/generated.dtsi (renamed from zephyr/projects/nissa/nivviks/generated.dtsi)0
-rw-r--r--zephyr/program/nissa/nivviks/keyboard.dtsi (renamed from zephyr/projects/nissa/nivviks/keyboard.dtsi)0
-rw-r--r--zephyr/program/nissa/nivviks/motionsense.dtsi (renamed from zephyr/projects/nissa/nivviks/motionsense.dtsi)0
-rw-r--r--zephyr/program/nissa/nivviks/overlay.dtsi439
-rw-r--r--zephyr/program/nissa/nivviks/power_signals.dtsi (renamed from zephyr/projects/nissa/nivviks/power_signals.dtsi)0
-rw-r--r--zephyr/program/nissa/nivviks/project.conf (renamed from zephyr/projects/nissa/nivviks/project.conf)0
-rw-r--r--zephyr/program/nissa/nivviks/project.overlay (renamed from zephyr/projects/nissa/joxer/project.overlay)0
-rw-r--r--zephyr/program/nissa/nivviks/pwm_leds.dtsi (renamed from zephyr/projects/nissa/nivviks/pwm_leds.dtsi)0
-rw-r--r--zephyr/program/nissa/nivviks/src/charger.c56
-rw-r--r--zephyr/program/nissa/nivviks/src/fan.c42
-rw-r--r--zephyr/program/nissa/nivviks/src/form_factor.c46
-rw-r--r--zephyr/program/nissa/nivviks/src/keyboard.c (renamed from zephyr/projects/nissa/nivviks/src/keyboard.c)0
-rw-r--r--zephyr/program/nissa/nivviks/src/led.c (renamed from zephyr/projects/nissa/nivviks/src/led.c)0
-rw-r--r--zephyr/program/nissa/nivviks/src/usbc.c251
-rw-r--r--zephyr/program/nissa/npcx_program.conf48
-rw-r--r--zephyr/program/nissa/program.conf145
-rw-r--r--zephyr/program/nissa/pujjo/cbi.dtsi190
-rw-r--r--zephyr/program/nissa/pujjo/generated.dtsi277
-rw-r--r--zephyr/program/nissa/pujjo/keyboard.dtsi (renamed from zephyr/projects/nissa/pujjo/keyboard.dtsi)0
-rw-r--r--zephyr/program/nissa/pujjo/motionsense.dtsi245
-rw-r--r--zephyr/program/nissa/pujjo/overlay.dtsi371
-rw-r--r--zephyr/program/nissa/pujjo/power_signals.dtsi (renamed from zephyr/projects/nissa/pujjo/power_signals.dtsi)0
-rw-r--r--zephyr/program/nissa/pujjo/project.conf (renamed from zephyr/projects/nissa/pujjo/project.conf)0
-rw-r--r--zephyr/program/nissa/pujjo/project.overlay (renamed from zephyr/projects/nissa/pujjo/project.overlay)0
-rw-r--r--zephyr/program/nissa/pujjo/pujjo_vif.xml (renamed from zephyr/projects/nissa/pujjo/pujjo_vif.xml)0
-rw-r--r--zephyr/program/nissa/pujjo/src/charger.c64
-rw-r--r--zephyr/program/nissa/pujjo/src/fan.c42
-rw-r--r--zephyr/program/nissa/pujjo/src/form_factor.c78
-rw-r--r--zephyr/program/nissa/pujjo/src/hdmi.c (renamed from zephyr/projects/nissa/pujjo/src/hdmi.c)0
-rw-r--r--zephyr/program/nissa/pujjo/src/keyboard.c (renamed from zephyr/projects/nissa/pujjo/src/keyboard.c)0
-rw-r--r--zephyr/program/nissa/pujjo/src/led.c134
-rw-r--r--zephyr/program/nissa/pujjo/src/usbc.c227
-rw-r--r--zephyr/program/nissa/src/board_power.c169
-rw-r--r--zephyr/program/nissa/src/common.c199
-rw-r--r--zephyr/program/nissa/src/led.c (renamed from zephyr/projects/nissa/src/led.c)0
-rw-r--r--zephyr/program/nissa/src/sub_board.c288
-rw-r--r--zephyr/program/nissa/xivu/cbi.dtsi133
-rw-r--r--zephyr/program/nissa/xivu/generated.dtsi (renamed from zephyr/projects/nissa/xivu/generated.dtsi)0
-rw-r--r--zephyr/program/nissa/xivu/keyboard.dtsi (renamed from zephyr/projects/nissa/xivu/keyboard.dtsi)0
-rw-r--r--zephyr/program/nissa/xivu/led_pins.dtsi84
-rw-r--r--zephyr/program/nissa/xivu/led_policy.dtsi (renamed from zephyr/projects/nissa/xivu/led_policy.dtsi)0
-rw-r--r--zephyr/program/nissa/xivu/motionsense.dtsi252
-rw-r--r--zephyr/program/nissa/xivu/overlay.dtsi383
-rw-r--r--zephyr/program/nissa/xivu/power_signals.dtsi (renamed from zephyr/projects/nissa/xivu/power_signals.dtsi)0
-rw-r--r--zephyr/program/nissa/xivu/project.conf25
-rw-r--r--zephyr/program/nissa/xivu/project.overlay (renamed from zephyr/projects/nissa/xivu/project.overlay)0
-rw-r--r--zephyr/program/nissa/xivu/src/charger.c69
-rw-r--r--zephyr/program/nissa/xivu/src/form_factor.c78
-rw-r--r--zephyr/program/nissa/xivu/src/keyboard.c (renamed from zephyr/projects/nissa/xivu/src/keyboard.c)0
-rw-r--r--zephyr/program/nissa/xivu/src/usbc.c343
-rw-r--r--zephyr/program/nissa/xivur/cbi.dtsi30
-rw-r--r--zephyr/program/nissa/xivur/generated.dtsi291
-rw-r--r--zephyr/program/nissa/xivur/keyboard.dtsi48
-rw-r--r--zephyr/program/nissa/xivur/motionsense.dtsi166
-rw-r--r--zephyr/program/nissa/xivur/overlay.dtsi (renamed from zephyr/projects/nissa/nivviks/overlay.dtsi)0
-rw-r--r--zephyr/program/nissa/xivur/power_signals.dtsi220
-rw-r--r--zephyr/program/nissa/xivur/project.conf8
-rw-r--r--zephyr/program/nissa/xivur/project.overlay (renamed from zephyr/projects/nissa/nivviks/project.overlay)0
-rw-r--r--zephyr/program/nissa/xivur/pwm_leds.dtsi62
-rw-r--r--zephyr/program/nissa/xivur/src/charger.c56
-rw-r--r--zephyr/program/nissa/xivur/src/fan.c (renamed from zephyr/projects/nissa/nivviks/src/fan.c)0
-rw-r--r--zephyr/program/nissa/xivur/src/form_factor.c (renamed from zephyr/projects/nissa/nivviks/src/form_factor.c)0
-rw-r--r--zephyr/program/nissa/xivur/src/keyboard.c29
-rw-r--r--zephyr/program/nissa/xivur/src/led.c51
-rw-r--r--zephyr/program/nissa/xivur/src/usbc.c (renamed from zephyr/projects/nissa/craask/src/usbc.c)0
-rw-r--r--zephyr/program/nissa/yaviks/cbi.dtsi (renamed from zephyr/projects/nissa/yaviks/cbi.dtsi)0
-rw-r--r--zephyr/program/nissa/yaviks/fan.dtsi71
-rw-r--r--zephyr/program/nissa/yaviks/gpio.dtsi (renamed from zephyr/projects/nissa/yaviks/gpio.dtsi)0
-rw-r--r--zephyr/program/nissa/yaviks/keyboard.dtsi (renamed from zephyr/projects/nissa/yaviks/keyboard.dtsi)0
-rw-r--r--zephyr/program/nissa/yaviks/overlay.dtsi383
-rw-r--r--zephyr/program/nissa/yaviks/power_signals.dtsi (renamed from zephyr/projects/nissa/yaviks/power_signals.dtsi)0
-rw-r--r--zephyr/program/nissa/yaviks/project.conf34
-rw-r--r--zephyr/program/nissa/yaviks/project.overlay13
-rw-r--r--zephyr/program/nissa/yaviks/src/charger.c74
-rw-r--r--zephyr/program/nissa/yaviks/src/fan.c37
-rw-r--r--zephyr/program/nissa/yaviks/src/keyboard.c106
-rw-r--r--zephyr/program/nissa/yaviks/src/led.c231
-rw-r--r--zephyr/program/nissa/yaviks/src/thermal.c108
-rw-r--r--zephyr/program/nissa/yaviks/src/usbc.c369
-rw-r--r--zephyr/program/nissa/yaviks/yaviks_vif.xml (renamed from zephyr/projects/nissa/yaviks/yaviks_vif.xml)0
-rw-r--r--zephyr/program/npcx_evb/npcx7/BUILD.py (renamed from zephyr/projects/npcx_evb/npcx7/BUILD.py)0
-rw-r--r--zephyr/program/npcx_evb/npcx7/CMakeLists.txt (renamed from zephyr/projects/npcx_evb/npcx7/CMakeLists.txt)0
-rw-r--r--zephyr/program/npcx_evb/npcx7/fan.dts (renamed from zephyr/projects/npcx_evb/npcx7/fan.dts)0
-rw-r--r--zephyr/program/npcx_evb/npcx7/gpio.dts (renamed from zephyr/projects/npcx_evb/npcx7/gpio.dts)0
-rw-r--r--zephyr/program/npcx_evb/npcx7/interrupts.dts (renamed from zephyr/projects/npcx_evb/npcx7/interrupts.dts)0
-rw-r--r--zephyr/program/npcx_evb/npcx7/keyboard.dts42
-rw-r--r--zephyr/program/npcx_evb/npcx7/prj.conf56
-rw-r--r--zephyr/program/npcx_evb/npcx9/BUILD.py (renamed from zephyr/projects/npcx_evb/npcx9/BUILD.py)0
-rw-r--r--zephyr/program/npcx_evb/npcx9/CMakeLists.txt (renamed from zephyr/projects/npcx_evb/npcx9/CMakeLists.txt)0
-rw-r--r--zephyr/program/npcx_evb/npcx9/fan.dts (renamed from zephyr/projects/npcx_evb/npcx9/fan.dts)0
-rw-r--r--zephyr/program/npcx_evb/npcx9/gpio.dts (renamed from zephyr/projects/npcx_evb/npcx9/gpio.dts)0
-rw-r--r--zephyr/program/npcx_evb/npcx9/interrupts.dts (renamed from zephyr/projects/npcx_evb/npcx9/interrupts.dts)0
-rw-r--r--zephyr/program/npcx_evb/npcx9/keyboard.dts42
-rw-r--r--zephyr/program/npcx_evb/npcx9/prj.conf60
-rw-r--r--zephyr/program/rex/BUILD.py (renamed from zephyr/projects/rex/BUILD.py)0
-rw-r--r--zephyr/program/rex/CMakeLists.txt (renamed from zephyr/projects/rex/CMakeLists.txt)0
-rw-r--r--zephyr/program/rex/Kconfig (renamed from zephyr/projects/rex/Kconfig)0
-rw-r--r--zephyr/program/rex/battery.dts (renamed from zephyr/projects/rex/battery.dts)0
-rw-r--r--zephyr/program/rex/fan.dts (renamed from zephyr/projects/rex/fan.dts)0
-rw-r--r--zephyr/program/rex/generated.dts (renamed from zephyr/projects/rex/generated.dts)0
-rw-r--r--zephyr/program/rex/include/gpio_map.h (renamed from zephyr/projects/rex/include/gpio_map.h)0
-rw-r--r--zephyr/program/rex/interrupts.dts (renamed from zephyr/projects/rex/interrupts.dts)0
-rw-r--r--zephyr/program/rex/keyboard.dts (renamed from zephyr/projects/rex/keyboard.dts)0
-rw-r--r--zephyr/program/rex/led.dts122
-rw-r--r--zephyr/program/rex/motionsense.dts (renamed from zephyr/projects/rex/motionsense.dts)0
-rw-r--r--zephyr/program/rex/power_signals.dts152
-rw-r--r--zephyr/program/rex/prj.conf151
-rw-r--r--zephyr/program/rex/prj_rex.conf6
-rw-r--r--zephyr/program/rex/rex.dts262
-rw-r--r--zephyr/program/rex/rex0_gpio.csv (renamed from zephyr/projects/rex/rex0_gpio.csv)0
-rw-r--r--zephyr/program/rex/src/board_power.c61
-rw-r--r--zephyr/program/rex/src/usb_pd_policy.c77
-rw-r--r--zephyr/program/rex/src/usbc_config.c292
-rw-r--r--zephyr/program/rex/temp_sensors.dts (renamed from zephyr/projects/rex/temp_sensors.dts)0
-rw-r--r--zephyr/program/rex/usbc.dts (renamed from zephyr/projects/rex/usbc.dts)0
-rw-r--r--zephyr/program/skyrim/BUILD.py48
-rw-r--r--zephyr/program/skyrim/CMakeLists.txt43
-rw-r--r--zephyr/program/skyrim/Kconfig46
-rw-r--r--zephyr/program/skyrim/adc.dtsi82
-rw-r--r--zephyr/program/skyrim/crystaldrift/CMakeLists.txt12
-rw-r--r--zephyr/program/skyrim/crystaldrift/battery.dtsi15
-rw-r--r--zephyr/program/skyrim/crystaldrift/crystaldrift.dtsi209
-rw-r--r--zephyr/program/skyrim/crystaldrift/led_pins.dtsi61
-rw-r--r--zephyr/program/skyrim/crystaldrift/led_policy.dtsi (renamed from zephyr/projects/skyrim/led_policy_morthal.dts)0
-rw-r--r--zephyr/program/skyrim/crystaldrift/motionsense.dtsi (renamed from zephyr/projects/skyrim/motionsense.dts)0
-rw-r--r--zephyr/program/skyrim/crystaldrift/project.conf26
-rw-r--r--zephyr/program/skyrim/crystaldrift/project.overlay19
-rw-r--r--zephyr/program/skyrim/crystaldrift/src/alt_charger.c31
-rw-r--r--zephyr/program/skyrim/crystaldrift/src/fan.c62
-rw-r--r--zephyr/program/skyrim/crystaldrift/src/form_factor.c38
-rw-r--r--zephyr/program/skyrim/crystaldrift/src/ppc_config.c46
-rw-r--r--zephyr/program/skyrim/crystaldrift/src/usb_mux_config.c142
-rw-r--r--zephyr/program/skyrim/fan.dtsi39
-rw-r--r--zephyr/program/skyrim/frostflow/CMakeLists.txt15
-rw-r--r--zephyr/program/skyrim/frostflow/battery.dtsi (renamed from zephyr/projects/skyrim/battery_frostflow.dts)0
-rw-r--r--zephyr/program/skyrim/frostflow/frostflow.dtsi223
-rw-r--r--zephyr/program/skyrim/frostflow/include/keyboard_customization.h (renamed from zephyr/projects/skyrim/include/frostflow/keyboard_customization.h)0
-rw-r--r--zephyr/program/skyrim/frostflow/led_pins.dtsi59
-rw-r--r--zephyr/program/skyrim/frostflow/led_policy.dtsi (renamed from zephyr/projects/skyrim/led_policy_frostflow.dts)0
-rw-r--r--zephyr/program/skyrim/frostflow/motionsense.dtsi135
-rw-r--r--zephyr/program/skyrim/frostflow/project.conf33
-rw-r--r--zephyr/program/skyrim/frostflow/project.overlay19
-rw-r--r--zephyr/program/skyrim/frostflow/src/keyboard.c (renamed from zephyr/projects/skyrim/src/frostflow/keyboard.c)0
-rw-r--r--zephyr/program/skyrim/frostflow/src/keyboard_customization.c85
-rw-r--r--zephyr/program/skyrim/frostflow/src/ppc_config.c46
-rw-r--r--zephyr/program/skyrim/frostflow/src/thermal.c109
-rw-r--r--zephyr/program/skyrim/frostflow/src/usb_mux_config.c62
-rw-r--r--zephyr/program/skyrim/gpio.dtsi370
-rw-r--r--zephyr/program/skyrim/i2c.dtsi294
-rw-r--r--zephyr/program/skyrim/include/keyboard_customization.h78
-rw-r--r--zephyr/program/skyrim/interrupts.dtsi (renamed from zephyr/projects/skyrim/interrupts.dts)0
-rw-r--r--zephyr/program/skyrim/keyboard.dtsi48
-rw-r--r--zephyr/program/skyrim/morthal/CMakeLists.txt8
-rw-r--r--zephyr/program/skyrim/morthal/battery.dtsi (renamed from zephyr/projects/skyrim/battery_morthal.dts)0
-rw-r--r--zephyr/program/skyrim/morthal/led_pins.dtsi59
-rw-r--r--zephyr/program/skyrim/morthal/led_policy.dtsi (renamed from zephyr/projects/skyrim/led_policy_skyrim.dts)0
-rw-r--r--zephyr/program/skyrim/morthal/morthal.dtsi185
-rw-r--r--zephyr/program/skyrim/morthal/motionsense.dtsi135
-rw-r--r--zephyr/program/skyrim/morthal/project.conf23
-rw-r--r--zephyr/program/skyrim/morthal/project.overlay19
-rw-r--r--zephyr/program/skyrim/morthal/src/ppc_config.c46
-rw-r--r--zephyr/program/skyrim/morthal/src/usb_mux_config.c142
-rw-r--r--zephyr/program/skyrim/motionsense.dtsi135
-rw-r--r--zephyr/program/skyrim/program.conf140
-rw-r--r--zephyr/program/skyrim/skyrim/CMakeLists.txt13
-rw-r--r--zephyr/program/skyrim/skyrim/battery.dtsi (renamed from zephyr/projects/skyrim/battery_skyrim.dts)0
-rw-r--r--zephyr/program/skyrim/skyrim/led_pins.dtsi59
-rw-r--r--zephyr/program/skyrim/skyrim/led_policy.dtsi103
-rw-r--r--zephyr/program/skyrim/skyrim/motionsense.dtsi135
-rw-r--r--zephyr/program/skyrim/skyrim/project.conf26
-rw-r--r--zephyr/program/skyrim/skyrim/project.overlay19
-rw-r--r--zephyr/program/skyrim/skyrim/skyrim.dtsi209
-rw-r--r--zephyr/program/skyrim/skyrim/skyrim_vif.xml346
-rw-r--r--zephyr/program/skyrim/skyrim/src/alt_charger.c31
-rw-r--r--zephyr/program/skyrim/skyrim/src/fan.c62
-rw-r--r--zephyr/program/skyrim/skyrim/src/form_factor.c38
-rw-r--r--zephyr/program/skyrim/skyrim/src/keyboard.c (renamed from zephyr/projects/skyrim/src/skyrim/keyboard.c)0
-rw-r--r--zephyr/program/skyrim/skyrim/src/ppc_config.c46
-rw-r--r--zephyr/program/skyrim/skyrim/src/usb_mux_config.c142
-rw-r--r--zephyr/program/skyrim/src/common.c (renamed from zephyr/projects/skyrim/src/common.c)0
-rw-r--r--zephyr/program/skyrim/src/power_signals.c245
-rw-r--r--zephyr/program/skyrim/src/stt.c (renamed from zephyr/projects/skyrim/src/stt.c)0
-rw-r--r--zephyr/program/skyrim/src/usb_pd_policy.c93
-rw-r--r--zephyr/program/skyrim/src/usbc_config.c394
-rw-r--r--zephyr/program/skyrim/usbc.dtsi (renamed from zephyr/projects/skyrim/usbc.dts)0
-rw-r--r--zephyr/program/skyrim/winterhold/CMakeLists.txt12
-rw-r--r--zephyr/program/skyrim/winterhold/battery.dtsi33
-rw-r--r--zephyr/program/skyrim/winterhold/led_pins.dtsi59
-rw-r--r--zephyr/program/skyrim/winterhold/led_policy.dtsi (renamed from zephyr/projects/skyrim/led_policy_winterhold.dts)0
-rw-r--r--zephyr/program/skyrim/winterhold/motionsense.dtsi124
-rw-r--r--zephyr/program/skyrim/winterhold/project.conf47
-rw-r--r--zephyr/program/skyrim/winterhold/project.overlay19
-rw-r--r--zephyr/program/skyrim/winterhold/src/battery_present.c81
-rw-r--r--zephyr/program/skyrim/winterhold/src/kb_backlight.c34
-rw-r--r--zephyr/program/skyrim/winterhold/src/keyboard.c (renamed from zephyr/projects/skyrim/src/winterhold/keyboard.c)0
-rw-r--r--zephyr/program/skyrim/winterhold/src/ppc_config.c27
-rw-r--r--zephyr/program/skyrim/winterhold/src/sensor.c37
-rw-r--r--zephyr/program/skyrim/winterhold/src/usb_mux_config.c146
-rw-r--r--zephyr/program/skyrim/winterhold/winterhold.dtsi168
-rw-r--r--zephyr/program/trogdor/lazor/BUILD.py (renamed from zephyr/projects/trogdor/lazor/BUILD.py)0
-rw-r--r--zephyr/program/trogdor/lazor/CMakeLists.txt (renamed from zephyr/projects/trogdor/lazor/CMakeLists.txt)0
-rw-r--r--zephyr/program/trogdor/lazor/adc.dts (renamed from zephyr/projects/trogdor/lazor/adc.dts)0
-rw-r--r--zephyr/program/trogdor/lazor/battery.dts (renamed from zephyr/projects/trogdor/lazor/battery.dts)0
-rw-r--r--zephyr/program/trogdor/lazor/default_gpio_pinctrl.dts (renamed from zephyr/projects/trogdor/lazor/default_gpio_pinctrl.dts)0
-rw-r--r--zephyr/program/trogdor/lazor/display.dts (renamed from zephyr/projects/trogdor/lazor/display.dts)0
-rw-r--r--zephyr/program/trogdor/lazor/gpio.dts314
-rw-r--r--zephyr/program/trogdor/lazor/host_interface_npcx.dts (renamed from zephyr/projects/trogdor/lazor/host_interface_npcx.dts)0
-rw-r--r--zephyr/program/trogdor/lazor/i2c.dts (renamed from zephyr/projects/trogdor/lazor/i2c.dts)0
-rw-r--r--zephyr/program/trogdor/lazor/include/sku.h (renamed from zephyr/projects/trogdor/lazor/include/sku.h)0
-rw-r--r--zephyr/program/trogdor/lazor/interrupts.dts (renamed from zephyr/projects/trogdor/lazor/interrupts.dts)0
-rw-r--r--zephyr/program/trogdor/lazor/keyboard.dts38
-rw-r--r--zephyr/program/trogdor/lazor/led.dts (renamed from zephyr/projects/trogdor/lazor/led.dts)0
-rw-r--r--zephyr/program/trogdor/lazor/motionsense.dts (renamed from zephyr/projects/trogdor/lazor/motionsense.dts)0
-rw-r--r--zephyr/program/trogdor/lazor/prj.conf149
-rw-r--r--zephyr/program/trogdor/lazor/pwm_led.dts55
-rw-r--r--zephyr/program/trogdor/lazor/src/hibernate.c (renamed from zephyr/projects/trogdor/lazor/src/hibernate.c)0
-rw-r--r--zephyr/program/trogdor/lazor/src/i2c.c17
-rw-r--r--zephyr/program/trogdor/lazor/src/power.c59
-rw-r--r--zephyr/program/trogdor/lazor/src/sku.c92
-rw-r--r--zephyr/program/trogdor/lazor/src/switchcap.c128
-rw-r--r--zephyr/program/trogdor/lazor/src/usb_pd_policy.c261
-rw-r--r--zephyr/program/trogdor/lazor/src/usbc_config.c334
-rw-r--r--zephyr/program/trogdor/lazor/usbc.dts (renamed from zephyr/projects/trogdor/lazor/usbc.dts)0
-rw-r--r--zephyr/projects/brya/battery_present.c21
-rw-r--r--zephyr/projects/brya/i2c.dts285
-rw-r--r--zephyr/projects/brya/kblight_hooks.c67
-rw-r--r--zephyr/projects/brya/prj.conf200
-rw-r--r--zephyr/projects/corsola/BUILD.py139
-rw-r--r--zephyr/projects/corsola/CMakeLists.txt81
-rw-r--r--zephyr/projects/corsola/Kconfig52
-rw-r--r--zephyr/projects/corsola/adc_tentacruel.dts66
-rw-r--r--zephyr/projects/corsola/battery_kingler.dts15
-rw-r--r--zephyr/projects/corsola/battery_steelix.dts24
-rw-r--r--zephyr/projects/corsola/cbi_steelix.dts95
-rw-r--r--zephyr/projects/corsola/gpio_steelix.dts255
-rw-r--r--zephyr/projects/corsola/i2c_krabby.dts22
-rw-r--r--zephyr/projects/corsola/i2c_krabby_tentacruel.dtsi138
-rw-r--r--zephyr/projects/corsola/i2c_magikarp.dts36
-rw-r--r--zephyr/projects/corsola/i2c_tentacruel.dts38
-rw-r--r--zephyr/projects/corsola/include/baseboard_usbc_config.h39
-rw-r--r--zephyr/projects/corsola/include/variant_db_detection.h33
-rw-r--r--zephyr/projects/corsola/interrupts_steelix.dts10
-rw-r--r--zephyr/projects/corsola/keyboard_steelix.dts29
-rw-r--r--zephyr/projects/corsola/led_it81202_base.dtsi184
-rw-r--r--zephyr/projects/corsola/led_kingler.dts71
-rw-r--r--zephyr/projects/corsola/led_magikarp.dts136
-rw-r--r--zephyr/projects/corsola/led_steelix.dts55
-rw-r--r--zephyr/projects/corsola/led_tentacruel.dts118
-rw-r--r--zephyr/projects/corsola/motionsense_steelix.dts133
-rw-r--r--zephyr/projects/corsola/power_signal.dts26
-rw-r--r--zephyr/projects/corsola/prj.conf101
-rw-r--r--zephyr/projects/corsola/prj_it81202_base.conf93
-rw-r--r--zephyr/projects/corsola/prj_kingler.conf12
-rw-r--r--zephyr/projects/corsola/prj_magikarp.conf27
-rw-r--r--zephyr/projects/corsola/prj_npcx993_base.conf95
-rw-r--r--zephyr/projects/corsola/prj_steelix.conf32
-rw-r--r--zephyr/projects/corsola/prj_tentacruel.conf26
-rw-r--r--zephyr/projects/corsola/src/board.c37
-rw-r--r--zephyr/projects/corsola/src/board_chipset.c49
-rw-r--r--zephyr/projects/corsola/src/hibernate.c22
-rw-r--r--zephyr/projects/corsola/src/kingler/board_steelix.c76
-rw-r--r--zephyr/projects/corsola/src/kingler/i2c.c21
-rw-r--r--zephyr/projects/corsola/src/kingler/led_steelix.c181
-rw-r--r--zephyr/projects/corsola/src/kingler/usb_pd_policy.c74
-rw-r--r--zephyr/projects/corsola/src/kingler/usbc_config.c317
-rw-r--r--zephyr/projects/corsola/src/krabby/charger_workaround.c93
-rw-r--r--zephyr/projects/corsola/src/krabby/hooks.c90
-rw-r--r--zephyr/projects/corsola/src/krabby/i2c.c19
-rw-r--r--zephyr/projects/corsola/src/krabby/ppc_krabby.c31
-rw-r--r--zephyr/projects/corsola/src/krabby/sensor_magikarp.c41
-rw-r--r--zephyr/projects/corsola/src/krabby/sensor_tentacruel.c41
-rw-r--r--zephyr/projects/corsola/src/krabby/temp_tentacruel.c129
-rw-r--r--zephyr/projects/corsola/src/krabby/usbc_config.c141
-rw-r--r--zephyr/projects/corsola/src/usb_pd_policy.c226
-rw-r--r--zephyr/projects/corsola/src/usbc_config.c319
-rw-r--r--zephyr/projects/corsola/src/variant_db_detection.c115
-rw-r--r--zephyr/projects/corsola/usba_steelix.dts10
-rw-r--r--zephyr/projects/corsola/usbc_krabby.dts59
-rw-r--r--zephyr/projects/corsola/usbc_magikarp.dts59
-rw-r--r--zephyr/projects/corsola/usbc_tentacruel.dts60
-rw-r--r--zephyr/projects/herobrine/BUILD.py124
-rw-r--r--zephyr/projects/herobrine/CMakeLists.txt37
-rw-r--r--zephyr/projects/herobrine/battery_evoker.dts15
-rw-r--r--zephyr/projects/herobrine/battery_herobrine.dts12
-rw-r--r--zephyr/projects/herobrine/battery_hoglin.dts12
-rw-r--r--zephyr/projects/herobrine/battery_villager.dts15
-rw-r--r--zephyr/projects/herobrine/battery_zombie.dts15
-rw-r--r--zephyr/projects/herobrine/gpio.dts329
-rw-r--r--zephyr/projects/herobrine/gpio_evoker.dts329
-rw-r--r--zephyr/projects/herobrine/gpio_hoglin.dts327
-rw-r--r--zephyr/projects/herobrine/gpio_villager.dts323
-rw-r--r--zephyr/projects/herobrine/gpio_zombie.dts323
-rw-r--r--zephyr/projects/herobrine/i2c_common.dtsi157
-rw-r--r--zephyr/projects/herobrine/i2c_evoker.dts46
-rw-r--r--zephyr/projects/herobrine/i2c_herobrine.dts39
-rw-r--r--zephyr/projects/herobrine/i2c_hoglin.dts34
-rw-r--r--zephyr/projects/herobrine/i2c_villager.dts34
-rw-r--r--zephyr/projects/herobrine/i2c_zombie.dts34
-rw-r--r--zephyr/projects/herobrine/include/board_chipset.h11
-rw-r--r--zephyr/projects/herobrine/led_pins_evoker.dts54
-rw-r--r--zephyr/projects/herobrine/led_pins_herobrine.dts56
-rw-r--r--zephyr/projects/herobrine/led_pins_hoglin.dts33
-rw-r--r--zephyr/projects/herobrine/led_pins_villager.dts33
-rw-r--r--zephyr/projects/herobrine/led_pins_zombie.dts33
-rw-r--r--zephyr/projects/herobrine/prj.conf160
-rw-r--r--zephyr/projects/herobrine/prj_evoker.conf16
-rw-r--r--zephyr/projects/herobrine/src/board_chipset.c83
-rw-r--r--zephyr/projects/herobrine/src/herobrine/alt_dev_replacement.c36
-rw-r--r--zephyr/projects/herobrine/src/i2c.c17
-rw-r--r--zephyr/projects/herobrine/src/usb_pd_policy.c254
-rw-r--r--zephyr/projects/herobrine/src/usbc_config.c278
-rw-r--r--zephyr/projects/herobrine/switchcap.dts12
-rw-r--r--zephyr/projects/herobrine/switchcap_hoglin.dts12
-rw-r--r--zephyr/projects/herobrine/usbc_evoker.dts42
-rw-r--r--zephyr/projects/herobrine/usbc_herobrine.dts43
-rw-r--r--zephyr/projects/herobrine/usbc_hoglin.dts42
-rw-r--r--zephyr/projects/herobrine/usbc_villager.dts42
-rw-r--r--zephyr/projects/herobrine/usbc_zombie.dts42
-rw-r--r--zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts201
-rw-r--r--zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts31
-rw-r--r--zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/prj.conf84
-rw-r--r--zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts258
-rw-r--r--zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts59
-rw-r--r--zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/prj.conf24
-rw-r--r--zephyr/projects/intelrvp/adlrvp/prj.conf76
-rw-r--r--zephyr/projects/intelrvp/adlrvp/src/adlrvp.c430
-rw-r--r--zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts60
-rw-r--r--zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts59
-rw-r--r--zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts273
-rw-r--r--zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf18
-rw-r--r--zephyr/projects/intelrvp/mtlrvp/prj.conf80
-rw-r--r--zephyr/projects/intelrvp/mtlrvp/src/board_power.c61
-rw-r--r--zephyr/projects/intelrvp/mtlrvp/src/mtlrvp.c331
-rw-r--r--zephyr/projects/intelrvp/prj.conf72
-rw-r--r--zephyr/projects/intelrvp/src/chg_usb_pd.c129
-rw-r--r--zephyr/projects/intelrvp/src/intel_rvp_board_id.c30
-rw-r--r--zephyr/projects/intelrvp/zephyr_ap_pwrseq.conf9
-rw-r--r--zephyr/projects/it8xxx2_evb/include/i2c_map.h16
-rw-r--r--zephyr/projects/it8xxx2_evb/prj.conf44
-rw-r--r--zephyr/projects/minimal/prj.conf18
-rw-r--r--zephyr/projects/nissa/BUILD.py66
-rw-r--r--zephyr/projects/nissa/CMakeLists.txt84
-rw-r--r--zephyr/projects/nissa/Kconfig52
-rw-r--r--zephyr/projects/nissa/craask/cbi.dtsi107
-rw-r--r--zephyr/projects/nissa/craask/generated.dtsi288
-rw-r--r--zephyr/projects/nissa/craask/keyboard.dtsi32
-rw-r--r--zephyr/projects/nissa/craask/motionsense.dtsi257
-rw-r--r--zephyr/projects/nissa/craask/overlay.dtsi360
-rw-r--r--zephyr/projects/nissa/craask/project.conf15
-rw-r--r--zephyr/projects/nissa/craask/src/charger.c56
-rw-r--r--zephyr/projects/nissa/craask/src/form_factor.c121
-rw-r--r--zephyr/projects/nissa/craask/src/keyboard.c29
-rw-r--r--zephyr/projects/nissa/it8xxx2_program.conf62
-rw-r--r--zephyr/projects/nissa/joxer/motionsense.dtsi149
-rw-r--r--zephyr/projects/nissa/joxer/overlay.dtsi445
-rw-r--r--zephyr/projects/nissa/joxer/src/charger.c56
-rw-r--r--zephyr/projects/nissa/joxer/src/fan.c43
-rw-r--r--zephyr/projects/nissa/joxer/src/keyboard.c68
-rw-r--r--zephyr/projects/nissa/joxer/src/led.c181
-rw-r--r--zephyr/projects/nissa/joxer/src/usbc.c392
-rw-r--r--zephyr/projects/nissa/nereid/overlay.dtsi400
-rw-r--r--zephyr/projects/nissa/nereid/src/charger.c56
-rw-r--r--zephyr/projects/nissa/nereid/src/hdmi.c28
-rw-r--r--zephyr/projects/nissa/nereid/src/usbc.c393
-rw-r--r--zephyr/projects/nissa/nivviks/src/charger.c56
-rw-r--r--zephyr/projects/nissa/nivviks/src/usbc.c277
-rw-r--r--zephyr/projects/nissa/npcx_program.conf47
-rw-r--r--zephyr/projects/nissa/program.conf156
-rw-r--r--zephyr/projects/nissa/pujjo/cbi.dtsi190
-rw-r--r--zephyr/projects/nissa/pujjo/generated.dtsi277
-rw-r--r--zephyr/projects/nissa/pujjo/motionsense.dtsi245
-rw-r--r--zephyr/projects/nissa/pujjo/overlay.dtsi350
-rw-r--r--zephyr/projects/nissa/pujjo/src/charger.c64
-rw-r--r--zephyr/projects/nissa/pujjo/src/fan.c43
-rw-r--r--zephyr/projects/nissa/pujjo/src/form_factor.c66
-rw-r--r--zephyr/projects/nissa/pujjo/src/led.c134
-rw-r--r--zephyr/projects/nissa/pujjo/src/usbc.c242
-rw-r--r--zephyr/projects/nissa/src/board_power.c169
-rw-r--r--zephyr/projects/nissa/src/common.c154
-rw-r--r--zephyr/projects/nissa/src/sub_board.c298
-rw-r--r--zephyr/projects/nissa/xivu/cbi.dtsi77
-rw-r--r--zephyr/projects/nissa/xivu/led_pins.dtsi94
-rw-r--r--zephyr/projects/nissa/xivu/motionsense.dtsi156
-rw-r--r--zephyr/projects/nissa/xivu/overlay.dtsi357
-rw-r--r--zephyr/projects/nissa/xivu/project.conf14
-rw-r--r--zephyr/projects/nissa/xivu/src/charger.c69
-rw-r--r--zephyr/projects/nissa/xivu/src/usbc.c285
-rw-r--r--zephyr/projects/nissa/yaviks/overlay.dtsi402
-rw-r--r--zephyr/projects/nissa/yaviks/project.conf33
-rw-r--r--zephyr/projects/nissa/yaviks/project.overlay12
-rw-r--r--zephyr/projects/nissa/yaviks/src/charger.c74
-rw-r--r--zephyr/projects/nissa/yaviks/src/fan.c36
-rw-r--r--zephyr/projects/nissa/yaviks/src/keyboard.c106
-rw-r--r--zephyr/projects/nissa/yaviks/src/led.c231
-rw-r--r--zephyr/projects/nissa/yaviks/src/usbc.c393
-rw-r--r--zephyr/projects/npcx_evb/npcx7/keyboard.dts42
-rw-r--r--zephyr/projects/npcx_evb/npcx7/prj.conf60
-rw-r--r--zephyr/projects/npcx_evb/npcx9/keyboard.dts42
-rw-r--r--zephyr/projects/npcx_evb/npcx9/prj.conf64
-rw-r--r--zephyr/projects/rex/led.dts138
-rw-r--r--zephyr/projects/rex/power_signals.dts152
-rw-r--r--zephyr/projects/rex/prj.conf180
-rw-r--r--zephyr/projects/rex/prj_rex.conf9
-rw-r--r--zephyr/projects/rex/rex.dts262
-rw-r--r--zephyr/projects/rex/src/board_power.c61
-rw-r--r--zephyr/projects/rex/src/usb_pd_policy.c77
-rw-r--r--zephyr/projects/rex/src/usbc_config.c300
-rw-r--r--zephyr/projects/skyrim/BUILD.py86
-rw-r--r--zephyr/projects/skyrim/CMakeLists.txt62
-rw-r--r--zephyr/projects/skyrim/Kconfig46
-rw-r--r--zephyr/projects/skyrim/adc.dts82
-rw-r--r--zephyr/projects/skyrim/battery_winterhold.dts33
-rw-r--r--zephyr/projects/skyrim/fan.dts39
-rw-r--r--zephyr/projects/skyrim/frostflow.dts136
-rw-r--r--zephyr/projects/skyrim/gpio.dts370
-rw-r--r--zephyr/projects/skyrim/i2c_common.dtsi294
-rw-r--r--zephyr/projects/skyrim/keyboard.dts46
-rw-r--r--zephyr/projects/skyrim/led_pins_frostflow.dts63
-rw-r--r--zephyr/projects/skyrim/led_pins_morthal.dts63
-rw-r--r--zephyr/projects/skyrim/led_pins_skyrim.dts63
-rw-r--r--zephyr/projects/skyrim/led_pins_winterhold.dts63
-rw-r--r--zephyr/projects/skyrim/morthal.dts183
-rw-r--r--zephyr/projects/skyrim/prj.conf167
-rw-r--r--zephyr/projects/skyrim/prj_frostflow.conf30
-rw-r--r--zephyr/projects/skyrim/prj_morthal.conf23
-rw-r--r--zephyr/projects/skyrim/prj_skyrim.conf26
-rw-r--r--zephyr/projects/skyrim/prj_winterhold.conf26
-rw-r--r--zephyr/projects/skyrim/skyrim.dts207
-rw-r--r--zephyr/projects/skyrim/src/frostflow/keyboard_customization.c85
-rw-r--r--zephyr/projects/skyrim/src/frostflow/ppc_config.c46
-rw-r--r--zephyr/projects/skyrim/src/frostflow/usb_mux_config.c123
-rw-r--r--zephyr/projects/skyrim/src/morthal/ppc_config.c46
-rw-r--r--zephyr/projects/skyrim/src/morthal/usb_mux_config.c142
-rw-r--r--zephyr/projects/skyrim/src/power_signals.c245
-rw-r--r--zephyr/projects/skyrim/src/skyrim/alt_charger.c31
-rw-r--r--zephyr/projects/skyrim/src/skyrim/fan.c62
-rw-r--r--zephyr/projects/skyrim/src/skyrim/form_factor.c37
-rw-r--r--zephyr/projects/skyrim/src/skyrim/ppc_config.c46
-rw-r--r--zephyr/projects/skyrim/src/skyrim/usb_mux_config.c142
-rw-r--r--zephyr/projects/skyrim/src/usb_pd_policy.c93
-rw-r--r--zephyr/projects/skyrim/src/usbc_config.c403
-rw-r--r--zephyr/projects/skyrim/src/winterhold/kb_backlight.c34
-rw-r--r--zephyr/projects/skyrim/src/winterhold/ppc_config.c27
-rw-r--r--zephyr/projects/skyrim/src/winterhold/usb_mux_config.c110
-rw-r--r--zephyr/projects/skyrim/winterhold.dts126
-rw-r--r--zephyr/projects/trogdor/lazor/gpio.dts320
-rw-r--r--zephyr/projects/trogdor/lazor/gpio_led.dts33
-rw-r--r--zephyr/projects/trogdor/lazor/keyboard.dts38
-rw-r--r--zephyr/projects/trogdor/lazor/prj.conf164
-rw-r--r--zephyr/projects/trogdor/lazor/pwm_led.dts59
-rw-r--r--zephyr/projects/trogdor/lazor/src/i2c.c17
-rw-r--r--zephyr/projects/trogdor/lazor/src/power.c58
-rw-r--r--zephyr/projects/trogdor/lazor/src/sku.c92
-rw-r--r--zephyr/projects/trogdor/lazor/src/switchcap.c128
-rw-r--r--zephyr/projects/trogdor/lazor/src/usb_pd_policy.c261
-rw-r--r--zephyr/projects/trogdor/lazor/src/usbc_config.c335
-rw-r--r--zephyr/shim/chip/it8xxx2/clock.c7
-rw-r--r--zephyr/shim/chip/it8xxx2/gpio.c5
-rw-r--r--zephyr/shim/chip/it8xxx2/keyboard_raw.c9
-rw-r--r--zephyr/shim/chip/it8xxx2/power_policy.c7
-rw-r--r--zephyr/shim/chip/mchp/clock.c7
-rw-r--r--zephyr/shim/chip/mchp/gpio.c3
-rw-r--r--zephyr/shim/chip/mchp/keyboard_raw.c9
-rw-r--r--zephyr/shim/chip/mchp/system.c6
-rw-r--r--zephyr/shim/chip/mchp/system_download_from_flash.c7
-rw-r--r--zephyr/shim/chip/mchp/system_external_storage.c11
-rw-r--r--zephyr/shim/chip/npcx/clock.c7
-rw-r--r--zephyr/shim/chip/npcx/gpio.c11
-rw-r--r--zephyr/shim/chip/npcx/keyboard_raw.c9
-rw-r--r--zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c6
-rw-r--r--zephyr/shim/chip/npcx/power_policy.c9
-rw-r--r--zephyr/shim/chip/npcx/shi.c15
-rw-r--r--zephyr/shim/chip/npcx/system.c6
-rw-r--r--zephyr/shim/chip/npcx/system_download_from_flash.c9
-rw-r--r--zephyr/shim/chip/npcx/system_external_storage.c6
-rw-r--r--zephyr/shim/core/cortex-m/irq_command.c3
-rw-r--r--zephyr/shim/core/cortex-m/mpu.c7
-rw-r--r--zephyr/shim/include/board_led.h4
-rw-r--r--zephyr/shim/include/charger/chg_isl923x.h3
-rw-r--r--zephyr/shim/include/charger/chg_isl9241.h3
-rw-r--r--zephyr/shim/include/charger/chg_rt9490.h3
-rw-r--r--zephyr/shim/include/charger/chg_sm5803.h3
-rw-r--r--zephyr/shim/include/charger_chips.h1
-rw-r--r--zephyr/shim/include/config_chip.h129
-rw-r--r--zephyr/shim/include/cros_cbi.h7
-rw-r--r--zephyr/shim/include/fpu.h6
-rw-r--r--zephyr/shim/include/gpio/gpio.h1
-rw-r--r--zephyr/shim/include/motionsense_sensors.h3
-rw-r--r--zephyr/shim/include/motionsense_sensors_defs.h4
-rw-r--r--zephyr/shim/include/power/power.h34
-rw-r--r--zephyr/shim/include/temp_sensor/temp_sensor.h6
-rw-r--r--zephyr/shim/include/usbc/bc12_rt9490.h2
-rw-r--r--zephyr/shim/include/usbc/ppc.h7
-rw-r--r--zephyr/shim/include/usbc/tcpc_anx7447.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_anx7447_emul.h5
-rw-r--r--zephyr/shim/include/usbc/tcpc_ccgxxf.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_fusb302.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_generic_emul.h4
-rw-r--r--zephyr/shim/include/usbc/tcpc_it8xxx2.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_nct38xx.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_ps8xxx.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h3
-rw-r--r--zephyr/shim/include/usbc/tcpc_raa489000.h21
-rw-r--r--zephyr/shim/include/usbc/tcpc_rt1718s.h3
-rw-r--r--zephyr/shim/include/usbc/tcpci.h4
-rw-r--r--zephyr/shim/include/usbc/usb_muxes.h9
-rw-r--r--zephyr/shim/include/zephyr_hooks_shim.h6
-rw-r--r--zephyr/shim/include/zephyr_host_command.h3
-rw-r--r--zephyr/shim/include/zephyr_shim.h3
-rw-r--r--zephyr/shim/include/zephyr_write_protect.h1
-rw-r--r--zephyr/shim/src/CMakeLists.txt14
-rw-r--r--zephyr/shim/src/adc.c5
-rw-r--r--zephyr/shim/src/battery.c6
-rw-r--r--zephyr/shim/src/bb_retimer_usb_mux.c13
-rw-r--r--zephyr/shim/src/bc12.c5
-rw-r--r--zephyr/shim/src/bc12_pi3usb9201.c10
-rw-r--r--zephyr/shim/src/bc12_rt9490.c7
-rw-r--r--zephyr/shim/src/cbi/CMakeLists.txt7
-rw-r--r--zephyr/shim/src/cbi/cbi_eeprom.c37
-rw-r--r--zephyr/shim/src/cbi/cros_cbi.c3
-rw-r--r--zephyr/shim/src/cbi/cros_cbi_fw_config.c16
-rw-r--r--zephyr/shim/src/cbi/cros_cbi_ssfc.c29
-rw-r--r--zephyr/shim/src/charger.c3
-rw-r--r--zephyr/shim/src/chipset_api.c3
-rw-r--r--zephyr/shim/src/chipset_state_check.h2
-rw-r--r--zephyr/shim/src/console.c31
-rw-r--r--zephyr/shim/src/console_buffer.c4
-rw-r--r--zephyr/shim/src/crc.c4
-rw-r--r--zephyr/shim/src/espi.c24
-rw-r--r--zephyr/shim/src/fan.c32
-rw-r--r--zephyr/shim/src/flash.c11
-rw-r--r--zephyr/shim/src/gpio.c40
-rw-r--r--zephyr/shim/src/gpio_id.c20
-rw-r--r--zephyr/shim/src/gpio_int.c12
-rw-r--r--zephyr/shim/src/hooks.c11
-rw-r--r--zephyr/shim/src/host_command.c4
-rw-r--r--zephyr/shim/src/hwtimer.c5
-rw-r--r--zephyr/shim/src/i2c.c11
-rw-r--r--zephyr/shim/src/ioex.c9
-rw-r--r--zephyr/shim/src/ioex_drv.c47
-rw-r--r--zephyr/shim/src/keyboard_raw.c17
-rw-r--r--zephyr/shim/src/keyscan.c12
-rw-r--r--zephyr/shim/src/led_driver/CMakeLists.txt4
-rw-r--r--zephyr/shim/src/led_driver/led.c20
-rw-r--r--zephyr/shim/src/led_driver/led.h10
-rw-r--r--zephyr/shim/src/led_driver/led_gpio.c19
-rw-r--r--zephyr/shim/src/led_driver/led_pwm.c22
-rw-r--r--zephyr/shim/src/log_backend_console_buffer.c8
-rw-r--r--zephyr/shim/src/motionsense_sensors.c7
-rw-r--r--zephyr/shim/src/panic.c8
-rw-r--r--zephyr/shim/src/power.c30
-rw-r--r--zephyr/shim/src/ppc.c7
-rw-r--r--zephyr/shim/src/pwm_hc.c12
-rw-r--r--zephyr/shim/src/pwm_led.c1
-rw-r--r--zephyr/shim/src/rtc.c6
-rw-r--r--zephyr/shim/src/switchcap_gpio.c31
-rw-r--r--zephyr/shim/src/switchcap_ln9310.c26
-rw-r--r--zephyr/shim/src/system.c13
-rw-r--r--zephyr/shim/src/tasks.c46
-rw-r--r--zephyr/shim/src/tcpc.c10
-rw-r--r--zephyr/shim/src/tcpc_nct38xx.c6
-rw-r--r--zephyr/shim/src/temp_sensors.c69
-rw-r--r--zephyr/shim/src/thermal.c2
-rw-r--r--zephyr/shim/src/usb_muxes.c11
-rw-r--r--zephyr/shim/src/usba.c5
-rw-r--r--zephyr/shim/src/watchdog.c10
-rw-r--r--zephyr/shim/src/ztest_system.c2
-rw-r--r--zephyr/subsys/CMakeLists.txt1
-rw-r--r--zephyr/subsys/ap_pwrseq/include/signal_adc.h2
-rw-r--r--zephyr/subsys/ap_pwrseq/include/x86_common_pwrseq.h1
-rw-r--r--zephyr/subsys/ap_pwrseq/power_host_sleep.c7
-rw-r--r--zephyr/subsys/ap_pwrseq/power_signals.c10
-rw-r--r--zephyr/subsys/ap_pwrseq/signal_gpio.c6
-rw-r--r--zephyr/subsys/ap_pwrseq/signal_vw.c7
-rw-r--r--zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_console.c4
-rw-r--r--zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c5
-rw-r--r--zephyr/subsys/emul/CMakeLists.txt2
-rw-r--r--zephyr/subsys/emul/Kconfig5
-rw-r--r--zephyr/subsys/emul/ap_pwrseq/CMakeLists.txt1
-rw-r--r--zephyr/subsys/emul/ap_pwrseq/Kconfig34
-rw-r--r--zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c550
-rw-r--r--zephyr/test/ap_power/CMakeLists.txt2
-rw-r--r--zephyr/test/ap_power/boards/alderlake.dts269
-rw-r--r--zephyr/test/ap_power/boards/native_posix.overlay125
-rw-r--r--zephyr/test/ap_power/include/test_mocks.h23
-rw-r--r--zephyr/test/ap_power/include/test_state.h2
-rw-r--r--zephyr/test/ap_power/prj.conf9
-rw-r--r--zephyr/test/ap_power/src/ap_pwrseq.c141
-rw-r--r--zephyr/test/ap_power/src/board.c29
-rw-r--r--zephyr/test/ap_power/src/console_command.c6
-rw-r--r--zephyr/test/ap_power/src/events.c15
-rw-r--r--zephyr/test/ap_power/src/hibdelay.c37
-rw-r--r--zephyr/test/ap_power/src/hibernate.c39
-rw-r--r--zephyr/test/ap_power/src/host_command.c28
-rw-r--r--zephyr/test/ap_power/src/main.c5
-rw-r--r--zephyr/test/ap_power/src/signals.c20
-rw-r--r--zephyr/test/ap_power/src/test_mocks.c30
-rw-r--r--zephyr/test/ap_power/testcase.yaml8
-rw-r--r--zephyr/test/crc/main.c4
-rw-r--r--zephyr/test/drivers/CMakeLists.txt7
-rw-r--r--zephyr/test/drivers/Kconfig31
-rw-r--r--zephyr/test/drivers/anx7447/prj.conf1
-rw-r--r--zephyr/test/drivers/anx7447/src/low_power_mode.c6
-rw-r--r--zephyr/test/drivers/anx7447/tcpc_policy.dts2
-rw-r--r--zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c8
-rw-r--r--zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c247
-rw-r--r--zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt6
-rw-r--r--zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c279
-rw-r--r--zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c119
-rw-r--r--zephyr/test/drivers/boards/native_posix.overlay181
-rw-r--r--zephyr/test/drivers/button/src/main.c10
-rw-r--r--zephyr/test/drivers/chargesplash/src/chargesplash.c23
-rw-r--r--zephyr/test/drivers/common/include/test/drivers/stubs.h7
-rw-r--r--zephyr/test/drivers/common/include/test/drivers/test_mocks.h6
-rw-r--r--zephyr/test/drivers/common/include/test/drivers/test_state.h2
-rw-r--r--zephyr/test/drivers/common/include/test/drivers/utils.h76
-rw-r--r--zephyr/test/drivers/common/src/main.c5
-rw-r--r--zephyr/test/drivers/common/src/stubs.c88
-rw-r--r--zephyr/test/drivers/common/src/test_mocks.c10
-rw-r--r--zephyr/test/drivers/common/src/test_rules.c4
-rw-r--r--zephyr/test/drivers/common/src/utils.c36
-rw-r--r--zephyr/test/drivers/common_cbi/src/test_common_cbi.c221
-rw-r--r--zephyr/test/drivers/common_cbi_gpio/src/test_common_cbi_gpio.c4
-rw-r--r--zephyr/test/drivers/common_charger/CMakeLists.txt7
-rw-r--r--zephyr/test/drivers/common_charger/src/test_charge_state_v2.c129
-rw-r--r--zephyr/test/drivers/common_charger/src/test_common_charger.c10
-rw-r--r--zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c598
-rw-r--r--zephyr/test/drivers/console/src/shell.c8
-rw-r--r--zephyr/test/drivers/default/CMakeLists.txt10
-rw-r--r--zephyr/test/drivers/default/boards/native_posix.overlay34
-rw-r--r--zephyr/test/drivers/default/prj.conf1
-rw-r--r--zephyr/test/drivers/default/src/battery.c233
-rw-r--r--zephyr/test/drivers/default/src/bb_retimer.c30
-rw-r--r--zephyr/test/drivers/default/src/bc12.c277
-rw-r--r--zephyr/test/drivers/default/src/bma2x2.c13
-rw-r--r--zephyr/test/drivers/default/src/bmi160.c19
-rw-r--r--zephyr/test/drivers/default/src/bmi260.c15
-rw-r--r--zephyr/test/drivers/default/src/bmi_common.c8
-rw-r--r--zephyr/test/drivers/default/src/charge_manager.c4
-rw-r--r--zephyr/test/drivers/default/src/charge_state_prevent_power_on.c91
-rw-r--r--zephyr/test/drivers/default/src/chipset.c101
-rw-r--r--zephyr/test/drivers/default/src/console.c12
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/accelinfo.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/accelinit.c8
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/accelrange.c8
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/accelrate.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/accelread.c8
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/accelres.c8
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/accelspoof.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/adc.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/battery.c8
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/button.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/cbi.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/charge_manager.c8
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/charge_state.c34
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/chargen.c17
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/charger.c14
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/crash.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/cutoff.c8
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/ec_features.c16
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/gpio.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/hcdebug.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/hibdelay.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/hostevent.c8
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/i2c_portmap.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/md.c16
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/panic_output.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/port80.c11
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/power_button.c1
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/powerindebug.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/pwr_avg.c47
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/rtc.c4
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/rw.c18
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/shared_mem.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/sleepmask.c10
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/sleeptimeout.c6
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/switch.c31
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/sysinfo.c12
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c8
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c37
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/vboot_hash.c13
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/version.c10
-rw-r--r--zephyr/test/drivers/default/src/console_cmd/waitms.c7
-rw-r--r--zephyr/test/drivers/default/src/cros_cbi.c6
-rw-r--r--zephyr/test/drivers/default/src/espi.c13
-rw-r--r--zephyr/test/drivers/default/src/flash.c88
-rw-r--r--zephyr/test/drivers/default/src/gpio.c86
-rw-r--r--zephyr/test/drivers/default/src/i2c.c25
-rw-r--r--zephyr/test/drivers/default/src/i2c_passthru.c225
-rw-r--r--zephyr/test/drivers/default/src/integration/usbc/usb.c10
-rw-r--r--zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c14
-rw-r--r--zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c13
-rw-r--r--zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c64
-rw-r--r--zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c30
-rw-r--r--zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c14
-rw-r--r--zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c11
-rw-r--r--zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c44
-rw-r--r--zephyr/test/drivers/default/src/isl923x.c14
-rw-r--r--zephyr/test/drivers/default/src/led.c11
-rw-r--r--zephyr/test/drivers/default/src/lid_angle.c4
-rw-r--r--zephyr/test/drivers/default/src/lid_switch.c19
-rw-r--r--zephyr/test/drivers/default/src/lis2dw12.c5
-rw-r--r--zephyr/test/drivers/default/src/ln9310.c16
-rw-r--r--zephyr/test/drivers/default/src/locate_chip.c10
-rw-r--r--zephyr/test/drivers/default/src/motion_sense/motion_sense.c20
-rw-r--r--zephyr/test/drivers/default/src/panic.c11
-rw-r--r--zephyr/test/drivers/default/src/panic_output.c4
-rw-r--r--zephyr/test/drivers/default/src/port80.c11
-rw-r--r--zephyr/test/drivers/default/src/power_common.c42
-rw-r--r--zephyr/test/drivers/default/src/ppc_sn5s330.c16
-rw-r--r--zephyr/test/drivers/default/src/ppc_syv682x.c92
-rw-r--r--zephyr/test/drivers/default/src/ps8xxx.c23
-rw-r--r--zephyr/test/drivers/default/src/smart.c17
-rw-r--r--zephyr/test/drivers/default/src/stm_mems_common.c11
-rw-r--r--zephyr/test/drivers/default/src/tablet_mode.c66
-rw-r--r--zephyr/test/drivers/default/src/task.c84
-rw-r--r--zephyr/test/drivers/default/src/tcpci.c23
-rw-r--r--zephyr/test/drivers/default/src/tcpci_test_common.c9
-rw-r--r--zephyr/test/drivers/default/src/tcpm_header.c235
-rw-r--r--zephyr/test/drivers/default/src/tcs3400.c13
-rw-r--r--zephyr/test/drivers/default/src/temp_sensor.c111
-rw-r--r--zephyr/test/drivers/default/src/thermistor.c47
-rw-r--r--zephyr/test/drivers/default/src/uart_hostcmd.c8
-rw-r--r--zephyr/test/drivers/default/src/usb_mux.c58
-rw-r--r--zephyr/test/drivers/default/src/util.c8
-rw-r--r--zephyr/test/drivers/default/src/vboot_hash.c9
-rw-r--r--zephyr/test/drivers/default/src/virtual_battery.c155
-rw-r--r--zephyr/test/drivers/default/src/vstore.c15
-rw-r--r--zephyr/test/drivers/default/src/watchdog.c17
-rw-r--r--zephyr/test/drivers/dps/src/dps.c8
-rw-r--r--zephyr/test/drivers/host_cmd/CMakeLists.txt1
-rw-r--r--zephyr/test/drivers/host_cmd/src/adc.c8
-rw-r--r--zephyr/test/drivers/host_cmd/src/battery_cut_off.c6
-rw-r--r--zephyr/test/drivers/host_cmd/src/battery_display_soc.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/battery_v2.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/charge_manager.c48
-rw-r--r--zephyr/test/drivers/host_cmd/src/get_cmd_versions.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/get_panic_info.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c8
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_command.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_event_commands.c3
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c187
-rw-r--r--zephyr/test/drivers/host_cmd/src/host_request_expected_size.c4
-rw-r--r--zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c3
-rw-r--r--zephyr/test/drivers/host_cmd/src/motion_sense.c16
-rw-r--r--zephyr/test/drivers/host_cmd/src/pd_chip_info.c12
-rw-r--r--zephyr/test/drivers/host_cmd/src/pd_control.c30
-rw-r--r--zephyr/test/drivers/host_cmd/src/pd_log.c39
-rw-r--r--zephyr/test/drivers/host_cmd/src/tablet_mode.c111
-rw-r--r--zephyr/test/drivers/host_cmd/src/usb_pd_control.c10
-rw-r--r--zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c6
-rw-r--r--zephyr/test/drivers/host_cmd_read_memmap/CMakeLists.txt7
-rw-r--r--zephyr/test/drivers/host_cmd_read_memmap/src/read_memmap.c96
-rw-r--r--zephyr/test/drivers/host_command_thread/CMakeLists.txt5
-rw-r--r--zephyr/test/drivers/host_command_thread/src/main.c83
-rw-r--r--zephyr/test/drivers/i2c_controller/include/basic_i2c_device_emul.h4
-rw-r--r--zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c7
-rw-r--r--zephyr/test/drivers/i2c_controller/src/i2c_controller.c122
-rw-r--r--zephyr/test/drivers/isl923x/src/charge_ramp_hw.c4
-rw-r--r--zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c10
-rw-r--r--zephyr/test/drivers/keyboard_scan/include/keyboard_test_utils.h2
-rw-r--r--zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c43
-rw-r--r--zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c34
-rw-r--r--zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c5
-rw-r--r--zephyr/test/drivers/keyboard_scan/src/mkbp_event.c121
-rw-r--r--zephyr/test/drivers/keyboard_scan/src/mkbp_info.c11
-rw-r--r--zephyr/test/drivers/led_common/CMakeLists.txt5
-rw-r--r--zephyr/test/drivers/led_common/src/main.c31
-rw-r--r--zephyr/test/drivers/led_driver/led_pins.dts32
-rw-r--r--zephyr/test/drivers/led_driver/led_policy.dts2
-rw-r--r--zephyr/test/drivers/led_driver/src/led.c3
-rw-r--r--zephyr/test/drivers/led_driver/src/led_common.c6
-rw-r--r--zephyr/test/drivers/locate_chip/src/locate_chip.c6
-rw-r--r--zephyr/test/drivers/memmap/CMakeLists.txt5
-rw-r--r--zephyr/test/drivers/memmap/src/main.c89
-rw-r--r--zephyr/test/drivers/mkbp/src/mkbp_fifo.c12
-rw-r--r--zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c8
-rw-r--r--zephyr/test/drivers/prj.conf29
-rw-r--r--zephyr/test/drivers/rt9490/charger.dts13
-rw-r--r--zephyr/test/drivers/rt9490/prj.conf2
-rw-r--r--zephyr/test/drivers/rt9490/src/bc12.c26
-rw-r--r--zephyr/test/drivers/rt9490/src/charger.c4
-rw-r--r--zephyr/test/drivers/shim_gpio_id/gpio_id.dts8
-rw-r--r--zephyr/test/drivers/shim_gpio_id/src/test_shim_gpio_id.c4
-rw-r--r--zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c16
-rw-r--r--zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c10
-rw-r--r--zephyr/test/drivers/system/src/system.c10
-rw-r--r--zephyr/test/drivers/system/src/system_board_version_cbi.c8
-rw-r--r--zephyr/test/drivers/system/src/system_board_version_default.c4
-rw-r--r--zephyr/test/drivers/system/src/system_not_board_ap_set_sku_id.c4
-rw-r--r--zephyr/test/drivers/testcase.yaml69
-rw-r--r--zephyr/test/drivers/timer/src/timer.c8
-rw-r--r--zephyr/test/drivers/usb_common/CMakeLists.txt2
-rw-r--r--zephyr/test/drivers/usb_common/src/suite.c4
-rw-r--r--zephyr/test/drivers/usb_common/src/usb_common.c298
-rw-r--r--zephyr/test/drivers/usb_common/src/usb_pd_discharge.c8
-rw-r--r--zephyr/test/drivers/usb_common/src/usb_pd_flags.c6
-rw-r--r--zephyr/test/drivers/usb_malfunction_sink/src/usb_malfunction_sink.c13
-rw-r--r--zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c17
-rw-r--r--zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c8
-rw-r--r--zephyr/test/drivers/usbc_alt_mode/include/test_usbc_alt_mode.h7
-rw-r--r--zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c129
-rw-r--r--zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c12
-rw-r--r--zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode_ec_mode_entry.c10
-rw-r--r--zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c21
-rw-r--r--zephyr/test/drivers/usbc_ctvpd/CMakeLists.txt7
-rw-r--r--zephyr/test/drivers/usbc_ctvpd/include/test_usbc_ctvpd.h29
-rw-r--r--zephyr/test/drivers/usbc_ctvpd/src/main.c169
-rw-r--r--zephyr/test/drivers/usbc_ocp/src/usbc_ocp.c8
-rw-r--r--zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c10
-rw-r--r--zephyr/test/drivers/usbc_svdm_dfp_only/boards/native_posix.overlay23
-rw-r--r--zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf1
-rw-r--r--zephyr/test/drivers/usbc_svdm_dfp_only/src/usbc_svdm_dfp_only.c8
-rw-r--r--zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c19
-rw-r--r--zephyr/test/drivers/usbc_usb4_mode/CMakeLists.txt5
-rw-r--r--zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c269
-rw-r--r--zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c21
-rw-r--r--zephyr/test/ec_app/prj.conf1
-rw-r--r--zephyr/test/ec_app/src/main.c8
-rw-r--r--zephyr/test/herobrine/CMakeLists.txt6
-rw-r--r--zephyr/test/herobrine/Kconfig2
-rw-r--r--zephyr/test/herobrine/README.md2
-rw-r--r--zephyr/test/herobrine/boards/native_posix.overlay2
-rw-r--r--zephyr/test/herobrine/prj.conf2
-rw-r--r--zephyr/test/herobrine/src/board_chipset.c8
-rw-r--r--zephyr/test/herobrine/testcase.yaml2
-rw-r--r--zephyr/test/hooks/hooks.c7
-rw-r--r--zephyr/test/i2c/prj.conf4
-rw-r--r--zephyr/test/i2c/src/main.c31
-rw-r--r--zephyr/test/i2c_dts/prj.conf3
-rw-r--r--zephyr/test/jump_tags/CMakeLists.txt13
-rw-r--r--zephyr/test/jump_tags/boards/native_posix.overlay33
-rw-r--r--zephyr/test/jump_tags/prj.conf14
-rw-r--r--zephyr/test/jump_tags/src/jump_tags.c176
-rw-r--r--zephyr/test/jump_tags/testcase.yaml13
-rw-r--r--zephyr/test/kingler/CMakeLists.txt13
-rw-r--r--zephyr/test/kingler/README.md2
-rw-r--r--zephyr/test/kingler/common.dts18
-rw-r--r--zephyr/test/kingler/prj.conf4
-rw-r--r--zephyr/test/kingler/src/alt_sensor.c12
-rw-r--r--zephyr/test/kingler/src/ccd.c10
-rw-r--r--zephyr/test/kingler/src/clamshell.c8
-rw-r--r--zephyr/test/kingler/src/db_detect_hdmi.c58
-rw-r--r--zephyr/test/kingler/src/db_detect_none.c11
-rw-r--r--zephyr/test/kingler/src/db_detect_typec.c8
-rw-r--r--zephyr/test/kingler/src/fakes.c3
-rw-r--r--zephyr/test/kingler/src/tablet.c8
-rw-r--r--zephyr/test/kingler/testcase.yaml14
-rw-r--r--zephyr/test/krabby/CMakeLists.txt10
-rw-r--r--zephyr/test/krabby/README.md2
-rw-r--r--zephyr/test/krabby/adc_temp.dts23
-rw-r--r--zephyr/test/krabby/common.dts71
-rw-r--r--zephyr/test/krabby/pinctrl.dts2
-rw-r--r--zephyr/test/krabby/prj.conf24
-rw-r--r--zephyr/test/krabby/src/charger_workaround.c10
-rw-r--r--zephyr/test/krabby/src/stubs.c58
-rw-r--r--zephyr/test/krabby/src/temp_tentacruel.c26
-rw-r--r--zephyr/test/krabby/src/usb_mux_init.c8
-rw-r--r--zephyr/test/krabby/src/usbc_config.c131
-rw-r--r--zephyr/test/krabby/testcase.yaml7
-rw-r--r--zephyr/test/math/src/fixed_point_int_sqrtf.c4
-rw-r--r--zephyr/test/math/src/mask.c7
-rw-r--r--zephyr/test/math/src/math_util.c6
-rw-r--r--zephyr/test/math/src/vector.c4
-rw-r--r--zephyr/test/qcom_power/boards/native_posix.overlay14
-rw-r--r--zephyr/test/qcom_power/prj.conf4
-rw-r--r--zephyr/test/qcom_power/src/main.c341
-rw-r--r--zephyr/test/rex/CMakeLists.txt6
-rw-r--r--zephyr/test/rex/README.md2
-rw-r--r--zephyr/test/rex/boards/native_posix.overlay2
-rw-r--r--zephyr/test/rex/src/usb_pd_policy.c7
-rw-r--r--zephyr/test/rex/testcase.yaml2
-rw-r--r--zephyr/test/system_common/prj.conf1
-rw-r--r--zephyr/test/system_common/src/build_info.c6
-rw-r--r--zephyr/test/system_common/src/get_version.c6
-rw-r--r--zephyr/test/system_common/src/reboot.c6
-rw-r--r--zephyr/test/system_common/src/system_is_locked.c4
-rw-r--r--zephyr/test/system_shim/CMakeLists.txt15
-rw-r--r--zephyr/test/system_shim/boards/native_posix.overlay5
-rw-r--r--zephyr/test/system_shim/default.overlay12
-rw-r--r--zephyr/test/system_shim/include/fakes.h31
-rw-r--r--zephyr/test/system_shim/prj.conf13
-rw-r--r--zephyr/test/system_shim/src/no_chosen.c24
-rw-r--r--zephyr/test/system_shim/src/suite.c50
-rw-r--r--zephyr/test/system_shim/src/test_system.c299
-rw-r--r--zephyr/test/system_shim/test_system.c257
-rw-r--r--zephyr/test/system_shim/testcase.yaml15
-rw-r--r--zephyr/test/tasks/main.c9
-rw-r--r--zephyr/test/test_utils/tasks_fakes.c5
-rw-r--r--zephyr/test/uart_printf/CMakeLists.txt20
-rw-r--r--zephyr/test/uart_printf/include/common.h12
-rw-r--r--zephyr/test/uart_printf/include/printf.h23
-rw-r--r--zephyr/test/uart_printf/include/uart.h28
-rw-r--r--zephyr/test/uart_printf/prj.conf9
-rw-r--r--zephyr/test/uart_printf/src/fakes.cc36
-rw-r--r--zephyr/test/uart_printf/src/main.cc101
-rw-r--r--zephyr/test/uart_printf/testcase.yaml8
-rw-r--r--zephyr/test/vboot_efs2/boards/native_posix.overlay16
-rw-r--r--zephyr/test/vboot_efs2/prj.conf10
-rw-r--r--zephyr/test/vboot_efs2/src/main.c25
-rw-r--r--zephyr/zmake/tests/test_jobserver.py201
-rw-r--r--zephyr/zmake/zmake/__main__.py9
-rw-r--r--zephyr/zmake/zmake/jobserver.py149
-rw-r--r--zephyr/zmake/zmake/multiproc.py45
-rw-r--r--zephyr/zmake/zmake/zmake.py691
2355 files changed, 53976 insertions, 36474 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d6f218c8cc..a0848a8779 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -2,7 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-image: jbettis/ubuntu-07sep22
+image: jbettis/ubuntu-07nov22
# You can update that image using this repo:
# https://gitlab.com/zephyr-ec/gitlab-ci-runner/-/tree/main
@@ -78,16 +78,11 @@ before_script:
# Install Python and packages
- python3 -V # Print out python version for debugging
- python3 -m pip install "${EC_DIR}/zephyr/zmake[tests]" --user
- - python3 -m pip install pyyaml packaging ply psutil 'pyelftools>=0.28'
- export PATH="$PATH:$HOME/.local/bin"
- export PYTHONIOENCODING=utf-8
# Build directory
- export BUILD_DIR=${EC_DIR}/build
- export TWISTER_OUT_DIR=${EC_DIR}/twister-out
- # Set up Twister to use the "host" toolchain, as defined in upstream Zephyr
- # repo, ultimately including ${ZEPHYR_BASE}/cmake/toolchain/host/generic.cmake
- - export TOOLCHAIN_ROOT=${ZEPHYR_BASE}
- - export ZEPHYR_TOOLCHAIN_VARIANT=host
# Users of this template must set:
# $PROJECT to the project to build. E.g., "lazor"
@@ -159,7 +154,7 @@ before_script:
"${MODULES_DIR}/**"
"${EC_DIR}/zephyr/drivers/**" "${EC_DIR}/zephyr/include/drivers/**"
"${EC_DIR}/zephyr/shim/chip/**" "${EC_DIR}/zephyr/shim/core/**"
- "${EC_DIR}/zephyr/projects/**" "/usr/include/**"
+ "${EC_DIR}/zephyr/program/**" "/usr/include/**"
"${EC_DIR}/build/**" "${EC_DIR}/twister-out*/**"
"${EC_DIR}/test/**"
"${EC_DIR}/zephyr/shim/chip/npcx/npcx_monitor/**"
@@ -174,7 +169,7 @@ before_script:
"${ZEPHYR_BASE}/**" "${MODULES_DIR}/**"
"${EC_DIR}/zephyr/drivers/**" "${EC_DIR}/zephyr/include/drivers/**"
"${EC_DIR}/zephyr/shim/chip/**" "${EC_DIR}/zephyr/shim/core/**"
- "${EC_DIR}/zephyr/projects/**" "/usr/include/**"
+ "${EC_DIR}/zephyr/program/**" "/usr/include/**"
"${EC_DIR}/build/**" "${EC_DIR}/twister-out*/**"
"${EC_DIR}/zephyr/shim/chip/npcx/npcx_monitor/**"
"${EC_DIR}/test/**"
@@ -275,6 +270,16 @@ skyrim_coverage:
PROJECT: "skyrim"
<<: *coverage_template
+rex:
+ variables:
+ PROJECT: "rex"
+ <<: *build_template
+
+rex_coverage:
+ variables:
+ PROJECT: "rex"
+ <<: *coverage_template
+
ec_coverage:
stage: test
needs: []
@@ -296,7 +301,7 @@ zephyr_coverage:
needs: []
script:
- python3 ${EC_DIR}/twister --coverage --outdir "${TWISTER_OUT_DIR}"
- -v -i --gcov-tool gcov -x=ALLOW_WARNINGS=ON
+ -v -i -x=ALLOW_WARNINGS=ON
artifacts:
paths:
- ec_dir/twister-out/coverage.info
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b2f3525fe..34e81f2be9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,6 +17,9 @@ endif()
set(PLATFORM_EC "${ZEPHYR_CURRENT_MODULE_DIR}" CACHE PATH
"Path to the platform/ec repo.")
+set(PLATFORM_EC_PROGRAM_DIR "${PLATFORM_EC}/zephyr/program" CACHE PATH
+ "Path to the root directory containing all Zephyr EC programs and projects.")
+
if(NOT EXISTS "${PLATFORM_EC}/zephyr/module.yml")
message(FATAL_ERROR "Failed to resolve PLATFORM_EC at
${PLATFORM_EC}/zephyr/module.yml")
diff --git a/Makefile.toolchain b/Makefile.toolchain
index c2612d260c..80896e3e40 100644
--- a/Makefile.toolchain
+++ b/Makefile.toolchain
@@ -47,6 +47,8 @@ ifeq ($(filter $(BOARD), $(CLANG_BOARDS)), $(BOARD))
CC=clang
USE_BUILTIN_STDLIB:=0
USE_CXX_COMPILER:=1
+# b/144957935: Generate exception on signed integer overflow.
+COMMON_WARN+=-ftrapv
endif
ifeq ($(USE_CXX_COMPILER), 1)
@@ -113,7 +115,7 @@ endif
C_WARN = -Wstrict-prototypes -Wdeclaration-after-statement -Wno-pointer-sign
C_WARN += -Werror-implicit-function-declaration
-COMMON_WARN = -Wall -Wundef \
+COMMON_WARN += -Wall -Wundef \
-Wno-trigraphs -Wno-format-security -Wno-address-of-packed-member \
-fno-common -fno-strict-aliasing -fno-strict-overflow -Wimplicit-fallthrough
# See https://www.chromium.org/chromium-os/build/c-exception-support
@@ -207,6 +209,9 @@ else
# TODO(https://issuetracker.google.com/234507656#comment19): C++ include path
# should not be necessary.
CXXFLAGS+=-I/usr/armv7m-cros-eabi/usr/include/c++/v1
+# TODO(https://issuetracker.google.com/254916723): Remove when toolchain is
+# fixed.
+CPPFLAGS+=-D_GNU_SOURCE
endif
ifeq ($(LIBFTDI_NAME),)
@@ -224,6 +229,9 @@ LIBFTDIUSB_HOST_LDLIBS:=$(shell $(HOST_PKG_CONFIG) --libs lib${LIBFTDI_NAME} l
LIBFTDIUSB_BUILD_CFLAGS:=$(shell $(BUILD_PKG_CONFIG) --cflags lib${LIBFTDI_NAME} libusb-1.0)
LIBFTDIUSB_BUILD_LDLIBS:=$(shell $(BUILD_PKG_CONFIG) --libs lib${LIBFTDI_NAME} libusb-1.0)
+LIBEC_HOST_CFLAGS:=$(shell $(HOST_PKG_CONFIG) --cflags libec)
+LIBEC_HOST_LDLIBS:=$(shell $(HOST_PKG_CONFIG) --libs libec)
+
ifeq ($(TEST_FUZZ),y)
LIBPROTOBUF_CFLAGS:=$(shell $(PKG_CONFIG) --cflags protobuf)
LIBPROTOBUF_LDLIBS:=$(shell $(PKG_CONFIG) --libs protobuf)
@@ -242,6 +250,7 @@ HOST_CFLAGS=$(HOST_CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN) \
HOST_CFLAGS+=$(LIBFTDIUSB_HOST_CFLAGS)
HOST_CFLAGS+=-DCHROMIUM_EC=$(EMPTY)
HOST_CXXFLAGS=$(HOST_CFLAGS) -Wno-c99-designator
+HOST_CXXFLAGS+=$(LIBEC_HOST_CFLAGS)
ifneq (${SYSROOT},)
LDFLAGS_EXTRA+=--sysroot=${SYSROOT}
endif
@@ -261,6 +270,7 @@ HOST_LDFLAGS=$(LIBFTDIUSB_HOST_LDLIBS)
ifneq (${HOST_SYSROOT},)
HOST_LDFLAGS+=--sysroot=${HOST_SYSROOT}
endif
+HOST_LDFLAGS+=$(LIBEC_HOST_LDLIBS)
HOST_TEST_LDFLAGS=-Wl,-T core/host/host_exe.lds -lrt -pthread -rdynamic -lm\
-fuse-ld=bfd -no-pie \
$(if $(TEST_COVERAGE), --coverage,) \
diff --git a/PRESUBMIT.cfg b/PRESUBMIT.cfg
index c42cb7d9b9..778c2046fb 100644
--- a/PRESUBMIT.cfg
+++ b/PRESUBMIT.cfg
@@ -14,6 +14,7 @@ tab_check: false
black_check: --include_regex=^util/chargen$
checkpatch_check: --no-tree --ignore=MSLEEP,VOLATILE,SPDX_LICENSE_TAG
kerneldoc_check: --include_regex=\bec_commands\.h$
+keyword_check: --block=zassume_
cros_license_check :
--exclude_regex=^third_party/bmi220/
diff --git a/baseboard/asurada/baseboard.c b/baseboard/asurada/baseboard.c
index 3a881c275a..c315841a6a 100644
--- a/baseboard/asurada/baseboard.c
+++ b/baseboard/asurada/baseboard.c
@@ -8,15 +8,14 @@
#include "adc.h"
#include "button.h"
#include "charge_manager.h"
-#include "charger.h"
-#include "charger.h"
#include "charge_state.h"
#include "charge_state_v2.h"
+#include "charger.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
-#include "driver/accelgyro_bmi_common.h"
#include "driver/accel_lis2dw12.h"
+#include "driver/accelgyro_bmi_common.h"
#include "driver/als_tcs3400.h"
#include "driver/bc12/mt6360.h"
#include "driver/charger/isl923x.h"
@@ -31,8 +30,8 @@
#include "keyboard_scan.h"
#include "lid_switch.h"
#include "motion_sense.h"
-#include "power_button.h"
#include "power.h"
+#include "power_button.h"
#include "regulator.h"
#include "spi.h"
#include "switch.h"
@@ -42,6 +41,7 @@
#include "timer.h"
#include "uart.h"
+/* This must be last. */
#include "gpio_list.h"
/* Wake-up pins for hibernate */
diff --git a/baseboard/asurada/baseboard.h b/baseboard/asurada/baseboard.h
index 62f74e1f57..a8b62ccf59 100644
--- a/baseboard/asurada/baseboard.h
+++ b/baseboard/asurada/baseboard.h
@@ -60,7 +60,8 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_ISL9238C
#define CONFIG_CHARGER_MAINTAIN_VBAT
#define CONFIG_CHARGER_OTG
@@ -183,8 +184,8 @@
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
-#include "registers.h"
#include "power/mt8192.h"
+#include "registers.h"
void board_reset_pd_mcu(void);
enum board_sub_board board_get_sub_board(void);
diff --git a/baseboard/asurada/regulator.c b/baseboard/asurada/regulator.c
index e2731c8385..0487f8faa6 100644
--- a/baseboard/asurada/regulator.c
+++ b/baseboard/asurada/regulator.c
@@ -3,8 +3,8 @@
* found in the LICENSE file.
*/
-#include "common.h"
#include "bc12/mt6360_public.h"
+#include "common.h"
/* SD Card */
int board_regulator_get_info(uint32_t index, char *name, uint16_t *num_voltages,
diff --git a/baseboard/asurada/usbc_config.c b/baseboard/asurada/usbc_config.c
index 0be43d343a..89b027124e 100644
--- a/baseboard/asurada/usbc_config.c
+++ b/baseboard/asurada/usbc_config.c
@@ -7,11 +7,11 @@
#include "adc.h"
#include "baseboard_common.h"
-#include "bc12/pi3usb9201_public.h"
#include "bc12/mt6360_public.h"
+#include "bc12/pi3usb9201_public.h"
#include "button.h"
-#include "charger.h"
#include "charge_state_v2.h"
+#include "charger.h"
#include "charger/isl923x_public.h"
#include "console.h"
#include "ec_commands.h"
@@ -20,20 +20,19 @@
#include "hooks.h"
#include "i2c.h"
#include "lid_switch.h"
-#include "task.h"
-#include "ppc/syv682x_public.h"
#include "power.h"
#include "power_button.h"
+#include "ppc/syv682x_public.h"
#include "spi.h"
#include "switch.h"
#include "tablet_mode.h"
+#include "task.h"
#include "tcpm/it8xxx2_pd_public.h"
#include "uart.h"
-#include "usbc_ppc.h"
#include "usb_charge.h"
#include "usb_mux.h"
-#include "usb_mux/ps8743_public.h"
#include "usb_mux/it5205_public.h"
+#include "usb_mux/ps8743_public.h"
#include "usb_pd_tcpm.h"
#include "usbc_ppc.h"
@@ -309,13 +308,6 @@ void board_reset_pd_mcu(void)
*/
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
{
/*
diff --git a/baseboard/brask/baseboard.c b/baseboard/brask/baseboard.c
index 5a96ba49ca..33a3d9acf4 100644
--- a/baseboard/brask/baseboard.c
+++ b/baseboard/brask/baseboard.c
@@ -5,7 +5,6 @@
#include "common.h"
#include "compile_time_macros.h"
-
#include "gpio_signal.h"
/* Wake up pins */
diff --git a/baseboard/brask/baseboard.h b/baseboard/brask/baseboard.h
index 3fb3a5955f..8f10ebb8aa 100644
--- a/baseboard/brask/baseboard.h
+++ b/baseboard/brask/baseboard.h
@@ -189,13 +189,13 @@
#ifndef __ASSEMBLER__
-#include <stdbool.h>
-#include <stdint.h>
-
-#include "common.h"
#include "baseboard_usbc_config.h"
+#include "common.h"
#include "extpower.h"
+#include <stdbool.h>
+#include <stdint.h>
+
/*
* Configure run-time data structures and operation based on CBI data. This
* typically includes customization for changes in the BOARD_VERSION and
diff --git a/baseboard/brask/cbi.c b/baseboard/brask/cbi.c
index 0dcfcca253..0ff0e4c7f7 100644
--- a/baseboard/brask/cbi.c
+++ b/baseboard/brask/cbi.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "cros_board_info.h"
#include "hooks.h"
+#include <stdint.h>
+
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
diff --git a/baseboard/brask/usb_pd_policy.c b/baseboard/brask/usb_pd_policy.c
index 0503415a9d..e20ad13f98 100644
--- a/baseboard/brask/usb_pd_policy.c
+++ b/baseboard/brask/usb_pd_policy.c
@@ -5,9 +5,6 @@
/* Shared USB-C policy for Brask boards */
-#include <stddef.h>
-#include <stdint.h>
-
#include "charge_manager.h"
#include "chipset.h"
#include "common.h"
@@ -16,15 +13,17 @@
#include "ec_commands.h"
#include "gpio.h"
#include "timer.h"
-#include "usbc_ppc.h"
#include "usb_mux.h"
#include "usb_pd.h"
-#include "usb_pd.h"
#include "usb_pd_tbt.h"
#include "usb_pd_tcpm.h"
#include "usb_pd_vdo.h"
+#include "usbc_ppc.h"
#include "util.h"
+#include <stddef.h>
+#include <stdint.h>
+
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
diff --git a/baseboard/brya/baseboard.h b/baseboard/brya/baseboard.h
index 84fefa9b53..b4ba8f2d16 100644
--- a/baseboard/brya/baseboard.h
+++ b/baseboard/brya/baseboard.h
@@ -68,7 +68,8 @@
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CMD_CHARGER_DUMP
@@ -240,14 +241,14 @@
#ifndef __ASSEMBLER__
-#include <stdbool.h>
-#include <stdint.h>
-
+#include "baseboard_usbc_config.h"
#include "cbi.h"
#include "common.h"
-#include "baseboard_usbc_config.h"
#include "extpower.h"
+#include <stdbool.h>
+#include <stdint.h>
+
/*
* Check battery disconnect state.
* This function will return if battery is initialized or not.
diff --git a/baseboard/brya/baseboard_usbc_config.h b/baseboard/brya/baseboard_usbc_config.h
index 6d0cf828a3..17f1fe6b06 100644
--- a/baseboard/brya/baseboard_usbc_config.h
+++ b/baseboard/brya/baseboard_usbc_config.h
@@ -11,7 +11,9 @@
#include "gpio_signal.h"
/* Common definition for the USB PD interrupt handlers. */
+#ifdef CONFIG_USB_CHARGER
void bc12_interrupt(enum gpio_signal signal);
+#endif
void ppc_interrupt(enum gpio_signal signal);
void retimer_interrupt(enum gpio_signal signal);
void tcpc_alert_event(enum gpio_signal signal);
diff --git a/baseboard/brya/battery_presence.c b/baseboard/brya/battery_presence.c
index 1e4ab4ed44..ad055c1d12 100644
--- a/baseboard/brya/battery_presence.c
+++ b/baseboard/brya/battery_presence.c
@@ -6,12 +6,12 @@
* Each board should implement board_battery_info[] to define the specific
* battery packs supported.
*/
-#include <stdbool.h>
-
#include "battery.h"
#include "battery_smart.h"
#include "common.h"
+#include <stdbool.h>
+
static enum battery_present batt_pres_prev = BP_NOT_SURE;
__overridable bool board_battery_is_initialized(void)
diff --git a/baseboard/brya/cbi.c b/baseboard/brya/cbi.c
index 7bc8dad117..f6e5034561 100644
--- a/baseboard/brya/cbi.c
+++ b/baseboard/brya/cbi.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "cros_board_info.h"
#include "hooks.h"
+#include <stdint.h>
+
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
diff --git a/baseboard/brya/charger_bq25720.c b/baseboard/brya/charger_bq25720.c
index a4fa209246..4976abdea6 100644
--- a/baseboard/brya/charger_bq25720.c
+++ b/baseboard/brya/charger_bq25720.c
@@ -3,16 +3,15 @@
* found in the LICENSE file.
*/
-#include "common.h"
-
#include "charge_manager.h"
#include "charge_state_v2.h"
#include "charger.h"
+#include "common.h"
#include "compile_time_macros.h"
#include "console.h"
#include "driver/charger/bq25710.h"
-#include "usbc_ppc.h"
#include "usb_pd.h"
+#include "usbc_ppc.h"
#include "util.h"
#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
@@ -81,10 +80,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/baseboard/brya/usb_pd_policy.c b/baseboard/brya/usb_pd_policy.c
index e902fbc4a6..377ef0462e 100644
--- a/baseboard/brya/usb_pd_policy.c
+++ b/baseboard/brya/usb_pd_policy.c
@@ -5,9 +5,6 @@
/* Shared USB-C policy for Brya boards */
-#include <stddef.h>
-#include <stdint.h>
-
#include "charge_manager.h"
#include "chipset.h"
#include "common.h"
@@ -16,15 +13,17 @@
#include "ec_commands.h"
#include "gpio.h"
#include "timer.h"
-#include "usbc_ppc.h"
#include "usb_mux.h"
#include "usb_pd.h"
-#include "usb_pd.h"
#include "usb_pd_tbt.h"
#include "usb_pd_tcpm.h"
#include "usb_pd_vdo.h"
+#include "usbc_ppc.h"
#include "util.h"
+#include <stddef.h>
+#include <stdint.h>
+
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
diff --git a/baseboard/cherry/baseboard.c b/baseboard/cherry/baseboard.c
index 3f5f5c0e64..4e0a00e1ad 100644
--- a/baseboard/cherry/baseboard.c
+++ b/baseboard/cherry/baseboard.c
@@ -8,9 +8,9 @@
#include "adc.h"
#include "button.h"
#include "charge_manager.h"
-#include "charger.h"
#include "charge_state.h"
#include "charge_state_v2.h"
+#include "charger.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
@@ -29,8 +29,8 @@
#include "i2c.h"
#include "keyboard_scan.h"
#include "lid_switch.h"
-#include "power_button.h"
#include "power.h"
+#include "power_button.h"
#include "regulator.h"
#include "spi.h"
#include "switch.h"
@@ -41,10 +41,10 @@
#include "timer.h"
#include "uart.h"
#include "usb_charge.h"
-#include "usbc_ppc.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#include "usb_tc_sm.h"
+#include "usbc_ppc.h"
static void bc12_interrupt(enum gpio_signal signal);
static void ppc_interrupt(enum gpio_signal signal);
diff --git a/baseboard/cherry/baseboard.h b/baseboard/cherry/baseboard.h
index 2b0d03a436..cfc1425d57 100644
--- a/baseboard/cherry/baseboard.h
+++ b/baseboard/cherry/baseboard.h
@@ -70,7 +70,8 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_ISL9238C
#define CONFIG_CHARGER_MAINTAIN_VBAT
/* Not used in boot flow, set to 0 to suppress system_can_boot_ap warning */
@@ -212,8 +213,8 @@
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
-#include "registers.h"
#include "power/mt8192.h"
+#include "registers.h"
enum adc_channel {
ADC_VBUS, /* ADC 0 */
diff --git a/baseboard/dedede/baseboard.c b/baseboard/dedede/baseboard.c
index cd55f37588..22034a09bd 100644
--- a/baseboard/dedede/baseboard.c
+++ b/baseboard/dedede/baseboard.c
@@ -294,6 +294,7 @@ int board_is_i2c_port_powered(int port)
return chipset_in_state(CHIPSET_STATE_ANY_OFF) ? 0 : 1;
}
+#if defined(CONFIG_CHARGER_RAA489000) || defined(CONFIG_CHARGER_SM5803)
__overridable int extpower_is_present(void)
{
int port;
@@ -314,6 +315,7 @@ __overridable int extpower_is_present(void)
return 0;
}
+#endif
__override uint32_t board_override_feature_flags0(uint32_t flags0)
{
diff --git a/baseboard/dedede/baseboard.h b/baseboard/dedede/baseboard.h
index e581a0e8d0..ba83b44375 100644
--- a/baseboard/dedede/baseboard.h
+++ b/baseboard/dedede/baseboard.h
@@ -164,7 +164,8 @@
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 256
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 256
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 256
#define CONFIG_USB_CHARGER
#define CONFIG_TRICKLE_CHARGING
diff --git a/baseboard/goroh/baseboard.c b/baseboard/goroh/baseboard.c
index f70f070fac..3ad5eda917 100644
--- a/baseboard/goroh/baseboard.c
+++ b/baseboard/goroh/baseboard.c
@@ -10,15 +10,14 @@
#include "baseboard_usbc_config.h"
#include "button.h"
#include "charge_manager.h"
-#include "charger.h"
-#include "charger.h"
#include "charge_state.h"
#include "charge_state_v2.h"
+#include "charger.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
-#include "driver/accelgyro_bmi_common.h"
#include "driver/accel_lis2dw12.h"
+#include "driver/accelgyro_bmi_common.h"
#include "driver/als_tcs3400.h"
#include "driver/charger/isl923x.h"
#include "driver/ppc/syv682x.h"
@@ -31,9 +30,8 @@
#include "keyboard_scan.h"
#include "lid_switch.h"
#include "motion_sense.h"
-#include "power_button.h"
-#include "power.h"
#include "power.h"
+#include "power_button.h"
#include "spi.h"
#include "switch.h"
#include "tablet_mode.h"
@@ -41,11 +39,12 @@
#include "temp_sensor.h"
#include "timer.h"
#include "uart.h"
-#include "usbc_ppc.h"
#include "usb_mux.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
+#include "usbc_ppc.h"
+/* Must be last. */
#include "gpio_list.h"
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
@@ -161,13 +160,6 @@ const struct cc_para_t *board_get_cc_tuning_parameter(enum usbpd_port port)
return &cc_parameter[port];
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
{
/*
diff --git a/baseboard/goroh/baseboard.h b/baseboard/goroh/baseboard.h
index 1488bb6fcf..594686f0bf 100644
--- a/baseboard/goroh/baseboard.h
+++ b/baseboard/goroh/baseboard.h
@@ -57,7 +57,8 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_ISL9238C
#define CONFIG_CHARGER_MAINTAIN_VBAT
#define CONFIG_CHARGER_OTG
@@ -185,8 +186,8 @@
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
-#include "registers.h"
#include "power/falconlite.h"
+#include "registers.h"
int board_get_version(void);
void board_reset_pd_mcu(void);
diff --git a/baseboard/goroh/usbc_config.c b/baseboard/goroh/usbc_config.c
index 9d162ca783..f604a090d1 100644
--- a/baseboard/goroh/usbc_config.c
+++ b/baseboard/goroh/usbc_config.c
@@ -4,22 +4,22 @@
*/
/* Goroh family-specific USB-C configuration */
-#include <stdint.h>
-#include <stdbool.h>
-
#include "common.h"
#include "compile_time_macros.h"
#include "config.h"
#include "console.h"
-#include "hooks.h"
-#include "driver/tcpm/it8xxx2_pd_public.h"
#include "driver/ppc/syv682x_public.h"
#include "driver/retimer/ps8818_public.h"
+#include "driver/tcpm/it8xxx2_pd_public.h"
#include "driver/tcpm/tcpci.h"
-#include "usb_pd.h"
-#include "usbc_ppc.h"
#include "gpio.h"
#include "gpio_signal.h"
+#include "hooks.h"
+#include "usb_pd.h"
+#include "usbc_ppc.h"
+
+#include <stdbool.h>
+#include <stdint.h>
#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ##args)
@@ -81,7 +81,7 @@ static const struct usb_mux_chain goroh_usb_c1_ps8818_retimer = {
&(const struct usb_mux){
.usb_port = USBC_PORT_C1,
.i2c_port = I2C_PORT_USB_C1,
- .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS,
+ .i2c_addr_flags = PS8818_I2C_ADDR0_FLAGS,
.driver = &ps8818_usb_retimer_driver,
},
.next = NULL,
diff --git a/baseboard/grunt/baseboard.c b/baseboard/grunt/baseboard.c
index 5fbf2823be..6c2fbc2046 100644
--- a/baseboard/grunt/baseboard.c
+++ b/baseboard/grunt/baseboard.c
@@ -464,18 +464,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- /*
- * Limit the input current to 95% negotiated limit,
- * to account for the charger chip margin.
- */
- charge_ma = charge_ma * 95 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
/* Keyboard scan setting */
__override struct keyboard_scan_config keyscan_config = {
/*
diff --git a/baseboard/grunt/baseboard.h b/baseboard/grunt/baseboard.h
index 1c19c05330..bdbec1e0d2 100644
--- a/baseboard/grunt/baseboard.h
+++ b/baseboard/grunt/baseboard.h
@@ -72,7 +72,9 @@
*
* See also b/111214767
*/
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
@@ -189,7 +191,6 @@
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
-#include "math_util.h"
#include "registers.h"
enum adc_channel {
@@ -223,23 +224,6 @@ enum sensor_id {
SENSOR_COUNT,
};
-/*
- * Matrix to rotate accelerators into the standard reference frame. The default
- * is the identity which is correct for the reference design. Variations of
- * Grunt may need to change it for manufacturability.
- * For the lid:
- * +x to the right
- * +y up
- * +z out of the page
- *
- * The principle axes of the body are aligned with the lid when the lid is in
- * the 180 degree position (open, flat).
- *
- * Boards within the Grunt family may need to modify this definition at
- * board_init() time.
- */
-extern mat33_fp_t grunt_base_standard_ref;
-
/* Sensors without hardware FIFO are in forced mode */
#define CONFIG_ACCEL_FORCE_MODE_MASK (1 << LID_ACCEL)
diff --git a/baseboard/guybrush/baseboard.c b/baseboard/guybrush/baseboard.c
index 5d36f5be9a..c79d14cf6d 100644
--- a/baseboard/guybrush/baseboard.c
+++ b/baseboard/guybrush/baseboard.c
@@ -5,25 +5,25 @@
/* Guybrush family-specific configuration */
-#include "cros_board_info.h"
#include "base_fw_config.h"
#include "battery_fuel_gauge.h"
#include "charge_manager.h"
#include "charge_ramp.h"
-#include "charge_state_v2.h"
#include "charge_state.h"
+#include "charge_state_v2.h"
#include "charger.h"
#include "chip/npcx/ps2_chip.h"
#include "chip/npcx/pwm_chip.h"
#include "chipset.h"
+#include "cros_board_info.h"
#include "driver/ppc/aoz1380_public.h"
#include "driver/ppc/nx20p348x.h"
#include "driver/retimer/anx7491.h"
#include "driver/retimer/ps8811.h"
#include "driver/retimer/ps8818_public.h"
#include "driver/tcpm/nct38xx.h"
-#include "driver/usb_mux/anx7451.h"
#include "driver/usb_mux/amd_fp6.h"
+#include "driver/usb_mux/anx7451.h"
#include "fan.h"
#include "fan_chip.h"
#include "gpio.h"
@@ -246,7 +246,7 @@ const struct usb_mux usbc1_ps8818 = {
.usb_port = USBC_PORT_C1,
.i2c_port = I2C_PORT_TCPC1,
.flags = USB_MUX_FLAG_RESETS_IN_G3,
- .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS,
+ .i2c_addr_flags = PS8818_I2C_ADDR0_FLAGS,
.driver = &ps8818_usb_retimer_driver,
.board_set = &board_c1_ps8818_mux_set,
};
@@ -534,13 +534,6 @@ int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp)
return rv;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
void sbu_fault_interrupt(enum ioex_signal signal)
{
int port = (signal == IOEX_USB_C0_SBU_FAULT_ODL) ? 0 : 1;
@@ -581,7 +574,7 @@ static void reset_nct38xx_port(int port)
GPIO_USB_C0_TCPC_RST_L :
GPIO_USB_C1_TCPC_RST_L;
- if (port < 0 || port > USBC_PORT_COUNT) {
+ if (port < 0 || port >= USBC_PORT_COUNT) {
CPRINTSUSB("%s invalid port %d", __func__, port);
return;
}
diff --git a/baseboard/guybrush/baseboard.h b/baseboard/guybrush/baseboard.h
index 04b1e10c97..e5223abfbe 100644
--- a/baseboard/guybrush/baseboard.h
+++ b/baseboard/guybrush/baseboard.h
@@ -162,7 +162,8 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_ISL9241
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
diff --git a/baseboard/guybrush/cbi.c b/baseboard/guybrush/cbi.c
index 6ce6fe0eb7..1baf506297 100644
--- a/baseboard/guybrush/cbi.c
+++ b/baseboard/guybrush/cbi.c
@@ -6,8 +6,8 @@
/* Guybrush CrOS Board Info(CBI) utilities */
#include "base_fw_config.h"
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "cros_board_info.h"
#include "hooks.h"
diff --git a/baseboard/hatch/baseboard.c b/baseboard/hatch/baseboard.c
index f5376700c5..b4e37e6bc8 100644
--- a/baseboard/hatch/baseboard.c
+++ b/baseboard/hatch/baseboard.c
@@ -348,13 +348,6 @@ int ppc_get_alert_status(int port)
#endif
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
#ifdef USB_PD_PORT_TCPC_MST
void baseboard_mst_enable_control(enum mst_source src, int level)
{
diff --git a/baseboard/hatch/baseboard.h b/baseboard/hatch/baseboard.h
index d5d680e7bf..4aee5200de 100644
--- a/baseboard/hatch/baseboard.h
+++ b/baseboard/hatch/baseboard.h
@@ -96,7 +96,9 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_BQ25710
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512 /* Allow low-current USB charging */
+/* Allow low-current USB charging */
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_CHARGE_RAMP_HW
diff --git a/baseboard/herobrine/baseboard.h b/baseboard/herobrine/baseboard.h
index 0782612cb8..72b8b02b04 100644
--- a/baseboard/herobrine/baseboard.h
+++ b/baseboard/herobrine/baseboard.h
@@ -88,7 +88,8 @@
#define CONFIG_CHARGER_PSYS_READ
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 10000
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
diff --git a/baseboard/herobrine/usbc_config.c b/baseboard/herobrine/usbc_config.c
index 2ebb8ae029..a5df0a0d4c 100644
--- a/baseboard/herobrine/usbc_config.c
+++ b/baseboard/herobrine/usbc_config.c
@@ -5,9 +5,9 @@
/* Herobrine family-specific USB-C configuration */
+#include "charge_state.h"
#include "charger.h"
#include "charger/isl923x_public.h"
-#include "charge_state.h"
#include "console.h"
#include "usb_pd.h"
diff --git a/baseboard/honeybuns/baseboard.c b/baseboard/honeybuns/baseboard.c
index 506eb6f265..430eb488e7 100644
--- a/baseboard/honeybuns/baseboard.c
+++ b/baseboard/honeybuns/baseboard.c
@@ -7,15 +7,15 @@
#include "console.h"
#include "cros_board_info.h"
#include "driver/mp4245.h"
+#include "driver/tcpm/tcpm.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
-#include "usb_pd.h"
#include "system.h"
#include "task.h"
#include "timer.h"
+#include "usb_pd.h"
#include "usbc_ppc.h"
-#include "driver/tcpm/tcpm.h"
#include "util.h"
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
diff --git a/baseboard/honeybuns/baseboard.h b/baseboard/honeybuns/baseboard.h
index 4dd218f57d..a2dc18ccdb 100644
--- a/baseboard/honeybuns/baseboard.h
+++ b/baseboard/honeybuns/baseboard.h
@@ -61,7 +61,6 @@
/* 48 MHz SYSCLK clock frequency */
#define CPU_CLOCK 48000000
-#define CONFIG_STM_HWTIMER32
#define TIM_CLOCK32 2
#define TIM_CLOCK_MSB 3
#define TIM_CLOCK_LSB 15
diff --git a/baseboard/honeybuns/usb_pd_policy.c b/baseboard/honeybuns/usb_pd_policy.c
index 956a73e7fb..f2e13d9ed9 100644
--- a/baseboard/honeybuns/usb_pd_policy.c
+++ b/baseboard/honeybuns/usb_pd_policy.c
@@ -3,13 +3,12 @@
* found in the LICENSE file.
*/
+#include "chip/stm32/ucpd-stm32gx.h"
#include "common.h"
#include "console.h"
-#include "chip/stm32/ucpd-stm32gx.h"
#include "cros_board_info.h"
#include "driver/mp4245.h"
#include "driver/tcpm/tcpci.h"
-#include "driver/mp4245.h"
#include "gpio.h"
#include "hooks.h"
#include "task.h"
diff --git a/baseboard/honeybuns/usbc_support.c b/baseboard/honeybuns/usbc_support.c
index db68ad527c..9c94f3f0ba 100644
--- a/baseboard/honeybuns/usbc_support.c
+++ b/baseboard/honeybuns/usbc_support.c
@@ -7,21 +7,21 @@
#include "common.h"
#include "console.h"
-#include "driver/tcpm/tcpci.h"
#include "driver/tcpm/ps8xxx.h"
-#include "sn5s330.h"
+#include "driver/tcpm/tcpci.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
+#include "registers.h"
+#include "sn5s330.h"
#include "system.h"
#include "timer.h"
+#include "ucpd-stm32gx.h"
#include "usb_charge.h"
-#include "usb_pd_tcpm.h"
#include "usb_pd.h"
+#include "usb_pd_tcpm.h"
#include "usbc_ppc.h"
#include "util.h"
-#include "registers.h"
-#include "ucpd-stm32gx.h"
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
diff --git a/baseboard/intelrvp/adlrvp.c b/baseboard/intelrvp/adlrvp.c
index 35ed0edf32..5f307ac066 100644
--- a/baseboard/intelrvp/adlrvp.c
+++ b/baseboard/intelrvp/adlrvp.c
@@ -5,10 +5,10 @@
/* Intel ADLRVP board-specific common configuration */
-#include "battery_fuel_gauge.h"
-#include "charger.h"
#include "battery.h"
+#include "battery_fuel_gauge.h"
#include "bq25710.h"
+#include "charger.h"
#include "common.h"
#include "driver/retimer/bb_retimer_public.h"
#include "extpower.h"
diff --git a/baseboard/intelrvp/baseboard.h b/baseboard/intelrvp/baseboard.h
index b927632fc5..e47434c4af 100644
--- a/baseboard/intelrvp/baseboard.h
+++ b/baseboard/intelrvp/baseboard.h
@@ -68,7 +68,8 @@
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_SENSE_RESISTOR 5
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
diff --git a/baseboard/intelrvp/chg_usb_pd.c b/baseboard/intelrvp/chg_usb_pd.c
index 95aeea0441..c4ae3ea72d 100644
--- a/baseboard/intelrvp/chg_usb_pd.c
+++ b/baseboard/intelrvp/chg_usb_pd.c
@@ -125,10 +125,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/baseboard/intelrvp/chg_usb_pd_mecc_1_0.c b/baseboard/intelrvp/chg_usb_pd_mecc_1_0.c
index cbc61e8402..ee8c67c7b6 100644
--- a/baseboard/intelrvp/chg_usb_pd_mecc_1_0.c
+++ b/baseboard/intelrvp/chg_usb_pd_mecc_1_0.c
@@ -11,8 +11,8 @@
#include "driver/ppc/sn5s330.h"
#include "gpio.h"
#include "hooks.h"
-#include "tcpm/tcpci.h"
#include "system.h"
+#include "tcpm/tcpci.h"
#include "usbc_ppc.h"
#ifdef CONFIG_ZEPHYR
diff --git a/baseboard/ite_evb/baseboard.c b/baseboard/ite_evb/baseboard.c
index 70f50f054b..4c82a91d4b 100644
--- a/baseboard/ite_evb/baseboard.c
+++ b/baseboard/ite_evb/baseboard.c
@@ -25,6 +25,8 @@
#include "timer.h"
#include "uart.h"
#include "util.h"
+
+/* Must be last. */
#include "gpio_list.h"
#if defined(CONFIG_FANS) || defined(CONFIG_PWM)
diff --git a/baseboard/ite_evb/usb_pd_policy.c b/baseboard/ite_evb/usb_pd_policy.c
index 71af9d2b1c..c7d10787bb 100644
--- a/baseboard/ite_evb/usb_pd_policy.c
+++ b/baseboard/ite_evb/usb_pd_policy.c
@@ -6,8 +6,8 @@
/* Shared USB-C policy for ite_evb baseboard */
#include "adc.h"
-#include "config.h"
#include "common.h"
+#include "config.h"
#include "console.h"
#include "gpio.h"
#include "hooks.h"
@@ -16,9 +16,9 @@
#include "system.h"
#include "task.h"
#include "timer.h"
-#include "util.h"
#include "usb_mux.h"
#include "usb_pd_pdo.h"
+#include "util.h"
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
diff --git a/baseboard/kalista/baseboard.c b/baseboard/kalista/baseboard.c
index e929e5449c..7b20ea6a43 100644
--- a/baseboard/kalista/baseboard.c
+++ b/baseboard/kalista/baseboard.c
@@ -15,13 +15,12 @@
#include "console.h"
#include "cros_board_info.h"
#include "driver/pmic_tps650x30.h"
-#include "driver/temp_sensor/tmp432.h"
#include "driver/tcpm/ps8xxx.h"
#include "driver/tcpm/tcpci.h"
#include "driver/tcpm/tcpm.h"
+#include "driver/temp_sensor/tmp432.h"
#include "espi.h"
#include "extpower.h"
-#include "espi.h"
#include "fan.h"
#include "fan_chip.h"
#include "gpio.h"
diff --git a/baseboard/kalista/usb_pd_policy.c b/baseboard/kalista/usb_pd_policy.c
index 017c340a1b..b2f4656519 100644
--- a/baseboard/kalista/usb_pd_policy.c
+++ b/baseboard/kalista/usb_pd_policy.c
@@ -4,12 +4,12 @@
*/
#include "atomic.h"
-#include "extpower.h"
#include "charge_manager.h"
#include "common.h"
#include "console.h"
#include "driver/tcpm/anx74xx.h"
#include "driver/tcpm/ps8xxx.h"
+#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
#include "host_command.h"
@@ -17,11 +17,11 @@
#include "system.h"
#include "task.h"
#include "timer.h"
-#include "util.h"
#include "usb_mux.h"
#include "usb_pd.h"
#include "usb_pd_pdo.h"
#include "usb_pd_tcpm.h"
+#include "util.h"
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
diff --git a/baseboard/kukui/baseboard.h b/baseboard/kukui/baseboard.h
index d1ba87702e..6cb18b0d4e 100644
--- a/baseboard/kukui/baseboard.h
+++ b/baseboard/kukui/baseboard.h
@@ -62,6 +62,7 @@
#define CONFIG_CHARGER_SENSE_RESISTOR 10 /* BOARD_RS2 */
#define CONFIG_CHARGER_OTG
#define CONFIG_CHARGE_RAMP_HW
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
/* TCPC FUSB302 */
#define PD_POWER_SUPPLY_TURN_ON_DELAY 160000 /* us */
@@ -195,7 +196,7 @@
#define CONFIG_VBOOT_HASH
#define CONFIG_CHARGER
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 2
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000
#define CONFIG_CHARGER_DISCHARGE_ON_AC
@@ -274,7 +275,6 @@
#undef CONFIG_HIBERNATE
#define CONFIG_SPI_CONTROLLER
-#define CONFIG_STM_HWTIMER32
#define CONFIG_WATCHDOG_HELP
#undef CONFIG_UART_CONSOLE
#define CONFIG_UART_CONSOLE 1
@@ -287,6 +287,7 @@
#define CONFIG_USB_PD_VBUS_DETECT_TCPC
/* Modules we want to exclude */
+#undef CONFIG_ACCEL_SPOOF_MODE
#undef CONFIG_CMD_ACCELSPOOF
#undef CONFIG_CMD_BATTFAKE
#undef CONFIG_CMD_FLASH
@@ -311,14 +312,19 @@
#undef CONFIG_CMD_CRASH
#undef CONFIG_CMD_HCDEBUG
#undef CONFIG_CMD_IDLE_STATS
+#undef CONFIG_CMD_KEYBOARD
#undef CONFIG_CMD_MFALLOW
#undef CONFIG_CMD_MMAPINFO
+#undef CONFIG_CMD_PD
+#undef CONFIG_CMD_POWER_AP
#undef CONFIG_CMD_PWR_AVG
#undef CONFIG_CMD_REGULATOR
#undef CONFIG_CMD_RW
#undef CONFIG_CMD_SLEEPMASK
#undef CONFIG_CMD_SLEEPMASK_SET
+#undef CONFIG_CMD_SYSINFO
#undef CONFIG_CMD_TYPEC
+#undef CONFIG_CMD_WAITMS
#undef CONFIG_HOSTCMD_FLASHPD
#undef CONFIG_HOSTCMD_RWHASHPD
diff --git a/baseboard/kukui/charger_mt6370.c b/baseboard/kukui/charger_mt6370.c
index 398473bfc8..80587745ea 100644
--- a/baseboard/kukui/charger_mt6370.c
+++ b/baseboard/kukui/charger_mt6370.c
@@ -77,7 +77,8 @@ int board_cut_off_battery(void)
static void board_set_charge_limit_throttle(int charge_ma, int charge_mv)
{
charge_set_input_current_limit(
- MIN(throttled_ma, MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT)),
+ MIN(throttled_ma,
+ MAX(charge_ma, CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT)),
charge_mv);
}
@@ -355,8 +356,8 @@ DECLARE_HOOK(HOOK_BATTERY_SOC_CHANGE, board_charge_termination,
HOOK_PRIO_DEFAULT);
#endif
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
prev_charge_limit = charge_ma;
prev_charge_mv = charge_mv;
diff --git a/baseboard/kukui/emmc.c b/baseboard/kukui/emmc.c
index 8731d7259c..416d44c634 100644
--- a/baseboard/kukui/emmc.c
+++ b/baseboard/kukui/emmc.c
@@ -28,6 +28,7 @@
* case we interrupt the transfer, and the BootROM will try again.
*/
+#include "bootblock_data.h"
#include "chipset.h"
#include "clock.h"
#include "console.h"
@@ -41,8 +42,6 @@
#include "timer.h"
#include "util.h"
-#include "bootblock_data.h"
-
#define CPRINTS(format, args...) cprints(CC_SPI, format, ##args)
#define CPRINTF(format, args...) cprintf(CC_SPI, format, ##args)
diff --git a/baseboard/kukui/emmc_ite.c b/baseboard/kukui/emmc_ite.c
index 2767199be0..6ac0200c1d 100644
--- a/baseboard/kukui/emmc_ite.c
+++ b/baseboard/kukui/emmc_ite.c
@@ -3,6 +3,7 @@
* found in the LICENSE file.
*/
+#include "bootblock_data.h"
#include "chipset.h"
#include "console.h"
#include "endian.h"
@@ -15,8 +16,6 @@
#include "timer.h"
#include "util.h"
-#include "bootblock_data.h"
-
#define CPRINTS(format, args...) cprints(CC_SPI, format, ##args)
enum emmc_cmd {
diff --git a/baseboard/nucleo-f412zg/base-board.h b/baseboard/nucleo-f412zg/base-board.h
index 0ce6c226e2..a7bca6067f 100644
--- a/baseboard/nucleo-f412zg/base-board.h
+++ b/baseboard/nucleo-f412zg/base-board.h
@@ -168,7 +168,6 @@
#define CONFIG_RNG
#define CONFIG_SHA256
#define CONFIG_SHA256_UNROLLED
-#define CONFIG_STM_HWTIMER32
#define CONFIG_WP_ACTIVE_HIGH
#ifndef TEST_BUILD
diff --git a/baseboard/nucleo-h743zi/base-board.h b/baseboard/nucleo-h743zi/base-board.h
index eb4b8ac1fa..f86c6dc8d4 100644
--- a/baseboard/nucleo-h743zi/base-board.h
+++ b/baseboard/nucleo-h743zi/base-board.h
@@ -99,7 +99,6 @@
#define CONFIG_SHA256_UNROLLED
#undef CONFIG_SHAREDLIB_SIZE
#define CONFIG_SHAREDLIB_SIZE 0
-#define CONFIG_STM_HWTIMER32
#define CONFIG_WATCHDOG_HELP
#define CONFIG_WP_ACTIVE_HIGH
diff --git a/baseboard/octopus/baseboard.c b/baseboard/octopus/baseboard.c
index 0f012d1352..164e28b480 100644
--- a/baseboard/octopus/baseboard.c
+++ b/baseboard/octopus/baseboard.c
@@ -298,20 +298,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- /*
- * Empirically, the charger seems to draw a little more current that
- * it is set to, so we reduce our limit by 5%.
- */
-#if defined(CONFIG_CHARGER_BQ25710) || defined(CONFIG_CHARGER_ISL9238)
- charge_ma = (charge_ma * 95) / 100;
-#endif
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
void board_hibernate(void)
{
int port;
diff --git a/baseboard/octopus/baseboard.h b/baseboard/octopus/baseboard.h
index 724540d0f0..42093ab771 100644
--- a/baseboard/octopus/baseboard.h
+++ b/baseboard/octopus/baseboard.h
@@ -125,6 +125,8 @@
*/
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
#define CONFIG_EXTPOWER_DEBOUNCE_MS 200
+/* Charger seems to overdraw by about 5% */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#elif defined(VARIANT_OCTOPUS_CHARGER_BQ25703)
#define CONFIG_CHARGER_BQ25703
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
@@ -133,6 +135,8 @@
*/
#undef CONFIG_EXTPOWER_DEBOUNCE_MS
#define CONFIG_EXTPOWER_DEBOUNCE_MS 50
+/* Charger seems to overdraw by about 5% */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#elif defined(CONFIG_CHARGER_RUNTIME_CONFIG)
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_BQ25710
@@ -150,7 +154,9 @@
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER
-#define CONFIG_CHARGER_INPUT_CURRENT 512 /* Allow low-current USB charging */
+/* Allow low-current USB charging */
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_USB_CHARGER
diff --git a/baseboard/octopus/variant_usbc_ec_tcpcs.c b/baseboard/octopus/variant_usbc_ec_tcpcs.c
index 983887bc08..a93dfe3535 100644
--- a/baseboard/octopus/variant_usbc_ec_tcpcs.c
+++ b/baseboard/octopus/variant_usbc_ec_tcpcs.c
@@ -10,10 +10,10 @@
#include "console.h"
#include "driver/ppc/sn5s330.h"
#include "driver/tcpm/it83xx_pd.h"
-#include "driver/usb_mux/it5205.h"
#include "driver/tcpm/ps8xxx.h"
#include "driver/tcpm/tcpci.h"
#include "driver/tcpm/tcpm.h"
+#include "driver/usb_mux/it5205.h"
#include "gpio.h"
#include "hooks.h"
#include "system.h"
diff --git a/baseboard/trogdor/baseboard.h b/baseboard/trogdor/baseboard.h
index 2dedf8f330..28cf467272 100644
--- a/baseboard/trogdor/baseboard.h
+++ b/baseboard/trogdor/baseboard.h
@@ -92,7 +92,8 @@
#define CONFIG_CHARGER_PSYS_READ
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 10000
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
diff --git a/baseboard/volteer/baseboard.c b/baseboard/volteer/baseboard.c
index fd36aef81f..b9f10fd360 100644
--- a/baseboard/volteer/baseboard.c
+++ b/baseboard/volteer/baseboard.c
@@ -7,8 +7,8 @@
#include "adc.h"
#include "button.h"
#include "cbi_ec_fw_config.h"
-#include "charger.h"
#include "charge_ramp.h"
+#include "charger.h"
#include "cros_board_info.h"
#include "driver/charger/isl9241.h"
#include "driver/tcpm/ps8xxx.h"
diff --git a/baseboard/volteer/baseboard.h b/baseboard/volteer/baseboard.h
index 3b8e475fe5..d3c82f0651 100644
--- a/baseboard/volteer/baseboard.h
+++ b/baseboard/volteer/baseboard.h
@@ -107,7 +107,8 @@
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
/*
* Hardware based charge ramp is broken in the ISL9241 (b/169350714).
@@ -243,10 +244,10 @@
#ifndef __ASSEMBLER__
-#include "gpio_signal.h"
-#include "common.h"
#include "baseboard_usbc_config.h"
#include "cbi.h"
+#include "common.h"
+#include "gpio_signal.h"
enum adc_channel {
ADC_TEMP_SENSOR_1_CHARGER,
diff --git a/baseboard/volteer/battery_presence.c b/baseboard/volteer/battery_presence.c
index f143b67c91..d656b7b626 100644
--- a/baseboard/volteer/battery_presence.c
+++ b/baseboard/volteer/battery_presence.c
@@ -6,12 +6,12 @@
* Each board should implement board_battery_info[] to define the specific
* battery packs supported.
*/
-#include <stdbool.h>
-
#include "battery.h"
#include "battery_smart.h"
#include "gpio.h"
+#include <stdbool.h>
+
static enum battery_present batt_pres_prev = BP_NOT_SURE;
enum battery_present battery_hw_present(void)
diff --git a/baseboard/volteer/cbi.h b/baseboard/volteer/cbi.h
index dc940f1edc..4b4044ea3c 100644
--- a/baseboard/volteer/cbi.h
+++ b/baseboard/volteer/cbi.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_BASEBOARD_CBI_H
#define __CROS_EC_BASEBOARD_CBI_H
+#include "common.h"
+
unsigned char get_board_id(void);
/**
diff --git a/baseboard/volteer/cbi_ec_fw_config.c b/baseboard/volteer/cbi_ec_fw_config.c
index 7506278e16..f925498774 100644
--- a/baseboard/volteer/cbi_ec_fw_config.c
+++ b/baseboard/volteer/cbi_ec_fw_config.c
@@ -3,9 +3,9 @@
* found in the LICENSE file.
*/
+#include "cbi_ec_fw_config.h"
#include "common.h"
#include "console.h"
-#include "cbi_ec_fw_config.h"
#include "cros_board_info.h"
#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ##args)
diff --git a/baseboard/volteer/charger.c b/baseboard/volteer/charger.c
index 84fa4e037c..17f1fe5f7d 100644
--- a/baseboard/volteer/charger.c
+++ b/baseboard/volteer/charger.c
@@ -4,10 +4,10 @@
*/
/* Volteer family-specific configuration */
-#include "common.h"
-#include "charger.h"
#include "charge_manager.h"
#include "charge_state.h"
+#include "charger.h"
+#include "common.h"
#include "driver/charger/isl9241_public.h"
#include "gpio.h"
#ifdef CONFIG_ZEPHYR
@@ -80,13 +80,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
void board_overcurrent_event(int port, int is_overcurrented)
{
/* Note that the level is inverted because the pin is active low. */
diff --git a/baseboard/volteer/usb_pd_policy.c b/baseboard/volteer/usb_pd_policy.c
index 81e02b769f..18c24b64ef 100644
--- a/baseboard/volteer/usb_pd_policy.c
+++ b/baseboard/volteer/usb_pd_policy.c
@@ -8,11 +8,11 @@
#include "compile_time_macros.h"
#include "console.h"
#include "gpio.h"
+#include "system.h"
#include "usb_common.h"
#include "usb_mux.h"
-#include "usbc_ppc.h"
#include "usb_pd.h"
-#include "system.h"
+#include "usbc_ppc.h"
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
diff --git a/baseboard/volteer/usbc_config.c b/baseboard/volteer/usbc_config.c
index 001f47e45f..d77e275282 100644
--- a/baseboard/volteer/usbc_config.c
+++ b/baseboard/volteer/usbc_config.c
@@ -5,21 +5,22 @@
/* Volteer family-specific USB-C configuration */
-#include "common.h"
#include "charge_manager.h"
#include "charge_ramp.h"
#include "charge_state.h"
+#include "common.h"
+#include "driver/charger/isl9241_public.h"
#include "gpio.h"
#include "task.h"
+#include "usb_charge.h"
+#include "usb_pd.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
#ifdef CONFIG_ZEPHYR
-#include "usbc_config.h"
#include "baseboard_usbc_config.h"
+#include "usbc_config.h"
#endif
-#include "usbc_ppc.h"
-#include "usb_pd.h"
-#include "usb_charge.h"
-#include "util.h"
-#include "driver/charger/isl9241_public.h"
/******************************************************************************/
void tcpc_alert_event(enum gpio_signal signal)
diff --git a/baseboard/zork/baseboard.c b/baseboard/zork/baseboard.c
index 593bcf1168..dcf16cf7c6 100644
--- a/baseboard/zork/baseboard.c
+++ b/baseboard/zork/baseboard.c
@@ -24,8 +24,8 @@
#include "extpower.h"
#include "gpio.h"
#include "hooks.h"
-#include "ioexpander.h"
#include "i2c.h"
+#include "ioexpander.h"
#include "keyboard_scan.h"
#include "lid_switch.h"
#include "motion_sense.h"
@@ -96,13 +96,6 @@ static void baseboard_chipset_resume(void)
}
DECLARE_HOOK(HOOK_CHIPSET_RESUME, baseboard_chipset_resume, HOOK_PRIO_DEFAULT);
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
/* Keyboard scan setting */
__override struct keyboard_scan_config keyscan_config = {
/*
diff --git a/baseboard/zork/baseboard.h b/baseboard/zork/baseboard.h
index 2289c1891b..c55ca12c76 100644
--- a/baseboard/zork/baseboard.h
+++ b/baseboard/zork/baseboard.h
@@ -76,7 +76,8 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_ISL9241
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
@@ -290,7 +291,6 @@
#ifndef __ASSEMBLER__
#include "gpio_signal.h"
-#include "math_util.h"
#include "registers.h"
enum power_signal {
@@ -318,23 +318,6 @@ enum sensor_id {
SENSOR_COUNT,
};
-/*
- * Matrix to rotate accelerators into the standard reference frame. The default
- * is the identity which is correct for the reference design. Variations of
- * Zork may need to change it for manufacturability.
- * For the lid:
- * +x to the right
- * +y up
- * +z out of the page
- *
- * The principle axes of the body are aligned with the lid when the lid is in
- * the 180 degree position (open, flat).
- *
- * Boards within the Zork family may need to modify this definition at
- * board_init() time.
- */
-extern mat33_fp_t zork_base_standard_ref;
-
extern const struct thermistor_info thermistor_info;
/* Sensors without hardware FIFO are in forced mode */
diff --git a/baseboard/zork/cbi_ec_fw_config.c b/baseboard/zork/cbi_ec_fw_config.c
index 4482a5cf40..555aeab9d7 100644
--- a/baseboard/zork/cbi_ec_fw_config.c
+++ b/baseboard/zork/cbi_ec_fw_config.c
@@ -3,8 +3,8 @@
* found in the LICENSE file.
*/
-#include "common.h"
#include "cbi_ec_fw_config.h"
+#include "common.h"
#include "cros_board_info.h"
/****************************************************************************
diff --git a/baseboard/zork/variant_trembyle.c b/baseboard/zork/variant_trembyle.c
index 9c29e057cc..4542ea562c 100644
--- a/baseboard/zork/variant_trembyle.c
+++ b/baseboard/zork/variant_trembyle.c
@@ -499,7 +499,7 @@ struct usb_mux usbc1_ps8802 = {
const struct usb_mux usbc1_ps8818 = {
.usb_port = USBC_PORT_C1,
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS,
+ .i2c_addr_flags = PS8818_I2C_ADDR0_FLAGS,
.driver = &ps8818_usb_retimer_driver,
.board_set = &board_ps8818_mux_set,
};
diff --git a/board/adlrvpp_mchp1521/board.h b/board/adlrvpp_mchp1521/board.h
index bcd46acf25..645bfc0598 100644
--- a/board/adlrvpp_mchp1521/board.h
+++ b/board/adlrvpp_mchp1521/board.h
@@ -140,6 +140,9 @@
/* Use internal silicon 32KHz oscillator */
#undef CONFIG_CLOCK_SRC_EXTERNAL
+/* Free up flash space. */
+#undef CONFIG_CONSOLE_CMDHELP
+
#ifndef __ASSEMBLER__
enum adlrvp_i2c_channel {
diff --git a/board/agah/charger_isl9241.c b/board/agah/charger_isl9241.c
index 47e8261f78..d5f3d1a0b4 100644
--- a/board/agah/charger_isl9241.c
+++ b/board/agah/charger_isl9241.c
@@ -196,13 +196,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
static const struct charge_port_info bj_power = {
/* 150W (also default) */
.voltage = 19500,
diff --git a/board/agah/usbc_config.c b/board/agah/usbc_config.c
index a8bad0f121..d078ef59ac 100644
--- a/board/agah/usbc_config.c
+++ b/board/agah/usbc_config.c
@@ -149,7 +149,7 @@ const static struct usb_mux_chain usbc2_ps8818 = {
&(const struct usb_mux){
.usb_port = USBC_PORT_C2,
.i2c_port = I2C_PORT_USB_C2_TCPC,
- .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS,
+ .i2c_addr_flags = PS8818_I2C_ADDR0_FLAGS,
.driver = &ps8818_usb_retimer_driver,
.board_set = &board_ps8818_mux_set,
},
diff --git a/board/ambassador/board.c b/board/ambassador/board.c
index f2bc7557ec..3eff9215bc 100644
--- a/board/ambassador/board.c
+++ b/board/ambassador/board.c
@@ -88,8 +88,8 @@ uint16_t tcpc_get_alert_status(void)
}
/* Called when the charge manager has switched to a new port. */
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Blink alert if insufficient power per system_can_boot_ap(). */
int insufficient_power =
diff --git a/board/anahera/board.c b/board/anahera/board.c
index e087d629a7..cd9eb30870 100644
--- a/board/anahera/board.c
+++ b/board/anahera/board.c
@@ -64,15 +64,3 @@ enum battery_present battery_hw_present(void)
/* The GPIO is low when the battery is physically present */
return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES;
}
-
-__override void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- /*
- * Limit the input current to 95% negotiated limit,
- * to account for the charger chip margin.
- */
- charge_ma = charge_ma * 95 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/anahera/board.h b/board/anahera/board.h
index 18360171e3..82ba5a4e1c 100644
--- a/board/anahera/board.h
+++ b/board/anahera/board.h
@@ -33,6 +33,8 @@
#define CONFIG_USB_PORT_POWER_DUMB
#define CONFIG_USBC_RETIMER_PS8811
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
+
/* USB Type C and USB PD defines */
#define CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY
diff --git a/board/anahera/charger.c b/board/anahera/charger.c
index a4fa209246..7fabd2082e 100644
--- a/board/anahera/charger.c
+++ b/board/anahera/charger.c
@@ -81,10 +81,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/atlas/board.c b/board/atlas/board.c
index 6fbbb64b16..d2562d43d3 100644
--- a/board/atlas/board.c
+++ b/board/atlas/board.c
@@ -531,39 +531,15 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-/*
- * Limit the input current to 95% negotiated limit,
- * to account for the charger chip margin.
- */
-
-static int charger_derate(int current)
-{
- return current * 95 / 100;
-}
-
static void board_charger_init(void)
{
- charger_set_input_current_limit(CHARGER_SOLO,
- charger_derate(PD_MAX_CURRENT_MA));
+ charger_set_input_current_limit(
+ CHARGER_SOLO,
+ PD_MAX_CURRENT_MA *
+ (100 - CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT) / 100);
}
DECLARE_HOOK(HOOK_INIT, board_charger_init, HOOK_PRIO_DEFAULT);
-/**
- * Set the charge limit based upon desired maximum.
- *
- * @param port Port number.
- * @param supplier Charge supplier type.
- * @param charge_ma Desired charge limit (mA).
- * @param charge_mv Negotiated charge voltage (mV).
- */
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = charger_derate(charge_ma);
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
static void board_chipset_suspend(void)
{
gpio_set_level(GPIO_KBD_BL_EN, 0);
diff --git a/board/atlas/board.h b/board/atlas/board.h
index 9718ab7cdd..3dbce640bb 100644
--- a/board/atlas/board.h
+++ b/board/atlas/board.h
@@ -77,7 +77,9 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_CHARGER_PSYS
#define CONFIG_CHARGER_PSYS_READ
diff --git a/board/banshee/charger.c b/board/banshee/charger.c
index 88f5b85a41..7a16fcd5cb 100644
--- a/board/banshee/charger.c
+++ b/board/banshee/charger.c
@@ -79,10 +79,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/beadrix/board.c b/board/beadrix/board.c
index 5cea32f90c..24c6cb960e 100644
--- a/board/beadrix/board.c
+++ b/board/beadrix/board.c
@@ -474,19 +474,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-/* Vconn control for integrated ITE TCPC */
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * TODO(b/151955431): Characterize the input current limit in case a
- * scaling needs to be applied here
- */
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > CONFIG_USB_PD_PORT_MAX_COUNT)
diff --git a/board/beetley/board.c b/board/beetley/board.c
index f6b1f1008c..89a1d6b13f 100644
--- a/board/beetley/board.c
+++ b/board/beetley/board.c
@@ -384,19 +384,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/beetley/board.h b/board/beetley/board.h
index a70ee73ebb..b05b8e2eb5 100644
--- a/board/beetley/board.h
+++ b/board/beetley/board.h
@@ -27,6 +27,11 @@
/* Charger */
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER_RAA489000
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
#define PD_MAX_VOLTAGE_MV 20000
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
#define CONFIG_CHARGER_SENSE_RESISTOR 10
diff --git a/board/bellis/board.c b/board/bellis/board.c
index e03ae1c36c..3acdb66e4f 100644
--- a/board/bellis/board.c
+++ b/board/bellis/board.c
@@ -236,14 +236,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/bellis/board.h b/board/bellis/board.h
index d502c4c5ef..0741de5dc7 100644
--- a/board/bellis/board.h
+++ b/board/bellis/board.h
@@ -40,6 +40,7 @@
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_RUNTIME_CONFIG
diff --git a/board/blipper/board.c b/board/blipper/board.c
index 766f55579c..ce1bc27700 100644
--- a/board/blipper/board.c
+++ b/board/blipper/board.c
@@ -536,19 +536,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/blipper/board.h b/board/blipper/board.h
index 379a92a007..896ebec76a 100644
--- a/board/blipper/board.h
+++ b/board/blipper/board.h
@@ -29,6 +29,11 @@
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
/* DAC for PSYS */
#define CONFIG_DAC
diff --git a/board/boten/board.c b/board/boten/board.c
index c47b9e46f0..fc70b11ada 100644
--- a/board/boten/board.c
+++ b/board/boten/board.c
@@ -244,19 +244,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/boten/board.h b/board/boten/board.h
index ec5d25ff9f..2e607f73c1 100644
--- a/board/boten/board.h
+++ b/board/boten/board.h
@@ -32,6 +32,11 @@
*/
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
/* DAC for PSYS */
#define CONFIG_DAC
diff --git a/board/brask/led.c b/board/brask/led.c
index 0a57994ca0..b86a291625 100644
--- a/board/brask/led.c
+++ b/board/brask/led.c
@@ -249,8 +249,8 @@ int led_set_brightness(enum ec_led_id id, const uint8_t *brightness)
else
return set_color(id, LED_OFF, 0);
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Blink alert if insufficient power per system_can_boot_ap(). */
int insufficient_power =
diff --git a/board/brya/charger.c b/board/brya/charger.c
index a4fa209246..7fabd2082e 100644
--- a/board/brya/charger.c
+++ b/board/brya/charger.c
@@ -81,10 +81,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/bugzzy/board.c b/board/bugzzy/board.c
index 5a28fb2c25..443f5f6d2f 100644
--- a/board/bugzzy/board.c
+++ b/board/bugzzy/board.c
@@ -393,19 +393,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/bugzzy/board.h b/board/bugzzy/board.h
index 707314d02a..45bdfdc9f3 100644
--- a/board/bugzzy/board.h
+++ b/board/bugzzy/board.h
@@ -43,6 +43,11 @@
#undef CONFIG_CHARGER_SINGLE_CHIP
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
#define CONFIG_BATTERY_CHECK_CHARGE_TEMP_LIMITS
#define CONFIG_CHARGER_PROFILE_OVERRIDE
@@ -183,6 +188,14 @@
#define CONFIG_TABLET_MODE
#define CONFIG_TABLET_MODE_SWITCH
+/* On-body detection */
+#define CONFIG_BODY_DETECTION
+#define CONFIG_BODY_DETECTION_SENSOR BASE_ACCEL
+#define CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR 150 /* % */
+#define CONFIG_GESTURE_DETECTION
+#define CONFIG_GESTURE_DETECTION_MASK BIT(CONFIG_BODY_DETECTION_SENSOR)
+#define CONFIG_GESTURE_HOST_DETECTION
+
/* LIS2DS Lid accel */
#define CONFIG_ACCEL_LIS2DS
diff --git a/board/burnet/board.c b/board/burnet/board.c
index aa378ca289..a89250ae34 100644
--- a/board/burnet/board.c
+++ b/board/burnet/board.c
@@ -222,14 +222,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/burnet/board.h b/board/burnet/board.h
index 6870ccc2d2..5199ae4aaf 100644
--- a/board/burnet/board.h
+++ b/board/burnet/board.h
@@ -8,6 +8,9 @@
#ifndef __CROS_EC_BOARD_H
#define __CROS_EC_BOARD_H
+/* Free up flash space. */
+#undef CONFIG_CMD_KEYBOARD
+
#define VARIANT_KUKUI_JACUZZI
#define VARIANT_KUKUI_BATTERY_SMART
#define VARIANT_KUKUI_CHARGER_ISL9238
@@ -28,6 +31,7 @@
#define CONFIG_BATTERY_COUNT 1
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_BC12_DETECT_PI3USB9201
diff --git a/board/c2d2/board.h b/board/c2d2/board.h
index 6b1ac69efd..c1b450f482 100644
--- a/board/c2d2/board.h
+++ b/board/c2d2/board.h
@@ -34,7 +34,6 @@
#undef CONFIG_UART_RX_DMA
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_HW_CRC
/* USB Configuration */
diff --git a/board/cappy2/board.c b/board/cappy2/board.c
index de651ac874..7956ae77f5 100644
--- a/board/cappy2/board.c
+++ b/board/cappy2/board.c
@@ -229,19 +229,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/cappy2/board.h b/board/cappy2/board.h
index b21a20d6e5..8f503b1bcc 100644
--- a/board/cappy2/board.h
+++ b/board/cappy2/board.h
@@ -39,6 +39,11 @@
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
/* Keyboard */
#undef CONFIG_PWM_KBLIGHT
diff --git a/board/casta/board.c b/board/casta/board.c
index 512a7c224b..2ae65c7d86 100644
--- a/board/casta/board.c
+++ b/board/casta/board.c
@@ -172,7 +172,8 @@ static void set_input_limit_on_ac_removal(void)
if (get_cbi_ssfc_charger() != SSFC_CHARGER_BQ25710)
return;
- charger_set_input_current_limit(0, CONFIG_CHARGER_INPUT_CURRENT);
+ charger_set_input_current_limit(0,
+ CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT);
}
DECLARE_HOOK(HOOK_AC_CHANGE, set_input_limit_on_ac_removal, HOOK_PRIO_DEFAULT);
diff --git a/board/cerise/board.c b/board/cerise/board.c
index e3fa60c76a..9b214f2dae 100644
--- a/board/cerise/board.c
+++ b/board/cerise/board.c
@@ -236,14 +236,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/cerise/board.h b/board/cerise/board.h
index 41d86b956d..d2c58e9f6e 100644
--- a/board/cerise/board.h
+++ b/board/cerise/board.h
@@ -28,6 +28,7 @@
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_RUNTIME_CONFIG
diff --git a/board/cherry/board.c b/board/cherry/board.c
index c2ad54acb2..f8700404ed 100644
--- a/board/cherry/board.c
+++ b/board/cherry/board.c
@@ -262,13 +262,6 @@ const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
/* Initialize board. */
static void board_init(void)
{
diff --git a/board/chocodile_vpdmcu/board.h b/board/chocodile_vpdmcu/board.h
index ede07dd9a0..0e0ff70ab8 100644
--- a/board/chocodile_vpdmcu/board.h
+++ b/board/chocodile_vpdmcu/board.h
@@ -55,7 +55,6 @@
#undef CONFIG_LID_SWITCH
#define CONFIG_LOW_POWER_IDLE
#define CONFIG_LTO
-#define CONFIG_STM_HWTIMER32
#undef CONFIG_TASK_PROFILING
#undef CONFIG_UART_TX_BUF_SIZE
#undef CONFIG_UART_TX_DMA
@@ -72,6 +71,7 @@
#define CONFIG_USB_PD_DECODE_SOP
#define CONFIG_USB_PD_DUAL_ROLE
#define CONFIG_USB_PD_INTERNAL_COMP
+#undef CONFIG_USB_DPM_SM
#define CONFIG_VBOOT_HASH
#define CONFIG_WATCHDOG
#undef CONFIG_WATCHDOG_HELP
diff --git a/board/coachz/board.c b/board/coachz/board.c
index 1e1ed2ab71..4863cd94c9 100644
--- a/board/coachz/board.c
+++ b/board/coachz/board.c
@@ -513,6 +513,7 @@ void board_tcpc_init(void)
/* Enable PPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -683,8 +684,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -696,9 +697,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_ma = charge_ma * 95 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/coachz/board.h b/board/coachz/board.h
index c332b98c34..70594d3efa 100644
--- a/board/coachz/board.h
+++ b/board/coachz/board.h
@@ -40,6 +40,8 @@
#define CONFIG_BATTERY_FUEL_GAUGE
#define CONFIG_BATTERY_VENDOR_PARAM
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
+
/* BC 1.2 Charger */
#define CONFIG_BC12_DETECT_PI3USB9201
diff --git a/board/coffeecake/board.h b/board/coffeecake/board.h
index 966a5b2516..9c7a2643d0 100644
--- a/board/coffeecake/board.h
+++ b/board/coffeecake/board.h
@@ -18,7 +18,6 @@
#define CONFIG_UART_CONSOLE 1
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_ADC
#define CONFIG_BOARD_PRE_INIT
#define CONFIG_CMD_CHARGER
diff --git a/board/coral/board.c b/board/coral/board.c
index c63a2f6ddc..a2a99ed42b 100644
--- a/board/coral/board.c
+++ b/board/coral/board.c
@@ -554,8 +554,8 @@ int board_set_active_charge_port(int charge_port)
* @param charge_ma Desired charge limit (mA).
* @param charge_mv Negotiated charge voltage (mV).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Enable charging trigger by BC1.2 detection */
int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP ||
@@ -566,9 +566,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
if (bd9995x_bc12_enable_charging(port, bc12_enable))
return;
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
/**
diff --git a/board/coral/board.h b/board/coral/board.h
index bc6226152c..cea83ef4a5 100644
--- a/board/coral/board.h
+++ b/board/coral/board.h
@@ -25,6 +25,7 @@
#define CONFIG_CMD_CHARGER_ADC_AMON_BMON
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define BD9995X_IOUT_GAIN_SELECT \
BD9995X_CMD_PMON_IOUT_CTRL_SET_IOUT_GAIN_SET_20V
@@ -59,7 +60,8 @@
#define CONFIG_CHARGER_BD9995X
#define CONFIG_CHARGER_BD9995X_CHGEN
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_MAINTAIN_VBAT
#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
diff --git a/board/corori/board.c b/board/corori/board.c
index 4fe1e01fec..52ef76a19c 100644
--- a/board/corori/board.c
+++ b/board/corori/board.c
@@ -311,19 +311,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/corori/board.h b/board/corori/board.h
index 75e0e4eec6..646b14227d 100644
--- a/board/corori/board.h
+++ b/board/corori/board.h
@@ -28,6 +28,11 @@
#undef CONFIG_CMD_CHARGER_DUMP
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
/* LED defines */
#define CONFIG_LED_COMMON
diff --git a/board/corori2/board.c b/board/corori2/board.c
index efebc3af2e..e3103f65ff 100644
--- a/board/corori2/board.c
+++ b/board/corori2/board.c
@@ -454,19 +454,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/corori2/board.h b/board/corori2/board.h
index 3483d96f88..c62cade1c3 100644
--- a/board/corori2/board.h
+++ b/board/corori2/board.h
@@ -20,6 +20,7 @@
/* Save some flash space */
#define CONFIG_CHIP_INIT_ROM_REGION
#undef CONFIG_CONSOLE_CMDHELP
+#undef CONFIG_CONSOLE_HISTORY
#define CONFIG_DEBUG_ASSERT_BRIEF
#define CONFIG_USB_PD_DEBUG_LEVEL 0
@@ -30,6 +31,8 @@
#undef CONFIG_CMD_ACCELSPOOF
#undef CONFIG_CMD_BATTFAKE
#undef CONFIG_CMD_GETTIME
+#undef CONFIG_CMD_I2C_SCAN
+#undef CONFIG_CMD_I2C_XFER
#undef CONFIG_CMD_MEM
/* Battery */
@@ -47,6 +50,11 @@
#undef CONFIG_CHARGER_SINGLE_CHIP
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
/*
* GPIO for C1 interrupts, for baseboard use
diff --git a/board/cret/board.c b/board/cret/board.c
index c9c34d6d32..3c56757ef7 100644
--- a/board/cret/board.c
+++ b/board/cret/board.c
@@ -304,19 +304,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/cret/board.h b/board/cret/board.h
index 2080185c7c..eb6b261cdf 100644
--- a/board/cret/board.h
+++ b/board/cret/board.h
@@ -34,6 +34,11 @@
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CHARGING_CURRENT_1100MA 1100
diff --git a/board/crota/board.c b/board/crota/board.c
index cb3e79ee56..a12ef75d30 100644
--- a/board/crota/board.c
+++ b/board/crota/board.c
@@ -51,7 +51,7 @@ static void board_chipset_suspend(void)
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
-static bool board_is_convertible(void)
+bool board_is_convertible(void)
{
/*
* convertible = 0
diff --git a/board/crota/board.h b/board/crota/board.h
index 3d79e190bd..d652a93ad0 100644
--- a/board/crota/board.h
+++ b/board/crota/board.h
@@ -288,6 +288,8 @@ enum thermal_cfg_table { LAPTOP_MODE, TABLET_MODE, THERMAL_CFG_TABLE_COUNT };
void motion_interrupt(enum gpio_signal signal);
+bool board_is_convertible(void);
+
#endif /* !__ASSEMBLER__ */
#endif /* __CROS_EC_BOARD_H */
diff --git a/board/crota/charger.c b/board/crota/charger.c
index c7dcf7b0c1..9f044790e0 100644
--- a/board/crota/charger.c
+++ b/board/crota/charger.c
@@ -79,10 +79,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/crota/sensors.c b/board/crota/sensors.c
index 79d2492060..7d60234dc3 100644
--- a/board/crota/sensors.c
+++ b/board/crota/sensors.c
@@ -10,9 +10,11 @@
#include "driver/accel_lis2dw12.h"
#include "driver/accelgyro_bmi_common.h"
#include "driver/accelgyro_lsm6dso.h"
+#include "fw_config.h"
#include "gpio.h"
#include "hooks.h"
#include "motion_sense.h"
+#include "tablet_mode.h"
#include "temp_sensor.h"
#include "thermal.h"
#include "temp_sensor/thermistor.h"
@@ -209,10 +211,29 @@ static void board_update_motion_sensor_config(void)
} else {
ccprints("BASE IMU is LSM6DSO");
}
+
+ if (!board_is_convertible()) {
+ tablet_set_mode(0, TABLET_TRIGGER_LID);
+ gmr_tablet_switch_disable();
+ /* Make sure tablet mode detection is not trigger by mistake. */
+ gpio_set_flags(GPIO_TABLET_MODE_L, GPIO_INPUT | GPIO_PULL_UP);
+ /*
+ * Make sure we don't even try to initialize the lid accel, it
+ * is not present.
+ */
+ motion_sensors[LID_ACCEL].active_mask = 0;
+ gpio_set_flags(GPIO_EC_ACCEL_INT_R_L,
+ GPIO_INPUT | GPIO_PULL_UP);
+ }
}
DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_update_motion_sensor_config,
HOOK_PRIO_INIT_I2C + 1);
+__override int sensor_board_is_lid_angle_available(void)
+{
+ return board_is_convertible();
+}
+
static void baseboard_sensors_init(void)
{
/* Enable gpio interrupt for lid accel sensor */
diff --git a/board/damu/board.c b/board/damu/board.c
index ddc8885e22..717276e768 100644
--- a/board/damu/board.c
+++ b/board/damu/board.c
@@ -236,14 +236,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/damu/board.h b/board/damu/board.h
index 49875e6883..16e03cf45c 100644
--- a/board/damu/board.h
+++ b/board/damu/board.h
@@ -28,6 +28,7 @@
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_RUNTIME_CONFIG
diff --git a/board/dibbi/board.c b/board/dibbi/board.c
new file mode 100644
index 0000000000..9b3207859a
--- /dev/null
+++ b/board/dibbi/board.c
@@ -0,0 +1,374 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Dibbi board-specific configuration */
+
+#include "adc_chip.h"
+#include "button.h"
+#include "charge_manager.h"
+#include "charge_state_v2.h"
+#include "charger.h"
+#include "driver/temp_sensor/thermistor.h"
+#include "driver/tcpm/it83xx_pd.h"
+#include "driver/usb_mux/it5205.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "intc.h"
+#include "power.h"
+#include "power_button.h"
+#include "pwm.h"
+#include "pwm_chip.h"
+#include "switch.h"
+#include "system.h"
+#include "tablet_mode.h"
+#include "task.h"
+#include "tcpm/tcpci.h"
+#include "temp_sensor.h"
+#include "uart.h"
+#include "usb_charge.h"
+#include "usb_mux.h"
+#include "usb_pd.h"
+#include "usb_pd_tcpm.h"
+
+#define CPRINTUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+
+/* ADC channels */
+const struct adc_t adc_channels[] = {
+ [ADC_VSNS_PP3300_A] = { .name = "PP3300_A_PGOOD",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH0 },
+ [ADC_TEMP_SENSOR_1] = { .name = "TEMP_SENSOR1",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH2 },
+ [ADC_TEMP_SENSOR_2] = { .name = "TEMP_SENSOR2",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH3 },
+ [ADC_PPVAR_PWR_IN_IMON] = { .name = "ADC_PPVAR_PWR_IN_IMON",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH15 },
+ [ADC_SNS_PPVAR_PWR_IN] = { .name = "ADC_SNS_PPVAR_PWR_IN",
+ .factor_mul = ADC_MAX_MVOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ .channel = CHIP_ADC_CH16 },
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
+/* TCPCs */
+const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+ {
+ .bus_type = EC_BUS_TYPE_EMBEDDED,
+ .drv = &it83xx_tcpm_drv,
+ },
+};
+
+/* USB Muxes */
+const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+ {
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = 0,
+ .i2c_port = I2C_PORT_USB_C0,
+ .i2c_addr_flags = IT5205_I2C_ADDR1_FLAGS,
+ .driver = &it5205_usb_mux_driver,
+ },
+ },
+};
+
+/* USB-A ports */
+const int usb_port_enable[USB_PORT_COUNT] = {
+ GPIO_EN_USB_A0_VBUS,
+ GPIO_EN_USB_A1_VBUS,
+ GPIO_EN_USB_A2_VBUS,
+};
+
+/* PWM channels. Must be in the exactly same order as in enum pwm_channel. */
+const struct pwm_t pwm_channels[] = {
+ [PWM_CH_LED_RED] = {
+ .channel = 1,
+ .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
+ .freq_hz = 2400,
+ },
+
+ [PWM_CH_LED_GREEN] = {
+ .channel = 2,
+ .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
+ .freq_hz = 2400,
+ },
+
+ [PWM_CH_LED_BLUE] = {
+ .channel = 3,
+ .flags = PWM_CONFIG_DSLEEP | PWM_CONFIG_ACTIVE_LOW,
+ .freq_hz = 2400,
+ }
+
+};
+BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+
+/* Thermistors */
+const struct temp_sensor_t temp_sensors[] = {
+ [TEMP_SENSOR_1] = { .name = "Memory",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_1 },
+ [TEMP_SENSOR_2] = { .name = "Ambient",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_51k1_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_2 },
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+
+static void c0_ccsbu_ovp_interrupt(enum gpio_signal s)
+{
+ cprints(CC_USBPD, "C0: CC OVP, SBU OVP, or thermal event");
+ pd_handle_cc_overvoltage(0);
+}
+
+void board_init(void)
+{
+ int on;
+
+ gpio_enable_interrupt(GPIO_USB_C0_CCSBU_OVP_ODL);
+ gpio_enable_interrupt(GPIO_BJ_ADP_PRESENT_L);
+ gpio_enable_interrupt(GPIO_USBC_ADP_PRESENT_L);
+
+ /* Turn on 5V if the system is on, otherwise turn it off */
+ on = chipset_in_state(CHIPSET_STATE_ON | CHIPSET_STATE_ANY_SUSPEND |
+ CHIPSET_STATE_SOFT_OFF);
+ board_power_5v_enable(on);
+}
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+
+void board_reset_pd_mcu(void)
+{
+ /*
+ * Nothing to do. TCPC C0 is internal.
+ */
+}
+
+__override void board_power_5v_enable(int enable)
+{
+ /*
+ * Mainboard 5V regulator activated by GPIO.
+ * USB-A ports are activated by usb_port_power_dumb.
+ */
+ gpio_set_level(GPIO_EN_PP5000, !!enable);
+}
+
+void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
+ int charge_mv)
+{
+ int insufficient_power =
+ (charge_ma * charge_mv) <
+ (CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON * 1000);
+ /* TODO(b/259467280) blink LED on error */
+ (void)insufficient_power;
+}
+
+int board_vbus_source_enabled(int port)
+{
+ if (port != CHARGE_PORT_TYPEC0)
+ return 0;
+ return gpio_get_level(GPIO_EN_USB_C0_VBUS);
+}
+
+/* Vconn control for integrated ITE TCPC */
+void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
+{
+ /* Vconn control is only for port 0 */
+ if (port)
+ return;
+
+ if (cc_pin == USBPD_CC_PIN_1)
+ gpio_set_level(GPIO_EN_USB_C0_CC1_VCONN, !!enabled);
+ else
+ gpio_set_level(GPIO_EN_USB_C0_CC2_VCONN, !!enabled);
+}
+
+__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ int ilim3A;
+
+ if (port < 0 || port > CONFIG_USB_PD_PORT_MAX_COUNT)
+ return;
+
+ /* Switch between 1.5A and 3A ILIM values */
+ ilim3A = (rp == TYPEC_RP_3A0);
+ gpio_set_level(GPIO_USB_C0_VBUS_ILIM, ilim3A);
+}
+
+/******************************************************************************/
+/*
+ * Since dibbi has no battery, it must source all of its power from either
+ * USB-C or the barrel jack (preferred). Fizz operates in continuous safe
+ * mode (charge_manager_leave_safe_mode() will never be called), which
+ * modifies port selection as follows:
+ *
+ * - Dual-role / dedicated capability of the port partner is ignored.
+ * - Charge ceiling on PD voltage transition is ignored.
+ * - CHARGE_PORT_NONE will never be selected.
+ */
+
+/* List of BJ adapters */
+enum bj_adapter {
+ BJ_NONE,
+ BJ_65W_19V,
+};
+
+/* Barrel-jack power adapter ratings. */
+static const struct charge_port_info bj_adapters[] = {
+ [BJ_NONE] = { .current = 0, .voltage = 0 },
+ [BJ_65W_19V] = { .current = 3420, .voltage = 19000 },
+};
+#define BJ_ADP_RATING_DEFAULT BJ_65W_19V /* BJ power ratings default */
+#define ADP_DEBOUNCE_MS 1000 /* Debounce time for BJ plug/unplug */
+
+/* Debounced connection state of the barrel jack */
+static int8_t bj_adp_connected = -1;
+static void adp_connect_deferred(void)
+{
+ const struct charge_port_info *pi;
+ int connected = !gpio_get_level(GPIO_BJ_ADP_PRESENT_L);
+
+ /* Debounce */
+ if (connected == bj_adp_connected)
+ return;
+
+ if (connected) {
+ pi = &bj_adapters[BJ_ADP_RATING_DEFAULT];
+ } else {
+ /* No barrel-jack, zero out this power supply */
+ pi = &bj_adapters[BJ_NONE];
+ }
+ /* This will result in a call to board_set_active_charge_port */
+ charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED,
+ DEDICATED_CHARGE_PORT, pi);
+ bj_adp_connected = connected;
+}
+DECLARE_DEFERRED(adp_connect_deferred);
+
+/* IRQ for BJ plug/unplug. It shouldn't be called if BJ is the power source. */
+void adp_connect_interrupt(enum gpio_signal signal)
+{
+ hook_call_deferred(&adp_connect_deferred_data, ADP_DEBOUNCE_MS * MSEC);
+}
+
+/* IRQ for USB-C plug/unplug. */
+void usbc_connect_interrupt(enum gpio_signal signal)
+{
+ task_wake(TASK_ID_PD_C0);
+}
+
+int board_set_active_charge_port(int port)
+{
+ const int active_port = charge_manager_get_active_charge_port();
+
+ CPRINTUSB("Requested charge port change to %d", port);
+
+ if (port < 0 || CHARGE_PORT_COUNT <= port)
+ return EC_ERROR_INVAL;
+
+ if (port == active_port)
+ return EC_SUCCESS;
+
+ /* Don't sink from a source port */
+ if (board_vbus_source_enabled(port))
+ return EC_ERROR_INVAL;
+
+ if (!chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
+ int bj_requested;
+
+ if (charge_manager_get_active_charge_port() != CHARGE_PORT_NONE)
+ /* Change is only permitted while the system is off */
+ return EC_ERROR_INVAL;
+
+ /*
+ * Current setting is no charge port but the AP is on, so the
+ * charge manager is out of sync (probably because we're
+ * reinitializing after sysjump). Reject requests that aren't
+ * in sync with our outputs.
+ */
+ bj_requested = port == CHARGE_PORT_BARRELJACK;
+ if (bj_adp_connected != bj_requested)
+ return EC_ERROR_INVAL;
+ }
+
+ CPRINTUSB("New charger p%d", port);
+
+ switch (port) {
+ case CHARGE_PORT_TYPEC0:
+ gpio_set_level(GPIO_EN_PPVAR_USBC_ADP_L, 0);
+ gpio_set_level(GPIO_EN_PPVAR_BJ_ADP_L, 1);
+ gpio_enable_interrupt(GPIO_BJ_ADP_PRESENT_L);
+ break;
+ case CHARGE_PORT_BARRELJACK:
+ /* Make sure BJ adapter is sourcing power */
+ if (gpio_get_level(GPIO_BJ_ADP_PRESENT_L))
+ return EC_ERROR_INVAL;
+ gpio_set_level(GPIO_EN_PPVAR_BJ_ADP_L, 0);
+ gpio_set_level(GPIO_EN_PPVAR_USBC_ADP_L, 1);
+ gpio_disable_interrupt(GPIO_BJ_ADP_PRESENT_L);
+ break;
+ default:
+ return EC_ERROR_INVAL;
+ }
+
+ return EC_SUCCESS;
+}
+
+static void board_charge_manager_init(void)
+{
+ enum charge_port port;
+
+ /*
+ * Initialize all charge suppliers to 0. The charge manager waits until
+ * all ports have reported in before doing anything.
+ */
+ for (int i = 0; i < CHARGE_PORT_COUNT; i++) {
+ for (int j = 0; j < CHARGE_SUPPLIER_COUNT; j++)
+ charge_manager_update_charge(j, i, NULL);
+ }
+
+ port = gpio_get_level(GPIO_BJ_ADP_PRESENT_L) ? CHARGE_PORT_TYPEC0 :
+ CHARGE_PORT_BARRELJACK;
+ CPRINTUSB("Power source is p%d (%s)", port,
+ port == CHARGE_PORT_TYPEC0 ? "USB-C" : "BJ");
+
+ /* Initialize the power source supplier */
+ switch (port) {
+ case CHARGE_PORT_TYPEC0:
+ typec_set_input_current_limit(port, 3000, 5000);
+ break;
+ case CHARGE_PORT_BARRELJACK:
+ charge_manager_update_charge(
+ CHARGE_SUPPLIER_DEDICATED, DEDICATED_CHARGE_PORT,
+ &bj_adapters[BJ_ADP_RATING_DEFAULT]);
+ break;
+ }
+
+ /* Report charge state from the barrel jack. */
+ adp_connect_deferred();
+}
+DECLARE_HOOK(HOOK_INIT, board_charge_manager_init,
+ HOOK_PRIO_INIT_CHARGE_MANAGER + 1);
+
+__override int extpower_is_present(void)
+{
+ /*
+ * There's no battery, so running this method implies we have power.
+ */
+ return 1;
+}
+
+/* Must come after other header files and interrupt handler declarations */
+#include "gpio_list.h"
diff --git a/board/dibbi/board.h b/board/dibbi/board.h
new file mode 100644
index 0000000000..c59a540b5d
--- /dev/null
+++ b/board/dibbi/board.h
@@ -0,0 +1,145 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Dibbi board configuration */
+
+#ifndef __CROS_EC_BOARD_H
+#define __CROS_EC_BOARD_H
+
+/* Select Baseboard features */
+#define VARIANT_DEDEDE_EC_IT8320
+#include "baseboard.h"
+
+/* System unlocked in early development */
+#define CONFIG_SYSTEM_UNLOCKED
+
+#define CONFIG_CMD_CHARGER_DUMP
+
+/* Power */
+#undef CONFIG_CHARGER
+#undef CONFIG_CHARGER_DISCHARGE_ON_AC
+#undef CONFIG_USB_PD_VBUS_MEASURE_CHARGER
+#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 16000
+#define PD_MAX_VOLTAGE_MV 15000
+#define CONFIG_USB_PD_VBUS_DETECT_GPIO
+/* ADC sensors could measure VBUS on this board, but components are DNS */
+#define CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT
+
+/* Override macro for C0 only */
+#define PORT_TO_HPD(port) (GPIO_USB_C0_DP_HPD)
+
+/* Power: Dedicated barreljack charger port */
+#undef CONFIG_DEDICATED_CHARGE_PORT_COUNT
+#define CONFIG_DEDICATED_CHARGE_PORT_COUNT 1
+#define DEDICATED_CHARGE_PORT 1
+
+/* USB Type-C */
+#undef CONFIG_USB_CHARGER
+#undef CONFIG_USB_MUX_PI3USB31532
+
+/* TCPC */
+#define CONFIG_USB_PD_PORT_MAX_COUNT 1
+#define CONFIG_USB_PD_TCPM_ITE_ON_CHIP /* C0: ITE EC TCPC */
+#define CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT 1
+
+/* USB Mux and Retimer */
+#define CONFIG_USB_MUX_IT5205 /* C0: ITE Mux */
+#define I2C_PORT_USB_MUX I2C_PORT_USB_C0 /* Required for ITE Mux */
+
+/* USB Type A Features */
+#define CONFIG_USB_PORT_POWER_DUMB
+#define USB_PORT_COUNT 3 /* Type A ports */
+
+/* No battery */
+#undef CONFIG_BATTERY_CUT_OFF
+#undef CONFIG_BATTERY_PRESENT_GPIO
+#undef CONFIG_BATTERY_REQUESTS_NIL_WHEN_DEAD
+#undef CONFIG_BATTERY_REVIVE_DISCONNECT
+#undef CONFIG_BATTERY_SMART
+
+/* LED */
+/* TODO(b/259467280) Determine what LED/PWM impl is needed*/
+/* #define CONFIG_LED_PWM */
+/* #define CONFIG_LED_PWM_COUNT 1 */
+
+/* PWM */
+#define CONFIG_PWM
+
+/* Thermistors */
+#define CONFIG_TEMP_SENSOR
+#define CONFIG_THERMISTOR
+#define CONFIG_STEINHART_HART_3V3_51K1_47K_4050B
+
+/* Buttons */
+#define CONFIG_DEDICATED_RECOVERY_BUTTON
+#define CONFIG_DEDICATED_RECOVERY_BUTTON_2
+#define CONFIG_POWER_BUTTON
+#define CONFIG_POWER_BUTTON_IGNORE_LID
+#define CONFIG_POWER_BUTTON_X86
+
+/* No Keyboard */
+#undef CONFIG_MKBP_EVENT
+#undef CONFIG_MKBP_EVENT_WAKEUP_MASK
+#undef CONFIG_MKBP_USE_GPIO_AND_HOST_EVENT
+#undef CONFIG_KEYBOARD_COL2_INVERTED
+#undef CONFIG_KEYBOARD_PROTOCOL_8042
+#undef CONFIG_MKBP_INPUT_DEVICES
+#undef CONFIG_CMD_KEYBOARD
+#undef CONFIG_KEYBOARD_BOOT_KEYS
+#undef CONFIG_KEYBOARD_RUNTIME_KEYS
+
+/* No backlight */
+#undef CONFIG_BACKLIGHT_LID
+#undef GPIO_ENABLE_BACKLIGHT
+
+/* Unused features - Misc */
+#undef CONFIG_HIBERNATE
+#undef CONFIG_VOLUME_BUTTONS
+#undef CONFIG_LID_SWITCH
+#undef CONFIG_TABLET_MODE
+#undef CONFIG_TABLET_MODE_SWITCH
+#undef CONFIG_GMR_TABLET_MODE
+#undef GPIO_TABLET_MODE_L
+
+/* Unused GPIOs */
+#undef GPIO_USB_C1_DP_HPD
+
+/* Pin renaming */
+#define GPIO_RECOVERY_L GPIO_EC_RECOVERY_BTN_ODL
+#define GPIO_RECOVERY_L_2 GPIO_H1_EC_RECOVERY_BTN_ODL
+#define GPIO_POWER_BUTTON_L GPIO_H1_EC_PWR_BTN_ODL
+
+#ifndef __ASSEMBLER__
+
+#include "gpio_signal.h"
+#include "registers.h"
+
+enum charge_port {
+ CHARGE_PORT_TYPEC0,
+ CHARGE_PORT_BARRELJACK,
+};
+
+enum pwm_channel {
+ PWM_CH_LED_RED,
+ PWM_CH_LED_GREEN,
+ PWM_CH_LED_BLUE,
+ PWM_CH_COUNT,
+};
+
+/* ADC channels */
+enum adc_channel {
+ ADC_VSNS_PP3300_A, /* ADC0 */
+ ADC_TEMP_SENSOR_1, /* ADC2 */
+ ADC_TEMP_SENSOR_2, /* ADC3 */
+ ADC_PPVAR_PWR_IN_IMON, /* ADC15 */
+ ADC_SNS_PPVAR_PWR_IN, /* ADC16 */
+ ADC_CH_COUNT
+};
+
+enum temp_sensor_id { TEMP_SENSOR_1, TEMP_SENSOR_2, TEMP_SENSOR_COUNT };
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* __CROS_EC_BOARD_H */
diff --git a/board/dibbi/build.mk b/board/dibbi/build.mk
new file mode 100644
index 0000000000..07ea50c392
--- /dev/null
+++ b/board/dibbi/build.mk
@@ -0,0 +1,14 @@
+# -*- makefile -*-
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Board specific files build
+#
+
+CHIP:=it83xx
+CHIP_FAMILY:=it8320
+CHIP_VARIANT:=it8320dx
+BASEBOARD:=dedede
+
+board-y=board.o led.o usb_pd_policy.o
diff --git a/board/dibbi/ec.tasklist b/board/dibbi/ec.tasklist
new file mode 100644
index 0000000000..768c31112a
--- /dev/null
+++ b/board/dibbi/ec.tasklist
@@ -0,0 +1,16 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+ * See CONFIG_TASK_LIST in config.h for details.
+ */
+
+#define CONFIG_TASK_LIST \
+ TASK_ALWAYS(HOOKS, hook_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_NOTEST(CHIPSET, chipset_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_ALWAYS(POWERBTN, power_button_task, NULL, ULTRA_TASK_STACK_SIZE) \
+ TASK_ALWAYS(PD_C0, pd_task, NULL, ULTRA_TASK_STACK_SIZE)
diff --git a/board/dibbi/gpio.inc b/board/dibbi/gpio.inc
new file mode 100644
index 0000000000..a5c0c02a72
--- /dev/null
+++ b/board/dibbi/gpio.inc
@@ -0,0 +1,142 @@
+/* -*- mode:c -*-
+ *
+ * Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Declare symbolic names for all the GPIOs that we care about.
+ * Note: Those with interrupt handlers must be declared first. */
+
+/* Power State interrupts */
+GPIO_INT(SLP_S4_L, PIN(I, 5), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(SLP_S3_L, PIN(H, 3), GPIO_INT_BOTH, baseboard_all_sys_pgood_interrupt)
+GPIO_INT(SLP_S0_L, PIN(E, 4), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(SLP_SUS_L, PIN(G, 2), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(VCCIN_AUX_VID0, PIN(D, 0), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(RSMRST_PWRGD_L, PIN(E, 1), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(CPU_C10_GATE_L, PIN(G, 1), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(PG_DRAM_OD, PIN(D, 3), GPIO_INT_BOTH, baseboard_all_sys_pgood_interrupt)
+GPIO_INT(PG_PP1050_ST_OD, PIN(L, 1), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(VCCIN_AUX_VID1, PIN(K, 1), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(PG_VCCIO_EXT_OD, PIN(D, 7), GPIO_INT_BOTH, baseboard_all_sys_pgood_interrupt)
+GPIO_INT(ESPI_RESET_L, PIN(D, 2), GPIO_INT_FALLING | GPIO_SEL_1P8V, espi_reset_pin_asserted_interrupt)
+
+GPIO_INT(H1_EC_PWR_BTN_ODL, PIN(E, 2), GPIO_INT_BOTH | GPIO_PULL_UP, power_button_interrupt)
+#ifdef CONFIG_LOW_POWER_IDLE
+/* Used to wake up the EC from Deep Doze mode when writing to console */
+GPIO_INT(UART1_RX, PIN(B, 0), GPIO_INT_BOTH, uart_deepsleep_interrupt) /* UART_DBG_TX_EC_RX */
+#endif
+
+/* USB-C interrupts */
+GPIO_INT(USB_C0_CCSBU_OVP_ODL, PIN(K, 6), GPIO_INT_FALLING | GPIO_PULL_UP, c0_ccsbu_ovp_interrupt) /* Fault protection */
+
+/* Other interrupts */
+GPIO_INT(EC_WP_OD, PIN(A, 6), GPIO_INT_BOTH, switch_interrupt)
+/* Directly connected recovery button */
+GPIO_INT(EC_RECOVERY_BTN_ODL, PIN(K, 7), GPIO_INT_BOTH, button_interrupt)
+/* Recovery button input from H1 */
+GPIO_INT(H1_EC_RECOVERY_BTN_ODL, PIN(K, 4), GPIO_INT_BOTH, button_interrupt)
+GPIO_INT(BJ_ADP_PRESENT_L, PIN(A, 7), GPIO_INT_BOTH | GPIO_PULL_UP, adp_connect_interrupt)
+GPIO_INT(USBC_ADP_PRESENT_L, PIN(K, 3), GPIO_INT_BOTH | GPIO_PULL_UP, usbc_connect_interrupt)
+
+/* Power sequence GPIOs */
+GPIO(EC_AP_RTCRST, PIN(K, 2), GPIO_OUT_LOW)
+GPIO(EC_AP_PWR_BTN_ODL, PIN(B, 6), GPIO_ODR_HIGH)
+GPIO(EC_AP_DPWROK, PIN(L, 7), GPIO_OUT_LOW)
+GPIO(EC_AP_RSMRST_L, PIN(H, 0), GPIO_OUT_LOW)
+GPIO(EC_AP_WAKE_ODL, PIN(D, 5), GPIO_ODR_HIGH)
+GPIO(SYS_RST_ODL, PIN(D, 1), GPIO_ODR_HIGH)
+GPIO(EC_AP_SYS_PWROK, PIN(F, 2), GPIO_OUT_LOW)
+GPIO(PG_PP5000_U_OD, PIN(E, 3), GPIO_INPUT)
+GPIO(EN_PP3300_A, PIN(C, 5), GPIO_OUT_LOW)
+GPIO(EC_AP_PCH_PWROK_OD, PIN(D, 6), GPIO_ODR_LOW)
+GPIO(EN_PP5000_U, PIN(K, 5), GPIO_OUT_LOW)
+/* TODO(b:149775160) - Modify if needed if we ever use this signal. */
+GPIO(EN_VCCST, PIN(D, 4), GPIO_INPUT)
+GPIO(EN_VCCIO_EXT, PIN(B, 2), GPIO_OUT_LOW)
+GPIO(EC_PROCHOT_ODL, PIN(I, 1), GPIO_ODR_HIGH | GPIO_SEL_1P8V)
+GPIO(EC_AP_VCCST_PWRGD_OD, PIN(E, 5), GPIO_ODR_LOW)
+GPIO(ALL_SYS_PWRGD, PIN(B, 7), GPIO_OUT_LOW)
+GPIO(EN_PPVAR_BJ_ADP_L, PIN(J, 0), GPIO_OUT_LOW)
+GPIO(EN_PPVAR_USBC_ADP_L, PIN(J, 1), GPIO_OUT_LOW)
+GPIO(EN_USB_C0_VBUS, PIN(I, 7), GPIO_OUT_LOW)
+GPIO(USB_C0_VBUS_ILIM, PIN(I, 6), GPIO_OUT_LOW)
+
+/* Required for icelake chipset code, but implemented through other means for dedede */
+UNIMPLEMENTED(AC_PRESENT)
+UNIMPLEMENTED(PG_EC_DSW_PWROK)
+UNIMPLEMENTED(PG_EC_ALL_SYS_PWRGD)
+
+/* Required for dedede baseboard but not used in dibbi */
+UNIMPLEMENTED(USB_C0_INT_ODL)
+UNIMPLEMENTED(EN_SLP_Z)
+
+/* I2C pins - Alternate function below configures I2C module on these pins */
+GPIO(EC_I2C_EEPROM_SCL, PIN(B, 3), GPIO_INPUT)
+GPIO(EC_I2C_EEPROM_SDA, PIN(B, 4), GPIO_INPUT)
+GPIO(EC_I2C_BATTERY_SCL, PIN(C, 1), GPIO_INPUT)
+GPIO(EC_I2C_BATTERY_SDA, PIN(C, 2), GPIO_INPUT)
+GPIO(EC_I2C_SENSOR_SCL, PIN(F, 6), GPIO_INPUT | GPIO_SEL_1P8V)
+GPIO(EC_I2C_SENSOR_SDA, PIN(F, 7), GPIO_INPUT | GPIO_SEL_1P8V)
+GPIO(EC_I2C_USB_C0_SCL, PIN(A, 4), GPIO_INPUT)
+GPIO(EC_I2C_USB_C0_SDA, PIN(A, 5), GPIO_INPUT)
+
+/* USB pins */
+GPIO(EN_USB_C0_CC1_VCONN, PIN(H, 4), GPIO_OUT_LOW)
+GPIO(EN_USB_C0_CC2_VCONN, PIN(H, 6), GPIO_OUT_LOW)
+GPIO(EC_AP_USB_C0_HPD, PIN(L, 4), GPIO_OUT_LOW)
+GPIO(EN_USB_A0_VBUS, PIN(L, 6), GPIO_OUT_LOW)
+GPIO(EN_USB_A1_VBUS, PIN(C, 6), GPIO_OUT_LOW)
+GPIO(EN_USB_A2_VBUS, PIN(C, 4), GPIO_OUT_LOW)
+
+/* MKBP event synchronization */
+/* TODO(b/257833880) Check whether this pin is needed */
+GPIO(EC_AP_MKBP_INT_L, PIN(L, 5), GPIO_ODR_HIGH)
+
+/* Misc pins which will run to the I/O board */
+GPIO(EC_SUB_IO_1_1, PIN(L, 3), GPIO_INPUT)
+GPIO(EC_SUB_IO_1_2, PIN(F, 0), GPIO_INPUT)
+GPIO(EC_SUB_IO_2_1, PIN(F, 1), GPIO_INPUT)
+GPIO(EC_SUB_IO_2_2, PIN(L, 2), GPIO_INPUT)
+
+/* Misc */
+GPIO(EC_ENTERING_RW, PIN(G, 0), GPIO_OUT_LOW)
+GPIO(CCD_MODE_ODL, PIN(H, 5), GPIO_ODR_HIGH)
+GPIO(EC_BATTERY_PRES_ODL, PIN(I, 4), GPIO_INPUT)
+GPIO(ECH1_PACKET_MODE, PIN(H, 1), GPIO_OUT_LOW)
+
+
+/* NC pins, enable internal pull-down to avoid floating state. */
+GPIO(GPIOC0_NC, PIN(C, 0), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOC3_NC, PIN(C, 3), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOG3_NC, PIN(G, 3), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOG4_NC, PIN(G, 4), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOG5_NC, PIN(G, 5), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOG6_NC, PIN(G, 6), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOG7_NC, PIN(G, 7), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOJ4_NC, PIN(J, 4), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOJ5_NC, PIN(J, 5), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOJ6_NC, PIN(J, 6), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOK0_NC, PIN(K, 0), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOL0_NC, PIN(L, 0), GPIO_INPUT | GPIO_PULL_DOWN)
+GPIO(GPIOM6_NC, PIN(M, 6), GPIO_INPUT | GPIO_PULL_DOWN)
+/* TODO(b/257833880) add any new unused pins */
+
+/* Alternate functions GPIO definitions */
+/* UART */
+ALTERNATE(PIN_MASK(B, BIT(0) | BIT(1)), 0, MODULE_UART, 0) /* UART for debug */
+
+/* I2C */
+ALTERNATE(PIN_MASK(B, BIT(3) | BIT(4)), 0, MODULE_I2C, 0) /* I2C0 */
+ALTERNATE(PIN_MASK(C, BIT(1) | BIT(2)), 0, MODULE_I2C, 0) /* I2C1 */
+ALTERNATE(PIN_MASK(F, BIT(6) | BIT(7)), 0, MODULE_I2C, GPIO_SEL_1P8V) /* I2C2 - 1.8V */
+ALTERNATE(PIN_MASK(E, BIT(0) | BIT(7)), 0, MODULE_I2C, 0) /* I2C4 */
+ALTERNATE(PIN_MASK(A, BIT(4) | BIT(5)), 0, MODULE_I2C, 0) /* I2C5 */
+
+/* ADC */
+ALTERNATE(PIN_MASK(I, BIT(0) | BIT(2) | BIT(3)), 0, MODULE_ADC, 0) /* ADC0: EC_VSNS_PP3300_A, ADC2: TEMP_SENSOR_1, ADC3: TEMP_SENSOR_2 */
+ALTERNATE(PIN_MASK(L, BIT(2) | BIT(3)), 0, MODULE_ADC, 0) /* ADC15: PPVAR_PWR_IN_IMON, ADC16: SNS_PPVAR_PWR_IN */
+
+/* PWM */
+ALTERNATE(PIN_MASK(A, BIT(1) | BIT(2) | BIT(3)), 0, MODULE_PWM, 0) /* LED_[R,G,B]_ODL */
diff --git a/board/dibbi/led.c b/board/dibbi/led.c
new file mode 100644
index 0000000000..44cfc0b457
--- /dev/null
+++ b/board/dibbi/led.c
@@ -0,0 +1,38 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Dibbi specific PWM LED settings. */
+
+#include "common.h"
+#include "ec_commands.h"
+#include "pwm.h"
+#include "util.h"
+
+/* TODO(b/259467280) Implement LED logic */
+
+const enum ec_led_id supported_led_ids[] = {
+ EC_LED_ID_POWER_LED,
+};
+const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
+
+void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
+{
+ /* TODO(b/259467280) check this implementation */
+ memset(brightness_range, '\0',
+ sizeof(*brightness_range) * EC_LED_COLOR_COUNT);
+ brightness_range[EC_LED_COLOR_RED] = 100;
+ brightness_range[EC_LED_COLOR_GREEN] = 100;
+ brightness_range[EC_LED_COLOR_BLUE] = 100;
+ brightness_range[EC_LED_COLOR_YELLOW] = 100;
+ brightness_range[EC_LED_COLOR_WHITE] = 100;
+ brightness_range[EC_LED_COLOR_AMBER] = 100;
+}
+
+int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
+{
+ /* TODO(b/259467280) fix this implementation */
+
+ return EC_SUCCESS;
+}
diff --git a/board/dibbi/usb_pd_policy.c b/board/dibbi/usb_pd_policy.c
new file mode 100644
index 0000000000..9d573b9c61
--- /dev/null
+++ b/board/dibbi/usb_pd_policy.c
@@ -0,0 +1,69 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_manager.h"
+#include "charger.h"
+#include "chipset.h"
+#include "common.h"
+#include "console.h"
+#include "driver/tcpm/tcpci.h"
+#include "gpio.h"
+#include "usb_pd.h"
+
+#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
+
+__override int pd_check_power_swap(int port)
+{
+ /* If type-c port is supplying power, we never swap PR (to source) */
+ if (port == charge_manager_get_active_charge_port())
+ return 0;
+ /*
+ * Allow power swap as long as we are acting as a dual role device,
+ * otherwise assume our role is fixed (not in S0 or console command
+ * to fix our role).
+ */
+ return (pd_get_dual_role(port) == PD_DRP_TOGGLE_ON ? 1 : 0);
+}
+
+int pd_check_vconn_swap(int port)
+{
+ /* Allow VCONN swaps if the AP is on */
+ return gpio_get_level(GPIO_EN_PP5000_U);
+}
+
+void pd_power_supply_reset(int port)
+{
+ if (port < 0 || port >= board_get_usb_pd_port_count())
+ return;
+
+ /* Disable VBUS source */
+ gpio_set_level(GPIO_EN_USB_C0_VBUS, 0);
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ /* Disable charging */
+ gpio_set_level(GPIO_EN_PPVAR_USBC_ADP_L, 1);
+
+ /* Enable VBUS source */
+ gpio_set_level(GPIO_EN_USB_C0_VBUS, 1);
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
+}
+
+__override int pd_snk_is_vbus_provided(int port)
+{
+ if (port != CHARGE_PORT_TYPEC0)
+ return 0;
+
+ return gpio_get_level(GPIO_USBC_ADP_PRESENT_L);
+}
diff --git a/board/dibbi/vif_override.xml b/board/dibbi/vif_override.xml
new file mode 100644
index 0000000000..32736caf64
--- /dev/null
+++ b/board/dibbi/vif_override.xml
@@ -0,0 +1,3 @@
+<!-- Add VIF field overrides here. See genvif.c and the Vendor Info File
+ Definition from the USB-IF.
+-->
diff --git a/board/dingdong/board.h b/board/dingdong/board.h
index c0372c9322..52c3b740e4 100644
--- a/board/dingdong/board.h
+++ b/board/dingdong/board.h
@@ -15,7 +15,6 @@
#define CONFIG_UART_CONSOLE 1
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_ADC
#define CONFIG_BOARD_PRE_INIT
#define CONFIG_HW_CRC
diff --git a/board/discovery-stm32f072/board.h b/board/discovery-stm32f072/board.h
index d5db803b65..b112f14f9f 100644
--- a/board/discovery-stm32f072/board.h
+++ b/board/discovery-stm32f072/board.h
@@ -23,7 +23,6 @@
#define CONFIG_UART_CONSOLE 2
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_HW_CRC
/* USB Configuration */
diff --git a/board/discovery/board.h b/board/discovery/board.h
index e348454af1..a722408e81 100644
--- a/board/discovery/board.h
+++ b/board/discovery/board.h
@@ -25,9 +25,14 @@
#ifndef __ASSEMBLER__
-/* Timer selection */
-#define TIM_CLOCK_MSB 3
-#define TIM_CLOCK_LSB 4
+/* Timer selection
+ *
+ * "discovery" is an STM32L152RC, which is a "Category 3" product that
+ * has the 32-bit timer TIM5. See Section 17 "General-purpose Timers" and
+ * "Table 3. STM32L15xxx product categories":
+ * https://www.st.com/resource/en/reference_manual/cd00240193-stm32l100xx-stm32l151xx-stm32l152xx-and-stm32l162xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf
+ */
+#define TIM_CLOCK32 5
#include "gpio_signal.h"
diff --git a/board/dojo/board.c b/board/dojo/board.c
index 62f2e6ac09..5c7db8b443 100644
--- a/board/dojo/board.c
+++ b/board/dojo/board.c
@@ -467,14 +467,13 @@ const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
},
};
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Limit input current lower than 2944 mA for safety */
charge_ma = MIN(charge_ma, 2944);
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
/* NVME */
diff --git a/board/dooly/board.c b/board/dooly/board.c
index 6e1f6ebbeb..9652de72c0 100644
--- a/board/dooly/board.c
+++ b/board/dooly/board.c
@@ -323,8 +323,8 @@ uint16_t tcpc_get_alert_status(void)
}
/* Called when the charge manager has switched to a new port. */
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Blink alert if insufficient power per system_can_boot_ap(). */
int insufficient_power =
diff --git a/board/drawcia/board.c b/board/drawcia/board.c
index 118b3178be..58def569be 100644
--- a/board/drawcia/board.c
+++ b/board/drawcia/board.c
@@ -610,19 +610,17 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
/* Limit C1 on board version 0 to 2.0 A */
if ((board_version == 0) && (port == 1))
- icl = MIN(icl, 2000);
+ charge_ma = MIN(charge_ma, 2000);
/*
* TODO(b/151955431): Characterize the input current limit in case a
* scaling needs to be applied here
*/
- charge_set_input_current_limit(icl, charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
int board_set_active_charge_port(int port)
diff --git a/board/drawcia_riscv/board.c b/board/drawcia_riscv/board.c
index cbc977d64b..ba325aedc6 100644
--- a/board/drawcia_riscv/board.c
+++ b/board/drawcia_riscv/board.c
@@ -542,19 +542,17 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
/* Limit C1 on board version 0 to 2.0 A */
if ((board_version == 0) && (port == 1))
- icl = MIN(icl, 2000);
+ charge_ma = MIN(charge_ma, 2000);
/*
* TODO(b/151955431): Characterize the input current limit in case a
* scaling needs to be applied here
*/
- charge_set_input_current_limit(icl, charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
int board_set_active_charge_port(int port)
diff --git a/board/driblee/board.c b/board/driblee/board.c
index 30075e683e..05ec708ac5 100644
--- a/board/driblee/board.c
+++ b/board/driblee/board.c
@@ -338,19 +338,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/driblee/board.h b/board/driblee/board.h
index f6a3ac9130..514fe584ff 100644
--- a/board/driblee/board.h
+++ b/board/driblee/board.h
@@ -31,6 +31,11 @@
#undef CONFIG_CMD_CHARGER_DUMP
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
#define CONFIG_MATH_UTIL
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CHARGING_CURRENT_1100MA 1100
diff --git a/board/drobit/board.c b/board/drobit/board.c
index 1a20870d1f..1d881d9a2c 100644
--- a/board/drobit/board.c
+++ b/board/drobit/board.c
@@ -475,17 +475,3 @@ static void board_chipset_suspend(void)
gpio_set_level(GPIO_EC_KB_BL_EN, 0);
}
DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
-
-/******************************************************************************/
-/* Set the charge limit based upon desired maximum. */
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- /*
- * Limit the input current to 98% negotiated limit,
- * to account for the charger chip margin.
- */
- charge_ma = charge_ma * 98 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/drobit/board.h b/board/drobit/board.h
index d6fda98f3d..bf3e64ae5a 100644
--- a/board/drobit/board.h
+++ b/board/drobit/board.h
@@ -89,6 +89,7 @@
/* charger defines */
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 2
/*
* Macros for GPIO signals used in common code that don't match the
diff --git a/board/eldrid/board.c b/board/eldrid/board.c
index 81fdf22ffc..1abf9c6acd 100644
--- a/board/eldrid/board.c
+++ b/board/eldrid/board.c
@@ -182,14 +182,7 @@ __override void board_set_charge_limit(int port, int supplier, int charge_ma,
else
isl9241_set_ac_prochot(0, 3328);
- /*
- * Follow OEM request to limit the input current to
- * 90% negotiated limit.
- */
- charge_ma = charge_ma * 90 / 100;
-
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
/******************************************************************************/
diff --git a/board/eldrid/board.h b/board/eldrid/board.h
index 1bbe183425..8cfac4d8bc 100644
--- a/board/eldrid/board.h
+++ b/board/eldrid/board.h
@@ -93,6 +93,8 @@
/* charger defines */
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+/* OEM requested 10% derating */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 10
/* Retimer */
#undef CONFIG_USBC_RETIMER_INTEL_BB
diff --git a/board/elm/board.c b/board/elm/board.c
index 4007d34379..f8621d086e 100644
--- a/board/elm/board.c
+++ b/board/elm/board.c
@@ -337,13 +337,10 @@ int board_set_active_charge_port(int charge_port)
* @param charge_ma Desired charge limit (mA).
* @param charge_mv Negotiated charge voltage (mV).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
- /* Limit input current 95% ratio on elm board for safety */
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
pd_send_host_event(PD_EVENT_POWER_CHANGE);
}
diff --git a/board/elm/board.h b/board/elm/board.h
index 10cb6bb75d..6e4e705604 100644
--- a/board/elm/board.h
+++ b/board/elm/board.h
@@ -37,13 +37,15 @@
#define CONFIG_BATTERY_SMART
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGE_RAMP_HW
#define CONFIG_CHARGER_ISL9237
#define CONFIG_CHARGER_MAX_INPUT_CURRENT 3000
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
#define CONFIG_CHARGER_DISCHARGE_ON_AC
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHIPSET_MT817X
#define CONFIG_CMD_TYPEC
#define CONFIG_EXTPOWER_GPIO
@@ -73,7 +75,6 @@
#define CONFIG_USB_CHARGER
#define CONFIG_SPI
#define CONFIG_SPI_CONTROLLER
-#define CONFIG_STM_HWTIMER32
#define CONFIG_VBOOT_HASH
#undef CONFIG_WATCHDOG_HELP
#define CONFIG_SWITCH
diff --git a/board/eve/board.c b/board/eve/board.c
index 3f5da1a83a..96534f62c7 100644
--- a/board/eve/board.c
+++ b/board/eve/board.c
@@ -634,8 +634,8 @@ int board_set_active_charge_port(int charge_port)
* @param charge_ma Desired charge limit (mA).
* @param charge_mv Negotiated charge voltage (mV).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Enable charging trigger by BC1.2 detection */
int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP ||
@@ -646,9 +646,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
if (bd9995x_bc12_enable_charging(port, bc12_enable))
return;
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
/**
diff --git a/board/eve/board.h b/board/eve/board.h
index 064bce4b60..e3623979c3 100644
--- a/board/eve/board.h
+++ b/board/eve/board.h
@@ -100,7 +100,9 @@
#define CONFIG_CHARGER_BD9995X
#define CONFIG_CHARGER_BD9995X_CHGEN
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_MAINTAIN_VBAT
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_CHARGER_PSYS_READ
diff --git a/board/ezkinil/board.c b/board/ezkinil/board.c
index c9e1aca267..5e15b458cc 100644
--- a/board/ezkinil/board.c
+++ b/board/ezkinil/board.c
@@ -865,16 +865,3 @@ int fan_percent_to_rpm(int fan, int pct)
return fan_table[current_level].rpm;
}
-
-__override void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- /*
- * Limit the input current to 95% negotiated limit,
- * to account for the charger chip margin.
- */
- charge_ma = charge_ma * 95 / 100;
-
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/ezkinil/board.h b/board/ezkinil/board.h
index aa1fe065f4..c5e6ce1771 100644
--- a/board/ezkinil/board.h
+++ b/board/ezkinil/board.h
@@ -15,6 +15,9 @@
#define CONFIG_KEYBOARD_FACTORY_TEST
+/* charger margin */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
+
/* Motion sensing drivers */
#define CONFIG_ACCELGYRO_ICM426XX
#define CONFIG_ACCELGYRO_ICM426XX_INT_EVENT \
diff --git a/board/felwinter/board.h b/board/felwinter/board.h
index 17e1cf9246..0ca6a59b9c 100644
--- a/board/felwinter/board.h
+++ b/board/felwinter/board.h
@@ -179,6 +179,7 @@
#define CONFIG_CHARGE_RAMP_SW
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 10
#define CONFIG_KEYBOARD_REFRESH_ROW3
diff --git a/board/felwinter/charger_isl9241.c b/board/felwinter/charger_isl9241.c
index dd2535ea7c..95227f753a 100644
--- a/board/felwinter/charger_isl9241.c
+++ b/board/felwinter/charger_isl9241.c
@@ -79,11 +79,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_ma = (charge_ma * 90) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/fennel/board.c b/board/fennel/board.c
index 563f680dee..6d864252b6 100644
--- a/board/fennel/board.c
+++ b/board/fennel/board.c
@@ -237,14 +237,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/fennel/board.h b/board/fennel/board.h
index 6bb90ef0f3..42e1fcd451 100644
--- a/board/fennel/board.h
+++ b/board/fennel/board.h
@@ -26,6 +26,7 @@
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_RUNTIME_CONFIG
diff --git a/board/fizz/board.c b/board/fizz/board.c
index f58083c6ed..296ddca5a7 100644
--- a/board/fizz/board.c
+++ b/board/fizz/board.c
@@ -512,8 +512,8 @@ static void set_charge_limit(int charge_ma)
}
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
int p87w = 0, p65w = 0, p60w = 0;
diff --git a/board/fluffy/board.h b/board/fluffy/board.h
index 1309c41901..604e67d9b8 100644
--- a/board/fluffy/board.h
+++ b/board/fluffy/board.h
@@ -38,7 +38,6 @@
#define USB_EP_COUNT 2
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_ADC
#define CONFIG_I2C
diff --git a/board/fusb307bgevb/board.h b/board/fusb307bgevb/board.h
index 5e45b346b7..8d2fdfcfed 100644
--- a/board/fusb307bgevb/board.h
+++ b/board/fusb307bgevb/board.h
@@ -29,7 +29,6 @@
#define CONFIG_UART_CONSOLE 2
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_HW_CRC
#define CONFIG_I2C
#define CONFIG_I2C_CONTROLLER
diff --git a/board/gaelin/board.c b/board/gaelin/board.c
index 6fad328a76..7228c9e2f2 100644
--- a/board/gaelin/board.c
+++ b/board/gaelin/board.c
@@ -17,7 +17,6 @@
#include "gpio_signal.h"
#include "power_button.h"
#include "hooks.h"
-#include "peripheral_charger.h"
#include "power.h"
#include "switch.h"
#include "throttle_ap.h"
@@ -41,33 +40,6 @@ const int usb_port_enable[USB_PORT_COUNT] = {
};
BUILD_ASSERT(ARRAY_SIZE(usb_port_enable) == USB_PORT_COUNT);
-extern struct pchg_drv cps8100_drv;
-struct pchg pchgs[] = {
- [0] = {
- .cfg = &(const struct pchg_config) {
- .drv = &cps8100_drv,
- .i2c_port = I2C_PORT_QI,
- .irq_pin = GPIO_QI_INT_ODL,
- .full_percent = 96,
- .block_size = 128,
- },
- .policy = {
- [PCHG_CHIPSET_STATE_ON] = &pchg_policy_on,
- [PCHG_CHIPSET_STATE_SUSPEND] = &pchg_policy_suspend,
- },
- .events = QUEUE_NULL(PCHG_EVENT_QUEUE_SIZE, enum pchg_event),
- },
-};
-const int pchg_count = ARRAY_SIZE(pchgs);
-
-__override void board_pchg_power_on(int port, bool on)
-{
- if (port == 0)
- gpio_set_level(GPIO_EC_QI_PWR, on);
- else
- CPRINTS("%s: Invalid port=%d", __func__, port);
-}
-
/******************************************************************************/
int board_set_active_charge_port(int port)
@@ -118,7 +90,6 @@ int board_set_active_charge_port(int port)
switch (port) {
case CHARGE_PORT_TYPEC0:
case CHARGE_PORT_TYPEC1:
- case CHARGE_PORT_TYPEC2:
gpio_set_level(GPIO_EN_PPVAR_BJ_ADP_L, 1);
break;
case CHARGE_PORT_BARRELJACK:
@@ -293,6 +264,7 @@ void board_overcurrent_event(int port, int is_overcurrented)
usbc_overcurrent = is_overcurrented;
update_5v_usage();
}
+
/*
* Power monitoring and management.
*
@@ -336,7 +308,6 @@ void board_overcurrent_event(int port, int is_overcurrented)
#define THROT_TYPE_A_REAR BIT(1)
#define THROT_TYPE_C0 BIT(2)
#define THROT_TYPE_C1 BIT(3)
-#define THROT_TYPE_C2 BIT(4)
#define THROT_PROCHOT BIT(5)
/*
@@ -471,16 +442,6 @@ static void power_monitor(void)
gap += POWER_GAIN_TYPE_C;
}
/*
- * If the type-C port is sourcing power,
- * check whether it should be throttled.
- */
- if (ppc_is_sourcing_vbus(2) && gap <= 0) {
- new_state |= THROT_TYPE_C2;
- headroom_5v_z1 += PWR_Z1_C_HIGH - PWR_Z1_C_LOW;
- if (!(current_state & THROT_TYPE_C2))
- gap += POWER_GAIN_TYPE_C;
- }
- /*
* As a last resort, turn on PROCHOT to
* throttle the CPU.
*/
@@ -570,15 +531,6 @@ static void power_monitor(void)
tcpm_select_rp_value(1, rp);
pd_update_contract(1);
}
- if (diff & THROT_TYPE_C2) {
- enum tcpc_rp_value rp = (new_state & THROT_TYPE_C2) ?
- TYPEC_RP_1A5 :
- TYPEC_RP_3A0;
-
- ppc_set_vbus_source_current_limit(2, rp);
- tcpm_select_rp_value(2, rp);
- pd_update_contract(2);
- }
if (diff & THROT_TYPE_A_REAR) {
int typea_bc = (new_state & THROT_TYPE_A_REAR) ? 1 : 0;
diff --git a/board/gaelin/board.h b/board/gaelin/board.h
index f113c6cffd..166f0f1432 100644
--- a/board/gaelin/board.h
+++ b/board/gaelin/board.h
@@ -16,7 +16,7 @@
#define CONFIG_MP2964
/* Barrel Jack */
-#define DEDICATED_CHARGE_PORT 3
+#define DEDICATED_CHARGE_PORT 2
/* HDMI CEC */
#define CONFIG_CEC
@@ -31,19 +31,9 @@
/* USB Type C and USB PD defines */
#define CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY
-#define CONFIG_IO_EXPANDER
-#define CONFIG_IO_EXPANDER_NCT38XX
-#define CONFIG_IO_EXPANDER_PORT_COUNT 2
-
#define CONFIG_USB_PD_PPC
-#define CONFIG_USB_PD_TCPM_RT1715
-#define CONFIG_USBC_RETIMER_INTEL_BB
-
-#define CONFIG_USBC_RETIMER_KB800X
-#define CONFIG_KB800X_CUSTOM_XBAR
-#define CONFIG_USBC_PPC_SYV682X
-#undef CONFIG_SYV682X_HV_ILIM
-#define CONFIG_SYV682X_HV_ILIM SYV682X_HV_ILIM_5_50
+#define CONFIG_USB_PD_TCPM_PS8815
+#define CONFIG_USBC_PPC_NX20P3483 /* Compatible with Silicon Mitus SM5360A */
/* TODO: b/177608416 - measure and check these values on brya */
#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
@@ -92,22 +82,17 @@
#define GPIO_RECOVERY_L_2 GPIO_GSC_EC_RECOVERY_BTN_OD
/* I2C Bus Configuration */
+#define I2C_PORT_SCALER NPCX_I2C_PORT5_0
-#define I2C_PORT_DP_REDRIVER NPCX_I2C_PORT0_0
-
-#define I2C_PORT_USB_C0_C2_TCPC NPCX_I2C_PORT1_0
+#define I2C_PORT_USB_C0_TCPC NPCX_I2C_PORT1_0
#define I2C_PORT_USB_C1_TCPC NPCX_I2C_PORT4_1
-#define I2C_PORT_USB_C0_C2_PPC NPCX_I2C_PORT2_0
-#define I2C_PORT_USB_C1_PPC NPCX_I2C_PORT6_1
+#define I2C_PORT_USB_C0_PPC NPCX_I2C_PORT2_0
+#define I2C_PORT_USB_C1_PPC NPCX_I2C_PORT3_0
-#define I2C_PORT_USB_C0_C2_BC12 NPCX_I2C_PORT2_0
-#define I2C_PORT_USB_C1_BC12 NPCX_I2C_PORT6_1
+#define I2C_PORT_USB_C0_BC12 NPCX_I2C_PORT2_0
+#define I2C_PORT_USB_C1_BC12 NPCX_I2C_PORT3_0
-#define I2C_PORT_USB_C0_C2_MUX NPCX_I2C_PORT3_0
-#define I2C_PORT_USB_C1_MUX NPCX_I2C_PORT6_1
-
-#define I2C_PORT_QI NPCX_I2C_PORT5_0
#define I2C_PORT_EEPROM NPCX_I2C_PORT7_0
#define I2C_PORT_MP2964 NPCX_I2C_PORT7_0
@@ -115,17 +100,7 @@
#define I2C_ADDR_MP2964_FLAGS 0x20
-#define USBC_PORT_C0_BB_RETIMER_I2C_ADDR 0x58
-#define USBC_PORT_C2_BB_RETIMER_I2C_ADDR 0x59
-
-/* Enabling Thunderbolt-compatible mode */
-#define CONFIG_USB_PD_TBT_COMPAT_MODE
-
-/* Enabling USB4 mode */
-#define CONFIG_USB_PD_USB4
-
-/* Retimer */
-#define CONFIG_USBC_RETIMER_FW_UPDATE
+#define I2C_ADDR_SCALER_FLAGS 0x58
/* Thermal features */
#define CONFIG_THERMISTOR
@@ -136,21 +111,14 @@
/* ADC */
#define CONFIG_ADC
-/*
- * TODO(b/197478860): Enable the fan control. We need
- * to check the sensor value and adjust the fan speed.
- */
+/* Fan */
#define CONFIG_FANS FAN_CH_COUNT
+#define RPM_DEVIATION 1
+#define CONFIG_CUSTOM_FAN_CONTROL
/* Include math_util for bitmask_uint64 used in pd_timers */
#define CONFIG_MATH_UTIL
-/* WPC/Qi charger */
-#ifdef SECTION_IS_RW
-#define CONFIG_PERIPHERAL_CHARGER
-#define CONFIG_CPS8100
-#endif
-
#ifndef __ASSEMBLER__
#include "gpio_signal.h" /* needed by registers.h */
@@ -160,7 +128,6 @@
enum charge_port {
CHARGE_PORT_TYPEC0,
CHARGE_PORT_TYPEC1,
- CHARGE_PORT_TYPEC2,
CHARGE_PORT_BARRELJACK,
CHARGE_PORT_ENUM_COUNT
};
@@ -183,8 +150,6 @@ enum temp_sensor_id {
TEMP_SENSOR_COUNT
};
-enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_C2_NCT38XX, IOEX_PORT_COUNT };
-
enum pwm_channel {
PWM_CH_LED_GREEN, /* PWM0 */
PWM_CH_FAN, /* PWM5 */
diff --git a/board/gaelin/build.mk b/board/gaelin/build.mk
index 3de758d1bd..6961fb3f60 100644
--- a/board/gaelin/build.mk
+++ b/board/gaelin/build.mk
@@ -19,4 +19,5 @@ board-y+=i2c.o
board-y+=led.o
board-y+=pwm.o
board-y+=sensors.o
+board-y+=thermal.o
board-y+=usbc_config.o
diff --git a/board/gaelin/ec.tasklist b/board/gaelin/ec.tasklist
index d16fc35f52..4a40f332e8 100644
--- a/board/gaelin/ec.tasklist
+++ b/board/gaelin/ec.tasklist
@@ -12,10 +12,8 @@
#define CONFIG_TASK_LIST \
TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \
- TASK_ALWAYS_RW(PCHG, pchg_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(USB_CHG_P0, usb_charger_task, 0, TASK_STACK_SIZE) \
TASK_ALWAYS(USB_CHG_P1, usb_charger_task, 0, TASK_STACK_SIZE) \
- TASK_ALWAYS(USB_CHG_P2, usb_charger_task, 0, TASK_STACK_SIZE) \
TASK_NOTEST(CHIPSET, chipset_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(USB_MUX, usb_mux_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \
@@ -23,7 +21,6 @@
TASK_ALWAYS(POWERBTN, power_button_task, NULL, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(PD_C0, pd_task, NULL, VENTI_TASK_STACK_SIZE) \
TASK_ALWAYS(PD_C1, pd_task, NULL, VENTI_TASK_STACK_SIZE) \
- TASK_ALWAYS(PD_C2, pd_task, NULL, VENTI_TASK_STACK_SIZE) \
- TASK_ALWAYS(PD_INT_C0, pd_shared_alert_task, (BIT(2) | BIT(0)), LARGER_TASK_STACK_SIZE) \
+ TASK_ALWAYS(PD_INT_C0, pd_interrupt_handler_task, 0, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(PD_INT_C1, pd_interrupt_handler_task, 1, LARGER_TASK_STACK_SIZE) \
TASK_ALWAYS(CEC, cec_task, NULL, LARGER_TASK_STACK_SIZE)
diff --git a/board/gaelin/fans.c b/board/gaelin/fans.c
index 6828438a10..5f54e6e63c 100644
--- a/board/gaelin/fans.c
+++ b/board/gaelin/fans.c
@@ -30,16 +30,10 @@ static const struct fan_conf fan_conf_0 = {
.enable_gpio = GPIO_EN_PP5000_FAN,
};
-/*
- * TOOD(b/197478860): need to update for real fan
- *
- * Prototype fan spins at about 7200 RPM at 100% PWM.
- * Set minimum at around 30% PWM.
- */
static const struct fan_rpm fan_rpm_0 = {
- .rpm_min = 2200,
- .rpm_start = 2200,
- .rpm_max = 7200,
+ .rpm_min = 2350,
+ .rpm_start = 2350,
+ .rpm_max = 4100,
};
const struct fan_t fans[FAN_CH_COUNT] = {
diff --git a/board/gaelin/gpio.inc b/board/gaelin/gpio.inc
index 51cf0010c6..6de7003743 100644
--- a/board/gaelin/gpio.inc
+++ b/board/gaelin/gpio.inc
@@ -18,15 +18,11 @@ GPIO_INT(SLP_S3_L, PIN(A, 5), GPIO_INT_BOTH, power_signal_inte
GPIO_INT(SLP_SUS_L, PIN(F, 1), GPIO_INT_BOTH, power_signal_interrupt)
GPIO_INT(SYS_SLP_S0IX_L, PIN(D, 5), GPIO_INT_BOTH, power_signal_interrupt)
GPIO_INT(USB_C0_BC12_INT_ODL, PIN(C, 6), GPIO_INT_FALLING, bc12_interrupt)
-GPIO_INT(USB_C0_C2_TCPC_INT_ODL, PIN(E, 0), GPIO_INT_FALLING, tcpc_alert_event)
+GPIO_INT(USB_C0_TCPC_INT_ODL, PIN(E, 0), GPIO_INT_FALLING, tcpc_alert_event)
GPIO_INT(USB_C0_PPC_INT_ODL, PIN(6, 2), GPIO_INT_FALLING, ppc_interrupt)
-GPIO_INT(USB_C0_RT_INT_ODL, PIN(B, 1), GPIO_INT_FALLING, retimer_interrupt)
GPIO_INT(USB_C1_BC12_INT_ODL, PIN(5, 0), GPIO_INT_FALLING, bc12_interrupt)
GPIO_INT(USB_C1_PPC_INT_ODL, PIN(F, 5), GPIO_INT_FALLING, ppc_interrupt)
GPIO_INT(USB_C1_TCPC_INT_ODL, PIN(A, 2), GPIO_INT_FALLING, tcpc_alert_event)
-GPIO_INT(USB_C2_BC12_INT_ODL, PIN(8, 3), GPIO_INT_FALLING, bc12_interrupt)
-GPIO_INT(USB_C2_PPC_INT_ODL, PIN(7, 0), GPIO_INT_FALLING, ppc_interrupt)
-GPIO_INT(USB_C2_RT_INT_ODL, PIN(4, 1), GPIO_INT_FALLING, retimer_interrupt)
GPIO_INT(BJ_ADP_PRESENT_ODL, PIN(8, 2), GPIO_INT_BOTH | GPIO_PULL_UP, adp_connect_interrupt)
GPIO_INT(EC_RECOVERY_BTN_OD, PIN(2, 3), GPIO_INT_BOTH, button_interrupt)
GPIO_INT(HDMI_CONN_OC_ODL, PIN(2, 4), GPIO_INPUT | GPIO_INT_BOTH, port_ocp_interrupt)
@@ -34,11 +30,6 @@ GPIO_INT(USB_A0_OC_ODL, PIN(3, 1), GPIO_INPUT | GPIO_PULL_UP | GPIO
GPIO_INT(USB_A1_OC_ODL, PIN(3, 0), GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH, port_ocp_interrupt)
GPIO_INT(USB_A2_OC_ODL, PIN(2, 7), GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH, port_ocp_interrupt)
GPIO_INT(USB_A3_OC_ODL, PIN(2, 6), GPIO_INPUT | GPIO_PULL_UP | GPIO_INT_BOTH, port_ocp_interrupt)
-#ifdef SECTION_IS_RW
-GPIO_INT(QI_INT_ODL, PIN(9, 6), GPIO_INT_FALLING, pchg_irq)
-#else
-UNIMPLEMENTED(QI_INT_ODL)
-#endif
/* CCD */
GPIO(CCD_MODE_ODL, PIN(E, 5), GPIO_INPUT)
@@ -54,8 +45,25 @@ GPIO(EN_PP5000_FAN, PIN(6, 1), GPIO_OUT_HIGH)
GPIO(ANALOG_PPVAR_PWR_IN_IMON_EC, PIN(4, 2), GPIO_INPUT)
/* Display */
-GPIO(DP_CONN_OC_ODL, PIN(2, 5), GPIO_INPUT)
-
+GPIO(EC_OVERRIDE_SCLR_EN, PIN(D, 4), GPIO_OUT_HIGH)
+
+/* TODO(b/260063632): the gpio pin control is wip, setting to level high
+ to enable the backlight by default */
+GPIO(EC_12VSC_EN, PIN(D, 2), GPIO_OUT_HIGH)
+
+GPIO(OSD_STS, PIN(4, 1), GPIO_INPUT)
+GPIO(DISP_MODE, PIN(A, 0), GPIO_INPUT)
+GPIO(PANEL_PWR_STS, PIN(9, 5), GPIO_INPUT)
+GPIO(EN_SCLR_RAILS, PIN(0, 4), GPIO_INPUT)
+GPIO(HDMI_5V_IN, PIN(9, 3), GPIO_INPUT)
+GPIO(HDMI0_CABLE_DET, PIN(9, 6), GPIO_INPUT)
+GPIO(WP_EC, PIN(C, 3), GPIO_INPUT)
+GPIO(OSD_INT, PIN(0, 5), GPIO_INPUT)
+
+/* Audio */
+/* TODO(b/260063632): the gpio pin control is wip, setting to level high
+ to enable the speaker by default */
+GPIO(EC_AMP_SD, PIN(5, 6), GPIO_OUT_HIGH)
/* BarrelJack */
GPIO(EN_PPVAR_BJ_ADP_L, PIN(0, 7), GPIO_OUT_LOW)
@@ -79,17 +87,6 @@ GPIO(CPU_C10_GATE_L, PIN(6, 7), GPIO_INPUT)
GPIO(EC_PCH_PWR_BTN_ODL, PIN(C, 1), GPIO_ODR_HIGH)
GPIO(GSC_EC_RECOVERY_BTN_OD, PIN(2, 2), GPIO_INPUT)
-/* NFC */
-/* TODO(b/194068530): Enable NFC */
-GPIO(NFC_COIL_ACT_L, PIN(D, 4), GPIO_INPUT)
-GPIO(NFC_LOW_POWER_MODE, PIN(9, 5), GPIO_OUT_HIGH)
-GPIO(NFC_CARD_DET_L, PIN(A, 3), GPIO_INPUT)
-GPIO(EN_NFC_BUZZER, PIN(0, 5), GPIO_OUT_LOW)
-
-/* Wireless Charger */
-GPIO(EC_QI_PWR, PIN(D, 2), GPIO_OUT_LOW)
-GPIO(QI_RESET_L, PIN(9, 3), GPIO_OUT_HIGH)
-
/* HDMI CEC */
/* TODO(b/197474873): Enable HDMI CEC */
GPIO(HDMI_CEC_IN, PIN(4, 0), GPIO_INPUT)
@@ -97,20 +94,16 @@ GPIO(HDMI_CEC_OUT, PIN(D, 3), GPIO_OUT_HIGH | GPIO_OPEN_DRAIN)
GPIO(HDMI_CEC_PULL_UP, PIN(C, 2), GPIO_OUT_HIGH)
/* I2C SCL/SDA */
-GPIO(EC_I2C_QI_SCL, PIN(3, 3), GPIO_INPUT)
-GPIO(EC_I2C_QI_SDA, PIN(3, 6), GPIO_INPUT)
+GPIO(SMSCALER_CLK, PIN(3, 3), GPIO_INPUT)
+GPIO(SMSCALER_DATA, PIN(3, 6), GPIO_INPUT)
GPIO(EC_I2C_MISC_SCL_R, PIN(B, 3), GPIO_INPUT)
GPIO(EC_I2C_MISC_SDA_R, PIN(B, 2), GPIO_INPUT)
-GPIO(EC_I2C_DP_SCL, PIN(B, 5), GPIO_INPUT)
-GPIO(EC_I2C_DP_SDA, PIN(B, 4), GPIO_INPUT)
-GPIO(EC_I2C_USB_C0_C2_PPC_SCL, PIN(9, 2), GPIO_INPUT)
-GPIO(EC_I2C_USB_C0_C2_PPC_SDA, PIN(9, 1), GPIO_INPUT)
-GPIO(EC_I2C_USB_C0_C2_RT_SCL, PIN(D, 1), GPIO_INPUT)
-GPIO(EC_I2C_USB_C0_C2_RT_SDA, PIN(D, 0), GPIO_INPUT)
-GPIO(EC_I2C_USB_C0_C2_TCPC_SCL, PIN(9, 0), GPIO_INPUT)
-GPIO(EC_I2C_USB_C0_C2_TCPC_SDA, PIN(8, 7), GPIO_INPUT)
-GPIO(EC_I2C_USB_C1_MIX_SCL, PIN(E, 4), GPIO_INPUT)
-GPIO(EC_I2C_USB_C1_MIX_SDA, PIN(E, 3), GPIO_INPUT)
+GPIO(EC_I2C_USB_C0_PPC_BC_SCL, PIN(9, 2), GPIO_INPUT)
+GPIO(EC_I2C_USB_C0_PPC_BC_SDA, PIN(9, 1), GPIO_INPUT)
+GPIO(EC_I2C_USB_C1_PPC_BC_SCL, PIN(D, 1), GPIO_INPUT)
+GPIO(EC_I2C_USB_C1_PPC_BC_SDA, PIN(D, 0), GPIO_INPUT)
+GPIO(EC_I2C_USB_C0_TCPC_SCL, PIN(9, 0), GPIO_INPUT)
+GPIO(EC_I2C_USB_C0_TCPC_SDA, PIN(8, 7), GPIO_INPUT)
GPIO(EC_I2C_USB_C1_TCPC_SCL, PIN(F, 3), GPIO_INPUT)
GPIO(EC_I2C_USB_C1_TCPC_SDA, PIN(F, 2), GPIO_INPUT)
@@ -128,36 +121,26 @@ GPIO(USB_A_OC_SOC_L, PIN(8, 0), GPIO_OUT_HIGH)
/* LED */
/* TODO(b/197471359): LED implementation */
-GPIO(LED_GREEN_L, PIN(C, 3), GPIO_OUT_LOW)
GPIO(LED_RED_L, PIN(C, 4), GPIO_OUT_LOW)
/* USBC */
-GPIO(USB_C0_C2_TCPC_RST_ODL, PIN(A, 7), GPIO_ODR_LOW)
+GPIO(USB_C0_FRS_EN, PIN(9, 7), GPIO_OUT_LOW)
+GPIO(USB_C0_RT_RST_L, PIN(A, 7), GPIO_OUT_HIGH)
GPIO(USB_C1_FRS_EN, PIN(9, 4), GPIO_OUT_LOW)
-GPIO(USB_C1_RT_INT_ODL, PIN(A, 0), GPIO_INPUT)
-GPIO(USB_C1_RT_RST_R_L, PIN(0, 2), GPIO_OUT_LOW)
+GPIO(USB_C1_RT_RST_L, PIN(0, 2), GPIO_OUT_HIGH)
/* GPIO02_P2 to PU */
/* GPIO03_P2 to PU */
-IOEX(USB_C0_OC_ODL, EXPIN(IOEX_C0_NCT38XX, 0, 4), GPIO_ODR_HIGH)
-IOEX(USB_C0_FRS_EN, EXPIN(IOEX_C0_NCT38XX, 0, 6), GPIO_LOW)
-IOEX(USB_C0_RT_RST_ODL, EXPIN(IOEX_C0_NCT38XX, 0, 7), GPIO_ODR_LOW)
-
-IOEX(USB_C2_RT_RST_ODL, EXPIN(IOEX_C2_NCT38XX, 0, 2), GPIO_ODR_LOW)
-IOEX(USB_C1_OC_ODL, EXPIN(IOEX_C2_NCT38XX, 0, 3), GPIO_ODR_HIGH)
-IOEX(USB_C2_OC_ODL, EXPIN(IOEX_C2_NCT38XX, 0, 4), GPIO_ODR_HIGH)
-IOEX(USB_C2_FRS_EN, EXPIN(IOEX_C2_NCT38XX, 0, 6), GPIO_LOW)
/* GPIO07_P2 to PU */
/* UART alternate functions */
ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* GPIO64/CR_SIN1, GPO65/CR_SOUT1/FLPRG1_L */
/* I2C alternate functions */
-ALTERNATE(PIN_MASK(3, 0x48), 0, MODULE_I2C, 0) /* GPIO33/I2C5_SCL0/CTS_L, GPIO36/RTS_L/I2C5_SDA0 */
+ALTERNATE(PIN_MASK(3, 0x48), 0, MODULE_I2C, 0) /* GPIO36/RTS_L/I2C5_SDA0, GPIO33/I2C5_SCL0/CTS_L */
ALTERNATE(PIN_MASK(8, 0x80), 0, MODULE_I2C, 0) /* GPIO87/I2C1_SDA0 */
ALTERNATE(PIN_MASK(9, 0x07), 0, MODULE_I2C, 0) /* GPIO92/I2C2_SCL0, GPIO91/I2C2_SDA0, GPIO90/I2C1_SCL0 */
ALTERNATE(PIN_MASK(B, 0x0c), 0, MODULE_I2C, 0) /* GPIOB3/I2C7_SCL0/DCD_L, GPIOB2/I2C7_SDA0/DSR_L */
-ALTERNATE(PIN_MASK(B, 0x30), 0, MODULE_I2C, 0) /* GPIOB5/I2C0_SCL0, GPIOB4/I2C0_SDA0 */
ALTERNATE(PIN_MASK(D, 0x03), 0, MODULE_I2C, 0) /* GPIOD1/I2C3_SCL0, GPIOD0/I2C3_SDA0 */
ALTERNATE(PIN_MASK(E, 0x18), 0, MODULE_I2C, 0) /* GPIOE4/I2C6_SCL1/I3C_SCL, GPIOE3/I2C6_SDA1/I3C_SDA */
ALTERNATE(PIN_MASK(F, 0x0c), 0, MODULE_I2C, 0) /* GPIOF3/I2C4_SCL1, GPIOF2/I2C4_SDA1 */
@@ -178,10 +161,14 @@ UNUSED(PIN(3, 2)) /* GPO32/TRIS_L */
UNUSED(PIN(3, 5)) /* GPO35/CR_SOUT4/TEST_L */
UNUSED(PIN(6, 6)) /* GPIO66 */
UNUSED(PIN(8, 1)) /* GPIO81/PECI_DATA */
-UNUSED(PIN(5, 6)) /* GPIO56/CLKRUN# */
-UNUSED(PIN(9, 7)) /* GPIO97 */
UNUSED(PIN(8, 6)) /* GPIO86/TXD/CR_SOUT2 */
UNUSED(PIN(1, 3)) /* KSO06/GPO13/GP_SEL# */
UNUSED(PIN(1, 2)) /* KSO07/GPO12/JEN# */
UNUSED(PIN(0, 6)) /* KSO11/GPIO06/P80_CLK */
-UNUSED(PIN(0, 4)) /* KSO13/GPIO04 */
+UNUSED(PIN(B, 4)) /* GPIOB4/I2C0_SDA0 */
+UNUSED(PIN(2, 5)) /* KSI4/GPIO25/TRACECLK/GP_SCLK */
+UNUSED(PIN(B, 5)) /* GPIOB5/I2C0_SCL0 */
+UNUSED(PIN(8, 3)) /* KSO15/GPIO83 */
+UNUSED(PIN(B, 1)) /* KSO17/GPIOB1/CR_SIN4 */
+UNUSED(PIN(7, 0)) /* GPIO70/PS2_DAT0 */
+UNUSED(PIN(A, 3)) /* SPIP_MOSI/GPIOA3 */
diff --git a/board/gaelin/i2c.c b/board/gaelin/i2c.c
index 0a0b6b69a6..f9bfa11657 100644
--- a/board/gaelin/i2c.c
+++ b/board/gaelin/i2c.c
@@ -11,60 +11,44 @@
/* I2C port map configuration */
const struct i2c_port_t i2c_ports[] = {
{
- /* I2C0 */
- .name = "dp_redriver",
- .port = I2C_PORT_DP_REDRIVER,
- .kbps = 400,
- .scl = GPIO_EC_I2C_DP_SCL,
- .sda = GPIO_EC_I2C_DP_SDA,
- },
- {
/* I2C1 */
- .name = "tcpc0,2",
- .port = I2C_PORT_USB_C0_C2_TCPC,
+ .name = "tcpc0",
+ .port = I2C_PORT_USB_C0_TCPC,
.kbps = 1000,
- .scl = GPIO_EC_I2C_USB_C0_C2_TCPC_SCL,
- .sda = GPIO_EC_I2C_USB_C0_C2_TCPC_SDA,
+ .scl = GPIO_EC_I2C_USB_C0_TCPC_SCL,
+ .sda = GPIO_EC_I2C_USB_C0_TCPC_SDA,
},
{
/* I2C2 */
- .name = "ppc0,2",
- .port = I2C_PORT_USB_C0_C2_PPC,
+ .name = "ppc0",
+ .port = I2C_PORT_USB_C0_PPC,
.kbps = 1000,
- .scl = GPIO_EC_I2C_USB_C0_C2_PPC_SCL,
- .sda = GPIO_EC_I2C_USB_C0_C2_PPC_SDA,
+ .scl = GPIO_EC_I2C_USB_C0_PPC_BC_SCL,
+ .sda = GPIO_EC_I2C_USB_C0_PPC_BC_SDA,
},
{
/* I2C3 */
- .name = "retimer0,2",
- .port = I2C_PORT_USB_C0_C2_MUX,
+ .name = "ppc1",
+ .port = I2C_PORT_USB_C1_PPC,
.kbps = 1000,
- .scl = GPIO_EC_I2C_USB_C0_C2_RT_SCL,
- .sda = GPIO_EC_I2C_USB_C0_C2_RT_SDA,
+ .scl = GPIO_EC_I2C_USB_C1_PPC_BC_SCL,
+ .sda = GPIO_EC_I2C_USB_C1_PPC_BC_SDA,
},
{
- /* I2C4 C1 TCPC */
+ /* I2C4 */
.name = "tcpc1",
.port = I2C_PORT_USB_C1_TCPC,
- .kbps = 400,
+ .kbps = 1000,
.scl = GPIO_EC_I2C_USB_C1_TCPC_SCL,
.sda = GPIO_EC_I2C_USB_C1_TCPC_SDA,
},
{
/* I2C5 */
- .name = "wireless_charger",
- .port = I2C_PORT_QI,
+ .name = "scaler",
+ .port = I2C_PORT_SCALER,
.kbps = 400,
- .scl = GPIO_EC_I2C_QI_SCL,
- .sda = GPIO_EC_I2C_QI_SDA,
- },
- {
- /* I2C6 */
- .name = "ppc1",
- .port = I2C_PORT_USB_C1_PPC,
- .kbps = 1000,
- .scl = GPIO_EC_I2C_USB_C1_MIX_SCL,
- .sda = GPIO_EC_I2C_USB_C1_MIX_SDA,
+ .scl = GPIO_SMSCALER_CLK,
+ .sda = GPIO_SMSCALER_DATA,
},
{
/* I2C7 */
diff --git a/board/gaelin/led.c b/board/gaelin/led.c
index 842cee0530..a4b9a0d094 100644
--- a/board/gaelin/led.c
+++ b/board/gaelin/led.c
@@ -249,8 +249,8 @@ int led_set_brightness(enum ec_led_id id, const uint8_t *brightness)
else
return set_color(id, LED_OFF, 0);
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Blink alert if insufficient power per system_can_boot_ap(). */
int insufficient_power =
diff --git a/board/gaelin/pwm.c b/board/gaelin/pwm.c
index 3d4335f453..fe7e82894a 100644
--- a/board/gaelin/pwm.c
+++ b/board/gaelin/pwm.c
@@ -16,8 +16,8 @@ const struct pwm_t pwm_channels[] = {
PWM_CONFIG_DSLEEP,
.freq = 2000 },
[PWM_CH_FAN] = { .channel = 5,
- .flags = PWM_CONFIG_OPEN_DRAIN | PWM_CONFIG_DSLEEP,
- .freq = 1000 },
+ .flags = PWM_CONFIG_OPEN_DRAIN,
+ .freq = 25000 },
[PWM_CH_LED_RED] = { .channel = 2,
.flags = PWM_CONFIG_ACTIVE_LOW | PWM_CONFIG_DSLEEP,
.freq = 2000 },
diff --git a/board/gaelin/thermal.c b/board/gaelin/thermal.c
new file mode 100644
index 0000000000..e15e0043e1
--- /dev/null
+++ b/board/gaelin/thermal.c
@@ -0,0 +1,140 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "chipset.h"
+#include "common.h"
+#include "console.h"
+#include "fan.h"
+#include "hooks.h"
+#include "host_command.h"
+#include "temp_sensor.h"
+#include "thermal.h"
+#include "util.h"
+
+/* Console output macros */
+#define CPUTS(outstr) cputs(CC_THERMAL, outstr)
+#define CPRINTS(format, args...) cprints(CC_THERMAL, format, ##args)
+
+struct fan_step {
+ /*
+ * Sensor 1~4 trigger point, set -1 if we're not using this
+ * sensor to determine fan speed.
+ */
+ int8_t on[TEMP_SENSOR_COUNT];
+ /*
+ * Sensor 1~4 trigger point, set -1 if we're not using this
+ * sensor to determine fan speed.
+ */
+ int8_t off[TEMP_SENSOR_COUNT];
+ /* Fan rpm */
+ int16_t rpm[FAN_CH_COUNT];
+};
+
+static const struct fan_step fan_table[] = {
+ {
+ /* level 0 */
+ .on = { 65, -1, -1, -1 },
+ .off = { 0, -1, -1, -1 },
+ .rpm = { 2350 },
+ },
+ {
+ /* level 1 */
+ .on = { 80, -1, -1, -1 },
+ .off = { 60, -1, -1, -1 },
+ .rpm = { 2350 },
+ },
+ {
+ /* level 2 */
+ .on = { 87, -1, -1, -1 },
+ .off = { 75, -1, -1, -1 },
+ .rpm = { 3250 },
+ },
+ {
+ /* level 3 */
+ .on = { 91, -1, -1, -1 },
+ .off = { 82, -1, -1, -1 },
+ .rpm = { 3750 },
+ },
+ {
+ /* level 4 */
+ .on = { 100, -1, -1, -1 },
+ .off = { 86, -1, -1, -1 },
+ .rpm = { 4100 },
+ },
+};
+const int num_fan_levels = ARRAY_SIZE(fan_table);
+
+int fan_table_to_rpm(int fan, int *temp, enum temp_sensor_id temp_sensor)
+{
+ /* current fan level */
+ static int current_level;
+ /* previous fan level */
+ static int prev_current_level;
+ /* previous sensor temperature */
+ static int prev_temp[TEMP_SENSOR_COUNT];
+ int i;
+ int new_rpm = 0;
+
+ /*
+ * Compare the current and previous temperature, we have
+ * the three paths:
+ * 1. decreasing path. (check the release point)
+ * 2. increasing path. (check the trigger point)
+ * 3. invariant path. (return the current RPM)
+ */
+ if (temp[temp_sensor] < prev_temp[temp_sensor]) {
+ for (i = current_level; i > 0; i--) {
+ if (temp[temp_sensor] < fan_table[i].off[temp_sensor])
+ current_level = i - 1;
+ else
+ break;
+ }
+ } else if (temp[temp_sensor] > prev_temp[temp_sensor]) {
+ for (i = current_level; i < num_fan_levels; i++) {
+ if (temp[temp_sensor] > fan_table[i].on[temp_sensor])
+ current_level = i + 1;
+ else
+ break;
+ }
+ }
+
+ if (current_level < 0)
+ current_level = 0;
+ if (current_level >= num_fan_levels)
+ current_level = num_fan_levels - 1;
+
+ if (current_level != prev_current_level) {
+ CPRINTS("temp: %d, prev_temp: %d", temp[temp_sensor],
+ prev_temp[temp_sensor]);
+ CPRINTS("current_level: %d", current_level);
+ }
+
+ prev_temp[temp_sensor] = temp[temp_sensor];
+ prev_current_level = current_level;
+
+ switch (fan) {
+ case FAN_CH_0:
+ new_rpm = fan_table[current_level].rpm[FAN_CH_0];
+ break;
+ default:
+ break;
+ }
+
+ return new_rpm;
+}
+
+void board_override_fan_control(int fan, int *temp)
+{
+ if (chipset_in_state(CHIPSET_STATE_ON)) {
+ fan_set_rpm_mode(FAN_CH(fan), 1);
+ fan_set_rpm_target(FAN_CH(fan),
+ fan_table_to_rpm(FAN_CH(fan), temp,
+ TEMP_SENSOR_1_CPU));
+ } else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) {
+ /* Stop fan when enter S0ix */
+ fan_set_rpm_mode(FAN_CH(fan), 1);
+ fan_set_rpm_target(FAN_CH(fan), 0);
+ }
+}
diff --git a/board/gaelin/usbc_config.c b/board/gaelin/usbc_config.c
index 806ff2c4ee..98595fc607 100644
--- a/board/gaelin/usbc_config.c
+++ b/board/gaelin/usbc_config.c
@@ -10,17 +10,13 @@
#include "compile_time_macros.h"
#include "console.h"
#include "driver/bc12/pi3usb9201_public.h"
-#include "driver/ppc/syv682x_public.h"
-#include "driver/retimer/bb_retimer_public.h"
-#include "driver/retimer/kb800x.h"
-#include "driver/tcpm/nct38xx.h"
-#include "driver/tcpm/rt1715.h"
+#include "driver/ppc/nx20p348x.h"
+#include "driver/tcpm/ps8xxx_public.h"
#include "driver/tcpm/tcpci.h"
#include "ec_commands.h"
#include "gpio.h"
#include "gpio_signal.h"
#include "hooks.h"
-#include "ioexpander.h"
#include "system.h"
#include "task.h"
#include "task_id.h"
@@ -40,29 +36,22 @@ const struct tcpc_config_t tcpc_config[] = {
[USBC_PORT_C0] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
- .port = I2C_PORT_USB_C0_C2_TCPC,
- .addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
+ .port = I2C_PORT_USB_C0_TCPC,
+ .addr_flags = PS8XXX_I2C_ADDR1_FLAGS,
},
- .drv = &nct38xx_tcpm_drv,
+ .drv = &ps8xxx_tcpm_drv,
.flags = TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_NO_DEBUG_ACC_CONTROL,
+ TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V,
},
[USBC_PORT_C1] = {
.bus_type = EC_BUS_TYPE_I2C,
.i2c_info = {
.port = I2C_PORT_USB_C1_TCPC,
- .addr_flags = RT1715_I2C_ADDR_FLAGS,
+ .addr_flags = PS8XXX_I2C_ADDR2_FLAGS,
},
- .drv = &rt1715_tcpm_drv,
- },
- [USBC_PORT_C2] = {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C0_C2_TCPC,
- .addr_flags = NCT38XX_I2C_ADDR2_1_FLAGS,
- },
- .drv = &nct38xx_tcpm_drv,
- .flags = TCPC_FLAGS_TCPCI_REV2_0,
+ .drv = &ps8xxx_tcpm_drv,
+ .flags = TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V,
},
};
BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT);
@@ -71,19 +60,16 @@ BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT);
/* USBC PPC configuration */
struct ppc_config_t ppc_chips[] = {
[USBC_PORT_C0] = {
- .i2c_port = I2C_PORT_USB_C0_C2_PPC,
- .i2c_addr_flags = SYV682X_ADDR0_FLAGS,
- .drv = &syv682x_drv,
+ /* Compatible with Silicon Mitus SM5360A */
+ .i2c_port = I2C_PORT_USB_C0_PPC,
+ .i2c_addr_flags = NX20P3483_ADDR2_FLAGS,
+ .drv = &nx20p348x_drv,
},
[USBC_PORT_C1] = {
+ /* Compatible with Silicon Mitus SM5360A */
.i2c_port = I2C_PORT_USB_C1_PPC,
- .i2c_addr_flags = SYV682X_ADDR0_FLAGS,
- .drv = &syv682x_drv,
- },
- [USBC_PORT_C2] = {
- .i2c_port = I2C_PORT_USB_C0_C2_PPC,
- .i2c_addr_flags = SYV682X_ADDR2_FLAGS,
- .drv = &syv682x_drv,
+ .i2c_addr_flags = NX20P3483_ADDR3_FLAGS,
+ .drv = &nx20p348x_drv,
},
};
BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == USBC_PORT_COUNT);
@@ -95,200 +81,100 @@ static const struct usb_mux_chain usbc0_tcss_usb_mux = {
.mux =
&(const struct usb_mux){
.usb_port = USBC_PORT_C0,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
+ .driver = &tcpci_tcpm_usb_mux_driver,
+ .hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
};
static const struct usb_mux_chain usbc1_tcss_usb_mux = {
.mux =
&(const struct usb_mux){
.usb_port = USBC_PORT_C1,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
+ .driver = &tcpci_tcpm_usb_mux_driver,
+ .hpd_update = &ps8xxx_tcpc_update_hpd_status,
},
};
-static const struct usb_mux_chain usbc2_tcss_usb_mux = {
- .mux =
- &(const struct usb_mux){
- .usb_port = USBC_PORT_C2,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
- },
-};
-
-struct kb800x_control_t kb800x_control[] = {
- [USBC_PORT_C0] = {
- },
- [USBC_PORT_C1] = {
- .retimer_rst_gpio = GPIO_USB_C1_RT_RST_R_L,
- .ss_lanes = {
- [KB800X_A0] = KB800X_TX0, [KB800X_A1] = KB800X_RX0,
- [KB800X_B0] = KB800X_RX1, [KB800X_B1] = KB800X_TX1,
- [KB800X_C0] = KB800X_RX0, [KB800X_C1] = KB800X_TX0,
- [KB800X_D0] = KB800X_TX1, [KB800X_D1] = KB800X_RX1,
- }
- },
- [USBC_PORT_C2] = {
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(kb800x_control) == USBC_PORT_COUNT);
const struct usb_mux_chain usb_muxes[] = {
[USBC_PORT_C0] = {
.mux = &(const struct usb_mux) {
.usb_port = USBC_PORT_C0,
- .driver = &bb_usb_retimer,
- .hpd_update = bb_retimer_hpd_update,
- .i2c_port = I2C_PORT_USB_C0_C2_MUX,
- .i2c_addr_flags = USBC_PORT_C0_BB_RETIMER_I2C_ADDR,
+ .driver = &virtual_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
},
.next = &usbc0_tcss_usb_mux,
},
[USBC_PORT_C1] = {
.mux = &(const struct usb_mux) {
.usb_port = USBC_PORT_C1,
- .driver = &kb800x_usb_mux_driver,
- .i2c_port = I2C_PORT_USB_C1_MUX,
- .i2c_addr_flags = KB800X_I2C_ADDR0_FLAGS,
+ .driver = &virtual_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
},
.next = &usbc1_tcss_usb_mux,
},
- [USBC_PORT_C2] = {
- .mux = &(const struct usb_mux) {
- .usb_port = USBC_PORT_C2,
- .driver = &bb_usb_retimer,
- .hpd_update = bb_retimer_hpd_update,
- .i2c_port = I2C_PORT_USB_C0_C2_MUX,
- .i2c_addr_flags = USBC_PORT_C2_BB_RETIMER_I2C_ADDR,
- },
- .next = &usbc2_tcss_usb_mux,
- },
};
BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
/* BC1.2 charger detect configuration */
const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = {
[USBC_PORT_C0] = {
- .i2c_port = I2C_PORT_USB_C0_C2_BC12,
+ .i2c_port = I2C_PORT_USB_C0_BC12,
.i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
},
[USBC_PORT_C1] = {
.i2c_port = I2C_PORT_USB_C1_BC12,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
- },
- [USBC_PORT_C2] = {
- .i2c_port = I2C_PORT_USB_C0_C2_BC12,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_1_FLAGS,
+ .i2c_addr_flags = PI3USB9201_I2C_ADDR_2_FLAGS,
},
};
BUILD_ASSERT(ARRAY_SIZE(pi3usb9201_bc12_chips) == USBC_PORT_COUNT);
-/*
- * USB C0 and C2 uses burnside bridge chips and have their reset
- * controlled by their respective TCPC chips acting as GPIO expanders.
- *
- * ioex_init() is normally called before we take the TCPCs out of
- * reset, so we need to start in disabled mode, then explicitly
- * call ioex_init().
- */
-
-struct ioexpander_config_t ioex_config[] = {
- [IOEX_C0_NCT38XX] = {
- .i2c_host_port = I2C_PORT_USB_C0_C2_TCPC,
- .i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
- .drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
- },
- [IOEX_C2_NCT38XX] = {
- .i2c_host_port = I2C_PORT_USB_C0_C2_TCPC,
- .i2c_addr_flags = NCT38XX_I2C_ADDR2_1_FLAGS,
- .drv = &nct38xx_ioexpander_drv,
- .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT);
-
-__override int bb_retimer_power_enable(const struct usb_mux *me, bool enable)
+static void ps8815_reset(int port)
{
- enum ioex_signal rst_signal;
-
- if (me->usb_port == USBC_PORT_C0) {
- rst_signal = IOEX_USB_C0_RT_RST_ODL;
- } else if (me->usb_port == USBC_PORT_C2) {
- rst_signal = IOEX_USB_C2_RT_RST_ODL;
+ int val;
+ int i2c_port;
+ uint16_t i2c_addr_flags;
+ enum gpio_signal ps8xxx_rst_odl;
+
+ if (port == USBC_PORT_C0) {
+ ps8xxx_rst_odl = GPIO_USB_C0_RT_RST_L;
+ i2c_port = I2C_PORT_USB_C0_TCPC;
+ i2c_addr_flags = PS8XXX_I2C_ADDR1_FLAGS;
+ } else if (port == USBC_PORT_C1) {
+ ps8xxx_rst_odl = GPIO_USB_C1_RT_RST_L;
+ i2c_port = I2C_PORT_USB_C1_TCPC;
+ i2c_addr_flags = PS8XXX_I2C_ADDR2_FLAGS;
} else {
- return EC_ERROR_INVAL;
+ return;
}
- /*
- * We do not have a load switch for the burnside bridge chips,
- * so we only need to sequence reset.
- */
+ gpio_set_level(ps8xxx_rst_odl, 0);
+ msleep(GENERIC_MAX(PS8XXX_RESET_DELAY_MS, PS8815_PWR_H_RST_H_DELAY_MS));
+ gpio_set_level(ps8xxx_rst_odl, 1);
+ msleep(PS8815_FW_INIT_DELAY_MS);
- if (enable) {
- /*
- * Tpw, minimum time from VCC to RESET_N de-assertion is 100us.
- * For boards that don't provide a load switch control, the
- * retimer_init() function ensures power is up before calling
- * this function.
- */
- ioex_set_level(rst_signal, 1);
- /*
- * Allow 1ms time for the retimer to power up lc_domain
- * which powers I2C controller within retimer
- */
- msleep(1);
- } else {
- ioex_set_level(rst_signal, 0);
- msleep(1);
+ CPRINTS("[C%d] %s: patching ps8815 registers", port, __func__);
+
+ if (i2c_read8(i2c_port, i2c_addr_flags, 0x0f, &val) == EC_SUCCESS)
+ CPRINTS("ps8815: reg 0x0f was %02x", val);
+ else {
+ CPRINTS("delay 10ms to make sure ps8815 is waken from idle");
+ msleep(10);
}
- return EC_SUCCESS;
-}
-__override int bb_retimer_reset(const struct usb_mux *me)
-{
- /*
- * TODO(b/193402306, b/195375738): Remove this once transition to
- * QS Silicon is complete
- */
- bb_retimer_power_enable(me, false);
- msleep(5);
- bb_retimer_power_enable(me, true);
- msleep(25);
+ if (i2c_write8(i2c_port, i2c_addr_flags, 0x0f, 0x31) == EC_SUCCESS)
+ CPRINTS("ps8815: reg 0x0f set to 0x31");
- return EC_SUCCESS;
+ if (i2c_read8(i2c_port, i2c_addr_flags, 0x0f, &val) == EC_SUCCESS)
+ CPRINTS("ps8815: reg 0x0f now %02x", val);
}
void board_reset_pd_mcu(void)
{
- enum gpio_signal tcpc_rst;
-
- tcpc_rst = GPIO_USB_C0_C2_TCPC_RST_ODL;
-
- /*
- * TODO(b/179648104): figure out correct timing
- */
-
- gpio_set_level(tcpc_rst, 0);
- gpio_set_level(GPIO_USB_C1_RT_RST_R_L, 0);
-
- /*
- * delay for power-on to reset-off and min. assertion time
- */
-
- msleep(20);
-
- gpio_set_level(tcpc_rst, 1);
- gpio_set_level(GPIO_USB_C1_RT_RST_R_L, 1);
-
- /* wait for chips to come up */
-
- msleep(50);
-}
-
-static void enable_ioex(int ioex)
-{
- ioex_init(ioex);
+ ps8815_reset(USBC_PORT_C0);
+ usb_mux_hpd_update(USBC_PORT_C0, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ ps8815_reset(USBC_PORT_C1);
+ usb_mux_hpd_update(USBC_PORT_C1, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
static void board_tcpc_init(void)
@@ -296,25 +182,19 @@ static void board_tcpc_init(void)
/* Don't reset TCPCs after initial reset */
if (!system_jumped_late()) {
board_reset_pd_mcu();
-
- /*
- * These IO expander pins are implemented using the
- * C0/C2 TCPC, so they must be set up after the TCPC has
- * been taken out of reset.
- */
- enable_ioex(IOEX_C0_NCT38XX);
- enable_ioex(IOEX_C2_NCT38XX);
}
/* Enable PPC interrupts. */
gpio_enable_interrupt(GPIO_USB_C0_PPC_INT_ODL);
- gpio_enable_interrupt(GPIO_USB_C2_PPC_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_PPC_INT_ODL);
/* Enable TCPC interrupts. */
- gpio_enable_interrupt(GPIO_USB_C0_C2_TCPC_INT_ODL);
-
- gpio_enable_interrupt(GPIO_USB_C1_PPC_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C0_TCPC_INT_ODL);
gpio_enable_interrupt(GPIO_USB_C1_TCPC_INT_ODL);
+
+ /* Enable BC1.2 interrupts. */
+ gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_ODL);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_CHIPSET);
@@ -322,8 +202,8 @@ uint16_t tcpc_get_alert_status(void)
{
uint16_t status = 0;
- if (gpio_get_level(GPIO_USB_C0_C2_TCPC_INT_ODL) == 0)
- status |= PD_STATUS_TCPC_ALERT_0 | PD_STATUS_TCPC_ALERT_2;
+ if (gpio_get_level(GPIO_USB_C0_TCPC_INT_ODL) == 0)
+ status |= PD_STATUS_TCPC_ALERT_0;
if (gpio_get_level(GPIO_USB_C1_TCPC_INT_ODL) == 0)
status |= PD_STATUS_TCPC_ALERT_1;
@@ -337,15 +217,13 @@ int ppc_get_alert_status(int port)
return gpio_get_level(GPIO_USB_C0_PPC_INT_ODL) == 0;
else if (port == USBC_PORT_C1)
return gpio_get_level(GPIO_USB_C1_PPC_INT_ODL) == 0;
- else if (port == USBC_PORT_C2)
- return gpio_get_level(GPIO_USB_C2_PPC_INT_ODL) == 0;
return 0;
}
void tcpc_alert_event(enum gpio_signal signal)
{
switch (signal) {
- case GPIO_USB_C0_C2_TCPC_INT_ODL:
+ case GPIO_USB_C0_TCPC_INT_ODL:
schedule_deferred_pd_interrupt(USBC_PORT_C0);
break;
case GPIO_USB_C1_TCPC_INT_ODL:
@@ -365,9 +243,6 @@ void bc12_interrupt(enum gpio_signal signal)
case GPIO_USB_C1_BC12_INT_ODL:
usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
break;
- case GPIO_USB_C2_BC12_INT_ODL:
- usb_charger_task_set_event(2, USB_CHG_EVENT_BC12);
- break;
default:
break;
}
@@ -377,13 +252,10 @@ void ppc_interrupt(enum gpio_signal signal)
{
switch (signal) {
case GPIO_USB_C0_PPC_INT_ODL:
- syv682x_interrupt(USBC_PORT_C0);
+ nx20p348x_interrupt(USBC_PORT_C0);
break;
case GPIO_USB_C1_PPC_INT_ODL:
- syv682x_interrupt(USBC_PORT_C1);
- break;
- case GPIO_USB_C2_PPC_INT_ODL:
- syv682x_interrupt(USBC_PORT_C2);
+ nx20p348x_interrupt(USBC_PORT_C1);
break;
default:
break;
@@ -401,16 +273,3 @@ __override bool board_is_dts_port(int port)
{
return port == USBC_PORT_C0;
}
-
-__override bool board_is_tbt_usb4_port(int port)
-{
- return true;
-}
-
-__override enum tbt_compat_cable_speed board_get_max_tbt_speed(int port)
-{
- if (!board_is_tbt_usb4_port(port))
- return TBT_SS_RES_0;
-
- return TBT_SS_TBT_GEN3;
-}
diff --git a/board/gaelin/usbc_config.h b/board/gaelin/usbc_config.h
index 5e7beae21a..219ad9a745 100644
--- a/board/gaelin/usbc_config.h
+++ b/board/gaelin/usbc_config.h
@@ -8,13 +8,8 @@
#ifndef __CROS_EC_USBC_CONFIG_H
#define __CROS_EC_USBC_CONFIG_H
-#define CONFIG_USB_PD_PORT_MAX_COUNT 3
+#define CONFIG_USB_PD_PORT_MAX_COUNT 2
-enum usbc_port {
- USBC_PORT_C0 = 0,
- USBC_PORT_C1,
- USBC_PORT_C2,
- USBC_PORT_COUNT
-};
+enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
#endif /* __CROS_EC_USBC_CONFIG_H */
diff --git a/board/galtic/board.c b/board/galtic/board.c
index af0638be20..9800c1150c 100644
--- a/board/galtic/board.c
+++ b/board/galtic/board.c
@@ -502,18 +502,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * TODO(b/151955431): Characterize the input current limit in case a
- * scaling needs to be applied here
- */
- charge_set_input_current_limit(icl, charge_mv);
-}
-
int board_is_sourcing_vbus(int port)
{
int regval;
diff --git a/board/gelarshie/board.c b/board/gelarshie/board.c
index 11346a3c7d..174e4b0764 100644
--- a/board/gelarshie/board.c
+++ b/board/gelarshie/board.c
@@ -511,6 +511,7 @@ void board_tcpc_init(void)
/* Enable PPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -682,8 +683,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -695,9 +696,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_ma = charge_ma * 95 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/gelarshie/board.h b/board/gelarshie/board.h
index 7e27c7a62f..737f005639 100644
--- a/board/gelarshie/board.h
+++ b/board/gelarshie/board.h
@@ -35,6 +35,7 @@
#undef CONFIG_CMD_ACCEL_FIFO
#undef CONFIG_CMD_ACCEL_INFO
#undef CONFIG_CMD_TASK_RESET
+#undef CONFIG_CONSOLE_CMDHELP
/* Battery */
#define CONFIG_BATTERY_DEVICE_CHEMISTRY "LION"
@@ -42,6 +43,9 @@
#define CONFIG_BATTERY_FUEL_GAUGE
#define CONFIG_BATTERY_VENDOR_PARAM
+/* charger margin */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
+
/* Enable PD3.0 */
#define CONFIG_USB_PD_REV30
/* BC 1.2 Charger */
diff --git a/board/gimble/board.c b/board/gimble/board.c
index 0ca135b9fd..5373eb2bff 100644
--- a/board/gimble/board.c
+++ b/board/gimble/board.c
@@ -185,16 +185,3 @@ __overridable void board_ps8xxx_tcpc_init(int port)
CPRINTS("ps8815: fail to write reg 0x%02x",
PS8815_REG_RX_EQ_AT_5G);
}
-
-__override void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- /*
- * Follow OEM request to limit the input current to
- * 90% negotiated limit.
- */
- charge_ma = charge_ma * 90 / 100;
-
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/gimble/board.h b/board/gimble/board.h
index 015f3f78e6..1d4099e7eb 100644
--- a/board/gimble/board.h
+++ b/board/gimble/board.h
@@ -196,6 +196,8 @@
#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
#define CONFIG_CHARGER_BQ25710_PSYS_SENSING
+/* OEM requested 10% derating */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 10
/* PROCHOT defines */
#define BATT_MAX_CONTINUE_DISCHARGE_WATT 45
diff --git a/board/gimble/charger.c b/board/gimble/charger.c
index a4fa209246..7fabd2082e 100644
--- a/board/gimble/charger.c
+++ b/board/gimble/charger.c
@@ -81,10 +81,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/gooey/board.c b/board/gooey/board.c
index 250f6afd61..544117f9c6 100644
--- a/board/gooey/board.c
+++ b/board/gooey/board.c
@@ -259,19 +259,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/gooey/board.h b/board/gooey/board.h
index b586c0f334..fde32f8866 100644
--- a/board/gooey/board.h
+++ b/board/gooey/board.h
@@ -32,6 +32,11 @@
*/
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
/* DAC for PSYS */
#define CONFIG_DAC
diff --git a/board/haboki/board.c b/board/haboki/board.c
index d7509115b5..8814871ed7 100644
--- a/board/haboki/board.c
+++ b/board/haboki/board.c
@@ -526,19 +526,17 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
/* Limit C1 on board version 0 to 2.0 A */
if ((board_version == 0) && (port == 1))
- icl = MIN(icl, 2000);
+ charge_ma = MIN(charge_ma, 2000);
/*
* TODO(b/151955431): Characterize the input current limit in case a
* scaling needs to be applied here
*/
- charge_set_input_current_limit(icl, charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
int board_set_active_charge_port(int port)
diff --git a/board/hammer/board.h b/board/hammer/board.h
index bce7dc39f4..dd4b337c66 100644
--- a/board/hammer/board.h
+++ b/board/hammer/board.h
@@ -83,7 +83,6 @@
#define CONFIG_LTO
#define CONFIG_FORCE_CONSOLE_RESUME
#define CONFIG_MATH_UTIL
-#define CONFIG_STM_HWTIMER32
/* USB Configuration */
#define CONFIG_USB
@@ -270,7 +269,7 @@
#ifdef BOARD_WAND
/* Battery and charger options. */
#define CONFIG_CHARGER
-#define CONFIG_CHARGER_INPUT_CURRENT 128
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 128
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
diff --git a/board/hatch_fp/board.h b/board/hatch_fp/board.h
index d36a9228c1..9e900a126a 100644
--- a/board/hatch_fp/board.h
+++ b/board/hatch_fp/board.h
@@ -235,7 +235,6 @@
#define CONFIG_SHA256
#define CONFIG_SHA256_UNROLLED
#define CONFIG_SPI
-#define CONFIG_STM_HWTIMER32
#define CONFIG_WP_ACTIVE_HIGH
#define CONFIG_PANIC_STRIP_GPR
diff --git a/board/hatch_fp/build.mk b/board/hatch_fp/build.mk
index 828e7523b3..894c907ab9 100644
--- a/board/hatch_fp/build.mk
+++ b/board/hatch_fp/build.mk
@@ -29,6 +29,7 @@ test-list-y=\
abort \
aes \
always_memset \
+ benchmark \
cec \
compile_time_macros \
cortexm_fpu \
@@ -39,6 +40,8 @@ test-list-y=\
flash_write_protect \
fpsensor \
fpsensor_hw \
+ ftrapv \
+ libc_printf \
mpu \
mutex \
panic \
@@ -46,6 +49,7 @@ test-list-y=\
pingpong \
printf \
queue \
+ rng_benchmark \
rollback \
rollback_entropy \
rsa3 \
diff --git a/board/herobrine/usbc_config.c b/board/herobrine/usbc_config.c
index 98d1b70bac..c80b00f0de 100644
--- a/board/herobrine/usbc_config.c
+++ b/board/herobrine/usbc_config.c
@@ -177,6 +177,7 @@ void board_tcpc_init(void)
/* Enable PPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -285,8 +286,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -298,8 +299,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/hoho/board.h b/board/hoho/board.h
index 7768ab7293..f6421fdaf0 100644
--- a/board/hoho/board.h
+++ b/board/hoho/board.h
@@ -15,7 +15,6 @@
#define CONFIG_UART_CONSOLE 1
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_ADC
#define CONFIG_BOARD_PRE_INIT
#define CONFIG_CMD_SPI_FLASH
diff --git a/board/homestar/board.c b/board/homestar/board.c
index ab4b95b625..11035d2034 100644
--- a/board/homestar/board.c
+++ b/board/homestar/board.c
@@ -459,6 +459,7 @@ void board_tcpc_init(void)
/* Enable PPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -630,8 +631,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -643,9 +644,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_ma = charge_ma * 95 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/homestar/board.h b/board/homestar/board.h
index 230aa6e7d3..60d943b300 100644
--- a/board/homestar/board.h
+++ b/board/homestar/board.h
@@ -27,6 +27,9 @@
#define CONFIG_BATTERY_FUEL_GAUGE
#define CONFIG_BATTERY_VENDOR_PARAM
+/* charger margin */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
+
/* Enable PD3.0 */
#define CONFIG_USB_PD_REV30
diff --git a/board/host/charger.c b/board/host/charger.c
index fddadf245d..0580ddcb41 100644
--- a/board/host/charger.c
+++ b/board/host/charger.c
@@ -136,7 +136,8 @@ static enum ec_error_list mock_set_input_current_limit(int chgnum, int current)
static enum ec_error_list mock_post_init(int chgnum)
{
- mock_current = mock_input_current = CONFIG_CHARGER_INPUT_CURRENT;
+ mock_current = mock_input_current =
+ CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT;
return EC_SUCCESS;
}
diff --git a/board/hyperdebug/board.c b/board/hyperdebug/board.c
index 37e41f66a9..66cd981dca 100644
--- a/board/hyperdebug/board.c
+++ b/board/hyperdebug/board.c
@@ -20,6 +20,8 @@
#include "usb-stream.h"
#include "gpio_list.h"
+#include <stdio.h>
+
void board_config_pre_init(void)
{
/* enable SYSCFG clock */
@@ -236,6 +238,26 @@ static void board_init(void)
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+const char *board_read_serial(void)
+{
+ const uint32_t *stm32_unique_id =
+ (const uint32_t *)STM32_UNIQUE_ID_BASE;
+ static char serial[13];
+
+ // Compute 12 hex digits from three factory programmed 32-bit "Unique
+ // ID" words in a manner that has been observed to be consistent with
+ // how the STM DFU ROM bootloader presents its serial number. This
+ // means that the serial number of any particular HyperDebug board will
+ // remain the same as it enters and leaves DFU mode for software
+ // upgrade.
+ int rc = snprintf(serial, sizeof(serial), "%08X%04X",
+ stm32_unique_id[0] + stm32_unique_id[2],
+ stm32_unique_id[1] >> 16);
+ if (12 != rc)
+ return NULL;
+ return serial;
+}
+
/**
* Find a GPIO signal by name.
*
diff --git a/board/hyperdebug/board.h b/board/hyperdebug/board.h
index 9d15311784..86c2c88ad0 100644
--- a/board/hyperdebug/board.h
+++ b/board/hyperdebug/board.h
@@ -36,7 +36,6 @@
#undef CONFIG_UART_RX_DMA
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_HW_CRC
#undef CONFIG_PVD
/*
diff --git a/board/icarus/board.c b/board/icarus/board.c
index be464e3a77..4d145287a4 100644
--- a/board/icarus/board.c
+++ b/board/icarus/board.c
@@ -204,14 +204,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/icarus/board.h b/board/icarus/board.h
index 98b6da3fd5..ca1a236307 100644
--- a/board/icarus/board.h
+++ b/board/icarus/board.h
@@ -24,6 +24,7 @@
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_RUNTIME_CONFIG
diff --git a/board/jacuzzi/board.c b/board/jacuzzi/board.c
index 129b75f8e2..d9e88d3f80 100644
--- a/board/jacuzzi/board.c
+++ b/board/jacuzzi/board.c
@@ -244,14 +244,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/jacuzzi/board.h b/board/jacuzzi/board.h
index 0fd5f6496d..d5d0523790 100644
--- a/board/jacuzzi/board.h
+++ b/board/jacuzzi/board.h
@@ -34,6 +34,7 @@
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_RUNTIME_CONFIG
diff --git a/board/kano/charger.c b/board/kano/charger.c
index ab48a7338c..95227f753a 100644
--- a/board/kano/charger.c
+++ b/board/kano/charger.c
@@ -79,10 +79,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/kappa/board.c b/board/kappa/board.c
index c04b24d3ed..c00e375560 100644
--- a/board/kappa/board.c
+++ b/board/kappa/board.c
@@ -217,14 +217,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/kappa/board.h b/board/kappa/board.h
index 6b6461ae83..5c49053a7b 100644
--- a/board/kappa/board.h
+++ b/board/kappa/board.h
@@ -26,6 +26,7 @@
#define CONFIG_BATTERY_COUNT 1
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_BC12_DETECT_PI3USB9201
diff --git a/board/kappa/led.c b/board/kappa/led.c
index 1dc86013d7..d9ecb33da0 100644
--- a/board/kappa/led.c
+++ b/board/kappa/led.c
@@ -129,6 +129,7 @@ static void led_set_battery(void)
case PWR_STATE_FORCED_IDLE:
led_set_color_battery((battery_ticks & 0x2) ? LED_AMBER :
LED_OFF);
+ break;
default:
/* Other states don't alter LED behavior */
break;
diff --git a/board/kingoftown/usbc_config.c b/board/kingoftown/usbc_config.c
index f0f17e93a9..eafd55bcf2 100644
--- a/board/kingoftown/usbc_config.c
+++ b/board/kingoftown/usbc_config.c
@@ -225,6 +225,7 @@ void board_tcpc_init(void)
/* Enable PPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -333,8 +334,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -346,8 +347,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/kinox/board.c b/board/kinox/board.c
index 7c55fba876..7d9955e05f 100644
--- a/board/kinox/board.c
+++ b/board/kinox/board.c
@@ -100,8 +100,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
}
diff --git a/board/kracko/board.c b/board/kracko/board.c
index 136b05ea1e..47bf6a7687 100644
--- a/board/kracko/board.c
+++ b/board/kracko/board.c
@@ -582,19 +582,17 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
/* Limit C1 on board version 0 to 2.0 A */
if ((board_version == 0) && (port == 1))
- icl = MIN(icl, 2000);
+ charge_ma = MIN(charge_ma, 2000);
/*
* TODO(b/151955431): Characterize the input current limit in case a
* scaling needs to be applied here
*/
- charge_set_input_current_limit(icl, charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
int board_set_active_charge_port(int port)
diff --git a/board/kuldax/led.c b/board/kuldax/led.c
index 39b79e2196..2fabc26a9a 100644
--- a/board/kuldax/led.c
+++ b/board/kuldax/led.c
@@ -259,8 +259,8 @@ int led_set_brightness(enum ec_led_id id, const uint8_t *brightness)
else
return set_color(id, LED_OFF, 0);
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Blink alert if insufficient power per system_can_boot_ap(). */
int insufficient_power =
diff --git a/board/kuldax/sensors.c b/board/kuldax/sensors.c
index 96f49de8a3..a41d5be713 100644
--- a/board/kuldax/sensors.c
+++ b/board/kuldax/sensors.c
@@ -46,11 +46,11 @@ const struct adc_t adc_channels[] = {
.factor_mul = ADC_MAX_VOLT * 39,
.factor_div = (ADC_READ_MAX + 1) * 5,
},
- [ADC_PPVAR_IMON] = { /* 872.3 mV/A */
+ [ADC_PPVAR_IMON] = { /* 20/(20+8.66)*50/200 */
.name = "PPVAR_IMON",
.input_ch = NPCX_ADC_CH3,
- .factor_mul = ADC_MAX_VOLT * 1433,
- .factor_div = (ADC_READ_MAX + 1) * 1250,
+ .factor_mul = ADC_MAX_VOLT * 143,
+ .factor_div = (ADC_READ_MAX + 1) * 25,
},
};
diff --git a/board/lalala/board.c b/board/lalala/board.c
index 78404d6821..f0f354fcf3 100644
--- a/board/lalala/board.c
+++ b/board/lalala/board.c
@@ -397,19 +397,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/lalala/board.h b/board/lalala/board.h
index 4967e49752..2996ad3613 100644
--- a/board/lalala/board.h
+++ b/board/lalala/board.h
@@ -33,6 +33,11 @@
#undef CONFIG_CMD_CHARGER_DUMP
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
/* GPIO for C1 interrupts, for baseboard use */
#define GPIO_USB_C1_INT_ODL GPIO_SUB_USB_C1_INT_ODL
diff --git a/board/lantis/board.c b/board/lantis/board.c
index 08fc84e222..9917231474 100644
--- a/board/lantis/board.c
+++ b/board/lantis/board.c
@@ -719,18 +719,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * TODO(b/151955431): Characterize the input current limit in case a
- * scaling needs to be applied here
- */
- charge_set_input_current_limit(icl, charge_mv);
-}
-
int board_set_active_charge_port(int port)
{
int is_valid_port = (port >= 0 && port < board_get_usb_pd_port_count());
diff --git a/board/lazor/usbc_config.c b/board/lazor/usbc_config.c
index 11cc649573..26a8a5692d 100644
--- a/board/lazor/usbc_config.c
+++ b/board/lazor/usbc_config.c
@@ -263,6 +263,7 @@ void board_tcpc_init(void)
/* Enable PPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -370,8 +371,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -383,8 +384,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/lisbon/led.c b/board/lisbon/led.c
index 842cee0530..a4b9a0d094 100644
--- a/board/lisbon/led.c
+++ b/board/lisbon/led.c
@@ -249,8 +249,8 @@ int led_set_brightness(enum ec_led_id id, const uint8_t *brightness)
else
return set_color(id, LED_OFF, 0);
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Blink alert if insufficient power per system_can_boot_ap(). */
int insufficient_power =
diff --git a/board/madoo/board.c b/board/madoo/board.c
index eedf8e6fdd..77c939143a 100644
--- a/board/madoo/board.c
+++ b/board/madoo/board.c
@@ -312,20 +312,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- reduce
- * our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/madoo/board.h b/board/madoo/board.h
index 82cfa30b0e..0d5e24c2a0 100644
--- a/board/madoo/board.h
+++ b/board/madoo/board.h
@@ -19,6 +19,11 @@
#define CONFIG_OCPC_DEF_RBATT_MOHMS \
22 /* R_DS(on) 11.6mOhm + 10mOhm sns rstr \
*/
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
#define CONFIG_OCPC
#undef CONFIG_CHARGER_SINGLE_CHIP
diff --git a/board/magolor/board.c b/board/magolor/board.c
index bfa77375e5..3ddc1af3d1 100644
--- a/board/magolor/board.c
+++ b/board/magolor/board.c
@@ -415,6 +415,8 @@ void board_hibernate(void)
if (board_get_charger_chip_count() > 1)
raa489000_hibernate(1, true);
raa489000_hibernate(0, true);
+
+ msleep(1000); /* Wait for charger to enter low power mode */
}
void board_reset_pd_mcu(void)
@@ -593,19 +595,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/magolor/board.h b/board/magolor/board.h
index 481856323f..beb2cc279c 100644
--- a/board/magolor/board.h
+++ b/board/magolor/board.h
@@ -45,6 +45,11 @@
#undef CONFIG_CMD_CHARGER_DUMP
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
/* GPIO for C1 interrupts, for baseboard use */
#define GPIO_USB_C1_INT_ODL GPIO_SUB_C1_INT_EN_RAILS_ODL
diff --git a/board/makomo/board.c b/board/makomo/board.c
index 24b34d9a75..5a7158b58a 100644
--- a/board/makomo/board.c
+++ b/board/makomo/board.c
@@ -235,14 +235,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/makomo/board.h b/board/makomo/board.h
index bf705e9560..86e5e78862 100644
--- a/board/makomo/board.h
+++ b/board/makomo/board.h
@@ -27,6 +27,7 @@
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_RUNTIME_CONFIG
diff --git a/board/marasov/battery.c b/board/marasov/battery.c
new file mode 100644
index 0000000000..b974930d5b
--- /dev/null
+++ b/board/marasov/battery.c
@@ -0,0 +1,77 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Battery pack vendor provided charging profile
+ */
+
+#include "battery_fuel_gauge.h"
+#include "cbi.h"
+#include "common.h"
+#include "compile_time_macros.h"
+#include "gpio.h"
+/*
+ * Battery info for all Brya battery types. Note that the fields
+ * start_charging_min/max and charging_min/max are not used for the charger.
+ * The effective temperature limits are given by discharging_min/max_c.
+ *
+ * Fuel Gauge (FG) parameters which are used for determining if the battery
+ * is connected, the appropriate ship mode (battery cutoff) command, and the
+ * charge/discharge FETs status.
+ *
+ * Ship mode (battery cutoff) requires 2 writes to the appropriate smart battery
+ * register. For some batteries, the charge/discharge FET bits are set when
+ * charging/discharging is active, in other types, these bits set mean that
+ * charging/discharging is disabled. Therefore, in addition to the mask for
+ * these bits, a disconnect value must be specified. Note that for TI fuel
+ * gauge, the charge/discharge FET status is found in Operation Status (0x54),
+ * but a read of Manufacturer Access (0x00) will return the lower 16 bits of
+ * Operation status which contains the FET status bits.
+ *
+ * The assumption for battery types supported is that the charge/discharge FET
+ * status can be read with a sb_read() command and therefore, only the register
+ * address, mask, and disconnect value need to be provided.
+ */
+const struct board_batt_params board_battery_info[] = {
+ /* C490-42 Battery Information */
+ [BATTERY_C490] = {
+ .fuel_gauge = {
+ .manuf_name = "AS3GWQd3jB",
+ .device_name = "C490-42",
+ .ship_mode = {
+ .reg_addr = 0x00,
+ .reg_data = { 0x0010, 0x0010 },
+ },
+ .fet = {
+ .reg_addr = 0x99,
+ .reg_mask = 0x000c,
+ .disconnect_val = 0x000c,
+ }
+ },
+ .batt_info = {
+ .voltage_max = 13200, /* mV */
+ .voltage_normal = 11880, /* mV */
+ .voltage_min = 9000, /* mV */
+ .precharge_current = 256, /* mA */
+ .start_charging_min_c = 0,
+ .start_charging_max_c = 45,
+ .charging_min_c = 0,
+ .charging_max_c = 60,
+ .discharging_min_c = -20,
+ .discharging_max_c = 60,
+ },
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT);
+
+const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_C490;
+
+enum battery_present battery_hw_present(void)
+{
+ enum gpio_signal batt_pres;
+
+ batt_pres = GPIO_EC_BATT_PRES_ODL;
+
+ /* The GPIO is low when the battery is physically present */
+ return gpio_get_level(batt_pres) ? BP_NO : BP_YES;
+}
diff --git a/board/marasov/board.c b/board/marasov/board.c
new file mode 100644
index 0000000000..e48dfaa163
--- /dev/null
+++ b/board/marasov/board.c
@@ -0,0 +1,52 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "button.h"
+#include "cbi.h"
+#include "charge_ramp.h"
+#include "charger.h"
+#include "common.h"
+#include "console.h"
+#include "driver/accelgyro_lsm6dso.h"
+#include "driver/accel_lis2dw12.h"
+#include "driver/als_tcs3400.h"
+#include "fw_config.h"
+#include "gpio.h"
+#include "gpio_signal.h"
+#include "hooks.h"
+#include "lid_switch.h"
+#include "power_button.h"
+#include "power.h"
+#include "registers.h"
+#include "switch.h"
+#include "tablet_mode.h"
+#include "throttle_ap.h"
+#include "usbc_config.h"
+
+#include "gpio_list.h" /* Must come after other header files. */
+
+/* Console output macros */
+#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args)
+
+/* Called on AP S3 -> S0 transition */
+static void board_chipset_resume(void)
+{
+ /* Allow keyboard backlight to be enabled */
+
+ if (IS_ENABLED(CONFIG_PWM_KBLIGHT))
+ gpio_set_level(GPIO_EC_KB_BL_EN_L, 0);
+}
+DECLARE_HOOK(HOOK_CHIPSET_RESUME, board_chipset_resume, HOOK_PRIO_DEFAULT);
+
+/* Called on AP S0 -> S3 transition */
+static void board_chipset_suspend(void)
+{
+ /* Turn off the keyboard backlight if it's on. */
+
+ if (IS_ENABLED(CONFIG_PWM_KBLIGHT))
+ gpio_set_level(GPIO_EC_KB_BL_EN_L, 1);
+}
+DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, board_chipset_suspend, HOOK_PRIO_DEFAULT);
diff --git a/board/marasov/board.h b/board/marasov/board.h
new file mode 100644
index 0000000000..6cb0225edc
--- /dev/null
+++ b/board/marasov/board.h
@@ -0,0 +1,217 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Brya board configuration */
+
+#ifndef __CROS_EC_BOARD_H
+#define __CROS_EC_BOARD_H
+
+#include "compile_time_macros.h"
+
+/*
+ * Early brya boards are not set up for vivaldi
+ */
+#undef CONFIG_KEYBOARD_VIVALDI
+
+/* Baseboard features */
+#include "baseboard.h"
+
+/*
+ * This will happen automatically on NPCX9 ES2 and later. Do not remove
+ * until we can confirm all earlier chips are out of service.
+ */
+#define CONFIG_HIBERNATE_PSL_VCC1_RST_WAKEUP
+
+#define CONFIG_MP2964
+
+/* LED */
+#define CONFIG_LED_ONOFF_STATES
+#define CONFIG_LED_ONOFF_STATES_BAT_LOW 10
+
+#undef CONFIG_TABLET_MODE
+#undef CONFIG_TABLET_MODE_SWITCH
+#undef CONFIG_GMR_TABLET_MODE
+#undef CONFIG_VOLUME_BUTTONS
+
+/* USB Type A Features */
+#define USB_PORT_COUNT 2
+#define CONFIG_USB_PORT_POWER_DUMB
+
+/* USB Type C and USB PD defines */
+#define CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY
+
+#define CONFIG_IO_EXPANDER
+#define CONFIG_IO_EXPANDER_NCT38XX
+#define CONFIG_IO_EXPANDER_PORT_COUNT 1
+
+#define CONFIG_USB_PD_FRS_PPC
+
+#define CONFIG_USB_PD_TCPM_PS8815
+#define CONFIG_USB_PD_TCPM_PS8815_FORCE_DID
+#define CONFIG_USBC_RETIMER_INTEL_BB
+#undef CONFIG_BC12_DETECT_PI3USB9201
+#undef CONFIG_USB_CHARGER
+
+/* Battery Configuration */
+#define CONFIG_SMBUS_PEC
+#undef CONFIG_BATT_HOST_FULL_FACTOR
+#define CONFIG_BATT_HOST_FULL_FACTOR 99
+
+/* I2C speed console command */
+#define CONFIG_CMD_I2C_SPEED
+
+/* I2C control host command */
+#define CONFIG_HOSTCMD_I2C_CONTROL
+
+#define CONFIG_USBC_PPC_SYV682X
+
+/* TODO: b/177608416 - measure and check these values on brya */
+#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
+#define PD_POWER_SUPPLY_TURN_OFF_DELAY 30000 /* us */
+#define PD_VCONN_SWAP_DELAY 5000 /* us */
+
+/*
+ * Passive USB-C cables only support up to 60W.
+ */
+#define PD_OPERATING_POWER_MW 15000
+#define PD_MAX_POWER_MW 60000
+#define PD_MAX_CURRENT_MA 3000
+#define PD_MAX_VOLTAGE_MV 20000
+
+/*
+ * Macros for GPIO signals used in common code that don't match the
+ * schematic names. Signal names in gpio.inc match the schematic and are
+ * then redefined here to so it's more clear which signal is being used for
+ * which purpose.
+ */
+#define GPIO_AC_PRESENT GPIO_ACOK_OD
+#define GPIO_CPU_PROCHOT GPIO_EC_PROCHOT_ODL
+#define GPIO_EC_INT_L GPIO_EC_PCH_INT_ODL
+#define GPIO_ENABLE_BACKLIGHT GPIO_EC_EN_EDP_BL
+#define GPIO_ENTERING_RW GPIO_EC_ENTERING_RW
+#define GPIO_KBD_KSO2 GPIO_EC_KSO_02_INV
+#define GPIO_PACKET_MODE_EN GPIO_EC_GSC_PACKET_MODE
+#define GPIO_PCH_PWRBTN_L GPIO_EC_PCH_PWR_BTN_ODL
+#define GPIO_PCH_RSMRST_L GPIO_EC_PCH_RSMRST_L
+#define GPIO_PCH_RTCRST GPIO_EC_PCH_RTCRST
+#define GPIO_PCH_SLP_S0_L GPIO_SYS_SLP_S0IX_L
+#define GPIO_PCH_SLP_S3_L GPIO_SLP_S3_L
+#define GPIO_TEMP_SENSOR_POWER GPIO_SEQ_EC_DSW_PWROK
+
+/*
+ * GPIO_EC_PCH_INT_ODL is used for MKBP events as well as a PCH wakeup
+ * signal.
+ */
+#define GPIO_PCH_WAKE_L GPIO_EC_PCH_INT_ODL
+#define GPIO_PG_EC_ALL_SYS_PWRGD GPIO_SEQ_EC_ALL_SYS_PG
+#define GPIO_PG_EC_DSW_PWROK GPIO_SEQ_EC_DSW_PWROK
+#define GPIO_PG_EC_RSMRST_ODL GPIO_SEQ_EC_RSMRST_ODL
+#define GPIO_POWER_BUTTON_L GPIO_GSC_EC_PWR_BTN_ODL
+#define GPIO_SYS_RESET_L GPIO_SYS_RST_ODL
+#define GPIO_VOLUME_DOWN_L GPIO_EC_VOLDN_BTN_ODL
+#define GPIO_VOLUME_UP_L GPIO_EC_VOLUP_BTN_ODL
+#define GPIO_WP_L GPIO_EC_WP_ODL
+
+/* System has back-lit keyboard */
+#define CONFIG_PWM_KBLIGHT
+
+/* I2C Bus Configuration */
+
+#define I2C_PORT_SENSOR NPCX_I2C_PORT0_0
+
+#define I2C_PORT_USB_C0_TCPC NPCX_I2C_PORT1_0
+#define I2C_PORT_USB_C1_TCPC NPCX_I2C_PORT4_1
+
+#define I2C_PORT_USB_C0_PPC NPCX_I2C_PORT2_0
+#define I2C_PORT_USB_C1_PPC NPCX_I2C_PORT6_1
+
+#define I2C_PORT_USB_C0_MUX NPCX_I2C_PORT3_0
+#define I2C_PORT_USB_C1_MUX NPCX_I2C_PORT6_1
+
+#define I2C_PORT_BATTERY NPCX_I2C_PORT5_0
+#define I2C_PORT_CHARGER NPCX_I2C_PORT7_0
+#define I2C_PORT_EEPROM NPCX_I2C_PORT7_0
+#define I2C_PORT_MP2964 NPCX_I2C_PORT7_0
+
+#define I2C_ADDR_EEPROM_FLAGS 0x50
+
+#define I2C_ADDR_MP2964_FLAGS 0x20
+
+/*
+ * see b/174768555#comment22
+ */
+#define USBC_PORT_C0_BB_RETIMER_I2C_ADDR 0x56
+
+/* Enabling Thunderbolt-compatible mode */
+#define CONFIG_USB_PD_TBT_COMPAT_MODE
+
+/* Enabling USB4 mode */
+#define CONFIG_USB_PD_USB4
+#define CONFIG_USB_PD_DATA_RESET_MSG
+
+/* Retimer */
+#define CONFIG_USBC_RETIMER_FW_UPDATE
+
+/* Thermal features */
+#define CONFIG_THERMISTOR
+#define CONFIG_TEMP_SENSOR
+#define CONFIG_TEMP_SENSOR_POWER
+#define CONFIG_STEINHART_HART_3V3_30K9_47K_4050B
+
+#define CONFIG_FANS FAN_CH_COUNT
+
+/* Charger defines */
+#define CONFIG_CHARGER_BQ25720
+#define CONFIG_CHARGER_BQ25720_VSYS_TH2_CUSTOM
+#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV 70
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR 10
+#define CONFIG_CHARGER_BQ25710_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_BQ25710_PSYS_SENSING
+
+/*
+ * Older boards have a different ADC assignment.
+ */
+
+#define CONFIG_ADC_CHANNELS_RUNTIME_CONFIG
+
+#ifndef __ASSEMBLER__
+
+#include "gpio_signal.h" /* needed by registers.h */
+#include "registers.h"
+#include "usbc_config.h"
+
+enum adc_channel {
+ ADC_TEMP_SENSOR_1_DDR_SOC,
+ ADC_TEMP_SENSOR_2_AMBIENT,
+ ADC_TEMP_SENSOR_3_CHARGER,
+ ADC_TEMP_SENSOR_4_WWAN,
+ ADC_CH_COUNT
+};
+
+enum temp_sensor_id {
+ TEMP_SENSOR_1_DDR_SOC,
+ TEMP_SENSOR_2_AMBIENT,
+ TEMP_SENSOR_3_CHARGER,
+ TEMP_SENSOR_4_WWAN,
+ TEMP_SENSOR_COUNT
+};
+
+enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_PORT_COUNT };
+
+enum battery_type { BATTERY_C490, BATTERY_TYPE_COUNT };
+
+enum pwm_channel {
+ PWM_CH_KBLIGHT, /* PWM3 */
+ PWM_CH_FAN, /* PWM5 */
+ PWM_CH_COUNT
+};
+
+enum fan_channel { FAN_CH_0 = 0, FAN_CH_COUNT };
+
+enum mft_channel { MFT_CH_0 = 0, MFT_CH_COUNT };
+
+#endif /* !__ASSEMBLER__ */
+
+#endif /* __CROS_EC_BOARD_H */
diff --git a/board/marasov/build.mk b/board/marasov/build.mk
new file mode 100644
index 0000000000..8b85854cf0
--- /dev/null
+++ b/board/marasov/build.mk
@@ -0,0 +1,25 @@
+# -*- makefile -*-
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# Brya board specific files build
+#
+
+CHIP:=npcx
+CHIP_FAMILY:=npcx9
+CHIP_VARIANT:=npcx9m3f
+BASEBOARD:=brya
+
+board-y=
+board-y+=battery.o
+board-y+=board.o
+board-y+=charger.o
+board-y+=fans.o
+board-y+=fw_config.o
+board-y+=i2c.o
+board-y+=keyboard.o
+board-y+=led.o
+board-y+=pwm.o
+board-y+=sensors.o
+board-y+=usbc_config.o
diff --git a/board/marasov/charger.c b/board/marasov/charger.c
new file mode 100644
index 0000000000..68fff4f283
--- /dev/null
+++ b/board/marasov/charger.c
@@ -0,0 +1,83 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+
+#include "charge_manager.h"
+#include "charge_state_v2.h"
+#include "charger.h"
+#include "compile_time_macros.h"
+#include "console.h"
+#include "driver/charger/bq25710.h"
+#include "usbc_ppc.h"
+#include "usb_pd.h"
+#include "util.h"
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+#ifndef CONFIG_ZEPHYR
+/* Charger Chip Configuration */
+const struct charger_config_t chg_chips[] = {
+ {
+ .i2c_port = I2C_PORT_CHARGER,
+ .i2c_addr_flags = BQ25710_SMBUS_ADDR1_FLAGS,
+ .drv = &bq25710_drv,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(chg_chips) == CHARGER_NUM);
+#endif
+
+int board_set_active_charge_port(int port)
+{
+ int is_valid_port = board_is_usb_pd_port_present(port);
+ int i;
+
+ if (port == CHARGE_PORT_NONE) {
+ CPRINTSUSB("Disabling all charger ports");
+
+ /* Disable all ports. */
+ for (i = 0; i < ppc_cnt; i++) {
+ /*
+ * Do not return early if one fails otherwise we can
+ * get into a boot loop assertion failure.
+ */
+ if (ppc_vbus_sink_enable(i, 0))
+ CPRINTSUSB("Disabling C%d as sink failed.", i);
+ }
+
+ return EC_SUCCESS;
+ } else if (!is_valid_port) {
+ return EC_ERROR_INVAL;
+ }
+
+ /* Check if the port is sourcing VBUS. */
+ if (ppc_is_sourcing_vbus(port)) {
+ CPRINTFUSB("Skip enable C%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+ CPRINTSUSB("New charge port: C%d", port);
+
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < ppc_cnt; i++) {
+ if (i == port)
+ continue;
+
+ if (ppc_vbus_sink_enable(i, 0))
+ CPRINTSUSB("C%d: sink path disable failed.", i);
+ }
+
+ /* Enable requested charge port. */
+ if (ppc_vbus_sink_enable(port, 1)) {
+ CPRINTSUSB("C%d: sink path enable failed.", port);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ return EC_SUCCESS;
+}
diff --git a/board/marasov/ec.tasklist b/board/marasov/ec.tasklist
new file mode 100644
index 0000000000..a4039fc94f
--- /dev/null
+++ b/board/marasov/ec.tasklist
@@ -0,0 +1,26 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+ * See CONFIG_TASK_LIST in config.h for details.
+ *
+ * USB_CHG_Px tasks must be contiguous (see USB_CHG_PORT_TO_TASK_ID(x)).
+ * PD_Cx tasks must be contiguous (see PD_PORT_TO_TASK_ID(x))
+ */
+
+#define CONFIG_TASK_LIST \
+ TASK_ALWAYS(HOOKS, hook_task, NULL, HOOKS_TASK_STACK_SIZE) \
+ TASK_ALWAYS(CHARGER, charger_task, NULL, BASEBOARD_CHARGER_TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYPROTO, keyboard_protocol_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_NOTEST(CHIPSET, chipset_task, NULL, BASEBOARD_CHIPSET_TASK_STACK_SIZE) \
+ TASK_ALWAYS(USB_MUX, usb_mux_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, CONSOLE_TASK_STACK_SIZE) \
+ TASK_ALWAYS(POWERBTN, power_button_task, NULL, BASEBOARD_POWERBTN_TASK_STACK_SIZE) \
+ TASK_NOTEST(KEYSCAN, keyboard_scan_task, NULL, VENTI_TASK_STACK_SIZE) \
+ TASK_ALWAYS(PD_C0, pd_task, NULL, BASEBOARD_PD_TASK_STACK_SIZE) \
+ TASK_ALWAYS(PD_C1, pd_task, NULL, BASEBOARD_PD_TASK_STACK_SIZE) \
+ TASK_ALWAYS(PD_INT_C0, pd_interrupt_handler_task, 0, BASEBOARD_PD_INT_TASK_STACK_SIZE) \
+ TASK_ALWAYS(PD_INT_C1, pd_interrupt_handler_task, 1, BASEBOARD_PD_INT_TASK_STACK_SIZE)
diff --git a/board/marasov/fans.c b/board/marasov/fans.c
new file mode 100644
index 0000000000..158f4bf704
--- /dev/null
+++ b/board/marasov/fans.c
@@ -0,0 +1,89 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Physical fans. These are logically separate from pwm_channels. */
+
+#include "common.h"
+#include "compile_time_macros.h"
+#include "console.h"
+#include "fan_chip.h"
+#include "fan.h"
+#include "hooks.h"
+#include "pwm.h"
+
+/* MFT channels. These are logically separate from pwm_channels. */
+const struct mft_t mft_channels[] = {
+ [MFT_CH_0] = {
+ .module = NPCX_MFT_MODULE_1,
+ .clk_src = TCKC_LFCLK,
+ .pwm_id = PWM_CH_FAN,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(mft_channels) == MFT_CH_COUNT);
+
+static const struct fan_conf fan_conf_0 = {
+ .flags = FAN_USE_RPM_MODE,
+ .ch = MFT_CH_0, /* Use MFT id to control fan */
+ .pgood_gpio = -1,
+ .enable_gpio = GPIO_EN_PP5000_FAN,
+};
+
+/*
+ * TOOD(b/181271666): thermistor placement and calibration
+ *
+ * Prototype fan spins at about 4200 RPM at 100% PWM, this
+ * is specific to board ID 2 and might also apears in later
+ * boards as well.
+ */
+static const struct fan_rpm fan_rpm_0 = {
+ .rpm_min = 2200,
+ .rpm_start = 2200,
+ .rpm_max = 4200,
+};
+
+const struct fan_t fans[FAN_CH_COUNT] = {
+ [FAN_CH_0] = {
+ .conf = &fan_conf_0,
+ .rpm = &fan_rpm_0,
+ },
+};
+
+#ifndef CONFIG_FANS
+
+/*
+ * TODO(b/181271666): use static fan speeds until fan and sensors are
+ * tuned. for now, use:
+ *
+ * AP off: 33%
+ * AP on: 100%
+ */
+
+static void fan_slow(void)
+{
+ const int duty_pct = 33;
+
+ ccprints("%s: speed %d%%", __func__, duty_pct);
+
+ pwm_enable(PWM_CH_FAN, 1);
+ pwm_set_duty(PWM_CH_FAN, duty_pct);
+}
+
+static void fan_max(void)
+{
+ const int duty_pct = 100;
+
+ ccprints("%s: speed %d%%", __func__, duty_pct);
+
+ pwm_enable(PWM_CH_FAN, 1);
+ pwm_set_duty(PWM_CH_FAN, duty_pct);
+}
+
+DECLARE_HOOK(HOOK_INIT, fan_slow, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, fan_slow, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, fan_slow, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_CHIPSET_RESET, fan_max, HOOK_PRIO_FIRST);
+DECLARE_HOOK(HOOK_CHIPSET_RESUME, fan_max, HOOK_PRIO_DEFAULT);
+
+#endif /* CONFIG_FANS */
diff --git a/board/marasov/fw_config.c b/board/marasov/fw_config.c
new file mode 100644
index 0000000000..375f5e965b
--- /dev/null
+++ b/board/marasov/fw_config.c
@@ -0,0 +1,46 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "cbi.h"
+#include "common.h"
+#include "compile_time_macros.h"
+#include "console.h"
+#include "cros_board_info.h"
+#include "fw_config.h"
+
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
+
+static union brya_cbi_fw_config fw_config;
+BUILD_ASSERT(sizeof(fw_config) == sizeof(uint32_t));
+
+/*
+ * FW_CONFIG defaults for brya if the CBI.FW_CONFIG data is not
+ * initialized.
+ */
+static const union brya_cbi_fw_config fw_config_defaults = {
+ .usb_db = DB_USB3_PS8815,
+ .kb_bl = KEYBOARD_BACKLIGHT_ENABLED,
+};
+
+/****************************************************************************
+ * Brya FW_CONFIG access
+ */
+void board_init_fw_config(void)
+{
+ if (cbi_get_fw_config(&fw_config.raw_value)) {
+ CPRINTS("CBI: Read FW_CONFIG failed, using board defaults");
+ fw_config = fw_config_defaults;
+ }
+}
+
+union brya_cbi_fw_config get_fw_config(void)
+{
+ return fw_config;
+}
+
+enum ec_cfg_usb_db_type ec_cfg_usb_db_type(void)
+{
+ return fw_config.usb_db;
+}
diff --git a/board/marasov/fw_config.h b/board/marasov/fw_config.h
new file mode 100644
index 0000000000..906e61fe7e
--- /dev/null
+++ b/board/marasov/fw_config.h
@@ -0,0 +1,52 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __BOARD_BRYA_FW_CONFIG_H_
+#define __BOARD_BRYA_FW_CONFIG_H_
+
+#include <stdint.h>
+
+/****************************************************************************
+ * CBI FW_CONFIG layout for Brya board.
+ *
+ * Source of truth is the project/brya/brya/config.star configuration file.
+ */
+
+enum ec_cfg_usb_db_type {
+ DB_USB3_PS8815 = 0,
+};
+
+enum ec_cfg_keyboard_backlight_type {
+ KEYBOARD_BACKLIGHT_DISABLED = 0,
+ KEYBOARD_BACKLIGHT_ENABLED = 1
+};
+
+union brya_cbi_fw_config {
+ struct {
+ enum ec_cfg_usb_db_type usb_db : 4;
+ uint32_t sd_db : 2;
+ uint32_t lte_db : 1;
+ enum ec_cfg_keyboard_backlight_type kb_bl : 1;
+ uint32_t audio : 3;
+ uint32_t reserved_1 : 21;
+ };
+ uint32_t raw_value;
+};
+
+/**
+ * Read the cached FW_CONFIG. Guaranteed to have valid values.
+ *
+ * @return the FW_CONFIG for the board.
+ */
+union brya_cbi_fw_config get_fw_config(void);
+
+/**
+ * Get the USB daughter board type from FW_CONFIG.
+ *
+ * @return the USB daughter board type.
+ */
+enum ec_cfg_usb_db_type ec_cfg_usb_db_type(void);
+
+#endif /* __BOARD_BRYA_FW_CONFIG_H_ */
diff --git a/board/marasov/generated-gpio.inc b/board/marasov/generated-gpio.inc
new file mode 100644
index 0000000000..f01f5b790b
--- /dev/null
+++ b/board/marasov/generated-gpio.inc
@@ -0,0 +1,127 @@
+/*
+ * This file was auto-generated.
+ */
+
+/* INTERRUPT GPIOs: */
+GPIO_INT(ACOK_OD, PIN(0, 0), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, extpower_interrupt)
+GPIO_INT(EC_PROCHOT_IN_L, PIN(F, 0), GPIO_INT_BOTH, throttle_ap_prochot_input_interrupt)
+GPIO_INT(EC_WP_ODL, PIN(A, 1), GPIO_INT_BOTH, switch_interrupt)
+GPIO_INT(GSC_EC_PWR_BTN_ODL, PIN(0, 1), GPIO_INT_BOTH | GPIO_HIB_WAKE_LOW, power_button_interrupt)
+GPIO_INT(LID_OPEN, PIN(D, 2), GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH, lid_interrupt)
+GPIO_INT(SEQ_EC_ALL_SYS_PG, PIN(F, 4), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(SEQ_EC_DSW_PWROK, PIN(C, 7), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(SEQ_EC_RSMRST_ODL, PIN(E, 2), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(SLP_S3_L, PIN(A, 5), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(SLP_SUS_L, PIN(F, 1), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(SYS_SLP_S0IX_L, PIN(D, 5), GPIO_INT_BOTH, power_signal_interrupt)
+GPIO_INT(USB_C0_TCPC_INT_ODL, PIN(E, 0), GPIO_INT_FALLING, tcpc_alert_event)
+GPIO_INT(USB_C0_PPC_INT_ODL, PIN(6, 2), GPIO_INT_FALLING, ppc_interrupt)
+GPIO_INT(USB_C0_RT_INT_ODL, PIN(B, 1), GPIO_INT_FALLING, retimer_interrupt)
+GPIO_INT(USB_C1_PPC_INT_ODL, PIN(F, 5), GPIO_INT_FALLING, ppc_interrupt)
+GPIO_INT(USB_C1_TCPC_INT_ODL, PIN(A, 2), GPIO_INT_FALLING, tcpc_alert_event)
+
+/* USED GPIOs: */
+GPIO(CCD_MODE_ODL, PIN(E, 5), GPIO_INPUT)
+GPIO(CHARGER_VAP_OTG_EN, PIN(7, 3), GPIO_OUT_LOW)
+GPIO(CPU_C10_GATE_L, PIN(6, 7), GPIO_INPUT)
+GPIO(EC_BATT_PRES_ODL, PIN(A, 3), GPIO_INPUT)
+GPIO(EC_ENTERING_RW, PIN(0, 3), GPIO_OUT_LOW)
+GPIO(EC_EN_EDP_BL, PIN(D, 3), GPIO_OUT_HIGH)
+GPIO(EC_GSC_PACKET_MODE, PIN(7, 5), GPIO_OUT_LOW)
+GPIO(EC_I2C_BAT_SCL, PIN(3, 3), GPIO_INPUT)
+GPIO(EC_I2C_BAT_SDA, PIN(3, 6), GPIO_INPUT)
+GPIO(EC_I2C_MISC_SCL_R, PIN(B, 3), GPIO_INPUT)
+GPIO(EC_I2C_MISC_SDA_R, PIN(B, 2), GPIO_INPUT)
+GPIO(EC_I2C_SENSOR_SCL, PIN(B, 5), GPIO_INPUT | GPIO_SEL_1P8V)
+GPIO(EC_I2C_SENSOR_SDA, PIN(B, 4), GPIO_INPUT | GPIO_SEL_1P8V)
+GPIO(EC_I2C_USB_C0_PPC_BC_SCL, PIN(9, 2), GPIO_INPUT)
+GPIO(EC_I2C_USB_C0_PPC_BC_SDA, PIN(9, 1), GPIO_INPUT)
+GPIO(EC_I2C_USB_C0_RT_SCL, PIN(D, 1), GPIO_INPUT)
+GPIO(EC_I2C_USB_C0_RT_SDA, PIN(D, 0), GPIO_INPUT)
+GPIO(EC_I2C_USB_C0_TCPC_SCL, PIN(9, 0), GPIO_INPUT)
+GPIO(EC_I2C_USB_C0_TCPC_SDA, PIN(8, 7), GPIO_INPUT)
+GPIO(EC_I2C_USB_C1_MIX_SCL, PIN(E, 4), GPIO_INPUT)
+GPIO(EC_I2C_USB_C1_MIX_SDA, PIN(E, 3), GPIO_INPUT)
+GPIO(EC_I2C_USB_C1_TCPC_SCL, PIN(F, 3), GPIO_INPUT)
+GPIO(EC_I2C_USB_C1_TCPC_SDA, PIN(F, 2), GPIO_INPUT)
+GPIO(EC_KB_BL_EN_L, PIN(8, 6), GPIO_OUT_HIGH)
+GPIO(EC_PCHHOT_ODL, PIN(7, 4), GPIO_INPUT)
+GPIO(EC_PCH_INT_ODL, PIN(B, 0), GPIO_ODR_HIGH)
+GPIO(EC_PCH_PWR_BTN_ODL, PIN(C, 1), GPIO_ODR_HIGH)
+GPIO(EC_PCH_RSMRST_L, PIN(A, 6), GPIO_OUT_LOW)
+GPIO(EC_PCH_RTCRST, PIN(7, 6), GPIO_OUT_LOW)
+GPIO(EC_PCH_SYS_PWROK, PIN(3, 7), GPIO_OUT_LOW)
+GPIO(EC_PCH_WAKE_R_ODL, PIN(C, 0), GPIO_ODR_HIGH)
+GPIO(EC_PROCHOT_ODL, PIN(6, 3), GPIO_ODR_HIGH)
+GPIO(EN_PP5000_FAN, PIN(6, 1), GPIO_OUT_HIGH)
+GPIO(EN_PP5000_USBA_R, PIN(D, 7), GPIO_OUT_LOW)
+GPIO(EN_S5_RAILS, PIN(B, 6), GPIO_OUT_LOW)
+GPIO(IMVP9_VRRDY_OD, PIN(4, 3), GPIO_INPUT)
+GPIO(PCH_PWROK, PIN(7, 2), GPIO_OUT_LOW)
+GPIO(SYS_RST_ODL, PIN(C, 5), GPIO_ODR_HIGH)
+GPIO(USB_C0_TCPC_RST_ODL, PIN(A, 7), GPIO_ODR_LOW)
+GPIO(USB_C1_FRS_EN, PIN(9, 4), GPIO_OUT_LOW)
+GPIO(USB_C1_OC_ODL, PIN(9, 6), GPIO_ODR_HIGH)
+GPIO(USB_C1_RT_INT_ODL, PIN(A, 0), GPIO_INPUT)
+GPIO(USB_C1_RT_RST_R_ODL, PIN(0, 2), GPIO_ODR_LOW)
+GPIO(VCCST_PWRGD_OD, PIN(A, 4), GPIO_ODR_LOW)
+GPIO(PWR_LED_W_ODL, PIN(6, 0), GPIO_OUT_HIGH)
+GPIO(PWR_LED_A_ODL, PIN(C, 2), GPIO_OUT_HIGH)
+
+/* UART alternate functions */
+ALTERNATE(PIN_MASK(6, 0x30), 0, MODULE_UART, 0) /* GPIO64/CR_SIN1, GPO65/CR_SOUT1/FLPRG1_L */
+
+/* I2C alternate functions */
+ALTERNATE(PIN_MASK(3, 0x48), 0, MODULE_I2C, 0) /* GPIO33/I2C5_SCL0/CTS_L, GPIO36/RTS_L/I2C5_SDA0 */
+ALTERNATE(PIN_MASK(8, 0x80), 0, MODULE_I2C, 0) /* GPIO87/I2C1_SDA0 */
+ALTERNATE(PIN_MASK(9, 0x07), 0, MODULE_I2C, 0) /* GPIO92/I2C2_SCL0, GPIO91/I2C2_SDA0, GPIO90/I2C1_SCL0 */
+ALTERNATE(PIN_MASK(B, 0x0c), 0, MODULE_I2C, 0) /* GPIOB3/I2C7_SCL0/DCD_L, GPIOB2/I2C7_SDA0/DSR_L */
+ALTERNATE(PIN_MASK(B, 0x30), 0, MODULE_I2C, GPIO_SEL_1P8V) /* GPIOB5/I2C0_SCL0, GPIOB4/I2C0_SDA0 */
+ALTERNATE(PIN_MASK(D, 0x03), 0, MODULE_I2C, 0) /* GPIOD1/I2C3_SCL0, GPIOD0/I2C3_SDA0 */
+ALTERNATE(PIN_MASK(E, 0x18), 0, MODULE_I2C, 0) /* GPIOE4/I2C6_SCL1/I3C_SCL, GPIOE3/I2C6_SDA1/I3C_SDA */
+ALTERNATE(PIN_MASK(F, 0x0c), 0, MODULE_I2C, 0) /* GPIOF3/I2C4_SCL1, GPIOF2/I2C4_SDA1 */
+
+/* PWM alternate functions */
+ALTERNATE(PIN_MASK(4, 0x01), 0, MODULE_PWM, 0) /* GPIO40/TA1 */
+ALTERNATE(PIN_MASK(8, 0x01), 0, MODULE_PWM, 0) /* GPIO80/PWM3 */
+ALTERNATE(PIN_MASK(B, 0x80), 0, MODULE_PWM, 0) /* GPIOB7/PWM5 */
+
+/* ADC alternate functions */
+ALTERNATE(PIN_MASK(3, 0x10), 0, MODULE_ADC, 0) /* GPIO34/PS2_DAT2/ADC6 */
+ALTERNATE(PIN_MASK(4, 0x34), 0, MODULE_ADC, 0) /* GPIO42/ADC3/RI_L, GPIO45/ADC0, GPIO44/ADC1 */
+ALTERNATE(PIN_MASK(E, 0x02), 0, MODULE_ADC, 0) /* GPIOE1/ADC7 */
+
+/* KB alternate functions */
+ALTERNATE(PIN_MASK(0, 0xf0), 0, MODULE_KB, GPIO_ODR_HIGH) /* KSO10&P80_CLK/GPIO07, KSO11&P80_DAT/GPIO06, KSO12/GPIO05, KSO13/GPIO04 */
+ALTERNATE(PIN_MASK(1, 0x7f), 0, MODULE_KB, GPIO_ODR_HIGH) /* KSO06/GPO13/GP_SEL_L, KSO07/GPO12/JEN_L, KSO03/GPIO16/JTAG_TDO0_SWO, KSO04/GPIO15/XNOR, KSO05/GPIO14, KSO08/GPIO11/CR_SOUT1, KSO09/GPIO10/CR_SIN1 */
+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 */
+ALTERNATE(PIN_MASK(0, 0x02), 0, MODULE_PMU, GPIO_INT_BOTH | GPIO_HIB_WAKE_LOW) /* GPIO01/PSL_IN3_L&GPI01 */
+ALTERNATE(PIN_MASK(D, 0x04), 0, MODULE_PMU, GPIO_INT_BOTH | GPIO_HIB_WAKE_HIGH) /* PSL_IN1_L&GPID2/GPIOD2 */
+
+/* Unused Pins */
+UNUSED(PIN(D, 6)) /* GPOD6/CR_SOUT3/SHDF_ESPI_L */
+UNUSED(PIN(3, 2)) /* GPO32/TRIS_L */
+UNUSED(PIN(3, 5)) /* GPO35/CR_SOUT4/TEST_L */
+UNUSED(PIN(6, 6)) /* GPIO66 */
+UNUSED(PIN(5, 7)) /* GPIO57/SER_IRQ/ESPI_ALERT_L */
+UNUSED(PIN(9, 5)) /* GPIO95 */
+UNUSED(PIN(8, 1)) /* GPIO81 */
+UNUSED(PIN(5, 6)) /* GPIO56 */
+UNUSED(PIN(D, 4)) /* GPIOD4 */
+UNUSED(PIN(9, 3)) /* GPIO93 */
+UNUSED(PIN(9, 7)) /* GPIO97 */
+UNUSED(PIN(C, 3)) /* GPIOC3 */
+UNUSED(PIN(C, 4)) /* GPIOC4 */
+UNUSED(PIN(C, 6)) /* GPIOC6 */
+UNUSED(PIN(5, 0)) /* GPIO50 */
+UNUSED(PIN(8, 3)) /* GPIO83 */
+UNUSED(PIN(7, 0)) /* GPIO70 */
+UNUSED(PIN(4, 1)) /* GPIO41 */
+
+/* Pre-configured PSL balls: J8 K6 */
diff --git a/board/marasov/gpio.inc b/board/marasov/gpio.inc
new file mode 100644
index 0000000000..d4a2ff2d67
--- /dev/null
+++ b/board/marasov/gpio.inc
@@ -0,0 +1,38 @@
+/* -*- mode:c -*-
+ *
+ * Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#define MODULE_KB MODULE_KEYBOARD_SCAN
+
+/*
+ * Generated-gpio.inc is produced using a Brya specific tool that
+ * parses the GPIO definitions derived from the board schematics and
+ * EC pinout descriptions derived form the chip datasheets to generate
+ * the Chrome EC GPIO pinout definitions. Due to the confidential
+ * nature of schematics and datasheets, they are not provided here.
+ *
+ * Variants that do not auto-generate their GPIO definitions should
+ * combine the Brya gpio.inc and generated-gpio.inc into their
+ * gpio.inc and customize as appropriate.
+ */
+
+#include "generated-gpio.inc"
+
+/*
+ * The NPCX keyboard driver does not use named GPIOs to access
+ * keyboard scan pins, so we do not list them in *gpio.inc. However, when
+ * KEYBOARD_COL2_INVERTED is defined, this name is required.
+ */
+GPIO(EC_KSO_02_INV, PIN(1, 7), GPIO_OUT_LOW)
+
+/* IO expander configuration */
+
+/* GPIO02_P2 to PU */
+/* GPIO03_P2 to PU */
+IOEX(USB_C0_OC_ODL, EXPIN(IOEX_C0_NCT38XX, 0, 4), GPIO_ODR_HIGH)
+IOEX(USB_C0_FRS_EN, EXPIN(IOEX_C0_NCT38XX, 0, 6), GPIO_OUT_LOW)
+IOEX(USB_C0_RT_RST_ODL, EXPIN(IOEX_C0_NCT38XX, 0, 7), GPIO_ODR_LOW)
+/* GPIO07_P2 to PU */
diff --git a/board/marasov/i2c.c b/board/marasov/i2c.c
new file mode 100644
index 0000000000..15c9b13e83
--- /dev/null
+++ b/board/marasov/i2c.c
@@ -0,0 +1,81 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "compile_time_macros.h"
+#include "console.h"
+#include "hooks.h"
+#include "i2c.h"
+
+/* I2C port map configuration */
+const struct i2c_port_t i2c_ports[] = {
+ {
+ /* I2C0 */
+ .name = "sensor",
+ .port = I2C_PORT_SENSOR,
+ .kbps = 400,
+ .scl = GPIO_EC_I2C_SENSOR_SCL,
+ .sda = GPIO_EC_I2C_SENSOR_SDA,
+ },
+ {
+ /* I2C1 */
+ .name = "tcpc0,2",
+ .port = I2C_PORT_USB_C0_TCPC,
+ .kbps = 1000,
+ .scl = GPIO_EC_I2C_USB_C0_TCPC_SCL,
+ .sda = GPIO_EC_I2C_USB_C0_TCPC_SDA,
+ },
+ {
+ /* I2C2 */
+ .name = "ppc0,2",
+ .port = I2C_PORT_USB_C0_PPC,
+ .kbps = 1000,
+ .scl = GPIO_EC_I2C_USB_C0_PPC_BC_SCL,
+ .sda = GPIO_EC_I2C_USB_C0_PPC_BC_SDA,
+ },
+ {
+ /* I2C3 */
+ .name = "retimer0,2",
+ .port = I2C_PORT_USB_C0_MUX,
+ .kbps = 1000,
+ .scl = GPIO_EC_I2C_USB_C0_RT_SCL,
+ .sda = GPIO_EC_I2C_USB_C0_RT_SDA,
+ },
+ {
+ /* I2C4 C1 TCPC */
+ .name = "tcpc1",
+ .port = I2C_PORT_USB_C1_TCPC,
+ .kbps = 1000,
+ .scl = GPIO_EC_I2C_USB_C1_TCPC_SCL,
+ .sda = GPIO_EC_I2C_USB_C1_TCPC_SDA,
+ .flags = I2C_PORT_FLAG_DYNAMIC_SPEED,
+ },
+ {
+ /* I2C5 */
+ .name = "battery",
+ .port = I2C_PORT_BATTERY,
+ .kbps = 100,
+ .scl = GPIO_EC_I2C_BAT_SCL,
+ .sda = GPIO_EC_I2C_BAT_SDA,
+ },
+ {
+ /* I2C6 */
+ .name = "ppc1",
+ .port = I2C_PORT_USB_C1_PPC,
+ .kbps = 1000,
+ .scl = GPIO_EC_I2C_USB_C1_MIX_SCL,
+ .sda = GPIO_EC_I2C_USB_C1_MIX_SDA,
+ .flags = I2C_PORT_FLAG_DYNAMIC_SPEED,
+ },
+ {
+ /* I2C7 */
+ .name = "eeprom",
+ .port = I2C_PORT_EEPROM,
+ .kbps = 400,
+ .scl = GPIO_EC_I2C_MISC_SCL_R,
+ .sda = GPIO_EC_I2C_MISC_SDA_R,
+ },
+};
+const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
diff --git a/board/marasov/keyboard.c b/board/marasov/keyboard.c
new file mode 100644
index 0000000000..936aeb290b
--- /dev/null
+++ b/board/marasov/keyboard.c
@@ -0,0 +1,25 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+
+#include "keyboard_scan.h"
+#include "timer.h"
+
+/* Keyboard scan setting */
+__override struct keyboard_scan_config keyscan_config = {
+ /* Increase from 50 us, because KSO_02 passes through the H1. */
+ .output_settle_us = 80,
+ /* Other values should be the same as the default configuration. */
+ .debounce_down_us = 9 * MSEC,
+ .debounce_up_us = 30 * MSEC,
+ .scan_period_us = 3 * MSEC,
+ .min_post_scan_delay_us = 1000,
+ .poll_timeout_us = 100 * MSEC,
+ .actual_key_mask = {
+ 0x14, 0xff, 0xff, 0xff, 0xff, 0xf5, 0xff,
+ 0xa4, 0xff, 0xfe, 0x55, 0xfa, 0xca /* full set */
+ },
+};
diff --git a/board/marasov/led.c b/board/marasov/led.c
new file mode 100644
index 0000000000..74005005cb
--- /dev/null
+++ b/board/marasov/led.c
@@ -0,0 +1,101 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "chipset.h"
+#include "ec_commands.h"
+#include "gpio.h"
+#include "led_common.h"
+#include "led_onoff_states.h"
+
+#define LED_OFF_LVL 1
+#define LED_ON_LVL 0
+
+__override const int led_charge_lvl_1;
+__override const int led_charge_lvl_2 = 95;
+
+__override struct led_descriptor
+ led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = {
+ [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER,
+ LED_INDEFINITE } },
+ [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER,
+ LED_INDEFINITE } },
+ [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_WHITE,
+ LED_INDEFINITE } },
+ [STATE_DISCHARGE_S0] = { { EC_LED_COLOR_WHITE,
+ LED_INDEFINITE } },
+ [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER,
+ 1 * LED_ONE_SEC },
+ { LED_OFF, 3 * LED_ONE_SEC } },
+ [STATE_DISCHARGE_S3] = { { EC_LED_COLOR_WHITE,
+ 1 * LED_ONE_SEC },
+ { LED_OFF, 3 * LED_ONE_SEC } },
+ [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER,
+ 1 * LED_ONE_SEC },
+ { LED_OFF, 1 * LED_ONE_SEC } },
+ [STATE_FACTORY_TEST] = { { EC_LED_COLOR_WHITE,
+ 2 * LED_ONE_SEC },
+ { EC_LED_COLOR_AMBER,
+ 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_WHITE:
+ gpio_set_level(GPIO_PWR_LED_A_ODL, LED_OFF_LVL);
+ gpio_set_level(GPIO_PWR_LED_W_ODL, LED_ON_LVL);
+ break;
+ case EC_LED_COLOR_AMBER:
+ gpio_set_level(GPIO_PWR_LED_A_ODL, LED_ON_LVL);
+ gpio_set_level(GPIO_PWR_LED_W_ODL, LED_OFF_LVL);
+ break;
+ default: /* LED_OFF and other unsupported colors */
+ gpio_set_level(GPIO_PWR_LED_W_ODL, LED_OFF_LVL);
+ gpio_set_level(GPIO_PWR_LED_A_ODL, LED_OFF_LVL);
+ 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_WHITE] = 1;
+ brightness_range[EC_LED_COLOR_AMBER] = 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);
+ }
+
+ return EC_SUCCESS;
+}
+
+__override enum led_states board_led_get_state(enum led_states desired_state)
+{
+ if (desired_state == STATE_BATTERY_ERROR) {
+ if (chipset_in_state(CHIPSET_STATE_ON))
+ return desired_state;
+ else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND))
+ return STATE_DISCHARGE_S3;
+ else
+ return STATE_DISCHARGE_S5;
+ }
+ return desired_state;
+}
diff --git a/board/marasov/pwm.c b/board/marasov/pwm.c
new file mode 100644
index 0000000000..f693a6e27f
--- /dev/null
+++ b/board/marasov/pwm.c
@@ -0,0 +1,38 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+
+#include "compile_time_macros.h"
+#include "hooks.h"
+#include "pwm.h"
+#include "pwm_chip.h"
+
+const struct pwm_t pwm_channels[] = {
+ [PWM_CH_KBLIGHT] = {
+ .channel = 3,
+ .flags = 0,
+ /*
+ * Set PWM frequency to multiple of 50 Hz and 60 Hz to prevent
+ * flicker. Higher frequencies consume similar average power to
+ * lower PWM frequencies, but higher frequencies record a much
+ * lower maximum power.
+ */
+ .freq = 12000,
+ },
+ [PWM_CH_FAN] = {
+ .channel = 5,
+ .flags = PWM_CONFIG_OPEN_DRAIN,
+ .freq = 25000,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(pwm_channels) == PWM_CH_COUNT);
+
+static void board_pwm_init(void)
+{
+ pwm_enable(PWM_CH_KBLIGHT, 1);
+ pwm_set_duty(PWM_CH_KBLIGHT, 50);
+}
+DECLARE_HOOK(HOOK_INIT, board_pwm_init, HOOK_PRIO_DEFAULT);
diff --git a/board/marasov/sensors.c b/board/marasov/sensors.c
new file mode 100644
index 0000000000..2a25141639
--- /dev/null
+++ b/board/marasov/sensors.c
@@ -0,0 +1,187 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "adc.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "temp_sensor.h"
+#include "thermal.h"
+#include "temp_sensor/thermistor.h"
+
+/* ADC configuration */
+struct adc_t adc_channels[] = {
+ [ADC_TEMP_SENSOR_1_DDR_SOC] = {
+ .name = "TEMP_DDR_SOC",
+ .input_ch = NPCX_ADC_CH0,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ },
+ [ADC_TEMP_SENSOR_2_AMBIENT] = {
+ .name = "TEMP_AMBIENT",
+ .input_ch = NPCX_ADC_CH1,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ },
+ [ADC_TEMP_SENSOR_3_CHARGER] = {
+ .name = "TEMP_CHARGER",
+ .input_ch = NPCX_ADC_CH6,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ },
+ [ADC_TEMP_SENSOR_4_WWAN] = {
+ .name = "TEMP_WWAN",
+ .input_ch = NPCX_ADC_CH7,
+ .factor_mul = ADC_MAX_VOLT,
+ .factor_div = ADC_READ_MAX + 1,
+ .shift = 0,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(adc_channels) == ADC_CH_COUNT);
+
+/* Temperature sensor configuration */
+const struct temp_sensor_t temp_sensors[] = {
+ [TEMP_SENSOR_1_DDR_SOC] = {
+ .name = "DDR and SOC",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_1_DDR_SOC,
+ },
+ [TEMP_SENSOR_2_AMBIENT] = {
+ .name = "Ambient",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_2_AMBIENT,
+ },
+ [TEMP_SENSOR_3_CHARGER] = {
+ .name = "Charger",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_3_CHARGER,
+ },
+ [TEMP_SENSOR_4_WWAN] = {
+ .name = "WWAN",
+ .type = TEMP_SENSOR_TYPE_BOARD,
+ .read = get_temp_3v3_30k9_47k_4050b,
+ .idx = ADC_TEMP_SENSOR_4_WWAN,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+
+/*
+ * TODO(b/180681346): update for Alder Lake/brya
+ *
+ * Alder Lake specifies 100 C as maximum TDP temperature. THRMTRIP# occurs at
+ * 130 C. However, sensor is located next to DDR, so we need to use the lower
+ * DDR temperature limit (85 C)
+ */
+/*
+ * TODO(b/202062363): Remove when clang is fixed.
+ */
+#define THERMAL_CPU \
+ { \
+ .temp_host = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(85), \
+ [EC_TEMP_THRESH_HALT] = C_TO_K(90), \
+ }, \
+ .temp_host_release = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(80), \
+ }, \
+ .temp_fan_off = C_TO_K(35), \
+ .temp_fan_max = C_TO_K(60), \
+ }
+__maybe_unused static const struct ec_thermal_config thermal_cpu = THERMAL_CPU;
+
+/*
+ * TODO(b/180681346): update for Alder Lake/brya
+ *
+ * Inductor limits - used for both charger and PP3300 regulator
+ *
+ * Need to use the lower of the charger IC, PP3300 regulator, and the inductors
+ *
+ * Charger max recommended temperature 100C, max absolute temperature 125C
+ * PP3300 regulator: operating range -40 C to 145 C
+ *
+ * Inductors: limit of 125c
+ * PCB: limit is 80c
+ */
+/*
+ * TODO(b/202062363): Remove when clang is fixed.
+ */
+#define THERMAL_AMBIENT \
+ { \
+ .temp_host = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(85), \
+ [EC_TEMP_THRESH_HALT] = C_TO_K(90), \
+ }, \
+ .temp_host_release = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(80), \
+ }, \
+ .temp_fan_off = C_TO_K(35), \
+ .temp_fan_max = C_TO_K(60), \
+ }
+__maybe_unused static const struct ec_thermal_config thermal_ambient =
+ THERMAL_AMBIENT;
+
+/*
+ * Inductor limits - used for both charger and PP3300 regulator
+ *
+ * Need to use the lower of the charger IC, PP3300 regulator, and the inductors
+ *
+ * Charger max recommended temperature 125C, max absolute temperature 150C
+ * PP3300 regulator: operating range -40 C to 125 C
+ *
+ * Inductors: limit of 125c
+ * PCB: limit is 80c
+ */
+/*
+ * TODO(b/202062363): Remove when clang is fixed.
+ */
+#define THERMAL_CHARGER \
+ { \
+ .temp_host = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(105), \
+ [EC_TEMP_THRESH_HALT] = C_TO_K(120), \
+ }, \
+ .temp_host_release = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(90), \
+ }, \
+ .temp_fan_off = C_TO_K(35), \
+ .temp_fan_max = C_TO_K(65), \
+ }
+__maybe_unused static const struct ec_thermal_config thermal_charger =
+ THERMAL_CHARGER;
+
+/*
+ * TODO(b/180681346): update for brya WWAN module
+ */
+/*
+ * TODO(b/202062363): Remove when clang is fixed.
+ */
+#define THERMAL_WWAN \
+ { \
+ .temp_host = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(130), \
+ [EC_TEMP_THRESH_HALT] = C_TO_K(130), \
+ }, \
+ .temp_host_release = { \
+ [EC_TEMP_THRESH_HIGH] = C_TO_K(100), \
+ }, \
+ .temp_fan_off = C_TO_K(35), \
+ .temp_fan_max = C_TO_K(60), \
+ }
+__maybe_unused static const struct ec_thermal_config thermal_wwan =
+ THERMAL_WWAN;
+
+struct ec_thermal_config thermal_params[] = {
+ [TEMP_SENSOR_1_DDR_SOC] = THERMAL_CPU,
+ [TEMP_SENSOR_2_AMBIENT] = THERMAL_AMBIENT,
+ [TEMP_SENSOR_3_CHARGER] = THERMAL_CHARGER,
+ [TEMP_SENSOR_4_WWAN] = THERMAL_WWAN,
+};
+BUILD_ASSERT(ARRAY_SIZE(thermal_params) == TEMP_SENSOR_COUNT);
diff --git a/board/marasov/usbc_config.c b/board/marasov/usbc_config.c
new file mode 100644
index 0000000000..b974ba7509
--- /dev/null
+++ b/board/marasov/usbc_config.c
@@ -0,0 +1,348 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include "cbi.h"
+#include "charger.h"
+#include "common.h"
+#include "compile_time_macros.h"
+#include "console.h"
+#include "driver/ppc/syv682x_public.h"
+#include "driver/retimer/bb_retimer_public.h"
+#include "driver/tcpm/nct38xx.h"
+#include "driver/tcpm/ps8xxx_public.h"
+#include "driver/tcpm/tcpci.h"
+#include "ec_commands.h"
+#include "fw_config.h"
+#include "gpio.h"
+#include "gpio_signal.h"
+#include "hooks.h"
+#include "ioexpander.h"
+#include "system.h"
+#include "task.h"
+#include "task_id.h"
+#include "timer.h"
+#include "usbc_config.h"
+#include "usbc_ppc.h"
+#include "usb_mux.h"
+#include "usb_pd.h"
+#include "usb_pd_tcpm.h"
+
+#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
+
+#ifdef CONFIG_ZEPHYR
+enum ioex_port { IOEX_C0_NCT38XX = 0, IOEX_PORT_COUNT };
+#endif /* CONFIG_ZEPHYR */
+
+#ifndef CONFIG_ZEPHYR
+/* USBC TCPC configuration */
+const struct tcpc_config_t tcpc_config[] = {
+ [USBC_PORT_C0] = {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_USB_C0_TCPC,
+ .addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
+ },
+ .drv = &nct38xx_tcpm_drv,
+ .flags = TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_NO_DEBUG_ACC_CONTROL,
+ },
+ [USBC_PORT_C1] = {
+ .bus_type = EC_BUS_TYPE_I2C,
+ .i2c_info = {
+ .port = I2C_PORT_USB_C1_TCPC,
+ .addr_flags = PS8XXX_I2C_ADDR1_FLAGS,
+ },
+ .drv = &ps8xxx_tcpm_drv,
+ .flags = TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V |
+ TCPC_FLAGS_CONTROL_VCONN |
+ TCPC_FLAGS_CONTROL_FRS,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT);
+BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT);
+#endif /* !CONFIG_ZEPHYR */
+
+/******************************************************************************/
+/* USB-A charging control */
+
+#ifndef CONFIG_ZEPHYR
+const int usb_port_enable[USB_PORT_COUNT] = {
+ GPIO_EN_PP5000_USBA_R,
+};
+#endif
+BUILD_ASSERT(ARRAY_SIZE(usb_port_enable) == USB_PORT_COUNT);
+
+/******************************************************************************/
+
+#ifndef CONFIG_ZEPHYR
+/* USBC PPC configuration */
+struct ppc_config_t ppc_chips[] = {
+ [USBC_PORT_C0] = {
+ .i2c_port = I2C_PORT_USB_C0_PPC,
+ .i2c_addr_flags = SYV682X_ADDR0_FLAGS,
+ .frs_en = IOEX_USB_C0_FRS_EN,
+ .drv = &syv682x_drv,
+ },
+ [USBC_PORT_C1] = {
+ /* Compatible with Silicon Mitus SM5360A */
+ .i2c_port = I2C_PORT_USB_C1_PPC,
+ .i2c_addr_flags = SYV682X_ADDR0_FLAGS,
+ .drv = &syv682x_drv,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == USBC_PORT_COUNT);
+
+unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
+
+/* USBC mux configuration - Alder Lake includes internal mux */
+static const struct usb_mux_chain usbc0_tcss_usb_mux = {
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = USBC_PORT_C0,
+ .driver = &virtual_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
+ },
+};
+
+/*
+ * USB3 DB mux configuration - the top level mux still needs to be set
+ * to the virtual_usb_mux_driver so the AP gets notified of mux changes
+ * and updates the TCSS configuration on state changes.
+ */
+static const struct usb_mux_chain usbc1_usb3_db_retimer = {
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = USBC_PORT_C1,
+ .driver = &tcpci_tcpm_usb_mux_driver,
+ .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ },
+};
+
+const struct usb_mux_chain usb_muxes[] = {
+ [USBC_PORT_C0] = {
+ .mux = &(const struct usb_mux) {
+ .usb_port = USBC_PORT_C0,
+ .flags = USB_MUX_FLAG_CAN_IDLE,
+ .driver = &bb_usb_retimer,
+ .hpd_update = bb_retimer_hpd_update,
+ .i2c_port = I2C_PORT_USB_C0_MUX,
+ .i2c_addr_flags = USBC_PORT_C0_BB_RETIMER_I2C_ADDR,
+ },
+ .next = &usbc0_tcss_usb_mux,
+ },
+ [USBC_PORT_C1] = {
+ .mux = &(const struct usb_mux) {
+ /* PS8815 DB */
+ .usb_port = USBC_PORT_C1,
+ .driver = &virtual_usb_mux_driver,
+ .hpd_update = &virtual_hpd_update,
+ },
+ .next = &usbc1_usb3_db_retimer,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
+
+/*
+ * USB C0 uses burnside bridge chips and have their reset
+ * controlled by their respective TCPC chips acting as GPIO expanders.
+ *
+ * ioex_init() is normally called before we take the TCPCs out of
+ * reset, so we need to start in disabled mode, then explicitly
+ * call ioex_init().
+ */
+
+struct ioexpander_config_t ioex_config[] = {
+ [IOEX_C0_NCT38XX] = {
+ .i2c_host_port = I2C_PORT_USB_C0_TCPC,
+ .i2c_addr_flags = NCT38XX_I2C_ADDR1_1_FLAGS,
+ .drv = &nct38xx_ioexpander_drv,
+ .flags = IOEX_FLAGS_DEFAULT_INIT_DISABLED,
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(ioex_config) == CONFIG_IO_EXPANDER_PORT_COUNT);
+#endif /* !CONFIG_ZEPHYR */
+
+__override int bb_retimer_power_enable(const struct usb_mux *me, bool enable)
+{
+ enum ioex_signal rst_signal;
+
+ if (me->usb_port == USBC_PORT_C0) {
+/* TODO: explore how to handle board id in zephyr*/
+#ifndef CONFIG_ZEPHYR
+ rst_signal = IOEX_USB_C0_RT_RST_ODL;
+#else
+ /* On Zephyr use bb_controls generated from DTS */
+ rst_signal = bb_controls[me->usb_port].retimer_rst_gpio;
+#endif /* !CONFIG_ZEPHYR */
+ } else {
+ return EC_ERROR_INVAL;
+ }
+
+ /*
+ * We do not have a load switch for the burnside bridge chips,
+ * so we only need to sequence reset.
+ */
+
+ if (enable) {
+ /*
+ * Tpw, minimum time from VCC to RESET_N de-assertion is 100us.
+ * For boards that don't provide a load switch control, the
+ * retimer_init() function ensures power is up before calling
+ * this function.
+ */
+ ioex_set_level(rst_signal, 1);
+ /*
+ * Allow 1ms time for the retimer to power up lc_domain
+ * which powers I2C controller within retimer
+ */
+ msleep(1);
+ } else {
+ ioex_set_level(rst_signal, 0);
+ msleep(1);
+ }
+ return EC_SUCCESS;
+}
+
+void board_reset_pd_mcu(void)
+{
+ enum gpio_signal tcpc_rst;
+
+#ifndef CONFIG_ZEPHYR
+ tcpc_rst = GPIO_USB_C0_TCPC_RST_ODL;
+#else
+ tcpc_rst = GPIO_UNIMPLEMENTED;
+#endif /* !CONFIG_ZEPHYR */
+
+ /*
+ * TODO(b/179648104): figure out correct timing
+ */
+
+ gpio_set_level(tcpc_rst, 0);
+ gpio_set_level(GPIO_USB_C1_RT_RST_R_ODL, 0);
+
+ /*
+ * delay for power-on to reset-off and min. assertion time
+ */
+
+ msleep(20);
+
+ gpio_set_level(tcpc_rst, 1);
+ gpio_set_level(GPIO_USB_C1_RT_RST_R_ODL, 1);
+
+ /* wait for chips to come up */
+
+ msleep(50);
+}
+
+static void board_tcpc_init(void)
+{
+ /* Don't reset TCPCs after initial reset */
+ if (!system_jumped_late())
+ board_reset_pd_mcu();
+
+ /*
+ * These IO expander pins are implemented using the
+ * C0 TCPC, so they must be set up after the TCPC has
+ * been taken out of reset.
+ */
+#ifndef CONFIG_ZEPHYR
+ ioex_init(IOEX_C0_NCT38XX);
+#else
+ gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_port1)));
+#endif
+
+ /* Enable PPC interrupts. */
+ gpio_enable_interrupt(GPIO_USB_C0_PPC_INT_ODL);
+
+ /* Enable TCPC interrupts. */
+ gpio_enable_interrupt(GPIO_USB_C0_TCPC_INT_ODL);
+
+ gpio_enable_interrupt(GPIO_USB_C1_PPC_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_TCPC_INT_ODL);
+}
+DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_CHIPSET);
+
+uint16_t tcpc_get_alert_status(void)
+{
+ uint16_t status = 0;
+
+ if (gpio_get_level(GPIO_USB_C0_TCPC_INT_ODL) == 0)
+ status |= PD_STATUS_TCPC_ALERT_0;
+
+ if (gpio_get_level(GPIO_USB_C1_TCPC_INT_ODL) == 0)
+ status |= PD_STATUS_TCPC_ALERT_1;
+
+ return status;
+}
+
+int ppc_get_alert_status(int port)
+{
+ if (port == USBC_PORT_C0)
+ return gpio_get_level(GPIO_USB_C0_PPC_INT_ODL) == 0;
+ else if (port == USBC_PORT_C1)
+ return gpio_get_level(GPIO_USB_C1_PPC_INT_ODL) == 0;
+ return 0;
+}
+
+void tcpc_alert_event(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_TCPC_INT_ODL:
+ schedule_deferred_pd_interrupt(USBC_PORT_C0);
+ break;
+ case GPIO_USB_C1_TCPC_INT_ODL:
+ schedule_deferred_pd_interrupt(USBC_PORT_C1);
+ break;
+ default:
+ break;
+ }
+}
+
+void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_PPC_INT_ODL:
+ syv682x_interrupt(USBC_PORT_C0);
+ break;
+ case GPIO_USB_C1_PPC_INT_ODL:
+ syv682x_interrupt(USBC_PORT_C1);
+ break;
+ default:
+ break;
+ }
+}
+
+void retimer_interrupt(enum gpio_signal signal)
+{
+ /*
+ * TODO(b/179513527): add USB-C support
+ */
+}
+
+__override bool board_is_dts_port(int port)
+{
+ return port == USBC_PORT_C0;
+}
+
+__override bool board_is_tbt_usb4_port(int port)
+{
+ if (port == USBC_PORT_C0)
+ return true;
+
+ return false;
+}
+
+__override enum tbt_compat_cable_speed board_get_max_tbt_speed(int port)
+{
+ if (!board_is_tbt_usb4_port(port))
+ return TBT_SS_RES_0;
+
+ return TBT_SS_TBT_GEN3;
+}
diff --git a/board/marasov/usbc_config.h b/board/marasov/usbc_config.h
new file mode 100644
index 0000000000..1fa7ad4c7a
--- /dev/null
+++ b/board/marasov/usbc_config.h
@@ -0,0 +1,17 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Brya board-specific USB-C configuration */
+
+#ifndef __CROS_EC_USBC_CONFIG_H
+#define __CROS_EC_USBC_CONFIG_H
+
+#ifndef CONFIG_ZEPHYR
+#define CONFIG_USB_PD_PORT_MAX_COUNT 2
+#endif
+
+enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
+
+#endif /* __CROS_EC_USBC_CONFIG_H */
diff --git a/board/marasov/vif_override.xml b/board/marasov/vif_override.xml
new file mode 100644
index 0000000000..6ade5d2f92
--- /dev/null
+++ b/board/marasov/vif_override.xml
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vif:VIF xmlns="http://usb.org/VendorInfoFile.xsd">
+ <vif:Product_Revision>2</vif:Product_Revision>
+ <vif:TID>0</vif:TID>
+ <vif:Product>
+ <vif:USB4_Num_Internal_Host_Controllers value="1" />
+ <vif:USB4_Num_PCIe_DN_Bridges value="0" />
+ <vif:USB4RouterList>
+ <vif:Usb4Router>
+ <!--USB4 Router 0-->
+ <vif:USB4_Router_ID value="0" />
+ <vif:USB4_Silicon_VID value="32903">8087</vif:USB4_Silicon_VID>
+ <vif:USB4_Num_Lane_Adapters value="4" />
+ <vif:USB4_Num_USB3_DN_Adapters value="1" />
+ <vif:USB4_Num_DP_IN_Adapters value="1" />
+ <vif:USB4_Num_DP_OUT_Adapters value="0" />
+ <vif:USB4_Num_PCIe_DN_Adapters value="4" />
+ <vif:USB4_TBT3_Not_Supported value="0">TBT3 Compatible</vif:USB4_TBT3_Not_Supported>
+ <vif:USB4_PCIe_Wake_Supported value="true" />
+ <vif:USB4_USB3_Wake_Supported value="false" />
+ <vif:USB4_Num_Unused_Adapters value="0" />
+ <vif:USB4_TBT3_VID value="32903">8087</vif:USB4_TBT3_VID>
+ <vif:USB4_PCIe_Switch_Vendor_ID value="32902">8086</vif:USB4_PCIe_Switch_Vendor_ID>
+ <vif:USB4_PCIe_Switch_Device_ID value="39451">9A1B</vif:USB4_PCIe_Switch_Device_ID>
+ </vif:Usb4Router>
+ </vif:USB4RouterList>
+ </vif:Product>
+
+ <vif:Component>
+ <vif:USB4_Max_Speed value="1">Gen 3 (40Gb)</vif:USB4_Max_Speed>
+
+ <!--;USB Host-->
+
+ <vif:Host_Speed value="4">USB 3.2 Gen 2x2</vif:Host_Speed>
+ <vif:Host_Contains_Captive_Retimer value="true" />
+ <vif:Host_Truncates_DP_For_tDHPResponse value="false" />
+ <vif:Host_Suspend_Supported value="true" />
+
+ <!--;PD Source-->
+ <!-- will we ever clear USB_Suspend_Supported? -->
+ <vif:USB_Suspend_May_Be_Cleared value="true" />
+
+ <!-- remove FR_Swap_* when we enable CONFIG_USB_PD_FRS -->
+ <!--;Dual Role-->
+ <vif:FR_Swap_Supported_As_Initial_Sink value="true" />
+ <!--;PD Source-->
+ <vif:FR_Swap_Type_C_Current_Capability_As_Initial_Sink value="3">3A @ 5V</vif:FR_Swap_Type_C_Current_Capability_As_Initial_Sink>
+ <vif:SrcPdoList>
+ <vif:SrcPDO>
+ <!--Source PDO 1-->
+ <vif:Src_PD_OCP_OC_Debounce value="50">50 msec</vif:Src_PD_OCP_OC_Debounce>
+ <vif:Src_PD_OCP_OC_Threshold value="360">3600 mA</vif:Src_PD_OCP_OC_Threshold>
+ </vif:SrcPDO>
+ </vif:SrcPdoList>
+
+ <!-- SOP Discover ID -->
+ <vif:Product_Type_UFP_SOP value="2">PDUSB Peripheral</vif:Product_Type_UFP_SOP>
+ <vif:Product_Type_DFP_SOP value="2">PDUSB Host</vif:Product_Type_DFP_SOP>
+
+ <!-- USB4 Port -->
+ <vif:USB4_Lane_0_Adapter value="1" />
+ <vif:USB4_UFP_Supported value="false" />
+ <vif:USB4_DFP_Supported value="true" />
+ <vif:USB4_USB3_Tunneling_Supported value="true" />
+ <vif:USB4_DP_Tunneling_Supported value="true" />
+ <vif:USB4_CL1_State_Supported value="true" />
+ <vif:USB4_CL2_State_Supported value="true" />
+ <vif:USB4_Num_Retimers value="1" />
+ <vif:USB4_DP_Bit_Rate value="3">HBR3</vif:USB4_DP_Bit_Rate>
+ <vif:USB4_Num_DP_Lanes value="4">4 Lanes</vif:USB4_Num_DP_Lanes>
+
+ </vif:Component>
+
+ <vif:Component>
+ <vif:USB4_Supported value="false" />
+
+ <!--;USB Host-->
+ <vif:Host_Speed value="2">USB 3.2 Gen 2x1</vif:Host_Speed>
+ <vif:Host_Contains_Captive_Retimer value="true" />
+ <vif:Host_Truncates_DP_For_tDHPResponse value="false" />
+ <vif:Host_Suspend_Supported value="true" />
+
+ <!--;PD Source-->
+ <!-- will we ever clear USB_Suspend_Supported? -->
+ <vif:USB_Suspend_May_Be_Cleared value="true" />
+
+ <!-- remove FR_Swap_* when we enable CONFIG_USB_PD_FRS -->
+ <!--;Dual Role-->
+ <vif:FR_Swap_Supported_As_Initial_Sink value="true" />
+ <!--;PD Source-->
+ <vif:FR_Swap_Type_C_Current_Capability_As_Initial_Sink value="3">3A @ 5V</vif:FR_Swap_Type_C_Current_Capability_As_Initial_Sink>
+ <vif:SrcPdoList>
+ <vif:SrcPDO>
+ <!--Source PDO 1-->
+ <vif:Src_PD_OCP_OC_Debounce value="50">50 msec</vif:Src_PD_OCP_OC_Debounce>
+ <vif:Src_PD_OCP_OC_Threshold value="360">3600 mA</vif:Src_PD_OCP_OC_Threshold>
+ </vif:SrcPDO>
+ </vif:SrcPdoList>
+
+ <!-- SOP Discover ID -->
+ <vif:Product_Type_UFP_SOP value="3">PSD</vif:Product_Type_UFP_SOP>
+ <vif:Product_Type_DFP_SOP value="2">PDUSB Host</vif:Product_Type_DFP_SOP>
+
+ </vif:Component>
+
+ <vif:Component>
+ <vif:USB4_Max_Speed value="1">Gen 3 (40Gb)</vif:USB4_Max_Speed>
+ <!--;USB Host-->
+ <vif:Host_Speed value="4">USB 3.2 Gen 2x2</vif:Host_Speed>
+ <vif:Host_Contains_Captive_Retimer value="true" />
+ <vif:Host_Truncates_DP_For_tDHPResponse value="false" />
+ <vif:Host_Suspend_Supported value="true" />
+
+ <!--;PD Source-->
+ <!-- will we ever clear USB_Suspend_Supported? -->
+ <vif:USB_Suspend_May_Be_Cleared value="true" />
+
+ <!-- remove FR_Swap_* when we enable CONFIG_USB_PD_FRS -->
+ <!--;Dual Role-->
+ <vif:FR_Swap_Supported_As_Initial_Sink value="true" />
+ <!--;PD Source-->
+ <vif:FR_Swap_Type_C_Current_Capability_As_Initial_Sink value="3">3A @ 5V</vif:FR_Swap_Type_C_Current_Capability_As_Initial_Sink>
+ <vif:SrcPdoList>
+ <vif:SrcPDO>
+ <!--Source PDO 1-->
+ <vif:Src_PD_OCP_OC_Debounce value="50">50 msec</vif:Src_PD_OCP_OC_Debounce>
+ <vif:Src_PD_OCP_OC_Threshold value="360">3600 mA</vif:Src_PD_OCP_OC_Threshold>
+ </vif:SrcPDO>
+ </vif:SrcPdoList>
+
+ <!-- SOP Discover ID -->
+ <vif:Product_Type_UFP_SOP value="2">PDUSB Peripheral</vif:Product_Type_UFP_SOP>
+ <vif:Product_Type_DFP_SOP value="2">PDUSB Host</vif:Product_Type_DFP_SOP>
+
+ <!-- USB4 Port -->
+ <vif:USB4_Lane_0_Adapter value="1" />
+ <vif:USB4_UFP_Supported value="false" />
+ <vif:USB4_DFP_Supported value="true" />
+ <vif:USB4_USB3_Tunneling_Supported value="true" />
+ <vif:USB4_DP_Tunneling_Supported value="true" />
+ <vif:USB4_CL1_State_Supported value="true" />
+ <vif:USB4_CL2_State_Supported value="true" />
+ <vif:USB4_Num_Retimers value="1" />
+ <vif:USB4_DP_Bit_Rate value="3">HBR3</vif:USB4_DP_Bit_Rate>
+ <vif:USB4_Num_DP_Lanes value="4">4 Lanes</vif:USB4_Num_DP_Lanes>
+
+ </vif:Component>
+</vif:VIF>
diff --git a/board/marzipan/board.c b/board/marzipan/board.c
index 125c39a826..cf59f133e7 100644
--- a/board/marzipan/board.c
+++ b/board/marzipan/board.c
@@ -496,6 +496,7 @@ void board_tcpc_init(void)
/* Enable PPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -625,8 +626,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -638,8 +639,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/mchpevb1/board.c b/board/mchpevb1/board.c
index 23135108f6..3b7b34843b 100644
--- a/board/mchpevb1/board.c
+++ b/board/mchpevb1/board.c
@@ -590,21 +590,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-
-/**
- * Set the charge limit based upon desired maximum.
- *
- * @param port Port number.
- * @param supplier Charge supplier type.
- * @param charge_ma Desired charge limit (mA).
- * @param charge_mv Negotiated charge voltage (mV).
- */
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
#endif
/*
diff --git a/board/mchpevb1/board.h b/board/mchpevb1/board.h
index 10208ca736..dd7c87fd6f 100644
--- a/board/mchpevb1/board.h
+++ b/board/mchpevb1/board.h
@@ -150,7 +150,8 @@
/* #define CONFIG_CHARGER_DISCHARGE_ON_AC */
/* #define CONFIG_CHARGER_ISL9237 */
/* #define CONFIG_CHARGER_ILIM_PIN_DISABLED */
-/* #define CONFIG_CHARGER_INPUT_CURRENT 512 */
+/* #define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512 */
+/* #define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512 */
/* #define CONFIG_CHARGER_NARROW_VDC */
/* #define CONFIG_CHARGER_PROFILE_OVERRIDE */
diff --git a/board/metaknight/board.c b/board/metaknight/board.c
index 5aa3a21cc0..e5d86aba63 100644
--- a/board/metaknight/board.c
+++ b/board/metaknight/board.c
@@ -396,19 +396,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/metaknight/board.h b/board/metaknight/board.h
index 5bd3c56a83..79027a3e9c 100644
--- a/board/metaknight/board.h
+++ b/board/metaknight/board.h
@@ -22,6 +22,11 @@
#undef CONFIG_CHARGER_SINGLE_CHIP
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
/*
* GPIO for C1 interrupts, for baseboard use
diff --git a/board/mithrax/board.h b/board/mithrax/board.h
index d12375d678..0b6ea04bd4 100644
--- a/board/mithrax/board.h
+++ b/board/mithrax/board.h
@@ -176,6 +176,7 @@
#define CONFIG_CHARGE_RAMP_SW
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 10
/* RGB Keyboard */
#ifdef SECTION_IS_RW
diff --git a/board/mithrax/charger_isl9241.c b/board/mithrax/charger_isl9241.c
index a9eafe353e..7a16fcd5cb 100644
--- a/board/mithrax/charger_isl9241.c
+++ b/board/mithrax/charger_isl9241.c
@@ -79,11 +79,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_ma = (charge_ma * 90) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/moli/board.c b/board/moli/board.c
index acc12f9831..a63c93ae50 100644
--- a/board/moli/board.c
+++ b/board/moli/board.c
@@ -8,11 +8,13 @@
#include "button.h"
#include "charge_manager.h"
#include "charge_state_v2.h"
+#include "chipset.h"
#include "common.h"
#include "compile_time_macros.h"
#include "console.h"
#include "cros_board_info.h"
#include "driver/tcpm/tcpci.h"
+#include "fw_config.h"
#include "gpio.h"
#include "gpio_signal.h"
#include "hooks.h"
@@ -31,6 +33,32 @@ static void power_monitor(void);
DECLARE_DEFERRED(power_monitor);
/******************************************************************************/
+/* Power on by HDMI/ DP monitor */
+struct monitor_config {
+ enum gpio_signal gpio;
+ uint8_t state;
+};
+
+static struct monitor_config monitors[MONITOR_COUNT] = {
+ [HDMI1_MONITOR] = {
+ .gpio = GPIO_HDMI1_MONITOR_ON,
+ .state = MONITOR_OFF,
+ },
+
+ [HDMI2_MONITOR] = {
+ .gpio = GPIO_HDMI2_MONITOR_ON,
+ .state = MONITOR_OFF,
+ },
+
+ [OPTION_MONITOR] = {
+ .gpio = GPIO_OPTION_MONITOR_ON,
+ .state = MONITOR_OFF,
+ },
+};
+
+/******************************************************************************/
+
+/******************************************************************************/
/* USB-A charging control */
const int usb_port_enable[USB_PORT_COUNT] = {
@@ -116,34 +144,6 @@ static uint8_t usbc_overcurrent;
* only do that if the system is off since it might still brown out.
*/
-/*
- * Barrel-jack power adapter ratings.
- */
-static const struct {
- int voltage;
- int current;
-} bj_power[] = {
- { /* 0 - 90W (also default) */
- .voltage = 19000,
- .current = 4740 },
- { /* 1 - 135W */
- .voltage = 19500,
- .current = 6920 },
-};
-
-static unsigned int ec_config_get_bj_power(void)
-{
- uint32_t fw_config;
- unsigned int bj;
-
- cbi_get_fw_config(&fw_config);
- bj = (fw_config & EC_CFG_BJ_POWER_MASK) >> EC_CFG_BJ_POWER_L;
- /* Out of range value defaults to 0 */
- if (bj >= ARRAY_SIZE(bj_power))
- bj = 0;
- return bj;
-}
-
#define ADP_DEBOUNCE_MS 1000 /* Debounce time for BJ plug/unplug */
/* Debounced connection state of the barrel jack */
static int8_t adp_connected = -1;
@@ -155,12 +155,9 @@ static void adp_connect_deferred(void)
/* Debounce */
if (connected == adp_connected)
return;
- if (connected) {
- unsigned int bj = ec_config_get_bj_power();
+ if (connected)
+ ec_bj_power(&pi.voltage, &pi.current);
- pi.voltage = bj_power[bj].voltage;
- pi.current = bj_power[bj].current;
- }
charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED,
DEDICATED_CHARGE_PORT, &pi);
adp_connected = connected;
@@ -192,12 +189,29 @@ DECLARE_HOOK(HOOK_INIT, adp_state_init, HOOK_PRIO_INIT_CHARGE_MANAGER + 1);
static void board_init(void)
{
+ int i;
+
gpio_enable_interrupt(GPIO_BJ_ADP_PRESENT_ODL);
gpio_enable_interrupt(GPIO_HDMI_CONN_OC_ODL);
gpio_enable_interrupt(GPIO_USB_A1_OC_ODL);
gpio_enable_interrupt(GPIO_USB_A2_OC_ODL);
gpio_enable_interrupt(GPIO_USB_A3_OC_ODL);
gpio_enable_interrupt(GPIO_USB_A4_OC_ODL);
+
+ if (ec_cfg_power_on_monitor() == POWER_ON_MONITOR_ENABLE) {
+ /*
+ * Only enable interrupt when fw_config set it as enable.
+ */
+ gpio_enable_interrupt(GPIO_HDMI1_MONITOR_ON);
+ gpio_enable_interrupt(GPIO_HDMI2_MONITOR_ON);
+ gpio_enable_interrupt(GPIO_OPTION_MONITOR_ON);
+
+ /*
+ * Initialize the monitor state to corresponding gpio state.
+ */
+ for (i = 0; i < MONITOR_COUNT; i++)
+ monitors[i].state = gpio_get_level(monitors[i].gpio);
+ }
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
@@ -432,3 +446,72 @@ static void power_monitor(void)
* Start power monitoring after ADCs have been initialised.
*/
DECLARE_HOOK(HOOK_INIT, power_monitor, HOOK_PRIO_INIT_ADC + 1);
+
+/******************************************************************************/
+/*
+ * System power on and wake up by monitor power button.
+ *
+ * After pressing power button of monitor for power on, monitor will send power
+ * on signal with 3.3V / 200ms to DT. If DT detect that pulse, there are three
+ * DT behavior:
+ *
+ * - Do nothing in state S0.
+ * - Wake up from state S0ix.
+ * - Power on from state S5 and G3.
+ */
+
+/* Debounce time for HDMI power button press */
+#define MONITOR_DEBOUNCE_MS 100
+
+static void monitor_irq_deferred(void);
+DECLARE_DEFERRED(monitor_irq_deferred);
+
+static void monitor_irq_deferred(void)
+{
+ int i;
+
+ for (i = 0; i < MONITOR_COUNT; i++) {
+ if (monitors[i].state && gpio_get_level(monitors[i].gpio)) {
+ /*
+ * System power on from state S5 and G3.
+ */
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ chipset_power_on();
+ /*
+ * System wake up from state S0ix.
+ */
+ else if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND))
+ power_button_simulate_press(200);
+ }
+ monitors[i].state = MONITOR_OFF;
+ }
+}
+
+/* Power on by HDMI/ DP monitor. */
+void monitor_interrupt(enum gpio_signal signal)
+{
+ /*
+ * Power on by HDMI/ DP monitor only works
+ * when system is not in S0.
+ */
+ if (chipset_in_state(CHIPSET_STATE_ON))
+ return;
+
+ if (ec_cfg_power_on_monitor() == POWER_ON_MONITOR_ENABLE) {
+ switch (signal) {
+ case GPIO_HDMI1_MONITOR_ON:
+ monitors[HDMI1_MONITOR].state = MONITOR_ON;
+ break;
+ case GPIO_HDMI2_MONITOR_ON:
+ monitors[HDMI2_MONITOR].state = MONITOR_ON;
+ break;
+ case GPIO_OPTION_MONITOR_ON:
+ monitors[OPTION_MONITOR].state = MONITOR_ON;
+ break;
+ default:
+ break;
+ }
+ hook_call_deferred(&monitor_irq_deferred_data,
+ MONITOR_DEBOUNCE_MS * MSEC);
+ }
+}
diff --git a/board/moli/board.h b/board/moli/board.h
index e7aa7855e7..8d0ba97fb2 100644
--- a/board/moli/board.h
+++ b/board/moli/board.h
@@ -181,17 +181,17 @@ enum fan_channel { FAN_CH_0 = 0, FAN_CH_COUNT };
enum mft_channel { MFT_CH_0 = 0, MFT_CH_COUNT };
-/*
- * firmware config fields
- */
-/*
- * Barrel-jack power (2 bits).
- */
-#define EC_CFG_BJ_POWER_L 0
-#define EC_CFG_BJ_POWER_H 1
-#define EC_CFG_BJ_POWER_MASK GENMASK(EC_CFG_BJ_POWER_H, EC_CFG_BJ_POWER_L)
+enum monitor_port {
+ HDMI1_MONITOR,
+ HDMI2_MONITOR,
+ OPTION_MONITOR,
+ MONITOR_COUNT
+};
+
+enum monitor_state { MONITOR_OFF, MONITOR_ON };
extern void adp_connect_interrupt(enum gpio_signal signal);
+extern void monitor_interrupt(enum gpio_signal signal);
#endif /* !__ASSEMBLER__ */
diff --git a/board/moli/build.mk b/board/moli/build.mk
index 4897d446b2..4ddfaaf181 100644
--- a/board/moli/build.mk
+++ b/board/moli/build.mk
@@ -20,3 +20,4 @@ board-y+=pwm.o
board-y+=sensors.o
board-y+=thermal.o
board-y+=usbc_config.o
+board-y+=fw_config.o
diff --git a/board/moli/fw_config.c b/board/moli/fw_config.c
new file mode 100644
index 0000000000..5807ee9111
--- /dev/null
+++ b/board/moli/fw_config.c
@@ -0,0 +1,73 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "cbi.h"
+#include "common.h"
+#include "compile_time_macros.h"
+#include "console.h"
+#include "cros_board_info.h"
+#include "fw_config.h"
+
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
+
+static union moli_cbi_fw_config fw_config;
+BUILD_ASSERT(sizeof(fw_config) == sizeof(uint32_t));
+
+/*
+ * FW_CONFIG defaults for moli if the CBI.FW_CONFIG data is not
+ * initialized.
+ */
+static const union moli_cbi_fw_config fw_config_defaults = {
+ .bj_power = BJ_90W,
+ .po_mon = POWER_ON_MONITOR_ENABLE,
+};
+
+/*
+ * Barrel-jack power adapter ratings.
+ */
+static const struct {
+ int voltage;
+ int current;
+} bj_power[] = {
+ [BJ_90W] = { /* 0 - 90W (also default) */
+ .voltage = 19000,
+ .current = 4740 },
+ [BJ_135W] = { /* 1 - 135W */
+ .voltage = 19500,
+ .current = 6920 },
+};
+
+/****************************************************************************
+ * Moli FW_CONFIG access
+ */
+void board_init_fw_config(void)
+{
+ if (cbi_get_fw_config(&fw_config.raw_value)) {
+ CPRINTS("CBI: Read FW_CONFIG failed, using board defaults");
+ fw_config = fw_config_defaults;
+ }
+}
+
+union moli_cbi_fw_config get_fw_config(void)
+{
+ return fw_config;
+}
+
+void ec_bj_power(uint32_t *voltage, uint32_t *current)
+{
+ unsigned int bj;
+
+ bj = fw_config.bj_power;
+ /* Out of range value defaults to 0 */
+ if (bj >= ARRAY_SIZE(bj_power))
+ bj = 0;
+ *voltage = bj_power[bj].voltage;
+ *current = bj_power[bj].current;
+}
+
+enum ec_cfg_power_on_monitor ec_cfg_power_on_monitor(void)
+{
+ return fw_config.po_mon;
+}
diff --git a/board/moli/fw_config.h b/board/moli/fw_config.h
new file mode 100644
index 0000000000..ee3dcd274d
--- /dev/null
+++ b/board/moli/fw_config.h
@@ -0,0 +1,53 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __BOARD_MOLI_FW_CONFIG_H_
+#define __BOARD_MOLI_FW_CONFIG_H_
+
+#include <stdint.h>
+
+/****************************************************************************
+ * CBI FW_CONFIG layout for Moli board.
+ *
+ * Source of truth is the project/brask/moli/config.star configuration file.
+ */
+
+enum ec_cfg_bj_power { BJ_90W = 0, BJ_135W = 1 };
+
+enum ec_cfg_power_on_monitor {
+ POWER_ON_MONITOR_ENABLE = 0,
+ POWER_ON_MONITOR_DISABLE = 1
+};
+
+union moli_cbi_fw_config {
+ struct {
+ uint32_t bj_power : 2;
+ uint32_t mlb_usb_tbt : 2;
+ uint32_t storage : 2;
+ uint32_t audio : 1;
+ enum ec_cfg_power_on_monitor po_mon : 1;
+ uint32_t reserved_1 : 24;
+ };
+ uint32_t raw_value;
+};
+
+/**
+ * Read the cached FW_CONFIG. Guaranteed to have valid values.
+ *
+ * @return the FW_CONFIG for the board.
+ */
+union moli_cbi_fw_config get_fw_config(void);
+
+/**
+ * Get the barrel-jack power from FW_CONFIG.
+ */
+void ec_bj_power(uint32_t *voltage, uint32_t *current);
+
+/**
+ * Get enable/disable power on by monitor from FW_CONFIG.
+ */
+enum ec_cfg_power_on_monitor ec_cfg_power_on_monitor(void);
+
+#endif /* __BOARD_MOLI_FW_CONFIG_H_ */
diff --git a/board/moli/gpio.inc b/board/moli/gpio.inc
index fb3b508573..e8473f8c95 100644
--- a/board/moli/gpio.inc
+++ b/board/moli/gpio.inc
@@ -25,6 +25,9 @@ GPIO_INT(EC_RECOVERY_BTN_ODL, PIN(2, 3), GPIO_INT_BOTH, button_interrupt)
GPIO_INT(USB_C1_RT_INT_ODL, PIN(4, 1), GPIO_INT_FALLING, retimer_interrupt)
GPIO_INT(USB_C1_BC12_INT_ODL, PIN(8, 3), GPIO_INT_FALLING, bc12_interrupt)
GPIO_INT(USB_C1_PPC_INT_ODL, PIN(7, 0), GPIO_INT_FALLING, ppc_interrupt)
+GPIO_INT(HDMI1_MONITOR_ON, PIN(B, 4), GPIO_INT_RISING, monitor_interrupt)
+GPIO_INT(HDMI2_MONITOR_ON, PIN(B, 5), GPIO_INT_RISING, monitor_interrupt)
+GPIO_INT(OPTION_MONITOR_ON, PIN(1, 0), GPIO_INT_RISING, monitor_interrupt)
/* CCD */
GPIO(CCD_MODE_ODL, PIN(E, 5), GPIO_INPUT)
@@ -120,12 +123,9 @@ GPIO(LED_ORANGE_CONTROL, PIN(3, 1), GPIO_ODR_LOW)
GPIO(LED_BLUE_CONTROL, PIN(2, 5), GPIO_ODR_LOW)
/* Option Board */
-GPIO(HDMI1_MONITOR_ON, PIN(B, 4), GPIO_INPUT)
-GPIO(HDMI1_MONON_SIO, PIN(1, 6), GPIO_ODR_LOW)
-GPIO(OPTION_MONITOR_ON, PIN(1, 0), GPIO_INPUT)
-GPIO(OPTION_MONON_SIO, PIN(2, 1), GPIO_ODR_LOW)
-GPIO(HDMI2_MONITOR_ON, PIN(B, 5), GPIO_INPUT)
-GPIO(HDMI2_MONON_SIO, PIN(1, 5), GPIO_ODR_LOW)
+GPIO(HDMI1_MONON_SIO, PIN(1, 6), GPIO_INPUT)
+GPIO(HDMI2_MONON_SIO, PIN(1, 5), GPIO_INPUT)
+GPIO(OPTION_MONON_SIO, PIN(2, 1), GPIO_INPUT)
IOEX(USB_C0_OC_ODL, EXPIN(IOEX_C0_NCT38XX, 0, 4), GPIO_ODR_HIGH)
IOEX(USB_C0_FRS_EN, EXPIN(IOEX_C0_NCT38XX, 0, 6), GPIO_LOW)
diff --git a/board/moli/led.c b/board/moli/led.c
index f2ab214418..edb429e530 100644
--- a/board/moli/led.c
+++ b/board/moli/led.c
@@ -270,8 +270,8 @@ int led_set_brightness(enum ec_led_id id, const uint8_t *brightness)
return set_color(id, LED_OFF, 0);
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Blink alert if insufficient power per system_can_boot_ap(). */
int insufficient_power =
diff --git a/board/mrbland/board.c b/board/mrbland/board.c
index 50ba008512..52b1c50a1b 100644
--- a/board/mrbland/board.c
+++ b/board/mrbland/board.c
@@ -585,8 +585,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -598,9 +598,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_ma = charge_ma * 95 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/mrbland/board.h b/board/mrbland/board.h
index 0f78db50d9..cc6207ca83 100644
--- a/board/mrbland/board.h
+++ b/board/mrbland/board.h
@@ -24,6 +24,8 @@
#define CONFIG_BATTERY_FUEL_GAUGE
#define CONFIG_BATTERY_VENDOR_PARAM
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
+
/* Enable PD3.0 */
#define CONFIG_USB_PD_REV30
diff --git a/board/munna/board.c b/board/munna/board.c
index f6996b8460..6d7b35da1c 100644
--- a/board/munna/board.c
+++ b/board/munna/board.c
@@ -236,14 +236,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/munna/board.h b/board/munna/board.h
index 5dc35c68df..20194bed88 100644
--- a/board/munna/board.h
+++ b/board/munna/board.h
@@ -40,6 +40,7 @@
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_RUNTIME_CONFIG
diff --git a/board/nami/board.c b/board/nami/board.c
index 02fb27a283..2ab66ab951 100644
--- a/board/nami/board.c
+++ b/board/nami/board.c
@@ -747,8 +747,8 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Limit the input current to 96% negotiated limit,
@@ -760,8 +760,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
(model == MODEL_EKKO || model == MODEL_BARD))
factor = 95;
charge_ma = charge_ma * factor / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
void board_hibernate(void)
diff --git a/board/nami/board.h b/board/nami/board.h
index 51cde41acb..652db4826d 100644
--- a/board/nami/board.h
+++ b/board/nami/board.h
@@ -96,7 +96,8 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 27000
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000
/* AP's thresholds. */
diff --git a/board/nautilus/board.c b/board/nautilus/board.c
index 3cdd7abaf1..af7d7f48d4 100644
--- a/board/nautilus/board.c
+++ b/board/nautilus/board.c
@@ -528,26 +528,6 @@ int board_set_active_charge_port(int charge_port)
}
/**
- * Set the charge limit based upon desired maximum.
- *
- * @param port Port number.
- * @param supplier Charge supplier type.
- * @param charge_ma Desired charge limit (mA).
- * @param charge_mv Negotiated charge voltage (mV).
- */
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- /*
- * Limit the input current to 96% negotiated limit,
- * to account for the charger chip margin.
- */
- charge_ma = charge_ma * 96 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
-/**
* Return the maximum allowed input current
*/
int board_get_ramp_current_limit(int supplier, int sup_curr)
diff --git a/board/nautilus/board.h b/board/nautilus/board.h
index cbca28a71f..2b4f25538d 100644
--- a/board/nautilus/board.h
+++ b/board/nautilus/board.h
@@ -79,11 +79,13 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_CHARGER_PSYS
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* margining */
#define CONFIG_CMD_CHARGER_ADC_AMON_BMON
#define CONFIG_HOSTCMD_PD_CONTROL
#define CONFIG_EXTPOWER_GPIO
diff --git a/board/nocturne/board.c b/board/nocturne/board.c
index d32f036844..1c0b2b3397 100644
--- a/board/nocturne/board.c
+++ b/board/nocturne/board.c
@@ -760,19 +760,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * Nocturne seems to overdraw its set input current limit by about 5%.
- * Request at most 95% of what's desired.
- */
- icl = icl * 95 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
static void board_chipset_reset(void)
{
board_report_pmic_fault("CHIPSET RESET");
diff --git a/board/nocturne/board.h b/board/nocturne/board.h
index 279016ec98..73700b8480 100644
--- a/board/nocturne/board.h
+++ b/board/nocturne/board.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_BOARD_H
#define __CROS_EC_BOARD_H
+#define CONFIG_LTO
+
/*
* By default, enable all console messages excepted HC, ACPI and event:
* The sensor stack is generating a lot of activity.
@@ -31,6 +33,7 @@
#define CONFIG_ADC
#define CONFIG_BACKLIGHT_LID
#define CONFIG_HOST_INTERFACE_ESPI
+#define CONFIG_FPU
#define CONFIG_I2C
#define CONFIG_I2C_BUS_MAY_BE_UNPOWERED
#define CONFIG_I2C_CONTROLLER
@@ -67,8 +70,14 @@
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 128
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 128
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 128
#define CONFIG_CHARGER_ISL9238
+/*
+ * Nocturne seems to overdraw its set input current limit by about 5%.
+ * Request at most 95% of what's desired.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
#define CONFIG_CHARGER_PROFILE_OVERRIDE
diff --git a/board/nocturne_fp/board.h b/board/nocturne_fp/board.h
index e7d34445b0..d95df6101a 100644
--- a/board/nocturne_fp/board.h
+++ b/board/nocturne_fp/board.h
@@ -110,7 +110,6 @@
#define CONFIG_SHA256
#define CONFIG_SHA256_UNROLLED
#define CONFIG_SPI
-#define CONFIG_STM_HWTIMER32
#undef CONFIG_TASK_PROFILING
#define CONFIG_WATCHDOG_HELP
#define CONFIG_WP_ACTIVE_HIGH
diff --git a/board/nocturne_fp/build.mk b/board/nocturne_fp/build.mk
index 65ffd6c096..2bc59c1f13 100644
--- a/board/nocturne_fp/build.mk
+++ b/board/nocturne_fp/build.mk
@@ -29,6 +29,7 @@ test-list-y=\
abort \
aes \
always_memset \
+ benchmark \
cec \
compile_time_macros \
cortexm_fpu \
@@ -39,6 +40,8 @@ test-list-y=\
flash_write_protect \
fpsensor \
fpsensor_hw \
+ ftrapv \
+ libc_printf \
mpu \
mutex \
panic \
@@ -46,6 +49,7 @@ test-list-y=\
pingpong \
printf \
queue \
+ rng_benchmark \
rollback \
rollback_entropy \
rsa3 \
diff --git a/board/nucleo-dartmonkey/build.mk b/board/nucleo-dartmonkey/build.mk
index 2e3e1f31d2..b544490fc9 100644
--- a/board/nucleo-dartmonkey/build.mk
+++ b/board/nucleo-dartmonkey/build.mk
@@ -22,11 +22,13 @@ test-list-y=\
flash_write_protect \
fpsensor \
fpsensor_hw \
+ libc_printf \
mpu \
mutex \
pingpong \
printf \
queue \
+ rng_benchmark \
rollback \
rollback_entropy \
rsa3 \
diff --git a/board/nucleo-f072rb/board.h b/board/nucleo-f072rb/board.h
index d807209564..bd957d35db 100644
--- a/board/nucleo-f072rb/board.h
+++ b/board/nucleo-f072rb/board.h
@@ -16,7 +16,6 @@
#define CONFIG_UART_CONSOLE 2
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#ifdef CTS_MODULE
#undef STM32_IRQ_EXT2_3_PRIORITY
diff --git a/board/nucleo-f411re/board.h b/board/nucleo-f411re/board.h
index d4e299dcff..3b7d5f1bf1 100644
--- a/board/nucleo-f411re/board.h
+++ b/board/nucleo-f411re/board.h
@@ -19,7 +19,6 @@
/* Optional features */
#undef CONFIG_LID_SWITCH
#undef CONFIG_HIBERNATE
-#define CONFIG_STM_HWTIMER32
#define CONFIG_WATCHDOG_HELP
#define CONFIG_TASK_PROFILING
diff --git a/board/nucleo-f412zg/build.mk b/board/nucleo-f412zg/build.mk
index 21a2955bc4..d923a7a40f 100644
--- a/board/nucleo-f412zg/build.mk
+++ b/board/nucleo-f412zg/build.mk
@@ -19,11 +19,13 @@ test-list-y=\
exception \
flash_physical \
flash_write_protect \
+ libc_printf \
mpu \
mutex \
pingpong \
printf \
queue \
+ rng_benchmark \
rollback \
rollback_entropy \
rsa3 \
diff --git a/board/nucleo-g431rb/board.h b/board/nucleo-g431rb/board.h
index 905b4ea110..e2df8d2547 100644
--- a/board/nucleo-g431rb/board.h
+++ b/board/nucleo-g431rb/board.h
@@ -12,7 +12,6 @@
#define CONFIG_SYSTEM_UNLOCKED /* Allow dangerous commands while in dev. */
#define CPU_CLOCK 48000000
-#define CONFIG_STM_HWTIMER32
#define TIM_CLOCK32 2
#define TIM_CLOCK_MSB 3
#define TIM_CLOCK_LSB 15
diff --git a/board/nucleo-h743zi/build.mk b/board/nucleo-h743zi/build.mk
index 6153d85d8a..ad04a68918 100644
--- a/board/nucleo-h743zi/build.mk
+++ b/board/nucleo-h743zi/build.mk
@@ -19,11 +19,13 @@ test-list-y=\
exception \
flash_physical \
flash_write_protect \
+ libc_printf \
mpu \
mutex \
pingpong \
printf \
queue \
+ rng_benchmark \
rollback \
rollback_entropy \
rsa3 \
diff --git a/board/oak/board.c b/board/oak/board.c
index 468b6e6677..17908caa7a 100644
--- a/board/oak/board.c
+++ b/board/oak/board.c
@@ -357,11 +357,10 @@ int board_set_active_charge_port(int charge_port)
* @param charge_ma Desired charge limit (mA).
* @param charge_mv Negotiated charge voltage (mV).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
pd_send_host_event(PD_EVENT_POWER_CHANGE);
}
diff --git a/board/oak/board.h b/board/oak/board.h
index 6f5ed3fc87..c429a655c5 100644
--- a/board/oak/board.h
+++ b/board/oak/board.h
@@ -14,6 +14,7 @@
/* Free up some flash space */
#define CONFIG_DEBUG_ASSERT_BRIEF
#define CONFIG_USB_PD_DEBUG_LEVEL 0
+#undef CONFIG_CONSOLE_CMDHELP
#define CONFIG_LTO
@@ -39,7 +40,8 @@
#define CONFIG_CHARGE_MANAGER
#define CONFIG_CHARGER
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#if BOARD_REV == OAK_REV1
#define CONFIG_CHARGER_BQ24773
@@ -105,7 +107,6 @@
#define CONFIG_USB_PD_VBUS_DETECT_TCPC
#define CONFIG_SPI
#define CONFIG_SPI_CONTROLLER
-#define CONFIG_STM_HWTIMER32
#define CONFIG_VBOOT_HASH
#undef CONFIG_WATCHDOG_HELP
#define CONFIG_SWITCH
diff --git a/board/osiris/charger.c b/board/osiris/charger.c
index 88f5b85a41..7a16fcd5cb 100644
--- a/board/osiris/charger.c
+++ b/board/osiris/charger.c
@@ -79,10 +79,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/pazquel/board.c b/board/pazquel/board.c
index 6ed03e90ad..1efad2255f 100644
--- a/board/pazquel/board.c
+++ b/board/pazquel/board.c
@@ -305,6 +305,7 @@ void board_tcpc_init(void)
/* Enable PPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -533,8 +534,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -546,8 +547,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/pdeval-stm32f072/board.h b/board/pdeval-stm32f072/board.h
index 4cb55573f4..6ba7923b8e 100644
--- a/board/pdeval-stm32f072/board.h
+++ b/board/pdeval-stm32f072/board.h
@@ -21,7 +21,6 @@
#define CONFIG_HW_CRC
#define CONFIG_I2C
#define CONFIG_I2C_CONTROLLER
-#define CONFIG_STM_HWTIMER32
/* USB Power Delivery configuration */
#define CONFIG_USB_POWER_DELIVERY
#define CONFIG_USB_PD_TCPMV1
diff --git a/board/pico/board.c b/board/pico/board.c
index f884545b6d..801c344a69 100644
--- a/board/pico/board.c
+++ b/board/pico/board.c
@@ -320,14 +320,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/pico/board.h b/board/pico/board.h
index 665cf59691..97128b54f1 100644
--- a/board/pico/board.h
+++ b/board/pico/board.h
@@ -28,6 +28,7 @@
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_RUNTIME_CONFIG
diff --git a/board/pirika/board.c b/board/pirika/board.c
index 8913ec0f07..ae1c74bdfc 100644
--- a/board/pirika/board.c
+++ b/board/pirika/board.c
@@ -491,18 +491,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * TODO(b/151955431): Characterize the input current limit in case a
- * scaling needs to be applied here
- */
- charge_set_input_current_limit(icl, charge_mv);
-}
-
int board_is_sourcing_vbus(int port)
{
int regval;
@@ -590,7 +578,7 @@ __override void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki,
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
- if (port < 0 || port > board_get_usb_pd_port_count())
+ if (!board_is_usb_pd_port_present(port))
return;
raa489000_set_output_current(port, rp);
diff --git a/board/plankton/board.h b/board/plankton/board.h
index 224364269b..a17bd30c3c 100644
--- a/board/plankton/board.h
+++ b/board/plankton/board.h
@@ -16,7 +16,6 @@
#define CONFIG_UART_CONSOLE 2
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_USB_POWER_DELIVERY
#define CONFIG_USB_PD_TCPMV1
#define CONFIG_USB_PD_ALT_MODE
diff --git a/board/polyberry/board.h b/board/polyberry/board.h
index 41069f2722..1390bb996c 100644
--- a/board/polyberry/board.h
+++ b/board/polyberry/board.h
@@ -60,7 +60,6 @@
#undef CONFIG_WATCHDOG
/* Optional features */
-#define CONFIG_STM_HWTIMER32
/*
* Allow dangerous commands all the time, since we don't have a write protect
diff --git a/board/pompom/board.c b/board/pompom/board.c
index 394f06be8e..ccaff4f55f 100644
--- a/board/pompom/board.c
+++ b/board/pompom/board.c
@@ -269,8 +269,6 @@ DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
void board_hibernate(void)
{
- int i;
-
/*
* Sensors are unpowered in hibernate. Apply PD to the
* interrupt lines such that they don't float.
@@ -290,8 +288,7 @@ void board_hibernate(void)
* otherwise, ACOK won't go High and can't wake EC up. Check the
* bug b/170324206 for details.
*/
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
- ppc_vbus_sink_enable(i, 1);
+ ppc_vbus_sink_enable(USB_PD_PORT_C0, 1);
}
__override uint16_t board_get_ps8xxx_product_id(int port)
@@ -323,9 +320,9 @@ void board_tcpc_init(void)
* Initialize HPD to low; after sysjump SOC needs to see
* HPD pulse to enable video path
*/
- for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ usb_mux_hpd_update(USB_PD_PORT_C0,
+ USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
}
DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_INIT_I2C + 1);
@@ -405,24 +402,20 @@ void board_overcurrent_event(int port, int is_overcurrented)
int board_set_active_charge_port(int port)
{
- int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
- int i;
+ int is_real_port = (port == USB_PD_PORT_C0);
if (!is_real_port && port != CHARGE_PORT_NONE)
return EC_ERROR_INVAL;
if (port == CHARGE_PORT_NONE) {
CPRINTS("Disabling all charging port");
-
- /* Disable all ports. */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- /*
- * Do not return early if one fails otherwise we can
- * get into a boot loop assertion failure.
- */
- if (board_vbus_sink_enable(i, 0))
- CPRINTS("Disabling p%d sink path failed.", i);
- }
+ /*
+ * Do not return early if one fails otherwise we can
+ * get into a boot loop assertion failure.
+ */
+ if (board_vbus_sink_enable(USB_PD_PORT_C0, 0))
+ CPRINTS("Disabling p%d sink path failed.",
+ USB_PD_PORT_C0);
return EC_SUCCESS;
}
@@ -435,18 +428,6 @@ int board_set_active_charge_port(int port)
CPRINTS("New charge port: p%d", port);
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- if (i == port)
- continue;
-
- if (board_vbus_sink_enable(i, 0))
- CPRINTS("p%d: sink path disable failed.", i);
- }
-
/* Enable requested charge port. */
if (board_vbus_sink_enable(port, 1)) {
CPRINTS("p%d: sink path enable failed.", port);
@@ -456,8 +437,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -469,9 +450,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_ma = charge_ma * 95 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/pompom/board.h b/board/pompom/board.h
index 40e7185c16..774b339273 100644
--- a/board/pompom/board.h
+++ b/board/pompom/board.h
@@ -23,6 +23,8 @@
/* BC 1.2 Charger */
#define CONFIG_BC12_DETECT_PI3USB9201
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
+
/* USB */
#define CONFIG_USB_PD_TCPM_MULTI_PS8XXX
#define CONFIG_USB_PD_TCPM_PS8751
@@ -30,6 +32,7 @@
#define CONFIG_USB_PD_TCPM_PS8805
#define CONFIG_USBC_PPC_SN5S330
#define CONFIG_USB_PD_PORT_MAX_COUNT 1
+#define USB_PD_PORT_C0 0
/* USB-A */
#define USB_PORT_COUNT 1
diff --git a/board/poppy/board.c b/board/poppy/board.c
index 38183c0da0..ab3f3b40b0 100644
--- a/board/poppy/board.c
+++ b/board/poppy/board.c
@@ -58,9 +58,6 @@
#define USB_PD_PORT_ANX74XX 0
-/* Minimum input current limit. */
-#define ILIM_MIN_MA 472
-
static void tcpc_alert_event(enum gpio_signal signal)
{
if ((signal == GPIO_USB_C0_PD_INT_ODL) &&
@@ -679,8 +676,8 @@ int board_set_active_charge_port(int charge_port)
* @param charge_ma Desired charge limit (mA).
* @param charge_mv Negotiated charge voltage (mV).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Adjust ILIM according to measurements to eliminate overshoot. */
charge_ma = (charge_ma - 500) * 31 / 32 + 472;
@@ -688,7 +685,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
if (charge_mv > 5000)
charge_ma -= 52;
- charge_set_input_current_limit(MAX(charge_ma, ILIM_MIN_MA), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
void board_hibernate(void)
diff --git a/board/poppy/board.h b/board/poppy/board.h
index b55dc1d818..5242c1d3a8 100644
--- a/board/poppy/board.h
+++ b/board/poppy/board.h
@@ -89,7 +89,8 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 472
#define CONFIG_CHARGER_PSYS
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
diff --git a/board/primus/board.c b/board/primus/board.c
index 8b5f1a86fc..3f438cee00 100644
--- a/board/primus/board.c
+++ b/board/primus/board.c
@@ -137,8 +137,7 @@ __override void board_set_charge_limit(int port, int supplier, int charge_ma,
else
charge_ma = charge_ma * 93 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
static void configure_input_current_limit(void)
@@ -159,9 +158,7 @@ static void configure_input_current_limit(void)
else
adapter_current_ma = adapter_current_ma * 97 / 100;
- charge_set_input_current_limit(MAX(adapter_current_ma,
- CONFIG_CHARGER_INPUT_CURRENT),
- adapter_current_mv);
+ charge_set_input_current_limit(adapter_current_ma, adapter_current_mv);
}
DECLARE_HOOK(HOOK_CHIPSET_STARTUP, configure_input_current_limit,
HOOK_PRIO_DEFAULT);
diff --git a/board/primus/charger.c b/board/primus/charger.c
index a4fa209246..7fabd2082e 100644
--- a/board/primus/charger.c
+++ b/board/primus/charger.c
@@ -81,10 +81,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/prism/board.h b/board/prism/board.h
index 5c3cabce53..42768de2e7 100644
--- a/board/prism/board.h
+++ b/board/prism/board.h
@@ -111,7 +111,6 @@
#define CONFIG_LTO
#define CONFIG_FORCE_CONSOLE_RESUME
#define CONFIG_MATH_UTIL
-#define CONFIG_STM_HWTIMER32
/* USB Configuration */
#define CONFIG_USB
diff --git a/board/puff/board.c b/board/puff/board.c
index d863b5fc0b..5475773aa0 100644
--- a/board/puff/board.c
+++ b/board/puff/board.c
@@ -88,8 +88,8 @@ uint16_t tcpc_get_alert_status(void)
}
/* Called when the charge manager has switched to a new port. */
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Blink alert if insufficient power per system_can_boot_ap(). */
int insufficient_power =
diff --git a/board/quackingstick/board.c b/board/quackingstick/board.c
index 6cdf814c74..7002a62e03 100644
--- a/board/quackingstick/board.c
+++ b/board/quackingstick/board.c
@@ -612,8 +612,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -625,9 +625,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_ma = charge_ma * 95 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
/**
diff --git a/board/quackingstick/board.h b/board/quackingstick/board.h
index 9b50237b4d..a8ec5a4231 100644
--- a/board/quackingstick/board.h
+++ b/board/quackingstick/board.h
@@ -32,6 +32,8 @@
#define CONFIG_BATTERY_FUEL_GAUGE
#define CONFIG_BATTERY_VENDOR_PARAM
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
+
/* BC 1.2 Charger */
#define CONFIG_BC12_DETECT_PI3USB9201
diff --git a/board/rainier/board.c b/board/rainier/board.c
index 07a006b671..05142a3936 100644
--- a/board/rainier/board.c
+++ b/board/rainier/board.c
@@ -173,8 +173,8 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* NOP because there is no internal power therefore no charging.
diff --git a/board/rainier/board.h b/board/rainier/board.h
index 463a1e4a05..745ebeaca8 100644
--- a/board/rainier/board.h
+++ b/board/rainier/board.h
@@ -22,7 +22,6 @@
#define CONFIG_POWER_COMMON
#define CONFIG_SPI
#define CONFIG_SPI_CONTROLLER
-#define CONFIG_STM_HWTIMER32
/* Source RTCCLK from external 32.768kHz source on PC15/OSC32_IN. */
#define CONFIG_STM32_CLOCK_LSE
#define CONFIG_SWITCH
diff --git a/board/rammus/board.c b/board/rammus/board.c
index 8cbc6c6856..e4abed4afb 100644
--- a/board/rammus/board.c
+++ b/board/rammus/board.c
@@ -558,26 +558,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-/**
- * Set the charge limit based upon desired maximum.
- *
- * @param port Port number.
- * @param supplier Charge supplier type.
- * @param charge_ma Desired charge limit (mA).
- * @param charge_mv Negotiated charge voltage (mV).
- */
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- /*
- * Limit the input current to 96% negotiated limit,
- * to account for the charger chip margin.
- */
- charge_ma = charge_ma * 96 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
void board_hibernate(void)
{
CPRINTS("Triggering PMIC shutdown.");
diff --git a/board/rammus/board.h b/board/rammus/board.h
index c0c8238c3e..975417df9a 100644
--- a/board/rammus/board.h
+++ b/board/rammus/board.h
@@ -84,10 +84,12 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_ISL9238
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_PSYS
#define CONFIG_CHARGER_SENSE_RESISTOR 10
#define CONFIG_CHARGER_SENSE_RESISTOR_AC 20
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4 /* charger margin */
#define CONFIG_CMD_CHARGER_ADC_AMON_BMON
#define CONFIG_HOSTCMD_PD_CONTROL
#define CONFIG_EXTPOWER_GPIO
diff --git a/board/redrix/charger.c b/board/redrix/charger.c
index a4fa209246..7fabd2082e 100644
--- a/board/redrix/charger.c
+++ b/board/redrix/charger.c
@@ -81,10 +81,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/reef/board.c b/board/reef/board.c
index e41921a436..ad92334c2b 100644
--- a/board/reef/board.c
+++ b/board/reef/board.c
@@ -543,8 +543,8 @@ int board_set_active_charge_port(int charge_port)
* @param charge_ma Desired charge limit (mA).
* @param charge_mv Negotiated charge voltage (mV).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Enable charging trigger by BC1.2 detection */
int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP ||
@@ -555,9 +555,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
if (bd9995x_bc12_enable_charging(port, bc12_enable))
return;
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
/**
diff --git a/board/reef/board.h b/board/reef/board.h
index fc25024dff..cc1783e43a 100644
--- a/board/reef/board.h
+++ b/board/reef/board.h
@@ -50,7 +50,9 @@
#define CONFIG_CHARGER_BD9995X
#define CONFIG_CHARGER_BD9995X_CHGEN
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 18000
#define CONFIG_CHARGER_MAINTAIN_VBAT
diff --git a/board/reef_it8320/board.c b/board/reef_it8320/board.c
index b00e451842..1e222a4ed4 100644
--- a/board/reef_it8320/board.c
+++ b/board/reef_it8320/board.c
@@ -299,8 +299,8 @@ int board_set_active_charge_port(int charge_port)
* @param charge_ma Desired charge limit (mA).
* @param charge_mv Negotiated charge voltage (mV).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Enable charging trigger by BC1.2 detection */
int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP ||
@@ -311,9 +311,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
if (bd9995x_bc12_enable_charging(port, bc12_enable))
return;
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
/**
diff --git a/board/reef_it8320/board.h b/board/reef_it8320/board.h
index 45abf34151..dbccc6eeee 100644
--- a/board/reef_it8320/board.h
+++ b/board/reef_it8320/board.h
@@ -48,7 +48,9 @@
#define CONFIG_CHARGER_BD9995X
#define CONFIG_CHARGER_BD9995X_CHGEN
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 18000
#define CONFIG_CHARGER_MAINTAIN_VBAT
diff --git a/board/reef_mchp/board.c b/board/reef_mchp/board.c
index 0a40f5dd04..c50a4feb8a 100644
--- a/board/reef_mchp/board.c
+++ b/board/reef_mchp/board.c
@@ -736,8 +736,8 @@ int board_set_active_charge_port(int charge_port)
* @param charge_ma Desired charge limit (mA).
* @param charge_mv Negotiated charge voltage (mV).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/* Enable charging trigger by BC1.2 detection */
int bc12_enable = (supplier == CHARGE_SUPPLIER_BC12_CDP ||
@@ -748,9 +748,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
if (bd9995x_bc12_enable_charging(port, bc12_enable))
return;
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
/**
diff --git a/board/reef_mchp/board.h b/board/reef_mchp/board.h
index bde2d831d3..925f271ffd 100644
--- a/board/reef_mchp/board.h
+++ b/board/reef_mchp/board.h
@@ -53,7 +53,9 @@
#define CONFIG_CHARGER_BD9995X
#define CONFIG_CHARGER_BD9995X_CHGEN
#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 1
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 18000
#define CONFIG_CHARGER_MAINTAIN_VBAT
diff --git a/board/sasuke/board.c b/board/sasuke/board.c
index ddd5279d62..e6767d8126 100644
--- a/board/sasuke/board.c
+++ b/board/sasuke/board.c
@@ -395,19 +395,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/sasuke/board.h b/board/sasuke/board.h
index 64c830df0f..df390d2d99 100644
--- a/board/sasuke/board.h
+++ b/board/sasuke/board.h
@@ -29,6 +29,11 @@
#define CONFIG_OCPC_DEF_RBATT_MOHMS \
22 /* R_DS(on) 11.6mOhm + 10mOhm sns rstr \
*/
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
#define CONFIG_OCPC
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#define CONFIG_CHARGE_RAMP_HW
diff --git a/board/sasukette/board.c b/board/sasukette/board.c
index e45213a63a..f6786c1441 100644
--- a/board/sasukette/board.c
+++ b/board/sasukette/board.c
@@ -251,19 +251,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
int board_is_sourcing_vbus(int port)
{
int regval;
diff --git a/board/sasukette/board.h b/board/sasukette/board.h
index 44cb65239a..f06a89a5f0 100644
--- a/board/sasukette/board.h
+++ b/board/sasukette/board.h
@@ -36,6 +36,11 @@
#define CONFIG_CHARGER_PROFILE_OVERRIDE
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE (100 * MSEC)
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
/* LED */
#define CONFIG_LED_COMMON
diff --git a/board/scarlet/board.c b/board/scarlet/board.c
index 34e5cc456c..66017e172d 100644
--- a/board/scarlet/board.c
+++ b/board/scarlet/board.c
@@ -212,13 +212,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int extpower_is_present(void)
{
/*
diff --git a/board/scarlet/board.h b/board/scarlet/board.h
index 4691d74391..cdc09f9114 100644
--- a/board/scarlet/board.h
+++ b/board/scarlet/board.h
@@ -32,7 +32,6 @@
#define CONFIG_POWER_COMMON
#define CONFIG_SPI
#define CONFIG_SPI_CONTROLLER
-#define CONFIG_STM_HWTIMER32
/* Source RTCCLK from external 32.768kHz source on PC15/OSC32_IN. */
#define CONFIG_STM32_CLOCK_LSE
#define CONFIG_SWITCH
@@ -70,7 +69,8 @@
#define CONFIG_CHARGER
#define CONFIG_CHARGER_RT9467
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_BAT_PCT 2
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 15000
#define CONFIG_CHARGER_PROFILE_OVERRIDE
diff --git a/board/servo_micro/board.h b/board/servo_micro/board.h
index 801b67e07e..109a40409d 100644
--- a/board/servo_micro/board.h
+++ b/board/servo_micro/board.h
@@ -30,7 +30,6 @@
#undef CONFIG_UART_RX_DMA
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_HW_CRC
#define CONFIG_PVD
/* See 'Programmable voltage detector characteristics' in the STM32F072x8
diff --git a/board/servo_v4/board.h b/board/servo_v4/board.h
index 289c117989..1c7d90eab4 100644
--- a/board/servo_v4/board.h
+++ b/board/servo_v4/board.h
@@ -35,7 +35,6 @@
#define CONFIG_CMD_USART_INFO
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_HW_CRC
#define CONFIG_PVD
/* See 'Programmable voltage detector characteristics' in the STM32F072x8
@@ -97,6 +96,8 @@
#undef CONFIG_CMD_FLASHINFO
#undef CONFIG_CMD_FLASH_WP
#undef CONFIG_CMD_GETTIME
+#undef CONFIG_CMD_I2C_SCAN
+#undef CONFIG_CMD_I2C_XFER
#undef CONFIG_CMD_MEM
#undef CONFIG_CMD_SHMEM
#undef CONFIG_CMD_SYSLOCK
diff --git a/board/servo_v4/usb_pd_policy.c b/board/servo_v4/usb_pd_policy.c
index 4fcded6842..e3eba6104a 100644
--- a/board/servo_v4/usb_pd_policy.c
+++ b/board/servo_v4/usb_pd_policy.c
@@ -364,8 +364,8 @@ int board_set_active_charge_port(int charge_port)
return 0;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
if (port != CHG)
return;
diff --git a/board/servo_v4p1/board.h b/board/servo_v4p1/board.h
index b6c7915c6c..4debd67b49 100644
--- a/board/servo_v4p1/board.h
+++ b/board/servo_v4p1/board.h
@@ -97,7 +97,6 @@
#undef CONFIG_UART_RX_DMA
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_HW_CRC
#define CONFIG_PVD
/*
diff --git a/board/servo_v4p1/usb_pd_policy.c b/board/servo_v4p1/usb_pd_policy.c
index 7f5b6f35bf..fc79bf84da 100644
--- a/board/servo_v4p1/usb_pd_policy.c
+++ b/board/servo_v4p1/usb_pd_policy.c
@@ -391,8 +391,8 @@ int board_set_active_charge_port(int charge_port)
return 0;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
if (port != CHG)
return;
diff --git a/board/shotzo/board.c b/board/shotzo/board.c
index dea75ee7d2..5d96e164cf 100644
--- a/board/shotzo/board.c
+++ b/board/shotzo/board.c
@@ -351,8 +351,8 @@ uint16_t tcpc_get_alert_status(void)
return 0;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
if (port == CHARGER_SOLO) {
charger_set_input_current_limit(CHARGER_SOLO, max_ma);
diff --git a/board/stern/board.c b/board/stern/board.c
index 26576ede86..a6d488aaf6 100644
--- a/board/stern/board.c
+++ b/board/stern/board.c
@@ -236,14 +236,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/stern/board.h b/board/stern/board.h
index eedbc2a44c..d7d96ea67c 100644
--- a/board/stern/board.h
+++ b/board/stern/board.h
@@ -28,6 +28,7 @@
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_RUNTIME_CONFIG
diff --git a/board/stm32f446e-eval/board.h b/board/stm32f446e-eval/board.h
index 4ae9117829..667483d81f 100644
--- a/board/stm32f446e-eval/board.h
+++ b/board/stm32f446e-eval/board.h
@@ -56,7 +56,6 @@
#undef CONFIG_WATCHDOG
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_DMA_HELP
#define CONFIG_FLASH_CROS
diff --git a/board/stm32l476g-eval/board.h b/board/stm32l476g-eval/board.h
index 26ea530e4e..40c7fb0eca 100644
--- a/board/stm32l476g-eval/board.h
+++ b/board/stm32l476g-eval/board.h
@@ -33,7 +33,6 @@
#endif
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#ifdef CTS_MODULE_I2C
#define CONFIG_I2C
diff --git a/board/storo/board.c b/board/storo/board.c
index f6f3ed5750..83d9ef4c72 100644
--- a/board/storo/board.c
+++ b/board/storo/board.c
@@ -431,19 +431,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
int board_is_sourcing_vbus(int port)
{
int regval;
diff --git a/board/storo/board.h b/board/storo/board.h
index 93dd573ba1..1f33ce53b0 100644
--- a/board/storo/board.h
+++ b/board/storo/board.h
@@ -31,6 +31,11 @@
#define CONFIG_OCPC_DEF_RBATT_MOHMS \
22 /* R_DS(on) 11.6mOhm + 10mOhm sns rstr \
*/
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
#define CONFIG_OCPC
#undef CONFIG_CHARGER_SINGLE_CHIP
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
diff --git a/board/sweetberry/board.h b/board/sweetberry/board.h
index 4387cd4094..4d945f5dc4 100644
--- a/board/sweetberry/board.h
+++ b/board/sweetberry/board.h
@@ -77,7 +77,6 @@
#undef CONFIG_WATCHDOG
/* Optional features */
-#define CONFIG_STM_HWTIMER32
/*
* Allow dangerous commands all the time, since we don't have a write protect
diff --git a/board/taeko/board.c b/board/taeko/board.c
index 79ef4029d6..9f0d21b8b8 100644
--- a/board/taeko/board.c
+++ b/board/taeko/board.c
@@ -136,16 +136,3 @@ enum battery_present battery_hw_present(void)
/* The GPIO is low when the battery is physically present */
return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES;
}
-
-__override void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- /*
- * Follow OEM request to limit the input current to
- * 95% negotiated limit.
- */
- charge_ma = charge_ma * 95 / 100;
-
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/taeko/board.h b/board/taeko/board.h
index c3193c8847..a3ae9abb00 100644
--- a/board/taeko/board.h
+++ b/board/taeko/board.h
@@ -26,6 +26,9 @@
#define CONFIG_MP2964
+/* OEM requested 5% charger current margin */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
+
/* LED */
#define CONFIG_LED_ONOFF_STATES
diff --git a/board/taeko/charger.c b/board/taeko/charger.c
index a4fa209246..7fabd2082e 100644
--- a/board/taeko/charger.c
+++ b/board/taeko/charger.c
@@ -81,10 +81,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/taniks/board.c b/board/taniks/board.c
index 5da998524b..f8501d761b 100644
--- a/board/taniks/board.c
+++ b/board/taniks/board.c
@@ -115,16 +115,3 @@ enum battery_present battery_hw_present(void)
/* The GPIO is low when the battery is physically present */
return gpio_get_level(GPIO_EC_BATT_PRES_ODL) ? BP_NO : BP_YES;
}
-
-__override void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- /*
- * Follow OEM request to limit the input current to
- * 95% negotiated limit.
- */
- charge_ma = charge_ma * 95 / 100;
-
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/taniks/board.h b/board/taniks/board.h
index 6cd42ad7bb..a301f3b458 100644
--- a/board/taniks/board.h
+++ b/board/taniks/board.h
@@ -36,6 +36,9 @@
*/
#define CONFIG_HIBERNATE_PSL_VCC1_RST_WAKEUP
+/* OEM requested 5% charger margin */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
+
/* LED */
#define CONFIG_LED_ONOFF_STATES
diff --git a/board/taniks/charger.c b/board/taniks/charger.c
index a4fa209246..7fabd2082e 100644
--- a/board/taniks/charger.c
+++ b/board/taniks/charger.c
@@ -81,10 +81,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/terrador/board.c b/board/terrador/board.c
index 8426216e79..3724c9d2d0 100644
--- a/board/terrador/board.c
+++ b/board/terrador/board.c
@@ -301,6 +301,7 @@ void ppc_interrupt(enum gpio_signal signal)
break;
case GPIO_USB_C1_PPC_INT_ODL:
syv682x_interrupt(USBC_PORT_C1);
+ break;
default:
break;
}
diff --git a/board/tglrvp_ish/board.h b/board/tglrvp_ish/board.h
index 3912e8803a..e285014e5e 100644
--- a/board/tglrvp_ish/board.h
+++ b/board/tglrvp_ish/board.h
@@ -79,8 +79,11 @@
#define CONFIG_ISH_IPAPG
#define CONFIG_ISH_D0I2_MIN_USEC (15 * MSEC)
+#ifdef BOARD_ADL_ISH_LITE
+#define CONFIG_ISH_D0I3_MIN_USEC (3000 * MSEC)
+#else
#define CONFIG_ISH_D0I3_MIN_USEC (50 * MSEC)
-
+#endif
#define CONFIG_ISH_NEW_PM
#ifndef __ASSEMBLER__
diff --git a/board/tigertail/board.h b/board/tigertail/board.h
index ea4d11db06..26e6af5985 100644
--- a/board/tigertail/board.h
+++ b/board/tigertail/board.h
@@ -24,7 +24,6 @@
#undef CONFIG_UART_RX_DMA
/* Optional features */
-#define CONFIG_STM_HWTIMER32
#define CONFIG_HW_CRC
/* USB Configuration */
diff --git a/board/trogdor/usbc_config.c b/board/trogdor/usbc_config.c
index 39a54f659e..b9c37a04fd 100644
--- a/board/trogdor/usbc_config.c
+++ b/board/trogdor/usbc_config.c
@@ -225,6 +225,7 @@ void board_tcpc_init(void)
/* Enable PPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -333,8 +334,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -346,8 +347,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/twinkie/board.h b/board/twinkie/board.h
index b1379fb15b..808053d146 100644
--- a/board/twinkie/board.h
+++ b/board/twinkie/board.h
@@ -79,8 +79,7 @@ void trace_packets(void);
void set_trace_mode(int mode);
/* Timer selection */
-#define TIM_CLOCK_MSB 3
-#define TIM_CLOCK_LSB 15
+#define TIM_CLOCK32 2
#define TIM_ADC 16
#include "gpio_signal.h"
diff --git a/board/vell/board.h b/board/vell/board.h
index 4b3d527901..3a7d97858c 100644
--- a/board/vell/board.h
+++ b/board/vell/board.h
@@ -61,6 +61,8 @@
#undef CONFIG_SYV682X_HV_ILIM
#define CONFIG_SYV682X_HV_ILIM SYV682X_HV_ILIM_5_50
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
+
/* TODO: b/177608416 - measure and check these values on brya */
#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
#define PD_POWER_SUPPLY_TURN_OFF_DELAY 30000 /* us */
diff --git a/board/vell/charger.c b/board/vell/charger.c
index e33a0ed44a..53b14381cd 100644
--- a/board/vell/charger.c
+++ b/board/vell/charger.c
@@ -81,18 +81,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- /*
- * Limit the input current to 96% negotiated limit,
- * to account for the charger chip margin.
- */
- charge_ma = charge_ma * 96 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
static void set_ac_prochot(void)
{
isl9241_set_ac_prochot(CHARGER_SOLO, PD_MAX_CURRENT_MA);
diff --git a/board/vilboz/board.c b/board/vilboz/board.c
index 7c74794d9d..1ba266f145 100644
--- a/board/vilboz/board.c
+++ b/board/vilboz/board.c
@@ -504,16 +504,3 @@ const int usb_port_enable[USBA_PORT_COUNT] = {
IOEX_EN_USB_A0_5V,
GPIO_EN_USB_A1_5V,
};
-
-__override void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- /*
- * Limit the input current to 95% negotiated limit,
- * to account for the charger chip margin.
- */
- charge_ma = charge_ma * 95 / 100;
-
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/vilboz/board.h b/board/vilboz/board.h
index 5160abbc26..8a7c86824d 100644
--- a/board/vilboz/board.h
+++ b/board/vilboz/board.h
@@ -20,6 +20,7 @@
#define GPIO_USB2_ILIM_SEL GPIO_USB_A1_CHARGE_EN_DB_L
#define CONFIG_CHARGER_PROFILE_OVERRIDE
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
/* Motion sensing drivers */
#define CONFIG_ACCELGYRO_LSM6DSM
diff --git a/board/volmar/charger.c b/board/volmar/charger.c
index 88f5b85a41..7a16fcd5cb 100644
--- a/board/volmar/charger.c
+++ b/board/volmar/charger.c
@@ -79,10 +79,3 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/board/waddledee/board.c b/board/waddledee/board.c
index d7abda740c..4dfb3048ca 100644
--- a/board/waddledee/board.c
+++ b/board/waddledee/board.c
@@ -342,18 +342,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * TODO(b/151955431): Characterize the input current limit in case a
- * scaling needs to be applied here
- */
- charge_set_input_current_limit(icl, charge_mv);
-}
-
int board_set_active_charge_port(int port)
{
int is_valid_port = (port >= 0 && port < board_get_usb_pd_port_count());
diff --git a/board/waddledoo/board.c b/board/waddledoo/board.c
index e207e59456..3cdb71cc5e 100644
--- a/board/waddledoo/board.c
+++ b/board/waddledoo/board.c
@@ -390,19 +390,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/waddledoo/board.h b/board/waddledoo/board.h
index 727f1bdb33..23a89c84d6 100644
--- a/board/waddledoo/board.h
+++ b/board/waddledoo/board.h
@@ -18,10 +18,12 @@
#define CONFIG_SYSTEM_UNLOCKED
/* Save some flash space */
+#undef CONFIG_ACCEL_SPOOF_MODE
#define CONFIG_CHIP_INIT_ROM_REGION
#undef CONFIG_CONSOLE_CMDHELP
+#undef CONFIG_CONSOLE_HISTORY
#define CONFIG_DEBUG_ASSERT_BRIEF
-#define CONFIG_USB_PD_DEBUG_LEVEL 2
+#define CONFIG_USB_PD_DEBUG_LEVEL 0
/* EC console commands */
#define CONFIG_CMD_CHARGER_DUMP
@@ -41,6 +43,11 @@
#define CONFIG_OCPC_DEF_RBATT_MOHMS \
22 /* R_DS(on) 11.6mOhm + 10mOhm sns rstr \
*/
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
#define CONFIG_OCPC
#undef CONFIG_CHARGER_SINGLE_CHIP
#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
diff --git a/board/waddledoo2/board.c b/board/waddledoo2/board.c
index fd12aec449..98c061d9af 100644
--- a/board/waddledoo2/board.c
+++ b/board/waddledoo2/board.c
@@ -397,19 +397,6 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * b/147463641: The charger IC seems to overdraw ~4%, therefore we
- * reduce our target accordingly.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
{
if (port < 0 || port > board_get_usb_pd_port_count())
diff --git a/board/waddledoo2/board.h b/board/waddledoo2/board.h
index 93f0a0f108..3b4587037d 100644
--- a/board/waddledoo2/board.h
+++ b/board/waddledoo2/board.h
@@ -28,6 +28,11 @@
#define CONFIG_OCPC_DEF_RBATT_MOHMS \
22 /* R_DS(on) 11.6mOhm + 10mOhm sns rstr \
*/
+/*
+ * b/147463641: The charger IC seems to overdraw ~4%, therefore we
+ * reduce our target accordingly.
+ */
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 4
#define CONFIG_OCPC
#undef CONFIG_CHARGER_SINGLE_CHIP
#undef CONFIG_CMD_CHARGER_DUMP
diff --git a/board/wheelie/board.c b/board/wheelie/board.c
index 9708dcca82..e8852a0b5a 100644
--- a/board/wheelie/board.c
+++ b/board/wheelie/board.c
@@ -229,18 +229,6 @@ uint16_t tcpc_get_alert_status(void)
return status;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * TODO(b/151955431): Characterize the input current limit in case a
- * scaling needs to be applied here
- */
- charge_set_input_current_limit(icl, charge_mv);
-}
-
int board_set_active_charge_port(int port)
{
int is_valid_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
diff --git a/board/willow/board.c b/board/willow/board.c
index 826df6940c..1fdcc37492 100644
--- a/board/willow/board.c
+++ b/board/willow/board.c
@@ -234,14 +234,6 @@ int board_set_active_charge_port(int charge_port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * 95) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
int board_discharge_on_ac(int enable)
{
int ret, port;
diff --git a/board/willow/board.h b/board/willow/board.h
index 18745a07a4..315c206a07 100644
--- a/board/willow/board.h
+++ b/board/willow/board.h
@@ -27,6 +27,7 @@
#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
#define CONFIG_CHARGER_PSYS
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
#define CONFIG_CHARGER_RUNTIME_CONFIG
diff --git a/board/woomax/board.c b/board/woomax/board.c
index 747c576fc2..7e9fbd224f 100644
--- a/board/woomax/board.c
+++ b/board/woomax/board.c
@@ -451,7 +451,7 @@ static int woomax_ps8802_mux_set(const struct usb_mux *me,
const struct usb_mux usbc1_woomax_ps8818 = {
.usb_port = USBC_PORT_C1,
.i2c_port = I2C_PORT_TCPC1,
- .i2c_addr_flags = PS8818_I2C_ADDR_FLAGS,
+ .i2c_addr_flags = PS8818_I2C_ADDR0_FLAGS,
.driver = &ps8818_usb_retimer_driver,
.board_set = &woomax_ps8818_mux_set,
};
diff --git a/board/wormdingler/board.c b/board/wormdingler/board.c
index 3c4dfe4b3c..e9e929de53 100644
--- a/board/wormdingler/board.c
+++ b/board/wormdingler/board.c
@@ -458,6 +458,7 @@ void board_tcpc_init(void)
/* Enable PPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL);
+ gpio_enable_interrupt(GPIO_USB_C1_SWCTL_INT_ODL);
/* Enable TCPC interrupts */
gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
@@ -629,8 +630,8 @@ int board_set_active_charge_port(int port)
return EC_SUCCESS;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
/*
* Ignore lower charge ceiling on PD transition if our battery is
@@ -642,9 +643,7 @@ void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
charge_ma = max_ma;
}
- charge_ma = charge_ma * 95 / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
+ charge_set_input_current_limit(charge_ma, charge_mv);
}
uint16_t tcpc_get_alert_status(void)
diff --git a/board/wormdingler/board.h b/board/wormdingler/board.h
index 3c3ba6ead5..447846c509 100644
--- a/board/wormdingler/board.h
+++ b/board/wormdingler/board.h
@@ -24,6 +24,8 @@
#define CONFIG_BATTERY_FUEL_GAUGE
#define CONFIG_BATTERY_VENDOR_PARAM
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT 5
+
/* Enable PD3.0 */
#define CONFIG_USB_PD_REV30
diff --git a/builtin/assert.h b/builtin/assert.h
index 2e943f7615..71a275bf23 100644
--- a/builtin/assert.h
+++ b/builtin/assert.h
@@ -21,7 +21,12 @@ extern "C" {
#ifdef CONFIG_DEBUG_ASSERT_REBOOTS
#ifdef CONFIG_DEBUG_ASSERT_BRIEF
-noreturn void panic_assert_fail(const char *fname, int linenum);
+#if defined(__cplusplus) && !defined(__clang__)
+[[noreturn]]
+#else
+noreturn
+#endif
+void panic_assert_fail(const char *fname, int linenum);
#define ASSERT(cond) \
do { \
if (!(cond)) \
@@ -30,7 +35,12 @@ noreturn void panic_assert_fail(const char *fname, int linenum);
#else /* !CONFIG_DEBUG_ASSERT_BRIEF */
-noreturn void panic_assert_fail(const char *msg, const char *func,
+#if defined(__cplusplus) && !defined(__clang__)
+[[noreturn]]
+#else
+noreturn
+#endif
+void panic_assert_fail(const char *msg, const char *func,
const char *fname, int linenum);
#define ASSERT(cond) \
do { \
diff --git a/builtin/inttypes.h b/builtin/inttypes.h
index 1ef305548b..eed80407ce 100644
--- a/builtin/inttypes.h
+++ b/builtin/inttypes.h
@@ -6,6 +6,8 @@
#ifndef __CROS_EC_INTTYPES_H__
#define __CROS_EC_INTTYPES_H__
+#include <stdint.h>
+
#define PRIx64 "llx"
#define PRId64 "lld"
diff --git a/builtin/math.h b/builtin/math.h
index c015d9d18d..aa07a0286d 100644
--- a/builtin/math.h
+++ b/builtin/math.h
@@ -6,9 +6,10 @@
#ifndef __CROS_EC_MATH_H__
#define __CROS_EC_MATH_H__
-#include <stdbool.h>
#include "fpu.h"
+#include <stdbool.h>
+
static inline bool isnan(float a)
{
return __builtin_isnan(a);
diff --git a/builtin/stdio.h b/builtin/stdio.h
index 7536499feb..bd75c01f53 100644
--- a/builtin/stdio.h
+++ b/builtin/stdio.h
@@ -6,11 +6,11 @@
#ifndef __CROS_EC_STDIO_H__
#define __CROS_EC_STDIO_H__
-#include <stddef.h>
-#include <stdarg.h>
-
#include "common.h"
+#include <stdarg.h>
+#include <stddef.h>
+
/**
* Print formatted outut to a string.
*
diff --git a/chip/host/flash.c b/chip/host/flash.c
index 209489162c..03a5fc777b 100644
--- a/chip/host/flash.c
+++ b/chip/host/flash.c
@@ -5,8 +5,6 @@
/* Flash module for emulator */
-#include <stdio.h>
-
#include "builtin/assert.h"
#include "common.h"
#include "config_chip.h"
@@ -14,6 +12,8 @@
#include "persistence.h"
#include "util.h"
+#include <stdio.h>
+
/* This needs to be aligned to the erase bank size for NVCTR. */
__aligned(CONFIG_FLASH_ERASE_SIZE) char __host_flash[CONFIG_FLASH_SIZE_BYTES];
uint8_t __host_flash_protect[PHYSICAL_BANKS];
diff --git a/chip/host/gpio.c b/chip/host/gpio.c
index b74bec52a1..d80d93dcf7 100644
--- a/chip/host/gpio.c
+++ b/chip/host/gpio.c
@@ -5,8 +5,6 @@
/* GPIO module for emulator */
-#include "console.h"
-
#include "common.h"
#include "console.h"
#include "gpio.h"
diff --git a/chip/host/persistence.c b/chip/host/persistence.c
index 4d8ef09df1..369f58034b 100644
--- a/chip/host/persistence.c
+++ b/chip/host/persistence.c
@@ -18,13 +18,14 @@
* this homegrown implementation of something similar-yet-different.
*/
-#include <linux/limits.h>
-#include <unistd.h>
+#include "builtin/assert.h"
+#include "util.h"
+
#include <stdio.h>
#include <string.h>
-#include "builtin/assert.h"
-#include "util.h"
+#include <linux/limits.h>
+#include <unistd.h>
/* The longest path in a chroot seems to be about 280 characters (as of
* April 2021) so define a cut-off instead of just hoping for the best:
diff --git a/chip/host/reboot.c b/chip/host/reboot.c
index 24d90d943d..59e15ee81d 100644
--- a/chip/host/reboot.c
+++ b/chip/host/reboot.c
@@ -5,14 +5,15 @@
/* Emulator self-reboot procedure */
-#include <string.h>
-#include <unistd.h>
-
#include "console.h"
#include "host_test.h"
#include "reboot.h"
#include "test_util.h"
+#include <string.h>
+
+#include <unistd.h>
+
#ifdef TEST_FUZZ
/* reboot breaks fuzzing, let's just not do it. */
void emulator_reboot(void)
diff --git a/chip/host/spi_controller.c b/chip/host/spi_controller.c
index a1df53d935..ae6e2c9346 100644
--- a/chip/host/spi_controller.c
+++ b/chip/host/spi_controller.c
@@ -5,13 +5,12 @@
* Mock SPI Controller driver for unit test.
*/
-#include <stdint.h>
-
#include "common.h"
#include "gpio.h"
-
#include "spi.h"
+#include <stdint.h>
+
test_mockable int spi_enable(const struct spi_device_t *spi_device, int enable)
{
return EC_SUCCESS;
diff --git a/chip/host/trng.c b/chip/host/trng.c
index ef3df1ad5f..d0def66277 100644
--- a/chip/host/trng.c
+++ b/chip/host/trng.c
@@ -14,11 +14,11 @@
#error "This fake trng driver must not be used in non-test builds."
#endif
+#include "common.h"
+
#include <stdint.h>
#include <stdlib.h> /* Only valid for host */
-#include "common.h"
-
static unsigned int seed;
test_mockable void trng_init(void)
diff --git a/chip/host/uart.c b/chip/host/uart.c
index 9e70a6005c..71e8345196 100644
--- a/chip/host/uart.c
+++ b/chip/host/uart.c
@@ -5,12 +5,6 @@
/* UART driver for emulator */
-#include <pthread.h>
-#include <signal.h>
-#include <stdio.h>
-#include <termio.h>
-#include <unistd.h>
-
#include "builtin/assert.h"
#include "common.h"
#include "queue.h"
@@ -19,6 +13,13 @@
#include "uart.h"
#include "util.h"
+#include <signal.h>
+#include <stdio.h>
+
+#include <pthread.h>
+#include <termio.h>
+#include <unistd.h>
+
static int stopped = 1;
static int init_done;
diff --git a/chip/ish/aontaskfw/ish_aontask.c b/chip/ish/aontaskfw/ish_aontask.c
index d167f3f5df..6f2d9c9f2d 100644
--- a/chip/ish/aontaskfw/ish_aontask.c
+++ b/chip/ish/aontaskfw/ish_aontask.c
@@ -45,8 +45,8 @@
#include "common.h"
#include "ia_structs.h"
-#include "ish_aon_share.h"
#include "ish_aon_defs.h"
+#include "ish_aon_share.h"
#include "ish_dma.h"
#include "power_mgt.h"
@@ -91,6 +91,56 @@
static void handle_reset(enum ish_pm_state pm_state);
+#if defined(CHIP_VARIANT_ISH5P4)
+static void sb_upstream_write_raw_base(uint32_t addr, uint32_t attr,
+ uint32_t data, uint32_t sairs,
+ uint8_t addr48, uint16_t addr_hi)
+{
+ uint32_t eflags;
+ uint32_t addr_hi_32;
+
+ addr_hi_32 = addr_hi | (1 << 31);
+
+ eflags = interrupt_lock();
+
+ PMU_VNN_REQ = (1 << VNN_ID_SIDEBAND);
+ while (!(PMU_VNN_REQ_ACK & PMU_VNN_REQ_ACK_STATUS))
+ continue;
+
+ if (dma_poll(SBEP_REG_UP_MSG_STATUS_ADDR, 0, UP_STATUS_BUSY_MASK) ==
+ DMA_RC_OK) {
+ SBEP_REG_UP_MSG_REQ_ADDR_LOW = addr;
+
+ if (addr48) {
+ SBEP_REG_UP_MSG_REQ_ADDR_HIGH = addr_hi_32;
+ } else {
+ SBEP_REG_UP_MSG_REQ_ADDR_HIGH = 0;
+ }
+
+ SBEP_REG_UP_MSG_REQ_ATTR = attr;
+ SBEP_REG_UP_MSG_REQ_DATA = data;
+ SBEP_REG_UP_MSG_REQ_EH = sairs;
+ SBEP_REG_UP_MSG_COMMAND = SBEP_CMD_WRITE;
+
+ dma_poll(SBEP_REG_UP_MSG_STATUS_ADDR, 0, UP_STATUS_BUSY_MASK);
+ dma_poll(SBEP_REG_UP_MSG_STATUS_ADDR, UP_STATUS_MSG_SENT_MASK,
+ UP_STATUS_MSG_SENT_MASK);
+ SBEP_REG_UP_MSG_STATUS = UP_STATUS_MSG_SENT_CLR;
+ }
+
+ PMU_VNN_REQ = (1 << VNN_ID_SIDEBAND);
+ interrupt_unlock(eflags);
+}
+
+static void sb_upstream_write_raw(uint32_t addr, uint32_t attr, uint32_t data,
+ uint32_t sairs)
+{
+ addr = addr & 0x0000FFFF;
+
+ sb_upstream_write_raw_base(addr, attr, data, sairs, 0, 0);
+}
+#endif
+
/* ISR for PMU wakeup interrupt */
static void pmu_wakeup_isr(void)
{
@@ -670,6 +720,13 @@ static void handle_d0i3(void)
aon_share.pg_exit = 0;
}
+#if defined(CHIP_VARIANT_ISH5P4)
+ /* Set PMC LTR to 2ms before DMA copy */
+ if (IS_ENABLED(CONFIG_ISH_NEW_PM))
+ sb_upstream_write_raw(0, LTR_CMD_ATTR, LTR_CMD_DATA_2MS,
+ SBEP_PMC_SAIRS_VAL);
+#endif
+
/* store main FW 's context to IMR DDR from main SRAM */
ret = store_main_fw();
@@ -680,6 +737,13 @@ static void handle_d0i3(void)
/* power off main SRAM */
sram_power(0);
+#if defined(CHIP_VARIANT_ISH5P4)
+ /* Set LTR to a large number after DMA copy done */
+ if (IS_ENABLED(CONFIG_ISH_NEW_PM))
+ sb_upstream_write_raw(0, LTR_CMD_ATTR, LTR_CMD_DATA_INFINITE,
+ SBEP_PMC_SAIRS_VAL);
+#endif
+
set_vnnred_aoncg();
if (IS_ENABLED(CONFIG_ISH_IPAPG) && is_ipapg_allowed()) {
@@ -712,6 +776,13 @@ static void handle_d0i3(void)
aon_share.uma_msb);
}
+#if defined(CHIP_VARIANT_ISH5P4)
+ /* Set PMC LTR to 2ms before DMA copy */
+ if (IS_ENABLED(CONFIG_ISH_NEW_PM))
+ sb_upstream_write_raw(0, LTR_CMD_ATTR, LTR_CMD_DATA_2MS,
+ SBEP_PMC_SAIRS_VAL);
+#endif
+
/* restore main FW 's context to main SRAM from IMR DDR */
ret = restore_main_fw();
diff --git a/chip/ish/clock.c b/chip/ish/clock.c
index e46c4278b7..f9fec0b7d2 100644
--- a/chip/ish/clock.c
+++ b/chip/ish/clock.c
@@ -7,8 +7,8 @@
#include "clock.h"
#include "common.h"
-#include "util.h"
#include "power_mgt.h"
+#include "util.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CLOCK, outstr)
diff --git a/chip/ish/dma.c b/chip/ish/dma.c
index 48a27a0463..eae6a850f1 100644
--- a/chip/ish/dma.c
+++ b/chip/ish/dma.c
@@ -7,34 +7,12 @@
#include "common.h"
#include "console.h"
-#include "registers.h"
#include "ish_dma.h"
+#include "registers.h"
#include "util.h"
static int dma_init_called; /* If ish_dma_init is called */
-static int dma_poll(uint32_t addr, uint32_t expected, uint32_t mask)
-{
- int retval = -1;
- uint32_t counter = 0;
-
- /*
- * The timeout is approximately 2.2 seconds according to
- * value of UINT32_MAX, 120MHZ ISH clock frequency and
- * instruction count which is around 4.
- */
- while (counter < (UINT32_MAX / 64)) {
- /* test condition */
- if ((REG32(addr) & mask) == expected) {
- retval = DMA_RC_OK;
- break;
- }
- counter++;
- }
-
- return retval;
-}
-
void ish_dma_ocp_timeout_disable(void)
{
if (!IS_ENABLED(CONFIG_ISH_NEW_PM)) {
@@ -44,24 +22,6 @@ void ish_dma_ocp_timeout_disable(void)
}
}
-static inline uint32_t interrupt_lock(void)
-{
- uint32_t eflags = 0;
- __asm__ volatile("pushfl;" /* save eflag value */
- "popl %0;"
- "cli;"
- : "=r"(eflags)); /* shut off interrupts */
- return eflags;
-}
-
-static inline void interrupt_unlock(uint32_t eflags)
-{
- __asm__ volatile("pushl %0;" /* restore elfag values */
- "popfl;"
- :
- : "r"(eflags));
-}
-
void dma_configure_psize(void)
{
/* Give chan0 512 bytes for high performance, and chan1 128 bytes. */
diff --git a/chip/ish/hbm.h b/chip/ish/hbm.h
index d666f748c8..17c7853b1d 100644
--- a/chip/ish/hbm.h
+++ b/chip/ish/hbm.h
@@ -6,11 +6,11 @@
#ifndef __HBM_H
#define __HBM_H
-#include <stdint.h>
-#include <stddef.h>
-
#include "heci_client.h"
+#include <stddef.h>
+#include <stdint.h>
+
#define HBM_MAJOR_VERSION 1
#ifdef HECI_ENABLE_DMA
#define HBM_MINOR_VERSION 2
diff --git a/chip/ish/heci_client.h b/chip/ish/heci_client.h
index 951b82c6d9..2ba9ea01db 100644
--- a/chip/ish/heci_client.h
+++ b/chip/ish/heci_client.h
@@ -6,11 +6,11 @@
#ifndef __HECI_CLIENT_H
#define __HECI_CLIENT_H
-#include <stdint.h>
-#include <stddef.h>
-
#include "hooks.h"
+#include <stddef.h>
+#include <stdint.h>
+
#define HECI_MAX_NUM_OF_CLIENTS 2
#define HECI_MAX_MSG_SIZE 4960
diff --git a/chip/ish/hid_device.h b/chip/ish/hid_device.h
index ba7722f5bb..07d8a77673 100644
--- a/chip/ish/hid_device.h
+++ b/chip/ish/hid_device.h
@@ -6,11 +6,11 @@
#ifndef __HID_DEVICE_H
#define __HID_DEVICE_H
-#include <stdint.h>
-#include <stddef.h>
-
#include "hooks.h"
+#include <stddef.h>
+#include <stdint.h>
+
#define HID_SUBSYS_MAX_PAYLOAD_SIZE 4954
enum HID_SUBSYS_ERR {
diff --git a/chip/ish/hwtimer.c b/chip/ish/hwtimer.c
index 57049a63b3..40c3de67a8 100644
--- a/chip/ish/hwtimer.c
+++ b/chip/ish/hwtimer.c
@@ -8,9 +8,9 @@
#include "console.h"
#include "hpet.h"
#include "hwtimer.h"
-#include "timer.h"
#include "registers.h"
#include "task.h"
+#include "timer.h"
#include "util.h"
#define CPUTS(outstr) cputs(CC_CLOCK, outstr)
diff --git a/chip/ish/i2c.c b/chip/ish/i2c.c
index e26bcd70e5..230f073369 100644
--- a/chip/ish/i2c.c
+++ b/chip/ish/i2c.c
@@ -6,16 +6,16 @@
/* I2C port module for ISH */
#include "common.h"
-#include "console.h"
#include "config_chip.h"
+#include "console.h"
#include "gpio.h"
#include "hooks.h"
+#include "hwtimer.h"
#include "i2c.h"
-#include "registers.h"
#include "ish_i2c.h"
+#include "registers.h"
#include "task.h"
#include "timer.h"
-#include "hwtimer.h"
#include "util.h"
#define CPUTS(outstr) cputs(CC_I2C, outstr)
diff --git a/chip/ish/ipc_heci.c b/chip/ish/ipc_heci.c
index 1fd81e3d3f..8ce0a258e1 100644
--- a/chip/ish/ipc_heci.c
+++ b/chip/ish/ipc_heci.c
@@ -24,15 +24,15 @@
*/
#include "builtin/assert.h"
-#include "registers.h"
#include "console.h"
-#include "task.h"
-#include "util.h"
+#include "hooks.h"
+#include "hwtimer.h"
#include "ipc_heci.h"
#include "ish_fwst.h"
#include "queue.h"
-#include "hooks.h"
-#include "hwtimer.h"
+#include "registers.h"
+#include "task.h"
+#include "util.h"
#define CPUTS(outstr) cputs(CC_LPC, outstr)
#define CPRINTS(format, args...) cprints(CC_LPC, format, ##args)
diff --git a/chip/ish/ipc_heci.h b/chip/ish/ipc_heci.h
index f9372aefa3..96b08f9c4a 100644
--- a/chip/ish/ipc_heci.h
+++ b/chip/ish/ipc_heci.h
@@ -7,6 +7,8 @@
#ifndef __IPC_HECI_H
#define __IPC_HECI_H
+#include <stddef.h>
+
enum IPC_ERR {
IPC_ERR_IPC_IS_NOT_READY = EC_ERROR_INTERNAL_FIRST + 0,
IPC_ERR_TOO_SMALL_BUFFER = EC_ERROR_INTERNAL_FIRST + 1,
diff --git a/chip/ish/ish_dma.h b/chip/ish/ish_dma.h
index fb9c4f4f06..89d6cb7342 100644
--- a/chip/ish/ish_dma.h
+++ b/chip/ish/ish_dma.h
@@ -27,6 +27,47 @@
#define PAGE_SIZE 4096
+static inline uint32_t interrupt_lock(void)
+{
+ uint32_t eflags = 0;
+
+ __asm__ volatile("pushfl;" /* save eflag value */
+ "popl %0;"
+ "cli;"
+ : "=r"(eflags)); /* shut off interrupts */
+ return eflags;
+}
+
+static inline void interrupt_unlock(uint32_t eflags)
+{
+ __asm__ volatile("pushl %0;" /* restore elfag values */
+ "popfl;"
+ :
+ : "r"(eflags));
+}
+
+static inline int dma_poll(uint32_t addr, uint32_t expected, uint32_t mask)
+{
+ int retval = -1;
+ uint32_t counter = 0;
+
+ /*
+ * The timeout is approximately 2.2 seconds according to
+ * value of UINT32_MAX, 120MHZ ISH clock frequency and
+ * instruction count which is around 4.
+ */
+ while (counter < (UINT32_MAX / 64)) {
+ /* test condition */
+ if ((REG32(addr) & mask) == expected) {
+ retval = DMA_RC_OK;
+ break;
+ }
+ counter++;
+ }
+
+ return retval;
+}
+
/**
* SRAM: ISH local static ram
* UMA: Protected system DRAM region dedicated for ISH
diff --git a/chip/ish/ish_i2c.h b/chip/ish/ish_i2c.h
index c24f4e0cdc..7aa2977178 100644
--- a/chip/ish/ish_i2c.h
+++ b/chip/ish/ish_i2c.h
@@ -6,9 +6,10 @@
#ifndef __CROS_EC_ISH_I2C_H
#define __CROS_EC_ISH_I2C_H
-#include <stdint.h>
#include "task.h"
+#include <stdint.h>
+
#define I2C_TSC_TIMEOUT 2000000
#define I2C_CALIB_ADDRESS 0x3
#define I2C_INTERRUPT_TIMEOUT (TICKFREQ / 20)
diff --git a/chip/ish/ish_persistent_data.c b/chip/ish/ish_persistent_data.c
index 149acaeade..ed909d6f7b 100644
--- a/chip/ish/ish_persistent_data.c
+++ b/chip/ish/ish_persistent_data.c
@@ -4,11 +4,11 @@
*/
#include "common.h"
-#include "ec_commands.h"
#include "config.h"
+#include "ec_commands.h"
#include "hooks.h"
-#include "system.h"
#include "ish_persistent_data.h"
+#include "system.h"
#define PERSISTENT_DATA_MAGIC 0x49534864 /* "ISHd" */
diff --git a/chip/ish/power_mgt.c b/chip/ish/power_mgt.c
index 83ef0fc91b..de9022b55a 100644
--- a/chip/ish/power_mgt.c
+++ b/chip/ish/power_mgt.c
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdnoreturn.h>
-
#include "aontaskfw/ish_aon_share.h"
#include "console.h"
#include "hwtimer.h"
@@ -17,6 +15,8 @@
#include "util.h"
#include "watchdog.h"
+#include <stdnoreturn.h>
+
#define CPUTS(outstr) cputs(CC_SYSTEM, outstr)
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
@@ -612,8 +612,18 @@ void ish_pm_init(void)
/* clear reset history register in CCU */
CCU_RST_HST = CCU_RST_HST;
+#if defined(CHIP_VARIANT_ISH5P4)
+ if (IS_ENABLED(CONFIG_ISH_NEW_PM))
+ PMU_D3_STATUS_1 = 0xffffffff;
+#endif
+
/* disable TCG and disable BCG */
- CCU_TCG_EN = 0;
+ CCU_TCG_ENABLE = 0;
+ CCU_BCG_ENABLE = 0;
+
+ /* Disable power gate of CACHE and ROM */
+ PMU_RF_ROM_PWR_CTRL = 0;
+
reset_bcg();
if (IS_ENABLED(CONFIG_ISH_PM_AONTASK))
@@ -624,8 +634,15 @@ void ish_pm_init(void)
PMU_GPIO_WAKE_MASK1 = 0;
}
- /* unmask all wake up events */
+ /* Unmask all wake up events in event1 */
PMU_MASK_EVENT = ~PMU_MASK_EVENT_BIT_ALL;
+ /* Mask events in event2 */
+ PMU_MASK_EVENT2 = PMU_MASK2_ALL_EVENTS;
+
+#if defined(CHIP_VARIANT_ISH5P4)
+ SBEP_REG_CLK_GATE_ENABLE =
+ (SB_CLK_GATE_EN_LOCAL_CLK_GATE | SB_CLK_GATE_EN_TRUNK_CLK_GATE);
+#endif
if (IS_ENABLED(CONFIG_ISH_NEW_PM)) {
PMU_ISH_FABRIC_CNT = (PMU_ISH_FABRIC_CNT & 0xffff0000) |
@@ -648,6 +665,15 @@ void ish_pm_init(void)
(PMU_D3_STATUS & PMU_BME_BIT_SET))
PMU_D3_STATUS = PMU_D3_STATUS;
+#if defined(CHIP_VARIANT_ISH5P4)
+ if (IS_ENABLED(CONFIG_ISH_NEW_PM)) {
+ /* Mask all function1 */
+ PMU_REG_MASK_D3_RISE = 0x2;
+ PMU_REG_MASK_D3_FALL = 0x2;
+ PMU_REG_MASK_BME_RISE = 0x2;
+ PMU_REG_MASK_BME_FALL = 0x2;
+ }
+#endif
enable_d3bme_irqs();
}
}
diff --git a/chip/ish/power_mgt.h b/chip/ish/power_mgt.h
index 851529ffb1..a7a702018f 100644
--- a/chip/ish/power_mgt.h
+++ b/chip/ish/power_mgt.h
@@ -6,11 +6,11 @@
#ifndef __CROS_EC_POWER_MGT_H
#define __CROS_EC_POWER_MGT_H
-#include <stdnoreturn.h>
-
#include "common.h"
#include "registers.h"
+#include <stdnoreturn.h>
+
extern void uart_port_restore(void);
extern void uart_to_idle(void);
extern void clear_fabric_error(void);
diff --git a/chip/ish/registers.h b/chip/ish/registers.h
index bdd04a7cb2..7fe5d2c5ab 100644
--- a/chip/ish/registers.h
+++ b/chip/ish/registers.h
@@ -48,6 +48,7 @@ enum ish_i2c_port {
#define ISH_IOAPIC_BASE 0xFEC00000
#define ISH_HPET_BASE 0x04700000
#define ISH_LAPIC_BASE 0xFEE00000
+#define ISH_SBEP_BASE 0x04500000
#else
#define ISH_I2C0_BASE 0x00100000
#define ISH_I2C1_BASE 0x00102000
@@ -128,6 +129,66 @@ enum ish_i2c_port {
#define ISH_GPIO_GWSR REG32(ISH_GPIO_BASE + 0x118) /* Wake Source */
#define ISH_GPIO_GSEC REG32(ISH_GPIO_BASE + 0x130) /* Secure Input */
+#if defined(CHIP_VARIANT_ISH5P4)
+/* Side Band End Point registers */
+#define SBEP_REG_CLK_GATE_ENABLE REG32(ISH_SBEP_BASE + 0x006C)
+#define SB_CLK_GATE_EN_LOCAL_CLK_GATE BIT(0)
+#define SB_CLK_GATE_EN_TRUNK_CLK_GATE BIT(1)
+#endif
+
+#define SBEP_REG_UP_MSG_STATUS_ADDR (ISH_SBEP_BASE + 0x0040)
+#define SBEP_REG_UP_MSG_STATUS REG32(ISH_SBEP_BASE + 0x0040)
+#define SBEP_REG_UP_MSG_COMMAND REG32(ISH_SBEP_BASE + 0x0044)
+#define SBEP_REG_UP_MSG_REQ_ADDR_LOW REG32(ISH_SBEP_BASE + 0x0048)
+#define SBEP_REG_UP_MSG_REQ_ADDR_HIGH REG32(ISH_SBEP_BASE + 0x004C)
+#define SBEP_REG_UP_MSG_REQ_DATA REG32(ISH_SBEP_BASE + 0x0050)
+#define SBEP_REG_UP_MSG_REQ_ATTR REG32(ISH_SBEP_BASE + 0x0054)
+#define SBEP_REG_UP_MSG_REQ_EH REG32(ISH_SBEP_BASE + 0x0058)
+
+#define UP_STATUS_BUSY_MASK 0x01
+#define UP_STATUS_MSG_SENT_MASK 0x02
+#define UP_STATUS_MSG_SENT_CLR 0x02
+
+#define SBEP_CMD_ACTION 0x1
+#define SBEP_CMD_TYPE_WRITE 0x0
+#define SBEP_CMD_TYPE_READ 0x1
+#define SBEP_CMD_POSTED 0x1
+#define SBEP_CMD_NON_POSTED 0x0
+#define SBEP_CMD_INT_ENABLED 0x1
+#define SBEP_CMD_ACTION_OFF 0
+#define SBEP_CMD_TYPE_OFF 1
+#define SBEP_CMD_POSTED_OFF 2
+#define SBEP_CMD_INT_OFF 3
+
+#define SBEP_CMD_WRITE \
+ ((SBEP_CMD_ACTION << SBEP_CMD_ACTION_OFF) | \
+ (SBEP_CMD_TYPE_WRITE << SBEP_CMD_TYPE_OFF) | \
+ (SBEP_CMD_POSTED << SBEP_CMD_POSTED_OFF) | \
+ (SBEP_CMD_INT_ENABLED << SBEP_CMD_INT_OFF))
+
+#define SBEP_ATTR_LTR_OPCODE 0x43
+#define SBEP_ATTR_PMC_DEST_ID 0xCC
+#define SBEP_ATTR_DEST_ID_OFF 0
+#define SBEP_ATTR_OPCODE_OFF 8
+#define SBEP_ATTR_WRITE_ALL_BYTES 0xF
+#define SBEP_ATTR_BYTE_ENABLE_OFF 16
+#define LTR_CMD_ATTR \
+ ((SBEP_ATTR_PMC_DEST_ID << SBEP_ATTR_DEST_ID_OFF) | \
+ (SBEP_ATTR_LTR_OPCODE << SBEP_ATTR_OPCODE_OFF) | \
+ (SBEP_ATTR_WRITE_ALL_BYTES << SBEP_ATTR_BYTE_ENABLE_OFF))
+#define LTR_CMD_DATA_2MS 0x90029002
+#define LTR_CMD_DATA_INFINITE 0
+
+#define SBEP_SAIRS_ROOT_SPACE_PMC 0
+
+#define SBEP_SAIRS_EH_PRESENT 1
+#define SBEP_SAIRS_ROOT_SPACE_OFF 16
+#define SBEP_SAIRS_EH_PRESENT_OFF 31
+
+#define SBEP_PMC_SAIRS_VAL \
+ ((SBEP_SAIRS_ROOT_SPACE_PMC << SBEP_SAIRS_ROOT_SPACE_OFF) | \
+ (SBEP_SAIRS_EH_PRESENT << SBEP_SAIRS_EH_PRESENT_OFF))
+
/* APIC interrupt vectors */
#define ISH_TS_VECTOR 0x20 /* Task switch vector */
#define LAPIC_LVT_ERROR_VECTOR 0x21 /* Clears IOAPIC/LAPIC sync errors */
@@ -208,6 +269,7 @@ enum ish_i2c_port {
#define PMU_PMC_PG_WAKE REG32(ISH_PMU_BASE + 0xF18)
#define PMU_INTERNAL_PCE REG32(ISH_PMU_BASE + 0xF30)
#define PMU_D3_STATUS REG32(ISH_PMU_BASE + 0x100)
+#define PMU_D3_STATUS_1 REG32(ISH_PMU_BASE + 0x104)
#define PMU_HOST_RST_B BIT(0)
#define PMU_PCE_SHADOW_MASK 0x1F
#define PMU_PCE_PG_ALLOWED BIT(4)
@@ -232,6 +294,10 @@ enum ish_i2c_port {
#define PMU_BME_BIT_FALLING_EDGE_STATUS BIT(26)
#define PMU_BME_BIT_RISING_EDGE_MASK BIT(27)
#define PMU_BME_BIT_FALLING_EDGE_MASK BIT(28)
+#define PMU_REG_MASK_D3_RISE REG32(ISH_PMU_BASE + 0x200)
+#define PMU_REG_MASK_D3_FALL REG32(ISH_PMU_BASE + 0x208)
+#define PMU_REG_MASK_BME_RISE REG32(ISH_PMU_BASE + 0x220)
+#define PMU_REG_MASK_BME_FALL REG32(ISH_PMU_BASE + 0x228)
#endif
#define PMU_GPIO_WAKE_MASK0 REG32(ISH_PMU_BASE + 0x250)
@@ -256,6 +322,7 @@ enum ish_i2c_port {
#define VNN_ID_DMA0 4
#define VNN_ID_DMA(chan) (VNN_ID_DMA0 + chan)
+#define VNN_ID_SIDEBAND 21
/* OCP registers */
#define OCP_IOSF2OCP_BRIDGE (ISH_OCP_BASE + 0x9400)
@@ -322,6 +389,7 @@ enum ish_i2c_port {
#define DEST_BURST_SIZE 3
#define PMU_MASK_EVENT REG32(ISH_PMU_BASE + 0x10)
+#define PMU_MASK_EVENT2 REG32(ISH_PMU_BASE + 0x4C)
#define PMU_MASK_EVENT_BIT_GPIO(pin) BIT(pin)
#define PMU_MASK_EVENT_BIT_HPET BIT(16)
#define PMU_MASK_EVENT_BIT_IPC BIT(17)
@@ -332,6 +400,16 @@ enum ish_i2c_port {
#define PMU_MASK_EVENT_BIT_SPI BIT(22)
#define PMU_MASK_EVENT_BIT_UART BIT(23)
#define PMU_MASK_EVENT_BIT_ALL (0xffffffff)
+#define PMU_MASK_EVENT2_SRAM_ERASE1 BIT(3)
+#define PMU_MASK_EVENT2_SRAM_ERASE0 BIT(4)
+#define PMU_MASK_EVENT2_ISOL_ACK_RISE BIT(14)
+#define PMU_MASK_EVENT2_ISOL_ACK_FALL BIT(15)
+#define PMU_MASK_EVENT2_HOST_RST_RISE BIT(16)
+#define PMU_MASK_EVENT2_HOST_RST_FALL BIT(17)
+#define PMU_MASK2_ALL_EVENTS \
+ (PMU_MASK_EVENT2_SRAM_ERASE0 | PMU_MASK_EVENT2_SRAM_ERASE1 | \
+ PMU_MASK_EVENT2_ISOL_ACK_RISE | PMU_MASK_EVENT2_ISOL_ACK_FALL | \
+ PMU_MASK_EVENT2_HOST_RST_RISE | PMU_MASK_EVENT2_HOST_RST_FALL)
#define PMU_RF_ROM_PWR_CTRL REG32(ISH_PMU_BASE + 0x30)
diff --git a/chip/ish/system_state_subsys.c b/chip/ish/system_state_subsys.c
index bfc120ff9b..76053dcded 100644
--- a/chip/ish/system_state_subsys.c
+++ b/chip/ish/system_state_subsys.c
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
+#include "console.h"
#include "heci_client.h"
#include "registers.h"
#include "system_state.h"
-#include "console.h"
#ifdef SS_SUBSYSTEM_DEBUG
#define CPUTS(outstr) cputs(CC_LPC, outstr)
diff --git a/chip/ish/uart.c b/chip/ish/uart.c
index b1c9493869..0ff03da89a 100644
--- a/chip/ish/uart.c
+++ b/chip/ish/uart.c
@@ -4,17 +4,16 @@
*/
/* UART module for ISH */
+#include "atomic.h"
#include "common.h"
-#include "math_util.h"
#include "console.h"
-#include "uart_defs.h"
-#include "atomic.h"
-#include "task.h"
+#include "interrupts.h"
+#include "math_util.h"
#include "registers.h"
+#include "system.h"
+#include "task.h"
#include "uart.h"
#include "uart_defs.h"
-#include "interrupts.h"
-#include "system.h"
#define CPUTS(outstr) cputs(CC_LPC, outstr)
#define CPRINTS(format, args...) cprints(CC_LPC, format, ##args)
diff --git a/chip/ish/uart_defs.h b/chip/ish/uart_defs.h
index 1fc36b7adc..581a702d31 100644
--- a/chip/ish/uart_defs.h
+++ b/chip/ish/uart_defs.h
@@ -8,10 +8,11 @@
#ifndef __CROS_EC_UART_DEFS_H_
#define __CROS_EC_UART_DEFS_H_
-#include <stdint.h>
-#include <stddef.h>
#include "atomic.h"
+#include <stddef.h>
+#include <stdint.h>
+
#define UART_ERROR -1
#define UART_BUSY -2
#ifdef CHIP_VARIANT_ISH5P4
diff --git a/chip/ish/watchdog.c b/chip/ish/watchdog.c
index 7b32133619..8f0ea5ddf1 100644
--- a/chip/ish/watchdog.c
+++ b/chip/ish/watchdog.c
@@ -23,9 +23,9 @@
#include "ec_commands.h"
#include "hooks.h"
#include "ish_persistent_data.h"
-#include "task.h"
#include "registers.h"
#include "system.h"
+#include "task.h"
#include "watchdog.h"
/* Units are hundreds of milliseconds */
diff --git a/chip/it83xx/adc.c b/chip/it83xx/adc.c
index 9f9fa27f41..c666fc4e88 100644
--- a/chip/it83xx/adc.c
+++ b/chip/it83xx/adc.c
@@ -7,8 +7,8 @@
#include "adc.h"
#include "clock.h"
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "gpio.h"
#include "hooks.h"
#include "registers.h"
diff --git a/chip/it83xx/adc_chip.h b/chip/it83xx/adc_chip.h
index 99e84624e0..3804a684e5 100644
--- a/chip/it83xx/adc_chip.h
+++ b/chip/it83xx/adc_chip.h
@@ -8,10 +8,10 @@
#ifndef __CROS_EC_ADC_CHIP_H
#define __CROS_EC_ADC_CHIP_H
-#include <stdint.h>
-
#include "common.h"
+#include <stdint.h>
+
/*
* Maximum time we allow for an ADC conversion.
* NOTE:
diff --git a/chip/it83xx/flash.c b/chip/it83xx/flash.c
index 25aefa2f66..fa8ab65292 100644
--- a/chip/it83xx/flash.c
+++ b/chip/it83xx/flash.c
@@ -9,13 +9,13 @@
#include "flash_chip.h"
#include "host_command.h"
#include "intc.h"
-#include "system.h"
-#include "util.h"
-#include "watchdog.h"
#include "registers.h"
-#include "task.h"
#include "shared_mem.h"
+#include "system.h"
+#include "task.h"
#include "uart.h"
+#include "util.h"
+#include "watchdog.h"
#define FLASH_DMA_START ((uint32_t)&__flash_dma_start)
#define FLASH_DMA_CODE __attribute__((section(".flash_direct_map")))
diff --git a/chip/it83xx/hwtimer.c b/chip/it83xx/hwtimer.c
index b9add82b5a..7a46f52773 100644
--- a/chip/it83xx/hwtimer.c
+++ b/chip/it83xx/hwtimer.c
@@ -5,8 +5,8 @@
/* Hardware timers driver */
-#include "cpu.h"
#include "common.h"
+#include "cpu.h"
#include "hooks.h"
#include "hwtimer.h"
#include "hwtimer_chip.h"
diff --git a/chip/it83xx/i2c_peripheral.c b/chip/it83xx/i2c_peripheral.c
index 80fea907fd..dfb139514f 100644
--- a/chip/it83xx/i2c_peripheral.c
+++ b/chip/it83xx/i2c_peripheral.c
@@ -12,9 +12,10 @@
#include "i2c_peripheral.h"
#include "printf.h"
#include "registers.h"
+#include "task.h"
+
#include <stddef.h>
#include <string.h>
-#include "task.h"
/* Console output macros */
#define CPRINTS(format, args...) cprints(CC_I2C, format, ##args)
diff --git a/chip/it83xx/keyboard_raw.c b/chip/it83xx/keyboard_raw.c
index 0d2f048deb..9123a6e5e8 100644
--- a/chip/it83xx/keyboard_raw.c
+++ b/chip/it83xx/keyboard_raw.c
@@ -4,11 +4,11 @@
*/
#include "common.h"
+#include "irq_chip.h"
#include "keyboard_raw.h"
#include "keyboard_scan.h"
#include "registers.h"
#include "task.h"
-#include "irq_chip.h"
#define KSOH_PIN_MASK (((1 << (KEYBOARD_COLS_MAX - 8)) - 1) & 0xff)
diff --git a/chip/it83xx/peci.c b/chip/it83xx/peci.c
index e5f172ce80..ee94f2baac 100644
--- a/chip/it83xx/peci.c
+++ b/chip/it83xx/peci.c
@@ -10,9 +10,9 @@
#include "hooks.h"
#include "peci.h"
#include "registers.h"
-#include "util.h"
-#include "timer.h"
#include "task.h"
+#include "timer.h"
+#include "util.h"
enum peci_status {
PECI_STATUS_NO_ERR = 0x00,
diff --git a/chip/it83xx/pwm.c b/chip/it83xx/pwm.c
index 07165dea77..3d0d4eaeb6 100644
--- a/chip/it83xx/pwm.c
+++ b/chip/it83xx/pwm.c
@@ -8,11 +8,11 @@
#include "clock.h"
#include "gpio.h"
#include "hooks.h"
+#include "math_util.h"
#include "pwm.h"
#include "pwm_chip.h"
#include "registers.h"
#include "util.h"
-#include "math_util.h"
#define PWM_CTRX_MIN 100
#define PWM_EC_FREQ 8000000
diff --git a/chip/max32660/clock_chip.c b/chip/max32660/clock_chip.c
index 93a5f862d8..26225401ba 100644
--- a/chip/max32660/clock_chip.c
+++ b/chip/max32660/clock_chip.c
@@ -9,16 +9,16 @@
#include "common.h"
#include "console.h"
#include "cpu.h"
+#include "gcr_regs.h"
#include "hooks.h"
#include "hwtimer.h"
+#include "pwrseq_regs.h"
#include "registers.h"
#include "system.h"
#include "timer.h"
+#include "tmr_regs.h"
#include "util.h"
#include "watchdog.h"
-#include "tmr_regs.h"
-#include "gcr_regs.h"
-#include "pwrseq_regs.h"
#define MAX32660_SYSTEMCLOCK SYS_CLOCK_HIRC
diff --git a/chip/max32660/flash_chip.c b/chip/max32660/flash_chip.c
index eb702799b0..01a26f94b5 100644
--- a/chip/max32660/flash_chip.c
+++ b/chip/max32660/flash_chip.c
@@ -5,16 +5,16 @@
/* MAX32660 Flash Memory Module for Chrome EC */
+#include "common.h"
#include "flash.h"
+#include "flc_regs.h"
+#include "icc_regs.h"
+#include "registers.h"
#include "switch.h"
#include "system.h"
#include "timer.h"
#include "util.h"
#include "watchdog.h"
-#include "registers.h"
-#include "common.h"
-#include "icc_regs.h"
-#include "flc_regs.h"
#define CPUTS(outstr) cputs(CC_SYSTEM, outstr)
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
diff --git a/chip/max32660/gpio_chip.c b/chip/max32660/gpio_chip.c
index cc54f9055f..b6deaa9111 100644
--- a/chip/max32660/gpio_chip.c
+++ b/chip/max32660/gpio_chip.c
@@ -6,16 +6,16 @@
/* MAX32660 GPIO module for Chrome EC */
#include "clock.h"
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "gpio.h"
+#include "gpio_regs.h"
#include "hooks.h"
+#include "registers.h"
#include "switch.h"
#include "task.h"
#include "timer.h"
#include "util.h"
-#include "registers.h"
-#include "gpio_regs.h"
#define CPRINTF(format, args...) cprintf(CC_GPIO, format, ##args)
#define CPRINTS(format, args...) cprints(CC_GPIO, format, ##args)
diff --git a/chip/max32660/hwtimer_chip.c b/chip/max32660/hwtimer_chip.c
index a6469ae795..b6c39f4036 100644
--- a/chip/max32660/hwtimer_chip.c
+++ b/chip/max32660/hwtimer_chip.c
@@ -6,15 +6,15 @@
/* MAX32660 HW Timer module for Chrome EC */
#include "clock.h"
-#include "console.h"
#include "common.h"
+#include "console.h"
+#include "gcr_regs.h"
#include "hooks.h"
#include "hwtimer.h"
+#include "registers.h"
#include "task.h"
#include "timer.h"
-#include "registers.h"
#include "tmr_regs.h"
-#include "gcr_regs.h"
/* Define the rollover timer */
#define TMR_ROLLOVER MXC_TMR0
diff --git a/chip/max32660/i2c_chip.c b/chip/max32660/i2c_chip.c
index bb116f4d8a..a4fab91199 100644
--- a/chip/max32660/i2c_chip.c
+++ b/chip/max32660/i2c_chip.c
@@ -5,18 +5,19 @@
/* MAX32660 I2C port module for Chrome EC. */
-#include <stdint.h>
-#include <stddef.h>
#include "common.h"
#include "config_chip.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
+#include "i2c_regs.h"
+#include "registers.h"
#include "stdbool.h"
#include "system.h"
#include "task.h"
-#include "registers.h"
-#include "i2c_regs.h"
+
+#include <stddef.h>
+#include <stdint.h>
/**
* Byte to use if the EC HOST requested more data
diff --git a/chip/max32660/system_chip.c b/chip/max32660/system_chip.c
index 8679881102..f63e22dc26 100644
--- a/chip/max32660/system_chip.c
+++ b/chip/max32660/system_chip.c
@@ -9,14 +9,14 @@
#include "common.h"
#include "console.h"
#include "cpu.h"
+#include "gcr_regs.h"
#include "host_command.h"
#include "panic.h"
+#include "registers.h"
#include "system.h"
#include "task.h"
#include "timer.h"
#include "util.h"
-#include "registers.h"
-#include "gcr_regs.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_SYSTEM, outstr)
diff --git a/chip/max32660/uart_chip.c b/chip/max32660/uart_chip.c
index 87ba59e629..ec25d9e476 100644
--- a/chip/max32660/uart_chip.c
+++ b/chip/max32660/uart_chip.c
@@ -5,18 +5,19 @@
/* MAX32660 Console UART Module for Chrome EC */
-#include <stdint.h>
+#include "common.h"
+#include "gcr_regs.h"
+#include "gpio.h"
+#include "gpio_regs.h"
+#include "registers.h"
#include "system.h"
#include "task.h"
-#include "uart.h"
-#include "registers.h"
#include "tmr_regs.h"
-#include "gpio.h"
-#include "gpio_regs.h"
-#include "common.h"
-#include "gcr_regs.h"
+#include "uart.h"
#include "uart_regs.h"
+#include <stdint.h>
+
static int done_uart_init_yet;
#ifndef UARTN
diff --git a/chip/max32660/wdt_chip.c b/chip/max32660/wdt_chip.c
index 03cd2bd009..4890c34536 100644
--- a/chip/max32660/wdt_chip.c
+++ b/chip/max32660/wdt_chip.c
@@ -7,14 +7,14 @@
#include "clock.h"
#include "common.h"
+#include "config.h"
+#include "console.h"
#include "gpio.h"
#include "hooks.h"
+#include "registers.h"
#include "task.h"
#include "util.h"
#include "watchdog.h"
-#include "console.h"
-#include "registers.h"
-#include "board.h"
#include "wdt_regs.h"
#define CPUTS(outstr) cputs(CC_COMMAND, outstr)
diff --git a/chip/mchp/adc.c b/chip/mchp/adc.c
index 621fe1f3be..f09c04d26b 100644
--- a/chip/mchp/adc.c
+++ b/chip/mchp/adc.c
@@ -10,9 +10,9 @@
#include "hooks.h"
#include "registers.h"
#include "task.h"
+#include "tfdp_chip.h"
#include "timer.h"
#include "util.h"
-#include "tfdp_chip.h"
/*
* Conversion on a single channel takes less than 12 ms. Set timeout to
diff --git a/chip/mchp/clock.c b/chip/mchp/clock.c
index 4701d43b1f..0323d16f8f 100644
--- a/chip/mchp/clock.c
+++ b/chip/mchp/clock.c
@@ -17,10 +17,10 @@
#include "shared_mem.h"
#include "system.h"
#include "task.h"
+#include "tfdp_chip.h"
#include "timer.h"
#include "uart.h"
#include "util.h"
-#include "tfdp_chip.h"
#include "vboot_hash.h"
/* Console output macros */
diff --git a/chip/mchp/dma.c b/chip/mchp/dma.c
index 8a091286a7..c921527d7f 100644
--- a/chip/mchp/dma.c
+++ b/chip/mchp/dma.c
@@ -9,9 +9,9 @@
#include "hooks.h"
#include "registers.h"
#include "task.h"
+#include "tfdp_chip.h"
#include "timer.h"
#include "util.h"
-#include "tfdp_chip.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_DMA, outstr)
diff --git a/chip/mchp/dma_chip.h b/chip/mchp/dma_chip.h
index 6f569a1dc7..bfdb8ab9be 100644
--- a/chip/mchp/dma_chip.h
+++ b/chip/mchp/dma_chip.h
@@ -13,8 +13,8 @@
#ifndef _DMA_CHIP_H
#define _DMA_CHIP_H
-#include <stdint.h>
#include <stddef.h>
+#include <stdint.h>
#ifdef __cplusplus
extern "C" {
diff --git a/chip/mchp/espi.c b/chip/mchp/espi.c
index 371cf09c5e..53d17e90b2 100644
--- a/chip/mchp/espi.c
+++ b/chip/mchp/espi.c
@@ -5,29 +5,26 @@
/* ESPI module for Chrome EC */
-#include "common.h"
#include "acpi.h"
+#include "chipset.h"
+#include "common.h"
#include "console.h"
+#include "espi.h"
#include "gpio.h"
#include "hooks.h"
#include "host_command.h"
#include "keyboard_protocol.h"
-#include "port80.h"
-#include "util.h"
-#include "chipset.h"
-
-#include "registers.h"
-#include "espi.h"
#include "lpc.h"
#include "lpc_chip.h"
+#include "port80.h"
+#include "power.h"
+#include "registers.h"
#include "system.h"
#include "task.h"
-#include "console.h"
+#include "tfdp_chip.h"
+#include "timer.h"
#include "uart.h"
#include "util.h"
-#include "power.h"
-#include "timer.h"
-#include "tfdp_chip.h"
/* Console output macros */
#ifdef CONFIG_MCHP_ESPI_DEBUG
diff --git a/chip/mchp/fan.c b/chip/mchp/fan.c
index 3f61cb4d2f..c68d71bcc8 100644
--- a/chip/mchp/fan.c
+++ b/chip/mchp/fan.c
@@ -9,8 +9,8 @@
#include "fan.h"
#include "registers.h"
-#include "util.h"
#include "tfdp_chip.h"
+#include "util.h"
/* Maximum fan driver setting value */
#define MAX_FAN_DRIVER_SETTING 0x3ff
diff --git a/chip/mchp/flash.c b/chip/mchp/flash.c
index 4b0e407fb2..f0f3a5575e 100644
--- a/chip/mchp/flash.c
+++ b/chip/mchp/flash.c
@@ -6,14 +6,14 @@
#include "common.h"
#include "console.h"
#include "flash.h"
+#include "hooks.h"
#include "host_command.h"
#include "shared_mem.h"
#include "spi.h"
#include "spi_flash.h"
#include "system.h"
-#include "util.h"
-#include "hooks.h"
#include "tfdp_chip.h"
+#include "util.h"
#define PAGE_SIZE 256
diff --git a/chip/mchp/gpio.c b/chip/mchp/gpio.c
index a3cab86fcc..3ad9d7b6e4 100644
--- a/chip/mchp/gpio.c
+++ b/chip/mchp/gpio.c
@@ -8,13 +8,13 @@
#include "common.h"
#include "gpio.h"
#include "hooks.h"
+#include "lpc_chip.h"
#include "registers.h"
#include "system.h"
#include "task.h"
+#include "tfdp_chip.h"
#include "timer.h"
#include "util.h"
-#include "lpc_chip.h"
-#include "tfdp_chip.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_LPC, outstr)
diff --git a/chip/mchp/gpio_chip.h b/chip/mchp/gpio_chip.h
index e092669b60..ec0f3d2278 100644
--- a/chip/mchp/gpio_chip.h
+++ b/chip/mchp/gpio_chip.h
@@ -13,11 +13,11 @@
#ifndef _GPIO_CHIP_H
#define _GPIO_CHIP_H
-#include <stdint.h>
-#include <stddef.h>
-
#include "gpio.h"
+#include <stddef.h>
+#include <stdint.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/chip/mchp/gpio_cmds.c b/chip/mchp/gpio_cmds.c
index 927d6d0326..a53f8cca2a 100644
--- a/chip/mchp/gpio_cmds.c
+++ b/chip/mchp/gpio_cmds.c
@@ -8,12 +8,12 @@
#include "common.h"
#include "console.h"
#include "gpio.h"
+#include "gpio_chip.h"
#include "hooks.h"
#include "registers.h"
#include "system.h"
-#include "util.h"
-#include "gpio_chip.h"
#include "tfdp_chip.h"
+#include "util.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_LPC, outstr)
diff --git a/chip/mchp/gpspi.c b/chip/mchp/gpspi.c
index 0142fe0e3c..a7f7b388c4 100644
--- a/chip/mchp/gpspi.c
+++ b/chip/mchp/gpspi.c
@@ -9,15 +9,15 @@
#include "console.h"
#include "dma.h"
#include "gpio.h"
+#include "gpspi_chip.h"
+#include "hooks.h"
#include "registers.h"
#include "spi.h"
-#include "timer.h"
-#include "util.h"
-#include "hooks.h"
-#include "task.h"
#include "spi_chip.h"
-#include "gpspi_chip.h"
+#include "task.h"
#include "tfdp_chip.h"
+#include "timer.h"
+#include "util.h"
#define CPUTS(outstr) cputs(CC_SPI, outstr)
#define CPRINTS(format, args...) cprints(CC_SPI, format, ##args)
diff --git a/chip/mchp/gpspi_chip.h b/chip/mchp/gpspi_chip.h
index 7c1285b6cf..16c3208410 100644
--- a/chip/mchp/gpspi_chip.h
+++ b/chip/mchp/gpspi_chip.h
@@ -13,8 +13,8 @@
#ifndef _GPSPI_CHIP_H
#define _GPSPI_CHIP_H
-#include <stdint.h>
#include <stddef.h>
+#include <stdint.h>
/* struct spi_device_t */
#include "spi.h"
diff --git a/chip/mchp/hwtimer.c b/chip/mchp/hwtimer.c
index 2e9ff780fb..c72140b18f 100644
--- a/chip/mchp/hwtimer.c
+++ b/chip/mchp/hwtimer.c
@@ -11,8 +11,8 @@
#include "hwtimer.h"
#include "registers.h"
#include "task.h"
-#include "timer.h"
#include "tfdp_chip.h"
+#include "timer.h"
void __hw_clock_event_set(uint32_t deadline)
{
diff --git a/chip/mchp/keyboard_raw.c b/chip/mchp/keyboard_raw.c
index daa0c8e64f..30181776fa 100644
--- a/chip/mchp/keyboard_raw.c
+++ b/chip/mchp/keyboard_raw.c
@@ -11,8 +11,8 @@
#include "keyboard_scan.h"
#include "registers.h"
#include "task.h"
-#include "util.h"
#include "tfdp_chip.h"
+#include "util.h"
/*
* Using direct mode interrupt, do not enable
diff --git a/chip/mchp/lfw/ec_lfw.c b/chip/mchp/lfw/ec_lfw.c
index dfd9814e6e..eb8b3370cb 100644
--- a/chip/mchp/lfw/ec_lfw.c
+++ b/chip/mchp/lfw/ec_lfw.c
@@ -6,23 +6,23 @@
*
*/
-#include <stdint.h>
-
+#include "clock.h"
#include "config.h"
+#include "cpu.h"
#include "cros_version.h"
+#include "dma.h"
#include "gpio.h"
+#include "gpio_list.h"
+#include "hwtimer.h"
+#include "registers.h"
#include "spi.h"
#include "spi_flash.h"
-#include "util.h"
-#include "timer.h"
-#include "dma.h"
-#include "registers.h"
-#include "cpu.h"
-#include "clock.h"
#include "system.h"
-#include "hwtimer.h"
-#include "gpio_list.h"
#include "tfdp_chip.h"
+#include "timer.h"
+#include "util.h"
+
+#include <stdint.h>
#ifdef CONFIG_MCHP_LFW_DEBUG
#include "dma_chip.h"
@@ -305,7 +305,7 @@ void uart_init(void)
}
#endif /* #ifdef CONFIG_UART_CONSOLE */
-void fault_handler(void)
+noreturn void watchdog_reset(void)
{
uart_puts("EXCEPTION!\nTriggering watchdog reset\n");
/* trigger reset in 1 ms */
@@ -315,6 +315,11 @@ void fault_handler(void)
;
}
+void fault_handler(void)
+{
+ asm("b watchdog_reset");
+}
+
void jump_to_image(uintptr_t init_addr)
{
void (*resetvec)(void) = (void (*)(void))init_addr;
diff --git a/chip/mchp/lfw/ec_lfw.h b/chip/mchp/lfw/ec_lfw.h
index 2589638954..0c677e5d0b 100644
--- a/chip/mchp/lfw/ec_lfw.h
+++ b/chip/mchp/lfw/ec_lfw.h
@@ -7,6 +7,7 @@
*/
#include <stdint.h>
+
#include <stdnoreturn.h>
/* Why naked? This is dangerous except for
diff --git a/chip/mchp/lfw/ec_lfw.ld b/chip/mchp/lfw/ec_lfw.ld
index f0071a55e9..d178a42280 100644
--- a/chip/mchp/lfw/ec_lfw.ld
+++ b/chip/mchp/lfw/ec_lfw.ld
@@ -79,7 +79,15 @@ SECTIONS
FILL(0xFF);
. = ORIGIN(SRAM) + LENGTH(SRAM) - 1;
BYTE(0xFF); /* emit at least a byte to make linker happy */
- }
+ } >SRAM
__image_size = LOADADDR(.text) + SIZEOF(.text) - ORIGIN(VECTOR);
+
+ /*
+ * Discard C++ exception index table and exception table. These are
+ * described in more detail in "Exception Handling ABI for ARM
+ * Architecture":
+ * https://github.com/ARM-software/abi-aa/blob/60a8eb8c55e999d74dac5e368fc9d7e36e38dda4/ehabi32/ehabi32.rst#54the-object-producer-interface
+ */
+ /DISCARD/ : { *(.ARM.*) }
}
diff --git a/chip/mchp/lfw/ec_lfw_416kb.ld b/chip/mchp/lfw/ec_lfw_416kb.ld
index f27d046e7d..c7dfacada3 100644
--- a/chip/mchp/lfw/ec_lfw_416kb.ld
+++ b/chip/mchp/lfw/ec_lfw_416kb.ld
@@ -83,7 +83,15 @@ SECTIONS
FILL(0xFF);
. = ORIGIN(SRAM) + LENGTH(SRAM) - 1;
BYTE(0xFF); /* emit at least a byte to make linker happy */
- }
+ } >SRAM
__image_size = LOADADDR(.text) + SIZEOF(.text) - ORIGIN(VECTOR);
+
+ /*
+ * Discard C++ exception index table and exception table. These are
+ * described in more detail in "Exception Handling ABI for ARM
+ * Architecture":
+ * https://github.com/ARM-software/abi-aa/blob/60a8eb8c55e999d74dac5e368fc9d7e36e38dda4/ehabi32/ehabi32.rst#54the-object-producer-interface
+ */
+ /DISCARD/ : { *(.ARM.*) }
}
diff --git a/chip/mchp/lpc.c b/chip/mchp/lpc.c
index da9b045b22..e41e4b0c78 100644
--- a/chip/mchp/lpc.c
+++ b/chip/mchp/lpc.c
@@ -5,24 +5,24 @@
/* LPC module for MCHP MEC family */
-#include "common.h"
#include "acpi.h"
+#include "chipset.h"
+#include "common.h"
#include "console.h"
+#include "espi.h"
#include "gpio.h"
#include "hooks.h"
#include "host_command.h"
#include "keyboard_protocol.h"
#include "lpc.h"
#include "lpc_chip.h"
-#include "espi.h"
#include "port80.h"
#include "registers.h"
#include "system.h"
#include "task.h"
+#include "tfdp_chip.h"
#include "timer.h"
#include "util.h"
-#include "chipset.h"
-#include "tfdp_chip.h"
/* Console output macros */
#ifdef CONFIG_MCHP_DEBUG_LPC
diff --git a/chip/mchp/pwm.c b/chip/mchp/pwm.c
index d0e88b5175..706228fa53 100644
--- a/chip/mchp/pwm.c
+++ b/chip/mchp/pwm.c
@@ -12,8 +12,8 @@
#include "pwm.h"
#include "pwm_chip.h"
#include "registers.h"
-#include "util.h"
#include "tfdp_chip.h"
+#include "util.h"
#define CPUTS(outstr) cputs(CC_PWM, outstr)
#define CPRINTS(format, args...) cprints(CC_PWM, format, ##args)
diff --git a/chip/mchp/qmspi.c b/chip/mchp/qmspi.c
index 6979bdae6a..a0d31b72e3 100644
--- a/chip/mchp/qmspi.c
+++ b/chip/mchp/qmspi.c
@@ -8,17 +8,17 @@
#include "common.h"
#include "console.h"
#include "dma.h"
+#include "dma_chip.h"
#include "gpio.h"
+#include "hooks.h"
+#include "qmspi_chip.h"
#include "registers.h"
#include "spi.h"
-#include "timer.h"
-#include "util.h"
-#include "hooks.h"
-#include "task.h"
-#include "dma_chip.h"
#include "spi_chip.h"
-#include "qmspi_chip.h"
+#include "task.h"
#include "tfdp_chip.h"
+#include "timer.h"
+#include "util.h"
#define CPUTS(outstr) cputs(CC_SPI, outstr)
#define CPRINTS(format, args...) cprints(CC_SPI, format, ##args)
diff --git a/chip/mchp/qmspi_chip.h b/chip/mchp/qmspi_chip.h
index 5a66c34e62..899f59516f 100644
--- a/chip/mchp/qmspi_chip.h
+++ b/chip/mchp/qmspi_chip.h
@@ -13,8 +13,8 @@
#ifndef _QMSPI_CHIP_H
#define _QMSPI_CHIP_H
-#include <stdint.h>
#include <stddef.h>
+#include <stdint.h>
/* struct spi_device_t */
#include "spi.h"
diff --git a/chip/mchp/spi.c b/chip/mchp/spi.c
index 195c10d8a6..4445666790 100644
--- a/chip/mchp/spi.c
+++ b/chip/mchp/spi.c
@@ -9,14 +9,14 @@
#include "console.h"
#include "dma.h"
#include "gpio.h"
+#include "hooks.h"
+#include "qmspi_chip.h"
#include "registers.h"
#include "spi.h"
+#include "spi_chip.h"
+#include "task.h"
#include "timer.h"
#include "util.h"
-#include "hooks.h"
-#include "task.h"
-#include "spi_chip.h"
-#include "qmspi_chip.h"
#if defined(CONFIG_MCHP_GPSPI) && !defined(LFW)
#include "gpspi_chip.h"
#endif
diff --git a/chip/mchp/spi_chip.h b/chip/mchp/spi_chip.h
index f8c4c1169c..e651901ea4 100644
--- a/chip/mchp/spi_chip.h
+++ b/chip/mchp/spi_chip.h
@@ -13,8 +13,8 @@
#ifndef _SPI_CHIP_H
#define _SPI_CHIP_H
-#include <stdint.h>
#include <stddef.h>
+#include <stdint.h>
/* struct spi_device_t */
#include "spi.h"
diff --git a/chip/mchp/system.c b/chip/mchp/system.c
index bb5224c455..65470c43b9 100644
--- a/chip/mchp/system.c
+++ b/chip/mchp/system.c
@@ -5,11 +5,9 @@
/* System module for Chrome EC : MCHP hardware specific implementation */
-#include <stdnoreturn.h>
-
-#include "common.h" /* includes config.h and board.h */
#include "clock.h"
#include "clock_chip.h"
+#include "common.h" /* includes config.h and board.h */
#include "console.h"
#include "cpu.h"
#include "gpio.h"
@@ -25,6 +23,8 @@
#include "timer.h"
#include "util.h"
+#include <stdnoreturn.h>
+
#define CPUTS(outstr) cputs(CC_LPC, outstr)
#define CPRINTS(format, args...) cprints(CC_LPC, format, ##args)
diff --git a/chip/mchp/uart.c b/chip/mchp/uart.c
index 00bfc77e14..59ea3e1c35 100644
--- a/chip/mchp/uart.c
+++ b/chip/mchp/uart.c
@@ -13,9 +13,9 @@
#include "registers.h"
#include "system.h"
#include "task.h"
+#include "tfdp_chip.h"
#include "uart.h"
#include "util.h"
-#include "tfdp_chip.h"
#define TX_FIFO_SIZE 16
diff --git a/chip/mchp/watchdog.c b/chip/mchp/watchdog.c
index 0de4398fdb..50edda70e0 100644
--- a/chip/mchp/watchdog.c
+++ b/chip/mchp/watchdog.c
@@ -8,8 +8,8 @@
#include "hooks.h"
#include "registers.h"
#include "task.h"
-#include "watchdog.h"
#include "tfdp_chip.h"
+#include "watchdog.h"
void watchdog_reload(void)
{
diff --git a/chip/mt_scp/mt818x/ipi.c b/chip/mt_scp/mt818x/ipi.c
index 723137d9c9..d0d9292fd1 100644
--- a/chip/mt_scp/mt818x/ipi.c
+++ b/chip/mt_scp/mt818x/ipi.c
@@ -24,13 +24,13 @@
#include "console.h"
#include "hooks.h"
#include "host_command.h"
+#include "hwtimer.h"
#include "ipi_chip.h"
#include "mkbp_event.h"
#include "power.h"
#include "system.h"
#include "task.h"
#include "util.h"
-#include "hwtimer.h"
#include "video.h"
#define CPRINTF(format, args...) cprintf(CC_IPI, format, ##args)
diff --git a/chip/mt_scp/mt818x/memmap.c b/chip/mt_scp/mt818x/memmap.c
index 0ecb370cf3..24c0fd8f7a 100644
--- a/chip/mt_scp/mt818x/memmap.c
+++ b/chip/mt_scp/mt818x/memmap.c
@@ -11,8 +11,8 @@
#include "hooks.h"
#include "memmap.h"
#include "registers.h"
-#include "util.h"
#include "task.h"
+#include "util.h"
/*
* Map SCP address (bits 31~28) to AP address
diff --git a/chip/mt_scp/mt8192/clock.c b/chip/mt_scp/mt8192/clock.c
index 665695a7a2..21d07d410a 100644
--- a/chip/mt_scp/mt8192/clock.c
+++ b/chip/mt_scp/mt8192/clock.c
@@ -5,9 +5,6 @@
/* Clocks, PLL and power settings */
-#include <assert.h>
-#include <string.h>
-
#include "clock.h"
#include "common.h"
#include "console.h"
@@ -17,6 +14,9 @@
#include "registers.h"
#include "timer.h"
+#include <assert.h>
+#include <string.h>
+
#define CPRINTF(format, args...) cprintf(CC_CLOCK, format, ##args)
#define CPRINTS(format, args...) cprints(CC_CLOCK, format, ##args)
diff --git a/chip/mt_scp/mt8195/clock.c b/chip/mt_scp/mt8195/clock.c
index 2ed3fab4a1..779f356bab 100644
--- a/chip/mt_scp/mt8195/clock.c
+++ b/chip/mt_scp/mt8195/clock.c
@@ -5,9 +5,6 @@
/* Clocks, PLL and power settings */
-#include <assert.h>
-#include <string.h>
-
#include "clock.h"
#include "common.h"
#include "console.h"
@@ -20,6 +17,9 @@
#include "task.h"
#include "timer.h"
+#include <assert.h>
+#include <string.h>
+
#define CPRINTF(format, args...) cprintf(CC_CLOCK, format, ##args)
#define CPRINTS(format, args...) cprints(CC_CLOCK, format, ##args)
diff --git a/chip/npcx/adc.c b/chip/npcx/adc.c
index f01419bf67..73d4ec48b3 100644
--- a/chip/npcx/adc.c
+++ b/chip/npcx/adc.c
@@ -9,8 +9,8 @@
#include "atomic.h"
#include "clock.h"
#include "clock_chip.h"
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "gpio.h"
#include "hooks.h"
#include "registers.h"
diff --git a/chip/npcx/espi.c b/chip/npcx/espi.c
index d64a22860d..e73d04e988 100644
--- a/chip/npcx/espi.c
+++ b/chip/npcx/espi.c
@@ -5,18 +5,18 @@
/* ESPI module for Chrome EC */
-#include "registers.h"
-#include "system.h"
-#include "task.h"
#include "chipset.h"
#include "console.h"
-#include "uart.h"
-#include "util.h"
-#include "power.h"
#include "espi.h"
-#include "lpc_chip.h"
#include "hooks.h"
+#include "lpc_chip.h"
+#include "power.h"
+#include "registers.h"
+#include "system.h"
+#include "task.h"
#include "timer.h"
+#include "uart.h"
+#include "util.h"
/* Console output macros */
#if !(DEBUG_ESPI)
@@ -274,6 +274,9 @@ void espi_wait_vw_not_dirty(enum espi_vw_signal signal, unsigned int timeout_us)
uint64_t timeout;
sig_idx = espi_vw_get_signal_index(signal);
+ /* Cannot find signal index */
+ if (sig_idx < 0)
+ return;
for (offset = 0; offset < ESPI_VWEVSM_NUM; offset++) {
uint8_t vw_idx = VWEVSM_IDX_GET(NPCX_VWEVSM(offset));
diff --git a/chip/npcx/fan.c b/chip/npcx/fan.c
index 6a246f5c6a..9ceccaba33 100644
--- a/chip/npcx/fan.c
+++ b/chip/npcx/fan.c
@@ -7,20 +7,19 @@
#include "clock.h"
#include "clock_chip.h"
+#include "console.h"
#include "fan.h"
#include "fan_chip.h"
#include "gpio.h"
#include "hooks.h"
-#include "registers.h"
-#include "util.h"
+#include "math_util.h"
#include "pwm.h"
#include "pwm_chip.h"
-#include "console.h"
-#include "timer.h"
-#include "task.h"
-#include "hooks.h"
+#include "registers.h"
#include "system.h"
-#include "math_util.h"
+#include "task.h"
+#include "timer.h"
+#include "util.h"
#if !(DEBUG_FAN)
#define CPRINTS(...)
diff --git a/chip/npcx/flash.c b/chip/npcx/flash.c
index 390cb1fa64..dc8de6e3ee 100644
--- a/chip/npcx/flash.c
+++ b/chip/npcx/flash.c
@@ -6,18 +6,18 @@
/* Flash memory module for Chrome EC */
#include "builtin/assert.h"
+#include "console.h"
#include "flash.h"
#include "host_command.h"
+#include "hwtimer_chip.h"
#include "registers.h"
#include "spi_flash_reg.h"
#include "switch.h"
#include "system.h"
+#include "task.h"
#include "timer.h"
#include "util.h"
-#include "task.h"
#include "watchdog.h"
-#include "console.h"
-#include "hwtimer_chip.h"
static int all_protected; /* Has all-flash protection been requested? */
static int addr_prot_start;
diff --git a/chip/npcx/gpio.c b/chip/npcx/gpio.c
index 4127b79e30..a976b3b122 100644
--- a/chip/npcx/gpio.c
+++ b/chip/npcx/gpio.c
@@ -7,19 +7,19 @@
#include "builtin/assert.h"
#include "common.h"
+#include "ec_commands.h"
#include "gpio.h"
#include "gpio_chip.h"
-#include "i2c.h"
#include "hooks.h"
+#include "host_command.h"
+#include "hwtimer_chip.h"
+#include "i2c.h"
#include "registers.h"
+#include "system.h"
+#include "system_chip.h"
#include "task.h"
#include "timer.h"
#include "util.h"
-#include "system.h"
-#include "system_chip.h"
-#include "ec_commands.h"
-#include "host_command.h"
-#include "hwtimer_chip.h"
#if !(DEBUG_GPIO)
#define CPUTS(...)
diff --git a/chip/npcx/header.c b/chip/npcx/header.c
index 2db7d9094c..81e5e986af 100644
--- a/chip/npcx/header.c
+++ b/chip/npcx/header.c
@@ -10,11 +10,11 @@
* This header is used by Nuvoton EC Booter.
*/
-#include <stdint.h>
-
#include "config.h"
#include "registers.h"
+#include <stdint.h>
+
/* Signature used by fw header */
#define SIG_FW_EC 0x2A3B4D5E
diff --git a/chip/npcx/hwtimer.c b/chip/npcx/hwtimer.c
index dfa06f69b2..e2e2fe4b19 100644
--- a/chip/npcx/hwtimer.c
+++ b/chip/npcx/hwtimer.c
@@ -8,12 +8,12 @@
#include "clock.h"
#include "clock_chip.h"
#include "common.h"
+#include "console.h"
#include "hooks.h"
#include "hwtimer.h"
#include "hwtimer_chip.h"
#include "math_util.h"
#include "registers.h"
-#include "console.h"
#include "task.h"
#include "timer.h"
#include "util.h"
diff --git a/chip/npcx/keyboard_raw.c b/chip/npcx/keyboard_raw.c
index cb2be7911e..1774e7353d 100644
--- a/chip/npcx/keyboard_raw.c
+++ b/chip/npcx/keyboard_raw.c
@@ -5,11 +5,11 @@
/* Functions needed by keyboard scanner module for Chrome EC */
+#include "clock.h"
#include "common.h"
+#include "gpio.h"
#include "keyboard_raw.h"
#include "keyboard_scan.h"
-#include "clock.h"
-#include "gpio.h"
#include "registers.h"
#include "task.h"
diff --git a/chip/npcx/lct.c b/chip/npcx/lct.c
index 19568cac44..8f720e1376 100644
--- a/chip/npcx/lct.c
+++ b/chip/npcx/lct.c
@@ -4,9 +4,9 @@
*/
/* LCT (Long Countdown Timer) module for Chrome EC */
-#include "lct_chip.h"
#include "console.h"
#include "hooks.h"
+#include "lct_chip.h"
#include "registers.h"
#include "rtc.h"
#include "task.h"
diff --git a/chip/npcx/lpc.c b/chip/npcx/lpc.c
index 48e094f3fc..b44420e025 100644
--- a/chip/npcx/lpc.c
+++ b/chip/npcx/lpc.c
@@ -20,12 +20,12 @@
#include "lpc_chip.h"
#include "port80.h"
#include "registers.h"
-#include "system.h"
#include "sib_chip.h"
+#include "system.h"
+#include "system_chip.h"
#include "task.h"
#include "uart.h"
#include "util.h"
-#include "system_chip.h"
/* Console output macros */
#if !(DEBUG_LPC)
diff --git a/chip/npcx/peci.c b/chip/npcx/peci.c
index 7c213648f4..8a4372f7bd 100644
--- a/chip/npcx/peci.c
+++ b/chip/npcx/peci.c
@@ -15,8 +15,8 @@
#include "peci.h"
#include "registers.h"
#include "task.h"
-#include "timer.h"
#include "temp_sensor.h"
+#include "timer.h"
#include "util.h"
/* Initial PECI baud rate */
diff --git a/chip/npcx/ps2.c b/chip/npcx/ps2.c
index a8a65e63ea..5fc91ef241 100644
--- a/chip/npcx/ps2.c
+++ b/chip/npcx/ps2.c
@@ -8,11 +8,11 @@
#include "atomic.h"
#include "clock.h"
#include "console.h"
-#include "hooks.h"
#include "gpio.h"
+#include "hooks.h"
#include "ps2_chip.h"
-#include "task.h"
#include "registers.h"
+#include "task.h"
#include "timer.h"
#include "util.h"
diff --git a/chip/npcx/registers.h b/chip/npcx/registers.h
index 922d787323..a583fb1c64 100644
--- a/chip/npcx/registers.h
+++ b/chip/npcx/registers.h
@@ -8,9 +8,9 @@
#ifndef __CROS_EC_REGISTERS_H
#define __CROS_EC_REGISTERS_H
+#include "clock_chip.h"
#include "common.h"
#include "compile_time_macros.h"
-#include "clock_chip.h"
/******************************************************************************/
/*
diff --git a/chip/npcx/sha256_chip.c b/chip/npcx/sha256_chip.c
index e2590cad65..4d90ba6e74 100644
--- a/chip/npcx/sha256_chip.c
+++ b/chip/npcx/sha256_chip.c
@@ -32,7 +32,7 @@ enum ncl_sha_type {
* The base address of the table that holds the function pointer for each
* SHA256 API in ROM.
*/
-#define NCL_SHA_BASE_ADDR 0x00000100UL
+#define NCL_SHA_BASE_ADDR 0x0000013CUL
struct ncl_sha {
/* Get the SHA context size required by SHA APIs. */
uint32_t (*get_context_size)(void);
diff --git a/chip/npcx/shi.c b/chip/npcx/shi.c
index d5f19c9191..dde2243462 100644
--- a/chip/npcx/shi.c
+++ b/chip/npcx/shi.c
@@ -15,12 +15,12 @@
#include "clock.h"
#include "console.h"
#include "gpio.h"
-#include "task.h"
#include "hooks.h"
#include "host_command.h"
#include "registers.h"
#include "spi.h"
#include "system.h"
+#include "task.h"
#include "timer.h"
#include "util.h"
diff --git a/chip/npcx/spi.c b/chip/npcx/spi.c
index 0161ce63ef..bbe6b33a9d 100644
--- a/chip/npcx/spi.c
+++ b/chip/npcx/spi.c
@@ -5,11 +5,11 @@
/* SPI module for Chrome EC */
+#include "clock.h"
+#include "clock_chip.h"
#include "console.h"
#include "gpio.h"
#include "hooks.h"
-#include "clock.h"
-#include "clock_chip.h"
#include "registers.h"
#include "spi.h"
#include "task.h"
diff --git a/chip/npcx/spiflashfw/npcx_monitor.c b/chip/npcx/spiflashfw/npcx_monitor.c
index 5b7a767992..0d8530a456 100644
--- a/chip/npcx/spiflashfw/npcx_monitor.c
+++ b/chip/npcx/spiflashfw/npcx_monitor.c
@@ -5,12 +5,13 @@
* NPCX SoC spi flash update tool - monitor firmware
*/
-#include <stdint.h>
#include "config.h"
#include "npcx_monitor.h"
#include "registers.h"
#include "util.h"
+#include <stdint.h>
+
/*****************************************************************************/
/* spi flash internal functions */
void sspi_flash_pinmux(int enable)
diff --git a/chip/npcx/system-npcx7.c b/chip/npcx/system-npcx7.c
index 5cacbec749..386544ed04 100644
--- a/chip/npcx/system-npcx7.c
+++ b/chip/npcx/system-npcx7.c
@@ -11,16 +11,16 @@
#include "console.h"
#include "cpu.h"
#include "ec_commands.h"
+#include "gpio.h"
#include "hooks.h"
+#include "hwtimer_chip.h"
#include "lct_chip.h"
#include "registers.h"
+#include "rom_chip.h"
#include "system.h"
+#include "system_chip.h"
#include "task.h"
#include "util.h"
-#include "gpio.h"
-#include "hwtimer_chip.h"
-#include "system_chip.h"
-#include "rom_chip.h"
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
diff --git a/chip/npcx/system-npcx9.c b/chip/npcx/system-npcx9.c
index 5cacbec749..386544ed04 100644
--- a/chip/npcx/system-npcx9.c
+++ b/chip/npcx/system-npcx9.c
@@ -11,16 +11,16 @@
#include "console.h"
#include "cpu.h"
#include "ec_commands.h"
+#include "gpio.h"
#include "hooks.h"
+#include "hwtimer_chip.h"
#include "lct_chip.h"
#include "registers.h"
+#include "rom_chip.h"
#include "system.h"
+#include "system_chip.h"
#include "task.h"
#include "util.h"
-#include "gpio.h"
-#include "hwtimer_chip.h"
-#include "system_chip.h"
-#include "rom_chip.h"
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
diff --git a/chip/npcx/uart.c b/chip/npcx/uart.c
index bc87b5921e..d77c3579c5 100644
--- a/chip/npcx/uart.c
+++ b/chip/npcx/uart.c
@@ -6,6 +6,7 @@
/* UART module for Chrome EC */
#include "clock.h"
+#include "clock_chip.h"
#include "common.h"
#include "console.h"
#include "gpio.h"
@@ -13,7 +14,6 @@
#include "hwtimer_chip.h"
#include "lpc.h"
#include "registers.h"
-#include "clock_chip.h"
#include "system.h"
#include "task.h"
#include "timer.h"
diff --git a/chip/npcx/uartn.c b/chip/npcx/uartn.c
index 9bcaccd94c..66cb30062b 100644
--- a/chip/npcx/uartn.c
+++ b/chip/npcx/uartn.c
@@ -6,15 +6,16 @@
/* UART module for Chrome EC */
-#include <clock.h>
#include "common.h"
-#include <gpio.h>
-#include <gpio_chip.h>
#include "registers.h"
#include "system.h"
#include "task.h"
#include "util.h"
+#include <clock.h>
+#include <gpio.h>
+#include <gpio_chip.h>
+
#ifdef NPCX_UART_FIFO_SUPPORT
/* Enable UART Tx FIFO empty interrupt */
#define NPCX_UART_TX_EMPTY_INT_EN(n) \
diff --git a/chip/npcx/watchdog.c b/chip/npcx/watchdog.c
index 8ae9ee0474..7998378565 100644
--- a/chip/npcx/watchdog.c
+++ b/chip/npcx/watchdog.c
@@ -8,14 +8,14 @@
#include "clock.h"
#include "common.h"
#include "console.h"
-#include "registers.h"
-#include "hwtimer_chip.h"
#include "gpio.h"
#include "hooks.h"
-#include "timer.h"
+#include "hwtimer_chip.h"
+#include "registers.h"
+#include "system_chip.h"
#include "task.h"
+#include "timer.h"
#include "util.h"
-#include "system_chip.h"
#include "watchdog.h"
/* WDCNT value for watchdog period */
diff --git a/chip/stm32/adc-stm32l.c b/chip/stm32/adc-stm32l.c
index 636710f071..06b16224f7 100644
--- a/chip/stm32/adc-stm32l.c
+++ b/chip/stm32/adc-stm32l.c
@@ -4,9 +4,9 @@
*/
#include "adc.h"
+#include "clock.h"
#include "common.h"
#include "console.h"
-#include "clock.h"
#include "dma.h"
#include "hooks.h"
#include "registers.h"
diff --git a/chip/stm32/bkpdata.c b/chip/stm32/bkpdata.c
index bde026facd..ef5729d118 100644
--- a/chip/stm32/bkpdata.c
+++ b/chip/stm32/bkpdata.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <assert.h>
-
#include "bkpdata.h"
#include "registers.h"
#include "system.h" /* enum system_bbram_idx */
#include "task.h"
+#include <assert.h>
+
uint16_t bkpdata_read(enum bkpdata_index index)
{
if (index < 0 || index >= STM32_BKP_ENTRIES)
diff --git a/chip/stm32/build.mk b/chip/stm32/build.mk
index 1fc14a15fa..72984eec5f 100644
--- a/chip/stm32/build.mk
+++ b/chip/stm32/build.mk
@@ -33,8 +33,6 @@ CORE:=cortex-m
CFLAGS_CPU+=-mcpu=cortex-m3
endif
-# Select between 16-bit and 32-bit timer for clock source
-TIMER_TYPE=$(if $(CONFIG_STM_HWTIMER32),32,)
DMA_TYPE=$(if $(CHIP_FAMILY_STM32F4)$(CHIP_FAMILY_STM32H7),-stm32f4,)
SPI_TYPE=$(if $(CHIP_FAMILY_STM32H7),-stm32h7,)
@@ -48,7 +46,7 @@ chip-$(CONFIG_FPU)+=fpu.o
chip-$(CONFIG_SPI)+=spi.o
chip-$(CONFIG_SPI_CONTROLLER)+=spi_controller$(SPI_TYPE).o
chip-$(CONFIG_COMMON_GPIO)+=gpio.o gpio-$(CHIP_FAMILY).o
-chip-$(CONFIG_COMMON_TIMER)+=hwtimer$(TIMER_TYPE).o
+chip-$(CONFIG_COMMON_TIMER)+=hwtimer32.o
chip-$(CONFIG_I2C)+=i2c-$(CHIP_FAMILY).o
chip-$(CONFIG_ITE_FLASH_SUPPORT)+=i2c_ite_flash_support.o
chip-$(CONFIG_STREAM_USART)+=usart.o usart-$(CHIP_FAMILY).o
diff --git a/chip/stm32/clock-f.c b/chip/stm32/clock-f.c
index d181397d86..0aad58ab00 100644
--- a/chip/stm32/clock-f.c
+++ b/chip/stm32/clock-f.c
@@ -7,8 +7,8 @@
#include "builtin/assert.h"
#include "chipset.h"
-#include "clock.h"
#include "clock-f.h"
+#include "clock.h"
#include "common.h"
#include "console.h"
#include "cpu.h"
diff --git a/chip/stm32/clock-stm32f0.c b/chip/stm32/clock-stm32f0.c
index 3b56382fdb..18c089b036 100644
--- a/chip/stm32/clock-stm32f0.c
+++ b/chip/stm32/clock-stm32f0.c
@@ -6,8 +6,8 @@
/* Clocks and power management settings */
#include "chipset.h"
-#include "clock.h"
#include "clock-f.h"
+#include "clock.h"
#include "common.h"
#include "console.h"
#include "cpu.h"
diff --git a/chip/stm32/clock-stm32f3.c b/chip/stm32/clock-stm32f3.c
index 7d2b3de7f2..5b17fe56eb 100644
--- a/chip/stm32/clock-stm32f3.c
+++ b/chip/stm32/clock-stm32f3.c
@@ -6,8 +6,8 @@
/* Clocks and power management settings */
#include "chipset.h"
-#include "clock.h"
#include "clock-f.h"
+#include "clock.h"
#include "common.h"
#include "console.h"
#include "cpu.h"
diff --git a/chip/stm32/clock-stm32f4.c b/chip/stm32/clock-stm32f4.c
index 479faac7da..15cf8a45e2 100644
--- a/chip/stm32/clock-stm32f4.c
+++ b/chip/stm32/clock-stm32f4.c
@@ -7,8 +7,8 @@
#include "builtin/assert.h"
#include "chipset.h"
-#include "clock.h"
#include "clock-f.h"
+#include "clock.h"
#include "common.h"
#include "console.h"
#include "cpu.h"
diff --git a/chip/stm32/clock-stm32g4.c b/chip/stm32/clock-stm32g4.c
index dbb8fd88cb..962fdc37f2 100644
--- a/chip/stm32/clock-stm32g4.c
+++ b/chip/stm32/clock-stm32g4.c
@@ -7,8 +7,8 @@
#include "builtin/assert.h"
#include "chipset.h"
-#include "clock.h"
#include "clock-f.h"
+#include "clock.h"
#include "common.h"
#include "console.h"
#include "cpu.h"
diff --git a/chip/stm32/clock-stm32h7.c b/chip/stm32/clock-stm32h7.c
index 67e17f4174..3e6ba679cb 100644
--- a/chip/stm32/clock-stm32h7.c
+++ b/chip/stm32/clock-stm32h7.c
@@ -13,8 +13,6 @@
* but at least yields predictable behavior.
*/
-#include <stdbool.h>
-
#include "builtin/assert.h"
#include "chipset.h"
#include "clock.h"
@@ -29,6 +27,8 @@
#include "uart.h"
#include "util.h"
+#include <stdbool.h>
+
/* Check chip family and variant for compatibility */
#ifndef CHIP_FAMILY_STM32H7
#error Source clock-stm32h7.c does not support this chip family.
diff --git a/chip/stm32/clock-stm32l4.c b/chip/stm32/clock-stm32l4.c
index 77e807c1ad..412771163c 100644
--- a/chip/stm32/clock-stm32l4.c
+++ b/chip/stm32/clock-stm32l4.c
@@ -7,8 +7,8 @@
#include "builtin/assert.h"
#include "chipset.h"
-#include "clock.h"
#include "clock-l4.h"
+#include "clock.h"
#include "common.h"
#include "console.h"
#include "cpu.h"
diff --git a/chip/stm32/config-stm32l15x.h b/chip/stm32/config-stm32l15x.h
index ae069ed005..d35b3ccbcf 100644
--- a/chip/stm32/config-stm32l15x.h
+++ b/chip/stm32/config-stm32l15x.h
@@ -24,8 +24,19 @@
#define CONFIG_RAM_BASE 0x20000000
#define CONFIG_RAM_SIZE 0x00004000
-/* Number of IRQ vectors on the NVIC */
-#define CONFIG_IRQ_COUNT 45
+/* Number of IRQ vectors on the NVIC
+ *
+ * Section 10.1 "Nested vectored interrupt controller (NVIC)" states:
+ * 45 maskable interrupt channels in Cat.1 and Cat.2 devices (see Table 49)
+ * 54 maskable interrupt channels in Cat.3 devices (see Table 50) and 57
+ * channels in Cat.4, Cat.5 and Cat.6 devices (see Table 51).
+ *
+ * The only STM32L15 that we support is the "discovery" board is a "Category
+ * 3" device. See Section 1.5 "Product Category definition".
+ *
+ * https://www.st.com/resource/en/reference_manual/cd00240193-stm32l100xx-stm32l151xx-stm32l152xx-and-stm32l162xx-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf
+ */
+#define CONFIG_IRQ_COUNT 54
/* Lots of RAM, so use bigger UART buffer */
#undef CONFIG_UART_TX_BUF_SIZE
diff --git a/chip/stm32/flash-f.c b/chip/stm32/flash-f.c
index 9bfdb1b6b7..2673201472 100644
--- a/chip/stm32/flash-f.c
+++ b/chip/stm32/flash-f.c
@@ -5,22 +5,23 @@
/* Common flash memory module for STM32F and STM32F0 */
-#include <stdbool.h>
#include "battery.h"
#include "builtin/assert.h"
-#include "console.h"
#include "clock.h"
-#include "flash.h"
+#include "console.h"
#include "flash-f.h"
+#include "flash.h"
#include "hooks.h"
-#include "registers.h"
#include "panic.h"
+#include "registers.h"
#include "system.h"
#include "task.h"
#include "timer.h"
#include "util.h"
#include "watchdog.h"
+#include <stdbool.h>
+
#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
diff --git a/chip/stm32/flash-stm32f3.c b/chip/stm32/flash-stm32f3.c
index 8705e4d657..c41f9c526d 100644
--- a/chip/stm32/flash-stm32f3.c
+++ b/chip/stm32/flash-stm32f3.c
@@ -5,15 +5,16 @@
/* Flash memory module for stm32f3 and stm32f4 */
-#include <stdbool.h>
#include "common.h"
-#include "flash.h"
#include "flash-f.h"
#include "flash-regs.h"
+#include "flash.h"
#include "hooks.h"
+#include "panic.h"
#include "registers.h"
#include "system.h"
-#include "panic.h"
+
+#include <stdbool.h>
/*****************************************************************************/
/* Physical layer APIs */
diff --git a/chip/stm32/flash-stm32f4.c b/chip/stm32/flash-stm32f4.c
index 8705e4d657..c41f9c526d 100644
--- a/chip/stm32/flash-stm32f4.c
+++ b/chip/stm32/flash-stm32f4.c
@@ -5,15 +5,16 @@
/* Flash memory module for stm32f3 and stm32f4 */
-#include <stdbool.h>
#include "common.h"
-#include "flash.h"
#include "flash-f.h"
#include "flash-regs.h"
+#include "flash.h"
#include "hooks.h"
+#include "panic.h"
#include "registers.h"
#include "system.h"
-#include "panic.h"
+
+#include <stdbool.h>
/*****************************************************************************/
/* Physical layer APIs */
diff --git a/chip/stm32/flash-stm32g4-l4.c b/chip/stm32/flash-stm32g4-l4.c
index 31dba5c887..ad08047c23 100644
--- a/chip/stm32/flash-stm32g4-l4.c
+++ b/chip/stm32/flash-stm32g4-l4.c
@@ -4,12 +4,12 @@
*/
/* Flash memory module for STM32L4 family */
-#include "common.h"
#include "clock.h"
+#include "common.h"
#include "flash.h"
#include "hooks.h"
-#include "registers.h"
#include "panic.h"
+#include "registers.h"
#include "system.h"
#include "task.h"
#include "timer.h"
diff --git a/chip/stm32/flash-stm32h7.c b/chip/stm32/flash-stm32h7.c
index 445b354e57..2b9b594938 100644
--- a/chip/stm32/flash-stm32h7.c
+++ b/chip/stm32/flash-stm32h7.c
@@ -4,14 +4,14 @@
*/
/* Flash memory module for STM32H7 family */
-#include "common.h"
#include "clock.h"
+#include "common.h"
#include "cpu.h"
-#include "flash.h"
#include "flash-regs.h"
+#include "flash.h"
#include "hooks.h"
-#include "registers.h"
#include "panic.h"
+#include "registers.h"
#include "system.h"
#include "task.h"
#include "timer.h"
diff --git a/chip/stm32/hwtimer.c b/chip/stm32/hwtimer.c
deleted file mode 100644
index 3521347f3f..0000000000
--- a/chip/stm32/hwtimer.c
+++ /dev/null
@@ -1,481 +0,0 @@
-/* Copyright 2012 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Hardware timers driver */
-
-#include "builtin/assert.h"
-#include "clock.h"
-#include "clock-f.h"
-#include "common.h"
-#include "hooks.h"
-#include "hwtimer.h"
-#include "panic.h"
-#include "registers.h"
-#include "task.h"
-#include "timer.h"
-#include "watchdog.h"
-
-/*
- * Trigger select mapping for secondary timer from primary timer. This is
- * unfortunately not very straightforward; there's no tidy way to do this
- * algorithmically. To avoid burning memory for a lookup table, use macros to
- * compute the offset. This also has the benefit that compilation will fail if
- * an unsupported primary/secondary pairing is used.
- */
-#ifdef CHIP_FAMILY_STM32F0
-/*
- * Secondary Primary
- * 1 15 2 3 17
- * 2 1 15 3 14
- * 3 1 2 15 14
- * 15 2 3 16 17
- * --------------------
- * ts = 0 1 2 3
- */
-#define STM32_TIM_TS_SECONDARY_1_PRIMARY_15 0
-#define STM32_TIM_TS_SECONDARY_1_PRIMARY_2 1
-#define STM32_TIM_TS_SECONDARY_1_PRIMARY_3 2
-#define STM32_TIM_TS_SECONDARY_1_PRIMARY_17 3
-#define STM32_TIM_TS_SECONDARY_2_PRIMARY_1 0
-#define STM32_TIM_TS_SECONDARY_2_PRIMARY_15 1
-#define STM32_TIM_TS_SECONDARY_2_PRIMARY_3 2
-#define STM32_TIM_TS_SECONDARY_2_PRIMARY_14 3
-#define STM32_TIM_TS_SECONDARY_3_PRIMARY_1 0
-#define STM32_TIM_TS_SECONDARY_3_PRIMARY_2 1
-#define STM32_TIM_TS_SECONDARY_3_PRIMARY_15 2
-#define STM32_TIM_TS_SECONDARY_3_PRIMARY_14 3
-#define STM32_TIM_TS_SECONDARY_15_PRIMARY_2 0
-#define STM32_TIM_TS_SECONDARY_15_PRIMARY_3 1
-#define STM32_TIM_TS_SECONDARY_15_PRIMARY_16 2
-#define STM32_TIM_TS_SECONDARY_15_PRIMARY_17 3
-#elif defined(CHIP_FAMILY_STM32F3)
-/*
- * Secondary Primary
- * 2 19 15 3 14
- * 3 19 2 5 14
- * 4 19 2 3 15
- * 5 2 3 4 15
- * 12 4 5 13 14
- * 19 2 3 15 16
- * ---------------------
- * ts = 0 1 2 3
- */
-#define STM32_TIM_TS_SECONDARY_2_PRIMARY_19 0
-#define STM32_TIM_TS_SECONDARY_2_PRIMARY_15 1
-#define STM32_TIM_TS_SECONDARY_2_PRIMARY_3 2
-#define STM32_TIM_TS_SECONDARY_2_PRIMARY_14 3
-#define STM32_TIM_TS_SECONDARY_3_PRIMARY_19 0
-#define STM32_TIM_TS_SECONDARY_3_PRIMARY_2 1
-#define STM32_TIM_TS_SECONDARY_3_PRIMARY_5 2
-#define STM32_TIM_TS_SECONDARY_3_PRIMARY_14 3
-#define STM32_TIM_TS_SECONDARY_4_PRIMARY_19 0
-#define STM32_TIM_TS_SECONDARY_4_PRIMARY_2 1
-#define STM32_TIM_TS_SECONDARY_4_PRIMARY_3 2
-#define STM32_TIM_TS_SECONDARY_4_PRIMARY_15 3
-#define STM32_TIM_TS_SECONDARY_5_PRIMARY_2 0
-#define STM32_TIM_TS_SECONDARY_5_PRIMARY_3 1
-#define STM32_TIM_TS_SECONDARY_5_PRIMARY_4 2
-#define STM32_TIM_TS_SECONDARY_5_PRIMARY_15 3
-#define STM32_TIM_TS_SECONDARY_12_PRIMARY_4 0
-#define STM32_TIM_TS_SECONDARY_12_PRIMARY_5 1
-#define STM32_TIM_TS_SECONDARY_12_PRIMARY_13 2
-#define STM32_TIM_TS_SECONDARY_12_PRIMARY_14 3
-#define STM32_TIM_TS_SECONDARY_19_PRIMARY_2 0
-#define STM32_TIM_TS_SECONDARY_19_PRIMARY_3 1
-#define STM32_TIM_TS_SECONDARY_19_PRIMARY_15 2
-#define STM32_TIM_TS_SECONDARY_19_PRIMARY_16 3
-#else /* !CHIP_FAMILY_STM32F0 && !CHIP_FAMILY_STM32F3 */
-/*
- * Secondary Primary
- * 1 15 2 3 4 (STM32F100 only)
- * 2 9 10 3 4
- * 3 9 2 11 4
- * 4 10 2 3 9
- * 9 2 3 10 11 (STM32L15x only)
- * --------------------
- * ts = 0 1 2 3
- */
-#define STM32_TIM_TS_SECONDARY_1_PRIMARY_15 0
-#define STM32_TIM_TS_SECONDARY_1_PRIMARY_2 1
-#define STM32_TIM_TS_SECONDARY_1_PRIMARY_3 2
-#define STM32_TIM_TS_SECONDARY_1_PRIMARY_4 3
-#define STM32_TIM_TS_SECONDARY_2_PRIMARY_9 0
-#define STM32_TIM_TS_SECONDARY_2_PRIMARY_10 1
-#define STM32_TIM_TS_SECONDARY_2_PRIMARY_3 2
-#define STM32_TIM_TS_SECONDARY_2_PRIMARY_4 3
-#define STM32_TIM_TS_SECONDARY_3_PRIMARY_9 0
-#define STM32_TIM_TS_SECONDARY_3_PRIMARY_2 1
-#define STM32_TIM_TS_SECONDARY_3_PRIMARY_11 2
-#define STM32_TIM_TS_SECONDARY_3_PRIMARY_4 3
-#define STM32_TIM_TS_SECONDARY_4_PRIMARY_10 0
-#define STM32_TIM_TS_SECONDARY_4_PRIMARY_2 1
-#define STM32_TIM_TS_SECONDARY_4_PRIMARY_3 2
-#define STM32_TIM_TS_SECONDARY_4_PRIMARY_9 3
-#define STM32_TIM_TS_SECONDARY_9_PRIMARY_2 0
-#define STM32_TIM_TS_SECONDARY_9_PRIMARY_3 1
-#define STM32_TIM_TS_SECONDARY_9_PRIMARY_10 2
-#define STM32_TIM_TS_SECONDARY_9_PRIMARY_11 3
-#endif /* !CHIP_FAMILY_STM32F0 */
-#define TSMAP(secondary, primary) \
- CONCAT4(STM32_TIM_TS_SECONDARY_, secondary, _PRIMARY_, primary)
-
-/*
- * Timers are defined per board. This gives us flexibility to work around
- * timers which are dedicated to board-specific PWM sources.
- */
-#define IRQ_MSB IRQ_TIM(TIM_CLOCK_MSB)
-#define IRQ_LSB IRQ_TIM(TIM_CLOCK_LSB)
-#define IRQ_WD IRQ_TIM(TIM_WATCHDOG)
-
-/* TIM1 has fancy names for its IRQs; remap count-up IRQ for the macro above */
-#if defined TIM_WATCHDOG && (TIM_WATCHDOG == 1)
-#define STM32_IRQ_TIM1 STM32_IRQ_TIM1_BRK_UP_TRG
-#else /* !(TIM_WATCHDOG == 1) */
-#define STM32_IRQ_TIM1 STM32_IRQ_TIM1_CC
-#endif /* !(TIM_WATCHDOG == 1) */
-
-#define TIM_BASE(n) CONCAT3(STM32_TIM, n, _BASE)
-#define TIM_WD_BASE TIM_BASE(TIM_WATCHDOG)
-
-static uint32_t last_deadline;
-
-void __hw_clock_event_set(uint32_t deadline)
-{
- last_deadline = deadline;
-
- if ((deadline >> 16) > STM32_TIM_CNT(TIM_CLOCK_MSB)) {
- /* first set a match on the MSB */
- STM32_TIM_CCR1(TIM_CLOCK_MSB) = deadline >> 16;
- /* disable LSB match */
- STM32_TIM_DIER(TIM_CLOCK_LSB) &= ~2;
- /* Clear the match flags */
- STM32_TIM_SR(TIM_CLOCK_MSB) = ~2;
- STM32_TIM_SR(TIM_CLOCK_LSB) = ~2;
- /* Set the match interrupt */
- STM32_TIM_DIER(TIM_CLOCK_MSB) |= 2;
- }
- /*
- * In the unlikely case where the MSB has increased and matched
- * the deadline MSB before we set the match interrupt, as the STM
- * hardware timer won't trigger an interrupt, we fall back to the
- * following LSB event code to set another interrupt.
- */
- if ((deadline >> 16) == STM32_TIM_CNT(TIM_CLOCK_MSB)) {
- /* we can set a match on the LSB only */
- STM32_TIM_CCR1(TIM_CLOCK_LSB) = deadline & 0xffff;
- /* disable MSB match */
- STM32_TIM_DIER(TIM_CLOCK_MSB) &= ~2;
- /* Clear the match flags */
- STM32_TIM_SR(TIM_CLOCK_MSB) = ~2;
- STM32_TIM_SR(TIM_CLOCK_LSB) = ~2;
- /* Set the match interrupt */
- STM32_TIM_DIER(TIM_CLOCK_LSB) |= 2;
- }
- /*
- * If the LSB deadline is already in the past and won't trigger an
- * interrupt, the common code in process_timers will deal with the
- * expired timer and automatically set the next deadline, we don't need
- * to do anything here.
- */
-}
-
-uint32_t __hw_clock_event_get(void)
-{
- return last_deadline;
-}
-
-void __hw_clock_event_clear(void)
-{
- /* Disable the match interrupts */
- STM32_TIM_DIER(TIM_CLOCK_LSB) &= ~2;
- STM32_TIM_DIER(TIM_CLOCK_MSB) &= ~2;
-}
-
-uint32_t __hw_clock_source_read(void)
-{
- uint32_t hi;
- uint32_t lo;
-
- /* Ensure the two half-words are coherent */
- do {
- hi = STM32_TIM_CNT(TIM_CLOCK_MSB);
- lo = STM32_TIM_CNT(TIM_CLOCK_LSB);
- } while (hi != STM32_TIM_CNT(TIM_CLOCK_MSB));
-
- return (hi << 16) | lo;
-}
-
-void __hw_clock_source_set(uint32_t ts)
-{
- ASSERT(!is_interrupt_enabled());
-
- /* Stop counting (LSB first, then MSB) */
- STM32_TIM_CR1(TIM_CLOCK_LSB) &= ~1;
- STM32_TIM_CR1(TIM_CLOCK_MSB) &= ~1;
-
- /* Set new value to counters */
- STM32_TIM_CNT(TIM_CLOCK_MSB) = ts >> 16;
- STM32_TIM_CNT(TIM_CLOCK_LSB) = ts & 0xffff;
-
- /*
- * Clear status. We may clear information other than timer overflow
- * (eg. event timestamp was matched) but:
- * - Bits other than overflow are unused (see __hw_clock_source_irq())
- * - After setting timestamp software will trigger timer interrupt using
- * task_trigger_irq() (see force_time() in common/timer.c).
- * process_timers() is called from timer interrupt, so if "match" bit
- * was present in status (think: some task timers are expired)
- * process_timers() will handle that correctly.
- */
- STM32_TIM_SR(TIM_CLOCK_MSB) = 0;
- STM32_TIM_SR(TIM_CLOCK_LSB) = 0;
-
- /* Start counting (MSB first, then LSB) */
- STM32_TIM_CR1(TIM_CLOCK_MSB) |= 1;
- STM32_TIM_CR1(TIM_CLOCK_LSB) |= 1;
-}
-
-static void __hw_clock_source_irq(void)
-{
- uint32_t stat_tim_msb = STM32_TIM_SR(TIM_CLOCK_MSB);
-
- /* Clear status */
- STM32_TIM_SR(TIM_CLOCK_LSB) = 0;
- STM32_TIM_SR(TIM_CLOCK_MSB) = 0;
-
- /*
- * Find expired timers and set the new timer deadline
- * signal overflow if the 16-bit MSB counter has overflowed.
- */
- process_timers(stat_tim_msb & 0x01);
-}
-DECLARE_IRQ(IRQ_MSB, __hw_clock_source_irq, 1);
-DECLARE_IRQ(IRQ_LSB, __hw_clock_source_irq, 1);
-
-void __hw_timer_enable_clock(int n, int enable)
-{
- volatile uint32_t *reg;
- uint32_t mask = 0;
-
- /*
- * Mapping of timers to reg/mask is split into a few different ranges,
- * some specific to individual chips.
- */
-#if defined(CHIP_FAMILY_STM32F0)
- if (n == 1) {
- reg = &STM32_RCC_APB2ENR;
- mask = STM32_RCC_PB2_TIM1;
- }
-#elif defined(CHIP_FAMILY_STM32L) || defined(CHIP_FAMILY_STM32F4)
- if (n >= 9 && n <= 11) {
- reg = &STM32_RCC_APB2ENR;
- mask = STM32_RCC_PB2_TIM9 << (n - 9);
- }
-#endif
-
-#if defined(CHIP_FAMILY_STM32F0)
- if (n >= 15 && n <= 17) {
- reg = &STM32_RCC_APB2ENR;
- mask = STM32_RCC_PB2_TIM15 << (n - 15);
- }
-#endif
-
-#if defined(CHIP_FAMILY_STM32F0) || defined(CHIP_FAMILY_STM32F3)
- if (n == 14) {
- reg = &STM32_RCC_APB1ENR;
- mask = STM32_RCC_PB1_TIM14;
- }
-#endif
-
-#if defined(CHIP_FAMILY_STM32F3)
- if (n == 12 || n == 13) {
- reg = &STM32_RCC_APB1ENR;
- mask = STM32_RCC_PB1_TIM12 << (n - 12);
- }
- if (n == 18) {
- reg = &STM32_RCC_APB1ENR;
- mask = STM32_RCC_PB1_TIM18;
- }
- if (n == 19) {
- reg = &STM32_RCC_APB2ENR;
- mask = STM32_RCC_PB2_TIM19;
- }
-#endif
-
- if (n >= 2 && n <= 7) {
- reg = &STM32_RCC_APB1ENR;
- mask = STM32_RCC_PB1_TIM2 << (n - 2);
- }
-
- if (!mask)
- return;
-
- if (enable)
- *reg |= mask;
- else
- *reg &= ~mask;
-}
-
-static void update_prescaler(void)
-{
- /*
- * Pre-scaler value :
- * TIM_CLOCK_LSB is counting microseconds;
- * TIM_CLOCK_MSB is counting every TIM_CLOCK_LSB overflow.
- *
- * This will take effect at the next update event (when the current
- * prescaler counter ticks down, or if forced via EGR).
- */
- STM32_TIM_PSC(TIM_CLOCK_MSB) = 0;
- STM32_TIM_PSC(TIM_CLOCK_LSB) = (clock_get_timer_freq() / SECOND) - 1;
-}
-DECLARE_HOOK(HOOK_FREQ_CHANGE, update_prescaler, HOOK_PRIO_DEFAULT);
-
-int __hw_clock_source_init(uint32_t start_t)
-{
- /*
- * we use 2 chained 16-bit counters to emulate a 32-bit one :
- * TIM_CLOCK_MSB is the MSB (Secondary)
- * TIM_CLOCK_LSB is the LSB (Primary)
- */
-
- /* Enable TIM_CLOCK_MSB and TIM_CLOCK_LSB clocks */
- __hw_timer_enable_clock(TIM_CLOCK_MSB, 1);
- __hw_timer_enable_clock(TIM_CLOCK_LSB, 1);
-
- /* Delay 1 APB clock cycle after the clock is enabled */
- clock_wait_bus_cycles(BUS_APB, 1);
-
- /*
- * Timer configuration : Upcounter, counter disabled, update event only
- * on overflow.
- */
- STM32_TIM_CR1(TIM_CLOCK_MSB) = 0x0004;
- STM32_TIM_CR1(TIM_CLOCK_LSB) = 0x0004;
- /*
- * TIM_CLOCK_LSB (primary mode) generates a periodic trigger signal on
- * each UEV
- */
- STM32_TIM_CR2(TIM_CLOCK_MSB) = 0x0000;
- STM32_TIM_CR2(TIM_CLOCK_LSB) = 0x0020;
-
- STM32_TIM_SMCR(TIM_CLOCK_MSB) =
- 0x0007 | (TSMAP(TIM_CLOCK_MSB, TIM_CLOCK_LSB) << 4);
- STM32_TIM_SMCR(TIM_CLOCK_LSB) = 0x0000;
-
- /* Auto-reload value : 16-bit free-running counters */
- STM32_TIM_ARR(TIM_CLOCK_MSB) = 0xffff;
- STM32_TIM_ARR(TIM_CLOCK_LSB) = 0xffff;
-
- /* Update prescaler */
- update_prescaler();
-
- /* Reload the pre-scaler */
- STM32_TIM_EGR(TIM_CLOCK_MSB) = 0x0001;
- STM32_TIM_EGR(TIM_CLOCK_LSB) = 0x0001;
-
- /* Set up the overflow interrupt on TIM_CLOCK_MSB */
- STM32_TIM_DIER(TIM_CLOCK_MSB) = 0x0001;
- STM32_TIM_DIER(TIM_CLOCK_LSB) = 0x0000;
-
- /* Override the count with the start value */
- STM32_TIM_CNT(TIM_CLOCK_MSB) = start_t >> 16;
- STM32_TIM_CNT(TIM_CLOCK_LSB) = start_t & 0xffff;
-
- /* Start counting */
- STM32_TIM_CR1(TIM_CLOCK_MSB) |= 1;
- STM32_TIM_CR1(TIM_CLOCK_LSB) |= 1;
-
- /* Enable timer interrupts */
- task_enable_irq(IRQ_MSB);
- task_enable_irq(IRQ_LSB);
-
- return IRQ_LSB;
-}
-
-#ifdef CONFIG_WATCHDOG_HELP
-
-void __keep watchdog_check(uint32_t excep_lr, uint32_t excep_sp)
-{
- struct timer_ctlr *timer = (struct timer_ctlr *)TIM_WD_BASE;
-
- /* clear status */
- timer->sr = 0;
-
- watchdog_trace(excep_lr, excep_sp);
-}
-
-void IRQ_HANDLER(IRQ_WD)(void) __attribute__((naked));
-void IRQ_HANDLER(IRQ_WD)(void)
-{
- /* Naked call so we can extract raw LR and SP */
- asm volatile("mov r0, lr\n"
- "mov r1, sp\n"
- /* Must push registers in pairs to keep 64-bit aligned
- * stack for ARM EABI. */
- "push {r0, lr}\n"
- "bl watchdog_check\n"
- "pop {r0,pc}\n");
-}
-const struct irq_priority __keep IRQ_PRIORITY(IRQ_WD)
- __attribute__((section(".rodata.irqprio"))) = {
- IRQ_WD, 0
- }; /* put the watchdog
- at the highest
- priority
- */
-
-void hwtimer_setup_watchdog(void)
-{
- struct timer_ctlr *timer = (struct timer_ctlr *)TIM_WD_BASE;
-
- /* Enable clock */
- __hw_timer_enable_clock(TIM_WATCHDOG, 1);
-
- /* Delay 1 APB clock cycle after the clock is enabled */
- clock_wait_bus_cycles(BUS_APB, 1);
-
- /*
- * Timer configuration : Down counter, counter disabled, update
- * event only on overflow.
- */
- timer->cr1 = 0x0014 | BIT(7);
-
- /* TIM (secondary mode) uses TIM_CLOCK_LSB as internal trigger */
- timer->smcr = 0x0007 | (TSMAP(TIM_WATCHDOG, TIM_CLOCK_LSB) << 4);
-
- /*
- * The auto-reload value is based on the period between rollovers for
- * TIM_CLOCK_LSB. Since TIM_CLOCK_LSB runs at 1MHz, it will overflow
- * in 65.536ms. We divide our required watchdog period by this amount
- * to obtain the number of times TIM_CLOCK_LSB can overflow before we
- * generate an interrupt.
- */
- timer->arr = timer->cnt = CONFIG_AUX_TIMER_PERIOD_MS * MSEC / BIT(16);
-
- /* count on every TIM_CLOCK_LSB overflow */
- timer->psc = 0;
-
- /* Reload the pre-scaler from arr when it goes below zero */
- timer->egr = 0x0000;
-
- /* setup the overflow interrupt */
- timer->dier = 0x0001;
-
- /* Start counting */
- timer->cr1 |= 1;
-
- /* Enable timer interrupts */
- task_enable_irq(IRQ_WD);
-}
-
-void hwtimer_reset_watchdog(void)
-{
- struct timer_ctlr *timer = (struct timer_ctlr *)TIM_WD_BASE;
-
- timer->cnt = timer->arr;
-}
-
-#endif /* defined(CONFIG_WATCHDOG_HELP) */
diff --git a/chip/stm32/hwtimer32.c b/chip/stm32/hwtimer32.c
index 0448d34e4b..ebe46d8316 100644
--- a/chip/stm32/hwtimer32.c
+++ b/chip/stm32/hwtimer32.c
@@ -6,8 +6,8 @@
/* Hardware 32-bit timer driver */
#include "builtin/assert.h"
-#include "clock.h"
#include "clock-f.h"
+#include "clock.h"
#include "common.h"
#include "hooks.h"
#include "hwtimer.h"
diff --git a/chip/stm32/i2c-stm32l4.c b/chip/stm32/i2c-stm32l4.c
index eeb87ec4e0..bb24a8a50f 100644
--- a/chip/stm32/i2c-stm32l4.c
+++ b/chip/stm32/i2c-stm32l4.c
@@ -4,7 +4,6 @@
*/
#include "builtin/assert.h"
-#include "printf.h"
#include "chipset.h"
#include "clock.h"
#include "common.h"
@@ -13,8 +12,8 @@
#include "hooks.h"
#include "hwtimer.h"
#include "i2c.h"
+#include "printf.h"
#include "registers.h"
-
#include "system.h"
#include "task.h"
#include "timer.h"
diff --git a/chip/stm32/i2c_ite_flash_support.c b/chip/stm32/i2c_ite_flash_support.c
index 8482065086..335064572b 100644
--- a/chip/stm32/i2c_ite_flash_support.c
+++ b/chip/stm32/i2c_ite_flash_support.c
@@ -4,8 +4,8 @@
*/
/* STM implementation for flashing ITE-based ECs over i2c */
-#include "i2c_ite_flash_support.h"
#include "i2c.h"
+#include "i2c_ite_flash_support.h"
#include "registers.h"
#include "time.h"
diff --git a/chip/stm32/pwm.c b/chip/stm32/pwm.c
index 0f2e50c999..a9f266cbe0 100644
--- a/chip/stm32/pwm.c
+++ b/chip/stm32/pwm.c
@@ -6,8 +6,8 @@
/* PWM control module for STM32 */
#include "builtin/assert.h"
-#include "clock.h"
#include "clock-f.h"
+#include "clock.h"
#include "gpio.h"
#include "hooks.h"
#include "hwtimer.h"
diff --git a/chip/stm32/uart.c b/chip/stm32/uart.c
index 1bb961a935..916cb2257a 100644
--- a/chip/stm32/uart.c
+++ b/chip/stm32/uart.c
@@ -5,17 +5,17 @@
/* USART driver for Chrome EC */
-#include "common.h"
#include "clock.h"
+#include "common.h"
#include "dma.h"
#include "gpio.h"
#include "hooks.h"
#include "registers.h"
+#include "stm32-dma.h"
#include "system.h"
#include "task.h"
#include "uart.h"
#include "util.h"
-#include "stm32-dma.h"
/* Console USART index */
#define UARTN CONFIG_UART_CONSOLE
diff --git a/chip/stm32/ucpd-stm32gx.c b/chip/stm32/ucpd-stm32gx.c
index 3fec860200..424792c5d0 100644
--- a/chip/stm32/ucpd-stm32gx.c
+++ b/chip/stm32/ucpd-stm32gx.c
@@ -6,8 +6,8 @@
/* STM32GX UCPD module for Chrome EC */
#include "clock.h"
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "driver/tcpm/tcpm.h"
#include "gpio.h"
#include "hooks.h"
diff --git a/chip/stm32/usart-stm32f0.c b/chip/stm32/usart-stm32f0.c
index 56325cdc74..debb062473 100644
--- a/chip/stm32/usart-stm32f0.c
+++ b/chip/stm32/usart-stm32f0.c
@@ -2,14 +2,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "usart-stm32f0.h"
-
#include "clock.h"
#include "common.h"
#include "compile_time_macros.h"
#include "hooks.h"
#include "registers.h"
#include "task.h"
+#include "usart-stm32f0.h"
#include "util.h"
/*
diff --git a/chip/stm32/usart-stm32f3.c b/chip/stm32/usart-stm32f3.c
index f5a138643c..b46ac2ed8f 100644
--- a/chip/stm32/usart-stm32f3.c
+++ b/chip/stm32/usart-stm32f3.c
@@ -2,13 +2,12 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "usart-stm32f3.h"
-
#include "common.h"
#include "compile_time_macros.h"
#include "hooks.h"
#include "registers.h"
#include "task.h"
+#include "usart-stm32f3.h"
#include "util.h"
/*
diff --git a/chip/stm32/usart-stm32f4.c b/chip/stm32/usart-stm32f4.c
index a710760e3a..0806cab062 100644
--- a/chip/stm32/usart-stm32f4.c
+++ b/chip/stm32/usart-stm32f4.c
@@ -3,14 +3,13 @@
* found in the LICENSE file.
*/
-#include "usart-stm32f4.h"
-
#include "clock.h"
#include "common.h"
#include "compile_time_macros.h"
#include "hooks.h"
#include "registers.h"
#include "task.h"
+#include "usart-stm32f4.h"
#include "util.h"
/*
diff --git a/chip/stm32/usart-stm32l.c b/chip/stm32/usart-stm32l.c
index dc300d598a..b6c9e21595 100644
--- a/chip/stm32/usart-stm32l.c
+++ b/chip/stm32/usart-stm32l.c
@@ -2,14 +2,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "usart-stm32l.h"
-
#include "clock.h"
#include "common.h"
#include "compile_time_macros.h"
#include "hooks.h"
#include "registers.h"
#include "task.h"
+#include "usart-stm32l.h"
#include "util.h"
/*
diff --git a/chip/stm32/usart-stm32l5.c b/chip/stm32/usart-stm32l5.c
index 30e0f009ff..5f34c37bc4 100644
--- a/chip/stm32/usart-stm32l5.c
+++ b/chip/stm32/usart-stm32l5.c
@@ -2,14 +2,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "usart-stm32l.h"
-
#include "clock.h"
#include "common.h"
#include "compile_time_macros.h"
#include "hooks.h"
#include "registers.h"
#include "task.h"
+#include "usart-stm32l.h"
#include "util.h"
/*
diff --git a/chip/stm32/usart_host_command.c b/chip/stm32/usart_host_command.c
index 437975e609..817343df98 100644
--- a/chip/stm32/usart_host_command.c
+++ b/chip/stm32/usart_host_command.c
@@ -3,8 +3,8 @@
* found in the LICENSE file.
*/
-#include "common.h"
#include "clock.h"
+#include "common.h"
#include "dma.h"
#include "gpio.h"
#include "hooks.h"
@@ -13,9 +13,9 @@
#include "registers.h"
#include "system.h"
#include "task.h"
-#include "usart_rx_dma.h"
-#include "usart_host_command.h"
#include "usart-stm32f4.h"
+#include "usart_host_command.h"
+#include "usart_rx_dma.h"
#include "util.h"
/* Console output macros */
diff --git a/chip/stm32/usart_host_command.h b/chip/stm32/usart_host_command.h
index ee4bdd88dc..ddbd5c5c99 100644
--- a/chip/stm32/usart_host_command.h
+++ b/chip/stm32/usart_host_command.h
@@ -6,12 +6,13 @@
#ifndef __CROS_EC_USART_HOST_COMMAND_H
#define __CROS_EC_USART_HOST_COMMAND_H
-#include <stdarg.h> /* For va_list */
#include "common.h"
#include "gpio.h"
#include "host_command.h"
#include "usart.h"
+#include <stdarg.h> /* For va_list */
+
/*
* Add data to host command layer buffer.
*/
diff --git a/chip/stm32/usart_rx_dma.c b/chip/stm32/usart_rx_dma.c
index 21c8313c73..8997617ff3 100644
--- a/chip/stm32/usart_rx_dma.c
+++ b/chip/stm32/usart_rx_dma.c
@@ -3,14 +3,13 @@
* found in the LICENSE file.
*/
-#include "usart_rx_dma.h"
-
#include "atomic.h"
#include "common.h"
#include "console.h"
#include "registers.h"
#include "system.h"
#include "usart_host_command.h"
+#include "usart_rx_dma.h"
#include "util.h"
typedef size_t (*add_data_t)(struct usart_config const *config,
diff --git a/chip/stm32/usart_rx_dma.h b/chip/stm32/usart_rx_dma.h
index 6d273d18b9..191ccc8c7f 100644
--- a/chip/stm32/usart_rx_dma.h
+++ b/chip/stm32/usart_rx_dma.h
@@ -7,8 +7,8 @@
#ifndef __CROS_EC_USART_RX_DMA_H
#define __CROS_EC_USART_RX_DMA_H
-#include "producer.h"
#include "dma.h"
+#include "producer.h"
#include "queue.h"
#include "usart.h"
diff --git a/chip/stm32/usart_rx_interrupt-stm32f0.c b/chip/stm32/usart_rx_interrupt-stm32f0.c
index dfbe6ec3ff..a142bcd436 100644
--- a/chip/stm32/usart_rx_interrupt-stm32f0.c
+++ b/chip/stm32/usart_rx_interrupt-stm32f0.c
@@ -5,12 +5,11 @@
/* Interrupt based USART RX driver for STM32F0 and STM32F3 */
-#include "usart.h"
-
#include "atomic.h"
#include "common.h"
#include "queue.h"
#include "registers.h"
+#include "usart.h"
static void usart_rx_init(struct usart_config const *config)
{
diff --git a/chip/stm32/usart_rx_interrupt-stm32f3.c b/chip/stm32/usart_rx_interrupt-stm32f3.c
index dfbe6ec3ff..a142bcd436 100644
--- a/chip/stm32/usart_rx_interrupt-stm32f3.c
+++ b/chip/stm32/usart_rx_interrupt-stm32f3.c
@@ -5,12 +5,11 @@
/* Interrupt based USART RX driver for STM32F0 and STM32F3 */
-#include "usart.h"
-
#include "atomic.h"
#include "common.h"
#include "queue.h"
#include "registers.h"
+#include "usart.h"
static void usart_rx_init(struct usart_config const *config)
{
diff --git a/chip/stm32/usart_rx_interrupt-stm32f4.c b/chip/stm32/usart_rx_interrupt-stm32f4.c
index 1d86c7d5b6..80ba37e88f 100644
--- a/chip/stm32/usart_rx_interrupt-stm32f4.c
+++ b/chip/stm32/usart_rx_interrupt-stm32f4.c
@@ -5,12 +5,11 @@
/* Interrupt based USART RX driver for STM32F0 and STM32F4 */
-#include "usart.h"
-
#include "atomic.h"
#include "common.h"
#include "queue.h"
#include "registers.h"
+#include "usart.h"
static void usart_rx_init(struct usart_config const *config)
{
diff --git a/chip/stm32/usart_rx_interrupt-stm32l.c b/chip/stm32/usart_rx_interrupt-stm32l.c
index 750809307b..2c74d7dbd1 100644
--- a/chip/stm32/usart_rx_interrupt-stm32l.c
+++ b/chip/stm32/usart_rx_interrupt-stm32l.c
@@ -5,12 +5,11 @@
/* Interrupt based USART RX driver for STM32L */
-#include "usart.h"
-
#include "atomic.h"
#include "common.h"
#include "queue.h"
#include "registers.h"
+#include "usart.h"
static void usart_rx_init(struct usart_config const *config)
{
diff --git a/chip/stm32/usart_rx_interrupt.c b/chip/stm32/usart_rx_interrupt.c
index dfbe6ec3ff..a142bcd436 100644
--- a/chip/stm32/usart_rx_interrupt.c
+++ b/chip/stm32/usart_rx_interrupt.c
@@ -5,12 +5,11 @@
/* Interrupt based USART RX driver for STM32F0 and STM32F3 */
-#include "usart.h"
-
#include "atomic.h"
#include "common.h"
#include "queue.h"
#include "registers.h"
+#include "usart.h"
static void usart_rx_init(struct usart_config const *config)
{
diff --git a/chip/stm32/usart_tx_dma.c b/chip/stm32/usart_tx_dma.c
index 8128231ff7..d6469aa9e6 100644
--- a/chip/stm32/usart_tx_dma.c
+++ b/chip/stm32/usart_tx_dma.c
@@ -2,13 +2,12 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "usart_tx_dma.h"
-
-#include "usart.h"
#include "common.h"
#include "registers.h"
#include "system.h"
#include "task.h"
+#include "usart.h"
+#include "usart_tx_dma.h"
#include "util.h"
void usart_tx_dma_written(struct consumer const *consumer, size_t count)
diff --git a/chip/stm32/usart_tx_interrupt.c b/chip/stm32/usart_tx_interrupt.c
index 80d1d4df0f..7c99840e26 100644
--- a/chip/stm32/usart_tx_interrupt.c
+++ b/chip/stm32/usart_tx_interrupt.c
@@ -5,12 +5,11 @@
/* Interrupt based USART TX driver for STM32 */
-#include "usart.h"
-
#include "common.h"
#include "registers.h"
#include "system.h"
#include "task.h"
+#include "usart.h"
#include "usart_host_command.h"
#include "util.h"
diff --git a/chip/stm32/usb-stm32f3.c b/chip/stm32/usb-stm32f3.c
index eb48129e09..bef15db566 100644
--- a/chip/stm32/usb-stm32f3.c
+++ b/chip/stm32/usb-stm32f3.c
@@ -5,9 +5,8 @@
* STM32F3 Family specific USB functionality
*/
-#include "usb-stm32f3.h"
-
#include "system.h"
+#include "usb-stm32f3.h"
#include "usb_api.h"
void usb_connect(void)
diff --git a/chip/stm32/usb-stream.c b/chip/stm32/usb-stream.c
index 76f7fbd340..f9cd2687bf 100644
--- a/chip/stm32/usb-stream.c
+++ b/chip/stm32/usb-stream.c
@@ -11,10 +11,10 @@
#include "registers.h"
#include "task.h"
#include "timer.h"
-#include "util.h"
#include "usart.h"
-#include "usb_hw.h"
#include "usb-stream.h"
+#include "usb_hw.h"
+#include "util.h"
static size_t rx_read(struct usb_stream_config const *config)
{
diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c
index 1c621a32b3..dba9ebaba1 100644
--- a/chip/stm32/usb.c
+++ b/chip/stm32/usb.c
@@ -15,10 +15,10 @@
#include "system.h"
#include "task.h"
#include "timer.h"
-#include "util.h"
#include "usb_api.h"
#include "usb_descriptor.h"
#include "usb_hw.h"
+#include "util.h"
/* Console output macro */
#define CPRINTF(format, args...) cprintf(CC_USB, format, ##args)
diff --git a/chip/stm32/usb_console.c b/chip/stm32/usb_console.c
index fdadc243c1..062ce2f484 100644
--- a/chip/stm32/usb_console.c
+++ b/chip/stm32/usb_console.c
@@ -12,10 +12,10 @@
#include "registers.h"
#include "task.h"
#include "timer.h"
-#include "util.h"
#include "usb_api.h"
#include "usb_descriptor.h"
#include "usb_hw.h"
+#include "util.h"
/* Console output macro */
#define CPRINTF(format, args...) cprintf(CC_USB, format, ##args)
diff --git a/chip/stm32/usb_dwc.c b/chip/stm32/usb_dwc.c
index 67f89a5222..15ce4bff7f 100644
--- a/chip/stm32/usb_dwc.c
+++ b/chip/stm32/usb_dwc.c
@@ -13,12 +13,12 @@
#include "hooks.h"
#include "link_defs.h"
#include "registers.h"
-#include "usb_hw.h"
#include "system.h"
#include "task.h"
#include "timer.h"
-#include "util.h"
#include "usb_descriptor.h"
+#include "usb_hw.h"
+#include "util.h"
#include "watchdog.h"
/****************************************************************************/
diff --git a/chip/stm32/usb_dwc_console.c b/chip/stm32/usb_dwc_console.c
index fd66db7380..ff3c0817b6 100644
--- a/chip/stm32/usb_dwc_console.c
+++ b/chip/stm32/usb_dwc_console.c
@@ -12,9 +12,9 @@
#include "registers.h"
#include "task.h"
#include "timer.h"
-#include "util.h"
#include "usb_descriptor.h"
#include "usb_hw.h"
+#include "util.h"
/* Console output macro */
#define CPRINTF(format, args...) cprintf(CC_USB, format, ##args)
diff --git a/chip/stm32/usb_dwc_stream.c b/chip/stm32/usb_dwc_stream.c
index 670c93b437..78e0a4b484 100644
--- a/chip/stm32/usb_dwc_stream.c
+++ b/chip/stm32/usb_dwc_stream.c
@@ -3,12 +3,11 @@
* found in the LICENSE file.
*/
+#include "console.h"
#include "registers.h"
#include "timer.h"
#include "usb_dwc_stream.h"
#include "util.h"
-
-#include "console.h"
#define CPRINTF(format, args...) cprintf(CC_USB, format, ##args)
/*
diff --git a/chip/stm32/usb_dwc_stream.h b/chip/stm32/usb_dwc_stream.h
index 7e5e938053..bd512f5e9a 100644
--- a/chip/stm32/usb_dwc_stream.h
+++ b/chip/stm32/usb_dwc_stream.h
@@ -10,9 +10,9 @@
#include "compile_time_macros.h"
#include "consumer.h"
#include "hooks.h"
-#include "registers.h"
#include "producer.h"
#include "queue.h"
+#include "registers.h"
#include "usb_descriptor.h"
#include "usb_hw.h"
diff --git a/chip/stm32/usb_endpoints.c b/chip/stm32/usb_endpoints.c
index cf8cb17869..57ebc86eb2 100644
--- a/chip/stm32/usb_endpoints.c
+++ b/chip/stm32/usb_endpoints.c
@@ -5,13 +5,14 @@
* USB endpoints/interfaces callbacks declaration
*/
-#include <stdint.h>
-#include <stddef.h>
+#include "common.h"
#include "compiler.h"
#include "config.h"
-#include "common.h"
#include "usb_hw.h"
+#include <stddef.h>
+#include <stdint.h>
+
typedef void (*xfer_func)(void);
typedef void (*evt_func)(enum usb_ep_event evt);
diff --git a/chip/stm32/usb_hid.c b/chip/stm32/usb_hid.c
index e9426b690d..321248c702 100644
--- a/chip/stm32/usb_hid.c
+++ b/chip/stm32/usb_hid.c
@@ -13,11 +13,11 @@
#include "registers.h"
#include "task.h"
#include "timer.h"
-#include "util.h"
#include "usb_descriptor.h"
-#include "usb_hw.h"
#include "usb_hid.h"
#include "usb_hid_hw.h"
+#include "usb_hw.h"
+#include "util.h"
/* Console output macro */
#define CPRINTF(format, args...) cprintf(CC_USB, format, ##args)
diff --git a/chip/stm32/usb_hid_hw.h b/chip/stm32/usb_hid_hw.h
index 54bfca0808..5e28a801c1 100644
--- a/chip/stm32/usb_hid_hw.h
+++ b/chip/stm32/usb_hid_hw.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_USB_HID_HW_H
#define __CROS_EC_USB_HID_HW_H
+#include "chip/stm32/usb_hw.h"
+
#include <common.h>
struct usb_hid_config_t {
diff --git a/chip/stm32/usb_hid_keyboard.c b/chip/stm32/usb_hid_keyboard.c
index 7f3caac960..7b40f31309 100644
--- a/chip/stm32/usb_hid_keyboard.c
+++ b/chip/stm32/usb_hid_keyboard.c
@@ -20,12 +20,12 @@
#include "tablet_mode.h"
#include "task.h"
#include "timer.h"
-#include "util.h"
#include "usb_api.h"
#include "usb_descriptor.h"
-#include "usb_hw.h"
#include "usb_hid.h"
#include "usb_hid_hw.h"
+#include "usb_hw.h"
+#include "util.h"
/* Console output macro */
#define CPRINTF(format, args...) cprintf(CC_USB, format, ##args)
diff --git a/chip/stm32/usb_hid_touchpad.c b/chip/stm32/usb_hid_touchpad.c
index 15dd38756f..8eb5ee95dc 100644
--- a/chip/stm32/usb_hid_touchpad.c
+++ b/chip/stm32/usb_hid_touchpad.c
@@ -15,13 +15,13 @@
#include "registers.h"
#include "task.h"
#include "timer.h"
-#include "util.h"
#include "usb_api.h"
#include "usb_descriptor.h"
-#include "usb_hw.h"
#include "usb_hid.h"
#include "usb_hid_hw.h"
#include "usb_hid_touchpad.h"
+#include "usb_hw.h"
+#include "util.h"
/* Console output macro */
#define CPRINTF(format, args...) cprintf(CC_USB, format, ##args)
diff --git a/chip/stm32/usb_isochronous.c b/chip/stm32/usb_isochronous.c
index ad20b6d1ca..d2225991c0 100644
--- a/chip/stm32/usb_isochronous.c
+++ b/chip/stm32/usb_isochronous.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include "stddef.h"
#include "common.h"
#include "config.h"
#include "link_defs.h"
#include "registers.h"
-#include "util.h"
+#include "stddef.h"
#include "usb_api.h"
#include "usb_hw.h"
#include "usb_isochronous.h"
+#include "util.h"
/* Console output macro */
#define CPRINTF(format, args...) cprintf(CC_USB, format, ##args)
diff --git a/chip/stm32/usb_pd_phy.c b/chip/stm32/usb_pd_phy.c
index 9536301863..2d090293f9 100644
--- a/chip/stm32/usb_pd_phy.c
+++ b/chip/stm32/usb_pd_phy.c
@@ -11,15 +11,15 @@
#include "crc.h"
#include "dma.h"
#include "gpio.h"
-#include "hwtimer.h"
#include "hooks.h"
+#include "hwtimer.h"
#include "registers.h"
#include "system.h"
#include "task.h"
#include "timer.h"
-#include "util.h"
#include "usb_pd.h"
#include "usb_pd_config.h"
+#include "util.h"
#ifdef CONFIG_COMMON_RUNTIME
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
diff --git a/cmake/toolchain-armv7m.cmake b/cmake/toolchain-armv7m.cmake
new file mode 100644
index 0000000000..641b0debf2
--- /dev/null
+++ b/cmake/toolchain-armv7m.cmake
@@ -0,0 +1,38 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+set(CMAKE_SYSTEM_NAME Generic)
+set(CMAKE_SYSTEM_PROCESSOR arm)
+
+set(PREFIX armv7m-cros-eabi-)
+set(CMAKE_SYSROOT /usr/armv7m-cros-eabi/)
+
+set(CMAKE_C_COMPILER ${PREFIX}clang)
+set(CMAKE_CXX_COMPILER ${PREFIX}clang++)
+set(CMAKE_LINKER ${PREFIX}ld.lld)
+set(CMAKE_AR ${PREFIX}ar)
+set(CMAKE_NM ${PREFIX}nm)
+set(CMAKE_OBJCOPY ${PREFIX}objcopy)
+set(CMAKE_OBJDUMP ${PREFIX}objdump)
+set(CMAKE_RANLIB ${PREFIX}ranlib)
+set(CMAKE_READELF ${PREFIX}readelf)
+
+add_compile_options(-Oz)
+
+add_compile_options(-flto)
+add_link_options(-flto)
+
+# TODO(b/234507656): Remove this include when clang is fixed.
+add_compile_options(-I/usr/armv7m-cros-eabi/usr/include/c++/v1)
+# TODO(b/254916723): Remove this define when clang is fixed.
+add_compile_options(-D_GNU_SOURCE)
+add_link_options(-lclang_rt.builtins-armv7m)
+add_link_options(-lnosys)
+
+set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
diff --git a/common/accel_cal.c b/common/accel_cal.c
index 0fe9fe7656..878f3b06fa 100644
--- a/common/accel_cal.c
+++ b/common/accel_cal.c
@@ -3,9 +3,9 @@
* found in the LICENSE file.
*/
+#include "accel_cal.h"
#include "common.h"
#include "console.h"
-#include "accel_cal.h"
#define CPRINTS(format, args...) cprints(CC_MOTION_SENSE, format, ##args)
diff --git a/common/acpi.c b/common/acpi.c
index c6fcfce417..5dd71d244e 100644
--- a/common/acpi.c
+++ b/common/acpi.c
@@ -5,6 +5,7 @@
#include "acpi.h"
#include "battery.h"
+#include "body_detection.h"
#include "common.h"
#include "console.h"
#include "dptf.h"
@@ -17,8 +18,8 @@
#include "lpc.h"
#include "printf.h"
#include "pwm.h"
-#include "timer.h"
#include "tablet_mode.h"
+#include "timer.h"
#include "usb_charge.h"
#include "usb_common.h"
#include "util.h"
@@ -235,6 +236,11 @@ int acpi_ap_to_ec(int is_cmd, uint8_t value, uint8_t *resultptr)
EC_ACPI_MEM_DDPN_MASK)
<< EC_ACPI_MEM_DDPN_SHIFT;
#endif
+
+#ifdef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE
+ if (body_detect_get_state() == BODY_DETECTION_ON_BODY)
+ result |= BIT(EC_ACPI_MEM_STTB_SHIFT);
+#endif
break;
case EC_ACPI_MEM_DEVICE_FEATURES0:
diff --git a/common/base32.c b/common/base32.c
index fc3fe3c8ae..e5c30c4d6f 100644
--- a/common/base32.c
+++ b/common/base32.c
@@ -5,8 +5,8 @@
/* Base-32 encoding/decoding */
-#include "common.h"
#include "base32.h"
+#include "common.h"
#include "util.h"
static const unsigned char crc5_table1[] = { 0x00, 0x0E, 0x1C, 0x12, 0x11, 0x1F,
diff --git a/common/base_state.c b/common/base_state.c
index f90a5e7ce5..7bbd14eb00 100644
--- a/common/base_state.c
+++ b/common/base_state.c
@@ -5,8 +5,8 @@
#include "base_state.h"
#include "console.h"
-#include "host_command.h"
#include "hooks.h"
+#include "host_command.h"
#define CPRINTS(format, args...) cprints(CC_MOTION_LID, format, ##args)
diff --git a/common/battery_fuel_gauge.c b/common/battery_fuel_gauge.c
index 88f941f194..6a62c21479 100644
--- a/common/battery_fuel_gauge.c
+++ b/common/battery_fuel_gauge.c
@@ -7,6 +7,7 @@
#include "battery_fuel_gauge.h"
#include "battery_smart.h"
+#include "builtin/assert.h"
#include "console.h"
#include "hooks.h"
#include "i2c.h"
@@ -22,7 +23,8 @@
* a device name has been specified in the board_battery_info table,
* then both the manufacturer and device name must match.
*/
-static bool authenticate_battery_type(int index, char *manuf_name)
+test_export_static bool authenticate_battery_type(int index,
+ const char *manuf_name)
{
char device_name[32];
@@ -84,6 +86,12 @@ void battery_set_fixed_battery_type(int type)
}
#endif /* CONFIG_BATTERY_TYPE_NO_AUTO_DETECT */
+/**
+ * Allows us to override the battery in order to select the battery which has
+ * the right configuration for the test.
+ */
+test_export_static int battery_fuel_gauge_type_override = -1;
+
/* Get type of the battery connected on the board */
static int get_battery_type(void)
{
@@ -91,6 +99,10 @@ static int get_battery_type(void)
int i;
static enum battery_type battery_type = BATTERY_TYPE_COUNT;
+ if (IS_ENABLED(TEST_BUILD) && battery_fuel_gauge_type_override >= 0) {
+ return battery_fuel_gauge_type_override;
+ }
+
/*
* If battery_type is not the default value, then can return here
* as there is no need to query the fuel gauge.
@@ -237,17 +249,12 @@ enum ec_error_list battery_sleep_fuel_gauge(void)
return sb_write(sleep_command->reg_addr, sleep_command->reg_data);
}
-static enum ec_error_list battery_get_fet_status_regval(int *regval)
+static enum ec_error_list battery_get_fet_status_regval(int type, int *regval)
{
int rv;
uint8_t data[6];
- int type = get_battery_type();
- /* If battery type is not known, can't check CHG/DCHG FETs */
- if (type == BATTERY_TYPE_COUNT) {
- /* Still don't know, so return here */
- return EC_ERROR_BUSY;
- }
+ ASSERT(type < BATTERY_TYPE_COUNT);
/* Read the status of charge/discharge FETs */
if (board_battery_info[type].fuel_gauge.fet.mfgacc_support == 1) {
@@ -270,7 +277,7 @@ int battery_is_charge_fet_disabled(void)
int type = get_battery_type();
/* If battery type is not known, can't check CHG/DCHG FETs */
- if (type == BATTERY_TYPE_COUNT) {
+ if (type >= BATTERY_TYPE_COUNT) {
/* Still don't know, so return here */
return -1;
}
@@ -281,7 +288,7 @@ int battery_is_charge_fet_disabled(void)
if (!board_battery_info[type].fuel_gauge.fet.cfet_mask)
return 0;
- rv = battery_get_fet_status_regval(&reg);
+ rv = battery_get_fet_status_regval(type, &reg);
if (rv)
return -1;
@@ -307,12 +314,12 @@ enum battery_disconnect_state battery_get_disconnect_state(void)
int type = get_battery_type();
/* If battery type is not known, can't check CHG/DCHG FETs */
- if (type == BATTERY_TYPE_COUNT) {
+ if (type >= BATTERY_TYPE_COUNT) {
/* Still don't know, so return here */
return BATTERY_DISCONNECT_ERROR;
}
- if (battery_get_fet_status_regval(&reg))
+ if (battery_get_fet_status_regval(type, &reg))
return BATTERY_DISCONNECT_ERROR;
if ((reg & board_battery_info[type].fuel_gauge.fet.reg_mask) ==
diff --git a/common/battery_v2.c b/common/battery_v2.c
index 57ae07196b..50b5fb12f1 100644
--- a/common/battery_v2.c
+++ b/common/battery_v2.c
@@ -86,7 +86,7 @@ host_command_battery_get_static(struct host_cmd_handler_args *args)
const struct ec_params_battery_static_info *p = args->params;
const struct battery_static_info *bs;
- if (p->index < 0 || p->index >= CONFIG_BATTERY_COUNT)
+ if (p->index >= CONFIG_BATTERY_COUNT)
return EC_RES_INVALID_PARAM;
bs = &battery_static[p->index];
@@ -144,7 +144,7 @@ host_command_battery_get_dynamic(struct host_cmd_handler_args *args)
const struct ec_params_battery_dynamic_info *p = args->params;
struct ec_response_battery_dynamic_info *r = args->response;
- if (p->index < 0 || p->index >= CONFIG_BATTERY_COUNT)
+ if (p->index >= CONFIG_BATTERY_COUNT)
return EC_RES_INVALID_PARAM;
args->response_size = sizeof(*r);
diff --git a/common/bluetooth_le.c b/common/bluetooth_le.c
index 3108553a8b..d102740293 100644
--- a/common/bluetooth_le.c
+++ b/common/bluetooth_le.c
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include "builtin/assert.h"
#include "bluetooth_le.h"
-#include "util.h"
+#include "builtin/assert.h"
#include "console.h"
+#include "util.h"
#define CPRINTF(format, args...) cprintf(CC_BLUETOOTH_LE, format, ##args)
diff --git a/common/body_detection.c b/common/body_detection.c
index 848c4f08c1..e6b842ddf1 100644
--- a/common/body_detection.c
+++ b/common/body_detection.c
@@ -113,6 +113,11 @@ void body_detect_change_state(enum body_detect_states state, bool spoof)
/* reset time counting of stationary */
stationary_timeframe = 0;
}
+
+#ifdef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE
+ host_set_single_event(EC_HOST_EVENT_MODE_CHANGE);
+#endif
+
/* state changing log */
CPRINTS("body_detect changed state to: %s body",
motion_state ? "on" : "off");
diff --git a/common/btle_hci_controller.c b/common/btle_hci_controller.c
index a4dcadaccf..605b67945b 100644
--- a/common/btle_hci_controller.c
+++ b/common/btle_hci_controller.c
@@ -3,9 +3,9 @@
* found in the LICENSE file.
*/
-#include "btle_hci_int.h"
-#include "btle_hci2.h"
#include "bluetooth_le_ll.h"
+#include "btle_hci2.h"
+#include "btle_hci_int.h"
#include "console.h"
#ifdef CONFIG_BLUETOOTH_HCI_DEBUG
diff --git a/common/btle_ll.c b/common/btle_ll.c
index 71ca108565..eea9534fe3 100644
--- a/common/btle_ll.c
+++ b/common/btle_ll.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include "bluetooth_le_ll.h"
#include "bluetooth_le.h"
+#include "bluetooth_le_ll.h"
#include "btle_hci_int.h"
-#include "util.h"
#include "console.h"
#include "radio.h"
#include "radio_test.h"
#include "task.h"
#include "timer.h"
+#include "util.h"
#ifdef CONFIG_BLUETOOTH_LL_DEBUG
diff --git a/common/button.c b/common/button.c
index aa7bcf6b4c..284d026285 100644
--- a/common/button.c
+++ b/common/button.c
@@ -12,8 +12,8 @@
#include "compile_time_macros.h"
#include "console.h"
#include "gpio.h"
-#include "host_command.h"
#include "hooks.h"
+#include "host_command.h"
#include "keyboard_protocol.h"
#include "led_common.h"
#include "mkbp_input_devices.h"
diff --git a/common/charge_manager.c b/common/charge_manager.c
index 3e8b937e53..703b8933db 100644
--- a/common/charge_manager.c
+++ b/common/charge_manager.c
@@ -23,7 +23,7 @@
#include "typec_control.h"
#include "usb_common.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_tcpm.h"
#include "util.h"
@@ -835,8 +835,12 @@ static void charge_manager_refresh(void)
override_port = OVERRIDE_OFF;
if (new_supplier == CHARGE_SUPPLIER_NONE) {
+#ifdef CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT
+ new_charge_current = CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT;
+#else
new_charge_current = 0;
- new_charge_current_uncapped = 0;
+#endif
+ new_charge_current_uncapped = new_charge_current;
new_charge_voltage = 0;
} else {
new_charge_current_uncapped =
@@ -1707,3 +1711,11 @@ board_fill_source_power_info(int port, struct ec_response_usb_pd_power_info *r)
r->meas.current_lim = 0;
r->max_power = 0;
}
+
+__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
+{
+#if defined(CONFIG_CHARGER) && defined(CONFIG_BATTERY)
+ charge_set_input_current_limit(charge_ma, charge_mv);
+#endif
+}
diff --git a/common/charge_state_v2.c b/common/charge_state_v2.c
index 728606ef8a..742c94bdb6 100644
--- a/common/charge_state_v2.c
+++ b/common/charge_state_v2.c
@@ -9,9 +9,9 @@
#include "battery_smart.h"
#include "builtin/assert.h"
#include "charge_manager.h"
-#include "charger_profile_override.h"
#include "charge_state.h"
#include "charger.h"
+#include "charger_profile_override.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
@@ -1382,7 +1382,7 @@ struct charge_state_data *charge_get_status(void)
}
/* Determine if the battery is outside of allowable temperature range */
-static int battery_outside_charging_temperature(void)
+int battery_outside_charging_temperature(void)
{
const struct battery_info *batt_info = battery_get_info();
int batt_temp_c = DECI_KELVIN_TO_CELSIUS(curr.batt.temperature);
@@ -1507,9 +1507,9 @@ static int get_desired_input_current(enum battery_present batt_present,
int ilim = charge_manager_get_charger_current();
return ilim == CHARGE_CURRENT_UNINITIALIZED ?
CHARGE_CURRENT_UNINITIALIZED :
- MAX(CONFIG_CHARGER_INPUT_CURRENT, ilim);
+ MAX(CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT, ilim);
#else
- return CONFIG_CHARGER_INPUT_CURRENT;
+ return CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT;
#endif
} else {
#ifdef CONFIG_USB_POWER_DELIVERY
@@ -2082,14 +2082,15 @@ int charge_want_shutdown(void)
(curr.batt.state_of_charge < battery_level_shutdown);
}
-int charge_prevent_power_on(int power_button_pressed)
+#ifdef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
+test_export_static int charge_prevent_power_on_automatic_power_on = 1;
+#endif
+
+bool charge_prevent_power_on(bool power_button_pressed)
{
int prevent_power_on = 0;
struct batt_params params;
struct batt_params *current_batt_params = &curr.batt;
-#ifdef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
- static int automatic_power_on = 1;
-#endif
/* If battery params seem uninitialized then retrieve them */
if (current_batt_params->is_present == BP_NOT_SURE) {
@@ -2104,7 +2105,7 @@ int charge_prevent_power_on(int power_button_pressed)
* power-ups are user-requested and non-automatic.
*/
if (power_button_pressed)
- automatic_power_on = 0;
+ charge_prevent_power_on_automatic_power_on = 0;
/*
* Require a minimum battery level to power on and ensure that the
* battery can provide power to the system.
@@ -2150,12 +2151,13 @@ int charge_prevent_power_on(int power_button_pressed)
* except when auto-power-on at EC startup and the battery
* is physically present.
*/
- prevent_power_on &=
- (system_is_locked() || (automatic_power_on
+ prevent_power_on &= (system_is_locked() ||
+ (charge_prevent_power_on_automatic_power_on
#ifdef CONFIG_BATTERY_HW_PRESENT_CUSTOM
- && battery_hw_present() == BP_YES
+
+ && battery_hw_present() == BP_YES
#endif
- ));
+ ));
#endif /* CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON */
#ifdef CONFIG_CHARGE_MANAGER
@@ -2189,7 +2191,7 @@ int charge_prevent_power_on(int power_button_pressed)
prevent_power_on = 1;
#endif /* CONFIG_SYSTEM_UNLOCKED */
- return prevent_power_on;
+ return prevent_power_on != 0;
}
static int battery_near_full(void)
@@ -2328,6 +2330,18 @@ int charge_set_input_current_limit(int ma, int mv)
{
__maybe_unused int chgnum = 0;
+#ifdef CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT
+ if (CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT != 0) {
+ ma = (ma * (100 - CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT)) /
+ 100;
+ }
+#endif
+#ifdef CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT
+ if (CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT > 0) {
+ ma = MAX(ma, CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT);
+ }
+#endif
+
if (IS_ENABLED(CONFIG_OCPC))
chgnum = charge_get_active_chg_chip();
#ifdef CONFIG_EC_EC_COMM_BATTERY_CLIENT
diff --git a/common/chargen.c b/common/chargen.c
index 9b2c23ed79..626e13e71f 100644
--- a/common/chargen.c
+++ b/common/chargen.c
@@ -6,13 +6,13 @@
#include "common.h"
#include "config.h"
#include "console.h"
+#include "hooks.h"
+#include "task.h"
#include "timer.h"
#include "uart.h"
#include "usb_console.h"
#include "util.h"
#include "watchdog.h"
-#include "hooks.h"
-#include "task.h"
#ifndef SECTION_IS_RO
diff --git a/common/charger.c b/common/charger.c
index db780d59cf..198dc0db8c 100644
--- a/common/charger.c
+++ b/common/charger.c
@@ -6,15 +6,16 @@
*/
#include "battery_smart.h"
+#include "builtin/assert.h"
#include "charge_state_v2.h"
#include "charger.h"
#include "common.h"
#include "console.h"
#include "dptf.h"
+#include "hooks.h"
#include "host_command.h"
#include "printf.h"
#include "util.h"
-#include "hooks.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHARGER, outstr)
@@ -96,8 +97,12 @@ void charger_get_params(struct charger_params *chg)
{
int chgnum = 0;
- if (IS_ENABLED(CONFIG_OCPC))
+ if (IS_ENABLED(CONFIG_OCPC)) {
chgnum = charge_get_active_chg_chip();
+ /* set to CHARGE_PORT_NONE when no charger connected */
+ if (chgnum < 0)
+ chgnum = 0;
+ }
memset(chg, 0, sizeof(*chg));
@@ -495,8 +500,10 @@ enum ec_error_list charger_discharge_on_ac(int enable)
return rv;
}
-enum ec_error_list charger_enable_bypass_mode(int chgnum, int enable)
+enum ec_error_list charger_enable_bypass_mode(int chgnum, bool enable)
{
+ ASSERT(chgnum >= 0 && chgnum < board_get_charger_chip_count());
+
if (!chg_chips[chgnum].drv->enable_bypass_mode)
return EC_ERROR_UNIMPLEMENTED;
return chg_chips[chgnum].drv->enable_bypass_mode(chgnum, enable);
diff --git a/common/chargesplash.c b/common/chargesplash.c
index 17da9a5c8c..c3d93cc47b 100644
--- a/common/chargesplash.c
+++ b/common/chargesplash.c
@@ -3,9 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdbool.h>
-#include <string.h>
-
#include "chipset.h"
#include "common.h"
#include "console.h"
@@ -18,6 +15,9 @@
#include "timer.h"
#include "util.h"
+#include <stdbool.h>
+#include <string.h>
+
#define CPRINTS(format, args...) \
cprints(CC_USBCHARGE, "chargesplash: " format, ##args)
diff --git a/common/chipset.c b/common/chipset.c
index 55964e4ba9..5a699bfe25 100644
--- a/common/chipset.c
+++ b/common/chipset.c
@@ -134,3 +134,21 @@ enum chipset_shutdown_reason chipset_get_shutdown_reason(void)
}
#endif /* !CONFIG_AP_RESET_LOG */
+
+#ifdef TEST_BUILD
+uint32_t test_chipset_get_ap_resets_since_ec_boot(void)
+{
+ uint32_t count;
+
+ mutex_lock(&reset_log_mutex);
+ count = ap_resets_since_ec_boot;
+ mutex_unlock(&reset_log_mutex);
+
+ return count;
+}
+
+void test_chipset_corrupt_reset_log_checksum(void)
+{
+ reset_log_checksum = ~reset_log_checksum;
+}
+#endif /* TEST_BUILD */
diff --git a/common/dps.c b/common/dps.c
index c5a8ba4045..b0751acc39 100644
--- a/common/dps.c
+++ b/common/dps.c
@@ -5,16 +5,14 @@
* Dynamic PDO Selection.
*/
-#include <stdint.h>
-
-#include "dps.h"
#include "atomic.h"
#include "battery.h"
-#include "common.h"
-#include "console.h"
-#include "charger.h"
#include "charge_manager.h"
#include "charge_state.h"
+#include "charger.h"
+#include "common.h"
+#include "console.h"
+#include "dps.h"
#include "ec_commands.h"
#include "hooks.h"
#include "math_util.h"
@@ -24,6 +22,8 @@
#include "usb_pd.h"
#include "util.h"
+#include <stdint.h>
+
#define K_MORE_PWR 96
#define K_LESS_PWR 93
#define K_SAMPLE 1
@@ -231,7 +231,7 @@ static int get_battery_target_voltage(int *target_mv)
*
* @return 0 if error occurs, else battery efficient voltage in mV
*/
-int get_efficient_voltage(void)
+static int get_efficient_voltage(void)
{
int eff_mv = 0;
int batt_mv;
diff --git a/common/ec_ec_comm_server.c b/common/ec_ec_comm_server.c
index 6f37004513..174ac54757 100644
--- a/common/ec_ec_comm_server.c
+++ b/common/ec_ec_comm_server.c
@@ -5,16 +5,16 @@
* EC-EC communication, task and functions for server.
*/
-#include "common.h"
#include "battery.h"
#include "charge_state_v2.h"
+#include "common.h"
#include "console.h"
#include "crc8.h"
#include "ec_commands.h"
#include "ec_ec_comm_server.h"
#include "extpower.h"
-#include "hwtimer.h"
#include "hooks.h"
+#include "hwtimer.h"
#include "queue.h"
#include "queue_policies.h"
#include "system.h"
@@ -169,8 +169,9 @@ handle_cmd_charger_control(const struct ec_params_charger_control *params,
goto out;
}
- /* Reset input current to minimum. */
- charge_set_input_current_limit(CONFIG_CHARGER_INPUT_CURRENT, 0);
+ /* Reset input current to default. */
+ charge_set_input_current_limit(
+ CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT, 0);
/* Setup and enable "OTG". */
charge_set_output_current_limit(CHARGER_SOLO,
-params->max_current,
diff --git a/common/ec_features.c b/common/ec_features.c
index 6778a3b36a..7a69575500 100644
--- a/common/ec_features.c
+++ b/common/ec_features.c
@@ -5,11 +5,12 @@
/* Present Chrome EC device features to the outside world */
+#include "board_config.h"
#include "common.h"
#include "config.h"
#include "console.h"
#include "ec_commands.h"
-#include "board_config.h"
+#include "motion_sense.h"
uint32_t get_feature_flags0(void)
{
@@ -128,7 +129,10 @@ uint32_t get_feature_flags1(void)
| EC_FEATURE_MASK_1(EC_FEATURE_MOTION_SENSE_TIGHT_TIMESTAMPS)
#endif
#if defined(CONFIG_LID_ANGLE) && defined(CONFIG_TABLET_MODE)
- | EC_FEATURE_MASK_1(EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS)
+ | (sensor_board_is_lid_angle_available() ?
+ EC_FEATURE_MASK_1(
+ EC_FEATURE_REFINED_TABLET_MODE_HYSTERESIS) :
+ 0)
#endif
#ifdef CONFIG_VBOOT_EFS2
| EC_FEATURE_MASK_1(EC_FEATURE_EFS2)
diff --git a/common/espi.c b/common/espi.c
index dfb1f90749..f57e13cf76 100644
--- a/common/espi.c
+++ b/common/espi.c
@@ -6,9 +6,9 @@
/* eSPI common functionality for Chrome EC */
#include "common.h"
+#include "espi.h"
#include "gpio.h"
#include "registers.h"
-#include "espi.h"
#include "timer.h"
#include "util.h"
diff --git a/common/flash.c b/common/flash.c
index 0a027fd312..4f3f578eed 100644
--- a/common/flash.c
+++ b/common/flash.c
@@ -232,6 +232,13 @@ static int flash_range_ok(int offset, int size_req, int align)
}
#ifdef CONFIG_MAPPED_STORAGE
+
+/**
+ * A test public variable allowing us to override the base address of
+ * flash_physical_dataptr().
+ */
+test_export_static const char *flash_physical_dataptr_override;
+
/**
* Get the physical memory address of a flash offset
*
@@ -245,6 +252,9 @@ static int flash_range_ok(int offset, int size_req, int align)
*/
static const char *flash_physical_dataptr(int offset)
{
+ if (IS_ENABLED(TEST_BUILD) && flash_physical_dataptr_override != NULL) {
+ return flash_physical_dataptr_override + offset;
+ }
return (char *)((uintptr_t)CONFIG_MAPPED_STORAGE_BASE + offset);
}
@@ -978,6 +988,8 @@ DECLARE_DEFERRED(flash_erase_deferred);
/* Console commands */
#ifdef CONFIG_CMD_FLASHINFO
+#define BIT_TO_ON_OFF(value, mask) \
+ ((((value) & (mask)) == (mask)) ? "ON" : "OFF")
static int command_flash_info(int argc, const char **argv)
{
int i, flags;
@@ -1002,36 +1014,35 @@ static int command_flash_info(int argc, const char **argv)
ccprintf("Protect: %4d B\n", CONFIG_FLASH_BANK_SIZE);
#endif
flags = crec_flash_get_protect();
- ccprintf("Flags: ");
- if (flags & EC_FLASH_PROTECT_GPIO_ASSERTED)
- ccputs(" wp_gpio_asserted");
- if (flags & EC_FLASH_PROTECT_RO_AT_BOOT)
- ccputs(" ro_at_boot");
- if (flags & EC_FLASH_PROTECT_ALL_AT_BOOT)
- ccputs(" all_at_boot");
- if (flags & EC_FLASH_PROTECT_RO_NOW)
- ccputs(" ro_now");
- if (flags & EC_FLASH_PROTECT_ALL_NOW)
- ccputs(" all_now");
+ ccprintf("Flags:\n");
+ ccprintf(" wp_gpio_asserted: %s\n",
+ BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_GPIO_ASSERTED));
+ ccprintf(" ro_at_boot: %s\n",
+ BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_RO_AT_BOOT));
+ ccprintf(" all_at_boot: %s\n",
+ BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ALL_AT_BOOT));
+ ccprintf(" ro_now: %s\n",
+ BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_RO_NOW));
+ ccprintf(" all_now: %s\n",
+ BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ALL_NOW));
#ifdef CONFIG_FLASH_PROTECT_RW
- if (flags & EC_FLASH_PROTECT_RW_AT_BOOT)
- ccputs(" rw_at_boot");
- if (flags & EC_FLASH_PROTECT_RW_NOW)
- ccputs(" rw_now");
+ ccprintf(" rw_at_boot: %s\n",
+ BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_RW_AT_BOOT));
+ ccprintf(" rw_now: %s\n",
+ BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_RW_NOW));
#endif
- if (flags & EC_FLASH_PROTECT_ERROR_STUCK)
- ccputs(" STUCK");
- if (flags & EC_FLASH_PROTECT_ERROR_INCONSISTENT)
- ccputs(" INCONSISTENT");
- if (flags & EC_FLASH_PROTECT_ERROR_UNKNOWN)
- ccputs(" UNKNOWN_ERROR");
+ ccprintf(" STUCK: %s\n",
+ BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ERROR_STUCK));
+ ccprintf(" INCONSISTENT: %s\n",
+ BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ERROR_INCONSISTENT));
+ ccprintf(" UNKNOWN_ERROR: %s\n",
+ BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ERROR_UNKNOWN));
#ifdef CONFIG_ROLLBACK
- if (flags & EC_FLASH_PROTECT_ROLLBACK_AT_BOOT)
- ccputs(" rollback_at_boot");
- if (flags & EC_FLASH_PROTECT_ROLLBACK_NOW)
- ccputs(" rollback_now");
+ ccprintf(" rollback_at_boot: %s\n",
+ BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ROLLBACK_AT_BOOT));
+ ccprintf(" rollback_now: %s\n",
+ BIT_TO_ON_OFF(flags, EC_FLASH_PROTECT_ROLLBACK_NOW));
#endif
- ccputs("\n");
ccputs("Protected now:");
for (i = 0; i < PHYSICAL_BANKS; i++) {
diff --git a/common/fmap.c b/common/fmap.c
index 469fac0ceb..0fa77c47cd 100644
--- a/common/fmap.c
+++ b/common/fmap.c
@@ -4,13 +4,13 @@
* found in the LICENSE file.
*/
-#include <stddef.h>
-
#include "common.h"
#include "cros_version.h"
#include "rwsig.h"
#include "util.h"
+#include <stddef.h>
+
/*
* FMAP structs.
* See
diff --git a/common/fpsensor/fpsensor_crypto.c b/common/fpsensor/fpsensor_crypto.c
index 257042197e..aac50bb297 100644
--- a/common/fpsensor/fpsensor_crypto.c
+++ b/common/fpsensor/fpsensor_crypto.c
@@ -2,16 +2,16 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <stdbool.h>
-
-#include "aes.h"
#include "aes-gcm.h"
+#include "aes.h"
#include "cryptoc/util.h"
#include "fpsensor_crypto.h"
#include "fpsensor_private.h"
#include "fpsensor_state.h"
#include "rollback.h"
+#include <stdbool.h>
+
#if !defined(CONFIG_AES) || !defined(CONFIG_AES_GCM) || \
!defined(CONFIG_ROLLBACK_SECRET_SIZE)
#error "fpsensor requires AES, AES_GCM and ROLLBACK_SECRET_SIZE"
diff --git a/common/gesture.c b/common/gesture.c
index 99d054783d..48e6af3571 100644
--- a/common/gesture.c
+++ b/common/gesture.c
@@ -8,8 +8,8 @@
#include "accelgyro.h"
#include "common.h"
#include "console.h"
-#include "hooks.h"
#include "gesture.h"
+#include "hooks.h"
#include "lid_switch.h"
#include "lightbar.h"
#include "motion_sense.h"
diff --git a/common/gpio_commands.c b/common/gpio_commands.c
index d6257ea61d..06e0203090 100644
--- a/common/gpio_commands.c
+++ b/common/gpio_commands.c
@@ -91,7 +91,10 @@ __maybe_unused static const struct gpio_flag_description gpio_descriptions[] = {
{ GPIO_INPUT, "I" }, { GPIO_OUTPUT, "O" },
{ GPIO_LOW, "L" }, { GPIO_HIGH, "H" },
{ GPIO_OPEN_DRAIN, "ODR" }, { GPIO_PULL_UP, "PU" },
- { GPIO_PULL_DOWN, "PD" }, { GPIO_SEL_1P8V, "1P8" },
+ { GPIO_PULL_DOWN, "PD" },
+#ifdef GPIO_SEL_1P8V
+ { GPIO_SEL_1P8V, "1P8" },
+#endif
#ifndef CONFIG_ZEPHYR
{ GPIO_ANALOG, "A" }, { GPIO_ALTERNATE, "ALT" },
{ GPIO_LOCKED, "LCK" }
diff --git a/common/gyro_cal.c b/common/gyro_cal.c
index 8996b85757..e2cb8d55db 100644
--- a/common/gyro_cal.c
+++ b/common/gyro_cal.c
@@ -5,6 +5,7 @@
#include "gyro_cal.h"
#include "string.h"
+
#include <stdbool.h>
/*
diff --git a/common/host_command_pd.c b/common/host_command_pd.c
index 23e2710695..e7dbbc2b5f 100644
--- a/common/host_command_pd.c
+++ b/common/host_command_pd.c
@@ -126,10 +126,7 @@ static void pd_check_chg_status(struct ec_response_pd_status *pd_status)
#endif
/* Set input current limit */
- rv = charge_set_input_current_limit(
- MAX(pd_status->curr_lim_ma, CONFIG_CHARGER_INPUT_CURRENT), 0);
- if (rv < 0)
- CPRINTS("Failed to set input curr limit from PD MCU");
+ board_set_charge_limit(pd_status->curr_lim_ma, 0);
}
#endif /* CONFIG_HOSTCMD_PD_CHG_CTRL */
#endif /* CONFIG_HOSTCMD_PD */
diff --git a/common/i2c_controller.c b/common/i2c_controller.c
index b51f726369..96809ee84c 100644
--- a/common/i2c_controller.c
+++ b/common/i2c_controller.c
@@ -7,12 +7,12 @@
#include "battery.h"
#include "builtin/assert.h"
-#include "clock.h"
#include "charge_state.h"
+#include "clock.h"
#include "console.h"
#include "crc8.h"
-#include "host_command.h"
#include "gpio.h"
+#include "host_command.h"
#include "i2c.h"
#include "i2c_bitbang.h"
#include "i2c_private.h"
@@ -22,12 +22,13 @@
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#include "util.h"
-#include "watchdog.h"
#include "virtual_battery.h"
+#include "watchdog.h"
#ifdef CONFIG_ZEPHYR
-#include <zephyr/drivers/i2c.h>
#include "i2c/i2c.h"
+
+#include <zephyr/drivers/i2c.h>
#endif /* CONFIG_ZEPHYR */
#define CPUTS(outstr) cputs(CC_I2C, outstr)
@@ -833,7 +834,7 @@ int i2c_write_block(const int port, const uint16_t addr_flags, int offset,
if (rv)
continue;
- if (I2C_USE_PEC(addr_flags)) {
+ if (IS_ENABLED(CONFIG_SMBUS_PEC) && I2C_USE_PEC(addr_flags)) {
rv = i2c_xfer_unlocked(port, addr_flags, data, len,
NULL, 0, 0);
if (rv)
diff --git a/common/i2c_controller_cros_ec.c b/common/i2c_controller_cros_ec.c
index aafeb504ce..d68f67c60e 100644
--- a/common/i2c_controller_cros_ec.c
+++ b/common/i2c_controller_cros_ec.c
@@ -4,16 +4,15 @@
*/
#include "builtin/assert.h"
-#include "system.h"
+#include "console.h"
#include "gpio.h"
-
+#include "i2c.h"
#include "i2c_bitbang.h"
#include "i2c_private.h"
-#include "i2c.h"
-#include "console.h"
-#include "watchdog.h"
#include "printf.h"
+#include "system.h"
#include "util.h"
+#include "watchdog.h"
/* This source file contains I2C controller code that is used only in legacy
* (CrOS EC) builds.
diff --git a/common/i2c_hid_touchpad.c b/common/i2c_hid_touchpad.c
index 02261d8fa4..2664dabe3e 100644
--- a/common/i2c_hid_touchpad.c
+++ b/common/i2c_hid_touchpad.c
@@ -3,10 +3,9 @@
* found in the LICENSE file.
*/
-#include "i2c_hid_touchpad.h"
-
#include "console.h"
#include "hwtimer.h"
+#include "i2c_hid_touchpad.h"
#include "util.h"
/* 2 bytes for length + 1 byte for report ID */
diff --git a/common/i2c_trace.c b/common/i2c_trace.c
index c7207698b7..8532766ea8 100644
--- a/common/i2c_trace.c
+++ b/common/i2c_trace.c
@@ -6,8 +6,8 @@
#include "common.h"
#include "console.h"
#include "i2c.h"
-#include "stddef.h"
#include "stdbool.h"
+#include "stddef.h"
#include "util.h"
#define CPUTS(outstr) cputs(CC_I2C, outstr)
@@ -67,7 +67,7 @@ static int command_i2ctrace_list(void)
i2c_port = get_i2c_port(trace_entries[i].port);
ccprintf("%-2zd %d %-8s 0x%X", i, trace_entries[i].port,
#ifndef CONFIG_ZEPHYR
- i2c_port->name,
+ i2c_port ? i2c_port->name : "invalid",
#else
"",
#endif /* CONFIG_ZEPHYR */
diff --git a/common/init_rom.c b/common/init_rom.c
index 102c3a00ae..ad9e80f423 100644
--- a/common/init_rom.c
+++ b/common/init_rom.c
@@ -7,8 +7,8 @@
#include "builtin/assert.h"
#include "common.h"
-#include "init_rom.h"
#include "flash.h"
+#include "init_rom.h"
#include "stdbool.h"
#include "stddef.h"
diff --git a/common/kasa.c b/common/kasa.c
index 6b974dc574..0ab716c729 100644
--- a/common/kasa.c
+++ b/common/kasa.c
@@ -6,6 +6,7 @@
#include "common.h"
#include "kasa.h"
#include "mat44.h"
+
#include <string.h>
void kasa_reset(struct kasa_fit *kasa)
diff --git a/common/keyboard_8042.c b/common/keyboard_8042.c
index e0371ddd5c..6e2b14719f 100644
--- a/common/keyboard_8042.c
+++ b/common/keyboard_8042.c
@@ -5,8 +5,9 @@
* 8042 keyboard protocol
*/
-#include "button.h"
+#include "atkbd_protocol.h"
#include "builtin/assert.h"
+#include "button.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
@@ -14,7 +15,6 @@
#include "hooks.h"
#include "host_command.h"
#include "i8042_protocol.h"
-#include "atkbd_protocol.h"
#include "keyboard_8042_sharedlib.h"
#include "keyboard_config.h"
#include "keyboard_protocol.h"
@@ -78,6 +78,15 @@ enum scancode_set_list {
#define KB_TO_HOST_RETRIES 3
/*
+ * Timeout for SETLEDS command. Kernel is supposed to send the second byte
+ * within this period. When timeout occurs, the second byte is received as
+ * 'Unsupported AT keyboard command 0x00' (or 0x04). You can evaluate your
+ * timeout is too long or too short by calculating the duration between 'KB
+ * SETLEDS' and 'Unsupported AT...'.
+ */
+#define SETLEDS_TIMEOUT (30 * MSEC)
+
+/*
* Mutex to control write access to the to-host buffer head. Don't need to
* mutex the tail because reads are only done in one place.
*/
@@ -87,6 +96,7 @@ static mutex_t to_host_mutex;
enum {
CHAN_KBD = 0,
CHAN_AUX,
+ CHAN_CMD,
};
struct data_byte {
uint8_t chan;
@@ -94,6 +104,7 @@ struct data_byte {
};
static struct queue const to_host = QUEUE_NULL(16, struct data_byte);
+static struct queue const to_host_cmd = QUEUE_NULL(16, struct data_byte);
/* Queue command/data from the host */
enum {
@@ -162,6 +173,7 @@ static int typematic_inter_delay;
static int typematic_len; /* length of typematic_scan_code */
static uint8_t typematic_scan_code[MAX_SCAN_CODE_LEN];
static timestamp_t typematic_deadline;
+static timestamp_t setleds_deadline;
#define KB_SYSJUMP_TAG 0x4b42 /* "KB" */
#define KB_HOOK_VERSION 2
@@ -182,18 +194,16 @@ struct kblog_t {
/*
* Type:
*
- * s = byte enqueued to send to host
* a = aux byte enqueued to send to host
- * t = to-host queue tail pointer before type='s' bytes enqueued
- *
- * d = data byte from host
* c = command byte from host
- *
- * k = to-host queue head pointer before byte dequeued
- * K = byte actually sent to host via LPC
- * A = byte actually sent to host via LPC as AUX
- *
+ * d = data byte from host
+ * r = typematic
+ * s = byte enqueued to send to host
+ * t = to-host queue tail pointer before type='s' bytes enqueued
+ * u = byte enqueued to send to host with priority
* x = to_host queue was cleared
+ * A = byte actually sent to host via LPC as AUX
+ * K = byte actually sent to host via LPC
*
* The to-host head and tail pointers are logged pre-wrapping to the
* queue size. This means that they continually increment as units
@@ -265,7 +275,7 @@ static void aux_enable_irq(int enable)
* host cannot read the previous byte away in time.
*
* @param len Number of bytes to send to the host
- * @param to_host Data to send
+ * @param bytes Data to send
* @param chan Channel to send data on
*/
static void i8042_send_to_host(int len, const uint8_t *bytes, uint8_t chan,
@@ -281,15 +291,29 @@ static void i8042_send_to_host(int len, const uint8_t *bytes, uint8_t chan,
for (i = 0; i < len; i++)
kblog_put('r', bytes[i]);
} else {
- for (i = 0; i < len; i++)
- kblog_put(chan == CHAN_AUX ? 'a' : 's', bytes[i]);
+ struct queue const *queue = &to_host;
+
+ if (chan == CHAN_CMD)
+ queue = &to_host_cmd;
+
+ for (i = 0; i < len; i++) {
+ char type;
+
+ if (chan == CHAN_AUX)
+ type = 'a';
+ else if (chan == CHAN_CMD)
+ type = 'u';
+ else
+ type = 's';
+ kblog_put(type, bytes[i]);
+ }
- if (queue_space(&to_host) >= len) {
- kblog_put('t', to_host.state->tail);
+ if (queue_space(queue) >= len) {
+ kblog_put('t', queue->state->tail);
for (i = 0; i < len; i++) {
data.chan = chan;
data.byte = bytes[i];
- queue_add_unit(&to_host, &data);
+ queue_add_unit(queue, &data);
}
}
}
@@ -417,6 +441,7 @@ void keyboard_clear_buffer(void)
mutex_lock(&to_host_mutex);
kblog_put('x', queue_count(&to_host));
queue_init(&to_host);
+ queue_init(&to_host_cmd);
mutex_unlock(&to_host_mutex);
lpc_keyboard_clear_buffer();
}
@@ -661,6 +686,8 @@ static int handle_keyboard_data(uint8_t data, uint8_t *output)
/* Chrome OS doesn't have keyboard LEDs, so ignore */
output[out_len++] = ATKBD_RET_ACK;
data_port_state = STATE_ATKBD_SETLEDS;
+ setleds_deadline.val = get_time().val + SETLEDS_TIMEOUT;
+ CPRINTS5("KB SETLEDS");
break;
case ATKBD_CMD_EX_SETLEDS:
@@ -868,20 +895,23 @@ static void i8042_handle_from_host(void)
struct host_byte h;
int ret_len;
uint8_t output[MAX_SCAN_CODE_LEN];
- uint8_t chan = CHAN_KBD;
+ uint8_t chan;
while (queue_remove_unit(&from_host, &h)) {
if (h.type == HOST_COMMAND) {
ret_len = handle_keyboard_command(h.byte, output);
+ chan = CHAN_KBD;
} else {
CPRINTS5("KB recv data: 0x%02x", h.byte);
kblog_put('d', h.byte);
if (IS_ENABLED(CONFIG_8042_AUX) &&
- handle_mouse_data(h.byte, output, &ret_len))
+ handle_mouse_data(h.byte, output, &ret_len)) {
chan = CHAN_AUX;
- else
+ } else {
ret_len = handle_keyboard_data(h.byte, output);
+ chan = CHAN_CMD;
+ }
}
i8042_send_to_host(ret_len, output, chan, 0);
@@ -925,10 +955,14 @@ void keyboard_protocol_task(void *u)
i8042_handle_from_host();
/* Check if we have data to send to host */
- if (queue_is_empty(&to_host))
+ if (queue_is_empty(&to_host) &&
+ queue_is_empty(&to_host_cmd))
break;
- /* Handle data waiting for host */
+ /*
+ * Check if the output buffer is full. We can't proceed
+ * until the host read the data.
+ */
if (lpc_keyboard_has_char()) {
/* If interrupts disabled, nothing we can do */
if (!i8042_keyboard_irq_enabled &&
@@ -946,26 +980,53 @@ void keyboard_protocol_task(void *u)
* data? Send it another interrupt in case it
* somehow missed the first one.
*/
- CPRINTS("KB extra IRQ");
+ CPRINTS("KB host not responding");
lpc_keyboard_resume_irq();
retries = 0;
break;
}
+ /*
+ * We know DBBOUT is empty but we need act quickly as
+ * the host might be sending a byte to DBBIN.
+ *
+ * So be cautious if you're adding any code below up to
+ * lpc_keyboard_put_char since that'll increase the race
+ * condition. For example, you don't want to add CPRINTS
+ * or kblog_put.
+ *
+ * We should claim OBF=1 atomically to prevent the host
+ * from writing to DBBIN (i.e. set-ibf-if-not-obf). It's
+ * not possible for NPCX because NPCX's HIKMST-IBF is
+ * read-only.
+ */
+
/* Get a char from buffer. */
- kblog_put('k', to_host.state->head);
- queue_remove_unit(&to_host, &entry);
+ if (queue_count(&to_host_cmd)) {
+ queue_remove_unit(&to_host_cmd, &entry);
+ } else if (data_port_state == STATE_ATKBD_SETLEDS) {
+ /* to_host_cmd is empty but in SETLEDS */
+ if (!timestamp_expired(setleds_deadline, &t))
+ /* Let's wait for the 2nd byte. */
+ break;
+ /* Didn't receive 2nd byte. Go back to CMD. */
+ CPRINTS("KB SETLEDS timeout");
+ data_port_state = STATE_ATKBD_CMD;
+ } else {
+ /* to_host isn't empty && not in SETLEDS */
+ queue_remove_unit(&to_host, &entry);
+ }
/* Write to host. */
if (entry.chan == CHAN_AUX &&
IS_ENABLED(CONFIG_8042_AUX)) {
- kblog_put('A', entry.byte);
lpc_aux_put_char(entry.byte,
i8042_aux_irq_enabled);
+ kblog_put('A', entry.byte);
} else {
- kblog_put('K', entry.byte);
lpc_keyboard_put_char(
entry.byte, i8042_keyboard_irq_enabled);
+ kblog_put('K', entry.byte);
}
retries = 0;
}
diff --git a/common/keyboard_8042_sharedlib.c b/common/keyboard_8042_sharedlib.c
index 3e98c977b7..810f9873b3 100644
--- a/common/keyboard_8042_sharedlib.c
+++ b/common/keyboard_8042_sharedlib.c
@@ -5,8 +5,6 @@
* Objects which can be shared between RO and RW for 8042 keyboard protocol.
*/
-#include <stddef.h>
-
#include "builtin/assert.h"
#include "button.h"
#include "keyboard_8042_sharedlib.h"
@@ -15,6 +13,8 @@
#include "libsharedobjs.h"
#include "util.h"
+#include <stddef.h>
+
#ifndef CONFIG_KEYBOARD_CUSTOMIZATION
/* The standard Chrome OS keyboard matrix table in scan code set 2. */
static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
diff --git a/common/keyboard_scan.c b/common/keyboard_scan.c
index 6c3756170b..617ae3fc02 100644
--- a/common/keyboard_scan.c
+++ b/common/keyboard_scan.c
@@ -913,6 +913,7 @@ void keyboard_scan_task(void *u)
uint32_t local_disable_scanning = 0;
print_state(debounced_state, "init state");
+ poll_deadline.val = 0;
keyboard_raw_task_start();
@@ -1078,6 +1079,10 @@ int keyboard_factory_test_scan(void)
keyboard_scan_enable(0, KB_SCAN_DISABLE_LID_CLOSED);
flags = gpio_get_default_flags(GPIO_KBD_KSO2);
+ if (IS_ENABLED(CONFIG_ZEPHYR))
+ /* set all KSI/KSO pins to GPIO_ALT_FUNC_NONE */
+ keybaord_raw_config_alt(0);
+
/* Set all of KSO/KSI pins to internal pull-up and input */
for (i = 0; i < keyboard_factory_scan_pins_used; i++) {
if (keyboard_factory_scan_pins[i][0] < 0)
@@ -1086,7 +1091,9 @@ int keyboard_factory_test_scan(void)
port = keyboard_factory_scan_pins[i][0];
id = keyboard_factory_scan_pins[i][1];
- gpio_set_alternate_function(port, 1 << id, GPIO_ALT_FUNC_NONE);
+ if (!IS_ENABLED(CONFIG_ZEPHYR))
+ gpio_set_alternate_function(port, 1 << id,
+ GPIO_ALT_FUNC_NONE);
gpio_set_flags_by_mask(port, 1 << id,
GPIO_INPUT | GPIO_PULL_UP);
}
@@ -1119,7 +1126,10 @@ int keyboard_factory_test_scan(void)
GPIO_INPUT | GPIO_PULL_UP);
}
done:
- gpio_config_module(MODULE_KEYBOARD_SCAN, 1);
+ if (IS_ENABLED(CONFIG_ZEPHYR))
+ keybaord_raw_config_alt(1);
+ else
+ gpio_config_module(MODULE_KEYBOARD_SCAN, 1);
gpio_set_flags(GPIO_KBD_KSO2, flags);
keyboard_scan_enable(1, KB_SCAN_DISABLE_LID_CLOSED);
diff --git a/common/keyboard_vivaldi.c b/common/keyboard_vivaldi.c
index 11f5b708e6..44bbff2c11 100644
--- a/common/keyboard_vivaldi.c
+++ b/common/keyboard_vivaldi.c
@@ -6,13 +6,14 @@
/* Vivali Keyboard code for Chrome EC */
#include "builtin/assert.h"
-#include "keyboard_8042_sharedlib.h"
-#include "keyboard_scan.h"
#include "ec_commands.h"
#include "gpio.h"
+#include "keyboard_8042_sharedlib.h"
+#include "keyboard_scan.h"
+
+#include <hooks.h>
#include <host_command.h>
#include <util.h>
-#include <hooks.h>
/* Console output macros */
#define CPUTS(outstr) cputs(CC_KEYBOARD, outstr)
diff --git a/common/led_common.c b/common/led_common.c
index 2c73ba95e6..cabaf22e10 100644
--- a/common/led_common.c
+++ b/common/led_common.c
@@ -47,6 +47,10 @@ int led_auto_control_is_enabled(enum ec_led_id led_id)
return (led_auto_control_flags & LED_AUTO_CONTROL_FLAG(led_id)) != 0;
}
+/* Empty functions cannot be verified in testing to not have had any
+ * side-effects, remove from coverage.
+ * LCOV_EXCL_START
+ */
__attribute__((weak)) void board_led_auto_control(void)
{
/*
@@ -56,6 +60,7 @@ __attribute__((weak)) void board_led_auto_control(void)
* is changed.
*/
}
+/* LCOV_EXCL_STOP */
static enum ec_status led_command_control(struct host_cmd_handler_args *args)
{
@@ -91,6 +96,7 @@ static enum ec_status led_command_control(struct host_cmd_handler_args *args)
}
DECLARE_HOST_COMMAND(EC_CMD_LED_CONTROL, led_command_control, EC_VER_MASK(1));
+#ifndef CONFIG_ZEPHYR
__attribute__((weak)) void led_control(enum ec_led_id led_id,
enum ec_led_state state)
{
@@ -99,3 +105,4 @@ __attribute__((weak)) void led_control(enum ec_led_id led_id,
* LED. Boards can provide their own implementation.
*/
}
+#endif
diff --git a/common/led_policy_std.c b/common/led_policy_std.c
index fe8570df87..b9d95af639 100644
--- a/common/led_policy_std.c
+++ b/common/led_policy_std.c
@@ -6,14 +6,14 @@
* This assumes a red/green battery led and a single power led.
*/
-#include "gpio.h"
-#include "hooks.h"
#include "battery.h"
#include "charge_state.h"
#include "chipset.h"
+#include "gpio.h"
+#include "hooks.h"
#include "led_common.h"
-#include "util.h"
#include "lid_switch.h"
+#include "util.h"
#ifdef CONFIG_LED_BAT_ACTIVE_LOW
#define BAT_LED_ON 0
diff --git a/common/lightbar.c b/common/lightbar.c
index 8a6a874b34..a705a2cbed 100644
--- a/common/lightbar.c
+++ b/common/lightbar.c
@@ -17,8 +17,8 @@
#include "hooks.h"
#include "host_command.h"
#include "lb_common.h"
-#include "lightbar.h"
#include "lid_switch.h"
+#include "lightbar.h"
#include "motion_sense.h"
#include "pwm.h"
#include "system.h"
diff --git a/common/mag_cal.c b/common/mag_cal.c
index a9ce95798c..2ad89c48df 100644
--- a/common/mag_cal.c
+++ b/common/mag_cal.c
@@ -8,7 +8,6 @@
#include "mag_cal.h"
#include "mat33.h"
#include "mat44.h"
-
#include "math.h"
#include "math_util.h"
#include "util.h"
diff --git a/common/mkbp_event.c b/common/mkbp_event.c
index e602f81baf..eb57a11656 100644
--- a/common/mkbp_event.c
+++ b/common/mkbp_event.c
@@ -11,10 +11,10 @@
#include "host_command.h"
#include "host_command_heci.h"
#include "hwtimer.h"
-#include "timer.h"
#include "link_defs.h"
#include "mkbp_event.h"
#include "power.h"
+#include "timer.h"
#include "util.h"
#define CPUTS(outstr) cputs(CC_COMMAND, outstr)
@@ -586,5 +586,12 @@ void mkbp_event_clear_all(void)
/* Reset the interrupt line */
mkbp_set_host_active(0, NULL);
+#ifdef CONFIG_MKBP_EVENT_WAKEUP_MASK
+ mkbp_event_wake_mask = CONFIG_MKBP_EVENT_WAKEUP_MASK;
+#endif /* CONFIG_MKBP_EVENT_WAKEUP_MASK */
+
+#ifdef CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK
+ mkbp_host_event_wake_mask = CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK;
+#endif /* CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK */
}
#endif
diff --git a/common/mock/charge_manager_mock.c b/common/mock/charge_manager_mock.c
index c800b9b9b1..745b37efa7 100644
--- a/common/mock/charge_manager_mock.c
+++ b/common/mock/charge_manager_mock.c
@@ -8,12 +8,12 @@
* @brief Mock charge_manager
*/
-#include <stdlib.h>
-
#include "charge_manager.h"
#include "common.h"
#include "mock/charge_manager_mock.h"
+#include <stdlib.h>
+
#ifndef TEST_BUILD
#error "Mocks should only be in the test build."
#endif
diff --git a/common/mock/dp_alt_mode_mock.c b/common/mock/dp_alt_mode_mock.c
index e261415aaa..ed769ed4b5 100644
--- a/common/mock/dp_alt_mode_mock.c
+++ b/common/mock/dp_alt_mode_mock.c
@@ -10,8 +10,8 @@
*/
#include "console.h"
-#include "usb_dp_alt_mode.h"
#include "mock/dp_alt_mode_mock.h"
+#include "usb_dp_alt_mode.h"
#ifndef TEST_BUILD
#error "Mocks should only be in the test build."
diff --git a/common/mock/fp_sensor_mock.c b/common/mock/fp_sensor_mock.c
index 4db25a821c..57a4f42ae9 100644
--- a/common/mock/fp_sensor_mock.c
+++ b/common/mock/fp_sensor_mock.c
@@ -8,12 +8,12 @@
* @brief Mock fpsensor private driver
*/
-#include <stdlib.h>
-
#include "common.h"
#include "fpsensor.h"
#include "mock/fp_sensor_mock.h"
+#include <stdlib.h>
+
#ifndef TEST_BUILD
#error "Mocks should only be in the test build."
#endif
diff --git a/common/mock/fpsensor_crypto_mock.c b/common/mock/fpsensor_crypto_mock.c
index f2cc425c8f..334f98300a 100644
--- a/common/mock/fpsensor_crypto_mock.c
+++ b/common/mock/fpsensor_crypto_mock.c
@@ -7,16 +7,17 @@
* @file fpsensor_crypto_mock.c
* @brief Mock fpsensor_crypto library
*/
-#include "sha256.h"
-#include <stdio.h>
-#include <stdint.h>
-#include <string.h>
#include "assert.h"
#include "compile_time_macros.h"
#include "console.h"
#include "ec_commands.h"
#include "fpsensor_private.h"
#include "mock/fpsensor_crypto_mock.h"
+#include "sha256.h"
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
#ifndef TEST_BUILD
#error "Mocks should only be in the test build."
diff --git a/common/mock/fpsensor_state_mock.c b/common/mock/fpsensor_state_mock.c
index cbeb29ae3c..d71285c1de 100644
--- a/common/mock/fpsensor_state_mock.c
+++ b/common/mock/fpsensor_state_mock.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <stddef.h>
-#include <string.h>
-
#include "common.h"
#include "driver/fingerprint/fpsensor.h"
#include "ec_commands.h"
#include "test_util.h"
+#include <stddef.h>
+#include <string.h>
+
#ifndef TEST_BUILD
#error "Mocks should only be in the test build."
#endif
diff --git a/common/mock/mkbp_events_mock.c b/common/mock/mkbp_events_mock.c
index 3f4d76b659..559cb1494d 100644
--- a/common/mock/mkbp_events_mock.c
+++ b/common/mock/mkbp_events_mock.c
@@ -8,11 +8,11 @@
* @brief Mock event handling for MKBP keyboard protocol
*/
-#include <stdint.h>
-
#include "common.h"
#include "mock/mkbp_events_mock.h"
+#include <stdint.h>
+
#ifndef TEST_BUILD
#error "Mocks should only be in the test build."
#endif
diff --git a/common/mock/rollback_latest_mock.c b/common/mock/rollback_latest_mock.c
index ab62645a1c..b3433246d7 100644
--- a/common/mock/rollback_latest_mock.c
+++ b/common/mock/rollback_latest_mock.c
@@ -8,13 +8,13 @@
* @brief Mock rollback block library
*/
-#include <string.h>
-
#include "common.h"
#include "compile_time_macros.h"
-#include "util.h"
#include "mock/rollback_latest_mock.h"
#include "rollback_private.h"
+#include "util.h"
+
+#include <string.h>
#ifndef TEST_BUILD
#error "Mocks should only be in the test build."
diff --git a/common/mock/rollback_mock.c b/common/mock/rollback_mock.c
index e68616df53..9395248a61 100644
--- a/common/mock/rollback_mock.c
+++ b/common/mock/rollback_mock.c
@@ -8,13 +8,13 @@
* @brief Mock rollback block library
*/
-#include <stdint.h>
-#include <string.h>
-
#include "common.h"
#include "compile_time_macros.h"
-#include "util.h"
#include "mock/rollback_mock.h"
+#include "util.h"
+
+#include <stdint.h>
+#include <string.h>
#ifndef TEST_BUILD
#error "Mocks should only be in the test build."
diff --git a/common/mock/usb_mux_mock.c b/common/mock/usb_mux_mock.c
index 815cdf777c..b612f47d4f 100644
--- a/common/mock/usb_mux_mock.c
+++ b/common/mock/usb_mux_mock.c
@@ -6,9 +6,9 @@
#include "common.h"
#include "console.h"
-#include "usb_mux.h"
-#include "mock/usb_mux_mock.h"
#include "memory.h"
+#include "mock/usb_mux_mock.h"
+#include "usb_mux.h"
#ifndef CONFIG_COMMON_RUNTIME
#define cprints(format, args...)
diff --git a/common/mock/usb_pd_dpm_mock.c b/common/mock/usb_pd_dpm_mock.c
index 158c53c650..66b7ccfc2b 100644
--- a/common/mock/usb_pd_dpm_mock.c
+++ b/common/mock/usb_pd_dpm_mock.c
@@ -8,9 +8,9 @@
* Refer to USB PD 3.0 spec, version 2.0, sections 8.2 and 8.3
*/
-#include "usb_pd.h"
-#include "mock/usb_pd_dpm_mock.h"
#include "memory.h"
+#include "mock/usb_pd_dpm_mock.h"
+#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#ifndef TEST_BUILD
@@ -49,7 +49,7 @@ void dpm_set_mode_exit_request(int port)
{
}
-void dpm_run(int port)
+void dpm_run(int port, int evt, int en)
{
}
@@ -95,3 +95,7 @@ int dpm_get_status_msg(int port, uint8_t *msg, uint32_t *len)
void dpm_handle_alert(int port, uint32_t ado)
{
}
+
+void dpm_set_pe_ready(int port, bool enable)
+{
+}
diff --git a/common/mock/usb_pe_sm_mock.c b/common/mock/usb_pe_sm_mock.c
index 24861a73f9..38df938c46 100644
--- a/common/mock/usb_pe_sm_mock.c
+++ b/common/mock/usb_pe_sm_mock.c
@@ -7,11 +7,11 @@
#include "common.h"
#include "console.h"
-#include "usb_pd.h"
-#include "usb_pe_sm.h"
-#include "mock/usb_pe_sm_mock.h"
#include "memory.h"
+#include "mock/usb_pe_sm_mock.h"
+#include "usb_pd.h"
#include "usb_pd_tcpm.h"
+#include "usb_pe_sm.h"
#ifndef CONFIG_COMMON_RUNTIME
#define cprints(format, args...)
diff --git a/common/mock/usb_prl_mock.c b/common/mock/usb_prl_mock.c
index df61cfaf95..769cd6073c 100644
--- a/common/mock/usb_prl_mock.c
+++ b/common/mock/usb_prl_mock.c
@@ -4,16 +4,17 @@
*
* Mock Protocol Layer module.
*/
-#include <string.h>
#include "common.h"
-#include "usb_emsg.h"
-#include "usb_pe_sm.h"
-#include "usb_prl_sm.h"
#include "mock/usb_prl_mock.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
+#include "usb_emsg.h"
#include "usb_pd_tcpm.h"
+#include "usb_pe_sm.h"
+#include "usb_prl_sm.h"
+
+#include <string.h>
#ifndef TEST_BUILD
#error "Mocks should only be in the test build."
diff --git a/common/mock/usb_tc_sm_mock.c b/common/mock/usb_tc_sm_mock.c
index 5badc6eba6..6adf6b3246 100644
--- a/common/mock/usb_tc_sm_mock.c
+++ b/common/mock/usb_tc_sm_mock.c
@@ -8,9 +8,9 @@
#include "common.h"
#include "console.h"
#include "ec_commands.h"
-#include "usb_tc_sm.h"
-#include "mock/usb_tc_sm_mock.h"
#include "memory.h"
+#include "mock/usb_tc_sm_mock.h"
+#include "usb_tc_sm.h"
#ifndef CONFIG_COMMON_RUNTIME
#define cprints(format, args...)
diff --git a/common/motion_lid.c b/common/motion_lid.c
index d8445bb3d4..878d471ed4 100644
--- a/common/motion_lid.c
+++ b/common/motion_lid.c
@@ -5,8 +5,8 @@
/* Motion sense module to read from various motion sensors. */
-#include "acpi.h"
#include "accelgyro.h"
+#include "acpi.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
@@ -20,8 +20,8 @@
#include "motion_sense.h"
#include "power.h"
#include "tablet_mode.h"
-#include "timer.h"
#include "task.h"
+#include "timer.h"
#include "util.h"
/* Console output macros */
diff --git a/common/motion_sense.c b/common/motion_sense.c
index c08909d24e..0b72a69780 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -20,17 +20,17 @@
#include "lightbar.h"
#include "math_util.h"
#include "mkbp_event.h"
-#include "motion_sense.h"
-#include "motion_sense_fifo.h"
#include "motion_lid.h"
#include "motion_orientation.h"
+#include "motion_sense.h"
+#include "motion_sense_fifo.h"
#include "online_calibration.h"
-#include "printf.h"
#include "power.h"
+#include "printf.h"
#include "queue.h"
#include "tablet_mode.h"
-#include "timer.h"
#include "task.h"
+#include "timer.h"
#include "util.h"
/* Console output macros */
@@ -81,6 +81,13 @@ static int init_sensor_mutex(const struct device *dev)
SYS_INIT(init_sensor_mutex, POST_KERNEL, 50);
#endif /* CONFIG_ZEPHYR */
+#ifdef CONFIG_LID_ANGLE
+__attribute__((weak)) int sensor_board_is_lid_angle_available(void)
+{
+ return 1;
+}
+#endif
+
static inline int
motion_sensor_in_forced_mode(const struct motion_sensor_t *sensor)
{
@@ -111,7 +118,8 @@ motion_sensor_time_to_read(const timestamp_t *ts,
sensor->next_collection - motion_min_interval);
}
-static enum sensor_config motion_sense_get_ec_config(void)
+STATIC_IF_NOT(CONFIG_ZTEST)
+enum sensor_config motion_sense_get_ec_config(void)
{
switch (sensor_active) {
case SENSOR_ACTIVE_S0:
@@ -123,7 +131,7 @@ static enum sensor_config motion_sense_get_ec_config(void)
default:
CPRINTS("get_ec_config: Invalid active state: %x",
sensor_active);
- return SENSOR_CONFIG_MAX;
+ return SENSOR_CONFIG_EC_S5;
}
}
/* motion_sense_set_data_rate
@@ -321,7 +329,12 @@ static void motion_sense_switch_sensor_rate(void)
body_detect_set_enable(false);
break;
case SENSOR_ACTIVE_S0:
- body_detect_set_enable(was_enabled);
+ /* force to enable the body detection in S0 */
+ if (IS_ENABLED(
+ CONFIG_BODY_DETECTION_ALWAYS_ENABLE_IN_S0))
+ body_detect_set_enable(true);
+ else
+ body_detect_set_enable(was_enabled);
break;
default:
break;
@@ -1422,7 +1435,8 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args)
default:
/* Call other users of the motion task */
if (IS_ENABLED(CONFIG_LID_ANGLE) &&
- (ret == EC_RES_INVALID_PARAM))
+ (ret == EC_RES_INVALID_PARAM) &&
+ sensor_board_is_lid_angle_available())
ret = host_cmd_motion_lid(args);
return ret;
}
diff --git a/common/motion_sense_fifo.c b/common/motion_sense_fifo.c
index d3887fa08f..fd1bfda88c 100644
--- a/common/motion_sense_fifo.c
+++ b/common/motion_sense_fifo.c
@@ -6,14 +6,14 @@
#include "accelgyro.h"
#include "console.h"
#include "hwtimer.h"
+#include "math_util.h"
#include "mkbp_event.h"
#include "motion_sense_fifo.h"
+#include "online_calibration.h"
+#include "stdbool.h"
#include "tablet_mode.h"
#include "task.h"
#include "util.h"
-#include "math_util.h"
-#include "online_calibration.h"
-#include "stdbool.h"
#define CPRINTS(format, args...) cprints(CC_MOTION_SENSE, format, ##args)
diff --git a/common/newton_fit.c b/common/newton_fit.c
index 5d217bc63d..3ba01dbd90 100644
--- a/common/newton_fit.c
+++ b/common/newton_fit.c
@@ -5,9 +5,10 @@
#include "common.h"
#include "console.h"
-#include "newton_fit.h"
#include "math.h"
#include "math_util.h"
+#include "newton_fit.h"
+
#include <string.h>
#define CPRINTS(fmt, args...) cprints(CC_MOTION_SENSE, fmt, ##args)
diff --git a/common/ocpc.c b/common/ocpc.c
index c27cf4efe5..88308e5bc7 100644
--- a/common/ocpc.c
+++ b/common/ocpc.c
@@ -58,6 +58,7 @@ static int k_d = KD;
static int k_p_div = KP_DIV;
static int k_i_div = KI_DIV;
static int k_d_div = KD_DIV;
+static int drive_limit = CONFIG_OCPC_DEF_DRIVELIMIT_MILLIVOLTS;
static int debug_output;
static int viz_output;
@@ -247,9 +248,10 @@ enum ec_error_list ocpc_calc_resistances(struct ocpc_data *ocpc,
return EC_SUCCESS;
}
-int ocpc_config_secondary_charger(int *desired_input_current,
- struct ocpc_data *ocpc, int voltage_mv,
- int current_ma)
+int ocpc_config_secondary_charger(int *desired_charger_input_current,
+ struct ocpc_data *ocpc,
+ int desired_batt_voltage_mv,
+ int desired_batt_current_ma)
{
int rv = EC_SUCCESS;
struct batt_params batt;
@@ -285,8 +287,8 @@ int ocpc_config_secondary_charger(int *desired_input_current,
batt_info = battery_get_info();
- if (current_ma == 0) {
- vsys_target = voltage_mv;
+ if (desired_batt_current_ma == 0) {
+ vsys_target = desired_batt_voltage_mv;
goto set_vsys;
}
@@ -317,8 +319,8 @@ int ocpc_config_secondary_charger(int *desired_input_current,
if (!timestamp_expired(delay, NULL))
return EC_ERROR_BUSY;
- result = charger_set_vsys_compensation(chgnum, ocpc, current_ma,
- voltage_mv);
+ result = charger_set_vsys_compensation(
+ chgnum, ocpc, desired_batt_current_ma, desired_batt_voltage_mv);
switch (result) {
case EC_SUCCESS:
/* No further action required, so we're done here. */
@@ -376,8 +378,9 @@ int ocpc_config_secondary_charger(int *desired_input_current,
if (batt.desired_voltage) {
if (((batt.voltage < batt_info->voltage_min) ||
((batt.voltage < batt_info->voltage_normal) &&
- (current_ma >= 0) &&
- (current_ma <= batt_info->precharge_current))) &&
+ (desired_batt_current_ma >= 0) &&
+ (desired_batt_current_ma <=
+ batt_info->precharge_current))) &&
(ph != PHASE_PRECHARGE)) {
/*
* If the charger IC doesn't support the linear charge
@@ -389,11 +392,12 @@ int ocpc_config_secondary_charger(int *desired_input_current,
} else if (result == EC_SUCCESS) {
CPRINTS("OCPC: Enabling linear precharge");
ph = PHASE_PRECHARGE;
- i_ma = current_ma;
+ i_ma = desired_batt_current_ma;
}
} else if (batt.voltage < batt.desired_voltage) {
if ((ph == PHASE_PRECHARGE) &&
- (current_ma > batt_info->precharge_current)) {
+ (desired_batt_current_ma >
+ batt_info->precharge_current)) {
/*
* Precharge phase is complete. Now set the
* target VSYS to the battery voltage to prevent
@@ -422,7 +426,7 @@ int ocpc_config_secondary_charger(int *desired_input_current,
if ((ph != PHASE_PRECHARGE) && (ph < PHASE_CV_TRIP))
ph = PHASE_CC;
- i_ma = current_ma;
+ i_ma = desired_batt_current_ma;
} else {
/*
* Once the battery voltage reaches the desired voltage,
@@ -452,6 +456,16 @@ int ocpc_config_secondary_charger(int *desired_input_current,
*/
if (ocpc->last_vsys != OCPC_UNINIT) {
error = i_ma - batt.current;
+
+ /* Uses charger input error if controller is proportional only.
+ */
+ if ((k_i == 0) && (k_d == 0)) {
+ int charger_input_error =
+ (*desired_charger_input_current -
+ ocpc->secondary_ibus_ma);
+ error = MIN(error, charger_input_error);
+ }
+
/* Add some hysteresis. */
if (ABS(error) < (i_step / 2))
error = 0;
@@ -490,11 +504,15 @@ int ocpc_config_secondary_charger(int *desired_input_current,
* VSYS rather quickly, but we'll be conservative on
* increasing VSYS.
*/
- if (drive > 10)
- drive = 10;
+ if (drive > drive_limit)
+ drive = drive_limit;
CPRINTS_DBG("drive = %d", drive);
}
+ CPRINTS_DBG("##DATA = %d %d %d %d %d %d %d", batt.desired_current,
+ batt.current, *desired_charger_input_current,
+ ocpc->secondary_ibus_ma, error, ocpc->last_vsys, drive);
+
/*
* For the pre-charge phase, simply keep the VSYS target at the desired
* voltage.
@@ -537,7 +555,7 @@ int ocpc_config_secondary_charger(int *desired_input_current,
/* If we're input current limited, we cannot increase VSYS any more. */
CPRINTS_DBG("OCPC: Inst. Input Current: %dmA (Limit: %dmA)",
- ocpc->secondary_ibus_ma, *desired_input_current);
+ ocpc->secondary_ibus_ma, *desired_charger_input_current);
if (charger_is_icl_reached(chgnum, &icl_reached) != EC_SUCCESS) {
/*
@@ -546,7 +564,7 @@ int ocpc_config_secondary_charger(int *desired_input_current,
* 95% of the limit.
*/
if (ocpc->secondary_ibus_ma >=
- (*desired_input_current * 95 / 100))
+ (*desired_charger_input_current * 95 / 100))
icl_reached = true;
}
@@ -765,3 +783,16 @@ static int command_ocpcpid(int argc, const char **argv)
DECLARE_SAFE_CONSOLE_COMMAND(ocpcpid, command_ocpcpid,
"[<k/p/d> <numerator> <denominator>]",
"Show/Set PID constants for OCPC PID loop");
+
+static int command_ocpcdrvlmt(int argc, const char **argv)
+{
+ if (argc == 2) {
+ drive_limit = atoi(argv[1]);
+ }
+
+ /* Print the current constants */
+ ccprintf("Drive Limit = %d\n", drive_limit);
+ return EC_SUCCESS;
+}
+DECLARE_SAFE_CONSOLE_COMMAND(ocpcdrvlmt, command_ocpcdrvlmt, "[<drive_limit>]",
+ "Show/Set drive limit for OCPC PID loop");
diff --git a/common/online_calibration.c b/common/online_calibration.c
index 2d79c6ae1d..a56aa0dce7 100644
--- a/common/online_calibration.c
+++ b/common/online_calibration.c
@@ -3,19 +3,19 @@
* found in the LICENSE file.
*/
+#include "accel_cal.h"
#include "accelgyro.h"
#include "atomic.h"
-#include "hwtimer.h"
-#include "online_calibration.h"
#include "common.h"
+#include "ec_commands.h"
+#include "gyro_cal.h"
+#include "hwtimer.h"
#include "mag_cal.h"
+#include "mkbp_event.h"
+#include "online_calibration.h"
+#include "task.h"
#include "util.h"
#include "vec3.h"
-#include "task.h"
-#include "ec_commands.h"
-#include "accel_cal.h"
-#include "mkbp_event.h"
-#include "gyro_cal.h"
#define CPRINTS(format, args...) cprints(CC_MOTION_SENSE, format, ##args)
diff --git a/common/panic_output.c b/common/panic_output.c
index 2f92e65514..55d551f548 100644
--- a/common/panic_output.c
+++ b/common/panic_output.c
@@ -175,8 +175,10 @@ uintptr_t get_panic_data_start(void)
if (IS_ENABLED(CONFIG_BOARD_NATIVE_POSIX))
return (uintptr_t)pdata_ptr;
+ /* LCOV_EXCL_START - Can't cover non posix lines (yet) */
return ((uintptr_t)CONFIG_PANIC_DATA_BASE + CONFIG_PANIC_DATA_SIZE -
pdata_ptr->struct_size);
+ /* LCOV_EXCL_STOP */
}
static uint32_t get_panic_data_size(void)
@@ -199,6 +201,7 @@ struct panic_data *get_panic_data_write(void)
return pdata_ptr;
}
#else
+/* LCOV_EXCL_START - Can't cover non posix lines (yet) */
struct panic_data *get_panic_data_write(void)
{
/*
@@ -208,7 +211,7 @@ struct panic_data *get_panic_data_write(void)
* end of RAM.
*/
struct panic_data *const pdata_ptr = PANIC_DATA_PTR;
- const struct jump_data *jdata_ptr;
+ struct jump_data *jdata_ptr;
uintptr_t data_begin;
size_t move_size;
int delta;
@@ -264,6 +267,16 @@ struct panic_data *get_panic_data_write(void)
move_size = 0;
}
+ /* Check if there's enough space for jump tags after move */
+ if (data_begin - move_size < JUMP_DATA_MIN_ADDRESS) {
+ /* Not enough room for jump tags, clear tags.
+ * TODO(b/251190975): This failure should be reported
+ * in the panic data structure for more visibility.
+ */
+ move_size -= jdata_ptr->jump_tag_total;
+ jdata_ptr->jump_tag_total = 0;
+ }
+
data_begin -= move_size;
if (move_size != 0) {
@@ -282,6 +295,7 @@ struct panic_data *get_panic_data_write(void)
return pdata_ptr;
}
+/* LCOV_EXCL_STOP */
#endif /* CONFIG_BOARD_NATIVE_POSIX */
static void panic_init(void)
diff --git a/common/power_button.c b/common/power_button.c
index 36d7e510d2..484d25154a 100644
--- a/common/power_button.c
+++ b/common/power_button.c
@@ -184,6 +184,15 @@ static void power_button_change_deferred(void)
}
DECLARE_DEFERRED(power_button_change_deferred);
+static void power_button_simulate_deferred(void)
+{
+ ccprintf("Simulating %s release.\n", power_button.name);
+ simulate_power_pressed = 0;
+ power_button_is_stable = 0;
+ power_button_change_deferred();
+}
+DECLARE_DEFERRED(power_button_simulate_deferred);
+
void power_button_interrupt(enum gpio_signal signal)
{
/*
@@ -205,15 +214,9 @@ void power_button_simulate_press(unsigned int duration)
ccprintf("Simulating %d ms %s press.\n", duration, power_button.name);
simulate_power_pressed = 1;
power_button_is_stable = 0;
- hook_call_deferred(&power_button_change_deferred_data, 0);
-
- if (duration > 0)
- msleep(duration);
-
- ccprintf("Simulating %s release.\n", power_button.name);
- simulate_power_pressed = 0;
- power_button_is_stable = 0;
- hook_call_deferred(&power_button_change_deferred_data, 0);
+ power_button_change_deferred();
+ hook_call_deferred(&power_button_simulate_deferred_data,
+ duration * MSEC);
}
/*****************************************************************************/
diff --git a/common/pwm_kblight.c b/common/pwm_kblight.c
index 5748bef700..bd7e07644d 100644
--- a/common/pwm_kblight.c
+++ b/common/pwm_kblight.c
@@ -19,11 +19,6 @@ static int kblight_pwm_set(int percent)
return EC_SUCCESS;
}
-static int kblight_pwm_get(void)
-{
- return pwm_get_duty(kblight_pwm_ch);
-}
-
static int kblight_pwm_init(void)
{
/* dnojiri: Why do we need save/restore setting over sysjump? */
@@ -46,7 +41,6 @@ static int kblight_pwm_get_enabled(void)
const struct kblight_drv kblight_pwm = {
.init = kblight_pwm_init,
.set = kblight_pwm_set,
- .get = kblight_pwm_get,
.enable = kblight_pwm_enable,
.get_enabled = kblight_pwm_get_enabled,
};
diff --git a/common/rgb_keyboard.c b/common/rgb_keyboard.c
index 5f130ee776..0036cdcd16 100644
--- a/common/rgb_keyboard.c
+++ b/common/rgb_keyboard.c
@@ -2,8 +2,6 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <stdbool.h>
-
#include "atomic.h"
#include "common.h"
#include "console.h"
@@ -18,6 +16,8 @@
#include "timer.h"
#include "util.h"
+#include <stdbool.h>
+
/* Console output macros */
#define CPUTS(outstr) cputs(CC_RGBKBD, outstr)
#define CPRINTF(fmt, args...) cprintf(CC_RGBKBD, "RGBKBD: " fmt, ##args)
@@ -476,7 +476,6 @@ static void rgbkbd_reset(void)
const struct kblight_drv kblight_rgbkbd = {
.init = rgbkbd_init,
.set = rgbkbd_kblight_set,
- .get = NULL,
.enable = rgbkbd_enable,
.get_enabled = rgbkbd_get_enabled,
};
diff --git a/common/shmalloc.c b/common/shmalloc.c
index 6cbf213227..37b7b2c736 100644
--- a/common/shmalloc.c
+++ b/common/shmalloc.c
@@ -5,8 +5,6 @@
*/
/* Malloc/free memory module for Chrome EC */
-#include <stdint.h>
-
#include "common.h"
#include "hooks.h"
#include "link_defs.h"
@@ -15,6 +13,8 @@
#include "task.h"
#include "util.h"
+#include <stdint.h>
+
static struct mutex shmem_lock;
#ifndef TEST_SHMALLOC
diff --git a/common/spi/flash_reg/CMakeLists.txt b/common/spi/flash_reg/CMakeLists.txt
index fda467d2e4..55708ac57e 100644
--- a/common/spi/flash_reg/CMakeLists.txt
+++ b/common/spi/flash_reg/CMakeLists.txt
@@ -6,6 +6,7 @@ cmake_minimum_required(VERSION 3.20.0)
# Create the library
if(BOARD STREQUAL unit_testing)
+ find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
add_library(spi_flash_reg)
else()
zephyr_library_named(spi_flash_reg)
@@ -45,11 +46,8 @@ target_include_directories(spi_flash_reg PUBLIC public)
if(BOARD STREQUAL unit_testing)
project(flash_reg)
- # Set the sources for the test (must be done before find_package)
- set(SOURCES src/spi_flash_reg_test.c)
-
- # Create the unittest libraries and binary
- find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
+ # Set the sources for the test
+ target_sources(testbinary PRIVATE src/spi_flash_reg_test.c)
# Link the library being tested
target_link_libraries(testbinary PRIVATE spi_flash_reg)
diff --git a/common/spi/flash_reg/src/spi_flash_reg_test.c b/common/spi/flash_reg/src/spi_flash_reg_test.c
index 4a6a7a5edf..b9a45476b1 100644
--- a/common/spi/flash_reg/src/spi_flash_reg_test.c
+++ b/common/spi/flash_reg/src/spi_flash_reg_test.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "common.h"
#include "spi_flash_reg.h"
+#include <zephyr/ztest.h>
+
ZTEST_SUITE(flash_reg_to_protect, NULL, NULL, NULL, NULL, NULL);
ZTEST(flash_reg_to_protect, test_invalid_args)
diff --git a/common/spi_flash.c b/common/spi_flash.c
index 8eaf3e8406..1540c7bb33 100644
--- a/common/spi_flash.c
+++ b/common/spi_flash.c
@@ -9,6 +9,8 @@
#include "builtin/assert.h"
#include "common.h"
#include "console.h"
+#include "ec_commands.h"
+#include "flash.h"
#include "host_command.h"
#include "shared_mem.h"
#include "spi.h"
@@ -17,8 +19,6 @@
#include "timer.h"
#include "util.h"
#include "watchdog.h"
-#include "ec_commands.h"
-#include "flash.h"
/*
* Time to sleep when chip is busy
diff --git a/common/spi_nor.c b/common/spi_nor.c
index 015cb7077c..1eca5d806f 100644
--- a/common/spi_nor.c
+++ b/common/spi_nor.c
@@ -7,13 +7,13 @@
#include "common.h"
#include "console.h"
-#include "spi_nor.h"
+#include "sfdp.h"
#include "shared_mem.h"
-#include "util.h"
-#include "task.h"
#include "spi.h"
-#include "sfdp.h"
+#include "spi_nor.h"
+#include "task.h"
#include "timer.h"
+#include "util.h"
#include "watchdog.h"
#ifdef CONFIG_SPI_NOR_DEBUG
diff --git a/common/stillness_detector.c b/common/stillness_detector.c
index c43e19873e..f81c51ef3a 100644
--- a/common/stillness_detector.c
+++ b/common/stillness_detector.c
@@ -6,6 +6,7 @@
#include "common.h"
#include "stillness_detector.h"
#include "timer.h"
+
#include <string.h>
static void still_det_reset(struct still_det *still_det)
diff --git a/common/system.c b/common/system.c
index 375cca2882..e10712259c 100644
--- a/common/system.c
+++ b/common/system.c
@@ -27,6 +27,7 @@
#ifdef CONFIG_MPU
#include "mpu.h"
#endif
+#include "cros_version.h"
#include "panic.h"
#include "sysjump.h"
#include "system.h"
@@ -36,7 +37,6 @@
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#include "util.h"
-#include "cros_version.h"
#include "watchdog.h"
/* Console output macros */
@@ -67,6 +67,11 @@ static enum ec_reboot_cmd reboot_at_shutdown;
static enum sysinfo_flags system_info_flags;
+/* Ensure enough space for panic_data, jump_data and at least one jump tag */
+BUILD_ASSERT((sizeof(struct panic_data) + sizeof(struct jump_data) +
+ JUMP_TAG_MAX_SIZE) <= CONFIG_PRESERVED_END_OF_RAM_SIZE,
+ "End of ram data size is too small for panic and jump data");
+
STATIC_IF(CONFIG_HIBERNATE) uint32_t hibernate_seconds;
STATIC_IF(CONFIG_HIBERNATE) uint32_t hibernate_microseconds;
@@ -349,15 +354,24 @@ test_mockable int system_jumped_late(void)
int system_add_jump_tag(uint16_t tag, int version, int size, const void *data)
{
struct jump_tag *t;
+ size_t new_entry_size;
/* Only allowed during a sysjump */
if (!jdata || jdata->magic != JUMP_DATA_MAGIC)
return EC_ERROR_UNKNOWN;
/* Make room for the new tag */
- if (size > 255)
+ if (size > JUMP_TAG_MAX_SIZE)
+ return EC_ERROR_INVAL;
+
+ new_entry_size = ROUNDUP4(size) + sizeof(struct jump_tag);
+
+ if (system_usable_ram_end() - new_entry_size < JUMP_DATA_MIN_ADDRESS) {
+ ccprintf("ERROR: out of space for jump tags\n");
return EC_ERROR_INVAL;
- jdata->jump_tag_total += ROUNDUP4(size) + sizeof(struct jump_tag);
+ }
+
+ jdata->jump_tag_total += new_entry_size;
t = (struct jump_tag *)system_usable_ram_end();
t->tag = tag;
@@ -378,6 +392,10 @@ test_mockable const uint8_t *system_get_jump_tag(uint16_t tag, int *version,
if (!jdata)
return NULL;
+ /* Ensure system_usable_ram_end() is within bounds */
+ if (system_usable_ram_end() < JUMP_DATA_MIN_ADDRESS)
+ return NULL;
+
/* Search through tag data for a match */
while (used < jdata->jump_tag_total) {
/* Check the next tag */
@@ -918,6 +936,18 @@ void system_common_pre_init(void)
else
delta = sizeof(struct jump_data) - jdata->struct_size;
+ /*
+ * Check if enough space for jump data.
+ * Clear jump data and return if not.
+ */
+ if (system_usable_ram_end() < JUMP_DATA_MIN_ADDRESS) {
+ /* TODO(b/251190975): This failure should be reported
+ * in the panic data structure for more visibility.
+ */
+ memset(jdata, 0, sizeof(struct jump_data));
+ return;
+ }
+
if (delta && jdata->jump_tag_total) {
uint8_t *d = (uint8_t *)system_usable_ram_end();
memmove(d, d + delta, jdata->jump_tag_total);
diff --git a/common/tablet_mode.c b/common/tablet_mode.c
index 576e80c0ef..18e97e91db 100644
--- a/common/tablet_mode.c
+++ b/common/tablet_mode.c
@@ -28,6 +28,12 @@ static uint32_t tablet_mode;
*/
static bool tablet_mode_forced;
+/*
+ * Console command can force the value of tablet_mode. If tablet_mode_force is
+ * false, use stored tablet mode value before it was (possibly) overridden.
+ */
+static uint32_t tablet_mode_store;
+
/* True if GMR sensor is reporting 360 degrees. */
static bool gmr_sensor_at_360;
@@ -62,27 +68,51 @@ static void notify_tablet_mode_change(void)
void tablet_set_mode(int mode, uint32_t trigger)
{
- uint32_t old_mode = tablet_mode;
-
- /* If tablet_mode is forced via a console command, ignore set. */
- if (tablet_mode_forced)
- return;
+ uint32_t new_mode = tablet_mode_forced ? tablet_mode_store :
+ tablet_mode;
+ uint32_t old_mode = 0;
if (disabled) {
- CPRINTS("Tablet mode set while disabled (ignoring)!");
+ /*
+ * If tablet mode is being forced by the user, then this logging
+ * would be misleading since the mode wouldn't change anyway, so
+ * skip it.
+ */
+ if (!tablet_mode_forced)
+ CPRINTS("Tablet mode set while disabled (ignoring)!");
return;
}
if (gmr_sensor_at_360 && !mode) {
- CPRINTS("Ignoring tablet mode exit while gmr sensor "
- "reports 360-degree tablet mode.");
+ /*
+ * If tablet mode is being forced by the user, then this logging
+ * would be misleading since the mode wouldn't change anyway, so
+ * skip it.
+ */
+ if (!tablet_mode_forced)
+ CPRINTS("Ignoring tablet mode exit while gmr sensor "
+ "reports 360-degree tablet mode.");
return;
}
if (mode)
- tablet_mode |= trigger;
+ new_mode |= trigger;
else
- tablet_mode &= ~trigger;
+ new_mode &= ~trigger;
+
+ if (tablet_mode_forced) {
+ /*
+ * Save the current mode based on the HW orientation, so we
+ * apply the correct mode if tablet mode no longer forced in the
+ * future. Don't notify of the tablet mode change yet, since
+ * that will be done as part of handling 'tabletmode reset'.
+ */
+ tablet_mode_store = new_mode;
+ return;
+ }
+
+ old_mode = tablet_mode;
+ tablet_mode = new_mode;
/* Boolean comparison */
if (!tablet_mode == !old_mode)
@@ -173,11 +203,42 @@ void gmr_tablet_switch_disable(void)
}
#endif
+static enum ec_status tablet_mode_command(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_set_tablet_mode *p = args->params;
+
+ if (tablet_mode_forced == false)
+ tablet_mode_store = tablet_mode;
+
+ switch (p->tablet_mode) {
+ case TABLET_MODE_DEFAULT:
+ tablet_mode = tablet_mode_store;
+ tablet_mode_forced = false;
+ break;
+ case TABLET_MODE_FORCE_TABLET:
+ tablet_mode = TABLET_TRIGGER_LID;
+ tablet_mode_forced = true;
+ break;
+ case TABLET_MODE_FORCE_CLAMSHELL:
+ tablet_mode = 0;
+ tablet_mode_forced = true;
+ break;
+ default:
+ CPRINTS("Invalid EC_CMD_SET_TABLET_MODE parameter: %d",
+ p->tablet_mode);
+ return EC_RES_INVALID_PARAM;
+ }
+
+ notify_tablet_mode_change();
+
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_SET_TABLET_MODE, tablet_mode_command,
+ EC_VER_MASK(0) | EC_VER_MASK(1));
+
#ifdef CONFIG_TABLET_MODE
static int command_settabletmode(int argc, const char **argv)
{
- static uint32_t tablet_mode_store;
-
if (argc == 1) {
print_tablet_mode();
return EC_SUCCESS;
diff --git a/common/test_util.c b/common/test_util.c
index 659476fc17..fd8caba10a 100644
--- a/common/test_util.c
+++ b/common/test_util.c
@@ -11,7 +11,6 @@
#include <stdlib.h>
#endif
-#include <assert.h>
#include "console.h"
#include "hooks.h"
#include "host_command.h"
@@ -20,6 +19,8 @@
#include "test_util.h"
#include "util.h"
+#include <assert.h>
+
struct test_util_tag {
uint8_t error_count;
};
diff --git a/common/timer.c b/common/timer.c
index d0fd1eca6e..bf2a731a1d 100644
--- a/common/timer.c
+++ b/common/timer.c
@@ -12,9 +12,9 @@
#include "hooks.h"
#include "hwtimer.h"
#include "system.h"
-#include "util.h"
#include "task.h"
#include "timer.h"
+#include "util.h"
#include "watchdog.h"
#ifdef CONFIG_ZEPHYR
diff --git a/common/uart_buffering.c b/common/uart_buffering.c
index 1aa6e9ef35..f3d150dfda 100644
--- a/common/uart_buffering.c
+++ b/common/uart_buffering.c
@@ -5,8 +5,6 @@
/* Common code to do UART buffering and printing */
-#include <stdarg.h>
-
#include "common.h"
#include "console.h"
#include "hooks.h"
@@ -19,6 +17,8 @@
#include "uart.h"
#include "util.h"
+#include <stdarg.h>
+
/* Macros to advance in the circular buffers */
#define TX_BUF_NEXT(i) (((i) + 1) & (CONFIG_UART_TX_BUF_SIZE - 1))
#define RX_BUF_NEXT(i) (((i) + 1) & (CONFIG_UART_RX_BUF_SIZE - 1))
diff --git a/common/uart_hostcmd.c b/common/uart_hostcmd.c
index 7b4ff5b461..506a49221d 100644
--- a/common/uart_hostcmd.c
+++ b/common/uart_hostcmd.c
@@ -3,8 +3,8 @@
* found in the LICENSE file.
*/
-#include "config.h"
#include "common.h"
+#include "config.h"
#include "ec_commands.h"
#include "host_command.h"
#include "uart.h"
diff --git a/common/uart_printf.c b/common/uart_printf.c
index 6f8ebb5cbc..55b8a40cde 100644
--- a/common/uart_printf.c
+++ b/common/uart_printf.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <stddef.h>
-
#include "common.h"
#include "printf.h"
#include "uart.h"
+#include <stddef.h>
+
static int __tx_char(void *context, int c)
{
/*
@@ -31,9 +31,10 @@ int uart_putc(int c)
int uart_puts(const char *outstr)
{
/* Put all characters in the output buffer */
- while (*outstr) {
- if (__tx_char(NULL, *outstr++) != 0)
+ for (; *outstr != '\0'; ++outstr) {
+ if (__tx_char(NULL, *outstr) != 0) {
break;
+ }
}
uart_tx_start();
@@ -44,30 +45,34 @@ int uart_puts(const char *outstr)
int uart_put(const char *out, int len)
{
+ int written;
+
/* Put all characters in the output buffer */
- while (len--) {
- if (__tx_char(NULL, *out++) != 0)
+ for (written = 0; written < len; written++) {
+ if (__tx_char(NULL, *out++) != 0) {
break;
+ }
}
uart_tx_start();
- /* Successful if we consumed all output */
- return len ? EC_ERROR_OVERFLOW : EC_SUCCESS;
+ return written;
}
int uart_put_raw(const char *out, int len)
{
+ int written;
+
/* Put all characters in the output buffer */
- while (len--) {
- if (uart_tx_char_raw(NULL, *out++) != 0)
+ for (written = 0; written < len; written++) {
+ if (uart_tx_char_raw(NULL, *out++) != 0) {
break;
+ }
}
uart_tx_start();
- /* Successful if we consumed all output */
- return len ? EC_ERROR_OVERFLOW : EC_SUCCESS;
+ return written;
}
int uart_vprintf(const char *format, va_list args)
diff --git a/common/uptime.c b/common/uptime.c
index 3b2c68fd34..1ce7e2a329 100644
--- a/common/uptime.c
+++ b/common/uptime.c
@@ -2,13 +2,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <stddef.h>
-
#include "chipset.h"
-#include "system.h"
#include "host_command.h"
+#include "system.h"
#include "util.h"
+#include <stddef.h>
+
static enum ec_status
host_command_get_uptime_info(struct host_cmd_handler_args *args)
{
diff --git a/common/usb_common.c b/common/usb_common.c
index b4fefb6cf7..a92b1e380f 100644
--- a/common/usb_common.c
+++ b/common/usb_common.c
@@ -17,9 +17,9 @@
#include "ec_commands.h"
#include "gpio.h"
#include "hooks.h"
+#include "host_command.h"
#include "mkbp_event.h"
#include "stdbool.h"
-#include "host_command.h"
#include "system.h"
#include "task.h"
#include "typec_control.h"
@@ -27,7 +27,7 @@
#include "usb_common.h"
#include "usb_mux.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_flags.h"
#include "usb_pd_tcpm.h"
#include "usb_pe_sm.h"
@@ -198,18 +198,6 @@ enum pd_cc_states pd_get_cc_state(enum tcpc_cc_voltage_status cc1,
return PD_CC_NONE;
}
-/**
- * This function checks the current CC status of the port partner
- * and returns true if the attached partner is debug accessory.
- */
-bool pd_is_debug_acc(int port)
-{
- enum pd_cc_states cc_state = pd_get_task_cc_state(port);
-
- return cc_state == PD_CC_UFP_DEBUG_ACC ||
- cc_state == PD_CC_DFP_DEBUG_ACC;
-}
-
__overridable int pd_board_check_request(uint32_t rdo, int pdo_cnt)
{
return EC_SUCCESS;
@@ -634,15 +622,17 @@ void pd_set_vbus_discharge(int port, int enable)
static mutex_t discharge_lock[CONFIG_USB_PD_PORT_MAX_COUNT];
#ifdef CONFIG_ZEPHYR
static bool inited[CONFIG_USB_PD_PORT_MAX_COUNT];
+#endif
+ if (port >= board_get_usb_pd_port_count())
+ return;
+
+#ifdef CONFIG_ZEPHYR
if (!inited[port]) {
(void)k_mutex_init(&discharge_lock[port]);
inited[port] = true;
}
#endif
- if (port >= board_get_usb_pd_port_count())
- return;
-
mutex_lock(&discharge_lock[port]);
enable &= !board_vbus_source_enabled(port);
diff --git a/common/usb_host_command.c b/common/usb_host_command.c
index 83a6e24a7d..0aeff40d39 100644
--- a/common/usb_host_command.c
+++ b/common/usb_host_command.c
@@ -7,13 +7,13 @@
#include "console.h"
#include "consumer.h"
#include "ec_commands.h"
-#include "queue_policies.h"
#include "host_command.h"
#include "printf.h"
+#include "queue_policies.h"
#include "system.h"
+#include "usb-stream.h"
#include "usb_api.h"
#include "usb_hw.h"
-#include "usb-stream.h"
#include "util.h"
#define CPUTS(outstr) cputs(CC_USB, outstr)
diff --git a/common/usb_i2c.c b/common/usb_i2c.c
index 8482ec0967..b1cd45c76a 100644
--- a/common/usb_i2c.c
+++ b/common/usb_i2c.c
@@ -4,21 +4,19 @@
*/
#include "common.h"
-#include "link_defs.h"
-#include "registers.h"
-#include "i2c.h"
-#include "usb_descriptor.h"
-#include "util.h"
-
-#include "common.h"
#include "console.h"
#include "consumer.h"
+#include "i2c.h"
+#include "link_defs.h"
#include "producer.h"
#include "queue.h"
#include "queue_policies.h"
+#include "registers.h"
#include "task.h"
#include "usb-stream.h"
+#include "usb_descriptor.h"
#include "usb_i2c.h"
+#include "util.h"
#define CPRINTS(format, args...) cprints(CC_I2C, format, ##args)
diff --git a/common/usb_pd_alt_mode_dfp.c b/common/usb_pd_alt_mode_dfp.c
index dc8543c920..6df0215274 100644
--- a/common/usb_pd_alt_mode_dfp.c
+++ b/common/usb_pd_alt_mode_dfp.c
@@ -13,8 +13,8 @@
#include "task_id.h"
#include "timer.h"
#include "typec_control.h"
-#include "usb_common.h"
#include "usb_charge.h"
+#include "usb_common.h"
#include "usb_dp_alt_mode.h"
#include "usb_mux.h"
#include "usb_pd.h"
diff --git a/common/usb_pd_console_cmd.c b/common/usb_pd_console_cmd.c
index 23f2a27b1e..5a1afe88a5 100644
--- a/common/usb_pd_console_cmd.c
+++ b/common/usb_pd_console_cmd.c
@@ -7,8 +7,8 @@
#include "console.h"
#include "usb_pd.h"
-#include "util.h"
#include "usb_pd_tcpm.h"
+#include "util.h"
#ifdef CONFIG_USB_PD_ALT_MODE_DFP
#ifdef CONFIG_CMD_USB_PD_PE
diff --git a/common/usb_pd_host_cmd.c b/common/usb_pd_host_cmd.c
index e3008d26fb..ea05de3457 100644
--- a/common/usb_pd_host_cmd.c
+++ b/common/usb_pd_host_cmd.c
@@ -5,8 +5,6 @@
* Host commands for USB-PD module.
*/
-#include <string.h>
-
#include "atomic.h"
#include "battery.h"
#include "charge_manager.h"
@@ -17,8 +15,10 @@
#include "tcpm/tcpm.h"
#include "usb_common.h"
#include "usb_mux.h"
-#include "usb_pd_tcpm.h"
#include "usb_pd.h"
+#include "usb_pd_tcpm.h"
+
+#include <string.h>
#ifdef CONFIG_COMMON_RUNTIME
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
diff --git a/common/usb_pd_pdo.c b/common/usb_pd_pdo.c
index 3141af34a9..66f5f3feac 100644
--- a/common/usb_pd_pdo.c
+++ b/common/usb_pd_pdo.c
@@ -4,8 +4,8 @@
*/
#include "usb_pd.h"
-#include "util.h"
#include "usb_pd_pdo.h"
+#include "util.h"
#ifndef CONFIG_USB_PD_CUSTOM_PDO
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c
index c63cde6301..036e253766 100644
--- a/common/usb_pd_policy.c
+++ b/common/usb_pd_policy.c
@@ -22,13 +22,13 @@
#include "task.h"
#include "tcpm/tcpm.h"
#include "timer.h"
-#include "util.h"
#include "usb_api.h"
#include "usb_common.h"
#include "usb_mux.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#include "usbc_ppc.h"
+#include "util.h"
#ifdef CONFIG_COMMON_RUNTIME
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
diff --git a/common/usb_pd_protocol.c b/common/usb_pd_protocol.c
index 6ad8f7a9f8..c946f417f8 100644
--- a/common/usb_pd_protocol.c
+++ b/common/usb_pd_protocol.c
@@ -26,16 +26,16 @@
#include "tcpm/tcpm.h"
#include "timer.h"
#include "typec_control.h"
-#include "util.h"
#include "usb_charge.h"
#include "usb_common.h"
#include "usb_mux.h"
#include "usb_pd.h"
#include "usb_pd_flags.h"
-#include "usb_pd_tcpm.h"
#include "usb_pd_tcpc.h"
+#include "usb_pd_tcpm.h"
#include "usbc_ocp.h"
#include "usbc_ppc.h"
+#include "util.h"
#include "vboot.h"
/* Flags to clear on a disconnect */
diff --git a/common/usb_pd_tcpc.c b/common/usb_pd_tcpc.c
index c8010a5005..a9a4d1d5a5 100644
--- a/common/usb_pd_tcpc.c
+++ b/common/usb_pd_tcpc.c
@@ -18,10 +18,10 @@
#include "tcpm/tcpci.h"
#include "tcpm/tcpm.h"
#include "timer.h"
-#include "util.h"
#include "usb_pd.h"
#include "usb_pd_config.h"
#include "usb_pd_tcpm.h"
+#include "util.h"
#ifdef CONFIG_COMMON_RUNTIME
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
diff --git a/common/usb_update.c b/common/usb_update.c
index 444a4d6949..2e9a681fed 100644
--- a/common/usb_update.c
+++ b/common/usb_update.c
@@ -9,8 +9,8 @@
#include "consumer.h"
#include "curve25519.h"
#include "flash.h"
-#include "queue_policies.h"
#include "host_command.h"
+#include "queue_policies.h"
#include "rollback.h"
#include "rwsig.h"
#include "sha256.h"
diff --git a/common/usbc/dp_alt_mode.c b/common/usbc/dp_alt_mode.c
index f53d212b91..22975aff5b 100644
--- a/common/usbc/dp_alt_mode.c
+++ b/common/usbc/dp_alt_mode.c
@@ -9,8 +9,6 @@
* section 5.2
*/
-#include <stdbool.h>
-#include <stdint.h>
#include "atomic.h"
#include "builtin/assert.h"
#include "console.h"
@@ -19,6 +17,9 @@
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
+#include <stdbool.h>
+#include <stdint.h>
+
#ifdef CONFIG_COMMON_RUNTIME
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
@@ -306,13 +307,13 @@ enum dpm_msg_setup_status dp_setup_next_vdm(int port, int *vdo_count,
* this doesn't set up the VDM, it clears state.
* TODO(b/159856063): Clean up the API to the fx functions.
*/
- if (!(modep && modep->opos))
- return MSG_SETUP_ERROR;
-
usb_mux_set_safe_mode_exit(port);
dp_state[port] = DP_PREPARE_EXIT;
return MSG_SETUP_MUX_WAIT;
case DP_PREPARE_EXIT:
+ if (!(modep && modep->opos))
+ return MSG_SETUP_ERROR;
+
/* DPM should call setup only after safe state is set */
vdm[0] = VDO(USB_SID_DISPLAYPORT, 1, /* structured */
CMD_EXIT_MODE);
diff --git a/common/usbc/tbt_alt_mode.c b/common/usbc/tbt_alt_mode.c
index c0e4e172cc..fec1ee9de3 100644
--- a/common/usbc/tbt_alt_mode.c
+++ b/common/usbc/tbt_alt_mode.c
@@ -9,8 +9,6 @@
*/
#include "atomic.h"
-#include <stdbool.h>
-#include <stdint.h>
#include "compile_time_macros.h"
#include "console.h"
#include "tcpm/tcpm.h"
@@ -23,6 +21,9 @@
#include "usb_pe_sm.h"
#include "usb_tbt_alt_mode.h"
+#include <stdbool.h>
+#include <stdint.h>
+
/*
* Enter/Exit TBT mode with active cable
*
diff --git a/common/usbc/usb_mode.c b/common/usbc/usb_mode.c
index 8f4824e4e9..017f89fc74 100644
--- a/common/usbc/usb_mode.c
+++ b/common/usbc/usb_mode.c
@@ -9,8 +9,6 @@
* USB Power Delivery Specification Revision 3.0, Version 2.0 Section 6.4.8
*/
-#include <stdbool.h>
-#include <stdint.h>
#include "compile_time_macros.h"
#include "console.h"
#include "tcpm/tcpm.h"
@@ -19,12 +17,15 @@
#include "usb_mode.h"
#include "usb_mux.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_tcpm.h"
#include "usb_pe_sm.h"
#include "usb_tbt_alt_mode.h"
#include "usbc_ppc.h"
+#include <stdbool.h>
+#include <stdint.h>
+
#ifdef CONFIG_COMMON_RUNTIME
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
diff --git a/common/usbc/usb_pd_console.c b/common/usbc/usb_pd_console.c
index 89a5492ad5..ed3d687ef4 100644
--- a/common/usbc/usb_pd_console.c
+++ b/common/usbc/usb_pd_console.c
@@ -6,12 +6,12 @@
#include "common.h"
#include "console.h"
#include "usb_common.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_timer.h"
#include "usb_pe_sm.h"
#include "usb_prl_sm.h"
#include "usb_tc_sm.h"
-#include "usb_pd.h"
#include "util.h"
#ifndef TEST_USB_PD_CONSOLE
@@ -146,8 +146,8 @@ static
case PD_DRP_FORCE_SOURCE:
ccprintf("force source\n");
break;
- cflush();
}
+ cflush();
} else {
if (!strcasecmp(argv[3], "on"))
pd_set_dual_role(port,
diff --git a/common/usbc/usb_pd_dpm.c b/common/usbc/usb_pd_dpm.c
index daccc2ba2a..775ea0da46 100644
--- a/common/usbc/usb_pd_dpm.c
+++ b/common/usbc/usb_pd_dpm.c
@@ -25,12 +25,13 @@
#include "usb_mode.h"
#include "usb_mux.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_pdo.h"
#include "usb_pd_tcpm.h"
#include "usb_pd_timer.h"
#include "usb_pe_sm.h"
#include "usb_tbt_alt_mode.h"
+#include "usb_tc_sm.h"
#ifdef CONFIG_ZEPHYR
#include "temp_sensor/temp_sensor.h"
@@ -48,6 +49,8 @@
#define DPM_ATTENION_MAX_VDO 2
static struct {
+ /* state machine context */
+ struct sm_ctx ctx;
atomic_t flags;
uint32_t vdm_req[VDO_MAX_SIZE];
int vdm_req_cnt;
@@ -69,10 +72,51 @@ static struct {
#define DPM_FLAG_ENTER_ANY \
(DPM_FLAG_ENTER_DP | DPM_FLAG_ENTER_TBT | DPM_FLAG_ENTER_USB4)
#define DPM_FLAG_SEND_VDM_REQ BIT(5)
-#define DPM_FLAG_DATA_RESET_REQUESTED BIT(6)
-#define DPM_FLAG_DATA_RESET_DONE BIT(7)
-#define DPM_FLAG_PD_BUTTON_PRESSED BIT(8)
-#define DPM_FLAG_PD_BUTTON_RELEASED BIT(9)
+#define DPM_FLAG_DATA_RESET_DONE BIT(6)
+#define DPM_FLAG_PD_BUTTON_PRESSED BIT(7)
+#define DPM_FLAG_PD_BUTTON_RELEASED BIT(8)
+#define DPM_FLAG_PE_READY BIT(9)
+
+/* List of all Device Policy Manager level states */
+enum usb_dpm_state {
+ /* Normal States */
+ DPM_WAITING,
+ DPM_DFP_READY,
+ DPM_UFP_READY,
+ DPM_DATA_RESET,
+};
+
+/* Forward declare the full list of states. This is indexed by usb_pd_state */
+static const struct usb_state dpm_states[];
+
+/* List of human readable state names for console debugging */
+__maybe_unused static __const_data const char *const dpm_state_names[] = {
+ /* Normal States */
+ [DPM_WAITING] = "DPM Waiting",
+ [DPM_DFP_READY] = "DPM DFP Ready",
+ [DPM_UFP_READY] = "DPM UFP Ready",
+ [DPM_DATA_RESET] = "DPM Data Reset",
+};
+
+static enum sm_local_state local_state[CONFIG_USB_PD_PORT_MAX_COUNT];
+
+/* Set the DPM state machine to a new state. */
+static void set_state_dpm(const int port, const enum usb_dpm_state new_state)
+{
+ set_state(port, &dpm[port].ctx, &dpm_states[new_state]);
+}
+
+/* Get the current TypeC state. */
+__maybe_unused test_export_static enum usb_dpm_state
+get_state_dpm(const int port)
+{
+ return dpm[port].ctx.current - &dpm_states[0];
+}
+
+static void print_current_state(const int port)
+{
+ CPRINTS("C%d: %s", port, dpm_state_names[get_state_dpm(port)]);
+}
#ifdef CONFIG_ZEPHYR
static int init_vdm_req_mutex(const struct device *dev)
@@ -180,6 +224,9 @@ void dpm_init(int port)
{
dpm[port].flags = 0;
dpm[port].pd_button_state = DPM_PD_BUTTON_IDLE;
+
+ /* Ensure that DPM state machine gets reset */
+ set_state_dpm(port, DPM_WAITING);
}
void dpm_mode_exit_complete(int port)
@@ -203,11 +250,22 @@ void dpm_set_mode_exit_request(int port)
void dpm_data_reset_complete(int port)
{
- DPM_CLR_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED);
DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_DONE);
DPM_CLR_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE);
}
+void dpm_set_pe_ready(int port, bool enable)
+{
+ /*
+ * DPM should remain DPM_WAITING state until the PE is in its ready
+ * state and is able to accept requests from the DPM layer.
+ */
+ if (enable)
+ DPM_SET_FLAG(port, DPM_FLAG_PE_READY);
+ else
+ DPM_CLR_FLAG(port, DPM_FLAG_PE_READY);
+}
+
static void dpm_clear_mode_exit_request(int port)
{
DPM_CLR_FLAG(port, DPM_FLAG_EXIT_REQUEST);
@@ -286,236 +344,6 @@ void dpm_vdm_naked(int port, enum tcpci_msg_type type, uint16_t svid,
}
}
-/*
- * Requests that the PE send one VDM, whichever is next in the mode entry
- * sequence. This only happens if preconditions for mode entry are met. If
- * CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY is enabled, this function waits for the
- * AP to direct mode entry.
- */
-static void dpm_attempt_mode_entry(int port)
-{
- int vdo_count = 0;
- uint32_t vdm[VDO_MAX_SIZE];
- enum tcpci_msg_type tx_type = TCPCI_MSG_SOP;
- bool enter_mode_requested =
- IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) ? false : true;
- enum dpm_msg_setup_status status = MSG_SETUP_UNSUPPORTED;
-
- if (pd_get_data_role(port) != PD_ROLE_DFP) {
- if (DPM_CHK_FLAG(port, DPM_FLAG_ENTER_DP | DPM_FLAG_ENTER_TBT |
- DPM_FLAG_ENTER_USB4))
- DPM_CLR_FLAG(port, DPM_FLAG_ENTER_DP |
- DPM_FLAG_ENTER_TBT |
- DPM_FLAG_ENTER_USB4);
- /*
- * TODO(b/168030639): Notify the AP that the enter mode request
- * failed.
- */
- return;
- }
-
-#ifdef CONFIG_AP_POWER_CONTROL
- /*
- * Do not try to enter mode while CPU is off.
- * CPU transitions (e.g b/158634281) can occur during the discovery
- * phase or during enter/exit negotiations, and the state
- * of the modes can get out of sync, causing the attempt to
- * enter the mode to fail prematurely.
- */
- if (!chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON))
- return;
-#endif
- /*
- * If discovery has not occurred for modes, do not attempt to switch
- * to alt mode.
- */
- if (pd_get_svids_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE ||
- pd_get_modes_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE)
- return;
-
- if (dp_entry_is_done(port) ||
- (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) &&
- tbt_entry_is_done(port)) ||
- (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port))) {
- dpm_set_mode_entry_done(port);
- return;
- }
-
- /*
- * If muxes are still settling, then wait on our next VDM. We must
- * ensure we correctly sequence actions such as USB safe state with TBT
- * entry or DP configuration.
- */
- if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port))
- return;
-
- if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) &&
- IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) &&
- DPM_CHK_FLAG(port, DPM_FLAG_ENTER_ANY) &&
- !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED) &&
- !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
- pd_dpm_request(port, DPM_REQUEST_DATA_RESET);
- DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED);
- return;
- }
-
- if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) &&
- IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) &&
- !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
- return;
- }
-
- /* Check if port, port partner and cable support USB4. */
- if (IS_ENABLED(CONFIG_USB_PD_USB4) && board_is_tbt_usb4_port(port) &&
- enter_usb_port_partner_is_capable(port) &&
- enter_usb_cable_is_capable(port) &&
- dpm_mode_entry_requested(port, TYPEC_MODE_USB4)) {
- /*
- * For certain cables, enter Thunderbolt alt mode with the
- * cable and USB4 mode with the port partner.
- */
- if (tbt_cable_entry_required_for_usb4(port)) {
- vdo_count = ARRAY_SIZE(vdm);
- status = tbt_setup_next_vdm(port, &vdo_count, vdm,
- &tx_type);
- } else {
- pd_dpm_request(port, DPM_REQUEST_ENTER_USB);
- return;
- }
- }
-
- /* If not, check if they support Thunderbolt alt mode. */
- if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) &&
- board_is_tbt_usb4_port(port) &&
- pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP,
- USB_VID_INTEL) &&
- dpm_mode_entry_requested(port, TYPEC_MODE_TBT)) {
- enter_mode_requested = true;
- vdo_count = ARRAY_SIZE(vdm);
- status = tbt_setup_next_vdm(port, &vdo_count, vdm, &tx_type);
- }
-
- /* If not, check if they support DisplayPort alt mode. */
- if (status == MSG_SETUP_UNSUPPORTED &&
- !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE) &&
- pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP,
- USB_SID_DISPLAYPORT) &&
- dpm_mode_entry_requested(port, TYPEC_MODE_DP)) {
- enter_mode_requested = true;
- vdo_count = ARRAY_SIZE(vdm);
- status = dp_setup_next_vdm(port, &vdo_count, vdm);
- }
-
- /* Not ready to send a VDM, check again next cycle */
- if (status == MSG_SETUP_MUX_WAIT)
- return;
-
- /*
- * If the PE didn't discover any supported (requested) alternate mode,
- * just mark setup done and get out of here.
- */
- if (status != MSG_SETUP_SUCCESS &&
- !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE)) {
- if (enter_mode_requested) {
- /*
- * TODO(b/168030639): Notify the AP that mode entry
- * failed.
- */
- CPRINTS("C%d: No supported alt mode discovered", port);
- }
- /*
- * If the AP did not request mode entry, it may do so in the
- * future, but the DPM is done trying for now.
- */
- dpm_set_mode_entry_done(port);
- return;
- }
-
- if (status != MSG_SETUP_SUCCESS) {
- dpm_set_mode_entry_done(port);
- CPRINTS("C%d: Couldn't construct alt mode VDM", port);
- return;
- }
-
- /*
- * TODO(b/155890173): Provide a host command to request that the PE send
- * an arbitrary VDM via this mechanism.
- */
- if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) {
- dpm_set_mode_entry_done(port);
- return;
- }
-
- pd_dpm_request(port, DPM_REQUEST_VDM);
-}
-
-static void dpm_attempt_mode_exit(int port)
-{
- uint32_t vdm[VDO_MAX_SIZE];
- int vdo_count = ARRAY_SIZE(vdm);
- enum dpm_msg_setup_status status = MSG_SETUP_ERROR;
- enum tcpci_msg_type tx_type = TCPCI_MSG_SOP;
-
- /* First, try Data Reset. If Data Reset completes, all the alt mode
- * state checked below will reset to its inactive state. If Data Reset
- * is not supported, exit active modes individually.
- */
- if (IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG)) {
- if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED) &&
- !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
- pd_dpm_request(port, DPM_REQUEST_DATA_RESET);
- DPM_SET_FLAG(port, DPM_FLAG_DATA_RESET_REQUESTED);
- return;
- } else if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
- return;
- }
- }
-
- /* TODO(b/209625351): Data Reset is the only real way to exit from USB4
- * mode. If that failed, the TCPM shouldn't try anything else.
- */
- if (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port)) {
- CPRINTS("C%d: USB4 teardown", port);
- usb4_exit_mode_request(port);
- }
-
- /*
- * If muxes are still settling, then wait on our next VDM. We must
- * ensure we correctly sequence actions such as USB safe state with TBT
- * or DP mode exit.
- */
- if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port))
- return;
-
- if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && tbt_is_active(port)) {
- /*
- * When the port is in USB4 mode and receives an exit request,
- * it leaves USB4 SOP in active state.
- */
- CPRINTS("C%d: TBT teardown", port);
- tbt_exit_mode_request(port);
- status = tbt_setup_next_vdm(port, &vdo_count, vdm, &tx_type);
- } else if (dp_is_active(port)) {
- CPRINTS("C%d: DP teardown", port);
- status = dp_setup_next_vdm(port, &vdo_count, vdm);
- } else {
- /* Clear exit mode request */
- dpm_clear_mode_exit_request(port);
- return;
- }
-
- /* This covers error, wait mux, and unsupported cases */
- if (status != MSG_SETUP_SUCCESS)
- return;
-
- if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) {
- dpm_clear_mode_exit_request(port);
- return;
- }
-
- pd_dpm_request(port, DPM_REQUEST_VDM);
-}
-
static void dpm_send_req_vdm(int port)
{
/* Set up VDM REQ msg that was passed in previously */
@@ -640,24 +468,6 @@ static void dpm_run_pd_button_sm(int port)
DPM_CLR_FLAG(port, DPM_FLAG_PD_BUTTON_RELEASED);
}
-void dpm_run(int port)
-{
- if (pd_get_data_role(port) == PD_ROLE_DFP) {
- /* Run DFP related DPM requests */
- if (DPM_CHK_FLAG(port, DPM_FLAG_EXIT_REQUEST))
- dpm_attempt_mode_exit(port);
- else if (!DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE))
- dpm_attempt_mode_entry(port);
-
- /* Run USB PD Power button state machine */
- dpm_run_pd_button_sm(port);
- }
-
- /* Run any VDM REQ messages */
- if (DPM_CHK_FLAG(port, DPM_FLAG_SEND_VDM_REQ))
- dpm_send_req_vdm(port);
-}
-
/*
* Source-out policy variables and APIs
*
@@ -1199,3 +1009,375 @@ uint8_t pd_get_bist_share_mode(void)
{
return bist_shared_mode_enabled;
}
+
+/*
+ * Requests that the PE send one VDM, whichever is next in the mode entry
+ * sequence. This only happens if preconditions for mode entry are met. If
+ * CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY is enabled, this function waits for the
+ * AP to direct mode entry.
+ *
+ * Returns true when the DPM state is changed in this function.
+ */
+static bool dpm_dfp_enter_mode_msg(int port)
+{
+ int vdo_count = 0;
+ uint32_t vdm[VDO_MAX_SIZE];
+ enum tcpci_msg_type tx_type = TCPCI_MSG_SOP;
+ bool enter_mode_requested =
+ IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) ? false : true;
+ enum dpm_msg_setup_status status = MSG_SETUP_UNSUPPORTED;
+
+#ifdef CONFIG_AP_POWER_CONTROL
+ /*
+ * Do not try to enter mode while CPU is off.
+ * CPU transitions (e.g b/158634281) can occur during the discovery
+ * phase or during enter/exit negotiations, and the state
+ * of the modes can get out of sync, causing the attempt to
+ * enter the mode to fail prematurely.
+ */
+ if (!chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON))
+ return false;
+#endif
+ /*
+ * If discovery has not occurred for modes, do not attempt to switch
+ * to alt mode.
+ */
+ if (pd_get_svids_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE ||
+ pd_get_modes_discovery(port, TCPCI_MSG_SOP) != PD_DISC_COMPLETE)
+ return false;
+
+ if (dp_entry_is_done(port) ||
+ (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) &&
+ tbt_entry_is_done(port)) ||
+ (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port))) {
+ dpm_set_mode_entry_done(port);
+ return false;
+ }
+
+ /*
+ * If AP mode entry is enabled, and a Data Reset has not been done, then
+ * first request Data Reset prior to attempting to enter any modes.
+ */
+ if (IS_ENABLED(CONFIG_USB_PD_REQUIRE_AP_MODE_ENTRY) &&
+ IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) &&
+ DPM_CHK_FLAG(port, DPM_FLAG_ENTER_ANY) &&
+ !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
+ set_state_dpm(port, DPM_DATA_RESET);
+ return true;
+ }
+
+ /* Check if port, port partner and cable support USB4. */
+ if (IS_ENABLED(CONFIG_USB_PD_USB4) && board_is_tbt_usb4_port(port) &&
+ enter_usb_port_partner_is_capable(port) &&
+ enter_usb_cable_is_capable(port) &&
+ dpm_mode_entry_requested(port, TYPEC_MODE_USB4)) {
+ /*
+ * For certain cables, enter Thunderbolt alt mode with the
+ * cable and USB4 mode with the port partner.
+ */
+ if (tbt_cable_entry_required_for_usb4(port)) {
+ vdo_count = ARRAY_SIZE(vdm);
+ status = tbt_setup_next_vdm(port, &vdo_count, vdm,
+ &tx_type);
+ } else {
+ pd_dpm_request(port, DPM_REQUEST_ENTER_USB);
+ return false;
+ }
+ }
+
+ /* If not, check if they support Thunderbolt alt mode. */
+ if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) &&
+ board_is_tbt_usb4_port(port) &&
+ pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP,
+ USB_VID_INTEL) &&
+ dpm_mode_entry_requested(port, TYPEC_MODE_TBT)) {
+ enter_mode_requested = true;
+ vdo_count = ARRAY_SIZE(vdm);
+ status = tbt_setup_next_vdm(port, &vdo_count, vdm, &tx_type);
+ }
+
+ /* If not, check if they support DisplayPort alt mode. */
+ if (status == MSG_SETUP_UNSUPPORTED &&
+ !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE) &&
+ pd_is_mode_discovered_for_svid(port, TCPCI_MSG_SOP,
+ USB_SID_DISPLAYPORT) &&
+ dpm_mode_entry_requested(port, TYPEC_MODE_DP)) {
+ enter_mode_requested = true;
+ vdo_count = ARRAY_SIZE(vdm);
+ status = dp_setup_next_vdm(port, &vdo_count, vdm);
+ }
+
+ /* Not ready to send a VDM, check again next cycle */
+ if (status == MSG_SETUP_MUX_WAIT)
+ return false;
+
+ /*
+ * If the PE didn't discover any supported (requested) alternate mode,
+ * just mark setup done and get out of here.
+ */
+ if (status != MSG_SETUP_SUCCESS &&
+ !DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE)) {
+ if (enter_mode_requested) {
+ /*
+ * TODO(b/168030639): Notify the AP that mode entry
+ * failed.
+ */
+ CPRINTS("C%d: No supported alt mode discovered", port);
+ }
+ /*
+ * If the AP did not request mode entry, it may do so in the
+ * future, but the DPM is done trying for now.
+ */
+ dpm_set_mode_entry_done(port);
+ return false;
+ }
+
+ if (status != MSG_SETUP_SUCCESS) {
+ dpm_set_mode_entry_done(port);
+ CPRINTS("C%d: Couldn't construct alt mode VDM", port);
+ return false;
+ }
+
+ /*
+ * TODO(b/155890173): Provide a host command to request that the PE send
+ * an arbitrary VDM via this mechanism.
+ */
+ if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) {
+ dpm_set_mode_entry_done(port);
+ return false;
+ }
+
+ /* Wait for PE to handle VDM request */
+ pd_dpm_request(port, DPM_REQUEST_VDM);
+ set_state_dpm(port, DPM_WAITING);
+
+ return true;
+}
+
+/*
+ * Checks to see if either USB4 or ALT-DP/TBT modes need to be exited. If the
+ * DPM is requesting the PE to send an exit message, then this function will
+ * return true to indicate that the DPM state has been changed.
+ */
+static bool dpm_dfp_exit_mode_msg(int port)
+{
+ uint32_t vdm[VDO_MAX_SIZE];
+ int vdo_count = ARRAY_SIZE(vdm);
+ enum dpm_msg_setup_status status = MSG_SETUP_ERROR;
+ enum tcpci_msg_type tx_type = TCPCI_MSG_SOP;
+
+ /* First, try Data Reset. If Data Reset completes, all the alt mode
+ * state checked below will reset to its inactive state. If Data Reset
+ * is not supported, exit active modes individually.
+ */
+ if (IS_ENABLED(CONFIG_USB_PD_DATA_RESET_MSG) &&
+ !DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE)) {
+ set_state_dpm(port, DPM_DATA_RESET);
+ return true;
+ }
+
+ /* TODO(b/209625351): Data Reset is the only real way to exit from USB4
+ * mode. If that failed, the TCPM shouldn't try anything else.
+ */
+ if (IS_ENABLED(CONFIG_USB_PD_USB4) && enter_usb_entry_is_done(port)) {
+ CPRINTS("C%d: USB4 teardown", port);
+ usb4_exit_mode_request(port);
+ }
+
+ if (IS_ENABLED(CONFIG_USB_PD_TBT_COMPAT_MODE) && tbt_is_active(port)) {
+ /*
+ * When the port is in USB4 mode and receives an exit request,
+ * it leaves USB4 SOP in active state.
+ */
+ CPRINTS("C%d: TBT teardown", port);
+ tbt_exit_mode_request(port);
+ status = tbt_setup_next_vdm(port, &vdo_count, vdm, &tx_type);
+ } else if (dp_is_active(port)) {
+ CPRINTS("C%d: DP teardown", port);
+ status = dp_setup_next_vdm(port, &vdo_count, vdm);
+ } else {
+ /* Clear exit mode request */
+ dpm_clear_mode_exit_request(port);
+ return false;
+ }
+
+ /* This covers error, wait mux, and unsupported cases */
+ if (status != MSG_SETUP_SUCCESS)
+ return false;
+
+ if (!pd_setup_vdm_request(port, tx_type, vdm, vdo_count)) {
+ dpm_clear_mode_exit_request(port);
+ return false;
+ }
+
+ pd_dpm_request(port, DPM_REQUEST_VDM);
+ set_state_dpm(port, DPM_WAITING);
+
+ return true;
+}
+
+void dpm_run(int port, int evt, int en)
+{
+ switch (local_state[port]) {
+ case SM_PAUSED:
+ if (!en)
+ break;
+ __fallthrough;
+ case SM_INIT:
+ dpm_init(port);
+ local_state[port] = SM_RUN;
+ __fallthrough;
+ case SM_RUN:
+ if (!en) {
+ local_state[port] = SM_PAUSED;
+ /*
+ * While we are paused, exit all states and wait until
+ * initialized again.
+ */
+ set_state(port, &dpm[port].ctx, NULL);
+ break;
+ }
+
+ /* Run state machine */
+ run_state(port, &dpm[port].ctx);
+
+ break;
+ }
+}
+
+/*
+ * DPM_WAITING
+ */
+static void dpm_waiting_entry(const int port)
+{
+ DPM_CLR_FLAG(port, DPM_FLAG_PE_READY);
+ print_current_state(port);
+}
+
+static void dpm_waiting_run(const int port)
+{
+ enum pd_data_role dr = pd_get_data_role(port);
+
+ if (DPM_CHK_FLAG(port, DPM_FLAG_PE_READY)) {
+ if (dr == PD_ROLE_UFP) {
+ set_state_dpm(port, DPM_UFP_READY);
+ } else if (dr == PD_ROLE_DFP) {
+ set_state_dpm(port, DPM_DFP_READY);
+ }
+ }
+}
+
+/*
+ * DPM_DFP_READY
+ */
+static void dpm_dfp_ready_entry(const int port)
+{
+ print_current_state(port);
+}
+
+static void dpm_dfp_ready_run(const int port)
+{
+ if (!DPM_CHK_FLAG(port, DPM_FLAG_PE_READY)) {
+ set_state_dpm(port, DPM_WAITING);
+ return;
+ }
+
+ /* Run power button state machine */
+ dpm_run_pd_button_sm(port);
+
+ /*
+ * If muxes are still settling, then wait on our next VDM. We must
+ * ensure we correctly sequence actions such as USB safe state with TBT
+ * or DP mode exit.
+ */
+ if (IS_ENABLED(CONFIG_USBC_SS_MUX) && !usb_mux_set_completed(port))
+ return;
+
+ /* Run DFP related DPM requests */
+ if (DPM_CHK_FLAG(port, DPM_FLAG_EXIT_REQUEST)) {
+ if (dpm_dfp_exit_mode_msg(port))
+ return;
+ } else if (!DPM_CHK_FLAG(port, DPM_FLAG_MODE_ENTRY_DONE)) {
+ if (dpm_dfp_enter_mode_msg(port))
+ return;
+ }
+
+ /* Run any VDM REQ messages */
+ if (DPM_CHK_FLAG(port, DPM_FLAG_SEND_VDM_REQ)) {
+ dpm_send_req_vdm(port);
+ set_state_dpm(port, DPM_WAITING);
+ return;
+ }
+}
+
+/*
+ * DPM_UFP_READY
+ */
+static void dpm_ufp_ready_entry(const int port)
+{
+ print_current_state(port);
+}
+
+static void dpm_ufp_ready_run(const int port)
+{
+ if (!DPM_CHK_FLAG(port, DPM_FLAG_PE_READY)) {
+ set_state_dpm(port, DPM_WAITING);
+ return;
+ }
+
+ if (DPM_CHK_FLAG(port, DPM_FLAG_ENTER_ANY)) {
+ DPM_CLR_FLAG(port, DPM_FLAG_ENTER_DP | DPM_FLAG_ENTER_TBT |
+ DPM_FLAG_ENTER_USB4);
+ /*
+ * TODO(b/168030639): Notify the AP that the
+ * enter mode request failed.
+ */
+ return;
+ }
+
+ /* Run any VDM REQ messages */
+ if (DPM_CHK_FLAG(port, DPM_FLAG_SEND_VDM_REQ)) {
+ dpm_send_req_vdm(port);
+ set_state_dpm(port, DPM_WAITING);
+ return;
+ }
+}
+
+/*
+ * DPM_DATA_RESET
+ */
+static void dpm_data_reset_entry(const int port)
+{
+ print_current_state(port);
+
+ pd_dpm_request(port, DPM_REQUEST_DATA_RESET);
+}
+
+static void dpm_data_reset_run(const int port)
+{
+ /* Wait for Data Reset to Complete */
+ if (!DPM_CHK_FLAG(port, DPM_FLAG_DATA_RESET_DONE))
+ return;
+
+ set_state_dpm(port, DPM_DFP_READY);
+}
+
+static __const_data const struct usb_state dpm_states[] = {
+ /* Normal States */
+ [DPM_WAITING] = {
+ .entry = dpm_waiting_entry,
+ .run = dpm_waiting_run,
+ },
+ [DPM_DFP_READY] = {
+ .entry = dpm_dfp_ready_entry,
+ .run = dpm_dfp_ready_run,
+ },
+ [DPM_UFP_READY] = {
+ .entry = dpm_ufp_ready_entry,
+ .run = dpm_ufp_ready_run,
+ },
+ [DPM_DATA_RESET] = {
+ .entry = dpm_data_reset_entry,
+ .run = dpm_data_reset_run,
+ },
+};
diff --git a/common/usbc/usb_pd_host.c b/common/usbc/usb_pd_host.c
index 1e2965d114..0b3958cd47 100644
--- a/common/usbc/usb_pd_host.c
+++ b/common/usbc/usb_pd_host.c
@@ -5,17 +5,17 @@
* Host commands for TCPMv2 USB PD module
*/
-#include <string.h>
-
#include "console.h"
#include "ec_commands.h"
#include "host_command.h"
#include "usb_mux.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_tcpm.h"
#include "util.h"
+#include <string.h>
+
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
@@ -112,6 +112,8 @@ static enum ec_status hc_typec_control(struct host_cmd_handler_args *args)
{
const struct ec_params_typec_control *p = args->params;
mux_state_t mode;
+ uint32_t data[VDO_MAX_SIZE];
+ enum tcpci_msg_type tx_type;
if (p->port >= board_get_usb_pd_port_count())
return EC_RES_INVALID_PARAM;
@@ -140,6 +142,34 @@ static enum ec_status hc_typec_control(struct host_cmd_handler_args *args)
return EC_RES_SUCCESS;
case TYPEC_CONTROL_COMMAND_BIST_SHARE_MODE:
return pd_set_bist_share_mode(p->bist_share_mode);
+ case TYPEC_CONTROL_COMMAND_SEND_VDM_REQ:
+ if (!IS_ENABLED(CONFIG_USB_PD_VDM_AP_CONTROL))
+ return EC_RES_INVALID_PARAM;
+
+ if (p->vdm_req_params.vdm_data_objects <= 0 ||
+ p->vdm_req_params.vdm_data_objects > VDO_MAX_SIZE)
+ return EC_RES_INVALID_PARAM;
+
+ memcpy(data, p->vdm_req_params.vdm_data,
+ sizeof(uint32_t) * p->vdm_req_params.vdm_data_objects);
+
+ switch (p->vdm_req_params.partner_type) {
+ case TYPEC_PARTNER_SOP:
+ tx_type = TCPCI_MSG_SOP;
+ break;
+ case TYPEC_PARTNER_SOP_PRIME:
+ tx_type = TCPCI_MSG_SOP_PRIME;
+ break;
+ case TYPEC_PARTNER_SOP_PRIME_PRIME:
+ tx_type = TCPCI_MSG_SOP_PRIME_PRIME;
+ break;
+ default:
+ return EC_RES_INVALID_PARAM;
+ }
+
+ return pd_request_vdm(p->port, data,
+ p->vdm_req_params.vdm_data_objects,
+ tx_type);
default:
return EC_RES_INVALID_PARAM;
}
diff --git a/common/usbc/usb_pe_ctvpd_sm.c b/common/usbc/usb_pe_ctvpd_sm.c
index dbd32a6b7d..223c40c71d 100644
--- a/common/usbc/usb_pe_ctvpd_sm.c
+++ b/common/usbc/usb_pe_ctvpd_sm.c
@@ -6,15 +6,14 @@
#include "common.h"
#include "console.h"
#include "task.h"
-#include "util.h"
+#include "usb_emsg.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#include "usb_pe_sm.h"
#include "usb_prl_sm.h"
-#include "usb_pd_tcpm.h"
-#include "usb_tc_sm.h"
-#include "usb_emsg.h"
#include "usb_sm.h"
+#include "usb_tc_sm.h"
+#include "util.h"
/* USB Policy Engine Charge-Through VCONN Powered Device module */
diff --git a/common/usbc/usb_pe_drp_sm.c b/common/usbc/usb_pe_drp_sm.c
index f6cd95463f..0de098788a 100644
--- a/common/usbc/usb_pe_drp_sm.c
+++ b/common/usbc/usb_pe_drp_sm.c
@@ -21,25 +21,25 @@
#include "system.h"
#include "task.h"
#include "tcpm/tcpm.h"
-#include "util.h"
#include "usb_charge.h"
#include "usb_common.h"
#include "usb_dp_alt_mode.h"
+#include "usb_emsg.h"
#include "usb_mode.h"
#include "usb_mux.h"
-#include "usb_pd_dpm.h"
-#include "usb_pd_policy.h"
#include "usb_pd.h"
+#include "usb_pd_dpm_sm.h"
+#include "usb_pd_policy.h"
#include "usb_pd_tcpm.h"
#include "usb_pd_timer.h"
#include "usb_pe_private.h"
#include "usb_pe_sm.h"
-#include "usb_tbt_alt_mode.h"
#include "usb_prl_sm.h"
-#include "usb_tc_sm.h"
-#include "usb_emsg.h"
#include "usb_sm.h"
+#include "usb_tbt_alt_mode.h"
+#include "usb_tc_sm.h"
#include "usbc_ppc.h"
+#include "util.h"
/*
* USB Policy Engine Sink / Source module
@@ -202,91 +202,91 @@ typedef int (*svdm_rsp_func)(int port, uint32_t *payload);
/* List of all Policy Engine level states */
enum usb_pe_state {
/* Super States */
- PE_PRS_FRS_SHARED,
- PE_VDM_SEND_REQUEST,
+ PE_PRS_FRS_SHARED, /* pe-st0 */
+ PE_VDM_SEND_REQUEST, /* pe-st1 */
/* Normal States */
- PE_SRC_STARTUP,
- PE_SRC_DISCOVERY,
- PE_SRC_SEND_CAPABILITIES,
- PE_SRC_NEGOTIATE_CAPABILITY,
- PE_SRC_TRANSITION_SUPPLY,
- PE_SRC_READY,
- PE_SRC_DISABLED,
- PE_SRC_CAPABILITY_RESPONSE,
- PE_SRC_HARD_RESET,
- PE_SRC_HARD_RESET_RECEIVED,
- PE_SRC_TRANSITION_TO_DEFAULT,
- PE_SNK_STARTUP,
- PE_SNK_DISCOVERY,
- PE_SNK_WAIT_FOR_CAPABILITIES,
- PE_SNK_EVALUATE_CAPABILITY,
- PE_SNK_SELECT_CAPABILITY,
- PE_SNK_READY,
- PE_SNK_HARD_RESET,
- PE_SNK_TRANSITION_TO_DEFAULT,
- PE_SNK_GIVE_SINK_CAP,
- PE_SNK_GET_SOURCE_CAP,
- PE_SNK_TRANSITION_SINK,
- PE_SEND_SOFT_RESET,
- PE_SOFT_RESET,
- PE_SEND_NOT_SUPPORTED,
- PE_SRC_PING,
- PE_DRS_EVALUATE_SWAP,
- PE_DRS_CHANGE,
- PE_DRS_SEND_SWAP,
- PE_PRS_SRC_SNK_EVALUATE_SWAP,
- PE_PRS_SRC_SNK_TRANSITION_TO_OFF,
- PE_PRS_SRC_SNK_ASSERT_RD,
- PE_PRS_SRC_SNK_WAIT_SOURCE_ON,
- PE_PRS_SRC_SNK_SEND_SWAP,
- PE_PRS_SNK_SRC_EVALUATE_SWAP,
- PE_PRS_SNK_SRC_TRANSITION_TO_OFF,
- PE_PRS_SNK_SRC_ASSERT_RP,
- PE_PRS_SNK_SRC_SOURCE_ON,
- PE_PRS_SNK_SRC_SEND_SWAP,
- PE_VCS_EVALUATE_SWAP,
- PE_VCS_SEND_SWAP,
- PE_VCS_WAIT_FOR_VCONN_SWAP,
- PE_VCS_TURN_ON_VCONN_SWAP,
- PE_VCS_TURN_OFF_VCONN_SWAP,
- PE_VCS_SEND_PS_RDY_SWAP,
- PE_VCS_CBL_SEND_SOFT_RESET,
- PE_VDM_IDENTITY_REQUEST_CBL,
- PE_INIT_PORT_VDM_IDENTITY_REQUEST,
- PE_INIT_VDM_SVIDS_REQUEST,
- PE_INIT_VDM_MODES_REQUEST,
- PE_VDM_REQUEST_DPM,
- PE_VDM_RESPONSE,
- PE_WAIT_FOR_ERROR_RECOVERY,
- PE_BIST_TX,
- PE_DEU_SEND_ENTER_USB,
- PE_DR_GET_SINK_CAP,
- PE_DR_SNK_GIVE_SOURCE_CAP,
- PE_DR_SRC_GET_SOURCE_CAP,
+ PE_SRC_STARTUP, /* pe-st2 */
+ PE_SRC_DISCOVERY, /* pe-st3 */
+ PE_SRC_SEND_CAPABILITIES, /* pe-st4 */
+ PE_SRC_NEGOTIATE_CAPABILITY, /* pe-st5 */
+ PE_SRC_TRANSITION_SUPPLY, /* pe-st6 */
+ PE_SRC_READY, /* pe-st7 */
+ PE_SRC_DISABLED, /* pe-st8 */
+ PE_SRC_CAPABILITY_RESPONSE, /* pe-st9 */
+ PE_SRC_HARD_RESET, /* pe-st10 */
+ PE_SRC_HARD_RESET_RECEIVED, /* pe-st11 */
+ PE_SRC_TRANSITION_TO_DEFAULT, /* pe-st12 */
+ PE_SNK_STARTUP, /* pe-st13 */
+ PE_SNK_DISCOVERY, /* pe-st14 */
+ PE_SNK_WAIT_FOR_CAPABILITIES, /* pe-st15 */
+ PE_SNK_EVALUATE_CAPABILITY, /* pe-st16 */
+ PE_SNK_SELECT_CAPABILITY, /* pe-st17 */
+ PE_SNK_READY, /* pe-st18 */
+ PE_SNK_HARD_RESET, /* pe-st19 */
+ PE_SNK_TRANSITION_TO_DEFAULT, /* pe-st20 */
+ PE_SNK_GIVE_SINK_CAP, /* pe-st21 */
+ PE_SNK_GET_SOURCE_CAP, /* pe-st22 */
+ PE_SNK_TRANSITION_SINK, /* pe-st23 */
+ PE_SEND_SOFT_RESET, /* pe-st24 */
+ PE_SOFT_RESET, /* pe-st25 */
+ PE_SEND_NOT_SUPPORTED, /* pe-st26 */
+ PE_SRC_PING, /* pe-st27 */
+ PE_DRS_EVALUATE_SWAP, /* pe-st28 */
+ PE_DRS_CHANGE, /* pe-st29 */
+ PE_DRS_SEND_SWAP, /* pe-st30 */
+ PE_PRS_SRC_SNK_EVALUATE_SWAP, /* pe-st31 */
+ PE_PRS_SRC_SNK_TRANSITION_TO_OFF, /* pe-st32 */
+ PE_PRS_SRC_SNK_ASSERT_RD, /* pe-st33 */
+ PE_PRS_SRC_SNK_WAIT_SOURCE_ON, /* pe-st34 */
+ PE_PRS_SRC_SNK_SEND_SWAP, /* pe-st35 */
+ PE_PRS_SNK_SRC_EVALUATE_SWAP, /* pe-st36 */
+ PE_PRS_SNK_SRC_TRANSITION_TO_OFF, /* pe-st37 */
+ PE_PRS_SNK_SRC_ASSERT_RP, /* pe-st38 */
+ PE_PRS_SNK_SRC_SOURCE_ON, /* pe-st39 */
+ PE_PRS_SNK_SRC_SEND_SWAP, /* pe-st40 */
+ PE_VCS_EVALUATE_SWAP, /* pe-st41 */
+ PE_VCS_SEND_SWAP, /* pe-st42 */
+ PE_VCS_WAIT_FOR_VCONN_SWAP, /* pe-st43 */
+ PE_VCS_TURN_ON_VCONN_SWAP, /* pe-st44 */
+ PE_VCS_TURN_OFF_VCONN_SWAP, /* pe-st45 */
+ PE_VCS_SEND_PS_RDY_SWAP, /* pe-st46 */
+ PE_VCS_CBL_SEND_SOFT_RESET, /* pe-st47 */
+ PE_VDM_IDENTITY_REQUEST_CBL, /* pe-st48 */
+ PE_INIT_PORT_VDM_IDENTITY_REQUEST, /* pe-st49 */
+ PE_INIT_VDM_SVIDS_REQUEST, /* pe-st50 */
+ PE_INIT_VDM_MODES_REQUEST, /* pe-st51 */
+ PE_VDM_REQUEST_DPM, /* pe-st52 */
+ PE_VDM_RESPONSE, /* pe-st53 */
+ PE_WAIT_FOR_ERROR_RECOVERY, /* pe-st54 */
+ PE_BIST_TX, /* pe-st55 */
+ PE_DEU_SEND_ENTER_USB, /* pe-st56 */
+ PE_DR_GET_SINK_CAP, /* pe-st57 */
+ PE_DR_SNK_GIVE_SOURCE_CAP, /* pe-st58 */
+ PE_DR_SRC_GET_SOURCE_CAP, /* pe-st59 */
/* PD3.0 only states below here*/
/* UFP Data Reset States */
- PE_UDR_SEND_DATA_RESET,
- PE_UDR_DATA_RESET_RECEIVED,
- PE_UDR_TURN_OFF_VCONN,
- PE_UDR_SEND_PS_RDY,
- PE_UDR_WAIT_FOR_DATA_RESET_COMPLETE,
+ PE_UDR_SEND_DATA_RESET, /* pe-st60 */
+ PE_UDR_DATA_RESET_RECEIVED, /* pe-st61 */
+ PE_UDR_TURN_OFF_VCONN, /* pe-st62 */
+ PE_UDR_SEND_PS_RDY, /* pe-st63 */
+ PE_UDR_WAIT_FOR_DATA_RESET_COMPLETE, /* pe-st64 */
/* DFP Data Reset States */
- PE_DDR_SEND_DATA_RESET,
- PE_DDR_DATA_RESET_RECEIVED,
- PE_DDR_WAIT_FOR_VCONN_OFF,
- PE_DDR_PERFORM_DATA_RESET,
- PE_FRS_SNK_SRC_START_AMS,
- PE_GIVE_BATTERY_CAP,
- PE_GIVE_BATTERY_STATUS,
- PE_GIVE_STATUS,
- PE_SEND_ALERT,
- PE_ALERT_RECEIVED,
- PE_SRC_CHUNK_RECEIVED,
- PE_SNK_CHUNK_RECEIVED,
- PE_VCS_FORCE_VCONN,
- PE_GET_REVISION,
+ PE_DDR_SEND_DATA_RESET, /* pe-st65 */
+ PE_DDR_DATA_RESET_RECEIVED, /* pe-st66 */
+ PE_DDR_WAIT_FOR_VCONN_OFF, /* pe-st67 */
+ PE_DDR_PERFORM_DATA_RESET, /* pe-st68 */
+ PE_FRS_SNK_SRC_START_AMS, /* pe-st69 */
+ PE_GIVE_BATTERY_CAP, /* pe-st70 */
+ PE_GIVE_BATTERY_STATUS, /* pe-st71 */
+ PE_GIVE_STATUS, /* pe-st72 */
+ PE_SEND_ALERT, /* pe-st73 */
+ PE_ALERT_RECEIVED, /* pe-st74 */
+ PE_SRC_CHUNK_RECEIVED, /* pe-st75 */
+ PE_SNK_CHUNK_RECEIVED, /* pe-st76 */
+ PE_VCS_FORCE_VCONN, /* pe-st77 */
+ PE_GET_REVISION, /* pe-st78 */
};
/*
@@ -2927,11 +2927,17 @@ static void pe_src_ready_run(int port)
if (pe_attempt_port_discovery(port))
return;
- /* No DPM requests; attempt mode entry/exit if needed */
- dpm_run(port);
+ /* Inform DPM state machine that PE is set for messages */
+ dpm_set_pe_ready(port, true);
}
}
+static void pe_src_ready_exit(int port)
+{
+ /* Inform DPM state machine that PE is in ready state */
+ dpm_set_pe_ready(port, false);
+}
+
/**
* PE_SRC_Disabled
*/
@@ -3803,11 +3809,17 @@ static void pe_snk_ready_run(int port)
if (pe_attempt_port_discovery(port))
return;
- /* No DPM requests; attempt mode entry/exit if needed */
- dpm_run(port);
+ /* Inform DPM state machine that PE is set for messages */
+ dpm_set_pe_ready(port, true);
}
}
+static void pe_snk_ready_exit(int port)
+{
+ /* Inform DPM state machine that PE is in ready state */
+ dpm_set_pe_ready(port, false);
+}
+
/**
* PE_SNK_Hard_Reset
*/
@@ -6502,7 +6514,7 @@ static void pe_vcs_evaluate_swap_entry(int port)
*/
/* DPM rejects a VCONN Swap and port is not a VCONN source*/
- if (!tc_check_vconn_swap(port) && tc_is_vconn_src(port) < 1) {
+ if (!tc_check_vconn_swap(port) || tc_is_vconn_src(port) < 1) {
/* NOTE: PE_VCS_Reject_Swap State embedded here */
send_ctrl_msg(port, TCPCI_MSG_SOP, PD_CTRL_REJECT);
}
@@ -7674,8 +7686,7 @@ static void pe_ddr_perform_data_reset_run(int port)
* interpretations are mutually exclusive. Resolve that
* ambiguity and update this implementation.
*/
- usb_mux_set(port, USB_PD_MUX_NONE, USB_SWITCH_DISCONNECT,
- polarity_rm_dts(pd_get_polarity(port)));
+ set_usb_mux_with_current_data_role(port);
} else if (IS_ENABLED(CONFIG_USBC_VCONN) &&
PE_CHK_FLAG(port, PE_FLAGS_VCONN_SWAP_COMPLETE) &&
tc_is_vconn_src(port)) {
@@ -7902,6 +7913,7 @@ static __const_data const struct usb_state pe_states[] = {
[PE_SRC_READY] = {
.entry = pe_src_ready_entry,
.run = pe_src_ready_run,
+ .exit = pe_src_ready_exit,
},
[PE_SRC_DISABLED] = {
.entry = pe_src_disabled_entry,
@@ -7948,6 +7960,7 @@ static __const_data const struct usb_state pe_states[] = {
[PE_SNK_READY] = {
.entry = pe_snk_ready_entry,
.run = pe_snk_ready_run,
+ .exit = pe_snk_ready_exit,
},
[PE_SNK_HARD_RESET] = {
.entry = pe_snk_hard_reset_entry,
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c
index db9f460e61..5c17459834 100644
--- a/common/usbc/usb_prl_sm.c
+++ b/common/usbc/usb_prl_sm.c
@@ -20,16 +20,16 @@
#include "system.h"
#include "task.h"
#include "tcpm/tcpm.h"
-#include "util.h"
#include "usb_charge.h"
+#include "usb_emsg.h"
#include "usb_mux.h"
#include "usb_pd.h"
#include "usb_pd_timer.h"
#include "usb_pe_sm.h"
#include "usb_prl_sm.h"
-#include "usb_tc_sm.h"
-#include "usb_emsg.h"
#include "usb_sm.h"
+#include "usb_tc_sm.h"
+#include "util.h"
#include "vpd_api.h"
#ifdef CONFIG_COMMON_RUNTIME
diff --git a/common/usbc/usb_retimer_fw_update.c b/common/usbc/usb_retimer_fw_update.c
index 9b581ea872..a8cabf00a2 100644
--- a/common/usbc/usb_retimer_fw_update.c
+++ b/common/usbc/usb_retimer_fw_update.c
@@ -3,9 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdbool.h>
-#include <stdint.h>
-
#include "builtin/assert.h"
#include "compile_time_macros.h"
#include "console.h"
@@ -15,6 +12,9 @@
#include "usb_mux.h"
#include "usb_tc_sm.h"
+#include <stdbool.h>
+#include <stdint.h>
+
#ifdef CONFIG_COMMON_RUNTIME
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
diff --git a/common/usbc/usb_tc_drp_acc_trysrc_sm.c b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
index ae84574b40..168490d67e 100644
--- a/common/usbc/usb_tc_drp_acc_trysrc_sm.c
+++ b/common/usbc/usb_tc_drp_acc_trysrc_sm.c
@@ -17,7 +17,7 @@
#include "usb_common.h"
#include "usb_mux.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_tcpm.h"
#include "usb_pd_timer.h"
#include "usb_pe_sm.h"
@@ -3749,6 +3749,13 @@ __maybe_unused static void tc_ct_attached_snk_entry(int port)
/* The port shall reject a VCONN swap request. */
TC_SET_FLAG(port, TC_FLAGS_REJECT_VCONN_SWAP);
+
+ /*
+ * Type-C r 2.2: The Host shall not advertise dual-role data or
+ * dual-role power in its SourceCapability or SinkCapability messages -
+ * Host changes its advertised capabilities to UFP role/sink only role.
+ */
+ tc_set_data_role(port, PD_ROLE_UFP);
}
__maybe_unused static void tc_ct_attached_snk_run(int port)
diff --git a/common/usbc/usb_tc_vpd_sm.c b/common/usbc/usb_tc_vpd_sm.c
index 40b855db9b..1a820c4003 100644
--- a/common/usbc/usb_tc_vpd_sm.c
+++ b/common/usbc/usb_tc_vpd_sm.c
@@ -11,8 +11,8 @@
#include "tcpm/tcpm.h"
#include "typec_control.h"
#include "usb_pd.h"
-#include "usb_tc_sm.h"
#include "usb_sm.h"
+#include "usb_tc_sm.h"
#include "vpd_api.h"
/* USB Type-C VCONN Powered Device module */
diff --git a/common/usbc/usbc_task.c b/common/usbc/usbc_task.c
index 6384aae879..5d68221b3e 100644
--- a/common/usbc/usbc_task.c
+++ b/common/usbc/usbc_task.c
@@ -19,19 +19,19 @@
#include "registers.h"
#include "system.h"
#include "task.h"
+#include "tcpm/tcpm.h"
#include "timer.h"
-#include "util.h"
#include "usb_charge.h"
#include "usb_mux.h"
#include "usb_pd.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_timer.h"
-#include "usb_prl_sm.h"
-#include "tcpm/tcpm.h"
#include "usb_pe_sm.h"
#include "usb_prl_sm.h"
#include "usb_sm.h"
#include "usb_tc_sm.h"
#include "usbc_ppc.h"
+#include "util.h"
#define USBC_EVENT_TIMEOUT (5 * MSEC)
#define USBC_MIN_EVENT_TIMEOUT (1 * MSEC)
@@ -141,6 +141,10 @@ static bool pd_task_loop(int port)
if (IS_ENABLED(CONFIG_USB_PD_TCPC))
tcpc_run(port, evt);
+ /* Run Device Policy Manager */
+ if (IS_ENABLED(CONFIG_USB_DPM_SM))
+ dpm_run(port, evt, tc_get_pd_enabled(port));
+
/* Run policy engine state machine */
if (IS_ENABLED(CONFIG_USB_PE_SM))
pe_run(port, evt, tc_get_pd_enabled(port));
diff --git a/common/usbc_intr_task.c b/common/usbc_intr_task.c
index 6c724c1279..d1d25c6b68 100644
--- a/common/usbc_intr_task.c
+++ b/common/usbc_intr_task.c
@@ -5,8 +5,6 @@
/* High-priority interrupt tasks implementations */
-#include <stdint.h>
-
#include "builtin/assert.h"
#include "common.h"
#include "compile_time_macros.h"
@@ -18,6 +16,8 @@
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
+#include <stdint.h>
+
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
diff --git a/common/usbc_ocp.c b/common/usbc_ocp.c
index ba975b6105..406deb2b20 100644
--- a/common/usbc_ocp.c
+++ b/common/usbc_ocp.c
@@ -15,13 +15,8 @@
#include "usbc_ocp.h"
#include "util.h"
-#ifndef TEST_BUILD
#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
-#else
-#define CPRINTF(args...)
-#define CPRINTS(args...)
-#endif
/*
* Number of seconds until a latched-off port is re-enabled for sourcing after
diff --git a/common/vboot/efs2.c b/common/vboot/efs2.c
index b45109029d..3346a2c76b 100644
--- a/common/vboot/efs2.c
+++ b/common/vboot/efs2.c
@@ -21,8 +21,8 @@
#include "sha256.h"
#include "system.h"
#include "task.h"
-#include "usb_pd.h"
#include "uart.h"
+#include "usb_pd.h"
#include "vboot.h"
#include "vboot_hash.h"
diff --git a/common/vboot/vboot.c b/common/vboot/vboot.c
index cf449da1b8..162b396ba5 100644
--- a/common/vboot/vboot.c
+++ b/common/vboot/vboot.c
@@ -17,13 +17,13 @@
#include "host_command.h"
#include "rsa.h"
#include "rwsig.h"
-#include "stdbool.h"
#include "sha256.h"
#include "shared_mem.h"
+#include "stdbool.h"
#include "system.h"
#include "usb_pd.h"
-#include "vboot.h"
#include "vb21_struct.h"
+#include "vboot.h"
#define CPRINTS(format, args...) cprints(CC_VBOOT, "VB " format, ##args)
#define CPRINTF(format, args...) cprintf(CC_VBOOT, "VB " format, ##args)
diff --git a/common/vec3.c b/common/vec3.c
index 67a6049dea..4cf26ebf4c 100644
--- a/common/vec3.c
+++ b/common/vec3.c
@@ -6,8 +6,8 @@
#include "common.h"
#include "math.h"
#include "math_util.h"
-#include "vec3.h"
#include "util.h"
+#include "vec3.h"
static fpv3_t zero_initialized_vector = { FLOAT_TO_FP(0.0f), FLOAT_TO_FP(0.0f),
FLOAT_TO_FP(0.0f) };
diff --git a/common/version.c b/common/version.c
index 8b1ac5e53d..fe082abbe0 100644
--- a/common/version.c
+++ b/common/version.c
@@ -5,7 +5,6 @@
/* Embed firmware version number in the binary */
-#include <stdint.h>
#include "common.h"
#include "compile_time_macros.h"
#include "cros_version.h"
@@ -14,6 +13,8 @@
#include "stddef.h"
#include "system.h"
+#include <stdint.h>
+
BUILD_ASSERT(CONFIG_ROLLBACK_VERSION >= 0);
BUILD_ASSERT(CONFIG_ROLLBACK_VERSION <= INT32_MAX);
diff --git a/common/virtual_battery.c b/common/virtual_battery.c
index adb4e96d7f..743f2a8801 100644
--- a/common/virtual_battery.c
+++ b/common/virtual_battery.c
@@ -103,9 +103,6 @@ int virtual_battery_handler(struct ec_response_i2c_passthru *resp, int in_len,
if (cache_hit)
*err_code = 0;
break;
- default:
- reset_parse_state();
- return EC_ERROR_INVAL;
}
acc_write_len += write_len;
@@ -129,10 +126,15 @@ int virtual_battery_handler(struct ec_response_i2c_passthru *resp, int in_len,
read_len, 0);
}
break;
+ /* LCOV_EXCL_START - Unreachable in IDLE state and remaining
+ * states covered above.
+ */
default:
reset_parse_state();
return EC_ERROR_INVAL;
}
+ /* LCOV_EXCL_STOP */
+
/* Reset the state in the end of messages */
reset_parse_state();
}
diff --git a/core/cortex-m/cpu.h b/core/cortex-m/cpu.h
index 8c284d6132..4a36d63dda 100644
--- a/core/cortex-m/cpu.h
+++ b/core/cortex-m/cpu.h
@@ -8,10 +8,11 @@
#ifndef __CROS_EC_CPU_H
#define __CROS_EC_CPU_H
-#include <stdint.h>
#include "compile_time_macros.h"
#include "debug.h"
+#include <stdint.h>
+
/* Macro to access 32-bit registers */
#define CPUREG(addr) (*(volatile uint32_t *)(addr))
diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S
index f5679a97f6..8ea35911df 100644
--- a/core/cortex-m/ec.lds.S
+++ b/core/cortex-m/ec.lds.S
@@ -347,6 +347,13 @@ SECTIONS
. = ALIGN(64);
KEEP(*(.google))
#endif
+
+ /*
+ * https://developer.arm.com/documentation/dui0475/c/the-arm-c-and-c---libraries/c---initialization--construction-and-destruction
+ */
+ . = ALIGN(4);
+ *(.init_array*)
+
/*
* Empty C++ exception index table. The exception index
* table is described in more detail in "Exception Handling
diff --git a/core/cortex-m/include/mpu_private.h b/core/cortex-m/include/mpu_private.h
index eca474e14d..fc7617da66 100644
--- a/core/cortex-m/include/mpu_private.h
+++ b/core/cortex-m/include/mpu_private.h
@@ -12,6 +12,9 @@
#ifndef __CROS_EC_MPU_PRIVATE_H
#define __CROS_EC_MPU_PRIVATE_H
+#include <stdbool.h>
+#include <stdint.h>
+
int mpu_num_regions(void);
bool has_mpu(void);
bool mpu_is_unified(void);
@@ -21,5 +24,6 @@ int mpu_update_region(uint8_t region, uint32_t addr, uint8_t size_bit,
int mpu_config_region(uint8_t region, uint32_t addr, uint32_t size,
uint16_t attr, uint8_t enable);
struct mpu_rw_regions mpu_get_rw_regions(void);
+uint32_t align_down_to_bits(uint32_t addr, uint8_t addr_bits);
#endif /* __CROS_EC_MPU_PRIVATE_H */
diff --git a/core/cortex-m/llsr.c b/core/cortex-m/llsr.c
index 0ab920f628..933382034b 100644
--- a/core/cortex-m/llsr.c
+++ b/core/cortex-m/llsr.c
@@ -5,10 +5,11 @@
/* Enable the use of right shift for uint64_t. */
-#include <console.h>
-#include <compile_time_macros.h>
#include <stdint.h>
+#include <compile_time_macros.h>
+#include <console.h>
+
union words {
uint64_t u64;
uint32_t w[2];
diff --git a/core/cortex-m/mpu.c b/core/cortex-m/mpu.c
index c0793180dc..953cbb7393 100644
--- a/core/cortex-m/mpu.c
+++ b/core/cortex-m/mpu.c
@@ -6,9 +6,9 @@
/* MPU module for Chrome EC */
#include "builtin/assert.h"
-#include "mpu.h"
#include "console.h"
#include "cpu.h"
+#include "mpu.h"
#include "registers.h"
#include "task.h"
#include "util.h"
@@ -95,6 +95,17 @@ int mpu_update_region(uint8_t region, uint32_t addr, uint8_t size_bit,
}
/*
+ * Align address to a maximum of 31 bits
+ */
+uint32_t align_down_to_bits(uint32_t addr, uint8_t addr_bits)
+{
+ if (addr_bits < 32)
+ return addr & ~((1u << addr_bits) - 1);
+ else
+ return addr;
+}
+
+/*
* Greedily configure the largest possible part of the given region from the
* base address.
*
@@ -140,7 +151,7 @@ static int mpu_config_region_greedy(uint8_t region, uint32_t addr,
* disabling if it is not completely contained in the requested
* range.
*/
- subregion_base = addr & ~((1 << natural_alignment) - 1);
+ subregion_base = align_down_to_bits(addr, natural_alignment);
subregion_size = 1 << (natural_alignment - 3);
*consumed = 0;
for (sr_idx = 0; sr_idx < 8; sr_idx++) {
@@ -159,7 +170,8 @@ static int mpu_config_region_greedy(uint8_t region, uint32_t addr,
*consumed = 1 << natural_alignment;
}
- return mpu_update_region(region, addr & ~((1 << natural_alignment) - 1),
+ return mpu_update_region(region,
+ align_down_to_bits(addr, natural_alignment),
natural_alignment, attr, enable,
subregion_disable);
}
diff --git a/core/cortex-m/panic.c b/core/cortex-m/panic.c
index 0f803dc8e5..1de8376cfb 100644
--- a/core/cortex-m/panic.c
+++ b/core/cortex-m/panic.c
@@ -7,8 +7,8 @@
#include "console.h"
#include "cpu.h"
#include "host_command.h"
-#include "panic.h"
#include "panic-internal.h"
+#include "panic.h"
#include "printf.h"
#include "system.h"
#include "task.h"
diff --git a/core/cortex-m/vecttable.c b/core/cortex-m/vecttable.c
index 037bc28c36..aea4bf3dc7 100644
--- a/core/cortex-m/vecttable.c
+++ b/core/cortex-m/vecttable.c
@@ -9,6 +9,7 @@
#define ___INIT
#include "compiler.h"
#include "config.h"
+
#include <task.h>
#endif
diff --git a/core/cortex-m0/build.mk b/core/cortex-m0/build.mk
index 7de8956a4d..f3cce27eea 100644
--- a/core/cortex-m0/build.mk
+++ b/core/cortex-m0/build.mk
@@ -6,6 +6,14 @@
# Cortex-M0 core OS files build
#
+# When set to 1, exclusively use builtins from compiler-rt.
+# When set to 0, use EC's builtins.
+USE_LLVM_COMPILER_RT:=0
+
+ifeq ($(USE_LLVM_COMPILER_RT),1)
+CFLAGS_CPU+=-DUSE_LLVM_COMPILER_RT
+endif
+
# CPU specific compilation flags
CFLAGS_CPU+=-mthumb
ifeq ($(cc-name),clang)
@@ -24,14 +32,12 @@ LDFLAGS_EXTRA+=-flto
endif
core-y=cpu.o debug.o init.o thumb_case.o mula.o
-# When using clang, we get these as builtins from compiler-rt.
-ifneq ($(cc-name),clang)
+ifeq ($(USE_LLVM_COMPILER_RT),0)
core-y+=div.o lmul.o ldivmod.o uldivmod.o
endif
core-y+=vecttable.o
-# When using clang, we get these as builtins from compiler-rt.
-ifneq ($(cc-name),clang)
+ifeq ($(USE_LLVM_COMPILER_RT),0)
core-y+=__builtin.o
endif
core-$(CONFIG_COMMON_PANIC_OUTPUT)+=panic.o
diff --git a/core/cortex-m0/config_core.h b/core/cortex-m0/config_core.h
index 9ef52f848a..63e6da8972 100644
--- a/core/cortex-m0/config_core.h
+++ b/core/cortex-m0/config_core.h
@@ -12,12 +12,11 @@
/*
* Emulate the CLZ/CTZ instructions since the CPU core is lacking support.
- * When building with clang, we rely on compiler_rt to provide this support.
*/
-#ifndef __clang__
+#ifndef USE_LLVM_COMPILER_RT
#define CONFIG_SOFTWARE_CLZ
#define CONFIG_SOFTWARE_CTZ
-#endif /* __clang__ */
+#endif /* USE_LLVM_COMPILER_RT */
#define CONFIG_ASSEMBLY_MULA32
diff --git a/core/cortex-m0/cpu.h b/core/cortex-m0/cpu.h
index 568b16eedb..bdb7a3c6f5 100644
--- a/core/cortex-m0/cpu.h
+++ b/core/cortex-m0/cpu.h
@@ -8,10 +8,11 @@
#ifndef __CROS_EC_CPU_H
#define __CROS_EC_CPU_H
-#include <stdint.h>
#include "compile_time_macros.h"
#include "debug.h"
+#include <stdint.h>
+
/* Macro to access 32-bit registers */
#define CPUREG(addr) (*(volatile uint32_t *)(addr))
diff --git a/core/cortex-m0/panic.c b/core/cortex-m0/panic.c
index 3e4c1eb3be..533e45713d 100644
--- a/core/cortex-m0/panic.c
+++ b/core/cortex-m0/panic.c
@@ -7,8 +7,8 @@
#include "console.h"
#include "cpu.h"
#include "host_command.h"
-#include "panic.h"
#include "panic-internal.h"
+#include "panic.h"
#include "printf.h"
#include "system.h"
#include "task.h"
diff --git a/core/cortex-m0/vecttable.c b/core/cortex-m0/vecttable.c
index 7fd5c7fb8f..050a7d318a 100644
--- a/core/cortex-m0/vecttable.c
+++ b/core/cortex-m0/vecttable.c
@@ -7,13 +7,13 @@
#ifndef ___INIT
#define ___INIT
-#include <stddef.h>
-#include <stdint.h>
-
#include "compiler.h"
#include "config.h"
#include "panic-internal.h"
#include "task.h"
+
+#include <stddef.h>
+#include <stdint.h>
#endif /* __INIT */
typedef void (*func)(void);
diff --git a/core/host/host_task.h b/core/host/host_task.h
index 82b33f96c5..e79111f6f4 100644
--- a/core/host/host_task.h
+++ b/core/host/host_task.h
@@ -8,10 +8,10 @@
#ifndef __CROS_EC_HOST_TASK_H
#define __CROS_EC_HOST_TASK_H
-#include <pthread.h>
-
#include "task.h"
+#include <pthread.h>
+
/**
* Returns the thread corresponding to the task.
*/
diff --git a/core/host/panic.c b/core/host/panic.c
index e354757d75..0dd00ac604 100644
--- a/core/host/panic.c
+++ b/core/host/panic.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
+#include "config.h"
+#include "panic.h"
+#include "stack_trace.h"
+
#include <assert.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <stdint.h>
#include <string.h>
-#include "config.h"
-#include "panic.h"
-#include "stack_trace.h"
-
void panic_assert_fail(const char *msg, const char *func, const char *fname,
int linenum)
{
diff --git a/core/host/stack_trace.c b/core/host/stack_trace.c
index f8918b1c57..4f4ab380d9 100644
--- a/core/host/stack_trace.c
+++ b/core/host/stack_trace.c
@@ -3,14 +3,15 @@
* found in the LICENSE file.
*/
-#include <execinfo.h>
+#include "host_task.h"
+#include "host_test.h"
+#include "timer.h"
+
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
-#include "host_task.h"
-#include "host_test.h"
-#include "timer.h"
+#include <execinfo.h>
#define SIGNAL_TRACE_DUMP SIGTERM
#define MAX_TRACE 30
@@ -40,6 +41,11 @@ static void __attribute__((noinline)) _task_dump_trace_impl(int offset)
int i, nb;
sz = backtrace(trace, MAX_TRACE);
+ if (sz < offset) {
+ fprintf(stderr, "Can't print backtrace: %ld < %d\n", sz,
+ offset);
+ return;
+ }
messages = backtrace_symbols(trace + offset, sz - offset);
for (i = 0; i < sz - offset; ++i) {
diff --git a/core/host/task.c b/core/host/task.c
index 31ea386f2e..fa853dce60 100644
--- a/core/host/task.c
+++ b/core/host/task.c
@@ -5,15 +5,6 @@
/* Task scheduling / events module for Chrome EC operating system */
-#include <malloc.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <signal.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
#include "atomic.h"
#include "common.h"
#include "console.h"
@@ -23,6 +14,16 @@
#include "test_util.h"
#include "timer.h"
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <malloc.h>
+#include <pthread.h>
+#include <semaphore.h>
+
#define SIGNAL_INTERRUPT SIGUSR1
struct emu_task_t {
diff --git a/core/host/timer.c b/core/host/timer.c
index 66f047cd4d..b2c9c5c478 100644
--- a/core/host/timer.c
+++ b/core/host/timer.c
@@ -5,15 +5,15 @@
/* Timer module */
-#include <stdint.h>
-#include <stdio.h>
-
#include "builtin/assert.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
#include "util.h"
+#include <stdint.h>
+#include <stdio.h>
+
static timestamp_t boot_time;
static int time_set;
diff --git a/core/minute-ia/mpu.c b/core/minute-ia/mpu.c
index d91d71f99c..6cbf4c634f 100644
--- a/core/minute-ia/mpu.c
+++ b/core/minute-ia/mpu.c
@@ -5,8 +5,8 @@
/* MPU module for ISH */
-#include "mpu.h"
#include "console.h"
+#include "mpu.h"
#include "registers.h"
#include "task.h"
#include "util.h"
diff --git a/core/minute-ia/task.c b/core/minute-ia/task.c
index b4b747baa0..540e387d2a 100644
--- a/core/minute-ia/task.c
+++ b/core/minute-ia/task.c
@@ -16,14 +16,14 @@
#include "builtin/assert.h"
#include "common.h"
#include "console.h"
+#include "hpet.h"
+#include "interrupts.h"
#include "link_defs.h"
#include "panic.h"
#include "task.h"
+#include "task_defs.h"
#include "timer.h"
#include "util.h"
-#include "task_defs.h"
-#include "interrupts.h"
-#include "hpet.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_SYSTEM, outstr)
diff --git a/core/riscv-rv32i/panic.c b/core/riscv-rv32i/panic.c
index 3ac34c7774..0ea86840f9 100644
--- a/core/riscv-rv32i/panic.c
+++ b/core/riscv-rv32i/panic.c
@@ -3,8 +3,8 @@
* found in the LICENSE file.
*/
-#include "cpu.h"
#include "console.h"
+#include "cpu.h"
#include "panic.h"
#include "task.h"
#include "util.h"
diff --git a/cts/common/th_common.c b/cts/common/th_common.c
index 3084579b99..cc9c6be75f 100644
--- a/cts/common/th_common.c
+++ b/cts/common/th_common.c
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
+#include "cts_common.h"
#include "gpio.h"
#include "timer.h"
#include "watchdog.h"
-#include "cts_common.h"
/* Return SUCCESS if and only if we reach end of function
* Returning success here means sync was successful
diff --git a/cts/gpio/dut.c b/cts/gpio/dut.c
index 92ae893a48..ef609cf4a8 100644
--- a/cts/gpio/dut.c
+++ b/cts/gpio/dut.c
@@ -4,13 +4,12 @@
*/
#include "common.h"
+#include "cts_common.h"
#include "gpio.h"
-#include "watchdog.h"
-#include "uart.h"
#include "task.h"
#include "timer.h"
+#include "uart.h"
#include "watchdog.h"
-#include "cts_common.h"
enum cts_rc sync_test(void)
{
diff --git a/cts/gpio/th.c b/cts/gpio/th.c
index 98fc232d1c..54a083cef9 100644
--- a/cts/gpio/th.c
+++ b/cts/gpio/th.c
@@ -4,13 +4,12 @@
*/
#include "common.h"
+#include "cts_common.h"
#include "gpio.h"
-#include "watchdog.h"
-#include "uart.h"
#include "task.h"
#include "timer.h"
+#include "uart.h"
#include "watchdog.h"
-#include "cts_common.h"
enum cts_rc sync_test(void)
{
diff --git a/cts/i2c/th.c b/cts/i2c/th.c
index ef57f6300c..b613f2d25d 100644
--- a/cts/i2c/th.c
+++ b/cts/i2c/th.c
@@ -3,7 +3,6 @@
* found in the LICENSE file.
*/
-#include <string.h>
#include "common.h"
#include "cts_common.h"
#include "cts_i2c.h"
@@ -14,6 +13,8 @@
#include "uart.h"
#include "watchdog.h"
+#include <string.h>
+
static uint8_t inbox[I2C_MAX_HOST_PACKET_SIZE + 2];
static char data_received;
diff --git a/cts/interrupt/dut.c b/cts/interrupt/dut.c
index c2e0af0f81..15bba740f0 100644
--- a/cts/interrupt/dut.c
+++ b/cts/interrupt/dut.c
@@ -3,7 +3,6 @@
* found in the LICENSE file.
*/
-#include <string.h>
#include "common.h"
#include "cts_common.h"
#include "gpio.h"
@@ -12,6 +11,8 @@
#include "timer.h"
#include "watchdog.h"
+#include <string.h>
+
static int got_interrupt;
static int wake_me_up;
static int state_index;
diff --git a/cts/mutex/dut.c b/cts/mutex/dut.c
index c48dfcaa64..c4778de957 100644
--- a/cts/mutex/dut.c
+++ b/cts/mutex/dut.c
@@ -6,8 +6,8 @@
* Tasks for mutexes basic tests.
*/
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "cts_common.h"
#include "task.h"
#include "test_util.h"
diff --git a/cts/mutex/th.c b/cts/mutex/th.c
index c48dfcaa64..c4778de957 100644
--- a/cts/mutex/th.c
+++ b/cts/mutex/th.c
@@ -6,8 +6,8 @@
* Tasks for mutexes basic tests.
*/
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "cts_common.h"
#include "task.h"
#include "test_util.h"
diff --git a/docs/code_coverage.md b/docs/code_coverage.md
index 49b6cfb493..0a5eeb3150 100644
--- a/docs/code_coverage.md
+++ b/docs/code_coverage.md
@@ -80,10 +80,10 @@ The coverage report top-level page is
`build/zephyr/coverage_rpt/index.html`.
For coverage report for a single test you can run:
-`./twister -v -i --coverage -p native_posix -p unit_testing -s <pathToTest>/<testName>`
+`./twister -v -i --coverage -p native_posix -p unit_testing -s external/platform/ec/zephyr/test/<testDir>/<testName>`
Example of running test tasks.default from zephyr/test/tasks/testcase.yaml:
-`./twister -v -i --coverage -p native_posix -p unit_testing -s zephyr/test/tasks/tasks.default`
+`./twister -v -i --coverage -p native_posix -p unit_testing -s external/platform/ec/zephyr/test/tasks/tasks.default`
## Code Coverage in CQ
diff --git a/docs/gitlab.md b/docs/gitlab.md
index 9f8d07ceec..2ebc5c60f7 100644
--- a/docs/gitlab.md
+++ b/docs/gitlab.md
@@ -45,7 +45,7 @@ sudo dpkg -i gitlab-runner_amd64.deb
### Running a Job
Once Docker and the Gitlab Runner are installed, invoke it as follows. This
-takes place outside of the
+takes place outside of the chroot environment.
```
(outside)
@@ -82,3 +82,72 @@ If you used the command as shown above, all of the build artifacts and source,
as checked out by the Gitlab runner, should be under `~/gitlab-runner-output`.
This will persist after the container exits but also get overwritten again on
the next run.
+
+## Gitlab runners
+
+The gitlab builds run on a number of [virtual and real machines](https://gitlab.com/groups/zephyr-ec/-/runners)
+which are currently at Simon's house, and cloud virtual machines.
+
+### Create a new VM
+
+* Visit https://pantheon.corp.google.com/compute/instances?onCreate=true&project=chromeos-ec-gitlab
+ * Click on instance-1
+ * Click create similar
+* Wait for new instance to be created
+* Click on SSH
+* Install docker
+```
+sudo apt-get remove docker docker-engine docker.io containerd runc
+sudo apt-get update
+sudo apt-get install \
+ ca-certificates \
+ curl \
+ gnupg \
+ lsb-release
+sudo mkdir -p /etc/apt/keyrings
+curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
+echo \
+ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
+ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
+sudo apt-get update
+sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
+sudo docker run hello-world
+```
+* Install gitlab runner
+```
+sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
+sudo chmod +x /usr/local/bin/gitlab-runner
+sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
+sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
+sudo gitlab-runner start
+```
+* Register new runner using command from https://gitlab.com/groups/zephyr-ec/-/runners (click on Register a group runner, click on show instructions, click on Linux)
+```
+sudo gitlab-runner register --url https://gitlab.com/ --registration-token TOKENGOESHERE
+Runtime platform arch=amd64 os=linux pid=56156 revision=bbcb5aba version=15.3.0
+Running in system-mode.
+
+Enter the GitLab instance URL (for example, https://gitlab.com/):
+[https://gitlab.com/]:
+Enter the registration token:
+[TOKENGOESHERE]:
+Enter a description for the runner:
+[instance-2]: Cloud runner instance-2
+Enter tags for the runner (comma-separated):
+
+Enter optional maintenance note for the runner:
+
+Registering runner... succeeded runner=TOKENGOESHERE
+Enter an executor: docker, parallels, shell, docker-ssh+machine, custom, docker-ssh, ssh, virtualbox, docker+machine, kubernetes:
+docker
+Enter the default Docker image (for example, ruby:2.7):
+ruby:2.7
+Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
+
+Configuration (with the authentication token) was saved in "/etc/gitlab-runner/config.toml"
+```
+
+* Install cleanup docker cleanup daily cron
+```
+( echo "0 3 * * * /usr/bin/docker system prune -f -a --volumes" ; sudo crontab -l -u root ) | sudo crontab -u root -
+```
diff --git a/docs/low_battery_startup.md b/docs/low_battery_startup.md
index 48f9c28f49..1f94d4956e 100644
--- a/docs/low_battery_startup.md
+++ b/docs/low_battery_startup.md
@@ -77,8 +77,7 @@ analog signaling alone. Via digital communication in the PD protocol, much
higher power states may be negotiated. However, higher power states also usually
run at a higher voltage state as well. Any time the voltage level is changing,
the power sink (the ChromeOS device) must lower its power consumption during the
-transient. The standby current level is governed by
-`CONFIG_CHARGER_INPUT_CURRENT`.
+transient.
PD port partners are capable of both soft and hard resets. Hard resets will
cause a dead-bus state for a brief interval before PD can renegotiate, from
@@ -169,7 +168,7 @@ is robust enough to support the device during brief intervals of PD negotiation
without browning out.
```
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 1
```
@@ -206,7 +205,7 @@ the kernel and get to the login screen.
```
/* Limit battery impact during PD voltage changes. */
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
/* Distrust the battery SOC measurement a bit. */
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 3
@@ -257,7 +256,7 @@ less. Very briefly drawing current out of the battery does not cause a brownout.
Example configuration:
```
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON 3
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON 15000
#define CONFIG_CHARGER_LIMIT_POWER_THRESH_CHG_MW 27000
@@ -301,7 +300,7 @@ performing a no-battery boot. Nami is an exemplar.
Example configuration:
```
-#define CONFIG_CHARGER_INPUT_CURRENT 512
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 512
#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC 1
#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT 15000
@@ -337,17 +336,27 @@ Example configuration:
## Configuration Option Details
-### `CONFIG_CHARGER_INPUT_CURRENT`
+### `CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT`
Required.
-The lowest current limit programmed into the charger. This determines both the
-default level used on startup, and the value used during the voltage transients
-in PD negotiation.
+The default charger current limit used on startup and for inactive ports. It
+should not be higher than 512 mA unless the device ships with a discrete power
+supply. Raising this term above 512 mA is contrary to USB-PD. It may be lowered
+in order to improve compatibility with marginal BC1.2 chargers.
-It should not be higher than 512 mA unless the device ships with a discrete
-power supply. Raising this term above 512 mA is contrary to USB-PD. It may be
-lowered in order to improve compatibility with marginal BC1.2 chargers.
+### `CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT`
+
+Optional.
+
+If set, charger input current limits will never be set lower than this value.
+Historically most boards used the same value
+as `CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT`, but doing so violates USB-PD standby
+power requirements when voltages greater than 5V are used with the default 512
+mA value. Configuring this option to a nonzero value may be useful if a board
+needs extra headroom (possibly at the cost of drawing excess standby power), but
+boards should prefer to override `board_set_charge_limit()` instead to limit
+situations with excess power draw to only occur when that extra power is needed.
### `CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON`
diff --git a/docs/zephyr/README.md b/docs/zephyr/README.md
index 3b8b8dc05e..84239d3b05 100644
--- a/docs/zephyr/README.md
+++ b/docs/zephyr/README.md
@@ -110,7 +110,7 @@ The following provides an overview of the sub-directories found under
sub-directory.
* `zephyr/linker/` - Linker directive files used to construct the Zephyr EC
binaries.
-* `zephyr/projects/` - Program-specific configurations for each program
+* `zephyr/program/` - Program-specific configurations for each program
supported by Zephyr.
* `zephyr/shim/` - Source code that adapts the legacy EC APIs to the equivalent
Zephyr OS API.
diff --git a/docs/zephyr/project_config.md b/docs/zephyr/project_config.md
index f930908502..f81cc083c9 100644
--- a/docs/zephyr/project_config.md
+++ b/docs/zephyr/project_config.md
@@ -3,29 +3,174 @@ Project Configuration
[TOC]
-## Setting up a new program ("reference board" or "baseboard")
-
-Unlike the legacy EC codebase, Zephyr projects all live together in
-one big happy directory. The intent of this design is to encourage
-code-sharing between projects, and reduce the amount of copy/paste
-that is required to bring up a new project. This directory can, but
-does not have to, correlate to the unified build Chrome OS board,
-however firmware authors can always choose a different structure if it
-makes sense for the specific scenario. As a hypothetical example,
-similar Chromeboxes and Chromebooks may wish to share the Zephyr EC
-project directory instead of use separate directories, even if they
-are using a different unified build board.
-
-To set up a new EC program, create a new directory under
-[`zephyr/projects`](../../zephyr/projects) with the following files:
-
-- `BUILD.py` - specifies which builds can be made from this directory,
- and what the device-tree overlays and Kconfig files are for each
- build.
-- `CMakeLists.txt` - Baseboard-specific C files can be listed here.
-- `prj.conf` (optional) - Default Kconfig settings for all projects.
-- `Kconfig` (optional) - Set options for your reference design here,
- which variants can use to install optional C sources.
+## Overview
+
+This document defines the organization of the program and project specific files
+needed by Zephyr EC projects.
+
+The goals of the project organization include:
+
+* Minimize code duplication, allowing multiple projects to share common
+ configuration options and devicetree nodes.
+* Define the set of files required by each project.
+* Define the best practices for devicetrees.
+
+
+### Glossary
+
+- **program**: The name of a Chromebook reference design. The **program**
+ includes all Chromebooks based on a single AP SoC, such as Intel MeteorLake,
+ Qualcomm 7c G3, or AMD Mendocino. The **program** corresponds to a single
+ board overlay in the ChromeOS SDK. The term *baseboard* is often used as a
+ synonym for **program**.
+
+- **project**: The name of a specific Chromebook model or variant. All
+ Chromebook **programs** contain at least one **project** which serves as the
+ reference design(s) for the **program**. The reference **project** may or may
+ not use the same name as the **program**. For example, the reference
+ **project** for the skyrim **program** is also called skyrim. The corsola
+ **program** included two reference **projects**, kingler and krabby. For the
+ legacy ECOS builds, *board* was used as a synonym for **project**.
+
+This document uses bold to highlight the terms **program** and **project** to
+reference the definitions above.
+
+## Directory Structure
+
+The [`zephyr/program`](../../zephyr/program) contains the **program** and
+**project** configuration files for all Zephyr based EC builds.
+
+### `zephyr/program` directory
+
+Each **program** has it's own subdirectory under `zephyr/program`.
+
+```
+zephyr/program/
+├── brya/
+├── corsola/
+├── herobrine/
+├── intelrvp/
+├── it8xxx2_evb/
+├── minimal/
+├── nissa/
+├── npcx_evb/
+├── rex/
+├── skyrim/
+└── trogdor/
+```
+
+> The [`zephyr/program/minimal`](../../zephyr/program/minimal/) **program**
+contains example EC projects that demonstrate how to build a Zephyr EC with the
+minimum feature set enabled. These projects require only a working UART on the
+target board.
+
+### `zephyr/program/`**`<program>`**`/` Directory Overview
+
+Each **program** subdirectory contains a subdirectory foreach each **project**,
+including a subdirectory for the reference **project**.
+
+The minimum configuration for a **program** named *skyrim* with just a single
+reference **project**, also named *skyrim*, is shown below.
+
+```
+zephyr/program/skyrim/
+├── include/
+│ └── <program headers>.h
+├── skyrim/
+│ ├── include/
+│ │ └── <project headers>.h
+│ ├── src/
+│ │ └── <project sources>.c
+│ ├── CMakeLists.txt
+│ ├── project.conf
+│ └── project.overlay
+├── src/
+│ └── <program sources>.c
+├── BUILD.py
+├── CMakeLists.txt
+├── Kconfig
+├── program.conf
+└── <devicetrees>.dtsi
+```
+
+#### `zephyr/program/`**`<program>`**`/` Directory Details
+
+Description of the files and directories found directly in the **<program>**
+level directory. Note that all paths are relative to the `zephyr/program/`
+directory.
+
+- **`<program>`**`/`: Top level directory for the **program**. [skyrim] is the
+ *program* name in the example above.
+- **`<program>`**`/include/`: Directory containing the header files common to
+ all **projects** in the **program**. Use of **program** level includes is
+ discouraged. Instead, consider creating a generic driver that can be shared
+ across all **programs**.
+- **`<program>`**`/src/`: Directory containing the C source files common to all
+ **projects** in the **program**.
+- [**`<program>`**`/BUILD.py`](#build_py): Defines which **projects** can be
+ made from this directory.
+- [**`<program>`**`/CMakeLists.txt`](#cmakelists_txt): CMake file for the
+ **program**.
+- [**`<program>`**`/Kconfig`](#kconfig) - Defines new Kconfig options, used by
+ all **projects** in the **program**.
+- [**`<program>`**`/program.conf`](#program_conf) - Sets the default Kconfig
+ settings for all **projects**.
+- **`<program>`**`/<devictrees>.dtsi` - One or more devicetree files, organized
+ by the hardware module or EC feature. See the [Devicetree Best
+ Practices](#devicetree-best-practices) section for additional information.
+- **`<program>`**`/`**`<project>`**`/`: Top level directory for the
+ **<project**>. Create a separate directory for each **project** defined by the
+ **program**.
+
+### `zephyr/program/`**`<program>`**`/`**`<project>`**`/` Directory Details
+
+Each **project** provides the following files. Note that all paths are relative
+to the `zephyr/program/`**`<program>`**`/` directory.
+
+- **`<project>`**`/include/`: The **project** may optionally provide a public
+ include directory, but this is discouraged. There are some exceptions where
+ the legacy EC code expects the project to define a public header, such as the
+ keyboard_customization.h file.
+- **`<project>`**`/src/`: Directory containing the C source files specific to
+ the **project**.
+- [**`<project>`**`/CMakeLists.txt`](#cmakelists_txt): CMake file for the
+ **project**.
+- [**`<project>`**`/project.conf`](#project_conf): Kconfig settings for the
+ **project**.
+- [**`<project>`**`/project.overlay`](#project_overlay): Main devicetree overlay
+ for the **project**.
+
+Creation of custom C source files specific to the **program** or **project** is
+discouaraged. You can usually project manage project specific settings with
+Kconfig and devicetree changes only.
+
+Note that **program** and **project** custom C files are still subject to the
+same unit test requirements. So all custom C files also require that you write
+tests.
+
+## Setting up a new **program**
+
+To set up a new EC **program**, create a new directory under
+[`zephyr/program`] with the organization shown below.
+Note that for this example, the new **program** is called "my_program", and the
+reference **project** is called "my_reference_project".
+
+> Tip - Copy one the **projects** defined by the [*minimal*] **program** to
+> start with the bare miminimum of features required to boot the Zephyr EC
+> appliation. Then follow the steps in the detailed in [Creating a New Zephyr EC
+> Project].
+
+```
+zephyr/program/my_program/
+├── my_reference_project/
+│ ├── CMakeLists.txt
+│ ├── project.conf
+│ └── project.overlay
+├── BUILD.py
+├── CMakeLists.txt
+├── Kconfig
+└── program.conf
+```
An in-depth example of each file is given below:
@@ -50,18 +195,24 @@ When `BUILD.py` is sourced, the following two globals are defined:
Google codename). This name must be unique amongst all projects
known to `zmake`, and `zmake` will error if you choose a conflicting
name.
-- `zephyr_board` (required): The name of the Zephyr board to use for
- the project. The Zephyr build system expects a Zephyr board
- directory under `boards/${ARCH}/${ZEPHYR_BOARD_NAME}`. **Note:**
- the concept of a Zephyr board does not align with the Chrome OS
- concept of a board: for most projects this will typically be the
- name of the EC chip used, not the name of the model or overlay.
+- `zephyr_board` (required): The name of the EC chip used. **Note:** the concept
+ of a Zephyr board does not align with the ChromeOS concept of a board. The
+ Zephyr build system requires a set of devicetree and Kconfig files under under
+ `boards/${ARCH}/${ZEPHYR_BOARD_NAME}`. For the Zephyr EC application, the EC
+ chip is mapped onto the Zephyr board organization. Supported `zephyr_boards`
+ include:
+ - `mec1727`: Microchip MEC1727, 416 KiB RAM, 512 KiB flash
+ - `npcx7`: Nuvoton NPCX7m7FC, 384 KiB, 512 KiB flash
+ - `npcx9m3f`: Nuvoton NPCX9m3F, 320 KiB RAM, 512 KiB flash
+ - `npcx9m7f`: Nuvoton NPCX9m7F, 384 KiB RAM, 1 MiB flash
+ - `it81202bx`: ITE IT81202, 60 KiB RAM, 1 MiB flash
+ - `it81302bx`: ITE IT81302, 60 KiB RAM, 1 MiB flash
- `supported_toolchains` (required): A list of the toolchain names
- supported by the build. Valid values are `coreboot-sdk`, `host`,
- `llvm`, and `zephyr`. Note that only `coreboot-sdk` and `llvm` are
- supported in the chroot, and all projects must be able to build in
- the chroot, so your project must at least list one of `coreboot-sdk`
- or `llvm`.
+ supported by the build. Valid values are:
+ - `coreboot-sdk`: only supported in the chroot
+ - `host`: used for unit and integration tests
+ - `llvm`: only supported in the chroot
+ - `zephyr`: only supported outside the chroot
- `output_packer` (required): An output packer type which defines
which builds get generated, and how they get assembled together into
a binary.
@@ -77,9 +228,22 @@ When `BUILD.py` is sourced, the following two globals are defined:
be used when running the test. Instances of `{test_temp_dir}`
inside of an argument will be replaced with a path to a temporary
directory guaranteed to be unique for the current execution.
-- `dts_overlays` (optional): A list of files which should be
- concatenated together and applied as a Zephyr device-tree overlay.
- Defaults to no overlays (empty list).
+- `dts_overlays` (optional): A list of files which should be concatenated
+ together and applied as a Zephyr device-tree overlay. The recommended setting
+ is to select the **project** specific devicetree overlay file.
+
+ ``` python
+ dts_overlays=[here / project_name / "project.overlay"]
+ ```
+
+- `kconfig_files` (optional): A list of files that contain the Kconfig settings
+ for the **project**. The recommended setting is select the **program**
+ configuration file followed by the **project** configuration file.
+
+ ``` python
+ kconfig_files=[here / "program.conf", here / <project> / "project.conf",]
+ ```
+
- `project_dir` (optional): The path to where `CMakeLists.txt` and
`Kconfig` can be found for the project, defaulting to `here`.
@@ -113,18 +277,33 @@ This file, should at minimum contain the following:
cmake_minimum_required(VERSION 3.20.1)
find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
-project(ec)
+project(**project**)
+```
+
+If your **program** provides any C files, add them to your program CMake file
+using `zephyr_library_sources()`.
+
+``` cmake
+zephyr_library_sources("src/my_program_source.c")
+```
+
+For your **project** C files, create **`<project>/`**`CMakeLists.txt` and use
+`add_subdirectory()` to include the **project** CMake file.
+
+``` cmake
+add_subdirectory("my_reference_project")
```
-You may additionally want to specify any C files your project needs
-using `zephyr_library_sources`. If you need to add extra include
-directories, use `cros_ec_library_include_directories`.
+Add the requires `zephyr_library_souces()` calls to the
+**`<project>/`**`CMakeLists.txt` file.
-### prj.conf and prj_${project_name}.conf
+If your **program** or **project** provides a public header, make the include
+directory visible to rest of the code using
+`cros_ec_library_include_directories()`.
-`prj.conf` has default Kconfig settings for all projects, and
-`prj_${project_name}.conf` can contain overrides for certain projects.
-The format is `KEY=VALUE`, as typical for Kconfig.
+``` cmake
+cros_ec_library_include_directories("include")
+```
### Kconfig
@@ -136,6 +315,33 @@ The file must end with a single line that reads
`source "Kconfig.zephyr"`. Note that this file is optional, so it's
recommended to only include it if you really need it.
+### program.conf
+
+`program.conf` has default Kconfig settings for all **projects** defined for the
+**program**. The format is `KEY=VALUE`, as typical for Kconfig.
+
+### project.conf
+
+`project.conf` has the Kconfig settings for a single **project**. The format is
+`KEY=VALUE`, as typical for Kconfig.
+
+Kconfig settings in `project.conf` take precedence over the Kconfig settings
+from `program.conf`.
+
+### project.overlay
+
+`project.overlay` is the main devicetree overlay for the **project**. The
+`project.overlay` contains the following components:
+- One or more `#include` statements to add devicetrees defined by the
+ **program** into project.
+- `/delete-node/` statements to remove specific devicetree nodes defined by the
+ **program** devicetrees.
+- New devicetree nodes for **project** specific settings that are not provided
+ by any **program** devicetrees.
+
+> Tip: After building your **project**, you can view the final devicetree in the
+file `build/zephyr/`**`<project>`**`/build-ro/zephyr/zephyr.dts`.
+
## Setting up a new variant of an EC program
**Unlike our legacy EC, there are no files or directories to copy and
@@ -194,3 +400,167 @@ With this simple variant syntax, lists (like Kconfig files and DTS
overlays) are concatenated. This means it's not possible to remove
files during variant registration for this syntax, so it's only
recommended for the simple case.
+
+## Devicetree Best Practices
+
+Below are the best practices for devicetree organization:
+
+* Split the devicetree across multiple files, organized by the functional block.
+ This organization applies to the shared **program** devicetrees only.
+ * FW_CONFIG
+ * GPIOs
+ * I2C
+ * Interrupts
+ * Keyboard
+ * LEDs
+ * Sensors
+ * Thermal (fans and temperature sensors)
+ * USB-C
+* When creating **program**, usually with a single reference project, add the
+ shared devicetree files in the program directory, separated by the functional
+ area noted above.
+* Each project creates a `project.overlay` file, and uses `#include` statements
+ to add shared devicetree files from the program directory. An example
+ project.overlay for the skyrim project is shown below.
+
+ ``` c
+ /* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+ /* Skyrim program common DTS includes */
+ #include "../adc.dtsi"
+ #include "../fan.dtsi"
+ #include "../gpio.dtsi"
+ #include "../i2c.dtsi"
+ #include "../interrupts.dtsi"
+ #include "../keyboard.dtsi"
+ #include "../motionsense.dtsi"
+ #include "../usbc.dtsi"
+
+ /* Skyrim project node overrides */
+ /* ... */
+ ```
+
+### Managing **project** specific settings
+
+When the **project** needs to make changes to the shared devicetree files, there
+are two strategies:
+
+* For small changes, add the `/delete-node/` attribute to the `project.overlay`
+ file to remove the specific devices and devicetree nodes from the **project**
+ final devicetree.
+* For larger changes, remove the corresponding `#include` statements from the
+ `project.overlay` file. Then,dDirectly add any required nodes to the
+ `project.overlay` file.
+
+In both cases, the shared devicetree file in the **program** directory is not
+changed.
+
+### Small Devicetree Changes
+
+Examples of small devicetree changes include:
+* Change the I2C peripheral address of a device.
+* Changing USB-C related chips.
+* Changing motionsense properties, such as the odr and ec-rate properties.
+* Overriding a specific property of a node - for instance modifying the
+ `pinctrl-0` property to adjust the EC pins connected to a device driver.
+
+The example below demonstrates how to define a device in a **program**
+devicetree file and then override the setting in the `project.overlay` file.
+
+* The herobrine program defines the TCPC at I2C address `0xb` in the file
+`zephyr/program/herobrine/i2c.dtsi`. This I2C address is valid for the
+herobrine, evoker, and villager projects while the hoglin project needs to
+change the I2C address to `0x1b`.
+
+ ``` c
+ /* zephyr/program/herobrine/i2c.dtsi */
+
+ &i2c1_0 {
+ status = "okay";
+ /* ... */
+ tcpc_port0: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ };
+ };
+ ````
+* The hoglin `project.overlay` file deletes the TCPC node at address `0xb` and
+creates a new node at address `0x1b`. The node name “tcpc_port0” is kept the
+same, so any references to this node name do not change, such as the USB-C port
+configuration.
+
+ ``` c
+ /* zephyr/program/herobrine/hoglin/project.overlay */
+
+ #include “../i2c.dtsi”
+
+ &i2c1_0 {
+ /delete-node/ ps8xxx@b;
+ tcpc_port0: ps8xxx@1b {
+ compatible = "parade,ps8xxx";
+ reg = <0x1b>;
+ };
+ };
+ ```
+
+While it is also possible to change a device’s I2C address by directly
+overriding the `reg` property, this should not be done. Changing only the `reg`
+property causes a mismatch between the node name, `ps8xxx@b`, and the actual
+device address, `0x1b`.
+
+Your `project.overlay` file can also directly override properties defined by the
+**program** devicetree files.
+
+* The skyrim **program** sets the I2C clock frequency for first I2C bus to fast
+ (400 KHz).
+ ``` c
+ /* zephyr/program/skyrim/i2c.dtsi */
+ &i2c0_0 {
+ status = "okay";
+ label = "I2C_TCPC0";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
+ pinctrl-names = "default";
+ };
+ ```
+* Override the I2C clock frequency to fast-plus (1 MHz) in the winterhold
+ `project.overlay`.
+ ``` c
+ /* zephyr/program/skyrim/winterhold/project.overlay */
+ #include "../i2c.dtsi"
+ &i2c0_0 {
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+ };
+ ```
+### Large Devicetree Changes
+
+For large devicetree changes, the preference is to copy the relevant devicetree
+fragment into the `project.overlay` file and edit the fragment directly.
+
+Examples of large devicetree changes (or changes that don’t benefit from using
+the /delete-node/ attribute) include:
+* GPIOs - specifically the “named-gpios” node. This integrates better with the
+ arbitrage and the pinmap utility, which auto-generates the EC GPIO settings
+ based on schematic data.
+* Changes to the motionsense sensor types. Currently x86 architectures impose a
+ fixed ordering for the accelerometers and gryoscopes when accessed through the
+ LPC memory map (see the [`EC_MEMMAP_ACC_DATA`]). Deleting nodes changes the
+ order of the children under the motionsense-sense node and causes the test
+ [`hardware.SensorAccel`] to fail. Copy the motionsense nodes into the
+ project.overlay file and modify as required.
+* LED policies - generally each OEM/ODM defines unique LED policies for their
+ designs to establish differentiation for their brand. There is little value to
+ creating common LED policies for all **projects** in the **program**.
+* Batteries - batteries also are generally specific to the OEM/ODM. Define the
+ **project** batteries directly in the `project.overlay` file.
+
+
+[skyrim]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/HEAD:src/platform/ec/zephyr/program/skyrim
+[`zephyr/program`]: ../../zephyr/program/
+[*minimal*]: ../../zephyr/program/minimal/
+[Creating a New Zephyr EC Project]: ./zephyr_new_board_checklist.md
+[`EC_MEMMAP_ACC_DATA`]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/HEAD:src/platform/ec/include/ec_commands.h;l=181
+[`hardware.SensorAccel`]: https://crsrc.org/o/src/platform/tast-tests/src/chromiumos/tast/local/bundles/cros/hardware/sensor_accel.go;drc=8fbf2c53960bc8917a6a01fda5405cad7c17201e;l=30
diff --git a/docs/zephyr/zephyr_battery.md b/docs/zephyr/zephyr_battery.md
index 3dde8cb9cf..02ed5d424b 100644
--- a/docs/zephyr/zephyr_battery.md
+++ b/docs/zephyr/zephyr_battery.md
@@ -17,7 +17,8 @@ Refer to [Kconfig.battery] for all sub-options controlling battery behavior.
#### Enable battery feature configs
-Add battery configs to `ec/zephyr/projects/{project}/{board}/prj.conf`.
+Add battery configs to either the [`program.conf`] or [`project.conf`] file for
+your project.
Example:
@@ -271,3 +272,5 @@ Usage:
[ectool]: ../ap-ec-comm.md
[task]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/shim/include/shimmed_task_id.h
[*node label*]: https://docs.zephyrproject.org/latest/build/dts/intro.html#dt-node-labels
+[`program.conf`]: ./project_config.md#program_conf
+[`project.conf`]: ./project_config.md#project_conf
diff --git a/docs/zephyr/zephyr_charger.md b/docs/zephyr/zephyr_charger.md
index 8bb4f8d3f5..0dc62f2b5d 100644
--- a/docs/zephyr/zephyr_charger.md
+++ b/docs/zephyr/zephyr_charger.md
@@ -20,7 +20,9 @@ charging configuration found in [Kconfig.usb_charger].
### Example of enabled configs
-In `ec/zephyr/projects/{project}/{board}/prj.conf`, one may add:
+Enable and disable charger configs in either the [`program.conf`] or
+[`project.conf`] file for your project.
+
```
# Charger
@@ -289,3 +291,5 @@ The [chargestate] command may also be invoked.
[ectool]: ../docs/ap-ec-comm.md
[mapping legacy I2C port numbers to Zephyr devicetree nodes]: ./zephyr_i2c.md#mapping-legacy-i2c-port-numbers-to-zephyr-devicetree-nodes
[pwr_avg]: ./zephyr_battery.md#pwr_avg
+[`program.conf`]: ./project_config.md#program_conf
+[`project.conf`]: ./project_config.md#project_conf
diff --git a/docs/zephyr/zephyr_leds.md b/docs/zephyr/zephyr_leds.md
index b29b4ab610..3f57aea013 100644
--- a/docs/zephyr/zephyr_leds.md
+++ b/docs/zephyr/zephyr_leds.md
@@ -53,23 +53,23 @@ gpio-led-pins {
compatible = "cros-ec,gpio-led-pins";
/* Amber - turn on yellow LED */
color_amber: color-amber {
- led-pins = <&gpio_ec_chg_led_y_c1 1>,
- <&gpio_ec_chg_led_b_c1 0>;
+ led-pins = <&gpio_ec_chg_led_y_c1 &gpio_ec_chg_led_b_c1>;
+ led-values = <1 0>;
};
/* Blue - turn on blue LED */
color_blue: color-blue {
- led-pins = <&gpio_ec_chg_led_y_c1 0>,
- <&gpio_ec_chg_led_b_c1 1>;
+ led-pins = <&gpio_ec_chg_led_y_c1 &gpio_ec_chg_led_b_c1>;
+ led-values = <0 1>;
};
/* White - turn on both LEDs */
color_white: color-white {
- led-pins = <&gpio_ec_chg_led_y_c1 1>,
- <&gpio_ec_chg_led_b_c1 1>;
+ led-pins = <&gpio_ec_chg_led_y_c1 &gpio_ec_chg_led_b_c1>;
+ led-values = <1 1>;
};
/* Off - turn off both LEDs */
color_off: color-off {
- led-pins = <&gpio_ec_chg_led_y_c1 0>,
- <&gpio_ec_chg_led_b_c1 0>;
+ led-pins = <&gpio_ec_chg_led_y_c1 &gpio_ec_chg_led_b_c1>;
+ led-values = <0 0>;
};
};
```
@@ -77,7 +77,7 @@ GPIO LED Pins dts file example: [led_pins_herobrine.dts]
#### PWM based LEDs
Configure PWM based LEDs with two separate nodes.
-The `cros-ec,pwm-pin-config` node, described in [cros-ec,pwm_led_pin_config.yaml], configures the PWM channel and frequency.
+The `pwm-leds` node, described in [pwm-leds.yaml], configures the PWM channel and frequency.
The `cros-ec,pwm-led-pins` node, described in [cros-ec,pwm_led_pins.yaml], configures the LED colors.
PWM LEDs can vary duty-cycle percentage, providing finer color control over GPIO LEDs.
@@ -86,16 +86,14 @@ Example:
For this example, the board contains dual-channel LED, one channel controls white color intensity, and one channel controls the amber color intensity.
To set the LED color to amber, the yellow channel duty-cycle is set to 100 percentage and white channel duty-cycle is set to 0.
```
-pwm_pins {
- compatible = "cros-ec,pwm-pin-config";
+pwmleds {
+ compatible = "pwm-leds";
pwm_y: pwm_y {
- #led-pin-cells = <1>;
pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
};
pwm_w: pwm_w {
- #led-pin-cells = <1>;
pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
};
};
@@ -105,18 +103,18 @@ pwm-led-pins {
pwm-frequency = <100>;
/* Amber - turn on yellow LED */
color_amber: color-amber {
- led-pins = <&pwm_y 100>,
- <&pwm_w 0>;
+ led-pwms = <&pwm_y &pwm_w>;
+ pwm-values = <100 0>;
};
/* White - turn on white LED */
color_white: color-white {
- led-pins = <&pwm_y 0>,
- <&pwm_w 100>;
+ led-pwms = <&pwm_y &pwm_w>;
+ pwm-values = <0 100>;
};
/* Off - turn off both LEDs */
color_off: color-off {
- led-pins = <&pwm_y 0>,
- <&pwm_w 0>;
+ led-pwms = <&pwm_y &pwm_w>;
+ pwm-values = <0 0>;
};
};
```
@@ -198,7 +196,7 @@ TODO: Enable support for ledtest
- Look for the gpio/pwm pins in the schematic with which the LEDs are attached to.
- In the above snippet, LEDs are configured to use PWM pins and attached to PWM2 and PWM3.
-- Add PWM config nodes as shown in [cros-ec,pwm_led_pin_config.yaml] and [led_pins_skyrim.dts].
+- Add PWM config nodes as shown in [pwm-leds.yaml] and [led_pins_skyrim.dts].
- Add pin nodes based on the color of the LEDs attached as shown in [cros-ec,pwm_led_pins.yaml] and [led_pins_skyrim.dts]. Name the nodes according to the LED color for readability. e.g. `color-amber`
- Based on the device LED policy, create led_policy nodes as shown in [cros-ec,led_policy.yaml] and [led_policy_skyrim.dts].
@@ -214,10 +212,10 @@ TODO: Enable support for ledtest
[cros-ec,led_policy.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/dts/bindings/leds/cros-ec,led-colors.yaml
[cros-ec,gpio_led_pins.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml
[cros-ec,pwm_led_pins.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml
-[cros-ec,pwm_led_pin_config.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/dts/bindings/leds/cros-ec,pwm-led-pin-config.yaml
-[led_policy_skyrim.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/projects/skyrim/led_policy_skyrim.dts
-[led_pins_skyrim.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/projects/skyrim/led_pins_skyrim.dts
-[led_policy_herobrine.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/projects/herobrine/led_policy_herobrine.dts
-[led_pins_herobrine.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/projects/herobrine/led_pins_herobrine.dts
+[pwm-leds.yaml]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/third_party/zephyr/main/dts/bindings/led/pwm-leds.yaml
+[led_policy_skyrim.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/skyrim/led_policy_skyrim.dts
+[led_pins_skyrim.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/skyrim/led_pins_skyrim.dts
+[led_policy_herobrine.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/herobrine/led_policy_herobrine.dts
+[led_pins_herobrine.dts]: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/herobrine/led_pins_herobrine.dts
[Example CL enabling single port pwm based LEDs]: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3651490
[Example CL enabling dual port gpio based LEDs]: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3635067
diff --git a/docs/zephyr/zephyr_mkbp.md b/docs/zephyr/zephyr_mkbp.md
index bedc550f7d..186ea9ce44 100644
--- a/docs/zephyr/zephyr_mkbp.md
+++ b/docs/zephyr/zephyr_mkbp.md
@@ -76,7 +76,7 @@ Possible enums to use in these nodes are specified in file: [MKBP event mask enu
## Examples
-[Lazor wake-up masks](https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/projects/trogdor/lazor/gpio.dts?q=ec-mkbp-host-event-wakeup-mask)
+[Lazor wake-up masks](https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/zephyr/program/trogdor/lazor/gpio.dts?q=ec-mkbp-host-event-wakeup-mask)
For detailed descriptions of the MKBP and host event types, please see
[ec_commands.h](/include/ec_commands.h) header file.
diff --git a/docs/zephyr/zephyr_new_board_checklist.md b/docs/zephyr/zephyr_new_board_checklist.md
index 9baaaf4c42..4b3917581b 100644
--- a/docs/zephyr/zephyr_new_board_checklist.md
+++ b/docs/zephyr/zephyr_new_board_checklist.md
@@ -37,7 +37,7 @@ Each feature includes the following sub-tasks:
- **Example** - This section walks through a complete example for configuring an
EC feature based on existing board implementation.
-## Adding a new board to zmake
+## Adding a new project to zmake
Refer the [project configuration](project_config.md) documentation to add a new
board project to zmake.
diff --git a/docs/zephyr/zephyr_ssfc.md b/docs/zephyr/zephyr_ssfc.md
index d40fdbc9c4..6a3fe079d3 100644
--- a/docs/zephyr/zephyr_ssfc.md
+++ b/docs/zephyr/zephyr_ssfc.md
@@ -25,11 +25,11 @@ Device tree is used to define and specify the field sizes and values.
## Devicetree Nodes
-The [`SSFC`] device tree nodes are defined via the [`named-cbi-ssfc`] and
-[`named-cbi-ssfc-value`] YAML bindings.
+The [`SSFC`] device tree nodes are defined via the [`cros-ec,cbi-ssfc`] and
+[`cros-ec,cbi-ssfc-value`] YAML bindings.
-The [`named-cbi-ssfc`] bindings define the name and size of each field.
-The [`named-cbi-ssfc-value`] bindings allow names/values to be defined for each
+The [`cros-ec,cbi-ssfc`] bindings define the name and size of each field.
+The [`cros-ec,cbi-ssfc-value`] bindings allow names/values to be defined for each
value that may be stored in the field.
One of the values may be designated as the default, which is used if
the [`CBI`] data cannot be accessed.
@@ -41,12 +41,12 @@ value is used as a default, indicating the default field.
An example definition is:
```
cbi-ssfc {
- compatible = "named-cbi-ssfc";
+ compatible = "cros-ec,cbi-ssfc";
base_sensor {
enum-name = "BASE_SENSOR";
size = <3>;
base_sensor_0: bmi160 {
- compatible = "named-cbi-ssfc-value";
+ compatible = "cros-ec,cbi-ssfc-value";
status = "okay";
value = <1>;
};
@@ -55,7 +55,7 @@ cbi-ssfc {
enum-name = "LID_SENSOR";
size = <3>;
lid_sensor_0: bma255 {
- compatible = "named-cbi-ssfc-value";
+ compatible = "cros-ec,cbi-ssfc-value";
status = "okay";
value = <1>;
};
@@ -64,7 +64,7 @@ cbi-ssfc {
enum-name = "LIGHTBAR";
size = <2>;
lightbar_0: 10_led {
- compatible = "named-cbi-ssfc-value";
+ compatible = "cros-ec,cbi-ssfc-value";
status = "okay";
value = <1>;
};
@@ -99,6 +99,6 @@ The [`ectool cbi`] command can be used to read and set the [`SSFC`].
[`CBI`]: https://chromium.googlesource.com/chromiumos/docs/+/HEAD/design_docs/cros_board_info.md
[`CBI Configuration`]: ./zephyr_cbi.md
[`ectool cbi`]: ./zephyr_cbi.md#testing-and-debugging
-[`named-cbi-ssfc`]: ../../zephyr/dts/bindings/cbi/named-cbi-fw-config.yaml
-[`named-cbi-ssfc-value`]: ../../zephyr/dts/bindings/cbi/named-cbi-fw-config-value.yaml
+[`cros-ec,cbi-ssfc`]: ../../zephyr/dts/bindings/cbi/cros-ec,cbi-fw-config.yaml
+[`cros-ec,cbi-ssfc-value`]: ../../zephyr/dts/bindings/cbi/cros-ec,cbi-fw-config-value.yaml
[`SSFC`]: https://chromium.googlesource.com/chromiumos/docs/+/HEAD/design_docs/firmware_config.md
diff --git a/docs/zephyr/zephyr_temperature_sensor.md b/docs/zephyr/zephyr_temperature_sensor.md
index 8ee87a84f7..7be5f5ccaf 100644
--- a/docs/zephyr/zephyr_temperature_sensor.md
+++ b/docs/zephyr/zephyr_temperature_sensor.md
@@ -76,7 +76,7 @@ on Zephyr-based boards.
Temperature sensors are declared as separate nodes and additional properties are
defined by the `cros-ec,temp-sensors` node in the device tree. This example is
-from [zephyr/projects/brya/temp_sensors.dts](../../zephyr/projects/brya/temp_sensors.dts):
+from [zephyr/program/brya/temp_sensors.dts](../../zephyr/program/brya/temp_sensors.dts):
```
temp_ddr_soc: ddr_soc {
diff --git a/docs/zephyr/zephyr_troubleshooting.md b/docs/zephyr/zephyr_troubleshooting.md
index 646240ce18..a7a7716e5e 100644
--- a/docs/zephyr/zephyr_troubleshooting.md
+++ b/docs/zephyr/zephyr_troubleshooting.md
@@ -12,10 +12,10 @@ The build system lists the various overlay files specified by `BUILD.py`, for
example:
```
--- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/projects/brya/adc.dts
--- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/projects/brya/battery.dts
--- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/projects/brya/cbi_eeprom.dts
--- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/projects/brya/fan.dts
+-- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/program/brya/adc.dts
+-- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/program/brya/battery.dts
+-- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/program/brya/cbi_eeprom.dts
+-- Found devicetree overlay: /mnt/host/source/src/platform/ec/zephyr/program/brya/fan.dts
...
```
diff --git a/docs/zephyr/ztest.md b/docs/zephyr/ztest.md
index 437c79d12e..d6b598b0e3 100644
--- a/docs/zephyr/ztest.md
+++ b/docs/zephyr/ztest.md
@@ -120,24 +120,39 @@ For most use cases these are the things to remember:
## Running twister
-Run all tests under a specific directory:
+### Run all tests under a specific directory
```shell
platform/ec$ ./twister -T path/to/my/tests
```
-Run a specific test:
+### Run a specific test
```shell
-platform/ec$ ./twister -s path/to/my/tests/my.test.case
+platform/ec$ ./twister -s external/platform/ec/zephyr/test/<test dir>/<my.test.case>
```
-Run all tests with coverage (get more info on code coverage at
-[Zephyr ztest code coverage](../code_coverage.md#Zephyr_ztest_code_coverage):
+For example:
+```shell
+platform/ec$ ./twister -s external/platform/ec/zephyr/test/drivers/drivers.default
+```
+
+Explanation of this string: `external/` is not a path component, but rather a
+label that indicates we are running tests from outside of the Zephyr tree;
+`platform/ec/zephyr/test/` is the location of our tests relative to the first
+common parent of `ZEPHYR_BASE` and `platform/ec`; `drivers` is the directory for
+our driver tests, and `drivers.default` is a specific test scenario defined in
+that directory's `testcase.yaml` file.
+
+### Run all tests with coverage
+
+You can find more info on code coverage at
+[Zephyr ztest code coverage](../code_coverage.md#Zephyr_ztest_code_coverage).
+
```shell
platform/ec$ ./twister -p native_posix -p unit_testing --coverage
```
-Get more info on twister:
+### Get more info on twister
```shell
platform/ec$ ./twister --help
```
@@ -151,38 +166,11 @@ Other useful flags:
## Using assumptions
-The `zassume_*` API is used to minimize failures while allowing us to find out
-exactly what's going wrong. When writing a test, only assert on code you're
-testing. Any dependencies should use the `zassume_*` API. If the assumption
-fails, your test will be marked as skipped and Twister will report an error.
-Generally speaking, if an assumption fails, either the test wasn't set up
-correctly, or there should be another test that's testing the dependency.
-
-### Example: when to use an assumption
-
-In a given project layout we might have several components (A, B, C, and D). In
-this scenario, components B, C, and D all depend on A to function. In each test
-for B, C, and D we'll include the following:
-
-```c
-static void test_suite_before(void *f)
-{
- struct my_suite_fixture *fixture = f;
-
- zassume_ok(f->a->init(), "Failed to initialize A, see test suite 'a_init'");
-}
-```
-
-The above will call A's init function and assume that it returned 0 (status OK).
-If this assumption fails, then B, C, and D will all be marked as skipped along
-with a log message telling us to look at the test suite 'a_init'.
-
-Key takeaways:
-1. If it's code that you depend on (module/library/logic), use assume. It's not
- what you're testing, you shouldn't raise false failures.
-2. Document why/where you believe that the logic should have been tested. If we
- end up skipping this test, we should know where the tests that should have
- caught the error belong.
+The `zassume*` API is used to skip tests when certain preconditions are not
+met. Please don't use it. In our tests we shouldn't ever need to skip tests
+since we control all dependencies. If for some reason you actually need to skip
+a test use `ztest_test_skip()` since that will indicate that you intended to
+skip and didn't use assume by mistake when you meant to use assert.
## Debugging
diff --git a/driver/accel_bma2x2.c b/driver/accel_bma2x2.c
index 08e818cb8d..772ae64696 100644
--- a/driver/accel_bma2x2.c
+++ b/driver/accel_bma2x2.c
@@ -9,11 +9,11 @@
* Supported: BMA255
*/
+#include "accel_bma2x2.h"
#include "accelgyro.h"
#include "builtin/assert.h"
#include "common.h"
#include "console.h"
-#include "accel_bma2x2.h"
#include "i2c.h"
#include "math_util.h"
#include "spi.h"
diff --git a/driver/accel_bma4xx.c b/driver/accel_bma4xx.c
index b731bca422..29d05a35d8 100644
--- a/driver/accel_bma4xx.c
+++ b/driver/accel_bma4xx.c
@@ -9,17 +9,18 @@
* Supported: BMA422
*/
-#include "accelgyro.h"
#include "accel_bma422.h"
+#include "accelgyro.h"
#include "builtin/assert.h"
#include "common.h"
#include "console.h"
-#include "i2c.h"
#include "hwtimer.h"
+#include "i2c.h"
#include "math_util.h"
#include "spi.h"
#include "task.h"
#include "util.h"
+
#include <motion_sense_fifo.h>
#ifdef CONFIG_ACCEL_BMA4XX_INT_EVENT
diff --git a/driver/accel_bma4xx.h b/driver/accel_bma4xx.h
index afa0776a38..778150e30a 100644
--- a/driver/accel_bma4xx.h
+++ b/driver/accel_bma4xx.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_ACCEL_BMA4XX_H
#define __CROS_EC_ACCEL_BMA4XX_H
+#include "config.h"
+
#define BMA4_I2C_ADDR_PRIMARY 0x18
#define BMA4_I2C_ADDR_SECONDARY 0x19
#define BMA4_I2C_BMM150_ADDR 0x10
@@ -194,6 +196,8 @@
extern const struct accelgyro_drv bma4_accel_drv;
#if defined(CONFIG_ZEPHYR)
+#include <zephyr/devicetree.h>
+
#if DT_NODE_EXISTS(DT_ALIAS(bma4xx_int))
/*
* Get the motion sensor ID of the BMA4xx sensor that generates the interrupt.
@@ -209,6 +213,9 @@ extern const struct accelgyro_drv bma4_accel_drv;
*/
#define CONFIG_ACCEL_BMA4XX_INT_EVENT \
TASK_EVENT_MOTION_SENSOR_INTERRUPT(SENSOR_ID(DT_ALIAS(bma4xx_int)))
+
+#include "gpio_signal.h"
+void bma4xx_interrupt(enum gpio_signal signal);
#endif /* DT_NODE_EXISTS */
#endif /* CONFIG_ZEPHYR */
diff --git a/driver/accel_kionix.c b/driver/accel_kionix.c
index cc12987f40..c04855c89d 100644
--- a/driver/accel_kionix.c
+++ b/driver/accel_kionix.c
@@ -9,12 +9,12 @@
* Supported: KX022, KXCJ9
*/
-#include "accelgyro.h"
-#include "common.h"
-#include "console.h"
#include "accel_kionix.h"
#include "accel_kx022.h"
#include "accel_kxcj9.h"
+#include "accelgyro.h"
+#include "common.h"
+#include "console.h"
#include "i2c.h"
#include "math_util.h"
#include "motion_orientation.h"
diff --git a/driver/accel_kionix.h b/driver/accel_kionix.h
index 8777396e01..4f5d02ee55 100644
--- a/driver/accel_kionix.h
+++ b/driver/accel_kionix.h
@@ -8,8 +8,8 @@
#ifndef __CROS_EC_ACCEL_KIONIX_H
#define __CROS_EC_ACCEL_KIONIX_H
-#include "common.h"
#include "accelgyro.h"
+#include "common.h"
#include "driver/accel_kx022.h"
#include "driver/accel_kxcj9.h"
diff --git a/driver/accel_lis2dh.c b/driver/accel_lis2dh.c
index eaedb216d7..26954f3c4b 100644
--- a/driver/accel_lis2dh.c
+++ b/driver/accel_lis2dh.c
@@ -11,14 +11,14 @@
#include "accelgyro.h"
#include "common.h"
#include "console.h"
+#include "driver/accel_lis2dh.h"
+#include "driver/stm_mems_common.h"
#include "hooks.h"
#include "hwtimer.h"
#include "i2c.h"
#include "math_util.h"
#include "task.h"
#include "util.h"
-#include "driver/accel_lis2dh.h"
-#include "driver/stm_mems_common.h"
#define CPUTS(outstr) cputs(CC_ACCEL, outstr)
#define CPRINTS(format, args...) cprints(CC_ACCEL, format, ##args)
diff --git a/driver/accel_lis2dw12.c b/driver/accel_lis2dw12.c
index 3cf3e4b64a..42d9381bda 100644
--- a/driver/accel_lis2dw12.c
+++ b/driver/accel_lis2dw12.c
@@ -7,10 +7,10 @@
* LIS2DW12 accelerometer module for Chrome EC 3D digital accelerometer.
* For more details on LIS2DW12 device please refers to www.st.com.
*/
+#include "accel_lis2dw12.h"
#include "accelgyro.h"
#include "common.h"
#include "console.h"
-#include "accel_lis2dw12.h"
#include "hooks.h"
#include "hwtimer.h"
#include "math_util.h"
diff --git a/driver/accelgyro_bmi160.c b/driver/accelgyro_bmi160.c
index 0a736760d0..7a398e5f4b 100644
--- a/driver/accelgyro_bmi160.c
+++ b/driver/accelgyro_bmi160.c
@@ -9,14 +9,14 @@
*/
#include "accelgyro.h"
+#include "accelgyro_bmi160.h"
+#include "accelgyro_bmi_common.h"
#include "builtin/assert.h"
#include "common.h"
#include "console.h"
-#include "accelgyro_bmi_common.h"
-#include "accelgyro_bmi160.h"
-#include "mag_bmm150.h"
#include "hwtimer.h"
#include "i2c.h"
+#include "mag_bmm150.h"
#include "math_util.h"
#include "motion_orientation.h"
#include "motion_sense_fifo.h"
diff --git a/driver/accelgyro_bmi260.c b/driver/accelgyro_bmi260.c
index f0b16be4d5..1b47983b80 100644
--- a/driver/accelgyro_bmi260.c
+++ b/driver/accelgyro_bmi260.c
@@ -9,10 +9,10 @@
*/
#include "accelgyro.h"
+#include "accelgyro_bmi260.h"
+#include "accelgyro_bmi_common.h"
#include "builtin/assert.h"
#include "console.h"
-#include "accelgyro_bmi_common.h"
-#include "accelgyro_bmi260.h"
#include "hwtimer.h"
#include "i2c.h"
#include "init_rom.h"
diff --git a/driver/accelgyro_bmi_common.c b/driver/accelgyro_bmi_common.c
index 73131b0aae..27aab34c3e 100644
--- a/driver/accelgyro_bmi_common.c
+++ b/driver/accelgyro_bmi_common.c
@@ -9,11 +9,11 @@
*/
#include "accelgyro.h"
-#include "console.h"
#include "accelgyro_bmi_common.h"
+#include "console.h"
+#include "i2c.h"
#include "mag_bmm150.h"
#include "mag_lis2mdl.h"
-#include "i2c.h"
#include "math_util.h"
#include "motion_sense_fifo.h"
#include "spi.h"
diff --git a/driver/accelgyro_icm42607.c b/driver/accelgyro_icm42607.c
index 28a131d33f..f57f11fae2 100644
--- a/driver/accelgyro_icm42607.c
+++ b/driver/accelgyro_icm42607.c
@@ -10,8 +10,8 @@
#include "accelgyro.h"
#include "console.h"
-#include "driver/accelgyro_icm_common.h"
#include "driver/accelgyro_icm42607.h"
+#include "driver/accelgyro_icm_common.h"
#include "hwtimer.h"
#include "i2c.h"
#include "math_util.h"
diff --git a/driver/accelgyro_icm426xx.c b/driver/accelgyro_icm426xx.c
index 0311ed8187..c3c9e2225f 100644
--- a/driver/accelgyro_icm426xx.c
+++ b/driver/accelgyro_icm426xx.c
@@ -10,8 +10,8 @@
#include "accelgyro.h"
#include "console.h"
-#include "driver/accelgyro_icm_common.h"
#include "driver/accelgyro_icm426xx.h"
+#include "driver/accelgyro_icm_common.h"
#include "hwtimer.h"
#include "i2c.h"
#include "math_util.h"
diff --git a/driver/accelgyro_icm_common.c b/driver/accelgyro_icm_common.c
index 22a2b0820d..44a3b61370 100644
--- a/driver/accelgyro_icm_common.c
+++ b/driver/accelgyro_icm_common.c
@@ -10,10 +10,10 @@
#include "accelgyro.h"
#include "console.h"
+#include "driver/accelgyro_icm426xx.h"
+#include "driver/accelgyro_icm_common.h"
#include "i2c.h"
#include "spi.h"
-#include "driver/accelgyro_icm_common.h"
-#include "driver/accelgyro_icm426xx.h"
#define CPUTS(outstr) cputs(CC_ACCEL, outstr)
#define CPRINTF(format, args...) cprintf(CC_ACCEL, format, ##args)
diff --git a/driver/accelgyro_icm_common.h b/driver/accelgyro_icm_common.h
index 400c56ba6f..32adf6f5ff 100644
--- a/driver/accelgyro_icm_common.h
+++ b/driver/accelgyro_icm_common.h
@@ -8,12 +8,12 @@
#ifndef __CROS_EC_ACCELGYRO_ICM_COMMON_H
#define __CROS_EC_ACCELGYRO_ICM_COMMON_H
-#include <sys/types.h>
-
#include "accelgyro.h"
+#include "builtin/stddef.h"
#include "hwtimer.h"
#include "timer.h"
-#include "builtin/stddef.h"
+
+#include <sys/types.h>
#if !defined(CONFIG_ACCELGYRO_ICM_COMM_SPI) && \
!defined(CONFIG_ACCELGYRO_ICM_COMM_I2C)
diff --git a/driver/accelgyro_lsm6dsm.h b/driver/accelgyro_lsm6dsm.h
index 51da2a42fb..8fa53c6a6d 100644
--- a/driver/accelgyro_lsm6dsm.h
+++ b/driver/accelgyro_lsm6dsm.h
@@ -8,10 +8,10 @@
#ifndef __CROS_EC_ACCELGYRO_LSM6DSM_H
#define __CROS_EC_ACCELGYRO_LSM6DSM_H
-#include "stm_mems_common.h"
-#include "mag_cal.h"
#include "mag_bmm150.h"
+#include "mag_cal.h"
#include "mag_lis2mdl.h"
+#include "stm_mems_common.h"
/*
* 7-bit address is 110101xb. Where 'x' is determined
diff --git a/driver/als_cm32183.c b/driver/als_cm32183.c
index d97c179fe8..a2ee9f365e 100644
--- a/driver/als_cm32183.c
+++ b/driver/als_cm32183.c
@@ -5,10 +5,10 @@
* CAPELLA CM32183 light sensor driver
*/
+#include "accelgyro.h"
#include "common.h"
#include "driver/als_cm32183.h"
#include "i2c.h"
-#include "accelgyro.h"
#include "math_util.h"
struct cm32183_drv_data {
diff --git a/driver/als_tcs3400.c b/driver/als_tcs3400.c
index 002e269ada..8874ce79d6 100644
--- a/driver/als_tcs3400.c
+++ b/driver/als_tcs3400.c
@@ -5,9 +5,9 @@
* AMS TCS3400 light sensor driver
*/
#include "accelgyro.h"
+#include "als_tcs3400.h"
#include "common.h"
#include "console.h"
-#include "als_tcs3400.h"
#include "hooks.h"
#include "hwtimer.h"
#include "i2c.h"
diff --git a/driver/amd_stt.c b/driver/amd_stt.c
index 93da8cecb5..a80220033c 100644
--- a/driver/amd_stt.c
+++ b/driver/amd_stt.c
@@ -4,8 +4,8 @@
*/
#include "amd_stt.h"
-#include "common.h"
#include "chipset.h"
+#include "common.h"
#include "console.h"
#include "driver/sb_rmi.h"
#include "hooks.h"
diff --git a/driver/battery/bq27621_g1.c b/driver/battery/bq27621_g1.c
index f29039f0c1..73ca8476b3 100644
--- a/driver/battery/bq27621_g1.c
+++ b/driver/battery/bq27621_g1.c
@@ -11,8 +11,8 @@
#include "extpower.h"
#include "hooks.h"
#include "i2c.h"
-#include "util.h"
#include "timer.h"
+#include "util.h"
#define BQ27621_ADDR_FLAGS 0x55
#define BQ27621_TYPE_ID 0x0621
diff --git a/driver/bc12/max14637.c b/driver/bc12/max14637.c
index 09fa009c45..a2603c7973 100644
--- a/driver/bc12/max14637.c
+++ b/driver/bc12/max14637.c
@@ -13,13 +13,13 @@
*/
#include "builtin/assert.h"
-#include "max14637.h"
#include "charge_manager.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
#include "gpio.h"
#include "hooks.h"
+#include "max14637.h"
#include "power.h"
#include "power/cannonlake.h"
#include "task.h"
diff --git a/driver/bc12/mt6360.c b/driver/bc12/mt6360.c
index 49ec031e09..ca4bf11794 100644
--- a/driver/bc12/mt6360.c
+++ b/driver/bc12/mt6360.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include "charger.h"
#include "charge_manager.h"
+#include "charger.h"
#include "console.h"
#include "crc8.h"
-#include "mt6360.h"
#include "ec_commands.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
+#include "mt6360.h"
#include "task.h"
#include "timer.h"
#include "usb_charge.h"
diff --git a/driver/bc12/pi3usb9201.c b/driver/bc12/pi3usb9201.c
index e892c34e8c..4e39933657 100644
--- a/driver/bc12/pi3usb9201.c
+++ b/driver/bc12/pi3usb9201.c
@@ -5,12 +5,12 @@
/* PI3USB9201 USB BC 1.2 Charger Detector driver. */
-#include "pi3usb9201.h"
#include "charge_manager.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
#include "gpio.h"
+#include "pi3usb9201.h"
#include "power.h"
#include "task.h"
#include "timer.h"
diff --git a/driver/charger/bd9995x.c b/driver/charger/bd9995x.c
index aa37bf4e8a..f8e426fdc3 100644
--- a/driver/charger/bd9995x.c
+++ b/driver/charger/bd9995x.c
@@ -18,9 +18,9 @@
#include "panic.h"
#include "task.h"
#include "time.h"
-#include "util.h"
#include "usb_charge.h"
#include "usb_pd.h"
+#include "util.h"
#define OTPROM_LOAD_WAIT_RETRY 3
@@ -904,7 +904,8 @@ static void bd9995x_battery_charging_profile_settings(int chgnum)
const struct battery_info *bi = battery_get_info();
/* Input Current Limit Setting */
- bd9995x_set_input_current_limit(chgnum, CONFIG_CHARGER_INPUT_CURRENT);
+ bd9995x_set_input_current_limit(chgnum,
+ CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT);
/* Charge Termination Current Setting */
ch_raw_write16(chgnum, BD9995X_CMD_ITERM_SET, 0,
@@ -1004,10 +1005,10 @@ static void bd9995x_init(void)
* Disable the input current limit when VBAT is < VSYSREG_SET. This
* needs to be done before calling
* bd9995x_battery_charging_profile_settings() as in that function the
- * input current limit is set to CONFIG_CHARGER_INPUT_CURRENT which is
- * 512 mA. In deeply discharged battery cases, setting the input current
- * limit this low can cause VSYS to collapse, which in turn can cause
- * the EC's brownout detector to reset the EC.
+ * input current limit is set to CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT
+ * which is 512 mA. In deeply discharged battery cases, setting the
+ * input current limit this low can cause VSYS to collapse, which in
+ * turn can cause the EC's brownout detector to reset the EC.
*/
if (ch_raw_read16(CHARGER_SOLO, BD9995X_CMD_VIN_CTRL_SET, &reg,
BD9995X_EXTENDED_COMMAND))
diff --git a/driver/charger/bq24715.c b/driver/charger/bq24715.c
index 8e8e0efd50..6855d6e334 100644
--- a/driver/charger/bq24715.c
+++ b/driver/charger/bq24715.c
@@ -8,8 +8,8 @@
#include "battery_smart.h"
#include "bq24715.h"
#include "charger.h"
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "i2c.h"
#include "util.h"
@@ -207,8 +207,8 @@ static enum ec_error_list bq24715_post_init(int chgnum)
if (rv)
return rv;
- rv = bq24715_set_input_current_limit(chgnum,
- CONFIG_CHARGER_INPUT_CURRENT);
+ rv = bq24715_set_input_current_limit(
+ chgnum, CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT);
return rv;
}
diff --git a/driver/charger/bq24773.c b/driver/charger/bq24773.c
index bfa0aa36e7..d678944ceb 100644
--- a/driver/charger/bq24773.c
+++ b/driver/charger/bq24773.c
@@ -8,8 +8,8 @@
#include "battery_smart.h"
#include "bq24773.h"
#include "charger.h"
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "util.h"
/*
diff --git a/driver/charger/bq25710.c b/driver/charger/bq25710.c
index 831f7e110d..222d2f58a4 100644
--- a/driver/charger/bq25710.c
+++ b/driver/charger/bq25710.c
@@ -5,8 +5,6 @@
* TI bq25710 battery charger driver.
*/
-#include <stdbool.h>
-
#include "battery.h"
#include "battery_smart.h"
#include "bq257x0_regs.h"
@@ -17,11 +15,13 @@
#include "console.h"
#include "hooks.h"
#include "i2c.h"
-#include "task.h"
#include "system.h"
+#include "task.h"
#include "timer.h"
#include "util.h"
+#include <stdbool.h>
+
#if !defined(CONFIG_CHARGER_BQ25710) && !defined(CONFIG_CHARGER_BQ25720)
#error Only the BQ25720 and BQ25710 are supported by bq25710 driver.
#endif
diff --git a/driver/charger/isl923x.c b/driver/charger/isl923x.c
index 2263c45b78..dac1df69a2 100644
--- a/driver/charger/isl923x.c
+++ b/driver/charger/isl923x.c
@@ -11,9 +11,9 @@
#include "builtin/assert.h"
#include "charge_state_v2.h"
#include "charger.h"
+#include "common.h"
#include "compile_time_macros.h"
#include "console.h"
-#include "common.h"
#include "hooks.h"
#include "i2c.h"
#include "isl923x.h"
@@ -772,7 +772,7 @@ static void isl923x_init(int chgnum)
* Initialize the input current limit to the board's default.
*/
if (isl923x_set_input_current_limit(
- chgnum, CONFIG_CHARGER_INPUT_CURRENT))
+ chgnum, CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT))
goto init_fail;
}
@@ -865,7 +865,7 @@ enum ec_error_list raa489000_is_acok(int chgnum, bool *acok)
{
int regval, rv;
- if ((chgnum < 0) || (chgnum > board_get_charger_chip_count())) {
+ if ((chgnum < 0) || (chgnum >= board_get_charger_chip_count())) {
CPRINTS("%s: Invalid chgnum! (%d)", __func__, chgnum);
return EC_ERROR_INVAL;
}
@@ -890,7 +890,7 @@ void raa489000_hibernate(int chgnum, bool disable_adc)
{
int rv, regval;
- if ((chgnum < 0) || (chgnum > board_get_charger_chip_count())) {
+ if ((chgnum < 0) || (chgnum >= board_get_charger_chip_count())) {
CPRINTS("%s: Invalid chgnum! (%d)", __func__, chgnum);
return;
}
diff --git a/driver/charger/isl9241.c b/driver/charger/isl9241.c
index 9ca2e9f3e0..445d94734c 100644
--- a/driver/charger/isl9241.c
+++ b/driver/charger/isl9241.c
@@ -11,11 +11,11 @@
#endif
#include "battery.h"
#include "battery_smart.h"
-#include "charger.h"
#include "charge_manager.h"
#include "charge_state.h"
-#include "console.h"
+#include "charger.h"
#include "common.h"
+#include "console.h"
#include "hooks.h"
#include "i2c.h"
#include "isl9241.h"
@@ -893,8 +893,8 @@ static void isl9241_init(int chgnum)
return;
/* Initialize the input current limit to the board's default. */
- if (isl9241_set_input_current_limit(chgnum,
- CONFIG_CHARGER_INPUT_CURRENT))
+ if (isl9241_set_input_current_limit(
+ chgnum, CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT))
goto init_fail;
return;
diff --git a/driver/charger/rt946x.c b/driver/charger/rt946x.c
index 58b5c1adb4..0e52d8e3bb 100644
--- a/driver/charger/rt946x.c
+++ b/driver/charger/rt946x.c
@@ -7,17 +7,17 @@
#include "battery.h"
#include "battery_smart.h"
-#include "charger.h"
#include "charge_manager.h"
+#include "charger.h"
#include "common.h"
#include "compile_time_macros.h"
#include "config.h"
#include "console.h"
+#include "driver/wpc/p9221.h"
#include "extpower.h"
#include "hooks.h"
#include "i2c.h"
#include "printf.h"
-#include "driver/wpc/p9221.h"
#include "rt946x.h"
#include "task.h"
#include "tcpm/tcpm.h"
diff --git a/driver/charger/rt9490.c b/driver/charger/rt9490.c
index 8bf418a065..016ef12d44 100644
--- a/driver/charger/rt9490.c
+++ b/driver/charger/rt9490.c
@@ -9,8 +9,8 @@
#include "battery_smart.h"
#include "builtin/assert.h"
#include "builtin/endian.h"
-#include "charger.h"
#include "charge_manager.h"
+#include "charger.h"
#include "common.h"
#include "config.h"
#include "console.h"
@@ -18,11 +18,11 @@
#include "i2c.h"
#include "rt9490.h"
#include "task.h"
+#include "temp_sensor/temp_sensor.h"
+#include "temp_sensor/thermistor.h"
#include "usb_charge.h"
#include "usb_pd.h"
#include "util.h"
-#include "temp_sensor/temp_sensor.h"
-#include "temp_sensor/thermistor.h"
/* Console output macros */
#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args)
@@ -359,6 +359,10 @@ static int rt9490_init_setting(int chgnum)
RT9490_EN_FON_PP_BAT_TRACK);
RETURN_ERROR(rt9490_enable_hidden_mode(chgnum, false));
+ /* Disable non-standard TA detection */
+ RETURN_ERROR(rt9490_clr_bit(chgnum, RT9490_REG_ADD_CTRL2,
+ RT9490_SPEC_TA_EN));
+
return EC_SUCCESS;
}
diff --git a/driver/charger/rt9490.h b/driver/charger/rt9490.h
index ea1d6cfcfb..88f979ae5e 100644
--- a/driver/charger/rt9490.h
+++ b/driver/charger/rt9490.h
@@ -4,10 +4,10 @@
*
* Richtek 5A 1-4 cell buck-boost switching battery charger driver.
*/
-#include <stdbool.h>
-
#include "temp_sensor.h"
+#include <stdbool.h>
+
#ifndef __CROS_EC_RT9490_H
#define __CROS_EC_RT9490_H
@@ -248,6 +248,9 @@ struct rt9490_init_setting {
/* ADD CTRL1 */
#define RT9490_PWM_1MHZ_EN BIT(4)
+/* ADD CTRL2 */
+#define RT9490_SPEC_TA_EN BIT(2)
+
/* HD_ADD_CTRL 2 */
#define RT9490_EN_FON_PP_BAT_TRACK BIT(5)
diff --git a/driver/charger/sm5803.c b/driver/charger/sm5803.c
index f6d4e60eec..57b1a0330f 100644
--- a/driver/charger/sm5803.c
+++ b/driver/charger/sm5803.c
@@ -14,8 +14,8 @@
#include "hooks.h"
#include "i2c.h"
#include "sm5803.h"
-#include "system.h"
#include "stdbool.h"
+#include "system.h"
#include "throttle_ap.h"
#include "timer.h"
#include "usb_charge.h"
@@ -712,7 +712,7 @@ static void sm5803_init(int chgnum)
rv |= chg_write8(chgnum, SM5803_REG_DPM_VL_SET_LSB, (reg & 0x7));
/* Set default input current */
- reg = SM5803_CURRENT_TO_REG(CONFIG_CHARGER_INPUT_CURRENT) &
+ reg = SM5803_CURRENT_TO_REG(CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT) &
SM5803_CHG_ILIM_RAW;
rv |= chg_write8(chgnum, SM5803_REG_CHG_ILIM, reg);
diff --git a/driver/fingerprint/elan/elan_private.c b/driver/fingerprint/elan/elan_private.c
index fc95ceb685..a176f29f0d 100644
--- a/driver/fingerprint/elan/elan_private.c
+++ b/driver/fingerprint/elan/elan_private.c
@@ -3,24 +3,24 @@
* found in the LICENSE file.
*/
-#include <stddef.h>
#include "common.h"
#include "console.h"
+#include "cryptoc/util.h"
+#include "elan_sensor.h"
+#include "elan_sensor_pal.h"
+#include "elan_setting.h"
#include "endian.h"
+#include "fpsensor.h"
#include "gpio.h"
#include "link_defs.h"
+#include "math_util.h"
+#include "shared_mem.h"
#include "spi.h"
#include "system.h"
#include "timer.h"
#include "util.h"
-#include "shared_mem.h"
-#include "math_util.h"
-#include "fpsensor.h"
-#include "cryptoc/util.h"
-#include "elan_sensor.h"
-#include "elan_setting.h"
-#include "elan_sensor_pal.h"
+#include <stddef.h>
static uint16_t errors;
diff --git a/driver/fingerprint/elan/elan_sensor_pal.c b/driver/fingerprint/elan/elan_sensor_pal.c
index 4056c52f38..2a91fe176e 100644
--- a/driver/fingerprint/elan/elan_sensor_pal.c
+++ b/driver/fingerprint/elan/elan_sensor_pal.c
@@ -4,24 +4,24 @@
*/
/* ELAN Platform Abstraction Layer callbacks */
-#include <stddef.h>
#include "common.h"
#include "console.h"
+#include "cryptoc/util.h"
+#include "elan_sensor.h"
+#include "elan_sensor_pal.h"
+#include "elan_setting.h"
#include "endian.h"
#include "fpsensor.h"
#include "gpio.h"
#include "link_defs.h"
+#include "math_util.h"
+#include "shared_mem.h"
#include "spi.h"
#include "system.h"
#include "timer.h"
#include "util.h"
-#include "shared_mem.h"
-#include "math_util.h"
-#include "cryptoc/util.h"
-#include "elan_setting.h"
-#include "elan_sensor.h"
-#include "elan_sensor_pal.h"
+#include <stddef.h>
static uint8_t tx_buf[CONFIG_SPI_TX_BUF_SIZE] __uncached;
static uint8_t rx_buf[CONFIG_SPI_RX_BUF_SIZE] __uncached;
diff --git a/driver/fingerprint/fpc/bep/fpc_misc.c b/driver/fingerprint/fpc/bep/fpc_misc.c
index f78a429233..6b716e0524 100644
--- a/driver/fingerprint/fpc/bep/fpc_misc.c
+++ b/driver/fingerprint/fpc/bep/fpc_misc.c
@@ -5,12 +5,12 @@
/* FPC Platform Abstraction Layer */
-#include <stdint.h>
-#include <stddef.h>
-
#include "shared_mem.h"
#include "uart.h"
+#include <stddef.h>
+#include <stdint.h>
+
void __unused *fpc_malloc(uint32_t size)
{
char *data;
diff --git a/driver/fingerprint/fpc/bep/fpc_private.c b/driver/fingerprint/fpc/bep/fpc_private.c
index ac20e10758..70aa8fe8c5 100644
--- a/driver/fingerprint/fpc/bep/fpc_private.c
+++ b/driver/fingerprint/fpc/bep/fpc_private.c
@@ -3,9 +3,7 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-#include <stddef.h>
-
+#include "driver/fingerprint/fpc/fpc_sensor.h"
#include "fpc_bio_algorithm.h"
#include "fpsensor.h"
#include "gpio.h"
@@ -13,7 +11,8 @@
#include "system.h"
#include "util.h"
-#include "driver/fingerprint/fpc/fpc_sensor.h"
+#include <stddef.h>
+#include <stdint.h>
/* Console output macros */
#define CPRINTF(format, args...) cprintf(CC_FP, format, ##args)
diff --git a/driver/fingerprint/fpc/bep/fpc_private.h b/driver/fingerprint/fpc/bep/fpc_private.h
index ca5b98fa8e..df8b8eeea6 100644
--- a/driver/fingerprint/fpc/bep/fpc_private.h
+++ b/driver/fingerprint/fpc/bep/fpc_private.h
@@ -8,6 +8,10 @@
#ifndef __CROS_EC_FPC_PRIVATE_H
#define __CROS_EC_FPC_PRIVATE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <stdint.h>
typedef struct {
@@ -46,4 +50,8 @@ int fp_sensor_maintenance(uint8_t *image_data,
*/
int fpc_get_hwid(uint16_t *id);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __CROS_EC_FPC_PRIVATE_H */
diff --git a/driver/fingerprint/fpc/bep/fpc_sensor_spi.c b/driver/fingerprint/fpc/bep/fpc_sensor_spi.c
index 752b9909bc..565b29c69d 100644
--- a/driver/fingerprint/fpc/bep/fpc_sensor_spi.c
+++ b/driver/fingerprint/fpc/bep/fpc_sensor_spi.c
@@ -5,18 +5,17 @@
/* FPC Platform Abstraction Layer */
-#include <stdint.h>
-#include <stdbool.h>
-#include <stddef.h>
-
#include "console.h"
-#include "fpsensor.h"
+#include "driver/fingerprint/fpc/fpc_sensor.h"
#include "fpc_sensor_spi.h"
+#include "fpsensor.h"
#include "gpio.h"
#include "spi.h"
#include "util.h"
-#include "driver/fingerprint/fpc/fpc_sensor.h"
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
/* Console output macros */
#define CPRINTF(format, args...) cprintf(CC_FP, format, ##args)
diff --git a/driver/fingerprint/fpc/bep/fpc_sensor_spi.h b/driver/fingerprint/fpc/bep/fpc_sensor_spi.h
index ad7e5411d8..015bc03dae 100644
--- a/driver/fingerprint/fpc/bep/fpc_sensor_spi.h
+++ b/driver/fingerprint/fpc/bep/fpc_sensor_spi.h
@@ -14,8 +14,9 @@
* fingerprint sensor.
*/
-#include <stdint.h>
#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
typedef bool (*fpc_wfi_check_t)(void);
diff --git a/driver/fingerprint/fpc/bep/fpc_timebase.c b/driver/fingerprint/fpc/bep/fpc_timebase.c
index a63a4c3d6d..c34b9e27db 100644
--- a/driver/fingerprint/fpc/bep/fpc_timebase.c
+++ b/driver/fingerprint/fpc/bep/fpc_timebase.c
@@ -5,11 +5,11 @@
/* FPC Platform Abstraction Layer */
-#include <stdint.h>
-
#include "fpc_timebase.h"
#include "timer.h"
+#include <stdint.h>
+
uint32_t __unused fpc_timebase_get_tick(void)
{
clock_t time;
diff --git a/driver/fingerprint/fpc/bep/fpc_timebase.h b/driver/fingerprint/fpc/bep/fpc_timebase.h
index ce9018461b..35cf67fed2 100644
--- a/driver/fingerprint/fpc/bep/fpc_timebase.h
+++ b/driver/fingerprint/fpc/bep/fpc_timebase.h
@@ -13,10 +13,10 @@
* Supplies tick counter and wait operation(s).
*/
-#include <stdint.h>
-
#include "common.h"
+#include <stdint.h>
+
/**
* @brief Reads the system tick counter.
*
diff --git a/driver/fingerprint/fpc/fpc_sensor.c b/driver/fingerprint/fpc/fpc_sensor.c
index bbab729b12..9cb97a9125 100644
--- a/driver/fingerprint/fpc/fpc_sensor.c
+++ b/driver/fingerprint/fpc/fpc_sensor.c
@@ -4,9 +4,10 @@
*/
#include <stddef.h>
+
+#include <common/fpsensor/fpsensor_private.h>
#include <include/fpsensor.h>
#include <include/fpsensor_state.h>
-#include <common/fpsensor/fpsensor_private.h>
#if defined(CONFIG_FP_SENSOR_FPC1025) || defined(CONFIG_FP_SENSOR_FPC1035)
#include "bep/fpc_private.h"
#elif defined(CONFIG_FP_SENSOR_FPC1145)
diff --git a/driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h b/driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h
index 7dda6d46de..834f7394e4 100644
--- a/driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h
+++ b/driver/fingerprint/fpc/libfp/fpc_bio_algorithm.h
@@ -5,8 +5,11 @@
#ifndef BIOD_BIO_ALGORITHM_H_
#define BIOD_BIO_ALGORITHM_H_
+#include <stddef.h>
#include <stdint.h>
+#include <sys/types.h>
+
enum bio_algorithm_type {
BIO_ALGORITHM_FINGERPRINT,
BIO_ALGORITHM_IRIS,
diff --git a/driver/fingerprint/fpc/libfp/fpc_private.c b/driver/fingerprint/fpc/libfp/fpc_private.c
index fcc0180784..8b1ceff405 100644
--- a/driver/fingerprint/fpc/libfp/fpc_private.c
+++ b/driver/fingerprint/fpc/libfp/fpc_private.c
@@ -3,10 +3,9 @@
* found in the LICENSE file.
*/
-#include <stddef.h>
-#include <sys/types.h>
#include "common.h"
#include "console.h"
+#include "driver/fingerprint/fpc/fpc_sensor.h"
#include "fpc_bio_algorithm.h"
#include "fpc_private.h"
#include "fpsensor.h"
@@ -17,7 +16,9 @@
#include "timer.h"
#include "util.h"
-#include "driver/fingerprint/fpc/fpc_sensor.h"
+#include <stddef.h>
+
+#include <sys/types.h>
#define CPRINTF(format, args...) cprintf(CC_FP, format, ##args)
#define CPRINTS(format, args...) cprints(CC_FP, format, ##args)
diff --git a/driver/fingerprint/fpc/libfp/fpc_private.h b/driver/fingerprint/fpc/libfp/fpc_private.h
index 19ac3b7a13..a1fe0e47a2 100644
--- a/driver/fingerprint/fpc/libfp/fpc_private.h
+++ b/driver/fingerprint/fpc/libfp/fpc_private.h
@@ -8,6 +8,10 @@
#ifndef __CROS_EC_FPC_PRIVATE_H
#define __CROS_EC_FPC_PRIVATE_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* External error codes from FPC's sensor library */
enum fpc_error_code_external {
FPC_ERROR_NONE = 0,
@@ -157,4 +161,8 @@ int fp_sensor_maintenance(uint8_t *image_data,
*/
int fpc_get_hwid(uint16_t *id);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* __CROS_EC_FPC_PRIVATE_H */
diff --git a/driver/fingerprint/fpc/libfp/fpc_sensor_pal.c b/driver/fingerprint/fpc/libfp/fpc_sensor_pal.c
index c0578bc09b..a856e0afaf 100644
--- a/driver/fingerprint/fpc/libfp/fpc_sensor_pal.c
+++ b/driver/fingerprint/fpc/libfp/fpc_sensor_pal.c
@@ -6,8 +6,8 @@
#include "common.h"
#include "console.h"
-#include "fpsensor.h"
#include "fpc_sensor_pal.h"
+#include "fpsensor.h"
#include "shared_mem.h"
#include "spi.h"
#include "timer.h"
diff --git a/driver/gl3590.c b/driver/gl3590.c
index da374fbc88..03af496293 100644
--- a/driver/gl3590.c
+++ b/driver/gl3590.c
@@ -4,13 +4,12 @@
*/
#include "console.h"
+#include "gl3590.h"
#include "hooks.h"
#include "i2c.h"
+#include "pwr_defs.h"
#include "system.h"
#include "util.h"
-#include "pwr_defs.h"
-
-#include "gl3590.h"
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
#define CPRINTF(format, args...) cprintf(CC_I2C, format, ##args)
diff --git a/driver/ina2xx.c b/driver/ina2xx.c
index e09c141f50..64a2dadeed 100644
--- a/driver/ina2xx.c
+++ b/driver/ina2xx.c
@@ -8,9 +8,9 @@
#include "console.h"
#include "hooks.h"
#include "i2c.h"
+#include "ina2xx.h"
#include "system.h"
#include "timer.h"
-#include "ina2xx.h"
#include "util.h"
/* Console output macros */
diff --git a/driver/ina3221.c b/driver/ina3221.c
index 4659552497..ec28ec3f26 100644
--- a/driver/ina3221.c
+++ b/driver/ina3221.c
@@ -8,9 +8,9 @@
#include "console.h"
#include "hooks.h"
#include "i2c.h"
+#include "ina3221.h"
#include "system.h"
#include "timer.h"
-#include "ina3221.h"
#include "util.h"
/* Console output macros */
diff --git a/driver/ioexpander/it8801.c b/driver/ioexpander/it8801.c
index 256b4c9654..932cbb2648 100644
--- a/driver/ioexpander/it8801.c
+++ b/driver/ioexpander/it8801.c
@@ -10,12 +10,12 @@
#include "i2c.h"
#include "ioexpander.h"
#include "it8801.h"
+#include "keyboard_backlight.h"
#include "keyboard_raw.h"
#include "keyboard_scan.h"
#include "registers.h"
#include "task.h"
#include "util.h"
-#include "keyboard_backlight.h"
#define CPRINTS(format, args...) cprints(CC_KEYSCAN, format, ##args)
@@ -685,11 +685,6 @@ static int it8801_kblight_set_brightness(int percent)
return EC_SUCCESS;
}
-static int it8801_kblight_get_brightness(void)
-{
- return it8801_pwm_get_duty(it8801_kblight_pwm_ch);
-}
-
static int it8801_kblight_init(void)
{
it8801_pwm_set_duty(it8801_kblight_pwm_ch, 0);
@@ -700,7 +695,6 @@ static int it8801_kblight_init(void)
const struct kblight_drv kblight_it8801 = {
.init = it8801_kblight_init,
.set = it8801_kblight_set_brightness,
- .get = it8801_kblight_get_brightness,
.enable = it8801_kblight_enable,
.get_enabled = it8801_kblight_get_enabled,
};
diff --git a/driver/ioexpander/pcal6408.c b/driver/ioexpander/pcal6408.c
index 1b746bffc3..cec5e5902e 100644
--- a/driver/ioexpander/pcal6408.c
+++ b/driver/ioexpander/pcal6408.c
@@ -6,10 +6,10 @@
*/
#include "common.h"
#include "console.h"
-#include "math_util.h"
#include "gpio.h"
#include "i2c.h"
#include "ioexpander.h"
+#include "math_util.h"
#include "pcal6408.h"
#define CPRINTF(format, args...) cprintf(CC_GPIO, format, ##args)
diff --git a/driver/led/aw20198.c b/driver/led/aw20198.c
index e2eea69481..eca596d62e 100644
--- a/driver/led/aw20198.c
+++ b/driver/led/aw20198.c
@@ -2,8 +2,6 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <string.h>
-
#include "aw20198.h"
#include "common.h"
#include "console.h"
@@ -13,6 +11,8 @@
#include "stddef.h"
#include "timer.h"
+#include <string.h>
+
#define CPRINTF(fmt, args...) cprintf(CC_RGBKBD, "AW20198: " fmt, ##args)
#define CPRINTS(fmt, args...) cprints(CC_RGBKBD, "AW20198: " fmt, ##args)
diff --git a/driver/led/is31fl3733b.c b/driver/led/is31fl3733b.c
index 33004d1cec..3ff0c19655 100644
--- a/driver/led/is31fl3733b.c
+++ b/driver/led/is31fl3733b.c
@@ -2,7 +2,6 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <string.h>
#include "common.h"
#include "console.h"
#include "gpio.h"
@@ -11,6 +10,8 @@
#include "stddef.h"
#include "timer.h"
+#include <string.h>
+
#define CPRINTF(fmt, args...) cprintf(CC_RGBKBD, "RGBKBD: " fmt, ##args)
#define CPRINTS(fmt, args...) cprints(CC_RGBKBD, "RGBKBD: " fmt, ##args)
diff --git a/driver/led/is31fl3743b.c b/driver/led/is31fl3743b.c
index 5eef21c388..6725c1d406 100644
--- a/driver/led/is31fl3743b.c
+++ b/driver/led/is31fl3743b.c
@@ -2,8 +2,6 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <string.h>
-
#include "common.h"
#include "console.h"
#include "gpio.h"
@@ -12,6 +10,8 @@
#include "stddef.h"
#include "timer.h"
+#include <string.h>
+
#define CPRINTF(fmt, args...) cprintf(CC_RGBKBD, "RGBKBD: " fmt, ##args)
#define CPRINTS(fmt, args...) cprints(CC_RGBKBD, "RGBKBD: " fmt, ##args)
diff --git a/driver/led/lm3509.c b/driver/led/lm3509.c
index 5df604bac6..81dd940c4f 100644
--- a/driver/led/lm3509.c
+++ b/driver/led/lm3509.c
@@ -70,16 +70,6 @@ static int lm3509_set_brightness(int percent)
return lm3509_write(LM3509_REG_BMAIN, brightness_to_bmain(percent));
}
-static int lm3509_get_brightness(void)
-{
- int rv, val;
- rv = lm3509_read(LM3509_REG_BMAIN, &val);
- if (rv)
- return -1;
- val &= LM3509_BMAIN_MASK;
- return lm3509_brightness[val] / 10;
-}
-
static int lm3509_init(void)
{
return EC_SUCCESS;
@@ -88,7 +78,6 @@ static int lm3509_init(void)
const struct kblight_drv kblight_lm3509 = {
.init = lm3509_init,
.set = lm3509_set_brightness,
- .get = lm3509_get_brightness,
.enable = lm3509_power,
.get_enabled = lm3509_get_power,
};
diff --git a/driver/led/mp3385.h b/driver/led/mp3385.h
index 733a8f76cd..2f179666d8 100644
--- a/driver/led/mp3385.h
+++ b/driver/led/mp3385.h
@@ -8,8 +8,8 @@
#ifndef __CROS_EC_MP3385_H
#define __CROS_EC_MP3385_H
-#include "gpio.h"
#include "common.h"
+#include "gpio.h"
/*
* Overridable board initialization. Should be overridden by a board
diff --git a/driver/led/oz554.h b/driver/led/oz554.h
index c735f9f3b9..27b43a1300 100644
--- a/driver/led/oz554.h
+++ b/driver/led/oz554.h
@@ -8,8 +8,8 @@
#ifndef __CROS_EC_OZ554_H
#define __CROS_EC_OZ554_H
-#include "gpio.h"
#include "common.h"
+#include "gpio.h"
/*
* Overridable board initialization. Should be overridden by a board
diff --git a/driver/led/tlc59116f.c b/driver/led/tlc59116f.c
index 1350602f6f..72e51e3fb8 100644
--- a/driver/led/tlc59116f.c
+++ b/driver/led/tlc59116f.c
@@ -2,8 +2,6 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <string.h>
-
#include "common.h"
#include "console.h"
#include "i2c.h"
@@ -11,6 +9,8 @@
#include "stddef.h"
#include "tlc59116f.h"
+#include <string.h>
+
#define CPRINTF(fmt, args...) cprintf(CC_RGBKBD, "TLC59116F: " fmt, ##args)
#define CPRINTS(fmt, args...) cprints(CC_RGBKBD, "TLC59116F: " fmt, ##args)
diff --git a/driver/ln9310.c b/driver/ln9310.c
index 4a56568eb9..f9dfedfc54 100644
--- a/driver/ln9310.c
+++ b/driver/ln9310.c
@@ -10,8 +10,8 @@
#include "driver/ln9310.h"
#include "hooks.h"
#include "i2c.h"
-#include "util.h"
#include "timer.h"
+#include "util.h"
#define CPUTS(outstr) cputs(CC_I2C, outstr)
#define CPRINTF(format, args...) cprintf(CC_I2C, format, ##args)
diff --git a/driver/mag_lis2mdl.c b/driver/mag_lis2mdl.c
index e8a8cb82ca..a871f9e310 100644
--- a/driver/mag_lis2mdl.c
+++ b/driver/mag_lis2mdl.c
@@ -10,9 +10,9 @@
*/
#include "common.h"
+#include "driver/accelgyro_lsm6dsm.h"
#include "driver/mag_lis2mdl.h"
#include "driver/sensorhub_lsm6dsm.h"
-#include "driver/accelgyro_lsm6dsm.h"
#include "driver/stm_mems_common.h"
#include "hwtimer.h"
#include "mag_cal.h"
diff --git a/driver/mcdp28x0.c b/driver/mcdp28x0.c
index 1b56e6d53f..791c3c519f 100644
--- a/driver/mcdp28x0.c
+++ b/driver/mcdp28x0.c
@@ -5,9 +5,9 @@
* Megachips DisplayPort to HDMI protocol converter / level shifter driver.
*/
+#include "common.h"
#include "config.h"
#include "console.h"
-#include "common.h"
#include "ec_commands.h"
#include "mcdp28x0.h"
#include "queue.h"
diff --git a/driver/nfc/ctn730.c b/driver/nfc/ctn730.c
index e72f4459ad..c19b440824 100644
--- a/driver/nfc/ctn730.c
+++ b/driver/nfc/ctn730.c
@@ -4,9 +4,9 @@
*/
#include "chipset.h"
-#include "ctn730.h"
#include "common.h"
#include "console.h"
+#include "ctn730.h"
#include "gpio.h"
#include "i2c.h"
#include "peripheral_charger.h"
@@ -66,6 +66,8 @@ static const char *_text_instruction(uint8_t instruction)
return "CHARGING_STATE";
case WLC_CHG_CTRL_CHARGING_INFO:
return "CHARGING_INFO";
+ case WLC_CHG_CTRL_OPTIONAL_NDEF:
+ return "OPTIONAL_NDEF";
default:
return "UNDEF";
}
@@ -484,6 +486,10 @@ static int _process_payload_event(struct pchg *ctx, struct ctn730_msg *res)
ctx->event = PCHG_EVENT_CHARGE_UPDATE;
ctx->battery_percent = buf[0];
break;
+ case WLC_CHG_CTRL_OPTIONAL_NDEF:
+ if (len == 0)
+ return EC_ERROR_INVAL;
+ break;
default:
CPRINTS("Received unknown event (%d)", res->instruction);
break;
diff --git a/driver/nfc/ctn730.h b/driver/nfc/ctn730.h
index 45314428a9..e1ae7ab754 100644
--- a/driver/nfc/ctn730.h
+++ b/driver/nfc/ctn730.h
@@ -32,6 +32,7 @@
#define WLC_CHG_CTRL_DEVICE_STATE 0b010010
#define WLC_CHG_CTRL_CHARGING_STATE 0b010100
#define WLC_CHG_CTRL_CHARGING_INFO 0b010101
+#define WLC_CHG_CTRL_OPTIONAL_NDEF 0b011111
/* WLC_HOST_CTRL_RESET constants */
#define WLC_HOST_CTRL_RESET_CMD_SIZE 1
diff --git a/driver/nvidia_gpu.c b/driver/nvidia_gpu.c
index e9fbd156ac..b8a2195470 100644
--- a/driver/nvidia_gpu.c
+++ b/driver/nvidia_gpu.c
@@ -5,8 +5,6 @@
* Nvidia GPU D-Notify driver
*/
-#include <stddef.h>
-
#include "charge_manager.h"
#include "charge_state.h"
#include "compile_time_macros.h"
@@ -19,6 +17,8 @@
#include "throttle_ap.h"
#include "timer.h"
+#include <stddef.h>
+
#define CPRINTS(fmt, args...) cprints(CC_GPU, "GPU: " fmt, ##args)
#define CPRINTF(fmt, args...) cprintf(CC_GPU, "GPU: " fmt, ##args)
diff --git a/driver/ppc/ktu1125.c b/driver/ppc/ktu1125.c
index 047d011aac..f90168adef 100644
--- a/driver/ppc/ktu1125.c
+++ b/driver/ppc/ktu1125.c
@@ -7,14 +7,14 @@
#include "common.h"
#include "console.h"
-#include "ktu1125.h"
#include "hooks.h"
#include "i2c.h"
+#include "ktu1125.h"
#include "system.h"
#include "timer.h"
#include "usb_charge.h"
-#include "usb_pd_tcpm.h"
#include "usb_pd.h"
+#include "usb_pd_tcpm.h"
#include "usbc_ppc.h"
#include "util.h"
diff --git a/driver/ppc/ktu1125.h b/driver/ppc/ktu1125.h
index 229c894b8c..9957ed80ec 100644
--- a/driver/ppc/ktu1125.h
+++ b/driver/ppc/ktu1125.h
@@ -9,7 +9,6 @@
#define __CROS_EC_KTU1125_H
#include "common.h"
-
#include "driver/ppc/ktu1125_public.h"
#define KTU1125_ID 0x0
diff --git a/driver/ppc/nx20p348x.c b/driver/ppc/nx20p348x.c
index d202898a85..14dfb88e02 100644
--- a/driver/ppc/nx20p348x.c
+++ b/driver/ppc/nx20p348x.c
@@ -7,15 +7,15 @@
#include "common.h"
#include "console.h"
-#include "nx20p348x.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
+#include "nx20p348x.h"
#include "system.h"
#include "tcpm/tcpm.h"
#include "usb_charge.h"
-#include "usb_pd_tcpm.h"
#include "usb_pd.h"
+#include "usb_pd_tcpm.h"
#include "usbc_ppc.h"
#include "util.h"
diff --git a/driver/ppc/sn5s330.c b/driver/ppc/sn5s330.c
index 385f27fe52..9404c8df76 100644
--- a/driver/ppc/sn5s330.c
+++ b/driver/ppc/sn5s330.c
@@ -12,14 +12,14 @@
#include "common.h"
#include "console.h"
-#include "sn5s330.h"
#include "hooks.h"
#include "i2c.h"
+#include "sn5s330.h"
#include "system.h"
#include "timer.h"
#include "usb_charge.h"
-#include "usb_pd_tcpm.h"
#include "usb_pd.h"
+#include "usb_pd_tcpm.h"
#include "usbc_ppc.h"
#include "util.h"
diff --git a/driver/ppc/sn5s330.h b/driver/ppc/sn5s330.h
index 70a46920ee..3748370007 100644
--- a/driver/ppc/sn5s330.h
+++ b/driver/ppc/sn5s330.h
@@ -9,7 +9,6 @@
#define __CROS_EC_SN5S330_H
#include "common.h"
-
#include "driver/ppc/sn5s330_public.h"
struct sn5s330_config {
diff --git a/driver/ppc/syv682x.c b/driver/ppc/syv682x.c
index 88c6443ad0..42488a4a26 100644
--- a/driver/ppc/syv682x.c
+++ b/driver/ppc/syv682x.c
@@ -8,17 +8,17 @@
#include "common.h"
#include "config.h"
#include "console.h"
-#include "syv682x.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
#include "system.h"
+#include "syv682x.h"
#include "tcpm/tcpm.h"
#include "timer.h"
#include "usb_charge.h"
+#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#include "usbc_ppc.h"
-#include "usb_pd.h"
#include "util.h"
#define SYV682X_FLAGS_SOURCE_ENABLED BIT(0)
diff --git a/driver/retimer/anx7483.c b/driver/retimer/anx7483.c
index 3f4713fc85..f8b11f0e85 100644
--- a/driver/retimer/anx7483.c
+++ b/driver/retimer/anx7483.c
@@ -6,11 +6,11 @@
*/
#include "anx7483.h"
-#include "retimer/anx7483_public.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
#include "i2c.h"
+#include "retimer/anx7483_public.h"
#include "timer.h"
#include "usb_mux.h"
#include "util.h"
@@ -346,6 +346,34 @@ enum ec_error_list anx7483_set_eq(const struct usb_mux *me,
return anx7483_write(me, reg, value);
}
+enum ec_error_list anx7483_set_fg(const struct usb_mux *me,
+ enum anx7483_tune_pin pin,
+ enum anx7483_fg_setting fg)
+{
+ int reg, value;
+
+ if (pin == ANX7483_PIN_UTX1)
+ reg = ANX7483_UTX1_PORT_CFG2_REG;
+ else if (pin == ANX7483_PIN_UTX2)
+ reg = ANX7483_UTX2_PORT_CFG2_REG;
+ else if (pin == ANX7483_PIN_URX1)
+ reg = ANX7483_URX1_PORT_CFG2_REG;
+ else if (pin == ANX7483_PIN_URX2)
+ reg = ANX7483_URX2_PORT_CFG2_REG;
+ else if (pin == ANX7483_PIN_DRX1)
+ reg = ANX7483_DRX1_PORT_CFG2_REG;
+ else if (pin == ANX7483_PIN_DRX2)
+ reg = ANX7483_DRX2_PORT_CFG2_REG;
+ else
+ return EC_ERROR_INVAL;
+
+ RETURN_ERROR(anx7483_read(me, reg, &value));
+ value &= ~ANX7483_CFG2_FG_MASK;
+ value |= fg << ANX7483_CFG2_FG_SHIFT;
+
+ return anx7483_write(me, reg, value);
+}
+
const struct usb_mux_driver anx7483_usb_retimer_driver = {
.init = anx7483_init,
.set = anx7483_set,
diff --git a/driver/retimer/anx7483.h b/driver/retimer/anx7483.h
index d489b3d8e6..c438a278b9 100644
--- a/driver/retimer/anx7483.h
+++ b/driver/retimer/anx7483.h
@@ -72,6 +72,9 @@
#define ANX7483_DRX1_PORT_CFG2_REG 0x5E
#define ANX7483_DRX2_PORT_CFG2_REG 0x22
+#define ANX7483_CFG2_FG_SHIFT 4
+#define ANX7483_CFG2_FG_MASK GENMASK(5, 4)
+
/*
* Default CFG2 value to apply: 0.3 dB with optimized fine tuning
*/
diff --git a/driver/retimer/bb_retimer.c b/driver/retimer/bb_retimer.c
index f7a4ce6164..3bee94bb56 100644
--- a/driver/retimer/bb_retimer.c
+++ b/driver/retimer/bb_retimer.c
@@ -5,10 +5,10 @@
* Driver for Intel Burnside Bridge - Thunderbolt/USB/DisplayPort Retimer
*/
-#include "driver/retimer/bb_retimer.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
+#include "driver/retimer/bb_retimer.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
@@ -428,7 +428,14 @@ static int retimer_set_state(const struct usb_mux *me, mux_state_t mux_state,
set_retimer_con |= BB_RETIMER_USB_3_SPEED;
}
+ /*
+ * Bit 8: DP_CONNECTION
+ * 0 – No DP connection
+ * 1 – DP connected
+ */
if (mux_state & USB_PD_MUX_DP_ENABLED) {
+ set_retimer_con |= BB_RETIMER_DP_CONNECTION;
+
/*
* Bit 11-10: DP_PIN_ASSIGNMENT (ignored if BIT8 = 0)
* 00 – Pin assignments E/E’
@@ -545,26 +552,15 @@ void bb_retimer_hpd_update(const struct usb_mux *me, mux_state_t hpd_state,
retimer_con_reg &= ~BB_RETIMER_IRQ_HPD;
/*
- * Bit 8: DP_CONNECTION
- * 0 - No DP connection
- * 1 - DP connected
- *
* Bit 15: HPD_LVL (ignored if BIT8 = 0)
* 0 - HPD_State Low
* 1 - HPD_State High
- *
- * HDMI card connect to chromebook the DP_CONNECTION bit
- * would be enable.
- * It will increase BBR power consumption, so enable the DP bit
- * only when the HPD bit is set so that the retimer stays in
- * low power mode until the external monitor is connected.
*/
+
if (hpd_state & USB_PD_MUX_HPD_LVL)
- retimer_con_reg |=
- (BB_RETIMER_HPD_LVL | BB_RETIMER_DP_CONNECTION);
+ retimer_con_reg |= BB_RETIMER_HPD_LVL;
else
- retimer_con_reg &=
- ~(BB_RETIMER_HPD_LVL | BB_RETIMER_DP_CONNECTION);
+ retimer_con_reg &= ~BB_RETIMER_HPD_LVL;
/* Writing the register4 */
bb_retimer_write(me, BB_RETIMER_REG_CONNECTION_STATE, retimer_con_reg);
diff --git a/driver/retimer/nb7v904m.c b/driver/retimer/nb7v904m.c
index 58c57e5c95..2990a906b5 100644
--- a/driver/retimer/nb7v904m.c
+++ b/driver/retimer/nb7v904m.c
@@ -4,7 +4,6 @@
*
* ON Semiconductor NB7V904M USB Type-C DisplayPort Alt Mode Redriver
*/
-#include <stdbool.h>
#include "common.h"
#include "console.h"
#include "ec_commands.h"
@@ -12,6 +11,8 @@
#include "nb7v904m.h"
#include "usb_mux.h"
+#include <stdbool.h>
+
#define CPRINTS(format, args...) cprints(CC_USB, format, ##args)
#define CPRINTF(format, args...) cprintf(CC_USB, format, ##args)
diff --git a/driver/retimer/pi3dpx1207.c b/driver/retimer/pi3dpx1207.c
index 27ea474832..e40f269e3b 100644
--- a/driver/retimer/pi3dpx1207.c
+++ b/driver/retimer/pi3dpx1207.c
@@ -5,12 +5,12 @@
* PI3DPX1207 retimer.
*/
-#include "pi3dpx1207.h"
#include "common.h"
#include "console.h"
#include "gpio.h"
#include "i2c.h"
#include "ioexpander.h"
+#include "pi3dpx1207.h"
#include "usb_mux.h"
#define I2C_MAX_RETRIES 2
diff --git a/driver/sb_rmi.c b/driver/sb_rmi.c
index 420ef672ad..62c105f6ff 100644
--- a/driver/sb_rmi.c
+++ b/driver/sb_rmi.c
@@ -5,8 +5,8 @@
/* AMD SB-RMI (Side-band Remote Management Interface) Driver */
-#include "common.h"
#include "chipset.h"
+#include "common.h"
#include "console.h"
#include "i2c.h"
#include "sb_rmi.h"
diff --git a/driver/stm_mems_common.h b/driver/stm_mems_common.h
index 370ce10d9c..58e039bdd2 100644
--- a/driver/stm_mems_common.h
+++ b/driver/stm_mems_common.h
@@ -8,11 +8,11 @@
#ifndef __CROS_EC_ST_COMMONS_H
#define __CROS_EC_ST_COMMONS_H
-#include "common.h"
-#include "util.h"
#include "accelgyro.h"
+#include "common.h"
#include "console.h"
#include "i2c.h"
+#include "util.h"
/* X, Y, Z axis data len */
#define OUT_XYZ_SIZE 6
diff --git a/driver/tcpm/anx7447.c b/driver/tcpm/anx7447.c
index 8c21f77536..4b8d82c034 100644
--- a/driver/tcpm/anx7447.c
+++ b/driver/tcpm/anx7447.c
@@ -5,9 +5,9 @@
/* ANX7447 port manager */
+#include "anx7447.h"
#include "builtin/assert.h"
#include "common.h"
-#include "anx7447.h"
#include "console.h"
#include "hooks.h"
#include "tcpm/tcpci.h"
diff --git a/driver/tcpm/anx7447.h b/driver/tcpm/anx7447.h
index 42de7502f1..56d810574d 100644
--- a/driver/tcpm/anx7447.h
+++ b/driver/tcpm/anx7447.h
@@ -3,8 +3,8 @@
* found in the LICENSE file.
*/
-#include "usb_mux.h"
#include "driver/tcpm/anx7447_public.h"
+#include "usb_mux.h"
/* USB Power delivery port management */
diff --git a/driver/tcpm/anx74xx.c b/driver/tcpm/anx74xx.c
index 64a9271f1c..e6ad23c25a 100644
--- a/driver/tcpm/anx74xx.c
+++ b/driver/tcpm/anx74xx.c
@@ -7,8 +7,8 @@
/* Type-C port manager for Analogix's anx74xx chips */
-#include "console.h"
#include "anx74xx.h"
+#include "console.h"
#include "task.h"
#include "tcpm/tcpci.h"
#include "tcpm/tcpm.h"
diff --git a/driver/tcpm/fusb302.c b/driver/tcpm/fusb302.c
index 4b4a15c711..3f11e568d0 100644
--- a/driver/tcpm/fusb302.c
+++ b/driver/tcpm/fusb302.c
@@ -9,8 +9,8 @@
#include "console.h"
#include "fusb302.h"
-#include "task.h"
#include "hooks.h"
+#include "task.h"
#include "tcpm/tcpci.h"
#include "tcpm/tcpm.h"
#include "timer.h"
diff --git a/driver/tcpm/it83xx.c b/driver/tcpm/it83xx.c
index 0b636e2e89..d04cb2f597 100644
--- a/driver/tcpm/it83xx.c
+++ b/driver/tcpm/it83xx.c
@@ -9,17 +9,17 @@
#include "common.h"
#include "config.h"
#include "console.h"
+#include "hooks.h"
#include "it83xx_pd.h"
#include "registers.h"
#include "system.h"
#include "task.h"
#include "tcpm/tcpci.h"
#include "timer.h"
-#include "util.h"
#include "usb_common.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
-#include "hooks.h"
+#include "util.h"
#ifdef CONFIG_USB_PD_TCPMV1
#if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) || \
diff --git a/driver/tcpm/it83xx_pd.h b/driver/tcpm/it83xx_pd.h
index 1ab76e2b79..2cb63aa22f 100644
--- a/driver/tcpm/it83xx_pd.h
+++ b/driver/tcpm/it83xx_pd.h
@@ -7,10 +7,10 @@
#ifndef __CROS_EC_DRIVER_TCPM_IT83XX_H
#define __CROS_EC_DRIVER_TCPM_IT83XX_H
-#include <stdint.h>
-
#include "driver/tcpm/it8xxx2_pd_public.h"
+#include <stdint.h>
+
/* USBPD Controller */
#if defined(CONFIG_USB_PD_TCPM_DRIVER_IT83XX)
#define IT83XX_USBPD_BASE(port) (0x00F03700 + (0x100 * (port)))
diff --git a/driver/tcpm/it8xxx2.c b/driver/tcpm/it8xxx2.c
index 6782b528e5..9bf50e1335 100644
--- a/driver/tcpm/it8xxx2.c
+++ b/driver/tcpm/it8xxx2.c
@@ -9,17 +9,17 @@
#include "common.h"
#include "config.h"
#include "console.h"
+#include "hooks.h"
#include "it83xx_pd.h"
#include "ite_pd_intc.h"
#include "registers.h"
#include "system.h"
#include "task.h"
#include "timer.h"
-#include "util.h"
#include "usb_common.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
-#include "hooks.h"
+#include "util.h"
#ifdef CONFIG_USB_PD_TCPMV1
#if defined(CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE) || \
diff --git a/driver/tcpm/nct38xx.c b/driver/tcpm/nct38xx.c
index e3a9fc04a2..120749fb62 100644
--- a/driver/tcpm/nct38xx.c
+++ b/driver/tcpm/nct38xx.c
@@ -15,9 +15,10 @@
#include "usb_common.h"
#ifdef CONFIG_ZEPHYR
+#include "usbc/tcpc_nct38xx.h"
+
#include <zephyr/device.h>
#include <zephyr/drivers/gpio/gpio_nct38xx.h>
-#include "usbc/tcpc_nct38xx.h"
#endif
#if defined(CONFIG_ZEPHYR) && defined(CONFIG_IO_EXPANDER_NCT38XX)
diff --git a/driver/tcpm/ps8xxx.h b/driver/tcpm/ps8xxx.h
index 7d873abc85..ed3197c822 100644
--- a/driver/tcpm/ps8xxx.h
+++ b/driver/tcpm/ps8xxx.h
@@ -2,9 +2,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "usb_mux.h"
-
#include "driver/tcpm/ps8xxx_public.h"
+#include "usb_mux.h"
/* Parade Tech Type-C port controller */
diff --git a/driver/tcpm/rt1718s.h b/driver/tcpm/rt1718s.h
index f7c821ba53..8ff977e26b 100644
--- a/driver/tcpm/rt1718s.h
+++ b/driver/tcpm/rt1718s.h
@@ -6,9 +6,9 @@
#define __CROS_EC_USB_PD_TCPM_RT1718S_H
#include "tcpm/rt1718s_public.h"
-#include "util.h"
#include "usb_charge.h"
#include "usb_pd_tcpm.h"
+#include "util.h"
/* RT1718S Private RegMap */
#define RT1718S_PHYCTRL1 0x80
diff --git a/driver/tcpm/stm32gx.c b/driver/tcpm/stm32gx.c
index 77a436b2ac..029570faca 100644
--- a/driver/tcpm/stm32gx.c
+++ b/driver/tcpm/stm32gx.c
@@ -9,16 +9,16 @@
#include "common.h"
#include "config.h"
#include "console.h"
+#include "hooks.h"
#include "registers.h"
#include "stm32gx.h"
#include "system.h"
#include "task.h"
#include "tcpm/tcpci.h"
#include "timer.h"
-#include "util.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
-#include "hooks.h"
+#include "util.h"
/*
* STM32G4 UCPD peripheral does not have the ability to detect VBUS, but
diff --git a/driver/tcpm/tcpci.c b/driver/tcpm/tcpci.c
index 6e8a1feaf9..243ca94bd5 100644
--- a/driver/tcpm/tcpci.c
+++ b/driver/tcpm/tcpci.c
@@ -5,8 +5,8 @@
/* Type-C port manager */
-#include "atomic.h"
#include "anx74xx.h"
+#include "atomic.h"
#include "compile_time_macros.h"
#include "console.h"
#include "ec_commands.h"
@@ -1848,7 +1848,7 @@ static const struct tcpc_reg_dump_map tcpc_regs[] = {
/*
* Dump standard TCPC registers.
*/
-void tcpc_dump_std_registers(int port)
+test_mockable void tcpc_dump_std_registers(int port)
{
tcpc_dump_registers(port, tcpc_regs, ARRAY_SIZE(tcpc_regs));
}
@@ -1890,6 +1890,9 @@ const struct tcpm_drv tcpci_tcpm_drv = {
#ifdef CONFIG_USB_PD_TCPC_LOW_POWER
.enter_low_power_mode = &tcpci_enter_low_power_mode,
#endif
+#ifdef CONFIG_USB_PD_FRS_TCPC
+ .set_frs_enable = &tcpci_tcpc_fast_role_swap_enable,
+#endif
.set_bist_test_mode = &tcpci_set_bist_test_mode,
.get_bist_test_mode = &tcpci_get_bist_test_mode,
#ifdef CONFIG_CMD_TCPC_DUMP
diff --git a/driver/tcpm/tusb422.c b/driver/tcpm/tusb422.c
index 6d12d1758b..79554bd0cf 100644
--- a/driver/tcpm/tusb422.c
+++ b/driver/tcpm/tusb422.c
@@ -6,10 +6,10 @@
/* Type-C port manager for TI TUSB422 Port Controller */
#include "common.h"
-#include "tusb422.h"
#include "tcpm/tcpci.h"
#include "tcpm/tcpm.h"
#include "timer.h"
+#include "tusb422.h"
#include "usb_pd.h"
#ifndef CONFIG_USB_PD_TCPM_TCPCI
diff --git a/driver/temp_sensor/adt7481.c b/driver/temp_sensor/adt7481.c
index 0157d64b2d..f0aee1506f 100644
--- a/driver/temp_sensor/adt7481.c
+++ b/driver/temp_sensor/adt7481.c
@@ -5,12 +5,12 @@
/* ADT7481 temperature sensor module for Chrome EC */
+#include "adt7481.h"
#include "common.h"
#include "console.h"
-#include "adt7481.h"
#include "gpio.h"
-#include "i2c.h"
#include "hooks.h"
+#include "i2c.h"
#include "util.h"
static int temp_val_local;
diff --git a/driver/temp_sensor/amd_r19me4070.c b/driver/temp_sensor/amd_r19me4070.c
index 97868b6945..3ee230da09 100644
--- a/driver/temp_sensor/amd_r19me4070.c
+++ b/driver/temp_sensor/amd_r19me4070.c
@@ -5,12 +5,12 @@
/* R19ME4070 temperature sensor module for Chrome EC */
+#include "amd_r19me4070.h"
#include "chipset.h"
#include "common.h"
#include "console.h"
#include "hooks.h"
#include "i2c.h"
-#include "amd_r19me4070.h"
#include "power.h"
#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
diff --git a/driver/temp_sensor/f75303.c b/driver/temp_sensor/f75303.c
index e686537c31..d83f7bc4a6 100644
--- a/driver/temp_sensor/f75303.c
+++ b/driver/temp_sensor/f75303.c
@@ -6,11 +6,11 @@
/* F75303 temperature sensor module for Chrome EC */
#include "common.h"
+#include "console.h"
#include "f75303.h"
-#include "i2c.h"
#include "hooks.h"
+#include "i2c.h"
#include "util.h"
-#include "console.h"
static int temps[F75303_IDX_COUNT];
static int8_t fake_temp[F75303_IDX_COUNT] = { -1, -1, -1 };
diff --git a/driver/temp_sensor/g753.c b/driver/temp_sensor/g753.c
index 8d94cac4f8..f162cbf846 100644
--- a/driver/temp_sensor/g753.c
+++ b/driver/temp_sensor/g753.c
@@ -9,8 +9,8 @@
#include "console.h"
#include "g753.h"
#include "gpio.h"
-#include "i2c.h"
#include "hooks.h"
+#include "i2c.h"
#include "util.h"
static int temp_val_local;
diff --git a/driver/temp_sensor/g78x.c b/driver/temp_sensor/g78x.c
index 82cb2d26e9..413e2dda8a 100644
--- a/driver/temp_sensor/g78x.c
+++ b/driver/temp_sensor/g78x.c
@@ -9,8 +9,8 @@
#include "console.h"
#include "g78x.h"
#include "gpio.h"
-#include "i2c.h"
#include "hooks.h"
+#include "i2c.h"
#include "util.h"
static int temp_val_local;
diff --git a/driver/temp_sensor/oti502.c b/driver/temp_sensor/oti502.c
index 2051df89f6..4564ad9257 100644
--- a/driver/temp_sensor/oti502.c
+++ b/driver/temp_sensor/oti502.c
@@ -7,9 +7,9 @@
#include "common.h"
#include "console.h"
-#include "oti502.h"
-#include "i2c.h"
#include "hooks.h"
+#include "i2c.h"
+#include "oti502.h"
#include "util.h"
static int temp_val_ambient; /* Ambient is chip temperature*/
diff --git a/driver/temp_sensor/pct2075.c b/driver/temp_sensor/pct2075.c
index 9c7b7190e9..02150ad796 100644
--- a/driver/temp_sensor/pct2075.c
+++ b/driver/temp_sensor/pct2075.c
@@ -7,8 +7,8 @@
#include "common.h"
#include "console.h"
-#include "i2c.h"
#include "hooks.h"
+#include "i2c.h"
#include "math_util.h"
#include "temp_sensor/pct2075.h"
#include "util.h"
@@ -76,6 +76,7 @@ int pct2075_get_val_mk(int idx, int *temp_mk_ptr)
return EC_SUCCESS;
}
+#ifndef CONFIG_ZEPHYR
static void pct2075_poll(void)
{
int s;
@@ -87,6 +88,18 @@ static void pct2075_poll(void)
}
}
DECLARE_HOOK(HOOK_SECOND, pct2075_poll, HOOK_PRIO_TEMP_SENSOR);
+#else
+void pct2075_update_temperature(int idx)
+{
+ int temp_reg = 0;
+
+ if (idx >= PCT2075_COUNT)
+ return;
+
+ if (get_reg_temp(idx, &temp_reg) == EC_SUCCESS)
+ temp_mk_local[idx] = pct2075_reg_to_mk(temp_reg);
+}
+#endif /* CONFIG_ZEPHYR */
void pct2075_init(void)
{
diff --git a/driver/temp_sensor/tmp112.c b/driver/temp_sensor/tmp112.c
index f7f28159aa..267227f6f3 100644
--- a/driver/temp_sensor/tmp112.c
+++ b/driver/temp_sensor/tmp112.c
@@ -7,8 +7,8 @@
#include "common.h"
#include "console.h"
-#include "i2c.h"
#include "hooks.h"
+#include "i2c.h"
#include "math_util.h"
#include "temp_sensor/tmp112.h"
#include "util.h"
@@ -92,6 +92,7 @@ int tmp112_get_val_mk(int idx, int *temp_mk_ptr)
return EC_SUCCESS;
}
+#ifndef CONFIG_ZEPHYR
static void tmp112_poll(void)
{
int s;
@@ -103,6 +104,18 @@ static void tmp112_poll(void)
}
}
DECLARE_HOOK(HOOK_SECOND, tmp112_poll, HOOK_PRIO_TEMP_SENSOR);
+#else
+static void tmp112_update_temperature(int idx)
+{
+ int temp_reg = 0;
+
+ if (idx >= TMP112_COUNT)
+ return;
+
+ if (get_reg_temp(idx, &temp_reg) == EC_SUCCESS)
+ temp_mk_local[idx] = tmp112_reg_to_mk(temp_reg);
+}
+#endif /* CONFIG_ZEPHYR */
void tmp112_init(void)
{
diff --git a/driver/temp_sensor/tmp411.c b/driver/temp_sensor/tmp411.c
index 8a14440671..4f8a08a181 100644
--- a/driver/temp_sensor/tmp411.c
+++ b/driver/temp_sensor/tmp411.c
@@ -7,10 +7,10 @@
#include "common.h"
#include "console.h"
-#include "tmp411.h"
#include "gpio.h"
-#include "i2c.h"
#include "hooks.h"
+#include "i2c.h"
+#include "tmp411.h"
#include "util.h"
static int temp_val_local;
diff --git a/driver/temp_sensor/tmp432.c b/driver/temp_sensor/tmp432.c
index fde6536536..581e33b979 100644
--- a/driver/temp_sensor/tmp432.c
+++ b/driver/temp_sensor/tmp432.c
@@ -7,10 +7,10 @@
#include "common.h"
#include "console.h"
-#include "tmp432.h"
#include "gpio.h"
-#include "i2c.h"
#include "hooks.h"
+#include "i2c.h"
+#include "tmp432.h"
#include "util.h"
static int temp_val_local;
diff --git a/driver/temp_sensor/tmp468.c b/driver/temp_sensor/tmp468.c
index 87eb040460..3bfaeeedbb 100644
--- a/driver/temp_sensor/tmp468.c
+++ b/driver/temp_sensor/tmp468.c
@@ -7,13 +7,12 @@
#include "common.h"
#include "console.h"
-#include "tmp432.h"
#include "gpio.h"
-#include "i2c.h"
#include "hooks.h"
-#include "util.h"
-
+#include "i2c.h"
+#include "tmp432.h"
#include "tmp468.h"
+#include "util.h"
static int fake_temp[TMP468_CHANNEL_COUNT] = { -1, -1, -1, -1, -1,
-1, -1, -1, -1 };
diff --git a/driver/touchpad_elan.c b/driver/touchpad_elan.c
index 05c081a84a..7dacf9fdb1 100644
--- a/driver/touchpad_elan.c
+++ b/driver/touchpad_elan.c
@@ -7,20 +7,20 @@
#include "common.h"
#include "console.h"
#include "gpio.h"
-#include "hwtimer.h"
#include "hooks.h"
+#include "hwtimer.h"
#include "i2c.h"
#include "math_util.h"
#include "sha256.h"
#include "shared_mem.h"
-#include "task.h"
#include "tablet_mode.h"
+#include "task.h"
#include "timer.h"
#include "touchpad.h"
#include "update_fw.h"
-#include "util.h"
#include "usb_api.h"
#include "usb_hid_touchpad.h"
+#include "util.h"
#include "watchdog.h"
/* Console output macros */
diff --git a/driver/touchpad_gt7288.c b/driver/touchpad_gt7288.c
index 9d9b31a22b..f225c5b7eb 100644
--- a/driver/touchpad_gt7288.c
+++ b/driver/touchpad_gt7288.c
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdbool.h>
-
#include "common.h"
#include "console.h"
#include "hooks.h"
@@ -13,6 +11,8 @@
#include "touchpad_gt7288.h"
#include "util.h"
+#include <stdbool.h>
+
/* Define this to enable various warning messages during report parsing. */
#undef DEBUG_CHECKS
diff --git a/driver/touchpad_st.c b/driver/touchpad_st.c
index f66df6ab2a..f71b952f86 100644
--- a/driver/touchpad_st.c
+++ b/driver/touchpad_st.c
@@ -8,14 +8,14 @@
#include "common.h"
#include "console.h"
#include "gpio.h"
-#include "hwtimer.h"
#include "hooks.h"
+#include "hwtimer.h"
#include "i2c.h"
#include "printf.h"
#include "registers.h"
#include "spi.h"
-#include "task.h"
#include "tablet_mode.h"
+#include "task.h"
#include "timer.h"
#include "touchpad.h"
#include "touchpad_st.h"
diff --git a/driver/touchpad_st.h b/driver/touchpad_st.h
index 6ea3f6aeb0..1dee7f0947 100644
--- a/driver/touchpad_st.h
+++ b/driver/touchpad_st.h
@@ -6,10 +6,10 @@
#ifndef __CROS_EC_TOUCHPAD_ST_H
#define __CROS_EC_TOUCHPAD_ST_H
-#include <stdint.h>
-
#include "common.h"
+#include <stdint.h>
+
#define ST_VENDOR_ID 0x0483
#define ST_TP_EXTRA_BYTE 1
diff --git a/driver/usb_mux/pi3usb3x532.h b/driver/usb_mux/pi3usb3x532.h
index 9214d349f0..d0a7abaa89 100644
--- a/driver/usb_mux/pi3usb3x532.h
+++ b/driver/usb_mux/pi3usb3x532.h
@@ -12,8 +12,8 @@
#ifndef __CROS_EC_PI3USB3X532_H
#define __CROS_EC_PI3USB3X532_H
-#include "usb_pd.h"
#include "usb_mux.h"
+#include "usb_pd.h"
/* I2C Addresses */
#define PI3USB3X532_I2C_ADDR0 0x54
diff --git a/driver/usb_mux/tusb1064.h b/driver/usb_mux/tusb1064.h
index 1a38290174..0e366f1bc9 100644
--- a/driver/usb_mux/tusb1064.h
+++ b/driver/usb_mux/tusb1064.h
@@ -6,9 +6,10 @@
#ifndef __CROS_EC_TUSB1064_H
#define __CROS_EC_TUSB1064_H
-#include <stdint.h>
#include "usb_mux.h"
+#include <stdint.h>
+
/*
* TUSB1064 Has 16 possible device addresses which are selected by A1|A0 lines
* using 4 level inputs.
diff --git a/driver/usb_mux/usb_mux.c b/driver/usb_mux/usb_mux.c
index edc9da5778..73c8a165bf 100644
--- a/driver/usb_mux/usb_mux.c
+++ b/driver/usb_mux/usb_mux.c
@@ -7,9 +7,9 @@
#include "atomic.h"
#include "builtin/assert.h"
+#include "chipset.h"
#include "common.h"
#include "console.h"
-#include "chipset.h"
#include "ec_commands.h"
#include "hooks.h"
#include "host_command.h"
diff --git a/driver/wpc/p9221.h b/driver/wpc/p9221.h
index 53dcc57aa7..1360c54ee7 100644
--- a/driver/wpc/p9221.h
+++ b/driver/wpc/p9221.h
@@ -10,9 +10,9 @@
#ifndef __P9221_R7_H
#define __P9221_R7_H
+#include "charge_manager.h"
#include "common.h"
#include "gpio.h"
-#include "charge_manager.h"
#include "task.h"
/* ========== Variant-specific configuration ============ */
diff --git a/extra/ftdi_hostcmd/test_cmds.c b/extra/ftdi_hostcmd/test_cmds.c
index 748b862b56..ba985717bf 100644
--- a/extra/ftdi_hostcmd/test_cmds.c
+++ b/extra/ftdi_hostcmd/test_cmds.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
+#include "ec_commands.h"
+#include "mpsse.h"
+
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include "mpsse.h"
-
-#include "ec_commands.h"
+#include <unistd.h>
static int opt_verbose;
diff --git a/extra/lightbar/input.c b/extra/lightbar/input.c
index 5b605600ea..1ddfe2e1b3 100644
--- a/extra/lightbar/input.c
+++ b/extra/lightbar/input.c
@@ -3,17 +3,17 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "simulation.h"
+
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include "simulation.h"
-
#ifdef HAS_GNU_READLINE
-#include <readline/readline.h>
#include <readline/history.h>
+#include <readline/readline.h>
char *get_input(const char *prompt)
{
diff --git a/extra/lightbar/main.c b/extra/lightbar/main.c
index 321c0c73d2..e08aefc114 100644
--- a/extra/lightbar/main.c
+++ b/extra/lightbar/main.c
@@ -3,18 +3,19 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "simulation.h"
+
#include <assert.h>
#include <errno.h>
#include <inttypes.h>
-#include <pthread.h>
+#include <stdarg.h>
#include <stdint.h>
-#include <string.h>
#include <stdio.h>
#include <stdlib.h>
-#include <stdarg.h>
+#include <string.h>
#include <time.h>
-#include "simulation.h"
+#include <pthread.h>
static void *(*thread_fns[])(void *) = {
entry_windows,
diff --git a/extra/lightbar/simulation.h b/extra/lightbar/simulation.h
index c77583e6c9..93f0a957c0 100644
--- a/extra/lightbar/simulation.h
+++ b/extra/lightbar/simulation.h
@@ -6,15 +6,16 @@
#ifndef __EXTRA_SIMULATION_H
#define __EXTRA_SIMULATION_H
+#include "lb_common.h"
+#include "lightbar.h"
+
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <unistd.h>
-#include "lb_common.h"
-#include "lightbar.h"
+#include <unistd.h>
/* Functions specific to our simulation environment */
void *entry_windows(void *);
diff --git a/extra/lightbar/windows.c b/extra/lightbar/windows.c
index e0b14fae42..3371cd42f5 100644
--- a/extra/lightbar/windows.c
+++ b/extra/lightbar/windows.c
@@ -3,16 +3,17 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "simulation.h"
+
#include <assert.h>
-#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
-#include <xcb/xcb.h>
-#include "simulation.h"
+#include <pthread.h>
+#include <xcb/xcb.h>
/*****************************************************************************/
/* Window drawing stuff */
diff --git a/extra/rma_reset/rma_reset.c b/extra/rma_reset/rma_reset.c
index d437b63f1a..4c2ce76803 100644
--- a/extra/rma_reset/rma_reset.c
+++ b/extra/rma_reset/rma_reset.c
@@ -3,27 +3,28 @@
* found in the LICENSE file.
*/
+#include "base32.h"
+#include "curve25519.h"
+#include "rma_auth.h"
+#include "sha256.h"
+
#include <ctype.h>
-#include <endian.h>
#include <errno.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include <endian.h>
#include <fcntl.h>
#include <getopt.h>
#include <openssl/bn.h>
#include <openssl/ec.h>
#include <openssl/obj_mac.h>
#include <openssl/rand.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
#include <unistd.h>
-#include "rma_auth.h"
-#include "curve25519.h"
-#include "sha256.h"
-#include "base32.h"
-
#define EC_COORDINATE_SZ 32
#define EC_PRIV_KEY_SZ 32
#define EC_P256_UNCOMPRESSED_PUB_KEY_SZ (EC_COORDINATE_SZ * 2 + 1)
diff --git a/extra/sps_errs/prog.c b/extra/sps_errs/prog.c
index bf44dd182c..5c614ec55d 100644
--- a/extra/sps_errs/prog.c
+++ b/extra/sps_errs/prog.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
+#include "ec_commands.h"
+#include "mpsse.h"
+
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
-#include "mpsse.h"
-
-#include "ec_commands.h"
+#include <unistd.h>
static int opt_verbose;
static size_t stop_after = -1;
diff --git a/extra/touchpad_updater/touchpad_updater.c b/extra/touchpad_updater/touchpad_updater.c
index fee898ca06..608a847cd6 100644
--- a/extra/touchpad_updater/touchpad_updater.c
+++ b/extra/touchpad_updater/touchpad_updater.c
@@ -5,17 +5,17 @@
*/
#include <errno.h>
-#include <getopt.h>
-#include <poll.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/select.h>
-#include <unistd.h>
+#include <getopt.h>
#include <libusb.h>
+#include <poll.h>
+#include <sys/select.h>
+#include <unistd.h>
/* Command line options */
static uint16_t vid = 0x18d1; /* Google */
diff --git a/extra/usb_console/usb_console.c b/extra/usb_console/usb_console.c
index aea9eb8293..db1f2a4bec 100644
--- a/extra/usb_console/usb_console.c
+++ b/extra/usb_console/usb_console.c
@@ -5,17 +5,17 @@
*/
#include <errno.h>
-#include <getopt.h>
-#include <poll.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/select.h>
-#include <unistd.h>
+#include <getopt.h>
#include <libusb.h>
+#include <poll.h>
+#include <sys/select.h>
+#include <unistd.h>
/* Options */
static uint16_t vid = 0x18d1; /* Google */
diff --git a/extra/usb_gpio/usb_gpio.c b/extra/usb_gpio/usb_gpio.c
index 7f2121d2b0..41810a6a0e 100644
--- a/extra/usb_gpio/usb_gpio.c
+++ b/extra/usb_gpio/usb_gpio.c
@@ -4,11 +4,12 @@
* found in the LICENSE file.
*/
-#include <libusb.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+
+#include <libusb.h>
#include <unistd.h>
#define CHECK(expression) \
diff --git a/extra/usb_updater/desc_parser.c b/extra/usb_updater/desc_parser.c
index 7e9f583902..d75677f0e0 100644
--- a/extra/usb_updater/desc_parser.c
+++ b/extra/usb_updater/desc_parser.c
@@ -4,15 +4,16 @@
* found in the LICENSE file.
*/
+#include "desc_parser.h"
+
#include <ctype.h>
#include <errno.h>
-#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/stat.h>
-#include "desc_parser.h"
+#include <malloc.h>
+#include <sys/stat.h>
static FILE *hash_file_;
static int line_count_;
diff --git a/extra/usb_updater/usb_updater2.c b/extra/usb_updater/usb_updater2.c
index d591811a2b..744bf94b30 100644
--- a/extra/usb_updater/usb_updater2.c
+++ b/extra/usb_updater/usb_updater2.c
@@ -4,29 +4,29 @@
* found in the LICENSE file.
*/
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
#include <asm/byteorder.h>
#include <endian.h>
#include <fcntl.h>
+#include <fmap.h>
#include <getopt.h>
#include <libusb.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
-#include <time.h>
#include <unistd.h>
-#include <fmap.h>
-
#ifndef __packed
#define __packed __attribute__((packed))
#endif
#include "compile_time_macros.h"
#include "misc_util.h"
-#include "usb_descriptor.h"
#include "update_fw.h"
+#include "usb_descriptor.h"
#include "vb21_struct.h"
#ifdef DEBUG
diff --git a/firmware_builder.py b/firmware_builder.py
index afd3d815c5..06bf9beec6 100755
--- a/firmware_builder.py
+++ b/firmware_builder.py
@@ -74,9 +74,23 @@ def build(opts):
ec_dir = pathlib.Path(__file__).parent
subprocess.run([ec_dir / "util" / "check_clang_format.py"], check=True)
+ cmd = ["make", "clobber"]
+ print(f"# Running {' '.join(cmd)}.")
+ subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True)
+
cmd = ["make", "buildall_only", f"-j{opts.cpus}"]
print(f"# Running {' '.join(cmd)}.")
subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True)
+
+ # extra/rma_reset is used in chromeos-base/ec-utils-test
+ cmd = ["make", "-C", "extra/rma_reset", "clean"]
+ print(f"# Running {' '.join(cmd)}.")
+ subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True)
+
+ cmd = ["make", "-C", "extra/rma_reset", f"-j{opts.cpus}"]
+ print(f"# Running {' '.join(cmd)}.")
+ subprocess.run(cmd, cwd=os.path.dirname(__file__), check=True)
+
ec_dir = os.path.dirname(__file__)
build_dir = os.path.join(ec_dir, "build")
for build_target in sorted(os.listdir(build_dir)):
diff --git a/fuzz/host_command_fuzz.c b/fuzz/host_command_fuzz.c
index 0a648f602c..2875c687dd 100644
--- a/fuzz/host_command_fuzz.c
+++ b/fuzz/host_command_fuzz.c
@@ -5,9 +5,6 @@
* Fuzz host command.
*/
-#include <pthread.h>
-#include <sys/time.h>
-
#include "builtin/assert.h"
#include "common.h"
#include "console.h"
@@ -19,6 +16,9 @@
#include "timer.h"
#include "util.h"
+#include <pthread.h>
+#include <sys/time.h>
+
/* Only test requests with valid size and checksum (makes fuzzing faster) */
#define VALID_REQUEST_ONLY
diff --git a/fuzz/pchg_fuzz.c b/fuzz/pchg_fuzz.c
index 4ef5f28b74..06c94a2d83 100644
--- a/fuzz/pchg_fuzz.c
+++ b/fuzz/pchg_fuzz.c
@@ -14,10 +14,11 @@
#include "timer.h"
#include "util.h"
-#include <pthread.h>
#include <stdlib.h>
#include <string.h>
+#include <pthread.h>
+
#define TASK_EVENT_FUZZ TASK_EVENT_CUSTOM_BIT(0)
extern struct pchg_drv ctn730_drv;
diff --git a/fuzz/span.h b/fuzz/span.h
index 9cb08f9461..de144efe60 100644
--- a/fuzz/span.h
+++ b/fuzz/span.h
@@ -5,9 +5,8 @@
#ifndef __FUZZ_SPAN_H
#define __FUZZ_SPAN_H
-#include <unistd.h>
-
#include <algorithm>
+#include <unistd.h>
namespace fuzz
{
diff --git a/fuzz/usb_pd_fuzz.c b/fuzz/usb_pd_fuzz.c
index bb462b9e61..809e09cdbb 100644
--- a/fuzz/usb_pd_fuzz.c
+++ b/fuzz/usb_pd_fuzz.c
@@ -13,10 +13,11 @@
#include "usb_pd_tcpm.h"
#include "util.h"
-#include <pthread.h>
#include <stdlib.h>
#include <string.h>
+#include <pthread.h>
+
#define TASK_EVENT_FUZZ TASK_EVENT_CUSTOM_BIT(0)
#define PORT0 0
@@ -224,7 +225,9 @@ void run_test(int argc, const char **argv)
task_wait_event(50 * MSEC);
}
+ pthread_mutex_lock(&lock);
pthread_cond_signal(&done_cond);
+ pthread_mutex_unlock(&lock);
}
}
@@ -266,8 +269,17 @@ int test_fuzz_one_input(const uint8_t *data, unsigned int size)
return 0;
}
+ pthread_mutex_init(&lock, NULL);
+ pthread_cond_init(&done_cond, NULL);
+
task_set_event(TASK_ID_TEST_RUNNER, TASK_EVENT_FUZZ);
+
+ pthread_mutex_lock(&lock);
pthread_cond_wait(&done_cond, &lock);
+ pthread_mutex_unlock(&lock);
+
+ pthread_cond_destroy(&done_cond);
+ pthread_mutex_destroy(&lock);
return 0;
}
diff --git a/include/accelgyro.h b/include/accelgyro.h
index 74824b2611..b51a0ea148 100644
--- a/include/accelgyro.h
+++ b/include/accelgyro.h
@@ -6,8 +6,8 @@
#ifndef __CROS_EC_ACCELGYRO_H
#define __CROS_EC_ACCELGYRO_H
-#include "motion_sense.h"
#include "math_util.h"
+#include "motion_sense.h"
/* Header file for accelerometer / gyro drivers. */
diff --git a/include/base32.h b/include/base32.h
index a1816afb60..d1acc6ab95 100644
--- a/include/base32.h
+++ b/include/base32.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_BASE32_H
#define __CROS_EC_BASE32_H
+#include <stdint.h>
+
/* Symbol map for base32 encoding */
extern const char base32_map[33];
diff --git a/include/battery.h b/include/battery.h
index 51fcd68696..be93b44c21 100644
--- a/include/battery.h
+++ b/include/battery.h
@@ -220,7 +220,7 @@ enum battery_present battery_is_present(void);
* If battery support is not enabled and the board does not specifically
* provide its own implementation, assume a battery is never present.
*/
-static inline enum battery_present battery_is_present(void)
+test_mockable_static_inline enum battery_present battery_is_present(void)
{
return BP_NO;
}
diff --git a/include/battery_fuel_gauge.h b/include/battery_fuel_gauge.h
index 0a2a4064bb..efcf18530c 100644
--- a/include/battery_fuel_gauge.h
+++ b/include/battery_fuel_gauge.h
@@ -9,6 +9,7 @@
#define __CROS_EC_BATTERY_FUEL_GAUGE_H
#include "battery.h"
+
#include <stdbool.h>
/* Number of writes needed to invoke battery cutoff command */
diff --git a/include/benchmark.h b/include/benchmark.h
new file mode 100644
index 0000000000..190580ebb7
--- /dev/null
+++ b/include/benchmark.h
@@ -0,0 +1,157 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Benchmark utility functions.
+ */
+
+#ifndef __CROS_EC_BENCHMARK_H
+#define __CROS_EC_BENCHMARK_H
+
+#include <stdint.h>
+
+#include <array>
+#include <functional>
+#include <optional>
+#include <string_view>
+
+extern "C" {
+#include "clock.h"
+#include "console.h"
+#include "timer.h"
+#include "util.h"
+#include "watchdog.h"
+}
+
+/* Benchmark execution options */
+struct BenchmarkOptions {
+ /* Number of test iterations */
+ int num_iterations = 10;
+ /* Whether to reload the watchdog between executions of f() */
+ bool reload_watchdog = true;
+ /* Whether to enable fast CPU clock during the test (when supported) */
+ bool use_fast_cpu = true;
+};
+
+/* The result of a benchmark run with various timing metrics.
+ * All time measurements are in micro seconds, except the average that
+ * is captured in nanoseconds for increased resolution.
+ */
+struct BenchmarkResult {
+ /* Name of the test, used when printing results */
+ std::string_view name;
+ /* Total elapsed time (us) for all iterations */
+ uint32_t elapsed_time;
+ /* Average elapsed time (ns) for a single iteration */
+ uint32_t average_time;
+ /* Minimum elapsed time (us) for a single iteration */
+ uint32_t min_time;
+ /* Maximum elapsed time (us) for a single iteration */
+ uint32_t max_time;
+};
+
+/* Benchmark main class responsible for running the experiments and
+ * collecting/printing the results.
+ * Note that the implementation intentionally avoid dynamic memory allocations
+ * and stores up to MAX_NUM_RESULTS results into a std::array.
+ */
+template <int MAX_NUM_RESULTS = 5> class Benchmark {
+ public:
+ explicit Benchmark(const BenchmarkOptions &options = BenchmarkOptions())
+ : options_(options){};
+
+ /* Run benchmark of the function f().
+ *
+ * TODO(b/253099367): replace std::optional with StatusOr
+ */
+ std::optional<BenchmarkResult>
+ run(const std::string_view benchmark_name, std::function<void()> f)
+ {
+ if (benchmark_name.empty()) {
+ ccprintf("%s: benchmark_name cannot be empty\n",
+ __func__);
+ return {};
+ }
+ if (num_results_ >= MAX_NUM_RESULTS) {
+ ccprintf("%s: cannot store new BenchmarkResults\n",
+ __func__);
+ return {};
+ }
+
+ BenchmarkResult &result = results_[num_results_++];
+ result.name = benchmark_name;
+ result.elapsed_time = 0;
+
+ if (options_.use_fast_cpu)
+ clock_enable_module(MODULE_FAST_CPU, 1);
+
+ bool valid_min_max = false;
+ for (int i = 0; i < options_.num_iterations; ++i) {
+ timestamp_t start_time = get_time();
+ f();
+ uint32_t iteration_time = time_since32(start_time);
+
+ if (options_.reload_watchdog)
+ watchdog_reload();
+
+ if (valid_min_max) {
+ result.max_time =
+ MAX(result.max_time, iteration_time);
+ result.min_time =
+ MIN(result.min_time, iteration_time);
+ } else {
+ result.max_time = iteration_time;
+ result.min_time = iteration_time;
+ valid_min_max = true;
+ }
+ result.elapsed_time += iteration_time;
+ }
+
+ if (options_.use_fast_cpu)
+ clock_enable_module(MODULE_FAST_CPU, 0);
+
+ result.average_time =
+ (result.elapsed_time) / options_.num_iterations;
+
+ return result;
+ }
+
+ void print_results() const
+ {
+ print_header();
+ for (int i = 0; i < num_results_; ++i)
+ print_result(results_[i]);
+ }
+
+ private:
+ const BenchmarkOptions options_;
+ std::array<BenchmarkResult, MAX_NUM_RESULTS> results_;
+ int num_results_ = 0;
+
+ /* Print table header with column names */
+ void print_header() const
+ {
+ constexpr char kSeparator[] = "--------------------------";
+
+ ccprintf("%16s | %15s | %13s | %13s | %13s | %13s\n",
+ "Test Name", "Num Iterations", "Elapsed (us)",
+ "Min (us)", "Max (us)", "Avg (us)");
+ ccprintf("%.*s | %.*s | %.*s | %.*s | %.*s | %.*s\n", 16,
+ kSeparator, 15, kSeparator, 13, kSeparator, 13,
+ kSeparator, 13, kSeparator, 13, kSeparator);
+ cflush();
+ }
+
+ /* Print a single benchmark result */
+ int print_result(const BenchmarkResult &result) const
+ {
+ ccprintf("%16s | %15u | %13u | %13u | %13u | %13u\n",
+ result.name.data(), options_.num_iterations,
+ result.elapsed_time, result.min_time, result.max_time,
+ result.average_time);
+ cflush();
+ return EC_SUCCESS;
+ }
+};
+
+#endif /* __CROS_EC_BENCHMARK_H */
diff --git a/include/bluetooth_le_ll.h b/include/bluetooth_le_ll.h
index d17aec8a57..ec2bb7f7e7 100644
--- a/include/bluetooth_le_ll.h
+++ b/include/bluetooth_le_ll.h
@@ -3,8 +3,8 @@
* found in the LICENSE file.
*/
-#include "common.h"
#include "btle_hci_int.h"
+#include "common.h"
enum ll_state_t {
UNINITIALIZED,
diff --git a/include/body_detection.h b/include/body_detection.h
index 8fea5d84e1..7ab7ab3e6d 100644
--- a/include/body_detection.h
+++ b/include/body_detection.h
@@ -6,8 +6,8 @@
#ifndef __CROS_EC_BODY_DETECTION_H
#define __CROS_EC_BODY_DETECTION_H
-#include <stdint.h>
#include <stdbool.h>
+#include <stdint.h>
enum body_detect_states { BODY_DETECTION_OFF_BODY, BODY_DETECTION_ON_BODY };
diff --git a/include/button.h b/include/button.h
index f0c71d7f3f..b38191aaf5 100644
--- a/include/button.h
+++ b/include/button.h
@@ -10,8 +10,8 @@
#include "common.h"
#include "compile_time_macros.h"
-#include "gpio_signal.h"
#include "ec_commands.h"
+#include "gpio_signal.h"
#define BUTTON_FLAG_ACTIVE_HIGH BIT(0)
#define BUTTON_FLAG_DISABLED BIT(1) /* Button disabled */
diff --git a/include/charge_manager.h b/include/charge_manager.h
index 459673a630..2d4155f09d 100644
--- a/include/charge_manager.h
+++ b/include/charge_manager.h
@@ -300,14 +300,19 @@ int board_set_active_charge_port(int charge_port);
/**
* Set the charge current limit.
*
+ * The default implementation of this function derates charge_ma by
+ * CONFIG_CHARGER_INPUT_CURRENT_PCT (if configured), and clamps charge_ma to
+ * a lower bound of CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT (if configured).
+ *
* @param port PD port.
* @param supplier Identified CHARGE_SUPPLIER_*.
* @param charge_ma Desired charge current limit, <= max_ma.
* @param max_ma Maximum charge current limit, >= charge_ma.
* @param charge_mv Negotiated charge voltage (mV).
*/
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv);
+__override_proto void board_set_charge_limit(int port, int supplier,
+ int charge_ma, int max_ma,
+ int charge_mv);
/**
* Get whether the port is sourcing power on VBUS.
diff --git a/include/charge_state.h b/include/charge_state.h
index 221947b9d1..dcf3430954 100644
--- a/include/charge_state.h
+++ b/include/charge_state.h
@@ -6,8 +6,8 @@
#define __CROS_EC_CHARGE_STATE_H
#include "common.h"
-#include "timer.h"
#include "stdbool.h"
+#include "timer.h"
/* Stuff that's common to all charger implementations can go here. */
@@ -158,18 +158,19 @@ static inline int battery_is_below_threshold(enum batt_threshold_type type,
#endif
/**
- * Return non-zero if the battery level is too low to allow power on, even if
- * a charger is attached.
+ * @brief whether or not the charge state will prevent power-on
*
* @param power_button_pressed True if the power-up attempt is caused by a
* power button press.
+ * @return True if the battery level is too low to allow power on, even if a
+ * charger is attached.
*/
#ifdef CONFIG_BATTERY
-int charge_prevent_power_on(int power_button_pressed);
+bool charge_prevent_power_on(bool power_button_pressed);
#else
-static inline int charge_prevent_power_on(int power_button_pressed)
+static inline bool charge_prevent_power_on(bool power_button_pressed)
{
- return 0;
+ return false;
}
#endif
diff --git a/include/charge_state_v2.h b/include/charge_state_v2.h
index 0817204774..6d0b936f4a 100644
--- a/include/charge_state_v2.h
+++ b/include/charge_state_v2.h
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdbool.h>
-
#include "battery.h"
#include "battery_smart.h"
#include "charger.h"
@@ -13,6 +11,8 @@
#include "ocpc.h"
#include "timer.h"
+#include <stdbool.h>
+
#ifndef __CROS_EC_CHARGE_STATE_V2_H
#define __CROS_EC_CHARGE_STATE_V2_H
@@ -71,6 +71,10 @@ int charge_set_output_current_limit(int chgnum, int ma, int mv);
* Set the charge input current limit. This value is stored and sent every
* time AC is applied.
*
+ * The input current limit is automatically derated by
+ * CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT (if configured), and is clamped to
+ * no less than CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT mA (if configured).
+ *
* @param ma New input current limit in mA
* @param mv Negotiated charge voltage in mV.
* @return EC_SUCCESS or error
diff --git a/include/charger.h b/include/charger.h
index e4c10ec7a9..df3f3f65dd 100644
--- a/include/charger.h
+++ b/include/charger.h
@@ -393,7 +393,7 @@ enum ec_error_list charger_enable_linear_charge(int chgnum, bool enable);
* @param enable: Whether to enable or disable bypass mode.
* @return EC_SUCCESS on success, error otherwise.
*/
-enum ec_error_list charger_enable_bypass_mode(int chgnum, int enable);
+enum ec_error_list charger_enable_bypass_mode(int chgnum, bool enable);
/**
* Get the charger configuration for the number of battery cells
diff --git a/include/chipset.h b/include/chipset.h
index fd7455f9f7..ead2a9680e 100644
--- a/include/chipset.h
+++ b/include/chipset.h
@@ -299,4 +299,20 @@ static inline enum chipset_shutdown_reason chipset_get_shutdown_reason(void)
#endif /* !CONFIG_CMD_AP_RESET_LOG */
+#ifdef TEST_BUILD
+/**
+ * @brief Gets the number of AP resets since the EC booted. Takes the reset log
+ * mutex for thread safety.
+ *
+ * @return uint32_t AP reset count
+ */
+uint32_t test_chipset_get_ap_resets_since_ec_boot(void);
+
+/**
+ * @brief Corrupts the stored reset log checksum, which forces init_reset_log()
+ * to wipe the log and fully reset.
+ */
+void test_chipset_corrupt_reset_log_checksum(void);
+#endif /* TEST_BUILD */
+
#endif /* __CROS_EC_CHIPSET_H */
diff --git a/include/common.h b/include/common.h
index 6f76157b6c..02f7449d81 100644
--- a/include/common.h
+++ b/include/common.h
@@ -8,13 +8,14 @@
#ifndef __CROS_EC_COMMON_H
#define __CROS_EC_COMMON_H
-#include <stdint.h>
-#include <inttypes.h>
-
#include "compile_time_macros.h"
+#include <inttypes.h>
+#include <stdint.h>
+
#ifdef CONFIG_ZEPHYR
#include "fpu.h"
+
#include <zephyr/sys/util.h>
#include <zephyr/toolchain.h>
#ifdef CONFIG_ZTEST
diff --git a/include/config.h b/include/config.h
index f0b528bead..8d78921cde 100644
--- a/include/config.h
+++ b/include/config.h
@@ -221,6 +221,12 @@
/* The threshold duration to change to off_body */
#undef CONFIG_BODY_DETECTION_STATIONARY_DURATION
+/* Send the SCI event to notify host when body status change */
+#undef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE
+
+/* Always enable the body detection function in S0 */
+#undef CONFIG_BODY_DETECTION_ALWAYS_ENABLE_IN_S0
+
/*
* Use the old standard reference frame for accelerometers. The old
* reference frame is:
@@ -1035,7 +1041,38 @@
* this should be set to 512 mA in order to not brown-out low-current USB
* charge ports in accordance with USB-PD r3.0 Sec. 7.3
*/
-#undef CONFIG_CHARGER_INPUT_CURRENT
+#undef CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT
+
+/*
+ * Minimum current limit that will ever be set for chargers, even if a lower
+ * limit is requested. This will allow the charger to draw more power than
+ * the requested limit.
+ *
+ * If set, this should usually be set to no more than 2.5W divided by the
+ * maximum supported input voltage in order to satisfy USB-PD pSnkStdby
+ * requirements. Higher values may help devices stay alive under low-battery
+ * conditions at the cost of violating standby power limits.
+ *
+ * Many boards set this to large values, since historically this number was
+ * usually equal to CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT. New boards should
+ * avoid doing so if possible.
+ */
+#undef CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT
+
+/*
+ * Percentage derating factor applied to charger input current limits.
+ *
+ * Desired charger current is reduced by this many percent when programming
+ * chargers via the charge manager, which is usually used to account for
+ * chargers that draw slightly more current than the programmed limit or to
+ * provide some margin for accuracy. For example, if this value is set to 4
+ * and input current is limited to 1000 mA, the charger will be given a limit
+ * of 960 mA.
+ *
+ * Boards requiring more complex control over input current should leave this
+ * undefined and override board_set_charge_limit instead.
+ */
+#undef CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT
/*
* This config option is used to enable IDCHG trigger for prochot. This macro
@@ -1333,6 +1370,9 @@
*/
#undef CONFIG_OCPC_DEF_RBATT_MOHMS
+/* Set a default OCPC drive limit for legacy boards */
+#define CONFIG_OCPC_DEF_DRIVELIMIT_MILLIVOLTS 10
+
/* Enable trickle charging */
#undef CONFIG_TRICKLE_CHARGING
@@ -3998,9 +4038,6 @@
/* Default stack size to use for tasks, in bytes */
#undef CONFIG_STACK_SIZE
-/* Use 32-bit timer for clock source on stm32. */
-#undef CONFIG_STM_HWTIMER32
-
/* Compile charger detect for STM32 */
#undef CONFIG_STM32_CHARGER_DETECT
@@ -4474,10 +4511,12 @@
* TYPEC_SM - Type-C deals with CC lines voltage level connections
* PRL_SM - Protocol handles flow and chunking TX and RX messages
* PE - Policy Engine handles PD communication flow
+ * DPM - Device Policy Manager layer is used to determine port policy
*/
#define CONFIG_USB_TYPEC_SM
#define CONFIG_USB_PRL_SM
#define CONFIG_USB_PE_SM
+#define CONFIG_USB_DPM_SM
/* Enables PD Console commands */
#define CONFIG_USB_PD_CONSOLE_CMD
@@ -6927,4 +6966,9 @@
#define HAS_GPU_DRIVER
#endif
+/* Default to 1024 for end of ram data (panic and jump data) */
+#ifndef CONFIG_PRESERVED_END_OF_RAM_SIZE
+#define CONFIG_PRESERVED_END_OF_RAM_SIZE 1024
+#endif
+
#endif /* __CROS_EC_CONFIG_H */
diff --git a/include/console.h b/include/console.h
index ddfba89926..03abbe5732 100644
--- a/include/console.h
+++ b/include/console.h
@@ -10,6 +10,7 @@
#include "common.h"
#include "config.h"
+
#include <stdbool.h>
#ifdef CONFIG_ZEPHYR
diff --git a/include/crc8.h b/include/crc8.h
index c20314311e..ca1a98eb43 100644
--- a/include/crc8.h
+++ b/include/crc8.h
@@ -7,6 +7,8 @@
#ifndef __CROS_EC_CRC8_H
#define __CROS_EC_CRC8_H
+#include <stdint.h>
+
/**
* crc8
* Return CRC-8 of the data, using x^8 + x^2 + x + 1 polynomial. A table-based
diff --git a/include/dps.h b/include/dps.h
index 8794220ab2..c4d2c884b1 100644
--- a/include/dps.h
+++ b/include/dps.h
@@ -6,10 +6,10 @@
#ifndef __CROS_EC_DPS__H
#define __CROS_EC_DPS__H
-#include <stdbool.h>
-
#include "common.h"
+#include <stdbool.h>
+
#define DPS_FLAG_DISABLED BIT(0)
#define DPS_FLAG_NO_SRCCAP BIT(1)
#define DPS_FLAG_WAITING BIT(2)
diff --git a/include/driver/accel_lis2dw12_public.h b/include/driver/accel_lis2dw12_public.h
index 5596e6ba6a..163bc8ae21 100644
--- a/include/driver/accel_lis2dw12_public.h
+++ b/include/driver/accel_lis2dw12_public.h
@@ -8,6 +8,7 @@
#ifndef __CROS_EC_DRIVER_ACCEL_LIS2DW12_PUBLIC_H
#define __CROS_EC_DRIVER_ACCEL_LIS2DW12_PUBLIC_H
+#include "config.h"
#include "gpio_signal.h"
extern const struct accelgyro_drv lis2dw12_drv;
diff --git a/include/driver/accelgyro_bmi260.h b/include/driver/accelgyro_bmi260.h
index 5d55a85acc..baf78e9e00 100644
--- a/include/driver/accelgyro_bmi260.h
+++ b/include/driver/accelgyro_bmi260.h
@@ -10,8 +10,8 @@
#include "accelgyro.h"
#include "common.h"
-#include "mag_bmm150.h"
#include "driver/accelgyro_bmi260_public.h"
+#include "mag_bmm150.h"
#define BMI260_CHIP_ID 0x00
/* BMI260 chip identifier */
diff --git a/include/driver/accelgyro_bmi_common.h b/include/driver/accelgyro_bmi_common.h
index 371d3d97ce..01a9ecffd6 100644
--- a/include/driver/accelgyro_bmi_common.h
+++ b/include/driver/accelgyro_bmi_common.h
@@ -10,8 +10,8 @@
#include "accelgyro.h"
#include "accelgyro_bmi160.h"
#include "accelgyro_bmi260.h"
-#include "mag_bmm150.h"
#include "accelgyro_bmi_common_public.h"
+#include "mag_bmm150.h"
#if !defined(CONFIG_ACCELGYRO_BMI_COMM_SPI) && \
!defined(CONFIG_ACCELGYRO_BMI_COMM_I2C)
diff --git a/include/driver/retimer/anx7483_public.h b/include/driver/retimer/anx7483_public.h
index 83ad32508e..4f44c4d180 100644
--- a/include/driver/retimer/anx7483_public.h
+++ b/include/driver/retimer/anx7483_public.h
@@ -38,6 +38,14 @@ enum anx7483_eq_setting {
ANX7483_EQ_SETTING_12_5DB = 15,
};
+/* Flat gain tuning */
+enum anx7483_fg_setting {
+ ANX7483_FG_SETTING_NEG_1_5DB = 0,
+ ANX7483_FG_SETTING_0_5DB = 1,
+ ANX7483_FG_SETTING_0_3DB = 2,
+ ANX7483_FG_SETTING_1_2DB = 3,
+};
+
enum anx7483_tune_pin {
ANX7483_PIN_UTX1,
ANX7483_PIN_UTX2,
@@ -52,6 +60,11 @@ enum ec_error_list anx7483_set_eq(const struct usb_mux *me,
enum anx7483_tune_pin pin,
enum anx7483_eq_setting eq);
+/* Adjust the flat gain for a pin */
+enum ec_error_list anx7483_set_fg(const struct usb_mux *me,
+ enum anx7483_tune_pin pin,
+ enum anx7483_fg_setting fg);
+
/*
* Configure datasheet defaults for tuning registers at this mux setting.
* Return int so function can be used directly for board_set.
diff --git a/include/driver/retimer/bb_retimer.h b/include/driver/retimer/bb_retimer.h
index 460156803e..b47743f882 100644
--- a/include/driver/retimer/bb_retimer.h
+++ b/include/driver/retimer/bb_retimer.h
@@ -8,8 +8,8 @@
#ifndef __CROS_EC_BB_RETIMER_H
#define __CROS_EC_BB_RETIMER_H
-#include "usb_mux.h"
#include "driver/retimer/bb_retimer_public.h"
+#include "usb_mux.h"
/* Burnside Bridge I2C Configuration Space */
#define BB_RETIMER_REG_VENDOR_ID 0
diff --git a/include/driver/retimer/ps8818_public.h b/include/driver/retimer/ps8818_public.h
index 3f0aba963b..bdecb7a0d4 100644
--- a/include/driver/retimer/ps8818_public.h
+++ b/include/driver/retimer/ps8818_public.h
@@ -9,7 +9,10 @@
#ifndef __CROS_EC_USB_RETIMER_PS8818_H
#define __CROS_EC_USB_RETIMER_PS8818_H
-#define PS8818_I2C_ADDR_FLAGS 0x28
+#define PS8818_I2C_ADDR0_FLAGS 0x28
+#define PS8818_I2C_ADDR1_FLAGS 0x30
+#define PS8818_I2C_ADDR2_FLAGS 0x58
+#define PS8818_I2C_ADDR3_FLAGS 0x70
/*
* PAGE 0 Register Definitions
diff --git a/include/driver/temp_sensor/pct2075.h b/include/driver/temp_sensor/pct2075.h
index e79ac0e97a..2d374bb2ba 100644
--- a/include/driver/temp_sensor/pct2075.h
+++ b/include/driver/temp_sensor/pct2075.h
@@ -21,6 +21,7 @@
#define PCT2075_REG_CONF 0x01
#define PCT2075_REG_THYST 0x02
#define PCT2075_REG_TOS 0x03
+#define PCT2075_REG_TIDLE 0x04
/*
* I2C port and address information for all the board PCT2075 sensors should be
@@ -67,4 +68,8 @@ int pct2075_get_val_mk(int idx, int *temp_mk_ptr);
*/
void pct2075_init(void);
+#ifdef CONFIG_ZEPHYR
+void pct2075_update_temperature(int idx);
+#endif /* CONFIG_ZEPHYR */
+
#endif /* __CROS_EC_PCT2075_H */
diff --git a/include/driver/temp_sensor/thermistor.h b/include/driver/temp_sensor/thermistor.h
index 46b7763747..3e220b2505 100644
--- a/include/driver/temp_sensor/thermistor.h
+++ b/include/driver/temp_sensor/thermistor.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_TEMP_SENSOR_THERMISTOR_H
#define __CROS_EC_TEMP_SENSOR_THERMISTOR_H
+#include <stdint.h>
+
struct thermistor_data_pair {
uint8_t mv; /* Scaled voltage level at ADC (in mV) */
uint8_t temp; /* Temperature in Celsius */
diff --git a/include/driver/temp_sensor/tmp112.h b/include/driver/temp_sensor/tmp112.h
index 56d55d9133..3c9a0a004b 100644
--- a/include/driver/temp_sensor/tmp112.h
+++ b/include/driver/temp_sensor/tmp112.h
@@ -63,4 +63,8 @@ int tmp112_get_val_mk(int idx, int *temp_mk_ptr);
*/
void tmp112_init(void);
+#ifdef CONFIG_ZEPHYR
+void tmp112_update_temperature(int idx);
+#endif /* CONFIG_ZEPHYR */
+
#endif /* __CROS_EC_TMP112_H */
diff --git a/include/ec_commands.h b/include/ec_commands.h
index 892787e4dc..6c30528d44 100644
--- a/include/ec_commands.h
+++ b/include/ec_commands.h
@@ -416,6 +416,7 @@ extern "C" {
/*
* Report device orientation
* Bits Definition
+ * 4 Off Body/On Body status: 0 = Off Body.
* 3:1 Device DPTF Profile Number (DDPN)
* 0 = Reserved for backward compatibility (indicates no valid
* profile number. Host should fall back to using TBMD).
@@ -428,6 +429,8 @@ extern "C" {
#define EC_ACPI_MEM_TBMD_MASK 0x1
#define EC_ACPI_MEM_DDPN_SHIFT 1
#define EC_ACPI_MEM_DDPN_MASK 0x7
+#define EC_ACPI_MEM_STTB_SHIFT 4
+#define EC_ACPI_MEM_STTB_MASK 0x1
/*
* Report device features. Uses the same format as the host command, except:
@@ -752,6 +755,7 @@ enum host_event_code {
*
* - TABLET/LAPTOP mode
* - detachable base attach/detach event
+ * - on body/off body transition event
*/
EC_HOST_EVENT_MODE_CHANGE = 29,
@@ -1731,6 +1735,9 @@ struct ec_params_flash_read {
* struct ec_params_flash_write - Parameters for the flash write command.
* @offset: Byte offset to write.
* @size: Size to write in bytes.
+ * @data: Data to write.
+ * @data.words32: uint32_t data to write.
+ * @data.bytes: uint8_t data to write.
*/
struct ec_params_flash_write {
uint32_t offset;
@@ -2833,8 +2840,8 @@ struct ec_motion_sense_activity {
uint8_t activity; /* one of enum motionsensor_activity */
uint8_t enable; /* 1: enable, 0: disable */
uint8_t reserved;
- uint16_t parameters[3]; /* activity dependent parameters */
-} __ec_todo_unpacked;
+ uint16_t parameters[4]; /* activity dependent parameters */
+} __ec_todo_packed;
/* Module flag masks used for the dump sub-command. */
#define MOTIONSENSE_MODULE_FLAG_ACTIVE BIT(0)
@@ -3303,6 +3310,22 @@ struct ec_params_usb_charge_set_mode {
} __ec_align1;
/*****************************************************************************/
+/* Tablet mode commands */
+
+/* Set tablet mode */
+#define EC_CMD_SET_TABLET_MODE 0x0031
+
+enum tablet_mode_override {
+ TABLET_MODE_DEFAULT,
+ TABLET_MODE_FORCE_TABLET,
+ TABLET_MODE_FORCE_CLAMSHELL,
+};
+
+struct ec_params_set_tablet_mode {
+ uint8_t tablet_mode; /* enum tablet_mode_override */
+} __ec_align1;
+
+/*****************************************************************************/
/* Persistent storage for host */
/* Maximum bytes that can be read/written in a single command */
@@ -6716,6 +6739,7 @@ struct ec_response_regulator_get_voltage {
enum typec_partner_type {
TYPEC_PARTNER_SOP = 0,
TYPEC_PARTNER_SOP_PRIME = 1,
+ TYPEC_PARTNER_SOP_PRIME_PRIME = 2,
};
struct ec_params_typec_discovery {
@@ -6747,6 +6771,7 @@ enum typec_control_command {
TYPEC_CONTROL_COMMAND_TBT_UFP_REPLY,
TYPEC_CONTROL_COMMAND_USB_MUX_SET,
TYPEC_CONTROL_COMMAND_BIST_SHARE_MODE,
+ TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
};
/* Modes (USB or alternate) that a type-C port may enter. */
@@ -6772,6 +6797,17 @@ struct typec_usb_mux_set {
uint8_t mux_flags;
} __ec_align1;
+#define VDO_MAX_SIZE 7
+
+struct typec_vdm_req {
+ /* VDM data, including VDM header */
+ uint32_t vdm_data[VDO_MAX_SIZE];
+ /* Number of 32-bit fields filled in */
+ uint8_t vdm_data_objects;
+ /* Partner to address - see enum typec_partner_type */
+ uint8_t partner_type;
+} __ec_align1;
+
struct ec_params_typec_control {
uint8_t port;
uint8_t command; /* enum typec_control_command */
@@ -6793,6 +6829,8 @@ struct ec_params_typec_control {
struct typec_usb_mux_set mux_params;
/* Used for BIST_SHARE_MODE */
uint8_t bist_share_mode;
+ /* Used for VMD_REQ */
+ struct typec_vdm_req vdm_req_params;
uint8_t placeholder[128];
};
} __ec_align1;
diff --git a/include/ec_ec_comm_client.h b/include/ec_ec_comm_client.h
index 9b506dd402..57c599a365 100644
--- a/include/ec_ec_comm_client.h
+++ b/include/ec_ec_comm_client.h
@@ -8,9 +8,10 @@
#ifndef EC_EC_COMM_CLIENT_H_
#define EC_EC_COMM_CLIENT_H_
-#include <stdint.h>
#include "config.h"
+#include <stdint.h>
+
/**
* Sends EC_CMD_BATTERY_GET_DYNAMIC command to server, and writes the
* battery dynamic information into battery_dynamic[BATT_IDX_BASE].
diff --git a/include/ec_ec_comm_server.h b/include/ec_ec_comm_server.h
index 0eb094fea3..9728e021a8 100644
--- a/include/ec_ec_comm_server.h
+++ b/include/ec_ec_comm_server.h
@@ -8,10 +8,11 @@
#ifndef EC_EC_COMM_SERVER_H_
#define EC_EC_COMM_SERVER_H_
-#include <stdint.h>
#include "consumer.h"
#include "queue.h"
+#include <stdint.h>
+
extern struct queue const ec_ec_comm_server_input;
extern struct queue const ec_ec_comm_server_output;
diff --git a/include/event_log.h b/include/event_log.h
index bd3b88510b..5438a34414 100644
--- a/include/event_log.h
+++ b/include/event_log.h
@@ -6,6 +6,8 @@
#ifndef __CROS_EC_EVENT_LOG_H
#define __CROS_EC_EVENT_LOG_H
+#include <stdint.h>
+
struct event_log_entry {
uint32_t timestamp; /* relative timestamp in milliseconds */
uint8_t type; /* event type, caller-defined */
diff --git a/include/fan.h b/include/fan.h
index 31af7a58ff..7c64f4e31b 100644
--- a/include/fan.h
+++ b/include/fan.h
@@ -8,6 +8,10 @@
#ifndef __CROS_EC_FAN_H
#define __CROS_EC_FAN_H
+#include "config.h"
+
+#include <stdint.h>
+
#ifdef CONFIG_ZEPHYR
#ifdef CONFIG_PLATFORM_EC_FAN
@@ -40,6 +44,7 @@ struct fan_rpm {
int rpm_min;
int rpm_start;
int rpm_max;
+ uint8_t rpm_deviation;
};
/* Characteristic of each physical fan */
diff --git a/include/flash_log.h b/include/flash_log.h
index 7141a8b67a..36e3be6738 100644
--- a/include/flash_log.h
+++ b/include/flash_log.h
@@ -6,9 +6,9 @@
#ifndef __CROS_EC_EVENT_LOG_H
#define __CROS_EC_EVENT_LOG_H
-#include "config.h"
#include "common.h"
#include "compile_time_macros.h"
+#include "config.h"
#include "stddef.h"
enum flash_event_type {
diff --git a/include/fpsensor.h b/include/fpsensor.h
index 3963df86a7..a59eea1b89 100644
--- a/include/fpsensor.h
+++ b/include/fpsensor.h
@@ -8,10 +8,11 @@
#ifndef __CROS_EC_FPSENSOR_H
#define __CROS_EC_FPSENSOR_H
-#include <stdint.h>
#include "common.h"
#include "ec_commands.h"
+#include <stdint.h>
+
#ifndef SPI_FP_DEVICE
#define SPI_FP_DEVICE (&spi_devices[0])
#endif
diff --git a/include/fpsensor_crypto.h b/include/fpsensor_crypto.h
index 7dff9238fa..f000b841e4 100644
--- a/include/fpsensor_crypto.h
+++ b/include/fpsensor_crypto.h
@@ -8,10 +8,10 @@
#ifndef __CROS_EC_FPSENSOR_CRYPTO_H
#define __CROS_EC_FPSENSOR_CRYPTO_H
-#include <stddef.h>
-
#include "sha256.h"
+#include <stddef.h>
+
#define HKDF_MAX_INFO_SIZE 128
#define HKDF_SHA256_MAX_BLOCK_COUNT 255
diff --git a/include/fpsensor_state.h b/include/fpsensor_state.h
index ce454233fa..d8f112afcd 100644
--- a/include/fpsensor_state.h
+++ b/include/fpsensor_state.h
@@ -8,16 +8,15 @@
#ifndef __CROS_EC_FPSENSOR_STATE_H
#define __CROS_EC_FPSENSOR_STATE_H
-#include <stdbool.h>
-#include <stdint.h>
-
#include "atomic.h"
#include "common.h"
+#include "driver/fingerprint/fpsensor.h"
#include "ec_commands.h"
#include "link_defs.h"
#include "timer.h"
-#include "driver/fingerprint/fpsensor.h"
+#include <stdbool.h>
+#include <stdint.h>
/* if no special memory regions are defined, fallback on regular SRAM */
#ifndef FP_FRAME_SECTION
diff --git a/include/gpio.h b/include/gpio.h
index 54464d1bfb..086ed9131f 100644
--- a/include/gpio.h
+++ b/include/gpio.h
@@ -21,6 +21,10 @@
*/
#ifdef CONFIG_ZEPHYR
#include <zephyr/drivers/gpio.h>
+#include <zephyr/dt-bindings/gpio/ite-it8xxx2-gpio.h>
+#include <zephyr/dt-bindings/gpio/nuvoton-npcx-gpio.h>
+
+#include <dt-bindings/native-posix-gpio.h>
/*
* Some flag definitions are duplicated by our private devicetree binding
@@ -79,7 +83,16 @@
/* GPIO_INT_DSLEEP not supported by Zephyr */
/* GPIO_INT_SHARED not supported by Zephyr */
+#if DT_HAS_COMPAT_STATUS_OKAY(nuvoton_npcx_gpio)
+#define GPIO_VOLTAGE_1P8 NPCX_GPIO_VOLTAGE_1P8
+#define GPIO_SEL_1P8V GPIO_VOLTAGE_1P8
+#elif DT_HAS_COMPAT_STATUS_OKAY(ite_it8xxx2_gpio)
+#define GPIO_VOLTAGE_1P8 IT8XXX2_GPIO_VOLTAGE_1P8
#define GPIO_SEL_1P8V GPIO_VOLTAGE_1P8
+#elif DT_HAS_COMPAT_STATUS_OKAY(zephyr_gpio_emul)
+#define GPIO_VOLTAGE_1P8 NATIVE_POSIX_GPIO_VOLTAGE_1P8
+#define GPIO_SEL_1P8V GPIO_VOLTAGE_1P8
+#endif
/* GPIO_ALTERNATE not supported by Zephyr */
/* GPIO_LOCKED not supported by Zephyr */
/* GPIO_HIB_WAKE_HIGH not supported by Zephyr */
diff --git a/include/gpio_list.h b/include/gpio_list.h
index 17fc0d3b09..e5a90b4e89 100644
--- a/include/gpio_list.h
+++ b/include/gpio_list.h
@@ -67,9 +67,9 @@ const int gpio_ih_count = ARRAY_SIZE(gpio_irq_handlers);
#define PIN(a, b...) \
static const int _pin_##a##_##b \
__attribute__((unused, section(".unused"))) = __LINE__;
-#include "gpio.wrap"
-
#include "ioexpander.h"
+
+#include "gpio.wrap"
#define IOEX_EXPIN(ioex, port, index) (ioex), (port), BIT(index)
/*
diff --git a/include/host_command.h b/include/host_command.h
index 59389107c7..7efd54e297 100644
--- a/include/host_command.h
+++ b/include/host_command.h
@@ -8,8 +8,8 @@
#ifndef __CROS_EC_HOST_COMMAND_H
#define __CROS_EC_HOST_COMMAND_H
-#include "compiler.h"
#include "common.h"
+#include "compiler.h"
#include "ec_commands.h"
#ifdef __cplusplus
diff --git a/include/hwtimer.h b/include/hwtimer.h
index 093a44cad1..9058563e7a 100644
--- a/include/hwtimer.h
+++ b/include/hwtimer.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_HWTIMER_H
#define __CROS_EC_HWTIMER_H
+#include <stdint.h>
+
/**
* Programs when the next timer should fire an interrupt.
*
diff --git a/include/i2c_bitbang.h b/include/i2c_bitbang.h
index 9c7c730518..c9b0587410 100644
--- a/include/i2c_bitbang.h
+++ b/include/i2c_bitbang.h
@@ -5,10 +5,10 @@
#ifndef __CROS_EC_I2C_BITBANG_H
#define __CROS_EC_I2C_BITBANG_H
-#include <stdbool.h>
-
#include "i2c.h"
+#include <stdbool.h>
+
extern const struct i2c_drv bitbang_drv;
extern const struct i2c_port_t i2c_bitbang_ports[];
diff --git a/include/keyboard_8042.h b/include/keyboard_8042.h
index 34c98c2a38..bd56106f1d 100644
--- a/include/keyboard_8042.h
+++ b/include/keyboard_8042.h
@@ -8,8 +8,8 @@
#ifndef __CROS_EC_KEYBOARD_8042_H
#define __CROS_EC_KEYBOARD_8042_H
-#include "common.h"
#include "button.h"
+#include "common.h"
/**
* Called by power button handler and button interrupt handler.
diff --git a/include/keyboard_8042_sharedlib.h b/include/keyboard_8042_sharedlib.h
index bd7a7b5ec7..2f8dfdc242 100644
--- a/include/keyboard_8042_sharedlib.h
+++ b/include/keyboard_8042_sharedlib.h
@@ -8,12 +8,12 @@
#ifndef __CROS_EC_KEYBOARD_8042_SHAREDLIB_H
#define __CROS_EC_KEYBOARD_8042_SHAREDLIB_H
-#include <stddef.h>
-
#include "button.h"
#include "keyboard_config.h"
#include "keyboard_protocol.h"
+#include <stddef.h>
+
struct button_8042_t {
uint16_t scancode;
int repeat;
diff --git a/include/keyboard_backlight.h b/include/keyboard_backlight.h
index cf68805235..929dbfa90e 100644
--- a/include/keyboard_backlight.h
+++ b/include/keyboard_backlight.h
@@ -32,12 +32,6 @@ struct kblight_drv {
int (*set)(int percent);
/**
- * Get the current brightness
- * @return Brightness in percentage
- */
- int (*get)(void);
-
- /**
* Enable or disable keyboard backlight
* @param enable: 1=Enable, 0=Disable.
* @return EC_SUCCESS or EC_ERROR_*
diff --git a/include/keyboard_protocol.h b/include/keyboard_protocol.h
index 7b9006fcc0..8f10c7bd0e 100644
--- a/include/keyboard_protocol.h
+++ b/include/keyboard_protocol.h
@@ -8,8 +8,8 @@
#ifndef __CROS_EC_KEYBOARD_PROTOCOL_H
#define __CROS_EC_KEYBOARD_PROTOCOL_H
-#include "common.h"
#include "button.h"
+#include "common.h"
/* Routines common to all protocols */
diff --git a/include/keyboard_raw.h b/include/keyboard_raw.h
index dca7b3c79a..350791998f 100644
--- a/include/keyboard_raw.h
+++ b/include/keyboard_raw.h
@@ -16,6 +16,8 @@
#include "gpio_signal.h"
#include "keyboard_config.h"
+#include <stdbool.h>
+
/* Column values for keyboard_raw_drive_column() */
enum keyboard_column_index {
KEYBOARD_COLUMN_ALL = -2, /* Drive all columns */
@@ -62,6 +64,14 @@ int keyboard_raw_read_rows(void);
*/
void keyboard_raw_enable_interrupt(int enable);
+/**
+ * Enable or disable keyboard alternative function.
+ *
+ * @param enable 1 enable KSI/KSO alternative function,
+ * 0 set all KSI/KSO pins to normal GPIO.
+ */
+void keybaord_raw_config_alt(bool enable);
+
#ifdef HAS_TASK_KEYSCAN
/**
diff --git a/include/mag_cal.h b/include/mag_cal.h
index 66281bba4e..82453c5235 100644
--- a/include/mag_cal.h
+++ b/include/mag_cal.h
@@ -8,10 +8,10 @@
#ifndef __CROS_EC_MAG_CAL_H
#define __CROS_EC_MAG_CAL_H
-#include "math_util.h"
+#include "kasa.h"
#include "mat44.h"
+#include "math_util.h"
#include "vec4.h"
-#include "kasa.h"
#define MAG_CAL_MAX_SAMPLES 0xffff
#define MAG_CAL_MIN_BATCH_WINDOW_US (2 * SECOND)
diff --git a/include/math_util.h b/include/math_util.h
index 51065d2bce..6b4b8cb3e5 100644
--- a/include/math_util.h
+++ b/include/math_util.h
@@ -8,9 +8,11 @@
#ifndef __CROS_EC_MATH_UTIL_H
#define __CROS_EC_MATH_UTIL_H
-#include <stdint.h>
+#include "config.h"
#include "limits.h"
+#include <stdint.h>
+
#ifdef CONFIG_FPU
typedef float fp_t;
typedef float fp_inter_t;
diff --git a/include/mock/fpsensor_state_mock.h b/include/mock/fpsensor_state_mock.h
index 32450e3cc0..c683ba5deb 100644
--- a/include/mock/fpsensor_state_mock.h
+++ b/include/mock/fpsensor_state_mock.h
@@ -6,12 +6,12 @@
#ifndef __MOCK_FPSENSOR_STATE_MOCK_H
#define __MOCK_FPSENSOR_STATE_MOCK_H
-#include <stdbool.h>
-#include <stdint.h>
-
#include "driver/fingerprint/fpsensor.h"
#include "ec_commands.h"
+#include <stdbool.h>
+#include <stdint.h>
+
extern const uint8_t default_fake_tpm_seed[FP_CONTEXT_TPM_BYTES];
extern const uint8_t
default_fake_fp_positive_match_salt[FP_MAX_FINGER_COUNT]
diff --git a/include/mock/tcpc_mock.h b/include/mock/tcpc_mock.h
index 2f3a78c69a..fef45b492b 100644
--- a/include/mock/tcpc_mock.h
+++ b/include/mock/tcpc_mock.h
@@ -4,8 +4,8 @@
*/
/* Mock for the TCPC interface */
-#include "usb_pd_tcpm.h"
#include "usb_pd.h"
+#include "usb_pd_tcpm.h"
/* Controller for TCPC state */
struct mock_tcpc_ctrl {
diff --git a/include/mock/usb_pd_dpm_mock.h b/include/mock/usb_pd_dpm_mock.h
index 8f91cfb390..266cad4aef 100644
--- a/include/mock/usb_pd_dpm_mock.h
+++ b/include/mock/usb_pd_dpm_mock.h
@@ -8,7 +8,7 @@
#define __MOCK_USB_PD_DPM_MOCK_H
#include "common.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
/* Defaults should all be 0 values. */
struct mock_dpm_port_t {
diff --git a/include/mock/usb_pe_sm_mock.h b/include/mock/usb_pe_sm_mock.h
index 819f086c5a..778e7943c4 100644
--- a/include/mock/usb_pe_sm_mock.h
+++ b/include/mock/usb_pe_sm_mock.h
@@ -8,8 +8,8 @@
#define __MOCK_USB_PE_SM_MOCK_H
#include "common.h"
-#include "usb_pe_sm.h"
#include "usb_pd_tcpm.h"
+#include "usb_pe_sm.h"
struct mock_pe_port_t {
enum tcpci_msg_type sop;
diff --git a/include/mock/usb_prl_mock.h b/include/mock/usb_prl_mock.h
index eef1d8de63..7758700d3a 100644
--- a/include/mock/usb_prl_mock.h
+++ b/include/mock/usb_prl_mock.h
@@ -9,7 +9,9 @@
#include "common.h"
#include "usb_emsg.h"
+#include "usb_pd.h"
#include "usb_pd_tcpm.h"
+#include "usb_pe_sm.h"
void mock_prl_reset(void);
diff --git a/include/mock/usb_tc_sm_mock.h b/include/mock/usb_tc_sm_mock.h
index 532f2bfb54..2dc09ade8b 100644
--- a/include/mock/usb_tc_sm_mock.h
+++ b/include/mock/usb_tc_sm_mock.h
@@ -8,9 +8,9 @@
#define __MOCK_USB_TC_SM_MOCK_H
#include "common.h"
-#include "usb_tc_sm.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
+#include "usb_tc_sm.h"
struct mock_tc_port_t {
int rev;
diff --git a/include/motion_sense.h b/include/motion_sense.h
index 6033d52ff9..ac074055aa 100644
--- a/include/motion_sense.h
+++ b/include/motion_sense.h
@@ -283,6 +283,12 @@ int sensor_init_done(struct motion_sensor_t *sensor);
void sensor_board_proc_double_tap(void);
/**
+ * Board specific function to double check lid angle calculation is possible.
+ *
+ */
+int sensor_board_is_lid_angle_available(void);
+
+/**
* Commit the data in a sensor's raw_xyz vector. This operation might have
* different meanings depending on the CONFIG_ACCEL_FIFO flag.
*
@@ -354,4 +360,8 @@ ec_motion_sensor_fill_values(struct ec_response_motion_sensor_data *dst,
dst->data[2] = v[2];
}
+#ifdef CONFIG_ZTEST
+enum sensor_config motion_sense_get_ec_config(void);
+#endif
+
#endif /* __CROS_EC_MOTION_SENSE_H */
diff --git a/include/newton_fit.h b/include/newton_fit.h
index 2fb1994083..dc0a8ffe6e 100644
--- a/include/newton_fit.h
+++ b/include/newton_fit.h
@@ -9,8 +9,8 @@
#define __CROS_EC_NEWTON_FIT_H
#include "queue.h"
-#include "vec3.h"
#include "stdbool.h"
+#include "vec3.h"
struct newton_fit_orientation {
/** An orientations. */
diff --git a/include/ocpc.h b/include/ocpc.h
index da1c6907d4..20ec35c797 100644
--- a/include/ocpc.h
+++ b/include/ocpc.h
@@ -42,15 +42,16 @@ struct ocpc_data {
/** Set the VSYS target for the secondary charger IC.
*
- * @param curr: Pointer to desired_input_current
+ * @param desired_charger_input_current: Pointer to desired_input_current
* @param ocpc: Pointer to OCPC data
- * @param voltage_mv: The desired voltage
- * @param current_ma: The desired current
+ * @param desired_batt_current_ma: The desired voltage
+ * @param desired_batt_voltage_mv: The desired current
* @return EC_SUCCESS on success, error otherwise.
*/
-int ocpc_config_secondary_charger(int *desired_input_current,
- struct ocpc_data *ocpc, int voltage_mv,
- int current_ma);
+int ocpc_config_secondary_charger(int *desired_charger_input_current,
+ struct ocpc_data *ocpc,
+ int desired_batt_voltage_mv,
+ int desired_batt_current_ma);
/** Get the runtime data from the various ADCs.
*
@@ -59,8 +60,8 @@ int ocpc_config_secondary_charger(int *desired_input_current,
void ocpc_get_adcs(struct ocpc_data *ocpc);
/* Set the PID constants for the charging loop */
-__overridable void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki,
- int *ki_div, int *kd, int *kd_div);
+__override_proto void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki,
+ int *ki_div, int *kd, int *kd_div);
/*
** Set up some initial values for the OCPC data structure. This will call off
diff --git a/include/panic.h b/include/panic.h
index 8eda475f2a..25829017ea 100644
--- a/include/panic.h
+++ b/include/panic.h
@@ -9,12 +9,13 @@
#ifndef __CROS_EC_PANIC_H
#define __CROS_EC_PANIC_H
+#include "common.h"
+#include "software_panic.h"
+
#include <stdarg.h>
#include <stdint.h>
-#include <stdnoreturn.h>
-#include "common.h"
-#include "software_panic.h"
+#include <stdnoreturn.h>
#ifdef __cplusplus
extern "C" {
diff --git a/include/printf.h b/include/printf.h
index f797ca593e..a06d8e1c7b 100644
--- a/include/printf.h
+++ b/include/printf.h
@@ -8,12 +8,13 @@
#ifndef __CROS_EC_PRINTF_H
#define __CROS_EC_PRINTF_H
+#include "common.h"
+#include "console.h"
+
#include <stdarg.h> /* For va_list */
#include <stdbool.h>
#include <stddef.h> /* For size_t */
-#include "console.h"
#include <stdio.h>
-#include "common.h"
/**
* Buffer size in bytes large enough to hold the largest possible timestamp.
diff --git a/include/pwm.h b/include/pwm.h
index 48963d9d3c..b56f9f8c1a 100644
--- a/include/pwm.h
+++ b/include/pwm.h
@@ -6,10 +6,10 @@
#ifndef __CROS_EC_PWM_H
#define __CROS_EC_PWM_H
-#include <inttypes.h>
-
#include "util.h"
+#include <inttypes.h>
+
#define PWM_RAW_TO_PERCENT(v) DIV_ROUND_NEAREST((uint32_t)(v)*100, UINT16_MAX)
#define PWM_PERCENT_TO_RAW(v) ((uint32_t)(v)*UINT16_MAX / 100)
diff --git a/include/queue_policies.h b/include/queue_policies.h
index aceb477ef6..eb80d3673b 100644
--- a/include/queue_policies.h
+++ b/include/queue_policies.h
@@ -7,9 +7,9 @@
#ifndef __CROS_EC_QUEUE_POLICIES_H
#define __CROS_EC_QUEUE_POLICIES_H
-#include "queue.h"
#include "consumer.h"
#include "producer.h"
+#include "queue.h"
/*
* The direct notification policy manages a 1-to-1 producer consumer model.
diff --git a/include/rgb_keyboard.h b/include/rgb_keyboard.h
index 56a3e09a91..8c16f6f7e8 100644
--- a/include/rgb_keyboard.h
+++ b/include/rgb_keyboard.h
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <stdbool.h>
-
#include "common.h"
#include "ec_commands.h"
#include "stddef.h"
+#include <stdbool.h>
+
/* Use this instead of '3' for readability where applicable. */
#define SIZE_OF_RGB sizeof(struct rgb_s)
diff --git a/include/rma_auth.h b/include/rma_auth.h
index 2ad9299fed..0b02a1bdc6 100644
--- a/include/rma_auth.h
+++ b/include/rma_auth.h
@@ -8,10 +8,10 @@
#ifndef __CROS_EC_RMA_AUTH_H
#define __CROS_EC_RMA_AUTH_H
-#include <stdint.h>
-
#include "common.h" /* For __packed. */
+#include <stdint.h>
+
/* Current challenge protocol version */
#define RMA_CHALLENGE_VERSION 0
diff --git a/include/shared_mem.h b/include/shared_mem.h
index 307ce9f5e5..482d3a6dec 100644
--- a/include/shared_mem.h
+++ b/include/shared_mem.h
@@ -18,6 +18,7 @@
#define __CROS_EC_SHARED_MEM_H
#include "common.h"
+
#include <stddef.h>
/**
diff --git a/include/stillness_detector.h b/include/stillness_detector.h
index 79de2de79f..67269c6db4 100644
--- a/include/stillness_detector.h
+++ b/include/stillness_detector.h
@@ -9,6 +9,7 @@
#include "common.h"
#include "math_util.h"
#include "stdbool.h"
+
#include <stdint.h>
struct still_det {
diff --git a/include/sysjump.h b/include/sysjump.h
index 7d86df2e61..b7779b9c86 100644
--- a/include/sysjump.h
+++ b/include/sysjump.h
@@ -21,6 +21,16 @@
#define JUMP_DATA_SIZE_V1 12 /* Size of version 1 jump data struct */
#define JUMP_DATA_SIZE_V2 16 /* Size of version 2 jump data struct */
+#define JUMP_TAG_MAX_SIZE 255
+
+#if !defined(CONFIG_RAM_SIZE) || !(CONFIG_RAM_SIZE > 0)
+/* Disable check by setting jump data min address to zero */
+#define JUMP_DATA_MIN_ADDRESS 0
+#else
+#define JUMP_DATA_MIN_ADDRESS \
+ (CONFIG_RAM_BASE + CONFIG_RAM_SIZE - CONFIG_PRESERVED_END_OF_RAM_SIZE)
+#endif
+
struct jump_data {
/*
* Add new fields to the _start_ of the struct, since we copy it to the
diff --git a/include/system.h b/include/system.h
index ed811e9626..c7884199e1 100644
--- a/include/system.h
+++ b/include/system.h
@@ -8,8 +8,6 @@
#ifndef __CROS_EC_SYSTEM_H
#define __CROS_EC_SYSTEM_H
-#include <stdnoreturn.h>
-
#include "atomic.h"
#include "common.h"
#include "compile_time_macros.h"
@@ -17,6 +15,8 @@
#include "ec_commands.h"
#include "timer.h"
+#include <stdnoreturn.h>
+
#ifdef CONFIG_ZEPHYR
#ifdef CONFIG_CPU_CORTEX_M
/*
@@ -214,7 +214,7 @@ int system_jumped_late(void);
* This may ONLY be called from within a HOOK_SYSJUMP handler.
*
* @param tag Data type
- * @param size Size of data; must be less than 255 bytes.
+ * @param size Size of data; must be less than JUMP_TAG_MAX_SIZE bytes.
* @param version Data version, so that tag data can evolve as firmware
* is updated.
* @param data Pointer to data to save
diff --git a/include/task.h b/include/task.h
index bc7314169e..a527ca695a 100644
--- a/include/task.h
+++ b/include/task.h
@@ -15,9 +15,10 @@ extern "C" {
#include "atomic_t.h"
#include "common.h"
#include "compile_time_macros.h"
-#include <stdbool.h>
#include "task_id.h"
+#include <stdbool.h>
+
/* Task event bitmasks */
/* Tasks may use the bits in TASK_EVENT_CUSTOM_BIT for their own events */
#define TASK_EVENT_CUSTOM_BIT(x) BUILD_CHECK_INLINE(BIT(x), BIT(x) & 0x0ffff)
diff --git a/include/task_id.h b/include/task_id.h
index e617d820b5..9ddc61678b 100644
--- a/include/task_id.h
+++ b/include/task_id.h
@@ -16,6 +16,8 @@
#include "config.h"
#include "task_filter.h"
+#include <stdint.h>
+
/* define the name of the header containing the list of tasks */
#define STRINGIFY0(name) #name
#define STRINGIFY(name) STRINGIFY0(name)
diff --git a/include/test_util.h b/include/test_util.h
index 004e8aaf0d..efdee22cc6 100644
--- a/include/test_util.h
+++ b/include/test_util.h
@@ -19,8 +19,9 @@ extern "C" {
#include "stack_trace.h"
#ifdef CONFIG_ZTEST
-#include <zephyr/ztest.h>
#include "ec_tasks.h"
+
+#include <zephyr/ztest.h>
#endif /* CONFIG_ZTEST */
/* This allows tests to be easily commented out in run_test for debugging */
@@ -124,6 +125,7 @@ enum test_state_t {
TEST_STATE_STEP_7,
TEST_STATE_STEP_8,
TEST_STATE_STEP_9,
+ TEST_STATE_STEP_10,
TEST_STATE_PASSED,
TEST_STATE_FAILED,
};
diff --git a/include/tests/enum_strings.h b/include/tests/enum_strings.h
index 2ad0725f8f..7654dc9377 100644
--- a/include/tests/enum_strings.h
+++ b/include/tests/enum_strings.h
@@ -5,8 +5,8 @@
/* Defines helper function that convert Enums to strings for prints in tests */
-#include "usb_pd_tcpm.h"
#include "usb_pd.h"
+#include "usb_pd_tcpm.h"
#ifndef __CROS_EC_TEST_ENUM_STINGS_H
#define __CROS_EC_TEST_ENUM_STINGS_H
diff --git a/include/trng.h b/include/trng.h
index cf8326e5bf..3b28796ed0 100644
--- a/include/trng.h
+++ b/include/trng.h
@@ -5,10 +5,11 @@
#ifndef __EC_INCLUDE_TRNG_H
#define __EC_INCLUDE_TRNG_H
-#include <common.h>
#include <stddef.h>
#include <stdint.h>
+#include <common.h>
+
/**
* Initialize the true random number generator.
*
diff --git a/include/uart.h b/include/uart.h
index 851b331fd2..086c407695 100644
--- a/include/uart.h
+++ b/include/uart.h
@@ -8,10 +8,11 @@
#ifndef __CROS_EC_UART_H
#define __CROS_EC_UART_H
-#include <stdarg.h> /* For va_list */
#include "common.h"
#include "gpio_signal.h"
+#include <stdarg.h> /* For va_list */
+
/**
* Initialize the UART module.
*/
@@ -52,7 +53,7 @@ int uart_puts(const char *outstr);
*
* @param out Pointer to data to send
* @param len Length of transfer in bytes
- * @return EC_SUCCESS, or non-zero if output was truncated.
+ * @return number of characters successfully written.
*/
int uart_put(const char *out, int len);
@@ -61,7 +62,7 @@ int uart_put(const char *out, int len);
*
* @param out Pointer to data to send
* @param len Length of transfer in bytes
- * @return EC_SUCCESS, or non-zero if output was truncated.
+ * @return number of characters successfully written.
*/
int uart_put_raw(const char *out, int len);
diff --git a/include/update_fw.h b/include/update_fw.h
index dc520c2eb9..a4f56942a7 100644
--- a/include/update_fw.h
+++ b/include/update_fw.h
@@ -6,10 +6,10 @@
#ifndef __CROS_EC_UPDATE_FW_H
#define __CROS_EC_UPDATE_FW_H
-#include <stddef.h>
-
#include "compile_time_macros.h"
+#include <stddef.h>
+
/*
* This file contains structures used to facilitate EC firmware updates
* over USB (and over TPM for cr50).
diff --git a/include/usb_common.h b/include/usb_common.h
index bad1a0c058..f93178322e 100644
--- a/include/usb_common.h
+++ b/include/usb_common.h
@@ -6,6 +6,7 @@
#define __CROS_EC_USB_COMMON_H
/* Functions that are shared between old and new PD stacks */
+#include "ec_commands.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
diff --git a/include/usb_dp_alt_mode.h b/include/usb_dp_alt_mode.h
index 83dc35b085..275580b407 100644
--- a/include/usb_dp_alt_mode.h
+++ b/include/usb_dp_alt_mode.h
@@ -12,10 +12,10 @@
#ifndef __CROS_EC_USB_DP_ALT_MODE_H
#define __CROS_EC_USB_DP_ALT_MODE_H
-#include <stdint.h>
-
#include "tcpm/tcpm.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
+
+#include <stdint.h>
/*
* Initialize DP state for the specified port.
diff --git a/include/usb_mode.h b/include/usb_mode.h
index 4cf7710960..5c6f71b372 100644
--- a/include/usb_mode.h
+++ b/include/usb_mode.h
@@ -12,11 +12,11 @@
#ifndef __CROS_EC_USB_MODE_H
#define __CROS_EC_USB_MODE_H
-#include <stdint.h>
-
#include "tcpm/tcpm.h"
#include "usb_pd_tcpm.h"
+#include <stdint.h>
+
/*
* Initialize USB4 state for the specified port.
*
diff --git a/include/usb_pd.h b/include/usb_pd.h
index 92580252a5..e4ab8f6432 100644
--- a/include/usb_pd.h
+++ b/include/usb_pd.h
@@ -8,14 +8,15 @@
#ifndef __CROS_EC_USB_PD_H
#define __CROS_EC_USB_PD_H
-#include <stdbool.h>
-#include <stdint.h>
#include "common.h"
#include "ec_commands.h"
#include "usb_pd_tbt.h"
#include "usb_pd_tcpm.h"
#include "usb_pd_vdo.h"
+#include <stdbool.h>
+#include <stdint.h>
+
/* PD Host command timeout */
#define PD_HOST_COMMAND_TIMEOUT_US SECOND
@@ -476,7 +477,6 @@ struct partner_active_modes {
* VDM object is minimum of VDM header + 6 additional data objects.
*/
#define VDO_HDR_SIZE 1
-#define VDO_MAX_SIZE 7
#define VDM_VER10 0
#define VDM_VER20 1
@@ -3189,13 +3189,6 @@ __override_proto void board_process_pd_alert(int port);
*/
void board_reset_pd_mcu(void);
-/**
- * Return true if specified PD port is debug accessory.
- *
- * @param port USB-C port number
- */
-bool pd_is_debug_acc(int port);
-
/*
* Notify the AP that we have entered into DisplayPort Alternate Mode. This
* sets a DP_ALT_MODE_ENTERED MKBP event which may wake the AP.
diff --git a/include/usb_pd_dpm.h b/include/usb_pd_dpm.h
deleted file mode 100644
index c74357d588..0000000000
--- a/include/usb_pd_dpm.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/* Copyright 2020 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/*
- * Device Policy Manager implementation
- * Refer to USB PD 3.0 spec, version 2.0, sections 8.2 and 8.3
- */
-
-#ifndef __CROS_EC_USB_DPM_H
-#define __CROS_EC_USB_DPM_H
-
-#include "ec_commands.h"
-#include "usb_pd_tcpm.h"
-
-/*
- * Initializes DPM state for a port.
- *
- * @param port USB-C port number
- */
-void dpm_init(int port);
-
-/*
- * Informs the DPM that a mode exit is complete.
- *
- * @param port USB-C port number
- */
-void dpm_mode_exit_complete(int port);
-
-/*
- * Informs the DPM that Exit Mode request is received
- *
- * @param port USB-C port number
- */
-void dpm_set_mode_exit_request(int port);
-
-/* Informs the DPM that the PE has performed a Data Reset (or at least
- * determined that the port partner doesn't support one).
- *
- * @param port USB-C port number
- */
-void dpm_data_reset_complete(int port);
-
-/*
- * Informs the DPM that a VDM ACK was received.
- *
- * @param port USB-C port number
- * @param type Transmit type (SOP, SOP') for received ACK
- * @param vdo_count The number of VDOs in vdm; must be at least 1
- * @param vdm The VDM payload of the ACK
- */
-void dpm_vdm_acked(int port, enum tcpci_msg_type type, int vdo_count,
- uint32_t *vdm);
-
-/*
- * Informs the DPM that a VDM NAK was received. Also applies when a VDM request
- * received a Not Supported response or timed out waiting for a response.
- *
- * @param port USB-C port number
- * @param type Transmit type (SOP, SOP') for request
- * @param svid The SVID of the request
- * @param vdm_cmd The VDM command of the request
- */
-void dpm_vdm_naked(int port, enum tcpci_msg_type type, uint16_t svid,
- uint8_t vdm_cmd);
-
-/*
- * Drives the Policy Engine through entry/exit mode process
- *
- * @param port USB-C port number
- */
-void dpm_run(int port);
-
-/*
- * Determines the current allocation for the connection, past the basic
- * CONFIG_USB_PD_PULLUP value set by the TC (generally 1.5 A)
- *
- * @param port USB-C port number
- * @param vsafe5v_pdo Copy of first Sink_Capability PDO, which should
- * represent the vSafe5V fixed PDO
- */
-void dpm_evaluate_sink_fixed_pdo(int port, uint32_t vsafe5v_pdo);
-
-/*
- * Registers port as a non-PD sink, so that can be taken into account when
- * allocating current.
- *
- * @param port USB-C port number
- */
-void dpm_add_non_pd_sink(int port);
-
-/*
- * Evaluates the request from port partner
- *
- * @param port USB-C port number
- * @param rdo Request from port partner
- */
-void dpm_evaluate_request_rdo(int port, uint32_t rdo);
-
-/*
- * Remove this port as a sink, and reallocate maximum current as needed.
- *
- * @param port USB-C port number
- */
-void dpm_remove_sink(int port);
-
-/*
- * Remove this port as a source, and reallocate reserved FRS maximum current
- * as needed.
- *
- * @param port USB-C port number
- */
-void dpm_remove_source(int port);
-
-/*
- * Return the appropriate Source Capability PDO to offer this port
- *
- * @param src_pdo Will point to appropriate PDO to offer
- * @param port USB-C port number
- * @return Number of PDOs
- */
-int dpm_get_source_pdo(const uint32_t **src_pdo, const int port);
-
-/*
- * Report offered source current for this port
- *
- * @param port USB-C port number
- * @return Current offered, in mA
- */
-int dpm_get_source_current(const int port);
-
-/*
- * Report we've been asked to enter BIST Shared Test Mode
- *
- * @param port USB-C port number
- */
-void dpm_bist_shared_mode_enter(int port);
-
-/*
- * Report we've been asked to exit BIST Shared Test Mode
- *
- * @param port USB-C port number
- */
-void dpm_bist_shared_mode_exit(int port);
-
-/*
- * Set BIST Shared Test Mode
- */
-enum ec_status pd_set_bist_share_mode(uint8_t enable);
-
-/*
- * Get BIST Shared Test Mode status
- */
-uint8_t pd_get_bist_share_mode(void);
-/*
- * Build SOP Status Data Block (SDB)
- *
- * @param port USB-C port number
- * @param *msg pointer to pd message
- * @param *len pointer to uint32_t holding length of SDB
- */
-int dpm_get_status_msg(int port, uint8_t *msg, uint32_t *len);
-
-/*
- * DPM function to handle a received alert message
- *
- * @param port USB-C port number
- * @param ado Alert Data Object (ado) received from partner
- */
-void dpm_handle_alert(int port, uint32_t ado);
-
-/* Enum for modules to describe to the DPM their setup status */
-enum dpm_msg_setup_status {
- MSG_SETUP_SUCCESS,
- MSG_SETUP_ERROR,
- MSG_SETUP_UNSUPPORTED,
- MSG_SETUP_MUX_WAIT,
-};
-
-/* Enum to describe current state of connected USB PD buttons */
-enum dpm_pd_button_state {
- DPM_PD_BUTTON_IDLE,
- DPM_PD_BUTTON_PRESSED,
-};
-#endif /* __CROS_EC_USB_DPM_H */
diff --git a/include/usb_pd_dpm_sm.h b/include/usb_pd_dpm_sm.h
new file mode 100644
index 0000000000..8fdd147be1
--- /dev/null
+++ b/include/usb_pd_dpm_sm.h
@@ -0,0 +1,196 @@
+/* Copyright 2020 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/*
+ * Device Policy Manager implementation
+ * Refer to USB PD 3.0 spec, version 2.0, sections 8.2 and 8.3
+ */
+
+#ifndef __CROS_EC_USB_DPM_H
+#define __CROS_EC_USB_DPM_H
+
+#include "ec_commands.h"
+#include "usb_pd_tcpm.h"
+
+/*
+ * Initializes DPM state for a port.
+ *
+ * @param port USB-C port number
+ */
+void dpm_init(int port);
+
+/**
+ * Runs the Device Policy Manager State Machine
+ *
+ * @param port USB-C port number
+ * @param evt system event, ie: PD_EVENT_RX
+ * @param en 0 to disable the machine, 1 to enable the machine
+ */
+void dpm_run(int port, int evt, int en);
+
+/*
+ * Informs the DPM that a mode exit is complete.
+ *
+ * @param port USB-C port number
+ */
+void dpm_mode_exit_complete(int port);
+
+/*
+ * Informs the DPM that Exit Mode request is received
+ *
+ * @param port USB-C port number
+ */
+void dpm_set_mode_exit_request(int port);
+
+/* Informs the DPM that the PE has performed a Data Reset (or at least
+ * determined that the port partner doesn't support one).
+ *
+ * @param port USB-C port number
+ */
+void dpm_data_reset_complete(int port);
+
+/*
+ * Informs the DPM that PE layer is in ready state so that data role can be
+ * checked and DPM can know to exit the idle state.
+ *
+ * @param port USB-C port number
+ */
+void dpm_set_pe_ready(int port, bool enable);
+
+/*
+ * Informs the DPM that a VDM ACK was received.
+ *
+ * @param port USB-C port number
+ * @param type Transmit type (SOP, SOP') for received ACK
+ * @param vdo_count The number of VDOs in vdm; must be at least 1
+ * @param vdm The VDM payload of the ACK
+ */
+void dpm_vdm_acked(int port, enum tcpci_msg_type type, int vdo_count,
+ uint32_t *vdm);
+
+/*
+ * Informs the DPM that a VDM NAK was received. Also applies when a VDM request
+ * received a Not Supported response or timed out waiting for a response.
+ *
+ * @param port USB-C port number
+ * @param type Transmit type (SOP, SOP') for request
+ * @param svid The SVID of the request
+ * @param vdm_cmd The VDM command of the request
+ */
+void dpm_vdm_naked(int port, enum tcpci_msg_type type, uint16_t svid,
+ uint8_t vdm_cmd);
+
+/*
+ * Determines the current allocation for the connection, past the basic
+ * CONFIG_USB_PD_PULLUP value set by the TC (generally 1.5 A)
+ *
+ * @param port USB-C port number
+ * @param vsafe5v_pdo Copy of first Sink_Capability PDO, which should
+ * represent the vSafe5V fixed PDO
+ */
+void dpm_evaluate_sink_fixed_pdo(int port, uint32_t vsafe5v_pdo);
+
+/*
+ * Registers port as a non-PD sink, so that can be taken into account when
+ * allocating current.
+ *
+ * @param port USB-C port number
+ */
+void dpm_add_non_pd_sink(int port);
+
+/*
+ * Evaluates the request from port partner
+ *
+ * @param port USB-C port number
+ * @param rdo Request from port partner
+ */
+void dpm_evaluate_request_rdo(int port, uint32_t rdo);
+
+/*
+ * Remove this port as a sink, and reallocate maximum current as needed.
+ *
+ * @param port USB-C port number
+ */
+void dpm_remove_sink(int port);
+
+/*
+ * Remove this port as a source, and reallocate reserved FRS maximum current
+ * as needed.
+ *
+ * @param port USB-C port number
+ */
+void dpm_remove_source(int port);
+
+/*
+ * Return the appropriate Source Capability PDO to offer this port
+ *
+ * @param src_pdo Will point to appropriate PDO to offer
+ * @param port USB-C port number
+ * @return Number of PDOs
+ */
+int dpm_get_source_pdo(const uint32_t **src_pdo, const int port);
+
+/*
+ * Report offered source current for this port
+ *
+ * @param port USB-C port number
+ * @return Current offered, in mA
+ */
+int dpm_get_source_current(const int port);
+
+/*
+ * Report we've been asked to enter BIST Shared Test Mode
+ *
+ * @param port USB-C port number
+ */
+void dpm_bist_shared_mode_enter(int port);
+
+/*
+ * Report we've been asked to exit BIST Shared Test Mode
+ *
+ * @param port USB-C port number
+ */
+void dpm_bist_shared_mode_exit(int port);
+
+/*
+ * Set BIST Shared Test Mode
+ */
+enum ec_status pd_set_bist_share_mode(uint8_t enable);
+
+/*
+ * Get BIST Shared Test Mode status
+ */
+uint8_t pd_get_bist_share_mode(void);
+/*
+ * Build SOP Status Data Block (SDB)
+ *
+ * @param port USB-C port number
+ * @param *msg pointer to pd message
+ * @param *len pointer to uint32_t holding length of SDB
+ */
+int dpm_get_status_msg(int port, uint8_t *msg, uint32_t *len);
+
+/*
+ * DPM function to handle a received alert message
+ *
+ * @param port USB-C port number
+ * @param ado Alert Data Object (ado) received from partner
+ */
+void dpm_handle_alert(int port, uint32_t ado);
+
+/* Enum for modules to describe to the DPM their setup status */
+enum dpm_msg_setup_status {
+ MSG_SETUP_SUCCESS,
+ MSG_SETUP_ERROR,
+ MSG_SETUP_UNSUPPORTED,
+ MSG_SETUP_MUX_WAIT,
+};
+
+/* Enum to describe current state of connected USB PD buttons */
+enum dpm_pd_button_state {
+ DPM_PD_BUTTON_IDLE,
+ DPM_PD_BUTTON_PRESSED,
+};
+#endif /* __CROS_EC_USB_DPM_H */
diff --git a/include/usb_pd_tcpc.h b/include/usb_pd_tcpc.h
index a89030cdb7..7af0a570e4 100644
--- a/include/usb_pd_tcpc.h
+++ b/include/usb_pd_tcpc.h
@@ -8,9 +8,10 @@
#ifndef __CROS_EC_USB_PD_TCPC_H
#define __CROS_EC_USB_PD_TCPC_H
-#include <stdint.h>
#include "usb_pd_tcpm.h"
+#include <stdint.h>
+
/* If we are a TCPC but not a TCPM, then we implement the peripheral TCPCI */
#if defined(CONFIG_USB_PD_TCPC) && !defined(CONFIG_USB_PD_TCPM_STUB)
#define TCPCI_I2C_PERIPHERAL
diff --git a/include/usb_pd_tcpm.h b/include/usb_pd_tcpm.h
index f3f449721e..199682122c 100644
--- a/include/usb_pd_tcpm.h
+++ b/include/usb_pd_tcpm.h
@@ -8,12 +8,13 @@
#ifndef __CROS_EC_USB_PD_TCPM_H
#define __CROS_EC_USB_PD_TCPM_H
-#include <stdbool.h>
#include "common.h"
#include "compiler.h"
#include "ec_commands.h"
#include "i2c.h"
+#include <stdbool.h>
+
/* Time to wait for TCPC to complete transmit */
#define PD_T_TCPC_TX_TIMEOUT (100 * MSEC)
diff --git a/include/usb_pd_timer.h b/include/usb_pd_timer.h
index 439b30513d..687c980243 100644
--- a/include/usb_pd_timer.h
+++ b/include/usb_pd_timer.h
@@ -8,11 +8,11 @@
#ifndef __CROS_EC_USB_PD_TIMER_H
#define __CROS_EC_USB_PD_TIMER_H
-#include <stdbool.h>
-
#include "atomic.h"
#include "atomic_bit.h"
+#include <stdbool.h>
+
/*
* List of all timers that will be managed by usb_pd_timer
*/
diff --git a/include/usb_prl_sm.h b/include/usb_prl_sm.h
index 99b69f156f..5671f8300e 100644
--- a/include/usb_prl_sm.h
+++ b/include/usb_prl_sm.h
@@ -8,11 +8,10 @@
#ifndef __CROS_EC_USB_PRL_H
#define __CROS_EC_USB_PRL_H
#include "common.h"
+#include "timer.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#include "usb_sm.h"
-#include "timer.h"
-#include "usb_pd_tcpm.h"
/**
* Returns TX success time stamp.
diff --git a/include/usb_tbt_alt_mode.h b/include/usb_tbt_alt_mode.h
index 378cd0ccce..ff2ad44ed0 100644
--- a/include/usb_tbt_alt_mode.h
+++ b/include/usb_tbt_alt_mode.h
@@ -11,12 +11,12 @@
#ifndef __CROS_EC_USB_TBT_ALT_MODE_H
#define __CROS_EC_USB_TBT_ALT_MODE_H
-#include <stdint.h>
-
#include "tcpm/tcpm.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_pd_tcpm.h"
+#include <stdint.h>
+
/*
* Initialize Thunderbolt state for the specified port.
*
diff --git a/include/usb_tc_sm.h b/include/usb_tc_sm.h
index ec6473edfd..009e5db089 100644
--- a/include/usb_tc_sm.h
+++ b/include/usb_tc_sm.h
@@ -8,9 +8,9 @@
#ifndef __CROS_EC_USB_TC_H
#define __CROS_EC_USB_TC_H
-#include "usb_sm.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
+#include "usb_sm.h"
enum try_src_override_t {
TRY_SRC_OVERRIDE_OFF,
diff --git a/include/util.h b/include/util.h
index dc2e038705..9db98f2b3f 100644
--- a/include/util.h
+++ b/include/util.h
@@ -16,6 +16,7 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
+
#include <strings.h>
#ifdef CONFIG_ZEPHYR
#include <zephyr/sys/util.h>
diff --git a/include/vb21_struct.h b/include/vb21_struct.h
index c8b49ac05e..b23eb0cd30 100644
--- a/include/vb21_struct.h
+++ b/include/vb21_struct.h
@@ -14,10 +14,10 @@
#ifndef VBOOT_REFERENCE_VB21_STRUCT_H_
#define VBOOT_REFERENCE_VB21_STRUCT_H_
-#include <stdint.h>
-
#include "2id.h"
+#include <stdint.h>
+
/*
* Magic numbers used by vb21_struct_common.magic.
*
diff --git a/include/vboot.h b/include/vboot.h
index 55359e8044..9a3013ebbc 100644
--- a/include/vboot.h
+++ b/include/vboot.h
@@ -7,11 +7,11 @@
#define __CROS_EC_INCLUDE_VBOOT_H
#include "common.h"
-#include "vb21_struct.h"
#include "rsa.h"
#include "sha256.h"
#include "stdbool.h"
#include "timer.h"
+#include "vb21_struct.h"
/**
* Validate key contents.
diff --git a/include/watchdog.h b/include/watchdog.h
index d6768425ce..5e6e5626e6 100644
--- a/include/watchdog.h
+++ b/include/watchdog.h
@@ -8,10 +8,10 @@
#ifndef __CROS_EC_WATCHDOG_H
#define __CROS_EC_WATCHDOG_H
-#include <stdint.h>
-
#include "config.h"
+#include <stdint.h>
+
/**
* Initialize the watchdog.
*
diff --git a/libc/syscalls.c b/libc/syscalls.c
index 9c683a2732..43955a0ddd 100644
--- a/libc/syscalls.c
+++ b/libc/syscalls.c
@@ -14,6 +14,7 @@
#include "panic.h"
#include "software_panic.h"
#include "task.h"
+#include "uart.h"
/**
* Reboot the system.
@@ -27,3 +28,18 @@ void _exit(int rc)
panic_printf("%s called with rc: %d\n", __func__, rc);
software_panic(PANIC_SW_EXIT, task_get_current());
}
+
+/**
+ * Write to the UART.
+ *
+ * This function is called from libc functions such as printf().
+ *
+ * @param fd ignored
+ * @param buf buffer to write
+ * @param len number of bytes in @buf to write
+ * @return number of bytes successfully written
+ */
+int _write(int fd, char *buf, int len)
+{
+ return uart_put(buf, len);
+}
diff --git a/power/amd_x86.c b/power/amd_x86.c
index e5b44a313f..ca40ef9f3b 100644
--- a/power/amd_x86.c
+++ b/power/amd_x86.c
@@ -13,15 +13,15 @@
#include "hooks.h"
#include "lid_switch.h"
#include "lpc.h"
-#include "power/amd_x86.h"
#include "power.h"
+#include "power/amd_x86.h"
#include "power_button.h"
+#include "registers.h"
#include "system.h"
#include "timer.h"
#include "usb_charge.h"
#include "util.h"
#include "wireless.h"
-#include "registers.h"
/* Console output macros */
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
diff --git a/power/hibernate.c b/power/hibernate.c
new file mode 100644
index 0000000000..46c842bce6
--- /dev/null
+++ b/power/hibernate.c
@@ -0,0 +1,181 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "console.h"
+#include "extpower.h"
+#include "hooks.h"
+#include "host_command.h"
+#include "system.h"
+#include "util.h"
+
+#include <zephyr/init.h>
+#include <zephyr/logging/log.h>
+
+#include <ap_power/ap_power.h>
+#include <ap_power/ap_power_interface.h>
+
+LOG_MODULE_DECLARE(ap_pwrseq, CONFIG_AP_PWRSEQ_LOG_LEVEL);
+
+/*
+ * Hibernate processing.
+ *
+ * When enabled, the system will be put into an extreme low
+ * power state after the AP is in G3 for a configurable period of time,
+ * and there is no external power connected (i.e on battery).
+ *
+ * The delay has a configurable default, and may be set dynamically
+ * via a host command, or an EC console command. A typical delay
+ * may be 1 hour (3600 seconds).
+ *
+ * AP events such as AP_POWER_HARD_OFF are listened for, and
+ * a timer is used to detect when the AP has been off for the
+ * selected delay time. If the AP is started again, the timer is canceled.
+ * Once the timer expires, the system_hibernate() function is called,
+ * and this will suspend the EC until a wake signal is received.
+ */
+static uint32_t hibernate_delay = CONFIG_HIBERNATE_DELAY_SEC;
+
+/*
+ * Return true if conditions are right for hibernation.
+ */
+static inline bool ready_to_hibernate(void)
+{
+ return ap_power_in_or_transitioning_to_state(AP_POWER_STATE_HARD_OFF) &&
+ !extpower_is_present();
+}
+
+/*
+ * The AP has been off for the delay period, so hibernate the system,
+ * if ready. Called from system work queue.
+ */
+static void hibernate_handler(struct k_work *unused)
+{
+ if (ready_to_hibernate()) {
+ LOG_INF("System hibernating due to %d seconds AP off",
+ hibernate_delay);
+ system_hibernate(0, 0);
+ }
+}
+
+K_WORK_DEFINE(hibernate_work, hibernate_handler);
+
+/*
+ * Hibernate timer handler.
+ * Called when timer has expired.
+ * Schedule hibernate_handler to run via system work queue.
+ */
+static void timer_handler(struct k_timer *timer)
+{
+ k_work_submit(&hibernate_work);
+}
+
+K_TIMER_DEFINE(hibernate_timer, timer_handler, NULL);
+
+/*
+ * A change has been detected in either the AP state or the
+ * external power supply.
+ */
+static void change_detected(void)
+{
+ if (ready_to_hibernate()) {
+ /*
+ * AP is off, and there is no external power.
+ * Start the timer if it is not already running.
+ */
+ if (k_timer_remaining_get(&hibernate_timer) == 0) {
+ k_timer_start(&hibernate_timer,
+ K_SECONDS(hibernate_delay), K_NO_WAIT);
+ }
+
+ } else {
+ /*
+ * AP is either on, or external power is on.
+ * Either way, no hibernation is done.
+ * Make sure the timer is not running.
+ */
+ k_timer_stop(&hibernate_timer);
+ }
+}
+
+static void ap_change(struct ap_power_ev_callback *callback,
+ struct ap_power_ev_data data)
+{
+ change_detected();
+}
+
+/*
+ * Hook to listen for external power supply changes.
+ */
+DECLARE_HOOK(HOOK_AC_CHANGE, change_detected, HOOK_PRIO_DEFAULT);
+
+/*
+ * EC Console command to get/set the hibernation delay
+ */
+static int command_hibernation_delay(int argc, const char **argv)
+{
+ char *e;
+ uint32_t remaining;
+
+ if (argc >= 2) {
+ uint32_t s = strtoi(argv[1], &e, 0);
+
+ if (*e)
+ return EC_ERROR_PARAM1;
+
+ hibernate_delay = s;
+ }
+
+ /* Print the current setting */
+ ccprintf("Hibernation delay: %d s\n", hibernate_delay);
+ remaining = k_timer_remaining_get(&hibernate_timer);
+ if (remaining == 0) {
+ ccprintf("Timer not running\n");
+ } else {
+ ccprintf("Time remaining: %d s\n", remaining / 1000);
+ }
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(hibdelay, command_hibernation_delay, "[sec]",
+ "Set the delay before going into hibernation");
+/*
+ * Host command to set the hibernation delay
+ */
+static enum ec_status
+host_command_hibernation_delay(struct host_cmd_handler_args *args)
+{
+ const struct ec_params_hibernation_delay *p = args->params;
+ struct ec_response_hibernation_delay *r = args->response;
+
+ /* Only change the hibernation delay if seconds is non-zero. */
+ if (p->seconds)
+ hibernate_delay = p->seconds;
+
+ r->hibernate_delay = hibernate_delay;
+ /*
+ * It makes no sense to try and set these values since
+ * they are only valid when the AP is in G3 (so this
+ * host command will never be called at that point).
+ */
+ r->time_g3 = 0;
+ r->time_remaining = 0;
+
+ args->response_size = sizeof(struct ec_response_hibernation_delay);
+ return EC_RES_SUCCESS;
+}
+DECLARE_HOST_COMMAND(EC_CMD_HIBERNATION_DELAY, host_command_hibernation_delay,
+ EC_VER_MASK(0));
+
+static int hibernate_init(const struct device *unused)
+{
+ static struct ap_power_ev_callback cb;
+
+ ap_power_ev_init_callback(&cb, ap_change,
+ AP_POWER_INITIALIZED | AP_POWER_HARD_OFF |
+ AP_POWER_STARTUP);
+ ap_power_ev_add_callback(&cb);
+ return 0;
+}
+
+SYS_INIT(hibernate_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
diff --git a/power/mt8186.c b/power/mt8186.c
index b05700b599..723036a21f 100644
--- a/power/mt8186.c
+++ b/power/mt8186.c
@@ -290,6 +290,14 @@ enum power_state power_chipset_init(void)
* the only way is to ask GPIO_AC_PRESENT directly.
*/
exit_hard_off = 0;
+ } else if (system_get_reset_flags() & EC_RESET_FLAG_AP_IDLE) {
+ if (init_state == POWER_S0) {
+ gpio_enable_interrupt(GPIO_AP_EC_WDTRST_L);
+ gpio_enable_interrupt(GPIO_AP_EC_WARM_RST_REQ);
+ disable_sleep(SLEEP_MASK_AP_RUN);
+ }
+
+ return init_state;
}
if (battery_is_present() == BP_YES)
diff --git a/power/qcom.c b/power/qcom.c
index 30374cd330..eba2d32442 100644
--- a/power/qcom.c
+++ b/power/qcom.c
@@ -1139,7 +1139,6 @@ test_mockable enum power_state power_handle_state(enum power_state state)
default:
CPRINTS("Unexpected power state %d", state);
ASSERT(0);
- break;
}
return state;
diff --git a/power/rk3288.c b/power/rk3288.c
index e4e4ac9d69..8aea147391 100644
--- a/power/rk3288.c
+++ b/power/rk3288.c
@@ -32,8 +32,8 @@
#include "console.h"
#include "gpio.h"
#include "hooks.h"
-#include "lid_switch.h"
#include "keyboard_scan.h"
+#include "lid_switch.h"
#include "power.h"
#include "power_button.h"
#include "power_led.h"
diff --git a/test/abort.c b/test/abort.c
index e0069e920f..dcc798861e 100644
--- a/test/abort.c
+++ b/test/abort.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <stdlib.h>
-
#include "common.h"
#include "panic.h"
#include "system.h"
#include "task.h"
#include "test_util.h"
+#include <stdlib.h>
+
test_static int test_abort(void)
{
ccprintf("Calling abort\n");
diff --git a/test/accel_cal.c b/test/accel_cal.c
index 481d0615f2..5c50211bd5 100644
--- a/test/accel_cal.c
+++ b/test/accel_cal.c
@@ -3,10 +3,11 @@
* found in the LICENSE file.
*/
-#include "common.h"
#include "accel_cal.h"
-#include "test_util.h"
+#include "common.h"
#include "motion_sense.h"
+#include "test_util.h"
+
#include <math.h>
struct motion_sensor_t motion_sensors[] = {};
diff --git a/test/aes.c b/test/aes.c
deleted file mode 100644
index 0fc220d997..0000000000
--- a/test/aes.c
+++ /dev/null
@@ -1,588 +0,0 @@
-/* Copyright 2018 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
-
-#include "aes.h"
-#include "aes-gcm.h"
-#include "builtin/assert.h"
-#include "console.h"
-#include "common.h"
-#include "test_util.h"
-#include "timer.h"
-#include "util.h"
-#include "watchdog.h"
-
-/* Temporary buffer, to avoid using too much stack space. */
-static uint8_t tmp[512];
-
-/*
- * Do encryption, put result in |result|, and compare with |ciphertext|.
- */
-static int test_aes_gcm_encrypt(uint8_t *result, const uint8_t *key,
- int key_size, const uint8_t *plaintext,
- const uint8_t *ciphertext, int plaintext_size,
- const uint8_t *nonce, int nonce_size,
- const uint8_t *tag, int tag_size)
-{
- static AES_KEY aes_key;
- static GCM128_CONTEXT ctx;
-
- TEST_ASSERT(AES_set_encrypt_key(key, 8 * key_size, &aes_key) == 0);
-
- CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0);
- CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size);
- TEST_ASSERT(CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, result,
- plaintext_size));
- TEST_ASSERT(CRYPTO_gcm128_finish(&ctx, tag, tag_size));
- TEST_ASSERT_ARRAY_EQ(ciphertext, result, plaintext_size);
-
- return EC_SUCCESS;
-}
-
-/*
- * Do decryption, put result in |result|, and compare with |plaintext|.
- */
-static int test_aes_gcm_decrypt(uint8_t *result, const uint8_t *key,
- int key_size, const uint8_t *plaintext,
- const uint8_t *ciphertext, int plaintext_size,
- const uint8_t *nonce, int nonce_size,
- const uint8_t *tag, int tag_size)
-{
- static AES_KEY aes_key;
- static GCM128_CONTEXT ctx;
-
- TEST_ASSERT(AES_set_encrypt_key(key, 8 * key_size, &aes_key) == 0);
-
- CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0);
- CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size);
- TEST_ASSERT(CRYPTO_gcm128_decrypt(&ctx, &aes_key, ciphertext, result,
- plaintext_size));
- TEST_ASSERT(CRYPTO_gcm128_finish(&ctx, tag, tag_size));
- TEST_ASSERT_ARRAY_EQ(plaintext, result, plaintext_size);
-
- return EC_SUCCESS;
-}
-
-static int test_aes_gcm_raw_inplace(const uint8_t *key, int key_size,
- const uint8_t *plaintext,
- const uint8_t *ciphertext,
- int plaintext_size, const uint8_t *nonce,
- int nonce_size, const uint8_t *tag,
- int tag_size)
-{
- /*
- * Make copies that will be clobbered during in-place encryption or
- * decryption.
- */
- uint8_t plaintext_copy[plaintext_size];
- uint8_t ciphertext_copy[plaintext_size];
-
- memcpy(plaintext_copy, plaintext, plaintext_size);
- memcpy(ciphertext_copy, ciphertext, plaintext_size);
-
- TEST_ASSERT(test_aes_gcm_encrypt(plaintext_copy, key, key_size,
- plaintext_copy, ciphertext,
- plaintext_size, nonce, nonce_size, tag,
- tag_size) == EC_SUCCESS);
-
- TEST_ASSERT(test_aes_gcm_decrypt(ciphertext_copy, key, key_size,
- plaintext, ciphertext_copy,
- plaintext_size, nonce, nonce_size, tag,
- tag_size) == EC_SUCCESS);
-
- return EC_SUCCESS;
-}
-
-static int test_aes_gcm_raw_non_inplace(const uint8_t *key, int key_size,
- const uint8_t *plaintext,
- const uint8_t *ciphertext,
- int plaintext_size,
- const uint8_t *nonce, int nonce_size,
- const uint8_t *tag, int tag_size)
-{
- TEST_ASSERT(test_aes_gcm_encrypt(tmp, key, key_size, plaintext,
- ciphertext, plaintext_size, nonce,
- nonce_size, tag,
- tag_size) == EC_SUCCESS);
-
- TEST_ASSERT(test_aes_gcm_decrypt(tmp, key, key_size, plaintext,
- ciphertext, plaintext_size, nonce,
- nonce_size, tag,
- tag_size) == EC_SUCCESS);
-
- return EC_SUCCESS;
-}
-
-static int test_aes_gcm_raw(const uint8_t *key, int key_size,
- const uint8_t *plaintext, const uint8_t *ciphertext,
- int plaintext_size, const uint8_t *nonce,
- int nonce_size, const uint8_t *tag, int tag_size)
-{
- TEST_ASSERT(plaintext_size <= sizeof(tmp));
-
- TEST_ASSERT(test_aes_gcm_raw_non_inplace(key, key_size, plaintext,
- ciphertext, plaintext_size,
- nonce, nonce_size, tag,
- tag_size) == EC_SUCCESS);
- TEST_ASSERT(test_aes_gcm_raw_inplace(key, key_size, plaintext,
- ciphertext, plaintext_size, nonce,
- nonce_size, tag,
- tag_size) == EC_SUCCESS);
-
- return EC_SUCCESS;
-}
-
-static int test_aes_gcm(void)
-{
- /*
- * Test vectors from BoringSSL crypto/fipsmodule/modes/gcm_tests.txt
- * (only the ones with actual data, and no additional data).
- */
- static const uint8_t key1[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- static const uint8_t plain1[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- static const uint8_t nonce1[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- static const uint8_t cipher1[] = {
- 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92,
- 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78,
- };
- static const uint8_t tag1[] = {
- 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd,
- 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf,
- };
-
- static const uint8_t key2[] = {
- 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
- 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
- };
- static const uint8_t plain2[] = {
- 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59,
- 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53,
- 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31,
- 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
- 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a,
- 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39,
- 0x1a, 0xaf, 0xd2, 0x55,
- };
- static const uint8_t nonce2[] = {
- 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce,
- 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88,
- };
- static const uint8_t cipher2[] = {
- 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 0x4b, 0x72,
- 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 0xe3, 0xaa, 0x21, 0x2f,
- 0x2c, 0x02, 0xa4, 0xe0, 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac,
- 0xa1, 0x2e, 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
- 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, 0x1b, 0xa3,
- 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, 0x3d, 0x58, 0xe0, 0x91,
- 0x47, 0x3f, 0x59, 0x85,
- };
- static const uint8_t tag2[] = {
- 0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6,
- 0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4,
- };
-
- static const uint8_t key3[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- static const uint8_t plain3[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- static const uint8_t nonce3[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- static const uint8_t cipher3[] = {
- 0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41,
- 0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00,
- };
- static const uint8_t tag3[] = {
- 0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab,
- 0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb,
- };
-
- static const uint8_t key4[] = {
- 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
- 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
- 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
- };
- static const uint8_t plain4[] = {
- 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59,
- 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53,
- 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31,
- 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
- 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a,
- 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39,
- 0x1a, 0xaf, 0xd2, 0x55,
- };
- static const uint8_t nonce4[] = {
- 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce,
- 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88,
- };
- static const uint8_t cipher4[] = {
- 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, 0xeb, 0x06,
- 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, 0x85, 0x9e, 0x1c, 0xea,
- 0xa6, 0xef, 0xd9, 0x84, 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1,
- 0xe1, 0x9c, 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25,
- 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, 0x18, 0xe2,
- 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, 0xcc, 0xda, 0x27, 0x10,
- 0xac, 0xad, 0xe2, 0x56,
- };
- static const uint8_t tag4[] = {
- 0x99, 0x24, 0xa7, 0xc8, 0x58, 0x73, 0x36, 0xbf,
- 0xb1, 0x18, 0x02, 0x4d, 0xb8, 0x67, 0x4a, 0x14,
- };
-
- static const uint8_t key5[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- static const uint8_t plain5[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- static const uint8_t nonce5[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- static const uint8_t cipher5[] = {
- 0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e,
- 0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18,
- };
- static const uint8_t tag5[] = {
- 0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0,
- 0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19,
- };
-
- static const uint8_t key6[] = {
- 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
- 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
- 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
- 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
- };
- static const uint8_t plain6[] = {
- 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59,
- 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53,
- 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31,
- 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
- 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a,
- 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39,
- 0x1a, 0xaf, 0xd2, 0x55,
- };
- static const uint8_t nonce6[] = {
- 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce,
- 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88,
- };
- static const uint8_t cipher6[] = {
- 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 0xf4, 0x7f,
- 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 0x64, 0x3a, 0x8c, 0xdc,
- 0xbf, 0xe5, 0xc0, 0xc9, 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55,
- 0xd1, 0xaa, 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
- 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 0xc5, 0xf6,
- 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 0xbc, 0xc9, 0xf6, 0x62,
- 0x89, 0x80, 0x15, 0xad,
- };
- static const uint8_t tag6[] = {
- 0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd,
- 0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c,
- };
-
- static const uint8_t key7[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- static const uint8_t plain7[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- /* This nonce results in 0xfff in counter LSB. */
- static const uint8_t nonce7[] = {
- 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00,
- };
- static const uint8_t cipher7[] = {
- 0x56, 0xb3, 0x37, 0x3c, 0xa9, 0xef, 0x6e, 0x4a, 0x2b, 0x64,
- 0xfe, 0x1e, 0x9a, 0x17, 0xb6, 0x14, 0x25, 0xf1, 0x0d, 0x47,
- 0xa7, 0x5a, 0x5f, 0xce, 0x13, 0xef, 0xc6, 0xbc, 0x78, 0x4a,
- 0xf2, 0x4f, 0x41, 0x41, 0xbd, 0xd4, 0x8c, 0xf7, 0xc7, 0x70,
- 0x88, 0x7a, 0xfd, 0x57, 0x3c, 0xca, 0x54, 0x18, 0xa9, 0xae,
- 0xff, 0xcd, 0x7c, 0x5c, 0xed, 0xdf, 0xc6, 0xa7, 0x83, 0x97,
- 0xb9, 0xa8, 0x5b, 0x49, 0x9d, 0xa5, 0x58, 0x25, 0x72, 0x67,
- 0xca, 0xab, 0x2a, 0xd0, 0xb2, 0x3c, 0xa4, 0x76, 0xa5, 0x3c,
- 0xb1, 0x7f, 0xb4, 0x1c, 0x4b, 0x8b, 0x47, 0x5c, 0xb4, 0xf3,
- 0xf7, 0x16, 0x50, 0x94, 0xc2, 0x29, 0xc9, 0xe8, 0xc4, 0xdc,
- 0x0a, 0x2a, 0x5f, 0xf1, 0x90, 0x3e, 0x50, 0x15, 0x11, 0x22,
- 0x13, 0x76, 0xa1, 0xcd, 0xb8, 0x36, 0x4c, 0x50, 0x61, 0xa2,
- 0x0c, 0xae, 0x74, 0xbc, 0x4a, 0xcd, 0x76, 0xce, 0xb0, 0xab,
- 0xc9, 0xfd, 0x32, 0x17, 0xef, 0x9f, 0x8c, 0x90, 0xbe, 0x40,
- 0x2d, 0xdf, 0x6d, 0x86, 0x97, 0xf4, 0xf8, 0x80, 0xdf, 0xf1,
- 0x5b, 0xfb, 0x7a, 0x6b, 0x28, 0x24, 0x1e, 0xc8, 0xfe, 0x18,
- 0x3c, 0x2d, 0x59, 0xe3, 0xf9, 0xdf, 0xff, 0x65, 0x3c, 0x71,
- 0x26, 0xf0, 0xac, 0xb9, 0xe6, 0x42, 0x11, 0xf4, 0x2b, 0xae,
- 0x12, 0xaf, 0x46, 0x2b, 0x10, 0x70, 0xbe, 0xf1, 0xab, 0x5e,
- 0x36, 0x06, 0x87, 0x2c, 0xa1, 0x0d, 0xee, 0x15, 0xb3, 0x24,
- 0x9b, 0x1a, 0x1b, 0x95, 0x8f, 0x23, 0x13, 0x4c, 0x4b, 0xcc,
- 0xb7, 0xd0, 0x32, 0x00, 0xbc, 0xe4, 0x20, 0xa2, 0xf8, 0xeb,
- 0x66, 0xdc, 0xf3, 0x64, 0x4d, 0x14, 0x23, 0xc1, 0xb5, 0x69,
- 0x90, 0x03, 0xc1, 0x3e, 0xce, 0xf4, 0xbf, 0x38, 0xa3, 0xb6,
- 0x0e, 0xed, 0xc3, 0x40, 0x33, 0xba, 0xc1, 0x90, 0x27, 0x83,
- 0xdc, 0x6d, 0x89, 0xe2, 0xe7, 0x74, 0x18, 0x8a, 0x43, 0x9c,
- 0x7e, 0xbc, 0xc0, 0x67, 0x2d, 0xbd, 0xa4, 0xdd, 0xcf, 0xb2,
- 0x79, 0x46, 0x13, 0xb0, 0xbe, 0x41, 0x31, 0x5e, 0xf7, 0x78,
- 0x70, 0x8a, 0x70, 0xee, 0x7d, 0x75, 0x16, 0x5c,
- };
- static const uint8_t tag7[] = {
- 0x8b, 0x30, 0x7f, 0x6b, 0x33, 0x28, 0x6d, 0x0a,
- 0xb0, 0x26, 0xa9, 0xed, 0x3f, 0xe1, 0xe8, 0x5f,
- };
-
- TEST_ASSERT(!test_aes_gcm_raw(key1, sizeof(key1), plain1, cipher1,
- sizeof(plain1), nonce1, sizeof(nonce1),
- tag1, sizeof(tag1)));
- TEST_ASSERT(!test_aes_gcm_raw(key2, sizeof(key2), plain2, cipher2,
- sizeof(plain2), nonce2, sizeof(nonce2),
- tag2, sizeof(tag2)));
- TEST_ASSERT(!test_aes_gcm_raw(key3, sizeof(key3), plain3, cipher3,
- sizeof(plain3), nonce3, sizeof(nonce3),
- tag3, sizeof(tag3)));
- TEST_ASSERT(!test_aes_gcm_raw(key4, sizeof(key4), plain4, cipher4,
- sizeof(plain4), nonce4, sizeof(nonce4),
- tag4, sizeof(tag4)));
- TEST_ASSERT(!test_aes_gcm_raw(key5, sizeof(key5), plain5, cipher5,
- sizeof(plain5), nonce5, sizeof(nonce5),
- tag5, sizeof(tag5)));
- TEST_ASSERT(!test_aes_gcm_raw(key6, sizeof(key6), plain6, cipher6,
- sizeof(plain6), nonce6, sizeof(nonce6),
- tag6, sizeof(tag6)));
- TEST_ASSERT(!test_aes_gcm_raw(key7, sizeof(key7), plain7, cipher7,
- sizeof(plain7), nonce7, sizeof(nonce7),
- tag7, sizeof(tag7)));
-
- return EC_SUCCESS;
-}
-
-static void test_aes_gcm_speed(void)
-{
- int i;
- static const uint8_t key[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- const int key_size = sizeof(key);
- static const uint8_t plaintext[512] = { 0 };
- const int plaintext_size = sizeof(plaintext);
- static const uint8_t nonce[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- };
- const int nonce_size = sizeof(nonce);
- uint8_t tag[16] = { 0 };
- const int tag_size = sizeof(tag);
-
- uint8_t *out = tmp;
- static AES_KEY aes_key;
- static GCM128_CONTEXT ctx;
- timestamp_t t0, t1;
-
- assert(plaintext_size <= sizeof(tmp));
-
- t0 = get_time();
- for (i = 0; i < 1000; i++) {
- AES_set_encrypt_key(key, 8 * key_size, &aes_key);
- CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0);
- CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size);
- CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, out,
- plaintext_size);
- CRYPTO_gcm128_tag(&ctx, tag, tag_size);
- }
- t1 = get_time();
- ccprintf("AES-GCM duration %lld us\n", (long long)(t1.val - t0.val));
-}
-
-static int test_aes_raw(const uint8_t *key, int key_size,
- const uint8_t *plaintext, const uint8_t *ciphertext)
-{
- AES_KEY aes_key;
- uint8_t *block = tmp;
-
- TEST_ASSERT(AES_BLOCK_SIZE <= sizeof(tmp));
-
- TEST_ASSERT(AES_set_encrypt_key(key, 8 * key_size, &aes_key) == 0);
-
- /* Test encryption. */
- AES_encrypt(plaintext, block, &aes_key);
- TEST_ASSERT_ARRAY_EQ(ciphertext, block, AES_BLOCK_SIZE);
-
- /* Test in-place encryption. */
- memcpy(block, plaintext, AES_BLOCK_SIZE);
- AES_encrypt(block, block, &aes_key);
- TEST_ASSERT_ARRAY_EQ(ciphertext, block, AES_BLOCK_SIZE);
-
- TEST_ASSERT(AES_set_decrypt_key(key, 8 * key_size, &aes_key) == 0);
-
- /* Test decryption. */
- AES_decrypt(ciphertext, block, &aes_key);
- TEST_ASSERT_ARRAY_EQ(plaintext, block, AES_BLOCK_SIZE);
-
- /* Test in-place decryption. */
- memcpy(block, ciphertext, AES_BLOCK_SIZE);
- AES_decrypt(block, block, &aes_key);
- TEST_ASSERT_ARRAY_EQ(plaintext, block, AES_BLOCK_SIZE);
-
- return EC_SUCCESS;
-}
-
-static int test_aes(void)
-{
- /* Test vectors from FIPS-197, Appendix C. */
- static const uint8_t key1[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- };
- static const uint8_t plain1[] = {
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
- 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
- };
- static const uint8_t cipher1[] = {
- 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
- 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a,
- };
-
- static const uint8_t key2[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- };
- static const uint8_t plain2[] = {
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
- 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
- };
- static const uint8_t cipher2[] = {
- 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
- 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91,
- };
-
- static const uint8_t key3[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- };
- static const uint8_t plain3[] = {
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
- 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
- };
- static const uint8_t cipher3[] = {
- 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
- 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89,
- };
-
- TEST_ASSERT(!test_aes_raw(key1, sizeof(key1), plain1, cipher1));
- TEST_ASSERT(!test_aes_raw(key2, sizeof(key2), plain2, cipher2));
- TEST_ASSERT(!test_aes_raw(key3, sizeof(key3), plain3, cipher3));
-
- return EC_SUCCESS;
-}
-
-static void test_aes_speed(void)
-{
- int i;
- /* Test vectors from FIPS-197, Appendix C. */
- static const uint8_t key[] __aligned(4) = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- };
- const int key_size = sizeof(key);
- static const uint8_t plaintext[] __aligned(4) = {
- 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
- 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
- };
-
- AES_KEY aes_key;
- uint8_t block[AES_BLOCK_SIZE];
- timestamp_t t0, t1;
-
- AES_set_encrypt_key(key, 8 * key_size, &aes_key);
- AES_encrypt(plaintext, block, &aes_key);
- t0 = get_time();
- for (i = 0; i < 1000; i++)
- AES_encrypt(block, block, &aes_key);
- t1 = get_time();
- ccprintf("AES duration %lld us\n", (long long)(t1.val - t0.val));
-}
-
-void run_test(int argc, const char **argv)
-{
- watchdog_reload();
-
- /* do not check result, just as a benchmark */
- test_aes_speed();
-
- watchdog_reload();
- RUN_TEST(test_aes);
-
- /* do not check result, just as a benchmark */
- test_aes_gcm_speed();
-
- watchdog_reload();
- RUN_TEST(test_aes_gcm);
-
- test_print_result();
-}
diff --git a/test/aes.cc b/test/aes.cc
new file mode 100644
index 0000000000..6986abd148
--- /dev/null
+++ b/test/aes.cc
@@ -0,0 +1,601 @@
+/* Copyright 2018 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */
+
+#include "benchmark.h"
+#include "common.h"
+#include "test_util.h"
+
+extern "C" {
+#include "aes.h"
+#include "aes-gcm.h"
+#include "builtin/assert.h"
+#include "console.h"
+#include "timer.h"
+#include "util.h"
+#include "watchdog.h"
+}
+
+/* Temporary buffer, to avoid using too much stack space. */
+static uint8_t tmp[512];
+
+/*
+ * Do encryption, put result in |result|, and compare with |ciphertext|.
+ */
+static int test_aes_gcm_encrypt(uint8_t *result, const uint8_t *key,
+ int key_size, const uint8_t *plaintext,
+ const uint8_t *ciphertext, int plaintext_size,
+ const uint8_t *nonce, int nonce_size,
+ const uint8_t *tag, int tag_size)
+{
+ static AES_KEY aes_key;
+ static GCM128_CONTEXT ctx;
+
+ TEST_ASSERT(AES_set_encrypt_key(key, 8 * key_size, &aes_key) == 0);
+
+ CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0);
+ CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size);
+ TEST_ASSERT(CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, result,
+ plaintext_size));
+ TEST_ASSERT(CRYPTO_gcm128_finish(&ctx, tag, tag_size));
+ TEST_ASSERT_ARRAY_EQ(ciphertext, result, plaintext_size);
+
+ return EC_SUCCESS;
+}
+
+/*
+ * Do decryption, put result in |result|, and compare with |plaintext|.
+ */
+static int test_aes_gcm_decrypt(uint8_t *result, const uint8_t *key,
+ int key_size, const uint8_t *plaintext,
+ const uint8_t *ciphertext, int plaintext_size,
+ const uint8_t *nonce, int nonce_size,
+ const uint8_t *tag, int tag_size)
+{
+ static AES_KEY aes_key;
+ static GCM128_CONTEXT ctx;
+
+ TEST_ASSERT(AES_set_encrypt_key(key, 8 * key_size, &aes_key) == 0);
+
+ CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0);
+ CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size);
+ TEST_ASSERT(CRYPTO_gcm128_decrypt(&ctx, &aes_key, ciphertext, result,
+ plaintext_size));
+ TEST_ASSERT(CRYPTO_gcm128_finish(&ctx, tag, tag_size));
+ TEST_ASSERT_ARRAY_EQ(plaintext, result, plaintext_size);
+
+ return EC_SUCCESS;
+}
+
+static int test_aes_gcm_raw_inplace(const uint8_t *key, int key_size,
+ const uint8_t *plaintext,
+ const uint8_t *ciphertext,
+ int plaintext_size, const uint8_t *nonce,
+ int nonce_size, const uint8_t *tag,
+ int tag_size)
+{
+ /*
+ * Make copies that will be clobbered during in-place encryption or
+ * decryption.
+ */
+ uint8_t plaintext_copy[plaintext_size];
+ uint8_t ciphertext_copy[plaintext_size];
+
+ memcpy(plaintext_copy, plaintext, plaintext_size);
+ memcpy(ciphertext_copy, ciphertext, plaintext_size);
+
+ TEST_ASSERT(test_aes_gcm_encrypt(plaintext_copy, key, key_size,
+ plaintext_copy, ciphertext,
+ plaintext_size, nonce, nonce_size, tag,
+ tag_size) == EC_SUCCESS);
+
+ TEST_ASSERT(test_aes_gcm_decrypt(ciphertext_copy, key, key_size,
+ plaintext, ciphertext_copy,
+ plaintext_size, nonce, nonce_size, tag,
+ tag_size) == EC_SUCCESS);
+
+ return EC_SUCCESS;
+}
+
+static int test_aes_gcm_raw_non_inplace(const uint8_t *key, int key_size,
+ const uint8_t *plaintext,
+ const uint8_t *ciphertext,
+ int plaintext_size,
+ const uint8_t *nonce, int nonce_size,
+ const uint8_t *tag, int tag_size)
+{
+ TEST_ASSERT(test_aes_gcm_encrypt(tmp, key, key_size, plaintext,
+ ciphertext, plaintext_size, nonce,
+ nonce_size, tag,
+ tag_size) == EC_SUCCESS);
+
+ TEST_ASSERT(test_aes_gcm_decrypt(tmp, key, key_size, plaintext,
+ ciphertext, plaintext_size, nonce,
+ nonce_size, tag,
+ tag_size) == EC_SUCCESS);
+
+ return EC_SUCCESS;
+}
+
+static int test_aes_gcm_raw(const uint8_t *key, int key_size,
+ const uint8_t *plaintext, const uint8_t *ciphertext,
+ std::size_t plaintext_size, const uint8_t *nonce,
+ std::size_t nonce_size, const uint8_t *tag,
+ std::size_t tag_size)
+{
+ TEST_ASSERT(plaintext_size <= sizeof(tmp));
+
+ TEST_ASSERT(test_aes_gcm_raw_non_inplace(key, key_size, plaintext,
+ ciphertext, plaintext_size,
+ nonce, nonce_size, tag,
+ tag_size) == EC_SUCCESS);
+ TEST_ASSERT(test_aes_gcm_raw_inplace(key, key_size, plaintext,
+ ciphertext, plaintext_size, nonce,
+ nonce_size, tag,
+ tag_size) == EC_SUCCESS);
+
+ return EC_SUCCESS;
+}
+
+static int test_aes_gcm(void)
+{
+ /*
+ * Test vectors from BoringSSL crypto/fipsmodule/modes/gcm_tests.txt
+ * (only the ones with actual data, and no additional data).
+ */
+ static const uint8_t key1[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const uint8_t plain1[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const uint8_t nonce1[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const uint8_t cipher1[] = {
+ 0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92,
+ 0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78,
+ };
+ static const uint8_t tag1[] = {
+ 0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd,
+ 0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf,
+ };
+
+ static const uint8_t key2[] = {
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
+ };
+ static const uint8_t plain2[] = {
+ 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59,
+ 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53,
+ 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31,
+ 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+ 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a,
+ 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39,
+ 0x1a, 0xaf, 0xd2, 0x55,
+ };
+ static const uint8_t nonce2[] = {
+ 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce,
+ 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88,
+ };
+ static const uint8_t cipher2[] = {
+ 0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24, 0x4b, 0x72,
+ 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c, 0xe3, 0xaa, 0x21, 0x2f,
+ 0x2c, 0x02, 0xa4, 0xe0, 0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac,
+ 0xa1, 0x2e, 0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
+ 0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05, 0x1b, 0xa3,
+ 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97, 0x3d, 0x58, 0xe0, 0x91,
+ 0x47, 0x3f, 0x59, 0x85,
+ };
+ static const uint8_t tag2[] = {
+ 0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6,
+ 0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4,
+ };
+
+ static const uint8_t key3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const uint8_t plain3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const uint8_t nonce3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const uint8_t cipher3[] = {
+ 0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41,
+ 0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00,
+ };
+ static const uint8_t tag3[] = {
+ 0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab,
+ 0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb,
+ };
+
+ static const uint8_t key4[] = {
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ };
+ static const uint8_t plain4[] = {
+ 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59,
+ 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53,
+ 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31,
+ 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+ 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a,
+ 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39,
+ 0x1a, 0xaf, 0xd2, 0x55,
+ };
+ static const uint8_t nonce4[] = {
+ 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce,
+ 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88,
+ };
+ static const uint8_t cipher4[] = {
+ 0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41, 0xeb, 0x06,
+ 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57, 0x85, 0x9e, 0x1c, 0xea,
+ 0xa6, 0xef, 0xd9, 0x84, 0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1,
+ 0xe1, 0x9c, 0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25,
+ 0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47, 0x18, 0xe2,
+ 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9, 0xcc, 0xda, 0x27, 0x10,
+ 0xac, 0xad, 0xe2, 0x56,
+ };
+ static const uint8_t tag4[] = {
+ 0x99, 0x24, 0xa7, 0xc8, 0x58, 0x73, 0x36, 0xbf,
+ 0xb1, 0x18, 0x02, 0x4d, 0xb8, 0x67, 0x4a, 0x14,
+ };
+
+ static const uint8_t key5[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const uint8_t plain5[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const uint8_t nonce5[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const uint8_t cipher5[] = {
+ 0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e,
+ 0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18,
+ };
+ static const uint8_t tag5[] = {
+ 0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0,
+ 0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19,
+ };
+
+ static const uint8_t key6[] = {
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
+ 0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
+ 0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
+ };
+ static const uint8_t plain6[] = {
+ 0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5, 0xa5, 0x59,
+ 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a, 0x86, 0xa7, 0xa9, 0x53,
+ 0x15, 0x34, 0xf7, 0xda, 0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31,
+ 0x8a, 0x72, 0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
+ 0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25, 0xb1, 0x6a,
+ 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57, 0xba, 0x63, 0x7b, 0x39,
+ 0x1a, 0xaf, 0xd2, 0x55,
+ };
+ static const uint8_t nonce6[] = {
+ 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce,
+ 0xdb, 0xad, 0xde, 0xca, 0xf8, 0x88,
+ };
+ static const uint8_t cipher6[] = {
+ 0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07, 0xf4, 0x7f,
+ 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d, 0x64, 0x3a, 0x8c, 0xdc,
+ 0xbf, 0xe5, 0xc0, 0xc9, 0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55,
+ 0xd1, 0xaa, 0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
+ 0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38, 0xc5, 0xf6,
+ 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a, 0xbc, 0xc9, 0xf6, 0x62,
+ 0x89, 0x80, 0x15, 0xad,
+ };
+ static const uint8_t tag6[] = {
+ 0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd,
+ 0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c,
+ };
+
+ static const uint8_t key7[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ static const uint8_t plain7[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ /* This nonce results in 0xfff in counter LSB. */
+ static const uint8_t nonce7[] = {
+ 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00,
+ };
+ static const uint8_t cipher7[] = {
+ 0x56, 0xb3, 0x37, 0x3c, 0xa9, 0xef, 0x6e, 0x4a, 0x2b, 0x64,
+ 0xfe, 0x1e, 0x9a, 0x17, 0xb6, 0x14, 0x25, 0xf1, 0x0d, 0x47,
+ 0xa7, 0x5a, 0x5f, 0xce, 0x13, 0xef, 0xc6, 0xbc, 0x78, 0x4a,
+ 0xf2, 0x4f, 0x41, 0x41, 0xbd, 0xd4, 0x8c, 0xf7, 0xc7, 0x70,
+ 0x88, 0x7a, 0xfd, 0x57, 0x3c, 0xca, 0x54, 0x18, 0xa9, 0xae,
+ 0xff, 0xcd, 0x7c, 0x5c, 0xed, 0xdf, 0xc6, 0xa7, 0x83, 0x97,
+ 0xb9, 0xa8, 0x5b, 0x49, 0x9d, 0xa5, 0x58, 0x25, 0x72, 0x67,
+ 0xca, 0xab, 0x2a, 0xd0, 0xb2, 0x3c, 0xa4, 0x76, 0xa5, 0x3c,
+ 0xb1, 0x7f, 0xb4, 0x1c, 0x4b, 0x8b, 0x47, 0x5c, 0xb4, 0xf3,
+ 0xf7, 0x16, 0x50, 0x94, 0xc2, 0x29, 0xc9, 0xe8, 0xc4, 0xdc,
+ 0x0a, 0x2a, 0x5f, 0xf1, 0x90, 0x3e, 0x50, 0x15, 0x11, 0x22,
+ 0x13, 0x76, 0xa1, 0xcd, 0xb8, 0x36, 0x4c, 0x50, 0x61, 0xa2,
+ 0x0c, 0xae, 0x74, 0xbc, 0x4a, 0xcd, 0x76, 0xce, 0xb0, 0xab,
+ 0xc9, 0xfd, 0x32, 0x17, 0xef, 0x9f, 0x8c, 0x90, 0xbe, 0x40,
+ 0x2d, 0xdf, 0x6d, 0x86, 0x97, 0xf4, 0xf8, 0x80, 0xdf, 0xf1,
+ 0x5b, 0xfb, 0x7a, 0x6b, 0x28, 0x24, 0x1e, 0xc8, 0xfe, 0x18,
+ 0x3c, 0x2d, 0x59, 0xe3, 0xf9, 0xdf, 0xff, 0x65, 0x3c, 0x71,
+ 0x26, 0xf0, 0xac, 0xb9, 0xe6, 0x42, 0x11, 0xf4, 0x2b, 0xae,
+ 0x12, 0xaf, 0x46, 0x2b, 0x10, 0x70, 0xbe, 0xf1, 0xab, 0x5e,
+ 0x36, 0x06, 0x87, 0x2c, 0xa1, 0x0d, 0xee, 0x15, 0xb3, 0x24,
+ 0x9b, 0x1a, 0x1b, 0x95, 0x8f, 0x23, 0x13, 0x4c, 0x4b, 0xcc,
+ 0xb7, 0xd0, 0x32, 0x00, 0xbc, 0xe4, 0x20, 0xa2, 0xf8, 0xeb,
+ 0x66, 0xdc, 0xf3, 0x64, 0x4d, 0x14, 0x23, 0xc1, 0xb5, 0x69,
+ 0x90, 0x03, 0xc1, 0x3e, 0xce, 0xf4, 0xbf, 0x38, 0xa3, 0xb6,
+ 0x0e, 0xed, 0xc3, 0x40, 0x33, 0xba, 0xc1, 0x90, 0x27, 0x83,
+ 0xdc, 0x6d, 0x89, 0xe2, 0xe7, 0x74, 0x18, 0x8a, 0x43, 0x9c,
+ 0x7e, 0xbc, 0xc0, 0x67, 0x2d, 0xbd, 0xa4, 0xdd, 0xcf, 0xb2,
+ 0x79, 0x46, 0x13, 0xb0, 0xbe, 0x41, 0x31, 0x5e, 0xf7, 0x78,
+ 0x70, 0x8a, 0x70, 0xee, 0x7d, 0x75, 0x16, 0x5c,
+ };
+ static const uint8_t tag7[] = {
+ 0x8b, 0x30, 0x7f, 0x6b, 0x33, 0x28, 0x6d, 0x0a,
+ 0xb0, 0x26, 0xa9, 0xed, 0x3f, 0xe1, 0xe8, 0x5f,
+ };
+
+ TEST_ASSERT(!test_aes_gcm_raw(key1, sizeof(key1), plain1, cipher1,
+ sizeof(plain1), nonce1, sizeof(nonce1),
+ tag1, sizeof(tag1)));
+ TEST_ASSERT(!test_aes_gcm_raw(key2, sizeof(key2), plain2, cipher2,
+ sizeof(plain2), nonce2, sizeof(nonce2),
+ tag2, sizeof(tag2)));
+ TEST_ASSERT(!test_aes_gcm_raw(key3, sizeof(key3), plain3, cipher3,
+ sizeof(plain3), nonce3, sizeof(nonce3),
+ tag3, sizeof(tag3)));
+ TEST_ASSERT(!test_aes_gcm_raw(key4, sizeof(key4), plain4, cipher4,
+ sizeof(plain4), nonce4, sizeof(nonce4),
+ tag4, sizeof(tag4)));
+ TEST_ASSERT(!test_aes_gcm_raw(key5, sizeof(key5), plain5, cipher5,
+ sizeof(plain5), nonce5, sizeof(nonce5),
+ tag5, sizeof(tag5)));
+ TEST_ASSERT(!test_aes_gcm_raw(key6, sizeof(key6), plain6, cipher6,
+ sizeof(plain6), nonce6, sizeof(nonce6),
+ tag6, sizeof(tag6)));
+ TEST_ASSERT(!test_aes_gcm_raw(key7, sizeof(key7), plain7, cipher7,
+ sizeof(plain7), nonce7, sizeof(nonce7),
+ tag7, sizeof(tag7)));
+
+ return EC_SUCCESS;
+}
+
+static void test_aes_gcm_speed(void)
+{
+ Benchmark benchmark({ .num_iterations = 1000 });
+ static const uint8_t key[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ const int key_size = sizeof(key);
+ static uint8_t plaintext[512] = { 0 };
+ const auto plaintext_size = sizeof(plaintext);
+ static const uint8_t nonce[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ };
+ const int nonce_size = sizeof(nonce);
+ uint8_t tag[16] = { 0 };
+ const int tag_size = sizeof(tag);
+
+ uint8_t *encrypted_data = tmp;
+ static AES_KEY aes_key;
+ static GCM128_CONTEXT ctx;
+
+ assert(plaintext_size <= sizeof(tmp));
+
+ benchmark.run("AES-GCM encrypt", [&]() {
+ AES_set_encrypt_key(key, 8 * key_size, &aes_key);
+ CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0);
+ CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size);
+ CRYPTO_gcm128_encrypt(&ctx, &aes_key, plaintext, encrypted_data,
+ plaintext_size);
+ CRYPTO_gcm128_tag(&ctx, tag, tag_size);
+ });
+
+ benchmark.run("AES-GCM decrypt", [&]() {
+ AES_set_encrypt_key(key, 8 * key_size, &aes_key);
+ CRYPTO_gcm128_init(&ctx, &aes_key, (block128_f)AES_encrypt, 0);
+ CRYPTO_gcm128_setiv(&ctx, &aes_key, nonce, nonce_size);
+ auto decrypt_res =
+ CRYPTO_gcm128_decrypt(&ctx, &aes_key, encrypted_data,
+ plaintext, plaintext_size);
+
+ auto finish_res = CRYPTO_gcm128_finish(&ctx, tag, tag_size);
+ assert(decrypt_res);
+ assert(finish_res);
+ });
+ benchmark.print_results();
+}
+
+static int test_aes_raw(const uint8_t *key, int key_size,
+ const uint8_t *plaintext, const uint8_t *ciphertext)
+{
+ AES_KEY aes_key;
+ uint8_t *block = tmp;
+
+ TEST_ASSERT(AES_BLOCK_SIZE <= sizeof(tmp));
+
+ TEST_ASSERT(AES_set_encrypt_key(key, 8 * key_size, &aes_key) == 0);
+
+ /* Test encryption. */
+ AES_encrypt(plaintext, block, &aes_key);
+ TEST_ASSERT_ARRAY_EQ(ciphertext, block, AES_BLOCK_SIZE);
+
+ /* Test in-place encryption. */
+ memcpy(block, plaintext, AES_BLOCK_SIZE);
+ AES_encrypt(block, block, &aes_key);
+ TEST_ASSERT_ARRAY_EQ(ciphertext, block, AES_BLOCK_SIZE);
+
+ TEST_ASSERT(AES_set_decrypt_key(key, 8 * key_size, &aes_key) == 0);
+
+ /* Test decryption. */
+ AES_decrypt(ciphertext, block, &aes_key);
+ TEST_ASSERT_ARRAY_EQ(plaintext, block, AES_BLOCK_SIZE);
+
+ /* Test in-place decryption. */
+ memcpy(block, ciphertext, AES_BLOCK_SIZE);
+ AES_decrypt(block, block, &aes_key);
+ TEST_ASSERT_ARRAY_EQ(plaintext, block, AES_BLOCK_SIZE);
+
+ return EC_SUCCESS;
+}
+
+static int test_aes(void)
+{
+ /* Test vectors from FIPS-197, Appendix C. */
+ static const uint8_t key1[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ };
+ static const uint8_t plain1[] = {
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
+ };
+ static const uint8_t cipher1[] = {
+ 0x69, 0xc4, 0xe0, 0xd8, 0x6a, 0x7b, 0x04, 0x30,
+ 0xd8, 0xcd, 0xb7, 0x80, 0x70, 0xb4, 0xc5, 0x5a,
+ };
+
+ static const uint8_t key2[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ };
+ static const uint8_t plain2[] = {
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
+ };
+ static const uint8_t cipher2[] = {
+ 0xdd, 0xa9, 0x7c, 0xa4, 0x86, 0x4c, 0xdf, 0xe0,
+ 0x6e, 0xaf, 0x70, 0xa0, 0xec, 0x0d, 0x71, 0x91,
+ };
+
+ static const uint8_t key3[] = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+ 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+ };
+ static const uint8_t plain3[] = {
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
+ };
+ static const uint8_t cipher3[] = {
+ 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf,
+ 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89,
+ };
+
+ TEST_ASSERT(!test_aes_raw(key1, sizeof(key1), plain1, cipher1));
+ TEST_ASSERT(!test_aes_raw(key2, sizeof(key2), plain2, cipher2));
+ TEST_ASSERT(!test_aes_raw(key3, sizeof(key3), plain3, cipher3));
+
+ return EC_SUCCESS;
+}
+
+static void test_aes_speed(void)
+{
+ Benchmark benchmark({ .num_iterations = 1000 });
+ /* Test vectors from FIPS-197, Appendix C. */
+ static const uint8_t key[] __aligned(4) = {
+ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+ 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+ };
+ const int key_size = sizeof(key);
+ static const uint8_t plaintext[] __aligned(4) = {
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
+ };
+
+ AES_KEY aes_key;
+ uint8_t block[AES_BLOCK_SIZE];
+
+ AES_set_encrypt_key(key, 8 * key_size, &aes_key);
+ AES_encrypt(plaintext, block, &aes_key);
+ benchmark.run("AES", [&block, &aes_key]() {
+ AES_encrypt(block, block, &aes_key);
+ });
+ benchmark.print_results();
+}
+
+void run_test(int argc, const char **argv)
+{
+ watchdog_reload();
+
+ /* do not check result, just as a benchmark */
+ test_aes_speed();
+
+ watchdog_reload();
+ RUN_TEST(test_aes);
+
+ /* do not check result, just as a benchmark */
+ test_aes_gcm_speed();
+
+ watchdog_reload();
+ RUN_TEST(test_aes_gcm);
+
+ test_print_result();
+}
diff --git a/test/always_memset.c b/test/always_memset.c
index 40a68d883b..eed15cab27 100644
--- a/test/always_memset.c
+++ b/test/always_memset.c
@@ -10,12 +10,11 @@
* If optimization is disabled, the test_optimization_working test will fail.
*/
-#include <string.h>
-
#include "common.h"
+#include "cryptoc/util.h"
#include "test_util.h"
-#include "cryptoc/util.h"
+#include <string.h>
/* 256 bytes of stack is only safe enough for a memcpy. */
#define EXTRA_STACK_SIZE 256
diff --git a/test/base32.c b/test/base32.c
index c1ec489ea0..50b9d994c1 100644
--- a/test/base32.c
+++ b/test/base32.c
@@ -5,12 +5,13 @@
* Test Base-32 encoding/decoding
*/
-#include <stdio.h>
-#include "common.h"
#include "base32.h"
+#include "common.h"
#include "test_util.h"
#include "util.h"
+#include <stdio.h>
+
DECLARE_EC_TEST(test_crc5)
{
uint32_t seen;
diff --git a/test/benchmark.cc b/test/benchmark.cc
new file mode 100644
index 0000000000..e28bfbd999
--- /dev/null
+++ b/test/benchmark.cc
@@ -0,0 +1,98 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Simple test to validate the benchmark library.
+ */
+
+#include "benchmark.h"
+
+extern "C" {
+#include "test_util.h"
+}
+
+/* Sample function for the benchmark */
+static void float_mult()
+{
+ float a = 1.1;
+ float b = 1.1;
+ int i;
+
+ for (i = 0; i < 1000; ++i)
+ a *= b;
+}
+
+test_static int test_valid_benchmark()
+{
+ Benchmark benchmark;
+
+ auto result = benchmark.run("float_mult", float_mult);
+ TEST_ASSERT(result.has_value());
+
+ benchmark.print_results();
+ return EC_SUCCESS;
+}
+
+test_static int test_num_iterations()
+{
+ Benchmark benchmark({ .num_iterations = 5 });
+ int num_calls = 0;
+
+ auto result = benchmark.run("call_counter", [&] { ++num_calls; });
+ TEST_ASSERT(result.has_value());
+ TEST_EQ(num_calls, 5, "%d");
+
+ return EC_SUCCESS;
+}
+
+test_static int test_empty_benchmark_name()
+{
+ Benchmark benchmark;
+ TEST_ASSERT(!benchmark.run("", [] {}).has_value());
+ return EC_SUCCESS;
+}
+
+test_static int test_too_many_runs()
+{
+ auto benchmark = Benchmark<3>();
+ TEST_ASSERT(benchmark.run("call_1", [] {}).has_value());
+ TEST_ASSERT(benchmark.run("call_2", [] {}).has_value());
+ TEST_ASSERT(benchmark.run("call_3", [] {}).has_value());
+ TEST_ASSERT(!benchmark.run("call_4", [] {}).has_value());
+
+ return EC_SUCCESS;
+}
+
+test_static int test_min_max_time()
+{
+ // Run test 3 times with increasing delay of 1ms, 2ms, and 4ms
+ Benchmark benchmark({ .num_iterations = 3 });
+ int delay_us = 1000;
+
+ auto result = benchmark.run("delay", [&delay_us] {
+ udelay(delay_us);
+ delay_us *= 2;
+ });
+ TEST_ASSERT(result.has_value());
+
+ auto min_time = result.value().min_time;
+ auto max_time = result.value().max_time;
+
+ TEST_GE(min_time, 995U, "%u");
+ TEST_LE(min_time, 1005U, "%u");
+ TEST_GE(max_time, 3995U, "%u");
+ TEST_LE(max_time, 4005U, "%u");
+
+ return EC_SUCCESS;
+}
+
+void run_test(int argc, const char **argv)
+{
+ test_reset();
+ RUN_TEST(test_valid_benchmark);
+ RUN_TEST(test_num_iterations);
+ RUN_TEST(test_too_many_runs);
+ RUN_TEST(test_empty_benchmark_name);
+ RUN_TEST(test_min_max_time);
+ test_print_result();
+}
diff --git a/test/benchmark.tasklist b/test/benchmark.tasklist
new file mode 100644
index 0000000000..6d43377af5
--- /dev/null
+++ b/test/benchmark.tasklist
@@ -0,0 +1,9 @@
+/* Copyright 2022 The ChromiumOS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * See CONFIG_TASK_LIST in config.h for details.
+ */
+#define CONFIG_TEST_TASK_LIST
diff --git a/test/build.mk b/test/build.mk
index 08e2d15c9f..30908d309e 100644
--- a/test/build.mk
+++ b/test/build.mk
@@ -24,6 +24,7 @@ test-list-host += aes
test-list-host += always_memset
test-list-host += base32
test-list-host += battery_get_params_smart
+test-list-host += benchmark
test-list-host += bklight_lid
test-list-host += bklight_passthru
test-list-host += body_detection
@@ -169,6 +170,7 @@ aes-y=aes.o
always_memset-y=always_memset.o
base32-y=base32.o
battery_get_params_smart-y=battery_get_params_smart.o
+benchmark-y=benchmark.o
bklight_lid-y=bklight_lid.o
bklight_passthru-y=bklight_passthru.o
body_detection-y=body_detection.o body_detection_data_literals.o motion_common.o
@@ -196,6 +198,7 @@ fpsensor-y=fpsensor.o
fpsensor_crypto-y=fpsensor_crypto.o
fpsensor_hw-y=fpsensor_hw.o
fpsensor_state-y=fpsensor_state.o
+ftrapv-y=ftrapv.o
gyro_cal-y=gyro_cal.o gyro_cal_init_for_test.o
hooks-y=hooks.o
host_command-y=host_command.o
@@ -221,6 +224,9 @@ online_calibration-y=online_calibration.o
online_calibration_spoof-y=online_calibration_spoof.o gyro_cal_init_for_test.o
rgb_keyboard-y=rgb_keyboard.o
kasa-y=kasa.o
+ifeq ($(USE_BUILTIN_STDLIB), 0)
+libc_printf-y=libc_printf.o
+endif
mpu-y=mpu.o
mutex-y=mutex.o
newton_fit-y=newton_fit.o
@@ -231,6 +237,7 @@ power_button-y=power_button.o
powerdemo-y=powerdemo.o
printf-y=printf.o
queue-y=queue.o
+rng_benchmark-y=rng_benchmark.o
rollback-y=rollback.o
rollback_entropy-y=rollback_entropy.o
rollback_secret-y=rollback_secret.o
diff --git a/test/button.c b/test/button.c
index c1acba7048..3a46625660 100644
--- a/test/button.c
+++ b/test/button.c
@@ -15,10 +15,10 @@
#include "console.h"
#include "gpio.h"
#include "host_command.h"
-#include "test_util.h"
-#include "timer.h"
#include "keyboard_config.h"
#include "keyboard_protocol.h"
+#include "test_util.h"
+#include "timer.h"
#include "util.h"
#define UNCHANGED -1
diff --git a/test/cec.c b/test/cec.c
index 7718b7b705..6d385665a8 100644
--- a/test/cec.c
+++ b/test/cec.c
@@ -5,11 +5,11 @@
* Test the buffer handling of HDMI CEC
*/
-#include <string.h>
-
#include "cec.h"
#include "test_util.h"
+#include <string.h>
+
struct overflow_msg {
struct cec_msg_transfer transfer;
uint8_t overflow_detector;
diff --git a/test/charge_manager.c b/test/charge_manager.c
index 9a27a419d0..9d1c888e9d 100644
--- a/test/charge_manager.c
+++ b/test/charge_manager.c
@@ -34,8 +34,8 @@ static int new_power_request[CONFIG_USB_PD_PORT_MAX_COUNT];
static enum pd_power_role power_role[CONFIG_USB_PD_PORT_MAX_COUNT];
/* Callback functions called by CM on state change */
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
active_charge_limit = charge_ma;
}
diff --git a/test/charge_ramp.c b/test/charge_ramp.c
index a4d53b31d6..056fa67c21 100644
--- a/test/charge_ramp.c
+++ b/test/charge_ramp.c
@@ -73,8 +73,8 @@ int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state)
vbus_low_current_ma;
}
-void board_set_charge_limit(int port, int supplier, int limit_ma, int max_ma,
- int max_mv)
+__override void board_set_charge_limit(int port, int supplier, int limit_ma,
+ int max_ma, int max_mv)
{
charge_limit_ma = limit_ma;
if (charge_limit_ma > overcurrent_current_ma)
diff --git a/test/compile_time_macros.c b/test/compile_time_macros.c
index 544da9e0d8..5e5d716627 100644
--- a/test/compile_time_macros.c
+++ b/test/compile_time_macros.c
@@ -5,8 +5,8 @@
* Test compile_time_macros.h
*/
-#include "stdbool.h"
#include "common.h"
+#include "stdbool.h"
#include "test_util.h"
static int test_BIT(void)
diff --git a/test/console_edit.c b/test/console_edit.c
index b9753468fd..5ec649be5f 100644
--- a/test/console_edit.c
+++ b/test/console_edit.c
@@ -7,11 +7,11 @@
#include "common.h"
#include "console.h"
+#include "ec_commands.h"
#include "test_util.h"
#include "timer.h"
-#include "util.h"
#include "uart.h"
-#include "ec_commands.h"
+#include "util.h"
static int cmd_1_call_cnt;
static int cmd_2_call_cnt;
diff --git a/test/cortexm_fpu.c b/test/cortexm_fpu.c
index c27edbaf40..f31ec63535 100644
--- a/test/cortexm_fpu.c
+++ b/test/cortexm_fpu.c
@@ -3,12 +3,11 @@
* found in the LICENSE file.
*/
-#include "test_util.h"
-
#include "cpu.h"
#include "math.h"
#include "registers.h"
#include "task.h"
+#include "test_util.h"
#include "time.h"
static volatile uint32_t fpscr;
diff --git a/test/entropy.c b/test/entropy.c
index 8fbdb9147f..abac349d76 100644
--- a/test/entropy.c
+++ b/test/entropy.c
@@ -5,8 +5,8 @@
* Tests entropy source.
*/
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "rollback.h"
#include "test_util.h"
#include "timer.h"
diff --git a/test/fake_usbc.c b/test/fake_usbc.c
index 1d9c42a97a..6a2cab09aa 100644
--- a/test/fake_usbc.c
+++ b/test/fake_usbc.c
@@ -5,9 +5,9 @@
* Test USB Type-C module.
*/
#include "common.h"
-#include "usb_tc_sm.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
+#include "usb_tc_sm.h"
__overridable int pd_is_vbus_present(int port)
{
@@ -304,7 +304,7 @@ void dpm_set_mode_exit_request(int port)
{
}
-void dpm_run(int port)
+void dpm_run(int port, int evt, int enable)
{
}
@@ -351,6 +351,10 @@ void dpm_handle_alert(int port, uint32_t ado)
{
}
+void dpm_set_pe_ready(int port, bool enable)
+{
+}
+
static enum tcpc_rp_value lcl_rp;
__overridable void typec_select_src_current_limit_rp(int port,
enum tcpc_rp_value rp)
diff --git a/test/fp.c b/test/fp.c
index ab41868578..135670f47a 100644
--- a/test/fp.c
+++ b/test/fp.c
@@ -8,7 +8,6 @@
* early. e.g. CONFIG_FPU, which is needed in math_util.h.
*/
#include "common.h"
-
#include "mat33.h"
#include "mat44.h"
#include "math.h"
diff --git a/test/fpsensor.c b/test/fpsensor.c
index 588374d4db..2daaa0d2cf 100644
--- a/test/fpsensor.c
+++ b/test/fpsensor.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <stddef.h>
-#include <stdbool.h>
-
+#include "common/fpsensor/fpsensor_private.h"
#include "ec_commands.h"
#include "mock/fpsensor_detect_mock.h"
#include "string.h"
#include "test_util.h"
-#include "common/fpsensor/fpsensor_private.h"
+
+#include <stdbool.h>
+#include <stddef.h>
static const struct ec_response_get_protocol_info expected_info[] = {
[FP_TRANSPORT_TYPE_SPI] = {
diff --git a/test/fpsensor_crypto.c b/test/fpsensor_crypto.c
index 9265a608b4..238f2b3452 100644
--- a/test/fpsensor_crypto.c
+++ b/test/fpsensor_crypto.c
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdbool.h>
-
#include "builtin/assert.h"
#include "common.h"
#include "ec_commands.h"
@@ -17,6 +15,8 @@
#include "test_util.h"
#include "util.h"
+#include <stdbool.h>
+
extern int get_ikm(uint8_t *ikm);
static const uint8_t fake_positive_match_salt[] = {
diff --git a/test/fpsensor_hw.c b/test/fpsensor_hw.c
deleted file mode 100644
index ff5b78ace2..0000000000
--- a/test/fpsensor_hw.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "common.h"
-#include "test_util.h"
-#include "fpc_private.h"
-#include "board.h"
-
-#ifdef SECTION_IS_RW
-#include "fpc/fpc_sensor.h"
-static const uint32_t fp_sensor_hwid = FP_SENSOR_HWID;
-#else
-static const uint32_t fp_sensor_hwid = UINT32_MAX;
-#endif
-
-/* Hardware-dependent smoke test that makes a SPI transaction with the
- * fingerprint sensor.
- */
-test_static int test_fp_check_hwid(void)
-{
- uint16_t id = 0;
-
- if (IS_ENABLED(SECTION_IS_RW)) {
- TEST_EQ(fpc_get_hwid(&id), EC_SUCCESS, "%d");
- /* The lower 4-bits of the sensor hardware id are a
- * manufacturing ID that is ok to vary.
- */
- TEST_EQ(fp_sensor_hwid, id >> 4, "%d");
- };
- return EC_SUCCESS;
-}
-
-void run_test(int argc, const char **argv)
-{
- RUN_TEST(test_fp_check_hwid);
- test_print_result();
-}
diff --git a/test/fpsensor_hw.cc b/test/fpsensor_hw.cc
new file mode 100644
index 0000000000..3d4a6c95dd
--- /dev/null
+++ b/test/fpsensor_hw.cc
@@ -0,0 +1,39 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "test_util.h"
+#include "fpc_private.h"
+#include "board.h"
+
+#ifdef SECTION_IS_RW
+#include "fpc/fpc_sensor.h"
+static const uint32_t fp_sensor_hwid = FP_SENSOR_HWID;
+#else
+static const uint32_t fp_sensor_hwid = UINT32_MAX;
+#endif
+
+/* Hardware-dependent smoke test that makes a SPI transaction with the
+ * fingerprint sensor.
+ */
+test_static int test_fp_check_hwid(void)
+{
+ uint16_t id = 0;
+
+ if (IS_ENABLED(SECTION_IS_RW)) {
+ TEST_EQ(fpc_get_hwid(&id), EC_SUCCESS, "%d");
+ /* The lower 4-bits of the sensor hardware id are a
+ * manufacturing ID that is ok to vary.
+ */
+ TEST_EQ(fp_sensor_hwid, id >> 4, "%d");
+ };
+ return EC_SUCCESS;
+}
+
+extern "C" void run_test(int argc, const char **argv)
+{
+ RUN_TEST(test_fp_check_hwid);
+ test_print_result();
+}
diff --git a/test/fpsensor_state.c b/test/fpsensor_state.c
index 0b61e1c2d4..771523b33b 100644
--- a/test/fpsensor_state.c
+++ b/test/fpsensor_state.c
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdbool.h>
-
#include "common.h"
#include "ec_commands.h"
#include "fpsensor_state.h"
@@ -12,6 +10,8 @@
#include "test_util.h"
#include "util.h"
+#include <stdbool.h>
+
test_static int test_fp_enc_status_valid_flags(void)
{
/* Putting expected value here because test_static should take void */
diff --git a/test/ftrapv.c b/test/ftrapv.c
new file mode 100644
index 0000000000..1aefb8404f
--- /dev/null
+++ b/test/ftrapv.c
@@ -0,0 +1,265 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "panic.h"
+#include "system.h"
+#include "task.h"
+#include "test_util.h"
+
+#include <stdlib.h>
+
+/*
+ * trapping addition: __addvsi3.
+ */
+test_static int test_ftrapv_addition(void)
+{
+ int32_t test_overflow = INT32_MAX;
+ int32_t ret;
+
+ ccprintf("Testing signed integer addition overflow\n");
+ cflush();
+ ret = test_overflow + 1;
+
+ /* Should never reach this. */
+ ccprintf("ret: %d\n", ret);
+ cflush();
+
+ return EC_ERROR_UNKNOWN;
+}
+
+/*
+ * trapping subtraction: __subvsi3.
+ */
+test_static int test_ftrapv_subtraction(void)
+{
+ int32_t test_overflow = INT32_MIN;
+ int32_t ret;
+
+ ccprintf("Testing signed integer subtraction overflow\n");
+ cflush();
+ ret = test_overflow - 1;
+
+ /* Should never reach this. */
+ ccprintf("ret: %d\n", ret);
+ cflush();
+
+ return EC_ERROR_UNKNOWN;
+}
+
+/*
+ * trapping multiplication: __mulvsi3.
+ */
+test_static int test_ftrapv_multiplication(void)
+{
+ int32_t test_overflow = INT32_MAX;
+ int32_t ret;
+
+ ccprintf("Testing signed integer multiplication overflow\n");
+ cflush();
+ ret = test_overflow * 2;
+
+ /* Should never reach this. */
+ ccprintf("ret: %d\n", ret);
+ cflush();
+
+ return EC_ERROR_UNKNOWN;
+}
+
+/*
+ * trapping negation: __negvsi2.
+ */
+test_static int test_ftrapv_negation(void)
+{
+ int32_t test_overflow = INT32_MIN;
+ int32_t ret;
+
+ ccprintf("Testing signed integer negation overflow\n");
+ cflush();
+ ret = -test_overflow;
+
+ /* Should never reach this. */
+ ccprintf("ret: %d\n", ret);
+ cflush();
+
+ return EC_ERROR_UNKNOWN;
+}
+
+/*
+ * trapping absolute value: __absvsi2.
+ *
+ * TODO(b/258074414): Trapping on absolute value overflow is broken in clang.
+ */
+test_static int test_ftrapv_absolute_value(void)
+{
+ int32_t test_overflow = INT32_MIN;
+ int32_t ret;
+
+ ccprintf("Testing signed integer absolute value overflow\n");
+ cflush();
+
+ ret = abs(test_overflow);
+
+ /* Should never reach this. */
+ ccprintf("ret: %d\n", ret);
+ cflush();
+
+ return EC_ERROR_UNKNOWN;
+}
+
+test_static int test_panic_data(void)
+{
+ const uint32_t expected_reason = 0;
+ const uint32_t expected_info = 0;
+ /*
+ * https://developer.arm.com/documentation/dui0552/a/the-cortex-m3-processor/exception-model/exception-types
+ */
+ const uint8_t expected_exception = 6; /* usage fault */
+
+ uint32_t reason = UINT32_MAX;
+ uint32_t info = UINT32_MAX;
+ uint8_t exception = UINT8_MAX;
+
+ panic_get_reason(&reason, &info, &exception);
+
+ TEST_EQ(reason, expected_reason, "%08x");
+ TEST_EQ(info, expected_info, "%d");
+ TEST_EQ(exception, expected_exception, "%d");
+
+ return EC_SUCCESS;
+}
+
+test_static void run_test_step1(void)
+{
+ test_set_next_step(TEST_STATE_STEP_2);
+ RUN_TEST(test_ftrapv_addition);
+}
+
+test_static void run_test_step2(void)
+{
+ RUN_TEST(test_panic_data);
+
+ if (test_get_error_count())
+ test_reboot_to_next_step(TEST_STATE_FAILED);
+ else
+ test_reboot_to_next_step(TEST_STATE_STEP_3);
+}
+
+test_static void run_test_step3(void)
+{
+ test_set_next_step(TEST_STATE_STEP_4);
+ RUN_TEST(test_ftrapv_subtraction);
+}
+
+test_static void run_test_step4(void)
+{
+ RUN_TEST(test_panic_data);
+
+ if (test_get_error_count())
+ test_reboot_to_next_step(TEST_STATE_FAILED);
+ else
+ test_reboot_to_next_step(TEST_STATE_STEP_5);
+}
+
+test_static void run_test_step5(void)
+{
+ test_set_next_step(TEST_STATE_STEP_6);
+ RUN_TEST(test_ftrapv_multiplication);
+}
+
+test_static void run_test_step6(void)
+{
+ RUN_TEST(test_panic_data);
+
+ if (test_get_error_count())
+ test_reboot_to_next_step(TEST_STATE_FAILED);
+ else
+ test_reboot_to_next_step(TEST_STATE_STEP_7);
+}
+
+test_static void run_test_step7(void)
+{
+ test_set_next_step(TEST_STATE_STEP_8);
+ RUN_TEST(test_ftrapv_negation);
+}
+
+test_static void run_test_step8(void)
+{
+ RUN_TEST(test_panic_data);
+
+ if (test_get_error_count())
+ test_reboot_to_next_step(TEST_STATE_FAILED);
+ else
+ test_reboot_to_next_step(TEST_STATE_STEP_9);
+}
+
+test_static void run_test_step9(void)
+{
+ /*
+ * TODO(b/258074414): Trapping on absolute value overflow is broken in
+ * clang, so skip the check.
+ */
+#if 0
+ test_set_next_step(TEST_STATE_STEP_10);
+ RUN_TEST(test_ftrapv_absolute_value);
+#else
+ test_reboot_to_next_step(TEST_STATE_STEP_10);
+#endif
+}
+
+test_static void run_test_step10(void)
+{
+ /*
+ * TODO(b/258074414): Trapping on absolute value overflow is broken in
+ * clang, so skip the check.
+ */
+#if 0
+ RUN_TEST(test_panic_data);
+#endif
+
+ if (test_get_error_count())
+ test_reboot_to_next_step(TEST_STATE_FAILED);
+ else
+ test_reboot_to_next_step(TEST_STATE_PASSED);
+}
+
+void test_run_step(uint32_t state)
+{
+ if (state & TEST_STATE_MASK(TEST_STATE_STEP_1)) {
+ run_test_step1();
+ } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_2)) {
+ run_test_step2();
+ } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_3)) {
+ run_test_step3();
+ } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_4)) {
+ run_test_step4();
+ } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_5)) {
+ run_test_step5();
+ } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_6)) {
+ run_test_step6();
+ } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_7)) {
+ run_test_step7();
+ } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_8)) {
+ run_test_step8();
+ } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_9)) {
+ run_test_step9();
+ } else if (state & TEST_STATE_MASK(TEST_STATE_STEP_10)) {
+ run_test_step10();
+ }
+}
+
+int task_test(void *unused)
+{
+ if (IS_ENABLED(SECTION_IS_RW))
+ test_run_multistep();
+ return EC_SUCCESS;
+}
+
+void run_test(int argc, const char **argv)
+{
+ test_reset();
+ msleep(30); /* Wait for TASK_ID_TEST to initialize */
+ task_wake(TASK_ID_TEST);
+}
diff --git a/test/ftrapv.tasklist b/test/ftrapv.tasklist
new file mode 100644
index 0000000000..273a9664c0
--- /dev/null
+++ b/test/ftrapv.tasklist
@@ -0,0 +1,10 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * See CONFIG_TASK_LIST in config.h for details.
+ */
+#define CONFIG_TEST_TASK_LIST \
+ TASK_TEST(TEST, task_test, NULL, TASK_STACK_SIZE)
diff --git a/test/gyro_cal.c b/test/gyro_cal.c
index c8e8d30589..cf9af0fdbc 100644
--- a/test/gyro_cal.c
+++ b/test/gyro_cal.c
@@ -5,14 +5,15 @@
#include "common.h"
#include "gyro_cal.h"
-#include "gyro_still_det.h"
#include "gyro_cal_init_for_test.h"
+#include "gyro_still_det.h"
#include "motion_sense.h"
#include "test_util.h"
-#include <string.h>
-#include <stdlib.h>
+
#include <math.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
float kToleranceGyroRps = 1e-6f;
float kDefaultGravityMps2 = 9.81f;
diff --git a/test/gyro_cal_init_for_test.c b/test/gyro_cal_init_for_test.c
index 0ba1a65e6b..ebb1dd8799 100644
--- a/test/gyro_cal_init_for_test.c
+++ b/test/gyro_cal_init_for_test.c
@@ -4,8 +4,9 @@
*/
#include "common.h"
-#include "timer.h"
#include "gyro_cal_init_for_test.h"
+#include "timer.h"
+
#include <string.h>
#define NANO_PI (3.14159265359f)
diff --git a/test/interrupt.c b/test/interrupt.c
index efd8b47a34..fbd35253e8 100644
--- a/test/interrupt.c
+++ b/test/interrupt.c
@@ -4,8 +4,6 @@
*
* Test interrupt support of EC emulator.
*/
-#include <stdio.h>
-
#include "common.h"
#include "console.h"
#include "task.h"
@@ -13,6 +11,8 @@
#include "timer.h"
#include "util.h"
+#include <stdio.h>
+
static int main_count;
static int has_error;
static int interrupt_count;
diff --git a/test/kasa.c b/test/kasa.c
index 23968faf7c..222fb2a0cf 100644
--- a/test/kasa.c
+++ b/test/kasa.c
@@ -5,8 +5,9 @@
#include "common.h"
#include "kasa.h"
-#include "test_util.h"
#include "motion_sense.h"
+#include "test_util.h"
+
#include <stdio.h>
struct motion_sensor_t motion_sensors[] = {};
diff --git a/test/kb_8042.c b/test/kb_8042.c
index e7d7690cff..0065319576 100644
--- a/test/kb_8042.c
+++ b/test/kb_8042.c
@@ -5,7 +5,6 @@
* Tests for keyboard MKBP protocol
*/
-#include <stdbool.h>
#include "atkbd_protocol.h"
#include "common.h"
#include "console.h"
@@ -24,6 +23,8 @@
#include "timer.h"
#include "util.h"
+#include <stdbool.h>
+
static const char *action[2] = { "release", "press" };
/*
@@ -261,6 +262,7 @@ static int _read_cmd_byte(uint8_t *cmd)
void before_test(void)
{
/* Make sure all tests start with the controller in the same state */
+ keyboard_clear_buffer();
_write_cmd_byte(I8042_XLATE | I8042_AUX_DIS | I8042_KBD_DIS);
}
@@ -274,7 +276,7 @@ void after_test(void)
}
}
-static int test_8042_aux_loopback(void)
+test_static int test_8042_aux_loopback(void)
{
/* Disable all IRQs */
WRITE_CMD_BYTE(0);
@@ -293,7 +295,7 @@ static int test_8042_aux_loopback(void)
return EC_SUCCESS;
}
-static int test_8042_aux_two_way_communication(void)
+test_static int test_8042_aux_two_way_communication(void)
{
/* Enable AUX IRQ */
WRITE_CMD_BYTE(I8042_ENIRQ12);
@@ -311,7 +313,7 @@ static int test_8042_aux_two_way_communication(void)
return EC_SUCCESS;
}
-static int test_8042_aux_inhibit(void)
+test_static int test_8042_aux_inhibit(void)
{
/* Enable AUX IRQ, but inhibit the AUX device from sending data. */
WRITE_CMD_BYTE(I8042_ENIRQ12 | I8042_AUX_DIS);
@@ -339,7 +341,7 @@ static int test_8042_aux_inhibit(void)
return EC_SUCCESS;
}
-static int test_8042_aux_controller_commands(void)
+test_static int test_8042_aux_controller_commands(void)
{
uint8_t ctrl;
@@ -359,7 +361,7 @@ static int test_8042_aux_controller_commands(void)
return EC_SUCCESS;
}
-static int test_8042_aux_test_command(void)
+test_static int test_8042_aux_test_command(void)
{
i8042_write_cmd(I8042_TEST_MOUSE);
@@ -368,7 +370,7 @@ static int test_8042_aux_test_command(void)
return EC_SUCCESS;
}
-static int test_8042_self_test(void)
+test_static int test_8042_self_test(void)
{
i8042_write_cmd(I8042_RESET_SELF_TEST);
VERIFY_LPC_CHAR("\x55");
@@ -376,7 +378,7 @@ static int test_8042_self_test(void)
return EC_SUCCESS;
}
-static int test_8042_keyboard_test_command(void)
+test_static int test_8042_keyboard_test_command(void)
{
i8042_write_cmd(I8042_TEST_KB_PORT);
VERIFY_LPC_CHAR("\x00"); /* Data and Clock are not stuck */
@@ -384,7 +386,7 @@ static int test_8042_keyboard_test_command(void)
return EC_SUCCESS;
}
-static int test_8042_keyboard_controller_commands(void)
+test_static int test_8042_keyboard_controller_commands(void)
{
uint8_t ctrl;
@@ -404,7 +406,7 @@ static int test_8042_keyboard_controller_commands(void)
return EC_SUCCESS;
}
-static int test_8042_keyboard_key_pressed_while_inhibited(void)
+test_static int test_8042_keyboard_key_pressed_while_inhibited(void)
{
ENABLE_KEYSTROKE(1);
@@ -440,7 +442,8 @@ static int test_8042_keyboard_key_pressed_while_inhibited(void)
return EC_SUCCESS;
}
-static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte(void)
+test_static int
+test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte(void)
{
ENABLE_KEYSTROKE(1);
/* Simulate a keypress on the keyboard */
@@ -472,7 +475,7 @@ static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte(void)
return EC_SUCCESS;
}
-static int
+test_static int
test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte_with_read(void)
{
uint8_t cmd;
@@ -524,7 +527,7 @@ test_8042_keyboard_key_pressed_before_inhibit_using_cmd_byte_with_read(void)
return EC_SUCCESS;
}
-static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd(void)
+test_static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd(void)
{
ENABLE_KEYSTROKE(1);
/* Simulate a keypress on the keyboard */
@@ -556,7 +559,7 @@ static int test_8042_keyboard_key_pressed_before_inhibit_using_cmd(void)
return EC_SUCCESS;
}
-static int test_single_key_press(void)
+test_static int test_single_key_press(void)
{
ENABLE_KEYSTROKE(1);
press_key(1, 1, 1);
@@ -572,7 +575,7 @@ static int test_single_key_press(void)
return EC_SUCCESS;
}
-static int test_disable_keystroke(void)
+test_static int test_disable_keystroke(void)
{
ENABLE_KEYSTROKE(0);
press_key(1, 1, 1);
@@ -583,7 +586,7 @@ static int test_disable_keystroke(void)
return EC_SUCCESS;
}
-static int test_typematic(void)
+test_static int test_typematic(void)
{
ENABLE_KEYSTROKE(1);
@@ -610,7 +613,7 @@ static int test_typematic(void)
return EC_SUCCESS;
}
-static int test_atkbd_get_scancode(void)
+test_static int test_atkbd_get_scancode(void)
{
SET_SCANCODE(1);
@@ -635,7 +638,7 @@ static int test_atkbd_get_scancode(void)
return EC_SUCCESS;
}
-static int test_atkbd_set_scancode_with_keystroke_disabled(void)
+test_static int test_atkbd_set_scancode_with_keystroke_disabled(void)
{
ENABLE_KEYSTROKE(0);
@@ -647,7 +650,7 @@ static int test_atkbd_set_scancode_with_keystroke_disabled(void)
return EC_SUCCESS;
}
-static int test_atkbd_set_scancode_with_key_press_before_set(void)
+test_static int test_atkbd_set_scancode_with_key_press_before_set(void)
{
ENABLE_KEYSTROKE(0);
ENABLE_KEYSTROKE(1);
@@ -660,26 +663,17 @@ static int test_atkbd_set_scancode_with_key_press_before_set(void)
* ATKBD_CMD_SSCANSET should cause the keyboard to stop scanning, flush
* the keyboards output queue, and reset the typematic key.
*/
- keyboard_host_write(ATKBD_CMD_SSCANSET, 0);
- /* Read out the scan code that got pushed into the output buffer before
- * the command was sent.
- */
- VERIFY_LPC_CHAR("\x01");
+ i8042_write_data(ATKBD_CMD_SSCANSET);
+ VERIFY_ATKBD_ACK();
/*
* FIXME: This is wrong. The keyboard's output queue should have been
* flushed when it received the `ATKBD_CMD_SSCANSET` command.
*/
- VERIFY_LPC_CHAR("\x81");
-
- /* This is the ACK for `ATKBD_CMD_SSCANSET`. */
- VERIFY_ATKBD_ACK();
-
- /* The keyboard has flushed the buffer so no more keys. */
- VERIFY_NO_CHAR();
+ VERIFY_LPC_CHAR("\x01\x81");
/* Finish setting scan code 1 */
- keyboard_host_write(1, 0);
+ i8042_write_data(1);
VERIFY_ATKBD_ACK();
/* Key scanning should be restored. */
@@ -690,7 +684,7 @@ static int test_atkbd_set_scancode_with_key_press_before_set(void)
return EC_SUCCESS;
}
-static int test_atkbd_set_scancode_with_key_press_during_set(void)
+test_static int test_atkbd_set_scancode_with_key_press_during_set(void)
{
ENABLE_KEYSTROKE(1);
@@ -698,7 +692,7 @@ static int test_atkbd_set_scancode_with_key_press_during_set(void)
* ATKBD_CMD_SSCANSET should cause the keyboard to stop scanning, flush
* the keyboards output queue, and reset the typematic key.
*/
- keyboard_host_write(ATKBD_CMD_SSCANSET, 0);
+ i8042_write_data(ATKBD_CMD_SSCANSET);
VERIFY_ATKBD_ACK();
/* These keypresses should be dropped. */
@@ -711,7 +705,7 @@ static int test_atkbd_set_scancode_with_key_press_during_set(void)
VERIFY_LPC_CHAR("\x01\x81");
/* Finish setting scan code 1 */
- keyboard_host_write(1, 0);
+ i8042_write_data(1);
VERIFY_ATKBD_ACK();
/* Key scanning should be restored. */
@@ -722,7 +716,7 @@ static int test_atkbd_set_scancode_with_key_press_during_set(void)
return EC_SUCCESS;
}
-static int test_atkbd_echo(void)
+test_static int test_atkbd_echo(void)
{
i8042_write_data(ATKBD_CMD_DIAG_ECHO);
VERIFY_ATKBD_ACK();
@@ -732,7 +726,7 @@ static int test_atkbd_echo(void)
return EC_SUCCESS;
}
-static int test_atkbd_get_id(void)
+test_static int test_atkbd_get_id(void)
{
i8042_write_data(ATKBD_CMD_GETID);
VERIFY_ATKBD_ACK();
@@ -747,8 +741,10 @@ static int test_atkbd_get_id(void)
return EC_SUCCESS;
}
-static int test_atkbd_set_leds_keypress_during(void)
+test_static int test_atkbd_set_leds_keypress_during(void)
{
+ ENABLE_KEYSTROKE(1);
+
/* This should pause scanning. */
i8042_write_data(ATKBD_CMD_SETLEDS);
VERIFY_ATKBD_ACK();
@@ -756,16 +752,20 @@ static int test_atkbd_set_leds_keypress_during(void)
/* Simulate keypress while keyboard is waiting for option byte */
press_key(1, 1, 1);
press_key(1, 1, 0);
- /* FIXME: This is wrong, we shouldn't have any key strokes */
- VERIFY_LPC_CHAR("\x01\x81");
+
+ /* Scancode is kept in queue during SETLEDS. */
+ VERIFY_NO_CHAR();
i8042_write_data(0x01);
VERIFY_ATKBD_ACK();
+ /* Scancode previously queued should be sent now. */
+ VERIFY_LPC_CHAR("\x01\x81");
+
return EC_SUCCESS;
}
-static int test_atkbd_set_leds_abort_set(void)
+test_static int test_atkbd_set_leds_abort_set(void)
{
i8042_write_data(ATKBD_CMD_SETLEDS);
VERIFY_ATKBD_ACK();
@@ -785,7 +785,7 @@ static int test_atkbd_set_leds_abort_set(void)
return EC_SUCCESS;
}
-static int test_atkbd_set_ex_leds(void)
+test_static int test_atkbd_set_ex_leds(void)
{
i8042_write_data(ATKBD_CMD_EX_SETLEDS);
VERIFY_ATKBD_ACK();
@@ -801,9 +801,10 @@ static int test_atkbd_set_ex_leds(void)
return EC_SUCCESS;
}
-static int test_scancode_set2(void)
+test_static int test_scancode_set2(void)
{
SET_SCANCODE(2);
+ ENABLE_KEYSTROKE(1);
WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE);
press_key(1, 1, 1);
@@ -820,7 +821,7 @@ static int test_scancode_set2(void)
return EC_SUCCESS;
}
-static int test_power_button(void)
+test_static int test_power_button(void)
{
ENABLE_KEYSTROKE(0);
@@ -857,7 +858,7 @@ static int test_power_button(void)
return EC_SUCCESS;
}
-static int test_sysjump(void)
+test_static int test_sysjump(void)
{
SET_SCANCODE(2);
ENABLE_KEYSTROKE(1);
@@ -868,15 +869,17 @@ static int test_sysjump(void)
return EC_ERROR_UNKNOWN;
}
-static int test_sysjump_cont(void)
+test_static int test_sysjump_cont(void)
{
WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE);
+
press_key(1, 1, 1);
VERIFY_LPC_CHAR("\x01");
press_key(1, 1, 0);
VERIFY_LPC_CHAR("\x81");
WRITE_CMD_BYTE(READ_CMD_BYTE() & ~I8042_XLATE);
+
press_key(1, 1, 1);
VERIFY_LPC_CHAR("\x76");
press_key(1, 1, 0);
@@ -885,7 +888,7 @@ static int test_sysjump_cont(void)
return EC_SUCCESS;
}
-static const struct ec_response_keybd_config keybd_config = {
+test_static const struct ec_response_keybd_config keybd_config = {
.num_top_row_keys = 13,
.action_keys = {
TK_BACK, /* T1 */
@@ -910,7 +913,7 @@ board_vivaldi_keybd_config(void)
return &keybd_config;
}
-static int test_ec_cmd_get_keybd_config(void)
+test_static int test_ec_cmd_get_keybd_config(void)
{
struct ec_response_keybd_config resp;
int rv;
@@ -931,22 +934,25 @@ static int test_ec_cmd_get_keybd_config(void)
return EC_SUCCESS;
}
-static int test_vivaldi_top_keys(void)
+test_static int test_vivaldi_top_keys(void)
{
SET_SCANCODE(2);
/* Test REFRESH key */
WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE);
+
press_key(2, 3, 1); /* Press T2 */
VERIFY_LPC_CHAR("\xe0\x67"); /* Check REFRESH scancode in set-1 */
/* Test SNAPSHOT key */
WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE);
+
press_key(4, 3, 1); /* Press T2 */
VERIFY_LPC_CHAR("\xe0\x13"); /* Check SNAPSHOT scancode in set-1 */
/* Test VOL_UP key */
WRITE_CMD_BYTE(READ_CMD_BYTE() | I8042_XLATE);
+
press_key(5, 3, 1); /* Press T2 */
VERIFY_LPC_CHAR("\xe0\x30"); /* Check VOL_UP scancode in set-1 */
diff --git a/test/kb_scan.c b/test/kb_scan.c
index 82693ff525..031c972d0e 100644
--- a/test/kb_scan.c
+++ b/test/kb_scan.c
@@ -578,6 +578,7 @@ static void run_test_step1(void)
lid_open = 1;
hook_notify(HOOK_LID_CHANGE);
test_reset();
+ msleep(1);
RUN_TEST(deghost_test);
@@ -606,6 +607,7 @@ static void run_test_step2(void)
lid_open = 1;
hook_notify(HOOK_LID_CHANGE);
test_reset();
+ msleep(1);
RUN_TEST(test_check_boot_esc);
@@ -620,6 +622,7 @@ static void run_test_step3(void)
lid_open = 1;
hook_notify(HOOK_LID_CHANGE);
test_reset();
+ msleep(1);
RUN_TEST(test_check_boot_down);
diff --git a/test/libc_printf.c b/test/libc_printf.c
new file mode 100644
index 0000000000..8900d9ea04
--- /dev/null
+++ b/test/libc_printf.c
@@ -0,0 +1,28 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "test_util.h"
+
+#include <stdio.h>
+
+test_static int test_printf(void)
+{
+ /*
+ * The test itself is not verifying that printing works (according to
+ * the test framework, this will always pass).
+ *
+ * Instead, the test runner (test/run_device_tests.py) looks for the
+ * printed string in the test output to determine if the test passed.
+ */
+ printf("printf called\n");
+ return EC_SUCCESS;
+}
+
+void run_test(int argc, const char **argv)
+{
+ test_reset();
+ RUN_TEST(test_printf);
+ test_print_result();
+}
diff --git a/test/libc_printf.tasklist b/test/libc_printf.tasklist
new file mode 100644
index 0000000000..959f62ef79
--- /dev/null
+++ b/test/libc_printf.tasklist
@@ -0,0 +1,9 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * See CONFIG_TASK_LIST in config.h for details.
+ */
+#define CONFIG_TEST_TASK_LIST
diff --git a/test/lightbar.c b/test/lightbar.c
index 90400d1cf5..d51b61779e 100644
--- a/test/lightbar.c
+++ b/test/lightbar.c
@@ -5,8 +5,8 @@
#include "console.h"
#include "ec_commands.h"
-#include "lightbar.h"
#include "host_command.h"
+#include "lightbar.h"
#include "test_util.h"
#include "timer.h"
#include "util.h"
diff --git a/test/mag_cal.c b/test/mag_cal.c
index 245bad786c..fe98318258 100644
--- a/test/mag_cal.c
+++ b/test/mag_cal.c
@@ -6,6 +6,7 @@
#include "common.h"
#include "mag_cal.h"
#include "test_util.h"
+
#include <stdio.h>
/**
diff --git a/test/math_util.c b/test/math_util.c
index 1ee9b1484b..c08bd0c561 100644
--- a/test/math_util.c
+++ b/test/math_util.c
@@ -5,14 +5,15 @@
* Test motion sense code.
*/
-#include <math.h>
-#include <stdio.h>
#include "common.h"
#include "math_util.h"
#include "motion_sense.h"
#include "test_util.h"
#include "util.h"
+#include <math.h>
+#include <stdio.h>
+
/*****************************************************************************/
/*
* Need to define motion sensor globals just to compile.
diff --git a/test/motion_angle.c b/test/motion_angle.c
index 3f206de078..8eb1a775e4 100644
--- a/test/motion_angle.c
+++ b/test/motion_angle.c
@@ -6,9 +6,6 @@
* transition.
*/
-#include <math.h>
-#include <stdio.h>
-
#include "accelgyro.h"
#include "common.h"
#include "gpio.h"
@@ -20,6 +17,9 @@
#include "test_util.h"
#include "util.h"
+#include <math.h>
+#include <stdio.h>
+
/*****************************************************************************/
/* Test utilities */
diff --git a/test/motion_angle_tablet.c b/test/motion_angle_tablet.c
index 2c0c15c828..2f458381b3 100644
--- a/test/motion_angle_tablet.c
+++ b/test/motion_angle_tablet.c
@@ -5,9 +5,6 @@
* Test motion sense code, when in tablet mode.
*/
-#include <math.h>
-#include <stdio.h>
-
#include "accelgyro.h"
#include "common.h"
#include "gpio.h"
@@ -19,6 +16,9 @@
#include "test_util.h"
#include "util.h"
+#include <math.h>
+#include <stdio.h>
+
/*****************************************************************************/
/* Test utilities */
diff --git a/test/motion_lid.c b/test/motion_lid.c
index 39b83ce6fc..40e6dcb0f0 100644
--- a/test/motion_lid.c
+++ b/test/motion_lid.c
@@ -5,9 +5,6 @@
* Test motion sense code.
*/
-#include <math.h>
-#include <stdio.h>
-
#include "accelgyro.h"
#include "common.h"
#include "gpio.h"
@@ -20,6 +17,9 @@
#include "timer.h"
#include "util.h"
+#include <math.h>
+#include <stdio.h>
+
extern enum chipset_state_mask sensor_active;
extern int wait_us;
diff --git a/test/motion_sense_fifo.c b/test/motion_sense_fifo.c
index 5a977e94d0..3cea279bda 100644
--- a/test/motion_sense_fifo.c
+++ b/test/motion_sense_fifo.c
@@ -5,15 +5,16 @@
* Test motion_sense_fifo.
*/
+#include "accelgyro.h"
#include "ec_commands.h"
-#include "stdio.h"
-#include "motion_sense_fifo.h"
-#include "test_util.h"
-#include "util.h"
#include "hwtimer.h"
+#include "motion_sense_fifo.h"
+#include "stdio.h"
#include "task.h"
+#include "test_util.h"
#include "timer.h"
-#include "accelgyro.h"
+#include "util.h"
+
#include <sys/types.h>
mutex_t g_sensor_mutex;
diff --git a/test/mpu.c b/test/mpu.c
index 2193c0c617..dfc5877d5a 100644
--- a/test/mpu.c
+++ b/test/mpu.c
@@ -3,13 +3,22 @@
* found in the LICENSE file.
*/
-#include <stdbool.h>
+/* This test file meant to be executed on a real device. Example:
+ * 1. make tests BOARD=bloonchipper
+ * 2. servod --board=bloonchipper
+ * 3. flash_ec --board bloonchipper --image build/bloonchipper/test-mpu.bin
+ * 4. Open console via dut-control raw_fpmcu_console_uart_pty
+ * 5. runtest on console
+ */
+
#include "mpu.h"
#include "mpu_private.h"
#include "string.h"
#include "system.h"
#include "test_util.h"
+#include <stdbool.h>
+
struct mpu_info {
bool has_mpu;
int num_mpu_regions;
@@ -172,6 +181,19 @@ test_static int test_mpu_get_rw_regions(void)
return EC_SUCCESS;
}
+test_static int test_align_down_to_bits(void)
+{
+ uint32_t addr = 0x87654321;
+
+ TEST_EQ(align_down_to_bits(addr, 0), addr, "%d");
+ TEST_EQ(align_down_to_bits(addr, 1), 0x87654320, "%d");
+ TEST_EQ(align_down_to_bits(addr, 30), 0x80000000, "%d");
+ TEST_EQ(align_down_to_bits(addr, 31), 0x80000000, "%d");
+ TEST_EQ(align_down_to_bits(addr, 32), addr, "%d");
+ TEST_EQ(align_down_to_bits(addr, 33), addr, "%d");
+ return EC_SUCCESS;
+}
+
void run_test(int argc, const char **argv)
{
enum ec_image cur_image = system_get_image_copy();
@@ -211,6 +233,8 @@ void run_test(int argc, const char **argv)
RUN_TEST(reset_mpu);
RUN_TEST(test_mpu_get_rw_regions);
RUN_TEST(reset_mpu);
+ RUN_TEST(test_align_down_to_bits);
+ RUN_TEST(reset_mpu);
/* This test must be last because it generates a panic */
RUN_TEST(test_mpu_update_region_valid_region);
RUN_TEST(reset_mpu);
diff --git a/test/mutex.c b/test/mutex.c
index a03e504a0a..b4066c8c4f 100644
--- a/test/mutex.c
+++ b/test/mutex.c
@@ -6,8 +6,8 @@
* Tasks for mutexes basic tests.
*/
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
diff --git a/test/newton_fit.c b/test/newton_fit.c
index 07c35aad2a..62f4710f0c 100644
--- a/test/newton_fit.c
+++ b/test/newton_fit.c
@@ -4,9 +4,10 @@
*/
#include "common.h"
-#include "newton_fit.h"
#include "motion_sense.h"
+#include "newton_fit.h"
#include "test_util.h"
+
#include <stdio.h>
/*
diff --git a/test/nvidia_gpu.c b/test/nvidia_gpu.c
index d6086cc8c4..b660943e04 100644
--- a/test/nvidia_gpu.c
+++ b/test/nvidia_gpu.c
@@ -4,12 +4,11 @@
*
* Tests for Nvidia GPU.
*/
-#include <stdio.h>
-
#include "charge_manager.h"
#include "charge_state.h"
#include "common.h"
#include "console.h"
+#include "driver/nvidia_gpu.h"
#include "hooks.h"
#include "host_command.h"
#include "task.h"
@@ -18,7 +17,7 @@
#include "timer.h"
#include "util.h"
-#include "driver/nvidia_gpu.h"
+#include <stdio.h>
struct d_notify_policy d_notify_policies[] = {
AC_ATLEAST_W(100), AC_ATLEAST_W(65), AC_DC,
diff --git a/test/online_calibration.c b/test/online_calibration.c
index cecb543eef..c845378012 100644
--- a/test/online_calibration.c
+++ b/test/online_calibration.c
@@ -10,6 +10,7 @@
#include "online_calibration.h"
#include "test_util.h"
#include "timer.h"
+
#include <stdio.h>
int mkbp_send_event(uint8_t event_type)
diff --git a/test/online_calibration_spoof.c b/test/online_calibration_spoof.c
index 44a3b812d9..31c17bb8dd 100644
--- a/test/online_calibration_spoof.c
+++ b/test/online_calibration_spoof.c
@@ -5,13 +5,14 @@
#include "accel_cal.h"
#include "accelgyro.h"
+#include "gyro_cal.h"
+#include "gyro_cal_init_for_test.h"
#include "hwtimer.h"
#include "mag_cal.h"
#include "online_calibration.h"
#include "test_util.h"
-#include "gyro_cal_init_for_test.h"
-#include "gyro_cal.h"
#include "timer.h"
+
#include <stdio.h>
int mkbp_send_event(uint8_t event_type)
diff --git a/test/panic_data.c b/test/panic_data.c
index 334b766dfc..8892c17ece 100644
--- a/test/panic_data.c
+++ b/test/panic_data.c
@@ -3,12 +3,11 @@
* found in the LICENSE file.
*/
-#include "test_util.h"
-
#include "builtin/assert.h"
#include "panic.h"
#include "system.h"
#include "task.h"
+#include "test_util.h"
static int get_assert_line(void)
{
diff --git a/test/powerdemo.c b/test/powerdemo.c
index 7a4f0c5ccb..2900401370 100644
--- a/test/powerdemo.c
+++ b/test/powerdemo.c
@@ -8,9 +8,9 @@
#include "clock.h"
#include "common.h"
#include "powerdemo.h"
+#include "registers.h"
#include "task.h"
#include "timer.h"
-#include "registers.h"
static volatile enum {
POWER_STATE_IDLE = 0, /* Idle */
diff --git a/test/printf.c b/test/printf.c
index 29ffdfcea4..7c037e22da 100644
--- a/test/printf.c
+++ b/test/printf.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stddef.h>
-
#include "common.h"
#include "compiler.h"
#include "printf.h"
#include "test_util.h"
#include "util.h"
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+
#ifdef USE_BUILTIN_STDLIB
/*
* When USE_BUILTIN_STDLIB is defined, we want to test the EC printf
diff --git a/test/rgb_keyboard.c b/test/rgb_keyboard.c
index d32215e649..1b6ea1bf95 100644
--- a/test/rgb_keyboard.c
+++ b/test/rgb_keyboard.c
@@ -4,8 +4,6 @@
*
* Tests for RGB keyboard.
*/
-#include <stdio.h>
-
#include "common.h"
#include "console.h"
#include "keyboard_backlight.h"
@@ -15,6 +13,8 @@
#include "timer.h"
#include "util.h"
+#include <stdio.h>
+
#define RGB_GRID0_COL 11
#define RGB_GRID0_ROW 6
#define RGB_GRID1_COL 11
diff --git a/test/rng_benchmark.cc b/test/rng_benchmark.cc
new file mode 100644
index 0000000000..2e47b8ea27
--- /dev/null
+++ b/test/rng_benchmark.cc
@@ -0,0 +1,81 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Measure performance of the hardware True Random Number Generator (TRNG)
+ * compared to the std::rand().
+ */
+
+#include "benchmark.h"
+
+#include "console.h"
+#include <array>
+#include <cstdint>
+#include <cstdlib>
+
+extern "C" {
+#include "test_util.h"
+#include "trng.h"
+}
+
+test_static int test_rng()
+{
+ constexpr int num_iterations = 100;
+ Benchmark benchmark({ .num_iterations = num_iterations });
+ std::array<uint32_t, num_iterations> trng_out;
+ std::array<int, num_iterations> rand_out;
+
+ // Try the hardware true random number generator
+ trng_out.fill(0);
+
+ trng_init();
+ auto result = benchmark.run("trng", [&trng_out]() {
+ static int i = 0;
+ trng_out[i++] = trng_rand();
+ });
+ trng_exit();
+
+ TEST_ASSERT(result.has_value());
+ for (int i = 0; i < trng_out.size() - 1; ++i) {
+ TEST_NE(trng_out[i], trng_out[i + 1], "%d");
+ cflush();
+ }
+
+ // Repeat the test by turning the TNRG on and off at each iteration
+ trng_out.fill(0);
+ result = benchmark.run("trng_on_off", [&trng_out]() {
+ trng_init();
+ static int i = 0;
+ trng_out[i++] = trng_rand();
+ trng_exit();
+ });
+
+ TEST_ASSERT(result.has_value());
+ for (int i = 0; i < trng_out.size() - 1; ++i) {
+ TEST_NE(trng_out[i], trng_out[i + 1], "%d");
+ cflush();
+ }
+
+ // Repeat the test using std::rand() for comparison
+ rand_out.fill(0);
+ result = benchmark.run("std::rand", [&rand_out]() {
+ static int i = 0;
+ rand_out[i++] = std::rand();
+ });
+
+ TEST_ASSERT(result.has_value());
+ for (int i = 0; i < rand_out.size() - 1; ++i) {
+ TEST_NE(rand_out[i], rand_out[i + 1], "%d");
+ cflush();
+ }
+
+ benchmark.print_results();
+ return EC_SUCCESS;
+}
+
+void run_test(int argc, const char **argv)
+{
+ test_reset();
+ RUN_TEST(test_rng);
+ test_print_result();
+} \ No newline at end of file
diff --git a/test/rng_benchmark.tasklist b/test/rng_benchmark.tasklist
new file mode 100644
index 0000000000..19615b9ea8
--- /dev/null
+++ b/test/rng_benchmark.tasklist
@@ -0,0 +1,9 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * See CONFIG_TASK_LIST in config.h for details.
+ */
+#define CONFIG_TEST_TASK_LIST \ No newline at end of file
diff --git a/test/rollback.c b/test/rollback.c
index e2c1070ef4..6324fe86fc 100644
--- a/test/rollback.c
+++ b/test/rollback.c
@@ -3,12 +3,13 @@
* found in the LICENSE file.
*/
-#include <stdbool.h>
#include "flash.h"
#include "mpu.h"
#include "string.h"
#include "test_util.h"
+#include <stdbool.h>
+
struct rollback_info {
int region_0_offset;
int region_1_offset;
diff --git a/test/rollback_secret.c b/test/rollback_secret.c
index 4813814f19..46ecfa587b 100644
--- a/test/rollback_secret.c
+++ b/test/rollback_secret.c
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-
#include "mock/rollback_latest_mock.h"
#include "rollback.h"
#include "rollback_private.h"
@@ -12,6 +10,8 @@
#include "system.h"
#include "test_util.h"
+#include <stdint.h>
+
extern int get_latest_rollback(struct rollback_data *data);
test_static int test_get_rollback_secret_latest_rollback_fail(void)
diff --git a/test/rsa.c b/test/rsa.c
index 2774e9edb4..a63b274711 100644
--- a/test/rsa.c
+++ b/test/rsa.c
@@ -5,8 +5,8 @@
* Tests RSA implementation.
*/
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "rsa.h"
#include "test_util.h"
#include "util.h"
diff --git a/test/rtc.c b/test/rtc.c
index 7c38c4fa6d..3a006498f2 100644
--- a/test/rtc.c
+++ b/test/rtc.c
@@ -5,8 +5,8 @@
* Tests for rtc time conversions
*/
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "rtc.h"
#include "test_util.h"
#include "util.h"
diff --git a/test/run_device_tests.py b/test/run_device_tests.py
index 4e0b0127e3..8983a60b82 100755
--- a/test/run_device_tests.py
+++ b/test/run_device_tests.py
@@ -52,7 +52,7 @@ from concurrent.futures.thread import ThreadPoolExecutor
from dataclasses import dataclass, field
from enum import Enum
from pathlib import Path
-from typing import BinaryIO, Dict, List, Optional
+from typing import BinaryIO, Dict, List, Optional, Tuple
# pylint: disable=import-error
import colorama # type: ignore[import]
@@ -91,6 +91,7 @@ DATA_ACCESS_VIOLATION_20000000_REGEX = re.compile(
DATA_ACCESS_VIOLATION_24000000_REGEX = re.compile(
r"Data access violation, mfar = 24000000\r\n"
)
+PRINTF_CALLED_REGEX = re.compile(r"printf called\r\n")
BLOONCHIPPER = "bloonchipper"
DARTMONKEY = "dartmonkey"
@@ -196,6 +197,7 @@ class AllTests:
TestConfig(test_name="abort"),
TestConfig(test_name="aes"),
TestConfig(test_name="always_memset"),
+ TestConfig(test_name="benchmark"),
TestConfig(test_name="cec"),
TestConfig(test_name="cortexm_fpu"),
TestConfig(test_name="crc"),
@@ -234,6 +236,11 @@ class AllTests:
test_name="fpsensor",
test_args=["uart"],
),
+ TestConfig(test_name="ftrapv"),
+ TestConfig(
+ test_name="libc_printf",
+ finish_regexes=[PRINTF_CALLED_REGEX],
+ ),
TestConfig(
config_name="mpu_ro",
test_name="mpu",
@@ -250,6 +257,7 @@ class AllTests:
TestConfig(test_name="pingpong"),
TestConfig(test_name="printf"),
TestConfig(test_name="queue"),
+ TestConfig(test_name="rng_benchmark"),
TestConfig(
config_name="rollback_region0",
test_name="rollback",
@@ -389,7 +397,7 @@ def read_file_gsutil(path: str) -> bytes:
return gsutil.stdout
-def find_section_offset_size(section: str, image: bytes) -> (int, int):
+def find_section_offset_size(section: str, image: bytes) -> Tuple[int, int]:
"""Get offset and size of the section in image"""
areas = fmap.fmap_decode(image)["areas"]
area = next(area for area in areas if area["name"] == section)
diff --git a/test/sha256.c b/test/sha256.c
index 4b5326d189..0387d23175 100644
--- a/test/sha256.c
+++ b/test/sha256.c
@@ -5,8 +5,8 @@
* Tests SHA256 implementation.
*/
-#include "console.h"
#include "common.h"
+#include "console.h"
#include "sha256.h"
#include "test_util.h"
#include "util.h"
diff --git a/test/shmalloc.c b/test/shmalloc.c
index 899876ab43..f86efd4fa9 100644
--- a/test/shmalloc.c
+++ b/test/shmalloc.c
@@ -4,11 +4,6 @@
* found in the LICENSE file.
*/
-#include <stddef.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-
#include "common.h"
#include "compile_time_macros.h"
#include "console.h"
@@ -16,6 +11,11 @@
#include "shared_mem.h"
#include "test_util.h"
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
/*
* Total size of memory in the malloc pool (shared between free and allocated
* buffers.
diff --git a/test/stdlib.c b/test/stdlib.c
index 909502aee8..3034522c23 100644
--- a/test/stdlib.c
+++ b/test/stdlib.c
@@ -8,9 +8,9 @@
#include "common.h"
#include "compiler.h"
#include "console.h"
-#include "system.h"
#include "printf.h"
#include "shared_mem.h"
+#include "system.h"
#include "test_util.h"
#include "timer.h"
#include "util.h"
diff --git a/test/stillness_detector.c b/test/stillness_detector.c
index 8858d751d7..2e82075e5e 100644
--- a/test/stillness_detector.c
+++ b/test/stillness_detector.c
@@ -3,10 +3,11 @@
* found in the LICENSE file.
*/
-#include "stillness_detector.h"
#include "motion_sense.h"
+#include "stillness_detector.h"
#include "test_util.h"
#include "timer.h"
+
#include <stdio.h>
/*****************************************************************************/
diff --git a/test/system_is_locked.c b/test/system_is_locked.c
index 47a7977601..0a517f1509 100644
--- a/test/system_is_locked.c
+++ b/test/system_is_locked.c
@@ -3,12 +3,11 @@
* found in the LICENSE file.
*/
-#include "test_util.h"
-
#include "flash.h"
#include "string.h"
#include "system.h"
#include "task.h"
+#include "test_util.h"
#include "write_protect.h"
static bool write_protect_enabled;
diff --git a/test/test_config.h b/test/test_config.h
index 3482449c10..704c3b42c1 100644
--- a/test/test_config.h
+++ b/test/test_config.h
@@ -305,7 +305,7 @@ enum sensor_id {
#define CONFIG_BATTERY_SMART
#define CONFIG_CHARGER
#define CONFIG_CHARGER_PROFILE_OVERRIDE
-#define CONFIG_CHARGER_INPUT_CURRENT 4032
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 4032
#define CONFIG_CHARGER_DISCHARGE_ON_AC
#define CONFIG_CHARGER_DISCHARGE_ON_AC_CUSTOM
#define CONFIG_I2C
@@ -346,7 +346,7 @@ int ncp15wb_calculate_temp(uint16_t adc);
#ifdef TEST_BATTERY_GET_PARAMS_SMART
#define CONFIG_BATTERY_MOCK
#define CONFIG_BATTERY_SMART
-#define CONFIG_CHARGER_INPUT_CURRENT 4032
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT 4032
#define CONFIG_I2C
#define CONFIG_I2C_CONTROLLER
#define I2C_PORT_MASTER 0
@@ -403,6 +403,7 @@ int ncp15wb_calculate_temp(uint16_t adc);
#undef CONFIG_USB_PE_SM
#undef CONFIG_USB_TYPEC_SM
#undef CONFIG_USB_PD_HOST_CMD
+#undef CONFIG_USB_DPM_SM
#define CONFIG_USB_PRL_SM
#define CONFIG_USB_PD_TCPC
#define CONFIG_USB_PD_TCPM_STUB
@@ -423,6 +424,7 @@ int ncp15wb_calculate_temp(uint16_t adc);
#define CONFIG_USB_PD_EXTENDED_MESSAGES
#define CONFIG_USB_PD_TCPMV2
#undef CONFIG_USB_PE_SM
+#undef CONFIG_USB_DPM_SM
#undef CONFIG_USB_TYPEC_SM
#undef CONFIG_USB_PD_HOST_CMD
#define CONFIG_USB_PRL_SM
@@ -531,6 +533,7 @@ int ncp15wb_calculate_temp(uint16_t adc);
#define CONFIG_USB_POWER_DELIVERY
#undef CONFIG_USB_PRL_SM
#undef CONFIG_USB_PE_SM
+#undef CONFIG_USB_DPM_SM
#undef CONFIG_USB_PD_HOST_CMD
#endif
@@ -615,6 +618,7 @@ int ncp15wb_calculate_temp(uint16_t adc);
#define CONFIG_CMD_PD_TIMER
#undef CONFIG_USB_PD_HOST_CMD
#undef CONFIG_USB_PRL_SM
+#undef CONFIG_USB_DPM_SM
#endif
#if defined(TEST_CHARGE_MANAGER) || defined(TEST_CHARGE_MANAGER_DRP_CHARGING)
diff --git a/test/uptime.c b/test/uptime.c
index 0b6c9b56e6..ab65820c18 100644
--- a/test/uptime.c
+++ b/test/uptime.c
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdbool.h>
-
#include "common.h"
#include "ec_commands.h"
#include "host_command.h"
@@ -12,6 +10,8 @@
#include "timer.h"
#include "util.h"
+#include <stdbool.h>
+
static bool get_ap_reset_stats_should_succeed = true;
/* Mocks */
diff --git a/test/usb_pd_console.c b/test/usb_pd_console.c
index cb2539fea4..dc574bccf0 100644
--- a/test/usb_pd_console.c
+++ b/test/usb_pd_console.c
@@ -10,11 +10,11 @@
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
-#include "usb_pe_sm.h"
+#include "test_util.h"
#include "usb_pd.h"
+#include "usb_pe_sm.h"
#include "usb_tc_sm.h"
#include "util.h"
-#include "test_util.h"
/* Defined in implementation */
int command_pd(int argc, const char **argv);
diff --git a/test/usb_pd_int.c b/test/usb_pd_int.c
index 0072da851d..1b9336361d 100644
--- a/test/usb_pd_int.c
+++ b/test/usb_pd_int.c
@@ -4,11 +4,11 @@
*
* Test USB-PD interrupt task.
*/
-#include "task.h"
-#include "test_util.h"
#include "mock/tcpc_mock.h"
#include "mock/timer_mock.h"
#include "mock/usb_mux_mock.h"
+#include "task.h"
+#include "test_util.h"
#define PORT0 0
diff --git a/test/usb_pe_drp.c b/test/usb_pe_drp.c
index 8d75454c6a..c4d2c924e4 100644
--- a/test/usb_pe_drp.c
+++ b/test/usb_pe_drp.c
@@ -5,6 +5,13 @@
* Test USB PE module.
*/
#include "common.h"
+#include "mock/charge_manager_mock.h"
+#include "mock/dp_alt_mode_mock.h"
+#include "mock/tcpc_mock.h"
+#include "mock/usb_mux_mock.h"
+#include "mock/usb_pd_dpm_mock.h"
+#include "mock/usb_prl_mock.h"
+#include "mock/usb_tc_sm_mock.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
@@ -13,13 +20,6 @@
#include "usb_pe.h"
#include "usb_pe_sm.h"
#include "usb_sm_checks.h"
-#include "mock/charge_manager_mock.h"
-#include "mock/usb_tc_sm_mock.h"
-#include "mock/tcpc_mock.h"
-#include "mock/usb_mux_mock.h"
-#include "mock/usb_pd_dpm_mock.h"
-#include "mock/dp_alt_mode_mock.h"
-#include "mock/usb_prl_mock.h"
/* Install Mock TCPC and MUX drivers */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
diff --git a/test/usb_pe_drp_noextended.c b/test/usb_pe_drp_noextended.c
index 6108458c9c..aa202a7dda 100644
--- a/test/usb_pe_drp_noextended.c
+++ b/test/usb_pe_drp_noextended.c
@@ -5,6 +5,9 @@
* Test USB PE module.
*/
#include "common.h"
+#include "mock/tcpc_mock.h"
+#include "mock/usb_mux_mock.h"
+#include "mock/usb_tc_sm_mock.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
@@ -13,9 +16,6 @@
#include "usb_pe.h"
#include "usb_pe_sm.h"
#include "usb_sm_checks.h"
-#include "mock/usb_tc_sm_mock.h"
-#include "mock/tcpc_mock.h"
-#include "mock/usb_mux_mock.h"
/* Install Mock TCPC and MUX drivers */
const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
diff --git a/test/usb_pe_drp_old.c b/test/usb_pe_drp_old.c
index 0985a4cae9..4ea07c1ec9 100644
--- a/test/usb_pe_drp_old.c
+++ b/test/usb_pe_drp_old.c
@@ -7,6 +7,7 @@
#include "battery.h"
#include "common.h"
#include "gpio.h"
+#include "mock/usb_prl_mock.h"
#include "task.h"
#include "test_util.h"
#include "timer.h"
@@ -19,7 +20,6 @@
#include "usb_prl_sm.h"
#include "usb_sm_checks.h"
#include "usb_tc_sm.h"
-#include "mock/usb_prl_mock.h"
#define pe_set_flag(_p, name) pe_set_fn((_p), (name##_FN))
#define pe_clr_flag(_p, name) pe_clr_fn((_p), (name##_FN))
diff --git a/test/usb_prl_noextended.c b/test/usb_prl_noextended.c
index 956c0027f5..609de56d49 100644
--- a/test/usb_prl_noextended.c
+++ b/test/usb_prl_noextended.c
@@ -11,9 +11,9 @@
#include "test_util.h"
#include "timer.h"
#include "usb_emsg.h"
-#include "usb_pd_test_util.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
+#include "usb_pd_test_util.h"
#include "usb_pe_sm.h"
#include "usb_prl_sm.h"
#include "usb_sm_checks.h"
diff --git a/test/usb_prl_old.c b/test/usb_prl_old.c
index 956c0027f5..609de56d49 100644
--- a/test/usb_prl_old.c
+++ b/test/usb_prl_old.c
@@ -11,9 +11,9 @@
#include "test_util.h"
#include "timer.h"
#include "usb_emsg.h"
-#include "usb_pd_test_util.h"
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
+#include "usb_pd_test_util.h"
#include "usb_pe_sm.h"
#include "usb_prl_sm.h"
#include "usb_sm_checks.h"
diff --git a/test/usb_sm_checks.c b/test/usb_sm_checks.c
index a8dbdad872..2204326d97 100644
--- a/test/usb_sm_checks.c
+++ b/test/usb_sm_checks.c
@@ -9,10 +9,10 @@
#include "test_util.h"
#include "timer.h"
#include "usb_pd.h"
+#include "usb_pd_test_util.h"
#include "usb_sm.h"
#include "usb_tc_sm.h"
#include "util.h"
-#include "usb_pd_test_util.h"
#include "vpd_api.h"
#ifdef CONFIG_USB_TYPEC_SM
diff --git a/test/usb_sm_framework_h3.c b/test/usb_sm_framework_h3.c
index 20f9b706c6..704bae8f9b 100644
--- a/test/usb_sm_framework_h3.c
+++ b/test/usb_sm_framework_h3.c
@@ -9,10 +9,10 @@
#include "test_util.h"
#include "timer.h"
#include "usb_pd.h"
+#include "usb_pd_test_util.h"
#include "usb_sm.h"
#include "usb_tc_sm.h"
#include "util.h"
-#include "usb_pd_test_util.h"
#include "vpd_api.h"
/*
diff --git a/test/usb_tcpmv2_compliance_common.c b/test/usb_tcpmv2_compliance_common.c
index 9f839ecf1c..ed46d7baa0 100644
--- a/test/usb_tcpmv2_compliance_common.c
+++ b/test/usb_tcpmv2_compliance_common.c
@@ -10,8 +10,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
uint32_t rdo = RDO_FIXED(1, 500, 500, 0);
uint32_t pdo = PDO_FIXED(5000, 3000,
diff --git a/test/usb_tcpmv2_td_pd_ll_e3.c b/test/usb_tcpmv2_td_pd_ll_e3.c
index f239c87885..8e1d46c15e 100644
--- a/test/usb_tcpmv2_td_pd_ll_e3.c
+++ b/test/usb_tcpmv2_td_pd_ll_e3.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
/*****************************************************************************
* TD.PD.LL.E3. Soft Reset Usage
diff --git a/test/usb_tcpmv2_td_pd_ll_e4.c b/test/usb_tcpmv2_td_pd_ll_e4.c
index f315fc2a63..fea5e3dc81 100644
--- a/test/usb_tcpmv2_td_pd_ll_e4.c
+++ b/test/usb_tcpmv2_td_pd_ll_e4.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
/*****************************************************************************
* TD.PD.LL.E4. Hard Reset Usage
diff --git a/test/usb_tcpmv2_td_pd_ll_e5.c b/test/usb_tcpmv2_td_pd_ll_e5.c
index 7c7446a7b3..49b76fd44e 100644
--- a/test/usb_tcpmv2_td_pd_ll_e5.c
+++ b/test/usb_tcpmv2_td_pd_ll_e5.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
/*****************************************************************************
* TD.PD.LL.E5. Soft Reset
diff --git a/test/usb_tcpmv2_td_pd_other.c b/test/usb_tcpmv2_td_pd_other.c
index 18477ac825..62e051a7a9 100644
--- a/test/usb_tcpmv2_td_pd_other.c
+++ b/test/usb_tcpmv2_td_pd_other.c
@@ -8,9 +8,9 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
-#include "usb_tc_sm.h"
#include "usb_prl_sm.h"
+#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
int test_connect_as_nonpd_sink(void)
{
diff --git a/test/usb_tcpmv2_td_pd_src3_e1.c b/test/usb_tcpmv2_td_pd_src3_e1.c
index 4f5637ccd2..9c79ea741a 100644
--- a/test/usb_tcpmv2_td_pd_src3_e1.c
+++ b/test/usb_tcpmv2_td_pd_src3_e1.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
#define BUFFER_SIZE 100
diff --git a/test/usb_tcpmv2_td_pd_src3_e7.c b/test/usb_tcpmv2_td_pd_src3_e7.c
index 40f65f2b9a..e94b017cc6 100644
--- a/test/usb_tcpmv2_td_pd_src3_e7.c
+++ b/test/usb_tcpmv2_td_pd_src3_e7.c
@@ -4,13 +4,13 @@
*/
#include "battery.h"
+#include "driver/tcpm/tcpci.h"
#include "mock/tcpci_i2c_mock.h"
#include "task.h"
-#include "driver/tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
#define BUFFER_SIZE 100
diff --git a/test/usb_tcpmv2_td_pd_src3_e8.c b/test/usb_tcpmv2_td_pd_src3_e8.c
index 8686226a50..a19f6c8c82 100644
--- a/test/usb_tcpmv2_td_pd_src3_e8.c
+++ b/test/usb_tcpmv2_td_pd_src3_e8.c
@@ -4,13 +4,13 @@
*/
#include "battery.h"
+#include "driver/tcpm/tcpci.h"
#include "mock/tcpci_i2c_mock.h"
#include "task.h"
-#include "driver/tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
#define BUFFER_SIZE 100
diff --git a/test/usb_tcpmv2_td_pd_src3_e9.c b/test/usb_tcpmv2_td_pd_src3_e9.c
index 59b7a22d74..833a9c056f 100644
--- a/test/usb_tcpmv2_td_pd_src3_e9.c
+++ b/test/usb_tcpmv2_td_pd_src3_e9.c
@@ -4,13 +4,13 @@
*/
#include "battery.h"
+#include "driver/tcpm/tcpci.h"
#include "mock/tcpci_i2c_mock.h"
#include "task.h"
-#include "driver/tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
#define BUFFER_SIZE 100
diff --git a/test/usb_tcpmv2_td_pd_src_e1.c b/test/usb_tcpmv2_td_pd_src_e1.c
index cfb62764b2..10166c4b65 100644
--- a/test/usb_tcpmv2_td_pd_src_e1.c
+++ b/test/usb_tcpmv2_td_pd_src_e1.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
/*****************************************************************************
* TD.PD.SRC.E1 Source Capabilities sent timely
diff --git a/test/usb_tcpmv2_td_pd_src_e2.c b/test/usb_tcpmv2_td_pd_src_e2.c
index cabba40bb9..fbe3e4bce7 100644
--- a/test/usb_tcpmv2_td_pd_src_e2.c
+++ b/test/usb_tcpmv2_td_pd_src_e2.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
#define BUFFER_SIZE 100
diff --git a/test/usb_tcpmv2_td_pd_src_e5.c b/test/usb_tcpmv2_td_pd_src_e5.c
index ef40ee75cf..bc391104ab 100644
--- a/test/usb_tcpmv2_td_pd_src_e5.c
+++ b/test/usb_tcpmv2_td_pd_src_e5.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
/*****************************************************************************
* TD.PD.SRC.E5 SenderResponseTimer Timeout - Request
diff --git a/test/usb_tcpmv2_td_pd_vndi3_e3.c b/test/usb_tcpmv2_td_pd_vndi3_e3.c
index 8157835328..590c02a0e8 100644
--- a/test/usb_tcpmv2_td_pd_vndi3_e3.c
+++ b/test/usb_tcpmv2_td_pd_vndi3_e3.c
@@ -8,8 +8,8 @@
#include "tcpm/tcpci.h"
#include "test_util.h"
#include "timer.h"
-#include "usb_tcpmv2_compliance.h"
#include "usb_tc_sm.h"
+#include "usb_tcpmv2_compliance.h"
uint32_t vdo =
VDO(USB_SID_PD, 1, VDO_SVDM_VERS(VDM_VER20) | CMD_DISCOVER_IDENT);
diff --git a/test/usb_test/device_configuration.c b/test/usb_test/device_configuration.c
index 06c71fefd9..94496fa0fc 100644
--- a/test/usb_test/device_configuration.c
+++ b/test/usb_test/device_configuration.c
@@ -5,13 +5,14 @@
*/
#include <errno.h>
-#include <getopt.h>
-#include <libusb.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <getopt.h>
+#include <libusb.h>
+
/* Options */
static uint16_t vid = 0x18d1; /* Google */
static uint16_t pid = 0x5014; /* Cr50 */
diff --git a/test/usb_typec_ctvpd.c b/test/usb_typec_ctvpd.c
index 71d543cec0..17c3452a62 100644
--- a/test/usb_typec_ctvpd.c
+++ b/test/usb_typec_ctvpd.c
@@ -10,12 +10,12 @@
#include "test_util.h"
#include "timer.h"
#include "usb_pd.h"
-#include "usb_sm.h"
-#include "usb_tc_sm.h"
-#include "util.h"
#include "usb_pd_tcpm.h"
#include "usb_pd_test_util.h"
+#include "usb_sm.h"
#include "usb_sm_checks.h"
+#include "usb_tc_sm.h"
+#include "util.h"
#include "vpd_api.h"
#define PORT0 0
diff --git a/test/utils_str.c b/test/utils_str.c
index 36ad63989e..4b2e3d4427 100644
--- a/test/utils_str.c
+++ b/test/utils_str.c
@@ -7,8 +7,8 @@
#include "common.h"
#include "console.h"
-#include "system.h"
#include "printf.h"
+#include "system.h"
#include "test_util.h"
#include "timer.h"
#include "util.h"
diff --git a/test/vboot.c b/test/vboot.c
index f75208de90..caa3d2d7cb 100644
--- a/test/vboot.c
+++ b/test/vboot.c
@@ -7,10 +7,10 @@
#include "common.h"
#include "rsa.h"
-#include "test_util.h"
-#include "vboot.h"
#include "rsa2048-3.h"
#include "rwsig.h"
+#include "test_util.h"
+#include "vboot.h"
struct vboot_key {
struct vb21_packed_key vb21_key;
diff --git a/test/version.c b/test/version.c
index 9731863f29..fea691eef7 100644
--- a/test/version.c
+++ b/test/version.c
@@ -9,8 +9,8 @@
#include "ec_commands.h"
#include "stddef.h"
#include "system.h"
-#include "util.h"
#include "test_util.h"
+#include "util.h"
/*
* Tests that fw version adheres to the expected format.
diff --git a/test/vpd_api.c b/test/vpd_api.c
index 51a2e76cd6..e159dcb066 100644
--- a/test/vpd_api.c
+++ b/test/vpd_api.c
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
+#include "console.h"
+#include "driver/tcpm/tcpm.h"
#include "registers.h"
#include "vpd_api.h"
-#include "driver/tcpm/tcpm.h"
-#include "console.h"
/*
* Polarity based on 'DFP Perspective' (see table USB Type-C Cable and Connector
* Specification)
diff --git a/util/build.mk b/util/build.mk
index 2f7f6c48ff..12479d4a7c 100644
--- a/util/build.mk
+++ b/util/build.mk
@@ -97,11 +97,11 @@ build-util-bin-y += gen_touchpad_hash
# Assume RW section (touchpad FW must be identical for both RO+RW)
$(out)/util/gen_touchpad_hash: BUILD_LDFLAGS += -DSECTION_IS_RW=$(EMPTY)
-HOST_OPENSSL_CFLAGS := $(shell $(HOST_PKG_CONFIG) --cflags openssl)
-HOST_OPENSSL_LDFLAGS := $(shell $(HOST_PKG_CONFIG) --libs openssl)
+BUILD_OPENSSL_CFLAGS := $(shell $(BUILD_PKG_CONFIG) --cflags openssl)
+BUILD_OPENSSL_LDFLAGS := $(shell $(BUILD_PKG_CONFIG) --libs openssl)
-$(out)/util/gen_touchpad_hash: BUILD_CFLAGS += $(HOST_OPENSSL_CFLAGS)
-$(out)/util/gen_touchpad_hash: BUILD_LDFLAGS += $(HOST_OPENSSL_LDFLAGS)
+$(out)/util/gen_touchpad_hash: BUILD_CFLAGS += $(BUILD_OPENSSL_CFLAGS)
+$(out)/util/gen_touchpad_hash: BUILD_LDFLAGS += $(BUILD_OPENSSL_LDFLAGS)
deps-y += $(out)/util/gen_touchpad_hash.d
endif # CONFIG_TOUCHPAD_VIRTUAL_OFF
diff --git a/util/build_with_clang.py b/util/build_with_clang.py
index a0afb8a4cd..ae707718e4 100755
--- a/util/build_with_clang.py
+++ b/util/build_with_clang.py
@@ -10,6 +10,7 @@ import concurrent
import logging
import multiprocessing
import os
+import shutil
import subprocess
import sys
import typing
@@ -27,10 +28,12 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [
# Boards that use CHIP:=stm32 and *not* CHIP_FAMILY:=stm32f0
# git grep --name-only 'CHIP:=stm32' | xargs grep -L 'CHIP_FAMILY:=stm32f0' | sed 's#board/\(.*\)/build.mk#"\1",#'
"baklava",
+ "bellis",
"discovery",
"gingerbread",
"hatch_fp",
"hyperdebug",
+ "munna",
"nocturne_fp",
"nucleo-f411re",
"nucleo-g431rb",
@@ -43,8 +46,11 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [
# Boards that use CHIP:=stm32 *and* CHIP_FAMILY:=stm32f0
# git grep --name-only 'CHIP:=stm32' | xargs grep -L 'CHIP_FAMILY:=stm32f0' | sed 's#board/\(.*\)/build.mk#"\1",#'
"bland",
+ "burnet",
"c2d2",
+ "cerise",
"coffeecake",
+ "damu",
"dingdong",
"discovery-stm32f072",
"don",
@@ -56,6 +62,11 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [
"gelatin",
"hammer",
"hoho",
+ "kakadu",
+ "kappa",
+ "katsu",
+ "krane",
+ "kukui",
"magnemite",
"masterball",
"minimuffin",
@@ -67,14 +78,23 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [
"rainier",
"scarlet",
"servo_micro",
+ "servo_v4",
"servo_v4p1",
"staff",
"star",
+ "stern",
"tigertail",
"twinkie",
"wand",
+ "willow",
"zed",
"zinger",
+ # Boards that use CHIP:=mchp
+ # git grep --name-only 'CHIP:=mchp' | sed 's#board/\(.*\)/build.mk#"\1",#'
+ "adlrvpp_mchp1521",
+ "adlrvpp_mchp1727",
+ "mchpevb1",
+ "reef_mchp",
# Boards that use CHIP:=max32660
# git grep --name-only 'CHIP:=max32660' | sed 's#board/\(.*\)/build.mk#"\1",#'
"max32660-eval",
@@ -90,7 +110,6 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [
"banshee",
"berknip",
"bloog",
- "bobba",
"boldar",
"brask",
"brya",
@@ -99,12 +118,10 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [
"careena",
"casta",
"chronicler",
- "coachz",
"collis",
"copano",
"coral",
"corori",
- "corori2",
"cret",
"crota",
"dalboz",
@@ -127,6 +144,7 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [
"fleex",
"foob",
"gaelin",
+ "gelarshie",
"genesis",
"gimble",
"grunt",
@@ -153,6 +171,7 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [
"lux",
"madoo",
"magolor",
+ "marasov",
"marzipan",
"meep",
"metaknight",
@@ -165,6 +184,7 @@ BOARDS_THAT_COMPILE_SUCCESSFULLY_WITH_CLANG = [
"nautilus",
"nightfury",
"nipperkin",
+ "nocturne",
"npcx7_evb",
"npcx9_evb",
"npcx_evb",
@@ -226,6 +246,7 @@ NDS32_BOARDS = [
"beetley",
"blipper",
"boten",
+ "dibbi",
"drawcia",
"galtic",
"gooey",
@@ -261,39 +282,20 @@ RISCV_BOARDS = [
]
BOARDS_THAT_FAIL_WITH_CLANG = [
- # Boards that use CHIP:=stm32 and *not* CHIP_FAMILY:=stm32f0
- "bellis", # overflows flash
- "munna", # overflows flash
# Boards that use CHIP:=stm32 *and* CHIP_FAMILY:=stm32f0
- "burnet", # overflows flash
- "cerise", # overflows flash
"chocodile_vpdmcu", # compilation error: b/254710459
- "damu", # overflows flash
"fennel", # overflows flash
"jacuzzi", # overflows flash
"juniper", # overflows flash
- "kakadu", # overflows flash
- "kappa", # overflows flash
- "katsu", # overflows flash
"kodama", # overflows flash
- "krane", # overflows flash
- "kukui", # overflows flash
"makomo", # overflows flash
"oak", # overflows flash
- "servo_v4", # overflows flash
- "stern", # overflows flash
- "willow", # overflows flash
- # Boards that use CHIP:=mchp
- # git grep --name-only 'CHIP:=mchp' | sed 's#board/\(.*\)/build.mk#"\1",#'
- "adlrvpp_mchp1521", # compilation errors
- "adlrvpp_mchp1727", # compilation errors
- "mchpevb1", # compilation errors
- "reef_mchp", # compilation errors
# Boards that use CHIP:=npcx
+ "bobba", # overflows flash
+ "coachz", # overflows flash
+ "corori2", # overflows flash
"garg", # overflows flash
- "gelarshie", # overflows flash
"mushu", # overflows flash
- "nocturne", # overflows flash
"terrador", # overflows flash
"volteer", # overflows flash
"waddledoo", # overflows flash
@@ -360,9 +362,27 @@ def main() -> int:
"--num_threads", "-j", type=int, default=multiprocessing.cpu_count()
)
+ group = parser.add_mutually_exclusive_group(required=False)
+ group.add_argument(
+ "--clean",
+ action="store_true",
+ help="Remove build directory before compiling",
+ )
+ group.add_argument(
+ "--no-clean",
+ dest="clean",
+ action="store_false",
+ help="Do not remove build directory before compiling",
+ )
+ parser.set_defaults(clean=True)
+
args = parser.parse_args()
logging.basicConfig(level=args.log_level)
+ if args.clean:
+ logging.debug("Removing build directory")
+ shutil.rmtree("./build", ignore_errors=True)
+
check_boards()
logging.debug("Building with %d threads", args.num_threads)
diff --git a/util/cbi-util.c b/util/cbi-util.c
index 5bea9a04b9..2c262c181b 100644
--- a/util/cbi-util.c
+++ b/util/cbi-util.c
@@ -5,20 +5,21 @@
* Cros Board Info utility
*/
-#include <compile_time_macros.h>
+#include "crc8.h"
+#include "cros_board_info.h"
+
#include <errno.h>
-#include <dirent.h>
-#include <getopt.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
-#include <unistd.h>
+#include <string.h>
-#include "cros_board_info.h"
-#include "crc8.h"
+#include <compile_time_macros.h>
+#include <dirent.h>
+#include <getopt.h>
+#include <unistd.h>
#define ARGS_MASK_BOARD_VERSION BIT(0)
#define ARGS_MASK_FILENAME BIT(1)
diff --git a/util/check_clang_format.py b/util/check_clang_format.py
index df98bb0eda..5862c02a3d 100755
--- a/util/check_clang_format.py
+++ b/util/check_clang_format.py
@@ -12,6 +12,7 @@ the pre-upload checks.
import logging
import pathlib
+import shlex
import subprocess
import sys
from typing import List
@@ -27,6 +28,11 @@ def main(argv=None):
action="store_true",
help="Fix any formatting errors automatically.",
)
+ parser.add_argument(
+ "file",
+ nargs="*",
+ help="File or directory to clang-format.",
+ )
opts = parser.parse_args(argv)
logging.info("Validating all code is formatted with clang-format.")
@@ -34,7 +40,7 @@ def main(argv=None):
all_files = [
ec_dir / path
for path in subprocess.run(
- ["git", "ls-files", "-z"],
+ ["git", "ls-files", "-z"] + opts.file,
check=True,
cwd=ec_dir,
stdout=subprocess.PIPE,
@@ -56,12 +62,14 @@ def main(argv=None):
if path.name.endswith(".c") or path.name.endswith(".h"):
cmd.append(path)
+ logging.debug("Running %s", " ".join(shlex.quote(str(x)) for x in cmd))
result = subprocess.run(
cmd,
check=False,
cwd=ec_dir,
stderr=subprocess.PIPE,
encoding="utf-8",
+ stdin=subprocess.DEVNULL,
)
if result.stderr:
logging.error("All C source must be formatted with clang-format!")
diff --git a/util/clangd_config.py b/util/clangd_config.py
index 2553707c43..1e013b4159 100755
--- a/util/clangd_config.py
+++ b/util/clangd_config.py
@@ -32,7 +32,7 @@ def ec_fetch_boards(ec_root: Path) -> Optional[List[str]]:
def zephyr_fetch_projects(ec_root: Path) -> Optional[List[str]]:
"""Return a list of Zephyr projects seen."""
- base = str(ec_root) + "/zephyr/projects/"
+ base = str(ec_root) + "/zephyr/program/"
boards = glob.glob(base + "*")
if boards is None:
diff --git a/util/comm-dev.cc b/util/comm-dev.cc
index f6467492f9..bbb79a448c 100644
--- a/util/comm-dev.cc
+++ b/util/comm-dev.cc
@@ -292,3 +292,8 @@ int comm_init_dev(const char *device_name)
return 0;
}
+
+int comm_get_fd()
+{
+ return fd;
+}
diff --git a/util/comm-host.h b/util/comm-host.h
index 907df3df96..0f07bb48f3 100644
--- a/util/comm-host.h
+++ b/util/comm-host.h
@@ -53,6 +53,14 @@ int comm_init_alt(int interfaces, const char *device_name, int i2c_bus);
int comm_init_dev(const char *device_name);
/**
+ * Get the file descriptor associated with the dev interface. comm_init_dev
+ * must be called first in order for the file descriptor to be valid.
+ *
+ * @return file descriptor
+ */
+int comm_get_fd(void);
+
+/**
* Initialize input & output buffers
*
* @return 0 in case of success, or error code.
diff --git a/util/config_allowed.txt b/util/config_allowed.txt
index e503e96f94..f7e20b379c 100644
--- a/util/config_allowed.txt
+++ b/util/config_allowed.txt
@@ -122,15 +122,7 @@ CONFIG_BOARD_I2C_ADDR_FLAGS
CONFIG_BOARD_ID_CMD_ACPI_EC1
CONFIG_BOARD_POST_GPIO_INIT
CONFIG_BOARD_PRE_INIT
-CONFIG_BODY_DETECTION
-CONFIG_BODY_DETECTION_CONFIDENCE_DELTA
-CONFIG_BODY_DETECTION_MAX_WINDOW_SIZE
-CONFIG_BODY_DETECTION_OFF_BODY_CON
-CONFIG_BODY_DETECTION_ON_BODY_CON
CONFIG_BODY_DETECTION_SENSOR
-CONFIG_BODY_DETECTION_STATIONARY_DURATION
-CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR
-CONFIG_BODY_DETECTION_VAR_THRESHOLD
CONFIG_BOOTBLOCK
CONFIG_BOOTCFG_VALUE
CONFIG_BOOT_HEADER_STORAGE_OFF
@@ -169,7 +161,6 @@ CONFIG_CHARGE_MANAGER_BAT_PCT_SAFE_MODE_EXIT
CONFIG_CHARGE_MANAGER_DRP_CHARGING
CONFIG_CHARGE_MANAGER_EXTERNAL_POWER_LIMIT
CONFIG_CHARGE_MANAGER_SAFE_MODE
-CONFIG_CHARGE_STATE_DEBUG
CONFIG_CHIPSET_ALDERLAKE
CONFIG_CHIPSET_APL_GLK
CONFIG_CHIPSET_APOLLOLAKE
@@ -287,7 +278,6 @@ CONFIG_CMD_POWERLED
CONFIG_CMD_POWER_AP
CONFIG_CMD_PPC_DUMP
CONFIG_CMD_PS2
-CONFIG_CMD_PWR_AVG
CONFIG_CMD_RAND
CONFIG_CMD_REGULATOR
CONFIG_CMD_RESET_FLAGS
@@ -342,7 +332,6 @@ CONFIG_CROS_EC_RW_MEM_SIZE
CONFIG_CTN730
CONFIG_CTS_TASK_LIST
CONFIG_CURVE25519
-CONFIG_CUSTOM_FAN_CONTROL
CONFIG_DATA_RAM_SIZE
CONFIG_DEBUG_BRINGUP
CONFIG_DEBUG_DISABLE_WRITE_BUFFER
@@ -387,7 +376,6 @@ CONFIG_ENABLE_JTAG_SELECTION
CONFIG_EVENT_LOG_SIZE
CONFIG_EXPERIMENTAL_CONSOLE
CONFIG_EXTENDED_VERSION_INFO
-CONFIG_EXTPOWER_DEBOUNCE_MS
CONFIG_FAKE_SHMEM
CONFIG_FANS
CONFIG_FAN_DSLEEP
@@ -419,6 +407,7 @@ CONFIG_FLASH_WRITE_SIZE
CONFIG_FMAP
CONFIG_FOO
CONFIG_FORCE_CONSOLE_RESUME
+CONFIG_FPU
CONFIG_FPU_WARNINGS
CONFIG_FP_SENSOR_ELAN515
CONFIG_FP_SENSOR_ELAN80
@@ -432,7 +421,6 @@ CONFIG_FW_PSTATE_OFF
CONFIG_FW_PSTATE_SIZE
CONFIG_GESTURE_DETECTION
CONFIG_GESTURE_DETECTION_MASK
-CONFIG_GESTURE_HOST_DETECTION
CONFIG_GESTURE_ORIENTATION
CONFIG_GESTURE_SAMPLING_INTERVAL_MS
CONFIG_GESTURE_SENSOR_DOUBLE_TAP
@@ -459,10 +447,8 @@ CONFIG_H2RAM_BASE
CONFIG_H2RAM_HOST_LPC_IO_BASE
CONFIG_H2RAM_SIZE
CONFIG_HAS_TASK_PD_INT
-CONFIG_HIBERNATE
CONFIG_HIBERNATE_BATT_PCT
CONFIG_HIBERNATE_BATT_SEC
-CONFIG_HIBERNATE_DELAY_SEC
CONFIG_HIBERNATE_PSL_COMPENSATE_RTC
CONFIG_HIBERNATE_PSL_OUT_FLAGS
CONFIG_HIBERNATE_PSL_VCC1_RST_WAKEUP
@@ -563,7 +549,6 @@ CONFIG_ITE_FLASH_SUPPORT
CONFIG_KEYBOARD_ASSISTANT_KEY
CONFIG_KEYBOARD_BACKLIGHT
CONFIG_KEYBOARD_BOOT_KEYS
-CONFIG_KEYBOARD_FACTORY_TEST
CONFIG_KEYBOARD_IRQ_GPIO
CONFIG_KEYBOARD_KSO_BASE
CONFIG_KEYBOARD_KSO_HIGH_DRIVE
@@ -827,7 +812,6 @@ CONFIG_STM32_CLOCK_HSE_HZ
CONFIG_STM32_CLOCK_LSE
CONFIG_STM32_EXTENDED_RESET_FLAGS
CONFIG_STM32_SPI1_CONTROLLER
-CONFIG_STM_HWTIMER32
CONFIG_STREAM_SIGNATURE
CONFIG_STREAM_USART
CONFIG_STREAM_USART1
diff --git a/util/corsola-relevant-paths.txt b/util/corsola-relevant-paths.txt
new file mode 100644
index 0000000000..3bb8e4f5a7
--- /dev/null
+++ b/util/corsola-relevant-paths.txt
@@ -0,0 +1,32 @@
+# Here you can place files of interest to be included in the commit message for
+# merge commits to cros/firmware-corsola-15194.B
+common/charge_state_v2.c
+common/dps.c
+common/mkbp_*
+common/usb_charger.c
+common/usb_common.c
+common/usbc/*_pd_*
+common/usbc/dp_alt_mode.c
+common/usbc/usb_pe_drp_sm.c
+common/usbc/usb_prl_sm.c
+common/usbc/usb_sm.c
+common/usbc/usb_tc_drp_acc_trysrc_sm.c
+driver/battery/smart.c
+driver/bc12/pi3usb9201.*
+driver/charger/isl923x.*
+driver/charger/rt949*
+driver/ppc/nx20p348x.*
+driver/ppc/rt1718s.*
+driver/ppc/syv682x.*
+driver/tcpm/anx7447.*
+driver/tcpm/rt1718s.*
+driver/tcpm/tcpci.*
+driver/usb_mux/it5205.*
+driver/usb_mux/ps8743.*
+power/mt8186.c
+zephyr/boards/arm/npcx9/*
+zephyr/boards/riscv/it8xxx2/*
+zephyr/drivers/*
+zephyr/projects/corsola/*
+zephyr/projects/corsola/*
+zephyr/shim/*
diff --git a/util/crash_analyzer.py b/util/crash_analyzer.py
index c2e07face2..88592f800a 100755
--- a/util/crash_analyzer.py
+++ b/util/crash_analyzer.py
@@ -124,7 +124,23 @@ def cm0_parse(match) -> dict:
regs["ipsr"] = values[22]
regs["cause"] = get_crash_cause(values[6]) # r4
- regs["symbol"] = get_symbol(values[7]) # r5
+
+ # based on crash reports in case of asserrt the PC is in R3
+ if regs["cause"] == "assert":
+ regs["symbol"] = get_symbol(values[5]) # r3
+ else:
+ # Heuristics: try link register, then PC, then what is believed to be PC.
+ # When analyzing watchdogs, we try to be as close as possible to the caller
+ # function that caused the watchdog.
+ # That's why we prioritize LR (return address) over PC.
+ if regs["lr"] != -1:
+ regs["symbol"] = get_symbol(regs["lr"])
+ elif regs["pc"] != -1:
+ regs["symbol"] = get_symbol(regs["pc"])
+ else:
+ # Otherwise, if both LR and PC are empty, most probably
+ # PC is in R5.
+ regs["symbol"] = get_symbol(values[7]) # r5
return regs
diff --git a/util/cros_ec_dev.h b/util/cros_ec_dev.h
index 3ffed56632..6421afc601 100644
--- a/util/cros_ec_dev.h
+++ b/util/cros_ec_dev.h
@@ -6,9 +6,10 @@
#ifndef __UTIL_CROS_EC_DEV_H
#define __UTIL_CROS_EC_DEV_H
+#include "ec_commands.h"
+
#include <linux/ioctl.h>
#include <linux/types.h>
-#include "ec_commands.h"
#ifdef __cplusplus
extern "C" {
diff --git a/util/ecst.h b/util/ecst.h
index 7d3dbbe153..fed160e22a 100644
--- a/util/ecst.h
+++ b/util/ecst.h
@@ -11,9 +11,10 @@
Includes
--------------------------------------------------------------------------*/
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <stdio.h>
+
#include <curses.h>
/*---------------------------------------------------------------------------
diff --git a/util/ectool.cc b/util/ectool.cc
index 61c0e85301..fd27105d1f 100644
--- a/util/ectool.cc
+++ b/util/ectool.cc
@@ -33,8 +33,11 @@
#include "lock/gec_lock.h"
#include "misc_util.h"
#include "panic.h"
+#include "tablet_mode.h"
#include "usb_pd.h"
+#include <libec/add_entropy_command.h>
+
/* Maximum flash size (16 MB, conservative) */
#define MAX_FLASH_SIZE 0x1000000
@@ -313,6 +316,8 @@ const char help_str[] =
" Display system info.\n"
" switches\n"
" Prints current EC switch positions\n"
+ " tabletmode [on | off | reset]\n"
+ " Manually force tablet mode to on, off or reset.\n"
" temps <sensorid>\n"
" Print temperature and temperature ratio between fan_off and\n"
" fan_max values, which could be a fan speed if it's controlled\n"
@@ -564,39 +569,24 @@ int cmd_adc_read(int argc, char *argv[])
int cmd_add_entropy(int argc, char *argv[])
{
- struct ec_params_rollback_add_entropy p;
- int rv;
- int tries = 100; /* Wait for 10 seconds at most */
-
+ bool reset = false;
if (argc >= 2 && !strcmp(argv[1], "reset"))
- p.action = ADD_ENTROPY_RESET_ASYNC;
- else
- p.action = ADD_ENTROPY_ASYNC;
-
- rv = ec_command(EC_CMD_ADD_ENTROPY, 0, &p, sizeof(p), NULL, 0);
-
- if (rv != EC_RES_SUCCESS)
- goto out;
-
- while (tries--) {
- usleep(100000);
+ reset = true;
- p.action = ADD_ENTROPY_GET_RESULT;
- rv = ec_command(EC_CMD_ADD_ENTROPY, 0, &p, sizeof(p), NULL, 0);
-
- if (rv == EC_RES_SUCCESS) {
- printf("Entropy added successfully\n");
- return EC_RES_SUCCESS;
- }
+ ec::AddEntropyCommand add_entropy_command(reset);
+ if (!add_entropy_command.Run(comm_get_fd())) {
+ fprintf(stderr, "Failed to run addentropy command\n");
+ return -1;
+ }
- /* Abort if EC returns an error other than EC_RES_BUSY. */
- if (rv <= -EECRESULT && rv != -EECRESULT - EC_RES_BUSY)
- goto out;
+ int rv = add_entropy_command.Result();
+ if (rv != EC_RES_SUCCESS) {
+ rv = -EECRESULT - add_entropy_command.Result();
+ fprintf(stderr, "Failed to add entropy: %d\n", rv);
+ return rv;
}
- rv = -EECRESULT - EC_RES_TIMEOUT;
-out:
- fprintf(stderr, "Failed to add entropy: %d\n", rv);
+ printf("Entropy added successfully\n");
return rv;
}
@@ -884,7 +874,7 @@ int cmd_test(int argc, char *argv[])
int cmd_s5(int argc, char *argv[])
{
struct ec_params_get_set_value p;
- struct ec_params_get_set_value r;
+ struct ec_response_get_set_value r;
int rv, param;
p.flags = 0;
@@ -7271,6 +7261,37 @@ int cmd_switches(int argc, char *argv[])
return 0;
}
+int cmd_tabletmode(int argc, char *argv[])
+{
+ struct ec_params_set_tablet_mode p;
+
+ if (argc != 2)
+ return EC_ERROR_PARAM_COUNT;
+
+ memset(&p, 0, sizeof(p));
+ if (argv[1][0] == 'o' && argv[1][1] == 'n') {
+ p.tablet_mode = TABLET_MODE_FORCE_TABLET;
+ } else if (argv[1][0] == 'o' && argv[1][1] == 'f') {
+ p.tablet_mode = TABLET_MODE_FORCE_CLAMSHELL;
+ } else if (argv[1][0] == 'r') {
+ // Match tablet mode to the current HW orientation.
+ p.tablet_mode = TABLET_MODE_DEFAULT;
+ } else {
+ return EC_ERROR_PARAM1;
+ }
+
+ int rv = ec_command(EC_CMD_SET_TABLET_MODE, 0, &p, sizeof(p), NULL, 0);
+ rv = (rv < 0 ? rv : 0);
+
+ if (rv < 0) {
+ fprintf(stderr, "Failed to set tablet mode, rv=%d\n", rv);
+ } else {
+ printf("\n");
+ printf("SUCCESS. The tablet mode has been set.\n");
+ }
+ return rv;
+}
+
int cmd_wireless(int argc, char *argv[])
{
char *e;
@@ -10149,7 +10170,10 @@ int cmd_typec_control(int argc, char *argv[])
" <mux_mode> is one of: dp, dock, usb, tbt,\n"
" usb4, none, safe\n"
" 5: Enable bist share mode\n"
- " args: <0: DISABLE, 1: ENABLE>\n",
+ " args: <0: DISABLE, 1: ENABLE>\n"
+ " 6: Send VDM REQ\n"
+ " args: <tx_type vdm_hdr [vdo...]>\n"
+ " <tx_type> is 0 - SOP, 1 - SOP', 2 - SOP''\n",
argv[0]);
return -1;
}
@@ -10253,6 +10277,35 @@ int cmd_typec_control(int argc, char *argv[])
}
p.bist_share_mode = conversion_result;
break;
+ case TYPEC_CONTROL_COMMAND_SEND_VDM_REQ:
+ if (argc < 5) {
+ fprintf(stderr, "Missing VDM header and type\n");
+ return -1;
+ }
+ if (argc > 4 + VDO_MAX_SIZE) {
+ fprintf(stderr, "Too many VDOs\n");
+ return -1;
+ }
+
+ conversion_result = strtol(argv[3], &endptr, 0);
+ if ((endptr && *endptr) || conversion_result > UINT8_MAX ||
+ conversion_result < 0) {
+ fprintf(stderr, "Bad SOP* type\n");
+ return -1;
+ }
+ p.vdm_req_params.partner_type = conversion_result;
+
+ int vdm_index;
+ for (vdm_index = 0; vdm_index < argc - 4; vdm_index++) {
+ uint32_t vdm_entry =
+ strtoul(argv[vdm_index + 4], &endptr, 0);
+ if (endptr && *endptr) {
+ fprintf(stderr, "Bad VDO\n");
+ return -1;
+ }
+ p.vdm_req_params.vdm_data[vdm_index] = vdm_entry;
+ }
+ p.vdm_req_params.vdm_data_objects = vdm_index;
}
rv = ec_command(EC_CMD_TYPEC_CONTROL, 0, &p, sizeof(p), ec_inbuf,
@@ -10991,6 +11044,7 @@ const struct command commands[] = {
{ "sysinfo", cmd_sysinfo },
{ "port80flood", cmd_port_80_flood },
{ "switches", cmd_switches },
+ { "tabletmode", cmd_tabletmode },
{ "temps", cmd_temperature },
{ "tempsinfo", cmd_temp_sensor_info },
{ "test", cmd_test },
diff --git a/util/export_taskinfo.c b/util/export_taskinfo.c
index af40ef8de6..0fe8644792 100644
--- a/util/export_taskinfo.c
+++ b/util/export_taskinfo.c
@@ -6,11 +6,11 @@
* section definitions to export different tasklists.
*/
-#include <stdint.h>
-
#include "config.h"
#include "task_id.h"
+#include <stdint.h>
+
#ifdef SECTION_IS_RO
#define GET_TASKINFOS_FUNC get_ro_taskinfos
#elif defined(SECTION_IS_RW)
diff --git a/util/flash_fp_mcu b/util/flash_fp_mcu
index 578382c213..4f8fa26749 100644
--- a/util/flash_fp_mcu
+++ b/util/flash_fp_mcu
@@ -702,6 +702,26 @@ config_ghost() {
config_brya
}
+config_rex() {
+ readonly TRANSPORT="SPI"
+ readonly DEVICE="/dev/spidev0.0"
+
+ # See kernel/v5.15/drivers/pinctrl/intel/pinctrl-meteorlake.c
+ # for pin name and pin number.
+ # Examine `cat /sys/kernel/debug/pinctrl/INTC1083:00/gpio-ranges` on a
+ # rex device to determine gpio number from pin number.
+ # For example: GPP_B11, the pin number is 215 from the pinctrl-meteorlake.c.
+ # From the gpio-ranges, the gpio value is 925 + (215-204) = 936
+
+ readonly GPIO_CHIP="gpiochip573"
+ # FPMCU RST_ODL is on GPP_C23 = 637 + (52 - 29) = 660
+ readonly GPIO_NRST=660
+ # FPMCU BOOT0 is on GPP_C22 = 637 + (51 - 29) = 659
+ readonly GPIO_BOOT0=659
+ # FP_PWR_EN is on GPP_B11 = 925 + (215-204) = 936
+ readonly GPIO_PWREN=936
+}
+
config_zork() {
readonly TRANSPORT="UART"
readonly DEVICE="/dev/ttyS1"
diff --git a/util/gen_emmc_transfer_data.c b/util/gen_emmc_transfer_data.c
index 3c80724594..1de9d6b5a0 100644
--- a/util/gen_emmc_transfer_data.c
+++ b/util/gen_emmc_transfer_data.c
@@ -6,14 +6,14 @@
* eMMC protocol.
*/
-#include <err.h>
#include <errno.h>
-#include <getopt.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <compile_time_macros.h>
+#include <err.h>
+#include <getopt.h>
/* eMMC transfer block size */
#define BLOCK_SIZE 512
diff --git a/util/gen_touchpad_hash.c b/util/gen_touchpad_hash.c
index 98370038b7..edf1022bf9 100644
--- a/util/gen_touchpad_hash.c
+++ b/util/gen_touchpad_hash.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
-#include <err.h>
-#include <getopt.h>
-#include <stdio.h>
+#include "config.h"
+
#include <stdint.h>
+#include <stdio.h>
#include <string.h>
-#include <unistd.h>
+#include <err.h>
+#include <getopt.h>
#include <openssl/sha.h>
-
-#include "config.h"
+#include <unistd.h>
static void print_hex(FILE *out, uint8_t *digest, int len, int last)
{
diff --git a/util/genvif.c b/util/genvif.c
index 543577cb11..892bf14367 100644
--- a/util/genvif.c
+++ b/util/genvif.c
@@ -5,25 +5,25 @@
#define _GNU_SOURCE /* for asprintf */
+#include "charge_manager.h"
+#include "config.h"
+#include "genvif.h"
+#include "usb_pd.h"
+#include "usb_pd_pdo.h"
+#include "usb_pd_tcpm.h"
+
+#include <ctype.h>
#include <errno.h>
+#include <limits.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
-#include <string.h>
#include <stdlib.h>
-#include <getopt.h>
-#include <dirent.h>
-#include <limits.h>
-#include <ctype.h>
-
-#include "config.h"
-#include "usb_pd.h"
-#include "usb_pd_pdo.h"
-#include "usb_pd_tcpm.h"
-#include "charge_manager.h"
+#include <string.h>
-#include "genvif.h"
+#include <dirent.h>
+#include <getopt.h>
#define VIF_APP_VENDOR_VALUE "Google"
#define VIF_APP_NAME_VALUE "EC GENVIF"
diff --git a/util/gpios_to_zephyr_dts.c b/util/gpios_to_zephyr_dts.c
index d0e51b3e46..7efcd67ceb 100644
--- a/util/gpios_to_zephyr_dts.c
+++ b/util/gpios_to_zephyr_dts.c
@@ -32,8 +32,8 @@
#define _POSIX_C_SOURCE 200809L
#include <ctype.h>
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
/*
diff --git a/util/iteflash.c b/util/iteflash.c
index 9085365135..8b03c2e4cb 100644
--- a/util/iteflash.c
+++ b/util/iteflash.c
@@ -8,25 +8,26 @@
/* remove when ftdi_usb_purge_buffers has been replaced to follow libftdi */
#define _FTDI_DISABLE_DEPRECATED
+#include "compile_time_macros.h"
+#include "usb_if.h"
+
#include <errno.h>
-#include <fcntl.h>
-#include <ftdi.h>
-#include <getopt.h>
-#include <linux/i2c-dev.h>
-#include <linux/i2c.h>
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/ioctl.h>
#include <time.h>
-#include <unistd.h>
-#include <sys/wait.h>
-#include "compile_time_macros.h"
-#include "usb_if.h"
+#include <fcntl.h>
+#include <ftdi.h>
+#include <getopt.h>
+#include <linux/i2c-dev.h>
+#include <linux/i2c.h>
+#include <sys/ioctl.h>
+#include <sys/wait.h>
+#include <unistd.h>
/* Default FTDI device : Servo v2. */
#define SERVO_USB_VID 0x18d1
diff --git a/util/kconfig_check.py b/util/kconfig_check.py
index e745b3aeca..f3d127175c 100755
--- a/util/kconfig_check.py
+++ b/util/kconfig_check.py
@@ -259,8 +259,8 @@ class KconfigCheck:
dirs.remove("Kconfig")
if "boards" in dirs:
dirs.remove("boards")
- if "projects" in dirs:
- dirs.remove("projects")
+ if "program" in dirs:
+ dirs.remove("program")
if "test" in dirs:
dirs.remove("test")
if "chip" in dirs:
diff --git a/util/run_host_test b/util/run_host_test
index 3108da1852..3ee8ccc7ed 100755
--- a/util/run_host_test
+++ b/util/run_host_test
@@ -26,6 +26,7 @@ class TestResult(enum.Enum):
@property
def reason(self):
+ """Return a map of test result enums to descriptions."""
return {
TestResult.SUCCESS: 'passed',
TestResult.FAIL: 'failed',
@@ -35,11 +36,12 @@ class TestResult(enum.Enum):
def run_test(path, timeout=10):
+ """Runs a test."""
start_time = time.monotonic()
env = dict(os.environ)
env['ASAN_OPTIONS'] = 'log_path=stderr'
- proc = subprocess.Popen(
+ with subprocess.Popen(
[path],
bufsize=0,
stdin=subprocess.PIPE,
@@ -47,49 +49,50 @@ def run_test(path, timeout=10):
env=env,
encoding='utf-8',
errors='replace',
- )
-
- # Put the output pipe in non-blocking mode. We will then select(2)
- # on the pipe to know when we have bytes to process.
- os.set_blocking(proc.stdout.fileno(), False)
-
- try:
- output_buffer = io.StringIO()
- while True:
- select_timeout = timeout - (time.monotonic() - start_time)
- if select_timeout <= 0:
- return TestResult.TIMEOUT, output_buffer.getvalue()
-
- readable, _, _ = select.select(
- [proc.stdout], [], [], select_timeout)
-
- if not readable:
- # Indicates that select(2) timed out.
- return TestResult.TIMEOUT, output_buffer.getvalue()
-
- output_buffer.write(proc.stdout.read())
- output_log = output_buffer.getvalue()
-
- if 'Pass!' in output_log:
- return TestResult.SUCCESS, output_log
- if 'Fail!' in output_log:
- return TestResult.FAIL, output_log
- if proc.poll():
- return TestResult.UNEXPECTED_TERMINATION, output_log
- finally:
- # Check if the process has exited. If not, send it a SIGTERM, wait for
- # it to exit, and if it times out, kill the process directly.
- if not proc.poll():
- try:
- proc.terminate()
- proc.wait(timeout)
- except subprocess.TimeoutExpired:
- proc.kill()
+ ) as proc:
+
+ # Put the output pipe in non-blocking mode. We will then select(2)
+ # on the pipe to know when we have bytes to process.
+ os.set_blocking(proc.stdout.fileno(), False)
+
+ try:
+ output_buffer = io.StringIO()
+ while True:
+ select_timeout = timeout - (time.monotonic() - start_time)
+ if select_timeout <= 0:
+ return TestResult.TIMEOUT, output_buffer.getvalue()
+
+ readable, _, _ = select.select(
+ [proc.stdout], [], [], select_timeout)
+
+ if not readable:
+ # Indicates that select(2) timed out.
+ return TestResult.TIMEOUT, output_buffer.getvalue()
+
+ output_buffer.write(proc.stdout.read())
+ output_log = output_buffer.getvalue()
+
+ if 'Pass!' in output_log:
+ return TestResult.SUCCESS, output_log
+ if 'Fail!' in output_log:
+ return TestResult.FAIL, output_log
+ if proc.poll():
+ return TestResult.UNEXPECTED_TERMINATION, output_log
+ finally:
+ # Check if the process has exited. If not, send it a SIGTERM, wait
+ # for it to exit, and if it times out, kill the process directly.
+ if not proc.poll():
+ try:
+ proc.terminate()
+ proc.wait(timeout)
+ except subprocess.TimeoutExpired:
+ proc.kill()
def parse_options(argv):
+ """Parse command line flags."""
parser = argparse.ArgumentParser()
- parser.add_argument('-t', '--timeout', type=float, default=60,
+ parser.add_argument('-t', '--timeout', type=float, default=120,
help='Timeout to kill test after.')
parser.add_argument('--coverage', action='store_const', const='coverage',
default='host', dest='test_target',
@@ -101,6 +104,7 @@ def parse_options(argv):
def main(argv):
+ """The main function."""
opts = parse_options(argv)
# Tests will be located in build/host, unless the --coverage flag was
diff --git a/util/twister_launcher.py b/util/twister_launcher.py
index 033b4c59dd..11202f9343 100755
--- a/util/twister_launcher.py
+++ b/util/twister_launcher.py
@@ -37,6 +37,10 @@ parameters that may be used, please consult the Twister documentation.
# version: "version:5.8.0.chromium.3"
# >
# wheel: <
+# name: "infra/python/wheels/pyelftools-py2_py3"
+# version: "version:0.29"
+# >
+# wheel: <
# name: "infra/python/wheels/pykwalify-py2_py3"
# version: "version:1.8.0"
# >
@@ -77,8 +81,10 @@ parameters that may be used, please consult the Twister documentation.
import argparse
import json
import os
+import pathlib
import re
import shlex
+import shutil
import subprocess
import sys
import time
@@ -92,7 +98,8 @@ def find_checkout() -> Path:
if cros_checkout is not None:
return Path(cros_checkout)
- # Attempt to locate checkout location relatively if being run outside of chroot.
+ # Attempt to locate checkout location relatively if being run outside of
+ # chroot.
try:
cros_checkout = Path(__file__).resolve().parents[4]
assert (cros_checkout / "src").exists()
@@ -167,59 +174,75 @@ def is_rdb_login():
return ret.returncode == 0
-def upload_results(ec_base):
+def upload_results(ec_base, outdir):
"""Uploads Zephyr Test results to ResultDB"""
flag = False
if is_rdb_login():
- json_path = ec_base / "twister-out" / "twister.json"
- cmd = [
- "rdb",
- "stream",
- "-new",
- "-realm",
- "chromium:public",
- "--",
- str(ec_base / "util/zephyr_to_resultdb.py"),
- "--result=" + str(json_path),
- "--upload=True",
- ]
-
- start_time = time.time()
- ret = subprocess.run(cmd, capture_output=True, text=True, check=True)
- end_time = time.time()
-
- # Extract URL to test report from captured output
- rdb_url = re.search(
- r"(?P<url>https?://[^\s]+)", ret.stderr.split("\n")[0]
- ).group("url")
- print(f"\nTEST RESULTS ({end_time - start_time:.3f}s): {rdb_url}\n")
- flag = ret.returncode == 0
+ json_path = pathlib.Path(outdir) / "twister.json"
+
+ if json_path.exists():
+ cmd = [
+ "rdb",
+ "stream",
+ "-new",
+ "-realm",
+ "chromium:public",
+ "--",
+ "vpython3",
+ str(ec_base / "util/zephyr_to_resultdb.py"),
+ "--result=" + str(json_path),
+ "--upload=True",
+ ]
+
+ start_time = time.time()
+ ret = subprocess.run(
+ cmd, capture_output=True, text=True, check=True
+ )
+ end_time = time.time()
+
+ # Extract URL to test report from captured output
+ rdb_url = re.search(
+ r"(?P<url>https?://[^\s]+)", ret.stderr.split("\n")[0]
+ ).group("url")
+ print(f"\nTEST RESULTS ({end_time - start_time:.3f}s): {rdb_url}\n")
+ flag = ret.returncode == 0
else:
print("Unable to upload test results, please run 'rdb auth-login'\n")
return flag
-def check_for_skipped_tests(ec_base):
+def check_for_skipped_tests(outdir):
"""Checks Twister json test report for skipped tests"""
found_skipped = False
- json_path = ec_base / "twister-out" / "twister.json"
- with open(json_path) as file:
- data = json.load(file)
+ json_path = pathlib.Path(outdir) / "twister.json"
+ if json_path.exists():
+ with open(json_path) as file:
+ data = json.load(file)
- for testsuite in data["testsuites"]:
- for testcase in testsuite["testcases"]:
- if testcase["status"] == "skipped":
- tc_name = testcase["identifier"]
- print(f"TEST SKIPPED: {tc_name}")
- found_skipped = True
+ for testsuite in data["testsuites"]:
+ for testcase in testsuite["testcases"]:
+ if testcase["status"] == "skipped":
+ tc_name = testcase["identifier"]
+ print(f"TEST SKIPPED: {tc_name}")
+ found_skipped = True
- file.close()
+ file.close()
return found_skipped
+def append_cmake_compiler(cmdline, cmake_var, exe_options):
+ """Picks the first available exe from exe_options and adds a cmake variable
+ to cmdline."""
+ for exe in exe_options:
+ exe_path = shutil.which(exe)
+ if exe_path:
+ cmdline.append(f"-x={cmake_var}={exe_path}")
+ return
+
+
def main():
"""Run Twister using defaults for the EC project."""
@@ -233,21 +256,6 @@ def main():
if ec_base.resolve() not in zephyr_modules:
zephyr_modules.append(ec_base)
- # Prepare environment variables for export to Twister. Inherit the parent
- # process's environment, but set some default values if not already set.
- twister_env = dict(os.environ)
- is_in_chroot = Path("/etc/cros_chroot_version").is_file()
- extra_env_vars = {
- "TOOLCHAIN_ROOT": os.environ.get(
- "TOOLCHAIN_ROOT",
- str(ec_base / "zephyr") if is_in_chroot else zephyr_base,
- ),
- "ZEPHYR_TOOLCHAIN_VARIANT": os.environ.get(
- "ZEPHYR_TOOLCHAIN_VARIANT", "llvm" if is_in_chroot else "host"
- ),
- }
- twister_env.update(extra_env_vars)
-
# Twister CLI args
# TODO(b/239165779): Reduce or remove the usage of label properties
# Zephyr upstream has deprecated the label property. We need to allow
@@ -263,6 +271,7 @@ def main():
f"-x=ZEPHYR_BASE={zephyr_base}",
f"-x=ZEPHYR_MODULES={';'.join([str(p) for p in zephyr_modules])}",
]
+ is_in_chroot = Path("/etc/cros_chroot_version").is_file()
# `-T` flags (used for specifying test directories to build and run)
# require special handling. When run without `-T` flags, Twister will
@@ -276,11 +285,31 @@ def main():
parser.add_argument("-T", "--testsuite-root", action="append")
parser.add_argument("-p", "--platform", action="append")
parser.add_argument("-v", "--verbose", action="count", default=0)
+ parser.add_argument("--gcov-tool")
parser.add_argument(
- "--gcov-tool", default=str(ec_base / "util" / "llvm-gcov.sh")
+ "--no-upload-cros-rdb", dest="upload_cros_rdb", action="store_false"
)
parser.add_argument(
- "--no-upload-cros-rdb", dest="upload_cros_rdb", action="store_false"
+ "-O",
+ "--outdir",
+ default=os.path.join(os.getcwd(), "twister-out"),
+ )
+ parser.add_argument(
+ "--toolchain",
+ default=os.environ.get(
+ "ZEPHYR_TOOLCHAIN_VARIANT",
+ "llvm" if is_in_chroot else "host",
+ ),
+ )
+ parser.add_argument(
+ "--gcc", dest="toolchain", action="store_const", const="host"
+ )
+ parser.add_argument(
+ "--llvm",
+ "--clang",
+ dest="toolchain",
+ action="store_const",
+ const="llvm",
)
intercepted_args, other_args = parser.parse_known_args()
@@ -294,19 +323,14 @@ def main():
for arg in intercepted_args.testsuite_root:
twister_cli.extend(["-T", arg])
else:
- # Use EC base dir when no -T args specified. This will cause all
- # Twister-compatible EC tests to run.
- twister_cli.extend(["-T", str(ec_base)])
+ # Use this set of test suite roots when no -T args are present. This
+ # should encompass all current Zephyr EC tests. The paths are meant to
+ # be as specific as possible to limit Twister's search scope. This saves
+ # significant time when starting Twister.
+ twister_cli.extend(["-T", str(ec_base / "common")])
+ twister_cli.extend(["-T", str(ec_base / "zephyr/test")])
twister_cli.extend(["-T", str(zephyr_base / "tests/subsys/shell")])
- # Pass through the chosen coverage tool, or fall back on the default choice
- # (see add_argument above).
- twister_cli.extend(
- [
- "--gcov-tool",
- intercepted_args.gcov_tool,
- ]
- )
if intercepted_args.platform:
# Pass user-provided -p args when present.
for arg in intercepted_args.platform:
@@ -316,6 +340,32 @@ def main():
twister_cli.extend(["-p", "native_posix"])
twister_cli.extend(["-p", "unit_testing"])
+ twister_cli.extend(["--outdir", intercepted_args.outdir])
+
+ # Prepare environment variables for export to Twister. Inherit the parent
+ # process's environment, but set some default values if not already set.
+ twister_env = dict(os.environ)
+ extra_env_vars = {
+ "TOOLCHAIN_ROOT": os.environ.get(
+ "TOOLCHAIN_ROOT",
+ str(ec_base / "zephyr") if is_in_chroot else str(zephyr_base),
+ ),
+ "ZEPHYR_TOOLCHAIN_VARIANT": intercepted_args.toolchain,
+ }
+ gcov_tool = None
+ if intercepted_args.toolchain == "host":
+ gcov_tool = "gcov"
+ elif intercepted_args.toolchain == "llvm":
+ gcov_tool = str(ec_base / "util" / "llvm-gcov.sh")
+ else:
+ print("Unknown toolchain specified:", intercepted_args.toolchain)
+ if intercepted_args.gcov_tool:
+ gcov_tool = intercepted_args.gcov_tool
+ if gcov_tool:
+ twister_cli.extend(["--gcov-tool", gcov_tool])
+
+ twister_env.update(extra_env_vars)
+
# Append additional user-supplied args
twister_cli.extend(other_args)
@@ -334,7 +384,7 @@ def main():
# Invoke Twister and wait for it to exit.
result = subprocess.run(twister_cli, env=twister_env, check=False)
- if check_for_skipped_tests(ec_base):
+ if check_for_skipped_tests(intercepted_args.outdir):
result.returncode = 1
if result.returncode == 0:
@@ -343,7 +393,7 @@ def main():
print("TEST EXECUTION FAILED")
if is_tool("rdb") and intercepted_args.upload_cros_rdb:
- upload_results(ec_base)
+ upload_results(ec_base, intercepted_args.outdir)
sys.exit(result.returncode)
diff --git a/util/twister_tags.py b/util/twister_tags.py
index 692fdc1e99..68ac5846bd 100755
--- a/util/twister_tags.py
+++ b/util/twister_tags.py
@@ -29,6 +29,7 @@ TAG_TO_DESCRIPTION = {
"mkbp": "Testing the MKBP (Matrix Keyboard Protocol) stack",
"system": "Directly test functions in common/system.c or shim/src/system.c",
"spi": "SPI related tests",
+ "uart": "UART related tests",
}
SCRIPT_PATH = os.path.realpath(__file__)
diff --git a/util/uart_stress_tester.py b/util/uart_stress_tester.py
index 3b29a50a2b..05976889d6 100755
--- a/util/uart_stress_tester.py
+++ b/util/uart_stress_tester.py
@@ -90,6 +90,7 @@ class UartSerial:
"touch " + FLAG_FILENAME, # Create a temp file
],
"cleanup_cmd": [
+ "\x03",
"rm -f " + FLAG_FILENAME, # Remove the temp file
"dmesg -E", # Enable console message
"logout", # Logout
@@ -109,7 +110,7 @@ class UartSerial:
"prompt": "ec:~$",
"device_type": "EC(Zephyr)",
"prepare_cmd": ["chan save", "chan 0"], # Disable console message
- "cleanup_cmd": ["", "chan restore"],
+ "cleanup_cmd": ["x", "", "chan restore"],
"end_of_input": CRLF,
},
)
@@ -213,8 +214,6 @@ class UartSerial:
self.serial.flushInput()
self.serial.flushOutput()
- # Send 'x' to cancel any previous chargen command still running.
- self.run_command(["x"], delay=1)
self.get_output() # drain data
# Send a couple of line feeds, and capture the prompt text.
@@ -330,9 +329,9 @@ class UartSerial:
if captured:
if self.num_ch_cap == 0:
# Strip prompt on first read (if it's there)
- prefixstr = self.dev_prof["prompt"] + " "
- if captured.startswith(prefixstr):
- captured = captured[len(prefixstr) :]
+ start = captured.find("0123")
+ if start > 0:
+ captured = captured[start:]
# There is some output data. Reset the data starvation count.
data_starve_count = 0
else:
diff --git a/util/update_release_branch.py b/util/update_release_branch.py
index 0a871724fe..939d572dc4 100755
--- a/util/update_release_branch.py
+++ b/util/update_release_branch.py
@@ -42,11 +42,11 @@ def git_commit_msg(cros_main, branch, head, merge_head, rel_paths, cmd):
A String containing the git commit message with the exception of the
Signed-Off-By field and Change-ID field.
"""
- relevant_commits_cmd, relevant_commits = get_relevant_commits(
+ relevant_commits_cmd, relevant_commits, relevant_hdr = get_relevant_commits(
head, merge_head, "--oneline", rel_paths
)
- _, relevant_bugs = get_relevant_commits(head, merge_head, "", rel_paths)
+ _, relevant_bugs, _ = get_relevant_commits(head, merge_head, "", rel_paths)
relevant_bugs = set(re.findall("BUG=(.*)", relevant_bugs))
# Filter out "none" from set of bugs
filtered = []
@@ -65,7 +65,7 @@ Merge remote-tracking branch {CROS_MAIN} into {BRANCH}
Generated by: {COMMAND_LINE}
-Relevant changes:
+{RELEVANT_COMMITS_HEADER}
{RELEVANT_COMMITS_CMD}
@@ -93,6 +93,7 @@ Force-Relevant-Builds: all
BRANCH=branch,
RELEVANT_COMMITS_CMD=relevant_commits_cmd,
RELEVANT_COMMITS=relevant_commits,
+ RELEVANT_COMMITS_HEADER=relevant_hdr,
BUG_FIELD=bug_field,
COMMAND_LINE=cmd,
)
@@ -135,8 +136,10 @@ def get_relevant_commits(head, merge_head, fmt, relevant_paths):
Returns:
A tuple containing the arguments passed to the git log command and
- stdout.
+ stdout, and the header for the message
"""
+ if not relevant_paths:
+ return "", "", ""
if fmt:
cmd = [
"git",
@@ -156,7 +159,129 @@ def get_relevant_commits(head, merge_head, fmt, relevant_paths):
proc = subprocess.run(
cmd, stdout=subprocess.PIPE, encoding="utf-8", check=True, shell=True
)
- return "".join(proc.args), proc.stdout
+ return "".join(proc.args), proc.stdout, "Relevant changes:"
+
+
+def merge_repo(
+ base, cros_main, cmd_checkout, strategy, cmd, prunelist, relevant_paths
+):
+ """Merge changes from ToT into this repo's branch.
+
+ For this repo, merge the changes from ToT to the branch set
+ in the merge command.
+
+ Args:
+ base: String indicating the Source directory of repo.
+ cros_main: String indicating the origin branch name
+ cmd_checkout: String list containing the checkout command to use.
+ strategy: String list containing the merge strategy,
+ cmd: String containing the command line
+ prunelist: String list containing the files to remove.
+ relevant_paths: String containing all the relevant paths for this
+ particular baseboard or board.
+ """
+ # Change directory to the repo being merged
+ print('Starting merge in "%s"' % base)
+ print('Checkout command: "%s"' % " ".join(cmd_checkout))
+ os.chdir(base)
+ # Check if we are already in merge process
+ result = subprocess.run(
+ ["git", "rev-parse", "--quiet", "--verify", "MERGE_HEAD"],
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL,
+ check=False,
+ )
+
+ if result.returncode:
+ # Let's perform the merge
+ print("Updating remote...")
+ subprocess.run(["git", "remote", "update"], check=True)
+ subprocess.run(cmd_checkout, check=True)
+ cmd_merge = [
+ "git",
+ "merge",
+ "--no-ff",
+ "--no-commit",
+ cros_main,
+ "-s",
+ ]
+ cmd_merge.extend(strategy)
+ print('Merge command: "%s"' % " ".join(cmd_merge))
+ try:
+ subprocess.run(cmd_merge, check=True)
+ except subprocess.CalledProcessError:
+ # We've likely encountered a merge conflict due to new OWNERS file
+ # modifications. If we're removing the owners, we'll delete them.
+ if prunelist:
+ # Find the unmerged files
+ unmerged = (
+ subprocess.run(
+ ["git", "diff", "--name-only", "--diff-filter=U"],
+ stdout=subprocess.PIPE,
+ encoding="utf-8",
+ check=True,
+ )
+ .stdout.rstrip()
+ .split()
+ )
+
+ # Prune OWNERS files
+ for file in unmerged:
+ if file in prunelist:
+ subprocess.run(["git", "rm", file], check=False)
+ unmerged.remove(file)
+
+ print("Removed non-root OWNERS files.")
+ if unmerged:
+ print(
+ "Unmerged files still exist! You need to manually resolve this."
+ )
+ print("\n".join(unmerged))
+ sys.exit(1)
+ else:
+ raise
+ else:
+ print(
+ "We have already started merge process.",
+ "Attempt to generate commit.",
+ )
+ # Check whether any commit is needed.
+ changes = subprocess.run(
+ ["git", "status", "--porcelain"],
+ stdout=subprocess.PIPE,
+ encoding="utf-8",
+ check=True,
+ ).stdout.rstrip()
+ if not changes:
+ print("No changes have been found, skipping commit.")
+ return
+
+ print("Generating commit message...")
+ branch = subprocess.run(
+ ["git", "rev-parse", "--abbrev-ref", "HEAD"],
+ stdout=subprocess.PIPE,
+ encoding="utf-8",
+ check=True,
+ ).stdout.rstrip()
+ head = subprocess.run(
+ ["git", "rev-parse", "--short", "HEAD"],
+ stdout=subprocess.PIPE,
+ encoding="utf-8",
+ check=True,
+ ).stdout.rstrip()
+ merge_head = subprocess.run(
+ ["git", "rev-parse", "--short", "MERGE_HEAD"],
+ stdout=subprocess.PIPE,
+ encoding="utf-8",
+ check=True,
+ ).stdout.rstrip()
+
+ print("Typing as fast as I can...")
+ commit_msg = git_commit_msg(
+ cros_main, branch, head, merge_head, relevant_paths, cmd
+ )
+ subprocess.run(["git", "commit", "--signoff", "-m", commit_msg], check=True)
+ subprocess.run(["git", "commit", "--amend"], check=True)
def main(argv):
@@ -186,7 +311,11 @@ def main(argv):
parser.add_argument("--baseboard")
parser.add_argument("--board")
parser.add_argument(
- "release_branch", help=("The name of the target release" " branch")
+ "release_branch",
+ help=(
+ "The name of the target release branch, "
+ "without the trailing '-main'."
+ ),
)
parser.add_argument(
"--remote_prefix",
@@ -197,6 +326,11 @@ def main(argv):
default="cros",
)
parser.add_argument(
+ "--srcbase",
+ help=("The base directory where the src tree exists."),
+ default="/mnt/host/source/",
+ )
+ parser.add_argument(
"--relevant_paths_file",
help=(
"A path to a text file which includes other "
@@ -213,7 +347,7 @@ def main(argv):
parser.add_argument(
"--strategy_option",
"-X",
- help=("The strategy option for the chosen merge " "strategy"),
+ help=("The strategy option for the chosen merge strategy"),
)
parser.add_argument(
"--remove_owners",
@@ -221,6 +355,12 @@ def main(argv):
action=("store_true"),
help=("Remove non-root OWNERS level files if present"),
)
+ parser.add_argument(
+ "--zephyr",
+ "-z",
+ action=("store_true"),
+ help=("If set, treat the board as a Zephyr based program"),
+ )
opts = parser.parse_args(argv[1:])
@@ -228,17 +368,24 @@ def main(argv):
board_dir = ""
if opts.baseboard:
+ # If a zephyr board, no baseboard allowed
+ if opts.zephyr:
+ raise Exception("--baseboard not allowed for Zephyr boards")
# Dereference symlinks so "git log" works as expected.
baseboard_dir = os.path.relpath("baseboard/" + opts.baseboard)
baseboard_dir = os.path.relpath(os.path.realpath(baseboard_dir))
boards = get_relevant_boards(opts.baseboard)
elif opts.board:
- board_dir = os.path.relpath("board/" + opts.board)
+ if opts.zephyr:
+ board_dir = os.path.relpath("zephyr/program/" + opts.board)
+ else:
+ board_dir = os.path.relpath("board/" + opts.board)
board_dir = os.path.relpath(os.path.realpath(board_dir))
boards = [opts.board]
else:
- boards = []
+ # With no board or baseboard, not sure whether this should proceed
+ raise Exception("no board or baseboard specified")
print("Gathering relevant paths...")
relevant_paths = []
@@ -247,10 +394,12 @@ def main(argv):
elif opts.board:
relevant_paths.append(board_dir)
- for board in boards:
- relevant_paths.append("board/" + board)
+ if not opts.zephyr:
+ for board in boards:
+ relevant_paths.append("board/" + board)
# Check for the existence of a file that has other paths of interest.
+ # Also check for 'relevant-paths.txt' in the board directory
if opts.relevant_paths_file and os.path.exists(opts.relevant_paths_file):
with open(opts.relevant_paths_file, "r") as relevant_paths_file:
for line in relevant_paths_file:
@@ -260,17 +409,9 @@ def main(argv):
relevant_paths.append("util/getversion.sh")
relevant_paths = " ".join(relevant_paths)
- # Check if we are already in merge process
- result = subprocess.run(
- ["git", "rev-parse", "--quiet", "--verify", "MERGE_HEAD"],
- stdout=subprocess.DEVNULL,
- stderr=subprocess.DEVNULL,
- check=False,
- )
-
# Prune OWNERS files if desired
+ prunelist = []
if opts.remove_owners:
- prunelist = []
for root, dirs, files in os.walk("."):
for name in dirs:
if "build" in name:
@@ -291,112 +432,83 @@ def main(argv):
for path in prunelist:
print(" " + path)
- if result.returncode:
- # Let's perform the merge
- print("Updating remote...")
- subprocess.run(["git", "remote", "update"], check=True)
- subprocess.run(
- [
- "git",
- "checkout",
- "-B",
- opts.release_branch,
- opts.remote_prefix + "/" + opts.release_branch,
- ],
- check=True,
- )
- print("Attempting git merge...")
- if opts.merge_strategy == "recursive" and not opts.strategy_option:
- opts.strategy_option = "theirs"
- print(
- 'Using "%s" merge strategy' % opts.merge_strategy,
- (
- "with strategy option '%s'" % opts.strategy_option
- if opts.strategy_option
- else ""
- ),
- )
- cros_main = opts.remote_prefix + "/" + "main"
- arglist = [
+ # Create the merge and checkout commands to use.
+ cmd_checkout = [
+ "git",
+ "checkout",
+ "-B",
+ opts.release_branch,
+ opts.remote_prefix + "/" + opts.release_branch,
+ ]
+ if opts.merge_strategy == "recursive" and not opts.strategy_option:
+ opts.strategy_option = "theirs"
+ print(
+ 'Using "%s" merge strategy' % opts.merge_strategy,
+ (
+ "with strategy option '%s'" % opts.strategy_option
+ if opts.strategy_option
+ else ""
+ ),
+ )
+ cros_main = opts.remote_prefix + "/" + "main"
+ strategy = [
+ opts.merge_strategy,
+ ]
+ if opts.strategy_option:
+ strategy.append("-X" + opts.strategy_option)
+ cmd = " ".join(argv)
+
+ # Merge each of the repos
+ merge_repo(
+ os.path.join(opts.srcbase, "src/platform/ec"),
+ cros_main,
+ cmd_checkout,
+ strategy,
+ cmd,
+ prunelist,
+ relevant_paths,
+ )
+ if opts.zephyr:
+ # Strip off any trailing -main or -master from branch name
+ if opts.release_branch.endswith("-main"):
+ opts.release_branch = opts.release_branch[:-5]
+ if opts.release_branch.endswith("-master"):
+ opts.release_branch = opts.release_branch[:-7]
+ cmd_checkout = [
"git",
- "merge",
- "--no-ff",
- "--no-commit",
- cros_main,
- "-s",
- opts.merge_strategy,
+ "checkout",
+ "-B",
+ opts.release_branch,
+ opts.remote_prefix + "/" + opts.release_branch,
]
- if opts.strategy_option:
- arglist.append("-X" + opts.strategy_option)
- try:
- subprocess.run(arglist, check=True)
- except:
- # We've likely encountered a merge conflict due to new OWNERS file
- # modifications. If we're removing the owners, we'll delete them.
- if opts.remove_owners and prunelist:
- # Find the unmerged files
- unmerged = (
- subprocess.run(
- ["git", "diff", "--name-only", "--diff-filter=U"],
- stdout=subprocess.PIPE,
- encoding="utf-8",
- check=True,
- )
- .stdout.rstrip()
- .split()
- )
-
- # Prune OWNERS files
- for file in unmerged:
- if file in prunelist:
- subprocess.run(["git", "rm", file], check=False)
- unmerged.remove(file)
-
- print("Removed non-root OWNERS files.")
- if unmerged:
- print(
- "Unmerged files still exist! You need to manually resolve this."
- )
- print("\n".join(unmerged))
- sys.exit(1)
- else:
- raise
- else:
- print(
- "We have already started merge process.",
- "Attempt to generate commit.",
+ prunelist = []
+ if opts.remove_owners:
+ # Remove the top level OWNERS file from the list
+ # to avoid any conflict with the modified branch file.
+ prunelist.append("OWNERS")
+ merge_repo(
+ os.path.join(opts.srcbase, "src/third_party/zephyr/main"),
+ cros_main,
+ cmd_checkout,
+ strategy,
+ cmd,
+ prunelist,
+ [],
+ )
+ # cmsis repo has different remote
+ cros_main = opts.remote_prefix + "/" + "chromeos-main"
+ merge_repo(
+ os.path.join(opts.srcbase, "src/third_party/zephyr/cmsis"),
+ cros_main,
+ cmd_checkout,
+ strategy,
+ cmd,
+ prunelist,
+ [],
)
-
- print("Generating commit message...")
- branch = subprocess.run(
- ["git", "rev-parse", "--abbrev-ref", "HEAD"],
- stdout=subprocess.PIPE,
- encoding="utf-8",
- check=True,
- ).stdout.rstrip()
- head = subprocess.run(
- ["git", "rev-parse", "--short", "HEAD"],
- stdout=subprocess.PIPE,
- encoding="utf-8",
- check=True,
- ).stdout.rstrip()
- merge_head = subprocess.run(
- ["git", "rev-parse", "--short", "MERGE_HEAD"],
- stdout=subprocess.PIPE,
- encoding="utf-8",
- check=True,
- ).stdout.rstrip()
-
- cmd = " ".join(argv)
- print("Typing as fast as I can...")
- commit_msg = git_commit_msg(
- cros_main, branch, head, merge_head, relevant_paths, cmd
- )
- subprocess.run(["git", "commit", "--signoff", "-m", commit_msg], check=True)
- subprocess.run(["git", "commit", "--amend"], check=True)
print(
(
- "Finished! **Please review the commit to see if it's to your "
+ "Finished! **Please review the commit(s) to see if they're to your "
"liking.**"
)
)
diff --git a/util/usb_if.c b/util/usb_if.c
index 0cd642834a..eec8b22f5b 100644
--- a/util/usb_if.c
+++ b/util/usb_if.c
@@ -4,12 +4,12 @@
* found in the LICENSE file.
*/
+#include "usb_if.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "usb_if.h"
-
/* Return 0 on error, since it's never gonna be EP 0 */
static int find_endpoint(const struct libusb_interface_descriptor *iface,
uint16_t subclass, uint16_t protocol,
diff --git a/util/uut/com_port.h b/util/uut/com_port.h
index ca52bdd234..0a5d843e0f 100644
--- a/util/uut/com_port.h
+++ b/util/uut/com_port.h
@@ -10,6 +10,7 @@
#define __UTIL_UUT_COM_PORT_H
#include <stdbool.h>
+
#include <termios.h>
#ifdef __cplusplus
diff --git a/util/zephyr_to_resultdb.py b/util/zephyr_to_resultdb.py
index 48bfe151e4..6c378bde5c 100755
--- a/util/zephyr_to_resultdb.py
+++ b/util/zephyr_to_resultdb.py
@@ -11,8 +11,11 @@
import argparse
import base64
+import datetime
import json
import os
+import pathlib
+import re
import requests # pylint: disable=import-error
@@ -47,7 +50,7 @@ def translate_duration(testcase):
if not time:
return None
- return f"{time}ms"
+ return f"{float(time)/1000:.9f}s"
def testcase_summary(testcase):
@@ -59,9 +62,7 @@ def testcase_summary(testcase):
or "reason" in testcase
or translate_status(testcase["status"]) == "SKIP"
):
- html = (
- '<p><text-artifact artifact-id="artifact-content-in-request"></p>'
- )
+ html = '<p><text-artifact artifact-id="test_log"></p>'
return html
@@ -82,40 +83,113 @@ def testcase_artifact(testcase):
return base64.b64encode(artifact.encode())
-def testcase_to_result(testsuite, testcase):
- """Translates ZTEST testcase to ResultDB format"""
+def testsuite_artifact(testsuite):
+ """Translates ZTEST testcase to ResultDB artifact"""
+ artifact = "Unknown"
+
+ if "log" in testsuite and testsuite["log"]:
+ artifact = testsuite["log"]
+
+ return base64.b64encode(artifact.encode())
+
+
+def testcase_to_result(testsuite, testcase, base_tags, config_tags):
+ """Translates ZTEST testcase to ResultDB format
+ See TestResult type in
+ https://crsrc.org/i/go/src/go.chromium.org/luci/resultdb/sink/proto/v1/test_result.proto
+ """
result = {
"testId": testcase["identifier"],
"status": translate_status(testcase["status"]),
"expected": translate_expected(testcase["status"]),
"summaryHtml": testcase_summary(testcase),
"artifacts": {
- "artifact-content-in-request": {
+ "test_log": {
"contents": testcase_artifact(testcase),
- }
+ },
+ "testsuite_log": {
+ "contents": testsuite_artifact(testsuite),
+ },
},
- # TODO(b/239952573) Add all test configs as tags
"tags": [
- {"key": "category", "value": "ChromeOS/EC"},
{"key": "platform", "value": testsuite["platform"]},
],
"duration": translate_duration(testcase),
"testMetadata": {"name": testcase["identifier"]},
}
+ for (key, value) in base_tags:
+ result["tags"].append({"key": key, "value": value})
+
+ for (key, value) in config_tags:
+ result["tags"].append({"key": key.lower(), "value": value})
+
+ if result["status"] == "FAIL" and "log" in testcase and testcase["log"]:
+ assert_msg = re.findall(
+ r"Assertion failed.*$", testcase["log"], re.MULTILINE
+ )
+ result["failureReason"] = {"primaryErrorMessage": assert_msg[0]}
+
return result
+def get_testsuite_config_tags(twister_dir, testsuite):
+ """Creates config tags from the testsuite"""
+ config_tags = []
+ suite_path = f"{twister_dir}/{testsuite['platform']}/{testsuite['name']}"
+ dot_config = f"{suite_path}/zephyr/.config"
+
+ if pathlib.Path(dot_config).exists():
+ with open(dot_config) as file:
+ lines = file.readlines()
+
+ for line in lines:
+ # Ignore empty lines and comments
+ if line.strip() and not line.startswith("#"):
+ result = re.search(r"(\w+)=(.+$)", line)
+ config_tags.append((result.group(1), result.group(2)))
+ else:
+ print(f"Can't find config file for {testsuite['name']}")
+
+ return config_tags
+
+
+def create_base_tags(data):
+ """Creates base tags needed for Testhaus"""
+ base_tags = []
+
+ queued_time = datetime.datetime.fromisoformat(
+ data["environment"]["run_date"]
+ )
+ base_tags.append(
+ ("queued_time", queued_time.strftime("%Y-%m-%d %H:%M:%S.%f UTC"))
+ )
+
+ base_tags.append(("zephyr_version", data["environment"]["zephyr_version"]))
+ base_tags.append(("board", data["environment"]["os"]))
+ base_tags.append(("toolchain", data["environment"]["toolchain"]))
+
+ return base_tags
+
+
def json_to_resultdb(result_file):
"""Translates Twister json test report to ResultDB format"""
with open(result_file) as file:
data = json.load(file)
results = []
+ base_tags = create_base_tags(data)
for testsuite in data["testsuites"]:
+ config_tags = get_testsuite_config_tags(
+ os.path.dirname(result_file), testsuite
+ )
for testcase in testsuite["testcases"]:
if testcase["status"]:
- results.append(testcase_to_result(testsuite, testcase))
+ results.append(
+ testcase_to_result(
+ testsuite, testcase, base_tags, config_tags
+ )
+ )
file.close()
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
index ae882e5640..0b36bcc24e 100644
--- a/zephyr/CMakeLists.txt
+++ b/zephyr/CMakeLists.txt
@@ -182,6 +182,8 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSM
"${PLATFORM_EC}/driver/accelgyro_lsm6dsm.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCEL_FIFO
"${PLATFORM_EC}/common/motion_sense_fifo.c")
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BODY_DETECTION
+ "${PLATFORM_EC}/common/body_detection.c")
zephyr_library_sources_ifdef(CONFIG_ADC
"${PLATFORM_EC}/common/adc.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ALS_TCS3400
@@ -244,10 +246,9 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CPS8100
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_OCPC
"${PLATFORM_EC}/common/ocpc.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI
"${PLATFORM_EC}/common/cbi.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_GPIO
- "${PLATFORM_EC}/common/cbi.c"
"${PLATFORM_EC}/common/cbi_gpio.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CONSOLE_CMD_MEM
"${PLATFORM_EC}/common/memory_commands.c")
@@ -362,6 +363,9 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_SC7180
"${PLATFORM_EC}/power/qcom.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_SC7280
"${PLATFORM_EC}/power/qcom.c")
+if (CONFIG_PLATFORM_EC_HIBERNATE AND CONFIG_AP_PWRSEQ)
+ zephyr_library_sources( "${PLATFORM_EC}/power/hibernate.c")
+endif ()
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PANIC
"${PLATFORM_EC}/common/panic_output.c")
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SHA256_SW
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
index f4d274ca1d..6b0a512328 100644
--- a/zephyr/Kconfig
+++ b/zephyr/Kconfig
@@ -8,6 +8,7 @@ rsource "emul/Kconfig"
rsource "fake/Kconfig"
rsource "mock/Kconfig"
rsource "subsys/Kconfig"
+rsource "subsys/emul/Kconfig"
if ZTEST
@@ -332,6 +333,14 @@ config PLATFORM_EC_EXTPOWER_GPIO
project should define a GPIO pin named GPIO_AC_PRESENT, with
extpower_interrupt configured as the handler.
+config PLATFORM_EC_EXTPOWER_DEBOUNCE_MS
+ int "Debounce time for external power signal"
+ default 30
+ help
+ Enable external power signal debounce time. Extend the
+ debounce time to ensure that the external power signal can
+ supply stable power.
+
config PLATFORM_EC_FLASH_CROS
bool
help
@@ -340,16 +349,6 @@ config PLATFORM_EC_FLASH_CROS
e.g. to support auto-update. Various write-protection features are
also provided.
-config PLATFORM_EC_FPU
- bool "Support floating point"
- depends on FPU && (CPU_CORTEX_M || RISCV) && !NEWLIB_LIBC
- default y
- help
- This enables support for floating point. This is generally already
- provided in Zephyr, but the EC side expects a few functions to be
- available which are not available with Zephyr's minimal lib: sqrtf()
- and fabsf(). Enabling this options defines them.
-
config PLATFORM_EC_HOOKS
bool "Hooks and deferred compatibility shim"
default y
@@ -456,6 +455,14 @@ config PLATFORM_EC_POWER_COMMON
help
Compile common code for AP power state machine.
+config CROS_EC_POWER_SIGNAL_LIST
+ bool "Define the power signal list from the devicetree"
+ default y
+ depends on $(dt_nodelabel_enabled,power_signal_list)
+ help
+ Define the global power_signal_list[] from the devicetree. Requires a
+ node with nodelabel power_signal_list.
+
config PLATFORM_EC_MKBP_EVENT
bool "MKBP event"
help
@@ -544,6 +551,7 @@ config PLATFORM_EC_PWM_DISPLIGHT
bool "PWM display backlight"
default y
depends on DT_HAS_CROS_EC_DISPLIGHT_ENABLED
+ select PWM
select PLATFORM_EC_PWM_HC
help
Enables display backlight controlled by a PWM signal connected
@@ -591,7 +599,7 @@ endchoice # PLATFORM_EC_SHA256_MODE
config PLATFORM_EC_SHA256_UNROLLED
bool "Manually unroll sha256 transform"
- depends on PLATFORM_EC_SHA25_SW
+ depends on PLATFORM_EC_SHA256_SW
default n
help
Enable loop unroll to improve the performance of sha256 software
@@ -614,25 +622,17 @@ config PLATFORM_EC_SWITCH
This also enables the "mmapinfo" console command to report the current
state of all switches.
-choice PLATFORM_EC_SWITCHCAP_TYPE
- prompt "Enable switchcap support"
- optional
- help
- Enable support for switchcap used to power on the AP.
- If enabled, type of switchcap must be selected and node in device
- tree must be added that describes the driver and pins used to control
- the switchcap.
-
config PLATFORM_EC_SWITCHCAP_GPIO
bool "GPIO controlled switchcap"
+ default y
+ depends on DT_HAS_CROS_EC_SWITCHCAP_GPIO_ENABLED
help
Enable support for the GPIO controlled switchcap.
Pins used for controlling the switchcap must be defined in board's
device tree.
config PLATFORM_EC_SWITCHCAP_LN9310
- bool "LN9310 switchcap driver"
- depends on PLATFORM_EC_I2C
+ bool "LN9310 switchcap common code"
help
Enable support for the LION Semiconductor LN9310 switched
capacitor converter. This will export definitions for
@@ -640,7 +640,14 @@ config PLATFORM_EC_SWITCHCAP_LN9310
project-specific code should call appropriately if there's
no switchcap node in device tree.
-endchoice
+config CROS_EC_SWITCHCAP_LN9310
+ bool "LN9310 switchcap generic driver"
+ default y
+ depends on DT_HAS_LION_LN9310_ENABLED
+ help
+ Enable support for the generic driver for the LION Semiconductor
+ LN9310 switched capacitor converter. This requires a lion,ln9310 node
+ to be defined.
config PLATFORM_EC_SYSTEM_UNLOCKED
bool "System unlocked: allow dangerous commands while in development"
@@ -800,4 +807,14 @@ config PLATFORM_EC_MATH_UTIL
Math utilities including bitmask manipulation, division rounding,
trigonometric function, etc.
+config PLATFORM_EC_GPIO_ID
+ bool "Enable GPIO ID handling for board and sku ids"
+ default y
+ depends on DT_HAS_CROS_EC_GPIO_ID_ENABLED
+ help
+ Enable setting board and sku IDs using GPIOs. Defines the
+ board_get_sku_id and board_get_version functions based on the
+ devicetree node using the known nodelabels gpio_id_sku and
+ gpio_id_board.
+
endif # PLATFORM_EC
diff --git a/zephyr/Kconfig.adc b/zephyr/Kconfig.adc
index 40ec1e4e89..5efc1a9bd5 100644
--- a/zephyr/Kconfig.adc
+++ b/zephyr/Kconfig.adc
@@ -2,6 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+config ADC
+ default y
+ depends on DT_HAS_NAMED_ADC_CHANNELS_ENABLED
+
# Note - CONFIG_ADC is defined in upstream Zephyr
if ADC
diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery
index 92bce6b618..2aedc00dca 100644
--- a/zephyr/Kconfig.battery
+++ b/zephyr/Kconfig.battery
@@ -4,6 +4,8 @@
menuconfig PLATFORM_EC_BATTERY
bool "Battery support"
+ default y
+ depends on DT_HAS_BATTERY_SMART_ENABLED
help
Enables battery support on the board. Requires selection of a battery
and a charger IC.
diff --git a/zephyr/Kconfig.body_detection b/zephyr/Kconfig.body_detection
new file mode 100644
index 0000000000..85386a68c1
--- /dev/null
+++ b/zephyr/Kconfig.body_detection
@@ -0,0 +1,97 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+menuconfig PLATFORM_EC_BODY_DETECTION
+ bool "Sensor body detection"
+ help
+ Enable the body detection function.
+
+ The Power Reduction Algorithm is based on the Motion Detector
+ output of In Motion (on body) state or Stationary (off body) state.
+ The input of the Motion Detector is the X and Y axis signal
+ from an accelerometer.
+
+if PLATFORM_EC_BODY_DETECTION
+
+config PLATFORM_EC_BODY_DETECTION_MAX_WINDOW_SIZE
+ int "Maximal sensor data rate"
+ default 250
+ help
+ Sets the maximum sensor data rate, in Hz. Note that larger data rate
+ values consume more memory and computing resource.
+
+config PLATFORM_EC_BODY_DETECTION_VAR_THRESHOLD
+ int "The threshold of acceleration variance for confidence calculation"
+ default 550
+ help
+ The unit is (mm/s^2)^2
+
+ The motion confidence is calculated if the variance is within
+ variance_threshold +/- confidence_delta. Otherwise, if variance is
+ too high/low, confidence will be 100%/0%
+
+config PLATFORM_EC_BODY_DETECTION_CONFIDENCE_DELTA
+ int "The delta of acceleration variance for confidence calculation"
+ default 525
+ help
+ The unit is (mm/s^2)^2
+
+ The motion confidence is calculated if the variance is within
+ variance_threshold +/- confidence_delta. Otherwise, if variance is
+ too high/low, confidence will be 100%/0%
+
+config PLATFORM_EC_BODY_DETECTION_VAR_NOISE_FACTOR
+ int "How much noise affects the threshold of variance"
+ default 120
+ help
+ The unit is percentage
+
+ This is used for mitigate the effect of the noise from the sensor.
+ If set to 100%, the average noise is canceled out. This is set to
+ 120% by default because the noise might get larger than average
+ sometimes.
+
+config PLATFORM_EC_BODY_DETECTION_ON_BODY_CON
+ int "The confidence limit of on_body"
+ default 50
+ help
+ The unit is percentage
+
+ Higher the value, more diffcult to enter the on-body from off-body
+
+config PLATFORM_EC_BODY_DETECTION_OFF_BODY_CON
+ int "The confidence limit of off body"
+ default 10
+ help
+ The unit is percentage
+
+ Lower the value, more diffcult to enter the off-body from on-body.
+ Should be set less than the PLATFORM_EC_BODY_DETECTION_ON_BODY_CON
+
+config PLATFORM_EC_BODY_DETECTION_STATIONARY_DURATION
+ int "The threshold duration to change to off_body"
+ default 15
+ help
+ The unit is seconds
+
+ How long should we stay in on-body state before entering to off-body
+ state when the motion confidence is less than
+ PLATFORM_EC_BODY_DETECTION_OFF_BODY_CON
+
+config PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE
+ bool "Notify host with a specific host event when body status is changed"
+ default n
+ help
+ Notify the host via SCI events EC_HOST_EVENT_MODE_CHANGE when body
+ status is changed, in addition to adding an event in the motion sensor
+ FIFO queue.
+
+config PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0
+ bool "Always enable body detection function in S0"
+ default n
+ help
+ Always enable the body detection function in S0
+ w/o the host command
+
+endif # PLATFORM_EC_BODY_DETECTION
diff --git a/zephyr/Kconfig.cbi b/zephyr/Kconfig.cbi
index a2be51375e..db54c87fbb 100644
--- a/zephyr/Kconfig.cbi
+++ b/zephyr/Kconfig.cbi
@@ -19,9 +19,9 @@ config PLATFORM_EC_EEPROM_CBI_WP
signal. The accompanying hardware must ensure that the CBI WP gets
latched and is only reset when EC_RST_ODL is asserted.
-choice PLATFORM_EC_CBI_STORAGE_TYPE
- prompt "Select CBI storage Type"
- optional
+config PLATFORM_EC_CBI
+ bool "CBI support"
+ default y
help
CBI is a means for accessing board information, typically set
during the factory process. This allows selection of the physical
@@ -31,6 +31,14 @@ choice PLATFORM_EC_CBI_STORAGE_TYPE
https://chromium.googlesource.com/chromiumos/docs/+/HEAD/design_docs/cros_board_info.md
+if PLATFORM_EC_CBI
+
+choice PLATFORM_EC_CBI_STORAGE_TYPE
+ prompt "CBI storage type"
+ default PLATFORM_EC_CBI_EEPROM if $(dt_nodelabel_enabled,cbi_eeprom)
+ help
+ Select the backing storage type for CBI data.
+
config PLATFORM_EC_CBI_EEPROM
bool "CBI EEPROM support"
depends on EEPROM
@@ -46,3 +54,5 @@ config PLATFORM_EC_CBI_GPIO
CBI for AP to query.
endchoice
+
+endif # PLATFORM_EC_CBI
diff --git a/zephyr/Kconfig.charger b/zephyr/Kconfig.charger
index f408797d17..c2c6eeb3f4 100644
--- a/zephyr/Kconfig.charger
+++ b/zephyr/Kconfig.charger
@@ -63,6 +63,21 @@ config PLATFORM_EC_CHARGE_MANAGER
source is available on the hardware, so cannot be built without
PLATFORM_EC_USBC.
+config PLATFORM_EC_CHARGE_STATE_DEBUG
+ bool "Debug information about the charge state"
+ depends on PLATFORM_EC_CHARGE_MANAGER
+ help
+ Enables debug information regarding the current charge state. Enabling
+ this config will allow the EC_CMD_CHARGE_STATE host command to use the
+ CHARGE_STATE_CMD_GET_PARAM command to query the current charge state.
+
+config PLATFORM_EC_CMD_PWR_AVG
+ bool "Enable the console command to print power average"
+ depends on PLATFORM_EC_CHARGE_MANAGER
+ help
+ Enables the console command which prints out the current (past 1
+ minute) power average.
+
config PLATFORM_EC_CHARGESPLASH
bool "Charging splashscreen support"
help
@@ -171,6 +186,8 @@ config PLATFORM_EC_CHARGER_RAA489000
config PLATFORM_EC_CHARGER_RT9490
bool "Use the RT9490 charger"
+ default y
+ depends on DT_HAS_RICHTEK_RT9490_ENABLED || DT_HAS_ZEPHYR_RT9490_EMUL_ENABLED
depends on PLATFORM_EC_I2C
select PLATFORM_EC_CHARGER_OTG_SUPPORTED
help
@@ -187,6 +204,12 @@ config PLATFORM_EC_CHARGER_SM5803
Enables the driver for the SM5803.
The SM5803 is the Silicon Mitus SM5803 Buck-Boost Charger.
+ This charger is known to be very inefficient when operating in buck-boost
+ mode (when input voltage is close to output voltage), such that permanent
+ damage may be done to the charger. Users should exercise caution around
+ choice of supported configurations: see b:260271871, b:258754576, and
+ b:230712704 for more information.
+
if PLATFORM_EC_OCPC
@@ -199,6 +222,13 @@ config PLATFORM_EC_OCPC_DEF_RBATT_MOHMS
This should be at a minimum the Rds(on) resistance of the BFET plus
the series sense resistor.
+config PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS
+ int "Drive Limit for the OCPC PID control loop"
+ default 10
+ help
+ Sets how agressively the OCPC PID control loop can adjust VSYS to drive
+ the battery with the correct current.
+
endif # PLATFORM_EC_OCPC
config PLATFORM_EC_CHARGER_DISCHARGE_ON_AC
diff --git a/zephyr/Kconfig.defaults b/zephyr/Kconfig.defaults
index e0992f91fa..a7497ca9a4 100644
--- a/zephyr/Kconfig.defaults
+++ b/zephyr/Kconfig.defaults
@@ -13,9 +13,6 @@ config LOG
default y
imply LOG_DEFAULT_MINIMAL
-config GPIO_EMUL
- default y if ARCH_POSIX
-
config GPIO
default y if ARCH_POSIX
@@ -25,6 +22,9 @@ config THREAD_MAX_NAME_LEN
config SHELL_PROMPT_UART
default "ec:~$ "
+config SHELL_VT100_COLORS
+ default n
+
config SHELL_THREAD_PRIORITY_OVERRIDE
default y
@@ -34,4 +34,10 @@ config SHELL_THREAD_PRIORITY
config EXTRA_EXCEPTION_INFO
default y if ARCH_HAS_EXTRA_EXCEPTION_INFO
+config EEPROM_SHELL
+ default n
+
+config PWM_SHELL
+ default n
+
orsource "Kconfig.defaults-$(ARCH)"
diff --git a/zephyr/Kconfig.i2c b/zephyr/Kconfig.i2c
index 0187409b31..9fa1d274aa 100644
--- a/zephyr/Kconfig.i2c
+++ b/zephyr/Kconfig.i2c
@@ -3,7 +3,10 @@
# found in the LICENSE file.
config PLATFORM_EC_I2C
- def_bool I2C
+ bool "EC I2C Support"
+ default y
+ depends on DT_HAS_NAMED_I2C_PORTS_ENABLED
+ select 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
diff --git a/zephyr/Kconfig.ioex b/zephyr/Kconfig.ioex
index e9bb8065e1..9be34197db 100644
--- a/zephyr/Kconfig.ioex
+++ b/zephyr/Kconfig.ioex
@@ -4,7 +4,8 @@
menuconfig PLATFORM_EC_IOEX_CROS_DRV
bool "IO expander support"
- depends on I2C
+ default y
+ depends on I2C && DT_HAS_CROS_IOEX_CHIP_ENABLED
help
Enable support for CrOS EC ioex drivers.
diff --git a/zephyr/Kconfig.keyboard b/zephyr/Kconfig.keyboard
index e0f1b2517e..c425d7af0d 100644
--- a/zephyr/Kconfig.keyboard
+++ b/zephyr/Kconfig.keyboard
@@ -19,6 +19,15 @@ menuconfig PLATFORM_EC_KEYBOARD
if PLATFORM_EC_KEYBOARD
+config CROS_EC_KEYSCAN
+ bool "Devicetree based keyscan map"
+ default y
+ depends on DT_HAS_CROS_EC_KEYSCAN_ENABLED
+ help
+ Define a keyscan_config data structure based on a the keyscan
+ configuration found in devicetree. Requires a cros-ec,keyscan node to
+ be defined.
+
choice PLATFORM_EC_KEYBOARD_PROTOCOL_MODE
prompt "Select the keyboard protocol to use"
help
@@ -50,6 +59,8 @@ endchoice # PLATFORM_EC_KEYBOARD_PROTOCOL_MODE
config PLATFORM_EC_KEYBOARD_DISCRETE
bool "Support discrete Keyboard"
+ default y
+ depends on $(dt_nodelabel_enabled,kb_discrete)
help
Enable support for a discrete Keyboard if the platform needs one
or the raw Keyboard support is not built-in in the EC.
@@ -62,6 +73,13 @@ config PLATFORM_EC_KEYBOARD_DEBUG
if the board is currently headless and keyboard functionality is being
checked.
+config PLATFORM_EC_KEYBOARD_FACTORY_TEST
+ bool "Support keyboard factory test"
+ help
+ Enable support "ectool kbfactorytest" command.
+ Need to map keyboard connector pins to EC GPIO pins in
+ keyboard_factory_scan_pins table.
+
config PLATFORM_EC_KEYBOARD_KEYPAD
bool "Support a numeric keypad"
help
@@ -85,17 +103,17 @@ config PLATFORM_EC_KEYBOARD_VIVALDI
config PLATFORM_EC_KEYBOARD_CUSTOMIZATION
bool "Support keyboard customization"
help
- Enable support for customization keyboard, some boards need to custom matrix
- because those board keyboard layout doesn't follow a common matrix.
+ Enable support for customization keyboard, some boards need to custom matrix
+ because those board keyboard layout doesn't follow a common matrix.
- If define, the board layer
- needs to implement:
- 1. the scancode_set2 and keycap_label array
- 2. keyboard_customization.h which is similar to keyboard_config.h
+ If define, the board layer
+ needs to implement:
+ 1. the scancode_set2 and keycap_label array
+ 2. keyboard_customization.h which is similar to keyboard_config.h
- Note that if your board has the standard chromeos keyboard layout other
- than the top row, and you are looking only for top row customization,
- then you should be looking at overriding board_vivaldi_keybd_config() instead.
+ Note that if your board has the standard chromeos keyboard layout other
+ than the top row, and you are looking only for top row customization,
+ then you should be looking at overriding board_vivaldi_keybd_config() instead.
choice PLATFORM_EC_KEYBOARD_PWRBTN_MODE
prompt "Select the impact of pressing the power button"
@@ -199,6 +217,7 @@ config PLATFORM_EC_PWM_KBLIGHT
bool "PWM keyboard backlight"
default y
depends on DT_HAS_CROS_EC_KBLIGHT_PWM_ENABLED
+ select PWM
select PLATFORM_EC_PWM_HC
help
Enables a PWM-controlled keyboard backlight controlled by a PWM signal
diff --git a/zephyr/Kconfig.led b/zephyr/Kconfig.led
index d3d50ccc56..da00d6ff9c 100644
--- a/zephyr/Kconfig.led
+++ b/zephyr/Kconfig.led
@@ -19,6 +19,9 @@ if PLATFORM_EC_LED_COMMON
config PLATFORM_EC_LED_PWM
bool "PWM (Pulse Width Modulation) LEDs"
+ default y
+ depends on DT_HAS_CROS_EC_PWM_LEDS_ENABLED
+ select PWM
help
Enable PWM (Pulse Width Modulation) controlled LEDs that conform to
the Chromium OS LED behavior specification.
@@ -167,6 +170,8 @@ endif # PLATFORM_EC_LED_COMMON
config PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY
bool "MAX695X Seven Segment Display"
+ default y
+ depends on DT_HAS_MAXIM_MAX695X_ENABLED
help
Enable this to support MAX6958/MAX6959 7-Segment LED Display.
The MAX6958/MAX6959 is a compact multiplexed common - cathode display
diff --git a/zephyr/Kconfig.led_dt b/zephyr/Kconfig.led_dt
index 25993802a3..adedfb16b6 100644
--- a/zephyr/Kconfig.led_dt
+++ b/zephyr/Kconfig.led_dt
@@ -3,7 +3,27 @@
# found in the LICENSE file.
menuconfig PLATFORM_EC_LED_DT
- bool "LED Support"
+ bool "DT LED Support"
help
Enable devicetree based LED module supporting automatic control of the
battery and power LEDs.
+
+if PLATFORM_EC_LED_DT
+
+config PLATFORM_EC_LED_DT_GPIO
+ bool "DT LED Support (GPIO)"
+ default y
+ depends on DT_HAS_CROS_EC_GPIO_LED_PINS_ENABLED
+ help
+ Enable support for devicetree GPIO LEDs, requires a node using the
+ cros-ec,gpio-led-pins compatible.
+
+config PLATFORM_EC_LED_DT_PWM
+ bool "DT LED Support (PWM)"
+ default y
+ depends on DT_HAS_CROS_EC_PWM_LED_PINS_ENABLED
+ select PWM
+ help
+ Enable support for devicetree PWM LEDs, requires a node using the
+ cros-ec,pwm-led-pins compatible.
+endif
diff --git a/zephyr/Kconfig.motionsense b/zephyr/Kconfig.motionsense
index 7cf991918b..86a7fb08bc 100644
--- a/zephyr/Kconfig.motionsense
+++ b/zephyr/Kconfig.motionsense
@@ -93,10 +93,9 @@ config PLATFORM_EC_LID_ANGLE
peripheral devices(refer "Lid Angle Update" below).
# TODO(b/173507858): add more detail after .dts change
-if PLATFORM_EC_LID_ANGLE
-
config PLATFORM_EC_LID_ANGLE_UPDATE
bool "Lid Angle Update"
+ depends on PLATFORM_EC_LID_ANGLE
help
Enable this to allow using the lid angle measurement to determine if
peripheral devices should be enabled or disabled, like key scanning,
@@ -127,7 +126,6 @@ config PLATFORM_EC_GMR_TABLET_MODE
in common/tablet_mode.c.
endif # PLATFORM_EC_TABLET_MODE
-endif # PLATFORM_EC_LID_ANGLE
config PLATFORM_EC_CONSOLE_CMD_ACCELS
bool "Console commands: accels, accelrate, accelinit, accelinfo, etc."
@@ -174,4 +172,10 @@ config PLATFORM_EC_CONSOLE_CMD_ACCEL_SPOOF
endif # PLATFORM_EC_ACCEL_SPOOF_MODE
+config PLATFORM_EC_GESTURE_HOST_DETECTION
+ bool "Gesture host detection"
+ help
+ Enable gesture host interface
+
rsource "Kconfig.sensor_devices"
+rsource "Kconfig.body_detection"
diff --git a/zephyr/Kconfig.panic b/zephyr/Kconfig.panic
index c402fc1e70..4bffa64b39 100644
--- a/zephyr/Kconfig.panic
+++ b/zephyr/Kconfig.panic
@@ -2,6 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+config PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE
+ int "Size of preserved ram for panic and jump data"
+ default 1024
+ help
+ Size of preserved non-initialized memory at end of ram for panic and
+ jump data. The linker will ensure at least this much space is
+ unallocated.
+
if PLATFORM_EC_PANIC
config PLATFORM_EC_SOFTWARE_PANIC
diff --git a/zephyr/Kconfig.pd b/zephyr/Kconfig.pd
index f6508c2da0..c84c57d3c0 100644
--- a/zephyr/Kconfig.pd
+++ b/zephyr/Kconfig.pd
@@ -161,11 +161,15 @@ menuconfig PLATFORM_EC_USB_PD_DPS
default n
select HAS_TASK_DPS
help
- Enable this if the board needs dynamic PDO selection.
- DPS picks a power efficient PDO regarding to the underlying battery
- configuration and the system loading.
- Default configuration can be overridden by `dps_config` to adapt
- to each board's need.
+ Enable this to permit dynamic PDO selection (DPS). DPS can select different
+ USB PDOs depending on system load and battery configuration to select input
+ characteristics (particularly voltage) that allow the system to operate more
+ efficiently.
+
+ This should not be enabled without evaluating charger efficiency against
+ input voltage and overriding `dps_config` as necessary to accurately reflect
+ actual platform behavior: untuned behavior is likely to be worse than
+ leaving DPS disabled.
config PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE
bool "Board can use TCPC-controlled DRP toggle"
@@ -304,6 +308,15 @@ config PLATFORM_EC_USB_PE_SM
USB devices. You should normally define this unless you want to
override it in your board code, which is not recommended.
+config PLATFORM_EC_USB_DPM_SM
+ bool "Device Policy Manager (DPM) state machine"
+ default y
+ help
+ This enables the device policy manager portion of the power-delivery
+ (PD), protocol which is used to define port policy decision. You
+ should normally define this unless you want to override it in your
+ board code, which is not recommended.
+
config PLATFORM_EC_USB_PD_DECODE_SOP
def_bool y # Required for TCPMV2
help
diff --git a/zephyr/Kconfig.pmic b/zephyr/Kconfig.pmic
index 831767c546..ef1df085c8 100644
--- a/zephyr/Kconfig.pmic
+++ b/zephyr/Kconfig.pmic
@@ -15,8 +15,8 @@ if PLATFORM_EC_PMIC
config PLATFORM_EC_MP2964
bool "Enable MP2964 PMIC support"
- depends on AP_X86_INTEL
- depends on PLATFORM_EC_I2C
+ default y
+ depends on DT_HAS_MPS_MP2964_ENABLED
help
Enables support for the MPS MP2964 PMIC (Power Management IC).
This is a dual rail IMVP8 - IMVP9.1 compatible Digital
diff --git a/zephyr/Kconfig.retimer b/zephyr/Kconfig.retimer
index 9ce134dc13..3a052f1f1a 100644
--- a/zephyr/Kconfig.retimer
+++ b/zephyr/Kconfig.retimer
@@ -6,6 +6,8 @@ if PLATFORM_EC_USBC
config PLATFORM_EC_USBC_RETIMER_INTEL_BB
bool "Support Intel Burnside Bridge retimer"
+ depends on PLATFORM_EC_USB_MUX
+ depends on DT_HAS_INTEL_JHL8040R_ENABLED
select PLATFORM_EC_USB_PD_USB4
select PLATFORM_EC_USB_PD_TBT_COMPAT_MODE
help
@@ -29,6 +31,8 @@ config PLATFORM_EC_USBC_RETIMER_INTEL_BB
config PLATFORM_EC_USBC_RETIMER_INTEL_HB
bool "Support Intel Hayden Bridge retimer"
+ depends on PLATFORM_EC_USB_MUX
+ depends on DT_HAS_INTEL_JHL8040R_ENABLED
select PLATFORM_EC_USB_PD_USB4
select PLATFORM_EC_USB_PD_TBT_COMPAT_MODE
help
diff --git a/zephyr/Kconfig.system b/zephyr/Kconfig.system
index 5467bc7422..ec0333ec35 100644
--- a/zephyr/Kconfig.system
+++ b/zephyr/Kconfig.system
@@ -18,16 +18,50 @@ config PLATFORM_EC_CONSOLE_CMD_SYSINFO
Enable the sysinfo console command, which shows statistics
about the current image copy running, reset flags, etc.
+config PLATFORM_EC_HIBERNATE
+ bool
+ help
+ Enable system hibernation.
+ The type of hibernation supported must be selected.
+
+choice PLATFORM_EC_HIBERNATE_TYPE
+ prompt "Choose a hibernate type"
+ default PLATFORM_EC_HIBERNATE_PSL if DT_HAS_NUVOTON_NPCX_POWER_PSL_ENABLED && SOC_FAMILY_NPCX
+ default PLATFORM_EC_HIBERNATE_WAKE_PINS if !DT_HAS_NUVOTON_NPCX_POWER_PSL_ENABLED || !SOC_FAMILY_NPCX
+ help
+ Select the type of hibernation supported. Either
+ PLATFORM_EC_HIBERNATE_PSL (for power switch logic support) or
+ PLATFORM_EC_HIBERNATE_WAKE_PINS (using wake pins) are
+ supported.
+
config PLATFORM_EC_HIBERNATE_PSL
bool "System hibernating with PSL (Power Switch Logic) mechanism"
- default y
depends on DT_HAS_NUVOTON_NPCX_POWER_PSL_ENABLED
depends on SOC_FAMILY_NPCX
+ select PLATFORM_EC_HIBERNATE
help
Use PSL (Power Switch Logic) for hibernating. It turns off VCC power
rail for ultra-low power consumption and uses PSL inputs rely on VSBY
power rail to wake up ec and the whole system.
+config PLATFORM_EC_HIBERNATE_WAKE_PINS
+ bool "System hibernating with wake-source pins"
+ select PLATFORM_EC_HIBERNATE
+ help
+ Use wake source pins for hibernating. It turns off VCC power
+ rail for ultra-low power consumption and uses a low power
+ power rail. Changes on wake source pins will wake up the EC.
+
+endchoice # PLATFORM_EC_HIBERNATE_TYPE
+
+config PLATFORM_EC_HIBERNATE_DELAY_SEC
+ int "Delay in seconds from AP power off to hibernate"
+ depends on PLATFORM_EC_HIBERNATE
+ default 3600
+ help
+ This value is the delay in seconds from when the AP enters G3
+ to when the system is hibernated.
+
config PLATFORM_EC_SYSTEM_PRE_INIT_PRIORITY
int "System pre-initialization priority"
default 20
diff --git a/zephyr/Kconfig.temperature b/zephyr/Kconfig.temperature
index 09756663bc..82bac6922f 100644
--- a/zephyr/Kconfig.temperature
+++ b/zephyr/Kconfig.temperature
@@ -4,6 +4,8 @@
menuconfig PLATFORM_EC_TEMP_SENSOR
bool "Temperature sensors"
+ default y
+ depends on DT_HAS_CROS_EC_TEMP_SENSORS_ENABLED
help
Support for temperature sensors. Once enabled, "temps" console
command and EC_CMD_TEMP_SENSOR_GET_INFO host command are available.
@@ -33,6 +35,8 @@ config PLATFORM_EC_DPTF
config PLATFORM_EC_THERMISTOR
bool "Thermistor support"
+ default y
+ depends on DT_HAS_CROS_EC_THERMISTOR_ENABLED
depends on ADC
help
Enables support for thermistors (resistor whose resistance is
@@ -40,18 +44,24 @@ config PLATFORM_EC_THERMISTOR
config PLATFORM_EC_TEMP_SENSOR_PCT2075
bool "PCT2075 support"
+ default y
+ depends on DT_HAS_NXP_PCT2075_ENABLED
help
Enables support for the CrosEC PCT2075 sensor, an i2c peripheral
temperature sensor from NXP.
config PLATFORM_EC_TEMP_SENSOR_SB_TSI
bool "SB TSI support"
+ default y
+ depends on DT_HAS_AMD_SB_TSI_ENABLED
help
Enables support for the Side Band Temperature Sensor Interface,
an i2c peripheral available on AMD platforms.
config PLATFORM_EC_TEMP_SENSOR_TMP112
bool "TMP112 support"
+ default y
+ depends on DT_HAS_CROS_EC_TEMP_SENSOR_TMP112_ENABLED
help
Enables support for the CrosEC TMP112 driver, an i2c peripheral
temperature sensor from TI.
@@ -81,6 +91,7 @@ config PLATFORM_EC_FAN
bool "Fan support"
default y
depends on DT_HAS_CROS_EC_FANS_ENABLED
+ select PWM
help
Enables support for fans. Allows periodic thermal task to
automatically set the fan speed (control temperature).
@@ -90,6 +101,13 @@ config PLATFORM_EC_FAN
available. Also enables a periodic task (1s) to verify fan is
running (is not stalled).
+config PLATFORM_EC_CUSTOM_FAN_CONTROL
+ bool "Fan custom control support"
+ default n
+ help
+ Enable fan custom control to let projects define
+ their own fan control mechanism by EC.
+
if PLATFORM_EC_FAN
config PLATFORM_EC_NUM_FANS
diff --git a/zephyr/Kconfig.usb_charger b/zephyr/Kconfig.usb_charger
index 1c58753412..fa17f6c020 100644
--- a/zephyr/Kconfig.usb_charger
+++ b/zephyr/Kconfig.usb_charger
@@ -40,6 +40,8 @@ config PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201
config PLATFORM_EC_BC12_DETECT_PI3USB9201
bool "Enable support for Pericom PI3USB9201"
select PLATFORM_EC_BC12_DETECT_DATA_ROLE_TRIGGER
+ default y
+ depends on DT_HAS_PERICOM_PI3USB9201_ENABLED
help
This is a Dual-Role USB Charging-Type Detector. It can operate in
host or client mode. It supports Battery Charging Specification, rev
diff --git a/zephyr/Kconfig.usb_mux b/zephyr/Kconfig.usb_mux
index 6f4e31a2cf..376a28f9b2 100644
--- a/zephyr/Kconfig.usb_mux
+++ b/zephyr/Kconfig.usb_mux
@@ -7,6 +7,7 @@ if PLATFORM_EC_USBC
menuconfig PLATFORM_EC_USB_MUX
bool "USB muxes"
default y
+ depends on DT_HAS_CROS_EC_USB_MUX_CHAIN_ENABLED
help
Enables support for USB muxes. These allow multiplexing
diff --git a/zephyr/Kconfig.usba b/zephyr/Kconfig.usba
index 8abbe839f6..b5413d2c83 100644
--- a/zephyr/Kconfig.usba
+++ b/zephyr/Kconfig.usba
@@ -4,6 +4,8 @@
menuconfig PLATFORM_EC_USBA
bool "USB Type-A support"
+ default y
+ depends on DT_HAS_CROS_EC_USBA_PORT_ENABLE_PINS_ENABLED
help
Enable USB Type A ports
diff --git a/zephyr/Kconfig.usbc b/zephyr/Kconfig.usbc
index 903cf575c6..082f96ca7f 100644
--- a/zephyr/Kconfig.usbc
+++ b/zephyr/Kconfig.usbc
@@ -31,18 +31,54 @@ rsource "Kconfig.usb_charger"
if PLATFORM_EC_USBC
-config PLATFORM_EC_CHARGER_INPUT_CURRENT
+config PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT
int "Charger input current in mA"
depends on PLATFORM_EC_CHARGE_MANAGER
default 512
help
- This is the default input current for the board in mA. Many boards
- also use this as the least maximum input current during transients.
+ Default input current limit for the board in mA.
This value should depend on external power adapter, designed charging
voltage, and the maximum power of the running system. For type-C
- chargers, this should be set to 512 mA in order to not brown-out
- low-current USB charge ports in accordance with USB-PD r3.0 Sec. 7.3
+ chargers, this should be set to no more than 512 mA in order to not
+ brown-out low-current USB charge ports in accordance with USB-PD r3.0
+ Sec. 7.3.
+
+config PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT
+ int "Minimum charger input current limit in mA"
+ default 0
+ depends on PLATFORM_EC_CHARGE_MANAGER
+ help
+ Minimum current limit in mA that will ever be set for chargers, even if a
+ lower limit is requested.
+
+ If set, this should usually be set to no more than 2.5W divided by the
+ maximum supported input voltage in order to satisfy USB-PD pSnkStdby
+ requirements. Higher values may help devices stay alive under low-battery
+ conditions at the cost of violating standby power limits.
+
+ Many boards set this to large values, since historically this number was
+ usually equal to the default current limit. New boards should avoid doing
+ so if possible, and usually leave this unset: customization of
+ board_set_charge_limit() should be considered instead if a device sometimes
+ requires amounts of power in violation of specs, to limit those violations
+ only to situations where they are necessary.
+
+config PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT
+ int "Charger input current derating percentage"
+ default 0
+ depends on PLATFORM_EC_CHARGE_MANAGER
+ help
+ Setting this to a nonzero value causes actual charger current limits
+ to be adjusted by the given percentage. For example, setting this to
+ 4 and requesting a current limit of 1000 mA causes the charge manager
+ to program an actual current limit of 960 mA.
+
+ This is useful if a charger consistently draws more current than the
+ programmed limit, or if it is desired to derate for other
+ safety-related reasons. If a more complex (non-linear) adjustment is
+ required, boards should override the board_set_charge_limit()
+ function instead of configuring this option.
config PLATFORM_EC_USBC_OCP
bool
diff --git a/zephyr/app/ec/Kconfig b/zephyr/app/ec/Kconfig
index fbf6185740..72c80f5d3a 100644
--- a/zephyr/app/ec/Kconfig
+++ b/zephyr/app/ec/Kconfig
@@ -27,6 +27,14 @@ config NUM_PREEMPT_PRIORITIES
default 26
#
+# Override the LOG_PRINTK to be no as it currently makes multiple
+# tests timeout and a few others fail in console assertions
+# TODO(b/http://b/260772137) Fix LOG_PRINTK issue and remove override
+#
+config LOG_PRINTK
+ default n
+
+#
# In Zephyr, the default system workqueue thread priority level is the lowest
# cooperative priority. Override its priority to the second lowest preempt
# priority. (i.e. NUM_PREEMPT_PRIORITIES - 1)
@@ -154,4 +162,22 @@ config SHIMMED_TASKS
build. The CROS_EC_TASK_LIST defines a list of CROS_EC_TASK that
should be shimmed in.
+#
+# These shell options are turned off by MINIMAL_SHELL, but are important to us;
+# override Zephyr's default to keep them on.
+#
+config SHELL_HISTORY
+ default y
+
+config SHELL_TAB
+ default y
+
+config SHELL_TAB_AUTOCOMPLETION
+ default y if SHELL_TAB
+
+config SHELL_HELP
+ default y
+
+config KERNEL_SHELL
+ default y
endif # CROS_EC
diff --git a/zephyr/app/ec/chip/riscv/riscv-ite/it8xxx2-espi.c b/zephyr/app/ec/chip/riscv/riscv-ite/it8xxx2-espi.c
index 6109964cb9..3c623b5aac 100644
--- a/zephyr/app/ec/chip/riscv/riscv-ite/it8xxx2-espi.c
+++ b/zephyr/app/ec/chip/riscv/riscv-ite/it8xxx2-espi.c
@@ -2,12 +2,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <soc_espi.h>
-#include <ap_power/ap_power.h>
-#include <chipset.h>
#include <zephyr/devicetree.h>
#include <zephyr/logging/log.h>
+#include <ap_power/ap_power.h>
+#include <chipset.h>
+#include <soc_espi.h>
+
LOG_MODULE_REGISTER(ec_chip_it8xxx2_espi, CONFIG_ESPI_LOG_LEVEL);
/*
diff --git a/zephyr/app/ec/ec_app_main.c b/zephyr/app/ec/ec_app_main.c
index 9b13c8ab86..4ab5fd3a44 100644
--- a/zephyr/app/ec/ec_app_main.c
+++ b/zephyr/app/ec/ec_app_main.c
@@ -3,14 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/sys/printk.h>
-#include <zephyr/shell/shell_uart.h>
-
#include "ap_power/ap_pwrseq.h"
#include "button.h"
#include "chipset.h"
#include "cros_board_info.h"
+#include "ec_app_main.h"
#include "ec_tasks.h"
#include "hooks.h"
#include "keyboard_scan.h"
@@ -19,7 +16,10 @@
#include "vboot.h"
#include "watchdog.h"
#include "zephyr_espi_shim.h"
-#include "ec_app_main.h"
+
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell_uart.h>
+#include <zephyr/sys/printk.h>
/* For testing purposes this is not named main. See main_shim.c for the real
* main() function.
diff --git a/zephyr/app/ec/main_shim.c b/zephyr/app/ec/main_shim.c
index a14cff2dcb..0ec92b70bf 100644
--- a/zephyr/app/ec/main_shim.c
+++ b/zephyr/app/ec/main_shim.c
@@ -3,10 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
#include "ec_app_main.h"
#include "host_command.h"
+#include <zephyr/kernel.h>
+
/** A stub main to call the real ec app main function. LCOV_EXCL_START */
void main(void)
{
diff --git a/zephyr/boards/arm/mec1727/mec1727_defconfig b/zephyr/boards/arm/mec1727/mec1727_defconfig
index e8c189750e..b99bd0a487 100644
--- a/zephyr/boards/arm/mec1727/mec1727_defconfig
+++ b/zephyr/boards/arm/mec1727/mec1727_defconfig
@@ -12,10 +12,6 @@ CONFIG_RTOS_TIMER=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32768
CONFIG_SYS_CLOCK_TICKS_PER_SEC=32768
-# ADC
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
# Serial Drivers
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
diff --git a/zephyr/boards/arm/npcx7/npcx7.dts b/zephyr/boards/arm/npcx7/npcx7.dts
index c1e548c62b..a4f0646001 100644
--- a/zephyr/boards/arm/npcx7/npcx7.dts
+++ b/zephyr/boards/arm/npcx7/npcx7.dts
@@ -7,9 +7,12 @@
#include <cros/nuvoton/npcx7.dtsi>
#include <dt-bindings/gpio_defines.h>
+#include <dt-bindings/gpio/nuvoton-npcx-gpio.h>
#include <nuvoton/npcx7m7fc.dtsi>
#include <nuvoton/npcx/npcx7/npcx7-pinctrl.dtsi>
+#define GPIO_VOLTAGE_1P8 NPCX_GPIO_VOLTAGE_1P8
+
/ {
model = "NPCX7";
diff --git a/zephyr/boards/arm/npcx7/npcx7_defconfig b/zephyr/boards/arm/npcx7/npcx7_defconfig
index c6c8f6c3f4..f84f44f9e3 100644
--- a/zephyr/boards/arm/npcx7/npcx7_defconfig
+++ b/zephyr/boards/arm/npcx7/npcx7_defconfig
@@ -12,10 +12,6 @@ CONFIG_BOARD_NPCX7=y
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
-# ADC
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
# Enable console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
diff --git a/zephyr/boards/arm/npcx9/npcx9.dtsi b/zephyr/boards/arm/npcx9/npcx9.dtsi
index 15547d5802..113cecc173 100644
--- a/zephyr/boards/arm/npcx9/npcx9.dtsi
+++ b/zephyr/boards/arm/npcx9/npcx9.dtsi
@@ -4,8 +4,11 @@
*/
#include <dt-bindings/gpio_defines.h>
+#include <dt-bindings/gpio/nuvoton-npcx-gpio.h>
#include <nuvoton/npcx/npcx9/npcx9-pinctrl.dtsi>
+#define GPIO_VOLTAGE_1P8 NPCX_GPIO_VOLTAGE_1P8
+
/ {
model = "NPCX9";
@@ -56,6 +59,112 @@
pinmux = <&altc_shi_sl>;
pinmux-gpio;
};
+
+ /* Keyboard peripheral interfaces */
+ /omit-if-no-ref/ ksi0_gpio_gp31: periph-kbscan-ksi0-gpio {
+ pinmux = <&alt7_no_ksi0_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ ksi1_gpio_gp30: periph-kbscan-ksi1-gpio {
+ pinmux = <&alt7_no_ksi1_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ ksi2_gpio_gp27: periph-kbscan-ksi2-gpio {
+ pinmux = <&alt7_no_ksi2_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ ksi3_gpio_gp26: periph-kbscan-ksi3-gpio {
+ pinmux = <&alt7_no_ksi3_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ ksi4_gpio_gp25: periph-kbscan-ksi4-gpio {
+ pinmux = <&alt7_no_ksi4_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ ksi5_gpio_gp24: periph-kbscan-ksi5-gpio {
+ pinmux = <&alt7_no_ksi5_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ ksi6_gpio_gp23: periph-kbscan-ksi6-gpio {
+ pinmux = <&alt7_no_ksi6_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ ksi7_gpio_gp22: periph-kbscan-ksi7-gpio {
+ pinmux = <&alt7_no_ksi7_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso00_gpio_gp21: periph-kbscan-kso00-gpio {
+ pinmux = <&alt8_no_kso00_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso01_gpio_gp20: periph-kbscan-kso01-gpio {
+ pinmux = <&alt8_no_kso01_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso02_gpio_gp17: periph-kbscan-kso02-gpio {
+ pinmux = <&alt8_no_kso02_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso03_gpio_gp16: periph-kbscan-kso03-gpio {
+ pinmux = <&alt8_no_kso03_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso04_gpio_gp15: periph-kbscan-kso04-gpio {
+ pinmux = <&alt8_no_kso04_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso05_gpio_gp14: periph-kbscan-kso05-gpio {
+ pinmux = <&alt8_no_kso05_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso06_gpio_gp13: periph-kbscan-kso06-gpio {
+ pinmux = <&alt8_no_kso06_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso07_gpio_gp12: periph-kbscan-kso07-gpio {
+ pinmux = <&alt8_no_kso07_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso08_gpio_gp11: periph-kbscan-kso08-gpio {
+ pinmux = <&alt9_no_kso08_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso09_gpio_gp10: periph-kbscan-kso09-gpio {
+ pinmux = <&alt9_no_kso09_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso10_gpio_gp07: periph-kbscan-kso10-gpio {
+ pinmux = <&alt9_no_kso10_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso11_gpio_gp06: periph-kbscan-kso11-gpio {
+ pinmux = <&alt9_no_kso11_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso12_gpio_gp05: periph-kbscan-kso12-gpio {
+ pinmux = <&alt9_no_kso12_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso13_gpio_gp04: periph-kbscan-kso13-gpio {
+ pinmux = <&alt9_no_kso13_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso14_gpio_gp82: periph-kbscan-kso14-gpio {
+ pinmux = <&alt9_no_kso14_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso15_gpio_gp83: periph-kbscan-kso15-gpio {
+ pinmux = <&alt9_no_kso15_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso16_gpio_gp03: periph-kbscan-kso16-gpio {
+ pinmux = <&alta_no_kso16_sl>;
+ pinmux-gpio;
+ };
+ /omit-if-no-ref/ kso17_gpio_gpb1: periph-kbscan-kso17-gpio {
+ pinmux = <&alta_no_kso17_sl>;
+ pinmux-gpio;
+ };
};
/* PSL_OUT is fixed to GPIO85 in npcx9 series. */
diff --git a/zephyr/boards/arm/npcx9/npcx9m3f_defconfig b/zephyr/boards/arm/npcx9/npcx9m3f_defconfig
index d3b4bcc3a2..8238d10e03 100644
--- a/zephyr/boards/arm/npcx9/npcx9m3f_defconfig
+++ b/zephyr/boards/arm/npcx9/npcx9m3f_defconfig
@@ -9,10 +9,6 @@ CONFIG_SOC_NPCX9M3F=y
# Platform Configuration
CONFIG_BOARD_NPCX9=y
-# ADC
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
# Serial Drivers
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
diff --git a/zephyr/boards/arm/npcx9/npcx9m7f_defconfig b/zephyr/boards/arm/npcx9/npcx9m7f_defconfig
index e742904aed..1cb02182da 100644
--- a/zephyr/boards/arm/npcx9/npcx9m7f_defconfig
+++ b/zephyr/boards/arm/npcx9/npcx9m7f_defconfig
@@ -9,10 +9,6 @@ CONFIG_SOC_NPCX9M7F=y
# Platform Configuration
CONFIG_BOARD_NPCX9=y
-# ADC
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
# Serial Drivers
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
diff --git a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig
index faee09f492..755d982eef 100644
--- a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig
+++ b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig
@@ -40,14 +40,6 @@ CONFIG_WATCHDOG=y
# I2C
CONFIG_I2C=y
-# ADC
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-
# Power Management
CONFIG_PM=y
CONFIG_PM_DEVICE=y
diff --git a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig
index da75b3d113..bdedd931c1 100644
--- a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig
+++ b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig
@@ -37,17 +37,6 @@ CONFIG_CLOCK_CONTROL=y
# WATCHDOG configuration
CONFIG_WATCHDOG=y
-# I2C
-CONFIG_I2C=y
-
-# ADC
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-
# Power Management
CONFIG_PM=y
CONFIG_PM_DEVICE=y
diff --git a/zephyr/boards/riscv/it8xxx2/it81202bx_defconfig b/zephyr/boards/riscv/it8xxx2/it81202bx_defconfig
index a024ab5824..82a8a0f63f 100644
--- a/zephyr/boards/riscv/it8xxx2/it81202bx_defconfig
+++ b/zephyr/boards/riscv/it8xxx2/it81202bx_defconfig
@@ -10,10 +10,6 @@ CONFIG_SOC_IT81202_BX=y
# Platform Configuration
CONFIG_BOARD_IT8XXX2=y
-# ADC
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
# Power Management
CONFIG_PM=y
CONFIG_PM_DEVICE=y
diff --git a/zephyr/boards/riscv/it8xxx2/it81302bx_defconfig b/zephyr/boards/riscv/it8xxx2/it81302bx_defconfig
index 2841b9663c..6cfac9eeb5 100644
--- a/zephyr/boards/riscv/it8xxx2/it81302bx_defconfig
+++ b/zephyr/boards/riscv/it8xxx2/it81302bx_defconfig
@@ -10,10 +10,6 @@ CONFIG_SOC_IT81302_BX=y
# Platform Configuration
CONFIG_BOARD_IT8XXX2=y
-# ADC
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
# Power Management
CONFIG_PM=y
CONFIG_PM_DEVICE=y
diff --git a/zephyr/boards/riscv/it8xxx2/it8xxx2.dts b/zephyr/boards/riscv/it8xxx2/it8xxx2.dts
index 640efd1433..a7cc336cb4 100644
--- a/zephyr/boards/riscv/it8xxx2/it8xxx2.dts
+++ b/zephyr/boards/riscv/it8xxx2/it8xxx2.dts
@@ -6,9 +6,12 @@
/dts-v1/;
#include <dt-bindings/gpio_defines.h>
+#include <dt-bindings/gpio/ite-it8xxx2-gpio.h>
#include <cros/ite/it8xxx2.dtsi>
#include <ite/it8xxx2.dtsi>
+#define GPIO_VOLTAGE_1P8 IT8XXX2_GPIO_VOLTAGE_1P8
+
/ {
model = "Google IT8XXX2 Baseboard";
diff --git a/zephyr/cmake/compiler/clang/compiler_flags.cmake b/zephyr/cmake/compiler/clang/compiler_flags.cmake
index 3423f1c36c..f24e1f1f4c 100644
--- a/zephyr/cmake/compiler/clang/compiler_flags.cmake
+++ b/zephyr/cmake/compiler/clang/compiler_flags.cmake
@@ -8,9 +8,19 @@ include("${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake")
set_compiler_property(PROPERTY hosted)
# Disable position independent code.
-add_compile_options(-fno-PIC)
+if ("${ARCH}" STREQUAL "posix" OR "${ARCH}" STREQUAL "unit_testing")
+ add_compile_options(-fPIC)
+else()
+ add_compile_options(-fno-PIC)
+endif()
+
+# When testing, look for stack smashing
+add_compile_option_ifdef(CONFIG_ZTEST -fstack-protector-all)
check_set_compiler_property(APPEND PROPERTY warning_extended -Wunused-variable
-Werror=unused-variable -Werror=missing-braces
-Werror=sometimes-uninitialized -Werror=unused-function
-Werror=array-bounds)
+
+# clang flags for coverage generation
+set_property(TARGET compiler PROPERTY coverage --coverage -fno-inline)
diff --git a/zephyr/cmake/compiler/clang/generic.cmake b/zephyr/cmake/compiler/clang/generic.cmake
index b848c8bd03..a59b7e4a72 100644
--- a/zephyr/cmake/compiler/clang/generic.cmake
+++ b/zephyr/cmake/compiler/clang/generic.cmake
@@ -3,4 +3,5 @@
# found in the LICENSE file.
set(CMAKE_C_COMPILER "/usr/bin/x86_64-pc-linux-gnu-clang")
+set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-pc-linux-gnu-clang++")
set(CMAKE_GCOV "/usr/bin/llvm-cov gcov")
diff --git a/zephyr/cmake/compiler/gcc/compiler_flags.cmake b/zephyr/cmake/compiler/gcc/compiler_flags.cmake
index adc111835e..fbc7ca1d61 100644
--- a/zephyr/cmake/compiler/gcc/compiler_flags.cmake
+++ b/zephyr/cmake/compiler/gcc/compiler_flags.cmake
@@ -8,3 +8,6 @@ include("${ZEPHYR_BASE}/cmake/compiler/gcc/compiler_flags.cmake")
# Disable position independent code.
add_compile_options(-fno-PIC)
+
+# gcc flags for coverage generation
+set_compiler_property(PROPERTY coverage -fprofile-arcs -ftest-coverage -fno-inline)
diff --git a/zephyr/cmake/compiler/gcc/generic.cmake b/zephyr/cmake/compiler/gcc/generic.cmake
new file mode 100644
index 0000000000..8f41f59bee
--- /dev/null
+++ b/zephyr/cmake/compiler/gcc/generic.cmake
@@ -0,0 +1,5 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+include("${ZEPHYR_BASE}/cmake/compiler/gcc/generic.cmake")
diff --git a/zephyr/cmake/linker/ld/clang/linker_flags.cmake b/zephyr/cmake/linker/ld/clang/linker_flags.cmake
new file mode 100644
index 0000000000..38f5428d13
--- /dev/null
+++ b/zephyr/cmake/linker/ld/clang/linker_flags.cmake
@@ -0,0 +1,7 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+if (NOT CONFIG_COVERAGE_GCOV)
+ set_property(TARGET linker PROPERTY coverage --coverage)
+endif()
diff --git a/zephyr/cmake/linker/ld/gcc/linker_flags.cmake b/zephyr/cmake/linker/ld/gcc/linker_flags.cmake
index f71793c431..b5ec8b05ca 100644
--- a/zephyr/cmake/linker/ld/gcc/linker_flags.cmake
+++ b/zephyr/cmake/linker/ld/gcc/linker_flags.cmake
@@ -2,6 +2,10 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+if (NOT CONFIG_COVERAGE_GCOV)
+ set_property(TARGET linker PROPERTY coverage -lgcov)
+endif()
+
# GCC 11 by default emits DWARF version 5 which cannot be parsed by
# pyelftools. Can be removed once pyelftools supports v5.
add_link_options(-gdwarf-4)
diff --git a/zephyr/cmake/toolchain/host/generic.cmake b/zephyr/cmake/toolchain/host/generic.cmake
new file mode 100644
index 0000000000..4cc0fbd352
--- /dev/null
+++ b/zephyr/cmake/toolchain/host/generic.cmake
@@ -0,0 +1,18 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+set(CROSS_COMPILE_TARGET_posix x86_64-pc-linux-gnu)
+set(CROSS_COMPILE_TARGET_unit_testing x86_64-pc-linux-gnu)
+set(CROSS_COMPILE_TARGET ${CROSS_COMPILE_TARGET_${ARCH}})
+
+set(CC gcc)
+set(CROSS_COMPILE "/usr/bin/${CROSS_COMPILE_TARGET}-")
+
+set(COMPILER gcc)
+set(LINKER ld)
+set(BINTOOLS gnu)
+
+set(TOOLCHAIN_HAS_NEWLIB OFF CACHE BOOL "True if toolchain supports newlib")
+
+message(STATUS "Found toolchain: host ${ARCH} (gcc/ld)")
diff --git a/zephyr/cmake/toolchain/host/target.cmake b/zephyr/cmake/toolchain/host/target.cmake
new file mode 100644
index 0000000000..9d540f97ff
--- /dev/null
+++ b/zephyr/cmake/toolchain/host/target.cmake
@@ -0,0 +1,5 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+include("${ZEPHYR_BASE}/cmake/toolchain/host/target.cmake")
diff --git a/zephyr/cmake/toolchain/llvm/target.cmake b/zephyr/cmake/toolchain/llvm/target.cmake
index e6960dade5..e8e5df7be1 100644
--- a/zephyr/cmake/toolchain/llvm/target.cmake
+++ b/zephyr/cmake/toolchain/llvm/target.cmake
@@ -7,8 +7,8 @@ set(LINKER lld)
set(BINTOOLS llvm)
# Mapping of Zephyr architecture -> toolchain triple
-# Note only "posix" is supported at the moment.
-set(CROSS_COMPILE_TARGET_posix x86_64-pc-linux-gnu)
+set(CROSS_COMPILE_TARGET_posix x86_64-pc-linux-gnu)
+set(CROSS_COMPILE_TARGET_unit_testing x86_64-pc-linux-gnu)
set(CROSS_COMPILE_TARGET ${CROSS_COMPILE_TARGET_${ARCH}})
diff --git a/zephyr/drivers/cros_displight/cros_displight.c b/zephyr/drivers/cros_displight/cros_displight.c
index 98d1dd0823..850b0d7c90 100644
--- a/zephyr/drivers/cros_displight/cros_displight.c
+++ b/zephyr/drivers/cros_displight/cros_displight.c
@@ -5,29 +5,27 @@
#define DT_DRV_COMPAT cros_ec_displight
+#include "common.h"
+#include "util.h"
+
#include <zephyr/devicetree.h>
-#include <drivers/cros_displight.h>
#include <zephyr/drivers/pwm.h>
#include <zephyr/logging/log.h>
-#include "common.h"
-#include "util.h"
+#include <drivers/cros_displight.h>
LOG_MODULE_REGISTER(displight, LOG_LEVEL_ERR);
BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
"Exactly one instance of cros-ec,displight should be defined.");
-#define DISPLIGHT_PWM_NODE DT_INST_PWMS_CTLR(0)
-#define DISPLIGHT_PWM_CHANNEL DT_INST_PWMS_CHANNEL(0)
-#define DISPLIGHT_PWM_FLAGS DT_INST_PWMS_FLAGS(0)
-#define DISPLIGHT_PWM_PERIOD_NS DT_INST_PWMS_PERIOD(0)
+static const struct pwm_dt_spec displight_pwm = PWM_DT_SPEC_INST_GET(0);
static int displight_percent;
static void displight_set_duty(int percent)
{
- const struct device *pwm_dev = DEVICE_DT_GET(DISPLIGHT_PWM_NODE);
+ const struct device *pwm_dev = displight_pwm.dev;
uint32_t pulse_ns;
int rv;
@@ -36,15 +34,14 @@ static void displight_set_duty(int percent)
return;
}
- pulse_ns = DIV_ROUND_NEAREST(DISPLIGHT_PWM_PERIOD_NS * percent, 100);
+ pulse_ns = DIV_ROUND_NEAREST(displight_pwm.period * percent, 100);
LOG_DBG("displight PWM %s set percent (%d), pulse %d", pwm_dev->name,
percent, pulse_ns);
- rv = pwm_set(pwm_dev, DISPLIGHT_PWM_CHANNEL, DISPLIGHT_PWM_PERIOD_NS,
- pulse_ns, DISPLIGHT_PWM_FLAGS);
+ rv = pwm_set_pulse_dt(&displight_pwm, pulse_ns);
if (rv) {
- LOG_ERR("pwm_set() failed %s (%d)", pwm_dev->name, rv);
+ LOG_ERR("pwm_set_pulse_dt failed %s (%d)", pwm_dev->name, rv);
}
}
diff --git a/zephyr/drivers/cros_flash/Kconfig b/zephyr/drivers/cros_flash/Kconfig
index 8931f413e4..06f2b9f8c0 100644
--- a/zephyr/drivers/cros_flash/Kconfig
+++ b/zephyr/drivers/cros_flash/Kconfig
@@ -4,8 +4,8 @@
menuconfig CROS_FLASH_NPCX
bool "Nuvoton NPCX flash driver for the Zephyr shim"
- depends on SOC_FAMILY_NPCX
default y
+ depends on DT_HAS_NUVOTON_NPCX_CROS_FLASH_ENABLED
select PLATFORM_EC_FLASH_CROS
select PLATFORM_EC_SPI_FLASH_REGS
help
@@ -39,8 +39,8 @@ config CROS_FLASH_IT8XXX2
config CROS_FLASH_XEC
bool "Microchip XEC flash driver for the Zephyr shim"
- depends on SOC_FAMILY_MEC
default y
+ depends on DT_HAS_MICROCHIP_XEC_CROS_FLASH_ENABLED
select PLATFORM_EC_FLASH_CROS
select PLATFORM_EC_SPI_FLASH_REGS
help
diff --git a/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c b/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c
index 4838c5d583..79ef0c36b2 100644
--- a/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c
+++ b/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c
@@ -5,17 +5,18 @@
#define DT_DRV_COMPAT ite_it8xxx2_cros_flash
-#include <drivers/cros_flash.h>
-#include <zephyr/drivers/flash.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-#include <soc.h>
-
#include "flash.h"
#include "host_command.h"
#include "system.h"
#include "watchdog.h"
+#include <zephyr/drivers/flash.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
+#include <drivers/cros_flash.h>
+#include <soc.h>
+
LOG_MODULE_REGISTER(cros_flash, LOG_LEVEL_ERR);
/* Device data */
diff --git a/zephyr/drivers/cros_flash/cros_flash_npcx.c b/zephyr/drivers/cros_flash/cros_flash_npcx.c
index 032bb5906c..e49067ad1a 100644
--- a/zephyr/drivers/cros_flash/cros_flash_npcx.c
+++ b/zephyr/drivers/cros_flash/cros_flash_npcx.c
@@ -5,18 +5,19 @@
#define DT_DRV_COMPAT nuvoton_npcx_cros_flash
-#include <drivers/cros_flash.h>
+#include "../drivers/flash/spi_nor.h"
+#include "flash.h"
+#include "spi_flash_reg.h"
+#include "write_protect.h"
+
#include <zephyr/drivers/flash.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/spi.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
-#include <soc.h>
-#include "flash.h"
-#include "spi_flash_reg.h"
-#include "write_protect.h"
-#include "../drivers/flash/spi_nor.h"
+#include <drivers/cros_flash.h>
+#include <soc.h>
LOG_MODULE_REGISTER(cros_flash, LOG_LEVEL_ERR);
diff --git a/zephyr/drivers/cros_flash/cros_flash_xec.c b/zephyr/drivers/cros_flash/cros_flash_xec.c
index 2b92eae25b..610a79c971 100644
--- a/zephyr/drivers/cros_flash/cros_flash_xec.c
+++ b/zephyr/drivers/cros_flash/cros_flash_xec.c
@@ -5,18 +5,19 @@
#define DT_DRV_COMPAT microchip_xec_cros_flash
-#include <drivers/cros_flash.h>
+#include "../drivers/flash/spi_nor.h"
+#include "flash.h"
+#include "spi_flash_reg.h"
+#include "write_protect.h"
+
#include <zephyr/drivers/flash.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/spi.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
-#include <soc.h>
-#include "flash.h"
-#include "spi_flash_reg.h"
-#include "write_protect.h"
-#include "../drivers/flash/spi_nor.h"
+#include <drivers/cros_flash.h>
+#include <soc.h>
LOG_MODULE_REGISTER(cros_flash, LOG_LEVEL_ERR);
diff --git a/zephyr/drivers/cros_kb_raw/Kconfig b/zephyr/drivers/cros_kb_raw/Kconfig
index 1055c8a4b2..1e10f38bbe 100644
--- a/zephyr/drivers/cros_kb_raw/Kconfig
+++ b/zephyr/drivers/cros_kb_raw/Kconfig
@@ -6,8 +6,8 @@ if PLATFORM_EC_KEYBOARD
menuconfig CROS_KB_RAW_NPCX
bool "Nuvoton NPCX raw-keyboard-scan driver for the Zephyr shim"
- depends on SOC_FAMILY_NPCX
default y
+ depends on DT_HAS_NUVOTON_NPCX_CROS_KB_RAW_ENABLED
help
This option enables a driver for providing raw access to the
keyboard-scan peripheral in the chip. This is used instead of the
@@ -27,8 +27,8 @@ endif # CROS_KB_RAW_NPCX
config CROS_KB_RAW_ITE
bool "ITE raw-keyboard-scan driver for the Zephyr shim"
- depends on SOC_FAMILY_RISCV_ITE
default y
+ depends on DT_HAS_ITE_IT8XXX2_CROS_KB_RAW_ENABLED
help
This option enables a driver for providing raw access to the
keyboard-scan peripheral in the chip. This is used instead of the
@@ -37,8 +37,8 @@ config CROS_KB_RAW_ITE
menuconfig CROS_KB_RAW_XEC
bool "Microchip raw-keyboard-scan driver for the Zephyr shim"
- depends on SOC_FAMILY_MEC
default y
+ depends on DT_HAS_MICROCHIP_XEC_CROS_KB_RAW_ENABLED
help
This option enables a driver for providing raw access to the
keyboard-scan peripheral in the chip. This is used instead of the
diff --git a/zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c b/zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c
index fdbc8ee30d..f824d1d90c 100644
--- a/zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c
+++ b/zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c
@@ -5,22 +5,23 @@
#define DT_DRV_COMPAT ite_it8xxx2_cros_kb_raw
+#include "ec_tasks.h"
+#include "keyboard_raw.h"
+#include "task.h"
+
#include <assert.h>
-#include <drivers/cros_kb_raw.h>
+
#include <zephyr/drivers/clock_control.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/interrupt_controller/wuc_ite_it8xxx2.h>
#include <zephyr/dt-bindings/interrupt-controller/it8xxx2-wuc.h>
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
+#include <drivers/cros_kb_raw.h>
#include <soc.h>
-#include <soc_dt.h>
#include <soc/ite_it8xxx2/reg_def_cros.h>
-
-#include "ec_tasks.h"
-#include "keyboard_raw.h"
-#include "task.h"
-
-#include <zephyr/logging/log.h>
+#include <soc_dt.h>
LOG_MODULE_REGISTER(cros_kb_raw, LOG_LEVEL_ERR);
#define KEYBOARD_KSI_PIN_COUNT IT8XXX2_DT_INST_WUCCTRL_LEN(0)
diff --git a/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c b/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c
index c720f4b431..6c61568016 100644
--- a/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c
+++ b/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c
@@ -5,21 +5,22 @@
#define DT_DRV_COMPAT nuvoton_npcx_cros_kb_raw
-#include <assert.h>
-#include <zephyr/dt-bindings/clock/npcx_clock.h>
-#include <drivers/cros_kb_raw.h>
-#include <zephyr/drivers/clock_control.h>
-#include <zephyr/drivers/pinctrl.h>
-#include <zephyr/kernel.h>
-#include <soc.h>
-#include <soc/nuvoton_npcx/reg_def_cros.h>
-
#include "ec_tasks.h"
#include "keyboard_raw.h"
#include "soc_miwu.h"
#include "task.h"
+#include <assert.h>
+
+#include <zephyr/drivers/clock_control.h>
+#include <zephyr/drivers/pinctrl.h>
+#include <zephyr/dt-bindings/clock/npcx_clock.h>
+#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
+
+#include <drivers/cros_kb_raw.h>
+#include <soc.h>
+#include <soc/nuvoton_npcx/reg_def_cros.h>
LOG_MODULE_REGISTER(cros_kb_raw, LOG_LEVEL_ERR);
#ifdef CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED
@@ -218,11 +219,24 @@ static int cros_kb_raw_npcx_init(const struct device *dev)
return 0;
}
+#ifdef CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST
+static int cros_kb_raw_npcx_config_alt(const struct device *dev, bool enable)
+{
+ const struct cros_kb_raw_npcx_config *const config = DRV_CONFIG(dev);
+ uint8_t id = enable ? PINCTRL_STATE_DEFAULT : PINCTRL_STATE_SLEEP;
+
+ return pinctrl_apply_state(config->pcfg, id);
+}
+#endif
+
static const struct cros_kb_raw_driver_api cros_kb_raw_npcx_driver_api = {
.init = cros_kb_raw_npcx_init,
.drive_colum = cros_kb_raw_npcx_drive_column,
.read_rows = cros_kb_raw_npcx_read_row,
.enable_interrupt = cros_kb_raw_npcx_enable_interrupt,
+#ifdef CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST
+ .config_alt = cros_kb_raw_npcx_config_alt,
+#endif
};
PINCTRL_DT_INST_DEFINE(0);
diff --git a/zephyr/drivers/cros_kb_raw/cros_kb_raw_xec.c b/zephyr/drivers/cros_kb_raw/cros_kb_raw_xec.c
index 797377f84f..30ffd7ca85 100644
--- a/zephyr/drivers/cros_kb_raw/cros_kb_raw_xec.c
+++ b/zephyr/drivers/cros_kb_raw/cros_kb_raw_xec.c
@@ -5,19 +5,20 @@
#define DT_DRV_COMPAT microchip_xec_cros_kb_raw
-#include <assert.h>
-#include <drivers/cros_kb_raw.h>
-#include <zephyr/drivers/clock_control.h>
-#include <zephyr/drivers/pinctrl.h>
-#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
-#include <soc.h>
-#include <soc/microchip_xec/reg_def_cros.h>
-
#include "ec_tasks.h"
#include "keyboard_raw.h"
#include "task.h"
+#include <assert.h>
+
+#include <zephyr/drivers/clock_control.h>
+#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
+#include <zephyr/drivers/pinctrl.h>
#include <zephyr/logging/log.h>
+
+#include <drivers/cros_kb_raw.h>
+#include <soc.h>
+#include <soc/microchip_xec/reg_def_cros.h>
LOG_MODULE_REGISTER(cros_kb_raw, LOG_LEVEL_ERR);
#ifdef CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED
diff --git a/zephyr/drivers/cros_kblight/pwm_kblight.c b/zephyr/drivers/cros_kblight/pwm_kblight.c
index 59b4ef20ef..ca395f8dba 100644
--- a/zephyr/drivers/cros_kblight/pwm_kblight.c
+++ b/zephyr/drivers/cros_kblight/pwm_kblight.c
@@ -5,30 +5,27 @@
#define DT_DRV_COMPAT cros_ec_kblight_pwm
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/pwm.h>
-#include <zephyr/logging/log.h>
-
#include "common.h"
#include "keyboard_backlight.h"
#include "util.h"
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/pwm.h>
+#include <zephyr/logging/log.h>
+
LOG_MODULE_REGISTER(kblight, LOG_LEVEL_ERR);
BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
"Exactly one instance of cros-ec,kblight-pwm should be defined.");
-#define KBLIGHT_PWM_NODE DT_INST_PWMS_CTLR(0)
-#define KBLIGHT_PWM_CHANNEL DT_INST_PWMS_CHANNEL(0)
-#define KBLIGHT_PWM_FLAGS DT_INST_PWMS_FLAGS(0)
-#define KBLIGHT_PWM_PERIOD_NS DT_INST_PWMS_PERIOD(0)
+static const struct pwm_dt_spec kblight_pwm_dt = PWM_DT_SPEC_INST_GET(0);
static bool kblight_enabled;
static int kblight_percent;
static void kblight_pwm_set_duty(int percent)
{
- const struct device *pwm_dev = DEVICE_DT_GET(KBLIGHT_PWM_NODE);
+ const struct device *pwm_dev = kblight_pwm_dt.dev;
uint32_t pulse_ns;
int rv;
@@ -37,15 +34,14 @@ static void kblight_pwm_set_duty(int percent)
return;
}
- pulse_ns = DIV_ROUND_NEAREST(KBLIGHT_PWM_PERIOD_NS * percent, 100);
+ pulse_ns = DIV_ROUND_NEAREST(kblight_pwm_dt.period * percent, 100);
LOG_DBG("kblight PWM %s set percent (%d), pulse %d", pwm_dev->name,
percent, pulse_ns);
- rv = pwm_set(pwm_dev, KBLIGHT_PWM_CHANNEL, KBLIGHT_PWM_PERIOD_NS,
- pulse_ns, KBLIGHT_PWM_FLAGS);
+ rv = pwm_set_pulse_dt(&kblight_pwm_dt, pulse_ns);
if (rv) {
- LOG_ERR("pwm_set() failed %s (%d)", pwm_dev->name, rv);
+ LOG_ERR("pwm_set_pulse_dt failed %s (%d)", pwm_dev->name, rv);
}
}
@@ -56,11 +52,6 @@ static int kblight_pwm_set(int percent)
return EC_SUCCESS;
}
-static int kblight_pwm_get(void)
-{
- return kblight_percent;
-}
-
static int kblight_pwm_enable(int enable)
{
kblight_enabled = enable;
@@ -88,7 +79,6 @@ static int kblight_pwm_init(void)
const struct kblight_drv kblight_pwm = {
.init = kblight_pwm_init,
.set = kblight_pwm_set,
- .get = kblight_pwm_get,
.enable = kblight_pwm_enable,
.get_enabled = kblight_pwm_get_enabled,
};
diff --git a/zephyr/drivers/cros_rtc/Kconfig b/zephyr/drivers/cros_rtc/Kconfig
index 2839b03c62..2f064b4db8 100644
--- a/zephyr/drivers/cros_rtc/Kconfig
+++ b/zephyr/drivers/cros_rtc/Kconfig
@@ -6,7 +6,12 @@ if PLATFORM_EC_RTC && !ARCH_POSIX
choice CROS_RTC_TYPE
prompt "Select the RTC to use"
- default CROS_RTC_NPCX if SOC_FAMILY_NPCX
+ # List standalone controllers before embedded once so that they get
+ # higher priority.
+ default CROS_RTC_NXP_PCF85063A if DT_HAS_NXP_RTC_PCF85063A_ENABLED
+ default CROS_RTC_RENESAS_IDT1337AG if DT_HAS_RENESAS_RTC_IDT1337AG_ENABLED
+ default CROS_RTC_NPCX if DT_HAS_NUVOTON_NPCX_CROS_MTC_ENABLED
+ default CROS_RTC_XEC if DT_HAS_MICROCHIP_XEC_CROS_RTC_ENABLED
help
Select the RTC used on the board.
@@ -40,4 +45,11 @@ config CROS_RTC_RENESAS_IDT1337AG
endchoice # CROS_RTC_TYPE
+config PLATFORM_EC_PCF85063A_CAP_SEL
+ bool "Set CAP_SEL of PCF85063A"
+ depends on CROS_RTC_NXP_PCF85063A
+ help
+ This option select the internal oscillator capacitor to 12.5 pF,
+ default is 7 pF.
+
endif # PLATFORM_EC_RTC
diff --git a/zephyr/drivers/cros_rtc/cros_rtc_npcx.c b/zephyr/drivers/cros_rtc/cros_rtc_npcx.c
index 3312ad899f..a248357cfe 100644
--- a/zephyr/drivers/cros_rtc/cros_rtc_npcx.c
+++ b/zephyr/drivers/cros_rtc/cros_rtc_npcx.c
@@ -1,23 +1,23 @@
-/*
- * Copyright 2021 Google LLC
- *
- * SPDX-License-Identifier: Apache-2.0
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
*/
#define DT_DRV_COMPAT nuvoton_npcx_cros_mtc
-#include <assert.h>
-#include <drivers/cros_rtc.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/kernel.h>
-#include <soc.h>
-#include <soc/nuvoton_npcx/reg_def_cros.h>
-
#include "ec_tasks.h"
#include "soc_miwu.h"
#include "task.h"
+#include <assert.h>
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
+
+#include <drivers/cros_rtc.h>
+#include <soc.h>
+#include <soc/nuvoton_npcx/reg_def_cros.h>
LOG_MODULE_REGISTER(cros_rtc, LOG_LEVEL_ERR);
#define NPCX_MTC_TTC_LOAD_DELAY_US 250 /* Delay after writing TTC */
diff --git a/zephyr/drivers/cros_rtc/cros_rtc_xec.c b/zephyr/drivers/cros_rtc/cros_rtc_xec.c
index c543aab6af..f42560e107 100644
--- a/zephyr/drivers/cros_rtc/cros_rtc_xec.c
+++ b/zephyr/drivers/cros_rtc/cros_rtc_xec.c
@@ -5,17 +5,18 @@
#define DT_DRV_COMPAT microchip_xec_cros_rtc
+#include "ec_tasks.h"
+#include "task.h"
+
#include <assert.h>
-#include <drivers/cros_rtc.h>
+
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
+#include <drivers/cros_rtc.h>
#include <soc.h>
#include <soc/microchip_xec/reg_def_cros.h>
-
-#include "ec_tasks.h"
-#include "task.h"
-
-#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(cros_rtc, LOG_LEVEL_ERR);
/* Driver config */
diff --git a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c
index c5580eaeef..298c8cd64f 100644
--- a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c
+++ b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c
@@ -5,18 +5,19 @@
#define DT_DRV_COMPAT nxp_rtc_pcf85063a
+#include "nxp_rtc_pcf85063a.h"
+
#include <assert.h>
+
#include <zephyr/device.h>
-#include <drivers/cros_rtc.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
+#include <drivers/cros_rtc.h>
#include <rtc.h>
#include <soc.h>
-
-#include "nxp_rtc_pcf85063a.h"
-
-#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(cros_rtc, LOG_LEVEL_ERR);
/* Driver config */
@@ -362,6 +363,16 @@ static int nxp_rtc_pcf85063a_init(const struct device *dev)
}
}
+#ifdef CONFIG_PLATFORM_EC_PCF85063A_CAP_SEL
+ ret = pcf85063a_write_reg(dev, REG_CONTROL_1,
+ (CONTROL_1_DEFAULT_VALUE | CAP_SEL));
+
+ if (ret < 0) {
+ LOG_ERR("PCF85063A set CAP_SEL Fail!");
+ return ret;
+ }
+#endif
+
/*
* Read Seconds register and check if oscillator is stopped.
* If so, clear the bit.
diff --git a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h
index 54b1fbd2ea..c0139db631 100644
--- a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h
+++ b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h
@@ -10,6 +10,7 @@
#define SOFT_RESET 0x58
#define CONTROL_1_DEFAULT_VALUE 0
#define OS_BIT 0x80
+#define CAP_SEL 0x01
#define DISABLE_ALARM 0x80
#define ENABLE_ALARM_INTERRUPT 0x80
#define RTC_STOP_CLOCKS 0x20
diff --git a/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c b/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c
index 7a9a11fd41..f6d3a7c292 100644
--- a/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c
+++ b/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c
@@ -5,18 +5,19 @@
#define DT_DRV_COMPAT renesas_rtc_idt1337ag
+#include "renesas_rtc_idt1337ag.h"
+
#include <assert.h>
+
#include <zephyr/device.h>
-#include <drivers/cros_rtc.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
+#include <drivers/cros_rtc.h>
#include <rtc.h>
#include <soc.h>
-
-#include "renesas_rtc_idt1337ag.h"
-
-#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(cros_rtc, LOG_LEVEL_ERR);
/* Driver config */
diff --git a/zephyr/drivers/cros_shi/Kconfig b/zephyr/drivers/cros_shi/Kconfig
index ebcd937c7d..3b93ad48ee 100644
--- a/zephyr/drivers/cros_shi/Kconfig
+++ b/zephyr/drivers/cros_shi/Kconfig
@@ -2,17 +2,19 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+if PLATFORM_EC_HOST_INTERFACE_SHI
+
config CROS_SHI_NPCX
bool
- depends on SOC_FAMILY_NPCX
- depends on PLATFORM_EC_HOST_INTERFACE_SHI
default y
+ depends on DT_HAS_NUVOTON_NPCX_CROS_SHI_ENABLED
help
This option enables Serial Host Interface driver for the NPCX family
of processors. This is used for host-command communication on the
platform which AP is ARM-based SoC.
if CROS_SHI_NPCX
+
config CROS_SHI_MAX_REQUEST
hex "Max data size for the version 3 request packet"
default 0x220
@@ -38,9 +40,8 @@ endif # CROS_SHI_NPCX
config CROS_SHI_IT8XXX2
bool
- depends on SOC_FAMILY_RISCV_ITE
- depends on PLATFORM_EC_HOST_INTERFACE_SHI
default y
+ depends on DT_HAS_ITE_IT8XXX2_CROS_SHI_ENABLED
help
This option enables spi host interface driver which is required to
communicate with the EC when the CPU is the ARM processor.
@@ -58,3 +59,5 @@ config CROS_SHI_IT8XXX2_INIT_PRIORITY
configuration these pins to alt function of SHI.
endif # CROS_SHI_IT8XXX2
+
+endif # PLATFORM_EC_HOST_INTERFACE_SHI
diff --git a/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c b/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c
index ee6ce3f7a4..15b5daf85b 100644
--- a/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c
+++ b/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c
@@ -5,20 +5,22 @@
#define DT_DRV_COMPAT ite_it8xxx2_cros_shi
-#include <zephyr/device.h>
+#include "chipset.h"
+#include "console.h"
+#include "gpio/gpio_int.h"
+#include "host_command.h"
+
#include <errno.h>
+
+#include <zephyr/device.h>
+#include <zephyr/drivers/pinctrl.h>
+#include <zephyr/dt-bindings/pinctrl/it8xxx2-pinctrl.h>
#include <zephyr/init.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
+
#include <soc.h>
#include <soc_dt.h>
-#include <zephyr/drivers/pinctrl.h>
-#include <zephyr/dt-bindings/pinctrl/it8xxx2-pinctrl.h>
-
-#include "chipset.h"
-#include "console.h"
-#include "gpio/gpio_int.h"
-#include "host_command.h"
/* Console output macros */
#define CPRINTS(format, args...) cprints(CC_SPI, format, ##args)
diff --git a/zephyr/drivers/cros_shi/cros_shi_npcx.c b/zephyr/drivers/cros_shi/cros_shi_npcx.c
index ce3279288b..79bc79db2e 100644
--- a/zephyr/drivers/cros_shi/cros_shi_npcx.c
+++ b/zephyr/drivers/cros_shi/cros_shi_npcx.c
@@ -5,22 +5,24 @@
#define DT_DRV_COMPAT nuvoton_npcx_cros_shi
-#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
+#include "host_command.h"
+#include "soc_miwu.h"
+#include "system.h"
+
#include <assert.h>
-#include <zephyr/dt-bindings/clock/npcx_clock.h>
+
+#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
#include <zephyr/drivers/clock_control.h>
-#include <zephyr/drivers/pinctrl.h>
-#include <drivers/cros_shi.h>
#include <zephyr/drivers/gpio.h>
-#include <zephyr/logging/log.h>
+#include <zephyr/drivers/pinctrl.h>
+#include <zephyr/dt-bindings/clock/npcx_clock.h>
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
+#include <drivers/cros_shi.h>
#include <soc.h>
#include <soc/nuvoton_npcx/reg_def_cros.h>
-#include "host_command.h"
-#include "soc_miwu.h"
-#include "system.h"
-
#ifdef CONFIG_CROS_SHI_NPCX_DEBUG
#define DEBUG_CPRINTS(format, args...) cprints(CC_SPI, format, ##args)
#define DEBUG_CPRINTF(format, args...) cprintf(CC_SPI, format, ##args)
diff --git a/zephyr/drivers/cros_system/cros_system_it8xxx2.c b/zephyr/drivers/cros_system/cros_system_it8xxx2.c
index 8c63886808..a78b5c929c 100644
--- a/zephyr/drivers/cros_system/cros_system_it8xxx2.c
+++ b/zephyr/drivers/cros_system/cros_system_it8xxx2.c
@@ -5,17 +5,18 @@
#define DT_DRV_COMPAT ite_it8xxx2_gctrl
+#include "drivers/cros_system.h"
+#include "gpio/gpio_int.h"
+#include "system.h"
+#include "util.h"
+
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>
+
#include <soc.h>
#include <soc/ite_it8xxx2/reg_def_cros.h>
-#include "drivers/cros_system.h"
-#include "gpio/gpio_int.h"
-#include "system.h"
-#include "util.h"
-
LOG_MODULE_REGISTER(cros_system, LOG_LEVEL_ERR);
#define GCTRL_IT8XXX2_REG_BASE \
diff --git a/zephyr/drivers/cros_system/cros_system_native_posix.c b/zephyr/drivers/cros_system/cros_system_native_posix.c
index fab9c4d033..59fdb39972 100644
--- a/zephyr/drivers/cros_system/cros_system_native_posix.c
+++ b/zephyr/drivers/cros_system/cros_system_native_posix.c
@@ -6,12 +6,12 @@
/* LCOV_EXCL_START */
/* This is test code, so it should be excluded from coverage */
-#include <zephyr/logging/log.h>
-#include <zephyr/sys/util.h>
-
#include "common.h"
#include "drivers/cros_system.h"
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/util.h>
+
LOG_MODULE_REGISTER(cros_system, LOG_LEVEL_ERR);
/* Driver config stub */
diff --git a/zephyr/drivers/cros_system/cros_system_npcx.c b/zephyr/drivers/cros_system/cros_system_npcx.c
index 4ab21ca549..4fc1f1f977 100644
--- a/zephyr/drivers/cros_system/cros_system_npcx.c
+++ b/zephyr/drivers/cros_system/cros_system_npcx.c
@@ -3,21 +3,22 @@
* found in the LICENSE file.
*/
+#include "drivers/cros_system.h"
+#include "gpio/gpio_int.h"
+#include "rom_chip.h"
+#include "soc_gpio.h"
+#include "soc_miwu.h"
+#include "system.h"
+
#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/pinctrl.h>
#include <zephyr/drivers/watchdog.h>
#include <zephyr/logging/log.h>
-#include <soc.h>
-#include <soc/nuvoton_npcx/reg_def_cros.h>
#include <zephyr/sys/util.h>
-#include "drivers/cros_system.h"
-#include "gpio/gpio_int.h"
-#include "rom_chip.h"
-#include "soc_gpio.h"
-#include "soc_miwu.h"
-#include "system.h"
+#include <soc.h>
+#include <soc/nuvoton_npcx/reg_def_cros.h>
LOG_MODULE_REGISTER(cros_system, LOG_LEVEL_ERR);
diff --git a/zephyr/drivers/cros_system/cros_system_xec.c b/zephyr/drivers/cros_system/cros_system_xec.c
index a3cf9aea22..f91b4630fc 100644
--- a/zephyr/drivers/cros_system/cros_system_xec.c
+++ b/zephyr/drivers/cros_system/cros_system_xec.c
@@ -3,18 +3,19 @@
* found in the LICENSE file.
*/
+#include "gpio/gpio_int.h"
+#include "system.h"
+#include "system_chip.h"
+
#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
-#include <drivers/cros_system.h>
+#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
#include <zephyr/drivers/watchdog.h>
#include <zephyr/logging/log.h>
-#include <soc.h>
-#include <soc/microchip_xec/reg_def_cros.h>
#include <zephyr/sys/util.h>
-#include "system.h"
-#include "system_chip.h"
-#include <zephyr/drivers/interrupt_controller/intc_mchp_xec_ecia.h>
-#include "gpio/gpio_int.h"
+#include <drivers/cros_system.h>
+#include <soc.h>
+#include <soc/microchip_xec/reg_def_cros.h>
LOG_MODULE_REGISTER(cros_system, LOG_LEVEL_ERR);
diff --git a/zephyr/dts/bindings/battery/battery-fuel-gauge.yaml b/zephyr/dts/bindings/battery/battery-fuel-gauge.yaml
index d2fed4bfa6..83bd825236 100644
--- a/zephyr/dts/bindings/battery/battery-fuel-gauge.yaml
+++ b/zephyr/dts/bindings/battery/battery-fuel-gauge.yaml
@@ -5,8 +5,6 @@
description: |
Battery fuel gauge parameters
-compatible: "battery-fuel-gauge"
-
properties:
manuf_name:
description: |
diff --git a/zephyr/dts/bindings/battery/battery-info.yaml b/zephyr/dts/bindings/battery/battery-info.yaml
index 54e81cedeb..c188616260 100644
--- a/zephyr/dts/bindings/battery/battery-info.yaml
+++ b/zephyr/dts/bindings/battery/battery-info.yaml
@@ -8,8 +8,6 @@ description:
Current is in milliamperes
Temperature is in Celsius degrees
-compatible: "battery-info"
-
properties:
voltage_max:
description: |
diff --git a/zephyr/dts/bindings/battery/battery-smart.yaml b/zephyr/dts/bindings/battery/battery-smart.yaml
index 1d0c9786eb..5992226291 100644
--- a/zephyr/dts/bindings/battery/battery-smart.yaml
+++ b/zephyr/dts/bindings/battery/battery-smart.yaml
@@ -28,6 +28,7 @@ properties:
- "dynapack,cosmx_gh02047xl"
- "dynapack,c140254"
- "ganfeng,7c01"
+ - "ganfeng,sg20"
- "getac,bq40z50-R3-S3"
- "getac,bq40z50-R3-S2"
- "lgc,ac17a8m"
diff --git a/zephyr/dts/bindings/battery/cosmx,ap20cbl-2.yaml b/zephyr/dts/bindings/battery/cosmx,ap20cbl-2.yaml
index 5e64834f15..7faceedb11 100644
--- a/zephyr/dts/bindings/battery/cosmx,ap20cbl-2.yaml
+++ b/zephyr/dts/bindings/battery/cosmx,ap20cbl-2.yaml
@@ -17,22 +17,22 @@ properties:
default: 0x3A
ship_mode_reg_data:
default: [ 0xC574, 0xC574 ]
- # Documentation: b/243772306
+ # Documentation: b/257860663#comment7
# Manufacturer Access 0x00
- # b14: C-FET Status (0: Off, 1: On)
- # b15: D-FET Status (0: Off, 1: On)
+ # b14: Charging Disabled (0: Off, 1: On)
+ # b13: Discharging Disabled (0: Off, 1: On)
fet_mfgacc_support:
default: 1
fet_reg_addr:
default: 0x0
fet_reg_mask:
- default: 0x8000
+ default: 0x2000
fet_disconnect_val:
- default: 0x0000
+ default: 0x2000
fet_cfet_mask:
default: 0x4000
fet_cfet_off_val:
- default: 0x0000
+ default: 0x4000
# Battery info
voltage_max:
diff --git a/zephyr/dts/bindings/battery/ganfeng,sg20.yaml b/zephyr/dts/bindings/battery/ganfeng,sg20.yaml
new file mode 100644
index 0000000000..6e8f558b00
--- /dev/null
+++ b/zephyr/dts/bindings/battery/ganfeng,sg20.yaml
@@ -0,0 +1,53 @@
+description: "Ganfeng SG20"
+compatible: "ganfeng,sg20"
+
+include: battery-smart.yaml
+
+properties:
+ enum-name:
+ type: string
+ default: "ganfeng,sg20"
+
+ # Fuel gauge
+ manuf_name:
+ default: "Ganfeng"
+ device_name:
+ default: "SG20"
+ ship_mode_reg_addr:
+ default: 0x00
+ ship_mode_reg_data:
+ default: [ 0x0010, 0x0010 ]
+ fet_mfgacc_support:
+ default: 0
+ fet_reg_addr:
+ default: 0x43
+ fet_reg_mask:
+ default: 0x0001
+ fet_disconnect_val:
+ default: 0x0000
+ fet_cfet_mask:
+ default: 0x0002
+ fet_cfet_off_val:
+ default: 0x0000
+
+ # Battery info
+ voltage_max:
+ default: 8700
+ voltage_normal:
+ default: 7600
+ 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: 60
diff --git a/zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc-value.yaml b/zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc-value.yaml
new file mode 100644
index 0000000000..6bbba1bdd7
--- /dev/null
+++ b/zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc-value.yaml
@@ -0,0 +1,22 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+description:
+ Possible CBI SSFC field values.
+ It has to be defined as grandchild on the "cros-ec,cbi-ssfc"
+
+compatible: "cros-ec,cbi-ssfc-value"
+
+properties:
+ value:
+ type: int
+ required: true
+ description:
+ Unique value of CBI SSFC field
+ default:
+ type: boolean
+ description:
+ Indicates that the specified value is default for the parent
+ CBI SSFC field node. It should appear only once for the CBI SSFC
+ definition.
diff --git a/zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc.yaml b/zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc.yaml
new file mode 100644
index 0000000000..d1cc4c26e5
--- /dev/null
+++ b/zephyr/dts/bindings/cbi/cros-ec,cbi-ssfc.yaml
@@ -0,0 +1,56 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+description: CBI Second Source Factory Cache (SSFC)
+
+compatible: "cros-ec,cbi-ssfc"
+
+child-binding:
+ description:
+ CBI SSFC fields definition.
+ The order of the children in this node define the order
+ of the SSFC bit fields from least significant bit to most
+ significant bit. The total size of all SSFC bit fields
+ must not exceed 32 bits.
+ properties:
+ enum-name:
+ type: string
+ required: true
+ description:
+ Enum values used only for description purposes
+ enum:
+ - AUDIO_CODEC
+ - BASE_SENSOR
+ - LID_SENSOR
+ - LIGHTBAR
+ - USB_SS_MUX
+ size:
+ type: int
+ required: true
+ description: The size of the field in bits.
+
+# Example:
+#
+# cbi-ssfc {
+# compatible = "cros-ec,cbi-ssfc";
+#
+# base_sensor {
+# enum-name = "BASE_SENSOR";
+# size = <3>;
+# bmi160 {
+# compatible = "cros-ec,cbi-ssfc-value";
+# status = "okay";
+#
+# value = <1>;
+# devices = <&alt_base_accel &alt_base_gyro>;
+# };
+# kx022 {
+# compatible = "cros-ec,cbi-ssfc-value";
+# status = "okay";
+#
+# value = <3>;
+# devices = <&base_accel_kx022>;
+# };
+# };
+# };
diff --git a/zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml b/zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml
deleted file mode 100644
index 7e04afed87..0000000000
--- a/zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description:
- Possible CBI SSFC field values.
- It has to be defied as grandchild on the "named-cbi-ssfc"
-
-compatible: "named-cbi-ssfc-value"
-
-properties:
- value:
- type: int
- required: true
- description:
- Unique value of CBI SSFC field
- default:
- type: boolean
- description:
- Indicates that the specified value is default for the parent
- CBI SSFC field node. It should appear only once for the CBI SSFC
- definition.
diff --git a/zephyr/dts/bindings/cbi/named-cbi-ssfc.yaml b/zephyr/dts/bindings/cbi/named-cbi-ssfc.yaml
deleted file mode 100644
index 2db330079d..0000000000
--- a/zephyr/dts/bindings/cbi/named-cbi-ssfc.yaml
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: CBI Second Source Factory Cache (SSFC)
-
-compatible: "named-cbi-ssfc"
-
-child-binding:
- description:
- CBI SSFC fields definition.
- The order of the children in this node define the order
- of the SSFC bit fields from least significant bit to most
- significant bit. The total size of all SSFC bit fields
- must not exceed 32 bits.
- properties:
- enum-name:
- type: string
- required: true
- description:
- Enum values used only for description purposes
- enum:
- - AUDIO_CODEC
- - BASE_SENSOR
- - LID_SENSOR
- - LIGHTBAR
- - USB_SS_MUX
- size:
- type: int
- required: true
- description: The size of the field in bits.
-
-# Example:
-#
-# cbi-ssfc {
-# compatible = "named-cbi-ssfc";
-#
-# base_sensor {
-# enum-name = "BASE_SENSOR";
-# size = <3>;
-# bmi160 {
-# compatible = "named-cbi-ssfc-value";
-# status = "okay";
-#
-# value = <1>;
-# devices = <&alt_base_accel &alt_base_gyro>;
-# };
-# kx022 {
-# compatible = "named-cbi-ssfc-value";
-# status = "okay";
-#
-# value = <3>;
-# devices = <&base_accel_kx022>;
-# };
-# };
-# }; \ No newline at end of file
diff --git a/zephyr/dts/bindings/charger/richtek,rt9490.yaml b/zephyr/dts/bindings/charger/richtek,rt9490.yaml
index ecd25696f3..0f9acf999a 100644
--- a/zephyr/dts/bindings/charger/richtek,rt9490.yaml
+++ b/zephyr/dts/bindings/charger/richtek,rt9490.yaml
@@ -9,6 +9,11 @@ compatible: "richtek,rt9490"
include: chg-chip.yaml
properties:
- thermistor:
- type: phandle
- description: Underlying thermistor device to measure temperature
+ irq:
+ type: phandles
+ description: |
+ GPIO interrupt from BC1.2
+
+ thermistor:
+ type: phandle
+ description: Underlying thermistor device to measure temperature
diff --git a/zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8186-power-signal-list.yaml b/zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8186-power-signal-list.yaml
new file mode 100644
index 0000000000..5f0e75f717
--- /dev/null
+++ b/zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8186-power-signal-list.yaml
@@ -0,0 +1,20 @@
+# Copyright 2021 Google LLC
+# SPDX-License-Identifier: Apache-2.0
+
+description: MediaTek MT8186, Power Signal List
+compatible: "mediatek,mt8186-power-signal-list"
+
+include: power-signal-list.yaml
+
+properties:
+ power-signals-required:
+ default: 4
+
+child-binding:
+ properties:
+ power-enum-name:
+ enum:
+ - AP_IN_RST
+ - AP_IN_S3
+ - AP_WDT_ASSERTED
+ - AP_WARM_RST_REQ
diff --git a/zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8192-power-signal-list.yaml b/zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8192-power-signal-list.yaml
new file mode 100644
index 0000000000..8bbd1207eb
--- /dev/null
+++ b/zephyr/dts/bindings/cros_pwr_signal/mediatek,mt8192-power-signal-list.yaml
@@ -0,0 +1,19 @@
+# Copyright 2021 Google LLC
+# SPDX-License-Identifier: Apache-2.0
+
+description: MediaTek, Power Signal List
+compatible: "mediatek,mt8192-power-signal-list"
+
+include: power-signal-list.yaml
+
+properties:
+ power-signals-required:
+ default: 3
+
+child-binding:
+ properties:
+ power-enum-name:
+ enum:
+ - AP_IN_S3_L
+ - AP_WDT_ASSERTED
+ - PMIC_PWR_GOOD
diff --git a/zephyr/dts/bindings/cros_pwr_signal/mt8186,power-signal-list.yaml b/zephyr/dts/bindings/cros_pwr_signal/mt8186,power-signal-list.yaml
deleted file mode 100644
index 6e9af9ccef..0000000000
--- a/zephyr/dts/bindings/cros_pwr_signal/mt8186,power-signal-list.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2021 Google LLC
-# SPDX-License-Identifier: Apache-2.0
-
-description: MediaTek MT8186, Power Signal List
-compatible: "mt8186,power-signal-list"
-
-include: power-signal-list.yaml
-
-properties:
- power-signals-required:
- default: 4
-
-child-binding:
- properties:
- power-enum-name:
- enum:
- - AP_IN_RST
- - AP_IN_S3
- - AP_WDT_ASSERTED
- - AP_WARM_RST_REQ
diff --git a/zephyr/dts/bindings/cros_pwr_signal/mt8192,power-signal-list.yaml b/zephyr/dts/bindings/cros_pwr_signal/mt8192,power-signal-list.yaml
deleted file mode 100644
index b1dedb76c8..0000000000
--- a/zephyr/dts/bindings/cros_pwr_signal/mt8192,power-signal-list.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2021 Google LLC
-# SPDX-License-Identifier: Apache-2.0
-
-description: MediaTek, Power Signal List
-compatible: "mt8192,power-signal-list"
-
-include: power-signal-list.yaml
-
-properties:
- power-signals-required:
- default: 3
-
-child-binding:
- properties:
- power-enum-name:
- enum:
- - AP_IN_S3_L
- - AP_WDT_ASSERTED
- - PMIC_PWR_GOOD
diff --git a/zephyr/dts/bindings/emul/cros,anx7447-tcpc-emul.yaml b/zephyr/dts/bindings/emul/cros,anx7447-tcpc-emul.yaml
new file mode 100644
index 0000000000..a4b41a0cec
--- /dev/null
+++ b/zephyr/dts/bindings/emul/cros,anx7447-tcpc-emul.yaml
@@ -0,0 +1,16 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+description: Zephyr ANX7447 emulator
+
+compatible: "cros,anx7447-tcpc-emul"
+
+include: i2c-device.yaml
+
+properties:
+ tcpc-flags:
+ type: int
+ default: 0
+ description: |
+ TCPC configuration flags
diff --git a/zephyr/dts/bindings/emul/cros,anx7447-tcpc.yaml b/zephyr/dts/bindings/emul/cros,anx7447-tcpc.yaml
deleted file mode 100644
index 562485d03d..0000000000
--- a/zephyr/dts/bindings/emul/cros,anx7447-tcpc.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-#
-description: Zephyr ANX7447 emulator
-
-compatible: "cros,anx7447-emul"
-
-include: i2c-device.yaml
-
-properties:
- tcpc-flags:
- type: int
- default: 0
- description: |
- TCPC configuration flags
diff --git a/zephyr/dts/bindings/emul/cros,bb-retimer-emul.yaml b/zephyr/dts/bindings/emul/cros,bb-retimer-emul.yaml
deleted file mode 100644
index 11dd5f5218..0000000000
--- a/zephyr/dts/bindings/emul/cros,bb-retimer-emul.yaml
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Zephyr BB retimer Emulator
-
-compatible: "cros,bb-retimer-emul"
-
-include: base.yaml
-
-properties:
- vendor:
- type: string
- required: true
- enum:
- - BB_RETIMER_VENDOR_ID_1
- - BB_RETIMER_VENDOR_ID_2
- description: Vendor ID used by device that is emulated.
-
- error-on-ro-write:
- type: boolean
- description:
- Flag indicating if error should be generated when read only register
- is being written.
-
- error-on-reserved-bit-write:
- type: boolean
- description:
- Flag indicating if error should be generated when reserved bit
- is being written.
diff --git a/zephyr/dts/bindings/emul/zephyr,bma255-emul.yaml b/zephyr/dts/bindings/emul/zephyr,bma255-emul.yaml
new file mode 100644
index 0000000000..7017d62667
--- /dev/null
+++ b/zephyr/dts/bindings/emul/zephyr,bma255-emul.yaml
@@ -0,0 +1,83 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+description: Zephyr BMA255 Emulator
+
+compatible: "zephyr,bma255-emul"
+
+include: base.yaml
+
+properties:
+ nvm-off-x:
+ type: int
+ required: false
+ default: 0
+ description: Accelerometer offset of x axis stored in NVM.
+
+ nvm-off-y:
+ type: int
+ required: false
+ default: 0
+ description: Accelerometer offset of y axis stored in NVM.
+
+ nvm-off-z:
+ type: int
+ required: false
+ default: 0
+ description: Accelerometer offset of z axis stored in NVM.
+
+ nvm-gp0:
+ type: int
+ required: false
+ default: 0
+ description: GP0 value stored in NVM.
+
+ nvm-gp1:
+ type: int
+ required: false
+ default: 0
+ description: GP1 value stored in NVM.
+
+ nvm-acc-x:
+ type: int
+ required: false
+ default: 0
+ description: Accelerometer value of x axis used until new value is set.
+
+ nvm-acc-y:
+ type: int
+ required: false
+ default: 0
+ description: Accelerometer value of y axis used until new value is set.
+
+ nvm-acc-z:
+ type: int
+ required: false
+ default: 0
+ description: Accelerometer value of z axis used until new value is set.
+
+ error-on-compensation-not-ready:
+ type: boolean
+ description:
+ Flag indicating if error should be generated when fast compensation
+ is started when not ready bit is set.
+
+ error-on-ro-write:
+ type: boolean
+ description:
+ Flag indicating if error should be generated when read only register
+ is being written.
+
+ error-on-reserved-bit-write:
+ type: boolean
+ description:
+ Flag indicating if error should be generated when reserved bit
+ is being written.
+
+ error-on-msb-first-access:
+ type: boolean
+ description:
+ Flag indicating if error should be generated when MSB register of
+ accelerometer value is accessed before LSB and shadowing is enabled
+ at the same time.
diff --git a/zephyr/dts/bindings/emul/zephyr,bma255.yaml b/zephyr/dts/bindings/emul/zephyr,bma255.yaml
deleted file mode 100644
index 3f504e05a5..0000000000
--- a/zephyr/dts/bindings/emul/zephyr,bma255.yaml
+++ /dev/null
@@ -1,83 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Zephyr BMA255 Emulator
-
-compatible: "zephyr,bma255"
-
-include: base.yaml
-
-properties:
- nvm-off-x:
- type: int
- required: false
- default: 0
- description: Accelerometer offset of x axis stored in NVM.
-
- nvm-off-y:
- type: int
- required: false
- default: 0
- description: Accelerometer offset of y axis stored in NVM.
-
- nvm-off-z:
- type: int
- required: false
- default: 0
- description: Accelerometer offset of z axis stored in NVM.
-
- nvm-gp0:
- type: int
- required: false
- default: 0
- description: GP0 value stored in NVM.
-
- nvm-gp1:
- type: int
- required: false
- default: 0
- description: GP1 value stored in NVM.
-
- nvm-acc-x:
- type: int
- required: false
- default: 0
- description: Accelerometer value of x axis used until new value is set.
-
- nvm-acc-y:
- type: int
- required: false
- default: 0
- description: Accelerometer value of y axis used until new value is set.
-
- nvm-acc-z:
- type: int
- required: false
- default: 0
- description: Accelerometer value of z axis used until new value is set.
-
- error-on-compensation-not-ready:
- type: boolean
- description:
- Flag indicating if error should be generated when fast compensation
- is started when not ready bit is set.
-
- error-on-ro-write:
- type: boolean
- description:
- Flag indicating if error should be generated when read only register
- is being written.
-
- error-on-reserved-bit-write:
- type: boolean
- description:
- Flag indicating if error should be generated when reserved bit
- is being written.
-
- error-on-msb-first-access:
- type: boolean
- description:
- Flag indicating if error should be generated when MSB register of
- accelerometer value is accessed before LSB and shadowing is enabled
- at the same time.
diff --git a/zephyr/dts/bindings/emul/zephyr,bmi-emul.yaml b/zephyr/dts/bindings/emul/zephyr,bmi-emul.yaml
new file mode 100644
index 0000000000..b8b1d2551d
--- /dev/null
+++ b/zephyr/dts/bindings/emul/zephyr,bmi-emul.yaml
@@ -0,0 +1,42 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+description: Zephyr BMI Emulator
+
+compatible: "zephyr,bmi-emul"
+
+include: base.yaml
+
+properties:
+ device-model:
+ type: string
+ required: true
+ enum:
+ - BMI_EMUL_160
+ - BMI_EMUL_260
+ description: Model of device that is emulated.
+
+ error-on-ro-write:
+ type: boolean
+ description:
+ Flag indicating if error should be generated when read only register
+ is being written.
+
+ error-on-wo-read:
+ type: boolean
+ description:
+ Flag indicating if error should be generated when write only register
+ is being read.
+
+ error-on-reserved-bit-write:
+ type: boolean
+ description:
+ Flag indicating if error should be generated when reserved bit
+ is being written.
+
+ simulate-command-exec-time:
+ type: boolean
+ description:
+ Flag indicating if emulator should wait the same amount of time before
+ finishing command as real device would.
diff --git a/zephyr/dts/bindings/emul/zephyr,bmi.yaml b/zephyr/dts/bindings/emul/zephyr,bmi.yaml
deleted file mode 100644
index 6280d5cc39..0000000000
--- a/zephyr/dts/bindings/emul/zephyr,bmi.yaml
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Zephyr BMI Emulator
-
-compatible: "zephyr,bmi"
-
-include: base.yaml
-
-properties:
- device-model:
- type: string
- required: true
- enum:
- - BMI_EMUL_160
- - BMI_EMUL_260
- description: Model of device that is emulated.
-
- error-on-ro-write:
- type: boolean
- description:
- Flag indicating if error should be generated when read only register
- is being written.
-
- error-on-wo-read:
- type: boolean
- description:
- Flag indicating if error should be generated when write only register
- is being read.
-
- error-on-reserved-bit-write:
- type: boolean
- description:
- Flag indicating if error should be generated when reserved bit
- is being written.
-
- simulate-command-exec-time:
- type: boolean
- description:
- Flag indicating if emulator should wait the same amount of time before
- finishing command as real device would.
diff --git a/zephyr/dts/bindings/emul/zephyr,pi3usb9201-emul.yaml b/zephyr/dts/bindings/emul/zephyr,pi3usb9201-emul.yaml
deleted file mode 100644
index 1f26a62f73..0000000000
--- a/zephyr/dts/bindings/emul/zephyr,pi3usb9201-emul.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Zephyr pi3usb9201 Emulator
-
-compatible: "zephyr,pi3usb9201-emul"
-
-include: base.yaml
diff --git a/zephyr/dts/bindings/emul/zephyr,smart-battery-emul.yaml b/zephyr/dts/bindings/emul/zephyr,smart-battery-emul.yaml
new file mode 100644
index 0000000000..88060b01d7
--- /dev/null
+++ b/zephyr/dts/bindings/emul/zephyr,smart-battery-emul.yaml
@@ -0,0 +1,161 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+description: Zephyr Smart Battery Emulator
+
+compatible: "zephyr,smart-battery-emul"
+
+include: base.yaml
+
+properties:
+ mf-access:
+ type: int
+ required: false
+ default: 0
+ description: Word returned on manufacturer access command.
+
+ at-rate-full-mw-support:
+ type: boolean
+ description:
+ Flag indicating if AT_RATE_TIME_TO_FULL command supports mW capacity
+ mode.
+
+ version:
+ type: string
+ required: false
+ enum:
+ - BATTERY_SPEC_VER_1_0
+ - BATTERY_SPEC_VER_1_1
+ - BATTERY_SPEC_VER_1_1_WITH_PEC
+ default: BATTERY_SPEC_VER_1_1_WITH_PEC
+ description: Version of Smart Battery.
+
+ vscale:
+ type: int
+ required: false
+ default: 0
+ description: Scaling of voltage.
+
+ ipscale:
+ type: int
+ required: false
+ default: 0
+ description: Scaling of current.
+
+ int-charge-controller:
+ type: boolean
+ description: Flag indicating if internal charge controller is supported.
+
+ primary-battery:
+ type: boolean
+ description:
+ Flag indicating if primary battery role selection is supported.
+
+ design-mv:
+ type: int
+ required: false
+ default: 5000
+ description: Design battery voltage in mV.
+
+ design-cap:
+ type: int
+ required: false
+ default: 5000
+ description: Design battery capacity in mAh.
+
+ temperature:
+ type: int
+ required: false
+ default: 2930
+ description: Battery temperature in 0.1 Kelvins.
+
+ volt:
+ type: int
+ required: false
+ default: 5000
+ description: Battery voltage in mV.
+
+ cur:
+ type: int
+ required: false
+ default: 1000
+ description: Current charging (> 0) or discharging (< 0) battery in mA.
+
+ avg-cur:
+ type: int
+ required: false
+ default: 1000
+ description: Average current from 1 minute.
+
+ max-error:
+ type: int
+ required: false
+ default: 0
+ description: Maximum error of commands return value in percent.
+
+ cap:
+ type: int
+ required: false
+ default: 2000
+ description: Capacity of the battery in mAh.
+
+ full-cap:
+ type: int
+ required: false
+ default: 4000
+ description: Full capacity of the battery in mAh.
+
+ desired-charg-cur:
+ type: int
+ required: false
+ default: 2000
+ description: Charging current requested by battery.
+
+ desired-charg-volt:
+ type: int
+ required: false
+ default: 7000
+ description: Charging voltage requested by battery.
+
+ cycle-count:
+ type: int
+ required: false
+ default: 125
+ description: Number of cycles.
+
+ serial-number:
+ type: int
+ required: false
+ default: 7
+ description: Serial number of battery.
+
+ mf-name:
+ type: string
+ required: false
+ default: "zephyr"
+ description: Manufacturer name. Length has to be smaller than 32 bytes.
+
+ dev-name:
+ type: string
+ required: false
+ default: "smartbat"
+ description: Device name. Length has to be smaller than 32 bytes.
+
+ dev-chem:
+ type: string
+ required: false
+ default: "LION"
+ description: Device chemistry. Length has to be smaller than 32 bytes.
+
+ mf-data:
+ type: string
+ required: false
+ default: "LION"
+ description: Manufacturer data. Length has to be smaller than 32 bytes.
+
+ mf-info:
+ type: string
+ required: false
+ default: "LION"
+ description: Manufacturer info. Length has to be smaller than 32 bytes.
diff --git a/zephyr/dts/bindings/emul/zephyr,smart-battery.yaml b/zephyr/dts/bindings/emul/zephyr,smart-battery.yaml
deleted file mode 100644
index 4c46fd4f64..0000000000
--- a/zephyr/dts/bindings/emul/zephyr,smart-battery.yaml
+++ /dev/null
@@ -1,161 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Zephyr Smart Battery Emulator
-
-compatible: "zephyr,smart-battery"
-
-include: base.yaml
-
-properties:
- mf-access:
- type: int
- required: false
- default: 0
- description: Word returned on manufacturer access command.
-
- at-rate-full-mw-support:
- type: boolean
- description:
- Flag indicating if AT_RATE_TIME_TO_FULL command supports mW capacity
- mode.
-
- version:
- type: string
- required: false
- enum:
- - BATTERY_SPEC_VER_1_0
- - BATTERY_SPEC_VER_1_1
- - BATTERY_SPEC_VER_1_1_WITH_PEC
- default: BATTERY_SPEC_VER_1_1_WITH_PEC
- description: Version of Smart Battery.
-
- vscale:
- type: int
- required: false
- default: 0
- description: Scaling of voltage.
-
- ipscale:
- type: int
- required: false
- default: 0
- description: Scaling of current.
-
- int-charge-controller:
- type: boolean
- description: Flag indicating if internal charge controller is supported.
-
- primary-battery:
- type: boolean
- description:
- Flag indicating if primary battery role selection is supported.
-
- design-mv:
- type: int
- required: false
- default: 5000
- description: Design battery voltage in mV.
-
- design-cap:
- type: int
- required: false
- default: 5000
- description: Design battery capacity in mAh.
-
- temperature:
- type: int
- required: false
- default: 2930
- description: Battery temperature in 0.1 Kelvins.
-
- volt:
- type: int
- required: false
- default: 5000
- description: Battery voltage in mV.
-
- cur:
- type: int
- required: false
- default: 1000
- description: Current charging (> 0) or discharging (< 0) battery in mA.
-
- avg-cur:
- type: int
- required: false
- default: 1000
- description: Average current from 1 minute.
-
- max-error:
- type: int
- required: false
- default: 0
- description: Maximum error of commands return value in percent.
-
- cap:
- type: int
- required: false
- default: 2000
- description: Capacity of the battery in mAh.
-
- full-cap:
- type: int
- required: false
- default: 4000
- description: Full capacity of the battery in mAh.
-
- desired-charg-cur:
- type: int
- required: false
- default: 2000
- description: Charging current requested by battery.
-
- desired-charg-volt:
- type: int
- required: false
- default: 7000
- description: Charging voltage requested by battery.
-
- cycle-count:
- type: int
- required: false
- default: 125
- description: Number of cycles.
-
- serial-number:
- type: int
- required: false
- default: 7
- description: Serial number of battery.
-
- mf-name:
- type: string
- required: false
- default: "zephyr"
- description: Manufacturer name. Length has to be smaller than 32 bytes.
-
- dev-name:
- type: string
- required: false
- default: "smartbat"
- description: Device name. Length has to be smaller than 32 bytes.
-
- dev-chem:
- type: string
- required: false
- default: "LION"
- description: Device chemistry. Length has to be smaller than 32 bytes.
-
- mf-data:
- type: string
- required: false
- default: "LION"
- description: Manufacturer data. Length has to be smaller than 32 bytes.
-
- mf-info:
- type: string
- required: false
- default: "LION"
- description: Manufacturer info. Length has to be smaller than 32 bytes.
diff --git a/zephyr/dts/bindings/emul/zephyr,tcs3400-emul.yaml b/zephyr/dts/bindings/emul/zephyr,tcs3400-emul.yaml
new file mode 100644
index 0000000000..8c33331b7a
--- /dev/null
+++ b/zephyr/dts/bindings/emul/zephyr,tcs3400-emul.yaml
@@ -0,0 +1,44 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+description: Zephyr ALS TCS3400 light sensor i2c emulator
+
+compatible: "zephyr,tcs3400-emul"
+
+include: base.yaml
+
+properties:
+ device-id:
+ type: string
+ required: false
+ enum:
+ - TCS340015_DEVICE_ID
+ - TCS340037_DEVICE_ID
+ default: TCS340015_DEVICE_ID
+ description: Device ID that is set in the register.
+
+ revision:
+ type: int
+ required: false
+ default: 0
+ description: Wafer die revision level that is set in the register.
+
+ error-on-ro-write:
+ type: boolean
+ description:
+ Flag indicating if error should be generated when read only register
+ is being written.
+
+ error-on-reserved-bit-write:
+ type: boolean
+ description:
+ Flag indicating if error should be generated when reserved bit
+ is being written.
+
+ error-on-msb-first-access:
+ type: boolean
+ description:
+ Flag indicating if error should be generated when MSB register of
+ accelerometer value is accessed before LSB and shadowing is enabled
+ at the same time.
diff --git a/zephyr/dts/bindings/emul/zephyr,tcs3400.yaml b/zephyr/dts/bindings/emul/zephyr,tcs3400.yaml
deleted file mode 100644
index f214a21064..0000000000
--- a/zephyr/dts/bindings/emul/zephyr,tcs3400.yaml
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Zephyr ALS TCS3400 light sensor i2c emulator
-
-compatible: "zephyr,tcs3400"
-
-include: base.yaml
-
-properties:
- device-id:
- type: string
- required: false
- enum:
- - TCS340015_DEVICE_ID
- - TCS340037_DEVICE_ID
- default: TCS340015_DEVICE_ID
- description: Device ID that is set in the register.
-
- revision:
- type: int
- required: false
- default: 0
- description: Wafer die revision level that is set in the register.
-
- error-on-ro-write:
- type: boolean
- description:
- Flag indicating if error should be generated when read only register
- is being written.
-
- error-on-reserved-bit-write:
- type: boolean
- description:
- Flag indicating if error should be generated when reserved bit
- is being written.
-
- error-on-msb-first-access:
- type: boolean
- description:
- Flag indicating if error should be generated when MSB register of
- accelerometer value is accessed before LSB and shadowing is enabled
- at the same time.
diff --git a/zephyr/dts/bindings/emul/zephyr,tusb1064.yaml b/zephyr/dts/bindings/emul/zephyr,tusb1064-emul.yaml
index 3cab1dd5a6..3cab1dd5a6 100644
--- a/zephyr/dts/bindings/emul/zephyr,tusb1064.yaml
+++ b/zephyr/dts/bindings/emul/zephyr,tusb1064-emul.yaml
diff --git a/zephyr/dts/bindings/fan/cros-ec,fan-steps.yaml b/zephyr/dts/bindings/fan/cros-ec,fan-steps.yaml
new file mode 100644
index 0000000000..3befe43868
--- /dev/null
+++ b/zephyr/dts/bindings/fan/cros-ec,fan-steps.yaml
@@ -0,0 +1,27 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+description: Fan steps parent node
+compatible: "cros-ec,fan-steps"
+child-binding:
+ description: Support multiple thermal sensor temperature to trigger different fans speed,
+ each step could have different rpm for each fan
+ properties:
+ temp_on:
+ required: false
+ type: array
+ description:
+ Temperatures for each sensor to trigger next fan level,
+ <sensor 0, sensor 1, sensor 2, ...> mapping to variant overlay
+ temp_off:
+ required: false
+ type: array
+ description:
+ Temperatures for each sensor to trigger previous fan level,
+ <sensor 0, sensor 1, sensor 2, ...> mapping to variant overlay
+ rpm_target:
+ required: false
+ type: array
+ description:
+ Support multiple fan speed target for each level (in RPM),
+ <fan0 rpm target, fan1 rpm target, ...>
diff --git a/zephyr/dts/bindings/fan/cros-ec,fans.yaml b/zephyr/dts/bindings/fan/cros-ec,fans.yaml
index 9aa6317f61..a9d198e37c 100644
--- a/zephyr/dts/bindings/fan/cros-ec,fans.yaml
+++ b/zephyr/dts/bindings/fan/cros-ec,fans.yaml
@@ -24,6 +24,12 @@ child-binding:
type: int
description:
Maximum fan speed (in RPM)
+ rpm_deviation:
+ required: false
+ default: 7
+ type: int
+ description:
+ Percentage of fan rpm deviation
pwms:
type: phandle-array
required: true
diff --git a/zephyr/dts/bindings/gpio/gpio-enum-name.yaml b/zephyr/dts/bindings/gpio/gpio-enum-name.yaml
index 8252ca75e1..5041b0646a 100644
--- a/zephyr/dts/bindings/gpio/gpio-enum-name.yaml
+++ b/zephyr/dts/bindings/gpio/gpio-enum-name.yaml
@@ -55,6 +55,7 @@ properties:
- GPIO_EN_USB_A_5V
- GPIO_IMVP9_VRRDY_OD
- GPIO_KB_DISCRETE_INT
+ - GPIO_KBD_KSO2
- GPIO_LID_ACCEL_INT_L
- GPIO_LID_OPEN
- GPIO_PACKET_MODE_EN
diff --git a/zephyr/dts/bindings/gpio/named-gpios.yaml b/zephyr/dts/bindings/gpio/named-gpios.yaml
index bf0ba7237e..7b92f1a636 100644
--- a/zephyr/dts/bindings/gpio/named-gpios.yaml
+++ b/zephyr/dts/bindings/gpio/named-gpios.yaml
@@ -15,9 +15,6 @@ child-binding:
gpios:
type: phandle-array
required: false
- "#led-pin-cells":
- type: int
- required: false
no-auto-init:
description:
When set, the GPIO is not initialised, and can be
@@ -36,5 +33,3 @@ child-binding:
to the particular board's GPIO name.
type: string
required: false
- led-pin-cells:
- - value
diff --git a/zephyr/dts/bindings/keyboard/cros-ec,keyscan.yaml b/zephyr/dts/bindings/keyboard/cros-ec,keyscan.yaml
new file mode 100644
index 0000000000..0e093bf015
--- /dev/null
+++ b/zephyr/dts/bindings/keyboard/cros-ec,keyscan.yaml
@@ -0,0 +1,82 @@
+ # Copyright 2021 The ChromiumOS Authors
+ # Use of this source code is governed by a BSD-style license that can be
+ # found in the LICENSE file.
+
+description: Keyboard scanning properties
+
+compatible: "cros-ec,keyscan"
+
+properties:
+ output-settle:
+ type: int
+ required: false
+ default: 80
+ description: |
+ Delay time, in microseconds, between setting up output and waiting for
+ it to settle. 80 microseconds is the recommended value when column 2
+ of the keyboard passes through the Google Security Chip. Otherwise 50
+ microseconds is the recommended value.
+
+ debounce-down:
+ type: int
+ required: false
+ default: 9000
+ description: |
+ Time, in microseconds, to debounce key-down.
+
+ debounce-up:
+ type: int
+ required: false
+ default: 30000
+ description: |
+ Time, in microseconds, to debounce key-up.
+
+ scan-period:
+ type: int
+ required: false
+ default: 3000
+ description: |
+ Time between scans when keyboard scan task runs in polling mode.
+
+ min-post-scan-delay:
+ type: int
+ required: false
+ default: 1000
+ description: |
+ Minimum time between end of one scan and start of the next one.
+ This ensures keyboard scanning doesn't starve the rest of the system
+ if the scan period is set too short, or if other higher-priority
+ system activity is starving the keyboard scan task too.
+
+ poll-timeout:
+ type: int
+ required: false
+ default: 100000
+ description: |
+ Revert to interrupt mode after no keyboard activity for this period.
+ Specified in microseconds.
+
+ actual-key-mask:
+ type: array
+ required: false
+ default: [
+ 0x1c, # C0
+ 0xff, # C1
+ 0xff, # C2
+ 0xff, # C3
+ 0xff, # C4
+ 0xf5, # C5
+ 0xff, # C6
+ 0xa4, # C7
+ 0xfe, # C8
+ 0x55, # C9
+ 0xfa, # C10
+ 0xff, # C11
+ 0xca, # C12
+ 0x00, # C13 for keypad
+ 0x00, # C14 for keypad
+ ]
+ description: |
+ Keyboard scanning mask. For each keyboard column, specify which
+ keyboard rows actually exist. Default key mask includes scanning for
+ full Chromebook keyboard, excluding the keypad.
diff --git a/zephyr/dts/bindings/keyboard/cros-keyscan.yaml b/zephyr/dts/bindings/keyboard/cros-keyscan.yaml
deleted file mode 100644
index a2ec2afc46..0000000000
--- a/zephyr/dts/bindings/keyboard/cros-keyscan.yaml
+++ /dev/null
@@ -1,82 +0,0 @@
- # Copyright 2021 The ChromiumOS Authors
- # Use of this source code is governed by a BSD-style license that can be
- # found in the LICENSE file.
-
-description: Keyboard scanning properties
-
-compatible: "cros-keyscan"
-
-properties:
- output-settle:
- type: int
- required: false
- default: 80
- description: |
- Delay time, in microseconds, between setting up output and waiting for
- it to settle. 80 microseconds is the recommended value when column 2
- of the keyboard passes through the Google Security Chip. Otherwise 50
- microseconds is the recommended value.
-
- debounce-down:
- type: int
- required: false
- default: 9000
- description: |
- Time, in microseconds, to debounce key-down.
-
- debounce-up:
- type: int
- required: false
- default: 30000
- description: |
- Time, in microseconds, to debounce key-up.
-
- scan-period:
- type: int
- required: false
- default: 3000
- description: |
- Time between scans when keyboard scan task runs in polling mode.
-
- min-post-scan-delay:
- type: int
- required: false
- default: 1000
- description: |
- Minimum time between end of one scan and start of the next one.
- This ensures keyboard scanning doesn't starve the rest of the system
- if the scan period is set too short, or if other higher-priority
- system activity is starving the keyboard scan task too.
-
- poll-timeout:
- type: int
- required: false
- default: 100000
- description: |
- Revert to interrupt mode after no keyboard activity for this period.
- Specified in microseconds.
-
- actual-key-mask:
- type: array
- required: false
- default: [
- 0x1c, # C0
- 0xff, # C1
- 0xff, # C2
- 0xff, # C3
- 0xff, # C4
- 0xf5, # C5
- 0xff, # C6
- 0xa4, # C7
- 0xfe, # C8
- 0x55, # C9
- 0xfa, # C10
- 0xff, # C11
- 0xca, # C12
- 0x00, # C13 for keypad
- 0x00, # C14 for keypad
- ]
- description: |
- Keyboard scanning mask. For each keyboard column, specify which
- keyboard rows actually exist. Default key mask includes scanning for
- full Chromebook keyboard, excluding the keypad.
diff --git a/zephyr/dts/bindings/led/maxim,max695x.yaml b/zephyr/dts/bindings/led/maxim,max695x.yaml
new file mode 100644
index 0000000000..a219512b0d
--- /dev/null
+++ b/zephyr/dts/bindings/led/maxim,max695x.yaml
@@ -0,0 +1,18 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+description: |
+ MAX6958/MAX6959 7-Segment LED Display
+
+ Example configuration
+
+ max695x@38 {
+ compatible = "maxim,max695x";
+ reg = <0x38>;
+ };
+
+
+compatible: "maxim,max695x"
+
+include: i2c-device.yaml
diff --git a/zephyr/dts/bindings/led/maxim,seven-seg-display.yaml b/zephyr/dts/bindings/led/maxim,seven-seg-display.yaml
deleted file mode 100644
index d66a0cdca2..0000000000
--- a/zephyr/dts/bindings/led/maxim,seven-seg-display.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: MAX6958/MAX6959 7-Segment LED Display
-
-compatible: "maxim,seven-seg-display"
-
-include: i2c-device.yaml
-
-#
-# examples:
-#
-# seven_seg_display: max695x-seven-seg-display@38 {
-# compatible = "maxim,seven-seg-display";
-# reg = <0x38>;
-# label = "MAX695X_SEVEN_SEG_DISPLAY";
-# };
-#
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 2e5fe7cff0..fbf4e5217c 100644
--- a/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml
+++ b/zephyr/dts/bindings/leds/cros-ec,gpio-led-pins.yaml
@@ -15,8 +15,8 @@ child-binding:
the LED and 0 always turns off the LED. So a node looks like
color-amber {
led-color = "LED_AMBER";
- led-pins = <&gpio_ec_chg_led_y_c1 1>,
- <&gpio_ec_chg_led_b_c1 0>;
+ led-pins = <&gpio_ec_chg_led_y_c1 gpio_ec_chg_led_b_c1>;
+ led-values = <1 0>;
};
properties:
led-color:
@@ -61,10 +61,15 @@ child-binding:
- EC_LED_COLOR_WHITE
- EC_LED_COLOR_AMBER
led-pins:
- type: phandle-array
+ type: phandles
required: true
description: |
- This property is used to specify an array of gpio pins and
- corresponding values to enable a particular color.
- e.g. Amber color - led-pins = <&gpio_ec_chg_led_y_c1 1>,
- <&gpio_ec_chg_led_b_c1 0>;
+ This property is used to specify an array of gpio pins to set a
+ particular color.
+
+ led-values:
+ type: array
+ required: true
+ description: |
+ This property is used to specify an array of values to set on the
+ corresponding led-pins to set a particular color.
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 19fee69be4..5ee8e112b5 100644
--- a/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml
+++ b/zephyr/dts/bindings/leds/cros-ec,pwm-led-pins.yaml
@@ -14,8 +14,8 @@ child-binding:
looks like this where 100 is PWM duty cycle in percentage.
color-amber {
led-color = "LED_AMBER";
- led-pins = <&pwm_led_y 100>,
- <&pwm_led_b 0>;
+ led-pwms = <&pwm_led_y &pwm_led_b>;
+ led-values = <100 0>;
};
properties:
led-color:
@@ -59,11 +59,16 @@ child-binding:
- EC_LED_COLOR_YELLOW
- EC_LED_COLOR_WHITE
- EC_LED_COLOR_AMBER
- led-pins:
- type: phandle-array
+ led-pwms:
+ type: phandles
required: true
description: |
- This property is used to specify an array of PWM pins and
- corresponding values to enable a particular color.
- e.g. Amber color - led-pins = <&pwm_led_y 100>,
- <&pwm_led_b 0>;
+ This property is used to specify an array of pwms to set a
+ particular color.
+
+ led-values:
+ type: array
+ required: true
+ description: |
+ This property is used to specify an array of values to set on the
+ corresponding pwm-pins to set a particular color.
diff --git a/zephyr/dts/bindings/leds/cros-ec,pwm-pin-config.yaml b/zephyr/dts/bindings/leds/cros-ec,pwm-pin-config.yaml
deleted file mode 100644
index bdef6b6144..0000000000
--- a/zephyr/dts/bindings/leds/cros-ec,pwm-pin-config.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: PWM LED pin configuration
-
-compatible: "cros-ec,pwm-pin-config"
-
-child-binding:
- description: PWMs associated with LEDs
- properties:
- pwms:
- type: phandle-array
- required: true
- "#led-pin-cells":
- type: int
- required: false
- led-pin-cells:
- - value
diff --git a/zephyr/dts/bindings/power/intel,ap-pwr-signal-emul.yaml b/zephyr/dts/bindings/power/intel,ap-pwr-signal-emul.yaml
new file mode 100644
index 0000000000..1863349892
--- /dev/null
+++ b/zephyr/dts/bindings/power/intel,ap-pwr-signal-emul.yaml
@@ -0,0 +1,124 @@
+ # Copyright 2022 The ChromiumOS Authors
+ # Use of this source code is governed by a BSD-style license that can be
+ # found in the LICENSE file.
+
+description: |
+ Power Signal Emulator Node
+
+ Power signal emulator allows executing AP Power Sequence in a virtual
+ environment by simulating power signals behavior.
+
+ This file defines a node to bind two or more power signals. A node connects
+ one input-signal with one or more output-signals. When a node is loaded and
+ initialized by power signal emulator, its input-signal state will control
+ the value of its children output-signals. Behavior of output-signals are
+ configurable to meet AP power sequence test cases.
+
+ Power Signals direction is determined from emulator node perspective. An input
+ signal in a node, is the one to be monitored by the emulator, while an output
+ signal gets its value altered when corresponding input signal's state changes.
+
+compatible: "intel,ap-pwr-signal-emul"
+
+properties:
+ input-signal:
+ type: phandle
+ required: true
+ description: |
+ Input signal whose value is monitored to control children output-signal`s
+ value.
+
+ assert-value:
+ type: int
+ required: false
+ default: 1
+ description: |
+ Value that indicates `input-signal` must be ASSERTED.
+
+ A power signal state can be ASSERTED or DEASSERTED.`input-signal` is only
+ considered asserted if its new value is equal to `assert-value`, any
+ other value makes it deasserted.
+
+ edge:
+ type: string
+ required: false
+ description: |
+ Controls when to trigger children value change, based on `input-signal`
+ new state.
+
+ EDGE_ACTIVE_ON_ASSERT: Children value changes only when `input-signal`
+ state changes into asserted.
+
+ EDGE_ACTIVE_ON_DEASSERT: Children value changes only when `input-signal`
+ state changes into deasserted.
+
+ EDGE_ACTIVE_ON_DEASSERT: Children value changes everytime `input-signal`
+ state changes.
+
+ default: EDGE_ACTIVE_ON_BOTH
+ enum:
+ - EDGE_ACTIVE_ON_ASSERT
+ - EDGE_ACTIVE_ON_DEASSERT
+ - EDGE_ACTIVE_ON_BOTH
+
+ init-value:
+ type: int
+ required: false
+ description: |
+ Initial value of `input-signal`.
+
+child-binding:
+ description: |
+ Child power signals configuration.
+
+ properties:
+ output-signal:
+ type: phandle
+ required: true
+ description: |
+ Output signal whose value will be controlled by parent `input-signal`
+ state.
+
+ assert-value:
+ type: int
+ required: false
+ default: 1
+ description: |
+ Value that will be assigned to this signal when parent `input-signal`
+ state is asserted.
+
+ assert-delay-ms:
+ type: int
+ required: false
+ default: 10
+ description: |
+ Milliseconds to delay setting this signal to its `assert-value`
+ after `input-signal` is asserted.
+
+ deassert-value:
+ type: int
+ required: false
+ default: 0
+ description: |
+ Value that will be assigned to this signal when parent `input-signal`
+ state is deasserted.
+
+ deassert-delay-ms:
+ type: int
+ required: false
+ default: 10
+ description: |
+ Milliseconds to delay setting this signal to its `deassert-value`
+ after `input-signal` is deasserted.
+
+ init-value:
+ type: int
+ required: false
+ description: |
+ Value set to this power signal when initializing this node.
+
+ invert-value:
+ type: boolean
+ description: |
+ Invert this power signal assertion logic, this applies to both values
+ and delays.
diff --git a/zephyr/dts/bindings/power/intel,ap-pwr-test-platform.yaml b/zephyr/dts/bindings/power/intel,ap-pwr-test-platform.yaml
new file mode 100644
index 0000000000..c2f7e10cd1
--- /dev/null
+++ b/zephyr/dts/bindings/power/intel,ap-pwr-test-platform.yaml
@@ -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.
+
+description: |
+ Power Signal Test Platform
+
+ This is a virtual representation of platform comprised of one or more power
+ signal emulator nodes. Test platform is loaded into power signal emulator.
+
+compatible: "intel,ap-pwr-test-platform"
+
+properties:
+ nodes:
+ type: phandles
+ required: true
+ description: |
+ phandle array of power signals nodes to be run by emulator.
diff --git a/zephyr/dts/bindings/switchcap/cros-ec,switchcap-gpio.yaml b/zephyr/dts/bindings/switchcap/cros-ec,switchcap-gpio.yaml
new file mode 100644
index 0000000000..344738c8c0
--- /dev/null
+++ b/zephyr/dts/bindings/switchcap/cros-ec,switchcap-gpio.yaml
@@ -0,0 +1,22 @@
+description: SwitchCap controlled by gpios
+
+compatible: "cros-ec,switchcap-gpio"
+
+properties:
+ enable-pin:
+ type: phandle
+ required: true
+ description: |
+ GPIO used to enable the switch cap
+
+ power-good-pin:
+ type: phandle
+ required: false
+ description: |
+ GPIO used to read if power is good
+
+ poff-delay-ms:
+ type: int
+ required: false
+ description: |
+ Additional power off delay required for some systems
diff --git a/zephyr/dts/bindings/switchcap/lion,ln9310.yaml b/zephyr/dts/bindings/switchcap/lion,ln9310.yaml
new file mode 100644
index 0000000000..c1c4a99bee
--- /dev/null
+++ b/zephyr/dts/bindings/switchcap/lion,ln9310.yaml
@@ -0,0 +1,28 @@
+description: SwitchCap controlled by Lion Semiconductor LN9310
+
+compatible: "lion,ln9310"
+
+properties:
+ enable-pin:
+ type: phandle
+ required: true
+ description: |
+ GPIO used to enable the switch cap. Relies on
+ GPIO flags to determine active low or high.
+
+ port:
+ type: phandle
+ required: true
+ description: |
+ I2C port used to communicate with controller
+
+ addr-flags:
+ type: string
+ default: "LN9310_I2C_ADDR_0_FLAGS"
+ enum:
+ - "LN9310_I2C_ADDR_0_FLAGS"
+ - "LN9310_I2C_ADDR_1_FLAGS"
+ - "LN9310_I2C_ADDR_2_FLAGS"
+ - "LN9310_I2C_ADDR_3_FLAGS"
+ description: |
+ I2C address of controller
diff --git a/zephyr/dts/bindings/switchcap/switchcap-gpio.yaml b/zephyr/dts/bindings/switchcap/switchcap-gpio.yaml
deleted file mode 100644
index 0016401835..0000000000
--- a/zephyr/dts/bindings/switchcap/switchcap-gpio.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
-description: SwitchCap controlled by gpios
-
-compatible: "switchcap-gpio"
-
-properties:
- enable-pin:
- type: phandle
- required: true
- description: |
- GPIO used to enable the switch cap
-
- power-good-pin:
- type: phandle
- required: false
- description: |
- GPIO used to read if power is good
-
- poff-delay-ms:
- type: int
- required: false
- description: |
- Additional power off delay required for some systems
diff --git a/zephyr/dts/bindings/switchcap/switchcap-ln9310.yaml b/zephyr/dts/bindings/switchcap/switchcap-ln9310.yaml
deleted file mode 100644
index 2a73325cd3..0000000000
--- a/zephyr/dts/bindings/switchcap/switchcap-ln9310.yaml
+++ /dev/null
@@ -1,28 +0,0 @@
-description: SwitchCap controlled by LN9310
-
-compatible: "switchcap-ln9310"
-
-properties:
- enable-pin:
- type: phandle
- required: true
- description: |
- GPIO used to enable the switch cap. Relies on
- GPIO flags to determine active low or high.
-
- port:
- type: phandle
- required: true
- description: |
- I2C port used to communicate with controller
-
- addr-flags:
- type: string
- default: "LN9310_I2C_ADDR_0_FLAGS"
- enum:
- - "LN9310_I2C_ADDR_0_FLAGS"
- - "LN9310_I2C_ADDR_1_FLAGS"
- - "LN9310_I2C_ADDR_2_FLAGS"
- - "LN9310_I2C_ADDR_3_FLAGS"
- description: |
- I2C address of controller
diff --git a/zephyr/dts/bindings/usbc/bc12/richtek,rt9490-bc12.yaml b/zephyr/dts/bindings/usbc/bc12/richtek,rt9490-bc12.yaml
deleted file mode 100644
index 38791d65bf..0000000000
--- a/zephyr/dts/bindings/usbc/bc12/richtek,rt9490-bc12.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: USBC BC1.2
-
-compatible: "richtek,rt9490-bc12"
-
-include: base.yaml
-
-properties:
- irq:
- type: phandles
- description: |
- GPIO interrupt from BC1.2
diff --git a/zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml b/zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml
new file mode 100644
index 0000000000..f8dd9807ed
--- /dev/null
+++ b/zephyr/dts/bindings/usbc/tcpc/renesas,raa489000.yaml
@@ -0,0 +1,16 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+description: Renesas RAA489000 USB TCPC binding
+
+compatible: "renesas,raa489000"
+
+include: i2c-device.yaml
+
+properties:
+ tcpc-flags:
+ type: int
+ default: 0
+ description: |
+ TCPC configuration flags
diff --git a/zephyr/dts/board-overlays/native_posix.dts b/zephyr/dts/board-overlays/native_posix.dts
index 44a034d73b..c8bfe02539 100644
--- a/zephyr/dts/board-overlays/native_posix.dts
+++ b/zephyr/dts/board-overlays/native_posix.dts
@@ -4,6 +4,9 @@
*/
#include <dt-bindings/gpio_defines.h>
+#include <dt-bindings/native-posix-gpio.h>
+
+#define GPIO_VOLTAGE_1P8 NATIVE_POSIX_GPIO_VOLTAGE_1P8
/ {
named-gpios {
diff --git a/zephyr/dts/it8xxx2_emul.dts b/zephyr/dts/it8xxx2_emul.dts
index b22251b67b..5f517b0c1b 100644
--- a/zephyr/dts/it8xxx2_emul.dts
+++ b/zephyr/dts/it8xxx2_emul.dts
@@ -8,6 +8,9 @@
*/
#include <dt-bindings/gpio_defines.h>
+#include <dt-bindings/native-posix-gpio.h>
+
+#define GPIO_VOLTAGE_1P8 NATIVE_POSIX_GPIO_VOLTAGE_1P8
/ {
gpioa: gpio@f01601 {
@@ -182,4 +185,11 @@
#size-cells = <0>;
reg = <0x00f03500 0x0080>;
};
+
+ adc0: adc {
+ compatible = "zephyr,adc-emul";
+ nchannels = <6>;
+ ref-internal-mv = <3300>;
+ #io-channel-cells = <1>;
+ };
};
diff --git a/zephyr/emul/CMakeLists.txt b/zephyr/emul/CMakeLists.txt
index 377be11792..3d268dde80 100644
--- a/zephyr/emul/CMakeLists.txt
+++ b/zephyr/emul/CMakeLists.txt
@@ -26,5 +26,6 @@ zephyr_library_sources_ifdef(CONFIG_EMUL_CROS_FLASH emul_flash.c)
zephyr_library_sources_ifdef(CONFIG_EMUL_RTC emul_rtc.c)
zephyr_library_sources_ifdef(CONFIG_EMUL_RT9490 emul_rt9490.c)
zephyr_library_sources_ifdef(CONFIG_PWM_MOCK pwm_mock.c)
+zephyr_library_sources_ifdef(CONFIG_EMUL_PCT2075 emul_pct2075.c)
cros_ec_library_include_directories_ifdef(CONFIG_EMUL_CROS_FLASH include)
diff --git a/zephyr/emul/Kconfig b/zephyr/emul/Kconfig
index e445e30154..44d53179c3 100644
--- a/zephyr/emul/Kconfig
+++ b/zephyr/emul/Kconfig
@@ -13,12 +13,16 @@ config EMUL_COMMON_I2C
config EMUL_SMART_BATTERY
bool "Smart Battery emulator"
+ default y
+ depends on DT_HAS_ZEPHYR_SMART_BATTERY_EMUL_ENABLED
select EMUL_COMMON_I2C
help
Enable the Smart Battery emulator. This driver use emulated I2C bus.
config EMUL_BMA255
bool "BMA255 emulator"
+ default y
+ depends on DT_HAS_ZEPHYR_BMA255_EMUL_ENABLED
select EMUL_COMMON_I2C
help
Enable the BMA255 emulator. This driver use emulated I2C bus.
@@ -27,6 +31,8 @@ config EMUL_BMA255
config EMUL_BC12_DETECT_PI3USB9201
bool "PI3USB9201 emulator"
+ default y
+ depends on ZTEST && DT_HAS_PERICOM_PI3USB9201_ENABLED
help
Enable the PI3USB9201 emulator. PI3USB9201 is a BC1.2 charger
detector/advertiser. The emulator supports reading and writing the
@@ -34,6 +40,8 @@ config EMUL_BC12_DETECT_PI3USB9201
config EMUL_PPC_SYV682X
bool "Silergy SYV682x PPC emulator"
+ default y
+ depends on DT_HAS_ZEPHYR_SYV682X_EMUL_ENABLED
select PLATFORM_EC_USBC_PPC_SYV682X
help
Enable the SYV682x emulator. SYV682 is a USB Type-C PPC. This driver
@@ -41,6 +49,8 @@ config EMUL_PPC_SYV682X
config EMUL_BMI
bool "BMI emulator"
+ default y
+ depends on DT_HAS_ZEPHYR_BMI_EMUL_ENABLED
select EMUL_COMMON_I2C
help
Enable the BMI emulator. This driver use emulated I2C bus.
@@ -49,6 +59,8 @@ config EMUL_BMI
config EMUL_TCS3400
bool "TCS3400 emulator"
+ default y
+ depends on DT_HAS_ZEPHYR_TCS3400_EMUL_ENABLED
select EMUL_COMMON_I2C
help
Enable the TCS3400 light sensor. This driver use emulated I2C bus.
@@ -62,6 +74,8 @@ config EMUL_TCS3400
config EMUL_TUSB1064
bool "TCS3400 emulator"
+ default y
+ depends on DT_HAS_ZEPHYR_TUSB1064_EMUL_ENABLED
select EMUL_COMMON_I2C
help
Enable the TUSB1064 usb mux. This driver use emulated I2C bus.
@@ -69,6 +83,8 @@ config EMUL_TUSB1064
config EMUL_BB_RETIMER
bool "BB retimer emulator"
+ default y
+ depends on ZTEST && DT_HAS_INTEL_JHL8040R_ENABLED
select EMUL_COMMON_I2C
help
Enable the BB (Burnside Bridge) retimer emulator. This driver use
@@ -78,11 +94,15 @@ config EMUL_BB_RETIMER
config EMUL_KB_RAW
bool "Raw keyboard emulator"
+ default y
+ depends on DT_HAS_CROS_EC_KB_RAW_EMUL_ENABLED
help
Enable the raw keyboard emulator.
config EMUL_CROS_FLASH
bool "Emulated flash driver for the Zephyr shim"
+ default y
+ depends on DT_HAS_CROS_EC_FLASH_EMUL_ENABLED
select PLATFORM_EC_FLASH_CROS
imply SYSTEM_FAKE
help
@@ -90,11 +110,15 @@ config EMUL_CROS_FLASH
config EMUL_RTC
bool "Emulated RTC driver for Zephyr shim"
+ default y
+ depends on DT_HAS_CROS_EC_RTC_EMUL_ENABLED
help
This options enables the RTC emulator for testing.
config EMUL_RT9490
bool "Rt9490 charger emulator"
+ default y
+ depends on DT_HAS_ZEPHYR_RT9490_EMUL_ENABLED
select EMUL_COMMON_I2C
help
Enable the RT9490 light sensor emulator. This driver use emulated I2C
@@ -102,10 +126,21 @@ config EMUL_RT9490
config PWM_MOCK
bool "Mock implementation of an PWM device"
+ default y
+ depends on DT_HAS_CROS_PWM_MOCK_ENABLED
help
Enable the PWM mock. This driver is a pure mock and does nothing by
default.
+config EMUL_PCT2075
+ bool "PCT2075 emulator"
+ default y
+ depends on ZTEST && DT_HAS_NXP_PCT2075_ENABLED
+ select EMUL_COMMON_I2C
+ help
+ Enable the PCT2075 temperature sensor emulator. It uses emulated I2C bus.
+ Emulator API is available in zephyr/include/emul/emul_pct2075.h.
+
rsource "Kconfig.ln9310"
rsource "Kconfig.lis2dw12"
rsource "Kconfig.i2c_mock"
diff --git a/zephyr/emul/emul_bb_retimer.c b/zephyr/emul/emul_bb_retimer.c
index 266fd1a340..8028c53c0f 100644
--- a/zephyr/emul/emul_bb_retimer.c
+++ b/zephyr/emul/emul_bb_retimer.c
@@ -3,22 +3,21 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_bb_retimer_emul
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(emul_bb_retimer);
+#include "driver/retimer/bb_retimer.h"
+#include "emul/emul_bb_retimer.h"
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_stub_device.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_bb_retimer.h"
-#include "emul/emul_stub_device.h"
+#define DT_DRV_COMPAT intel_jhl8040r
-#include "driver/retimer/bb_retimer.h"
+#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
+LOG_MODULE_REGISTER(emul_bb_retimer);
/** Run-time data used by the emulator */
struct bb_emul_data {
@@ -309,10 +308,9 @@ static int bb_emul_init(const struct emul *emul, const struct device *parent)
#define BB_RETIMER_EMUL(n) \
static struct bb_emul_data bb_emul_data_##n = { \
- .vendor_id = DT_STRING_TOKEN(DT_DRV_INST(n), vendor), \
- .error_on_ro_write = DT_INST_PROP(n, error_on_ro_write),\
- .error_on_rsvd_write = DT_INST_PROP(n, \
- error_on_reserved_bit_write), \
+ .vendor_id = BB_RETIMER_VENDOR_ID_1, \
+ .error_on_ro_write = true, \
+ .error_on_rsvd_write = true, \
.common = { \
.start_write = NULL, \
.write_byte = bb_emul_write_byte, \
diff --git a/zephyr/emul/emul_bma255.c b/zephyr/emul/emul_bma255.c
index a57c8fbdbb..2afe1f722e 100644
--- a/zephyr/emul/emul_bma255.c
+++ b/zephyr/emul/emul_bma255.c
@@ -3,22 +3,21 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT zephyr_bma255
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(emul_bma255);
+#include "driver/accel_bma2x2.h"
+#include "emul/emul_bma255.h"
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_stub_device.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_bma255.h"
+#define DT_DRV_COMPAT zephyr_bma255_emul
-#include "driver/accel_bma2x2.h"
-#include "emul/emul_stub_device.h"
+#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
+LOG_MODULE_REGISTER(emul_bma255);
/** Run-time data used by the emulator */
struct bma_emul_data {
diff --git a/zephyr/emul/emul_bmi.c b/zephyr/emul/emul_bmi.c
index fe46428f01..d0f5691402 100644
--- a/zephyr/emul/emul_bmi.c
+++ b/zephyr/emul/emul_bmi.c
@@ -3,25 +3,24 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT zephyr_bmi
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(emul_bmi);
+#include "driver/accelgyro_bmi160.h"
+#include "driver/accelgyro_bmi260.h"
+#include "driver/accelgyro_bmi_common.h"
+#include "emul/emul_bmi.h"
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_stub_device.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
#include <zephyr/sys/__assert.h>
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_bmi.h"
-#include "emul/emul_stub_device.h"
+#define DT_DRV_COMPAT zephyr_bmi_emul
-#include "driver/accelgyro_bmi160.h"
-#include "driver/accelgyro_bmi260.h"
-#include "driver/accelgyro_bmi_common.h"
+#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
+LOG_MODULE_REGISTER(emul_bmi);
/** Run-time data used by the emulator */
struct bmi_emul_data {
diff --git a/zephyr/emul/emul_bmi160.c b/zephyr/emul/emul_bmi160.c
index c1d6b58a8f..8b3042e2ff 100644
--- a/zephyr/emul/emul_bmi160.c
+++ b/zephyr/emul/emul_bmi160.c
@@ -3,21 +3,20 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT zephyr_bmi
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(emul_bmi160);
+#include "driver/accelgyro_bmi160.h"
+#include "driver/accelgyro_bmi_common.h"
+#include "emul/emul_bmi.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
-#include "emul/emul_bmi.h"
+#define DT_DRV_COMPAT zephyr_bmi_emul
-#include "driver/accelgyro_bmi160.h"
-#include "driver/accelgyro_bmi_common.h"
+#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
+LOG_MODULE_REGISTER(emul_bmi160);
/** Mask reserved bits in each register of BMI160 */
static const uint8_t bmi_emul_160_rsvd_mask[] = {
diff --git a/zephyr/emul/emul_bmi260.c b/zephyr/emul/emul_bmi260.c
index 5892a9ae96..d62b51ebfa 100644
--- a/zephyr/emul/emul_bmi260.c
+++ b/zephyr/emul/emul_bmi260.c
@@ -3,21 +3,20 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT zephyr_bmi
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(emul_bmi260);
+#include "driver/accelgyro_bmi260.h"
+#include "driver/accelgyro_bmi_common.h"
+#include "emul/emul_bmi.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
-#include "emul/emul_bmi.h"
+#define DT_DRV_COMPAT zephyr_bmi_emul
-#include "driver/accelgyro_bmi260.h"
-#include "driver/accelgyro_bmi_common.h"
+#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
+LOG_MODULE_REGISTER(emul_bmi260);
/** Mask reserved bits in each register of BMI260 */
static const uint8_t bmi_emul_260_rsvd_mask[] = {
diff --git a/zephyr/emul/emul_clock_control.c b/zephyr/emul/emul_clock_control.c
index 561298a705..e4223a5b43 100644
--- a/zephyr/emul/emul_clock_control.c
+++ b/zephyr/emul/emul_clock_control.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_clock_control_emul
+#include "common.h"
+#include "emul/emul_clock_control.h"
#include <zephyr/device.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
-#include "common.h"
-#include "emul/emul_clock_control.h"
+#define DT_DRV_COMPAT cros_clock_control_emul
-#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(clock_control_emul, CONFIG_CLOCK_CONTROL_EMUL_LOG_LEVEL);
/** Data needed to maintain the current emulator state */
diff --git a/zephyr/emul/emul_common_i2c.c b/zephyr/emul/emul_common_i2c.c
index 70bc962c5f..327188cb48 100644
--- a/zephyr/emul/emul_common_i2c.c
+++ b/zephyr/emul/emul_common_i2c.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(emul_common_i2c);
+#include "emul/emul_common_i2c.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
-#include "emul/emul_common_i2c.h"
+#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
+LOG_MODULE_REGISTER(emul_common_i2c);
/** Check description in emul_common_i2c.h */
int i2c_common_emul_lock_data(struct i2c_common_emul_data *common_data,
@@ -172,16 +172,6 @@ static int i2c_common_emul_write_byte(const struct emul *target,
{
int reg, ret;
- /* Custom user handler */
- if (data->write_func) {
- ret = data->write_func(target, data->cur_reg, val,
- data->msg_byte, data->write_func_data);
- if (ret < 0) {
- return -EIO;
- } else if (ret == 0) {
- return 0;
- }
- }
/* Check if user wants to fail on accessed register */
if (data->access_reg) {
reg = data->access_reg(target, data->cur_reg, data->msg_byte,
@@ -195,6 +185,18 @@ static int i2c_common_emul_write_byte(const struct emul *target,
data->write_fail_reg == I2C_COMMON_EMUL_FAIL_ALL_REG) {
return -EIO;
}
+
+ /* Custom user handler */
+ if (data->write_func) {
+ ret = data->write_func(target, data->cur_reg, val,
+ data->msg_byte, data->write_func_data);
+ if (ret < 0) {
+ return -EIO;
+ } else if (ret == 0) {
+ return 0;
+ }
+ }
+
/* Emulator handler */
if (data->write_byte) {
k_mutex_lock(&data->data_mtx, K_FOREVER);
@@ -228,16 +230,6 @@ static int i2c_common_emul_read_byte(const struct emul *target,
{
int reg, ret;
- /* Custom user handler */
- if (data->read_func) {
- ret = data->read_func(target, data->cur_reg, val,
- data->msg_byte, data->read_func_data);
- if (ret < 0) {
- return -EIO;
- } else if (ret == 0) {
- return 0;
- }
- }
/* Check if user wants to fail on accessed register */
if (data->access_reg) {
reg = data->access_reg(target, data->cur_reg, data->msg_byte,
@@ -250,6 +242,18 @@ static int i2c_common_emul_read_byte(const struct emul *target,
data->read_fail_reg == I2C_COMMON_EMUL_FAIL_ALL_REG) {
return -EIO;
}
+
+ /* Custom user handler */
+ if (data->read_func) {
+ ret = data->read_func(target, data->cur_reg, val,
+ data->msg_byte, data->read_func_data);
+ if (ret < 0) {
+ return -EIO;
+ } else if (ret == 0) {
+ return 0;
+ }
+ }
+
/* Emulator handler */
if (data->read_byte) {
k_mutex_lock(&data->data_mtx, K_FOREVER);
diff --git a/zephyr/emul/emul_flash.c b/zephyr/emul/emul_flash.c
index 0efc690fd4..936ee5470c 100644
--- a/zephyr/emul/emul_flash.c
+++ b/zephyr/emul/emul_flash.c
@@ -3,19 +3,19 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_ec_flash_emul
-
-#include <zephyr/drivers/flash.h>
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(emul_flash);
+#include "drivers/cros_flash.h"
+#include "ec_commands.h"
+#include "flash.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
-#include <ec_commands.h>
-#include <drivers/cros_flash.h>
+#include <zephyr/drivers/flash.h>
+#include <zephyr/logging/log.h>
#include <zephyr/sys/__assert.h>
-#include "flash.h"
+#define DT_DRV_COMPAT cros_ec_flash_emul
+
+LOG_MODULE_REGISTER(emul_flash);
struct flash_emul_data {
const struct device *flash_dev;
diff --git a/zephyr/emul/emul_isl923x.c b/zephyr/emul/emul_isl923x.c
index 1ecb9e79f9..d46f1131d4 100644
--- a/zephyr/emul/emul_isl923x.c
+++ b/zephyr/emul/emul_isl923x.c
@@ -3,25 +3,26 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_isl923x_emul
-
-#include <zephyr/device.h>
-#include <zephyr/drivers/i2c.h>
-#include <zephyr/drivers/i2c_emul.h>
-#include <zephyr/drivers/emul.h>
-#include <errno.h>
-#include <zephyr/sys/__assert.h>
-#include <zephyr/ztest.h>
-
#include "driver/charger/isl923x.h"
#include "driver/charger/isl923x_public.h"
#include "emul/emul_common_i2c.h"
#include "emul/emul_isl923x.h"
#include "emul/emul_smart_battery.h"
-#include "i2c.h"
#include "emul/emul_stub_device.h"
+#include "i2c.h"
+#include <errno.h>
+
+#include <zephyr/device.h>
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/i2c.h>
+#include <zephyr/drivers/i2c_emul.h>
#include <zephyr/logging/log.h>
+#include <zephyr/sys/__assert.h>
+#include <zephyr/ztest.h>
+
+#define DT_DRV_COMPAT cros_isl923x_emul
+
LOG_MODULE_REGISTER(isl923x_emul, CONFIG_ISL923X_EMUL_LOG_LEVEL);
/** Mask used for the charge current register */
diff --git a/zephyr/emul/emul_kb_raw.c b/zephyr/emul/emul_kb_raw.c
index 1fdd93d1a0..2e8cdbdd7d 100644
--- a/zephyr/emul/emul_kb_raw.c
+++ b/zephyr/emul/emul_kb_raw.c
@@ -3,16 +3,17 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_ec_kb_raw_emul
-
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(emul_kb_raw);
-
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
+#include <zephyr/logging/log.h>
+
#include <drivers/cros_kb_raw.h>
#include <keyboard_raw.h>
+#define DT_DRV_COMPAT cros_ec_kb_raw_emul
+
+LOG_MODULE_REGISTER(emul_kb_raw);
+
struct kb_raw_emul_data {
int active_column;
int *matrix;
diff --git a/zephyr/emul/emul_lis2dw12.c b/zephyr/emul/emul_lis2dw12.c
index bdc4b50358..547e74912c 100644
--- a/zephyr/emul/emul_lis2dw12.c
+++ b/zephyr/emul/emul_lis2dw12.c
@@ -3,22 +3,23 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_lis2dw12_emul
+#include "driver/accel_lis2dw12.h"
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_lis2dw12.h"
+#include "emul/emul_stub_device.h"
+#include "i2c.h"
+
+#include <errno.h>
#include <zephyr/device.h>
+#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
-#include <zephyr/drivers/emul.h>
-#include <errno.h>
+#include <zephyr/logging/log.h>
#include <zephyr/sys/__assert.h>
-#include "driver/accel_lis2dw12.h"
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_lis2dw12.h"
-#include "i2c.h"
-#include "emul/emul_stub_device.h"
+#define DT_DRV_COMPAT cros_lis2dw12_emul
-#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(lis2dw12_emul, CONFIG_LIS2DW12_EMUL_LOG_LEVEL);
struct lis2dw12_emul_data {
diff --git a/zephyr/emul/emul_ln9310.c b/zephyr/emul/emul_ln9310.c
index bd6d41bce3..9d6a0197a0 100644
--- a/zephyr/emul/emul_ln9310.c
+++ b/zephyr/emul/emul_ln9310.c
@@ -3,9 +3,15 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_ln9310_emul
+#include "driver/ln9310.h"
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_ln9310.h"
+#include "emul/emul_stub_device.h"
+#include "hooks.h"
+#include "i2c.h"
#include <errno.h>
+
#include <zephyr/device.h>
#include <zephyr/devicetree/gpio.h>
#include <zephyr/drivers/emul.h>
@@ -13,16 +19,11 @@
#include <zephyr/drivers/gpio/gpio_emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
#include <zephyr/sys/__assert.h>
-#include "driver/ln9310.h"
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_ln9310.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "emul/emul_stub_device.h"
+#define DT_DRV_COMPAT cros_ln9310_emul
-#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(ln9310_emul, CONFIG_LN9310_EMUL_LOG_LEVEL);
enum functional_mode {
diff --git a/zephyr/emul/emul_pct2075.c b/zephyr/emul/emul_pct2075.c
new file mode 100644
index 0000000000..cfd172b6dc
--- /dev/null
+++ b/zephyr/emul/emul_pct2075.c
@@ -0,0 +1,107 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "driver/temp_sensor/pct2075.h"
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_pct2075.h"
+#include "emul/emul_stub_device.h"
+#include "util.h"
+
+#include <zephyr/device.h>
+
+/* NOTE: The emulator doesn't support OS pin */
+
+#define DT_DRV_COMPAT nxp_pct2075
+
+#define PCT2075_TEMP_MAX_MC 127000
+#define PCT2075_TEMP_MIN_MC -55000
+#define PCT2075_RESOLUTION_MC 125
+
+static const uint16_t default_values[PCT2075_REG_NUMBER] = {
+ [PCT2075_REG_TEMP] = 0x00, [PCT2075_REG_CONF] = 0x00,
+ [PCT2075_REG_THYST] = 0x4b00, [PCT2075_REG_TOS] = 0x5000,
+ [PCT2075_REG_TIDLE] = 0x00,
+};
+
+void pct2075_emul_reset_regs(const struct emul *emul)
+{
+ struct pct2075_data *data = (struct pct2075_data *)emul->data;
+
+ memcpy(data->regs, default_values, PCT2075_REG_NUMBER + 1);
+}
+
+int pct2075_emul_set_temp(const struct emul *emul, int mk)
+{
+ struct pct2075_data *data = (struct pct2075_data *)emul->data;
+ int mc = MILLI_KELVIN_TO_MILLI_CELSIUS(mk);
+ int reg;
+
+ if (!IN_RANGE(mc, PCT2075_TEMP_MIN_MC, PCT2075_TEMP_MAX_MC)) {
+ return -1;
+ }
+
+ /* Divide by the sensor resolution to get register value */
+ reg = mc / PCT2075_RESOLUTION_MC;
+
+ /* Use 11 most significant bits. */
+ data->regs[PCT2075_REG_TEMP] = reg << 5;
+
+ return 0;
+}
+
+int pct2075_emul_read_byte(const struct emul *target, int reg, uint8_t *val,
+ int bytes)
+{
+ struct pct2075_data *data = (struct pct2075_data *)target->data;
+
+ if (!IN_RANGE(reg, 0, PCT2075_REG_NUMBER - 1)) {
+ return -1;
+ }
+
+ if (bytes == 0) {
+ *val = data->regs[reg] >> 8;
+ } else if (bytes == 1) {
+ *val = data->regs[reg] & 0x00FF;
+ } else {
+ /* Support up to 2 bytes read */
+ return -1;
+ }
+
+ return 0;
+}
+
+static int pct2075_emul_init(const struct emul *emul,
+ const struct device *parent)
+{
+ struct pct2075_data *data = (struct pct2075_data *)emul->data;
+ struct i2c_common_emul_data *common_data = &data->common;
+
+ i2c_common_emul_init(common_data);
+
+ pct2075_emul_reset_regs(emul);
+
+ return 0;
+}
+
+#define INIT_PCT2075_EMUL(n) \
+ static struct i2c_common_emul_cfg common_cfg_##n; \
+ static struct pct2075_data pct2075_data_##n; \
+ static struct i2c_common_emul_cfg common_cfg_##n = { \
+ .dev_label = DT_NODE_FULL_NAME(DT_DRV_INST(n)), \
+ .data = &pct2075_data_##n.common, \
+ .addr = DT_INST_REG_ADDR(n) \
+ }; \
+ static struct pct2075_data pct2075_data_##n = { \
+ .common = { \
+ .cfg = &common_cfg_##n, \
+ .read_byte = pct2075_emul_read_byte, \
+ }, \
+ }; \
+ EMUL_DT_INST_DEFINE(n, pct2075_emul_init, &pct2075_data_##n, \
+ &common_cfg_##n, &i2c_common_emul_api)
+
+DT_INST_FOREACH_STATUS_OKAY(INIT_PCT2075_EMUL)
+
+DT_INST_FOREACH_STATUS_OKAY(EMUL_STUB_DEVICE);
diff --git a/zephyr/emul/emul_pi3usb9201.c b/zephyr/emul/emul_pi3usb9201.c
index 3b1193d9b1..a722fc3039 100644
--- a/zephyr/emul/emul_pi3usb9201.c
+++ b/zephyr/emul/emul_pi3usb9201.c
@@ -3,18 +3,18 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT zephyr_pi3usb9201_emul
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_pi3usb9201.h"
+#include "emul/emul_stub_device.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
-#include "emul/emul_pi3usb9201.h"
-#include "emul/emul_stub_device.h"
-#include "emul/emul_common_i2c.h"
+#define DT_DRV_COMPAT pericom_pi3usb9201
-#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(emul_pi3usb9201, LOG_LEVEL_DBG);
#define EMUL_REG_COUNT (PI3USB9201_REG_HOST_STS + 1)
diff --git a/zephyr/emul/emul_rt9490.c b/zephyr/emul/emul_rt9490.c
index bc156b7085..1775bc9235 100644
--- a/zephyr/emul/emul_rt9490.c
+++ b/zephyr/emul/emul_rt9490.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/device.h>
-
#include "driver/charger/rt9490.h"
#include "emul/emul_common_i2c.h"
#include "emul/emul_rt9490.h"
#include "emul/emul_stub_device.h"
#include "util.h"
+#include <zephyr/device.h>
+
#define DT_DRV_COMPAT zephyr_rt9490_emul
#define RT9490_REG_MAX 255
diff --git a/zephyr/emul/emul_rtc.c b/zephyr/emul/emul_rtc.c
index 0bd2ef0828..845f0e8d78 100644
--- a/zephyr/emul/emul_rtc.c
+++ b/zephyr/emul/emul_rtc.c
@@ -5,18 +5,18 @@
/* This is not a chip emulator, it's a fake driver. */
-#define DT_DRV_COMPAT cros_ec_rtc_emul
-
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(emul_rtc);
+#include "drivers/cros_rtc.h"
+#include "ec_commands.h"
+#include "flash.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
-#include <ec_commands.h>
-#include <drivers/cros_rtc.h>
+#include <zephyr/logging/log.h>
#include <zephyr/sys/__assert.h>
-#include "flash.h"
+#define DT_DRV_COMPAT cros_ec_rtc_emul
+
+LOG_MODULE_REGISTER(emul_rtc);
struct cros_rtc_emul_data {
const struct device *rtc_dev;
diff --git a/zephyr/emul/emul_smart_battery.c b/zephyr/emul/emul_smart_battery.c
index 3f79ec2019..acada754d7 100644
--- a/zephyr/emul/emul_smart_battery.c
+++ b/zephyr/emul/emul_smart_battery.c
@@ -3,24 +3,23 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT zephyr_smart_battery
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(smart_battery);
+#include "battery_smart.h"
+#include "crc8.h"
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_smart_battery.h"
+#include "emul/emul_stub_device.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
#include <zephyr/ztest.h>
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_smart_battery.h"
+#define DT_DRV_COMPAT zephyr_smart_battery_emul
-#include "crc8.h"
-#include "battery_smart.h"
-#include "emul/emul_stub_device.h"
+#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
+LOG_MODULE_REGISTER(smart_battery);
/** Run-time data used by the emulator */
struct sbat_emul_data {
@@ -788,8 +787,10 @@ static int sbat_emul_access_reg(const struct emul *emul, int reg, int bytes,
static int sbat_emul_init(const struct emul *emul, const struct device *parent)
{
struct sbat_emul_data *data = emul->data;
+ const struct i2c_common_emul_cfg *cfg = emul->cfg;
data->common.i2c = parent;
+ data->common.cfg = cfg;
i2c_common_emul_init(&data->common);
@@ -901,14 +902,14 @@ static void emul_smart_battery_reset_capacity(const struct emul *emul)
}
#define SBAT_EMUL_RESET_RULE_AFTER(n) \
- emul_smart_battery_reset_capacity(EMUL_DT_GET(DT_DRV_INST(n)))
+ emul_smart_battery_reset_capacity(EMUL_DT_GET(DT_DRV_INST(n)));
static void emul_sbat_reset(const struct ztest_unit_test *test, void *data)
{
ARG_UNUSED(test);
ARG_UNUSED(data);
- DT_INST_FOREACH_STATUS_OKAY(SBAT_EMUL_RESET_RULE_AFTER);
+ DT_INST_FOREACH_STATUS_OKAY(SBAT_EMUL_RESET_RULE_AFTER)
}
ZTEST_RULE(emul_smart_battery_reset, NULL, emul_sbat_reset);
diff --git a/zephyr/emul/emul_sn5s330.c b/zephyr/emul/emul_sn5s330.c
index 6a520ed195..96342abf70 100644
--- a/zephyr/emul/emul_sn5s330.c
+++ b/zephyr/emul/emul_sn5s330.c
@@ -3,25 +3,26 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_sn5s330_emul
-
-#include <zephyr/device.h>
-#include <zephyr/drivers/i2c.h>
-#include <zephyr/drivers/i2c_emul.h>
-#include <zephyr/drivers/emul.h>
-#include <errno.h>
-#include <zephyr/sys/__assert.h>
-#include <zephyr/devicetree/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-
#include "driver/ppc/sn5s330.h"
#include "driver/ppc/sn5s330_public.h"
#include "emul/emul_common_i2c.h"
#include "emul/emul_sn5s330.h"
-#include "i2c.h"
#include "emul/emul_stub_device.h"
+#include "i2c.h"
+#include <errno.h>
+
+#include <zephyr/device.h>
+#include <zephyr/devicetree/gpio.h>
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/drivers/i2c.h>
+#include <zephyr/drivers/i2c_emul.h>
#include <zephyr/logging/log.h>
+#include <zephyr/sys/__assert.h>
+
+#define DT_DRV_COMPAT cros_sn5s330_emul
+
LOG_MODULE_REGISTER(sn5s330_emul, CONFIG_SN5S330_EMUL_LOG_LEVEL);
struct sn5s330_emul_data {
diff --git a/zephyr/emul/emul_syv682x.c b/zephyr/emul/emul_syv682x.c
index 8fb4bfc928..68c1a84e15 100644
--- a/zephyr/emul/emul_syv682x.c
+++ b/zephyr/emul/emul_syv682x.c
@@ -3,25 +3,26 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT zephyr_syv682x_emul
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_stub_device.h"
+#include "emul/emul_syv682x.h"
+
+#include <stdint.h>
+#include <string.h>
#include <zephyr/device.h>
#include <zephyr/devicetree/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(syv682x);
-#include <stdint.h>
-#include <string.h>
#include <zephyr/ztest.h>
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_syv682x.h"
-#include "emul/emul_stub_device.h"
+#define DT_DRV_COMPAT zephyr_syv682x_emul
+#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
+LOG_MODULE_REGISTER(syv682x);
#define EMUL_REG_COUNT (SYV682X_CONTROL_4_REG + 1)
#define EMUL_REG_IS_VALID(reg) (reg >= 0 && reg < EMUL_REG_COUNT)
diff --git a/zephyr/emul/emul_tcs3400.c b/zephyr/emul/emul_tcs3400.c
index e87deebc35..0266fe2998 100644
--- a/zephyr/emul/emul_tcs3400.c
+++ b/zephyr/emul/emul_tcs3400.c
@@ -3,23 +3,22 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT zephyr_tcs3400
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(emul_tcs);
+#include "driver/als_tcs3400.h"
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_stub_device.h"
+#include "emul/emul_tcs3400.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
#include <zephyr/ztest.h>
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_tcs3400.h"
-#include "emul/emul_stub_device.h"
+#define DT_DRV_COMPAT zephyr_tcs3400_emul
-#include "driver/als_tcs3400.h"
+#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
+LOG_MODULE_REGISTER(emul_tcs);
/** Run-time data used by the emulator */
struct tcs_emul_data {
diff --git a/zephyr/emul/emul_tusb1064.c b/zephyr/emul/emul_tusb1064.c
index 4396cc5fc5..866493bc32 100644
--- a/zephyr/emul/emul_tusb1064.c
+++ b/zephyr/emul/emul_tusb1064.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/device.h>
-
#include "driver/usb_mux/tusb1064.h"
#include "emul/emul_common_i2c.h"
#include "emul/emul_stub_device.h"
#include "util.h"
+#include <zephyr/device.h>
+
#define DT_DRV_COMPAT zephyr_tusb1064_emul
#define TUSB1064_REG_MAX 255
diff --git a/zephyr/emul/i2c_mock.c b/zephyr/emul/i2c_mock.c
index 8601c87ee7..c906e76c13 100644
--- a/zephyr/emul/i2c_mock.c
+++ b/zephyr/emul/i2c_mock.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_i2c_mock
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_stub_device.h"
#include <zephyr/device.h>
#include <zephyr/logging/log.h>
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_stub_device.h"
+#define DT_DRV_COMPAT cros_i2c_mock
LOG_MODULE_REGISTER(i2c_mock, CONFIG_I2C_MOCK_LOG_LEVEL);
diff --git a/zephyr/emul/pwm_mock.c b/zephyr/emul/pwm_mock.c
index 0d32155d8f..26f7891cb8 100644
--- a/zephyr/emul/pwm_mock.c
+++ b/zephyr/emul/pwm_mock.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_pwm_mock
+#include "pwm_mock.h"
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
-#include <zephyr/kernel.h>
#include <zephyr/drivers/pwm.h>
+#include <zephyr/kernel.h>
-#include "pwm_mock.h"
+#define DT_DRV_COMPAT cros_pwm_mock
#define CYCLES_PER_SEC 1000000
diff --git a/zephyr/emul/tcpc/CMakeLists.txt b/zephyr/emul/tcpc/CMakeLists.txt
index 8c011229f2..25031ad658 100644
--- a/zephyr/emul/tcpc/CMakeLists.txt
+++ b/zephyr/emul/tcpc/CMakeLists.txt
@@ -10,4 +10,5 @@ zephyr_library_sources_ifdef(CONFIG_EMUL_TCPCI_PARTNER_DRP emul_tcpci_partner_dr
zephyr_library_sources_ifdef(CONFIG_EMUL_TCPCI_PARTNER_SNK emul_tcpci_partner_snk.c)
zephyr_library_sources_ifdef(CONFIG_EMUL_TCPCI_PARTNER_SRC emul_tcpci_partner_src.c)
zephyr_library_sources_ifdef(CONFIG_EMUL_TCPCI_PARTNER_FAULTY_EXT emul_tcpci_partner_faulty_ext.c)
+zephyr_library_sources_ifdef(CONFIG_EMUL_TCPCI_PARTNER_VPD emul_tcpci_partner_vpd.c)
zephyr_library_sources_ifdef(CONFIG_EMUL_ANX7447 emul_anx7447.c)
diff --git a/zephyr/emul/tcpc/Kconfig b/zephyr/emul/tcpc/Kconfig
index 03b432f0a6..147f267113 100644
--- a/zephyr/emul/tcpc/Kconfig
+++ b/zephyr/emul/tcpc/Kconfig
@@ -4,6 +4,8 @@
menuconfig EMUL_TCPCI
bool "TCPCI common functionality"
+ default y
+ depends on DT_HAS_CROS_TCPCI_GENERIC_EMUL_ENABLED
depends on I2C_EMUL
help
Enable the TCPCI emulator. This driver uses the emulated I2C bus.
@@ -21,6 +23,8 @@ source "subsys/logging/Kconfig.template.log_config"
config EMUL_ANX7447
bool "Analogix ANX7447 emulator"
+ default y
+ depends on DT_HAS_CROS_ANX7447_TCPC_EMUL_ENABLED
help
Enable emulator for ANX7447 of TCPM. This emulator is extension for
TCPCI emulator. ANX7447 specific API is available in
@@ -36,6 +40,8 @@ config EMUL_TCPCI_PARTNER_COMMON
config EMUL_PS8XXX
bool "Parade PS8XXX emulator"
+ default y
+ depends on DT_HAS_CROS_PS8XXX_EMUL_ENABLED
help
Enable emulator for PS8XXX family of TCPC. This emulator is extenstion
for TCPCI emulator. PS8XXX specific API is available in
@@ -76,4 +82,14 @@ config EMUL_TCPCI_PARTNER_FAULTY_EXT
to TCPCI emulator. API of malfunctioning device emulator is
available in zephyr/include/emul/tcpc/emul_tcpci_partner_faulty_ext.h
+config EMUL_TCPCI_PARTNER_VPD
+ bool "USB-C VCONN-powered device emulator"
+ select EMUL_TCPCI_PARTNER_COMMON
+ # select EMUL_TCPCI_PARTNER_SRC
+ help
+ Enable USB-C VCONN-powered device (VPD) emulator, which may be
+ attached to TCPCI emulator. API of VPD is available in
+ zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h. This emulation is
+ specifically for the host port side of the VPD.
+
endif # EMUL_TCPCI
diff --git a/zephyr/emul/tcpc/emul_anx7447.c b/zephyr/emul/tcpc/emul_anx7447.c
index 6a351a4182..fb15e2eb4e 100644
--- a/zephyr/emul/tcpc/emul_anx7447.c
+++ b/zephyr/emul/tcpc/emul_anx7447.c
@@ -3,22 +3,21 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_anx7447_emul
-
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(anx7447_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_stub_device.h"
+#include "emul/tcpc/emul_tcpci.h"
+#include "tcpm/tcpci.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
#include <zephyr/ztest.h>
-#include "tcpm/tcpci.h"
-#include "emul/emul_stub_device.h"
+#define DT_DRV_COMPAT cros_anx7447_tcpc_emul
-#include "emul/emul_common_i2c.h"
-#include "emul/tcpc/emul_tcpci.h"
+LOG_MODULE_REGISTER(anx7447_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
/**
* @brief Function called for each byte of read message from anx7447 emulator
diff --git a/zephyr/emul/tcpc/emul_ps8xxx.c b/zephyr/emul/tcpc/emul_ps8xxx.c
index 57cc2c85f5..90b9ce7af3 100644
--- a/zephyr/emul/tcpc/emul_ps8xxx.c
+++ b/zephyr/emul/tcpc/emul_ps8xxx.c
@@ -3,28 +3,25 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_ps8xxx_emul
-
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(ps8xxx_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
+#include "driver/tcpm/ps8xxx.h"
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_stub_device.h"
+#include "emul/tcpc/emul_ps8xxx.h"
+#include "emul/tcpc/emul_tcpci.h"
+#include "tcpm/tcpci.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
#include <zephyr/ztest.h>
-#include "tcpm/tcpci.h"
-
-#include "emul/emul_common_i2c.h"
-#include "emul/tcpc/emul_ps8xxx.h"
-#include "emul/tcpc/emul_tcpci.h"
-#include "emul/emul_stub_device.h"
-
-#include "driver/tcpm/ps8xxx.h"
-
+#define DT_DRV_COMPAT cros_ps8xxx_emul
#define PS8XXX_REG_MUX_IN_HPD_ASSERTION MUX_IN_HPD_ASSERTION_REG
+LOG_MODULE_REGISTER(ps8xxx_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
+
/** Run-time data used by the emulator */
struct ps8xxx_emul_data {
/** Common I2C data used by "hidden" ports */
diff --git a/zephyr/emul/tcpc/emul_tcpci.c b/zephyr/emul/tcpc/emul_tcpci.c
index aa4e508489..e5dcf78bdc 100644
--- a/zephyr/emul/tcpc/emul_tcpci.c
+++ b/zephyr/emul/tcpc/emul_tcpci.c
@@ -3,21 +3,20 @@
* found in the LICENSE file.
*/
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(tcpci_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
+#include "emul/emul_common_i2c.h"
+#include "emul/tcpc/emul_tcpci.h"
+#include "tcpm/tcpci.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/logging/log.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/ztest.h>
-#include "tcpm/tcpci.h"
-
-#include "emul/emul_common_i2c.h"
-#include "emul/tcpc/emul_tcpci.h"
+LOG_MODULE_REGISTER(tcpci_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
/**
* @brief Returns number of bytes in specific register
diff --git a/zephyr/emul/tcpc/emul_tcpci_generic.c b/zephyr/emul/tcpc/emul_tcpci_generic.c
index 204e040ede..01fae7c978 100644
--- a/zephyr/emul/tcpc/emul_tcpci_generic.c
+++ b/zephyr/emul/tcpc/emul_tcpci_generic.c
@@ -3,22 +3,21 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_tcpci_generic_emul
-
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(tcpci_generic_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_stub_device.h"
+#include "emul/tcpc/emul_tcpci.h"
+#include "tcpm/tcpci.h"
#include <zephyr/device.h>
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/logging/log.h>
#include <zephyr/ztest.h>
-#include "tcpm/tcpci.h"
-#include "emul/emul_stub_device.h"
+#define DT_DRV_COMPAT cros_tcpci_generic_emul
-#include "emul/emul_common_i2c.h"
-#include "emul/tcpc/emul_tcpci.h"
+LOG_MODULE_REGISTER(tcpci_generic_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
/**
* @brief Function called for each byte of read message from TCPCI emulator
diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_common.c b/zephyr/emul/tcpc/emul_tcpci_partner_common.c
index 22a9ddb91e..0473f967dc 100644
--- a/zephyr/emul/tcpc/emul_tcpci_partner_common.c
+++ b/zephyr/emul/tcpc/emul_tcpci_partner_common.c
@@ -3,19 +3,21 @@
* found in the LICENSE file.
*/
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(tcpci_partner, CONFIG_TCPCI_EMUL_LOG_LEVEL);
+#include "common.h"
+#include "driver/tcpm/tcpci.h"
+#include "emul/tcpc/emul_tcpci.h"
+#include "emul/tcpc/emul_tcpci_partner_common.h"
+#include "usb_pd.h"
+#include "util.h"
#include <stdlib.h>
-#include <zephyr/sys/byteorder.h>
+
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/byteorder.h>
#include <zephyr/ztest.h>
-#include "common.h"
-#include "emul/tcpc/emul_tcpci_partner_common.h"
-#include "emul/tcpc/emul_tcpci.h"
-#include "usb_pd.h"
-#include "util.h"
+LOG_MODULE_REGISTER(tcpci_partner, CONFIG_TCPCI_EMUL_LOG_LEVEL);
/** Length of PDO, RDO and BIST request object in SOP message in bytes */
#define TCPCI_MSG_DO_LEN 4
@@ -404,11 +406,21 @@ int tcpci_partner_send_control_msg(struct tcpci_partner_data *data,
msg->type = type;
- if (msg->type == PD_CTRL_DR_SWAP) {
- /* Remember the control request initiated, so we can
- * handle the responses
+ switch (msg->type) {
+ case PD_CTRL_DR_SWAP:
+ case PD_CTRL_VCONN_SWAP:
+ /* For supported message types, remember the control request
+ * initiated, so the partner can handle the responses.
+ * (Eventually, all messages that can start an AMS should be
+ * supported.)
*/
tcpci_partner_common_set_ams_ctrl_msg(data, msg->type);
+ break;
+ default:
+ /* For messages that do not start an AMS, there is nothing to
+ * record.
+ */
+ break;
}
return tcpci_partner_send_msg(data, msg, delay);
@@ -747,6 +759,27 @@ tcpci_partner_common_vdm_handler(struct tcpci_partner_data *data,
}
static enum tcpci_partner_handler_res
+tcpci_partner_enter_usb_handler(struct tcpci_partner_data *data,
+ const struct tcpci_emul_msg *message)
+{
+ /*
+ * Validate received Enter_USB message against EUDO contents in
+ * tcpci_partner_data.
+ *
+ * TODO(b/260095516): This support needs to be expanded to validate the
+ * message contents, in a bit field basis. Currently, using this field
+ * as simple ACCEPT/REJECT criteria. If this value is 0 (default case),
+ * then ACCEPT this message, else reject it.
+ */
+ if (data->enter_usb_accept)
+ tcpci_partner_send_control_msg(data, PD_CTRL_ACCEPT, 0);
+ else
+ tcpci_partner_send_control_msg(data, PD_CTRL_REJECT, 0);
+
+ return TCPCI_PARTNER_COMMON_MSG_HANDLED;
+}
+
+static enum tcpci_partner_handler_res
tcpci_partner_common_cable_handler(struct tcpci_partner_data *data,
const struct tcpci_emul_msg *message,
enum tcpci_msg_type sop_type)
@@ -941,6 +974,26 @@ tcpci_partner_common_accept_dr_swap_handler(struct tcpci_partner_data *data)
}
static enum tcpci_partner_handler_res
+tcpci_partner_common_accept_vconn_swap_handler(struct tcpci_partner_data *data)
+{
+ if (data->vconn_role == PD_ROLE_VCONN_SRC) {
+ /* TODO: Wait for PS_RDY. */
+ } else {
+ /* VCONN Swap from off to VCONN Source means the partner sends
+ * the first PS_RDY after turning on VCONN.
+ */
+ tcpci_partner_common_set_vconn(data, PD_ROLE_VCONN_ON);
+ tcpci_partner_send_control_msg(data, PD_CTRL_PS_RDY, 15);
+ tcpci_partner_common_clear_ams_ctrl_msg(data);
+ /* Strictly speaking, the AMS isn't over until the partner
+ * receives GoodCRC for the PS_RDY.
+ */
+ }
+
+ return TCPCI_PARTNER_COMMON_MSG_HANDLED;
+}
+
+static enum tcpci_partner_handler_res
tcpi_drp_emul_ps_rdy_handler(struct tcpci_partner_data *data)
{
switch (data->cur_ams_ctrl_req) {
@@ -958,8 +1011,25 @@ static enum tcpci_partner_handler_res
tcpi_partner_common_handle_accept(struct tcpci_partner_data *data)
{
switch (data->cur_ams_ctrl_req) {
+ case PD_CTRL_VCONN_SWAP:
+ data->cur_ams_ctrl_req = PD_CTRL_INVALID;
+ return TCPCI_PARTNER_COMMON_MSG_HANDLED;
+
+ default:
+ LOG_ERR("Unhandled current_req=%u in ACCEPT",
+ data->cur_ams_ctrl_req);
+ return TCPCI_PARTNER_COMMON_MSG_NOT_HANDLED;
+ }
+}
+
+static enum tcpci_partner_handler_res
+tcpci_partner_common_handle_reject(struct tcpci_partner_data *data)
+{
+ switch (data->cur_ams_ctrl_req) {
case PD_CTRL_DR_SWAP:
return tcpci_partner_common_accept_dr_swap_handler(data);
+ case PD_CTRL_VCONN_SWAP:
+ return tcpci_partner_common_accept_vconn_swap_handler(data);
default:
LOG_ERR("Unhandled current_req=%u in ACCEPT",
@@ -1032,6 +1102,8 @@ tcpci_partner_common_sop_msg_handler(struct tcpci_partner_data *data,
switch (PD_HEADER_TYPE(header)) {
case PD_DATA_VENDOR_DEF:
return tcpci_partner_common_vdm_handler(data, tx_msg);
+ case PD_DATA_ENTER_USB:
+ return tcpci_partner_enter_usb_handler(data, tx_msg);
default:
/* No other common handlers for data messages */
return TCPCI_PARTNER_COMMON_MSG_NOT_HANDLED;
@@ -1072,6 +1144,10 @@ tcpci_partner_common_sop_msg_handler(struct tcpci_partner_data *data,
tcpci_partner_common_send_hard_reset(data);
return TCPCI_PARTNER_COMMON_MSG_HARD_RESET;
+ } else if (data->cur_ams_ctrl_req != PD_CTRL_INVALID) {
+ if (tcpci_partner_common_handle_reject(data) ==
+ TCPCI_PARTNER_COMMON_MSG_HANDLED)
+ return TCPCI_PARTNER_COMMON_MSG_HANDLED;
}
tcpci_partner_common_clear_ams_ctrl_msg(data);
@@ -1107,6 +1183,18 @@ tcpci_partner_common_sop_msg_handler(struct tcpci_partner_data *data,
tcpci_partner_common_send_soft_reset(data);
return TCPCI_PARTNER_COMMON_MSG_HANDLED;
+ case PD_CTRL_DATA_RESET:
+ /*
+ * Send Accept/Reject message
+ * TODO(b/260095516): To fully exercise this code path, there
+ * needs to be a mechanism (trigger) to either accept or reject
+ * this message.
+ */
+ tcpci_partner_send_control_msg(data, PD_CTRL_ACCEPT, 0);
+ return TCPCI_PARTNER_COMMON_MSG_HANDLED;
+ case PD_CTRL_DATA_RESET_COMPLETE:
+ /* There is no expected reply message from the port parter */
+ return TCPCI_PARTNER_COMMON_MSG_HANDLED;
}
return TCPCI_PARTNER_COMMON_MSG_NOT_HANDLED;
@@ -1141,6 +1229,16 @@ void tcpci_partner_set_discovery_info(struct tcpci_partner_data *data,
memcpy(data->modes_vdm, modes_vdm, modes_vdos * sizeof(*modes_vdm));
}
+static void tcpci_partner_common_control_change(struct tcpci_partner_data *data)
+{
+ const struct emul *tcpci_emul = data->tcpci_emul;
+ uint16_t role_control;
+
+ tcpci_emul_get_reg(tcpci_emul, TCPC_REG_ROLE_CTRL, &role_control);
+ data->tcpm_cc1 = TCPC_REG_ROLE_CTRL_CC1(role_control);
+ data->tcpm_cc1 = TCPC_REG_ROLE_CTRL_CC2(role_control);
+}
+
void tcpci_partner_common_disconnect(struct tcpci_partner_data *data)
{
tcpci_partner_clear_msg_queue(data);
@@ -1316,7 +1414,6 @@ void tcpci_partner_received_msg_status(struct tcpci_partner_data *data,
if (data->received_msg_status == NULL) {
return;
}
-
/*
* Status of each received message should be reported to TCPCI emulator
* only once
@@ -1440,6 +1537,22 @@ tcpci_partner_rx_consumed_op(const struct emul *emul,
tcpci_partner_free_msg(msg);
}
+static void
+tcpci_partner_control_change_op(const struct emul *emul,
+ const struct tcpci_emul_partner_ops *ops)
+{
+ struct tcpci_partner_data *data =
+ CONTAINER_OF(ops, struct tcpci_partner_data, ops);
+ struct tcpci_partner_extension *ext;
+
+ tcpci_partner_common_control_change(data);
+ for (ext = data->extensions; ext != NULL; ext = ext->next) {
+ if (ext->ops->control_change) {
+ ext->ops->control_change(ext, data);
+ }
+ }
+}
+
/**
* @brief Function called when emulator is disconnected from TCPCI
*
@@ -1521,6 +1634,7 @@ void tcpci_partner_init(struct tcpci_partner_data *data, enum pd_rev_type rev)
data->identity_vdos = 0;
data->svids_vdos = 0;
data->modes_vdos = 0;
+ data->enter_usb_accept = false;
tcpci_partner_common_clear_ams_ctrl_msg(data);
@@ -1531,7 +1645,7 @@ void tcpci_partner_init(struct tcpci_partner_data *data, enum pd_rev_type rev)
data->ops.transmit = tcpci_partner_transmit_op;
data->ops.rx_consumed = tcpci_partner_rx_consumed_op;
- data->ops.control_change = NULL;
+ data->ops.control_change = tcpci_partner_control_change_op;
data->ops.disconnect = tcpci_partner_disconnect_op;
data->displayport_configured = false;
data->entered_svid = 0;
diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_drp.c b/zephyr/emul/tcpc/emul_tcpci_partner_drp.c
index 277957282d..45fa21d972 100644
--- a/zephyr/emul/tcpc/emul_tcpci_partner_drp.c
+++ b/zephyr/emul/tcpc/emul_tcpci_partner_drp.c
@@ -3,12 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(tcpci_drp_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
-
-#include <zephyr/sys/byteorder.h>
-#include <zephyr/kernel.h>
-
#include "common.h"
#include "emul/tcpc/emul_tcpci.h"
#include "emul/tcpc/emul_tcpci_partner_common.h"
@@ -18,6 +12,12 @@ LOG_MODULE_REGISTER(tcpci_drp_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
#include "tcpm/tcpci.h"
#include "usb_pd.h"
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/byteorder.h>
+
+LOG_MODULE_REGISTER(tcpci_drp_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
+
/**
* @brief Handle SOP messages as TCPCI dual role device
*
diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c b/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c
index fc4cd06b82..f2920ba20c 100644
--- a/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c
+++ b/zephyr/emul/tcpc/emul_tcpci_partner_faulty_ext.c
@@ -3,18 +3,18 @@
* found in the LICENSE file.
*/
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(tcpci_faulty_ext, CONFIG_TCPCI_EMUL_LOG_LEVEL);
-
-#include <zephyr/sys/byteorder.h>
-#include <zephyr/kernel.h>
-
#include "common.h"
#include "emul/tcpc/emul_tcpci.h"
#include "emul/tcpc/emul_tcpci_partner_common.h"
#include "emul/tcpc/emul_tcpci_partner_faulty_ext.h"
#include "usb_pd.h"
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/byteorder.h>
+
+LOG_MODULE_REGISTER(tcpci_faulty_ext, CONFIG_TCPCI_EMUL_LOG_LEVEL);
+
/**
* @brief Reduce number of times to repeat action. If count reaches zero, action
* is removed from queue.
diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_snk.c b/zephyr/emul/tcpc/emul_tcpci_partner_snk.c
index 8d0fe1fa1e..d14012af41 100644
--- a/zephyr/emul/tcpc/emul_tcpci_partner_snk.c
+++ b/zephyr/emul/tcpc/emul_tcpci_partner_snk.c
@@ -3,18 +3,18 @@
* found in the LICENSE file.
*/
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(tcpci_snk_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
-
-#include <zephyr/sys/byteorder.h>
-#include <zephyr/kernel.h>
-
#include "common.h"
#include "emul/tcpc/emul_tcpci.h"
#include "emul/tcpc/emul_tcpci_partner_common.h"
#include "emul/tcpc/emul_tcpci_partner_snk.h"
#include "usb_pd.h"
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/byteorder.h>
+
+LOG_MODULE_REGISTER(tcpci_snk_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
+
/** Length of PDO, RDO and BIST request object in SOP message in bytes */
#define TCPCI_MSG_DO_LEN 4
/** Length of header in SOP message in bytes */
diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_src.c b/zephyr/emul/tcpc/emul_tcpci_partner_src.c
index c81d69c25f..7f4245fa6f 100644
--- a/zephyr/emul/tcpc/emul_tcpci_partner_src.c
+++ b/zephyr/emul/tcpc/emul_tcpci_partner_src.c
@@ -3,18 +3,18 @@
* found in the LICENSE file.
*/
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(tcpci_src_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
-
-#include <zephyr/sys/byteorder.h>
-#include <zephyr/kernel.h>
-
#include "common.h"
+#include "emul/tcpc/emul_tcpci.h"
#include "emul/tcpc/emul_tcpci_partner_common.h"
#include "emul/tcpc/emul_tcpci_partner_src.h"
-#include "emul/tcpc/emul_tcpci.h"
#include "usb_pd.h"
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/byteorder.h>
+
+LOG_MODULE_REGISTER(tcpci_src_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
+
/**
* @brief Start source capability timer. Capability message will be send after
* @p time.
diff --git a/zephyr/emul/tcpc/emul_tcpci_partner_vpd.c b/zephyr/emul/tcpc/emul_tcpci_partner_vpd.c
new file mode 100644
index 0000000000..f01227e913
--- /dev/null
+++ b/zephyr/emul/tcpc/emul_tcpci_partner_vpd.c
@@ -0,0 +1,125 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "driver/tcpm/tcpci.h"
+#include "emul/tcpc/emul_tcpci_partner_common.h"
+#include "emul/tcpc/emul_tcpci_partner_faulty_ext.h"
+#include "emul/tcpc/emul_tcpci_partner_snk.h"
+#include "emul/tcpc/emul_tcpci_partner_src.h"
+#include "emul/tcpc/emul_tcpci_partner_vpd.h"
+
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/byteorder.h>
+
+LOG_MODULE_REGISTER(tcpci_vpd_emul, CONFIG_TCPCI_EMUL_LOG_LEVEL);
+
+static enum tcpci_partner_handler_res
+tcpci_vpd_emul_handle_sop_msg(struct tcpci_partner_extension *ext,
+ struct tcpci_partner_data *common_data,
+ const struct tcpci_emul_msg *msg)
+{
+ struct tcpci_vpd_emul_data *data =
+ CONTAINER_OF(ext, struct tcpci_vpd_emul_data, ext);
+
+ /* Do not respond to SOP messages until charge-through is connected. */
+ if (!data->charge_through_connected)
+ return TCPCI_PARTNER_COMMON_MSG_NO_GOODCRC;
+
+ /* Once charge-through is connected, let the charger (later extension)
+ * handle SOP messages.
+ */
+ return TCPCI_PARTNER_COMMON_MSG_NOT_HANDLED;
+}
+
+static int tcpci_vpd_emul_connect(struct tcpci_partner_extension *ext,
+ struct tcpci_partner_data *common_data)
+{
+ struct tcpci_vpd_emul_data *data =
+ CONTAINER_OF(ext, struct tcpci_vpd_emul_data, ext);
+
+ /* Strictly speaking, the VPD shouldn't GoodCRC anything on SOP, Source
+ * Capabilities is the first message it will receive, so that's good
+ * enough.
+ */
+ if (common_data->power_role == PD_ROLE_SOURCE) {
+ tcpci_faulty_ext_clear_actions_list(&data->fault_ext);
+ } else {
+ data->fault_actions[0].action_mask =
+ TCPCI_FAULTY_EXT_FAIL_SRC_CAP;
+ data->fault_actions[0].count = TCPCI_FAULTY_EXT_INFINITE_ACTION;
+ tcpci_faulty_ext_append_action(&data->fault_ext,
+ &data->fault_actions[0]);
+ }
+
+ return 0;
+}
+
+static void
+tcpci_vpd_emul_control_change(struct tcpci_partner_extension *ext,
+ struct tcpci_partner_data *common_data)
+{
+ struct tcpci_vpd_emul_data *data =
+ CONTAINER_OF(ext, struct tcpci_vpd_emul_data, ext);
+ enum pd_cc_states tcpm_cc_state =
+ pd_get_cc_state(common_data->tcpm_cc1, common_data->tcpm_cc2);
+
+ LOG_DBG("TCPM changed control register; TCPM CC1 %u, CC2 %u",
+ common_data->tcpm_cc1, common_data->tcpm_cc2);
+ if (!data->charge_through_connected &&
+ tcpm_cc_state == PD_CC_UFP_ATTACHED) {
+ LOG_INF("Connecting charge-through port as Source");
+ data->charge_through_connected = true;
+ tcpci_partner_common_hard_reset_as_role(common_data,
+ PD_ROLE_SOURCE);
+ tcpci_partner_connect_to_tcpci(common_data,
+ common_data->tcpci_emul);
+ }
+}
+
+void tcpci_vpd_emul_disconnect(struct tcpci_partner_extension *ext,
+ struct tcpci_partner_data *common_data)
+{
+ struct tcpci_vpd_emul_data *data =
+ CONTAINER_OF(ext, struct tcpci_vpd_emul_data, ext);
+
+ data->charge_through_connected = false;
+ tcpci_partner_common_hard_reset_as_role(common_data, PD_ROLE_SINK);
+}
+
+static struct tcpci_partner_extension_ops vpd_emul_ops = {
+ .sop_msg_handler = tcpci_vpd_emul_handle_sop_msg,
+ .connect = tcpci_vpd_emul_connect,
+ .control_change = tcpci_vpd_emul_control_change,
+ .disconnect = tcpci_vpd_emul_disconnect,
+};
+
+struct tcpci_partner_extension *
+tcpci_vpd_emul_init(struct tcpci_vpd_emul_data *data,
+ struct tcpci_partner_data *common_data,
+ struct tcpci_partner_extension *ext)
+{
+ struct tcpci_partner_extension *vpd_ext = &data->ext;
+ struct tcpci_partner_extension *snk_ext;
+ struct tcpci_partner_extension *src_ext;
+
+ /* A VPD host port initially attaches as a Sink and responds to SOP'
+ * Discover Identity while ignoring SOP traffic. Then, when a Source is
+ * connected to the charge-through port, the CT-VPD acts as a Source.
+ * This extension therefore contains a faulty extension, a sink
+ * extension, and a source extension, in that order. Due to the
+ * linked-list extension structure, the initialization order is the
+ * reverse of that.
+ */
+ src_ext = tcpci_src_emul_init(&data->src_ext, common_data, ext);
+ snk_ext = tcpci_snk_emul_init(&data->snk_ext, common_data, src_ext);
+ vpd_ext->next =
+ tcpci_faulty_ext_init(&data->fault_ext, common_data, snk_ext);
+
+ vpd_ext->ops = &vpd_emul_ops;
+
+ data->charge_through_connected = false;
+
+ return vpd_ext;
+}
diff --git a/zephyr/fake/include/system_fake.h b/zephyr/fake/include/system_fake.h
index b80624e289..805e3ae44b 100644
--- a/zephyr/fake/include/system_fake.h
+++ b/zephyr/fake/include/system_fake.h
@@ -6,10 +6,10 @@
#ifndef ZEPHYR_FAKE_SYSTEM_FAKE_H
#define ZEPHYR_FAKE_SYSTEM_FAKE_H
-#include <setjmp.h>
-
#include "ec_commands.h"
+#include <setjmp.h>
+
/**
* @brief Set the current image copy.
*/
diff --git a/zephyr/fake/system_fake.c b/zephyr/fake/system_fake.c
index 75beb62b23..402559a885 100644
--- a/zephyr/fake/system_fake.c
+++ b/zephyr/fake/system_fake.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
-#include <setjmp.h>
-
#include "system.h"
#include "system_fake.h"
+#include <setjmp.h>
+
static enum ec_image shrspi_image_copy = EC_IMAGE_RO;
/* setjmp environment to use for reboot (NULL if none) */
diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py
index 545d31312d..edcbfc58ef 100755
--- a/zephyr/firmware_builder.py
+++ b/zephyr/firmware_builder.py
@@ -24,28 +24,44 @@ DEFAULT_BUNDLE_DIRECTORY = "/tmp/artifact_bundles"
DEFAULT_BUNDLE_METADATA_FILE = "/tmp/artifact_bundle_metadata"
# Boards that we want to track the coverage of our own files specifically.
-SPECIAL_BOARDS = ["herobrine", "krabby", "nivviks", "skyrim", "kingler"]
+SPECIAL_BOARDS = ["herobrine", "krabby", "nivviks", "skyrim", "kingler", "rex"]
-def log_cmd(cmd):
+def log_cmd(cmd, env=None):
"""Log subprocess command."""
+ if env is not None:
+ print("env", end=" ")
+ [ # pylint:disable=expression-not-assigned
+ print(key + "=" + shlex.quote(str(value)), end=" ")
+ for key, value in env.items()
+ ]
print(" ".join(shlex.quote(str(x)) for x in cmd))
sys.stdout.flush()
-def run_twister(platform_ec, code_coverage=False, extra_args=None):
- """Build the tests using twister."""
+def run_twister(
+ platform_ec, code_coverage=False, extra_args=None, use_gcc=False
+):
+ """Build the tests using twister.
+
+ Returns the path to the twister-out dir.
+ """
+
+ if use_gcc:
+ outdir = "twister-out-gcc"
+ toolchain = "host"
+ else:
+ outdir = "twister-out-llvm"
+ toolchain = "llvm"
cmd = [
platform_ec / "twister",
"--outdir",
- platform_ec / "twister-out",
+ platform_ec / outdir,
"-v",
"-i",
- "-p",
- "native_posix",
- "-p",
- "unit_testing",
"--no-upload-cros-rdb",
+ "--toolchain",
+ toolchain,
]
if extra_args:
@@ -60,7 +76,14 @@ def run_twister(platform_ec, code_coverage=False, extra_args=None):
]
)
log_cmd(cmd)
- subprocess.run(cmd, check=True, cwd=platform_ec, stdin=subprocess.DEVNULL)
+
+ subprocess.run(
+ cmd,
+ check=True,
+ cwd=platform_ec,
+ stdin=subprocess.DEVNULL,
+ )
+ return platform_ec / outdir
def build(opts):
@@ -76,6 +99,11 @@ def build(opts):
stdin=subprocess.DEVNULL,
)
+ # Start with a clean build environment
+ cmd = ["make", "clobber"]
+ log_cmd(cmd)
+ subprocess.run(cmd, cwd=platform_ec, check=True, stdin=subprocess.DEVNULL)
+
cmd = ["zmake", "-D", "build", "-a"]
if opts.code_coverage:
cmd.append("--coverage")
@@ -243,7 +271,10 @@ def test(opts):
# Twister-based tests
platform_ec = zephyr_dir.parent
third_party = platform_ec.parent.parent / "third_party"
- run_twister(platform_ec, opts.code_coverage)
+ twister_out_dir = run_twister(platform_ec, opts.code_coverage)
+ twister_out_dir_gcc = run_twister(
+ platform_ec, opts.code_coverage, use_gcc=True
+ )
if opts.code_coverage:
build_dir = platform_ec / "build" / "zephyr"
@@ -252,7 +283,7 @@ def test(opts):
[
"/usr/bin/lcov",
"--summary",
- platform_ec / "twister-out" / "coverage.info",
+ twister_out_dir / "coverage.info",
],
cwd=zephyr_dir,
check=True,
@@ -262,6 +293,20 @@ def test(opts):
).stdout
_extract_lcov_summary("EC_ZEPHYR_TESTS", metrics, output)
+ output = subprocess.run(
+ [
+ "/usr/bin/lcov",
+ "--summary",
+ twister_out_dir_gcc / "coverage.info",
+ ],
+ cwd=zephyr_dir,
+ check=True,
+ stdout=subprocess.PIPE,
+ universal_newlines=True,
+ stdin=subprocess.DEVNULL,
+ ).stdout
+ _extract_lcov_summary("EC_ZEPHYR_TESTS_GCC", metrics, output)
+
cmd = ["make", "test-coverage", f"-j{opts.cpus}"]
log_cmd(cmd)
subprocess.run(
@@ -291,7 +336,9 @@ def test(opts):
"-a",
platform_ec / "build/coverage/lcov.info",
"-a",
- platform_ec / "twister-out" / "coverage.info",
+ twister_out_dir / "coverage.info",
+ "-a",
+ twister_out_dir_gcc / "coverage.info",
]
log_cmd(cmd)
output = subprocess.run(
@@ -343,6 +390,7 @@ def test(opts):
zephyr_dir / "emul/**",
zephyr_dir / "mock/**",
third_party / "zephyr/main/subsys/emul/**",
+ third_party / "zephyr/main/arch/posix/**",
# Exclude all files ending in _test.[ch] or _emul.[ch]
"**/*_test.c",
"**/*_test.h",
@@ -470,7 +518,7 @@ def test(opts):
# These are questionable, but they are essentially untestable
zephyr_dir / "drivers/**",
zephyr_dir / "include/drivers/**",
- zephyr_dir / "projects/**",
+ zephyr_dir / "program/**",
zephyr_dir / "shim/chip/**",
zephyr_dir / "shim/chip/npcx/npcx_monitor/**",
zephyr_dir / "shim/core/**",
diff --git a/zephyr/include/drivers/cros_flash.h b/zephyr/include/drivers/cros_flash.h
index 267649476b..d7078cfb83 100644
--- a/zephyr/include/drivers/cros_flash.h
+++ b/zephyr/include/drivers/cros_flash.h
@@ -16,8 +16,8 @@
#ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_FLASH_H_
#define ZEPHYR_INCLUDE_DRIVERS_CROS_FLASH_H_
-#include <zephyr/kernel.h>
#include <zephyr/device.h>
+#include <zephyr/kernel.h>
/**
* @brief CROS Flash Driver APIs
diff --git a/zephyr/include/drivers/cros_kb_raw.h b/zephyr/include/drivers/cros_kb_raw.h
index d370a3bbde..7b9255bb9f 100644
--- a/zephyr/include/drivers/cros_kb_raw.h
+++ b/zephyr/include/drivers/cros_kb_raw.h
@@ -22,11 +22,11 @@
#ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_KB_RAW_H_
#define ZEPHYR_INCLUDE_DRIVERS_CROS_KB_RAW_H_
-#include <zephyr/kernel.h>
+#include "gpio_signal.h"
+
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
-
-#include "gpio_signal.h"
+#include <zephyr/kernel.h>
/*
* When CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED is enabled, the keyboard
@@ -60,11 +60,17 @@ typedef int (*cros_kb_raw_api_read_rows)(const struct device *dev);
typedef int (*cros_kb_raw_api_enable_interrupt)(const struct device *dev,
int enable);
+typedef int (*cros_kb_raw_api_config_alt)(const struct device *dev,
+ bool enable);
+
__subsystem struct cros_kb_raw_driver_api {
cros_kb_raw_api_init init;
cros_kb_raw_api_drive_column drive_colum;
cros_kb_raw_api_read_rows read_rows;
cros_kb_raw_api_enable_interrupt enable_interrupt;
+#ifdef CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST
+ cros_kb_raw_api_config_alt config_alt;
+#endif
};
/**
@@ -174,6 +180,36 @@ static inline int z_impl_cros_kb_raw_enable_interrupt(const struct device *dev,
}
/**
+ * @brief Enable or disable keyboard alternative function.
+ *
+ * Enabling alternative function.
+ *
+ * @param dev Pointer to the device structure for the keyboard driver instance.
+ * @param enable If 1, enable keyboard function. Otherwise, disable it (as
+ * GPIO).
+ *
+ * @return 0 If successful.
+ * @retval -ENOTSUP Not supported api function.
+ */
+
+#ifdef CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST
+__syscall int cros_kb_raw_config_alt(const struct device *dev, bool enable);
+
+static inline int z_impl_cros_kb_raw_config_alt(const struct device *dev,
+ bool enable)
+{
+ const struct cros_kb_raw_driver_api *api =
+ (const struct cros_kb_raw_driver_api *)dev->api;
+
+ if (!api->config_alt) {
+ return -ENOTSUP;
+ }
+
+ return api->config_alt(dev, enable);
+}
+#endif
+
+/**
* @brief Set the logical level of the keyboard column 2 output.
*
* When CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED is enabled, the column 2
diff --git a/zephyr/include/drivers/cros_rtc.h b/zephyr/include/drivers/cros_rtc.h
index 3a0f332b98..540391aac6 100644
--- a/zephyr/include/drivers/cros_rtc.h
+++ b/zephyr/include/drivers/cros_rtc.h
@@ -16,8 +16,8 @@
#ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_RTC_H_
#define ZEPHYR_INCLUDE_DRIVERS_CROS_RTC_H_
-#include <zephyr/kernel.h>
#include <zephyr/device.h>
+#include <zephyr/kernel.h>
/**
* @brief CROS Real-Time Clock (RTC) Driver APIs
diff --git a/zephyr/include/drivers/cros_shi.h b/zephyr/include/drivers/cros_shi.h
index 3eb3038a45..2ec2d2233a 100644
--- a/zephyr/include/drivers/cros_shi.h
+++ b/zephyr/include/drivers/cros_shi.h
@@ -18,8 +18,8 @@
* @{
*/
-#include <zephyr/kernel.h>
#include <zephyr/device.h>
+#include <zephyr/kernel.h>
/**
* @cond INTERNAL_HIDDEN
diff --git a/zephyr/include/drivers/cros_system.h b/zephyr/include/drivers/cros_system.h
index 5105d97cc9..c098c2cfcd 100644
--- a/zephyr/include/drivers/cros_system.h
+++ b/zephyr/include/drivers/cros_system.h
@@ -18,8 +18,8 @@
* @{
*/
-#include <zephyr/kernel.h>
#include <zephyr/device.h>
+#include <zephyr/kernel.h>
/**
* @brief system_reset_cause enum
diff --git a/zephyr/include/dt-bindings/native-posix-gpio.h b/zephyr/include/dt-bindings/native-posix-gpio.h
new file mode 100644
index 0000000000..c0b8077e3d
--- /dev/null
+++ b/zephyr/include/dt-bindings/native-posix-gpio.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef DT_BINDINGS_NATIVE_POSIX_GPIO_H_
+#define DT_BINDINGS_NATIVE_POSIX_GPIO_H_
+
+/** Used for testing, bits 8-15 for specific SoC flags. */
+#define NATIVE_POSIX_GPIO_VOLTAGE_1P8 (1 << 8)
+
+#endif /* DT_BINDINGS_NATIVE_POSIX_GPIO_H_ */
diff --git a/zephyr/include/emul/emul_isl923x.h b/zephyr/include/emul/emul_isl923x.h
index e41cf26f87..7d085658cf 100644
--- a/zephyr/include/emul/emul_isl923x.h
+++ b/zephyr/include/emul/emul_isl923x.h
@@ -7,8 +7,8 @@
#define ZEPHYR_INCLUDE_EMUL_EMUL_ISL923X_H_
#include <zephyr/device.h>
-#include <zephyr/drivers/i2c_emul.h>
#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/i2c_emul.h>
/**
* @brief Get the emulator's parent bus device
diff --git a/zephyr/include/emul/emul_kb_raw.h b/zephyr/include/emul/emul_kb_raw.h
index 1660ccefd4..0598eda7ab 100644
--- a/zephyr/include/emul/emul_kb_raw.h
+++ b/zephyr/include/emul/emul_kb_raw.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The ChromiumOS Authors.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/include/emul/emul_ln9310.h b/zephyr/include/emul/emul_ln9310.h
index 0c0e61003e..5d0cab9c20 100644
--- a/zephyr/include/emul/emul_ln9310.h
+++ b/zephyr/include/emul/emul_ln9310.h
@@ -12,10 +12,12 @@
#ifndef ZEPHYR_INCLUDE_EMUL_EMUL_LN9310_H_
#define ZEPHYR_INCLUDE_EMUL_EMUL_LN9310_H_
-#include <zephyr/drivers/emul.h>
#include "driver/ln9310.h"
+
#include <stdbool.h>
+#include <zephyr/drivers/emul.h>
+
/**
* @brief Select the current emulator to use.
*
diff --git a/zephyr/include/emul/emul_pct2075.h b/zephyr/include/emul/emul_pct2075.h
new file mode 100644
index 0000000000..f9e1ef60b2
--- /dev/null
+++ b/zephyr/include/emul/emul_pct2075.h
@@ -0,0 +1,32 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef EMUL_PCT2075_H
+#define EMUL_PCT2075_H
+
+#include "emul/emul_common_i2c.h"
+
+#include <zephyr/drivers/emul.h>
+
+#define PCT2075_REG_NUMBER 5
+
+struct pct2075_data {
+ struct i2c_common_emul_data common;
+ uint16_t regs[PCT2075_REG_NUMBER];
+};
+
+/**
+ * @brief Set the temperature measurement for the sensor.
+ *
+ * @param emul Pointer to emulator
+ * @param mk Temperature to set in mili-kalvin. The temperature
+ * should me in range of 328150 to 400150, with 150 resolution.
+ *
+ * @return 0 on success
+ * @return negative on error
+ */
+int pct2075_emul_set_temp(const struct emul *emul, int mk);
+
+#endif
diff --git a/zephyr/include/emul/emul_power_signals.h b/zephyr/include/emul/emul_power_signals.h
new file mode 100644
index 0000000000..7dea6079f0
--- /dev/null
+++ b/zephyr/include/emul/emul_power_signals.h
@@ -0,0 +1,49 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef EMUL_POWER_SIGNALS_H_
+#define EMUL_POWER_SIGNALS_H_
+
+/**
+ * @brief Test platform definition,
+ * This structure contains all power signal nodes associated to one
+ * test.
+ */
+struct power_signal_emul_test_platform {
+ char *name_id;
+ int nodes_count;
+ struct power_signal_emul_node **nodes;
+};
+
+#define EMUL_POWER_SIGNAL_TEST_PLATFORM_DECL(inst) \
+ extern const struct power_signal_emul_test_platform inst;
+
+#define EMUL_POWER_SIGNAL_TEST_PLATFORM(inst) (&DT_CAT(DT_N_S_, inst))
+
+DT_FOREACH_STATUS_OKAY(intel_ap_pwr_test_platform,
+ EMUL_POWER_SIGNAL_TEST_PLATFORM_DECL)
+/**
+ * @brief Load test platform.
+ *
+ * This initializes each of the test platform nodes.
+ *
+ * @param test_platform Pointer to test platform structure.
+ *
+ * @return 0 indicating success.
+ * @return -EINVAL `test_id` parameter is invalid.
+ * @return -EBUSY `test_id` One test platform is currently loaded.
+ */
+int power_signal_emul_load(
+ const struct power_signal_emul_test_platform *test_platform);
+
+/**
+ * @brief Unload test platform.
+ *
+ * @return 0 indicating success.
+ * @return -EINVAL no test platform has been loaded.
+ */
+int power_signal_emul_unload(void);
+
+#endif /* EMUL_POWER_SIGNALS_H_ */
diff --git a/zephyr/include/emul/emul_smart_battery.h b/zephyr/include/emul/emul_smart_battery.h
index 826e817992..35018f37f7 100644
--- a/zephyr/include/emul/emul_smart_battery.h
+++ b/zephyr/include/emul/emul_smart_battery.h
@@ -12,12 +12,13 @@
#ifndef __EMUL_SMART_BATTERY_H
#define __EMUL_SMART_BATTERY_H
+#include "emul/emul_common_i2c.h"
+
+#include <stdint.h>
+
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
-#include <stdint.h>
-
-#include "emul/emul_common_i2c.h"
/**
* @brief Smart Battery emulator backend API
diff --git a/zephyr/include/emul/emul_syv682x.h b/zephyr/include/emul/emul_syv682x.h
index 78ee2406eb..3e4328323e 100644
--- a/zephyr/include/emul/emul_syv682x.h
+++ b/zephyr/include/emul/emul_syv682x.h
@@ -11,9 +11,10 @@
#ifndef __EMUL_SYV682X_H
#define __EMUL_SYV682X_H
-#include <zephyr/drivers/i2c_emul.h>
#include <stdint.h>
+#include <zephyr/drivers/i2c_emul.h>
+
/* Register info copied from syv682.h */
/* SYV682x register addresses */
diff --git a/zephyr/include/emul/tcpc/emul_tcpci.h b/zephyr/include/emul/tcpc/emul_tcpci.h
index 8175b9ce96..8badf7dbc4 100644
--- a/zephyr/include/emul/tcpc/emul_tcpci.h
+++ b/zephyr/include/emul/tcpc/emul_tcpci.h
@@ -12,12 +12,13 @@
#ifndef __EMUL_TCPCI_H
#define __EMUL_TCPCI_H
+#include "emul/emul_common_i2c.h"
+
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/drivers/i2c_emul.h>
-#include <usb_pd_tcpm.h>
-#include "emul/emul_common_i2c.h"
+#include <usb_pd_tcpm.h>
/**
* Number of emulated register. This include vendor registers defined in TCPCI
diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h
index f232724ece..dd8909c2ca 100644
--- a/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h
+++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_common.h
@@ -12,16 +12,17 @@
#ifndef __EMUL_TCPCI_PARTNER_COMMON_H
#define __EMUL_TCPCI_PARTNER_COMMON_H
-#include <zephyr/drivers/emul.h>
-#include <zephyr/kernel.h>
-#include <zephyr/sys/atomic.h>
-#include <stdbool.h>
-#include <stdint.h>
-
#include "ec_commands.h"
#include "emul/tcpc/emul_tcpci.h"
#include "usb_pd.h"
+#include <stdbool.h>
+#include <stdint.h>
+
+#include <zephyr/drivers/emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/sys/atomic.h>
+
/**
* @brief Common code used by TCPCI partner device emulators
* @defgroup tcpci_partner Common code for TCPCI partner device emulators
@@ -147,6 +148,9 @@ struct tcpci_partner_data {
/* SVID of entered mode (0 if no mode is entered) */
uint16_t entered_svid;
+ enum tcpc_cc_voltage_status tcpm_cc1;
+ enum tcpc_cc_voltage_status tcpm_cc2;
+
/* VDMs with which the partner responds to discovery REQs. The VDM
* buffers include the VDM header, and the VDO counts include 1 for the
* VDM header. This structure has space for the mode response for a
@@ -183,6 +187,8 @@ struct tcpci_partner_data {
*/
bool have_response[PD_BATT_MAX];
} battery_capabilities;
+ /* Used to control accept/reject for partner port of Enter_USB msg */
+ bool enter_usb_accept;
/*
* Cable which is "plugged in" to this port partner
@@ -311,6 +317,9 @@ struct tcpci_partner_extension_ops {
void (*soft_reset)(struct tcpci_partner_extension *ext,
struct tcpci_partner_data *common_data);
+ void (*control_change)(struct tcpci_partner_extension *ext,
+ struct tcpci_partner_data *common_data);
+
/**
* @brief Function called when partner emulator is disconnected from
* TCPM
diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_drp.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_drp.h
index e4f58fcd37..cacb4e6270 100644
--- a/zephyr/include/emul/tcpc/emul_tcpci_partner_drp.h
+++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_drp.h
@@ -12,13 +12,14 @@
#ifndef __EMUL_TCPCI_PARTNER_DRP_H
#define __EMUL_TCPCI_PARTNER_DRP_H
-#include <zephyr/drivers/emul.h>
#include "emul/tcpc/emul_tcpci.h"
#include "emul/tcpc/emul_tcpci_partner_common.h"
#include "emul/tcpc/emul_tcpci_partner_snk.h"
#include "emul/tcpc/emul_tcpci_partner_src.h"
#include "usb_pd.h"
+#include <zephyr/drivers/emul.h>
+
/**
* @brief USB-C dual role device extension backend API
* @defgroup tcpci_snk_emul USB-C dual role device extension
diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_faulty_ext.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_faulty_ext.h
index f0627c95bd..317e9817d4 100644
--- a/zephyr/include/emul/tcpc/emul_tcpci_partner_faulty_ext.h
+++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_faulty_ext.h
@@ -12,11 +12,12 @@
#ifndef __EMUL_TCPCI_PARTNER_FAULTY_EXT_H
#define __EMUL_TCPCI_PARTNER_FAULTY_EXT_H
-#include <zephyr/drivers/emul.h>
#include "emul/tcpc/emul_tcpci.h"
#include "emul/tcpc/emul_tcpci_partner_common.h"
#include "usb_pd.h"
+#include <zephyr/drivers/emul.h>
+
/**
* @brief USB-C malfunctioning device extension backend API
* @defgroup tcpci_faulty_ext USB-C malfunctioning device extension
diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h
index 584458942b..edf09d25eb 100644
--- a/zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h
+++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_snk.h
@@ -12,11 +12,12 @@
#ifndef __EMUL_TCPCI_PARTNER_SNK_H
#define __EMUL_TCPCI_PARTNER_SNK_H
-#include <zephyr/drivers/emul.h>
-#include "emul/tcpc/emul_tcpci_partner_common.h"
#include "emul/tcpc/emul_tcpci.h"
+#include "emul/tcpc/emul_tcpci_partner_common.h"
#include "usb_pd.h"
+#include <zephyr/drivers/emul.h>
+
/**
* @brief USB-C sink device extension backend API
* @defgroup tcpci_snk_emul USB-C sink device extension
diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_src.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_src.h
index e72d0e4135..7ce14da82a 100644
--- a/zephyr/include/emul/tcpc/emul_tcpci_partner_src.h
+++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_src.h
@@ -12,11 +12,12 @@
#ifndef __EMUL_TCPCI_PARTNER_SRC_H
#define __EMUL_TCPCI_PARTNER_SRC_H
-#include <zephyr/drivers/emul.h>
-#include "emul/tcpc/emul_tcpci_partner_common.h"
#include "emul/tcpc/emul_tcpci.h"
+#include "emul/tcpc/emul_tcpci_partner_common.h"
#include "usb_pd.h"
+#include <zephyr/drivers/emul.h>
+
/**
* @brief USB-C source device extension backend API
* @defgroup tcpci_src_emul USB-C source device extension
diff --git a/zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h b/zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h
new file mode 100644
index 0000000000..6de0452b05
--- /dev/null
+++ b/zephyr/include/emul/tcpc/emul_tcpci_partner_vpd.h
@@ -0,0 +1,49 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * @file
+ *
+ * @brief Backend API for USB-C VCONN-powered device emulator
+ */
+
+#ifndef __EMUL_TCPCI_PARTNER_VPD_H
+#define __EMUL_TCPCI_PARTNER_VPD_H
+
+#include "emul/tcpc/emul_tcpci_partner_common.h"
+#include "emul/tcpc/emul_tcpci_partner_faulty_ext.h"
+#include "emul/tcpc/emul_tcpci_partner_snk.h"
+#include "emul/tcpc/emul_tcpci_partner_src.h"
+
+#include <zephyr/drivers/emul.h>
+
+/**
+ * @brief USB-C VCONN-powered device extension backend API
+ * @defgroup tcpci_src_emul USB-C source device extension
+ * @{
+ */
+
+struct tcpci_vpd_emul_data {
+ /** Common extension structure */
+ struct tcpci_partner_extension ext;
+ /** Pointer to common TCPCI partner data */
+ struct tcpci_partner_data *common_data;
+ struct tcpci_faulty_ext_data fault_ext;
+ struct tcpci_faulty_ext_action fault_actions[1];
+ struct tcpci_snk_emul_data snk_ext;
+ struct tcpci_src_emul_data src_ext;
+ bool charge_through_connected;
+};
+
+struct tcpci_partner_extension *
+tcpci_vpd_emul_init(struct tcpci_vpd_emul_data *data,
+ struct tcpci_partner_data *common_data,
+ struct tcpci_partner_extension *ext);
+
+/**
+ * @}
+ */
+
+#endif /* __EMUL_TCPCI_PARTNER_VPD_H */
diff --git a/zephyr/linker/CMakeLists.txt b/zephyr/linker/CMakeLists.txt
index 94544d454b..adffc2246f 100644
--- a/zephyr/linker/CMakeLists.txt
+++ b/zephyr/linker/CMakeLists.txt
@@ -21,3 +21,7 @@ zephyr_linker_sources_ifdef(CONFIG_SOC_FAMILY_MEC ROM_START SORT_KEY 1
zephyr_linker_sources(DATA_SECTIONS iterables-ram.ld)
zephyr_linker_sources(SECTIONS iterables-rom.ld)
+
+# Ensure there's space for panic and jump data at the end of ram
+# Must be added to "SECTIONS" because this is applied last
+zephyr_linker_sources(SECTIONS end-of-ram.ld)
diff --git a/zephyr/linker/end-of-ram.ld b/zephyr/linker/end-of-ram.ld
new file mode 100644
index 0000000000..e03de7481d
--- /dev/null
+++ b/zephyr/linker/end-of-ram.ld
@@ -0,0 +1,29 @@
+/* Copyright 2022 The Chromium OS Authors.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* This section simply ensures there's enough unused space at the end of ram to
+ * hold panic and jump data. This space isn't directly allocated because it
+ * would result in the SRAM utilization always being reported as 100%.
+ */
+#if !defined(CONFIG_BOARD_NATIVE_POSIX)
+SECTION_PROLOGUE(.end_of_ram_info, 0, )
+{
+ ASSERT(DEFINED(_image_ram_end) && _image_ram_end > 0, "Error: _image_ram_end is not defined");
+
+#if defined(RAM_ADDR) && defined(RAM_SIZE)
+ PROVIDE(__unused_ram_start = _image_ram_end);
+ PROVIDE(__unused_ram_end = RAM_ADDR + RAM_SIZE);
+ PROVIDE(__unused_ram_size = __unused_ram_end - __unused_ram_start);
+ ASSERT(__unused_ram_size >= CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE,
+ "ERROR: Not enough space for preserved end of ram data (see PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE)");
+#endif
+
+#if defined(CONFIG_SHAREDMEM_MINIMUM_SIZE)
+ ASSERT(CONFIG_SHAREDMEM_MINIMUM_SIZE >= CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE,
+ "ERROR: Sharedmem must be at least large enough for preserved end of ram data");
+#endif
+
+}
+#endif
diff --git a/zephyr/mock/power.c b/zephyr/mock/power.c
index 73f93ce3b5..b0de50a30e 100644
--- a/zephyr/mock/power.c
+++ b/zephyr/mock/power.c
@@ -3,16 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/logging/log.h>
-#include <zephyr/ztest.h>
-
#include "hooks.h"
#include "lid_switch.h"
+#include "mock/power.h"
#include "power.h"
#include "task.h"
#include "util.h"
-#include "mock/power.h"
+#include <zephyr/logging/log.h>
+#include <zephyr/ztest.h>
LOG_MODULE_REGISTER(mock_power);
diff --git a/zephyr/projects/.pylintrc b/zephyr/program/.pylintrc
index 8bdb6378e4..8bdb6378e4 100644
--- a/zephyr/projects/.pylintrc
+++ b/zephyr/program/.pylintrc
diff --git a/zephyr/projects/brya/BUILD.py b/zephyr/program/brya/BUILD.py
index 9991335ca7..9991335ca7 100644
--- a/zephyr/projects/brya/BUILD.py
+++ b/zephyr/program/brya/BUILD.py
diff --git a/zephyr/projects/brya/CMakeLists.txt b/zephyr/program/brya/CMakeLists.txt
index 11c1a8386f..11c1a8386f 100644
--- a/zephyr/projects/brya/CMakeLists.txt
+++ b/zephyr/program/brya/CMakeLists.txt
diff --git a/zephyr/projects/brya/Kconfig b/zephyr/program/brya/Kconfig
index 4dd8e23443..4dd8e23443 100644
--- a/zephyr/projects/brya/Kconfig
+++ b/zephyr/program/brya/Kconfig
diff --git a/zephyr/projects/brya/adc.dts b/zephyr/program/brya/adc.dts
index f3f0d1e064..f3f0d1e064 100644
--- a/zephyr/projects/brya/adc.dts
+++ b/zephyr/program/brya/adc.dts
diff --git a/zephyr/projects/brya/battery.dts b/zephyr/program/brya/battery.dts
index 4844d88d92..4844d88d92 100644
--- a/zephyr/projects/brya/battery.dts
+++ b/zephyr/program/brya/battery.dts
diff --git a/zephyr/program/brya/battery_present.c b/zephyr/program/brya/battery_present.c
new file mode 100644
index 0000000000..b2af448271
--- /dev/null
+++ b/zephyr/program/brya/battery_present.c
@@ -0,0 +1,21 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "battery.h"
+#include "cbi.h"
+
+#include <zephyr/drivers/gpio.h>
+
+enum battery_present battery_hw_present(void)
+{
+ const struct gpio_dt_spec *batt_pres;
+
+ if (get_board_id() == 1)
+ batt_pres = GPIO_DT_FROM_NODELABEL(gpio_id_1_ec_batt_pres_odl);
+ else
+ batt_pres = GPIO_DT_FROM_NODELABEL(gpio_ec_batt_pres_odl);
+
+ /* The GPIO is low when the battery is physically present */
+ return gpio_pin_get_dt(batt_pres) ? BP_NO : BP_YES;
+}
diff --git a/zephyr/projects/brya/brya.dts b/zephyr/program/brya/brya.dts
index 4b0490afa9..4b0490afa9 100644
--- a/zephyr/projects/brya/brya.dts
+++ b/zephyr/program/brya/brya.dts
diff --git a/zephyr/projects/brya/fan.dts b/zephyr/program/brya/fan.dts
index aa6dcfde7d..aa6dcfde7d 100644
--- a/zephyr/projects/brya/fan.dts
+++ b/zephyr/program/brya/fan.dts
diff --git a/zephyr/projects/brya/gpio.dts b/zephyr/program/brya/gpio.dts
index 6c6a2ac054..6c6a2ac054 100644
--- a/zephyr/projects/brya/gpio.dts
+++ b/zephyr/program/brya/gpio.dts
diff --git a/zephyr/program/brya/i2c.dts b/zephyr/program/brya/i2c.dts
new file mode 100644
index 0000000000..8de12cdb5e
--- /dev/null
+++ b/zephyr/program/brya/i2c.dts
@@ -0,0 +1,284 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+ #include <dt-bindings/usb_pd_tcpm.h>
+
+/ {
+ named-i2c-ports {
+ compatible = "named-i2c-ports";
+ i2c_sensor: sensor {
+ i2c-port = <&i2c0_0>;
+ enum-names = "I2C_PORT_SENSOR";
+ };
+ tcpc0_2: tcpc0_2 {
+ i2c-port = <&i2c1_0>;
+ enum-names = "I2C_PORT_USB_C0_C2_TCPC";
+ };
+ tcpc1: tcpc1 {
+ i2c-port = <&i2c4_1>;
+ enum-names = "I2C_PORT_USB_C1_TCPC";
+ dynamic-speed;
+ };
+ c0_c2_bc12: c0_c2_bc12 {
+ i2c-port = <&i2c2_0>;
+ enum-names = "I2C_PORT_USB_C0_C2_PPC",
+ "I2C_PORT_USB_C0_C2_BC12";
+ };
+ c1_bc12: c1_bc12 {
+ i2c-port = <&i2c6_1>;
+ enum-names = "I2C_PORT_USB_C1_PPC",
+ "I2C_PORT_USB_C1_BC12";
+ dynamic-speed;
+ };
+ retimer0_2: retimer0_2 {
+ i2c-port = <&i2c3_0>;
+ enum-names = "I2C_PORT_USB_C0_C2_MUX";
+ };
+ battery {
+ i2c-port = <&i2c5_0>;
+ enum-names = "I2C_PORT_BATTERY";
+ };
+ i2c_charger: charger {
+ i2c-port = <&i2c7_0>;
+ enum-names = "I2C_PORT_CHARGER",
+ "I2C_PORT_EEPROM",
+ "I2C_PORT_MP2964";
+ };
+ };
+};
+
+&i2c0_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
+ pinctrl-names = "default";
+};
+
+&i2c_ctrl0 {
+ status = "okay";
+};
+
+&i2c1_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+ pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
+ pinctrl-names = "default";
+
+ tcpc_port0: nct38xx@70 {
+ compatible = "nuvoton,nct38xx";
+ reg = <0x70>;
+ gpio-dev = <&nct3808_0_P1>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>;
+ };
+
+ nct3808_0_P1: nct3808_0_P1@70 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "nuvoton,nct38xx-gpio";
+ reg = <0x70>;
+ label = "NCT3808_0_P1";
+
+ ioex_port1: gpio@0 {
+ compatible = "nuvoton,nct38xx-gpio-port";
+ reg = <0x0>;
+ label = "NCT3808_0_P1_GPIO0";
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <8>;
+ pin_mask = <0xdc>;
+ pinmux_mask = <0xff>;
+ };
+ };
+
+ tcpc_port2: nct38xx@74 {
+ compatible = "nuvoton,nct38xx";
+ reg = <0x74>;
+ gpio-dev = <&nct3808_0_P2>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
+
+ nct3808_0_P2: nct3808_0_P2@74 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "nuvoton,nct38xx-gpio";
+ reg = <0x74>;
+ label = "NCT3808_0_P2";
+
+ ioex_port2: gpio@0 {
+ compatible = "nuvoton,nct38xx-gpio-port";
+ reg = <0x0>;
+ label = "NCT3808_0_P2_GPIO0";
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <8>;
+ pin_mask = <0xdc>;
+ pinmux_mask = <0xff>;
+ };
+ };
+
+ nct3808_alert_1 {
+ compatible = "nuvoton,nct38xx-gpio-alert";
+ irq-gpios = <&gpioe 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
+ nct38xx-dev = <&nct3808_0_P1 &nct3808_0_P2>;
+ label = "NCT3808_ALERT_1";
+ };
+};
+
+&i2c_ctrl1 {
+ status = "okay";
+};
+
+&i2c2_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+ pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>;
+ pinctrl-names = "default";
+
+ ppc_port0: syv682x@40 {
+ compatible = "silergy,syv682x";
+ status = "okay";
+ reg = <0x40>;
+ frs_en_gpio = <&usb_c0_frs_en>;
+ };
+
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ irq = <&int_usb_c0_bc12>;
+ };
+
+ ppc_port2: syv682x@42 {
+ compatible = "silergy,syv682x";
+ status = "okay";
+ reg = <0x42>;
+ frs_en_gpio = <&usb_c2_frs_en>;
+ };
+
+ bc12_port2: pi3usb9201@5d {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5d>;
+ irq = <&int_usb_c2_bc12>;
+ };
+};
+
+&i2c_ctrl2 {
+ status = "okay";
+};
+
+&i2c3_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+ pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
+ pinctrl-names = "default";
+
+ usb_c0_bb_retimer: jhl8040r-c0@56 {
+ compatible = "intel,jhl8040r";
+ reg = <0x56>;
+ int-pin = <&usb_c0_rt_int_odl>;
+ reset-pin = <&usb_c0_rt_rst_odl>;
+ };
+
+ usb_c2_bb_retimer: jhl8040r-c2@57 {
+ compatible = "intel,jhl8040r";
+ reg = <0x57>;
+ int-pin = <&usb_c2_rt_int_odl>;
+ reset-pin = <&usb_c2_rt_rst_odl>;
+ };
+};
+
+&i2c_ctrl3 {
+ status = "okay";
+};
+
+&i2c4_1 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>;
+ pinctrl-names = "default";
+
+ tcpc_port1: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V |
+ TCPC_FLAGS_CONTROL_VCONN |
+ TCPC_FLAGS_CONTROL_FRS)>;
+ };
+};
+
+&i2c_ctrl4 {
+ status = "okay";
+};
+
+&i2c5_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+ pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>;
+ pinctrl-names = "default";
+};
+
+&i2c_ctrl5 {
+ status = "okay";
+};
+
+&i2c6_1 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>;
+ pinctrl-names = "default";
+
+ ppc_port1: nx20p348x@72 {
+ compatible = "nxp,nx20p348x";
+ status = "okay";
+ reg = <0x72>;
+ };
+
+ bc12_port1: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ irq = <&int_usb_c1_bc12>;
+ };
+};
+
+&i2c_ctrl6 {
+ status = "okay";
+};
+
+&i2c7_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
+ pinctrl-names = "default";
+
+ pmic_mp2964@20 {
+ compatible = "mps,mp2964";
+ reg = <0x20>;
+ };
+
+ charger: bq25710@9 {
+ compatible = "ti,bq25710";
+ status = "okay";
+ reg = <0x9>;
+ };
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+};
+
+&i2c_ctrl7 {
+ status = "okay";
+};
diff --git a/zephyr/projects/brya/interrupts.dts b/zephyr/program/brya/interrupts.dts
index 1adca3e035..1adca3e035 100644
--- a/zephyr/projects/brya/interrupts.dts
+++ b/zephyr/program/brya/interrupts.dts
diff --git a/zephyr/program/brya/kblight_hooks.c b/zephyr/program/brya/kblight_hooks.c
new file mode 100644
index 0000000000..8716537f5d
--- /dev/null
+++ b/zephyr/program/brya/kblight_hooks.c
@@ -0,0 +1,69 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "cbi.h"
+#include "hooks.h"
+
+#include <stdbool.h>
+
+#include <zephyr/drivers/gpio.h>
+
+#include <ap_power/ap_power.h>
+
+/* Enable/Disable keyboard backlight gpio */
+static inline void kbd_backlight_enable(bool enable)
+{
+ if (get_board_id() == 1)
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_id_1_ec_kb_bl_en),
+ enable);
+ else
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_kb_bl_en_l),
+ !enable);
+}
+
+static void board_backlight_handler(struct ap_power_ev_callback *cb,
+ struct ap_power_ev_data data)
+{
+ bool enable;
+
+ switch (data.event) {
+ default:
+ return;
+
+ case AP_POWER_RESUME:
+ /* Called on AP S3 -> S0 transition */
+ enable = true;
+ break;
+
+ case AP_POWER_SUSPEND:
+ /* Called on AP S0 -> S3 transition */
+ enable = false;
+ break;
+ }
+ kbd_backlight_enable(enable);
+}
+
+/*
+ * Explicitly apply the board ID 1 *gpio.inc settings to pins that
+ * were reassigned on current boards.
+ */
+static void set_board_id_1_gpios(void)
+{
+ static struct ap_power_ev_callback cb;
+
+ /*
+ * Add a callback for suspend/resume to
+ * control the keyboard backlight.
+ */
+ ap_power_ev_init_callback(&cb, board_backlight_handler,
+ AP_POWER_RESUME | AP_POWER_SUSPEND);
+ ap_power_ev_add_callback(&cb);
+
+ if (get_board_id() != 1)
+ return;
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_id_1_ec_kb_bl_en),
+ GPIO_OUTPUT_LOW);
+}
+DECLARE_HOOK(HOOK_INIT, set_board_id_1_gpios, HOOK_PRIO_FIRST);
diff --git a/zephyr/projects/brya/keyboard.dts b/zephyr/program/brya/keyboard.dts
index 91fad2db92..91fad2db92 100644
--- a/zephyr/projects/brya/keyboard.dts
+++ b/zephyr/program/brya/keyboard.dts
diff --git a/zephyr/projects/brya/motionsense.dts b/zephyr/program/brya/motionsense.dts
index 08994e30cc..08994e30cc 100644
--- a/zephyr/projects/brya/motionsense.dts
+++ b/zephyr/program/brya/motionsense.dts
diff --git a/zephyr/program/brya/prj.conf b/zephyr/program/brya/prj.conf
new file mode 100644
index 0000000000..402db74994
--- /dev/null
+++ b/zephyr/program/brya/prj.conf
@@ -0,0 +1,175 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_CROS_EC=y
+CONFIG_PLATFORM_EC=y
+CONFIG_SHIMMED_TASKS=y
+CONFIG_PLATFORM_EC_POWER_BUTTON=y
+CONFIG_PLATFORM_EC_LID_SWITCH=y
+CONFIG_PLATFORM_EC_SWITCH=y
+CONFIG_LTO=y
+CONFIG_CROS_SYSTEM_NPCX=y
+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_ADC_CHANNELS_RUNTIME_CONFIG=y
+
+CONFIG_KERNEL_SHELL=y
+
+# SoC configuration
+CONFIG_AP=y
+CONFIG_AP_X86_INTEL_ADL=y
+CONFIG_FPU=y
+CONFIG_ARM_MPU=y
+
+# CBI
+CONFIG_EEPROM=y
+CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
+
+# eSPI
+CONFIG_ESPI=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US=150
+
+# Power Sequencing
+CONFIG_PLATFORM_EC_POWERSEQ=y
+CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET=y
+CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y
+CONFIG_PLATFORM_EC_POWERSEQ_S4=y
+CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
+CONFIG_PLATFORM_EC_THROTTLE_AP=y
+
+# Host command
+CONFIG_PLATFORM_EC_HOSTCMD=y
+CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET=y
+
+# Console command
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y
+
+# Sensors
+CONFIG_SENSOR=y
+CONFIG_SENSOR_SHELL=n
+CONFIG_PLATFORM_EC_MOTIONSENSE=y
+CONFIG_PLATFORM_EC_ACCEL_FIFO=y
+CONFIG_PLATFORM_EC_ALS=y
+CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y
+CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
+CONFIG_PLATFORM_EC_LID_ANGLE=y
+CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
+CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
+CONFIG_PLATFORM_EC_TABLET_MODE=y
+CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
+
+# Sensor Drivers
+CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y
+CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
+CONFIG_PLATFORM_EC_ALS_TCS3400=y
+
+# Temperature sensors
+CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y
+
+# MKBP event
+CONFIG_PLATFORM_EC_MKBP_EVENT=y
+CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
+CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y
+
+# PMIC
+CONFIG_PLATFORM_EC_PMIC=y
+
+# Keyboard
+CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y
+CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
+CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y
+CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
+CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
+CONFIG_PLATFORM_EC_CMD_BUTTON=n
+
+CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_SMART=y
+CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
+CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
+CONFIG_PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM=y
+CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
+
+# USB-C and charging
+CONFIG_PLATFORM_EC_CHARGER_BQ25720=y
+CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM=y
+CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_DV=70
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y
+CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512
+CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=3
+CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC=1
+CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000
+CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15001
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10
+CONFIG_PLATFORM_EC_CHARGE_RAMP_SW=y
+CONFIG_PLATFORM_EC_USB_PID=0x504F
+CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y
+CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y
+CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=y
+CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
+CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
+CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n
+CONFIG_PLATFORM_EC_USB_MUX_TASK=y
+CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL=y
+CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=2
+CONFIG_PLATFORM_EC_USB_PD_ALT_MODE_UFP=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_REV30=y
+CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y
+CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y
+CONFIG_PLATFORM_EC_USB_PD_USB4=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1715=n
+CONFIG_PLATFORM_EC_USB_PD_TCPM_TUSB422=n
+CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y
+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_CONSOLE_CMD_PPC_DUMP=n
+CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n
+CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n
+CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=y
+CONFIG_PLATFORM_EC_USB_PD_INT_SHARED=y
+CONFIG_PLATFORM_EC_USB_PD_PORT_0_SHARED=y
+CONFIG_PLATFORM_EC_USB_PD_PORT_2_SHARED=y
+
+CONFIG_SYSCON=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_COMMON=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_LEDTEST=n
+CONFIG_PLATFORM_EC_LED_PWM_NEAR_FULL_COLOR=4
+CONFIG_PLATFORM_EC_LED_PWM_SOC_ON_COLOR=4
+CONFIG_PLATFORM_EC_LED_PWM_SOC_SUSPEND_COLOR=4
+CONFIG_PLATFORM_EC_LED_PWM_LOW_BATT_COLOR=5
+
+# TODO(b/188605676): bring these features up
+CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n
+
+# Power Sequencing
+CONFIG_PLATFORM_EC_POWERSEQ=y
+CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
+CONFIG_CHIPSET_ALDERLAKE_SLG4BD44540=y
+CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET=n
+CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y
+CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
+# Treat 2nd reset from H1 as Power-On
+CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y
+CONFIG_PLATFORM_EC_THROTTLE_AP=y
+
+# RTC
+CONFIG_PLATFORM_EC_RTC=y
diff --git a/zephyr/projects/brya/prj_brya.conf b/zephyr/program/brya/prj_brya.conf
index 5aaf86a8c9..5aaf86a8c9 100644
--- a/zephyr/projects/brya/prj_brya.conf
+++ b/zephyr/program/brya/prj_brya.conf
diff --git a/zephyr/projects/brya/pwm_leds.dts b/zephyr/program/brya/pwm_leds.dts
index 4321b4bd34..4321b4bd34 100644
--- a/zephyr/projects/brya/pwm_leds.dts
+++ b/zephyr/program/brya/pwm_leds.dts
diff --git a/zephyr/projects/brya/temp_sensors.dts b/zephyr/program/brya/temp_sensors.dts
index ae436a2c6b..ae436a2c6b 100644
--- a/zephyr/projects/brya/temp_sensors.dts
+++ b/zephyr/program/brya/temp_sensors.dts
diff --git a/zephyr/projects/brya/usbc.dts b/zephyr/program/brya/usbc.dts
index 1be9ac94ac..1be9ac94ac 100644
--- a/zephyr/projects/brya/usbc.dts
+++ b/zephyr/program/brya/usbc.dts
diff --git a/zephyr/program/corsola/BUILD.py b/zephyr/program/corsola/BUILD.py
new file mode 100644
index 0000000000..f145953e0d
--- /dev/null
+++ b/zephyr/program/corsola/BUILD.py
@@ -0,0 +1,52 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Define zmake projects for corsola."""
+
+# Default chip is it81202bx, some variants will use NPCX9X.
+
+
+def register_corsola_project(
+ project_name,
+ chip="it81202bx",
+):
+ """Register a variant of corsola."""
+ register_func = register_binman_project
+ if chip.startswith("npcx"):
+ register_func = register_npcx_project
+
+ chip_kconfig = {"it81202bx": "ite", "npcx9m3f": "npcx"}[chip]
+
+ register_func(
+ project_name=project_name,
+ zephyr_board=chip,
+ dts_overlays=[here / project_name / "project.overlay"],
+ kconfig_files=[
+ here / "program.conf",
+ here / f"{chip_kconfig}_program.conf",
+ here / project_name / "project.conf",
+ ],
+ )
+
+
+register_corsola_project("krabby")
+
+register_corsola_project(
+ project_name="kingler",
+ chip="npcx9m3f",
+)
+
+register_corsola_project(
+ project_name="steelix",
+ chip="npcx9m3f",
+)
+
+register_corsola_project("tentacruel")
+
+register_corsola_project("magikarp")
+
+register_corsola_project(
+ project_name="voltorb",
+ chip="npcx9m3f",
+)
diff --git a/zephyr/program/corsola/CMakeLists.txt b/zephyr/program/corsola/CMakeLists.txt
new file mode 100644
index 0000000000..33aa0804d2
--- /dev/null
+++ b/zephyr/program/corsola/CMakeLists.txt
@@ -0,0 +1,88 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+cmake_minimum_required(VERSION 3.13.1)
+
+find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+
+cros_ec_library_include_directories(include)
+
+# Include selected EC source from the baseboard
+zephyr_library_sources(
+ "src/board.c"
+ "src/board_chipset.c"
+ "src/hibernate.c"
+)
+
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usbc_config.c")
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usb_pd_policy.c")
+zephyr_library_sources_ifdef(CONFIG_VARIANT_CORSOLA_DB_DETECTION
+ "src/variant_db_detection.c")
+
+if(DEFINED CONFIG_BOARD_KRABBY)
+ project(krabby)
+ zephyr_library_sources("src/krabby/hooks.c"
+ "src/krabby/charger_workaround.c"
+ "src/krabby/ppc_krabby.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/krabby/usb_pd_policy.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/krabby/usbc_config.c")
+elseif(DEFINED CONFIG_BOARD_KINGLER)
+ project(kingler)
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/kingler/i2c.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON
+ "src/kingler/led.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/kingler/usb_pd_policy.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/kingler/usbc_config.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG
+ "src/kingler/button.c")
+elseif(DEFINED CONFIG_BOARD_STEELIX)
+ project(steelix)
+ zephyr_library_sources("src/kingler/board_steelix.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/kingler/i2c.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON
+ "src/kingler/led_steelix.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/kingler/usb_pd_policy.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/kingler/usbc_config.c")
+
+elseif(DEFINED CONFIG_BOARD_TENTACRUEL)
+ project(tentacruel)
+ zephyr_library_sources("src/krabby/hooks.c"
+ "src/krabby/charger_workaround.c"
+ "src/krabby/sensor_tentacruel.c"
+ "src/krabby/temp_tentacruel.c"
+ "src/krabby/ppc_tentacruel.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/krabby/usb_pd_policy.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/krabby/usbc_config.c")
+
+elseif(DEFINED CONFIG_BOARD_MAGIKARP)
+ project(magikarp)
+ zephyr_library_sources("src/krabby/hooks.c"
+ "src/krabby/sensor_magikarp.c"
+ "src/krabby/ppc_magikarp.c"
+ "src/krabby/keyboard_magikarp.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/krabby/usb_pd_policy.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/krabby/usbc_config.c")
+
+elseif(DEFINED CONFIG_BOARD_VOLTORB)
+ project(voltorb)
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/kingler/i2c.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/kingler/usb_pd_policy.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/kingler/usbc_config.c")
+
+endif()
diff --git a/zephyr/program/corsola/Kconfig b/zephyr/program/corsola/Kconfig
new file mode 100644
index 0000000000..731de33d8b
--- /dev/null
+++ b/zephyr/program/corsola/Kconfig
@@ -0,0 +1,58 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+config BOARD_KRABBY
+ bool "Google Krabby Board"
+ help
+ Build Google Krabby reference board. Krabby has MediaTek MT8186 SoC
+ with ITE it81202-bx EC.
+
+config BOARD_KINGLER
+ bool "Google Kingler Board"
+ help
+ Build Google Kingler reference board. Krabby has MediaTek MT8186 SoC
+ with NPCX993FA0BX EC.
+
+config BOARD_STEELIX
+ bool "Google Steelix Board"
+ help
+ Build Google Steelix variant board. Steelix is a variant of Kingler
+ and has MediaTek MT8186 SoC with NPCX993FA0BX EC.
+
+config BOARD_TENTACRUEL
+ bool "Google Tentacruel Board"
+ help
+ Build Google Tentacruel variant board. Tentacruel is a variant of Krabby
+ and has MediaTek MT8186 SoC with ITE it81202-bx EC.
+
+config BOARD_MAGIKARP
+ bool "Google Magikarp Board"
+ help
+ Build Google Magikarp variant board. Magikarp is a variant of Krabby
+ and has MediaTek MT8186 SoC with ITE it81202-bx EC.
+
+config BOARD_VOLTORB
+ bool "Google Voltorb Board"
+ help
+ Build Google Voltorb variant board. Voltorb is a variant of Kingler
+ and has MediaTek MT8186/MT8186T SoC with NPCX993FA0BX EC.
+
+config VARIANT_CORSOLA_DB_DETECTION
+ bool "Corsola Platform Runtime Daughter Board Detection"
+ depends on PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG
+ depends on PLATFORM_EC_USB_MUX_RUNTIME_CONFIG
+ help
+ Daughter board detection for Type-C subboard or HDMI subboard. This
+ includes pin configuration and driver loading.
+ default y
+
+config VARIANT_CORSOLA_USBA
+ bool "Corsola Platform USB-A support"
+ help
+ Support Corsola USB-A related functions. Enable this function if
+ it has USB-A ports.
+ depends on PLATFORM_EC_USBC
+ default y
+
+source "Kconfig.zephyr"
diff --git a/zephyr/projects/corsola/adc_magikarp.dts b/zephyr/program/corsola/adc_magikarp.dtsi
index 358af6f0f4..358af6f0f4 100644
--- a/zephyr/projects/corsola/adc_magikarp.dts
+++ b/zephyr/program/corsola/adc_magikarp.dtsi
diff --git a/zephyr/program/corsola/adc_tentacruel.dtsi b/zephyr/program/corsola/adc_tentacruel.dtsi
new file mode 100644
index 0000000000..63ecb23a8e
--- /dev/null
+++ b/zephyr/program/corsola/adc_tentacruel.dtsi
@@ -0,0 +1,72 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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-adc-channels {
+ compatible = "named-adc-channels";
+ adc_vbus_c0 {
+ enum-name = "ADC_VBUS_C0";
+ io-channels = <&adc0 0>;
+ mul = <10>;
+ };
+ adc_board_id0 {
+ enum-name = "ADC_BOARD_ID_0";
+ io-channels = <&adc0 1>;
+ };
+ adc_board_id1 {
+ enum-name = "ADC_BOARD_ID_1";
+ io-channels = <&adc0 2>;
+ };
+ adc_vbus_c1 {
+ enum-name = "ADC_VBUS_C1";
+ io-channels = <&adc0 7>;
+ mul = <10>;
+ };
+ adc_ambient: ambient {
+ enum-name = "ADC_TEMP_SENSOR_2_AMBIENT";
+ io-channels = <&adc0 5>;
+ };
+ };
+};
+
+&adc0 {
+ status = "okay";
+ pinctrl-0 = <&adc0_ch0_gpi0_default
+ &adc0_ch1_gpi1_default
+ &adc0_ch2_gpi2_default
+ &adc0_ch5_gpi5_default
+ &adc0_ch7_gpi7_default>;
+ pinctrl-names = "default";
+};
+
+/ {
+ temp_ambient: ambient {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>;
+ adc = <&adc_ambient>;
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ ambient {
+ temp_host_high = <56>;
+ temp_host_halt = <80>;
+ temp_host_release_high = <42>;
+ sensor = <&temp_ambient>;
+ };
+ temp_charger: charger {
+ temp_host_high = <68>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <59>;
+ sensor = <&charger_bc12_port1>;
+ };
+ };
+};
+
+&thermistor_3V3_30K9_47K_NCP15WB {
+ status = "okay";
+};
diff --git a/zephyr/projects/corsola/battery_krabby.dts b/zephyr/program/corsola/battery_krabby.dtsi
index ce41859182..ce41859182 100644
--- a/zephyr/projects/corsola/battery_krabby.dts
+++ b/zephyr/program/corsola/battery_krabby.dtsi
diff --git a/zephyr/projects/corsola/battery_magikarp.dts b/zephyr/program/corsola/battery_magikarp.dtsi
index bbdd6ac0c5..bbdd6ac0c5 100644
--- a/zephyr/projects/corsola/battery_magikarp.dts
+++ b/zephyr/program/corsola/battery_magikarp.dtsi
diff --git a/zephyr/projects/corsola/battery_tentacruel.dts b/zephyr/program/corsola/battery_tentacruel.dtsi
index f116c20a51..f116c20a51 100644
--- a/zephyr/projects/corsola/battery_tentacruel.dts
+++ b/zephyr/program/corsola/battery_tentacruel.dtsi
diff --git a/zephyr/projects/corsola/cbi_magikarp.dts b/zephyr/program/corsola/cbi_magikarp.dtsi
index 5eac6b82c6..5eac6b82c6 100644
--- a/zephyr/projects/corsola/cbi_magikarp.dts
+++ b/zephyr/program/corsola/cbi_magikarp.dtsi
diff --git a/zephyr/projects/corsola/cbi_tentacruel.dts b/zephyr/program/corsola/cbi_tentacruel.dtsi
index 2cd4594417..2cd4594417 100644
--- a/zephyr/projects/corsola/cbi_tentacruel.dts
+++ b/zephyr/program/corsola/cbi_tentacruel.dtsi
diff --git a/zephyr/projects/corsola/common.dts b/zephyr/program/corsola/common.dtsi
index 001dcc7ce3..001dcc7ce3 100644
--- a/zephyr/projects/corsola/common.dts
+++ b/zephyr/program/corsola/common.dtsi
diff --git a/zephyr/projects/corsola/gpio_magikarp.dts b/zephyr/program/corsola/gpio_magikarp.dtsi
index cb9f6f1a0a..cb9f6f1a0a 100644
--- a/zephyr/projects/corsola/gpio_magikarp.dts
+++ b/zephyr/program/corsola/gpio_magikarp.dtsi
diff --git a/zephyr/projects/corsola/gpio_tentacruel.dts b/zephyr/program/corsola/gpio_tentacruel.dtsi
index a9ac9e8eac..a9ac9e8eac 100644
--- a/zephyr/projects/corsola/gpio_tentacruel.dts
+++ b/zephyr/program/corsola/gpio_tentacruel.dtsi
diff --git a/zephyr/program/corsola/i2c_krabby.dtsi b/zephyr/program/corsola/i2c_krabby.dtsi
new file mode 100644
index 0000000000..102ec4947c
--- /dev/null
+++ b/zephyr/program/corsola/i2c_krabby.dtsi
@@ -0,0 +1,23 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ite_i2c.dtsi"
+
+&i2c0 {
+ charger_bc12_port1: rt9490@53 {
+ compatible = "richtek,rt9490";
+ status = "okay";
+ reg = <0x53>;
+ irq = <&int_usb_c1_bc12_charger>;
+ };
+};
+
+&i2c4 {
+ tusb1064_mux_1: tusb1064-mux-1@44 {
+ compatible = "ti,tusb1064";
+ reg = <0x44>;
+ board-init = "tusb1064_mux_1_board_init";
+ };
+};
diff --git a/zephyr/program/corsola/i2c_magikarp.dtsi b/zephyr/program/corsola/i2c_magikarp.dtsi
new file mode 100644
index 0000000000..0dfd317b88
--- /dev/null
+++ b/zephyr/program/corsola/i2c_magikarp.dtsi
@@ -0,0 +1,37 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ite_i2c.dtsi"
+
+&i2c0 {
+ charger_bc12_port1: rt9490@53 {
+ compatible = "richtek,rt9490";
+ status = "okay";
+ reg = <0x53>;
+ irq = <&int_usb_c1_bc12_charger>;
+ };
+};
+
+&i2c2 {
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ irq = <&int_usb_c0_bc12>;
+ };
+ ppc_port0: syv682x@40 {
+ compatible = "silergy,syv682x";
+ status = "okay";
+ reg = <0x40>;
+ frs_en_gpio = <&usb_c0_frs_en>;
+ };
+};
+
+&i2c4 {
+ ps8743_mux_1: ps8743-mux-1@10 {
+ compatible = "parade,ps8743";
+ reg = <0x10>;
+ };
+};
diff --git a/zephyr/program/corsola/i2c_tentacruel.dtsi b/zephyr/program/corsola/i2c_tentacruel.dtsi
new file mode 100644
index 0000000000..05203103d5
--- /dev/null
+++ b/zephyr/program/corsola/i2c_tentacruel.dtsi
@@ -0,0 +1,39 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ite_i2c.dtsi"
+
+&i2c0 {
+ charger_bc12_port1: rt9490@53 {
+ compatible = "richtek,rt9490";
+ status = "okay";
+ reg = <0x53>;
+ irq = <&int_usb_c1_bc12_charger>;
+ thermistor = <&thermistor_rt9490>;
+ };
+};
+
+&i2c2 {
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ irq = <&int_usb_c0_bc12>;
+ };
+ ppc_port0: syv682x@40 {
+ compatible = "silergy,syv682x";
+ status = "okay";
+ reg = <0x40>;
+ frs_en_gpio = <&usb_c0_frs_en>;
+ };
+};
+
+&i2c4 {
+ ps8743_mux_1: ps8743-mux-1@10 {
+ compatible = "parade,ps8743";
+ reg = <0x10>;
+ board-init = "ps8743_eq_c1_setting";
+ };
+};
diff --git a/zephyr/program/corsola/include/baseboard_usbc_config.h b/zephyr/program/corsola/include/baseboard_usbc_config.h
new file mode 100644
index 0000000000..a80aa10446
--- /dev/null
+++ b/zephyr/program/corsola/include/baseboard_usbc_config.h
@@ -0,0 +1,42 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Corsola daughter board detection */
+
+#ifndef __CROS_EC_BASEBOARD_USBC_CONFIG_H
+#define __CROS_EC_BASEBOARD_USBC_CONFIG_H
+
+#include "gpio.h"
+
+#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S
+#define GPIO_EN_USB_C1_SINK RT1718S_GPIO1
+#define GPIO_EN_USB_C1_SOURCE RT1718S_GPIO2
+#define GPIO_EN_USB_C1_FRS RT1718S_GPIO3
+#endif
+
+void ppc_interrupt(enum gpio_signal signal);
+void ccd_interrupt(enum gpio_signal signal);
+void hdmi_hpd_interrupt(enum gpio_signal signal);
+void ps185_hdmi_hpd_mux_set(void);
+int corsola_is_dp_muxable(int port);
+
+/* USB-A ports */
+enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_COUNT };
+
+/* USB-C ports */
+enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
+BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT);
+
+/**
+ * Is the port fine to be muxed its DisplayPort lines?
+ *
+ * Only one port can be muxed to DisplayPort at a time.
+ *
+ * @param port Port number of TCPC.
+ * @return 1 is fine; 0 is bad as other port is already muxed;
+ */
+int corsola_is_dp_muxable(int port);
+
+#endif /* __CROS_EC_BASEBOARD_USBC_CONFIG_H */
diff --git a/zephyr/program/corsola/include/variant_db_detection.h b/zephyr/program/corsola/include/variant_db_detection.h
new file mode 100644
index 0000000000..e98ba3067d
--- /dev/null
+++ b/zephyr/program/corsola/include/variant_db_detection.h
@@ -0,0 +1,37 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Corsola daughter board detection */
+
+#ifndef __CROS_EC_CORSOLA_DB_DETECTION_H
+#define __CROS_EC_CORSOLA_DB_DETECTION_H
+
+enum corsola_db_type {
+ CORSOLA_DB_UNINIT = -1,
+ CORSOLA_DB_NONE,
+ CORSOLA_DB_TYPEC,
+ CORSOLA_DB_HDMI,
+ CORSOLA_DB_COUNT,
+};
+
+#ifdef CONFIG_VARIANT_CORSOLA_DB_DETECTION
+/*
+ * Get the connected daughterboard type.
+ *
+ * @return The daughterboard type.
+ */
+enum corsola_db_type corsola_get_db_type(void);
+#else
+inline enum corsola_db_type corsola_get_db_type(void)
+{
+ return CORSOLA_DB_NONE;
+};
+#endif /* CONFIG_VARIANT_CORSOLA_DB_DETECTION */
+
+/* return the adjusted port count for board overridden usbc/charger functions.
+ */
+uint8_t board_get_adjusted_usb_pd_port_count(void);
+
+#endif /* __CROS_EC_CORSOLA_DB_DETECTION_H */
diff --git a/zephyr/projects/corsola/interrupts_magikarp.dts b/zephyr/program/corsola/interrupts_magikarp.dtsi
index 4f4e0ba100..4f4e0ba100 100644
--- a/zephyr/projects/corsola/interrupts_magikarp.dts
+++ b/zephyr/program/corsola/interrupts_magikarp.dtsi
diff --git a/zephyr/projects/corsola/interrupts_tentacruel.dts b/zephyr/program/corsola/interrupts_tentacruel.dtsi
index 11229daf36..11229daf36 100644
--- a/zephyr/projects/corsola/interrupts_tentacruel.dts
+++ b/zephyr/program/corsola/interrupts_tentacruel.dtsi
diff --git a/zephyr/projects/corsola/adc_krabby.dts b/zephyr/program/corsola/ite_adc.dtsi
index be65e9eea7..be65e9eea7 100644
--- a/zephyr/projects/corsola/adc_krabby.dts
+++ b/zephyr/program/corsola/ite_adc.dtsi
diff --git a/zephyr/projects/corsola/gpio_krabby.dts b/zephyr/program/corsola/ite_gpio.dtsi
index 5f06609f43..5f06609f43 100644
--- a/zephyr/projects/corsola/gpio_krabby.dts
+++ b/zephyr/program/corsola/ite_gpio.dtsi
diff --git a/zephyr/program/corsola/ite_i2c.dtsi b/zephyr/program/corsola/ite_i2c.dtsi
new file mode 100644
index 0000000000..ba8e31423a
--- /dev/null
+++ b/zephyr/program/corsola/ite_i2c.dtsi
@@ -0,0 +1,131 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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";
+
+ battery {
+ i2c-port = <&i2c1>;
+ remote-port = <1>;
+ enum-names = "I2C_PORT_BATTERY",
+ "I2C_PORT_VIRTUAL_BATTERY";
+ };
+ i2c_charger: charger {
+ i2c-port = <&i2c0>;
+ enum-names = "I2C_PORT_CHARGER",
+ "I2C_PORT_EEPROM";
+ };
+ i2c_sensor: sensor {
+ i2c-port = <&i2c3>;
+ enum-names = "I2C_PORT_SENSOR";
+ };
+ i2c_usb_c0: usb-c0 {
+ i2c-port = <&i2c2>;
+ enum-names = "I2C_PORT_USB_C0",
+ "I2C_PORT_USB_MUX0";
+ };
+ i2c_usb_c1: usb-c1 {
+ i2c-port = <&i2c4>;
+ enum-names = "I2C_PORT_USB_C1",
+ "I2C_PORT_USB_MUX1";
+ };
+ };
+
+};
+
+&pinctrl {
+ i2c3_clk_gpf2_sleep: i2c3_clk_gpf2_sleep {
+ pinmuxs = <&pinctrlf 2 IT8XXX2_ALT_DEFAULT>;
+ };
+ i2c3_data_gpf3_sleep: i2c3_data_gpf3_sleep {
+ pinmuxs = <&pinctrlf 3 IT8XXX2_ALT_DEFAULT>;
+ };
+};
+
+&i2c0 {
+ /* EC_I2C_PWR_CBI */
+ label = "I2C_PWR_CBI";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c0_clk_gpb3_default
+ &i2c0_data_gpb4_default>;
+ pinctrl-names = "default";
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+};
+
+&i2c1 {
+ /* EC_I2C_BATTERY */
+ label = "I2C_BATTERY";
+ status = "okay";
+ clock-frequency = <50000>;
+ pinctrl-0 = <&i2c1_clk_gpc1_default
+ &i2c1_data_gpc2_default>;
+ pinctrl-names = "default";
+ fifo-enable;
+};
+
+&i2c2 {
+ /* EC_I2C_USB_C0 */
+ label = "I2C_USB_C0";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c2_clk_gpf6_default
+ &i2c2_data_gpf7_default>;
+ pinctrl-names = "default";
+ /delete-property/ fifo-enable;
+
+ bc12_ppc_port0: rt1739@70 {
+ compatible = "richtek,rt1739";
+ status = "okay";
+ reg = <0x70>;
+ };
+
+ it5205_mux_0: it5205-mux-0@48 {
+ compatible = "ite,it5205";
+ reg = <0x48>;
+ };
+};
+
+&i2c3 {
+ /* EC_I2C_SENSOR */
+ label = "I2C_SENSOR";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ scl-gpios = <&gpiof 2 0>;
+ sda-gpios = <&gpiof 3 0>;
+ pinctrl-0 = <&i2c3_clk_gpf2_default
+ &i2c3_data_gpf3_default>;
+ pinctrl-1 = <&i2c3_clk_gpf2_sleep
+ &i2c3_data_gpf3_sleep>;
+ pinctrl-names = "default", "sleep";
+ prescale-scl-low = <1>;
+};
+
+&i2c4 {
+ /* EC_I2C_USB_C1 */
+ label = "I2C_USB_C1";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c4_clk_gpe0_default
+ &i2c4_data_gpe7_default>;
+ pinctrl-names = "default";
+ prescale-scl-low = <1>;
+
+ ppc_port1: syv682x@40 {
+ compatible = "silergy,syv682x";
+ status = "okay";
+ reg = <0x40>;
+ frs_en_gpio = <&gpio_ec_x_gpio1>;
+ };
+};
diff --git a/zephyr/projects/corsola/interrupts_krabby.dts b/zephyr/program/corsola/ite_interrupts.dtsi
index 3caf4660ae..3caf4660ae 100644
--- a/zephyr/projects/corsola/interrupts_krabby.dts
+++ b/zephyr/program/corsola/ite_interrupts.dtsi
diff --git a/zephyr/program/corsola/ite_keyboard.dtsi b/zephyr/program/corsola/ite_keyboard.dtsi
new file mode 100644
index 0000000000..8d2a345ff0
--- /dev/null
+++ b/zephyr/program/corsola/ite_keyboard.dtsi
@@ -0,0 +1,28 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ cros-keyscan {
+ compatible = "cros-ec,keyscan";
+
+ scan-period = <10000>;
+
+ actual-key-mask = <
+ 0x1c /* C0 */
+ 0xff /* C1 */
+ 0xff /* C2 */
+ 0xff /* C3 */
+ 0xff /* C4 */
+ 0xf5 /* C5 */
+ 0xff /* C6 */
+ 0xa4 /* C7 */
+ 0xff /* C8 */
+ 0xfe /* C9 */
+ 0x55 /* C10 */
+ 0xfa /* C11 */
+ 0xca /* C12 */
+ >;
+ };
+};
diff --git a/zephyr/projects/corsola/motionsense_krabby.dts b/zephyr/program/corsola/ite_motionsense.dtsi
index 1c7d5b2df4..1c7d5b2df4 100644
--- a/zephyr/projects/corsola/motionsense_krabby.dts
+++ b/zephyr/program/corsola/ite_motionsense.dtsi
diff --git a/zephyr/program/corsola/ite_program.conf b/zephyr/program/corsola/ite_program.conf
new file mode 100644
index 0000000000..55aecebb90
--- /dev/null
+++ b/zephyr/program/corsola/ite_program.conf
@@ -0,0 +1,85 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Bring up options
+CONFIG_SHELL_HISTORY_BUFFER=256
+CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
+CONFIG_PLATFORM_EC_BRINGUP=y
+
+# Power Sequencing
+CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y
+
+# Lid Switch
+CONFIG_PLATFORM_EC_LID_SWITCH=y
+
+# Charger
+CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y
+CONFIG_PLATFORM_EC_CHARGER_MAINTAIN_VBAT=y
+CONFIG_PLATFORM_EC_CHARGER_PSYS=y
+CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y
+# BOARD_RS2
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
+# BOARD_RS1
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20
+CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y
+
+# Host Commands
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y
+CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_DT=y
+
+# Sensors
+CONFIG_PLATFORM_EC_MOTIONSENSE=y
+CONFIG_PLATFORM_EC_ACCEL_FIFO=y
+CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
+CONFIG_PLATFORM_EC_LID_ANGLE=y
+CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
+CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
+CONFIG_PLATFORM_EC_TABLET_MODE=y
+CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
+CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000
+
+# Sensor Drivers
+CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
+CONFIG_PLATFORM_EC_ACCELGYRO_ICM42607=y
+CONFIG_PLATFORM_EC_ACCELGYRO_ICM_COMM_I2C=y
+
+# Tasks
+CONFIG_TASK_CHARGER_STACK_SIZE=1024
+CONFIG_TASK_CHIPSET_STACK_SIZE=1440
+CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1024
+CONFIG_TASK_PD_STACK_SIZE=1280
+
+# USB-C
+CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n
+CONFIG_PLATFORM_EC_USBC_PPC_RT1739=y
+CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y
+CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y
+CONFIG_PLATFORM_EC_USB_MUX_IT5205=y
+CONFIG_PLATFORM_EC_USB_MUX_TUSB546=y
+CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT=y
+CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n
+CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=0
+CONFIG_PLATFORM_EC_USB_PD_PULLUP=1
+
+CONFIG_PLATFORM_EC_SHA256_UNROLLED=y
+
+# TODO(b/180980668): bring these features up
+CONFIG_LTO=n
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
diff --git a/zephyr/program/corsola/ite_usbc.dtsi b/zephyr/program/corsola/ite_usbc.dtsi
new file mode 100644
index 0000000000..f8881e437c
--- /dev/null
+++ b/zephyr/program/corsola/ite_usbc.dtsi
@@ -0,0 +1,59 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ usbc {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port0@0 {
+ compatible = "named-usbc-port";
+ reg = <0>;
+ bc12 = <&bc12_ppc_port0>;
+ ppc = <&bc12_ppc_port0>;
+ tcpc = <&usbpd0>;
+ chg = <&charger_bc12_port1>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&it5205_mux_0 &virtual_mux_0>;
+ };
+ };
+ port0-muxes {
+ virtual_mux_0: virtual-mux-0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+
+ port1@1 {
+ compatible = "named-usbc-port";
+ reg = <1>;
+ bc12 = <&charger_bc12_port1>;
+ ppc = <&ppc_port1>;
+ tcpc = <&usbpd1>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&tusb1064_mux_1 &virtual_mux_1>;
+ };
+ usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db {
+ compatible = "cros-ec,usb-mux-chain";
+ alternative-chain;
+ usb-muxes = <&virtual_mux_1>;
+ };
+ };
+ port1-muxes {
+ virtual_mux_1: virtual-mux-1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ };
+};
+
+&usbpd0 {
+ status = "okay";
+};
+
+&usbpd1 {
+ status = "okay";
+};
diff --git a/zephyr/program/corsola/kingler/project.conf b/zephyr/program/corsola/kingler/project.conf
new file mode 100644
index 0000000000..cd4a735d71
--- /dev/null
+++ b/zephyr/program/corsola/kingler/project.conf
@@ -0,0 +1,9 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Variant config
+CONFIG_BOARD_KINGLER=y
+
+# Keyboard
+CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y
diff --git a/zephyr/program/corsola/kingler/project.overlay b/zephyr/program/corsola/kingler/project.overlay
new file mode 100644
index 0000000000..93f06d94e2
--- /dev/null
+++ b/zephyr/program/corsola/kingler/project.overlay
@@ -0,0 +1,96 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Corsola program common DTS includes */
+
+#include "../common.dtsi"
+#include "../power_signal.dtsi"
+#include "../usba.dtsi"
+#include "../npcx_adc.dtsi"
+#include "../npcx_host_interface.dtsi"
+#include "../npcx_i2c.dtsi"
+#include "../npcx_interrupts.dtsi"
+#include "../npcx_gpio.dtsi"
+#include "../npcx_keyboard.dtsi"
+#include "../npcx_motionsense.dtsi"
+#include "../npcx_usbc.dtsi"
+#include "../npcx_default_gpio_pinctrl.dtsi"
+
+/* board override */
+/ {
+ batteries {
+ default_battery: smp_l20m3pg2 {
+ compatible = "smp,l20m3pg2", "battery-smart";
+ };
+ lgc_l20l3pg2 {
+ compatible = "lgc,l20l3pg2", "battery-smart";
+ };
+ };
+
+ pwmleds {
+ compatible = "pwm-leds";
+ pwm_led0: pwm_led_0 {
+ pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED
+ &pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED
+ &pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ };
+
+ cros-pwmleds {
+ compatible = "cros-ec,pwm-leds";
+
+ leds = <&pwm_led0>;
+
+ color-map-red = <100 0 0>;
+ color-map-green = < 0 100 0>;
+ color-map-amber = <100 20 0>;
+
+ brightness-range = <255 255 0 0 0 255>;
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ pwm_led_0@0 {
+ reg = <0>;
+ ec-led-name = "EC_LED_ID_BATTERY_LED";
+ };
+ };
+};
+
+/* Red LED */
+&pwm0_gpc3 {
+ drive-open-drain;
+};
+
+&pwm0 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm0_gpc3>;
+ pinctrl-names = "default";
+};
+
+/* Green LED */
+&pwm1_gpc2 {
+ drive-open-drain;
+};
+
+&pwm1 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm1_gpc2>;
+ pinctrl-names = "default";
+};
+
+/* Blue LED */
+&pwm2_gpc4 {
+ drive-open-drain;
+};
+
+&pwm2 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/corsola/prj_krabby.conf b/zephyr/program/corsola/krabby/project.conf
index c4cde05c16..c4cde05c16 100644
--- a/zephyr/projects/corsola/prj_krabby.conf
+++ b/zephyr/program/corsola/krabby/project.conf
diff --git a/zephyr/program/corsola/krabby/project.overlay b/zephyr/program/corsola/krabby/project.overlay
new file mode 100644
index 0000000000..6aafaf4379
--- /dev/null
+++ b/zephyr/program/corsola/krabby/project.overlay
@@ -0,0 +1,19 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Corsola program common DTS includes */
+
+#include "../common.dtsi"
+#include "../power_signal.dtsi"
+#include "../usba.dtsi"
+#include "../ite_adc.dtsi"
+#include "../battery_krabby.dtsi"
+#include "../ite_gpio.dtsi"
+#include "../ite_keyboard.dtsi"
+#include "../i2c_krabby.dtsi"
+#include "../ite_interrupts.dtsi"
+#include "../led_krabby.dtsi"
+#include "../ite_motionsense.dtsi"
+#include "../ite_usbc.dtsi"
diff --git a/zephyr/program/corsola/led_it81202_base.dtsi b/zephyr/program/corsola/led_it81202_base.dtsi
new file mode 100644
index 0000000000..582af0b092
--- /dev/null
+++ b/zephyr/program/corsola/led_it81202_base.dtsi
@@ -0,0 +1,174 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include <dt-bindings/battery.h>
+
+/ {
+ led-colors {
+ compatible = "cros-ec,led-policy";
+
+ bat-power-state-charge {
+ charge-state = "PWR_STATE_CHARGE";
+
+ color-0 {
+ led-color = <&color_battery_amber>;
+ };
+ };
+
+ bat-power-state-near-full {
+ charge-state = "PWR_STATE_CHARGE_NEAR_FULL";
+
+ color-0 {
+ led-color = <&color_battery_white>;
+ };
+ };
+
+ bat-power-state-discharge {
+ charge-state = "PWR_STATE_DISCHARGE";
+
+ color-0 {
+ led-color = <&color_battery_off>;
+ };
+ };
+
+ bat-power-state-discharge-s0-bat-low {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+ batt-lvl = <BATTERY_LEVEL_EMPTY BATTERY_LEVEL_LOW>;
+
+ color-0 {
+ led-color = <&color_battery_amber>;
+ period-ms = <1000>;
+ };
+
+ color-1 {
+ led-color = <&color_battery_off>;
+ period-ms = <3000>;
+ };
+ };
+
+ bat-power-state-error {
+ charge-state = "PWR_STATE_ERROR";
+
+ color-0 {
+ led-color = <&color_battery_amber>;
+ period-ms = <1000>;
+ };
+
+ color-1 {
+ led-color = <&color_battery_off>;
+ period-ms = <1000>;
+ };
+ };
+
+ pwr-power-state-off {
+ color-0 {
+ led-color = <&color_power_off>;
+ };
+ };
+
+ pwr-power-state-on {
+ chipset-state = "POWER_S0";
+
+ color-0 {
+ led-color = <&color_power_white>;
+ };
+ };
+
+ pwr-power-state-s3 {
+ chipset-state = "POWER_S3";
+
+ color-0 {
+ led-color = <&color_power_white>;
+ period-ms = <1000>;
+ };
+
+ color-1 {
+ led-color = <&color_power_off>;
+ period-ms = <3000>;
+ };
+ };
+ };
+
+ pwmleds {
+ compatible = "pwm-leds";
+
+ /* NOTE: &pwm number needs same with channel number */
+ led_power_white: ec_led1_odl {
+ pwms = <&pwm0 PWM_CHANNEL_0 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+ led_battery_amber: ec_led2_odl {
+ pwms = <&pwm1 PWM_CHANNEL_1 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+ led_battery_white: ec_led3_odl {
+ pwms = <&pwm2 PWM_CHANNEL_2 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+ };
+
+ pwm-led-pins {
+ compatible = "cros-ec,pwm-led-pins";
+
+ color_power_off: color-power-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_POWER_LED";
+ led-pwms = <&led_power_white>;
+ led-values = <0>;
+ };
+
+ color_power_white: color-power-white {
+ led-color = "LED_WHITE";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-id = "EC_LED_ID_POWER_LED";
+ led-pwms = <&led_power_white>;
+ led-values = <100>;
+ };
+
+ color_battery_off: color-battery-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pwms = <&led_battery_amber &led_battery_white>;
+ led-values = <0 0>;
+ };
+
+ color_battery_amber: color-battery-amber {
+ led-color = "LED_AMBER";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pwms = <&led_battery_amber &led_battery_white>;
+ led-values = <100 0>;
+ };
+
+ color_battery_white: color-battery-white {
+ led-color = "LED_WHITE";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pwms = <&led_battery_amber &led_battery_white>;
+ led-values = <0 100>;
+ };
+ };
+};
+
+/* LED1 */
+&pwm0 {
+ status = "okay";
+ prescaler-cx = <PWM_PRESCALER_C4>;
+ pinctrl-0 = <&pwm0_gpa0_default>;
+ pinctrl-names = "default";
+};
+
+/* LED2 */
+&pwm1 {
+ status = "okay";
+ prescaler-cx = <PWM_PRESCALER_C4>;
+ pinctrl-0 = <&pwm1_gpa1_default>;
+ pinctrl-names = "default";
+};
+
+/* LED3 */
+&pwm2 {
+ status = "okay";
+ prescaler-cx = <PWM_PRESCALER_C4>;
+ pinctrl-0 = <&pwm2_gpa2_default>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/corsola/led_krabby.dts b/zephyr/program/corsola/led_krabby.dtsi
index b16bff3cac..b16bff3cac 100644
--- a/zephyr/projects/corsola/led_krabby.dts
+++ b/zephyr/program/corsola/led_krabby.dtsi
diff --git a/zephyr/program/corsola/led_magikarp.dtsi b/zephyr/program/corsola/led_magikarp.dtsi
new file mode 100644
index 0000000000..f8b53a42ec
--- /dev/null
+++ b/zephyr/program/corsola/led_magikarp.dtsi
@@ -0,0 +1,137 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "led_it81202_base.dtsi"
+
+/ {
+ led-colors {
+ compatible = "cros-ec,led-policy";
+
+ /* Magikarp LED bat charge */
+ bat-power-state-charge {
+ charge-state = "PWR_STATE_CHARGE";
+ /* Battery percent range (>= Empty, <= 94%) */
+ batt-lvl = <BATTERY_LEVEL_EMPTY
+ (BATTERY_LEVEL_NEAR_FULL - 3)>;
+ color-0 {
+ led-color = <&color_battery_amber>;
+ };
+ };
+
+ bat-power-state-charge-near-full {
+ charge-state = "PWR_STATE_CHARGE";
+ /* Battery percent range (>= 95%, <= Full) */
+ batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2)
+ BATTERY_LEVEL_FULL>;
+ color-0 {
+ led-color = <&color_battery_white>;
+ };
+ };
+
+ /* Magikarp LED bat discharge */
+ bat-power-state-discharge-s0 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+ /* Battery percent range (>= 11%, <= Full) */
+ batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>;
+
+ color-0 {
+ led-color = <&color_battery_white>;
+ };
+ };
+
+
+ bat-power-state-discharge-s0-bat-low {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+ /* Battery percent range (>= Empty, <= 10%) */
+ batt-lvl = <BATTERY_LEVEL_EMPTY BATTERY_LEVEL_LOW>;
+
+ color-0 {
+ led-color = <&color_battery_amber>;
+ period-ms = <1000>;
+ };
+
+ color-1 {
+ led-color = <&color_battery_off>;
+ period-ms = <3000>;
+ };
+ };
+
+ bat-power-state-discharge-s3 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S3";
+
+ color-0 {
+ led-color = <&color_battery_white>;
+ period-ms = <1000>;
+ };
+
+ color-1 {
+ led-color = <&color_battery_off>;
+ period-ms = <3000>;
+ };
+ };
+
+ bat-power-state-discharge-s5 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S5";
+ color-0 {
+ led-color = <&color_battery_off>;
+ };
+ };
+
+ /* Magikarp LED bat error */
+ bat-power-state-error {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S0";
+
+ color-0 {
+ led-color = <&color_battery_amber>;
+ period-ms = <1000>;
+ };
+
+ color-1 {
+ led-color = <&color_battery_off>;
+ period-ms = <1000>;
+ };
+ };
+
+ bat-power-state-error-s3 {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S3";
+
+ color-0 {
+ led-color = <&color_battery_white>;
+ period-ms = <1000>;
+ };
+
+ color-1 {
+ led-color = <&color_battery_off>;
+ period-ms = <3000>;
+ };
+ };
+
+ bat-power-state-error-s5 {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S5";
+
+ color-0 {
+ led-color = <&color_battery_off>;
+ };
+ };
+ };
+
+ pwm-led-pins {
+ compatible = "cros-ec,pwm-led-pins";
+
+ /* Overwrite Power LED white to off */
+ color_power_white: color-power-white {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_POWER_LED";
+ led-pwms = <&led_power_white>;
+ led-values = <0>;
+ };
+ };
+};
diff --git a/zephyr/program/corsola/led_tentacruel.dtsi b/zephyr/program/corsola/led_tentacruel.dtsi
new file mode 100644
index 0000000000..05d49371af
--- /dev/null
+++ b/zephyr/program/corsola/led_tentacruel.dtsi
@@ -0,0 +1,119 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "led_it81202_base.dtsi"
+
+/ {
+ led-colors {
+ compatible = "cros-ec,led-policy";
+
+ /* Tentacruel LED bat charge */
+ bat-power-state-charge {
+ charge-state = "PWR_STATE_CHARGE";
+ /* Battery percent range (>= Empty, <= 94%) */
+ batt-lvl = <BATTERY_LEVEL_EMPTY
+ (BATTERY_LEVEL_NEAR_FULL - 3)>;
+ color-0 {
+ led-color = <&color_battery_amber>;
+ };
+ };
+
+ bat-power-state-charge-near-full {
+ charge-state = "PWR_STATE_CHARGE";
+ /* Battery percent range (>= 95%, <= Full) */
+ batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2)
+ BATTERY_LEVEL_FULL>;
+ color-0 {
+ led-color = <&color_battery_white>;
+ };
+ };
+
+ /* Tentacruel LED bat discharge */
+ bat-power-state-discharge {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+ /* Battery percent range (>= 11%, <= Full) */
+ batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>;
+
+ color-0 {
+ led-color = <&color_battery_white>;
+ };
+ };
+
+ bat-power-state-discharge-s3 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S3";
+
+ color-0 {
+ led-color = <&color_battery_white>;
+ period-ms = <1000>;
+ };
+
+ color-1 {
+ led-color = <&color_battery_off>;
+ period-ms = <3000>;
+ };
+ };
+
+ bat-power-state-discharge-s5 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S5";
+ color-0 {
+ led-color = <&color_battery_off>;
+ };
+ };
+
+ /* Tentacruel LED bat error */
+ bat-power-state-error {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S0";
+
+ color-0 {
+ led-color = <&color_battery_amber>;
+ period-ms = <1000>;
+ };
+
+ color-1 {
+ led-color = <&color_battery_off>;
+ period-ms = <1000>;
+ };
+ };
+
+ bat-power-state-error-s3 {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S3";
+
+ color-0 {
+ led-color = <&color_battery_white>;
+ period-ms = <1000>;
+ };
+
+ color-1 {
+ led-color = <&color_battery_off>;
+ period-ms = <3000>;
+ };
+ };
+
+ bat-power-state-error-s5 {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S5";
+
+ color-0 {
+ led-color = <&color_battery_off>;
+ };
+ };
+ };
+
+ pwm-led-pins {
+ compatible = "cros-ec,pwm-led-pins";
+
+ /* Overwrite Power LED white to off */
+ color_power_white: color-power-white {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_POWER_LED";
+ led-pwms = <&led_power_white>;
+ led-values = <0>;
+ };
+ };
+};
diff --git a/zephyr/program/corsola/magikarp/project.conf b/zephyr/program/corsola/magikarp/project.conf
new file mode 100644
index 0000000000..2fd94d6fbe
--- /dev/null
+++ b/zephyr/program/corsola/magikarp/project.conf
@@ -0,0 +1,22 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Variant config
+CONFIG_BOARD_MAGIKARP=y
+
+# USB-C
+CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n
+CONFIG_PLATFORM_EC_USB_MUX_PS8743=y
+CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000
+
+# Keyboard
+CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
+CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
+
+# Sensor
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
diff --git a/zephyr/program/corsola/magikarp/project.overlay b/zephyr/program/corsola/magikarp/project.overlay
new file mode 100644
index 0000000000..f4ca85e375
--- /dev/null
+++ b/zephyr/program/corsola/magikarp/project.overlay
@@ -0,0 +1,20 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Corsola program common DTS includes */
+
+#include "../common.dtsi"
+#include "../power_signal.dtsi"
+#include "../usba.dtsi"
+#include "../adc_magikarp.dtsi"
+#include "../battery_magikarp.dtsi"
+#include "../cbi_magikarp.dtsi"
+#include "../gpio_magikarp.dtsi"
+#include "../ite_keyboard.dtsi"
+#include "../i2c_magikarp.dtsi"
+#include "../interrupts_magikarp.dtsi"
+#include "../led_magikarp.dtsi"
+#include "../motionsense_magikarp.dtsi"
+#include "../usbc_magikarp.dtsi"
diff --git a/zephyr/projects/corsola/motionsense_magikarp.dts b/zephyr/program/corsola/motionsense_magikarp.dtsi
index 92e73bd2c6..92e73bd2c6 100644
--- a/zephyr/projects/corsola/motionsense_magikarp.dts
+++ b/zephyr/program/corsola/motionsense_magikarp.dtsi
diff --git a/zephyr/projects/corsola/motionsense_tentacruel.dts b/zephyr/program/corsola/motionsense_tentacruel.dtsi
index 68b2c023df..68b2c023df 100644
--- a/zephyr/projects/corsola/motionsense_tentacruel.dts
+++ b/zephyr/program/corsola/motionsense_tentacruel.dtsi
diff --git a/zephyr/projects/corsola/adc_kingler.dts b/zephyr/program/corsola/npcx_adc.dtsi
index 7b69abe48a..7b69abe48a 100644
--- a/zephyr/projects/corsola/adc_kingler.dts
+++ b/zephyr/program/corsola/npcx_adc.dtsi
diff --git a/zephyr/projects/corsola/default_gpio_pinctrl_kingler.dts b/zephyr/program/corsola/npcx_default_gpio_pinctrl.dtsi
index 604658a145..604658a145 100644
--- a/zephyr/projects/corsola/default_gpio_pinctrl_kingler.dts
+++ b/zephyr/program/corsola/npcx_default_gpio_pinctrl.dtsi
diff --git a/zephyr/projects/corsola/gpio_kingler.dts b/zephyr/program/corsola/npcx_gpio.dtsi
index 9a827a06dd..9a827a06dd 100644
--- a/zephyr/projects/corsola/gpio_kingler.dts
+++ b/zephyr/program/corsola/npcx_gpio.dtsi
diff --git a/zephyr/projects/corsola/host_interface_npcx.dts b/zephyr/program/corsola/npcx_host_interface.dtsi
index 14efa3c6b2..14efa3c6b2 100644
--- a/zephyr/projects/corsola/host_interface_npcx.dts
+++ b/zephyr/program/corsola/npcx_host_interface.dtsi
diff --git a/zephyr/projects/corsola/i2c_kingler.dts b/zephyr/program/corsola/npcx_i2c.dtsi
index 90390ab8a0..90390ab8a0 100644
--- a/zephyr/projects/corsola/i2c_kingler.dts
+++ b/zephyr/program/corsola/npcx_i2c.dtsi
diff --git a/zephyr/projects/corsola/interrupts_kingler.dts b/zephyr/program/corsola/npcx_interrupts.dtsi
index f3da785a60..f3da785a60 100644
--- a/zephyr/projects/corsola/interrupts_kingler.dts
+++ b/zephyr/program/corsola/npcx_interrupts.dtsi
diff --git a/zephyr/projects/corsola/npcx_keyboard.dts b/zephyr/program/corsola/npcx_keyboard.dtsi
index f9e46de1f2..f9e46de1f2 100644
--- a/zephyr/projects/corsola/npcx_keyboard.dts
+++ b/zephyr/program/corsola/npcx_keyboard.dtsi
diff --git a/zephyr/projects/corsola/motionsense_kingler.dts b/zephyr/program/corsola/npcx_motionsense.dtsi
index a7f674e01f..a7f674e01f 100644
--- a/zephyr/projects/corsola/motionsense_kingler.dts
+++ b/zephyr/program/corsola/npcx_motionsense.dtsi
diff --git a/zephyr/program/corsola/npcx_program.conf b/zephyr/program/corsola/npcx_program.conf
new file mode 100644
index 0000000000..300cbe085d
--- /dev/null
+++ b/zephyr/program/corsola/npcx_program.conf
@@ -0,0 +1,84 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+# Bring up options
+CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
+
+# Debug options and features; can be disabled to save memory or once bringup
+# is complete.
+CONFIG_SHELL_MINIMAL=n
+
+# Charger
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
+CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y
+CONFIG_PLATFORM_EC_CHARGER_PSYS=y
+CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20
+CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y
+
+# PWM
+CONFIG_PWM=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_COMMON=y
+CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y
+
+# Math
+CONFIG_PLATFORM_EC_MATH_UTIL=y
+
+# Power sequencing
+CONFIG_PLATFORM_EC_POWERSEQ_MT8186=y
+CONFIG_PLATFORM_EC_POWERSEQ_S4=n
+
+# Button
+CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y
+
+# Sensors
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
+CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y
+CONFIG_PLATFORM_EC_ACCEL_FIFO=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
+CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
+CONFIG_PLATFORM_EC_LID_ANGLE=y
+CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
+CONFIG_PLATFORM_EC_LID_SWITCH=y
+CONFIG_PLATFORM_EC_MOTIONSENSE=y
+CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
+CONFIG_PLATFORM_EC_TABLET_MODE=y
+CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
+
+# USBC
+CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n
+CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_OFF_DELAY=15000
+CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_ON_DELAY=15000
+CONFIG_PLATFORM_EC_USBC_PPC=y
+CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y
+CONFIG_PLATFORM_EC_USBC_PPC_RT1718S=y
+CONFIG_PLATFORM_EC_USB_MUX_PS8743=y
+CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
+CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL=y
+CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=2
+CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447_AUX_PU_PD=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_BY_BOARD=y
+
+# External power
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
+
+# Keyboard
+CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y
+
+CONFIG_SYSCON=y
+
+CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n
diff --git a/zephyr/projects/corsola/usbc_kingler.dts b/zephyr/program/corsola/npcx_usbc.dtsi
index 18bc6ce303..18bc6ce303 100644
--- a/zephyr/projects/corsola/usbc_kingler.dts
+++ b/zephyr/program/corsola/npcx_usbc.dtsi
diff --git a/zephyr/program/corsola/power_signal.dtsi b/zephyr/program/corsola/power_signal.dtsi
new file mode 100644
index 0000000000..5037bac228
--- /dev/null
+++ b/zephyr/program/corsola/power_signal.dtsi
@@ -0,0 +1,26 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ power_signal_list: power-signal-list {
+ compatible = "mediatek,mt8186-power-signal-list";
+ ap_in_rst {
+ power-enum-name = "AP_IN_RST";
+ power-gpio-pin = <&ap_sysrst_odl_r>;
+ };
+ ap_in_s3 {
+ power-enum-name = "AP_IN_S3";
+ power-gpio-pin = <&ap_in_sleep_l>;
+ };
+ ap_wdt_asserted {
+ power-enum-name = "AP_WDT_ASSERTED";
+ power-gpio-pin = <&ap_ec_wdtrst_l>;
+ };
+ ap_warm_rst_req {
+ power-enum-name = "AP_WARM_RST_REQ";
+ power-gpio-pin = <&ap_ec_warm_rst_req>;
+ };
+ };
+};
diff --git a/zephyr/program/corsola/program.conf b/zephyr/program/corsola/program.conf
new file mode 100644
index 0000000000..86bd30aaed
--- /dev/null
+++ b/zephyr/program/corsola/program.conf
@@ -0,0 +1,96 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+
+# http://google3/hardware/standards/usb/
+CONFIG_PLATFORM_EC_USB_PID=0x505C
+
+# CROS EC
+CONFIG_CROS_EC=y
+CONFIG_PLATFORM_EC=y
+CONFIG_PLATFORM_EC_SWITCH=y
+CONFIG_SHIMMED_TASKS=y
+
+# AP SoC configuration
+CONFIG_AP=y
+CONFIG_AP_ARM_MTK_MT8186=y
+
+# Variant config
+CONFIG_VARIANT_CORSOLA_DB_DETECTION=y
+
+# Shell features
+CONFIG_KERNEL_SHELL=y
+CONFIG_SHELL_HELP=y
+CONFIG_SHELL_HISTORY=y
+CONFIG_SHELL_TAB=y
+CONFIG_SHELL_TAB_AUTOCOMPLETION=y
+
+# CBI
+CONFIG_EEPROM=y
+CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
+
+# Keyboard
+CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y
+CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
+
+# MKBP
+CONFIG_PLATFORM_EC_MKBP_EVENT=y
+CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
+CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y
+
+# EFS2
+CONFIG_PLATFORM_EC_VBOOT_EFS2=y
+
+# USB
+CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
+CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n
+CONFIG_PLATFORM_EC_USB_PD_USB4=n
+CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB_CUSTOM_HOOK=y
+
+# USB-C
+CONFIG_PLATFORM_EC_USBC=y
+CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y
+CONFIG_PLATFORM_EC_USB_PD_DPS=y
+CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y
+CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO_CUSTOM=y
+CONFIG_PLATFORM_EC_USB_PD_FRS=y
+CONFIG_PLATFORM_EC_USB_PD_CLEAR_HARD_RESET_STATUS=y
+
+# Power Seq
+CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y
+CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
+CONFIG_PLATFORM_EC_POWERSEQ=y
+CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y
+CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
+CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
+
+# Optional features
+CONFIG_FLASH_SHELL=n
+
+# EEPROM
+CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
+
+# Host Commands
+CONFIG_PLATFORM_EC_HOSTCMD=y
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
+CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
+CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
+CONFIG_PLATFORM_EC_BATTERY_SMART=y
+CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV=9000
+CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y
+CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y
+
+# Charger
+CONFIG_PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201=y
+CONFIG_PLATFORM_EC_CHARGE_MANAGER=y
+# b:257167723: Adapter output current exceeds the spec on heavy-load.
+# Preserve a margin in case of charger overdraw.
+CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=3
+
+# Button
+CONFIG_PLATFORM_EC_CMD_BUTTON=y
+CONFIG_PLATFORM_EC_POWER_BUTTON=y
+CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
diff --git a/zephyr/program/corsola/src/board.c b/zephyr/program/corsola/src/board.c
new file mode 100644
index 0000000000..bd0ee739b5
--- /dev/null
+++ b/zephyr/program/corsola/src/board.c
@@ -0,0 +1,36 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "baseboard_usbc_config.h"
+#include "console.h"
+#include "hooks.h"
+#include "typec_control.h"
+#include "usb_dp_alt_mode.h"
+#include "usb_mux.h"
+#include "usb_pd.h"
+#include "usbc_ppc.h"
+
+#define CPRINTS(format, args...) cprints(CC_USB, format, ##args)
+
+static void ccd_interrupt_deferred(void)
+{
+ /*
+ * If CCD_MODE_ODL asserts, it means there's a debug accessory connected
+ * and we should enable the SBU FETs.
+ */
+ typec_set_sbu(CONFIG_CCD_USBC_PORT_NUMBER, 1);
+
+ /* Mux DP AUX away when CCD enabled to prevent the AUX channel
+ * interferes the SBU pins.
+ */
+ CPRINTS("CCD Enabled, mux DP_AUX_PATH_SEL to 1");
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), 1);
+}
+DECLARE_DEFERRED(ccd_interrupt_deferred);
+
+void ccd_interrupt(enum gpio_signal signal)
+{
+ hook_call_deferred(&ccd_interrupt_deferred_data, 0);
+}
diff --git a/zephyr/program/corsola/src/board_chipset.c b/zephyr/program/corsola/src/board_chipset.c
new file mode 100644
index 0000000000..e534bfafcb
--- /dev/null
+++ b/zephyr/program/corsola/src/board_chipset.c
@@ -0,0 +1,51 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Corsola baseboard-chipset specific configuration */
+
+#include "gpio.h"
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/init.h>
+
+#include <ap_power/ap_power.h>
+
+static void board_backlight_handler(struct ap_power_ev_callback *cb,
+ struct ap_power_ev_data data)
+{
+ int value;
+
+ switch (data.event) {
+ default:
+ return;
+
+ case AP_POWER_RESUME:
+ /* Called on AP S3 -> S0 transition */
+ value = 1;
+ break;
+
+ case AP_POWER_SUSPEND:
+ /* Called on AP S0 -> S3 transition */
+ value = 0;
+ break;
+ }
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_bl_en_od), value);
+}
+
+static int install_backlight_handler(const struct device *unused)
+{
+ static struct ap_power_ev_callback cb;
+
+ /*
+ * Add a callback for suspend/resume to
+ * control the keyboard backlight.
+ */
+ ap_power_ev_init_callback(&cb, board_backlight_handler,
+ AP_POWER_RESUME | AP_POWER_SUSPEND);
+ ap_power_ev_add_callback(&cb);
+ return 0;
+}
+
+SYS_INIT(install_backlight_handler, APPLICATION, 1);
diff --git a/zephyr/program/corsola/src/hibernate.c b/zephyr/program/corsola/src/hibernate.c
new file mode 100644
index 0000000000..2b7ed9795d
--- /dev/null
+++ b/zephyr/program/corsola/src/hibernate.c
@@ -0,0 +1,22 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "charger.h"
+#include "driver/charger/isl923x_public.h"
+#include "system.h"
+
+#include <zephyr/drivers/gpio.h>
+
+/* Corsola board specific hibernate implementation */
+__override void board_hibernate(void)
+{
+#ifdef CONFIG_CHARGER_ISL9238C
+ isl9238c_hibernate(CHARGER_SOLO);
+#endif
+}
+
+__override void board_hibernate_late(void)
+{
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_ulp), 1);
+}
diff --git a/zephyr/program/corsola/src/kingler/board_steelix.c b/zephyr/program/corsola/src/kingler/board_steelix.c
new file mode 100644
index 0000000000..b4faf5af0c
--- /dev/null
+++ b/zephyr/program/corsola/src/kingler/board_steelix.c
@@ -0,0 +1,76 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Board re-init for Rusty board
+ * Rusty shares the firmware with Steelix.
+ * Steelix is convertible but Rusty is clamshell
+ * so some functions should be disabled for clamshell.
+ */
+#include "accelgyro.h"
+#include "common.h"
+#include "cros_cbi.h"
+#include "driver/accelgyro_bmi3xx.h"
+#include "driver/accelgyro_lsm6dsm.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "motion_sense.h"
+#include "motionsense_sensors.h"
+#include "tablet_mode.h"
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_REGISTER(board_init, LOG_LEVEL_ERR);
+
+static bool board_is_clamshell;
+
+static void board_setup_init(void)
+{
+ int ret;
+ uint32_t val;
+
+ ret = cros_cbi_get_fw_config(FORM_FACTOR, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR);
+ return;
+ }
+ if (val == CLAMSHELL) {
+ board_is_clamshell = true;
+ motion_sensor_count = 0;
+ gmr_tablet_switch_disable();
+ }
+}
+DECLARE_HOOK(HOOK_INIT, board_setup_init, HOOK_PRIO_PRE_DEFAULT);
+
+static void disable_base_imu_irq(void)
+{
+ if (board_is_clamshell) {
+ gpio_disable_dt_interrupt(
+ GPIO_INT_FROM_NODELABEL(int_base_imu));
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(base_imu_int_l),
+ GPIO_INPUT | GPIO_PULL_UP);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, disable_base_imu_irq, HOOK_PRIO_POST_DEFAULT);
+
+static bool base_use_alt_sensor;
+
+void motion_interrupt(enum gpio_signal signal)
+{
+ if (base_use_alt_sensor) {
+ lsm6dsm_interrupt(signal);
+ } else {
+ bmi3xx_interrupt(signal);
+ }
+}
+
+static void alt_sensor_init(void)
+{
+ base_use_alt_sensor = cros_cbi_ssfc_check_match(
+ CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1)));
+
+ motion_sensors_check_ssfc();
+}
+DECLARE_HOOK(HOOK_INIT, alt_sensor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/projects/corsola/src/kingler/button.c b/zephyr/program/corsola/src/kingler/button.c
index 920069bef6..920069bef6 100644
--- a/zephyr/projects/corsola/src/kingler/button.c
+++ b/zephyr/program/corsola/src/kingler/button.c
diff --git a/zephyr/program/corsola/src/kingler/i2c.c b/zephyr/program/corsola/src/kingler/i2c.c
new file mode 100644
index 0000000000..5bd8aef7d5
--- /dev/null
+++ b/zephyr/program/corsola/src/kingler/i2c.c
@@ -0,0 +1,21 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "i2c.h"
+#include "i2c/i2c.h"
+
+/* Kingler and Steelix board specific i2c implementation */
+
+#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
+int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc)
+{
+ return (i2c_get_device_for_port(cmd_desc->port) ==
+ i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY) ||
+ i2c_get_device_for_port(cmd_desc->port) ==
+ i2c_get_device_for_port(I2C_PORT_EEPROM) ||
+ i2c_get_device_for_port(cmd_desc->port) ==
+ i2c_get_device_for_port(I2C_PORT_USB_C0));
+}
+#endif
diff --git a/zephyr/projects/corsola/src/kingler/led.c b/zephyr/program/corsola/src/kingler/led.c
index 4e2c5b12fb..4e2c5b12fb 100644
--- a/zephyr/projects/corsola/src/kingler/led.c
+++ b/zephyr/program/corsola/src/kingler/led.c
diff --git a/zephyr/program/corsola/src/kingler/led_steelix.c b/zephyr/program/corsola/src/kingler/led_steelix.c
new file mode 100644
index 0000000000..1188c4f95e
--- /dev/null
+++ b/zephyr/program/corsola/src/kingler/led_steelix.c
@@ -0,0 +1,181 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Battery LED control for Steelix
+ */
+
+#include "board_led.h"
+#include "common.h"
+#include "cros_cbi.h"
+#include "led_common.h"
+#include "led_onoff_states.h"
+#include "util.h"
+
+#include <zephyr/drivers/pwm.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_REGISTER(board_led, LOG_LEVEL_ERR);
+
+#define BOARD_LED_PWM_PERIOD_NS BOARD_LED_HZ_TO_PERIOD_NS(100)
+
+static const struct board_led_pwm_dt_channel board_led_battery_red =
+ BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_battery_red));
+static const struct board_led_pwm_dt_channel board_led_battery_green =
+ BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_battery_green));
+static const struct board_led_pwm_dt_channel board_led_power_white =
+ BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_power_white));
+
+__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_RED,
+ LED_INDEFINITE } },
+ [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER,
+ LED_INDEFINITE } },
+ [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN,
+ LED_INDEFINITE } },
+ [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_DISCHARGE_S0_BAT_LOW] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC },
+ { LED_OFF, 1 * LED_ONE_SEC } },
+ [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC },
+ { EC_LED_COLOR_GREEN,
+ 2 * LED_ONE_SEC } },
+ };
+
+__override const struct led_descriptor
+ led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = {
+ [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } },
+ [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE,
+ 3 * LED_ONE_SEC },
+ { LED_OFF, 0.5 * LED_ONE_SEC } },
+ [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE,
+ 3 * LED_ONE_SEC },
+ { LED_OFF,
+ 0.5 * LED_ONE_SEC } },
+ [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } },
+ };
+
+const enum ec_led_id supported_led_ids[] = {
+ EC_LED_ID_BATTERY_LED,
+ EC_LED_ID_POWER_LED,
+};
+
+const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
+
+static void board_led_pwm_set_duty(const struct board_led_pwm_dt_channel *ch,
+ int percent)
+{
+ uint32_t pulse_ns;
+ int rv;
+
+ if (!device_is_ready(ch->dev)) {
+ LOG_ERR("PWM device %s not ready", ch->dev->name);
+ return;
+ }
+
+ pulse_ns = DIV_ROUND_NEAREST(BOARD_LED_PWM_PERIOD_NS * percent, 100);
+
+ LOG_DBG("Board LED PWM %s set percent (%d), pulse %d", ch->dev->name,
+ percent, pulse_ns);
+
+ rv = pwm_set(ch->dev, ch->channel, BOARD_LED_PWM_PERIOD_NS, pulse_ns,
+ ch->flags);
+ if (rv) {
+ LOG_ERR("pwm_set() failed %s (%d)", ch->dev->name, rv);
+ }
+}
+
+static bool device_is_clamshell(void)
+{
+ int ret;
+ uint32_t val;
+
+ ret = cros_cbi_get_fw_config(FORM_FACTOR, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR);
+ return false;
+ }
+
+ return val == CLAMSHELL;
+}
+
+__override void led_set_color_battery(enum ec_led_colors color)
+{
+ switch (color) {
+ case EC_LED_COLOR_RED:
+ board_led_pwm_set_duty(&board_led_battery_red, 100);
+ board_led_pwm_set_duty(&board_led_battery_green, 0);
+ break;
+ case EC_LED_COLOR_GREEN:
+ board_led_pwm_set_duty(&board_led_battery_red, 0);
+ board_led_pwm_set_duty(&board_led_battery_green, 100);
+ break;
+ case EC_LED_COLOR_AMBER:
+ board_led_pwm_set_duty(&board_led_battery_red, 100);
+ board_led_pwm_set_duty(&board_led_battery_green, 20);
+ break;
+ default: /* LED_OFF and other unsupported colors */
+ board_led_pwm_set_duty(&board_led_battery_red, 0);
+ board_led_pwm_set_duty(&board_led_battery_green, 0);
+ break;
+ }
+}
+
+__override void led_set_color_power(enum ec_led_colors color)
+{
+ if (device_is_clamshell()) {
+ board_led_pwm_set_duty(&board_led_power_white, 0);
+ } else {
+ switch (color) {
+ case EC_LED_COLOR_WHITE:
+ board_led_pwm_set_duty(&board_led_power_white, 100);
+ break;
+ default:
+ board_led_pwm_set_duty(&board_led_power_white, 0);
+ 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_RED] = 1;
+ brightness_range[EC_LED_COLOR_GREEN] = 1;
+ brightness_range[EC_LED_COLOR_AMBER] = 1;
+ } else if (led_id == EC_LED_ID_POWER_LED) {
+ if (device_is_clamshell()) {
+ brightness_range[EC_LED_COLOR_WHITE] = 0;
+ } else {
+ 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_RED] != 0) {
+ led_set_color_battery(EC_LED_COLOR_RED);
+ } else if (brightness[EC_LED_COLOR_GREEN] != 0) {
+ led_set_color_battery(EC_LED_COLOR_GREEN);
+ } else if (brightness[EC_LED_COLOR_AMBER] != 0) {
+ led_set_color_battery(EC_LED_COLOR_AMBER);
+ } else {
+ led_set_color_battery(LED_OFF);
+ }
+ } else if (led_id == EC_LED_ID_POWER_LED) {
+ if (brightness[EC_LED_COLOR_WHITE] != 0) {
+ led_set_color_power(EC_LED_COLOR_WHITE);
+ } else {
+ led_set_color_power(LED_OFF);
+ }
+ }
+
+ return EC_SUCCESS;
+}
diff --git a/zephyr/program/corsola/src/kingler/usb_pd_policy.c b/zephyr/program/corsola/src/kingler/usb_pd_policy.c
new file mode 100644
index 0000000000..c9e26f6681
--- /dev/null
+++ b/zephyr/program/corsola/src/kingler/usb_pd_policy.c
@@ -0,0 +1,73 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "baseboard_usbc_config.h"
+#include "charge_manager.h"
+#include "console.h"
+#include "driver/ppc/rt1718s.h"
+#include "system.h"
+#include "usb_mux.h"
+#include "usb_pd.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+void pd_power_supply_reset(int port)
+{
+ int prev_en;
+
+ prev_en = ppc_is_sourcing_vbus(port);
+
+ if (port == USBC_PORT_C1) {
+ rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SOURCE, 0);
+ }
+
+ /* Disable VBUS. */
+ ppc_vbus_source_enable(port, 0);
+
+ /* Enable discharge if we were previously sourcing 5V */
+ if (prev_en) {
+ pd_set_vbus_discharge(port, 1);
+ }
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ int rv;
+
+ /* Disable charging. */
+ rv = ppc_vbus_sink_enable(port, 0);
+ if (rv) {
+ return rv;
+ }
+
+ pd_set_vbus_discharge(port, 0);
+
+ /* Provide Vbus. */
+ if (port == USBC_PORT_C1) {
+ rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SOURCE, 1);
+ }
+
+ rv = ppc_vbus_source_enable(port, 1);
+ if (rv) {
+ return rv;
+ }
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
+}
+
+int pd_snk_is_vbus_provided(int port)
+{
+ /* TODO: use ADC? */
+ return tcpm_check_vbus_level(port, VBUS_PRESENT);
+}
diff --git a/zephyr/program/corsola/src/kingler/usbc_config.c b/zephyr/program/corsola/src/kingler/usbc_config.c
new file mode 100644
index 0000000000..2e05d3720e
--- /dev/null
+++ b/zephyr/program/corsola/src/kingler/usbc_config.c
@@ -0,0 +1,317 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Kingler board-specific USB-C configuration */
+
+/* TODO(b/220196310): Create GPIO driver for RT17181S TCPC */
+#ifdef __REQUIRE_ZEPHYR_GPIOS__
+#undef __REQUIRE_ZEPHYR_GPIOS__
+#endif
+
+#include "baseboard_usbc_config.h"
+#include "charger.h"
+#include "console.h"
+#include "driver/bc12/pi3usb9201_public.h"
+#include "driver/charger/isl923x_public.h"
+#include "driver/ppc/nx20p348x.h"
+#include "driver/ppc/rt1718s.h"
+#include "driver/tcpm/anx7447.h"
+#include "driver/tcpm/rt1718s.h"
+#include "driver/usb_mux/ps8743.h"
+#include "gpio.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "timer.h"
+#include "usb_charge.h"
+#include "usb_mux.h"
+#include "usb_pd_tcpm.h"
+#include "usbc_ppc.h"
+#include "variant_db_detection.h"
+
+#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
+
+/* USB Mux */
+
+/* USB Mux C1 : board_init of PS8743 */
+int ps8743_mux_1_board_init(const struct usb_mux *me)
+{
+ ps8743_tune_usb_eq(me, PS8743_USB_EQ_TX_3_6_DB,
+ PS8743_USB_EQ_RX_16_0_DB);
+
+ return EC_SUCCESS;
+}
+
+void board_usb_mux_init(void)
+{
+ if (corsola_get_db_type() == CORSOLA_DB_TYPEC) {
+ /* Disable DCI function. This is not needed for ARM. */
+ ps8743_field_update(usb_muxes[1].mux, PS8743_REG_DCI_CONFIG_2,
+ PS8743_AUTO_DCI_MODE_MASK,
+ PS8743_AUTO_DCI_MODE_FORCE_USB);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, board_usb_mux_init, HOOK_PRIO_INIT_I2C + 1);
+
+void board_tcpc_init(void)
+{
+ /* Only reset TCPC if not sysjump */
+ if (!system_jumped_late()) {
+ /* TODO(crosbug.com/p/61098): How long do we need to wait? */
+ board_reset_pd_mcu();
+ }
+
+ /* Enable TCPC interrupts */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc));
+ if (corsola_get_db_type() == CORSOLA_DB_TYPEC) {
+ gpio_enable_dt_interrupt(
+ GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc));
+ }
+
+ /* Enable BC1.2 interrupts. */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12));
+
+ /*
+ * Initialize HPD to low; after sysjump SOC needs to see
+ * HPD pulse to enable video path
+ */
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) {
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C);
+
+__override int board_rt1718s_init(int port)
+{
+ static bool gpio_initialized;
+
+ if (!system_jumped_late() && !gpio_initialized) {
+ /* set GPIO 1~3 as push pull, as output, output low. */
+ rt1718s_gpio_set_flags(port, RT1718S_GPIO1, GPIO_OUT_LOW);
+ rt1718s_gpio_set_flags(port, RT1718S_GPIO2, GPIO_OUT_LOW);
+ rt1718s_gpio_set_flags(port, RT1718S_GPIO3, GPIO_OUT_LOW);
+ gpio_initialized = true;
+ }
+
+ /* gpio1 low, gpio2 output high when receiving frs signal */
+ RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_GPIO1_VBUS_CTRL,
+ RT1718S_GPIO1_VBUS_CTRL_FRS_RX_VBUS,
+ 0));
+ RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_GPIO2_VBUS_CTRL,
+ RT1718S_GPIO2_VBUS_CTRL_FRS_RX_VBUS,
+ 0xFF));
+
+ /* Trigger GPIO 1/2 change when FRS signal received */
+ RETURN_ERROR(rt1718s_update_bits8(
+ port, RT1718S_FRS_CTRL3,
+ RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO2 |
+ RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO1,
+ RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO2 |
+ RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO1));
+ /* Set FRS signal detect time to 46.875us */
+ RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_FRS_CTRL1,
+ RT1718S_FRS_CTRL1_FRSWAPRX_MASK,
+ 0xFF));
+
+ /* Disable BC1.2 SRC mode */
+ RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_RT2_BC12_SRC_FUNC,
+ RT1718S_RT2_BC12_SRC_FUNC_BC12_SRC_EN,
+ 0));
+
+ return EC_SUCCESS;
+}
+
+__override int board_rt1718s_set_frs_enable(int port, int enable)
+{
+ if (port == USBC_PORT_C1)
+ /*
+ * Use set_flags (implemented by a single i2c write) instead
+ * of set_level (= i2c_update) to save one read operation in
+ * FRS path.
+ */
+ rt1718s_gpio_set_flags(port, GPIO_EN_USB_C1_FRS,
+ enable ? GPIO_OUT_HIGH : GPIO_OUT_LOW);
+ return EC_SUCCESS;
+}
+
+void board_reset_pd_mcu(void)
+{
+ CPRINTS("Resetting TCPCs...");
+ /* reset C0 ANX3447 */
+ /* Assert reset */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst), 1);
+ msleep(1);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst), 0);
+ /* After TEST_R release, anx7447/3447 needs 2ms to finish eFuse
+ * loading.
+ */
+ msleep(2);
+
+ /* reset C1 RT1718s */
+ rt1718s_sw_reset(USBC_PORT_C1);
+}
+
+/* Used by Vbus discharge common code with CONFIG_USB_PD_DISCHARGE */
+int board_vbus_source_enabled(int port)
+{
+ return ppc_is_sourcing_vbus(port);
+}
+
+__override int board_rt1718s_set_snk_enable(int port, int enable)
+{
+ if (port == USBC_PORT_C1) {
+ rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SINK, enable);
+ }
+
+ return EC_SUCCESS;
+}
+
+int board_set_active_charge_port(int port)
+{
+ int i;
+ bool is_valid_port =
+ (port >= 0 && port < board_get_adjusted_usb_pd_port_count());
+ /* adjust the actual port count when not the type-c db connected. */
+
+ if (!is_valid_port && port != CHARGE_PORT_NONE) {
+ return EC_ERROR_INVAL;
+ }
+
+ if (port == CHARGE_PORT_NONE) {
+ CPRINTS("Disabling all charger ports");
+
+ /* Disable all ports. */
+ for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) {
+ /*
+ * Do not return early if one fails otherwise we can
+ * get into a boot loop assertion failure.
+ */
+ if (ppc_vbus_sink_enable(i, 0)) {
+ CPRINTS("Disabling C%d as sink failed.", i);
+ }
+ }
+
+ return EC_SUCCESS;
+ }
+
+ /* Check if the port is sourcing VBUS. */
+ if (ppc_is_sourcing_vbus(port)) {
+ CPRINTS("Skip enable C%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+ CPRINTS("New charge port: C%d", port);
+
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) {
+ if (i == port) {
+ continue;
+ }
+
+ if (ppc_vbus_sink_enable(i, 0)) {
+ CPRINTS("C%d: sink path disable failed.", i);
+ }
+ }
+
+ /* Enable requested charge port. */
+ if (ppc_vbus_sink_enable(port, 1)) {
+ CPRINTS("C%d: sink path enable failed.", port);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ return EC_SUCCESS;
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ uint16_t status = 0;
+
+ if (!gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl))) {
+ if (!gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst))) {
+ status |= PD_STATUS_TCPC_ALERT_0;
+ }
+ }
+
+ if (!gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl))) {
+ return status |= PD_STATUS_TCPC_ALERT_1;
+ }
+ return status;
+}
+
+void tcpc_alert_event(enum gpio_signal signal)
+{
+ int port;
+
+ switch (signal) {
+ case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_tcpc_int_odl)):
+ port = 0;
+ break;
+ case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c1_tcpc_int_odl)):
+ port = 1;
+ break;
+ default:
+ return;
+ }
+
+ schedule_deferred_pd_interrupt(port);
+}
+
+void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_ppc_int_odl)):
+ ppc_chips[0].drv->interrupt(0);
+ break;
+ case GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl)):
+ ppc_chips[1].drv->interrupt(1);
+ break;
+ default:
+ break;
+ }
+}
+
+void bc12_interrupt(enum gpio_signal signal)
+{
+ usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
+}
+
+__override int board_get_vbus_voltage(int port)
+{
+ int voltage = 0;
+ int rv;
+
+ switch (port) {
+ case USBC_PORT_C0:
+ rv = tcpc_config[USBC_PORT_C0].drv->get_vbus_voltage(port,
+ &voltage);
+ if (rv)
+ return 0;
+ break;
+ case USBC_PORT_C1:
+ rt1718s_get_adc(port, RT1718S_ADC_VBUS1, &voltage);
+ break;
+ default:
+ return 0;
+ }
+ return voltage;
+}
+
+__override int board_nx20p348x_init(int port)
+{
+ int rv;
+
+ rv = i2c_update8(ppc_chips[port].i2c_port,
+ ppc_chips[port].i2c_addr_flags,
+ NX20P348X_DEVICE_CONTROL_REG, NX20P348X_CTRL_LDO_SD,
+ MASK_SET);
+ return rv;
+}
diff --git a/zephyr/program/corsola/src/krabby/charger_workaround.c b/zephyr/program/corsola/src/krabby/charger_workaround.c
new file mode 100644
index 0000000000..be046a947b
--- /dev/null
+++ b/zephyr/program/corsola/src/krabby/charger_workaround.c
@@ -0,0 +1,93 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charger.h"
+#include "driver/charger/rt9490.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "system.h"
+
+#include <zephyr/sys/util.h>
+
+/*
+ * This workaround and the board id checks only apply to krabby and early
+ * tentacruel devices.
+ * Newer project should have all of these fixed.
+ */
+BUILD_ASSERT(IS_ENABLED(CONFIG_BOARD_KRABBY) ||
+ IS_ENABLED(CONFIG_BOARD_TENTACRUEL) || IS_ENABLED(CONFIG_TEST));
+
+/* b/194967754#comment5: work around for IBUS ADC unstable issue */
+static void ibus_adc_workaround(void)
+{
+ if (system_get_board_version() != 0) {
+ return;
+ }
+
+ i2c_update8(chg_chips[CHARGER_SOLO].i2c_port,
+ chg_chips[CHARGER_SOLO].i2c_addr_flags,
+ RT9490_REG_ADC_CHANNEL0, RT9490_VSYS_ADC_DIS, MASK_SET);
+
+ rt9490_enable_hidden_mode(CHARGER_SOLO, true);
+ /* undocumented registers... */
+ i2c_write8(chg_chips[CHARGER_SOLO].i2c_port,
+ chg_chips[CHARGER_SOLO].i2c_addr_flags, 0x52, 0xC4);
+
+ i2c_update8(chg_chips[CHARGER_SOLO].i2c_port,
+ chg_chips[CHARGER_SOLO].i2c_addr_flags,
+ RT9490_REG_ADC_CHANNEL0, RT9490_VSYS_ADC_DIS, MASK_CLR);
+ rt9490_enable_hidden_mode(CHARGER_SOLO, false);
+}
+
+/* b/214880220#comment44: lock i2c at 400khz */
+static void i2c_speed_workaround(void)
+{
+ if (system_get_board_version() >= 3) {
+ return;
+ }
+
+ rt9490_enable_hidden_mode(CHARGER_SOLO, true);
+ /* Set to Auto mode, default run at 400kHz */
+ i2c_write8(chg_chips[CHARGER_SOLO].i2c_port,
+ chg_chips[CHARGER_SOLO].i2c_addr_flags, 0x71, 0x22);
+ /* Manually select for 400kHz, valid only when 0x71[7] == 1 */
+ i2c_write8(chg_chips[CHARGER_SOLO].i2c_port,
+ chg_chips[CHARGER_SOLO].i2c_addr_flags, 0xF7, 0x14);
+ rt9490_enable_hidden_mode(CHARGER_SOLO, false);
+}
+
+static void eoc_deglitch_workaround(void)
+{
+ if (system_get_board_version() != 1) {
+ return;
+ }
+
+ /* set end-of-charge deglitch time to 2ms */
+ i2c_update8(chg_chips[CHARGER_SOLO].i2c_port,
+ chg_chips[CHARGER_SOLO].i2c_addr_flags,
+ RT9490_REG_ADD_CTRL0, RT9490_TD_EOC, MASK_CLR);
+}
+
+static void disable_safety_timer(void)
+{
+ if (system_get_board_version() >= 2) {
+ return;
+ }
+ /* Disable charge timer */
+ i2c_write8(chg_chips[CHARGER_SOLO].i2c_port,
+ chg_chips[CHARGER_SOLO].i2c_addr_flags,
+ RT9490_REG_SAFETY_TMR_CTRL,
+ RT9490_EN_TRICHG_TMR | RT9490_EN_PRECHG_TMR |
+ RT9490_EN_FASTCHG_TMR);
+}
+
+static void board_rt9490_workaround(void)
+{
+ ibus_adc_workaround();
+ i2c_speed_workaround();
+ eoc_deglitch_workaround();
+ disable_safety_timer();
+}
+DECLARE_HOOK(HOOK_INIT, board_rt9490_workaround, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/program/corsola/src/krabby/hooks.c b/zephyr/program/corsola/src/krabby/hooks.c
new file mode 100644
index 0000000000..2582998b9c
--- /dev/null
+++ b/zephyr/program/corsola/src/krabby/hooks.c
@@ -0,0 +1,91 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charger.h"
+#include "driver/charger/rt9490.h"
+#include "extpower.h"
+#include "gpio.h"
+#include "hooks.h"
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/pinctrl.h>
+#include <zephyr/init.h>
+
+#include <ap_power/ap_power.h>
+
+#define I2C3_NODE DT_NODELABEL(i2c3)
+PINCTRL_DT_DEFINE(I2C3_NODE);
+
+static void board_i2c3_ctrl(bool enable)
+{
+ if (DEVICE_DT_GET(
+ DT_GPIO_CTLR_BY_IDX(DT_NODELABEL(i2c3), scl_gpios, 0)) ==
+ DEVICE_DT_GET(DT_NODELABEL(gpiof))) {
+ const struct pinctrl_dev_config *pcfg =
+ PINCTRL_DT_DEV_CONFIG_GET(I2C3_NODE);
+
+ if (enable) {
+ pinctrl_apply_state(pcfg, PINCTRL_STATE_DEFAULT);
+ } else {
+ pinctrl_apply_state(pcfg, PINCTRL_STATE_SLEEP);
+ }
+ }
+}
+
+static void board_enable_i2c3(void)
+{
+ board_i2c3_ctrl(1);
+}
+DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_enable_i2c3, HOOK_PRIO_FIRST);
+
+static void board_disable_i2c3(void)
+{
+ board_i2c3_ctrl(0);
+}
+DECLARE_HOOK(HOOK_CHIPSET_HARD_OFF, board_disable_i2c3, HOOK_PRIO_LAST);
+
+static void board_suspend_handler(struct ap_power_ev_callback *cb,
+ struct ap_power_ev_data data)
+{
+ int value;
+
+ switch (data.event) {
+ default:
+ return;
+
+ case AP_POWER_RESUME:
+ value = 1;
+ break;
+
+ case AP_POWER_SUSPEND:
+ value = 0;
+ break;
+ }
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_5v_usm), value);
+}
+
+static int install_suspend_handler(const struct device *unused)
+{
+ static struct ap_power_ev_callback cb;
+
+ /*
+ * Add a callback for suspend/resume.
+ */
+ ap_power_ev_init_callback(&cb, board_suspend_handler,
+ AP_POWER_RESUME | AP_POWER_SUSPEND);
+ ap_power_ev_add_callback(&cb);
+ return 0;
+}
+
+SYS_INIT(install_suspend_handler, APPLICATION, 1);
+
+static void board_hook_ac_change(void)
+{
+ if (system_get_board_version() >= 1) {
+ rt9490_enable_adc(CHARGER_SOLO, extpower_is_present());
+ }
+}
+DECLARE_HOOK(HOOK_AC_CHANGE, board_hook_ac_change, HOOK_PRIO_DEFAULT);
+DECLARE_HOOK(HOOK_INIT, board_hook_ac_change, HOOK_PRIO_LAST);
diff --git a/zephyr/program/corsola/src/krabby/i2c.c b/zephyr/program/corsola/src/krabby/i2c.c
new file mode 100644
index 0000000000..66b88b09b0
--- /dev/null
+++ b/zephyr/program/corsola/src/krabby/i2c.c
@@ -0,0 +1,19 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "i2c.h"
+#include "i2c/i2c.h"
+
+/* Krabby board specific i2c implementation */
+
+#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
+int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc)
+{
+ return (i2c_get_device_for_port(cmd_desc->port) ==
+ i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY) ||
+ i2c_get_device_for_port(cmd_desc->port) ==
+ i2c_get_device_for_port(I2C_PORT_EEPROM));
+}
+#endif
diff --git a/zephyr/projects/corsola/src/krabby/keyboard_magikarp.c b/zephyr/program/corsola/src/krabby/keyboard_magikarp.c
index bcb706bba3..bcb706bba3 100644
--- a/zephyr/projects/corsola/src/krabby/keyboard_magikarp.c
+++ b/zephyr/program/corsola/src/krabby/keyboard_magikarp.c
diff --git a/zephyr/program/corsola/src/krabby/ppc_krabby.c b/zephyr/program/corsola/src/krabby/ppc_krabby.c
new file mode 100644
index 0000000000..dbbfee57b5
--- /dev/null
+++ b/zephyr/program/corsola/src/krabby/ppc_krabby.c
@@ -0,0 +1,31 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Krabby PPC/BC12 (RT1739) configuration */
+
+#include "baseboard_usbc_config.h"
+#include "driver/ppc/rt1739.h"
+#include "driver/ppc/syv682x.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "variant_db_detection.h"
+
+void c0_bc12_interrupt(enum gpio_signal signal)
+{
+ rt1739_interrupt(0);
+}
+
+static void board_usbc_init(void)
+{
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc_bc12));
+}
+DECLARE_HOOK(HOOK_INIT, board_usbc_init, HOOK_PRIO_POST_DEFAULT);
+
+void ppc_interrupt(enum gpio_signal signal)
+{
+ if (signal == GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl))) {
+ syv682x_interrupt(1);
+ }
+}
diff --git a/zephyr/projects/corsola/src/krabby/ppc_magikarp.c b/zephyr/program/corsola/src/krabby/ppc_magikarp.c
index 41cce3f73d..41cce3f73d 100644
--- a/zephyr/projects/corsola/src/krabby/ppc_magikarp.c
+++ b/zephyr/program/corsola/src/krabby/ppc_magikarp.c
diff --git a/zephyr/projects/corsola/src/krabby/ppc_tentacruel.c b/zephyr/program/corsola/src/krabby/ppc_tentacruel.c
index 877b9940b4..877b9940b4 100644
--- a/zephyr/projects/corsola/src/krabby/ppc_tentacruel.c
+++ b/zephyr/program/corsola/src/krabby/ppc_tentacruel.c
diff --git a/zephyr/program/corsola/src/krabby/sensor_magikarp.c b/zephyr/program/corsola/src/krabby/sensor_magikarp.c
new file mode 100644
index 0000000000..48e6f6c23c
--- /dev/null
+++ b/zephyr/program/corsola/src/krabby/sensor_magikarp.c
@@ -0,0 +1,41 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "accelgyro.h"
+#include "common.h"
+#include "cros_cbi.h"
+#include "driver/accelgyro_bmi323.h"
+#include "driver/accelgyro_icm42607.h"
+#include "hooks.h"
+#include "motionsense_sensors.h"
+
+void motion_interrupt(enum gpio_signal signal)
+{
+ uint32_t val;
+
+ cros_cbi_get_fw_config(FW_BASE_GYRO, &val);
+ if (val == FW_BASE_ICM42607) {
+ icm42607_interrupt(signal);
+ } else if (val == FW_BASE_BMI323) {
+ bmi3xx_interrupt(signal);
+ }
+}
+
+static void motionsense_init(void)
+{
+ uint32_t val;
+
+ cros_cbi_get_fw_config(FW_BASE_GYRO, &val);
+ if (val == FW_BASE_ICM42607) {
+ ccprints("BASE ACCEL is ICM42607");
+ } else if (val == FW_BASE_BMI323) {
+ MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel);
+ MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro);
+ ccprints("BASE ACCEL IS BMI323");
+ } else {
+ ccprints("no motionsense");
+ }
+}
+DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/program/corsola/src/krabby/sensor_tentacruel.c b/zephyr/program/corsola/src/krabby/sensor_tentacruel.c
new file mode 100644
index 0000000000..48e6f6c23c
--- /dev/null
+++ b/zephyr/program/corsola/src/krabby/sensor_tentacruel.c
@@ -0,0 +1,41 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "accelgyro.h"
+#include "common.h"
+#include "cros_cbi.h"
+#include "driver/accelgyro_bmi323.h"
+#include "driver/accelgyro_icm42607.h"
+#include "hooks.h"
+#include "motionsense_sensors.h"
+
+void motion_interrupt(enum gpio_signal signal)
+{
+ uint32_t val;
+
+ cros_cbi_get_fw_config(FW_BASE_GYRO, &val);
+ if (val == FW_BASE_ICM42607) {
+ icm42607_interrupt(signal);
+ } else if (val == FW_BASE_BMI323) {
+ bmi3xx_interrupt(signal);
+ }
+}
+
+static void motionsense_init(void)
+{
+ uint32_t val;
+
+ cros_cbi_get_fw_config(FW_BASE_GYRO, &val);
+ if (val == FW_BASE_ICM42607) {
+ ccprints("BASE ACCEL is ICM42607");
+ } else if (val == FW_BASE_BMI323) {
+ MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel);
+ MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro);
+ ccprints("BASE ACCEL IS BMI323");
+ } else {
+ ccprints("no motionsense");
+ }
+}
+DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/program/corsola/src/krabby/temp_tentacruel.c b/zephyr/program/corsola/src/krabby/temp_tentacruel.c
new file mode 100644
index 0000000000..08d5204e28
--- /dev/null
+++ b/zephyr/program/corsola/src/krabby/temp_tentacruel.c
@@ -0,0 +1,129 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_state.h"
+#include "charger.h"
+#include "common.h"
+#include "config.h"
+#include "console.h"
+#include "driver/charger/rt9490.h"
+#include "hooks.h"
+#include "temp_sensor/temp_sensor.h"
+#include "thermal.h"
+#include "util.h"
+
+#define NUM_CURRENT_LEVELS ARRAY_SIZE(current_table)
+#define TEMP_THRESHOLD 50
+#define TEMP_BUFF_SIZE 60
+#define KEEP_TIME 5
+
+BUILD_ASSERT(IS_ENABLED(CONFIG_BOARD_TENTACRUEL) || IS_ENABLED(CONFIG_TEST));
+/* calculate current average temperature */
+static int average_tempature(void)
+{
+ static int temp_history_buffer[TEMP_BUFF_SIZE];
+ static int buff_ptr;
+ static int temp_sum;
+ static int past_temp;
+ static int avg_temp;
+ int cur_temp, t;
+
+ temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL(temp_charger)), &t);
+ cur_temp = K_TO_C(t);
+ past_temp = temp_history_buffer[buff_ptr];
+ temp_history_buffer[buff_ptr] = cur_temp;
+ temp_sum = temp_sum + temp_history_buffer[buff_ptr] - past_temp;
+ buff_ptr++;
+ if (buff_ptr >= TEMP_BUFF_SIZE) {
+ buff_ptr = 0;
+ }
+ /* Calculate per minute temperature.
+ * It's expected low temperature when the first 60 seconds.
+ */
+ avg_temp = temp_sum / TEMP_BUFF_SIZE;
+ return avg_temp;
+}
+
+static int current_level;
+
+/* Limit charging current table : 3600/3000/2400/1800
+ * note this should be in descending order.
+ */
+static uint16_t current_table[] = {
+ 3600,
+ 3000,
+ 2400,
+ 1600,
+};
+
+/* Called by hook task every hook second (1 sec) */
+static void current_update(void)
+{
+ int temp;
+ static uint8_t uptime;
+ static uint8_t dntime;
+
+ temp = average_tempature();
+#ifndef CONFIG_TEST
+ if (charge_get_state() == PWR_STATE_DISCHARGE) {
+ current_level = 0;
+ uptime = 0;
+ dntime = 0;
+ return;
+ }
+#endif
+ if (temp >= TEMP_THRESHOLD) {
+ dntime = 0;
+ if (uptime < KEEP_TIME) {
+ uptime++;
+ } else {
+ uptime = 0;
+ current_level++;
+ }
+ } else if (current_level != 0 && temp < TEMP_THRESHOLD) {
+ uptime = 0;
+ if (dntime < KEEP_TIME) {
+ dntime++;
+ } else {
+ dntime = 0;
+ current_level--;
+ }
+ } else {
+ uptime = 0;
+ dntime = 0;
+ }
+ if (current_level > NUM_CURRENT_LEVELS) {
+ current_level = NUM_CURRENT_LEVELS;
+ }
+}
+DECLARE_HOOK(HOOK_SECOND, current_update, HOOK_PRIO_DEFAULT);
+
+int charger_profile_override(struct charge_state_data *curr)
+{
+ /*
+ * Precharge must be executed when communication is failed on
+ * dead battery.
+ */
+ if (!(curr->batt.flags & BATT_FLAG_RESPONSIVE))
+ return 0;
+ if (current_level != 0) {
+ if (curr->requested_current > current_table[current_level - 1])
+ curr->requested_current =
+ current_table[current_level - 1];
+ }
+ return 0;
+}
+
+enum ec_status charger_profile_override_get_param(uint32_t param,
+ uint32_t *value)
+{
+ return EC_RES_INVALID_PARAM;
+}
+
+enum ec_status charger_profile_override_set_param(uint32_t param,
+ uint32_t value)
+{
+ return EC_RES_INVALID_PARAM;
+}
diff --git a/zephyr/projects/corsola/src/krabby/usb_pd_policy.c b/zephyr/program/corsola/src/krabby/usb_pd_policy.c
index 8f2a2c3515..8f2a2c3515 100644
--- a/zephyr/projects/corsola/src/krabby/usb_pd_policy.c
+++ b/zephyr/program/corsola/src/krabby/usb_pd_policy.c
diff --git a/zephyr/program/corsola/src/krabby/usbc_config.c b/zephyr/program/corsola/src/krabby/usbc_config.c
new file mode 100644
index 0000000000..ab5888616e
--- /dev/null
+++ b/zephyr/program/corsola/src/krabby/usbc_config.c
@@ -0,0 +1,142 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Krabby board-specific USB-C configuration */
+
+#include "adc.h"
+#include "baseboard_usbc_config.h"
+#include "charge_manager.h"
+#include "console.h"
+#include "driver/tcpm/it83xx_pd.h"
+#include "driver/usb_mux/tusb1064.h"
+#include "i2c.h"
+#include "usb_pd.h"
+#include "usbc_ppc.h"
+#include "variant_db_detection.h"
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
+
+int tusb1064_mux_1_board_init(const struct usb_mux *me)
+{
+ int rv;
+
+ rv = i2c_write8(me->i2c_port, me->i2c_addr_flags,
+ TUSB1064_REG_DP1DP3EQ_SEL,
+ TUSB1064_DP1EQ(TUSB1064_DP_EQ_RX_8_9_DB) |
+ TUSB1064_DP3EQ(TUSB1064_DP_EQ_RX_5_4_DB));
+ if (rv)
+ return rv;
+
+ /* Enable EQ_OVERRIDE so the gain registers are used */
+ return i2c_update8(me->i2c_port, me->i2c_addr_flags,
+ TUSB1064_REG_GENERAL, REG_GENERAL_EQ_OVERRIDE,
+ MASK_SET);
+}
+
+#ifdef CONFIG_USB_PD_TCPM_ITE_ON_CHIP
+const struct cc_para_t *board_get_cc_tuning_parameter(enum usbpd_port port)
+{
+ const static struct cc_para_t
+ cc_parameter[CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT] = {
+ {
+ .rising_time =
+ IT83XX_TX_PRE_DRIVING_TIME_1_UNIT,
+ .falling_time =
+ IT83XX_TX_PRE_DRIVING_TIME_2_UNIT,
+ },
+ {
+ .rising_time =
+ IT83XX_TX_PRE_DRIVING_TIME_1_UNIT,
+ .falling_time =
+ IT83XX_TX_PRE_DRIVING_TIME_2_UNIT,
+ },
+ };
+
+ return &cc_parameter[port];
+}
+#endif
+
+void board_reset_pd_mcu(void)
+{
+ /*
+ * C0 & C1: TCPC is embedded in the EC and processes interrupts in the
+ * chip code (it83xx/intc.c)
+ */
+}
+
+int board_set_active_charge_port(int port)
+{
+ int i;
+ int is_valid_port =
+ (port >= 0 && port < board_get_adjusted_usb_pd_port_count());
+ /* adjust the actual port count when not the type-c db connected. */
+
+ if (!is_valid_port && port != CHARGE_PORT_NONE) {
+ return EC_ERROR_INVAL;
+ }
+
+ if (port == CHARGE_PORT_NONE) {
+ CPRINTS("Disabling all charger ports");
+
+ /* Disable all ports. */
+ for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) {
+ /*
+ * Do not return early if one fails otherwise we can
+ * get into a boot loop assertion failure.
+ */
+ if (ppc_vbus_sink_enable(i, 0)) {
+ CPRINTS("Disabling C%d as sink failed.", i);
+ }
+ }
+
+ return EC_SUCCESS;
+ }
+
+ /* Check if the port is sourcing VBUS. */
+ if (ppc_is_sourcing_vbus(port)) {
+ CPRINTS("Skip enable C%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+ CPRINTS("New charge port: C%d", port);
+
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < board_get_adjusted_usb_pd_port_count(); i++) {
+ if (i == port) {
+ continue;
+ }
+
+ if (ppc_vbus_sink_enable(i, 0)) {
+ CPRINTS("C%d: sink path disable failed.", i);
+ }
+ }
+
+ /* Enable requested charge port. */
+ if (ppc_vbus_sink_enable(port, 1)) {
+ CPRINTS("C%d: sink path enable failed.", port);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ return EC_SUCCESS;
+}
+
+#ifdef CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT
+enum adc_channel board_get_vbus_adc(int port)
+{
+ if (port == 0) {
+ return ADC_VBUS_C0;
+ }
+ if (port == 1) {
+ return ADC_VBUS_C1;
+ }
+ CPRINTSUSB("Unknown vbus adc port id: %d", port);
+ return ADC_VBUS_C0;
+}
+#endif /* CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT */
diff --git a/zephyr/program/corsola/src/usb_pd_policy.c b/zephyr/program/corsola/src/usb_pd_policy.c
new file mode 100644
index 0000000000..a5f3f11134
--- /dev/null
+++ b/zephyr/program/corsola/src/usb_pd_policy.c
@@ -0,0 +1,225 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "atomic.h"
+#include "baseboard_usbc_config.h"
+#include "chipset.h"
+#include "console.h"
+#include "hooks.h"
+#include "timer.h"
+#include "typec_control.h"
+#include "usb_dp_alt_mode.h"
+#include "usb_mux.h"
+#include "usb_pd.h"
+#include "usbc_ppc.h"
+
+#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
+
+static int active_aux_port = -1;
+
+int pd_check_vconn_swap(int port)
+{
+ /* Allow Vconn swap if AP is on. */
+ return chipset_in_state(CHIPSET_STATE_SUSPEND | CHIPSET_STATE_ON);
+}
+
+static void set_dp_aux_path_sel(int port)
+{
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), port);
+ CPRINTS("Set DP_AUX_PATH_SEL: %d", port);
+}
+
+int svdm_get_hpd_gpio(int port)
+{
+ /* HPD is low active, inverse the result */
+ return !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl));
+}
+
+static void reset_aux_deferred(void)
+{
+ if (active_aux_port == -1)
+ /* reset to 1 for lower power consumption. */
+ set_dp_aux_path_sel(1);
+}
+DECLARE_DEFERRED(reset_aux_deferred);
+
+void svdm_set_hpd_gpio(int port, int en)
+{
+ /*
+ * HPD is low active, inverse the en.
+ *
+ * Implement FCFS policy:
+ * 1) Enable hpd if no active port.
+ * 2) Disable hpd if active port is the given port.
+ */
+ if (en && active_aux_port < 0) {
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl), 0);
+ active_aux_port = port;
+ hook_call_deferred(&reset_aux_deferred_data, -1);
+ }
+
+ if (!en && active_aux_port == port) {
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl), 1);
+ active_aux_port = -1;
+ /*
+ * This might be a HPD debounce to send a HPD IRQ (500us), so
+ * do not reset the aux path immediately. Defer this call and
+ * re-check if this is a real disable.
+ */
+ hook_call_deferred(&reset_aux_deferred_data, 1 * MSEC);
+ }
+}
+
+__override int svdm_dp_config(int port, uint32_t *payload)
+{
+ int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT);
+ uint8_t pin_mode = get_dp_pin_mode(port);
+ mux_state_t mux_mode = svdm_dp_get_mux_mode(port);
+ int mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]);
+
+ if (!pin_mode) {
+ return 0;
+ }
+
+ CPRINTS("pin_mode: %x, mf: %d, mux: %d", pin_mode, mf_pref, mux_mode);
+ /*
+ * Defer setting the usb_mux until HPD goes high, svdm_dp_attention().
+ * The AP only supports one DP phy. An external DP mux switches between
+ * the two ports. Should switch those muxes when it is really used,
+ * i.e. HPD high; otherwise, the real use case is preempted, like:
+ * (1) plug a dongle without monitor connected to port-0,
+ * (2) plug a dongle without monitor connected to port-1,
+ * (3) plug a monitor to the port-1 dongle.
+ */
+
+ payload[0] =
+ VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos));
+ payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */
+ 1, /* DPv1.3 signaling */
+ 2); /* UFP connected */
+ return 2;
+};
+
+__override void svdm_dp_post_config(int port)
+{
+ mux_state_t mux_mode = svdm_dp_get_mux_mode(port);
+
+ typec_set_sbu(port, true);
+
+ /*
+ * Prior to post-config, the mux will be reset to safe mode, and this
+ * will break mux config and aux path config we did in the first DP
+ * status command. Only enable this if the port is the current aux-port.
+ */
+ if (port == active_aux_port) {
+ usb_mux_set(port, mux_mode, USB_SWITCH_CONNECT,
+ polarity_rm_dts(pd_get_polarity(port)));
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ }
+
+ dp_flags[port] |= DP_FLAGS_DP_ON;
+}
+
+int corsola_is_dp_muxable(int port)
+{
+ int i;
+
+ for (i = 0; i < board_get_usb_pd_port_count(); i++) {
+ if (i != port) {
+ if (usb_mux_get(i) & USB_PD_MUX_DP_ENABLED) {
+ return 0;
+ }
+ }
+ }
+
+ return 1;
+}
+
+__override int svdm_dp_attention(int port, uint32_t *payload)
+{
+ int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
+ int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
+#ifdef CONFIG_USB_PD_DP_HPD_GPIO
+ int cur_lvl = svdm_get_hpd_gpio(port);
+#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
+ mux_state_t mux_state;
+
+ dp_status[port] = payload[1];
+
+ if (!corsola_is_dp_muxable(port)) {
+ /* TODO(waihong): Info user? */
+ CPRINTS("p%d: The other port is already muxed.", port);
+ return 0; /* nak */
+ }
+
+ if (lvl) {
+ set_dp_aux_path_sel(port);
+
+ usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT,
+ polarity_rm_dts(pd_get_polarity(port)));
+ } else {
+ usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT,
+ polarity_rm_dts(pd_get_polarity(port)));
+ }
+
+ if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl)) {
+ /*
+ * Wake up the AP. IRQ or level high indicates a DP sink is now
+ * present.
+ */
+ if (IS_ENABLED(CONFIG_MKBP_EVENT)) {
+ pd_notify_dp_alt_mode_entry(port);
+ }
+ }
+
+#ifdef CONFIG_USB_PD_DP_HPD_GPIO
+ if (irq && !lvl) {
+ /*
+ * IRQ can only be generated when the level is high, because
+ * the IRQ is signaled by a short low pulse from the high level.
+ */
+ CPRINTF("ERR:HPD:IRQ&LOW\n");
+ return 0; /* nak */
+ }
+
+ if (irq && cur_lvl) {
+ uint64_t now = get_time().val;
+ /* wait for the minimum spacing between IRQ_HPD if needed */
+ if (now < svdm_hpd_deadline[port]) {
+ usleep(svdm_hpd_deadline[port] - now);
+ }
+
+ /* generate IRQ_HPD pulse */
+ svdm_set_hpd_gpio(port, 0);
+ /*
+ * b/171172053#comment14: since the HPD_DSTREAM_DEBOUNCE_IRQ is
+ * very short (500us), we can use udelay instead of usleep for
+ * more stable pulse period.
+ */
+ udelay(HPD_DSTREAM_DEBOUNCE_IRQ);
+ svdm_set_hpd_gpio(port, 1);
+ } else {
+ svdm_set_hpd_gpio(port, lvl);
+ }
+
+ /* set the minimum time delay (2ms) for the next HPD IRQ */
+ svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
+#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
+
+ mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
+ (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ usb_mux_hpd_update(port, mux_state);
+
+#ifdef USB_PD_PORT_TCPC_MST
+ if (port == USB_PD_PORT_TCPC_MST) {
+ baseboard_mst_enable_control(port, lvl);
+ }
+#endif
+
+ /* ack */
+ return 1;
+}
diff --git a/zephyr/program/corsola/src/usbc_config.c b/zephyr/program/corsola/src/usbc_config.c
new file mode 100644
index 0000000000..93eb72a48f
--- /dev/null
+++ b/zephyr/program/corsola/src/usbc_config.c
@@ -0,0 +1,247 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Corsola baseboard-specific USB-C configuration */
+
+#include "adc.h"
+#include "baseboard_usbc_config.h"
+#include "button.h"
+#include "charge_state_v2.h"
+#include "charger.h"
+#include "console.h"
+#include "ec_commands.h"
+#include "extpower.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "lid_switch.h"
+#include "power.h"
+#include "power_button.h"
+#include "ppc/syv682x_public.h"
+#include "spi.h"
+#include "switch.h"
+#include "tablet_mode.h"
+#include "task.h"
+#include "uart.h"
+#include "usb_charge.h"
+#include "usb_mux.h"
+#include "usb_pd_tcpm.h"
+#include "usb_tc_sm.h"
+#include "usbc/usb_muxes.h"
+#include "usbc_ppc.h"
+#include "variant_db_detection.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#include <ap_power/ap_power.h>
+
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
+
+/* a flag for indicating the tasks are inited. */
+static bool tasks_inited;
+
+/* Baseboard */
+static void baseboard_init(void)
+{
+#ifdef CONFIG_VARIANT_CORSOLA_USBA
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usba));
+#endif
+ /* If CCD mode has enabled before init, force the ccd_interrupt. */
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ccd_mode_odl))) {
+ ccd_interrupt(GPIO_CCD_MODE_ODL);
+ }
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode_odl));
+}
+DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_PRE_DEFAULT);
+
+__override uint8_t board_get_usb_pd_port_count(void)
+{
+ /* This function returns the PORT_COUNT+1 when HDMI db is connected.
+ * This is a trick to ensure the usb_mux_set being set properley.
+ * HDMI display functions using the USB virtual mux to * communicate
+ * with the DP bridge.
+ */
+ if (corsola_get_db_type() == CORSOLA_DB_HDMI) {
+ if (tasks_inited) {
+ return CONFIG_USB_PD_PORT_MAX_COUNT;
+ } else {
+ return CONFIG_USB_PD_PORT_MAX_COUNT - 1;
+ }
+ } else if (corsola_get_db_type() == CORSOLA_DB_NONE) {
+ return CONFIG_USB_PD_PORT_MAX_COUNT - 1;
+ }
+
+ return CONFIG_USB_PD_PORT_MAX_COUNT;
+}
+
+uint8_t board_get_adjusted_usb_pd_port_count(void)
+{
+ if (corsola_get_db_type() == CORSOLA_DB_TYPEC) {
+ return CONFIG_USB_PD_PORT_MAX_COUNT;
+ } else {
+ return CONFIG_USB_PD_PORT_MAX_COUNT - 1;
+ }
+}
+
+/* USB-A */
+void usb_a0_interrupt(enum gpio_signal signal)
+{
+ enum usb_charge_mode mode = gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(
+ gpio_ap_xhci_init_done)) ?
+ USB_CHARGE_MODE_ENABLED :
+ USB_CHARGE_MODE_DISABLED;
+
+ const int xhci_stat = gpio_get_level(signal);
+
+ for (int i = 0; i < USB_PORT_COUNT; i++) {
+ usb_charge_set_mode(i, mode, USB_ALLOW_SUSPEND_CHARGE);
+ }
+
+ for (int i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ /*
+ * Enable DRP toggle after XHCI inited. This is used to follow
+ * USB 3.2 spec 10.3.1.1.
+ */
+ if (xhci_stat) {
+ pd_set_dual_role(i, PD_DRP_TOGGLE_ON);
+ } else if (tc_is_attached_src(i)) {
+ /*
+ * This is a AP reset S0->S0 transition.
+ * We should set the role back to sink.
+ */
+ pd_set_dual_role(i, PD_DRP_FORCE_SINK);
+ }
+ }
+}
+
+__override enum pd_dual_role_states pd_get_drp_state_in_s0(void)
+{
+ if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ap_xhci_init_done))) {
+ return PD_DRP_TOGGLE_ON;
+ } else {
+ return PD_DRP_FORCE_SINK;
+ }
+}
+
+void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
+{
+ /*
+ * We ignore the cc_pin and PPC vconn because polarity and PPC vconn
+ * should already be set correctly in the PPC driver via the pd
+ * state machine.
+ */
+}
+
+/* HDMI/TYPE-C function shared subboard interrupt */
+void x_ec_interrupt(enum gpio_signal signal)
+{
+ int sub = corsola_get_db_type();
+
+ if (sub == CORSOLA_DB_TYPEC) {
+ /* C1: PPC interrupt */
+ ppc_interrupt(signal);
+ } else if (sub == CORSOLA_DB_HDMI) {
+ hdmi_hpd_interrupt(signal);
+ } else {
+ CPRINTS("Undetected subboard interrupt.");
+ }
+}
+
+static void board_hdmi_handler(struct ap_power_ev_callback *cb,
+ struct ap_power_ev_data data)
+{
+ int value;
+
+ switch (data.event) {
+ default:
+ return;
+
+ case AP_POWER_RESUME:
+ value = 1;
+ break;
+
+ case AP_POWER_SUSPEND:
+ value = 0;
+ break;
+ }
+ gpio_pin_set_dt(GPIO_DT_FROM_ALIAS(gpio_en_hdmi_pwr), value);
+ gpio_pin_set_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_pwrdn_odl), value);
+}
+
+static void tasks_init_deferred(void)
+{
+ tasks_inited = true;
+ if (corsola_get_db_type() == CORSOLA_DB_HDMI) {
+ /* If the HDMI port is plugged on-boot, and the usb_mux won't
+ * be configured before the task inited. Re-invoke the
+ * HPD configuration after task inited.
+ */
+ ps185_hdmi_hpd_mux_set();
+ }
+}
+DECLARE_DEFERRED(tasks_init_deferred);
+
+static void baseboard_x_ec_gpio2_init(void)
+{
+ static struct ppc_drv virtual_ppc_drv = { 0 };
+ static struct tcpm_drv virtual_tcpc_drv = { 0 };
+ static struct bc12_drv virtual_bc12_drv = { 0 };
+
+ /* no sub board */
+ if (corsola_get_db_type() == CORSOLA_DB_NONE) {
+ return;
+ }
+
+ /* type-c: USB_C1_PPC_INT_ODL / hdmi: PS185_EC_DP_HPD */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2));
+
+ if (corsola_get_db_type() == CORSOLA_DB_TYPEC) {
+ gpio_pin_interrupt_configure_dt(
+ GPIO_DT_FROM_ALIAS(gpio_usb_c1_ppc_int_odl),
+ GPIO_INT_EDGE_FALLING);
+ return;
+ }
+ if (corsola_get_db_type() == CORSOLA_DB_HDMI) {
+ static struct ap_power_ev_callback cb;
+
+ ap_power_ev_init_callback(&cb, board_hdmi_handler,
+ AP_POWER_RESUME | AP_POWER_SUSPEND);
+ ap_power_ev_add_callback(&cb);
+ }
+
+ /* drop related C1 port drivers when it's a HDMI DB. */
+ ppc_chips[USBC_PORT_C1] =
+ (const struct ppc_config_t){ .drv = &virtual_ppc_drv };
+ tcpc_config[USBC_PORT_C1] =
+ (const struct tcpc_config_t){ .drv = &virtual_tcpc_drv };
+ bc12_ports[USBC_PORT_C1] =
+ (const struct bc12_config){ .drv = &virtual_bc12_drv };
+ /* Use virtual mux to notify AP the mainlink direction. */
+ USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_1_hdmi_db);
+
+ /*
+ * If a HDMI DB is attached, C1 port tasks will be exiting in that
+ * the port number is larger than board_get_usb_pd_port_count().
+ * After C1 port tasks finished, we intentionally increase the port
+ * count by 1 for usb_mux to access the C1 virtual mux for notifying
+ * mainlink direction.
+ */
+ hook_call_deferred(&tasks_init_deferred_data, 2 * SECOND);
+}
+DECLARE_HOOK(HOOK_INIT, baseboard_x_ec_gpio2_init, HOOK_PRIO_DEFAULT);
+
+__override uint8_t get_dp_pin_mode(int port)
+{
+ if (corsola_get_db_type() == CORSOLA_DB_HDMI && port == USBC_PORT_C1) {
+ if (usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED) {
+ return MODE_DP_PIN_E;
+ } else {
+ return 0;
+ }
+ }
+
+ return pd_dfp_dp_get_pin_mode(port, dp_status[port]);
+}
diff --git a/zephyr/program/corsola/src/variant_db_detection.c b/zephyr/program/corsola/src/variant_db_detection.c
new file mode 100644
index 0000000000..9ade144513
--- /dev/null
+++ b/zephyr/program/corsola/src/variant_db_detection.c
@@ -0,0 +1,210 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Corsola daughter board detection */
+#include "baseboard_usbc_config.h"
+#include "console.h"
+#include "cros_cbi.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "usb_mux.h"
+#include "variant_db_detection.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
+
+#ifdef TEST_BUILD
+uint32_t dp_status[CONFIG_USB_PD_PORT_MAX_COUNT];
+#endif
+
+static void corsola_db_config(enum corsola_db_type type)
+{
+ switch (type) {
+ case CORSOLA_DB_HDMI:
+ /* EC_X_GPIO1 */
+ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_hdmi_pwr),
+ GPIO_OUTPUT_HIGH);
+ /* X_EC_GPIO2 */
+ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd),
+ GPIO_INPUT);
+ gpio_enable_dt_interrupt(
+ GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2));
+ /* EC_X_GPIO3 */
+ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_pwrdn_odl),
+ GPIO_OUTPUT_HIGH | GPIO_OPEN_DRAIN);
+ return;
+ case CORSOLA_DB_TYPEC:
+ /* EC_X_GPIO1 */
+ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_frs_en),
+ GPIO_OUTPUT_LOW);
+ /* X_EC_GPIO2 */
+ gpio_pin_configure_dt(
+ GPIO_DT_FROM_ALIAS(gpio_usb_c1_ppc_int_odl),
+ GPIO_INPUT | GPIO_PULL_UP);
+ gpio_enable_dt_interrupt(
+ GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2));
+ /* EC_X_GPIO3 */
+ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_dp_in_hpd),
+ GPIO_OUTPUT_LOW);
+ return;
+ case CORSOLA_DB_NONE:
+ /* Set floating pins as input with PU to prevent leakage */
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_x_gpio1),
+ GPIO_INPUT | GPIO_PULL_UP);
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_x_ec_gpio2),
+ GPIO_INPUT | GPIO_PULL_UP);
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_x_gpio3),
+ GPIO_INPUT | GPIO_PULL_UP);
+ return;
+ default:
+ break;
+ }
+}
+
+enum corsola_db_type corsola_get_db_type(void)
+{
+#if DT_NODE_EXISTS(DT_NODELABEL(db_config))
+ int ret;
+ uint32_t val;
+#endif
+ static enum corsola_db_type db = CORSOLA_DB_UNINIT;
+
+ if (db != CORSOLA_DB_UNINIT) {
+ return db;
+ }
+
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_hdmi_prsnt_odl))) {
+ db = CORSOLA_DB_HDMI;
+ } else {
+ db = CORSOLA_DB_TYPEC;
+ }
+
+/* Detect for no sub board case by FW_CONFIG */
+#if DT_NODE_EXISTS(DT_NODELABEL(db_config))
+ ret = cros_cbi_get_fw_config(DB, &val);
+ if (ret != 0) {
+ CPRINTS("Error retrieving CBI FW_CONFIG field %d", DB);
+ } else if (val == DB_NONE) {
+ db = CORSOLA_DB_NONE;
+ }
+#endif
+
+ corsola_db_config(db);
+
+ switch (db) {
+ case CORSOLA_DB_NONE:
+ CPRINTS("Detect %s DB", "NONE");
+ break;
+ case CORSOLA_DB_TYPEC:
+ CPRINTS("Detect %s DB", "TYPEC");
+ break;
+ case CORSOLA_DB_HDMI:
+ CPRINTS("Detect %s DB", "HDMI");
+ break;
+ default:
+ CPRINTS("DB UNINIT");
+ break;
+ }
+
+ return db;
+}
+
+static void corsola_db_init(void)
+{
+ corsola_get_db_type();
+}
+DECLARE_HOOK(HOOK_INIT, corsola_db_init, HOOK_PRIO_PRE_I2C);
+
+/**
+ * Handle PS185 HPD changing state.
+ */
+void ps185_hdmi_hpd_mux_set(void)
+{
+ const int hpd =
+ gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd));
+
+ if (!corsola_is_dp_muxable(USBC_PORT_C1)) {
+ return;
+ }
+
+ if (hpd && !(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED)) {
+ dp_status[USBC_PORT_C1] =
+ VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */
+ 0, /* HPD level ... not applicable */
+ 0, /* exit DP? ... no */
+ 0, /* usb mode? ... no */
+ 0, /* multi-function ... no */
+ 1, /* DP enabled ... yes */
+ 0, /* power low? ... no */
+ (!!DP_FLAGS_DP_ON));
+ /* update C1 virtual mux */
+ usb_mux_set(USBC_PORT_C1, USB_PD_MUX_DP_ENABLED,
+ USB_SWITCH_DISCONNECT,
+ 0 /* polarity, don't care */);
+ CPRINTS("HDMI plug");
+ }
+}
+
+static void ps185_hdmi_hpd_deferred(void)
+{
+ const int hpd =
+ gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd));
+
+ if (!hpd && (usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED)) {
+ dp_status[USBC_PORT_C1] =
+ VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */
+ 0, /* HPD level ... not applicable */
+ 0, /* exit DP? ... no */
+ 0, /* usb mode? ... no */
+ 0, /* multi-function ... no */
+ 0, /* DP enabled ... no */
+ 0, /* power low? ... no */
+ (!DP_FLAGS_DP_ON));
+ usb_mux_set(USBC_PORT_C1, USB_PD_MUX_NONE,
+ USB_SWITCH_DISCONNECT,
+ 0 /* polarity, don't care */);
+ CPRINTS("HDMI unplug");
+
+ return;
+ }
+
+ ps185_hdmi_hpd_mux_set();
+}
+DECLARE_DEFERRED(ps185_hdmi_hpd_deferred);
+
+#define HPD_SINK_ABSENCE_DEBOUNCE (2 * MSEC)
+
+void hdmi_hpd_interrupt(enum gpio_signal signal)
+{
+ const int hpd =
+ gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd));
+
+ if (!hpd) {
+ hook_call_deferred(&ps185_hdmi_hpd_deferred_data,
+ HPD_SINK_ABSENCE_DEBOUNCE);
+ } else {
+ hook_call_deferred(&ps185_hdmi_hpd_deferred_data, -1);
+ }
+
+ /* C0 DP is muxed, we should not send HPD to the AP */
+ if (!corsola_is_dp_muxable(USBC_PORT_C1)) {
+ if (hpd) {
+ CPRINTS("C0 port is already muxed.");
+ }
+ return;
+ }
+
+ if (hpd && !(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED)) {
+ /* set dp_aux_path_sel first, and configure the usb_mux in the
+ * deferred hook to prevent from dead locking.
+ */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), hpd);
+ hook_call_deferred(&ps185_hdmi_hpd_deferred_data, 0);
+ }
+
+ svdm_set_hpd_gpio(USBC_PORT_C1, hpd);
+}
diff --git a/zephyr/program/corsola/steelix/cbi.dtsi b/zephyr/program/corsola/steelix/cbi.dtsi
new file mode 100644
index 0000000000..6636b53a96
--- /dev/null
+++ b/zephyr/program/corsola/steelix/cbi.dtsi
@@ -0,0 +1,95 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ steelix-fw-config {
+ compatible = "cros-ec,cbi-fw-config";
+
+ /*
+ * FW_CONFIG field to indicate the device is clamshell
+ * or convertible.
+ */
+ form_factor {
+ enum-name = "FORM_FACTOR";
+ start = <13>;
+ size = <3>;
+
+ convertible {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "CONVERTIBLE";
+ value = <1>;
+ };
+ clamshell {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "CLAMSHELL";
+ value = <0>;
+ };
+ };
+
+ /* FW_CONFIG field to indicate which DB is attached. */
+ db_config: db {
+ enum-name = "DB";
+ start = <0>;
+ size = <4>;
+
+ sub-board-1 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "DB_NONE";
+ value = <0>;
+ };
+ sub-board-2 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "DB_USBA_HDMI";
+ value = <1>;
+ };
+ sub-board-3 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "DB_USBA_HDMI_LTE";
+ value = <2>;
+ };
+ };
+ };
+
+ /* Steelix-specific ssfc fields. */
+ steelix-ssfc {
+ compatible = "cros-ec,cbi-ssfc";
+
+ /* SSFC field to identify BASE motion sensor. */
+ base-sensor {
+ enum-name = "BASE_SENSOR";
+ size = <3>;
+
+ base_sensor_0: bmi323 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <1>;
+ default;
+ };
+ base_sensor_1: lsm6dsm {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <2>;
+ };
+ };
+
+ /* SSFC field to identify LID motion sensor. */
+ lid-sensor {
+ enum-name = "LID_SENSOR";
+ size = <3>;
+
+ lid_sensor_0: bma422 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <1>;
+ default;
+ };
+ lid_sensor_1: lis2dw12 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <2>;
+ };
+ };
+ };
+};
diff --git a/zephyr/program/corsola/steelix/interrupts.dtsi b/zephyr/program/corsola/steelix/interrupts.dtsi
new file mode 100644
index 0000000000..b212cd9496
--- /dev/null
+++ b/zephyr/program/corsola/steelix/interrupts.dtsi
@@ -0,0 +1,12 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+ /* This file should only be included in the project.overlay. */
+&int_base_imu {
+ irq-pin = <&base_imu_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "motion_interrupt";
+};
+
diff --git a/zephyr/program/corsola/steelix/project.conf b/zephyr/program/corsola/steelix/project.conf
new file mode 100644
index 0000000000..bf2de72512
--- /dev/null
+++ b/zephyr/program/corsola/steelix/project.conf
@@ -0,0 +1,34 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Variant config
+CONFIG_BOARD_STEELIX=y
+
+# steelix only use D2, drop the workaround config for H1
+CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n
+
+# Motion sensor
+CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
+CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSM=y
+CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y
+
+# Keyboard
+CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
+CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
+CONFIG_PLATFORM_EC_KEYBOARD_STRICT_DEBOUNCE=y
+
+# USBC
+CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3250
+CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000
+
+# Remove bring up options for FW QUAL
+CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n
+
+# Remove debug options and features for FW QUAL
+CONFIG_LOG=n
+CONFIG_LOG_MODE_MINIMAL=n
+CONFIG_SHELL_MINIMAL=y
+
+# AC_OK debounce time
+CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800
diff --git a/zephyr/program/corsola/steelix/project.overlay b/zephyr/program/corsola/steelix/project.overlay
new file mode 100644
index 0000000000..f850a51563
--- /dev/null
+++ b/zephyr/program/corsola/steelix/project.overlay
@@ -0,0 +1,298 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Corsola program common DTS includes */
+
+#include "../common.dtsi"
+#include "../power_signal.dtsi"
+#include "../usba.dtsi"
+#include "../npcx_adc.dtsi"
+#include "../npcx_gpio.dtsi"
+#include "../npcx_host_interface.dtsi"
+#include "../npcx_i2c.dtsi"
+#include "../npcx_interrupts.dtsi"
+#include "../npcx_keyboard.dtsi"
+#include "../npcx_motionsense.dtsi"
+#include "../npcx_usbc.dtsi"
+#include "../npcx_default_gpio_pinctrl.dtsi"
+
+/* Projrect level DTS shared with tests */
+#include "./cbi.dtsi"
+#include "./interrupts.dtsi"
+
+/* board override */
+/ {
+ aliases {
+ /*
+ * motion sense's <>_INT_EVENT is handled
+ * by alias. Using the alias, each driver creates
+ * its own <>_INT_EVENT.
+ */
+ lsm6dsm-int = &base_accel;
+ };
+
+ named-gpios {
+ en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus_x {
+ gpios = <&gpiof 5 GPIO_OUTPUT_LOW>;
+ };
+ usb_a1_fault_odl {
+ gpios = <&gpiof 4 GPIO_INPUT>;
+ };
+ };
+
+ batteries {
+ default_battery: byd_l22b3pg0 {
+ compatible = "byd,l22b3pg0", "battery-smart";
+ };
+ celxpert_l22c3pg0 {
+ compatible = "celxpert,l22c3pg0", "battery-smart";
+ };
+ cosmx_l22x3pg0 {
+ compatible = "cosmx,l22x3pg0", "battery-smart";
+ };
+ smp_l22m3pg0 {
+ compatible = "smp,l22m3pg0", "battery-smart";
+ };
+ sunwoda_l22d3pg0 {
+ compatible = "sunwoda,l22d3pg0", "battery-smart";
+ };
+ };
+
+
+ /* Steelix-specific ssfc fields. */
+ steelix-ssfc {
+ compatible = "cros-ec,cbi-ssfc";
+
+ /* SSFC field to identify BASE motion sensor. */
+ base-sensor {
+ enum-name = "BASE_SENSOR";
+ size = <3>;
+
+ base_sensor_0: bmi323 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <1>;
+ default;
+ };
+ base_sensor_1: lsm6dsm {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <2>;
+ };
+ };
+
+ /* SSFC field to identify LID motion sensor. */
+ lid-sensor {
+ enum-name = "LID_SENSOR";
+ size = <3>;
+
+ lid_sensor_0: bma422 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <1>;
+ default;
+ };
+ lid_sensor_1: lis2dw12 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <2>;
+ };
+ };
+ };
+
+ /* Rotation matrix used by drivers. */
+ motionsense-rotation-ref {
+ compatible = "cros-ec,motionsense-rotation-ref";
+ base_rot_ref_lsm6dsm: base-rotation-ref-lsm6dsm {
+ mat33 = <0 1 0
+ 1 0 0
+ 0 0 (-1)>;
+ };
+ };
+
+ /*
+ * Driver specific data. A driver-specific data can be shared with
+ * different motion sensors while they are using the same driver.
+ *
+ * If a node's compatible starts with "cros-ec,accelgyro-", it is for
+ * a common structure defined in accelgyro.h.
+ * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
+ * "struct als_drv_data_t" in accelgyro.h
+ */
+ motionsense-sensor-data {
+ lis2dw12_data: lis2dw12-drv-data {
+ compatible = "cros-ec,drvdata-lis2dw12";
+ status = "okay";
+ };
+ lsm6dsm_data_accel: lsm6dsm-accel-drv-data {
+ compatible = "cros-ec,drvdata-lsm6dsm";
+ status = "okay";
+ };
+ lsm6dsm_data_gyro: lsm6dsm-gyro-drv-data {
+ compatible = "cros-ec,drvdata-lsm6dsm";
+ status = "okay";
+ };
+ };
+
+ motionsense-sensor-alt {
+ alt_lid_accel: alt-lid-accel {
+ compatible = "cros-ec,lis2dw12";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&lid_rot_ref>;
+ default-range = <2>;
+ drv-data = <&lis2dw12_data>;
+ i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS";
+ alternate-for = <&lid_accel>;
+ alternate-ssfc-indicator = <&lid_sensor_1>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ alt_base_accel: alt-base-accel {
+ compatible = "cros-ec,lsm6dsm-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref_lsm6dsm>;
+ drv-data = <&lsm6dsm_data_accel>;
+ alternate-for = <&base_accel>;
+ alternate-ssfc-indicator = <&base_sensor_1>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ ec-rate = <(100 * USEC_PER_MSEC)>;
+ };
+ ec-s3 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ ec-rate = <0>;
+ };
+ };
+ };
+
+ alt_base_gyro: alt-base-gyro {
+ compatible = "cros-ec,lsm6dsm-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref_lsm6dsm>;
+ default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */
+ drv-data = <&lsm6dsm_data_gyro>;
+ alternate-for = <&base_gyro>;
+ alternate-ssfc-indicator = <&base_sensor_1>;
+ };
+ };
+
+ cros-keyscan {
+ compatible = "cros-ec,keyscan";
+
+ debounce-down = <15000>;
+ debounce-up = <15000>;
+
+ actual-key-mask = <
+ 0x1c /* C0 */
+ 0xff /* C1 */
+ 0xff /* C2 */
+ 0xff /* C3 */
+ 0xff /* C4 */
+ 0xf5 /* C5 */
+ 0xff /* C6 */
+ 0xa4 /* C7 */
+ 0xff /* C8 */
+ 0xfe /* C9 */
+ 0x55 /* C10 */
+ 0xfa /* C11 */
+ 0xca /* C12 */
+ >;
+ };
+
+ pwmleds {
+ compatible = "pwm-leds";
+ led_battery_red: ec_led1_odl {
+ pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ led_battery_green: ec_led2_odl {
+ pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ led_power_white: ec_led3_odl {
+ pwms = <&pwm4 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ };
+};
+
+/* Red LED */
+&pwm0_gpc3 {
+ drive-open-drain;
+};
+
+&pwm0 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm0_gpc3>;
+ pinctrl-names = "default";
+};
+
+/* Green LED */
+&pwm1_gpc2 {
+ drive-open-drain;
+};
+
+&pwm1 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm1_gpc2>;
+ pinctrl-names = "default";
+};
+
+/* White LED */
+&pwm4_gpb6 {
+ drive-open-drain;
+};
+
+&pwm4 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm4_gpb6>;
+ pinctrl-names = "default";
+};
+
+/* inherit the rot_ref from Kingler and overwrite it */
+&lid_rot_ref {
+ mat33 = <0 1 0
+ 1 0 0
+ 0 0 (-1)>;
+};
+
+&base_rot_ref {
+ mat33 = <1 0 0
+ 0 (-1) 0
+ 0 0 (-1)>;
+};
+
+/* steelix usba port enable config */
+&usba_port_enable_list {
+ enable-pins = <&en_pp5000_usb_a0_vbus
+ &en_pp5000_usb_a1_vbus>;
+};
diff --git a/zephyr/program/corsola/tentacruel/project.conf b/zephyr/program/corsola/tentacruel/project.conf
new file mode 100644
index 0000000000..cf5f727cbc
--- /dev/null
+++ b/zephyr/program/corsola/tentacruel/project.conf
@@ -0,0 +1,21 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Variant config
+CONFIG_BOARD_TENTACRUEL=y
+
+# USB-C
+CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n
+CONFIG_PLATFORM_EC_USB_MUX_PS8743=y
+
+# Keyboard
+CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
+CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
+
+# Sensor
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
+
+# Battery
+CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y
diff --git a/zephyr/program/corsola/tentacruel/project.overlay b/zephyr/program/corsola/tentacruel/project.overlay
new file mode 100644
index 0000000000..79bf2baa3d
--- /dev/null
+++ b/zephyr/program/corsola/tentacruel/project.overlay
@@ -0,0 +1,21 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Corsola program common DTS includes */
+
+#include "../common.dtsi"
+#include "../power_signal.dtsi"
+#include "../usba.dtsi"
+#include "../adc_tentacruel.dtsi"
+#include "../battery_tentacruel.dtsi"
+#include "../cbi_tentacruel.dtsi"
+#include "../gpio_tentacruel.dtsi"
+#include "../ite_keyboard.dtsi"
+#include "../i2c_tentacruel.dtsi"
+#include "../interrupts_tentacruel.dtsi"
+#include "../led_tentacruel.dtsi"
+#include "../motionsense_tentacruel.dtsi"
+#include "../usbc_tentacruel.dtsi"
+#include "../thermistor_tentacruel.dtsi"
diff --git a/zephyr/projects/corsola/thermistor_tentacruel.dts b/zephyr/program/corsola/thermistor_tentacruel.dtsi
index f9e5306f24..f9e5306f24 100644
--- a/zephyr/projects/corsola/thermistor_tentacruel.dts
+++ b/zephyr/program/corsola/thermistor_tentacruel.dtsi
diff --git a/zephyr/projects/corsola/usba.dts b/zephyr/program/corsola/usba.dtsi
index 2ecb3b7d5a..2ecb3b7d5a 100644
--- a/zephyr/projects/corsola/usba.dts
+++ b/zephyr/program/corsola/usba.dtsi
diff --git a/zephyr/program/corsola/usbc_magikarp.dtsi b/zephyr/program/corsola/usbc_magikarp.dtsi
new file mode 100644
index 0000000000..1d96f2a194
--- /dev/null
+++ b/zephyr/program/corsola/usbc_magikarp.dtsi
@@ -0,0 +1,59 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ usbc {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port0@0 {
+ compatible = "named-usbc-port";
+ reg = <0>;
+ bc12 = <&bc12_port0>;
+ ppc = <&ppc_port0>;
+ tcpc = <&usbpd0>;
+ chg = <&charger_bc12_port1>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&it5205_mux_0 &virtual_mux_0>;
+ };
+ };
+ port0-muxes {
+ virtual_mux_0: virtual-mux-0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+
+ port1@1 {
+ compatible = "named-usbc-port";
+ reg = <1>;
+ bc12 = <&charger_bc12_port1>;
+ ppc = <&ppc_port1>;
+ tcpc = <&usbpd1>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&ps8743_mux_1 &virtual_mux_1>;
+ };
+ usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db {
+ compatible = "cros-ec,usb-mux-chain";
+ alternative-chain;
+ usb-muxes = <&virtual_mux_1>;
+ };
+ };
+ port1-muxes {
+ virtual_mux_1: virtual-mux-1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ };
+};
+
+&usbpd0 {
+ status = "okay";
+};
+
+&usbpd1 {
+ status = "okay";
+};
diff --git a/zephyr/program/corsola/usbc_tentacruel.dtsi b/zephyr/program/corsola/usbc_tentacruel.dtsi
new file mode 100644
index 0000000000..3a0ead7b3e
--- /dev/null
+++ b/zephyr/program/corsola/usbc_tentacruel.dtsi
@@ -0,0 +1,60 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ usbc {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port0@0 {
+ compatible = "named-usbc-port";
+ reg = <0>;
+ bc12 = <&bc12_port0>;
+ ppc = <&bc12_ppc_port0>;
+ ppc_alt = <&ppc_port0>;
+ tcpc = <&usbpd0>;
+ chg = <&charger_bc12_port1>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&it5205_mux_0 &virtual_mux_0>;
+ };
+ };
+ port0-muxes {
+ virtual_mux_0: virtual-mux-0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+
+ port1@1 {
+ compatible = "named-usbc-port";
+ reg = <1>;
+ bc12 = <&charger_bc12_port1>;
+ ppc = <&ppc_port1>;
+ tcpc = <&usbpd1>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&ps8743_mux_1 &virtual_mux_1>;
+ };
+ usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db {
+ compatible = "cros-ec,usb-mux-chain";
+ alternative-chain;
+ usb-muxes = <&virtual_mux_1>;
+ };
+ };
+ port1-muxes {
+ virtual_mux_1: virtual-mux-1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ };
+};
+
+&usbpd0 {
+ status = "okay";
+};
+
+&usbpd1 {
+ status = "okay";
+};
diff --git a/zephyr/program/corsola/voltorb/project.conf b/zephyr/program/corsola/voltorb/project.conf
new file mode 100644
index 0000000000..c1be25bfc1
--- /dev/null
+++ b/zephyr/program/corsola/voltorb/project.conf
@@ -0,0 +1,41 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Variant config
+CONFIG_BOARD_VOLTORB=y
+
+# Voltorb only use D2, drop the workaround config for H1
+CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n
+
+# No A+Gsensor
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=n
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=n
+CONFIG_PLATFORM_EC_ACCEL_BMA4XX=n
+CONFIG_PLATFORM_EC_ACCEL_FIFO=n
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=n
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n
+CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n
+CONFIG_PLATFORM_EC_LID_ANGLE=n
+CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n
+CONFIG_PLATFORM_EC_MOTIONSENSE=n
+CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=n
+CONFIG_PLATFORM_EC_TABLET_MODE=n
+CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n
+
+# LED
+CONFIG_PLATFORM_EC_LED_COMMON=n
+CONFIG_PLATFORM_EC_LED_ONOFF_STATES=n
+CONFIG_PLATFORM_EC_LED_DT=y
+
+# Keyboard
+CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
+CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
+CONFIG_PLATFORM_EC_KEYBOARD_STRICT_DEBOUNCE=y
+
+# USBC
+CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3250
+CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000
+
+# AC_OK debounce time
+CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS=800
diff --git a/zephyr/program/corsola/voltorb/project.overlay b/zephyr/program/corsola/voltorb/project.overlay
new file mode 100644
index 0000000000..8cd5a2bad8
--- /dev/null
+++ b/zephyr/program/corsola/voltorb/project.overlay
@@ -0,0 +1,309 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Corsola program common DTS includes */
+
+#include "../common.dtsi"
+#include "../power_signal.dtsi"
+#include "../usba.dtsi"
+#include "../npcx_adc.dtsi"
+#include "../npcx_gpio.dtsi"
+#include "../npcx_host_interface.dtsi"
+#include "../npcx_i2c.dtsi"
+#include "../npcx_interrupts.dtsi"
+#include "../npcx_keyboard.dtsi"
+#include "../npcx_usbc.dtsi"
+#include "../npcx_default_gpio_pinctrl.dtsi"
+#include <dt-bindings/battery.h>
+
+/ {
+ unused-pins {
+ compatible = "unused-gpios";
+
+ unused-gpios =
+ /* base_imu_int_l */
+ <&gpio5 6 0>,
+ /* ec_pen_chg_dis_odl */
+ <&gpioe 4 0>,
+ /* lid_accel_int_l */
+ <&gpiob 3 0>,
+ /* gpio_tablet_mode_l */
+ <&gpiob 2 0>,
+ /* LED3 */
+ <&gpioc 4 0>;
+ };
+
+ batteries {
+ default_battery: lgc_ap18c8k {
+ compatible = "lgc,ap18c8k", "battery-smart";
+ };
+ cosmx_ap20cbl-2 {
+ compatible = "cosmx,ap20cbl-2", "battery-smart";
+ };
+ };
+
+ cros-keyscan {
+ compatible = "cros-ec,keyscan";
+
+ debounce-down = <20000>;
+ debounce-up = <20000>;
+
+ actual-key-mask = <
+ 0x1c /* C0 */
+ 0xff /* C1 */
+ 0xff /* C2 */
+ 0xff /* C3 */
+ 0xff /* C4 */
+ 0xf5 /* C5 */
+ 0xff /* C6 */
+ 0xa4 /* C7 */
+ 0xff /* C8 */
+ 0xfe /* C9 */
+ 0x55 /* C10 */
+ 0xfa /* C11 */
+ 0xca /* C12 */
+ >;
+ };
+
+ led_colors: led-colors {
+ compatible = "cros-ec,led-policy";
+
+ /* Voltorb LED bat charge */
+ bat-power-state-charge-lvl-1 {
+ charge-state = "PWR_STATE_CHARGE";
+ /* Battery percent range (>= Empty, <= 94%) */
+ batt-lvl = <BATTERY_LEVEL_EMPTY
+ (BATTERY_LEVEL_NEAR_FULL - 3)>;
+
+ color-0 {
+ led-color = <&color_amber>;
+ };
+ };
+ bat-power-state-charge-lvl-2 {
+ charge-state = "PWR_STATE_CHARGE";
+ /* Battery percent range (>= 95%, <= 96%) */
+ batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2)
+ (BATTERY_LEVEL_NEAR_FULL - 1)>;
+
+ color-0 {
+ led-color = <&color_blue>;
+ };
+ };
+
+ /* Voltorb LED bat charge near full */
+ bat-power-state-charge-near-full {
+ charge-state = "PWR_STATE_CHARGE_NEAR_FULL";
+
+ color-0 {
+ led-color = <&color_blue>;
+ };
+ };
+
+ /* Voltorb LED bat discharge */
+ bat-power-state-discharge-s0 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+ /* Battery percent range (>= 14%, <= Full) */
+ batt-lvl = <(BATTERY_LEVEL_LOW + 4) BATTERY_LEVEL_FULL>;
+
+ color-0 {
+ led-color = <&color_blue>;
+ };
+ };
+ bat-power-state-discharge-s0-bat-low {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+ /* Battery percent range (>= 7%, <= 13%) */
+ batt-lvl = <(BATTERY_LEVEL_CRITICAL + 2)
+ (BATTERY_LEVEL_LOW + 3)>;
+
+ color-0 {
+ led-color = <&color_amber>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <3000>;
+ };
+ };
+ bat-power-state-discharge-s0-bat-critical {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+ /* Battery percent range (>= Empty, <= 6%) */
+ batt-lvl = <BATTERY_LEVEL_EMPTY
+ (BATTERY_LEVEL_CRITICAL + 1)>;
+
+ color-0 {
+ led-color = <&color_amber>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <1000>;
+ };
+ };
+ bat-power-state-discharge-s3 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S3";
+
+ color-0 {
+ led-color = <&color_amber>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <3000>;
+ };
+ };
+ bat-power-state-discharge-s5 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S5";
+
+ color-0 {
+ led-color = <&color_off>;
+ };
+ };
+
+ /* Voltorb LED bat error */
+ bat-power-state-error {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S0";
+
+ color-0 {
+ led-color = <&color_amber>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <1000>;
+ };
+ };
+ bat-power-state-error-s3 {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S3";
+
+ color-0 {
+ led-color = <&color_amber>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <3000>;
+ };
+ };
+ bat-power-state-error-s5 {
+ charge-state = "PWR_STATE_ERROR";
+ chipset-state = "POWER_S5";
+
+ color-0 {
+ led-color = <&color_off>;
+ };
+ };
+
+ /* Voltorb LED power idle */
+ power-state-idle {
+ charge-state = "PWR_STATE_IDLE";
+
+ color-0 {
+ led-color = <&color_blue>;
+ };
+ };
+
+ /* Voltorb LED power forced idle */
+ power-state-forced-idle-right {
+ charge-state = "PWR_STATE_FORCED_IDLE";
+
+ color-0 {
+ led-color = <&color_amber>;
+ period-ms = <2000>;
+ };
+ color-1 {
+ led-color = <&color_blue>;
+ period-ms = <2000>;
+ };
+ };
+ };
+
+ pwmleds {
+ compatible = "pwm-leds";
+
+ led_amber: ec_led1_odl {
+ pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+
+ led_blue: ec_led2_odl {
+ pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ };
+
+ pwm-led-pins {
+ compatible = "cros-ec,pwm-led-pins";
+
+ color_off: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pwms = <&led_amber &led_blue>;
+ led-values = <0 0>;
+ };
+
+ color_amber: color-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pwms = <&led_amber &led_blue>;
+ led-values = <100 0>;
+ };
+
+ color_blue: color_blue {
+ led-color = "LED_BLUE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_BLUE";
+ led-pwms = <&led_amber &led_blue>;
+ led-values = <0 100>;
+ };
+ };
+};
+
+/* Amber LED */
+&pwm0_gpc3 {
+ drive-open-drain;
+};
+
+&pwm0 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm0_gpc3>;
+ pinctrl-names = "default";
+};
+
+/* Blue LED */
+&pwm1_gpc2 {
+ drive-open-drain;
+};
+
+&pwm1 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm1_gpc2>;
+ pinctrl-names = "default";
+};
+
+/* gpio overrides */
+/ {
+ named-gpios {
+ /delete-node/ base_imu_int_l;
+ /delete-node/ ec_pen_chg_dis_odl;
+ /delete-node/ lid_accel_int_l;
+ /delete-node/ gpio_tablet_mode_l;
+ };
+};
+
+/* interrupts overrides */
+/ {
+ gpio-interrupts {
+ /delete-node/ base_imu;
+ /delete-node/ tablet_mode;
+ };
+};
diff --git a/zephyr/program/herobrine/BUILD.py b/zephyr/program/herobrine/BUILD.py
new file mode 100644
index 0000000000..0bee6ffe2a
--- /dev/null
+++ b/zephyr/program/herobrine/BUILD.py
@@ -0,0 +1,49 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Define zmake projects for herobrine."""
+
+
+def register_variant(
+ project_name,
+):
+ """Register a variant of herobrine."""
+ register_npcx_project(
+ project_name=project_name,
+ zephyr_board="npcx9m3f",
+ dts_overlays=[
+ here / project_name / "project.overlay",
+ ],
+ kconfig_files=[
+ # Common to all projects.
+ here / "program.conf",
+ # Project-specific KConfig customization.
+ here / project_name / "project.conf",
+ ],
+ )
+
+
+register_variant(
+ project_name="evoker",
+)
+
+register_variant(
+ project_name="herobrine",
+)
+
+register_variant(
+ project_name="hoglin",
+)
+
+register_variant(
+ project_name="villager",
+)
+
+register_variant(
+ project_name="zoglin",
+)
+
+register_variant(
+ project_name="zombie",
+)
diff --git a/zephyr/program/herobrine/CMakeLists.txt b/zephyr/program/herobrine/CMakeLists.txt
new file mode 100644
index 0000000000..90a49a053e
--- /dev/null
+++ b/zephyr/program/herobrine/CMakeLists.txt
@@ -0,0 +1,36 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+cmake_minimum_required(VERSION 3.13.1)
+
+find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+
+cros_ec_library_include_directories(include)
+
+# Common Herobrine implementation
+zephyr_library_sources(
+ "src/board_chipset.c"
+)
+
+# Board specific implementation
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/usbc_config.c"
+ "src/usb_pd_policy.c")
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C
+ "src/i2c.c")
+
+if(DEFINED CONFIG_BOARD_EVOKER)
+ project(evoker)
+elseif(DEFINED CONFIG_BOARD_HEROBRINE)
+ project(herobrine)
+ add_subdirectory(herobrine)
+elseif(DEFINED CONFIG_BOARD_HOGLIN)
+ project(hoglin)
+elseif(DEFINED CONFIG_BOARD_VILLAGER)
+ project(villager)
+elseif(DEFINED CONFIG_BOARD_ZOGLIN)
+ project(zoglin)
+elseif(DEFINED CONFIG_BOARD_ZOMBIE)
+ project(zombie)
+endif()
diff --git a/zephyr/projects/herobrine/Kconfig b/zephyr/program/herobrine/Kconfig
index d0056288d5..d0056288d5 100644
--- a/zephyr/projects/herobrine/Kconfig
+++ b/zephyr/program/herobrine/Kconfig
diff --git a/zephyr/projects/herobrine/adc.dts b/zephyr/program/herobrine/adc.dtsi
index 16a5434e9d..16a5434e9d 100644
--- a/zephyr/projects/herobrine/adc.dts
+++ b/zephyr/program/herobrine/adc.dtsi
diff --git a/zephyr/projects/herobrine/common.dts b/zephyr/program/herobrine/common.dtsi
index a722f1dfa2..a722f1dfa2 100644
--- a/zephyr/projects/herobrine/common.dts
+++ b/zephyr/program/herobrine/common.dtsi
diff --git a/zephyr/projects/herobrine/default_gpio_pinctrl.dts b/zephyr/program/herobrine/default_gpio_pinctrl.dtsi
index 604658a145..604658a145 100644
--- a/zephyr/projects/herobrine/default_gpio_pinctrl.dts
+++ b/zephyr/program/herobrine/default_gpio_pinctrl.dtsi
diff --git a/zephyr/projects/herobrine/display.dts b/zephyr/program/herobrine/display.dtsi
index 65d3a2d91b..65d3a2d91b 100644
--- a/zephyr/projects/herobrine/display.dts
+++ b/zephyr/program/herobrine/display.dtsi
diff --git a/zephyr/program/herobrine/evoker/gpio.dtsi b/zephyr/program/herobrine/evoker/gpio.dtsi
new file mode 100644
index 0000000000..fd4a773369
--- /dev/null
+++ b/zephyr/program/herobrine/evoker/gpio.dtsi
@@ -0,0 +1,309 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ aliases {
+ gpio-wp = &gpio_ec_wp_odl;
+ gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ };
+
+ named-gpios {
+ compatible = "named-gpios";
+
+ gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl {
+ gpios = <&gpioe 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_PD_INT_ODL";
+ };
+ gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl {
+ gpios = <&gpiof 5 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_PD_INT_ODL";
+ };
+ gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl {
+ gpios = <&gpio0 3 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
+ };
+ gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl {
+ gpios = <&gpio4 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
+ };
+ gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
+ gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
+ gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_chg_acok_od: chg_acok_od {
+ gpios = <&gpiod 2 GPIO_INPUT>;
+ enum-name = "GPIO_AC_PRESENT";
+ };
+ gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
+ gpios = <&gpio0 0 GPIO_INPUT>;
+ enum-name = "GPIO_POWER_BUTTON_L";
+ };
+ gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
+ gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_DOWN_L";
+ };
+ gpio_ec_volup_btn_odl: ec_volup_btn_odl {
+ gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_UP_L";
+ };
+ gpio_ec_wp_odl: ec_wp_odl {
+ gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ };
+ gpio_lid_open_ec: lid_open_ec {
+ gpios = <&gpio0 1 GPIO_INPUT>;
+ enum-name = "GPIO_LID_OPEN";
+ };
+ gpio_ap_rst_l: ap_rst_l {
+ gpios = <&gpio5 1 GPIO_INPUT>;
+ enum-name = "GPIO_AP_RST_L";
+ };
+ gpio_ps_hold: ps_hold {
+ gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_PS_HOLD";
+ };
+ gpio_ap_suspend: ap_suspend {
+ gpios = <&gpio5 7 GPIO_INPUT>;
+ enum-name = "GPIO_AP_SUSPEND";
+ };
+ gpio_mb_power_good: mb_power_good {
+ gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_POWER_GOOD";
+ };
+ gpio_warm_reset_l: warm_reset_l {
+ gpios = <&gpiob 0 GPIO_INPUT>;
+ enum-name = "GPIO_WARM_RESET_L";
+ };
+ ap_ec_spi_cs_l {
+ gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>;
+ };
+ gpio_tablet_mode_l: tablet_mode_l {
+ gpios = <&gpioc 6 GPIO_INPUT>;
+ enum-name = "GPIO_TABLET_MODE_L";
+ };
+ gpio_accel_gyro_int_l: accel_gyro_int_l {
+ gpios = <&gpioa 3 GPIO_INPUT>;
+ };
+ gpio_rtc_ec_wake_odl: rtc_ec_wake_odl {
+ gpios = <&gpio0 2 GPIO_INPUT>;
+ };
+ ec_entering_rw {
+ gpios = <&gpio7 2 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_ENTERING_RW";
+ };
+ ccd_mode_odl {
+ gpios = <&gpio6 3 GPIO_INPUT>;
+ enum-name = "GPIO_CCD_MODE_ODL";
+ };
+ ec_batt_pres_odl {
+ gpios = <&gpioe 5 GPIO_INPUT>;
+ enum-name = "GPIO_BATT_PRES_ODL";
+ };
+ ec_gsc_packet_mode {
+ gpios = <&gpio8 3 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_PACKET_MODE_EN";
+ };
+ pmic_resin_l {
+ gpios = <&gpioa 0 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PMIC_RESIN_L";
+ };
+ pmic_kpd_pwr_odl {
+ gpios = <&gpioa 2 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PMIC_KPD_PWR_ODL";
+ };
+ ap_ec_int_l {
+ gpios = <&gpio5 6 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_EC_INT_L";
+ };
+ gpio_switchcap_on: switchcap_on {
+ gpios = <&gpiod 5 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_SWITCHCAP_ON";
+ };
+ gpio_en_pp5000_s5: en_pp5000_s5 {
+ gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>;
+ enum-name = "GPIO_EN_PP5000";
+ };
+ ec_bl_disable_l {
+ /* The PMIC controls backlight enable and this pin must
+ * be HiZ for normal operation. But the backlight can
+ * be enabled by setting this pin low and configuring it
+ * as an output.
+ */
+ gpios = <&gpiob 6 GPIO_INPUT>;
+ enum-name = "GPIO_ENABLE_BACKLIGHT";
+ };
+ lid_accel_int_l {
+ gpios = <&gpioa 1 GPIO_INPUT>;
+ };
+ tp_int_gate {
+ gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
+ };
+ gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l {
+ gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l {
+ gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_dp_mux_oe_l: dp_mux_oe_l {
+ gpios = <&gpiob 1 GPIO_ODR_HIGH>;
+ };
+ gpio_dp_mux_sel: dp_mux_sel {
+ gpios = <&gpio4 5 GPIO_OUTPUT_LOW>;
+ };
+ gpio_dp_hot_plug_det_r: dp_hot_plug_det_r {
+ gpios = <&gpio9 5 GPIO_OUTPUT_LOW>;
+ };
+ gpio_usb_c0_frs_en: usb_c0_frs_en {
+ gpios = <&gpioc 5 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_USB_C0_FRS_EN";
+ };
+ gpio_usb_c1_frs_en: usb_c1_frs_en {
+ gpios = <&gpioc 1 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_USB_C1_FRS_EN";
+ };
+ gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 {
+ gpios = <&gpio6 0 GPIO_OUTPUT_LOW>;
+ };
+ gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 {
+ gpios = <&gpioc 0 GPIO_OUTPUT_LOW>;
+ };
+ gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 {
+ gpios = <&gpioc 3 GPIO_OUTPUT_LOW>;
+ };
+ gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 {
+ gpios = <&gpioc 4 GPIO_OUTPUT_LOW>;
+ };
+ ap_ec_spi_mosi {
+ gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>;
+ };
+ ap_ec_spi_miso {
+ gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>;
+ };
+ ap_ec_spi_clk {
+ gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>;
+ };
+ gpio_brd_id0: brd_id0 {
+ gpios = <&gpio9 4 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION1";
+ };
+ gpio_brd_id1: brd_id1 {
+ gpios = <&gpio9 7 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION2";
+ };
+ gpio_brd_id2: brd_id2 {
+ gpios = <&gpioa 5 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION3";
+ };
+ gpio_sku_id0: sku_id0 {
+ gpios = <&gpio6 7 GPIO_INPUT>;
+ };
+ gpio_sku_id1: sku_id1 {
+ gpios = <&gpio7 0 GPIO_INPUT>;
+ };
+ gpio_sku_id2: sku_id2 {
+ gpios = <&gpioe 1 GPIO_INPUT>;
+ };
+ gpio_switchcap_pg: src_vph_pwr_pg {
+ gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_SWITCHCAP_PG";
+ };
+ arm_x86 {
+ gpios = <&gpio6 6 GPIO_OUTPUT_LOW>;
+ };
+ ec-i2c-sensor-scl {
+ gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec-i2c-sensor-sda {
+ gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_ec_kso_02_inv: ec_kso_02_inv {
+ gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
+ };
+ };
+
+ gpio_id_sku: sku {
+ compatible = "cros-ec,gpio-id";
+ bits = <
+ &gpio_sku_id0
+ &gpio_sku_id1
+ &gpio_sku_id2
+ >;
+ system = "ternary";
+ };
+
+ gpio_id_board: board {
+ compatible = "cros-ec,gpio-id";
+ bits = <
+ &gpio_brd_id0
+ &gpio_brd_id1
+ &gpio_brd_id2
+ >;
+ system = "ternary";
+ };
+
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios =
+ <&gpio5 2 0>,
+ <&gpio5 4 0>,
+ <&gpio7 6 0>,
+ <&gpiod 1 0>,
+ <&gpiod 0 0>,
+ <&gpioe 3 0>,
+ <&gpio0 4 0>,
+ <&gpiod 6 0>,
+ <&gpio3 2 0>,
+ <&gpio3 5 0>,
+ <&gpiod 7 0>,
+ <&gpio8 6 0>,
+ <&gpiod 4 0>,
+ <&gpio4 1 0>,
+ <&gpio3 4 0>,
+ <&gpioc 7 0>,
+ <&gpioa 4 0>,
+ <&gpio9 6 0>,
+ <&gpio9 3 0>,
+ <&gpioa 7 0>,
+ <&gpio5 0 0>,
+ <&gpio8 1 0>,
+ <&gpiof 0 0>,
+ <&gpio7 5 0>,
+ <&gpiof 4 0>,
+ <&gpiob 7 0>;
+ };
+};
+
+/* Power switch logic input pads */
+&psl_in1_gpd2 {
+ /* ACOK_OD */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in2_gp00 {
+ /* EC_PWR_BTN_ODL */
+ psl-in-mode = "edge";
+ psl-in-pol = "low-falling";
+};
+
+&psl_in3_gp01 {
+ /* LID_OPEN_EC */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in4_gp02 {
+ /* RTC_EC_WAKE_ODL */
+ psl-in-mode = "edge";
+ psl-in-pol = "low-falling";
+};
+
+/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
+&power_ctrl_psl {
+ status = "okay";
+ pinctrl-names = "sleep";
+ pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>;
+};
diff --git a/zephyr/program/herobrine/evoker/led_pins.dtsi b/zephyr/program/herobrine/evoker/led_pins.dtsi
new file mode 100644
index 0000000000..8365691f4d
--- /dev/null
+++ b/zephyr/program/herobrine/evoker/led_pins.dtsi
@@ -0,0 +1,64 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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_power_off: color-power-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_POWER_LED";
+ led-pins = <&gpio_ec_chg_led_w_c1>;
+ led-values = <0>;
+ };
+
+ color_power_white: color-power-white {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_POWER_LED";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-pins = <&gpio_ec_chg_led_w_c1>;
+ led-values = <1>;
+ };
+
+ color_battery_off: color-battery-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_w_c0
+ &gpio_ec_chg_led_r_c0>;
+ led-values = <0 0 0>;
+ };
+
+ color_battery_amber: color-battery-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_w_c0
+ &gpio_ec_chg_led_r_c0>;
+ led-values = <1 0 0>;
+ };
+
+ color_battery_white: color-battery-white {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_w_c0
+ &gpio_ec_chg_led_r_c0>;
+ led-values = <0 1 0>;
+ };
+
+ color_battery_red: color-battery-red {
+ led-color = "LED_RED";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_RED";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_w_c0
+ &gpio_ec_chg_led_r_c0>;
+ led-values = <0 0 1>;
+ };
+ };
+};
diff --git a/zephyr/projects/herobrine/led_policy_evoker.dts b/zephyr/program/herobrine/evoker/led_policy.dtsi
index fc17755ede..fc17755ede 100644
--- a/zephyr/projects/herobrine/led_policy_evoker.dts
+++ b/zephyr/program/herobrine/evoker/led_policy.dtsi
diff --git a/zephyr/projects/herobrine/motionsense_evoker.dts b/zephyr/program/herobrine/evoker/motionsense.dtsi
index aa7646e0b3..aa7646e0b3 100644
--- a/zephyr/projects/herobrine/motionsense_evoker.dts
+++ b/zephyr/program/herobrine/evoker/motionsense.dtsi
diff --git a/zephyr/program/herobrine/evoker/project.conf b/zephyr/program/herobrine/evoker/project.conf
new file mode 100644
index 0000000000..a57c119b90
--- /dev/null
+++ b/zephyr/program/herobrine/evoker/project.conf
@@ -0,0 +1,22 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Evoker board-specific Kconfig settings.
+CONFIG_BOARD_EVOKER=y
+
+# Disable type-c port sourcing 3A
+CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=0
+
+CONFIG_PLATFORM_EC_ACCEL_BMA255=n
+CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y
+
+# ISL9238C disable the CMOUT latch function.
+CONFIG_PLATFORM_EC_ISL9238C_DISABLE_CMOUT_LATCH=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y
+
+# Disable USB-A
+CONFIG_PLATFORM_EC_USBA=n
+
+# Set PCF85063A CAP_SEL
+CONFIG_PLATFORM_EC_PCF85063A_CAP_SEL=y
diff --git a/zephyr/program/herobrine/evoker/project.overlay b/zephyr/program/herobrine/evoker/project.overlay
new file mode 100644
index 0000000000..61d3129f70
--- /dev/null
+++ b/zephyr/program/herobrine/evoker/project.overlay
@@ -0,0 +1,59 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Herobrine program common DTS includes */
+#include "../adc.dtsi"
+#include "../common.dtsi"
+#include "../i2c.dtsi"
+#include "../interrupts.dtsi"
+#include "../keyboard.dtsi"
+#include "../default_gpio_pinctrl.dtsi"
+#include "../display.dtsi"
+#include "../switchcap.dtsi"
+#include "../usbc.dtsi"
+
+/* Evoker project DTS includes*/
+#include "gpio.dtsi"
+#include "led_pins.dtsi"
+#include "led_policy.dtsi"
+#include "motionsense.dtsi"
+
+/* evoker overrides follow... */
+/* battery overrides */
+/ {
+ batteries {
+ default_battery: pc_vp_bp153 {
+ compatible = "smp,pc-vp-bp153", "battery-smart";
+ };
+ ap16l5j {
+ compatible = "panasonic,ap16l5j", "battery-smart";
+ };
+ };
+
+};
+
+/* i2c overrides */
+&i2c1_0 {
+ ppc_port0_alt: sn5s330@40 {
+ compatible = "ti,sn5s330";
+ status = "okay";
+ reg = <0x40>;
+ };
+};
+
+&i2c2_0 {
+ ppc_port1_alt: sn5s330@40 {
+ compatible = "ti,sn5s330";
+ status = "okay";
+ reg = <0x40>;
+ };
+};
+
+/* interrupts overrides */
+/ {
+ gpio-interrupts {
+ /delete-node/ usb_a0_oc;
+ };
+};
diff --git a/zephyr/program/herobrine/gpio.dtsi b/zephyr/program/herobrine/gpio.dtsi
new file mode 100644
index 0000000000..60a60ec658
--- /dev/null
+++ b/zephyr/program/herobrine/gpio.dtsi
@@ -0,0 +1,321 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ aliases {
+ gpio-wp = &gpio_ec_wp_odl;
+ gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ };
+
+ named-gpios {
+ compatible = "named-gpios";
+
+ gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl {
+ gpios = <&gpioe 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_PD_INT_ODL";
+ };
+ gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl {
+ gpios = <&gpiof 5 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_PD_INT_ODL";
+ };
+ gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl {
+ gpios = <&gpio0 3 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
+ };
+ gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl {
+ gpios = <&gpio4 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
+ };
+ gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
+ gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
+ gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_usb_a0_oc_odl: usb_a0_oc_odl {
+ gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_chg_acok_od: chg_acok_od {
+ gpios = <&gpiod 2 GPIO_INPUT>;
+ enum-name = "GPIO_AC_PRESENT";
+ };
+ gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
+ gpios = <&gpio0 0 GPIO_INPUT>;
+ enum-name = "GPIO_POWER_BUTTON_L";
+ };
+ gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
+ gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_DOWN_L";
+ };
+ gpio_ec_volup_btn_odl: ec_volup_btn_odl {
+ gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_UP_L";
+ };
+ gpio_ec_wp_odl: ec_wp_odl {
+ gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ };
+ gpio_lid_open_ec: lid_open_ec {
+ gpios = <&gpio0 1 GPIO_INPUT>;
+ enum-name = "GPIO_LID_OPEN";
+ };
+ gpio_ap_rst_l: ap_rst_l {
+ gpios = <&gpio5 1 GPIO_INPUT>;
+ enum-name = "GPIO_AP_RST_L";
+ };
+ gpio_ps_hold: ps_hold {
+ gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_PS_HOLD";
+ };
+ gpio_ap_suspend: ap_suspend {
+ gpios = <&gpio5 7 GPIO_INPUT>;
+ enum-name = "GPIO_AP_SUSPEND";
+ };
+ gpio_mb_power_good: mb_power_good {
+ gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_POWER_GOOD";
+ };
+ gpio_warm_reset_l: warm_reset_l {
+ gpios = <&gpiob 0 GPIO_INPUT>;
+ enum-name = "GPIO_WARM_RESET_L";
+ };
+ ap_ec_spi_cs_l {
+ gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>;
+ };
+ gpio_tablet_mode_l: tablet_mode_l {
+ gpios = <&gpioc 6 GPIO_INPUT>;
+ enum-name = "GPIO_TABLET_MODE_L";
+ };
+ gpio_accel_gyro_int_l: accel_gyro_int_l {
+ gpios = <&gpioa 3 GPIO_INPUT>;
+ };
+ gpio_rtc_ec_wake_odl: rtc_ec_wake_odl {
+ gpios = <&gpio0 2 GPIO_INPUT>;
+ };
+ ec_entering_rw {
+ gpios = <&gpio7 2 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_ENTERING_RW";
+ };
+ ccd_mode_odl {
+ gpios = <&gpio6 3 GPIO_INPUT>;
+ enum-name = "GPIO_CCD_MODE_ODL";
+ };
+ ec_batt_pres_odl {
+ gpios = <&gpioe 5 GPIO_INPUT>;
+ enum-name = "GPIO_BATT_PRES_ODL";
+ };
+ ec_gsc_packet_mode {
+ gpios = <&gpio8 3 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_PACKET_MODE_EN";
+ };
+ pmic_resin_l {
+ gpios = <&gpioa 0 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PMIC_RESIN_L";
+ };
+ pmic_kpd_pwr_odl {
+ gpios = <&gpioa 2 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PMIC_KPD_PWR_ODL";
+ };
+ ap_ec_int_l {
+ gpios = <&gpio5 6 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_EC_INT_L";
+ };
+ gpio_switchcap_on: switchcap_on {
+ gpios = <&gpiod 5 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_SWITCHCAP_ON";
+ };
+ gpio_en_pp5000_s5: en_pp5000_s5 {
+ gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>;
+ enum-name = "GPIO_EN_PP5000";
+ };
+ ec_bl_disable_l {
+ /* The PMIC controls backlight enable and this pin must
+ * be HiZ for normal operation. But the backlight can
+ * be enabled by setting this pin low and configuring it
+ * as an output.
+ */
+ gpios = <&gpiob 6 GPIO_INPUT>;
+ enum-name = "GPIO_ENABLE_BACKLIGHT";
+ };
+ lid_accel_int_l {
+ gpios = <&gpioa 1 GPIO_INPUT>;
+ };
+ tp_int_gate {
+ gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
+ };
+ gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l {
+ gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l {
+ gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_dp_mux_oe_l: dp_mux_oe_l {
+ gpios = <&gpiob 1 GPIO_ODR_HIGH>;
+ };
+ gpio_dp_mux_sel: dp_mux_sel {
+ gpios = <&gpio4 5 GPIO_OUTPUT_LOW>;
+ };
+ gpio_dp_hot_plug_det_r: dp_hot_plug_det_r {
+ gpios = <&gpio9 5 GPIO_OUTPUT_LOW>;
+ };
+ gpio_en_usb_a_5v: en_usb_a_5v {
+ gpios = <&gpiof 0 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_EN_USB_A_5V";
+ };
+ usb_a_cdp_ilim_en_l {
+ gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_usb_c0_frs_en: usb_c0_frs_en {
+ gpios = <&gpioc 5 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_USB_C0_FRS_EN";
+ };
+ gpio_usb_c1_frs_en: usb_c1_frs_en {
+ gpios = <&gpioc 1 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_USB_C1_FRS_EN";
+ };
+ gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 {
+ gpios = <&gpio6 0 GPIO_OUTPUT_LOW>;
+ };
+ gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 {
+ gpios = <&gpioc 0 GPIO_OUTPUT_LOW>;
+ };
+ gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 {
+ gpios = <&gpioc 3 GPIO_OUTPUT_LOW>;
+ };
+ gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 {
+ gpios = <&gpioc 4 GPIO_OUTPUT_LOW>;
+ };
+ ap_ec_spi_mosi {
+ gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>;
+ };
+ ap_ec_spi_miso {
+ gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>;
+ };
+ ap_ec_spi_clk {
+ gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>;
+ };
+ gpio_brd_id0: brd_id0 {
+ gpios = <&gpio9 4 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION1";
+ };
+ gpio_brd_id1: brd_id1 {
+ gpios = <&gpio9 7 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION2";
+ };
+ gpio_brd_id2: brd_id2 {
+ gpios = <&gpioa 5 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION3";
+ };
+ gpio_sku_id0: sku_id0 {
+ gpios = <&gpio6 7 GPIO_INPUT>;
+ };
+ gpio_sku_id1: sku_id1 {
+ gpios = <&gpio7 0 GPIO_INPUT>;
+ };
+ gpio_sku_id2: sku_id2 {
+ gpios = <&gpioe 1 GPIO_INPUT>;
+ };
+ gpio_switchcap_pg: src_vph_pwr_pg {
+ gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_SWITCHCAP_PG";
+ };
+ arm_x86 {
+ gpios = <&gpio6 6 GPIO_OUTPUT_LOW>;
+ };
+ ec-i2c-sensor-scl {
+ gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec-i2c-sensor-sda {
+ gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_ec_kso_02_inv: ec_kso_02_inv {
+ gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
+ };
+ };
+
+ usba-port-enable-list {
+ compatible = "cros-ec,usba-port-enable-pins";
+ enable-pins = <&gpio_en_usb_a_5v>;
+ };
+
+ gpio_id_sku: sku {
+ compatible = "cros-ec,gpio-id";
+ bits = <
+ &gpio_sku_id0
+ &gpio_sku_id1
+ &gpio_sku_id2
+ >;
+ system = "ternary";
+ };
+
+ gpio_id_board: board {
+ compatible = "cros-ec,gpio-id";
+ bits = <
+ &gpio_brd_id0
+ &gpio_brd_id1
+ &gpio_brd_id2
+ >;
+ system = "ternary";
+ };
+
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios =
+ <&gpio5 2 0>,
+ <&gpio5 4 0>,
+ <&gpio7 6 0>,
+ <&gpiod 1 0>,
+ <&gpiod 0 0>,
+ <&gpioe 3 0>,
+ <&gpio0 4 0>,
+ <&gpiod 6 0>,
+ <&gpio3 2 0>,
+ <&gpio3 5 0>,
+ <&gpiod 7 0>,
+ <&gpio8 6 0>,
+ <&gpiod 4 0>,
+ <&gpio4 1 0>,
+ <&gpio3 4 0>,
+ <&gpioc 7 0>,
+ <&gpioa 4 0>,
+ <&gpio9 6 0>,
+ <&gpio9 3 0>,
+ <&gpioa 7 0>,
+ <&gpio5 0 0>,
+ <&gpio8 1 0>,
+ <&gpiob 7 0>;
+ };
+};
+
+/* Power switch logic input pads */
+&psl_in1_gpd2 {
+ /* ACOK_OD */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in2_gp00 {
+ /* EC_PWR_BTN_ODL */
+ psl-in-mode = "edge";
+ psl-in-pol = "low-falling";
+};
+
+&psl_in3_gp01 {
+ /* LID_OPEN_EC */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in4_gp02 {
+ /* RTC_EC_WAKE_ODL */
+ psl-in-mode = "edge";
+ psl-in-pol = "low-falling";
+};
+
+/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
+&power_ctrl_psl {
+ status = "okay";
+ pinctrl-names = "sleep";
+ pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>;
+};
diff --git a/zephyr/program/herobrine/herobrine/CMakeLists.txt b/zephyr/program/herobrine/herobrine/CMakeLists.txt
new file mode 100644
index 0000000000..5524db7215
--- /dev/null
+++ b/zephyr/program/herobrine/herobrine/CMakeLists.txt
@@ -0,0 +1,6 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/alt_dev_replacement.c")
diff --git a/zephyr/program/herobrine/herobrine/led_pins.dtsi b/zephyr/program/herobrine/herobrine/led_pins.dtsi
new file mode 100644
index 0000000000..23a0271e69
--- /dev/null
+++ b/zephyr/program/herobrine/herobrine/led_pins.dtsi
@@ -0,0 +1,62 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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_left: color-off-left {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_LEFT_LED";
+ led-pins = <&gpio_ec_chg_led_y_c1
+ &gpio_ec_chg_led_w_c1>;
+ led-values = <0 0>;
+ };
+
+ color_off_right: color-off-right {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_RIGHT_LED";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_w_c0>;
+ led-values = <0 0>;
+ };
+
+ color_amber_left: color-amber-left {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_LEFT_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pins = <&gpio_ec_chg_led_y_c1
+ &gpio_ec_chg_led_w_c1>;
+ led-values = <1 0>;
+ };
+
+ color_amber_right: color-amber-right {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_RIGHT_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_w_c0>;
+ led-values = <1 0>;
+ };
+
+ color_white_left: color-white-left {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_LEFT_LED";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-pins = <&gpio_ec_chg_led_y_c1
+ &gpio_ec_chg_led_w_c1>;
+ led-values = <0 1>;
+ };
+
+ color_white_right: color-white-right {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_RIGHT_LED";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_w_c0>;
+ led-values = <0 1>;
+ };
+ };
+};
diff --git a/zephyr/projects/herobrine/led_policy_herobrine.dts b/zephyr/program/herobrine/herobrine/led_policy.dtsi
index 13e5306deb..13e5306deb 100644
--- a/zephyr/projects/herobrine/led_policy_herobrine.dts
+++ b/zephyr/program/herobrine/herobrine/led_policy.dtsi
diff --git a/zephyr/projects/herobrine/prj_herobrine.conf b/zephyr/program/herobrine/herobrine/project.conf
index bf39f65692..bf39f65692 100644
--- a/zephyr/projects/herobrine/prj_herobrine.conf
+++ b/zephyr/program/herobrine/herobrine/project.conf
diff --git a/zephyr/program/herobrine/herobrine/project.overlay b/zephyr/program/herobrine/herobrine/project.overlay
new file mode 100644
index 0000000000..6ee53f67f0
--- /dev/null
+++ b/zephyr/program/herobrine/herobrine/project.overlay
@@ -0,0 +1,64 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Herobrine program common DTS includes */
+#include "../adc.dtsi"
+#include "../common.dtsi"
+#include "../i2c.dtsi"
+#include "../interrupts.dtsi"
+#include "../keyboard.dtsi"
+#include "../default_gpio_pinctrl.dtsi"
+#include "../display.dtsi"
+#include "../gpio.dtsi"
+#include "../motionsense.dtsi"
+#include "../switchcap.dtsi"
+#include "../usbc.dtsi"
+
+/* Herobrine project DTS includes*/
+#include "led_pins.dtsi"
+#include "led_policy.dtsi"
+
+/* herobrine overrides follow... */
+/* battery overrides */
+/ {
+ batteries {
+ default_battery: ap16l5j {
+ compatible = "panasonic,ap16l5j", "battery-smart";
+ };
+ };
+};
+
+/* i2c overrides */
+&i2c1_0 {
+
+ /delete-node/ syv682x@41;
+ ppc_port0: sn5s330@40 {
+ compatible = "ti,sn5s330";
+ status = "okay";
+ reg = <0x40>;
+ };
+
+ ppc_port0_alt: syv682x@41 {
+ compatible = "silergy,syv682x";
+ status = "okay";
+ reg = <0x41>;
+ frs_en_gpio = <&gpio_usb_c0_frs_en>;
+ };
+};
+
+&i2c2_0 {
+
+ /delete-node/ syv682x@41;
+ ppc_port1: sn5s330@40 {
+ compatible = "ti,sn5s330";
+ status = "okay";
+ reg = <0x40>;
+ };
+};
+
+/* usbc overrides */
+&port0 {
+ ppc_alt = <&ppc_port0_alt>;
+};
diff --git a/zephyr/program/herobrine/herobrine/src/alt_dev_replacement.c b/zephyr/program/herobrine/herobrine/src/alt_dev_replacement.c
new file mode 100644
index 0000000000..e1e9250ec4
--- /dev/null
+++ b/zephyr/program/herobrine/herobrine/src/alt_dev_replacement.c
@@ -0,0 +1,37 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "cros_board_info.h"
+#include "hooks.h"
+#include "usbc/ppc.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_REGISTER(alt_dev_replacement);
+
+#define BOARD_VERSION_UNKNOWN 0xffffffff
+
+/* Check board version to decide which ppc is used. */
+static bool board_has_alt_ppc(void)
+{
+ static uint32_t board_version = BOARD_VERSION_UNKNOWN;
+
+ if (board_version == BOARD_VERSION_UNKNOWN) {
+ if (cbi_get_board_version(&board_version) != EC_SUCCESS) {
+ LOG_ERR("Failed to get board version.");
+ board_version = 0;
+ }
+ }
+
+ return (board_version >= 1);
+}
+
+static void check_alternate_devices(void)
+{
+ /* Configure the PPC driver */
+ if (board_has_alt_ppc())
+ /* Arg is the USB port number */
+ PPC_ENABLE_ALTERNATE(0);
+}
+DECLARE_HOOK(HOOK_INIT, check_alternate_devices, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/program/herobrine/hoglin/gpio.dtsi b/zephyr/program/herobrine/hoglin/gpio.dtsi
new file mode 100644
index 0000000000..c742393ff8
--- /dev/null
+++ b/zephyr/program/herobrine/hoglin/gpio.dtsi
@@ -0,0 +1,321 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ aliases {
+ gpio-wp = &gpio_ec_wp_odl;
+ gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ };
+
+ named-gpios {
+ compatible = "named-gpios";
+
+ gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl {
+ gpios = <&gpioe 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_PD_INT_ODL";
+ };
+ gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl {
+ gpios = <&gpiof 5 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_PD_INT_ODL";
+ };
+ gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl {
+ gpios = <&gpio0 3 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
+ };
+ gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl {
+ gpios = <&gpio4 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
+ };
+ gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
+ gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
+ gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_usb_a0_oc_odl: usb_a0_oc_odl {
+ gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_chg_acok_od: chg_acok_od {
+ gpios = <&gpiod 2 GPIO_INPUT>;
+ enum-name = "GPIO_AC_PRESENT";
+ };
+ gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
+ gpios = <&gpio0 0 GPIO_INPUT>;
+ enum-name = "GPIO_POWER_BUTTON_L";
+ };
+ gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
+ gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_DOWN_L";
+ };
+ gpio_ec_volup_btn_odl: ec_volup_btn_odl {
+ gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_UP_L";
+ };
+ gpio_ec_wp_odl: ec_wp_odl {
+ gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ };
+ gpio_lid_open_ec: lid_open_ec {
+ gpios = <&gpio0 1 GPIO_INPUT>;
+ enum-name = "GPIO_LID_OPEN";
+ };
+ gpio_ap_rst_l: ap_rst_l {
+ gpios = <&gpio5 1 GPIO_INPUT>;
+ enum-name = "GPIO_AP_RST_L";
+ };
+ gpio_ps_hold: ps_hold {
+ gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_PS_HOLD";
+ };
+ gpio_ap_suspend: ap_suspend {
+ gpios = <&gpio5 7 GPIO_INPUT>;
+ enum-name = "GPIO_AP_SUSPEND";
+ };
+ gpio_mb_power_good: mb_power_good {
+ gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_POWER_GOOD";
+ };
+ gpio_warm_reset_l: warm_reset_l {
+ gpios = <&gpiob 0 GPIO_INPUT>;
+ enum-name = "GPIO_WARM_RESET_L";
+ };
+ ap_ec_spi_cs_l {
+ gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>;
+ };
+ gpio_tablet_mode_l: tablet_mode_l {
+ gpios = <&gpioc 6 GPIO_INPUT>;
+ enum-name = "GPIO_TABLET_MODE_L";
+ };
+ gpio_accel_gyro_int_l: accel_gyro_int_l {
+ gpios = <&gpioa 3 GPIO_INPUT>;
+ };
+ gpio_rtc_ec_wake_odl: rtc_ec_wake_odl {
+ gpios = <&gpio0 2 GPIO_INPUT>;
+ };
+ ec_entering_rw {
+ gpios = <&gpio7 2 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_ENTERING_RW";
+ };
+ ccd_mode_odl {
+ gpios = <&gpio6 3 GPIO_INPUT>;
+ enum-name = "GPIO_CCD_MODE_ODL";
+ };
+ ec_batt_pres_odl {
+ gpios = <&gpioe 5 GPIO_INPUT>;
+ enum-name = "GPIO_BATT_PRES_ODL";
+ };
+ ec_gsc_packet_mode {
+ gpios = <&gpio8 3 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_PACKET_MODE_EN";
+ };
+ pmic_resin_l {
+ gpios = <&gpioa 0 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PMIC_RESIN_L";
+ };
+ pmic_kpd_pwr_odl {
+ gpios = <&gpioa 2 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PMIC_KPD_PWR_ODL";
+ };
+ ap_ec_int_l {
+ gpios = <&gpio5 6 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_EC_INT_L";
+ };
+ gpio_switchcap_on: switchcap_on {
+ gpios = <&gpio5 0 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_SWITCHCAP_ON";
+ };
+ gpio_en_pp5000_s5: en_pp5000_s5 {
+ gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>;
+ enum-name = "GPIO_EN_PP5000";
+ };
+ ec_bl_disable_l {
+ /* The PMIC controls backlight enable and this pin must
+ * be HiZ for normal operation. But the backlight can
+ * be enabled by setting this pin low and configuring it
+ * as an output.
+ */
+ gpios = <&gpiob 6 GPIO_INPUT>;
+ enum-name = "GPIO_ENABLE_BACKLIGHT";
+ };
+ lid_accel_int_l {
+ gpios = <&gpioa 1 GPIO_INPUT>;
+ };
+ tp_int_gate {
+ gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
+ };
+ gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l {
+ gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l {
+ gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_dp_mux_oe_l: dp_mux_oe_l {
+ gpios = <&gpiob 1 GPIO_ODR_HIGH>;
+ };
+ gpio_dp_mux_sel: dp_mux_sel {
+ gpios = <&gpio4 5 GPIO_OUTPUT_LOW>;
+ };
+ gpio_dp_hot_plug_det_r: dp_hot_plug_det_r {
+ gpios = <&gpio9 5 GPIO_OUTPUT_LOW>;
+ };
+ gpio_en_usb_a_5v: en_usb_a_5v {
+ gpios = <&gpiof 0 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_EN_USB_A_5V";
+ };
+ usb_a_cdp_ilim_en_l {
+ gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_usb_c0_frs_en: usb_c0_frs_en {
+ gpios = <&gpioc 5 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_USB_C0_FRS_EN";
+ };
+ gpio_usb_c1_frs_en: usb_c1_frs_en {
+ gpios = <&gpioc 1 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_USB_C1_FRS_EN";
+ };
+ gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 {
+ gpios = <&gpio6 0 GPIO_OUTPUT_LOW>;
+ };
+ gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 {
+ gpios = <&gpioc 0 GPIO_OUTPUT_LOW>;
+ };
+ gpio_ec_chg_led_y_c1: ec_chg_led_b_c1 {
+ gpios = <&gpioc 3 GPIO_OUTPUT_LOW>;
+ };
+ gpio_ec_chg_led_w_c1: ec_chg_led_r_c1 {
+ gpios = <&gpioc 4 GPIO_OUTPUT_LOW>;
+ };
+ ap_ec_spi_mosi {
+ gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>;
+ };
+ ap_ec_spi_miso {
+ gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>;
+ };
+ ap_ec_spi_clk {
+ gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>;
+ };
+ gpio_brd_id0: brd_id0 {
+ gpios = <&gpio9 4 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION1";
+ };
+ gpio_brd_id1: brd_id1 {
+ gpios = <&gpio9 7 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION2";
+ };
+ gpio_brd_id2: brd_id2 {
+ gpios = <&gpioa 5 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION3";
+ };
+ gpio_sku_id0: sku_id0 {
+ gpios = <&gpio6 7 GPIO_INPUT>;
+ };
+ gpio_sku_id1: sku_id1 {
+ gpios = <&gpio7 0 GPIO_INPUT>;
+ };
+ gpio_sku_id2: sku_id2 {
+ gpios = <&gpioe 1 GPIO_INPUT>;
+ };
+ gpio_switchcap_pg: src_vph_pwr_pg {
+ gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_SWITCHCAP_PG";
+ };
+ arm_x86 {
+ gpios = <&gpio6 6 GPIO_OUTPUT_LOW>;
+ };
+ ec-i2c-sensor-scl {
+ gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec-i2c-sensor-sda {
+ gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_ec_kso_02_inv: ec_kso_02_inv {
+ gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
+ };
+ };
+
+ usba-port-enable-list {
+ compatible = "cros-ec,usba-port-enable-pins";
+ enable-pins = <&gpio_en_usb_a_5v>;
+ };
+
+ gpio_id_sku: sku {
+ compatible = "cros-ec,gpio-id";
+ bits = <
+ &gpio_sku_id0
+ &gpio_sku_id1
+ &gpio_sku_id2
+ >;
+ system = "ternary";
+ };
+
+ gpio_id_board: board {
+ compatible = "cros-ec,gpio-id";
+ bits = <
+ &gpio_brd_id0
+ &gpio_brd_id1
+ &gpio_brd_id2
+ >;
+ system = "ternary";
+ };
+
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios =
+ <&gpio5 2 0>,
+ <&gpio5 4 0>,
+ <&gpio7 6 0>,
+ <&gpiod 1 0>,
+ <&gpiod 0 0>,
+ <&gpioe 3 0>,
+ <&gpio0 4 0>,
+ <&gpiod 6 0>,
+ <&gpio3 2 0>,
+ <&gpio3 5 0>,
+ <&gpiod 7 0>,
+ <&gpio8 6 0>,
+ <&gpiod 4 0>,
+ <&gpio4 1 0>,
+ <&gpio3 4 0>,
+ <&gpioc 7 0>,
+ <&gpioa 4 0>,
+ <&gpio9 6 0>,
+ <&gpio9 3 0>,
+ <&gpioa 7 0>,
+ <&gpiod 5 0>,
+ <&gpio8 1 0>,
+ <&gpiob 7 0>;
+ };
+};
+
+/* Power switch logic input pads */
+&psl_in1_gpd2 {
+ /* ACOK_OD */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in2_gp00 {
+ /* EC_PWR_BTN_ODL */
+ psl-in-mode = "edge";
+ psl-in-pol = "low-falling";
+};
+
+&psl_in3_gp01 {
+ /* LID_OPEN_EC */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in4_gp02 {
+ /* RTC_EC_WAKE_ODL */
+ psl-in-mode = "edge";
+ psl-in-pol = "low-falling";
+};
+
+/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
+&power_ctrl_psl {
+ status = "okay";
+ pinctrl-names = "sleep";
+ pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>;
+};
diff --git a/zephyr/program/herobrine/hoglin/led_pins.dtsi b/zephyr/program/herobrine/hoglin/led_pins.dtsi
new file mode 100644
index 0000000000..b70c385b98
--- /dev/null
+++ b/zephyr/program/herobrine/hoglin/led_pins.dtsi
@@ -0,0 +1,36 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pins = <&gpio_ec_chg_led_b_c0
+ &gpio_ec_chg_led_r_c0>;
+ led-values = <0 0>;
+ };
+
+ color_blue: color-blue {
+ led-color = "LED_BLUE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_BLUE";
+ led-pins = <&gpio_ec_chg_led_b_c0
+ &gpio_ec_chg_led_r_c0>;
+ led-values = <1 0>;
+ };
+
+ color_red: color-red {
+ led-color = "LED_RED";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_RED";
+ led-pins = <&gpio_ec_chg_led_b_c0
+ &gpio_ec_chg_led_r_c0>;
+ led-values = <0 1>;
+ };
+ };
+};
diff --git a/zephyr/projects/herobrine/led_policy_hoglin.dts b/zephyr/program/herobrine/hoglin/led_policy.dtsi
index 043dfbcaa5..043dfbcaa5 100644
--- a/zephyr/projects/herobrine/led_policy_hoglin.dts
+++ b/zephyr/program/herobrine/hoglin/led_policy.dtsi
diff --git a/zephyr/projects/herobrine/motionsense_hoglin.dts b/zephyr/program/herobrine/hoglin/motionsense.dtsi
index c3935178ff..c3935178ff 100644
--- a/zephyr/projects/herobrine/motionsense_hoglin.dts
+++ b/zephyr/program/herobrine/hoglin/motionsense.dtsi
diff --git a/zephyr/projects/herobrine/prj_hoglin.conf b/zephyr/program/herobrine/hoglin/project.conf
index c6e20937c0..c6e20937c0 100644
--- a/zephyr/projects/herobrine/prj_hoglin.conf
+++ b/zephyr/program/herobrine/hoglin/project.conf
diff --git a/zephyr/program/herobrine/hoglin/project.overlay b/zephyr/program/herobrine/hoglin/project.overlay
new file mode 100644
index 0000000000..e37a325654
--- /dev/null
+++ b/zephyr/program/herobrine/hoglin/project.overlay
@@ -0,0 +1,54 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Herobrine program common DTS includes */
+#include "../adc.dtsi"
+#include "../common.dtsi"
+#include "../i2c.dtsi"
+#include "../interrupts.dtsi"
+#include "../keyboard.dtsi"
+#include "../default_gpio_pinctrl.dtsi"
+#include "../usbc.dtsi"
+#include "../switchcap.dtsi"
+
+/* Hoglin project DTS includes*/
+#include "gpio.dtsi"
+#include "led_pins.dtsi"
+#include "led_policy.dtsi"
+#include "motionsense.dtsi"
+
+/* hoglin overrides follow... */
+/* battery overrides */
+/ {
+ batteries {
+ default_battery: 7c01 {
+ compatible = "ganfeng,7c01", "battery-smart";
+ };
+ };
+
+};
+
+/* switchcap overrides */
+&{/switchcap} {
+ /delete-property/ power-good-pin;
+ poff-delay-ms = <550>;
+};
+
+/* i2c overrides */
+&i2c1_0 {
+ /delete-node/ ps8xxx@b;
+ tcpc_port0: ps8xxx@1b {
+ compatible = "parade,ps8xxx";
+ reg = <0x1b>;
+ };
+};
+
+&i2c2_0 {
+ /delete-node/ ps8xxx@b;
+ tcpc_port1: ps8xxx@1b {
+ compatible = "parade,ps8xxx";
+ reg = <0x1b>;
+ };
+};
diff --git a/zephyr/program/herobrine/i2c.dtsi b/zephyr/program/herobrine/i2c.dtsi
new file mode 100644
index 0000000000..58c3f8d014
--- /dev/null
+++ b/zephyr/program/herobrine/i2c.dtsi
@@ -0,0 +1,181 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ 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-7 = &i2c7_0;
+ };
+
+ named-i2c-ports {
+ compatible = "named-i2c-ports";
+
+ i2c_power: power {
+ i2c-port = <&i2c0_0>;
+ remote-port = <0>;
+ enum-names = "I2C_PORT_POWER",
+ "I2C_PORT_BATTERY",
+ "I2C_PORT_VIRTUAL_BATTERY",
+ "I2C_PORT_CHARGER";
+ };
+ i2c_tcpc0: tcpc0 {
+ i2c-port = <&i2c1_0>;
+ dynamic-speed;
+ enum-names = "I2C_PORT_TCPC0";
+ };
+ i2c_tcpc1: tcpc1 {
+ i2c-port = <&i2c2_0>;
+ dynamic-speed;
+ enum-names = "I2C_PORT_TCPC1";
+ };
+ rtc {
+ i2c-port = <&i2c4_1>;
+ enum-names = "I2C_PORT_RTC";
+ };
+ i2c_eeprom: eeprom {
+ i2c-port = <&i2c5_0>;
+ enum-names = "I2C_PORT_EEPROM";
+ };
+ i2c_sensor: sensor {
+ i2c-port = <&i2c7_0>;
+ enum-names = "I2C_PORT_SENSOR",
+ "I2C_PORT_ACCEL";
+ };
+ };
+
+
+};
+
+&i2c0_0 {
+ label = "I2C_POWER";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+ pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
+ pinctrl-names = "default";
+
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ irq = <&int_usb_c0_bc12>;
+ };
+
+ charger: isl923x@9 {
+ compatible = "intersil,isl923x";
+ status = "okay";
+ reg = <0x9>;
+ };
+};
+
+&i2c_ctrl0 {
+ status = "okay";
+};
+
+&i2c1_0 {
+ label = "I2C_USB_C0_PD";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+ pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
+ pinctrl-names = "default";
+
+ ppc_port0: syv682x@41 {
+ compatible = "silergy,syv682x";
+ status = "okay";
+ reg = <0x41>;
+ frs_en_gpio = <&gpio_usb_c0_frs_en>;
+ };
+
+ tcpc_port0: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ };
+};
+
+&i2c_ctrl1 {
+ status = "okay";
+};
+
+&i2c2_0 {
+ label = "I2C_USB_C1_PD";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+ pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>;
+ pinctrl-names = "default";
+
+ ppc_port1: syv682x@41 {
+ compatible = "silergy,syv682x";
+ status = "okay";
+ reg = <0x41>;
+ frs_en_gpio = <&gpio_usb_c1_frs_en>;
+ };
+
+ tcpc_port1: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ };
+};
+
+&i2c_ctrl2 {
+ status = "okay";
+};
+
+&i2c3_0 {
+ /* Not used as no WLC connected */
+ clock-frequency = <I2C_BITRATE_FAST>;
+};
+
+&i2c4_1 {
+ label = "I2C_RTC";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>;
+ pinctrl-names = "default";
+
+ pcf85063a: pcf85063a@51 {
+ compatible = "nxp,rtc-pcf85063a";
+ reg = <0x51>;
+ int-pin = <&gpio_rtc_ec_wake_odl>;
+ };
+};
+
+&i2c_ctrl4 {
+ status = "okay";
+};
+
+&i2c5_0 {
+ label = "I2C_EEPROM";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>;
+ pinctrl-names = "default";
+
+ bc12_port1: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ irq = <&int_usb_c1_bc12>;
+ };
+};
+
+&i2c_ctrl5 {
+ status = "okay";
+};
+
+&i2c7_0 {
+ label = "I2C_SENSOR";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
+ pinctrl-names = "default";
+};
+
+&i2c_ctrl7 {
+ status = "okay";
+};
diff --git a/zephyr/program/herobrine/include/board_chipset.h b/zephyr/program/herobrine/include/board_chipset.h
new file mode 100644
index 0000000000..000bc06654
--- /dev/null
+++ b/zephyr/program/herobrine/include/board_chipset.h
@@ -0,0 +1,13 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __CROS_EC_HEROBRINE_BOARD_CHIPSET_H
+#define __CROS_EC_HEROBRINE_BOARD_CHIPSET_H
+
+#include "common.h"
+
+__test_only void reset_pp5000_inited(void);
+
+#endif /* __CROS_EC_HEROBRINE_BOARD_CHIPSET_H */
diff --git a/zephyr/projects/herobrine/interrupts.dts b/zephyr/program/herobrine/interrupts.dtsi
index 82650bfc51..82650bfc51 100644
--- a/zephyr/projects/herobrine/interrupts.dts
+++ b/zephyr/program/herobrine/interrupts.dtsi
diff --git a/zephyr/projects/herobrine/keyboard.dts b/zephyr/program/herobrine/keyboard.dtsi
index 3b7e830f2f..3b7e830f2f 100644
--- a/zephyr/projects/herobrine/keyboard.dts
+++ b/zephyr/program/herobrine/keyboard.dtsi
diff --git a/zephyr/projects/herobrine/motionsense.dts b/zephyr/program/herobrine/motionsense.dtsi
index 1955f43284..1955f43284 100644
--- a/zephyr/projects/herobrine/motionsense.dts
+++ b/zephyr/program/herobrine/motionsense.dtsi
diff --git a/zephyr/program/herobrine/program.conf b/zephyr/program/herobrine/program.conf
new file mode 100644
index 0000000000..babc8483c9
--- /dev/null
+++ b/zephyr/program/herobrine/program.conf
@@ -0,0 +1,140 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_CROS_EC=y
+CONFIG_SHIMMED_TASKS=y
+CONFIG_PLATFORM_EC=y
+CONFIG_PLATFORM_EC_BRINGUP=y
+CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
+CONFIG_PLATFORM_EC_SWITCH=y
+CONFIG_PLATFORM_EC_LID_SWITCH=y
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=y
+CONFIG_PLATFORM_EC_POWER_BUTTON=y
+CONFIG_KERNEL_SHELL=y
+CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y
+
+# I2C options
+CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y
+CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y
+
+# Shell history and tab autocompletion (for convenience)
+CONFIG_SHELL_HELP=y
+CONFIG_SHELL_HISTORY=y
+CONFIG_SHELL_TAB=y
+CONFIG_SHELL_TAB_AUTOCOMPLETION=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_COMMON=n
+CONFIG_PLATFORM_EC_LED_DT=y
+
+# Application Processor is Qualcomm SC7280
+CONFIG_AP_ARM_QUALCOMM_SC7280=y
+
+# Board version is selected over GPIO board ID pins.
+CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y
+
+# Power Sequencing
+CONFIG_PLATFORM_EC_POWERSEQ=y
+CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y
+CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
+CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
+CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y
+CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y
+
+# MKBP event
+CONFIG_PLATFORM_EC_MKBP_EVENT=y
+CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y
+
+# Keyboard
+CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y
+CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
+CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
+CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
+CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
+CONFIG_PLATFORM_EC_CMD_BUTTON=y
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_SMART=y
+CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y
+CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y
+CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
+CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
+CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
+CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y
+CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y
+CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY=y
+CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY="LION"
+CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y
+CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=2
+CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=12500
+CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512
+CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y
+CONFIG_PLATFORM_EC_CHARGER_PSYS=y
+CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20
+CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y
+
+# USB-C
+CONFIG_PLATFORM_EC_USB_PD_FRS=y
+CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n
+CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y
+CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y
+CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y
+CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y
+CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE=n
+CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y
+CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
+CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_DPS=y
+CONFIG_PLATFORM_EC_USB_PD_REV30=y
+CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
+CONFIG_PLATFORM_EC_USB_PD_USB4=n
+CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805=y
+CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n
+CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n
+CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
+CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=2
+
+# USB ID
+# This is allocated specifically for Herobrine
+# http://google3/hardware/standards/usb/
+# TODO(b/183608112): Move to device tree
+CONFIG_PLATFORM_EC_USB_PID=0x5055
+
+# RTC
+CONFIG_PLATFORM_EC_RTC=y
+CONFIG_PLATFORM_EC_HOSTCMD_RTC=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC_ALARM=y
+
+# EC software sync
+CONFIG_PLATFORM_EC_VBOOT_HASH=y
+
+# Sensors
+CONFIG_PLATFORM_EC_MOTIONSENSE=y
+CONFIG_PLATFORM_EC_ACCEL_FIFO=y
+CONFIG_PLATFORM_EC_ACCEL_SPOOF_MODE=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
+CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
+CONFIG_PLATFORM_EC_LID_ANGLE=y
+CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
+CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
+CONFIG_PLATFORM_EC_TABLET_MODE=y
+CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
+CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000
+
+# Sensor Drivers
+CONFIG_PLATFORM_EC_ACCEL_BMA255=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI260=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
+
+CONFIG_SYSCON=y
+CONFIG_PLATFORM_EC_EMULATED_SYSRQ=y
diff --git a/zephyr/program/herobrine/src/board_chipset.c b/zephyr/program/herobrine/src/board_chipset.c
new file mode 100644
index 0000000000..dece9708ff
--- /dev/null
+++ b/zephyr/program/herobrine/src/board_chipset.c
@@ -0,0 +1,82 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Herobrine chipset-specific configuration */
+
+#include "battery.h"
+#include "board_chipset.h"
+#include "charger.h"
+#include "common.h"
+#include "console.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "timer.h"
+#include "usb_pd.h"
+
+#define CPRINTS(format, args...) cprints(CC_HOOK, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_HOOK, format, ##args)
+
+/*
+ * A window of PD negotiation. It starts from the Type-C state reaching
+ * Attached.SNK, and ends when the PD contract is created. The VBUS may be
+ * raised anytime in this window.
+ *
+ * The current implementation is the worst case scenario: every message the PD
+ * negotiation is received at the last moment before timeout. More extra time
+ * is added to compensate the delay internally, like the decision of the DPM.
+ *
+ * TODO(waihong): Cancel this timer when the PD contract is negotiated.
+ */
+#define PD_READY_TIMEOUT \
+ (PD_T_SINK_WAIT_CAP + PD_T_SENDER_RESPONSE + PD_T_SINK_TRANSITION + \
+ 20 * MSEC)
+
+#define PD_READY_POLL_DELAY (10 * MSEC)
+
+static timestamp_t pd_ready_timeout;
+
+static bool pp5000_inited;
+
+__test_only void reset_pp5000_inited(void)
+{
+ pp5000_inited = false;
+}
+
+/* Called on USB PD connected */
+static void board_usb_pd_connect(void)
+{
+ int soc = -1;
+
+ /* First boot, battery unattached or low SOC */
+ if (!pp5000_inited &&
+ ((battery_state_of_charge_abs(&soc) != EC_SUCCESS ||
+ soc < charger_get_min_bat_pct_for_power_on()))) {
+ pd_ready_timeout = get_time();
+ pd_ready_timeout.val += PD_READY_TIMEOUT;
+ }
+}
+DECLARE_HOOK(HOOK_USB_PD_CONNECT, board_usb_pd_connect, HOOK_PRIO_DEFAULT);
+
+static void wait_pd_ready(void)
+{
+ CPRINTS("Wait PD negotiated VBUS transition %u",
+ pd_ready_timeout.le.lo);
+ while (pd_ready_timeout.val && get_time().val < pd_ready_timeout.val)
+ usleep(PD_READY_POLL_DELAY);
+}
+
+/* Called on AP S5 -> S3 transition */
+static void board_chipset_pre_init(void)
+{
+ if (!pp5000_inited) {
+ if (pd_ready_timeout.val) {
+ wait_pd_ready();
+ }
+ CPRINTS("Enable 5V rail");
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_s5), 1);
+ pp5000_inited = true;
+ }
+}
+DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_chipset_pre_init, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/program/herobrine/src/i2c.c b/zephyr/program/herobrine/src/i2c.c
new file mode 100644
index 0000000000..8cf2cfc232
--- /dev/null
+++ b/zephyr/program/herobrine/src/i2c.c
@@ -0,0 +1,17 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "i2c.h"
+#include "i2c/i2c.h"
+
+/* Herobrine-NPCX9 board specific i2c implementation */
+
+#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
+int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc)
+{
+ return (i2c_get_device_for_port(cmd_desc->port) ==
+ i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY));
+}
+#endif
diff --git a/zephyr/program/herobrine/src/usb_pd_policy.c b/zephyr/program/herobrine/src/usb_pd_policy.c
new file mode 100644
index 0000000000..ad34f3b6e4
--- /dev/null
+++ b/zephyr/program/herobrine/src/usb_pd_policy.c
@@ -0,0 +1,254 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_manager.h"
+#include "chipset.h"
+#include "console.h"
+#include "system.h"
+#include "usb_mux.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+int pd_check_vconn_swap(int port)
+{
+ /* In G3, do not allow vconn swap since PP5000 rail is off */
+ return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_s5));
+}
+
+static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT];
+
+static void board_vbus_update_source_current(int port)
+{
+ ppc_vbus_source_enable(port, vbus_en[port]);
+}
+
+void pd_power_supply_reset(int port)
+{
+ int prev_en;
+
+ prev_en = vbus_en[port];
+
+ /* Disable VBUS */
+ vbus_en[port] = 0;
+ board_vbus_update_source_current(port);
+
+ /* Enable discharge if we were previously sourcing 5V */
+ if (prev_en)
+ pd_set_vbus_discharge(port, 1);
+
+ /* notify host of power info change */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ /* Disable charging */
+ board_vbus_sink_enable(port, 0);
+
+ pd_set_vbus_discharge(port, 0);
+
+ /* Provide VBUS */
+ vbus_en[port] = 1;
+ board_vbus_update_source_current(port);
+
+ /* notify host of power info change */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS; /* we are ready */
+}
+
+int board_vbus_source_enabled(int port)
+{
+ return vbus_en[port];
+}
+
+int pd_snk_is_vbus_provided(int port)
+{
+ return tcpm_check_vbus_level(port, VBUS_PRESENT);
+}
+
+/* ----------------- Vendor Defined Messages ------------------ */
+#ifdef CONFIG_USB_PD_ALT_MODE_DFP
+__override int svdm_dp_config(int port, uint32_t *payload)
+{
+ int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT);
+ uint8_t pin_mode = get_dp_pin_mode(port);
+
+ if (!pin_mode)
+ return 0;
+
+ /*
+ * Defer setting the usb_mux until HPD goes high, svdm_dp_attention().
+ * The AP only supports one DP phy. An external DP mux switches between
+ * the two ports. Should switch those muxes when it is really used,
+ * i.e. HPD high; otherwise, the real use case is preempted, like:
+ * (1) plug a dongle without monitor connected to port-0,
+ * (2) plug a dongle without monitor connected to port-1,
+ * (3) plug a monitor to the port-1 dongle.
+ */
+
+ payload[0] =
+ VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos));
+ payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */
+ 1, /* DPv1.3 signaling */
+ 2); /* UFP connected */
+ return 2;
+};
+
+__override void svdm_dp_post_config(int port)
+{
+ dp_flags[port] |= DP_FLAGS_DP_ON;
+}
+
+/**
+ * Is the port fine to be muxed its DisplayPort lines?
+ *
+ * Only one port can be muxed to DisplayPort at a time.
+ *
+ * @param port Port number of TCPC.
+ * @return 1 is fine; 0 is bad as other port is already muxed;
+ */
+static int is_dp_muxable(int port)
+{
+ int i;
+
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
+ if (i != port) {
+ if (usb_mux_get(i) & USB_PD_MUX_DP_ENABLED)
+ return 0;
+ }
+
+ return 1;
+}
+
+__override int svdm_dp_attention(int port, uint32_t *payload)
+{
+ const struct gpio_dt_spec *hpd =
+ GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det_r);
+ int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
+ int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
+ int cur_lvl = gpio_pin_get_dt(hpd);
+ mux_state_t mux_state;
+
+ dp_status[port] = payload[1];
+
+ if (!is_dp_muxable(port)) {
+ /* TODO(waihong): Info user? */
+ CPRINTS("p%d: The other port is already muxed.", port);
+ return 0;
+ }
+
+ /*
+ * Initial implementation to handle HPD. Only the first-plugged port
+ * works, i.e. sending HPD signal to AP. The second-plugged port
+ * will be ignored.
+ *
+ * TODO(waihong): Continue the above case, if the first-plugged port
+ * is then unplugged, switch to the second-plugged port and signal AP?
+ */
+ if (lvl) {
+ /*
+ * Enable and switch the DP port selection mux to the
+ * correct port.
+ *
+ * TODO(waihong): Better to move switching DP mux to
+ * the usb_mux abstraction.
+ */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel),
+ port == 1);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 0);
+
+ /* Connect the SBU lines in PPC chip. */
+ if (IS_ENABLED(CONFIG_USBC_PPC_SBU))
+ ppc_set_sbu(port, 1);
+
+ /*
+ * Connect the USB SS/DP lines in TCPC chip.
+ *
+ * When mf_pref not true, still use the dock muxing
+ * because of the board USB-C topology (limited to 2
+ * lanes DP).
+ */
+ usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT,
+ polarity_rm_dts(pd_get_polarity(port)));
+ } else {
+ /* Disconnect the DP port selection mux. */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0);
+
+ /* Disconnect the SBU lines in PPC chip. */
+ if (IS_ENABLED(CONFIG_USBC_PPC_SBU))
+ ppc_set_sbu(port, 0);
+
+ /* Disconnect the DP but keep the USB SS lines in TCPC chip. */
+ usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT,
+ polarity_rm_dts(pd_get_polarity(port)));
+ }
+
+ if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl))
+ /*
+ * Wake up the AP. IRQ or level high indicates a DP sink is now
+ * present.
+ */
+ pd_notify_dp_alt_mode_entry(port);
+
+ /* Configure TCPC for the HPD event, for proper muxing */
+ mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
+ (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ usb_mux_hpd_update(port, mux_state);
+
+ /* Signal AP for the HPD event, through GPIO to AP */
+ if (irq & cur_lvl) {
+ uint64_t now = get_time().val;
+ /* Wait for the minimum spacing between IRQ_HPD if needed */
+ if (now < svdm_hpd_deadline[port])
+ usleep(svdm_hpd_deadline[port] - now);
+
+ /* Generate IRQ_HPD pulse */
+ CPRINTS("C%d: Recv IRQ. HPD->0", port);
+ gpio_pin_set_dt(hpd, 0);
+ usleep(HPD_DSTREAM_DEBOUNCE_IRQ);
+ gpio_pin_set_dt(hpd, 1);
+ CPRINTS("C%d: Recv IRQ. HPD->1", port);
+
+ /* Set the minimum time delay (2ms) for the next HPD IRQ */
+ svdm_hpd_deadline[port] =
+ get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
+ } else if (irq & !lvl) {
+ CPRINTF("ERR:HPD:IRQ&LOW\n");
+ return 0;
+ } else {
+ CPRINTS("C%d: Recv lvl. HPD->%d", port, lvl);
+ gpio_pin_set_dt(hpd, lvl);
+ /* Set the minimum time delay (2ms) for the next HPD IRQ */
+ svdm_hpd_deadline[port] =
+ get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
+ }
+
+ return 1;
+}
+
+__override void svdm_exit_dp_mode(int port)
+{
+ CPRINTS("%s(%d)", __func__, port);
+ if (is_dp_muxable(port)) {
+ /* Disconnect the DP port selection mux. */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0);
+
+ /* Signal AP for the HPD low event */
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ CPRINTS("C%d: DP exit. HPD->0", port);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det_r),
+ 0);
+ }
+}
+#endif /* CONFIG_USB_PD_ALT_MODE_DFP */
diff --git a/zephyr/program/herobrine/src/usbc_config.c b/zephyr/program/herobrine/src/usbc_config.c
new file mode 100644
index 0000000000..3333a110da
--- /dev/null
+++ b/zephyr/program/herobrine/src/usbc_config.c
@@ -0,0 +1,282 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Herobrine board-specific USB-C configuration */
+
+#include "charge_manager.h"
+#include "charge_state.h"
+#include "charger.h"
+#include "charger/isl923x_public.h"
+#include "common.h"
+#include "config.h"
+#include "cros_board_info.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "ppc/sn5s330_public.h"
+#include "ppc/syv682x_public.h"
+#include "system.h"
+#include "tcpm/ps8xxx_public.h"
+#include "tcpm/tcpci.h"
+#include "timer.h"
+#include "usb_mux.h"
+#include "usb_pd.h"
+#include "usbc/ppc.h"
+#include "usbc_ocp.h"
+#include "usbc_ppc.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/* GPIO Interrupt Handlers */
+void tcpc_alert_event(enum gpio_signal signal)
+{
+ int port = -1;
+
+ switch (signal) {
+ case GPIO_USB_C0_PD_INT_ODL:
+ port = 0;
+ break;
+ case GPIO_USB_C1_PD_INT_ODL:
+ port = 1;
+ break;
+ default:
+ return;
+ }
+
+ schedule_deferred_pd_interrupt(port);
+}
+
+#ifdef CONFIG_PLATFORM_EC_USBA
+static void usba_oc_deferred(void)
+{
+ /* Use next number after all USB-C ports to indicate the USB-A port */
+ board_overcurrent_event(
+ CONFIG_USB_PD_PORT_MAX_COUNT,
+ !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_a0_oc_odl)));
+}
+DECLARE_DEFERRED(usba_oc_deferred);
+
+void usba_oc_interrupt(enum gpio_signal signal)
+{
+ hook_call_deferred(&usba_oc_deferred_data, 0);
+}
+#endif
+
+void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_SWCTL_INT_ODL:
+ ppc_chips[0].drv->interrupt(0);
+ break;
+
+ case GPIO_USB_C1_SWCTL_INT_ODL:
+ ppc_chips[1].drv->interrupt(1);
+ break;
+
+ default:
+ break;
+ }
+}
+
+int charger_profile_override(struct charge_state_data *curr)
+{
+ int usb_mv;
+ int port;
+
+ if (curr->state != ST_CHARGE)
+ return 0;
+
+ /* Lower the max requested voltage to 5V when battery is full. */
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF) &&
+ !(curr->batt.flags & BATT_FLAG_BAD_STATUS) &&
+ !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
+ (curr->batt.status & STATUS_FULLY_CHARGED))
+ usb_mv = 5000;
+ else
+ usb_mv = PD_MAX_VOLTAGE_MV;
+
+ if (pd_get_max_voltage() != usb_mv) {
+ CPRINTS("VBUS limited to %dmV", usb_mv);
+ for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++)
+ pd_set_external_voltage_limit(port, usb_mv);
+ }
+
+ return 0;
+}
+
+enum ec_status charger_profile_override_get_param(uint32_t param,
+ uint32_t *value)
+{
+ return EC_RES_INVALID_PARAM;
+}
+
+enum ec_status charger_profile_override_set_param(uint32_t param,
+ uint32_t value)
+{
+ return EC_RES_INVALID_PARAM;
+}
+
+#ifdef CONFIG_PLATFORM_EC_USBA
+/* Initialize board USC-C things */
+static void board_init_usbc(void)
+{
+ /* Enable USB-A overcurrent interrupt */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_oc));
+}
+DECLARE_HOOK(HOOK_INIT, board_init_usbc, HOOK_PRIO_DEFAULT);
+#endif
+
+void board_tcpc_init(void)
+{
+ /* Only reset TCPC if not sysjump */
+ if (!system_jumped_late()) {
+ /* TODO(crosbug.com/p/61098): How long do we need to wait? */
+ board_reset_pd_mcu();
+ }
+
+ /* Enable PPC interrupts */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_swctl));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_swctl));
+
+ /* Enable TCPC interrupts */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_pd));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_pd));
+
+ /*
+ * Initialize HPD to low; after sysjump SOC needs to see
+ * HPD pulse to enable video path
+ */
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
+}
+DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C);
+
+void board_reset_pd_mcu(void)
+{
+ cprints(CC_USB, "Resetting TCPCs...");
+ cflush();
+
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 0);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 0);
+ msleep(PS8XXX_RESET_DELAY_MS);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 1);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 1);
+ msleep(PS8805_FW_INIT_DELAY_MS);
+}
+
+void board_set_tcpc_power_mode(int port, int mode)
+{
+ /* Ignore the "mode" to turn the chip on. We can only do a reset. */
+ if (mode)
+ return;
+
+ board_reset_pd_mcu();
+}
+
+int board_vbus_sink_enable(int port, int enable)
+{
+ /* Both ports are controlled by PPC SN5S330 */
+ return ppc_vbus_sink_enable(port, enable);
+}
+
+int board_is_sourcing_vbus(int port)
+{
+ /* Both ports are controlled by PPC SN5S330 */
+ return ppc_is_sourcing_vbus(port);
+}
+
+void board_overcurrent_event(int port, int is_overcurrented)
+{
+ /* TODO(b/120231371): Notify AP */
+ CPRINTS("p%d: overcurrent!", port);
+}
+
+int board_set_active_charge_port(int port)
+{
+ int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
+ int i;
+
+ if (!is_real_port && port != CHARGE_PORT_NONE)
+ return EC_ERROR_INVAL;
+
+ if (port == CHARGE_PORT_NONE) {
+ CPRINTS("Disabling all charging port");
+
+ /* Disable all ports. */
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ /*
+ * Do not return early if one fails otherwise we can
+ * get into a boot loop assertion failure.
+ */
+ if (board_vbus_sink_enable(i, 0))
+ CPRINTS("Disabling p%d sink path failed.", i);
+ }
+
+ return EC_SUCCESS;
+ }
+
+ /* Check if the port is sourcing VBUS. */
+ if (board_is_sourcing_vbus(port)) {
+ CPRINTS("Skip enable p%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+ CPRINTS("New charge port: p%d", port);
+
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ if (i == port)
+ continue;
+
+ if (board_vbus_sink_enable(i, 0))
+ CPRINTS("p%d: sink path disable failed.", i);
+ }
+
+ /* Enable requested charge port. */
+ if (board_vbus_sink_enable(port, 1)) {
+ CPRINTS("p%d: sink path enable failed.", port);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ return EC_SUCCESS;
+}
+
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
+{
+ /*
+ * Ignore lower charge ceiling on PD transition if our battery is
+ * critical, as we may brownout.
+ */
+ if (supplier == CHARGE_SUPPLIER_PD && charge_ma < 1500 &&
+ charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) {
+ CPRINTS("Using max ilim %d", max_ma);
+ charge_ma = max_ma;
+ }
+
+ charge_set_input_current_limit(charge_ma, charge_mv);
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ uint16_t status = 0;
+
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl)))
+ if (gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l)))
+ status |= PD_STATUS_TCPC_ALERT_0;
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_int_odl)))
+ if (gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l)))
+ status |= PD_STATUS_TCPC_ALERT_1;
+
+ return status;
+}
diff --git a/zephyr/program/herobrine/switchcap.dtsi b/zephyr/program/herobrine/switchcap.dtsi
new file mode 100644
index 0000000000..fb2db35d1a
--- /dev/null
+++ b/zephyr/program/herobrine/switchcap.dtsi
@@ -0,0 +1,12 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ switchcap {
+ compatible = "cros-ec,switchcap-gpio";
+ enable-pin = <&gpio_switchcap_on>;
+ power-good-pin = <&gpio_switchcap_pg>;
+ };
+};
diff --git a/zephyr/program/herobrine/usbc.dtsi b/zephyr/program/herobrine/usbc.dtsi
new file mode 100644
index 0000000000..bed94800dd
--- /dev/null
+++ b/zephyr/program/herobrine/usbc.dtsi
@@ -0,0 +1,42 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ usbc {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port0: port0@0 {
+ compatible = "named-usbc-port";
+ reg = <0>;
+ bc12 = <&bc12_port0>;
+ ppc = <&ppc_port0>;
+ tcpc = <&tcpc_port0>;
+ chg = <&charger>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&usb_mux_0>;
+ };
+ };
+ usb_mux_0: usb-mux-0 {
+ compatible = "parade,usbc-mux-ps8xxx";
+ };
+
+ port1: port1@1 {
+ compatible = "named-usbc-port";
+ reg = <1>;
+ bc12 = <&bc12_port1>;
+ ppc = <&ppc_port1>;
+ tcpc = <&tcpc_port1>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&usb_mux_1>;
+ };
+ };
+ usb_mux_1: usb-mux-1 {
+ compatible = "parade,usbc-mux-ps8xxx";
+ };
+ };
+};
diff --git a/zephyr/program/herobrine/villager/gpio.dtsi b/zephyr/program/herobrine/villager/gpio.dtsi
new file mode 100644
index 0000000000..9884fc7fb2
--- /dev/null
+++ b/zephyr/program/herobrine/villager/gpio.dtsi
@@ -0,0 +1,317 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ aliases {
+ gpio-wp = &gpio_ec_wp_odl;
+ gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ };
+
+ named-gpios {
+ compatible = "named-gpios";
+
+ gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl {
+ gpios = <&gpioe 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_PD_INT_ODL";
+ };
+ gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl {
+ gpios = <&gpiof 5 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_PD_INT_ODL";
+ };
+ gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl {
+ gpios = <&gpio0 3 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
+ };
+ gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl {
+ gpios = <&gpio4 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
+ };
+ gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
+ gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
+ gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_usb_a0_oc_odl: usb_a0_oc_odl {
+ gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_chg_acok_od: chg_acok_od {
+ gpios = <&gpiod 2 GPIO_INPUT>;
+ enum-name = "GPIO_AC_PRESENT";
+ };
+ gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
+ gpios = <&gpio0 0 GPIO_INPUT>;
+ enum-name = "GPIO_POWER_BUTTON_L";
+ };
+ gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
+ gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_DOWN_L";
+ };
+ gpio_ec_volup_btn_odl: ec_volup_btn_odl {
+ gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_UP_L";
+ };
+ gpio_ec_wp_odl: ec_wp_odl {
+ gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ };
+ gpio_lid_open_ec: lid_open_ec {
+ gpios = <&gpio0 1 GPIO_INPUT>;
+ enum-name = "GPIO_LID_OPEN";
+ };
+ gpio_ap_rst_l: ap_rst_l {
+ gpios = <&gpio5 1 GPIO_INPUT>;
+ enum-name = "GPIO_AP_RST_L";
+ };
+ gpio_ps_hold: ps_hold {
+ gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_PS_HOLD";
+ };
+ gpio_ap_suspend: ap_suspend {
+ gpios = <&gpio5 7 GPIO_INPUT>;
+ enum-name = "GPIO_AP_SUSPEND";
+ };
+ gpio_mb_power_good: mb_power_good {
+ gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_POWER_GOOD";
+ };
+ gpio_warm_reset_l: warm_reset_l {
+ gpios = <&gpiob 0 GPIO_INPUT>;
+ enum-name = "GPIO_WARM_RESET_L";
+ };
+ ap_ec_spi_cs_l {
+ gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>;
+ };
+ gpio_tablet_mode_l: tablet_mode_l {
+ gpios = <&gpioc 6 GPIO_INPUT>;
+ enum-name = "GPIO_TABLET_MODE_L";
+ };
+ gpio_accel_gyro_int_l: accel_gyro_int_l {
+ gpios = <&gpioa 3 GPIO_INPUT>;
+ };
+ gpio_rtc_ec_wake_odl: rtc_ec_wake_odl {
+ gpios = <&gpio0 2 GPIO_INPUT>;
+ };
+ ec_entering_rw {
+ gpios = <&gpio7 2 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_ENTERING_RW";
+ };
+ ccd_mode_odl {
+ gpios = <&gpio6 3 GPIO_INPUT>;
+ enum-name = "GPIO_CCD_MODE_ODL";
+ };
+ ec_batt_pres_odl {
+ gpios = <&gpioe 5 GPIO_INPUT>;
+ enum-name = "GPIO_BATT_PRES_ODL";
+ };
+ ec_gsc_packet_mode {
+ gpios = <&gpio8 3 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_PACKET_MODE_EN";
+ };
+ pmic_resin_l {
+ gpios = <&gpioa 0 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PMIC_RESIN_L";
+ };
+ pmic_kpd_pwr_odl {
+ gpios = <&gpioa 2 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PMIC_KPD_PWR_ODL";
+ };
+ ap_ec_int_l {
+ gpios = <&gpio5 6 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_EC_INT_L";
+ };
+ gpio_switchcap_on: switchcap_on {
+ gpios = <&gpiod 5 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_SWITCHCAP_ON";
+ };
+ gpio_en_pp5000_s5: en_pp5000_s5 {
+ gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>;
+ enum-name = "GPIO_EN_PP5000";
+ };
+ ec_bl_disable_l {
+ /* The PMIC controls backlight enable and this pin must
+ * be HiZ for normal operation. But the backlight can
+ * be enabled by setting this pin low and configuring it
+ * as an output.
+ */
+ gpios = <&gpiob 6 GPIO_INPUT>;
+ enum-name = "GPIO_ENABLE_BACKLIGHT";
+ };
+ lid_accel_int_l {
+ gpios = <&gpioa 1 GPIO_INPUT>;
+ };
+ tp_int_gate {
+ gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
+ };
+ gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l {
+ gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l {
+ gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_dp_mux_oe_l: dp_mux_oe_l {
+ gpios = <&gpiob 1 GPIO_ODR_HIGH>;
+ };
+ gpio_dp_mux_sel: dp_mux_sel {
+ gpios = <&gpio4 5 GPIO_OUTPUT_LOW>;
+ };
+ gpio_dp_hot_plug_det_r: dp_hot_plug_det_r {
+ gpios = <&gpio9 5 GPIO_OUTPUT_LOW>;
+ };
+ gpio_en_usb_a_5v: en_usb_a_5v {
+ gpios = <&gpiof 0 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_EN_USB_A_5V";
+ };
+ usb_a_cdp_ilim_en_l {
+ gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_usb_c0_frs_en: usb_c0_frs_en {
+ gpios = <&gpioc 5 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_USB_C0_FRS_EN";
+ };
+ gpio_usb_c1_frs_en: usb_c1_frs_en {
+ gpios = <&gpioc 1 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_USB_C1_FRS_EN";
+ };
+ gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 {
+ gpios = <&gpio6 0 GPIO_OUTPUT_LOW>;
+ };
+ gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 {
+ gpios = <&gpioc 0 GPIO_OUTPUT_LOW>;
+ };
+ ap_ec_spi_mosi {
+ gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>;
+ };
+ ap_ec_spi_miso {
+ gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>;
+ };
+ ap_ec_spi_clk {
+ gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>;
+ };
+ gpio_brd_id0: brd_id0 {
+ gpios = <&gpio9 4 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION1";
+ };
+ gpio_brd_id1: brd_id1 {
+ gpios = <&gpio9 7 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION2";
+ };
+ gpio_brd_id2: brd_id2 {
+ gpios = <&gpioa 5 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION3";
+ };
+ gpio_sku_id0: sku_id0 {
+ gpios = <&gpio6 7 GPIO_INPUT>;
+ };
+ gpio_sku_id1: sku_id1 {
+ gpios = <&gpio7 0 GPIO_INPUT>;
+ };
+ gpio_sku_id2: sku_id2 {
+ gpios = <&gpioe 1 GPIO_INPUT>;
+ };
+ gpio_switchcap_pg: src_vph_pwr_pg {
+ gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_SWITCHCAP_PG";
+ };
+ arm_x86 {
+ gpios = <&gpio6 6 GPIO_OUTPUT_LOW>;
+ };
+ ec-i2c-sensor-scl {
+ gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec-i2c-sensor-sda {
+ gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_ec_kso_02_inv: ec_kso_02_inv {
+ gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
+ };
+ };
+
+ usba-port-enable-list {
+ compatible = "cros-ec,usba-port-enable-pins";
+ enable-pins = <&gpio_en_usb_a_5v>;
+ };
+
+ gpio_id_sku: sku {
+ compatible = "cros-ec,gpio-id";
+ bits = <
+ &gpio_sku_id0
+ &gpio_sku_id1
+ &gpio_sku_id2
+ >;
+ system = "ternary";
+ };
+
+ gpio_id_board: board {
+ compatible = "cros-ec,gpio-id";
+ bits = <
+ &gpio_brd_id0
+ &gpio_brd_id1
+ &gpio_brd_id2
+ >;
+ system = "ternary";
+ };
+
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios =
+ <&gpio5 2 0>,
+ <&gpio5 4 0>,
+ <&gpio7 6 0>,
+ <&gpiod 1 0>,
+ <&gpiod 0 0>,
+ <&gpioe 3 0>,
+ <&gpio0 4 0>,
+ <&gpiod 6 0>,
+ <&gpio3 2 0>,
+ <&gpio3 5 0>,
+ <&gpiod 7 0>,
+ <&gpio8 6 0>,
+ <&gpiod 4 0>,
+ <&gpio4 1 0>,
+ <&gpio3 4 0>,
+ <&gpioc 3 0>,
+ <&gpioc 4 0>,
+ <&gpioc 7 0>,
+ <&gpioa 4 0>,
+ <&gpio9 6 0>,
+ <&gpio9 3 0>,
+ <&gpioa 7 0>,
+ <&gpio5 0 0>,
+ <&gpio8 1 0>,
+ <&gpiob 7 0>;
+ };
+};
+
+/* Power switch logic input pads */
+&psl_in1_gpd2 {
+ /* ACOK_OD */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in2_gp00 {
+ /* EC_PWR_BTN_ODL */
+ psl-in-mode = "edge";
+ psl-in-pol = "low-falling";
+};
+
+&psl_in3_gp01 {
+ /* LID_OPEN_EC */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in4_gp02 {
+ /* RTC_EC_WAKE_ODL */
+ psl-in-mode = "edge";
+ psl-in-pol = "low-falling";
+};
+
+/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
+&power_ctrl_psl {
+ status = "okay";
+ pinctrl-names = "sleep";
+ pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>;
+};
diff --git a/zephyr/program/herobrine/villager/led_pins.dtsi b/zephyr/program/herobrine/villager/led_pins.dtsi
new file mode 100644
index 0000000000..2a74fce58c
--- /dev/null
+++ b/zephyr/program/herobrine/villager/led_pins.dtsi
@@ -0,0 +1,36 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_b_c0>;
+ led-values = <0 0>;
+ };
+
+ color_amber: color-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_b_c0>;
+ led-values = <1 0>;
+ };
+
+ color_blue: color-blue {
+ led-color = "LED_BLUE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_BLUE";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_b_c0>;
+ led-values = <0 1>;
+ };
+ };
+};
diff --git a/zephyr/projects/herobrine/led_policy_villager.dts b/zephyr/program/herobrine/villager/led_policy.dtsi
index f8996a3f4b..f8996a3f4b 100644
--- a/zephyr/projects/herobrine/led_policy_villager.dts
+++ b/zephyr/program/herobrine/villager/led_policy.dtsi
diff --git a/zephyr/projects/herobrine/motionsense_villager.dts b/zephyr/program/herobrine/villager/motionsense.dtsi
index 31d00e04a5..31d00e04a5 100644
--- a/zephyr/projects/herobrine/motionsense_villager.dts
+++ b/zephyr/program/herobrine/villager/motionsense.dtsi
diff --git a/zephyr/projects/herobrine/prj_villager.conf b/zephyr/program/herobrine/villager/project.conf
index 35eebe6d99..35eebe6d99 100644
--- a/zephyr/projects/herobrine/prj_villager.conf
+++ b/zephyr/program/herobrine/villager/project.conf
diff --git a/zephyr/program/herobrine/villager/project.overlay b/zephyr/program/herobrine/villager/project.overlay
new file mode 100644
index 0000000000..5f968e4e9b
--- /dev/null
+++ b/zephyr/program/herobrine/villager/project.overlay
@@ -0,0 +1,33 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Herobrine program common DTS includes */
+#include "../adc.dtsi"
+#include "../common.dtsi"
+#include "../i2c.dtsi"
+#include "../interrupts.dtsi"
+#include "../keyboard.dtsi"
+#include "../default_gpio_pinctrl.dtsi"
+#include "../switchcap.dtsi"
+#include "../usbc.dtsi"
+
+/* Villager project DTS includes*/
+#include "gpio.dtsi"
+#include "led_pins.dtsi"
+#include "led_policy.dtsi"
+#include "motionsense.dtsi"
+
+/* villager overrides follow... */
+/* battery overrides */
+/ {
+ batteries {
+ default_battery: ap19a5k {
+ compatible = "panasonic,ap19a5k", "battery-smart";
+ };
+ ap19a8k {
+ compatible = "lgc,ap19a8k", "battery-smart";
+ };
+ };
+};
diff --git a/zephyr/projects/herobrine/prj_zoglin.conf b/zephyr/program/herobrine/zoglin/project.conf
index 7f96cf6c79..7f96cf6c79 100644
--- a/zephyr/projects/herobrine/prj_zoglin.conf
+++ b/zephyr/program/herobrine/zoglin/project.conf
diff --git a/zephyr/program/herobrine/zoglin/project.overlay b/zephyr/program/herobrine/zoglin/project.overlay
new file mode 100644
index 0000000000..b631d4b490
--- /dev/null
+++ b/zephyr/program/herobrine/zoglin/project.overlay
@@ -0,0 +1,6 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "../hoglin/project.overlay"
diff --git a/zephyr/program/herobrine/zombie/gpio.dtsi b/zephyr/program/herobrine/zombie/gpio.dtsi
new file mode 100644
index 0000000000..711854fb79
--- /dev/null
+++ b/zephyr/program/herobrine/zombie/gpio.dtsi
@@ -0,0 +1,317 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ aliases {
+ gpio-wp = &gpio_ec_wp_odl;
+ gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ };
+
+ named-gpios {
+ compatible = "named-gpios";
+
+ gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl {
+ gpios = <&gpioe 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_PD_INT_ODL";
+ };
+ gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl {
+ gpios = <&gpiof 5 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_PD_INT_ODL";
+ };
+ gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl {
+ gpios = <&gpio0 3 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
+ };
+ gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl {
+ gpios = <&gpio4 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
+ };
+ gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
+ gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
+ gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_usb_a0_oc_odl: usb_a0_oc_odl {
+ gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_chg_acok_od: chg_acok_od {
+ gpios = <&gpiod 2 GPIO_INPUT>;
+ enum-name = "GPIO_AC_PRESENT";
+ };
+ gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
+ gpios = <&gpio0 0 GPIO_INPUT>;
+ enum-name = "GPIO_POWER_BUTTON_L";
+ };
+ gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
+ gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_DOWN_L";
+ };
+ gpio_ec_volup_btn_odl: ec_volup_btn_odl {
+ gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_UP_L";
+ };
+ gpio_ec_wp_odl: ec_wp_odl {
+ gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ };
+ gpio_lid_open_ec: lid_open_ec {
+ gpios = <&gpio0 1 GPIO_INPUT>;
+ enum-name = "GPIO_LID_OPEN";
+ };
+ gpio_ap_rst_l: ap_rst_l {
+ gpios = <&gpio5 1 GPIO_INPUT>;
+ enum-name = "GPIO_AP_RST_L";
+ };
+ gpio_ps_hold: ps_hold {
+ gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_PS_HOLD";
+ };
+ gpio_ap_suspend: ap_suspend {
+ gpios = <&gpio5 7 GPIO_INPUT>;
+ enum-name = "GPIO_AP_SUSPEND";
+ };
+ gpio_mb_power_good: mb_power_good {
+ gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_POWER_GOOD";
+ };
+ gpio_warm_reset_l: warm_reset_l {
+ gpios = <&gpiob 0 GPIO_INPUT>;
+ enum-name = "GPIO_WARM_RESET_L";
+ };
+ ap_ec_spi_cs_l {
+ gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>;
+ };
+ gpio_tablet_mode_l: tablet_mode_l {
+ gpios = <&gpioc 6 GPIO_INPUT>;
+ enum-name = "GPIO_TABLET_MODE_L";
+ };
+ gpio_accel_gyro_int_l: accel_gyro_int_l {
+ gpios = <&gpioa 3 GPIO_INPUT>;
+ };
+ gpio_rtc_ec_wake_odl: rtc_ec_wake_odl {
+ gpios = <&gpio0 2 GPIO_INPUT>;
+ };
+ ec_entering_rw {
+ gpios = <&gpio7 2 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_ENTERING_RW";
+ };
+ ccd_mode_odl {
+ gpios = <&gpio6 3 GPIO_INPUT>;
+ enum-name = "GPIO_CCD_MODE_ODL";
+ };
+ ec_batt_pres_odl {
+ gpios = <&gpioe 5 GPIO_INPUT>;
+ enum-name = "GPIO_BATT_PRES_ODL";
+ };
+ ec_gsc_packet_mode {
+ gpios = <&gpio8 3 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_PACKET_MODE_EN";
+ };
+ pmic_resin_l {
+ gpios = <&gpioa 0 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PMIC_RESIN_L";
+ };
+ pmic_kpd_pwr_odl {
+ gpios = <&gpioa 2 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PMIC_KPD_PWR_ODL";
+ };
+ ap_ec_int_l {
+ gpios = <&gpio5 6 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_EC_INT_L";
+ };
+ gpio_switchcap_on: switchcap_on {
+ gpios = <&gpiod 5 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_SWITCHCAP_ON";
+ };
+ gpio_en_pp5000_s5: en_pp5000_s5 {
+ gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>;
+ enum-name = "GPIO_EN_PP5000";
+ };
+ ec_bl_disable_l {
+ /* The PMIC controls backlight enable and this pin must
+ * be HiZ for normal operation. But the backlight can
+ * be enabled by setting this pin low and configuring it
+ * as an output.
+ */
+ gpios = <&gpiob 6 GPIO_INPUT>;
+ enum-name = "GPIO_ENABLE_BACKLIGHT";
+ };
+ lid_accel_int_l {
+ gpios = <&gpioa 1 GPIO_INPUT>;
+ };
+ tp_int_gate {
+ gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
+ };
+ gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l {
+ gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l {
+ gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_dp_mux_oe_l: dp_mux_oe_l {
+ gpios = <&gpiob 1 GPIO_ODR_HIGH>;
+ };
+ gpio_dp_mux_sel: dp_mux_sel {
+ gpios = <&gpio4 5 GPIO_OUTPUT_LOW>;
+ };
+ gpio_dp_hot_plug_det_r: dp_hot_plug_det_r {
+ gpios = <&gpio9 5 GPIO_OUTPUT_LOW>;
+ };
+ gpio_en_usb_a_5v: en_usb_a_5v {
+ gpios = <&gpiof 0 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_EN_USB_A_5V";
+ };
+ usb_a_cdp_ilim_en_l {
+ gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_usb_c0_frs_en: usb_c0_frs_en {
+ gpios = <&gpioc 5 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_USB_C0_FRS_EN";
+ };
+ gpio_usb_c1_frs_en: usb_c1_frs_en {
+ gpios = <&gpioc 1 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_USB_C1_FRS_EN";
+ };
+ gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 {
+ gpios = <&gpio6 0 GPIO_OUTPUT_LOW>;
+ };
+ gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 {
+ gpios = <&gpioc 0 GPIO_OUTPUT_LOW>;
+ };
+ ap_ec_spi_mosi {
+ gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>;
+ };
+ ap_ec_spi_miso {
+ gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>;
+ };
+ ap_ec_spi_clk {
+ gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>;
+ };
+ gpio_brd_id0: brd_id0 {
+ gpios = <&gpio9 4 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION1";
+ };
+ gpio_brd_id1: brd_id1 {
+ gpios = <&gpio9 7 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION2";
+ };
+ gpio_brd_id2: brd_id2 {
+ gpios = <&gpioa 5 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION3";
+ };
+ gpio_sku_id0: sku_id0 {
+ gpios = <&gpio6 7 GPIO_INPUT>;
+ };
+ gpio_sku_id1: sku_id1 {
+ gpios = <&gpio7 0 GPIO_INPUT>;
+ };
+ gpio_sku_id2: sku_id2 {
+ gpios = <&gpioe 1 GPIO_INPUT>;
+ };
+ gpio_switchcap_pg: src_vph_pwr_pg {
+ gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_SWITCHCAP_PG";
+ };
+ arm_x86 {
+ gpios = <&gpio6 6 GPIO_OUTPUT_LOW>;
+ };
+ ec-i2c-sensor-scl {
+ gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec-i2c-sensor-sda {
+ gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_ec_kso_02_inv: ec_kso_02_inv {
+ gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
+ };
+ };
+
+ usba-port-enable-list {
+ compatible = "cros-ec,usba-port-enable-pins";
+ enable-pins = <&gpio_en_usb_a_5v>;
+ };
+
+ gpio_id_sku: sku {
+ compatible = "cros-ec,gpio-id";
+ bits = <
+ &gpio_sku_id0
+ &gpio_sku_id1
+ &gpio_sku_id2
+ >;
+ system = "ternary";
+ };
+
+ gpio_id_board: board {
+ compatible = "cros-ec,gpio-id";
+ bits = <
+ &gpio_brd_id0
+ &gpio_brd_id1
+ &gpio_brd_id2
+ >;
+ system = "ternary";
+ };
+
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios =
+ <&gpio5 2 0>,
+ <&gpio5 4 0>,
+ <&gpio7 6 0>,
+ <&gpiod 1 0>,
+ <&gpiod 0 0>,
+ <&gpioe 3 0>,
+ <&gpio0 4 0>,
+ <&gpiod 6 0>,
+ <&gpio3 2 0>,
+ <&gpio3 5 0>,
+ <&gpiod 7 0>,
+ <&gpio8 6 0>,
+ <&gpiod 4 0>,
+ <&gpio4 1 0>,
+ <&gpio3 4 0>,
+ <&gpioc 3 0>,
+ <&gpioc 4 0>,
+ <&gpioc 7 0>,
+ <&gpioa 4 0>,
+ <&gpio9 6 0>,
+ <&gpio9 3 0>,
+ <&gpioa 7 0>,
+ <&gpio5 0 0>,
+ <&gpio8 1 0>,
+ <&gpiob 7 0>;
+ };
+};
+
+/* Power switch logic input pads */
+&psl_in1_gpd2 {
+ /* ACOK_OD */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in2_gp00 {
+ /* EC_PWR_BTN_ODL */
+ psl-in-mode = "edge";
+ psl-in-pol = "low-falling";
+};
+
+&psl_in3_gp01 {
+ /* LID_OPEN_EC */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in4_gp02 {
+ /* RTC_EC_WAKE_ODL */
+ psl-in-mode = "edge";
+ psl-in-pol = "low-falling";
+};
+
+/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
+&power_ctrl_psl {
+ status = "okay";
+ pinctrl-names = "sleep";
+ pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>;
+};
diff --git a/zephyr/program/herobrine/zombie/led_pins.dtsi b/zephyr/program/herobrine/zombie/led_pins.dtsi
new file mode 100644
index 0000000000..2a74fce58c
--- /dev/null
+++ b/zephyr/program/herobrine/zombie/led_pins.dtsi
@@ -0,0 +1,36 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_b_c0>;
+ led-values = <0 0>;
+ };
+
+ color_amber: color-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_b_c0>;
+ led-values = <1 0>;
+ };
+
+ color_blue: color-blue {
+ led-color = "LED_BLUE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_BLUE";
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_b_c0>;
+ led-values = <0 1>;
+ };
+ };
+};
diff --git a/zephyr/projects/herobrine/led_policy_zombie.dts b/zephyr/program/herobrine/zombie/led_policy.dtsi
index f8996a3f4b..f8996a3f4b 100644
--- a/zephyr/projects/herobrine/led_policy_zombie.dts
+++ b/zephyr/program/herobrine/zombie/led_policy.dtsi
diff --git a/zephyr/projects/herobrine/motionsense_zombie.dts b/zephyr/program/herobrine/zombie/motionsense.dtsi
index e069564b35..e069564b35 100644
--- a/zephyr/projects/herobrine/motionsense_zombie.dts
+++ b/zephyr/program/herobrine/zombie/motionsense.dtsi
diff --git a/zephyr/projects/herobrine/prj_zombie.conf b/zephyr/program/herobrine/zombie/project.conf
index 037ab5cc05..037ab5cc05 100644
--- a/zephyr/projects/herobrine/prj_zombie.conf
+++ b/zephyr/program/herobrine/zombie/project.conf
diff --git a/zephyr/program/herobrine/zombie/project.overlay b/zephyr/program/herobrine/zombie/project.overlay
new file mode 100644
index 0000000000..e5b530dc5f
--- /dev/null
+++ b/zephyr/program/herobrine/zombie/project.overlay
@@ -0,0 +1,30 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Herobrine program common DTS includes */
+#include "../adc.dtsi"
+#include "../common.dtsi"
+#include "../i2c.dtsi"
+#include "../interrupts.dtsi"
+#include "../keyboard.dtsi"
+#include "../default_gpio_pinctrl.dtsi"
+#include "../switchcap.dtsi"
+#include "../usbc.dtsi"
+
+/* Zombie project DTS includes*/
+#include "gpio.dtsi"
+#include "led_pins.dtsi"
+#include "led_policy.dtsi"
+#include "motionsense.dtsi"
+
+/* zombie overrides follow... */
+/* battery overrides */
+/ {
+ batteries {
+ default_battery: sg20 {
+ compatible = "ganfeng,sg20", "battery-smart";
+ };
+ };
+};
diff --git a/zephyr/projects/intelrvp/BUILD.py b/zephyr/program/intelrvp/BUILD.py
index f129b3d2d2..f129b3d2d2 100644
--- a/zephyr/projects/intelrvp/BUILD.py
+++ b/zephyr/program/intelrvp/BUILD.py
diff --git a/zephyr/projects/intelrvp/CMakeLists.txt b/zephyr/program/intelrvp/CMakeLists.txt
index 039627dec6..039627dec6 100644
--- a/zephyr/projects/intelrvp/CMakeLists.txt
+++ b/zephyr/program/intelrvp/CMakeLists.txt
diff --git a/zephyr/projects/intelrvp/Kconfig b/zephyr/program/intelrvp/Kconfig
index 605f57c054..605f57c054 100644
--- a/zephyr/projects/intelrvp/Kconfig
+++ b/zephyr/program/intelrvp/Kconfig
diff --git a/zephyr/projects/intelrvp/adlrvp/CMakeLists.txt b/zephyr/program/intelrvp/adlrvp/CMakeLists.txt
index 71dee29552..71dee29552 100644
--- a/zephyr/projects/intelrvp/adlrvp/CMakeLists.txt
+++ b/zephyr/program/intelrvp/adlrvp/CMakeLists.txt
diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts
new file mode 100644
index 0000000000..39fd720290
--- /dev/null
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts
@@ -0,0 +1,200 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ hibernate-wake-pins {
+ compatible = "cros-ec,hibernate-wake-pins";
+ wakeup-irqs = <
+ &int_ac_present
+ &int_lid_open
+ &int_power_button
+ >;
+ };
+
+ named-i2c-ports {
+ compatible = "named-i2c-ports";
+
+ i2c_charger: charger {
+ i2c-port = <&i2c_smb_0>;
+ enum-names = "I2C_PORT_BATTERY",
+ "I2C_PORT_CHARGER",
+ "I2C_PORT_EEPROM",
+ "I2C_PORT_PORT80";
+ };
+ typec_0: typec-0 {
+ i2c-port = <&i2c_smb_1>;
+ enum-names = "I2C_PORT_TYPEC_0";
+ };
+ typec_1: typec-1 {
+ i2c-port = <&i2c_smb_2>;
+ enum-names = "I2C_PORT_TYPEC_1";
+ };
+ typec_2: typec-2 {
+ i2c-port = <&i2c_smb_3>;
+ enum-names = "I2C_PORT_TYPEC_2";
+ };
+ typec_3: typec-3 {
+ i2c-port = <&i2c_smb_4>;
+ enum-names = "I2C_PORT_TYPEC_3";
+ };
+ };
+};
+
+/* charger */
+&i2c_smb_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+ port_sel = <0>;
+ pinctrl-0 = <&i2c00_scl_gpio004 &i2c00_sda_gpio003>;
+ pinctrl-names = "default";
+
+ pca95xx: pca95xx@22 {
+ compatible = "nxp,pca95xx";
+ label = "PCA95XX";
+ reg = <0x22>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <16>;
+ };
+
+ rvp_board_id: rvp-board-id {
+ compatible = "intel,rvp-board-id";
+
+ /*
+ * BOM ID [2] : IOEX[0]
+ * BOM ID [1:0] : IOEX[15:14]
+ */
+ bom-gpios = <&pca95xx 0 0>, <&pca95xx 15 0>, <&pca95xx 14 0>;
+
+ /*
+ * FAB ID [1:0] : IOEX[2:1]
+ */
+ fab-gpios = <&pca95xx 2 0>, <&pca95xx 1 0>;
+
+ /*
+ * BOARD ID[5:0] : IOEX[13:8]
+ */
+ board-gpios = <&pca95xx 13 0>, <&pca95xx 12 0>, <&pca95xx 11 0>,
+ <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>;
+ };
+
+ max695x@38 {
+ compatible = "maxim,max695x";
+ reg = <0x38>;
+ };
+
+ charger: isl9241@9 {
+ compatible = "intersil,isl9241";
+ status = "okay";
+ reg = <0x9>;
+ };
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+};
+
+/* typec_0 */
+&i2c_smb_1 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ port_sel = <6>;
+ pinctrl-0 = <&i2c06_scl_gpio140 &i2c06_sda_gpio132>;
+ pinctrl-names = "default";
+
+ tcpc_port0: fusb302@22 {
+ compatible = "fairchild,fusb302";
+ reg = <0x22>;
+ };
+
+ usb_c0_soc_side_bb_retimer: jhl8040r-c0-soc-side@54 {
+ compatible = "intel,jhl8040r";
+ reg = <0x54>;
+ reset-pin = <&usb_c0_bb_retimer_rst>;
+ ls-en-pin = <&usb_c0_bb_retimer_ls_en>;
+ };
+
+ usb_c0_bb_retimer: jhl8040r-c0@56 {
+ compatible = "intel,jhl8040r";
+ reg = <0x56>;
+ reset-pin = <&usb_c0_bb_retimer_rst>;
+ ls-en-pin = <&usb_c0_bb_retimer_ls_en>;
+ };
+};
+
+/* typec_1 */
+&i2c_smb_2 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ port_sel = <3>;
+ pinctrl-0 = <&i2c03_scl_gpio010 &i2c03_sda_gpio007>;
+ pinctrl-names = "default";
+
+ tcpc_port1: fusb302@22 {
+ compatible = "fairchild,fusb302";
+ reg = <0x22>;
+ };
+
+ usb_c1_soc_side_bb_retimer: jhl8040r-c1-soc-side@55 {
+ compatible = "intel,jhl8040r";
+ reg = <0x55>;
+ reset-pin = <&usb_c1_bb_retimer_rst>;
+ ls-en-pin = <&usb_c1_bb_retimer_ls_en>;
+ };
+
+ usb_c1_bb_retimer: jhl8040r-c1@57 {
+ compatible = "intel,jhl8040r";
+ reg = <0x57>;
+ reset-pin = <&usb_c1_bb_retimer_rst>;
+ ls-en-pin = <&usb_c1_bb_retimer_ls_en>;
+ };
+};
+
+/* typec_2 */
+&i2c_smb_3 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ port_sel = <7>;
+ pinctrl-0 = <&i2c07_scl_gpio013 &i2c07_sda_gpio012>;
+ pinctrl-names = "default";
+
+ tcpc_port2: fusb302@22 {
+ compatible = "fairchild,fusb302";
+ reg = <0x22>;
+ };
+
+ usb_c2_bb_retimer: jhl8040r-c2@58 {
+ compatible = "intel,jhl8040r";
+ reg = <0x58>;
+ reset-pin = <&usb_c2_bb_retimer_rst>;
+ ls-en-pin = <&usb_c2_bb_retimer_ls_en>;
+ };
+};
+
+/* typec_3 */
+&i2c_smb_4 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ port_sel = <2>;
+ pinctrl-0 = <&i2c02_scl_gpio155 &i2c02_sda_gpio154>;
+ pinctrl-names = "default";
+
+ tcpc_port3: fusb302@22 {
+ compatible = "fairchild,fusb302";
+ reg = <0x22>;
+ };
+
+ usb_c3_bb_retimer: jhl8040r-c3@59 {
+ compatible = "intel,jhl8040r";
+ reg = <0x59>;
+ reset-pin = <&usb_c3_bb_retimer_rst>;
+ ls-en-pin = <&usb_c3_bb_retimer_ls_en>;
+ };
+};
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts
index 1c760120f1..1c760120f1 100644
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/bb_retimer.dts
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/gpio.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/gpio.dts
index d526fdcb3b..d526fdcb3b 100644
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/gpio.dts
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/gpio.dts
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts
index 17986fe2c7..17986fe2c7 100644
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/interrupts.dts
diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts
new file mode 100644
index 0000000000..2601da793d
--- /dev/null
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts
@@ -0,0 +1,31 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ cros-keyscan {
+ compatible = "cros-ec,keyscan";
+
+ output-settle = <80>;
+ debounce-down = <9000>;
+ debounce-up = <30000>;
+ poll-timeout = <100000>;
+
+ actual-key-mask = <
+ 0x14 /* C0 */
+ 0xff /* C1 */
+ 0xff /* C2 */
+ 0xff /* C3 */
+ 0xff /* C4 */
+ 0xf5 /* C5 */
+ 0xff /* C6 */
+ 0xa4 /* C7 */
+ 0xff /* C8 */
+ 0xfe /* C9 */
+ 0x55 /* C10 */
+ 0xfa /* C11 */
+ 0xca /* C12 */
+ >;
+ };
+};
diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf
new file mode 100644
index 0000000000..d7220368a2
--- /dev/null
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/prj.conf
@@ -0,0 +1,75 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_BOARD_ADLRVP_MCHP=y
+CONFIG_CROS_SYSTEM_XEC=y
+
+# For MCHP ESPI Drivers
+CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD=y
+CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION=y
+CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE=y
+CONFIG_ESPI_PERIPHERAL_XEC_EMI0=y
+CONFIG_ESPI_PERIPHERAL_ACPI_EC_IBF_EVT_DATA=y
+CONFIG_ESPI_PERIPHERAL_KBC_OBE_CBK=y
+CONFIG_ESPI_PERIPHERAL_KBC_IBF_EVT_DATA=y
+
+# Invoke SoC Python script to create zephyr.mchp.bin which
+# is zephyr.bin processed for Boot-ROM loading.
+CONFIG_MCHP_MEC_UNSIGNED_HEADER=y
+CONFIG_MCHP_MEC_HEADER_FLASH_SIZE_256K=y
+
+# Support Zephyr SPI NOR driver to work with MCHP SPI driver
+CONFIG_SPI_NOR=y
+CONFIG_SPI_XEC_QMSPI_FULL_DUPLEX=y
+
+# Sensors - MCHP TACH driver under sensor
+CONFIG_SENSOR=n
+CONFIG_SENSOR_SHELL=n
+
+# Debug option
+# Enable flash console commands
+CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=y
+
+
+## TODO - support following features next
+# Fan
+CONFIG_PLATFORM_EC_FAN=n
+
+# RTC
+CONFIG_PLATFORM_EC_RTC=n
+
+# PWM
+CONFIG_PWM=n
+
+## INTEL RVP
+# Host command
+CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET=n
+
+# Power Sequencing
+CONFIG_PLATFORM_EC_THROTTLE_AP=n
+
+## ADL RVP
+# CBI
+CONFIG_EEPROM=n
+
+# LED
+CONFIG_PLATFORM_EC_LED_COMMON=n
+CONFIG_PLATFORM_EC_LED_PWM=n
+CONFIG_PLATFORM_EC_LED_PWM_TASK_DISABLED=n
+
+# Temperature sensors
+CONFIG_PLATFORM_EC_TEMP_SENSOR=n
+CONFIG_PLATFORM_EC_THERMISTOR=n
+CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=n
+
+# Charger
+CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y
+
+# H1 issues second reset
+CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n
+
+# Debug options
+# Enable flash console commands
+CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=y
+CONFIG_WDT_DISABLE_AT_BOOT=y
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/usbc.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/usbc.dts
index 471a1f52e9..471a1f52e9 100644
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/usbc.dts
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_mchp/usbc.dts
diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts
new file mode 100644
index 0000000000..b8fbd6656d
--- /dev/null
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts
@@ -0,0 +1,257 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ chosen {
+ cros,rtc = &mtc;
+ };
+
+ hibernate-wake-pins {
+ compatible = "cros-ec,hibernate-wake-pins";
+ wakeup-irqs = <
+ &int_ac_present
+ &int_lid_open
+ &int_power_button
+ >;
+ };
+
+ named-i2c-ports {
+ compatible = "named-i2c-ports";
+
+ i2c_charger: charger {
+ i2c-port = <&i2c7_0>;
+ enum-names = "I2C_PORT_BATTERY",
+ "I2C_PORT_CHARGER",
+ "I2C_PORT_EEPROM",
+ "I2C_PORT_PORT80";
+ };
+ typec_0: typec-0 {
+ i2c-port = <&i2c0_0>;
+ enum-names = "I2C_PORT_TYPEC_0";
+ };
+ typec_1: typec-1 {
+ i2c-port = <&i2c2_0>;
+ enum-names = "I2C_PORT_TYPEC_1";
+ };
+ typec_2: typec-2 {
+ i2c-port = <&i2c1_0>;
+ enum-names = "I2C_PORT_TYPEC_2";
+ };
+ typec_3: typec-3 {
+ i2c-port = <&i2c3_0>;
+ enum-names = "I2C_PORT_TYPEC_3";
+ };
+ };
+
+ named-adc-channels {
+ compatible = "named-adc-channels";
+
+ adc_ambient: ambient {
+ enum-name = "ADC_TEMP_SENSOR_1";
+ io-channels = <&adc0 3>;
+ };
+ adc_ddr: ddr {
+ enum-name = "ADC_TEMP_SENSOR_2";
+ io-channels = <&adc0 4>;
+ };
+ adc_skin: skin {
+ enum-name = "ADC_TEMP_SENSOR_3";
+ io-channels = <&adc0 2>;
+ };
+ adc_vr: vr {
+ enum-name = "ADC_TEMP_SENSOR_4";
+ io-channels = <&adc0 1>;
+ };
+ };
+
+};
+
+/* host interface */
+&espi0 {
+ status = "okay";
+ pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
+ pinctrl-names = "default";
+};
+
+/* charger */
+&i2c7_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+ pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
+ pinctrl-names = "default";
+
+ pca95xx: pca95xx@22 {
+ compatible = "nxp,pca95xx";
+ label = "PCA95XX";
+ reg = <0x22>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <16>;
+ };
+
+ rvp_board_id: rvp-board-id {
+ compatible = "intel,rvp-board-id";
+
+ /*
+ * BOM ID [2] : IOEX[0]
+ * BOM ID [1:0] : IOEX[15:14]
+ */
+ bom-gpios = <&pca95xx 0 0>, <&pca95xx 15 0>, <&pca95xx 14 0>;
+
+ /*
+ * FAB ID [1:0] : IOEX[2:1]
+ */
+ fab-gpios = <&pca95xx 2 0>, <&pca95xx 1 0>;
+
+ /*
+ * BOARD ID[5:0] : IOEX[13:8]
+ */
+ board-gpios = <&pca95xx 13 0>, <&pca95xx 12 0>, <&pca95xx 11 0>,
+ <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>;
+ };
+
+ max695x@38 {
+ compatible = "maxim,max695x";
+ reg = <0x38>;
+ };
+
+ charger: isl9241@9 {
+ compatible = "intersil,isl9241";
+ status = "okay";
+ reg = <0x9>;
+ };
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+};
+
+&i2c_ctrl7 {
+ status = "okay";
+};
+
+/* typec_0 */
+&i2c0_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
+ pinctrl-names = "default";
+
+ tcpc_port0: fusb302@22 {
+ compatible = "fairchild,fusb302";
+ reg = <0x22>;
+ };
+
+ usb_c0_soc_side_bb_retimer: jhl8040r-c0-soc-side@54 {
+ compatible = "intel,jhl8040r";
+ reg = <0x54>;
+ reset-pin = <&usb_c0_bb_retimer_rst>;
+ ls-en-pin = <&usb_c0_bb_retimer_ls_en>;
+ };
+
+ usb_c0_bb_retimer: jhl8040r-c0@56 {
+ compatible = "intel,jhl8040r";
+ reg = <0x56>;
+ reset-pin = <&usb_c0_bb_retimer_rst>;
+ ls-en-pin = <&usb_c0_bb_retimer_ls_en>;
+ };
+};
+
+&i2c_ctrl0 {
+ status = "okay";
+};
+
+/* typec_1 */
+&i2c2_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>;
+ pinctrl-names = "default";
+
+ tcpc_port1: fusb302@22 {
+ compatible = "fairchild,fusb302";
+ reg = <0x22>;
+ };
+
+ usb_c1_soc_side_bb_retimer: jhl8040r-c1-soc-side@55 {
+ compatible = "intel,jhl8040r";
+ reg = <0x55>;
+ reset-pin = <&usb_c1_bb_retimer_rst>;
+ ls-en-pin = <&usb_c1_bb_retimer_ls_en>;
+ };
+
+ usb_c1_bb_retimer: jhl8040r-c1@57 {
+ compatible = "intel,jhl8040r";
+ reg = <0x57>;
+ reset-pin = <&usb_c1_bb_retimer_rst>;
+ ls-en-pin = <&usb_c1_bb_retimer_ls_en>;
+ };
+};
+
+&i2c_ctrl2 {
+ status = "okay";
+};
+
+/* typec_2 */
+&i2c1_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
+ pinctrl-names = "default";
+
+ tcpc_port2: fusb302@22 {
+ compatible = "fairchild,fusb302";
+ reg = <0x22>;
+ };
+
+ usb_c2_bb_retimer: jhl8040r-c2@58 {
+ compatible = "intel,jhl8040r";
+ reg = <0x58>;
+ reset-pin = <&usb_c2_bb_retimer_rst>;
+ ls-en-pin = <&usb_c2_bb_retimer_ls_en>;
+ };
+};
+
+&i2c_ctrl1 {
+ status = "okay";
+};
+
+/* typec_3 */
+&i2c3_0 {
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
+ pinctrl-names = "default";
+
+ tcpc_port3: fusb302@22 {
+ compatible = "fairchild,fusb302";
+ reg = <0x22>;
+ };
+
+ usb_c3_bb_retimer: jhl8040r-c3@59 {
+ compatible = "intel,jhl8040r";
+ reg = <0x59>;
+ reset-pin = <&usb_c3_bb_retimer_rst>;
+ ls-en-pin = <&usb_c3_bb_retimer_ls_en>;
+ };
+};
+
+&i2c_ctrl3 {
+ status = "okay";
+};
+
+&adc0 {
+ status = "okay";
+ pinctrl-0 = <&adc0_chan1_gp44
+ &adc0_chan2_gp43
+ &adc0_chan3_gp42
+ &adc0_chan4_gp41>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/fan.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/fan.dts
index 8babe53903..8babe53903 100644
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/fan.dts
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/fan.dts
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/gpio.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/gpio.dts
index 1d38fc877c..1d38fc877c 100644
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/gpio.dts
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/gpio.dts
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts
index d7bb40fad2..d7bb40fad2 100644
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/interrupts.dts
diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts
new file mode 100644
index 0000000000..be0a570e95
--- /dev/null
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts
@@ -0,0 +1,59 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ cros-keyscan {
+ compatible = "cros-ec,keyscan";
+
+ output-settle = <35>;
+ debounce-down = <5000>;
+ debounce-up = <40000>;
+ poll-timeout = <100000>;
+
+ actual-key-mask = <
+ 0x14 /* C0 */
+ 0xff /* C1 */
+ 0xff /* C2 */
+ 0xff /* C3 */
+ 0xff /* C4 */
+ 0xf5 /* C5 */
+ 0xff /* C6 */
+ 0xa4 /* C7 */
+ 0xff /* C8 */
+ 0xfe /* C9 */
+ 0x55 /* C10 */
+ 0xfa /* C11 */
+ 0xca /* C12 */
+ >;
+ };
+};
+
+&cros_kb_raw {
+ status = "okay";
+ /* No KSO2 (it's inverted and implemented by GPIO) */
+ pinctrl-0 = <
+ &ksi0_gp31
+ &ksi1_gp30
+ &ksi2_gp27
+ &ksi3_gp26
+ &ksi4_gp25
+ &ksi5_gp24
+ &ksi6_gp23
+ &ksi7_gp22
+ &kso00_gp21
+ &kso01_gp20
+ &kso03_gp16
+ &kso04_gp15
+ &kso05_gp14
+ &kso06_gp13
+ &kso07_gp12
+ &kso08_gp11
+ &kso09_gp10
+ &kso10_gp07
+ &kso11_gp06
+ &kso12_gp05
+ >;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf
new file mode 100644
index 0000000000..d04abada31
--- /dev/null
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/prj.conf
@@ -0,0 +1,13 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_BOARD_ADLRVP_NPCX=y
+CONFIG_CROS_SYSTEM_NPCX=y
+CONFIG_SYSCON=y
+
+# Charger
+CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y
+
+# RTC
+CONFIG_PLATFORM_EC_RTC=y
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts
index eb1576dbff..eb1576dbff 100644
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/pwm_leds.dts
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts
index 93ecaa02f6..93ecaa02f6 100644
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/temp_sensor.dts
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/usbc.dts
index 471a1f52e9..471a1f52e9 100644
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/usbc.dts
+++ b/zephyr/program/intelrvp/adlrvp/adlrvp_npcx/usbc.dts
diff --git a/zephyr/projects/intelrvp/adlrvp/battery.dts b/zephyr/program/intelrvp/adlrvp/battery.dts
index 1de4111791..1de4111791 100644
--- a/zephyr/projects/intelrvp/adlrvp/battery.dts
+++ b/zephyr/program/intelrvp/adlrvp/battery.dts
diff --git a/zephyr/projects/intelrvp/adlrvp/include/adlrvp_zephyr.h b/zephyr/program/intelrvp/adlrvp/include/adlrvp_zephyr.h
index 135fd4ef4f..135fd4ef4f 100644
--- a/zephyr/projects/intelrvp/adlrvp/include/adlrvp_zephyr.h
+++ b/zephyr/program/intelrvp/adlrvp/include/adlrvp_zephyr.h
diff --git a/zephyr/projects/intelrvp/adlrvp/ioex.dts b/zephyr/program/intelrvp/adlrvp/ioex.dts
index 3e2227dacb..3e2227dacb 100644
--- a/zephyr/projects/intelrvp/adlrvp/ioex.dts
+++ b/zephyr/program/intelrvp/adlrvp/ioex.dts
diff --git a/zephyr/program/intelrvp/adlrvp/prj.conf b/zephyr/program/intelrvp/adlrvp/prj.conf
new file mode 100644
index 0000000000..df0811ecdd
--- /dev/null
+++ b/zephyr/program/intelrvp/adlrvp/prj.conf
@@ -0,0 +1,64 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Power Sequencing
+CONFIG_AP_X86_INTEL_TGL=y
+CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE=n
+CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
+CONFIG_PLATFORM_EC_POWERSEQ_ICELAKE=y
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y
+CONFIG_PLATFORM_EC_BATTERY_V2=y
+
+# BC1.2
+CONFIG_PLATFORM_EC_USB_CHARGER=n
+
+# CBI
+CONFIG_EEPROM=y
+
+# Charger
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10
+CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=n
+CONFIG_PLATFORM_EC_CHARGER_BQ25720=y
+CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM=y
+CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_DV=70
+CONFIG_PLATFORM_EC_CHARGER_ISL9241=y
+CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_COMMON=y
+CONFIG_PLATFORM_EC_LED_PWM_TASK_DISABLED=y
+
+# Temperature sensors
+CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y
+
+# USB-C and PD
+CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
+CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n
+CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n
+CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG=n
+CONFIG_PLATFORM_EC_USB_MUX_TUSB1044=y
+CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_REV30=y
+CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y
+CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y
+CONFIG_PLATFORM_EC_USB_PD_USB4=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_FUSB302=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y
+CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y
+CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=y
+
+# IOEX
+CONFIG_PLATFORM_EC_IOEX_PCA9675=y
+
+# eSPI
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US=150
diff --git a/zephyr/program/intelrvp/adlrvp/src/adlrvp.c b/zephyr/program/intelrvp/adlrvp/src/adlrvp.c
new file mode 100644
index 0000000000..d7d192b1af
--- /dev/null
+++ b/zephyr/program/intelrvp/adlrvp/src/adlrvp.c
@@ -0,0 +1,430 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* TODO: b/218904113: Convert to using Zephyr GPIOs */
+#include "adlrvp_zephyr.h"
+#include "battery.h"
+#include "battery_fuel_gauge.h"
+#include "bq25710.h"
+#include "charger.h"
+#include "common.h"
+#include "console.h"
+#include "driver/retimer/bb_retimer_public.h"
+#include "extpower.h"
+#include "gpio_signal.h"
+#include "hooks.h"
+#include "intel_rvp_board_id.h"
+#include "intelrvp.h"
+#include "ioexpander.h"
+#include "isl9241.h"
+#include "power/icelake.h"
+#include "sn5s330.h"
+#include "system.h"
+#include "task.h"
+#include "tusb1064.h"
+#include "usb_mux.h"
+#include "usbc/usb_muxes.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+#define CPRINTF(format, args...) cprintf(CC_COMMAND, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_COMMAND, format, ##args)
+
+/* TCPC AIC GPIO Configuration */
+const struct tcpc_aic_gpio_config_t tcpc_aic_gpios[] = {
+ [TYPE_C_PORT_0] = {
+ .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p0)),
+ .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p0)),
+ .ppc_intr_handler = sn5s330_interrupt,
+ },
+#if defined(HAS_TASK_PD_C1)
+ [TYPE_C_PORT_1] = {
+ .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p1)),
+ .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p1)),
+ .ppc_intr_handler = sn5s330_interrupt,
+ },
+#endif
+#if defined(HAS_TASK_PD_C2)
+ [TYPE_C_PORT_2] = {
+ .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p2)),
+ .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p2)),
+ .ppc_intr_handler = sn5s330_interrupt,
+ },
+#endif
+#if defined(HAS_TASK_PD_C3)
+ [TYPE_C_PORT_3] = {
+ .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p3)),
+ .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p3)),
+ .ppc_intr_handler = sn5s330_interrupt,
+ },
+#endif
+};
+BUILD_ASSERT(ARRAY_SIZE(tcpc_aic_gpios) == CONFIG_USB_PD_PORT_MAX_COUNT);
+
+/* USB-C PPC configuration */
+struct ppc_config_t ppc_chips[] = {
+ [TYPE_C_PORT_0] = {
+ .i2c_port = I2C_PORT_TYPEC_0,
+ .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC,
+ .drv = &sn5s330_drv,
+ },
+#if defined(HAS_TASK_PD_C1)
+ [TYPE_C_PORT_1] = {
+ .i2c_port = I2C_PORT_TYPEC_1,
+ .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC,
+ .drv = &sn5s330_drv
+ },
+#endif
+#if defined(HAS_TASK_PD_C2)
+ [TYPE_C_PORT_2] = {
+ .i2c_port = I2C_PORT_TYPEC_2,
+ .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC,
+ .drv = &sn5s330_drv,
+ },
+#endif
+#if defined(HAS_TASK_PD_C3)
+ [TYPE_C_PORT_3] = {
+ .i2c_port = I2C_PORT_TYPEC_3,
+ .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC,
+ .drv = &sn5s330_drv,
+ },
+#endif
+};
+BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == CONFIG_USB_PD_PORT_MAX_COUNT);
+unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
+
+/* Cache BB retimer power state */
+static bool cache_bb_enable[CONFIG_USB_PD_PORT_MAX_COUNT];
+
+void board_overcurrent_event(int port, int is_overcurrented)
+{
+ /* Port 0 & 1 and 2 & 3 share same line for over current indication */
+#if defined(HAS_TASK_PD_C2)
+ enum ioex_signal oc_signal = port < TYPE_C_PORT_2 ? IOEX_USB_C0_C1_OC :
+ IOEX_USB_C2_C3_OC;
+#else
+ enum ioex_signal oc_signal = IOEX_USB_C0_C1_OC;
+#endif
+
+ /* Overcurrent indication is active low signal */
+ ioex_set_level(oc_signal, is_overcurrented ? 0 : 1);
+}
+
+__override int bb_retimer_power_enable(const struct usb_mux *me, bool enable)
+{
+ /*
+ * ADL-P-DDR5 RVP SKU has cascaded retimer topology.
+ * Ports with cascaded retimers share common load switch and reset pin
+ * hence no need to set the power state again if the 1st retimer's power
+ * status has already changed.
+ */
+ if (cache_bb_enable[me->usb_port] == enable)
+ return EC_SUCCESS;
+
+ cache_bb_enable[me->usb_port] = enable;
+
+ /* Handle retimer's power domain.*/
+ if (enable) {
+ ioex_set_level(bb_controls[me->usb_port].usb_ls_en_gpio, 1);
+
+ /*
+ * minimum time from VCC to RESET_N de-assertion is 100us
+ * For boards that don't provide a load switch control, the
+ * retimer_init() function ensures power is up before calling
+ * this function.
+ */
+ msleep(1);
+ ioex_set_level(bb_controls[me->usb_port].retimer_rst_gpio, 1);
+
+ /*
+ * Allow 1ms time for the retimer to power up lc_domain
+ * which powers I2C controller within retimer
+ */
+ msleep(1);
+
+ } else {
+ ioex_set_level(bb_controls[me->usb_port].retimer_rst_gpio, 0);
+ msleep(1);
+ ioex_set_level(bb_controls[me->usb_port].usb_ls_en_gpio, 0);
+ }
+ return EC_SUCCESS;
+}
+
+static void board_connect_c0_sbu_deferred(void)
+{
+ int ccd_intr_level = gpio_get_level(GPIO_CCD_MODE_ODL);
+
+ if (ccd_intr_level) {
+ /* Default set the SBU lines to AUX mode on TCPC-AIC */
+ ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_1, 0);
+ ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_0, 0);
+ } else {
+ /* Set the SBU lines to CCD mode on TCPC-AIC */
+ ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_1, 1);
+ ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_0, 0);
+ }
+}
+DECLARE_DEFERRED(board_connect_c0_sbu_deferred);
+
+void board_connect_c0_sbu(enum gpio_signal s)
+{
+ hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0);
+}
+
+static void enable_h1_irq(void)
+{
+ gpio_enable_interrupt(GPIO_CCD_MODE_ODL);
+}
+DECLARE_HOOK(HOOK_INIT, enable_h1_irq, HOOK_PRIO_LAST);
+
+void set_charger_system_voltage(void)
+{
+ switch (ADL_RVP_BOARD_ID(board_get_version())) {
+ case ADLN_LP5_ERB_SKU_BOARD_ID:
+ case ADLN_LP5_RVP_SKU_BOARD_ID:
+ /*
+ * As per b:196184163 configure the PPVAR_SYS depend
+ * on AC or AC+battery
+ */
+ if (extpower_is_present() && battery_is_present()) {
+ bq25710_set_min_system_voltage(
+ CHARGER_SOLO, battery_get_info()->voltage_min);
+ } else {
+ bq25710_set_min_system_voltage(
+ CHARGER_SOLO, battery_get_info()->voltage_max);
+ }
+ break;
+
+ /* Add additional board SKUs */
+ default:
+ break;
+ }
+}
+DECLARE_HOOK(HOOK_AC_CHANGE, set_charger_system_voltage, HOOK_PRIO_DEFAULT);
+
+static void configure_charger(void)
+{
+ switch (ADL_RVP_BOARD_ID(board_get_version())) {
+ case ADLN_LP5_ERB_SKU_BOARD_ID:
+ case ADLN_LP5_RVP_SKU_BOARD_ID:
+ /* charger chip BQ25720 support */
+ chg_chips[0].i2c_addr_flags = BQ25710_SMBUS_ADDR1_FLAGS;
+ chg_chips[0].drv = &bq25710_drv;
+ set_charger_system_voltage();
+ break;
+
+ /* Add additional board SKUs */
+ default:
+ break;
+ }
+}
+
+static void configure_retimer_usbmux(void)
+{
+ struct usb_mux *mux;
+
+ switch (ADL_RVP_BOARD_ID(board_get_version())) {
+ case ADLN_LP5_ERB_SKU_BOARD_ID:
+ case ADLN_LP5_RVP_SKU_BOARD_ID:
+ /* enable TUSB1044RNQR redriver on Port0 */
+ mux = USB_MUX_POINTER(DT_NODELABEL(usb_mux_chain_0), 0);
+ mux->i2c_addr_flags = TUSB1064_I2C_ADDR14_FLAGS;
+ mux->driver = &tusb1064_usb_mux_driver;
+ mux->hpd_update = tusb1044_hpd_update;
+
+#if defined(HAS_TASK_PD_C1)
+ mux = USB_MUX_POINTER(DT_NODELABEL(usb_mux_chain_1), 0);
+ mux->driver = NULL;
+ mux->hpd_update = NULL;
+#endif
+ break;
+
+ case ADLP_LP5_T4_RVP_SKU_BOARD_ID:
+ /* No retimer on Port-2 */
+#if defined(HAS_TASK_PD_C2)
+ mux = USB_MUX_POINTER(DT_NODELABEL(usb_mux_chain_2), 0);
+ mux->driver = NULL;
+#endif
+ break;
+
+ case ADLP_DDR5_RVP_SKU_BOARD_ID:
+ /*
+ * ADL-P-DDR5 RVP has dual BB-retimers for port0 & port1.
+ * Change the default usb mux config on runtime to support
+ * dual retimer topology.
+ */
+ USB_MUX_ENABLE_ALTERNATIVE(usb_mux_alt_chain_0);
+#if defined(HAS_TASK_PD_C1)
+ USB_MUX_ENABLE_ALTERNATIVE(usb_mux_alt_chain_1);
+#endif
+ break;
+
+ /* Add additional board SKUs */
+
+ default:
+ break;
+ }
+}
+
+static void configure_battery_type(void)
+{
+ int bat_cell_type;
+
+ switch (ADL_RVP_BOARD_ID(board_get_version())) {
+ case ADLM_LP4_RVP1_SKU_BOARD_ID:
+ case ADLM_LP5_RVP2_SKU_BOARD_ID:
+ case ADLM_LP5_RVP3_SKU_BOARD_ID:
+ case ADLN_LP5_ERB_SKU_BOARD_ID:
+ case ADLN_LP5_RVP_SKU_BOARD_ID:
+ /* configure Battery to 2S based */
+ bat_cell_type = BATTERY_TYPE(DT_ALIAS(getac_2s));
+ break;
+ default:
+ /* configure Battery to 3S based */
+ bat_cell_type = BATTERY_TYPE(DT_ALIAS(getac_3s));
+ break;
+ }
+
+ /* Set the fixed battery type */
+ battery_set_fixed_battery_type(bat_cell_type);
+}
+/******************************************************************************/
+/* PWROK signal configuration */
+/*
+ * On ADLRVP, SYS_PWROK_EC is an output controlled by EC and uses ALL_SYS_PWRGD
+ * as input.
+ */
+const struct intel_x86_pwrok_signal pwrok_signal_assert_list[] = {
+ {
+ .gpio = GPIO_PCH_SYS_PWROK,
+ .delay_ms = 3,
+ },
+};
+const int pwrok_signal_assert_count = ARRAY_SIZE(pwrok_signal_assert_list);
+
+const struct intel_x86_pwrok_signal pwrok_signal_deassert_list[] = {
+ {
+ .gpio = GPIO_PCH_SYS_PWROK,
+ },
+};
+const int pwrok_signal_deassert_count = ARRAY_SIZE(pwrok_signal_deassert_list);
+
+/*
+ * Returns board information (board id[7:0] and Fab id[15:8]) on success
+ * -1 on error.
+ */
+__override int board_get_version(void)
+{
+ /* Cache the board ID */
+ static int adlrvp_board_id;
+
+ int i;
+ int rv = EC_ERROR_UNKNOWN;
+
+ int fab_id, board_id, bom_id;
+
+ /* Board ID is already read */
+ if (adlrvp_board_id)
+ return adlrvp_board_id;
+
+ /*
+ * IOExpander that has Board ID information is on DSW-VAL rail on
+ * ADL RVP. On cold boot cycles, DSW-VAL rail is taking time to settle.
+ * This loop retries to ensure rail is settled and read is successful
+ */
+ for (i = 0; i < RVP_VERSION_READ_RETRY_CNT; i++) {
+ rv = gpio_pin_get_dt(&bom_id_config[0]);
+
+ if (rv >= 0)
+ break;
+
+ k_msleep(1);
+ }
+
+ /* retrun -1 if failed to read board id */
+ if (rv < 0)
+ return -1;
+
+ /*
+ * BOM ID [2] : IOEX[0]
+ * BOM ID [1:0] : IOEX[15:14]
+ */
+ bom_id = gpio_pin_get_dt(&bom_id_config[0]) << 2;
+ bom_id |= gpio_pin_get_dt(&bom_id_config[1]) << 1;
+ bom_id |= gpio_pin_get_dt(&bom_id_config[2]);
+
+ /*
+ * FAB ID [1:0] : IOEX[2:1] + 1
+ */
+ fab_id = gpio_pin_get_dt(&fab_id_config[0]) << 1;
+ fab_id |= gpio_pin_get_dt(&fab_id_config[1]);
+ fab_id += 1;
+
+ /*
+ * BOARD ID[5:0] : IOEX[13:8]
+ */
+ board_id = gpio_pin_get_dt(&board_id_config[0]) << 5;
+ board_id |= gpio_pin_get_dt(&board_id_config[1]) << 4;
+ board_id |= gpio_pin_get_dt(&board_id_config[2]) << 3;
+ board_id |= gpio_pin_get_dt(&board_id_config[3]) << 2;
+ board_id |= gpio_pin_get_dt(&board_id_config[4]) << 1;
+ board_id |= gpio_pin_get_dt(&board_id_config[5]);
+
+ CPRINTF("BID:0x%x, FID:0x%x, BOM:0x%x", board_id, fab_id, bom_id);
+
+ adlrvp_board_id = board_id | (fab_id << 8);
+ return adlrvp_board_id;
+}
+
+__override bool board_is_tbt_usb4_port(int port)
+{
+ bool tbt_usb4 = true;
+
+ switch (ADL_RVP_BOARD_ID(board_get_version())) {
+ case ADLN_LP5_ERB_SKU_BOARD_ID:
+ case ADLN_LP5_RVP_SKU_BOARD_ID:
+ /* No retimer on both ports */
+ tbt_usb4 = false;
+ break;
+
+ case ADLP_LP5_T4_RVP_SKU_BOARD_ID:
+ /* No retimer on Port-2 hence no platform level AUX & LSx mux */
+#if defined(HAS_TASK_PD_C2)
+ if (port == TYPE_C_PORT_2)
+ tbt_usb4 = false;
+#endif
+ break;
+
+ /* Add additional board SKUs */
+ default:
+ break;
+ }
+
+ return tbt_usb4;
+}
+
+static int board_pre_task_peripheral_init(const struct device *unused)
+{
+ ARG_UNUSED(unused);
+
+ /* Initialized IOEX-0 to access IOEX-GPIOs needed pre-task */
+ ioex_init(IOEX_C0_PCA9675);
+
+ /* Make sure SBU are routed to CCD or AUX based on CCD status at init */
+ board_connect_c0_sbu_deferred();
+
+ /* Configure battery type */
+ configure_battery_type();
+
+ /* Reconfigure board specific charger drivers */
+ configure_charger();
+
+ /* Configure board specific retimer & mux */
+ configure_retimer_usbmux();
+
+ return 0;
+}
+SYS_INIT(board_pre_task_peripheral_init, APPLICATION,
+ CONFIG_APPLICATION_INIT_PRIORITY);
diff --git a/zephyr/projects/intelrvp/include/intel_rvp_board_id.h b/zephyr/program/intelrvp/include/intel_rvp_board_id.h
index 7825b272e3..7825b272e3 100644
--- a/zephyr/projects/intelrvp/include/intel_rvp_board_id.h
+++ b/zephyr/program/intelrvp/include/intel_rvp_board_id.h
diff --git a/zephyr/projects/intelrvp/include/intelrvp.h b/zephyr/program/intelrvp/include/intelrvp.h
index 9b6dc98485..9b6dc98485 100644
--- a/zephyr/projects/intelrvp/include/intelrvp.h
+++ b/zephyr/program/intelrvp/include/intelrvp.h
diff --git a/zephyr/projects/intelrvp/led.md b/zephyr/program/intelrvp/led.md
index c36bc6b36c..c36bc6b36c 100644
--- a/zephyr/projects/intelrvp/led.md
+++ b/zephyr/program/intelrvp/led.md
diff --git a/zephyr/projects/intelrvp/legacy_ec_pwrseq.conf b/zephyr/program/intelrvp/legacy_ec_pwrseq.conf
index 331afb637d..331afb637d 100644
--- a/zephyr/projects/intelrvp/legacy_ec_pwrseq.conf
+++ b/zephyr/program/intelrvp/legacy_ec_pwrseq.conf
diff --git a/zephyr/projects/intelrvp/mtlrvp/CMakeLists.txt b/zephyr/program/intelrvp/mtlrvp/CMakeLists.txt
index c6729af776..c6729af776 100644
--- a/zephyr/projects/intelrvp/mtlrvp/CMakeLists.txt
+++ b/zephyr/program/intelrvp/mtlrvp/CMakeLists.txt
diff --git a/zephyr/projects/intelrvp/mtlrvp/ioex.dts b/zephyr/program/intelrvp/mtlrvp/ioex.dts
index 7d2f4b5820..7d2f4b5820 100644
--- a/zephyr/projects/intelrvp/mtlrvp/ioex.dts
+++ b/zephyr/program/intelrvp/mtlrvp/ioex.dts
diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts
index cf85dd3413..cf85dd3413 100644
--- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts
+++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/fan.dts
diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts
index 77b4cf0573..77b4cf0573 100644
--- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts
+++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/gpio.dts
diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts
new file mode 100644
index 0000000000..ad928fd593
--- /dev/null
+++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts
@@ -0,0 +1,65 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+/ {
+ gpio-interrupts {
+ compatible = "cros-ec,gpio-interrupts";
+
+ int_lid_open: lid_open {
+ irq-pin = <&smc_lid>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "lid_interrupt";
+ };
+ int_power_button: power_button {
+ irq-pin = <&smc_onoff_n>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "power_button_interrupt";
+ };
+ int_ac_present: ac_present {
+ irq-pin = <&bc_acok>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "extpower_interrupt";
+ };
+ int_ioex_kbd_intr_n: ioex_kbd_intr_n {
+ irq-pin = <&ioex_kbd_intr_n>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "io_expander_it8801_interrupt";
+ };
+ int_usb_c0_c1_tcpc: usb_c0_tcpc {
+ irq-pin = <&usbc_tcpc_alrt_p0>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "tcpc_alert_event";
+ };
+ int_usb_c0_ppc: usb_c0_ppc {
+ irq-pin = <&usbc_tcpc_ppc_alrt_p0>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "ppc_interrupt";
+ };
+ int_usb_c1_ppc: usb_c1_ppc {
+ irq-pin = <&usbc_tcpc_ppc_alrt_p1>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "ppc_interrupt";
+ };
+ int_usb_c2_tcpc: usb_c2_tcpc {
+ irq-pin = <&usbc_tcpc_alrt_p2>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "tcpc_alert_event";
+ };
+ int_usb_c3_tcpc: usb_c3_tcpc {
+ irq-pin = <&usbc_tcpc_alrt_p3>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "tcpc_alert_event";
+ };
+ int_ccd_mode: ccd_mode {
+ irq-pin = <&ccd_mode_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "board_connect_c0_sbu";
+ };
+ int_dc_jack_present: dc_jack_present {
+ irq-pin = <&std_adp_prsnt>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "board_dc_jack_interrupt";
+ };
+ };
+};
diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts
new file mode 100644
index 0000000000..be0a570e95
--- /dev/null
+++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts
@@ -0,0 +1,59 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ cros-keyscan {
+ compatible = "cros-ec,keyscan";
+
+ output-settle = <35>;
+ debounce-down = <5000>;
+ debounce-up = <40000>;
+ poll-timeout = <100000>;
+
+ actual-key-mask = <
+ 0x14 /* C0 */
+ 0xff /* C1 */
+ 0xff /* C2 */
+ 0xff /* C3 */
+ 0xff /* C4 */
+ 0xf5 /* C5 */
+ 0xff /* C6 */
+ 0xa4 /* C7 */
+ 0xff /* C8 */
+ 0xfe /* C9 */
+ 0x55 /* C10 */
+ 0xfa /* C11 */
+ 0xca /* C12 */
+ >;
+ };
+};
+
+&cros_kb_raw {
+ status = "okay";
+ /* No KSO2 (it's inverted and implemented by GPIO) */
+ pinctrl-0 = <
+ &ksi0_gp31
+ &ksi1_gp30
+ &ksi2_gp27
+ &ksi3_gp26
+ &ksi4_gp25
+ &ksi5_gp24
+ &ksi6_gp23
+ &ksi7_gp22
+ &kso00_gp21
+ &kso01_gp20
+ &kso03_gp16
+ &kso04_gp15
+ &kso05_gp14
+ &kso06_gp13
+ &kso07_gp12
+ &kso08_gp11
+ &kso09_gp10
+ &kso10_gp07
+ &kso11_gp06
+ &kso12_gp05
+ >;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts
new file mode 100644
index 0000000000..25ad865dd7
--- /dev/null
+++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts
@@ -0,0 +1,272 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+ #include <dt-bindings/usb_pd_tcpm.h>
+
+/ {
+ chosen {
+ cros,rtc = &mtc;
+ };
+
+ hibernate-wake-pins {
+ compatible = "cros-ec,hibernate-wake-pins";
+ wakeup-irqs = <
+ &int_ac_present
+ &int_lid_open
+ &int_power_button
+ >;
+ };
+
+ named-i2c-ports {
+ compatible = "named-i2c-ports";
+
+ i2c_charger: charger {
+ i2c-port = <&i2c7_0>;
+ enum-names = "I2C_PORT_CHARGER",
+ "I2C_PORT_BATTERY",
+ "I2C_PORT_EEPROM",
+ "I2C_PORT_KB_DISCRETE",
+ "I2C_PORT_PORT80";
+ };
+ typec_aic1: typec-aic1{
+ i2c-port = <&i2c0_0>;
+ enum-names = "I2C_PORT_TYPEC_AIC_1";
+ };
+ typec_aic2: typec-aic2{
+ i2c-port = <&i2c1_0>;
+ enum-names = "I2C_PORT_TYPEC_AIC_2";
+ };
+ };
+
+ named-adc-channels {
+ compatible = "named-adc-channels";
+
+ adc_ambient: ambient {
+ enum-name = "ADC_TEMP_SENSOR_1";
+ io-channels = <&adc0 3>;
+ };
+ adc_ddr: ddr {
+ enum-name = "ADC_TEMP_SENSOR_2";
+ io-channels = <&adc0 4>;
+ };
+ adc_skin: skin {
+ enum-name = "ADC_TEMP_SENSOR_3";
+ io-channels = <&adc0 2>;
+ };
+ adc_vr: vr {
+ enum-name = "ADC_TEMP_SENSOR_4";
+ io-channels = <&adc0 1>;
+ };
+ };
+};
+
+/* charger */
+&i2c7_0 {
+ label = "I2C_CHARGER";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+ pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
+ pinctrl-names = "default";
+
+ pca95xx: pca95xx@22 {
+ compatible = "nxp,pca95xx";
+ label = "PCA95XX";
+ reg = <0x22>;
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <16>;
+ };
+
+ rvp_board_id: rvp-board-id {
+ compatible = "intel,rvp-board-id";
+
+ /*
+ * BOM ID [2] : IOEX[0]
+ * BOM ID [1:0] : IOEX[15:14]
+ */
+ bom-gpios = <&pca95xx 0 0>, <&pca95xx 15 0>, <&pca95xx 14 0>;
+
+ /*
+ * FAB ID [1:0] : IOEX[2:1]
+ */
+ fab-gpios = <&pca95xx 2 0>, <&pca95xx 1 0>;
+
+ /*
+ * BOARD ID[5:0] : IOEX[13:8]
+ */
+ board-gpios = <&pca95xx 13 0>, <&pca95xx 12 0>, <&pca95xx 11 0>,
+ <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>;
+ };
+
+ kb_discrete: ite-it8801@39 {
+ compatible = "ite,it8801";
+ reg = <0x39>;
+ };
+
+ max695x@38 {
+ compatible = "maxim,max695x";
+ reg = <0x38>;
+ };
+
+ charger: isl9241@9 {
+ compatible = "intersil,isl9241";
+ status = "okay";
+ reg = <0x9>;
+ };
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+};
+
+/* host interface */
+&espi0 {
+ status = "okay";
+ pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
+ pinctrl-names = "default";
+};
+
+&i2c_ctrl7 {
+ status = "okay";
+};
+
+/* typec_aic1 */
+&i2c0_0 {
+ label = "I2C_USB_C0_C1_TCPC";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
+ pinctrl-names = "default";
+
+ tcpc_port0: nct38xx@73 {
+ compatible = "nuvoton,nct38xx";
+ reg = <0x73>;
+ gpio-dev = <&nct38xx_c0>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>;
+ };
+
+ nct38xx_c0: nct38xx_c0@73 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "nuvoton,nct38xx-gpio";
+ reg = <0x73>;
+ label = "NCT38XX_C0";
+
+ ioex_c0: gpio@0 {
+ compatible = "nuvoton,nct38xx-gpio-port";
+ reg = <0x0>;
+ label = "NCT38XX_C0_GPIO0";
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <8>;
+ pin_mask = <0xdc>;
+ pinmux_mask = <0xff>;
+ };
+ };
+
+ tcpc_port1: nct38xx@77 {
+ compatible = "nuvoton,nct38xx";
+ reg = <0x77>;
+ gpio-dev = <&nct38xx_c1>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
+
+ nct38xx_c1: nct38xx_c1@77 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "nuvoton,nct38xx-gpio";
+ reg = <0x77>;
+ label = "NCT38XX_C1";
+
+ ioex_c1: gpio@0 {
+ compatible = "nuvoton,nct38xx-gpio-port";
+ reg = <0x0>;
+ label = "NCT38XX_C1_GPIO0";
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <8>;
+ pin_mask = <0xdc>;
+ pinmux_mask = <0xff>;
+ };
+ };
+
+ nct38xx_alert_0 {
+ compatible = "nuvoton,nct38xx-gpio-alert";
+ irq-gpios = <&gpio4 0 GPIO_ACTIVE_LOW>;
+ nct38xx-dev = <&nct38xx_c0 &nct38xx_c1>;
+ label = "NCT38XX_ALERT_1";
+ };
+
+ usb_c0_hb_retimer: jhl8040r-c0@56 {
+ compatible = "intel,jhl8040r";
+ reg = <0x56>;
+ reset-pin = <&usb_c0_hb_retimer_rst>;
+ ls-en-pin = <&usb_c0_hb_retimer_ls_en>;
+ };
+
+ usb_c1_hb_retimer: jhl8040r-c1@57 {
+ compatible = "intel,jhl8040r";
+ reg = <0x57>;
+ reset-pin = <&usb_c1_hb_retimer_rst>;
+ ls-en-pin = <&usb_c1_hb_retimer_ls_en>;
+ };
+};
+
+&i2c_ctrl0 {
+ status = "okay";
+};
+
+/* typec_aic2 */
+&i2c1_0 {
+ label = "I2C_USB_C2_C3_TCPC";
+ status = "okay";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
+ pinctrl-names = "default";
+
+ tcpc_port2: ccgxxf@b {
+ compatible = "cypress,ccgxxf";
+ reg = <0xb>;
+ };
+
+ tcpc_port3: ccgxxf@1b {
+ compatible = "cypress,ccgxxf";
+ reg = <0x1b>;
+ };
+
+ usb_c2_hb_retimer: jhl8040r-c2@58 {
+ compatible = "intel,jhl8040r";
+ reg = <0x58>;
+ reset-pin = <&usb_c2_hb_retimer_rst>;
+ ls-en-pin = <&usb_c2_hb_retimer_ls_en>;
+ };
+
+ usb_c3_hb_retimer: jhl8040r-c3@59 {
+ compatible = "intel,jhl8040r";
+ reg = <0x59>;
+ reset-pin = <&usb_c3_hb_retimer_rst>;
+ ls-en-pin = <&usb_c3_hb_retimer_ls_en>;
+ };
+};
+
+&i2c_ctrl1 {
+ status = "okay";
+};
+
+&adc0 {
+ status = "okay";
+ pinctrl-0 = <&adc0_chan1_gp44
+ &adc0_chan2_gp43
+ &adc0_chan3_gp42
+ &adc0_chan4_gp41>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts
index 3c270d296f..3c270d296f 100644
--- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts
+++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx_power_signals.dts
diff --git a/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf
new file mode 100644
index 0000000000..e4b25b48e7
--- /dev/null
+++ b/zephyr/program/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf
@@ -0,0 +1,10 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_BOARD_MTLRVP_NPCX=y
+CONFIG_CROS_SYSTEM_NPCX=y
+CONFIG_SYSCON=y
+
+# RTC
+CONFIG_PLATFORM_EC_RTC=y
diff --git a/zephyr/program/intelrvp/mtlrvp/prj.conf b/zephyr/program/intelrvp/mtlrvp/prj.conf
new file mode 100644
index 0000000000..1270712f99
--- /dev/null
+++ b/zephyr/program/intelrvp/mtlrvp/prj.conf
@@ -0,0 +1,67 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Power Sequencing
+CONFIG_AP_X86_INTEL_MTL=y
+CONFIG_X86_NON_DSX_PWRSEQ_MTL=y
+CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE=n
+CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y
+CONFIG_PLATFORM_EC_BATTERY_V2=y
+
+# CBI
+CONFIG_EEPROM=y
+CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y
+CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
+
+# Disable BC1.2
+CONFIG_PLATFORM_EC_USB_CHARGER=n
+
+# Charger
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10
+CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=n
+CONFIG_PLATFORM_EC_CHARGER_ISL9241=y
+CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y
+
+# IOEX
+CONFIG_PLATFORM_EC_IOEX_CCGXXF=y
+CONFIG_PLATFORM_EC_IOEX_IT8801=y
+
+#Keyboard from I/O expander
+CONFIG_CROS_KB_RAW_NPCX=n
+
+# Temperature sensors
+CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y
+
+# USB CONFIG
+CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
+CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
+CONFIG_PLATFORM_EC_USB_MUX_TASK=y
+CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y
+CONFIG_PLATFORM_EC_USBC_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_CCGXXF=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y
+CONFIG_PLATFORM_EC_USB_PD_TRY_SRC=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU=y
+CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=y
+CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB=y
+CONFIG_PLATFORM_EC_USBC_VCONN=y
+CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y
+CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y
+CONFIG_PLATFORM_EC_USB_PD_USB4=y
+CONFIG_PLATFORM_EC_USB_PD_INT_SHARED=y
+CONFIG_PLATFORM_EC_USB_PD_PORT_0_SHARED=y
+CONFIG_PLATFORM_EC_USB_PD_PORT_1_SHARED=y
diff --git a/zephyr/program/intelrvp/mtlrvp/src/board_power.c b/zephyr/program/intelrvp/mtlrvp/src/board_power.c
new file mode 100644
index 0000000000..e35450b8b5
--- /dev/null
+++ b/zephyr/program/intelrvp/mtlrvp/src/board_power.c
@@ -0,0 +1,61 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gpio/gpio.h"
+#include "gpio_signal.h"
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/atomic.h>
+
+#include <ap_power/ap_power.h>
+#include <ap_power/ap_power_events.h>
+#include <ap_power/ap_power_interface.h>
+#include <ap_power_override_functions.h>
+#include <power_signals.h>
+#include <x86_power_signals.h>
+
+LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF);
+
+#if CONFIG_X86_NON_DSX_PWRSEQ_MTL
+#define X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS 50
+
+void board_ap_power_force_shutdown(void)
+{
+ int timeout_ms = X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS;
+
+ /* Turn off PCH_RMSRST to meet tPCH12 */
+ power_signal_set(PWR_EC_PCH_RSMRST, 0);
+
+ /* Turn off PRIM load switch. */
+ power_signal_set(PWR_EN_PP3300_A, 0);
+
+ /* Wait RSMRST to be off. */
+ while (power_signal_get(PWR_RSMRST) && (timeout_ms > 0)) {
+ k_msleep(1);
+ timeout_ms--;
+ };
+
+ if (power_signal_get(PWR_RSMRST))
+ LOG_WRN("RSMRST_ODL didn't go low! Assuming G3.");
+}
+
+void board_ap_power_action_g3_s5(void)
+{
+ /* Turn on the PP3300_PRIM rail. */
+ power_signal_set(PWR_EN_PP3300_A, 1);
+
+ if (!power_wait_signals_timeout(
+ IN_PGOOD_ALL_CORE,
+ AP_PWRSEQ_DT_VALUE(wait_signal_timeout))) {
+ ap_power_ev_send_callbacks(AP_POWER_PRE_INIT);
+ }
+}
+
+bool board_ap_power_check_power_rails_enabled(void)
+{
+ return power_signal_get(PWR_EN_PP3300_A);
+}
+#endif /* CONFIG_X86_NON_DSX_PWRSEQ_MTL */
diff --git a/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c b/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c
new file mode 100644
index 0000000000..e73995337a
--- /dev/null
+++ b/zephyr/program/intelrvp/mtlrvp/src/mtlrvp.c
@@ -0,0 +1,334 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "battery_fuel_gauge.h"
+#include "charger.h"
+#include "common.h"
+#include "console.h"
+#include "driver/retimer/bb_retimer_public.h"
+#include "driver/tcpm/ccgxxf.h"
+#include "driver/tcpm/nct38xx.h"
+#include "driver/tcpm/tcpci.h"
+#include "extpower.h"
+#include "gpio.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "intel_rvp_board_id.h"
+#include "intelrvp.h"
+#include "ioexpander.h"
+#include "isl9241.h"
+#include "keyboard_raw.h"
+#include "power/meteorlake.h"
+#include "sn5s330.h"
+#include "system.h"
+#include "task.h"
+#include "tusb1064.h"
+#include "usb_mux.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+#define CPRINTF(format, args...) cprintf(CC_COMMAND, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_COMMAND, format, ##args)
+
+/*******************************************************************/
+/* USB-C Configuration Start */
+
+/* PPC */
+#define I2C_ADDR_SN5S330_P0 0x40
+#define I2C_ADDR_SN5S330_P1 0x41
+
+/* IOEX ports */
+enum ioex_port {
+ IOEX_KBD = 0,
+#if defined(HAS_TASK_PD_C2)
+ IOEX_C2_CCGXXF,
+#endif
+ IOEX_COUNT
+};
+
+/* USB-C ports */
+enum usbc_port {
+ USBC_PORT_C0 = 0,
+ USBC_PORT_C1,
+#if defined(HAS_TASK_PD_C2)
+ USBC_PORT_C2,
+ USBC_PORT_C3,
+#endif
+ USBC_PORT_COUNT
+};
+BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT);
+
+/* USB-C PPC configuration */
+struct ppc_config_t ppc_chips[] = {
+ [USBC_PORT_C0] = {
+ .i2c_port = I2C_PORT_TYPEC_AIC_1,
+ .i2c_addr_flags = I2C_ADDR_SN5S330_P0,
+ .drv = &sn5s330_drv,
+ },
+ [USBC_PORT_C1] = {
+ .i2c_port = I2C_PORT_TYPEC_AIC_1,
+ .i2c_addr_flags = I2C_ADDR_SN5S330_P1,
+ .drv = &sn5s330_drv,
+ },
+};
+unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
+
+/* TCPC AIC GPIO Configuration */
+const struct tcpc_aic_gpio_config_t tcpc_aic_gpios[] = {
+ [USBC_PORT_C0] = {
+ .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p0)),
+ .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p0)),
+ .ppc_intr_handler = sn5s330_interrupt,
+ },
+ [USBC_PORT_C1] = {
+ .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p0)),
+ .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p1)),
+ .ppc_intr_handler = sn5s330_interrupt,
+ },
+#if defined(HAS_TASK_PD_C2)
+ [USBC_PORT_C2] = {
+ .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p2)),
+ /* No PPC alert for CCGXXF */
+ },
+ [USBC_PORT_C3] = {
+ .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p3)),
+ /* No PPC alert for CCGXXF */
+ },
+#endif
+};
+BUILD_ASSERT(ARRAY_SIZE(tcpc_aic_gpios) == CONFIG_USB_PD_PORT_MAX_COUNT);
+
+static void board_connect_c0_sbu_deferred(void)
+{
+ enum pd_power_role prole;
+
+ if (gpio_get_level(GPIO_CCD_MODE_ODL)) {
+ CPRINTS("Default AUX line connected");
+ /* Default set the SBU lines to AUX mode */
+ ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_1, 0);
+ ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_0, 1);
+ } else {
+ prole = pd_get_power_role(USBC_PORT_C0);
+ CPRINTS("%s debug device is attached",
+ prole == PD_ROLE_SINK ? "Servo V4C/SuzyQ" : "Intel");
+
+ if (prole == PD_ROLE_SINK) {
+ /* Set the SBU lines to Google CCD mode */
+ ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_1, 1);
+ ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_0, 1);
+ } else {
+ /* Set the SBU lines to Intel CCD mode */
+ ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_1, 0);
+ ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_0, 0);
+ }
+ }
+}
+DECLARE_DEFERRED(board_connect_c0_sbu_deferred);
+
+void board_overcurrent_event(int port, int is_overcurrented)
+{
+ /*
+ * TODO: Meteorlake PCH does not use Physical GPIO for over current
+ * error, hence Send 'Over Current Virtual Wire' eSPI signal.
+ */
+}
+
+void board_reset_pd_mcu(void)
+{
+ /* Reset NCT38XX TCPC */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(usb_c0_c1_tcpc_rst_odl), 0);
+ msleep(NCT38XX_RESET_HOLD_DELAY_MS);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(usb_c0_c1_tcpc_rst_odl), 1);
+ nct38xx_reset_notify(0);
+ nct38xx_reset_notify(1);
+
+ if (NCT3807_RESET_POST_DELAY_MS != 0) {
+ msleep(NCT3807_RESET_POST_DELAY_MS);
+ }
+
+ /* NCT38XX chip uses gpio ioex */
+ gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_c0)));
+ gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_c1)));
+
+#if defined(HAS_TASK_PD_C2)
+ /* Reset the ccgxxf ports only resetting 1 is required */
+ ccgxxf_reset(USBC_PORT_C2);
+
+ /* CCGXXF has ioex on port 2 */
+ ioex_init(IOEX_C2_CCGXXF);
+#endif
+}
+
+void board_connect_c0_sbu(enum gpio_signal signal)
+{
+ hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0);
+}
+
+/******************************************************************************/
+/* KSO mapping for discrete keyboard */
+__override const uint8_t it8801_kso_mapping[] = {
+ 0, 1, 20, 3, 4, 5, 6, 11, 12, 13, 14, 15, 16,
+};
+BUILD_ASSERT(ARRAY_SIZE(it8801_kso_mapping) == KEYBOARD_COLS_MAX);
+
+/* PWROK signal configuration */
+/*
+ * On MTLRVP, SYS_PWROK_EC is an output controlled by EC and uses ALL_SYS_PWRGD
+ * as input.
+ */
+const struct intel_x86_pwrok_signal pwrok_signal_assert_list[] = {
+ {
+ .gpio = GPIO_PCH_SYS_PWROK,
+ .delay_ms = 3,
+ },
+};
+const int pwrok_signal_assert_count = ARRAY_SIZE(pwrok_signal_assert_list);
+
+const struct intel_x86_pwrok_signal pwrok_signal_deassert_list[] = {
+ {
+ .gpio = GPIO_PCH_SYS_PWROK,
+ },
+};
+const int pwrok_signal_deassert_count = ARRAY_SIZE(pwrok_signal_deassert_list);
+
+/*
+ * Returns board information (board id[7:0] and Fab id[15:8]) on success
+ * -1 on error.
+ */
+__override int board_get_version(void)
+{
+ /* Cache the MTLRVP board ID */
+ static int mtlrvp_board_id;
+
+ int i;
+ int rv = EC_ERROR_UNKNOWN;
+ int fab_id, board_id, bom_id;
+
+ /* Board ID is already read */
+ if (mtlrvp_board_id)
+ return mtlrvp_board_id;
+
+ /*
+ * IOExpander that has Board ID information is on DSW-VAL rail on
+ * ADL RVP. On cold boot cycles, DSW-VAL rail is taking time to settle.
+ * This loop retries to ensure rail is settled and read is successful
+ */
+ for (i = 0; i < RVP_VERSION_READ_RETRY_CNT; i++) {
+ rv = gpio_pin_get_dt(&bom_id_config[0]);
+
+ if (rv >= 0)
+ break;
+
+ k_msleep(1);
+ }
+
+ /* return -1 if failed to read board id */
+ if (rv)
+ return -1;
+
+ /*
+ * BOM ID [2] : IOEX[0]
+ * BOM ID [1:0] : IOEX[15:14]
+ */
+ bom_id = gpio_pin_get_dt(&bom_id_config[0]) << 2;
+ bom_id |= gpio_pin_get_dt(&bom_id_config[1]) << 1;
+ bom_id |= gpio_pin_get_dt(&bom_id_config[2]);
+ /*
+ * FAB ID [1:0] : IOEX[2:1] + 1
+ */
+ fab_id = gpio_pin_get_dt(&fab_id_config[0]) << 1;
+ fab_id |= gpio_pin_get_dt(&fab_id_config[1]);
+ fab_id += 1;
+
+ /*
+ * BOARD ID[5:0] : IOEX[13:8]
+ */
+ board_id = gpio_pin_get_dt(&board_id_config[0]) << 5;
+ board_id |= gpio_pin_get_dt(&board_id_config[1]) << 4;
+ board_id |= gpio_pin_get_dt(&board_id_config[2]) << 3;
+ board_id |= gpio_pin_get_dt(&board_id_config[3]) << 2;
+ board_id |= gpio_pin_get_dt(&board_id_config[4]) << 1;
+ board_id |= gpio_pin_get_dt(&board_id_config[5]);
+
+ CPRINTF("BID:0x%x, FID:0x%x, BOM:0x%x", board_id, fab_id, bom_id);
+
+ mtlrvp_board_id = board_id | (fab_id << 8);
+ return mtlrvp_board_id;
+}
+
+static void board_int_init(void)
+{
+ /* Enable PPC interrupts. */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc));
+
+ /* Enable TCPC interrupts. */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_c1_tcpc));
+#if defined(HAS_TASK_PD_C2)
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c2_tcpc));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c3_tcpc));
+#endif
+
+ /* Enable CCD Mode interrupt */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode));
+
+ /* Enable DC jack interrupt */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_dc_jack_present));
+}
+
+static int board_pre_task_peripheral_init(const struct device *unused)
+{
+ ARG_UNUSED(unused);
+
+ /* Only reset tcpc/pd if not sysjump */
+ if (!system_jumped_late()) {
+ /* Initialize tcpc and all ioex */
+ board_reset_pd_mcu();
+ }
+
+ /* Initialize all interrupts */
+ board_int_init();
+
+ /* Make sure SBU are routed to CCD or AUX based on CCD status at init */
+ board_connect_c0_sbu_deferred();
+
+ return 0;
+}
+SYS_INIT(board_pre_task_peripheral_init, APPLICATION,
+ CONFIG_APPLICATION_INIT_PRIORITY);
+
+/*
+ * Since MTLRVP has both PPC and TCPC ports override to check if the port
+ * is a PPC or non PPC port
+ */
+__override bool pd_check_vbus_level(int port, enum vbus_level level)
+{
+ if (!board_port_has_ppc(port)) {
+ return tcpm_check_vbus_level(port, level);
+ } else if (level == VBUS_PRESENT) {
+ return pd_snk_is_vbus_provided(port);
+ } else {
+ return !pd_snk_is_vbus_provided(port);
+ }
+}
+
+__override bool board_port_has_ppc(int port)
+{
+ bool ppc_port;
+
+ switch (port) {
+ case USBC_PORT_C0:
+ case USBC_PORT_C1:
+ ppc_port = true;
+ break;
+ default:
+ ppc_port = false;
+ break;
+ }
+
+ return ppc_port;
+}
diff --git a/zephyr/projects/intelrvp/mtlrvp/usbc.dts b/zephyr/program/intelrvp/mtlrvp/usbc.dts
index e4f3bdc465..e4f3bdc465 100644
--- a/zephyr/projects/intelrvp/mtlrvp/usbc.dts
+++ b/zephyr/program/intelrvp/mtlrvp/usbc.dts
diff --git a/zephyr/program/intelrvp/prj.conf b/zephyr/program/intelrvp/prj.conf
new file mode 100644
index 0000000000..9ca19c5071
--- /dev/null
+++ b/zephyr/program/intelrvp/prj.conf
@@ -0,0 +1,64 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+CONFIG_CROS_EC=y
+CONFIG_LTO=y
+CONFIG_PLATFORM_EC=y
+CONFIG_PLATFORM_EC_POWER_BUTTON=y
+CONFIG_PLATFORM_EC_LID_SWITCH=y
+CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
+CONFIG_SHIMMED_TASKS=y
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
+CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
+CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
+CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
+CONFIG_PLATFORM_EC_BATTERY_SMART=y
+CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y
+CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000
+CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15001
+CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512
+
+#Power Sequencing
+CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y
+
+# Host command
+CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET=y
+CONFIG_PLATFORM_EC_PORT80=y
+
+# USB-C and PD
+CONFIG_PLATFORM_EC_USB_VID=0x18d1
+CONFIG_PLATFORM_EC_USB_PID=0x8086
+CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=y
+
+# eSPI
+CONFIG_ESPI=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y
+
+# Keyboard
+CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y
+CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
+CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y
+CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
+CONFIG_PLATFORM_EC_CMD_BUTTON=n
+
+# Sensors
+CONFIG_SENSOR=y
+CONFIG_SENSOR_SHELL=n
+
+# Shell Commands
+CONFIG_SHELL_HELP=y
+CONFIG_SHELL_HISTORY=y
+CONFIG_SHELL_TAB=y
+CONFIG_SHELL_TAB_AUTOCOMPLETION=y
+CONFIG_KERNEL_SHELL=y
+
+# TODO
+# Below conf are disabled to compile successfully
+# These will be enabled in upcoming CLs
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
diff --git a/zephyr/program/intelrvp/src/chg_usb_pd.c b/zephyr/program/intelrvp/src/chg_usb_pd.c
new file mode 100644
index 0000000000..084617cb98
--- /dev/null
+++ b/zephyr/program/intelrvp/src/chg_usb_pd.c
@@ -0,0 +1,122 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Common USB PD charge configuration */
+
+#include "charge_manager.h"
+#include "charge_state_v2.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "intelrvp.h"
+#include "tcpm/tcpci.h"
+
+#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
+#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
+
+bool is_typec_port(int port)
+{
+#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0
+ return !(port == DEDICATED_CHARGE_PORT || port == CHARGE_PORT_NONE);
+#else
+ return !(port == CHARGE_PORT_NONE);
+#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */
+}
+
+static inline int board_dc_jack_present(void)
+{
+#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0
+ return gpio_get_level(GPIO_DC_JACK_PRESENT);
+#else
+ return 0;
+#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */
+}
+
+static void board_dc_jack_handle(void)
+{
+#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0
+ struct charge_port_info charge_dc_jack;
+
+ /* System is booted from DC Jack */
+ if (board_dc_jack_present()) {
+ charge_dc_jack.current =
+ (PD_MAX_POWER_MW * 1000) / DC_JACK_MAX_VOLTAGE_MV;
+ charge_dc_jack.voltage = DC_JACK_MAX_VOLTAGE_MV;
+ } else {
+ charge_dc_jack.current = 0;
+ charge_dc_jack.voltage = USB_CHARGER_VOLTAGE_MV;
+ }
+
+ charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED,
+ DEDICATED_CHARGE_PORT, &charge_dc_jack);
+#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */
+}
+
+void board_dc_jack_interrupt(enum gpio_signal signal)
+{
+ board_dc_jack_handle();
+}
+
+static void board_charge_init(void)
+{
+ int port, supplier;
+ struct charge_port_info charge_init = {
+ .current = 0,
+ .voltage = USB_CHARGER_VOLTAGE_MV,
+ };
+
+ /* Initialize all charge suppliers to seed the charge manager */
+ for (port = 0; port < CHARGE_PORT_COUNT; port++) {
+ for (supplier = 0; supplier < CHARGE_SUPPLIER_COUNT;
+ supplier++) {
+ charge_manager_update_charge(supplier, port,
+ &charge_init);
+ }
+ }
+
+ board_dc_jack_handle();
+}
+DECLARE_HOOK(HOOK_INIT, board_charge_init, HOOK_PRIO_DEFAULT);
+
+int board_set_active_charge_port(int port)
+{
+ int i;
+ /* charge port is a realy physical port */
+ int is_real_port = (port >= 0 && port < CHARGE_PORT_COUNT);
+ /* check if we are source vbus on that port */
+ int source = board_vbus_source_enabled(port);
+
+ if (is_real_port && source) {
+ CPRINTS("Skip enable p%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0
+ /*
+ * Do not enable Type-C port if the DC Jack is present.
+ * When the Type-C is active port, hardware circuit will
+ * block DC jack from enabling +VADP_OUT.
+ */
+ if (port != DEDICATED_CHARGE_PORT && board_dc_jack_present()) {
+ CPRINTS("DC Jack present, Skip enable p%d", port);
+ return EC_ERROR_INVAL;
+ }
+#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT */
+
+ /* Make sure non-charging ports are disabled */
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ if (i != port) {
+ board_charging_enable(i, 0);
+ }
+ }
+
+ /* Enable charging port */
+ if (is_typec_port(port)) {
+ board_charging_enable(port, 1);
+ }
+
+ CPRINTS("New chg p%d", port);
+
+ return EC_SUCCESS;
+}
diff --git a/zephyr/projects/intelrvp/src/chg_usb_pd_mecc_1_1.c b/zephyr/program/intelrvp/src/chg_usb_pd_mecc_1_1.c
index 45fbbc6f65..45fbbc6f65 100644
--- a/zephyr/projects/intelrvp/src/chg_usb_pd_mecc_1_1.c
+++ b/zephyr/program/intelrvp/src/chg_usb_pd_mecc_1_1.c
diff --git a/zephyr/program/intelrvp/src/intel_rvp_board_id.c b/zephyr/program/intelrvp/src/intel_rvp_board_id.c
new file mode 100644
index 0000000000..7062cb74b9
--- /dev/null
+++ b/zephyr/program/intelrvp/src/intel_rvp_board_id.c
@@ -0,0 +1,31 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "intel_rvp_board_id.h"
+
+#include <zephyr/devicetree.h>
+
+#define DT_DRV_COMPAT intel_rvp_board_id
+
+BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) <= 1,
+ "Unsupported RVP Board ID instance");
+
+#define RVP_ID_GPIO_DT_SPEC_GET(idx, node_id, prop) \
+ GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, idx),
+
+#define RVP_ID_CONFIG_LIST(node_id, prop) \
+ LISTIFY(DT_PROP_LEN(node_id, prop), RVP_ID_GPIO_DT_SPEC_GET, (), \
+ node_id, prop)
+
+#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
+const struct gpio_dt_spec bom_id_config[] = { RVP_ID_CONFIG_LIST(DT_DRV_INST(0),
+ bom_gpios) };
+
+const struct gpio_dt_spec fab_id_config[] = { RVP_ID_CONFIG_LIST(DT_DRV_INST(0),
+ fab_gpios) };
+
+const struct gpio_dt_spec board_id_config[] = { RVP_ID_CONFIG_LIST(
+ DT_DRV_INST(0), board_gpios) };
+#endif /* #if DT_HAS_COMPAT_STATUS_OKAY */
diff --git a/zephyr/projects/intelrvp/src/intel_rvp_led.c b/zephyr/program/intelrvp/src/intel_rvp_led.c
index 0e4d872963..0e4d872963 100644
--- a/zephyr/projects/intelrvp/src/intel_rvp_led.c
+++ b/zephyr/program/intelrvp/src/intel_rvp_led.c
diff --git a/zephyr/projects/intelrvp/src/intelrvp.c b/zephyr/program/intelrvp/src/intelrvp.c
index 7098f26cbf..7098f26cbf 100644
--- a/zephyr/projects/intelrvp/src/intelrvp.c
+++ b/zephyr/program/intelrvp/src/intelrvp.c
diff --git a/zephyr/projects/intelrvp/src/usb_pd_policy_mecc_1_1.c b/zephyr/program/intelrvp/src/usb_pd_policy_mecc_1_1.c
index a194b358f1..a194b358f1 100644
--- a/zephyr/projects/intelrvp/src/usb_pd_policy_mecc_1_1.c
+++ b/zephyr/program/intelrvp/src/usb_pd_policy_mecc_1_1.c
diff --git a/zephyr/program/intelrvp/zephyr_ap_pwrseq.conf b/zephyr/program/intelrvp/zephyr_ap_pwrseq.conf
new file mode 100644
index 0000000000..d33b9bc963
--- /dev/null
+++ b/zephyr/program/intelrvp/zephyr_ap_pwrseq.conf
@@ -0,0 +1,10 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Zephyr Inbuilt AP Power Sequencing Config
+CONFIG_AP_PWRSEQ=y
+CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y
+CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y
+CONFIG_AP_PWRSEQ_S0IX=y
+CONFIG_AP_PWRSEQ_S0IX_ERROR_RECOVERY=y
diff --git a/zephyr/projects/it8xxx2_evb/BUILD.py b/zephyr/program/it8xxx2_evb/BUILD.py
index ee89c75390..ee89c75390 100644
--- a/zephyr/projects/it8xxx2_evb/BUILD.py
+++ b/zephyr/program/it8xxx2_evb/BUILD.py
diff --git a/zephyr/projects/it8xxx2_evb/CMakeLists.txt b/zephyr/program/it8xxx2_evb/CMakeLists.txt
index 170606a52d..170606a52d 100644
--- a/zephyr/projects/it8xxx2_evb/CMakeLists.txt
+++ b/zephyr/program/it8xxx2_evb/CMakeLists.txt
diff --git a/zephyr/projects/it8xxx2_evb/adc.dts b/zephyr/program/it8xxx2_evb/adc.dts
index 509c9b9daf..509c9b9daf 100644
--- a/zephyr/projects/it8xxx2_evb/adc.dts
+++ b/zephyr/program/it8xxx2_evb/adc.dts
diff --git a/zephyr/projects/it8xxx2_evb/fan.dts b/zephyr/program/it8xxx2_evb/fan.dts
index 2551507ec3..2551507ec3 100644
--- a/zephyr/projects/it8xxx2_evb/fan.dts
+++ b/zephyr/program/it8xxx2_evb/fan.dts
diff --git a/zephyr/projects/it8xxx2_evb/gpio.dts b/zephyr/program/it8xxx2_evb/gpio.dts
index 85bb45d7a0..85bb45d7a0 100644
--- a/zephyr/projects/it8xxx2_evb/gpio.dts
+++ b/zephyr/program/it8xxx2_evb/gpio.dts
diff --git a/zephyr/projects/it8xxx2_evb/i2c.dts b/zephyr/program/it8xxx2_evb/i2c.dts
index c08c543e44..c08c543e44 100644
--- a/zephyr/projects/it8xxx2_evb/i2c.dts
+++ b/zephyr/program/it8xxx2_evb/i2c.dts
diff --git a/zephyr/program/it8xxx2_evb/include/i2c_map.h b/zephyr/program/it8xxx2_evb/include/i2c_map.h
new file mode 100644
index 0000000000..a6878e8bae
--- /dev/null
+++ b/zephyr/program/it8xxx2_evb/include/i2c_map.h
@@ -0,0 +1,16 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __ZEPHYR_CHROME_I2C_MAP_H
+#define __ZEPHYR_CHROME_I2C_MAP_H
+
+#include "config.h"
+
+#include <zephyr/devicetree.h>
+
+/* We need registers.h to get the chip specific defines for now */
+#include "i2c/i2c.h"
+
+#endif /* __ZEPHYR_CHROME_I2C_MAP_H */
diff --git a/zephyr/projects/it8xxx2_evb/interrupts.dts b/zephyr/program/it8xxx2_evb/interrupts.dts
index 07fc0ed339..07fc0ed339 100644
--- a/zephyr/projects/it8xxx2_evb/interrupts.dts
+++ b/zephyr/program/it8xxx2_evb/interrupts.dts
diff --git a/zephyr/program/it8xxx2_evb/prj.conf b/zephyr/program/it8xxx2_evb/prj.conf
new file mode 100644
index 0000000000..7a608cb831
--- /dev/null
+++ b/zephyr/program/it8xxx2_evb/prj.conf
@@ -0,0 +1,33 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_CROS_EC=y
+CONFIG_PLATFORM_EC=y
+CONFIG_SHIMMED_TASKS=y
+
+# SoC configuration
+CONFIG_AP=y
+CONFIG_AP_ARM_MTK_MT8192=y
+
+# Lid switch
+CONFIG_PLATFORM_EC_LID_SWITCH=y
+
+# Fan
+CONFIG_SENSOR=y
+
+# Power Button
+CONFIG_PLATFORM_EC_POWER_BUTTON=y
+
+# TODO(b:185202623): bring these features up
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
+CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=n
+CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n
+CONFIG_PLATFORM_EC_KEYBOARD=n
+CONFIG_PLATFORM_EC_SWITCH=n
+CONFIG_PLATFORM_EC_VBOOT_EFS2=n
+CONFIG_PLATFORM_EC_VBOOT_HASH=n
+
+# USB-C
+CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
+CONFIG_PLATFORM_EC_USB_PD_USB4=n
diff --git a/zephyr/projects/it8xxx2_evb/pwm.dts b/zephyr/program/it8xxx2_evb/pwm.dts
index c566e5c029..c566e5c029 100644
--- a/zephyr/projects/it8xxx2_evb/pwm.dts
+++ b/zephyr/program/it8xxx2_evb/pwm.dts
diff --git a/zephyr/projects/minimal/BUILD.py b/zephyr/program/minimal/BUILD.py
index 5e892aa2d7..5e892aa2d7 100644
--- a/zephyr/projects/minimal/BUILD.py
+++ b/zephyr/program/minimal/BUILD.py
diff --git a/zephyr/projects/minimal/CMakeLists.txt b/zephyr/program/minimal/CMakeLists.txt
index de3bec9428..de3bec9428 100644
--- a/zephyr/projects/minimal/CMakeLists.txt
+++ b/zephyr/program/minimal/CMakeLists.txt
diff --git a/zephyr/projects/minimal/README.md b/zephyr/program/minimal/README.md
index 72c092dfce..72c092dfce 100644
--- a/zephyr/projects/minimal/README.md
+++ b/zephyr/program/minimal/README.md
diff --git a/zephyr/projects/minimal/it8xxx2.dts b/zephyr/program/minimal/it8xxx2.dts
index 3d2028afb2..3d2028afb2 100644
--- a/zephyr/projects/minimal/it8xxx2.dts
+++ b/zephyr/program/minimal/it8xxx2.dts
diff --git a/zephyr/projects/minimal/npcx9.dts b/zephyr/program/minimal/npcx9.dts
index 3a9f3b26e4..3a9f3b26e4 100644
--- a/zephyr/projects/minimal/npcx9.dts
+++ b/zephyr/program/minimal/npcx9.dts
diff --git a/zephyr/program/minimal/prj.conf b/zephyr/program/minimal/prj.conf
new file mode 100644
index 0000000000..bacb4fe288
--- /dev/null
+++ b/zephyr/program/minimal/prj.conf
@@ -0,0 +1,18 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_PLATFORM_EC=y
+CONFIG_CROS_EC=y
+CONFIG_SHIMMED_TASKS=y
+CONFIG_SYSCON=y
+
+# Disable default features we don't want in a minimal example.
+CONFIG_ADC=n
+CONFIG_PWM=n
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
+CONFIG_PLATFORM_EC_KEYBOARD=n
+CONFIG_PLATFORM_EC_POWER_BUTTON=n
+CONFIG_PLATFORM_EC_SWITCH=n
+CONFIG_PLATFORM_EC_VBOOT_EFS2=n
+CONFIG_PLATFORM_EC_I2C=n
diff --git a/zephyr/program/nissa/BUILD.py b/zephyr/program/nissa/BUILD.py
new file mode 100644
index 0000000000..fa5c77baf9
--- /dev/null
+++ b/zephyr/program/nissa/BUILD.py
@@ -0,0 +1,71 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Define zmake projects for nissa."""
+
+# Nivviks and Craask, Pujjo, Xivu, Xivur has NPCX993F, Nereid and Joxer, Yaviks has ITE81302
+
+
+def register_nissa_project(
+ project_name,
+ chip="it81302bx",
+):
+ """Register a variant of nissa."""
+ register_func = register_binman_project
+ if chip.startswith("npcx"):
+ register_func = register_npcx_project
+
+ chip_kconfig = {"it81302bx": "it8xxx2", "npcx9m3f": "npcx"}[chip]
+
+ return register_func(
+ project_name=project_name,
+ zephyr_board=chip,
+ dts_overlays=[here / project_name / "project.overlay"],
+ kconfig_files=[
+ here / "program.conf",
+ here / f"{chip_kconfig}_program.conf",
+ here / project_name / "project.conf",
+ ],
+ )
+
+
+nivviks = register_nissa_project(
+ project_name="nivviks",
+ chip="npcx9m3f",
+)
+
+nereid = register_nissa_project(
+ project_name="nereid",
+ chip="it81302bx",
+)
+
+craask = register_nissa_project(
+ project_name="craask",
+ chip="npcx9m3f",
+)
+
+pujjo = register_nissa_project(
+ project_name="pujjo",
+ chip="npcx9m3f",
+)
+
+xivu = register_nissa_project(
+ project_name="xivu",
+ chip="npcx9m3f",
+)
+
+xivur = register_nissa_project(
+ project_name="xivur",
+ chip="npcx9m3f",
+)
+
+joxer = register_nissa_project(
+ project_name="joxer",
+ chip="it81302bx",
+)
+
+yaviks = register_nissa_project(
+ project_name="yaviks",
+ chip="it81302bx",
+)
diff --git a/zephyr/program/nissa/CMakeLists.txt b/zephyr/program/nissa/CMakeLists.txt
new file mode 100644
index 0000000000..967fff2229
--- /dev/null
+++ b/zephyr/program/nissa/CMakeLists.txt
@@ -0,0 +1,99 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+cmake_minimum_required(VERSION 3.13.1)
+
+find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+
+zephyr_include_directories(include)
+zephyr_library_sources("src/common.c")
+zephyr_library_sources_ifdef(CONFIG_NISSA_SUB_BOARD "src/sub_board.c")
+zephyr_library_sources_ifdef(CONFIG_AP_PWRSEQ "src/board_power.c")
+
+if(DEFINED CONFIG_BOARD_NIVVIKS)
+ project(nivviks)
+ zephyr_library_sources(
+ "nivviks/src/led.c"
+ "nivviks/src/form_factor.c"
+ "nivviks/src/keyboard.c"
+ )
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "nivviks/src/fan.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "nivviks/src/usbc.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "nivviks/src/charger.c")
+endif()
+if(DEFINED CONFIG_BOARD_NEREID)
+ project(nereid)
+ zephyr_library_sources(
+ "src/led.c"
+ "nereid/src/keyboard.c"
+ "nereid/src/hdmi.c"
+ )
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "nereid/src/usbc.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "nereid/src/charger.c")
+endif()
+if(DEFINED CONFIG_BOARD_CRAASK)
+ zephyr_library_sources(
+ "craask/src/fan.c"
+ "craask/src/form_factor.c"
+ "craask/src/keyboard.c"
+ "craask/src/kb_backlight.c"
+ "craask/src/led.c"
+ )
+ project(craask)
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "craask/src/usbc.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "craask/src/charger.c")
+endif()
+if(DEFINED CONFIG_BOARD_PUJJO)
+ project(pujjo)
+ zephyr_library_sources(
+ "pujjo/src/led.c"
+ "pujjo/src/keyboard.c"
+ "pujjo/src/hdmi.c"
+ "pujjo/src/form_factor.c"
+ )
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "pujjo/src/fan.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "pujjo/src/usbc.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "pujjo/src/charger.c")
+endif()
+if(DEFINED CONFIG_BOARD_XIVU)
+ project(xivu)
+ zephyr_library_sources(
+ "xivu/src/form_factor.c"
+ "xivu/src/keyboard.c"
+ )
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "xivu/src/usbc.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "xivu/src/charger.c")
+endif()
+if(DEFINED CONFIG_BOARD_JOXER)
+ project(joxer)
+ zephyr_library_sources(
+ "joxer/src/led.c"
+ "joxer/src/keyboard.c"
+ )
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "joxer/src/usbc.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "joxer/src/charger.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "joxer/src/fan.c")
+endif()
+if(DEFINED CONFIG_BOARD_YAVIKS)
+ project(yaviks)
+ zephyr_library_sources(
+ "yaviks/src/led.c"
+ "yaviks/src/keyboard.c"
+ "yaviks/src/thermal.c"
+ )
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "yaviks/src/usbc.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "yaviks/src/charger.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "yaviks/src/fan.c")
+endif()
+if(DEFINED CONFIG_BOARD_XIVUR)
+ project(xivur)
+ zephyr_library_sources(
+ "xivur/src/led.c"
+ "xivur/src/form_factor.c"
+ "xivur/src/keyboard.c"
+ )
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "xivur/src/fan.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "xivur/src/usbc.c")
+ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "xivur/src/charger.c")
+endif()
diff --git a/zephyr/program/nissa/Kconfig b/zephyr/program/nissa/Kconfig
new file mode 100644
index 0000000000..a7fb4c666a
--- /dev/null
+++ b/zephyr/program/nissa/Kconfig
@@ -0,0 +1,67 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+config NISSA_SUB_BOARD
+ bool "Nissa sub-board support"
+ default y
+ help
+ Enable the sub-board support for Nissa boards.
+ This uses a common fw_config bitfield to select
+ one of a number of option sub-boards with different
+ hardware configurations.
+
+config BOARD_NIVVIKS
+ bool "Google Nivviks Board"
+ help
+ Build Google Nivviks reference board. Nivviks has Intel ADL-N SoC
+ with NPCX993FA0BX EC.
+
+config BOARD_NEREID
+ bool "Google Nereid Board"
+ help
+ Build Google Nereid reference board. Nereid has Intel ADL-N SoC
+ with IT81302 EC.
+
+config BOARD_CRAASK
+ bool "Google Craask Board"
+ help
+ Build Google Craask board. Craask has Intel ADL-N SoC
+ with NPCX993FA0BX EC.
+
+config BOARD_PUJJO
+ bool "Google Pujjo Board"
+ help
+ Build Google Pujjo board. Pujjo has Intel ADL-N SoC
+ with NPCX993FA0BX EC.
+
+config BOARD_XIVU
+ bool "Google Xivu Board"
+ help
+ Build Google Xivu board. Xivu has Intel ADL-N SoC
+ with NPCX993FA0BX EC.
+
+config BOARD_XIVUR
+ bool "Google Xivur Board"
+ help
+ Build Google Xivur board. Xivur has Intel ADL-N SoC
+ with NPCX993FA0BX EC.
+
+config BOARD_JOXER
+ bool "Google Joxer Board"
+ help
+ Build Google Joxer reference board. Joxer has Intel ADL-N SoC
+ with IT81302 EC.
+
+config BOARD_YAVIKS
+ bool "Google Yaviks Board"
+ help
+ Build Google Yaviks board. Yaviks has Intel ADL-N SoC
+ with IT81302 EC.
+
+
+module = NISSA
+module-str = Nissa board-specific code
+source "subsys/logging/Kconfig.template.log_config"
+
+source "Kconfig.zephyr"
diff --git a/zephyr/projects/nissa/cbi.dtsi b/zephyr/program/nissa/cbi.dtsi
index d841be1624..d841be1624 100644
--- a/zephyr/projects/nissa/cbi.dtsi
+++ b/zephyr/program/nissa/cbi.dtsi
diff --git a/zephyr/program/nissa/craask/cbi.dtsi b/zephyr/program/nissa/craask/cbi.dtsi
new file mode 100644
index 0000000000..e329929227
--- /dev/null
+++ b/zephyr/program/nissa/craask/cbi.dtsi
@@ -0,0 +1,152 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ /* Craask-specific fw_config fields. */
+ nissa-fw-config {
+ /*
+ * FW_CONFIG field to describe Lid sensor orientation.
+ */
+ lid-inversion {
+ enum-name = "FW_LID_INVERSION";
+ start = <8>;
+ size = <1>;
+
+ /*
+ * 0: regular placement of the lid sensor
+ * 1: rotate 180' of xy plane.
+ */
+ regular {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_LID_REGULAR";
+ value = <0>;
+ default;
+ };
+ xy_rotate_180 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_LID_XY_ROT_180";
+ value = <1>;
+ };
+ };
+ /*
+ * FW_CONFIG field to describe Clamshell/Convertible.
+ */
+ form_factor {
+ enum-name = "FORM_FACTOR";
+ start = <9>;
+ size = <1>;
+
+ /*
+ * 0: convertible, 1: clamshell
+ */
+ convertible {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "CONVERTIBLE";
+ value = <0>;
+ };
+ clamshell {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "CLAMSHELL";
+ value = <1>;
+ };
+ };
+
+ /*
+ * FW_CONFIG field to enable fan or not.
+ */
+ fan {
+ enum-name = "FW_FAN";
+ start = <17>;
+ size = <1>;
+
+ no-fan {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FAN_NOT_PRESENT";
+ value = <0>;
+ };
+ fan-present {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FAN_PRESENT";
+ value = <1>;
+ /*
+ * Set as default so that unprovisioned
+ * configs will run the fan regardless.
+ */
+ default;
+ };
+ };
+
+ /*
+ * FW_CONFIG field to enable KB back light or not.
+ */
+ kb-bl {
+ enum-name = "FW_KB_BL";
+ start = <18>;
+ size = <1>;
+
+ no-kb-bl {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_KB_BL_NOT_PRESENT";
+ value = <0>;
+ };
+ kb-bl-present {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_KB_BL_PRESENT";
+ value = <1>;
+ };
+ };
+ };
+ /* Craask-specific ssfc fields. */
+ cbi-ssfc {
+ compatible = "cros-ec,cbi-ssfc";
+ /*
+ * SSFC bit0-1 was defined for AUDIO CODEC.
+ * 0: ALC5682I_VS
+ * 1: NAU8825
+ */
+ audio_codec {
+ enum-name = "AUDIO_CODEC";
+ size = <2>;
+ };
+ /*
+ * SSFC field to identify LID motion sensor.
+ */
+ lid-sensor {
+ enum-name = "LID_SENSOR";
+ size = <2>;
+
+ lid_sensor_0: lis2dw12 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <0>;
+ default;
+ };
+ lid_sensor_1: bma422 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <1>;
+ };
+ };
+ /*
+ * SSFC field to identify BASE motion sensor.
+ */
+ base-sensor {
+ enum-name = "BASE_SENSOR";
+ size = <2>;
+
+ base_sensor_0: lsm6dso {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <0>;
+ default;
+ };
+ base_sensor_1: bmi323 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <1>;
+ };
+ };
+ };
+};
diff --git a/zephyr/program/nissa/craask/fan.dtsi b/zephyr/program/nissa/craask/fan.dtsi
new file mode 100644
index 0000000000..b94b0a018c
--- /dev/null
+++ b/zephyr/program/nissa/craask/fan.dtsi
@@ -0,0 +1,38 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+/ {
+ fans {
+ compatible = "cros-ec,fans";
+ fan_0 {
+ pwms = <&pwm5 5 PWM_KHZ(25) PWM_POLARITY_NORMAL>;
+ tach = <&tach2>;
+ rpm_min = <2500>;
+ rpm_start = <2500>;
+ rpm_max = <4100>;
+ enable_gpio = <&gpio_fan_enable>;
+ };
+ };
+};
+
+&pwm5_gpb7 {
+ drive-open-drain;
+};
+
+/* pwm for fan */
+&pwm5 {
+ status = "okay";
+ pinctrl-0 = <&pwm5_gpb7>;
+ pinctrl-names = "default";
+};
+
+/* Tachometer for fan speed measurement */
+&tach2 {
+ status = "okay";
+ pinctrl-0 = <&ta2_1_in_gp73>;
+ pinctrl-names = "default";
+ 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/program/nissa/craask/generated.dtsi b/zephyr/program/nissa/craask/generated.dtsi
new file mode 100644
index 0000000000..b10ec5f08b
--- /dev/null
+++ b/zephyr/program/nissa/craask/generated.dtsi
@@ -0,0 +1,289 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc {
+ enum-name = "ADC_PP1050_PROC";
+ io-channels = <&adc0 4>;
+ };
+ adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 {
+ enum-name = "ADC_PP3300_S5";
+ io-channels = <&adc0 6>;
+ };
+ adc_temp_sensor_1: temp_sensor_1 {
+ enum-name = "ADC_TEMP_SENSOR_1";
+ io-channels = <&adc0 0>;
+ };
+ adc_temp_sensor_2: temp_sensor_2 {
+ enum-name = "ADC_TEMP_SENSOR_2";
+ io-channels = <&adc0 1>;
+ };
+ adc_temp_sensor_3: temp_sensor_3 {
+ enum-name = "ADC_TEMP_SENSOR_3";
+ io-channels = <&adc0 10>;
+ };
+ };
+
+ named-gpios {
+ compatible = "named-gpios";
+
+ gpio_acc_int_l: acc_int_l {
+ gpios = <&gpio5 0 GPIO_INPUT>;
+ };
+ gpio_all_sys_pwrgd: all_sys_pwrgd {
+ gpios = <&gpioa 7 GPIO_INPUT>;
+ };
+ gpio_ccd_mode_odl: ccd_mode_odl {
+ gpios = <&gpioe 5 GPIO_INPUT>;
+ enum-name = "GPIO_CCD_MODE_ODL";
+ };
+ gpio_cpu_c10_gate_l: cpu_c10_gate_l {
+ gpios = <&gpio6 7 GPIO_INPUT>;
+ };
+ gpio_ec_battery_pres_odl: ec_battery_pres_odl {
+ gpios = <&gpioa 3 GPIO_INPUT>;
+ enum-name = "GPIO_BATT_PRES_ODL";
+ };
+ gpio_ec_cbi_wp: ec_cbi_wp {
+ gpios = <&gpio7 4 GPIO_OUTPUT>;
+ };
+ gpio_ec_edp_bl_en_od: ec_edp_bl_en_od {
+ gpios = <&gpiod 3 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_ENABLE_BACKLIGHT";
+ };
+ gpio_ec_entering_rw: ec_entering_rw {
+ gpios = <&gpio0 3 GPIO_OUTPUT>;
+ enum-name = "GPIO_ENTERING_RW";
+ };
+ gpio_ec_gsc_packet_mode: ec_gsc_packet_mode {
+ gpios = <&gpio7 5 GPIO_OUTPUT>;
+ enum-name = "GPIO_PACKET_MODE_EN";
+ };
+ gpio_ec_kso_02_inv: ec_kso_02_inv {
+ gpios = <&gpio1 7 (GPIO_OUTPUT | GPIO_ACTIVE_LOW)>;
+ enum-name = "GPIO_KBD_KSO2";
+ };
+ gpio_ec_pch_wake_odl: ec_pch_wake_odl {
+ gpios = <&gpiob 0 GPIO_ODR_LOW>;
+ };
+ gpio_ec_prochot_odl: ec_prochot_odl {
+ gpios = <&gpiof 1 GPIO_ODR_HIGH>;
+ };
+ gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok {
+ gpios = <&gpio6 1 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd {
+ gpios = <&gpioe 4 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_int_odl: ec_soc_int_odl {
+ gpios = <&gpio8 0 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_EC_INT_L";
+ };
+ gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od {
+ gpios = <&gpio7 2 GPIO_ODR_HIGH>;
+ };
+ gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl {
+ gpios = <&gpioc 1 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PCH_PWRBTN_L";
+ };
+ gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l {
+ gpios = <&gpioa 6 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_rtcrst: ec_soc_rtcrst {
+ gpios = <&gpio7 6 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok {
+ gpios = <&gpio3 7 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od {
+ gpios = <&gpioa 4 GPIO_ODR_HIGH>;
+ };
+ gpio_ec_wp_odl: ec_wp_odl {
+ gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ };
+ gpio_en_kb_bl: en_kb_bl {
+ gpios = <&gpioa 0 GPIO_OUTPUT>;
+ enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT";
+ };
+ gpio_en_pp3300_s5: en_pp3300_s5 {
+ gpios = <&gpiob 6 GPIO_OUTPUT>;
+ enum-name = "GPIO_TEMP_SENSOR_POWER";
+ };
+ gpio_en_pp5000_pen_x: en_pp5000_pen_x {
+ gpios = <&gpioe 2 GPIO_OUTPUT>;
+ };
+ gpio_en_pp5000_s5: en_pp5000_s5 {
+ gpios = <&gpio4 0 GPIO_OUTPUT>;
+ };
+ gpio_en_slp_z: en_slp_z {
+ gpios = <&gpioe 1 GPIO_OUTPUT>;
+ };
+ gpio_en_usb_a0_vbus: en_usb_a0_vbus {
+ gpios = <&gpio9 1 GPIO_OUTPUT>;
+ };
+ gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl {
+ gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_POWER_BUTTON_L";
+ };
+ gpio_hdmi_sel: hdmi_sel {
+ gpios = <&gpioc 6 GPIO_OUTPUT>;
+ };
+ gpio_imu_int_l: imu_int_l {
+ gpios = <&gpio5 6 GPIO_INPUT>;
+ };
+ gpio_imvp91_vrrdy_od: imvp91_vrrdy_od {
+ gpios = <&gpio4 3 GPIO_INPUT>;
+ };
+ gpio_lid_open: lid_open {
+ gpios = <&gpiod 2 GPIO_INPUT>;
+ enum-name = "GPIO_LID_OPEN";
+ };
+ gpio_pen_detect_odl: pen_detect_odl {
+ gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od {
+ gpios = <&gpiof 0 GPIO_INPUT>;
+ };
+ gpio_pg_pp5000_s5_od: pg_pp5000_s5_od {
+ gpios = <&gpio4 2 GPIO_INPUT>;
+ };
+ gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l {
+ gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_slp_s0_l: slp_s0_l {
+ gpios = <&gpio9 7 GPIO_INPUT>;
+ };
+ gpio_slp_s3_l: slp_s3_l {
+ gpios = <&gpioa 5 GPIO_INPUT>;
+ };
+ gpio_slp_s4_l: slp_s4_l {
+ gpios = <&gpio7 0 GPIO_INPUT>;
+ };
+ gpio_slp_sus_l: slp_sus_l {
+ gpios = <&gpio6 2 GPIO_INPUT>;
+ };
+ gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp {
+ gpios = <&gpiod 5 GPIO_OUTPUT>;
+ enum-name = "GPIO_USB2_ILIM_SEL";
+ };
+ gpio_sys_rst_odl: sys_rst_odl {
+ gpios = <&gpioc 5 GPIO_ODR_HIGH>;
+ };
+ gpio_tablet_mode_l: tablet_mode_l {
+ gpios = <&gpio9 5 GPIO_INPUT>;
+ enum-name = "GPIO_TABLET_MODE_L";
+ };
+ gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp {
+ gpios = <&gpio8 5 GPIO_OUTPUT>;
+ enum-name = "GPIO_USB1_ILIM_SEL";
+ };
+ gpio_usb_c0_int_odl: usb_c0_int_odl {
+ gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_vccin_aux_vid0: vccin_aux_vid0 {
+ gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_vccin_aux_vid1: vccin_aux_vid1 {
+ gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_voldn_btn_odl: voldn_btn_odl {
+ gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_DOWN_L";
+ };
+ gpio_volup_btn_odl: volup_btn_odl {
+ gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_UP_L";
+ };
+ };
+
+ named-i2c-ports {
+ compatible = "named-i2c-ports";
+
+ i2c_ec_i2c_eeprom: ec_i2c_eeprom {
+ i2c-port = <&i2c0_0>;
+ enum-names = "I2C_PORT_EEPROM";
+ };
+ i2c_ec_i2c_sensor: ec_i2c_sensor {
+ i2c-port = <&i2c1_0>;
+ enum-names = "I2C_PORT_SENSOR";
+ };
+ i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 {
+ i2c-port = <&i2c3_0>;
+ enum-names = "I2C_PORT_USB_C0_TCPC";
+ };
+ i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 {
+ i2c-port = <&i2c5_1>;
+ enum-names = "I2C_PORT_USB_C1_TCPC";
+ };
+ i2c_ec_i2c_batt: ec_i2c_batt {
+ i2c-port = <&i2c7_0>;
+ enum-names = "I2C_PORT_BATTERY";
+ };
+ };
+};
+
+&adc0 {
+ status = "okay";
+ pinctrl-0 = <&adc0_chan0_gp45
+ &adc0_chan1_gp44
+ &adc0_chan4_gp41
+ &adc0_chan6_gp34
+ &adc0_chan10_gpe0>;
+ pinctrl-names = "default";
+};
+
+&i2c0_0 {
+ status = "okay";
+ pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
+ pinctrl-names = "default";
+};
+
+&i2c1_0 {
+ status = "okay";
+ pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
+ pinctrl-names = "default";
+};
+
+&i2c3_0 {
+ status = "okay";
+ pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
+ pinctrl-names = "default";
+};
+
+&i2c5_1 {
+ status = "okay";
+ pinctrl-0 = <&i2c5_1_sda_scl_gpf4_f5>;
+ pinctrl-names = "default";
+};
+
+&i2c7_0 {
+ status = "okay";
+ pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
+ pinctrl-names = "default";
+};
+
+&i2c_ctrl0 {
+ status = "okay";
+};
+
+&i2c_ctrl1 {
+ status = "okay";
+};
+
+&i2c_ctrl3 {
+ status = "okay";
+};
+
+&i2c_ctrl5 {
+ status = "okay";
+};
+
+&i2c_ctrl7 {
+ status = "okay";
+};
diff --git a/zephyr/program/nissa/craask/keyboard.dtsi b/zephyr/program/nissa/craask/keyboard.dtsi
new file mode 100644
index 0000000000..06eb6bacfb
--- /dev/null
+++ b/zephyr/program/nissa/craask/keyboard.dtsi
@@ -0,0 +1,54 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+&cros_kb_raw {
+ status = "okay";
+ /* No KSO2 (it's inverted and implemented by GPIO) */
+ pinctrl-0 = <
+ &ksi0_gp31
+ &ksi1_gp30
+ &ksi2_gp27
+ &ksi3_gp26
+ &ksi4_gp25
+ &ksi5_gp24
+ &ksi6_gp23
+ &ksi7_gp22
+ &kso00_gp21
+ &kso01_gp20
+ &kso03_gp16
+ &kso04_gp15
+ &kso05_gp14
+ &kso06_gp13
+ &kso07_gp12
+ &kso08_gp11
+ &kso09_gp10
+ &kso10_gp07
+ &kso11_gp06
+ &kso12_gp05
+ >;
+ pinctrl-1 = <
+ &ksi0_gpio_gp31
+ &ksi1_gpio_gp30
+ &ksi2_gpio_gp27
+ &ksi3_gpio_gp26
+ &ksi4_gpio_gp25
+ &ksi5_gpio_gp24
+ &ksi6_gpio_gp23
+ &ksi7_gpio_gp22
+ &kso00_gpio_gp21
+ &kso01_gpio_gp20
+ &kso03_gpio_gp16
+ &kso04_gpio_gp15
+ &kso05_gpio_gp14
+ &kso06_gpio_gp13
+ &kso07_gpio_gp12
+ &kso08_gpio_gp11
+ &kso09_gpio_gp10
+ &kso10_gpio_gp07
+ &kso11_gpio_gp06
+ &kso12_gpio_gp05
+ >;
+ pinctrl-names = "default", "sleep";
+};
diff --git a/zephyr/program/nissa/craask/motionsense.dtsi b/zephyr/program/nissa/craask/motionsense.dtsi
new file mode 100644
index 0000000000..941dfa2240
--- /dev/null
+++ b/zephyr/program/nissa/craask/motionsense.dtsi
@@ -0,0 +1,256 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/motionsense/utils.h>
+
+
+/ {
+ aliases {
+ /*
+ * Interrupt bindings for sensor devices.
+ */
+ lsm6dso-int = &base_accel;
+ lis2dw12-int = &lid_accel;
+ bmi3xx-int = &base_accel;
+ bma4xx-int = &lid_accel;
+ };
+
+ /*
+ * Declare mutexes used by sensor drivers.
+ * A mutex node is used to create an instance of mutex_t.
+ * A mutex node is referenced by a sensor node if the
+ * corresponding sensor driver needs to use the
+ * instance of the mutex.
+ */
+ motionsense-mutex {
+ compatible = "cros-ec,motionsense-mutex";
+ lid_mutex: lis2dw12-mutex {
+ };
+
+ lid_mutex_bma422: bma422-mutex {
+ };
+
+ base_mutex: base-mutex {
+ };
+
+ base_mutex_bmi323: bmi323-mutex {
+ };
+ };
+
+ /* Rotation matrix used by drivers. */
+ motionsense-rotation-ref {
+ compatible = "cros-ec,motionsense-rotation-ref";
+ lid_rot_ref: lid-rotation-ref {
+ mat33 = <(-1) 0 0
+ 0 1 0
+ 0 0 (-1)>;
+ };
+
+ base_rot_ref: base-rotation-ref {
+ mat33 = <1 0 0
+ 0 (-1) 0
+ 0 0 (-1)>;
+ };
+
+ base_rot_ver1: base-rotation-ver1 {
+ mat33 = <(-1) 0 0
+ 0 (-1) 0
+ 0 0 1>;
+ };
+
+ lid_rot_bma422: lid-rotation-bma {
+ mat33 = <1 0 0
+ 0 (-1) 0
+ 0 0 (-1)>;
+ };
+
+ base_rot_bmi323: base-rotation-bmi323 {
+ mat33 = <0 (-1) 0
+ (-1) 0 0
+ 0 0 (-1)>;
+ };
+ };
+
+ /*
+ * Driver specific data. A driver-specific data can be shared with
+ * different motion sensors while they are using the same driver.
+ *
+ * If a node's compatible starts with "cros-ec,accelgyro-", it is for
+ * a common structure defined in accelgyro.h.
+ * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
+ * "struct als_drv_data_t" in accelgyro.h
+ */
+ motionsense-sensor-data {
+ lsm6dso_accel_data: lsm6dso-accel-drv-data {
+ compatible = "cros-ec,drvdata-lsm6dso";
+ status = "okay";
+ };
+
+ lsm6dso_gyro_data: lsm6dso-gyro-drv-data {
+ compatible = "cros-ec,drvdata-lsm6dso";
+ status = "okay";
+ };
+
+ lis2dw12_data: lis2dw12-drv-data {
+ compatible = "cros-ec,drvdata-lis2dw12";
+ status = "okay";
+ };
+
+ bma422_data: bma4xx-drv-data {
+ compatible = "cros-ec,drvdata-bma4xx";
+ status = "okay";
+ };
+
+ bmi323_data: bmi323-drv-data {
+ compatible = "cros-ec,drvdata-bmi3xx";
+ status = "okay";
+ };
+ };
+
+ /*
+ * List of motion sensors that creates motion_sensors array.
+ * The nodelabel "lid_accel" and "base_accel" are used to indicate
+ * motion sensor IDs for lid angle calculation.
+ * TODO(b/238139272): The first entries of the array must be
+ * accelerometers,then gyroscope. Fix this dependency in the DTS
+ * processing which makes the devicetree entries independent.
+ */
+ motionsense-sensor {
+ lid_accel: lid-accel {
+ compatible = "cros-ec,lis2dw12";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&lid_rot_ref>;
+ default-range = <2>;
+ drv-data = <&lis2dw12_data>;
+ i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS";
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_accel: base-accel {
+ compatible = "cros-ec,lsm6dso-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&lsm6dso_accel_data>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_gyro: base-gyro {
+ compatible = "cros-ec,lsm6dso-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */
+ drv-data = <&lsm6dso_gyro_data>;
+ };
+ };
+
+ motionsense-sensor-alt {
+ alt_lid_accel: alt-lid-accel {
+ compatible = "cros-ec,bma4xx";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex_bma422>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&lid_rot_bma422>;
+ default-range = <2>;
+ drv-data = <&bma422_data>;
+ i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY";
+ alternate-for = <&lid_accel>;
+ alternate-ssfc-indicator = <&lid_sensor_1>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ alt_base_accel: alt-base-accel {
+ compatible = "cros-ec,bmi3xx-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex_bmi323>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_bmi323>;
+ drv-data = <&bmi323_data>;
+ alternate-for = <&base_accel>;
+ alternate-ssfc-indicator = <&base_sensor_1>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ alt_base_gyro: alt-base-gyro {
+ compatible = "cros-ec,bmi3xx-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex_bmi323>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_bmi323>;
+ drv-data = <&bmi323_data>;
+ alternate-for = <&base_gyro>;
+ alternate-ssfc-indicator = <&base_sensor_1>;
+ };
+ };
+
+ motionsense-sensor-info {
+ compatible = "cros-ec,motionsense-sensor-info";
+
+ /*
+ * list of GPIO interrupts that have to
+ * be enabled at initial stage
+ */
+ sensor-irqs = <&int_imu &int_lid_accel>;
+ };
+};
diff --git a/zephyr/program/nissa/craask/overlay.dtsi b/zephyr/program/nissa/craask/overlay.dtsi
new file mode 100644
index 0000000000..749317cbf5
--- /dev/null
+++ b/zephyr/program/nissa/craask/overlay.dtsi
@@ -0,0 +1,414 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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>
+#include <dt-bindings/usbc_mux.h>
+#include <dt-bindings/usb_pd_tcpm.h>
+
+/ {
+ aliases {
+ gpio-cbi-wp = &gpio_ec_cbi_wp;
+ gpio-wp = &gpio_ec_wp_odl;
+ int-wp = &int_wp_l;
+ gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ };
+
+ ec-console {
+ compatible = "ec-console";
+ disabled = "events", "lpc", "hostcmd";
+ };
+
+ batteries {
+ default_battery: lgc {
+ compatible = "lgc,ap18c8k", "battery-smart";
+ };
+ cosmx {
+ compatible = "cosmx,ap20cbl", "battery-smart";
+ };
+ cosmx-2 {
+ compatible = "cosmx,ap20cbl-2", "battery-smart";
+ };
+ };
+
+ hibernate-wake-pins {
+ compatible = "cros-ec,hibernate-wake-pins";
+ wakeup-irqs = <
+ &int_power_button
+ &int_lid_open
+ >;
+ };
+
+ gpio-interrupts {
+ compatible = "cros-ec,gpio-interrupts";
+
+ int_power_button: power_button {
+ irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "power_button_interrupt";
+ };
+ int_wp_l: wp_l {
+ irq-pin = <&gpio_ec_wp_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "switch_interrupt";
+ };
+ int_lid_open: lid_open {
+ irq-pin = <&gpio_lid_open>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "lid_interrupt";
+ };
+ int_tablet_mode: tablet_mode {
+ irq-pin = <&gpio_tablet_mode_l>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "gmr_tablet_switch_isr";
+ };
+ int_imu: ec_imu {
+ irq-pin = <&gpio_imu_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "motion_interrupt";
+ };
+ int_lid_accel: ec_lid_accel {
+ irq-pin = <&gpio_acc_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "lid_accel_interrupt";
+ };
+ int_vol_down: vol_down {
+ irq-pin = <&gpio_voldn_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_vol_up: vol_up {
+ irq-pin = <&gpio_volup_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_usb_c0: usb_c0 {
+ irq-pin = <&gpio_usb_c0_int_odl>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_interrupt";
+ };
+ int_usb_c1: usb_c1 {
+ irq-pin = <&gpio_sb_1>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_interrupt";
+ };
+ };
+
+ named-gpios {
+ gpio_sb_1: sb-1 {
+ gpios = <&gpio0 2 GPIO_PULL_UP>;
+ no-auto-init;
+ };
+
+ gpio_sb_2: sb-2 {
+ gpios = <&gpiod 4 GPIO_OUTPUT>;
+ no-auto-init;
+ };
+
+ /*
+ * 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.
+ */
+ gpio_sb_3: sb-3 {
+ gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>;
+ no-auto-init;
+ };
+ gpio_sb_4: sb-4 {
+ gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ no-auto-init;
+ };
+ gpio_fan_enable: fan-enable {
+ gpios = <&gpio6 3 GPIO_OUTPUT>;
+ no-auto-init;
+ };
+ ec-i2c-sensor-scl {
+ gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec-i2c-sensor-sda {
+ gpios = <&gpio8 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ };
+
+ /*
+ * Aliases used for sub-board GPIOs.
+ */
+ aliases {
+ /*
+ * Input GPIO when used with type-C port 1
+ * Output when used with HDMI sub-board
+ */
+ gpio-usb-c1-int-odl = &gpio_sb_1;
+ gpio-en-rails-odl = &gpio_sb_1;
+ /*
+ * Sub-board with type A USB, enable.
+ */
+ gpio-en-usb-a1-vbus = &gpio_sb_2;
+ /*
+ * HPD pins for HDMI sub-board.
+ */
+ gpio-hdmi-en-odl = &gpio_sb_3;
+ gpio-hpd-odl = &gpio_sb_4;
+ /*
+ * Enable S5 rails for LTE sub-board
+ */
+ gpio-en-sub-s5-rails = &gpio_sb_2;
+ };
+
+ temp_memory: memory {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_1>;
+ };
+ temp_charger: charger {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_2>;
+ };
+ temp_ambient: ambient {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_3>;
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ memory {
+ temp_host_high = <75>;
+ temp_host_halt = <85>;
+ temp_host_release_high = <70>;
+ temp_host_release_halt = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_memory>;
+ };
+ charger {
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_charger>;
+ };
+ ambient {
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_ambient>;
+ };
+ };
+
+ usba {
+ compatible = "cros-ec,usba-port-enable-pins";
+ /*
+ * sb_2 is only configured as GPIO when USB-A1 is present,
+ * but it's still safe to control when disabled.
+ *
+ * ILIM_SEL pins are referred to by legacy enum name,
+ * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
+ * sub-boards that don't have USB-A so is safe to control
+ * regardless of system configuration.
+ */
+ enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
+ status = "okay";
+ };
+
+ usbc {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port0@0 {
+ compatible = "named-usbc-port";
+ reg = <0>;
+ bc12 = <&bc12_port0>;
+ chg = <&chg_port0>;
+ tcpc = <&tcpc_port0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_0>;
+ };
+ };
+ port0-muxes {
+ virtual_mux_0: virtual-mux-0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ /*
+ * TODO(b:211693800): port1 may not be present on some
+ * sub-boards.
+ */
+ port1@1 {
+ compatible = "named-usbc-port";
+ reg = <1>;
+ bc12 = <&bc12_port1>;
+ chg = <&chg_port1>;
+ tcpc = <&tcpc_port1>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_1 &anx7483_mux_1>;
+ };
+ usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux {
+ compatible = "cros-ec,usb-mux-chain";
+ alternative-chain;
+ usb-muxes = <&virtual_mux_1>;
+ };
+ };
+ port1-muxes {
+ virtual_mux_1: virtual-mux-1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ };
+
+ kblight {
+ compatible = "cros-ec,kblight-pwm";
+ pwms = <&pwm6 6 PWM_HZ(2400) PWM_POLARITY_NORMAL>;
+ };
+
+ /*
+ * Declare unused GPIOs so that they are shut down
+ * and use minimal power
+ */
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios =
+ <&gpio3 2 0>,
+ <&gpio3 3 0>,
+ <&gpio3 5 0>,
+ <&gpio3 6 0>,
+ <&gpio5 7 0>,
+ <&gpio6 0 0>,
+ <&gpio6 3 0>,
+ <&gpio6 6 0>,
+ <&gpio7 3 0>,
+ <&gpio8 3 0>,
+ <&gpio8 6 0>,
+ <&gpiob 1 0>,
+ <&gpiob 7 0>,
+ <&gpioc 7 0>,
+ <&gpiof 2 0>,
+ <&gpiof 3 0>;
+ };
+};
+
+&thermistor_3V3_51K1_47K_4050B {
+ status = "okay";
+};
+
+&adc_ec_vsense_pp3300_s5 {
+ /*
+ * Voltage divider on input has 47k upper and 220k lower legs with
+ * 2714 mV full-scale reading on the ADC. Apply the largest possible
+ * multiplier (without overflowing int32) to get the best possible
+ * approximation of the actual ratio, but derate by a factor of two to
+ * ensure unexpectedly high values won't overflow.
+ */
+ mul = <(791261 / 2)>;
+ div = <(651975 / 2)>;
+};
+
+/* Set bus speeds for I2C */
+&i2c0_0 {
+ label = "I2C_EEPROM";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+};
+
+&i2c1_0 {
+ label = "I2C_SENSOR";
+ clock-frequency = <I2C_BITRATE_FAST>;
+};
+
+&i2c3_0 {
+ label = "I2C_USB_C0_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ /*
+ * BC1.2 interrupt is shared with TCPC, so
+ * IRQ is not specified here and handled by
+ * usb_c0_interrupt.
+ */
+ };
+
+ chg_port0: isl923x@9 {
+ compatible = "intersil,isl923x";
+ status = "okay";
+ reg = <0x9>;
+ };
+
+ tcpc_port0: raa489000@22 {
+ compatible = "renesas,raa489000";
+ reg = <0x22>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_VBUS_MONITOR)>;
+ };
+};
+
+&i2c5_1 {
+ label = "I2C_SUB_C1_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+
+ bc12_port1: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ };
+
+ chg_port1: isl923x@9 {
+ compatible = "intersil,isl923x";
+ status = "okay";
+ reg = <0x9>;
+ };
+
+ tcpc_port1: raa489000@22 {
+ compatible = "renesas,raa489000";
+ reg = <0x22>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_VBUS_MONITOR)>;
+ };
+
+ anx7483_mux_1: anx7483-mux-1@3e {
+ compatible = "analogix,anx7483";
+ reg = <0x3e>;
+ board-set = "anx7483_set_default_tuning";
+ flags = <USB_MUX_FLAG_RESETS_IN_G3>;
+ };
+};
+
+&i2c7_0 {
+ label = "I2C_BATTERY";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+};
+
+&pwm6 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm6_gpc0>;
+ pinctrl-names = "default";
+};
+
+/* host interface */
+&espi0 {
+ status = "okay";
+ pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
+ pinctrl-names = "default";
+};
+
+/*
+ * Declare GPIOs that have leakage current caused by board issues here. NPCX ec
+ * will disable their input buffers before entering deep sleep and restore them
+ * after waking up automatically for better power consumption.
+ */
+&power_leakage_io {
+ leak-gpios = <&gpioa 4 0
+ &gpiof 1 0>;
+};
diff --git a/zephyr/projects/nissa/craask/power_signals.dtsi b/zephyr/program/nissa/craask/power_signals.dtsi
index 1d2b23069d..1d2b23069d 100644
--- a/zephyr/projects/nissa/craask/power_signals.dtsi
+++ b/zephyr/program/nissa/craask/power_signals.dtsi
diff --git a/zephyr/program/nissa/craask/project.conf b/zephyr/program/nissa/craask/project.conf
new file mode 100644
index 0000000000..85cef7caba
--- /dev/null
+++ b/zephyr/program/nissa/craask/project.conf
@@ -0,0 +1,17 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_BOARD_CRAASK=y
+CONFIG_PLATFORM_EC_OCPC=y
+
+# Sensor drivers
+CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y
+CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
+CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y
+
+CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y
+
+CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST=y
diff --git a/zephyr/program/nissa/craask/project.overlay b/zephyr/program/nissa/craask/project.overlay
new file mode 100644
index 0000000000..6107b6ef15
--- /dev/null
+++ b/zephyr/program/nissa/craask/project.overlay
@@ -0,0 +1,15 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "../cbi.dtsi"
+
+#include "cbi.dtsi"
+#include "fan.dtsi"
+#include "generated.dtsi"
+#include "keyboard.dtsi"
+#include "motionsense.dtsi"
+#include "overlay.dtsi"
+#include "power_signals.dtsi"
+#include "pwm_leds.dtsi"
diff --git a/zephyr/projects/nissa/craask/pwm_leds.dtsi b/zephyr/program/nissa/craask/pwm_leds.dtsi
index e55aa1c9ef..e55aa1c9ef 100644
--- a/zephyr/projects/nissa/craask/pwm_leds.dtsi
+++ b/zephyr/program/nissa/craask/pwm_leds.dtsi
diff --git a/zephyr/program/nissa/craask/src/charger.c b/zephyr/program/nissa/craask/src/charger.c
new file mode 100644
index 0000000000..3984045a19
--- /dev/null
+++ b/zephyr/program/nissa/craask/src/charger.c
@@ -0,0 +1,56 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "charger.h"
+#include "charger/isl923x_public.h"
+#include "console.h"
+#include "extpower.h"
+#include "nissa_common.h"
+#include "usb_pd.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+int extpower_is_present(void)
+{
+ int port;
+ int rv;
+ bool acok;
+
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
+ rv = raa489000_is_acok(port, &acok);
+ if ((rv == EC_SUCCESS) && acok)
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ * Craask does not have a GPIO indicating whether extpower is present,
+ * so detect using the charger(s).
+ */
+__override void board_check_extpower(void)
+{
+ static int last_extpower_present;
+ int extpower_present = extpower_is_present();
+
+ if (last_extpower_present ^ extpower_present)
+ extpower_handle_update(extpower_present);
+
+ last_extpower_present = extpower_present;
+}
+
+__override void board_hibernate(void)
+{
+ /* Shut down the chargers */
+ if (board_get_usb_pd_port_count() == 2)
+ raa489000_hibernate(CHARGER_SECONDARY, true);
+ raa489000_hibernate(CHARGER_PRIMARY, true);
+ LOG_INF("Charger(s) hibernated");
+ cflush();
+}
diff --git a/zephyr/program/nissa/craask/src/fan.c b/zephyr/program/nissa/craask/src/fan.c
new file mode 100644
index 0000000000..c01ee3d752
--- /dev/null
+++ b/zephyr/program/nissa/craask/src/fan.c
@@ -0,0 +1,37 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "cros_cbi.h"
+#include "fan.h"
+#include "gpio/gpio.h"
+#include "hooks.h"
+#include "nissa_common.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+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/program/nissa/craask/src/form_factor.c b/zephyr/program/nissa/craask/src/form_factor.c
new file mode 100644
index 0000000000..56d0c50f73
--- /dev/null
+++ b/zephyr/program/nissa/craask/src/form_factor.c
@@ -0,0 +1,133 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "accelgyro.h"
+#include "button.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "driver/accel_bma4xx.h"
+#include "driver/accel_lis2dw12_public.h"
+#include "driver/accelgyro_bmi323.h"
+#include "driver/accelgyro_lsm6dso.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "motion_sense.h"
+#include "motionsense_sensors.h"
+#include "nissa_common.h"
+#include "tablet_mode.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+/*
+ * Mainboard orientation support.
+ */
+
+#define LIS_ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_bma422))
+#define BMA_ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref))
+#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(base_rot_ver1))
+#define LID_SENSOR SENSOR_ID(DT_NODELABEL(lid_accel))
+#define BASE_SENSOR SENSOR_ID(DT_NODELABEL(base_accel))
+#define BASE_GYRO SENSOR_ID(DT_NODELABEL(base_gyro))
+#define ALT_LID_S SENSOR_ID(DT_NODELABEL(alt_lid_accel))
+
+static bool use_alt_sensor;
+static bool use_alt_lid_accel;
+
+void motion_interrupt(enum gpio_signal signal)
+{
+ if (use_alt_sensor)
+ bmi3xx_interrupt(signal);
+ else
+ lsm6dso_interrupt(signal);
+}
+
+void lid_accel_interrupt(enum gpio_signal signal)
+{
+ if (use_alt_lid_accel)
+ bma4xx_interrupt(signal);
+ else
+ lis2dw12_interrupt(signal);
+}
+
+static void form_factor_init(void)
+{
+ int ret;
+ uint32_t val;
+ enum nissa_sub_board_type sb = nissa_get_sb_type();
+
+ ret = cbi_get_board_version(&val);
+ if (ret != EC_SUCCESS) {
+ LOG_ERR("Error retrieving CBI BOARD_VER.");
+ return;
+ }
+ /*
+ * The volume up/down button are exchanged on ver3 USB
+ * sub board.
+ *
+ * LTE:
+ * volup -> gpioa2, voldn -> gpio93
+ * USB:
+ * volup -> gpio93, voldn -> gpioa2
+ */
+ if (val == 3 && sb == NISSA_SB_C_A) {
+ LOG_INF("Volume up/down btn exchanged on ver3 USB sku");
+ buttons[BUTTON_VOLUME_UP].gpio = GPIO_VOLUME_DOWN_L;
+ buttons[BUTTON_VOLUME_DOWN].gpio = GPIO_VOLUME_UP_L;
+ }
+
+ /*
+ * If the board version is 1
+ * use ver1 rotation matrix.
+ */
+ if (val == 1) {
+ LOG_INF("Switching to ver1 base");
+ motion_sensors[BASE_SENSOR].rot_standard_ref = &ALT_MAT;
+ motion_sensors[BASE_GYRO].rot_standard_ref = &ALT_MAT;
+ }
+
+ /*
+ * If the firmware config indicates
+ * an craaskbowl form factor, use the alternative
+ * rotation matrix.
+ */
+ ret = cros_cbi_get_fw_config(FW_LID_INVERSION, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d",
+ FW_LID_INVERSION);
+ return;
+ }
+ if (val == FW_LID_XY_ROT_180) {
+ LOG_INF("Lid sensor placement rotate 180 on xy plane");
+ motion_sensors[LID_SENSOR].rot_standard_ref = &LIS_ALT_MAT;
+ motion_sensors_alt[ALT_LID_S].rot_standard_ref = &BMA_ALT_MAT;
+ }
+
+ /* check which motion sensors are used */
+ use_alt_sensor = cros_cbi_ssfc_check_match(
+ CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1)));
+ use_alt_lid_accel = cros_cbi_ssfc_check_match(
+ CBI_SSFC_VALUE_ID(DT_NODELABEL(lid_sensor_1)));
+
+ motion_sensors_check_ssfc();
+
+ /* Check if it's clamshell or convertible */
+ ret = cros_cbi_get_fw_config(FORM_FACTOR, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR);
+ return;
+ }
+ if (val == CLAMSHELL) {
+ LOG_INF("Clamshell: disable motionsense function.");
+ motion_sensor_count = 0;
+ gmr_tablet_switch_disable();
+ gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu));
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l),
+ GPIO_DISCONNECTED);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/program/nissa/craask/src/kb_backlight.c b/zephyr/program/nissa/craask/src/kb_backlight.c
new file mode 100644
index 0000000000..108cbb3abd
--- /dev/null
+++ b/zephyr/program/nissa/craask/src/kb_backlight.c
@@ -0,0 +1,34 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "board_config.h"
+#include "common.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+__override uint32_t board_override_feature_flags0(uint32_t flags0)
+{
+ int ret;
+ uint32_t val;
+
+ /*
+ * Remove keyboard backlight feature for devices that don't support it.
+ */
+ ret = cros_cbi_get_fw_config(FW_KB_BL, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_KB_BL);
+ return flags0;
+ }
+
+ if (val == FW_KB_BL_NOT_PRESENT)
+ return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB));
+ else
+ return flags0;
+}
diff --git a/zephyr/program/nissa/craask/src/keyboard.c b/zephyr/program/nissa/craask/src/keyboard.c
new file mode 100644
index 0000000000..1d2102b655
--- /dev/null
+++ b/zephyr/program/nissa/craask/src/keyboard.c
@@ -0,0 +1,45 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ec_commands.h"
+
+static const struct ec_response_keybd_config craask_kb = {
+ .num_top_row_keys = 10,
+ .action_keys = {
+ TK_BACK, /* T1 */
+ TK_REFRESH, /* T2 */
+ TK_FULLSCREEN, /* T3 */
+ TK_OVERVIEW, /* T4 */
+ TK_SNAPSHOT, /* T5 */
+ TK_BRIGHTNESS_DOWN, /* T6 */
+ TK_BRIGHTNESS_UP, /* T7 */
+ TK_VOL_MUTE, /* T8 */
+ TK_VOL_DOWN, /* T9 */
+ TK_VOL_UP, /* T10 */
+ },
+ .capabilities = KEYBD_CAP_SCRNLOCK_KEY,
+};
+
+__override const struct ec_response_keybd_config *
+board_vivaldi_keybd_config(void)
+{
+ return &craask_kb;
+}
+
+/*
+ * We have total 30 pins for keyboard connecter {-1, -1} mean
+ * the N/A pin that don't consider it and reserve index 0 area
+ * that we don't have pin 0.
+ */
+const int keyboard_factory_scan_pins[][2] = {
+ { -1, -1 }, { 0, 5 }, { 1, 1 }, { 1, 0 }, { 0, 6 }, { 0, 7 },
+ { -1, -1 }, { -1, -1 }, { 1, 4 }, { 1, 3 }, { -1, -1 }, { 1, 6 },
+ { 1, 7 }, { 3, 1 }, { 2, 0 }, { 1, 5 }, { 2, 6 }, { 2, 7 },
+ { 2, 1 }, { 2, 4 }, { 2, 5 }, { 1, 2 }, { 2, 3 }, { 2, 2 },
+ { 3, 0 }, { -1, -1 }, { 0, 4 }, { -1, -1 }, { 8, 2 }, { -1, -1 },
+ { -1, -1 },
+};
+const int keyboard_factory_scan_pins_used =
+ ARRAY_SIZE(keyboard_factory_scan_pins);
diff --git a/zephyr/projects/nissa/craask/src/led.c b/zephyr/program/nissa/craask/src/led.c
index 0af0202cf4..0af0202cf4 100644
--- a/zephyr/projects/nissa/craask/src/led.c
+++ b/zephyr/program/nissa/craask/src/led.c
diff --git a/zephyr/program/nissa/craask/src/usbc.c b/zephyr/program/nissa/craask/src/usbc.c
new file mode 100644
index 0000000000..1e0c1627bb
--- /dev/null
+++ b/zephyr/program/nissa/craask/src/usbc.c
@@ -0,0 +1,251 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_state_v2.h"
+#include "chipset.h"
+#include "driver/charger/isl923x_public.h"
+#include "driver/retimer/anx7483_public.h"
+#include "driver/tcpm/raa489000.h"
+#include "driver/tcpm/tcpci.h"
+#include "hooks.h"
+#include "nissa_common.h"
+#include "system.h"
+#include "usb_mux.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+int board_is_sourcing_vbus(int port)
+{
+ int regval;
+
+ tcpc_read(port, TCPC_REG_POWER_STATUS, &regval);
+ return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS);
+}
+
+int board_set_active_charge_port(int port)
+{
+ int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
+ int i;
+ int old_port;
+
+ if (!is_real_port && port != CHARGE_PORT_NONE)
+ return EC_ERROR_INVAL;
+
+ old_port = charge_manager_get_active_charge_port();
+
+ LOG_INF("New chg p%d", port);
+
+ /* Disable all ports. */
+ if (port == CHARGE_PORT_NONE) {
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ tcpc_write(i, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_SNK_CTRL_LOW);
+ raa489000_enable_asgate(i, false);
+ }
+
+ return EC_SUCCESS;
+ }
+
+ /* Check if port is sourcing VBUS. */
+ if (board_is_sourcing_vbus(port)) {
+ LOG_WRN("Skip enable p%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ if (i == port)
+ continue;
+
+ if (tcpc_write(i, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_SNK_CTRL_LOW))
+ LOG_WRN("p%d: sink path disable failed.", i);
+ raa489000_enable_asgate(i, false);
+ }
+
+ /*
+ * Stop the charger IC from switching while changing ports. Otherwise,
+ * we can overcurrent the adapter we're switching to. (crbug.com/926056)
+ */
+ if (old_port != CHARGE_PORT_NONE)
+ charger_discharge_on_ac(1);
+
+ /* Enable requested charge port. */
+ if (raa489000_enable_asgate(port, true) ||
+ tcpc_write(port, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_SNK_CTRL_HIGH)) {
+ LOG_WRN("p%d: sink path enable failed.", port);
+ charger_discharge_on_ac(0);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ /* Allow the charger IC to begin/continue switching. */
+ charger_discharge_on_ac(0);
+
+ return EC_SUCCESS;
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ uint16_t status = 0;
+ int regval;
+
+ /*
+ * The interrupt line is shared between the TCPC and BC1.2 detector IC.
+ * Therefore, go out and actually read the alert registers to report the
+ * alert status.
+ */
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
+ if (!tcpc_read16(0, TCPC_REG_ALERT, &regval)) {
+ /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */
+ if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0))
+ regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
+
+ if (regval)
+ status |= PD_STATUS_TCPC_ALERT_0;
+ }
+ }
+
+ if (board_get_usb_pd_port_count() == 2 &&
+ !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
+ /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */
+ if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0))
+ regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
+
+ if (regval)
+ status |= PD_STATUS_TCPC_ALERT_1;
+ }
+ }
+
+ return status;
+}
+
+void pd_power_supply_reset(int port)
+{
+ /* Disable VBUS */
+ tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW);
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ return;
+
+ raa489000_set_output_current(port, rp);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ int rv;
+
+ if (port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ return EC_ERROR_INVAL;
+
+ /* Disable charging. */
+ rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW);
+ if (rv)
+ return rv;
+
+ /* Our policy is not to source VBUS when the AP is off. */
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ return EC_ERROR_NOT_POWERED;
+
+ /* Provide Vbus. */
+ rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH);
+ if (rv)
+ return rv;
+
+ rv = raa489000_enable_asgate(port, true);
+ if (rv)
+ return rv;
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
+}
+
+void board_reset_pd_mcu(void)
+{
+ /*
+ * TODO(b:147316511): could send a reset command to the TCPC here
+ * if needed.
+ */
+}
+
+/*
+ * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible
+ * for an interrupt to be lost if one asserts the IRQ, the other does the same
+ * then the first releases it: there will only be one falling edge to trigger
+ * the interrupt, and the line will be held low. We handle this by running a
+ * deferred check after a falling edge to see whether the IRQ is still being
+ * asserted. If it is, we assume an interrupt may have been lost and we need
+ * to poll each chip for events again.
+ */
+#define USBC_INT_POLL_DELAY_US 5000
+
+static void poll_c0_int(void);
+DECLARE_DEFERRED(poll_c0_int);
+static void poll_c1_int(void);
+DECLARE_DEFERRED(poll_c1_int);
+
+static void usbc_interrupt_trigger(int port)
+{
+ schedule_deferred_pd_interrupt(port);
+ usb_charger_task_set_event(port, USB_CHG_EVENT_BC12);
+}
+
+static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio,
+ const struct deferred_data *ud)
+{
+ if (!gpio_pin_get_dt(gpio)) {
+ usbc_interrupt_trigger(port);
+ hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
+ }
+}
+
+static void poll_c0_int(void)
+{
+ poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl),
+ &poll_c0_int_data);
+}
+
+static void poll_c1_int(void)
+{
+ poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl),
+ &poll_c1_int_data);
+}
+
+void usb_interrupt(enum gpio_signal signal)
+{
+ int port;
+ const struct deferred_data *ud;
+
+ if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) {
+ port = 0;
+ ud = &poll_c0_int_data;
+ } else {
+ port = 1;
+ ud = &poll_c1_int_data;
+ }
+ /*
+ * We've just been called from a falling edge, so there's definitely
+ * no lost IRQ right now. Cancel any pending check.
+ */
+ hook_call_deferred(ud, -1);
+ /* Trigger polling of TCPC and BC1.2 in respective tasks */
+ usbc_interrupt_trigger(port);
+ /* Check for lost interrupts in a bit */
+ hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
+}
diff --git a/zephyr/projects/nissa/include/nissa_common.h b/zephyr/program/nissa/include/nissa_common.h
index 7cdaba2e50..7cdaba2e50 100644
--- a/zephyr/projects/nissa/include/nissa_common.h
+++ b/zephyr/program/nissa/include/nissa_common.h
diff --git a/zephyr/projects/nissa/include/nissa_hdmi.h b/zephyr/program/nissa/include/nissa_hdmi.h
index 9f2f533ba7..9f2f533ba7 100644
--- a/zephyr/projects/nissa/include/nissa_hdmi.h
+++ b/zephyr/program/nissa/include/nissa_hdmi.h
diff --git a/zephyr/program/nissa/it8xxx2_program.conf b/zephyr/program/nissa/it8xxx2_program.conf
new file mode 100644
index 0000000000..475f34cf9d
--- /dev/null
+++ b/zephyr/program/nissa/it8xxx2_program.conf
@@ -0,0 +1,65 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_CROS_FLASH_IT8XXX2=y
+CONFIG_CROS_SYSTEM_IT8XXX2=y
+CONFIG_ESPI_IT8XXX2=y
+CONFIG_FPU=y
+# rv32iafc/ilp32f is not supported by the toolchain, so use soft-float
+CONFIG_FLOAT_HARD=n
+
+# EC performance is bad; limiting sensor data rate helps keep it from degrading
+# so much that it causes problems. b/240485526, b/230818312
+CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000
+
+# Allow more time for the charger to stabilise
+CONFIG_PLATFORM_EC_POWER_BUTTON_INIT_TIMEOUT=5
+
+# ITE has more space, so don't restrict shell
+CONFIG_SHELL_MINIMAL=n
+
+# RAM savings, since this chip is tight on available RAM.
+# It's useful to store a lot of logs for the host to request, but the default 4k
+# is pretty large.
+CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE_BUF_SIZE=2048
+# Our threads have short names, save 20 bytes per thread
+CONFIG_THREAD_MAX_NAME_LEN=12
+# Task stacks, tuned by experiment. Most expanded to prevent overflow, and a few
+# shrunk to save RAM.
+CONFIG_AP_PWRSEQ_STACK_SIZE=1408
+CONFIG_TASK_HOSTCMD_STACK_SIZE=1280
+CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1280
+CONFIG_TASK_PD_INT_STACK_SIZE=1280
+
+# TCPC+PPC: ITE on-chip for C0, PS8745 for optional C1
+CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8745=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_CHARGER=y
+# SM5803 controls power path on both ports
+CONFIG_PLATFORM_EC_USB_PD_5V_CHARGER_CTRL=y
+# SM5803 can discharge VBUS, but not via one of the available options;
+# pd_power_supply_reset() does discharge.
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE=n
+# The EC is put into programming mode while firmware is running
+# (after releasing reset) and PD after being reset will hard-reset
+# the port if a contract was already set up. If the system has no
+# battery, this will prevent programming because it will brown out
+# the system and reset. Inserting a delay gives the programmer more
+# time to put the EC into programming mode.
+CONFIG_PLATFORM_EC_USB_PD_STARTUP_DELAY_MS=2000
+
+# Charger driver and configuration
+CONFIG_PLATFORM_EC_OCPC=y
+CONFIG_PLATFORM_EC_CHARGER_SM5803=y
+CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS=21
+CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=15000
+# SM5803 is very inefficient in buck-boost operation, so DPS doesn't help and
+# might actually contribute to charger failures.
+CONFIG_PLATFORM_EC_USB_PD_DPS=n
+
+# VSENSE: PP3300_S5 & PP1050_PROC
+CONFIG_VCMP_IT8XXX2=y
+CONFIG_SENSOR=y
+CONFIG_SENSOR_SHELL=n
diff --git a/zephyr/projects/nissa/joxer/cbi.dtsi b/zephyr/program/nissa/joxer/cbi.dtsi
index afbd125b32..afbd125b32 100644
--- a/zephyr/projects/nissa/joxer/cbi.dtsi
+++ b/zephyr/program/nissa/joxer/cbi.dtsi
diff --git a/zephyr/projects/nissa/joxer/generated.dtsi b/zephyr/program/nissa/joxer/generated.dtsi
index 22214b9726..22214b9726 100644
--- a/zephyr/projects/nissa/joxer/generated.dtsi
+++ b/zephyr/program/nissa/joxer/generated.dtsi
diff --git a/zephyr/projects/nissa/joxer/joxer_vif.xml b/zephyr/program/nissa/joxer/joxer_vif.xml
index cfbce5623a..cfbce5623a 100644
--- a/zephyr/projects/nissa/joxer/joxer_vif.xml
+++ b/zephyr/program/nissa/joxer/joxer_vif.xml
diff --git a/zephyr/projects/nissa/joxer/keyboard.dtsi b/zephyr/program/nissa/joxer/keyboard.dtsi
index 04a620767a..04a620767a 100644
--- a/zephyr/projects/nissa/joxer/keyboard.dtsi
+++ b/zephyr/program/nissa/joxer/keyboard.dtsi
diff --git a/zephyr/program/nissa/joxer/motionsense.dtsi b/zephyr/program/nissa/joxer/motionsense.dtsi
new file mode 100644
index 0000000000..e9c46a849a
--- /dev/null
+++ b/zephyr/program/nissa/joxer/motionsense.dtsi
@@ -0,0 +1,148 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/motionsense/utils.h>
+
+
+/ {
+ aliases {
+ /*
+ * Interrupt bindings for sensor devices.
+ */
+ bmi3xx-int = &base_accel;
+ bma4xx-int = &lid_accel;
+ };
+
+ /*
+ * Declare mutexes used by sensor drivers.
+ * A mutex node is used to create an instance of mutex_t.
+ * A mutex node is referenced by a sensor node if the
+ * corresponding sensor driver needs to use the
+ * instance of the mutex.
+ */
+ motionsense-mutex {
+ compatible = "cros-ec,motionsense-mutex";
+ lid_mutex: lid-mutex {
+ };
+
+ base_mutex: base-mutex {
+ };
+ };
+
+ /* Rotation matrix used by drivers. */
+ motionsense-rotation-ref {
+ compatible = "cros-ec,motionsense-rotation-ref";
+ lid_rot_ref: lid-rotation-ref {
+ mat33 = <0 (-1) 0
+ (-1) 0 0
+ 0 0 (-1)>;
+ };
+
+ base_rot_ref: base-rotation-ref {
+ mat33 = <1 0 0
+ 0 1 0
+ 0 0 1>;
+ };
+ };
+
+ /*
+ * Driver specific data. A driver-specific data can be shared with
+ * different motion sensors while they are using the same driver.
+ *
+ * If a node's compatible starts with "cros-ec,accelgyro-", it is for
+ * a common structure defined in accelgyro.h.
+ * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
+ * "struct als_drv_data_t" in accelgyro.h
+ */
+ motionsense-sensor-data {
+ bmi323_data: bmi323-drv-data {
+ compatible = "cros-ec,drvdata-bmi3xx";
+ status = "okay";
+ };
+
+ bma422_data: bma422-drv-data {
+ compatible = "cros-ec,drvdata-bma4xx";
+ status = "okay";
+ };
+ };
+
+ /*
+ * List of motion sensors that creates motion_sensors array.
+ * The nodelabel "lid_accel" and "base_accel" are used to indicate
+ * motion sensor IDs for lid angle calculation.
+ * TODO(b/238139272): The first entries of the array must be
+ * accelerometers,then gyroscope. Fix this dependency in the DTS
+ * processing which makes the devicetree entries independent.
+ */
+ motionsense-sensor {
+ lid_accel: lid-accel {
+ compatible = "cros-ec,bma4xx";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&lid_rot_ref>;
+ default-range = <2>;
+ drv-data = <&bma422_data>;
+ i2c-spi-addr-flags = "BMA4_I2C_ADDR_SECONDARY";
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_accel: base-accel {
+ compatible = "cros-ec,bmi3xx-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi323_data>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_gyro: base-gyro {
+ compatible = "cros-ec,bmi3xx-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi323_data>;
+ };
+ };
+
+ motionsense-sensor-info {
+ compatible = "cros-ec,motionsense-sensor-info";
+
+ /*
+ * list of GPIO interrupts that have to
+ * be enabled at initial stage
+ */
+ sensor-irqs = <&int_imu &int_lid_accel>;
+ };
+};
diff --git a/zephyr/program/nissa/joxer/overlay.dtsi b/zephyr/program/nissa/joxer/overlay.dtsi
new file mode 100644
index 0000000000..56f1d928cf
--- /dev/null
+++ b/zephyr/program/nissa/joxer/overlay.dtsi
@@ -0,0 +1,459 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * 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>
+#include <dt-bindings/usb_pd_tcpm.h>
+
+/ {
+ aliases {
+ gpio-cbi-wp = &gpio_ec_cbi_wp;
+ gpio-wp = &gpio_ec_wp_odl;
+ int-wp = &int_wp_l;
+ /*
+ * USB-C: interrupt input.
+ * I2C pins are on i2c_ec_i2c_sub_usb_c1
+ */
+ gpio-usb-c1-int-odl = &gpio_sb_1;
+ /*
+ * USB-A: VBUS enable output
+ * LTE: power enable output
+ */
+ gpio-en-usb-a1-vbus = &gpio_sb_2;
+ /*
+ * HDMI: power enable output, HDMI enable output,
+ * and HPD input
+ */
+ gpio-en-rails-odl = &gpio_sb_1;
+ gpio-hdmi-en-odl = &gpio_sb_4;
+ gpio-hpd-odl = &gpio_sb_3;
+ /*
+ * Enable S5 rails for LTE sub-board
+ */
+ gpio-en-sub-s5-rails = &gpio_sb_2;
+ };
+
+ ec-console {
+ compatible = "ec-console";
+ disabled = "events", "lpc", "hostcmd";
+ };
+
+ batteries {
+ default_battery: cosmx {
+ compatible = "cosmx,gh02047xl", "battery-smart";
+ };
+ dynapack_atl_gh02047xl {
+ compatible = "dynapack,atl_gh02047xl", "battery-smart";
+ };
+ dynapack_cosmx_gh02047xl {
+ compatible = "dynapack,cosmx_gh02047xl", "battery-smart";
+ };
+ smp_coslight_gh02047xl {
+ compatible = "smp,coslight_gh02047xl", "battery-smart";
+ };
+ smp_highpower_gh02047xl {
+ compatible = "smp,highpower_gh02047xl", "battery-smart";
+ };
+ };
+
+ hibernate-wake-pins {
+ compatible = "cros-ec,hibernate-wake-pins";
+ wakeup-irqs = <
+ &int_power_button
+ &int_lid_open
+ >;
+ };
+
+ gpio-interrupts {
+ compatible = "cros-ec,gpio-interrupts";
+
+ int_power_button: power_button {
+ irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "power_button_interrupt";
+ };
+ int_vol_down: vol_down {
+ irq-pin = <&gpio_voldn_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_vol_up: vol_up {
+ irq-pin = <&gpio_volup_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_wp_l: wp_l {
+ irq-pin = <&gpio_ec_wp_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "switch_interrupt";
+ };
+ int_lid_open: lid_open {
+ irq-pin = <&gpio_lid_open>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "lid_interrupt";
+ };
+ int_tablet_mode: tablet_mode {
+ irq-pin = <&gpio_tablet_mode_l>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "gmr_tablet_switch_isr";
+ };
+ int_imu: ec_imu {
+ irq-pin = <&gpio_imu_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "bmi3xx_interrupt";
+ };
+ int_lid_accel: ec_lid_accel {
+ irq-pin = <&gpio_acc_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "bma4xx_interrupt";
+ };
+ int_usb_c0: usb_c0 {
+ irq-pin = <&gpio_usb_c0_int_odl>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_c0_interrupt";
+ };
+ int_usb_c1: usb_c1 {
+ irq-pin = <&gpio_sb_1>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_c1_interrupt";
+ };
+ };
+
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios = <&gpioc 3 0>,
+ <&gpiod 4 0>,
+ <&gpioh 2 0>,
+ <&gpiol 4 0>;
+ };
+
+ named-gpios {
+ /*
+ * EC doesn't take any specific action on CC/SBU disconnect due to
+ * fault, but this definition is useful for hardware testing.
+ */
+ gpio_usb_c0_prot_fault_odl: usb_c0_prot_fault_odl {
+ gpios = <&gpiok 6 GPIO_INPUT_PULL_UP>;
+ };
+
+ gpio_sb_1: sb_1 {
+ gpios = <&gpioe 6 0>;
+ no-auto-init;
+ };
+ gpio_sb_2: sb_2 {
+ gpios = <&gpiof 0 0>;
+ no-auto-init;
+ };
+
+ gpio_sb_3: sb_3 {
+ gpios = <&gpioe 7 0>;
+ no-auto-init;
+ };
+ gpio_sb_4: sb_4 {
+ gpios = <&gpioe 0 0>;
+ no-auto-init;
+ };
+ gpio_fan_enable: fan-enable {
+ gpios = <&gpiol 4 GPIO_OUTPUT>;
+ no-auto-init;
+ };
+ gpio_power_led_gate: power_led_gate {
+ gpios = <&gpiof 1 GPIO_OUTPUT_LOW>;
+ };
+ gpio_led_1_odl: led_1_odl {
+ gpios = <&gpioa 1 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_led_2_odl: led_2_odl {
+ gpios = <&gpioa 2 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_led_3_l: led_3_l {
+ gpios = <&gpiol 2 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_led_4_l: led_4_l {
+ gpios = <&gpiol 3 GPIO_OUTPUT_HIGH>;
+ };
+ };
+
+ temp_memory: memory {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_1>;
+ };
+ temp_charger: charger {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_2>;
+ };
+ temp_ambient: ambient {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_3>;
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ memory {
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_memory>;
+ };
+ charger {
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_charger>;
+ };
+ ambient {
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_ambient>;
+ };
+ };
+
+ usba {
+ compatible = "cros-ec,usba-port-enable-pins";
+ /*
+ * sb_2 is only configured as GPIO when USB-A1 is present,
+ * but it's still safe to control when disabled.
+ *
+ * ILIM_SEL pins are referred to by legacy enum name,
+ * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
+ * sub-boards that don't have USB-A so is safe to control
+ * regardless of system configuration.
+ */
+ enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
+ status = "okay";
+ };
+
+ usbc {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port0@0 {
+ compatible = "named-usbc-port";
+ reg = <0>;
+ bc12 = <&bc12_port0>;
+ chg = <&chg_port0>;
+ tcpc = <&usbpd0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_0>;
+ };
+ };
+ port0-muxes {
+ virtual_mux_0: virtual-mux-0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ port1@1 {
+ compatible = "named-usbc-port";
+ reg = <1>;
+ bc12 = <&bc12_port1>;
+ chg = <&chg_port1>;
+ tcpc = <&tcpc_port1>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_1 &tcpci_mux_1>;
+ };
+ usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux {
+ compatible = "cros-ec,usb-mux-chain";
+ alternative-chain;
+ usb-muxes = <&virtual_mux_1>;
+ };
+ };
+ port1-muxes {
+ virtual_mux_1: virtual-mux-1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ tcpci_mux_1: tcpci-mux-1 {
+ compatible = "parade,usbc-mux-ps8xxx";
+ };
+ };
+ };
+ fans {
+ compatible = "cros-ec,fans";
+
+ fan_0 {
+ pwms = <&pwm7 PWM_CHANNEL_7 PWM_KHZ(30) PWM_POLARITY_NORMAL>;
+ tach = <&tach1>;
+ rpm_min = <1500>;
+ rpm_start = <1500>;
+ rpm_max = <6500>;
+ enable_gpio = <&gpio_fan_enable>;
+ };
+ };
+};
+
+&gpio_acc_int_l {
+ gpios = <&gpioc 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+};
+&gpio_imu_int_l {
+ gpios = <&gpioj 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+};
+&gpio_vccin_aux_vid0 {
+ gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+};
+&gpio_vccin_aux_vid1 {
+ gpios = <&gpiok 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+};
+
+&gpio_ec_prochot_odl {
+ gpios = <&gpioi 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>;
+};
+
+&thermistor_3V3_51K1_47K_4050B {
+ status = "okay";
+};
+
+&adc_ec_vsense_pp3300_s5 {
+ /*
+ * Voltage divider on input has 47k upper and 220k lower legs with 3 V
+ * full-scale reading on the ADC. Apply the largest possible multiplier
+ * (without overflowing int32) to get the best possible approximation
+ * of the actual ratio, but derate by a factor of two to ensure
+ * unexpectedly high values won't overflow.
+ */
+ mul = <(715828 / 2)>;
+ div = <(589820 / 2)>;
+};
+
+&adc0 {
+ pinctrl-0 = <&adc0_ch0_gpi0_default
+ &adc0_ch2_gpi2_default
+ &adc0_ch3_gpi3_default
+ &adc0_ch13_gpl0_default
+ &adc0_ch14_gpl1_default>;
+ pinctrl-names = "default";
+};
+
+&pinctrl {
+ i2c2_clk_gpf6_default: i2c2_clk_gpf6_default {
+ gpio-voltage = "1v8";
+ };
+ i2c2_data_gpf7_default: i2c2_data_gpf7_default {
+ gpio-voltage = "1v8";
+ };
+};
+
+
+&i2c0 {
+ label = "I2C_EEPROM";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+ pinctrl-0 = <&i2c0_clk_gpb3_default
+ &i2c0_data_gpb4_default>;
+ pinctrl-names = "default";
+};
+
+&i2c1 {
+ label = "I2C_BATTERY";
+ clock-frequency = <50000>;
+ pinctrl-0 = <&i2c1_clk_gpc1_default
+ &i2c1_data_gpc2_default>;
+ pinctrl-names = "default";
+};
+
+&i2c2 {
+ label = "I2C_SENSOR";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c2_clk_gpf6_default
+ &i2c2_data_gpf7_default>;
+ pinctrl-names = "default";
+};
+
+&i2c4 {
+ label = "I2C_SUB_C1_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+ pinctrl-0 = <&i2c4_clk_gpe0_default
+ &i2c4_data_gpe7_default>;
+ pinctrl-names = "default";
+
+ bc12_port1: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ };
+
+ chg_port1: sm5803@32 {
+ compatible = "siliconmitus,sm5803";
+ status = "okay";
+ reg = <0x32>;
+ };
+
+ tcpc_port1: ps8745@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
+};
+
+&i2c_ec_i2c_sub_usb_c1 {
+ /*
+ * Dynamic speed setting is used for AP-controlled firmware update
+ * of PS8745 TCPC/redriver: the AP lowers speed to 400 kHz in order
+ * to use more efficient window programming, then sets it back when
+ * done.
+ */
+ dynamic-speed;
+};
+
+&i2c5 {
+ label = "I2C_USB_C0_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+ pinctrl-0 = <&i2c5_clk_gpa4_default
+ &i2c5_data_gpa5_default>;
+ pinctrl-names = "default";
+
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ };
+
+ chg_port0: sm5803@32 {
+ compatible = "siliconmitus,sm5803";
+ status = "okay";
+ reg = <0x32>;
+ };
+};
+
+/* pwm for fan */
+&pwm7 {
+ status = "okay";
+ prescaler-cx = <PWM_PRESCALER_C6>;
+ pinctrl-0 = <&pwm7_gpa7_default>;
+ pinctrl-names = "default";
+};
+
+/* fan tachometer sensor */
+&tach1 {
+ status = "okay";
+ channel = <IT8XXX2_TACH_CHANNEL_A>;
+ pulses-per-round = <2>;
+ pinctrl-0 = <&tach1a_gpd7_default>;
+ pinctrl-names = "default";
+};
+
+&usbpd0 {
+ status = "okay";
+};
diff --git a/zephyr/projects/nissa/joxer/power_signals.dtsi b/zephyr/program/nissa/joxer/power_signals.dtsi
index 8affae03b1..8affae03b1 100644
--- a/zephyr/projects/nissa/joxer/power_signals.dtsi
+++ b/zephyr/program/nissa/joxer/power_signals.dtsi
diff --git a/zephyr/projects/nissa/joxer/project.conf b/zephyr/program/nissa/joxer/project.conf
index a0de72294c..a0de72294c 100644
--- a/zephyr/projects/nissa/joxer/project.conf
+++ b/zephyr/program/nissa/joxer/project.conf
diff --git a/zephyr/projects/nissa/craask/project.overlay b/zephyr/program/nissa/joxer/project.overlay
index 9ca681d979..9ca681d979 100644
--- a/zephyr/projects/nissa/craask/project.overlay
+++ b/zephyr/program/nissa/joxer/project.overlay
diff --git a/zephyr/projects/nissa/joxer/pwm_leds.dtsi b/zephyr/program/nissa/joxer/pwm_leds.dtsi
index aa4a76b271..aa4a76b271 100644
--- a/zephyr/projects/nissa/joxer/pwm_leds.dtsi
+++ b/zephyr/program/nissa/joxer/pwm_leds.dtsi
diff --git a/zephyr/program/nissa/joxer/src/charger.c b/zephyr/program/nissa/joxer/src/charger.c
new file mode 100644
index 0000000000..4bb7de7ecb
--- /dev/null
+++ b/zephyr/program/nissa/joxer/src/charger.c
@@ -0,0 +1,56 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "charger.h"
+#include "console.h"
+#include "driver/charger/sm5803.h"
+#include "extpower.h"
+#include "nissa_common.h"
+#include "usb_pd.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+int extpower_is_present(void)
+{
+ int port;
+ int rv;
+ bool acok;
+
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
+ rv = sm5803_is_acok(port, &acok);
+ if ((rv == EC_SUCCESS) && acok)
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ * Joxer not have a GPIO indicating whether extpower is present,
+ * so detect using the charger(s).
+ */
+__override void board_check_extpower(void)
+{
+ static int last_extpower_present;
+ int extpower_present = extpower_is_present();
+
+ if (last_extpower_present ^ extpower_present)
+ extpower_handle_update(extpower_present);
+
+ last_extpower_present = extpower_present;
+}
+
+__override void board_hibernate(void)
+{
+ /* Shut down the chargers */
+ if (board_get_usb_pd_port_count() == 2)
+ sm5803_hibernate(CHARGER_SECONDARY);
+ sm5803_hibernate(CHARGER_PRIMARY);
+ LOG_INF("Charger(s) hibernated");
+ cflush();
+}
diff --git a/zephyr/program/nissa/joxer/src/fan.c b/zephyr/program/nissa/joxer/src/fan.c
new file mode 100644
index 0000000000..82be341da5
--- /dev/null
+++ b/zephyr/program/nissa/joxer/src/fan.c
@@ -0,0 +1,42 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "cros_cbi.h"
+#include "fan.h"
+#include "gpio/gpio.h"
+#include "hooks.h"
+#include "nissa_common.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+/*
+ * Joxer 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/program/nissa/joxer/src/keyboard.c b/zephyr/program/nissa/joxer/src/keyboard.c
new file mode 100644
index 0000000000..e9e20194f0
--- /dev/null
+++ b/zephyr/program/nissa/joxer/src/keyboard.c
@@ -0,0 +1,68 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "cros_cbi.h"
+#include "ec_commands.h"
+#include "gpio/gpio.h"
+#include "hooks.h"
+#include "keyboard_8042_sharedlib.h"
+#include "nissa_common.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+static const struct ec_response_keybd_config joxer_kb_legacy = {
+ .num_top_row_keys = 13,
+ .action_keys = {
+ TK_BACK, /* T1 */
+ TK_REFRESH, /* T2 */
+ TK_FULLSCREEN, /* T3 */
+ TK_OVERVIEW, /* T4 */
+ TK_SNAPSHOT, /* T5 */
+ TK_BRIGHTNESS_DOWN, /* T6 */
+ TK_BRIGHTNESS_UP, /* T7 */
+ TK_KBD_BKLIGHT_TOGGLE, /* T8 */
+ TK_PLAY_PAUSE, /* T9 */
+ TK_MICMUTE, /* T10 */
+ TK_VOL_MUTE, /* T11 */
+ TK_VOL_DOWN, /* T12 */
+ TK_VOL_UP, /* T13 */
+ },
+ .capabilities = KEYBD_CAP_SCRNLOCK_KEY,
+};
+
+__override const struct ec_response_keybd_config *
+board_vivaldi_keybd_config(void)
+{
+ return &joxer_kb_legacy;
+}
+
+/*
+ * Keyboard layout decided by FW config.
+ */
+static void kb_layout_init(void)
+{
+ int ret;
+ uint32_t val;
+ /*
+ * Retrieve the kb layout config.
+ */
+ ret = cros_cbi_get_fw_config(FW_KB_LAYOUT, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d",
+ FW_KB_LAYOUT);
+ return;
+ }
+ /*
+ * If keyboard is US2(FW_KB_LAYOUT_US2), we need translate right ctrl
+ * to backslash(\|) key.
+ */
+ if (val == FW_KB_LAYOUT_US2)
+ set_scancode_set2(4, 0, get_scancode_set2(2, 7));
+}
+DECLARE_HOOK(HOOK_INIT, kb_layout_init, HOOK_PRIO_POST_FIRST);
diff --git a/zephyr/program/nissa/joxer/src/led.c b/zephyr/program/nissa/joxer/src/led.c
new file mode 100644
index 0000000000..c617ee9507
--- /dev/null
+++ b/zephyr/program/nissa/joxer/src/led.c
@@ -0,0 +1,181 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Battery LED control for nissa
+ */
+#include "charge_manager.h"
+#include "common.h"
+#include "compile_time_macros.h"
+#include "ec_commands.h"
+#include "gpio.h"
+#include "led_common.h"
+#include "led_onoff_states.h"
+#include "pwm.h"
+#include "util.h"
+
+#include <stdint.h>
+
+#define BAT_LED_ON_LVL 0
+#define BAT_LED_OFF_LVL 1
+
+#define PWR_LED_ON_LVL 1
+#define PWR_LED_OFF_LVL 0
+
+#define LED_SIDESEL_MB_PORT 0
+#define LED_SIDESEL_DB_PORT 1
+
+__override const int led_charge_lvl_1 = 5;
+__override const int led_charge_lvl_2 = 95;
+
+__override struct led_descriptor
+ led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = {
+ [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER,
+ LED_INDEFINITE } },
+ [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER,
+ LED_INDEFINITE } },
+ [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_WHITE,
+ LED_INDEFINITE } },
+ [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER,
+ 1 * LED_ONE_SEC },
+ { LED_OFF, 1 * LED_ONE_SEC } },
+ [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER,
+ 0.5 * LED_ONE_SEC },
+ { LED_OFF, 0.5 * LED_ONE_SEC } },
+ [STATE_FACTORY_TEST] = { { EC_LED_COLOR_WHITE,
+ 1 * LED_ONE_SEC },
+ { LED_OFF, 1 * LED_ONE_SEC } },
+ };
+
+__override const struct led_descriptor
+ led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = {
+ [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } },
+ [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE,
+ 1 * LED_ONE_SEC },
+ { LED_OFF, 1 * LED_ONE_SEC } },
+ [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE,
+ 1 * LED_ONE_SEC },
+ { LED_OFF,
+ 1 * LED_ONE_SEC } },
+ [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } },
+ };
+
+const enum ec_led_id supported_led_ids[] = {
+ EC_LED_ID_BATTERY_LED,
+ EC_LED_ID_POWER_LED,
+};
+
+const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
+
+__override void led_set_color_battery(enum ec_led_colors color)
+{
+ int port;
+
+ /* There are four battery leds, LED1/LED2 are on MB side and
+ * LED3/LED4 are on DB side. All leds are OFF by default.
+ */
+ int led1, led2, led3, led4;
+
+ led1 = led2 = led3 = led4 = BAT_LED_OFF_LVL;
+
+ /* Check which port is the charging port,
+ * and turn on the corresponding led.
+ */
+ if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) {
+ port = charge_manager_get_active_charge_port();
+ switch (port) {
+ case LED_SIDESEL_MB_PORT:
+ switch (color) {
+ case EC_LED_COLOR_AMBER:
+ led1 = BAT_LED_ON_LVL;
+ break;
+ case EC_LED_COLOR_WHITE:
+ led2 = BAT_LED_ON_LVL;
+ break;
+ default: /* LED_OFF and other unsupported colors */
+ break;
+ }
+ break;
+ case LED_SIDESEL_DB_PORT:
+ switch (color) {
+ case EC_LED_COLOR_AMBER:
+ led3 = BAT_LED_ON_LVL;
+ break;
+ case EC_LED_COLOR_WHITE:
+ led4 = BAT_LED_ON_LVL;
+ break;
+ default: /* LED_OFF and other unsupported colors */
+ break;
+ }
+ break;
+ default: /* Unknown charging port */
+ break;
+ }
+ } else {
+ switch (color) {
+ case EC_LED_COLOR_AMBER:
+ led1 = BAT_LED_ON_LVL;
+ led3 = BAT_LED_ON_LVL;
+ break;
+ case EC_LED_COLOR_WHITE:
+ led2 = BAT_LED_ON_LVL;
+ led4 = BAT_LED_ON_LVL;
+ break;
+ default: /* LED_OFF and other unsupported colors */
+ break;
+ }
+ }
+
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), led1);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), led2);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_3_l), led3);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_4_l), led4);
+}
+
+__override void led_set_color_power(enum ec_led_colors color)
+{
+ if (color == EC_LED_COLOR_WHITE)
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led_gate),
+ PWR_LED_ON_LVL);
+ else
+ /* LED_OFF and unsupported colors */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led_gate),
+ PWR_LED_OFF_LVL);
+}
+
+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;
+ } else if (led_id == EC_LED_ID_POWER_LED) {
+ 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) {
+ led_auto_control(led_id, 0);
+ if (brightness[EC_LED_COLOR_AMBER] != 0)
+ led_set_color_battery(EC_LED_COLOR_AMBER);
+ else if (brightness[EC_LED_COLOR_WHITE] != 0)
+ led_set_color_battery(EC_LED_COLOR_WHITE);
+ else if (brightness[LED_OFF] != 0)
+ led_set_color_battery(LED_OFF);
+ else {
+ led_auto_control(led_id, 1);
+ led_set_color_battery(LED_OFF);
+ }
+ } else if (led_id == EC_LED_ID_POWER_LED) {
+ if (brightness[EC_LED_COLOR_WHITE] != 0)
+ led_set_color_power(EC_LED_COLOR_WHITE);
+ else
+ led_set_color_power(LED_OFF);
+ }
+
+ return EC_SUCCESS;
+}
diff --git a/zephyr/program/nissa/joxer/src/usbc.c b/zephyr/program/nissa/joxer/src/usbc.c
new file mode 100644
index 0000000000..8e576c5673
--- /dev/null
+++ b/zephyr/program/nissa/joxer/src/usbc.c
@@ -0,0 +1,368 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_state_v2.h"
+#include "chipset.h"
+#include "driver/charger/sm5803.h"
+#include "driver/tcpm/it83xx_pd.h"
+#include "driver/tcpm/ps8xxx_public.h"
+#include "driver/tcpm/tcpci.h"
+#include "hooks.h"
+#include "nissa_common.h"
+#include "system.h"
+#include "usb_mux.h"
+
+#include <zephyr/logging/log.h>
+
+#include <ap_power/ap_power.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+/* Vconn control for integrated ITE TCPC */
+void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
+{
+ /* Vconn control is only for port 0 */
+ if (port)
+ return;
+
+ if (cc_pin == USBPD_CC_PIN_1)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc1_vconn),
+ !!enabled);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc2_vconn),
+ !!enabled);
+}
+
+__override bool pd_check_vbus_level(int port, enum vbus_level level)
+{
+ return sm5803_check_vbus_level(port, level);
+}
+
+/*
+ * Putting chargers into LPM when in suspend reduces power draw by about 8mW
+ * per charger, but also seems critical to correct operation in source mode:
+ * if chargers are not in LPM when a sink is first connected, VBUS sourcing
+ * works even if the partner is later removed (causing LPM entry) and
+ * reconnected (causing LPM exit). If in LPM initially, sourcing VBUS
+ * consistently causes the charger to report (apparently spurious) overcurrent
+ * failures.
+ *
+ * In short, this is important to making things work correctly but we don't
+ * understand why.
+ */
+static void board_chargers_suspend(struct ap_power_ev_callback *const cb,
+ const struct ap_power_ev_data data)
+{
+ void (*fn)(int chgnum);
+
+ switch (data.event) {
+ case AP_POWER_SUSPEND:
+ fn = sm5803_enable_low_power_mode;
+ break;
+ case AP_POWER_RESUME:
+ fn = sm5803_disable_low_power_mode;
+ break;
+ default:
+ LOG_WRN("%s: power event %d is not recognized", __func__,
+ data.event);
+ return;
+ }
+
+ fn(CHARGER_PRIMARY);
+ if (board_get_charger_chip_count() > 1)
+ fn(CHARGER_SECONDARY);
+}
+
+static int board_chargers_suspend_init(const struct device *unused)
+{
+ static struct ap_power_ev_callback cb = {
+ .handler = board_chargers_suspend,
+ .events = AP_POWER_SUSPEND | AP_POWER_RESUME,
+ };
+ ap_power_ev_add_callback(&cb);
+ return 0;
+}
+SYS_INIT(board_chargers_suspend_init, APPLICATION, 0);
+
+int board_set_active_charge_port(int port)
+{
+ int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count());
+ int i;
+ int old_port;
+ int rv;
+
+ if (!is_real_port && port != CHARGE_PORT_NONE)
+ return EC_ERROR_INVAL;
+
+ old_port = charge_manager_get_active_charge_port();
+ LOG_INF("Charge update: p%d -> p%d", old_port, port);
+
+ /* Check if port is sourcing VBUS. */
+ if (port != CHARGE_PORT_NONE && charger_is_sourcing_otg_power(port)) {
+ LOG_WRN("Skip enable p%d: already sourcing", port);
+ return EC_ERROR_INVAL;
+ }
+
+ /* Disable sinking on all ports except the desired one */
+ for (i = 0; i < board_get_usb_pd_port_count(); i++) {
+ if (i == port)
+ continue;
+
+ if (sm5803_vbus_sink_enable(i, 0))
+ /*
+ * Do not early-return because this can fail during
+ * power-on which would put us into a loop.
+ */
+ LOG_WRN("p%d: sink path disable failed.", i);
+ }
+
+ /* Don't enable anything (stop here) if no ports were requested */
+ if ((port == CHARGE_PORT_NONE) || (old_port == port))
+ return EC_SUCCESS;
+
+ /*
+ * Stop the charger IC from switching while changing ports. Otherwise,
+ * we can overcurrent the adapter we're switching to. (crbug.com/926056)
+ */
+ if (old_port != CHARGE_PORT_NONE)
+ charger_discharge_on_ac(1);
+
+ /* Enable requested charge port. */
+ rv = sm5803_vbus_sink_enable(port, 1);
+ if (rv)
+ LOG_WRN("p%d: sink path enable failed: code %d", port, rv);
+
+ /* Allow the charger IC to begin/continue switching. */
+ charger_discharge_on_ac(0);
+
+ return rv;
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ /*
+ * TCPC 0 is embedded in the EC and processes interrupts in the chip
+ * code (it83xx/intc.c). This function only needs to poll port C1 if
+ * present.
+ */
+ uint16_t status = 0;
+ int regval;
+
+ /* Is the C1 port present and its IRQ line asserted? */
+ if (board_get_usb_pd_port_count() == 2 &&
+ !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ /*
+ * C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if
+ * it asserted the IRQ.
+ */
+ if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
+ if (regval)
+ status = PD_STATUS_TCPC_ALERT_1;
+ }
+ }
+
+ return status;
+}
+
+void pd_power_supply_reset(int port)
+{
+ int prev_en;
+
+ if (port < 0 || port >= board_get_usb_pd_port_count())
+ return;
+
+ prev_en = charger_is_sourcing_otg_power(port);
+
+ /* Disable Vbus */
+ charger_enable_otg_power(port, 0);
+
+ /* Discharge Vbus if previously enabled */
+ if (prev_en)
+ sm5803_set_vbus_disch(port, 1);
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ enum ec_error_list rv;
+
+ if (port < 0 || port > board_get_usb_pd_port_count()) {
+ LOG_WRN("Port C%d does not exist, cannot enable VBUS", port);
+ return EC_ERROR_INVAL;
+ }
+
+ /* Disable sinking */
+ rv = sm5803_vbus_sink_enable(port, 0);
+ if (rv) {
+ LOG_WRN("C%d failed to disable sinking: %d", port, rv);
+ return rv;
+ }
+
+ /* Disable Vbus discharge */
+ rv = sm5803_set_vbus_disch(port, 0);
+ if (rv) {
+ LOG_WRN("C%d failed to clear VBUS discharge: %d", port, rv);
+ return rv;
+ }
+
+ /* Provide Vbus */
+ rv = charger_enable_otg_power(port, 1);
+ if (rv) {
+ LOG_WRN("C%d failed to enable VBUS sourcing: %d", port, rv);
+ return rv;
+ }
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
+}
+
+__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ int rv;
+ const int current = rp == TYPEC_RP_3A0 ? 3000 : 1500;
+
+ rv = charger_set_otg_current_voltage(port, current, 5000);
+ if (rv != EC_SUCCESS) {
+ LOG_WRN("Failed to set source ilimit on port %d to %d: %d",
+ port, current, rv);
+ }
+}
+
+void board_reset_pd_mcu(void)
+{
+ /*
+ * Do nothing. The integrated TCPC for C0 lacks a dedicated reset
+ * command, and C1 (if present) doesn't have a reset pin connected
+ * to the EC.
+ */
+}
+
+#define INT_RECHECK_US 5000
+
+/* C0 interrupt line shared by BC 1.2 and charger */
+
+static void check_c0_line(void);
+DECLARE_DEFERRED(check_c0_line);
+
+static void notify_c0_chips(void)
+{
+ usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
+ sm5803_interrupt(0);
+}
+
+static void check_c0_line(void)
+{
+ /*
+ * If line is still being held low, see if there's more to process from
+ * one of the chips
+ */
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
+ notify_c0_chips();
+ hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
+ }
+}
+
+void usb_c0_interrupt(enum gpio_signal s)
+{
+ /* Cancel any previous calls to check the interrupt line */
+ hook_call_deferred(&check_c0_line_data, -1);
+
+ /* Notify all chips using this line that an interrupt came in */
+ notify_c0_chips();
+
+ /* Check the line again in 5ms */
+ hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
+}
+
+/* C1 interrupt line shared by BC 1.2, TCPC, and charger */
+static void check_c1_line(void);
+DECLARE_DEFERRED(check_c1_line);
+
+static void notify_c1_chips(void)
+{
+ schedule_deferred_pd_interrupt(1);
+ usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
+ /* Charger is handled in board_process_pd_alert */
+}
+
+static void check_c1_line(void)
+{
+ /*
+ * If line is still being held low, see if there's more to process from
+ * one of the chips.
+ */
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ notify_c1_chips();
+ hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
+ }
+}
+
+void usb_c1_interrupt(enum gpio_signal s)
+{
+ /* Cancel any previous calls to check the interrupt line */
+ hook_call_deferred(&check_c1_line_data, -1);
+
+ /* Notify all chips using this line that an interrupt came in */
+ notify_c1_chips();
+
+ /* Check the line again in 5ms */
+ hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
+}
+
+/*
+ * Check state of IRQ lines at startup, ensuring an IRQ that happened before
+ * the EC started up won't get lost (leaving the IRQ line asserted and blocking
+ * any further interrupts on the port).
+ *
+ * Although the PD task will check for pending TCPC interrupts on startup,
+ * the charger sharing the IRQ will not be polled automatically.
+ */
+void board_handle_initial_typec_irq(void)
+{
+ check_c0_line();
+ check_c1_line();
+}
+/*
+ * This must run after sub-board detection (which happens in EC main()),
+ * but isn't depended on by anything else either.
+ */
+DECLARE_HOOK(HOOK_INIT, board_handle_initial_typec_irq, HOOK_PRIO_LAST);
+
+/*
+ * Handle charger interrupts in the PD task. Not doing so can lead to a priority
+ * inversion where we fail to respond to TCPC alerts quickly enough because we
+ * don't get another edge on a shared IRQ until the charger interrupt is cleared
+ * (or the IRQ is polled again), which happens in the low-priority charger task:
+ * the high-priority type-C handler is thus blocked on the lower-priority
+ * charger.
+ *
+ * To avoid that, we run charger interrupts at the same priority.
+ */
+void board_process_pd_alert(int port)
+{
+ /*
+ * Port 0 doesn't use an external TCPC, so its interrupts don't need
+ * this special handling.
+ */
+ if (port == 1 &&
+ !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ sm5803_handle_interrupt(port);
+ }
+}
+
+int pd_snk_is_vbus_provided(int port)
+{
+ int chg_det = 0;
+
+ sm5803_get_chg_det(port, &chg_det);
+
+ return chg_det;
+}
diff --git a/zephyr/projects/nissa/nereid/generated.dtsi b/zephyr/program/nissa/nereid/generated.dtsi
index bca58c478e..bca58c478e 100644
--- a/zephyr/projects/nissa/nereid/generated.dtsi
+++ b/zephyr/program/nissa/nereid/generated.dtsi
diff --git a/zephyr/projects/nissa/nereid/keyboard.dtsi b/zephyr/program/nissa/nereid/keyboard.dtsi
index 04a620767a..04a620767a 100644
--- a/zephyr/projects/nissa/nereid/keyboard.dtsi
+++ b/zephyr/program/nissa/nereid/keyboard.dtsi
diff --git a/zephyr/projects/nissa/nereid/motionsense.dtsi b/zephyr/program/nissa/nereid/motionsense.dtsi
index a65bb48fbd..a65bb48fbd 100644
--- a/zephyr/projects/nissa/nereid/motionsense.dtsi
+++ b/zephyr/program/nissa/nereid/motionsense.dtsi
diff --git a/zephyr/projects/nissa/nereid/nereid_vif.xml b/zephyr/program/nissa/nereid/nereid_vif.xml
index 91c8dbe68b..91c8dbe68b 100644
--- a/zephyr/projects/nissa/nereid/nereid_vif.xml
+++ b/zephyr/program/nissa/nereid/nereid_vif.xml
diff --git a/zephyr/program/nissa/nereid/overlay.dtsi b/zephyr/program/nissa/nereid/overlay.dtsi
new file mode 100644
index 0000000000..36d30a0fce
--- /dev/null
+++ b/zephyr/program/nissa/nereid/overlay.dtsi
@@ -0,0 +1,409 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * 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>
+#include <dt-bindings/usb_pd_tcpm.h>
+
+/ {
+ aliases {
+ gpio-cbi-wp = &gpio_ec_cbi_wp;
+ gpio-wp = &gpio_ec_wp_odl;
+ int-wp = &int_wp_l;
+ /*
+ * USB-C: interrupt input.
+ * I2C pins are on i2c_ec_i2c_sub_usb_c1
+ */
+ gpio-usb-c1-int-odl = &gpio_sb_1;
+ /*
+ * USB-A: VBUS enable output
+ * LTE: power enable output
+ */
+ gpio-en-usb-a1-vbus = &gpio_sb_2;
+ /*
+ * HDMI: power enable output, HDMI enable output,
+ * and HPD input
+ */
+ gpio-en-rails-odl = &gpio_sb_1;
+ gpio-hdmi-en-odl = &gpio_sb_4;
+ gpio-hpd-odl = &gpio_sb_3;
+ /*
+ * Enable S5 rails for LTE sub-board
+ */
+ gpio-en-sub-s5-rails = &gpio_sb_2;
+ };
+
+
+ ec-console {
+ compatible = "ec-console";
+ disabled = "events", "lpc", "hostcmd";
+ };
+
+ batteries {
+ default_battery: smp {
+ compatible = "smp,l20m3pg0", "battery-smart";
+ };
+ };
+
+ hibernate-wake-pins {
+ compatible = "cros-ec,hibernate-wake-pins";
+ wakeup-irqs = <
+ &int_power_button
+ &int_lid_open
+ >;
+ };
+
+ gpio-interrupts {
+ compatible = "cros-ec,gpio-interrupts";
+
+ int_power_button: power_button {
+ irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "power_button_interrupt";
+ };
+ int_vol_down: vol_down {
+ irq-pin = <&gpio_voldn_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_vol_up: vol_up {
+ irq-pin = <&gpio_volup_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_wp_l: wp_l {
+ irq-pin = <&gpio_ec_wp_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "switch_interrupt";
+ };
+ int_lid_open: lid_open {
+ irq-pin = <&gpio_lid_open>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "lid_interrupt";
+ };
+ int_tablet_mode: tablet_mode {
+ irq-pin = <&gpio_tablet_mode_l>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "gmr_tablet_switch_isr";
+ };
+ int_imu: ec_imu {
+ irq-pin = <&gpio_imu_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "bmi3xx_interrupt";
+ };
+ int_lid_imu: lid_imu {
+ irq-pin = <&gpio_acc_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "bma4xx_interrupt";
+ };
+ int_usb_c0: usb_c0 {
+ irq-pin = <&gpio_usb_c0_int_odl>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_c0_interrupt";
+ };
+ int_usb_c1: usb_c1 {
+ irq-pin = <&gpio_sb_1>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_c1_interrupt";
+ };
+ };
+
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios = <&gpioc 3 0>,
+ <&gpiod 4 0>,
+ <&gpiod 7 0>,
+ <&gpioh 2 0>,
+ <&gpioj 7 0>,
+ <&gpiol 4 0>;
+ };
+
+ named-gpios {
+ /*
+ * EC doesn't take any specific action on CC/SBU disconnect due to
+ * fault, but this definition is useful for hardware testing.
+ */
+ gpio_usb_c0_prot_fault_odl: usb_c0_prot_fault_odl {
+ gpios = <&gpiok 6 GPIO_INPUT_PULL_UP>;
+ };
+
+ gpio_sb_1: sb_1 {
+ gpios = <&gpioe 6 0>;
+ no-auto-init;
+ };
+ gpio_sb_2: sb_2 {
+ gpios = <&gpiof 0 0>;
+ no-auto-init;
+ };
+
+ gpio_sb_3: sb_3 {
+ gpios = <&gpioe 7 0>;
+ no-auto-init;
+ };
+ gpio_sb_4: sb_4 {
+ gpios = <&gpioe 0 0>;
+ no-auto-init;
+ };
+ };
+
+ temp_memory: memory {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_1>;
+ };
+ temp_charger: charger {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_2>;
+ };
+ temp_ambient: ambient {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_3>;
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ memory {
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_memory>;
+ };
+ charger {
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_charger>;
+ };
+ ambient {
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_ambient>;
+ };
+ };
+
+ usba {
+ compatible = "cros-ec,usba-port-enable-pins";
+ /*
+ * sb_2 is only configured as GPIO when USB-A1 is present,
+ * but it's still safe to control when disabled.
+ *
+ * ILIM_SEL pins are referred to by legacy enum name,
+ * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
+ * sub-boards that don't have USB-A so is safe to control
+ * regardless of system configuration.
+ */
+ enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
+ status = "okay";
+ };
+
+ usbc {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port0@0 {
+ compatible = "named-usbc-port";
+ reg = <0>;
+ bc12 = <&bc12_port0>;
+ chg = <&chg_port0>;
+ tcpc = <&usbpd0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_0>;
+ };
+ };
+ port0-muxes {
+ virtual_mux_0: virtual-mux-0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ port1@1 {
+ compatible = "named-usbc-port";
+ reg = <1>;
+ bc12 = <&bc12_port1>;
+ chg = <&chg_port1>;
+ tcpc = <&tcpc_port1>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_1 &tcpci_mux_1>;
+ };
+ usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux {
+ compatible = "cros-ec,usb-mux-chain";
+ alternative-chain;
+ usb-muxes = <&virtual_mux_1>;
+ };
+ };
+ port1-muxes {
+ virtual_mux_1: virtual-mux-1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ tcpci_mux_1: tcpci-mux-1 {
+ compatible = "parade,usbc-mux-ps8xxx";
+ };
+ };
+ };
+};
+
+&gpio_acc_int_l {
+ gpios = <&gpioc 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+};
+&gpio_imu_int_l {
+ gpios = <&gpioj 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+};
+&gpio_vccin_aux_vid0 {
+ gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+};
+&gpio_vccin_aux_vid1 {
+ gpios = <&gpiok 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+};
+
+&gpio_ec_prochot_odl {
+ gpios = <&gpioi 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>;
+};
+
+&thermistor_3V3_51K1_47K_4050B {
+ status = "okay";
+};
+
+&adc_ec_vsense_pp3300_s5 {
+ /*
+ * Voltage divider on input has 47k upper and 220k lower legs with 3 V
+ * full-scale reading on the ADC. Apply the largest possible multiplier
+ * (without overflowing int32) to get the best possible approximation
+ * of the actual ratio, but derate by a factor of two to ensure
+ * unexpectedly high values won't overflow.
+ */
+ mul = <(715828 / 2)>;
+ div = <(589820 / 2)>;
+};
+
+&adc0 {
+ pinctrl-0 = <&adc0_ch0_gpi0_default
+ &adc0_ch2_gpi2_default
+ &adc0_ch3_gpi3_default
+ &adc0_ch13_gpl0_default
+ &adc0_ch14_gpl1_default>;
+ pinctrl-names = "default";
+};
+
+&pinctrl {
+ i2c4_clk_gpe0_sleep: i2c4_clk_gpe0_sleep {
+ pinmuxs = <&pinctrle 0 IT8XXX2_ALT_DEFAULT>;
+ };
+ i2c4_data_gpe7_sleep: i2c4_data_gpe7_sleep {
+ pinmuxs = <&pinctrle 7 IT8XXX2_ALT_DEFAULT>;
+ };
+ i2c2_clk_gpf6_default: i2c2_clk_gpf6_default {
+ gpio-voltage = "1v8";
+ };
+ i2c2_data_gpf7_default: i2c2_data_gpf7_default {
+ gpio-voltage = "1v8";
+ };
+};
+
+&i2c0 {
+ label = "I2C_EEPROM";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+ pinctrl-0 = <&i2c0_clk_gpb3_default
+ &i2c0_data_gpb4_default>;
+ pinctrl-names = "default";
+};
+
+&i2c1 {
+ label = "I2C_BATTERY";
+ clock-frequency = <50000>;
+ pinctrl-0 = <&i2c1_clk_gpc1_default
+ &i2c1_data_gpc2_default>;
+ pinctrl-names = "default";
+};
+
+&i2c2 {
+ label = "I2C_SENSOR";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c2_clk_gpf6_default
+ &i2c2_data_gpf7_default>;
+ pinctrl-names = "default";
+};
+
+&i2c4 {
+ label = "I2C_SUB_C1_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+ pinctrl-0 = <&i2c4_clk_gpe0_default
+ &i2c4_data_gpe7_default>;
+ pinctrl-1 = <&i2c4_clk_gpe0_sleep
+ &i2c4_data_gpe7_sleep>;
+ pinctrl-names = "default", "sleep";
+
+ bc12_port1: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ };
+
+ chg_port1: sm5803@32 {
+ compatible = "siliconmitus,sm5803";
+ status = "okay";
+ reg = <0x32>;
+ };
+
+ tcpc_port1: ps8745@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
+};
+
+&i2c_ec_i2c_sub_usb_c1 {
+ /*
+ * Dynamic speed setting is used for AP-controlled firmware update
+ * of PS8745 TCPC/redriver: the AP lowers speed to 400 kHz in order
+ * to use more efficient window programming, then sets it back when
+ * done.
+ */
+ dynamic-speed;
+};
+
+&i2c5 {
+ label = "I2C_USB_C0_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+ pinctrl-0 = <&i2c5_clk_gpa4_default
+ &i2c5_data_gpa5_default>;
+ pinctrl-names = "default";
+
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ };
+
+ chg_port0: sm5803@32 {
+ compatible = "siliconmitus,sm5803";
+ status = "okay";
+ reg = <0x32>;
+ };
+};
+
+&usbpd0 {
+ status = "okay";
+};
diff --git a/zephyr/projects/nissa/nereid/power_signals.dtsi b/zephyr/program/nissa/nereid/power_signals.dtsi
index 8affae03b1..8affae03b1 100644
--- a/zephyr/projects/nissa/nereid/power_signals.dtsi
+++ b/zephyr/program/nissa/nereid/power_signals.dtsi
diff --git a/zephyr/projects/nissa/nereid/project.conf b/zephyr/program/nissa/nereid/project.conf
index 75a5faba5d..75a5faba5d 100644
--- a/zephyr/projects/nissa/nereid/project.conf
+++ b/zephyr/program/nissa/nereid/project.conf
diff --git a/zephyr/projects/nissa/nereid/project.overlay b/zephyr/program/nissa/nereid/project.overlay
index 0aceac1c47..0aceac1c47 100644
--- a/zephyr/projects/nissa/nereid/project.overlay
+++ b/zephyr/program/nissa/nereid/project.overlay
diff --git a/zephyr/projects/nissa/nereid/pwm_leds.dtsi b/zephyr/program/nissa/nereid/pwm_leds.dtsi
index aa4a76b271..aa4a76b271 100644
--- a/zephyr/projects/nissa/nereid/pwm_leds.dtsi
+++ b/zephyr/program/nissa/nereid/pwm_leds.dtsi
diff --git a/zephyr/program/nissa/nereid/src/charger.c b/zephyr/program/nissa/nereid/src/charger.c
new file mode 100644
index 0000000000..dc4eda9291
--- /dev/null
+++ b/zephyr/program/nissa/nereid/src/charger.c
@@ -0,0 +1,56 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "charger.h"
+#include "console.h"
+#include "driver/charger/sm5803.h"
+#include "extpower.h"
+#include "nissa_common.h"
+#include "usb_pd.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+int extpower_is_present(void)
+{
+ int port;
+ int rv;
+ bool acok;
+
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
+ rv = sm5803_is_acok(port, &acok);
+ if ((rv == EC_SUCCESS) && acok)
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ * Nereid does not have a GPIO indicating whether extpower is present,
+ * so detect using the charger(s).
+ */
+__override void board_check_extpower(void)
+{
+ static int last_extpower_present;
+ int extpower_present = extpower_is_present();
+
+ if (last_extpower_present ^ extpower_present)
+ extpower_handle_update(extpower_present);
+
+ last_extpower_present = extpower_present;
+}
+
+__override void board_hibernate(void)
+{
+ /* Shut down the chargers */
+ if (board_get_usb_pd_port_count() == 2)
+ sm5803_hibernate(CHARGER_SECONDARY);
+ sm5803_hibernate(CHARGER_PRIMARY);
+ LOG_INF("Charger(s) hibernated");
+ cflush();
+}
diff --git a/zephyr/program/nissa/nereid/src/hdmi.c b/zephyr/program/nissa/nereid/src/hdmi.c
new file mode 100644
index 0000000000..5025472c6d
--- /dev/null
+++ b/zephyr/program/nissa/nereid/src/hdmi.c
@@ -0,0 +1,29 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "nissa_hdmi.h"
+
+#include <cros_board_info.h>
+
+__override void nissa_configure_hdmi_power_gpios(void)
+{
+ /*
+ * Nereid versions before 2 need hdmi-en-odl to be
+ * pulled down to enable VCC on the HDMI port, but later
+ * versions (and other boards) disconnect this so
+ * the port's VCC directly follows en-rails-odl. Only
+ * configure the GPIO if needed, to save power.
+ */
+ uint32_t board_version = 0;
+
+ /* CBI errors ignored, will configure the pin */
+ cbi_get_board_version(&board_version);
+ if (board_version < 2) {
+ nissa_configure_hdmi_vcc();
+ }
+
+ /* Still always need core rails controlled */
+ nissa_configure_hdmi_rails();
+}
diff --git a/zephyr/projects/nissa/nereid/src/keyboard.c b/zephyr/program/nissa/nereid/src/keyboard.c
index b69bb4da33..b69bb4da33 100644
--- a/zephyr/projects/nissa/nereid/src/keyboard.c
+++ b/zephyr/program/nissa/nereid/src/keyboard.c
diff --git a/zephyr/program/nissa/nereid/src/usbc.c b/zephyr/program/nissa/nereid/src/usbc.c
new file mode 100644
index 0000000000..1e87abfa0d
--- /dev/null
+++ b/zephyr/program/nissa/nereid/src/usbc.c
@@ -0,0 +1,369 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_state_v2.h"
+#include "chipset.h"
+#include "driver/charger/sm5803.h"
+#include "driver/tcpm/it83xx_pd.h"
+#include "driver/tcpm/ps8xxx_public.h"
+#include "driver/tcpm/tcpci.h"
+#include "hooks.h"
+#include "nissa_common.h"
+#include "system.h"
+#include "usb_mux.h"
+
+#include <zephyr/logging/log.h>
+
+#include <ap_power/ap_power.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+/* Vconn control for integrated ITE TCPC */
+void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
+{
+ /* Vconn control is only for port 0 */
+ if (port)
+ return;
+
+ if (cc_pin == USBPD_CC_PIN_1)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc1_vconn),
+ !!enabled);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc2_vconn),
+ !!enabled);
+}
+
+__override bool pd_check_vbus_level(int port, enum vbus_level level)
+{
+ return sm5803_check_vbus_level(port, level);
+}
+
+/*
+ * Putting chargers into LPM when in suspend reduces power draw by about 8mW
+ * per charger, but also seems critical to correct operation in source mode:
+ * if chargers are not in LPM when a sink is first connected, VBUS sourcing
+ * works even if the partner is later removed (causing LPM entry) and
+ * reconnected (causing LPM exit). If in LPM initially, sourcing VBUS
+ * consistently causes the charger to report (apparently spurious) overcurrent
+ * failures.
+ *
+ * In short, this is important to making things work correctly but we don't
+ * understand why.
+ */
+static void board_chargers_suspend(struct ap_power_ev_callback *const cb,
+ const struct ap_power_ev_data data)
+{
+ void (*fn)(int chgnum);
+
+ switch (data.event) {
+ case AP_POWER_SUSPEND:
+ fn = sm5803_enable_low_power_mode;
+ break;
+ case AP_POWER_RESUME:
+ fn = sm5803_disable_low_power_mode;
+ break;
+ default:
+ LOG_WRN("%s: power event %d is not recognized", __func__,
+ data.event);
+ return;
+ }
+
+ fn(CHARGER_PRIMARY);
+ if (board_get_charger_chip_count() > 1)
+ fn(CHARGER_SECONDARY);
+}
+
+static int board_chargers_suspend_init(const struct device *unused)
+{
+ static struct ap_power_ev_callback cb = {
+ .handler = board_chargers_suspend,
+ .events = AP_POWER_SUSPEND | AP_POWER_RESUME,
+ };
+ ap_power_ev_add_callback(&cb);
+ return 0;
+}
+SYS_INIT(board_chargers_suspend_init, APPLICATION, 0);
+
+int board_set_active_charge_port(int port)
+{
+ int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count());
+ int i;
+ int old_port;
+ int rv;
+
+ if (!is_real_port && port != CHARGE_PORT_NONE)
+ return EC_ERROR_INVAL;
+
+ old_port = charge_manager_get_active_charge_port();
+ LOG_INF("Charge update: p%d -> p%d", old_port, port);
+
+ /* Check if port is sourcing VBUS. */
+ if (port != CHARGE_PORT_NONE && charger_is_sourcing_otg_power(port)) {
+ LOG_WRN("Skip enable p%d: already sourcing", port);
+ return EC_ERROR_INVAL;
+ }
+
+ /* Disable sinking on all ports except the desired one */
+ for (i = 0; i < board_get_usb_pd_port_count(); i++) {
+ if (i == port)
+ continue;
+
+ if (sm5803_vbus_sink_enable(i, 0))
+ /*
+ * Do not early-return because this can fail during
+ * power-on which would put us into a loop.
+ */
+ LOG_WRN("p%d: sink path disable failed.", i);
+ }
+
+ /* Don't enable anything (stop here) if no ports were requested */
+ if ((port == CHARGE_PORT_NONE) || (old_port == port))
+ return EC_SUCCESS;
+
+ /*
+ * Stop the charger IC from switching while changing ports. Otherwise,
+ * we can overcurrent the adapter we're switching to. (crbug.com/926056)
+ */
+ if (old_port != CHARGE_PORT_NONE)
+ charger_discharge_on_ac(1);
+
+ /* Enable requested charge port. */
+ rv = sm5803_vbus_sink_enable(port, 1);
+ if (rv)
+ LOG_WRN("p%d: sink path enable failed: code %d", port, rv);
+
+ /* Allow the charger IC to begin/continue switching. */
+ charger_discharge_on_ac(0);
+
+ return rv;
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ /*
+ * TCPC 0 is embedded in the EC and processes interrupts in the chip
+ * code (it83xx/intc.c). This function only needs to poll port C1 if
+ * present.
+ */
+ uint16_t status = 0;
+ int regval;
+
+ /* Is the C1 port present and its IRQ line asserted? */
+ if (board_get_usb_pd_port_count() == 2 &&
+ !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ /*
+ * C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if
+ * it asserted the IRQ.
+ */
+ if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
+ if (regval)
+ status = PD_STATUS_TCPC_ALERT_1;
+ }
+ }
+
+ return status;
+}
+
+void pd_power_supply_reset(int port)
+{
+ int prev_en;
+
+ if (port < 0 || port >= board_get_usb_pd_port_count())
+ return;
+
+ prev_en = charger_is_sourcing_otg_power(port);
+
+ /* Disable Vbus */
+ charger_enable_otg_power(port, 0);
+
+ /* Discharge Vbus if previously enabled */
+ if (prev_en)
+ sm5803_set_vbus_disch(port, 1);
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ enum ec_error_list rv;
+
+ if (port < 0 || port > board_get_usb_pd_port_count()) {
+ LOG_WRN("Port C%d does not exist, cannot enable VBUS", port);
+ return EC_ERROR_INVAL;
+ }
+
+ /* Disable sinking */
+ rv = sm5803_vbus_sink_enable(port, 0);
+ if (rv) {
+ LOG_WRN("C%d failed to disable sinking: %d", port, rv);
+ return rv;
+ }
+
+ /* Disable Vbus discharge */
+ rv = sm5803_set_vbus_disch(port, 0);
+ if (rv) {
+ LOG_WRN("C%d failed to clear VBUS discharge: %d", port, rv);
+ return rv;
+ }
+
+ /* Provide Vbus */
+ rv = charger_enable_otg_power(port, 1);
+ if (rv) {
+ LOG_WRN("C%d failed to enable VBUS sourcing: %d", port, rv);
+ return rv;
+ }
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
+}
+
+__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ int rv;
+ const int current = rp == TYPEC_RP_3A0 ? 3000 : 1500;
+
+ rv = charger_set_otg_current_voltage(port, current, 5000);
+ if (rv != EC_SUCCESS) {
+ LOG_WRN("Failed to set source ilimit on port %d to %d: %d",
+ port, current, rv);
+ }
+}
+
+void board_reset_pd_mcu(void)
+{
+ /*
+ * Do nothing. The integrated TCPC for C0 lacks a dedicated reset
+ * command, and C1 (if present) doesn't have a reset pin connected
+ * to the EC.
+ */
+}
+
+#define INT_RECHECK_US 5000
+
+/* C0 interrupt line shared by BC 1.2 and charger */
+
+static void check_c0_line(void);
+DECLARE_DEFERRED(check_c0_line);
+
+static void notify_c0_chips(void)
+{
+ usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
+ sm5803_interrupt(0);
+}
+
+static void check_c0_line(void)
+{
+ /*
+ * If line is still being held low, see if there's more to process from
+ * one of the chips
+ */
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
+ notify_c0_chips();
+ hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
+ }
+}
+
+void usb_c0_interrupt(enum gpio_signal s)
+{
+ /* Cancel any previous calls to check the interrupt line */
+ hook_call_deferred(&check_c0_line_data, -1);
+
+ /* Notify all chips using this line that an interrupt came in */
+ notify_c0_chips();
+
+ /* Check the line again in 5ms */
+ hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
+}
+
+/* C1 interrupt line shared by BC 1.2, TCPC, and charger */
+static void check_c1_line(void);
+DECLARE_DEFERRED(check_c1_line);
+
+static void notify_c1_chips(void)
+{
+ schedule_deferred_pd_interrupt(1);
+ usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
+ /* Charger is handled in board_process_pd_alert */
+}
+
+static void check_c1_line(void)
+{
+ /*
+ * If line is still being held low, see if there's more to process from
+ * one of the chips.
+ */
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ notify_c1_chips();
+ hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
+ }
+}
+
+void usb_c1_interrupt(enum gpio_signal s)
+{
+ /* Cancel any previous calls to check the interrupt line */
+ hook_call_deferred(&check_c1_line_data, -1);
+
+ /* Notify all chips using this line that an interrupt came in */
+ notify_c1_chips();
+
+ /* Check the line again in 5ms */
+ hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
+}
+
+/*
+ * Check state of IRQ lines at startup, ensuring an IRQ that happened before
+ * the EC started up won't get lost (leaving the IRQ line asserted and blocking
+ * any further interrupts on the port).
+ *
+ * Although the PD task will check for pending TCPC interrupts on startup,
+ * the charger sharing the IRQ will not be polled automatically.
+ */
+void board_handle_initial_typec_irq(void)
+{
+ check_c0_line();
+ if (board_get_usb_pd_port_count() == 2)
+ check_c1_line();
+}
+/*
+ * This must run after sub-board detection (which happens in EC main()),
+ * but isn't depended on by anything else either.
+ */
+DECLARE_HOOK(HOOK_INIT, board_handle_initial_typec_irq, HOOK_PRIO_LAST);
+
+/*
+ * Handle charger interrupts in the PD task. Not doing so can lead to a priority
+ * inversion where we fail to respond to TCPC alerts quickly enough because we
+ * don't get another edge on a shared IRQ until the charger interrupt is cleared
+ * (or the IRQ is polled again), which happens in the low-priority charger task:
+ * the high-priority type-C handler is thus blocked on the lower-priority
+ * charger.
+ *
+ * To avoid that, we run charger interrupts at the same priority.
+ */
+void board_process_pd_alert(int port)
+{
+ /*
+ * Port 0 doesn't use an external TCPC, so its interrupts don't need
+ * this special handling.
+ */
+ if (port == 1 &&
+ !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ sm5803_handle_interrupt(port);
+ }
+}
+
+int pd_snk_is_vbus_provided(int port)
+{
+ int chg_det = 0;
+
+ sm5803_get_chg_det(port, &chg_det);
+
+ return chg_det;
+}
diff --git a/zephyr/projects/nissa/nissa.csv b/zephyr/program/nissa/nissa.csv
index 45b73ea229..45b73ea229 100644
--- a/zephyr/projects/nissa/nissa.csv
+++ b/zephyr/program/nissa/nissa.csv
diff --git a/zephyr/projects/nissa/nivviks/cbi.dtsi b/zephyr/program/nissa/nivviks/cbi.dtsi
index 112a2a885c..112a2a885c 100644
--- a/zephyr/projects/nissa/nivviks/cbi.dtsi
+++ b/zephyr/program/nissa/nivviks/cbi.dtsi
diff --git a/zephyr/projects/nissa/nivviks/generated.dtsi b/zephyr/program/nissa/nivviks/generated.dtsi
index 91718302b4..91718302b4 100644
--- a/zephyr/projects/nissa/nivviks/generated.dtsi
+++ b/zephyr/program/nissa/nivviks/generated.dtsi
diff --git a/zephyr/projects/nissa/nivviks/keyboard.dtsi b/zephyr/program/nissa/nivviks/keyboard.dtsi
index 00610e4e18..00610e4e18 100644
--- a/zephyr/projects/nissa/nivviks/keyboard.dtsi
+++ b/zephyr/program/nissa/nivviks/keyboard.dtsi
diff --git a/zephyr/projects/nissa/nivviks/motionsense.dtsi b/zephyr/program/nissa/nivviks/motionsense.dtsi
index 6297a07bf5..6297a07bf5 100644
--- a/zephyr/projects/nissa/nivviks/motionsense.dtsi
+++ b/zephyr/program/nissa/nivviks/motionsense.dtsi
diff --git a/zephyr/program/nissa/nivviks/overlay.dtsi b/zephyr/program/nissa/nivviks/overlay.dtsi
new file mode 100644
index 0000000000..c3a8d7a61d
--- /dev/null
+++ b/zephyr/program/nissa/nivviks/overlay.dtsi
@@ -0,0 +1,439 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * 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>
+#include <dt-bindings/usbc_mux.h>
+#include <dt-bindings/usb_pd_tcpm.h>
+
+/ {
+ aliases {
+ gpio-cbi-wp = &gpio_ec_cbi_wp;
+ gpio-wp = &gpio_ec_wp_odl;
+ int-wp = &int_wp_l;
+ gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ };
+
+ ec-console {
+ compatible = "ec-console";
+ disabled = "events", "lpc", "hostcmd";
+ };
+
+ batteries {
+ default_battery: lgc {
+ compatible = "lgc,ap18c8k", "battery-smart";
+ };
+ lgc_ap19b8m {
+ compatible = "lgc,ap19b8m", "battery-smart";
+ };
+ };
+
+ hibernate-wake-pins {
+ compatible = "cros-ec,hibernate-wake-pins";
+ wakeup-irqs = <
+ &int_power_button
+ &int_lid_open
+ >;
+ };
+
+ gpio-interrupts {
+ compatible = "cros-ec,gpio-interrupts";
+
+ int_power_button: power_button {
+ irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "power_button_interrupt";
+ };
+ int_wp_l: wp_l {
+ irq-pin = <&gpio_ec_wp_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "switch_interrupt";
+ };
+ int_lid_open: lid_open {
+ irq-pin = <&gpio_lid_open>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "lid_interrupt";
+ };
+ int_tablet_mode: tablet_mode {
+ irq-pin = <&gpio_tablet_mode_l>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "gmr_tablet_switch_isr";
+ };
+ int_imu: ec_imu {
+ irq-pin = <&gpio_imu_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "lsm6dso_interrupt";
+ };
+ int_vol_down: vol_down {
+ irq-pin = <&gpio_voldn_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_vol_up: vol_up {
+ irq-pin = <&gpio_volup_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_usb_c0: usb_c0 {
+ irq-pin = <&gpio_usb_c0_int_odl>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_interrupt";
+ };
+ int_usb_c1: usb_c1 {
+ irq-pin = <&gpio_sb_1>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_interrupt";
+ };
+ };
+
+ named-gpios {
+ gpio_sb_1: sb-1 {
+ gpios = <&gpio0 2 GPIO_PULL_UP>;
+ no-auto-init;
+ };
+
+ gpio_sb_2: sb-2 {
+ gpios = <&gpiod 4 GPIO_OUTPUT>;
+ no-auto-init;
+ };
+
+ /*
+ * 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.
+ */
+ gpio_sb_3: sb-3 {
+ gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>;
+ no-auto-init;
+ };
+ gpio_sb_4: sb-4 {
+ gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ no-auto-init;
+ };
+ gpio_fan_enable: fan-enable {
+ gpios = <&gpio6 3 GPIO_OUTPUT>;
+ no-auto-init;
+ };
+ ec-i2c-sensor-scl {
+ gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec-i2c-sensor-sda {
+ gpios = <&gpio8 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ };
+
+ /*
+ * Aliases used for sub-board GPIOs.
+ */
+ aliases {
+ /*
+ * Input GPIO when used with type-C port 1
+ * Output when used with HDMI sub-board
+ */
+ gpio-usb-c1-int-odl = &gpio_sb_1;
+ gpio-en-rails-odl = &gpio_sb_1;
+ /*
+ * Sub-board with type A USB, enable.
+ */
+ gpio-en-usb-a1-vbus = &gpio_sb_2;
+ /*
+ * HPD pins for HDMI sub-board.
+ */
+ gpio-hdmi-en-odl = &gpio_sb_3;
+ gpio-hpd-odl = &gpio_sb_4;
+ /*
+ * Enable S5 rails for LTE sub-board
+ */
+ gpio-en-sub-s5-rails = &gpio_sb_2;
+ };
+
+ temp_memory: memory {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_1>;
+ };
+ temp_charger: charger {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_2>;
+ };
+ temp_ambient: ambient {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_3>;
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ memory {
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_memory>;
+ };
+ charger {
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_charger>;
+ };
+ ambient {
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_ambient>;
+ };
+ };
+
+ usba {
+ compatible = "cros-ec,usba-port-enable-pins";
+ /*
+ * sb_2 is only configured as GPIO when USB-A1 is present,
+ * but it's still safe to control when disabled.
+ *
+ * ILIM_SEL pins are referred to by legacy enum name,
+ * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
+ * sub-boards that don't have USB-A so is safe to control
+ * regardless of system configuration.
+ */
+ enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
+ status = "okay";
+ };
+
+ usbc {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port0@0 {
+ compatible = "named-usbc-port";
+ reg = <0>;
+ bc12 = <&bc12_port0>;
+ chg = <&chg_port0>;
+ tcpc = <&tcpc_port0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_0>;
+ };
+ };
+ port0-muxes {
+ virtual_mux_0: virtual-mux-0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ /*
+ * TODO(b:211693800): port1 may not be present on some
+ * sub-boards.
+ */
+ port1@1 {
+ compatible = "named-usbc-port";
+ reg = <1>;
+ bc12 = <&bc12_port1>;
+ chg = <&chg_port1>;
+ tcpc = <&tcpc_port1>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_1 &anx7483_mux_1>;
+ };
+ usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux {
+ compatible = "cros-ec,usb-mux-chain";
+ alternative-chain;
+ usb-muxes = <&virtual_mux_1>;
+ };
+ };
+ port1-muxes {
+ virtual_mux_1: virtual-mux-1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ };
+
+ fans {
+ compatible = "cros-ec,fans";
+
+ fan_0 {
+ pwms = <&pwm5 5 PWM_KHZ(1) PWM_POLARITY_NORMAL>;
+ rpm_min = <2200>;
+ rpm_start = <2200>;
+ rpm_max = <4200>;
+ tach = <&tach2>;
+ enable_gpio = <&gpio_fan_enable>;
+ };
+ };
+
+ /*
+ * Declare unused GPIOs so that they are shut down
+ * and use minimal power
+ */
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios =
+ <&gpio3 2 0>,
+ <&gpio3 3 0>,
+ <&gpio3 5 0>,
+ <&gpio3 6 0>,
+ <&gpio5 7 0>,
+ <&gpio6 0 0>,
+ <&gpio6 3 0>,
+ <&gpio6 6 0>,
+ <&gpio7 3 0>,
+ <&gpio8 3 0>,
+ <&gpio8 6 0>,
+ <&gpiob 1 0>,
+ <&gpiob 7 0>,
+ <&gpioc 7 0>,
+ <&gpiof 2 0>,
+ <&gpiof 3 0>;
+ };
+};
+
+&thermistor_3V3_51K1_47K_4050B {
+ status = "okay";
+};
+
+&adc_ec_vsense_pp3300_s5 {
+ /*
+ * Voltage divider on input has 47k upper and 220k lower legs with
+ * 2714 mV full-scale reading on the ADC. Apply the largest possible
+ * multiplier (without overflowing int32) to get the best possible
+ * approximation of the actual ratio, but derate by a factor of two to
+ * ensure unexpectedly high values won't overflow.
+ */
+ mul = <(791261 / 2)>;
+ div = <(651975 / 2)>;
+};
+
+/* Set bus speeds for I2C */
+&i2c0_0 {
+ label = "I2C_EEPROM";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+};
+
+&i2c1_0 {
+ label = "I2C_SENSOR";
+ clock-frequency = <I2C_BITRATE_FAST>;
+};
+
+&i2c3_0 {
+ label = "I2C_USB_C0_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ /*
+ * BC1.2 interrupt is shared with TCPC, so
+ * IRQ is not specified here and handled by
+ * usb_c0_interrupt.
+ */
+ };
+
+ chg_port0: isl923x@9 {
+ compatible = "intersil,isl923x";
+ status = "okay";
+ reg = <0x9>;
+ };
+
+ tcpc_port0: raa489000@22 {
+ compatible = "renesas,raa489000";
+ reg = <0x22>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_VBUS_MONITOR)>;
+ };
+};
+
+&i2c5_1 {
+ label = "I2C_SUB_C1_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+
+ bc12_port1: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ };
+
+ chg_port1: isl923x@9 {
+ compatible = "intersil,isl923x";
+ status = "okay";
+ reg = <0x9>;
+ };
+
+ tcpc_port1: raa489000@22 {
+ compatible = "renesas,raa489000";
+ reg = <0x22>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_VBUS_MONITOR)>;
+ };
+
+ anx7483_mux_1: anx7483-mux-1@3e {
+ compatible = "analogix,anx7483";
+ reg = <0x3e>;
+ board-set = "anx7483_set_default_tuning";
+ flags = <USB_MUX_FLAG_RESETS_IN_G3>;
+ };
+};
+
+&i2c7_0 {
+ label = "I2C_BATTERY";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+};
+
+&pwm5_gpb7 {
+ drive-open-drain;
+};
+
+&pwm5 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm5_gpb7>;
+ pinctrl-names = "default";
+};
+
+/* Tachometer for fan speed measurement */
+&tach2 {
+ status = "okay";
+ pinctrl-0 = <&ta2_1_in_gp73>;
+ pinctrl-names = "default";
+ 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 */
+};
+
+/* host interface */
+&espi0 {
+ status = "okay";
+ pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
+ pinctrl-names = "default";
+};
+
+/*
+ * Declare GPIOs that have leakage current caused by board issues here. NPCX ec
+ * will disable their input buffers before entering deep sleep and restore them
+ * after waking up automatically for better power consumption.
+ */
+&power_leakage_io {
+ leak-gpios = <&gpioa 4 0
+ &gpiof 1 0>;
+};
diff --git a/zephyr/projects/nissa/nivviks/power_signals.dtsi b/zephyr/program/nissa/nivviks/power_signals.dtsi
index 1d2b23069d..1d2b23069d 100644
--- a/zephyr/projects/nissa/nivviks/power_signals.dtsi
+++ b/zephyr/program/nissa/nivviks/power_signals.dtsi
diff --git a/zephyr/projects/nissa/nivviks/project.conf b/zephyr/program/nissa/nivviks/project.conf
index af9e4e2586..af9e4e2586 100644
--- a/zephyr/projects/nissa/nivviks/project.conf
+++ b/zephyr/program/nissa/nivviks/project.conf
diff --git a/zephyr/projects/nissa/joxer/project.overlay b/zephyr/program/nissa/nivviks/project.overlay
index 9ca681d979..9ca681d979 100644
--- a/zephyr/projects/nissa/joxer/project.overlay
+++ b/zephyr/program/nissa/nivviks/project.overlay
diff --git a/zephyr/projects/nissa/nivviks/pwm_leds.dtsi b/zephyr/program/nissa/nivviks/pwm_leds.dtsi
index a265a5929e..a265a5929e 100644
--- a/zephyr/projects/nissa/nivviks/pwm_leds.dtsi
+++ b/zephyr/program/nissa/nivviks/pwm_leds.dtsi
diff --git a/zephyr/program/nissa/nivviks/src/charger.c b/zephyr/program/nissa/nivviks/src/charger.c
new file mode 100644
index 0000000000..234bcbbd55
--- /dev/null
+++ b/zephyr/program/nissa/nivviks/src/charger.c
@@ -0,0 +1,56 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "charger.h"
+#include "charger/isl923x_public.h"
+#include "console.h"
+#include "extpower.h"
+#include "nissa_common.h"
+#include "usb_pd.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+int extpower_is_present(void)
+{
+ int port;
+ int rv;
+ bool acok;
+
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
+ rv = raa489000_is_acok(port, &acok);
+ if ((rv == EC_SUCCESS) && acok)
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ * Nivviks does not have a GPIO indicating whether extpower is present,
+ * so detect using the charger(s).
+ */
+__override void board_check_extpower(void)
+{
+ static int last_extpower_present;
+ int extpower_present = extpower_is_present();
+
+ if (last_extpower_present ^ extpower_present)
+ extpower_handle_update(extpower_present);
+
+ last_extpower_present = extpower_present;
+}
+
+__override void board_hibernate(void)
+{
+ /* Shut down the chargers */
+ if (board_get_usb_pd_port_count() == 2)
+ raa489000_hibernate(CHARGER_SECONDARY, true);
+ raa489000_hibernate(CHARGER_PRIMARY, true);
+ LOG_INF("Charger(s) hibernated");
+ cflush();
+}
diff --git a/zephyr/program/nissa/nivviks/src/fan.c b/zephyr/program/nissa/nivviks/src/fan.c
new file mode 100644
index 0000000000..3111a70e03
--- /dev/null
+++ b/zephyr/program/nissa/nivviks/src/fan.c
@@ -0,0 +1,42 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "cros_cbi.h"
+#include "fan.h"
+#include "gpio/gpio.h"
+#include "hooks.h"
+#include "nissa_common.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.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/program/nissa/nivviks/src/form_factor.c b/zephyr/program/nissa/nivviks/src/form_factor.c
new file mode 100644
index 0000000000..08dfa5c04b
--- /dev/null
+++ b/zephyr/program/nissa/nivviks/src/form_factor.c
@@ -0,0 +1,46 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "accelgyro.h"
+#include "cros_cbi.h"
+#include "hooks.h"
+#include "motionsense_sensors.h"
+#include "nissa_common.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/logging/log.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))
+#define BASE_GYRO SENSOR_ID(DT_NODELABEL(base_gyro))
+
+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;
+ motion_sensors[BASE_GYRO].rot_standard_ref = &ALT_MAT;
+ }
+}
+DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/projects/nissa/nivviks/src/keyboard.c b/zephyr/program/nissa/nivviks/src/keyboard.c
index f13d5bf78c..f13d5bf78c 100644
--- a/zephyr/projects/nissa/nivviks/src/keyboard.c
+++ b/zephyr/program/nissa/nivviks/src/keyboard.c
diff --git a/zephyr/projects/nissa/nivviks/src/led.c b/zephyr/program/nissa/nivviks/src/led.c
index 9087982604..9087982604 100644
--- a/zephyr/projects/nissa/nivviks/src/led.c
+++ b/zephyr/program/nissa/nivviks/src/led.c
diff --git a/zephyr/program/nissa/nivviks/src/usbc.c b/zephyr/program/nissa/nivviks/src/usbc.c
new file mode 100644
index 0000000000..1e0c1627bb
--- /dev/null
+++ b/zephyr/program/nissa/nivviks/src/usbc.c
@@ -0,0 +1,251 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_state_v2.h"
+#include "chipset.h"
+#include "driver/charger/isl923x_public.h"
+#include "driver/retimer/anx7483_public.h"
+#include "driver/tcpm/raa489000.h"
+#include "driver/tcpm/tcpci.h"
+#include "hooks.h"
+#include "nissa_common.h"
+#include "system.h"
+#include "usb_mux.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+int board_is_sourcing_vbus(int port)
+{
+ int regval;
+
+ tcpc_read(port, TCPC_REG_POWER_STATUS, &regval);
+ return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS);
+}
+
+int board_set_active_charge_port(int port)
+{
+ int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
+ int i;
+ int old_port;
+
+ if (!is_real_port && port != CHARGE_PORT_NONE)
+ return EC_ERROR_INVAL;
+
+ old_port = charge_manager_get_active_charge_port();
+
+ LOG_INF("New chg p%d", port);
+
+ /* Disable all ports. */
+ if (port == CHARGE_PORT_NONE) {
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ tcpc_write(i, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_SNK_CTRL_LOW);
+ raa489000_enable_asgate(i, false);
+ }
+
+ return EC_SUCCESS;
+ }
+
+ /* Check if port is sourcing VBUS. */
+ if (board_is_sourcing_vbus(port)) {
+ LOG_WRN("Skip enable p%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ if (i == port)
+ continue;
+
+ if (tcpc_write(i, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_SNK_CTRL_LOW))
+ LOG_WRN("p%d: sink path disable failed.", i);
+ raa489000_enable_asgate(i, false);
+ }
+
+ /*
+ * Stop the charger IC from switching while changing ports. Otherwise,
+ * we can overcurrent the adapter we're switching to. (crbug.com/926056)
+ */
+ if (old_port != CHARGE_PORT_NONE)
+ charger_discharge_on_ac(1);
+
+ /* Enable requested charge port. */
+ if (raa489000_enable_asgate(port, true) ||
+ tcpc_write(port, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_SNK_CTRL_HIGH)) {
+ LOG_WRN("p%d: sink path enable failed.", port);
+ charger_discharge_on_ac(0);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ /* Allow the charger IC to begin/continue switching. */
+ charger_discharge_on_ac(0);
+
+ return EC_SUCCESS;
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ uint16_t status = 0;
+ int regval;
+
+ /*
+ * The interrupt line is shared between the TCPC and BC1.2 detector IC.
+ * Therefore, go out and actually read the alert registers to report the
+ * alert status.
+ */
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
+ if (!tcpc_read16(0, TCPC_REG_ALERT, &regval)) {
+ /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */
+ if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0))
+ regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
+
+ if (regval)
+ status |= PD_STATUS_TCPC_ALERT_0;
+ }
+ }
+
+ if (board_get_usb_pd_port_count() == 2 &&
+ !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
+ /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */
+ if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0))
+ regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
+
+ if (regval)
+ status |= PD_STATUS_TCPC_ALERT_1;
+ }
+ }
+
+ return status;
+}
+
+void pd_power_supply_reset(int port)
+{
+ /* Disable VBUS */
+ tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW);
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ return;
+
+ raa489000_set_output_current(port, rp);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ int rv;
+
+ if (port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ return EC_ERROR_INVAL;
+
+ /* Disable charging. */
+ rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW);
+ if (rv)
+ return rv;
+
+ /* Our policy is not to source VBUS when the AP is off. */
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ return EC_ERROR_NOT_POWERED;
+
+ /* Provide Vbus. */
+ rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH);
+ if (rv)
+ return rv;
+
+ rv = raa489000_enable_asgate(port, true);
+ if (rv)
+ return rv;
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
+}
+
+void board_reset_pd_mcu(void)
+{
+ /*
+ * TODO(b:147316511): could send a reset command to the TCPC here
+ * if needed.
+ */
+}
+
+/*
+ * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible
+ * for an interrupt to be lost if one asserts the IRQ, the other does the same
+ * then the first releases it: there will only be one falling edge to trigger
+ * the interrupt, and the line will be held low. We handle this by running a
+ * deferred check after a falling edge to see whether the IRQ is still being
+ * asserted. If it is, we assume an interrupt may have been lost and we need
+ * to poll each chip for events again.
+ */
+#define USBC_INT_POLL_DELAY_US 5000
+
+static void poll_c0_int(void);
+DECLARE_DEFERRED(poll_c0_int);
+static void poll_c1_int(void);
+DECLARE_DEFERRED(poll_c1_int);
+
+static void usbc_interrupt_trigger(int port)
+{
+ schedule_deferred_pd_interrupt(port);
+ usb_charger_task_set_event(port, USB_CHG_EVENT_BC12);
+}
+
+static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio,
+ const struct deferred_data *ud)
+{
+ if (!gpio_pin_get_dt(gpio)) {
+ usbc_interrupt_trigger(port);
+ hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
+ }
+}
+
+static void poll_c0_int(void)
+{
+ poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl),
+ &poll_c0_int_data);
+}
+
+static void poll_c1_int(void)
+{
+ poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl),
+ &poll_c1_int_data);
+}
+
+void usb_interrupt(enum gpio_signal signal)
+{
+ int port;
+ const struct deferred_data *ud;
+
+ if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) {
+ port = 0;
+ ud = &poll_c0_int_data;
+ } else {
+ port = 1;
+ ud = &poll_c1_int_data;
+ }
+ /*
+ * We've just been called from a falling edge, so there's definitely
+ * no lost IRQ right now. Cancel any pending check.
+ */
+ hook_call_deferred(ud, -1);
+ /* Trigger polling of TCPC and BC1.2 in respective tasks */
+ usbc_interrupt_trigger(port);
+ /* Check for lost interrupts in a bit */
+ hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
+}
diff --git a/zephyr/program/nissa/npcx_program.conf b/zephyr/program/nissa/npcx_program.conf
new file mode 100644
index 0000000000..83ee245a8d
--- /dev/null
+++ b/zephyr/program/nissa/npcx_program.conf
@@ -0,0 +1,48 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# EC chip configuration: NPCX993
+CONFIG_CROS_SYSTEM_NPCX=y
+CONFIG_SOC_SERIES_NPCX9=y
+CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y
+CONFIG_SYSCON=y
+CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=256
+
+# Common sensor drivers
+CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
+
+# Keyboard
+CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y
+# Ensure recovery key combination (esc+refresh+power) is reliable
+CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
+CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
+
+# TCPC+PPC: both C0 and C1 (if present) are RAA489000
+CONFIG_PLATFORM_EC_USB_PD_TCPM_RAA489000=y
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_TCPC_LPM_EXIT_DEBOUNCE_US=100000
+# RAA489000 uses TCPCI but not a separate PPC, so custom function is required
+CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y
+# type C port 1 redriver
+CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y
+
+# Save some flash space by turning off features we don't care much about
+# (EC Kconfig.console turns the ones we do care about on by default)
+CONFIG_SHELL_MINIMAL=y
+
+# FRS enable
+CONFIG_PLATFORM_EC_USB_PD_FRS=y
+CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y
+
+# Charger driver and configuration
+CONFIG_PLATFORM_EC_CHARGER_RAA489000=y
+CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS=22
+
+# VSENSE: PP3300_S5 & PP1050_PROC
+CONFIG_ADC_CMP_NPCX=y
+CONFIG_ADC_CMP_NPCX_WORKQUEUE=y
+CONFIG_ADC_CMP_NPCX_WORKQUEUE_PRIORITY=12
+CONFIG_SENSOR=y
+CONFIG_SENSOR_SHELL=n
diff --git a/zephyr/program/nissa/program.conf b/zephyr/program/nissa/program.conf
new file mode 100644
index 0000000000..ade406671a
--- /dev/null
+++ b/zephyr/program/nissa/program.conf
@@ -0,0 +1,145 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Core EC configuration: build the EC application, using ECOS shims
+# (which are currently required for a number of features).
+CONFIG_CROS_EC=y
+CONFIG_PLATFORM_EC=y
+CONFIG_SHIMMED_TASKS=y
+CONFIG_LTO=y
+
+# RAM-saving options
+# flash shell command is unused, allocated a 4kB buffer for flash test
+CONFIG_FLASH_SHELL=n
+# EC default 1kB buffer seems unnecessarily large, Zephyr default is 8 bytes
+CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE=128
+
+# Standard shimmed features
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y
+CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
+CONFIG_PLATFORM_EC_LID_SWITCH=y
+CONFIG_PLATFORM_EC_POWER_BUTTON=y
+CONFIG_PLATFORM_EC_SWITCH=y
+CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
+CONFIG_PLATFORM_EC_TABLET_MODE=y
+CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
+CONFIG_PLATFORM_EC_VBOOT_EFS2=y
+CONFIG_PLATFORM_EC_VBOOT_HASH=y
+
+# Application processor; communicates with EC via eSPI
+CONFIG_AP=y
+CONFIG_AP_X86_INTEL_ADL=y
+CONFIG_ESPI=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y
+CONFIG_PLATFORM_EC_HOSTCMD=y
+CONFIG_HCDEBUG_OFF=y
+CONFIG_PLATFORM_EC_THROTTLE_AP=y
+CONFIG_PLATFORM_EC_PORT80=y
+CONFIG_PLATFORM_EC_PORT80_QUIET=y
+
+# AP Power Sequencing
+CONFIG_AP_PWRSEQ=y
+CONFIG_X86_NON_DSX_PWRSEQ_ADL=y
+CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y
+CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y
+CONFIG_AP_PWRSEQ_S0IX=y
+CONFIG_AP_PWRSEQ_S0IX_ERROR_RECOVERY=y
+
+# Keyboard support
+CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y
+CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y
+CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
+CONFIG_PLATFORM_EC_CMD_BUTTON=n
+# Column 2 is driven through the GSC, which inverts the signal going through it
+CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_COMMON=y
+CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_LEDTEST=n
+
+# MKBP event
+CONFIG_PLATFORM_EC_MKBP_EVENT=y
+CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
+CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y
+
+# Temperature sensor support
+CONFIG_PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY=y
+
+# CBI EEPROM support
+CONFIG_EEPROM=y
+CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
+
+# PWM support
+CONFIG_PWM_SHELL=y
+
+# Sensors support
+CONFIG_PLATFORM_EC_LID_ANGLE=y
+CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
+CONFIG_PLATFORM_EC_MOTIONSENSE=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
+CONFIG_PLATFORM_EC_ACCEL_FIFO=y
+CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
+
+# USB-C: enable PD on up to two ports
+CONFIG_PLATFORM_EC_USBC=y
+CONFIG_PLATFORM_EC_USBC_PPC=n
+CONFIG_PLATFORM_EC_USB_VID=0x18d1
+CONFIG_PLATFORM_EC_USB_PID=0x505a
+# USB4 and TBT are unsupported
+CONFIG_PLATFORM_EC_USB_PD_USB4=n
+CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
+
+CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y
+CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
+CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=y
+# ADL integrated muxes are slow: unblock PD
+CONFIG_PLATFORM_EC_USB_MUX_TASK=y
+
+# USB-C TCPC and PPC standard options
+CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
+
+# USB-A host ports
+CONFIG_PLATFORM_EC_USB_PORT_ENABLE_DYNAMIC=y
+# 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
+CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_CDP_SDP_ONLY=y
+CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_DEFAULT_CDP=y
+CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_INVERTED=y
+
+# Battery support
+CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
+CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
+CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
+CONFIG_PLATFORM_EC_BATTERY_SMART=y
+CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
+
+# Charger support
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y
+CONFIG_PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS=200
+# Assume 4% overdraw, which could be changed with actual characterization
+CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=4
+CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512
+
+# Reduce logging so that state transitions do not cause protocol issues
+# pd dump [1-3] can be used to increase the debugging level
+CONFIG_PLATFORM_EC_USB_PD_INITIAL_DEBUG_LEVEL=0
+
+# System-side power distribution is designed to be robust up to about 45W, and
+# higher input power may have negative reliability implications (especially for
+# systems with 2S batteries). Most devices can't exceed 45W sinking anyway, so
+# limit charger power to keep system input current within the design range.
+CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000
+# 15V input is slightly more efficient than 20V for all supported chargers, and
+# because power is limited to 45W for other reasons (see above) limiting input
+# voltage like this does not compromise the total power capacity of the system.
+CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=15000 \ No newline at end of file
diff --git a/zephyr/program/nissa/pujjo/cbi.dtsi b/zephyr/program/nissa/pujjo/cbi.dtsi
new file mode 100644
index 0000000000..02057140a5
--- /dev/null
+++ b/zephyr/program/nissa/pujjo/cbi.dtsi
@@ -0,0 +1,190 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ /* Pujjo-specific fw_config fields. */
+ nissa-fw-config {
+ /*
+ * FW_CONFIG field to enable KB back light or not.
+ */
+ kb-bl {
+ enum-name = "FW_KB_BL";
+ start = <3>;
+ size = <1>;
+
+ no-kb-bl {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_KB_BL_NOT_PRESENT";
+ value = <0>;
+ };
+ kb-bl-present {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_KB_BL_PRESENT";
+ value = <1>;
+ };
+ };
+
+ /*
+ * FW_CONFIG field for KB PWB present or not.
+ */
+ kb-pwb {
+ enum-name = "FW_KB_PWB";
+ start = <4>;
+ size = <1>;
+
+ no-kb-pwb {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_KB_PWB_NOT_PRESENT";
+ value = <0>;
+ };
+ kb-pwb-present {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_KB_PWB_PRESENT";
+ value = <1>;
+ };
+ };
+
+ /*
+ * FW_CONFIG field for tablet present or not.
+ */
+ tablet {
+ enum-name = "FW_TABLET";
+ start = <5>;
+ size = <1>;
+
+ no-tablet {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_TABLET_NOT_PRESENT";
+ value = <0>;
+ };
+ tablet-present {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_TABLET_PRESENT";
+ value = <1>;
+ };
+ };
+
+ /*
+ * FW_CONFIG field for LTE board present or not.
+ *
+ * start = <6>;
+ * size = <1>;
+ */
+
+ /*
+ * FW_CONFIG field for SD card present or not.
+ *
+ * start = <7>;
+ * size = <1>;
+ */
+
+ /*
+ * FW_CONFIG field for pen present or not.
+ */
+ pen {
+ enum-name = "FW_PEN";
+ start = <8>;
+ size = <1>;
+
+ no-pen {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_PEN_NOT_PRESENT";
+ value = <0>;
+ };
+ pen-present {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_PEN_PRESENT";
+ value = <1>;
+ };
+ };
+
+ /*
+ * FW_CONFIG field for WF camera present or not.
+ *
+ * start = <9>;
+ * size = <1>;
+ */
+
+ /*
+ * FW_CONFIG field for multiple thermal table.
+ */
+ therm-table {
+ enum-name = "THERM_TABLE";
+ start = <10>;
+ size = <2>;
+
+ therm-table-1 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "THERM_TABLE_1";
+ value = <1>;
+ };
+ };
+
+ /*
+ * FW_CONFIG field for multiple audio module.
+ *
+ * start = <12>;
+ * size = <3>;
+ */
+
+ /*
+ * FW_CONFIG field for EXT_VR.
+ *
+ * start = <15>;
+ * size = <1>;
+ */
+
+ /*
+ * FW_CONFIG field for multiple wi-fi SAR.
+ *
+ * start = <16>;
+ * size = <2>;
+ */
+ };
+
+ /* Pujjo-specific ssfc fields. */
+ cbi-ssfc {
+ compatible = "cros-ec,cbi-ssfc";
+ /*
+ * SSFC field to identify BASE motion sensor.
+ */
+ base-sensor {
+ enum-name = "BASE_SENSOR";
+ size = <2>;
+
+ base_sensor_0: bmi323 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <0>;
+ default;
+ };
+ base_sensor_1: lsm6dsm {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <1>;
+ };
+ };
+
+ /*
+ * SSFC field to identify LID motion sensor.
+ */
+ lid-sensor {
+ enum-name = "LID_SENSOR";
+ size = <2>;
+
+ lid_sensor_0: bma422 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <0>;
+ default;
+ };
+ lid_sensor_1: lis2dw12 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <1>;
+ };
+ };
+ };
+};
diff --git a/zephyr/program/nissa/pujjo/generated.dtsi b/zephyr/program/nissa/pujjo/generated.dtsi
new file mode 100644
index 0000000000..46da0e4a02
--- /dev/null
+++ b/zephyr/program/nissa/pujjo/generated.dtsi
@@ -0,0 +1,277 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * This file is auto-generated - do not edit!
+ */
+
+/ {
+
+ named-adc-channels {
+ compatible = "named-adc-channels";
+
+ adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc {
+ enum-name = "ADC_PP1050_PROC";
+ io-channels = <&adc0 4>;
+ };
+ adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 {
+ enum-name = "ADC_PP3300_S5";
+ io-channels = <&adc0 6>;
+ };
+ adc_temp_sensor_1: temp_sensor_1 {
+ enum-name = "ADC_TEMP_SENSOR_1";
+ io-channels = <&adc0 0>;
+ };
+ adc_temp_sensor_2: temp_sensor_2 {
+ enum-name = "ADC_TEMP_SENSOR_2";
+ io-channels = <&adc0 1>;
+ };
+ adc_temp_sensor_3: temp_sensor_3 {
+ enum-name = "ADC_TEMP_SENSOR_3";
+ io-channels = <&adc0 10>;
+ };
+ };
+
+ named-gpios {
+ compatible = "named-gpios";
+
+ gpio_acc_int_l: acc_int_l {
+ gpios = <&gpio5 0 GPIO_INPUT>;
+ };
+ gpio_all_sys_pwrgd: all_sys_pwrgd {
+ gpios = <&gpioa 7 GPIO_INPUT>;
+ };
+ gpio_ccd_mode_odl: ccd_mode_odl {
+ gpios = <&gpioe 5 GPIO_INPUT>;
+ enum-name = "GPIO_CCD_MODE_ODL";
+ };
+ gpio_cpu_c10_gate_l: cpu_c10_gate_l {
+ gpios = <&gpio6 7 GPIO_INPUT>;
+ };
+ gpio_ec_battery_pres_odl: ec_battery_pres_odl {
+ gpios = <&gpioa 3 GPIO_INPUT>;
+ enum-name = "GPIO_BATT_PRES_ODL";
+ };
+ gpio_ec_cbi_wp: ec_cbi_wp {
+ gpios = <&gpio7 4 GPIO_OUTPUT>;
+ };
+ gpio_ec_edp_bl_en_od: ec_edp_bl_en_od {
+ gpios = <&gpiod 3 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_ENABLE_BACKLIGHT";
+ };
+ gpio_ec_entering_rw: ec_entering_rw {
+ gpios = <&gpio0 3 GPIO_OUTPUT>;
+ enum-name = "GPIO_ENTERING_RW";
+ };
+ gpio_ec_gsc_packet_mode: ec_gsc_packet_mode {
+ gpios = <&gpio7 5 GPIO_OUTPUT>;
+ enum-name = "GPIO_PACKET_MODE_EN";
+ };
+ gpio_ec_kso_02_inv: ec_kso_02_inv {
+ gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
+ };
+ gpio_ec_pch_wake_odl: ec_pch_wake_odl {
+ gpios = <&gpiob 0 GPIO_ODR_LOW>;
+ };
+ gpio_ec_prochot_odl: ec_prochot_odl {
+ gpios = <&gpiof 1 GPIO_ODR_HIGH>;
+ };
+ gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok {
+ gpios = <&gpio6 1 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd {
+ gpios = <&gpioe 4 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_int_odl: ec_soc_int_odl {
+ gpios = <&gpio8 0 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_EC_INT_L";
+ };
+ gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od {
+ gpios = <&gpio7 2 GPIO_ODR_HIGH>;
+ };
+ gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl {
+ gpios = <&gpioc 1 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PCH_PWRBTN_L";
+ };
+ gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l {
+ gpios = <&gpioa 6 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_rtcrst: ec_soc_rtcrst {
+ gpios = <&gpio7 6 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok {
+ gpios = <&gpio3 7 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od {
+ gpios = <&gpioa 4 GPIO_ODR_HIGH>;
+ };
+ gpio_ec_wp_odl: ec_wp_odl {
+ gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ };
+ gpio_en_kb_bl: en_kb_bl {
+ gpios = <&gpioa 0 GPIO_OUTPUT>;
+ enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT";
+ };
+ gpio_en_pp3300_s5: en_pp3300_s5 {
+ gpios = <&gpiob 6 GPIO_OUTPUT>;
+ enum-name = "GPIO_TEMP_SENSOR_POWER";
+ };
+ gpio_en_pp5000_pen_x: en_pp5000_pen_x {
+ gpios = <&gpioe 2 GPIO_OUTPUT>;
+ };
+ gpio_en_pp5000_s5: en_pp5000_s5 {
+ gpios = <&gpio4 0 GPIO_OUTPUT>;
+ };
+ gpio_en_slp_z: en_slp_z {
+ gpios = <&gpioe 1 GPIO_OUTPUT>;
+ };
+ gpio_en_usb_a0_vbus: en_usb_a0_vbus {
+ gpios = <&gpio9 1 GPIO_OUTPUT>;
+ };
+ gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl {
+ gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_POWER_BUTTON_L";
+ };
+ gpio_hdmi_sel: hdmi_sel {
+ gpios = <&gpioc 6 GPIO_OUTPUT>;
+ };
+ gpio_imu_int_l: imu_int_l {
+ gpios = <&gpio5 6 GPIO_INPUT>;
+ };
+ gpio_imvp91_vrrdy_od: imvp91_vrrdy_od {
+ gpios = <&gpio4 3 GPIO_INPUT>;
+ };
+ gpio_lid_open: lid_open {
+ gpios = <&gpiod 2 GPIO_INPUT>;
+ enum-name = "GPIO_LID_OPEN";
+ };
+ gpio_pen_detect_odl: pen_detect_odl {
+ gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od {
+ gpios = <&gpiof 0 GPIO_INPUT>;
+ };
+ gpio_pg_pp5000_s5_od: pg_pp5000_s5_od {
+ gpios = <&gpio4 2 GPIO_INPUT>;
+ };
+ gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l {
+ gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_slp_s0_l: slp_s0_l {
+ gpios = <&gpio9 7 GPIO_INPUT>;
+ };
+ gpio_slp_s3_l: slp_s3_l {
+ gpios = <&gpioa 5 GPIO_INPUT>;
+ };
+ gpio_slp_s4_l: slp_s4_l {
+ gpios = <&gpio7 0 GPIO_INPUT>;
+ };
+ gpio_slp_sus_l: slp_sus_l {
+ gpios = <&gpio6 2 GPIO_INPUT>;
+ };
+ gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp {
+ gpios = <&gpiod 5 GPIO_OUTPUT>;
+ enum-name = "GPIO_USB2_ILIM_SEL";
+ };
+ gpio_sys_rst_odl: sys_rst_odl {
+ gpios = <&gpioc 5 GPIO_ODR_HIGH>;
+ };
+ gpio_tablet_mode_l: tablet_mode_l {
+ gpios = <&gpio9 5 GPIO_INPUT>;
+ enum-name = "GPIO_TABLET_MODE_L";
+ };
+ gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp {
+ gpios = <&gpio8 5 GPIO_OUTPUT>;
+ enum-name = "GPIO_USB1_ILIM_SEL";
+ };
+ gpio_usb_c0_int_odl: usb_c0_int_odl {
+ gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_vccin_aux_vid0: vccin_aux_vid0 {
+ gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_vccin_aux_vid1: vccin_aux_vid1 {
+ gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_voldn_btn_odl: voldn_btn_odl {
+ gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_DOWN_L";
+ };
+ gpio_volup_btn_odl: volup_btn_odl {
+ gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_UP_L";
+ };
+ };
+
+ named-i2c-ports {
+ compatible = "named-i2c-ports";
+
+ i2c_ec_i2c_eeprom: ec_i2c_eeprom {
+ i2c-port = <&i2c0_0>;
+ enum-names = "I2C_PORT_EEPROM";
+ };
+ i2c_ec_i2c_sensor: ec_i2c_sensor {
+ i2c-port = <&i2c1_0>;
+ enum-names = "I2C_PORT_SENSOR";
+ };
+ i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 {
+ i2c-port = <&i2c3_0>;
+ enum-names = "I2C_PORT_USB_C0_TCPC";
+ };
+ i2c_ec_i2c_batt: ec_i2c_batt {
+ i2c-port = <&i2c7_0>;
+ enum-names = "I2C_PORT_BATTERY";
+ };
+ };
+};
+
+&adc0 {
+ status = "okay";
+ pinctrl-0 = <&adc0_chan0_gp45
+ &adc0_chan1_gp44
+ &adc0_chan4_gp41
+ &adc0_chan6_gp34
+ &adc0_chan10_gpe0>;
+ pinctrl-names = "default";
+};
+
+
+&i2c0_0 {
+ status = "okay";
+ pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
+ pinctrl-names = "default";
+};
+
+&i2c1_0 {
+ status = "okay";
+ pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
+ pinctrl-names = "default";
+};
+
+&i2c3_0 {
+ status = "okay";
+ pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
+ pinctrl-names = "default";
+};
+
+&i2c7_0 {
+ status = "okay";
+ pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
+ pinctrl-names = "default";
+};
+
+&i2c_ctrl0 {
+ status = "okay";
+};
+
+&i2c_ctrl1 {
+ status = "okay";
+};
+
+&i2c_ctrl3 {
+ status = "okay";
+};
+
+&i2c_ctrl7 {
+ status = "okay";
+};
diff --git a/zephyr/projects/nissa/pujjo/keyboard.dtsi b/zephyr/program/nissa/pujjo/keyboard.dtsi
index 00610e4e18..00610e4e18 100644
--- a/zephyr/projects/nissa/pujjo/keyboard.dtsi
+++ b/zephyr/program/nissa/pujjo/keyboard.dtsi
diff --git a/zephyr/program/nissa/pujjo/motionsense.dtsi b/zephyr/program/nissa/pujjo/motionsense.dtsi
new file mode 100644
index 0000000000..af21e0509e
--- /dev/null
+++ b/zephyr/program/nissa/pujjo/motionsense.dtsi
@@ -0,0 +1,245 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/motionsense/utils.h>
+
+
+/ {
+ aliases {
+ /*
+ * Interrupt bindings for sensor devices.
+ */
+ bmi3xx-int = &base_accel;
+ lsm6dsm-int = &base_accel;
+ lis2dw12-int = &lid_accel;
+ bma4xx-int = &lid_accel;
+ };
+
+ /*
+ * Declare mutexes used by sensor drivers.
+ * A mutex node is used to create an instance of mutex_t.
+ * A mutex node is referenced by a sensor node if the
+ * corresponding sensor driver needs to use the
+ * instance of the mutex.
+ */
+ motionsense-mutex {
+ compatible = "cros-ec,motionsense-mutex";
+ lid_mutex: lid-mutex {
+ };
+
+ base_mutex: base-mutex {
+ };
+ };
+
+ /* Rotation matrix used by drivers. */
+ motionsense-rotation-ref {
+ compatible = "cros-ec,motionsense-rotation-ref";
+ lid_rot_ref: lid-rotation-ref {
+ mat33 = <0 (-1) 0
+ (-1) 0 0
+ 0 0 (-1)>;
+ };
+
+ lid_rot_lis2dw12: lid-rotation-lis2dw12 {
+ mat33 = <0 (-1) 0
+ (-1) 0 0
+ 0 0 (-1)>;
+ };
+
+ base_rot_ref: base-rotation-ref {
+ mat33 = <0 1 0
+ (-1) 0 0
+ 0 0 1>;
+ };
+
+ base_rot_lsm6dsm: base-rotation-lsm6dsm {
+ mat33 = <1 0 0
+ 0 1 0
+ 0 0 1>;
+ };
+ };
+
+ /*
+ * Driver specific data. A driver-specific data can be shared with
+ * different motion sensors while they are using the same driver.
+ *
+ * If a node's compatible starts with "cros-ec,accelgyro-", it is for
+ * a common structure defined in accelgyro.h.
+ * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
+ * "struct als_drv_data_t" in accelgyro.h
+ */
+ motionsense-sensor-data {
+ bmi323_data: bmi323-drv-data {
+ compatible = "cros-ec,drvdata-bmi3xx";
+ status = "okay";
+ };
+
+ lsm6dsm_data_accel: lsm6dsm-accel-drv-data {
+ compatible = "cros-ec,drvdata-lsm6dsm";
+ status = "okay";
+ };
+
+ lsm6dsm_data_gyro: lsm6dsm-gyro-drv-data {
+ compatible = "cros-ec,drvdata-lsm6dsm";
+ status = "okay";
+ };
+
+ bma422_data: bma422-drv-data {
+ compatible = "cros-ec,drvdata-bma4xx";
+ status = "okay";
+ };
+
+ lis2dw12_data: lis2dw12-drv-data {
+ compatible = "cros-ec,drvdata-lis2dw12";
+ status = "okay";
+ };
+ };
+
+ /*
+ * List of motion sensors that creates motion_sensors array.
+ * The nodelabel "lid_accel" and "base_accel" are used to indicate
+ * motion sensor IDs for lid angle calculation.
+ * TODO(b/238139272): The first entries of the array must be
+ * accelerometers,then gyroscope. Fix this dependency in the DTS
+ * processing which makes the devicetree entries independent.
+ */
+ motionsense-sensor {
+ lid_accel: lid-accel {
+ compatible = "cros-ec,bma4xx";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&lid_rot_ref>;
+ default-range = <2>;
+ drv-data = <&bma422_data>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_accel: base-accel {
+ compatible = "cros-ec,bmi3xx-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi323_data>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_gyro: base-gyro {
+ compatible = "cros-ec,bmi3xx-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi323_data>;
+ };
+ };
+
+ motionsense-sensor-alt {
+ alt_lid_accel: alt-lid-accel {
+ compatible = "cros-ec,lis2dw12";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&lid_rot_lis2dw12>;
+ default-range = <2>;
+ drv-data = <&lis2dw12_data>;
+ i2c-spi-addr-flags = "LIS2DWL_ADDR1_FLAGS";
+ alternate-for = <&lid_accel>;
+ alternate-ssfc-indicator = <&lid_sensor_1>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ alt_base_accel: alt-base-accel {
+ compatible = "cros-ec,lsm6dsm-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_lsm6dsm>;
+ drv-data = <&lsm6dsm_data_accel>;
+ alternate-for = <&base_accel>;
+ alternate-ssfc-indicator = <&base_sensor_1>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ ec-rate = <(100 * USEC_PER_MSEC)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ ec-rate = <0>;
+ };
+ };
+ };
+
+ alt_base_gyro: alt-base-gyro {
+ compatible = "cros-ec,lsm6dsm-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_lsm6dsm>;
+ drv-data = <&lsm6dsm_data_gyro>;
+ default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */
+ alternate-for = <&base_gyro>;
+ alternate-ssfc-indicator = <&base_sensor_1>;
+ };
+ };
+
+ motionsense-sensor-info {
+ compatible = "cros-ec,motionsense-sensor-info";
+
+ /*
+ * list of GPIO interrupts that have to
+ * be enabled at initial stage
+ */
+ sensor-irqs = <&int_imu &int_lid_accel>;
+ };
+};
diff --git a/zephyr/program/nissa/pujjo/overlay.dtsi b/zephyr/program/nissa/pujjo/overlay.dtsi
new file mode 100644
index 0000000000..cb20ec6554
--- /dev/null
+++ b/zephyr/program/nissa/pujjo/overlay.dtsi
@@ -0,0 +1,371 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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>
+#include <dt-bindings/usb_pd_tcpm.h>
+
+/ {
+ aliases {
+ gpio-cbi-wp = &gpio_ec_cbi_wp;
+ gpio-wp = &gpio_ec_wp_odl;
+ int-wp = &int_wp_l;
+ gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ };
+
+ ec-console {
+ compatible = "ec-console";
+ disabled = "events", "lpc", "hostcmd";
+ };
+
+ batteries {
+ default_battery: smp {
+ compatible = "smp,l22m3pg0", "battery-smart";
+ };
+ smp_l22m3pg1 {
+ compatible = "smp,l22m3pg1", "battery-smart";
+ };
+ sunwoda_l22d3pg0 {
+ compatible = "sunwoda,l22d3pg0", "battery-smart";
+ };
+ sunwoda_l22d3pg1 {
+ compatible = "sunwoda,l22d3pg1", "battery-smart";
+ };
+ celxpert_l22c3pg0 {
+ compatible = "celxpert,l22c3pg0", "battery-smart";
+ };
+ };
+
+ hibernate-wake-pins {
+ compatible = "cros-ec,hibernate-wake-pins";
+ wakeup-irqs = <
+ &int_power_button
+ &int_lid_open
+ >;
+ };
+
+ gpio-interrupts {
+ compatible = "cros-ec,gpio-interrupts";
+
+ int_power_button: power_button {
+ irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "power_button_interrupt";
+ };
+ int_wp_l: wp_l {
+ irq-pin = <&gpio_ec_wp_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "switch_interrupt";
+ };
+ int_lid_open: lid_open {
+ irq-pin = <&gpio_lid_open>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "lid_interrupt";
+ };
+ int_tablet_mode: tablet_mode {
+ irq-pin = <&gpio_tablet_mode_l>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "gmr_tablet_switch_isr";
+ };
+ int_imu: ec_imu {
+ irq-pin = <&gpio_imu_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "motion_interrupt";
+ };
+ int_lid_accel: lid_accel {
+ irq-pin = <&gpio_acc_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "lid_accel_interrupt";
+ };
+ int_vol_down: vol_down {
+ irq-pin = <&gpio_voldn_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_vol_up: vol_up {
+ irq-pin = <&gpio_volup_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_usb_c0: usb_c0 {
+ irq-pin = <&gpio_usb_c0_int_odl>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_interrupt";
+ };
+ };
+
+ named-gpios {
+ gpio_sb_2: sb_2 {
+ gpios = <&gpiod 4 GPIO_OUTPUT>;
+ no-auto-init;
+ };
+
+ gpio_sb_3: sb_3 {
+ gpios = <&gpiof 5 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>;
+ no-auto-init;
+ };
+ gpio_sb_4: sb_4 {
+ gpios = <&gpiof 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ no-auto-init;
+ };
+ gpio_fan_enable: fan-enable {
+ gpios = <&gpio6 3 GPIO_OUTPUT>;
+ no-auto-init;
+ };
+ ec-i2c-sensor-scl {
+ gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec-i2c-sensor-sda {
+ gpios = <&gpio8 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_power_led: power_led {
+ gpios = <&gpioc 2 GPIO_OUTPUT_LOW>;
+ };
+ gpio_led_1_odl: led_1_odl {
+ gpios = <&gpioc 4 GPIO_OUTPUT_LOW>;
+ };
+ gpio_led_2_odl: led_2_odl {
+ gpios = <&gpioc 3 GPIO_OUTPUT_LOW>;
+ };
+ };
+
+ /*
+ * Aliases used for sub-board GPIOs.
+ */
+ aliases {
+ /*
+ * Sub-board with type A USB, enable.
+ */
+ gpio-en-usb-a1-vbus = &gpio_sb_2;
+ /*
+ * HPD pins for HDMI sub-board.
+ */
+ gpio-hdmi-en-odl = &gpio_sb_3;
+ gpio-hpd-odl = &gpio_sb_4;
+ /*
+ * Enable S5 rails for LTE sub-board
+ */
+ gpio-en-sub-s5-rails = &gpio_sb_2;
+ };
+
+ temp_cpu: cpu {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_1>;
+ };
+ temp_ddr: ddr {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_2>;
+ };
+ temp_ambient: ambient {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_3>;
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ cpu {
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <90>;
+ temp_host_halt = <100>;
+ temp_host_release_high = <85>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_cpu>;
+ };
+ ddr {
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <90>;
+ temp_host_halt = <100>;
+ temp_host_release_high = <85>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_ddr>;
+ };
+ ambient {
+ temp_fan_off = <35>;
+ temp_fan_max = <60>;
+ temp_host_high = <90>;
+ temp_host_halt = <100>;
+ temp_host_release_high = <85>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_ambient>;
+ };
+ };
+
+ usba {
+ compatible = "cros-ec,usba-port-enable-pins";
+ /*
+ * sb_2 is only configured as GPIO when USB-A1 is present,
+ * but it's still safe to control when disabled.
+ *
+ * ILIM_SEL pins are referred to by legacy enum name,
+ * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
+ * sub-boards that don't have USB-A so is safe to control
+ * regardless of system configuration.
+ */
+ enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
+ status = "okay";
+ };
+
+ usbc {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port0@0 {
+ compatible = "named-usbc-port";
+ reg = <0>;
+ bc12 = <&bc12_port0>;
+ chg = <&chg_port0>;
+ tcpc = <&tcpc_port0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_0>;
+ };
+ };
+ port0-muxes {
+ virtual_mux_0: virtual-mux-0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ };
+
+ fans {
+ compatible = "cros-ec,fans";
+
+ fan_0 {
+ pwms = <&pwm5 5 PWM_KHZ(1) PWM_POLARITY_NORMAL>;
+ rpm_min = <2200>;
+ rpm_start = <2200>;
+ rpm_max = <4200>;
+ tach = <&tach2>;
+ enable_gpio = <&gpio_fan_enable>;
+ };
+ };
+
+ /*
+ * Declare unused GPIOs so that they are shut down
+ * and use minimal power
+ */
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios =
+ <&gpio3 3 0>,
+ <&gpio3 6 0>,
+ <&gpiod 7 0>,
+ <&gpiof 2 0>,
+ <&gpiof 3 0>;
+ };
+};
+
+&thermistor_3V3_51K1_47K_4050B {
+ status = "okay";
+};
+
+&adc_ec_vsense_pp3300_s5 {
+ /*
+ * Voltage divider on input has 47k upper and 220k lower legs with
+ * 2714 mV full-scale reading on the ADC. Apply the largest possible
+ * multiplier (without overflowing int32) to get the best possible
+ * approximation of the actual ratio, but derate by a factor of two to
+ * ensure unexpectedly high values won't overflow.
+ */
+ mul = <(791261 / 2)>;
+ div = <(651975 / 2)>;
+};
+
+/* Set bus speeds for I2C */
+&i2c0_0 {
+ label = "I2C_EEPROM";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+};
+
+&i2c1_0 {
+ label = "I2C_SENSOR";
+ clock-frequency = <I2C_BITRATE_FAST>;
+};
+
+&i2c3_0 {
+ label = "I2C_USB_C0_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ /*
+ * BC1.2 interrupt is shared with TCPC, so
+ * IRQ is not specified here and handled by
+ * usb_c0_interrupt.
+ */
+ };
+
+ chg_port0: isl923x@9 {
+ compatible = "intersil,isl923x";
+ status = "okay";
+ reg = <0x9>;
+ };
+
+ tcpc_port0: raa489000@22 {
+ compatible = "renesas,raa489000";
+ reg = <0x22>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_VBUS_MONITOR)>;
+ };
+};
+
+&i2c7_0 {
+ label = "I2C_BATTERY";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+};
+
+&pwm5_gpb7 {
+ drive-open-drain;
+};
+
+&pwm5 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm5_gpb7>;
+ pinctrl-names = "default";
+};
+
+/* Tachometer for fan speed measurement */
+&tach2 {
+ status = "okay";
+ pinctrl-0 = <&ta2_1_in_gp73>;
+ pinctrl-names = "default";
+ 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 */
+};
+
+/* host interface */
+&espi0 {
+ status = "okay";
+ pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
+ pinctrl-names = "default";
+};
+
+/*
+ * Declare GPIOs that have leakage current caused by board issues here. NPCX ec
+ * will disable their input buffers before entering deep sleep and restore them
+ * after waking up automatically for better power consumption.
+ */
+&power_leakage_io {
+ leak-gpios = <&gpioa 4 0
+ &gpiof 1 0>;
+};
diff --git a/zephyr/projects/nissa/pujjo/power_signals.dtsi b/zephyr/program/nissa/pujjo/power_signals.dtsi
index 1d2b23069d..1d2b23069d 100644
--- a/zephyr/projects/nissa/pujjo/power_signals.dtsi
+++ b/zephyr/program/nissa/pujjo/power_signals.dtsi
diff --git a/zephyr/projects/nissa/pujjo/project.conf b/zephyr/program/nissa/pujjo/project.conf
index b9dc28b9cd..b9dc28b9cd 100644
--- a/zephyr/projects/nissa/pujjo/project.conf
+++ b/zephyr/program/nissa/pujjo/project.conf
diff --git a/zephyr/projects/nissa/pujjo/project.overlay b/zephyr/program/nissa/pujjo/project.overlay
index e498775714..e498775714 100644
--- a/zephyr/projects/nissa/pujjo/project.overlay
+++ b/zephyr/program/nissa/pujjo/project.overlay
diff --git a/zephyr/projects/nissa/pujjo/pujjo_vif.xml b/zephyr/program/nissa/pujjo/pujjo_vif.xml
index b7d462584a..b7d462584a 100644
--- a/zephyr/projects/nissa/pujjo/pujjo_vif.xml
+++ b/zephyr/program/nissa/pujjo/pujjo_vif.xml
diff --git a/zephyr/program/nissa/pujjo/src/charger.c b/zephyr/program/nissa/pujjo/src/charger.c
new file mode 100644
index 0000000000..8763f24793
--- /dev/null
+++ b/zephyr/program/nissa/pujjo/src/charger.c
@@ -0,0 +1,64 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "charger.h"
+#include "charger/isl923x_public.h"
+#include "console.h"
+#include "driver/charger/isl923x.h"
+#include "driver/tcpm/raa489000.h"
+#include "extpower.h"
+#include "hooks.h"
+#include "nissa_common.h"
+#include "usb_pd.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+int extpower_is_present(void)
+{
+ int port;
+ int rv;
+ bool acok;
+
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
+ rv = raa489000_is_acok(port, &acok);
+ if ((rv == EC_SUCCESS) && acok)
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ * Pujjo does not have a GPIO indicating whether extpower is present,
+ * so detect using the charger(s).
+ */
+__override void board_check_extpower(void)
+{
+ static int last_extpower_present;
+ int extpower_present = extpower_is_present();
+
+ if (last_extpower_present ^ extpower_present)
+ extpower_handle_update(extpower_present);
+
+ last_extpower_present = extpower_present;
+}
+
+__override void board_hibernate(void)
+{
+ /* Shut down the chargers */
+ raa489000_hibernate(0, true);
+ LOG_INF("Charger(s) hibernated");
+ cflush();
+}
+
+static void charger_prochot_init(void)
+{
+ isl923x_set_ac_prochot(CHARGER_SOLO, 3500);
+ isl923x_set_dc_prochot(CHARGER_SOLO, 6528);
+}
+DECLARE_HOOK(HOOK_INIT, charger_prochot_init, HOOK_PRIO_POST_FIRST);
diff --git a/zephyr/program/nissa/pujjo/src/fan.c b/zephyr/program/nissa/pujjo/src/fan.c
new file mode 100644
index 0000000000..8b8634a653
--- /dev/null
+++ b/zephyr/program/nissa/pujjo/src/fan.c
@@ -0,0 +1,42 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "cros_cbi.h"
+#include "fan.h"
+#include "gpio/gpio.h"
+#include "hooks.h"
+#include "nissa_common.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+/*
+ * Pujjo 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/program/nissa/pujjo/src/form_factor.c b/zephyr/program/nissa/pujjo/src/form_factor.c
new file mode 100644
index 0000000000..f160c88d78
--- /dev/null
+++ b/zephyr/program/nissa/pujjo/src/form_factor.c
@@ -0,0 +1,78 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "accelgyro.h"
+#include "button.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "driver/accel_bma4xx.h"
+#include "driver/accel_lis2dw12_public.h"
+#include "driver/accelgyro_bmi323.h"
+#include "driver/accelgyro_lsm6dsm.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "motion_sense.h"
+#include "motionsense_sensors.h"
+#include "nissa_common.h"
+#include "tablet_mode.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+static bool use_alt_sensor;
+static bool use_alt_lid_accel;
+
+void motion_interrupt(enum gpio_signal signal)
+{
+ if (use_alt_sensor)
+ lsm6dsm_interrupt(signal);
+ else
+ bmi3xx_interrupt(signal);
+}
+
+void lid_accel_interrupt(enum gpio_signal signal)
+{
+ if (use_alt_lid_accel)
+ lis2dw12_interrupt(signal);
+ else
+ bma4xx_interrupt(signal);
+}
+
+static void sensor_init(void)
+{
+ int ret;
+ uint32_t val;
+ /* check which sensors are installed */
+ use_alt_sensor = cros_cbi_ssfc_check_match(
+ CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1)));
+ use_alt_lid_accel = cros_cbi_ssfc_check_match(
+ CBI_SSFC_VALUE_ID(DT_NODELABEL(lid_sensor_1)));
+
+ motion_sensors_check_ssfc();
+
+ /* Check if it's tablet or not */
+ ret = cros_cbi_get_fw_config(FW_TABLET, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_TABLET);
+ return;
+ }
+ if (val == FW_TABLET_NOT_PRESENT) {
+ LOG_INF("Clamshell: disable motionsense function.");
+ motion_sensor_count = 0;
+ gmr_tablet_switch_disable();
+ gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu));
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l),
+ GPIO_DISCONNECTED);
+
+ LOG_INF("Clamshell: disable volume button function.");
+ button_disable_gpio(BUTTON_VOLUME_UP);
+ button_disable_gpio(BUTTON_VOLUME_DOWN);
+ } else {
+ LOG_INF("Tablet: Enable motionsense function.");
+ }
+}
+DECLARE_HOOK(HOOK_INIT, sensor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/projects/nissa/pujjo/src/hdmi.c b/zephyr/program/nissa/pujjo/src/hdmi.c
index 9461e7c53e..9461e7c53e 100644
--- a/zephyr/projects/nissa/pujjo/src/hdmi.c
+++ b/zephyr/program/nissa/pujjo/src/hdmi.c
diff --git a/zephyr/projects/nissa/pujjo/src/keyboard.c b/zephyr/program/nissa/pujjo/src/keyboard.c
index 1587030080..1587030080 100644
--- a/zephyr/projects/nissa/pujjo/src/keyboard.c
+++ b/zephyr/program/nissa/pujjo/src/keyboard.c
diff --git a/zephyr/program/nissa/pujjo/src/led.c b/zephyr/program/nissa/pujjo/src/led.c
new file mode 100644
index 0000000000..4d859f2764
--- /dev/null
+++ b/zephyr/program/nissa/pujjo/src/led.c
@@ -0,0 +1,134 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Pujjo specific PWM LED settings: there are 2 LEDs on each side of the board,
+ * each one can be controlled separately. The LED colors are white or amber,
+ * and the default behavior is tied to the charging process: both sides are
+ * amber while charging the battery and white when the battery is charged.
+ */
+
+#include "common.h"
+#include "gpio.h"
+#include "led_common.h"
+#include "led_onoff_states.h"
+
+#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args)
+
+#define LED_OFF_LVL 1
+#define LED_ON_LVL 0
+
+__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_RED,
+ LED_INDEFINITE } },
+ [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER,
+ LED_INDEFINITE } },
+ [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN,
+ LED_INDEFINITE } },
+ [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC },
+ { LED_OFF, 1 * LED_ONE_SEC } },
+ [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC },
+ { EC_LED_COLOR_GREEN,
+ 2 * LED_ONE_SEC } },
+ };
+
+__override const struct led_descriptor
+ led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = {
+ [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } },
+ [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE,
+ 3 * LED_ONE_SEC },
+ { LED_OFF, 0.5 * LED_ONE_SEC } },
+ [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE,
+ 3 * LED_ONE_SEC },
+ { LED_OFF,
+ 0.5 * LED_ONE_SEC } },
+ [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } },
+ };
+
+const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED,
+ EC_LED_ID_POWER_LED };
+
+const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
+
+__override void led_set_color_power(enum ec_led_colors color)
+{
+ if (color == EC_LED_COLOR_WHITE)
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led),
+ LED_ON_LVL);
+ else
+ /* LED_OFF and unsupported colors */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led),
+ LED_OFF_LVL);
+}
+
+__override void led_set_color_battery(enum ec_led_colors color)
+{
+ switch (color) {
+ case EC_LED_COLOR_AMBER:
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl),
+ LED_ON_LVL);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl),
+ LED_ON_LVL);
+ break;
+ case EC_LED_COLOR_RED:
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl),
+ LED_ON_LVL);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl),
+ LED_OFF_LVL);
+ break;
+ case EC_LED_COLOR_GREEN:
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl),
+ LED_OFF_LVL);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl),
+ LED_ON_LVL);
+ break;
+ default: /* LED_OFF and other unsupported colors */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl),
+ LED_OFF_LVL);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl),
+ LED_OFF_LVL);
+ 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_RED] = 1;
+ brightness_range[EC_LED_COLOR_AMBER] = 1;
+ brightness_range[EC_LED_COLOR_GREEN] = 1;
+ } else if (led_id == EC_LED_ID_POWER_LED) {
+ 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_RED] != 0)
+ led_set_color_battery(EC_LED_COLOR_RED);
+ else if (brightness[EC_LED_COLOR_AMBER] != 0)
+ led_set_color_battery(EC_LED_COLOR_AMBER);
+ else if (brightness[EC_LED_COLOR_GREEN] != 0)
+ led_set_color_battery(EC_LED_COLOR_GREEN);
+ else
+ led_set_color_battery(LED_OFF);
+ } else if (led_id == EC_LED_ID_POWER_LED) {
+ if (brightness[EC_LED_COLOR_WHITE] != 0)
+ led_set_color_power(EC_LED_COLOR_WHITE);
+ else
+ led_set_color_power(LED_OFF);
+ }
+
+ return EC_SUCCESS;
+}
diff --git a/zephyr/program/nissa/pujjo/src/usbc.c b/zephyr/program/nissa/pujjo/src/usbc.c
new file mode 100644
index 0000000000..ac93edfd7a
--- /dev/null
+++ b/zephyr/program/nissa/pujjo/src/usbc.c
@@ -0,0 +1,227 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_state_v2.h"
+#include "chipset.h"
+#include "driver/charger/isl923x_public.h"
+#include "driver/retimer/anx7483_public.h"
+#include "driver/tcpm/raa489000.h"
+#include "driver/tcpm/tcpci.h"
+#include "hooks.h"
+#include "nissa_common.h"
+#include "system.h"
+#include "usb_mux.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+int board_is_sourcing_vbus(int port)
+{
+ int regval;
+
+ tcpc_read(port, TCPC_REG_POWER_STATUS, &regval);
+ return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS);
+}
+
+int board_set_active_charge_port(int port)
+{
+ int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
+ int i;
+ int old_port;
+
+ if (!is_real_port && port != CHARGE_PORT_NONE)
+ return EC_ERROR_INVAL;
+
+ old_port = charge_manager_get_active_charge_port();
+
+ LOG_INF("New chg p%d", port);
+
+ /* Disable all ports. */
+ if (port == CHARGE_PORT_NONE) {
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ tcpc_write(i, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_SNK_CTRL_LOW);
+ raa489000_enable_asgate(i, false);
+ }
+
+ return EC_SUCCESS;
+ }
+
+ /* Check if port is sourcing VBUS. */
+ if (board_is_sourcing_vbus(port)) {
+ LOG_WRN("Skip enable p%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ if (i == port)
+ continue;
+
+ if (tcpc_write(i, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_SNK_CTRL_LOW))
+ LOG_WRN("p%d: sink path disable failed.", i);
+ raa489000_enable_asgate(i, false);
+ }
+
+ /*
+ * Stop the charger IC from switching while changing ports. Otherwise,
+ * we can overcurrent the adapter we're switching to. (crbug.com/926056)
+ */
+ if (old_port != CHARGE_PORT_NONE)
+ charger_discharge_on_ac(1);
+
+ /* Enable requested charge port. */
+ if (raa489000_enable_asgate(port, true) ||
+ tcpc_write(port, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_SNK_CTRL_HIGH)) {
+ LOG_WRN("p%d: sink path enable failed.", port);
+ charger_discharge_on_ac(0);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ /* Allow the charger IC to begin/continue switching. */
+ charger_discharge_on_ac(0);
+
+ return EC_SUCCESS;
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ uint16_t status = 0;
+ int regval;
+
+ /*
+ * The interrupt line is shared between the TCPC and BC1.2 detector IC.
+ * Therefore, go out and actually read the alert registers to report the
+ * alert status.
+ */
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
+ if (!tcpc_read16(0, TCPC_REG_ALERT, &regval)) {
+ /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */
+ if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0))
+ regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
+
+ if (regval)
+ status |= PD_STATUS_TCPC_ALERT_0;
+ }
+ }
+ return status;
+}
+
+void pd_power_supply_reset(int port)
+{
+ /* Disable VBUS */
+ tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW);
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ return;
+
+ raa489000_set_output_current(port, rp);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ int rv;
+
+ if (port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ return EC_ERROR_INVAL;
+
+ /* Disable charging. */
+ rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW);
+ if (rv)
+ return rv;
+
+ /* Our policy is not to source VBUS when the AP is off. */
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ return EC_ERROR_NOT_POWERED;
+
+ /* Provide Vbus. */
+ rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH);
+ if (rv)
+ return rv;
+
+ rv = raa489000_enable_asgate(port, true);
+ if (rv)
+ return rv;
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
+}
+
+void board_reset_pd_mcu(void)
+{
+ /*
+ * TODO(b:147316511): could send a reset command to the TCPC here
+ * if needed.
+ */
+}
+
+/*
+ * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible
+ * for an interrupt to be lost if one asserts the IRQ, the other does the same
+ * then the first releases it: there will only be one falling edge to trigger
+ * the interrupt, and the line will be held low. We handle this by running a
+ * deferred check after a falling edge to see whether the IRQ is still being
+ * asserted. If it is, we assume an interrupt may have been lost and we need
+ * to poll each chip for events again.
+ */
+#define USBC_INT_POLL_DELAY_US 5000
+
+static void poll_c0_int(void);
+DECLARE_DEFERRED(poll_c0_int);
+
+static void usbc_interrupt_trigger(int port)
+{
+ schedule_deferred_pd_interrupt(port);
+ usb_charger_task_set_event(port, USB_CHG_EVENT_BC12);
+}
+
+static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio,
+ const struct deferred_data *ud)
+{
+ if (!gpio_pin_get_dt(gpio)) {
+ usbc_interrupt_trigger(port);
+ hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
+ }
+}
+
+static void poll_c0_int(void)
+{
+ poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl),
+ &poll_c0_int_data);
+}
+
+void usb_interrupt(enum gpio_signal signal)
+{
+ int port;
+ const struct deferred_data *ud;
+
+ if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) {
+ port = 0;
+ ud = &poll_c0_int_data;
+ }
+ /*
+ * We've just been called from a falling edge, so there's definitely
+ * no lost IRQ right now. Cancel any pending check.
+ */
+ hook_call_deferred(ud, -1);
+ /* Trigger polling of TCPC and BC1.2 in respective tasks */
+ usbc_interrupt_trigger(port);
+ /* Check for lost interrupts in a bit */
+ hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
+}
diff --git a/zephyr/program/nissa/src/board_power.c b/zephyr/program/nissa/src/board_power.c
new file mode 100644
index 0000000000..858076686b
--- /dev/null
+++ b/zephyr/program/nissa/src/board_power.c
@@ -0,0 +1,169 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gpio/gpio.h"
+#include "gpio_signal.h"
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/atomic.h>
+
+#include <ap_power/ap_power.h>
+#include <ap_power/ap_power_events.h>
+#include <ap_power/ap_power_interface.h>
+#include <ap_power_override_functions.h>
+#include <power_signals.h>
+#include <x86_power_signals.h>
+
+LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF);
+
+#define X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS 5
+
+static bool s0_stable;
+
+static void generate_ec_soc_dsw_pwrok_handler(int delay)
+{
+ int in_sig_val = power_signal_get(PWR_DSW_PWROK);
+
+ if (in_sig_val != power_signal_get(PWR_EC_SOC_DSW_PWROK)) {
+ if (in_sig_val)
+ k_msleep(delay);
+ power_signal_set(PWR_EC_SOC_DSW_PWROK, 1);
+ }
+}
+
+void board_ap_power_force_shutdown(void)
+{
+ int timeout_ms = X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS;
+
+ if (s0_stable) {
+ /* Enable these power signals in case of sudden shutdown */
+ power_signal_enable(PWR_DSW_PWROK);
+ power_signal_enable(PWR_PG_PP1P05);
+ }
+
+ power_signal_set(PWR_EC_SOC_DSW_PWROK, 0);
+ power_signal_set(PWR_EC_PCH_RSMRST, 0);
+
+ while (power_signal_get(PWR_RSMRST) == 0 &&
+ power_signal_get(PWR_SLP_SUS) == 0 && timeout_ms > 0) {
+ k_msleep(1);
+ timeout_ms--;
+ }
+ if (power_signal_get(PWR_SLP_SUS) == 0) {
+ LOG_WRN("SLP_SUS is not deasserted! Assuming G3");
+ }
+
+ if (power_signal_get(PWR_RSMRST) == 1) {
+ LOG_WRN("RSMRST is not deasserted! Assuming G3");
+ }
+
+ power_signal_set(PWR_EN_PP3300_A, 0);
+
+ power_signal_set(PWR_EN_PP5000_A, 0);
+
+ timeout_ms = X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS;
+ while (power_signal_get(PWR_DSW_PWROK) && timeout_ms > 0) {
+ k_msleep(1);
+ timeout_ms--;
+ };
+
+ if (power_signal_get(PWR_DSW_PWROK))
+ LOG_WRN("DSW_PWROK didn't go low! Assuming G3.");
+
+ power_signal_disable(PWR_DSW_PWROK);
+ power_signal_disable(PWR_PG_PP1P05);
+ s0_stable = false;
+}
+
+void board_ap_power_action_g3_s5(void)
+{
+ power_signal_enable(PWR_DSW_PWROK);
+ power_signal_enable(PWR_PG_PP1P05);
+
+ LOG_DBG("Turning on PWR_EN_PP5000_A and PWR_EN_PP3300_A");
+ power_signal_set(PWR_EN_PP5000_A, 1);
+ power_signal_set(PWR_EN_PP3300_A, 1);
+
+ power_wait_signals_timeout(IN_PGOOD_ALL_CORE,
+ AP_PWRSEQ_DT_VALUE(wait_signal_timeout));
+
+ generate_ec_soc_dsw_pwrok_handler(AP_PWRSEQ_DT_VALUE(dsw_pwrok_delay));
+ s0_stable = false;
+}
+
+void board_ap_power_action_s3_s0(void)
+{
+ s0_stable = false;
+}
+
+void board_ap_power_action_s0_s3(void)
+{
+ power_signal_enable(PWR_DSW_PWROK);
+ power_signal_enable(PWR_PG_PP1P05);
+ s0_stable = false;
+}
+
+void board_ap_power_action_s0(void)
+{
+ if (s0_stable) {
+ return;
+ }
+ LOG_INF("Reaching S0");
+ power_signal_disable(PWR_DSW_PWROK);
+ power_signal_disable(PWR_PG_PP1P05);
+ s0_stable = true;
+}
+
+int board_ap_power_assert_pch_power_ok(void)
+{
+ /* Pass though PCH_PWROK */
+ if (power_signal_get(PWR_PCH_PWROK) == 0) {
+ k_msleep(AP_PWRSEQ_DT_VALUE(pch_pwrok_delay));
+ power_signal_set(PWR_PCH_PWROK, 1);
+ }
+
+ return 0;
+}
+
+bool board_ap_power_check_power_rails_enabled(void)
+{
+ return power_signal_get(PWR_EN_PP3300_A) &&
+ power_signal_get(PWR_EN_PP5000_A) &&
+ power_signal_get(PWR_EC_SOC_DSW_PWROK);
+}
+
+int board_power_signal_get(enum power_signal signal)
+{
+ switch (signal) {
+ default:
+ LOG_ERR("Unknown signal for board get: %d", signal);
+ return -EINVAL;
+
+ case PWR_ALL_SYS_PWRGD:
+ /*
+ * All system power is good.
+ * Checks that PWR_SLP_S3 is off, and
+ * the GPIO signal for all power good is set,
+ * and that the 1.05 volt line is ready.
+ */
+ if (power_signal_get(PWR_SLP_S3)) {
+ return 0;
+ }
+ if (!gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_all_sys_pwrgd))) {
+ return 0;
+ }
+ if (!power_signal_get(PWR_PG_PP1P05)) {
+ return 0;
+ }
+ return 1;
+ }
+}
+
+int board_power_signal_set(enum power_signal signal, int value)
+{
+ return -EINVAL;
+}
diff --git a/zephyr/program/nissa/src/common.c b/zephyr/program/nissa/src/common.c
new file mode 100644
index 0000000000..d437bfca47
--- /dev/null
+++ b/zephyr/program/nissa/src/common.c
@@ -0,0 +1,199 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "charge_state_v2.h"
+#include "charger.h"
+#include "chipset.h"
+#include "cros_cbi.h"
+#include "hooks.h"
+#include "nissa_common.h"
+#include "system.h"
+#include "usb_mux.h"
+
+#include <zephyr/device.h>
+#include <zephyr/logging/log.h>
+
+#include <ap_power/ap_power.h>
+LOG_MODULE_REGISTER(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+static uint8_t cached_usb_pd_port_count;
+
+__override uint8_t board_get_usb_pd_port_count(void)
+{
+ __ASSERT(cached_usb_pd_port_count != 0,
+ "sub-board detection did not run before a port count request");
+ if (cached_usb_pd_port_count == 0)
+ LOG_WRN("USB PD Port count not initialized!");
+ return cached_usb_pd_port_count;
+}
+
+static void board_power_change(struct ap_power_ev_callback *cb,
+ struct ap_power_ev_data data)
+{
+ /*
+ * Enable power to pen garage when system is active (safe even if no
+ * pen is present).
+ */
+ const struct gpio_dt_spec *const pen_power_gpio =
+ GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_pen_x);
+
+ switch (data.event) {
+ case AP_POWER_STARTUP:
+ gpio_pin_set_dt(pen_power_gpio, 1);
+ break;
+ case AP_POWER_SHUTDOWN:
+ gpio_pin_set_dt(pen_power_gpio, 0);
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+ * Initialise the USB PD port count, which
+ * depends on which sub-board is attached.
+ */
+static void board_setup_init(void)
+{
+ static struct ap_power_ev_callback cb;
+
+ ap_power_ev_init_callback(&cb, board_power_change,
+ AP_POWER_STARTUP | AP_POWER_SHUTDOWN);
+ ap_power_ev_add_callback(&cb);
+
+ switch (nissa_get_sb_type()) {
+ default:
+ cached_usb_pd_port_count = 1;
+ break;
+
+ case NISSA_SB_C_A:
+ case NISSA_SB_C_LTE:
+ cached_usb_pd_port_count = 2;
+ break;
+ }
+}
+/*
+ * Make sure setup is done after EEPROM is readable.
+ */
+DECLARE_HOOK(HOOK_INIT, board_setup_init, HOOK_PRIO_INIT_I2C);
+
+int pd_check_vconn_swap(int port)
+{
+ /* Allow VCONN swaps if the AP is on. */
+ return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON);
+}
+
+/*
+ * Count of chargers depends on sub board presence.
+ */
+__override uint8_t board_get_charger_chip_count(void)
+{
+ return board_get_usb_pd_port_count();
+}
+
+/*
+ * Retrieve sub-board type from FW_CONFIG.
+ */
+enum nissa_sub_board_type nissa_get_sb_type(void)
+{
+ static enum nissa_sub_board_type sb = NISSA_SB_UNKNOWN;
+ int ret;
+ uint32_t val;
+
+ /*
+ * Return cached value.
+ */
+ if (sb != NISSA_SB_UNKNOWN)
+ return sb;
+
+ sb = NISSA_SB_NONE; /* Defaults to none */
+ ret = cros_cbi_get_fw_config(FW_SUB_BOARD, &val);
+ if (ret != 0) {
+ LOG_WRN("Error retrieving CBI FW_CONFIG field %d",
+ FW_SUB_BOARD);
+ return sb;
+ }
+ switch (val) {
+ default:
+ LOG_WRN("No sub-board defined");
+ break;
+ case FW_SUB_BOARD_1:
+ sb = NISSA_SB_C_A;
+ LOG_INF("SB: USB type C, USB type A");
+ break;
+
+ case FW_SUB_BOARD_2:
+ sb = NISSA_SB_C_LTE;
+ LOG_INF("SB: USB type C, WWAN LTE");
+ break;
+
+ case FW_SUB_BOARD_3:
+ sb = NISSA_SB_HDMI_A;
+ LOG_INF("SB: HDMI, USB type A");
+ break;
+ }
+ return sb;
+}
+
+__override void ocpc_get_pid_constants(int *kp, int *kp_div, int *ki,
+ int *ki_div, int *kd, int *kd_div)
+{
+ *kp = 1;
+ *kp_div = 32;
+ *ki = 0;
+ *ki_div = 1;
+ *kd = 0;
+ *kd_div = 1;
+}
+
+#ifdef CONFIG_PLATFORM_EC_CHARGER_SM5803
+/*
+ * Called by USB-PD code to determine whether a given input voltage is
+ * acceptable.
+ */
+__override int pd_is_valid_input_voltage(int mv)
+{
+ int battery_voltage, rv;
+
+ rv = battery_design_voltage(&battery_voltage);
+ if (rv) {
+ LOG_ERR("Unable to get battery design voltage: %d", rv);
+ return true;
+ }
+
+ /*
+ * SM5803 is extremely inefficient in buck-boost mode, when
+ * VBUS ~= VSYS: very high temperatures on the chip and associated
+ * inductor have been observed when sinking normal charge current in
+ * buck-boost mode (but not in buck or boost mode) so we choose to
+ * completely exclude some voltages that are likely to be problematic.
+ *
+ * Nissa devices use either 2S or 3S batteries, for which VBUS will
+ * usually only be near VSYS with a 3S battery and 12V input (picked
+ * from among common supported PD voltages)- 2S can get close to
+ * 9V, but we expect charge current to be low when a 2S battery is
+ * charged to that voltage (because it will be nearly full).
+ *
+ * We assume that any battery with a design voltage above 9V is 3S, and
+ * that other problematic PD voltages (near to, but not exactly 12V)
+ * will rarely occur.
+ */
+ if (battery_voltage > 9000 && mv == 12000) {
+ return false;
+ }
+ return true;
+}
+#endif
+
+/* Trigger shutdown by enabling the Z-sleep circuit */
+__override void board_hibernate_late(void)
+{
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_slp_z), 1);
+ /*
+ * The system should hibernate, but there may be
+ * a small delay, so return.
+ */
+}
diff --git a/zephyr/projects/nissa/src/led.c b/zephyr/program/nissa/src/led.c
index 2617d0092d..2617d0092d 100644
--- a/zephyr/projects/nissa/src/led.c
+++ b/zephyr/program/nissa/src/led.c
diff --git a/zephyr/program/nissa/src/sub_board.c b/zephyr/program/nissa/src/sub_board.c
new file mode 100644
index 0000000000..e8e9648ba6
--- /dev/null
+++ b/zephyr/program/nissa/src/sub_board.c
@@ -0,0 +1,288 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Nissa sub-board hardware configuration */
+
+#include "cros_board_info.h"
+#include "driver/tcpm/tcpci.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "nissa_common.h"
+#include "nissa_hdmi.h"
+#include "task.h"
+#include "usb_charge.h"
+#include "usb_pd.h"
+#include "usbc/usb_muxes.h"
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/pinctrl.h>
+#include <zephyr/init.h>
+#include <zephyr/kernel.h>
+#include <zephyr/sys/printk.h>
+
+#include <ap_power/ap_power.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+#if NISSA_BOARD_HAS_HDMI_SUPPORT
+static void hdmi_power_handler(struct ap_power_ev_callback *cb,
+ struct ap_power_ev_data data)
+{
+ /* Enable VCC on the HDMI port. */
+ const struct gpio_dt_spec *s3_rail =
+ GPIO_DT_FROM_ALIAS(gpio_hdmi_en_odl);
+ /* Connect AP's DDC to sub-board (default is USB-C aux) */
+ const struct gpio_dt_spec *ddc_select =
+ GPIO_DT_FROM_NODELABEL(gpio_hdmi_sel);
+
+ switch (data.event) {
+ case AP_POWER_PRE_INIT:
+ LOG_DBG("Connecting HDMI DDC to sub-board");
+ gpio_pin_set_dt(ddc_select, 1);
+ break;
+ case AP_POWER_STARTUP:
+ LOG_DBG("Enabling HDMI VCC");
+ gpio_pin_set_dt(s3_rail, 1);
+ break;
+ case AP_POWER_SHUTDOWN:
+ LOG_DBG("Disabling HDMI VCC");
+ gpio_pin_set_dt(s3_rail, 0);
+ break;
+ case AP_POWER_HARD_OFF:
+ LOG_DBG("Disconnecting HDMI sub-board DDC");
+ gpio_pin_set_dt(ddc_select, 0);
+ break;
+ default:
+ LOG_ERR("Unhandled HDMI power event %d", data.event);
+ break;
+ }
+}
+
+static void hdmi_hpd_interrupt(const struct device *device,
+ struct gpio_callback *callback,
+ gpio_port_pins_t pins)
+{
+ int state = gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_hpd_odl));
+
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_soc_hdmi_hpd), state);
+ LOG_DBG("HDMI HPD changed state to %d", state);
+}
+
+void nissa_configure_hdmi_rails(void)
+{
+#if DT_NODE_EXISTS(GPIO_DT_FROM_ALIAS(gpio_en_rails_odl))
+ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_rails_odl),
+ GPIO_OUTPUT_INACTIVE | GPIO_OPEN_DRAIN |
+ GPIO_PULL_UP | GPIO_ACTIVE_LOW);
+#endif
+}
+
+void nissa_configure_hdmi_vcc(void)
+{
+ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_hdmi_en_odl),
+ GPIO_OUTPUT_INACTIVE | GPIO_OPEN_DRAIN |
+ GPIO_ACTIVE_LOW);
+}
+
+__overridable void nissa_configure_hdmi_power_gpios(void)
+{
+ nissa_configure_hdmi_rails();
+}
+
+#ifdef CONFIG_SOC_IT8XXX2
+/*
+ * On it8xxx2, the below condition will break the EC to enter deep doze mode
+ * (b:237717730):
+ * Enhance i2c (GPE0/E7, GPH1/GPH2 or GPA4/GPA5) is enabled and its clock and
+ * data pins aren't both at high level.
+ *
+ * Since HDMI+type A SKU doesn't use i2c4, disable it for better power number.
+ */
+#define I2C4_NODE DT_NODELABEL(i2c4)
+#if DT_NODE_EXISTS(I2C4_NODE)
+PINCTRL_DT_DEFINE(I2C4_NODE);
+
+/* disable i2c4 alternate function */
+static void soc_it8xxx2_disable_i2c4_alt(void)
+{
+ const struct pinctrl_dev_config *pcfg =
+ PINCTRL_DT_DEV_CONFIG_GET(I2C4_NODE);
+
+ pinctrl_apply_state(pcfg, PINCTRL_STATE_SLEEP);
+}
+#endif /* DT_NODE_EXISTS(I2C4_NODE) */
+#endif /* CONFIG_SOC_IT8XXX2 */
+#endif /* NISSA_BOARD_HAS_HDMI_SUPPORT */
+
+static void lte_power_handler(struct ap_power_ev_callback *cb,
+ struct ap_power_ev_data data)
+{
+ /* Enable rails for S5 */
+ const struct gpio_dt_spec *s5_rail =
+ GPIO_DT_FROM_ALIAS(gpio_en_sub_s5_rails);
+ switch (data.event) {
+ case AP_POWER_PRE_INIT:
+ LOG_DBG("Enabling LTE sub-board power rails");
+ gpio_pin_set_dt(s5_rail, 1);
+ break;
+ case AP_POWER_HARD_OFF:
+ LOG_DBG("Disabling LTE sub-board power rails");
+ gpio_pin_set_dt(s5_rail, 0);
+ break;
+ default:
+ LOG_ERR("Unhandled LTE power event %d", data.event);
+ break;
+ }
+}
+
+/**
+ * Configure GPIOs (and other pin functions) that vary with present sub-board.
+ *
+ * The functions of some pins vary according to which sub-board is present
+ * (indicated by CBI fw_config); this function configures them according to the
+ * needs of the present sub-board.
+ */
+static void nereid_subboard_config(void)
+{
+ enum nissa_sub_board_type sb = nissa_get_sb_type();
+ static struct ap_power_ev_callback power_cb;
+
+ /*
+ * USB-A port: current limit output is configured by default and unused
+ * if this port is not present. VBUS enable must be configured if
+ * needed and is controlled by the usba-port-enable-pins driver.
+ */
+ if (sb == NISSA_SB_C_A || sb == NISSA_SB_HDMI_A ||
+ sb == NISSA_SB_NONE) {
+ /*
+ * Configure VBUS enable, retaining current value.
+ * SB_NONE indicates missing fw_config; it's safe to enable VBUS
+ * control in this case since all that will happen is we turn
+ * off power to LTE, and it's useful to allow USB-A to work in
+ * such a configuration.
+ */
+ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_usb_a1_vbus),
+ GPIO_OUTPUT);
+ } else {
+ /* Turn off unused pins */
+ gpio_pin_configure_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_sub_usb_a1_ilimit_sdp),
+ GPIO_DISCONNECTED);
+ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_usb_a1_vbus),
+ GPIO_DISCONNECTED);
+ /* Disable second USB-A port enable GPIO */
+ __ASSERT(USB_PORT_ENABLE_COUNT == 2,
+ "USB A port count != 2 (%d)", USB_PORT_ENABLE_COUNT);
+ usb_port_enable[1] = -1;
+ }
+ /*
+ * USB-C port: the default configuration has I2C on the I2C pins,
+ * but the interrupt line needs to be configured.
+ */
+#if CONFIG_USB_PD_PORT_MAX_COUNT > 1
+ if (sb == NISSA_SB_C_A || sb == NISSA_SB_C_LTE) {
+ /* Configure interrupt input */
+ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl),
+ GPIO_INPUT | GPIO_PULL_UP);
+ } else {
+ /* Port doesn't exist, doesn't need muxing */
+ USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_1_no_mux);
+ }
+#endif
+
+ switch (sb) {
+#if NISSA_BOARD_HAS_HDMI_SUPPORT
+ case NISSA_SB_HDMI_A: {
+ /*
+ * HDMI: two outputs control power which must be configured to
+ * non-default settings, and HPD must be forwarded to the AP
+ * on another output pin.
+ */
+ const struct gpio_dt_spec *hpd_gpio =
+ GPIO_DT_FROM_ALIAS(gpio_hpd_odl);
+ static struct gpio_callback hdmi_hpd_cb;
+ int rv, irq_key;
+
+ nissa_configure_hdmi_power_gpios();
+
+#if CONFIG_SOC_IT8XXX2 && DT_NODE_EXISTS(I2C4_NODE)
+ /* disable i2c4 alternate function for better power number */
+ soc_it8xxx2_disable_i2c4_alt();
+#endif
+
+ /*
+ * Control HDMI power according to AP power state. Some events
+ * won't do anything if the corresponding pin isn't configured,
+ * but that's okay.
+ */
+ ap_power_ev_init_callback(
+ &power_cb, hdmi_power_handler,
+ AP_POWER_PRE_INIT | AP_POWER_HARD_OFF |
+ AP_POWER_STARTUP | AP_POWER_SHUTDOWN);
+ ap_power_ev_add_callback(&power_cb);
+
+ /*
+ * Configure HPD input from sub-board; it's inverted by a buffer
+ * on the sub-board.
+ */
+ gpio_pin_configure_dt(hpd_gpio, GPIO_INPUT | GPIO_ACTIVE_LOW);
+ /* Register interrupt handler for HPD changes */
+ gpio_init_callback(&hdmi_hpd_cb, hdmi_hpd_interrupt,
+ BIT(hpd_gpio->pin));
+ gpio_add_callback(hpd_gpio->port, &hdmi_hpd_cb);
+ rv = gpio_pin_interrupt_configure_dt(hpd_gpio,
+ GPIO_INT_EDGE_BOTH);
+ __ASSERT(rv == 0,
+ "HPD interrupt configuration returned error %d", rv);
+ /*
+ * Run the HPD handler once to ensure output is in sync.
+ * Lock interrupts to ensure that we don't cause desync if an
+ * HPD interrupt comes in between the internal read of the input
+ * and write to the output.
+ */
+ irq_key = irq_lock();
+ hdmi_hpd_interrupt(hpd_gpio->port, &hdmi_hpd_cb,
+ BIT(hpd_gpio->pin));
+ irq_unlock(irq_key);
+ break;
+ }
+#endif
+ case NISSA_SB_C_LTE:
+ /*
+ * LTE: Set up callbacks for enabling/disabling
+ * sub-board power on S5 state.
+ */
+ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_sub_s5_rails),
+ GPIO_OUTPUT_INACTIVE);
+ /* Control LTE power when CPU entering or
+ * exiting S5 state.
+ */
+ ap_power_ev_init_callback(&power_cb, lte_power_handler,
+ AP_POWER_HARD_OFF |
+ AP_POWER_PRE_INIT);
+ ap_power_ev_add_callback(&power_cb);
+ break;
+
+ default:
+ break;
+ }
+}
+DECLARE_HOOK(HOOK_INIT, nereid_subboard_config, HOOK_PRIO_POST_FIRST);
+
+/*
+ * Enable interrupts
+ */
+static void board_init(void)
+{
+ /*
+ * Enable USB-C interrupts.
+ */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0));
+#if CONFIG_USB_PD_PORT_MAX_COUNT > 1
+ if (board_get_usb_pd_port_count() == 2)
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1));
+#endif
+}
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/program/nissa/xivu/cbi.dtsi b/zephyr/program/nissa/xivu/cbi.dtsi
new file mode 100644
index 0000000000..72f83c28a4
--- /dev/null
+++ b/zephyr/program/nissa/xivu/cbi.dtsi
@@ -0,0 +1,133 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ /* Xivu-specific fw_config fields. */
+ nissa-fw-config {
+ /*
+ * FW_CONFIG field to enable WFC or not.
+ */
+ wfc {
+ enum-name = "FW_WFC";
+ start = <0>;
+ size = <1>;
+
+ wfc-mipi {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_WFC_MIPI";
+ value = <0>;
+ };
+ wfc-absent {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_WFC_ABSENT";
+ value = <1>;
+ };
+ };
+
+ /*
+ * FW_CONFIG field to enable stylus or not.
+ */
+ stylus {
+ enum-name = "FW_STYLUS";
+ start = <1>;
+ size = <1>;
+
+ stylus-present {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_STYLUS_PRESENT";
+ value = <0>;
+ };
+ stylus-absent {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_STYLUS_ABSENT";
+ value = <1>;
+ };
+ };
+ /*
+ * FW_CONFIG field to indicate which sub-board
+ * is attached.
+ */
+ sub-board {
+ enum-name = "FW_SUB_BOARD";
+ start = <2>;
+ size = <2>;
+
+ sub-board-1 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_SUB_BOARD_1";
+ value = <0>;
+ };
+ sub-board-2 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_SUB_BOARD_2";
+ value = <1>;
+ };
+ sub-board-3 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_SUB_BOARD_3";
+ value = <2>;
+ };
+ };
+
+/delete-node/ fan;
+ };
+
+ /* Xivu-specific ssfc fields. */
+ cbi-ssfc {
+ compatible = "cros-ec,cbi-ssfc";
+ /*
+ * SSFC field to identify LID motion sensor.
+ */
+ lid-sensor {
+ enum-name = "LID_SENSOR";
+ size = <2>;
+
+ lid_sensor_none: none {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <0>;
+ default;
+ };
+
+ lid_sensor_lis2dw12: lis2dw12 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <1>;
+ default;
+ };
+ lid_sensor_bma422: bma422 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <2>;
+ };
+ };
+ /*
+ * SSFC field to identify BASE motion sensor.
+ */
+ base-sensor {
+ enum-name = "BASE_SENSOR";
+ size = <2>;
+
+ base_sensor_none: none {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <0>;
+ default;
+ };
+ base_sensor_lsm6dso: lsm6dso {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <1>;
+ default;
+ };
+ base_sensor_bmi323: bmi323 {
+ compatible = "cros-ec,cbi-ssfc-value";
+ status = "okay";
+ value = <2>;
+ };
+ };
+ };
+
+};
diff --git a/zephyr/projects/nissa/xivu/generated.dtsi b/zephyr/program/nissa/xivu/generated.dtsi
index 383054adf8..383054adf8 100644
--- a/zephyr/projects/nissa/xivu/generated.dtsi
+++ b/zephyr/program/nissa/xivu/generated.dtsi
diff --git a/zephyr/projects/nissa/xivu/keyboard.dtsi b/zephyr/program/nissa/xivu/keyboard.dtsi
index 5248c4aaff..5248c4aaff 100644
--- a/zephyr/projects/nissa/xivu/keyboard.dtsi
+++ b/zephyr/program/nissa/xivu/keyboard.dtsi
diff --git a/zephyr/program/nissa/xivu/led_pins.dtsi b/zephyr/program/nissa/xivu/led_pins.dtsi
new file mode 100644
index 0000000000..e7efa3e96c
--- /dev/null
+++ b/zephyr/program/nissa/xivu/led_pins.dtsi
@@ -0,0 +1,84 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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_led_y_c0: pwm_led_y_c0 {
+ pwms = <&pwm2 0 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+ pwm_led_w_c0: pwm_led_w_c0 {
+ pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+ pwm_led_y_c1: pwm_led_y_c1 {
+ pwms = <&pwm6 0 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+ pwm_led_w_c1: pwm_led_w_c1 {
+ pwms = <&pwm1 0 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+ };
+
+ pwm-led-pins {
+ compatible = "cros-ec,pwm-led-pins";
+
+ color_off: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pwms = <&pwm_led_y_c0 &pwm_led_y_c1
+ &pwm_led_w_c0 &pwm_led_w_c1>;
+ led-values = <0 0 0 0>;
+ };
+
+ color_amber: color-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pwms = <&pwm_led_y_c0 &pwm_led_y_c1
+ &pwm_led_w_c0 &pwm_led_w_c1>;
+ led-values = <50 50 0 0>;
+ };
+
+ color_white: color-white {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-pwms = <&pwm_led_y_c0 &pwm_led_y_c1
+ &pwm_led_w_c0 &pwm_led_w_c1>;
+ led-values = <0 0 50 50>;
+ };
+ };
+};
+
+/* LED2 */
+&pwm0 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm0_gpc3>;
+ pinctrl-names = "default";
+};
+
+/* LED3 */
+&pwm1 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm1_gpc2>;
+ pinctrl-names = "default";
+};
+
+/* LED1 */
+&pwm2 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
+
+/* LED0 */
+&pwm6 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm6_gpc0>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/nissa/xivu/led_policy.dtsi b/zephyr/program/nissa/xivu/led_policy.dtsi
index 562e361ec5..562e361ec5 100644
--- a/zephyr/projects/nissa/xivu/led_policy.dtsi
+++ b/zephyr/program/nissa/xivu/led_policy.dtsi
diff --git a/zephyr/program/nissa/xivu/motionsense.dtsi b/zephyr/program/nissa/xivu/motionsense.dtsi
new file mode 100644
index 0000000000..fd82aa6ae2
--- /dev/null
+++ b/zephyr/program/nissa/xivu/motionsense.dtsi
@@ -0,0 +1,252 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/motionsense/utils.h>
+
+
+/ {
+ aliases {
+ /*
+ * Interrupt bindings for sensor devices.
+ */
+ lsm6dso-int = &base_accel;
+ lis2dw12-int = &lid_accel;
+ bmi3xx-int = &base_accel;
+ bma4xx-int = &lid_accel;
+ };
+
+ /*
+ * Declare mutexes used by sensor drivers.
+ * A mutex node is used to create an instance of mutex_t.
+ * A mutex node is referenced by a sensor node if the
+ * corresponding sensor driver needs to use the
+ * instance of the mutex.
+ */
+ motionsense-mutex {
+ compatible = "cros-ec,motionsense-mutex";
+ lid_mutex: lid-mutex {
+ };
+
+ lid_mutex_bma422: bma422-mutex {
+ };
+
+ base_mutex: base-mutex {
+ };
+
+ base_mutex_bmi323: bmi323-mutex {
+ };
+ };
+
+ /* Rotation matrix used by drivers. */
+ motionsense-rotation-ref {
+ compatible = "cros-ec,motionsense-rotation-ref";
+ lid_rot_ref: lid-rotation-ref {
+ mat33 = <0 1 0
+ 1 0 0
+ 0 0 (-1)>;
+ };
+
+ base_rot_ref: base-rotation-ref {
+ mat33 = <0 1 0
+ (-1) 0 0
+ 0 0 1>;
+ };
+
+ lid_rot_bma422: lid-rotation-bma {
+ mat33 = <(-1) 0 0
+ 0 1 0
+ 0 0 (-1)>;
+ };
+
+ base_rot_ref_bmi: base-rotation-ref-bmi {
+ mat33 = <(-1) 0 0
+ 0 (-1) 0
+ 0 0 1>;
+ };
+ };
+
+ /*
+ * Driver specific data. A driver-specific data can be shared with
+ * different motion sensors while they are using the same driver.
+ *
+ * If a node's compatible starts with "cros-ec,accelgyro-", it is for
+ * a common structure defined in accelgyro.h.
+ * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
+ * "struct als_drv_data_t" in accelgyro.h
+ */
+ motionsense-sensor-data {
+ lsm6dso_accel_data: lsm6dso-accel-drv-data {
+ compatible = "cros-ec,drvdata-lsm6dso";
+ status = "okay";
+ };
+
+ lsm6dso_gyro_data: lsm6dso-gyro-drv-data {
+ compatible = "cros-ec,drvdata-lsm6dso";
+ status = "okay";
+ };
+
+ lis2dw12_data: lis2dw12-drv-data {
+ compatible = "cros-ec,drvdata-lis2dw12";
+ status = "okay";
+ };
+
+ bma422_data: bma4xx-drv-data {
+ compatible = "cros-ec,drvdata-bma4xx";
+ status = "okay";
+ };
+
+ bmi323_data: bmi323-drv-data {
+ compatible = "cros-ec,drvdata-bmi3xx";
+ status = "okay";
+ };
+ };
+
+ /*
+ * List of motion sensors that creates motion_sensors array.
+ * The nodelabel "lid_accel" and "base_accel" are used to indicate
+ * motion sensor IDs for lid angle calculation.
+ * TODO(b/238139272): The first entries of the array must be
+ * accelerometers,then gyroscope. Fix this dependency in the DTS
+ * processing which makes the devicetree entries independent.
+ */
+ motionsense-sensor {
+ lid_accel: lid-accel {
+ compatible = "cros-ec,lis2dw12";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&lid_rot_ref>;
+ default-range = <2>;
+ drv-data = <&lis2dw12_data>;
+ i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS";
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_accel: base-accel {
+ compatible = "cros-ec,lsm6dso-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&lsm6dso_accel_data>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_gyro: base-gyro {
+ compatible = "cros-ec,lsm6dso-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */
+ drv-data = <&lsm6dso_gyro_data>;
+ };
+ };
+
+ motionsense-sensor-alt {
+ alt_lid_accel: alt-lid-accel {
+ compatible = "cros-ec,bma4xx";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex_bma422>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&lid_rot_bma422>;
+ default-range = <2>;
+ drv-data = <&bma422_data>;
+ i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY";
+ alternate-for = <&lid_accel>;
+ alternate-ssfc-indicator = <&lid_sensor_bma422>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ alt_base_accel: alt-base-accel {
+ compatible = "cros-ec,bmi3xx-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex_bmi323>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref_bmi>;
+ drv-data = <&bmi323_data>;
+ alternate-for = <&base_accel>;
+ alternate-ssfc-indicator = <&base_sensor_bmi323>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ alt_base_gyro: alt-base-gyro {
+ compatible = "cros-ec,bmi3xx-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex_bmi323>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref_bmi>;
+ drv-data = <&bmi323_data>;
+ alternate-for = <&base_gyro>;
+ alternate-ssfc-indicator = <&base_sensor_bmi323>;
+ };
+ };
+
+ motionsense-sensor-info {
+ compatible = "cros-ec,motionsense-sensor-info";
+
+ /*
+ * list of GPIO interrupts that have to
+ * be enabled at initial stage
+ */
+ sensor-irqs = <&int_imu>;
+ /* list of sensors in force mode */
+ accel-force-mode-sensors = <&lid_accel>;
+ };
+};
diff --git a/zephyr/program/nissa/xivu/overlay.dtsi b/zephyr/program/nissa/xivu/overlay.dtsi
new file mode 100644
index 0000000000..402f0e2f2f
--- /dev/null
+++ b/zephyr/program/nissa/xivu/overlay.dtsi
@@ -0,0 +1,383 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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>
+#include <dt-bindings/usbc_mux.h>
+#include <dt-bindings/usb_pd_tcpm.h>
+
+/ {
+ aliases {
+ gpio-cbi-wp = &gpio_ec_cbi_wp;
+ gpio-wp = &gpio_ec_wp_odl;
+ int-wp = &int_wp_l;
+ gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ };
+
+ ec-console {
+ compatible = "ec-console";
+ disabled = "events", "lpc", "hostcmd";
+ };
+
+ batteries {
+ default_battery: smp_c31n2005 {
+ compatible = "smp,c31n2005", "battery-smart";
+ };
+ };
+
+ hibernate-wake-pins {
+ compatible = "cros-ec,hibernate-wake-pins";
+ wakeup-irqs = <
+ &int_power_button
+ &int_lid_open
+ >;
+ };
+
+ gpio-interrupts {
+ compatible = "cros-ec,gpio-interrupts";
+
+ int_power_button: power_button {
+ irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "power_button_interrupt";
+ };
+ int_wp_l: wp_l {
+ irq-pin = <&gpio_ec_wp_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "switch_interrupt";
+ };
+ int_lid_open: lid_open {
+ irq-pin = <&gpio_lid_open>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "lid_interrupt";
+ };
+ int_tablet_mode: tablet_mode {
+ irq-pin = <&gpio_tablet_mode_l>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "gmr_tablet_switch_isr";
+ };
+ int_imu: ec_imu {
+ irq-pin = <&gpio_imu_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "motion_interrupt";
+ };
+ int_lid_accel: ec_lid_accel {
+ irq-pin = <&gpio_acc_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "lid_accel_interrupt";
+ };
+ int_vol_down: vol_down {
+ irq-pin = <&gpio_voldn_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_vol_up: vol_up {
+ irq-pin = <&gpio_volup_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "button_interrupt";
+ };
+ int_usb_c0: usb_c0 {
+ irq-pin = <&gpio_usb_c0_int_odl>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_interrupt";
+ };
+ int_usb_c1: usb_c1 {
+ irq-pin = <&gpio_sb_1>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_interrupt";
+ };
+ };
+
+ named-gpios {
+ gpio_sb_1: sb-1 {
+ gpios = <&gpio0 2 GPIO_PULL_UP>;
+ no-auto-init;
+ };
+
+ gpio_sb_2: sb-2 {
+ gpios = <&gpiod 4 GPIO_OUTPUT>;
+ no-auto-init;
+ };
+
+ /*
+ * 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.
+ */
+ gpio_sb_3: sb-3 {
+ gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>;
+ no-auto-init;
+ };
+ gpio_sb_4: sb-4 {
+ gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ no-auto-init;
+ };
+ };
+
+ /*
+ * Aliases used for sub-board GPIOs.
+ */
+ aliases {
+ /*
+ * Input GPIO when used with type-C port 1
+ */
+ gpio-usb-c1-int-odl = &gpio_sb_1;
+ gpio-en-rails-odl = &gpio_sb_1;
+ /*
+ * Sub-board with type A USB, enable.
+ */
+ gpio-en-usb-a1-vbus = &gpio_sb_2;
+ /*
+ * Enable S5 rails for LTE sub-board
+ */
+ gpio-en-sub-s5-rails = &gpio_sb_2;
+ };
+
+ temp_memory: memory {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_1>;
+ };
+ temp_ambient: ambient {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_2>;
+ };
+ temp_charger1: charger1 {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_3>;
+ };
+ temp_charger2: charger2 {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_4>;
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ memory {
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ temp_host_release_halt = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_memory>;
+ };
+ ambient {
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ temp_host_release_halt = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_ambient>;
+ };
+ charger1 {
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ temp_host_release_halt = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_charger1>;
+ };
+ charger2 {
+ temp_host_high = <85>;
+ temp_host_halt = <90>;
+ temp_host_release_high = <80>;
+ temp_host_release_halt = <80>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_charger2>;
+ };
+ };
+
+ usba {
+ compatible = "cros-ec,usba-port-enable-pins";
+ /*
+ * sb_2 is only configured as GPIO when USB-A1 is present,
+ * but it's still safe to control when disabled.
+ *
+ * ILIM_SEL pins are referred to by legacy enum name,
+ * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
+ * sub-boards that don't have USB-A so is safe to control
+ * regardless of system configuration.
+ */
+ enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
+ status = "okay";
+ };
+
+ usbc {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port0@0 {
+ compatible = "named-usbc-port";
+ reg = <0>;
+ bc12 = <&bc12_port0>;
+ chg = <&chg_port0>;
+ tcpc = <&tcpc_port0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_0>;
+ };
+ };
+ port0-muxes {
+ virtual_mux_0: virtual-mux-0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ /*
+ * TODO(b:211693800): port1 may not be present on some
+ * sub-boards.
+ */
+ port1@1 {
+ compatible = "named-usbc-port";
+ reg = <1>;
+ bc12 = <&bc12_port1>;
+ chg = <&chg_port1>;
+ tcpc = <&tcpc_port1>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_1 &anx7483_mux_1>;
+ };
+ usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux {
+ compatible = "cros-ec,usb-mux-chain";
+ alternative-chain;
+ usb-muxes = <&virtual_mux_1>;
+ };
+ };
+ port1-muxes {
+ virtual_mux_1: virtual-mux-1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ };
+
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios =
+ <&gpio8 5 0>,
+ <&gpio3 6 0>,
+ <&gpiod 7 0>,
+ <&gpio6 0 0>,
+ <&gpiof 2 0>,
+ <&gpiof 3 0>;
+ };
+};
+
+&thermistor_3V3_51K1_47K_4050B {
+ status = "okay";
+};
+
+&adc_ec_vsense_pp3300_s5 {
+ /*
+ * Voltage divider on input has 47k upper and 220k lower legs with
+ * 2714 mV full-scale reading on the ADC. Apply the largest possible
+ * multiplier (without overflowing int32) to get the best possible
+ * approximation of the actual ratio, but derate by a factor of two to
+ * ensure unexpectedly high values won't overflow.
+ */
+ mul = <(791261 / 2)>;
+ div = <(651975 / 2)>;
+};
+
+/* Set bus speeds for I2C */
+&i2c0_0 {
+ label = "I2C_EEPROM";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+};
+
+&i2c1_0 {
+ label = "I2C_SENSOR";
+ clock-frequency = <I2C_BITRATE_FAST>;
+};
+
+&i2c3_0 {
+ label = "I2C_USB_C0_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ /*
+ * BC1.2 interrupt is shared with TCPC, so
+ * IRQ is not specified here and handled by
+ * usb_c0_interrupt.
+ */
+ };
+
+ chg_port0: isl923x@9 {
+ compatible = "intersil,isl923x";
+ status = "okay";
+ reg = <0x9>;
+ };
+
+ tcpc_port0: raa489000@22 {
+ compatible = "renesas,raa489000";
+ reg = <0x22>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_VBUS_MONITOR)>;
+ };
+};
+
+&i2c5_1 {
+ label = "I2C_SUB_C1_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+
+ bc12_port1: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ };
+
+ chg_port1: isl923x@9 {
+ compatible = "intersil,isl923x";
+ status = "okay";
+ reg = <0x9>;
+ };
+
+ tcpc_port1: raa489000@22 {
+ compatible = "renesas,raa489000";
+ reg = <0x22>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_VBUS_MONITOR)>;
+ };
+
+ anx7483_mux_1: anx7483-mux-1@3e {
+ compatible = "analogix,anx7483";
+ reg = <0x3e>;
+ board-set = "anx7483_set_default_tuning";
+ flags = <USB_MUX_FLAG_RESETS_IN_G3>;
+ };
+};
+
+&i2c7_0 {
+ label = "I2C_BATTERY";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+};
+
+&pwm6 {
+ status = "okay";
+ pinctrl-0 = <&pwm6_gpc0>;
+ pinctrl-names = "default";
+};
+
+/* host interface */
+&espi0 {
+ status = "okay";
+ pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/nissa/xivu/power_signals.dtsi b/zephyr/program/nissa/xivu/power_signals.dtsi
index 1d2b23069d..1d2b23069d 100644
--- a/zephyr/projects/nissa/xivu/power_signals.dtsi
+++ b/zephyr/program/nissa/xivu/power_signals.dtsi
diff --git a/zephyr/program/nissa/xivu/project.conf b/zephyr/program/nissa/xivu/project.conf
new file mode 100644
index 0000000000..d20c490c20
--- /dev/null
+++ b/zephyr/program/nissa/xivu/project.conf
@@ -0,0 +1,25 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_BOARD_XIVU=y
+CONFIG_PLATFORM_EC_OCPC=y
+
+CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=10
+
+# LED
+CONFIG_PLATFORM_EC_LED_COMMON=n
+CONFIG_PLATFORM_EC_LED_DT=y
+
+# USBC
+CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000
+
+# Battery
+CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y
+
+# Montionsense
+CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
+CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
+CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y
diff --git a/zephyr/projects/nissa/xivu/project.overlay b/zephyr/program/nissa/xivu/project.overlay
index a7c5b7e9e7..a7c5b7e9e7 100644
--- a/zephyr/projects/nissa/xivu/project.overlay
+++ b/zephyr/program/nissa/xivu/project.overlay
diff --git a/zephyr/program/nissa/xivu/src/charger.c b/zephyr/program/nissa/xivu/src/charger.c
new file mode 100644
index 0000000000..a3d9d16443
--- /dev/null
+++ b/zephyr/program/nissa/xivu/src/charger.c
@@ -0,0 +1,69 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "charger.h"
+#include "charger/isl923x_public.h"
+#include "console.h"
+#include "extpower.h"
+#include "nissa_common.h"
+#include "usb_pd.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+int extpower_is_present(void)
+{
+ int port;
+ int rv;
+ bool acok;
+
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
+ rv = raa489000_is_acok(port, &acok);
+ if ((rv == EC_SUCCESS) && acok)
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ * Xivu does not have a GPIO indicating whether extpower is present,
+ * so detect using the charger(s).
+ */
+__override void board_check_extpower(void)
+{
+ static int last_extpower_present;
+ int extpower_present_p0 = 0;
+ int extpower_present_p1 = 0;
+
+ int extpower_present = extpower_is_present();
+
+ if (last_extpower_present ^ extpower_present)
+ extpower_handle_update(extpower_present);
+
+ last_extpower_present = extpower_present;
+
+ if (pd_is_connected(0))
+ extpower_present_p0 = extpower_is_present();
+ else if (pd_is_connected(1))
+ extpower_present_p1 = extpower_is_present();
+
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_acok_otg_c0),
+ extpower_present_p0);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_acok_otg_c1),
+ extpower_present_p1);
+}
+
+__override void board_hibernate(void)
+{
+ /* Shut down the chargers */
+ if (board_get_usb_pd_port_count() == 2)
+ raa489000_hibernate(CHARGER_SECONDARY, true);
+ raa489000_hibernate(CHARGER_PRIMARY, true);
+ LOG_INF("Charger(s) hibernated");
+ cflush();
+}
diff --git a/zephyr/program/nissa/xivu/src/form_factor.c b/zephyr/program/nissa/xivu/src/form_factor.c
new file mode 100644
index 0000000000..2ce6f5418d
--- /dev/null
+++ b/zephyr/program/nissa/xivu/src/form_factor.c
@@ -0,0 +1,78 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "accelgyro.h"
+#include "button.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "driver/accel_bma4xx.h"
+#include "driver/accel_lis2dw12_public.h"
+#include "driver/accelgyro_bmi323.h"
+#include "driver/accelgyro_lsm6dso.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "motion_sense.h"
+#include "motionsense_sensors.h"
+#include "nissa_common.h"
+#include "tablet_mode.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+static bool use_alt_sensor;
+static bool use_alt_lid_accel;
+
+void motion_interrupt(enum gpio_signal signal)
+{
+ if (use_alt_sensor)
+ bmi3xx_interrupt(signal);
+ else
+ lsm6dso_interrupt(signal);
+}
+
+void lid_accel_interrupt(enum gpio_signal signal)
+{
+ if (use_alt_lid_accel)
+ bma4xx_interrupt(signal);
+ else
+ lis2dw12_interrupt(signal);
+}
+
+static void form_factor_init(void)
+{
+ if (cros_cbi_ssfc_check_match(
+ CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_bmi323)))) {
+ use_alt_sensor = true;
+ MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel);
+ MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro);
+ ccprints("BASE ACCEL IS BMI323");
+ } else if (cros_cbi_ssfc_check_match(CBI_SSFC_VALUE_ID(
+ DT_NODELABEL(base_sensor_lsm6dso)))) {
+ use_alt_sensor = false;
+ ccprints("BASE ACCEL IS LSM6DSO");
+ } else {
+ use_alt_sensor = false;
+ ccprints("no motionsense");
+ }
+
+ if (cros_cbi_ssfc_check_match(
+ CBI_SSFC_VALUE_ID(DT_NODELABEL(lid_sensor_bma422)))) {
+ use_alt_lid_accel = true;
+ MOTIONSENSE_ENABLE_ALTERNATE(alt_lid_accel);
+ ccprints("LID SENSOR IS BMA422");
+ } else if (cros_cbi_ssfc_check_match(CBI_SSFC_VALUE_ID(
+ DT_NODELABEL(lid_sensor_lis2dw12)))) {
+ use_alt_lid_accel = false;
+ ccprints("LID SENSOR IS LIS2DW12");
+ } else {
+ use_alt_lid_accel = false;
+ ccprints("no lid sensor");
+ }
+
+ motion_sensors_check_ssfc();
+}
+DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/projects/nissa/xivu/src/keyboard.c b/zephyr/program/nissa/xivu/src/keyboard.c
index ef799fb1d2..ef799fb1d2 100644
--- a/zephyr/projects/nissa/xivu/src/keyboard.c
+++ b/zephyr/program/nissa/xivu/src/keyboard.c
diff --git a/zephyr/program/nissa/xivu/src/usbc.c b/zephyr/program/nissa/xivu/src/usbc.c
new file mode 100644
index 0000000000..174eb07c60
--- /dev/null
+++ b/zephyr/program/nissa/xivu/src/usbc.c
@@ -0,0 +1,343 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_state_v2.h"
+#include "chipset.h"
+#include "driver/charger/isl923x_public.h"
+#include "driver/retimer/anx7483_public.h"
+#include "driver/tcpm/raa489000.h"
+#include "driver/tcpm/tcpci.h"
+#include "hooks.h"
+#include "nissa_common.h"
+#include "system.h"
+#include "temp_sensor/temp_sensor.h"
+#include "usb_mux.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+int board_is_sourcing_vbus(int port)
+{
+ int regval;
+
+ tcpc_read(port, TCPC_REG_POWER_STATUS, &regval);
+ return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS);
+}
+
+int board_set_active_charge_port(int port)
+{
+ int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
+ int i;
+ int old_port;
+
+ if (!is_real_port && port != CHARGE_PORT_NONE)
+ return EC_ERROR_INVAL;
+
+ old_port = charge_manager_get_active_charge_port();
+
+ LOG_INF("New chg p%d", port);
+
+ /* Disable all ports. */
+ if (port == CHARGE_PORT_NONE) {
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ tcpc_write(i, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_SNK_CTRL_LOW);
+ raa489000_enable_asgate(i, false);
+ }
+
+ return EC_SUCCESS;
+ }
+
+ /* Check if port is sourcing VBUS. */
+ if (board_is_sourcing_vbus(port)) {
+ LOG_WRN("Skip enable p%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ if (i == port)
+ continue;
+
+ if (tcpc_write(i, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_SNK_CTRL_LOW))
+ LOG_WRN("p%d: sink path disable failed.", i);
+ raa489000_enable_asgate(i, false);
+ }
+
+ /*
+ * Stop the charger IC from switching while changing ports. Otherwise,
+ * we can overcurrent the adapter we're switching to. (crbug.com/926056)
+ */
+ if (old_port != CHARGE_PORT_NONE)
+ charger_discharge_on_ac(1);
+
+ /* Enable requested charge port. */
+ if (raa489000_enable_asgate(port, true) ||
+ tcpc_write(port, TCPC_REG_COMMAND,
+ TCPC_REG_COMMAND_SNK_CTRL_HIGH)) {
+ LOG_WRN("p%d: sink path enable failed.", port);
+ charger_discharge_on_ac(0);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ /* Allow the charger IC to begin/continue switching. */
+ charger_discharge_on_ac(0);
+
+ return EC_SUCCESS;
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ uint16_t status = 0;
+ int regval;
+
+ /*
+ * The interrupt line is shared between the TCPC and BC1.2 detector IC.
+ * Therefore, go out and actually read the alert registers to report the
+ * alert status.
+ */
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
+ if (!tcpc_read16(0, TCPC_REG_ALERT, &regval)) {
+ /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */
+ if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0))
+ regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
+
+ if (regval)
+ status |= PD_STATUS_TCPC_ALERT_0;
+ }
+ }
+
+ if (board_get_usb_pd_port_count() == 2 &&
+ !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
+ /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */
+ if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0))
+ regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
+
+ if (regval)
+ status |= PD_STATUS_TCPC_ALERT_1;
+ }
+ }
+
+ return status;
+}
+
+void pd_power_supply_reset(int port)
+{
+ /* Disable VBUS */
+ tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW);
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+/* VBUS_CURRENT_TARGET */
+#define RAA489000_VBUS_CURRENT_TARGET_3_3A 0x68 /* 3.3A */
+
+__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ int rv;
+
+ if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ return;
+
+ int selected_cur = rp == TYPEC_RP_3A0 ?
+ RAA489000_VBUS_CURRENT_TARGET_3_3A :
+ RAA489000_VBUS_CURRENT_TARGET_1_5A;
+
+ rv = tcpc_write16(port, RAA489000_VBUS_CURRENT_TARGET, selected_cur);
+
+ if (rv != EC_SUCCESS) {
+ LOG_WRN("Failed to set source ilimit on port %d to %d: %d",
+ port, selected_cur, rv);
+ }
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ int rv;
+
+ if (port >= CONFIG_USB_PD_PORT_MAX_COUNT)
+ return EC_ERROR_INVAL;
+
+ /* Disable charging. */
+ rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW);
+ if (rv)
+ return rv;
+
+ /* Our policy is not to source VBUS when the AP is off. */
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
+ return EC_ERROR_NOT_POWERED;
+
+ /* Provide Vbus. */
+ rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH);
+ if (rv)
+ return rv;
+
+ rv = raa489000_enable_asgate(port, true);
+ if (rv)
+ return rv;
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
+}
+
+void board_reset_pd_mcu(void)
+{
+ /*
+ * TODO(b:147316511): could send a reset command to the TCPC here
+ * if needed.
+ */
+}
+
+/*
+ * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible
+ * for an interrupt to be lost if one asserts the IRQ, the other does the same
+ * then the first releases it: there will only be one falling edge to trigger
+ * the interrupt, and the line will be held low. We handle this by running a
+ * deferred check after a falling edge to see whether the IRQ is still being
+ * asserted. If it is, we assume an interrupt may have been lost and we need
+ * to poll each chip for events again.
+ */
+#define USBC_INT_POLL_DELAY_US 5000
+
+static void poll_c0_int(void);
+DECLARE_DEFERRED(poll_c0_int);
+static void poll_c1_int(void);
+DECLARE_DEFERRED(poll_c1_int);
+
+static void usbc_interrupt_trigger(int port)
+{
+ schedule_deferred_pd_interrupt(port);
+ usb_charger_task_set_event(port, USB_CHG_EVENT_BC12);
+}
+
+static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio,
+ const struct deferred_data *ud)
+{
+ if (!gpio_pin_get_dt(gpio)) {
+ usbc_interrupt_trigger(port);
+ hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
+ }
+}
+
+static void poll_c0_int(void)
+{
+ poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl),
+ &poll_c0_int_data);
+}
+
+static void poll_c1_int(void)
+{
+ poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl),
+ &poll_c1_int_data);
+}
+
+void usb_interrupt(enum gpio_signal signal)
+{
+ int port;
+ const struct deferred_data *ud;
+
+ if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) {
+ port = 0;
+ ud = &poll_c0_int_data;
+ } else {
+ port = 1;
+ ud = &poll_c1_int_data;
+ }
+ /*
+ * We've just been called from a falling edge, so there's definitely
+ * no lost IRQ right now. Cancel any pending check.
+ */
+ hook_call_deferred(ud, -1);
+ /* Trigger polling of TCPC and BC1.2 in respective tasks */
+ usbc_interrupt_trigger(port);
+ /* Check for lost interrupts in a bit */
+ hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
+}
+
+struct chg_curr_step {
+ int on;
+ int off;
+ int curr_ma;
+};
+
+static const struct chg_curr_step chg_curr_table[] = {
+ { .on = 0, .off = 36, .curr_ma = 2800 },
+ { .on = 46, .off = 36, .curr_ma = 1500 },
+ { .on = 48, .off = 38, .curr_ma = 1000 },
+};
+
+/* All charge current tables must have the same number of levels */
+#define NUM_CHG_CURRENT_LEVELS ARRAY_SIZE(chg_curr_table)
+
+int charger_profile_override(struct charge_state_data *curr)
+{
+ int rv;
+ int chg_temp_c;
+ int current;
+ int thermal_sensor0;
+ static int current_level;
+ static int prev_tmp;
+
+ /*
+ * Precharge must be executed when communication is failed on
+ * dead battery.
+ */
+ if (!(curr->batt.flags & BATT_FLAG_RESPONSIVE))
+ return 0;
+
+ current = curr->requested_current;
+
+ rv = temp_sensor_read(
+ TEMP_SENSOR_ID_BY_DEV(DT_NODELABEL(temp_charger1)),
+ &thermal_sensor0);
+ chg_temp_c = K_TO_C(thermal_sensor0);
+
+ if (rv != EC_SUCCESS)
+ return 0;
+
+ if (chipset_in_state(CHIPSET_STATE_ON)) {
+ if (chg_temp_c < prev_tmp) {
+ if (chg_temp_c <= chg_curr_table[current_level].off)
+ current_level = current_level - 1;
+ } else if (chg_temp_c > prev_tmp) {
+ if (chg_temp_c >= chg_curr_table[current_level + 1].on)
+ current_level = current_level + 1;
+ }
+ /*
+ * Prevent level always minus 0 or over table steps.
+ */
+ if (current_level < 0)
+ current_level = 0;
+ else if (current_level >= NUM_CHG_CURRENT_LEVELS)
+ current_level = NUM_CHG_CURRENT_LEVELS - 1;
+
+ prev_tmp = chg_temp_c;
+ current = chg_curr_table[current_level].curr_ma;
+
+ curr->requested_current = MIN(curr->requested_current, current);
+ }
+ return 0;
+}
+
+enum ec_status charger_profile_override_get_param(uint32_t param,
+ uint32_t *value)
+{
+ return EC_RES_INVALID_PARAM;
+}
+
+enum ec_status charger_profile_override_set_param(uint32_t param,
+ uint32_t value)
+{
+ return EC_RES_INVALID_PARAM;
+}
diff --git a/zephyr/program/nissa/xivur/cbi.dtsi b/zephyr/program/nissa/xivur/cbi.dtsi
new file mode 100644
index 0000000000..112a2a885c
--- /dev/null
+++ b/zephyr/program/nissa/xivur/cbi.dtsi
@@ -0,0 +1,30 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ /* Nivviks-specific fw_config fields. */
+ nissa-fw-config {
+ /*
+ * FW_CONFIG field to describe mainboard orientation in chassis.
+ */
+ base-inversion {
+ enum-name = "FW_BASE_INVERSION";
+ start = <3>;
+ size = <1>;
+
+ inverted {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_BASE_INVERTED";
+ value = <0>;
+ };
+ regular {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_BASE_REGULAR";
+ value = <1>;
+ default;
+ };
+ };
+ };
+};
diff --git a/zephyr/program/nissa/xivur/generated.dtsi b/zephyr/program/nissa/xivur/generated.dtsi
new file mode 100644
index 0000000000..91718302b4
--- /dev/null
+++ b/zephyr/program/nissa/xivur/generated.dtsi
@@ -0,0 +1,291 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * This file is auto-generated - do not edit!
+ */
+
+/ {
+
+ named-adc-channels {
+ compatible = "named-adc-channels";
+
+ adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc {
+ enum-name = "ADC_PP1050_PROC";
+ io-channels = <&adc0 4>;
+ };
+ adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 {
+ enum-name = "ADC_PP3300_S5";
+ io-channels = <&adc0 6>;
+ };
+ adc_temp_sensor_1: temp_sensor_1 {
+ enum-name = "ADC_TEMP_SENSOR_1";
+ io-channels = <&adc0 0>;
+ };
+ adc_temp_sensor_2: temp_sensor_2 {
+ enum-name = "ADC_TEMP_SENSOR_2";
+ io-channels = <&adc0 1>;
+ };
+ adc_temp_sensor_3: temp_sensor_3 {
+ enum-name = "ADC_TEMP_SENSOR_3";
+ io-channels = <&adc0 10>;
+ };
+ };
+
+ named-gpios {
+ compatible = "named-gpios";
+
+ gpio_acc_int_l: acc_int_l {
+ gpios = <&gpio5 0 GPIO_INPUT>;
+ };
+ gpio_all_sys_pwrgd: all_sys_pwrgd {
+ gpios = <&gpioa 7 GPIO_INPUT>;
+ };
+ gpio_ccd_mode_odl: ccd_mode_odl {
+ gpios = <&gpioe 5 GPIO_INPUT>;
+ enum-name = "GPIO_CCD_MODE_ODL";
+ };
+ gpio_cpu_c10_gate_l: cpu_c10_gate_l {
+ gpios = <&gpio6 7 GPIO_INPUT>;
+ };
+ gpio_ec_battery_pres_odl: ec_battery_pres_odl {
+ gpios = <&gpioa 3 GPIO_INPUT>;
+ enum-name = "GPIO_BATT_PRES_ODL";
+ };
+ gpio_ec_cbi_wp: ec_cbi_wp {
+ gpios = <&gpio7 4 GPIO_OUTPUT>;
+ };
+ gpio_ec_edp_bl_en_od: ec_edp_bl_en_od {
+ gpios = <&gpiod 3 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_ENABLE_BACKLIGHT";
+ };
+ gpio_ec_entering_rw: ec_entering_rw {
+ gpios = <&gpio0 3 GPIO_OUTPUT>;
+ enum-name = "GPIO_ENTERING_RW";
+ };
+ gpio_ec_gsc_packet_mode: ec_gsc_packet_mode {
+ gpios = <&gpio7 5 GPIO_OUTPUT>;
+ enum-name = "GPIO_PACKET_MODE_EN";
+ };
+ gpio_ec_kso_02_inv: ec_kso_02_inv {
+ gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
+ };
+ gpio_ec_pch_wake_odl: ec_pch_wake_odl {
+ gpios = <&gpiob 0 GPIO_ODR_LOW>;
+ };
+ gpio_ec_prochot_odl: ec_prochot_odl {
+ gpios = <&gpiof 1 GPIO_ODR_HIGH>;
+ };
+ gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok {
+ gpios = <&gpio6 1 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd {
+ gpios = <&gpioe 4 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_int_odl: ec_soc_int_odl {
+ gpios = <&gpio8 0 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_EC_INT_L";
+ };
+ gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od {
+ gpios = <&gpio7 2 GPIO_ODR_HIGH>;
+ };
+ gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl {
+ gpios = <&gpioc 1 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PCH_PWRBTN_L";
+ };
+ gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l {
+ gpios = <&gpioa 6 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_rtcrst: ec_soc_rtcrst {
+ gpios = <&gpio7 6 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok {
+ gpios = <&gpio3 7 GPIO_OUTPUT>;
+ };
+ gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od {
+ gpios = <&gpioa 4 GPIO_ODR_HIGH>;
+ };
+ gpio_ec_wp_odl: ec_wp_odl {
+ gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ };
+ gpio_en_kb_bl: en_kb_bl {
+ gpios = <&gpioa 0 GPIO_OUTPUT>;
+ enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT";
+ };
+ gpio_en_pp3300_s5: en_pp3300_s5 {
+ gpios = <&gpiob 6 GPIO_OUTPUT>;
+ enum-name = "GPIO_TEMP_SENSOR_POWER";
+ };
+ gpio_en_pp5000_pen_x: en_pp5000_pen_x {
+ gpios = <&gpioe 2 GPIO_OUTPUT>;
+ };
+ gpio_en_pp5000_s5: en_pp5000_s5 {
+ gpios = <&gpio4 0 GPIO_OUTPUT>;
+ };
+ gpio_en_slp_z: en_slp_z {
+ gpios = <&gpioe 1 GPIO_OUTPUT>;
+ };
+ gpio_en_usb_a0_vbus: en_usb_a0_vbus {
+ gpios = <&gpio9 1 GPIO_OUTPUT>;
+ };
+ gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl {
+ gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_POWER_BUTTON_L";
+ };
+ gpio_hdmi_sel: hdmi_sel {
+ gpios = <&gpioc 6 GPIO_OUTPUT>;
+ };
+ gpio_imu_int_l: imu_int_l {
+ gpios = <&gpio5 6 GPIO_INPUT>;
+ };
+ gpio_imvp91_vrrdy_od: imvp91_vrrdy_od {
+ gpios = <&gpio4 3 GPIO_INPUT>;
+ };
+ gpio_lid_open: lid_open {
+ gpios = <&gpiod 2 GPIO_INPUT>;
+ enum-name = "GPIO_LID_OPEN";
+ };
+ gpio_pen_detect_odl: pen_detect_odl {
+ gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od {
+ gpios = <&gpiof 0 GPIO_INPUT>;
+ };
+ gpio_pg_pp5000_s5_od: pg_pp5000_s5_od {
+ gpios = <&gpio4 2 GPIO_INPUT>;
+ };
+ gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l {
+ gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_slp_s0_l: slp_s0_l {
+ gpios = <&gpio9 7 GPIO_INPUT>;
+ };
+ gpio_slp_s3_l: slp_s3_l {
+ gpios = <&gpioa 5 GPIO_INPUT>;
+ };
+ gpio_slp_s4_l: slp_s4_l {
+ gpios = <&gpio7 0 GPIO_INPUT>;
+ };
+ gpio_slp_sus_l: slp_sus_l {
+ gpios = <&gpio6 2 GPIO_INPUT>;
+ };
+ gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp {
+ gpios = <&gpiod 5 GPIO_OUTPUT>;
+ enum-name = "GPIO_USB2_ILIM_SEL";
+ };
+ gpio_sys_rst_odl: sys_rst_odl {
+ gpios = <&gpioc 5 GPIO_ODR_HIGH>;
+ };
+ gpio_tablet_mode_l: tablet_mode_l {
+ gpios = <&gpio9 5 GPIO_INPUT>;
+ enum-name = "GPIO_TABLET_MODE_L";
+ };
+ gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp {
+ gpios = <&gpio8 5 GPIO_OUTPUT>;
+ enum-name = "GPIO_USB1_ILIM_SEL";
+ };
+ gpio_usb_c0_int_odl: usb_c0_int_odl {
+ gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_vccin_aux_vid0: vccin_aux_vid0 {
+ gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_vccin_aux_vid1: vccin_aux_vid1 {
+ gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_voldn_btn_odl: voldn_btn_odl {
+ gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_DOWN_L";
+ };
+ gpio_volup_btn_odl: volup_btn_odl {
+ gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_UP_L";
+ };
+ };
+
+ named-i2c-ports {
+ compatible = "named-i2c-ports";
+
+ i2c_ec_i2c_eeprom: ec_i2c_eeprom {
+ i2c-port = <&i2c0_0>;
+ enum-names = "I2C_PORT_EEPROM";
+ };
+ i2c_ec_i2c_sensor: ec_i2c_sensor {
+ i2c-port = <&i2c1_0>;
+ enum-names = "I2C_PORT_SENSOR";
+ };
+ i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 {
+ i2c-port = <&i2c3_0>;
+ enum-names = "I2C_PORT_USB_C0_TCPC";
+ };
+ i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 {
+ i2c-port = <&i2c5_1>;
+ enum-names = "I2C_PORT_USB_C1_TCPC";
+ };
+ i2c_ec_i2c_batt: ec_i2c_batt {
+ i2c-port = <&i2c7_0>;
+ enum-names = "I2C_PORT_BATTERY";
+ };
+ };
+};
+
+&adc0 {
+ status = "okay";
+ pinctrl-0 = <&adc0_chan0_gp45
+ &adc0_chan1_gp44
+ &adc0_chan4_gp41
+ &adc0_chan6_gp34
+ &adc0_chan10_gpe0>;
+ pinctrl-names = "default";
+};
+
+
+&i2c0_0 {
+ status = "okay";
+ pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
+ pinctrl-names = "default";
+};
+
+&i2c1_0 {
+ status = "okay";
+ pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
+ pinctrl-names = "default";
+};
+
+&i2c3_0 {
+ status = "okay";
+ pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
+ pinctrl-names = "default";
+};
+
+&i2c5_1 {
+ status = "okay";
+ pinctrl-0 = <&i2c5_1_sda_scl_gpf4_f5>;
+ pinctrl-names = "default";
+};
+
+&i2c7_0 {
+ status = "okay";
+ pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
+ pinctrl-names = "default";
+};
+
+&i2c_ctrl0 {
+ status = "okay";
+};
+
+&i2c_ctrl1 {
+ status = "okay";
+};
+
+&i2c_ctrl3 {
+ status = "okay";
+};
+
+&i2c_ctrl5 {
+ status = "okay";
+};
+
+&i2c_ctrl7 {
+ status = "okay";
+};
diff --git a/zephyr/program/nissa/xivur/keyboard.dtsi b/zephyr/program/nissa/xivur/keyboard.dtsi
new file mode 100644
index 0000000000..00610e4e18
--- /dev/null
+++ b/zephyr/program/nissa/xivur/keyboard.dtsi
@@ -0,0 +1,48 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ kblight {
+ compatible = "cros-ec,kblight-pwm";
+ pwms = <&pwm6 6 PWM_HZ(2400) PWM_POLARITY_NORMAL>;
+ };
+};
+
+&pwm6 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm6_gpc0>;
+ pinctrl-names = "default";
+};
+
+&cros_kb_raw {
+ status = "okay";
+ /* No KSO2 (it's inverted and implemented by GPIO) */
+ pinctrl-0 = <
+ &ksi0_gp31
+ &ksi1_gp30
+ &ksi2_gp27
+ &ksi3_gp26
+ &ksi4_gp25
+ &ksi5_gp24
+ &ksi6_gp23
+ &ksi7_gp22
+ &kso00_gp21
+ &kso01_gp20
+ &kso03_gp16
+ &kso04_gp15
+ &kso05_gp14
+ &kso06_gp13
+ &kso07_gp12
+ &kso08_gp11
+ &kso09_gp10
+ &kso10_gp07
+ &kso11_gp06
+ &kso12_gp05
+ &kso13_gp04
+ &kso14_gp82
+ >;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/program/nissa/xivur/motionsense.dtsi b/zephyr/program/nissa/xivur/motionsense.dtsi
new file mode 100644
index 0000000000..6297a07bf5
--- /dev/null
+++ b/zephyr/program/nissa/xivur/motionsense.dtsi
@@ -0,0 +1,166 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/motionsense/utils.h>
+
+
+/ {
+ aliases {
+ /*
+ * Interrupt bindings for sensor devices.
+ */
+ lsm6dso-int = &base_accel;
+ lis2dw12-int = &lid_accel;
+ };
+
+ /*
+ * Declare mutexes used by sensor drivers.
+ * A mutex node is used to create an instance of mutex_t.
+ * A mutex node is referenced by a sensor node if the
+ * corresponding sensor driver needs to use the
+ * instance of the mutex.
+ */
+ motionsense-mutex {
+ compatible = "cros-ec,motionsense-mutex";
+ lid_mutex: lid-mutex {
+ };
+
+ base_mutex: base-mutex {
+ };
+ };
+
+ /* Rotation matrix used by drivers. */
+ motionsense-rotation-ref {
+ compatible = "cros-ec,motionsense-rotation-ref";
+ lid_rot_ref: lid-rotation-ref {
+ mat33 = <(-1) 0 0
+ 0 1 0
+ 0 0 (-1)>;
+ };
+
+ base_rot_ref: base-rot-ref {
+ mat33 = <(-1) 0 0
+ 0 (-1) 0
+ 0 0 1>;
+ };
+
+ base_rot_inverted: base-rotation-inverted {
+ mat33 = <1 0 0
+ 0 (-1) 0
+ 0 0 (-1)>;
+ };
+ };
+
+ /*
+ * Driver specific data. A driver-specific data can be shared with
+ * different motion sensors while they are using the same driver.
+ *
+ * If a node's compatible starts with "cros-ec,accelgyro-", it is for
+ * a common structure defined in accelgyro.h.
+ * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
+ * "struct als_drv_data_t" in accelgyro.h
+ */
+ motionsense-sensor-data {
+ lsm6dso_accel_data: lsm6dso-accel-drv-data {
+ compatible = "cros-ec,drvdata-lsm6dso";
+ status = "okay";
+ };
+
+ lsm6dso_gyro_data: lsm6dso-gyro-drv-data {
+ compatible = "cros-ec,drvdata-lsm6dso";
+ status = "okay";
+ };
+
+ lis2dw12_data: lis2dw12-drv-data {
+ compatible = "cros-ec,drvdata-lis2dw12";
+ status = "okay";
+ };
+ };
+
+ /*
+ * List of motion sensors that creates motion_sensors array.
+ * The nodelabel "lid_accel" and "base_accel" are used to indicate
+ * motion sensor IDs for lid angle calculation.
+ * TODO(b/238139272): The first entries of the array must be
+ * accelerometers,then gyroscope. Fix this dependency in the DTS
+ * processing which makes the devicetree entries independent.
+ */
+ motionsense-sensor {
+ lid_accel: lid-accel {
+ compatible = "cros-ec,lis2dw12";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&lid_rot_ref>;
+ default-range = <2>;
+ drv-data = <&lis2dw12_data>;
+ i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS";
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_accel: base-accel {
+ compatible = "cros-ec,lsm6dso-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ 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_accel_data>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(10000 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_gyro: base-gyro {
+ compatible = "cros-ec,lsm6dso-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&base_mutex>;
+ port = <&i2c_ec_i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */
+ drv-data = <&lsm6dso_gyro_data>;
+ };
+ };
+
+ motionsense-sensor-info {
+ compatible = "cros-ec,motionsense-sensor-info";
+
+ /*
+ * list of GPIO interrupts that have to
+ * be enabled at initial stage
+ */
+ sensor-irqs = <&int_imu>;
+ /* list of sensors in force mode */
+ accel-force-mode-sensors = <&lid_accel>;
+ };
+};
diff --git a/zephyr/projects/nissa/nivviks/overlay.dtsi b/zephyr/program/nissa/xivur/overlay.dtsi
index c2d5e3f24b..c2d5e3f24b 100644
--- a/zephyr/projects/nissa/nivviks/overlay.dtsi
+++ b/zephyr/program/nissa/xivur/overlay.dtsi
diff --git a/zephyr/program/nissa/xivur/power_signals.dtsi b/zephyr/program/nissa/xivur/power_signals.dtsi
new file mode 100644
index 0000000000..1d2b23069d
--- /dev/null
+++ b/zephyr/program/nissa/xivur/power_signals.dtsi
@@ -0,0 +1,220 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ chosen {
+ intel-ap-pwrseq,espi = &espi0;
+ };
+
+ common-pwrseq {
+ compatible = "intel,ap-pwrseq";
+
+ sys-pwrok-delay = <10>;
+ all-sys-pwrgd-timeout = <20>;
+ };
+
+ pwr-en-pp5000-s5 {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "PP5000_S5 enable output to regulator";
+ enum-name = "PWR_EN_PP5000_A";
+ gpios = <&gpio4 0 0>;
+ output;
+ };
+ pwr-en-pp3300-s5 {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "PP3300_S5 enable output to LS";
+ enum-name = "PWR_EN_PP3300_A";
+ gpios = <&gpiob 6 0>;
+ output;
+ };
+ pwr-pg-ec-rsmrst-od {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "RSMRST power good from regulator";
+ enum-name = "PWR_RSMRST";
+ gpios = <&gpio9 4 0>;
+ interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ };
+ pwr-ec-pch-rsmrst-odl {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "RSMRST output to PCH";
+ enum-name = "PWR_EC_PCH_RSMRST";
+ gpios = <&gpioa 6 0>;
+ output;
+ };
+ pwr-slp-s0-l {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SLP_S0_L input from PCH";
+ enum-name = "PWR_SLP_S0";
+ gpios = <&gpio9 7 GPIO_ACTIVE_LOW>;
+ interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ };
+ pwr-slp-s3-l {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SLP_S3_L input from PCH";
+ enum-name = "PWR_SLP_S3";
+ gpios = <&gpioa 5 GPIO_ACTIVE_LOW>;
+ interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ };
+ pwr-slp-sus-l {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SLP_SUS_L input from PCH";
+ enum-name = "PWR_SLP_SUS";
+ gpios = <&gpio6 2 GPIO_ACTIVE_LOW>;
+ interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ };
+ pwr-ec-soc-dsw-pwrok {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "DSW_PWROK output to PCH";
+ enum-name = "PWR_EC_SOC_DSW_PWROK";
+ gpios = <&gpio6 1 0>;
+ output;
+ };
+ pwr-vccst-pwrgd-od {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "VCCST_PWRGD output to PCH";
+ enum-name = "PWR_VCCST_PWRGD";
+ gpios = <&gpioa 4 GPIO_OPEN_DRAIN>;
+ output;
+ };
+ pwr-imvp9-vrrdy-od {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "VRRDY input from IMVP9";
+ enum-name = "PWR_IMVP9_VRRDY";
+ gpios = <&gpio4 3 0>;
+ };
+ pwr-pch-pwrok {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "PCH_PWROK output to PCH";
+ enum-name = "PWR_PCH_PWROK";
+ gpios = <&gpio7 2 GPIO_OPEN_DRAIN>;
+ output;
+ };
+ pwr-ec-pch-sys-pwrok {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SYS_PWROK output to PCH";
+ enum-name = "PWR_EC_PCH_SYS_PWROK";
+ gpios = <&gpio3 7 0>;
+ output;
+ };
+ pwr-sys-rst-l {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SYS_RESET# output to PCH";
+ enum-name = "PWR_SYS_RST";
+ gpios = <&gpioc 5 (GPIO_ACTIVE_LOW|GPIO_OPEN_DRAIN)>;
+ output;
+ };
+ pwr-slp-s4 {
+ compatible = "intel,ap-pwrseq-vw";
+ dbg-label = "SLP_S4 virtual wire input from PCH";
+ enum-name = "PWR_SLP_S4";
+ virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4";
+ vw-invert;
+ };
+ pwr-slp-s5 {
+ compatible = "intel,ap-pwrseq-vw";
+ dbg-label = "SLP_S5 virtual wire input from PCH";
+ enum-name = "PWR_SLP_S5";
+ virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5";
+ vw-invert;
+ };
+ pwr-all-sys-pwrgd {
+ compatible = "intel,ap-pwrseq-external";
+ dbg-label = "Combined all power good";
+ enum-name = "PWR_ALL_SYS_PWRGD";
+ };
+ pwr-adc-pp3300 {
+ compatible = "intel,ap-pwrseq-adc";
+ dbg-label = "PP3300 PWROK (from ADC)";
+ enum-name = "PWR_DSW_PWROK";
+ trigger-high = <&cmp_pp3300_s5_high>;
+ trigger-low = <&cmp_pp3300_s5_low>;
+ };
+ pwr-adc-pp1p05 {
+ compatible = "intel,ap-pwrseq-adc";
+ dbg-label = "PP1P05 PWROK (from ADC)";
+ enum-name = "PWR_PG_PP1P05";
+ trigger-high = <&cmp_pp1p05_high>;
+ trigger-low = <&cmp_pp1p05_low>;
+ };
+
+ adc-cmp {
+ cmp_pp3300_s5_high: pp3300_high {
+ compatible = "nuvoton,adc-cmp";
+ io-channels = <&adc0 6>;
+ comparison = "ADC_CMP_NPCX_GREATER";
+ /*
+ * This is 90% of nominal voltage considering voltage
+ * divider on ADC input.
+ */
+ threshold-mv = <2448>;
+ };
+ cmp_pp3300_s5_low: pp3300_low {
+ compatible = "nuvoton,adc-cmp";
+ io-channels = <&adc0 6>;
+ comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL";
+ threshold-mv = <2448>;
+ };
+ cmp_pp1p05_high: pp1p05_high {
+ compatible = "nuvoton,adc-cmp";
+ io-channels = <&adc0 4>;
+ comparison = "ADC_CMP_NPCX_GREATER";
+ /* Setting at 90% of nominal voltage */
+ threshold-mv = <945>;
+ };
+ cmp_pp1p05_low: pp1p05_low {
+ compatible = "nuvoton,adc-cmp";
+ io-channels = <&adc0 4>;
+ comparison = "ADC_CMP_NPCX_LESS_OR_EQUAL";
+ threshold-mv = <945>;
+ };
+ };
+};
+
+/*
+ * Because the power signals directly reference the GPIOs,
+ * the correspinding named-gpios need to have no-auto-init set.
+ */
+&gpio_ec_soc_dsw_pwrok {
+ no-auto-init;
+};
+&gpio_ec_soc_pch_pwrok_od {
+ no-auto-init;
+};
+&gpio_ec_soc_rsmrst_l {
+ no-auto-init;
+};
+&gpio_ec_soc_sys_pwrok {
+ no-auto-init;
+};
+&gpio_ec_soc_vccst_pwrgd_od {
+ no-auto-init;
+};
+&gpio_en_pp3300_s5 {
+ no-auto-init;
+};
+&gpio_en_pp5000_s5 {
+ no-auto-init;
+};
+&gpio_imvp91_vrrdy_od {
+ no-auto-init;
+};
+&gpio_rsmrst_pwrgd_l {
+ no-auto-init;
+};
+&gpio_slp_s0_l {
+ no-auto-init;
+};
+&gpio_slp_s3_l {
+ no-auto-init;
+};
+&gpio_slp_s4_l {
+ no-auto-init;
+};
+&gpio_slp_sus_l {
+ no-auto-init;
+};
+&gpio_sys_rst_odl {
+ no-auto-init;
+};
diff --git a/zephyr/program/nissa/xivur/project.conf b/zephyr/program/nissa/xivur/project.conf
new file mode 100644
index 0000000000..c63cf8b41f
--- /dev/null
+++ b/zephyr/program/nissa/xivur/project.conf
@@ -0,0 +1,8 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_BOARD_XIVUR=y
+CONFIG_PLATFORM_EC_OCPC=y
+
+CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y
diff --git a/zephyr/projects/nissa/nivviks/project.overlay b/zephyr/program/nissa/xivur/project.overlay
index 9ca681d979..9ca681d979 100644
--- a/zephyr/projects/nissa/nivviks/project.overlay
+++ b/zephyr/program/nissa/xivur/project.overlay
diff --git a/zephyr/program/nissa/xivur/pwm_leds.dtsi b/zephyr/program/nissa/xivur/pwm_leds.dtsi
new file mode 100644
index 0000000000..a265a5929e
--- /dev/null
+++ b/zephyr/program/nissa/xivur/pwm_leds.dtsi
@@ -0,0 +1,62 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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 2 PWM_HZ(324) PWM_POLARITY_INVERTED>,
+ <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>,
+ <&pwm1 1 PWM_HZ(324) PWM_POLARITY_INVERTED>;
+ };
+ };
+
+ cros-pwmleds {
+ compatible = "cros-ec,pwm-leds";
+
+ leds = <&pwm_led0>;
+
+ /*<red green blue>*/
+ color-map-red = <100 0 0>;
+ color-map-green = < 0 100 0>;
+ color-map-blue = < 0 0 100>;
+ color-map-yellow = < 0 50 50>;
+ color-map-white = <100 100 100>;
+ color-map-amber = <100 0 0>;
+
+ brightness-range = <0 0 100 0 0 100>;
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ pwm_led_0@0 {
+ reg = <0>;
+ ec-led-name = "EC_LED_ID_BATTERY_LED";
+ };
+ };
+};
+
+/* Enable LEDs to work while CPU suspended */
+
+&pwm0 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm0_gpc3>;
+ pinctrl-names = "default";
+};
+
+&pwm1 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm1_gpc2>;
+ pinctrl-names = "default";
+};
+
+&pwm2 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/program/nissa/xivur/src/charger.c b/zephyr/program/nissa/xivur/src/charger.c
new file mode 100644
index 0000000000..9dadb0f42f
--- /dev/null
+++ b/zephyr/program/nissa/xivur/src/charger.c
@@ -0,0 +1,56 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <zephyr/logging/log.h>
+
+#include "battery.h"
+#include "charger.h"
+#include "charger/isl923x_public.h"
+#include "console.h"
+#include "extpower.h"
+#include "usb_pd.h"
+#include "nissa_common.h"
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+int extpower_is_present(void)
+{
+ int port;
+ int rv;
+ bool acok;
+
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
+ rv = raa489000_is_acok(port, &acok);
+ if ((rv == EC_SUCCESS) && acok)
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ * Nivviks does not have a GPIO indicating whether extpower is present,
+ * so detect using the charger(s).
+ */
+__override void board_check_extpower(void)
+{
+ static int last_extpower_present;
+ int extpower_present = extpower_is_present();
+
+ if (last_extpower_present ^ extpower_present)
+ extpower_handle_update(extpower_present);
+
+ last_extpower_present = extpower_present;
+}
+
+__override void board_hibernate(void)
+{
+ /* Shut down the chargers */
+ if (board_get_usb_pd_port_count() == 2)
+ raa489000_hibernate(CHARGER_SECONDARY, true);
+ raa489000_hibernate(CHARGER_PRIMARY, true);
+ LOG_INF("Charger(s) hibernated");
+ cflush();
+}
diff --git a/zephyr/projects/nissa/nivviks/src/fan.c b/zephyr/program/nissa/xivur/src/fan.c
index 840049722c..840049722c 100644
--- a/zephyr/projects/nissa/nivviks/src/fan.c
+++ b/zephyr/program/nissa/xivur/src/fan.c
diff --git a/zephyr/projects/nissa/nivviks/src/form_factor.c b/zephyr/program/nissa/xivur/src/form_factor.c
index 602b22baff..602b22baff 100644
--- a/zephyr/projects/nissa/nivviks/src/form_factor.c
+++ b/zephyr/program/nissa/xivur/src/form_factor.c
diff --git a/zephyr/program/nissa/xivur/src/keyboard.c b/zephyr/program/nissa/xivur/src/keyboard.c
new file mode 100644
index 0000000000..2bc1d203a7
--- /dev/null
+++ b/zephyr/program/nissa/xivur/src/keyboard.c
@@ -0,0 +1,29 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ec_commands.h"
+
+static const struct ec_response_keybd_config xivur_kb = {
+ .num_top_row_keys = 10,
+ .action_keys = {
+ TK_BACK, /* T1 */
+ TK_REFRESH, /* T2 */
+ TK_FULLSCREEN, /* T3 */
+ TK_OVERVIEW, /* T4 */
+ TK_SNAPSHOT, /* T5 */
+ TK_BRIGHTNESS_DOWN, /* T6 */
+ TK_BRIGHTNESS_UP, /* T7 */
+ TK_VOL_MUTE, /* T8 */
+ TK_VOL_DOWN, /* T9 */
+ TK_VOL_UP, /* T10 */
+ },
+ .capabilities = KEYBD_CAP_SCRNLOCK_KEY,
+};
+
+__override const struct ec_response_keybd_config *
+board_vivaldi_keybd_config(void)
+{
+ return &xivur_kb;
+}
diff --git a/zephyr/program/nissa/xivur/src/led.c b/zephyr/program/nissa/xivur/src/led.c
new file mode 100644
index 0000000000..9087982604
--- /dev/null
+++ b/zephyr/program/nissa/xivur/src/led.c
@@ -0,0 +1,51 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ *
+ * Battery LED control for nissa
+ */
+#include "common.h"
+#include "ec_commands.h"
+#include "led_common.h"
+#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 } },
+ [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER,
+ LED_INDEFINITE } },
+ [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_BLUE,
+ LED_INDEFINITE } },
+ [STATE_DISCHARGE_S0] = { { EC_LED_COLOR_BLUE,
+ LED_INDEFINITE } },
+ [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER,
+ LED_INDEFINITE } },
+ [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } },
+ [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER,
+ 1 * LED_ONE_SEC },
+ { LED_OFF, 1 * LED_ONE_SEC } },
+ [STATE_FACTORY_TEST] = { { EC_LED_COLOR_AMBER,
+ 2 * LED_ONE_SEC },
+ { EC_LED_COLOR_BLUE,
+ 2 * LED_ONE_SEC } },
+ };
+
+__override void led_set_color_battery(enum ec_led_colors color)
+{
+ switch (color) {
+ case EC_LED_COLOR_BLUE:
+ set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_BLUE);
+ break;
+ case EC_LED_COLOR_AMBER:
+ set_pwm_led_color(EC_LED_ID_BATTERY_LED, EC_LED_COLOR_AMBER);
+ break;
+ default: /* LED_OFF and other unsupported colors */
+ set_pwm_led_color(EC_LED_ID_BATTERY_LED, -1);
+ break;
+ }
+}
diff --git a/zephyr/projects/nissa/craask/src/usbc.c b/zephyr/program/nissa/xivur/src/usbc.c
index a15460a212..a15460a212 100644
--- a/zephyr/projects/nissa/craask/src/usbc.c
+++ b/zephyr/program/nissa/xivur/src/usbc.c
diff --git a/zephyr/projects/nissa/yaviks/cbi.dtsi b/zephyr/program/nissa/yaviks/cbi.dtsi
index c5716cbd37..c5716cbd37 100644
--- a/zephyr/projects/nissa/yaviks/cbi.dtsi
+++ b/zephyr/program/nissa/yaviks/cbi.dtsi
diff --git a/zephyr/program/nissa/yaviks/fan.dtsi b/zephyr/program/nissa/yaviks/fan.dtsi
new file mode 100644
index 0000000000..229530b57a
--- /dev/null
+++ b/zephyr/program/nissa/yaviks/fan.dtsi
@@ -0,0 +1,71 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+/ {
+ fans {
+ compatible = "cros-ec,fans";
+ fan_0 {
+ pwms = <&pwm2 PWM_CHANNEL_2 PWM_KHZ(25) PWM_POLARITY_NORMAL>;
+ tach = <&tach1>;
+ rpm_min = <2500>;
+ rpm_start = <2500>;
+ rpm_max = <4100>;
+ rpm_deviation = <1>;
+ enable_gpio = <&gpio_fan_enable>;
+ };
+ };
+ fan_steps {
+ compatible = "cros-ec,fan-steps";
+ level_0 {
+ temp_on = <44 47 0>;
+ temp_off = <99 99 99>;
+ rpm_target = <0>;
+ };
+ level_1 {
+ temp_on = <48 48 0>;
+ temp_off = <43 45 99>;
+ rpm_target = <2600>;
+ };
+ level_2 {
+ temp_on = <50 49 0>;
+ temp_off = <47 46 99>;
+ rpm_target = <2800>;
+ };
+ level_3 {
+ temp_on = <52 50 54>;
+ temp_off = <49 47 51>;
+ rpm_target = <3000>;
+ };
+ level_4 {
+ temp_on = <54 56 60>;
+ temp_off = <51 48 52>;
+ rpm_target = <3300>;
+ };
+ level_5 {
+ temp_on = <60 60 64>;
+ temp_off = <53 52 56>;
+ rpm_target = <3600>;
+ };
+ level_6 {
+ temp_on = <100 100 100>;
+ temp_off = <59 54 58>;
+ rpm_target = <4100>;
+ };
+ };
+};
+/* pwm for fan */
+&pwm2 {
+ status = "okay";
+ prescaler-cx = <PWM_PRESCALER_C6>;
+ pinctrl-0 = <&pwm2_gpa2_default>;
+ pinctrl-names = "default";
+};
+/* fan tachometer sensor */
+&tach1 {
+ status = "okay";
+ channel = <IT8XXX2_TACH_CHANNEL_A>;
+ pulses-per-round = <2>;
+ pinctrl-0 = <&tach1a_gpd7_default>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/nissa/yaviks/gpio.dtsi b/zephyr/program/nissa/yaviks/gpio.dtsi
index dae1d641cd..dae1d641cd 100644
--- a/zephyr/projects/nissa/yaviks/gpio.dtsi
+++ b/zephyr/program/nissa/yaviks/gpio.dtsi
diff --git a/zephyr/projects/nissa/yaviks/keyboard.dtsi b/zephyr/program/nissa/yaviks/keyboard.dtsi
index 04a620767a..04a620767a 100644
--- a/zephyr/projects/nissa/yaviks/keyboard.dtsi
+++ b/zephyr/program/nissa/yaviks/keyboard.dtsi
diff --git a/zephyr/program/nissa/yaviks/overlay.dtsi b/zephyr/program/nissa/yaviks/overlay.dtsi
new file mode 100644
index 0000000000..2b5f1e453d
--- /dev/null
+++ b/zephyr/program/nissa/yaviks/overlay.dtsi
@@ -0,0 +1,383 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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>
+#include <dt-bindings/usb_pd_tcpm.h>
+
+/ {
+ aliases {
+ gpio-cbi-wp = &gpio_ec_cbi_wp;
+ gpio-wp = &gpio_ec_wp_odl;
+ int-wp = &int_wp_l;
+ /*
+ * USB-C: interrupt input.
+ * I2C pins are on i2c_ec_i2c_sub_usb_c1
+ */
+ gpio-usb-c1-int-odl = &gpio_sb_1;
+ /*
+ * USB-A: VBUS enable output
+ * LTE: power enable output
+ */
+ gpio-en-usb-a1-vbus = &gpio_sb_2;
+ /*
+ * Enable S5 rails for LTE sub-board
+ */
+ gpio-en-sub-s5-rails = &gpio_sb_2;
+ };
+
+ ec-console {
+ compatible = "ec-console";
+ disabled = "events", "lpc", "hostcmd";
+ };
+
+ batteries {
+ default_battery: cosmx {
+ compatible = "cosmx,gh02047xl", "battery-smart";
+ };
+ dynapack_atl_gh02047xl {
+ compatible = "dynapack,atl_gh02047xl", "battery-smart";
+ };
+ dynapack_cosmx_gh02047xl {
+ compatible = "dynapack,cosmx_gh02047xl", "battery-smart";
+ };
+ smp_coslight_gh02047xl {
+ compatible = "smp,coslight_gh02047xl", "battery-smart";
+ };
+ smp_highpower_gh02047xl {
+ compatible = "smp,highpower_gh02047xl", "battery-smart";
+ };
+ default_battery_3s:cosmx_si03058xl {
+ compatible = "cosmx,si03058xl", "battery-smart";
+ };
+ smp_highpower_si03058xl {
+ compatible = "smp,highpower_si03058xl", "battery-smart";
+ };
+ };
+
+ hibernate-wake-pins {
+ compatible = "cros-ec,hibernate-wake-pins";
+ wakeup-irqs = <
+ &int_power_button
+ &int_lid_open
+ >;
+ };
+
+ gpio-interrupts {
+ compatible = "cros-ec,gpio-interrupts";
+
+ int_power_button: power_button {
+ irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "power_button_interrupt";
+ };
+ int_wp_l: wp_l {
+ irq-pin = <&gpio_ec_wp_odl>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "switch_interrupt";
+ };
+ int_lid_open: lid_open {
+ irq-pin = <&gpio_lid_open>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "lid_interrupt";
+ };
+ int_usb_c0: usb_c0 {
+ irq-pin = <&gpio_usb_c0_int_odl>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_c0_interrupt";
+ };
+ int_usb_c1: usb_c1 {
+ irq-pin = <&gpio_sb_1>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb_c1_interrupt";
+ };
+ };
+
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios = <&gpioa 7 0>,
+ <&gpioc 0 0>,
+ <&gpioc 6 0>,
+ <&gpiod 7 0>,
+ <&gpioh 2 0>,
+ <&gpioi 6 0>,
+ <&gpioi 7 0>,
+ <&gpioj 0 0>,
+ <&gpioj 3 0>,
+ <&gpiok 7 GPIO_OUTPUT>;
+ };
+
+ named-gpios {
+ /*
+ * EC doesn't take any specific action on CC/SBU disconnect due to
+ * fault, but this definition is useful for hardware testing.
+ */
+ gpio_usb_c0_prot_fault_odl: usb_c0_prot_fault_odl {
+ gpios = <&gpiok 6 GPIO_INPUT_PULL_UP>;
+ };
+
+ gpio_sb_1: sb_1 {
+ gpios = <&gpioe 6 0>;
+ no-auto-init;
+ };
+ gpio_sb_2: sb_2 {
+ gpios = <&gpiof 0 0>;
+ no-auto-init;
+ };
+ gpio_fan_enable: fan-enable {
+ gpios = <&gpioa 1 GPIO_OUTPUT>;
+ no-auto-init;
+ };
+ };
+
+ temp_cpu_thermistor: cpu {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_1>;
+ };
+ temp_5v_regulator_thermistor: 5v-regulator {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_2>;
+ };
+ temp_charger_thermistor: charger {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_51K1_47K_4050B>;
+ adc = <&adc_temp_sensor_3>;
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ temp_cpu: cpu {
+ temp_fan_off = <45>;
+ temp_fan_max = <60>;
+ temp_host_high = <75>;
+ temp_host_halt = <85>;
+ temp_host_release_high = <65>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_cpu_thermistor>;
+ };
+ temp_5v_regulator: 5v-regulator {
+ temp_fan_off = <50>;
+ temp_fan_max = <65>;
+ temp_host_high = <75>;
+ temp_host_halt = <85>;
+ temp_host_release_high = <65>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_5v_regulator_thermistor>;
+ };
+ temp_charger: charger {
+ temp_fan_off = <50>;
+ temp_fan_max = <65>;
+ temp_host_high = <80>;
+ temp_host_halt = <85>;
+ temp_host_release_high = <75>;
+ power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
+ sensor = <&temp_charger_thermistor>;
+ };
+ };
+
+ usba {
+ compatible = "cros-ec,usba-port-enable-pins";
+ /*
+ * sb_2 is only configured as GPIO when USB-A1 is present,
+ * but it's still safe to control when disabled.
+ *
+ * ILIM_SEL pins are referred to by legacy enum name,
+ * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
+ * sub-boards that don't have USB-A so is safe to control
+ * regardless of system configuration.
+ */
+ enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
+ status = "okay";
+ };
+
+ usbc {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ port0@0 {
+ compatible = "named-usbc-port";
+ reg = <0>;
+ bc12 = <&bc12_port0>;
+ chg = <&chg_port0>;
+ tcpc = <&usbpd0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_0>;
+ };
+ };
+ port0-muxes {
+ virtual_mux_0: virtual-mux-0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ port1@1 {
+ compatible = "named-usbc-port";
+ reg = <1>;
+ bc12 = <&bc12_port1>;
+ chg = <&chg_port1>;
+ tcpc = <&tcpc_port1>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_1 &tcpci_mux_1>;
+ };
+ usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux {
+ compatible = "cros-ec,usb-mux-chain";
+ alternative-chain;
+ usb-muxes = <&virtual_mux_1>;
+ };
+ };
+ port1-muxes {
+ virtual_mux_1: virtual-mux-1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ tcpci_mux_1: tcpci-mux-1 {
+ compatible = "parade,usbc-mux-ps8xxx";
+ };
+ };
+ };
+};
+
+&thermistor_3V3_51K1_47K_4050B {
+ status = "okay";
+};
+
+&adc_ec_vsense_pp3300_s5 {
+ /*
+ * Voltage divider on input has 47k upper and 220k lower legs with 3 V
+ * full-scale reading on the ADC. Apply the largest possible multiplier
+ * (without overflowing int32) to get the best possible approximation
+ * of the actual ratio, but derate by a factor of two to ensure
+ * unexpectedly high values won't overflow.
+ */
+ mul = <(715828 / 2)>;
+ div = <(589820 / 2)>;
+};
+
+&adc0 {
+ pinctrl-0 = <&adc0_ch0_gpi0_default
+ &adc0_ch2_gpi2_default
+ &adc0_ch3_gpi3_default
+ &adc0_ch13_gpl0_default
+ &adc0_ch14_gpl1_default>;
+ pinctrl-names = "default";
+ status = "okay";
+};
+
+&pinctrl {
+ i2c4_clk_gpe0_sleep: i2c4_clk_gpe0_sleep {
+ pinmuxs = <&pinctrle 0 IT8XXX2_ALT_DEFAULT>;
+ };
+ i2c4_data_gpe7_sleep: i2c4_data_gpe7_sleep {
+ pinmuxs = <&pinctrle 7 IT8XXX2_ALT_DEFAULT>;
+ };
+ i2c2_clk_gpf6_default: i2c2_clk_gpf6_default {
+ gpio-voltage = "1v8";
+ };
+ i2c2_data_gpf7_default: i2c2_data_gpf7_default {
+ gpio-voltage = "1v8";
+ };
+};
+
+&i2c0 {
+ label = "I2C_EEPROM";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ label = "EEPROM_CBI";
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+ pinctrl-0 = <&i2c0_clk_gpb3_default
+ &i2c0_data_gpb4_default>;
+ pinctrl-names = "default";
+ status = "okay";
+};
+
+&i2c1 {
+ label = "I2C_BATTERY";
+ clock-frequency = <50000>;
+ pinctrl-0 = <&i2c1_clk_gpc1_default
+ &i2c1_data_gpc2_default>;
+ pinctrl-names = "default";
+ status = "okay";
+};
+
+&i2c2 {
+ label = "I2C_SENSOR";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c2_clk_gpf6_default
+ &i2c2_data_gpf7_default>;
+ pinctrl-names = "default";
+ status = "okay";
+};
+
+&i2c4 {
+ label = "I2C_SUB_C1_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+ pinctrl-0 = <&i2c4_clk_gpe0_default
+ &i2c4_data_gpe7_default>;
+ pinctrl-1 = <&i2c4_clk_gpe0_sleep
+ &i2c4_data_gpe7_sleep>;
+ pinctrl-names = "default", "sleep";
+ status = "okay";
+
+ bc12_port1: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ };
+
+ chg_port1: sm5803@32 {
+ compatible = "siliconmitus,sm5803";
+ status = "okay";
+ reg = <0x32>;
+ };
+
+ tcpc_port1: ps8745@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
+};
+
+&i2c_ec_i2c_sub_usb_c1 {
+ /*
+ * Dynamic speed setting is used for AP-controlled firmware update
+ * of PS8745 TCPC/redriver: the AP lowers speed to 400 kHz in order
+ * to use more efficient window programming, then sets it back when
+ * done.
+ */
+ dynamic-speed;
+};
+
+&i2c5 {
+ label = "I2C_USB_C0_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST_PLUS>;
+ pinctrl-0 = <&i2c5_clk_gpa4_default
+ &i2c5_data_gpa5_default>;
+ pinctrl-names = "default";
+ status = "okay";
+
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ };
+
+ chg_port0: sm5803@32 {
+ compatible = "siliconmitus,sm5803";
+ status = "okay";
+ reg = <0x32>;
+ };
+};
+
+&usbpd0 {
+ status = "okay";
+};
diff --git a/zephyr/projects/nissa/yaviks/power_signals.dtsi b/zephyr/program/nissa/yaviks/power_signals.dtsi
index d64ac83150..d64ac83150 100644
--- a/zephyr/projects/nissa/yaviks/power_signals.dtsi
+++ b/zephyr/program/nissa/yaviks/power_signals.dtsi
diff --git a/zephyr/program/nissa/yaviks/project.conf b/zephyr/program/nissa/yaviks/project.conf
new file mode 100644
index 0000000000..80a9e9ea97
--- /dev/null
+++ b/zephyr/program/nissa/yaviks/project.conf
@@ -0,0 +1,34 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_BOARD_YAVIKS=y
+
+# Ensure recovery key combination (esc+refresh+power) is reliable: b/236580049
+CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
+CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
+
+# Sensors: disabled; yaviks is clamshell-only
+CONFIG_PLATFORM_EC_LID_ANGLE=n
+CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n
+CONFIG_PLATFORM_EC_MOTIONSENSE=n
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=n
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n
+CONFIG_PLATFORM_EC_ACCEL_FIFO=n
+CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=n
+CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n
+CONFIG_PLATFORM_EC_TABLET_MODE=n
+CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n
+CONFIG_PLATFORM_EC_VOLUME_BUTTONS=n
+CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000
+
+# Keyboard
+CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y
+CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=n
+
+# Fan
+CONFIG_PLATFORM_EC_FAN=y
+CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_PWM=n
diff --git a/zephyr/program/nissa/yaviks/project.overlay b/zephyr/program/nissa/yaviks/project.overlay
new file mode 100644
index 0000000000..fecd1c98c8
--- /dev/null
+++ b/zephyr/program/nissa/yaviks/project.overlay
@@ -0,0 +1,13 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "../cbi.dtsi"
+
+#include "cbi.dtsi"
+#include "fan.dtsi"
+#include "gpio.dtsi"
+#include "keyboard.dtsi"
+#include "overlay.dtsi"
+#include "power_signals.dtsi"
diff --git a/zephyr/program/nissa/yaviks/src/charger.c b/zephyr/program/nissa/yaviks/src/charger.c
new file mode 100644
index 0000000000..ec2247f4b4
--- /dev/null
+++ b/zephyr/program/nissa/yaviks/src/charger.c
@@ -0,0 +1,74 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "battery_fuel_gauge.h"
+#include "charger.h"
+#include "console.h"
+#include "driver/charger/sm5803.h"
+#include "extpower.h"
+#include "nissa_common.h"
+#include "usb_pd.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+int extpower_is_present(void)
+{
+ int port;
+ int rv;
+ bool acok;
+
+ for (port = 0; port < board_get_usb_pd_port_count(); port++) {
+ rv = sm5803_is_acok(port, &acok);
+ if ((rv == EC_SUCCESS) && acok)
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ * Yaviks does not have a GPIO indicating whether extpower is present,
+ * so detect using the charger(s).
+ */
+__override void board_check_extpower(void)
+{
+ static int last_extpower_present;
+ int extpower_present = extpower_is_present();
+
+ if (last_extpower_present ^ extpower_present)
+ extpower_handle_update(extpower_present);
+
+ last_extpower_present = extpower_present;
+}
+
+__override void board_hibernate(void)
+{
+ /* Shut down the chargers */
+ if (board_get_usb_pd_port_count() == 2)
+ sm5803_hibernate(CHARGER_SECONDARY);
+ sm5803_hibernate(CHARGER_PRIMARY);
+ LOG_INF("Charger(s) hibernated");
+ cflush();
+}
+
+__override int board_get_default_battery_type(void)
+{
+ int type = DEFAULT_BATTERY_TYPE;
+ int cells;
+
+ if (charger_get_battery_cells(CHARGER_PRIMARY, &cells) == EC_SUCCESS) {
+ if (cells == 3)
+ type = DEFAULT_BATTERY_TYPE_3S;
+ if (cells != 2 && cells != 3)
+ LOG_ERR("Unexpected number of cells");
+ } else {
+ LOG_ERR("Failed to get default battery type");
+ }
+
+ return type;
+}
diff --git a/zephyr/program/nissa/yaviks/src/fan.c b/zephyr/program/nissa/yaviks/src/fan.c
new file mode 100644
index 0000000000..c01ee3d752
--- /dev/null
+++ b/zephyr/program/nissa/yaviks/src/fan.c
@@ -0,0 +1,37 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "cros_cbi.h"
+#include "fan.h"
+#include "gpio/gpio.h"
+#include "hooks.h"
+#include "nissa_common.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+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/program/nissa/yaviks/src/keyboard.c b/zephyr/program/nissa/yaviks/src/keyboard.c
new file mode 100644
index 0000000000..54f8750e98
--- /dev/null
+++ b/zephyr/program/nissa/yaviks/src/keyboard.c
@@ -0,0 +1,106 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "cros_cbi.h"
+#include "ec_commands.h"
+#include "hooks.h"
+#include "keyboard_8042_sharedlib.h"
+#include "keyboard_scan.h"
+#include "timer.h"
+
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+/* Keyboard scan setting */
+__override struct keyboard_scan_config keyscan_config = {
+ /* Increase from 50 us, because KSO_02 passes through the H1. */
+ .output_settle_us = 80,
+ /* Other values should be the same as the default configuration. */
+ .debounce_down_us = 9 * MSEC,
+ .debounce_up_us = 30 * MSEC,
+ .scan_period_us = 3 * MSEC,
+ .min_post_scan_delay_us = 1000,
+ .poll_timeout_us = 100 * MSEC,
+ .actual_key_mask = {
+ 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xa4, 0xff, 0xf6, 0x55, 0xfe, 0xff, 0xff, 0xff, /* full set */
+ },
+};
+
+static const struct ec_response_keybd_config yaviks_kb_w_kb_light = {
+ .num_top_row_keys = 13,
+ .action_keys = {
+ TK_BACK, /* T1 */
+ TK_REFRESH, /* T2 */
+ TK_FULLSCREEN, /* T3 */
+ TK_OVERVIEW, /* T4 */
+ TK_SNAPSHOT, /* T5 */
+ TK_BRIGHTNESS_DOWN, /* T6 */
+ TK_BRIGHTNESS_UP, /* T7 */
+ TK_KBD_BKLIGHT_TOGGLE, /* T8 */
+ TK_PLAY_PAUSE, /* T9 */
+ TK_MICMUTE, /* T10 */
+ TK_VOL_MUTE, /* T11 */
+ TK_VOL_DOWN, /* T12 */
+ TK_VOL_UP, /* T13 */
+ },
+ .capabilities = KEYBD_CAP_NUMERIC_KEYPAD,
+};
+
+static const struct ec_response_keybd_config yaviks_kb_wo_kb_light = {
+ .num_top_row_keys = 13,
+ .action_keys = {
+ TK_BACK, /* T1 */
+ TK_REFRESH, /* T2 */
+ TK_FULLSCREEN, /* T3 */
+ TK_OVERVIEW, /* T4 */
+ TK_SNAPSHOT, /* T5 */
+ TK_BRIGHTNESS_DOWN, /* T6 */
+ TK_BRIGHTNESS_UP, /* T7 */
+ TK_PLAY_PAUSE, /* T8 */
+ TK_MICMUTE, /* T9 */
+ TK_VOL_MUTE, /* T10 */
+ TK_VOL_DOWN, /* T11 */
+ TK_VOL_UP, /* T12 */
+ TK_MENU, /* T13 */
+ },
+ .capabilities = KEYBD_CAP_NUMERIC_KEYPAD,
+};
+
+__override const struct ec_response_keybd_config *
+board_vivaldi_keybd_config(void)
+{
+ uint32_t val;
+
+ cros_cbi_get_fw_config(FW_KB_BACKLIGHT, &val);
+
+ if (val == FW_KB_BACKLIGHT_OFF)
+ return &yaviks_kb_wo_kb_light;
+ else
+ return &yaviks_kb_w_kb_light;
+}
+
+/*
+ * Keyboard layout decided by FW config.
+ */
+static void kb_layout_init(void)
+{
+ int ret;
+ uint32_t val;
+
+ ret = cros_cbi_get_fw_config(FW_KB_LAYOUT, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d",
+ FW_KB_LAYOUT);
+ return;
+ }
+ /*
+ * If keyboard is US2(FW_KB_LAYOUT_US2), we need translate right ctrl
+ * to backslash(\|) key.
+ */
+ if (val == FW_KB_LAYOUT_US2)
+ set_scancode_set2(4, 0, get_scancode_set2(2, 7));
+}
+DECLARE_HOOK(HOOK_INIT, kb_layout_init, HOOK_PRIO_POST_FIRST);
diff --git a/zephyr/program/nissa/yaviks/src/led.c b/zephyr/program/nissa/yaviks/src/led.c
new file mode 100644
index 0000000000..7671bd3a92
--- /dev/null
+++ b/zephyr/program/nissa/yaviks/src/led.c
@@ -0,0 +1,231 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "charge_manager.h"
+#include "charge_state.h"
+#include "chipset.h"
+#include "ec_commands.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "host_command.h"
+#include "led_common.h"
+
+#include <stdint.h>
+
+#define BAT_LED_ON 0
+#define BAT_LED_OFF 1
+
+#define BATT_LOW_BCT 10
+
+#define LED_TICKS_PER_CYCLE 4
+#define LED_TICKS_PER_CYCLE_S3 4
+#define LED_ON_TICKS 2
+#define POWER_LED_ON_S3_TICKS 2
+
+const enum ec_led_id supported_led_ids[] = { EC_LED_ID_LEFT_LED,
+ EC_LED_ID_RIGHT_LED };
+
+const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
+
+enum led_color {
+ LED_OFF = 0,
+ LED_AMBER,
+ LED_WHITE,
+ LED_COLOR_COUNT /* Number of colors, not a color itself */
+};
+
+enum led_port { LEFT_PORT = 0, RIGHT_PORT };
+
+static void led_set_color_battery(int port, enum led_color color)
+{
+ const struct gpio_dt_spec *amber_led, *white_led;
+
+ if (port == LEFT_PORT) {
+ amber_led = GPIO_DT_FROM_NODELABEL(gpio_c0_charger_led_amber_l);
+ white_led = GPIO_DT_FROM_NODELABEL(gpio_c0_charger_led_white_l);
+ } else if (port == RIGHT_PORT) {
+ amber_led = GPIO_DT_FROM_NODELABEL(gpio_c1_charger_led_amber_l);
+ white_led = GPIO_DT_FROM_NODELABEL(gpio_c1_charger_led_white_l);
+ }
+
+ switch (color) {
+ case LED_WHITE:
+ gpio_pin_set_dt(white_led, BAT_LED_ON);
+ gpio_pin_set_dt(amber_led, BAT_LED_OFF);
+ break;
+ case LED_AMBER:
+ gpio_pin_set_dt(white_led, BAT_LED_OFF);
+ gpio_pin_set_dt(amber_led, BAT_LED_ON);
+ break;
+ case LED_OFF:
+ gpio_pin_set_dt(white_led, BAT_LED_OFF);
+ gpio_pin_set_dt(amber_led, BAT_LED_OFF);
+ break;
+ default:
+ break;
+ }
+}
+
+void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
+{
+ switch (led_id) {
+ case EC_LED_ID_LEFT_LED:
+ brightness_range[EC_LED_COLOR_WHITE] = 1;
+ brightness_range[EC_LED_COLOR_AMBER] = 1;
+ break;
+ case EC_LED_ID_RIGHT_LED:
+ brightness_range[EC_LED_COLOR_WHITE] = 1;
+ brightness_range[EC_LED_COLOR_AMBER] = 1;
+ break;
+ default:
+ break;
+ }
+}
+
+int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
+{
+ switch (led_id) {
+ case EC_LED_ID_LEFT_LED:
+ if (brightness[EC_LED_COLOR_WHITE] != 0)
+ led_set_color_battery(LEFT_PORT, LED_WHITE);
+ else if (brightness[EC_LED_COLOR_AMBER] != 0)
+ led_set_color_battery(LEFT_PORT, LED_AMBER);
+ else
+ led_set_color_battery(LEFT_PORT, LED_OFF);
+ break;
+ case EC_LED_ID_RIGHT_LED:
+ if (brightness[EC_LED_COLOR_WHITE] != 0)
+ led_set_color_battery(RIGHT_PORT, LED_WHITE);
+ else if (brightness[EC_LED_COLOR_AMBER] != 0)
+ led_set_color_battery(RIGHT_PORT, LED_AMBER);
+ else
+ led_set_color_battery(RIGHT_PORT, LED_OFF);
+ break;
+ default:
+ return EC_ERROR_PARAM1;
+ }
+
+ return EC_SUCCESS;
+}
+
+/*
+ * Set active charge port color to the parameter, turn off all others.
+ * If no port is active (-1), turn off all LEDs.
+ */
+static void set_active_port_color(enum led_color color)
+{
+ int port = charge_manager_get_active_charge_port();
+
+ if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED))
+ led_set_color_battery(RIGHT_PORT,
+ (port == RIGHT_PORT) ? color : LED_OFF);
+ if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED))
+ led_set_color_battery(LEFT_PORT,
+ (port == LEFT_PORT) ? color : LED_OFF);
+}
+
+static void led_set_battery(void)
+{
+ static unsigned int battery_ticks;
+ static int suspend_ticks;
+
+ battery_ticks++;
+
+ /*
+ * Override battery LEDs for Yaviks, Yaviks is non-power LED
+ * design, blinking both two side battery white LEDs to indicate
+ * system suspend with non-charging state.
+ */
+ if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) &&
+ charge_get_state() != PWR_STATE_CHARGE) {
+ suspend_ticks++;
+
+ led_set_color_battery(RIGHT_PORT,
+ suspend_ticks % LED_TICKS_PER_CYCLE_S3 <
+ POWER_LED_ON_S3_TICKS ?
+ LED_WHITE :
+ LED_OFF);
+ led_set_color_battery(LEFT_PORT,
+ suspend_ticks % LED_TICKS_PER_CYCLE_S3 <
+ POWER_LED_ON_S3_TICKS ?
+ LED_WHITE :
+ LED_OFF);
+ return;
+ }
+
+ suspend_ticks = 0;
+
+ switch (charge_get_state()) {
+ case PWR_STATE_CHARGE:
+ /* Always indicate when charging, even in suspend. */
+ set_active_port_color(LED_AMBER);
+ break;
+ case PWR_STATE_DISCHARGE:
+ /*
+ * Blinking amber LEDs slowly if battery is lower 10
+ * percentage.
+ */
+ if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) {
+ if (charge_get_percent() < BATT_LOW_BCT)
+ led_set_color_battery(
+ RIGHT_PORT,
+ (battery_ticks % LED_TICKS_PER_CYCLE <
+ LED_ON_TICKS) ?
+ LED_AMBER :
+ LED_OFF);
+ else
+ led_set_color_battery(RIGHT_PORT, LED_OFF);
+ }
+
+ if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) {
+ if (charge_get_percent() < BATT_LOW_BCT)
+ led_set_color_battery(
+ LEFT_PORT,
+ (battery_ticks % LED_TICKS_PER_CYCLE <
+ LED_ON_TICKS) ?
+ LED_AMBER :
+ LED_OFF);
+ else
+ led_set_color_battery(LEFT_PORT, LED_OFF);
+ }
+ break;
+ case PWR_STATE_ERROR:
+ if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) {
+ led_set_color_battery(
+ RIGHT_PORT,
+ (battery_ticks & 0x1) ? LED_AMBER : LED_OFF);
+ }
+
+ if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) {
+ led_set_color_battery(LEFT_PORT, (battery_ticks & 0x1) ?
+ LED_AMBER :
+ LED_OFF);
+ }
+ break;
+ case PWR_STATE_CHARGE_NEAR_FULL:
+ set_active_port_color(LED_WHITE);
+ break;
+ case PWR_STATE_IDLE: /* External power connected in IDLE */
+ set_active_port_color(LED_WHITE);
+ break;
+ case PWR_STATE_FORCED_IDLE:
+ set_active_port_color(
+ (battery_ticks % LED_TICKS_PER_CYCLE < LED_ON_TICKS) ?
+ LED_AMBER :
+ LED_OFF);
+ break;
+ default:
+ /* Other states don't alter LED behavior */
+ break;
+ }
+}
+
+/* Called by hook task every TICK(IT83xx 500ms) */
+static void led_tick(void)
+{
+ led_set_battery();
+}
+DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/program/nissa/yaviks/src/thermal.c b/zephyr/program/nissa/yaviks/src/thermal.c
new file mode 100644
index 0000000000..a22a9a74c0
--- /dev/null
+++ b/zephyr/program/nissa/yaviks/src/thermal.c
@@ -0,0 +1,108 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "fan.h"
+#include "temp_sensor/temp_sensor.h"
+#include "thermal.h"
+#include "util.h"
+
+#include <ap_power/ap_power_interface.h>
+
+#define TEMP_CPU TEMP_SENSOR_ID(DT_NODELABEL(temp_cpu))
+#define TEMP_5V TEMP_SENSOR_ID(DT_NODELABEL(temp_5v_regulator))
+#define TEMP_CHARGER TEMP_SENSOR_ID(DT_NODELABEL(temp_charger))
+
+struct fan_step {
+ /*
+ * Sensor 1~3 trigger point, set -1 if we're not using this
+ * sensor to determine fan speed.
+ */
+ int8_t on[TEMP_SENSOR_COUNT];
+ /*
+ * Sensor 1~3 trigger point, set -1 if we're not using this
+ * sensor to determine fan speed.
+ */
+ int8_t off[TEMP_SENSOR_COUNT];
+ /* Fan rpm */
+ uint16_t rpm[FAN_CH_COUNT];
+};
+
+#define FAN_TABLE_ENTRY(nd) \
+ { \
+ .on = DT_PROP(nd, temp_on), \
+ .off = DT_PROP(nd, temp_off), \
+ .rpm = DT_PROP(nd, rpm_target), \
+ },
+
+static const struct fan_step fan_step_table[] = { DT_FOREACH_CHILD(
+ DT_INST(0, cros_ec_fan_steps), FAN_TABLE_ENTRY) };
+
+int fan_table_to_rpm(int fan, int *temp)
+{
+ /* current fan level */
+ static int current_level;
+ /* previous sensor temperature */
+ static int prev_tmp[TEMP_SENSOR_COUNT];
+ int i;
+ /*
+ * Compare the current and previous temperature, we have
+ * the three paths :
+ * 1. decreasing path. (check the release point)
+ * 2. increasing path. (check the trigger point)
+ * 3. invariant path. (return the current RPM)
+ *
+ * Yaviks thermal table V1-1
+ * Increase path judgment: CPU || (5V && Charger)
+ * Decrease path judgment: CPU && 5V && Charger
+ */
+ if (temp[TEMP_CPU] < prev_tmp[TEMP_CPU] ||
+ temp[TEMP_5V] < prev_tmp[TEMP_5V] ||
+ temp[TEMP_CHARGER] < prev_tmp[TEMP_CHARGER]) {
+ for (i = current_level; i > 0; i--) {
+ if (temp[TEMP_CPU] < fan_step_table[i].off[TEMP_CPU] &&
+ temp[TEMP_5V] < fan_step_table[i].off[TEMP_5V] &&
+ temp[TEMP_CHARGER] <
+ fan_step_table[i].off[TEMP_CHARGER]) {
+ current_level = i - 1;
+ } else
+ break;
+ }
+ } else if (temp[TEMP_CPU] > prev_tmp[TEMP_CPU] ||
+ temp[TEMP_5V] > prev_tmp[TEMP_5V] ||
+ temp[TEMP_CHARGER] > prev_tmp[TEMP_CHARGER]) {
+ for (i = current_level; i < ARRAY_SIZE(fan_step_table); i++) {
+ if (temp[TEMP_CPU] > fan_step_table[i].on[TEMP_CPU] ||
+ (temp[TEMP_5V] > fan_step_table[i].on[TEMP_5V] &&
+ temp[TEMP_CHARGER] >
+ fan_step_table[i].on[TEMP_CHARGER])) {
+ current_level = i + 1;
+ } else
+ break;
+ }
+ }
+ if (current_level < 0)
+ current_level = 0;
+
+ if (current_level >= ARRAY_SIZE(fan_step_table))
+ current_level = ARRAY_SIZE(fan_step_table) - 1;
+
+ for (i = 0; i < TEMP_SENSOR_COUNT; ++i)
+ prev_tmp[i] = temp[i];
+
+ return fan_step_table[current_level].rpm[fan];
+}
+
+void board_override_fan_control(int fan, int *temp)
+{
+ /*
+ * In common/fan.c pwm_fan_stop() will turn off fan
+ * when chipset suspend or shutdown.
+ */
+ if (ap_power_in_state(AP_POWER_STATE_ON)) {
+ fan_set_rpm_mode(fan, 1);
+ fan_set_rpm_target(fan, fan_table_to_rpm(fan, temp));
+ }
+}
diff --git a/zephyr/program/nissa/yaviks/src/usbc.c b/zephyr/program/nissa/yaviks/src/usbc.c
new file mode 100644
index 0000000000..1e87abfa0d
--- /dev/null
+++ b/zephyr/program/nissa/yaviks/src/usbc.c
@@ -0,0 +1,369 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_state_v2.h"
+#include "chipset.h"
+#include "driver/charger/sm5803.h"
+#include "driver/tcpm/it83xx_pd.h"
+#include "driver/tcpm/ps8xxx_public.h"
+#include "driver/tcpm/tcpci.h"
+#include "hooks.h"
+#include "nissa_common.h"
+#include "system.h"
+#include "usb_mux.h"
+
+#include <zephyr/logging/log.h>
+
+#include <ap_power/ap_power.h>
+
+LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
+
+/* Vconn control for integrated ITE TCPC */
+void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
+{
+ /* Vconn control is only for port 0 */
+ if (port)
+ return;
+
+ if (cc_pin == USBPD_CC_PIN_1)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc1_vconn),
+ !!enabled);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc2_vconn),
+ !!enabled);
+}
+
+__override bool pd_check_vbus_level(int port, enum vbus_level level)
+{
+ return sm5803_check_vbus_level(port, level);
+}
+
+/*
+ * Putting chargers into LPM when in suspend reduces power draw by about 8mW
+ * per charger, but also seems critical to correct operation in source mode:
+ * if chargers are not in LPM when a sink is first connected, VBUS sourcing
+ * works even if the partner is later removed (causing LPM entry) and
+ * reconnected (causing LPM exit). If in LPM initially, sourcing VBUS
+ * consistently causes the charger to report (apparently spurious) overcurrent
+ * failures.
+ *
+ * In short, this is important to making things work correctly but we don't
+ * understand why.
+ */
+static void board_chargers_suspend(struct ap_power_ev_callback *const cb,
+ const struct ap_power_ev_data data)
+{
+ void (*fn)(int chgnum);
+
+ switch (data.event) {
+ case AP_POWER_SUSPEND:
+ fn = sm5803_enable_low_power_mode;
+ break;
+ case AP_POWER_RESUME:
+ fn = sm5803_disable_low_power_mode;
+ break;
+ default:
+ LOG_WRN("%s: power event %d is not recognized", __func__,
+ data.event);
+ return;
+ }
+
+ fn(CHARGER_PRIMARY);
+ if (board_get_charger_chip_count() > 1)
+ fn(CHARGER_SECONDARY);
+}
+
+static int board_chargers_suspend_init(const struct device *unused)
+{
+ static struct ap_power_ev_callback cb = {
+ .handler = board_chargers_suspend,
+ .events = AP_POWER_SUSPEND | AP_POWER_RESUME,
+ };
+ ap_power_ev_add_callback(&cb);
+ return 0;
+}
+SYS_INIT(board_chargers_suspend_init, APPLICATION, 0);
+
+int board_set_active_charge_port(int port)
+{
+ int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count());
+ int i;
+ int old_port;
+ int rv;
+
+ if (!is_real_port && port != CHARGE_PORT_NONE)
+ return EC_ERROR_INVAL;
+
+ old_port = charge_manager_get_active_charge_port();
+ LOG_INF("Charge update: p%d -> p%d", old_port, port);
+
+ /* Check if port is sourcing VBUS. */
+ if (port != CHARGE_PORT_NONE && charger_is_sourcing_otg_power(port)) {
+ LOG_WRN("Skip enable p%d: already sourcing", port);
+ return EC_ERROR_INVAL;
+ }
+
+ /* Disable sinking on all ports except the desired one */
+ for (i = 0; i < board_get_usb_pd_port_count(); i++) {
+ if (i == port)
+ continue;
+
+ if (sm5803_vbus_sink_enable(i, 0))
+ /*
+ * Do not early-return because this can fail during
+ * power-on which would put us into a loop.
+ */
+ LOG_WRN("p%d: sink path disable failed.", i);
+ }
+
+ /* Don't enable anything (stop here) if no ports were requested */
+ if ((port == CHARGE_PORT_NONE) || (old_port == port))
+ return EC_SUCCESS;
+
+ /*
+ * Stop the charger IC from switching while changing ports. Otherwise,
+ * we can overcurrent the adapter we're switching to. (crbug.com/926056)
+ */
+ if (old_port != CHARGE_PORT_NONE)
+ charger_discharge_on_ac(1);
+
+ /* Enable requested charge port. */
+ rv = sm5803_vbus_sink_enable(port, 1);
+ if (rv)
+ LOG_WRN("p%d: sink path enable failed: code %d", port, rv);
+
+ /* Allow the charger IC to begin/continue switching. */
+ charger_discharge_on_ac(0);
+
+ return rv;
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ /*
+ * TCPC 0 is embedded in the EC and processes interrupts in the chip
+ * code (it83xx/intc.c). This function only needs to poll port C1 if
+ * present.
+ */
+ uint16_t status = 0;
+ int regval;
+
+ /* Is the C1 port present and its IRQ line asserted? */
+ if (board_get_usb_pd_port_count() == 2 &&
+ !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ /*
+ * C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if
+ * it asserted the IRQ.
+ */
+ if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
+ if (regval)
+ status = PD_STATUS_TCPC_ALERT_1;
+ }
+ }
+
+ return status;
+}
+
+void pd_power_supply_reset(int port)
+{
+ int prev_en;
+
+ if (port < 0 || port >= board_get_usb_pd_port_count())
+ return;
+
+ prev_en = charger_is_sourcing_otg_power(port);
+
+ /* Disable Vbus */
+ charger_enable_otg_power(port, 0);
+
+ /* Discharge Vbus if previously enabled */
+ if (prev_en)
+ sm5803_set_vbus_disch(port, 1);
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ enum ec_error_list rv;
+
+ if (port < 0 || port > board_get_usb_pd_port_count()) {
+ LOG_WRN("Port C%d does not exist, cannot enable VBUS", port);
+ return EC_ERROR_INVAL;
+ }
+
+ /* Disable sinking */
+ rv = sm5803_vbus_sink_enable(port, 0);
+ if (rv) {
+ LOG_WRN("C%d failed to disable sinking: %d", port, rv);
+ return rv;
+ }
+
+ /* Disable Vbus discharge */
+ rv = sm5803_set_vbus_disch(port, 0);
+ if (rv) {
+ LOG_WRN("C%d failed to clear VBUS discharge: %d", port, rv);
+ return rv;
+ }
+
+ /* Provide Vbus */
+ rv = charger_enable_otg_power(port, 1);
+ if (rv) {
+ LOG_WRN("C%d failed to enable VBUS sourcing: %d", port, rv);
+ return rv;
+ }
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
+}
+
+__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ int rv;
+ const int current = rp == TYPEC_RP_3A0 ? 3000 : 1500;
+
+ rv = charger_set_otg_current_voltage(port, current, 5000);
+ if (rv != EC_SUCCESS) {
+ LOG_WRN("Failed to set source ilimit on port %d to %d: %d",
+ port, current, rv);
+ }
+}
+
+void board_reset_pd_mcu(void)
+{
+ /*
+ * Do nothing. The integrated TCPC for C0 lacks a dedicated reset
+ * command, and C1 (if present) doesn't have a reset pin connected
+ * to the EC.
+ */
+}
+
+#define INT_RECHECK_US 5000
+
+/* C0 interrupt line shared by BC 1.2 and charger */
+
+static void check_c0_line(void);
+DECLARE_DEFERRED(check_c0_line);
+
+static void notify_c0_chips(void)
+{
+ usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
+ sm5803_interrupt(0);
+}
+
+static void check_c0_line(void)
+{
+ /*
+ * If line is still being held low, see if there's more to process from
+ * one of the chips
+ */
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
+ notify_c0_chips();
+ hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
+ }
+}
+
+void usb_c0_interrupt(enum gpio_signal s)
+{
+ /* Cancel any previous calls to check the interrupt line */
+ hook_call_deferred(&check_c0_line_data, -1);
+
+ /* Notify all chips using this line that an interrupt came in */
+ notify_c0_chips();
+
+ /* Check the line again in 5ms */
+ hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
+}
+
+/* C1 interrupt line shared by BC 1.2, TCPC, and charger */
+static void check_c1_line(void);
+DECLARE_DEFERRED(check_c1_line);
+
+static void notify_c1_chips(void)
+{
+ schedule_deferred_pd_interrupt(1);
+ usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
+ /* Charger is handled in board_process_pd_alert */
+}
+
+static void check_c1_line(void)
+{
+ /*
+ * If line is still being held low, see if there's more to process from
+ * one of the chips.
+ */
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ notify_c1_chips();
+ hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
+ }
+}
+
+void usb_c1_interrupt(enum gpio_signal s)
+{
+ /* Cancel any previous calls to check the interrupt line */
+ hook_call_deferred(&check_c1_line_data, -1);
+
+ /* Notify all chips using this line that an interrupt came in */
+ notify_c1_chips();
+
+ /* Check the line again in 5ms */
+ hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
+}
+
+/*
+ * Check state of IRQ lines at startup, ensuring an IRQ that happened before
+ * the EC started up won't get lost (leaving the IRQ line asserted and blocking
+ * any further interrupts on the port).
+ *
+ * Although the PD task will check for pending TCPC interrupts on startup,
+ * the charger sharing the IRQ will not be polled automatically.
+ */
+void board_handle_initial_typec_irq(void)
+{
+ check_c0_line();
+ if (board_get_usb_pd_port_count() == 2)
+ check_c1_line();
+}
+/*
+ * This must run after sub-board detection (which happens in EC main()),
+ * but isn't depended on by anything else either.
+ */
+DECLARE_HOOK(HOOK_INIT, board_handle_initial_typec_irq, HOOK_PRIO_LAST);
+
+/*
+ * Handle charger interrupts in the PD task. Not doing so can lead to a priority
+ * inversion where we fail to respond to TCPC alerts quickly enough because we
+ * don't get another edge on a shared IRQ until the charger interrupt is cleared
+ * (or the IRQ is polled again), which happens in the low-priority charger task:
+ * the high-priority type-C handler is thus blocked on the lower-priority
+ * charger.
+ *
+ * To avoid that, we run charger interrupts at the same priority.
+ */
+void board_process_pd_alert(int port)
+{
+ /*
+ * Port 0 doesn't use an external TCPC, so its interrupts don't need
+ * this special handling.
+ */
+ if (port == 1 &&
+ !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
+ sm5803_handle_interrupt(port);
+ }
+}
+
+int pd_snk_is_vbus_provided(int port)
+{
+ int chg_det = 0;
+
+ sm5803_get_chg_det(port, &chg_det);
+
+ return chg_det;
+}
diff --git a/zephyr/projects/nissa/yaviks/yaviks_vif.xml b/zephyr/program/nissa/yaviks/yaviks_vif.xml
index edc6299c58..edc6299c58 100644
--- a/zephyr/projects/nissa/yaviks/yaviks_vif.xml
+++ b/zephyr/program/nissa/yaviks/yaviks_vif.xml
diff --git a/zephyr/projects/npcx_evb/npcx7/BUILD.py b/zephyr/program/npcx_evb/npcx7/BUILD.py
index baa6774595..baa6774595 100644
--- a/zephyr/projects/npcx_evb/npcx7/BUILD.py
+++ b/zephyr/program/npcx_evb/npcx7/BUILD.py
diff --git a/zephyr/projects/npcx_evb/npcx7/CMakeLists.txt b/zephyr/program/npcx_evb/npcx7/CMakeLists.txt
index 64429d586e..64429d586e 100644
--- a/zephyr/projects/npcx_evb/npcx7/CMakeLists.txt
+++ b/zephyr/program/npcx_evb/npcx7/CMakeLists.txt
diff --git a/zephyr/projects/npcx_evb/npcx7/fan.dts b/zephyr/program/npcx_evb/npcx7/fan.dts
index dc4debdcb9..dc4debdcb9 100644
--- a/zephyr/projects/npcx_evb/npcx7/fan.dts
+++ b/zephyr/program/npcx_evb/npcx7/fan.dts
diff --git a/zephyr/projects/npcx_evb/npcx7/gpio.dts b/zephyr/program/npcx_evb/npcx7/gpio.dts
index d44927609d..d44927609d 100644
--- a/zephyr/projects/npcx_evb/npcx7/gpio.dts
+++ b/zephyr/program/npcx_evb/npcx7/gpio.dts
diff --git a/zephyr/projects/npcx_evb/npcx7/interrupts.dts b/zephyr/program/npcx_evb/npcx7/interrupts.dts
index 3e92428ef4..3e92428ef4 100644
--- a/zephyr/projects/npcx_evb/npcx7/interrupts.dts
+++ b/zephyr/program/npcx_evb/npcx7/interrupts.dts
diff --git a/zephyr/program/npcx_evb/npcx7/keyboard.dts b/zephyr/program/npcx_evb/npcx7/keyboard.dts
new file mode 100644
index 0000000000..e7e35d1493
--- /dev/null
+++ b/zephyr/program/npcx_evb/npcx7/keyboard.dts
@@ -0,0 +1,42 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ cros-keyscan {
+ compatible = "cros-ec,keyscan";
+
+ output-settle = <40>;
+ debounce-down = <6000>;
+ scan-period = <1500>;
+ poll-timeout = <1000000>;
+
+ actual-key-mask = <
+ 0x14 /* C0 */
+ 0xff /* C1 */
+ 0xff /* C2 */
+ 0xff /* C3 */
+ 0xff /* C4 */
+ 0xf5 /* C5 */
+ 0xff /* C6 */
+ 0xa4 /* C7 */
+ 0xff /* C8 */
+ 0xf6 /* C9 */
+ 0x55 /* C10 */
+ 0xfa /* C11 */
+ 0xc8 /* C12 */
+ >;
+ };
+
+ kblight {
+ compatible = "cros-ec,kblight-pwm";
+ pwms = <&pwm2 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>;
+ };
+};
+
+&pwm2 {
+ status = "okay";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/program/npcx_evb/npcx7/prj.conf b/zephyr/program/npcx_evb/npcx7/prj.conf
new file mode 100644
index 0000000000..f94c5ac2fa
--- /dev/null
+++ b/zephyr/program/npcx_evb/npcx7/prj.conf
@@ -0,0 +1,56 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_CROS_EC=y
+CONFIG_PLATFORM_EC=y
+CONFIG_PLATFORM_EC_BRINGUP=y
+CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
+CONFIG_PLATFORM_EC_LID_SWITCH=y
+CONFIG_PLATFORM_EC_POWER_BUTTON=y
+CONFIG_SHIMMED_TASKS=y
+
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
+CONFIG_PLATFORM_EC_SWITCH=n
+CONFIG_PLATFORM_EC_VBOOT_EFS2=n
+CONFIG_PLATFORM_EC_VSTORE=n
+
+# Board version is selected over GPIO board ID pins.
+CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y
+
+# Sensors
+CONFIG_SENSOR=y
+CONFIG_SENSOR_SHELL=n
+
+# Console command
+CONFIG_PLATFORM_EC_CONSOLE_CMD_SCRATCHPAD=y
+
+CONFIG_TRACING=y
+CONFIG_TRACING_ISR=y
+CONFIG_TRACING_USER=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_IRQ=y
+
+# eSPI
+CONFIG_ESPI=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
+
+# Keyboard
+CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y
+
+# RTC
+CONFIG_PLATFORM_EC_RTC=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y
+
+# USB-C
+CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
+CONFIG_PLATFORM_EC_USB_PD_USB4=n
+
+# Zephyr feature
+CONFIG_ASSERT=y
+CONFIG_SHELL_MINIMAL=n
+
+# Avoid underflow info from tachometer
+CONFIG_SENSOR_LOG_LEVEL_ERR=y
+
+CONFIG_SYSCON=y
diff --git a/zephyr/projects/npcx_evb/npcx9/BUILD.py b/zephyr/program/npcx_evb/npcx9/BUILD.py
index 335f410d9b..335f410d9b 100644
--- a/zephyr/projects/npcx_evb/npcx9/BUILD.py
+++ b/zephyr/program/npcx_evb/npcx9/BUILD.py
diff --git a/zephyr/projects/npcx_evb/npcx9/CMakeLists.txt b/zephyr/program/npcx_evb/npcx9/CMakeLists.txt
index ef734c06f6..ef734c06f6 100644
--- a/zephyr/projects/npcx_evb/npcx9/CMakeLists.txt
+++ b/zephyr/program/npcx_evb/npcx9/CMakeLists.txt
diff --git a/zephyr/projects/npcx_evb/npcx9/fan.dts b/zephyr/program/npcx_evb/npcx9/fan.dts
index dc4debdcb9..dc4debdcb9 100644
--- a/zephyr/projects/npcx_evb/npcx9/fan.dts
+++ b/zephyr/program/npcx_evb/npcx9/fan.dts
diff --git a/zephyr/projects/npcx_evb/npcx9/gpio.dts b/zephyr/program/npcx_evb/npcx9/gpio.dts
index 9a32112471..9a32112471 100644
--- a/zephyr/projects/npcx_evb/npcx9/gpio.dts
+++ b/zephyr/program/npcx_evb/npcx9/gpio.dts
diff --git a/zephyr/projects/npcx_evb/npcx9/interrupts.dts b/zephyr/program/npcx_evb/npcx9/interrupts.dts
index 3e92428ef4..3e92428ef4 100644
--- a/zephyr/projects/npcx_evb/npcx9/interrupts.dts
+++ b/zephyr/program/npcx_evb/npcx9/interrupts.dts
diff --git a/zephyr/program/npcx_evb/npcx9/keyboard.dts b/zephyr/program/npcx_evb/npcx9/keyboard.dts
new file mode 100644
index 0000000000..e7e35d1493
--- /dev/null
+++ b/zephyr/program/npcx_evb/npcx9/keyboard.dts
@@ -0,0 +1,42 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ cros-keyscan {
+ compatible = "cros-ec,keyscan";
+
+ output-settle = <40>;
+ debounce-down = <6000>;
+ scan-period = <1500>;
+ poll-timeout = <1000000>;
+
+ actual-key-mask = <
+ 0x14 /* C0 */
+ 0xff /* C1 */
+ 0xff /* C2 */
+ 0xff /* C3 */
+ 0xff /* C4 */
+ 0xf5 /* C5 */
+ 0xff /* C6 */
+ 0xa4 /* C7 */
+ 0xff /* C8 */
+ 0xf6 /* C9 */
+ 0x55 /* C10 */
+ 0xfa /* C11 */
+ 0xc8 /* C12 */
+ >;
+ };
+
+ kblight {
+ compatible = "cros-ec,kblight-pwm";
+ pwms = <&pwm2 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>;
+ };
+};
+
+&pwm2 {
+ status = "okay";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/program/npcx_evb/npcx9/prj.conf b/zephyr/program/npcx_evb/npcx9/prj.conf
new file mode 100644
index 0000000000..73b263c830
--- /dev/null
+++ b/zephyr/program/npcx_evb/npcx9/prj.conf
@@ -0,0 +1,60 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_CROS_EC=y
+CONFIG_PLATFORM_EC=y
+CONFIG_PLATFORM_EC_BRINGUP=y
+CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
+CONFIG_PLATFORM_EC_LID_SWITCH=y
+CONFIG_PLATFORM_EC_POWER_BUTTON=y
+CONFIG_SHIMMED_TASKS=y
+
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
+CONFIG_PLATFORM_EC_SWITCH=n
+CONFIG_PLATFORM_EC_VBOOT_EFS2=n
+CONFIG_PLATFORM_EC_VSTORE=n
+
+# Workaround npcx9 A1 chip's bug for download_from_flash API in th booter.
+# This can be removed when A2 chip is available.
+CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y
+
+# Board version is selected over GPIO board ID pins.
+CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y
+
+# Sensors
+CONFIG_SENSOR=y
+CONFIG_SENSOR_SHELL=n
+
+# Console command
+CONFIG_PLATFORM_EC_CONSOLE_CMD_SCRATCHPAD=y
+
+CONFIG_TRACING=y
+CONFIG_TRACING_ISR=y
+CONFIG_TRACING_USER=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_IRQ=y
+
+# eSPI
+CONFIG_ESPI=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
+
+# Keyboard
+CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y
+
+# RTC
+CONFIG_PLATFORM_EC_RTC=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y
+
+# USB-C
+CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
+CONFIG_PLATFORM_EC_USB_PD_USB4=n
+
+# Zephyr feature
+CONFIG_ASSERT=y
+CONFIG_SHELL_MINIMAL=n
+
+# Avoid underflow info from tachometer
+CONFIG_SENSOR_LOG_LEVEL_ERR=y
+
+CONFIG_SYSCON=y
diff --git a/zephyr/projects/rex/BUILD.py b/zephyr/program/rex/BUILD.py
index 2537f61226..2537f61226 100644
--- a/zephyr/projects/rex/BUILD.py
+++ b/zephyr/program/rex/BUILD.py
diff --git a/zephyr/projects/rex/CMakeLists.txt b/zephyr/program/rex/CMakeLists.txt
index 27d7dff068..27d7dff068 100644
--- a/zephyr/projects/rex/CMakeLists.txt
+++ b/zephyr/program/rex/CMakeLists.txt
diff --git a/zephyr/projects/rex/Kconfig b/zephyr/program/rex/Kconfig
index 7d17c27815..7d17c27815 100644
--- a/zephyr/projects/rex/Kconfig
+++ b/zephyr/program/rex/Kconfig
diff --git a/zephyr/projects/rex/battery.dts b/zephyr/program/rex/battery.dts
index e11346f48d..e11346f48d 100644
--- a/zephyr/projects/rex/battery.dts
+++ b/zephyr/program/rex/battery.dts
diff --git a/zephyr/projects/rex/fan.dts b/zephyr/program/rex/fan.dts
index aa6dcfde7d..aa6dcfde7d 100644
--- a/zephyr/projects/rex/fan.dts
+++ b/zephyr/program/rex/fan.dts
diff --git a/zephyr/projects/rex/generated.dts b/zephyr/program/rex/generated.dts
index 5b6f9cd708..5b6f9cd708 100644
--- a/zephyr/projects/rex/generated.dts
+++ b/zephyr/program/rex/generated.dts
diff --git a/zephyr/projects/rex/include/gpio_map.h b/zephyr/program/rex/include/gpio_map.h
index 01cbc44396..01cbc44396 100644
--- a/zephyr/projects/rex/include/gpio_map.h
+++ b/zephyr/program/rex/include/gpio_map.h
diff --git a/zephyr/projects/rex/interrupts.dts b/zephyr/program/rex/interrupts.dts
index 7de9141caf..7de9141caf 100644
--- a/zephyr/projects/rex/interrupts.dts
+++ b/zephyr/program/rex/interrupts.dts
diff --git a/zephyr/projects/rex/keyboard.dts b/zephyr/program/rex/keyboard.dts
index 91fad2db92..91fad2db92 100644
--- a/zephyr/projects/rex/keyboard.dts
+++ b/zephyr/program/rex/keyboard.dts
diff --git a/zephyr/program/rex/led.dts b/zephyr/program/rex/led.dts
new file mode 100644
index 0000000000..fb31eaac43
--- /dev/null
+++ b/zephyr/program/rex/led.dts
@@ -0,0 +1,122 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pins = <&gpio_led_1_l &gpio_led_2_l>;
+ led-values = <1 1>;
+ };
+
+ color_white: color-white {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-pins = <&gpio_led_1_l &gpio_led_2_l>;
+ led-values = <1 0>;
+ };
+
+ color_amber: color-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pins = <&gpio_led_1_l &gpio_led_2_l>;
+ led-values = <0 1>;
+ };
+ };
+
+ led-colors {
+ compatible = "cros-ec,led-policy";
+
+ power-state-charge {
+ charge-state = "PWR_STATE_CHARGE";
+
+ color-0 {
+ led-color = <&color_amber>;
+ };
+ };
+
+ power-state-discharge-s0 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+
+ color-0 {
+ led-color = <&color_off>;
+ };
+ };
+
+ power-state-discharge-s3 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S3";
+
+ /* Blue 1 sec, off 3 sec */
+ color-0 {
+ led-color = <&color_white>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <3000>;
+ };
+ };
+
+ power-state-discharge-s5 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S5";
+
+ color-0 {
+ led-color = <&color_off>;
+ };
+ };
+
+ power-state-error {
+ charge-state = "PWR_STATE_ERROR";
+
+ /* Red 1 sec, off 1 sec */
+ color-0 {
+ led-color = <&color_white>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <1000>;
+ };
+ };
+
+ power-state-near-full {
+ charge-state = "PWR_STATE_CHARGE_NEAR_FULL";
+
+ color-0 {
+ led-color = <&color_amber>;
+ };
+ };
+
+ power-state-forced-idle {
+ charge-state = "PWR_STATE_FORCED_IDLE";
+
+ /* White 2 sec, Amber 2 sec */
+ color-0 {
+ led-color = <&color_white>;
+ period-ms = <2000>;
+ };
+ color-1 {
+ led-color = <&color_amber>;
+ period-ms = <2000>;
+ };
+ };
+
+ power-state-idle-default {
+ charge-state = "PWR_STATE_IDLE";
+
+ color-0 {
+ led-color = <&color_white>;
+ };
+ };
+ };
+};
diff --git a/zephyr/projects/rex/motionsense.dts b/zephyr/program/rex/motionsense.dts
index 6af7cd2b12..6af7cd2b12 100644
--- a/zephyr/projects/rex/motionsense.dts
+++ b/zephyr/program/rex/motionsense.dts
diff --git a/zephyr/program/rex/power_signals.dts b/zephyr/program/rex/power_signals.dts
new file mode 100644
index 0000000000..09c84b8558
--- /dev/null
+++ b/zephyr/program/rex/power_signals.dts
@@ -0,0 +1,152 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ chosen {
+ intel-ap-pwrseq,espi = &espi0;
+ };
+
+ common-pwrseq {
+ compatible = "intel,ap-pwrseq";
+
+ sys-pwrok-delay = <3>;
+ all-sys-pwrgd-timeout = <20>;
+ };
+
+ pwr-en-pp3300-s5 {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "PP1800_S5/PP3300_S5 enable output to LS";
+ enum-name = "PWR_EN_PP3300_A";
+ gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>;
+ output;
+ };
+ pwr-pg-ec-rsmrst-od {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "RSMRST power good from regulator";
+ enum-name = "PWR_RSMRST";
+ gpios = <&gpioe 2 GPIO_ACTIVE_HIGH>;
+ interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ };
+ pwr-ec-pch-rsmrst-odl {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "RSMRST output to PCH";
+ enum-name = "PWR_EC_PCH_RSMRST";
+ gpios = <&gpioa 6 GPIO_ACTIVE_HIGH>;
+ output;
+ };
+ pwr-pch-pwrok {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "PCH_PWROK output to PCH";
+ enum-name = "PWR_PCH_PWROK";
+ gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>;
+ output;
+ };
+ pwr-ec-pch-sys-pwrok {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SYS_PWROK output to PCH";
+ enum-name = "PWR_EC_PCH_SYS_PWROK";
+ gpios = <&gpiob 0 GPIO_ACTIVE_HIGH>;
+ output;
+ };
+ pwr-sys-rst-l {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SYS_RESET# output to PCH";
+ enum-name = "PWR_SYS_RST";
+ gpios = <&gpioc 5 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
+ output;
+ };
+ pwr-slp-s0-l {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SLP_S0_L input from PCH";
+ enum-name = "PWR_SLP_S0";
+ gpios = <&gpiod 5 GPIO_ACTIVE_LOW>;
+ interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ };
+ pwr-slp-s3-l {
+ compatible = "intel,ap-pwrseq-vw";
+ dbg-label = "SLP_S3_L input from PCH";
+ enum-name = "PWR_SLP_S3";
+ virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4";
+ vw-invert;
+/*
+ * TODO: Initially, use virtual wire for sleep S3 signal instead of
+ * of the GPIO signal which also exists.
+ * compatible = "intel,ap-pwrseq-gpio";
+ * gpios = <&gpio4 1 GPIO_ACTIVE_LOW>;
+ * interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ */
+ };
+ pwr-slp-s4 {
+ compatible = "intel,ap-pwrseq-vw";
+ dbg-label = "SLP_S4 virtual wire input from PCH";
+ enum-name = "PWR_SLP_S4";
+ virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4";
+ vw-invert;
+ };
+ pwr-slp-s5 {
+ compatible = "intel,ap-pwrseq-vw";
+ dbg-label = "SLP_S5 virtual wire input from PCH";
+ enum-name = "PWR_SLP_S5";
+ virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5";
+ vw-invert;
+ };
+ pwr-all-sys-pwrgd {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "all power good";
+ enum-name = "PWR_ALL_SYS_PWRGD";
+ gpios = <&gpiof 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
+ interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ };
+};
+
+/*
+ * Because the power signals directly reference the GPIOs,
+ * the corresponding named-gpios need to have no-auto-init set.
+ */
+ /* pwr-en-pp3300-s5 */
+&gpio_en_s5_rails {
+ no-auto-init;
+};
+
+/* pwr-pg-ec-rsmrst-od */
+&gpio_seq_ec_rsmrst_odl {
+ no-auto-init;
+};
+
+/* pwr-ec-pch-rsmrst-odl */
+&gpio_ec_soc_rsmrst_l {
+ no-auto-init;
+};
+
+/* pwr-pch-pwrok */
+&gpio_soc_pwrok {
+ no-auto-init;
+};
+
+/* pwr-ec-pch-sys-pwrok */
+&gpio_sys_pwrok {
+ no-auto-init;
+};
+
+/* pwr-sys-rst-l */
+&gpio_sys_rst_odl {
+ no-auto-init;
+};
+
+/* pwr-slp-s0-l */
+&gpio_sys_slp_s0ix_3v3_l {
+ no-auto-init;
+};
+
+/* pwr-slp-s3-l */
+&gpio_slp_s3_ls_l {
+ no-auto-init;
+};
+
+/* pwr-all-sys-pwrgd */
+&gpio_seq_ec_all_sys_pg {
+ no-auto-init;
+};
+
diff --git a/zephyr/program/rex/prj.conf b/zephyr/program/rex/prj.conf
new file mode 100644
index 0000000000..221f1e712b
--- /dev/null
+++ b/zephyr/program/rex/prj.conf
@@ -0,0 +1,151 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_PLATFORM_EC=y
+CONFIG_CROS_EC=y
+CONFIG_SHIMMED_TASKS=y
+CONFIG_SYSCON=y
+# Enable during development
+CONFIG_LTO=n
+CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
+CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y
+
+# Shell Commands
+CONFIG_SHELL_HELP=y
+CONFIG_SHELL_HISTORY=y
+CONFIG_SHELL_TAB=y
+CONFIG_SHELL_TAB_AUTOCOMPLETION=y
+CONFIG_KERNEL_SHELL=y
+
+# Disable default features we don't want in a minimal example.
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=y
+CONFIG_PLATFORM_EC_SWITCH=y
+CONFIG_PLATFORM_EC_VBOOT_EFS2=y
+
+# Application processor; communicates with EC via eSPI
+CONFIG_AP=y
+CONFIG_ESPI=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
+CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y
+CONFIG_PLATFORM_EC_HOSTCMD=y
+# Disabling this until temp sensor support is in
+CONFIG_PLATFORM_EC_THROTTLE_AP=n
+CONFIG_PLATFORM_EC_PORT80=y
+
+# Power Sequecing
+CONFIG_AP_X86_INTEL_MTL=y
+CONFIG_X86_NON_DSX_PWRSEQ_MTL=y
+CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y
+# TODO (b/240434243): This may be needed, but using eSPI VW for now
+CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE=n
+CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
+
+# Zephyr Inbuilt AP Power Sequencing Config
+CONFIG_AP_PWRSEQ=y
+CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y
+CONFIG_AP_PWRSEQ_S0IX=y
+
+# I2C
+CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y
+
+# Temperature sensors
+CONFIG_SENSOR=y
+CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y
+
+# CBI EEPROM support
+CONFIG_EEPROM=y
+CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
+CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_DT=y
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_SMART=y
+CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
+CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
+CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
+CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
+
+# Charger
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
+CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT=512
+CONFIG_PLATFORM_EC_CHARGER_ISL9241=y
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10
+CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=30000
+CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000
+CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512
+
+# USBC
+CONFIG_PLATFORM_EC_USBC_PPC=y
+CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y
+CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y
+CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y
+CONFIG_PLATFORM_EC_USBC_PPC_SYV682X_SMART_DISCHARGE=y
+CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB=y
+CONFIG_PLATFORM_EC_USBC_VCONN=y
+
+CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_FRS=y
+CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_REV30=y
+CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815=y
+CONFIG_PLATFORM_EC_USB_PD_TRY_SRC=y
+CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=y
+CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y
+CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y
+CONFIG_PLATFORM_EC_USB_PD_USB4=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
+CONFIG_PLATFORM_EC_USB_PID=0x504D
+
+#USB Mux
+CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
+CONFIG_PLATFORM_EC_USB_MUX_TASK=y
+
+# External power
+CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
+
+# Standard shimmed features
+CONFIG_PLATFORM_EC_POWER_BUTTON=y
+CONFIG_PLATFORM_EC_LID_SWITCH=y
+
+# Keyboard support
+CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y
+# Column 2 is driven through the GSC, which inverts the signal going through it
+CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
+
+# MKBP event
+CONFIG_PLATFORM_EC_MKBP_EVENT=y
+CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
+CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y
+
+# Sensors console command
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y
+
+# Sensors
+CONFIG_SENSOR=y
+CONFIG_SENSOR_SHELL=n
+CONFIG_PLATFORM_EC_MOTIONSENSE=y
+CONFIG_PLATFORM_EC_ACCEL_FIFO=y
+CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y
+CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
+CONFIG_PLATFORM_EC_LID_ANGLE=y
+CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
+CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
+CONFIG_PLATFORM_EC_TABLET_MODE=y
+CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
+
+# Sensor Drivers
+CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y
+CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
+CONFIG_PLATFORM_EC_ALS_TCS3400=y
diff --git a/zephyr/program/rex/prj_rex.conf b/zephyr/program/rex/prj_rex.conf
new file mode 100644
index 0000000000..b724a881b9
--- /dev/null
+++ b/zephyr/program/rex/prj_rex.conf
@@ -0,0 +1,6 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Rex reference-board-specific Kconfig settings.
+CONFIG_BOARD_REX=y
diff --git a/zephyr/program/rex/rex.dts b/zephyr/program/rex/rex.dts
new file mode 100644
index 0000000000..a20bfccdfe
--- /dev/null
+++ b/zephyr/program/rex/rex.dts
@@ -0,0 +1,262 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+ #include <dt-bindings/usb_pd_tcpm.h>
+
+/ {
+ aliases {
+ gpio-wp = &ec_wp_l;
+ gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ };
+
+ named-gpios {
+ compatible = "named-gpios";
+
+ ec_wp_l: write-protect {
+ gpios = <&gpioa 0 GPIO_INPUT>;
+ };
+ gpio_ec_entering_rw: ec_entering_rw {
+ enum-name = "GPIO_ENTERING_RW";
+ };
+
+ ioex_usb_c0_sbu_fault_odl: usb_c0_sbu_fault_odl {
+ gpios = <&ioex_c0_port1 2 GPIO_INPUT>;
+ };
+ ioex_usb_c0_rt_rst_ls_l: usb_c0_rt_rst_ls_l {
+ gpios = <&ioex_c0_port0 7 GPIO_OUTPUT>;
+ };
+
+ ioex_usb_c0_frs_en: usb_c0_frs_en {
+ gpios = <&ioex_c0_port0 6 GPIO_OUTPUT_LOW>;
+ };
+
+ /* Need to designate 1.8V for I2C buses on the 1800mV rail */
+ ec-i2c-sensor-scl {
+ gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec-i2c-sensor-sda {
+ gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec-i2c-c0-rt-scl {
+ gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec-i2c-c0-rt-sda {
+ gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ };
+
+ usba-port-enable-list {
+ compatible = "cros-ec,usba-port-enable-pins";
+ enable-pins = <&gpio_en_pp5000_usba_r>;
+ };
+};
+
+/* host interface */
+&espi0 {
+ status = "okay";
+ pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
+ pinctrl-names = "default";
+};
+
+/* Power switch logic input pads */
+&psl_in1_gpd2 {
+ /* LID_OPEN */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in2_gp00 {
+ /* ACOK_OD */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in4_gp02 {
+ /* MECH_PWR_BTN_ODL */
+ psl-in-mode = "edge";
+ psl-in-pol = "low-falling";
+};
+
+/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
+&power_ctrl_psl {
+ status = "okay";
+ pinctrl-names = "sleep";
+ pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in4_gp02>;
+};
+
+/* ADC and GPIO alt-function specifications */
+&adc0 {
+ pinctrl-0 = <&adc0_chan0_gp45
+ &adc0_chan1_gp44
+ &adc0_chan8_gpf1
+ &adc0_chan7_gpe1>;
+ pinctrl-names = "default";
+};
+
+&i2c0_0 {
+ label = "I2C_SENSOR";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
+ pinctrl-names = "default";
+};
+
+&i2c1_0 {
+ label = "I2C_USB_C0_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
+ pinctrl-names = "default";
+
+ tcpc_port0: nct38xx@70 {
+ compatible = "nuvoton,nct38xx";
+ gpio-dev = <&nct3807_C0>;
+ reg = <0x70>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
+
+ nct3807_C0: nct3807_C0@70 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "nuvoton,nct38xx-gpio";
+ reg = <0x70>;
+ label = "NCT3807_C0";
+
+ ioex_c0_port0: gpio@0 {
+ compatible = "nuvoton,nct38xx-gpio-port";
+ reg = <0x0>;
+ label = "NCT3807_C0_GPIO0";
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <8>;
+ pin_mask = <0xff>;
+ pinmux_mask = <0xf7>;
+ };
+ ioex_c0_port1: gpio@1 {
+ compatible = "nuvoton,nct38xx-gpio-port";
+ reg = <0x1>;
+ label = "NCT3807_C0_GPIO1";
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <8>;
+ pin_mask = <0xff>;
+ };
+ };
+
+ nct3808_alert_0 {
+ compatible = "nuvoton,nct38xx-gpio-alert";
+ irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>;
+ nct38xx-dev = <&nct3807_C0>;
+ label = "NCT3807_ALERT_0";
+ };
+};
+
+&i2c2_0 {
+ label = "I2C_PPC0";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>;
+ pinctrl-names = "default";
+
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ irq = <&int_usb_c0_bc12>;
+ };
+
+ ppc_port0_syv: ppc_syv@40 {
+ compatible = "silergy,syv682x";
+ status = "okay";
+ reg = <0x40>;
+ frs_en_gpio = <&ioex_usb_c0_frs_en>;
+ };
+};
+
+&i2c3_0 {
+ label = "I2C_USB_C0_RT";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
+ pinctrl-names = "default";
+
+ usb_c0_hb_retimer: jhl8040r-c0@56 {
+ compatible = "intel,jhl8040r";
+ reg = <0x56>;
+ ls-en-pin = <&gpio_usb_c0_rt_3p3_sx_en>;
+ int-pin = <&gpio_usb_c0_rt_int_odl>;
+ reset-pin = <&ioex_usb_c0_rt_rst_ls_l>;
+ };
+};
+
+&i2c4_1 {
+ label = "I2C_USB_C1_TCPC";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>;
+ pinctrl-names = "default";
+
+ tcpc_port1: ps8xxx@b {
+ compatible = "parade,ps8xxx";
+ reg = <0xb>;
+ tcpc-flags = <(
+ TCPC_FLAGS_TCPCI_REV2_0 |
+ TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V |
+ TCPC_FLAGS_CONTROL_VCONN |
+ TCPC_FLAGS_CONTROL_FRS)>;
+ };
+};
+
+&i2c5_0 {
+ label = "I2C_BATTERY";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+
+ pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>;
+ pinctrl-names = "default";
+};
+
+&i2c6_1 {
+ label = "I2C_USB_1_MIX";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>;
+ pinctrl-names = "default";
+
+ bc12_port1: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ irq = <&int_usb_c1_bc12>;
+ };
+
+ ppc_port1_nxp: nx20p348x@72 {
+ compatible = "nxp,nx20p348x";
+ status = "okay";
+ reg = <0x72>;
+ };
+};
+
+&i2c7_0 {
+ label = "I2C_CHARGER";
+ clock-frequency = <I2C_BITRATE_FAST>;
+
+ pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
+ pinctrl-names = "default";
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+
+ charger: isl9241@9 {
+ compatible = "intersil,isl9241";
+ status = "okay";
+ reg = <0x09>;
+ };
+};
diff --git a/zephyr/projects/rex/rex0_gpio.csv b/zephyr/program/rex/rex0_gpio.csv
index 5c20f6fb00..5c20f6fb00 100644
--- a/zephyr/projects/rex/rex0_gpio.csv
+++ b/zephyr/program/rex/rex0_gpio.csv
diff --git a/zephyr/program/rex/src/board_power.c b/zephyr/program/rex/src/board_power.c
new file mode 100644
index 0000000000..655edaa452
--- /dev/null
+++ b/zephyr/program/rex/src/board_power.c
@@ -0,0 +1,61 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gpio/gpio.h"
+#include "gpio_signal.h"
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+
+#include <ap_power/ap_power.h>
+#include <ap_power/ap_power_events.h>
+#include <ap_power/ap_power_interface.h>
+#include <ap_power_override_functions.h>
+#include <power_signals.h>
+#include <x86_power_signals.h>
+
+LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF);
+
+#if CONFIG_X86_NON_DSX_PWRSEQ_MTL
+#define X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS 50
+
+void board_ap_power_force_shutdown(void)
+{
+ int timeout_ms = X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS;
+
+ /* Turn off PCH_RMSRST to meet tPCH12 */
+ power_signal_set(PWR_EC_PCH_RSMRST, 0);
+
+ /* Turn off PRIM load switch. */
+ power_signal_set(PWR_EN_PP3300_A, 0);
+
+ /* Wait RSMRST to be off. */
+ while (power_signal_get(PWR_RSMRST) && (timeout_ms > 0)) {
+ k_msleep(1);
+ timeout_ms--;
+ };
+
+ if (power_signal_get(PWR_RSMRST)) {
+ LOG_WRN("RSMRST_ODL didn't go low! Assuming G3.");
+ }
+}
+
+void board_ap_power_action_g3_s5(void)
+{
+ /* Turn on the PP3300_PRIM rail. */
+ power_signal_set(PWR_EN_PP3300_A, 1);
+
+ if (!power_wait_signals_timeout(
+ IN_PGOOD_ALL_CORE,
+ AP_PWRSEQ_DT_VALUE(wait_signal_timeout))) {
+ ap_power_ev_send_callbacks(AP_POWER_PRE_INIT);
+ }
+}
+
+bool board_ap_power_check_power_rails_enabled(void)
+{
+ return power_signal_get(PWR_EN_PP3300_A);
+}
+#endif /* CONFIG_X86_NON_DSX_PWRSEQ_MTL */
diff --git a/zephyr/program/rex/src/usb_pd_policy.c b/zephyr/program/rex/src/usb_pd_policy.c
new file mode 100644
index 0000000000..7c78c4ebae
--- /dev/null
+++ b/zephyr/program/rex/src/usb_pd_policy.c
@@ -0,0 +1,77 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Shared USB-C policy for Rex boards */
+
+#include "charge_manager.h"
+#include "chipset.h"
+#include "common.h"
+#include "compile_time_macros.h"
+#include "console.h"
+#include "ec_commands.h"
+#include "ioexpander.h"
+#include "system.h"
+#include "usb_mux.h"
+#include "usb_pd.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+#include <zephyr/drivers/gpio.h>
+
+int pd_check_vconn_swap(int port)
+{
+ /* Allow VCONN swaps if the AP is on. */
+ return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON);
+}
+
+void pd_power_supply_reset(int port)
+{
+ /* Disable VBUS. */
+ ppc_vbus_source_enable(port, 0);
+
+ /* Enable discharge if we were previously sourcing 5V */
+ if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE))
+ pd_set_vbus_discharge(port, 1);
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ int rv;
+
+ /* Disable charging. */
+ rv = ppc_vbus_sink_enable(port, 0);
+ if (rv)
+ return rv;
+
+ if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) {
+ pd_set_vbus_discharge(port, 0);
+ }
+
+ /* Provide Vbus. */
+ rv = ppc_vbus_source_enable(port, 1);
+ if (rv) {
+ return rv;
+ }
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
+}
+
+/* Used by Vbus discharge common code with CONFIG_USB_PD_DISCHARGE */
+int board_vbus_source_enabled(int port)
+{
+ return tcpm_get_src_ctrl(port);
+}
+
+/* Used by USB charger task with CONFIG_USB_PD_5V_EN_CUSTOM */
+int board_is_sourcing_vbus(int port)
+{
+ return board_vbus_source_enabled(port);
+}
diff --git a/zephyr/program/rex/src/usbc_config.c b/zephyr/program/rex/src/usbc_config.c
new file mode 100644
index 0000000000..df260f6730
--- /dev/null
+++ b/zephyr/program/rex/src/usbc_config.c
@@ -0,0 +1,292 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery_fuel_gauge.h"
+#include "charge_manager.h"
+#include "charge_ramp.h"
+#include "charge_state.h"
+#include "charge_state_v2.h"
+#include "charger.h"
+#include "driver/charger/isl9241.h"
+#include "driver/ppc/nx20p348x.h"
+#include "driver/retimer/bb_retimer_public.h"
+#include "driver/tcpm/nct38xx.h"
+#include "driver/tcpm/ps8xxx_public.h"
+#include "driver/tcpm/tcpci.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "ioexpander.h"
+#include "ppc/syv682x_public.h"
+#include "system.h"
+#include "task.h"
+#include "usb_mux.h"
+#include "usbc_ppc.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/*******************************************************************/
+/* USB-C Configuration Start */
+
+/* USB-C ports */
+enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
+BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT);
+
+static void usbc_interrupt_init(void)
+{
+ /* Only reset TCPC if not sysjump */
+ if (!system_jumped_late()) {
+ board_reset_pd_mcu();
+ }
+
+ /* Enable PPC interrupts. */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc));
+
+ /* Enable TCPC interrupts. */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc));
+
+ /* Enable BC 1.2 interrupts */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_bc12));
+
+ /* Enable SBU fault interrupts */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_sbu_fault));
+}
+DECLARE_HOOK(HOOK_INIT, usbc_interrupt_init, HOOK_PRIO_POST_I2C);
+
+void board_overcurrent_event(int port, int is_overcurrented)
+{
+ /*
+ * TODO: Meteorlake PCH does not use Physical GPIO for over current
+ * error, hence Send 'Over Current Virtual Wire' eSPI signal.
+ */
+}
+
+void sbu_fault_interrupt(enum gpio_signal signal)
+{
+ int port = USBC_PORT_C0;
+
+ CPRINTSUSB("C%d: SBU fault", port);
+ pd_handle_overcurrent(port);
+}
+
+void tcpc_alert_event(enum gpio_signal signal)
+{
+ int port;
+
+ switch (signal) {
+ case GPIO_USB_C0_TCPC_INT_ODL:
+ port = 0;
+ break;
+ case GPIO_USB_C1_TCPC_INT_ODL:
+ port = 1;
+ break;
+ default:
+ return;
+ }
+
+ schedule_deferred_pd_interrupt(port);
+}
+
+static void reset_nct38xx_port(int port)
+{
+ const struct gpio_dt_spec *reset_gpio_l;
+ const struct device *ioex_port0, *ioex_port1;
+
+ /* TODO(b/225189538): Save and restore ioex signals */
+ if (port == USBC_PORT_C0) {
+ reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_odl);
+ ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port0));
+ ioex_port1 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port1));
+ } else {
+ /* Invalid port: do nothing */
+ return;
+ }
+
+ gpio_pin_set_dt(reset_gpio_l, 0);
+ msleep(NCT38XX_RESET_HOLD_DELAY_MS);
+ gpio_pin_set_dt(reset_gpio_l, 1);
+ nct38xx_reset_notify(port);
+ if (NCT3807_RESET_POST_DELAY_MS != 0) {
+ msleep(NCT3807_RESET_POST_DELAY_MS);
+ }
+
+ /* Re-enable the IO expander pins */
+ gpio_reset_port(ioex_port0);
+ gpio_reset_port(ioex_port1);
+}
+
+void board_reset_pd_mcu(void)
+{
+ /* Reset TCPC0 */
+ reset_nct38xx_port(USBC_PORT_C0);
+
+ /* Reset TCPC1 */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl), 0);
+ msleep(PS8XXX_RESET_DELAY_MS);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl), 1);
+ msleep(PS8815_FW_INIT_DELAY_MS);
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ uint16_t status = 0;
+ const struct gpio_dt_spec *tcpc_c0_rst_l;
+ const struct gpio_dt_spec *tcpc_c0_int_l;
+ const struct gpio_dt_spec *tcpc_c1_rst_l;
+ const struct gpio_dt_spec *tcpc_c1_int_l;
+
+ tcpc_c0_rst_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_odl);
+ tcpc_c0_int_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl);
+
+ tcpc_c1_rst_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl);
+ tcpc_c1_int_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl);
+
+ /*
+ * Check which port has the ALERT line set and ignore if that TCPC has
+ * its reset line active.
+ */
+ if (!gpio_pin_get_dt(tcpc_c0_int_l) && gpio_pin_get_dt(tcpc_c0_rst_l)) {
+ status |= PD_STATUS_TCPC_ALERT_0;
+ }
+
+ if (!gpio_pin_get_dt(tcpc_c1_int_l) && gpio_pin_get_dt(tcpc_c1_rst_l)) {
+ status |= PD_STATUS_TCPC_ALERT_1;
+ }
+
+ return status;
+}
+
+void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_PPC_INT_ODL:
+ syv682x_interrupt(USBC_PORT_C0);
+ break;
+ case GPIO_USB_C1_PPC_INT_ODL:
+ nx20p348x_interrupt(USBC_PORT_C1);
+ break;
+ default:
+ break;
+ }
+}
+
+void bc12_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_BC12_INT_ODL:
+ usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
+ break;
+ case GPIO_USB_C1_BC12_INT_ODL:
+ usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
+ break;
+ default:
+ break;
+ }
+}
+
+static void board_disable_charger_ports(void)
+{
+ int i;
+
+ CPRINTSUSB("Disabling all charger ports");
+
+ /* Disable all ports. */
+ for (i = 0; i < ppc_cnt; i++) {
+ /*
+ * If this port had booted in dead battery mode, go
+ * ahead and reset it so EN_SNK responds properly.
+ */
+ if (nct38xx_get_boot_type(i) == NCT38XX_BOOT_DEAD_BATTERY) {
+ reset_nct38xx_port(i);
+ pd_set_error_recovery(i);
+ }
+
+ /*
+ * Do not return early if one fails otherwise we can
+ * get into a boot loop assertion failure.
+ */
+ if (ppc_vbus_sink_enable(i, 0)) {
+ CPRINTSUSB("Disabling C%d as sink failed.", i);
+ }
+ }
+}
+
+int board_set_active_charge_port(int port)
+{
+ int is_valid_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
+ int i;
+ int rv;
+
+ if (port == CHARGE_PORT_NONE) {
+ board_disable_charger_ports();
+ return EC_SUCCESS;
+ } else if (!is_valid_port) {
+ return EC_ERROR_INVAL;
+ }
+
+ /*
+ * Check if we can reset any ports in dead battery mode
+ *
+ * The NCT3807 may continue to keep EN_SNK low on the dead battery port
+ * and allow a dangerous level of voltage to pass through to the initial
+ * charge port (see b/183660105). We must reset the ports if we have
+ * sufficient battery to do so, which will bring EN_SNK back under
+ * normal control.
+ */
+ rv = EC_SUCCESS;
+ if (port == USBC_PORT_C0 &&
+ nct38xx_get_boot_type(port) == NCT38XX_BOOT_DEAD_BATTERY) {
+ /* Handle dead battery boot case */
+ CPRINTSUSB("Found dead battery on C0");
+ /*
+ * If we have battery, get this port reset ASAP.
+ * This means temporarily rejecting charge manager
+ * sets to it.
+ */
+ if (pd_is_battery_capable()) {
+ reset_nct38xx_port(port);
+ pd_set_error_recovery(port);
+ }
+ }
+
+ if (rv != EC_SUCCESS) {
+ return rv;
+ }
+
+ /* Check if the port is sourcing VBUS. */
+ if (tcpm_get_src_ctrl(port)) {
+ CPRINTSUSB("Skip enable C%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+ CPRINTSUSB("New charge port: C%d", port);
+
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < ppc_cnt; i++) {
+ if (i == port) {
+ continue;
+ }
+ if (ppc_vbus_sink_enable(i, 0)) {
+ CPRINTSUSB("C%d: sink path disable failed.", i);
+ }
+ }
+
+ /* Enable requested charge port. */
+ if (ppc_vbus_sink_enable(port, 1)) {
+ CPRINTSUSB("C%d: sink path enable failed.", port);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ return EC_SUCCESS;
+}
diff --git a/zephyr/projects/rex/temp_sensors.dts b/zephyr/program/rex/temp_sensors.dts
index 680ebc8954..680ebc8954 100644
--- a/zephyr/projects/rex/temp_sensors.dts
+++ b/zephyr/program/rex/temp_sensors.dts
diff --git a/zephyr/projects/rex/usbc.dts b/zephyr/program/rex/usbc.dts
index 84ae79fae6..84ae79fae6 100644
--- a/zephyr/projects/rex/usbc.dts
+++ b/zephyr/program/rex/usbc.dts
diff --git a/zephyr/program/skyrim/BUILD.py b/zephyr/program/skyrim/BUILD.py
new file mode 100644
index 0000000000..08c76c1f13
--- /dev/null
+++ b/zephyr/program/skyrim/BUILD.py
@@ -0,0 +1,48 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Define zmake projects for skyrim."""
+
+
+def register_skyrim_project(
+ project_name,
+):
+ """Register a variant of skyrim."""
+ register_npcx_project(
+ project_name=project_name,
+ zephyr_board="npcx9m3f",
+ dts_overlays=[
+ here / project_name / "project.overlay",
+ ],
+ kconfig_files=[
+ # Common to all projects.
+ here / "program.conf",
+ # Project-specific KConfig customization.
+ here / project_name / "project.conf",
+ ],
+ )
+
+
+register_skyrim_project(
+ project_name="morthal",
+)
+
+
+register_skyrim_project(
+ project_name="skyrim",
+)
+
+
+register_skyrim_project(
+ project_name="winterhold",
+)
+
+
+register_skyrim_project(
+ project_name="frostflow",
+)
+
+register_skyrim_project(
+ project_name="crystaldrift",
+)
diff --git a/zephyr/program/skyrim/CMakeLists.txt b/zephyr/program/skyrim/CMakeLists.txt
new file mode 100644
index 0000000000..bb1bde51a8
--- /dev/null
+++ b/zephyr/program/skyrim/CMakeLists.txt
@@ -0,0 +1,43 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+cmake_minimum_required(VERSION 3.13.1)
+
+find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+
+zephyr_library_sources("src/common.c")
+zephyr_library_sources("src/power_signals.c")
+
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
+ "src/usb_pd_policy.c"
+ "src/usbc_config.c")
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON
+ "src/led.c")
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_AMD_STT
+ "src/stt.c")
+
+if(DEFINED CONFIG_BOARD_MORTHAL)
+ project(morthal)
+ add_subdirectory(morthal)
+endif()
+
+if(DEFINED CONFIG_BOARD_SKYRIM)
+ project(skyrim)
+ add_subdirectory(skyrim)
+endif()
+
+if(DEFINED CONFIG_BOARD_WINTERHOLD)
+ project(winterhold)
+ add_subdirectory(winterhold)
+endif()
+
+if(DEFINED CONFIG_BOARD_FROSTFLOW)
+ project(frostflow)
+ add_subdirectory(frostflow)
+endif()
+
+if(DEFINED CONFIG_BOARD_CRYSTALDRIFT)
+ project(crystaldrift)
+ add_subdirectory(crystaldrift)
+endif()
diff --git a/zephyr/program/skyrim/Kconfig b/zephyr/program/skyrim/Kconfig
new file mode 100644
index 0000000000..a80ba2bd24
--- /dev/null
+++ b/zephyr/program/skyrim/Kconfig
@@ -0,0 +1,46 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+config BOARD_MORTHAL
+ bool "Google Morthal Board"
+ help
+ Build Google Morthal reference board. This board uses an AMD SoC
+ and NPCX9 EC
+
+config BOARD_SKYRIM
+ bool "Google Skyrim Board"
+ help
+ Build Google Skyrim reference board. This board uses an AMD SoC
+ and NPCX9 EC
+
+config BOARD_WINTERHOLD
+ bool "Google Winterhold Board"
+ help
+ Build Google Winterhold reference board. This board uses an AMD SoC
+ and NPCX9 EC
+
+config BOARD_FROSTFLOW
+ bool "Google Frostflow Board"
+ help
+ Build Google Frostflow reference board. This board uses an AMD SoC
+ and NPCX9 EC
+
+config BOARD_CRYSTALDRIFT
+ bool "Google Crystaldrift Board"
+ help
+ Build Google Crystaldrift reference board. This board uses an AMD SoC
+ and NPCX9 EC
+
+config BOARD_USB_HUB_RESET
+ bool "Support USB hub reset or not"
+ default y
+ help
+ Enable this if your board has a USB hub reset GPIO connect to EC to
+ reset the USB hub.
+
+module = SKYRIM
+module-str = Skyrim board-specific code
+source "subsys/logging/Kconfig.template.log_config"
+
+source "Kconfig.zephyr"
diff --git a/zephyr/program/skyrim/adc.dtsi b/zephyr/program/skyrim/adc.dtsi
new file mode 100644
index 0000000000..952e5db1d0
--- /dev/null
+++ b/zephyr/program/skyrim/adc.dtsi
@@ -0,0 +1,82 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * 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-adc-channels {
+ compatible = "named-adc-channels";
+
+ adc_temp_charger: temp-charger {
+ enum-name = "ADC_TEMP_SENSOR_CHARGER";
+ io-channels = <&adc0 1>;
+ };
+ adc_temp_memory: temp-memory {
+ enum-name = "ADC_TEMP_SENSOR_MEMORY";
+ io-channels = <&adc0 2>;
+ };
+ adc_core_imon1: core-imon1 {
+ enum-name = "ADC_CORE_IMON1";
+ io-channels = <&adc0 3>;
+ };
+ adc_core_imon2: core-imon2 {
+ enum-name = "ADC_SOC_IMON2";
+ io-channels = <&adc0 4>;
+ };
+ };
+
+ temp_charger_thermistor: charger-thermistor {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_30K9_47K_4050B>;
+ adc = <&adc_temp_charger>;
+ };
+
+ temp_memory_thermistor: memory-thermistor {
+ compatible = "cros-ec,temp-sensor-thermistor";
+ thermistor = <&thermistor_3V3_30K9_47K_4050B>;
+ adc = <&adc_temp_memory>;
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ temp_sensor_charger: charger-thermistor {
+ temp_host_high = <100>;
+ temp_host_halt = <105>;
+ temp_host_release_high = <80>;
+ sensor = <&temp_charger_thermistor>;
+ };
+
+ temp_sensor_memory: memory-thermistor {
+ temp_host_high = <100>;
+ temp_host_halt = <105>;
+ temp_host_release_high = <80>;
+ power-good-pin = <&gpio_pg_pwr_s5>;
+ sensor = <&temp_memory_thermistor>;
+ };
+
+ temp_sensor_cpu: cpu {
+ temp_host_high = <100>;
+ temp_host_halt = <105>;
+ temp_host_release_high = <80>;
+ temp_fan_off = <60>;
+ temp_fan_max = <90>;
+ power-good-pin = <&gpio_s0_pgood>;
+ sensor = <&temp_cpu>;
+ };
+ };
+};
+
+&adc0 {
+ status = "okay";
+ pinctrl-0 = <&adc0_chan1_gp44
+ &adc0_chan2_gp43
+ &adc0_chan3_gp42
+ &adc0_chan4_gp41>;
+ pinctrl-names = "default";
+};
+
+&thermistor_3V3_30K9_47K_4050B {
+ status = "okay";
+};
diff --git a/zephyr/program/skyrim/crystaldrift/CMakeLists.txt b/zephyr/program/skyrim/crystaldrift/CMakeLists.txt
new file mode 100644
index 0000000000..6e50c3d40e
--- /dev/null
+++ b/zephyr/program/skyrim/crystaldrift/CMakeLists.txt
@@ -0,0 +1,12 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+cros_ec_library_include_directories_ifdef(CONFIG_BOARD_CRYSTALDRIFT include)
+zephyr_library_sources(
+ "src/usb_mux_config.c"
+ "src/ppc_config.c"
+ "src/form_factor.c"
+ "src/alt_charger.c"
+)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/fan.c")
diff --git a/zephyr/program/skyrim/crystaldrift/battery.dtsi b/zephyr/program/skyrim/crystaldrift/battery.dtsi
new file mode 100644
index 0000000000..6b1799c233
--- /dev/null
+++ b/zephyr/program/skyrim/crystaldrift/battery.dtsi
@@ -0,0 +1,15 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ batteries {
+ default_battery: aec_5477109 {
+ compatible = "aec,5477109", "battery-smart";
+ };
+ smp_l20m3pg1 {
+ compatible = "smp,l20m3pg1", "battery-smart";
+ };
+ };
+};
diff --git a/zephyr/program/skyrim/crystaldrift/crystaldrift.dtsi b/zephyr/program/skyrim/crystaldrift/crystaldrift.dtsi
new file mode 100644
index 0000000000..812f97a7c7
--- /dev/null
+++ b/zephyr/program/skyrim/crystaldrift/crystaldrift.dtsi
@@ -0,0 +1,209 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/usbc_mux.h>
+
+#include "../i2c.dtsi"
+
+/ {
+ named-gpios {
+ /* Crystaldrift-specific GPIO customizations */
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ soc-pct2075 {
+ temp_host_high = <100>;
+ temp_host_halt = <105>;
+ temp_host_release_high = <80>;
+ temp_host_release_halt = <80>;
+ temp_fan_off = <35>;
+ temp_fan_max = <70>;
+ power-good-pin = <&gpio_pg_pwr_s5>;
+ sensor = <&soc_pct2075>;
+ };
+ amb-pct2075 {
+ power-good-pin = <&gpio_pg_pwr_s5>;
+ sensor = <&amb_pct2075>;
+ };
+ };
+
+ /*
+ * Note this is expected to vary per-board, so we keep it in the board
+ * dts files.
+ */
+ crystaldrift-fw-config {
+ compatible = "cros-ec,cbi-fw-config";
+
+ form-factor {
+ enum-name = "FW_FORM_FACTOR";
+ start = <0>;
+ size = <1>;
+
+ ff-clamshell {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FF_CLAMSHELL";
+ value = <0>;
+ };
+ ff-convertible {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FF_CONVERTIBLE";
+ value = <1>;
+ default;
+ };
+ };
+ io-db {
+ enum-name = "FW_IO_DB";
+ start = <6>;
+ size = <2>;
+
+ io-db-ps8811-ps8818 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_IO_DB_PS8811_PS8818";
+ value = <0>;
+ };
+ io-db-none-anx7483 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_IO_DB_NONE_ANX7483";
+ value = <1>;
+ default;
+ };
+ };
+
+ /*
+ * FW_CONFIG field to enable fan or not.
+ */
+ fan {
+ enum-name = "FW_FAN";
+ start = <10>;
+ size = <1>;
+
+ no-fan {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FAN_NOT_PRESENT";
+ value = <0>;
+ };
+ fan-present {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FAN_PRESENT";
+ value = <1>;
+ /*
+ * Set as default so that unprovisioned
+ * configs will run the fan regardless.
+ */
+ default;
+ };
+ };
+
+ charger-option {
+ enum-name = "FW_CHARGER";
+ start = <11>;
+ size = <2>;
+
+ charger-option-isl9241 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_CHARGER_ISL9241";
+ value = <0>;
+ default;
+ };
+ charger-option-isl9538 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_CHARGER_ISL9538";
+ value = <1>;
+ };
+ };
+ };
+
+ /* Rotation matrices for motion sensors. */
+ motionsense-rotation-ref {
+ compatible = "cros-ec,motionsense-rotation-ref";
+ lid_rot_ref: lid-rotation-ref {
+ mat33 = <0 (-1) 0
+ 1 0 0
+ 0 0 1>;
+ };
+
+ lid_rot_ref1: lid-rotation-ref1 {
+ mat33 = <0 1 0
+ (-1) 0 0
+ 0 0 1>;
+ };
+
+ base_rot_ref: base-rotation-ref {
+ mat33 = <0 1 0
+ (-1) 0 0
+ 0 0 1>;
+ };
+ };
+
+ ppc_port0: aoz1380 {
+ compatible = "aoz,aoz1380";
+ status = "okay";
+ };
+};
+
+&i2c0_0 {
+ anx7483_port0: anx7483@3e {
+ compatible = "analogix,anx7483";
+ reg = <0x3e>;
+ board-set = "board_anx7483_c0_mux_set";
+ flags = <USB_MUX_FLAG_RESETS_IN_G3>;
+ };
+};
+
+&i2c1_0 {
+ anx7483_port1: anx7483@3e {
+ compatible = "analogix,anx7483";
+ reg = <0x3e>;
+ board-set = "board_anx7483_c1_mux_set";
+ flags = <USB_MUX_FLAG_RESETS_IN_G3>;
+ };
+ ppc_port1: nx20p348x@71 {
+ compatible = "nxp,nx20p348x";
+ status = "okay";
+ reg = <0x71>;
+ };
+ ps8818_port1: ps8818@28 {
+ compatible = "parade,ps8818";
+ reg = <0x28>;
+ flags = <(USB_MUX_FLAG_RESETS_IN_G3)>;
+ board-set = "board_c1_ps8818_mux_set";
+ };
+};
+
+&i2c4_1 {
+ charger: isl9241@9 {
+ compatible = "intersil,isl9241";
+ status = "okay";
+ reg = <0x9>;
+ };
+ alt_charger: isl9538@9 {
+ compatible = "intersil,isl923x";
+ status = "okay";
+ reg = <0x9>;
+ };
+};
+
+&usbc_port0 {
+ chg_alt = <&alt_charger>;
+ ppc = <&ppc_port0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port0 &anx7483_port0>;
+ };
+};
+
+&usbc_port1 {
+ ppc = <&ppc_port1>;
+ usb-mux-chain-1-anx {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port1 &anx7483_port1>;
+ };
+ usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port1 &ps8818_port1>;
+ alternative-chain;
+ };
+};
diff --git a/zephyr/program/skyrim/crystaldrift/led_pins.dtsi b/zephyr/program/skyrim/crystaldrift/led_pins.dtsi
new file mode 100644
index 0000000000..f778a24a51
--- /dev/null
+++ b/zephyr/program/skyrim/crystaldrift/led_pins.dtsi
@@ -0,0 +1,61 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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_y: pwm_y {
+ pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+
+ pwm_w: pwm_w {
+ pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ };
+
+ pwm-led-pins {
+ compatible = "cros-ec,pwm-led-pins";
+
+ color_off: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <0 0>;
+ };
+
+ color_amber: color-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <100 0>;
+ };
+
+ color_white: color-white {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <0 100>;
+ };
+ };
+};
+
+/* Amber "battery charging" LED */
+&pwm2 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
+
+/* White "battery full" LED */
+&pwm3 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm3_gp80>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/skyrim/led_policy_morthal.dts b/zephyr/program/skyrim/crystaldrift/led_policy.dtsi
index a075c6b0d2..a075c6b0d2 100644
--- a/zephyr/projects/skyrim/led_policy_morthal.dts
+++ b/zephyr/program/skyrim/crystaldrift/led_policy.dtsi
diff --git a/zephyr/projects/skyrim/motionsense.dts b/zephyr/program/skyrim/crystaldrift/motionsense.dtsi
index f943bea4c8..f943bea4c8 100644
--- a/zephyr/projects/skyrim/motionsense.dts
+++ b/zephyr/program/skyrim/crystaldrift/motionsense.dtsi
diff --git a/zephyr/program/skyrim/crystaldrift/project.conf b/zephyr/program/skyrim/crystaldrift/project.conf
new file mode 100644
index 0000000000..e9339c1c3c
--- /dev/null
+++ b/zephyr/program/skyrim/crystaldrift/project.conf
@@ -0,0 +1,26 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Crystaldrift reference-board-specific Kconfig settings.
+CONFIG_BOARD_CRYSTALDRIFT=y
+
+# CBI WP pin present
+CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_DT=y
+
+# Crystaldrfit is capable of sinking 100W
+CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000
+CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000
+CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000
+
+CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y
+
+# Enable alternative charger chip
+CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y
+CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
diff --git a/zephyr/program/skyrim/crystaldrift/project.overlay b/zephyr/program/skyrim/crystaldrift/project.overlay
new file mode 100644
index 0000000000..1192bb0d16
--- /dev/null
+++ b/zephyr/program/skyrim/crystaldrift/project.overlay
@@ -0,0 +1,19 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Skyrim program common DTS includes */
+#include "../adc.dtsi"
+#include "../fan.dtsi"
+#include "../gpio.dtsi"
+#include "../interrupts.dtsi"
+#include "../keyboard.dtsi"
+#include "../usbc.dtsi"
+
+/* Crystaldrift project DTS includes*/
+#include "crystaldrift.dtsi"
+#include "battery.dtsi"
+#include "led_pins.dtsi"
+#include "led_policy.dtsi"
+#include "motionsense.dtsi"
diff --git a/zephyr/program/skyrim/crystaldrift/src/alt_charger.c b/zephyr/program/skyrim/crystaldrift/src/alt_charger.c
new file mode 100644
index 0000000000..a429457136
--- /dev/null
+++ b/zephyr/program/skyrim/crystaldrift/src/alt_charger.c
@@ -0,0 +1,31 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charger_chips.h"
+#include "common.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "hooks.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL);
+
+static void alt_charger_init(void)
+{
+ int ret;
+ uint32_t val;
+
+ ret = cros_cbi_get_fw_config(FW_CHARGER, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER);
+ return;
+ }
+
+ if (val == FW_CHARGER_ISL9538)
+ CHG_ENABLE_ALTERNATE(0);
+}
+DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST);
diff --git a/zephyr/program/skyrim/crystaldrift/src/fan.c b/zephyr/program/skyrim/crystaldrift/src/fan.c
new file mode 100644
index 0000000000..6645e2a495
--- /dev/null
+++ b/zephyr/program/skyrim/crystaldrift/src/fan.c
@@ -0,0 +1,62 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "fan.h"
+#include "gpio/gpio.h"
+#include "hooks.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL);
+
+/*
+ * Skyrim fan support
+ */
+static void fan_init(void)
+{
+ int ret;
+ uint32_t val;
+ uint32_t board_version;
+ /*
+ * 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;
+ }
+
+ ret = cbi_get_board_version(&board_version);
+ if (ret != EC_SUCCESS) {
+ LOG_ERR("Error retrieving CBI board version");
+ return;
+ }
+
+ if ((board_version >= 3) && (val != FW_FAN_PRESENT)) {
+ /* Disable the fan */
+ fan_set_count(0);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST);
+
+/*
+ * Pcore OCP support
+ * Note: early boards should note enable this interrupt as they are not
+ * correctly configured for it.
+ */
+__override bool board_supports_pcore_ocp(void)
+{
+ uint32_t board_version;
+
+ if (cbi_get_board_version(&board_version) == EC_SUCCESS &&
+ board_version > 3)
+ return true;
+
+ return false;
+}
diff --git a/zephyr/program/skyrim/crystaldrift/src/form_factor.c b/zephyr/program/skyrim/crystaldrift/src/form_factor.c
new file mode 100644
index 0000000000..688765617b
--- /dev/null
+++ b/zephyr/program/skyrim/crystaldrift/src/form_factor.c
@@ -0,0 +1,38 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "accelgyro.h"
+#include "common.h"
+#include "cros_board_info.h"
+#include "hooks.h"
+#include "motionsense_sensors.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL);
+
+/*
+ * Mainboard orientation support.
+ */
+
+#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1))
+#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel))
+
+static void form_factor_init(void)
+{
+ int ret;
+ uint32_t val;
+ /*
+ * If the board version >=4
+ * use ver1 rotation matrix.
+ */
+ ret = cbi_get_board_version(&val);
+ if (ret == EC_SUCCESS && val >= 4) {
+ LOG_INF("Switching to ver1 lid");
+ motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT;
+ }
+}
+DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/program/skyrim/crystaldrift/src/ppc_config.c b/zephyr/program/skyrim/crystaldrift/src/ppc_config.c
new file mode 100644
index 0000000000..3913fda4dc
--- /dev/null
+++ b/zephyr/program/skyrim/crystaldrift/src/ppc_config.c
@@ -0,0 +1,46 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Crystaldrift board-specific PPC code */
+
+#include "driver/ppc/aoz1380_public.h"
+#include "driver/ppc/nx20p348x.h"
+#include "usbc_ppc.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/*
+ * In the AOZ1380 PPC, there are no programmable features. We use
+ * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0
+ * current limits.
+ */
+int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ int rv = EC_SUCCESS;
+
+ rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en),
+ (rp == TYPEC_RP_3A0) ? 1 : 0);
+
+ return rv;
+}
+
+void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_PPC_INT_ODL:
+ aoz1380_interrupt(0);
+ break;
+
+ case GPIO_USB_C1_PPC_INT_ODL:
+ nx20p348x_interrupt(1);
+ break;
+
+ default:
+ break;
+ }
+}
diff --git a/zephyr/program/skyrim/crystaldrift/src/usb_mux_config.c b/zephyr/program/skyrim/crystaldrift/src/usb_mux_config.c
new file mode 100644
index 0000000000..0e08431360
--- /dev/null
+++ b/zephyr/program/skyrim/crystaldrift/src/usb_mux_config.c
@@ -0,0 +1,142 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Crystaldrift board-specific USB-C mux configuration */
+
+#include "console.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "driver/retimer/anx7483_public.h"
+#include "hooks.h"
+#include "ioexpander.h"
+#include "usb_mux.h"
+#include "usbc/usb_muxes.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/*
+ * USB C0 (general) and C1 (just ANX DB) use IOEX pins to
+ * indicate flipped polarity to a protection switch.
+ */
+static int ioex_set_flip(int port, mux_state_t mux_state)
+{
+ if (port == 0) {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 0);
+ } else {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 0);
+ }
+
+ return EC_SUCCESS;
+}
+
+int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
+ return anx7483_set_default_tuning(me, mux_state);
+}
+
+int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED;
+
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
+ /* Remove flipped from the state for easier compraisons */
+ mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED;
+
+ RETURN_ERROR(anx7483_set_default_tuning(me, mux_state));
+
+ if (mux_state == USB_PD_MUX_USB_ENABLED) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DP_ENABLED) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DOCK && !flipped) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DOCK && flipped) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ }
+
+ return EC_SUCCESS;
+}
+
+int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ CPRINTSUSB("C1: PS8818 mux using default tuning");
+
+ /* Once a DP connection is established, we need to set IN_HPD */
+ if (mux_state & USB_PD_MUX_DP_ENABLED)
+ ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1);
+ else
+ ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0);
+
+ return 0;
+}
+
+static void setup_mux(void)
+{
+ uint32_t val;
+
+ if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0)
+ CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG");
+ /* Val will have our dts default on error, so continue setup */
+
+ if (val == FW_IO_DB_PS8811_PS8818) {
+ CPRINTSUSB("C1: Setting PS8818 mux");
+ USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1);
+ } else if (val == FW_IO_DB_NONE_ANX7483) {
+ CPRINTSUSB("C1: Setting ANX7483 mux");
+ } else {
+ CPRINTSUSB("Unexpected DB_IO board: %d", val);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C);
diff --git a/zephyr/program/skyrim/fan.dtsi b/zephyr/program/skyrim/fan.dtsi
new file mode 100644
index 0000000000..dff26bcb29
--- /dev/null
+++ b/zephyr/program/skyrim/fan.dtsi
@@ -0,0 +1,39 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ fans {
+ compatible = "cros-ec,fans";
+
+ fan0: fan_0 {
+ pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>;
+ rpm_min = <3100>;
+ rpm_start = <3100>;
+ rpm_max = <8000>;
+ tach = <&tach1>;
+ pgood_gpio = <&gpio_s0_pgood>;
+ };
+ };
+};
+
+/* Tachemeter for fan speed measurement */
+&tach1 {
+ status = "okay";
+ pinctrl-0 = <&ta1_1_in_gp40>;
+ pinctrl-names = "default";
+ 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 */
+};
+
+&pwm0_gpc3 {
+ drive-open-drain;
+};
+
+&pwm0 {
+ status = "okay";
+ pinctrl-0 = <&pwm0_gpc3>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/program/skyrim/frostflow/CMakeLists.txt b/zephyr/program/skyrim/frostflow/CMakeLists.txt
new file mode 100644
index 0000000000..dd7eae2384
--- /dev/null
+++ b/zephyr/program/skyrim/frostflow/CMakeLists.txt
@@ -0,0 +1,15 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+cros_ec_library_include_directories_ifdef(CONFIG_BOARD_FROSTFLOW include)
+zephyr_include_directories("include")
+zephyr_library_sources(
+ "src/usb_mux_config.c"
+ "src/ppc_config.c"
+ "src/thermal.c"
+)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION
+ "src/keyboard.c"
+ "src/keyboard_customization.c"
+)
diff --git a/zephyr/projects/skyrim/battery_frostflow.dts b/zephyr/program/skyrim/frostflow/battery.dtsi
index 2d6b28de70..2d6b28de70 100644
--- a/zephyr/projects/skyrim/battery_frostflow.dts
+++ b/zephyr/program/skyrim/frostflow/battery.dtsi
diff --git a/zephyr/program/skyrim/frostflow/frostflow.dtsi b/zephyr/program/skyrim/frostflow/frostflow.dtsi
new file mode 100644
index 0000000000..1cadf7ee2d
--- /dev/null
+++ b/zephyr/program/skyrim/frostflow/frostflow.dtsi
@@ -0,0 +1,223 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/usbc_mux.h>
+
+#include "../i2c.dtsi"
+
+/ {
+ named-gpios {
+ /* Frostflow-specific GPIO customizations */
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ temp_soc: soc-pct2075 {
+ temp_host_high = <75>;
+ temp_host_halt = <80>;
+ temp_host_release_high = <65>;
+ temp_host_release_halt = <70>;
+ power-good-pin = <&gpio_pg_pwr_s5>;
+ sensor = <&soc_pct2075>;
+ };
+ temp_amb: amb-pct2075 {
+ temp_host_high = <65>;
+ temp_host_halt = <70>;
+ temp_host_release_high = <55>;
+ temp_host_release_halt = <60>;
+ temp_fan_off = <32>;
+ temp_fan_max = <45>;
+ power-good-pin = <&gpio_pg_pwr_s5>;
+ sensor = <&amb_pct2075>;
+ };
+ };
+
+ /* Rotation matrices for motion sensors. */
+ motionsense-rotation-ref {
+ compatible = "cros-ec,motionsense-rotation-ref";
+ lid_rot_ref: lid-rotation-ref {
+ mat33 = <1 0 0
+ 0 1 0
+ 0 0 1>;
+ };
+
+ base_rot_ref: base-rotation-ref {
+ mat33 = <0 1 0
+ 1 0 0
+ 0 0 (-1)>;
+ };
+ };
+
+ ppc_port0: aoz1380 {
+ compatible = "aoz,aoz1380";
+ status = "okay";
+ };
+
+ fan_steps_clamshell: fan-steps-clamshell {
+ compatible = "cros-ec,fan-steps";
+ level_0 {
+ temp_on = <(-1) (-1) (-1) (-1) 31>;
+ temp_off = <(-1) (-1) (-1) (-1) 99>;
+ rpm_target = <0>;
+ };
+ level_1 {
+ temp_on = <(-1) (-1) (-1) (-1) 32>;
+ temp_off = <(-1) (-1) (-1) (-1) 30>;
+ rpm_target = <2600>;
+ };
+ level_2 {
+ temp_on = <(-1) (-1) (-1) (-1) 34>;
+ temp_off = <(-1) (-1) (-1) (-1) 31>;
+ rpm_target = <2900>;
+ };
+ level_3 {
+ temp_on = <(-1) (-1) (-1) (-1) 36>;
+ temp_off = <(-1) (-1) (-1) (-1) 33>;
+ rpm_target = <3600>;
+ };
+ level_4 {
+ temp_on = <(-1) (-1) (-1) (-1) 38>;
+ temp_off = <(-1) (-1) (-1) (-1) 35>;
+ rpm_target = <4200>;
+ };
+ level_5 {
+ temp_on = <(-1) (-1) (-1) (-1) 45>;
+ temp_off = <(-1) (-1) (-1) (-1) 37>;
+ rpm_target = <4600>;
+ };
+ };
+
+ fan_steps_tablet: fan-steps-tablet {
+ compatible = "cros-ec,fan-steps";
+ level_0 {
+ temp_on = <(-1) (-1) (-1) (-1) 31>;
+ temp_off = <(-1) (-1) (-1) (-1) 99>;
+ rpm_target = <0>;
+ };
+ level_1 {
+ temp_on = <(-1) (-1) (-1) (-1) 32>;
+ temp_off = <(-1) (-1) (-1) (-1) 30>;
+ rpm_target = <2600>;
+ };
+ level_2 {
+ temp_on = <(-1) (-1) (-1) (-1) 34>;
+ temp_off = <(-1) (-1) (-1) (-1) 31>;
+ rpm_target = <2900>;
+ };
+ level_3 {
+ temp_on = <(-1) (-1) (-1) (-1) 36>;
+ temp_off = <(-1) (-1) (-1) (-1) 33>;
+ rpm_target = <3600>;
+ };
+ level_4 {
+ temp_on = <(-1) (-1) (-1) (-1) 38>;
+ temp_off = <(-1) (-1) (-1) (-1) 35>;
+ rpm_target = <4200>;
+ };
+ level_5 {
+ temp_on = <(-1) (-1) (-1) (-1) 45>;
+ temp_off = <(-1) (-1) (-1) (-1) 37>;
+ rpm_target = <4600>;
+ };
+ };
+};
+
+&i2c1_0 {
+ ppc_port1: nx20p348x@71 {
+ compatible = "nxp,nx20p348x";
+ status = "okay";
+ reg = <0x71>;
+ };
+ ps8818_port1: ps8818@28 {
+ compatible = "parade,ps8818";
+ reg = <0x28>;
+ flags = <(USB_MUX_FLAG_RESETS_IN_G3)>;
+ board-set = "board_c1_ps8818_mux_set";
+ };
+};
+
+&i2c4_1 {
+ charger: isl9241@9 {
+ compatible = "intersil,isl9241";
+ status = "okay";
+ reg = <0x9>;
+ };
+};
+
+&amd_fp6_port0 {
+ board-set = "board_c0_amd_fp6_mux_set";
+};
+
+&usbc_port0 {
+ ppc = <&ppc_port0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port0>;
+ };
+};
+
+&usbc_port1 {
+ ppc = <&ppc_port1>;
+ usb-mux-chain-1-ps8818 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port1 &ps8818_port1>;
+ };
+};
+
+&cros_kb_raw {
+ pinctrl-0 = <
+ &ksi0_gp31
+ &ksi1_gp30
+ &ksi2_gp27
+ &ksi3_gp26
+ &ksi4_gp25
+ &ksi5_gp24
+ &ksi6_gp23
+ &ksi7_gp22
+ &kso00_gp21
+ &kso01_gp20
+ &kso03_gp16
+ &kso04_gp15
+ &kso05_gp14
+ &kso06_gp13
+ &kso07_gp12
+ &kso08_gp11
+ &kso09_gp10
+ &kso10_gp07
+ &kso11_gp06
+ &kso12_gp05
+ &kso13_gp04
+ &kso14_gp82
+ >;
+};
+
+&temp_sensor_charger {
+ temp_host_high = <75>;
+ temp_host_halt = <80>;
+ temp_host_release_high = <65>;
+ temp_host_release_halt = <70>;
+};
+
+&temp_sensor_memory {
+ temp_host_high = <75>;
+ temp_host_halt = <80>;
+ temp_host_release_high = <65>;
+ temp_host_release_halt = <70>;
+};
+
+&temp_sensor_cpu {
+ /delete-property/ temp_host_high;
+ /delete-property/ temp_host_halt;
+ /delete-property/ temp_host_release_high;
+ /delete-property/ temp_fan_off;
+ /delete-property/ temp_fan_max;
+};
+
+&fan0 {
+ pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>;
+ rpm_min = <2400>;
+ rpm_start = <2600>;
+ rpm_max = <4600>;
+};
diff --git a/zephyr/projects/skyrim/include/frostflow/keyboard_customization.h b/zephyr/program/skyrim/frostflow/include/keyboard_customization.h
index 2d2a997f91..2d2a997f91 100644
--- a/zephyr/projects/skyrim/include/frostflow/keyboard_customization.h
+++ b/zephyr/program/skyrim/frostflow/include/keyboard_customization.h
diff --git a/zephyr/program/skyrim/frostflow/led_pins.dtsi b/zephyr/program/skyrim/frostflow/led_pins.dtsi
new file mode 100644
index 0000000000..78b9a59c40
--- /dev/null
+++ b/zephyr/program/skyrim/frostflow/led_pins.dtsi
@@ -0,0 +1,59 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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_y: pwm_y {
+ pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ pwm_w: pwm_w {
+ pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ };
+
+ pwm-led-pins {
+ compatible = "cros-ec,pwm-led-pins";
+
+ color_off: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <0 0>;
+ };
+
+ color_amber: color-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <100 0>;
+ };
+
+ color_white: color-white {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <0 100>;
+ };
+ };
+};
+
+/* Amber "battery charging" LED */
+&pwm2 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
+
+/* White "battery full" LED */
+&pwm3 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm3_gp80>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/skyrim/led_policy_frostflow.dts b/zephyr/program/skyrim/frostflow/led_policy.dtsi
index e5875640fb..e5875640fb 100644
--- a/zephyr/projects/skyrim/led_policy_frostflow.dts
+++ b/zephyr/program/skyrim/frostflow/led_policy.dtsi
diff --git a/zephyr/program/skyrim/frostflow/motionsense.dtsi b/zephyr/program/skyrim/frostflow/motionsense.dtsi
new file mode 100644
index 0000000000..f943bea4c8
--- /dev/null
+++ b/zephyr/program/skyrim/frostflow/motionsense.dtsi
@@ -0,0 +1,135 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/motionsense/utils.h>
+
+
+/ {
+ aliases {
+ /*
+ * motion sense's <>_INT_EVENT is handled
+ * by alias. Using the alias, each driver creates
+ * its own <>_INT_EVENT.
+ */
+ bmi3xx-int = &base_accel;
+ };
+
+ /*
+ * Declare mutexes used by sensor drivers.
+ * A mutex node is used to create an instance of mutex_t.
+ * A mutex node is referenced by a sensor node if the
+ * corresponding sensor driver needs to use the
+ * instance of the mutex.
+ */
+ motionsense-mutex {
+ compatible = "cros-ec,motionsense-mutex";
+ lid_mutex: lid-mutex {
+ };
+
+ mutex_bmi3xx: bmi3xx-mutex {
+ };
+ };
+
+ /*
+ * Driver specific data. A driver-specific data can be shared with
+ * different motion sensors while they are using the same driver.
+ *
+ * If a node's compatible starts with "cros-ec,accelgyro-", it is for
+ * a common structure defined in accelgyro.h.
+ * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
+ * "struct als_drv_data_t" in accelgyro.h
+ */
+ motionsense-sensor-data {
+ bma4xx_data: bma4xx-drv-data {
+ compatible = "cros-ec,drvdata-bma4xx";
+ status = "okay";
+ };
+
+ bmi3xx_data: bmi3xx-drv-data {
+ compatible = "cros-ec,drvdata-bmi3xx";
+ status = "okay";
+ };
+ };
+
+ /*
+ * List of motion sensors that creates motion_sensors array.
+ * The nodelabel "lid_accel" and "base_accel" are used to indicate
+ * motion sensor IDs for lid angle calculation.
+ */
+ motionsense-sensor {
+ lid_accel: lid-accel {
+ compatible = "cros-ec,bma4xx";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex>;
+ port = <&i2c_sensor>;
+ drv-data = <&bma4xx_data>;
+ rot-standard-ref = <&lid_rot_ref>;
+ default-range = <2>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ ec-rate = <100>;
+ };
+ ec-s3 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_accel: base-accel {
+ compatible = "cros-ec,bmi3xx-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&mutex_bmi3xx>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi3xx_data>;
+
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ ec-rate = <100>;
+ };
+ ec-s3 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base-gyro {
+ compatible = "cros-ec,bmi3xx-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&mutex_bmi3xx>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi3xx_data>;
+ };
+ };
+
+ motionsense-sensor-info {
+ compatible = "cros-ec,motionsense-sensor-info";
+
+ /*
+ * 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>;
+ };
+};
diff --git a/zephyr/program/skyrim/frostflow/project.conf b/zephyr/program/skyrim/frostflow/project.conf
new file mode 100644
index 0000000000..02da02d35d
--- /dev/null
+++ b/zephyr/program/skyrim/frostflow/project.conf
@@ -0,0 +1,33 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Frostflow reference-board-specific Kconfig settings.
+CONFIG_BOARD_FROSTFLOW=y
+CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=10
+
+# TODO(b/215404321): Remove later in board development
+CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
+CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n
+
+# LED
+CONFIG_PLATFORM_EC_LED_DT=y
+
+# Frostflow is capable of sinking 45W
+CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000
+CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3000
+CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000
+CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15000
+
+# Keyboard
+CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION=y
+
+# Frostflow not have the USB HUB
+CONFIG_BOARD_USB_HUB_RESET=n
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
+
+# Fan
+CONFIG_PLATFORM_EC_FAN=y
+CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL=y
diff --git a/zephyr/program/skyrim/frostflow/project.overlay b/zephyr/program/skyrim/frostflow/project.overlay
new file mode 100644
index 0000000000..a1bc7dbb5e
--- /dev/null
+++ b/zephyr/program/skyrim/frostflow/project.overlay
@@ -0,0 +1,19 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Skyrim program common DTS includes */
+#include "../adc.dtsi"
+#include "../fan.dtsi"
+#include "../gpio.dtsi"
+#include "../interrupts.dtsi"
+#include "../keyboard.dtsi"
+#include "../usbc.dtsi"
+
+/* Frostflow project DTS includes*/
+#include "frostflow.dtsi"
+#include "battery.dtsi"
+#include "led_pins.dtsi"
+#include "led_policy.dtsi"
+#include "motionsense.dtsi"
diff --git a/zephyr/projects/skyrim/src/frostflow/keyboard.c b/zephyr/program/skyrim/frostflow/src/keyboard.c
index 2905f17941..2905f17941 100644
--- a/zephyr/projects/skyrim/src/frostflow/keyboard.c
+++ b/zephyr/program/skyrim/frostflow/src/keyboard.c
diff --git a/zephyr/program/skyrim/frostflow/src/keyboard_customization.c b/zephyr/program/skyrim/frostflow/src/keyboard_customization.c
new file mode 100644
index 0000000000..bd02940e03
--- /dev/null
+++ b/zephyr/program/skyrim/frostflow/src/keyboard_customization.c
@@ -0,0 +1,85 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "gpio.h"
+#include "keyboard_customization.h"
+#include "keyboard_protocol.h"
+#include "keyboard_raw.h"
+
+#include <zephyr/drivers/gpio.h>
+
+static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
+ { 0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0x0000, 0x0000, 0x0000 },
+ { 0x001f, 0x0076, 0x0017, 0x000e, 0x001c, 0x003a, 0x000d, 0x0016 },
+ { 0x006c, 0xe024, 0xe01d, 0xe020, 0xe038, 0xe071, 0x0026, 0x002a },
+ { 0x0032, 0x0034, 0x002c, 0x002e, 0x002b, 0x0029, 0x0025, 0x002d },
+ { 0x0078, 0xe032, 0xe035, 0xe02c, 0xe02d, 0x0041, 0x001e, 0x001d },
+ { 0x0051, 0x0007, 0x005b, 0x000f, 0x0042, 0x0022, 0x003e, 0x0043 },
+ { 0x0031, 0x0033, 0x0035, 0x0036, 0x003b, 0x001b, 0x003d, 0x003c },
+ { 0x0000, 0x0012, 0x0061, 0x0000, 0x0000, 0x0000, 0x0000, 0x0059 },
+ { 0x0055, 0x0052, 0x0054, 0x004e, 0x004c, 0x0024, 0x0044, 0x004d },
+ { 0x0045, 0xe021, 0xe023, 0x002f, 0x004b, 0x0049, 0x0046, 0x001a },
+ { 0xe011, 0x0000, 0x006a, 0x0000, 0x005d, 0x0000, 0x0011, 0x0000 },
+ { 0xe07a, 0x005d, 0xe075, 0x006b, 0x005a, 0xe072, 0x004a, 0x0066 },
+ { 0xe06b, 0xe074, 0xe069, 0x0067, 0xe06c, 0x0064, 0x0015, 0xe07d },
+ { 0x0073, 0x007c, 0x007b, 0x0074, 0x0071, 0xe04a, 0x0070, 0x0021 },
+ { 0x0023, 0xe05a, 0x0075, 0x0079, 0x007a, 0x0072, 0x007d, 0x0069 },
+};
+
+uint16_t get_scancode_set2(uint8_t row, uint8_t col)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ return scancode_set2[col][row];
+ return 0;
+}
+
+void set_scancode_set2(uint8_t row, uint8_t col, uint16_t val)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ scancode_set2[col][row] = val;
+}
+
+#ifdef CONFIG_KEYBOARD_DEBUG
+static char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
+ { 'c', KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO },
+ { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO },
+ { 'q', KLLI_UNKNO, KLLI_UNKNO, KLLI_TAB, '`', '1', KLLI_UNKNO, 'a' },
+ { KLLI_R_ALT, KLLI_L_ALT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO },
+ { KLLI_UNKNO, KLLI_SPACE, 'e', KLLI_F4, KLLI_SEARC, '3', KLLI_F3,
+ KLLI_UNKNO },
+ { 'x', 'z', KLLI_F2, KLLI_F1, 's', '2', 'w', KLLI_ESC },
+ { 'v', 'b', 'g', 't', '5', '4', 'r', 'f' },
+ { 'm', 'n', 'h', 'y', '6', '7', 'u', 'j' },
+ { '.', KLLI_DOWN, '\\', 'o', KLLI_F10, '9', KLLI_UNKNO, 'l' },
+ { KLLI_R_SHT, KLLI_L_SHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO },
+ { ',', KLLI_UNKNO, KLLI_F7, KLLI_F6, KLLI_F5, '8', 'i', 'k' },
+ { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_F9, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_LEFT, KLLI_UNKNO },
+ { KLLI_R_CTR, KLLI_L_CTR, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO },
+ { '/', KLLI_UP, '-', KLLI_UNKNO, '0', 'p', '[', ';' },
+ { '\'', KLLI_ENTER, KLLI_UNKNO, KLLI_UNKNO, '=', KLLI_B_SPC, ']', 'd' },
+ { KLLI_UNKNO, KLLI_F8, KLLI_RIGHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
+ KLLI_UNKNO, KLLI_UNKNO },
+};
+
+char get_keycap_label(uint8_t row, uint8_t col)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ return keycap_label[col][row];
+ return KLLI_UNKNO;
+}
+
+void set_keycap_label(uint8_t row, uint8_t col, char val)
+{
+ if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
+ keycap_label[col][row] = val;
+}
+#endif
diff --git a/zephyr/program/skyrim/frostflow/src/ppc_config.c b/zephyr/program/skyrim/frostflow/src/ppc_config.c
new file mode 100644
index 0000000000..513c025dec
--- /dev/null
+++ b/zephyr/program/skyrim/frostflow/src/ppc_config.c
@@ -0,0 +1,46 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Frostflow board-specific PPC code */
+
+#include "driver/ppc/aoz1380_public.h"
+#include "driver/ppc/nx20p348x.h"
+#include "usbc_ppc.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/*
+ * In the AOZ1380 PPC, there are no programmable features. We use
+ * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0
+ * current limits.
+ */
+int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ int rv = EC_SUCCESS;
+
+ rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en),
+ (rp == TYPEC_RP_3A0) ? 1 : 0);
+
+ return rv;
+}
+
+void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_PPC_INT_ODL:
+ aoz1380_interrupt(0);
+ break;
+
+ case GPIO_USB_C1_PPC_INT_ODL:
+ nx20p348x_interrupt(1);
+ break;
+
+ default:
+ break;
+ }
+}
diff --git a/zephyr/program/skyrim/frostflow/src/thermal.c b/zephyr/program/skyrim/frostflow/src/thermal.c
new file mode 100644
index 0000000000..eae8aac25d
--- /dev/null
+++ b/zephyr/program/skyrim/frostflow/src/thermal.c
@@ -0,0 +1,109 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "chipset.h"
+#include "fan.h"
+#include "tablet_mode.h"
+#include "temp_sensor/temp_sensor.h"
+#include "thermal.h"
+#include "util.h"
+#include "console.h"
+
+#define TEMP_AMB TEMP_SENSOR_ID(DT_NODELABEL(temp_amb))
+
+struct fan_step {
+ /*
+ * Sensor 0~4 trigger point, set -1 if we're not using this
+ * sensor to determine fan speed.
+ */
+ int on[TEMP_SENSOR_COUNT];
+ /*
+ * Sensor 0~4 release point, set -1 if we're not using this
+ * sensor to determine fan speed.
+ */
+ int off[TEMP_SENSOR_COUNT];
+ /* Fan rpm */
+ uint16_t rpm[FAN_CH_COUNT];
+};
+
+#define FAN_TABLE_ENTRY(nd) \
+ { \
+ .on = DT_PROP(nd, temp_on), \
+ .off = DT_PROP(nd, temp_off), \
+ .rpm = DT_PROP(nd, rpm_target), \
+ },
+
+static const struct fan_step fan_table_clamshell[] = { DT_FOREACH_CHILD(
+ DT_NODELABEL(fan_steps_clamshell), FAN_TABLE_ENTRY) };
+
+static const struct fan_step fan_table_tablet[] = { DT_FOREACH_CHILD(
+ DT_NODELABEL(fan_steps_tablet), FAN_TABLE_ENTRY) };
+
+static const struct fan_step *fan_step_table;
+#define NUM_FAN_LEVELS ARRAY_SIZE(fan_table_clamshell)
+
+BUILD_ASSERT(ARRAY_SIZE(fan_table_clamshell) == ARRAY_SIZE(fan_table_tablet));
+
+int fan_table_to_rpm(int fan, int *temp)
+{
+ /* current fan level */
+ static int current_level;
+ /* previous sensor temperature */
+ static int prev_tmp[TEMP_SENSOR_COUNT];
+ int i;
+
+ if (tablet_get_mode())
+ fan_step_table = fan_table_tablet;
+ else
+ fan_step_table = fan_table_clamshell;
+
+ /*
+ * Compare the current and previous temperature, we have
+ * the three paths :
+ * 1. decreasing path. (check the release point)
+ * 2. increasing path. (check the trigger point)
+ * 3. invariant path. (return the current RPM)
+ */
+
+ if (temp[TEMP_AMB] < prev_tmp[TEMP_AMB]) {
+ for (i = current_level; i > 0; i--) {
+ if (temp[TEMP_AMB] < fan_step_table[i].off[TEMP_AMB])
+ current_level = i - 1;
+ else
+ break;
+ }
+ } else if (temp[TEMP_AMB] > prev_tmp[TEMP_AMB]) {
+ for (i = current_level; i < NUM_FAN_LEVELS; i++) {
+ if (temp[TEMP_AMB] > fan_step_table[i].on[TEMP_AMB])
+ current_level = i + 1;
+ else
+ break;
+ }
+ }
+
+ if (current_level < 0)
+ current_level = 0;
+
+ if (current_level >= NUM_FAN_LEVELS)
+ current_level = NUM_FAN_LEVELS - 1;
+
+ for (i = 0; i < TEMP_SENSOR_COUNT; ++i)
+ prev_tmp[i] = temp[i];
+
+ return fan_step_table[current_level].rpm[fan];
+}
+
+void board_override_fan_control(int fan, int *temp)
+{
+ /*
+ * In common/fan.c pwm_fan_stop() will turn off fan
+ * when chipset suspend or shutdown.
+ */
+ if (chipset_in_state(CHIPSET_STATE_ON)) {
+ fan_set_rpm_mode(fan, 1);
+ fan_set_rpm_target(fan, fan_table_to_rpm(fan, temp));
+ }
+}
diff --git a/zephyr/program/skyrim/frostflow/src/usb_mux_config.c b/zephyr/program/skyrim/frostflow/src/usb_mux_config.c
new file mode 100644
index 0000000000..2ec1dda0be
--- /dev/null
+++ b/zephyr/program/skyrim/frostflow/src/usb_mux_config.c
@@ -0,0 +1,62 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Frostflow board-specific USB-C mux configuration */
+
+#include "ioexpander.h"
+#include "usbc/usb_muxes.h"
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/*
+ * USB C0 (general) and C1 (just ps8815 DB) use IOEX pins to
+ * indicate flipped polarity to a protection switch.
+ */
+static int ioex_set_flip(int port, mux_state_t mux_state)
+{
+ if (port == 0) {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 0);
+ } else {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 0);
+ }
+
+ return EC_SUCCESS;
+}
+
+int board_c0_amd_fp6_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
+ return EC_SUCCESS;
+}
+
+int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ CPRINTSUSB("C1: PS8818 mux using default tuning");
+
+ /* Once a DP connection is established, we need to set IN_HPD */
+ if (mux_state & USB_PD_MUX_DP_ENABLED)
+ ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1);
+ else
+ ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0);
+
+ return 0;
+}
diff --git a/zephyr/program/skyrim/gpio.dtsi b/zephyr/program/skyrim/gpio.dtsi
new file mode 100644
index 0000000000..2b79bad222
--- /dev/null
+++ b/zephyr/program/skyrim/gpio.dtsi
@@ -0,0 +1,370 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ aliases {
+ gpio-wp = &gpio_wp;
+ gpio-cbi-wp = &gpio_cbi_wp;
+ gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ };
+
+ /* GPIOs shared by all boards */
+ named-gpios {
+ compatible = "named-gpios";
+
+ ccd_mode_odl {
+ gpios = <&gpioc 6 GPIO_ODR_HIGH>;
+ };
+ ec_gsc_packet_mode {
+ gpios = <&gpiob 1 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_PACKET_MODE_EN";
+ };
+ gpio_mech_pwr_btn_odl: mech_pwr_btn_odl {
+ gpios = <&gpiod 2 GPIO_INPUT>;
+ enum-name = "GPIO_POWER_BUTTON_L";
+ };
+ gpio_slp_s3_l: slp_s3_l {
+ gpios = <&gpio6 1 GPIO_INPUT>;
+ enum-name = "GPIO_PCH_SLP_S3_L";
+ alias = "GPIO_PCH_SLP_S0_L";
+ };
+ gpio_slp_s5_l: slp_s5_l {
+ gpios = <&gpio7 2 GPIO_INPUT>;
+ enum-name = "GPIO_PCH_SLP_S5_L";
+ };
+ gpio_pg_pwr_s5: pg_pwr_s5 {
+ gpios = <&gpioc 0 GPIO_INPUT>;
+ enum-name = "GPIO_S5_PGOOD";
+ };
+ gpio_s0_pgood: pg_pcore_s0_r_od {
+ gpios = <&gpiob 6 GPIO_INPUT>;
+ enum-name = "GPIO_S0_PGOOD";
+ };
+ gpio_acok_od: acok_od {
+ gpios = <&gpio0 0 GPIO_INPUT>;
+ enum-name = "GPIO_AC_PRESENT";
+ };
+ gpio_en_pwr_s5: en_pwr_s5 {
+ gpios = <&gpiob 7 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_EN_PWR_A";
+ };
+ gpio_en_pwr_s0_r: en_pwr_s0_r {
+ gpios = <&gpiof 1 GPIO_OUTPUT_LOW>;
+ };
+ gpio_en_pwr_pcore_s0_r: en_pwr_pcore_s0_r {
+ gpios = <&gpioe 1 GPIO_OUTPUT_LOW>;
+ };
+ ec_sys_rst_l {
+ gpios = <&gpio7 6 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_SYS_RESET_L";
+ };
+ gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l {
+ gpios = <&gpioc 5 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_PCH_RSMRST_L";
+ };
+ gpio_ec_pch_wake_odl: ec_soc_wake_l {
+ gpios = <&gpio0 3 GPIO_OUTPUT_HIGH>;
+ };
+ prochot_odl {
+ gpios = <&gpiod 5 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_CPU_PROCHOT";
+ };
+ soc_alert_ec_l {
+ gpios = <&gpioe 2 GPIO_INPUT>;
+ };
+ gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl {
+ gpios = <&gpioe 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_TCPC_INT_ODL";
+ };
+ gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl {
+ gpios = <&gpioc 7 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_TCPC_INT_ODL";
+ };
+ gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl {
+ gpios = <&gpio7 5 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_PPC_INT_ODL";
+ };
+ gpio_usb_c1_ppc_int_odl: usb_c1_ppc_int_odl {
+ gpios = <&gpiod 4 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_PPC_INT_ODL";
+ };
+ gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl {
+ gpios = <&gpioa 4 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_USB_C0_BC12_INT_ODL";
+ };
+ gpio_usb_c1_bc12_int_odl: usb_c1_bc12_int_odl {
+ gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_USB_C1_BC12_INT_ODL";
+ };
+ gpio_usb_c0_tcpc_rst_l: usb_c0_tcpc_rst_l {
+ gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>;
+ enum-name = "GPIO_USB_C0_TCPC_RST_L";
+ };
+ gpio_usb_c1_tcpc_rst_l: usb_c1_tcpc_rst_l {
+ gpios = <&gpio3 7 GPIO_OUTPUT_HIGH>;
+ enum-name = "GPIO_USB_C1_TCPC_RST_L";
+ };
+ usb_c0_hpd {
+ gpios = <&gpiof 5 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_USB_C0_DP_HPD";
+ };
+ usb_c1_hpd {
+ gpios = <&gpiof 4 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_USB_C1_DP_HPD";
+ };
+ gpio_lid_open: lid_open {
+ gpios = <&gpio0 2 GPIO_INPUT>;
+ enum-name = "GPIO_LID_OPEN";
+ };
+ gpio_ec_batt_pres_odl: ec_batt_pres_odl {
+ gpios = <&gpio9 4 GPIO_INPUT>;
+ enum-name = "GPIO_BATT_PRES_ODL";
+ };
+ gpio_ec_disable_disp_bl: ec_disable_disp_bl {
+ gpios = <&gpioa 6 GPIO_OUTPUT_HIGH>;
+ enum-name = "GPIO_ENABLE_BACKLIGHT_L";
+ };
+ gpio_usb_fault_odl: usb_fault_odl {
+ gpios = <&gpio5 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_en_pwr_s3: en_pwr_s3 {
+ gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
+ };
+ gpio_pg_groupc_s0_od: pg_groupc_s0_od {
+ gpios = <&gpiof 0 GPIO_INPUT>;
+ };
+ gpio_ec_i2c_usbc_pd_int: ec_i2c_usbc_pd_int {
+ gpios = <&gpioa 3 GPIO_INPUT>;
+ };
+ gpio_soc_thermtrip_odl: soc_thermtrip_odl {
+ gpios = <&gpio9 5 GPIO_INPUT>;
+ };
+ gpio_hub_rst: hub_rst {
+ gpios = <&gpio6 6 GPIO_OUTPUT_HIGH>;
+ };
+ ec_soc_int_l {
+ gpios = <&gpioa 1 GPIO_OUTPUT_HIGH>;
+ enum-name = "GPIO_EC_INT_L";
+ };
+ gpio_ec_soc_pwr_good: ec_soc_pwr_good {
+ gpios = <&gpiod 3 GPIO_OUTPUT_LOW>;
+ };
+ gpio_pcore_ocp_r_l: pcore_ocp_r_l {
+ gpios = <&gpioa 5 GPIO_INPUT>;
+ };
+ gpio_usb_hub_fault_q_odl: usb_hub_fault_q_odl {
+ gpios = <&gpioe 5 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_pg_lpddr5_s3_od: pg_lpddr5_s3_od {
+ gpios = <&gpio7 3 GPIO_INPUT>;
+ };
+ 3axis_int_l {
+ gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_ec_soc_pwr_btn_l: ec_soc_pwr_btn_l {
+ gpios = <&gpioa 7 GPIO_OUTPUT_HIGH>;
+ enum-name = "GPIO_PCH_PWRBTN_L";
+ };
+ gpio_volup_btn_odl: volup_btn_odl {
+ gpios = <&gpio6 7 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_UP_L";
+ };
+ gpio_voldn_btn_odl: voldn_btn_odl {
+ gpios = <&gpio7 0 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_DOWN_L";
+ };
+ ec_sc_rst {
+ gpios = <&gpiob 0 GPIO_OUTPUT_LOW>;
+ };
+ gpio_cbi_wp: ec_cbi_wp {
+ gpios = <&gpio8 1 GPIO_OUTPUT_LOW>;
+ };
+ gpio_wp: ec_wp_l {
+ gpios = <&gpiod 7 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ };
+ gpio_pg_lpddr5_s0_od: pg_lpddr5_s0_od {
+ gpios = <&gpio6 0 GPIO_INPUT>;
+ };
+ ec_espi_rst_l {
+ gpios = <&gpio5 4 GPIO_PULL_DOWN>;
+ };
+ gpio_accel_gyro_int_l: accel_gyro_int_l {
+ gpios = <&gpioa 0 GPIO_INPUT>;
+ };
+ /* unimplemented GPIOs */
+ entering-rw {
+ enum-name = "GPIO_ENTERING_RW";
+ };
+ pch-sys-prwok {
+ enum-name = "GPIO_PCH_SYS_PWROK";
+ };
+ ec_i2c_usb_a0_c0_scl {
+ gpios = <&gpiob 5 GPIO_INPUT>;
+ };
+ ec_i2c_usb_a0_c0_sda {
+ gpios = <&gpiob 4 GPIO_INPUT>;
+ };
+ ec_i2c_usb_a1_c1_scl {
+ gpios = <&gpio9 0 GPIO_INPUT>;
+ };
+ ec_i2c_usb_a1_c1_sda {
+ gpios = <&gpio8 7 GPIO_INPUT>;
+ };
+ ec_i2c_batt_scl {
+ gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec_i2c_batt_sda {
+ gpios = <&gpio9 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec_i2c_usbc_mux_scl {
+ gpios = <&gpiod 1 GPIO_INPUT>;
+ };
+ ec_i2c_usbc_mux_sda {
+ gpios = <&gpiod 0 GPIO_INPUT>;
+ };
+ ec_i2c_power_scl {
+ gpios = <&gpiof 3 GPIO_INPUT>;
+ };
+ ec_i2c_power_sda {
+ gpios = <&gpiof 2 GPIO_INPUT>;
+ };
+ ec_i2c_cbi_scl {
+ gpios = <&gpio3 3 GPIO_INPUT>;
+ };
+ ec_i2c_cbi_sda {
+ gpios = <&gpio3 6 GPIO_INPUT>;
+ };
+ ec_i2c_sensor_scl {
+ gpios = <&gpioe 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec_i2c_sensor_sda {
+ gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec_i2c_soc_sic {
+ gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec_i2c_soc_sid {
+ gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ en_kb_bl {
+ gpios = <&gpio9 7 GPIO_OUTPUT_HIGH>;
+ enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT";
+ };
+ gpio_ec_kso_02_inv: ec_kso_02_inv {
+ gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
+ };
+ tablet_mode_l {
+ gpios = <&gpioc 1 GPIO_INPUT>;
+ enum-name = "GPIO_TABLET_MODE_L";
+ };
+ ec_gpio56 {
+ gpios = <&gpio5 6 GPIO_INPUT_PULL_UP>;
+ };
+ ec_flprg2 {
+ gpios = <&gpio8 6 GPIO_INPUT_PULL_UP>;
+ };
+
+ usb_c0_tcpc_fastsw_ctl_en {
+ gpios = <&ioex_c0_port0 4 GPIO_OUTPUT_LOW>;
+ enum-name = "IOEX_USB_C0_TCPC_FASTSW_CTL_EN";
+ };
+ usb_c0_ppc_en_l {
+ gpios = <&ioex_c0_port1 0 GPIO_OUTPUT_LOW>;
+ };
+ ioex_usb_c0_ilim_3a_en: usb_c0_ppc_ilim_3a_en {
+ gpios = <&ioex_c0_port1 1 GPIO_OUTPUT_LOW>;
+ enum-name = "IOEX_USB_C0_PPC_ILIM_3A_EN";
+ };
+ ioex_usb_c0_sbu_fault_odl: usb_c0_sbu_fault_odl {
+ gpios = <&ioex_c0_port1 2 GPIO_INPUT>;
+ };
+ ioex_en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus {
+ gpios = <&ioex_c0_port1 5 GPIO_OUTPUT_LOW>;
+ };
+ ioex_usb_a0_fault_odl: usb_a0_fault_odl {
+ gpios = <&ioex_c0_port1 6 GPIO_INPUT>;
+ };
+ ioex_usb_c0_sbu_flip: usb_c0_sbu_flip {
+ gpios = <&ioex_c0_port1 7 GPIO_OUTPUT_LOW>;
+ enum-name = "IOEX_USB_C0_SBU_FLIP";
+ };
+
+ usb_a1_retimer_en {
+ gpios = <&ioex_c1_port0 0 GPIO_OUTPUT_LOW>;
+ enum-name = "IOEX_USB_A1_RETIMER_EN";
+ };
+ usb_a1_retimer_rst {
+ gpios = <&ioex_c1_port0 1 GPIO_OUTPUT_LOW>;
+ };
+ usb_c1_in_hpd {
+ gpios = <&ioex_c1_port0 3 GPIO_OUTPUT_LOW>;
+ enum-name = "IOEX_USB_C1_HPD_IN_DB";
+ };
+ usb_c1_tcpc_fastsw_ctl_en {
+ gpios = <&ioex_c1_port0 4 GPIO_OUTPUT_LOW>;
+ enum-name = "IOEX_USB_C1_TCPC_FASTSW_CTL_EN";
+ };
+ usb_c1_ppc_en_l {
+ gpios = <&ioex_c1_port1 0 GPIO_OUTPUT_LOW>;
+ };
+ usb_c1_ppc_ilim_3a_en {
+ gpios = <&ioex_c1_port1 1 GPIO_OUTPUT_LOW>;
+ enum-name = "IOEX_USB_C1_PPC_ILIM_3A_EN";
+ };
+ ioex_usb_c1_sbu_fault_odl: usb_c1_sbu_fault_odl {
+ gpios = <&ioex_c1_port1 2 GPIO_INPUT>;
+ enum-name = "IOEX_USB_C1_FAULT_ODL";
+ };
+ ioex_en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus {
+ gpios = <&ioex_c1_port1 5 GPIO_OUTPUT_LOW>;
+ };
+ ioex_usb_a1_fault_db_odl: usb_a1_fault_db_odl {
+ gpios = <&ioex_c1_port1 6 GPIO_INPUT>;
+ };
+ ioex_usb_c1_sbu_flip: usb_c1_sbu_flip {
+ gpios = <&ioex_c1_port1 7 GPIO_OUTPUT_LOW>;
+ enum-name = "IOEX_USB_C1_SBU_FLIP";
+ };
+ };
+
+ usba-port-enable-list {
+ compatible = "cros-ec,usba-port-enable-pins";
+ enable-pins = <&ioex_en_pp5000_usb_a0_vbus
+ &ioex_en_pp5000_usb_a1_vbus>;
+ };
+};
+
+/* PSL input pads*/
+&psl_in1_gpd2 {
+ /* MECH_PWR_BTN_ODL */
+ psl-in-mode = "edge";
+ psl-in-pol = "low-falling";
+};
+
+&psl_in2_gp00 {
+ /* ACOK_OD */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+&psl_in4_gp02 {
+ /* LID_OPEN */
+ psl-in-mode = "edge";
+ psl-in-pol = "high-rising";
+};
+
+/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
+&power_ctrl_psl {
+ status = "okay";
+ pinctrl-names = "sleep";
+ pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in4_gp02>;
+};
+
+/* host interface */
+&espi0 {
+ status = "okay";
+ pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/program/skyrim/i2c.dtsi b/zephyr/program/skyrim/i2c.dtsi
new file mode 100644
index 0000000000..460a6bcfd2
--- /dev/null
+++ b/zephyr/program/skyrim/i2c.dtsi
@@ -0,0 +1,294 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+ #include <dt-bindings/usb_pd_tcpm.h>
+
+/ {
+ 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-7 = &i2c7_0;
+ };
+
+ named-i2c-ports {
+ compatible = "named-i2c-ports";
+
+ i2c_tcpc0: tcpc0 {
+ i2c-port = <&i2c0_0>;
+ enum-names = "I2C_PORT_TCPC0";
+ };
+
+ i2c_tcpc1: tcpc1 {
+ i2c-port = <&i2c1_0>;
+ enum-names = "I2C_PORT_TCPC1";
+ };
+
+ battery {
+ i2c-port = <&i2c2_0>;
+ remote-port = <0>;
+ enum-names = "I2C_PORT_BATTERY";
+ };
+
+ usb-mux {
+ i2c-port = <&i2c3_0>;
+ enum-names = "I2C_PORT_USB_MUX";
+ };
+
+ i2c_charger: charger {
+ i2c-port = <&i2c4_1>;
+ enum-names = "I2C_PORT_CHARGER";
+ };
+
+ eeprom {
+ i2c-port = <&i2c5_0>;
+ enum-names = "I2C_PORT_EEPROM";
+ };
+
+ i2c_sensor: sensor {
+ i2c-port = <&i2c6_1>;
+ enum-names = "I2C_PORT_SENSOR";
+ };
+
+ i2c_soc_thermal: soc-thermal {
+ i2c-port = <&i2c7_0>;
+ enum-names = "I2C_PORT_THERMAL_AP";
+ };
+ };
+
+
+};
+
+&i2c0_0 {
+ status = "okay";
+ label = "I2C_TCPC0";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
+ pinctrl-names = "default";
+
+ bc12_port0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ irq = <&int_usb_c0_bc12>;
+ };
+
+ tcpc_port0: nct38xx@70 {
+ compatible = "nuvoton,nct38xx";
+ reg = <0x70>;
+ gpio-dev = <&nct3807_C0>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
+
+ nct3807_C0: nct3807_C0@70 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "nuvoton,nct38xx-gpio";
+ reg = <0x70>;
+ label = "NCT3807_C0";
+
+ ioex_c0_port0: gpio@0 {
+ compatible = "nuvoton,nct38xx-gpio-port";
+ reg = <0x0>;
+ label = "NCT3807_C0_GPIO0";
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <8>;
+ pin_mask = <0xff>;
+ pinmux_mask = <0xf7>;
+ };
+ ioex_c0_port1: gpio@1 {
+ compatible = "nuvoton,nct38xx-gpio-port";
+ reg = <0x1>;
+ label = "NCT3807_C0_GPIO1";
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <8>;
+ pin_mask = <0xff>;
+ };
+ };
+
+ nct3808_alert_0 {
+ compatible = "nuvoton,nct38xx-gpio-alert";
+ irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>;
+ nct38xx-dev = <&nct3807_C0>;
+ label = "NCT3807_ALERT_0";
+ };
+};
+
+&i2c_ctrl0 {
+ status = "okay";
+};
+
+&i2c1_0 {
+ status = "okay";
+ label = "I2C_TCPC1";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
+ pinctrl-names = "default";
+
+ bc12_port1: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ status = "okay";
+ reg = <0x5f>;
+ irq = <&int_usb_c1_bc12>;
+ };
+
+ tcpc_port1: nct38xx@70 {
+ compatible = "nuvoton,nct38xx";
+ reg = <0x70>;
+ gpio-dev = <&nct3807_C1>;
+ tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
+ };
+
+ nct3807_C1: nct3807_C1@70 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ compatible = "nuvoton,nct38xx-gpio";
+ reg = <0x70>;
+ label = "NCT3807_C1";
+
+ ioex_c1_port0: gpio@0 {
+ compatible = "nuvoton,nct38xx-gpio-port";
+ reg = <0x0>;
+ label = "NCT3807_C1_GPIO0";
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <8>;
+ pin_mask = <0xff>;
+ pinmux_mask = <0xf7>;
+ };
+ ioex_c1_port1: gpio@1 {
+ compatible = "nuvoton,nct38xx-gpio-port";
+ reg = <0x1>;
+ label = "NCT3807_C1_GPIO1";
+ gpio-controller;
+ #gpio-cells = <2>;
+ ngpios = <8>;
+ pin_mask = <0xff>;
+ };
+ };
+
+ nct3808_alert_1 {
+ compatible = "nuvoton,nct38xx-gpio-alert";
+ irq-gpios = <&gpioc 7 GPIO_ACTIVE_LOW>;
+ nct38xx-dev = <&nct3807_C1>;
+ label = "NCT3807_ALERT_1";
+ };
+};
+
+&i2c_ctrl1 {
+ status = "okay";
+};
+
+&i2c2_0 {
+ status = "okay";
+ label = "I2C_BATTERY";
+ clock-frequency = <I2C_BITRATE_STANDARD>;
+ pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>;
+ pinctrl-names = "default";
+};
+
+&i2c_ctrl2 {
+ status = "okay";
+};
+
+&i2c3_0 {
+ status = "okay";
+ label = "I2C_USB_MUX";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
+ pinctrl-names = "default";
+
+ amd_fp6_port0: amd_fp6@5c {
+ compatible = "amd,usbc-mux-amd-fp6";
+ status = "okay";
+ reg = <0x5c>;
+ };
+ amd_fp6_port1: amd_fp6@52 {
+ compatible = "amd,usbc-mux-amd-fp6";
+ status = "okay";
+ reg = <0x52>;
+ };
+};
+
+&i2c_ctrl3 {
+ status = "okay";
+};
+
+&i2c4_1 {
+ status = "okay";
+ label = "I2C_CHARGER";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>;
+ pinctrl-names = "default";
+};
+
+&i2c_ctrl4 {
+ status = "okay";
+};
+
+&i2c5_0 {
+ status = "okay";
+ label = "I2C_EEPROM";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>;
+ pinctrl-names = "default";
+
+ cbi_eeprom: eeprom@50 {
+ compatible = "atmel,at24";
+ reg = <0x50>;
+ size = <2048>;
+ pagesize = <16>;
+ address-width = <8>;
+ timeout = <5>;
+ };
+};
+
+&i2c_ctrl5 {
+ status = "okay";
+};
+
+&i2c6_1 {
+ status = "okay";
+ label = "I2C_SENSOR";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>;
+ pinctrl-names = "default";
+
+ soc_pct2075: soc-pct2075@48 {
+ compatible = "nxp,pct2075";
+ reg = <0x48>;
+ };
+
+ amb_pct2075: amb-pct2075@4f {
+ compatible = "nxp,pct2075";
+ reg = <0x4f>;
+ };
+};
+
+&i2c_ctrl6 {
+ status = "okay";
+};
+
+&i2c7_0 {
+ status = "okay";
+ label = "I2C_THERMAL_AP";
+ clock-frequency = <I2C_BITRATE_FAST>;
+ pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
+ pinctrl-names = "default";
+
+ temp_cpu: cpu@4c {
+ compatible = "amd,sb-tsi";
+ reg = <0x4c>;
+ };
+};
+
+&i2c_ctrl7 {
+ status = "okay";
+};
diff --git a/zephyr/program/skyrim/include/keyboard_customization.h b/zephyr/program/skyrim/include/keyboard_customization.h
new file mode 100644
index 0000000000..2d2a997f91
--- /dev/null
+++ b/zephyr/program/skyrim/include/keyboard_customization.h
@@ -0,0 +1,78 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Keyboard configuration */
+
+#ifndef __KEYBOARD_CUSTOMIZATION_H
+#define __KEYBOARD_CUSTOMIZATION_H
+
+/*
+ * KEYBOARD_COLS_MAX has the build time column size. It's used to allocate
+ * exact spaces for arrays. Actual keyboard scanning is done using
+ * keyboard_cols, which holds a runtime column size.
+ */
+#ifdef CONFIG_KEYBOARD_CUSTOMIZATION
+#undef KEYBOARD_COLS_MAX
+#undef KEYBOARD_ROWS
+
+#define KEYBOARD_COLS_MAX 15
+#define KEYBOARD_ROWS 8
+#endif
+
+/*
+ * WARNING: Do not directly modify it. You should call keyboard_raw_set_cols,
+ * instead. It checks whether you're eligible or not.
+ */
+extern uint8_t keyboard_cols;
+
+#define KEYBOARD_ROW_TO_MASK(r) (1 << (r))
+
+/* Columns and masks for keys we particularly care about */
+#define KEYBOARD_COL_DOWN 11
+#define KEYBOARD_ROW_DOWN 5
+#define KEYBOARD_MASK_DOWN KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_DOWN)
+#define KEYBOARD_COL_ESC 1
+#define KEYBOARD_ROW_ESC 1
+#define KEYBOARD_MASK_ESC KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_ESC)
+#define KEYBOARD_COL_KEY_H 6
+#define KEYBOARD_ROW_KEY_H 1
+#define KEYBOARD_MASK_KEY_H KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_H)
+#define KEYBOARD_COL_KEY_R 3
+#define KEYBOARD_ROW_KEY_R 7
+#define KEYBOARD_MASK_KEY_R KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_R)
+#define KEYBOARD_COL_LEFT_ALT 10
+#define KEYBOARD_ROW_LEFT_ALT 6
+#define KEYBOARD_MASK_LEFT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_ALT)
+#define KEYBOARD_COL_REFRESH 2
+#define KEYBOARD_ROW_REFRESH 3
+#define KEYBOARD_MASK_REFRESH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_REFRESH)
+#define KEYBOARD_COL_RIGHT_ALT 10
+#define KEYBOARD_ROW_RIGHT_ALT 0
+#define KEYBOARD_MASK_RIGHT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_ALT)
+#define KEYBOARD_DEFAULT_COL_VOL_UP 4
+#define KEYBOARD_DEFAULT_ROW_VOL_UP 1
+#define KEYBOARD_COL_LEFT_CTRL 0
+#define KEYBOARD_ROW_LEFT_CTRL 2
+#define KEYBOARD_MASK_LEFT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_CTRL)
+#define KEYBOARD_COL_RIGHT_CTRL 0
+#define KEYBOARD_ROW_RIGHT_CTRL 4
+#define KEYBOARD_MASK_RIGHT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_CTRL)
+#define KEYBOARD_COL_SEARCH 0
+#define KEYBOARD_ROW_SEARCH 3
+#define KEYBOARD_MASK_SEARCH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_SEARCH)
+#define KEYBOARD_COL_KEY_0 9
+#define KEYBOARD_ROW_KEY_0 0
+#define KEYBOARD_MASK_KEY_0 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_0)
+#define KEYBOARD_COL_KEY_1 1
+#define KEYBOARD_ROW_KEY_1 7
+#define KEYBOARD_MASK_KEY_1 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_1)
+#define KEYBOARD_COL_KEY_2 4
+#define KEYBOARD_ROW_KEY_2 6
+#define KEYBOARD_MASK_KEY_2 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_2)
+#define KEYBOARD_COL_LEFT_SHIFT 7
+#define KEYBOARD_ROW_LEFT_SHIFT 1
+#define KEYBOARD_MASK_LEFT_SHIFT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_SHIFT)
+
+#endif /* __KEYBOARD_CUSTOMIZATION_H */
diff --git a/zephyr/projects/skyrim/interrupts.dts b/zephyr/program/skyrim/interrupts.dtsi
index de4e87986a..de4e87986a 100644
--- a/zephyr/projects/skyrim/interrupts.dts
+++ b/zephyr/program/skyrim/interrupts.dtsi
diff --git a/zephyr/program/skyrim/keyboard.dtsi b/zephyr/program/skyrim/keyboard.dtsi
new file mode 100644
index 0000000000..aaf305c725
--- /dev/null
+++ b/zephyr/program/skyrim/keyboard.dtsi
@@ -0,0 +1,48 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ kblight {
+ compatible = "cros-ec,kblight-pwm";
+ pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_NORMAL>;
+ };
+};
+
+&pwm1 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm1_gpc2>;
+ pinctrl-names = "default";
+};
+
+&cros_kb_raw {
+ status = "okay";
+ /* No KSO2 (it's inverted and implemented by GPIO) */
+ pinctrl-0 = <
+ &ksi0_gp31
+ &ksi1_gp30
+ &ksi2_gp27
+ &ksi3_gp26
+ &ksi4_gp25
+ &ksi5_gp24
+ &ksi6_gp23
+ &ksi7_gp22
+ &kso00_gp21
+ &kso01_gp20
+ &kso03_gp16
+ &kso04_gp15
+ &kso05_gp14
+ &kso06_gp13
+ &kso07_gp12
+ &kso08_gp11
+ &kso09_gp10
+ &kso10_gp07
+ &kso11_gp06
+ &kso12_gp05
+ &kso13_gp04
+ &kso14_gp82
+ >;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/program/skyrim/morthal/CMakeLists.txt b/zephyr/program/skyrim/morthal/CMakeLists.txt
new file mode 100644
index 0000000000..b4819f1e73
--- /dev/null
+++ b/zephyr/program/skyrim/morthal/CMakeLists.txt
@@ -0,0 +1,8 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+zephyr_library_sources(
+ "src/ppc_config.c"
+ "src/usb_mux_config.c"
+)
diff --git a/zephyr/projects/skyrim/battery_morthal.dts b/zephyr/program/skyrim/morthal/battery.dtsi
index 8c87cef7f9..8c87cef7f9 100644
--- a/zephyr/projects/skyrim/battery_morthal.dts
+++ b/zephyr/program/skyrim/morthal/battery.dtsi
diff --git a/zephyr/program/skyrim/morthal/led_pins.dtsi b/zephyr/program/skyrim/morthal/led_pins.dtsi
new file mode 100644
index 0000000000..78b9a59c40
--- /dev/null
+++ b/zephyr/program/skyrim/morthal/led_pins.dtsi
@@ -0,0 +1,59 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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_y: pwm_y {
+ pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ pwm_w: pwm_w {
+ pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ };
+
+ pwm-led-pins {
+ compatible = "cros-ec,pwm-led-pins";
+
+ color_off: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <0 0>;
+ };
+
+ color_amber: color-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <100 0>;
+ };
+
+ color_white: color-white {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <0 100>;
+ };
+ };
+};
+
+/* Amber "battery charging" LED */
+&pwm2 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
+
+/* White "battery full" LED */
+&pwm3 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm3_gp80>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/skyrim/led_policy_skyrim.dts b/zephyr/program/skyrim/morthal/led_policy.dtsi
index a075c6b0d2..a075c6b0d2 100644
--- a/zephyr/projects/skyrim/led_policy_skyrim.dts
+++ b/zephyr/program/skyrim/morthal/led_policy.dtsi
diff --git a/zephyr/program/skyrim/morthal/morthal.dtsi b/zephyr/program/skyrim/morthal/morthal.dtsi
new file mode 100644
index 0000000000..99a062220d
--- /dev/null
+++ b/zephyr/program/skyrim/morthal/morthal.dtsi
@@ -0,0 +1,185 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/usbc_mux.h>
+
+#include "../i2c.dtsi"
+
+/ {
+ named-gpios {
+ /* Morthal-specific GPIO customizations */
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ soc-pct2075 {
+ temp_host_high = <100>;
+ temp_host_halt = <105>;
+ temp_host_release_high = <80>;
+ temp_host_release_halt = <80>;
+ temp_fan_off = <0>;
+ temp_fan_max = <70>;
+ power-good-pin = <&gpio_pg_pwr_s5>;
+ sensor = <&soc_pct2075>;
+ };
+ amb-pct2075 {
+ power-good-pin = <&gpio_pg_pwr_s5>;
+ sensor = <&amb_pct2075>;
+ };
+ };
+
+ /*
+ * Note this is expected to vary per-board, so we keep it in the board
+ * dts files.
+ */
+ morthal-fw-config {
+ compatible = "cros-ec,cbi-fw-config";
+
+ form-factor {
+ enum-name = "FW_FORM_FACTOR";
+ start = <0>;
+ size = <1>;
+
+ ff-clamshell {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FF_CLAMSHELL";
+ value = <0>;
+ };
+ ff-convertible {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FF_CONVERTIBLE";
+ value = <1>;
+ default;
+ };
+ };
+ io-db {
+ enum-name = "FW_IO_DB";
+ start = <6>;
+ size = <2>;
+
+ io-db-ps8811-ps8818 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_IO_DB_PS8811_PS8818";
+ value = <0>;
+ };
+ io-db-none-anx7483 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_IO_DB_NONE_ANX7483";
+ value = <1>;
+ default;
+ };
+ };
+
+ /*
+ * FW_CONFIG field to enable fan or not.
+ */
+ fan {
+ enum-name = "FW_FAN";
+ start = <10>;
+ size = <1>;
+
+ no-fan {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FAN_NOT_PRESENT";
+ value = <0>;
+ };
+ fan-present {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FAN_PRESENT";
+ value = <1>;
+ /*
+ * Set as default so that unprovisioned
+ * configs will run the fan regardless.
+ */
+ default;
+ };
+ };
+ };
+
+ /* Rotation matrices for motion sensors. */
+ motionsense-rotation-ref {
+ compatible = "cros-ec,motionsense-rotation-ref";
+ lid_rot_ref: lid-rotation-ref {
+ mat33 = <0 (-1) 0
+ 1 0 0
+ 0 0 1>;
+ };
+
+ lid_rot_ref1: lid-rotation-ref1 {
+ mat33 = <0 1 0
+ (-1) 0 0
+ 0 0 1>;
+ };
+
+ base_rot_ref: base-rotation-ref {
+ mat33 = <0 1 0
+ (-1) 0 0
+ 0 0 1>;
+ };
+ };
+
+ ppc_port0: aoz1380 {
+ compatible = "aoz,aoz1380";
+ status = "okay";
+ };
+};
+
+&i2c0_0 {
+ anx7483_port0: anx7483@3e {
+ compatible = "analogix,anx7483";
+ reg = <0x3e>;
+ board-set = "board_anx7483_c0_mux_set";
+ flags = <USB_MUX_FLAG_RESETS_IN_G3>;
+ };
+};
+
+&i2c1_0 {
+ anx7483_port1: anx7483@3e {
+ compatible = "analogix,anx7483";
+ reg = <0x3e>;
+ board-set = "board_anx7483_c1_mux_set";
+ flags = <USB_MUX_FLAG_RESETS_IN_G3>;
+ };
+ ppc_port1: nx20p348x@71 {
+ compatible = "nxp,nx20p348x";
+ status = "okay";
+ reg = <0x71>;
+ };
+ ps8818_port1: ps8818@28 {
+ compatible = "parade,ps8818";
+ reg = <0x28>;
+ flags = <(USB_MUX_FLAG_RESETS_IN_G3)>;
+ board-set = "board_c1_ps8818_mux_set";
+ };
+};
+
+&i2c4_1 {
+ charger: isl9241@9 {
+ compatible = "intersil,isl9241";
+ status = "okay";
+ reg = <0x9>;
+ };
+};
+
+&usbc_port0 {
+ ppc = <&ppc_port0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port0 &anx7483_port0>;
+ };
+};
+
+&usbc_port1 {
+ ppc = <&ppc_port1>;
+ usb-mux-chain-1-anx {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port1 &anx7483_port1>;
+ };
+ usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port1 &ps8818_port1>;
+ alternative-chain;
+ };
+};
diff --git a/zephyr/program/skyrim/morthal/motionsense.dtsi b/zephyr/program/skyrim/morthal/motionsense.dtsi
new file mode 100644
index 0000000000..f943bea4c8
--- /dev/null
+++ b/zephyr/program/skyrim/morthal/motionsense.dtsi
@@ -0,0 +1,135 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/motionsense/utils.h>
+
+
+/ {
+ aliases {
+ /*
+ * motion sense's <>_INT_EVENT is handled
+ * by alias. Using the alias, each driver creates
+ * its own <>_INT_EVENT.
+ */
+ bmi3xx-int = &base_accel;
+ };
+
+ /*
+ * Declare mutexes used by sensor drivers.
+ * A mutex node is used to create an instance of mutex_t.
+ * A mutex node is referenced by a sensor node if the
+ * corresponding sensor driver needs to use the
+ * instance of the mutex.
+ */
+ motionsense-mutex {
+ compatible = "cros-ec,motionsense-mutex";
+ lid_mutex: lid-mutex {
+ };
+
+ mutex_bmi3xx: bmi3xx-mutex {
+ };
+ };
+
+ /*
+ * Driver specific data. A driver-specific data can be shared with
+ * different motion sensors while they are using the same driver.
+ *
+ * If a node's compatible starts with "cros-ec,accelgyro-", it is for
+ * a common structure defined in accelgyro.h.
+ * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
+ * "struct als_drv_data_t" in accelgyro.h
+ */
+ motionsense-sensor-data {
+ bma4xx_data: bma4xx-drv-data {
+ compatible = "cros-ec,drvdata-bma4xx";
+ status = "okay";
+ };
+
+ bmi3xx_data: bmi3xx-drv-data {
+ compatible = "cros-ec,drvdata-bmi3xx";
+ status = "okay";
+ };
+ };
+
+ /*
+ * List of motion sensors that creates motion_sensors array.
+ * The nodelabel "lid_accel" and "base_accel" are used to indicate
+ * motion sensor IDs for lid angle calculation.
+ */
+ motionsense-sensor {
+ lid_accel: lid-accel {
+ compatible = "cros-ec,bma4xx";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex>;
+ port = <&i2c_sensor>;
+ drv-data = <&bma4xx_data>;
+ rot-standard-ref = <&lid_rot_ref>;
+ default-range = <2>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ ec-rate = <100>;
+ };
+ ec-s3 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_accel: base-accel {
+ compatible = "cros-ec,bmi3xx-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&mutex_bmi3xx>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi3xx_data>;
+
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ ec-rate = <100>;
+ };
+ ec-s3 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base-gyro {
+ compatible = "cros-ec,bmi3xx-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&mutex_bmi3xx>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi3xx_data>;
+ };
+ };
+
+ motionsense-sensor-info {
+ compatible = "cros-ec,motionsense-sensor-info";
+
+ /*
+ * 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>;
+ };
+};
diff --git a/zephyr/program/skyrim/morthal/project.conf b/zephyr/program/skyrim/morthal/project.conf
new file mode 100644
index 0000000000..8a22f58ab8
--- /dev/null
+++ b/zephyr/program/skyrim/morthal/project.conf
@@ -0,0 +1,23 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Morthal reference-board-specific Kconfig settings.
+CONFIG_BOARD_MORTHAL=y
+
+# TODO(b/215404321): Remove later in board development
+CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
+CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_DT=y
+
+# Morthal is capable of sinking 100W
+CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000
+CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000
+CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000
+
+CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
diff --git a/zephyr/program/skyrim/morthal/project.overlay b/zephyr/program/skyrim/morthal/project.overlay
new file mode 100644
index 0000000000..a41d358cce
--- /dev/null
+++ b/zephyr/program/skyrim/morthal/project.overlay
@@ -0,0 +1,19 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Skyrim program common DTS includes */
+#include "../adc.dtsi"
+#include "../fan.dtsi"
+#include "../gpio.dtsi"
+#include "../interrupts.dtsi"
+#include "../keyboard.dtsi"
+#include "../usbc.dtsi"
+
+/* Morthal project DTS includes*/
+#include "morthal.dtsi"
+#include "battery.dtsi"
+#include "led_pins.dtsi"
+#include "led_policy.dtsi"
+#include "motionsense.dtsi"
diff --git a/zephyr/program/skyrim/morthal/src/ppc_config.c b/zephyr/program/skyrim/morthal/src/ppc_config.c
new file mode 100644
index 0000000000..8108742fdc
--- /dev/null
+++ b/zephyr/program/skyrim/morthal/src/ppc_config.c
@@ -0,0 +1,46 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Morthal board-specific PPC code */
+
+#include "driver/ppc/aoz1380_public.h"
+#include "driver/ppc/nx20p348x.h"
+#include "usbc_ppc.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/*
+ * In the AOZ1380 PPC, there are no programmable features. We use
+ * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0
+ * current limits.
+ */
+int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ int rv = EC_SUCCESS;
+
+ rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en),
+ (rp == TYPEC_RP_3A0) ? 1 : 0);
+
+ return rv;
+}
+
+void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_PPC_INT_ODL:
+ aoz1380_interrupt(0);
+ break;
+
+ case GPIO_USB_C1_PPC_INT_ODL:
+ nx20p348x_interrupt(1);
+ break;
+
+ default:
+ break;
+ }
+}
diff --git a/zephyr/program/skyrim/morthal/src/usb_mux_config.c b/zephyr/program/skyrim/morthal/src/usb_mux_config.c
new file mode 100644
index 0000000000..f4b6502b35
--- /dev/null
+++ b/zephyr/program/skyrim/morthal/src/usb_mux_config.c
@@ -0,0 +1,142 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Morthal board-specific USB-C mux configuration */
+
+#include "console.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "driver/retimer/anx7483_public.h"
+#include "hooks.h"
+#include "ioexpander.h"
+#include "usb_mux.h"
+#include "usbc/usb_muxes.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/*
+ * USB C0 (general) and C1 (just ANX DB) use IOEX pins to
+ * indicate flipped polarity to a protection switch.
+ */
+static int ioex_set_flip(int port, mux_state_t mux_state)
+{
+ if (port == 0) {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 0);
+ } else {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 0);
+ }
+
+ return EC_SUCCESS;
+}
+
+int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
+ return anx7483_set_default_tuning(me, mux_state);
+}
+
+int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED;
+
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
+ /* Remove flipped from the state for easier compraisons */
+ mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED;
+
+ RETURN_ERROR(anx7483_set_default_tuning(me, mux_state));
+
+ if (mux_state == USB_PD_MUX_USB_ENABLED) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DP_ENABLED) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DOCK && !flipped) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DOCK && flipped) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ }
+
+ return EC_SUCCESS;
+}
+
+int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ CPRINTSUSB("C1: PS8818 mux using default tuning");
+
+ /* Once a DP connection is established, we need to set IN_HPD */
+ if (mux_state & USB_PD_MUX_DP_ENABLED)
+ ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1);
+ else
+ ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0);
+
+ return 0;
+}
+
+static void setup_mux(void)
+{
+ uint32_t val;
+
+ if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0)
+ CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG");
+ /* Val will have our dts default on error, so continue setup */
+
+ if (val == FW_IO_DB_PS8811_PS8818) {
+ CPRINTSUSB("C1: Setting PS8818 mux");
+ USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1);
+ } else if (val == FW_IO_DB_NONE_ANX7483) {
+ CPRINTSUSB("C1: Setting ANX7483 mux");
+ } else {
+ CPRINTSUSB("Unexpected DB_IO board: %d", val);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C);
diff --git a/zephyr/program/skyrim/motionsense.dtsi b/zephyr/program/skyrim/motionsense.dtsi
new file mode 100644
index 0000000000..f943bea4c8
--- /dev/null
+++ b/zephyr/program/skyrim/motionsense.dtsi
@@ -0,0 +1,135 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/motionsense/utils.h>
+
+
+/ {
+ aliases {
+ /*
+ * motion sense's <>_INT_EVENT is handled
+ * by alias. Using the alias, each driver creates
+ * its own <>_INT_EVENT.
+ */
+ bmi3xx-int = &base_accel;
+ };
+
+ /*
+ * Declare mutexes used by sensor drivers.
+ * A mutex node is used to create an instance of mutex_t.
+ * A mutex node is referenced by a sensor node if the
+ * corresponding sensor driver needs to use the
+ * instance of the mutex.
+ */
+ motionsense-mutex {
+ compatible = "cros-ec,motionsense-mutex";
+ lid_mutex: lid-mutex {
+ };
+
+ mutex_bmi3xx: bmi3xx-mutex {
+ };
+ };
+
+ /*
+ * Driver specific data. A driver-specific data can be shared with
+ * different motion sensors while they are using the same driver.
+ *
+ * If a node's compatible starts with "cros-ec,accelgyro-", it is for
+ * a common structure defined in accelgyro.h.
+ * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
+ * "struct als_drv_data_t" in accelgyro.h
+ */
+ motionsense-sensor-data {
+ bma4xx_data: bma4xx-drv-data {
+ compatible = "cros-ec,drvdata-bma4xx";
+ status = "okay";
+ };
+
+ bmi3xx_data: bmi3xx-drv-data {
+ compatible = "cros-ec,drvdata-bmi3xx";
+ status = "okay";
+ };
+ };
+
+ /*
+ * List of motion sensors that creates motion_sensors array.
+ * The nodelabel "lid_accel" and "base_accel" are used to indicate
+ * motion sensor IDs for lid angle calculation.
+ */
+ motionsense-sensor {
+ lid_accel: lid-accel {
+ compatible = "cros-ec,bma4xx";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex>;
+ port = <&i2c_sensor>;
+ drv-data = <&bma4xx_data>;
+ rot-standard-ref = <&lid_rot_ref>;
+ default-range = <2>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ ec-rate = <100>;
+ };
+ ec-s3 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_accel: base-accel {
+ compatible = "cros-ec,bmi3xx-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&mutex_bmi3xx>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi3xx_data>;
+
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ ec-rate = <100>;
+ };
+ ec-s3 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base-gyro {
+ compatible = "cros-ec,bmi3xx-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&mutex_bmi3xx>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi3xx_data>;
+ };
+ };
+
+ motionsense-sensor-info {
+ compatible = "cros-ec,motionsense-sensor-info";
+
+ /*
+ * 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>;
+ };
+};
diff --git a/zephyr/program/skyrim/program.conf b/zephyr/program/skyrim/program.conf
new file mode 100644
index 0000000000..e879e1153b
--- /dev/null
+++ b/zephyr/program/skyrim/program.conf
@@ -0,0 +1,140 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_CROS_EC=y
+CONFIG_PLATFORM_EC=y
+CONFIG_SHIMMED_TASKS=y
+CONFIG_ESPI=y
+
+# Shell features
+CONFIG_SHELL_HELP=y
+CONFIG_SHELL_HISTORY=y
+CONFIG_SHELL_TAB=y
+CONFIG_SHELL_TAB_AUTOCOMPLETION=y
+CONFIG_KERNEL_SHELL=y
+
+# Power sequencing
+CONFIG_AP=y
+CONFIG_AP_X86_AMD=y
+CONFIG_PLATFORM_EC_POWERSEQ=y
+CONFIG_PLATFORM_EC_POWER_BUTTON_TO_PCH_CUSTOM=y
+CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
+CONFIG_PLATFORM_EC_POWERSEQ_RSMRST_DELAY=y
+CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y
+CONFIG_PLATFORM_EC_PORT80=y
+
+# Power button
+CONFIG_PLATFORM_EC_POWER_BUTTON=y
+
+# CBI
+CONFIG_EEPROM=y
+CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
+
+# Temperature Sensors
+CONFIG_PLATFORM_EC_AMD_SB_RMI=y
+CONFIG_PLATFORM_EC_AMD_STT=y
+CONFIG_PLATFORM_EC_THROTTLE_AP=y
+
+# External power
+CONFIG_PLATFORM_EC_HOSTCMD=y
+CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=y
+CONFIG_PLATFORM_EC_BACKLIGHT_LID_ACTIVE_LOW=y
+
+# Sensors
+CONFIG_SENSOR=y
+CONFIG_SENSOR_SHELL=n
+
+# Lid switch
+CONFIG_PLATFORM_EC_LID_ANGLE=y
+CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
+CONFIG_PLATFORM_EC_LID_SWITCH=y
+
+# Keyboard
+CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y
+CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
+CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
+CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
+CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
+
+# Syscon
+CONFIG_SYSCON=y
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_SMART=y
+CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
+CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
+CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
+
+# Charger
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
+CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT=512
+CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512
+CONFIG_PLATFORM_EC_CHARGER_ISL9241=y
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20
+CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000
+
+# USB-C
+CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y
+CONFIG_PLATFORM_EC_USBC_PPC_AOZ1380=y
+CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7451=y
+CONFIG_PLATFORM_EC_USBC_RETIMER_PS8811=y
+CONFIG_PLATFORM_EC_USBC_RETIMER_PS8818=y
+CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y
+CONFIG_PLATFORM_EC_USB_MUX_AMD_FP6=y
+CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y
+CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
+CONFIG_PLATFORM_EC_USB_PID=0x505F
+CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y
+CONFIG_PLATFORM_EC_USB_PD_FRS=y
+CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
+CONFIG_PLATFORM_EC_USB_PD_REV30=y
+CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
+CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y
+CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n
+CONFIG_PLATFORM_EC_USB_PD_USB4=n
+CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
+# Give ourselves enough task space to use i2ctrace
+CONFIG_TASK_PD_STACK_SIZE=1280
+
+# Motion sense
+CONFIG_PLATFORM_EC_MOTIONSENSE=y
+CONFIG_PLATFORM_EC_ACCEL_FIFO=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
+CONFIG_PLATFORM_EC_LID_ANGLE=y
+CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
+CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
+
+CONFIG_PLATFORM_EC_MKBP_EVENT=y
+CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
+CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y
+
+CONFIG_PLATFORM_EC_TABLET_MODE=y
+CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
+CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
+
+CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
+
+# Misc.
+CONFIG_PLATFORM_EC_I2C_DEBUG=y
+CONFIG_PLATFORM_EC_PORT80_4_BYTE=y
+
+# These are debug options that happen to be expensive in terms of flash space.
+# Turn on as needed based on demand.
+CONFIG_FLASH_PAGE_LAYOUT=n # 1876 bytes
+CONFIG_FLASH_SHELL=n # 1852 bytes
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n # 656 bytes
+CONFIG_PLATFORM_EC_CONSOLE_CMD_MEM=n # 896 bytes
+# CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n # 1180 bytes
+CONFIG_PLATFORM_EC_CONSOLE_CMD_USB_PD_CABLE=n # 1104 bytes
+CONFIG_THREAD_MONITOR=n # 1548 bytes
diff --git a/zephyr/program/skyrim/skyrim/CMakeLists.txt b/zephyr/program/skyrim/skyrim/CMakeLists.txt
new file mode 100644
index 0000000000..fef1c72a31
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+cros_ec_library_include_directories_ifdef(CONFIG_BOARD_SKYRIM include)
+zephyr_library_sources(
+ "src/usb_mux_config.c"
+ "src/ppc_config.c"
+ "src/form_factor.c"
+ "src/alt_charger.c"
+ "src/keyboard.c"
+)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/fan.c")
diff --git a/zephyr/projects/skyrim/battery_skyrim.dts b/zephyr/program/skyrim/skyrim/battery.dtsi
index 8c87cef7f9..8c87cef7f9 100644
--- a/zephyr/projects/skyrim/battery_skyrim.dts
+++ b/zephyr/program/skyrim/skyrim/battery.dtsi
diff --git a/zephyr/program/skyrim/skyrim/led_pins.dtsi b/zephyr/program/skyrim/skyrim/led_pins.dtsi
new file mode 100644
index 0000000000..78b9a59c40
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/led_pins.dtsi
@@ -0,0 +1,59 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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_y: pwm_y {
+ pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ pwm_w: pwm_w {
+ pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ };
+
+ pwm-led-pins {
+ compatible = "cros-ec,pwm-led-pins";
+
+ color_off: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <0 0>;
+ };
+
+ color_amber: color-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <100 0>;
+ };
+
+ color_white: color-white {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <0 100>;
+ };
+ };
+};
+
+/* Amber "battery charging" LED */
+&pwm2 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
+
+/* White "battery full" LED */
+&pwm3 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm3_gp80>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/program/skyrim/skyrim/led_policy.dtsi b/zephyr/program/skyrim/skyrim/led_policy.dtsi
new file mode 100644
index 0000000000..a075c6b0d2
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/led_policy.dtsi
@@ -0,0 +1,103 @@
+#include <dt-bindings/battery.h>
+
+/ {
+ led-colors {
+ compatible = "cros-ec,led-policy";
+
+ power-state-charge {
+ charge-state = "PWR_STATE_CHARGE";
+
+ color-0 {
+ led-color = <&color_amber>;
+ };
+ };
+
+ power-state-discharge-s0 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+ /* Battery percent range (> Low, <= Full) */
+ batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>;
+
+ color-0 {
+ led-color = <&color_white>;
+ };
+ };
+
+ power-state-discharge-s0-batt-low {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S0";
+ /* Battery percent range (>= Empty, <= Low) */
+ batt-lvl = <BATTERY_LEVEL_EMPTY BATTERY_LEVEL_LOW>;
+
+ /* White 2 sec, off 1 sec */
+ color-0 {
+ led-color = <&color_white>;
+ period-ms = <2000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <1000>;
+ };
+ };
+
+ power-state-discharge-s3 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S3";
+
+ /* White 1 sec, off 1 sec */
+ color-0 {
+ led-color = <&color_white>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <1000>;
+ };
+ };
+
+ power-state-discharge-s5 {
+ charge-state = "PWR_STATE_DISCHARGE";
+ chipset-state = "POWER_S5";
+
+ color-0 {
+ led-color = <&color_off>;
+ };
+ };
+
+ power-state-error {
+ charge-state = "PWR_STATE_ERROR";
+
+ /* Amber 1 sec, off 1 sec */
+ color-0 {
+ led-color = <&color_amber>;
+ period-ms = <1000>;
+ };
+ color-1 {
+ led-color = <&color_off>;
+ period-ms = <1000>;
+ };
+ };
+
+ power-state-near-full {
+ charge-state = "PWR_STATE_CHARGE_NEAR_FULL";
+
+ color-0 {
+ led-color = <&color_white>;
+ };
+ };
+
+ power-state-forced-idle {
+ charge-state = "PWR_STATE_FORCED_IDLE";
+
+ /* Amber 2 sec, White 2 sec */
+ color-0 {
+ led-color = <&color_amber>;
+ period-ms = <2000>;
+ };
+ color-1 {
+ led-color = <&color_white>;
+ period-ms = <2000>;
+ };
+ };
+ };
+};
diff --git a/zephyr/program/skyrim/skyrim/motionsense.dtsi b/zephyr/program/skyrim/skyrim/motionsense.dtsi
new file mode 100644
index 0000000000..f943bea4c8
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/motionsense.dtsi
@@ -0,0 +1,135 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/motionsense/utils.h>
+
+
+/ {
+ aliases {
+ /*
+ * motion sense's <>_INT_EVENT is handled
+ * by alias. Using the alias, each driver creates
+ * its own <>_INT_EVENT.
+ */
+ bmi3xx-int = &base_accel;
+ };
+
+ /*
+ * Declare mutexes used by sensor drivers.
+ * A mutex node is used to create an instance of mutex_t.
+ * A mutex node is referenced by a sensor node if the
+ * corresponding sensor driver needs to use the
+ * instance of the mutex.
+ */
+ motionsense-mutex {
+ compatible = "cros-ec,motionsense-mutex";
+ lid_mutex: lid-mutex {
+ };
+
+ mutex_bmi3xx: bmi3xx-mutex {
+ };
+ };
+
+ /*
+ * Driver specific data. A driver-specific data can be shared with
+ * different motion sensors while they are using the same driver.
+ *
+ * If a node's compatible starts with "cros-ec,accelgyro-", it is for
+ * a common structure defined in accelgyro.h.
+ * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
+ * "struct als_drv_data_t" in accelgyro.h
+ */
+ motionsense-sensor-data {
+ bma4xx_data: bma4xx-drv-data {
+ compatible = "cros-ec,drvdata-bma4xx";
+ status = "okay";
+ };
+
+ bmi3xx_data: bmi3xx-drv-data {
+ compatible = "cros-ec,drvdata-bmi3xx";
+ status = "okay";
+ };
+ };
+
+ /*
+ * List of motion sensors that creates motion_sensors array.
+ * The nodelabel "lid_accel" and "base_accel" are used to indicate
+ * motion sensor IDs for lid angle calculation.
+ */
+ motionsense-sensor {
+ lid_accel: lid-accel {
+ compatible = "cros-ec,bma4xx";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_LID";
+ mutex = <&lid_mutex>;
+ port = <&i2c_sensor>;
+ drv-data = <&bma4xx_data>;
+ rot-standard-ref = <&lid_rot_ref>;
+ default-range = <2>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ ec-rate = <100>;
+ };
+ ec-s3 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base_accel: base-accel {
+ compatible = "cros-ec,bmi3xx-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&mutex_bmi3xx>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi3xx_data>;
+
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ ec-rate = <100>;
+ };
+ ec-s3 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+
+ base-gyro {
+ compatible = "cros-ec,bmi3xx-gyro";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&mutex_bmi3xx>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi3xx_data>;
+ };
+ };
+
+ motionsense-sensor-info {
+ compatible = "cros-ec,motionsense-sensor-info";
+
+ /*
+ * 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>;
+ };
+};
diff --git a/zephyr/program/skyrim/skyrim/project.conf b/zephyr/program/skyrim/skyrim/project.conf
new file mode 100644
index 0000000000..67b3f0f142
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/project.conf
@@ -0,0 +1,26 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Skyrim reference-board-specific Kconfig settings.
+CONFIG_BOARD_SKYRIM=y
+
+# CBI WP pin present
+CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_DT=y
+
+# Skyrim is capable of sinking 100W
+CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000
+CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000
+CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000
+
+CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y
+
+# Enable alternative charger chip
+CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y
+CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
diff --git a/zephyr/program/skyrim/skyrim/project.overlay b/zephyr/program/skyrim/skyrim/project.overlay
new file mode 100644
index 0000000000..9b61b2ac9b
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/project.overlay
@@ -0,0 +1,19 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Skyrim program common DTS includes */
+#include "../adc.dtsi"
+#include "../fan.dtsi"
+#include "../gpio.dtsi"
+#include "../interrupts.dtsi"
+#include "../keyboard.dtsi"
+#include "../usbc.dtsi"
+
+/* Skyrim project DTS includes*/
+#include "skyrim.dtsi"
+#include "battery.dtsi"
+#include "led_pins.dtsi"
+#include "led_policy.dtsi"
+#include "motionsense.dtsi"
diff --git a/zephyr/program/skyrim/skyrim/skyrim.dtsi b/zephyr/program/skyrim/skyrim/skyrim.dtsi
new file mode 100644
index 0000000000..1037df1c8c
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/skyrim.dtsi
@@ -0,0 +1,209 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/usbc_mux.h>
+
+#include "../i2c.dtsi"
+
+/ {
+ named-gpios {
+ /* Skyrim-specific GPIO customizations */
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ soc-pct2075 {
+ temp_host_high = <100>;
+ temp_host_halt = <105>;
+ temp_host_release_high = <80>;
+ temp_host_release_halt = <80>;
+ temp_fan_off = <35>;
+ temp_fan_max = <70>;
+ power-good-pin = <&gpio_pg_pwr_s5>;
+ sensor = <&soc_pct2075>;
+ };
+ amb-pct2075 {
+ power-good-pin = <&gpio_pg_pwr_s5>;
+ sensor = <&amb_pct2075>;
+ };
+ };
+
+ /*
+ * Note this is expected to vary per-board, so we keep it in the board
+ * dts files.
+ */
+ skyrim-fw-config {
+ compatible = "cros-ec,cbi-fw-config";
+
+ form-factor {
+ enum-name = "FW_FORM_FACTOR";
+ start = <0>;
+ size = <1>;
+
+ ff-clamshell {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FF_CLAMSHELL";
+ value = <0>;
+ };
+ ff-convertible {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FF_CONVERTIBLE";
+ value = <1>;
+ default;
+ };
+ };
+ io-db {
+ enum-name = "FW_IO_DB";
+ start = <6>;
+ size = <2>;
+
+ io-db-ps8811-ps8818 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_IO_DB_PS8811_PS8818";
+ value = <0>;
+ };
+ io-db-none-anx7483 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_IO_DB_NONE_ANX7483";
+ value = <1>;
+ default;
+ };
+ };
+
+ /*
+ * FW_CONFIG field to enable fan or not.
+ */
+ fan {
+ enum-name = "FW_FAN";
+ start = <10>;
+ size = <1>;
+
+ no-fan {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FAN_NOT_PRESENT";
+ value = <0>;
+ };
+ fan-present {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_FAN_PRESENT";
+ value = <1>;
+ /*
+ * Set as default so that unprovisioned
+ * configs will run the fan regardless.
+ */
+ default;
+ };
+ };
+
+ charger-option {
+ enum-name = "FW_CHARGER";
+ start = <11>;
+ size = <2>;
+
+ charger-option-isl9241 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_CHARGER_ISL9241";
+ value = <0>;
+ default;
+ };
+ charger-option-isl9538 {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_CHARGER_ISL9538";
+ value = <1>;
+ };
+ };
+ };
+
+ /* Rotation matrices for motion sensors. */
+ motionsense-rotation-ref {
+ compatible = "cros-ec,motionsense-rotation-ref";
+ lid_rot_ref: lid-rotation-ref {
+ mat33 = <0 (-1) 0
+ 1 0 0
+ 0 0 1>;
+ };
+
+ lid_rot_ref1: lid-rotation-ref1 {
+ mat33 = <0 1 0
+ (-1) 0 0
+ 0 0 1>;
+ };
+
+ base_rot_ref: base-rotation-ref {
+ mat33 = <0 1 0
+ (-1) 0 0
+ 0 0 1>;
+ };
+ };
+
+ ppc_port0: aoz1380 {
+ compatible = "aoz,aoz1380";
+ status = "okay";
+ };
+};
+
+&i2c0_0 {
+ anx7483_port0: anx7483@3e {
+ compatible = "analogix,anx7483";
+ reg = <0x3e>;
+ board-set = "board_anx7483_c0_mux_set";
+ flags = <USB_MUX_FLAG_RESETS_IN_G3>;
+ };
+};
+
+&i2c1_0 {
+ anx7483_port1: anx7483@3e {
+ compatible = "analogix,anx7483";
+ reg = <0x3e>;
+ board-set = "board_anx7483_c1_mux_set";
+ flags = <USB_MUX_FLAG_RESETS_IN_G3>;
+ };
+ ppc_port1: nx20p348x@71 {
+ compatible = "nxp,nx20p348x";
+ status = "okay";
+ reg = <0x71>;
+ };
+ ps8818_port1: ps8818@28 {
+ compatible = "parade,ps8818";
+ reg = <0x28>;
+ flags = <(USB_MUX_FLAG_RESETS_IN_G3)>;
+ board-set = "board_c1_ps8818_mux_set";
+ };
+};
+
+&i2c4_1 {
+ charger: isl9241@9 {
+ compatible = "intersil,isl9241";
+ status = "okay";
+ reg = <0x9>;
+ };
+ alt_charger: isl9538@9 {
+ compatible = "intersil,isl923x";
+ status = "okay";
+ reg = <0x9>;
+ };
+};
+
+&usbc_port0 {
+ chg_alt = <&alt_charger>;
+ ppc = <&ppc_port0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port0 &anx7483_port0>;
+ };
+};
+
+&usbc_port1 {
+ ppc = <&ppc_port1>;
+ usb-mux-chain-1-anx {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port1 &anx7483_port1>;
+ };
+ usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port1 &ps8818_port1>;
+ alternative-chain;
+ };
+};
diff --git a/zephyr/program/skyrim/skyrim/skyrim_vif.xml b/zephyr/program/skyrim/skyrim/skyrim_vif.xml
new file mode 100644
index 0000000000..28d6f19049
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/skyrim_vif.xml
@@ -0,0 +1,346 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vif:VIF xmlns:opt="http://usb.org/VendorInfoFileOptionalContent.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:vif="http://usb.org/VendorInfoFile.xsd">
+ <vif:VIF_Specification>3.22</vif:VIF_Specification>
+ <vif:VIF_App>
+ <vif:Vendor>USB-IF</vif:Vendor>
+ <vif:Name>VIF Editor</vif:Name>
+ <vif:Version>3.4.2.0</vif:Version>
+ </vif:VIF_App>
+ <vif:Vendor_Name>Google</vif:Vendor_Name>
+ <vif:Model_Part_Number>skyrim</vif:Model_Part_Number>
+ <vif:Product_Revision>FIX-ME</vif:Product_Revision>
+ <vif:TID>65535</vif:TID>
+ <vif:VIF_Product_Type value="0">Port Product</vif:VIF_Product_Type>
+ <vif:Certification_Type value="0">End Product</vif:Certification_Type>
+ <vif:Product>
+ <!--Product Level Content:-->
+ </vif:Product>
+ <vif:Component>
+ <!--Component 0: Port 0-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;Component-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:Port_Label>0</vif:Port_Label>
+ <vif:Connector_Type value="2">Type-C®</vif:Connector_Type>
+ <vif:USB4_Supported value="false" />
+ <vif:USB_PD_Support value="true" />
+ <vif:PD_Port_Type value="4">DRP</vif:PD_Port_Type>
+ <vif:Type_C_State_Machine value="2">DRP</vif:Type_C_State_Machine>
+ <vif:Port_Battery_Powered value="true" />
+ <vif:BC_1_2_Support value="3">Both</vif:BC_1_2_Support>
+ <vif:Captive_Cable value="false" />
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;General PD-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:PD_Spec_Revision_Major value="3" />
+ <vif:PD_Spec_Revision_Minor value="0" />
+ <vif:PD_Spec_Version_Major value="2" />
+ <vif:PD_Spec_Version_Minor value="0" />
+ <vif:PD_Specification_Revision value="2">Revision 3</vif:PD_Specification_Revision>
+ <vif:SOP_Capable value="true" />
+ <vif:SOP_P_Capable value="true" />
+ <vif:SOP_PP_Capable value="true" />
+ <vif:SOP_P_Debug_Capable value="false" />
+ <vif:SOP_PP_Debug_Capable value="false" />
+ <vif:Manufacturer_Info_Supported_Port value="false" />
+ <vif:Chunking_Implemented_SOP value="true" />
+ <vif:Unchunked_Extended_Messages_Supported value="false" />
+ <vif:Security_Msgs_Supported_SOP value="false" />
+ <vif:Unconstrained_Power value="false" />
+ <vif:Num_Fixed_Batteries value="1" />
+ <vif:Num_Swappable_Battery_Slots value="0" />
+ <vif:ID_Header_Connector_Type_SOP value="2">USB Type-C® Receptacle</vif:ID_Header_Connector_Type_SOP>
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;PD Capabilities-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:USB_Comms_Capable value="true" />
+ <vif:DR_Swap_To_DFP_Supported value="true" />
+ <vif:DR_Swap_To_UFP_Supported value="false" />
+ <vif:VCONN_Swap_To_On_Supported value="true" />
+ <vif:VCONN_Swap_To_Off_Supported value="true" />
+ <vif:Responds_To_Discov_SOP_UFP value="true" />
+ <vif:Responds_To_Discov_SOP_DFP value="true" />
+ <vif:Attempts_Discov_SOP value="true" />
+ <vif:Power_Interruption_Available value="0">No Interruption Possible</vif:Power_Interruption_Available>
+ <vif:Data_Reset_Supported value="false" />
+ <vif:Enter_USB_Supported value="false" />
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;USB Type-C®-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:Type_C_Can_Act_As_Host value="true" />
+ <vif:Type_C_Can_Act_As_Device value="false" />
+ <vif:Type_C_Implements_Try_SRC value="true" />
+ <vif:Type_C_Implements_Try_SNK value="false" />
+ <vif:Type_C_Supports_Audio_Accessory value="false" />
+ <vif:Type_C_Is_VCONN_Powered_Accessory value="false" />
+ <vif:Type_C_Is_Debug_Target_SRC value="true" />
+ <vif:Type_C_Is_Debug_Target_SNK value="true" />
+ <vif:RP_Value value="1">1.5A</vif:RP_Value>
+ <vif:Type_C_Port_On_Hub value="false" />
+ <vif:Type_C_Power_Source value="2">Both</vif:Type_C_Power_Source>
+ <vif:Type_C_Sources_VCONN value="true" />
+ <vif:Type_C_Is_Alt_Mode_Controller value="true" />
+ <vif:Type_C_Is_Alt_Mode_Adapter value="false" />
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;Product Power-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:Product_Total_Source_Power_mW value="22500">22500 mW</vif:Product_Total_Source_Power_mW>
+ <vif:Port_Source_Power_Type value="1">Shared</vif:Port_Source_Power_Type>
+ <vif:Port_Source_Power_Gang>CPower</vif:Port_Source_Power_Gang>
+ <vif:Port_Source_Power_Gang_Max_Power value="22500">22500 mW</vif:Port_Source_Power_Gang_Max_Power>
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;USB Host-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:Host_Supports_USB_Data value="true" />
+ <vif:Host_Speed value="1">USB 3.2 Gen 1x1</vif:Host_Speed>
+ <vif:Host_Contains_Captive_Retimer value="true" />
+ <vif:Host_Truncates_DP_For_tDHPResponse value="false" />
+ <vif:Host_Is_Embedded value="false" />
+ <vif:Host_Suspend_Supported value="true" />
+ <vif:Is_DFP_On_Hub value="false" />
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;Battery Charging 1.2-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:BC_1_2_Charging_Port_Type value="1">CDP</vif:BC_1_2_Charging_Port_Type>
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;PD Source-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:PD_Power_As_Source value="1500">1500 mW</vif:PD_Power_As_Source>
+ <vif:EPR_Supported_As_Src value="false" />
+ <vif:USB_Suspend_May_Be_Cleared value="true" />
+ <vif:Sends_Pings value="false" />
+ <vif:FR_Swap_Type_C_Current_Capability_As_Initial_Sink value="3">3A @ 5V</vif:FR_Swap_Type_C_Current_Capability_As_Initial_Sink>
+ <vif:Master_Port value="true" />
+ <vif:Has_Invariant_PDOs value="false" />
+ <vif:Num_Src_PDOs value="1" />
+ <vif:PD_OC_Protection value="false" />
+ <!--Bundle: SrcPdoList-->
+ <vif:SrcPdoList>
+ <vif:SrcPDO>
+ <!--Source PDO 1-->
+ <vif:Src_PDO_Supply_Type value="0">Fixed</vif:Src_PDO_Supply_Type>
+ <vif:Src_PDO_Peak_Current value="0">100% IOC</vif:Src_PDO_Peak_Current>
+ <vif:Src_PDO_Voltage value="100">5000 mV</vif:Src_PDO_Voltage>
+ <vif:Src_PDO_Max_Current value="300">3000 mA</vif:Src_PDO_Max_Current>
+ </vif:SrcPDO>
+ </vif:SrcPdoList>
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;PD Sink-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:PD_Power_As_Sink value="100000">100000 mW</vif:PD_Power_As_Sink>
+ <vif:EPR_Supported_As_Snk value="false" />
+ <vif:No_USB_Suspend_May_Be_Set value="true" />
+ <vif:GiveBack_May_Be_Set value="false" />
+ <vif:Higher_Capability_Set value="false" />
+ <vif:FR_Swap_Reqd_Type_C_Current_As_Initial_Source value="0">FR_Swap not supported</vif:FR_Swap_Reqd_Type_C_Current_As_Initial_Source>
+ <vif:Num_Snk_PDOs value="3" />
+ <!--Bundle: SnkPdoList-->
+ <vif:SnkPdoList>
+ <vif:SnkPDO>
+ <!--Sink PDO 1-->
+ <vif:Snk_PDO_Supply_Type value="0">Fixed</vif:Snk_PDO_Supply_Type>
+ <vif:Snk_PDO_Voltage value="100">5000 mV</vif:Snk_PDO_Voltage>
+ <vif:Snk_PDO_Op_Current value="300">3000 mA</vif:Snk_PDO_Op_Current>
+ </vif:SnkPDO>
+ <vif:SnkPDO>
+ <!--Sink PDO 2-->
+ <vif:Snk_PDO_Supply_Type value="1">Battery</vif:Snk_PDO_Supply_Type>
+ <vif:Snk_PDO_Op_Power value="60">15000 mW</vif:Snk_PDO_Op_Power>
+ <vif:Snk_PDO_Min_Voltage value="95">4750 mV</vif:Snk_PDO_Min_Voltage>
+ <vif:Snk_PDO_Max_Voltage value="400">20000 mV</vif:Snk_PDO_Max_Voltage>
+ </vif:SnkPDO>
+ <vif:SnkPDO>
+ <!--Sink PDO 3-->
+ <vif:Snk_PDO_Supply_Type value="2">Variable</vif:Snk_PDO_Supply_Type>
+ <vif:Snk_PDO_Min_Voltage value="95">4750 mV</vif:Snk_PDO_Min_Voltage>
+ <vif:Snk_PDO_Max_Voltage value="400">20000 mV</vif:Snk_PDO_Max_Voltage>
+ <vif:Snk_PDO_Op_Current value="500">5000 mA</vif:Snk_PDO_Op_Current>
+ </vif:SnkPDO>
+ </vif:SnkPdoList>
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;Dual Role-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:Accepts_PR_Swap_As_Src value="true" />
+ <vif:Accepts_PR_Swap_As_Snk value="true" />
+ <vif:Requests_PR_Swap_As_Src value="true" />
+ <vif:Requests_PR_Swap_As_Snk value="true" />
+ <vif:FR_Swap_Supported_As_Initial_Sink value="true" />
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;SOP Discover ID-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:XID_SOP value="0" />
+ <vif:Data_Capable_As_USB_Host_SOP value="true" />
+ <vif:Data_Capable_As_USB_Device_SOP value="false" />
+ <vif:Product_Type_UFP_SOP value="0">Undefined</vif:Product_Type_UFP_SOP>
+ <vif:Product_Type_DFP_SOP value="2">PDUSB Host</vif:Product_Type_DFP_SOP>
+ <vif:DFP_VDO_Port_Number value="0" />
+ <vif:Modal_Operation_Supported_SOP value="false" />
+ <vif:USB_VID_SOP value="6353">18D1</vif:USB_VID_SOP>
+ <vif:PID_SOP value="20575">505F</vif:PID_SOP>
+ <vif:bcdDevice_SOP value="0">0000</vif:bcdDevice_SOP>
+ </vif:Component>
+ <vif:Component>
+ <!--Component 1: Port 1-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;Component-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:Port_Label>1</vif:Port_Label>
+ <vif:Connector_Type value="2">Type-C®</vif:Connector_Type>
+ <vif:USB4_Supported value="false" />
+ <vif:USB_PD_Support value="true" />
+ <vif:PD_Port_Type value="4">DRP</vif:PD_Port_Type>
+ <vif:Type_C_State_Machine value="2">DRP</vif:Type_C_State_Machine>
+ <vif:Port_Battery_Powered value="true" />
+ <vif:BC_1_2_Support value="3">Both</vif:BC_1_2_Support>
+ <vif:Captive_Cable value="false" />
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;General PD-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:PD_Spec_Revision_Major value="3" />
+ <vif:PD_Spec_Revision_Minor value="0" />
+ <vif:PD_Spec_Version_Major value="2" />
+ <vif:PD_Spec_Version_Minor value="0" />
+ <vif:PD_Specification_Revision value="2">Revision 3</vif:PD_Specification_Revision>
+ <vif:SOP_Capable value="true" />
+ <vif:SOP_P_Capable value="true" />
+ <vif:SOP_PP_Capable value="true" />
+ <vif:SOP_P_Debug_Capable value="false" />
+ <vif:SOP_PP_Debug_Capable value="false" />
+ <vif:Manufacturer_Info_Supported_Port value="false" />
+ <vif:Chunking_Implemented_SOP value="true" />
+ <vif:Unchunked_Extended_Messages_Supported value="false" />
+ <vif:Security_Msgs_Supported_SOP value="false" />
+ <vif:Unconstrained_Power value="false" />
+ <vif:Num_Fixed_Batteries value="1" />
+ <vif:Num_Swappable_Battery_Slots value="0" />
+ <vif:ID_Header_Connector_Type_SOP value="2">USB Type-C® Receptacle</vif:ID_Header_Connector_Type_SOP>
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;PD Capabilities-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:USB_Comms_Capable value="true" />
+ <vif:DR_Swap_To_DFP_Supported value="true" />
+ <vif:DR_Swap_To_UFP_Supported value="false" />
+ <vif:VCONN_Swap_To_On_Supported value="true" />
+ <vif:VCONN_Swap_To_Off_Supported value="true" />
+ <vif:Responds_To_Discov_SOP_UFP value="true" />
+ <vif:Responds_To_Discov_SOP_DFP value="true" />
+ <vif:Attempts_Discov_SOP value="true" />
+ <vif:Power_Interruption_Available value="0">No Interruption Possible</vif:Power_Interruption_Available>
+ <vif:Data_Reset_Supported value="false" />
+ <vif:Enter_USB_Supported value="false" />
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;USB Type-C®-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:Type_C_Can_Act_As_Host value="true" />
+ <vif:Type_C_Can_Act_As_Device value="false" />
+ <vif:Type_C_Implements_Try_SRC value="true" />
+ <vif:Type_C_Implements_Try_SNK value="false" />
+ <vif:Type_C_Supports_Audio_Accessory value="false" />
+ <vif:Type_C_Is_VCONN_Powered_Accessory value="false" />
+ <vif:Type_C_Is_Debug_Target_SRC value="true" />
+ <vif:Type_C_Is_Debug_Target_SNK value="true" />
+ <vif:RP_Value value="1">1.5A</vif:RP_Value>
+ <vif:Type_C_Port_On_Hub value="false" />
+ <vif:Type_C_Power_Source value="2">Both</vif:Type_C_Power_Source>
+ <vif:Type_C_Sources_VCONN value="true" />
+ <vif:Type_C_Is_Alt_Mode_Controller value="true" />
+ <vif:Type_C_Is_Alt_Mode_Adapter value="false" />
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;Product Power-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:Product_Total_Source_Power_mW value="22500">22500 mW</vif:Product_Total_Source_Power_mW>
+ <vif:Port_Source_Power_Type value="1">Shared</vif:Port_Source_Power_Type>
+ <vif:Port_Source_Power_Gang>CPower</vif:Port_Source_Power_Gang>
+ <vif:Port_Source_Power_Gang_Max_Power value="22500">22500 mW</vif:Port_Source_Power_Gang_Max_Power>
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;USB Host-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:Host_Supports_USB_Data value="true" />
+ <vif:Host_Speed value="1">USB 3.2 Gen 1x1</vif:Host_Speed>
+ <vif:Host_Contains_Captive_Retimer value="true" />
+ <vif:Host_Truncates_DP_For_tDHPResponse value="false" />
+ <vif:Host_Is_Embedded value="false" />
+ <vif:Host_Suspend_Supported value="true" />
+ <vif:Is_DFP_On_Hub value="false" />
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;Battery Charging 1.2-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:BC_1_2_Charging_Port_Type value="1">CDP</vif:BC_1_2_Charging_Port_Type>
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;PD Source-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:PD_Power_As_Source value="15000">15000 mW</vif:PD_Power_As_Source>
+ <vif:EPR_Supported_As_Src value="false" />
+ <vif:USB_Suspend_May_Be_Cleared value="true" />
+ <vif:Sends_Pings value="false" />
+ <vif:FR_Swap_Type_C_Current_Capability_As_Initial_Sink value="3">3A @ 5V</vif:FR_Swap_Type_C_Current_Capability_As_Initial_Sink>
+ <vif:Master_Port value="true" />
+ <vif:Has_Invariant_PDOs value="false" />
+ <vif:Num_Src_PDOs value="1" />
+ <vif:PD_OC_Protection value="false" />
+ <!--Bundle: SrcPdoList-->
+ <vif:SrcPdoList>
+ <vif:SrcPDO>
+ <!--Source PDO 1-->
+ <vif:Src_PDO_Supply_Type value="0">Fixed</vif:Src_PDO_Supply_Type>
+ <vif:Src_PDO_Peak_Current value="0">100% IOC</vif:Src_PDO_Peak_Current>
+ <vif:Src_PDO_Voltage value="100">5000 mV</vif:Src_PDO_Voltage>
+ <vif:Src_PDO_Max_Current value="300">3000 mA</vif:Src_PDO_Max_Current>
+ </vif:SrcPDO>
+ </vif:SrcPdoList>
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;PD Sink-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:PD_Power_As_Sink value="100000">100000 mW</vif:PD_Power_As_Sink>
+ <vif:EPR_Supported_As_Snk value="false" />
+ <vif:No_USB_Suspend_May_Be_Set value="true" />
+ <vif:GiveBack_May_Be_Set value="false" />
+ <vif:Higher_Capability_Set value="false" />
+ <vif:FR_Swap_Reqd_Type_C_Current_As_Initial_Source value="0">FR_Swap not supported</vif:FR_Swap_Reqd_Type_C_Current_As_Initial_Source>
+ <vif:Num_Snk_PDOs value="3" />
+ <!--Bundle: SnkPdoList-->
+ <vif:SnkPdoList>
+ <vif:SnkPDO>
+ <!--Sink PDO 1-->
+ <vif:Snk_PDO_Supply_Type value="0">Fixed</vif:Snk_PDO_Supply_Type>
+ <vif:Snk_PDO_Voltage value="100">5000 mV</vif:Snk_PDO_Voltage>
+ <vif:Snk_PDO_Op_Current value="300">3000 mA</vif:Snk_PDO_Op_Current>
+ </vif:SnkPDO>
+ <vif:SnkPDO>
+ <!--Sink PDO 2-->
+ <vif:Snk_PDO_Supply_Type value="1">Battery</vif:Snk_PDO_Supply_Type>
+ <vif:Snk_PDO_Op_Power value="60">15000 mW</vif:Snk_PDO_Op_Power>
+ <vif:Snk_PDO_Min_Voltage value="95">4750 mV</vif:Snk_PDO_Min_Voltage>
+ <vif:Snk_PDO_Max_Voltage value="400">20000 mV</vif:Snk_PDO_Max_Voltage>
+ </vif:SnkPDO>
+ <vif:SnkPDO>
+ <!--Sink PDO 3-->
+ <vif:Snk_PDO_Supply_Type value="2">Variable</vif:Snk_PDO_Supply_Type>
+ <vif:Snk_PDO_Min_Voltage value="95">4750 mV</vif:Snk_PDO_Min_Voltage>
+ <vif:Snk_PDO_Max_Voltage value="400">20000 mV</vif:Snk_PDO_Max_Voltage>
+ <vif:Snk_PDO_Op_Current value="500">5000 mA</vif:Snk_PDO_Op_Current>
+ </vif:SnkPDO>
+ </vif:SnkPdoList>
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;Dual Role-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:Accepts_PR_Swap_As_Src value="true" />
+ <vif:Accepts_PR_Swap_As_Snk value="true" />
+ <vif:Requests_PR_Swap_As_Src value="true" />
+ <vif:Requests_PR_Swap_As_Snk value="true" />
+ <vif:FR_Swap_Supported_As_Initial_Sink value="true" />
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <!--;SOP Discover ID-->
+ <!--;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-->
+ <vif:XID_SOP value="0" />
+ <vif:Data_Capable_As_USB_Host_SOP value="true" />
+ <vif:Data_Capable_As_USB_Device_SOP value="false" />
+ <vif:Product_Type_UFP_SOP value="0">Undefined</vif:Product_Type_UFP_SOP>
+ <vif:Product_Type_DFP_SOP value="2">PDUSB Host</vif:Product_Type_DFP_SOP>
+ <vif:DFP_VDO_Port_Number value="1" />
+ <vif:Modal_Operation_Supported_SOP value="false" />
+ <vif:USB_VID_SOP value="6353">18D1</vif:USB_VID_SOP>
+ <vif:PID_SOP value="20575">505F</vif:PID_SOP>
+ <vif:bcdDevice_SOP value="0">0000</vif:bcdDevice_SOP>
+ </vif:Component>
+</vif:VIF>
diff --git a/zephyr/program/skyrim/skyrim/src/alt_charger.c b/zephyr/program/skyrim/skyrim/src/alt_charger.c
new file mode 100644
index 0000000000..91e5af8426
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/src/alt_charger.c
@@ -0,0 +1,31 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charger_chips.h"
+#include "common.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "hooks.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL);
+
+static void alt_charger_init(void)
+{
+ int ret;
+ uint32_t val;
+
+ ret = cros_cbi_get_fw_config(FW_CHARGER, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER);
+ return;
+ }
+
+ if (val == FW_CHARGER_ISL9538)
+ CHG_ENABLE_ALTERNATE(0);
+}
+DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST);
diff --git a/zephyr/program/skyrim/skyrim/src/fan.c b/zephyr/program/skyrim/skyrim/src/fan.c
new file mode 100644
index 0000000000..c584022a92
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/src/fan.c
@@ -0,0 +1,62 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "fan.h"
+#include "gpio/gpio.h"
+#include "hooks.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL);
+
+/*
+ * Skyrim fan support
+ */
+static void fan_init(void)
+{
+ int ret;
+ uint32_t val;
+ uint32_t board_version;
+ /*
+ * 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;
+ }
+
+ ret = cbi_get_board_version(&board_version);
+ if (ret != EC_SUCCESS) {
+ LOG_ERR("Error retrieving CBI board version");
+ return;
+ }
+
+ if ((board_version >= 3) && (val != FW_FAN_PRESENT)) {
+ /* Disable the fan */
+ fan_set_count(0);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST);
+
+/*
+ * Pcore OCP support
+ * Note: early boards should note enable this interrupt as they are not
+ * correctly configured for it.
+ */
+__override bool board_supports_pcore_ocp(void)
+{
+ uint32_t board_version;
+
+ if (cbi_get_board_version(&board_version) == EC_SUCCESS &&
+ board_version > 3)
+ return true;
+
+ return false;
+}
diff --git a/zephyr/program/skyrim/skyrim/src/form_factor.c b/zephyr/program/skyrim/skyrim/src/form_factor.c
new file mode 100644
index 0000000000..b13d905364
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/src/form_factor.c
@@ -0,0 +1,38 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "accelgyro.h"
+#include "common.h"
+#include "cros_board_info.h"
+#include "hooks.h"
+#include "motionsense_sensors.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL);
+
+/*
+ * Mainboard orientation support.
+ */
+
+#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1))
+#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel))
+
+static void form_factor_init(void)
+{
+ int ret;
+ uint32_t val;
+ /*
+ * If the board version >=4
+ * use ver1 rotation matrix.
+ */
+ ret = cbi_get_board_version(&val);
+ if (ret == EC_SUCCESS && val >= 4) {
+ LOG_INF("Switching to ver1 lid");
+ motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT;
+ }
+}
+DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/projects/skyrim/src/skyrim/keyboard.c b/zephyr/program/skyrim/skyrim/src/keyboard.c
index e261321e86..e261321e86 100644
--- a/zephyr/projects/skyrim/src/skyrim/keyboard.c
+++ b/zephyr/program/skyrim/skyrim/src/keyboard.c
diff --git a/zephyr/program/skyrim/skyrim/src/ppc_config.c b/zephyr/program/skyrim/skyrim/src/ppc_config.c
new file mode 100644
index 0000000000..047103baee
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/src/ppc_config.c
@@ -0,0 +1,46 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Skyrim board-specific PPC code */
+
+#include "driver/ppc/aoz1380_public.h"
+#include "driver/ppc/nx20p348x.h"
+#include "usbc_ppc.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/*
+ * In the AOZ1380 PPC, there are no programmable features. We use
+ * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0
+ * current limits.
+ */
+int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ int rv = EC_SUCCESS;
+
+ rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en),
+ (rp == TYPEC_RP_3A0) ? 1 : 0);
+
+ return rv;
+}
+
+void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_PPC_INT_ODL:
+ aoz1380_interrupt(0);
+ break;
+
+ case GPIO_USB_C1_PPC_INT_ODL:
+ nx20p348x_interrupt(1);
+ break;
+
+ default:
+ break;
+ }
+}
diff --git a/zephyr/program/skyrim/skyrim/src/usb_mux_config.c b/zephyr/program/skyrim/skyrim/src/usb_mux_config.c
new file mode 100644
index 0000000000..8d409dffdd
--- /dev/null
+++ b/zephyr/program/skyrim/skyrim/src/usb_mux_config.c
@@ -0,0 +1,142 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Skyrim board-specific USB-C mux configuration */
+
+#include "console.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "driver/retimer/anx7483_public.h"
+#include "hooks.h"
+#include "ioexpander.h"
+#include "usb_mux.h"
+#include "usbc/usb_muxes.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/*
+ * USB C0 (general) and C1 (just ANX DB) use IOEX pins to
+ * indicate flipped polarity to a protection switch.
+ */
+static int ioex_set_flip(int port, mux_state_t mux_state)
+{
+ if (port == 0) {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 0);
+ } else {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 0);
+ }
+
+ return EC_SUCCESS;
+}
+
+int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
+ return anx7483_set_default_tuning(me, mux_state);
+}
+
+int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED;
+
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
+ /* Remove flipped from the state for easier compraisons */
+ mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED;
+
+ RETURN_ERROR(anx7483_set_default_tuning(me, mux_state));
+
+ if (mux_state == USB_PD_MUX_USB_ENABLED) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DP_ENABLED) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DOCK && !flipped) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DOCK && flipped) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ }
+
+ return EC_SUCCESS;
+}
+
+int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ CPRINTSUSB("C1: PS8818 mux using default tuning");
+
+ /* Once a DP connection is established, we need to set IN_HPD */
+ if (mux_state & USB_PD_MUX_DP_ENABLED)
+ ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1);
+ else
+ ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0);
+
+ return 0;
+}
+
+static void setup_mux(void)
+{
+ uint32_t val;
+
+ if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0)
+ CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG");
+ /* Val will have our dts default on error, so continue setup */
+
+ if (val == FW_IO_DB_PS8811_PS8818) {
+ CPRINTSUSB("C1: Setting PS8818 mux");
+ USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1);
+ } else if (val == FW_IO_DB_NONE_ANX7483) {
+ CPRINTSUSB("C1: Setting ANX7483 mux");
+ } else {
+ CPRINTSUSB("Unexpected DB_IO board: %d", val);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C);
diff --git a/zephyr/projects/skyrim/src/common.c b/zephyr/program/skyrim/src/common.c
index af82139c1b..af82139c1b 100644
--- a/zephyr/projects/skyrim/src/common.c
+++ b/zephyr/program/skyrim/src/common.c
diff --git a/zephyr/program/skyrim/src/power_signals.c b/zephyr/program/skyrim/src/power_signals.c
new file mode 100644
index 0000000000..04ed3d441d
--- /dev/null
+++ b/zephyr/program/skyrim/src/power_signals.c
@@ -0,0 +1,245 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ap_power/ap_power.h"
+#include "charger.h"
+#include "chipset.h"
+#include "config.h"
+#include "gpio/gpio_int.h"
+#include "gpio_signal.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "ioexpander.h"
+#include "power.h"
+#include "power/amd_x86.h"
+#include "timer.h"
+
+/* Power Signal Input List */
+/* TODO: b/218904113: Convert to using Zephyr GPIOs */
+const struct power_signal_info power_signal_list[] = {
+ [X86_SLP_S3_N] = {
+ .gpio = GPIO_PCH_SLP_S3_L,
+ .flags = POWER_SIGNAL_ACTIVE_HIGH,
+ .name = "SLP_S3_DEASSERTED",
+ },
+ [X86_SLP_S5_N] = {
+ .gpio = GPIO_PCH_SLP_S5_L,
+ .flags = POWER_SIGNAL_ACTIVE_HIGH,
+ .name = "SLP_S5_DEASSERTED",
+ },
+ [X86_S0_PGOOD] = {
+ .gpio = GPIO_S0_PGOOD,
+ .flags = POWER_SIGNAL_ACTIVE_HIGH,
+ .name = "S0_PGOOD",
+ },
+ [X86_S5_PGOOD] = {
+ .gpio = GPIO_S5_PGOOD,
+ .flags = POWER_SIGNAL_ACTIVE_HIGH,
+ .name = "S5_PGOOD",
+ },
+};
+BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
+
+/* Chipset hooks */
+static void baseboard_suspend_change(struct ap_power_ev_callback *cb,
+ struct ap_power_ev_data data)
+{
+ switch (data.event) {
+ default:
+ return;
+
+ case AP_POWER_SUSPEND:
+ /* Disable display backlight and retimer */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_disable_disp_bl),
+ 1);
+ ioex_set_level(IOEX_USB_A1_RETIMER_EN, 0);
+ break;
+
+ case AP_POWER_RESUME:
+ /* Enable retimer and display backlight */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_disable_disp_bl),
+ 0);
+ ioex_set_level(IOEX_USB_A1_RETIMER_EN, 1);
+ /* Any retimer tuning can be done after the retimer turns on */
+ break;
+ }
+}
+
+static void baseboard_init(void)
+{
+ static struct ap_power_ev_callback cb;
+
+ /* Setup a suspend/resume callback */
+ ap_power_ev_init_callback(&cb, baseboard_suspend_change,
+ AP_POWER_RESUME | AP_POWER_SUSPEND);
+ ap_power_ev_add_callback(&cb);
+ /* Enable Power Group interrupts. */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_pg_groupc_s0));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_pg_lpddr_s0));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_pg_lpddr_s3));
+
+ /* Enable thermtrip interrupt */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_soc_thermtrip));
+}
+DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_POST_I2C);
+
+/**
+ * b/227296844: On G3->S5, wait for RSMRST_L to be deasserted before asserting
+ * PCH_PWRBTN_L. This can be as long as ~65ms after cold boot. Then wait an
+ * additional delay of T1a defined in the EDS before changing the power button.
+ */
+#define RSMRST_WAIT_DELAY 70
+#define EDS_PWR_BTN_RSMRST_T1A_DELAY 16
+void board_pwrbtn_to_pch(int level)
+{
+ timestamp_t start;
+
+ /* Add delay for G3 exit if asserting PWRBTN_L and RSMRST_L is low. */
+ if (!level &&
+ !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_soc_rsmrst_l))) {
+ start = get_time();
+ do {
+ usleep(500);
+ if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(
+ gpio_ec_soc_rsmrst_l)))
+ break;
+ } while (time_since32(start) < (RSMRST_WAIT_DELAY * MSEC));
+
+ if (!gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_ec_soc_rsmrst_l)))
+ ccprints("Error pwrbtn: RSMRST_L still low");
+
+ msleep(EDS_PWR_BTN_RSMRST_T1A_DELAY);
+ }
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_soc_pwr_btn_l), level);
+}
+
+/* Note: signal parameter unused */
+void baseboard_set_soc_pwr_pgood(enum gpio_signal unused)
+{
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_ec_soc_pwr_good),
+ gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_en_pwr_pcore_s0_r)) &&
+ gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_pg_lpddr5_s0_od)) &&
+ gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_s0_pgood)));
+}
+
+/* TODO(b/248284045): Remove when boards switch to new chip */
+#define MP2845A_I2C_ADDR_FLAGS 0x20
+#define MP2854A_MFR_VOUT_CMPS_MAX_REG 0x69
+#define MP2854A_MFR_LOW_PWR_SEL BIT(12)
+
+__overridable bool board_supports_pcore_ocp(void)
+{
+ return true;
+}
+
+static void setup_mp2845(void)
+{
+ if (i2c_update16(chg_chips[CHARGER_SOLO].i2c_port,
+ MP2845A_I2C_ADDR_FLAGS, MP2854A_MFR_VOUT_CMPS_MAX_REG,
+ MP2854A_MFR_LOW_PWR_SEL, MASK_CLR))
+ ccprints("Failed to send mp2845 workaround");
+
+ if (board_supports_pcore_ocp())
+ gpio_enable_dt_interrupt(
+ GPIO_INT_FROM_NODELABEL(int_soc_pcore_ocp));
+}
+DECLARE_DEFERRED(setup_mp2845);
+
+void baseboard_s0_pgood(enum gpio_signal signal)
+{
+ baseboard_set_soc_pwr_pgood(signal);
+
+ /* Chain off power signal interrupt handler for PG_PCORE_S0_R_OD */
+ power_signal_interrupt(signal);
+
+ /* Set up the MP2845, which is powered in S0 */
+ if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_s0_pgood)))
+ hook_call_deferred(&setup_mp2845_data, 50 * MSEC);
+ else
+ gpio_disable_dt_interrupt(
+ GPIO_INT_FROM_NODELABEL(int_soc_pcore_ocp));
+}
+
+/* Note: signal parameter unused */
+void baseboard_set_en_pwr_pcore(enum gpio_signal unused)
+{
+ /*
+ * EC must AND signals PG_LPDDR5_S3_OD, PG_GROUPC_S0_OD, and
+ * EN_PWR_S0_R
+ */
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_en_pwr_pcore_s0_r),
+ gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_pg_lpddr5_s3_od)) &&
+ gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_pg_groupc_s0_od)) &&
+ gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_en_pwr_s0_r)));
+
+ /* Update EC_SOC_PWR_GOOD based on our results */
+ baseboard_set_soc_pwr_pgood(unused);
+}
+
+void baseboard_en_pwr_s0(enum gpio_signal signal)
+{
+ /* EC must AND signals SLP_S3_L and PG_PWR_S5 */
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_en_pwr_s0_r),
+ gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s3_l)) &&
+ gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5)));
+
+ /* Change EN_PWR_PCORE_S0_R if needed*/
+ baseboard_set_en_pwr_pcore(signal);
+
+ /* Now chain off to the normal power signal interrupt handler. */
+ power_signal_interrupt(signal);
+}
+#ifdef CONFIG_BOARD_USB_HUB_RESET
+void baseboard_enable_hub(void)
+{
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_hub_rst), 0);
+}
+DECLARE_DEFERRED(baseboard_enable_hub);
+#endif /* CONFIG_BOARD_USB_HUB_RESET */
+
+void baseboard_s5_pgood(enum gpio_signal signal)
+{
+#ifdef CONFIG_BOARD_USB_HUB_RESET
+ /* We must enable the USB hub at least 30ms after S5 PGOOD */
+ if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5)))
+ hook_call_deferred(&baseboard_enable_hub_data, 30 * MSEC);
+ else
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_hub_rst), 1);
+#endif /* CONFIG_BOARD_USB_HUB_RESET */
+
+ /* Continue to our signal AND-ing and power interrupt */
+ baseboard_en_pwr_s0(signal);
+}
+
+void baseboard_set_en_pwr_s3(enum gpio_signal signal)
+{
+ /* EC must enable PWR_S3 when SLP_S5_L goes high, disable on low */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pwr_s3),
+ gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s5_l)));
+
+ /* Chain off the normal power signal interrupt handler */
+ power_signal_interrupt(signal);
+}
+
+void baseboard_soc_thermtrip(enum gpio_signal signal)
+{
+ ccprints("SoC thermtrip reported, shutting down");
+ chipset_force_shutdown(CHIPSET_SHUTDOWN_THERMAL);
+}
+
+void baseboard_soc_pcore_ocp(enum gpio_signal signal)
+{
+ ccprints("SoC Pcore OCP reported, shutting down");
+ chipset_force_shutdown(CHIPSET_SHUTDOWN_BOARD_CUSTOM);
+}
diff --git a/zephyr/projects/skyrim/src/stt.c b/zephyr/program/skyrim/src/stt.c
index 40743fbc68..40743fbc68 100644
--- a/zephyr/projects/skyrim/src/stt.c
+++ b/zephyr/program/skyrim/src/stt.c
diff --git a/zephyr/program/skyrim/src/usb_pd_policy.c b/zephyr/program/skyrim/src/usb_pd_policy.c
new file mode 100644
index 0000000000..745d95bc00
--- /dev/null
+++ b/zephyr/program/skyrim/src/usb_pd_policy.c
@@ -0,0 +1,93 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Shared USB-C policy for Zork boards */
+
+#include "charge_manager.h"
+#include "chipset.h"
+#include "common.h"
+#include "compile_time_macros.h"
+#include "console.h"
+#include "ec_commands.h"
+#include "ioexpander.h"
+#include "system.h"
+#include "usb_mux.h"
+#include "usb_pd.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+#include <zephyr/drivers/gpio.h>
+
+int pd_check_vconn_swap(int port)
+{
+ /*
+ * Do not allow vconn swap 5V rail is off
+ * S5_PGOOD depends on PG_PP5000_S5 being asserted,
+ * so GPIO_S5_PGOOD is a reasonable proxy for PP5000_S5
+ */
+ return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5));
+}
+
+void pd_power_supply_reset(int port)
+{
+ /* Disable VBUS. */
+ ppc_vbus_source_enable(port, 0);
+
+ /* Enable discharge if we were previously sourcing 5V */
+ if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE))
+ pd_set_vbus_discharge(port, 1);
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ int rv;
+
+ /* Disable charging. */
+ rv = ppc_vbus_sink_enable(port, 0);
+ if (rv)
+ return rv;
+
+ if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE))
+ pd_set_vbus_discharge(port, 0);
+
+ /* Provide Vbus. */
+ rv = ppc_vbus_source_enable(port, 1);
+ if (rv)
+ return rv;
+
+ /* Notify host of power info change. */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS;
+}
+
+__override int board_pd_set_frs_enable(int port, int enable)
+{
+ /*
+ * Both PPCs require the FRS GPIO to be set as soon as FRS capability
+ * is established.
+ */
+ if (port == 0)
+ ioex_set_level(IOEX_USB_C0_TCPC_FASTSW_CTL_EN, enable);
+ else
+ ioex_set_level(IOEX_USB_C1_TCPC_FASTSW_CTL_EN, enable);
+
+ return EC_SUCCESS;
+}
+
+/* Used by Vbus discharge common code with CONFIG_USB_PD_DISCHARGE */
+int board_vbus_source_enabled(int port)
+{
+ return tcpm_get_src_ctrl(port);
+}
+
+/* Used by USB charger task with CONFIG_USB_PD_5V_EN_CUSTOM */
+int board_is_sourcing_vbus(int port)
+{
+ return board_vbus_source_enabled(port);
+}
diff --git a/zephyr/program/skyrim/src/usbc_config.c b/zephyr/program/skyrim/src/usbc_config.c
new file mode 100644
index 0000000000..47d0ac6a29
--- /dev/null
+++ b/zephyr/program/skyrim/src/usbc_config.c
@@ -0,0 +1,394 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Skyrim family-specific USB-C configuration */
+
+#include "battery_fuel_gauge.h"
+#include "charge_manager.h"
+#include "charge_ramp.h"
+#include "charge_state.h"
+#include "charge_state_v2.h"
+#include "charger.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "driver/bc12/pi3usb9201.h"
+#include "driver/charger/isl9241.h"
+#include "driver/ppc/nx20p348x.h"
+#include "driver/retimer/anx7483_public.h"
+#include "driver/retimer/ps8811.h"
+#include "driver/retimer/ps8818_public.h"
+#include "driver/tcpm/nct38xx.h"
+#include "driver/usb_mux/amd_fp6.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "ioexpander.h"
+#include "power.h"
+#include "usb_mux.h"
+#include "usb_pd_tcpm.h"
+#include "usbc/usb_muxes.h"
+#include "usbc_ppc.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/* USB-A ports */
+enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_A1, USBA_PORT_COUNT };
+
+/* USB-C ports */
+enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
+BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT);
+
+static void reset_nct38xx_port(int port);
+
+static void usbc_interrupt_init(void)
+{
+ /* Enable PPC interrupts. */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc));
+
+ /* Enable TCPC interrupts. */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc));
+
+ /* Enable BC 1.2 interrupts */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_bc12));
+
+ /* Enable SBU fault interrupts */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_sbu_fault));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_sbu_fault));
+}
+DECLARE_HOOK(HOOK_INIT, usbc_interrupt_init, HOOK_PRIO_POST_I2C);
+
+static void usb_fault_interrupt_init(void)
+{
+ /* Enable USB fault interrupts when we hit S5 */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_hub_fault));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_fault));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a1_fault));
+}
+DECLARE_HOOK(HOOK_CHIPSET_STARTUP, usb_fault_interrupt_init, HOOK_PRIO_DEFAULT);
+
+static void usb_fault_interrupt_disable(void)
+{
+ /* Disable USB fault interrupts leaving S5 */
+ gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_hub_fault));
+ gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_fault));
+ gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a1_fault));
+}
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, usb_fault_interrupt_disable,
+ HOOK_PRIO_DEFAULT);
+
+int board_set_active_charge_port(int port)
+{
+ int is_valid_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
+ int i;
+ int rv;
+
+ if (port == CHARGE_PORT_NONE) {
+ CPRINTSUSB("Disabling all charger ports");
+
+ /* Disable all ports. */
+ for (i = 0; i < ppc_cnt; i++) {
+ /*
+ * If this port had booted in dead battery mode, go
+ * ahead and reset it so EN_SNK responds properly.
+ */
+ if (nct38xx_get_boot_type(i) ==
+ NCT38XX_BOOT_DEAD_BATTERY) {
+ reset_nct38xx_port(i);
+ pd_set_error_recovery(i);
+ }
+
+ /*
+ * Do not return early if one fails otherwise we can
+ * get into a boot loop assertion failure.
+ */
+ if (ppc_vbus_sink_enable(i, 0))
+ CPRINTSUSB("Disabling C%d as sink failed.", i);
+ }
+
+ return EC_SUCCESS;
+ } else if (!is_valid_port) {
+ return EC_ERROR_INVAL;
+ }
+
+ /*
+ * Check if we can reset any ports in dead battery mode
+ *
+ * The NCT3807 may continue to keep EN_SNK low on the dead battery port
+ * and allow a dangerous level of voltage to pass through to the initial
+ * charge port (see b/183660105). We must reset the ports if we have
+ * sufficient battery to do so, which will bring EN_SNK back under
+ * normal control.
+ */
+ rv = EC_SUCCESS;
+ for (i = 0; i < board_get_usb_pd_port_count(); i++) {
+ if (nct38xx_get_boot_type(i) == NCT38XX_BOOT_DEAD_BATTERY) {
+ CPRINTSUSB("Found dead battery on %d", i);
+ /*
+ * If we have battery, get this port reset ASAP.
+ * This means temporarily rejecting charge manager
+ * sets to it.
+ */
+ if (pd_is_battery_capable()) {
+ reset_nct38xx_port(i);
+ pd_set_error_recovery(i);
+
+ if (port == i)
+ rv = EC_ERROR_INVAL;
+ } else if (port != i) {
+ /*
+ * If other port is selected and in dead battery
+ * mode, reset this port. Otherwise, reject
+ * change because we'll brown out.
+ */
+ if (nct38xx_get_boot_type(port) ==
+ NCT38XX_BOOT_DEAD_BATTERY) {
+ reset_nct38xx_port(i);
+ pd_set_error_recovery(i);
+ } else {
+ rv = EC_ERROR_INVAL;
+ }
+ }
+ }
+ }
+
+ if (rv != EC_SUCCESS)
+ return rv;
+
+ /* Check if the port is sourcing VBUS. */
+ if (tcpm_get_src_ctrl(port)) {
+ CPRINTSUSB("Skip enable C%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+ CPRINTSUSB("New charge port: C%d", port);
+
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < ppc_cnt; i++) {
+ if (i == port)
+ continue;
+
+ if (ppc_vbus_sink_enable(i, 0))
+ CPRINTSUSB("C%d: sink path disable failed.", i);
+ }
+
+ /* Enable requested charge port. */
+ if (ppc_vbus_sink_enable(port, 1)) {
+ CPRINTSUSB("C%d: sink path enable failed.", port);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ return EC_SUCCESS;
+}
+
+void sbu_fault_interrupt(enum gpio_signal signal)
+{
+ int port = signal == IOEX_USB_C1_FAULT_ODL ? 1 : 0;
+
+ CPRINTSUSB("C%d: SBU fault", port);
+ pd_handle_overcurrent(port);
+}
+
+void usb_fault_interrupt(enum gpio_signal signal)
+{
+ int out;
+
+ CPRINTSUSB("USB fault(%d), alerting the SoC", signal);
+ out = gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_usb_hub_fault_q_odl)) &&
+ gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_a0_fault_odl)) &&
+ gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_a1_fault_db_odl));
+
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_fault_odl), out);
+}
+
+void usb_pd_soc_interrupt(enum gpio_signal signal)
+{
+ /*
+ * This interrupt is unexpected with our use of the SoC mux, so just log
+ * it as a point of interest.
+ */
+ CPRINTSUSB("SOC PD Interrupt");
+}
+
+#ifdef CONFIG_CHARGER_ISL9241
+/* Round up 3250 max current to multiple of 128mA for ISL9241 AC prochot. */
+#define SKYRIM_AC_PROCHOT_CURRENT_MA 3328
+static void set_ac_prochot(void)
+{
+ isl9241_set_ac_prochot(CHARGER_SOLO, SKYRIM_AC_PROCHOT_CURRENT_MA);
+}
+DECLARE_HOOK(HOOK_INIT, set_ac_prochot, HOOK_PRIO_DEFAULT);
+#endif /* CONFIG_CHARGER_ISL9241 */
+
+void tcpc_alert_event(enum gpio_signal signal)
+{
+ int port;
+
+ switch (signal) {
+ case GPIO_USB_C0_TCPC_INT_ODL:
+ port = 0;
+ break;
+ case GPIO_USB_C1_TCPC_INT_ODL:
+ port = 1;
+ break;
+ default:
+ return;
+ }
+
+ schedule_deferred_pd_interrupt(port);
+}
+
+static void reset_nct38xx_port(int port)
+{
+ const struct gpio_dt_spec *reset_gpio_l;
+ const struct device *ioex_port0, *ioex_port1;
+
+ /* TODO(b/225189538): Save and restore ioex signals */
+ if (port == USBC_PORT_C0) {
+ reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_l);
+ ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port0));
+ ioex_port1 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port1));
+ } else if (port == USBC_PORT_C1) {
+ reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_rst_l);
+ ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c1_port0));
+ ioex_port1 = DEVICE_DT_GET(DT_NODELABEL(ioex_c1_port1));
+ } else {
+ /* Invalid port: do nothing */
+ return;
+ }
+
+ gpio_pin_set_dt(reset_gpio_l, 0);
+ msleep(NCT38XX_RESET_HOLD_DELAY_MS);
+ gpio_pin_set_dt(reset_gpio_l, 1);
+ nct38xx_reset_notify(port);
+ if (NCT3807_RESET_POST_DELAY_MS != 0)
+ msleep(NCT3807_RESET_POST_DELAY_MS);
+
+ /* Re-enable the IO expander pins */
+ gpio_reset_port(ioex_port0);
+ gpio_reset_port(ioex_port1);
+}
+
+void board_reset_pd_mcu(void)
+{
+ /* Reset TCPC0 */
+ reset_nct38xx_port(USBC_PORT_C0);
+
+ /* Reset TCPC1 */
+ reset_nct38xx_port(USBC_PORT_C1);
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ uint16_t status = 0;
+
+ /*
+ * Check which port has the ALERT line set and ignore if that TCPC has
+ * its reset line active.
+ */
+ if (!gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl))) {
+ if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(
+ gpio_usb_c0_tcpc_rst_l)) != 0)
+ status |= PD_STATUS_TCPC_ALERT_0;
+ }
+
+ if (!gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl))) {
+ if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(
+ gpio_usb_c1_tcpc_rst_l)) != 0)
+ status |= PD_STATUS_TCPC_ALERT_1;
+ }
+
+ return status;
+}
+
+void bc12_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_BC12_INT_ODL:
+ usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
+ break;
+
+ case GPIO_USB_C1_BC12_INT_ODL:
+ usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
+ break;
+
+ default:
+ break;
+ }
+}
+
+/**
+ * Return if VBUS is sagging too low
+ *
+ * For legacy BC1.2 charging with CONFIG_CHARGE_RAMP_SW, ramp up input current
+ * until voltage drops to 4.5V. Don't go lower than this to be kind to the
+ * charger (see b/67964166).
+ */
+#define BC12_MIN_VOLTAGE 4500
+int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state)
+{
+ int voltage = 0;
+ int rv;
+
+ rv = charger_get_vbus_voltage(port, &voltage);
+
+ if (rv) {
+ CPRINTSUSB("%s rv=%d", __func__, rv);
+ return 0;
+ }
+
+ /*
+ * b/168569046: The ISL9241 sometimes incorrectly reports 0 for unknown
+ * reason, causing ramp to stop at 0.5A. Workaround this by ignoring 0.
+ * This partly defeats the point of ramping, but will still catch
+ * VBUS below 4.5V and above 0V.
+ */
+ if (voltage == 0) {
+ CPRINTSUSB("%s vbus=0", __func__);
+ return 0;
+ }
+
+ if (voltage < BC12_MIN_VOLTAGE)
+ CPRINTSUSB("%s vbus=%d", __func__, voltage);
+
+ return voltage < BC12_MIN_VOLTAGE;
+}
+
+#define SAFE_RESET_VBUS_DELAY_MS 900
+#define SAFE_RESET_VBUS_MV 5000
+void board_hibernate(void)
+{
+ int port;
+ enum ec_error_list ret;
+
+ /*
+ * If we are charging, then drop the Vbus level down to 5V to ensure
+ * that we don't get locked out of the 6.8V OVLO for our PPCs in
+ * dead-battery mode. This is needed when the TCPC/PPC rails go away.
+ * (b/79218851, b/143778351, b/147007265)
+ */
+ port = charge_manager_get_active_charge_port();
+ if (port != CHARGE_PORT_NONE) {
+ pd_request_source_voltage(port, SAFE_RESET_VBUS_MV);
+
+ /* Give PD task and PPC chip time to get to 5V */
+ msleep(SAFE_RESET_VBUS_DELAY_MS);
+ }
+
+ /* Try to put our battery fuel gauge into sleep mode */
+ ret = battery_sleep_fuel_gauge();
+ if ((ret != EC_SUCCESS) && (ret != EC_ERROR_UNIMPLEMENTED))
+ cprints(CC_SYSTEM, "Failed to send battery sleep command");
+}
diff --git a/zephyr/projects/skyrim/usbc.dts b/zephyr/program/skyrim/usbc.dtsi
index 8486927e8d..8486927e8d 100644
--- a/zephyr/projects/skyrim/usbc.dts
+++ b/zephyr/program/skyrim/usbc.dtsi
diff --git a/zephyr/program/skyrim/winterhold/CMakeLists.txt b/zephyr/program/skyrim/winterhold/CMakeLists.txt
new file mode 100644
index 0000000000..ebd01a87e6
--- /dev/null
+++ b/zephyr/program/skyrim/winterhold/CMakeLists.txt
@@ -0,0 +1,12 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+zephyr_library_sources(
+ "src/usb_mux_config.c"
+ "src/ppc_config.c"
+ "src/kb_backlight.c"
+ "src/keyboard.c"
+ "src/sensor.c"
+ "src/battery_present.c"
+)
diff --git a/zephyr/program/skyrim/winterhold/battery.dtsi b/zephyr/program/skyrim/winterhold/battery.dtsi
new file mode 100644
index 0000000000..8e82e0d1f2
--- /dev/null
+++ b/zephyr/program/skyrim/winterhold/battery.dtsi
@@ -0,0 +1,33 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ batteries {
+ default_battery: lgc_xphx8 {
+ compatible = "lgc,xphx8", "battery-smart";
+ };
+ smp_atlxdy9k {
+ compatible = "smp,atlxdy9k", "battery-smart";
+ };
+ smp_cosxdy9k {
+ compatible = "smp,cosxdy9k", "battery-smart";
+ };
+ byd_wv3k8 {
+ compatible = "byd,wv3k8", "battery-smart";
+ };
+ cosmx_mvk11 {
+ compatible = "cosmx,mvk11", "battery-smart";
+ };
+ sunwoda_atlvkyjx {
+ compatible = "sunwoda,atlvkyjx", "battery-smart";
+ };
+ sunwoda_cosvkyjx {
+ compatible = "sunwoda,cosvkyjx", "battery-smart";
+ };
+ atl_cfd72 {
+ compatible = "atl,cfd72", "battery-smart";
+ };
+ };
+};
diff --git a/zephyr/program/skyrim/winterhold/led_pins.dtsi b/zephyr/program/skyrim/winterhold/led_pins.dtsi
new file mode 100644
index 0000000000..78b9a59c40
--- /dev/null
+++ b/zephyr/program/skyrim/winterhold/led_pins.dtsi
@@ -0,0 +1,59 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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_y: pwm_y {
+ pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ pwm_w: pwm_w {
+ pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
+ };
+ };
+
+ pwm-led-pins {
+ compatible = "cros-ec,pwm-led-pins";
+
+ color_off: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <0 0>;
+ };
+
+ color_amber: color-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <100 0>;
+ };
+
+ color_white: color-white {
+ led-color = "LED_WHITE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_WHITE";
+ led-pwms = <&pwm_y &pwm_w>;
+ led-values = <0 100>;
+ };
+ };
+};
+
+/* Amber "battery charging" LED */
+&pwm2 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
+
+/* White "battery full" LED */
+&pwm3 {
+ status = "okay";
+ clock-bus = "NPCX_CLOCK_BUS_LFCLK";
+ pinctrl-0 = <&pwm3_gp80>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/skyrim/led_policy_winterhold.dts b/zephyr/program/skyrim/winterhold/led_policy.dtsi
index f1f8aa31ed..f1f8aa31ed 100644
--- a/zephyr/projects/skyrim/led_policy_winterhold.dts
+++ b/zephyr/program/skyrim/winterhold/led_policy.dtsi
diff --git a/zephyr/program/skyrim/winterhold/motionsense.dtsi b/zephyr/program/skyrim/winterhold/motionsense.dtsi
new file mode 100644
index 0000000000..60d345c0a2
--- /dev/null
+++ b/zephyr/program/skyrim/winterhold/motionsense.dtsi
@@ -0,0 +1,124 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/motionsense/utils.h>
+
+
+/ {
+ aliases {
+ /*
+ * motion sense's <>_INT_EVENT is handled
+ * by alias. Using the alias, each driver creates
+ * its own <>_INT_EVENT.
+ */
+ bmi3xx-int = &base_accel;
+ lis2dw12-int = &base_accel;
+
+ /* Use base accelerometer for on-body sensor */
+ on-body-sensor = &base_accel;
+ };
+
+ /*
+ * Declare mutexes used by sensor drivers.
+ * A mutex node is used to create an instance of mutex_t.
+ * A mutex node is referenced by a sensor node if the
+ * corresponding sensor driver needs to use the
+ * instance of the mutex.
+ */
+ motionsense-mutex {
+ mutex_bmi3xx: bmi3xx-mutex {
+ };
+ mutex_lis2dw12: lis2dw12-mutex {
+ };
+ };
+
+ /*
+ * Driver specific data. A driver-specific data can be shared with
+ * different motion sensors while they are using the same driver.
+ *
+ * If a node's compatible starts with "cros-ec,accelgyro-", it is for
+ * a common structure defined in accelgyro.h.
+ * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
+ * "struct als_drv_data_t" in accelgyro.h
+ */
+ motionsense-sensor-data {
+ bmi3xx_data: bmi3xx-drv-data {
+ compatible = "cros-ec,drvdata-bmi3xx";
+ status = "okay";
+ };
+ lis2dw12_data: lis2dw12-drv-data {
+ compatible = "cros-ec,drvdata-lis2dw12";
+ status = "okay";
+ };
+ };
+
+ /*
+ * List of motion sensors that creates motion_sensors array.
+ * The nodelabel "lid_accel" and "base_accel" are used to indicate
+ * motion sensor IDs for lid angle calculation.
+ */
+ motionsense-sensor {
+ base_accel: base-accel {
+ compatible = "cros-ec,lis2dw12";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&mutex_lis2dw12>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ default-range = <2>;
+ drv-data = <&lis2dw12_data>;
+ i2c-spi-addr-flags = "LIS2DWL_ADDR1_FLAGS";
+
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ ec-s3 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+ };
+
+ motionsense-sensor-alt {
+ alt_base_accel: alt-base-accel {
+ compatible = "cros-ec,bmi3xx-accel";
+ status = "okay";
+
+ active-mask = "SENSOR_ACTIVE_S0_S3";
+ location = "MOTIONSENSE_LOC_BASE";
+ mutex = <&mutex_bmi3xx>;
+ port = <&i2c_sensor>;
+ rot-standard-ref = <&base_rot_ref>;
+ drv-data = <&bmi3xx_data>;
+ alternate-for = <&base_accel>;
+ configs {
+ compatible =
+ "cros-ec,motionsense-sensor-config";
+ ec-s0 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ ec-rate = <100>;
+ };
+ ec-s3 {
+ odr = <(12500 | ROUND_UP_FLAG)>;
+ };
+ };
+ };
+ };
+
+ motionsense-sensor-info {
+ compatible = "cros-ec,motionsense-sensor-info";
+
+ /*
+ * list of GPIO interrupts that have to
+ * be enabled at initial stage
+ */
+ sensor-irqs = <&int_accel_gyro>;
+ };
+};
diff --git a/zephyr/program/skyrim/winterhold/project.conf b/zephyr/program/skyrim/winterhold/project.conf
new file mode 100644
index 0000000000..84be72ec0e
--- /dev/null
+++ b/zephyr/program/skyrim/winterhold/project.conf
@@ -0,0 +1,47 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Winterhold reference-board-specific Kconfig settings.
+CONFIG_BOARD_WINTERHOLD=y
+
+# TODO(b/215404321): Remove later in board development
+CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
+CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_DT=y
+
+CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y
+
+# Enable charger chip
+CONFIG_PLATFORM_EC_CHARGER_ISL9238=y
+CONFIG_PLATFORM_EC_CHARGER_ISL9241=n
+
+# Get the vbus voltage from TCPC
+CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=n
+CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y
+
+# Remove unused sensor
+CONFIG_PLATFORM_EC_ACCEL_BMA4XX=n
+
+# Support LIS2DW12 sensor
+CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
+
+# Disable lid configuration
+CONFIG_PLATFORM_EC_LID_ANGLE=n
+CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n
+
+# Disable tablet mode configuration
+CONFIG_PLATFORM_EC_TABLET_MODE=n
+CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n
+CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM=y
+
+# Body detection configuration
+CONFIG_PLATFORM_EC_BODY_DETECTION=y
+CONFIG_PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0=y
+CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE=y
+CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTION=y
diff --git a/zephyr/program/skyrim/winterhold/project.overlay b/zephyr/program/skyrim/winterhold/project.overlay
new file mode 100644
index 0000000000..9a13a1a3cd
--- /dev/null
+++ b/zephyr/program/skyrim/winterhold/project.overlay
@@ -0,0 +1,19 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Skyrim program common DTS includes */
+#include "../adc.dtsi"
+#include "../fan.dtsi"
+#include "../gpio.dtsi"
+#include "../interrupts.dtsi"
+#include "../keyboard.dtsi"
+#include "../usbc.dtsi"
+
+/* winterhold project DTS includes*/
+#include "winterhold.dtsi"
+#include "battery.dtsi"
+#include "led_pins.dtsi"
+#include "led_policy.dtsi"
+#include "motionsense.dtsi"
diff --git a/zephyr/program/skyrim/winterhold/src/battery_present.c b/zephyr/program/skyrim/winterhold/src/battery_present.c
new file mode 100644
index 0000000000..290955a242
--- /dev/null
+++ b/zephyr/program/skyrim/winterhold/src/battery_present.c
@@ -0,0 +1,81 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#include "battery.h"
+#include "battery_smart.h"
+#include "common.h"
+
+#include <zephyr/drivers/gpio.h>
+
+static enum battery_present batt_pres_prev = BP_NOT_SURE;
+
+__overridable bool board_battery_is_initialized(void)
+{
+ int batt_status;
+
+ return battery_status(&batt_status) != EC_SUCCESS ?
+ false :
+ !!(batt_status & STATUS_INITIALIZED);
+}
+
+/*
+ * Physical detection of battery.
+ */
+static enum battery_present battery_check_present_status(void)
+{
+ enum battery_present batt_pres;
+
+ if (battery_is_cut_off())
+ return BP_NO;
+
+ /* Get the physical hardware status */
+ batt_pres = battery_hw_present();
+
+ /*
+ * If the battery is not physically connected, then no need to perform
+ * any more checks.
+ */
+ if (batt_pres == BP_NO)
+ return BP_NO;
+
+ /*
+ * If the battery is present now and was present last time we checked,
+ * return early.
+ */
+ if ((batt_pres == BP_YES) && (batt_pres == batt_pres_prev))
+ return BP_YES;
+
+ /*
+ * Check battery initialization. If the battery is not initialized,
+ * then return BP_NOT_SURE. Battery could be in ship
+ * mode and might require pre-charge current to wake it up. BP_NO is not
+ * returned here because charger state machine will not provide
+ * pre-charge current assuming that battery is not present.
+ */
+ if (!board_battery_is_initialized())
+ return BP_NOT_SURE;
+
+ return BP_YES;
+}
+
+enum battery_present battery_is_present(void)
+{
+ batt_pres_prev = battery_check_present_status();
+ return batt_pres_prev;
+}
+
+enum battery_present battery_hw_present(void)
+{
+ const struct gpio_dt_spec *batt_pres;
+
+ batt_pres = GPIO_DT_FROM_NODELABEL(gpio_ec_batt_pres_odl);
+
+ /*
+ * The GPIO is low when the battery is physically present.
+ * But if battery cell voltage < 2.5V, it will not able to
+ * pull down EC_BATT_PRES_ODL. So we need to set pre-charge
+ * current even EC_BATT_PRES_ODL is high.
+ */
+ return gpio_pin_get_dt(batt_pres) ? BP_NOT_SURE : BP_YES;
+}
diff --git a/zephyr/program/skyrim/winterhold/src/kb_backlight.c b/zephyr/program/skyrim/winterhold/src/kb_backlight.c
new file mode 100644
index 0000000000..cbbfc0a4e9
--- /dev/null
+++ b/zephyr/program/skyrim/winterhold/src/kb_backlight.c
@@ -0,0 +1,34 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "board_config.h"
+#include "common.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/logging/log.h>
+
+LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL);
+
+__override uint32_t board_override_feature_flags0(uint32_t flags0)
+{
+ int ret;
+ uint32_t val;
+
+ /*
+ * Remove keyboard backlight feature for devices that don't support it.
+ */
+ ret = cros_cbi_get_fw_config(FW_KB_BL, &val);
+ if (ret != 0) {
+ LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_KB_BL);
+ return flags0;
+ }
+
+ if (val == FW_KB_BL_NOT_PRESENT)
+ return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB));
+ else
+ return flags0;
+}
diff --git a/zephyr/projects/skyrim/src/winterhold/keyboard.c b/zephyr/program/skyrim/winterhold/src/keyboard.c
index d3aebe0f2e..d3aebe0f2e 100644
--- a/zephyr/projects/skyrim/src/winterhold/keyboard.c
+++ b/zephyr/program/skyrim/winterhold/src/keyboard.c
diff --git a/zephyr/program/skyrim/winterhold/src/ppc_config.c b/zephyr/program/skyrim/winterhold/src/ppc_config.c
new file mode 100644
index 0000000000..d6adb145ff
--- /dev/null
+++ b/zephyr/program/skyrim/winterhold/src/ppc_config.c
@@ -0,0 +1,27 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Winterhold board-specific PPC code */
+
+#include "driver/ppc/nx20p348x.h"
+#include "usbc_ppc.h"
+
+#include <zephyr/drivers/gpio.h>
+
+void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_USB_C0_PPC_INT_ODL:
+ nx20p348x_interrupt(0);
+ break;
+
+ case GPIO_USB_C1_PPC_INT_ODL:
+ nx20p348x_interrupt(1);
+ break;
+
+ default:
+ break;
+ }
+}
diff --git a/zephyr/program/skyrim/winterhold/src/sensor.c b/zephyr/program/skyrim/winterhold/src/sensor.c
new file mode 100644
index 0000000000..52cd201705
--- /dev/null
+++ b/zephyr/program/skyrim/winterhold/src/sensor.c
@@ -0,0 +1,37 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "cros_board_info.h"
+#include "driver/accel_lis2dw12.h"
+#include "driver/accelgyro_bmi3xx.h"
+#include "hooks.h"
+#include "motionsense_sensors.h"
+
+void base_accel_interrupt(enum gpio_signal signal)
+{
+ int ret;
+ uint32_t val;
+
+ ret = cbi_get_board_version(&val);
+
+ if (ret == EC_SUCCESS && val < 1)
+ bmi3xx_interrupt(signal);
+ else
+ lis2dw12_interrupt(signal);
+}
+
+static void motionsense_init(void)
+{
+ int ret;
+ uint32_t val;
+
+ ret = cbi_get_board_version(&val);
+
+ if (ret == EC_SUCCESS && val < 1) {
+ MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel);
+ }
+}
+DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/program/skyrim/winterhold/src/usb_mux_config.c b/zephyr/program/skyrim/winterhold/src/usb_mux_config.c
new file mode 100644
index 0000000000..19153eb676
--- /dev/null
+++ b/zephyr/program/skyrim/winterhold/src/usb_mux_config.c
@@ -0,0 +1,146 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Winterhold board-specific USB-C mux configuration */
+
+#include "console.h"
+#include "cros_board_info.h"
+#include "cros_cbi.h"
+#include "driver/retimer/anx7483_public.h"
+#include "hooks.h"
+#include "ioexpander.h"
+#include "usb_mux.h"
+#include "usbc/usb_muxes.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+/*
+ * USB C0 (general) and C1 (just ANX DB) use IOEX pins to
+ * indicate flipped polarity to a protection switch.
+ */
+static int ioex_set_flip(int port, mux_state_t mux_state)
+{
+ if (port == 0) {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
+ 0);
+ } else {
+ if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 1);
+ else
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
+ 0);
+ }
+
+ return EC_SUCCESS;
+}
+
+int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
+ return anx7483_set_default_tuning(me, mux_state);
+}
+
+int board_anx7483_c1_fg_defalut_tuning(const struct usb_mux *me)
+{
+ RETURN_ERROR(
+ anx7483_set_fg(me, ANX7483_PIN_URX1, ANX7483_FG_SETTING_1_2DB));
+ RETURN_ERROR(
+ anx7483_set_fg(me, ANX7483_PIN_URX2, ANX7483_FG_SETTING_1_2DB));
+ RETURN_ERROR(
+ anx7483_set_fg(me, ANX7483_PIN_UTX1, ANX7483_FG_SETTING_1_2DB));
+ RETURN_ERROR(
+ anx7483_set_fg(me, ANX7483_PIN_UTX2, ANX7483_FG_SETTING_1_2DB));
+
+ return EC_SUCCESS;
+}
+
+int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state)
+{
+ bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED;
+
+ /* Set the SBU polarity mux */
+ RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
+
+ /* Remove flipped from the state for easier compraisons */
+ mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED;
+
+ RETURN_ERROR(anx7483_set_default_tuning(me, mux_state));
+
+ /*
+ * Set the Flat Gain to default every time, to prevent DP only mode's
+ * Flat Gain change in the last plug.
+ */
+ RETURN_ERROR(board_anx7483_c1_fg_defalut_tuning(me));
+
+ if (mux_state == USB_PD_MUX_USB_ENABLED) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ } else if (mux_state == USB_PD_MUX_DP_ENABLED) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_8_4DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_8_4DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
+ ANX7483_EQ_SETTING_8_4DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
+ ANX7483_EQ_SETTING_8_4DB));
+ RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX1,
+ ANX7483_FG_SETTING_0_5DB));
+ RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX2,
+ ANX7483_FG_SETTING_0_5DB));
+ RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX1,
+ ANX7483_FG_SETTING_0_5DB));
+ RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX2,
+ ANX7483_FG_SETTING_0_5DB));
+ } else if (mux_state == USB_PD_MUX_DOCK && !flipped) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_8_4DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
+ ANX7483_EQ_SETTING_8_4DB));
+ RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX2,
+ ANX7483_FG_SETTING_0_5DB));
+ RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX2,
+ ANX7483_FG_SETTING_0_5DB));
+ } else if (mux_state == USB_PD_MUX_DOCK && flipped) {
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
+ ANX7483_EQ_SETTING_8_4DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
+ ANX7483_EQ_SETTING_8_4DB));
+ RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
+ ANX7483_EQ_SETTING_12_5DB));
+ RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX1,
+ ANX7483_FG_SETTING_0_5DB));
+ RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX1,
+ ANX7483_FG_SETTING_0_5DB));
+ }
+
+ return EC_SUCCESS;
+}
diff --git a/zephyr/program/skyrim/winterhold/winterhold.dtsi b/zephyr/program/skyrim/winterhold/winterhold.dtsi
new file mode 100644
index 0000000000..a831cd9500
--- /dev/null
+++ b/zephyr/program/skyrim/winterhold/winterhold.dtsi
@@ -0,0 +1,168 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/usbc_mux.h>
+
+#include "../i2c.dtsi"
+
+/ {
+ named-gpios {
+ /* Winterhold-specific GPIO customizations */
+ };
+
+ named-temp-sensors {
+ compatible = "cros-ec,temp-sensors";
+ soc-pct2075 {
+ temp_host_high = <105>;
+ temp_host_halt = <110>;
+ temp_host_release_high = <95>;
+ temp_host_release_halt = <100>;
+ power-good-pin = <&gpio_pg_pwr_s5>;
+ sensor = <&soc_pct2075>;
+ };
+ amb-pct2075 {
+ temp_host_warn = <50>;
+ temp_host_high = <105>;
+ temp_host_halt = <110>;
+ temp_host_release_warn = <45>;
+ temp_host_release_high = <95>;
+ temp_host_release_halt = <100>;
+ temp_fan_off = <35>;
+ temp_fan_max = <40>;
+ power-good-pin = <&gpio_pg_pwr_s5>;
+ sensor = <&amb_pct2075>;
+ };
+ };
+
+ /*
+ * Note this is expected to vary per-board, so we keep it in the board
+ * dts files.
+ */
+ Winterhold-fw-config {
+ compatible = "cros-ec,cbi-fw-config";
+
+ /*
+ * FW_CONFIG field to enable KB back light or not.
+ */
+ kb-bl {
+ enum-name = "FW_KB_BL";
+ start = <1>;
+ size = <1>;
+
+ no-kb-bl {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_KB_BL_NOT_PRESENT";
+ value = <0>;
+ };
+ kb-bl-present {
+ compatible = "cros-ec,cbi-fw-config-value";
+ enum-name = "FW_KB_BL_PRESENT";
+ value = <1>;
+ };
+ };
+ };
+
+ /* Rotation matrices for motion sensors. */
+ motionsense-rotation-ref {
+ compatible = "cros-ec,motionsense-rotation-ref";
+ lid_rot_ref: lid-rotation-ref {
+ mat33 = <0 (-1) 0
+ 1 0 0
+ 0 0 1>;
+ };
+
+ base_rot_ref: base-rotation-ref {
+ mat33 = <0 1 0
+ (-1) 0 0
+ 0 0 1>;
+ };
+ };
+};
+
+&i2c0_0 {
+ anx7483_port0: anx7483@3e {
+ compatible = "analogix,anx7483";
+ reg = <0x3e>;
+ board-set = "board_anx7483_c0_mux_set";
+ flags = <USB_MUX_FLAG_RESETS_IN_G3>;
+ };
+ ppc_port0: nx20p348x@71 {
+ compatible = "nxp,nx20p348x";
+ status = "okay";
+ reg = <0x71>;
+ };
+};
+
+&i2c1_0 {
+ anx7483_port1: anx7483@3e {
+ compatible = "analogix,anx7483";
+ reg = <0x3e>;
+ board-set = "board_anx7483_c1_mux_set";
+ flags = <USB_MUX_FLAG_RESETS_IN_G3>;
+ };
+ ppc_port1: nx20p348x@71 {
+ compatible = "nxp,nx20p348x";
+ status = "okay";
+ reg = <0x71>;
+ };
+};
+
+&i2c4_1 {
+ charger: isl9238@9 {
+ compatible = "intersil,isl923x";
+ status = "okay";
+ reg = <0x9>;
+ };
+};
+
+&usbc_port0 {
+ ppc = <&ppc_port0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port0 &anx7483_port0>;
+ };
+};
+
+&usbc_port1 {
+ ppc = <&ppc_port1>;
+ usb-mux-chain-1-anx {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&amd_fp6_port1 &anx7483_port1>;
+ };
+};
+
+&fan0 {
+ pwms = <&pwm0 0 PWM_KHZ(2) PWM_POLARITY_NORMAL>;
+ rpm_min = <2100>;
+ rpm_start = <2600>;
+ rpm_max = <4800>;
+};
+
+&temp_sensor_charger {
+ temp_host_high = <100>;
+ temp_host_halt = <110>;
+ temp_host_release_high = <90>;
+ temp_host_release_halt = <100>;
+};
+
+&temp_sensor_memory {
+ temp_host_high = <91>;
+ temp_host_halt = <96>;
+ temp_host_release_high = <81>;
+ temp_host_release_halt = <86>;
+};
+
+&temp_sensor_cpu {
+ /delete-property/ temp_host_high;
+ /delete-property/ temp_host_halt;
+ /delete-property/ temp_host_release_high;
+ /delete-property/ temp_fan_off;
+ /delete-property/ temp_fan_max;
+};
+
+/* Override handler */
+&int_accel_gyro {
+ handler = "base_accel_interrupt";
+};
diff --git a/zephyr/projects/trogdor/lazor/BUILD.py b/zephyr/program/trogdor/lazor/BUILD.py
index ca1a26bdcf..ca1a26bdcf 100644
--- a/zephyr/projects/trogdor/lazor/BUILD.py
+++ b/zephyr/program/trogdor/lazor/BUILD.py
diff --git a/zephyr/projects/trogdor/lazor/CMakeLists.txt b/zephyr/program/trogdor/lazor/CMakeLists.txt
index b6d5024707..b6d5024707 100644
--- a/zephyr/projects/trogdor/lazor/CMakeLists.txt
+++ b/zephyr/program/trogdor/lazor/CMakeLists.txt
diff --git a/zephyr/projects/trogdor/lazor/adc.dts b/zephyr/program/trogdor/lazor/adc.dts
index b834001587..b834001587 100644
--- a/zephyr/projects/trogdor/lazor/adc.dts
+++ b/zephyr/program/trogdor/lazor/adc.dts
diff --git a/zephyr/projects/trogdor/lazor/battery.dts b/zephyr/program/trogdor/lazor/battery.dts
index 2b17dd4761..2b17dd4761 100644
--- a/zephyr/projects/trogdor/lazor/battery.dts
+++ b/zephyr/program/trogdor/lazor/battery.dts
diff --git a/zephyr/projects/trogdor/lazor/default_gpio_pinctrl.dts b/zephyr/program/trogdor/lazor/default_gpio_pinctrl.dts
index 1819bdbc3e..1819bdbc3e 100644
--- a/zephyr/projects/trogdor/lazor/default_gpio_pinctrl.dts
+++ b/zephyr/program/trogdor/lazor/default_gpio_pinctrl.dts
diff --git a/zephyr/projects/trogdor/lazor/display.dts b/zephyr/program/trogdor/lazor/display.dts
index 65d3a2d91b..65d3a2d91b 100644
--- a/zephyr/projects/trogdor/lazor/display.dts
+++ b/zephyr/program/trogdor/lazor/display.dts
diff --git a/zephyr/program/trogdor/lazor/gpio.dts b/zephyr/program/trogdor/lazor/gpio.dts
new file mode 100644
index 0000000000..d40a593949
--- /dev/null
+++ b/zephyr/program/trogdor/lazor/gpio.dts
@@ -0,0 +1,314 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/wake_mask_event_defines.h>
+
+/ {
+ aliases {
+ gpio-wp = &gpio_ec_wp_odl;
+ gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ };
+
+ named-gpios {
+ compatible = "named-gpios";
+
+ gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl {
+ gpios = <&gpioe 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_PD_INT_ODL";
+ };
+ gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl {
+ gpios = <&gpiof 5 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_PD_INT_ODL";
+ };
+ gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl {
+ gpios = <&gpio0 3 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
+ };
+ gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl {
+ gpios = <&gpio4 0 GPIO_INPUT>;
+ enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
+ };
+ gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
+ gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
+ gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_usb_a0_oc_odl: usb_a0_oc_odl {
+ gpios = <&gpiod 1 GPIO_INPUT_PULL_UP>;
+ };
+ gpio_acok_od: acok_od {
+ gpios = <&gpio0 0 GPIO_INPUT>;
+ enum-name = "GPIO_AC_PRESENT";
+ };
+ gpio_ccd_mode_odl: ccd_mode_odl {
+ gpios = <&gpioe 3 GPIO_INPUT>;
+ enum-name = "GPIO_CCD_MODE_ODL";
+ };
+ gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
+ gpios = <&gpio0 1 GPIO_INPUT>;
+ enum-name = "GPIO_POWER_BUTTON_L";
+ };
+ gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
+ gpios = <&gpio7 0 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_DOWN_L";
+ };
+ gpio_ec_volup_btn_odl: ec_volup_btn_odl {
+ gpios = <&gpiof 2 GPIO_INPUT_PULL_UP>;
+ enum-name = "GPIO_VOLUME_UP_L";
+ };
+ gpio_ec_wp_odl: ec_wp_odl {
+ gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ };
+ gpio_lid_open_ec: lid_open_ec {
+ gpios = <&gpiod 2 GPIO_INPUT>;
+ enum-name = "GPIO_LID_OPEN";
+ };
+ gpio_ap_rst_l: ap_rst_l {
+ gpios = <&gpioc 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ enum-name = "GPIO_AP_RST_L";
+ };
+ gpio_ps_hold: ps_hold {
+ gpios = <&gpioa 4 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_PS_HOLD";
+ };
+ gpio_ap_suspend: ap_suspend {
+ gpios = <&gpio5 7 GPIO_INPUT>;
+ enum-name = "GPIO_AP_SUSPEND";
+ };
+ gpio_deprecated_ap_rst_req: deprecated_ap_rst_req {
+ gpios = <&gpioc 2 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>;
+ enum-name = "GPIO_DEPRECATED_AP_RST_REQ";
+ };
+ gpio_power_good: power_good {
+ gpios = <&gpio5 4 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_POWER_GOOD";
+ };
+ gpio_warm_reset_l: warm_reset_l {
+ gpios = <&gpiof 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ enum-name = "GPIO_WARM_RESET_L";
+ };
+ ap_ec_spi_cs_l {
+ gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>;
+ };
+ gpio_tablet_mode_l: tablet_mode_l {
+ gpios = <&gpioc 6 GPIO_INPUT>;
+ enum-name = "GPIO_TABLET_MODE_L";
+ };
+ gpio_accel_gyro_int_l: accel_gyro_int_l {
+ gpios = <&gpioa 0 GPIO_INPUT>;
+ };
+ gpio_da9313_gpio0: da9313_gpio0 {
+ gpios = <&gpioe 2 GPIO_INPUT>;
+ enum-name = "GPIO_DA9313_GPIO0";
+ };
+ /*
+ * Active low input
+ */
+ gpio_switchcap_pg_int_l: switchcap_pg_int_l {
+ gpios = <&gpioe 2 (GPIO_ACTIVE_LOW | GPIO_INPUT)>;
+ };
+ gpio_ec_rst_odl: ec_rst_odl {
+ gpios = <&gpio0 2 GPIO_INPUT>;
+ };
+ ec_entering_rw {
+ gpios = <&gpioe 1 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_ENTERING_RW";
+ };
+ ec_batt_pres_odl {
+ gpios = <&gpioe 5 GPIO_INPUT>;
+ enum-name = "GPIO_BATT_PRES_ODL";
+ };
+ pm845_resin_l {
+ gpios = <&gpio3 2 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PMIC_RESIN_L";
+ };
+ pmic_kpd_pwr_odl {
+ gpios = <&gpiod 6 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_PMIC_KPD_PWR_ODL";
+ };
+ ec_int_l {
+ gpios = <&gpioa 2 GPIO_ODR_HIGH>;
+ enum-name = "GPIO_EC_INT_L";
+ };
+ qsip_on {
+ gpios = <&gpio5 0 GPIO_OUTPUT_LOW>;
+ };
+ gpio_hibernate_l: hibernate_l {
+ gpios = <&gpio5 2 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_switchcap_on: switchcap_on {
+ gpios = <&gpiod 5 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_SWITCHCAP_ON";
+ };
+ gpio_vbob_en: vbob_en {
+ gpios = <&gpiod 3 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_VBOB_EN";
+ };
+ gpio_en_pp3300_a: en_pp3300_a {
+ gpios = <&gpioa 6 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_EN_PP3300_A";
+ };
+ gpio_en_pp5000_a: en_pp5000_a {
+ gpios = <&gpio6 7 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_EN_PP5000";
+ };
+ ec_bl_disable_l {
+ gpios = <&gpiob 6 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_ENABLE_BACKLIGHT";
+ };
+ gpio_lid_accel_int_l: lid_accel_int_l {
+ gpios = <&gpio5 6 GPIO_INPUT>;
+ };
+ trackpad_int_gate {
+ gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
+ };
+ gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l {
+ gpios = <&gpiof 1 GPIO_ODR_HIGH>;
+ };
+ gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l {
+ gpios = <&gpioe 4 GPIO_ODR_HIGH>;
+ };
+ gpio_dp_mux_oe_l: dp_mux_oe_l {
+ gpios = <&gpio9 6 GPIO_ODR_HIGH>;
+ };
+ gpio_dp_mux_sel: dp_mux_sel {
+ gpios = <&gpio4 5 GPIO_OUTPUT_LOW>;
+ };
+ gpio_dp_hot_plug_det: dp_hot_plug_det {
+ gpios = <&gpio9 5 GPIO_OUTPUT_LOW>;
+ };
+ gpio_en_usb_a_5v: en_usb_a_5v {
+ gpios = <&gpio8 6 GPIO_OUTPUT_LOW>;
+ enum-name = "GPIO_EN_USB_A_5V";
+ };
+ usb_a_cdp_ilim_en {
+ gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>;
+ };
+ gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 {
+ gpios = <&gpioc 3 GPIO_OUTPUT_LOW>;
+ };
+ gpio_ec_chg_led_b_c1: ec_chg_led_b_c1 {
+ gpios = <&gpioc 4 GPIO_OUTPUT_LOW>;
+ };
+ gpio_brd_id0: brd_id0 {
+ gpios = <&gpioc 7 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION1";
+ };
+ gpio_brd_id1: brd_id1 {
+ gpios = <&gpio9 3 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION2";
+ };
+ gpio_brd_id2: brd_id2 {
+ gpios = <&gpio6 3 GPIO_INPUT>;
+ enum-name = "GPIO_BOARD_VERSION3";
+ };
+ gpio_sku_id0: sku_id0 {
+ gpios = <&gpiof 0 GPIO_INPUT>;
+ };
+ gpio_sku_id1: sku_id1 {
+ gpios = <&gpio4 1 GPIO_INPUT>;
+ };
+ gpio_sku_id2: sku_id2 {
+ gpios = <&gpiod 4 GPIO_INPUT>;
+ };
+ arm_x86 {
+ gpios = <&gpio6 6 GPIO_OUTPUT_LOW>;
+ };
+ ec-i2c-sensor-scl {
+ gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ ec-i2c-sensor-sda {
+ gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
+ };
+ gpio_ec_kso_02_inv: ec_kso_02_inv {
+ gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
+ };
+ };
+
+ usba-port-enable-list {
+ compatible = "cros-ec,usba-port-enable-pins";
+ enable-pins = <&gpio_en_usb_a_5v>;
+ };
+
+ hibernate-wake-pins {
+ compatible = "cros-ec,hibernate-wake-pins";
+ wakeup-irqs = <
+ &int_ac_present
+ &int_power_button
+ &int_lid_open
+ &int_ec_rst
+ >;
+ };
+
+ ec-mkbp-host-event-wakeup-mask {
+ compatible = "ec-wake-mask-event";
+ wakeup-mask = <(
+ HOST_EVENT_LID_OPEN |
+ HOST_EVENT_POWER_BUTTON |
+ HOST_EVENT_AC_CONNECTED |
+ HOST_EVENT_AC_DISCONNECTED |
+ HOST_EVENT_HANG_DETECT |
+ HOST_EVENT_RTC |
+ HOST_EVENT_MODE_CHANGE |
+ HOST_EVENT_DEVICE)>;
+ };
+
+ ec-mkbp-event-wakeup-mask {
+ compatible = "ec-wake-mask-event";
+ wakeup-mask = <(MKBP_EVENT_KEY_MATRIX |
+ MKBP_EVENT_HOST_EVENT |
+ MKBP_EVENT_SENSOR_FIFO)>;
+ };
+
+ gpio_id_sku: sku {
+ compatible = "cros-ec,gpio-id";
+ bits = <
+ &gpio_sku_id0
+ &gpio_sku_id1
+ &gpio_sku_id2
+ >;
+ system = "binary";
+ };
+
+ gpio_id_board: board {
+ compatible = "cros-ec,gpio-id";
+ bits = <
+ &gpio_brd_id0
+ &gpio_brd_id1
+ &gpio_brd_id2
+ >;
+ system = "binary_first_base3";
+ };
+
+ unused-pins {
+ compatible = "unused-gpios";
+ unused-gpios =
+ <&gpio5 1 0>,
+ <&gpiod 0 0>,
+ <&gpiof 3 0>,
+ <&gpio0 4 0>,
+ <&gpioc 0 0>,
+ <&gpioa 7 0>,
+ <&gpio8 3 0>,
+ <&gpio8 1 0>,
+ <&gpio3 7 0>,
+ <&gpio7 6 0>,
+ <&gpio3 4 0>,
+ <&gpioc 5 0>,
+ <&gpioa 3 0>,
+ <&gpio7 3 0>,
+ <&gpiod 7 0>,
+ <&gpioa 5 0>,
+ <&gpiob 0 0>,
+ <&gpio9 4 0>,
+ <&gpiob 1 0>,
+ <&gpio6 2 0>,
+ <&gpio3 5 0>,
+ <&gpio9 7 0>,
+ <&gpio6 0 0>,
+ <&gpio7 2 0>;
+ };
+};
diff --git a/zephyr/projects/trogdor/lazor/host_interface_npcx.dts b/zephyr/program/trogdor/lazor/host_interface_npcx.dts
index 14efa3c6b2..14efa3c6b2 100644
--- a/zephyr/projects/trogdor/lazor/host_interface_npcx.dts
+++ b/zephyr/program/trogdor/lazor/host_interface_npcx.dts
diff --git a/zephyr/projects/trogdor/lazor/i2c.dts b/zephyr/program/trogdor/lazor/i2c.dts
index e19ad224a9..e19ad224a9 100644
--- a/zephyr/projects/trogdor/lazor/i2c.dts
+++ b/zephyr/program/trogdor/lazor/i2c.dts
diff --git a/zephyr/projects/trogdor/lazor/include/sku.h b/zephyr/program/trogdor/lazor/include/sku.h
index 76825bbba1..76825bbba1 100644
--- a/zephyr/projects/trogdor/lazor/include/sku.h
+++ b/zephyr/program/trogdor/lazor/include/sku.h
diff --git a/zephyr/projects/trogdor/lazor/interrupts.dts b/zephyr/program/trogdor/lazor/interrupts.dts
index 5c2ed35e90..5c2ed35e90 100644
--- a/zephyr/projects/trogdor/lazor/interrupts.dts
+++ b/zephyr/program/trogdor/lazor/interrupts.dts
diff --git a/zephyr/program/trogdor/lazor/keyboard.dts b/zephyr/program/trogdor/lazor/keyboard.dts
new file mode 100644
index 0000000000..6580fa2a35
--- /dev/null
+++ b/zephyr/program/trogdor/lazor/keyboard.dts
@@ -0,0 +1,38 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/ {
+ cros-keyscan {
+ compatible = "cros-ec,keyscan";
+
+ actual-key-mask = <
+ 0x14 /* C0 */
+ 0xff /* C1 */
+ 0xff /* C2 */
+ 0xff /* C3 */
+ 0xff /* C4 */
+ 0xf5 /* C5 */
+ 0xff /* C6 */
+ 0xa4 /* C7 */
+ 0xff /* C8 */
+ 0xfe /* C9 */
+ 0x55 /* C10 */
+ 0xfa /* C11 */
+ 0xca /* C12 */
+ >;
+ };
+
+ kblight {
+ compatible = "cros-ec,kblight-pwm";
+ pwms = <&pwm3 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>;
+ generic-pwm-channel = <0>;
+ };
+};
+
+&pwm3 {
+ status = "okay";
+ pinctrl-0 = <&pwm3_gp80>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/trogdor/lazor/led.dts b/zephyr/program/trogdor/lazor/led.dts
index 4527afd34c..4527afd34c 100644
--- a/zephyr/projects/trogdor/lazor/led.dts
+++ b/zephyr/program/trogdor/lazor/led.dts
diff --git a/zephyr/projects/trogdor/lazor/motionsense.dts b/zephyr/program/trogdor/lazor/motionsense.dts
index 75fe31b997..75fe31b997 100644
--- a/zephyr/projects/trogdor/lazor/motionsense.dts
+++ b/zephyr/program/trogdor/lazor/motionsense.dts
diff --git a/zephyr/program/trogdor/lazor/prj.conf b/zephyr/program/trogdor/lazor/prj.conf
new file mode 100644
index 0000000000..7863c75917
--- /dev/null
+++ b/zephyr/program/trogdor/lazor/prj.conf
@@ -0,0 +1,149 @@
+# Copyright 2021 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_CROS_EC=y
+#
+# Lazor actually has a NPCX7M6FC, but
+# the NPCX7M7FC is actually the same die, without the
+# extra RAM being tested. The code size really could
+# do with the extra space, so we pretend the EC is the
+# part with the larger RAM. YMMV.
+#
+CONFIG_SOC_NPCX7M7FC=y
+CONFIG_SOC_SERIES_NPCX7=y
+CONFIG_SHIMMED_TASKS=y
+CONFIG_PLATFORM_EC=y
+CONFIG_PLATFORM_EC_BRINGUP=y
+CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
+CONFIG_PLATFORM_EC_SWITCH=y
+CONFIG_PLATFORM_EC_LID_SWITCH=y
+CONFIG_PLATFORM_EC_BACKLIGHT_LID=y
+CONFIG_PLATFORM_EC_POWER_BUTTON=y
+
+# LED
+CONFIG_PLATFORM_EC_LED_DT=y
+
+# PWM
+CONFIG_PWM=y
+
+# Application Processor is Qualcomm SC7180
+CONFIG_AP_ARM_QUALCOMM_SC7180=y
+
+# Board version is selected over GPIO board ID pins.
+CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y
+
+# LN9310 Switchcap
+CONFIG_PLATFORM_EC_SWITCHCAP_LN9310=y
+
+# Power Sequencing
+CONFIG_PLATFORM_EC_POWERSEQ=y
+CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y
+CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
+CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y
+CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y
+
+# Trogdor family does not use EFS2
+CONFIG_PLATFORM_EC_VBOOT_EFS2=n
+
+# MKBP event
+CONFIG_PLATFORM_EC_MKBP_EVENT=y
+CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y
+
+# Keyboard
+CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y
+CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
+CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
+CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
+CONFIG_PLATFORM_EC_CMD_BUTTON=y
+
+# Battery
+CONFIG_PLATFORM_EC_BATTERY_SMART=y
+CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y
+CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y
+CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
+CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
+CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
+CONFIG_PLATFORM_EC_CHARGER_ISL9238=y
+CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y
+CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY=y
+CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY="LION"
+CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
+CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y
+CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=2
+CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=10000
+CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512
+CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y
+CONFIG_PLATFORM_EC_CHARGER_PSYS=y
+CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
+CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20
+CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y
+
+# USB-C
+CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n
+CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y
+CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE=n
+CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y
+CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
+CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_REV30=n
+CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
+CONFIG_PLATFORM_EC_USB_PD_USB4=n
+CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_MULTI_PS8XXX=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8751=y
+CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805=y
+CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n
+CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n
+CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
+
+# USB ID
+# This is allocated specifically for Trogdor
+# http://google3/hardware/standards/usb/
+# TODO(b/183608112): Move to device tree
+CONFIG_PLATFORM_EC_USB_PID=0x5043
+
+# RTC
+CONFIG_PLATFORM_EC_RTC=y
+CONFIG_PLATFORM_EC_HOSTCMD_RTC=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y
+
+# EC software sync
+CONFIG_PLATFORM_EC_VBOOT_HASH=y
+
+# Sensors
+CONFIG_PLATFORM_EC_MOTIONSENSE=y
+CONFIG_PLATFORM_EC_ACCEL_FIFO=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
+CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
+CONFIG_PLATFORM_EC_LID_ANGLE=y
+CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
+CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
+CONFIG_PLATFORM_EC_TABLET_MODE=y
+CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
+
+# Sensor Drivers
+CONFIG_PLATFORM_EC_ACCEL_BMA255=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI160=y
+CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
+
+# Console history
+CONFIG_SHELL_HISTORY=y
+CONFIG_SHELL_CMDS=y
+CONFIG_SHELL_HELP=n
+CONFIG_SHELL_MINIMAL=y
+
+# Taskinfo
+CONFIG_THREAD_MONITOR=y
+CONFIG_KERNEL_SHELL=y
+
+CONFIG_SYSCON=y
+
+# Features should be enabled. But the code RAM is not enough, disable them.
+#CONFIG_PLATFORM_EC_ACCEL_SPOOF_MODE=y
+#CONFIG_PLATFORM_EC_EMULATED_SYSRQ=y
diff --git a/zephyr/program/trogdor/lazor/pwm_led.dts b/zephyr/program/trogdor/lazor/pwm_led.dts
new file mode 100644
index 0000000000..f8375b3596
--- /dev/null
+++ b/zephyr/program/trogdor/lazor/pwm_led.dts
@@ -0,0 +1,55 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * 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_y: pwm_y {
+ pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_NORMAL>;
+ };
+ pwm_b: pwm_b {
+ pwms = <&pwm2 0 PWM_HZ(324) PWM_POLARITY_NORMAL>;
+ };
+ };
+
+ pwm-led-pins {
+ compatible = "cros-ec,pwm-led-pins";
+
+ color_off: color-off {
+ led-color = "LED_OFF";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ led-pwms = <&pwm_y &pwm_b>;
+ led-values = <0 0>;
+ };
+
+ color_amber: color-amber {
+ led-color = "LED_AMBER";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_AMBER";
+ led-pwms = <&pwm_y &pwm_b>;
+ led-values = <100 0>;
+ };
+
+ color_blue: color-blue {
+ led-color = "LED_BLUE";
+ led-id = "EC_LED_ID_BATTERY_LED";
+ br-color = "EC_LED_COLOR_BLUE";
+ led-pwms = <&pwm_y &pwm_b>;
+ led-values = <0 100>;
+ };
+ };
+};
+
+&pwm0 {
+ status = "okay";
+ pinctrl-0 = <&pwm0_gpc3>;
+ pinctrl-names = "default";
+};
+
+&pwm2 {
+ status = "okay";
+ pinctrl-0 = <&pwm2_gpc4>;
+ pinctrl-names = "default";
+};
diff --git a/zephyr/projects/trogdor/lazor/src/hibernate.c b/zephyr/program/trogdor/lazor/src/hibernate.c
index 388ff1b087..388ff1b087 100644
--- a/zephyr/projects/trogdor/lazor/src/hibernate.c
+++ b/zephyr/program/trogdor/lazor/src/hibernate.c
diff --git a/zephyr/program/trogdor/lazor/src/i2c.c b/zephyr/program/trogdor/lazor/src/i2c.c
new file mode 100644
index 0000000000..e572bbdf37
--- /dev/null
+++ b/zephyr/program/trogdor/lazor/src/i2c.c
@@ -0,0 +1,17 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "i2c.h"
+#include "i2c/i2c.h"
+
+/* Lazor board specific i2c implementation */
+
+#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
+int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc)
+{
+ return (i2c_get_device_for_port(cmd_desc->port) ==
+ i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY));
+}
+#endif
diff --git a/zephyr/program/trogdor/lazor/src/power.c b/zephyr/program/trogdor/lazor/src/power.c
new file mode 100644
index 0000000000..ee99c77196
--- /dev/null
+++ b/zephyr/program/trogdor/lazor/src/power.c
@@ -0,0 +1,59 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gpio.h"
+#include "power.h"
+#include "task.h"
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/init.h>
+
+#include <ap_power/ap_power.h>
+
+static void board_power_change(struct ap_power_ev_callback *cb,
+ struct ap_power_ev_data data)
+{
+ switch (data.event) {
+ default:
+ return;
+
+ case AP_POWER_PRE_INIT:
+ /* Turn on the 3.3V rail */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp3300_a), 1);
+
+ /* Turn on the 5V rail. */
+#ifdef CONFIG_POWER_PP5000_CONTROL
+ power_5v_enable(task_get_current(), 1);
+#else /* !defined(CONFIG_POWER_PP5000_CONTROL) */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a), 1);
+#endif /* defined(CONFIG_POWER_PP5000_CONTROL) */
+ break;
+
+ case AP_POWER_SHUTDOWN_COMPLETE:
+ /* Turn off the 5V rail. */
+#ifdef CONFIG_POWER_PP5000_CONTROL
+ power_5v_enable(task_get_current(), 0);
+#else /* !defined(CONFIG_POWER_PP5000_CONTROL) */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a), 0);
+#endif /* defined(CONFIG_POWER_PP5000_CONTROL) */
+
+ /* Turn off the 3.3V and 5V rails. */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp3300_a), 0);
+ break;
+ }
+}
+
+static int board_power_handler_init(const struct device *unused)
+{
+ static struct ap_power_ev_callback cb;
+
+ /* Setup a suspend/resume callback */
+ ap_power_ev_init_callback(&cb, board_power_change,
+ AP_POWER_PRE_INIT |
+ AP_POWER_SHUTDOWN_COMPLETE);
+ ap_power_ev_add_callback(&cb);
+ return 0;
+}
+SYS_INIT(board_power_handler_init, APPLICATION, 1);
diff --git a/zephyr/program/trogdor/lazor/src/sku.c b/zephyr/program/trogdor/lazor/src/sku.c
new file mode 100644
index 0000000000..a6187d422f
--- /dev/null
+++ b/zephyr/program/trogdor/lazor/src/sku.c
@@ -0,0 +1,92 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "config.h"
+#include "console.h"
+#include "driver/ln9310.h"
+#include "hooks.h"
+#include "sku.h"
+#include "system.h"
+#include "tcpm/ps8xxx_public.h"
+#include "util.h"
+
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+static uint8_t sku_id;
+
+enum board_model {
+ LAZOR,
+ LIMOZEEN,
+ UNKNOWN,
+};
+
+static const char *const model_name[] = {
+ "LAZOR",
+ "LIMOZEEN",
+ "UNKNOWN",
+};
+
+static enum board_model get_model(void)
+{
+ if (sku_id == 0 || sku_id == 1 || sku_id == 2 || sku_id == 3)
+ return LAZOR;
+ if (sku_id == 4 || sku_id == 5 || sku_id == 6)
+ return LIMOZEEN;
+ return UNKNOWN;
+}
+
+/* Read SKU ID from GPIO and initialize variables for board variants */
+static void sku_init(void)
+{
+ sku_id = system_get_sku_id();
+ CPRINTS("SKU: %u (%s)", sku_id, model_name[get_model()]);
+}
+DECLARE_HOOK(HOOK_INIT, sku_init, HOOK_PRIO_POST_I2C);
+
+enum battery_cell_type board_get_battery_cell_type(void)
+{
+ switch (get_model()) {
+ case LIMOZEEN:
+ return BATTERY_CELL_TYPE_3S;
+ default:
+ return BATTERY_CELL_TYPE_UNKNOWN;
+ }
+}
+
+int board_is_clamshell(void)
+{
+ return get_model() == LIMOZEEN;
+}
+
+__override uint16_t board_get_ps8xxx_product_id(int port)
+{
+ /*
+ * Lazor (SKU_ID: 0, 1, 2, 3) rev 3+ changes TCPC from PS8751 to
+ * PS8805.
+ *
+ * Limozeen (SKU_ID: 4, 5, 6) all-rev uses PS8805.
+ */
+ if (get_model() == LAZOR && system_get_board_version() < 3)
+ return PS8751_PRODUCT_ID;
+
+ return PS8805_PRODUCT_ID;
+}
+
+int board_has_da9313(void)
+{
+ return get_model() == LAZOR;
+}
+
+int board_has_buck_ic(void)
+{
+ return get_model() == LIMOZEEN && system_get_board_version() >= 8;
+}
+
+int board_has_ln9310(void)
+{
+ return get_model() == LIMOZEEN && system_get_board_version() < 8;
+}
diff --git a/zephyr/program/trogdor/lazor/src/switchcap.c b/zephyr/program/trogdor/lazor/src/switchcap.c
new file mode 100644
index 0000000000..77413fb336
--- /dev/null
+++ b/zephyr/program/trogdor/lazor/src/switchcap.c
@@ -0,0 +1,128 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "config.h"
+#include "console.h"
+#include "driver/ln9310.h"
+#include "gpio/gpio_int.h"
+#include "hooks.h"
+#include "i2c.h"
+#include "power/qcom.h"
+#include "sku.h"
+#include "system.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTS(format, args...) cprints(CC_I2C, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_I2C, format, ##args)
+
+/* LN9310 switchcap */
+const struct ln9310_config_t ln9310_config = {
+ .i2c_port = I2C_PORT_POWER,
+ .i2c_addr_flags = LN9310_I2C_ADDR_0_FLAGS,
+};
+
+static void switchcap_init(void)
+{
+ if (board_has_da9313()) {
+ CPRINTS("Use switchcap: DA9313");
+
+ /*
+ * When the chip in power down mode, it outputs high-Z.
+ * Set pull-down to avoid floating.
+ */
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_da9313_gpio0),
+ GPIO_INPUT | GPIO_PULL_DOWN);
+
+ /*
+ * Configure DA9313 enable, push-pull output. Don't set the
+ * level here; otherwise, it will override its value and
+ * shutdown the switchcap when sysjump to RW.
+ */
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on),
+ GPIO_OUTPUT);
+ } else if (board_has_ln9310()) {
+ CPRINTS("Use switchcap: LN9310");
+
+ /* Enable interrupt for LN9310 */
+ gpio_enable_dt_interrupt(
+ GPIO_INT_FROM_NODELABEL(int_switchcap_pg));
+
+ /*
+ * Configure LN9310 enable, open-drain output. Don't set the
+ * level here; otherwise, it will override its value and
+ * shutdown the switchcap when sysjump to RW.
+ *
+ * Note that the gpio.inc configures it GPIO_OUT_LOW. When
+ * sysjump to RW, will output push-pull a short period of
+ * time. As it outputs LOW, should be fine.
+ *
+ * This GPIO changes like:
+ * (1) EC boots from RO -> high-Z
+ * (2) GPIO init according to gpio.inc -> push-pull LOW
+ * (3) This function configures it -> open-drain HIGH
+ * (4) Power sequence turns on the switchcap -> open-drain LOW
+ * (5) EC sysjumps to RW
+ * (6) GPIO init according to gpio.inc -> push-pull LOW
+ * (7) This function configures it -> open-drain LOW
+ */
+ gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on),
+ GPIO_OUTPUT | GPIO_OPEN_DRAIN);
+
+ /* Only configure the switchcap if not sysjump */
+ if (!system_jumped_late()) {
+ /*
+ * Deassert the enable pin, so the
+ * switchcap won't be enabled after the switchcap is
+ * configured from standby mode to switching mode.
+ */
+ gpio_pin_set_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), 0);
+ ln9310_init();
+ }
+ } else if (board_has_buck_ic()) {
+ CPRINTS("Use Buck IC");
+ } else {
+ CPRINTS("ERROR: No switchcap solution");
+ }
+}
+DECLARE_HOOK(HOOK_INIT, switchcap_init, HOOK_PRIO_DEFAULT);
+
+void board_set_switchcap_power(int enable)
+{
+ if (board_has_da9313()) {
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on),
+ enable);
+ } else if (board_has_ln9310()) {
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on),
+ enable);
+ ln9310_software_enable(enable);
+ } else if (board_has_buck_ic()) {
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_vbob_en), enable);
+ }
+}
+
+int board_is_switchcap_enabled(void)
+{
+ if (board_has_da9313() || board_has_ln9310())
+ return gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_switchcap_on));
+
+ /* Board has buck ic*/
+ return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_vbob_en));
+}
+
+int board_is_switchcap_power_good(void)
+{
+ if (board_has_da9313())
+ return gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_da9313_gpio0));
+ else if (board_has_ln9310())
+ return ln9310_power_good();
+
+ /* Board has buck ic no way to check POWER GOOD */
+ return 1;
+}
diff --git a/zephyr/program/trogdor/lazor/src/usb_pd_policy.c b/zephyr/program/trogdor/lazor/src/usb_pd_policy.c
new file mode 100644
index 0000000000..32e3376ca0
--- /dev/null
+++ b/zephyr/program/trogdor/lazor/src/usb_pd_policy.c
@@ -0,0 +1,261 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_manager.h"
+#include "chipset.h"
+#include "console.h"
+#include "system.h"
+#include "usb_mux.h"
+#include "usbc_ppc.h"
+#include "util.h"
+
+#include <zephyr/drivers/gpio.h>
+
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+int pd_check_vconn_swap(int port)
+{
+ /* In G3, do not allow vconn swap since PP5000 rail is off */
+ return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a));
+}
+
+static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT];
+#if CONFIG_USB_PD_PORT_MAX_COUNT == 1
+static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = { TYPEC_RP_1A5 };
+#else
+static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = { TYPEC_RP_1A5,
+ TYPEC_RP_1A5 };
+#endif
+
+static void board_vbus_update_source_current(int port)
+{
+ /* Both port are controlled by PPC SN5S330. */
+ ppc_set_vbus_source_current_limit(port, vbus_rp[port]);
+ ppc_vbus_source_enable(port, vbus_en[port]);
+}
+
+void pd_power_supply_reset(int port)
+{
+ int prev_en;
+
+ prev_en = vbus_en[port];
+
+ /* Disable VBUS */
+ vbus_en[port] = 0;
+ board_vbus_update_source_current(port);
+
+ /* Enable discharge if we were previously sourcing 5V */
+ if (prev_en)
+ pd_set_vbus_discharge(port, 1);
+
+ /* notify host of power info change */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+}
+
+int pd_set_power_supply_ready(int port)
+{
+ /* Disable charging */
+ board_vbus_sink_enable(port, 0);
+
+ pd_set_vbus_discharge(port, 0);
+
+ /* Provide VBUS */
+ vbus_en[port] = 1;
+ board_vbus_update_source_current(port);
+
+ /* notify host of power info change */
+ pd_send_host_event(PD_EVENT_POWER_CHANGE);
+
+ return EC_SUCCESS; /* we are ready */
+}
+
+int board_vbus_source_enabled(int port)
+{
+ return vbus_en[port];
+}
+
+__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
+{
+ vbus_rp[port] = rp;
+ board_vbus_update_source_current(port);
+}
+
+int pd_snk_is_vbus_provided(int port)
+{
+ return tcpm_check_vbus_level(port, VBUS_PRESENT);
+}
+
+/* ----------------- Vendor Defined Messages ------------------ */
+#ifdef CONFIG_USB_PD_ALT_MODE_DFP
+__override int svdm_dp_config(int port, uint32_t *payload)
+{
+ int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT);
+ uint8_t pin_mode = get_dp_pin_mode(port);
+
+ if (!pin_mode)
+ return 0;
+
+ /*
+ * Defer setting the usb_mux until HPD goes high, svdm_dp_attention().
+ * The AP only supports one DP phy. An external DP mux switches between
+ * the two ports. Should switch those muxes when it is really used,
+ * i.e. HPD high; otherwise, the real use case is preempted, like:
+ * (1) plug a dongle without monitor connected to port-0,
+ * (2) plug a dongle without monitor connected to port-1,
+ * (3) plug a monitor to the port-1 dongle.
+ */
+
+ payload[0] =
+ VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos));
+ payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */
+ 1, /* DPv1.3 signaling */
+ 2); /* UFP connected */
+ return 2;
+};
+
+__override void svdm_dp_post_config(int port)
+{
+ dp_flags[port] |= DP_FLAGS_DP_ON;
+}
+
+/**
+ * Is the port fine to be muxed its DisplayPort lines?
+ *
+ * Only one port can be muxed to DisplayPort at a time.
+ *
+ * @param port Port number of TCPC.
+ * @return 1 is fine; 0 is bad as other port is already muxed;
+ */
+static int is_dp_muxable(int port)
+{
+ int i;
+
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
+ if (i != port) {
+ if (usb_mux_get(i) & USB_PD_MUX_DP_ENABLED)
+ return 0;
+ }
+
+ return 1;
+}
+
+__override int svdm_dp_attention(int port, uint32_t *payload)
+{
+ const struct gpio_dt_spec *hpd =
+ GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det);
+ int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
+ int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
+ int cur_lvl = gpio_pin_get_dt(hpd);
+ mux_state_t mux_state;
+
+ dp_status[port] = payload[1];
+
+ if (!is_dp_muxable(port)) {
+ /* TODO(waihong): Info user? */
+ CPRINTS("p%d: The other port is already muxed.", port);
+ return 0;
+ }
+
+ /*
+ * Initial implementation to handle HPD. Only the first-plugged port
+ * works, i.e. sending HPD signal to AP. The second-plugged port
+ * will be ignored.
+ *
+ * TODO(waihong): Continue the above case, if the first-plugged port
+ * is then unplugged, switch to the second-plugged port and signal AP?
+ */
+ if (lvl) {
+ /*
+ * Enable and switch the DP port selection mux to the
+ * correct port.
+ *
+ * TODO(waihong): Better to move switching DP mux to
+ * the usb_mux abstraction.
+ */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel),
+ port == 1);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 0);
+
+ /* Connect the SBU lines in PPC chip. */
+ if (IS_ENABLED(CONFIG_USBC_PPC_SBU))
+ ppc_set_sbu(port, 1);
+
+ /*
+ * Connect the USB SS/DP lines in TCPC chip.
+ *
+ * When mf_pref not true, still use the dock muxing
+ * because of the board USB-C topology (limited to 2
+ * lanes DP).
+ */
+ usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT,
+ polarity_rm_dts(pd_get_polarity(port)));
+ } else {
+ /* Disconnect the DP port selection mux. */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0);
+
+ /* Disconnect the SBU lines in PPC chip. */
+ if (IS_ENABLED(CONFIG_USBC_PPC_SBU))
+ ppc_set_sbu(port, 0);
+
+ /* Disconnect the DP but keep the USB SS lines in TCPC chip. */
+ usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT,
+ polarity_rm_dts(pd_get_polarity(port)));
+ }
+
+ if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl))
+ /*
+ * Wake up the AP. IRQ or level high indicates a DP sink is now
+ * present.
+ */
+ pd_notify_dp_alt_mode_entry(port);
+
+ /* Configure TCPC for the HPD event, for proper muxing */
+ mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
+ (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ usb_mux_hpd_update(port, mux_state);
+
+ /* Signal AP for the HPD event, through GPIO to AP */
+ if (irq & cur_lvl) {
+ uint64_t now = get_time().val;
+ /* Wait for the minimum spacing between IRQ_HPD if needed */
+ if (now < svdm_hpd_deadline[port])
+ usleep(svdm_hpd_deadline[port] - now);
+
+ /* Generate IRQ_HPD pulse */
+ gpio_pin_set_dt(hpd, 0);
+ usleep(HPD_DSTREAM_DEBOUNCE_IRQ);
+ gpio_pin_set_dt(hpd, 1);
+
+ /* Set the minimum time delay (2ms) for the next HPD IRQ */
+ svdm_hpd_deadline[port] =
+ get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
+ } else if (irq & !lvl) {
+ CPRINTF("ERR:HPD:IRQ&LOW\n");
+ return 0;
+ }
+ gpio_pin_set_dt(hpd, lvl);
+ /* Set the minimum time delay (2ms) for the next HPD IRQ */
+ svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
+
+ return 1;
+}
+
+__override void svdm_exit_dp_mode(int port)
+{
+ if (is_dp_muxable(port)) {
+ /* Disconnect the DP port selection mux. */
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0);
+
+ /* Signal AP for the HPD low event */
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det),
+ 0);
+ }
+}
+#endif /* CONFIG_USB_PD_ALT_MODE_DFP */
diff --git a/zephyr/program/trogdor/lazor/src/usbc_config.c b/zephyr/program/trogdor/lazor/src/usbc_config.c
new file mode 100644
index 0000000000..d7d5ca2cc1
--- /dev/null
+++ b/zephyr/program/trogdor/lazor/src/usbc_config.c
@@ -0,0 +1,334 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Lazor board-specific USB-C configuration */
+
+#include "battery_fuel_gauge.h"
+#include "bc12/pi3usb9201_public.h"
+#include "charge_manager.h"
+#include "charge_state.h"
+#include "charger.h"
+#include "charger/isl923x_public.h"
+#include "common.h"
+#include "config.h"
+#include "driver/ln9310.h"
+#include "gpio/gpio_int.h"
+#include "gpio_signal.h"
+#include "hooks.h"
+#include "ppc/sn5s330_public.h"
+#include "system.h"
+#include "tcpm/ps8xxx_public.h"
+#include "tcpm/tcpci.h"
+#include "timer.h"
+#include "usb_mux.h"
+#include "usb_pd.h"
+#include "usbc_ocp.h"
+#include "usbc_ppc.h"
+
+#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
+#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
+
+int charger_profile_override(struct charge_state_data *curr)
+{
+ int usb_mv;
+ int port;
+
+ if (curr->state != ST_CHARGE)
+ return 0;
+
+ /* Lower the max requested voltage to 5V when battery is full. */
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF) &&
+ !(curr->batt.flags & BATT_FLAG_BAD_STATUS) &&
+ !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
+ (curr->batt.status & STATUS_FULLY_CHARGED))
+ usb_mv = 5000;
+ else
+ usb_mv = PD_MAX_VOLTAGE_MV;
+
+ if (pd_get_max_voltage() != usb_mv) {
+ CPRINTS("VBUS limited to %dmV", usb_mv);
+ for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++)
+ pd_set_external_voltage_limit(port, usb_mv);
+ }
+
+ return 0;
+}
+
+enum ec_status charger_profile_override_get_param(uint32_t param,
+ uint32_t *value)
+{
+ return EC_RES_INVALID_PARAM;
+}
+
+enum ec_status charger_profile_override_set_param(uint32_t param,
+ uint32_t value)
+{
+ return EC_RES_INVALID_PARAM;
+}
+
+static void usba_oc_deferred(void)
+{
+ /* Use next number after all USB-C ports to indicate the USB-A port */
+ board_overcurrent_event(
+ CONFIG_USB_PD_PORT_MAX_COUNT,
+ !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_a0_oc_odl)));
+}
+DECLARE_DEFERRED(usba_oc_deferred);
+
+void usba_oc_interrupt(enum gpio_signal signal)
+{
+ hook_call_deferred(&usba_oc_deferred_data, 0);
+}
+
+void ppc_interrupt(enum gpio_signal signal)
+{
+ switch (signal) {
+ case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_swctl_int_odl)):
+ sn5s330_interrupt(0);
+ break;
+ case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c1_swctl_int_odl)):
+ sn5s330_interrupt(1);
+ break;
+ default:
+ break;
+ }
+}
+
+static void board_connect_c0_sbu_deferred(void)
+{
+ /*
+ * If CCD_MODE_ODL asserts, it means there's a debug accessory connected
+ * and we should enable the SBU FETs.
+ */
+ ppc_set_sbu(0, 1);
+}
+DECLARE_DEFERRED(board_connect_c0_sbu_deferred);
+
+void board_connect_c0_sbu(enum gpio_signal s)
+{
+ hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0);
+}
+
+/* GPIO Interrupt Handlers */
+void tcpc_alert_event(enum gpio_signal signal)
+{
+ int port = -1;
+
+ switch (signal) {
+ case GPIO_USB_C0_PD_INT_ODL:
+ port = 0;
+ break;
+ case GPIO_USB_C1_PD_INT_ODL:
+ port = 1;
+ break;
+ default:
+ return;
+ }
+
+ schedule_deferred_pd_interrupt(port);
+}
+
+/*
+ * Port-0/1 USB mux driver.
+ *
+ * The USB mux is handled by TCPC chip and the HPD update is through a GPIO
+ * to AP. But the TCPC chip is also needed to know the HPD status; otherwise,
+ * the mux misbehaves.
+ */
+const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
+ {
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = 0,
+ .driver = &tcpci_tcpm_usb_mux_driver,
+ .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ },
+ },
+ {
+ .mux =
+ &(const struct usb_mux){
+ .usb_port = 1,
+ .driver = &tcpci_tcpm_usb_mux_driver,
+ .hpd_update = &ps8xxx_tcpc_update_hpd_status,
+ },
+ }
+};
+
+__override int board_get_default_battery_type(void)
+{
+ /*
+ * A 2S battery is set as default. If the board is configured to use
+ * a 3S battery, according to its SKU_ID, return a 3S battery as
+ * default. It helps to configure the charger to output a correct
+ * voltage in case the battery is not attached.
+ */
+ if (board_get_battery_cell_type() == BATTERY_CELL_TYPE_3S)
+ return BATTERY_LGC_AP18C8K;
+
+ return DEFAULT_BATTERY_TYPE;
+}
+
+/* Initialize board USC-C things */
+static void board_init_usbc(void)
+{
+ /* Enable USB-A overcurrent interrupt */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_oc));
+ /*
+ * The H1 SBU line for CCD are behind PPC chip. The PPC internal FETs
+ * for SBU may be disconnected after DP alt mode is off. Should enable
+ * the CCD_MODE_ODL interrupt to make sure the SBU FETs are connected.
+ */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode));
+}
+DECLARE_HOOK(HOOK_INIT, board_init_usbc, HOOK_PRIO_DEFAULT);
+
+void board_tcpc_init(void)
+{
+ /* Only reset TCPC if not sysjump */
+ if (!system_jumped_late()) {
+ /* TODO(crosbug.com/p/61098): How long do we need to wait? */
+ board_reset_pd_mcu();
+ }
+
+ /* Enable PPC interrupts */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_swctl));
+
+ /* Enable TCPC interrupts */
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc));
+ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc));
+
+ /*
+ * Initialize HPD to low; after sysjump SOC needs to see
+ * HPD pulse to enable video path
+ */
+ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
+ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
+ USB_PD_MUX_HPD_IRQ_DEASSERTED);
+}
+DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C);
+
+void board_reset_pd_mcu(void)
+{
+ cprints(CC_USB, "Resetting TCPCs...");
+ cflush();
+
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 0);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 0);
+ msleep(PS8XXX_RESET_DELAY_MS);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 1);
+ gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 1);
+}
+
+void board_set_tcpc_power_mode(int port, int mode)
+{
+ /* Ignore the "mode" to turn the chip on. We can only do a reset. */
+ if (mode)
+ return;
+
+ board_reset_pd_mcu();
+}
+
+int board_vbus_sink_enable(int port, int enable)
+{
+ /* Both ports are controlled by PPC SN5S330 */
+ return ppc_vbus_sink_enable(port, enable);
+}
+
+int board_is_sourcing_vbus(int port)
+{
+ /* Both ports are controlled by PPC SN5S330 */
+ return ppc_is_sourcing_vbus(port);
+}
+
+void board_overcurrent_event(int port, int is_overcurrented)
+{
+ /* TODO(b/120231371): Notify AP */
+ CPRINTS("p%d: overcurrent!", port);
+}
+
+int board_set_active_charge_port(int port)
+{
+ int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
+ int i;
+
+ if (!is_real_port && port != CHARGE_PORT_NONE)
+ return EC_ERROR_INVAL;
+
+ if (port == CHARGE_PORT_NONE) {
+ CPRINTS("Disabling all charging port");
+
+ /* Disable all ports. */
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ /*
+ * Do not return early if one fails otherwise we can
+ * get into a boot loop assertion failure.
+ */
+ if (board_vbus_sink_enable(i, 0))
+ CPRINTS("Disabling p%d sink path failed.", i);
+ }
+
+ return EC_SUCCESS;
+ }
+
+ /* Check if the port is sourcing VBUS. */
+ if (board_is_sourcing_vbus(port)) {
+ CPRINTS("Skip enable p%d", port);
+ return EC_ERROR_INVAL;
+ }
+
+ CPRINTS("New charge port: p%d", port);
+
+ /*
+ * Turn off the other ports' sink path FETs, before enabling the
+ * requested charge port.
+ */
+ for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
+ if (i == port)
+ continue;
+
+ if (board_vbus_sink_enable(i, 0))
+ CPRINTS("p%d: sink path disable failed.", i);
+ }
+
+ /* Enable requested charge port. */
+ if (board_vbus_sink_enable(port, 1)) {
+ CPRINTS("p%d: sink path enable failed.", port);
+ return EC_ERROR_UNKNOWN;
+ }
+
+ return EC_SUCCESS;
+}
+
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
+{
+ /*
+ * Ignore lower charge ceiling on PD transition if our battery is
+ * critical, as we may brownout.
+ */
+ if (supplier == CHARGE_SUPPLIER_PD && charge_ma < 1500 &&
+ charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) {
+ CPRINTS("Using max ilim %d", max_ma);
+ charge_ma = max_ma;
+ }
+
+ charge_set_input_current_limit(charge_ma, charge_mv);
+}
+
+uint16_t tcpc_get_alert_status(void)
+{
+ uint16_t status = 0;
+
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl)))
+ if (gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l)))
+ status |= PD_STATUS_TCPC_ALERT_0;
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_int_odl)))
+ if (gpio_pin_get_dt(
+ GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l)))
+ status |= PD_STATUS_TCPC_ALERT_1;
+
+ return status;
+}
diff --git a/zephyr/projects/trogdor/lazor/usbc.dts b/zephyr/program/trogdor/lazor/usbc.dts
index 7864c2716b..7864c2716b 100644
--- a/zephyr/projects/trogdor/lazor/usbc.dts
+++ b/zephyr/program/trogdor/lazor/usbc.dts
diff --git a/zephyr/projects/brya/battery_present.c b/zephyr/projects/brya/battery_present.c
deleted file mode 100644
index c487a01f36..0000000000
--- a/zephyr/projects/brya/battery_present.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include <zephyr/drivers/gpio.h>
-
-#include "battery.h"
-#include "cbi.h"
-
-enum battery_present battery_hw_present(void)
-{
- const struct gpio_dt_spec *batt_pres;
-
- if (get_board_id() == 1)
- batt_pres = GPIO_DT_FROM_NODELABEL(gpio_id_1_ec_batt_pres_odl);
- else
- batt_pres = GPIO_DT_FROM_NODELABEL(gpio_ec_batt_pres_odl);
-
- /* The GPIO is low when the battery is physically present */
- return gpio_pin_get_dt(batt_pres) ? BP_NO : BP_YES;
-}
diff --git a/zephyr/projects/brya/i2c.dts b/zephyr/projects/brya/i2c.dts
deleted file mode 100644
index 7284d80870..0000000000
--- a/zephyr/projects/brya/i2c.dts
+++ /dev/null
@@ -1,285 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
- #include <dt-bindings/usb_pd_tcpm.h>
-
-/ {
- named-i2c-ports {
- compatible = "named-i2c-ports";
- i2c_sensor: sensor {
- i2c-port = <&i2c0_0>;
- enum-names = "I2C_PORT_SENSOR";
- };
- tcpc0_2: tcpc0_2 {
- i2c-port = <&i2c1_0>;
- enum-names = "I2C_PORT_USB_C0_C2_TCPC";
- };
- tcpc1: tcpc1 {
- i2c-port = <&i2c4_1>;
- enum-names = "I2C_PORT_USB_C1_TCPC";
- dynamic-speed;
- };
- c0_c2_bc12: c0_c2_bc12 {
- i2c-port = <&i2c2_0>;
- enum-names = "I2C_PORT_USB_C0_C2_PPC",
- "I2C_PORT_USB_C0_C2_BC12";
- };
- c1_bc12: c1_bc12 {
- i2c-port = <&i2c6_1>;
- enum-names = "I2C_PORT_USB_C1_PPC",
- "I2C_PORT_USB_C1_BC12";
- dynamic-speed;
- };
- retimer0_2: retimer0_2 {
- i2c-port = <&i2c3_0>;
- enum-names = "I2C_PORT_USB_C0_C2_MUX";
- };
- battery {
- i2c-port = <&i2c5_0>;
- enum-names = "I2C_PORT_BATTERY";
- };
- i2c_charger: charger {
- i2c-port = <&i2c7_0>;
- enum-names = "I2C_PORT_CHARGER",
- "I2C_PORT_EEPROM",
- "I2C_PORT_MP2964";
- };
- };
-};
-
-&i2c0_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
- pinctrl-names = "default";
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c1_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
- pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
- pinctrl-names = "default";
-
- tcpc_port0: nct38xx@70 {
- compatible = "nuvoton,nct38xx";
- reg = <0x70>;
- gpio-dev = <&nct3808_0_P1>;
- tcpc-flags = <(
- TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>;
- };
-
- nct3808_0_P1: nct3808_0_P1@70 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "nuvoton,nct38xx-gpio";
- reg = <0x70>;
- label = "NCT3808_0_P1";
-
- ioex_port1: gpio@0 {
- compatible = "nuvoton,nct38xx-gpio-port";
- reg = <0x0>;
- label = "NCT3808_0_P1_GPIO0";
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <8>;
- pin_mask = <0xdc>;
- pinmux_mask = <0xff>;
- };
- };
-
- tcpc_port2: nct38xx@74 {
- compatible = "nuvoton,nct38xx";
- reg = <0x74>;
- gpio-dev = <&nct3808_0_P2>;
- tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
- };
-
- nct3808_0_P2: nct3808_0_P2@74 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "nuvoton,nct38xx-gpio";
- reg = <0x74>;
- label = "NCT3808_0_P2";
-
- ioex_port2: gpio@0 {
- compatible = "nuvoton,nct38xx-gpio-port";
- reg = <0x0>;
- label = "NCT3808_0_P2_GPIO0";
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <8>;
- pin_mask = <0xdc>;
- pinmux_mask = <0xff>;
- };
- };
-
- nct3808_alert_1 {
- compatible = "nuvoton,nct38xx-gpio-alert";
- irq-gpios = <&gpioe 0 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
- nct38xx-dev = <&nct3808_0_P1 &nct3808_0_P2>;
- label = "NCT3808_ALERT_1";
- };
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c2_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
- pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>;
- pinctrl-names = "default";
-
- ppc_port0: syv682x@40 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x40>;
- frs_en_gpio = <&usb_c0_frs_en>;
- };
-
- bc12_port0: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- irq = <&int_usb_c0_bc12>;
- };
-
- ppc_port2: syv682x@42 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x42>;
- frs_en_gpio = <&usb_c2_frs_en>;
- };
-
- bc12_port2: pi3usb9201@5d {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5d>;
- irq = <&int_usb_c2_bc12>;
- };
-};
-
-&i2c_ctrl2 {
- status = "okay";
-};
-
-&i2c3_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
- pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
- pinctrl-names = "default";
-
- usb_c0_bb_retimer: jhl8040r-c0@56 {
- compatible = "intel,jhl8040r";
- reg = <0x56>;
- int-pin = <&usb_c0_rt_int_odl>;
- reset-pin = <&usb_c0_rt_rst_odl>;
- };
-
- usb_c2_bb_retimer: jhl8040r-c2@57 {
- compatible = "intel,jhl8040r";
- reg = <0x57>;
- int-pin = <&usb_c2_rt_int_odl>;
- reset-pin = <&usb_c2_rt_rst_odl>;
- };
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&i2c4_1 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>;
- pinctrl-names = "default";
-
- tcpc_port1: ps8xxx@b {
- compatible = "parade,ps8xxx";
- reg = <0xb>;
- tcpc-flags = <(
- TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V |
- TCPC_FLAGS_CONTROL_VCONN |
- TCPC_FLAGS_CONTROL_FRS)>;
- };
-};
-
-&i2c_ctrl4 {
- status = "okay";
-};
-
-&i2c5_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
- pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>;
- pinctrl-names = "default";
-};
-
-&i2c_ctrl5 {
- status = "okay";
-};
-
-&i2c6_1 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>;
- pinctrl-names = "default";
-
- ppc_port1: nx20p348x@72 {
- compatible = "nxp,nx20p348x";
- status = "okay";
- reg = <0x72>;
- };
-
- bc12_port1: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- irq = <&int_usb_c1_bc12>;
- };
-};
-
-&i2c_ctrl6 {
- status = "okay";
-};
-
-&i2c7_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
- pinctrl-names = "default";
-
- pmic_mp2964: pmic_mp2964@20 {
- compatible = "mps,mp2964";
- reg = <0x20>;
- label = "I2C_ADDR_MP2964_FLAGS";
- };
-
- charger: bq25710@9 {
- compatible = "ti,bq25710";
- status = "okay";
- reg = <0x9>;
- };
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
diff --git a/zephyr/projects/brya/kblight_hooks.c b/zephyr/projects/brya/kblight_hooks.c
deleted file mode 100644
index d6d795f28e..0000000000
--- a/zephyr/projects/brya/kblight_hooks.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/drivers/gpio.h>
-#include <stdbool.h>
-
-#include <ap_power/ap_power.h>
-#include "cbi.h"
-#include "hooks.h"
-
-/* Enable/Disable keyboard backlight gpio */
-static inline void kbd_backlight_enable(bool enable)
-{
- if (get_board_id() == 1)
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_id_1_ec_kb_bl_en),
- enable);
- else
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_kb_bl_en_l),
- !enable);
-}
-
-static void board_backlight_handler(struct ap_power_ev_callback *cb,
- struct ap_power_ev_data data)
-{
- bool enable;
-
- switch (data.event) {
- default:
- return;
-
- case AP_POWER_RESUME:
- /* Called on AP S3 -> S0 transition */
- enable = true;
- break;
-
- case AP_POWER_SUSPEND:
- /* Called on AP S0 -> S3 transition */
- enable = false;
- break;
- }
- kbd_backlight_enable(enable);
-}
-
-/*
- * Explicitly apply the board ID 1 *gpio.inc settings to pins that
- * were reassigned on current boards.
- */
-static void set_board_id_1_gpios(void)
-{
- static struct ap_power_ev_callback cb;
-
- /*
- * Add a callback for suspend/resume to
- * control the keyboard backlight.
- */
- ap_power_ev_init_callback(&cb, board_backlight_handler,
- AP_POWER_RESUME | AP_POWER_SUSPEND);
- ap_power_ev_add_callback(&cb);
-
- if (get_board_id() != 1)
- return;
- gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_id_1_ec_kb_bl_en),
- GPIO_OUTPUT_LOW);
-}
-DECLARE_HOOK(HOOK_INIT, set_board_id_1_gpios, HOOK_PRIO_FIRST);
diff --git a/zephyr/projects/brya/prj.conf b/zephyr/projects/brya/prj.conf
deleted file mode 100644
index 422f862809..0000000000
--- a/zephyr/projects/brya/prj.conf
+++ /dev/null
@@ -1,200 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-CONFIG_SHIMMED_TASKS=y
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-CONFIG_PLATFORM_EC_SWITCH=y
-CONFIG_LTO=y
-CONFIG_CROS_FLASH_NPCX=y
-CONFIG_CROS_SYSTEM_NPCX=y
-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_ADC_CHANNELS_RUNTIME_CONFIG=y
-
-CONFIG_KERNEL_SHELL=y
-
-# SoC configuration
-CONFIG_AP=y
-CONFIG_AP_X86_INTEL_ADL=y
-CONFIG_FPU=y
-CONFIG_ARM_MPU=y
-
-# CBI
-CONFIG_EEPROM=y
-CONFIG_EEPROM_AT24=y
-CONFIG_EEPROM_SHELL=n
-CONFIG_PLATFORM_EC_CBI_EEPROM=y
-CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
-
-# eSPI
-CONFIG_ESPI=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US=150
-
-# I2C
-CONFIG_I2C=y
-
-# Power Sequencing
-CONFIG_PLATFORM_EC_POWERSEQ=y
-CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET=y
-CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y
-CONFIG_PLATFORM_EC_POWERSEQ_S4=y
-CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
-CONFIG_PLATFORM_EC_THROTTLE_AP=y
-
-# Host command
-CONFIG_PLATFORM_EC_HOSTCMD=y
-CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET=y
-
-# Console command
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y
-
-# Sensors
-CONFIG_SENSOR=y
-CONFIG_SENSOR_SHELL=n
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_ALS=y
-CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y
-CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
-CONFIG_PLATFORM_EC_LID_ANGLE=y
-CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
-CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
-CONFIG_PLATFORM_EC_TABLET_MODE=y
-CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
-
-# Sensor Drivers
-CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y
-CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
-CONFIG_PLATFORM_EC_ALS_TCS3400=y
-
-# Fan
-CONFIG_TACH_NPCX=y
-
-# Temperature sensors
-CONFIG_PLATFORM_EC_TEMP_SENSOR=y
-CONFIG_PLATFORM_EC_THERMISTOR=y
-CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y
-
-# MKBP event
-CONFIG_PLATFORM_EC_MKBP_EVENT=y
-CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
-CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y
-
-# PMIC
-CONFIG_PLATFORM_EC_PMIC=y
-CONFIG_PLATFORM_EC_MP2964=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD=y
-CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y
-CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
-CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y
-CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
-CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
-CONFIG_PLATFORM_EC_CMD_BUTTON=n
-CONFIG_CROS_KB_RAW_NPCX=y
-
-CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y
-
-# Battery
-CONFIG_PLATFORM_EC_BATTERY=y
-CONFIG_PLATFORM_EC_BATTERY_SMART=y
-CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
-CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
-CONFIG_PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM=y
-CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
-
-# USB-C and charging
-CONFIG_PLATFORM_EC_CHARGER_BQ25720=y
-CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM=y
-CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_DV=70
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y
-CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=3
-CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC=1
-CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000
-CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15001
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10
-CONFIG_PLATFORM_EC_CHARGE_RAMP_SW=y
-CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
-CONFIG_PLATFORM_EC_USB_PID=0x504F
-CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y
-CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y
-CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=y
-CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
-CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
-CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n
-CONFIG_PLATFORM_EC_USB_MUX_TASK=y
-CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL=y
-CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=2
-CONFIG_PLATFORM_EC_USB_PD_ALT_MODE_UFP=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_REV30=y
-CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y
-CONFIG_PLATFORM_EC_USB_PD_USB4=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1715=n
-CONFIG_PLATFORM_EC_USB_PD_TCPM_TUSB422=n
-CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y
-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_CONSOLE_CMD_PPC_DUMP=n
-CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n
-CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n
-CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=y
-CONFIG_PLATFORM_EC_USB_PD_INT_SHARED=y
-CONFIG_PLATFORM_EC_USB_PD_PORT_0_SHARED=y
-CONFIG_PLATFORM_EC_USB_PD_PORT_2_SHARED=y
-
-CONFIG_SYSCON=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_COMMON=y
-CONFIG_PLATFORM_EC_LED_PWM=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_LEDTEST=n
-CONFIG_PLATFORM_EC_LED_PWM_NEAR_FULL_COLOR=4
-CONFIG_PLATFORM_EC_LED_PWM_SOC_ON_COLOR=4
-CONFIG_PLATFORM_EC_LED_PWM_SOC_SUSPEND_COLOR=4
-CONFIG_PLATFORM_EC_LED_PWM_LOW_BATT_COLOR=5
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-
-#IOEX
-CONFIG_GPIO_NCT38XX=y
-
-# TODO(b/188605676): bring these features up
-CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n
-
-# Power Sequencing
-CONFIG_PLATFORM_EC_POWERSEQ=y
-CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
-CONFIG_CHIPSET_ALDERLAKE_SLG4BD44540=y
-CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET=n
-CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y
-CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
-# Treat 2nd reset from H1 as Power-On
-CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y
-CONFIG_PLATFORM_EC_THROTTLE_AP=y
-
-# RTC
-CONFIG_PLATFORM_EC_RTC=y
diff --git a/zephyr/projects/corsola/BUILD.py b/zephyr/projects/corsola/BUILD.py
deleted file mode 100644
index 4e82ab7926..0000000000
--- a/zephyr/projects/corsola/BUILD.py
+++ /dev/null
@@ -1,139 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Define zmake projects for corsola."""
-
-# Default chip is it81202bx, some variants will use NPCX9X.
-
-
-def register_corsola_project(
- project_name,
- chip="it81202bx",
- extra_dts_overlays=(),
- extra_kconfig_files=(),
-):
- """Register a variant of corsola."""
- register_func = register_binman_project
- if chip.startswith("npcx"):
- register_func = register_npcx_project
-
- register_func(
- project_name=project_name,
- zephyr_board=chip,
- dts_overlays=[
- here / "common.dts",
- here / "power_signal.dts",
- here / "usba.dts",
- *extra_dts_overlays,
- ],
- kconfig_files=[here / "prj.conf", *extra_kconfig_files],
- )
-
-
-register_corsola_project(
- "krabby",
- extra_dts_overlays=[
- here / "adc_krabby.dts",
- here / "battery_krabby.dts",
- here / "gpio_krabby.dts",
- here / "i2c_krabby.dts",
- here / "interrupts_krabby.dts",
- here / "led_krabby.dts",
- here / "motionsense_krabby.dts",
- here / "usbc_krabby.dts",
- ],
- extra_kconfig_files=[
- here / "prj_it81202_base.conf",
- here / "prj_krabby.conf",
- ],
-)
-
-register_corsola_project(
- project_name="kingler",
- chip="npcx9m3f",
- extra_dts_overlays=[
- here / "adc_kingler.dts",
- here / "battery_kingler.dts",
- here / "host_interface_npcx.dts",
- here / "i2c_kingler.dts",
- here / "interrupts_kingler.dts",
- here / "gpio_kingler.dts",
- here / "npcx_keyboard.dts",
- here / "led_kingler.dts",
- here / "motionsense_kingler.dts",
- here / "usbc_kingler.dts",
- here / "default_gpio_pinctrl_kingler.dts",
- ],
- extra_kconfig_files=[
- here / "prj_npcx993_base.conf",
- here / "prj_kingler.conf",
- ],
-)
-
-register_corsola_project(
- project_name="steelix",
- chip="npcx9m3f",
- extra_dts_overlays=[
- here / "adc_kingler.dts",
- here / "battery_steelix.dts",
- here / "host_interface_npcx.dts",
- here / "i2c_kingler.dts",
- here / "interrupts_kingler.dts",
- here / "interrupts_steelix.dts",
- here / "cbi_steelix.dts",
- here / "gpio_steelix.dts",
- here / "npcx_keyboard.dts",
- here / "keyboard_steelix.dts",
- here / "led_steelix.dts",
- here / "motionsense_kingler.dts",
- here / "motionsense_steelix.dts",
- here / "usba_steelix.dts",
- here / "usbc_kingler.dts",
- here / "default_gpio_pinctrl_kingler.dts",
- ],
- extra_kconfig_files=[
- here / "prj_npcx993_base.conf",
- here / "prj_steelix.conf",
- ],
-)
-
-
-register_corsola_project(
- "tentacruel",
- extra_dts_overlays=[
- here / "adc_tentacruel.dts",
- here / "battery_tentacruel.dts",
- here / "cbi_tentacruel.dts",
- here / "gpio_tentacruel.dts",
- here / "i2c_tentacruel.dts",
- here / "interrupts_tentacruel.dts",
- here / "led_tentacruel.dts",
- here / "motionsense_tentacruel.dts",
- here / "usbc_tentacruel.dts",
- here / "thermistor_tentacruel.dts",
- ],
- extra_kconfig_files=[
- here / "prj_it81202_base.conf",
- here / "prj_tentacruel.conf",
- ],
-)
-
-register_corsola_project(
- "magikarp",
- extra_dts_overlays=[
- here / "adc_magikarp.dts",
- here / "battery_magikarp.dts",
- here / "cbi_magikarp.dts",
- here / "gpio_magikarp.dts",
- here / "i2c_magikarp.dts",
- here / "interrupts_magikarp.dts",
- here / "led_magikarp.dts",
- here / "motionsense_magikarp.dts",
- here / "usbc_magikarp.dts",
- ],
- extra_kconfig_files=[
- here / "prj_it81202_base.conf",
- here / "prj_magikarp.conf",
- ],
-)
diff --git a/zephyr/projects/corsola/CMakeLists.txt b/zephyr/projects/corsola/CMakeLists.txt
deleted file mode 100644
index fa899a0e77..0000000000
--- a/zephyr/projects/corsola/CMakeLists.txt
+++ /dev/null
@@ -1,81 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
-
-cros_ec_library_include_directories(include)
-
-# Include selected EC source from the baseboard
-zephyr_library_sources(
- "src/board.c"
- "src/board_chipset.c"
- "src/hibernate.c"
-)
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usbc_config.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usb_pd_policy.c")
-zephyr_library_sources_ifdef(CONFIG_VARIANT_CORSOLA_DB_DETECTION
- "src/variant_db_detection.c")
-
-if(DEFINED CONFIG_BOARD_KRABBY)
- project(krabby)
- zephyr_library_sources("src/krabby/hooks.c"
- "src/krabby/charger_workaround.c"
- "src/krabby/ppc_krabby.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/krabby/usb_pd_policy.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/krabby/usbc_config.c")
-elseif(DEFINED CONFIG_BOARD_KINGLER)
- project(kingler)
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/kingler/i2c.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON
- "src/kingler/led.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/kingler/usb_pd_policy.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/kingler/usbc_config.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG
- "src/kingler/button.c")
-elseif(DEFINED CONFIG_BOARD_STEELIX)
- project(steelix)
- zephyr_library_sources("src/kingler/board_steelix.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/kingler/i2c.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON
- "src/kingler/led_steelix.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/kingler/usb_pd_policy.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/kingler/usbc_config.c")
-
-elseif(DEFINED CONFIG_BOARD_TENTACRUEL)
- project(tentacruel)
- zephyr_library_sources("src/krabby/hooks.c"
- "src/krabby/charger_workaround.c"
- "src/krabby/sensor_tentacruel.c"
- "src/krabby/temp_tentacruel.c"
- "src/krabby/ppc_tentacruel.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/krabby/usb_pd_policy.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/krabby/usbc_config.c")
-
-elseif(DEFINED CONFIG_BOARD_MAGIKARP)
- project(magikarp)
- zephyr_library_sources("src/krabby/hooks.c"
- "src/krabby/sensor_magikarp.c"
- "src/krabby/ppc_magikarp.c"
- "src/krabby/keyboard_magikarp.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/krabby/usb_pd_policy.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/krabby/usbc_config.c")
-
-endif()
-
diff --git a/zephyr/projects/corsola/Kconfig b/zephyr/projects/corsola/Kconfig
deleted file mode 100644
index 4f66601c20..0000000000
--- a/zephyr/projects/corsola/Kconfig
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-config BOARD_KRABBY
- bool "Google Krabby Board"
- help
- Build Google Krabby reference board. Krabby has MediaTek MT8186 SoC
- with ITE it81202-bx EC.
-
-config BOARD_KINGLER
- bool "Google Kingler Board"
- help
- Build Google Kingler reference board. Krabby has MediaTek MT8186 SoC
- with NPCX993FA0BX EC.
-
-config BOARD_STEELIX
- bool "Google Steelix Board"
- help
- Build Google Steelix variant board. Steelix is a variant of Kingler
- and has MediaTek MT8186 SoC with NPCX993FA0BX EC.
-
-config BOARD_TENTACRUEL
- bool "Google Tentacruel Board"
- help
- Build Google Tentacruel variant board. Tentacruel is a variant of Krabby
- and has MediaTek MT8186 SoC with ITE it81202-bx EC.
-
-config BOARD_MAGIKARP
- bool "Google Magikarp Board"
- help
- Build Google Magikarp variant board. Magikarp is a variant of Krabby
- and has MediaTek MT8186 SoC with ITE it81202-bx EC.
-
-config VARIANT_CORSOLA_DB_DETECTION
- bool "Corsola Platform Runtime Daughter Board Detection"
- depends on PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG
- depends on PLATFORM_EC_USB_MUX_RUNTIME_CONFIG
- help
- Daughter board detection for Type-C subboard or HDMI subboard. This
- includes pin configuration and driver loading.
- default y
-
-config VARIANT_CORSOLA_USBA
- bool "Corsola Platform USB-A support"
- help
- Support Corsola USB-A related functions. Enable this function if
- it has USB-A ports.
- depends on PLATFORM_EC_USBC
- default y
-
-source "Kconfig.zephyr"
diff --git a/zephyr/projects/corsola/adc_tentacruel.dts b/zephyr/projects/corsola/adc_tentacruel.dts
deleted file mode 100644
index 1b5e849589..0000000000
--- a/zephyr/projects/corsola/adc_tentacruel.dts
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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-adc-channels {
- compatible = "named-adc-channels";
- adc_vbus_c0 {
- enum-name = "ADC_VBUS_C0";
- io-channels = <&adc0 0>;
- mul = <10>;
- };
- adc_board_id0 {
- enum-name = "ADC_BOARD_ID_0";
- io-channels = <&adc0 1>;
- };
- adc_board_id1 {
- enum-name = "ADC_BOARD_ID_1";
- io-channels = <&adc0 2>;
- };
- adc_vbus_c1 {
- enum-name = "ADC_VBUS_C1";
- io-channels = <&adc0 7>;
- mul = <10>;
- };
- adc_ambient: ambient {
- enum-name = "ADC_TEMP_SENSOR_2_AMBIENT";
- io-channels = <&adc0 5>;
- };
- };
-};
-
-&adc0 {
- status = "okay";
- pinctrl-0 = <&adc0_ch0_gpi0_default
- &adc0_ch1_gpi1_default
- &adc0_ch2_gpi2_default
- &adc0_ch5_gpi5_default
- &adc0_ch7_gpi7_default>;
- pinctrl-names = "default";
-};
-
-/ {
- temp_ambient: ambient {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>;
- adc = <&adc_ambient>;
- };
-
- named-temp-sensors {
- compatible = "cros-ec,temp-sensors";
- ambient {
- sensor = <&temp_ambient>;
- };
- temp_charger: charger {
- sensor = <&charger>;
- };
- };
-};
-
-&thermistor_3V3_30K9_47K_NCP15WB {
- status = "okay";
-};
diff --git a/zephyr/projects/corsola/battery_kingler.dts b/zephyr/projects/corsola/battery_kingler.dts
deleted file mode 100644
index b01fb8a46d..0000000000
--- a/zephyr/projects/corsola/battery_kingler.dts
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- batteries {
- default_battery: smp_l20m3pg2 {
- compatible = "smp,l20m3pg2", "battery-smart";
- };
- lgc_l20l3pg2 {
- compatible = "lgc,l20l3pg2", "battery-smart";
- };
- };
-};
diff --git a/zephyr/projects/corsola/battery_steelix.dts b/zephyr/projects/corsola/battery_steelix.dts
deleted file mode 100644
index 594c83478c..0000000000
--- a/zephyr/projects/corsola/battery_steelix.dts
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- batteries {
- default_battery: byd_l22b3pg0 {
- compatible = "byd,l22b3pg0", "battery-smart";
- };
- celxpert_l22c3pg0 {
- compatible = "celxpert,l22c3pg0", "battery-smart";
- };
- cosmx_l22x3pg0 {
- compatible = "cosmx,l22x3pg0", "battery-smart";
- };
- smp_l22m3pg0 {
- compatible = "smp,l22m3pg0", "battery-smart";
- };
- sunwoda_l22d3pg0 {
- compatible = "sunwoda,l22d3pg0", "battery-smart";
- };
- };
-};
diff --git a/zephyr/projects/corsola/cbi_steelix.dts b/zephyr/projects/corsola/cbi_steelix.dts
deleted file mode 100644
index f4918b1577..0000000000
--- a/zephyr/projects/corsola/cbi_steelix.dts
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- steelix-fw-config {
- compatible = "cros-ec,cbi-fw-config";
-
- /*
- * FW_CONFIG field to indicate the device is clamshell
- * or convertible.
- */
- form_factor {
- enum-name = "FORM_FACTOR";
- start = <13>;
- size = <3>;
-
- convertible {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "CONVERTIBLE";
- value = <1>;
- };
- clamshell {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "CLAMSHELL";
- value = <0>;
- };
- };
-
- /* FW_CONFIG field to indicate which DB is attached. */
- db_config: db {
- enum-name = "DB";
- start = <0>;
- size = <4>;
-
- sub-board-1 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "DB_NONE";
- value = <0>;
- };
- sub-board-2 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "DB_USBA_HDMI";
- value = <1>;
- };
- sub-board-3 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "DB_USBA_HDMI_LTE";
- value = <2>;
- };
- };
- };
-
- /* Steelix-specific ssfc fields. */
- steelix-ssfc {
- compatible = "named-cbi-ssfc";
-
- /* SSFC field to identify BASE motion sensor. */
- base-sensor {
- enum-name = "BASE_SENSOR";
- size = <3>;
-
- base_sensor_0: bmi323 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
- value = <1>;
- default;
- };
- base_sensor_1: lsm6dsm {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
- value = <2>;
- };
- };
-
- /* SSFC field to identify LID motion sensor. */
- lid-sensor {
- enum-name = "LID_SENSOR";
- size = <3>;
-
- lid_sensor_0: bma422 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
- value = <1>;
- default;
- };
- lid_sensor_1: lis2dw12 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
- value = <2>;
- };
- };
- };
-};
diff --git a/zephyr/projects/corsola/gpio_steelix.dts b/zephyr/projects/corsola/gpio_steelix.dts
deleted file mode 100644
index 14120e6d7d..0000000000
--- a/zephyr/projects/corsola/gpio_steelix.dts
+++ /dev/null
@@ -1,255 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- aliases {
- gpio-cbi-wp = &gpio_ec_cbi_wp;
- gpio-wp = &gpio_ec_wp_l;
- gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- /*
- * In npcx9 series, gpio46, gpio47, and the whole gpio5 port
- * belong to VHIF power well. On steelix, it is connencted to
- * 1.8V.
- */
- base_imu_int_l: base_imu_int_l {
- gpios = <&gpio5 6 GPIO_INPUT>;
- };
- spi_ap_clk_ec {
- gpios = <&gpio5 5 GPIO_INPUT>;
- };
- spi_ap_cs_ec_l {
- gpios = <&gpio5 3 GPIO_INPUT>;
- };
- spi_ap_do_ec_di {
- gpios = <&gpio4 6 GPIO_INPUT>;
- };
- spi_ap_di_ec_do {
- gpios = <&gpio4 7 GPIO_INPUT>;
- };
- ap_ec_warm_rst_req: ap_ec_warm_rst_req {
- gpios = <&gpio5 1 (GPIO_INPUT | GPIO_ACTIVE_HIGH)>;
- enum-name = "GPIO_AP_EC_WARM_RST_REQ";
- };
- ap_ec_wdtrst_l: ap_ec_wdtrst_l {
- gpios = <&gpio5 2 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
- enum-name = "GPIO_AP_EC_WDTRST_L";
- };
- ap_in_sleep_l: ap_in_sleep_l {
- gpios = <&gpio5 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
- enum-name = "GPIO_AP_IN_SLEEP_L";
- };
- gpio_en_ulp: en_ulp {
- gpios = <&gpioc 6 GPIO_OUTPUT_LOW>;
- };
- en_ec_id_odl {
- gpios = <&gpio7 6 GPIO_ODR_HIGH>;
- };
- sys_rst_odl {
- gpios = <&gpioc 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_SYS_RST_ODL";
- };
- ec_i2c_sensor_scl {
- gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec_i2c_sensor_sda {
- gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec_i2c_usb_c0_scl {
- gpios = <&gpio9 0 GPIO_INPUT>;
- };
- ec_i2c_usb_c0_sda {
- gpios = <&gpio8 7 GPIO_INPUT>;
- };
- ec_i2c_usb_c1_scl {
- gpios = <&gpio9 2 GPIO_INPUT>;
- };
- ec_i2c_usb_c1_sda {
- gpios = <&gpio9 1 GPIO_INPUT>;
- };
- ec_i2c_pwr_cbi_scl {
- gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec_i2c_pwr_cbi_sda {
- gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec_i2c_batt_scl {
- gpios = <&gpio3 3 GPIO_INPUT>;
- };
- ec_i2c_batt_sda {
- gpios = <&gpio3 6 GPIO_INPUT>;
- };
- en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus_x {
- gpios = <&gpiof 5 GPIO_OUTPUT_LOW>;
- };
- usb_a1_fault_odl {
- gpios = <&gpiof 4 GPIO_INPUT>;
- };
- ec_pen_chg_dis_odl {
- gpios = <&gpioe 4 GPIO_INPUT>;
- };
- gpio_ec_cbi_wp: ec_cbi_wp {
- gpios = <&gpio8 0 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_wp_l: ec_wp_odl {
- gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW |
- GPIO_VOLTAGE_1P8)>;
- };
- lid_accel_int_l {
- gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- gpio_tablet_mode_l: tablet_mode_l {
- gpios = <&gpiob 2 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- };
- ec_ap_int_odl {
- gpios = <&gpioc 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_EC_INT_L";
- };
- gpio_ec_kso_02_inv: ec_kso_02_inv {
- gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
- };
- gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl {
- gpios = <&gpio8 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_BC12_INT_ODL";
- };
- ec_entering_rw {
- gpios = <&gpio0 3 GPIO_OUTPUT_LOW>;
- };
- charger_prochot_odl {
- gpios = <&gpiob 1 GPIO_INPUT>;
- };
- ec_rst_odl {
- gpios = <&gpio7 7 GPIO_INPUT>;
- };
- gpio_lid_open: lid_open {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- };
- gpio_acok_od: acok_od {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- };
- gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- };
- gpio_en_5v_usm: en_5v_usm {
- gpios = <&gpio0 2 GPIO_OUTPUT_LOW>;
- };
- packet_mode_en {
- gpios = <&gpio7 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_PACKET_MODE_EN";
- };
- gpio_x_ec_gpio2: x_ec_gpio2 {
- gpios = <&gpiod 4 GPIO_INPUT>;
- };
- /*
- * In npcx9 series, gpio93-97, the whole gpioa port, and gpiob0
- * belong to VSPI power well. On steelix, it is connencted to
- * 1.8V.
- */
- ap_sysrst_odl_r: ap_sysrst_odl_r {
- gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
- enum-name = "GPIO_AP_EC_SYSRST_ODL";
- };
- gpio_ap_xhci_init_done: ap_xhci_init_done {
- gpios = <&gpioa 3 GPIO_INPUT>;
- };
- gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl {
- gpios = <&gpio6 7 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PPC_INT_ODL";
- };
- pg_pp5000_z2_od {
- gpios = <&gpio7 0 GPIO_INPUT>;
- };
- gpio_ec_x_gpio1: ec_x_gpio1 {
- gpios = <&gpio6 2 GPIO_OUTPUT_LOW>;
- };
- dp_aux_path_sel: dp_aux_path_sel {
- gpios = <&gpio6 3 GPIO_OUTPUT_HIGH>;
- };
- gpio_ec_bl_en_od: ec_bl_en_od {
- gpios = <&gpio4 0 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>;
- };
- gpio_ec_x_gpio3: ec_x_gpio3 {
- gpios = <&gpiod 3 GPIO_OUTPUT_LOW>;
- };
- gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl {
- gpios = <&gpio7 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_TCPC_INT_ODL";
- };
- gpio_usb_c0_tcpc_rst: usb_c0_tcpc_rst {
- gpios = <&gpioc 0 GPIO_OUTPUT_LOW>;
- };
- en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus {
- gpios = <&gpio6 0 GPIO_OUTPUT_LOW>;
- };
- gpio_hdmi_prsnt_odl: hdmi_prsnt_odl {
- gpios = <&gpio3 7 GPIO_INPUT>;
- };
- en_pp5000_z2 {
- gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>;
- };
- gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl {
- gpios = <&gpioe 1 GPIO_INPUT>;
- };
- ec_batt_pres_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- };
- usb_a0_fault_odl {
- gpios = <&gpioc 7 GPIO_INPUT>;
- };
- ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl {
- gpios = <&gpio6 1 GPIO_ODR_HIGH>;
- };
- ec_pmic_en_odl {
- gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_EC_PMIC_EN_ODL";
- };
- gpio_ec_volup_btn_odl: ec_volup_btn_odl {
- gpios = <&gpiod 5 GPIO_INPUT>;
- enum-name = "GPIO_VOLUME_UP_L";
- };
- gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
- gpios = <&gpioe 2 GPIO_INPUT>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- };
- gpio_ccd_mode_odl: ccd_mode_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- };
- /* unimplemented GPIOs */
- entering-rw {
- enum-name = "GPIO_ENTERING_RW";
- };
- };
-
- /*
- * aliases for sub-board GPIOs
- */
- aliases {
- gpio-en-hdmi-pwr = &gpio_ec_x_gpio1;
- gpio-usb-c1-frs-en = &gpio_ec_x_gpio1;
- gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2;
- gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2;
- gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3;
- gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3;
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-irqs = <
- &int_ac_present
- &int_power_button
- &int_lid_open
- >;
- };
-};
diff --git a/zephyr/projects/corsola/i2c_krabby.dts b/zephyr/projects/corsola/i2c_krabby.dts
deleted file mode 100644
index a5dc03b655..0000000000
--- a/zephyr/projects/corsola/i2c_krabby.dts
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c_krabby_tentacruel.dtsi"
-
-&i2c0 {
- charger: rt9490@53 {
- compatible = "richtek,rt9490";
- status = "okay";
- reg = <0x53>;
- };
-};
-
-&i2c4 {
- tusb1064_mux_1: tusb1064-mux-1@44 {
- compatible = "ti,tusb1064";
- reg = <0x44>;
- board-init = "tusb1064_mux_1_board_init";
- };
-};
diff --git a/zephyr/projects/corsola/i2c_krabby_tentacruel.dtsi b/zephyr/projects/corsola/i2c_krabby_tentacruel.dtsi
deleted file mode 100644
index 6fd153e1fa..0000000000
--- a/zephyr/projects/corsola/i2c_krabby_tentacruel.dtsi
+++ /dev/null
@@ -1,138 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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";
-
- battery {
- i2c-port = <&i2c1>;
- remote-port = <1>;
- enum-names = "I2C_PORT_BATTERY",
- "I2C_PORT_VIRTUAL_BATTERY";
- };
- i2c_charger: charger {
- i2c-port = <&i2c0>;
- enum-names = "I2C_PORT_CHARGER",
- "I2C_PORT_EEPROM";
- };
- i2c_sensor: sensor {
- i2c-port = <&i2c3>;
- enum-names = "I2C_PORT_SENSOR";
- };
- i2c_usb_c0: usb-c0 {
- i2c-port = <&i2c2>;
- enum-names = "I2C_PORT_USB_C0",
- "I2C_PORT_USB_MUX0";
- };
- i2c_usb_c1: usb-c1 {
- i2c-port = <&i2c4>;
- enum-names = "I2C_PORT_USB_C1",
- "I2C_PORT_USB_MUX1";
- };
- };
-
-};
-
-&pinctrl {
- i2c3_clk_gpf2_sleep: i2c3_clk_gpf2_sleep {
- pinmuxs = <&pinctrlf 2 IT8XXX2_ALT_DEFAULT>;
- };
- i2c3_data_gpf3_sleep: i2c3_data_gpf3_sleep {
- pinmuxs = <&pinctrlf 3 IT8XXX2_ALT_DEFAULT>;
- };
-};
-
-&i2c0 {
- /* EC_I2C_PWR_CBI */
- label = "I2C_PWR_CBI";
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c0_clk_gpb3_default
- &i2c0_data_gpb4_default>;
- pinctrl-names = "default";
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
-
- bc12_port1: rt9490-bc12@53 {
- compatible = "richtek,rt9490-bc12";
- status = "okay";
- reg = <0x53>;
- irq = <&int_usb_c1_bc12_charger>;
- };
-};
-
-&i2c1 {
- /* EC_I2C_BATTERY */
- label = "I2C_BATTERY";
- status = "okay";
- clock-frequency = <50000>;
- pinctrl-0 = <&i2c1_clk_gpc1_default
- &i2c1_data_gpc2_default>;
- pinctrl-names = "default";
- fifo-enable;
-};
-
-&i2c2 {
- /* EC_I2C_USB_C0 */
- label = "I2C_USB_C0";
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c2_clk_gpf6_default
- &i2c2_data_gpf7_default>;
- pinctrl-names = "default";
- /delete-property/ fifo-enable;
-
- bc12_ppc_port0: rt1739@70 {
- compatible = "richtek,rt1739";
- status = "okay";
- reg = <0x70>;
- };
-
- it5205_mux_0: it5205-mux-0@48 {
- compatible = "ite,it5205";
- reg = <0x48>;
- };
-};
-
-&i2c3 {
- /* EC_I2C_SENSOR */
- label = "I2C_SENSOR";
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- scl-gpios = <&gpiof 2 0>;
- sda-gpios = <&gpiof 3 0>;
- pinctrl-0 = <&i2c3_clk_gpf2_default
- &i2c3_data_gpf3_default>;
- pinctrl-1 = <&i2c3_clk_gpf2_sleep
- &i2c3_data_gpf3_sleep>;
- pinctrl-names = "default", "sleep";
- prescale-scl-low = <1>;
-};
-
-&i2c4 {
- /* EC_I2C_USB_C1 */
- label = "I2C_USB_C1";
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c4_clk_gpe0_default
- &i2c4_data_gpe7_default>;
- pinctrl-names = "default";
- prescale-scl-low = <1>;
-
- ppc_port1: syv682x@40 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x40>;
- frs_en_gpio = <&gpio_ec_x_gpio1>;
- };
-};
diff --git a/zephyr/projects/corsola/i2c_magikarp.dts b/zephyr/projects/corsola/i2c_magikarp.dts
deleted file mode 100644
index fbf5ed6337..0000000000
--- a/zephyr/projects/corsola/i2c_magikarp.dts
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c_krabby_tentacruel.dtsi"
-
-&i2c0 {
- charger: rt9490@53 {
- compatible = "richtek,rt9490";
- status = "okay";
- reg = <0x53>;
- };
-};
-
-&i2c2 {
- bc12_port0: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- irq = <&int_usb_c0_bc12>;
- };
- ppc_port0: syv682x@40 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x40>;
- frs_en_gpio = <&usb_c0_frs_en>;
- };
-};
-
-&i2c4 {
- ps8743_mux_1: ps8743-mux-1@10 {
- compatible = "parade,ps8743";
- reg = <0x10>;
- };
-};
diff --git a/zephyr/projects/corsola/i2c_tentacruel.dts b/zephyr/projects/corsola/i2c_tentacruel.dts
deleted file mode 100644
index a635adcf5c..0000000000
--- a/zephyr/projects/corsola/i2c_tentacruel.dts
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c_krabby_tentacruel.dtsi"
-
-&i2c0 {
- charger: rt9490@53 {
- compatible = "richtek,rt9490";
- status = "okay";
- reg = <0x53>;
- thermistor = <&thermistor_rt9490>;
- };
-};
-
-&i2c2 {
- bc12_port0: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- irq = <&int_usb_c0_bc12>;
- };
- ppc_port0: syv682x@40 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x40>;
- frs_en_gpio = <&usb_c0_frs_en>;
- };
-};
-
-&i2c4 {
- ps8743_mux_1: ps8743-mux-1@10 {
- compatible = "parade,ps8743";
- reg = <0x10>;
- board-init = "ps8743_eq_c1_setting";
- };
-};
diff --git a/zephyr/projects/corsola/include/baseboard_usbc_config.h b/zephyr/projects/corsola/include/baseboard_usbc_config.h
deleted file mode 100644
index 66610fec5e..0000000000
--- a/zephyr/projects/corsola/include/baseboard_usbc_config.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Corsola daughter board detection */
-
-#ifndef __CROS_EC_BASEBOARD_USBC_CONFIG_H
-#define __CROS_EC_BASEBOARD_USBC_CONFIG_H
-
-#include "gpio.h"
-
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S
-#define GPIO_EN_USB_C1_SINK RT1718S_GPIO1
-#define GPIO_EN_USB_C1_SOURCE RT1718S_GPIO2
-#define GPIO_EN_USB_C1_FRS RT1718S_GPIO3
-#endif
-
-void ppc_interrupt(enum gpio_signal signal);
-void ccd_interrupt(enum gpio_signal signal);
-
-/* USB-A ports */
-enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_COUNT };
-
-/* USB-C ports */
-enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
-BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT);
-
-/**
- * Is the port fine to be muxed its DisplayPort lines?
- *
- * Only one port can be muxed to DisplayPort at a time.
- *
- * @param port Port number of TCPC.
- * @return 1 is fine; 0 is bad as other port is already muxed;
- */
-int corsola_is_dp_muxable(int port);
-
-#endif /* __CROS_EC_BASEBOARD_USBC_CONFIG_H */
diff --git a/zephyr/projects/corsola/include/variant_db_detection.h b/zephyr/projects/corsola/include/variant_db_detection.h
deleted file mode 100644
index 285ff327f2..0000000000
--- a/zephyr/projects/corsola/include/variant_db_detection.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Corsola daughter board detection */
-
-#ifndef __CROS_EC_CORSOLA_DB_DETECTION_H
-#define __CROS_EC_CORSOLA_DB_DETECTION_H
-
-enum corsola_db_type {
- CORSOLA_DB_UNINIT = -1,
- CORSOLA_DB_NONE,
- CORSOLA_DB_TYPEC,
- CORSOLA_DB_HDMI,
- CORSOLA_DB_COUNT,
-};
-
-#ifdef CONFIG_VARIANT_CORSOLA_DB_DETECTION
-/*
- * Get the connected daughterboard type.
- *
- * @return The daughterboard type.
- */
-enum corsola_db_type corsola_get_db_type(void);
-#else
-inline enum corsola_db_type corsola_get_db_type(void)
-{
- return CORSOLA_DB_NONE;
-};
-#endif /* CONFIG_VARIANT_CORSOLA_DB_DETECTION */
-
-#endif /* __CROS_EC_CORSOLA_DB_DETECTION_H */
diff --git a/zephyr/projects/corsola/interrupts_steelix.dts b/zephyr/projects/corsola/interrupts_steelix.dts
deleted file mode 100644
index 816beb95f4..0000000000
--- a/zephyr/projects/corsola/interrupts_steelix.dts
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-&int_base_imu {
- irq-pin = <&base_imu_int_l>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "motion_interrupt";
-};
diff --git a/zephyr/projects/corsola/keyboard_steelix.dts b/zephyr/projects/corsola/keyboard_steelix.dts
deleted file mode 100644
index 9a0dca3e05..0000000000
--- a/zephyr/projects/corsola/keyboard_steelix.dts
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- cros-keyscan {
- compatible = "cros-keyscan";
-
- debounce-down = <15000>;
- debounce-up = <15000>;
-
- actual-key-mask = <
- 0x1c /* C0 */
- 0xff /* C1 */
- 0xff /* C2 */
- 0xff /* C3 */
- 0xff /* C4 */
- 0xf5 /* C5 */
- 0xff /* C6 */
- 0xa4 /* C7 */
- 0xff /* C8 */
- 0xfe /* C9 */
- 0x55 /* C10 */
- 0xfa /* C11 */
- 0xca /* C12 */
- >;
- };
-};
diff --git a/zephyr/projects/corsola/led_it81202_base.dtsi b/zephyr/projects/corsola/led_it81202_base.dtsi
deleted file mode 100644
index dce7bb4f95..0000000000
--- a/zephyr/projects/corsola/led_it81202_base.dtsi
+++ /dev/null
@@ -1,184 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include <dt-bindings/battery.h>
-
-/ {
- led_colors: led-colors {
- compatible = "cros-ec,led-policy";
-
- bat-power-state-charge {
- charge-state = "PWR_STATE_CHARGE";
-
- color-0 {
- led-color = <&color_battery_amber>;
- };
- };
-
- bat-power-state-near-full {
- charge-state = "PWR_STATE_CHARGE_NEAR_FULL";
-
- color-0 {
- led-color = <&color_battery_white>;
- };
- };
-
- bat-power-state-discharge {
- charge-state = "PWR_STATE_DISCHARGE";
-
- color-0 {
- led-color = <&color_battery_off>;
- };
- };
-
- bat-power-state-discharge-s0-bat-low {
- charge-state = "PWR_STATE_DISCHARGE";
- chipset-state = "POWER_S0";
- batt-lvl = <BATTERY_LEVEL_EMPTY BATTERY_LEVEL_LOW>;
-
- color-0 {
- led-color = <&color_battery_amber>;
- period-ms = <1000>;
- };
-
- color-1 {
- led-color = <&color_battery_off>;
- period-ms = <3000>;
- };
- };
-
- bat-power-state-error {
- charge-state = "PWR_STATE_ERROR";
-
- color-0 {
- led-color = <&color_battery_amber>;
- period-ms = <1000>;
- };
-
- color-1 {
- led-color = <&color_battery_off>;
- period-ms = <1000>;
- };
- };
-
- pwr-power-state-off {
- color-0 {
- led-color = <&color_power_off>;
- };
- };
-
- pwr-power-state-on {
- chipset-state = "POWER_S0";
-
- color-0 {
- led-color = <&color_power_white>;
- };
- };
-
- pwr-power-state-s3 {
- chipset-state = "POWER_S3";
-
- color-0 {
- led-color = <&color_power_white>;
- period-ms = <1000>;
- };
-
- color-1 {
- led-color = <&color_power_off>;
- period-ms = <3000>;
- };
- };
- };
-
- pwmleds {
- compatible = "cros-ec,pwm-pin-config";
-
- /* NOTE: &pwm number needs same with channel number */
- led_power_white: ec_led1_odl {
- #led-pin-cells = <1>;
- pwms = <&pwm0
- PWM_CHANNEL_0
- PWM_HZ(324)
- PWM_POLARITY_INVERTED>;
- };
- led_battery_amber: ec_led2_odl {
- #led-pin-cells = <1>;
- pwms = <&pwm1
- PWM_CHANNEL_1
- PWM_HZ(324)
- PWM_POLARITY_INVERTED>;
- };
- led_battery_white: ec_led3_odl {
- #led-pin-cells = <1>;
- pwms = <&pwm2
- PWM_CHANNEL_2
- PWM_HZ(324)
- PWM_POLARITY_INVERTED>;
- };
- };
-
- pwm-led-pins {
- compatible = "cros-ec,pwm-led-pins";
-
- color_power_off: color-power-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_POWER_LED";
- led-pins = <&led_power_white 0>;
- };
-
- color_power_white: color-power-white {
- led-color = "LED_WHITE";
- br-color = "EC_LED_COLOR_WHITE";
- led-id = "EC_LED_ID_POWER_LED";
- led-pins = <&led_power_white 100>;
- };
-
- color_battery_off: color-battery-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&led_battery_amber 0>,
- <&led_battery_white 0>;
- };
-
- color_battery_amber: color-battery-amber {
- led-color = "LED_AMBER";
- br-color = "EC_LED_COLOR_AMBER";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&led_battery_amber 100>,
- <&led_battery_white 0>;
- };
-
- color_battery_white: color-battery-white {
- led-color = "LED_WHITE";
- br-color = "EC_LED_COLOR_WHITE";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&led_battery_amber 0>,
- <&led_battery_white 100>;
- };
- };
-};
-
-/* LED1 */
-&pwm0 {
- status = "okay";
- prescaler-cx = <PWM_PRESCALER_C4>;
- pinctrl-0 = <&pwm0_gpa0_default>;
- pinctrl-names = "default";
-};
-
-/* LED2 */
-&pwm1 {
- status = "okay";
- prescaler-cx = <PWM_PRESCALER_C4>;
- pinctrl-0 = <&pwm1_gpa1_default>;
- pinctrl-names = "default";
-};
-
-/* LED3 */
-&pwm2 {
- status = "okay";
- prescaler-cx = <PWM_PRESCALER_C4>;
- pinctrl-0 = <&pwm2_gpa2_default>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/corsola/led_kingler.dts b/zephyr/projects/corsola/led_kingler.dts
deleted file mode 100644
index 92f6c4d4fe..0000000000
--- a/zephyr/projects/corsola/led_kingler.dts
+++ /dev/null
@@ -1,71 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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 = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED
- &pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED
- &pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
- };
- };
-
- cros-pwmleds {
- compatible = "cros-ec,pwm-leds";
-
- leds = <&pwm_led0>;
-
- color-map-red = <100 0 0>;
- color-map-green = < 0 100 0>;
- color-map-amber = <100 20 0>;
-
- brightness-range = <255 255 0 0 0 255>;
-
- #address-cells = <1>;
- #size-cells = <0>;
-
- pwm_led_0@0 {
- reg = <0>;
- ec-led-name = "EC_LED_ID_BATTERY_LED";
- };
- };
-};
-
-/* Red LED */
-&pwm0_gpc3 {
- drive-open-drain;
-};
-
-&pwm0 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm0_gpc3>;
- pinctrl-names = "default";
-};
-
-/* Green LED */
-&pwm1_gpc2 {
- drive-open-drain;
-};
-
-&pwm1 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm1_gpc2>;
- pinctrl-names = "default";
-};
-
-/* Blue LED */
-&pwm2_gpc4 {
- drive-open-drain;
-};
-
-&pwm2 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm2_gpc4>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/corsola/led_magikarp.dts b/zephyr/projects/corsola/led_magikarp.dts
deleted file mode 100644
index 0e2b0aca52..0000000000
--- a/zephyr/projects/corsola/led_magikarp.dts
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "led_it81202_base.dtsi"
-
-/ {
- led_colors: led-colors {
- compatible = "cros-ec,led-policy";
-
- /* Magikarp LED bat charge */
- bat-power-state-charge {
- charge-state = "PWR_STATE_CHARGE";
- /* Battery percent range (>= Empty, <= 94%) */
- batt-lvl = <BATTERY_LEVEL_EMPTY
- (BATTERY_LEVEL_NEAR_FULL - 3)>;
- color-0 {
- led-color = <&color_battery_amber>;
- };
- };
-
- bat-power-state-charge-near-full {
- charge-state = "PWR_STATE_CHARGE";
- /* Battery percent range (>= 95%, <= Full) */
- batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2)
- BATTERY_LEVEL_FULL>;
- color-0 {
- led-color = <&color_battery_white>;
- };
- };
-
- /* Magikarp LED bat discharge */
- bat-power-state-discharge-s0 {
- charge-state = "PWR_STATE_DISCHARGE";
- chipset-state = "POWER_S0";
- /* Battery percent range (>= 11%, <= Full) */
- batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>;
-
- color-0 {
- led-color = <&color_battery_white>;
- };
- };
-
-
- bat-power-state-discharge-s0-bat-low {
- charge-state = "PWR_STATE_DISCHARGE";
- chipset-state = "POWER_S0";
- /* Battery percent range (>= Empty, <= 10%) */
- batt-lvl = <BATTERY_LEVEL_EMPTY BATTERY_LEVEL_LOW>;
-
- color-0 {
- led-color = <&color_battery_amber>;
- period-ms = <1000>;
- };
-
- color-1 {
- led-color = <&color_battery_off>;
- period-ms = <3000>;
- };
- };
-
- bat-power-state-discharge-s3 {
- charge-state = "PWR_STATE_DISCHARGE";
- chipset-state = "POWER_S3";
-
- color-0 {
- led-color = <&color_battery_white>;
- period-ms = <1000>;
- };
-
- color-1 {
- led-color = <&color_battery_off>;
- period-ms = <3000>;
- };
- };
-
- bat-power-state-discharge-s5 {
- charge-state = "PWR_STATE_DISCHARGE";
- chipset-state = "POWER_S5";
- color-0 {
- led-color = <&color_battery_off>;
- };
- };
-
- /* Magikarp LED bat error */
- bat-power-state-error {
- charge-state = "PWR_STATE_ERROR";
- chipset-state = "POWER_S0";
-
- color-0 {
- led-color = <&color_battery_amber>;
- period-ms = <1000>;
- };
-
- color-1 {
- led-color = <&color_battery_off>;
- period-ms = <1000>;
- };
- };
-
- bat-power-state-error-s3 {
- charge-state = "PWR_STATE_ERROR";
- chipset-state = "POWER_S3";
-
- color-0 {
- led-color = <&color_battery_white>;
- period-ms = <1000>;
- };
-
- color-1 {
- led-color = <&color_battery_off>;
- period-ms = <3000>;
- };
- };
-
- bat-power-state-error-s5 {
- charge-state = "PWR_STATE_ERROR";
- chipset-state = "POWER_S5";
-
- color-0 {
- led-color = <&color_battery_off>;
- };
- };
- };
-
- pwm-led-pins {
- compatible = "cros-ec,pwm-led-pins";
-
- /* Overwrite Power LED white to off */
- color_power_white: color-power-white {
- led-color = "LED_WHITE";
- led-id = "EC_LED_ID_POWER_LED";
- led-pins = <&led_power_white 0>;
- };
- };
-};
diff --git a/zephyr/projects/corsola/led_steelix.dts b/zephyr/projects/corsola/led_steelix.dts
deleted file mode 100644
index 6a25929327..0000000000
--- a/zephyr/projects/corsola/led_steelix.dts
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- pwmleds {
- compatible = "pwm-leds";
- led_battery_red: ec_led1_odl {
- pwms = <&pwm0 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
- };
- led_battery_green: ec_led2_odl {
- pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
- };
- led_power_white: ec_led3_odl {
- pwms = <&pwm4 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
- };
- };
-};
-
-/* Red LED */
-&pwm0_gpc3 {
- drive-open-drain;
-};
-
-&pwm0 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm0_gpc3>;
- pinctrl-names = "default";
-};
-
-/* Green LED */
-&pwm1_gpc2 {
- drive-open-drain;
-};
-
-&pwm1 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm1_gpc2>;
- pinctrl-names = "default";
-};
-
-/* White LED */
-&pwm4_gpb6 {
- drive-open-drain;
-};
-
-&pwm4 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm4_gpb6>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/corsola/led_tentacruel.dts b/zephyr/projects/corsola/led_tentacruel.dts
deleted file mode 100644
index 5569a956f6..0000000000
--- a/zephyr/projects/corsola/led_tentacruel.dts
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include "led_it81202_base.dtsi"
-
-/ {
- led_colors: led-colors {
- compatible = "cros-ec,led-policy";
-
- /* Tentacruel LED bat charge */
- bat-power-state-charge {
- charge-state = "PWR_STATE_CHARGE";
- /* Battery percent range (>= Empty, <= 94%) */
- batt-lvl = <BATTERY_LEVEL_EMPTY
- (BATTERY_LEVEL_NEAR_FULL - 3)>;
- color-0 {
- led-color = <&color_battery_amber>;
- };
- };
-
- bat-power-state-charge-near-full {
- charge-state = "PWR_STATE_CHARGE";
- /* Battery percent range (>= 95%, <= Full) */
- batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2)
- BATTERY_LEVEL_FULL>;
- color-0 {
- led-color = <&color_battery_white>;
- };
- };
-
- /* Tentacruel LED bat discharge */
- bat-power-state-discharge {
- charge-state = "PWR_STATE_DISCHARGE";
- chipset-state = "POWER_S0";
- /* Battery percent range (>= 11%, <= Full) */
- batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>;
-
- color-0 {
- led-color = <&color_battery_white>;
- };
- };
-
- bat-power-state-discharge-s3 {
- charge-state = "PWR_STATE_DISCHARGE";
- chipset-state = "POWER_S3";
-
- color-0 {
- led-color = <&color_battery_white>;
- period-ms = <1000>;
- };
-
- color-1 {
- led-color = <&color_battery_off>;
- period-ms = <3000>;
- };
- };
-
- bat-power-state-discharge-s5 {
- charge-state = "PWR_STATE_DISCHARGE";
- chipset-state = "POWER_S5";
- color-0 {
- led-color = <&color_battery_off>;
- };
- };
-
- /* Tentacruel LED bat error */
- bat-power-state-error {
- charge-state = "PWR_STATE_ERROR";
- chipset-state = "POWER_S0";
-
- color-0 {
- led-color = <&color_battery_amber>;
- period-ms = <1000>;
- };
-
- color-1 {
- led-color = <&color_battery_off>;
- period-ms = <1000>;
- };
- };
-
- bat-power-state-error-s3 {
- charge-state = "PWR_STATE_ERROR";
- chipset-state = "POWER_S3";
-
- color-0 {
- led-color = <&color_battery_white>;
- period-ms = <1000>;
- };
-
- color-1 {
- led-color = <&color_battery_off>;
- period-ms = <3000>;
- };
- };
-
- bat-power-state-error-s5 {
- charge-state = "PWR_STATE_ERROR";
- chipset-state = "POWER_S5";
-
- color-0 {
- led-color = <&color_battery_off>;
- };
- };
- };
-
- pwm-led-pins {
- compatible = "cros-ec,pwm-led-pins";
-
- /* Overwrite Power LED white to off */
- color_power_white: color-power-white {
- led-color = "LED_WHITE";
- led-id = "EC_LED_ID_POWER_LED";
- led-pins = <&led_power_white 0>;
- };
- };
-};
diff --git a/zephyr/projects/corsola/motionsense_steelix.dts b/zephyr/projects/corsola/motionsense_steelix.dts
deleted file mode 100644
index df96fc2e42..0000000000
--- a/zephyr/projects/corsola/motionsense_steelix.dts
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <dt-bindings/motionsense/utils.h>
-
-/* inherit the rot_ref from Kingler and overwrite it */
-&lid_rot_ref {
- mat33 = <0 1 0
- 1 0 0
- 0 0 (-1)>;
-};
-
-&base_rot_ref {
- mat33 = <1 0 0
- 0 (-1) 0
- 0 0 (-1)>;
-};
-
-/ {
- aliases {
- /*
- * motion sense's <>_INT_EVENT is handled
- * by alias. Using the alias, each driver creates
- * its own <>_INT_EVENT.
- */
- lsm6dsm-int = &base_accel;
- };
-
- /* Rotation matrix used by drivers. */
- motionsense-rotation-ref {
- compatible = "cros-ec,motionsense-rotation-ref";
- base_rot_ref_lsm6dsm: base-rotation-ref-lsm6dsm {
- mat33 = <0 1 0
- 1 0 0
- 0 0 (-1)>;
- };
- };
-
- /*
- * Driver specific data. A driver-specific data can be shared with
- * different motion sensors while they are using the same driver.
- *
- * If a node's compatible starts with "cros-ec,accelgyro-", it is for
- * a common structure defined in accelgyro.h.
- * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
- * "struct als_drv_data_t" in accelgyro.h
- */
- motionsense-sensor-data {
- lis2dw12_data: lis2dw12-drv-data {
- compatible = "cros-ec,drvdata-lis2dw12";
- status = "okay";
- };
- lsm6dsm_data_accel: lsm6dsm-accel-drv-data {
- compatible = "cros-ec,drvdata-lsm6dsm";
- status = "okay";
- };
- lsm6dsm_data_gyro: lsm6dsm-gyro-drv-data {
- compatible = "cros-ec,drvdata-lsm6dsm";
- status = "okay";
- };
- };
-
- motionsense-sensor-alt {
- alt_lid_accel: alt-lid-accel {
- compatible = "cros-ec,lis2dw12";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_LID";
- mutex = <&lid_mutex>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&lid_rot_ref>;
- default-range = <2>;
- drv-data = <&lis2dw12_data>;
- i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS";
- alternate-for = <&lid_accel>;
- alternate-ssfc-indicator = <&lid_sensor_1>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(12500 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- odr = <(12500 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- alt_base_accel: alt-base-accel {
- compatible = "cros-ec,lsm6dsm-accel";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref_lsm6dsm>;
- drv-data = <&lsm6dsm_data_accel>;
- alternate-for = <&base_accel>;
- alternate-ssfc-indicator = <&base_sensor_1>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(12500 | ROUND_UP_FLAG)>;
- ec-rate = <(100 * USEC_PER_MSEC)>;
- };
- ec-s3 {
- odr = <(12500 | ROUND_UP_FLAG)>;
- ec-rate = <0>;
- };
- };
- };
-
- alt_base_gyro: alt-base-gyro {
- compatible = "cros-ec,lsm6dsm-gyro";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref_lsm6dsm>;
- default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */
- drv-data = <&lsm6dsm_data_gyro>;
- alternate-for = <&base_gyro>;
- alternate-ssfc-indicator = <&base_sensor_1>;
- };
- };
-};
diff --git a/zephyr/projects/corsola/power_signal.dts b/zephyr/projects/corsola/power_signal.dts
deleted file mode 100644
index 181d7cf96e..0000000000
--- a/zephyr/projects/corsola/power_signal.dts
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- power_signal_list: power-signal-list {
- compatible = "mt8186,power-signal-list";
- ap_in_rst {
- power-enum-name = "AP_IN_RST";
- power-gpio-pin = <&ap_sysrst_odl_r>;
- };
- ap_in_s3 {
- power-enum-name = "AP_IN_S3";
- power-gpio-pin = <&ap_in_sleep_l>;
- };
- ap_wdt_asserted {
- power-enum-name = "AP_WDT_ASSERTED";
- power-gpio-pin = <&ap_ec_wdtrst_l>;
- };
- ap_warm_rst_req {
- power-enum-name = "AP_WARM_RST_REQ";
- power-gpio-pin = <&ap_ec_warm_rst_req>;
- };
- };
-};
diff --git a/zephyr/projects/corsola/prj.conf b/zephyr/projects/corsola/prj.conf
deleted file mode 100644
index 110b91bbbb..0000000000
--- a/zephyr/projects/corsola/prj.conf
+++ /dev/null
@@ -1,101 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-#
-
-# http://google3/hardware/standards/usb/
-CONFIG_PLATFORM_EC_USB_PID=0x505C
-
-# CROS EC
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-CONFIG_PLATFORM_EC_SWITCH=y
-CONFIG_SHIMMED_TASKS=y
-
-# AP SoC configuration
-CONFIG_AP=y
-CONFIG_AP_ARM_MTK_MT8186=y
-
-# Variant config
-CONFIG_VARIANT_CORSOLA_DB_DETECTION=y
-
-# Shell features
-CONFIG_KERNEL_SHELL=y
-CONFIG_SHELL_HELP=y
-CONFIG_SHELL_HISTORY=y
-CONFIG_SHELL_TAB=y
-CONFIG_SHELL_TAB_AUTOCOMPLETION=y
-
-# CBI
-CONFIG_EEPROM=y
-CONFIG_EEPROM_AT24=y
-CONFIG_EEPROM_SHELL=n
-CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
-CONFIG_PLATFORM_EC_CBI_EEPROM=y
-
-# I2C
-CONFIG_I2C=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD=y
-CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y
-CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
-
-# MKBP
-CONFIG_PLATFORM_EC_MKBP_EVENT=y
-CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
-CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y
-
-# EFS2
-CONFIG_PLATFORM_EC_VBOOT_EFS2=y
-
-# USB
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
-CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n
-CONFIG_PLATFORM_EC_USB_PD_USB4=n
-CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB_CUSTOM_HOOK=y
-
-# USB-C
-CONFIG_PLATFORM_EC_USBC=y
-CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y
-CONFIG_PLATFORM_EC_USB_PD_DPS=y
-CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y
-CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO_CUSTOM=y
-CONFIG_PLATFORM_EC_USB_PD_FRS=y
-
-# Power Seq
-CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-CONFIG_PLATFORM_EC_POWERSEQ=y
-CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y
-CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
-CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
-
-# Optional features
-CONFIG_FLASH_SHELL=n
-
-# EEPROM
-CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
-
-# Host Commands
-CONFIG_PLATFORM_EC_HOSTCMD=y
-
-# Battery
-CONFIG_PLATFORM_EC_BATTERY=y
-CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
-CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
-CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
-CONFIG_PLATFORM_EC_BATTERY_SMART=y
-CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV=9000
-CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y
-CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y
-
-# Charger
-CONFIG_PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201=y
-CONFIG_PLATFORM_EC_CHARGER=y
-CONFIG_PLATFORM_EC_CHARGE_MANAGER=y
-
-# Button
-CONFIG_PLATFORM_EC_CMD_BUTTON=y
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
diff --git a/zephyr/projects/corsola/prj_it81202_base.conf b/zephyr/projects/corsola/prj_it81202_base.conf
deleted file mode 100644
index 04283bcf5c..0000000000
--- a/zephyr/projects/corsola/prj_it81202_base.conf
+++ /dev/null
@@ -1,93 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Bring up options
-CONFIG_SHELL_HISTORY_BUFFER=256
-CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
-CONFIG_PLATFORM_EC_BRINGUP=y
-
-# Power Sequencing
-CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y
-
-# Lid Switch
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-
-# Charger
-CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y
-CONFIG_PLATFORM_EC_CHARGER_RT9490=y
-CONFIG_PLATFORM_EC_CHARGER_MAINTAIN_VBAT=y
-CONFIG_PLATFORM_EC_CHARGER_PSYS=y
-CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y
-# BOARD_RS2
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
-# BOARD_RS1
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20
-CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y
-
-# Host Commands
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y
-CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_DT=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-
-# Sensors
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
-CONFIG_PLATFORM_EC_LID_ANGLE=y
-CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
-CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
-CONFIG_PLATFORM_EC_TABLET_MODE=y
-CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
-CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000
-
-# Sensor Drivers
-CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
-CONFIG_PLATFORM_EC_ACCELGYRO_ICM42607=y
-CONFIG_PLATFORM_EC_ACCELGYRO_ICM_COMM_I2C=y
-
-# Tasks
-CONFIG_TASK_CHARGER_STACK_SIZE=1024
-CONFIG_TASK_CHIPSET_STACK_SIZE=1440
-CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1024
-CONFIG_TASK_PD_STACK_SIZE=1280
-
-# USB-A
-CONFIG_PLATFORM_EC_USBA=y
-
-# USB-C
-CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n
-CONFIG_PLATFORM_EC_USBC_PPC_RT1739=y
-CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y
-CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y
-CONFIG_PLATFORM_EC_USB_MUX_IT5205=y
-CONFIG_PLATFORM_EC_USB_MUX_TUSB546=y
-CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT=y
-CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n
-CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=0
-CONFIG_PLATFORM_EC_USB_PD_PULLUP=1
-
-CONFIG_PLATFORM_EC_SHA256_UNROLLED=y
-
-# TODO(b/180980668): bring these features up
-CONFIG_LTO=n
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
diff --git a/zephyr/projects/corsola/prj_kingler.conf b/zephyr/projects/corsola/prj_kingler.conf
deleted file mode 100644
index d7de991e93..0000000000
--- a/zephyr/projects/corsola/prj_kingler.conf
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Variant config
-CONFIG_BOARD_KINGLER=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_PWM=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y
diff --git a/zephyr/projects/corsola/prj_magikarp.conf b/zephyr/projects/corsola/prj_magikarp.conf
deleted file mode 100644
index a5ec9ede3b..0000000000
--- a/zephyr/projects/corsola/prj_magikarp.conf
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Variant config
-CONFIG_BOARD_MAGIKARP=y
-
-# USB-C
-CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
-CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n
-CONFIG_PLATFORM_EC_USB_MUX_PS8743=y
-CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
-CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
-
-# Sensor
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
-
-# Temperature sensors
-CONFIG_PLATFORM_EC_TEMP_SENSOR=y
-CONFIG_PLATFORM_EC_THERMISTOR=y
-
-# Battery
-CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
diff --git a/zephyr/projects/corsola/prj_npcx993_base.conf b/zephyr/projects/corsola/prj_npcx993_base.conf
deleted file mode 100644
index 0642bcd331..0000000000
--- a/zephyr/projects/corsola/prj_npcx993_base.conf
+++ /dev/null
@@ -1,95 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-
-# Bring up options
-CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
-
-# Debug options and features; can be disabled to save memory or once bringup
-# is complete.
-CONFIG_SHELL_MINIMAL=n
-CONFIG_LOG=y
-CONFIG_LOG_MODE_MINIMAL=y
-
-# ADC
-CONFIG_ADC=y
-
-# Charger
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
-CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y
-CONFIG_PLATFORM_EC_CHARGER_PSYS=y
-CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20
-CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-
-# LED
-CONFIG_PLATFORM_EC_LED_COMMON=y
-CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y
-
-# Math
-CONFIG_PLATFORM_EC_MATH_UTIL=y
-
-# Power sequencing
-CONFIG_PLATFORM_EC_POWERSEQ_MT8186=y
-CONFIG_PLATFORM_EC_POWERSEQ_S4=n
-
-# Button
-CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y
-
-# Sensors
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
-CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
-CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
-CONFIG_PLATFORM_EC_LID_ANGLE=y
-CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
-CONFIG_PLATFORM_EC_TABLET_MODE=y
-CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
-
-# USBA
-CONFIG_PLATFORM_EC_USBA=y
-
-# USBC
-CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
-CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n
-CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_OFF_DELAY=15000
-CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_ON_DELAY=15000
-CONFIG_PLATFORM_EC_USBC_PPC=y
-CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y
-CONFIG_PLATFORM_EC_USBC_PPC_RT1718S=y
-CONFIG_PLATFORM_EC_USB_MUX_PS8743=y
-CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
-CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL=y
-CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=2
-CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447_AUX_PU_PD=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_BY_BOARD=y
-
-# External power
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-
-# Keyboard
-CONFIG_CROS_KB_RAW_NPCX=y
-CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y
-
-CONFIG_SYSCON=y
-
-CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n
diff --git a/zephyr/projects/corsola/prj_steelix.conf b/zephyr/projects/corsola/prj_steelix.conf
deleted file mode 100644
index 7a854b1313..0000000000
--- a/zephyr/projects/corsola/prj_steelix.conf
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Variant config
-CONFIG_BOARD_STEELIX=y
-
-# steelix only use D2, drop the workaround config for H1
-CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n
-
-# Motion sensor
-CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
-CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSM=y
-CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
-CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
-CONFIG_PLATFORM_EC_KEYBOARD_STRICT_DEBOUNCE=y
-
-# USBC
-CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3250
-CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000
-
-# Remove bring up options for FW QUAL
-CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n
-
-# Remove debug options and features for FW QUAL
-CONFIG_LOG=n
-CONFIG_LOG_MODE_MINIMAL=n
-CONFIG_SHELL_MINIMAL=y
-CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=0
diff --git a/zephyr/projects/corsola/prj_tentacruel.conf b/zephyr/projects/corsola/prj_tentacruel.conf
deleted file mode 100644
index 71cc9d9694..0000000000
--- a/zephyr/projects/corsola/prj_tentacruel.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Variant config
-CONFIG_BOARD_TENTACRUEL=y
-
-# USB-C
-CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
-CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n
-CONFIG_PLATFORM_EC_USB_MUX_PS8743=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
-CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
-
-# Sensor
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
-
-# Temperature sensors
-CONFIG_PLATFORM_EC_TEMP_SENSOR=y
-CONFIG_PLATFORM_EC_THERMISTOR=y
-
-# Battery
-CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y
diff --git a/zephyr/projects/corsola/src/board.c b/zephyr/projects/corsola/src/board.c
deleted file mode 100644
index 93a2443191..0000000000
--- a/zephyr/projects/corsola/src/board.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "console.h"
-#include "hooks.h"
-#include "typec_control.h"
-#include "usb_dp_alt_mode.h"
-#include "usb_mux.h"
-#include "usb_pd.h"
-#include "usbc_ppc.h"
-
-#include "baseboard_usbc_config.h"
-
-#define CPRINTS(format, args...) cprints(CC_USB, format, ##args)
-
-static void ccd_interrupt_deferred(void)
-{
- /*
- * If CCD_MODE_ODL asserts, it means there's a debug accessory connected
- * and we should enable the SBU FETs.
- */
- typec_set_sbu(CONFIG_CCD_USBC_PORT_NUMBER, 1);
-
- /* Mux DP AUX away when CCD enabled to prevent the AUX channel
- * interferes the SBU pins.
- */
- CPRINTS("CCD Enabled, mux DP_AUX_PATH_SEL to 1");
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), 1);
-}
-DECLARE_DEFERRED(ccd_interrupt_deferred);
-
-void ccd_interrupt(enum gpio_signal signal)
-{
- hook_call_deferred(&ccd_interrupt_deferred_data, 0);
-}
diff --git a/zephyr/projects/corsola/src/board_chipset.c b/zephyr/projects/corsola/src/board_chipset.c
deleted file mode 100644
index 54e96bc631..0000000000
--- a/zephyr/projects/corsola/src/board_chipset.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Corsola baseboard-chipset specific configuration */
-
-#include <zephyr/init.h>
-#include <ap_power/ap_power.h>
-#include <zephyr/drivers/gpio.h>
-#include "gpio.h"
-
-static void board_backlight_handler(struct ap_power_ev_callback *cb,
- struct ap_power_ev_data data)
-{
- int value;
-
- switch (data.event) {
- default:
- return;
-
- case AP_POWER_RESUME:
- /* Called on AP S3 -> S0 transition */
- value = 1;
- break;
-
- case AP_POWER_SUSPEND:
- /* Called on AP S0 -> S3 transition */
- value = 0;
- break;
- }
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_bl_en_od), value);
-}
-
-static int install_backlight_handler(const struct device *unused)
-{
- static struct ap_power_ev_callback cb;
-
- /*
- * Add a callback for suspend/resume to
- * control the keyboard backlight.
- */
- ap_power_ev_init_callback(&cb, board_backlight_handler,
- AP_POWER_RESUME | AP_POWER_SUSPEND);
- ap_power_ev_add_callback(&cb);
- return 0;
-}
-
-SYS_INIT(install_backlight_handler, APPLICATION, 1);
diff --git a/zephyr/projects/corsola/src/hibernate.c b/zephyr/projects/corsola/src/hibernate.c
deleted file mode 100644
index 56c085e077..0000000000
--- a/zephyr/projects/corsola/src/hibernate.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include <zephyr/drivers/gpio.h>
-
-#include "charger.h"
-#include "driver/charger/isl923x_public.h"
-#include "system.h"
-
-/* Corsola board specific hibernate implementation */
-__override void board_hibernate(void)
-{
-#ifdef CONFIG_CHARGER_ISL9238C
- isl9238c_hibernate(CHARGER_SOLO);
-#endif
-}
-
-__override void board_hibernate_late(void)
-{
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_ulp), 1);
-}
diff --git a/zephyr/projects/corsola/src/kingler/board_steelix.c b/zephyr/projects/corsola/src/kingler/board_steelix.c
deleted file mode 100644
index 8b88a6d7c7..0000000000
--- a/zephyr/projects/corsola/src/kingler/board_steelix.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Board re-init for Rusty board
- * Rusty shares the firmware with Steelix.
- * Steelix is convertible but Rusty is clamshell
- * so some functions should be disabled for clamshell.
- */
-#include <zephyr/logging/log.h>
-#include <zephyr/drivers/gpio.h>
-
-#include "accelgyro.h"
-#include "common.h"
-#include "cros_cbi.h"
-#include "driver/accelgyro_bmi3xx.h"
-#include "driver/accelgyro_lsm6dsm.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "motion_sense.h"
-#include "motionsense_sensors.h"
-#include "tablet_mode.h"
-
-LOG_MODULE_REGISTER(board_init, LOG_LEVEL_ERR);
-
-static bool board_is_clamshell;
-
-static void board_setup_init(void)
-{
- int ret;
- uint32_t val;
-
- ret = cros_cbi_get_fw_config(FORM_FACTOR, &val);
- if (ret != 0) {
- LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR);
- return;
- }
- if (val == CLAMSHELL) {
- board_is_clamshell = true;
- motion_sensor_count = 0;
- gmr_tablet_switch_disable();
- }
-}
-DECLARE_HOOK(HOOK_INIT, board_setup_init, HOOK_PRIO_PRE_DEFAULT);
-
-static void disable_base_imu_irq(void)
-{
- if (board_is_clamshell) {
- gpio_disable_dt_interrupt(
- GPIO_INT_FROM_NODELABEL(int_base_imu));
- gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(base_imu_int_l),
- GPIO_INPUT | GPIO_PULL_UP);
- }
-}
-DECLARE_HOOK(HOOK_INIT, disable_base_imu_irq, HOOK_PRIO_POST_DEFAULT);
-
-static bool base_use_alt_sensor;
-
-void motion_interrupt(enum gpio_signal signal)
-{
- if (base_use_alt_sensor) {
- lsm6dsm_interrupt(signal);
- } else {
- bmi3xx_interrupt(signal);
- }
-}
-
-static void alt_sensor_init(void)
-{
- base_use_alt_sensor = cros_cbi_ssfc_check_match(
- CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1)));
-
- motion_sensors_check_ssfc();
-}
-DECLARE_HOOK(HOOK_INIT, alt_sensor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/projects/corsola/src/kingler/i2c.c b/zephyr/projects/corsola/src/kingler/i2c.c
deleted file mode 100644
index f2bbff3749..0000000000
--- a/zephyr/projects/corsola/src/kingler/i2c.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c/i2c.h"
-#include "i2c.h"
-
-/* Kingler and Steelix board specific i2c implementation */
-
-#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
-int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc)
-{
- return (i2c_get_device_for_port(cmd_desc->port) ==
- i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY) ||
- i2c_get_device_for_port(cmd_desc->port) ==
- i2c_get_device_for_port(I2C_PORT_EEPROM) ||
- i2c_get_device_for_port(cmd_desc->port) ==
- i2c_get_device_for_port(I2C_PORT_USB_C0));
-}
-#endif
diff --git a/zephyr/projects/corsola/src/kingler/led_steelix.c b/zephyr/projects/corsola/src/kingler/led_steelix.c
deleted file mode 100644
index 87b76128e8..0000000000
--- a/zephyr/projects/corsola/src/kingler/led_steelix.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Battery LED control for Steelix
- */
-
-#include <zephyr/drivers/pwm.h>
-#include <zephyr/logging/log.h>
-
-#include "board_led.h"
-#include "common.h"
-#include "cros_cbi.h"
-#include "led_common.h"
-#include "led_onoff_states.h"
-#include "util.h"
-
-LOG_MODULE_REGISTER(board_led, LOG_LEVEL_ERR);
-
-#define BOARD_LED_PWM_PERIOD_NS BOARD_LED_HZ_TO_PERIOD_NS(100)
-
-static const struct board_led_pwm_dt_channel board_led_battery_red =
- BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_battery_red));
-static const struct board_led_pwm_dt_channel board_led_battery_green =
- BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_battery_green));
-static const struct board_led_pwm_dt_channel board_led_power_white =
- BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_power_white));
-
-__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_RED,
- LED_INDEFINITE } },
- [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER,
- LED_INDEFINITE } },
- [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN,
- LED_INDEFINITE } },
- [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } },
- [STATE_DISCHARGE_S0_BAT_LOW] = { { LED_OFF, LED_INDEFINITE } },
- [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } },
- [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } },
- [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC },
- { LED_OFF, 1 * LED_ONE_SEC } },
- [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC },
- { EC_LED_COLOR_GREEN,
- 2 * LED_ONE_SEC } },
- };
-
-__override const struct led_descriptor
- led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = {
- [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } },
- [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE,
- 3 * LED_ONE_SEC },
- { LED_OFF, 0.5 * LED_ONE_SEC } },
- [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE,
- 3 * LED_ONE_SEC },
- { LED_OFF,
- 0.5 * LED_ONE_SEC } },
- [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } },
- };
-
-const enum ec_led_id supported_led_ids[] = {
- EC_LED_ID_BATTERY_LED,
- EC_LED_ID_POWER_LED,
-};
-
-const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-
-static void board_led_pwm_set_duty(const struct board_led_pwm_dt_channel *ch,
- int percent)
-{
- uint32_t pulse_ns;
- int rv;
-
- if (!device_is_ready(ch->dev)) {
- LOG_ERR("PWM device %s not ready", ch->dev->name);
- return;
- }
-
- pulse_ns = DIV_ROUND_NEAREST(BOARD_LED_PWM_PERIOD_NS * percent, 100);
-
- LOG_DBG("Board LED PWM %s set percent (%d), pulse %d", ch->dev->name,
- percent, pulse_ns);
-
- rv = pwm_set(ch->dev, ch->channel, BOARD_LED_PWM_PERIOD_NS, pulse_ns,
- ch->flags);
- if (rv) {
- LOG_ERR("pwm_set() failed %s (%d)", ch->dev->name, rv);
- }
-}
-
-static bool device_is_clamshell(void)
-{
- int ret;
- uint32_t val;
-
- ret = cros_cbi_get_fw_config(FORM_FACTOR, &val);
- if (ret != 0) {
- LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR);
- return false;
- }
-
- return val == CLAMSHELL;
-}
-
-__override void led_set_color_battery(enum ec_led_colors color)
-{
- switch (color) {
- case EC_LED_COLOR_RED:
- board_led_pwm_set_duty(&board_led_battery_red, 100);
- board_led_pwm_set_duty(&board_led_battery_green, 0);
- break;
- case EC_LED_COLOR_GREEN:
- board_led_pwm_set_duty(&board_led_battery_red, 0);
- board_led_pwm_set_duty(&board_led_battery_green, 100);
- break;
- case EC_LED_COLOR_AMBER:
- board_led_pwm_set_duty(&board_led_battery_red, 100);
- board_led_pwm_set_duty(&board_led_battery_green, 20);
- break;
- default: /* LED_OFF and other unsupported colors */
- board_led_pwm_set_duty(&board_led_battery_red, 0);
- board_led_pwm_set_duty(&board_led_battery_green, 0);
- break;
- }
-}
-
-__override void led_set_color_power(enum ec_led_colors color)
-{
- if (device_is_clamshell()) {
- board_led_pwm_set_duty(&board_led_power_white, 0);
- } else {
- switch (color) {
- case EC_LED_COLOR_WHITE:
- board_led_pwm_set_duty(&board_led_power_white, 100);
- break;
- default:
- board_led_pwm_set_duty(&board_led_power_white, 0);
- 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_RED] = 1;
- brightness_range[EC_LED_COLOR_GREEN] = 1;
- brightness_range[EC_LED_COLOR_AMBER] = 1;
- } else if (led_id == EC_LED_ID_POWER_LED) {
- if (device_is_clamshell()) {
- brightness_range[EC_LED_COLOR_WHITE] = 0;
- } else {
- 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_RED] != 0) {
- led_set_color_battery(EC_LED_COLOR_RED);
- } else if (brightness[EC_LED_COLOR_GREEN] != 0) {
- led_set_color_battery(EC_LED_COLOR_GREEN);
- } else if (brightness[EC_LED_COLOR_AMBER] != 0) {
- led_set_color_battery(EC_LED_COLOR_AMBER);
- } else {
- led_set_color_battery(LED_OFF);
- }
- } else if (led_id == EC_LED_ID_POWER_LED) {
- if (brightness[EC_LED_COLOR_WHITE] != 0) {
- led_set_color_power(EC_LED_COLOR_WHITE);
- } else {
- led_set_color_power(LED_OFF);
- }
- }
-
- return EC_SUCCESS;
-}
diff --git a/zephyr/projects/corsola/src/kingler/usb_pd_policy.c b/zephyr/projects/corsola/src/kingler/usb_pd_policy.c
deleted file mode 100644
index 3de2857ad1..0000000000
--- a/zephyr/projects/corsola/src/kingler/usb_pd_policy.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "charge_manager.h"
-#include "console.h"
-#include "driver/ppc/rt1718s.h"
-#include "system.h"
-#include "usb_mux.h"
-#include "usb_pd.h"
-#include "usbc_ppc.h"
-#include "util.h"
-
-#include "baseboard_usbc_config.h"
-
-#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-void pd_power_supply_reset(int port)
-{
- int prev_en;
-
- prev_en = ppc_is_sourcing_vbus(port);
-
- if (port == USBC_PORT_C1) {
- rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SOURCE, 0);
- }
-
- /* Disable VBUS. */
- ppc_vbus_source_enable(port, 0);
-
- /* Enable discharge if we were previously sourcing 5V */
- if (prev_en) {
- pd_set_vbus_discharge(port, 1);
- }
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- int rv;
-
- /* Disable charging. */
- rv = ppc_vbus_sink_enable(port, 0);
- if (rv) {
- return rv;
- }
-
- pd_set_vbus_discharge(port, 0);
-
- /* Provide Vbus. */
- if (port == USBC_PORT_C1) {
- rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SOURCE, 1);
- }
-
- rv = ppc_vbus_source_enable(port, 1);
- if (rv) {
- return rv;
- }
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS;
-}
-
-int pd_snk_is_vbus_provided(int port)
-{
- /* TODO: use ADC? */
- return tcpm_check_vbus_level(port, VBUS_PRESENT);
-}
diff --git a/zephyr/projects/corsola/src/kingler/usbc_config.c b/zephyr/projects/corsola/src/kingler/usbc_config.c
deleted file mode 100644
index 8c0ca86454..0000000000
--- a/zephyr/projects/corsola/src/kingler/usbc_config.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Kingler board-specific USB-C configuration */
-
-#include "charger.h"
-#include "console.h"
-#include "driver/bc12/pi3usb9201_public.h"
-#include "driver/charger/isl923x_public.h"
-#include "driver/ppc/nx20p348x.h"
-#include "driver/ppc/rt1718s.h"
-#include "driver/tcpm/anx7447.h"
-#include "driver/tcpm/rt1718s.h"
-#include "driver/usb_mux/ps8743.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "timer.h"
-#include "usb_charge.h"
-#include "usb_mux.h"
-#include "usb_pd_tcpm.h"
-#include "usbc_ppc.h"
-
-#include "baseboard_usbc_config.h"
-#include "variant_db_detection.h"
-
-/* TODO(b/220196310): Create GPIO driver for RT17181S TCPC */
-#ifdef __REQUIRE_ZEPHYR_GPIOS__
-#undef __REQUIRE_ZEPHYR_GPIOS__
-#endif
-#include "gpio.h"
-
-#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
-
-/* USB Mux */
-
-/* USB Mux C1 : board_init of PS8743 */
-int ps8743_mux_1_board_init(const struct usb_mux *me)
-{
- ps8743_tune_usb_eq(me, PS8743_USB_EQ_TX_3_6_DB,
- PS8743_USB_EQ_RX_16_0_DB);
-
- return EC_SUCCESS;
-}
-
-void board_usb_mux_init(void)
-{
- if (corsola_get_db_type() == CORSOLA_DB_TYPEC) {
- /* Disable DCI function. This is not needed for ARM. */
- ps8743_field_update(usb_muxes[1].mux, PS8743_REG_DCI_CONFIG_2,
- PS8743_AUTO_DCI_MODE_MASK,
- PS8743_AUTO_DCI_MODE_FORCE_USB);
- }
-}
-DECLARE_HOOK(HOOK_INIT, board_usb_mux_init, HOOK_PRIO_INIT_I2C + 1);
-
-void board_tcpc_init(void)
-{
- /* Only reset TCPC if not sysjump */
- if (!system_jumped_late()) {
- /* TODO(crosbug.com/p/61098): How long do we need to wait? */
- board_reset_pd_mcu();
- }
-
- /* Enable TCPC interrupts */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc));
- if (corsola_get_db_type() == CORSOLA_DB_TYPEC) {
- gpio_enable_dt_interrupt(
- GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc));
- }
-
- /* Enable BC1.2 interrupts. */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12));
-
- /*
- * Initialize HPD to low; after sysjump SOC needs to see
- * HPD pulse to enable video path
- */
- for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) {
- usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
- }
-}
-DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C);
-
-__override int board_rt1718s_init(int port)
-{
- static bool gpio_initialized;
-
- if (!system_jumped_late() && !gpio_initialized) {
- /* set GPIO 1~3 as push pull, as output, output low. */
- rt1718s_gpio_set_flags(port, RT1718S_GPIO1, GPIO_OUT_LOW);
- rt1718s_gpio_set_flags(port, RT1718S_GPIO2, GPIO_OUT_LOW);
- rt1718s_gpio_set_flags(port, RT1718S_GPIO3, GPIO_OUT_LOW);
- gpio_initialized = true;
- }
-
- /* gpio1 low, gpio2 output high when receiving frs signal */
- RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_GPIO1_VBUS_CTRL,
- RT1718S_GPIO1_VBUS_CTRL_FRS_RX_VBUS,
- 0));
- RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_GPIO2_VBUS_CTRL,
- RT1718S_GPIO2_VBUS_CTRL_FRS_RX_VBUS,
- 0xFF));
-
- /* Trigger GPIO 1/2 change when FRS signal received */
- RETURN_ERROR(rt1718s_update_bits8(
- port, RT1718S_FRS_CTRL3,
- RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO2 |
- RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO1,
- RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO2 |
- RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO1));
- /* Set FRS signal detect time to 46.875us */
- RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_FRS_CTRL1,
- RT1718S_FRS_CTRL1_FRSWAPRX_MASK,
- 0xFF));
-
- /* Disable BC1.2 SRC mode */
- RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_RT2_BC12_SRC_FUNC,
- RT1718S_RT2_BC12_SRC_FUNC_BC12_SRC_EN,
- 0));
-
- return EC_SUCCESS;
-}
-
-__override int board_rt1718s_set_frs_enable(int port, int enable)
-{
- if (port == USBC_PORT_C1)
- /*
- * Use set_flags (implemented by a single i2c write) instead
- * of set_level (= i2c_update) to save one read operation in
- * FRS path.
- */
- rt1718s_gpio_set_flags(port, GPIO_EN_USB_C1_FRS,
- enable ? GPIO_OUT_HIGH : GPIO_OUT_LOW);
- return EC_SUCCESS;
-}
-
-void board_reset_pd_mcu(void)
-{
- CPRINTS("Resetting TCPCs...");
- /* reset C0 ANX3447 */
- /* Assert reset */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst), 1);
- msleep(1);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst), 0);
- /* After TEST_R release, anx7447/3447 needs 2ms to finish eFuse
- * loading.
- */
- msleep(2);
-
- /* reset C1 RT1718s */
- rt1718s_sw_reset(USBC_PORT_C1);
-}
-
-/* Used by Vbus discharge common code with CONFIG_USB_PD_DISCHARGE */
-int board_vbus_source_enabled(int port)
-{
- return ppc_is_sourcing_vbus(port);
-}
-
-__override int board_rt1718s_set_snk_enable(int port, int enable)
-{
- if (port == USBC_PORT_C1) {
- rt1718s_gpio_set_level(port, GPIO_EN_USB_C1_SINK, enable);
- }
-
- return EC_SUCCESS;
-}
-
-int board_set_active_charge_port(int port)
-{
- int i;
- bool is_valid_port =
- (port >= 0 && port < board_get_usb_pd_port_count());
-
- if (!is_valid_port && port != CHARGE_PORT_NONE) {
- return EC_ERROR_INVAL;
- }
-
- if (port == CHARGE_PORT_NONE) {
- CPRINTS("Disabling all charger ports");
-
- /* Disable all ports. */
- for (i = 0; i < board_get_usb_pd_port_count(); i++) {
- /*
- * Do not return early if one fails otherwise we can
- * get into a boot loop assertion failure.
- */
- if (ppc_vbus_sink_enable(i, 0)) {
- CPRINTS("Disabling C%d as sink failed.", i);
- }
- }
-
- return EC_SUCCESS;
- }
-
- /* Check if the port is sourcing VBUS. */
- if (ppc_is_sourcing_vbus(port)) {
- CPRINTS("Skip enable C%d", port);
- return EC_ERROR_INVAL;
- }
-
- CPRINTS("New charge port: C%d", port);
-
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < board_get_usb_pd_port_count(); i++) {
- if (i == port) {
- continue;
- }
-
- if (ppc_vbus_sink_enable(i, 0)) {
- CPRINTS("C%d: sink path disable failed.", i);
- }
- }
-
- /* Enable requested charge port. */
- if (ppc_vbus_sink_enable(port, 1)) {
- CPRINTS("C%d: sink path enable failed.", port);
- return EC_ERROR_UNKNOWN;
- }
-
- return EC_SUCCESS;
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
-
- if (!gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl))) {
- if (!gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst))) {
- status |= PD_STATUS_TCPC_ALERT_0;
- }
- }
-
- if (!gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl))) {
- return status |= PD_STATUS_TCPC_ALERT_1;
- }
- return status;
-}
-
-void tcpc_alert_event(enum gpio_signal signal)
-{
- int port;
-
- switch (signal) {
- case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_tcpc_int_odl)):
- port = 0;
- break;
- case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c1_tcpc_int_odl)):
- port = 1;
- break;
- default:
- return;
- }
-
- schedule_deferred_pd_interrupt(port);
-}
-
-void ppc_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_ppc_int_odl)):
- ppc_chips[0].drv->interrupt(0);
- break;
- case GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl)):
- ppc_chips[1].drv->interrupt(1);
- break;
- default:
- break;
- }
-}
-
-void bc12_interrupt(enum gpio_signal signal)
-{
- usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
-}
-
-__override int board_get_vbus_voltage(int port)
-{
- int voltage = 0;
- int rv;
-
- switch (port) {
- case USBC_PORT_C0:
- rv = tcpc_config[USBC_PORT_C0].drv->get_vbus_voltage(port,
- &voltage);
- if (rv)
- return 0;
- break;
- case USBC_PORT_C1:
- rt1718s_get_adc(port, RT1718S_ADC_VBUS1, &voltage);
- break;
- default:
- return 0;
- }
- return voltage;
-}
-
-__override int board_nx20p348x_init(int port)
-{
- int rv;
-
- rv = i2c_update8(ppc_chips[port].i2c_port,
- ppc_chips[port].i2c_addr_flags,
- NX20P348X_DEVICE_CONTROL_REG, NX20P348X_CTRL_LDO_SD,
- MASK_SET);
- return rv;
-}
diff --git a/zephyr/projects/corsola/src/krabby/charger_workaround.c b/zephyr/projects/corsola/src/krabby/charger_workaround.c
deleted file mode 100644
index d7fd05cc00..0000000000
--- a/zephyr/projects/corsola/src/krabby/charger_workaround.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/sys/util.h>
-
-#include "charger.h"
-#include "driver/charger/rt9490.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "system.h"
-
-/*
- * This workaround and the board id checks only apply to krabby and early
- * tentacruel devices.
- * Newer project should have all of these fixed.
- */
-BUILD_ASSERT(IS_ENABLED(CONFIG_BOARD_KRABBY) ||
- IS_ENABLED(CONFIG_BOARD_TENTACRUEL) || IS_ENABLED(CONFIG_TEST));
-
-/* b/194967754#comment5: work around for IBUS ADC unstable issue */
-static void ibus_adc_workaround(void)
-{
- if (system_get_board_version() != 0) {
- return;
- }
-
- i2c_update8(chg_chips[CHARGER_SOLO].i2c_port,
- chg_chips[CHARGER_SOLO].i2c_addr_flags,
- RT9490_REG_ADC_CHANNEL0, RT9490_VSYS_ADC_DIS, MASK_SET);
-
- rt9490_enable_hidden_mode(CHARGER_SOLO, true);
- /* undocumented registers... */
- i2c_write8(chg_chips[CHARGER_SOLO].i2c_port,
- chg_chips[CHARGER_SOLO].i2c_addr_flags, 0x52, 0xC4);
-
- i2c_update8(chg_chips[CHARGER_SOLO].i2c_port,
- chg_chips[CHARGER_SOLO].i2c_addr_flags,
- RT9490_REG_ADC_CHANNEL0, RT9490_VSYS_ADC_DIS, MASK_CLR);
- rt9490_enable_hidden_mode(CHARGER_SOLO, false);
-}
-
-/* b/214880220#comment44: lock i2c at 400khz */
-static void i2c_speed_workaround(void)
-{
- if (system_get_board_version() >= 3) {
- return;
- }
-
- rt9490_enable_hidden_mode(CHARGER_SOLO, true);
- /* Set to Auto mode, default run at 400kHz */
- i2c_write8(chg_chips[CHARGER_SOLO].i2c_port,
- chg_chips[CHARGER_SOLO].i2c_addr_flags, 0x71, 0x22);
- /* Manually select for 400kHz, valid only when 0x71[7] == 1 */
- i2c_write8(chg_chips[CHARGER_SOLO].i2c_port,
- chg_chips[CHARGER_SOLO].i2c_addr_flags, 0xF7, 0x14);
- rt9490_enable_hidden_mode(CHARGER_SOLO, false);
-}
-
-static void eoc_deglitch_workaround(void)
-{
- if (system_get_board_version() != 1) {
- return;
- }
-
- /* set end-of-charge deglitch time to 2ms */
- i2c_update8(chg_chips[CHARGER_SOLO].i2c_port,
- chg_chips[CHARGER_SOLO].i2c_addr_flags,
- RT9490_REG_ADD_CTRL0, RT9490_TD_EOC, MASK_CLR);
-}
-
-static void disable_safety_timer(void)
-{
- if (system_get_board_version() >= 2) {
- return;
- }
- /* Disable charge timer */
- i2c_write8(chg_chips[CHARGER_SOLO].i2c_port,
- chg_chips[CHARGER_SOLO].i2c_addr_flags,
- RT9490_REG_SAFETY_TMR_CTRL,
- RT9490_EN_TRICHG_TMR | RT9490_EN_PRECHG_TMR |
- RT9490_EN_FASTCHG_TMR);
-}
-
-static void board_rt9490_workaround(void)
-{
- ibus_adc_workaround();
- i2c_speed_workaround();
- eoc_deglitch_workaround();
- disable_safety_timer();
-}
-DECLARE_HOOK(HOOK_INIT, board_rt9490_workaround, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/projects/corsola/src/krabby/hooks.c b/zephyr/projects/corsola/src/krabby/hooks.c
deleted file mode 100644
index 1eb4f600f2..0000000000
--- a/zephyr/projects/corsola/src/krabby/hooks.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/init.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/pinctrl.h>
-
-#include <ap_power/ap_power.h>
-#include "charger.h"
-#include "driver/charger/rt9490.h"
-#include "extpower.h"
-#include "gpio.h"
-#include "hooks.h"
-
-#define I2C3_NODE DT_NODELABEL(i2c3)
-PINCTRL_DT_DEFINE(I2C3_NODE);
-
-static void board_i2c3_ctrl(bool enable)
-{
- if (DEVICE_DT_GET(
- DT_GPIO_CTLR_BY_IDX(DT_NODELABEL(i2c3), scl_gpios, 0)) ==
- DEVICE_DT_GET(DT_NODELABEL(gpiof))) {
- const struct pinctrl_dev_config *pcfg =
- PINCTRL_DT_DEV_CONFIG_GET(I2C3_NODE);
-
- if (enable) {
- pinctrl_apply_state(pcfg, PINCTRL_STATE_DEFAULT);
- } else {
- pinctrl_apply_state(pcfg, PINCTRL_STATE_SLEEP);
- }
- }
-}
-
-static void board_enable_i2c3(void)
-{
- board_i2c3_ctrl(1);
-}
-DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_enable_i2c3, HOOK_PRIO_FIRST);
-
-static void board_disable_i2c3(void)
-{
- board_i2c3_ctrl(0);
-}
-DECLARE_HOOK(HOOK_CHIPSET_HARD_OFF, board_disable_i2c3, HOOK_PRIO_LAST);
-
-static void board_suspend_handler(struct ap_power_ev_callback *cb,
- struct ap_power_ev_data data)
-{
- int value;
-
- switch (data.event) {
- default:
- return;
-
- case AP_POWER_RESUME:
- value = 1;
- break;
-
- case AP_POWER_SUSPEND:
- value = 0;
- break;
- }
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_5v_usm), value);
-}
-
-static int install_suspend_handler(const struct device *unused)
-{
- static struct ap_power_ev_callback cb;
-
- /*
- * Add a callback for suspend/resume.
- */
- ap_power_ev_init_callback(&cb, board_suspend_handler,
- AP_POWER_RESUME | AP_POWER_SUSPEND);
- ap_power_ev_add_callback(&cb);
- return 0;
-}
-
-SYS_INIT(install_suspend_handler, APPLICATION, 1);
-
-static void board_hook_ac_change(void)
-{
- if (system_get_board_version() >= 1) {
- rt9490_enable_adc(CHARGER_SOLO, extpower_is_present());
- }
-}
-DECLARE_HOOK(HOOK_AC_CHANGE, board_hook_ac_change, HOOK_PRIO_DEFAULT);
-DECLARE_HOOK(HOOK_INIT, board_hook_ac_change, HOOK_PRIO_LAST);
diff --git a/zephyr/projects/corsola/src/krabby/i2c.c b/zephyr/projects/corsola/src/krabby/i2c.c
deleted file mode 100644
index a83af77dbd..0000000000
--- a/zephyr/projects/corsola/src/krabby/i2c.c
+++ /dev/null
@@ -1,19 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c/i2c.h"
-#include "i2c.h"
-
-/* Krabby board specific i2c implementation */
-
-#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
-int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc)
-{
- return (i2c_get_device_for_port(cmd_desc->port) ==
- i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY) ||
- i2c_get_device_for_port(cmd_desc->port) ==
- i2c_get_device_for_port(I2C_PORT_EEPROM));
-}
-#endif
diff --git a/zephyr/projects/corsola/src/krabby/ppc_krabby.c b/zephyr/projects/corsola/src/krabby/ppc_krabby.c
deleted file mode 100644
index d4f574a725..0000000000
--- a/zephyr/projects/corsola/src/krabby/ppc_krabby.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Krabby PPC/BC12 (RT1739) configuration */
-
-#include "baseboard_usbc_config.h"
-#include "gpio/gpio_int.h"
-#include "driver/ppc/rt1739.h"
-#include "driver/ppc/syv682x.h"
-#include "hooks.h"
-#include "variant_db_detection.h"
-
-void c0_bc12_interrupt(enum gpio_signal signal)
-{
- rt1739_interrupt(0);
-}
-
-static void board_usbc_init(void)
-{
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc_bc12));
-}
-DECLARE_HOOK(HOOK_INIT, board_usbc_init, HOOK_PRIO_POST_DEFAULT);
-
-void ppc_interrupt(enum gpio_signal signal)
-{
- if (signal == GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl))) {
- syv682x_interrupt(1);
- }
-}
diff --git a/zephyr/projects/corsola/src/krabby/sensor_magikarp.c b/zephyr/projects/corsola/src/krabby/sensor_magikarp.c
deleted file mode 100644
index 269bc26fae..0000000000
--- a/zephyr/projects/corsola/src/krabby/sensor_magikarp.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "common.h"
-#include "accelgyro.h"
-#include "cros_cbi.h"
-#include "driver/accelgyro_bmi323.h"
-#include "driver/accelgyro_icm42607.h"
-#include "hooks.h"
-#include "motionsense_sensors.h"
-
-void motion_interrupt(enum gpio_signal signal)
-{
- uint32_t val;
-
- cros_cbi_get_fw_config(FW_BASE_GYRO, &val);
- if (val == FW_BASE_ICM42607) {
- icm42607_interrupt(signal);
- } else if (val == FW_BASE_BMI323) {
- bmi3xx_interrupt(signal);
- }
-}
-
-static void motionsense_init(void)
-{
- uint32_t val;
-
- cros_cbi_get_fw_config(FW_BASE_GYRO, &val);
- if (val == FW_BASE_ICM42607) {
- ccprints("BASE ACCEL is ICM42607");
- } else if (val == FW_BASE_BMI323) {
- MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel);
- MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro);
- ccprints("BASE ACCEL IS BMI323");
- } else {
- ccprints("no motionsense");
- }
-}
-DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/projects/corsola/src/krabby/sensor_tentacruel.c b/zephyr/projects/corsola/src/krabby/sensor_tentacruel.c
deleted file mode 100644
index 269bc26fae..0000000000
--- a/zephyr/projects/corsola/src/krabby/sensor_tentacruel.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "common.h"
-#include "accelgyro.h"
-#include "cros_cbi.h"
-#include "driver/accelgyro_bmi323.h"
-#include "driver/accelgyro_icm42607.h"
-#include "hooks.h"
-#include "motionsense_sensors.h"
-
-void motion_interrupt(enum gpio_signal signal)
-{
- uint32_t val;
-
- cros_cbi_get_fw_config(FW_BASE_GYRO, &val);
- if (val == FW_BASE_ICM42607) {
- icm42607_interrupt(signal);
- } else if (val == FW_BASE_BMI323) {
- bmi3xx_interrupt(signal);
- }
-}
-
-static void motionsense_init(void)
-{
- uint32_t val;
-
- cros_cbi_get_fw_config(FW_BASE_GYRO, &val);
- if (val == FW_BASE_ICM42607) {
- ccprints("BASE ACCEL is ICM42607");
- } else if (val == FW_BASE_BMI323) {
- MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel);
- MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro);
- ccprints("BASE ACCEL IS BMI323");
- } else {
- ccprints("no motionsense");
- }
-}
-DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/projects/corsola/src/krabby/temp_tentacruel.c b/zephyr/projects/corsola/src/krabby/temp_tentacruel.c
deleted file mode 100644
index 59c5a989aa..0000000000
--- a/zephyr/projects/corsola/src/krabby/temp_tentacruel.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "charger.h"
-#include "charge_state.h"
-#include "common.h"
-#include "config.h"
-#include "console.h"
-#include "driver/charger/rt9490.h"
-#include "hooks.h"
-#include "temp_sensor/temp_sensor.h"
-#include "thermal.h"
-#include "util.h"
-
-#define NUM_CURRENT_LEVELS ARRAY_SIZE(current_table)
-#define TEMP_THRESHOLD 55
-#define TEMP_BUFF_SIZE 60
-#define KEEP_TIME 5
-
-BUILD_ASSERT(IS_ENABLED(CONFIG_BOARD_TENTACRUEL) || IS_ENABLED(CONFIG_TEST));
-/* calculate current average temperature */
-static int average_tempature(void)
-{
- static int temp_history_buffer[TEMP_BUFF_SIZE];
- static int buff_ptr;
- static int temp_sum;
- static int past_temp;
- static int avg_temp;
- int cur_temp, t;
-
- temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL(temp_charger)), &t);
- cur_temp = K_TO_C(t);
- past_temp = temp_history_buffer[buff_ptr];
- temp_history_buffer[buff_ptr] = cur_temp;
- temp_sum = temp_sum + temp_history_buffer[buff_ptr] - past_temp;
- buff_ptr++;
- if (buff_ptr >= TEMP_BUFF_SIZE) {
- buff_ptr = 0;
- }
- /* Calculate per minute temperature.
- * It's expected low temperature when the first 60 seconds.
- */
- avg_temp = temp_sum / TEMP_BUFF_SIZE;
- return avg_temp;
-}
-
-static int current_level;
-
-/* Limit charging current table : 3600/3000/2400/1800
- * note this should be in descending order.
- */
-static uint16_t current_table[] = {
- 3600,
- 3000,
- 2400,
- 1800,
-};
-
-/* Called by hook task every hook second (1 sec) */
-static void current_update(void)
-{
- int temp;
- static uint8_t uptime;
- static uint8_t dntime;
-
- temp = average_tempature();
-#ifndef CONFIG_TEST
- if (charge_get_state() == PWR_STATE_DISCHARGE) {
- current_level = 0;
- uptime = 0;
- dntime = 0;
- return;
- }
-#endif
- if (temp >= TEMP_THRESHOLD) {
- dntime = 0;
- if (uptime < KEEP_TIME) {
- uptime++;
- } else {
- uptime = 0;
- current_level++;
- }
- } else if (current_level != 0 && temp < TEMP_THRESHOLD) {
- uptime = 0;
- if (dntime < KEEP_TIME) {
- dntime++;
- } else {
- dntime = 0;
- current_level--;
- }
- } else {
- uptime = 0;
- dntime = 0;
- }
- if (current_level > NUM_CURRENT_LEVELS) {
- current_level = NUM_CURRENT_LEVELS;
- }
-}
-DECLARE_HOOK(HOOK_SECOND, current_update, HOOK_PRIO_DEFAULT);
-
-int charger_profile_override(struct charge_state_data *curr)
-{
- /*
- * Precharge must be executed when communication is failed on
- * dead battery.
- */
- if (!(curr->batt.flags & BATT_FLAG_RESPONSIVE))
- return 0;
- if (current_level != 0) {
- if (curr->requested_current > current_table[current_level - 1])
- curr->requested_current =
- current_table[current_level - 1];
- }
- return 0;
-}
-
-enum ec_status charger_profile_override_get_param(uint32_t param,
- uint32_t *value)
-{
- return EC_RES_INVALID_PARAM;
-}
-
-enum ec_status charger_profile_override_set_param(uint32_t param,
- uint32_t value)
-{
- return EC_RES_INVALID_PARAM;
-}
diff --git a/zephyr/projects/corsola/src/krabby/usbc_config.c b/zephyr/projects/corsola/src/krabby/usbc_config.c
deleted file mode 100644
index 7a7f710804..0000000000
--- a/zephyr/projects/corsola/src/krabby/usbc_config.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Krabby board-specific USB-C configuration */
-
-#include "adc.h"
-#include "baseboard_usbc_config.h"
-#include "charge_manager.h"
-#include "console.h"
-#include "driver/tcpm/it83xx_pd.h"
-#include "driver/usb_mux/tusb1064.h"
-#include "i2c.h"
-#include "usb_pd.h"
-#include "usbc_ppc.h"
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
-
-int tusb1064_mux_1_board_init(const struct usb_mux *me)
-{
- int rv;
-
- rv = i2c_write8(me->i2c_port, me->i2c_addr_flags,
- TUSB1064_REG_DP1DP3EQ_SEL,
- TUSB1064_DP1EQ(TUSB1064_DP_EQ_RX_8_9_DB) |
- TUSB1064_DP3EQ(TUSB1064_DP_EQ_RX_5_4_DB));
- if (rv)
- return rv;
-
- /* Enable EQ_OVERRIDE so the gain registers are used */
- return i2c_update8(me->i2c_port, me->i2c_addr_flags,
- TUSB1064_REG_GENERAL, REG_GENERAL_EQ_OVERRIDE,
- MASK_SET);
-}
-
-#ifdef CONFIG_USB_PD_TCPM_ITE_ON_CHIP
-const struct cc_para_t *board_get_cc_tuning_parameter(enum usbpd_port port)
-{
- const static struct cc_para_t
- cc_parameter[CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT] = {
- {
- .rising_time =
- IT83XX_TX_PRE_DRIVING_TIME_1_UNIT,
- .falling_time =
- IT83XX_TX_PRE_DRIVING_TIME_2_UNIT,
- },
- {
- .rising_time =
- IT83XX_TX_PRE_DRIVING_TIME_1_UNIT,
- .falling_time =
- IT83XX_TX_PRE_DRIVING_TIME_2_UNIT,
- },
- };
-
- return &cc_parameter[port];
-}
-#endif
-
-void board_reset_pd_mcu(void)
-{
- /*
- * C0 & C1: TCPC is embedded in the EC and processes interrupts in the
- * chip code (it83xx/intc.c)
- */
-}
-
-#ifndef CONFIG_TEST
-int board_set_active_charge_port(int port)
-{
- int i;
- int is_valid_port = (port >= 0 && port < board_get_usb_pd_port_count());
-
- if (!is_valid_port && port != CHARGE_PORT_NONE) {
- return EC_ERROR_INVAL;
- }
-
- if (port == CHARGE_PORT_NONE) {
- CPRINTS("Disabling all charger ports");
-
- /* Disable all ports. */
- for (i = 0; i < ppc_cnt; i++) {
- /*
- * Do not return early if one fails otherwise we can
- * get into a boot loop assertion failure.
- */
- if (ppc_vbus_sink_enable(i, 0)) {
- CPRINTS("Disabling C%d as sink failed.", i);
- }
- }
-
- return EC_SUCCESS;
- }
-
- /* Check if the port is sourcing VBUS. */
- if (ppc_is_sourcing_vbus(port)) {
- CPRINTS("Skip enable C%d", port);
- return EC_ERROR_INVAL;
- }
-
- CPRINTS("New charge port: C%d", port);
-
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < ppc_cnt; i++) {
- if (i == port) {
- continue;
- }
-
- if (ppc_vbus_sink_enable(i, 0)) {
- CPRINTS("C%d: sink path disable failed.", i);
- }
- }
-
- /* Enable requested charge port. */
- if (ppc_vbus_sink_enable(port, 1)) {
- CPRINTS("C%d: sink path enable failed.", port);
- return EC_ERROR_UNKNOWN;
- }
-
- return EC_SUCCESS;
-}
-#endif
-
-#ifdef CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT
-enum adc_channel board_get_vbus_adc(int port)
-{
- if (port == 0) {
- return ADC_VBUS_C0;
- }
- if (port == 1) {
- return ADC_VBUS_C1;
- }
- CPRINTSUSB("Unknown vbus adc port id: %d", port);
- return ADC_VBUS_C0;
-}
-#endif /* CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT */
diff --git a/zephyr/projects/corsola/src/usb_pd_policy.c b/zephyr/projects/corsola/src/usb_pd_policy.c
deleted file mode 100644
index a885362c61..0000000000
--- a/zephyr/projects/corsola/src/usb_pd_policy.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "atomic.h"
-#include "console.h"
-#include "chipset.h"
-#include "hooks.h"
-#include "timer.h"
-#include "typec_control.h"
-#include "usb_dp_alt_mode.h"
-#include "usb_mux.h"
-#include "usb_pd.h"
-#include "usbc_ppc.h"
-
-#include "baseboard_usbc_config.h"
-
-#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
-
-static int active_aux_port = -1;
-
-int pd_check_vconn_swap(int port)
-{
- /* Allow Vconn swap if AP is on. */
- return chipset_in_state(CHIPSET_STATE_SUSPEND | CHIPSET_STATE_ON);
-}
-
-static void set_dp_aux_path_sel(int port)
-{
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel), port);
- CPRINTS("Set DP_AUX_PATH_SEL: %d", port);
-}
-
-int svdm_get_hpd_gpio(int port)
-{
- /* HPD is low active, inverse the result */
- return !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl));
-}
-
-static void reset_aux_deferred(void)
-{
- if (active_aux_port == -1)
- /* reset to 1 for lower power consumption. */
- set_dp_aux_path_sel(1);
-}
-DECLARE_DEFERRED(reset_aux_deferred);
-
-void svdm_set_hpd_gpio(int port, int en)
-{
- /*
- * HPD is low active, inverse the en.
- *
- * Implement FCFS policy:
- * 1) Enable hpd if no active port.
- * 2) Disable hpd if active port is the given port.
- */
- if (en && active_aux_port < 0) {
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl), 0);
- active_aux_port = port;
- hook_call_deferred(&reset_aux_deferred_data, -1);
- }
-
- if (!en && active_aux_port == port) {
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ec_ap_dp_hpd_odl), 1);
- active_aux_port = -1;
- /*
- * This might be a HPD debounce to send a HPD IRQ (500us), so
- * do not reset the aux path immediately. Defer this call and
- * re-check if this is a real disable.
- */
- hook_call_deferred(&reset_aux_deferred_data, 1 * MSEC);
- }
-}
-
-__override int svdm_dp_config(int port, uint32_t *payload)
-{
- int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT);
- uint8_t pin_mode = get_dp_pin_mode(port);
- mux_state_t mux_mode = svdm_dp_get_mux_mode(port);
- int mf_pref = PD_VDO_DPSTS_MF_PREF(dp_status[port]);
-
- if (!pin_mode) {
- return 0;
- }
-
- CPRINTS("pin_mode: %x, mf: %d, mux: %d", pin_mode, mf_pref, mux_mode);
- /*
- * Defer setting the usb_mux until HPD goes high, svdm_dp_attention().
- * The AP only supports one DP phy. An external DP mux switches between
- * the two ports. Should switch those muxes when it is really used,
- * i.e. HPD high; otherwise, the real use case is preempted, like:
- * (1) plug a dongle without monitor connected to port-0,
- * (2) plug a dongle without monitor connected to port-1,
- * (3) plug a monitor to the port-1 dongle.
- */
-
- payload[0] =
- VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos));
- payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */
- 1, /* DPv1.3 signaling */
- 2); /* UFP connected */
- return 2;
-};
-
-__override void svdm_dp_post_config(int port)
-{
- mux_state_t mux_mode = svdm_dp_get_mux_mode(port);
-
- typec_set_sbu(port, true);
-
- /*
- * Prior to post-config, the mux will be reset to safe mode, and this
- * will break mux config and aux path config we did in the first DP
- * status command. Only enable this if the port is the current aux-port.
- */
- if (port == active_aux_port) {
- usb_mux_set(port, mux_mode, USB_SWITCH_CONNECT,
- polarity_rm_dts(pd_get_polarity(port)));
- usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL |
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
- }
-
- dp_flags[port] |= DP_FLAGS_DP_ON;
-}
-
-int corsola_is_dp_muxable(int port)
-{
- int i;
-
- for (i = 0; i < board_get_usb_pd_port_count(); i++) {
- if (i != port) {
- if (usb_mux_get(i) & USB_PD_MUX_DP_ENABLED) {
- return 0;
- }
- }
- }
-
- return 1;
-}
-
-__override int svdm_dp_attention(int port, uint32_t *payload)
-{
- int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
- int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
-#ifdef CONFIG_USB_PD_DP_HPD_GPIO
- int cur_lvl = svdm_get_hpd_gpio(port);
-#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
- mux_state_t mux_state;
-
- dp_status[port] = payload[1];
-
- if (!corsola_is_dp_muxable(port)) {
- /* TODO(waihong): Info user? */
- CPRINTS("p%d: The other port is already muxed.", port);
- return 0; /* nak */
- }
-
- if (lvl) {
- set_dp_aux_path_sel(port);
-
- usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT,
- polarity_rm_dts(pd_get_polarity(port)));
- } else {
- usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT,
- polarity_rm_dts(pd_get_polarity(port)));
- }
-
- if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl)) {
- /*
- * Wake up the AP. IRQ or level high indicates a DP sink is now
- * present.
- */
- if (IS_ENABLED(CONFIG_MKBP_EVENT)) {
- pd_notify_dp_alt_mode_entry(port);
- }
- }
-
-#ifdef CONFIG_USB_PD_DP_HPD_GPIO
- if (irq && !lvl) {
- /*
- * IRQ can only be generated when the level is high, because
- * the IRQ is signaled by a short low pulse from the high level.
- */
- CPRINTF("ERR:HPD:IRQ&LOW\n");
- return 0; /* nak */
- }
-
- if (irq && cur_lvl) {
- uint64_t now = get_time().val;
- /* wait for the minimum spacing between IRQ_HPD if needed */
- if (now < svdm_hpd_deadline[port]) {
- usleep(svdm_hpd_deadline[port] - now);
- }
-
- /* generate IRQ_HPD pulse */
- svdm_set_hpd_gpio(port, 0);
- /*
- * b/171172053#comment14: since the HPD_DSTREAM_DEBOUNCE_IRQ is
- * very short (500us), we can use udelay instead of usleep for
- * more stable pulse period.
- */
- udelay(HPD_DSTREAM_DEBOUNCE_IRQ);
- svdm_set_hpd_gpio(port, 1);
- } else {
- svdm_set_hpd_gpio(port, lvl);
- }
-
- /* set the minimum time delay (2ms) for the next HPD IRQ */
- svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
-#endif /* CONFIG_USB_PD_DP_HPD_GPIO */
-
- mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
- (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
- usb_mux_hpd_update(port, mux_state);
-
-#ifdef USB_PD_PORT_TCPC_MST
- if (port == USB_PD_PORT_TCPC_MST) {
- baseboard_mst_enable_control(port, lvl);
- }
-#endif
-
- /* ack */
- return 1;
-}
diff --git a/zephyr/projects/corsola/src/usbc_config.c b/zephyr/projects/corsola/src/usbc_config.c
deleted file mode 100644
index e3a2796de5..0000000000
--- a/zephyr/projects/corsola/src/usbc_config.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Corsola baseboard-specific USB-C configuration */
-
-#include <zephyr/drivers/gpio.h>
-#include <ap_power/ap_power.h>
-
-#include "adc.h"
-#include "baseboard_usbc_config.h"
-#include "button.h"
-#include "charger.h"
-#include "charge_state_v2.h"
-#include "console.h"
-#include "ec_commands.h"
-#include "extpower.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "lid_switch.h"
-#include "task.h"
-#include "ppc/syv682x_public.h"
-#include "power.h"
-#include "power_button.h"
-#include "spi.h"
-#include "switch.h"
-#include "tablet_mode.h"
-#include "uart.h"
-#include "usb_charge.h"
-#include "usb_mux.h"
-#include "usb_pd_tcpm.h"
-#include "usb_tc_sm.h"
-#include "usbc/usb_muxes.h"
-#include "usbc_ppc.h"
-
-#include "variant_db_detection.h"
-
-#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
-
-/* a flag for indicating the tasks are inited. */
-static bool tasks_inited;
-
-/* Baseboard */
-static void baseboard_init(void)
-{
-#ifdef CONFIG_VARIANT_CORSOLA_USBA
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usba));
-#endif
- /* If CCD mode has enabled before init, force the ccd_interrupt. */
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ccd_mode_odl))) {
- ccd_interrupt(GPIO_CCD_MODE_ODL);
- }
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode_odl));
-}
-DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_PRE_DEFAULT);
-
-__override uint8_t board_get_usb_pd_port_count(void)
-{
- if (corsola_get_db_type() == CORSOLA_DB_HDMI) {
- if (tasks_inited) {
- return CONFIG_USB_PD_PORT_MAX_COUNT;
- } else {
- return CONFIG_USB_PD_PORT_MAX_COUNT - 1;
- }
- } else if (corsola_get_db_type() == CORSOLA_DB_NONE) {
- return CONFIG_USB_PD_PORT_MAX_COUNT - 1;
- }
-
- return CONFIG_USB_PD_PORT_MAX_COUNT;
-}
-
-/* USB-A */
-void usb_a0_interrupt(enum gpio_signal signal)
-{
- enum usb_charge_mode mode = gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(
- gpio_ap_xhci_init_done)) ?
- USB_CHARGE_MODE_ENABLED :
- USB_CHARGE_MODE_DISABLED;
-
- const int xhci_stat = gpio_get_level(signal);
-
- for (int i = 0; i < USB_PORT_COUNT; i++) {
- usb_charge_set_mode(i, mode, USB_ALLOW_SUSPEND_CHARGE);
- }
-
- for (int i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- /*
- * Enable DRP toggle after XHCI inited. This is used to follow
- * USB 3.2 spec 10.3.1.1.
- */
- if (xhci_stat) {
- pd_set_dual_role(i, PD_DRP_TOGGLE_ON);
- } else if (tc_is_attached_src(i)) {
- /*
- * This is a AP reset S0->S0 transition.
- * We should set the role back to sink.
- */
- pd_set_dual_role(i, PD_DRP_FORCE_SINK);
- }
- }
-}
-
-__override enum pd_dual_role_states pd_get_drp_state_in_s0(void)
-{
- if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ap_xhci_init_done))) {
- return PD_DRP_TOGGLE_ON;
- } else {
- return PD_DRP_FORCE_SINK;
- }
-}
-
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
-void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
-{
- /*
- * We ignore the cc_pin and PPC vconn because polarity and PPC vconn
- * should already be set correctly in the PPC driver via the pd
- * state machine.
- */
-}
-
-/**
- * Handle PS185 HPD changing state.
- */
-int debounced_hpd;
-
-static void ps185_hdmi_hpd_deferred(void)
-{
- const int new_hpd =
- gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd));
-
- /* HPD status not changed, probably a glitch, just return. */
- if (debounced_hpd == new_hpd) {
- return;
- }
-
- debounced_hpd = new_hpd;
-
- if (!corsola_is_dp_muxable(USBC_PORT_C1)) {
- if (debounced_hpd) {
- CPRINTS("C0 port is already muxed.");
- }
- return;
- }
-
- if (debounced_hpd) {
- dp_status[USBC_PORT_C1] =
- VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */
- 0, /* HPD level ... not applicable */
- 0, /* exit DP? ... no */
- 0, /* usb mode? ... no */
- 0, /* multi-function ... no */
- 1, /* DP enabled ... yes */
- 0, /* power low? ... no */
- (!!DP_FLAGS_DP_ON));
- /* update C1 virtual mux */
- usb_mux_set(USBC_PORT_C1, USB_PD_MUX_DP_ENABLED,
- USB_SWITCH_DISCONNECT,
- 0 /* polarity, don't care */);
-
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(dp_aux_path_sel),
- debounced_hpd);
- CPRINTS("Set DP_AUX_PATH_SEL: %d", 1);
- }
- svdm_set_hpd_gpio(USBC_PORT_C1, debounced_hpd);
- CPRINTS(debounced_hpd ? "HDMI plug" : "HDMI unplug");
-}
-DECLARE_DEFERRED(ps185_hdmi_hpd_deferred);
-
-static void ps185_hdmi_hpd_disconnect_deferred(void)
-{
- const int new_hpd =
- gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd));
-
- if (debounced_hpd == new_hpd && !new_hpd) {
- dp_status[USBC_PORT_C1] =
- VDO_DP_STATUS(0, /* HPD IRQ ... not applicable */
- 0, /* HPD level ... not applicable */
- 0, /* exit DP? ... no */
- 0, /* usb mode? ... no */
- 0, /* multi-function ... no */
- 0, /* DP enabled ... no */
- 0, /* power low? ... no */
- (!DP_FLAGS_DP_ON));
- usb_mux_set(USBC_PORT_C1, USB_PD_MUX_NONE,
- USB_SWITCH_DISCONNECT,
- 0 /* polarity, don't care */);
- }
-}
-DECLARE_DEFERRED(ps185_hdmi_hpd_disconnect_deferred);
-
-#define PS185_HPD_DEBOUCE 250
-#define HPD_SINK_ABSENCE_DEBOUNCE (2 * MSEC)
-
-static void hdmi_hpd_interrupt(enum gpio_signal signal)
-{
- hook_call_deferred(&ps185_hdmi_hpd_deferred_data, PS185_HPD_DEBOUCE);
-
- if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd))) {
- hook_call_deferred(&ps185_hdmi_hpd_disconnect_deferred_data,
- HPD_SINK_ABSENCE_DEBOUNCE);
- } else {
- hook_call_deferred(&ps185_hdmi_hpd_disconnect_deferred_data,
- -1);
- }
-}
-
-/* HDMI/TYPE-C function shared subboard interrupt */
-void x_ec_interrupt(enum gpio_signal signal)
-{
- int sub = corsola_get_db_type();
-
- if (sub == CORSOLA_DB_TYPEC) {
- /* C1: PPC interrupt */
- ppc_interrupt(signal);
- } else if (sub == CORSOLA_DB_HDMI) {
- hdmi_hpd_interrupt(signal);
- } else {
- CPRINTS("Undetected subboard interrupt.");
- }
-}
-
-static void board_hdmi_handler(struct ap_power_ev_callback *cb,
- struct ap_power_ev_data data)
-{
- int value;
-
- switch (data.event) {
- default:
- return;
-
- case AP_POWER_RESUME:
- value = 1;
- break;
-
- case AP_POWER_SUSPEND:
- value = 0;
- break;
- }
- gpio_pin_set_dt(GPIO_DT_FROM_ALIAS(gpio_en_hdmi_pwr), value);
- gpio_pin_set_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_pwrdn_odl), value);
-}
-
-static void tasks_init_deferred(void)
-{
- tasks_inited = true;
-}
-DECLARE_DEFERRED(tasks_init_deferred);
-
-static void baseboard_x_ec_gpio2_init(void)
-{
- static struct ppc_drv virtual_ppc_drv = { 0 };
- static struct tcpm_drv virtual_tcpc_drv = { 0 };
- static struct bc12_drv virtual_bc12_drv = { 0 };
-
- /* no sub board */
- if (corsola_get_db_type() == CORSOLA_DB_NONE) {
- return;
- }
-
- /* type-c: USB_C1_PPC_INT_ODL / hdmi: PS185_EC_DP_HPD */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2));
-
- if (corsola_get_db_type() == CORSOLA_DB_TYPEC) {
- gpio_pin_interrupt_configure_dt(
- GPIO_DT_FROM_ALIAS(gpio_usb_c1_ppc_int_odl),
- GPIO_INT_EDGE_FALLING);
- return;
- }
- if (corsola_get_db_type() == CORSOLA_DB_HDMI) {
- static struct ap_power_ev_callback cb;
-
- ap_power_ev_init_callback(&cb, board_hdmi_handler,
- AP_POWER_RESUME | AP_POWER_SUSPEND);
- ap_power_ev_add_callback(&cb);
- }
-
- /* drop related C1 port drivers when it's a HDMI DB. */
- ppc_chips[USBC_PORT_C1] =
- (const struct ppc_config_t){ .drv = &virtual_ppc_drv };
- tcpc_config[USBC_PORT_C1] =
- (const struct tcpc_config_t){ .drv = &virtual_tcpc_drv };
- bc12_ports[USBC_PORT_C1] =
- (const struct bc12_config){ .drv = &virtual_bc12_drv };
- /* Use virtual mux to notify AP the mainlink direction. */
- USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_1_hdmi_db);
-
- /*
- * If a HDMI DB is attached, C1 port tasks will be exiting in that
- * the port number is larger than board_get_usb_pd_port_count().
- * After C1 port tasks finished, we intentionally increase the port
- * count by 1 for usb_mux to access the C1 virtual mux for notifying
- * mainlink direction.
- */
- hook_call_deferred(&tasks_init_deferred_data, 2 * SECOND);
-}
-DECLARE_HOOK(HOOK_INIT, baseboard_x_ec_gpio2_init, HOOK_PRIO_DEFAULT);
-
-__override uint8_t get_dp_pin_mode(int port)
-{
- if (corsola_get_db_type() == CORSOLA_DB_HDMI && port == USBC_PORT_C1) {
- if (usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED) {
- return MODE_DP_PIN_E;
- } else {
- return 0;
- }
- }
-
- return pd_dfp_dp_get_pin_mode(port, dp_status[port]);
-}
diff --git a/zephyr/projects/corsola/src/variant_db_detection.c b/zephyr/projects/corsola/src/variant_db_detection.c
deleted file mode 100644
index 6099d86bdd..0000000000
--- a/zephyr/projects/corsola/src/variant_db_detection.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Corsola daughter board detection */
-#include <zephyr/drivers/gpio.h>
-
-#include "console.h"
-#include "cros_cbi.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-
-#include "variant_db_detection.h"
-
-#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args)
-
-static void corsola_db_config(enum corsola_db_type type)
-{
- switch (type) {
- case CORSOLA_DB_HDMI:
- /* EC_X_GPIO1 */
- gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_hdmi_pwr),
- GPIO_OUTPUT_HIGH);
- /* X_EC_GPIO2 */
- gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd),
- GPIO_INPUT);
- gpio_enable_dt_interrupt(
- GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2));
- /* EC_X_GPIO3 */
- gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_pwrdn_odl),
- GPIO_OUTPUT_HIGH | GPIO_OPEN_DRAIN);
- return;
- case CORSOLA_DB_TYPEC:
- /* EC_X_GPIO1 */
- gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_frs_en),
- GPIO_OUTPUT_LOW);
- /* X_EC_GPIO2 */
- gpio_pin_configure_dt(
- GPIO_DT_FROM_ALIAS(gpio_usb_c1_ppc_int_odl),
- GPIO_INPUT | GPIO_PULL_UP);
- gpio_enable_dt_interrupt(
- GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2));
- /* EC_X_GPIO3 */
- gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_dp_in_hpd),
- GPIO_OUTPUT_LOW);
- return;
- case CORSOLA_DB_NONE:
- /* Set floating pins as input with PU to prevent leakage */
- gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_x_gpio1),
- GPIO_INPUT | GPIO_PULL_UP);
- gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_x_ec_gpio2),
- GPIO_INPUT | GPIO_PULL_UP);
- gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_x_gpio3),
- GPIO_INPUT | GPIO_PULL_UP);
- return;
- default:
- break;
- }
-}
-
-enum corsola_db_type corsola_get_db_type(void)
-{
-#if DT_NODE_EXISTS(DT_NODELABEL(db_config))
- int ret;
- uint32_t val;
-#endif
- static enum corsola_db_type db = CORSOLA_DB_UNINIT;
-
- if (db != CORSOLA_DB_UNINIT) {
- return db;
- }
-
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_hdmi_prsnt_odl))) {
- db = CORSOLA_DB_HDMI;
- } else {
- db = CORSOLA_DB_TYPEC;
- }
-
-/* Detect for no sub board case by FW_CONFIG */
-#if DT_NODE_EXISTS(DT_NODELABEL(db_config))
- ret = cros_cbi_get_fw_config(DB, &val);
- if (ret != 0) {
- CPRINTS("Error retrieving CBI FW_CONFIG field %d", DB);
- } else if (val == DB_NONE) {
- db = CORSOLA_DB_NONE;
- }
-#endif
-
- corsola_db_config(db);
-
- switch (db) {
- case CORSOLA_DB_NONE:
- CPRINTS("Detect %s DB", "NONE");
- break;
- case CORSOLA_DB_TYPEC:
- CPRINTS("Detect %s DB", "TYPEC");
- break;
- case CORSOLA_DB_HDMI:
- CPRINTS("Detect %s DB", "HDMI");
- break;
- default:
- CPRINTS("DB UNINIT");
- break;
- }
-
- return db;
-}
-
-static void corsola_db_init(void)
-{
- corsola_get_db_type();
-}
-DECLARE_HOOK(HOOK_INIT, corsola_db_init, HOOK_PRIO_PRE_I2C);
diff --git a/zephyr/projects/corsola/usba_steelix.dts b/zephyr/projects/corsola/usba_steelix.dts
deleted file mode 100644
index 0ddd67f664..0000000000
--- a/zephyr/projects/corsola/usba_steelix.dts
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* steelix usba port enable config */
-&usba_port_enable_list {
- enable-pins = <&en_pp5000_usb_a0_vbus
- &en_pp5000_usb_a1_vbus>;
-};
diff --git a/zephyr/projects/corsola/usbc_krabby.dts b/zephyr/projects/corsola/usbc_krabby.dts
deleted file mode 100644
index a72864da35..0000000000
--- a/zephyr/projects/corsola/usbc_krabby.dts
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_ppc_port0>;
- ppc = <&bc12_ppc_port0>;
- tcpc = <&usbpd0>;
- chg = <&charger>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&it5205_mux_0 &virtual_mux_0>;
- };
- };
- port0-muxes {
- virtual_mux_0: virtual-mux-0 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
-
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- ppc = <&ppc_port1>;
- tcpc = <&usbpd1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&tusb1064_mux_1 &virtual_mux_1>;
- };
- usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db {
- compatible = "cros-ec,usb-mux-chain";
- alternative-chain;
- usb-muxes = <&virtual_mux_1>;
- };
- };
- port1-muxes {
- virtual_mux_1: virtual-mux-1 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
- };
-};
-
-&usbpd0 {
- status = "okay";
-};
-
-&usbpd1 {
- status = "okay";
-};
diff --git a/zephyr/projects/corsola/usbc_magikarp.dts b/zephyr/projects/corsola/usbc_magikarp.dts
deleted file mode 100644
index c94db15b3a..0000000000
--- a/zephyr/projects/corsola/usbc_magikarp.dts
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- ppc = <&ppc_port0>;
- tcpc = <&usbpd0>;
- chg = <&charger>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&it5205_mux_0 &virtual_mux_0>;
- };
- };
- port0-muxes {
- virtual_mux_0: virtual-mux-0 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
-
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- ppc = <&ppc_port1>;
- tcpc = <&usbpd1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&ps8743_mux_1 &virtual_mux_1>;
- };
- usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db {
- compatible = "cros-ec,usb-mux-chain";
- alternative-chain;
- usb-muxes = <&virtual_mux_1>;
- };
- };
- port1-muxes {
- virtual_mux_1: virtual-mux-1 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
- };
-};
-
-&usbpd0 {
- status = "okay";
-};
-
-&usbpd1 {
- status = "okay";
-};
diff --git a/zephyr/projects/corsola/usbc_tentacruel.dts b/zephyr/projects/corsola/usbc_tentacruel.dts
deleted file mode 100644
index bb105a8e08..0000000000
--- a/zephyr/projects/corsola/usbc_tentacruel.dts
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- ppc = <&bc12_ppc_port0>;
- ppc_alt = <&ppc_port0>;
- tcpc = <&usbpd0>;
- chg = <&charger>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&it5205_mux_0 &virtual_mux_0>;
- };
- };
- port0-muxes {
- virtual_mux_0: virtual-mux-0 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
-
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- ppc = <&ppc_port1>;
- tcpc = <&usbpd1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&ps8743_mux_1 &virtual_mux_1>;
- };
- usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db {
- compatible = "cros-ec,usb-mux-chain";
- alternative-chain;
- usb-muxes = <&virtual_mux_1>;
- };
- };
- port1-muxes {
- virtual_mux_1: virtual-mux-1 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
- };
-};
-
-&usbpd0 {
- status = "okay";
-};
-
-&usbpd1 {
- status = "okay";
-};
diff --git a/zephyr/projects/herobrine/BUILD.py b/zephyr/projects/herobrine/BUILD.py
deleted file mode 100644
index d38803deb7..0000000000
--- a/zephyr/projects/herobrine/BUILD.py
+++ /dev/null
@@ -1,124 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Define zmake projects for herobrine."""
-
-
-def register_variant(
- project_name, extra_dts_overlays=(), extra_kconfig_files=()
-):
- """Register a variant of herobrine."""
- register_npcx_project(
- project_name=project_name,
- zephyr_board="npcx9m3f",
- dts_overlays=[
- # Common to all projects.
- here / "adc.dts",
- here / "common.dts",
- here / "interrupts.dts",
- here / "keyboard.dts",
- here / "default_gpio_pinctrl.dts",
- # Project-specific DTS customization.
- *extra_dts_overlays,
- ],
- kconfig_files=[
- # Common to all projects.
- here / "prj.conf",
- # Project-specific KConfig customization.
- *extra_kconfig_files,
- ],
- )
-
-
-register_variant(
- project_name="evoker",
- extra_dts_overlays=[
- here / "display.dts",
- here / "battery_evoker.dts",
- here / "gpio_evoker.dts",
- here / "i2c_evoker.dts",
- here / "led_pins_evoker.dts",
- here / "led_policy_evoker.dts",
- here / "motionsense_evoker.dts",
- here / "switchcap.dts",
- here / "usbc_evoker.dts",
- ],
- extra_kconfig_files=[here / "prj_evoker.conf"],
-)
-
-register_variant(
- project_name="herobrine",
- extra_dts_overlays=[
- here / "display.dts",
- here / "battery_herobrine.dts",
- here / "gpio.dts",
- here / "i2c_herobrine.dts",
- here / "led_pins_herobrine.dts",
- here / "led_policy_herobrine.dts",
- here / "motionsense.dts",
- here / "switchcap.dts",
- here / "usbc_herobrine.dts",
- ],
- extra_kconfig_files=[here / "prj_herobrine.conf"],
-)
-
-register_variant(
- project_name="hoglin",
- extra_dts_overlays=[
- here / "battery_hoglin.dts",
- here / "gpio_hoglin.dts",
- here / "i2c_hoglin.dts",
- here / "led_pins_hoglin.dts",
- here / "led_policy_hoglin.dts",
- here / "motionsense_hoglin.dts",
- here / "switchcap_hoglin.dts",
- here / "usbc_hoglin.dts",
- ],
- extra_kconfig_files=[here / "prj_hoglin.conf"],
-)
-
-register_variant(
- project_name="villager",
- extra_dts_overlays=[
- here / "battery_villager.dts",
- here / "gpio_villager.dts",
- here / "i2c_villager.dts",
- here / "led_pins_villager.dts",
- here / "led_policy_villager.dts",
- here / "motionsense_villager.dts",
- here / "switchcap.dts",
- here / "usbc_villager.dts",
- ],
- extra_kconfig_files=[here / "prj_villager.conf"],
-)
-
-register_variant(
- project_name="zoglin",
- extra_dts_overlays=[
- here / "battery_hoglin.dts",
- here / "gpio_hoglin.dts",
- here / "i2c_hoglin.dts",
- here / "led_pins_hoglin.dts",
- here / "led_policy_hoglin.dts",
- here / "motionsense_hoglin.dts",
- here / "switchcap_hoglin.dts",
- here / "usbc_hoglin.dts",
- ],
- extra_kconfig_files=[here / "prj_zoglin.conf"],
-)
-
-register_variant(
- project_name="zombie",
- extra_dts_overlays=[
- here / "battery_zombie.dts",
- here / "gpio_zombie.dts",
- here / "i2c_zombie.dts",
- here / "led_pins_zombie.dts",
- here / "led_policy_zombie.dts",
- here / "motionsense_zombie.dts",
- here / "switchcap.dts",
- here / "usbc_zombie.dts",
- ],
- extra_kconfig_files=[here / "prj_zombie.conf"],
-)
diff --git a/zephyr/projects/herobrine/CMakeLists.txt b/zephyr/projects/herobrine/CMakeLists.txt
deleted file mode 100644
index a7e2fc6cf6..0000000000
--- a/zephyr/projects/herobrine/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
-
-cros_ec_library_include_directories(include)
-
-# Common Herobrine implementation
-zephyr_library_sources(
- "src/board_chipset.c"
-)
-
-# Board specific implementation
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/usbc_config.c"
- "src/usb_pd_policy.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C
- "src/i2c.c")
-
-if(DEFINED CONFIG_BOARD_EVOKER)
- project(evoker)
-elseif(DEFINED CONFIG_BOARD_HEROBRINE)
- project(herobrine)
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/herobrine/alt_dev_replacement.c")
-elseif(DEFINED CONFIG_BOARD_HOGLIN)
- project(hoglin)
-elseif(DEFINED CONFIG_BOARD_VILLAGER)
- project(villager)
-elseif(DEFINED CONFIG_BOARD_ZOGLIN)
- project(zoglin)
-elseif(DEFINED CONFIG_BOARD_ZOMBIE)
- project(zombie)
-endif()
diff --git a/zephyr/projects/herobrine/battery_evoker.dts b/zephyr/projects/herobrine/battery_evoker.dts
deleted file mode 100644
index 0e09616c1d..0000000000
--- a/zephyr/projects/herobrine/battery_evoker.dts
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- batteries {
- default_battery: pc_vp_bp153 {
- compatible = "smp,pc-vp-bp153", "battery-smart";
- };
- ap16l5j {
- compatible = "panasonic,ap16l5j", "battery-smart";
- };
- };
-};
diff --git a/zephyr/projects/herobrine/battery_herobrine.dts b/zephyr/projects/herobrine/battery_herobrine.dts
deleted file mode 100644
index b347ec4c3c..0000000000
--- a/zephyr/projects/herobrine/battery_herobrine.dts
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- batteries {
- default_battery: ap16l5j {
- compatible = "panasonic,ap16l5j", "battery-smart";
- };
- };
-};
diff --git a/zephyr/projects/herobrine/battery_hoglin.dts b/zephyr/projects/herobrine/battery_hoglin.dts
deleted file mode 100644
index 11180c3988..0000000000
--- a/zephyr/projects/herobrine/battery_hoglin.dts
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- batteries {
- default_battery: 7c01 {
- compatible = "ganfeng,7c01", "battery-smart";
- };
- };
-};
diff --git a/zephyr/projects/herobrine/battery_villager.dts b/zephyr/projects/herobrine/battery_villager.dts
deleted file mode 100644
index dafd473a6e..0000000000
--- a/zephyr/projects/herobrine/battery_villager.dts
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- batteries {
- default_battery: ap19a5k {
- compatible = "panasonic,ap19a5k", "battery-smart";
- };
- ap19a8k {
- compatible = "lgc,ap19a8k", "battery-smart";
- };
- };
-};
diff --git a/zephyr/projects/herobrine/battery_zombie.dts b/zephyr/projects/herobrine/battery_zombie.dts
deleted file mode 100644
index dafd473a6e..0000000000
--- a/zephyr/projects/herobrine/battery_zombie.dts
+++ /dev/null
@@ -1,15 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- batteries {
- default_battery: ap19a5k {
- compatible = "panasonic,ap19a5k", "battery-smart";
- };
- ap19a8k {
- compatible = "lgc,ap19a8k", "battery-smart";
- };
- };
-};
diff --git a/zephyr/projects/herobrine/gpio.dts b/zephyr/projects/herobrine/gpio.dts
deleted file mode 100644
index a355aaf099..0000000000
--- a/zephyr/projects/herobrine/gpio.dts
+++ /dev/null
@@ -1,329 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- aliases {
- gpio-wp = &gpio_ec_wp_odl;
- gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PD_INT_ODL";
- };
- gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl {
- gpios = <&gpiof 5 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_PD_INT_ODL";
- };
- gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl {
- gpios = <&gpio0 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
- };
- gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl {
- gpios = <&gpio4 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
- };
- gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
- gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>;
- };
- gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
- gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>;
- };
- gpio_usb_a0_oc_odl: usb_a0_oc_odl {
- gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>;
- };
- gpio_chg_acok_od: chg_acok_od {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- };
- gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- };
- gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
- gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- };
- gpio_ec_volup_btn_odl: ec_volup_btn_odl {
- gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_UP_L";
- };
- gpio_ec_wp_odl: ec_wp_odl {
- gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
- };
- gpio_lid_open_ec: lid_open_ec {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- };
- gpio_ap_rst_l: ap_rst_l {
- gpios = <&gpio5 1 GPIO_INPUT>;
- enum-name = "GPIO_AP_RST_L";
- };
- gpio_ps_hold: ps_hold {
- gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_PS_HOLD";
- };
- gpio_ap_suspend: ap_suspend {
- gpios = <&gpio5 7 GPIO_INPUT>;
- enum-name = "GPIO_AP_SUSPEND";
- };
- gpio_mb_power_good: mb_power_good {
- gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_POWER_GOOD";
- };
- gpio_warm_reset_l: warm_reset_l {
- gpios = <&gpiob 0 GPIO_INPUT>;
- enum-name = "GPIO_WARM_RESET_L";
- };
- ap_ec_spi_cs_l {
- gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>;
- };
- gpio_tablet_mode_l: tablet_mode_l {
- gpios = <&gpioc 6 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- };
- gpio_accel_gyro_int_l: accel_gyro_int_l {
- gpios = <&gpioa 3 GPIO_INPUT>;
- };
- gpio_rtc_ec_wake_odl: rtc_ec_wake_odl {
- gpios = <&gpio0 2 GPIO_INPUT>;
- };
- ec_entering_rw {
- gpios = <&gpio7 2 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- };
- ccd_mode_odl {
- gpios = <&gpio6 3 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- };
- ec_batt_pres_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- };
- ec_gsc_packet_mode {
- gpios = <&gpio8 3 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_PACKET_MODE_EN";
- };
- pmic_resin_l {
- gpios = <&gpioa 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_RESIN_L";
- };
- pmic_kpd_pwr_odl {
- gpios = <&gpioa 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_KPD_PWR_ODL";
- };
- ap_ec_int_l {
- gpios = <&gpio5 6 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- };
- gpio_switchcap_on: switchcap_on {
- gpios = <&gpiod 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_SWITCHCAP_ON";
- };
- gpio_en_pp5000_s5: en_pp5000_s5 {
- gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>;
- enum-name = "GPIO_EN_PP5000";
- };
- ec_bl_disable_l {
- /* The PMIC controls backlight enable and this pin must
- * be HiZ for normal operation. But the backlight can
- * be enabled by setting this pin low and configuring it
- * as an output.
- */
- gpios = <&gpiob 6 GPIO_INPUT>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- };
- lid_accel_int_l {
- gpios = <&gpioa 1 GPIO_INPUT>;
- };
- tp_int_gate {
- gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
- };
- gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l {
- gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>;
- };
- gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l {
- gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>;
- };
- gpio_dp_mux_oe_l: dp_mux_oe_l {
- gpios = <&gpiob 1 GPIO_ODR_HIGH>;
- };
- gpio_dp_mux_sel: dp_mux_sel {
- gpios = <&gpio4 5 GPIO_OUTPUT_LOW>;
- };
- gpio_dp_hot_plug_det_r: dp_hot_plug_det_r {
- gpios = <&gpio9 5 GPIO_OUTPUT_LOW>;
- };
- gpio_en_usb_a_5v: en_usb_a_5v {
- gpios = <&gpiof 0 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_EN_USB_A_5V";
- };
- usb_a_cdp_ilim_en_l {
- gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>;
- };
- gpio_usb_c0_frs_en: usb_c0_frs_en {
- gpios = <&gpioc 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_USB_C0_FRS_EN";
- };
- gpio_usb_c1_frs_en: usb_c1_frs_en {
- gpios = <&gpioc 1 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_USB_C1_FRS_EN";
- };
- gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 {
- #led-pin-cells = <1>;
- gpios = <&gpio6 0 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 {
- #led-pin-cells = <1>;
- gpios = <&gpioc 0 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 {
- #led-pin-cells = <1>;
- gpios = <&gpioc 3 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 {
- #led-pin-cells = <1>;
- gpios = <&gpioc 4 GPIO_OUTPUT_LOW>;
- };
- ap_ec_spi_mosi {
- gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>;
- };
- ap_ec_spi_miso {
- gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>;
- };
- ap_ec_spi_clk {
- gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>;
- };
- gpio_brd_id0: brd_id0 {
- gpios = <&gpio9 4 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION1";
- };
- gpio_brd_id1: brd_id1 {
- gpios = <&gpio9 7 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION2";
- };
- gpio_brd_id2: brd_id2 {
- gpios = <&gpioa 5 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION3";
- };
- gpio_sku_id0: sku_id0 {
- gpios = <&gpio6 7 GPIO_INPUT>;
- };
- gpio_sku_id1: sku_id1 {
- gpios = <&gpio7 0 GPIO_INPUT>;
- };
- gpio_sku_id2: sku_id2 {
- gpios = <&gpioe 1 GPIO_INPUT>;
- };
- gpio_switchcap_pg: src_vph_pwr_pg {
- gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_SWITCHCAP_PG";
- };
- arm_x86 {
- gpios = <&gpio6 6 GPIO_OUTPUT_LOW>;
- };
- ec-i2c-sensor-scl {
- gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec-i2c-sensor-sda {
- gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- gpio_ec_kso_02_inv: ec_kso_02_inv {
- gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
- };
- };
-
- usba-port-enable-list {
- compatible = "cros-ec,usba-port-enable-pins";
- enable-pins = <&gpio_en_usb_a_5v>;
- };
-
- sku {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_sku_id0
- &gpio_sku_id1
- &gpio_sku_id2
- >;
-
- system = "ternary";
- };
-
- board {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_brd_id0
- &gpio_brd_id1
- &gpio_brd_id2
- >;
-
- system = "ternary";
- };
-
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios =
- <&gpio5 2 0>,
- <&gpio5 4 0>,
- <&gpio7 6 0>,
- <&gpiod 1 0>,
- <&gpiod 0 0>,
- <&gpioe 3 0>,
- <&gpio0 4 0>,
- <&gpiod 6 0>,
- <&gpio3 2 0>,
- <&gpio3 5 0>,
- <&gpiod 7 0>,
- <&gpio8 6 0>,
- <&gpiod 4 0>,
- <&gpio4 1 0>,
- <&gpio3 4 0>,
- <&gpioc 7 0>,
- <&gpioa 4 0>,
- <&gpio9 6 0>,
- <&gpio9 3 0>,
- <&gpioa 7 0>,
- <&gpio5 0 0>,
- <&gpio8 1 0>,
- <&gpiob 7 0>;
- };
-};
-
-/* Power switch logic input pads */
-&psl_in1_gpd2 {
- /* ACOK_OD */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in2_gp00 {
- /* EC_PWR_BTN_ODL */
- psl-in-mode = "edge";
- psl-in-pol = "low-falling";
-};
-
-&psl_in3_gp01 {
- /* LID_OPEN_EC */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in4_gp02 {
- /* RTC_EC_WAKE_ODL */
- psl-in-mode = "edge";
- psl-in-pol = "low-falling";
-};
-
-/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
-&power_ctrl_psl {
- status = "okay";
- pinctrl-names = "sleep";
- pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>;
-}; \ No newline at end of file
diff --git a/zephyr/projects/herobrine/gpio_evoker.dts b/zephyr/projects/herobrine/gpio_evoker.dts
deleted file mode 100644
index d60fdf93c7..0000000000
--- a/zephyr/projects/herobrine/gpio_evoker.dts
+++ /dev/null
@@ -1,329 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- aliases {
- gpio-wp = &gpio_ec_wp_odl;
- gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PD_INT_ODL";
- };
- gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl {
- gpios = <&gpiof 5 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_PD_INT_ODL";
- };
- gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl {
- gpios = <&gpio0 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
- };
- gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl {
- gpios = <&gpio4 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
- };
- gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
- gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>;
- };
- gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
- gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>;
- };
- gpio_usb_a0_oc_odl: usb_a0_oc_odl {
- gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>;
- };
- gpio_chg_acok_od: chg_acok_od {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- };
- gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- };
- gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
- gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- };
- gpio_ec_volup_btn_odl: ec_volup_btn_odl {
- gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_UP_L";
- };
- gpio_ec_wp_odl: ec_wp_odl {
- gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
- };
- gpio_lid_open_ec: lid_open_ec {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- };
- gpio_ap_rst_l: ap_rst_l {
- gpios = <&gpio5 1 GPIO_INPUT>;
- enum-name = "GPIO_AP_RST_L";
- };
- gpio_ps_hold: ps_hold {
- gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_PS_HOLD";
- };
- gpio_ap_suspend: ap_suspend {
- gpios = <&gpio5 7 GPIO_INPUT>;
- enum-name = "GPIO_AP_SUSPEND";
- };
- gpio_mb_power_good: mb_power_good {
- gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_POWER_GOOD";
- };
- gpio_warm_reset_l: warm_reset_l {
- gpios = <&gpiob 0 GPIO_INPUT>;
- enum-name = "GPIO_WARM_RESET_L";
- };
- ap_ec_spi_cs_l {
- gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>;
- };
- gpio_tablet_mode_l: tablet_mode_l {
- gpios = <&gpioc 6 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- };
- gpio_accel_gyro_int_l: accel_gyro_int_l {
- gpios = <&gpioa 3 GPIO_INPUT>;
- };
- gpio_rtc_ec_wake_odl: rtc_ec_wake_odl {
- gpios = <&gpio0 2 GPIO_INPUT>;
- };
- ec_entering_rw {
- gpios = <&gpio7 2 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- };
- ccd_mode_odl {
- gpios = <&gpio6 3 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- };
- ec_batt_pres_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- };
- ec_gsc_packet_mode {
- gpios = <&gpio8 3 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_PACKET_MODE_EN";
- };
- pmic_resin_l {
- gpios = <&gpioa 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_RESIN_L";
- };
- pmic_kpd_pwr_odl {
- gpios = <&gpioa 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_KPD_PWR_ODL";
- };
- ap_ec_int_l {
- gpios = <&gpio5 6 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- };
- gpio_switchcap_on: switchcap_on {
- gpios = <&gpiod 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_SWITCHCAP_ON";
- };
- gpio_en_pp5000_s5: en_pp5000_s5 {
- gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>;
- enum-name = "GPIO_EN_PP5000";
- };
- ec_bl_disable_l {
- /* The PMIC controls backlight enable and this pin must
- * be HiZ for normal operation. But the backlight can
- * be enabled by setting this pin low and configuring it
- * as an output.
- */
- gpios = <&gpiob 6 GPIO_INPUT>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- };
- lid_accel_int_l {
- gpios = <&gpioa 1 GPIO_INPUT>;
- };
- tp_int_gate {
- gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
- };
- gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l {
- gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>;
- };
- gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l {
- gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>;
- };
- gpio_dp_mux_oe_l: dp_mux_oe_l {
- gpios = <&gpiob 1 GPIO_ODR_HIGH>;
- };
- gpio_dp_mux_sel: dp_mux_sel {
- gpios = <&gpio4 5 GPIO_OUTPUT_LOW>;
- };
- gpio_dp_hot_plug_det_r: dp_hot_plug_det_r {
- gpios = <&gpio9 5 GPIO_OUTPUT_LOW>;
- };
- gpio_en_usb_a_5v: en_usb_a_5v {
- gpios = <&gpiof 0 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_EN_USB_A_5V";
- };
- usb_a_cdp_ilim_en_l {
- gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>;
- };
- gpio_usb_c0_frs_en: usb_c0_frs_en {
- gpios = <&gpioc 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_USB_C0_FRS_EN";
- };
- gpio_usb_c1_frs_en: usb_c1_frs_en {
- gpios = <&gpioc 1 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_USB_C1_FRS_EN";
- };
- gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 {
- #led-pin-cells = <1>;
- gpios = <&gpio6 0 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 {
- #led-pin-cells = <1>;
- gpios = <&gpioc 0 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 {
- #led-pin-cells = <1>;
- gpios = <&gpioc 3 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 {
- #led-pin-cells = <1>;
- gpios = <&gpioc 4 GPIO_OUTPUT_LOW>;
- };
- ap_ec_spi_mosi {
- gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>;
- };
- ap_ec_spi_miso {
- gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>;
- };
- ap_ec_spi_clk {
- gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>;
- };
- gpio_brd_id0: brd_id0 {
- gpios = <&gpio9 4 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION1";
- };
- gpio_brd_id1: brd_id1 {
- gpios = <&gpio9 7 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION2";
- };
- gpio_brd_id2: brd_id2 {
- gpios = <&gpioa 5 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION3";
- };
- gpio_sku_id0: sku_id0 {
- gpios = <&gpio6 7 GPIO_INPUT>;
- };
- gpio_sku_id1: sku_id1 {
- gpios = <&gpio7 0 GPIO_INPUT>;
- };
- gpio_sku_id2: sku_id2 {
- gpios = <&gpioe 1 GPIO_INPUT>;
- };
- gpio_switchcap_pg: src_vph_pwr_pg {
- gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_SWITCHCAP_PG";
- };
- arm_x86 {
- gpios = <&gpio6 6 GPIO_OUTPUT_LOW>;
- };
- ec-i2c-sensor-scl {
- gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec-i2c-sensor-sda {
- gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- gpio_ec_kso_02_inv: ec_kso_02_inv {
- gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
- };
- };
-
- usba-port-enable-list {
- compatible = "cros-ec,usba-port-enable-pins";
- enable-pins = <&gpio_en_usb_a_5v>;
- };
-
- sku {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_sku_id0
- &gpio_sku_id1
- &gpio_sku_id2
- >;
-
- system = "ternary";
- };
-
- board {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_brd_id0
- &gpio_brd_id1
- &gpio_brd_id2
- >;
-
- system = "ternary";
- };
-
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios =
- <&gpio5 2 0>,
- <&gpio5 4 0>,
- <&gpio7 6 0>,
- <&gpiod 1 0>,
- <&gpiod 0 0>,
- <&gpioe 3 0>,
- <&gpio0 4 0>,
- <&gpiod 6 0>,
- <&gpio3 2 0>,
- <&gpio3 5 0>,
- <&gpiod 7 0>,
- <&gpio8 6 0>,
- <&gpiod 4 0>,
- <&gpio4 1 0>,
- <&gpio3 4 0>,
- <&gpioc 7 0>,
- <&gpioa 4 0>,
- <&gpio9 6 0>,
- <&gpio9 3 0>,
- <&gpioa 7 0>,
- <&gpio5 0 0>,
- <&gpio8 1 0>,
- <&gpiob 7 0>;
- };
-};
-
-/* Power switch logic input pads */
-&psl_in1_gpd2 {
- /* ACOK_OD */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in2_gp00 {
- /* EC_PWR_BTN_ODL */
- psl-in-mode = "edge";
- psl-in-pol = "low-falling";
-};
-
-&psl_in3_gp01 {
- /* LID_OPEN_EC */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in4_gp02 {
- /* RTC_EC_WAKE_ODL */
- psl-in-mode = "edge";
- psl-in-pol = "low-falling";
-};
-
-/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
-&power_ctrl_psl {
- status = "okay";
- pinctrl-names = "sleep";
- pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>;
-};
diff --git a/zephyr/projects/herobrine/gpio_hoglin.dts b/zephyr/projects/herobrine/gpio_hoglin.dts
deleted file mode 100644
index cb7babc9cf..0000000000
--- a/zephyr/projects/herobrine/gpio_hoglin.dts
+++ /dev/null
@@ -1,327 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- aliases {
- gpio-wp = &gpio_ec_wp_odl;
- gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PD_INT_ODL";
- };
- gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl {
- gpios = <&gpiof 5 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_PD_INT_ODL";
- };
- gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl {
- gpios = <&gpio0 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
- };
- gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl {
- gpios = <&gpio4 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
- };
- gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
- gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>;
- };
- gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
- gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>;
- };
- gpio_usb_a0_oc_odl: usb_a0_oc_odl {
- gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>;
- };
- gpio_chg_acok_od: chg_acok_od {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- };
- gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- };
- gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
- gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- };
- gpio_ec_volup_btn_odl: ec_volup_btn_odl {
- gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_UP_L";
- };
- gpio_ec_wp_odl: ec_wp_odl {
- gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
- };
- gpio_lid_open_ec: lid_open_ec {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- };
- gpio_ap_rst_l: ap_rst_l {
- gpios = <&gpio5 1 GPIO_INPUT>;
- enum-name = "GPIO_AP_RST_L";
- };
- gpio_ps_hold: ps_hold {
- gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_PS_HOLD";
- };
- gpio_ap_suspend: ap_suspend {
- gpios = <&gpio5 7 GPIO_INPUT>;
- enum-name = "GPIO_AP_SUSPEND";
- };
- gpio_mb_power_good: mb_power_good {
- gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_POWER_GOOD";
- };
- gpio_warm_reset_l: warm_reset_l {
- gpios = <&gpiob 0 GPIO_INPUT>;
- enum-name = "GPIO_WARM_RESET_L";
- };
- ap_ec_spi_cs_l {
- gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>;
- };
- gpio_tablet_mode_l: tablet_mode_l {
- gpios = <&gpioc 6 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- };
- gpio_accel_gyro_int_l: accel_gyro_int_l {
- gpios = <&gpioa 3 GPIO_INPUT>;
- };
- gpio_rtc_ec_wake_odl: rtc_ec_wake_odl {
- gpios = <&gpio0 2 GPIO_INPUT>;
- };
- ec_entering_rw {
- gpios = <&gpio7 2 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- };
- ccd_mode_odl {
- gpios = <&gpio6 3 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- };
- ec_batt_pres_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- };
- ec_gsc_packet_mode {
- gpios = <&gpio8 3 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_PACKET_MODE_EN";
- };
- pmic_resin_l {
- gpios = <&gpioa 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_RESIN_L";
- };
- pmic_kpd_pwr_odl {
- gpios = <&gpioa 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_KPD_PWR_ODL";
- };
- ap_ec_int_l {
- gpios = <&gpio5 6 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- };
- gpio_switchcap_on: switchcap_on {
- gpios = <&gpio5 0 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_SWITCHCAP_ON";
- };
- gpio_en_pp5000_s5: en_pp5000_s5 {
- gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>;
- enum-name = "GPIO_EN_PP5000";
- };
- ec_bl_disable_l {
- /* The PMIC controls backlight enable and this pin must
- * be HiZ for normal operation. But the backlight can
- * be enabled by setting this pin low and configuring it
- * as an output.
- */
- gpios = <&gpiob 6 GPIO_INPUT>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- };
- lid_accel_int_l {
- gpios = <&gpioa 1 GPIO_INPUT>;
- };
- tp_int_gate {
- gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
- };
- gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l {
- gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>;
- };
- gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l {
- gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>;
- };
- gpio_dp_mux_oe_l: dp_mux_oe_l {
- gpios = <&gpiob 1 GPIO_ODR_HIGH>;
- };
- gpio_dp_mux_sel: dp_mux_sel {
- gpios = <&gpio4 5 GPIO_OUTPUT_LOW>;
- };
- gpio_dp_hot_plug_det_r: dp_hot_plug_det_r {
- gpios = <&gpio9 5 GPIO_OUTPUT_LOW>;
- };
- gpio_en_usb_a_5v: en_usb_a_5v {
- gpios = <&gpiof 0 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_EN_USB_A_5V";
- };
- usb_a_cdp_ilim_en_l {
- gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>;
- };
- gpio_usb_c0_frs_en: usb_c0_frs_en {
- gpios = <&gpioc 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_USB_C0_FRS_EN";
- };
- gpio_usb_c1_frs_en: usb_c1_frs_en {
- gpios = <&gpioc 1 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_USB_C1_FRS_EN";
- };
- gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 {
- #led-pin-cells = <1>;
- gpios = <&gpio6 0 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_chg_led_r_c0: ec_chg_led_r_c0 {
- #led-pin-cells = <1>;
- gpios = <&gpioc 0 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_chg_led_y_c1: ec_chg_led_b_c1 {
- gpios = <&gpioc 3 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_chg_led_w_c1: ec_chg_led_r_c1 {
- gpios = <&gpioc 4 GPIO_OUTPUT_LOW>;
- };
- ap_ec_spi_mosi {
- gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>;
- };
- ap_ec_spi_miso {
- gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>;
- };
- ap_ec_spi_clk {
- gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>;
- };
- gpio_brd_id0: brd_id0 {
- gpios = <&gpio9 4 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION1";
- };
- gpio_brd_id1: brd_id1 {
- gpios = <&gpio9 7 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION2";
- };
- gpio_brd_id2: brd_id2 {
- gpios = <&gpioa 5 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION3";
- };
- gpio_sku_id0: sku_id0 {
- gpios = <&gpio6 7 GPIO_INPUT>;
- };
- gpio_sku_id1: sku_id1 {
- gpios = <&gpio7 0 GPIO_INPUT>;
- };
- gpio_sku_id2: sku_id2 {
- gpios = <&gpioe 1 GPIO_INPUT>;
- };
- gpio_switchcap_pg: src_vph_pwr_pg {
- gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_SWITCHCAP_PG";
- };
- arm_x86 {
- gpios = <&gpio6 6 GPIO_OUTPUT_LOW>;
- };
- ec-i2c-sensor-scl {
- gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec-i2c-sensor-sda {
- gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- gpio_ec_kso_02_inv: ec_kso_02_inv {
- gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
- };
- };
-
- usba-port-enable-list {
- compatible = "cros-ec,usba-port-enable-pins";
- enable-pins = <&gpio_en_usb_a_5v>;
- };
-
- sku {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_sku_id0
- &gpio_sku_id1
- &gpio_sku_id2
- >;
-
- system = "ternary";
- };
-
- board {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_brd_id0
- &gpio_brd_id1
- &gpio_brd_id2
- >;
-
- system = "ternary";
- };
-
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios =
- <&gpio5 2 0>,
- <&gpio5 4 0>,
- <&gpio7 6 0>,
- <&gpiod 1 0>,
- <&gpiod 0 0>,
- <&gpioe 3 0>,
- <&gpio0 4 0>,
- <&gpiod 6 0>,
- <&gpio3 2 0>,
- <&gpio3 5 0>,
- <&gpiod 7 0>,
- <&gpio8 6 0>,
- <&gpiod 4 0>,
- <&gpio4 1 0>,
- <&gpio3 4 0>,
- <&gpioc 7 0>,
- <&gpioa 4 0>,
- <&gpio9 6 0>,
- <&gpio9 3 0>,
- <&gpioa 7 0>,
- <&gpiod 5 0>,
- <&gpio8 1 0>,
- <&gpiob 7 0>;
- };
-};
-
-/* Power switch logic input pads */
-&psl_in1_gpd2 {
- /* ACOK_OD */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in2_gp00 {
- /* EC_PWR_BTN_ODL */
- psl-in-mode = "edge";
- psl-in-pol = "low-falling";
-};
-
-&psl_in3_gp01 {
- /* LID_OPEN_EC */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in4_gp02 {
- /* RTC_EC_WAKE_ODL */
- psl-in-mode = "edge";
- psl-in-pol = "low-falling";
-};
-
-/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
-&power_ctrl_psl {
- status = "okay";
- pinctrl-names = "sleep";
- pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>;
-};
diff --git a/zephyr/projects/herobrine/gpio_villager.dts b/zephyr/projects/herobrine/gpio_villager.dts
deleted file mode 100644
index 1e7625ff6a..0000000000
--- a/zephyr/projects/herobrine/gpio_villager.dts
+++ /dev/null
@@ -1,323 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- aliases {
- gpio-wp = &gpio_ec_wp_odl;
- gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PD_INT_ODL";
- };
- gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl {
- gpios = <&gpiof 5 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_PD_INT_ODL";
- };
- gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl {
- gpios = <&gpio0 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
- };
- gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl {
- gpios = <&gpio4 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
- };
- gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
- gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>;
- };
- gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
- gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>;
- };
- gpio_usb_a0_oc_odl: usb_a0_oc_odl {
- gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>;
- };
- gpio_chg_acok_od: chg_acok_od {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- };
- gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- };
- gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
- gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- };
- gpio_ec_volup_btn_odl: ec_volup_btn_odl {
- gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_UP_L";
- };
- gpio_ec_wp_odl: ec_wp_odl {
- gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
- };
- gpio_lid_open_ec: lid_open_ec {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- };
- gpio_ap_rst_l: ap_rst_l {
- gpios = <&gpio5 1 GPIO_INPUT>;
- enum-name = "GPIO_AP_RST_L";
- };
- gpio_ps_hold: ps_hold {
- gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_PS_HOLD";
- };
- gpio_ap_suspend: ap_suspend {
- gpios = <&gpio5 7 GPIO_INPUT>;
- enum-name = "GPIO_AP_SUSPEND";
- };
- gpio_mb_power_good: mb_power_good {
- gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_POWER_GOOD";
- };
- gpio_warm_reset_l: warm_reset_l {
- gpios = <&gpiob 0 GPIO_INPUT>;
- enum-name = "GPIO_WARM_RESET_L";
- };
- ap_ec_spi_cs_l {
- gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>;
- };
- gpio_tablet_mode_l: tablet_mode_l {
- gpios = <&gpioc 6 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- };
- gpio_accel_gyro_int_l: accel_gyro_int_l {
- gpios = <&gpioa 3 GPIO_INPUT>;
- };
- gpio_rtc_ec_wake_odl: rtc_ec_wake_odl {
- gpios = <&gpio0 2 GPIO_INPUT>;
- };
- ec_entering_rw {
- gpios = <&gpio7 2 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- };
- ccd_mode_odl {
- gpios = <&gpio6 3 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- };
- ec_batt_pres_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- };
- ec_gsc_packet_mode {
- gpios = <&gpio8 3 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_PACKET_MODE_EN";
- };
- pmic_resin_l {
- gpios = <&gpioa 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_RESIN_L";
- };
- pmic_kpd_pwr_odl {
- gpios = <&gpioa 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_KPD_PWR_ODL";
- };
- ap_ec_int_l {
- gpios = <&gpio5 6 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- };
- gpio_switchcap_on: switchcap_on {
- gpios = <&gpiod 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_SWITCHCAP_ON";
- };
- gpio_en_pp5000_s5: en_pp5000_s5 {
- gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>;
- enum-name = "GPIO_EN_PP5000";
- };
- ec_bl_disable_l {
- /* The PMIC controls backlight enable and this pin must
- * be HiZ for normal operation. But the backlight can
- * be enabled by setting this pin low and configuring it
- * as an output.
- */
- gpios = <&gpiob 6 GPIO_INPUT>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- };
- lid_accel_int_l {
- gpios = <&gpioa 1 GPIO_INPUT>;
- };
- tp_int_gate {
- gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
- };
- gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l {
- gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>;
- };
- gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l {
- gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>;
- };
- gpio_dp_mux_oe_l: dp_mux_oe_l {
- gpios = <&gpiob 1 GPIO_ODR_HIGH>;
- };
- gpio_dp_mux_sel: dp_mux_sel {
- gpios = <&gpio4 5 GPIO_OUTPUT_LOW>;
- };
- gpio_dp_hot_plug_det_r: dp_hot_plug_det_r {
- gpios = <&gpio9 5 GPIO_OUTPUT_LOW>;
- };
- gpio_en_usb_a_5v: en_usb_a_5v {
- gpios = <&gpiof 0 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_EN_USB_A_5V";
- };
- usb_a_cdp_ilim_en_l {
- gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>;
- };
- gpio_usb_c0_frs_en: usb_c0_frs_en {
- gpios = <&gpioc 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_USB_C0_FRS_EN";
- };
- gpio_usb_c1_frs_en: usb_c1_frs_en {
- gpios = <&gpioc 1 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_USB_C1_FRS_EN";
- };
- gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 {
- #led-pin-cells = <1>;
- gpios = <&gpio6 0 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 {
- #led-pin-cells = <1>;
- gpios = <&gpioc 0 GPIO_OUTPUT_LOW>;
- };
- ap_ec_spi_mosi {
- gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>;
- };
- ap_ec_spi_miso {
- gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>;
- };
- ap_ec_spi_clk {
- gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>;
- };
- gpio_brd_id0: brd_id0 {
- gpios = <&gpio9 4 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION1";
- };
- gpio_brd_id1: brd_id1 {
- gpios = <&gpio9 7 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION2";
- };
- gpio_brd_id2: brd_id2 {
- gpios = <&gpioa 5 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION3";
- };
- gpio_sku_id0: sku_id0 {
- gpios = <&gpio6 7 GPIO_INPUT>;
- };
- gpio_sku_id1: sku_id1 {
- gpios = <&gpio7 0 GPIO_INPUT>;
- };
- gpio_sku_id2: sku_id2 {
- gpios = <&gpioe 1 GPIO_INPUT>;
- };
- gpio_switchcap_pg: src_vph_pwr_pg {
- gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_SWITCHCAP_PG";
- };
- arm_x86 {
- gpios = <&gpio6 6 GPIO_OUTPUT_LOW>;
- };
- ec-i2c-sensor-scl {
- gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec-i2c-sensor-sda {
- gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- gpio_ec_kso_02_inv: ec_kso_02_inv {
- gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
- };
- };
-
- usba-port-enable-list {
- compatible = "cros-ec,usba-port-enable-pins";
- enable-pins = <&gpio_en_usb_a_5v>;
- };
-
- sku {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_sku_id0
- &gpio_sku_id1
- &gpio_sku_id2
- >;
-
- system = "ternary";
- };
-
- board {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_brd_id0
- &gpio_brd_id1
- &gpio_brd_id2
- >;
-
- system = "ternary";
- };
-
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios =
- <&gpio5 2 0>,
- <&gpio5 4 0>,
- <&gpio7 6 0>,
- <&gpiod 1 0>,
- <&gpiod 0 0>,
- <&gpioe 3 0>,
- <&gpio0 4 0>,
- <&gpiod 6 0>,
- <&gpio3 2 0>,
- <&gpio3 5 0>,
- <&gpiod 7 0>,
- <&gpio8 6 0>,
- <&gpiod 4 0>,
- <&gpio4 1 0>,
- <&gpio3 4 0>,
- <&gpioc 3 0>,
- <&gpioc 4 0>,
- <&gpioc 7 0>,
- <&gpioa 4 0>,
- <&gpio9 6 0>,
- <&gpio9 3 0>,
- <&gpioa 7 0>,
- <&gpio5 0 0>,
- <&gpio8 1 0>,
- <&gpiob 7 0>;
- };
-};
-
-/* Power switch logic input pads */
-&psl_in1_gpd2 {
- /* ACOK_OD */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in2_gp00 {
- /* EC_PWR_BTN_ODL */
- psl-in-mode = "edge";
- psl-in-pol = "low-falling";
-};
-
-&psl_in3_gp01 {
- /* LID_OPEN_EC */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in4_gp02 {
- /* RTC_EC_WAKE_ODL */
- psl-in-mode = "edge";
- psl-in-pol = "low-falling";
-};
-
-/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
-&power_ctrl_psl {
- status = "okay";
- pinctrl-names = "sleep";
- pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>;
-};
diff --git a/zephyr/projects/herobrine/gpio_zombie.dts b/zephyr/projects/herobrine/gpio_zombie.dts
deleted file mode 100644
index 14ed1f54d6..0000000000
--- a/zephyr/projects/herobrine/gpio_zombie.dts
+++ /dev/null
@@ -1,323 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- aliases {
- gpio-wp = &gpio_ec_wp_odl;
- gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PD_INT_ODL";
- };
- gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl {
- gpios = <&gpiof 5 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_PD_INT_ODL";
- };
- gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl {
- gpios = <&gpio0 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
- };
- gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl {
- gpios = <&gpio4 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
- };
- gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
- gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>;
- };
- gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
- gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>;
- };
- gpio_usb_a0_oc_odl: usb_a0_oc_odl {
- gpios = <&gpiof 4 GPIO_INPUT_PULL_UP>;
- };
- gpio_chg_acok_od: chg_acok_od {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- };
- gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- };
- gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
- gpios = <&gpio6 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- };
- gpio_ec_volup_btn_odl: ec_volup_btn_odl {
- gpios = <&gpioc 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_UP_L";
- };
- gpio_ec_wp_odl: ec_wp_odl {
- gpios = <&gpiod 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
- };
- gpio_lid_open_ec: lid_open_ec {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- };
- gpio_ap_rst_l: ap_rst_l {
- gpios = <&gpio5 1 GPIO_INPUT>;
- enum-name = "GPIO_AP_RST_L";
- };
- gpio_ps_hold: ps_hold {
- gpios = <&gpioa 6 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_PS_HOLD";
- };
- gpio_ap_suspend: ap_suspend {
- gpios = <&gpio5 7 GPIO_INPUT>;
- enum-name = "GPIO_AP_SUSPEND";
- };
- gpio_mb_power_good: mb_power_good {
- gpios = <&gpio3 7 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_POWER_GOOD";
- };
- gpio_warm_reset_l: warm_reset_l {
- gpios = <&gpiob 0 GPIO_INPUT>;
- enum-name = "GPIO_WARM_RESET_L";
- };
- ap_ec_spi_cs_l {
- gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>;
- };
- gpio_tablet_mode_l: tablet_mode_l {
- gpios = <&gpioc 6 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- };
- gpio_accel_gyro_int_l: accel_gyro_int_l {
- gpios = <&gpioa 3 GPIO_INPUT>;
- };
- gpio_rtc_ec_wake_odl: rtc_ec_wake_odl {
- gpios = <&gpio0 2 GPIO_INPUT>;
- };
- ec_entering_rw {
- gpios = <&gpio7 2 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- };
- ccd_mode_odl {
- gpios = <&gpio6 3 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- };
- ec_batt_pres_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- };
- ec_gsc_packet_mode {
- gpios = <&gpio8 3 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_PACKET_MODE_EN";
- };
- pmic_resin_l {
- gpios = <&gpioa 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_RESIN_L";
- };
- pmic_kpd_pwr_odl {
- gpios = <&gpioa 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_KPD_PWR_ODL";
- };
- ap_ec_int_l {
- gpios = <&gpio5 6 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- };
- gpio_switchcap_on: switchcap_on {
- gpios = <&gpiod 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_SWITCHCAP_ON";
- };
- gpio_en_pp5000_s5: en_pp5000_s5 {
- gpios = <&gpio7 3 GPIO_OUTPUT_HIGH>;
- enum-name = "GPIO_EN_PP5000";
- };
- ec_bl_disable_l {
- /* The PMIC controls backlight enable and this pin must
- * be HiZ for normal operation. But the backlight can
- * be enabled by setting this pin low and configuring it
- * as an output.
- */
- gpios = <&gpiob 6 GPIO_INPUT>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- };
- lid_accel_int_l {
- gpios = <&gpioa 1 GPIO_INPUT>;
- };
- tp_int_gate {
- gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
- };
- gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l {
- gpios = <&gpiof 1 GPIO_OUTPUT_HIGH>;
- };
- gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l {
- gpios = <&gpioe 4 GPIO_OUTPUT_HIGH>;
- };
- gpio_dp_mux_oe_l: dp_mux_oe_l {
- gpios = <&gpiob 1 GPIO_ODR_HIGH>;
- };
- gpio_dp_mux_sel: dp_mux_sel {
- gpios = <&gpio4 5 GPIO_OUTPUT_LOW>;
- };
- gpio_dp_hot_plug_det_r: dp_hot_plug_det_r {
- gpios = <&gpio9 5 GPIO_OUTPUT_LOW>;
- };
- gpio_en_usb_a_5v: en_usb_a_5v {
- gpios = <&gpiof 0 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_EN_USB_A_5V";
- };
- usb_a_cdp_ilim_en_l {
- gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>;
- };
- gpio_usb_c0_frs_en: usb_c0_frs_en {
- gpios = <&gpioc 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_USB_C0_FRS_EN";
- };
- gpio_usb_c1_frs_en: usb_c1_frs_en {
- gpios = <&gpioc 1 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_USB_C1_FRS_EN";
- };
- gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 {
- #led-pin-cells = <1>;
- gpios = <&gpio6 0 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_chg_led_b_c0: ec_chg_led_b_c0 {
- #led-pin-cells = <1>;
- gpios = <&gpioc 0 GPIO_OUTPUT_LOW>;
- };
- ap_ec_spi_mosi {
- gpios = <&gpio4 6 GPIO_INPUT_PULL_DOWN>;
- };
- ap_ec_spi_miso {
- gpios = <&gpio4 7 GPIO_INPUT_PULL_DOWN>;
- };
- ap_ec_spi_clk {
- gpios = <&gpio5 5 GPIO_INPUT_PULL_DOWN>;
- };
- gpio_brd_id0: brd_id0 {
- gpios = <&gpio9 4 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION1";
- };
- gpio_brd_id1: brd_id1 {
- gpios = <&gpio9 7 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION2";
- };
- gpio_brd_id2: brd_id2 {
- gpios = <&gpioa 5 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION3";
- };
- gpio_sku_id0: sku_id0 {
- gpios = <&gpio6 7 GPIO_INPUT>;
- };
- gpio_sku_id1: sku_id1 {
- gpios = <&gpio7 0 GPIO_INPUT>;
- };
- gpio_sku_id2: sku_id2 {
- gpios = <&gpioe 1 GPIO_INPUT>;
- };
- gpio_switchcap_pg: src_vph_pwr_pg {
- gpios = <&gpioe 2 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_SWITCHCAP_PG";
- };
- arm_x86 {
- gpios = <&gpio6 6 GPIO_OUTPUT_LOW>;
- };
- ec-i2c-sensor-scl {
- gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec-i2c-sensor-sda {
- gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- gpio_ec_kso_02_inv: ec_kso_02_inv {
- gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
- };
- };
-
- usba-port-enable-list {
- compatible = "cros-ec,usba-port-enable-pins";
- enable-pins = <&gpio_en_usb_a_5v>;
- };
-
- sku {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_sku_id0
- &gpio_sku_id1
- &gpio_sku_id2
- >;
-
- system = "ternary";
- };
-
- board {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_brd_id0
- &gpio_brd_id1
- &gpio_brd_id2
- >;
-
- system = "ternary";
- };
-
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios =
- <&gpio5 2 0>,
- <&gpio5 4 0>,
- <&gpio7 6 0>,
- <&gpiod 1 0>,
- <&gpiod 0 0>,
- <&gpioe 3 0>,
- <&gpio0 4 0>,
- <&gpiod 6 0>,
- <&gpio3 2 0>,
- <&gpio3 5 0>,
- <&gpiod 7 0>,
- <&gpio8 6 0>,
- <&gpiod 4 0>,
- <&gpio4 1 0>,
- <&gpio3 4 0>,
- <&gpioc 3 0>,
- <&gpioc 4 0>,
- <&gpioc 7 0>,
- <&gpioa 4 0>,
- <&gpio9 6 0>,
- <&gpio9 3 0>,
- <&gpioa 7 0>,
- <&gpio5 0 0>,
- <&gpio8 1 0>,
- <&gpiob 7 0>;
- };
-};
-
-/* Power switch logic input pads */
-&psl_in1_gpd2 {
- /* ACOK_OD */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in2_gp00 {
- /* EC_PWR_BTN_ODL */
- psl-in-mode = "edge";
- psl-in-pol = "low-falling";
-};
-
-&psl_in3_gp01 {
- /* LID_OPEN_EC */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in4_gp02 {
- /* RTC_EC_WAKE_ODL */
- psl-in-mode = "edge";
- psl-in-pol = "low-falling";
-};
-
-/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
-&power_ctrl_psl {
- status = "okay";
- pinctrl-names = "sleep";
- pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>;
-};
diff --git a/zephyr/projects/herobrine/i2c_common.dtsi b/zephyr/projects/herobrine/i2c_common.dtsi
deleted file mode 100644
index b1ed0242c0..0000000000
--- a/zephyr/projects/herobrine/i2c_common.dtsi
+++ /dev/null
@@ -1,157 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- 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-7 = &i2c7_0;
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- i2c_power: power {
- i2c-port = <&i2c0_0>;
- remote-port = <0>;
- enum-names = "I2C_PORT_POWER",
- "I2C_PORT_BATTERY",
- "I2C_PORT_VIRTUAL_BATTERY",
- "I2C_PORT_CHARGER";
- };
- i2c_tcpc0: tcpc0 {
- i2c-port = <&i2c1_0>;
- dynamic-speed;
- enum-names = "I2C_PORT_TCPC0";
- };
- i2c_tcpc1: tcpc1 {
- i2c-port = <&i2c2_0>;
- dynamic-speed;
- enum-names = "I2C_PORT_TCPC1";
- };
- rtc {
- i2c-port = <&i2c4_1>;
- enum-names = "I2C_PORT_RTC";
- };
- i2c_eeprom: eeprom {
- i2c-port = <&i2c5_0>;
- enum-names = "I2C_PORT_EEPROM";
- };
- i2c_sensor: sensor {
- i2c-port = <&i2c7_0>;
- enum-names = "I2C_PORT_SENSOR",
- "I2C_PORT_ACCEL";
- };
- };
-
-
-};
-
-&i2c0_0 {
- label = "I2C_POWER";
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
- pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
- pinctrl-names = "default";
-
- bc12_port0: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- irq = <&int_usb_c0_bc12>;
- };
-
- charger: isl923x@9 {
- compatible = "intersil,isl923x";
- status = "okay";
- reg = <0x9>;
- };
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c1_0 {
- label = "I2C_USB_C0_PD";
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
- pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
- pinctrl-names = "default";
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c2_0 {
- label = "I2C_USB_C1_PD";
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
- pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>;
- pinctrl-names = "default";
-};
-
-&i2c_ctrl2 {
- status = "okay";
-};
-
-&i2c3_0 {
- /* Not used as no WLC connected */
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c4_1 {
- label = "I2C_RTC";
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>;
- pinctrl-names = "default";
-
- pcf85063a: pcf85063a@51 {
- compatible = "nxp,rtc-pcf85063a";
- reg = <0x51>;
- int-pin = <&gpio_rtc_ec_wake_odl>;
- };
-};
-
-&i2c_ctrl4 {
- status = "okay";
-};
-
-&i2c5_0 {
- label = "I2C_EEPROM";
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>;
- pinctrl-names = "default";
-
- bc12_port1: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- irq = <&int_usb_c1_bc12>;
- };
-};
-
-&i2c_ctrl5 {
- status = "okay";
-};
-
-&i2c7_0 {
- label = "I2C_SENSOR";
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
- pinctrl-names = "default";
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
diff --git a/zephyr/projects/herobrine/i2c_evoker.dts b/zephyr/projects/herobrine/i2c_evoker.dts
deleted file mode 100644
index 7023d08c8d..0000000000
--- a/zephyr/projects/herobrine/i2c_evoker.dts
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c_common.dtsi"
-
-&i2c1_0 {
- ppc_port0: syv682x@41 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x41>;
- frs_en_gpio = <&gpio_usb_c0_frs_en>;
- };
-
- ppc_port0_alt: sn5s330@40 {
- compatible = "ti,sn5s330";
- status = "okay";
- reg = <0x40>;
- };
-
- tcpc_port0: ps8xxx@b {
- compatible = "parade,ps8xxx";
- reg = <0xb>;
- };
-};
-
-&i2c2_0 {
- ppc_port1: syv682x@41 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x41>;
- frs_en_gpio = <&gpio_usb_c1_frs_en>;
- };
-
- ppc_port1_alt: sn5s330@40 {
- compatible = "ti,sn5s330";
- status = "okay";
- reg = <0x40>;
- };
-
- tcpc_port1: ps8xxx@b {
- compatible = "parade,ps8xxx";
- reg = <0xb>;
- };
-};
diff --git a/zephyr/projects/herobrine/i2c_herobrine.dts b/zephyr/projects/herobrine/i2c_herobrine.dts
deleted file mode 100644
index 92c68f4215..0000000000
--- a/zephyr/projects/herobrine/i2c_herobrine.dts
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c_common.dtsi"
-
-&i2c1_0 {
- ppc_port0: sn5s330@40 {
- compatible = "ti,sn5s330";
- status = "okay";
- reg = <0x40>;
- };
-
- ppc_port0_alt: syv682x@41 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x41>;
- frs_en_gpio = <&gpio_usb_c0_frs_en>;
- };
-
- tcpc_port0: ps8xxx@b {
- compatible = "parade,ps8xxx";
- reg = <0xb>;
- };
-};
-
-&i2c2_0 {
- ppc_port1: sn5s330@40 {
- compatible = "ti,sn5s330";
- status = "okay";
- reg = <0x40>;
- };
-
- tcpc_port1: ps8xxx@b {
- compatible = "parade,ps8xxx";
- reg = <0xb>;
- };
-};
diff --git a/zephyr/projects/herobrine/i2c_hoglin.dts b/zephyr/projects/herobrine/i2c_hoglin.dts
deleted file mode 100644
index 504dbb9248..0000000000
--- a/zephyr/projects/herobrine/i2c_hoglin.dts
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c_common.dtsi"
-
-&i2c1_0 {
- ppc_port0: syv682x@41 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x41>;
- frs_en_gpio = <&gpio_usb_c0_frs_en>;
- };
-
- tcpc_port0: ps8xxx@1b {
- compatible = "parade,ps8xxx";
- reg = <0x1b>;
- };
-};
-
-&i2c2_0 {
- ppc_port1: syv682x@41 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x41>;
- frs_en_gpio = <&gpio_usb_c1_frs_en>;
- };
-
- tcpc_port1: ps8xxx@1b {
- compatible = "parade,ps8xxx";
- reg = <0x1b>;
- };
-};
diff --git a/zephyr/projects/herobrine/i2c_villager.dts b/zephyr/projects/herobrine/i2c_villager.dts
deleted file mode 100644
index efdf88ac38..0000000000
--- a/zephyr/projects/herobrine/i2c_villager.dts
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c_common.dtsi"
-
-&i2c1_0 {
- ppc_port0: syv682x@41 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x41>;
- frs_en_gpio = <&gpio_usb_c0_frs_en>;
- };
-
- tcpc_port0: ps8xxx@b {
- compatible = "parade,ps8xxx";
- reg = <0xb>;
- };
-};
-
-&i2c2_0 {
- ppc_port1: syv682x@41 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x41>;
- frs_en_gpio = <&gpio_usb_c1_frs_en>;
- };
-
- tcpc_port1: ps8xxx@b {
- compatible = "parade,ps8xxx";
- reg = <0xb>;
- };
-};
diff --git a/zephyr/projects/herobrine/i2c_zombie.dts b/zephyr/projects/herobrine/i2c_zombie.dts
deleted file mode 100644
index efdf88ac38..0000000000
--- a/zephyr/projects/herobrine/i2c_zombie.dts
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c_common.dtsi"
-
-&i2c1_0 {
- ppc_port0: syv682x@41 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x41>;
- frs_en_gpio = <&gpio_usb_c0_frs_en>;
- };
-
- tcpc_port0: ps8xxx@b {
- compatible = "parade,ps8xxx";
- reg = <0xb>;
- };
-};
-
-&i2c2_0 {
- ppc_port1: syv682x@41 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x41>;
- frs_en_gpio = <&gpio_usb_c1_frs_en>;
- };
-
- tcpc_port1: ps8xxx@b {
- compatible = "parade,ps8xxx";
- reg = <0xb>;
- };
-};
diff --git a/zephyr/projects/herobrine/include/board_chipset.h b/zephyr/projects/herobrine/include/board_chipset.h
deleted file mode 100644
index 81c0dd1a40..0000000000
--- a/zephyr/projects/herobrine/include/board_chipset.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_HEROBRINE_BOARD_CHIPSET_H
-#define __CROS_EC_HEROBRINE_BOARD_CHIPSET_H
-
-__test_only void reset_pp5000_inited(void);
-
-#endif /* __CROS_EC_HEROBRINE_BOARD_CHIPSET_H */
diff --git a/zephyr/projects/herobrine/led_pins_evoker.dts b/zephyr/projects/herobrine/led_pins_evoker.dts
deleted file mode 100644
index ff2dc0e36c..0000000000
--- a/zephyr/projects/herobrine/led_pins_evoker.dts
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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_power_off: color-power-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_POWER_LED";
- led-pins = <&gpio_ec_chg_led_w_c1 0>;
- };
-
- color_power_white: color-power-white {
- led-color = "LED_WHITE";
- led-id = "EC_LED_ID_POWER_LED";
- led-pins = <&gpio_ec_chg_led_w_c1 1>;
- };
-
- color_battery_off: color-battery-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&gpio_ec_chg_led_y_c0 0>,
- <&gpio_ec_chg_led_w_c0 0>,
- <&gpio_ec_chg_led_r_c0 0>;
- };
-
- color_battery_amber: color-battery-amber {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&gpio_ec_chg_led_y_c0 1>,
- <&gpio_ec_chg_led_w_c0 0>,
- <&gpio_ec_chg_led_r_c0 0>;
- };
-
- color_battery_white: color-battery-white {
- led-color = "LED_WHITE";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&gpio_ec_chg_led_y_c0 0>,
- <&gpio_ec_chg_led_w_c0 1>,
- <&gpio_ec_chg_led_r_c0 0>;
- };
-
- color_battery_red: color-battery-red {
- led-color = "LED_RED";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&gpio_ec_chg_led_y_c0 0>,
- <&gpio_ec_chg_led_w_c0 0>,
- <&gpio_ec_chg_led_r_c0 1>;
- };
- };
-};
diff --git a/zephyr/projects/herobrine/led_pins_herobrine.dts b/zephyr/projects/herobrine/led_pins_herobrine.dts
deleted file mode 100644
index c509ab1a64..0000000000
--- a/zephyr/projects/herobrine/led_pins_herobrine.dts
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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_left: color-off-left {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_LEFT_LED";
- led-pins = <&gpio_ec_chg_led_y_c1 0>,
- <&gpio_ec_chg_led_w_c1 0>;
- };
-
- color_off_right: color-off-right {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_RIGHT_LED";
- led-pins = <&gpio_ec_chg_led_y_c0 0>,
- <&gpio_ec_chg_led_w_c0 0>;
- };
-
- color_amber_left: color-amber-left {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_LEFT_LED";
- br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&gpio_ec_chg_led_y_c1 1>,
- <&gpio_ec_chg_led_w_c1 0>;
- };
-
- color_amber_right: color-amber-right {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_RIGHT_LED";
- br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&gpio_ec_chg_led_y_c0 1>,
- <&gpio_ec_chg_led_w_c0 0>;
- };
-
- color_white_left: color-white-left {
- led-color = "LED_WHITE";
- led-id = "EC_LED_ID_LEFT_LED";
- br-color = "EC_LED_COLOR_WHITE";
- led-pins = <&gpio_ec_chg_led_y_c1 0>,
- <&gpio_ec_chg_led_w_c1 1>;
- };
-
- color_white_right: color-white-right {
- led-color = "LED_WHITE";
- led-id = "EC_LED_ID_RIGHT_LED";
- br-color = "EC_LED_COLOR_WHITE";
- led-pins = <&gpio_ec_chg_led_y_c0 0>,
- <&gpio_ec_chg_led_w_c0 1>;
- };
- };
-};
diff --git a/zephyr/projects/herobrine/led_pins_hoglin.dts b/zephyr/projects/herobrine/led_pins_hoglin.dts
deleted file mode 100644
index 7b125c5cac..0000000000
--- a/zephyr/projects/herobrine/led_pins_hoglin.dts
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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: color-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&gpio_ec_chg_led_b_c0 0>,
- <&gpio_ec_chg_led_r_c0 0>;
- };
-
- color_blue: color-blue {
- led-color = "LED_BLUE";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_BLUE";
- led-pins = <&gpio_ec_chg_led_b_c0 1>,
- <&gpio_ec_chg_led_r_c0 0>;
- };
-
- color_red: color-red {
- led-color = "LED_RED";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_RED";
- led-pins = <&gpio_ec_chg_led_b_c0 0>,
- <&gpio_ec_chg_led_r_c0 1>;
- };
- };
-};
diff --git a/zephyr/projects/herobrine/led_pins_villager.dts b/zephyr/projects/herobrine/led_pins_villager.dts
deleted file mode 100644
index b0913cdbce..0000000000
--- a/zephyr/projects/herobrine/led_pins_villager.dts
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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: color-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&gpio_ec_chg_led_y_c0 0>,
- <&gpio_ec_chg_led_b_c0 0>;
- };
-
- color_amber: color-amber {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&gpio_ec_chg_led_y_c0 1>,
- <&gpio_ec_chg_led_b_c0 0>;
- };
-
- color_blue: color-blue {
- led-color = "LED_BLUE";
- led-id = "EC_LED_ID_BATTERY_LED";
- 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_pins_zombie.dts b/zephyr/projects/herobrine/led_pins_zombie.dts
deleted file mode 100644
index b0913cdbce..0000000000
--- a/zephyr/projects/herobrine/led_pins_zombie.dts
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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: color-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&gpio_ec_chg_led_y_c0 0>,
- <&gpio_ec_chg_led_b_c0 0>;
- };
-
- color_amber: color-amber {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&gpio_ec_chg_led_y_c0 1>,
- <&gpio_ec_chg_led_b_c0 0>;
- };
-
- color_blue: color-blue {
- led-color = "LED_BLUE";
- led-id = "EC_LED_ID_BATTERY_LED";
- 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/prj.conf b/zephyr/projects/herobrine/prj.conf
deleted file mode 100644
index 3391e60dce..0000000000
--- a/zephyr/projects/herobrine/prj.conf
+++ /dev/null
@@ -1,160 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-CONFIG_SHIMMED_TASKS=y
-CONFIG_PLATFORM_EC=y
-CONFIG_PLATFORM_EC_BRINGUP=y
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-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_CBI_GPIO=y
-CONFIG_KERNEL_SHELL=y
-CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y
-
-# I2C options
-CONFIG_I2C=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y
-CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y
-
-# Shell history and tab autocompletion (for convenience)
-CONFIG_SHELL_HELP=y
-CONFIG_SHELL_HISTORY=y
-CONFIG_SHELL_TAB=y
-CONFIG_SHELL_TAB_AUTOCOMPLETION=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_COMMON=n
-CONFIG_PLATFORM_EC_LED_DT=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-
-# Application Processor is Qualcomm SC7280
-CONFIG_AP_ARM_QUALCOMM_SC7280=y
-
-# GPIO Switchcap
-CONFIG_PLATFORM_EC_SWITCHCAP_GPIO=y
-
-# Board version is selected over GPIO board ID pins.
-CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y
-
-# Power Sequencing
-CONFIG_PLATFORM_EC_POWERSEQ=y
-CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y
-CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
-CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
-CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y
-CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y
-
-# MKBP event
-CONFIG_PLATFORM_EC_MKBP_EVENT=y
-CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD=y
-CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y
-CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
-CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
-CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
-CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
-CONFIG_PLATFORM_EC_CMD_BUTTON=y
-CONFIG_CROS_KB_RAW_NPCX=y
-
-# ADC
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
-# Battery
-CONFIG_PLATFORM_EC_BATTERY=y
-CONFIG_PLATFORM_EC_BATTERY_SMART=y
-CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y
-CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y
-CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
-CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
-CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
-CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y
-CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y
-CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY=y
-CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY="LION"
-CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y
-CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=2
-CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=12500
-CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y
-CONFIG_PLATFORM_EC_CHARGER_PSYS=y
-CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20
-CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y
-
-# USB-A
-CONFIG_PLATFORM_EC_USBA=y
-
-# USB-C
-CONFIG_PLATFORM_EC_USB_PD_FRS=y
-CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
-CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n
-CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y
-CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y
-CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y
-CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y
-CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE=n
-CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y
-CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
-CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_DPS=y
-CONFIG_PLATFORM_EC_USB_PD_REV30=y
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
-CONFIG_PLATFORM_EC_USB_PD_USB4=n
-CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805=y
-CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n
-CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n
-CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
-CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=2
-
-# USB ID
-# This is allocated specifically for Herobrine
-# http://google3/hardware/standards/usb/
-# TODO(b/183608112): Move to device tree
-CONFIG_PLATFORM_EC_USB_PID=0x5055
-
-# RTC
-CONFIG_PLATFORM_EC_RTC=y
-CONFIG_CROS_RTC_NXP_PCF85063A=y
-CONFIG_PLATFORM_EC_HOSTCMD_RTC=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC_ALARM=y
-
-# EC software sync
-CONFIG_PLATFORM_EC_VBOOT_HASH=y
-
-# Sensors
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_ACCEL_SPOOF_MODE=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
-CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
-CONFIG_PLATFORM_EC_LID_ANGLE=y
-CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
-CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
-CONFIG_PLATFORM_EC_TABLET_MODE=y
-CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
-CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000
-
-# Sensor Drivers
-CONFIG_PLATFORM_EC_ACCEL_BMA255=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI260=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
-
-CONFIG_SYSCON=y
-CONFIG_PLATFORM_EC_EMULATED_SYSRQ=y
diff --git a/zephyr/projects/herobrine/prj_evoker.conf b/zephyr/projects/herobrine/prj_evoker.conf
deleted file mode 100644
index b4a5fce160..0000000000
--- a/zephyr/projects/herobrine/prj_evoker.conf
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Evoker board-specific Kconfig settings.
-CONFIG_BOARD_EVOKER=y
-
-# Disable type-c port sourcing 3A
-CONFIG_PLATFORM_EC_CONFIG_USB_PD_3A_PORTS=0
-
-CONFIG_PLATFORM_EC_ACCEL_BMA255=n
-CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y
-
-# ISL9238C disable the CMOUT latch function.
-CONFIG_PLATFORM_EC_ISL9238C_DISABLE_CMOUT_LATCH=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y \ No newline at end of file
diff --git a/zephyr/projects/herobrine/src/board_chipset.c b/zephyr/projects/herobrine/src/board_chipset.c
deleted file mode 100644
index 2312bdb1c4..0000000000
--- a/zephyr/projects/herobrine/src/board_chipset.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Herobrine chipset-specific configuration */
-
-#include "charger.h"
-#include "common.h"
-#include "console.h"
-#include "battery.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "timer.h"
-#include "usb_pd.h"
-
-#include "board_chipset.h"
-
-#define CPRINTS(format, args...) cprints(CC_HOOK, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_HOOK, format, ##args)
-
-/*
- * A window of PD negotiation. It starts from the Type-C state reaching
- * Attached.SNK, and ends when the PD contract is created. The VBUS may be
- * raised anytime in this window.
- *
- * The current implementation is the worst case scenario: every message the PD
- * negotiation is received at the last moment before timeout. More extra time
- * is added to compensate the delay internally, like the decision of the DPM.
- *
- * TODO(waihong): Cancel this timer when the PD contract is negotiated.
- */
-#define PD_READY_TIMEOUT \
- (PD_T_SINK_WAIT_CAP + PD_T_SENDER_RESPONSE + PD_T_SINK_TRANSITION + \
- 20 * MSEC)
-
-#define PD_READY_POLL_DELAY (10 * MSEC)
-
-static timestamp_t pd_ready_timeout;
-
-static bool pp5000_inited;
-
-__test_only void reset_pp5000_inited(void)
-{
- pp5000_inited = false;
-}
-
-/* Called on USB PD connected */
-static void board_usb_pd_connect(void)
-{
- int soc = -1;
-
- /* First boot, battery unattached or low SOC */
- if (!pp5000_inited &&
- ((battery_state_of_charge_abs(&soc) != EC_SUCCESS ||
- soc < charger_get_min_bat_pct_for_power_on()))) {
- pd_ready_timeout = get_time();
- pd_ready_timeout.val += PD_READY_TIMEOUT;
- }
-}
-DECLARE_HOOK(HOOK_USB_PD_CONNECT, board_usb_pd_connect, HOOK_PRIO_DEFAULT);
-
-static void wait_pd_ready(void)
-{
- CPRINTS("Wait PD negotiated VBUS transition %u",
- pd_ready_timeout.le.lo);
- while (pd_ready_timeout.val && get_time().val < pd_ready_timeout.val)
- usleep(PD_READY_POLL_DELAY);
-}
-
-/* Called on AP S5 -> S3 transition */
-static void board_chipset_pre_init(void)
-{
- if (!pp5000_inited) {
- if (pd_ready_timeout.val) {
- wait_pd_ready();
- }
- CPRINTS("Enable 5V rail");
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_s5), 1);
- pp5000_inited = true;
- }
-}
-DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_chipset_pre_init, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/projects/herobrine/src/herobrine/alt_dev_replacement.c b/zephyr/projects/herobrine/src/herobrine/alt_dev_replacement.c
deleted file mode 100644
index 00acd509f4..0000000000
--- a/zephyr/projects/herobrine/src/herobrine/alt_dev_replacement.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include <zephyr/logging/log.h>
-#include "usbc/ppc.h"
-#include "hooks.h"
-#include "cros_board_info.h"
-
-LOG_MODULE_REGISTER(alt_dev_replacement);
-
-#define BOARD_VERSION_UNKNOWN 0xffffffff
-
-/* Check board version to decide which ppc is used. */
-static bool board_has_alt_ppc(void)
-{
- static uint32_t board_version = BOARD_VERSION_UNKNOWN;
-
- if (board_version == BOARD_VERSION_UNKNOWN) {
- if (cbi_get_board_version(&board_version) != EC_SUCCESS) {
- LOG_ERR("Failed to get board version.");
- board_version = 0;
- }
- }
-
- return (board_version >= 1);
-}
-
-static void check_alternate_devices(void)
-{
- /* Configure the PPC driver */
- if (board_has_alt_ppc())
- /* Arg is the USB port number */
- PPC_ENABLE_ALTERNATE(0);
-}
-DECLARE_HOOK(HOOK_INIT, check_alternate_devices, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/projects/herobrine/src/i2c.c b/zephyr/projects/herobrine/src/i2c.c
deleted file mode 100644
index 88b722c42d..0000000000
--- a/zephyr/projects/herobrine/src/i2c.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c/i2c.h"
-#include "i2c.h"
-
-/* Herobrine-NPCX9 board specific i2c implementation */
-
-#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
-int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc)
-{
- return (i2c_get_device_for_port(cmd_desc->port) ==
- i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY));
-}
-#endif
diff --git a/zephyr/projects/herobrine/src/usb_pd_policy.c b/zephyr/projects/herobrine/src/usb_pd_policy.c
deleted file mode 100644
index adc517d3cb..0000000000
--- a/zephyr/projects/herobrine/src/usb_pd_policy.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "charge_manager.h"
-#include "chipset.h"
-#include "console.h"
-#include "system.h"
-#include "usb_mux.h"
-#include "usbc_ppc.h"
-#include "util.h"
-
-#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-int pd_check_vconn_swap(int port)
-{
- /* In G3, do not allow vconn swap since PP5000 rail is off */
- return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_s5));
-}
-
-static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT];
-
-static void board_vbus_update_source_current(int port)
-{
- ppc_vbus_source_enable(port, vbus_en[port]);
-}
-
-void pd_power_supply_reset(int port)
-{
- int prev_en;
-
- prev_en = vbus_en[port];
-
- /* Disable VBUS */
- vbus_en[port] = 0;
- board_vbus_update_source_current(port);
-
- /* Enable discharge if we were previously sourcing 5V */
- if (prev_en)
- pd_set_vbus_discharge(port, 1);
-
- /* notify host of power info change */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- /* Disable charging */
- board_vbus_sink_enable(port, 0);
-
- pd_set_vbus_discharge(port, 0);
-
- /* Provide VBUS */
- vbus_en[port] = 1;
- board_vbus_update_source_current(port);
-
- /* notify host of power info change */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS; /* we are ready */
-}
-
-int board_vbus_source_enabled(int port)
-{
- return vbus_en[port];
-}
-
-int pd_snk_is_vbus_provided(int port)
-{
- return tcpm_check_vbus_level(port, VBUS_PRESENT);
-}
-
-/* ----------------- Vendor Defined Messages ------------------ */
-#ifdef CONFIG_USB_PD_ALT_MODE_DFP
-__override int svdm_dp_config(int port, uint32_t *payload)
-{
- int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT);
- uint8_t pin_mode = get_dp_pin_mode(port);
-
- if (!pin_mode)
- return 0;
-
- /*
- * Defer setting the usb_mux until HPD goes high, svdm_dp_attention().
- * The AP only supports one DP phy. An external DP mux switches between
- * the two ports. Should switch those muxes when it is really used,
- * i.e. HPD high; otherwise, the real use case is preempted, like:
- * (1) plug a dongle without monitor connected to port-0,
- * (2) plug a dongle without monitor connected to port-1,
- * (3) plug a monitor to the port-1 dongle.
- */
-
- payload[0] =
- VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos));
- payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */
- 1, /* DPv1.3 signaling */
- 2); /* UFP connected */
- return 2;
-};
-
-__override void svdm_dp_post_config(int port)
-{
- dp_flags[port] |= DP_FLAGS_DP_ON;
-}
-
-/**
- * Is the port fine to be muxed its DisplayPort lines?
- *
- * Only one port can be muxed to DisplayPort at a time.
- *
- * @param port Port number of TCPC.
- * @return 1 is fine; 0 is bad as other port is already muxed;
- */
-static int is_dp_muxable(int port)
-{
- int i;
-
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
- if (i != port) {
- if (usb_mux_get(i) & USB_PD_MUX_DP_ENABLED)
- return 0;
- }
-
- return 1;
-}
-
-__override int svdm_dp_attention(int port, uint32_t *payload)
-{
- const struct gpio_dt_spec *hpd =
- GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det_r);
- int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
- int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
- int cur_lvl = gpio_pin_get_dt(hpd);
- mux_state_t mux_state;
-
- dp_status[port] = payload[1];
-
- if (!is_dp_muxable(port)) {
- /* TODO(waihong): Info user? */
- CPRINTS("p%d: The other port is already muxed.", port);
- return 0;
- }
-
- /*
- * Initial implementation to handle HPD. Only the first-plugged port
- * works, i.e. sending HPD signal to AP. The second-plugged port
- * will be ignored.
- *
- * TODO(waihong): Continue the above case, if the first-plugged port
- * is then unplugged, switch to the second-plugged port and signal AP?
- */
- if (lvl) {
- /*
- * Enable and switch the DP port selection mux to the
- * correct port.
- *
- * TODO(waihong): Better to move switching DP mux to
- * the usb_mux abstraction.
- */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel),
- port == 1);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 0);
-
- /* Connect the SBU lines in PPC chip. */
- if (IS_ENABLED(CONFIG_USBC_PPC_SBU))
- ppc_set_sbu(port, 1);
-
- /*
- * Connect the USB SS/DP lines in TCPC chip.
- *
- * When mf_pref not true, still use the dock muxing
- * because of the board USB-C topology (limited to 2
- * lanes DP).
- */
- usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT,
- polarity_rm_dts(pd_get_polarity(port)));
- } else {
- /* Disconnect the DP port selection mux. */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0);
-
- /* Disconnect the SBU lines in PPC chip. */
- if (IS_ENABLED(CONFIG_USBC_PPC_SBU))
- ppc_set_sbu(port, 0);
-
- /* Disconnect the DP but keep the USB SS lines in TCPC chip. */
- usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT,
- polarity_rm_dts(pd_get_polarity(port)));
- }
-
- if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl))
- /*
- * Wake up the AP. IRQ or level high indicates a DP sink is now
- * present.
- */
- pd_notify_dp_alt_mode_entry(port);
-
- /* Configure TCPC for the HPD event, for proper muxing */
- mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
- (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
- usb_mux_hpd_update(port, mux_state);
-
- /* Signal AP for the HPD event, through GPIO to AP */
- if (irq & cur_lvl) {
- uint64_t now = get_time().val;
- /* Wait for the minimum spacing between IRQ_HPD if needed */
- if (now < svdm_hpd_deadline[port])
- usleep(svdm_hpd_deadline[port] - now);
-
- /* Generate IRQ_HPD pulse */
- CPRINTS("C%d: Recv IRQ. HPD->0", port);
- gpio_pin_set_dt(hpd, 0);
- usleep(HPD_DSTREAM_DEBOUNCE_IRQ);
- gpio_pin_set_dt(hpd, 1);
- CPRINTS("C%d: Recv IRQ. HPD->1", port);
-
- /* Set the minimum time delay (2ms) for the next HPD IRQ */
- svdm_hpd_deadline[port] =
- get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
- } else if (irq & !lvl) {
- CPRINTF("ERR:HPD:IRQ&LOW\n");
- return 0;
- } else {
- CPRINTS("C%d: Recv lvl. HPD->%d", port, lvl);
- gpio_pin_set_dt(hpd, lvl);
- /* Set the minimum time delay (2ms) for the next HPD IRQ */
- svdm_hpd_deadline[port] =
- get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
- }
-
- return 1;
-}
-
-__override void svdm_exit_dp_mode(int port)
-{
- CPRINTS("%s(%d)", __func__, port);
- if (is_dp_muxable(port)) {
- /* Disconnect the DP port selection mux. */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0);
-
- /* Signal AP for the HPD low event */
- usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
- CPRINTS("C%d: DP exit. HPD->0", port);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det_r),
- 0);
- }
-}
-#endif /* CONFIG_USB_PD_ALT_MODE_DFP */
diff --git a/zephyr/projects/herobrine/src/usbc_config.c b/zephyr/projects/herobrine/src/usbc_config.c
deleted file mode 100644
index f040ab12cb..0000000000
--- a/zephyr/projects/herobrine/src/usbc_config.c
+++ /dev/null
@@ -1,278 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Herobrine board-specific USB-C configuration */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "charger.h"
-#include "charger/isl923x_public.h"
-#include "charge_manager.h"
-#include "charge_state.h"
-#include "common.h"
-#include "config.h"
-#include "cros_board_info.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "ppc/sn5s330_public.h"
-#include "ppc/syv682x_public.h"
-#include "system.h"
-#include "tcpm/ps8xxx_public.h"
-#include "tcpm/tcpci.h"
-#include "timer.h"
-#include "usb_pd.h"
-#include "usb_mux.h"
-#include "usbc_ocp.h"
-#include "usbc_ppc.h"
-#include "usbc/ppc.h"
-
-#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-/* GPIO Interrupt Handlers */
-void tcpc_alert_event(enum gpio_signal signal)
-{
- int port = -1;
-
- switch (signal) {
- case GPIO_USB_C0_PD_INT_ODL:
- port = 0;
- break;
- case GPIO_USB_C1_PD_INT_ODL:
- port = 1;
- break;
- default:
- return;
- }
-
- schedule_deferred_pd_interrupt(port);
-}
-
-static void usba_oc_deferred(void)
-{
- /* Use next number after all USB-C ports to indicate the USB-A port */
- board_overcurrent_event(
- CONFIG_USB_PD_PORT_MAX_COUNT,
- !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_a0_oc_odl)));
-}
-DECLARE_DEFERRED(usba_oc_deferred);
-
-void usba_oc_interrupt(enum gpio_signal signal)
-{
- hook_call_deferred(&usba_oc_deferred_data, 0);
-}
-
-void ppc_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_USB_C0_SWCTL_INT_ODL:
- ppc_chips[0].drv->interrupt(0);
- break;
-
- case GPIO_USB_C1_SWCTL_INT_ODL:
- ppc_chips[1].drv->interrupt(1);
- break;
-
- default:
- break;
- }
-}
-
-int charger_profile_override(struct charge_state_data *curr)
-{
- int usb_mv;
- int port;
-
- if (curr->state != ST_CHARGE)
- return 0;
-
- /* Lower the max requested voltage to 5V when battery is full. */
- if (chipset_in_state(CHIPSET_STATE_ANY_OFF) &&
- !(curr->batt.flags & BATT_FLAG_BAD_STATUS) &&
- !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
- (curr->batt.status & STATUS_FULLY_CHARGED))
- usb_mv = 5000;
- else
- usb_mv = PD_MAX_VOLTAGE_MV;
-
- if (pd_get_max_voltage() != usb_mv) {
- CPRINTS("VBUS limited to %dmV", usb_mv);
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++)
- pd_set_external_voltage_limit(port, usb_mv);
- }
-
- return 0;
-}
-
-enum ec_status charger_profile_override_get_param(uint32_t param,
- uint32_t *value)
-{
- return EC_RES_INVALID_PARAM;
-}
-
-enum ec_status charger_profile_override_set_param(uint32_t param,
- uint32_t value)
-{
- return EC_RES_INVALID_PARAM;
-}
-
-/* Initialize board USC-C things */
-static void board_init_usbc(void)
-{
- /* Enable USB-A overcurrent interrupt */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_oc));
-}
-DECLARE_HOOK(HOOK_INIT, board_init_usbc, HOOK_PRIO_DEFAULT);
-
-void board_tcpc_init(void)
-{
- /* Only reset TCPC if not sysjump */
- if (!system_jumped_late()) {
- /* TODO(crosbug.com/p/61098): How long do we need to wait? */
- board_reset_pd_mcu();
- }
-
- /* Enable PPC interrupts */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_swctl));
-
- /* Enable TCPC interrupts */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_pd));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_pd));
-
- /*
- * Initialize HPD to low; after sysjump SOC needs to see
- * HPD pulse to enable video path
- */
- for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
-}
-DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C);
-
-void board_reset_pd_mcu(void)
-{
- cprints(CC_USB, "Resetting TCPCs...");
- cflush();
-
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 0);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 0);
- msleep(PS8XXX_RESET_DELAY_MS);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 1);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 1);
- msleep(PS8805_FW_INIT_DELAY_MS);
-}
-
-void board_set_tcpc_power_mode(int port, int mode)
-{
- /* Ignore the "mode" to turn the chip on. We can only do a reset. */
- if (mode)
- return;
-
- board_reset_pd_mcu();
-}
-
-int board_vbus_sink_enable(int port, int enable)
-{
- /* Both ports are controlled by PPC SN5S330 */
- return ppc_vbus_sink_enable(port, enable);
-}
-
-int board_is_sourcing_vbus(int port)
-{
- /* Both ports are controlled by PPC SN5S330 */
- return ppc_is_sourcing_vbus(port);
-}
-
-void board_overcurrent_event(int port, int is_overcurrented)
-{
- /* TODO(b/120231371): Notify AP */
- CPRINTS("p%d: overcurrent!", port);
-}
-
-int board_set_active_charge_port(int port)
-{
- int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
- int i;
-
- if (!is_real_port && port != CHARGE_PORT_NONE)
- return EC_ERROR_INVAL;
-
- if (port == CHARGE_PORT_NONE) {
- CPRINTS("Disabling all charging port");
-
- /* Disable all ports. */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- /*
- * Do not return early if one fails otherwise we can
- * get into a boot loop assertion failure.
- */
- if (board_vbus_sink_enable(i, 0))
- CPRINTS("Disabling p%d sink path failed.", i);
- }
-
- return EC_SUCCESS;
- }
-
- /* Check if the port is sourcing VBUS. */
- if (board_is_sourcing_vbus(port)) {
- CPRINTS("Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
-
- CPRINTS("New charge port: p%d", port);
-
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- if (i == port)
- continue;
-
- if (board_vbus_sink_enable(i, 0))
- CPRINTS("p%d: sink path disable failed.", i);
- }
-
- /* Enable requested charge port. */
- if (board_vbus_sink_enable(port, 1)) {
- CPRINTS("p%d: sink path enable failed.", port);
- return EC_ERROR_UNKNOWN;
- }
-
- return EC_SUCCESS;
-}
-
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- /*
- * Ignore lower charge ceiling on PD transition if our battery is
- * critical, as we may brownout.
- */
- if (supplier == CHARGE_SUPPLIER_PD && charge_ma < 1500 &&
- charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) {
- CPRINTS("Using max ilim %d", max_ma);
- charge_ma = max_ma;
- }
-
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
-
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl)))
- if (gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l)))
- status |= PD_STATUS_TCPC_ALERT_0;
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_int_odl)))
- if (gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l)))
- status |= PD_STATUS_TCPC_ALERT_1;
-
- return status;
-}
diff --git a/zephyr/projects/herobrine/switchcap.dts b/zephyr/projects/herobrine/switchcap.dts
deleted file mode 100644
index ed200a0c6f..0000000000
--- a/zephyr/projects/herobrine/switchcap.dts
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- switchcap {
- compatible = "switchcap-gpio";
- enable-pin = <&gpio_switchcap_on>;
- power-good-pin = <&gpio_switchcap_pg>;
- };
-};
diff --git a/zephyr/projects/herobrine/switchcap_hoglin.dts b/zephyr/projects/herobrine/switchcap_hoglin.dts
deleted file mode 100644
index 7c083667a1..0000000000
--- a/zephyr/projects/herobrine/switchcap_hoglin.dts
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- switchcap {
- compatible = "switchcap-gpio";
- enable-pin = <&gpio_switchcap_on>;
- poff-delay-ms = <550>;
- };
-};
diff --git a/zephyr/projects/herobrine/usbc_evoker.dts b/zephyr/projects/herobrine/usbc_evoker.dts
deleted file mode 100644
index 20bd48382f..0000000000
--- a/zephyr/projects/herobrine/usbc_evoker.dts
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- ppc = <&ppc_port0>;
- tcpc = <&tcpc_port0>;
- chg = <&charger>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&usb_mux_0>;
- };
- };
- usb_mux_0: usb-mux-0 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
-
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- ppc = <&ppc_port1>;
- tcpc = <&tcpc_port1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&usb_mux_1>;
- };
- };
- usb_mux_1: usb-mux-1 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
- };
-};
diff --git a/zephyr/projects/herobrine/usbc_herobrine.dts b/zephyr/projects/herobrine/usbc_herobrine.dts
deleted file mode 100644
index 675286ecd7..0000000000
--- a/zephyr/projects/herobrine/usbc_herobrine.dts
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- ppc = <&ppc_port0>;
- ppc_alt = <&ppc_port0_alt>;
- tcpc = <&tcpc_port0>;
- chg = <&charger>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&usb_mux_0>;
- };
- };
- usb_mux_0: usb-mux-0 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
-
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- ppc = <&ppc_port1>;
- tcpc = <&tcpc_port1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&usb_mux_1>;
- };
- };
- usb_mux_1: usb-mux-1 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
- };
-};
diff --git a/zephyr/projects/herobrine/usbc_hoglin.dts b/zephyr/projects/herobrine/usbc_hoglin.dts
deleted file mode 100644
index 20bd48382f..0000000000
--- a/zephyr/projects/herobrine/usbc_hoglin.dts
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- ppc = <&ppc_port0>;
- tcpc = <&tcpc_port0>;
- chg = <&charger>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&usb_mux_0>;
- };
- };
- usb_mux_0: usb-mux-0 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
-
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- ppc = <&ppc_port1>;
- tcpc = <&tcpc_port1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&usb_mux_1>;
- };
- };
- usb_mux_1: usb-mux-1 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
- };
-};
diff --git a/zephyr/projects/herobrine/usbc_villager.dts b/zephyr/projects/herobrine/usbc_villager.dts
deleted file mode 100644
index 20bd48382f..0000000000
--- a/zephyr/projects/herobrine/usbc_villager.dts
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- ppc = <&ppc_port0>;
- tcpc = <&tcpc_port0>;
- chg = <&charger>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&usb_mux_0>;
- };
- };
- usb_mux_0: usb-mux-0 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
-
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- ppc = <&ppc_port1>;
- tcpc = <&tcpc_port1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&usb_mux_1>;
- };
- };
- usb_mux_1: usb-mux-1 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
- };
-};
diff --git a/zephyr/projects/herobrine/usbc_zombie.dts b/zephyr/projects/herobrine/usbc_zombie.dts
deleted file mode 100644
index 20bd48382f..0000000000
--- a/zephyr/projects/herobrine/usbc_zombie.dts
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- ppc = <&ppc_port0>;
- tcpc = <&tcpc_port0>;
- chg = <&charger>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&usb_mux_0>;
- };
- };
- usb_mux_0: usb-mux-0 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
-
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- ppc = <&ppc_port1>;
- tcpc = <&tcpc_port1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&usb_mux_1>;
- };
- };
- usb_mux_1: usb-mux-1 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
- };
-};
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts
deleted file mode 100644
index 527a62e776..0000000000
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/adlrvp_mchp.dts
+++ /dev/null
@@ -1,201 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-irqs = <
- &int_ac_present
- &int_lid_open
- &int_power_button
- >;
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- i2c_charger: charger {
- i2c-port = <&i2c_smb_0>;
- enum-names = "I2C_PORT_BATTERY",
- "I2C_PORT_CHARGER",
- "I2C_PORT_EEPROM",
- "I2C_PORT_PORT80";
- };
- typec_0: typec-0 {
- i2c-port = <&i2c_smb_1>;
- enum-names = "I2C_PORT_TYPEC_0";
- };
- typec_1: typec-1 {
- i2c-port = <&i2c_smb_2>;
- enum-names = "I2C_PORT_TYPEC_1";
- };
- typec_2: typec-2 {
- i2c-port = <&i2c_smb_3>;
- enum-names = "I2C_PORT_TYPEC_2";
- };
- typec_3: typec-3 {
- i2c-port = <&i2c_smb_4>;
- enum-names = "I2C_PORT_TYPEC_3";
- };
- };
-};
-
-/* charger */
-&i2c_smb_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
- port_sel = <0>;
- pinctrl-0 = <&i2c00_scl_gpio004 &i2c00_sda_gpio003>;
- pinctrl-names = "default";
-
- pca95xx: pca95xx@22 {
- compatible = "nxp,pca95xx";
- label = "PCA95XX";
- reg = <0x22>;
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <16>;
- };
-
- rvp_board_id: rvp-board-id {
- compatible = "intel,rvp-board-id";
-
- /*
- * BOM ID [2] : IOEX[0]
- * BOM ID [1:0] : IOEX[15:14]
- */
- bom-gpios = <&pca95xx 0 0>, <&pca95xx 15 0>, <&pca95xx 14 0>;
-
- /*
- * FAB ID [1:0] : IOEX[2:1]
- */
- fab-gpios = <&pca95xx 2 0>, <&pca95xx 1 0>;
-
- /*
- * BOARD ID[5:0] : IOEX[13:8]
- */
- board-gpios = <&pca95xx 13 0>, <&pca95xx 12 0>, <&pca95xx 11 0>,
- <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>;
- };
-
- seven_seg_display: max695x-seven-seg-display@38 {
- compatible = "maxim,seven-seg-display";
- reg = <0x38>;
- label = "MAX695X_SEVEN_SEG_DISPLAY";
- };
-
- charger: isl9241@9 {
- compatible = "intersil,isl9241";
- status = "okay";
- reg = <0x9>;
- };
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
-};
-
-/* typec_0 */
-&i2c_smb_1 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- port_sel = <6>;
- pinctrl-0 = <&i2c06_scl_gpio140 &i2c06_sda_gpio132>;
- pinctrl-names = "default";
-
- tcpc_port0: fusb302@22 {
- compatible = "fairchild,fusb302";
- reg = <0x22>;
- };
-
- usb_c0_soc_side_bb_retimer: jhl8040r-c0-soc-side@54 {
- compatible = "intel,jhl8040r";
- reg = <0x54>;
- reset-pin = <&usb_c0_bb_retimer_rst>;
- ls-en-pin = <&usb_c0_bb_retimer_ls_en>;
- };
-
- usb_c0_bb_retimer: jhl8040r-c0@56 {
- compatible = "intel,jhl8040r";
- reg = <0x56>;
- reset-pin = <&usb_c0_bb_retimer_rst>;
- ls-en-pin = <&usb_c0_bb_retimer_ls_en>;
- };
-};
-
-/* typec_1 */
-&i2c_smb_2 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- port_sel = <3>;
- pinctrl-0 = <&i2c03_scl_gpio010 &i2c03_sda_gpio007>;
- pinctrl-names = "default";
-
- tcpc_port1: fusb302@22 {
- compatible = "fairchild,fusb302";
- reg = <0x22>;
- };
-
- usb_c1_soc_side_bb_retimer: jhl8040r-c1-soc-side@55 {
- compatible = "intel,jhl8040r";
- reg = <0x55>;
- reset-pin = <&usb_c1_bb_retimer_rst>;
- ls-en-pin = <&usb_c1_bb_retimer_ls_en>;
- };
-
- usb_c1_bb_retimer: jhl8040r-c1@57 {
- compatible = "intel,jhl8040r";
- reg = <0x57>;
- reset-pin = <&usb_c1_bb_retimer_rst>;
- ls-en-pin = <&usb_c1_bb_retimer_ls_en>;
- };
-};
-
-/* typec_2 */
-&i2c_smb_3 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- port_sel = <7>;
- pinctrl-0 = <&i2c07_scl_gpio013 &i2c07_sda_gpio012>;
- pinctrl-names = "default";
-
- tcpc_port2: fusb302@22 {
- compatible = "fairchild,fusb302";
- reg = <0x22>;
- };
-
- usb_c2_bb_retimer: jhl8040r-c2@58 {
- compatible = "intel,jhl8040r";
- reg = <0x58>;
- reset-pin = <&usb_c2_bb_retimer_rst>;
- ls-en-pin = <&usb_c2_bb_retimer_ls_en>;
- };
-};
-
-/* typec_3 */
-&i2c_smb_4 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- port_sel = <2>;
- pinctrl-0 = <&i2c02_scl_gpio155 &i2c02_sda_gpio154>;
- pinctrl-names = "default";
-
- tcpc_port3: fusb302@22 {
- compatible = "fairchild,fusb302";
- reg = <0x22>;
- };
-
- usb_c3_bb_retimer: jhl8040r-c3@59 {
- compatible = "intel,jhl8040r";
- reg = <0x59>;
- reset-pin = <&usb_c3_bb_retimer_rst>;
- ls-en-pin = <&usb_c3_bb_retimer_ls_en>;
- };
-};
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts
deleted file mode 100644
index b3577e6afd..0000000000
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/keyboard.dts
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- cros-keyscan {
- compatible = "cros-keyscan";
-
- output-settle = <80>;
- debounce-down = <9000>;
- debounce-up = <30000>;
- poll-timeout = <100000>;
-
- actual-key-mask = <
- 0x14 /* C0 */
- 0xff /* C1 */
- 0xff /* C2 */
- 0xff /* C3 */
- 0xff /* C4 */
- 0xf5 /* C5 */
- 0xff /* C6 */
- 0xa4 /* C7 */
- 0xff /* C8 */
- 0xfe /* C9 */
- 0x55 /* C10 */
- 0xfa /* C11 */
- 0xca /* C12 */
- >;
- };
-};
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/prj.conf b/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/prj.conf
deleted file mode 100644
index 083530c858..0000000000
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_mchp/prj.conf
+++ /dev/null
@@ -1,84 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_BOARD_ADLRVP_MCHP=y
-CONFIG_CROS_FLASH_XEC=y
-CONFIG_CROS_SYSTEM_XEC=y
-CONFIG_CROS_KB_RAW_XEC=y
-
-# For MCHP ESPI Drivers
-CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD=y
-CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION=y
-CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE=y
-CONFIG_ESPI_PERIPHERAL_XEC_EMI0=y
-CONFIG_ESPI_PERIPHERAL_ACPI_EC_IBF_EVT_DATA=y
-CONFIG_ESPI_PERIPHERAL_KBC_OBE_CBK=y
-CONFIG_ESPI_PERIPHERAL_KBC_IBF_EVT_DATA=y
-
-# Invoke SoC Python script to create zephyr.mchp.bin which
-# is zephyr.bin processed for Boot-ROM loading.
-CONFIG_MCHP_MEC_UNSIGNED_HEADER=y
-CONFIG_MCHP_MEC_HEADER_FLASH_SIZE_256K=y
-
-# Support Zephyr SPI NOR driver to work with MCHP SPI driver
-CONFIG_SPI_NOR=y
-CONFIG_SPI_XEC_QMSPI_FULL_DUPLEX=y
-
-# Sensors - MCHP TACH driver under sensor
-CONFIG_SENSOR=n
-CONFIG_SENSOR_SHELL=n
-
-# Debug option
-# Enable flash console commands
-CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=y
-
-
-## TODO - support following features next
-# Fan
-CONFIG_PLATFORM_EC_FAN=n
-
-# RTC
-CONFIG_PLATFORM_EC_RTC=n
-
-# PWM
-CONFIG_PWM=n
-CONFIG_PWM_SHELL=n
-
-## INTEL RVP
-# Host command
-CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET=n
-
-# Power Sequencing
-CONFIG_PLATFORM_EC_THROTTLE_AP=n
-
-## ADL RVP
-# CBI
-CONFIG_EEPROM=n
-CONFIG_EEPROM_AT24=n
-CONFIG_EEPROM_SHELL=n
-CONFIG_PLATFORM_EC_CBI_EEPROM=n
-
-# LED
-CONFIG_PLATFORM_EC_LED_COMMON=n
-CONFIG_PLATFORM_EC_LED_PWM=n
-CONFIG_PLATFORM_EC_LED_PWM_TASK_DISABLED=n
-
-# Temperature sensors
-CONFIG_PLATFORM_EC_TEMP_SENSOR=n
-CONFIG_PLATFORM_EC_THERMISTOR=n
-CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=n
-
-# Charger
-CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y
-
-# H1 issues second reset
-CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n
-
-# 7-Segment Display
-CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=n
-
-# Debug options
-# Enable flash console commands
-CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=y
-CONFIG_WDT_DISABLE_AT_BOOT=y
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts
deleted file mode 100644
index 79723beabd..0000000000
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/adlrvp_npcx.dts
+++ /dev/null
@@ -1,258 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- chosen {
- cros,rtc = &mtc;
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-irqs = <
- &int_ac_present
- &int_lid_open
- &int_power_button
- >;
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- i2c_charger: charger {
- i2c-port = <&i2c7_0>;
- enum-names = "I2C_PORT_BATTERY",
- "I2C_PORT_CHARGER",
- "I2C_PORT_EEPROM",
- "I2C_PORT_PORT80";
- };
- typec_0: typec-0 {
- i2c-port = <&i2c0_0>;
- enum-names = "I2C_PORT_TYPEC_0";
- };
- typec_1: typec-1 {
- i2c-port = <&i2c2_0>;
- enum-names = "I2C_PORT_TYPEC_1";
- };
- typec_2: typec-2 {
- i2c-port = <&i2c1_0>;
- enum-names = "I2C_PORT_TYPEC_2";
- };
- typec_3: typec-3 {
- i2c-port = <&i2c3_0>;
- enum-names = "I2C_PORT_TYPEC_3";
- };
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- adc_ambient: ambient {
- enum-name = "ADC_TEMP_SENSOR_1";
- io-channels = <&adc0 3>;
- };
- adc_ddr: ddr {
- enum-name = "ADC_TEMP_SENSOR_2";
- io-channels = <&adc0 4>;
- };
- adc_skin: skin {
- enum-name = "ADC_TEMP_SENSOR_3";
- io-channels = <&adc0 2>;
- };
- adc_vr: vr {
- enum-name = "ADC_TEMP_SENSOR_4";
- io-channels = <&adc0 1>;
- };
- };
-
-};
-
-/* host interface */
-&espi0 {
- status = "okay";
- pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
- pinctrl-names = "default";
-};
-
-/* charger */
-&i2c7_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
- pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
- pinctrl-names = "default";
-
- pca95xx: pca95xx@22 {
- compatible = "nxp,pca95xx";
- label = "PCA95XX";
- reg = <0x22>;
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <16>;
- };
-
- rvp_board_id: rvp-board-id {
- compatible = "intel,rvp-board-id";
-
- /*
- * BOM ID [2] : IOEX[0]
- * BOM ID [1:0] : IOEX[15:14]
- */
- bom-gpios = <&pca95xx 0 0>, <&pca95xx 15 0>, <&pca95xx 14 0>;
-
- /*
- * FAB ID [1:0] : IOEX[2:1]
- */
- fab-gpios = <&pca95xx 2 0>, <&pca95xx 1 0>;
-
- /*
- * BOARD ID[5:0] : IOEX[13:8]
- */
- board-gpios = <&pca95xx 13 0>, <&pca95xx 12 0>, <&pca95xx 11 0>,
- <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>;
- };
-
- seven_seg_display: max695x-seven-seg-display@38 {
- compatible = "maxim,seven-seg-display";
- reg = <0x38>;
- label = "MAX695X_SEVEN_SEG_DISPLAY";
- };
-
- charger: isl9241@9 {
- compatible = "intersil,isl9241";
- status = "okay";
- reg = <0x9>;
- };
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
-
-/* typec_0 */
-&i2c0_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
- pinctrl-names = "default";
-
- tcpc_port0: fusb302@22 {
- compatible = "fairchild,fusb302";
- reg = <0x22>;
- };
-
- usb_c0_soc_side_bb_retimer: jhl8040r-c0-soc-side@54 {
- compatible = "intel,jhl8040r";
- reg = <0x54>;
- reset-pin = <&usb_c0_bb_retimer_rst>;
- ls-en-pin = <&usb_c0_bb_retimer_ls_en>;
- };
-
- usb_c0_bb_retimer: jhl8040r-c0@56 {
- compatible = "intel,jhl8040r";
- reg = <0x56>;
- reset-pin = <&usb_c0_bb_retimer_rst>;
- ls-en-pin = <&usb_c0_bb_retimer_ls_en>;
- };
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-/* typec_1 */
-&i2c2_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>;
- pinctrl-names = "default";
-
- tcpc_port1: fusb302@22 {
- compatible = "fairchild,fusb302";
- reg = <0x22>;
- };
-
- usb_c1_soc_side_bb_retimer: jhl8040r-c1-soc-side@55 {
- compatible = "intel,jhl8040r";
- reg = <0x55>;
- reset-pin = <&usb_c1_bb_retimer_rst>;
- ls-en-pin = <&usb_c1_bb_retimer_ls_en>;
- };
-
- usb_c1_bb_retimer: jhl8040r-c1@57 {
- compatible = "intel,jhl8040r";
- reg = <0x57>;
- reset-pin = <&usb_c1_bb_retimer_rst>;
- ls-en-pin = <&usb_c1_bb_retimer_ls_en>;
- };
-};
-
-&i2c_ctrl2 {
- status = "okay";
-};
-
-/* typec_2 */
-&i2c1_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
- pinctrl-names = "default";
-
- tcpc_port2: fusb302@22 {
- compatible = "fairchild,fusb302";
- reg = <0x22>;
- };
-
- usb_c2_bb_retimer: jhl8040r-c2@58 {
- compatible = "intel,jhl8040r";
- reg = <0x58>;
- reset-pin = <&usb_c2_bb_retimer_rst>;
- ls-en-pin = <&usb_c2_bb_retimer_ls_en>;
- };
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-/* typec_3 */
-&i2c3_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
- pinctrl-names = "default";
-
- tcpc_port3: fusb302@22 {
- compatible = "fairchild,fusb302";
- reg = <0x22>;
- };
-
- usb_c3_bb_retimer: jhl8040r-c3@59 {
- compatible = "intel,jhl8040r";
- reg = <0x59>;
- reset-pin = <&usb_c3_bb_retimer_rst>;
- ls-en-pin = <&usb_c3_bb_retimer_ls_en>;
- };
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&adc0 {
- status = "okay";
- pinctrl-0 = <&adc0_chan1_gp44
- &adc0_chan2_gp43
- &adc0_chan3_gp42
- &adc0_chan4_gp41>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts
deleted file mode 100644
index 81d6e82f48..0000000000
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/keyboard.dts
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- cros-keyscan {
- compatible = "cros-keyscan";
-
- output-settle = <35>;
- debounce-down = <5000>;
- debounce-up = <40000>;
- poll-timeout = <100000>;
-
- actual-key-mask = <
- 0x14 /* C0 */
- 0xff /* C1 */
- 0xff /* C2 */
- 0xff /* C3 */
- 0xff /* C4 */
- 0xf5 /* C5 */
- 0xff /* C6 */
- 0xa4 /* C7 */
- 0xff /* C8 */
- 0xfe /* C9 */
- 0x55 /* C10 */
- 0xfa /* C11 */
- 0xca /* C12 */
- >;
- };
-};
-
-&cros_kb_raw {
- status = "okay";
- /* No KSO2 (it's inverted and implemented by GPIO) */
- pinctrl-0 = <
- &ksi0_gp31
- &ksi1_gp30
- &ksi2_gp27
- &ksi3_gp26
- &ksi4_gp25
- &ksi5_gp24
- &ksi6_gp23
- &ksi7_gp22
- &kso00_gp21
- &kso01_gp20
- &kso03_gp16
- &kso04_gp15
- &kso05_gp14
- &kso06_gp13
- &kso07_gp12
- &kso08_gp11
- &kso09_gp10
- &kso10_gp07
- &kso11_gp06
- &kso12_gp05
- >;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/prj.conf b/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/prj.conf
deleted file mode 100644
index 2c98fd9330..0000000000
--- a/zephyr/projects/intelrvp/adlrvp/adlrvp_npcx/prj.conf
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_BOARD_ADLRVP_NPCX=y
-CONFIG_CROS_FLASH_NPCX=y
-CONFIG_CROS_SYSTEM_NPCX=y
-CONFIG_SYSCON=y
-
-# Charger
-CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y
-
-# FAN
-CONFIG_TACH_NPCX=y
-
-# Keyboard
-CONFIG_CROS_KB_RAW_NPCX=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-
-# RTC
-CONFIG_PLATFORM_EC_RTC=y
diff --git a/zephyr/projects/intelrvp/adlrvp/prj.conf b/zephyr/projects/intelrvp/adlrvp/prj.conf
deleted file mode 100644
index 4bcee4a953..0000000000
--- a/zephyr/projects/intelrvp/adlrvp/prj.conf
+++ /dev/null
@@ -1,76 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Power Sequencing
-CONFIG_AP_X86_INTEL_TGL=y
-CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE=n
-CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
-CONFIG_PLATFORM_EC_POWERSEQ_ICELAKE=y
-
-# Battery
-CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y
-CONFIG_PLATFORM_EC_BATTERY_V2=y
-
-# BC1.2
-CONFIG_PLATFORM_EC_USB_CHARGER=n
-
-# CBI
-CONFIG_EEPROM=y
-CONFIG_EEPROM_AT24=y
-CONFIG_EEPROM_SHELL=n
-CONFIG_PLATFORM_EC_CBI_EEPROM=y
-
-# Charger
-CONFIG_PLATFORM_EC_CHARGER=y
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10
-CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=n
-CONFIG_PLATFORM_EC_CHARGER_BQ25720=y
-CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM=y
-CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_DV=70
-CONFIG_PLATFORM_EC_CHARGER_ISL9241=y
-CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_COMMON=y
-CONFIG_PLATFORM_EC_LED_PWM=y
-CONFIG_PLATFORM_EC_LED_PWM_TASK_DISABLED=y
-
-# Temperature sensors
-CONFIG_PLATFORM_EC_TEMP_SENSOR=y
-CONFIG_PLATFORM_EC_THERMISTOR=y
-CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y
-
-# USB-C and PD
-CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
-CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n
-CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n
-CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG=n
-CONFIG_PLATFORM_EC_USB_MUX_TUSB1044=y
-CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_REV30=y
-CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y
-CONFIG_PLATFORM_EC_USB_PD_USB4=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_FUSB302=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y
-CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y
-CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=y
-
-# IOEX
-CONFIG_PLATFORM_EC_IOEX_CROS_DRV=y
-CONFIG_PLATFORM_EC_IOEX_PCA9675=y
-CONFIG_GPIO_PCA95XX=y
-
-# 7-Segment Display
-CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=y
-
-# eSPI
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US=150
diff --git a/zephyr/projects/intelrvp/adlrvp/src/adlrvp.c b/zephyr/projects/intelrvp/adlrvp/src/adlrvp.c
deleted file mode 100644
index ce5196c60d..0000000000
--- a/zephyr/projects/intelrvp/adlrvp/src/adlrvp.c
+++ /dev/null
@@ -1,430 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* TODO: b/218904113: Convert to using Zephyr GPIOs */
-#include "gpio_signal.h"
-#include "adlrvp_zephyr.h"
-#include "common.h"
-#include "console.h"
-#include "intelrvp.h"
-#include "intel_rvp_board_id.h"
-#include "battery_fuel_gauge.h"
-#include "charger.h"
-#include "battery.h"
-#include "bq25710.h"
-#include "driver/retimer/bb_retimer_public.h"
-#include "extpower.h"
-#include "hooks.h"
-#include "ioexpander.h"
-#include "isl9241.h"
-#include "power/icelake.h"
-#include "sn5s330.h"
-#include "system.h"
-#include "task.h"
-#include "tusb1064.h"
-#include "usb_mux.h"
-#include "usbc/usb_muxes.h"
-#include "usbc_ppc.h"
-#include "util.h"
-
-#define CPRINTF(format, args...) cprintf(CC_COMMAND, format, ##args)
-#define CPRINTS(format, args...) cprints(CC_COMMAND, format, ##args)
-
-/* TCPC AIC GPIO Configuration */
-const struct tcpc_aic_gpio_config_t tcpc_aic_gpios[] = {
- [TYPE_C_PORT_0] = {
- .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p0)),
- .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p0)),
- .ppc_intr_handler = sn5s330_interrupt,
- },
-#if defined(HAS_TASK_PD_C1)
- [TYPE_C_PORT_1] = {
- .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p1)),
- .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p1)),
- .ppc_intr_handler = sn5s330_interrupt,
- },
-#endif
-#if defined(HAS_TASK_PD_C2)
- [TYPE_C_PORT_2] = {
- .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p2)),
- .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p2)),
- .ppc_intr_handler = sn5s330_interrupt,
- },
-#endif
-#if defined(HAS_TASK_PD_C3)
- [TYPE_C_PORT_3] = {
- .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p3)),
- .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p3)),
- .ppc_intr_handler = sn5s330_interrupt,
- },
-#endif
-};
-BUILD_ASSERT(ARRAY_SIZE(tcpc_aic_gpios) == CONFIG_USB_PD_PORT_MAX_COUNT);
-
-/* USB-C PPC configuration */
-struct ppc_config_t ppc_chips[] = {
- [TYPE_C_PORT_0] = {
- .i2c_port = I2C_PORT_TYPEC_0,
- .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC,
- .drv = &sn5s330_drv,
- },
-#if defined(HAS_TASK_PD_C1)
- [TYPE_C_PORT_1] = {
- .i2c_port = I2C_PORT_TYPEC_1,
- .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC,
- .drv = &sn5s330_drv
- },
-#endif
-#if defined(HAS_TASK_PD_C2)
- [TYPE_C_PORT_2] = {
- .i2c_port = I2C_PORT_TYPEC_2,
- .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC,
- .drv = &sn5s330_drv,
- },
-#endif
-#if defined(HAS_TASK_PD_C3)
- [TYPE_C_PORT_3] = {
- .i2c_port = I2C_PORT_TYPEC_3,
- .i2c_addr_flags = I2C_ADDR_SN5S330_TCPC_AIC_PPC,
- .drv = &sn5s330_drv,
- },
-#endif
-};
-BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == CONFIG_USB_PD_PORT_MAX_COUNT);
-unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
-
-/* Cache BB retimer power state */
-static bool cache_bb_enable[CONFIG_USB_PD_PORT_MAX_COUNT];
-
-void board_overcurrent_event(int port, int is_overcurrented)
-{
- /* Port 0 & 1 and 2 & 3 share same line for over current indication */
-#if defined(HAS_TASK_PD_C2)
- enum ioex_signal oc_signal = port < TYPE_C_PORT_2 ? IOEX_USB_C0_C1_OC :
- IOEX_USB_C2_C3_OC;
-#else
- enum ioex_signal oc_signal = IOEX_USB_C0_C1_OC;
-#endif
-
- /* Overcurrent indication is active low signal */
- ioex_set_level(oc_signal, is_overcurrented ? 0 : 1);
-}
-
-__override int bb_retimer_power_enable(const struct usb_mux *me, bool enable)
-{
- /*
- * ADL-P-DDR5 RVP SKU has cascaded retimer topology.
- * Ports with cascaded retimers share common load switch and reset pin
- * hence no need to set the power state again if the 1st retimer's power
- * status has already changed.
- */
- if (cache_bb_enable[me->usb_port] == enable)
- return EC_SUCCESS;
-
- cache_bb_enable[me->usb_port] = enable;
-
- /* Handle retimer's power domain.*/
- if (enable) {
- ioex_set_level(bb_controls[me->usb_port].usb_ls_en_gpio, 1);
-
- /*
- * minimum time from VCC to RESET_N de-assertion is 100us
- * For boards that don't provide a load switch control, the
- * retimer_init() function ensures power is up before calling
- * this function.
- */
- msleep(1);
- ioex_set_level(bb_controls[me->usb_port].retimer_rst_gpio, 1);
-
- /*
- * Allow 1ms time for the retimer to power up lc_domain
- * which powers I2C controller within retimer
- */
- msleep(1);
-
- } else {
- ioex_set_level(bb_controls[me->usb_port].retimer_rst_gpio, 0);
- msleep(1);
- ioex_set_level(bb_controls[me->usb_port].usb_ls_en_gpio, 0);
- }
- return EC_SUCCESS;
-}
-
-static void board_connect_c0_sbu_deferred(void)
-{
- int ccd_intr_level = gpio_get_level(GPIO_CCD_MODE_ODL);
-
- if (ccd_intr_level) {
- /* Default set the SBU lines to AUX mode on TCPC-AIC */
- ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_1, 0);
- ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_0, 0);
- } else {
- /* Set the SBU lines to CCD mode on TCPC-AIC */
- ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_1, 1);
- ioex_set_level(IOEX_USB_C0_USB_MUX_CNTRL_0, 0);
- }
-}
-DECLARE_DEFERRED(board_connect_c0_sbu_deferred);
-
-void board_connect_c0_sbu(enum gpio_signal s)
-{
- hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0);
-}
-
-static void enable_h1_irq(void)
-{
- gpio_enable_interrupt(GPIO_CCD_MODE_ODL);
-}
-DECLARE_HOOK(HOOK_INIT, enable_h1_irq, HOOK_PRIO_LAST);
-
-void set_charger_system_voltage(void)
-{
- switch (ADL_RVP_BOARD_ID(board_get_version())) {
- case ADLN_LP5_ERB_SKU_BOARD_ID:
- case ADLN_LP5_RVP_SKU_BOARD_ID:
- /*
- * As per b:196184163 configure the PPVAR_SYS depend
- * on AC or AC+battery
- */
- if (extpower_is_present() && battery_is_present()) {
- bq25710_set_min_system_voltage(
- CHARGER_SOLO, battery_get_info()->voltage_min);
- } else {
- bq25710_set_min_system_voltage(
- CHARGER_SOLO, battery_get_info()->voltage_max);
- }
- break;
-
- /* Add additional board SKUs */
- default:
- break;
- }
-}
-DECLARE_HOOK(HOOK_AC_CHANGE, set_charger_system_voltage, HOOK_PRIO_DEFAULT);
-
-static void configure_charger(void)
-{
- switch (ADL_RVP_BOARD_ID(board_get_version())) {
- case ADLN_LP5_ERB_SKU_BOARD_ID:
- case ADLN_LP5_RVP_SKU_BOARD_ID:
- /* charger chip BQ25720 support */
- chg_chips[0].i2c_addr_flags = BQ25710_SMBUS_ADDR1_FLAGS;
- chg_chips[0].drv = &bq25710_drv;
- set_charger_system_voltage();
- break;
-
- /* Add additional board SKUs */
- default:
- break;
- }
-}
-
-static void configure_retimer_usbmux(void)
-{
- struct usb_mux *mux;
-
- switch (ADL_RVP_BOARD_ID(board_get_version())) {
- case ADLN_LP5_ERB_SKU_BOARD_ID:
- case ADLN_LP5_RVP_SKU_BOARD_ID:
- /* enable TUSB1044RNQR redriver on Port0 */
- mux = USB_MUX_POINTER(DT_NODELABEL(usb_mux_chain_0), 0);
- mux->i2c_addr_flags = TUSB1064_I2C_ADDR14_FLAGS;
- mux->driver = &tusb1064_usb_mux_driver;
- mux->hpd_update = tusb1044_hpd_update;
-
-#if defined(HAS_TASK_PD_C1)
- mux = USB_MUX_POINTER(DT_NODELABEL(usb_mux_chain_1), 0);
- mux->driver = NULL;
- mux->hpd_update = NULL;
-#endif
- break;
-
- case ADLP_LP5_T4_RVP_SKU_BOARD_ID:
- /* No retimer on Port-2 */
-#if defined(HAS_TASK_PD_C2)
- mux = USB_MUX_POINTER(DT_NODELABEL(usb_mux_chain_2), 0);
- mux->driver = NULL;
-#endif
- break;
-
- case ADLP_DDR5_RVP_SKU_BOARD_ID:
- /*
- * ADL-P-DDR5 RVP has dual BB-retimers for port0 & port1.
- * Change the default usb mux config on runtime to support
- * dual retimer topology.
- */
- USB_MUX_ENABLE_ALTERNATIVE(usb_mux_alt_chain_0);
-#if defined(HAS_TASK_PD_C1)
- USB_MUX_ENABLE_ALTERNATIVE(usb_mux_alt_chain_1);
-#endif
- break;
-
- /* Add additional board SKUs */
-
- default:
- break;
- }
-}
-
-static void configure_battery_type(void)
-{
- int bat_cell_type;
-
- switch (ADL_RVP_BOARD_ID(board_get_version())) {
- case ADLM_LP4_RVP1_SKU_BOARD_ID:
- case ADLM_LP5_RVP2_SKU_BOARD_ID:
- case ADLM_LP5_RVP3_SKU_BOARD_ID:
- case ADLN_LP5_ERB_SKU_BOARD_ID:
- case ADLN_LP5_RVP_SKU_BOARD_ID:
- /* configure Battery to 2S based */
- bat_cell_type = BATTERY_TYPE(DT_ALIAS(getac_2s));
- break;
- default:
- /* configure Battery to 3S based */
- bat_cell_type = BATTERY_TYPE(DT_ALIAS(getac_3s));
- break;
- }
-
- /* Set the fixed battery type */
- battery_set_fixed_battery_type(bat_cell_type);
-}
-/******************************************************************************/
-/* PWROK signal configuration */
-/*
- * On ADLRVP, SYS_PWROK_EC is an output controlled by EC and uses ALL_SYS_PWRGD
- * as input.
- */
-const struct intel_x86_pwrok_signal pwrok_signal_assert_list[] = {
- {
- .gpio = GPIO_PCH_SYS_PWROK,
- .delay_ms = 3,
- },
-};
-const int pwrok_signal_assert_count = ARRAY_SIZE(pwrok_signal_assert_list);
-
-const struct intel_x86_pwrok_signal pwrok_signal_deassert_list[] = {
- {
- .gpio = GPIO_PCH_SYS_PWROK,
- },
-};
-const int pwrok_signal_deassert_count = ARRAY_SIZE(pwrok_signal_deassert_list);
-
-/*
- * Returns board information (board id[7:0] and Fab id[15:8]) on success
- * -1 on error.
- */
-__override int board_get_version(void)
-{
- /* Cache the board ID */
- static int adlrvp_board_id;
-
- int i;
- int rv = EC_ERROR_UNKNOWN;
-
- int fab_id, board_id, bom_id;
-
- /* Board ID is already read */
- if (adlrvp_board_id)
- return adlrvp_board_id;
-
- /*
- * IOExpander that has Board ID information is on DSW-VAL rail on
- * ADL RVP. On cold boot cycles, DSW-VAL rail is taking time to settle.
- * This loop retries to ensure rail is settled and read is successful
- */
- for (i = 0; i < RVP_VERSION_READ_RETRY_CNT; i++) {
- rv = gpio_pin_get_dt(&bom_id_config[0]);
-
- if (rv >= 0)
- break;
-
- k_msleep(1);
- }
-
- /* retrun -1 if failed to read board id */
- if (rv < 0)
- return -1;
-
- /*
- * BOM ID [2] : IOEX[0]
- * BOM ID [1:0] : IOEX[15:14]
- */
- bom_id = gpio_pin_get_dt(&bom_id_config[0]) << 2;
- bom_id |= gpio_pin_get_dt(&bom_id_config[1]) << 1;
- bom_id |= gpio_pin_get_dt(&bom_id_config[2]);
-
- /*
- * FAB ID [1:0] : IOEX[2:1] + 1
- */
- fab_id = gpio_pin_get_dt(&fab_id_config[0]) << 1;
- fab_id |= gpio_pin_get_dt(&fab_id_config[1]);
- fab_id += 1;
-
- /*
- * BOARD ID[5:0] : IOEX[13:8]
- */
- board_id = gpio_pin_get_dt(&board_id_config[0]) << 5;
- board_id |= gpio_pin_get_dt(&board_id_config[1]) << 4;
- board_id |= gpio_pin_get_dt(&board_id_config[2]) << 3;
- board_id |= gpio_pin_get_dt(&board_id_config[3]) << 2;
- board_id |= gpio_pin_get_dt(&board_id_config[4]) << 1;
- board_id |= gpio_pin_get_dt(&board_id_config[5]);
-
- CPRINTF("BID:0x%x, FID:0x%x, BOM:0x%x", board_id, fab_id, bom_id);
-
- adlrvp_board_id = board_id | (fab_id << 8);
- return adlrvp_board_id;
-}
-
-__override bool board_is_tbt_usb4_port(int port)
-{
- bool tbt_usb4 = true;
-
- switch (ADL_RVP_BOARD_ID(board_get_version())) {
- case ADLN_LP5_ERB_SKU_BOARD_ID:
- case ADLN_LP5_RVP_SKU_BOARD_ID:
- /* No retimer on both ports */
- tbt_usb4 = false;
- break;
-
- case ADLP_LP5_T4_RVP_SKU_BOARD_ID:
- /* No retimer on Port-2 hence no platform level AUX & LSx mux */
-#if defined(HAS_TASK_PD_C2)
- if (port == TYPE_C_PORT_2)
- tbt_usb4 = false;
-#endif
- break;
-
- /* Add additional board SKUs */
- default:
- break;
- }
-
- return tbt_usb4;
-}
-
-static int board_pre_task_peripheral_init(const struct device *unused)
-{
- ARG_UNUSED(unused);
-
- /* Initialized IOEX-0 to access IOEX-GPIOs needed pre-task */
- ioex_init(IOEX_C0_PCA9675);
-
- /* Make sure SBU are routed to CCD or AUX based on CCD status at init */
- board_connect_c0_sbu_deferred();
-
- /* Configure battery type */
- configure_battery_type();
-
- /* Reconfigure board specific charger drivers */
- configure_charger();
-
- /* Configure board specific retimer & mux */
- configure_retimer_usbmux();
-
- return 0;
-}
-SYS_INIT(board_pre_task_peripheral_init, APPLICATION,
- CONFIG_APPLICATION_INIT_PRIORITY);
diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts
deleted file mode 100644
index b120f6c05e..0000000000
--- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/interrupts.dts
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-/ {
- gpio-interrupts {
- compatible = "cros-ec,gpio-interrupts";
-
- int_lid_open: lid_open {
- irq-pin = <&smc_lid>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "lid_interrupt";
- };
- int_power_button: power_button {
- irq-pin = <&smc_onoff_n>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "power_button_interrupt";
- };
- int_ac_present: ac_present {
- irq-pin = <&bc_acok>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "extpower_interrupt";
- };
- int_ioex_kbd_intr_n: ioex_kbd_intr_n {
- irq-pin = <&ioex_kbd_intr_n>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "io_expander_it8801_interrupt";
- };
- int_usb_c0_c1_tcpc: usb_c0_tcpc {
- irq-pin = <&usbc_tcpc_alrt_p0>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "tcpc_alert_event";
- };
- int_usb_c0_ppc: usb_c0_ppc {
- irq-pin = <&usbc_tcpc_ppc_alrt_p0>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "ppc_interrupt";
- };
- int_usb_c1_ppc: usb_c1_ppc {
- irq-pin = <&usbc_tcpc_ppc_alrt_p1>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "ppc_interrupt";
- };
- int_usb_c2_tcpc: usb_c2_tcpc {
- irq-pin = <&usbc_tcpc_alrt_p2>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "tcpc_alert_event";
- };
- int_usb_c3_tcpc: usb_c3_tcpc {
- irq-pin = <&usbc_tcpc_alrt_p3>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "tcpc_alert_event";
- };
- int_ccd_mode: ccd_mode {
- irq-pin = <&ccd_mode_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "board_connect_c0_sbu";
- };
- };
-};
diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts
deleted file mode 100644
index 81d6e82f48..0000000000
--- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/keyboard.dts
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- cros-keyscan {
- compatible = "cros-keyscan";
-
- output-settle = <35>;
- debounce-down = <5000>;
- debounce-up = <40000>;
- poll-timeout = <100000>;
-
- actual-key-mask = <
- 0x14 /* C0 */
- 0xff /* C1 */
- 0xff /* C2 */
- 0xff /* C3 */
- 0xff /* C4 */
- 0xf5 /* C5 */
- 0xff /* C6 */
- 0xa4 /* C7 */
- 0xff /* C8 */
- 0xfe /* C9 */
- 0x55 /* C10 */
- 0xfa /* C11 */
- 0xca /* C12 */
- >;
- };
-};
-
-&cros_kb_raw {
- status = "okay";
- /* No KSO2 (it's inverted and implemented by GPIO) */
- pinctrl-0 = <
- &ksi0_gp31
- &ksi1_gp30
- &ksi2_gp27
- &ksi3_gp26
- &ksi4_gp25
- &ksi5_gp24
- &ksi6_gp23
- &ksi7_gp22
- &kso00_gp21
- &kso01_gp20
- &kso03_gp16
- &kso04_gp15
- &kso05_gp14
- &kso06_gp13
- &kso07_gp12
- &kso08_gp11
- &kso09_gp10
- &kso10_gp07
- &kso11_gp06
- &kso12_gp05
- >;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts
deleted file mode 100644
index 86a46e3e7a..0000000000
--- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/mtlrvp_npcx.dts
+++ /dev/null
@@ -1,273 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
- #include <dt-bindings/usb_pd_tcpm.h>
-
-/ {
- chosen {
- cros,rtc = &mtc;
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-irqs = <
- &int_ac_present
- &int_lid_open
- &int_power_button
- >;
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- i2c_charger: charger {
- i2c-port = <&i2c7_0>;
- enum-names = "I2C_PORT_CHARGER",
- "I2C_PORT_BATTERY",
- "I2C_PORT_EEPROM",
- "I2C_PORT_KB_DISCRETE",
- "I2C_PORT_PORT80";
- };
- typec_aic1: typec-aic1{
- i2c-port = <&i2c0_0>;
- enum-names = "I2C_PORT_TYPEC_AIC_1";
- };
- typec_aic2: typec-aic2{
- i2c-port = <&i2c1_0>;
- enum-names = "I2C_PORT_TYPEC_AIC_2";
- };
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- adc_ambient: ambient {
- enum-name = "ADC_TEMP_SENSOR_1";
- io-channels = <&adc0 3>;
- };
- adc_ddr: ddr {
- enum-name = "ADC_TEMP_SENSOR_2";
- io-channels = <&adc0 4>;
- };
- adc_skin: skin {
- enum-name = "ADC_TEMP_SENSOR_3";
- io-channels = <&adc0 2>;
- };
- adc_vr: vr {
- enum-name = "ADC_TEMP_SENSOR_4";
- io-channels = <&adc0 1>;
- };
- };
-};
-
-/* charger */
-&i2c7_0 {
- label = "I2C_CHARGER";
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
- pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
- pinctrl-names = "default";
-
- pca95xx: pca95xx@22 {
- compatible = "nxp,pca95xx";
- label = "PCA95XX";
- reg = <0x22>;
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <16>;
- };
-
- rvp_board_id: rvp-board-id {
- compatible = "intel,rvp-board-id";
-
- /*
- * BOM ID [2] : IOEX[0]
- * BOM ID [1:0] : IOEX[15:14]
- */
- bom-gpios = <&pca95xx 0 0>, <&pca95xx 15 0>, <&pca95xx 14 0>;
-
- /*
- * FAB ID [1:0] : IOEX[2:1]
- */
- fab-gpios = <&pca95xx 2 0>, <&pca95xx 1 0>;
-
- /*
- * BOARD ID[5:0] : IOEX[13:8]
- */
- board-gpios = <&pca95xx 13 0>, <&pca95xx 12 0>, <&pca95xx 11 0>,
- <&pca95xx 10 0>, <&pca95xx 9 0>, <&pca95xx 8 0>;
- };
-
- kb_discrete: ite-it8801@39 {
- compatible = "ite,it8801";
- reg = <0x39>;
- };
-
- seven_seg_display: max695x-seven-seg-display@38 {
- compatible = "maxim,seven-seg-display";
- reg = <0x38>;
- label = "MAX695X_SEVEN_SEG_DISPLAY";
- };
-
- charger: isl9241@9 {
- compatible = "intersil,isl9241";
- status = "okay";
- reg = <0x9>;
- };
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
-};
-
-/* host interface */
-&espi0 {
- status = "okay";
- pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
- pinctrl-names = "default";
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
-
-/* typec_aic1 */
-&i2c0_0 {
- label = "I2C_USB_C0_C1_TCPC";
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
- pinctrl-names = "default";
-
- tcpc_port0: nct38xx@73 {
- compatible = "nuvoton,nct38xx";
- reg = <0x73>;
- gpio-dev = <&nct38xx_c0>;
- tcpc-flags = <(
- TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_NO_DEBUG_ACC_CONTROL)>;
- };
-
- nct38xx_c0: nct38xx_c0@73 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "nuvoton,nct38xx-gpio";
- reg = <0x73>;
- label = "NCT38XX_C0";
-
- ioex_c0:gpio@0 {
- compatible = "nuvoton,nct38xx-gpio-port";
- reg = <0x0>;
- label = "NCT38XX_C0_GPIO0";
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <8>;
- pin_mask = <0xdc>;
- pinmux_mask = <0xff>;
- };
- };
-
- tcpc_port1: nct38xx@77 {
- compatible = "nuvoton,nct38xx";
- reg = <0x77>;
- gpio-dev = <&nct38xx_c1>;
- tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
- };
-
- nct38xx_c1: nct38xx_c1@77 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "nuvoton,nct38xx-gpio";
- reg = <0x77>;
- label = "NCT38XX_C1";
-
- ioex_c1:gpio@0 {
- compatible = "nuvoton,nct38xx-gpio-port";
- reg = <0x0>;
- label = "NCT38XX_C1_GPIO0";
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <8>;
- pin_mask = <0xdc>;
- pinmux_mask = <0xff>;
- };
- };
-
- nct38xx_alert_0 {
- compatible = "nuvoton,nct38xx-gpio-alert";
- irq-gpios = <&gpio4 0 GPIO_ACTIVE_LOW>;
- nct38xx-dev = <&nct38xx_c0 &nct38xx_c1>;
- label = "NCT38XX_ALERT_1";
- };
-
- usb_c0_hb_retimer: jhl8040r-c0@56 {
- compatible = "intel,jhl8040r";
- reg = <0x56>;
- reset-pin = <&usb_c0_hb_retimer_rst>;
- ls-en-pin = <&usb_c0_hb_retimer_ls_en>;
- };
-
- usb_c1_hb_retimer: jhl8040r-c1@57 {
- compatible = "intel,jhl8040r";
- reg = <0x57>;
- reset-pin = <&usb_c1_hb_retimer_rst>;
- ls-en-pin = <&usb_c1_hb_retimer_ls_en>;
- };
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-/* typec_aic2 */
-&i2c1_0 {
- label = "I2C_USB_C2_C3_TCPC";
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
- pinctrl-names = "default";
-
- tcpc_port2: ccgxxf@b {
- compatible = "cypress,ccgxxf";
- reg = <0xb>;
- };
-
- tcpc_port3: ccgxxf@1b {
- compatible = "cypress,ccgxxf";
- reg = <0x1b>;
- };
-
- usb_c2_hb_retimer: jhl8040r-c2@58 {
- compatible = "intel,jhl8040r";
- reg = <0x58>;
- reset-pin = <&usb_c2_hb_retimer_rst>;
- ls-en-pin = <&usb_c2_hb_retimer_ls_en>;
- };
-
- usb_c3_hb_retimer: jhl8040r-c3@59 {
- compatible = "intel,jhl8040r";
- reg = <0x59>;
- reset-pin = <&usb_c3_hb_retimer_rst>;
- ls-en-pin = <&usb_c3_hb_retimer_ls_en>;
- };
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&adc0 {
- status = "okay";
- pinctrl-0 = <&adc0_chan1_gp44
- &adc0_chan2_gp43
- &adc0_chan3_gp42
- &adc0_chan4_gp41>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf b/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf
deleted file mode 100644
index 45b101a7ac..0000000000
--- a/zephyr/projects/intelrvp/mtlrvp/mtlrvpp_npcx/prj.conf
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_BOARD_MTLRVP_NPCX=y
-CONFIG_CROS_FLASH_NPCX=y
-CONFIG_CROS_SYSTEM_NPCX=y
-CONFIG_SYSCON=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-
-# Fan
-CONFIG_TACH_NPCX=y
-
-#RTC
-CONFIG_PLATFORM_EC_RTC=y
diff --git a/zephyr/projects/intelrvp/mtlrvp/prj.conf b/zephyr/projects/intelrvp/mtlrvp/prj.conf
deleted file mode 100644
index 1a521d4c89..0000000000
--- a/zephyr/projects/intelrvp/mtlrvp/prj.conf
+++ /dev/null
@@ -1,80 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Power Sequencing
-CONFIG_AP_X86_INTEL_MTL=y
-CONFIG_X86_NON_DSX_PWRSEQ_MTL=y
-CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE=n
-CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
-
-# Battery
-CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y
-CONFIG_PLATFORM_EC_BATTERY_V2=y
-
-# CBI
-CONFIG_EEPROM=y
-CONFIG_EEPROM_AT24=y
-CONFIG_EEPROM_SHELL=n
-CONFIG_PLATFORM_EC_CBI_EEPROM=y
-CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y
-CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
-
-# Disable BC1.2
-CONFIG_PLATFORM_EC_USB_CHARGER=n
-
-# Charger
-CONFIG_PLATFORM_EC_CHARGER=y
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10
-CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=n
-CONFIG_PLATFORM_EC_CHARGER_ISL9241=y
-CONFIG_PLATFORM_EC_DEDICATED_CHARGE_PORT=y
-
-# IOEX
-CONFIG_PLATFORM_EC_IOEX_CROS_DRV=y
-CONFIG_PLATFORM_EC_IOEX_CCGXXF=y
-CONFIG_GPIO_PCA95XX=y
-CONFIG_GPIO_NCT38XX=y
-CONFIG_PLATFORM_EC_IOEX_IT8801=y
-
-#Keyboard from I/O expander
-CONFIG_PLATFORM_EC_KEYBOARD_DISCRETE=y
-CONFIG_CROS_KB_RAW_NPCX=n
-
-# Temperature sensors
-CONFIG_PLATFORM_EC_TEMP_SENSOR=y
-CONFIG_PLATFORM_EC_THERMISTOR=y
-CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y
-
-# USB CONFIG
-CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
-CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
-CONFIG_PLATFORM_EC_USB_MUX_TASK=y
-CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y
-CONFIG_PLATFORM_EC_USBC_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_CCGXXF=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y
-CONFIG_PLATFORM_EC_USB_PD_TRY_SRC=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU=y
-CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=y
-CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB=y
-CONFIG_PLATFORM_EC_USBC_VCONN=y
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y
-CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y
-CONFIG_PLATFORM_EC_USB_PD_USB4=y
-CONFIG_PLATFORM_EC_USB_PD_INT_SHARED=y
-CONFIG_PLATFORM_EC_USB_PD_PORT_0_SHARED=y
-CONFIG_PLATFORM_EC_USB_PD_PORT_1_SHARED=y
-
-# 7-Segment Display
-CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY=y
diff --git a/zephyr/projects/intelrvp/mtlrvp/src/board_power.c b/zephyr/projects/intelrvp/mtlrvp/src/board_power.c
deleted file mode 100644
index 301402bf0f..0000000000
--- a/zephyr/projects/intelrvp/mtlrvp/src/board_power.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/sys/atomic.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/drivers/gpio.h>
-
-#include <ap_power/ap_power.h>
-#include <ap_power/ap_power_events.h>
-#include <ap_power/ap_power_interface.h>
-#include <ap_power_override_functions.h>
-#include <power_signals.h>
-#include <x86_power_signals.h>
-
-#include "gpio_signal.h"
-#include "gpio/gpio.h"
-
-LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF);
-
-#if CONFIG_X86_NON_DSX_PWRSEQ_MTL
-#define X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS 50
-
-void board_ap_power_force_shutdown(void)
-{
- int timeout_ms = X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS;
-
- /* Turn off PCH_RMSRST to meet tPCH12 */
- power_signal_set(PWR_EC_PCH_RSMRST, 0);
-
- /* Turn off PRIM load switch. */
- power_signal_set(PWR_EN_PP3300_A, 0);
-
- /* Wait RSMRST to be off. */
- while (power_signal_get(PWR_RSMRST) && (timeout_ms > 0)) {
- k_msleep(1);
- timeout_ms--;
- };
-
- if (power_signal_get(PWR_RSMRST))
- LOG_WRN("RSMRST_ODL didn't go low! Assuming G3.");
-}
-
-void board_ap_power_action_g3_s5(void)
-{
- /* Turn on the PP3300_PRIM rail. */
- power_signal_set(PWR_EN_PP3300_A, 1);
-
- if (!power_wait_signals_timeout(
- IN_PGOOD_ALL_CORE,
- AP_PWRSEQ_DT_VALUE(wait_signal_timeout))) {
- ap_power_ev_send_callbacks(AP_POWER_PRE_INIT);
- }
-}
-
-bool board_ap_power_check_power_rails_enabled(void)
-{
- return power_signal_get(PWR_EN_PP3300_A);
-}
-#endif /* CONFIG_X86_NON_DSX_PWRSEQ_MTL */
diff --git a/zephyr/projects/intelrvp/mtlrvp/src/mtlrvp.c b/zephyr/projects/intelrvp/mtlrvp/src/mtlrvp.c
deleted file mode 100644
index 9d96a08712..0000000000
--- a/zephyr/projects/intelrvp/mtlrvp/src/mtlrvp.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "battery.h"
-#include "battery_fuel_gauge.h"
-#include "charger.h"
-#include "common.h"
-#include "console.h"
-#include "driver/retimer/bb_retimer_public.h"
-#include "driver/tcpm/ccgxxf.h"
-#include "driver/tcpm/nct38xx.h"
-#include "driver/tcpm/tcpci.h"
-#include "extpower.h"
-#include "gpio.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "intelrvp.h"
-#include "intel_rvp_board_id.h"
-#include "ioexpander.h"
-#include "isl9241.h"
-#include "keyboard_raw.h"
-#include "power/meteorlake.h"
-#include "sn5s330.h"
-#include "system.h"
-#include "task.h"
-#include "tusb1064.h"
-#include "usb_mux.h"
-#include "usbc_ppc.h"
-#include "util.h"
-
-#define CPRINTF(format, args...) cprintf(CC_COMMAND, format, ##args)
-#define CPRINTS(format, args...) cprints(CC_COMMAND, format, ##args)
-
-/*******************************************************************/
-/* USB-C Configuration Start */
-
-/* PPC */
-#define I2C_ADDR_SN5S330_P0 0x40
-#define I2C_ADDR_SN5S330_P1 0x41
-
-/* IOEX ports */
-enum ioex_port {
- IOEX_KBD = 0,
-#if defined(HAS_TASK_PD_C2)
- IOEX_C2_CCGXXF,
-#endif
- IOEX_COUNT
-};
-
-/* USB-C ports */
-enum usbc_port {
- USBC_PORT_C0 = 0,
- USBC_PORT_C1,
-#if defined(HAS_TASK_PD_C2)
- USBC_PORT_C2,
- USBC_PORT_C3,
-#endif
- USBC_PORT_COUNT
-};
-BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT);
-
-/* USB-C PPC configuration */
-struct ppc_config_t ppc_chips[] = {
- [USBC_PORT_C0] = {
- .i2c_port = I2C_PORT_TYPEC_AIC_1,
- .i2c_addr_flags = I2C_ADDR_SN5S330_P0,
- .drv = &sn5s330_drv,
- },
- [USBC_PORT_C1] = {
- .i2c_port = I2C_PORT_TYPEC_AIC_1,
- .i2c_addr_flags = I2C_ADDR_SN5S330_P1,
- .drv = &sn5s330_drv,
- },
-};
-unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
-
-/* TCPC AIC GPIO Configuration */
-const struct tcpc_aic_gpio_config_t tcpc_aic_gpios[] = {
- [USBC_PORT_C0] = {
- .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p0)),
- .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p0)),
- .ppc_intr_handler = sn5s330_interrupt,
- },
- [USBC_PORT_C1] = {
- .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p0)),
- .ppc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_ppc_alrt_p1)),
- .ppc_intr_handler = sn5s330_interrupt,
- },
-#if defined(HAS_TASK_PD_C2)
- [USBC_PORT_C2] = {
- .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p2)),
- /* No PPC alert for CCGXXF */
- },
- [USBC_PORT_C3] = {
- .tcpc_alert = GPIO_SIGNAL(DT_NODELABEL(usbc_tcpc_alrt_p3)),
- /* No PPC alert for CCGXXF */
- },
-#endif
-};
-BUILD_ASSERT(ARRAY_SIZE(tcpc_aic_gpios) == CONFIG_USB_PD_PORT_MAX_COUNT);
-
-static void board_connect_c0_sbu_deferred(void)
-{
- enum pd_power_role prole;
-
- if (gpio_get_level(GPIO_CCD_MODE_ODL)) {
- CPRINTS("Default AUX line connected");
- /* Default set the SBU lines to AUX mode */
- ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_1, 0);
- ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_0, 1);
- } else {
- prole = pd_get_power_role(USBC_PORT_C0);
- CPRINTS("%s debug device is attached",
- prole == PD_ROLE_SINK ? "Servo V4C/SuzyQ" : "Intel");
-
- if (prole == PD_ROLE_SINK) {
- /* Set the SBU lines to Google CCD mode */
- ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_1, 1);
- ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_0, 1);
- } else {
- /* Set the SBU lines to Intel CCD mode */
- ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_1, 0);
- ioex_set_level(IOEX_USB_C0_MUX_SBU_SEL_0, 0);
- }
- }
-}
-DECLARE_DEFERRED(board_connect_c0_sbu_deferred);
-
-void board_overcurrent_event(int port, int is_overcurrented)
-{
- /*
- * TODO: Meteorlake PCH does not use Physical GPIO for over current
- * error, hence Send 'Over Current Virtual Wire' eSPI signal.
- */
-}
-
-void board_reset_pd_mcu(void)
-{
- /* Reset NCT38XX TCPC */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(usb_c0_c1_tcpc_rst_odl), 0);
- msleep(NCT38XX_RESET_HOLD_DELAY_MS);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(usb_c0_c1_tcpc_rst_odl), 1);
- nct38xx_reset_notify(0);
- nct38xx_reset_notify(1);
-
- if (NCT3807_RESET_POST_DELAY_MS != 0) {
- msleep(NCT3807_RESET_POST_DELAY_MS);
- }
-
- /* NCT38XX chip uses gpio ioex */
- gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_c0)));
- gpio_reset_port(DEVICE_DT_GET(DT_NODELABEL(ioex_c1)));
-
-#if defined(HAS_TASK_PD_C2)
- /* Reset the ccgxxf ports only resetting 1 is required */
- ccgxxf_reset(USBC_PORT_C2);
-
- /* CCGXXF has ioex on port 2 */
- ioex_init(IOEX_C2_CCGXXF);
-#endif
-}
-
-void board_connect_c0_sbu(enum gpio_signal signal)
-{
- hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0);
-}
-
-/******************************************************************************/
-/* KSO mapping for discrete keyboard */
-__override const uint8_t it8801_kso_mapping[] = {
- 0, 1, 20, 3, 4, 5, 6, 11, 12, 13, 14, 15, 16,
-};
-BUILD_ASSERT(ARRAY_SIZE(it8801_kso_mapping) == KEYBOARD_COLS_MAX);
-
-/* PWROK signal configuration */
-/*
- * On MTLRVP, SYS_PWROK_EC is an output controlled by EC and uses ALL_SYS_PWRGD
- * as input.
- */
-const struct intel_x86_pwrok_signal pwrok_signal_assert_list[] = {
- {
- .gpio = GPIO_PCH_SYS_PWROK,
- .delay_ms = 3,
- },
-};
-const int pwrok_signal_assert_count = ARRAY_SIZE(pwrok_signal_assert_list);
-
-const struct intel_x86_pwrok_signal pwrok_signal_deassert_list[] = {
- {
- .gpio = GPIO_PCH_SYS_PWROK,
- },
-};
-const int pwrok_signal_deassert_count = ARRAY_SIZE(pwrok_signal_deassert_list);
-
-/*
- * Returns board information (board id[7:0] and Fab id[15:8]) on success
- * -1 on error.
- */
-__override int board_get_version(void)
-{
- /* Cache the MTLRVP board ID */
- static int mtlrvp_board_id;
-
- int i;
- int rv = EC_ERROR_UNKNOWN;
- int fab_id, board_id, bom_id;
-
- /* Board ID is already read */
- if (mtlrvp_board_id)
- return mtlrvp_board_id;
-
- /*
- * IOExpander that has Board ID information is on DSW-VAL rail on
- * ADL RVP. On cold boot cycles, DSW-VAL rail is taking time to settle.
- * This loop retries to ensure rail is settled and read is successful
- */
- for (i = 0; i < RVP_VERSION_READ_RETRY_CNT; i++) {
- rv = gpio_pin_get_dt(&bom_id_config[0]);
-
- if (rv >= 0)
- break;
-
- k_msleep(1);
- }
-
- /* return -1 if failed to read board id */
- if (rv)
- return -1;
-
- /*
- * BOM ID [2] : IOEX[0]
- * BOM ID [1:0] : IOEX[15:14]
- */
- bom_id = gpio_pin_get_dt(&bom_id_config[0]) << 2;
- bom_id |= gpio_pin_get_dt(&bom_id_config[1]) << 1;
- bom_id |= gpio_pin_get_dt(&bom_id_config[2]);
- /*
- * FAB ID [1:0] : IOEX[2:1] + 1
- */
- fab_id = gpio_pin_get_dt(&fab_id_config[0]) << 1;
- fab_id |= gpio_pin_get_dt(&fab_id_config[1]);
- fab_id += 1;
-
- /*
- * BOARD ID[5:0] : IOEX[13:8]
- */
- board_id = gpio_pin_get_dt(&board_id_config[0]) << 5;
- board_id |= gpio_pin_get_dt(&board_id_config[1]) << 4;
- board_id |= gpio_pin_get_dt(&board_id_config[2]) << 3;
- board_id |= gpio_pin_get_dt(&board_id_config[3]) << 2;
- board_id |= gpio_pin_get_dt(&board_id_config[4]) << 1;
- board_id |= gpio_pin_get_dt(&board_id_config[5]);
-
- CPRINTF("BID:0x%x, FID:0x%x, BOM:0x%x", board_id, fab_id, bom_id);
-
- mtlrvp_board_id = board_id | (fab_id << 8);
- return mtlrvp_board_id;
-}
-
-static void board_int_init(void)
-{
- /* Enable PPC interrupts. */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc));
-
- /* Enable TCPC interrupts. */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_c1_tcpc));
-#if defined(HAS_TASK_PD_C2)
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c2_tcpc));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c3_tcpc));
-#endif
-
- /* Enable CCD Mode interrupt */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode));
-}
-
-static int board_pre_task_peripheral_init(const struct device *unused)
-{
- ARG_UNUSED(unused);
-
- /* Only reset tcpc/pd if not sysjump */
- if (!system_jumped_late()) {
- /* Initialize tcpc and all ioex */
- board_reset_pd_mcu();
- }
-
- /* Initialize all interrupts */
- board_int_init();
-
- /* Make sure SBU are routed to CCD or AUX based on CCD status at init */
- board_connect_c0_sbu_deferred();
-
- return 0;
-}
-SYS_INIT(board_pre_task_peripheral_init, APPLICATION,
- CONFIG_APPLICATION_INIT_PRIORITY);
-
-/*
- * Since MTLRVP has both PPC and TCPC ports override to check if the port
- * is a PPC or non PPC port
- */
-__override bool pd_check_vbus_level(int port, enum vbus_level level)
-{
- if (!board_port_has_ppc(port)) {
- return tcpm_check_vbus_level(port, level);
- } else if (level == VBUS_PRESENT) {
- return pd_snk_is_vbus_provided(port);
- } else {
- return !pd_snk_is_vbus_provided(port);
- }
-}
-
-__override bool board_port_has_ppc(int port)
-{
- bool ppc_port;
-
- switch (port) {
- case USBC_PORT_C0:
- case USBC_PORT_C1:
- ppc_port = true;
- break;
- default:
- ppc_port = false;
- break;
- }
-
- return ppc_port;
-}
diff --git a/zephyr/projects/intelrvp/prj.conf b/zephyr/projects/intelrvp/prj.conf
deleted file mode 100644
index df04eca101..0000000000
--- a/zephyr/projects/intelrvp/prj.conf
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-
-CONFIG_CROS_EC=y
-CONFIG_LTO=y
-CONFIG_PLATFORM_EC=y
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-CONFIG_SHIMMED_TASKS=y
-
-# Battery
-CONFIG_PLATFORM_EC_BATTERY=y
-CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
-CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
-CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
-CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
-CONFIG_PLATFORM_EC_BATTERY_SMART=y
-CONFIG_PLATFORM_EC_BATTERY_TYPE_NO_AUTO_DETECT=y
-CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000
-CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15001
-
-#Power Sequencing
-CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y
-
-# Host command
-CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET=y
-CONFIG_PLATFORM_EC_PORT80=y
-
-# USB-C and PD
-CONFIG_PLATFORM_EC_USB_VID=0x18d1
-CONFIG_PLATFORM_EC_USB_PID=0x8086
-CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=y
-
-# I2C
-CONFIG_I2C=y
-
-# eSPI
-CONFIG_ESPI=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD=y
-CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y
-CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
-CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y
-CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
-CONFIG_PLATFORM_EC_CMD_BUTTON=n
-
-# Sensors
-CONFIG_SENSOR=y
-CONFIG_SENSOR_SHELL=n
-
-# Shell Commands
-CONFIG_SHELL_HELP=y
-CONFIG_SHELL_HISTORY=y
-CONFIG_SHELL_TAB=y
-CONFIG_SHELL_TAB_AUTOCOMPLETION=y
-CONFIG_KERNEL_SHELL=y
-
-# Logging
-CONFIG_LOG=y
-CONFIG_LOG_MODE_MINIMAL=y
-
-# TODO
-# Below conf are disabled to compile successfully
-# These will be enabled in upcoming CLs
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
diff --git a/zephyr/projects/intelrvp/src/chg_usb_pd.c b/zephyr/projects/intelrvp/src/chg_usb_pd.c
deleted file mode 100644
index 63a1853b4d..0000000000
--- a/zephyr/projects/intelrvp/src/chg_usb_pd.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Common USB PD charge configuration */
-
-#include "charge_manager.h"
-#include "charge_state_v2.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "intelrvp.h"
-#include "tcpm/tcpci.h"
-
-#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args)
-#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args)
-
-bool is_typec_port(int port)
-{
-#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0
- return !(port == DEDICATED_CHARGE_PORT || port == CHARGE_PORT_NONE);
-#else
- return !(port == CHARGE_PORT_NONE);
-#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */
-}
-
-static inline int board_dc_jack_present(void)
-{
-#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0
- return gpio_get_level(GPIO_DC_JACK_PRESENT);
-#else
- return 0;
-#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */
-}
-
-static void board_dc_jack_handle(void)
-{
-#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0
- struct charge_port_info charge_dc_jack;
-
- /* System is booted from DC Jack */
- if (board_dc_jack_present()) {
- charge_dc_jack.current =
- (PD_MAX_POWER_MW * 1000) / DC_JACK_MAX_VOLTAGE_MV;
- charge_dc_jack.voltage = DC_JACK_MAX_VOLTAGE_MV;
- } else {
- charge_dc_jack.current = 0;
- charge_dc_jack.voltage = USB_CHARGER_VOLTAGE_MV;
- }
-
- charge_manager_update_charge(CHARGE_SUPPLIER_DEDICATED,
- DEDICATED_CHARGE_PORT, &charge_dc_jack);
-#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0 */
-}
-
-void board_dc_jack_interrupt(enum gpio_signal signal)
-{
- board_dc_jack_handle();
-}
-
-static void board_charge_init(void)
-{
- int port, supplier;
- struct charge_port_info charge_init = {
- .current = 0,
- .voltage = USB_CHARGER_VOLTAGE_MV,
- };
-
- /* Initialize all charge suppliers to seed the charge manager */
- for (port = 0; port < CHARGE_PORT_COUNT; port++) {
- for (supplier = 0; supplier < CHARGE_SUPPLIER_COUNT;
- supplier++) {
- charge_manager_update_charge(supplier, port,
- &charge_init);
- }
- }
-
- board_dc_jack_handle();
-}
-DECLARE_HOOK(HOOK_INIT, board_charge_init, HOOK_PRIO_DEFAULT);
-
-int board_set_active_charge_port(int port)
-{
- int i;
- /* charge port is a realy physical port */
- int is_real_port = (port >= 0 && port < CHARGE_PORT_COUNT);
- /* check if we are source vbus on that port */
- int source = board_vbus_source_enabled(port);
-
- if (is_real_port && source) {
- CPRINTS("Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
-
-#if CONFIG_DEDICATED_CHARGE_PORT_COUNT > 0
- /*
- * Do not enable Type-C port if the DC Jack is present.
- * When the Type-C is active port, hardware circuit will
- * block DC jack from enabling +VADP_OUT.
- */
- if (port != DEDICATED_CHARGE_PORT && board_dc_jack_present()) {
- CPRINTS("DC Jack present, Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
-#endif /* CONFIG_DEDICATED_CHARGE_PORT_COUNT */
-
- /* Make sure non-charging ports are disabled */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- if (i != port) {
- board_charging_enable(i, 0);
- }
- }
-
- /* Enable charging port */
- if (is_typec_port(port)) {
- board_charging_enable(port, 1);
- }
-
- CPRINTS("New chg p%d", port);
-
- return EC_SUCCESS;
-}
-
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/zephyr/projects/intelrvp/src/intel_rvp_board_id.c b/zephyr/projects/intelrvp/src/intel_rvp_board_id.c
deleted file mode 100644
index 77d4e93afd..0000000000
--- a/zephyr/projects/intelrvp/src/intel_rvp_board_id.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/devicetree.h>
-#include "intel_rvp_board_id.h"
-
-#define DT_DRV_COMPAT intel_rvp_board_id
-
-BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) <= 1,
- "Unsupported RVP Board ID instance");
-
-#define RVP_ID_GPIO_DT_SPEC_GET(idx, node_id, prop) \
- GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, idx),
-
-#define RVP_ID_CONFIG_LIST(node_id, prop) \
- LISTIFY(DT_PROP_LEN(node_id, prop), RVP_ID_GPIO_DT_SPEC_GET, (), \
- node_id, prop)
-
-#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
-const struct gpio_dt_spec bom_id_config[] = { RVP_ID_CONFIG_LIST(DT_DRV_INST(0),
- bom_gpios) };
-
-const struct gpio_dt_spec fab_id_config[] = { RVP_ID_CONFIG_LIST(DT_DRV_INST(0),
- fab_gpios) };
-
-const struct gpio_dt_spec board_id_config[] = { RVP_ID_CONFIG_LIST(
- DT_DRV_INST(0), board_gpios) };
-#endif /* #if DT_HAS_COMPAT_STATUS_OKAY */
diff --git a/zephyr/projects/intelrvp/zephyr_ap_pwrseq.conf b/zephyr/projects/intelrvp/zephyr_ap_pwrseq.conf
deleted file mode 100644
index 1ef365a8fa..0000000000
--- a/zephyr/projects/intelrvp/zephyr_ap_pwrseq.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Inbuilt AP Power Sequencing Config
-CONFIG_AP_PWRSEQ=y
-CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y
-CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y
-CONFIG_AP_PWRSEQ_S0IX=y
diff --git a/zephyr/projects/it8xxx2_evb/include/i2c_map.h b/zephyr/projects/it8xxx2_evb/include/i2c_map.h
deleted file mode 100644
index e83a238d3a..0000000000
--- a/zephyr/projects/it8xxx2_evb/include/i2c_map.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_CHROME_I2C_MAP_H
-#define __ZEPHYR_CHROME_I2C_MAP_H
-
-#include <zephyr/devicetree.h>
-
-#include "config.h"
-
-/* We need registers.h to get the chip specific defines for now */
-#include "i2c/i2c.h"
-
-#endif /* __ZEPHYR_CHROME_I2C_MAP_H */
diff --git a/zephyr/projects/it8xxx2_evb/prj.conf b/zephyr/projects/it8xxx2_evb/prj.conf
deleted file mode 100644
index d6d422e490..0000000000
--- a/zephyr/projects/it8xxx2_evb/prj.conf
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-CONFIG_SHIMMED_TASKS=y
-
-# SoC configuration
-CONFIG_AP=y
-CONFIG_AP_ARM_MTK_MT8192=y
-
-# Lid switch
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-
-# Logging
-CONFIG_LOG=y
-
-# Fan
-CONFIG_SENSOR=y
-
-# I2C
-CONFIG_I2C=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-
-# Power Button
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-
-# TODO(b:185202623): bring these features up
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=n
-CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n
-CONFIG_PLATFORM_EC_KEYBOARD=n
-CONFIG_CROS_KB_RAW_ITE=n
-CONFIG_PLATFORM_EC_SWITCH=n
-CONFIG_PLATFORM_EC_VBOOT_EFS2=n
-CONFIG_PLATFORM_EC_VBOOT_HASH=n
-
-# USB-C
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
-CONFIG_PLATFORM_EC_USB_PD_USB4=n
diff --git a/zephyr/projects/minimal/prj.conf b/zephyr/projects/minimal/prj.conf
deleted file mode 100644
index db7cac0cef..0000000000
--- a/zephyr/projects/minimal/prj.conf
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_PLATFORM_EC=y
-CONFIG_CROS_EC=y
-CONFIG_SHIMMED_TASKS=y
-CONFIG_SYSCON=y
-
-# Disable default features we don't want in a minimal example.
-CONFIG_ADC=n
-CONFIG_I2C=n
-CONFIG_PWM=n
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-CONFIG_PLATFORM_EC_KEYBOARD=n
-CONFIG_PLATFORM_EC_POWER_BUTTON=n
-CONFIG_PLATFORM_EC_SWITCH=n
-CONFIG_PLATFORM_EC_VBOOT_EFS2=n
diff --git a/zephyr/projects/nissa/BUILD.py b/zephyr/projects/nissa/BUILD.py
deleted file mode 100644
index b1affe7b4c..0000000000
--- a/zephyr/projects/nissa/BUILD.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Define zmake projects for nissa."""
-
-# Nivviks and Craask, Pujjo, Xivu has NPCX993F, Nereid and Joxer, Yaviks has ITE81302
-
-
-def register_nissa_project(
- project_name,
- chip="it81302bx",
-):
- """Register a variant of nissa."""
- register_func = register_binman_project
- if chip.startswith("npcx"):
- register_func = register_npcx_project
-
- chip_kconfig = {"it81302bx": "it8xxx2", "npcx9m3f": "npcx"}[chip]
-
- return register_func(
- project_name=project_name,
- zephyr_board=chip,
- dts_overlays=[here / project_name / "project.overlay"],
- kconfig_files=[
- here / "program.conf",
- here / f"{chip_kconfig}_program.conf",
- here / project_name / "project.conf",
- ],
- )
-
-
-nivviks = register_nissa_project(
- project_name="nivviks",
- chip="npcx9m3f",
-)
-
-nereid = register_nissa_project(
- project_name="nereid",
- chip="it81302bx",
-)
-
-craask = register_nissa_project(
- project_name="craask",
- chip="npcx9m3f",
-)
-
-pujjo = register_nissa_project(
- project_name="pujjo",
- chip="npcx9m3f",
-)
-
-xivu = register_nissa_project(
- project_name="xivu",
- chip="npcx9m3f",
-)
-
-joxer = register_nissa_project(
- project_name="joxer",
- chip="it81302bx",
-)
-
-yaviks = register_nissa_project(
- project_name="yaviks",
- chip="it81302bx",
-)
diff --git a/zephyr/projects/nissa/CMakeLists.txt b/zephyr/projects/nissa/CMakeLists.txt
deleted file mode 100644
index 8769af58ba..0000000000
--- a/zephyr/projects/nissa/CMakeLists.txt
+++ /dev/null
@@ -1,84 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
-
-zephyr_include_directories(include)
-zephyr_library_sources("src/common.c")
-zephyr_library_sources("src/sub_board.c")
-zephyr_library_sources_ifdef(CONFIG_AP_PWRSEQ "src/board_power.c")
-
-if(DEFINED CONFIG_BOARD_NIVVIKS)
- project(nivviks)
- zephyr_library_sources(
- "nivviks/src/led.c"
- "nivviks/src/form_factor.c"
- "nivviks/src/keyboard.c"
- )
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "nivviks/src/fan.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "nivviks/src/usbc.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "nivviks/src/charger.c")
-endif()
-if(DEFINED CONFIG_BOARD_NEREID)
- project(nereid)
- zephyr_library_sources(
- "src/led.c"
- "nereid/src/keyboard.c"
- "nereid/src/hdmi.c"
- )
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "nereid/src/usbc.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "nereid/src/charger.c")
-endif()
-if(DEFINED CONFIG_BOARD_CRAASK)
- zephyr_library_sources(
- "craask/src/form_factor.c"
- "craask/src/keyboard.c"
- "craask/src/led.c"
- )
- project(craask)
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "craask/src/usbc.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "craask/src/charger.c")
-endif()
-if(DEFINED CONFIG_BOARD_PUJJO)
- project(pujjo)
- zephyr_library_sources(
- "pujjo/src/led.c"
- "pujjo/src/keyboard.c"
- "pujjo/src/hdmi.c"
- "pujjo/src/form_factor.c"
- )
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "pujjo/src/fan.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "pujjo/src/usbc.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "pujjo/src/charger.c")
-endif()
-if(DEFINED CONFIG_BOARD_XIVU)
- project(xivu)
- zephyr_library_sources(
- "xivu/src/keyboard.c"
- )
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "xivu/src/usbc.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "xivu/src/charger.c")
-endif()
-if(DEFINED CONFIG_BOARD_JOXER)
- project(joxer)
- zephyr_library_sources(
- "joxer/src/led.c"
- "joxer/src/keyboard.c"
- )
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "joxer/src/usbc.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "joxer/src/charger.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "joxer/src/fan.c")
-endif()
-if(DEFINED CONFIG_BOARD_YAVIKS)
- project(yaviks)
- zephyr_library_sources(
- "yaviks/src/led.c"
- "yaviks/src/keyboard.c"
- )
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "yaviks/src/usbc.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER "yaviks/src/charger.c")
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "yaviks/src/fan.c")
-endif() \ No newline at end of file
diff --git a/zephyr/projects/nissa/Kconfig b/zephyr/projects/nissa/Kconfig
deleted file mode 100644
index 9e9ffc2528..0000000000
--- a/zephyr/projects/nissa/Kconfig
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-config BOARD_NIVVIKS
- bool "Google Nivviks Board"
- help
- Build Google Nivviks reference board. Nivviks has Intel ADL-N SoC
- with NPCX993FA0BX EC.
-
-config BOARD_NEREID
- bool "Google Nereid Board"
- help
- Build Google Nereid reference board. Nereid has Intel ADL-N SoC
- with IT81302 EC.
-
-config BOARD_CRAASK
- bool "Google Craask Board"
- help
- Build Google Craask board. Craask has Intel ADL-N SoC
- with NPCX993FA0BX EC.
-
-config BOARD_PUJJO
- bool "Google Pujjo Board"
- help
- Build Google Pujjo board. Pujjo has Intel ADL-N SoC
- with NPCX993FA0BX EC.
-
-config BOARD_XIVU
- bool "Google Xivu Board"
- help
- Build Google Xivu board. Xivu has Intel ADL-N SoC
- with NPCX993FA0BX EC.
-
-config BOARD_JOXER
- bool "Google Joxer Board"
- help
- Build Google Joxer reference board. Joxer has Intel ADL-N SoC
- with IT81302 EC.
-
-config BOARD_YAVIKS
- bool "Google Yaviks Board"
- help
- Build Google Yaviks board. Yaviks has Intel ADL-N SoC
- with IT81302 EC.
-
-
-module = NISSA
-module-str = Nissa board-specific code
-source "subsys/logging/Kconfig.template.log_config"
-
-source "Kconfig.zephyr"
diff --git a/zephyr/projects/nissa/craask/cbi.dtsi b/zephyr/projects/nissa/craask/cbi.dtsi
deleted file mode 100644
index 4c2e052f4d..0000000000
--- a/zephyr/projects/nissa/craask/cbi.dtsi
+++ /dev/null
@@ -1,107 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- /* Craask-specific fw_config fields. */
- nissa-fw-config {
- /*
- * FW_CONFIG field to describe Lid sensor orientation.
- */
- lid-inversion {
- enum-name = "FW_LID_INVERSION";
- start = <8>;
- size = <1>;
-
- /*
- * 0: regular placement of the lid sensor
- * 1: rotate 180' of xy plane.
- */
- regular {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_LID_REGULAR";
- value = <0>;
- default;
- };
- xy_rotate_180 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_LID_XY_ROT_180";
- value = <1>;
- };
- };
- /*
- * FW_CONFIG field to describe Clamshell/Convertible.
- */
- form_factor {
- enum-name = "FORM_FACTOR";
- start = <9>;
- size = <1>;
-
- /*
- * 0: convertible, 1: clamshell
- */
- convertible {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "CONVERTIBLE";
- value = <0>;
- };
- clamshell {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "CLAMSHELL";
- value = <1>;
- };
- };
- };
- /* Craask-specific ssfc fields. */
- cbi-ssfc {
- compatible = "named-cbi-ssfc";
- /*
- * SSFC bit0-1 was defined for AUDIO CODEC.
- * 0: ALC5682I_VS
- * 1: NAU8825
- */
- audio_codec {
- enum-name = "AUDIO_CODEC";
- size = <2>;
- };
- /*
- * SSFC field to identify LID motion sensor.
- */
- lid-sensor {
- enum-name = "LID_SENSOR";
- size = <2>;
-
- lid_sensor_0: lis2dw12 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
- value = <0>;
- default;
- };
- lid_sensor_1: bma422 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
- value = <1>;
- };
- };
- /*
- * SSFC field to identify BASE motion sensor.
- */
- base-sensor {
- enum-name = "BASE_SENSOR";
- size = <2>;
-
- base_sensor_0: lsm6dso {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
- value = <0>;
- default;
- };
- base_sensor_1: bmi323 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
- value = <1>;
- };
- };
- };
-};
diff --git a/zephyr/projects/nissa/craask/generated.dtsi b/zephyr/projects/nissa/craask/generated.dtsi
deleted file mode 100644
index 4303bbd4c5..0000000000
--- a/zephyr/projects/nissa/craask/generated.dtsi
+++ /dev/null
@@ -1,288 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc {
- enum-name = "ADC_PP1050_PROC";
- io-channels = <&adc0 4>;
- };
- adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 {
- enum-name = "ADC_PP3300_S5";
- io-channels = <&adc0 6>;
- };
- adc_temp_sensor_1: temp_sensor_1 {
- enum-name = "ADC_TEMP_SENSOR_1";
- io-channels = <&adc0 0>;
- };
- adc_temp_sensor_2: temp_sensor_2 {
- enum-name = "ADC_TEMP_SENSOR_2";
- io-channels = <&adc0 1>;
- };
- adc_temp_sensor_3: temp_sensor_3 {
- enum-name = "ADC_TEMP_SENSOR_3";
- io-channels = <&adc0 10>;
- };
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- gpio_acc_int_l: acc_int_l {
- gpios = <&gpio5 0 GPIO_INPUT>;
- };
- gpio_all_sys_pwrgd: all_sys_pwrgd {
- gpios = <&gpioa 7 GPIO_INPUT>;
- };
- gpio_ccd_mode_odl: ccd_mode_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- };
- gpio_cpu_c10_gate_l: cpu_c10_gate_l {
- gpios = <&gpio6 7 GPIO_INPUT>;
- };
- gpio_ec_battery_pres_odl: ec_battery_pres_odl {
- gpios = <&gpioa 3 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- };
- gpio_ec_cbi_wp: ec_cbi_wp {
- gpios = <&gpio7 4 GPIO_OUTPUT>;
- };
- gpio_ec_edp_bl_en_od: ec_edp_bl_en_od {
- gpios = <&gpiod 3 GPIO_ODR_HIGH>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- };
- gpio_ec_entering_rw: ec_entering_rw {
- gpios = <&gpio0 3 GPIO_OUTPUT>;
- enum-name = "GPIO_ENTERING_RW";
- };
- gpio_ec_gsc_packet_mode: ec_gsc_packet_mode {
- gpios = <&gpio7 5 GPIO_OUTPUT>;
- enum-name = "GPIO_PACKET_MODE_EN";
- };
- gpio_ec_kso_02_inv: ec_kso_02_inv {
- gpios = <&gpio1 7 (GPIO_OUTPUT | GPIO_ACTIVE_LOW)>;
- };
- gpio_ec_pch_wake_odl: ec_pch_wake_odl {
- gpios = <&gpiob 0 GPIO_ODR_LOW>;
- };
- gpio_ec_prochot_odl: ec_prochot_odl {
- gpios = <&gpiof 1 GPIO_ODR_HIGH>;
- };
- gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok {
- gpios = <&gpio6 1 GPIO_OUTPUT>;
- };
- gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd {
- gpios = <&gpioe 4 GPIO_OUTPUT>;
- };
- gpio_ec_soc_int_odl: ec_soc_int_odl {
- gpios = <&gpio8 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- };
- gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od {
- gpios = <&gpio7 2 GPIO_ODR_HIGH>;
- };
- gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl {
- gpios = <&gpioc 1 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PCH_PWRBTN_L";
- };
- gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l {
- gpios = <&gpioa 6 GPIO_OUTPUT>;
- };
- gpio_ec_soc_rtcrst: ec_soc_rtcrst {
- gpios = <&gpio7 6 GPIO_OUTPUT>;
- };
- gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok {
- gpios = <&gpio3 7 GPIO_OUTPUT>;
- };
- gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od {
- gpios = <&gpioa 4 GPIO_ODR_HIGH>;
- };
- gpio_ec_wp_odl: ec_wp_odl {
- gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
- };
- gpio_en_kb_bl: en_kb_bl {
- gpios = <&gpioa 0 GPIO_OUTPUT>;
- enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT";
- };
- gpio_en_pp3300_s5: en_pp3300_s5 {
- gpios = <&gpiob 6 GPIO_OUTPUT>;
- enum-name = "GPIO_TEMP_SENSOR_POWER";
- };
- gpio_en_pp5000_pen_x: en_pp5000_pen_x {
- gpios = <&gpioe 2 GPIO_OUTPUT>;
- };
- gpio_en_pp5000_s5: en_pp5000_s5 {
- gpios = <&gpio4 0 GPIO_OUTPUT>;
- };
- gpio_en_slp_z: en_slp_z {
- gpios = <&gpioe 1 GPIO_OUTPUT>;
- };
- gpio_en_usb_a0_vbus: en_usb_a0_vbus {
- gpios = <&gpio9 1 GPIO_OUTPUT>;
- };
- gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl {
- gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_POWER_BUTTON_L";
- };
- gpio_hdmi_sel: hdmi_sel {
- gpios = <&gpioc 6 GPIO_OUTPUT>;
- };
- gpio_imu_int_l: imu_int_l {
- gpios = <&gpio5 6 GPIO_INPUT>;
- };
- gpio_imvp91_vrrdy_od: imvp91_vrrdy_od {
- gpios = <&gpio4 3 GPIO_INPUT>;
- };
- gpio_lid_open: lid_open {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- };
- gpio_pen_detect_odl: pen_detect_odl {
- gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>;
- };
- gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od {
- gpios = <&gpiof 0 GPIO_INPUT>;
- };
- gpio_pg_pp5000_s5_od: pg_pp5000_s5_od {
- gpios = <&gpio4 2 GPIO_INPUT>;
- };
- gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l {
- gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>;
- };
- gpio_slp_s0_l: slp_s0_l {
- gpios = <&gpio9 7 GPIO_INPUT>;
- };
- gpio_slp_s3_l: slp_s3_l {
- gpios = <&gpioa 5 GPIO_INPUT>;
- };
- gpio_slp_s4_l: slp_s4_l {
- gpios = <&gpio7 0 GPIO_INPUT>;
- };
- gpio_slp_sus_l: slp_sus_l {
- gpios = <&gpio6 2 GPIO_INPUT>;
- };
- gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp {
- gpios = <&gpiod 5 GPIO_OUTPUT>;
- enum-name = "GPIO_USB2_ILIM_SEL";
- };
- gpio_sys_rst_odl: sys_rst_odl {
- gpios = <&gpioc 5 GPIO_ODR_HIGH>;
- };
- gpio_tablet_mode_l: tablet_mode_l {
- gpios = <&gpio9 5 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- };
- gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp {
- gpios = <&gpio8 5 GPIO_OUTPUT>;
- enum-name = "GPIO_USB1_ILIM_SEL";
- };
- gpio_usb_c0_int_odl: usb_c0_int_odl {
- gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>;
- };
- gpio_vccin_aux_vid0: vccin_aux_vid0 {
- gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- gpio_vccin_aux_vid1: vccin_aux_vid1 {
- gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- gpio_voldn_btn_odl: voldn_btn_odl {
- gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- };
- gpio_volup_btn_odl: volup_btn_odl {
- gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_UP_L";
- };
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- i2c_ec_i2c_eeprom: ec_i2c_eeprom {
- i2c-port = <&i2c0_0>;
- enum-names = "I2C_PORT_EEPROM";
- };
- i2c_ec_i2c_sensor: ec_i2c_sensor {
- i2c-port = <&i2c1_0>;
- enum-names = "I2C_PORT_SENSOR";
- };
- i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 {
- i2c-port = <&i2c3_0>;
- enum-names = "I2C_PORT_USB_C0_TCPC";
- };
- i2c_ec_i2c_sub_usb_c1: ec_i2c_sub_usb_c1 {
- i2c-port = <&i2c5_1>;
- enum-names = "I2C_PORT_USB_C1_TCPC";
- };
- i2c_ec_i2c_batt: ec_i2c_batt {
- i2c-port = <&i2c7_0>;
- enum-names = "I2C_PORT_BATTERY";
- };
- };
-};
-
-&adc0 {
- status = "okay";
- pinctrl-0 = <&adc0_chan0_gp45
- &adc0_chan1_gp44
- &adc0_chan4_gp41
- &adc0_chan6_gp34
- &adc0_chan10_gpe0>;
- pinctrl-names = "default";
-};
-
-&i2c0_0 {
- status = "okay";
- pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
- pinctrl-names = "default";
-};
-
-&i2c1_0 {
- status = "okay";
- pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
- pinctrl-names = "default";
-};
-
-&i2c3_0 {
- status = "okay";
- pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
- pinctrl-names = "default";
-};
-
-&i2c5_1 {
- status = "okay";
- pinctrl-0 = <&i2c5_1_sda_scl_gpf4_f5>;
- pinctrl-names = "default";
-};
-
-&i2c7_0 {
- status = "okay";
- pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
- pinctrl-names = "default";
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&i2c_ctrl5 {
- status = "okay";
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
diff --git a/zephyr/projects/nissa/craask/keyboard.dtsi b/zephyr/projects/nissa/craask/keyboard.dtsi
deleted file mode 100644
index f9e46de1f2..0000000000
--- a/zephyr/projects/nissa/craask/keyboard.dtsi
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-&cros_kb_raw {
- status = "okay";
- /* No KSO2 (it's inverted and implemented by GPIO) */
- pinctrl-0 = <
- &ksi0_gp31
- &ksi1_gp30
- &ksi2_gp27
- &ksi3_gp26
- &ksi4_gp25
- &ksi5_gp24
- &ksi6_gp23
- &ksi7_gp22
- &kso00_gp21
- &kso01_gp20
- &kso03_gp16
- &kso04_gp15
- &kso05_gp14
- &kso06_gp13
- &kso07_gp12
- &kso08_gp11
- &kso09_gp10
- &kso10_gp07
- &kso11_gp06
- &kso12_gp05
- >;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/nissa/craask/motionsense.dtsi b/zephyr/projects/nissa/craask/motionsense.dtsi
deleted file mode 100644
index 448aed6991..0000000000
--- a/zephyr/projects/nissa/craask/motionsense.dtsi
+++ /dev/null
@@ -1,257 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <dt-bindings/motionsense/utils.h>
-
-
-/ {
- aliases {
- /*
- * Interrupt bindings for sensor devices.
- */
- lsm6dso-int = &base_accel;
- lis2dw12-int = &lid_accel;
- bmi3xx-int = &base_accel;
- };
-
- /*
- * Declare mutexes used by sensor drivers.
- * A mutex node is used to create an instance of mutex_t.
- * A mutex node is referenced by a sensor node if the
- * corresponding sensor driver needs to use the
- * instance of the mutex.
- */
- motionsense-mutex {
- compatible = "cros-ec,motionsense-mutex";
- lid_mutex: lis2dw12-mutex {
- };
-
- lid_mutex_bma422: bma422-mutex {
- };
-
- base_mutex: base-mutex {
- };
-
- base_mutex_bmi323: bmi323-mutex {
- };
- };
-
- /* Rotation matrix used by drivers. */
- motionsense-rotation-ref {
- compatible = "cros-ec,motionsense-rotation-ref";
- lid_rot_ref: lid-rotation-ref {
- mat33 = <(-1) 0 0
- 0 1 0
- 0 0 (-1)>;
- };
-
- base_rot_ref: base-rotation-ref {
- mat33 = <1 0 0
- 0 (-1) 0
- 0 0 (-1)>;
- };
-
- base_rot_ver1: base-rotation-ver1 {
- mat33 = <(-1) 0 0
- 0 (-1) 0
- 0 0 1>;
- };
-
- lid_rot_bma422: lid-rotation-bma {
- mat33 = <1 0 0
- 0 (-1) 0
- 0 0 (-1)>;
- };
-
- base_rot_bmi323: base-rotation-bmi323 {
- mat33 = <1 0 0
- 0 (-1) 0
- 0 0 (-1)>;
- };
- };
-
- /*
- * Driver specific data. A driver-specific data can be shared with
- * different motion sensors while they are using the same driver.
- *
- * If a node's compatible starts with "cros-ec,accelgyro-", it is for
- * a common structure defined in accelgyro.h.
- * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
- * "struct als_drv_data_t" in accelgyro.h
- */
- motionsense-sensor-data {
- lsm6dso_accel_data: lsm6dso-accel-drv-data {
- compatible = "cros-ec,drvdata-lsm6dso";
- status = "okay";
- };
-
- lsm6dso_gyro_data: lsm6dso-gyro-drv-data {
- compatible = "cros-ec,drvdata-lsm6dso";
- status = "okay";
- };
-
- lis2dw12_data: lis2dw12-drv-data {
- compatible = "cros-ec,drvdata-lis2dw12";
- status = "okay";
- };
-
- bma422_data: bma4xx-drv-data {
- compatible = "cros-ec,drvdata-bma4xx";
- status = "okay";
- };
-
- bmi323_data: bmi323-drv-data {
- compatible = "cros-ec,drvdata-bmi3xx";
- status = "okay";
- };
- };
-
- /*
- * List of motion sensors that creates motion_sensors array.
- * The nodelabel "lid_accel" and "base_accel" are used to indicate
- * motion sensor IDs for lid angle calculation.
- * TODO(b/238139272): The first entries of the array must be
- * accelerometers,then gyroscope. Fix this dependency in the DTS
- * processing which makes the devicetree entries independent.
- */
- motionsense-sensor {
- lid_accel: lid-accel {
- compatible = "cros-ec,lis2dw12";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_LID";
- mutex = <&lid_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&lid_rot_ref>;
- default-range = <2>;
- drv-data = <&lis2dw12_data>;
- i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS";
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_accel: base-accel {
- compatible = "cros-ec,lsm6dso-accel";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&lsm6dso_accel_data>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_gyro: base-gyro {
- compatible = "cros-ec,lsm6dso-gyro";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */
- drv-data = <&lsm6dso_gyro_data>;
- };
- };
-
- motionsense-sensor-alt {
- alt_lid_accel: alt-lid-accel {
- compatible = "cros-ec,bma4xx";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_LID";
- mutex = <&lid_mutex_bma422>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&lid_rot_bma422>;
- default-range = <2>;
- drv-data = <&bma422_data>;
- i2c-spi-addr-flags = "BMA4_I2C_ADDR_PRIMARY";
- alternate-for = <&lid_accel>;
- alternate-ssfc-indicator = <&lid_sensor_1>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- alt_base_accel: alt-base-accel {
- compatible = "cros-ec,bmi3xx-accel";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex_bmi323>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&base_rot_bmi323>;
- drv-data = <&bmi323_data>;
- alternate-for = <&base_accel>;
- alternate-ssfc-indicator = <&base_sensor_1>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- alt_base_gyro: alt-base-gyro {
- compatible = "cros-ec,bmi3xx-gyro";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex_bmi323>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&base_rot_bmi323>;
- drv-data = <&bmi323_data>;
- alternate-for = <&base_gyro>;
- alternate-ssfc-indicator = <&base_sensor_1>;
- };
- };
-
- motionsense-sensor-info {
- compatible = "cros-ec,motionsense-sensor-info";
-
- /*
- * list of GPIO interrupts that have to
- * be enabled at initial stage
- */
- sensor-irqs = <&int_imu>;
- /* list of sensors in force mode */
- accel-force-mode-sensors = <&lid_accel>;
- };
-};
diff --git a/zephyr/projects/nissa/craask/overlay.dtsi b/zephyr/projects/nissa/craask/overlay.dtsi
deleted file mode 100644
index b3a510c111..0000000000
--- a/zephyr/projects/nissa/craask/overlay.dtsi
+++ /dev/null
@@ -1,360 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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>
-
-/ {
- aliases {
- gpio-cbi-wp = &gpio_ec_cbi_wp;
- gpio-wp = &gpio_ec_wp_odl;
- int-wp = &int_wp_l;
- gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
- };
-
- ec-console {
- compatible = "ec-console";
- disabled = "events", "lpc", "hostcmd";
- };
-
- batteries {
- default_battery: lgc {
- compatible = "lgc,ap18c8k", "battery-smart";
- };
- cosmx {
- compatible = "cosmx,ap20cbl", "battery-smart";
- };
- cosmx-2 {
- compatible = "cosmx,ap20cbl-2", "battery-smart";
- };
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-irqs = <
- &int_power_button
- &int_lid_open
- >;
- };
-
- gpio-interrupts {
- compatible = "cros-ec,gpio-interrupts";
-
- int_power_button: power_button {
- irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "power_button_interrupt";
- };
- int_wp_l: wp_l {
- irq-pin = <&gpio_ec_wp_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "switch_interrupt";
- };
- int_lid_open: lid_open {
- irq-pin = <&gpio_lid_open>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "lid_interrupt";
- };
- int_tablet_mode: tablet_mode {
- irq-pin = <&gpio_tablet_mode_l>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "gmr_tablet_switch_isr";
- };
- int_imu: ec_imu {
- irq-pin = <&gpio_imu_int_l>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "motion_interrupt";
- };
- int_vol_down: vol_down {
- irq-pin = <&gpio_voldn_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "button_interrupt";
- };
- int_vol_up: vol_up {
- irq-pin = <&gpio_volup_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "button_interrupt";
- };
- int_usb_c0: usb_c0 {
- irq-pin = <&gpio_usb_c0_int_odl>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "usb_interrupt";
- };
- int_usb_c1: usb_c1 {
- irq-pin = <&gpio_sb_1>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "usb_interrupt";
- };
- };
-
- named-gpios {
- gpio_sb_1: sb-1 {
- gpios = <&gpio0 2 GPIO_PULL_UP>;
- no-auto-init;
- };
-
- gpio_sb_2: sb-2 {
- gpios = <&gpiod 4 GPIO_OUTPUT>;
- no-auto-init;
- };
-
- /*
- * 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.
- */
- gpio_sb_3: sb-3 {
- gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>;
- no-auto-init;
- };
- gpio_sb_4: sb-4 {
- gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- no-auto-init;
- };
- ec-i2c-sensor-scl {
- gpios = <&gpio9 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec-i2c-sensor-sda {
- gpios = <&gpio8 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- };
-
- /*
- * Aliases used for sub-board GPIOs.
- */
- aliases {
- /*
- * Input GPIO when used with type-C port 1
- * Output when used with HDMI sub-board
- */
- gpio-usb-c1-int-odl = &gpio_sb_1;
- gpio-en-rails-odl = &gpio_sb_1;
- /*
- * Sub-board with type A USB, enable.
- */
- gpio-en-usb-a1-vbus = &gpio_sb_2;
- /*
- * HPD pins for HDMI sub-board.
- */
- gpio-hdmi-en-odl = &gpio_sb_3;
- gpio-hpd-odl = &gpio_sb_4;
- /*
- * Enable S5 rails for LTE sub-board
- */
- gpio-en-sub-s5-rails = &gpio_sb_2;
- };
-
- temp_memory: memory {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_1>;
- };
- temp_charger: charger {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_2>;
- };
- temp_ambient: ambient {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_3>;
- };
-
- named-temp-sensors {
- compatible = "cros-ec,temp-sensors";
- memory {
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_memory>;
- };
- charger {
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_charger>;
- };
- ambient {
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_ambient>;
- };
- };
-
- usba {
- compatible = "cros-ec,usba-port-enable-pins";
- /*
- * sb_2 is only configured as GPIO when USB-A1 is present,
- * but it's still safe to control when disabled.
- *
- * ILIM_SEL pins are referred to by legacy enum name,
- * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
- * sub-boards that don't have USB-A so is safe to control
- * regardless of system configuration.
- */
- enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
- status = "okay";
- };
-
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- chg = <&chg_port0>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&virtual_mux_0>;
- };
- };
- port0-muxes {
- virtual_mux_0: virtual-mux-0 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
- /*
- * TODO(b:211693800): port1 may not be present on some
- * sub-boards.
- */
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- chg = <&chg_port1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&virtual_mux_1 &anx7483_mux_1>;
- };
- usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux {
- compatible = "cros-ec,usb-mux-chain";
- alternative-chain;
- usb-muxes = <&virtual_mux_1>;
- };
- };
- port1-muxes {
- virtual_mux_1: virtual-mux-1 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
- };
-
- kblight {
- compatible = "cros-ec,kblight-pwm";
- pwms = <&pwm6 6 PWM_HZ(2400) PWM_POLARITY_NORMAL>;
- };
-};
-
-&thermistor_3V3_51K1_47K_4050B {
- status = "okay";
-};
-
-&adc_ec_vsense_pp3300_s5 {
- /*
- * Voltage divider on input has 47k upper and 220k lower legs with
- * 2714 mV full-scale reading on the ADC. Apply the largest possible
- * multiplier (without overflowing int32) to get the best possible
- * approximation of the actual ratio, but derate by a factor of two to
- * ensure unexpectedly high values won't overflow.
- */
- mul = <(791261 / 2)>;
- div = <(651975 / 2)>;
-};
-
-/* Set bus speeds for I2C */
-&i2c0_0 {
- label = "I2C_EEPROM";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
-};
-
-&i2c1_0 {
- label = "I2C_SENSOR";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c3_0 {
- label = "I2C_USB_C0_TCPC";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-
- bc12_port0: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- /*
- * BC1.2 interrupt is shared with TCPC, so
- * IRQ is not specified here and handled by
- * usb_c0_interrupt.
- */
- };
-
- chg_port0: isl923x@9 {
- compatible = "intersil,isl923x";
- status = "okay";
- reg = <0x9>;
- };
-};
-
-&i2c5_1 {
- label = "I2C_SUB_C1_TCPC";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-
- bc12_port1: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- };
-
- chg_port1: isl923x@9 {
- compatible = "intersil,isl923x";
- status = "okay";
- reg = <0x9>;
- };
-
- anx7483_mux_1: anx7483-mux-1@3e {
- compatible = "analogix,anx7483";
- reg = <0x3e>;
- board-set = "anx7483_set_default_tuning";
- };
-};
-
-&i2c7_0 {
- label = "I2C_BATTERY";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&pwm6 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm6_gpc0>;
- pinctrl-names = "default";
-};
-
-/* host interface */
-&espi0 {
- status = "okay";
- pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/nissa/craask/project.conf b/zephyr/projects/nissa/craask/project.conf
deleted file mode 100644
index b7f31cee63..0000000000
--- a/zephyr/projects/nissa/craask/project.conf
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_BOARD_CRAASK=y
-CONFIG_PLATFORM_EC_OCPC=y
-
-# Sensor drivers
-CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y
-CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
-CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y
-
-CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y
diff --git a/zephyr/projects/nissa/craask/src/charger.c b/zephyr/projects/nissa/craask/src/charger.c
deleted file mode 100644
index d4723e4a0a..0000000000
--- a/zephyr/projects/nissa/craask/src/charger.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-
-#include "battery.h"
-#include "charger.h"
-#include "charger/isl923x_public.h"
-#include "console.h"
-#include "extpower.h"
-#include "usb_pd.h"
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-int extpower_is_present(void)
-{
- int port;
- int rv;
- bool acok;
-
- for (port = 0; port < board_get_usb_pd_port_count(); port++) {
- rv = raa489000_is_acok(port, &acok);
- if ((rv == EC_SUCCESS) && acok)
- return 1;
- }
-
- return 0;
-}
-
-/*
- * Craask does not have a GPIO indicating whether extpower is present,
- * so detect using the charger(s).
- */
-__override void board_check_extpower(void)
-{
- static int last_extpower_present;
- int extpower_present = extpower_is_present();
-
- if (last_extpower_present ^ extpower_present)
- extpower_handle_update(extpower_present);
-
- last_extpower_present = extpower_present;
-}
-
-__override void board_hibernate(void)
-{
- /* Shut down the chargers */
- if (board_get_usb_pd_port_count() == 2)
- raa489000_hibernate(CHARGER_SECONDARY, true);
- raa489000_hibernate(CHARGER_PRIMARY, true);
- LOG_INF("Charger(s) hibernated");
- cflush();
-}
diff --git a/zephyr/projects/nissa/craask/src/form_factor.c b/zephyr/projects/nissa/craask/src/form_factor.c
deleted file mode 100644
index 59869eaa2f..0000000000
--- a/zephyr/projects/nissa/craask/src/form_factor.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/devicetree.h>
-#include <zephyr/logging/log.h>
-
-#include "accelgyro.h"
-#include "button.h"
-#include "cros_board_info.h"
-#include "cros_cbi.h"
-#include "driver/accelgyro_bmi323.h"
-#include "driver/accelgyro_lsm6dso.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "motionsense_sensors.h"
-#include "motion_sense.h"
-#include "tablet_mode.h"
-
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-/*
- * Mainboard orientation support.
- */
-
-#define LIS_ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_bma422))
-#define BMA_ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref))
-#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(base_rot_ver1))
-#define LID_SENSOR SENSOR_ID(DT_NODELABEL(lid_accel))
-#define BASE_SENSOR SENSOR_ID(DT_NODELABEL(base_accel))
-#define BASE_GYRO SENSOR_ID(DT_NODELABEL(base_gyro))
-#define ALT_LID_S SENSOR_ID(DT_NODELABEL(alt_lid_accel))
-
-static bool use_alt_sensor;
-
-void motion_interrupt(enum gpio_signal signal)
-{
- if (use_alt_sensor)
- bmi3xx_interrupt(signal);
- else
- lsm6dso_interrupt(signal);
-}
-
-static void form_factor_init(void)
-{
- int ret;
- uint32_t val;
- enum nissa_sub_board_type sb = nissa_get_sb_type();
-
- ret = cbi_get_board_version(&val);
- if (ret != EC_SUCCESS) {
- LOG_ERR("Error retrieving CBI BOARD_VER.");
- return;
- }
- /*
- * The volume up/down button are exchanged on ver3 USB
- * sub board.
- *
- * LTE:
- * volup -> gpioa2, voldn -> gpio93
- * USB:
- * volup -> gpio93, voldn -> gpioa2
- */
- if (val == 3 && sb == NISSA_SB_C_A) {
- LOG_INF("Volume up/down btn exchanged on ver3 USB sku");
- buttons[BUTTON_VOLUME_UP].gpio = GPIO_VOLUME_DOWN_L;
- buttons[BUTTON_VOLUME_DOWN].gpio = GPIO_VOLUME_UP_L;
- }
-
- /*
- * If the board version is 1
- * use ver1 rotation matrix.
- */
- if (val == 1) {
- LOG_INF("Switching to ver1 base");
- motion_sensors[BASE_SENSOR].rot_standard_ref = &ALT_MAT;
- motion_sensors[BASE_GYRO].rot_standard_ref = &ALT_MAT;
- }
-
- /*
- * If the firmware config indicates
- * an craaskbowl form factor, use the alternative
- * rotation matrix.
- */
- ret = cros_cbi_get_fw_config(FW_LID_INVERSION, &val);
- if (ret != 0) {
- LOG_ERR("Error retrieving CBI FW_CONFIG field %d",
- FW_LID_INVERSION);
- return;
- }
- if (val == FW_LID_XY_ROT_180) {
- LOG_INF("Lid sensor placement rotate 180 on xy plane");
- motion_sensors[LID_SENSOR].rot_standard_ref = &LIS_ALT_MAT;
- motion_sensors_alt[ALT_LID_S].rot_standard_ref = &BMA_ALT_MAT;
- }
-
- /* check which base sensor is used for motion_interrupt */
- use_alt_sensor = cros_cbi_ssfc_check_match(
- CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1)));
-
- motion_sensors_check_ssfc();
-
- /* Check if it's clamshell or convertible */
- ret = cros_cbi_get_fw_config(FORM_FACTOR, &val);
- if (ret != 0) {
- LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR);
- return;
- }
- if (val == CLAMSHELL) {
- LOG_INF("Clamshell: disable motionsense function.");
- motion_sensor_count = 0;
- gmr_tablet_switch_disable();
- gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu));
- gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l),
- GPIO_DISCONNECTED);
- }
-}
-DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/projects/nissa/craask/src/keyboard.c b/zephyr/projects/nissa/craask/src/keyboard.c
deleted file mode 100644
index 65229eb43f..0000000000
--- a/zephyr/projects/nissa/craask/src/keyboard.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "ec_commands.h"
-
-static const struct ec_response_keybd_config craask_kb = {
- .num_top_row_keys = 10,
- .action_keys = {
- TK_BACK, /* T1 */
- TK_REFRESH, /* T2 */
- TK_FULLSCREEN, /* T3 */
- TK_OVERVIEW, /* T4 */
- TK_SNAPSHOT, /* T5 */
- TK_BRIGHTNESS_DOWN, /* T6 */
- TK_BRIGHTNESS_UP, /* T7 */
- TK_VOL_MUTE, /* T8 */
- TK_VOL_DOWN, /* T9 */
- TK_VOL_UP, /* T10 */
- },
- .capabilities = KEYBD_CAP_SCRNLOCK_KEY,
-};
-
-__override const struct ec_response_keybd_config *
-board_vivaldi_keybd_config(void)
-{
- return &craask_kb;
-}
diff --git a/zephyr/projects/nissa/it8xxx2_program.conf b/zephyr/projects/nissa/it8xxx2_program.conf
deleted file mode 100644
index 3272c04209..0000000000
--- a/zephyr/projects/nissa/it8xxx2_program.conf
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_FLASH_IT8XXX2=y
-CONFIG_CROS_SYSTEM_IT8XXX2=y
-CONFIG_ESPI_IT8XXX2=y
-CONFIG_FPU=y
-# rv32iafc/ilp32f is not supported by the toolchain, so use soft-float
-CONFIG_FLOAT_HARD=n
-
-# EC performance is bad; limiting sensor data rate helps keep it from degrading
-# so much that it causes problems. b/240485526, b/230818312
-CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000
-
-# Allow more time for the charger to stabilise
-CONFIG_PLATFORM_EC_POWER_BUTTON_INIT_TIMEOUT=5
-
-# ITE has more space, so don't restrict shell
-CONFIG_SHELL_MINIMAL=n
-
-# RAM savings, since this chip is tight on available RAM.
-# It's useful to store a lot of logs for the host to request, but the default 4k
-# is pretty large.
-CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE_BUF_SIZE=2048
-# Our threads have short names, save 20 bytes per thread
-CONFIG_THREAD_MAX_NAME_LEN=12
-# Task stacks, tuned by experiment. Most expanded to prevent overflow, and a few
-# shrunk to save RAM.
-CONFIG_AP_PWRSEQ_STACK_SIZE=1408
-CONFIG_TASK_HOSTCMD_STACK_SIZE=1280
-CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1280
-CONFIG_TASK_PD_INT_STACK_SIZE=1280
-
-# TCPC+PPC: ITE on-chip for C0, PS8745 for optional C1
-CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8745=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_CHARGER=y
-# SM5803 controls power path on both ports
-CONFIG_PLATFORM_EC_USB_PD_5V_CHARGER_CTRL=y
-# SM5803 can discharge VBUS, but not via one of the available options;
-# pd_power_supply_reset() does discharge.
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE=n
-# The EC is put into programming mode while firmware is running
-# (after releasing reset) and PD after being reset will hard-reset
-# the port if a contract was already set up. If the system has no
-# battery, this will prevent programming because it will brown out
-# the system and reset. Inserting a delay gives the programmer more
-# time to put the EC into programming mode.
-CONFIG_PLATFORM_EC_USB_PD_STARTUP_DELAY_MS=2000
-
-# Charger driver and configuration
-CONFIG_PLATFORM_EC_OCPC=y
-CONFIG_PLATFORM_EC_CHARGER_SM5803=y
-CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS=21
-CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=15000
-
-# VSENSE: PP3300_S5 & PP1050_PROC
-CONFIG_VCMP_IT8XXX2=y
-CONFIG_SENSOR=y
-CONFIG_SENSOR_SHELL=n
diff --git a/zephyr/projects/nissa/joxer/motionsense.dtsi b/zephyr/projects/nissa/joxer/motionsense.dtsi
deleted file mode 100644
index 537cc34451..0000000000
--- a/zephyr/projects/nissa/joxer/motionsense.dtsi
+++ /dev/null
@@ -1,149 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <dt-bindings/motionsense/utils.h>
-
-
-/ {
- aliases {
- /*
- * Interrupt bindings for sensor devices.
- */
- bmi3xx-int = &base_accel;
- };
-
- /*
- * Declare mutexes used by sensor drivers.
- * A mutex node is used to create an instance of mutex_t.
- * A mutex node is referenced by a sensor node if the
- * corresponding sensor driver needs to use the
- * instance of the mutex.
- */
- motionsense-mutex {
- compatible = "cros-ec,motionsense-mutex";
- lid_mutex: lid-mutex {
- };
-
- base_mutex: base-mutex {
- };
- };
-
- /* Rotation matrix used by drivers. */
- motionsense-rotation-ref {
- compatible = "cros-ec,motionsense-rotation-ref";
- lid_rot_ref: lid-rotation-ref {
- mat33 = <0 (-1) 0
- (-1) 0 0
- 0 0 (-1)>;
- };
-
- base_rot_ref: base-rotation-ref {
- mat33 = <1 0 0
- 0 1 0
- 0 0 1>;
- };
- };
-
- /*
- * Driver specific data. A driver-specific data can be shared with
- * different motion sensors while they are using the same driver.
- *
- * If a node's compatible starts with "cros-ec,accelgyro-", it is for
- * a common structure defined in accelgyro.h.
- * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
- * "struct als_drv_data_t" in accelgyro.h
- */
- motionsense-sensor-data {
- bmi323_data: bmi323-drv-data {
- compatible = "cros-ec,drvdata-bmi3xx";
- status = "okay";
- };
-
- bma422_data: bma422-drv-data {
- compatible = "cros-ec,drvdata-bma4xx";
- status = "okay";
- };
- };
-
- /*
- * List of motion sensors that creates motion_sensors array.
- * The nodelabel "lid_accel" and "base_accel" are used to indicate
- * motion sensor IDs for lid angle calculation.
- * TODO(b/238139272): The first entries of the array must be
- * accelerometers,then gyroscope. Fix this dependency in the DTS
- * processing which makes the devicetree entries independent.
- */
- motionsense-sensor {
- lid_accel: lid-accel {
- compatible = "cros-ec,bma4xx";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_LID";
- mutex = <&lid_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&lid_rot_ref>;
- default-range = <2>;
- drv-data = <&bma422_data>;
- i2c-spi-addr-flags = "BMA4_I2C_ADDR_SECONDARY";
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_accel: base-accel {
- compatible = "cros-ec,bmi3xx-accel";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&bmi323_data>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_gyro: base-gyro {
- compatible = "cros-ec,bmi3xx-gyro";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&bmi323_data>;
- };
- };
-
- motionsense-sensor-info {
- compatible = "cros-ec,motionsense-sensor-info";
-
- /*
- * list of GPIO interrupts that have to
- * be enabled at initial stage
- */
- sensor-irqs = <&int_imu>;
- /* list of sensors in force mode */
- accel-force-mode-sensors = <&lid_accel>;
- };
-};
diff --git a/zephyr/projects/nissa/joxer/overlay.dtsi b/zephyr/projects/nissa/joxer/overlay.dtsi
deleted file mode 100644
index b587da8fb1..0000000000
--- a/zephyr/projects/nissa/joxer/overlay.dtsi
+++ /dev/null
@@ -1,445 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * 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>
-
-/ {
- aliases {
- gpio-cbi-wp = &gpio_ec_cbi_wp;
- gpio-wp = &gpio_ec_wp_odl;
- int-wp = &int_wp_l;
- /*
- * USB-C: interrupt input.
- * I2C pins are on i2c_ec_i2c_sub_usb_c1
- */
- gpio-usb-c1-int-odl = &gpio_sb_1;
- /*
- * USB-A: VBUS enable output
- * LTE: power enable output
- */
- gpio-en-usb-a1-vbus = &gpio_sb_2;
- /*
- * HDMI: power enable output, HDMI enable output,
- * and HPD input
- */
- gpio-en-rails-odl = &gpio_sb_1;
- gpio-hdmi-en-odl = &gpio_sb_4;
- gpio-hpd-odl = &gpio_sb_3;
- /*
- * Enable S5 rails for LTE sub-board
- */
- gpio-en-sub-s5-rails = &gpio_sb_2;
- };
-
- ec-console {
- compatible = "ec-console";
- disabled = "events", "lpc", "hostcmd";
- };
-
- batteries {
- default_battery: cosmx {
- compatible = "cosmx,gh02047xl", "battery-smart";
- };
- dynapack_atl_gh02047xl {
- compatible = "dynapack,atl_gh02047xl", "battery-smart";
- };
- dynapack_cosmx_gh02047xl {
- compatible = "dynapack,cosmx_gh02047xl", "battery-smart";
- };
- smp_coslight_gh02047xl {
- compatible = "smp,coslight_gh02047xl", "battery-smart";
- };
- smp_highpower_gh02047xl {
- compatible = "smp,highpower_gh02047xl", "battery-smart";
- };
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-irqs = <
- &int_power_button
- &int_lid_open
- >;
- };
-
- gpio-interrupts {
- compatible = "cros-ec,gpio-interrupts";
-
- int_power_button: power_button {
- irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "power_button_interrupt";
- };
- int_vol_down: vol_down {
- irq-pin = <&gpio_voldn_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "button_interrupt";
- };
- int_vol_up: vol_up {
- irq-pin = <&gpio_volup_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "button_interrupt";
- };
- int_wp_l: wp_l {
- irq-pin = <&gpio_ec_wp_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "switch_interrupt";
- };
- int_lid_open: lid_open {
- irq-pin = <&gpio_lid_open>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "lid_interrupt";
- };
- int_tablet_mode: tablet_mode {
- irq-pin = <&gpio_tablet_mode_l>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "gmr_tablet_switch_isr";
- };
- int_imu: ec_imu {
- irq-pin = <&gpio_imu_int_l>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "bmi3xx_interrupt";
- };
- int_usb_c0: usb_c0 {
- irq-pin = <&gpio_usb_c0_int_odl>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "usb_c0_interrupt";
- };
- int_usb_c1: usb_c1 {
- irq-pin = <&gpio_sb_1>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "usb_c1_interrupt";
- };
- };
-
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios = <&gpioc 3 0>,
- <&gpiod 4 0>,
- <&gpioh 2 0>,
- <&gpiol 4 0>;
- };
-
- named-gpios {
- /*
- * EC doesn't take any specific action on CC/SBU disconnect due to
- * fault, but this definition is useful for hardware testing.
- */
- gpio_usb_c0_prot_fault_odl: usb_c0_prot_fault_odl {
- gpios = <&gpiok 6 GPIO_INPUT_PULL_UP>;
- };
-
- gpio_sb_1: sb_1 {
- gpios = <&gpioe 6 0>;
- no-auto-init;
- };
- gpio_sb_2: sb_2 {
- gpios = <&gpiof 0 0>;
- no-auto-init;
- };
-
- gpio_sb_3: sb_3 {
- gpios = <&gpioe 7 0>;
- no-auto-init;
- };
- gpio_sb_4: sb_4 {
- gpios = <&gpioe 0 0>;
- no-auto-init;
- };
- gpio_fan_enable: fan-enable {
- gpios = <&gpiol 4 GPIO_OUTPUT>;
- no-auto-init;
- };
- gpio_power_led_gate: power_led_gate {
- gpios = <&gpiof 1 GPIO_OUTPUT_LOW>;
- };
- gpio_led_1_odl: led_1_odl {
- gpios = <&gpioa 1 GPIO_OUTPUT_HIGH>;
- };
- gpio_led_2_odl: led_2_odl {
- gpios = <&gpioa 2 GPIO_OUTPUT_HIGH>;
- };
- gpio_led_3_l: led_3_l {
- gpios = <&gpiol 2 GPIO_OUTPUT_HIGH>;
- };
- gpio_led_4_l: led_4_l {
- gpios = <&gpiol 3 GPIO_OUTPUT_HIGH>;
- };
- };
-
- temp_memory: memory {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_1>;
- };
- temp_charger: charger {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_2>;
- };
- temp_ambient: ambient {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_3>;
- };
-
- named-temp-sensors {
- compatible = "cros-ec,temp-sensors";
- memory {
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_memory>;
- };
- charger {
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_charger>;
- };
- ambient {
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_ambient>;
- };
- };
-
- usba {
- compatible = "cros-ec,usba-port-enable-pins";
- /*
- * sb_2 is only configured as GPIO when USB-A1 is present,
- * but it's still safe to control when disabled.
- *
- * ILIM_SEL pins are referred to by legacy enum name,
- * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
- * sub-boards that don't have USB-A so is safe to control
- * regardless of system configuration.
- */
- enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
- status = "okay";
- };
-
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- chg = <&chg_port0>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&virtual_mux_0>;
- };
- };
- port0-muxes {
- virtual_mux_0: virtual-mux-0 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- chg = <&chg_port1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&virtual_mux_1 &tcpci_mux_1>;
- };
- usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux {
- compatible = "cros-ec,usb-mux-chain";
- alternative-chain;
- usb-muxes = <&virtual_mux_1>;
- };
- };
- port1-muxes {
- virtual_mux_1: virtual-mux-1 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- tcpci_mux_1: tcpci-mux-1 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
- };
- };
- fans {
- compatible = "cros-ec,fans";
-
- fan_0 {
- pwms = <&pwm7 PWM_CHANNEL_7 PWM_KHZ(30) PWM_POLARITY_NORMAL>;
- tach = <&tach1>;
- rpm_min = <1500>;
- rpm_start = <1500>;
- rpm_max = <6500>;
- enable_gpio = <&gpio_fan_enable>;
- };
- };
-};
-
-&gpio_acc_int_l {
- gpios = <&gpioc 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
-};
-&gpio_imu_int_l {
- gpios = <&gpioj 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
-};
-&gpio_vccin_aux_vid0 {
- gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
-};
-&gpio_vccin_aux_vid1 {
- gpios = <&gpiok 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
-};
-
-&gpio_ec_prochot_odl {
- gpios = <&gpioi 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>;
-};
-
-&thermistor_3V3_51K1_47K_4050B {
- status = "okay";
-};
-
-&adc_ec_vsense_pp3300_s5 {
- /*
- * Voltage divider on input has 47k upper and 220k lower legs with 3 V
- * full-scale reading on the ADC. Apply the largest possible multiplier
- * (without overflowing int32) to get the best possible approximation
- * of the actual ratio, but derate by a factor of two to ensure
- * unexpectedly high values won't overflow.
- */
- mul = <(715828 / 2)>;
- div = <(589820 / 2)>;
-};
-
-&adc0 {
- pinctrl-0 = <&adc0_ch0_gpi0_default
- &adc0_ch2_gpi2_default
- &adc0_ch3_gpi3_default
- &adc0_ch13_gpl0_default
- &adc0_ch14_gpl1_default>;
- pinctrl-names = "default";
-};
-
-&pinctrl {
- i2c2_clk_gpf6_default: i2c2_clk_gpf6_default {
- gpio-voltage = "1v8";
- };
- i2c2_data_gpf7_default: i2c2_data_gpf7_default {
- gpio-voltage = "1v8";
- };
-};
-
-
-&i2c0 {
- label = "I2C_EEPROM";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
- pinctrl-0 = <&i2c0_clk_gpb3_default
- &i2c0_data_gpb4_default>;
- pinctrl-names = "default";
-};
-
-&i2c1 {
- label = "I2C_BATTERY";
- clock-frequency = <50000>;
- pinctrl-0 = <&i2c1_clk_gpc1_default
- &i2c1_data_gpc2_default>;
- pinctrl-names = "default";
-};
-
-&i2c2 {
- label = "I2C_SENSOR";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c2_clk_gpf6_default
- &i2c2_data_gpf7_default>;
- pinctrl-names = "default";
-};
-
-&i2c4 {
- label = "I2C_SUB_C1_TCPC";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
- pinctrl-0 = <&i2c4_clk_gpe0_default
- &i2c4_data_gpe7_default>;
- pinctrl-names = "default";
-
- bc12_port1: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- };
-
- chg_port1: sm5803@32 {
- compatible = "siliconmitus,sm5803";
- status = "okay";
- reg = <0x32>;
- };
-};
-
-&i2c_ec_i2c_sub_usb_c1 {
- /*
- * Dynamic speed setting is used for AP-controlled firmware update
- * of PS8745 TCPC/redriver: the AP lowers speed to 400 kHz in order
- * to use more efficient window programming, then sets it back when
- * done.
- */
- dynamic-speed;
-};
-
-&i2c5 {
- label = "I2C_USB_C0_TCPC";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
- pinctrl-0 = <&i2c5_clk_gpa4_default
- &i2c5_data_gpa5_default>;
- pinctrl-names = "default";
-
- bc12_port0: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- };
-
- chg_port0: sm5803@32 {
- compatible = "siliconmitus,sm5803";
- status = "okay";
- reg = <0x32>;
- };
-};
-
-/* pwm for fan */
-&pwm7 {
- status = "okay";
- prescaler-cx = <PWM_PRESCALER_C6>;
- pinctrl-0 = <&pwm7_gpa7_default>;
- pinctrl-names = "default";
-};
-
-/* fan tachometer sensor */
-&tach1 {
- status = "okay";
- channel = <IT8XXX2_TACH_CHANNEL_A>;
- pulses-per-round = <2>;
- pinctrl-0 = <&tach1a_gpd7_default>;
- pinctrl-names = "default";
-};
-
-&usbpd0 {
- status = "okay";
-};
diff --git a/zephyr/projects/nissa/joxer/src/charger.c b/zephyr/projects/nissa/joxer/src/charger.c
deleted file mode 100644
index b9454d8b80..0000000000
--- a/zephyr/projects/nissa/joxer/src/charger.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-
-#include "battery.h"
-#include "charger.h"
-#include "console.h"
-#include "driver/charger/sm5803.h"
-#include "extpower.h"
-#include "usb_pd.h"
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-int extpower_is_present(void)
-{
- int port;
- int rv;
- bool acok;
-
- for (port = 0; port < board_get_usb_pd_port_count(); port++) {
- rv = sm5803_is_acok(port, &acok);
- if ((rv == EC_SUCCESS) && acok)
- return 1;
- }
-
- return 0;
-}
-
-/*
- * Joxer not have a GPIO indicating whether extpower is present,
- * so detect using the charger(s).
- */
-__override void board_check_extpower(void)
-{
- static int last_extpower_present;
- int extpower_present = extpower_is_present();
-
- if (last_extpower_present ^ extpower_present)
- extpower_handle_update(extpower_present);
-
- last_extpower_present = extpower_present;
-}
-
-__override void board_hibernate(void)
-{
- /* Shut down the chargers */
- if (board_get_usb_pd_port_count() == 2)
- sm5803_hibernate(CHARGER_SECONDARY);
- sm5803_hibernate(CHARGER_PRIMARY);
- LOG_INF("Charger(s) hibernated");
- cflush();
-}
diff --git a/zephyr/projects/nissa/joxer/src/fan.c b/zephyr/projects/nissa/joxer/src/fan.c
deleted file mode 100644
index 6d234b2fc3..0000000000
--- a/zephyr/projects/nissa/joxer/src/fan.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/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);
-
-/*
- * Joxer 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/joxer/src/keyboard.c b/zephyr/projects/nissa/joxer/src/keyboard.c
deleted file mode 100644
index 48db40f53f..0000000000
--- a/zephyr/projects/nissa/joxer/src/keyboard.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/logging/log.h>
-
-#include "cros_cbi.h"
-#include "ec_commands.h"
-#include "gpio/gpio.h"
-#include "hooks.h"
-#include "keyboard_8042_sharedlib.h"
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-static const struct ec_response_keybd_config joxer_kb_legacy = {
- .num_top_row_keys = 13,
- .action_keys = {
- TK_BACK, /* T1 */
- TK_REFRESH, /* T2 */
- TK_FULLSCREEN, /* T3 */
- TK_OVERVIEW, /* T4 */
- TK_SNAPSHOT, /* T5 */
- TK_BRIGHTNESS_DOWN, /* T6 */
- TK_BRIGHTNESS_UP, /* T7 */
- TK_KBD_BKLIGHT_TOGGLE, /* T8 */
- TK_PLAY_PAUSE, /* T9 */
- TK_MICMUTE, /* T10 */
- TK_VOL_MUTE, /* T11 */
- TK_VOL_DOWN, /* T12 */
- TK_VOL_UP, /* T13 */
- },
- .capabilities = KEYBD_CAP_SCRNLOCK_KEY,
-};
-
-__override const struct ec_response_keybd_config *
-board_vivaldi_keybd_config(void)
-{
- return &joxer_kb_legacy;
-}
-
-/*
- * Keyboard layout decided by FW config.
- */
-static void kb_layout_init(void)
-{
- int ret;
- uint32_t val;
- /*
- * Retrieve the kb layout config.
- */
- ret = cros_cbi_get_fw_config(FW_KB_LAYOUT, &val);
- if (ret != 0) {
- LOG_ERR("Error retrieving CBI FW_CONFIG field %d",
- FW_KB_LAYOUT);
- return;
- }
- /*
- * If keyboard is US2(FW_KB_LAYOUT_US2), we need translate right ctrl
- * to backslash(\|) key.
- */
- if (val == FW_KB_LAYOUT_US2)
- set_scancode_set2(4, 0, get_scancode_set2(2, 7));
-}
-DECLARE_HOOK(HOOK_INIT, kb_layout_init, HOOK_PRIO_POST_FIRST);
diff --git a/zephyr/projects/nissa/joxer/src/led.c b/zephyr/projects/nissa/joxer/src/led.c
deleted file mode 100644
index d66e5b27a6..0000000000
--- a/zephyr/projects/nissa/joxer/src/led.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Battery LED control for nissa
- */
-#include <stdint.h>
-
-#include "charge_manager.h"
-#include "common.h"
-#include "compile_time_macros.h"
-#include "ec_commands.h"
-#include "gpio.h"
-#include "led_common.h"
-#include "led_onoff_states.h"
-#include "pwm.h"
-#include "util.h"
-
-#define BAT_LED_ON_LVL 0
-#define BAT_LED_OFF_LVL 1
-
-#define PWR_LED_ON_LVL 1
-#define PWR_LED_OFF_LVL 0
-
-#define LED_SIDESEL_MB_PORT 0
-#define LED_SIDESEL_DB_PORT 1
-
-__override const int led_charge_lvl_1 = 5;
-__override const int led_charge_lvl_2 = 95;
-
-__override struct led_descriptor
- led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = {
- [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_AMBER,
- LED_INDEFINITE } },
- [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER,
- LED_INDEFINITE } },
- [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_WHITE,
- LED_INDEFINITE } },
- [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } },
- [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER,
- 1 * LED_ONE_SEC },
- { LED_OFF, 1 * LED_ONE_SEC } },
- [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } },
- [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } },
- [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_AMBER,
- 0.5 * LED_ONE_SEC },
- { LED_OFF, 0.5 * LED_ONE_SEC } },
- [STATE_FACTORY_TEST] = { { EC_LED_COLOR_WHITE,
- 1 * LED_ONE_SEC },
- { LED_OFF, 1 * LED_ONE_SEC } },
- };
-
-__override const struct led_descriptor
- led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = {
- [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } },
- [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE,
- 1 * LED_ONE_SEC },
- { LED_OFF, 1 * LED_ONE_SEC } },
- [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE,
- 1 * LED_ONE_SEC },
- { LED_OFF,
- 1 * LED_ONE_SEC } },
- [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } },
- };
-
-const enum ec_led_id supported_led_ids[] = {
- EC_LED_ID_BATTERY_LED,
- EC_LED_ID_POWER_LED,
-};
-
-const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-
-__override void led_set_color_battery(enum ec_led_colors color)
-{
- int port;
-
- /* There are four battery leds, LED1/LED2 are on MB side and
- * LED3/LED4 are on DB side. All leds are OFF by default.
- */
- int led1, led2, led3, led4;
-
- led1 = led2 = led3 = led4 = BAT_LED_OFF_LVL;
-
- /* Check which port is the charging port,
- * and turn on the corresponding led.
- */
- if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED)) {
- port = charge_manager_get_active_charge_port();
- switch (port) {
- case LED_SIDESEL_MB_PORT:
- switch (color) {
- case EC_LED_COLOR_AMBER:
- led1 = BAT_LED_ON_LVL;
- break;
- case EC_LED_COLOR_WHITE:
- led2 = BAT_LED_ON_LVL;
- break;
- default: /* LED_OFF and other unsupported colors */
- break;
- }
- break;
- case LED_SIDESEL_DB_PORT:
- switch (color) {
- case EC_LED_COLOR_AMBER:
- led3 = BAT_LED_ON_LVL;
- break;
- case EC_LED_COLOR_WHITE:
- led4 = BAT_LED_ON_LVL;
- break;
- default: /* LED_OFF and other unsupported colors */
- break;
- }
- break;
- default: /* Unknown charging port */
- break;
- }
- } else {
- switch (color) {
- case EC_LED_COLOR_AMBER:
- led1 = BAT_LED_ON_LVL;
- led3 = BAT_LED_ON_LVL;
- break;
- case EC_LED_COLOR_WHITE:
- led2 = BAT_LED_ON_LVL;
- led4 = BAT_LED_ON_LVL;
- break;
- default: /* LED_OFF and other unsupported colors */
- break;
- }
- }
-
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl), led1);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl), led2);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_3_l), led3);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_4_l), led4);
-}
-
-__override void led_set_color_power(enum ec_led_colors color)
-{
- if (color == EC_LED_COLOR_WHITE)
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led_gate),
- PWR_LED_ON_LVL);
- else
- /* LED_OFF and unsupported colors */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led_gate),
- PWR_LED_OFF_LVL);
-}
-
-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;
- } else if (led_id == EC_LED_ID_POWER_LED) {
- 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) {
- led_auto_control(led_id, 0);
- if (brightness[EC_LED_COLOR_AMBER] != 0)
- led_set_color_battery(EC_LED_COLOR_AMBER);
- else if (brightness[EC_LED_COLOR_WHITE] != 0)
- led_set_color_battery(EC_LED_COLOR_WHITE);
- else if (brightness[LED_OFF] != 0)
- led_set_color_battery(LED_OFF);
- else {
- led_auto_control(led_id, 1);
- led_set_color_battery(LED_OFF);
- }
- } else if (led_id == EC_LED_ID_POWER_LED) {
- if (brightness[EC_LED_COLOR_WHITE] != 0)
- led_set_color_power(EC_LED_COLOR_WHITE);
- else
- led_set_color_power(LED_OFF);
- }
-
- return EC_SUCCESS;
-}
diff --git a/zephyr/projects/nissa/joxer/src/usbc.c b/zephyr/projects/nissa/joxer/src/usbc.c
deleted file mode 100644
index 5fec9ab544..0000000000
--- a/zephyr/projects/nissa/joxer/src/usbc.c
+++ /dev/null
@@ -1,392 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-#include <ap_power/ap_power.h>
-
-#include "charge_state_v2.h"
-#include "chipset.h"
-#include "hooks.h"
-#include "usb_mux.h"
-#include "system.h"
-#include "driver/charger/sm5803.h"
-#include "driver/tcpm/it83xx_pd.h"
-#include "driver/tcpm/ps8xxx_public.h"
-#include "driver/tcpm/tcpci.h"
-
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .bus_type = EC_BUS_TYPE_EMBEDDED,
- /* TCPC is embedded within EC so no i2c config needed */
- .drv = &it8xxx2_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
- },
- {
- /*
- * Sub-board: optional PS8745 TCPC+redriver. Behaves the same
- * as PS8815.
- */
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C1_TCPC,
- .addr_flags = PS8XXX_I2C_ADDR1_FLAGS,
- },
- .drv = &ps8xxx_tcpm_drv,
- /* PS8745 implements TCPCI 2.0 */
- .flags = TCPC_FLAGS_TCPCI_REV2_0,
- },
-};
-
-/* Vconn control for integrated ITE TCPC */
-void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
-{
- /* Vconn control is only for port 0 */
- if (port)
- return;
-
- if (cc_pin == USBPD_CC_PIN_1)
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc1_vconn),
- !!enabled);
- else
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc2_vconn),
- !!enabled);
-}
-
-__override bool pd_check_vbus_level(int port, enum vbus_level level)
-{
- return sm5803_check_vbus_level(port, level);
-}
-
-/*
- * Putting chargers into LPM when in suspend reduces power draw by about 8mW
- * per charger, but also seems critical to correct operation in source mode:
- * if chargers are not in LPM when a sink is first connected, VBUS sourcing
- * works even if the partner is later removed (causing LPM entry) and
- * reconnected (causing LPM exit). If in LPM initially, sourcing VBUS
- * consistently causes the charger to report (apparently spurious) overcurrent
- * failures.
- *
- * In short, this is important to making things work correctly but we don't
- * understand why.
- */
-static void board_chargers_suspend(struct ap_power_ev_callback *const cb,
- const struct ap_power_ev_data data)
-{
- void (*fn)(int chgnum);
-
- switch (data.event) {
- case AP_POWER_SUSPEND:
- fn = sm5803_enable_low_power_mode;
- break;
- case AP_POWER_RESUME:
- fn = sm5803_disable_low_power_mode;
- break;
- default:
- LOG_WRN("%s: power event %d is not recognized", __func__,
- data.event);
- return;
- }
-
- fn(CHARGER_PRIMARY);
- if (board_get_charger_chip_count() > 1)
- fn(CHARGER_SECONDARY);
-}
-
-static int board_chargers_suspend_init(const struct device *unused)
-{
- static struct ap_power_ev_callback cb = {
- .handler = board_chargers_suspend,
- .events = AP_POWER_SUSPEND | AP_POWER_RESUME,
- };
- ap_power_ev_add_callback(&cb);
- return 0;
-}
-SYS_INIT(board_chargers_suspend_init, APPLICATION, 0);
-
-int board_set_active_charge_port(int port)
-{
- int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count());
- int i;
- int old_port;
- int rv;
-
- if (!is_real_port && port != CHARGE_PORT_NONE)
- return EC_ERROR_INVAL;
-
- old_port = charge_manager_get_active_charge_port();
- LOG_INF("Charge update: p%d -> p%d", old_port, port);
-
- /* Check if port is sourcing VBUS. */
- if (port != CHARGE_PORT_NONE && charger_is_sourcing_otg_power(port)) {
- LOG_WRN("Skip enable p%d: already sourcing", port);
- return EC_ERROR_INVAL;
- }
-
- /* Disable sinking on all ports except the desired one */
- for (i = 0; i < board_get_usb_pd_port_count(); i++) {
- if (i == port)
- continue;
-
- if (sm5803_vbus_sink_enable(i, 0))
- /*
- * Do not early-return because this can fail during
- * power-on which would put us into a loop.
- */
- LOG_WRN("p%d: sink path disable failed.", i);
- }
-
- /* Don't enable anything (stop here) if no ports were requested */
- if ((port == CHARGE_PORT_NONE) || (old_port == port))
- return EC_SUCCESS;
-
- /*
- * Stop the charger IC from switching while changing ports. Otherwise,
- * we can overcurrent the adapter we're switching to. (crbug.com/926056)
- */
- if (old_port != CHARGE_PORT_NONE)
- charger_discharge_on_ac(1);
-
- /* Enable requested charge port. */
- rv = sm5803_vbus_sink_enable(port, 1);
- if (rv)
- LOG_WRN("p%d: sink path enable failed: code %d", port, rv);
-
- /* Allow the charger IC to begin/continue switching. */
- charger_discharge_on_ac(0);
-
- return rv;
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- /*
- * TCPC 0 is embedded in the EC and processes interrupts in the chip
- * code (it83xx/intc.c). This function only needs to poll port C1 if
- * present.
- */
- uint16_t status = 0;
- int regval;
-
- /* Is the C1 port present and its IRQ line asserted? */
- if (board_get_usb_pd_port_count() == 2 &&
- !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
- /*
- * C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if
- * it asserted the IRQ.
- */
- if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
- if (regval)
- status = PD_STATUS_TCPC_ALERT_1;
- }
- }
-
- return status;
-}
-
-void pd_power_supply_reset(int port)
-{
- int prev_en;
-
- if (port < 0 || port >= board_get_usb_pd_port_count())
- return;
-
- prev_en = charger_is_sourcing_otg_power(port);
-
- /* Disable Vbus */
- charger_enable_otg_power(port, 0);
-
- /* Discharge Vbus if previously enabled */
- if (prev_en)
- sm5803_set_vbus_disch(port, 1);
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- enum ec_error_list rv;
-
- if (port < 0 || port > board_get_usb_pd_port_count()) {
- LOG_WRN("Port C%d does not exist, cannot enable VBUS", port);
- return EC_ERROR_INVAL;
- }
-
- /* Disable sinking */
- rv = sm5803_vbus_sink_enable(port, 0);
- if (rv) {
- LOG_WRN("C%d failed to disable sinking: %d", port, rv);
- return rv;
- }
-
- /* Disable Vbus discharge */
- rv = sm5803_set_vbus_disch(port, 0);
- if (rv) {
- LOG_WRN("C%d failed to clear VBUS discharge: %d", port, rv);
- return rv;
- }
-
- /* Provide Vbus */
- rv = charger_enable_otg_power(port, 1);
- if (rv) {
- LOG_WRN("C%d failed to enable VBUS sourcing: %d", port, rv);
- return rv;
- }
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS;
-}
-
-__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- int rv;
- const int current = rp == TYPEC_RP_3A0 ? 3000 : 1500;
-
- rv = charger_set_otg_current_voltage(port, current, 5000);
- if (rv != EC_SUCCESS) {
- LOG_WRN("Failed to set source ilimit on port %d to %d: %d",
- port, current, rv);
- }
-}
-
-void board_reset_pd_mcu(void)
-{
- /*
- * Do nothing. The integrated TCPC for C0 lacks a dedicated reset
- * command, and C1 (if present) doesn't have a reset pin connected
- * to the EC.
- */
-}
-
-#define INT_RECHECK_US 5000
-
-/* C0 interrupt line shared by BC 1.2 and charger */
-
-static void check_c0_line(void);
-DECLARE_DEFERRED(check_c0_line);
-
-static void notify_c0_chips(void)
-{
- usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
- sm5803_interrupt(0);
-}
-
-static void check_c0_line(void)
-{
- /*
- * If line is still being held low, see if there's more to process from
- * one of the chips
- */
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
- notify_c0_chips();
- hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
- }
-}
-
-void usb_c0_interrupt(enum gpio_signal s)
-{
- /* Cancel any previous calls to check the interrupt line */
- hook_call_deferred(&check_c0_line_data, -1);
-
- /* Notify all chips using this line that an interrupt came in */
- notify_c0_chips();
-
- /* Check the line again in 5ms */
- hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
-}
-
-/* C1 interrupt line shared by BC 1.2, TCPC, and charger */
-static void check_c1_line(void);
-DECLARE_DEFERRED(check_c1_line);
-
-static void notify_c1_chips(void)
-{
- schedule_deferred_pd_interrupt(1);
- usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
- /* Charger is handled in board_process_pd_alert */
-}
-
-static void check_c1_line(void)
-{
- /*
- * If line is still being held low, see if there's more to process from
- * one of the chips.
- */
- if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
- notify_c1_chips();
- hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
- }
-}
-
-void usb_c1_interrupt(enum gpio_signal s)
-{
- /* Cancel any previous calls to check the interrupt line */
- hook_call_deferred(&check_c1_line_data, -1);
-
- /* Notify all chips using this line that an interrupt came in */
- notify_c1_chips();
-
- /* Check the line again in 5ms */
- hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
-}
-
-/*
- * Check state of IRQ lines at startup, ensuring an IRQ that happened before
- * the EC started up won't get lost (leaving the IRQ line asserted and blocking
- * any further interrupts on the port).
- *
- * Although the PD task will check for pending TCPC interrupts on startup,
- * the charger sharing the IRQ will not be polled automatically.
- */
-void board_handle_initial_typec_irq(void)
-{
- check_c0_line();
- check_c1_line();
-}
-/*
- * This must run after sub-board detection (which happens in EC main()),
- * but isn't depended on by anything else either.
- */
-DECLARE_HOOK(HOOK_INIT, board_handle_initial_typec_irq, HOOK_PRIO_LAST);
-
-/*
- * Handle charger interrupts in the PD task. Not doing so can lead to a priority
- * inversion where we fail to respond to TCPC alerts quickly enough because we
- * don't get another edge on a shared IRQ until the charger interrupt is cleared
- * (or the IRQ is polled again), which happens in the low-priority charger task:
- * the high-priority type-C handler is thus blocked on the lower-priority
- * charger.
- *
- * To avoid that, we run charger interrupts at the same priority.
- */
-void board_process_pd_alert(int port)
-{
- /*
- * Port 0 doesn't use an external TCPC, so its interrupts don't need
- * this special handling.
- */
- if (port == 1 &&
- !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
- sm5803_handle_interrupt(port);
- }
-}
-
-int pd_snk_is_vbus_provided(int port)
-{
- int chg_det = 0;
-
- sm5803_get_chg_det(port, &chg_det);
-
- return chg_det;
-}
diff --git a/zephyr/projects/nissa/nereid/overlay.dtsi b/zephyr/projects/nissa/nereid/overlay.dtsi
deleted file mode 100644
index a44a3e01bd..0000000000
--- a/zephyr/projects/nissa/nereid/overlay.dtsi
+++ /dev/null
@@ -1,400 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * 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>
-
-/ {
- aliases {
- gpio-cbi-wp = &gpio_ec_cbi_wp;
- gpio-wp = &gpio_ec_wp_odl;
- int-wp = &int_wp_l;
- /*
- * USB-C: interrupt input.
- * I2C pins are on i2c_ec_i2c_sub_usb_c1
- */
- gpio-usb-c1-int-odl = &gpio_sb_1;
- /*
- * USB-A: VBUS enable output
- * LTE: power enable output
- */
- gpio-en-usb-a1-vbus = &gpio_sb_2;
- /*
- * HDMI: power enable output, HDMI enable output,
- * and HPD input
- */
- gpio-en-rails-odl = &gpio_sb_1;
- gpio-hdmi-en-odl = &gpio_sb_4;
- gpio-hpd-odl = &gpio_sb_3;
- /*
- * Enable S5 rails for LTE sub-board
- */
- gpio-en-sub-s5-rails = &gpio_sb_2;
- };
-
-
- ec-console {
- compatible = "ec-console";
- disabled = "events", "lpc", "hostcmd";
- };
-
- batteries {
- default_battery: smp {
- compatible = "smp,l20m3pg0", "battery-smart";
- };
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-irqs = <
- &int_power_button
- &int_lid_open
- >;
- };
-
- gpio-interrupts {
- compatible = "cros-ec,gpio-interrupts";
-
- int_power_button: power_button {
- irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "power_button_interrupt";
- };
- int_vol_down: vol_down {
- irq-pin = <&gpio_voldn_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "button_interrupt";
- };
- int_vol_up: vol_up {
- irq-pin = <&gpio_volup_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "button_interrupt";
- };
- int_wp_l: wp_l {
- irq-pin = <&gpio_ec_wp_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "switch_interrupt";
- };
- int_lid_open: lid_open {
- irq-pin = <&gpio_lid_open>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "lid_interrupt";
- };
- int_tablet_mode: tablet_mode {
- irq-pin = <&gpio_tablet_mode_l>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "gmr_tablet_switch_isr";
- };
- int_imu: ec_imu {
- irq-pin = <&gpio_imu_int_l>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "bmi3xx_interrupt";
- };
- int_lid_imu: lid_imu {
- irq-pin = <&gpio_acc_int_l>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "bma4xx_interrupt";
- };
- int_usb_c0: usb_c0 {
- irq-pin = <&gpio_usb_c0_int_odl>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "usb_c0_interrupt";
- };
- int_usb_c1: usb_c1 {
- irq-pin = <&gpio_sb_1>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "usb_c1_interrupt";
- };
- };
-
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios = <&gpioc 3 0>,
- <&gpiod 4 0>,
- <&gpiod 7 0>,
- <&gpioh 2 0>,
- <&gpioj 7 0>,
- <&gpiol 4 0>;
- };
-
- named-gpios {
- /*
- * EC doesn't take any specific action on CC/SBU disconnect due to
- * fault, but this definition is useful for hardware testing.
- */
- gpio_usb_c0_prot_fault_odl: usb_c0_prot_fault_odl {
- gpios = <&gpiok 6 GPIO_INPUT_PULL_UP>;
- };
-
- gpio_sb_1: sb_1 {
- gpios = <&gpioe 6 0>;
- no-auto-init;
- };
- gpio_sb_2: sb_2 {
- gpios = <&gpiof 0 0>;
- no-auto-init;
- };
-
- gpio_sb_3: sb_3 {
- gpios = <&gpioe 7 0>;
- no-auto-init;
- };
- gpio_sb_4: sb_4 {
- gpios = <&gpioe 0 0>;
- no-auto-init;
- };
- };
-
- temp_memory: memory {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_1>;
- };
- temp_charger: charger {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_2>;
- };
- temp_ambient: ambient {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_3>;
- };
-
- named-temp-sensors {
- compatible = "cros-ec,temp-sensors";
- memory {
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_memory>;
- };
- charger {
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_charger>;
- };
- ambient {
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_ambient>;
- };
- };
-
- usba {
- compatible = "cros-ec,usba-port-enable-pins";
- /*
- * sb_2 is only configured as GPIO when USB-A1 is present,
- * but it's still safe to control when disabled.
- *
- * ILIM_SEL pins are referred to by legacy enum name,
- * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
- * sub-boards that don't have USB-A so is safe to control
- * regardless of system configuration.
- */
- enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
- status = "okay";
- };
-
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- chg = <&chg_port0>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&virtual_mux_0>;
- };
- };
- port0-muxes {
- virtual_mux_0: virtual-mux-0 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- chg = <&chg_port1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&virtual_mux_1 &tcpci_mux_1>;
- };
- usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux {
- compatible = "cros-ec,usb-mux-chain";
- alternative-chain;
- usb-muxes = <&virtual_mux_1>;
- };
- };
- port1-muxes {
- virtual_mux_1: virtual-mux-1 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- tcpci_mux_1: tcpci-mux-1 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
- };
- };
-};
-
-&gpio_acc_int_l {
- gpios = <&gpioc 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
-};
-&gpio_imu_int_l {
- gpios = <&gpioj 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
-};
-&gpio_vccin_aux_vid0 {
- gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
-};
-&gpio_vccin_aux_vid1 {
- gpios = <&gpiok 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
-};
-
-&gpio_ec_prochot_odl {
- gpios = <&gpioi 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>;
-};
-
-&thermistor_3V3_51K1_47K_4050B {
- status = "okay";
-};
-
-&adc_ec_vsense_pp3300_s5 {
- /*
- * Voltage divider on input has 47k upper and 220k lower legs with 3 V
- * full-scale reading on the ADC. Apply the largest possible multiplier
- * (without overflowing int32) to get the best possible approximation
- * of the actual ratio, but derate by a factor of two to ensure
- * unexpectedly high values won't overflow.
- */
- mul = <(715828 / 2)>;
- div = <(589820 / 2)>;
-};
-
-&adc0 {
- pinctrl-0 = <&adc0_ch0_gpi0_default
- &adc0_ch2_gpi2_default
- &adc0_ch3_gpi3_default
- &adc0_ch13_gpl0_default
- &adc0_ch14_gpl1_default>;
- pinctrl-names = "default";
-};
-
-&pinctrl {
- i2c4_clk_gpe0_sleep: i2c4_clk_gpe0_sleep {
- pinmuxs = <&pinctrle 0 IT8XXX2_ALT_DEFAULT>;
- };
- i2c4_data_gpe7_sleep: i2c4_data_gpe7_sleep {
- pinmuxs = <&pinctrle 7 IT8XXX2_ALT_DEFAULT>;
- };
- i2c2_clk_gpf6_default: i2c2_clk_gpf6_default {
- gpio-voltage = "1v8";
- };
- i2c2_data_gpf7_default: i2c2_data_gpf7_default {
- gpio-voltage = "1v8";
- };
-};
-
-&i2c0 {
- label = "I2C_EEPROM";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
- pinctrl-0 = <&i2c0_clk_gpb3_default
- &i2c0_data_gpb4_default>;
- pinctrl-names = "default";
-};
-
-&i2c1 {
- label = "I2C_BATTERY";
- clock-frequency = <50000>;
- pinctrl-0 = <&i2c1_clk_gpc1_default
- &i2c1_data_gpc2_default>;
- pinctrl-names = "default";
-};
-
-&i2c2 {
- label = "I2C_SENSOR";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c2_clk_gpf6_default
- &i2c2_data_gpf7_default>;
- pinctrl-names = "default";
-};
-
-&i2c4 {
- label = "I2C_SUB_C1_TCPC";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
- pinctrl-0 = <&i2c4_clk_gpe0_default
- &i2c4_data_gpe7_default>;
- pinctrl-1 = <&i2c4_clk_gpe0_sleep
- &i2c4_data_gpe7_sleep>;
- pinctrl-names = "default", "sleep";
-
- bc12_port1: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- };
-
- chg_port1: sm5803@32 {
- compatible = "siliconmitus,sm5803";
- status = "okay";
- reg = <0x32>;
- };
-};
-
-&i2c_ec_i2c_sub_usb_c1 {
- /*
- * Dynamic speed setting is used for AP-controlled firmware update
- * of PS8745 TCPC/redriver: the AP lowers speed to 400 kHz in order
- * to use more efficient window programming, then sets it back when
- * done.
- */
- dynamic-speed;
-};
-
-&i2c5 {
- label = "I2C_USB_C0_TCPC";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
- pinctrl-0 = <&i2c5_clk_gpa4_default
- &i2c5_data_gpa5_default>;
- pinctrl-names = "default";
-
- bc12_port0: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- };
-
- chg_port0: sm5803@32 {
- compatible = "siliconmitus,sm5803";
- status = "okay";
- reg = <0x32>;
- };
-};
-
-&usbpd0 {
- status = "okay";
-};
diff --git a/zephyr/projects/nissa/nereid/src/charger.c b/zephyr/projects/nissa/nereid/src/charger.c
deleted file mode 100644
index 181e9a61fd..0000000000
--- a/zephyr/projects/nissa/nereid/src/charger.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-
-#include "battery.h"
-#include "charger.h"
-#include "console.h"
-#include "driver/charger/sm5803.h"
-#include "extpower.h"
-#include "usb_pd.h"
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-int extpower_is_present(void)
-{
- int port;
- int rv;
- bool acok;
-
- for (port = 0; port < board_get_usb_pd_port_count(); port++) {
- rv = sm5803_is_acok(port, &acok);
- if ((rv == EC_SUCCESS) && acok)
- return 1;
- }
-
- return 0;
-}
-
-/*
- * Nereid does not have a GPIO indicating whether extpower is present,
- * so detect using the charger(s).
- */
-__override void board_check_extpower(void)
-{
- static int last_extpower_present;
- int extpower_present = extpower_is_present();
-
- if (last_extpower_present ^ extpower_present)
- extpower_handle_update(extpower_present);
-
- last_extpower_present = extpower_present;
-}
-
-__override void board_hibernate(void)
-{
- /* Shut down the chargers */
- if (board_get_usb_pd_port_count() == 2)
- sm5803_hibernate(CHARGER_SECONDARY);
- sm5803_hibernate(CHARGER_PRIMARY);
- LOG_INF("Charger(s) hibernated");
- cflush();
-}
diff --git a/zephyr/projects/nissa/nereid/src/hdmi.c b/zephyr/projects/nissa/nereid/src/hdmi.c
deleted file mode 100644
index 7e5708c6eb..0000000000
--- a/zephyr/projects/nissa/nereid/src/hdmi.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <cros_board_info.h>
-#include "nissa_hdmi.h"
-
-__override void nissa_configure_hdmi_power_gpios(void)
-{
- /*
- * Nereid versions before 2 need hdmi-en-odl to be
- * pulled down to enable VCC on the HDMI port, but later
- * versions (and other boards) disconnect this so
- * the port's VCC directly follows en-rails-odl. Only
- * configure the GPIO if needed, to save power.
- */
- uint32_t board_version = 0;
-
- /* CBI errors ignored, will configure the pin */
- cbi_get_board_version(&board_version);
- if (board_version < 2) {
- nissa_configure_hdmi_vcc();
- }
-
- /* Still always need core rails controlled */
- nissa_configure_hdmi_rails();
-}
diff --git a/zephyr/projects/nissa/nereid/src/usbc.c b/zephyr/projects/nissa/nereid/src/usbc.c
deleted file mode 100644
index 48f7cfd9cb..0000000000
--- a/zephyr/projects/nissa/nereid/src/usbc.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-#include <ap_power/ap_power.h>
-
-#include "charge_state_v2.h"
-#include "chipset.h"
-#include "hooks.h"
-#include "usb_mux.h"
-#include "system.h"
-#include "driver/charger/sm5803.h"
-#include "driver/tcpm/it83xx_pd.h"
-#include "driver/tcpm/ps8xxx_public.h"
-#include "driver/tcpm/tcpci.h"
-
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .bus_type = EC_BUS_TYPE_EMBEDDED,
- /* TCPC is embedded within EC so no i2c config needed */
- .drv = &it8xxx2_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
- },
- {
- /*
- * Sub-board: optional PS8745 TCPC+redriver. Behaves the same
- * as PS8815.
- */
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C1_TCPC,
- .addr_flags = PS8XXX_I2C_ADDR1_FLAGS,
- },
- .drv = &ps8xxx_tcpm_drv,
- /* PS8745 implements TCPCI 2.0 */
- .flags = TCPC_FLAGS_TCPCI_REV2_0,
- },
-};
-
-/* Vconn control for integrated ITE TCPC */
-void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
-{
- /* Vconn control is only for port 0 */
- if (port)
- return;
-
- if (cc_pin == USBPD_CC_PIN_1)
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc1_vconn),
- !!enabled);
- else
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc2_vconn),
- !!enabled);
-}
-
-__override bool pd_check_vbus_level(int port, enum vbus_level level)
-{
- return sm5803_check_vbus_level(port, level);
-}
-
-/*
- * Putting chargers into LPM when in suspend reduces power draw by about 8mW
- * per charger, but also seems critical to correct operation in source mode:
- * if chargers are not in LPM when a sink is first connected, VBUS sourcing
- * works even if the partner is later removed (causing LPM entry) and
- * reconnected (causing LPM exit). If in LPM initially, sourcing VBUS
- * consistently causes the charger to report (apparently spurious) overcurrent
- * failures.
- *
- * In short, this is important to making things work correctly but we don't
- * understand why.
- */
-static void board_chargers_suspend(struct ap_power_ev_callback *const cb,
- const struct ap_power_ev_data data)
-{
- void (*fn)(int chgnum);
-
- switch (data.event) {
- case AP_POWER_SUSPEND:
- fn = sm5803_enable_low_power_mode;
- break;
- case AP_POWER_RESUME:
- fn = sm5803_disable_low_power_mode;
- break;
- default:
- LOG_WRN("%s: power event %d is not recognized", __func__,
- data.event);
- return;
- }
-
- fn(CHARGER_PRIMARY);
- if (board_get_charger_chip_count() > 1)
- fn(CHARGER_SECONDARY);
-}
-
-static int board_chargers_suspend_init(const struct device *unused)
-{
- static struct ap_power_ev_callback cb = {
- .handler = board_chargers_suspend,
- .events = AP_POWER_SUSPEND | AP_POWER_RESUME,
- };
- ap_power_ev_add_callback(&cb);
- return 0;
-}
-SYS_INIT(board_chargers_suspend_init, APPLICATION, 0);
-
-int board_set_active_charge_port(int port)
-{
- int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count());
- int i;
- int old_port;
- int rv;
-
- if (!is_real_port && port != CHARGE_PORT_NONE)
- return EC_ERROR_INVAL;
-
- old_port = charge_manager_get_active_charge_port();
- LOG_INF("Charge update: p%d -> p%d", old_port, port);
-
- /* Check if port is sourcing VBUS. */
- if (port != CHARGE_PORT_NONE && charger_is_sourcing_otg_power(port)) {
- LOG_WRN("Skip enable p%d: already sourcing", port);
- return EC_ERROR_INVAL;
- }
-
- /* Disable sinking on all ports except the desired one */
- for (i = 0; i < board_get_usb_pd_port_count(); i++) {
- if (i == port)
- continue;
-
- if (sm5803_vbus_sink_enable(i, 0))
- /*
- * Do not early-return because this can fail during
- * power-on which would put us into a loop.
- */
- LOG_WRN("p%d: sink path disable failed.", i);
- }
-
- /* Don't enable anything (stop here) if no ports were requested */
- if ((port == CHARGE_PORT_NONE) || (old_port == port))
- return EC_SUCCESS;
-
- /*
- * Stop the charger IC from switching while changing ports. Otherwise,
- * we can overcurrent the adapter we're switching to. (crbug.com/926056)
- */
- if (old_port != CHARGE_PORT_NONE)
- charger_discharge_on_ac(1);
-
- /* Enable requested charge port. */
- rv = sm5803_vbus_sink_enable(port, 1);
- if (rv)
- LOG_WRN("p%d: sink path enable failed: code %d", port, rv);
-
- /* Allow the charger IC to begin/continue switching. */
- charger_discharge_on_ac(0);
-
- return rv;
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- /*
- * TCPC 0 is embedded in the EC and processes interrupts in the chip
- * code (it83xx/intc.c). This function only needs to poll port C1 if
- * present.
- */
- uint16_t status = 0;
- int regval;
-
- /* Is the C1 port present and its IRQ line asserted? */
- if (board_get_usb_pd_port_count() == 2 &&
- !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
- /*
- * C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if
- * it asserted the IRQ.
- */
- if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
- if (regval)
- status = PD_STATUS_TCPC_ALERT_1;
- }
- }
-
- return status;
-}
-
-void pd_power_supply_reset(int port)
-{
- int prev_en;
-
- if (port < 0 || port >= board_get_usb_pd_port_count())
- return;
-
- prev_en = charger_is_sourcing_otg_power(port);
-
- /* Disable Vbus */
- charger_enable_otg_power(port, 0);
-
- /* Discharge Vbus if previously enabled */
- if (prev_en)
- sm5803_set_vbus_disch(port, 1);
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- enum ec_error_list rv;
-
- if (port < 0 || port > board_get_usb_pd_port_count()) {
- LOG_WRN("Port C%d does not exist, cannot enable VBUS", port);
- return EC_ERROR_INVAL;
- }
-
- /* Disable sinking */
- rv = sm5803_vbus_sink_enable(port, 0);
- if (rv) {
- LOG_WRN("C%d failed to disable sinking: %d", port, rv);
- return rv;
- }
-
- /* Disable Vbus discharge */
- rv = sm5803_set_vbus_disch(port, 0);
- if (rv) {
- LOG_WRN("C%d failed to clear VBUS discharge: %d", port, rv);
- return rv;
- }
-
- /* Provide Vbus */
- rv = charger_enable_otg_power(port, 1);
- if (rv) {
- LOG_WRN("C%d failed to enable VBUS sourcing: %d", port, rv);
- return rv;
- }
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS;
-}
-
-__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- int rv;
- const int current = rp == TYPEC_RP_3A0 ? 3000 : 1500;
-
- rv = charger_set_otg_current_voltage(port, current, 5000);
- if (rv != EC_SUCCESS) {
- LOG_WRN("Failed to set source ilimit on port %d to %d: %d",
- port, current, rv);
- }
-}
-
-void board_reset_pd_mcu(void)
-{
- /*
- * Do nothing. The integrated TCPC for C0 lacks a dedicated reset
- * command, and C1 (if present) doesn't have a reset pin connected
- * to the EC.
- */
-}
-
-#define INT_RECHECK_US 5000
-
-/* C0 interrupt line shared by BC 1.2 and charger */
-
-static void check_c0_line(void);
-DECLARE_DEFERRED(check_c0_line);
-
-static void notify_c0_chips(void)
-{
- usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
- sm5803_interrupt(0);
-}
-
-static void check_c0_line(void)
-{
- /*
- * If line is still being held low, see if there's more to process from
- * one of the chips
- */
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
- notify_c0_chips();
- hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
- }
-}
-
-void usb_c0_interrupt(enum gpio_signal s)
-{
- /* Cancel any previous calls to check the interrupt line */
- hook_call_deferred(&check_c0_line_data, -1);
-
- /* Notify all chips using this line that an interrupt came in */
- notify_c0_chips();
-
- /* Check the line again in 5ms */
- hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
-}
-
-/* C1 interrupt line shared by BC 1.2, TCPC, and charger */
-static void check_c1_line(void);
-DECLARE_DEFERRED(check_c1_line);
-
-static void notify_c1_chips(void)
-{
- schedule_deferred_pd_interrupt(1);
- usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
- /* Charger is handled in board_process_pd_alert */
-}
-
-static void check_c1_line(void)
-{
- /*
- * If line is still being held low, see if there's more to process from
- * one of the chips.
- */
- if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
- notify_c1_chips();
- hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
- }
-}
-
-void usb_c1_interrupt(enum gpio_signal s)
-{
- /* Cancel any previous calls to check the interrupt line */
- hook_call_deferred(&check_c1_line_data, -1);
-
- /* Notify all chips using this line that an interrupt came in */
- notify_c1_chips();
-
- /* Check the line again in 5ms */
- hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
-}
-
-/*
- * Check state of IRQ lines at startup, ensuring an IRQ that happened before
- * the EC started up won't get lost (leaving the IRQ line asserted and blocking
- * any further interrupts on the port).
- *
- * Although the PD task will check for pending TCPC interrupts on startup,
- * the charger sharing the IRQ will not be polled automatically.
- */
-void board_handle_initial_typec_irq(void)
-{
- check_c0_line();
- if (board_get_usb_pd_port_count() == 2)
- check_c1_line();
-}
-/*
- * This must run after sub-board detection (which happens in EC main()),
- * but isn't depended on by anything else either.
- */
-DECLARE_HOOK(HOOK_INIT, board_handle_initial_typec_irq, HOOK_PRIO_LAST);
-
-/*
- * Handle charger interrupts in the PD task. Not doing so can lead to a priority
- * inversion where we fail to respond to TCPC alerts quickly enough because we
- * don't get another edge on a shared IRQ until the charger interrupt is cleared
- * (or the IRQ is polled again), which happens in the low-priority charger task:
- * the high-priority type-C handler is thus blocked on the lower-priority
- * charger.
- *
- * To avoid that, we run charger interrupts at the same priority.
- */
-void board_process_pd_alert(int port)
-{
- /*
- * Port 0 doesn't use an external TCPC, so its interrupts don't need
- * this special handling.
- */
- if (port == 1 &&
- !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
- sm5803_handle_interrupt(port);
- }
-}
-
-int pd_snk_is_vbus_provided(int port)
-{
- int chg_det = 0;
-
- sm5803_get_chg_det(port, &chg_det);
-
- return chg_det;
-}
diff --git a/zephyr/projects/nissa/nivviks/src/charger.c b/zephyr/projects/nissa/nivviks/src/charger.c
deleted file mode 100644
index e2f9f966e7..0000000000
--- a/zephyr/projects/nissa/nivviks/src/charger.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-
-#include "battery.h"
-#include "charger.h"
-#include "charger/isl923x_public.h"
-#include "console.h"
-#include "extpower.h"
-#include "usb_pd.h"
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-int extpower_is_present(void)
-{
- int port;
- int rv;
- bool acok;
-
- for (port = 0; port < board_get_usb_pd_port_count(); port++) {
- rv = raa489000_is_acok(port, &acok);
- if ((rv == EC_SUCCESS) && acok)
- return 1;
- }
-
- return 0;
-}
-
-/*
- * Nivviks does not have a GPIO indicating whether extpower is present,
- * so detect using the charger(s).
- */
-__override void board_check_extpower(void)
-{
- static int last_extpower_present;
- int extpower_present = extpower_is_present();
-
- if (last_extpower_present ^ extpower_present)
- extpower_handle_update(extpower_present);
-
- last_extpower_present = extpower_present;
-}
-
-__override void board_hibernate(void)
-{
- /* Shut down the chargers */
- if (board_get_usb_pd_port_count() == 2)
- raa489000_hibernate(CHARGER_SECONDARY, true);
- raa489000_hibernate(CHARGER_PRIMARY, true);
- LOG_INF("Charger(s) hibernated");
- cflush();
-}
diff --git a/zephyr/projects/nissa/nivviks/src/usbc.c b/zephyr/projects/nissa/nivviks/src/usbc.c
deleted file mode 100644
index 14fc5a071d..0000000000
--- a/zephyr/projects/nissa/nivviks/src/usbc.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-
-#include "charge_state_v2.h"
-#include "chipset.h"
-#include "hooks.h"
-#include "usb_mux.h"
-#include "system.h"
-#include "driver/charger/isl923x_public.h"
-#include "driver/retimer/anx7483_public.h"
-#include "driver/tcpm/tcpci.h"
-#include "driver/tcpm/raa489000.h"
-
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C0_TCPC,
- .addr_flags = RAA489000_TCPC0_I2C_FLAGS,
- },
- .drv = &raa489000_tcpm_drv,
- /* RAA489000 implements TCPCI 2.0 */
- .flags = TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_VBUS_MONITOR,
- },
- { /* sub-board */
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C1_TCPC,
- .addr_flags = RAA489000_TCPC0_I2C_FLAGS,
- },
- .drv = &raa489000_tcpm_drv,
- /* RAA489000 implements TCPCI 2.0 */
- .flags = TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_VBUS_MONITOR,
- },
-};
-
-int board_is_sourcing_vbus(int port)
-{
- int regval;
-
- tcpc_read(port, TCPC_REG_POWER_STATUS, &regval);
- return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS);
-}
-
-int board_set_active_charge_port(int port)
-{
- int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
- int i;
- int old_port;
-
- if (!is_real_port && port != CHARGE_PORT_NONE)
- return EC_ERROR_INVAL;
-
- old_port = charge_manager_get_active_charge_port();
-
- LOG_INF("New chg p%d", port);
-
- /* Disable all ports. */
- if (port == CHARGE_PORT_NONE) {
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- tcpc_write(i, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_SNK_CTRL_LOW);
- raa489000_enable_asgate(i, false);
- }
-
- return EC_SUCCESS;
- }
-
- /* Check if port is sourcing VBUS. */
- if (board_is_sourcing_vbus(port)) {
- LOG_WRN("Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
-
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- if (i == port)
- continue;
-
- if (tcpc_write(i, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_SNK_CTRL_LOW))
- LOG_WRN("p%d: sink path disable failed.", i);
- raa489000_enable_asgate(i, false);
- }
-
- /*
- * Stop the charger IC from switching while changing ports. Otherwise,
- * we can overcurrent the adapter we're switching to. (crbug.com/926056)
- */
- if (old_port != CHARGE_PORT_NONE)
- charger_discharge_on_ac(1);
-
- /* Enable requested charge port. */
- if (raa489000_enable_asgate(port, true) ||
- tcpc_write(port, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_SNK_CTRL_HIGH)) {
- LOG_WRN("p%d: sink path enable failed.", port);
- charger_discharge_on_ac(0);
- return EC_ERROR_UNKNOWN;
- }
-
- /* Allow the charger IC to begin/continue switching. */
- charger_discharge_on_ac(0);
-
- return EC_SUCCESS;
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
- int regval;
-
- /*
- * The interrupt line is shared between the TCPC and BC1.2 detector IC.
- * Therefore, go out and actually read the alert registers to report the
- * alert status.
- */
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
- if (!tcpc_read16(0, TCPC_REG_ALERT, &regval)) {
- /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */
- if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0))
- regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
-
- if (regval)
- status |= PD_STATUS_TCPC_ALERT_0;
- }
- }
-
- if (board_get_usb_pd_port_count() == 2 &&
- !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
- if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
- /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */
- if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0))
- regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
-
- if (regval)
- status |= PD_STATUS_TCPC_ALERT_1;
- }
- }
-
- return status;
-}
-
-void pd_power_supply_reset(int port)
-{
- /* Disable VBUS */
- tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW);
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT)
- return;
-
- raa489000_set_output_current(port, rp);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- int rv;
-
- if (port >= CONFIG_USB_PD_PORT_MAX_COUNT)
- return EC_ERROR_INVAL;
-
- /* Disable charging. */
- rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW);
- if (rv)
- return rv;
-
- /* Our policy is not to source VBUS when the AP is off. */
- if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
- return EC_ERROR_NOT_POWERED;
-
- /* Provide Vbus. */
- rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH);
- if (rv)
- return rv;
-
- rv = raa489000_enable_asgate(port, true);
- if (rv)
- return rv;
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS;
-}
-
-void board_reset_pd_mcu(void)
-{
- /*
- * TODO(b:147316511): could send a reset command to the TCPC here
- * if needed.
- */
-}
-
-/*
- * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible
- * for an interrupt to be lost if one asserts the IRQ, the other does the same
- * then the first releases it: there will only be one falling edge to trigger
- * the interrupt, and the line will be held low. We handle this by running a
- * deferred check after a falling edge to see whether the IRQ is still being
- * asserted. If it is, we assume an interrupt may have been lost and we need
- * to poll each chip for events again.
- */
-#define USBC_INT_POLL_DELAY_US 5000
-
-static void poll_c0_int(void);
-DECLARE_DEFERRED(poll_c0_int);
-static void poll_c1_int(void);
-DECLARE_DEFERRED(poll_c1_int);
-
-static void usbc_interrupt_trigger(int port)
-{
- schedule_deferred_pd_interrupt(port);
- usb_charger_task_set_event(port, USB_CHG_EVENT_BC12);
-}
-
-static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio,
- const struct deferred_data *ud)
-{
- if (!gpio_pin_get_dt(gpio)) {
- usbc_interrupt_trigger(port);
- hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
- }
-}
-
-static void poll_c0_int(void)
-{
- poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl),
- &poll_c0_int_data);
-}
-
-static void poll_c1_int(void)
-{
- poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl),
- &poll_c1_int_data);
-}
-
-void usb_interrupt(enum gpio_signal signal)
-{
- int port;
- const struct deferred_data *ud;
-
- if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) {
- port = 0;
- ud = &poll_c0_int_data;
- } else {
- port = 1;
- ud = &poll_c1_int_data;
- }
- /*
- * We've just been called from a falling edge, so there's definitely
- * no lost IRQ right now. Cancel any pending check.
- */
- hook_call_deferred(ud, -1);
- /* Trigger polling of TCPC and BC1.2 in respective tasks */
- usbc_interrupt_trigger(port);
- /* Check for lost interrupts in a bit */
- hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
-}
diff --git a/zephyr/projects/nissa/npcx_program.conf b/zephyr/projects/nissa/npcx_program.conf
deleted file mode 100644
index 5e0dd99501..0000000000
--- a/zephyr/projects/nissa/npcx_program.conf
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# EC chip configuration: NPCX993
-CONFIG_CROS_FLASH_NPCX=y
-CONFIG_CROS_SYSTEM_NPCX=y
-CONFIG_SOC_SERIES_NPCX9=y
-CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y
-CONFIG_SYSCON=y
-CONFIG_TACH_NPCX=y
-CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=256
-
-# Common sensor drivers
-CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
-
-# Keyboard
-CONFIG_CROS_KB_RAW_NPCX=y
-CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y
-# Ensure recovery key combination (esc+refresh+power) is reliable
-CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
-CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
-
-# TCPC+PPC: both C0 and C1 (if present) are RAA489000
-CONFIG_PLATFORM_EC_USB_PD_TCPM_RAA489000=y
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_TCPC_LPM_EXIT_DEBOUNCE_US=100000
-# RAA489000 uses TCPCI but not a separate PPC, so custom function is required
-CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y
-# type C port 1 redriver
-CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y
-# Save some space
-CONFIG_SHELL_MINIMAL=y
-
-# FRS enable
-CONFIG_PLATFORM_EC_USB_PD_FRS=y
-CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y
-
-# Charger driver and configuration
-CONFIG_PLATFORM_EC_CHARGER_RAA489000=y
-CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS=22
-
-# VSENSE: PP3300_S5 & PP1050_PROC
-CONFIG_ADC_CMP_NPCX=y
-CONFIG_SENSOR=y
-CONFIG_SENSOR_SHELL=n
diff --git a/zephyr/projects/nissa/program.conf b/zephyr/projects/nissa/program.conf
deleted file mode 100644
index c23a7f1381..0000000000
--- a/zephyr/projects/nissa/program.conf
+++ /dev/null
@@ -1,156 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Core EC configuration: build the EC application, using ECOS shims
-# (which are currently required for a number of features).
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-CONFIG_SHIMMED_TASKS=y
-CONFIG_LTO=y
-
-# Debug options and features; can be disabled to save memory or once bringup
-# is complete.
-CONFIG_LOG=y
-CONFIG_LOG_MODE_MINIMAL=y
-
-# RAM-saving options
-# flash shell command is unused, allocated a 4kB buffer for flash test
-CONFIG_FLASH_SHELL=n
-# EC default 1kB buffer seems unnecessarily large, Zephyr default is 8 bytes
-CONFIG_SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE=128
-
-# Standard shimmed features
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y
-CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-CONFIG_PLATFORM_EC_SWITCH=y
-CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
-CONFIG_PLATFORM_EC_TABLET_MODE=y
-CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
-CONFIG_PLATFORM_EC_VBOOT_EFS2=y
-CONFIG_PLATFORM_EC_VBOOT_HASH=y
-
-# Application processor; communicates with EC via eSPI
-CONFIG_AP=y
-CONFIG_AP_X86_INTEL_ADL=y
-CONFIG_ESPI=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y
-CONFIG_PLATFORM_EC_HOSTCMD=y
-CONFIG_HCDEBUG_OFF=y
-CONFIG_PLATFORM_EC_THROTTLE_AP=y
-CONFIG_PLATFORM_EC_PORT80=y
-CONFIG_PLATFORM_EC_PORT80_QUIET=y
-
-# AP Power Sequencing
-CONFIG_AP_PWRSEQ=y
-CONFIG_X86_NON_DSX_PWRSEQ_ADL=y
-CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y
-CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y
-CONFIG_AP_PWRSEQ_S0IX=y
-CONFIG_AP_PWRSEQ_S0IX_ERROR_RECOVERY=y
-
-# I2C
-CONFIG_I2C=y
-
-# Keyboard support
-CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y
-CONFIG_PLATFORM_EC_KEYBOARD=y
-CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y
-CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
-CONFIG_PLATFORM_EC_CMD_BUTTON=n
-# Column 2 is driven through the GSC, which inverts the signal going through it
-CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_COMMON=y
-CONFIG_PLATFORM_EC_LED_PWM=y
-CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_LEDTEST=n
-
-# MKBP event
-CONFIG_PLATFORM_EC_MKBP_EVENT=y
-CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
-CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y
-
-# Temperature sensor support
-CONFIG_PLATFORM_EC_TEMP_SENSOR=y
-CONFIG_PLATFORM_EC_THERMISTOR=y
-CONFIG_PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY=y
-
-# CBI EEPROM support
-CONFIG_EEPROM=y
-CONFIG_EEPROM_AT24=y
-CONFIG_EEPROM_SHELL=n
-CONFIG_PLATFORM_EC_CBI_EEPROM=y
-CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
-
-
-# PWM support
-CONFIG_PWM=y
-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
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
-
-# USB-C: enable PD on up to two ports
-CONFIG_PLATFORM_EC_USBC=y
-CONFIG_PLATFORM_EC_USBC_PPC=n
-CONFIG_PLATFORM_EC_USB_VID=0x18d1
-CONFIG_PLATFORM_EC_USB_PID=0x505a
-# USB4 and TBT are unsupported
-CONFIG_PLATFORM_EC_USB_PD_USB4=n
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
-
-CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y
-CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
-# ADL integrated muxes are slow: unblock PD
-CONFIG_PLATFORM_EC_USB_MUX_TASK=y
-CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
-
-# USB-C TCPC and PPC standard options
-CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
-
-# USB-A host ports
-CONFIG_PLATFORM_EC_USBA=y
-CONFIG_PLATFORM_EC_USB_PORT_ENABLE_DYNAMIC=y
-# 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
-CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_CDP_SDP_ONLY=y
-CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_DEFAULT_CDP=y
-CONFIG_PLATFORM_EC_USB_PORT_POWER_SMART_INVERTED=y
-
-# Battery support
-CONFIG_PLATFORM_EC_BATTERY=y
-CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
-CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
-CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
-CONFIG_PLATFORM_EC_BATTERY_SMART=y
-CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
-
-# Charger support
-CONFIG_PLATFORM_EC_CHARGER=y
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y
-
-# Dynamically select PD voltage to maximize charger efficiency
-CONFIG_PLATFORM_EC_USB_PD_DPS=y
-# Reduce logging so that state transitions do not cause protocol issues
-# pd dump [1-3] can be used to increase the debugging level
-CONFIG_PLATFORM_EC_USB_PD_INITIAL_DEBUG_LEVEL=0
diff --git a/zephyr/projects/nissa/pujjo/cbi.dtsi b/zephyr/projects/nissa/pujjo/cbi.dtsi
deleted file mode 100644
index b5ba92bd9e..0000000000
--- a/zephyr/projects/nissa/pujjo/cbi.dtsi
+++ /dev/null
@@ -1,190 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- /* Pujjo-specific fw_config fields. */
- nissa-fw-config {
- /*
- * FW_CONFIG field to enable KB back light or not.
- */
- kb-bl {
- enum-name = "FW_KB_BL";
- start = <3>;
- size = <1>;
-
- no-kb-bl {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_KB_BL_NOT_PRESENT";
- value = <0>;
- };
- kb-bl-present {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_KB_BL_PRESENT";
- value = <1>;
- };
- };
-
- /*
- * FW_CONFIG field for KB PWB present or not.
- */
- kb-pwb {
- enum-name = "FW_KB_PWB";
- start = <4>;
- size = <1>;
-
- no-kb-pwb {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_KB_PWB_NOT_PRESENT";
- value = <0>;
- };
- kb-pwb-present {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_KB_PWB_PRESENT";
- value = <1>;
- };
- };
-
- /*
- * FW_CONFIG field for tablet present or not.
- */
- tablet {
- enum-name = "FW_TABLET";
- start = <5>;
- size = <1>;
-
- no-tablet {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_TABLET_NOT_PRESENT";
- value = <0>;
- };
- tablet-present {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_TABLET_PRESENT";
- value = <1>;
- };
- };
-
- /*
- * FW_CONFIG field for LTE board present or not.
- *
- * start = <6>;
- * size = <1>;
- */
-
- /*
- * FW_CONFIG field for SD card present or not.
- *
- * start = <7>;
- * size = <1>;
- */
-
- /*
- * FW_CONFIG field for pen present or not.
- */
- pen {
- enum-name = "FW_PEN";
- start = <8>;
- size = <1>;
-
- no-pen {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_PEN_NOT_PRESENT";
- value = <0>;
- };
- pen-present {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_PEN_PRESENT";
- value = <1>;
- };
- };
-
- /*
- * FW_CONFIG field for WF camera present or not.
- *
- * start = <9>;
- * size = <1>;
- */
-
- /*
- * FW_CONFIG field for multiple thermal table.
- */
- therm-table {
- enum-name = "THERM_TABLE";
- start = <10>;
- size = <2>;
-
- therm-table-1 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "THERM_TABLE_1";
- value = <1>;
- };
- };
-
- /*
- * FW_CONFIG field for multiple audio module.
- *
- * start = <12>;
- * size = <3>;
- */
-
- /*
- * FW_CONFIG field for EXT_VR.
- *
- * start = <15>;
- * size = <1>;
- */
-
- /*
- * FW_CONFIG field for multiple wi-fi SAR.
- *
- * start = <16>;
- * size = <2>;
- */
- };
-
- /* Pujjo-specific ssfc fields. */
- cbi-ssfc {
- compatible = "named-cbi-ssfc";
- /*
- * SSFC field to identify BASE motion sensor.
- */
- base-sensor {
- enum-name = "BASE_SENSOR";
- size = <2>;
-
- base_sensor_0: bmi323 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
- value = <0>;
- default;
- };
- base_sensor_1: lsm6dsm {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
- value = <1>;
- };
- };
-
- /*
- * SSFC field to identify LID motion sensor.
- */
- lid-sensor {
- enum-name = "LID_SENSOR";
- size = <2>;
-
- lid_sensor_0: bma422 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
- value = <0>;
- default;
- };
- lid_sensor_1: lis2dw12 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
- value = <1>;
- };
- };
- };
-};
diff --git a/zephyr/projects/nissa/pujjo/generated.dtsi b/zephyr/projects/nissa/pujjo/generated.dtsi
deleted file mode 100644
index 727d2d3d53..0000000000
--- a/zephyr/projects/nissa/pujjo/generated.dtsi
+++ /dev/null
@@ -1,277 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * This file is auto-generated - do not edit!
- */
-
-/ {
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- adc_ec_vsense_pp1050_proc: ec_vsense_pp1050_proc {
- enum-name = "ADC_PP1050_PROC";
- io-channels = <&adc0 4>;
- };
- adc_ec_vsense_pp3300_s5: ec_vsense_pp3300_s5 {
- enum-name = "ADC_PP3300_S5";
- io-channels = <&adc0 6>;
- };
- adc_temp_sensor_1: temp_sensor_1 {
- enum-name = "ADC_TEMP_SENSOR_1";
- io-channels = <&adc0 0>;
- };
- adc_temp_sensor_2: temp_sensor_2 {
- enum-name = "ADC_TEMP_SENSOR_2";
- io-channels = <&adc0 1>;
- };
- adc_temp_sensor_3: temp_sensor_3 {
- enum-name = "ADC_TEMP_SENSOR_3";
- io-channels = <&adc0 10>;
- };
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- gpio_acc_int_l: acc_int_l {
- gpios = <&gpio5 0 GPIO_INPUT>;
- };
- gpio_all_sys_pwrgd: all_sys_pwrgd {
- gpios = <&gpioa 7 GPIO_INPUT>;
- };
- gpio_ccd_mode_odl: ccd_mode_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- };
- gpio_cpu_c10_gate_l: cpu_c10_gate_l {
- gpios = <&gpio6 7 GPIO_INPUT>;
- };
- gpio_ec_battery_pres_odl: ec_battery_pres_odl {
- gpios = <&gpioa 3 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- };
- gpio_ec_cbi_wp: ec_cbi_wp {
- gpios = <&gpio7 4 GPIO_OUTPUT>;
- };
- gpio_ec_edp_bl_en_od: ec_edp_bl_en_od {
- gpios = <&gpiod 3 GPIO_ODR_HIGH>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- };
- gpio_ec_entering_rw: ec_entering_rw {
- gpios = <&gpio0 3 GPIO_OUTPUT>;
- enum-name = "GPIO_ENTERING_RW";
- };
- gpio_ec_gsc_packet_mode: ec_gsc_packet_mode {
- gpios = <&gpio7 5 GPIO_OUTPUT>;
- enum-name = "GPIO_PACKET_MODE_EN";
- };
- gpio_ec_kso_02_inv: ec_kso_02_inv {
- gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
- };
- gpio_ec_pch_wake_odl: ec_pch_wake_odl {
- gpios = <&gpiob 0 GPIO_ODR_LOW>;
- };
- gpio_ec_prochot_odl: ec_prochot_odl {
- gpios = <&gpiof 1 GPIO_ODR_HIGH>;
- };
- gpio_ec_soc_dsw_pwrok: ec_soc_dsw_pwrok {
- gpios = <&gpio6 1 GPIO_OUTPUT>;
- };
- gpio_ec_soc_hdmi_hpd: ec_soc_hdmi_hpd {
- gpios = <&gpioe 4 GPIO_OUTPUT>;
- };
- gpio_ec_soc_int_odl: ec_soc_int_odl {
- gpios = <&gpio8 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- };
- gpio_ec_soc_pch_pwrok_od: ec_soc_pch_pwrok_od {
- gpios = <&gpio7 2 GPIO_ODR_HIGH>;
- };
- gpio_ec_soc_pwr_btn_odl: ec_soc_pwr_btn_odl {
- gpios = <&gpioc 1 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PCH_PWRBTN_L";
- };
- gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l {
- gpios = <&gpioa 6 GPIO_OUTPUT>;
- };
- gpio_ec_soc_rtcrst: ec_soc_rtcrst {
- gpios = <&gpio7 6 GPIO_OUTPUT>;
- };
- gpio_ec_soc_sys_pwrok: ec_soc_sys_pwrok {
- gpios = <&gpio3 7 GPIO_OUTPUT>;
- };
- gpio_ec_soc_vccst_pwrgd_od: ec_soc_vccst_pwrgd_od {
- gpios = <&gpioa 4 GPIO_ODR_HIGH>;
- };
- gpio_ec_wp_odl: ec_wp_odl {
- gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
- };
- gpio_en_kb_bl: en_kb_bl {
- gpios = <&gpioa 0 GPIO_OUTPUT>;
- enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT";
- };
- gpio_en_pp3300_s5: en_pp3300_s5 {
- gpios = <&gpiob 6 GPIO_OUTPUT>;
- enum-name = "GPIO_TEMP_SENSOR_POWER";
- };
- gpio_en_pp5000_pen_x: en_pp5000_pen_x {
- gpios = <&gpioe 2 GPIO_OUTPUT>;
- };
- gpio_en_pp5000_s5: en_pp5000_s5 {
- gpios = <&gpio4 0 GPIO_OUTPUT>;
- };
- gpio_en_slp_z: en_slp_z {
- gpios = <&gpioe 1 GPIO_OUTPUT>;
- };
- gpio_en_usb_a0_vbus: en_usb_a0_vbus {
- gpios = <&gpio9 1 GPIO_OUTPUT>;
- };
- gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl {
- gpios = <&gpio0 0 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_POWER_BUTTON_L";
- };
- gpio_hdmi_sel: hdmi_sel {
- gpios = <&gpioc 6 GPIO_OUTPUT>;
- };
- gpio_imu_int_l: imu_int_l {
- gpios = <&gpio5 6 GPIO_INPUT>;
- };
- gpio_imvp91_vrrdy_od: imvp91_vrrdy_od {
- gpios = <&gpio4 3 GPIO_INPUT>;
- };
- gpio_lid_open: lid_open {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- };
- gpio_pen_detect_odl: pen_detect_odl {
- gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>;
- };
- gpio_pg_pp1050_mem_s3_od: pg_pp1050_mem_s3_od {
- gpios = <&gpiof 0 GPIO_INPUT>;
- };
- gpio_pg_pp5000_s5_od: pg_pp5000_s5_od {
- gpios = <&gpio4 2 GPIO_INPUT>;
- };
- gpio_rsmrst_pwrgd_l: rsmrst_pwrgd_l {
- gpios = <&gpio9 4 GPIO_INPUT_PULL_UP>;
- };
- gpio_slp_s0_l: slp_s0_l {
- gpios = <&gpio9 7 GPIO_INPUT>;
- };
- gpio_slp_s3_l: slp_s3_l {
- gpios = <&gpioa 5 GPIO_INPUT>;
- };
- gpio_slp_s4_l: slp_s4_l {
- gpios = <&gpio7 0 GPIO_INPUT>;
- };
- gpio_slp_sus_l: slp_sus_l {
- gpios = <&gpio6 2 GPIO_INPUT>;
- };
- gpio_sub_usb_a1_ilimit_sdp: sub_usb_a1_ilimit_sdp {
- gpios = <&gpiod 5 GPIO_OUTPUT>;
- enum-name = "GPIO_USB2_ILIM_SEL";
- };
- gpio_sys_rst_odl: sys_rst_odl {
- gpios = <&gpioc 5 GPIO_ODR_HIGH>;
- };
- gpio_tablet_mode_l: tablet_mode_l {
- gpios = <&gpio9 5 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- };
- gpio_usb_a0_ilimit_sdp: usb_a0_ilimit_sdp {
- gpios = <&gpio8 5 GPIO_OUTPUT>;
- enum-name = "GPIO_USB1_ILIM_SEL";
- };
- gpio_usb_c0_int_odl: usb_c0_int_odl {
- gpios = <&gpio0 1 GPIO_INPUT_PULL_UP>;
- };
- gpio_vccin_aux_vid0: vccin_aux_vid0 {
- gpios = <&gpio9 2 GPIO_INPUT>;
- };
- gpio_vccin_aux_vid1: vccin_aux_vid1 {
- gpios = <&gpioe 3 GPIO_INPUT>;
- };
- gpio_voldn_btn_odl: voldn_btn_odl {
- gpios = <&gpio9 3 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- };
- gpio_volup_btn_odl: volup_btn_odl {
- gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_UP_L";
- };
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- i2c_ec_i2c_eeprom: ec_i2c_eeprom {
- i2c-port = <&i2c0_0>;
- enum-names = "I2C_PORT_EEPROM";
- };
- i2c_ec_i2c_sensor: ec_i2c_sensor {
- i2c-port = <&i2c1_0>;
- enum-names = "I2C_PORT_SENSOR";
- };
- i2c_ec_i2c_usb_c0: ec_i2c_usb_c0 {
- i2c-port = <&i2c3_0>;
- enum-names = "I2C_PORT_USB_C0_TCPC";
- };
- i2c_ec_i2c_batt: ec_i2c_batt {
- i2c-port = <&i2c7_0>;
- enum-names = "I2C_PORT_BATTERY";
- };
- };
-};
-
-&adc0 {
- status = "okay";
- pinctrl-0 = <&adc0_chan0_gp45
- &adc0_chan1_gp44
- &adc0_chan4_gp41
- &adc0_chan6_gp34
- &adc0_chan10_gpe0>;
- pinctrl-names = "default";
-};
-
-
-&i2c0_0 {
- status = "okay";
- pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
- pinctrl-names = "default";
-};
-
-&i2c1_0 {
- status = "okay";
- pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
- pinctrl-names = "default";
-};
-
-&i2c3_0 {
- status = "okay";
- pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
- pinctrl-names = "default";
-};
-
-&i2c7_0 {
- status = "okay";
- pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
- pinctrl-names = "default";
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
diff --git a/zephyr/projects/nissa/pujjo/motionsense.dtsi b/zephyr/projects/nissa/pujjo/motionsense.dtsi
deleted file mode 100644
index 2dfca337c4..0000000000
--- a/zephyr/projects/nissa/pujjo/motionsense.dtsi
+++ /dev/null
@@ -1,245 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <dt-bindings/motionsense/utils.h>
-
-
-/ {
- aliases {
- /*
- * Interrupt bindings for sensor devices.
- */
- bmi3xx-int = &base_accel;
- lsm6dsm-int = &base_accel;
- lis2dw12-int = &lid_accel;
- };
-
- /*
- * Declare mutexes used by sensor drivers.
- * A mutex node is used to create an instance of mutex_t.
- * A mutex node is referenced by a sensor node if the
- * corresponding sensor driver needs to use the
- * instance of the mutex.
- */
- motionsense-mutex {
- compatible = "cros-ec,motionsense-mutex";
- lid_mutex: lid-mutex {
- };
-
- base_mutex: base-mutex {
- };
- };
-
- /* Rotation matrix used by drivers. */
- motionsense-rotation-ref {
- compatible = "cros-ec,motionsense-rotation-ref";
- lid_rot_ref: lid-rotation-ref {
- mat33 = <0 (-1) 0
- (-1) 0 0
- 0 0 (-1)>;
- };
-
- lid_rot_lis2dw12: lid-rotation-lis2dw12 {
- mat33 = <0 (-1) 0
- (-1) 0 0
- 0 0 (-1)>;
- };
-
- base_rot_ref: base-rotation-ref {
- mat33 = <0 1 0
- (-1) 0 0
- 0 0 1>;
- };
-
- base_rot_lsm6dsm: base-rotation-lsm6dsm {
- mat33 = <1 0 0
- 0 1 0
- 0 0 1>;
- };
- };
-
- /*
- * Driver specific data. A driver-specific data can be shared with
- * different motion sensors while they are using the same driver.
- *
- * If a node's compatible starts with "cros-ec,accelgyro-", it is for
- * a common structure defined in accelgyro.h.
- * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
- * "struct als_drv_data_t" in accelgyro.h
- */
- motionsense-sensor-data {
- bmi323_data: bmi323-drv-data {
- compatible = "cros-ec,drvdata-bmi3xx";
- status = "okay";
- };
-
- lsm6dsm_data_accel: lsm6dsm-accel-drv-data {
- compatible = "cros-ec,drvdata-lsm6dsm";
- status = "okay";
- };
-
- lsm6dsm_data_gyro: lsm6dsm-gyro-drv-data {
- compatible = "cros-ec,drvdata-lsm6dsm";
- status = "okay";
- };
-
- bma422_data: bma422-drv-data {
- compatible = "cros-ec,drvdata-bma4xx";
- status = "okay";
- };
-
- lis2dw12_data: lis2dw12-drv-data {
- compatible = "cros-ec,drvdata-lis2dw12";
- status = "okay";
- };
- };
-
- /*
- * List of motion sensors that creates motion_sensors array.
- * The nodelabel "lid_accel" and "base_accel" are used to indicate
- * motion sensor IDs for lid angle calculation.
- * TODO(b/238139272): The first entries of the array must be
- * accelerometers,then gyroscope. Fix this dependency in the DTS
- * processing which makes the devicetree entries independent.
- */
- motionsense-sensor {
- lid_accel: lid-accel {
- compatible = "cros-ec,bma4xx";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_LID";
- mutex = <&lid_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&lid_rot_ref>;
- default-range = <2>;
- drv-data = <&bma422_data>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_accel: base-accel {
- compatible = "cros-ec,bmi3xx-accel";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&bmi323_data>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_gyro: base-gyro {
- compatible = "cros-ec,bmi3xx-gyro";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&bmi323_data>;
- };
- };
-
- motionsense-sensor-alt {
- alt_lid_accel: alt-lid-accel {
- compatible = "cros-ec,lis2dw12";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_LID";
- mutex = <&lid_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&lid_rot_lis2dw12>;
- default-range = <2>;
- drv-data = <&lis2dw12_data>;
- i2c-spi-addr-flags = "LIS2DWL_ADDR1_FLAGS";
- alternate-for = <&lid_accel>;
- alternate-ssfc-indicator = <&lid_sensor_1>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- alt_base_accel: alt-base-accel {
- compatible = "cros-ec,lsm6dsm-accel";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&base_rot_lsm6dsm>;
- drv-data = <&lsm6dsm_data_accel>;
- alternate-for = <&base_accel>;
- alternate-ssfc-indicator = <&base_sensor_1>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- ec-rate = <(100 * USEC_PER_MSEC)>;
- };
- ec-s3 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- ec-rate = <0>;
- };
- };
- };
-
- alt_base_gyro: alt-base-gyro {
- compatible = "cros-ec,lsm6dsm-gyro";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&base_rot_lsm6dsm>;
- drv-data = <&lsm6dsm_data_gyro>;
- alternate-for = <&base_gyro>;
- alternate-ssfc-indicator = <&base_sensor_1>;
- };
- };
-
- motionsense-sensor-info {
- compatible = "cros-ec,motionsense-sensor-info";
-
- /*
- * list of GPIO interrupts that have to
- * be enabled at initial stage
- */
- sensor-irqs = <&int_imu>;
- /* list of sensors in force mode */
- accel-force-mode-sensors = <&lid_accel>;
- };
-};
diff --git a/zephyr/projects/nissa/pujjo/overlay.dtsi b/zephyr/projects/nissa/pujjo/overlay.dtsi
deleted file mode 100644
index 60b3b60003..0000000000
--- a/zephyr/projects/nissa/pujjo/overlay.dtsi
+++ /dev/null
@@ -1,350 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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>
-
-/ {
- aliases {
- gpio-cbi-wp = &gpio_ec_cbi_wp;
- gpio-wp = &gpio_ec_wp_odl;
- int-wp = &int_wp_l;
- gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
- };
-
- ec-console {
- compatible = "ec-console";
- disabled = "events", "lpc", "hostcmd";
- };
-
- batteries {
- default_battery: smp {
- compatible = "smp,l22m3pg0", "battery-smart";
- };
- smp_l22m3pg1 {
- compatible = "smp,l22m3pg1", "battery-smart";
- };
- sunwoda_l22d3pg0 {
- compatible = "sunwoda,l22d3pg0", "battery-smart";
- };
- sunwoda_l22d3pg1 {
- compatible = "sunwoda,l22d3pg1", "battery-smart";
- };
- celxpert_l22c3pg0 {
- compatible = "celxpert,l22c3pg0", "battery-smart";
- };
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-irqs = <
- &int_power_button
- &int_lid_open
- >;
- };
-
- gpio-interrupts {
- compatible = "cros-ec,gpio-interrupts";
-
- int_power_button: power_button {
- irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "power_button_interrupt";
- };
- int_wp_l: wp_l {
- irq-pin = <&gpio_ec_wp_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "switch_interrupt";
- };
- int_lid_open: lid_open {
- irq-pin = <&gpio_lid_open>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "lid_interrupt";
- };
- int_tablet_mode: tablet_mode {
- irq-pin = <&gpio_tablet_mode_l>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "gmr_tablet_switch_isr";
- };
- int_imu: ec_imu {
- irq-pin = <&gpio_imu_int_l>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "motion_interrupt";
- };
- int_vol_down: vol_down {
- irq-pin = <&gpio_voldn_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "button_interrupt";
- };
- int_vol_up: vol_up {
- irq-pin = <&gpio_volup_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "button_interrupt";
- };
- int_usb_c0: usb_c0 {
- irq-pin = <&gpio_usb_c0_int_odl>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "usb_interrupt";
- };
- };
-
- named-gpios {
- gpio_sb_2: sb_2 {
- gpios = <&gpiod 4 GPIO_OUTPUT>;
- no-auto-init;
- };
-
- gpio_sb_3: sb_3 {
- gpios = <&gpiof 5 GPIO_OPEN_DRAIN>;
- no-auto-init;
- };
- gpio_sb_4: sb_4 {
- gpios = <&gpiof 4 GPIO_INPUT>;
- no-auto-init;
- };
- gpio_fan_enable: fan-enable {
- gpios = <&gpio6 3 GPIO_OUTPUT>;
- no-auto-init;
- };
- gpio_power_led: power_led {
- gpios = <&gpioc 2 GPIO_OUTPUT_LOW>;
- };
- gpio_led_1_odl: led_1_odl {
- gpios = <&gpioc 4 GPIO_OUTPUT_LOW>;
- };
- gpio_led_2_odl: led_2_odl {
- gpios = <&gpioc 3 GPIO_OUTPUT_LOW>;
- };
- };
-
- /*
- * Aliases used for sub-board GPIOs.
- */
- aliases {
- /*
- * Sub-board with type A USB, enable.
- */
- gpio-en-usb-a1-vbus = &gpio_sb_2;
- /*
- * HPD pins for HDMI sub-board.
- */
- gpio-hdmi-en-odl = &gpio_sb_3;
- gpio-hpd-odl = &gpio_sb_4;
- /*
- * Enable S5 rails for LTE sub-board
- */
- gpio-en-sub-s5-rails = &gpio_sb_2;
- };
-
- temp_cpu: cpu {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_1>;
- };
- temp_ddr: ddr {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_2>;
- };
- temp_ambient: ambient {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_3>;
- };
-
- named-temp-sensors {
- compatible = "cros-ec,temp-sensors";
- cpu {
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <90>;
- temp_host_halt = <100>;
- temp_host_release_high = <85>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_cpu>;
- };
- ddr {
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <90>;
- temp_host_halt = <100>;
- temp_host_release_high = <85>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_ddr>;
- };
- ambient {
- temp_fan_off = <35>;
- temp_fan_max = <60>;
- temp_host_high = <90>;
- temp_host_halt = <100>;
- temp_host_release_high = <85>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_ambient>;
- };
- };
-
- usba {
- compatible = "cros-ec,usba-port-enable-pins";
- /*
- * sb_2 is only configured as GPIO when USB-A1 is present,
- * but it's still safe to control when disabled.
- *
- * ILIM_SEL pins are referred to by legacy enum name,
- * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
- * sub-boards that don't have USB-A so is safe to control
- * regardless of system configuration.
- */
- enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
- status = "okay";
- };
-
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- chg = <&chg_port0>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&virtual_mux_0>;
- };
- };
- port0-muxes {
- virtual_mux_0: virtual-mux-0 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
- };
-
- fans {
- compatible = "cros-ec,fans";
-
- fan_0 {
- pwms = <&pwm5 5 PWM_KHZ(1) PWM_POLARITY_NORMAL>;
- rpm_min = <2200>;
- rpm_start = <2200>;
- rpm_max = <4200>;
- tach = <&tach2>;
- enable_gpio = <&gpio_fan_enable>;
- };
- };
-
- /*
- * Declare unused GPIOs so that they are shut down
- * and use minimal power
- */
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios =
- <&gpio3 3 0>,
- <&gpio3 6 0>,
- <&gpiod 7 0>,
- <&gpiof 2 0>,
- <&gpiof 3 0>;
- };
-};
-
-&thermistor_3V3_51K1_47K_4050B {
- status = "okay";
-};
-
-&adc_ec_vsense_pp3300_s5 {
- /*
- * Voltage divider on input has 47k upper and 220k lower legs with
- * 2714 mV full-scale reading on the ADC. Apply the largest possible
- * multiplier (without overflowing int32) to get the best possible
- * approximation of the actual ratio, but derate by a factor of two to
- * ensure unexpectedly high values won't overflow.
- */
- mul = <(791261 / 2)>;
- div = <(651975 / 2)>;
-};
-
-/* Set bus speeds for I2C */
-&i2c0_0 {
- label = "I2C_EEPROM";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
-};
-
-&i2c1_0 {
- label = "I2C_SENSOR";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c3_0 {
- label = "I2C_USB_C0_TCPC";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-
- bc12_port0: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- /*
- * BC1.2 interrupt is shared with TCPC, so
- * IRQ is not specified here and handled by
- * usb_c0_interrupt.
- */
- };
-
- chg_port0: isl923x@9 {
- compatible = "intersil,isl923x";
- status = "okay";
- reg = <0x9>;
- };
-};
-
-&i2c7_0 {
- label = "I2C_BATTERY";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&pwm5_gpb7 {
- drive-open-drain;
-};
-
-&pwm5 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm5_gpb7>;
- pinctrl-names = "default";
-};
-
-/* Tachometer for fan speed measurement */
-&tach2 {
- status = "okay";
- pinctrl-0 = <&ta2_1_in_gp73>;
- pinctrl-names = "default";
- 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 */
-};
-
-/* host interface */
-&espi0 {
- status = "okay";
- pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
- pinctrl-names = "default";
-};
-
-/*
- * Declare GPIOs that have leakage current caused by board issues here. NPCX ec
- * will disable their input buffers before entering deep sleep and restore them
- * after waking up automatically for better power consumption.
- */
-&power_leakage_io {
- leak-gpios = <&gpioa 4 0
- &gpiof 1 0>;
-};
diff --git a/zephyr/projects/nissa/pujjo/src/charger.c b/zephyr/projects/nissa/pujjo/src/charger.c
deleted file mode 100644
index f1f1d57790..0000000000
--- a/zephyr/projects/nissa/pujjo/src/charger.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-
-#include "battery.h"
-#include "charger.h"
-#include "charger/isl923x_public.h"
-#include "driver/tcpm/raa489000.h"
-#include "driver/charger/isl923x.h"
-#include "console.h"
-#include "extpower.h"
-#include "usb_pd.h"
-#include "nissa_common.h"
-#include "hooks.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-int extpower_is_present(void)
-{
- int port;
- int rv;
- bool acok;
-
- for (port = 0; port < board_get_usb_pd_port_count(); port++) {
- rv = raa489000_is_acok(port, &acok);
- if ((rv == EC_SUCCESS) && acok)
- return 1;
- }
-
- return 0;
-}
-
-/*
- * Pujjo does not have a GPIO indicating whether extpower is present,
- * so detect using the charger(s).
- */
-__override void board_check_extpower(void)
-{
- static int last_extpower_present;
- int extpower_present = extpower_is_present();
-
- if (last_extpower_present ^ extpower_present)
- extpower_handle_update(extpower_present);
-
- last_extpower_present = extpower_present;
-}
-
-__override void board_hibernate(void)
-{
- /* Shut down the chargers */
- raa489000_hibernate(0, true);
- LOG_INF("Charger(s) hibernated");
- cflush();
-}
-
-static void charger_prochot_init(void)
-{
- isl923x_set_ac_prochot(CHARGER_SOLO, 3500);
- isl923x_set_dc_prochot(CHARGER_SOLO, 6528);
-}
-DECLARE_HOOK(HOOK_INIT, charger_prochot_init, HOOK_PRIO_POST_FIRST);
diff --git a/zephyr/projects/nissa/pujjo/src/fan.c b/zephyr/projects/nissa/pujjo/src/fan.c
deleted file mode 100644
index 97323a7edf..0000000000
--- a/zephyr/projects/nissa/pujjo/src/fan.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/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);
-
-/*
- * Pujjo 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/pujjo/src/form_factor.c b/zephyr/projects/nissa/pujjo/src/form_factor.c
deleted file mode 100644
index 6b02a258bc..0000000000
--- a/zephyr/projects/nissa/pujjo/src/form_factor.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/devicetree.h>
-#include <zephyr/logging/log.h>
-
-#include "accelgyro.h"
-#include "button.h"
-#include "cros_board_info.h"
-#include "cros_cbi.h"
-#include "driver/accelgyro_bmi323.h"
-#include "driver/accelgyro_lsm6dsm.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "motionsense_sensors.h"
-#include "motion_sense.h"
-#include "tablet_mode.h"
-
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-static bool use_alt_sensor;
-
-void motion_interrupt(enum gpio_signal signal)
-{
- if (use_alt_sensor)
- lsm6dsm_interrupt(signal);
- else
- bmi3xx_interrupt(signal);
-}
-
-static void sensor_init(void)
-{
- int ret;
- uint32_t val;
- /* check which base sensor is used for motion_interrupt */
- use_alt_sensor = cros_cbi_ssfc_check_match(
- CBI_SSFC_VALUE_ID(DT_NODELABEL(base_sensor_1)));
-
- motion_sensors_check_ssfc();
-
- /* Check if it's tablet or not */
- ret = cros_cbi_get_fw_config(FW_TABLET, &val);
- if (ret != 0) {
- LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_TABLET);
- return;
- }
- if (val == FW_TABLET_NOT_PRESENT) {
- LOG_INF("Clamshell: disable motionsense function.");
- motion_sensor_count = 0;
- gmr_tablet_switch_disable();
- gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_imu));
- gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_imu_int_l),
- GPIO_DISCONNECTED);
-
- LOG_INF("Clamshell: disable volume button function.");
- button_disable_gpio(BUTTON_VOLUME_UP);
- button_disable_gpio(BUTTON_VOLUME_DOWN);
- } else {
- LOG_INF("Tablet: Enable motionsense function.");
- }
-}
-DECLARE_HOOK(HOOK_INIT, sensor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/projects/nissa/pujjo/src/led.c b/zephyr/projects/nissa/pujjo/src/led.c
deleted file mode 100644
index bd04af5a25..0000000000
--- a/zephyr/projects/nissa/pujjo/src/led.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Pujjo specific PWM LED settings: there are 2 LEDs on each side of the board,
- * each one can be controlled separately. The LED colors are white or amber,
- * and the default behavior is tied to the charging process: both sides are
- * amber while charging the battery and white when the battery is charged.
- */
-
-#include "common.h"
-#include "led_onoff_states.h"
-#include "led_common.h"
-#include "gpio.h"
-
-#define CPRINTS(format, args...) cprints(CC_CHARGER, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_CHARGER, format, ##args)
-
-#define LED_OFF_LVL 1
-#define LED_ON_LVL 0
-
-__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_RED,
- LED_INDEFINITE } },
- [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER,
- LED_INDEFINITE } },
- [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN,
- LED_INDEFINITE } },
- [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } },
- [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } },
- [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } },
- [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC },
- { LED_OFF, 1 * LED_ONE_SEC } },
- [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC },
- { EC_LED_COLOR_GREEN,
- 2 * LED_ONE_SEC } },
- };
-
-__override const struct led_descriptor
- led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = {
- [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } },
- [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE,
- 3 * LED_ONE_SEC },
- { LED_OFF, 0.5 * LED_ONE_SEC } },
- [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE,
- 3 * LED_ONE_SEC },
- { LED_OFF,
- 0.5 * LED_ONE_SEC } },
- [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } },
- };
-
-const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED,
- EC_LED_ID_POWER_LED };
-
-const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-
-__override void led_set_color_power(enum ec_led_colors color)
-{
- if (color == EC_LED_COLOR_WHITE)
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led),
- LED_ON_LVL);
- else
- /* LED_OFF and unsupported colors */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_power_led),
- LED_OFF_LVL);
-}
-
-__override void led_set_color_battery(enum ec_led_colors color)
-{
- switch (color) {
- case EC_LED_COLOR_AMBER:
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl),
- LED_ON_LVL);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl),
- LED_ON_LVL);
- break;
- case EC_LED_COLOR_RED:
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl),
- LED_ON_LVL);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl),
- LED_OFF_LVL);
- break;
- case EC_LED_COLOR_GREEN:
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl),
- LED_OFF_LVL);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl),
- LED_ON_LVL);
- break;
- default: /* LED_OFF and other unsupported colors */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_1_odl),
- LED_OFF_LVL);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_led_2_odl),
- LED_OFF_LVL);
- 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_RED] = 1;
- brightness_range[EC_LED_COLOR_AMBER] = 1;
- brightness_range[EC_LED_COLOR_GREEN] = 1;
- } else if (led_id == EC_LED_ID_POWER_LED) {
- 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_RED] != 0)
- led_set_color_battery(EC_LED_COLOR_RED);
- else if (brightness[EC_LED_COLOR_AMBER] != 0)
- led_set_color_battery(EC_LED_COLOR_AMBER);
- else if (brightness[EC_LED_COLOR_GREEN] != 0)
- led_set_color_battery(EC_LED_COLOR_GREEN);
- else
- led_set_color_battery(LED_OFF);
- } else if (led_id == EC_LED_ID_POWER_LED) {
- if (brightness[EC_LED_COLOR_WHITE] != 0)
- led_set_color_power(EC_LED_COLOR_WHITE);
- else
- led_set_color_power(LED_OFF);
- }
-
- return EC_SUCCESS;
-}
diff --git a/zephyr/projects/nissa/pujjo/src/usbc.c b/zephyr/projects/nissa/pujjo/src/usbc.c
deleted file mode 100644
index 5d3d94c243..0000000000
--- a/zephyr/projects/nissa/pujjo/src/usbc.c
+++ /dev/null
@@ -1,242 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-
-#include "charge_state_v2.h"
-#include "chipset.h"
-#include "hooks.h"
-#include "usb_mux.h"
-#include "system.h"
-#include "driver/charger/isl923x_public.h"
-#include "driver/retimer/anx7483_public.h"
-#include "driver/tcpm/tcpci.h"
-#include "driver/tcpm/raa489000.h"
-
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C0_TCPC,
- .addr_flags = RAA489000_TCPC0_I2C_FLAGS,
- },
- .drv = &raa489000_tcpm_drv,
- /* RAA489000 implements TCPCI 2.0 */
- .flags = TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_VBUS_MONITOR,
- },
-};
-
-int board_is_sourcing_vbus(int port)
-{
- int regval;
-
- tcpc_read(port, TCPC_REG_POWER_STATUS, &regval);
- return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS);
-}
-
-int board_set_active_charge_port(int port)
-{
- int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
- int i;
- int old_port;
-
- if (!is_real_port && port != CHARGE_PORT_NONE)
- return EC_ERROR_INVAL;
-
- old_port = charge_manager_get_active_charge_port();
-
- LOG_INF("New chg p%d", port);
-
- /* Disable all ports. */
- if (port == CHARGE_PORT_NONE) {
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- tcpc_write(i, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_SNK_CTRL_LOW);
- raa489000_enable_asgate(i, false);
- }
-
- return EC_SUCCESS;
- }
-
- /* Check if port is sourcing VBUS. */
- if (board_is_sourcing_vbus(port)) {
- LOG_WRN("Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
-
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- if (i == port)
- continue;
-
- if (tcpc_write(i, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_SNK_CTRL_LOW))
- LOG_WRN("p%d: sink path disable failed.", i);
- raa489000_enable_asgate(i, false);
- }
-
- /*
- * Stop the charger IC from switching while changing ports. Otherwise,
- * we can overcurrent the adapter we're switching to. (crbug.com/926056)
- */
- if (old_port != CHARGE_PORT_NONE)
- charger_discharge_on_ac(1);
-
- /* Enable requested charge port. */
- if (raa489000_enable_asgate(port, true) ||
- tcpc_write(port, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_SNK_CTRL_HIGH)) {
- LOG_WRN("p%d: sink path enable failed.", port);
- charger_discharge_on_ac(0);
- return EC_ERROR_UNKNOWN;
- }
-
- /* Allow the charger IC to begin/continue switching. */
- charger_discharge_on_ac(0);
-
- return EC_SUCCESS;
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
- int regval;
-
- /*
- * The interrupt line is shared between the TCPC and BC1.2 detector IC.
- * Therefore, go out and actually read the alert registers to report the
- * alert status.
- */
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
- if (!tcpc_read16(0, TCPC_REG_ALERT, &regval)) {
- /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */
- if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0))
- regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
-
- if (regval)
- status |= PD_STATUS_TCPC_ALERT_0;
- }
- }
- return status;
-}
-
-void pd_power_supply_reset(int port)
-{
- /* Disable VBUS */
- tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW);
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT)
- return;
-
- raa489000_set_output_current(port, rp);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- int rv;
-
- if (port >= CONFIG_USB_PD_PORT_MAX_COUNT)
- return EC_ERROR_INVAL;
-
- /* Disable charging. */
- rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW);
- if (rv)
- return rv;
-
- /* Our policy is not to source VBUS when the AP is off. */
- if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
- return EC_ERROR_NOT_POWERED;
-
- /* Provide Vbus. */
- rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH);
- if (rv)
- return rv;
-
- rv = raa489000_enable_asgate(port, true);
- if (rv)
- return rv;
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS;
-}
-
-void board_reset_pd_mcu(void)
-{
- /*
- * TODO(b:147316511): could send a reset command to the TCPC here
- * if needed.
- */
-}
-
-/*
- * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible
- * for an interrupt to be lost if one asserts the IRQ, the other does the same
- * then the first releases it: there will only be one falling edge to trigger
- * the interrupt, and the line will be held low. We handle this by running a
- * deferred check after a falling edge to see whether the IRQ is still being
- * asserted. If it is, we assume an interrupt may have been lost and we need
- * to poll each chip for events again.
- */
-#define USBC_INT_POLL_DELAY_US 5000
-
-static void poll_c0_int(void);
-DECLARE_DEFERRED(poll_c0_int);
-
-static void usbc_interrupt_trigger(int port)
-{
- schedule_deferred_pd_interrupt(port);
- usb_charger_task_set_event(port, USB_CHG_EVENT_BC12);
-}
-
-static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio,
- const struct deferred_data *ud)
-{
- if (!gpio_pin_get_dt(gpio)) {
- usbc_interrupt_trigger(port);
- hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
- }
-}
-
-static void poll_c0_int(void)
-{
- poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl),
- &poll_c0_int_data);
-}
-
-void usb_interrupt(enum gpio_signal signal)
-{
- int port;
- const struct deferred_data *ud;
-
- if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) {
- port = 0;
- ud = &poll_c0_int_data;
- }
- /*
- * We've just been called from a falling edge, so there's definitely
- * no lost IRQ right now. Cancel any pending check.
- */
- hook_call_deferred(ud, -1);
- /* Trigger polling of TCPC and BC1.2 in respective tasks */
- usbc_interrupt_trigger(port);
- /* Check for lost interrupts in a bit */
- hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
-}
diff --git a/zephyr/projects/nissa/src/board_power.c b/zephyr/projects/nissa/src/board_power.c
deleted file mode 100644
index d7fb4aeffe..0000000000
--- a/zephyr/projects/nissa/src/board_power.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/sys/atomic.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/drivers/gpio.h>
-
-#include <ap_power/ap_power.h>
-#include <ap_power/ap_power_events.h>
-#include <ap_power/ap_power_interface.h>
-#include <ap_power_override_functions.h>
-#include <power_signals.h>
-#include <x86_power_signals.h>
-
-#include "gpio_signal.h"
-#include "gpio/gpio.h"
-
-LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF);
-
-#define X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS 5
-
-static bool s0_stable;
-
-static void generate_ec_soc_dsw_pwrok_handler(int delay)
-{
- int in_sig_val = power_signal_get(PWR_DSW_PWROK);
-
- if (in_sig_val != power_signal_get(PWR_EC_SOC_DSW_PWROK)) {
- if (in_sig_val)
- k_msleep(delay);
- power_signal_set(PWR_EC_SOC_DSW_PWROK, 1);
- }
-}
-
-void board_ap_power_force_shutdown(void)
-{
- int timeout_ms = X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS;
-
- if (s0_stable) {
- /* Enable these power signals in case of sudden shutdown */
- power_signal_enable(PWR_DSW_PWROK);
- power_signal_enable(PWR_PG_PP1P05);
- }
-
- power_signal_set(PWR_EC_SOC_DSW_PWROK, 0);
- power_signal_set(PWR_EC_PCH_RSMRST, 0);
-
- while (power_signal_get(PWR_RSMRST) == 0 &&
- power_signal_get(PWR_SLP_SUS) == 0 && timeout_ms > 0) {
- k_msleep(1);
- timeout_ms--;
- }
- if (power_signal_get(PWR_SLP_SUS) == 0) {
- LOG_WRN("SLP_SUS is not deasserted! Assuming G3");
- }
-
- if (power_signal_get(PWR_RSMRST) == 1) {
- LOG_WRN("RSMRST is not deasserted! Assuming G3");
- }
-
- power_signal_set(PWR_EN_PP3300_A, 0);
-
- power_signal_set(PWR_EN_PP5000_A, 0);
-
- timeout_ms = X86_NON_DSX_ADLP_NONPWRSEQ_FORCE_SHUTDOWN_TO_MS;
- while (power_signal_get(PWR_DSW_PWROK) && timeout_ms > 0) {
- k_msleep(1);
- timeout_ms--;
- };
-
- if (power_signal_get(PWR_DSW_PWROK))
- LOG_WRN("DSW_PWROK didn't go low! Assuming G3.");
-
- power_signal_disable(PWR_DSW_PWROK);
- power_signal_disable(PWR_PG_PP1P05);
- s0_stable = false;
-}
-
-void board_ap_power_action_g3_s5(void)
-{
- power_signal_enable(PWR_DSW_PWROK);
- power_signal_enable(PWR_PG_PP1P05);
-
- LOG_DBG("Turning on PWR_EN_PP5000_A and PWR_EN_PP3300_A");
- power_signal_set(PWR_EN_PP5000_A, 1);
- power_signal_set(PWR_EN_PP3300_A, 1);
-
- power_wait_signals_timeout(IN_PGOOD_ALL_CORE,
- AP_PWRSEQ_DT_VALUE(wait_signal_timeout));
-
- generate_ec_soc_dsw_pwrok_handler(AP_PWRSEQ_DT_VALUE(dsw_pwrok_delay));
- s0_stable = false;
-}
-
-void board_ap_power_action_s3_s0(void)
-{
- s0_stable = false;
-}
-
-void board_ap_power_action_s0_s3(void)
-{
- power_signal_enable(PWR_DSW_PWROK);
- power_signal_enable(PWR_PG_PP1P05);
- s0_stable = false;
-}
-
-void board_ap_power_action_s0(void)
-{
- if (s0_stable) {
- return;
- }
- LOG_INF("Reaching S0");
- power_signal_disable(PWR_DSW_PWROK);
- power_signal_disable(PWR_PG_PP1P05);
- s0_stable = true;
-}
-
-int board_ap_power_assert_pch_power_ok(void)
-{
- /* Pass though PCH_PWROK */
- if (power_signal_get(PWR_PCH_PWROK) == 0) {
- k_msleep(AP_PWRSEQ_DT_VALUE(pch_pwrok_delay));
- power_signal_set(PWR_PCH_PWROK, 1);
- }
-
- return 0;
-}
-
-bool board_ap_power_check_power_rails_enabled(void)
-{
- return power_signal_get(PWR_EN_PP3300_A) &&
- power_signal_get(PWR_EN_PP5000_A) &&
- power_signal_get(PWR_EC_SOC_DSW_PWROK);
-}
-
-int board_power_signal_get(enum power_signal signal)
-{
- switch (signal) {
- default:
- LOG_ERR("Unknown signal for board get: %d", signal);
- return -EINVAL;
-
- case PWR_ALL_SYS_PWRGD:
- /*
- * All system power is good.
- * Checks that PWR_SLP_S3 is off, and
- * the GPIO signal for all power good is set,
- * and that the 1.05 volt line is ready.
- */
- if (power_signal_get(PWR_SLP_S3)) {
- return 0;
- }
- if (!gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_all_sys_pwrgd))) {
- return 0;
- }
- if (!power_signal_get(PWR_PG_PP1P05)) {
- return 0;
- }
- return 1;
- }
-}
-
-int board_power_signal_set(enum power_signal signal, int value)
-{
- return -EINVAL;
-}
diff --git a/zephyr/projects/nissa/src/common.c b/zephyr/projects/nissa/src/common.c
deleted file mode 100644
index 78f703ae49..0000000000
--- a/zephyr/projects/nissa/src/common.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/device.h>
-#include <ap_power/ap_power.h>
-
-#include "battery.h"
-#include "charger.h"
-#include "charge_state_v2.h"
-#include "chipset.h"
-#include "cros_cbi.h"
-#include "hooks.h"
-#include "usb_mux.h"
-#include "system.h"
-
-#include "nissa_common.h"
-
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-static uint8_t cached_usb_pd_port_count;
-
-__override uint8_t board_get_usb_pd_port_count(void)
-{
- __ASSERT(cached_usb_pd_port_count != 0,
- "sub-board detection did not run before a port count request");
- if (cached_usb_pd_port_count == 0)
- LOG_WRN("USB PD Port count not initialized!");
- return cached_usb_pd_port_count;
-}
-
-static void board_power_change(struct ap_power_ev_callback *cb,
- struct ap_power_ev_data data)
-{
- /*
- * Enable power to pen garage when system is active (safe even if no
- * pen is present).
- */
- const struct gpio_dt_spec *const pen_power_gpio =
- GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_pen_x);
-
- switch (data.event) {
- case AP_POWER_STARTUP:
- gpio_pin_set_dt(pen_power_gpio, 1);
- break;
- case AP_POWER_SHUTDOWN:
- gpio_pin_set_dt(pen_power_gpio, 0);
- break;
- default:
- break;
- }
-}
-
-/*
- * Initialise the USB PD port count, which
- * depends on which sub-board is attached.
- */
-static void board_setup_init(void)
-{
- static struct ap_power_ev_callback cb;
-
- ap_power_ev_init_callback(&cb, board_power_change,
- AP_POWER_STARTUP | AP_POWER_SHUTDOWN);
- ap_power_ev_add_callback(&cb);
-
- switch (nissa_get_sb_type()) {
- default:
- cached_usb_pd_port_count = 1;
- break;
-
- case NISSA_SB_C_A:
- case NISSA_SB_C_LTE:
- cached_usb_pd_port_count = 2;
- break;
- }
-}
-/*
- * Make sure setup is done after EEPROM is readable.
- */
-DECLARE_HOOK(HOOK_INIT, board_setup_init, HOOK_PRIO_INIT_I2C);
-
-__overridable void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- int icl = MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT);
-
- /*
- * Assume charger overdraws by about 4%, keeping the actual draw
- * within spec. This adjustment can be changed with characterization
- * of actual hardware.
- */
- icl = icl * 96 / 100;
- charge_set_input_current_limit(icl, charge_mv);
-}
-
-int pd_check_vconn_swap(int port)
-{
- /* Allow VCONN swaps if the AP is on. */
- return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON);
-}
-
-/*
- * Count of chargers depends on sub board presence.
- */
-__override uint8_t board_get_charger_chip_count(void)
-{
- return board_get_usb_pd_port_count();
-}
-
-/*
- * Retrieve sub-board type from FW_CONFIG.
- */
-enum nissa_sub_board_type nissa_get_sb_type(void)
-{
- static enum nissa_sub_board_type sb = NISSA_SB_UNKNOWN;
- int ret;
- uint32_t val;
-
- /*
- * Return cached value.
- */
- if (sb != NISSA_SB_UNKNOWN)
- return sb;
-
- sb = NISSA_SB_NONE; /* Defaults to none */
- ret = cros_cbi_get_fw_config(FW_SUB_BOARD, &val);
- if (ret != 0) {
- LOG_WRN("Error retrieving CBI FW_CONFIG field %d",
- FW_SUB_BOARD);
- return sb;
- }
- switch (val) {
- default:
- LOG_WRN("No sub-board defined");
- break;
- case FW_SUB_BOARD_1:
- sb = NISSA_SB_C_A;
- LOG_INF("SB: USB type C, USB type A");
- break;
-
- case FW_SUB_BOARD_2:
- sb = NISSA_SB_C_LTE;
- LOG_INF("SB: USB type C, WWAN LTE");
- break;
-
- case FW_SUB_BOARD_3:
- sb = NISSA_SB_HDMI_A;
- LOG_INF("SB: HDMI, USB type A");
- break;
- }
- return sb;
-}
diff --git a/zephyr/projects/nissa/src/sub_board.c b/zephyr/projects/nissa/src/sub_board.c
deleted file mode 100644
index 3ccbcd9325..0000000000
--- a/zephyr/projects/nissa/src/sub_board.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Nissa sub-board hardware configuration */
-
-#include <ap_power/ap_power.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/pinctrl.h>
-#include <zephyr/init.h>
-#include <zephyr/kernel.h>
-#include <zephyr/sys/printk.h>
-
-#include "cros_board_info.h"
-#include "driver/tcpm/tcpci.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "usb_charge.h"
-#include "usb_pd.h"
-#include "usbc/usb_muxes.h"
-#include "task.h"
-
-#include "nissa_common.h"
-#include "nissa_hdmi.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-#if NISSA_BOARD_HAS_HDMI_SUPPORT
-static void hdmi_power_handler(struct ap_power_ev_callback *cb,
- struct ap_power_ev_data data)
-{
- /* Enable VCC on the HDMI port. */
- const struct gpio_dt_spec *s3_rail =
- GPIO_DT_FROM_ALIAS(gpio_hdmi_en_odl);
- /* Connect AP's DDC to sub-board (default is USB-C aux) */
- const struct gpio_dt_spec *ddc_select =
- GPIO_DT_FROM_NODELABEL(gpio_hdmi_sel);
-
- switch (data.event) {
- case AP_POWER_PRE_INIT:
- LOG_DBG("Connecting HDMI DDC to sub-board");
- gpio_pin_set_dt(ddc_select, 1);
- break;
- case AP_POWER_STARTUP:
- LOG_DBG("Enabling HDMI VCC");
- gpio_pin_set_dt(s3_rail, 1);
- break;
- case AP_POWER_SHUTDOWN:
- LOG_DBG("Disabling HDMI VCC");
- gpio_pin_set_dt(s3_rail, 0);
- break;
- case AP_POWER_HARD_OFF:
- LOG_DBG("Disconnecting HDMI sub-board DDC");
- gpio_pin_set_dt(ddc_select, 0);
- break;
- default:
- LOG_ERR("Unhandled HDMI power event %d", data.event);
- break;
- }
-}
-
-static void hdmi_hpd_interrupt(const struct device *device,
- struct gpio_callback *callback,
- gpio_port_pins_t pins)
-{
- int state = gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_hpd_odl));
-
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_soc_hdmi_hpd), state);
- LOG_DBG("HDMI HPD changed state to %d", state);
-}
-
-void nissa_configure_hdmi_rails(void)
-{
-#if DT_NODE_EXISTS(GPIO_DT_FROM_ALIAS(gpio_en_rails_odl))
- gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_rails_odl),
- GPIO_OUTPUT_INACTIVE | GPIO_OPEN_DRAIN |
- GPIO_PULL_UP | GPIO_ACTIVE_LOW);
-#endif
-}
-
-void nissa_configure_hdmi_vcc(void)
-{
- gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_hdmi_en_odl),
- GPIO_OUTPUT_INACTIVE | GPIO_OPEN_DRAIN |
- GPIO_ACTIVE_LOW);
-}
-
-__overridable void nissa_configure_hdmi_power_gpios(void)
-{
- nissa_configure_hdmi_rails();
-}
-
-#ifdef CONFIG_SOC_IT8XXX2
-/*
- * On it8xxx2, the below condition will break the EC to enter deep doze mode
- * (b:237717730):
- * Enhance i2c (GPE0/E7, GPH1/GPH2 or GPA4/GPA5) is enabled and its clock and
- * data pins aren't both at high level.
- *
- * Since HDMI+type A SKU doesn't use i2c4, disable it for better power number.
- */
-#define I2C4_NODE DT_NODELABEL(i2c4)
-#if DT_NODE_EXISTS(I2C4_NODE)
-PINCTRL_DT_DEFINE(I2C4_NODE);
-
-/* disable i2c4 alternate function */
-static void soc_it8xxx2_disable_i2c4_alt(void)
-{
- const struct pinctrl_dev_config *pcfg =
- PINCTRL_DT_DEV_CONFIG_GET(I2C4_NODE);
-
- pinctrl_apply_state(pcfg, PINCTRL_STATE_SLEEP);
-}
-#endif /* DT_NODE_EXISTS(I2C4_NODE) */
-#endif /* CONFIG_SOC_IT8XXX2 */
-#endif /* NISSA_BOARD_HAS_HDMI_SUPPORT */
-
-static void lte_power_handler(struct ap_power_ev_callback *cb,
- struct ap_power_ev_data data)
-{
- /* Enable rails for S5 */
- const struct gpio_dt_spec *s5_rail =
- GPIO_DT_FROM_ALIAS(gpio_en_sub_s5_rails);
- switch (data.event) {
- case AP_POWER_PRE_INIT:
- LOG_DBG("Enabling LTE sub-board power rails");
- gpio_pin_set_dt(s5_rail, 1);
- break;
- case AP_POWER_HARD_OFF:
- LOG_DBG("Disabling LTE sub-board power rails");
- gpio_pin_set_dt(s5_rail, 0);
- break;
- default:
- LOG_ERR("Unhandled LTE power event %d", data.event);
- break;
- }
-}
-
-/**
- * Configure GPIOs (and other pin functions) that vary with present sub-board.
- *
- * The functions of some pins vary according to which sub-board is present
- * (indicated by CBI fw_config); this function configures them according to the
- * needs of the present sub-board.
- */
-static void nereid_subboard_config(void)
-{
- enum nissa_sub_board_type sb = nissa_get_sb_type();
- static struct ap_power_ev_callback power_cb;
-
- /*
- * USB-A port: current limit output is configured by default and unused
- * if this port is not present. VBUS enable must be configured if
- * needed and is controlled by the usba-port-enable-pins driver.
- */
- if (sb == NISSA_SB_C_A || sb == NISSA_SB_HDMI_A ||
- sb == NISSA_SB_NONE) {
- /*
- * Configure VBUS enable, default off.
- * SB_NONE indicates missing fw_config; it's safe to enable VBUS
- * control in this case since all that will happen is we turn
- * off power to LTE, and it's useful to allow USB-A to work in
- * such a configuration.
- */
- gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_usb_a1_vbus),
- GPIO_OUTPUT_LOW);
- } else {
- /* Turn off unused pins */
- gpio_pin_configure_dt(
- GPIO_DT_FROM_NODELABEL(gpio_sub_usb_a1_ilimit_sdp),
- GPIO_DISCONNECTED);
- gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_usb_a1_vbus),
- GPIO_DISCONNECTED);
- /* Disable second USB-A port enable GPIO */
- __ASSERT(USB_PORT_ENABLE_COUNT == 2,
- "USB A port count != 2 (%d)", USB_PORT_ENABLE_COUNT);
- usb_port_enable[1] = -1;
- }
- /*
- * USB-C port: the default configuration has I2C on the I2C pins,
- * but the interrupt line needs to be configured.
- */
-#if CONFIG_USB_PD_PORT_MAX_COUNT > 1
- if (sb == NISSA_SB_C_A || sb == NISSA_SB_C_LTE) {
- /* Configure interrupt input */
- gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl),
- GPIO_INPUT | GPIO_PULL_UP);
- } else {
- /* Port doesn't exist, doesn't need muxing */
- USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_1_no_mux);
- }
-#endif
-
- switch (sb) {
-#if NISSA_BOARD_HAS_HDMI_SUPPORT
- case NISSA_SB_HDMI_A: {
- /*
- * HDMI: two outputs control power which must be configured to
- * non-default settings, and HPD must be forwarded to the AP
- * on another output pin.
- */
- const struct gpio_dt_spec *hpd_gpio =
- GPIO_DT_FROM_ALIAS(gpio_hpd_odl);
- static struct gpio_callback hdmi_hpd_cb;
- int rv, irq_key;
-
- nissa_configure_hdmi_power_gpios();
-
-#if CONFIG_SOC_IT8XXX2 && DT_NODE_EXISTS(I2C4_NODE)
- /* disable i2c4 alternate function for better power number */
- soc_it8xxx2_disable_i2c4_alt();
-#endif
-
- /*
- * Control HDMI power according to AP power state. Some events
- * won't do anything if the corresponding pin isn't configured,
- * but that's okay.
- */
- ap_power_ev_init_callback(
- &power_cb, hdmi_power_handler,
- AP_POWER_PRE_INIT | AP_POWER_HARD_OFF |
- AP_POWER_STARTUP | AP_POWER_SHUTDOWN);
- ap_power_ev_add_callback(&power_cb);
-
- /*
- * Configure HPD input from sub-board; it's inverted by a buffer
- * on the sub-board.
- */
- gpio_pin_configure_dt(hpd_gpio, GPIO_INPUT | GPIO_ACTIVE_LOW);
- /* Register interrupt handler for HPD changes */
- gpio_init_callback(&hdmi_hpd_cb, hdmi_hpd_interrupt,
- BIT(hpd_gpio->pin));
- gpio_add_callback(hpd_gpio->port, &hdmi_hpd_cb);
- rv = gpio_pin_interrupt_configure_dt(hpd_gpio,
- GPIO_INT_EDGE_BOTH);
- __ASSERT(rv == 0,
- "HPD interrupt configuration returned error %d", rv);
- /*
- * Run the HPD handler once to ensure output is in sync.
- * Lock interrupts to ensure that we don't cause desync if an
- * HPD interrupt comes in between the internal read of the input
- * and write to the output.
- */
- irq_key = irq_lock();
- hdmi_hpd_interrupt(hpd_gpio->port, &hdmi_hpd_cb,
- BIT(hpd_gpio->pin));
- irq_unlock(irq_key);
- break;
- }
-#endif
- case NISSA_SB_C_LTE:
- /*
- * LTE: Set up callbacks for enabling/disabling
- * sub-board power on S5 state.
- */
- gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_sub_s5_rails),
- GPIO_OUTPUT_INACTIVE);
- /* Control LTE power when CPU entering or
- * exiting S5 state.
- */
- ap_power_ev_init_callback(&power_cb, lte_power_handler,
- AP_POWER_HARD_OFF |
- AP_POWER_PRE_INIT);
- ap_power_ev_add_callback(&power_cb);
- break;
-
- default:
- break;
- }
-}
-DECLARE_HOOK(HOOK_INIT, nereid_subboard_config, HOOK_PRIO_POST_FIRST);
-
-/*
- * Enable interrupts
- */
-static void board_init(void)
-{
- /*
- * Enable USB-C interrupts.
- */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0));
-#if CONFIG_USB_PD_PORT_MAX_COUNT > 1
- if (board_get_usb_pd_port_count() == 2)
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1));
-#endif
-}
-DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
-
-/* Trigger shutdown by enabling the Z-sleep circuit */
-__override void board_hibernate_late(void)
-{
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_slp_z), 1);
- /*
- * The system should hibernate, but there may be
- * a small delay, so return.
- */
-}
diff --git a/zephyr/projects/nissa/xivu/cbi.dtsi b/zephyr/projects/nissa/xivu/cbi.dtsi
deleted file mode 100644
index 4149ea291c..0000000000
--- a/zephyr/projects/nissa/xivu/cbi.dtsi
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- /* Xivu-specific fw_config fields. */
- nissa-fw-config {
- /*
- * FW_CONFIG field to enable WFC or not.
- */
- wfc {
- enum-name = "FW_WFC";
- start = <0>;
- size = <1>;
-
- wfc-mipi {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_WFC_MIPI";
- value = <0>;
- };
- wfc-absent {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_WFC_ABSENT";
- value = <1>;
- };
- };
-
- /*
- * FW_CONFIG field to enable stylus or not.
- */
- stylus {
- enum-name = "FW_STYLUS";
- start = <1>;
- size = <1>;
-
- stylus-present {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_STYLUS_PRESENT";
- value = <0>;
- };
- stylus-absent {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_STYLUS_ABSENT";
- value = <1>;
- };
- };
- /*
- * FW_CONFIG field to indicate which sub-board
- * is attached.
- */
- sub-board {
- enum-name = "FW_SUB_BOARD";
- start = <2>;
- size = <2>;
-
- sub-board-1 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_SUB_BOARD_1";
- value = <0>;
- };
- sub-board-2 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_SUB_BOARD_2";
- value = <1>;
- };
- sub-board-3 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_SUB_BOARD_3";
- value = <2>;
- };
- };
-
-/delete-node/ fan;
- };
-
-};
diff --git a/zephyr/projects/nissa/xivu/led_pins.dtsi b/zephyr/projects/nissa/xivu/led_pins.dtsi
deleted file mode 100644
index d85004a0c9..0000000000
--- a/zephyr/projects/nissa/xivu/led_pins.dtsi
+++ /dev/null
@@ -1,94 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- pwm_pins {
- compatible = "cros-ec,pwm-pin-config";
- pwm_led_y_c0: pwm_led_y_c0 {
- #led-pin-cells = <1>;
- pwms = <&pwm2 0 PWM_HZ(324) PWM_POLARITY_INVERTED>;
- };
-
- pwm_led_w_c0: pwm_led_w_c0 {
- #led-pin-cells = <1>;
- pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_INVERTED>;
- };
-
- pwm_led_y_c1: pwm_led_y_c1 {
- #led-pin-cells = <1>;
- pwms = <&pwm6 0 PWM_HZ(324) PWM_POLARITY_INVERTED>;
- };
-
- pwm_led_w_c1: pwm_led_w_c1 {
- #led-pin-cells = <1>;
- pwms = <&pwm1 0 PWM_HZ(324) PWM_POLARITY_INVERTED>;
- };
- };
-
- pwm-led-pins {
- compatible = "cros-ec,pwm-led-pins";
-
- color_off: color-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&pwm_led_y_c0 0>,
- <&pwm_led_y_c1 0>,
- <&pwm_led_w_c0 0>,
- <&pwm_led_w_c1 0>;
- };
-
- color_amber: color-amber {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&pwm_led_y_c0 1>,
- <&pwm_led_y_c1 1>,
- <&pwm_led_w_c0 0>,
- <&pwm_led_w_c1 0>;
- };
-
- color_white: color-white {
- led-color = "LED_WHITE";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_WHITE";
- led-pins = <&pwm_led_y_c0 0>,
- <&pwm_led_y_c1 0>,
- <&pwm_led_w_c0 1>,
- <&pwm_led_w_c1 1>;
- };
- };
-};
-
-/* LED2 */
-&pwm0 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm0_gpc3>;
- pinctrl-names = "default";
-};
-
-/* LED3 */
-&pwm1 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm1_gpc2>;
- pinctrl-names = "default";
-};
-
-/* LED1 */
-&pwm2 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm2_gpc4>;
- pinctrl-names = "default";
-};
-
-/* LED0 */
-&pwm6 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm6_gpc0>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/nissa/xivu/motionsense.dtsi b/zephyr/projects/nissa/xivu/motionsense.dtsi
deleted file mode 100644
index 332252c4ef..0000000000
--- a/zephyr/projects/nissa/xivu/motionsense.dtsi
+++ /dev/null
@@ -1,156 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <dt-bindings/motionsense/utils.h>
-
-
-/ {
- aliases {
- /*
- * Interrupt bindings for sensor devices.
- */
- lsm6dso-int = &base_accel;
- lis2dw12-int = &lid_accel;
- };
-
- /*
- * Declare mutexes used by sensor drivers.
- * A mutex node is used to create an instance of mutex_t.
- * A mutex node is referenced by a sensor node if the
- * corresponding sensor driver needs to use the
- * instance of the mutex.
- */
- motionsense-mutex {
- compatible = "cros-ec,motionsense-mutex";
- lid_mutex: lid-mutex {
- };
-
- base_mutex: base-mutex {
- };
- };
-
- /* Rotation matrix used by drivers. */
- motionsense-rotation-ref {
- compatible = "cros-ec,motionsense-rotation-ref";
- lid_rot_ref: lid-rotation-ref {
- mat33 = <0 1 0
- 1 0 0
- 0 0 (-1)>;
- };
-
- base_rot_ref: base-rotation-ref {
- mat33 = <0 (-1) 0
- 1 0 0
- 0 0 1>;
- };
- };
-
- /*
- * Driver specific data. A driver-specific data can be shared with
- * different motion sensors while they are using the same driver.
- *
- * If a node's compatible starts with "cros-ec,accelgyro-", it is for
- * a common structure defined in accelgyro.h.
- * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for
- * "struct als_drv_data_t" in accelgyro.h
- */
- motionsense-sensor-data {
- lsm6dso_accel_data: lsm6dso-accel-drv-data {
- compatible = "cros-ec,drvdata-lsm6dso";
- status = "okay";
- };
-
- lsm6dso_gyro_data: lsm6dso-gyro-drv-data {
- compatible = "cros-ec,drvdata-lsm6dso";
- status = "okay";
- };
-
- lis2dw12_data: lis2dw12-drv-data {
- compatible = "cros-ec,drvdata-lis2dw12";
- status = "okay";
- };
- };
-
- /*
- * List of motion sensors that creates motion_sensors array.
- * The nodelabel "lid_accel" and "base_accel" are used to indicate
- * motion sensor IDs for lid angle calculation.
- * TODO(b/238139272): The first entries of the array must be
- * accelerometers,then gyroscope. Fix this dependency in the DTS
- * processing which makes the devicetree entries independent.
- */
- motionsense-sensor {
- lid_accel: lid-accel {
- compatible = "cros-ec,lis2dw12";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_LID";
- mutex = <&lid_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&lid_rot_ref>;
- default-range = <2>;
- drv-data = <&lis2dw12_data>;
- i2c-spi-addr-flags = "LIS2DWL_ADDR0_FLAGS";
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_accel: base-accel {
- compatible = "cros-ec,lsm6dso-accel";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&lsm6dso_accel_data>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_gyro: base-gyro {
- compatible = "cros-ec,lsm6dso-gyro";
- status = "okay";
-
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&base_mutex>;
- port = <&i2c_ec_i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- default-range = <(1000 | ROUND_UP_FLAG)>; /* dps */
- drv-data = <&lsm6dso_gyro_data>;
- };
- };
-
- motionsense-sensor-info {
- compatible = "cros-ec,motionsense-sensor-info";
-
- /*
- * list of GPIO interrupts that have to
- * be enabled at initial stage
- */
- sensor-irqs = <&int_imu>;
- /* list of sensors in force mode */
- accel-force-mode-sensors = <&lid_accel>;
- };
-};
diff --git a/zephyr/projects/nissa/xivu/overlay.dtsi b/zephyr/projects/nissa/xivu/overlay.dtsi
deleted file mode 100644
index de45db75e7..0000000000
--- a/zephyr/projects/nissa/xivu/overlay.dtsi
+++ /dev/null
@@ -1,357 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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>
-
-/ {
- aliases {
- gpio-cbi-wp = &gpio_ec_cbi_wp;
- gpio-wp = &gpio_ec_wp_odl;
- int-wp = &int_wp_l;
- gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
- };
-
- ec-console {
- compatible = "ec-console";
- disabled = "events", "lpc", "hostcmd";
- };
-
- batteries {
- default_battery: smp_c31n2005 {
- compatible = "smp,c31n2005", "battery-smart";
- };
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-irqs = <
- &int_power_button
- &int_lid_open
- >;
- };
-
- gpio-interrupts {
- compatible = "cros-ec,gpio-interrupts";
-
- int_power_button: power_button {
- irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "power_button_interrupt";
- };
- int_wp_l: wp_l {
- irq-pin = <&gpio_ec_wp_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "switch_interrupt";
- };
- int_lid_open: lid_open {
- irq-pin = <&gpio_lid_open>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "lid_interrupt";
- };
- int_tablet_mode: tablet_mode {
- irq-pin = <&gpio_tablet_mode_l>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "gmr_tablet_switch_isr";
- };
- int_imu: ec_imu {
- irq-pin = <&gpio_imu_int_l>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "lsm6dso_interrupt";
- };
- int_vol_down: vol_down {
- irq-pin = <&gpio_voldn_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "button_interrupt";
- };
- int_vol_up: vol_up {
- irq-pin = <&gpio_volup_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "button_interrupt";
- };
- int_usb_c0: usb_c0 {
- irq-pin = <&gpio_usb_c0_int_odl>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "usb_interrupt";
- };
- int_usb_c1: usb_c1 {
- irq-pin = <&gpio_sb_1>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "usb_interrupt";
- };
- };
-
- named-gpios {
- gpio_sb_1: sb-1 {
- gpios = <&gpio0 2 GPIO_PULL_UP>;
- no-auto-init;
- };
-
- gpio_sb_2: sb-2 {
- gpios = <&gpiod 4 GPIO_OUTPUT>;
- no-auto-init;
- };
-
- /*
- * 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.
- */
- gpio_sb_3: sb-3 {
- gpios = <&gpiof 4 (GPIO_OPEN_DRAIN | GPIO_VOLTAGE_1P8)>;
- no-auto-init;
- };
- gpio_sb_4: sb-4 {
- gpios = <&gpiof 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- no-auto-init;
- };
- };
-
- /*
- * Aliases used for sub-board GPIOs.
- */
- aliases {
- /*
- * Input GPIO when used with type-C port 1
- */
- gpio-usb-c1-int-odl = &gpio_sb_1;
- gpio-en-rails-odl = &gpio_sb_1;
- /*
- * Sub-board with type A USB, enable.
- */
- gpio-en-usb-a1-vbus = &gpio_sb_2;
- /*
- * Enable S5 rails for LTE sub-board
- */
- gpio-en-sub-s5-rails = &gpio_sb_2;
- };
-
- temp_memory: memory {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_1>;
- };
- temp_ambient: ambient {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_2>;
- };
- temp_charger1: charger1 {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_3>;
- };
- temp_charger2: charger2 {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_4>;
- };
-
- named-temp-sensors {
- compatible = "cros-ec,temp-sensors";
- memory {
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- temp_host_release_halt = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_memory>;
- };
- ambient {
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- temp_host_release_halt = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_ambient>;
- };
- charger1 {
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- temp_host_release_halt = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_charger1>;
- };
- charger2 {
- temp_host_high = <85>;
- temp_host_halt = <90>;
- temp_host_release_high = <80>;
- temp_host_release_halt = <80>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_charger2>;
- };
- };
-
- usba {
- compatible = "cros-ec,usba-port-enable-pins";
- /*
- * sb_2 is only configured as GPIO when USB-A1 is present,
- * but it's still safe to control when disabled.
- *
- * ILIM_SEL pins are referred to by legacy enum name,
- * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
- * sub-boards that don't have USB-A so is safe to control
- * regardless of system configuration.
- */
- enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
- status = "okay";
- };
-
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- chg = <&chg_port0>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&virtual_mux_0>;
- };
- };
- port0-muxes {
- virtual_mux_0: virtual-mux-0 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
- /*
- * TODO(b:211693800): port1 may not be present on some
- * sub-boards.
- */
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- chg = <&chg_port1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&virtual_mux_1 &anx7483_mux_1>;
- };
- usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux {
- compatible = "cros-ec,usb-mux-chain";
- alternative-chain;
- usb-muxes = <&virtual_mux_1>;
- };
- };
- port1-muxes {
- virtual_mux_1: virtual-mux-1 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
- };
-
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios =
- <&gpio8 5 0>,
- <&gpio3 6 0>,
- <&gpiod 7 0>,
- <&gpio6 0 0>,
- <&gpiof 2 0>,
- <&gpiof 3 0>;
- };
-};
-
-&thermistor_3V3_51K1_47K_4050B {
- status = "okay";
-};
-
-&adc_ec_vsense_pp3300_s5 {
- /*
- * Voltage divider on input has 47k upper and 220k lower legs with
- * 2714 mV full-scale reading on the ADC. Apply the largest possible
- * multiplier (without overflowing int32) to get the best possible
- * approximation of the actual ratio, but derate by a factor of two to
- * ensure unexpectedly high values won't overflow.
- */
- mul = <(791261 / 2)>;
- div = <(651975 / 2)>;
-};
-
-/* Set bus speeds for I2C */
-&i2c0_0 {
- label = "I2C_EEPROM";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
-};
-
-&i2c1_0 {
- label = "I2C_SENSOR";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c3_0 {
- label = "I2C_USB_C0_TCPC";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-
- bc12_port0: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- /*
- * BC1.2 interrupt is shared with TCPC, so
- * IRQ is not specified here and handled by
- * usb_c0_interrupt.
- */
- };
-
- chg_port0: isl923x@9 {
- compatible = "intersil,isl923x";
- status = "okay";
- reg = <0x9>;
- };
-};
-
-&i2c5_1 {
- label = "I2C_SUB_C1_TCPC";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-
- bc12_port1: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- };
-
- chg_port1: isl923x@9 {
- compatible = "intersil,isl923x";
- status = "okay";
- reg = <0x9>;
- };
-
- anx7483_mux_1: anx7483-mux-1@3e {
- compatible = "analogix,anx7483";
- reg = <0x3e>;
- board-set = "anx7483_set_default_tuning";
- };
-};
-
-&i2c7_0 {
- label = "I2C_BATTERY";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&pwm6 {
- status = "okay";
- pinctrl-0 = <&pwm6_gpc0>;
- pinctrl-names = "default";
-};
-
-/* host interface */
-&espi0 {
- status = "okay";
- pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/nissa/xivu/project.conf b/zephyr/projects/nissa/xivu/project.conf
deleted file mode 100644
index 4ce9c635c3..0000000000
--- a/zephyr/projects/nissa/xivu/project.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_BOARD_XIVU=y
-CONFIG_PLATFORM_EC_OCPC=y
-CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_COMMON=n
-CONFIG_PLATFORM_EC_LED_DT=y
-
-# USBC
-CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000
diff --git a/zephyr/projects/nissa/xivu/src/charger.c b/zephyr/projects/nissa/xivu/src/charger.c
deleted file mode 100644
index 5021a55758..0000000000
--- a/zephyr/projects/nissa/xivu/src/charger.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-
-#include "battery.h"
-#include "charger.h"
-#include "charger/isl923x_public.h"
-#include "console.h"
-#include "extpower.h"
-#include "usb_pd.h"
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-int extpower_is_present(void)
-{
- int port;
- int rv;
- bool acok;
-
- for (port = 0; port < board_get_usb_pd_port_count(); port++) {
- rv = raa489000_is_acok(port, &acok);
- if ((rv == EC_SUCCESS) && acok)
- return 1;
- }
-
- return 0;
-}
-
-/*
- * Xivu does not have a GPIO indicating whether extpower is present,
- * so detect using the charger(s).
- */
-__override void board_check_extpower(void)
-{
- static int last_extpower_present;
- int extpower_present_p0 = 0;
- int extpower_present_p1 = 0;
-
- int extpower_present = extpower_is_present();
-
- if (last_extpower_present ^ extpower_present)
- extpower_handle_update(extpower_present);
-
- last_extpower_present = extpower_present;
-
- if (pd_is_connected(0))
- extpower_present_p0 = extpower_is_present();
- else if (pd_is_connected(1))
- extpower_present_p1 = extpower_is_present();
-
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_acok_otg_c0),
- extpower_present_p0);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_acok_otg_c1),
- extpower_present_p1);
-}
-
-__override void board_hibernate(void)
-{
- /* Shut down the chargers */
- if (board_get_usb_pd_port_count() == 2)
- raa489000_hibernate(CHARGER_SECONDARY, true);
- raa489000_hibernate(CHARGER_PRIMARY, true);
- LOG_INF("Charger(s) hibernated");
- cflush();
-}
diff --git a/zephyr/projects/nissa/xivu/src/usbc.c b/zephyr/projects/nissa/xivu/src/usbc.c
deleted file mode 100644
index 1520efaa55..0000000000
--- a/zephyr/projects/nissa/xivu/src/usbc.c
+++ /dev/null
@@ -1,285 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-
-#include "charge_state_v2.h"
-#include "chipset.h"
-#include "hooks.h"
-#include "usb_mux.h"
-#include "system.h"
-#include "driver/charger/isl923x_public.h"
-#include "driver/retimer/anx7483_public.h"
-#include "driver/tcpm/tcpci.h"
-#include "driver/tcpm/raa489000.h"
-
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C0_TCPC,
- .addr_flags = RAA489000_TCPC0_I2C_FLAGS,
- },
- .drv = &raa489000_tcpm_drv,
- /* RAA489000 implements TCPCI 2.0 */
- .flags = TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_VBUS_MONITOR,
- },
- { /* sub-board */
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C1_TCPC,
- .addr_flags = RAA489000_TCPC0_I2C_FLAGS,
- },
- .drv = &raa489000_tcpm_drv,
- /* RAA489000 implements TCPCI 2.0 */
- .flags = TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_VBUS_MONITOR,
- },
-};
-
-int board_is_sourcing_vbus(int port)
-{
- int regval;
-
- tcpc_read(port, TCPC_REG_POWER_STATUS, &regval);
- return !!(regval & TCPC_REG_POWER_STATUS_SOURCING_VBUS);
-}
-
-int board_set_active_charge_port(int port)
-{
- int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
- int i;
- int old_port;
-
- if (!is_real_port && port != CHARGE_PORT_NONE)
- return EC_ERROR_INVAL;
-
- old_port = charge_manager_get_active_charge_port();
-
- LOG_INF("New chg p%d", port);
-
- /* Disable all ports. */
- if (port == CHARGE_PORT_NONE) {
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- tcpc_write(i, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_SNK_CTRL_LOW);
- raa489000_enable_asgate(i, false);
- }
-
- return EC_SUCCESS;
- }
-
- /* Check if port is sourcing VBUS. */
- if (board_is_sourcing_vbus(port)) {
- LOG_WRN("Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
-
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- if (i == port)
- continue;
-
- if (tcpc_write(i, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_SNK_CTRL_LOW))
- LOG_WRN("p%d: sink path disable failed.", i);
- raa489000_enable_asgate(i, false);
- }
-
- /*
- * Stop the charger IC from switching while changing ports. Otherwise,
- * we can overcurrent the adapter we're switching to. (crbug.com/926056)
- */
- if (old_port != CHARGE_PORT_NONE)
- charger_discharge_on_ac(1);
-
- /* Enable requested charge port. */
- if (raa489000_enable_asgate(port, true) ||
- tcpc_write(port, TCPC_REG_COMMAND,
- TCPC_REG_COMMAND_SNK_CTRL_HIGH)) {
- LOG_WRN("p%d: sink path enable failed.", port);
- charger_discharge_on_ac(0);
- return EC_ERROR_UNKNOWN;
- }
-
- /* Allow the charger IC to begin/continue switching. */
- charger_discharge_on_ac(0);
-
- return EC_SUCCESS;
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
- int regval;
-
- /*
- * The interrupt line is shared between the TCPC and BC1.2 detector IC.
- * Therefore, go out and actually read the alert registers to report the
- * alert status.
- */
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
- if (!tcpc_read16(0, TCPC_REG_ALERT, &regval)) {
- /* The TCPCI Rev 1.0 spec says to ignore bits 14:12. */
- if (!(tcpc_config[0].flags & TCPC_FLAGS_TCPCI_REV2_0))
- regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
-
- if (regval)
- status |= PD_STATUS_TCPC_ALERT_0;
- }
- }
-
- if (board_get_usb_pd_port_count() == 2 &&
- !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
- if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
- /* TCPCI spec Rev 1.0 says to ignore bits 14:12. */
- if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0))
- regval &= ~((1 << 14) | (1 << 13) | (1 << 12));
-
- if (regval)
- status |= PD_STATUS_TCPC_ALERT_1;
- }
- }
-
- return status;
-}
-
-void pd_power_supply_reset(int port)
-{
- /* Disable VBUS */
- tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_LOW);
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- if (port < 0 || port >= CONFIG_USB_PD_PORT_MAX_COUNT)
- return;
-
- raa489000_set_output_current(port, rp);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- int rv;
-
- if (port >= CONFIG_USB_PD_PORT_MAX_COUNT)
- return EC_ERROR_INVAL;
-
- /* Disable charging. */
- rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SNK_CTRL_LOW);
- if (rv)
- return rv;
-
- /* Our policy is not to source VBUS when the AP is off. */
- if (chipset_in_state(CHIPSET_STATE_ANY_OFF))
- return EC_ERROR_NOT_POWERED;
-
- /* Provide Vbus. */
- rv = tcpc_write(port, TCPC_REG_COMMAND, TCPC_REG_COMMAND_SRC_CTRL_HIGH);
- if (rv)
- return rv;
-
- rv = raa489000_enable_asgate(port, true);
- if (rv)
- return rv;
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS;
-}
-
-void board_reset_pd_mcu(void)
-{
- /*
- * TODO(b:147316511): could send a reset command to the TCPC here
- * if needed.
- */
-}
-
-/*
- * Because the TCPCs and BC1.2 chips share interrupt lines, it's possible
- * for an interrupt to be lost if one asserts the IRQ, the other does the same
- * then the first releases it: there will only be one falling edge to trigger
- * the interrupt, and the line will be held low. We handle this by running a
- * deferred check after a falling edge to see whether the IRQ is still being
- * asserted. If it is, we assume an interrupt may have been lost and we need
- * to poll each chip for events again.
- */
-#define USBC_INT_POLL_DELAY_US 5000
-
-static void poll_c0_int(void);
-DECLARE_DEFERRED(poll_c0_int);
-static void poll_c1_int(void);
-DECLARE_DEFERRED(poll_c1_int);
-
-static void usbc_interrupt_trigger(int port)
-{
- schedule_deferred_pd_interrupt(port);
- usb_charger_task_set_event(port, USB_CHG_EVENT_BC12);
-}
-
-static inline void poll_usb_gpio(int port, const struct gpio_dt_spec *gpio,
- const struct deferred_data *ud)
-{
- if (!gpio_pin_get_dt(gpio)) {
- usbc_interrupt_trigger(port);
- hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
- }
-}
-
-static void poll_c0_int(void)
-{
- poll_usb_gpio(0, GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl),
- &poll_c0_int_data);
-}
-
-static void poll_c1_int(void)
-{
- poll_usb_gpio(1, GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl),
- &poll_c1_int_data);
-}
-
-void usb_interrupt(enum gpio_signal signal)
-{
- int port;
- const struct deferred_data *ud;
-
- if (signal == GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_int_odl))) {
- port = 0;
- ud = &poll_c0_int_data;
- } else {
- port = 1;
- ud = &poll_c1_int_data;
- }
- /*
- * We've just been called from a falling edge, so there's definitely
- * no lost IRQ right now. Cancel any pending check.
- */
- hook_call_deferred(ud, -1);
- /* Trigger polling of TCPC and BC1.2 in respective tasks */
- usbc_interrupt_trigger(port);
- /* Check for lost interrupts in a bit */
- hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
-}
-
-__override void board_set_charge_limit(int port, int supplier, int charge_ma,
- int max_ma, int charge_mv)
-{
- charge_ma = (charge_ma * 90) / 100;
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
diff --git a/zephyr/projects/nissa/yaviks/overlay.dtsi b/zephyr/projects/nissa/yaviks/overlay.dtsi
deleted file mode 100644
index d768116444..0000000000
--- a/zephyr/projects/nissa/yaviks/overlay.dtsi
+++ /dev/null
@@ -1,402 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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>
-
-/ {
- aliases {
- gpio-cbi-wp = &gpio_ec_cbi_wp;
- gpio-wp = &gpio_ec_wp_odl;
- int-wp = &int_wp_l;
- /*
- * USB-C: interrupt input.
- * I2C pins are on i2c_ec_i2c_sub_usb_c1
- */
- gpio-usb-c1-int-odl = &gpio_sb_1;
- /*
- * USB-A: VBUS enable output
- * LTE: power enable output
- */
- gpio-en-usb-a1-vbus = &gpio_sb_2;
- /*
- * Enable S5 rails for LTE sub-board
- */
- gpio-en-sub-s5-rails = &gpio_sb_2;
- };
-
- ec-console {
- compatible = "ec-console";
- disabled = "events", "lpc", "hostcmd";
- };
-
- batteries {
- default_battery: cosmx {
- compatible = "cosmx,gh02047xl", "battery-smart";
- };
- dynapack_atl_gh02047xl {
- compatible = "dynapack,atl_gh02047xl", "battery-smart";
- };
- dynapack_cosmx_gh02047xl {
- compatible = "dynapack,cosmx_gh02047xl", "battery-smart";
- };
- smp_coslight_gh02047xl {
- compatible = "smp,coslight_gh02047xl", "battery-smart";
- };
- smp_highpower_gh02047xl {
- compatible = "smp,highpower_gh02047xl", "battery-smart";
- };
- default_battery_3s:cosmx_si03058xl {
- compatible = "cosmx,si03058xl", "battery-smart";
- };
- smp_highpower_si03058xl {
- compatible = "smp,highpower_si03058xl", "battery-smart";
- };
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-irqs = <
- &int_power_button
- &int_lid_open
- >;
- };
-
- gpio-interrupts {
- compatible = "cros-ec,gpio-interrupts";
-
- int_power_button: power_button {
- irq-pin = <&gpio_gsc_ec_pwr_btn_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "power_button_interrupt";
- };
- int_wp_l: wp_l {
- irq-pin = <&gpio_ec_wp_odl>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "switch_interrupt";
- };
- int_lid_open: lid_open {
- irq-pin = <&gpio_lid_open>;
- flags = <GPIO_INT_EDGE_BOTH>;
- handler = "lid_interrupt";
- };
- int_usb_c0: usb_c0 {
- irq-pin = <&gpio_usb_c0_int_odl>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "usb_c0_interrupt";
- };
- int_usb_c1: usb_c1 {
- irq-pin = <&gpio_sb_1>;
- flags = <GPIO_INT_EDGE_FALLING>;
- handler = "usb_c1_interrupt";
- };
- };
-
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios = <&gpioa 7 0>,
- <&gpioc 0 0>,
- <&gpioc 6 0>,
- <&gpiod 7 0>,
- <&gpioh 2 0>,
- <&gpioi 6 0>,
- <&gpioi 7 0>,
- <&gpioj 0 0>,
- <&gpioj 3 0>,
- <&gpiok 7 GPIO_OUTPUT>;
- };
-
- named-gpios {
- /*
- * EC doesn't take any specific action on CC/SBU disconnect due to
- * fault, but this definition is useful for hardware testing.
- */
- gpio_usb_c0_prot_fault_odl: usb_c0_prot_fault_odl {
- gpios = <&gpiok 6 GPIO_INPUT_PULL_UP>;
- };
-
- gpio_sb_1: sb_1 {
- gpios = <&gpioe 6 0>;
- no-auto-init;
- };
- gpio_sb_2: sb_2 {
- gpios = <&gpiof 0 0>;
- no-auto-init;
- };
- gpio_fan_enable: fan-enable {
- gpios = <&gpioa 1 GPIO_OUTPUT>;
- no-auto-init;
- };
- };
-
- temp_cpu: cpu {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_1>;
- };
- temp_5v_regulator: 5v_regulator {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_2>;
- };
- temp_charger: charger {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- adc = <&adc_temp_sensor_3>;
- };
-
- named-temp-sensors {
- compatible = "cros-ec,temp-sensors";
- cpu {
- temp_fan_off = <45>;
- temp_fan_max = <60>;
- temp_host_high = <75>;
- temp_host_halt = <85>;
- temp_host_release_high = <65>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_cpu>;
- };
- 5v_regulator {
- temp_fan_off = <50>;
- temp_fan_max = <65>;
- temp_host_high = <75>;
- temp_host_halt = <85>;
- temp_host_release_high = <65>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_5v_regulator>;
- };
- charger {
- temp_fan_off = <50>;
- temp_fan_max = <65>;
- temp_host_high = <80>;
- temp_host_halt = <85>;
- temp_host_release_high = <75>;
- power-good-pin = <&gpio_ec_soc_dsw_pwrok>;
- sensor = <&temp_charger>;
- };
- };
-
- usba {
- compatible = "cros-ec,usba-port-enable-pins";
- /*
- * sb_2 is only configured as GPIO when USB-A1 is present,
- * but it's still safe to control when disabled.
- *
- * ILIM_SEL pins are referred to by legacy enum name,
- * GPIO_USB*_ILIM_SEL. The one for port A1 is unused on
- * sub-boards that don't have USB-A so is safe to control
- * regardless of system configuration.
- */
- enable-pins = <&gpio_en_usb_a0_vbus &gpio_sb_2>;
- status = "okay";
- };
-
- usbc {
- #address-cells = <1>;
- #size-cells = <0>;
-
- port0@0 {
- compatible = "named-usbc-port";
- reg = <0>;
- bc12 = <&bc12_port0>;
- chg = <&chg_port0>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&virtual_mux_0>;
- };
- };
- port0-muxes {
- virtual_mux_0: virtual-mux-0 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- };
- port1@1 {
- compatible = "named-usbc-port";
- reg = <1>;
- bc12 = <&bc12_port1>;
- chg = <&chg_port1>;
- usb-mux-chain-1 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&virtual_mux_1 &tcpci_mux_1>;
- };
- usb_mux_chain_1_no_mux: usb-mux-chain-1-no-mux {
- compatible = "cros-ec,usb-mux-chain";
- alternative-chain;
- usb-muxes = <&virtual_mux_1>;
- };
- };
- port1-muxes {
- virtual_mux_1: virtual-mux-1 {
- compatible = "cros-ec,usbc-mux-virtual";
- };
- tcpci_mux_1: tcpci-mux-1 {
- compatible = "parade,usbc-mux-ps8xxx";
- };
- };
- };
-
- fans {
- compatible = "cros-ec,fans";
- fan_0 {
- pwms = <&pwm2 PWM_CHANNEL_2 PWM_KHZ(25) PWM_POLARITY_NORMAL>;
- tach = <&tach1>;
- rpm_min = <2600>;
- rpm_start = <2600>;
- rpm_max = <4100>;
- enable_gpio = <&gpio_fan_enable>;
- };
- };
-};
-
-&thermistor_3V3_51K1_47K_4050B {
- status = "okay";
-};
-
-&adc_ec_vsense_pp3300_s5 {
- /*
- * Voltage divider on input has 47k upper and 220k lower legs with 3 V
- * full-scale reading on the ADC. Apply the largest possible multiplier
- * (without overflowing int32) to get the best possible approximation
- * of the actual ratio, but derate by a factor of two to ensure
- * unexpectedly high values won't overflow.
- */
- mul = <(715828 / 2)>;
- div = <(589820 / 2)>;
-};
-
-&adc0 {
- pinctrl-0 = <&adc0_ch0_gpi0_default
- &adc0_ch2_gpi2_default
- &adc0_ch3_gpi3_default
- &adc0_ch13_gpl0_default
- &adc0_ch14_gpl1_default>;
- pinctrl-names = "default";
- status = "okay";
-};
-
-&pinctrl {
- i2c4_clk_gpe0_sleep: i2c4_clk_gpe0_sleep {
- pinmuxs = <&pinctrle 0 IT8XXX2_ALT_DEFAULT>;
- };
- i2c4_data_gpe7_sleep: i2c4_data_gpe7_sleep {
- pinmuxs = <&pinctrle 7 IT8XXX2_ALT_DEFAULT>;
- };
- i2c2_clk_gpf6_default: i2c2_clk_gpf6_default {
- gpio-voltage = "1v8";
- };
- i2c2_data_gpf7_default: i2c2_data_gpf7_default {
- gpio-voltage = "1v8";
- };
-};
-
-&i2c0 {
- label = "I2C_EEPROM";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- label = "EEPROM_CBI";
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
- pinctrl-0 = <&i2c0_clk_gpb3_default
- &i2c0_data_gpb4_default>;
- pinctrl-names = "default";
- status = "okay";
-};
-
-&i2c1 {
- label = "I2C_BATTERY";
- clock-frequency = <50000>;
- pinctrl-0 = <&i2c1_clk_gpc1_default
- &i2c1_data_gpc2_default>;
- pinctrl-names = "default";
- status = "okay";
-};
-
-&i2c2 {
- label = "I2C_SENSOR";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c2_clk_gpf6_default
- &i2c2_data_gpf7_default>;
- pinctrl-names = "default";
- status = "okay";
-};
-
-&i2c4 {
- label = "I2C_SUB_C1_TCPC";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
- pinctrl-0 = <&i2c4_clk_gpe0_default
- &i2c4_data_gpe7_default>;
- pinctrl-1 = <&i2c4_clk_gpe0_sleep
- &i2c4_data_gpe7_sleep>;
- pinctrl-names = "default", "sleep";
- status = "okay";
-
- bc12_port1: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- };
-
- chg_port1: sm5803@32 {
- compatible = "siliconmitus,sm5803";
- status = "okay";
- reg = <0x32>;
- };
-};
-
-&i2c_ec_i2c_sub_usb_c1 {
- /*
- * Dynamic speed setting is used for AP-controlled firmware update
- * of PS8745 TCPC/redriver: the AP lowers speed to 400 kHz in order
- * to use more efficient window programming, then sets it back when
- * done.
- */
- dynamic-speed;
-};
-
-&i2c5 {
- label = "I2C_USB_C0_TCPC";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
- pinctrl-0 = <&i2c5_clk_gpa4_default
- &i2c5_data_gpa5_default>;
- pinctrl-names = "default";
- status = "okay";
-
- bc12_port0: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- };
-
- chg_port0: sm5803@32 {
- compatible = "siliconmitus,sm5803";
- status = "okay";
- reg = <0x32>;
- };
-};
-
-&usbpd0 {
- status = "okay";
-};
-
-/* pwm for fan */
-&pwm2 {
- status = "okay";
- prescaler-cx = <PWM_PRESCALER_C6>;
- pinctrl-0 = <&pwm2_gpa2_default>;
- pinctrl-names = "default";
-};
-/* fan tachometer sensor */
-&tach1 {
- status = "okay";
- channel = <IT8XXX2_TACH_CHANNEL_A>;
- pulses-per-round = <2>;
- pinctrl-0 = <&tach1a_gpd7_default>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/nissa/yaviks/project.conf b/zephyr/projects/nissa/yaviks/project.conf
deleted file mode 100644
index 0e385b843e..0000000000
--- a/zephyr/projects/nissa/yaviks/project.conf
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_BOARD_YAVIKS=y
-
-# Ensure recovery key combination (esc+refresh+power) is reliable: b/236580049
-CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
-CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
-
-# Sensors: disabled; yaviks is clamshell-only
-CONFIG_PLATFORM_EC_LID_ANGLE=n
-CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n
-CONFIG_PLATFORM_EC_MOTIONSENSE=n
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=n
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n
-CONFIG_PLATFORM_EC_ACCEL_FIFO=n
-CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=n
-CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n
-CONFIG_PLATFORM_EC_TABLET_MODE=n
-CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n
-CONFIG_PLATFORM_EC_VOLUME_BUTTONS=n
-CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y
-CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=n
-
-# Fan
-CONFIG_PLATFORM_EC_FAN=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_PWM=n
diff --git a/zephyr/projects/nissa/yaviks/project.overlay b/zephyr/projects/nissa/yaviks/project.overlay
deleted file mode 100644
index a7ce97a8b3..0000000000
--- a/zephyr/projects/nissa/yaviks/project.overlay
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "../cbi.dtsi"
-
-#include "cbi.dtsi"
-#include "gpio.dtsi"
-#include "keyboard.dtsi"
-#include "overlay.dtsi"
-#include "power_signals.dtsi"
diff --git a/zephyr/projects/nissa/yaviks/src/charger.c b/zephyr/projects/nissa/yaviks/src/charger.c
deleted file mode 100644
index 9be2e685b0..0000000000
--- a/zephyr/projects/nissa/yaviks/src/charger.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-
-#include "battery.h"
-#include "charger.h"
-#include "console.h"
-#include "driver/charger/sm5803.h"
-#include "extpower.h"
-#include "usb_pd.h"
-#include "nissa_common.h"
-#include "battery_fuel_gauge.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-int extpower_is_present(void)
-{
- int port;
- int rv;
- bool acok;
-
- for (port = 0; port < board_get_usb_pd_port_count(); port++) {
- rv = sm5803_is_acok(port, &acok);
- if ((rv == EC_SUCCESS) && acok)
- return 1;
- }
-
- return 0;
-}
-
-/*
- * Yaviks does not have a GPIO indicating whether extpower is present,
- * so detect using the charger(s).
- */
-__override void board_check_extpower(void)
-{
- static int last_extpower_present;
- int extpower_present = extpower_is_present();
-
- if (last_extpower_present ^ extpower_present)
- extpower_handle_update(extpower_present);
-
- last_extpower_present = extpower_present;
-}
-
-__override void board_hibernate(void)
-{
- /* Shut down the chargers */
- if (board_get_usb_pd_port_count() == 2)
- sm5803_hibernate(CHARGER_SECONDARY);
- sm5803_hibernate(CHARGER_PRIMARY);
- LOG_INF("Charger(s) hibernated");
- cflush();
-}
-
-__override int board_get_default_battery_type(void)
-{
- int type = DEFAULT_BATTERY_TYPE;
- int cells;
-
- if (charger_get_battery_cells(CHARGER_PRIMARY, &cells) == EC_SUCCESS) {
- if (cells == 3)
- type = DEFAULT_BATTERY_TYPE_3S;
- if (cells != 2 && cells != 3)
- LOG_ERR("Unexpected number of cells");
- } else {
- LOG_ERR("Failed to get default battery type");
- }
-
- return type;
-}
diff --git a/zephyr/projects/nissa/yaviks/src/fan.c b/zephyr/projects/nissa/yaviks/src/fan.c
deleted file mode 100644
index 23c3ec1143..0000000000
--- a/zephyr/projects/nissa/yaviks/src/fan.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/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);
-
-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/yaviks/src/keyboard.c b/zephyr/projects/nissa/yaviks/src/keyboard.c
deleted file mode 100644
index 46d6083dbf..0000000000
--- a/zephyr/projects/nissa/yaviks/src/keyboard.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include <zephyr/logging/log.h>
-
-#include "cros_cbi.h"
-#include "ec_commands.h"
-#include "hooks.h"
-#include "keyboard_8042_sharedlib.h"
-#include "keyboard_scan.h"
-#include "timer.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-/* Keyboard scan setting */
-__override struct keyboard_scan_config keyscan_config = {
- /* Increase from 50 us, because KSO_02 passes through the H1. */
- .output_settle_us = 80,
- /* Other values should be the same as the default configuration. */
- .debounce_down_us = 9 * MSEC,
- .debounce_up_us = 30 * MSEC,
- .scan_period_us = 3 * MSEC,
- .min_post_scan_delay_us = 1000,
- .poll_timeout_us = 100 * MSEC,
- .actual_key_mask = {
- 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xa4, 0xff, 0xf6, 0x55, 0xfe, 0xff, 0xff, 0xff, /* full set */
- },
-};
-
-static const struct ec_response_keybd_config yaviks_kb_w_kb_light = {
- .num_top_row_keys = 13,
- .action_keys = {
- TK_BACK, /* T1 */
- TK_REFRESH, /* T2 */
- TK_FULLSCREEN, /* T3 */
- TK_OVERVIEW, /* T4 */
- TK_SNAPSHOT, /* T5 */
- TK_BRIGHTNESS_DOWN, /* T6 */
- TK_BRIGHTNESS_UP, /* T7 */
- TK_KBD_BKLIGHT_TOGGLE, /* T8 */
- TK_PLAY_PAUSE, /* T9 */
- TK_MICMUTE, /* T10 */
- TK_VOL_MUTE, /* T11 */
- TK_VOL_DOWN, /* T12 */
- TK_VOL_UP, /* T13 */
- },
- .capabilities = KEYBD_CAP_NUMERIC_KEYPAD,
-};
-
-static const struct ec_response_keybd_config yaviks_kb_wo_kb_light = {
- .num_top_row_keys = 13,
- .action_keys = {
- TK_BACK, /* T1 */
- TK_REFRESH, /* T2 */
- TK_FULLSCREEN, /* T3 */
- TK_OVERVIEW, /* T4 */
- TK_SNAPSHOT, /* T5 */
- TK_BRIGHTNESS_DOWN, /* T6 */
- TK_BRIGHTNESS_UP, /* T7 */
- TK_PLAY_PAUSE, /* T8 */
- TK_MICMUTE, /* T9 */
- TK_VOL_MUTE, /* T10 */
- TK_VOL_DOWN, /* T11 */
- TK_VOL_UP, /* T12 */
- TK_MENU, /* T13 */
- },
- .capabilities = KEYBD_CAP_NUMERIC_KEYPAD,
-};
-
-__override const struct ec_response_keybd_config *
-board_vivaldi_keybd_config(void)
-{
- uint32_t val;
-
- cros_cbi_get_fw_config(FW_KB_BACKLIGHT, &val);
-
- if (val == FW_KB_BACKLIGHT_OFF)
- return &yaviks_kb_wo_kb_light;
- else
- return &yaviks_kb_w_kb_light;
-}
-
-/*
- * Keyboard layout decided by FW config.
- */
-static void kb_layout_init(void)
-{
- int ret;
- uint32_t val;
-
- ret = cros_cbi_get_fw_config(FW_KB_LAYOUT, &val);
- if (ret != 0) {
- LOG_ERR("Error retrieving CBI FW_CONFIG field %d",
- FW_KB_LAYOUT);
- return;
- }
- /*
- * If keyboard is US2(FW_KB_LAYOUT_US2), we need translate right ctrl
- * to backslash(\|) key.
- */
- if (val == FW_KB_LAYOUT_US2)
- set_scancode_set2(4, 0, get_scancode_set2(2, 7));
-}
-DECLARE_HOOK(HOOK_INIT, kb_layout_init, HOOK_PRIO_POST_FIRST);
diff --git a/zephyr/projects/nissa/yaviks/src/led.c b/zephyr/projects/nissa/yaviks/src/led.c
deleted file mode 100644
index 88a476f1b0..0000000000
--- a/zephyr/projects/nissa/yaviks/src/led.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <stdint.h>
-
-#include "battery.h"
-#include "charge_manager.h"
-#include "charge_state.h"
-#include "chipset.h"
-#include "ec_commands.h"
-#include "gpio.h"
-#include "host_command.h"
-#include "led_common.h"
-#include "hooks.h"
-
-#define BAT_LED_ON 0
-#define BAT_LED_OFF 1
-
-#define BATT_LOW_BCT 10
-
-#define LED_TICKS_PER_CYCLE 4
-#define LED_TICKS_PER_CYCLE_S3 4
-#define LED_ON_TICKS 2
-#define POWER_LED_ON_S3_TICKS 2
-
-const enum ec_led_id supported_led_ids[] = { EC_LED_ID_LEFT_LED,
- EC_LED_ID_RIGHT_LED };
-
-const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-
-enum led_color {
- LED_OFF = 0,
- LED_AMBER,
- LED_WHITE,
- LED_COLOR_COUNT /* Number of colors, not a color itself */
-};
-
-enum led_port { LEFT_PORT = 0, RIGHT_PORT };
-
-static void led_set_color_battery(int port, enum led_color color)
-{
- const struct gpio_dt_spec *amber_led, *white_led;
-
- if (port == LEFT_PORT) {
- amber_led = GPIO_DT_FROM_NODELABEL(gpio_c0_charger_led_amber_l);
- white_led = GPIO_DT_FROM_NODELABEL(gpio_c0_charger_led_white_l);
- } else if (port == RIGHT_PORT) {
- amber_led = GPIO_DT_FROM_NODELABEL(gpio_c1_charger_led_amber_l);
- white_led = GPIO_DT_FROM_NODELABEL(gpio_c1_charger_led_white_l);
- }
-
- switch (color) {
- case LED_WHITE:
- gpio_pin_set_dt(white_led, BAT_LED_ON);
- gpio_pin_set_dt(amber_led, BAT_LED_OFF);
- break;
- case LED_AMBER:
- gpio_pin_set_dt(white_led, BAT_LED_OFF);
- gpio_pin_set_dt(amber_led, BAT_LED_ON);
- break;
- case LED_OFF:
- gpio_pin_set_dt(white_led, BAT_LED_OFF);
- gpio_pin_set_dt(amber_led, BAT_LED_OFF);
- break;
- default:
- break;
- }
-}
-
-void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
-{
- switch (led_id) {
- case EC_LED_ID_LEFT_LED:
- brightness_range[EC_LED_COLOR_WHITE] = 1;
- brightness_range[EC_LED_COLOR_AMBER] = 1;
- break;
- case EC_LED_ID_RIGHT_LED:
- brightness_range[EC_LED_COLOR_WHITE] = 1;
- brightness_range[EC_LED_COLOR_AMBER] = 1;
- break;
- default:
- break;
- }
-}
-
-int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
-{
- switch (led_id) {
- case EC_LED_ID_LEFT_LED:
- if (brightness[EC_LED_COLOR_WHITE] != 0)
- led_set_color_battery(LEFT_PORT, LED_WHITE);
- else if (brightness[EC_LED_COLOR_AMBER] != 0)
- led_set_color_battery(LEFT_PORT, LED_AMBER);
- else
- led_set_color_battery(LEFT_PORT, LED_OFF);
- break;
- case EC_LED_ID_RIGHT_LED:
- if (brightness[EC_LED_COLOR_WHITE] != 0)
- led_set_color_battery(RIGHT_PORT, LED_WHITE);
- else if (brightness[EC_LED_COLOR_AMBER] != 0)
- led_set_color_battery(RIGHT_PORT, LED_AMBER);
- else
- led_set_color_battery(RIGHT_PORT, LED_OFF);
- break;
- default:
- return EC_ERROR_PARAM1;
- }
-
- return EC_SUCCESS;
-}
-
-/*
- * Set active charge port color to the parameter, turn off all others.
- * If no port is active (-1), turn off all LEDs.
- */
-static void set_active_port_color(enum led_color color)
-{
- int port = charge_manager_get_active_charge_port();
-
- if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED))
- led_set_color_battery(RIGHT_PORT,
- (port == RIGHT_PORT) ? color : LED_OFF);
- if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED))
- led_set_color_battery(LEFT_PORT,
- (port == LEFT_PORT) ? color : LED_OFF);
-}
-
-static void led_set_battery(void)
-{
- static unsigned int battery_ticks;
- static int suspend_ticks;
-
- battery_ticks++;
-
- /*
- * Override battery LEDs for Yaviks, Yaviks is non-power LED
- * design, blinking both two side battery white LEDs to indicate
- * system suspend with non-charging state.
- */
- if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) &&
- charge_get_state() != PWR_STATE_CHARGE) {
- suspend_ticks++;
-
- led_set_color_battery(RIGHT_PORT,
- suspend_ticks % LED_TICKS_PER_CYCLE_S3 <
- POWER_LED_ON_S3_TICKS ?
- LED_WHITE :
- LED_OFF);
- led_set_color_battery(LEFT_PORT,
- suspend_ticks % LED_TICKS_PER_CYCLE_S3 <
- POWER_LED_ON_S3_TICKS ?
- LED_WHITE :
- LED_OFF);
- return;
- }
-
- suspend_ticks = 0;
-
- switch (charge_get_state()) {
- case PWR_STATE_CHARGE:
- /* Always indicate when charging, even in suspend. */
- set_active_port_color(LED_AMBER);
- break;
- case PWR_STATE_DISCHARGE:
- /*
- * Blinking amber LEDs slowly if battery is lower 10
- * percentage.
- */
- if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) {
- if (charge_get_percent() < BATT_LOW_BCT)
- led_set_color_battery(
- RIGHT_PORT,
- (battery_ticks % LED_TICKS_PER_CYCLE <
- LED_ON_TICKS) ?
- LED_AMBER :
- LED_OFF);
- else
- led_set_color_battery(RIGHT_PORT, LED_OFF);
- }
-
- if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) {
- if (charge_get_percent() < BATT_LOW_BCT)
- led_set_color_battery(
- LEFT_PORT,
- (battery_ticks % LED_TICKS_PER_CYCLE <
- LED_ON_TICKS) ?
- LED_AMBER :
- LED_OFF);
- else
- led_set_color_battery(LEFT_PORT, LED_OFF);
- }
- break;
- case PWR_STATE_ERROR:
- if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) {
- led_set_color_battery(
- RIGHT_PORT,
- (battery_ticks & 0x1) ? LED_AMBER : LED_OFF);
- }
-
- if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED)) {
- led_set_color_battery(LEFT_PORT, (battery_ticks & 0x1) ?
- LED_AMBER :
- LED_OFF);
- }
- break;
- case PWR_STATE_CHARGE_NEAR_FULL:
- set_active_port_color(LED_WHITE);
- break;
- case PWR_STATE_IDLE: /* External power connected in IDLE */
- set_active_port_color(LED_WHITE);
- break;
- case PWR_STATE_FORCED_IDLE:
- set_active_port_color(
- (battery_ticks % LED_TICKS_PER_CYCLE < LED_ON_TICKS) ?
- LED_AMBER :
- LED_OFF);
- break;
- default:
- /* Other states don't alter LED behavior */
- break;
- }
-}
-
-/* Called by hook task every TICK(IT83xx 500ms) */
-static void led_tick(void)
-{
- led_set_battery();
-}
-DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/projects/nissa/yaviks/src/usbc.c b/zephyr/projects/nissa/yaviks/src/usbc.c
deleted file mode 100644
index 48f7cfd9cb..0000000000
--- a/zephyr/projects/nissa/yaviks/src/usbc.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-#include <ap_power/ap_power.h>
-
-#include "charge_state_v2.h"
-#include "chipset.h"
-#include "hooks.h"
-#include "usb_mux.h"
-#include "system.h"
-#include "driver/charger/sm5803.h"
-#include "driver/tcpm/it83xx_pd.h"
-#include "driver/tcpm/ps8xxx_public.h"
-#include "driver/tcpm/tcpci.h"
-
-#include "nissa_common.h"
-
-LOG_MODULE_DECLARE(nissa, CONFIG_NISSA_LOG_LEVEL);
-
-struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .bus_type = EC_BUS_TYPE_EMBEDDED,
- /* TCPC is embedded within EC so no i2c config needed */
- .drv = &it8xxx2_tcpm_drv,
- /* Alert is active-low, push-pull */
- .flags = 0,
- },
- {
- /*
- * Sub-board: optional PS8745 TCPC+redriver. Behaves the same
- * as PS8815.
- */
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C1_TCPC,
- .addr_flags = PS8XXX_I2C_ADDR1_FLAGS,
- },
- .drv = &ps8xxx_tcpm_drv,
- /* PS8745 implements TCPCI 2.0 */
- .flags = TCPC_FLAGS_TCPCI_REV2_0,
- },
-};
-
-/* Vconn control for integrated ITE TCPC */
-void board_pd_vconn_ctrl(int port, enum usbpd_cc_pin cc_pin, int enabled)
-{
- /* Vconn control is only for port 0 */
- if (port)
- return;
-
- if (cc_pin == USBPD_CC_PIN_1)
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc1_vconn),
- !!enabled);
- else
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_usb_c0_cc2_vconn),
- !!enabled);
-}
-
-__override bool pd_check_vbus_level(int port, enum vbus_level level)
-{
- return sm5803_check_vbus_level(port, level);
-}
-
-/*
- * Putting chargers into LPM when in suspend reduces power draw by about 8mW
- * per charger, but also seems critical to correct operation in source mode:
- * if chargers are not in LPM when a sink is first connected, VBUS sourcing
- * works even if the partner is later removed (causing LPM entry) and
- * reconnected (causing LPM exit). If in LPM initially, sourcing VBUS
- * consistently causes the charger to report (apparently spurious) overcurrent
- * failures.
- *
- * In short, this is important to making things work correctly but we don't
- * understand why.
- */
-static void board_chargers_suspend(struct ap_power_ev_callback *const cb,
- const struct ap_power_ev_data data)
-{
- void (*fn)(int chgnum);
-
- switch (data.event) {
- case AP_POWER_SUSPEND:
- fn = sm5803_enable_low_power_mode;
- break;
- case AP_POWER_RESUME:
- fn = sm5803_disable_low_power_mode;
- break;
- default:
- LOG_WRN("%s: power event %d is not recognized", __func__,
- data.event);
- return;
- }
-
- fn(CHARGER_PRIMARY);
- if (board_get_charger_chip_count() > 1)
- fn(CHARGER_SECONDARY);
-}
-
-static int board_chargers_suspend_init(const struct device *unused)
-{
- static struct ap_power_ev_callback cb = {
- .handler = board_chargers_suspend,
- .events = AP_POWER_SUSPEND | AP_POWER_RESUME,
- };
- ap_power_ev_add_callback(&cb);
- return 0;
-}
-SYS_INIT(board_chargers_suspend_init, APPLICATION, 0);
-
-int board_set_active_charge_port(int port)
-{
- int is_real_port = (port >= 0 && port < board_get_usb_pd_port_count());
- int i;
- int old_port;
- int rv;
-
- if (!is_real_port && port != CHARGE_PORT_NONE)
- return EC_ERROR_INVAL;
-
- old_port = charge_manager_get_active_charge_port();
- LOG_INF("Charge update: p%d -> p%d", old_port, port);
-
- /* Check if port is sourcing VBUS. */
- if (port != CHARGE_PORT_NONE && charger_is_sourcing_otg_power(port)) {
- LOG_WRN("Skip enable p%d: already sourcing", port);
- return EC_ERROR_INVAL;
- }
-
- /* Disable sinking on all ports except the desired one */
- for (i = 0; i < board_get_usb_pd_port_count(); i++) {
- if (i == port)
- continue;
-
- if (sm5803_vbus_sink_enable(i, 0))
- /*
- * Do not early-return because this can fail during
- * power-on which would put us into a loop.
- */
- LOG_WRN("p%d: sink path disable failed.", i);
- }
-
- /* Don't enable anything (stop here) if no ports were requested */
- if ((port == CHARGE_PORT_NONE) || (old_port == port))
- return EC_SUCCESS;
-
- /*
- * Stop the charger IC from switching while changing ports. Otherwise,
- * we can overcurrent the adapter we're switching to. (crbug.com/926056)
- */
- if (old_port != CHARGE_PORT_NONE)
- charger_discharge_on_ac(1);
-
- /* Enable requested charge port. */
- rv = sm5803_vbus_sink_enable(port, 1);
- if (rv)
- LOG_WRN("p%d: sink path enable failed: code %d", port, rv);
-
- /* Allow the charger IC to begin/continue switching. */
- charger_discharge_on_ac(0);
-
- return rv;
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- /*
- * TCPC 0 is embedded in the EC and processes interrupts in the chip
- * code (it83xx/intc.c). This function only needs to poll port C1 if
- * present.
- */
- uint16_t status = 0;
- int regval;
-
- /* Is the C1 port present and its IRQ line asserted? */
- if (board_get_usb_pd_port_count() == 2 &&
- !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
- /*
- * C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if
- * it asserted the IRQ.
- */
- if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
- if (regval)
- status = PD_STATUS_TCPC_ALERT_1;
- }
- }
-
- return status;
-}
-
-void pd_power_supply_reset(int port)
-{
- int prev_en;
-
- if (port < 0 || port >= board_get_usb_pd_port_count())
- return;
-
- prev_en = charger_is_sourcing_otg_power(port);
-
- /* Disable Vbus */
- charger_enable_otg_power(port, 0);
-
- /* Discharge Vbus if previously enabled */
- if (prev_en)
- sm5803_set_vbus_disch(port, 1);
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- enum ec_error_list rv;
-
- if (port < 0 || port > board_get_usb_pd_port_count()) {
- LOG_WRN("Port C%d does not exist, cannot enable VBUS", port);
- return EC_ERROR_INVAL;
- }
-
- /* Disable sinking */
- rv = sm5803_vbus_sink_enable(port, 0);
- if (rv) {
- LOG_WRN("C%d failed to disable sinking: %d", port, rv);
- return rv;
- }
-
- /* Disable Vbus discharge */
- rv = sm5803_set_vbus_disch(port, 0);
- if (rv) {
- LOG_WRN("C%d failed to clear VBUS discharge: %d", port, rv);
- return rv;
- }
-
- /* Provide Vbus */
- rv = charger_enable_otg_power(port, 1);
- if (rv) {
- LOG_WRN("C%d failed to enable VBUS sourcing: %d", port, rv);
- return rv;
- }
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS;
-}
-
-__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- int rv;
- const int current = rp == TYPEC_RP_3A0 ? 3000 : 1500;
-
- rv = charger_set_otg_current_voltage(port, current, 5000);
- if (rv != EC_SUCCESS) {
- LOG_WRN("Failed to set source ilimit on port %d to %d: %d",
- port, current, rv);
- }
-}
-
-void board_reset_pd_mcu(void)
-{
- /*
- * Do nothing. The integrated TCPC for C0 lacks a dedicated reset
- * command, and C1 (if present) doesn't have a reset pin connected
- * to the EC.
- */
-}
-
-#define INT_RECHECK_US 5000
-
-/* C0 interrupt line shared by BC 1.2 and charger */
-
-static void check_c0_line(void);
-DECLARE_DEFERRED(check_c0_line);
-
-static void notify_c0_chips(void)
-{
- usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
- sm5803_interrupt(0);
-}
-
-static void check_c0_line(void)
-{
- /*
- * If line is still being held low, see if there's more to process from
- * one of the chips
- */
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl))) {
- notify_c0_chips();
- hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
- }
-}
-
-void usb_c0_interrupt(enum gpio_signal s)
-{
- /* Cancel any previous calls to check the interrupt line */
- hook_call_deferred(&check_c0_line_data, -1);
-
- /* Notify all chips using this line that an interrupt came in */
- notify_c0_chips();
-
- /* Check the line again in 5ms */
- hook_call_deferred(&check_c0_line_data, INT_RECHECK_US);
-}
-
-/* C1 interrupt line shared by BC 1.2, TCPC, and charger */
-static void check_c1_line(void);
-DECLARE_DEFERRED(check_c1_line);
-
-static void notify_c1_chips(void)
-{
- schedule_deferred_pd_interrupt(1);
- usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
- /* Charger is handled in board_process_pd_alert */
-}
-
-static void check_c1_line(void)
-{
- /*
- * If line is still being held low, see if there's more to process from
- * one of the chips.
- */
- if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
- notify_c1_chips();
- hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
- }
-}
-
-void usb_c1_interrupt(enum gpio_signal s)
-{
- /* Cancel any previous calls to check the interrupt line */
- hook_call_deferred(&check_c1_line_data, -1);
-
- /* Notify all chips using this line that an interrupt came in */
- notify_c1_chips();
-
- /* Check the line again in 5ms */
- hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
-}
-
-/*
- * Check state of IRQ lines at startup, ensuring an IRQ that happened before
- * the EC started up won't get lost (leaving the IRQ line asserted and blocking
- * any further interrupts on the port).
- *
- * Although the PD task will check for pending TCPC interrupts on startup,
- * the charger sharing the IRQ will not be polled automatically.
- */
-void board_handle_initial_typec_irq(void)
-{
- check_c0_line();
- if (board_get_usb_pd_port_count() == 2)
- check_c1_line();
-}
-/*
- * This must run after sub-board detection (which happens in EC main()),
- * but isn't depended on by anything else either.
- */
-DECLARE_HOOK(HOOK_INIT, board_handle_initial_typec_irq, HOOK_PRIO_LAST);
-
-/*
- * Handle charger interrupts in the PD task. Not doing so can lead to a priority
- * inversion where we fail to respond to TCPC alerts quickly enough because we
- * don't get another edge on a shared IRQ until the charger interrupt is cleared
- * (or the IRQ is polled again), which happens in the low-priority charger task:
- * the high-priority type-C handler is thus blocked on the lower-priority
- * charger.
- *
- * To avoid that, we run charger interrupts at the same priority.
- */
-void board_process_pd_alert(int port)
-{
- /*
- * Port 0 doesn't use an external TCPC, so its interrupts don't need
- * this special handling.
- */
- if (port == 1 &&
- !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
- sm5803_handle_interrupt(port);
- }
-}
-
-int pd_snk_is_vbus_provided(int port)
-{
- int chg_det = 0;
-
- sm5803_get_chg_det(port, &chg_det);
-
- return chg_det;
-}
diff --git a/zephyr/projects/npcx_evb/npcx7/keyboard.dts b/zephyr/projects/npcx_evb/npcx7/keyboard.dts
deleted file mode 100644
index 3fb6986f1a..0000000000
--- a/zephyr/projects/npcx_evb/npcx7/keyboard.dts
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- cros-keyscan {
- compatible = "cros-keyscan";
-
- output-settle = <40>;
- debounce-down = <6000>;
- scan-period = <1500>;
- poll-timeout = <1000000>;
-
- actual-key-mask = <
- 0x14 /* C0 */
- 0xff /* C1 */
- 0xff /* C2 */
- 0xff /* C3 */
- 0xff /* C4 */
- 0xf5 /* C5 */
- 0xff /* C6 */
- 0xa4 /* C7 */
- 0xff /* C8 */
- 0xf6 /* C9 */
- 0x55 /* C10 */
- 0xfa /* C11 */
- 0xc8 /* C12 */
- >;
- };
-
- kblight {
- compatible = "cros-ec,kblight-pwm";
- pwms = <&pwm2 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>;
- };
-};
-
-&pwm2 {
- status = "okay";
- pinctrl-0 = <&pwm2_gpc4>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/npcx_evb/npcx7/prj.conf b/zephyr/projects/npcx_evb/npcx7/prj.conf
deleted file mode 100644
index 5f1fc03f88..0000000000
--- a/zephyr/projects/npcx_evb/npcx7/prj.conf
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-CONFIG_PLATFORM_EC_BRINGUP=y
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-CONFIG_SHIMMED_TASKS=y
-
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-CONFIG_PLATFORM_EC_SWITCH=n
-CONFIG_PLATFORM_EC_VBOOT_EFS2=n
-CONFIG_PLATFORM_EC_VSTORE=n
-
-# Board version is selected over GPIO board ID pins.
-CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y
-
-# PWM
-CONFIG_PWM=y
-
-# Sensors
-CONFIG_SENSOR=y
-CONFIG_SENSOR_SHELL=n
-
-# Console command
-CONFIG_PLATFORM_EC_CONSOLE_CMD_SCRATCHPAD=y
-
-CONFIG_TRACING=y
-CONFIG_TRACING_ISR=y
-CONFIG_TRACING_USER=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_IRQ=y
-
-# eSPI
-CONFIG_ESPI=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
-
-# Keyboard
-CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y
-
-# RTC
-CONFIG_PLATFORM_EC_RTC=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y
-
-# USB-C
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
-CONFIG_PLATFORM_EC_USB_PD_USB4=n
-
-# Zephyr feature
-CONFIG_ASSERT=y
-CONFIG_SHELL_MINIMAL=n
-CONFIG_LOG=y
-
-# Avoid underflow info from tachometer
-CONFIG_SENSOR_LOG_LEVEL_ERR=y
-
-CONFIG_SYSCON=y
diff --git a/zephyr/projects/npcx_evb/npcx9/keyboard.dts b/zephyr/projects/npcx_evb/npcx9/keyboard.dts
deleted file mode 100644
index 3fb6986f1a..0000000000
--- a/zephyr/projects/npcx_evb/npcx9/keyboard.dts
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- cros-keyscan {
- compatible = "cros-keyscan";
-
- output-settle = <40>;
- debounce-down = <6000>;
- scan-period = <1500>;
- poll-timeout = <1000000>;
-
- actual-key-mask = <
- 0x14 /* C0 */
- 0xff /* C1 */
- 0xff /* C2 */
- 0xff /* C3 */
- 0xff /* C4 */
- 0xf5 /* C5 */
- 0xff /* C6 */
- 0xa4 /* C7 */
- 0xff /* C8 */
- 0xf6 /* C9 */
- 0x55 /* C10 */
- 0xfa /* C11 */
- 0xc8 /* C12 */
- >;
- };
-
- kblight {
- compatible = "cros-ec,kblight-pwm";
- pwms = <&pwm2 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>;
- };
-};
-
-&pwm2 {
- status = "okay";
- pinctrl-0 = <&pwm2_gpc4>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/npcx_evb/npcx9/prj.conf b/zephyr/projects/npcx_evb/npcx9/prj.conf
deleted file mode 100644
index 827b6366c6..0000000000
--- a/zephyr/projects/npcx_evb/npcx9/prj.conf
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-CONFIG_PLATFORM_EC_BRINGUP=y
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-CONFIG_SHIMMED_TASKS=y
-
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-CONFIG_PLATFORM_EC_SWITCH=n
-CONFIG_PLATFORM_EC_VBOOT_EFS2=n
-CONFIG_PLATFORM_EC_VSTORE=n
-
-# Workaround npcx9 A1 chip's bug for download_from_flash API in th booter.
-# This can be removed when A2 chip is available.
-CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y
-
-# Board version is selected over GPIO board ID pins.
-CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y
-
-# PWM
-CONFIG_PWM=y
-
-# Sensors
-CONFIG_SENSOR=y
-CONFIG_SENSOR_SHELL=n
-
-# Console command
-CONFIG_PLATFORM_EC_CONSOLE_CMD_SCRATCHPAD=y
-
-CONFIG_TRACING=y
-CONFIG_TRACING_ISR=y
-CONFIG_TRACING_USER=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_IRQ=y
-
-# eSPI
-CONFIG_ESPI=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
-
-# Keyboard
-CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y
-
-# RTC
-CONFIG_PLATFORM_EC_RTC=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y
-
-# USB-C
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
-CONFIG_PLATFORM_EC_USB_PD_USB4=n
-
-# Zephyr feature
-CONFIG_ASSERT=y
-CONFIG_SHELL_MINIMAL=n
-CONFIG_LOG=y
-
-# Avoid underflow info from tachometer
-CONFIG_SENSOR_LOG_LEVEL_ERR=y
-
-CONFIG_SYSCON=y
diff --git a/zephyr/projects/rex/led.dts b/zephyr/projects/rex/led.dts
deleted file mode 100644
index 94acb6da5c..0000000000
--- a/zephyr/projects/rex/led.dts
+++ /dev/null
@@ -1,138 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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: color-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&gpio_led_1_l 1>,
- <&gpio_led_2_l 1>;
- };
-
- color_white: color-white {
- led-color = "LED_WHITE";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_WHITE";
- led-pins = <&gpio_led_1_l 1>,
- <&gpio_led_2_l 0>;
- };
-
- color_amber: color-amber {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&gpio_led_1_l 0>,
- <&gpio_led_2_l 1>;
- };
- };
-
- led-colors {
- compatible = "cros-ec,led-policy";
-
- power-state-charge {
- charge-state = "PWR_STATE_CHARGE";
-
- color-0 {
- led-color = <&color_amber>;
- };
- };
-
- power-state-discharge-s0 {
- charge-state = "PWR_STATE_DISCHARGE";
- chipset-state = "POWER_S0";
-
- color-0 {
- led-color = <&color_off>;
- };
- };
-
- power-state-discharge-s3 {
- charge-state = "PWR_STATE_DISCHARGE";
- chipset-state = "POWER_S3";
-
- /* Blue 1 sec, off 3 sec */
- color-0 {
- led-color = <&color_white>;
- period-ms = <1000>;
- };
- color-1 {
- led-color = <&color_off>;
- period-ms = <3000>;
- };
- };
-
- power-state-discharge-s5 {
- charge-state = "PWR_STATE_DISCHARGE";
- chipset-state = "POWER_S5";
-
- color-0 {
- led-color = <&color_off>;
- };
- };
-
- power-state-error {
- charge-state = "PWR_STATE_ERROR";
-
- /* Red 1 sec, off 1 sec */
- color-0 {
- led-color = <&color_white>;
- period-ms = <1000>;
- };
- color-1 {
- led-color = <&color_off>;
- period-ms = <1000>;
- };
- };
-
- power-state-near-full {
- charge-state = "PWR_STATE_CHARGE_NEAR_FULL";
-
- color-0 {
- led-color = <&color_amber>;
- };
- };
-
- power-state-forced-idle {
- charge-state = "PWR_STATE_FORCED_IDLE";
-
- /* White 2 sec, Amber 2 sec */
- color-0 {
- led-color = <&color_white>;
- period-ms = <2000>;
- };
- color-1 {
- led-color = <&color_amber>;
- period-ms = <2000>;
- };
- };
-
- power-state-idle-default {
- charge-state = "PWR_STATE_IDLE";
-
- color-0 {
- led-color = <&color_white>;
- };
- };
- };
-};
-
-&gpio_led_1_l {
- #led-pin-cells = <1>;
-};
-
-&gpio_led_2_l {
- #led-pin-cells = <1>;
-};
-
-&gpio_led_3_l {
- #led-pin-cells = <1>;
-};
-
-&gpio_led_4_l {
- #led-pin-cells = <1>;
-};
diff --git a/zephyr/projects/rex/power_signals.dts b/zephyr/projects/rex/power_signals.dts
deleted file mode 100644
index 860c316795..0000000000
--- a/zephyr/projects/rex/power_signals.dts
+++ /dev/null
@@ -1,152 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- chosen {
- intel-ap-pwrseq,espi = &espi0;
- };
-
- common-pwrseq {
- compatible = "intel,ap-pwrseq";
-
- sys-pwrok-delay = <3>;
- all-sys-pwrgd-timeout = <20>;
- };
-
- pwr-en-pp3300-s5 {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "PP1800_S5/PP3300_S5 enable output to LS";
- enum-name = "PWR_EN_PP3300_A";
- gpios = <&gpiob 6 GPIO_ACTIVE_HIGH>;
- output;
- };
- pwr-pg-ec-rsmrst-od {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "RSMRST power good from regulator";
- enum-name = "PWR_RSMRST";
- gpios = <&gpioe 2 GPIO_ACTIVE_HIGH>;
- interrupt-flags = <GPIO_INT_EDGE_BOTH>;
- };
- pwr-ec-pch-rsmrst-odl {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "RSMRST output to PCH";
- enum-name = "PWR_EC_PCH_RSMRST";
- gpios = <&gpioa 6 GPIO_ACTIVE_HIGH>;
- output;
- };
- pwr-pch-pwrok {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "PCH_PWROK output to PCH";
- enum-name = "PWR_PCH_PWROK";
- gpios = <&gpioa 5 GPIO_ACTIVE_HIGH>;
- output;
- };
- pwr-ec-pch-sys-pwrok {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "SYS_PWROK output to PCH";
- enum-name = "PWR_EC_PCH_SYS_PWROK";
- gpios = <&gpiob 0 GPIO_ACTIVE_HIGH>;
- output;
- };
- pwr-sys-rst-l {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "SYS_RESET# output to PCH";
- enum-name = "PWR_SYS_RST";
- gpios = <&gpioc 5 (GPIO_ACTIVE_LOW | GPIO_OPEN_DRAIN)>;
- output;
- };
- pwr-slp-s0-l {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "SLP_S0_L input from PCH";
- enum-name = "PWR_SLP_S0";
- gpios = <&gpiod 5 GPIO_ACTIVE_LOW>;
- interrupt-flags = <GPIO_INT_EDGE_BOTH>;
- };
- pwr-slp-s3-l {
- compatible = "intel,ap-pwrseq-vw";
- dbg-label = "SLP_S3_L input from PCH";
- enum-name = "PWR_SLP_S3";
- virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4";
- vw-invert;
-/*
- * TODO: Initially, use virtual wire for sleep S3 signal instead of
- * of the GPIO signal which also exists.
- * compatible = "intel,ap-pwrseq-gpio";
- * gpios = <&gpio4 1 GPIO_ACTIVE_LOW>;
- * interrupt-flags = <GPIO_INT_EDGE_BOTH>;
- */
- };
- pwr-slp-s4 {
- compatible = "intel,ap-pwrseq-vw";
- dbg-label = "SLP_S4 virtual wire input from PCH";
- enum-name = "PWR_SLP_S4";
- virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4";
- vw-invert;
- };
- pwr-slp-s5 {
- compatible = "intel,ap-pwrseq-vw";
- dbg-label = "SLP_S5 virtual wire input from PCH";
- enum-name = "PWR_SLP_S5";
- virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5";
- vw-invert;
- };
- pwr-all-sys-pwrgd {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "all power good";
- enum-name = "PWR_ALL_SYS_PWRGD";
- gpios = <&gpiof 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
- interrupt-flags = <GPIO_INT_EDGE_BOTH>;
- };
-};
-
-/*
- * Because the power signals directly reference the GPIOs,
- * the corresponding named-gpios need to have no-auto-init set.
- */
- /* pwr-en-pp3300-s5 */
-&gpio_en_s5_rails {
- no-auto-init;
-};
-
-/* pwr-pg-ec-rsmrst-od */
-&gpio_seq_ec_rsmrst_odl{
- no-auto-init;
-};
-
-/* pwr-ec-pch-rsmrst-odl */
-&gpio_ec_soc_rsmrst_l{
- no-auto-init;
-};
-
-/* pwr-pch-pwrok */
-&gpio_soc_pwrok{
- no-auto-init;
-};
-
-/* pwr-ec-pch-sys-pwrok */
-&gpio_sys_pwrok{
- no-auto-init;
-};
-
-/* pwr-sys-rst-l */
-&gpio_sys_rst_odl{
- no-auto-init;
-};
-
-/* pwr-slp-s0-l */
-&gpio_sys_slp_s0ix_3v3_l{
- no-auto-init;
-};
-
-/* pwr-slp-s3-l */
-&gpio_slp_s3_ls_l{
- no-auto-init;
-};
-
-/* pwr-all-sys-pwrgd */
-&gpio_seq_ec_all_sys_pg{
- no-auto-init;
-};
-
diff --git a/zephyr/projects/rex/prj.conf b/zephyr/projects/rex/prj.conf
deleted file mode 100644
index 7dcb2894da..0000000000
--- a/zephyr/projects/rex/prj.conf
+++ /dev/null
@@ -1,180 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_PLATFORM_EC=y
-CONFIG_CROS_EC=y
-CONFIG_SHIMMED_TASKS=y
-CONFIG_SYSCON=y
-# Enable during development
-CONFIG_LTO=n
-CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
-CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y
-
-# Shell Commands
-CONFIG_SHELL_HELP=y
-CONFIG_SHELL_HISTORY=y
-CONFIG_SHELL_TAB=y
-CONFIG_SHELL_TAB_AUTOCOMPLETION=y
-CONFIG_KERNEL_SHELL=y
-
-# Logging
-CONFIG_LOG=y
-CONFIG_LOG_MODE_MINIMAL=y
-
-# Disable default features we don't want in a minimal example.
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=y
-CONFIG_PLATFORM_EC_SWITCH=y
-CONFIG_PLATFORM_EC_VBOOT_EFS2=y
-
-# Application processor; communicates with EC via eSPI
-CONFIG_AP=y
-CONFIG_ESPI=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S3=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y
-CONFIG_PLATFORM_EC_HOSTCMD=y
-# Disabling this until temp sensor support is in
-CONFIG_PLATFORM_EC_THROTTLE_AP=n
-CONFIG_PLATFORM_EC_PORT80=y
-
-# Power Sequecing
-CONFIG_AP_X86_INTEL_MTL=y
-CONFIG_X86_NON_DSX_PWRSEQ_MTL=y
-CONFIG_X86_NON_DSX_PWRSEQ_HOST_CMD=y
-# TODO (b/240434243): This may be needed, but using eSPI VW for now
-CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE=n
-CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
-
-# Zephyr Inbuilt AP Power Sequencing Config
-CONFIG_AP_PWRSEQ=y
-CONFIG_X86_NON_DSX_PWRSEQ_CONSOLE=y
-CONFIG_AP_PWRSEQ_S0IX=y
-
-# ADC
-CONFIG_ADC=y
-
-# I2C
-CONFIG_I2C=y
-CONFIG_PLATFORM_EC_HOSTCMD_I2C_CONTROL=y
-
-# PWM
-CONFIG_PWM=y
-
-# Fan
-CONFIG_TACH_NPCX=y
-
-# Temperature sensors
-CONFIG_SENSOR=y
-CONFIG_PLATFORM_EC_TEMP_SENSOR=y
-CONFIG_PLATFORM_EC_THERMISTOR=y
-CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y
-
-# CBI EEPROM support
-CONFIG_EEPROM=y
-CONFIG_EEPROM_AT24=y
-CONFIG_EEPROM_SHELL=n
-CONFIG_PLATFORM_EC_CBI_EEPROM=y
-CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
-CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_DT=y
-
-# Battery
-CONFIG_PLATFORM_EC_BATTERY=y
-CONFIG_PLATFORM_EC_BATTERY_SMART=y
-CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
-CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
-CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
-CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
-
-# Charger
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
-CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT=512
-CONFIG_PLATFORM_EC_CHARGER_ISL9241=y
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=5
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10
-CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=30000
-CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT=15000
-
-# USB-A
-CONFIG_PLATFORM_EC_USBA=y
-
-# USBC
-CONFIG_PLATFORM_EC_USBC_PPC=y
-CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y
-CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y
-CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y
-CONFIG_PLATFORM_EC_USBC_PPC_SYV682X_SMART_DISCHARGE=y
-CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_HB=y
-CONFIG_PLATFORM_EC_USBC_VCONN=y
-
-CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_FRS=y
-CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_REV30=y
-CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815=y
-CONFIG_PLATFORM_EC_USB_PD_TRY_SRC=y
-CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=y
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=y
-CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=y
-CONFIG_PLATFORM_EC_USB_PD_USB4=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
-CONFIG_PLATFORM_EC_USB_PID=0x504D
-
-# IOEX
-CONFIG_GPIO_NCT38XX=y
-
-# BC 1.2
-CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
-
-#USB Mux
-CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
-CONFIG_PLATFORM_EC_USB_MUX_TASK=y
-
-# External power
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-
-# Standard shimmed features
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-
-# Keyboard support
-CONFIG_PLATFORM_EC_KEYBOARD=y
-CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y
-# Column 2 is driven through the GSC, which inverts the signal going through it
-CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
-
-# MKBP event
-CONFIG_PLATFORM_EC_MKBP_EVENT=y
-CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
-CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT=y
-
-# Sensors console command
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=y
-
-# Sensors
-CONFIG_SENSOR=y
-CONFIG_SENSOR_SHELL=n
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y
-CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
-CONFIG_PLATFORM_EC_LID_ANGLE=y
-CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
-CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
-CONFIG_PLATFORM_EC_TABLET_MODE=y
-CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
-
-# Sensor Drivers
-CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=y
-CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
-CONFIG_PLATFORM_EC_ALS_TCS3400=y
diff --git a/zephyr/projects/rex/prj_rex.conf b/zephyr/projects/rex/prj_rex.conf
deleted file mode 100644
index 0f204b9669..0000000000
--- a/zephyr/projects/rex/prj_rex.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Rex reference-board-specific Kconfig settings.
-CONFIG_BOARD_REX=y
-
-# Keyboard
-CONFIG_CROS_KB_RAW_NPCX=y
diff --git a/zephyr/projects/rex/rex.dts b/zephyr/projects/rex/rex.dts
deleted file mode 100644
index 0db4b96aa7..0000000000
--- a/zephyr/projects/rex/rex.dts
+++ /dev/null
@@ -1,262 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
- #include <dt-bindings/usb_pd_tcpm.h>
-
-/ {
- aliases {
- gpio-wp = &ec_wp_l;
- gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- ec_wp_l: write-protect {
- gpios = <&gpioa 0 GPIO_INPUT>;
- };
- gpio_ec_entering_rw: ec_entering_rw {
- enum-name = "GPIO_ENTERING_RW";
- };
-
- ioex_usb_c0_sbu_fault_odl: usb_c0_sbu_fault_odl {
- gpios = <&ioex_c0_port1 2 GPIO_INPUT>;
- };
- ioex_usb_c0_rt_rst_ls_l: usb_c0_rt_rst_ls_l {
- gpios = <&ioex_c0_port0 7 GPIO_OUTPUT>;
- };
-
- ioex_usb_c0_frs_en: usb_c0_frs_en {
- gpios = <&ioex_c0_port0 6 GPIO_OUTPUT_LOW>;
- };
-
- /* Need to designate 1.8V for I2C buses on the 1800mV rail */
- ec-i2c-sensor-scl {
- gpios = <&gpiob 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec-i2c-sensor-sda {
- gpios = <&gpiob 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec-i2c-c0-rt-scl {
- gpios = <&gpiod 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec-i2c-c0-rt-sda {
- gpios = <&gpiod 0 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- };
-
- usba-port-enable-list {
- compatible = "cros-ec,usba-port-enable-pins";
- enable-pins = <&gpio_en_pp5000_usba_r>;
- };
-};
-
-/* host interface */
-&espi0 {
- status = "okay";
- pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
- pinctrl-names = "default";
-};
-
-/* Power switch logic input pads */
-&psl_in1_gpd2 {
- /* LID_OPEN */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in2_gp00 {
- /* ACOK_OD */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in4_gp02 {
- /* MECH_PWR_BTN_ODL */
- psl-in-mode = "edge";
- psl-in-pol = "low-falling";
-};
-
-/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
-&power_ctrl_psl {
- status = "okay";
- pinctrl-names = "sleep";
- pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in3_gp01 &psl_in4_gp02>;
-};
-
-/* ADC and GPIO alt-function specifications */
-&adc0 {
- pinctrl-0 = <&adc0_chan0_gp45
- &adc0_chan1_gp44
- &adc0_chan8_gpf1
- &adc0_chan7_gpe1>;
- pinctrl-names = "default";
-};
-
-&i2c0_0 {
- label = "I2C_SENSOR";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
- pinctrl-names = "default";
-};
-
-&i2c1_0 {
- label = "I2C_USB_C0_TCPC";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
- pinctrl-names = "default";
-
- tcpc_port0: nct38xx@70 {
- compatible = "nuvoton,nct38xx";
- gpio-dev = <&nct3807_C0>;
- reg = <0x70>;
- tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
- };
-
- nct3807_C0:nct3807_C0@70 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "nuvoton,nct38xx-gpio";
- reg = <0x70>;
- label = "NCT3807_C0";
-
- ioex_c0_port0:gpio@0 {
- compatible = "nuvoton,nct38xx-gpio-port";
- reg = <0x0>;
- label = "NCT3807_C0_GPIO0";
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <8>;
- pin_mask = <0xff>;
- pinmux_mask = <0xf7>;
- };
- ioex_c0_port1:gpio@1 {
- compatible = "nuvoton,nct38xx-gpio-port";
- reg = <0x1>;
- label = "NCT3807_C0_GPIO1";
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <8>;
- pin_mask = <0xff>;
- };
- };
-
- nct3808_alert_0 {
- compatible = "nuvoton,nct38xx-gpio-alert";
- irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>;
- nct38xx-dev = <&nct3807_C0>;
- label = "NCT3807_ALERT_0";
- };
-};
-
-&i2c2_0 {
- label = "I2C_PPC0";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>;
- pinctrl-names = "default";
-
- bc12_port0: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- irq = <&int_usb_c0_bc12>;
- };
-
- ppc_port0_syv: ppc_syv@40 {
- compatible = "silergy,syv682x";
- status = "okay";
- reg = <0x40>;
- frs_en_gpio = <&ioex_usb_c0_frs_en>;
- };
-};
-
-&i2c3_0 {
- label = "I2C_USB_C0_RT";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
- pinctrl-names = "default";
-
- usb_c0_hb_retimer: jhl8040r-c0@56 {
- compatible = "intel,jhl8040r";
- reg = <0x56>;
- ls-en-pin = <&gpio_usb_c0_rt_3p3_sx_en>;
- int-pin = <&gpio_usb_c0_rt_int_odl>;
- reset-pin = <&ioex_usb_c0_rt_rst_ls_l>;
- };
-};
-
-&i2c4_1 {
- label = "I2_USB_C1_TCPC";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>;
- pinctrl-names = "default";
-
- tcpc_port1: ps8xxx@b {
- compatible = "parade,ps8xxx";
- reg = <0xb>;
- tcpc-flags = <(
- TCPC_FLAGS_TCPCI_REV2_0 |
- TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V |
- TCPC_FLAGS_CONTROL_VCONN |
- TCPC_FLAGS_CONTROL_FRS)>;
- };
-};
-
-&i2c5_0 {
- label = "I2C__BATTERY";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-
- pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>;
- pinctrl-names = "default";
-};
-
-&i2c6_1 {
- label = "I2C_USB_1_MIX";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>;
- pinctrl-names = "default";
-
- bc12_port1: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- irq = <&int_usb_c1_bc12>;
- };
-
- ppc_port1_nxp: nx20p348x@72 {
- compatible = "nxp,nx20p348x";
- status = "okay";
- reg = <0x72>;
- };
-};
-
-&i2c7_0 {
- label = "I2C_CHARGER";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
- pinctrl-names = "default";
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
-
- charger: isl9241@9 {
- compatible = "intersil,isl9241";
- status = "okay";
- reg = <0x09>;
- };
-};
diff --git a/zephyr/projects/rex/src/board_power.c b/zephyr/projects/rex/src/board_power.c
deleted file mode 100644
index c7f12d024e..0000000000
--- a/zephyr/projects/rex/src/board_power.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/logging/log.h>
-#include <zephyr/drivers/gpio.h>
-
-#include <ap_power/ap_power.h>
-#include <ap_power/ap_power_events.h>
-#include <ap_power/ap_power_interface.h>
-#include <ap_power_override_functions.h>
-#include <power_signals.h>
-#include <x86_power_signals.h>
-
-#include "gpio_signal.h"
-#include "gpio/gpio.h"
-
-LOG_MODULE_DECLARE(ap_pwrseq, LOG_LEVEL_INF);
-
-#if CONFIG_X86_NON_DSX_PWRSEQ_MTL
-#define X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS 50
-
-void board_ap_power_force_shutdown(void)
-{
- int timeout_ms = X86_NON_DSX_MTL_FORCE_SHUTDOWN_TO_MS;
-
- /* Turn off PCH_RMSRST to meet tPCH12 */
- power_signal_set(PWR_EC_PCH_RSMRST, 0);
-
- /* Turn off PRIM load switch. */
- power_signal_set(PWR_EN_PP3300_A, 0);
-
- /* Wait RSMRST to be off. */
- while (power_signal_get(PWR_RSMRST) && (timeout_ms > 0)) {
- k_msleep(1);
- timeout_ms--;
- };
-
- if (power_signal_get(PWR_RSMRST)) {
- LOG_WRN("RSMRST_ODL didn't go low! Assuming G3.");
- }
-}
-
-void board_ap_power_action_g3_s5(void)
-{
- /* Turn on the PP3300_PRIM rail. */
- power_signal_set(PWR_EN_PP3300_A, 1);
-
- if (!power_wait_signals_timeout(
- IN_PGOOD_ALL_CORE,
- AP_PWRSEQ_DT_VALUE(wait_signal_timeout))) {
- ap_power_ev_send_callbacks(AP_POWER_PRE_INIT);
- }
-}
-
-bool board_ap_power_check_power_rails_enabled(void)
-{
- return power_signal_get(PWR_EN_PP3300_A);
-}
-#endif /* CONFIG_X86_NON_DSX_PWRSEQ_MTL */
diff --git a/zephyr/projects/rex/src/usb_pd_policy.c b/zephyr/projects/rex/src/usb_pd_policy.c
deleted file mode 100644
index 7e9876f9c1..0000000000
--- a/zephyr/projects/rex/src/usb_pd_policy.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Shared USB-C policy for Rex boards */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "charge_manager.h"
-#include "chipset.h"
-#include "common.h"
-#include "compile_time_macros.h"
-#include "console.h"
-#include "ec_commands.h"
-#include "ioexpander.h"
-#include "system.h"
-#include "usb_mux.h"
-#include "usb_pd.h"
-#include "usbc_ppc.h"
-#include "util.h"
-
-int pd_check_vconn_swap(int port)
-{
- /* Allow VCONN swaps if the AP is on. */
- return chipset_in_state(CHIPSET_STATE_ANY_SUSPEND | CHIPSET_STATE_ON);
-}
-
-void pd_power_supply_reset(int port)
-{
- /* Disable VBUS. */
- ppc_vbus_source_enable(port, 0);
-
- /* Enable discharge if we were previously sourcing 5V */
- if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE))
- pd_set_vbus_discharge(port, 1);
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- int rv;
-
- /* Disable charging. */
- rv = ppc_vbus_sink_enable(port, 0);
- if (rv)
- return rv;
-
- if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE)) {
- pd_set_vbus_discharge(port, 0);
- }
-
- /* Provide Vbus. */
- rv = ppc_vbus_source_enable(port, 1);
- if (rv) {
- return rv;
- }
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS;
-}
-
-/* Used by Vbus discharge common code with CONFIG_USB_PD_DISCHARGE */
-int board_vbus_source_enabled(int port)
-{
- return tcpm_get_src_ctrl(port);
-}
-
-/* Used by USB charger task with CONFIG_USB_PD_5V_EN_CUSTOM */
-int board_is_sourcing_vbus(int port)
-{
- return board_vbus_source_enabled(port);
-}
diff --git a/zephyr/projects/rex/src/usbc_config.c b/zephyr/projects/rex/src/usbc_config.c
deleted file mode 100644
index 66f3a1f45d..0000000000
--- a/zephyr/projects/rex/src/usbc_config.c
+++ /dev/null
@@ -1,300 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "battery_fuel_gauge.h"
-#include "charger.h"
-#include "charge_manager.h"
-#include "charge_ramp.h"
-#include "charge_state_v2.h"
-#include "charge_state.h"
-#include "charger.h"
-#include "driver/charger/isl9241.h"
-#include "driver/retimer/bb_retimer_public.h"
-#include "driver/tcpm/nct38xx.h"
-#include "driver/tcpm/ps8xxx_public.h"
-#include "driver/tcpm/tcpci.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "ioexpander.h"
-#include "driver/ppc/nx20p348x.h"
-#include "ppc/syv682x_public.h"
-#include "system.h"
-#include "task.h"
-#include "usb_mux.h"
-#include "usbc_ppc.h"
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-/*******************************************************************/
-/* USB-C Configuration Start */
-
-/* USB-C ports */
-enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
-BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT);
-
-static void usbc_interrupt_init(void)
-{
- /* Only reset TCPC if not sysjump */
- if (!system_jumped_late()) {
- board_reset_pd_mcu();
- }
-
- /* Enable PPC interrupts. */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc));
-
- /* Enable TCPC interrupts. */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc));
-
- /* Enable BC 1.2 interrupts */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_bc12));
-
- /* Enable SBU fault interrupts */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_sbu_fault));
-}
-DECLARE_HOOK(HOOK_INIT, usbc_interrupt_init, HOOK_PRIO_POST_I2C);
-
-void board_overcurrent_event(int port, int is_overcurrented)
-{
- /*
- * TODO: Meteorlake PCH does not use Physical GPIO for over current
- * error, hence Send 'Over Current Virtual Wire' eSPI signal.
- */
-}
-
-void sbu_fault_interrupt(enum gpio_signal signal)
-{
- int port = USBC_PORT_C0;
-
- CPRINTSUSB("C%d: SBU fault", port);
- pd_handle_overcurrent(port);
-}
-
-void tcpc_alert_event(enum gpio_signal signal)
-{
- int port;
-
- switch (signal) {
- case GPIO_USB_C0_TCPC_INT_ODL:
- port = 0;
- break;
- case GPIO_USB_C1_TCPC_INT_ODL:
- port = 1;
- break;
- default:
- return;
- }
-
- schedule_deferred_pd_interrupt(port);
-}
-
-static void reset_nct38xx_port(int port)
-{
- const struct gpio_dt_spec *reset_gpio_l;
- const struct device *ioex_port0, *ioex_port1;
-
- /* TODO(b/225189538): Save and restore ioex signals */
- if (port == USBC_PORT_C0) {
- reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_odl);
- ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port0));
- ioex_port1 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port1));
- } else {
- /* Invalid port: do nothing */
- return;
- }
-
- gpio_pin_set_dt(reset_gpio_l, 0);
- msleep(NCT38XX_RESET_HOLD_DELAY_MS);
- gpio_pin_set_dt(reset_gpio_l, 1);
- nct38xx_reset_notify(port);
- if (NCT3807_RESET_POST_DELAY_MS != 0) {
- msleep(NCT3807_RESET_POST_DELAY_MS);
- }
-
- /* Re-enable the IO expander pins */
- gpio_reset_port(ioex_port0);
- gpio_reset_port(ioex_port1);
-}
-
-void board_reset_pd_mcu(void)
-{
- /* Reset TCPC0 */
- reset_nct38xx_port(USBC_PORT_C0);
-
- /* Reset TCPC1 */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl), 0);
- msleep(PS8XXX_RESET_DELAY_MS);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl), 1);
- msleep(PS8815_FW_INIT_DELAY_MS);
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
- const struct gpio_dt_spec *tcpc_c0_rst_l;
- const struct gpio_dt_spec *tcpc_c0_int_l;
- const struct gpio_dt_spec *tcpc_c1_rst_l;
- const struct gpio_dt_spec *tcpc_c1_int_l;
-
- tcpc_c0_rst_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_odl);
- tcpc_c0_int_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl);
-
- tcpc_c1_rst_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_rt_rst_r_odl);
- tcpc_c1_int_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl);
-
- /*
- * Check which port has the ALERT line set and ignore if that TCPC has
- * its reset line active.
- */
- if (!gpio_pin_get_dt(tcpc_c0_int_l) && gpio_pin_get_dt(tcpc_c0_rst_l)) {
- status |= PD_STATUS_TCPC_ALERT_0;
- }
-
- if (!gpio_pin_get_dt(tcpc_c1_int_l) && gpio_pin_get_dt(tcpc_c1_rst_l)) {
- status |= PD_STATUS_TCPC_ALERT_1;
- }
-
- return status;
-}
-
-void ppc_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_USB_C0_PPC_INT_ODL:
- syv682x_interrupt(USBC_PORT_C0);
- break;
- case GPIO_USB_C1_PPC_INT_ODL:
- nx20p348x_interrupt(USBC_PORT_C1);
- break;
- default:
- break;
- }
-}
-
-void bc12_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_USB_C0_BC12_INT_ODL:
- usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
- break;
- case GPIO_USB_C1_BC12_INT_ODL:
- usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
- break;
- default:
- break;
- }
-}
-
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
-static void board_disable_charger_ports(void)
-{
- int i;
-
- CPRINTSUSB("Disabling all charger ports");
-
- /* Disable all ports. */
- for (i = 0; i < ppc_cnt; i++) {
- /*
- * If this port had booted in dead battery mode, go
- * ahead and reset it so EN_SNK responds properly.
- */
- if (nct38xx_get_boot_type(i) == NCT38XX_BOOT_DEAD_BATTERY) {
- reset_nct38xx_port(i);
- pd_set_error_recovery(i);
- }
-
- /*
- * Do not return early if one fails otherwise we can
- * get into a boot loop assertion failure.
- */
- if (ppc_vbus_sink_enable(i, 0)) {
- CPRINTSUSB("Disabling C%d as sink failed.", i);
- }
- }
-}
-
-int board_set_active_charge_port(int port)
-{
- int is_valid_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
- int i;
- int rv;
-
- if (port == CHARGE_PORT_NONE) {
- board_disable_charger_ports();
- return EC_SUCCESS;
- } else if (!is_valid_port) {
- return EC_ERROR_INVAL;
- }
-
- /*
- * Check if we can reset any ports in dead battery mode
- *
- * The NCT3807 may continue to keep EN_SNK low on the dead battery port
- * and allow a dangerous level of voltage to pass through to the initial
- * charge port (see b/183660105). We must reset the ports if we have
- * sufficient battery to do so, which will bring EN_SNK back under
- * normal control.
- */
- rv = EC_SUCCESS;
- if (port == USBC_PORT_C0 &&
- nct38xx_get_boot_type(port) == NCT38XX_BOOT_DEAD_BATTERY) {
- /* Handle dead battery boot case */
- CPRINTSUSB("Found dead battery on C0");
- /*
- * If we have battery, get this port reset ASAP.
- * This means temporarily rejecting charge manager
- * sets to it.
- */
- if (pd_is_battery_capable()) {
- reset_nct38xx_port(port);
- pd_set_error_recovery(port);
- }
- }
-
- if (rv != EC_SUCCESS) {
- return rv;
- }
-
- /* Check if the port is sourcing VBUS. */
- if (tcpm_get_src_ctrl(port)) {
- CPRINTSUSB("Skip enable C%d", port);
- return EC_ERROR_INVAL;
- }
-
- CPRINTSUSB("New charge port: C%d", port);
-
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < ppc_cnt; i++) {
- if (i == port) {
- continue;
- }
- if (ppc_vbus_sink_enable(i, 0)) {
- CPRINTSUSB("C%d: sink path disable failed.", i);
- }
- }
-
- /* Enable requested charge port. */
- if (ppc_vbus_sink_enable(port, 1)) {
- CPRINTSUSB("C%d: sink path enable failed.", port);
- return EC_ERROR_UNKNOWN;
- }
-
- return EC_SUCCESS;
-}
diff --git a/zephyr/projects/skyrim/BUILD.py b/zephyr/projects/skyrim/BUILD.py
deleted file mode 100644
index 3807150af9..0000000000
--- a/zephyr/projects/skyrim/BUILD.py
+++ /dev/null
@@ -1,86 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Define zmake projects for skyrim."""
-
-
-def register_skyrim_project(
- project_name,
- extra_dts_overlays=(),
- extra_kconfig_files=(),
-):
- """Register a variant of skyrim."""
- register_npcx_project(
- project_name=project_name,
- zephyr_board="npcx9m3f",
- dts_overlays=[
- # Common to all projects.
- here / "adc.dts",
- here / "fan.dts",
- here / "gpio.dts",
- here / "interrupts.dts",
- here / "keyboard.dts",
- here / "motionsense.dts",
- here / "usbc.dts",
- # Project-specific DTS customizations.
- *extra_dts_overlays,
- ],
- kconfig_files=[here / "prj.conf", *extra_kconfig_files],
- )
-
-
-register_skyrim_project(
- project_name="morthal",
- extra_dts_overlays=[
- here / "morthal.dts",
- here / "battery_morthal.dts",
- here / "led_pins_morthal.dts",
- here / "led_policy_morthal.dts",
- ],
- extra_kconfig_files=[
- here / "prj_morthal.conf",
- ],
-)
-
-
-register_skyrim_project(
- project_name="skyrim",
- extra_dts_overlays=[
- here / "skyrim.dts",
- here / "battery_skyrim.dts",
- here / "led_pins_skyrim.dts",
- here / "led_policy_skyrim.dts",
- ],
- extra_kconfig_files=[
- here / "prj_skyrim.conf",
- ],
-)
-
-
-register_skyrim_project(
- project_name="winterhold",
- extra_dts_overlays=[
- here / "winterhold.dts",
- here / "battery_winterhold.dts",
- here / "led_pins_winterhold.dts",
- here / "led_policy_winterhold.dts",
- ],
- extra_kconfig_files=[
- here / "prj_winterhold.conf",
- ],
-)
-
-
-register_skyrim_project(
- project_name="frostflow",
- extra_dts_overlays=[
- here / "frostflow.dts",
- here / "battery_frostflow.dts",
- here / "led_pins_frostflow.dts",
- here / "led_policy_frostflow.dts",
- ],
- extra_kconfig_files=[
- here / "prj_frostflow.conf",
- ],
-)
diff --git a/zephyr/projects/skyrim/CMakeLists.txt b/zephyr/projects/skyrim/CMakeLists.txt
deleted file mode 100644
index 71b8427aa1..0000000000
--- a/zephyr/projects/skyrim/CMakeLists.txt
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
-
-zephyr_library_sources("src/common.c")
-zephyr_library_sources("src/power_signals.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "src/usb_pd_policy.c"
- "src/usbc_config.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON
- "src/led.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_AMD_STT
- "src/stt.c")
-
-if(DEFINED CONFIG_BOARD_MORTHAL)
- project(morthal)
- zephyr_library_sources(
- "src/morthal/ppc_config.c"
- "src/morthal/usb_mux_config.c"
-)
-endif()
-
-if(DEFINED CONFIG_BOARD_SKYRIM)
- project(skyrim)
- cros_ec_library_include_directories_ifdef(CONFIG_BOARD_SKYRIM include)
- zephyr_library_sources(
- "src/skyrim/usb_mux_config.c"
- "src/skyrim/ppc_config.c"
- "src/skyrim/form_factor.c"
- "src/skyrim/alt_charger.c"
- "src/skyrim/keyboard.c"
- )
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/skyrim/fan.c")
-endif()
-
-if(DEFINED CONFIG_BOARD_WINTERHOLD)
- project(winterhold)
- zephyr_library_sources(
- "src/winterhold/usb_mux_config.c"
- "src/winterhold/ppc_config.c"
- "src/winterhold/kb_backlight.c"
- "src/winterhold/keyboard.c"
- )
-endif()
-
-if(DEFINED CONFIG_BOARD_FROSTFLOW)
- project(frostflow)
- cros_ec_library_include_directories_ifdef(CONFIG_BOARD_FROSTFLOW include)
- zephyr_include_directories("include/frostflow")
- zephyr_library_sources(
- "src/frostflow/usb_mux_config.c"
- "src/frostflow/ppc_config.c"
- )
- zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION
- "src/frostflow/keyboard.c"
- "src/frostflow/keyboard_customization.c")
-endif()
diff --git a/zephyr/projects/skyrim/Kconfig b/zephyr/projects/skyrim/Kconfig
deleted file mode 100644
index fbb797f6fc..0000000000
--- a/zephyr/projects/skyrim/Kconfig
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-config BOARD_MORTHAL
- bool "Google Morthal Board"
- help
- Build Google Morthal reference board. This board uses an AMD SoC
- and NPCX9 EC
-
-config BOARD_SKYRIM
- bool "Google Skyrim Board"
- help
- Build Google Skyrim reference board. This board uses an AMD SoC
- and NPCX9 EC
-
-config BOARD_WINTERHOLD
- bool "Google Winterhold Board"
- help
- Build Google Winterhold reference board. This board uses an AMD SoC
- and NPCX9 EC
-
-config BOARD_FROSTFLOW
- bool "Google Frostflow Board"
- help
- Build Google Frostflow reference board. This board uses an AMD SoC
- and NPCX9 EC
-
-config BOARD_INPUT_CURRENT_SCALE_FACTOR
- int "Input current scale factor"
- default 100
- help
- Limit input current to fraction of negotiated limit.
-
-config BOARD_USB_HUB_RESET
- bool "Support USB hub reset or not"
- default y
- help
- Enable this if your board has a USB hub reset GPIO connect to EC to
- reset the USB hub.
-
-module = SKYRIM
-module-str = Skyrim board-specific code
-source "subsys/logging/Kconfig.template.log_config"
-
-source "Kconfig.zephyr"
diff --git a/zephyr/projects/skyrim/adc.dts b/zephyr/projects/skyrim/adc.dts
deleted file mode 100644
index 0f2ffd6436..0000000000
--- a/zephyr/projects/skyrim/adc.dts
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * 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-adc-channels {
- compatible = "named-adc-channels";
-
- adc_temp_charger: temp-charger {
- enum-name = "ADC_TEMP_SENSOR_CHARGER";
- io-channels = <&adc0 1>;
- };
- adc_temp_memory: temp-memory {
- enum-name = "ADC_TEMP_SENSOR_MEMORY";
- io-channels = <&adc0 2>;
- };
- adc_core_imon1: core-imon1 {
- enum-name = "ADC_CORE_IMON1";
- io-channels = <&adc0 3>;
- };
- adc_core_imon2: core-imon2 {
- enum-name = "ADC_SOC_IMON2";
- io-channels = <&adc0 4>;
- };
- };
-
- temp_charger_thermistor: charger-thermistor {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_30K9_47K_4050B>;
- adc = <&adc_temp_charger>;
- };
-
- temp_memory_thermistor: memory-thermistor {
- compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_3V3_30K9_47K_4050B>;
- adc = <&adc_temp_memory>;
- };
-
- named-temp-sensors {
- compatible = "cros-ec,temp-sensors";
- charger-thermistor {
- temp_host_high = <100>;
- temp_host_halt = <105>;
- temp_host_release_high = <80>;
- sensor = <&temp_charger_thermistor>;
- };
-
- memory-thermistor {
- temp_host_high = <100>;
- temp_host_halt = <105>;
- temp_host_release_high = <80>;
- power-good-pin = <&gpio_pg_pwr_s5>;
- sensor = <&temp_memory_thermistor>;
- };
-
- cpu {
- temp_host_high = <100>;
- temp_host_halt = <105>;
- temp_host_release_high = <80>;
- temp_fan_off = <60>;
- temp_fan_max = <90>;
- power-good-pin = <&gpio_s0_pgood>;
- sensor = <&temp_cpu>;
- };
- };
-};
-
-&adc0 {
- status = "okay";
- pinctrl-0 = <&adc0_chan1_gp44
- &adc0_chan2_gp43
- &adc0_chan3_gp42
- &adc0_chan4_gp41>;
- pinctrl-names = "default";
-};
-
-&thermistor_3V3_30K9_47K_4050B {
- status = "okay";
-};
diff --git a/zephyr/projects/skyrim/battery_winterhold.dts b/zephyr/projects/skyrim/battery_winterhold.dts
deleted file mode 100644
index d923243d45..0000000000
--- a/zephyr/projects/skyrim/battery_winterhold.dts
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- batteries {
- default_battery: lgc_xphx8 {
- compatible = "lgc,xphx8", "battery-smart";
- };
- smp_atlxdy9k {
- compatible = "smp,atlxdy9k", "battery-smart";
- };
- smp_cosxdy9k{
- compatible = "smp,cosxdy9k", "battery-smart";
- };
- byd_wv3k8{
- compatible = "byd,wv3k8", "battery-smart";
- };
- cosmx_mvk11{
- compatible = "cosmx,mvk11", "battery-smart";
- };
- sunwoda_atlvkyjx{
- compatible = "sunwoda,atlvkyjx", "battery-smart";
- };
- sunwoda_cosvkyjx{
- compatible = "sunwoda,cosvkyjx", "battery-smart";
- };
- atl_cfd72{
- compatible = "atl,cfd72", "battery-smart";
- };
- };
-};
diff --git a/zephyr/projects/skyrim/fan.dts b/zephyr/projects/skyrim/fan.dts
deleted file mode 100644
index f0bc28cb7e..0000000000
--- a/zephyr/projects/skyrim/fan.dts
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- fans {
- compatible = "cros-ec,fans";
-
- fan_0 {
- pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>;
- rpm_min = <3100>;
- rpm_start = <3100>;
- rpm_max = <8000>;
- tach = <&tach1>;
- pgood_gpio = <&gpio_s0_pgood>;
- };
- };
-};
-
-/* Tachemeter for fan speed measurement */
-&tach1 {
- status = "okay";
- pinctrl-0 = <&ta1_1_in_gp40>;
- pinctrl-names = "default";
- 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 */
-};
-
-&pwm0_gpc3 {
- drive-open-drain;
-};
-
-&pwm0 {
- status = "okay";
- pinctrl-0 = <&pwm0_gpc3>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/skyrim/frostflow.dts b/zephyr/projects/skyrim/frostflow.dts
deleted file mode 100644
index 1ed0b4cb2b..0000000000
--- a/zephyr/projects/skyrim/frostflow.dts
+++ /dev/null
@@ -1,136 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <dt-bindings/usbc_mux.h>
-
-#include "i2c_common.dtsi"
-
-/ {
- named-gpios {
- /* Frostflow-specific GPIO customizations */
- };
-
- named-temp-sensors {
- compatible = "cros-ec,temp-sensors";
- soc-pct2075 {
- temp_host_high = <100>;
- temp_host_halt = <105>;
- temp_host_release_high = <80>;
- temp_host_release_halt = <80>;
- temp_fan_off = <35>;
- temp_fan_max = <70>;
- power-good-pin = <&gpio_pg_pwr_s5>;
- sensor = <&soc_pct2075>;
- };
- amb-pct2075 {
- power-good-pin = <&gpio_pg_pwr_s5>;
- sensor = <&amb_pct2075>;
- };
- };
-
- /* Rotation matrices for motion sensors. */
- motionsense-rotation-ref {
- compatible = "cros-ec,motionsense-rotation-ref";
- lid_rot_ref: lid-rotation-ref {
- mat33 = <1 0 0
- 0 1 0
- 0 0 1>;
- };
-
- base_rot_ref: base-rotation-ref {
- mat33 = <0 1 0
- 1 0 0
- 0 0 (-1)>;
- };
- };
-
- ppc_port0: aoz1380 {
- compatible = "aoz,aoz1380";
- status = "okay";
- };
-};
-
-&i2c0_0 {
- anx7483_port0: anx7483@3e {
- compatible = "analogix,anx7483";
- reg = <0x3e>;
- board-set = "board_anx7483_c0_mux_set";
- };
-};
-
-&i2c1_0 {
- anx7483_port1: anx7483@3e {
- compatible = "analogix,anx7483";
- reg = <0x3e>;
- board-set = "board_anx7483_c1_mux_set";
- };
- ppc_port1: nx20p348x@71 {
- compatible = "nxp,nx20p348x";
- status = "okay";
- reg = <0x71>;
- };
- ps8818_port1: ps8818@28 {
- compatible = "parade,ps8818";
- reg = <0x28>;
- flags = <(USB_MUX_FLAG_RESETS_IN_G3)>;
- board-set = "board_c1_ps8818_mux_set";
- };
-};
-
-&i2c4_1 {
- charger: isl9241@9 {
- compatible = "intersil,isl9241";
- status = "okay";
- reg = <0x9>;
- };
-};
-
-&usbc_port0 {
- ppc = <&ppc_port0>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&amd_fp6_port0 &anx7483_port0>;
- };
-};
-
-&usbc_port1 {
- ppc = <&ppc_port1>;
- usb-mux-chain-1-anx {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&amd_fp6_port1 &anx7483_port1>;
- };
- usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&amd_fp6_port1 &ps8818_port1>;
- alternative-chain;
- };
-};
-
-&cros_kb_raw {
- pinctrl-0 = <
- &ksi0_gp31
- &ksi1_gp30
- &ksi2_gp27
- &ksi3_gp26
- &ksi4_gp25
- &ksi5_gp24
- &ksi6_gp23
- &ksi7_gp22
- &kso00_gp21
- &kso01_gp20
- &kso03_gp16
- &kso04_gp15
- &kso05_gp14
- &kso06_gp13
- &kso07_gp12
- &kso08_gp11
- &kso09_gp10
- &kso10_gp07
- &kso11_gp06
- &kso12_gp05
- &kso13_gp04
- &kso14_gp82
- >;
-};
diff --git a/zephyr/projects/skyrim/gpio.dts b/zephyr/projects/skyrim/gpio.dts
deleted file mode 100644
index 57abcc846d..0000000000
--- a/zephyr/projects/skyrim/gpio.dts
+++ /dev/null
@@ -1,370 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- aliases {
- gpio-wp = &gpio_wp;
- gpio-cbi-wp = &gpio_cbi_wp;
- gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
- };
-
- /* GPIOs shared by all boards */
- named-gpios {
- compatible = "named-gpios";
-
- ccd_mode_odl {
- gpios = <&gpioc 6 GPIO_ODR_HIGH>;
- };
- ec_gsc_packet_mode {
- gpios = <&gpiob 1 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_PACKET_MODE_EN";
- };
- gpio_mech_pwr_btn_odl: mech_pwr_btn_odl {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- };
- gpio_slp_s3_l: slp_s3_l {
- gpios = <&gpio6 1 GPIO_INPUT>;
- enum-name = "GPIO_PCH_SLP_S3_L";
- alias = "GPIO_PCH_SLP_S0_L";
- };
- gpio_slp_s5_l: slp_s5_l {
- gpios = <&gpio7 2 GPIO_INPUT>;
- enum-name = "GPIO_PCH_SLP_S5_L";
- };
- gpio_pg_pwr_s5: pg_pwr_s5 {
- gpios = <&gpioc 0 GPIO_INPUT>;
- enum-name = "GPIO_S5_PGOOD";
- };
- gpio_s0_pgood: pg_pcore_s0_r_od {
- gpios = <&gpiob 6 GPIO_INPUT>;
- enum-name = "GPIO_S0_PGOOD";
- };
- gpio_acok_od: acok_od {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- };
- gpio_en_pwr_s5: en_pwr_s5 {
- gpios = <&gpiob 7 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_EN_PWR_A";
- };
- gpio_en_pwr_s0_r: en_pwr_s0_r {
- gpios = <&gpiof 1 GPIO_OUTPUT_LOW>;
- };
- gpio_en_pwr_pcore_s0_r: en_pwr_pcore_s0_r {
- gpios = <&gpioe 1 GPIO_OUTPUT_LOW>;
- };
- ec_sys_rst_l {
- gpios = <&gpio7 6 GPIO_ODR_HIGH>;
- enum-name = "GPIO_SYS_RESET_L";
- };
- gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l {
- gpios = <&gpioc 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_PCH_RSMRST_L";
- };
- gpio_ec_pch_wake_odl: ec_soc_wake_l {
- gpios = <&gpio0 3 GPIO_OUTPUT_HIGH>;
- };
- prochot_odl {
- gpios = <&gpiod 5 GPIO_ODR_HIGH>;
- enum-name = "GPIO_CPU_PROCHOT";
- };
- soc_alert_ec_l {
- gpios = <&gpioe 2 GPIO_INPUT>;
- };
- gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_TCPC_INT_ODL";
- };
- gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl {
- gpios = <&gpioc 7 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_TCPC_INT_ODL";
- };
- gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl {
- gpios = <&gpio7 5 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PPC_INT_ODL";
- };
- gpio_usb_c1_ppc_int_odl: usb_c1_ppc_int_odl {
- gpios = <&gpiod 4 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_PPC_INT_ODL";
- };
- gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl {
- gpios = <&gpioa 4 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_USB_C0_BC12_INT_ODL";
- };
- gpio_usb_c1_bc12_int_odl: usb_c1_bc12_int_odl {
- gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_USB_C1_BC12_INT_ODL";
- };
- gpio_usb_c0_tcpc_rst_l: usb_c0_tcpc_rst_l {
- gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>;
- enum-name = "GPIO_USB_C0_TCPC_RST_L";
- };
- gpio_usb_c1_tcpc_rst_l: usb_c1_tcpc_rst_l {
- gpios = <&gpio3 7 GPIO_OUTPUT_HIGH>;
- enum-name = "GPIO_USB_C1_TCPC_RST_L";
- };
- usb_c0_hpd {
- gpios = <&gpiof 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_USB_C0_DP_HPD";
- };
- usb_c1_hpd {
- gpios = <&gpiof 4 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_USB_C1_DP_HPD";
- };
- gpio_lid_open: lid_open {
- gpios = <&gpio0 2 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- };
- ec_batt_pres_odl {
- gpios = <&gpio9 4 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- };
- gpio_ec_disable_disp_bl: ec_disable_disp_bl {
- gpios = <&gpioa 6 GPIO_OUTPUT_HIGH>;
- enum-name = "GPIO_ENABLE_BACKLIGHT_L";
- };
- gpio_usb_fault_odl: usb_fault_odl {
- gpios = <&gpio5 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>;
- };
- gpio_en_pwr_s3: en_pwr_s3 {
- gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
- };
- gpio_pg_groupc_s0_od: pg_groupc_s0_od {
- gpios = <&gpiof 0 GPIO_INPUT>;
- };
- gpio_ec_i2c_usbc_pd_int: ec_i2c_usbc_pd_int {
- gpios = <&gpioa 3 GPIO_INPUT>;
- };
- gpio_soc_thermtrip_odl: soc_thermtrip_odl {
- gpios = <&gpio9 5 GPIO_INPUT>;
- };
- gpio_hub_rst: hub_rst {
- gpios = <&gpio6 6 GPIO_OUTPUT_HIGH>;
- };
- ec_soc_int_l {
- gpios = <&gpioa 1 GPIO_OUTPUT_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- };
- gpio_ec_soc_pwr_good: ec_soc_pwr_good {
- gpios = <&gpiod 3 GPIO_OUTPUT_LOW>;
- };
- gpio_pcore_ocp_r_l: pcore_ocp_r_l {
- gpios = <&gpioa 5 GPIO_INPUT>;
- };
- gpio_usb_hub_fault_q_odl: usb_hub_fault_q_odl {
- gpios = <&gpioe 5 GPIO_INPUT_PULL_UP>;
- };
- gpio_pg_lpddr5_s3_od: pg_lpddr5_s3_od {
- gpios = <&gpio7 3 GPIO_INPUT>;
- };
- 3axis_int_l {
- gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>;
- };
- gpio_ec_soc_pwr_btn_l: ec_soc_pwr_btn_l {
- gpios = <&gpioa 7 GPIO_OUTPUT_HIGH>;
- enum-name = "GPIO_PCH_PWRBTN_L";
- };
- gpio_volup_btn_odl: volup_btn_odl {
- gpios = <&gpio6 7 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_UP_L";
- };
- gpio_voldn_btn_odl: voldn_btn_odl {
- gpios = <&gpio7 0 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- };
- ec_sc_rst {
- gpios = <&gpiob 0 GPIO_OUTPUT_LOW>;
- };
- gpio_cbi_wp: ec_cbi_wp {
- gpios = <&gpio8 1 GPIO_OUTPUT_LOW>;
- };
- gpio_wp: ec_wp_l {
- gpios = <&gpiod 7 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
- };
- gpio_pg_lpddr5_s0_od: pg_lpddr5_s0_od {
- gpios = <&gpio6 0 GPIO_INPUT>;
- };
- ec_espi_rst_l {
- gpios = <&gpio5 4 GPIO_PULL_DOWN>;
- };
- gpio_accel_gyro_int_l: accel_gyro_int_l {
- gpios = <&gpioa 0 GPIO_INPUT>;
- };
- /* unimplemented GPIOs */
- entering-rw {
- enum-name = "GPIO_ENTERING_RW";
- };
- pch-sys-prwok {
- enum-name = "GPIO_PCH_SYS_PWROK";
- };
- ec_i2c_usb_a0_c0_scl {
- gpios = <&gpiob 5 GPIO_INPUT>;
- };
- ec_i2c_usb_a0_c0_sda {
- gpios = <&gpiob 4 GPIO_INPUT>;
- };
- ec_i2c_usb_a1_c1_scl {
- gpios = <&gpio9 0 GPIO_INPUT>;
- };
- ec_i2c_usb_a1_c1_sda {
- gpios = <&gpio8 7 GPIO_INPUT>;
- };
- ec_i2c_batt_scl {
- gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec_i2c_batt_sda {
- gpios = <&gpio9 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec_i2c_usbc_mux_scl {
- gpios = <&gpiod 1 GPIO_INPUT>;
- };
- ec_i2c_usbc_mux_sda {
- gpios = <&gpiod 0 GPIO_INPUT>;
- };
- ec_i2c_power_scl {
- gpios = <&gpiof 3 GPIO_INPUT>;
- };
- ec_i2c_power_sda {
- gpios = <&gpiof 2 GPIO_INPUT>;
- };
- ec_i2c_cbi_scl {
- gpios = <&gpio3 3 GPIO_INPUT>;
- };
- ec_i2c_cbi_sda {
- gpios = <&gpio3 6 GPIO_INPUT>;
- };
- ec_i2c_sensor_scl {
- gpios = <&gpioe 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec_i2c_sensor_sda {
- gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec_i2c_soc_sic {
- gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec_i2c_soc_sid {
- gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- en_kb_bl {
- gpios = <&gpio9 7 GPIO_OUTPUT_HIGH>;
- enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT";
- };
- gpio_ec_kso_02_inv: ec_kso_02_inv {
- gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
- };
- tablet_mode_l {
- gpios = <&gpioc 1 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- };
- ec_gpio56 {
- gpios = <&gpio5 6 GPIO_INPUT_PULL_UP>;
- };
- ec_flprg2 {
- gpios = <&gpio8 6 GPIO_INPUT_PULL_UP>;
- };
-
- usb_c0_tcpc_fastsw_ctl_en {
- gpios = <&ioex_c0_port0 4 GPIO_OUTPUT_LOW>;
- enum-name = "IOEX_USB_C0_TCPC_FASTSW_CTL_EN";
- };
- usb_c0_ppc_en_l {
- gpios = <&ioex_c0_port1 0 GPIO_OUTPUT_LOW>;
- };
- ioex_usb_c0_ilim_3a_en: usb_c0_ppc_ilim_3a_en {
- gpios = <&ioex_c0_port1 1 GPIO_OUTPUT_LOW>;
- enum-name = "IOEX_USB_C0_PPC_ILIM_3A_EN";
- };
- ioex_usb_c0_sbu_fault_odl: usb_c0_sbu_fault_odl {
- gpios = <&ioex_c0_port1 2 GPIO_INPUT>;
- };
- ioex_en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus {
- gpios = <&ioex_c0_port1 5 GPIO_OUTPUT_LOW>;
- };
- ioex_usb_a0_fault_odl: usb_a0_fault_odl {
- gpios = <&ioex_c0_port1 6 GPIO_INPUT>;
- };
- ioex_usb_c0_sbu_flip: usb_c0_sbu_flip {
- gpios = <&ioex_c0_port1 7 GPIO_OUTPUT_LOW>;
- enum-name = "IOEX_USB_C0_SBU_FLIP";
- };
-
- usb_a1_retimer_en {
- gpios = <&ioex_c1_port0 0 GPIO_OUTPUT_LOW>;
- enum-name = "IOEX_USB_A1_RETIMER_EN";
- };
- usb_a1_retimer_rst {
- gpios = <&ioex_c1_port0 1 GPIO_OUTPUT_LOW>;
- };
- usb_c1_in_hpd {
- gpios = <&ioex_c1_port0 3 GPIO_OUTPUT_LOW>;
- enum-name = "IOEX_USB_C1_HPD_IN_DB";
- };
- usb_c1_tcpc_fastsw_ctl_en {
- gpios = <&ioex_c1_port0 4 GPIO_OUTPUT_LOW>;
- enum-name = "IOEX_USB_C1_TCPC_FASTSW_CTL_EN";
- };
- usb_c1_ppc_en_l {
- gpios = <&ioex_c1_port1 0 GPIO_OUTPUT_LOW>;
- };
- usb_c1_ppc_ilim_3a_en {
- gpios = <&ioex_c1_port1 1 GPIO_OUTPUT_LOW>;
- enum-name = "IOEX_USB_C1_PPC_ILIM_3A_EN";
- };
- ioex_usb_c1_sbu_fault_odl: usb_c1_sbu_fault_odl {
- gpios = <&ioex_c1_port1 2 GPIO_INPUT>;
- enum-name = "IOEX_USB_C1_FAULT_ODL";
- };
- ioex_en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus {
- gpios = <&ioex_c1_port1 5 GPIO_OUTPUT_LOW>;
- };
- ioex_usb_a1_fault_db_odl: usb_a1_fault_db_odl {
- gpios = <&ioex_c1_port1 6 GPIO_INPUT>;
- };
- ioex_usb_c1_sbu_flip: usb_c1_sbu_flip {
- gpios = <&ioex_c1_port1 7 GPIO_OUTPUT_LOW>;
- enum-name = "IOEX_USB_C1_SBU_FLIP";
- };
- };
-
- usba-port-enable-list {
- compatible = "cros-ec,usba-port-enable-pins";
- enable-pins = <&ioex_en_pp5000_usb_a0_vbus
- &ioex_en_pp5000_usb_a1_vbus>;
- };
-};
-
-/* PSL input pads*/
-&psl_in1_gpd2 {
- /* MECH_PWR_BTN_ODL */
- psl-in-mode = "edge";
- psl-in-pol = "low-falling";
-};
-
-&psl_in2_gp00 {
- /* ACOK_OD */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-&psl_in4_gp02 {
- /* LID_OPEN */
- psl-in-mode = "edge";
- psl-in-pol = "high-rising";
-};
-
-/* Power domain device controlled by PSL (Power Switch Logic) IO pads */
-&power_ctrl_psl {
- status = "okay";
- pinctrl-names = "sleep";
- pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in4_gp02>;
-};
-
-/* host interface */
-&espi0 {
- status = "okay";
- pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/skyrim/i2c_common.dtsi b/zephyr/projects/skyrim/i2c_common.dtsi
deleted file mode 100644
index aaf54a161b..0000000000
--- a/zephyr/projects/skyrim/i2c_common.dtsi
+++ /dev/null
@@ -1,294 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
- #include <dt-bindings/usb_pd_tcpm.h>
-
-/ {
- 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-7 = &i2c7_0;
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- i2c_tcpc0: tcpc0 {
- i2c-port = <&i2c0_0>;
- enum-names = "I2C_PORT_TCPC0";
- };
-
- i2c_tcpc1: tcpc1 {
- i2c-port = <&i2c1_0>;
- enum-names = "I2C_PORT_TCPC1";
- };
-
- battery {
- i2c-port = <&i2c2_0>;
- remote-port = <0>;
- enum-names = "I2C_PORT_BATTERY";
- };
-
- usb-mux {
- i2c-port = <&i2c3_0>;
- enum-names = "I2C_PORT_USB_MUX";
- };
-
- i2c_charger: charger {
- i2c-port = <&i2c4_1>;
- enum-names = "I2C_PORT_CHARGER";
- };
-
- eeprom {
- i2c-port = <&i2c5_0>;
- enum-names = "I2C_PORT_EEPROM";
- };
-
- i2c_sensor: sensor {
- i2c-port = <&i2c6_1>;
- enum-names = "I2C_PORT_SENSOR";
- };
-
- i2c_soc_thermal: soc-thermal {
- i2c-port = <&i2c7_0>;
- enum-names = "I2C_PORT_THERMAL_AP";
- };
- };
-
-
-};
-
-&i2c0_0 {
- status = "okay";
- label = "I2C_TCPC0";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>;
- pinctrl-names = "default";
-
- bc12_port0: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- irq = <&int_usb_c0_bc12>;
- };
-
- tcpc_port0: nct38xx@70 {
- compatible = "nuvoton,nct38xx";
- reg = <0x70>;
- gpio-dev = <&nct3807_C0>;
- tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
- };
-
- nct3807_C0:nct3807_C0@70 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "nuvoton,nct38xx-gpio";
- reg = <0x70>;
- label = "NCT3807_C0";
-
- ioex_c0_port0:gpio@0 {
- compatible = "nuvoton,nct38xx-gpio-port";
- reg = <0x0>;
- label = "NCT3807_C0_GPIO0";
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <8>;
- pin_mask = <0xff>;
- pinmux_mask = <0xf7>;
- };
- ioex_c0_port1:gpio@1 {
- compatible = "nuvoton,nct38xx-gpio-port";
- reg = <0x1>;
- label = "NCT3807_C0_GPIO1";
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <8>;
- pin_mask = <0xff>;
- };
- };
-
- nct3808_alert_0 {
- compatible = "nuvoton,nct38xx-gpio-alert";
- irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>;
- nct38xx-dev = <&nct3807_C0>;
- label = "NCT3807_ALERT_0";
- };
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c1_0 {
- status = "okay";
- label = "I2C_TCPC1";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>;
- pinctrl-names = "default";
-
- bc12_port1: pi3usb9201@5f {
- compatible = "pericom,pi3usb9201";
- status = "okay";
- reg = <0x5f>;
- irq = <&int_usb_c1_bc12>;
- };
-
- tcpc_port1: nct38xx@70 {
- compatible = "nuvoton,nct38xx";
- reg = <0x70>;
- gpio-dev = <&nct3807_C1>;
- tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>;
- };
-
- nct3807_C1:nct3807_C1@70 {
- #address-cells = <1>;
- #size-cells = <0>;
- compatible = "nuvoton,nct38xx-gpio";
- reg = <0x70>;
- label = "NCT3807_C1";
-
- ioex_c1_port0:gpio@0 {
- compatible = "nuvoton,nct38xx-gpio-port";
- reg = <0x0>;
- label = "NCT3807_C1_GPIO0";
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <8>;
- pin_mask = <0xff>;
- pinmux_mask = <0xf7>;
- };
- ioex_c1_port1:gpio@1 {
- compatible = "nuvoton,nct38xx-gpio-port";
- reg = <0x1>;
- label = "NCT3807_C1_GPIO1";
- gpio-controller;
- #gpio-cells = <2>;
- ngpios = <8>;
- pin_mask = <0xff>;
- };
- };
-
- nct3808_alert_1 {
- compatible = "nuvoton,nct38xx-gpio-alert";
- irq-gpios = <&gpioc 7 GPIO_ACTIVE_LOW>;
- nct38xx-dev = <&nct3807_C1>;
- label = "NCT3807_ALERT_1";
- };
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c2_0 {
- status = "okay";
- label = "I2C_BATTERY";
- clock-frequency = <I2C_BITRATE_STANDARD>;
- pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>;
- pinctrl-names = "default";
-};
-
-&i2c_ctrl2 {
- status = "okay";
-};
-
-&i2c3_0 {
- status = "okay";
- label = "I2C_USB_MUX";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>;
- pinctrl-names = "default";
-
- amd_fp6_port0: amd_fp6@5c {
- compatible = "amd,usbc-mux-amd-fp6";
- status = "okay";
- reg = <0x5c>;
- };
- amd_fp6_port1: amd_fp6@52 {
- compatible = "amd,usbc-mux-amd-fp6";
- status = "okay";
- reg = <0x52>;
- };
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&i2c4_1 {
- status = "okay";
- label = "I2C_CHARGER";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>;
- pinctrl-names = "default";
-};
-
-&i2c_ctrl4 {
- status = "okay";
-};
-
-&i2c5_0 {
- status = "okay";
- label = "I2C_EEPROM";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>;
- pinctrl-names = "default";
-
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- };
-};
-
-&i2c_ctrl5 {
- status = "okay";
-};
-
-&i2c6_1 {
- status = "okay";
- label = "I2C_SENSOR";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>;
- pinctrl-names = "default";
-
- soc_pct2075: soc-pct2075@48 {
- compatible = "nxp,pct2075";
- reg = <0x48>;
- };
-
- amb_pct2075: amb-pct2075@4f {
- compatible = "nxp,pct2075";
- reg = <0x4f>;
- };
-};
-
-&i2c_ctrl6 {
- status = "okay";
-};
-
-&i2c7_0 {
- status = "okay";
- label = "I2C_THERMAL_AP";
- clock-frequency = <I2C_BITRATE_FAST>;
- pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>;
- pinctrl-names = "default";
-
- temp_cpu: cpu@4c {
- compatible = "amd,sb-tsi";
- reg = <0x4c>;
- };
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
diff --git a/zephyr/projects/skyrim/keyboard.dts b/zephyr/projects/skyrim/keyboard.dts
deleted file mode 100644
index df334ba54c..0000000000
--- a/zephyr/projects/skyrim/keyboard.dts
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- kblight {
- compatible = "cros-ec,kblight-pwm";
- pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_NORMAL>;
- };
-};
-
-&pwm1 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm1_gpc2>;
- pinctrl-names = "default";
-};
-
-&cros_kb_raw {
- status = "okay";
- /* No KSO2 (it's inverted and implemented by GPIO) */
- pinctrl-0 = <
- &ksi0_gp31
- &ksi1_gp30
- &ksi2_gp27
- &ksi3_gp26
- &ksi4_gp25
- &ksi5_gp24
- &ksi6_gp23
- &ksi7_gp22
- &kso00_gp21
- &kso01_gp20
- &kso03_gp16
- &kso04_gp15
- &kso05_gp14
- &kso06_gp13
- &kso07_gp12
- &kso08_gp11
- &kso09_gp10
- &kso10_gp07
- &kso11_gp06
- &kso12_gp05
- >;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/skyrim/led_pins_frostflow.dts b/zephyr/projects/skyrim/led_pins_frostflow.dts
deleted file mode 100644
index d294490208..0000000000
--- a/zephyr/projects/skyrim/led_pins_frostflow.dts
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- pwm_pins {
- compatible = "cros-ec,pwm-pin-config";
-
- pwm_y: pwm_y {
- #led-pin-cells = <1>;
- pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
- };
-
- pwm_w: pwm_w {
- #led-pin-cells = <1>;
- pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
- };
- };
-
- pwm-led-pins {
- compatible = "cros-ec,pwm-led-pins";
-
- color_off: color-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&pwm_y 0>,
- <&pwm_w 0>;
- };
-
- color_amber: color-amber {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&pwm_y 100>,
- <&pwm_w 0>;
- };
-
- color_white: color-white {
- led-color = "LED_WHITE";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_WHITE";
- led-pins = <&pwm_y 0>,
- <&pwm_w 100>;
- };
- };
-};
-
-/* Amber "battery charging" LED */
-&pwm2 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm2_gpc4>;
- pinctrl-names = "default";
-};
-
-/* White "battery full" LED */
-&pwm3 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm3_gp80>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/skyrim/led_pins_morthal.dts b/zephyr/projects/skyrim/led_pins_morthal.dts
deleted file mode 100644
index d294490208..0000000000
--- a/zephyr/projects/skyrim/led_pins_morthal.dts
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- pwm_pins {
- compatible = "cros-ec,pwm-pin-config";
-
- pwm_y: pwm_y {
- #led-pin-cells = <1>;
- pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
- };
-
- pwm_w: pwm_w {
- #led-pin-cells = <1>;
- pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
- };
- };
-
- pwm-led-pins {
- compatible = "cros-ec,pwm-led-pins";
-
- color_off: color-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&pwm_y 0>,
- <&pwm_w 0>;
- };
-
- color_amber: color-amber {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&pwm_y 100>,
- <&pwm_w 0>;
- };
-
- color_white: color-white {
- led-color = "LED_WHITE";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_WHITE";
- led-pins = <&pwm_y 0>,
- <&pwm_w 100>;
- };
- };
-};
-
-/* Amber "battery charging" LED */
-&pwm2 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm2_gpc4>;
- pinctrl-names = "default";
-};
-
-/* White "battery full" LED */
-&pwm3 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm3_gp80>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/skyrim/led_pins_skyrim.dts b/zephyr/projects/skyrim/led_pins_skyrim.dts
deleted file mode 100644
index d294490208..0000000000
--- a/zephyr/projects/skyrim/led_pins_skyrim.dts
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- pwm_pins {
- compatible = "cros-ec,pwm-pin-config";
-
- pwm_y: pwm_y {
- #led-pin-cells = <1>;
- pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
- };
-
- pwm_w: pwm_w {
- #led-pin-cells = <1>;
- pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
- };
- };
-
- pwm-led-pins {
- compatible = "cros-ec,pwm-led-pins";
-
- color_off: color-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&pwm_y 0>,
- <&pwm_w 0>;
- };
-
- color_amber: color-amber {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&pwm_y 100>,
- <&pwm_w 0>;
- };
-
- color_white: color-white {
- led-color = "LED_WHITE";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_WHITE";
- led-pins = <&pwm_y 0>,
- <&pwm_w 100>;
- };
- };
-};
-
-/* Amber "battery charging" LED */
-&pwm2 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm2_gpc4>;
- pinctrl-names = "default";
-};
-
-/* White "battery full" LED */
-&pwm3 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm3_gp80>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/skyrim/led_pins_winterhold.dts b/zephyr/projects/skyrim/led_pins_winterhold.dts
deleted file mode 100644
index d294490208..0000000000
--- a/zephyr/projects/skyrim/led_pins_winterhold.dts
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- pwm_pins {
- compatible = "cros-ec,pwm-pin-config";
-
- pwm_y: pwm_y {
- #led-pin-cells = <1>;
- pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
- };
-
- pwm_w: pwm_w {
- #led-pin-cells = <1>;
- pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>;
- };
- };
-
- pwm-led-pins {
- compatible = "cros-ec,pwm-led-pins";
-
- color_off: color-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&pwm_y 0>,
- <&pwm_w 0>;
- };
-
- color_amber: color-amber {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&pwm_y 100>,
- <&pwm_w 0>;
- };
-
- color_white: color-white {
- led-color = "LED_WHITE";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_WHITE";
- led-pins = <&pwm_y 0>,
- <&pwm_w 100>;
- };
- };
-};
-
-/* Amber "battery charging" LED */
-&pwm2 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm2_gpc4>;
- pinctrl-names = "default";
-};
-
-/* White "battery full" LED */
-&pwm3 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
- pinctrl-0 = <&pwm3_gp80>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/skyrim/morthal.dts b/zephyr/projects/skyrim/morthal.dts
deleted file mode 100644
index 508ce23bce..0000000000
--- a/zephyr/projects/skyrim/morthal.dts
+++ /dev/null
@@ -1,183 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <dt-bindings/usbc_mux.h>
-
-#include "i2c_common.dtsi"
-
-/ {
- named-gpios {
- /* Morthal-specific GPIO customizations */
- };
-
- named-temp-sensors {
- compatible = "cros-ec,temp-sensors";
- soc-pct2075 {
- temp_host_high = <100>;
- temp_host_halt = <105>;
- temp_host_release_high = <80>;
- temp_host_release_halt = <80>;
- temp_fan_off = <0>;
- temp_fan_max = <70>;
- power-good-pin = <&gpio_pg_pwr_s5>;
- sensor = <&soc_pct2075>;
- };
- amb-pct2075 {
- power-good-pin = <&gpio_pg_pwr_s5>;
- sensor = <&amb_pct2075>;
- };
- };
-
- /*
- * Note this is expected to vary per-board, so we keep it in the board
- * dts files.
- */
- morthal-fw-config {
- compatible = "cros-ec,cbi-fw-config";
-
- form-factor {
- enum-name = "FW_FORM_FACTOR";
- start = <0>;
- size = <1>;
-
- ff-clamshell {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_FF_CLAMSHELL";
- value = <0>;
- };
- ff-convertible {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_FF_CONVERTIBLE";
- value = <1>;
- default;
- };
- };
- io-db {
- enum-name = "FW_IO_DB";
- start = <6>;
- size = <2>;
-
- io-db-ps8811-ps8818 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_IO_DB_PS8811_PS8818";
- value = <0>;
- };
- io-db-none-anx7483 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_IO_DB_NONE_ANX7483";
- value = <1>;
- default;
- };
- };
-
- /*
- * FW_CONFIG field to enable fan or not.
- */
- fan {
- enum-name = "FW_FAN";
- start = <10>;
- size = <1>;
-
- no-fan {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_FAN_NOT_PRESENT";
- value = <0>;
- };
- fan-present {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_FAN_PRESENT";
- value = <1>;
- /*
- * Set as default so that unprovisioned
- * configs will run the fan regardless.
- */
- default;
- };
- };
- };
-
- /* Rotation matrices for motion sensors. */
- motionsense-rotation-ref {
- compatible = "cros-ec,motionsense-rotation-ref";
- lid_rot_ref: lid-rotation-ref {
- mat33 = <0 (-1) 0
- 1 0 0
- 0 0 1>;
- };
-
- lid_rot_ref1: lid-rotation-ref1 {
- mat33 = <0 1 0
- (-1) 0 0
- 0 0 1>;
- };
-
- base_rot_ref: base-rotation-ref {
- mat33 = <0 1 0
- (-1) 0 0
- 0 0 1>;
- };
- };
-
- ppc_port0: aoz1380 {
- compatible = "aoz,aoz1380";
- status = "okay";
- };
-};
-
-&i2c0_0 {
- anx7483_port0: anx7483@3e {
- compatible = "analogix,anx7483";
- reg = <0x3e>;
- board-set = "board_anx7483_c0_mux_set";
- };
-};
-
-&i2c1_0 {
- anx7483_port1: anx7483@3e {
- compatible = "analogix,anx7483";
- reg = <0x3e>;
- board-set = "board_anx7483_c1_mux_set";
- };
- ppc_port1: nx20p348x@71 {
- compatible = "nxp,nx20p348x";
- status = "okay";
- reg = <0x71>;
- };
- ps8818_port1: ps8818@28 {
- compatible = "parade,ps8818";
- reg = <0x28>;
- flags = <(USB_MUX_FLAG_RESETS_IN_G3)>;
- board-set = "board_c1_ps8818_mux_set";
- };
-};
-
-&i2c4_1 {
- charger: isl9241@9 {
- compatible = "intersil,isl9241";
- status = "okay";
- reg = <0x9>;
- };
-};
-
-&usbc_port0 {
- ppc = <&ppc_port0>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&amd_fp6_port0 &anx7483_port0>;
- };
-};
-
-&usbc_port1 {
- ppc = <&ppc_port1>;
- usb-mux-chain-1-anx {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&amd_fp6_port1 &anx7483_port1>;
- };
- usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&amd_fp6_port1 &ps8818_port1>;
- alternative-chain;
- };
-};
diff --git a/zephyr/projects/skyrim/prj.conf b/zephyr/projects/skyrim/prj.conf
deleted file mode 100644
index a0085258e4..0000000000
--- a/zephyr/projects/skyrim/prj.conf
+++ /dev/null
@@ -1,167 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-CONFIG_SHIMMED_TASKS=y
-CONFIG_ESPI=y
-
-# Shell features
-CONFIG_SHELL_HELP=y
-CONFIG_SHELL_HISTORY=y
-CONFIG_SHELL_TAB=y
-CONFIG_SHELL_TAB_AUTOCOMPLETION=y
-CONFIG_KERNEL_SHELL=y
-
-# Power sequencing
-CONFIG_AP=y
-CONFIG_AP_X86_AMD=y
-CONFIG_PLATFORM_EC_POWERSEQ=y
-CONFIG_PLATFORM_EC_POWER_BUTTON_TO_PCH_CUSTOM=y
-CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
-CONFIG_PLATFORM_EC_POWERSEQ_RSMRST_DELAY=y
-CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y
-CONFIG_PLATFORM_EC_PORT80=y
-
-# Power button
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-
-# ADC
-CONFIG_ADC=y
-
-# I2C
-CONFIG_I2C=y
-
-# CBI
-CONFIG_EEPROM=y
-CONFIG_EEPROM_AT24=y
-CONFIG_EEPROM_SHELL=n
-CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
-CONFIG_PLATFORM_EC_CBI_EEPROM=y
-
-# Temperature Sensors
-CONFIG_PLATFORM_EC_AMD_SB_RMI=y
-CONFIG_PLATFORM_EC_AMD_STT=y
-CONFIG_PLATFORM_EC_TEMP_SENSOR=y
-CONFIG_PLATFORM_EC_TEMP_SENSOR_SB_TSI=y
-CONFIG_PLATFORM_EC_THERMISTOR=y
-CONFIG_PLATFORM_EC_THROTTLE_AP=y
-
-# External power
-CONFIG_PLATFORM_EC_HOSTCMD=y
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=y
-CONFIG_PLATFORM_EC_BACKLIGHT_LID_ACTIVE_LOW=y
-
-# Sensors
-CONFIG_SENSOR=y
-CONFIG_SENSOR_SHELL=n
-
-# Fan
-CONFIG_TACH_NPCX=y
-
-# Lid switch
-CONFIG_PLATFORM_EC_LID_ANGLE=y
-CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y
-CONFIG_PLATFORM_EC_KEYBOARD=y
-CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
-CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
-CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y
-CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-
-CONFIG_SYSCON=y
-
-# Battery
-CONFIG_PLATFORM_EC_BATTERY=y
-CONFIG_PLATFORM_EC_BATTERY_SMART=y
-CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
-CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
-CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
-CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
-
-# Charger
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
-CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT=512
-CONFIG_PLATFORM_EC_CHARGER_ISL9241=y
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20
-CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000
-
-# USB-A
-CONFIG_PLATFORM_EC_USBA=y
-
-# USB-C
-CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
-CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y
-CONFIG_PLATFORM_EC_USBC_PPC_AOZ1380=y
-CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7451=y
-CONFIG_PLATFORM_EC_USBC_RETIMER_PS8811=y
-CONFIG_PLATFORM_EC_USBC_RETIMER_PS8818=y
-CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y
-CONFIG_PLATFORM_EC_USB_MUX_AMD_FP6=y
-CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y
-CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
-CONFIG_PLATFORM_EC_USB_PID=0x505F
-CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y
-CONFIG_PLATFORM_EC_USB_PD_FRS=y
-CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
-CONFIG_PLATFORM_EC_USB_PD_REV30=y
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
-CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y
-CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n
-CONFIG_PLATFORM_EC_USB_PD_USB4=n
-CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y
-# Give ourselves enough task space to use i2ctrace
-CONFIG_TASK_PD_STACK_SIZE=1280
-
-# IOEX
-CONFIG_GPIO_NCT38XX=y
-
-# Motion sense
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
-CONFIG_PLATFORM_EC_LID_ANGLE=y
-CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
-CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
-
-CONFIG_PLATFORM_EC_MKBP_EVENT=y
-CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
-CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y
-
-CONFIG_PLATFORM_EC_TABLET_MODE=y
-CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
-CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
-
-CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
-
-# Misc.
-CONFIG_PLATFORM_EC_I2C_DEBUG=y
-CONFIG_PLATFORM_EC_PORT80_4_BYTE=y
-
-# These are debug options that happen to be expensive in terms of flash space.
-# Turn on as needed based on demand.
-CONFIG_FLASH_PAGE_LAYOUT=n # 1876 bytes
-CONFIG_FLASH_SHELL=n # 1852 bytes
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n # 656 bytes
-CONFIG_PLATFORM_EC_CONSOLE_CMD_MEM=n # 896 bytes
-# CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n # 1180 bytes
-CONFIG_PLATFORM_EC_CONSOLE_CMD_USB_PD_CABLE=n # 1104 bytes
-CONFIG_THREAD_MONITOR=n # 1548 bytes
diff --git a/zephyr/projects/skyrim/prj_frostflow.conf b/zephyr/projects/skyrim/prj_frostflow.conf
deleted file mode 100644
index 29931de4d4..0000000000
--- a/zephyr/projects/skyrim/prj_frostflow.conf
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Frostflow reference-board-specific Kconfig settings.
-CONFIG_BOARD_FROSTFLOW=y
-CONFIG_BOARD_INPUT_CURRENT_SCALE_FACTOR=90
-
-# TODO(b/215404321): Remove later in board development
-CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
-CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_DT=y
-
-# Frostflow is capable of sinking 45W
-CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000
-CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3000
-CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000
-CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15000
-# Only Frostflow has the PCT2075
-CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y
-
-CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION=y
-
-# Frostflow not have the USB HUB
-CONFIG_BOARD_USB_HUB_RESET=n
diff --git a/zephyr/projects/skyrim/prj_morthal.conf b/zephyr/projects/skyrim/prj_morthal.conf
deleted file mode 100644
index 3d2b3fddb7..0000000000
--- a/zephyr/projects/skyrim/prj_morthal.conf
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Morthal reference-board-specific Kconfig settings.
-CONFIG_BOARD_MORTHAL=y
-
-# TODO(b/215404321): Remove later in board development
-CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
-CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_DT=y
-
-# Morthal is capable of sinking 100W
-CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000
-CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000
-CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000
-
-# Only Morthal has the PCT2075
-CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y
-
-CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y
diff --git a/zephyr/projects/skyrim/prj_skyrim.conf b/zephyr/projects/skyrim/prj_skyrim.conf
deleted file mode 100644
index 2752854c8b..0000000000
--- a/zephyr/projects/skyrim/prj_skyrim.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Skyrim reference-board-specific Kconfig settings.
-CONFIG_BOARD_SKYRIM=y
-
-# CBI WP pin present
-CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_DT=y
-
-# Skyrim is capable of sinking 100W
-CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000
-CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000
-CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000
-
-# Only Skyrim has the PCT2075
-CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y
-
-CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y
-
-# Enable alternative charger chip
-CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y
-CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y
diff --git a/zephyr/projects/skyrim/prj_winterhold.conf b/zephyr/projects/skyrim/prj_winterhold.conf
deleted file mode 100644
index 2ccd195a72..0000000000
--- a/zephyr/projects/skyrim/prj_winterhold.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Winterhold reference-board-specific Kconfig settings.
-CONFIG_BOARD_WINTERHOLD=y
-
-# TODO(b/215404321): Remove later in board development
-CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
-CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_DT=y
-
-# Only Winterhold has the PCT2075
-CONFIG_PLATFORM_EC_TEMP_SENSOR_PCT2075=y
-
-CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y
-
-# Enable charger chip
-CONFIG_PLATFORM_EC_CHARGER_ISL9238=y
-CONFIG_PLATFORM_EC_CHARGER_ISL9241=n
-
-# Get the vbus voltage from TCPC
-CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=n
-CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y \ No newline at end of file
diff --git a/zephyr/projects/skyrim/skyrim.dts b/zephyr/projects/skyrim/skyrim.dts
deleted file mode 100644
index 6a812a55f3..0000000000
--- a/zephyr/projects/skyrim/skyrim.dts
+++ /dev/null
@@ -1,207 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <dt-bindings/usbc_mux.h>
-
-#include "i2c_common.dtsi"
-
-/ {
- named-gpios {
- /* Skyrim-specific GPIO customizations */
- };
-
- named-temp-sensors {
- compatible = "cros-ec,temp-sensors";
- soc-pct2075 {
- temp_host_high = <100>;
- temp_host_halt = <105>;
- temp_host_release_high = <80>;
- temp_host_release_halt = <80>;
- temp_fan_off = <35>;
- temp_fan_max = <70>;
- power-good-pin = <&gpio_pg_pwr_s5>;
- sensor = <&soc_pct2075>;
- };
- amb-pct2075 {
- power-good-pin = <&gpio_pg_pwr_s5>;
- sensor = <&amb_pct2075>;
- };
- };
-
- /*
- * Note this is expected to vary per-board, so we keep it in the board
- * dts files.
- */
- skyrim-fw-config {
- compatible = "cros-ec,cbi-fw-config";
-
- form-factor {
- enum-name = "FW_FORM_FACTOR";
- start = <0>;
- size = <1>;
-
- ff-clamshell {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_FF_CLAMSHELL";
- value = <0>;
- };
- ff-convertible {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_FF_CONVERTIBLE";
- value = <1>;
- default;
- };
- };
- io-db {
- enum-name = "FW_IO_DB";
- start = <6>;
- size = <2>;
-
- io-db-ps8811-ps8818 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_IO_DB_PS8811_PS8818";
- value = <0>;
- };
- io-db-none-anx7483 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_IO_DB_NONE_ANX7483";
- value = <1>;
- default;
- };
- };
-
- /*
- * FW_CONFIG field to enable fan or not.
- */
- fan {
- enum-name = "FW_FAN";
- start = <10>;
- size = <1>;
-
- no-fan {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_FAN_NOT_PRESENT";
- value = <0>;
- };
- fan-present {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_FAN_PRESENT";
- value = <1>;
- /*
- * Set as default so that unprovisioned
- * configs will run the fan regardless.
- */
- default;
- };
- };
-
- charger-option {
- enum-name = "FW_CHARGER";
- start = <11>;
- size = <2>;
-
- charger-option-isl9241 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_CHARGER_ISL9241";
- value = <0>;
- default;
- };
- charger-option-isl9538 {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_CHARGER_ISL9538";
- value = <1>;
- };
- };
- };
-
- /* Rotation matrices for motion sensors. */
- motionsense-rotation-ref {
- compatible = "cros-ec,motionsense-rotation-ref";
- lid_rot_ref: lid-rotation-ref {
- mat33 = <0 (-1) 0
- 1 0 0
- 0 0 1>;
- };
-
- lid_rot_ref1: lid-rotation-ref1 {
- mat33 = <0 1 0
- (-1) 0 0
- 0 0 1>;
- };
-
- base_rot_ref: base-rotation-ref {
- mat33 = <0 1 0
- (-1) 0 0
- 0 0 1>;
- };
- };
-
- ppc_port0: aoz1380 {
- compatible = "aoz,aoz1380";
- status = "okay";
- };
-};
-
-&i2c0_0 {
- anx7483_port0: anx7483@3e {
- compatible = "analogix,anx7483";
- reg = <0x3e>;
- board-set = "board_anx7483_c0_mux_set";
- };
-};
-
-&i2c1_0 {
- anx7483_port1: anx7483@3e {
- compatible = "analogix,anx7483";
- reg = <0x3e>;
- board-set = "board_anx7483_c1_mux_set";
- };
- ppc_port1: nx20p348x@71 {
- compatible = "nxp,nx20p348x";
- status = "okay";
- reg = <0x71>;
- };
- ps8818_port1: ps8818@28 {
- compatible = "parade,ps8818";
- reg = <0x28>;
- flags = <(USB_MUX_FLAG_RESETS_IN_G3)>;
- board-set = "board_c1_ps8818_mux_set";
- };
-};
-
-&i2c4_1 {
- charger: isl9241@9 {
- compatible = "intersil,isl9241";
- status = "okay";
- reg = <0x9>;
- };
- alt_charger: isl9538@9 {
- compatible = "intersil,isl923x";
- status = "okay";
- reg = <0x9>;
- };
-};
-
-&usbc_port0 {
- chg_alt = <&alt_charger>;
- ppc = <&ppc_port0>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&amd_fp6_port0 &anx7483_port0>;
- };
-};
-
-&usbc_port1 {
- ppc = <&ppc_port1>;
- usb-mux-chain-1-anx {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&amd_fp6_port1 &anx7483_port1>;
- };
- usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&amd_fp6_port1 &ps8818_port1>;
- alternative-chain;
- };
-};
diff --git a/zephyr/projects/skyrim/src/frostflow/keyboard_customization.c b/zephyr/projects/skyrim/src/frostflow/keyboard_customization.c
deleted file mode 100644
index d176323d80..0000000000
--- a/zephyr/projects/skyrim/src/frostflow/keyboard_customization.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "common.h"
-#include "gpio.h"
-#include "keyboard_customization.h"
-#include "keyboard_protocol.h"
-#include "keyboard_raw.h"
-
-static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
- { 0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0x0000, 0x0000, 0x0000 },
- { 0x001f, 0x0076, 0x0017, 0x000e, 0x001c, 0x003a, 0x000d, 0x0016 },
- { 0x006c, 0xe024, 0xe01d, 0xe020, 0xe038, 0xe071, 0x0026, 0x002a },
- { 0x0032, 0x0034, 0x002c, 0x002e, 0x002b, 0x0029, 0x0025, 0x002d },
- { 0x0078, 0xe032, 0xe035, 0xe02c, 0xe02d, 0x0041, 0x001e, 0x001d },
- { 0x0051, 0x0007, 0x005b, 0x000f, 0x0042, 0x0022, 0x003e, 0x0043 },
- { 0x0031, 0x0033, 0x0035, 0x0036, 0x003b, 0x001b, 0x003d, 0x003c },
- { 0x0000, 0x0012, 0x0061, 0x0000, 0x0000, 0x0000, 0x0000, 0x0059 },
- { 0x0055, 0x0052, 0x0054, 0x004e, 0x004c, 0x0024, 0x0044, 0x004d },
- { 0x0045, 0xe021, 0xe023, 0x002f, 0x004b, 0x0049, 0x0046, 0x001a },
- { 0xe011, 0x0000, 0x006a, 0x0000, 0x005d, 0x0000, 0x0011, 0x0000 },
- { 0xe07a, 0x005d, 0xe075, 0x006b, 0x005a, 0xe072, 0x004a, 0x0066 },
- { 0xe06b, 0xe074, 0xe069, 0x0067, 0xe06c, 0x0064, 0x0015, 0xe07d },
- { 0x0073, 0x007c, 0x007b, 0x0074, 0x0071, 0xe04a, 0x0070, 0x0021 },
- { 0x0023, 0xe05a, 0x0075, 0x0079, 0x007a, 0x0072, 0x007d, 0x0069 },
-};
-
-uint16_t get_scancode_set2(uint8_t row, uint8_t col)
-{
- if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
- return scancode_set2[col][row];
- return 0;
-}
-
-void set_scancode_set2(uint8_t row, uint8_t col, uint16_t val)
-{
- if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
- scancode_set2[col][row] = val;
-}
-
-#ifdef CONFIG_KEYBOARD_DEBUG
-static char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = {
- { 'c', KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
- KLLI_UNKNO, KLLI_UNKNO },
- { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
- KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO },
- { 'q', KLLI_UNKNO, KLLI_UNKNO, KLLI_TAB, '`', '1', KLLI_UNKNO, 'a' },
- { KLLI_R_ALT, KLLI_L_ALT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
- KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO },
- { KLLI_UNKNO, KLLI_SPACE, 'e', KLLI_F4, KLLI_SEARC, '3', KLLI_F3,
- KLLI_UNKNO },
- { 'x', 'z', KLLI_F2, KLLI_F1, 's', '2', 'w', KLLI_ESC },
- { 'v', 'b', 'g', 't', '5', '4', 'r', 'f' },
- { 'm', 'n', 'h', 'y', '6', '7', 'u', 'j' },
- { '.', KLLI_DOWN, '\\', 'o', KLLI_F10, '9', KLLI_UNKNO, 'l' },
- { KLLI_R_SHT, KLLI_L_SHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
- KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO },
- { ',', KLLI_UNKNO, KLLI_F7, KLLI_F6, KLLI_F5, '8', 'i', 'k' },
- { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_F9, KLLI_UNKNO, KLLI_UNKNO,
- KLLI_LEFT, KLLI_UNKNO },
- { KLLI_R_CTR, KLLI_L_CTR, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
- KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO },
- { '/', KLLI_UP, '-', KLLI_UNKNO, '0', 'p', '[', ';' },
- { '\'', KLLI_ENTER, KLLI_UNKNO, KLLI_UNKNO, '=', KLLI_B_SPC, ']', 'd' },
- { KLLI_UNKNO, KLLI_F8, KLLI_RIGHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO,
- KLLI_UNKNO, KLLI_UNKNO },
-};
-
-char get_keycap_label(uint8_t row, uint8_t col)
-{
- if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
- return keycap_label[col][row];
- return KLLI_UNKNO;
-}
-
-void set_keycap_label(uint8_t row, uint8_t col, char val)
-{
- if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS)
- keycap_label[col][row] = val;
-}
-#endif
diff --git a/zephyr/projects/skyrim/src/frostflow/ppc_config.c b/zephyr/projects/skyrim/src/frostflow/ppc_config.c
deleted file mode 100644
index 6072a788eb..0000000000
--- a/zephyr/projects/skyrim/src/frostflow/ppc_config.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Frostflow board-specific PPC code */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "driver/ppc/nx20p348x.h"
-#include "driver/ppc/aoz1380_public.h"
-#include "usbc_ppc.h"
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-/*
- * In the AOZ1380 PPC, there are no programmable features. We use
- * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0
- * current limits.
- */
-int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- int rv = EC_SUCCESS;
-
- rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en),
- (rp == TYPEC_RP_3A0) ? 1 : 0);
-
- return rv;
-}
-
-void ppc_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_USB_C0_PPC_INT_ODL:
- aoz1380_interrupt(0);
- break;
-
- case GPIO_USB_C1_PPC_INT_ODL:
- nx20p348x_interrupt(1);
- break;
-
- default:
- break;
- }
-}
diff --git a/zephyr/projects/skyrim/src/frostflow/usb_mux_config.c b/zephyr/projects/skyrim/src/frostflow/usb_mux_config.c
deleted file mode 100644
index e641e0d649..0000000000
--- a/zephyr/projects/skyrim/src/frostflow/usb_mux_config.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Frostflow board-specific USB-C mux configuration */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "console.h"
-#include "cros_board_info.h"
-#include "cros_cbi.h"
-#include "driver/retimer/anx7483_public.h"
-#include "hooks.h"
-#include "ioexpander.h"
-#include "usb_mux.h"
-#include "usbc/usb_muxes.h"
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-/*
- * USB C0 (general) and C1 (just ANX DB) use IOEX pins to
- * indicate flipped polarity to a protection switch.
- */
-static int ioex_set_flip(int port, mux_state_t mux_state)
-{
- if (port == 0) {
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
- 1);
- else
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
- 0);
- } else {
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
- 1);
- else
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
- 0);
- }
-
- return EC_SUCCESS;
-}
-
-int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state)
-{
- /* Set the SBU polarity mux */
- RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
-
- return anx7483_set_default_tuning(me, mux_state);
-}
-
-int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state)
-{
- bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED;
-
- /* Set the SBU polarity mux */
- RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
-
- /* Remove flipped from the state for easier compraisons */
- mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED;
-
- RETURN_ERROR(anx7483_set_default_tuning(me, mux_state));
-
- if (mux_state == USB_PD_MUX_USB_ENABLED) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
- ANX7483_EQ_SETTING_12_5DB));
- } else if (mux_state == USB_PD_MUX_DP_ENABLED) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
- ANX7483_EQ_SETTING_12_5DB));
- } else if (mux_state == USB_PD_MUX_DOCK && !flipped) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
- ANX7483_EQ_SETTING_12_5DB));
- } else if (mux_state == USB_PD_MUX_DOCK && flipped) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
- ANX7483_EQ_SETTING_12_5DB));
- }
-
- return EC_SUCCESS;
-}
-
-int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state)
-{
- CPRINTSUSB("C1: PS8818 mux using default tuning");
-
- /* Once a DP connection is established, we need to set IN_HPD */
- if (mux_state & USB_PD_MUX_DP_ENABLED)
- ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1);
- else
- ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0);
-
- return 0;
-}
diff --git a/zephyr/projects/skyrim/src/morthal/ppc_config.c b/zephyr/projects/skyrim/src/morthal/ppc_config.c
deleted file mode 100644
index f3ec1d312e..0000000000
--- a/zephyr/projects/skyrim/src/morthal/ppc_config.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Morthal board-specific PPC code */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "driver/ppc/nx20p348x.h"
-#include "driver/ppc/aoz1380_public.h"
-#include "usbc_ppc.h"
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-/*
- * In the AOZ1380 PPC, there are no programmable features. We use
- * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0
- * current limits.
- */
-int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- int rv = EC_SUCCESS;
-
- rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en),
- (rp == TYPEC_RP_3A0) ? 1 : 0);
-
- return rv;
-}
-
-void ppc_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_USB_C0_PPC_INT_ODL:
- aoz1380_interrupt(0);
- break;
-
- case GPIO_USB_C1_PPC_INT_ODL:
- nx20p348x_interrupt(1);
- break;
-
- default:
- break;
- }
-}
diff --git a/zephyr/projects/skyrim/src/morthal/usb_mux_config.c b/zephyr/projects/skyrim/src/morthal/usb_mux_config.c
deleted file mode 100644
index 8fe76233e2..0000000000
--- a/zephyr/projects/skyrim/src/morthal/usb_mux_config.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Morthal board-specific USB-C mux configuration */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "console.h"
-#include "cros_board_info.h"
-#include "cros_cbi.h"
-#include "driver/retimer/anx7483_public.h"
-#include "hooks.h"
-#include "ioexpander.h"
-#include "usb_mux.h"
-#include "usbc/usb_muxes.h"
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-/*
- * USB C0 (general) and C1 (just ANX DB) use IOEX pins to
- * indicate flipped polarity to a protection switch.
- */
-static int ioex_set_flip(int port, mux_state_t mux_state)
-{
- if (port == 0) {
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
- 1);
- else
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
- 0);
- } else {
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
- 1);
- else
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
- 0);
- }
-
- return EC_SUCCESS;
-}
-
-int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state)
-{
- /* Set the SBU polarity mux */
- RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
-
- return anx7483_set_default_tuning(me, mux_state);
-}
-
-int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state)
-{
- bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED;
-
- /* Set the SBU polarity mux */
- RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
-
- /* Remove flipped from the state for easier compraisons */
- mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED;
-
- RETURN_ERROR(anx7483_set_default_tuning(me, mux_state));
-
- if (mux_state == USB_PD_MUX_USB_ENABLED) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
- ANX7483_EQ_SETTING_12_5DB));
- } else if (mux_state == USB_PD_MUX_DP_ENABLED) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
- ANX7483_EQ_SETTING_12_5DB));
- } else if (mux_state == USB_PD_MUX_DOCK && !flipped) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
- ANX7483_EQ_SETTING_12_5DB));
- } else if (mux_state == USB_PD_MUX_DOCK && flipped) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
- ANX7483_EQ_SETTING_12_5DB));
- }
-
- return EC_SUCCESS;
-}
-
-int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state)
-{
- CPRINTSUSB("C1: PS8818 mux using default tuning");
-
- /* Once a DP connection is established, we need to set IN_HPD */
- if (mux_state & USB_PD_MUX_DP_ENABLED)
- ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1);
- else
- ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0);
-
- return 0;
-}
-
-static void setup_mux(void)
-{
- uint32_t val;
-
- if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0)
- CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG");
- /* Val will have our dts default on error, so continue setup */
-
- if (val == FW_IO_DB_PS8811_PS8818) {
- CPRINTSUSB("C1: Setting PS8818 mux");
- USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1);
- } else if (val == FW_IO_DB_NONE_ANX7483) {
- CPRINTSUSB("C1: Setting ANX7483 mux");
- } else {
- CPRINTSUSB("Unexpected DB_IO board: %d", val);
- }
-}
-DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C);
diff --git a/zephyr/projects/skyrim/src/power_signals.c b/zephyr/projects/skyrim/src/power_signals.c
deleted file mode 100644
index 5d372d35ae..0000000000
--- a/zephyr/projects/skyrim/src/power_signals.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "ap_power/ap_power.h"
-#include "charger.h"
-#include "chipset.h"
-#include "config.h"
-#include "gpio_signal.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "ioexpander.h"
-#include "power.h"
-#include "power/amd_x86.h"
-#include "timer.h"
-
-/* Power Signal Input List */
-/* TODO: b/218904113: Convert to using Zephyr GPIOs */
-const struct power_signal_info power_signal_list[] = {
- [X86_SLP_S3_N] = {
- .gpio = GPIO_PCH_SLP_S3_L,
- .flags = POWER_SIGNAL_ACTIVE_HIGH,
- .name = "SLP_S3_DEASSERTED",
- },
- [X86_SLP_S5_N] = {
- .gpio = GPIO_PCH_SLP_S5_L,
- .flags = POWER_SIGNAL_ACTIVE_HIGH,
- .name = "SLP_S5_DEASSERTED",
- },
- [X86_S0_PGOOD] = {
- .gpio = GPIO_S0_PGOOD,
- .flags = POWER_SIGNAL_ACTIVE_HIGH,
- .name = "S0_PGOOD",
- },
- [X86_S5_PGOOD] = {
- .gpio = GPIO_S5_PGOOD,
- .flags = POWER_SIGNAL_ACTIVE_HIGH,
- .name = "S5_PGOOD",
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-
-/* Chipset hooks */
-static void baseboard_suspend_change(struct ap_power_ev_callback *cb,
- struct ap_power_ev_data data)
-{
- switch (data.event) {
- default:
- return;
-
- case AP_POWER_SUSPEND:
- /* Disable display backlight and retimer */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_disable_disp_bl),
- 1);
- ioex_set_level(IOEX_USB_A1_RETIMER_EN, 0);
- break;
-
- case AP_POWER_RESUME:
- /* Enable retimer and display backlight */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_disable_disp_bl),
- 0);
- ioex_set_level(IOEX_USB_A1_RETIMER_EN, 1);
- /* Any retimer tuning can be done after the retimer turns on */
- break;
- }
-}
-
-static void baseboard_init(void)
-{
- static struct ap_power_ev_callback cb;
-
- /* Setup a suspend/resume callback */
- ap_power_ev_init_callback(&cb, baseboard_suspend_change,
- AP_POWER_RESUME | AP_POWER_SUSPEND);
- ap_power_ev_add_callback(&cb);
- /* Enable Power Group interrupts. */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_pg_groupc_s0));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_pg_lpddr_s0));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_pg_lpddr_s3));
-
- /* Enable thermtrip interrupt */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_soc_thermtrip));
-}
-DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_POST_I2C);
-
-/**
- * b/227296844: On G3->S5, wait for RSMRST_L to be deasserted before asserting
- * PCH_PWRBTN_L. This can be as long as ~65ms after cold boot. Then wait an
- * additional delay of T1a defined in the EDS before changing the power button.
- */
-#define RSMRST_WAIT_DELAY 70
-#define EDS_PWR_BTN_RSMRST_T1A_DELAY 16
-void board_pwrbtn_to_pch(int level)
-{
- timestamp_t start;
-
- /* Add delay for G3 exit if asserting PWRBTN_L and RSMRST_L is low. */
- if (!level &&
- !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_soc_rsmrst_l))) {
- start = get_time();
- do {
- usleep(500);
- if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(
- gpio_ec_soc_rsmrst_l)))
- break;
- } while (time_since32(start) < (RSMRST_WAIT_DELAY * MSEC));
-
- if (!gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_ec_soc_rsmrst_l)))
- ccprints("Error pwrbtn: RSMRST_L still low");
-
- msleep(EDS_PWR_BTN_RSMRST_T1A_DELAY);
- }
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_soc_pwr_btn_l), level);
-}
-
-/* Note: signal parameter unused */
-void baseboard_set_soc_pwr_pgood(enum gpio_signal unused)
-{
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(gpio_ec_soc_pwr_good),
- gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_pwr_pcore_s0_r)) &&
- gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_pg_lpddr5_s0_od)) &&
- gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_s0_pgood)));
-}
-
-/* TODO(b/248284045): Remove when boards switch to new chip */
-#define MP2845A_I2C_ADDR_FLAGS 0x20
-#define MP2854A_MFR_VOUT_CMPS_MAX_REG 0x69
-#define MP2854A_MFR_LOW_PWR_SEL BIT(12)
-
-__overridable bool board_supports_pcore_ocp(void)
-{
- return true;
-}
-
-static void setup_mp2845(void)
-{
- if (i2c_update16(chg_chips[CHARGER_SOLO].i2c_port,
- MP2845A_I2C_ADDR_FLAGS, MP2854A_MFR_VOUT_CMPS_MAX_REG,
- MP2854A_MFR_LOW_PWR_SEL, MASK_CLR))
- ccprints("Failed to send mp2845 workaround");
-
- if (board_supports_pcore_ocp())
- gpio_enable_dt_interrupt(
- GPIO_INT_FROM_NODELABEL(int_soc_pcore_ocp));
-}
-DECLARE_DEFERRED(setup_mp2845);
-
-void baseboard_s0_pgood(enum gpio_signal signal)
-{
- baseboard_set_soc_pwr_pgood(signal);
-
- /* Chain off power signal interrupt handler for PG_PCORE_S0_R_OD */
- power_signal_interrupt(signal);
-
- /* Set up the MP2845, which is powered in S0 */
- if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_s0_pgood)))
- hook_call_deferred(&setup_mp2845_data, 50 * MSEC);
- else
- gpio_disable_dt_interrupt(
- GPIO_INT_FROM_NODELABEL(int_soc_pcore_ocp));
-}
-
-/* Note: signal parameter unused */
-void baseboard_set_en_pwr_pcore(enum gpio_signal unused)
-{
- /*
- * EC must AND signals PG_LPDDR5_S3_OD, PG_GROUPC_S0_OD, and
- * EN_PWR_S0_R
- */
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_pwr_pcore_s0_r),
- gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_pg_lpddr5_s3_od)) &&
- gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_pg_groupc_s0_od)) &&
- gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_pwr_s0_r)));
-
- /* Update EC_SOC_PWR_GOOD based on our results */
- baseboard_set_soc_pwr_pgood(unused);
-}
-
-void baseboard_en_pwr_s0(enum gpio_signal signal)
-{
- /* EC must AND signals SLP_S3_L and PG_PWR_S5 */
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_pwr_s0_r),
- gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s3_l)) &&
- gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5)));
-
- /* Change EN_PWR_PCORE_S0_R if needed*/
- baseboard_set_en_pwr_pcore(signal);
-
- /* Now chain off to the normal power signal interrupt handler. */
- power_signal_interrupt(signal);
-}
-#ifdef CONFIG_BOARD_USB_HUB_RESET
-void baseboard_enable_hub(void)
-{
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_hub_rst), 0);
-}
-DECLARE_DEFERRED(baseboard_enable_hub);
-#endif /* CONFIG_BOARD_USB_HUB_RESET */
-
-void baseboard_s5_pgood(enum gpio_signal signal)
-{
-#ifdef CONFIG_BOARD_USB_HUB_RESET
- /* We must enable the USB hub at least 30ms after S5 PGOOD */
- if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5)))
- hook_call_deferred(&baseboard_enable_hub_data, 30 * MSEC);
- else
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_hub_rst), 1);
-#endif /* CONFIG_BOARD_USB_HUB_RESET */
-
- /* Continue to our signal AND-ing and power interrupt */
- baseboard_en_pwr_s0(signal);
-}
-
-void baseboard_set_en_pwr_s3(enum gpio_signal signal)
-{
- /* EC must enable PWR_S3 when SLP_S5_L goes high, disable on low */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pwr_s3),
- gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s5_l)));
-
- /* Chain off the normal power signal interrupt handler */
- power_signal_interrupt(signal);
-}
-
-void baseboard_soc_thermtrip(enum gpio_signal signal)
-{
- ccprints("SoC thermtrip reported, shutting down");
- chipset_force_shutdown(CHIPSET_SHUTDOWN_THERMAL);
-}
-
-void baseboard_soc_pcore_ocp(enum gpio_signal signal)
-{
- ccprints("SoC Pcore OCP reported, shutting down");
- chipset_force_shutdown(CHIPSET_SHUTDOWN_BOARD_CUSTOM);
-}
diff --git a/zephyr/projects/skyrim/src/skyrim/alt_charger.c b/zephyr/projects/skyrim/src/skyrim/alt_charger.c
deleted file mode 100644
index 4b717901cd..0000000000
--- a/zephyr/projects/skyrim/src/skyrim/alt_charger.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/devicetree.h>
-#include <zephyr/logging/log.h>
-
-#include "charger_chips.h"
-#include "common.h"
-#include "cros_board_info.h"
-#include "cros_cbi.h"
-#include "hooks.h"
-
-LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL);
-
-static void alt_charger_init(void)
-{
- int ret;
- uint32_t val;
-
- ret = cros_cbi_get_fw_config(FW_CHARGER, &val);
- if (ret != 0) {
- LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER);
- return;
- }
-
- if (val == FW_CHARGER_ISL9538)
- CHG_ENABLE_ALTERNATE(0);
-}
-DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST);
diff --git a/zephyr/projects/skyrim/src/skyrim/fan.c b/zephyr/projects/skyrim/src/skyrim/fan.c
deleted file mode 100644
index 0a368ee6f0..0000000000
--- a/zephyr/projects/skyrim/src/skyrim/fan.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/logging/log.h>
-
-#include "cros_board_info.h"
-#include "cros_cbi.h"
-#include "fan.h"
-#include "gpio/gpio.h"
-#include "hooks.h"
-
-LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL);
-
-/*
- * Skyrim fan support
- */
-static void fan_init(void)
-{
- int ret;
- uint32_t val;
- uint32_t board_version;
- /*
- * 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;
- }
-
- ret = cbi_get_board_version(&board_version);
- if (ret != EC_SUCCESS) {
- LOG_ERR("Error retrieving CBI board version");
- return;
- }
-
- if ((board_version >= 3) && (val != FW_FAN_PRESENT)) {
- /* Disable the fan */
- fan_set_count(0);
- }
-}
-DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST);
-
-/*
- * Pcore OCP support
- * Note: early boards should note enable this interrupt as they are not
- * correctly configured for it.
- */
-__override bool board_supports_pcore_ocp(void)
-{
- uint32_t board_version;
-
- if (cbi_get_board_version(&board_version) == EC_SUCCESS &&
- board_version > 3)
- return true;
-
- return false;
-}
diff --git a/zephyr/projects/skyrim/src/skyrim/form_factor.c b/zephyr/projects/skyrim/src/skyrim/form_factor.c
deleted file mode 100644
index f137c6db31..0000000000
--- a/zephyr/projects/skyrim/src/skyrim/form_factor.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/devicetree.h>
-#include <zephyr/logging/log.h>
-#include "common.h"
-#include "accelgyro.h"
-#include "cros_board_info.h"
-#include "hooks.h"
-#include "motionsense_sensors.h"
-
-LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL);
-
-/*
- * Mainboard orientation support.
- */
-
-#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1))
-#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel))
-
-static void form_factor_init(void)
-{
- int ret;
- uint32_t val;
- /*
- * If the board version >=4
- * use ver1 rotation matrix.
- */
- ret = cbi_get_board_version(&val);
- if (ret == EC_SUCCESS && val >= 4) {
- LOG_INF("Switching to ver1 lid");
- motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT;
- }
-}
-DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C);
diff --git a/zephyr/projects/skyrim/src/skyrim/ppc_config.c b/zephyr/projects/skyrim/src/skyrim/ppc_config.c
deleted file mode 100644
index bebc8adcc7..0000000000
--- a/zephyr/projects/skyrim/src/skyrim/ppc_config.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Skyrim board-specific PPC code */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "driver/ppc/nx20p348x.h"
-#include "driver/ppc/aoz1380_public.h"
-#include "usbc_ppc.h"
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-/*
- * In the AOZ1380 PPC, there are no programmable features. We use
- * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0
- * current limits.
- */
-int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- int rv = EC_SUCCESS;
-
- rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en),
- (rp == TYPEC_RP_3A0) ? 1 : 0);
-
- return rv;
-}
-
-void ppc_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_USB_C0_PPC_INT_ODL:
- aoz1380_interrupt(0);
- break;
-
- case GPIO_USB_C1_PPC_INT_ODL:
- nx20p348x_interrupt(1);
- break;
-
- default:
- break;
- }
-}
diff --git a/zephyr/projects/skyrim/src/skyrim/usb_mux_config.c b/zephyr/projects/skyrim/src/skyrim/usb_mux_config.c
deleted file mode 100644
index 6c65e56d9e..0000000000
--- a/zephyr/projects/skyrim/src/skyrim/usb_mux_config.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Skyrim board-specific USB-C mux configuration */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "console.h"
-#include "cros_board_info.h"
-#include "cros_cbi.h"
-#include "driver/retimer/anx7483_public.h"
-#include "hooks.h"
-#include "ioexpander.h"
-#include "usb_mux.h"
-#include "usbc/usb_muxes.h"
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-/*
- * USB C0 (general) and C1 (just ANX DB) use IOEX pins to
- * indicate flipped polarity to a protection switch.
- */
-static int ioex_set_flip(int port, mux_state_t mux_state)
-{
- if (port == 0) {
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
- 1);
- else
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
- 0);
- } else {
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
- 1);
- else
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
- 0);
- }
-
- return EC_SUCCESS;
-}
-
-int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state)
-{
- /* Set the SBU polarity mux */
- RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
-
- return anx7483_set_default_tuning(me, mux_state);
-}
-
-int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state)
-{
- bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED;
-
- /* Set the SBU polarity mux */
- RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
-
- /* Remove flipped from the state for easier compraisons */
- mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED;
-
- RETURN_ERROR(anx7483_set_default_tuning(me, mux_state));
-
- if (mux_state == USB_PD_MUX_USB_ENABLED) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
- ANX7483_EQ_SETTING_12_5DB));
- } else if (mux_state == USB_PD_MUX_DP_ENABLED) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
- ANX7483_EQ_SETTING_12_5DB));
- } else if (mux_state == USB_PD_MUX_DOCK && !flipped) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
- ANX7483_EQ_SETTING_12_5DB));
- } else if (mux_state == USB_PD_MUX_DOCK && flipped) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
- ANX7483_EQ_SETTING_12_5DB));
- }
-
- return EC_SUCCESS;
-}
-
-int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state)
-{
- CPRINTSUSB("C1: PS8818 mux using default tuning");
-
- /* Once a DP connection is established, we need to set IN_HPD */
- if (mux_state & USB_PD_MUX_DP_ENABLED)
- ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1);
- else
- ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0);
-
- return 0;
-}
-
-static void setup_mux(void)
-{
- uint32_t val;
-
- if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0)
- CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG");
- /* Val will have our dts default on error, so continue setup */
-
- if (val == FW_IO_DB_PS8811_PS8818) {
- CPRINTSUSB("C1: Setting PS8818 mux");
- USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1);
- } else if (val == FW_IO_DB_NONE_ANX7483) {
- CPRINTSUSB("C1: Setting ANX7483 mux");
- } else {
- CPRINTSUSB("Unexpected DB_IO board: %d", val);
- }
-}
-DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C);
diff --git a/zephyr/projects/skyrim/src/usb_pd_policy.c b/zephyr/projects/skyrim/src/usb_pd_policy.c
deleted file mode 100644
index ec9f873863..0000000000
--- a/zephyr/projects/skyrim/src/usb_pd_policy.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Shared USB-C policy for Zork boards */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "charge_manager.h"
-#include "chipset.h"
-#include "common.h"
-#include "compile_time_macros.h"
-#include "console.h"
-#include "ec_commands.h"
-#include "ioexpander.h"
-#include "system.h"
-#include "usb_mux.h"
-#include "usb_pd.h"
-#include "usbc_ppc.h"
-#include "util.h"
-
-int pd_check_vconn_swap(int port)
-{
- /*
- * Do not allow vconn swap 5V rail is off
- * S5_PGOOD depends on PG_PP5000_S5 being asserted,
- * so GPIO_S5_PGOOD is a reasonable proxy for PP5000_S5
- */
- return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_pg_pwr_s5));
-}
-
-void pd_power_supply_reset(int port)
-{
- /* Disable VBUS. */
- ppc_vbus_source_enable(port, 0);
-
- /* Enable discharge if we were previously sourcing 5V */
- if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE))
- pd_set_vbus_discharge(port, 1);
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- int rv;
-
- /* Disable charging. */
- rv = ppc_vbus_sink_enable(port, 0);
- if (rv)
- return rv;
-
- if (IS_ENABLED(CONFIG_USB_PD_DISCHARGE))
- pd_set_vbus_discharge(port, 0);
-
- /* Provide Vbus. */
- rv = ppc_vbus_source_enable(port, 1);
- if (rv)
- return rv;
-
- /* Notify host of power info change. */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS;
-}
-
-__override int board_pd_set_frs_enable(int port, int enable)
-{
- /*
- * Both PPCs require the FRS GPIO to be set as soon as FRS capability
- * is established.
- */
- if (port == 0)
- ioex_set_level(IOEX_USB_C0_TCPC_FASTSW_CTL_EN, enable);
- else
- ioex_set_level(IOEX_USB_C1_TCPC_FASTSW_CTL_EN, enable);
-
- return EC_SUCCESS;
-}
-
-/* Used by Vbus discharge common code with CONFIG_USB_PD_DISCHARGE */
-int board_vbus_source_enabled(int port)
-{
- return tcpm_get_src_ctrl(port);
-}
-
-/* Used by USB charger task with CONFIG_USB_PD_5V_EN_CUSTOM */
-int board_is_sourcing_vbus(int port)
-{
- return board_vbus_source_enabled(port);
-}
diff --git a/zephyr/projects/skyrim/src/usbc_config.c b/zephyr/projects/skyrim/src/usbc_config.c
deleted file mode 100644
index dec9f928b5..0000000000
--- a/zephyr/projects/skyrim/src/usbc_config.c
+++ /dev/null
@@ -1,403 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Skyrim family-specific USB-C configuration */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "cros_board_info.h"
-#include "cros_cbi.h"
-#include "battery_fuel_gauge.h"
-#include "charge_manager.h"
-#include "charge_ramp.h"
-#include "charge_state_v2.h"
-#include "charge_state.h"
-#include "charger.h"
-#include "driver/bc12/pi3usb9201.h"
-#include "driver/charger/isl9241.h"
-#include "driver/ppc/nx20p348x.h"
-#include "driver/retimer/anx7483_public.h"
-#include "driver/retimer/ps8811.h"
-#include "driver/retimer/ps8818_public.h"
-#include "driver/tcpm/nct38xx.h"
-#include "driver/usb_mux/amd_fp6.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "ioexpander.h"
-#include "power.h"
-#include "usb_mux.h"
-#include "usb_pd_tcpm.h"
-#include "usbc_ppc.h"
-#include "usbc/usb_muxes.h"
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-/* USB-A ports */
-enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_A1, USBA_PORT_COUNT };
-
-/* USB-C ports */
-enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
-BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT);
-
-static void reset_nct38xx_port(int port);
-
-static void usbc_interrupt_init(void)
-{
- /* Enable PPC interrupts. */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_ppc));
-
- /* Enable TCPC interrupts. */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc));
-
- /* Enable BC 1.2 interrupts */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_bc12));
-
- /* Enable SBU fault interrupts */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_sbu_fault));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_sbu_fault));
-}
-DECLARE_HOOK(HOOK_INIT, usbc_interrupt_init, HOOK_PRIO_POST_I2C);
-
-static void usb_fault_interrupt_init(void)
-{
- /* Enable USB fault interrupts when we hit S5 */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_hub_fault));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_fault));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a1_fault));
-}
-DECLARE_HOOK(HOOK_CHIPSET_STARTUP, usb_fault_interrupt_init, HOOK_PRIO_DEFAULT);
-
-static void usb_fault_interrupt_disable(void)
-{
- /* Disable USB fault interrupts leaving S5 */
- gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_hub_fault));
- gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_fault));
- gpio_disable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a1_fault));
-}
-DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, usb_fault_interrupt_disable,
- HOOK_PRIO_DEFAULT);
-
-int board_set_active_charge_port(int port)
-{
- int is_valid_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
- int i;
- int rv;
-
- if (port == CHARGE_PORT_NONE) {
- CPRINTSUSB("Disabling all charger ports");
-
- /* Disable all ports. */
- for (i = 0; i < ppc_cnt; i++) {
- /*
- * If this port had booted in dead battery mode, go
- * ahead and reset it so EN_SNK responds properly.
- */
- if (nct38xx_get_boot_type(i) ==
- NCT38XX_BOOT_DEAD_BATTERY) {
- reset_nct38xx_port(i);
- pd_set_error_recovery(i);
- }
-
- /*
- * Do not return early if one fails otherwise we can
- * get into a boot loop assertion failure.
- */
- if (ppc_vbus_sink_enable(i, 0))
- CPRINTSUSB("Disabling C%d as sink failed.", i);
- }
-
- return EC_SUCCESS;
- } else if (!is_valid_port) {
- return EC_ERROR_INVAL;
- }
-
- /*
- * Check if we can reset any ports in dead battery mode
- *
- * The NCT3807 may continue to keep EN_SNK low on the dead battery port
- * and allow a dangerous level of voltage to pass through to the initial
- * charge port (see b/183660105). We must reset the ports if we have
- * sufficient battery to do so, which will bring EN_SNK back under
- * normal control.
- */
- rv = EC_SUCCESS;
- for (i = 0; i < board_get_usb_pd_port_count(); i++) {
- if (nct38xx_get_boot_type(i) == NCT38XX_BOOT_DEAD_BATTERY) {
- CPRINTSUSB("Found dead battery on %d", i);
- /*
- * If we have battery, get this port reset ASAP.
- * This means temporarily rejecting charge manager
- * sets to it.
- */
- if (pd_is_battery_capable()) {
- reset_nct38xx_port(i);
- pd_set_error_recovery(i);
-
- if (port == i)
- rv = EC_ERROR_INVAL;
- } else if (port != i) {
- /*
- * If other port is selected and in dead battery
- * mode, reset this port. Otherwise, reject
- * change because we'll brown out.
- */
- if (nct38xx_get_boot_type(port) ==
- NCT38XX_BOOT_DEAD_BATTERY) {
- reset_nct38xx_port(i);
- pd_set_error_recovery(i);
- } else {
- rv = EC_ERROR_INVAL;
- }
- }
- }
- }
-
- if (rv != EC_SUCCESS)
- return rv;
-
- /* Check if the port is sourcing VBUS. */
- if (tcpm_get_src_ctrl(port)) {
- CPRINTSUSB("Skip enable C%d", port);
- return EC_ERROR_INVAL;
- }
-
- CPRINTSUSB("New charge port: C%d", port);
-
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < ppc_cnt; i++) {
- if (i == port)
- continue;
-
- if (ppc_vbus_sink_enable(i, 0))
- CPRINTSUSB("C%d: sink path disable failed.", i);
- }
-
- /* Enable requested charge port. */
- if (ppc_vbus_sink_enable(port, 1)) {
- CPRINTSUSB("C%d: sink path enable failed.", port);
- return EC_ERROR_UNKNOWN;
- }
-
- return EC_SUCCESS;
-}
-
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_ma = (charge_ma * CONFIG_BOARD_INPUT_CURRENT_SCALE_FACTOR) / 100;
-
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
-void sbu_fault_interrupt(enum gpio_signal signal)
-{
- int port = signal == IOEX_USB_C1_FAULT_ODL ? 1 : 0;
-
- CPRINTSUSB("C%d: SBU fault", port);
- pd_handle_overcurrent(port);
-}
-
-void usb_fault_interrupt(enum gpio_signal signal)
-{
- int out;
-
- CPRINTSUSB("USB fault(%d), alerting the SoC", signal);
- out = gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_usb_hub_fault_q_odl)) &&
- gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_a0_fault_odl)) &&
- gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_a1_fault_db_odl));
-
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_fault_odl), out);
-}
-
-void usb_pd_soc_interrupt(enum gpio_signal signal)
-{
- /*
- * This interrupt is unexpected with our use of the SoC mux, so just log
- * it as a point of interest.
- */
- CPRINTSUSB("SOC PD Interrupt");
-}
-
-#ifdef CONFIG_CHARGER_ISL9241
-/* Round up 3250 max current to multiple of 128mA for ISL9241 AC prochot. */
-#define SKYRIM_AC_PROCHOT_CURRENT_MA 3328
-static void set_ac_prochot(void)
-{
- isl9241_set_ac_prochot(CHARGER_SOLO, SKYRIM_AC_PROCHOT_CURRENT_MA);
-}
-DECLARE_HOOK(HOOK_INIT, set_ac_prochot, HOOK_PRIO_DEFAULT);
-#endif /* CONFIG_CHARGER_ISL9241 */
-
-void tcpc_alert_event(enum gpio_signal signal)
-{
- int port;
-
- switch (signal) {
- case GPIO_USB_C0_TCPC_INT_ODL:
- port = 0;
- break;
- case GPIO_USB_C1_TCPC_INT_ODL:
- port = 1;
- break;
- default:
- return;
- }
-
- schedule_deferred_pd_interrupt(port);
-}
-
-static void reset_nct38xx_port(int port)
-{
- const struct gpio_dt_spec *reset_gpio_l;
- const struct device *ioex_port0, *ioex_port1;
-
- /* TODO(b/225189538): Save and restore ioex signals */
- if (port == USBC_PORT_C0) {
- reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst_l);
- ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port0));
- ioex_port1 = DEVICE_DT_GET(DT_NODELABEL(ioex_c0_port1));
- } else if (port == USBC_PORT_C1) {
- reset_gpio_l = GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_rst_l);
- ioex_port0 = DEVICE_DT_GET(DT_NODELABEL(ioex_c1_port0));
- ioex_port1 = DEVICE_DT_GET(DT_NODELABEL(ioex_c1_port1));
- } else {
- /* Invalid port: do nothing */
- return;
- }
-
- gpio_pin_set_dt(reset_gpio_l, 0);
- msleep(NCT38XX_RESET_HOLD_DELAY_MS);
- gpio_pin_set_dt(reset_gpio_l, 1);
- nct38xx_reset_notify(port);
- if (NCT3807_RESET_POST_DELAY_MS != 0)
- msleep(NCT3807_RESET_POST_DELAY_MS);
-
- /* Re-enable the IO expander pins */
- gpio_reset_port(ioex_port0);
- gpio_reset_port(ioex_port1);
-}
-
-void board_reset_pd_mcu(void)
-{
- /* Reset TCPC0 */
- reset_nct38xx_port(USBC_PORT_C0);
-
- /* Reset TCPC1 */
- reset_nct38xx_port(USBC_PORT_C1);
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
-
- /*
- * Check which port has the ALERT line set and ignore if that TCPC has
- * its reset line active.
- */
- if (!gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl))) {
- if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(
- gpio_usb_c0_tcpc_rst_l)) != 0)
- status |= PD_STATUS_TCPC_ALERT_0;
- }
-
- if (!gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl))) {
- if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(
- gpio_usb_c1_tcpc_rst_l)) != 0)
- status |= PD_STATUS_TCPC_ALERT_1;
- }
-
- return status;
-}
-
-void bc12_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_USB_C0_BC12_INT_ODL:
- usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
- break;
-
- case GPIO_USB_C1_BC12_INT_ODL:
- usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
- break;
-
- default:
- break;
- }
-}
-
-/**
- * Return if VBUS is sagging too low
- *
- * For legacy BC1.2 charging with CONFIG_CHARGE_RAMP_SW, ramp up input current
- * until voltage drops to 4.5V. Don't go lower than this to be kind to the
- * charger (see b/67964166).
- */
-#define BC12_MIN_VOLTAGE 4500
-int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state)
-{
- int voltage = 0;
- int rv;
-
- rv = charger_get_vbus_voltage(port, &voltage);
-
- if (rv) {
- CPRINTSUSB("%s rv=%d", __func__, rv);
- return 0;
- }
-
- /*
- * b/168569046: The ISL9241 sometimes incorrectly reports 0 for unknown
- * reason, causing ramp to stop at 0.5A. Workaround this by ignoring 0.
- * This partly defeats the point of ramping, but will still catch
- * VBUS below 4.5V and above 0V.
- */
- if (voltage == 0) {
- CPRINTSUSB("%s vbus=0", __func__);
- return 0;
- }
-
- if (voltage < BC12_MIN_VOLTAGE)
- CPRINTSUSB("%s vbus=%d", __func__, voltage);
-
- return voltage < BC12_MIN_VOLTAGE;
-}
-
-#define SAFE_RESET_VBUS_DELAY_MS 900
-#define SAFE_RESET_VBUS_MV 5000
-void board_hibernate(void)
-{
- int port;
- enum ec_error_list ret;
-
- /*
- * If we are charging, then drop the Vbus level down to 5V to ensure
- * that we don't get locked out of the 6.8V OVLO for our PPCs in
- * dead-battery mode. This is needed when the TCPC/PPC rails go away.
- * (b/79218851, b/143778351, b/147007265)
- */
- port = charge_manager_get_active_charge_port();
- if (port != CHARGE_PORT_NONE) {
- pd_request_source_voltage(port, SAFE_RESET_VBUS_MV);
-
- /* Give PD task and PPC chip time to get to 5V */
- msleep(SAFE_RESET_VBUS_DELAY_MS);
- }
-
- /* Try to put our battery fuel gauge into sleep mode */
- ret = battery_sleep_fuel_gauge();
- if ((ret != EC_SUCCESS) && (ret != EC_ERROR_UNIMPLEMENTED))
- cprints(CC_SYSTEM, "Failed to send battery sleep command");
-}
diff --git a/zephyr/projects/skyrim/src/winterhold/kb_backlight.c b/zephyr/projects/skyrim/src/winterhold/kb_backlight.c
deleted file mode 100644
index 049b99e3a1..0000000000
--- a/zephyr/projects/skyrim/src/winterhold/kb_backlight.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/devicetree.h>
-#include <zephyr/logging/log.h>
-
-#include "board_config.h"
-#include "common.h"
-#include "cros_board_info.h"
-#include "cros_cbi.h"
-
-LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL);
-
-__override uint32_t board_override_feature_flags0(uint32_t flags0)
-{
- int ret;
- uint32_t val;
-
- /*
- * Remove keyboard backlight feature for devices that don't support it.
- */
- ret = cros_cbi_get_fw_config(FW_KB_BL, &val);
- if (ret != 0) {
- LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_KB_BL);
- return flags0;
- }
-
- if (val == FW_KB_BL_NOT_PRESENT)
- return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB));
- else
- return flags0;
-}
diff --git a/zephyr/projects/skyrim/src/winterhold/ppc_config.c b/zephyr/projects/skyrim/src/winterhold/ppc_config.c
deleted file mode 100644
index 72ddb6ce6c..0000000000
--- a/zephyr/projects/skyrim/src/winterhold/ppc_config.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Winterhold board-specific PPC code */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "driver/ppc/nx20p348x.h"
-#include "usbc_ppc.h"
-
-void ppc_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_USB_C0_PPC_INT_ODL:
- nx20p348x_interrupt(0);
- break;
-
- case GPIO_USB_C1_PPC_INT_ODL:
- nx20p348x_interrupt(1);
- break;
-
- default:
- break;
- }
-}
diff --git a/zephyr/projects/skyrim/src/winterhold/usb_mux_config.c b/zephyr/projects/skyrim/src/winterhold/usb_mux_config.c
deleted file mode 100644
index d2ee4a6606..0000000000
--- a/zephyr/projects/skyrim/src/winterhold/usb_mux_config.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Winterhold board-specific USB-C mux configuration */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "console.h"
-#include "cros_board_info.h"
-#include "cros_cbi.h"
-#include "driver/retimer/anx7483_public.h"
-#include "hooks.h"
-#include "ioexpander.h"
-#include "usb_mux.h"
-#include "usbc/usb_muxes.h"
-
-#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-/*
- * USB C0 (general) and C1 (just ANX DB) use IOEX pins to
- * indicate flipped polarity to a protection switch.
- */
-static int ioex_set_flip(int port, mux_state_t mux_state)
-{
- if (port == 0) {
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
- 1);
- else
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip),
- 0);
- } else {
- if (mux_state & USB_PD_MUX_POLARITY_INVERTED)
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
- 1);
- else
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip),
- 0);
- }
-
- return EC_SUCCESS;
-}
-
-int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state)
-{
- /* Set the SBU polarity mux */
- RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
-
- return anx7483_set_default_tuning(me, mux_state);
-}
-
-int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state)
-{
- bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED;
-
- /* Set the SBU polarity mux */
- RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state));
-
- /* Remove flipped from the state for easier compraisons */
- mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED;
-
- RETURN_ERROR(anx7483_set_default_tuning(me, mux_state));
-
- if (mux_state == USB_PD_MUX_USB_ENABLED) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
- ANX7483_EQ_SETTING_12_5DB));
- } else if (mux_state == USB_PD_MUX_DP_ENABLED) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
- ANX7483_EQ_SETTING_12_5DB));
- } else if (mux_state == USB_PD_MUX_DOCK && !flipped) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2,
- ANX7483_EQ_SETTING_12_5DB));
- } else if (mux_state == USB_PD_MUX_DOCK && flipped) {
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1,
- ANX7483_EQ_SETTING_12_5DB));
- RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2,
- ANX7483_EQ_SETTING_12_5DB));
- }
-
- return EC_SUCCESS;
-}
diff --git a/zephyr/projects/skyrim/winterhold.dts b/zephyr/projects/skyrim/winterhold.dts
deleted file mode 100644
index 6113923ed8..0000000000
--- a/zephyr/projects/skyrim/winterhold.dts
+++ /dev/null
@@ -1,126 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <dt-bindings/usbc_mux.h>
-
-#include "i2c_common.dtsi"
-
-/ {
- named-gpios {
- /* Winterhold-specific GPIO customizations */
- };
-
- named-temp-sensors {
- compatible = "cros-ec,temp-sensors";
- soc-pct2075 {
- temp_host_high = <100>;
- temp_host_halt = <105>;
- temp_host_release_high = <80>;
- temp_host_release_halt = <80>;
- temp_fan_off = <0>;
- temp_fan_max = <70>;
- power-good-pin = <&gpio_pg_pwr_s5>;
- sensor = <&soc_pct2075>;
- };
- amb-pct2075 {
- power-good-pin = <&gpio_pg_pwr_s5>;
- sensor = <&amb_pct2075>;
- };
- };
-
- /*
- * Note this is expected to vary per-board, so we keep it in the board
- * dts files.
- */
- Winterhold-fw-config {
- compatible = "cros-ec,cbi-fw-config";
-
- /*
- * FW_CONFIG field to enable KB back light or not.
- */
- kb-bl {
- enum-name = "FW_KB_BL";
- start = <1>;
- size = <1>;
-
- no-kb-bl {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_KB_BL_NOT_PRESENT";
- value = <0>;
- };
- kb-bl-present {
- compatible = "cros-ec,cbi-fw-config-value";
- enum-name = "FW_KB_BL_PRESENT";
- value = <1>;
- };
- };
- };
-
- /* Rotation matrices for motion sensors. */
- motionsense-rotation-ref {
- compatible = "cros-ec,motionsense-rotation-ref";
- lid_rot_ref: lid-rotation-ref {
- mat33 = <0 (-1) 0
- 1 0 0
- 0 0 1>;
- };
-
- base_rot_ref: base-rotation-ref {
- mat33 = <0 1 0
- (-1) 0 0
- 0 0 1>;
- };
- };
-};
-
-&i2c0_0 {
- anx7483_port0: anx7483@3e {
- compatible = "analogix,anx7483";
- reg = <0x3e>;
- board-set = "board_anx7483_c0_mux_set";
- };
- ppc_port0: nx20p348x@71 {
- compatible = "nxp,nx20p348x";
- status = "okay";
- reg = <0x71>;
- };
-};
-
-&i2c1_0 {
- anx7483_port1: anx7483@3e {
- compatible = "analogix,anx7483";
- reg = <0x3e>;
- board-set = "board_anx7483_c1_mux_set";
- };
- ppc_port1: nx20p348x@71 {
- compatible = "nxp,nx20p348x";
- status = "okay";
- reg = <0x71>;
- };
-};
-
-&i2c4_1 {
- charger: isl9238@9 {
- compatible = "intersil,isl923x";
- status = "okay";
- reg = <0x9>;
- };
-};
-
-&usbc_port0 {
- ppc = <&ppc_port0>;
- usb-mux-chain-0 {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&amd_fp6_port0 &anx7483_port0>;
- };
-};
-
-&usbc_port1 {
- ppc = <&ppc_port1>;
- usb-mux-chain-1-anx {
- compatible = "cros-ec,usb-mux-chain";
- usb-muxes = <&amd_fp6_port1 &anx7483_port1>;
- };
-};
diff --git a/zephyr/projects/trogdor/lazor/gpio.dts b/zephyr/projects/trogdor/lazor/gpio.dts
deleted file mode 100644
index a047d7e2f2..0000000000
--- a/zephyr/projects/trogdor/lazor/gpio.dts
+++ /dev/null
@@ -1,320 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <dt-bindings/wake_mask_event_defines.h>
-
-/ {
- aliases {
- gpio-wp = &gpio_ec_wp_odl;
- gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- gpio_usb_c0_pd_int_odl: usb_c0_pd_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PD_INT_ODL";
- };
- gpio_usb_c1_pd_int_odl: usb_c1_pd_int_odl {
- gpios = <&gpiof 5 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_PD_INT_ODL";
- };
- gpio_usb_c0_swctl_int_odl: usb_c0_swctl_int_odl {
- gpios = <&gpio0 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
- };
- gpio_usb_c1_swctl_int_odl: usb_c1_swctl_int_odl {
- gpios = <&gpio4 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
- };
- gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
- gpios = <&gpio6 1 GPIO_INPUT_PULL_UP>;
- };
- gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
- gpios = <&gpio8 2 GPIO_INPUT_PULL_UP>;
- };
- gpio_usb_a0_oc_odl: usb_a0_oc_odl {
- gpios = <&gpiod 1 GPIO_INPUT_PULL_UP>;
- };
- gpio_acok_od: acok_od {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- };
- gpio_ccd_mode_odl: ccd_mode_odl {
- gpios = <&gpioe 3 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- };
- gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- };
- gpio_ec_voldn_btn_odl: ec_voldn_btn_odl {
- gpios = <&gpio7 0 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- };
- gpio_ec_volup_btn_odl: ec_volup_btn_odl {
- gpios = <&gpiof 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_VOLUME_UP_L";
- };
- gpio_ec_wp_odl: ec_wp_odl {
- gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
- };
- gpio_lid_open_ec: lid_open_ec {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- };
- gpio_ap_rst_l: ap_rst_l {
- gpios = <&gpioc 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_AP_RST_L";
- };
- gpio_ps_hold: ps_hold {
- gpios = <&gpioa 4 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_PS_HOLD";
- };
- gpio_ap_suspend: ap_suspend {
- gpios = <&gpio5 7 GPIO_INPUT>;
- enum-name = "GPIO_AP_SUSPEND";
- };
- gpio_deprecated_ap_rst_req: deprecated_ap_rst_req {
- gpios = <&gpioc 2 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_DEPRECATED_AP_RST_REQ";
- };
- gpio_power_good: power_good {
- gpios = <&gpio5 4 GPIO_INPUT_PULL_DOWN>;
- enum-name = "GPIO_POWER_GOOD";
- };
- gpio_warm_reset_l: warm_reset_l {
- gpios = <&gpiof 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_WARM_RESET_L";
- };
- ap_ec_spi_cs_l {
- gpios = <&gpio5 3 GPIO_INPUT_PULL_DOWN>;
- };
- gpio_tablet_mode_l: tablet_mode_l {
- gpios = <&gpioc 6 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- };
- gpio_accel_gyro_int_l: accel_gyro_int_l {
- gpios = <&gpioa 0 GPIO_INPUT>;
- };
- gpio_da9313_gpio0: da9313_gpio0 {
- gpios = <&gpioe 2 GPIO_INPUT>;
- enum-name = "GPIO_DA9313_GPIO0";
- };
- /*
- * Active low input
- */
- gpio_switchcap_pg_int_l: switchcap_pg_int_l {
- gpios = <&gpioe 2 (GPIO_ACTIVE_LOW | GPIO_INPUT)>;
- };
- gpio_ec_rst_odl: ec_rst_odl {
- gpios = <&gpio0 2 GPIO_INPUT>;
- };
- ec_entering_rw {
- gpios = <&gpioe 1 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- };
- ec_batt_pres_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- };
- pm845_resin_l {
- gpios = <&gpio3 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_RESIN_L";
- };
- pmic_kpd_pwr_odl {
- gpios = <&gpiod 6 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_KPD_PWR_ODL";
- };
- ec_int_l {
- gpios = <&gpioa 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- };
- qsip_on {
- gpios = <&gpio5 0 GPIO_OUTPUT_LOW>;
- };
- gpio_hibernate_l: hibernate_l {
- gpios = <&gpio5 2 GPIO_OUTPUT_HIGH>;
- };
- gpio_switchcap_on: switchcap_on {
- gpios = <&gpiod 5 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_SWITCHCAP_ON";
- };
- gpio_vbob_en: vbob_en {
- gpios = <&gpiod 3 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_VBOB_EN";
- };
- gpio_en_pp3300_a: en_pp3300_a {
- gpios = <&gpioa 6 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_EN_PP3300_A";
- };
- gpio_en_pp5000_a: en_pp5000_a {
- gpios = <&gpio6 7 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_EN_PP5000";
- };
- ec_bl_disable_l {
- gpios = <&gpiob 6 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- };
- gpio_lid_accel_int_l: lid_accel_int_l {
- gpios = <&gpio5 6 GPIO_INPUT>;
- };
- trackpad_int_gate {
- gpios = <&gpio7 4 GPIO_OUTPUT_LOW>;
- };
- gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l {
- gpios = <&gpiof 1 GPIO_ODR_HIGH>;
- };
- gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l {
- gpios = <&gpioe 4 GPIO_ODR_HIGH>;
- };
- gpio_dp_mux_oe_l: dp_mux_oe_l {
- gpios = <&gpio9 6 GPIO_ODR_HIGH>;
- };
- gpio_dp_mux_sel: dp_mux_sel {
- gpios = <&gpio4 5 GPIO_OUTPUT_LOW>;
- };
- gpio_dp_hot_plug_det: dp_hot_plug_det {
- gpios = <&gpio9 5 GPIO_OUTPUT_LOW>;
- };
- gpio_en_usb_a_5v: en_usb_a_5v {
- gpios = <&gpio8 6 GPIO_OUTPUT_LOW>;
- enum-name = "GPIO_EN_USB_A_5V";
- };
- usb_a_cdp_ilim_en {
- gpios = <&gpio7 5 GPIO_OUTPUT_HIGH>;
- };
- gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 {
- #led-pin-cells = <1>;
- gpios = <&gpioc 3 GPIO_OUTPUT_LOW>;
- };
- gpio_ec_chg_led_b_c1: ec_chg_led_b_c1 {
- #led-pin-cells = <1>;
- gpios = <&gpioc 4 GPIO_OUTPUT_LOW>;
- };
- gpio_brd_id0: brd_id0 {
- gpios = <&gpioc 7 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION1";
- };
- gpio_brd_id1: brd_id1 {
- gpios = <&gpio9 3 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION2";
- };
- gpio_brd_id2: brd_id2 {
- gpios = <&gpio6 3 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION3";
- };
- gpio_sku_id0: sku_id0 {
- gpios = <&gpiof 0 GPIO_INPUT>;
- };
- gpio_sku_id1: sku_id1 {
- gpios = <&gpio4 1 GPIO_INPUT>;
- };
- gpio_sku_id2: sku_id2 {
- gpios = <&gpiod 4 GPIO_INPUT>;
- };
- arm_x86 {
- gpios = <&gpio6 6 GPIO_OUTPUT_LOW>;
- };
- ec-i2c-sensor-scl {
- gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- ec-i2c-sensor-sda {
- gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- };
- gpio_ec_kso_02_inv: ec_kso_02_inv {
- gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>;
- };
- };
-
- usba-port-enable-list {
- compatible = "cros-ec,usba-port-enable-pins";
- enable-pins = <&gpio_en_usb_a_5v>;
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-irqs = <
- &int_ac_present
- &int_power_button
- &int_lid_open
- &int_ec_rst
- >;
- };
-
- ec-mkbp-host-event-wakeup-mask {
- compatible = "ec-wake-mask-event";
- wakeup-mask = <(
- HOST_EVENT_LID_OPEN |
- HOST_EVENT_POWER_BUTTON |
- HOST_EVENT_AC_CONNECTED |
- HOST_EVENT_AC_DISCONNECTED |
- HOST_EVENT_HANG_DETECT |
- HOST_EVENT_RTC |
- HOST_EVENT_MODE_CHANGE |
- HOST_EVENT_DEVICE)>;
- };
-
- ec-mkbp-event-wakeup-mask {
- compatible = "ec-wake-mask-event";
- wakeup-mask = <(MKBP_EVENT_KEY_MATRIX |
- MKBP_EVENT_HOST_EVENT |
- MKBP_EVENT_SENSOR_FIFO)>;
- };
-
- sku {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_sku_id0
- &gpio_sku_id1
- &gpio_sku_id2
- >;
-
- system = "binary";
- };
-
- board {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_brd_id0
- &gpio_brd_id1
- &gpio_brd_id2
- >;
-
- system = "binary_first_base3";
- };
-
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios =
- <&gpio5 1 0>,
- <&gpiod 0 0>,
- <&gpiof 3 0>,
- <&gpio0 4 0>,
- <&gpioc 0 0>,
- <&gpioa 7 0>,
- <&gpio8 3 0>,
- <&gpio8 1 0>,
- <&gpio3 7 0>,
- <&gpio7 6 0>,
- <&gpio3 4 0>,
- <&gpioc 5 0>,
- <&gpioa 3 0>,
- <&gpio7 3 0>,
- <&gpiod 7 0>,
- <&gpioa 5 0>,
- <&gpiob 0 0>,
- <&gpio9 4 0>,
- <&gpiob 1 0>,
- <&gpio6 2 0>,
- <&gpio3 5 0>,
- <&gpio9 7 0>,
- <&gpio6 0 0>,
- <&gpio7 2 0>;
- };
-};
diff --git a/zephyr/projects/trogdor/lazor/gpio_led.dts b/zephyr/projects/trogdor/lazor/gpio_led.dts
deleted file mode 100644
index c8c026506b..0000000000
--- a/zephyr/projects/trogdor/lazor/gpio_led.dts
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * 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: color-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&gpio_ec_chg_led_y_c1 0>,
- <&gpio_ec_chg_led_b_c1 0>;
- };
-
- color_amber: color-amber {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&gpio_ec_chg_led_y_c1 1>,
- <&gpio_ec_chg_led_b_c1 0>;
- };
-
- color_blue: color-blue {
- led-color = "LED_BLUE";
- led-id = "EC_LED_ID_BATTERY_LED";
- 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/keyboard.dts b/zephyr/projects/trogdor/lazor/keyboard.dts
deleted file mode 100644
index b8689b883c..0000000000
--- a/zephyr/projects/trogdor/lazor/keyboard.dts
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- cros-keyscan {
- compatible = "cros-keyscan";
-
- actual-key-mask = <
- 0x14 /* C0 */
- 0xff /* C1 */
- 0xff /* C2 */
- 0xff /* C3 */
- 0xff /* C4 */
- 0xf5 /* C5 */
- 0xff /* C6 */
- 0xa4 /* C7 */
- 0xff /* C8 */
- 0xfe /* C9 */
- 0x55 /* C10 */
- 0xfa /* C11 */
- 0xca /* C12 */
- >;
- };
-
- kblight {
- compatible = "cros-ec,kblight-pwm";
- pwms = <&pwm3 0 PWM_KHZ(10) PWM_POLARITY_NORMAL>;
- generic-pwm-channel = <0>;
- };
-};
-
-&pwm3 {
- status = "okay";
- pinctrl-0 = <&pwm3_gp80>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/trogdor/lazor/prj.conf b/zephyr/projects/trogdor/lazor/prj.conf
deleted file mode 100644
index 358de69d68..0000000000
--- a/zephyr/projects/trogdor/lazor/prj.conf
+++ /dev/null
@@ -1,164 +0,0 @@
-# Copyright 2021 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-#
-# Lazor actually has a NPCX7M6FC, but
-# the NPCX7M7FC is actually the same die, without the
-# extra RAM being tested. The code size really could
-# do with the extra space, so we pretend the EC is the
-# part with the larger RAM. YMMV.
-#
-CONFIG_SOC_NPCX7M7FC=y
-CONFIG_SOC_SERIES_NPCX7=y
-CONFIG_SHIMMED_TASKS=y
-CONFIG_PLATFORM_EC=y
-CONFIG_PLATFORM_EC_BRINGUP=y
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-CONFIG_PLATFORM_EC_SWITCH=y
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=y
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-
-# I2C
-CONFIG_I2C=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_DT=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-
-# Application Processor is Qualcomm SC7180
-CONFIG_AP_ARM_QUALCOMM_SC7180=y
-
-# Board version is selected over GPIO board ID pins.
-CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=y
-
-# LN9310 Switchcap
-CONFIG_PLATFORM_EC_SWITCHCAP_LN9310=y
-
-# Power Sequencing
-CONFIG_PLATFORM_EC_POWERSEQ=y
-CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y
-CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
-CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y
-CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y
-
-# Trogdor family does not use EFS2
-CONFIG_PLATFORM_EC_VBOOT_EFS2=n
-
-# MKBP event
-CONFIG_PLATFORM_EC_MKBP_EVENT=y
-CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD=y
-CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y
-CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
-CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
-CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
-CONFIG_PLATFORM_EC_CMD_BUTTON=y
-CONFIG_CROS_KB_RAW_NPCX=y
-
-# ADC
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
-# Battery
-CONFIG_PLATFORM_EC_BATTERY=y
-CONFIG_PLATFORM_EC_BATTERY_SMART=y
-CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y
-CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y
-CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
-CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
-CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
-CONFIG_PLATFORM_EC_CHARGER_ISL9238=y
-CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y
-CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY=y
-CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY="LION"
-CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y
-CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON=2
-CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=10000
-CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y
-CONFIG_PLATFORM_EC_CHARGER_PSYS=y
-CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20
-CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y
-
-# USB-A
-CONFIG_PLATFORM_EC_USBA=y
-
-# USB-C
-CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
-CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n
-CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y
-CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE=n
-CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y
-CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
-CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_REV30=n
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
-CONFIG_PLATFORM_EC_USB_PD_USB4=n
-CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_MULTI_PS8XXX=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8751=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805=y
-CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n
-CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=n
-CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
-
-# USB ID
-# This is allocated specifically for Trogdor
-# http://google3/hardware/standards/usb/
-# TODO(b/183608112): Move to device tree
-CONFIG_PLATFORM_EC_USB_PID=0x5043
-
-# RTC
-CONFIG_PLATFORM_EC_RTC=y
-CONFIG_CROS_RTC_NPCX=y
-CONFIG_PLATFORM_EC_HOSTCMD_RTC=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC=y
-
-# EC software sync
-CONFIG_PLATFORM_EC_VBOOT_HASH=y
-
-# Sensors
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y
-CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
-CONFIG_PLATFORM_EC_LID_ANGLE=y
-CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
-CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
-CONFIG_PLATFORM_EC_TABLET_MODE=y
-CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
-
-# Sensor Drivers
-CONFIG_PLATFORM_EC_ACCEL_BMA255=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI160=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
-
-# Console history
-CONFIG_SHELL_HISTORY=y
-CONFIG_SHELL_CMDS=y
-CONFIG_SHELL_HELP=n
-CONFIG_SHELL_MINIMAL=y
-
-# Taskinfo
-CONFIG_THREAD_MONITOR=y
-CONFIG_KERNEL_SHELL=y
-
-CONFIG_SYSCON=y
-
-# Features should be enabled. But the code RAM is not enough, disable them.
-#CONFIG_PLATFORM_EC_ACCEL_SPOOF_MODE=y
-#CONFIG_PLATFORM_EC_EMULATED_SYSRQ=y
diff --git a/zephyr/projects/trogdor/lazor/pwm_led.dts b/zephyr/projects/trogdor/lazor/pwm_led.dts
deleted file mode 100644
index 0582966d6a..0000000000
--- a/zephyr/projects/trogdor/lazor/pwm_led.dts
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- pwm_pins {
- compatible = "cros-ec,pwm-pin-config";
-
- pwm_y: pwm_y {
- #led-pin-cells = <1>;
- pwms = <&pwm0 0 PWM_HZ(324) PWM_POLARITY_NORMAL>;
- };
-
- pwm_b: pwm_b {
- #led-pin-cells = <1>;
- pwms = <&pwm2 0 PWM_HZ(324) PWM_POLARITY_NORMAL>;
- };
- };
-
- pwm-led-pins {
- compatible = "cros-ec,pwm-led-pins";
-
- color_off: color-off {
- led-color = "LED_OFF";
- led-id = "EC_LED_ID_BATTERY_LED";
- led-pins = <&pwm_y 0>,
- <&pwm_b 0>;
- };
-
- color_amber: color-amber {
- led-color = "LED_AMBER";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&pwm_y 100>,
- <&pwm_b 0>;
- };
-
- color_blue: color-blue {
- led-color = "LED_BLUE";
- led-id = "EC_LED_ID_BATTERY_LED";
- br-color = "EC_LED_COLOR_BLUE";
- led-pins = <&pwm_y 0>,
- <&pwm_b 100>;
- };
- };
-};
-
-&pwm0 {
- status = "okay";
- pinctrl-0 = <&pwm0_gpc3>;
- pinctrl-names = "default";
-};
-
-&pwm2 {
- status = "okay";
- pinctrl-0 = <&pwm2_gpc4>;
- pinctrl-names = "default";
-};
diff --git a/zephyr/projects/trogdor/lazor/src/i2c.c b/zephyr/projects/trogdor/lazor/src/i2c.c
deleted file mode 100644
index 6d737b410f..0000000000
--- a/zephyr/projects/trogdor/lazor/src/i2c.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c/i2c.h"
-#include "i2c.h"
-
-/* Lazor board specific i2c implementation */
-
-#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
-int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc)
-{
- return (i2c_get_device_for_port(cmd_desc->port) ==
- i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY));
-}
-#endif
diff --git a/zephyr/projects/trogdor/lazor/src/power.c b/zephyr/projects/trogdor/lazor/src/power.c
deleted file mode 100644
index 96f9bc43c5..0000000000
--- a/zephyr/projects/trogdor/lazor/src/power.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/init.h>
-#include <zephyr/drivers/gpio.h>
-
-#include <ap_power/ap_power.h>
-#include "power.h"
-#include "task.h"
-#include "gpio.h"
-
-static void board_power_change(struct ap_power_ev_callback *cb,
- struct ap_power_ev_data data)
-{
- switch (data.event) {
- default:
- return;
-
- case AP_POWER_PRE_INIT:
- /* Turn on the 3.3V rail */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp3300_a), 1);
-
- /* Turn on the 5V rail. */
-#ifdef CONFIG_POWER_PP5000_CONTROL
- power_5v_enable(task_get_current(), 1);
-#else /* !defined(CONFIG_POWER_PP5000_CONTROL) */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a), 1);
-#endif /* defined(CONFIG_POWER_PP5000_CONTROL) */
- break;
-
- case AP_POWER_SHUTDOWN_COMPLETE:
- /* Turn off the 5V rail. */
-#ifdef CONFIG_POWER_PP5000_CONTROL
- power_5v_enable(task_get_current(), 0);
-#else /* !defined(CONFIG_POWER_PP5000_CONTROL) */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a), 0);
-#endif /* defined(CONFIG_POWER_PP5000_CONTROL) */
-
- /* Turn off the 3.3V and 5V rails. */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp3300_a), 0);
- break;
- }
-}
-
-static int board_power_handler_init(const struct device *unused)
-{
- static struct ap_power_ev_callback cb;
-
- /* Setup a suspend/resume callback */
- ap_power_ev_init_callback(&cb, board_power_change,
- AP_POWER_PRE_INIT |
- AP_POWER_SHUTDOWN_COMPLETE);
- ap_power_ev_add_callback(&cb);
- return 0;
-}
-SYS_INIT(board_power_handler_init, APPLICATION, 1);
diff --git a/zephyr/projects/trogdor/lazor/src/sku.c b/zephyr/projects/trogdor/lazor/src/sku.c
deleted file mode 100644
index 1d88437031..0000000000
--- a/zephyr/projects/trogdor/lazor/src/sku.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "common.h"
-#include "config.h"
-#include "console.h"
-#include "driver/ln9310.h"
-#include "tcpm/ps8xxx_public.h"
-#include "hooks.h"
-#include "sku.h"
-#include "system.h"
-#include "util.h"
-
-#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-static uint8_t sku_id;
-
-enum board_model {
- LAZOR,
- LIMOZEEN,
- UNKNOWN,
-};
-
-static const char *const model_name[] = {
- "LAZOR",
- "LIMOZEEN",
- "UNKNOWN",
-};
-
-static enum board_model get_model(void)
-{
- if (sku_id == 0 || sku_id == 1 || sku_id == 2 || sku_id == 3)
- return LAZOR;
- if (sku_id == 4 || sku_id == 5 || sku_id == 6)
- return LIMOZEEN;
- return UNKNOWN;
-}
-
-/* Read SKU ID from GPIO and initialize variables for board variants */
-static void sku_init(void)
-{
- sku_id = system_get_sku_id();
- CPRINTS("SKU: %u (%s)", sku_id, model_name[get_model()]);
-}
-DECLARE_HOOK(HOOK_INIT, sku_init, HOOK_PRIO_POST_I2C);
-
-enum battery_cell_type board_get_battery_cell_type(void)
-{
- switch (get_model()) {
- case LIMOZEEN:
- return BATTERY_CELL_TYPE_3S;
- default:
- return BATTERY_CELL_TYPE_UNKNOWN;
- }
-}
-
-int board_is_clamshell(void)
-{
- return get_model() == LIMOZEEN;
-}
-
-__override uint16_t board_get_ps8xxx_product_id(int port)
-{
- /*
- * Lazor (SKU_ID: 0, 1, 2, 3) rev 3+ changes TCPC from PS8751 to
- * PS8805.
- *
- * Limozeen (SKU_ID: 4, 5, 6) all-rev uses PS8805.
- */
- if (get_model() == LAZOR && system_get_board_version() < 3)
- return PS8751_PRODUCT_ID;
-
- return PS8805_PRODUCT_ID;
-}
-
-int board_has_da9313(void)
-{
- return get_model() == LAZOR;
-}
-
-int board_has_buck_ic(void)
-{
- return get_model() == LIMOZEEN && system_get_board_version() >= 8;
-}
-
-int board_has_ln9310(void)
-{
- return get_model() == LIMOZEEN && system_get_board_version() < 8;
-}
diff --git a/zephyr/projects/trogdor/lazor/src/switchcap.c b/zephyr/projects/trogdor/lazor/src/switchcap.c
deleted file mode 100644
index d8205cbcfc..0000000000
--- a/zephyr/projects/trogdor/lazor/src/switchcap.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "common.h"
-#include "config.h"
-#include "console.h"
-#include "driver/ln9310.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "power/qcom.h"
-#include "system.h"
-#include "sku.h"
-
-#define CPRINTS(format, args...) cprints(CC_I2C, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_I2C, format, ##args)
-
-/* LN9310 switchcap */
-const struct ln9310_config_t ln9310_config = {
- .i2c_port = I2C_PORT_POWER,
- .i2c_addr_flags = LN9310_I2C_ADDR_0_FLAGS,
-};
-
-static void switchcap_init(void)
-{
- if (board_has_da9313()) {
- CPRINTS("Use switchcap: DA9313");
-
- /*
- * When the chip in power down mode, it outputs high-Z.
- * Set pull-down to avoid floating.
- */
- gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_da9313_gpio0),
- GPIO_INPUT | GPIO_PULL_DOWN);
-
- /*
- * Configure DA9313 enable, push-pull output. Don't set the
- * level here; otherwise, it will override its value and
- * shutdown the switchcap when sysjump to RW.
- */
- gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on),
- GPIO_OUTPUT);
- } else if (board_has_ln9310()) {
- CPRINTS("Use switchcap: LN9310");
-
- /* Enable interrupt for LN9310 */
- gpio_enable_dt_interrupt(
- GPIO_INT_FROM_NODELABEL(int_switchcap_pg));
-
- /*
- * Configure LN9310 enable, open-drain output. Don't set the
- * level here; otherwise, it will override its value and
- * shutdown the switchcap when sysjump to RW.
- *
- * Note that the gpio.inc configures it GPIO_OUT_LOW. When
- * sysjump to RW, will output push-pull a short period of
- * time. As it outputs LOW, should be fine.
- *
- * This GPIO changes like:
- * (1) EC boots from RO -> high-Z
- * (2) GPIO init according to gpio.inc -> push-pull LOW
- * (3) This function configures it -> open-drain HIGH
- * (4) Power sequence turns on the switchcap -> open-drain LOW
- * (5) EC sysjumps to RW
- * (6) GPIO init according to gpio.inc -> push-pull LOW
- * (7) This function configures it -> open-drain LOW
- */
- gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on),
- GPIO_OUTPUT | GPIO_OPEN_DRAIN);
-
- /* Only configure the switchcap if not sysjump */
- if (!system_jumped_late()) {
- /*
- * Deassert the enable pin, so the
- * switchcap won't be enabled after the switchcap is
- * configured from standby mode to switching mode.
- */
- gpio_pin_set_dt(
- GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), 0);
- ln9310_init();
- }
- } else if (board_has_buck_ic()) {
- CPRINTS("Use Buck IC");
- } else {
- CPRINTS("ERROR: No switchcap solution");
- }
-}
-DECLARE_HOOK(HOOK_INIT, switchcap_init, HOOK_PRIO_DEFAULT);
-
-void board_set_switchcap_power(int enable)
-{
- if (board_has_da9313()) {
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on),
- enable);
- } else if (board_has_ln9310()) {
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_switchcap_on),
- enable);
- ln9310_software_enable(enable);
- } else if (board_has_buck_ic()) {
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_vbob_en), enable);
- }
-}
-
-int board_is_switchcap_enabled(void)
-{
- if (board_has_da9313() || board_has_ln9310())
- return gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_switchcap_on));
-
- /* Board has buck ic*/
- return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_vbob_en));
-}
-
-int board_is_switchcap_power_good(void)
-{
- if (board_has_da9313())
- return gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_da9313_gpio0));
- else if (board_has_ln9310())
- return ln9310_power_good();
-
- /* Board has buck ic no way to check POWER GOOD */
- return 1;
-}
diff --git a/zephyr/projects/trogdor/lazor/src/usb_pd_policy.c b/zephyr/projects/trogdor/lazor/src/usb_pd_policy.c
deleted file mode 100644
index 8d046826f9..0000000000
--- a/zephyr/projects/trogdor/lazor/src/usb_pd_policy.c
+++ /dev/null
@@ -1,261 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/drivers/gpio.h>
-
-#include "charge_manager.h"
-#include "chipset.h"
-#include "console.h"
-#include "system.h"
-#include "usb_mux.h"
-#include "usbc_ppc.h"
-#include "util.h"
-
-#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-int pd_check_vconn_swap(int port)
-{
- /* In G3, do not allow vconn swap since PP5000 rail is off */
- return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a));
-}
-
-static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT];
-#if CONFIG_USB_PD_PORT_MAX_COUNT == 1
-static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = { TYPEC_RP_1A5 };
-#else
-static uint8_t vbus_rp[CONFIG_USB_PD_PORT_MAX_COUNT] = { TYPEC_RP_1A5,
- TYPEC_RP_1A5 };
-#endif
-
-static void board_vbus_update_source_current(int port)
-{
- /* Both port are controlled by PPC SN5S330. */
- ppc_set_vbus_source_current_limit(port, vbus_rp[port]);
- ppc_vbus_source_enable(port, vbus_en[port]);
-}
-
-void pd_power_supply_reset(int port)
-{
- int prev_en;
-
- prev_en = vbus_en[port];
-
- /* Disable VBUS */
- vbus_en[port] = 0;
- board_vbus_update_source_current(port);
-
- /* Enable discharge if we were previously sourcing 5V */
- if (prev_en)
- pd_set_vbus_discharge(port, 1);
-
- /* notify host of power info change */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-}
-
-int pd_set_power_supply_ready(int port)
-{
- /* Disable charging */
- board_vbus_sink_enable(port, 0);
-
- pd_set_vbus_discharge(port, 0);
-
- /* Provide VBUS */
- vbus_en[port] = 1;
- board_vbus_update_source_current(port);
-
- /* notify host of power info change */
- pd_send_host_event(PD_EVENT_POWER_CHANGE);
-
- return EC_SUCCESS; /* we are ready */
-}
-
-int board_vbus_source_enabled(int port)
-{
- return vbus_en[port];
-}
-
-__override void typec_set_source_current_limit(int port, enum tcpc_rp_value rp)
-{
- vbus_rp[port] = rp;
- board_vbus_update_source_current(port);
-}
-
-int pd_snk_is_vbus_provided(int port)
-{
- return tcpm_check_vbus_level(port, VBUS_PRESENT);
-}
-
-/* ----------------- Vendor Defined Messages ------------------ */
-#ifdef CONFIG_USB_PD_ALT_MODE_DFP
-__override int svdm_dp_config(int port, uint32_t *payload)
-{
- int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT);
- uint8_t pin_mode = get_dp_pin_mode(port);
-
- if (!pin_mode)
- return 0;
-
- /*
- * Defer setting the usb_mux until HPD goes high, svdm_dp_attention().
- * The AP only supports one DP phy. An external DP mux switches between
- * the two ports. Should switch those muxes when it is really used,
- * i.e. HPD high; otherwise, the real use case is preempted, like:
- * (1) plug a dongle without monitor connected to port-0,
- * (2) plug a dongle without monitor connected to port-1,
- * (3) plug a monitor to the port-1 dongle.
- */
-
- payload[0] =
- VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos));
- payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */
- 1, /* DPv1.3 signaling */
- 2); /* UFP connected */
- return 2;
-};
-
-__override void svdm_dp_post_config(int port)
-{
- dp_flags[port] |= DP_FLAGS_DP_ON;
-}
-
-/**
- * Is the port fine to be muxed its DisplayPort lines?
- *
- * Only one port can be muxed to DisplayPort at a time.
- *
- * @param port Port number of TCPC.
- * @return 1 is fine; 0 is bad as other port is already muxed;
- */
-static int is_dp_muxable(int port)
-{
- int i;
-
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++)
- if (i != port) {
- if (usb_mux_get(i) & USB_PD_MUX_DP_ENABLED)
- return 0;
- }
-
- return 1;
-}
-
-__override int svdm_dp_attention(int port, uint32_t *payload)
-{
- const struct gpio_dt_spec *hpd =
- GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det);
- int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]);
- int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]);
- int cur_lvl = gpio_pin_get_dt(hpd);
- mux_state_t mux_state;
-
- dp_status[port] = payload[1];
-
- if (!is_dp_muxable(port)) {
- /* TODO(waihong): Info user? */
- CPRINTS("p%d: The other port is already muxed.", port);
- return 0;
- }
-
- /*
- * Initial implementation to handle HPD. Only the first-plugged port
- * works, i.e. sending HPD signal to AP. The second-plugged port
- * will be ignored.
- *
- * TODO(waihong): Continue the above case, if the first-plugged port
- * is then unplugged, switch to the second-plugged port and signal AP?
- */
- if (lvl) {
- /*
- * Enable and switch the DP port selection mux to the
- * correct port.
- *
- * TODO(waihong): Better to move switching DP mux to
- * the usb_mux abstraction.
- */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel),
- port == 1);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 0);
-
- /* Connect the SBU lines in PPC chip. */
- if (IS_ENABLED(CONFIG_USBC_PPC_SBU))
- ppc_set_sbu(port, 1);
-
- /*
- * Connect the USB SS/DP lines in TCPC chip.
- *
- * When mf_pref not true, still use the dock muxing
- * because of the board USB-C topology (limited to 2
- * lanes DP).
- */
- usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT,
- polarity_rm_dts(pd_get_polarity(port)));
- } else {
- /* Disconnect the DP port selection mux. */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0);
-
- /* Disconnect the SBU lines in PPC chip. */
- if (IS_ENABLED(CONFIG_USBC_PPC_SBU))
- ppc_set_sbu(port, 0);
-
- /* Disconnect the DP but keep the USB SS lines in TCPC chip. */
- usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT,
- polarity_rm_dts(pd_get_polarity(port)));
- }
-
- if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl))
- /*
- * Wake up the AP. IRQ or level high indicates a DP sink is now
- * present.
- */
- pd_notify_dp_alt_mode_entry(port);
-
- /* Configure TCPC for the HPD event, for proper muxing */
- mux_state = (lvl ? USB_PD_MUX_HPD_LVL : USB_PD_MUX_HPD_LVL_DEASSERTED) |
- (irq ? USB_PD_MUX_HPD_IRQ : USB_PD_MUX_HPD_IRQ_DEASSERTED);
- usb_mux_hpd_update(port, mux_state);
-
- /* Signal AP for the HPD event, through GPIO to AP */
- if (irq & cur_lvl) {
- uint64_t now = get_time().val;
- /* Wait for the minimum spacing between IRQ_HPD if needed */
- if (now < svdm_hpd_deadline[port])
- usleep(svdm_hpd_deadline[port] - now);
-
- /* Generate IRQ_HPD pulse */
- gpio_pin_set_dt(hpd, 0);
- usleep(HPD_DSTREAM_DEBOUNCE_IRQ);
- gpio_pin_set_dt(hpd, 1);
-
- /* Set the minimum time delay (2ms) for the next HPD IRQ */
- svdm_hpd_deadline[port] =
- get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
- } else if (irq & !lvl) {
- CPRINTF("ERR:HPD:IRQ&LOW\n");
- return 0;
- }
- gpio_pin_set_dt(hpd, lvl);
- /* Set the minimum time delay (2ms) for the next HPD IRQ */
- svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL;
-
- return 1;
-}
-
-__override void svdm_exit_dp_mode(int port)
-{
- if (is_dp_muxable(port)) {
- /* Disconnect the DP port selection mux. */
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0);
-
- /* Signal AP for the HPD low event */
- usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det),
- 0);
- }
-}
-#endif /* CONFIG_USB_PD_ALT_MODE_DFP */
diff --git a/zephyr/projects/trogdor/lazor/src/usbc_config.c b/zephyr/projects/trogdor/lazor/src/usbc_config.c
deleted file mode 100644
index f6bfdfb186..0000000000
--- a/zephyr/projects/trogdor/lazor/src/usbc_config.c
+++ /dev/null
@@ -1,335 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Lazor board-specific USB-C configuration */
-
-#include "battery_fuel_gauge.h"
-#include "bc12/pi3usb9201_public.h"
-#include "charger.h"
-#include "charger/isl923x_public.h"
-#include "charge_manager.h"
-#include "charge_state.h"
-#include "common.h"
-#include "config.h"
-#include "driver/ln9310.h"
-#include "gpio_signal.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-#include "ppc/sn5s330_public.h"
-#include "system.h"
-#include "tcpm/ps8xxx_public.h"
-#include "tcpm/tcpci.h"
-#include "timer.h"
-#include "usb_pd.h"
-#include "usb_mux.h"
-#include "usbc_ocp.h"
-#include "usbc_ppc.h"
-
-#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args)
-#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args)
-
-int charger_profile_override(struct charge_state_data *curr)
-{
- int usb_mv;
- int port;
-
- if (curr->state != ST_CHARGE)
- return 0;
-
- /* Lower the max requested voltage to 5V when battery is full. */
- if (chipset_in_state(CHIPSET_STATE_ANY_OFF) &&
- !(curr->batt.flags & BATT_FLAG_BAD_STATUS) &&
- !(curr->batt.flags & BATT_FLAG_WANT_CHARGE) &&
- (curr->batt.status & STATUS_FULLY_CHARGED))
- usb_mv = 5000;
- else
- usb_mv = PD_MAX_VOLTAGE_MV;
-
- if (pd_get_max_voltage() != usb_mv) {
- CPRINTS("VBUS limited to %dmV", usb_mv);
- for (port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; port++)
- pd_set_external_voltage_limit(port, usb_mv);
- }
-
- return 0;
-}
-
-enum ec_status charger_profile_override_get_param(uint32_t param,
- uint32_t *value)
-{
- return EC_RES_INVALID_PARAM;
-}
-
-enum ec_status charger_profile_override_set_param(uint32_t param,
- uint32_t value)
-{
- return EC_RES_INVALID_PARAM;
-}
-
-static void usba_oc_deferred(void)
-{
- /* Use next number after all USB-C ports to indicate the USB-A port */
- board_overcurrent_event(
- CONFIG_USB_PD_PORT_MAX_COUNT,
- !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_a0_oc_odl)));
-}
-DECLARE_DEFERRED(usba_oc_deferred);
-
-void usba_oc_interrupt(enum gpio_signal signal)
-{
- hook_call_deferred(&usba_oc_deferred_data, 0);
-}
-
-void ppc_interrupt(enum gpio_signal signal)
-{
- switch (signal) {
- case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_swctl_int_odl)):
- sn5s330_interrupt(0);
- break;
- case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c1_swctl_int_odl)):
- sn5s330_interrupt(1);
- break;
- default:
- break;
- }
-}
-
-static void board_connect_c0_sbu_deferred(void)
-{
- /*
- * If CCD_MODE_ODL asserts, it means there's a debug accessory connected
- * and we should enable the SBU FETs.
- */
- ppc_set_sbu(0, 1);
-}
-DECLARE_DEFERRED(board_connect_c0_sbu_deferred);
-
-void board_connect_c0_sbu(enum gpio_signal s)
-{
- hook_call_deferred(&board_connect_c0_sbu_deferred_data, 0);
-}
-
-/* GPIO Interrupt Handlers */
-void tcpc_alert_event(enum gpio_signal signal)
-{
- int port = -1;
-
- switch (signal) {
- case GPIO_USB_C0_PD_INT_ODL:
- port = 0;
- break;
- case GPIO_USB_C1_PD_INT_ODL:
- port = 1;
- break;
- default:
- return;
- }
-
- schedule_deferred_pd_interrupt(port);
-}
-
-/*
- * Port-0/1 USB mux driver.
- *
- * The USB mux is handled by TCPC chip and the HPD update is through a GPIO
- * to AP. But the TCPC chip is also needed to know the HPD status; otherwise,
- * the mux misbehaves.
- */
-const struct usb_mux_chain usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .mux =
- &(const struct usb_mux){
- .usb_port = 0,
- .driver = &tcpci_tcpm_usb_mux_driver,
- .hpd_update = &ps8xxx_tcpc_update_hpd_status,
- },
- },
- {
- .mux =
- &(const struct usb_mux){
- .usb_port = 1,
- .driver = &tcpci_tcpm_usb_mux_driver,
- .hpd_update = &ps8xxx_tcpc_update_hpd_status,
- },
- }
-};
-
-__override int board_get_default_battery_type(void)
-{
- /*
- * A 2S battery is set as default. If the board is configured to use
- * a 3S battery, according to its SKU_ID, return a 3S battery as
- * default. It helps to configure the charger to output a correct
- * voltage in case the battery is not attached.
- */
- if (board_get_battery_cell_type() == BATTERY_CELL_TYPE_3S)
- return BATTERY_LGC_AP18C8K;
-
- return DEFAULT_BATTERY_TYPE;
-}
-
-/* Initialize board USC-C things */
-static void board_init_usbc(void)
-{
- /* Enable USB-A overcurrent interrupt */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_oc));
- /*
- * The H1 SBU line for CCD are behind PPC chip. The PPC internal FETs
- * for SBU may be disconnected after DP alt mode is off. Should enable
- * the CCD_MODE_ODL interrupt to make sure the SBU FETs are connected.
- */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode));
-}
-DECLARE_HOOK(HOOK_INIT, board_init_usbc, HOOK_PRIO_DEFAULT);
-
-void board_tcpc_init(void)
-{
- /* Only reset TCPC if not sysjump */
- if (!system_jumped_late()) {
- /* TODO(crosbug.com/p/61098): How long do we need to wait? */
- board_reset_pd_mcu();
- }
-
- /* Enable PPC interrupts */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_swctl));
-
- /* Enable TCPC interrupts */
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc));
- gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc));
-
- /*
- * Initialize HPD to low; after sysjump SOC needs to see
- * HPD pulse to enable video path
- */
- for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port)
- usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED |
- USB_PD_MUX_HPD_IRQ_DEASSERTED);
-}
-DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C);
-
-void board_reset_pd_mcu(void)
-{
- cprints(CC_USB, "Resetting TCPCs...");
- cflush();
-
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 0);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 0);
- msleep(PS8XXX_RESET_DELAY_MS);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 1);
- gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 1);
-}
-
-void board_set_tcpc_power_mode(int port, int mode)
-{
- /* Ignore the "mode" to turn the chip on. We can only do a reset. */
- if (mode)
- return;
-
- board_reset_pd_mcu();
-}
-
-int board_vbus_sink_enable(int port, int enable)
-{
- /* Both ports are controlled by PPC SN5S330 */
- return ppc_vbus_sink_enable(port, enable);
-}
-
-int board_is_sourcing_vbus(int port)
-{
- /* Both ports are controlled by PPC SN5S330 */
- return ppc_is_sourcing_vbus(port);
-}
-
-void board_overcurrent_event(int port, int is_overcurrented)
-{
- /* TODO(b/120231371): Notify AP */
- CPRINTS("p%d: overcurrent!", port);
-}
-
-int board_set_active_charge_port(int port)
-{
- int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
- int i;
-
- if (!is_real_port && port != CHARGE_PORT_NONE)
- return EC_ERROR_INVAL;
-
- if (port == CHARGE_PORT_NONE) {
- CPRINTS("Disabling all charging port");
-
- /* Disable all ports. */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- /*
- * Do not return early if one fails otherwise we can
- * get into a boot loop assertion failure.
- */
- if (board_vbus_sink_enable(i, 0))
- CPRINTS("Disabling p%d sink path failed.", i);
- }
-
- return EC_SUCCESS;
- }
-
- /* Check if the port is sourcing VBUS. */
- if (board_is_sourcing_vbus(port)) {
- CPRINTS("Skip enable p%d", port);
- return EC_ERROR_INVAL;
- }
-
- CPRINTS("New charge port: p%d", port);
-
- /*
- * Turn off the other ports' sink path FETs, before enabling the
- * requested charge port.
- */
- for (i = 0; i < CONFIG_USB_PD_PORT_MAX_COUNT; i++) {
- if (i == port)
- continue;
-
- if (board_vbus_sink_enable(i, 0))
- CPRINTS("p%d: sink path disable failed.", i);
- }
-
- /* Enable requested charge port. */
- if (board_vbus_sink_enable(port, 1)) {
- CPRINTS("p%d: sink path enable failed.", port);
- return EC_ERROR_UNKNOWN;
- }
-
- return EC_SUCCESS;
-}
-
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- /*
- * Ignore lower charge ceiling on PD transition if our battery is
- * critical, as we may brownout.
- */
- if (supplier == CHARGE_SUPPLIER_PD && charge_ma < 1500 &&
- charge_get_percent() < CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON) {
- CPRINTS("Using max ilim %d", max_ma);
- charge_ma = max_ma;
- }
-
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- uint16_t status = 0;
-
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl)))
- if (gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l)))
- status |= PD_STATUS_TCPC_ALERT_0;
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl)))
- if (gpio_pin_get_dt(
- GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l)))
- status |= PD_STATUS_TCPC_ALERT_1;
-
- return status;
-}
diff --git a/zephyr/shim/chip/it8xxx2/clock.c b/zephyr/shim/chip/it8xxx2/clock.c
index 14dbc0e7eb..a4df87dc1d 100644
--- a/zephyr/shim/chip/it8xxx2/clock.c
+++ b/zephyr/shim/chip/it8xxx2/clock.c
@@ -3,15 +3,16 @@
* found in the LICENSE file.
*/
+#include "module_id.h"
+
#include <zephyr/device.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
-#include <soc.h>
-#include <soc/ite_it8xxx2/reg_def_cros.h>
#include <zephyr/sys/util.h>
-#include "module_id.h"
+#include <soc.h>
+#include <soc/ite_it8xxx2/reg_def_cros.h>
LOG_MODULE_REGISTER(shim_clock, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/chip/it8xxx2/gpio.c b/zephyr/shim/chip/it8xxx2/gpio.c
index 7106b2a294..16eb7a3963 100644
--- a/zephyr/shim/chip/it8xxx2/gpio.c
+++ b/zephyr/shim/chip/it8xxx2/gpio.c
@@ -3,14 +3,13 @@
* found in the LICENSE file.
*/
+#include "gpio/gpio.h"
+
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
-
#include <zephyr/logging/log.h>
-#include "gpio/gpio.h"
-
LOG_MODULE_REGISTER(shim_cros_gpio, LOG_LEVEL_ERR);
static const struct unused_pin_config unused_pin_configs[] = {
diff --git a/zephyr/shim/chip/it8xxx2/keyboard_raw.c b/zephyr/shim/chip/it8xxx2/keyboard_raw.c
index 0a117cda14..5fe99b7efa 100644
--- a/zephyr/shim/chip/it8xxx2/keyboard_raw.c
+++ b/zephyr/shim/chip/it8xxx2/keyboard_raw.c
@@ -5,13 +5,14 @@
/* Functions needed by keyboard scanner module for Chrome EC */
+#include "drivers/cros_kb_raw.h"
+#include "keyboard_raw.h"
+
#include <zephyr/device.h>
-#include <zephyr/logging/log.h>
-#include <soc.h>
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
-#include "drivers/cros_kb_raw.h"
-#include "keyboard_raw.h"
+#include <soc.h>
/**
* Return true if the current value of the given input GPIO port is zero
diff --git a/zephyr/shim/chip/it8xxx2/power_policy.c b/zephyr/shim/chip/it8xxx2/power_policy.c
index c8efb0ca96..c6e73d53a4 100644
--- a/zephyr/shim/chip/it8xxx2/power_policy.c
+++ b/zephyr/shim/chip/it8xxx2/power_policy.c
@@ -3,12 +3,13 @@
* found in the LICENSE file.
*/
+#include "system.h"
+
+#include <zephyr/kernel.h>
#include <zephyr/pm/pm.h>
#include <zephyr/pm/policy.h>
-#include <soc.h>
-#include <zephyr/kernel.h>
-#include "system.h"
+#include <soc.h>
static const struct pm_state_info pm_states[] =
PM_STATE_INFO_LIST_FROM_DT_CPU(DT_NODELABEL(cpu0));
diff --git a/zephyr/shim/chip/mchp/clock.c b/zephyr/shim/chip/mchp/clock.c
index 6ee4cd931c..5fb39bfd43 100644
--- a/zephyr/shim/chip/mchp/clock.c
+++ b/zephyr/shim/chip/mchp/clock.c
@@ -3,15 +3,16 @@
* found in the LICENSE file.
*/
+#include "clock_chip.h"
+#include "module_id.h"
+
#include <zephyr/device.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/dt-bindings/clock/mchp_xec_pcr.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
-#include <soc.h>
-#include "clock_chip.h"
-#include "module_id.h"
+#include <soc.h>
LOG_MODULE_REGISTER(shim_clock, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/chip/mchp/gpio.c b/zephyr/shim/chip/mchp/gpio.c
index 7801c6f7cc..d772a566d8 100644
--- a/zephyr/shim/chip/mchp/gpio.c
+++ b/zephyr/shim/chip/mchp/gpio.c
@@ -3,11 +3,12 @@
* found in the LICENSE file.
*/
+#include "gpio/gpio.h"
+
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
-#include "gpio/gpio.h"
LOG_MODULE_REGISTER(shim_cros_gpio, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/chip/mchp/keyboard_raw.c b/zephyr/shim/chip/mchp/keyboard_raw.c
index 95ad642d12..9183e4d7dd 100644
--- a/zephyr/shim/chip/mchp/keyboard_raw.c
+++ b/zephyr/shim/chip/mchp/keyboard_raw.c
@@ -5,13 +5,14 @@
/* Functions needed by keyboard scanner module for Chrome EC */
+#include "drivers/cros_kb_raw.h"
+#include "keyboard_raw.h"
+
#include <zephyr/device.h>
-#include <zephyr/logging/log.h>
-#include <soc.h>
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
-#include "drivers/cros_kb_raw.h"
-#include "keyboard_raw.h"
+#include <soc.h>
/**
* Return true if the current value of the given input GPIO port is zero
diff --git a/zephyr/shim/chip/mchp/system.c b/zephyr/shim/chip/mchp/system.c
index 35ba806533..6e5da9aa80 100644
--- a/zephyr/shim/chip/mchp/system.c
+++ b/zephyr/shim/chip/mchp/system.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/bbram.h>
-#include <zephyr/logging/log.h>
-
#include "system.h"
#include "system_chip.h"
+#include <zephyr/drivers/bbram.h>
+#include <zephyr/logging/log.h>
+
LOG_MODULE_REGISTER(shim_xec_system, LOG_LEVEL_ERR);
#define GET_BBRAM_OFS(node) DT_PROP(DT_PATH(named_bbram_regions, node), offset)
diff --git a/zephyr/shim/chip/mchp/system_download_from_flash.c b/zephyr/shim/chip/mchp/system_download_from_flash.c
index 51cdc5aab6..8f6304274f 100644
--- a/zephyr/shim/chip/mchp/system_download_from_flash.c
+++ b/zephyr/shim/chip/mchp/system_download_from_flash.c
@@ -2,13 +2,14 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <zephyr/dt-bindings/clock/npcx_clock.h>
-#include <stdnoreturn.h>
-
#include "common.h"
#include "soc.h"
#include "system_chip.h"
+#include <zephyr/dt-bindings/clock/npcx_clock.h>
+
+#include <stdnoreturn.h>
+
/* Modules Map */
#define WDT_NODE DT_INST(0, microchip_xec_watchdog)
#define STRUCT_WDT_REG_BASE_ADDR ((struct wdt_regs *)(DT_REG_ADDR(WDT_NODE)))
diff --git a/zephyr/shim/chip/mchp/system_external_storage.c b/zephyr/shim/chip/mchp/system_external_storage.c
index 4250b05fe3..5887e045a4 100644
--- a/zephyr/shim/chip/mchp/system_external_storage.c
+++ b/zephyr/shim/chip/mchp/system_external_storage.c
@@ -3,15 +3,16 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/bbram.h>
-#include <soc.h>
-
#include "clock_chip.h"
#include "common.h"
+#include "config_chip.h"
#include "system.h"
#include "system_chip.h"
-#include "config_chip.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/bbram.h>
+
+#include <soc.h>
#define MCHP_ECRO_WORD 0x4F524345u /* ASCII ECRO */
#define MCHP_ECRW_WORD 0x57524345u /* ASCII ECRW */
diff --git a/zephyr/shim/chip/npcx/clock.c b/zephyr/shim/chip/npcx/clock.c
index fc483ef775..2a6fe27ef4 100644
--- a/zephyr/shim/chip/npcx/clock.c
+++ b/zephyr/shim/chip/npcx/clock.c
@@ -3,15 +3,16 @@
* found in the LICENSE file.
*/
+#include "clock_chip.h"
+#include "module_id.h"
+
#include <zephyr/device.h>
#include <zephyr/drivers/clock_control.h>
#include <zephyr/dt-bindings/clock/npcx_clock.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
-#include <soc.h>
-#include "clock_chip.h"
-#include "module_id.h"
+#include <soc.h>
LOG_MODULE_REGISTER(shim_clock, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/chip/npcx/gpio.c b/zephyr/shim/chip/npcx/gpio.c
index 850123e17b..1d51c00f61 100644
--- a/zephyr/shim/chip/npcx/gpio.c
+++ b/zephyr/shim/chip/npcx/gpio.c
@@ -3,16 +3,15 @@
* found in the LICENSE file.
*/
+#include "gpio/gpio.h"
+#include "soc_gpio.h"
+#include "util.h"
+
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
-#include <zephyr/shell/shell.h>
-
#include <zephyr/logging/log.h>
-
-#include "gpio/gpio.h"
-#include "soc_gpio.h"
-#include "util.h"
+#include <zephyr/shell/shell.h>
LOG_MODULE_REGISTER(shim_cros_gpio, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/chip/npcx/keyboard_raw.c b/zephyr/shim/chip/npcx/keyboard_raw.c
index 4d43134482..1f01952ab9 100644
--- a/zephyr/shim/chip/npcx/keyboard_raw.c
+++ b/zephyr/shim/chip/npcx/keyboard_raw.c
@@ -5,15 +5,16 @@
/* Functions needed by keyboard scanner module for Chrome EC */
+#include "drivers/cros_kb_raw.h"
+#include "keyboard_raw.h"
+
#include <zephyr/device.h>
#include <zephyr/drivers/gpio.h>
+#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
+
#include <soc.h>
#include <soc_gpio.h>
-#include <zephyr/kernel.h>
-
-#include "drivers/cros_kb_raw.h"
-#include "keyboard_raw.h"
/**
* Return true if the current value of the given input GPIO port is zero
diff --git a/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c b/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c
index e3fecc0cbd..3062ed98a4 100644
--- a/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c
+++ b/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c
@@ -5,12 +5,14 @@
* NPCX SoC spi flash update tool - monitor firmware
*/
-#include <stdint.h>
-#include <zephyr/sys/util.h>
#include "config_chip.h"
#include "npcx_monitor.h"
#include "registers.h"
+#include <stdint.h>
+
+#include <zephyr/sys/util.h>
+
/*
* TODO(b/197162681): This was copied from chip/npcx/spiflashfw but this
* needs to be moved to Zephyr upstream
diff --git a/zephyr/shim/chip/npcx/power_policy.c b/zephyr/shim/chip/npcx/power_policy.c
index aea6e62d30..29ebcbd542 100644
--- a/zephyr/shim/chip/npcx/power_policy.c
+++ b/zephyr/shim/chip/npcx/power_policy.c
@@ -3,14 +3,15 @@
* found in the LICENSE file.
*/
+#include "console.h"
+#include "cros_version.h"
+#include "system.h"
+
#include <zephyr/kernel.h>
#include <zephyr/pm/pm.h>
#include <zephyr/pm/policy.h>
-#include <soc.h>
-#include "console.h"
-#include "cros_version.h"
-#include "system.h"
+#include <soc.h>
static const struct pm_state_info residency_info[] =
PM_STATE_INFO_LIST_FROM_DT_CPU(DT_NODELABEL(cpu0));
diff --git a/zephyr/shim/chip/npcx/shi.c b/zephyr/shim/chip/npcx/shi.c
index 8bec57252d..0cecc2c56e 100644
--- a/zephyr/shim/chip/npcx/shi.c
+++ b/zephyr/shim/chip/npcx/shi.c
@@ -5,19 +5,20 @@
/* Functions needed by Serial Host Interface module for Chrome EC */
-#include <zephyr/device.h>
-#include <zephyr/dt-bindings/clock/npcx_clock.h>
-#include <zephyr/logging/log.h>
-#include <soc.h>
-#include <zephyr/kernel.h>
-
-#include <ap_power/ap_power.h>
#include "chipset.h"
#include "drivers/cros_shi.h"
#include "hooks.h"
#include "host_command.h"
#include "system.h"
+#include <zephyr/device.h>
+#include <zephyr/dt-bindings/clock/npcx_clock.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
+#include <ap_power/ap_power.h>
+#include <soc.h>
+
LOG_MODULE_REGISTER(shim_cros_shi, LOG_LEVEL_DBG);
#define SHI_NODE DT_NODELABEL(shi)
diff --git a/zephyr/shim/chip/npcx/system.c b/zephyr/shim/chip/npcx/system.c
index 2240acea54..1fbdca0803 100644
--- a/zephyr/shim/chip/npcx/system.c
+++ b/zephyr/shim/chip/npcx/system.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/bbram.h>
-#include <zephyr/logging/log.h>
-
#include "system.h"
#include "system_chip.h"
+#include <zephyr/drivers/bbram.h>
+#include <zephyr/logging/log.h>
+
LOG_MODULE_REGISTER(shim_npcx_system, LOG_LEVEL_ERR);
static void chip_bbram_status_check(void)
diff --git a/zephyr/shim/chip/npcx/system_download_from_flash.c b/zephyr/shim/chip/npcx/system_download_from_flash.c
index 1aef9560d1..53e22d4839 100644
--- a/zephyr/shim/chip/npcx/system_download_from_flash.c
+++ b/zephyr/shim/chip/npcx/system_download_from_flash.c
@@ -2,14 +2,15 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <zephyr/dt-bindings/clock/npcx_clock.h>
-#include <stdnoreturn.h>
-#include <zephyr/sys/__assert.h>
-
#include "common.h"
#include "soc.h"
#include "system_chip.h"
+#include <zephyr/dt-bindings/clock/npcx_clock.h>
+#include <zephyr/sys/__assert.h>
+
+#include <stdnoreturn.h>
+
/* Modules Map */
#define NPCX_PMC_BASE_ADDR 0x4000D000
#define NPCX_GDMA_BASE_ADDR 0x40011000
diff --git a/zephyr/shim/chip/npcx/system_external_storage.c b/zephyr/shim/chip/npcx/system_external_storage.c
index 81e1968cf4..d3b2d26362 100644
--- a/zephyr/shim/chip/npcx/system_external_storage.c
+++ b/zephyr/shim/chip/npcx/system_external_storage.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/syscon.h>
-
#include "clock_chip.h"
#include "common.h"
#include "rom_chip.h"
#include "system.h"
#include "system_chip.h"
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/syscon.h>
+
/* TODO (b:179900857) Make this implementation not npcx specific. */
static const struct device *mdc_dev = DEVICE_DT_GET(DT_NODELABEL(mdc));
diff --git a/zephyr/shim/core/cortex-m/irq_command.c b/zephyr/shim/core/cortex-m/irq_command.c
index 1cf1a213e4..651f804800 100644
--- a/zephyr/shim/core/cortex-m/irq_command.c
+++ b/zephyr/shim/core/cortex-m/irq_command.c
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
#include "console.h"
+#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
+
/* IRQ counters */
int irq_count[CONFIG_NUM_IRQS];
diff --git a/zephyr/shim/core/cortex-m/mpu.c b/zephyr/shim/core/cortex-m/mpu.c
index 8025227700..601961225c 100644
--- a/zephyr/shim/core/cortex-m/mpu.c
+++ b/zephyr/shim/core/cortex-m/mpu.c
@@ -3,13 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
-#include <zephyr/arch/cpu.h>
-#include <zephyr/init.h>
-
#include "config.h"
#include "mpu.h"
+#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
+#include <zephyr/arch/cpu.h>
+#include <zephyr/init.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(shim_mpu, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/include/board_led.h b/zephyr/shim/include/board_led.h
index 074ffa0256..ae4b23d74e 100644
--- a/zephyr/shim/include/board_led.h
+++ b/zephyr/shim/include/board_led.h
@@ -6,6 +6,10 @@
#ifndef __BOARD_LED_H
#define __BOARD_LED_H
+#include <stdint.h>
+
+#include <zephyr/drivers/pwm.h>
+
struct board_led_pwm_dt_channel {
const struct device *dev;
uint32_t channel;
diff --git a/zephyr/shim/include/charger/chg_isl923x.h b/zephyr/shim/include/charger/chg_isl923x.h
index b0323cd1b8..9156e574de 100644
--- a/zephyr/shim/include/charger/chg_isl923x.h
+++ b/zephyr/shim/include/charger/chg_isl923x.h
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
#include "driver/charger/isl923x_public.h"
+#include <zephyr/devicetree.h>
+
#define ISL923X_CHG_COMPAT intersil_isl923x
#define ISL923X_EMUL_COMPAT cros_isl923x_emul
diff --git a/zephyr/shim/include/charger/chg_isl9241.h b/zephyr/shim/include/charger/chg_isl9241.h
index 711a581c2f..c6d2239038 100644
--- a/zephyr/shim/include/charger/chg_isl9241.h
+++ b/zephyr/shim/include/charger/chg_isl9241.h
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
#include "driver/charger/isl9241_public.h"
+#include <zephyr/devicetree.h>
+
#define ISL9241_CHG_COMPAT intersil_isl9241
#define CHG_CONFIG_ISL9241(id) \
diff --git a/zephyr/shim/include/charger/chg_rt9490.h b/zephyr/shim/include/charger/chg_rt9490.h
index 3ac596d482..44d81eac48 100644
--- a/zephyr/shim/include/charger/chg_rt9490.h
+++ b/zephyr/shim/include/charger/chg_rt9490.h
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
#include "driver/charger/rt9490.h"
+#include <zephyr/devicetree.h>
+
#define RT9490_CHG_COMPAT richtek_rt9490
#define RT9490_EMUL_COMPAT zephyr_rt9490_emul
diff --git a/zephyr/shim/include/charger/chg_sm5803.h b/zephyr/shim/include/charger/chg_sm5803.h
index 65ef066970..853dd06a63 100644
--- a/zephyr/shim/include/charger/chg_sm5803.h
+++ b/zephyr/shim/include/charger/chg_sm5803.h
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
#include "driver/charger/sm5803.h"
+#include <zephyr/devicetree.h>
+
#define SM5803_CHG_COMPAT siliconmitus_sm5803
#define CHG_CONFIG_SM5803(id) \
diff --git a/zephyr/shim/include/charger_chips.h b/zephyr/shim/include/charger_chips.h
index b24fa246bf..503a53330d 100644
--- a/zephyr/shim/include/charger_chips.h
+++ b/zephyr/shim/include/charger_chips.h
@@ -7,6 +7,7 @@
#define __CROS_EC_CHARGER_CHIPS_H
#include "charger.h"
+
#include <zephyr/devicetree.h>
extern const struct charger_config_t chg_chips_alt[];
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
index 7c63ca31f9..28a93739c5 100644
--- a/zephyr/shim/include/config_chip.h
+++ b/zephyr/shim/include/config_chip.h
@@ -15,6 +15,8 @@
#line 16
#include <zephyr/devicetree.h>
+#include <zephyr/toolchain.h>
+
#include <autoconf.h>
#define SENSOR_NODE DT_PATH(motionsense_sensor)
@@ -312,6 +314,11 @@
#ifdef CONFIG_PLATFORM_EC_OCPC
#define CONFIG_OCPC
#define CONFIG_OCPC_DEF_RBATT_MOHMS CONFIG_PLATFORM_EC_OCPC_DEF_RBATT_MOHMS
+#ifdef CONFIG_PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS
+#undef CONFIG_OCPC_DEF_DRIVELIMIT_MILLIVOLTS
+#define CONFIG_OCPC_DEF_DRIVELIMIT_MILLIVOLTS \
+ CONFIG_PLATFORM_EC_OCPC_DEF_DRIVELIMIT_MILLIVOLTS
+#endif
#endif
#undef CONFIG_CHARGER_SINGLE_CHIP
@@ -488,17 +495,23 @@
/* The jump data goes at the end of data ram, so for posix, the end of ram is
* wherever the jump data ended up.
*/
-#include "sysjump.h"
-extern char mock_jump_data[sizeof(struct jump_data) + 256];
+extern char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
#define CONFIG_RAM_BASE 0x0
-#define CONFIG_DATA_RAM_SIZE \
- (((uintptr_t)&mock_jump_data) + sizeof(mock_jump_data))
+#define CONFIG_DATA_RAM_SIZE \
+ (((uintptr_t)&mock_jump_data) + \
+ CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE)
#else
#error "A zephyr,sram device must be chosen in the device tree"
#endif
#define CONFIG_RAM_SIZE CONFIG_DATA_RAM_SIZE
+#undef CONFIG_PRESERVED_END_OF_RAM_SIZE
+#ifdef CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE
+#define CONFIG_PRESERVED_END_OF_RAM_SIZE \
+ CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE
+#endif
+
#define CONFIG_RO_MEM_OFF CONFIG_CROS_EC_RO_MEM_OFF
#define CONFIG_RO_MEM_SIZE CONFIG_CROS_EC_RO_MEM_SIZE
#define CONFIG_RW_MEM_OFF CONFIG_CROS_EC_RW_MEM_OFF
@@ -636,6 +649,11 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256];
#define CONFIG_FAN_BYPASS_SLOW_RESPONSE
#endif
+#undef CONFIG_CUSTOM_FAN_CONTROL
+#ifdef CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL
+#define CONFIG_CUSTOM_FAN_CONTROL
+#endif
+
#ifdef CONFIG_PLATFORM_EC_I2C
/* Also see shim/include/i2c/i2c.h which defines the ports enum */
#define CONFIG_I2C_CONTROLLER
@@ -711,6 +729,11 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256];
#define CONFIG_KEYBOARD_REFRESH_ROW3
#endif /* CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3 */
+#undef CONFIG_KEYBOARD_FACTORY_TEST
+#ifdef CONFIG_PLATFORM_EC_KEYBOARD_FACTORY_TEST
+#define CONFIG_KEYBOARD_FACTORY_TEST
+#endif
+
#undef CONFIG_KEYBOARD_KEYPAD
#ifdef CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD
#define CONFIG_KEYBOARD_KEYPAD
@@ -994,6 +1017,9 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256];
CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_OFF_DELAY
#endif
+#undef CONFIG_EXTPOWER_DEBOUNCE_MS
+#define CONFIG_EXTPOWER_DEBOUNCE_MS CONFIG_PLATFORM_EC_EXTPOWER_DEBOUNCE_MS
+
#undef CONFIG_CMD_PPC_DUMP
#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_PPC_DUMP
#define CONFIG_CMD_PPC_DUMP
@@ -1026,6 +1052,16 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256];
#endif
+#undef CONFIG_CHARGE_STATE_DEBUG
+#ifdef CONFIG_PLATFORM_EC_CHARGE_STATE_DEBUG
+#define CONFIG_CHARGE_STATE_DEBUG
+#endif
+
+#undef CONFIG_CMD_PWR_AVG
+#ifdef CONFIG_PLATFORM_EC_CMD_PWR_AVG
+#define CONFIG_CMD_PWR_AVG
+#endif
+
#undef CONFIG_CHARGESPLASH
#ifdef CONFIG_PLATFORM_EC_CHARGESPLASH
#define CONFIG_CHARGESPLASH
@@ -1042,9 +1078,22 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256];
CONFIG_PLATFORM_EC_CHARGESPLASH_MAX_REQUESTS_PER_PERIOD
#endif
-#undef CONFIG_CHARGER_INPUT_CURRENT
-#ifdef CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT
-#define CONFIG_CHARGER_INPUT_CURRENT CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT
+#undef CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT
+#ifdef CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT
+#define CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT \
+ CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT
+#endif
+
+#undef CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT
+#ifdef CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT
+#define CONFIG_CHARGER_MIN_INPUT_CURRENT_LIMIT \
+ CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT
+#endif
+
+#undef CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT
+#ifdef CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT
+#define CONFIG_CHARGER_INPUT_CURRENT_DERATE_PCT \
+ CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT
#endif
#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
@@ -1327,6 +1376,11 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256];
#define CONFIG_USB_PE_SM
#endif
+#undef CONFIG_USB_DPM_SM
+#ifdef CONFIG_PLATFORM_EC_USB_DPM_SM
+#define CONFIG_USB_DPM_SM
+#endif
+
#undef CONFIG_USB_PD_DECODE_SOP
#ifdef CONFIG_PLATFORM_EC_USB_PD_DECODE_SOP
#define CONFIG_USB_PD_DECODE_SOP
@@ -1927,6 +1981,42 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256];
#define CONFIG_ACCEL_FIFO_THRES CONFIG_PLATFORM_EC_ACCEL_FIFO_THRES
#endif /* CONFIG_PLATFORM_EC_ACCEL_FIFO */
+#undef CONFIG_BODY_DETECTION
+#undef CONFIG_BODY_DETECTION_SENSOR
+#undef CONFIG_BODY_DETECTION_MAX_WINDOW_SIZE
+#undef CONFIG_BODY_DETECTION_VAR_THRESHOLD
+#undef CONFIG_BODY_DETECTION_CONFIDENCE_DELTA
+#undef CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR
+#undef CONFIG_BODY_DETECTION_ON_BODY_CON
+#undef CONFIG_BODY_DETECTION_OFF_BODY_CON
+#undef CONFIG_BODY_DETECTION_STATIONARY_DURATION
+#undef CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE
+#undef CONFIG_BODY_DETECTION_ALWAYS_ENABLE_IN_S0
+#ifdef CONFIG_PLATFORM_EC_BODY_DETECTION
+#define CONFIG_BODY_DETECTION
+#define CONFIG_BODY_DETECTION_SENSOR SENSOR_ID(DT_ALIAS(on_body_sensor))
+#define CONFIG_BODY_DETECTION_MAX_WINDOW_SIZE \
+ CONFIG_PLATFORM_EC_BODY_DETECTION_MAX_WINDOW_SIZE
+#define CONFIG_BODY_DETECTION_VAR_THRESHOLD \
+ CONFIG_PLATFORM_EC_BODY_DETECTION_VAR_THRESHOLD
+#define CONFIG_BODY_DETECTION_CONFIDENCE_DELTA \
+ CONFIG_PLATFORM_EC_BODY_DETECTION_CONFIDENCE_DELTA
+#define CONFIG_BODY_DETECTION_VAR_NOISE_FACTOR \
+ CONFIG_PLATFORM_EC_BODY_DETECTION_VAR_NOISE_FACTOR
+#define CONFIG_BODY_DETECTION_ON_BODY_CON \
+ CONFIG_PLATFORM_EC_BODY_DETECTION_ON_BODY_CON
+#define CONFIG_BODY_DETECTION_OFF_BODY_CON \
+ CONFIG_PLATFORM_EC_BODY_DETECTION_OFF_BODY_CON
+#define CONFIG_BODY_DETECTION_STATIONARY_DURATION \
+ CONFIG_PLATFORM_EC_BODY_DETECTION_STATIONARY_DURATION
+#ifdef CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE
+#define CONFIG_BODY_DETECTION_NOTIFY_MODE_CHANGE
+#endif /* CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE */
+#ifdef CONFIG_PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0
+#define CONFIG_BODY_DETECTION_ALWAYS_ENABLE_IN_S0
+#endif
+#endif /* CONFIG_PLATFORM_EC_BODY_DETECTION */
+
#undef CONFIG_CMD_ACCELS
#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS
#define CONFIG_CMD_ACCELS
@@ -1953,6 +2043,11 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256];
#define CONFIG_CMD_ACCEL_SPOOF
#endif
+#undef CONFIG_GESTURE_HOST_DETECTION
+#ifdef CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTION
+#define CONFIG_GESTURE_HOST_DETECTION
+#endif
+
#undef CONFIG_SENSOR_TIGHT_TIMESTAMPS
#ifdef CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS
#define CONFIG_SENSOR_TIGHT_TIMESTAMPS
@@ -2073,7 +2168,10 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256];
#undef CONFIG_MAX695X_SEVEN_SEGMENT_DISPLAY
#ifdef CONFIG_PLATFORM_EC_MAX695X_SEVEN_SEGMENT_DISPLAY
#define CONFIG_MAX695X_SEVEN_SEGMENT_DISPLAY
-#define PORT80_I2C_ADDR DT_REG_ADDR(DT_NODELABEL(seven_seg_display))
+#define PORT80_I2C_ADDR \
+ DT_REG_ADDR(DT_COMPAT_GET_ANY_STATUS_OKAY(maxim_max695x))
+BUILD_ASSERT((DT_NUM_INST_STATUS_OKAY(maxim_max695x)) == 1,
+ "Only one instance of maxim,max695x should be defined");
#endif
#undef CONFIG_CMD_SEVEN_SEG_DISPLAY
@@ -2401,6 +2499,16 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256];
#define CONFIG_HIBERNATE_PSL
#endif
+#ifdef CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC
+#undef CONFIG_HIBERNATE_DELAY_SEC
+#define CONFIG_HIBERNATE_DELAY_SEC CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC
+#endif
+
+#undef CONFIG_HIBERNATE
+#ifdef CONFIG_PLATFORM_EC_HIBERNATE
+#define CONFIG_HIBERNATE
+#endif
+
#undef CONFIG_BATTERY_DEVICE_CHEMISTRY
#ifdef CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY
#define CONFIG_BATTERY_DEVICE_CHEMISTRY \
@@ -2537,7 +2645,10 @@ extern char mock_jump_data[sizeof(struct jump_data) + 256];
#undef CONFIG_MP2964
#ifdef CONFIG_PLATFORM_EC_MP2964
#define CONFIG_MP2964
-#define I2C_ADDR_MP2964_FLAGS DT_REG_ADDR(DT_NODELABEL(pmic_mp2964))
+#define I2C_ADDR_MP2964_FLAGS \
+ DT_REG_ADDR(DT_COMPAT_GET_ANY_STATUS_OKAY(mps_mp2964))
+BUILD_ASSERT((DT_NUM_INST_STATUS_OKAY(mps_mp2964)) == 1,
+ "Only one instance of mps,mp2964 should be defined");
#endif
#undef CONFIG_ACCELGYRO_ICM_COMM_SPI
diff --git a/zephyr/shim/include/cros_cbi.h b/zephyr/shim/include/cros_cbi.h
index 1f8a1b3dfa..603be590c1 100644
--- a/zephyr/shim/include/cros_cbi.h
+++ b/zephyr/shim/include/cros_cbi.h
@@ -6,17 +6,16 @@
#ifndef __CROS_EC_CROS_CBI_H
#define __CROS_EC_CROS_CBI_H
-#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
+#include <zephyr/kernel.h>
/*
* Macros are _INST_ types, so require DT_DRV_COMPAT to be defined.
*/
-#define DT_DRV_COMPAT named_cbi_ssfc_value
-#define CROS_CBI_LABEL "cros_cbi"
+#define DT_DRV_COMPAT cros_ec_cbi_ssfc_value
-#define CBI_SSFC_VALUE_COMPAT named_cbi_ssfc_value
+#define CBI_SSFC_VALUE_COMPAT DT_DRV_COMPAT
#define CBI_SSFC_VALUE_ID(id) DT_CAT(CBI_SSFC_VALUE_, id)
#define CBI_SSFC_VALUE_ID_WITH_COMMA(id) CBI_SSFC_VALUE_ID(id),
#define CBI_SSFC_VALUE_INST_ENUM(inst, _) \
diff --git a/zephyr/shim/include/fpu.h b/zephyr/shim/include/fpu.h
index d1e4460827..20df108b87 100644
--- a/zephyr/shim/include/fpu.h
+++ b/zephyr/shim/include/fpu.h
@@ -16,7 +16,7 @@
* This code is taken from core/cortex-m/include/fpu.h
*/
-#ifdef CONFIG_PLATFORM_EC_FPU
+#ifdef CONFIG_FPU
/* Implementation for Cortex-M */
#ifdef CONFIG_CPU_CORTEX_M
@@ -55,10 +55,12 @@ static inline float fabsf(float v)
__asm__("fabs.s %0, %1" : "=f"(abs) : "f"(v));
return abs;
}
+#elif CONFIG_BOARD_NATIVE_POSIX
+#include <math.h>
#else
#error "Unsupported core: please add an implementation"
#endif
-#endif /* CONFIG_PLATFORM_EC_FPU */
+#endif /* CONFIG_FPU */
#endif /* __CROS_EC_MATH_H */
diff --git a/zephyr/shim/include/gpio/gpio.h b/zephyr/shim/include/gpio/gpio.h
index 7d41c0fa02..fbe57729fe 100644
--- a/zephyr/shim/include/gpio/gpio.h
+++ b/zephyr/shim/include/gpio/gpio.h
@@ -8,6 +8,7 @@
#include <zephyr/device.h>
#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
/*
* Validate interrupt flags are valid for the Zephyr GPIO driver.
diff --git a/zephyr/shim/include/motionsense_sensors.h b/zephyr/shim/include/motionsense_sensors.h
index e00eae426e..f83a8c63ad 100644
--- a/zephyr/shim/include/motionsense_sensors.h
+++ b/zephyr/shim/include/motionsense_sensors.h
@@ -6,9 +6,10 @@
#ifndef __CROS_EC_MOTIONSENSE_SENSORS_H
#define __CROS_EC_MOTIONSENSE_SENSORS_H
-#include <zephyr/devicetree.h>
#include "motion_sense.h"
+#include <zephyr/devicetree.h>
+
extern struct motion_sensor_t motion_sensors_alt[];
/*
diff --git a/zephyr/shim/include/motionsense_sensors_defs.h b/zephyr/shim/include/motionsense_sensors_defs.h
index ac0fc6bf56..b4b0274237 100644
--- a/zephyr/shim/include/motionsense_sensors_defs.h
+++ b/zephyr/shim/include/motionsense_sensors_defs.h
@@ -6,10 +6,10 @@
#ifndef __CROS_EC_MOTIONSENSE_SENSORS_DEFS_H
#define __CROS_EC_MOTIONSENSE_SENSORS_DEFS_H
-#include <zephyr/devicetree.h>
-
#include "common.h"
+#include <zephyr/devicetree.h>
+
#define SENSOR_ID(id) DT_CAT(SENSOR_, id)
/* Define the SENSOR_ID if:
diff --git a/zephyr/shim/include/power/power.h b/zephyr/shim/include/power/power.h
index 1e780646af..a764e0c8b5 100644
--- a/zephyr/shim/include/power/power.h
+++ b/zephyr/shim/include/power/power.h
@@ -9,29 +9,9 @@
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
-#define POWER_SIGNAL_LIST_NODE DT_NODELABEL(power_signal_list)
-
-#define SYSTEM_DT_POWER_SIGNAL_CONFIG DT_NODE_EXISTS(POWER_SIGNAL_LIST_NODE)
-
-#if (SYSTEM_DT_POWER_SIGNAL_CONFIG)
-
-#define GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid) \
- DT_STRING_UPPER_TOKEN(DT_PROP(cid, power_gpio_pin), enum_name)
-#define GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid) \
- (DT_GPIO_FLAGS(DT_PROP(cid, power_gpio_pin), gpios) & \
- GPIO_ACTIVE_LOW ? \
- POWER_SIGNAL_ACTIVE_LOW : \
- POWER_SIGNAL_ACTIVE_HIGH)
-#define GEN_POWER_SIGNAL_STRUCT_ENTRY_NAME(cid) DT_PROP(cid, power_enum_name)
+#if CONFIG_CROS_EC_POWER_SIGNAL_LIST
-#define GEN_POWER_SIGNAL_STRUCT_ENTRY(cid) \
- { \
- .gpio = GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid), \
- .flags = GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid), \
- .name = GEN_POWER_SIGNAL_STRUCT_ENTRY_NAME(cid) \
- }
-#define GEN_POWER_SIGNAL_STRUCT(cid) \
- [GEN_POWER_SIGNAL_ENUM_ENTRY(cid)] = GEN_POWER_SIGNAL_STRUCT_ENTRY(cid),
+#define POWER_SIGNAL_LIST_NODE DT_NODELABEL(power_signal_list)
#define GEN_POWER_SIGNAL_ENUM_ENTRY(cid) \
DT_STRING_UPPER_TOKEN(cid, power_enum_name)
@@ -42,13 +22,5 @@ enum power_signal {
POWER_SIGNAL_COUNT
};
-/*
- * Verify the number of required power-signals are specified in
- * the DeviceTree
- */
-#define POWER_SIGNALS_REQUIRED \
- DT_PROP(POWER_SIGNAL_LIST_NODE, power_signals_required)
-BUILD_ASSERT(POWER_SIGNALS_REQUIRED == POWER_SIGNAL_COUNT);
-
-#endif /* SYSTEM_DT_POWER_SIGNAL_CONFIG */
+#endif /* CONFIG_CROS_EC_POWER_SIGNAL_LIST */
#endif /* ZEPHYR_CHROME_POWER_POWER_H */
diff --git a/zephyr/shim/include/temp_sensor/temp_sensor.h b/zephyr/shim/include/temp_sensor/temp_sensor.h
index 9be18987eb..c4770ce767 100644
--- a/zephyr/shim/include/temp_sensor/temp_sensor.h
+++ b/zephyr/shim/include/temp_sensor/temp_sensor.h
@@ -6,9 +6,10 @@
#ifndef ZEPHYR_SHIM_INCLUDE_TEMP_SENSOR_TEMP_SENSOR_H_
#define ZEPHYR_SHIM_INCLUDE_TEMP_SENSOR_TEMP_SENSOR_H_
-#include <zephyr/devicetree.h>
-#include "include/temp_sensor.h"
#include "charger/chg_rt9490.h"
+#include "include/temp_sensor.h"
+
+#include <zephyr/devicetree.h>
#ifdef CONFIG_PLATFORM_EC_TEMP_SENSOR
@@ -143,6 +144,7 @@ enum tmp112_sensor {
struct zephyr_temp_sensor {
/* Read sensor value in K into temp_ptr; return non-zero if error. */
int (*read)(const struct temp_sensor_t *sensor, int *temp_ptr);
+ void (*update_temperature)(int idx);
const struct thermistor_info *thermistor;
#if ANY_INST_HAS_POWER_GOOD_PIN
const struct device *power_good_dev;
diff --git a/zephyr/shim/include/usbc/bc12_rt9490.h b/zephyr/shim/include/usbc/bc12_rt9490.h
index a9371ddeea..c4323728f9 100644
--- a/zephyr/shim/include/usbc/bc12_rt9490.h
+++ b/zephyr/shim/include/usbc/bc12_rt9490.h
@@ -5,7 +5,7 @@
#include "driver/charger/rt9490.h"
-#define RT9490_BC12_COMPAT richtek_rt9490_bc12
+#define RT9490_BC12_COMPAT richtek_rt9490
#define BC12_CHIP_RT9490(id) \
{ \
diff --git a/zephyr/shim/include/usbc/ppc.h b/zephyr/shim/include/usbc/ppc.h
index 28e518a3ef..fa38145f66 100644
--- a/zephyr/shim/include/usbc/ppc.h
+++ b/zephyr/shim/include/usbc/ppc.h
@@ -6,15 +6,16 @@
#ifndef ZEPHYR_CHROME_USBC_PPC_H
#define ZEPHYR_CHROME_USBC_PPC_H
-#include <zephyr/device.h>
-#include <zephyr/devicetree.h>
-#include "usbc/ppc_rt1739.h"
#include "usbc/ppc_nx20p348x.h"
+#include "usbc/ppc_rt1739.h"
#include "usbc/ppc_sn5s330.h"
#include "usbc/ppc_syv682x.h"
#include "usbc/utils.h"
#include "usbc_ppc.h"
+#include <zephyr/device.h>
+#include <zephyr/devicetree.h>
+
extern struct ppc_config_t ppc_chips_alt[];
#define ALT_PPC_CHIP_CHK(usbc_id, usb_port_num) \
diff --git a/zephyr/shim/include/usbc/tcpc_anx7447.h b/zephyr/shim/include/usbc/tcpc_anx7447.h
index b45e03393c..89076c8c49 100644
--- a/zephyr/shim/include/usbc/tcpc_anx7447.h
+++ b/zephyr/shim/include/usbc/tcpc_anx7447.h
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
#include "tcpm/anx7447_public.h"
+#include <zephyr/devicetree.h>
+
#define ANX7447_TCPC_COMPAT analogix_anx7447_tcpc
#define TCPC_CONFIG_ANX7447(id) \
diff --git a/zephyr/shim/include/usbc/tcpc_anx7447_emul.h b/zephyr/shim/include/usbc/tcpc_anx7447_emul.h
index 78322a7329..3367286dd9 100644
--- a/zephyr/shim/include/usbc/tcpc_anx7447_emul.h
+++ b/zephyr/shim/include/usbc/tcpc_anx7447_emul.h
@@ -3,10 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
#include "driver/tcpm/anx7447_public.h"
-#define ANX7447_EMUL_COMPAT cros_anx7447_emul
+#include <zephyr/devicetree.h>
+
+#define ANX7447_EMUL_COMPAT cros_anx7447_tcpc_emul
#define TCPC_CONFIG_ANX7447_EMUL(id) \
{ \
diff --git a/zephyr/shim/include/usbc/tcpc_ccgxxf.h b/zephyr/shim/include/usbc/tcpc_ccgxxf.h
index 0c02cf6846..fb7bdcabcf 100644
--- a/zephyr/shim/include/usbc/tcpc_ccgxxf.h
+++ b/zephyr/shim/include/usbc/tcpc_ccgxxf.h
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
#include "driver/tcpm/ccgxxf.h"
+#include <zephyr/devicetree.h>
+
#define CCGXXF_TCPC_COMPAT cypress_ccgxxf
#define TCPC_CONFIG_CCGXXF(id) \
diff --git a/zephyr/shim/include/usbc/tcpc_fusb302.h b/zephyr/shim/include/usbc/tcpc_fusb302.h
index a2e512d938..fa309051cd 100644
--- a/zephyr/shim/include/usbc/tcpc_fusb302.h
+++ b/zephyr/shim/include/usbc/tcpc_fusb302.h
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
#include "driver/tcpm/fusb302.h"
+#include <zephyr/devicetree.h>
+
#define FUSB302_TCPC_COMPAT fairchild_fusb302
#define TCPC_CONFIG_FUSB302(id) \
diff --git a/zephyr/shim/include/usbc/tcpc_generic_emul.h b/zephyr/shim/include/usbc/tcpc_generic_emul.h
index 7dc46c51ba..9000dfdf20 100644
--- a/zephyr/shim/include/usbc/tcpc_generic_emul.h
+++ b/zephyr/shim/include/usbc/tcpc_generic_emul.h
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-
#include "driver/tcpm/tcpci.h"
+#include <zephyr/devicetree.h>
+
#define TCPCI_EMUL_COMPAT cros_tcpci_generic_emul
#define TCPC_CONFIG_TCPCI_EMUL(id) \
diff --git a/zephyr/shim/include/usbc/tcpc_it8xxx2.h b/zephyr/shim/include/usbc/tcpc_it8xxx2.h
index c619656667..b9084782e0 100644
--- a/zephyr/shim/include/usbc/tcpc_it8xxx2.h
+++ b/zephyr/shim/include/usbc/tcpc_it8xxx2.h
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
#include "driver/tcpm/it8xxx2_pd_public.h"
+#include <zephyr/devicetree.h>
+
#define IT8XXX2_TCPC_COMPAT ite_it8xxx2_usbpd
#define TCPC_CONFIG_IT8XXX2(id) \
diff --git a/zephyr/shim/include/usbc/tcpc_nct38xx.h b/zephyr/shim/include/usbc/tcpc_nct38xx.h
index 87ba3379c8..7a0752904e 100644
--- a/zephyr/shim/include/usbc/tcpc_nct38xx.h
+++ b/zephyr/shim/include/usbc/tcpc_nct38xx.h
@@ -6,9 +6,10 @@
#ifndef __CROS_EC_TCPC_NCT38XX_H
#define __CROS_EC_TCPC_NCT38XX_H
-#include <zephyr/devicetree.h>
#include "driver/tcpm/nct38xx.h"
+#include <zephyr/devicetree.h>
+
#define NCT38XX_TCPC_COMPAT nuvoton_nct38xx
#define TCPC_CONFIG_NCT38XX(id) \
diff --git a/zephyr/shim/include/usbc/tcpc_ps8xxx.h b/zephyr/shim/include/usbc/tcpc_ps8xxx.h
index 1a457af09b..7d3b9c6ccc 100644
--- a/zephyr/shim/include/usbc/tcpc_ps8xxx.h
+++ b/zephyr/shim/include/usbc/tcpc_ps8xxx.h
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
#include "driver/tcpm/ps8xxx_public.h"
+#include <zephyr/devicetree.h>
+
#define PS8XXX_COMPAT parade_ps8xxx
#define TCPC_CONFIG_PS8XXX(id) \
diff --git a/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h b/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h
index fbd2e4bfd1..b1ea6f1705 100644
--- a/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h
+++ b/zephyr/shim/include/usbc/tcpc_ps8xxx_emul.h
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
#include "driver/tcpm/ps8xxx_public.h"
+#include <zephyr/devicetree.h>
+
#define PS8XXX_EMUL_COMPAT cros_ps8xxx_emul
#define TCPC_CONFIG_PS8XXX_EMUL(id) \
diff --git a/zephyr/shim/include/usbc/tcpc_raa489000.h b/zephyr/shim/include/usbc/tcpc_raa489000.h
new file mode 100644
index 0000000000..47e7706ae1
--- /dev/null
+++ b/zephyr/shim/include/usbc/tcpc_raa489000.h
@@ -0,0 +1,21 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "driver/tcpm/raa489000.h"
+
+#include <zephyr/devicetree.h>
+
+#define RAA489000_TCPC_COMPAT renesas_raa489000
+
+#define TCPC_CONFIG_RAA489000(id) \
+ { \
+ .bus_type = EC_BUS_TYPE_I2C, \
+ .i2c_info = { \
+ .port = I2C_PORT_BY_DEV(id), \
+ .addr_flags = DT_REG_ADDR(id), \
+ }, \
+ .drv = &raa489000_tcpm_drv, \
+ .flags = DT_PROP(id, tcpc_flags), \
+ },
diff --git a/zephyr/shim/include/usbc/tcpc_rt1718s.h b/zephyr/shim/include/usbc/tcpc_rt1718s.h
index 794fb99480..861b474ecf 100644
--- a/zephyr/shim/include/usbc/tcpc_rt1718s.h
+++ b/zephyr/shim/include/usbc/tcpc_rt1718s.h
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
#include "tcpm/rt1718s_public.h"
+#include <zephyr/devicetree.h>
+
#define RT1718S_TCPC_COMPAT richtek_rt1718s_tcpc
#define TCPC_CONFIG_RT1718S(id) \
diff --git a/zephyr/shim/include/usbc/tcpci.h b/zephyr/shim/include/usbc/tcpci.h
index 67138dbe99..15cea4b332 100644
--- a/zephyr/shim/include/usbc/tcpci.h
+++ b/zephyr/shim/include/usbc/tcpci.h
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-
#include "driver/tcpm/tcpci.h"
+#include <zephyr/devicetree.h>
+
#define TCPCI_COMPAT cros_ec_tcpci
#define TCPC_CONFIG_TCPCI(id) \
diff --git a/zephyr/shim/include/usbc/usb_muxes.h b/zephyr/shim/include/usbc/usb_muxes.h
index f94aed488d..6ee9c691a8 100644
--- a/zephyr/shim/include/usbc/usb_muxes.h
+++ b/zephyr/shim/include/usbc/usb_muxes.h
@@ -6,8 +6,6 @@
#ifndef ZEPHYR_CHROME_USBC_USB_MUXES_H
#define ZEPHYR_CHROME_USBC_USB_MUXES_H
-#include <zephyr/devicetree.h>
-#include <zephyr/sys/util_macro.h>
#include "usb_mux.h"
#include "usbc/amd_fp6_usb_mux.h"
#include "usbc/anx7447_usb_mux.h"
@@ -21,6 +19,9 @@
#include "usbc/utils.h"
#include "usbc/virtual_usb_mux.h"
+#include <zephyr/devicetree.h>
+#include <zephyr/sys/util_macro.h>
+
/**
* @brief List of USB mux drivers compatibles and their configurations. Each
* element of list has to have (compatible, config) format.
@@ -177,14 +178,14 @@
* @brief Set struct usb_mux fields common for all USB muxes and alter flags
*
* @param mux_id USB mux node ID
- * @param flags_mask Mask for bits that should be igonred in flags property
+ * @param flags_mask Mask for bits that should be ignored in flags property
* @param flags_val Value that should be used instead for masked bits
*/
#define USB_MUX_COMMON_FIELDS_WITH_FLAGS(mux_id, flags_mask, flags_val) \
.usb_port = USB_MUX_PORT(mux_id), \
.board_init = USB_MUX_CALLBACK_OR_NULL(mux_id, board_init), \
.board_set = USB_MUX_CALLBACK_OR_NULL(mux_id, board_set), \
- .flags = (DT_PROP(mux_id, flags) & ~(flags_mask)) | (flags_val)
+ .flags = (DT_PROP_OR(mux_id, flags, 0) & ~(flags_mask)) | (flags_val)
/**
* @brief Set struct usb_mux fields common for all USB muxes
diff --git a/zephyr/shim/include/zephyr_hooks_shim.h b/zephyr/shim/include/zephyr_hooks_shim.h
index f3949787bd..f1c25c6e8f 100644
--- a/zephyr/shim/include/zephyr_hooks_shim.h
+++ b/zephyr/shim/include/zephyr_hooks_shim.h
@@ -8,12 +8,12 @@
#endif
#define __CROS_EC_ZEPHYR_HOOKS_SHIM_H
-#include <zephyr/init.h>
-#include <zephyr/kernel.h>
-
#include "common.h"
#include "cros_version.h"
+#include <zephyr/init.h>
+#include <zephyr/kernel.h>
+
/**
* The internal data structure stored for a deferred function.
*/
diff --git a/zephyr/shim/include/zephyr_host_command.h b/zephyr/shim/include/zephyr_host_command.h
index e2f0a7c296..9271c6c368 100644
--- a/zephyr/shim/include/zephyr_host_command.h
+++ b/zephyr/shim/include/zephyr_host_command.h
@@ -10,9 +10,10 @@
#endif
#define __CROS_EC_ZEPHYR_HOST_COMMAND_H
-#include <zephyr/init.h>
#include <stdbool.h>
+#include <zephyr/init.h>
+
/* Initializes and runs the host command handler loop. */
void host_command_task(void *u);
diff --git a/zephyr/shim/include/zephyr_shim.h b/zephyr/shim/include/zephyr_shim.h
index 3e12568155..dce1706c5b 100644
--- a/zephyr/shim/include/zephyr_shim.h
+++ b/zephyr/shim/include/zephyr_shim.h
@@ -6,9 +6,10 @@
#ifndef __BOARD_H
#define __BOARD_H
-#include <zephyr/devicetree.h>
#include "common.h"
+#include <zephyr/devicetree.h>
+
/* Included shimed version of gpio signal. */
#include "gpio_signal.h"
diff --git a/zephyr/shim/include/zephyr_write_protect.h b/zephyr/shim/include/zephyr_write_protect.h
index 227af16bd0..59a305a0f9 100644
--- a/zephyr/shim/include/zephyr_write_protect.h
+++ b/zephyr/shim/include/zephyr_write_protect.h
@@ -8,6 +8,7 @@
#include "gpio/gpio_int.h"
#include "gpio_signal.h"
+
#include <zephyr/drivers/gpio.h>
/**
diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt
index 97968e8a52..543c2b2303 100644
--- a/zephyr/shim/src/CMakeLists.txt
+++ b/zephyr/shim/src/CMakeLists.txt
@@ -5,9 +5,7 @@
zephyr_library_sources(console.c)
zephyr_library_sources(crc.c)
zephyr_library_sources(gpio.c)
-zephyr_library_sources(gpio_id.c)
zephyr_library_sources(gpio_int.c)
-zephyr_library_sources(power.c)
add_subdirectory("cbi")
add_subdirectory("led_driver")
@@ -31,6 +29,8 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI
espi.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN fan.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FLASH_CROS flash.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_GPIO_ID
+ gpio_id.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOOKS hooks.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD host_command.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE
@@ -42,20 +42,22 @@ if (NOT DEFINED CONFIG_PLATFORM_EC_KEYBOARD_DISCRETE)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD
keyboard_raw.c)
endif()
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD keyscan.c)
+zephyr_library_sources_ifdef(CONFIG_CROS_EC_KEYSCAN keyscan.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LOG_BACKEND_CONSOLE_BUFFER
log_backend_console_buffer.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MKBP_EVENT mkbp_event.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MOTIONSENSE
motionsense_sensors.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PANIC panic.c)
+zephyr_library_sources_ifdef(CONFIG_CROS_EC_POWER_SIGNAL_LIST
+ power.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PWM_HC pwm_hc.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_PWM pwm_led.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_RTC rtc.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SWITCHCAP_GPIO
- switchcap_gpio.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SWITCHCAP_LN9310
- switchcap_ln9310.c)
+ switchcap_gpio.c)
+zephyr_library_sources_ifdef(CONFIG_CROS_EC_SWITCHCAP_LN9310
+ switchcap_ln9310.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TEMP_SENSOR temp_sensors.c
thermal.c)
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TIMER hwtimer.c)
diff --git a/zephyr/shim/src/adc.c b/zephyr/shim/src/adc.c
index 9d5e64376c..b448823eee 100644
--- a/zephyr/shim/src/adc.c
+++ b/zephyr/shim/src/adc.c
@@ -3,11 +3,12 @@
* found in the LICENSE file.
*/
+#include "adc.h"
+#include "zephyr_adc.h"
+
#include <zephyr/devicetree/io-channels.h>
#include <zephyr/drivers/adc.h>
#include <zephyr/logging/log.h>
-#include "adc.h"
-#include "zephyr_adc.h"
LOG_MODULE_REGISTER(shim_adc, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/src/battery.c b/zephyr/shim/src/battery.c
index 98c0877770..8485f1314e 100644
--- a/zephyr/shim/src/battery.c
+++ b/zephyr/shim/src/battery.c
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-
#include "battery_fuel_gauge.h"
+#include <zephyr/devicetree.h>
+
#define NODE_FUEL_GAUGE(node) \
{ \
.manuf_name = DT_PROP(node, manuf_name), \
@@ -17,7 +17,7 @@
.reg_data = DT_PROP(node, ship_mode_reg_data), \
}, \
.sleep_mode = { \
- .sleep_supported = DT_PROP_OR(node, sleep_mode_supported, 0), \
+ .sleep_supported = DT_PROP_OR(node, sleep_mode_support, 0), \
.reg_addr = DT_PROP_OR(node, sleep_mode_reg_addr, 0), \
.reg_data = DT_PROP_OR(node, sleep_mode_reg_data, 0), \
}, \
diff --git a/zephyr/shim/src/bb_retimer_usb_mux.c b/zephyr/shim/src/bb_retimer_usb_mux.c
index c40068211e..b0e3944528 100644
--- a/zephyr/shim/src/bb_retimer_usb_mux.c
+++ b/zephyr/shim/src/bb_retimer_usb_mux.c
@@ -1,18 +1,13 @@
-/* Copyright 2022 The ChromiumOS Authors.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-#include <zephyr/sys/util_macro.h>
#include "usb_mux.h"
#include "usbc/usb_muxes.h"
-/**
- * This prevents creating struct usb_mux bb_controls[] for platforms that didn't
- * migrate USB mux configuration to DTS yet.
- */
-#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain)
+#include <zephyr/devicetree.h>
+#include <zephyr/sys/util_macro.h>
BB_RETIMER_CHECK_SAME_CONTROLS(BB_RETIMER_INSTANCES_LIST)
@@ -35,5 +30,3 @@ BB_RETIMER_CHECK_SAME_CONTROLS(BB_RETIMER_INSTANCES_LIST)
BB_CONTROLS_CONST struct bb_usb_control bb_controls[] = {
USB_MUX_BB_RETIMERS_CONTROLS_ARRAY
};
-
-#endif /* #if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain) */
diff --git a/zephyr/shim/src/bc12.c b/zephyr/shim/src/bc12.c
index 6542a166eb..12b45d2197 100644
--- a/zephyr/shim/src/bc12.c
+++ b/zephyr/shim/src/bc12.c
@@ -3,14 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
+#include "usb_charge.h"
#include "usbc/bc12_pi3usb9201.h"
#include "usbc/bc12_rt1718s.h"
#include "usbc/bc12_rt1739.h"
#include "usbc/bc12_rt9490.h"
#include "usbc/tcpc_rt1718s.h"
#include "usbc/utils.h"
-#include "usb_charge.h"
+
+#include <zephyr/devicetree.h>
#if DT_HAS_COMPAT_STATUS_OKAY(RT1718S_BC12_COMPAT) || \
DT_HAS_COMPAT_STATUS_OKAY(RT1739_BC12_COMPAT) || \
diff --git a/zephyr/shim/src/bc12_pi3usb9201.c b/zephyr/shim/src/bc12_pi3usb9201.c
index 25d1962ff2..d41fcc3212 100644
--- a/zephyr/shim/src/bc12_pi3usb9201.c
+++ b/zephyr/shim/src/bc12_pi3usb9201.c
@@ -5,20 +5,16 @@
#define DT_DRV_COMPAT pericom_pi3usb9201
-#include <zephyr/devicetree.h>
#include "bc12/pi3usb9201_public.h"
#include "gpio/gpio_int.h"
#include "hooks.h"
+#include "i2c/i2c.h"
#include "task.h"
#include "usb_charge.h"
#include "usb_pd.h"
#include "usbc/utils.h"
-#include "i2c/i2c.h"
-#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
-
-BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) > 0,
- "No compatible BC1.2 instance found");
+#include <zephyr/devicetree.h>
#define USBC_PORT_BC12(usbc_id, bc12_id) \
[USBC_PORT_NEW(usbc_id)] = { \
@@ -56,5 +52,3 @@ void usb1_evt(enum gpio_signal signal)
usb_charger_task_set_event(1, USB_CHG_EVENT_BC12);
}
#endif
-
-#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */
diff --git a/zephyr/shim/src/bc12_rt9490.c b/zephyr/shim/src/bc12_rt9490.c
index df10fb5570..a3c97e7faf 100644
--- a/zephyr/shim/src/bc12_rt9490.c
+++ b/zephyr/shim/src/bc12_rt9490.c
@@ -3,15 +3,14 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT richtek_rt9490_bc12
+#define DT_DRV_COMPAT richtek_rt9490
-#include <zephyr/devicetree.h>
#include "driver/charger/rt9490.h"
#include "gpio/gpio_int.h"
#include "hooks.h"
#include "usbc/utils.h"
-#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
+#include <zephyr/devicetree.h>
static void rt9490_bc12_enable_irqs(void)
{
@@ -42,5 +41,3 @@ void rt9490_bc12_dt_interrupt(enum gpio_signal signal)
break;
}
}
-
-#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */
diff --git a/zephyr/shim/src/cbi/CMakeLists.txt b/zephyr/shim/src/cbi/CMakeLists.txt
index 4b14f0bb1d..a5d3894ad0 100644
--- a/zephyr/shim/src/cbi/CMakeLists.txt
+++ b/zephyr/shim/src/cbi/CMakeLists.txt
@@ -1,9 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM cbi_eeprom.c
- cros_cbi.c
- cros_cbi_fw_config.c
- cros_cbi_ssfc.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_GPIO cros_cbi.c
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI cros_cbi.c
cros_cbi_fw_config.c
cros_cbi_ssfc.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM cbi_eeprom.c)
diff --git a/zephyr/shim/src/cbi/cbi_eeprom.c b/zephyr/shim/src/cbi/cbi_eeprom.c
index aa6c4e0fa1..9cd0d0a955 100644
--- a/zephyr/shim/src/cbi/cbi_eeprom.c
+++ b/zephyr/shim/src/cbi/cbi_eeprom.c
@@ -3,15 +3,16 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/eeprom.h>
-#include <zephyr/drivers/gpio.h>
-
#include "console.h"
#include "cros_board_info.h"
#include "write_protect.h"
-#if DT_NODE_EXISTS(DT_NODELABEL(cbi_eeprom))
-#define CBI_EEPROM_DEV DEVICE_DT_GET(DT_NODELABEL(cbi_eeprom))
+#include <zephyr/drivers/eeprom.h>
+#include <zephyr/drivers/gpio.h>
+
+#define CBI_EEPROM_NODE DT_NODELABEL(cbi_eeprom)
+
+BUILD_ASSERT(DT_NODE_EXISTS(CBI_EEPROM_NODE), "cbi_eeprom node not defined");
#ifdef CONFIG_PLATFORM_EC_EEPROM_CBI_WP
#if !DT_NODE_EXISTS(DT_ALIAS(gpio_cbi_wp))
@@ -25,22 +26,39 @@ void cbi_latch_eeprom_wp(void)
}
#endif /* CONFIG_PLATFORM_EC_EEPROM_CBI_WP */
-static int eeprom_load(uint8_t offset, uint8_t *data, int len)
+test_mockable_static int eeprom_load(uint8_t offset, uint8_t *data, int len)
{
- return eeprom_read(CBI_EEPROM_DEV, offset, data, len);
+ const struct device *dev;
+
+ dev = DEVICE_DT_GET(CBI_EEPROM_NODE);
+
+ if (!device_is_ready(dev)) {
+ return -ENODEV;
+ }
+
+ return eeprom_read(dev, offset, data, len);
}
static int eeprom_is_write_protected(void)
{
- if (IS_ENABLED(CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK))
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK)) {
return 0;
+ }
return write_protect_is_asserted();
}
static int eeprom_store(uint8_t *cbi)
{
- return eeprom_write(CBI_EEPROM_DEV, 0, cbi,
+ const struct device *dev;
+
+ dev = DEVICE_DT_GET(CBI_EEPROM_NODE);
+
+ if (!device_is_ready(dev)) {
+ return -ENODEV;
+ }
+
+ return eeprom_write(dev, 0, cbi,
((struct cbi_header *)cbi)->total_size);
}
@@ -54,4 +72,3 @@ const struct cbi_storage_config_t cbi_config = {
.storage_type = CBI_STORAGE_TYPE_EEPROM,
.drv = &eeprom_drv,
};
-#endif
diff --git a/zephyr/shim/src/cbi/cros_cbi.c b/zephyr/shim/src/cbi/cros_cbi.c
index 5b90f9442d..e6fa3e8cd1 100644
--- a/zephyr/shim/src/cbi/cros_cbi.c
+++ b/zephyr/shim/src/cbi/cros_cbi.c
@@ -3,9 +3,8 @@
* found in the LICENSE file.
*/
-#include "cros_cbi.h"
-
#include "cros_board_info.h"
+#include "cros_cbi.h"
#include "hooks.h"
static void cros_cbi_ec_init(void)
diff --git a/zephyr/shim/src/cbi/cros_cbi_fw_config.c b/zephyr/shim/src/cbi/cros_cbi_fw_config.c
index 6710a30726..8f6086eb58 100644
--- a/zephyr/shim/src/cbi/cros_cbi_fw_config.c
+++ b/zephyr/shim/src/cbi/cros_cbi_fw_config.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/logging/log.h>
-
#include "cros_board_info.h"
#include "cros_cbi.h"
+#include <zephyr/logging/log.h>
+
LOG_MODULE_REGISTER(cros_cbi_fw_config, LOG_LEVEL_ERR);
/*
@@ -47,13 +47,13 @@ LOG_MODULE_REGISTER(cros_cbi_fw_config, LOG_LEVEL_ERR);
#define FW_SHIFT_MASK(id) (FW_MASK(id) << FW_START(id))
/*
- * For a child "named-cbi-fw-config-value" node, retrieve the
+ * For a child "cros-ec,cbi-fw-config-value" node, retrieve the
* size of the parent field this value is associated with.
*/
#define FW_PARENT_SIZE(id) DT_PROP(DT_PARENT(id), size)
/*
- * For a child "named-cbi-fw-config-value" node, retrieve the
+ * For a child "cros-ec,cbi-fw-config-value" node, retrieve the
* start of the parent field this value is associated with.
*/
#define FW_PARENT_START(id) DT_PROP(DT_PARENT(id), start)
@@ -115,7 +115,7 @@ DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_VALUE_COMPAT, FW_VALUE_BUILD_ASSERT)
/*
* Define bit fields based on the device tree entries. Example:
* cbi-fw-config {
- * compatible = "named-cbi-fw-config";
+ * compatible = "cros-ec,cbi-fw-config";
*
* fan {
* enum-name = "FW_CONFIG_FAN";
@@ -123,7 +123,7 @@ DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_VALUE_COMPAT, FW_VALUE_BUILD_ASSERT)
* size = <1>;
* fan_present {
* enum-name = "FW_FAN_PRESENT"
- * compatible = "named-cbi-fw-config-value";
+ * compatible = "cros-ec,cbi-fw-config-value";
* value = <1>;
* };
* };
@@ -148,7 +148,7 @@ DT_FOREACH_STATUS_OKAY(CBI_FW_CONFIG_VALUE_COMPAT, FW_VALUE_BUILD_ASSERT)
break;
/*
- * Create a case for every child of this "named-cbi-fw-config" node.
+ * Create a case for every child of this "cros-ec,cbi-fw-config" node.
*/
#define FW_FIELD_NODES(inst, cached, value) \
DT_FOREACH_CHILD_STATUS_OKAY_VARGS(inst, FW_FIELD_CASE, cached, value)
@@ -177,7 +177,7 @@ static int cros_cbi_fw_config_get_field(uint32_t cached_fw_config,
{
switch (field_id) {
/*
- * Iterate through all the the "named-cbi-fw-config" nodes,
+ * Iterate through all the the "cros-ec,cbi-fw-config" nodes,
* and create cases for all of their child nodes.
*/
DT_FOREACH_STATUS_OKAY_VARGS(CBI_FW_CONFIG_COMPAT,
diff --git a/zephyr/shim/src/cbi/cros_cbi_ssfc.c b/zephyr/shim/src/cbi/cros_cbi_ssfc.c
index eb0f69b1cb..f20ca457f4 100644
--- a/zephyr/shim/src/cbi/cros_cbi_ssfc.c
+++ b/zephyr/shim/src/cbi/cros_cbi_ssfc.c
@@ -3,25 +3,24 @@
* found in the LICENSE file.
*/
-#include <zephyr/logging/log.h>
-
#include "cros_board_info.h"
#include "cros_cbi.h"
+#include <zephyr/logging/log.h>
+
LOG_MODULE_REGISTER(cros_cbi_ssfc, LOG_LEVEL_ERR);
-/* Actually, two "compatible" values are handle here -
- * named_cbi_ssfc_value and named_cbi_ssfc. named_cbi_ssfc_value nodes are
- * grandchildren of the named_cbi_ssfc node. named_cbi_ssfc_value is introduced
- * to iterate over grandchildren of the named_cbi_ssfc(macro
- * DT_FOREACH_CHILD can not be nested) and it can be pointed by a sensor dts to
- * indicate alternative usage.
+/* Actually, two "compatible" values are handle here - cros_ec_cbi_ssfc_value
+ * and cros_ec_cbi_ssfc. cros_ec_cbi_ssfc_value nodes are grandchildren of the
+ * cros_ec_cbi_ssfc node. cros_ec_cbi_ssfc_value is introduced to iterate over
+ * grandchildren of the cros_ec_cbi_ssfc (macro DT_FOREACH_CHILD can not be
+ * nested) and it can be pointed by a sensor dts to indicate alternative usage.
*/
-#define DT_DRV_COMPAT named_cbi_ssfc_value
+#define DT_DRV_COMPAT cros_ec_cbi_ssfc_value
-BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(named_cbi_ssfc) < 2,
+BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(cros_ec_cbi_ssfc) < 2,
"More than 1 CBI SSFS node");
-#define CBI_SSFC_NODE DT_INST(0, named_cbi_ssfc)
+#define CBI_SSFC_NODE DT_INST(0, cros_ec_cbi_ssfc)
#define CBI_SSFC_INIT_DEFAULT_ID(id, ssfc) \
do { \
@@ -73,13 +72,13 @@ BUILD_ASSERT(CBI_SSFC_FIELDS_SIZE <= 32, "CBI SSFS is bigger than 32 bits");
/*
* Define union bit fields based on the device tree entries. Example:
* cbi-ssfc {
- * compatible = "named-cbi-ssfc";
+ * compatible = "cros-ec,cbi-ssfc";
*
* base_sensor {
* enum-name = "BASE_SENSOR";
* size = <3>;
* bmi160 {
- * compatible = "named-cbi-ssfc-value";
+ * compatible = "cros-ec,cbi-ssfc-value";
* status = "okay";
* value = <1>;
* };
@@ -88,7 +87,7 @@ BUILD_ASSERT(CBI_SSFC_FIELDS_SIZE <= 32, "CBI SSFS is bigger than 32 bits");
* enum-name = "LID_SENSOR";
* size = <3>;
* bma255 {
- * compatible = "named-cbi-ssfc-value";
+ * compatible = "cros-ec,cbi-ssfc-value";
* status = "okay";
* value = <1>;
* };
@@ -97,7 +96,7 @@ BUILD_ASSERT(CBI_SSFC_FIELDS_SIZE <= 32, "CBI SSFS is bigger than 32 bits");
* enum-name = "LIGHTBAR";
* size = <2>;
* 10_led {
- * compatible = "named-cbi-ssfc-value";
+ * compatible = "cros-ec,cbi-ssfc-value";
* status = "okay";
* value = <1>;
* };
diff --git a/zephyr/shim/src/charger.c b/zephyr/shim/src/charger.c
index 35ede5a8f7..9d6021ad7d 100644
--- a/zephyr/shim/src/charger.c
+++ b/zephyr/shim/src/charger.c
@@ -4,7 +4,6 @@
*/
#include "charger.h"
-#include <zephyr/devicetree.h>
#include "charger/chg_bq25710.h"
#include "charger/chg_isl923x.h"
#include "charger/chg_isl9241.h"
@@ -12,6 +11,8 @@
#include "charger/chg_sm5803.h"
#include "usbc/utils.h"
+#include <zephyr/devicetree.h>
+
#define CHG_CHIP_ENTRY(usbc_id, chg_id, config_fn) \
[USBC_PORT_NEW(usbc_id)] = config_fn(chg_id)
diff --git a/zephyr/shim/src/chipset_api.c b/zephyr/shim/src/chipset_api.c
index 6c48719a7f..925d13f6e1 100644
--- a/zephyr/shim/src/chipset_api.c
+++ b/zephyr/shim/src/chipset_api.c
@@ -5,10 +5,9 @@
/* Chipset interface APIs */
-#include "common.h"
-
#include "ap_power/ap_power_interface.h"
#include "chipset_state_check.h"
+#include "common.h"
int chipset_in_state(int state_mask)
{
diff --git a/zephyr/shim/src/chipset_state_check.h b/zephyr/shim/src/chipset_state_check.h
index 2d10b2ce4a..c33a3f9553 100644
--- a/zephyr/shim/src/chipset_state_check.h
+++ b/zephyr/shim/src/chipset_state_check.h
@@ -6,8 +6,8 @@
#ifndef __CHIPSET_STATE_CHECK_H__
#define __CHIPSET_STATE_CHECK_H__
-#include "chipset.h"
#include "ap_power/ap_power_interface.h"
+#include "chipset.h"
BUILD_ASSERT((int)AP_POWER_STATE_HARD_OFF == (int)CHIPSET_STATE_HARD_OFF);
BUILD_ASSERT((int)AP_POWER_STATE_SOFT_OFF == (int)CHIPSET_STATE_SOFT_OFF);
diff --git a/zephyr/shim/src/console.c b/zephyr/shim/src/console.c
index 4ac8e249cb..fa6dc5a613 100644
--- a/zephyr/shim/src/console.c
+++ b/zephyr/shim/src/console.c
@@ -3,20 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/device.h>
-#include <zephyr/drivers/uart.h>
-#include <zephyr/shell/shell.h>
-#ifdef CONFIG_SHELL_BACKEND_DUMMY /* nocheck */
-#include <zephyr/shell/shell_dummy.h> /* nocheck */
-#endif
-#include <zephyr/shell/shell_uart.h>
-#include <stdbool.h>
-#include <string.h>
-#include <zephyr/sys/printk.h>
-#include <zephyr/sys/ring_buffer.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-
/*
* TODO(b/238433667): Include EC printf functions
* (crec_vsnprintf/crec_snprintf) until we switch to the standard
@@ -30,6 +16,21 @@
#include "usb_console.h"
#include "zephyr_console_shim.h"
+#include <stdbool.h>
+#include <string.h>
+
+#include <zephyr/device.h>
+#include <zephyr/drivers/uart.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/shell/shell.h>
+#ifdef CONFIG_SHELL_BACKEND_DUMMY /* nocheck */
+#include <zephyr/shell/shell_dummy.h> /* nocheck */
+#endif
+#include <zephyr/shell/shell_uart.h>
+#include <zephyr/sys/printk.h>
+#include <zephyr/sys/ring_buffer.h>
+
#if !defined(CONFIG_SHELL_BACKEND_SERIAL) && \
!defined(CONFIG_SHELL_BACKEND_DUMMY) /* nocheck */
#error Must select either CONFIG_SHELL_BACKEND_SERIAL or \
@@ -321,7 +322,7 @@ void uart_write_char(char c)
{
uart_poll_out(uart_shell_dev, c);
- if (IS_ENABLED(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE))
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE) && !k_is_in_isr())
console_buf_notify_chars(&c, 1);
}
diff --git a/zephyr/shim/src/console_buffer.c b/zephyr/shim/src/console_buffer.c
index dad0031267..f5e80b2d20 100644
--- a/zephyr/shim/src/console_buffer.c
+++ b/zephyr/shim/src/console_buffer.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-
#include "common.h"
#include "console.h"
#include "ec_commands.h"
+#include <zephyr/kernel.h>
+
static char console_buf[CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE_BUF_SIZE];
static uint32_t previous_snapshot_idx;
static uint32_t current_snapshot_idx;
diff --git a/zephyr/shim/src/crc.c b/zephyr/shim/src/crc.c
index f8ce335029..1e98c1cf3f 100644
--- a/zephyr/shim/src/crc.c
+++ b/zephyr/shim/src/crc.c
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/sys/crc.h>
-
#include "crc8.h"
+#include <zephyr/sys/crc.h>
+
/* Polynomial representation for x^8 + x^2 + x + 1 is 0x07 */
#define SMBUS_POLYNOMIAL 0x07
diff --git a/zephyr/shim/src/espi.c b/zephyr/shim/src/espi.c
index 6a8e18e262..9cc5de8f0b 100644
--- a/zephyr/shim/src/espi.c
+++ b/zephyr/shim/src/espi.c
@@ -3,17 +3,6 @@
* found in the LICENSE file.
*/
-#include <atomic.h>
-#include <zephyr/device.h>
-#include <zephyr/drivers/espi.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/kernel.h>
-#include <stdint.h>
-
-#include <ap_power/ap_power.h>
-#include <ap_power/ap_power_events.h>
-#include <ap_power/ap_power_espi.h>
#include "acpi.h"
#include "chipset.h"
#include "common.h"
@@ -28,6 +17,19 @@
#include "timer.h"
#include "zephyr_espi_shim.h"
+#include <stdint.h>
+
+#include <zephyr/device.h>
+#include <zephyr/drivers/espi.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
+#include <ap_power/ap_power.h>
+#include <ap_power/ap_power_espi.h>
+#include <ap_power/ap_power_events.h>
+#include <atomic.h>
+
#define VWIRE_PULSE_TRIGGER_TIME \
CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_DEFAULT_VW_WIDTH_US
diff --git a/zephyr/shim/src/fan.c b/zephyr/shim/src/fan.c
index c7074b0c4d..9978e6f4ca 100644
--- a/zephyr/shim/src/fan.c
+++ b/zephyr/shim/src/fan.c
@@ -5,12 +5,6 @@
#define DT_DRV_COMPAT cros_ec_fans
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/pwm.h>
-#include <zephyr/drivers/sensor.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/sys/util_macro.h>
-
#include "fan.h"
#include "gpio_signal.h"
#include "hooks.h"
@@ -18,6 +12,12 @@
#include "system.h"
#include "util.h"
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/pwm.h>
+#include <zephyr/drivers/sensor.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/util_macro.h>
+
LOG_MODULE_REGISTER(fan_shim, LOG_LEVEL_ERR);
BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
@@ -43,6 +43,7 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
.rpm_min = DT_PROP(node_id, rpm_min), \
.rpm_start = DT_PROP(node_id, rpm_start), \
.rpm_max = DT_PROP(node_id, rpm_max), \
+ .rpm_deviation = DT_PROP(node_id, rpm_deviation), \
};
#define FAN_INST(node_id) \
@@ -61,14 +62,6 @@ DT_INST_FOREACH_CHILD(0, FAN_CONFIGS)
const struct fan_t fans[FAN_CH_COUNT] = { DT_INST_FOREACH_CHILD(0, FAN_INST) };
-/* Rpm deviation (Unit:percent) */
-#ifndef RPM_DEVIATION
-#define RPM_DEVIATION 7
-#endif
-
-/* Margin of target rpm */
-#define RPM_MARGIN(rpm_target) (((rpm_target)*RPM_DEVIATION) / 100)
-
/* Fan mode */
enum fan_mode {
/* FAN rpm mode */
@@ -132,9 +125,9 @@ static void fan_pwm_update(int ch)
LOG_DBG("FAN PWM %s set percent (%d), pulse %d", pwm_dev->name,
data->pwm_percent, pulse_ns);
- ret = pwm_set_dt(&cfg->pwm, cfg->pwm.period, pulse_ns);
+ ret = pwm_set_pulse_dt(&cfg->pwm, pulse_ns);
if (ret) {
- LOG_ERR("pwm_set() failed %s (%d)", pwm_dev->name, ret);
+ LOG_ERR("pwm_set_pulse_dt failed %s (%d)", pwm_dev->name, ret);
}
}
@@ -226,9 +219,10 @@ enum fan_status fan_smart_control(int ch)
int duty, rpm_diff;
int rpm_actual = data->rpm_actual;
int rpm_target = data->rpm_target;
+ int deviation = fans[ch].rpm->rpm_deviation;
/* wait rpm is stable */
- if (ABS(rpm_actual - data->rpm_pre) > RPM_MARGIN(rpm_actual)) {
+ if (ABS(rpm_actual - data->rpm_pre) > (rpm_target * deviation / 100)) {
data->rpm_pre = rpm_actual;
return FAN_STATUS_CHANGING;
}
@@ -243,7 +237,7 @@ enum fan_status fan_smart_control(int ch)
return FAN_STATUS_STOPPED;
}
- if (rpm_diff > RPM_MARGIN(rpm_target)) {
+ if (rpm_diff > (rpm_target * deviation / 100)) {
/* Increase PWM duty */
if (duty == 100) {
return FAN_STATUS_FRUSTRATED;
@@ -251,7 +245,7 @@ enum fan_status fan_smart_control(int ch)
fan_adjust_duty(ch, rpm_diff, duty);
return FAN_STATUS_CHANGING;
- } else if (rpm_diff < -RPM_MARGIN(rpm_target)) {
+ } else if (rpm_diff < -(rpm_target * deviation / 100)) {
/* Decrease PWM duty */
if (duty == 1 && rpm_target != 0) {
return FAN_STATUS_FRUSTRATED;
diff --git a/zephyr/shim/src/flash.c b/zephyr/shim/src/flash.c
index 8aa7deecf5..5b7079e450 100644
--- a/zephyr/shim/src/flash.c
+++ b/zephyr/shim/src/flash.c
@@ -3,17 +3,18 @@
* found in the LICENSE file.
*/
-#include <flash.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/drivers/flash.h>
-
#include "console.h"
#include "drivers/cros_flash.h"
#include "registers.h"
#include "task.h"
#include "util.h"
+#include <zephyr/drivers/flash.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
+#include <flash.h>
+
LOG_MODULE_REGISTER(shim_flash, LOG_LEVEL_ERR);
#if !DT_HAS_CHOSEN(cros_ec_flash_controller)
diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c
index 528569980d..a629c77a11 100644
--- a/zephyr/shim/src/gpio.c
+++ b/zephyr/shim/src/gpio.c
@@ -3,19 +3,19 @@
* found in the LICENSE file.
*/
-#include <zephyr/device.h>
-#include <zephyr/init.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-
#ifdef __REQUIRE_ZEPHYR_GPIOS__
#undef __REQUIRE_ZEPHYR_GPIOS__
#endif
+#include "cros_version.h"
#include "gpio.h"
#include "gpio/gpio.h"
#include "ioexpander.h"
#include "system.h"
-#include "cros_version.h"
+
+#include <zephyr/device.h>
+#include <zephyr/init.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(gpio_shim, LOG_LEVEL_ERR);
@@ -166,6 +166,11 @@ int gpio_or_ioex_get_level(int signal, int *value)
return EC_SUCCESS;
}
+/* Don't define any 1.8V bit if not supported. */
+#ifndef GPIO_VOLTAGE_1P8
+#define GPIO_VOLTAGE_1P8 0
+#endif
+
/* GPIO flags which are the same in Zephyr and this codebase */
#define GPIO_CONVERSION_SAME_BITS \
(GPIO_OPEN_DRAIN | GPIO_PULL_UP | GPIO_PULL_DOWN | GPIO_VOLTAGE_1P8 | \
@@ -250,7 +255,10 @@ const struct gpio_dt_spec *gpio_get_dt_spec(enum gpio_signal signal)
return &configs[signal].spec;
}
-static int init_gpios(const struct device *unused)
+/* Allow access to this function in tests so we can run it multiple times
+ * without having to create a new binary for each run.
+ */
+test_export_static int init_gpios(const struct device *unused)
{
gpio_flags_t flags;
bool is_sys_jumped = system_jumped_to_this_image();
@@ -317,9 +325,10 @@ void gpio_reset(enum gpio_signal signal)
void gpio_reset_port(const struct device *port)
{
for (size_t i = 0; i < ARRAY_SIZE(configs); ++i) {
- if (port == configs[i].spec.port)
+ if (port == configs[i].spec.port) {
gpio_pin_configure_dt(&configs[i].spec,
configs[i].init_flags);
+ }
}
}
@@ -334,12 +343,17 @@ void gpio_set_flags(enum gpio_signal signal, int flags)
void gpio_set_flags_by_mask(uint32_t port, uint32_t mask, uint32_t flags)
{
- int pin;
+ const gpio_flags_t zephyr_flags = convert_to_zephyr_flags(flags);
- for (pin = 0; pin < 8; pin++)
- if (mask & BIT(pin))
- gpio_configure_port_pin(port, pin,
- convert_to_zephyr_flags(flags));
+ /* Using __builtin_ctz here will guarantee that this loop is as
+ * performant as the underlying architecture allows it to be.
+ */
+ while (mask != 0) {
+ int pin = __builtin_ctz(mask);
+
+ gpio_configure_port_pin(port, pin, zephyr_flags);
+ mask &= ~BIT(pin);
+ }
}
int signal_is_gpio(int signal)
diff --git a/zephyr/shim/src/gpio_id.c b/zephyr/shim/src/gpio_id.c
index b994154cd1..e157e2d487 100644
--- a/zephyr/shim/src/gpio_id.c
+++ b/zephyr/shim/src/gpio_id.c
@@ -3,16 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-
#ifdef __REQUIRE_ZEPHYR_GPIOS__
#undef __REQUIRE_ZEPHYR_GPIOS__
#endif
+
#include "gpio.h"
#include "util.h"
-#define IS_BOARD_COMPATIBLE DT_NODE_HAS_COMPAT(DT_PATH(board), cros_ec_gpio_id)
-#define IS_SKU_COMPATIBLE DT_NODE_HAS_COMPAT(DT_PATH(sku), cros_ec_gpio_id)
+#include <zephyr/devicetree.h>
#define CONVERT_NUMERAL_SYSTEM_EVAL(system, bits, nbits) \
system##_from_bits(bits, nbits)
@@ -23,14 +21,15 @@
#define READ_PIN_FROM_PHANDLE(node_id, prop, idx) \
gpio_get_ternary(GPIO_SIGNAL(DT_PHANDLE_BY_IDX(node_id, prop, idx))),
-#if DT_NODE_EXISTS(DT_PATH(sku)) && IS_SKU_COMPATIBLE
+#define SKU_GPIO_ID_NODE DT_NODELABEL(gpio_id_sku)
+#if DT_NODE_HAS_STATUS(SKU_GPIO_ID_NODE, okay)
__override uint32_t board_get_sku_id(void)
{
static uint32_t sku_id = (uint32_t)-1;
if (sku_id == (uint32_t)-1) {
- int bits[] = { DT_FOREACH_PROP_ELEM(DT_PATH(sku), bits,
+ int bits[] = { DT_FOREACH_PROP_ELEM(SKU_GPIO_ID_NODE, bits,
READ_PIN_FROM_PHANDLE) };
if (sizeof(bits) == 0)
@@ -46,14 +45,15 @@ __override uint32_t board_get_sku_id(void)
#endif
-#if DT_NODE_EXISTS(DT_PATH(board)) && IS_BOARD_COMPATIBLE
+#define BOARD_GPIO_ID_NODE DT_NODELABEL(gpio_id_board)
+#if DT_NODE_HAS_STATUS(SKU_GPIO_ID_NODE, okay)
__override int board_get_version(void)
{
static int board_version = -1;
if (board_version == -1) {
- int bits[] = { DT_FOREACH_PROP_ELEM(DT_PATH(board), bits,
+ int bits[] = { DT_FOREACH_PROP_ELEM(BOARD_GPIO_ID_NODE, bits,
READ_PIN_FROM_PHANDLE) };
if (sizeof(bits) == 0)
@@ -68,3 +68,7 @@ __override int board_get_version(void)
}
#endif
+
+BUILD_ASSERT(DT_NODE_HAS_STATUS(SKU_GPIO_ID_NODE, okay) ||
+ DT_NODE_HAS_STATUS(BOARD_GPIO_ID_NODE, okay),
+ "neither sku or board id nodelabels found");
diff --git a/zephyr/shim/src/gpio_int.c b/zephyr/shim/src/gpio_int.c
index 8406f3abe8..761e7e7b3c 100644
--- a/zephyr/shim/src/gpio_int.c
+++ b/zephyr/shim/src/gpio_int.c
@@ -3,18 +3,18 @@
* found in the LICENSE file.
*/
-#include <zephyr/device.h>
-#include <zephyr/init.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-
#ifdef __REQUIRE_ZEPHYR_GPIOS__
#undef __REQUIRE_ZEPHYR_GPIOS__
#endif
+#include "cros_version.h"
#include "gpio.h"
#include "gpio/gpio.h"
#include "gpio/gpio_int.h"
-#include "cros_version.h"
+
+#include <zephyr/device.h>
+#include <zephyr/init.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(gpio_int, LOG_LEVEL_ERR);
diff --git a/zephyr/shim/src/hooks.c b/zephyr/shim/src/hooks.c
index 3f11a578c5..b8f9b917e4 100644
--- a/zephyr/shim/src/hooks.c
+++ b/zephyr/shim/src/hooks.c
@@ -3,18 +3,19 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-
-#include <ap_power/ap_power.h>
-#include <ap_power/ap_power_events.h>
#include "common.h"
#include "console.h"
#include "ec_tasks.h"
-#include "hooks.h"
#include "hook_types.h"
+#include "hooks.h"
#include "task.h"
#include "timer.h"
+#include <zephyr/kernel.h>
+
+#include <ap_power/ap_power.h>
+#include <ap_power/ap_power_events.h>
+
/*
* hook_registry maps each hook_type to the list of handlers for that hook type.
*
diff --git a/zephyr/shim/src/host_command.c b/zephyr/shim/src/host_command.c
index c5a51332a1..16f5ae66d8 100644
--- a/zephyr/shim/src/host_command.c
+++ b/zephyr/shim/src/host_command.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-
#include "host_command.h"
#include "task.h"
+#include <zephyr/kernel.h>
+
struct host_command *zephyr_find_host_command(int command)
{
STRUCT_SECTION_FOREACH(host_command, cmd)
diff --git a/zephyr/shim/src/hwtimer.c b/zephyr/shim/src/hwtimer.c
index d99f7a826b..cefbe4eb7f 100644
--- a/zephyr/shim/src/hwtimer.c
+++ b/zephyr/shim/src/hwtimer.c
@@ -3,10 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
+#include "hwtimer.h"
+
#include <stdint.h>
-#include "hwtimer.h"
+#include <zephyr/kernel.h>
uint64_t __hw_clock_source_read64(void)
{
diff --git a/zephyr/shim/src/i2c.c b/zephyr/shim/src/i2c.c
index 0074327826..53766f1683 100644
--- a/zephyr/shim/src/i2c.c
+++ b/zephyr/shim/src/i2c.c
@@ -3,19 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/sys/util.h>
-#include <zephyr/drivers/i2c.h>
-
#include "console.h"
#include "i2c.h"
#include "i2c/i2c.h"
-/*
- * The named-i2c-ports node is required by the I2C shim
- */
-#if !DT_NODE_EXISTS(DT_PATH(named_i2c_ports))
-#error I2C shim requires the named-i2c-ports node to be defined.
-#endif
+#include <zephyr/drivers/i2c.h>
+#include <zephyr/sys/util.h>
/*
* Initialize device bindings in i2c_devices.
diff --git a/zephyr/shim/src/ioex.c b/zephyr/shim/src/ioex.c
index a5d685bc48..afda051c8a 100644
--- a/zephyr/shim/src/ioex.c
+++ b/zephyr/shim/src/ioex.c
@@ -3,15 +3,16 @@
* found in the LICENSE file.
*/
-#include <zephyr/init.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-#include "common.h"
#ifdef __REQUIRE_ZEPHYR_GPIOS__
#undef __REQUIRE_ZEPHYR_GPIOS__
#endif
+#include "common.h"
#include "ioexpander.h"
+#include <zephyr/init.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
LOG_MODULE_REGISTER(ioex_shim, LOG_LEVEL_ERR);
int ioex_init(int ioex)
diff --git a/zephyr/shim/src/ioex_drv.c b/zephyr/shim/src/ioex_drv.c
index 3baa4777fd..98f67a4459 100644
--- a/zephyr/shim/src/ioex_drv.c
+++ b/zephyr/shim/src/ioex_drv.c
@@ -3,38 +3,15 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_ioex_port
-#define DT_DRV_COMPAT_CHIP cros_ioex_chip
-
-#include <zephyr/device.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/i2c.h>
-#include <errno.h>
#ifdef __REQUIRE_ZEPHYR_GPIOS__
#undef __REQUIRE_ZEPHYR_GPIOS__
#endif
-#include "gpio.h"
-#include <zephyr/drivers/gpio/gpio_utils.h>
-#include <zephyr/init.h>
-#include <zephyr/kernel.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/sys/byteorder.h>
-#include <zephyr/sys/util.h>
#include "common.h"
#include "config.h"
-#include "i2c.h"
-#include "ioexpander.h"
-
/* Include drivers if enabled */
-#ifdef CONFIG_PLATFORM_EC_IOEX_CCGXXF
-#include "driver/tcpm/ccgxxf.h"
-#endif
#ifdef CONFIG_PLATFORM_EC_IOEX_IT8801
#include "driver/ioexpander/it8801.h"
#endif
-#ifdef CONFIG_PLATFORM_EC_IOEX_NCT38XX
-#include "driver/tcpm/nct38xx.h"
-#endif
#ifdef CONFIG_PLATFORM_EC_IOEX_PCA9675
#include "driver/ioexpander/pca9675.h"
#endif
@@ -44,6 +21,30 @@
#ifdef CONFIG_PLATFORM_EC_IOEX_TCA64XXA
#include "driver/ioexpander/tca64xxa.h"
#endif
+#ifdef CONFIG_PLATFORM_EC_IOEX_CCGXXF
+#include "driver/tcpm/ccgxxf.h"
+#endif
+#ifdef CONFIG_PLATFORM_EC_IOEX_NCT38XX
+#include "driver/tcpm/nct38xx.h"
+#endif
+#include "gpio.h"
+#include "i2c.h"
+#include "ioexpander.h"
+
+#include <errno.h>
+
+#include <zephyr/device.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_utils.h>
+#include <zephyr/drivers/i2c.h>
+#include <zephyr/init.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/sys/byteorder.h>
+#include <zephyr/sys/util.h>
+
+#define DT_DRV_COMPAT cros_ioex_port
+#define DT_DRV_COMPAT_CHIP cros_ioex_chip
LOG_MODULE_REGISTER(cros_ioex_port, CONFIG_GPIO_LOG_LEVEL);
diff --git a/zephyr/shim/src/keyboard_raw.c b/zephyr/shim/src/keyboard_raw.c
index c9f465d06d..73b3c2acaf 100644
--- a/zephyr/shim/src/keyboard_raw.c
+++ b/zephyr/shim/src/keyboard_raw.c
@@ -5,13 +5,14 @@
/* Functions needed by keyboard scanner module for Chrome EC */
+#include "drivers/cros_kb_raw.h"
+#include "keyboard_raw.h"
+
#include <zephyr/device.h>
-#include <zephyr/logging/log.h>
-#include <soc.h>
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
-#include "drivers/cros_kb_raw.h"
-#include "keyboard_raw.h"
+#include <soc.h>
LOG_MODULE_REGISTER(shim_cros_kb_raw, LOG_LEVEL_ERR);
@@ -63,3 +64,11 @@ void keyboard_raw_enable_interrupt(int enable)
{
cros_kb_raw_enable_interrupt(cros_kb_raw_dev, enable);
}
+
+/**
+ * Enable or disable keyboard alternative function.
+ */
+void keybaord_raw_config_alt(bool enable)
+{
+ cros_kb_raw_config_alt(cros_kb_raw_dev, enable);
+}
diff --git a/zephyr/shim/src/keyscan.c b/zephyr/shim/src/keyscan.c
index 514885379b..46bb5fcc7f 100644
--- a/zephyr/shim/src/keyscan.c
+++ b/zephyr/shim/src/keyscan.c
@@ -3,15 +3,18 @@
* found in the LICENSE file.
*/
-#define DT_DRV_COMPAT cros_keyscan
+#define DT_DRV_COMPAT cros_ec_keyscan
+
+#include "keyboard_scan.h"
#include <assert.h>
+
#include <zephyr/kernel.h>
-#include <soc.h>
-#include "keyboard_scan.h"
+#include <soc.h>
-#if DT_NODE_EXISTS(DT_INST(0, cros_keyscan))
+BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
+ "Exactly one instance of cros-ec,keyscan should be defined.");
/* The keyboard matrix should have at least enough columns for the
* standard keyboard with no keypad.
@@ -31,4 +34,3 @@ __override struct keyboard_scan_config keyscan_config = {
.poll_timeout_us = DT_INST_PROP(0, poll_timeout),
.actual_key_mask = DT_INST_PROP(0, actual_key_mask),
};
-#endif
diff --git a/zephyr/shim/src/led_driver/CMakeLists.txt b/zephyr/shim/src/led_driver/CMakeLists.txt
index 179f540fe1..7f513ed425 100644
--- a/zephyr/shim/src/led_driver/CMakeLists.txt
+++ b/zephyr/shim/src/led_driver/CMakeLists.txt
@@ -3,5 +3,5 @@
# found in the LICENSE file.
zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT led.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT led_gpio.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT led_pwm.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT_GPIO led_gpio.c)
+zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_DT_PWM led_pwm.c)
diff --git a/zephyr/shim/src/led_driver/led.c b/zephyr/shim/src/led_driver/led.c
index 011632ac83..9a1c07b310 100644
--- a/zephyr/shim/src/led_driver/led.c
+++ b/zephyr/shim/src/led_driver/led.c
@@ -5,7 +5,7 @@
* Power and battery LED control.
*/
-#include <zephyr/drivers/gpio.h>
+#define DT_DRV_COMPAT cros_ec_led_policy
#include "battery.h"
#include "charge_manager.h"
@@ -21,10 +21,12 @@
#include "util.h"
#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(led, LOG_LEVEL_ERR);
-#define LED_COLOR_NODE DT_PATH(led_colors)
+BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
+ "Exactly one instance of cros-ec,led-policy should be defined.");
struct led_color_node_t {
struct led_pins_node_t *pins_node;
@@ -33,10 +35,12 @@ struct led_color_node_t {
#define DECLARE_PINS_NODE(id) extern struct led_pins_node_t PINS_NODE(id);
-#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED)
-DT_FOREACH_CHILD(PWM_LED_PINS_NODE, DECLARE_PINS_NODE)
-#elif DT_HAS_COMPAT_STATUS_OKAY(COMPAT_GPIO_LED)
-DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, DECLARE_PINS_NODE)
+#if CONFIG_PLATFORM_EC_LED_DT_PWM
+DT_FOREACH_CHILD(DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_pwm_led_pins),
+ DECLARE_PINS_NODE)
+#elif CONFIG_PLATFORM_EC_LED_DT_GPIO
+DT_FOREACH_CHILD(DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_gpio_led_pins),
+ DECLARE_PINS_NODE)
#endif
/*
@@ -113,8 +117,8 @@ struct node_prop_t {
LED_COLOR_INIT(3, 4, state_id), \
} },
-static const struct node_prop_t node_array[] = { DT_FOREACH_CHILD(
- LED_COLOR_NODE, SET_LED_VALUES) };
+static const struct node_prop_t node_array[] = { DT_INST_FOREACH_CHILD(
+ 0, SET_LED_VALUES) };
test_export_static enum power_state get_chipset_state(void)
{
diff --git a/zephyr/shim/src/led_driver/led.h b/zephyr/shim/src/led_driver/led.h
index b8cedf5af7..a186d97da9 100644
--- a/zephyr/shim/src/led_driver/led.h
+++ b/zephyr/shim/src/led_driver/led.h
@@ -10,9 +10,6 @@
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/pwm.h>
-#define COMPAT_GPIO_LED cros_ec_gpio_led_pins
-#define COMPAT_PWM_LED cros_ec_pwm_led_pins
-
#define PINS_NODE(id) DT_CAT(PIN_NODE_, id)
#define PINS_ARRAY(id) DT_CAT(PINS_ARRAY_, id)
@@ -35,9 +32,6 @@
COND_CODE_1(DT_NODE_HAS_PROP(id, enum_name), \
(LED_ENUM(id, enum_name), ), ())
-#define GPIO_LED_PINS_NODE DT_PATH(gpio_led_pins)
-#define PWM_LED_PINS_NODE DT_PATH(pwm_led_pins)
-
enum led_color {
LED_OFF,
LED_RED,
@@ -85,12 +79,12 @@ struct led_pins_node_t {
/* Brightness Range color, only used to support ectool functionality */
enum ec_led_colors br_color;
-#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_GPIO_LED)
+#if CONFIG_PLATFORM_EC_LED_DT_GPIO
/* Array of GPIO pins to set to enable particular color */
struct gpio_pin_t *gpio_pins;
#endif
-#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED)
+#if CONFIG_PLATFORM_EC_LED_DT_PWM
/* Array of PWM pins to set to enable particular color */
struct pwm_pin_t *pwm_pins;
#endif
diff --git a/zephyr/shim/src/led_driver/led_gpio.c b/zephyr/shim/src/led_driver/led_gpio.c
index 122794dc82..d6af1772c2 100644
--- a/zephyr/shim/src/led_driver/led_gpio.c
+++ b/zephyr/shim/src/led_driver/led_gpio.c
@@ -5,6 +5,8 @@
* GPIO LED control.
*/
+#define DT_DRV_COMPAT cros_ec_gpio_led_pins
+
#include "ec_commands.h"
#include "led.h"
#include "util.h"
@@ -13,20 +15,21 @@
#include <zephyr/drivers/gpio.h>
#include <zephyr/logging/log.h>
-#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_GPIO_LED)
-
LOG_MODULE_REGISTER(gpio_led, LOG_LEVEL_ERR);
+BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
+ "Exactly one instance of cros-ec,gpio-led-pins should be defined.");
+
#define SET_PIN(node_id, prop, i) \
{ .signal = GPIO_SIGNAL(DT_PHANDLE_BY_IDX(node_id, prop, i)), \
- .val = DT_PHA_BY_IDX(node_id, prop, i, value) },
+ .val = DT_PROP_BY_IDX(node_id, led_values, i) },
#define SET_GPIO_PIN(node_id) \
{ DT_FOREACH_PROP_ELEM(node_id, led_pins, SET_PIN) };
#define GEN_PINS_ARRAY(id) struct gpio_pin_t PINS_ARRAY(id)[] = SET_GPIO_PIN(id)
-DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, GEN_PINS_ARRAY)
+DT_INST_FOREACH_CHILD(0, GEN_PINS_ARRAY)
#define SET_PIN_NODE(node_id) \
{ .led_color = GET_PROP(node_id, led_color), \
@@ -41,14 +44,14 @@ DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, GEN_PINS_ARRAY)
#define GEN_PINS_NODES(id) \
const struct led_pins_node_t PINS_NODE(id) = SET_PIN_NODE(id)
-DT_FOREACH_CHILD(GPIO_LED_PINS_NODE, GEN_PINS_NODES)
+DT_INST_FOREACH_CHILD(0, GEN_PINS_NODES)
/*
* Array of pointers to each pin node
*/
#define PINS_NODE_PTR(id) &PINS_NODE(id),
-const struct led_pins_node_t *pins_node[] = { DT_FOREACH_CHILD(
- GPIO_LED_PINS_NODE, PINS_NODE_PTR) };
+const struct led_pins_node_t *pins_node[] = { DT_INST_FOREACH_CHILD(
+ 0, PINS_NODE_PTR) };
/*
* Set all the GPIO pins defined in the node to the defined value,
@@ -138,5 +141,3 @@ const struct led_pins_node_t *led_get_node(enum led_color color,
return pin_node;
}
#endif /* TEST_BUILD */
-
-#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 00002fc32e..9fcafeea53 100644
--- a/zephyr/shim/src/led_driver/led_pwm.c
+++ b/zephyr/shim/src/led_driver/led_pwm.c
@@ -5,6 +5,8 @@
* PWM LED control.
*/
+#define DT_DRV_COMPAT cros_ec_pwm_led_pins
+
#include "ec_commands.h"
#include "led.h"
#include "util.h"
@@ -13,10 +15,11 @@
#include <zephyr/drivers/pwm.h>
#include <zephyr/logging/log.h>
-#if DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED)
-
LOG_MODULE_REGISTER(pwm_led, LOG_LEVEL_ERR);
+BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
+ "Exactly one instance of cros-ec,pwm-led-pins should be defined.");
+
/*
* Period in ns from frequency(Hz) defined in pins node
* period in sec = 1/freq
@@ -33,23 +36,23 @@ LOG_MODULE_REGISTER(pwm_led, LOG_LEVEL_ERR);
.pwm = PWM_DT_SPEC_GET(DT_PHANDLE_BY_IDX(node_id, prop, i)), \
.pulse_ns = DIV_ROUND_NEAREST( \
DT_PWMS_PERIOD(DT_PHANDLE_BY_IDX(node_id, prop, i)) * \
- DT_PHA_BY_IDX(node_id, prop, i, value), \
+ DT_PROP_BY_IDX(node_id, led_values, i), \
100), \
},
#define SET_PWM_PIN(node_id) \
- { DT_FOREACH_PROP_ELEM(node_id, led_pins, SET_PIN) };
+ { DT_FOREACH_PROP_ELEM(node_id, led_pwms, SET_PIN) };
#define GEN_PINS_ARRAY(id) struct pwm_pin_t PINS_ARRAY(id)[] = SET_PWM_PIN(id)
-DT_FOREACH_CHILD(PWM_LED_PINS_NODE, GEN_PINS_ARRAY)
+DT_INST_FOREACH_CHILD(0, GEN_PINS_ARRAY)
#define SET_PIN_NODE(node_id) \
{ .led_color = GET_PROP(node_id, led_color), \
.led_id = GET_PROP(node_id, led_id), \
.br_color = GET_PROP_NVE(node_id, br_color), \
.pwm_pins = PINS_ARRAY(node_id), \
- .pins_count = DT_PROP_LEN(node_id, led_pins) };
+ .pins_count = DT_PROP_LEN(node_id, led_pwms) };
/*
* Initialize led_pins_node_t struct for each pin node defined
@@ -57,14 +60,14 @@ DT_FOREACH_CHILD(PWM_LED_PINS_NODE, GEN_PINS_ARRAY)
#define GEN_PINS_NODES(id) \
const struct led_pins_node_t PINS_NODE(id) = SET_PIN_NODE(id)
-DT_FOREACH_CHILD(PWM_LED_PINS_NODE, GEN_PINS_NODES)
+DT_INST_FOREACH_CHILD(0, GEN_PINS_NODES)
/*
* Array of pointers to each pin node
*/
#define PINS_NODE_PTR(id) &PINS_NODE(id),
-const struct led_pins_node_t *pins_node[] = { DT_FOREACH_CHILD(
- PWM_LED_PINS_NODE, PINS_NODE_PTR) };
+const struct led_pins_node_t *pins_node[] = { DT_INST_FOREACH_CHILD(
+ 0, PINS_NODE_PTR) };
/*
* Set all the PWM channels defined in the node to the defined value,
@@ -147,4 +150,3 @@ __override int led_is_supported(enum ec_led_id led_id)
return ((1 << (int)led_id) & supported_leds);
}
-#endif /* DT_HAS_COMPAT_STATUS_OKAY(COMPAT_PWM_LED) */
diff --git a/zephyr/shim/src/log_backend_console_buffer.c b/zephyr/shim/src/log_backend_console_buffer.c
index cafb690b87..3f455469c4 100644
--- a/zephyr/shim/src/log_backend_console_buffer.c
+++ b/zephyr/shim/src/log_backend_console_buffer.c
@@ -1,13 +1,13 @@
-/* Copyright 2022 The ChromiumOS Authors.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "console.h"
+
#include <zephyr/logging/log_backend.h>
-#include <zephyr/logging/log_output.h>
#include <zephyr/logging/log_backend_std.h>
-
-#include "console.h"
+#include <zephyr/logging/log_output.h>
static uint8_t
char_out_buf[CONFIG_PLATFORM_EC_LOG_BACKEND_CONSOLE_BUFFER_TMP_BUF_SIZE];
diff --git a/zephyr/shim/src/motionsense_sensors.c b/zephyr/shim/src/motionsense_sensors.c
index 8d886192ac..72bb677af6 100644
--- a/zephyr/shim/src/motionsense_sensors.c
+++ b/zephyr/shim/src/motionsense_sensors.c
@@ -3,14 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/logging/log.h>
-#include "common.h"
#include "accelgyro.h"
+#include "common.h"
#include "cros_cbi.h"
-#include "hooks.h"
#include "gpio/gpio_int.h"
+#include "hooks.h"
#include "motionsense_sensors.h"
+#include <zephyr/logging/log.h>
+
LOG_MODULE_REGISTER(shim_cros_motionsense_sensors);
#define SENSOR_MUTEX_NODE DT_PATH(motionsense_mutex)
diff --git a/zephyr/shim/src/panic.c b/zephyr/shim/src/panic.c
index 9ff8a46f62..2ac8328e9e 100644
--- a/zephyr/shim/src/panic.c
+++ b/zephyr/shim/src/panic.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
+#include "common.h"
+#include "panic.h"
+
#include <zephyr/arch/cpu.h>
#include <zephyr/fatal.h>
+#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/logging/log_ctrl.h>
-#include <zephyr/kernel.h>
-
-#include "common.h"
-#include "panic.h"
/*
* Arch-specific configuration
diff --git a/zephyr/shim/src/power.c b/zephyr/shim/src/power.c
index 007c40ab71..ab58cf391d 100644
--- a/zephyr/shim/src/power.c
+++ b/zephyr/shim/src/power.c
@@ -3,16 +3,38 @@
* found in the LICENSE file.
*/
-#include <zephyr/sys/util.h>
-
#include "console.h"
#include "power.h"
#include "power/power.h"
-#if (SYSTEM_DT_POWER_SIGNAL_CONFIG)
+#include <zephyr/sys/util.h>
+
+#define GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid) \
+ DT_STRING_UPPER_TOKEN(DT_PROP(cid, power_gpio_pin), enum_name)
+#define GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid) \
+ (DT_GPIO_FLAGS(DT_PROP(cid, power_gpio_pin), gpios) & \
+ GPIO_ACTIVE_LOW ? \
+ POWER_SIGNAL_ACTIVE_LOW : \
+ POWER_SIGNAL_ACTIVE_HIGH)
+#define GEN_POWER_SIGNAL_STRUCT_ENTRY_NAME(cid) DT_PROP(cid, power_enum_name)
+
+#define GEN_POWER_SIGNAL_STRUCT_ENTRY(cid) \
+ { \
+ .gpio = GEN_POWER_SIGNAL_STRUCT_ENTRY_GPIO(cid), \
+ .flags = GEN_POWER_SIGNAL_STRUCT_ENTRY_FLAGS(cid), \
+ .name = GEN_POWER_SIGNAL_STRUCT_ENTRY_NAME(cid) \
+ }
+#define GEN_POWER_SIGNAL_STRUCT(cid) \
+ [GEN_POWER_SIGNAL_ENUM_ENTRY(cid)] = GEN_POWER_SIGNAL_STRUCT_ENTRY(cid),
const struct power_signal_info power_signal_list[] = { DT_FOREACH_CHILD(
POWER_SIGNAL_LIST_NODE, GEN_POWER_SIGNAL_STRUCT) };
BUILD_ASSERT(ARRAY_SIZE(power_signal_list) == POWER_SIGNAL_COUNT);
-#endif /* SYSTEM_DT_POWER_SIGNAL_CONFIG */
+/*
+ * Verify the number of required power-signals are specified in
+ * the DeviceTree
+ */
+#define POWER_SIGNALS_REQUIRED \
+ DT_PROP(POWER_SIGNAL_LIST_NODE, power_signals_required)
+BUILD_ASSERT(POWER_SIGNALS_REQUIRED == POWER_SIGNAL_COUNT);
diff --git a/zephyr/shim/src/ppc.c b/zephyr/shim/src/ppc.c
index c4c54d002f..c15c6900b1 100644
--- a/zephyr/shim/src/ppc.c
+++ b/zephyr/shim/src/ppc.c
@@ -3,14 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-#include "usbc_ppc.h"
+#include "usbc/ppc.h"
#include "usbc/ppc_aoz1380.h"
#include "usbc/ppc_nx20p348x.h"
#include "usbc/ppc_rt1739.h"
#include "usbc/ppc_sn5s330.h"
#include "usbc/ppc_syv682x.h"
-#include "usbc/ppc.h"
+#include "usbc_ppc.h"
+
+#include <zephyr/devicetree.h>
#if DT_HAS_COMPAT_STATUS_OKAY(AOZ1380_COMPAT) || \
DT_HAS_COMPAT_STATUS_OKAY(NX20P348X_COMPAT) || \
diff --git a/zephyr/shim/src/pwm_hc.c b/zephyr/shim/src/pwm_hc.c
index c0350c733f..3c7b2f1737 100644
--- a/zephyr/shim/src/pwm_hc.c
+++ b/zephyr/shim/src/pwm_hc.c
@@ -3,20 +3,20 @@
* found in the LICENSE file.
*/
-#include <zephyr/device.h>
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/pwm.h>
-#include <zephyr/logging/log.h>
-
#include "common.h"
#include "console.h"
#include "drivers/cros_displight.h"
#include "ec_commands.h"
#include "host_command.h"
-#include "pwm.h"
#include "keyboard_backlight.h"
+#include "pwm.h"
#include "util.h"
+#include <zephyr/device.h>
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/pwm.h>
+#include <zephyr/logging/log.h>
+
LOG_MODULE_REGISTER(pwm_shim, LOG_LEVEL_ERR);
#define HAS_PWM_GENERIC_CHANNEL(compat) \
diff --git a/zephyr/shim/src/pwm_led.c b/zephyr/shim/src/pwm_led.c
index 498c543ffb..81cc3a9c28 100644
--- a/zephyr/shim/src/pwm_led.c
+++ b/zephyr/shim/src/pwm_led.c
@@ -6,6 +6,7 @@
#define DT_DRV_COMPAT cros_ec_pwm_leds
#include <string.h>
+
#include <zephyr/devicetree.h>
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
diff --git a/zephyr/shim/src/rtc.c b/zephyr/shim/src/rtc.c
index c8a0511c95..3acf6a3bb6 100644
--- a/zephyr/shim/src/rtc.c
+++ b/zephyr/shim/src/rtc.c
@@ -3,9 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/logging/log.h>
-#include <zephyr/kernel.h>
-
#include "console.h"
#include "drivers/cros_rtc.h"
#include "hooks.h"
@@ -13,6 +10,9 @@
#include "system.h"
#include "util.h"
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
LOG_MODULE_REGISTER(shim_cros_rtc, LOG_LEVEL_ERR);
#define CROS_RTC_NODE DT_CHOSEN(cros_rtc)
diff --git a/zephyr/shim/src/switchcap_gpio.c b/zephyr/shim/src/switchcap_gpio.c
index 23bed493c8..982e5ff98c 100644
--- a/zephyr/shim/src/switchcap_gpio.c
+++ b/zephyr/shim/src/switchcap_gpio.c
@@ -3,33 +3,24 @@
* found in the LICENSE file.
*/
+#define DT_DRV_COMPAT cros_ec_switchcap_gpio
+
+#include "common.h"
+
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
-#include "common.h"
/* TODO(b/218600962): Consolidate switchcap code. */
-#if DT_NODE_EXISTS(DT_PATH(switchcap))
-
-#if !DT_NODE_HAS_COMPAT(DT_PATH(switchcap), switchcap_gpio)
-#error "Invalid /switchcap node in device tree"
-#endif
+#define SC_PIN_ENABLE_GPIO DT_INST_PROP(0, enable_pin)
+#define SC_PIN_ENABLE GPIO_DT_FROM_NODE(SC_PIN_ENABLE_GPIO)
-#define SC_PIN_ENABLE_PHANDLE \
- DT_PHANDLE_BY_IDX(DT_PATH(switchcap), enable_pin, 0)
-#define SC_PIN_ENABLE GPIO_DT_FROM_NODE(SC_PIN_ENABLE_PHANDLE)
+#define SC_PIN_POWER_GOOD_GPIO DT_INST_PROP(0, power_good_pin)
+#define SC_PIN_POWER_GOOD_EXISTS DT_NODE_EXISTS(SC_PIN_POWER_GOOD_GPIO)
+#define SC_PIN_POWER_GOOD GPIO_DT_FROM_NODE(SC_PIN_POWER_GOOD_GPIO)
-#define SC_PIN_POWER_GOOD_PHANDLE \
- DT_PHANDLE_BY_IDX(DT_PATH(switchcap), power_good_pin, 0)
-#define SC_PIN_POWER_GOOD_EXISTS DT_NODE_EXISTS(SC_PIN_POWER_GOOD_PHANDLE)
-#define SC_PIN_POWER_GOOD GPIO_DT_FROM_NODE(SC_PIN_POWER_GOOD_PHANDLE)
-
-#if DT_NODE_HAS_PROP(DT_PATH(switchcap), poff_delay_ms)
-static const int32_t poff_delay_ms = DT_PROP(DT_PATH(switchcap), poff_delay_ms);
-#else
-static const int32_t poff_delay_ms;
-#endif
+static const int32_t poff_delay_ms = DT_INST_PROP_OR(0, poff_delay_ms, 0);
void board_set_switchcap_power(int enable)
{
@@ -51,5 +42,3 @@ int board_is_switchcap_power_good(void)
return 1;
#endif
}
-
-#endif
diff --git a/zephyr/shim/src/switchcap_ln9310.c b/zephyr/shim/src/switchcap_ln9310.c
index 7c5fd4ed8d..54087ef6f2 100644
--- a/zephyr/shim/src/switchcap_ln9310.c
+++ b/zephyr/shim/src/switchcap_ln9310.c
@@ -3,27 +3,23 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/gpio.h>
+#define DT_DRV_COMPAT lion_ln9310
+
#include "common.h"
#include "ln9310.h"
-/* TODO(b/218600962): Consolidate switchcap code. */
-
-#if DT_NODE_EXISTS(DT_PATH(switchcap))
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
-#if !DT_NODE_HAS_COMPAT(DT_PATH(switchcap), switchcap_ln9310)
-#error "Invalid /switchcap node in device tree"
-#endif
+/* TODO(b/218600962): Consolidate switchcap code. */
-#define SC_PIN_ENABLE_PHANDLE \
- DT_PHANDLE_BY_IDX(DT_PATH(switchcap), enable_pin, 0)
-#define SC_PIN_ENABLE GPIO_DT_FROM_NODE(SC_PIN_ENABLE_PHANDLE)
+#define SC_PIN_ENABLE_GPIO DT_INST_PROP(0, enable_pin)
+#define SC_PIN_ENABLE GPIO_DT_FROM_NODE(SC_PIN_ENABLE_GPIO)
-#define SC_PORT_PHANDLE DT_PHANDLE(DT_PATH(switchcap), port)
-#define SC_PORT DT_STRING_UPPER_TOKEN_BY_IDX(SC_PORT_PHANDLE, enum_names, 0)
+#define SC_PORT_NODE DT_INST_PHANDLE(0, port)
+#define SC_PORT DT_STRING_UPPER_TOKEN_BY_IDX(SC_PORT_NODE, enum_names, 0)
-#define SC_ADDR_FLAGS DT_STRING_UPPER_TOKEN(DT_PATH(switchcap), addr_flags)
+#define SC_ADDR_FLAGS DT_INST_STRING_UPPER_TOKEN(0, addr_flags)
void board_set_switchcap_power(int enable)
{
@@ -45,5 +41,3 @@ const struct ln9310_config_t ln9310_config = {
.i2c_port = SC_PORT,
.i2c_addr_flags = SC_ADDR_FLAGS,
};
-
-#endif
diff --git a/zephyr/shim/src/system.c b/zephyr/shim/src/system.c
index 53e651ec03..0b47782b42 100644
--- a/zephyr/shim/src/system.c
+++ b/zephyr/shim/src/system.c
@@ -3,17 +3,18 @@
* found in the LICENSE file.
*/
-#include <zephyr/device.h>
-#include <zephyr/drivers/bbram.h>
-#include <drivers/cros_system.h>
-#include <zephyr/logging/log.h>
-
#include "common.h"
#include "console.h"
#include "cros_version.h"
#include "system.h"
#include "watchdog.h"
+#include <zephyr/device.h>
+#include <zephyr/drivers/bbram.h>
+#include <zephyr/logging/log.h>
+
+#include <drivers/cros_system.h>
+
#define BBRAM_REGION_PD0 DT_PATH(named_bbram_regions, pd0)
#define BBRAM_REGION_PD1 DT_PATH(named_bbram_regions, pd1)
#define BBRAM_REGION_PD2 DT_PATH(named_bbram_regions, pd2)
@@ -342,7 +343,7 @@ static int check_reset_cause(void)
return 0;
}
-static int system_preinitialize(const struct device *unused)
+test_export_static int system_preinitialize(const struct device *unused)
{
ARG_UNUSED(unused);
diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c
index 35d4ab7c42..68ebbbc482 100644
--- a/zephyr/shim/src/tasks.c
+++ b/zephyr/shim/src/tasks.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/init.h>
-#include <zephyr/sys/atomic.h>
-#include <zephyr/shell/shell.h>
-
#include "common.h"
#include "host_command.h"
-#include "timer.h"
#include "task.h"
+#include "timer.h"
+
+#include <zephyr/init.h>
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/sys/atomic.h>
/* Ensure that the idle task is at lower priority than lowest priority task. */
BUILD_ASSERT(EC_TASK_PRIORITY(EC_TASK_PRIO_LOWEST) < K_IDLE_PRIO,
@@ -105,7 +105,7 @@ atomic_t *task_get_event_bitmap(task_id_t cros_task_id)
data = task_get_base_data(cros_task_id);
- return &data->event_mask;
+ return data == NULL ? NULL : &data->event_mask;
}
void task_set_event(task_id_t cros_task_id, uint32_t event)
@@ -114,8 +114,10 @@ void task_set_event(task_id_t cros_task_id, uint32_t event)
data = task_get_base_data(cros_task_id);
- atomic_or(&data->event_mask, event);
- k_poll_signal_raise(&data->new_event, 0);
+ if (data != NULL) {
+ atomic_or(&data->event_mask, event);
+ k_poll_signal_raise(&data->new_event, 0);
+ }
}
uint32_t task_wait_event(int timeout_us)
@@ -124,6 +126,8 @@ uint32_t task_wait_event(int timeout_us)
data = task_get_base_data(task_get_current());
+ __ASSERT_NO_MSG(data != NULL);
+
const k_timeout_t timeout = (timeout_us == -1) ? K_FOREVER :
K_USEC(timeout_us);
const int64_t tick_deadline =
@@ -152,12 +156,12 @@ uint32_t task_wait_event(int timeout_us)
if (events == 0) {
const int64_t ticks_left = tick_deadline - k_uptime_ticks();
+ events |= TASK_EVENT_TIMER;
+
if (ticks_left > 0) {
return task_wait_event(
k_ticks_to_us_near64(ticks_left));
}
-
- events |= TASK_EVENT_TIMER;
}
return events;
@@ -309,18 +313,26 @@ int task_start_called(void)
{
return tasks_started;
}
-
+/*
+ * TODO(b/190203712): Implement this
+ * LCOV_EXCL_START
+ */
void task_disable_task(task_id_t tskid)
{
- /* TODO(b/190203712): Implement this */
}
+/* LCOV_EXCL_STOP */
+/*
+ * This function cannot be tested since it is architecture specific.
+ * LCOV_EXCL_START
+ */
void task_clear_pending_irq(int irq)
{
#if CONFIG_ITE_IT8XXX2_INTC
ite_intc_isr_clear(irq);
#endif
}
+/* LCOV_EXCL_STOP */
void task_enable_irq(int irq)
{
@@ -339,11 +351,3 @@ inline bool in_deferred_context(void)
*/
return (k_current_get() == &k_sys_work_q.thread);
}
-
-#if IS_ENABLED(CONFIG_KERNEL_SHELL) && IS_ENABLED(CONFIG_THREAD_MONITOR)
-static int taskinfo(const struct shell *shell, size_t argc, char **argv)
-{
- return shell_execute_cmd(shell, "kernel threads");
-}
-SHELL_CMD_REGISTER(taskinfo, NULL, "Threads statistics", taskinfo);
-#endif
diff --git a/zephyr/shim/src/tcpc.c b/zephyr/shim/src/tcpc.c
index ba251a196b..6ddad71535 100644
--- a/zephyr/shim/src/tcpc.c
+++ b/zephyr/shim/src/tcpc.c
@@ -3,10 +3,8 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-#include <zephyr/sys/util.h>
-#include "usb_pd_tcpm.h"
#include "usb_pd.h"
+#include "usb_pd_tcpm.h"
#include "usbc/tcpc_anx7447.h"
#include "usbc/tcpc_anx7447_emul.h"
#include "usbc/tcpc_ccgxxf.h"
@@ -16,10 +14,14 @@
#include "usbc/tcpc_nct38xx.h"
#include "usbc/tcpc_ps8xxx.h"
#include "usbc/tcpc_ps8xxx_emul.h"
+#include "usbc/tcpc_raa489000.h"
#include "usbc/tcpc_rt1718s.h"
#include "usbc/tcpci.h"
#include "usbc/utils.h"
+#include <zephyr/devicetree.h>
+#include <zephyr/sys/util.h>
+
#define HAS_TCPC_PROP(usbc_id) \
COND_CODE_1(DT_NODE_HAS_PROP(usbc_id, tcpc), (|| 1), ())
@@ -57,6 +59,8 @@
CHECK_COMPAT(PS8XXX_COMPAT, usbc_id, tcpc_id, TCPC_CONFIG_PS8XXX) \
CHECK_COMPAT(NCT38XX_TCPC_COMPAT, usbc_id, tcpc_id, \
TCPC_CONFIG_NCT38XX) \
+ CHECK_COMPAT(RAA489000_TCPC_COMPAT, usbc_id, tcpc_id, \
+ TCPC_CONFIG_RAA489000) \
CHECK_COMPAT(RT1718S_TCPC_COMPAT, usbc_id, tcpc_id, \
TCPC_CONFIG_RT1718S) \
CHECK_COMPAT(TCPCI_COMPAT, usbc_id, tcpc_id, TCPC_CONFIG_TCPCI) \
diff --git a/zephyr/shim/src/tcpc_nct38xx.c b/zephyr/shim/src/tcpc_nct38xx.c
index 9580759a6c..5d3f5ac25c 100644
--- a/zephyr/shim/src/tcpc_nct38xx.c
+++ b/zephyr/shim/src/tcpc_nct38xx.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/device.h>
-#include <zephyr/devicetree.h>
-
#include "config.h"
#include "usbc/tcpc_nct38xx.h"
#include "usbc/utils.h"
+#include <zephyr/device.h>
+#include <zephyr/devicetree.h>
+
#define GPIO_DEV_WITH_COMMA(id) DEVICE_DT_GET(DT_PHANDLE(id, gpio_dev)),
#define GPIO_DEV_BINDING(usbc_id, tcpc_id) \
diff --git a/zephyr/shim/src/temp_sensors.c b/zephyr/shim/src/temp_sensors.c
index 371d7d7fc9..ae3a367252 100644
--- a/zephyr/shim/src/temp_sensors.c
+++ b/zephyr/shim/src/temp_sensors.c
@@ -6,6 +6,7 @@
#include "adc.h"
#include "charger/chg_rt9490.h"
#include "driver/charger/rt9490.h"
+#include "hooks.h"
#include "temp_sensor.h"
#include "temp_sensor/pct2075.h"
#include "temp_sensor/sb_tsi.h"
@@ -79,6 +80,7 @@ static int thermistor_get_temp(const struct temp_sensor_t *sensor,
.read = &thermistor_get_temp, \
.thermistor = GET_THERMISTOR_INFO( \
DT_PHANDLE(sensor_id, thermistor)), \
+ .update_temperature = NULL, \
FILL_POWER_GOOD(named_id) })
#define TEMP_THERMISTOR(named_id, sensor_id) \
@@ -110,10 +112,12 @@ __maybe_unused static int pct2075_get_temp(const struct temp_sensor_t *sensor,
(DT_REG_ADDR(node_id) | I2C_FLAG_BIG_ENDIAN), \
},
-#define GET_ZEPHYR_TEMP_SENSOR_PCT2075(named_id) \
- (&(const struct zephyr_temp_sensor){ .read = &pct2075_get_temp, \
- .thermistor = NULL, \
- FILL_POWER_GOOD(named_id) })
+#define GET_ZEPHYR_TEMP_SENSOR_PCT2075(named_id) \
+ (&(const struct zephyr_temp_sensor){ \
+ .read = &pct2075_get_temp, \
+ .thermistor = NULL, \
+ .update_temperature = pct2075_update_temperature, \
+ FILL_POWER_GOOD(named_id) })
#define TEMP_PCT2075(named_id, sensor_id) \
[TEMP_SENSOR_ID(named_id)] = { \
@@ -144,9 +148,10 @@ __maybe_unused static int sb_tsi_get_temp(const struct temp_sensor_t *sensor,
#endif /* SB_TSI_COMPAT */
-#define GET_ZEPHYR_TEMP_SENSOR_SB_TSI(named_id) \
- (&(const struct zephyr_temp_sensor){ .read = &sb_tsi_get_temp, \
- .thermistor = NULL, \
+#define GET_ZEPHYR_TEMP_SENSOR_SB_TSI(named_id) \
+ (&(const struct zephyr_temp_sensor){ .read = &sb_tsi_get_temp, \
+ .thermistor = NULL, \
+ .update_temperature = NULL, \
FILL_POWER_GOOD(named_id) })
#define TEMP_SB_TSI(named_id, sensor_id) \
@@ -174,10 +179,12 @@ __maybe_unused static int tmp112_get_temp(const struct temp_sensor_t *sensor,
.i2c_addr_flags = DT_REG_ADDR(node_id), \
},
-#define GET_ZEPHYR_TEMP_SENSOR_TMP112(named_id) \
- (&(const struct zephyr_temp_sensor){ .read = &tmp112_get_temp, \
- .thermistor = NULL, \
- FILL_POWER_GOOD(named_id) })
+#define GET_ZEPHYR_TEMP_SENSOR_TMP112(named_id) \
+ (&(const struct zephyr_temp_sensor){ \
+ .read = &tmp112_get_temp, \
+ .thermistor = NULL, \
+ .update_temperature = tmp112_update_temperature, \
+ FILL_POWER_GOOD(named_id) })
#define TEMP_TMP112(named_id, sensor_id) \
[TEMP_SENSOR_ID(named_id)] = { \
@@ -204,6 +211,7 @@ const struct tmp112_sensor_t tmp112_sensors[TMP112_COUNT] = {
.read = &rt9490_get_thermistor_val, \
.thermistor = GET_THERMISTOR_INFO( \
DT_PHANDLE(sensor_id, thermistor)), \
+ .update_temperature = NULL, \
FILL_POWER_GOOD(named_id) })
#define TEMP_RT9490(named_id, sensor_id) \
@@ -235,6 +243,20 @@ const struct tmp112_sensor_t tmp112_sensors[TMP112_COUNT] = {
const struct temp_sensor_t temp_sensors[] = { DT_FOREACH_CHILD_SEP(
TEMP_SENSORS_NODEID, TEMP_SENSOR_ENTRY, (, )) };
+BUILD_ASSERT(ARRAY_SIZE(temp_sensors) == TEMP_SENSOR_COUNT);
+
+static bool temp_sensor_check_power(const struct temp_sensor_t *sensor)
+{
+#if ANY_INST_HAS_POWER_GOOD_PIN
+ if (sensor->zephyr_info->power_good_dev) {
+ if (!gpio_pin_get(sensor->zephyr_info->power_good_dev,
+ sensor->zephyr_info->power_good_pin))
+ return false;
+ }
+#endif
+ return true;
+}
+
int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr)
{
const struct temp_sensor_t *sensor;
@@ -243,15 +265,26 @@ int temp_sensor_read(enum temp_sensor_id id, int *temp_ptr)
return EC_ERROR_INVAL;
sensor = temp_sensors + id;
-#if ANY_INST_HAS_POWER_GOOD_PIN
- if (sensor->zephyr_info->power_good_dev) {
- if (!gpio_pin_get(sensor->zephyr_info->power_good_dev,
- sensor->zephyr_info->power_good_pin))
- return EC_ERROR_NOT_POWERED;
- }
-#endif
+ if (!temp_sensor_check_power(sensor))
+ return EC_ERROR_NOT_POWERED;
return sensor->zephyr_info->read(sensor, temp_ptr);
}
+void temp_sensors_update(void)
+{
+ for (int i = 0; i < TEMP_SENSOR_COUNT; i++) {
+ const struct temp_sensor_t *sensor = temp_sensors + i;
+
+ if (!sensor->zephyr_info->update_temperature)
+ continue;
+
+ if (!temp_sensor_check_power(sensor))
+ continue;
+
+ sensor->zephyr_info->update_temperature(sensor->idx);
+ }
+}
+DECLARE_HOOK(HOOK_SECOND, temp_sensors_update, HOOK_PRIO_TEMP_SENSOR);
+
#endif /* DT_HAS_COMPAT_STATUS_OKAY(TEMP_SENSORS_COMPAT) */
diff --git a/zephyr/shim/src/thermal.c b/zephyr/shim/src/thermal.c
index abe6b7da9e..fd1b0bfb52 100644
--- a/zephyr/shim/src/thermal.c
+++ b/zephyr/shim/src/thermal.c
@@ -3,9 +3,9 @@
* found in the LICENSE file.
*/
+#include "ec_commands.h"
#include "temp_sensor.h"
#include "temp_sensor/temp_sensor.h"
-#include "ec_commands.h"
#define THERMAL_CONFIG(node_id) \
[TEMP_SENSOR_ID(node_id)] = { \
diff --git a/zephyr/shim/src/usb_muxes.c b/zephyr/shim/src/usb_muxes.c
index 3f81e97787..b3854e2ca8 100644
--- a/zephyr/shim/src/usb_muxes.c
+++ b/zephyr/shim/src/usb_muxes.c
@@ -3,16 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-#include <zephyr/sys/util_macro.h>
#include "usb_mux.h"
#include "usbc/usb_muxes.h"
-/**
- * This prevents creating struct usb_mux usb_muxes[] for platforms that didn't
- * migrate USB mux configuration to DTS yet.
- */
-#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain)
+#include <zephyr/devicetree.h>
+#include <zephyr/sys/util_macro.h>
/**
* @brief Check if @p mux_id is not part of @p chain_id or if @p chain_id USBC
@@ -95,5 +90,3 @@ BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == CONFIG_USB_PD_PORT_MAX_COUNT);
* MAYBE_CONST struct usb_mux USB_MUX_NODE_<node_id> = { ... };
*/
USB_MUX_FOREACH_MUX(USB_MUX_DEFINE)
-
-#endif /* #if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_usb_mux_chain) */
diff --git a/zephyr/shim/src/usba.c b/zephyr/shim/src/usba.c
index 4db8c31e6a..a7360a9ddb 100644
--- a/zephyr/shim/src/usba.c
+++ b/zephyr/shim/src/usba.c
@@ -5,10 +5,9 @@
#define DT_DRV_COMPAT cros_ec_usba_port_enable_pins
-#include <zephyr/devicetree.h>
#include "hooks.h"
-#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
+#include <zephyr/devicetree.h>
#define PIN(node_id, prop, idx) \
GPIO_SIGNAL(DT_PHANDLE_BY_IDX(node_id, prop, idx)),
@@ -23,5 +22,3 @@ const
#endif
int usb_port_enable[] = { DT_INST_FOREACH_STATUS_OKAY(
USBA_ENABLE_PINS) };
-
-#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */
diff --git a/zephyr/shim/src/watchdog.c b/zephyr/shim/src/watchdog.c
index eb82f228d5..413ba50484 100644
--- a/zephyr/shim/src/watchdog.c
+++ b/zephyr/shim/src/watchdog.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/device.h>
-#include <zephyr/drivers/watchdog.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/kernel.h>
-
#include "config.h"
#include "hooks.h"
#include "watchdog.h"
+#include <zephyr/device.h>
+#include <zephyr/drivers/watchdog.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+
LOG_MODULE_REGISTER(watchdog_shim, LOG_LEVEL_ERR);
#define wdt DEVICE_DT_GET(DT_CHOSEN(cros_ec_watchdog))
diff --git a/zephyr/shim/src/ztest_system.c b/zephyr/shim/src/ztest_system.c
index 5933f18f05..13614ec8f0 100644
--- a/zephyr/shim/src/ztest_system.c
+++ b/zephyr/shim/src/ztest_system.c
@@ -12,7 +12,7 @@
#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args)
-char mock_jump_data[sizeof(struct jump_data) + 256];
+char mock_jump_data[CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE];
/* When CONFIG_RAM_SIZE is defined, this is provided by common/system.c */
#ifndef CONFIG_RAM_SIZE
diff --git a/zephyr/subsys/CMakeLists.txt b/zephyr/subsys/CMakeLists.txt
index a3837b94e8..dfd1a35871 100644
--- a/zephyr/subsys/CMakeLists.txt
+++ b/zephyr/subsys/CMakeLists.txt
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
add_subdirectory(ap_pwrseq)
+add_subdirectory(emul)
diff --git a/zephyr/subsys/ap_pwrseq/include/signal_adc.h b/zephyr/subsys/ap_pwrseq/include/signal_adc.h
index 81c6a1edd4..dea6d315d8 100644
--- a/zephyr/subsys/ap_pwrseq/include/signal_adc.h
+++ b/zephyr/subsys/ap_pwrseq/include/signal_adc.h
@@ -6,6 +6,8 @@
#ifndef __AP_PWRSEQ_SIGNAL_ADC_H__
#define __AP_PWRSEQ_SIGNAL_ADC_H__
+#include <power_signals.h>
+
#define PWR_SIG_TAG_ADC PWR_ADC_
/*
diff --git a/zephyr/subsys/ap_pwrseq/include/x86_common_pwrseq.h b/zephyr/subsys/ap_pwrseq/include/x86_common_pwrseq.h
index dcb2b3b968..75390b5005 100644
--- a/zephyr/subsys/ap_pwrseq/include/x86_common_pwrseq.h
+++ b/zephyr/subsys/ap_pwrseq/include/x86_common_pwrseq.h
@@ -7,6 +7,7 @@
#define __X86_COMMON_PWRSEQ_H__
#include <zephyr/logging/log.h>
+
#include <ap_power/ap_power_interface.h>
#include <ap_power_override_functions.h>
#include <power_signals.h>
diff --git a/zephyr/subsys/ap_pwrseq/power_host_sleep.c b/zephyr/subsys/ap_pwrseq/power_host_sleep.c
index 30025d21ea..bc38215921 100644
--- a/zephyr/subsys/ap_pwrseq/power_host_sleep.c
+++ b/zephyr/subsys/ap_pwrseq/power_host_sleep.c
@@ -174,10 +174,11 @@ void ap_power_sleep_notify_transition(enum ap_power_sleep_type check_state)
ap_power_ev_send_callbacks(AP_POWER_SUSPEND);
} else if (check_state == AP_POWER_SLEEP_RESUME) {
ap_power_ev_send_callbacks(AP_POWER_RESUME);
+ /*
+ * Transition is done; reset sleep state after resume.
+ */
+ ap_power_sleep_set_notify(AP_POWER_SLEEP_NONE);
}
-
- /* Transition is done; reset sleep state. */
- ap_power_sleep_set_notify(AP_POWER_SLEEP_NONE);
}
#endif /* CONFIG_AP_PWRSEQ_S0IX */
diff --git a/zephyr/subsys/ap_pwrseq/power_signals.c b/zephyr/subsys/ap_pwrseq/power_signals.c
index a02eef6e6b..1ae8604a3a 100644
--- a/zephyr/subsys/ap_pwrseq/power_signals.c
+++ b/zephyr/subsys/ap_pwrseq/power_signals.c
@@ -3,18 +3,18 @@
* found in the LICENSE file.
*/
+#include "signal_adc.h"
+#include "signal_gpio.h"
+#include "signal_vw.h"
+
#include <zephyr/kernel.h>
-#include <zephyr/toolchain.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/atomic.h>
+#include <zephyr/toolchain.h>
#include <ap_power/ap_pwrseq.h>
#include <power_signals.h>
-#include "signal_gpio.h"
-#include "signal_vw.h"
-#include "signal_adc.h"
-
LOG_MODULE_DECLARE(ap_pwrseq, CONFIG_AP_PWRSEQ_LOG_LEVEL);
#if DT_HAS_COMPAT_STATUS_OKAY(intel_ap_pwrseq)
diff --git a/zephyr/subsys/ap_pwrseq/signal_gpio.c b/zephyr/subsys/ap_pwrseq/signal_gpio.c
index 1dbd430bef..f09f6b23cb 100644
--- a/zephyr/subsys/ap_pwrseq/signal_gpio.c
+++ b/zephyr/subsys/ap_pwrseq/signal_gpio.c
@@ -3,10 +3,12 @@
* found in the LICENSE file.
*/
+#include "system.h"
+
+#include <zephyr/drivers/gpio.h>
+
#include <power_signals.h>
#include <signal_gpio.h>
-#include <zephyr/drivers/gpio.h>
-#include "system.h"
#define MY_COMPAT intel_ap_pwrseq_gpio
diff --git a/zephyr/subsys/ap_pwrseq/signal_vw.c b/zephyr/subsys/ap_pwrseq/signal_vw.c
index 0e9e4affff..cee88e362d 100644
--- a/zephyr/subsys/ap_pwrseq/signal_vw.c
+++ b/zephyr/subsys/ap_pwrseq/signal_vw.c
@@ -3,11 +3,12 @@
* found in the LICENSE file.
*/
-#include <atomic.h>
+#include "signal_vw.h"
+
#include <zephyr/drivers/espi.h>
-#include <x86_non_dsx_common_pwrseq_sm_handler.h>
-#include "signal_vw.h"
+#include <atomic.h>
+#include <x86_non_dsx_common_pwrseq_sm_handler.h>
#define MY_COMPAT intel_ap_pwrseq_vw
diff --git a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_console.c b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_console.c
index dbceeacc85..6ac2b5e0ba 100644
--- a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_console.c
+++ b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_console.c
@@ -3,8 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
#include <stdlib.h>
+
+#include <zephyr/shell/shell.h>
+
#include <x86_non_dsx_common_pwrseq_sm_handler.h>
LOG_MODULE_DECLARE(ap_pwrseq, CONFIG_AP_PWRSEQ_LOG_LEVEL);
diff --git a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c
index 09846759ee..55f1414a4b 100644
--- a/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c
+++ b/zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c
@@ -3,11 +3,12 @@
* found in the LICENSE file.
*/
-#include <atomic.h>
+#include "zephyr_console_shim.h"
+
#include <zephyr/init.h>
+#include <atomic.h>
#include <x86_non_dsx_common_pwrseq_sm_handler.h>
-#include "zephyr_console_shim.h"
static K_KERNEL_STACK_DEFINE(pwrseq_thread_stack, CONFIG_AP_PWRSEQ_STACK_SIZE);
static struct k_thread pwrseq_thread_data;
diff --git a/zephyr/subsys/emul/CMakeLists.txt b/zephyr/subsys/emul/CMakeLists.txt
new file mode 100644
index 0000000000..3394afcc94
--- /dev/null
+++ b/zephyr/subsys/emul/CMakeLists.txt
@@ -0,0 +1,2 @@
+
+add_subdirectory("ap_pwrseq")
diff --git a/zephyr/subsys/emul/Kconfig b/zephyr/subsys/emul/Kconfig
new file mode 100644
index 0000000000..48011312d5
--- /dev/null
+++ b/zephyr/subsys/emul/Kconfig
@@ -0,0 +1,5 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+rsource "ap_pwrseq/Kconfig"
diff --git a/zephyr/subsys/emul/ap_pwrseq/CMakeLists.txt b/zephyr/subsys/emul/ap_pwrseq/CMakeLists.txt
new file mode 100644
index 0000000000..476232d13b
--- /dev/null
+++ b/zephyr/subsys/emul/ap_pwrseq/CMakeLists.txt
@@ -0,0 +1 @@
+zephyr_library_sources_ifdef(CONFIG_EMUL_POWER_SIGNALS emul_power_signals.c)
diff --git a/zephyr/subsys/emul/ap_pwrseq/Kconfig b/zephyr/subsys/emul/ap_pwrseq/Kconfig
new file mode 100644
index 0000000000..309ee08eae
--- /dev/null
+++ b/zephyr/subsys/emul/ap_pwrseq/Kconfig
@@ -0,0 +1,34 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+if ZTEST
+
+config EMUL_POWER_SIGNALS
+ bool "Enable Power Signals Emulator"
+ help
+ Power signals emulator imitates the behavior of power signals
+ that interact with the EC within a given platform. It enables testing
+ AP Power Sequence execution in a virtual environment.
+
+if EMUL_POWER_SIGNALS
+
+module = EMUL_POWER_SIGNALS
+module-str = Power Signals Emulator
+source "subsys/logging/Kconfig.template.log_config"
+
+config EMUL_POWER_SIGNALS_WORK_QUEUE_STACK_SIZE
+ int "Power Signals Emulator internal work queue stack size"
+ default 1024
+ help
+ Power Signal Emulator has its own dedicated work queue, this defines
+ work queue thread stack size.
+
+config EMUL_POWER_SIGNALS_WORK_QUEUE_PRIO
+ int "Power Signals Emulator internal work queue thread priority"
+ default 0
+ help
+ Defines work queue thread thread priority.
+
+endif # EMUL_POWER_SIGNALS
+endif # ZTEST
diff --git a/zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c b/zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c
new file mode 100644
index 0000000000..e8f211bb56
--- /dev/null
+++ b/zephyr/subsys/emul/ap_pwrseq/emul_power_signals.c
@@ -0,0 +1,550 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ap_power/ap_power.h"
+#include "ap_power/ap_power_events.h"
+#include "chipset.h"
+#include "emul/emul_power_signals.h"
+#include "power_signals.h"
+#include "test_state.h"
+
+#include <zephyr/drivers/adc.h>
+#include <zephyr/drivers/espi.h>
+#include <zephyr/drivers/espi_emul.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/ztest.h>
+
+LOG_MODULE_REGISTER(emul_power_signal, CONFIG_EMUL_POWER_SIGNALS_LOG_LEVEL);
+
+/**
+ * @brief Power signal source type.
+ */
+enum power_signal_emul_source {
+ PWR_SIG_EMUL_SRC_GPIO,
+ PWR_SIG_EMUL_SRC_VW,
+ PWR_SIG_EMUL_SRC_EXT,
+ PWR_SIG_EMUL_SRC_ADC,
+};
+
+/**
+ * @brief Power signal containers definition.
+ */
+union power_signal_emul_signal_spec {
+ struct gpio_dt_spec gpio;
+ struct adc_dt_spec adc;
+};
+
+/**
+ * @brief Power signal descriptor.
+ */
+struct power_signal_emul_signal_desc {
+ const enum power_signal enum_id;
+ const char *name;
+ const enum power_signal_emul_source source;
+ const union power_signal_emul_signal_spec spec;
+};
+
+/**
+ * @brief Power signal output definition.
+ */
+struct power_signal_emul_output {
+ struct power_signal_emul_signal_desc desc;
+ const int assert_value;
+ const int assert_delay_ms;
+ const int deassert_value;
+ const int deassert_delay_ms;
+ const int init_value;
+ const bool retain;
+ const bool invert;
+ struct k_work_delayable d_work;
+ int value;
+};
+
+enum power_signal_edge {
+ EDGE_ACTIVE_ON_ASSERT,
+ EDGE_ACTIVE_ON_DEASSERT,
+ EDGE_ACTIVE_ON_BOTH,
+};
+
+/**
+ * @brief Power signal input definition.
+ */
+struct power_signal_emul_input {
+ struct power_signal_emul_signal_desc desc;
+ const int assert_value;
+ const int init_value;
+ const bool retain;
+ const enum power_signal_edge edge;
+ struct gpio_callback cb;
+ int value;
+};
+
+/**
+ * @brief Power signal node definition,
+ * One node contains at least one input signal and one or more output
+ * signals.
+ */
+struct power_signal_emul_node {
+ const char *name;
+ struct power_signal_emul_input input;
+ const int outputs_count;
+ struct power_signal_emul_output *const outputs;
+};
+
+#define EMUL_POWER_SIGNAL_GET_SOURCE(inst) \
+ COND_CODE_1( \
+ DT_NODE_HAS_COMPAT(inst, intel_ap_pwrseq_gpio), \
+ (PWR_SIG_EMUL_SRC_GPIO), \
+ (COND_CODE_1( \
+ DT_NODE_HAS_COMPAT(inst, intel_ap_pwrseq_vw), \
+ (PWR_SIG_EMUL_SRC_VW), \
+ (COND_CODE_1(DT_NODE_HAS_COMPAT( \
+ inst, intel_ap_pwrseq_external), \
+ (PWR_SIG_EMUL_SRC_EXT), \
+ (PWR_SIG_EMUL_SRC_ADC))))))
+
+#define EMUL_POWER_SIGNAL_GET_SIGNAL_SPEC(inst, dir_signal) \
+ { \
+ COND_CODE_1(DT_NODE_HAS_COMPAT(DT_PROP(inst, dir_signal), \
+ intel_ap_pwrseq_gpio), \
+ (.gpio = GPIO_DT_SPEC_GET( \
+ DT_PROP(inst, dir_signal), gpios)), \
+ ()) \
+ }
+
+#define EMUL_POWER_SIGNAL_GET_SIGNAL(inst, dir) \
+ { \
+ .enum_id = PWR_SIGNAL_ENUM(DT_PROP(inst, dir)), \
+ .name = DT_PROP(DT_PROP(inst, dir), enum_name), \
+ .source = EMUL_POWER_SIGNAL_GET_SOURCE(DT_PROP(inst, dir)), \
+ .spec = EMUL_POWER_SIGNAL_GET_SIGNAL_SPEC(inst, dir), \
+ }
+
+#define EMUL_POWER_SIGNAL_IN_DEF(inst) \
+ { \
+ .desc = EMUL_POWER_SIGNAL_GET_SIGNAL(inst, input_signal), \
+ .assert_value = DT_PROP(inst, assert_value), \
+ .init_value = DT_PROP_OR(inst, init_value, 0), \
+ .edge = DT_STRING_TOKEN(inst, edge), \
+ .retain = !DT_NODE_HAS_PROP(inst, init_value), \
+ }
+
+#define EMUL_POWER_SIGNAL_OUT_DEF(inst) \
+ { \
+ .desc = EMUL_POWER_SIGNAL_GET_SIGNAL(inst, output_signal), \
+ .assert_value = DT_PROP(inst, assert_value), \
+ .assert_delay_ms = DT_PROP(inst, assert_delay_ms), \
+ .deassert_value = DT_PROP(inst, deassert_value), \
+ .deassert_delay_ms = DT_PROP(inst, deassert_delay_ms), \
+ .init_value = DT_PROP_OR(inst, init_value, 0), \
+ .retain = !DT_NODE_HAS_PROP(inst, init_value), \
+ .invert = DT_PROP(inst, invert_value), \
+ },
+
+#define EMUL_POWER_SIGNAL_OUT_ARRAY_DEF(inst) \
+ static struct power_signal_emul_output DT_CAT(inst, _output)[] = { \
+ DT_FOREACH_CHILD_STATUS_OKAY(inst, EMUL_POWER_SIGNAL_OUT_DEF) \
+ };
+
+#define EMUL_POWER_SIGNAL_GET_INPUT_ENUM(inst) ENUM_##inst##_OUTPUT,
+
+#define EMUL_POWER_SIGNAL_NODES_DEF(inst) \
+ enum { \
+ DT_FOREACH_CHILD_STATUS_OKAY(inst, \
+ EMUL_POWER_SIGNAL_GET_INPUT_ENUM) \
+ DT_CAT(inst, _OUTPUT_COUNT), \
+ }; \
+ __COND_CODE(IS_EQ(DT_CAT(inst, _OUTPUT_COUNT), 0), (), \
+ (EMUL_POWER_SIGNAL_OUT_ARRAY_DEF(inst))) \
+ static struct power_signal_emul_node DT_CAT(inst, _node) = { \
+ .name = DT_NODE_FULL_NAME(inst), \
+ .input = EMUL_POWER_SIGNAL_IN_DEF(inst), \
+ .outputs_count = inst##_OUTPUT_COUNT, \
+ .outputs = __COND_CODE(IS_EQ(DT_CAT(inst, _OUTPUT_COUNT), 0), \
+ (NULL), (DT_CAT(inst, _output))), \
+ };
+
+DT_FOREACH_STATUS_OKAY(intel_ap_pwr_signal_emul, EMUL_POWER_SIGNAL_NODES_DEF)
+
+#define EMUL_POWER_SIGNAL_NODES_ARRAY_GET_NODES_REFS_WITH_COMMA(inst) \
+ (&DT_CAT(inst, _node)),
+
+#define EMUL_POWER_SIGNAL_NODES_ARRAY_GET_NODES_REFS(inst) \
+ EMUL_POWER_SIGNAL_NODES_ARRAY_GET_NODES_REFS_WITH_COMMA(inst)
+
+#define EMUL_POWER_SIGNAL_NODES_ARRAY_GET_IO_SIGNALS(inst, prop, idx) \
+ EMUL_POWER_SIGNAL_NODES_ARRAY_GET_NODES_REFS( \
+ DT_PHANDLE_BY_IDX(inst, prop, idx))
+
+#define EMUL_POWER_SIGNAL_NODES_ARRAY_DEF(inst) \
+ static struct power_signal_emul_node *DT_CAT(inst, _nodes)[] = { \
+ DT_FOREACH_PROP_ELEM( \
+ inst, nodes, \
+ EMUL_POWER_SIGNAL_NODES_ARRAY_GET_IO_SIGNALS) \
+ };
+
+DT_FOREACH_STATUS_OKAY(intel_ap_pwr_test_platform,
+ EMUL_POWER_SIGNAL_NODES_ARRAY_DEF)
+
+#define EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_NODES_REFS_ITEM(inst) \
+ DT_CAT(inst, _nodes),
+
+#define EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_NODES_REFS(inst) \
+ EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_NODES_REFS_ITEM(inst)
+
+#define EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_IO_SIGNALS(inst, prop, idx) \
+ EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_NODES_REFS( \
+ DT_PHANDLE_BY_IDX(inst, prop, idx))
+
+#define EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_NODES(inst) \
+ { \
+ DT_FOREACH_PROP_ELEM( \
+ inst, nodes, \
+ EMUL_POWER_SIGNAL_TEST_PLATFORM_GET_IO_SIGNALS) \
+ }
+
+#define EMUL_POWER_SIGNAL_TEST_PLATFORM_DEF(inst) \
+ const struct power_signal_emul_test_platform inst = { \
+ .name_id = DT_NODE_FULL_NAME(inst), \
+ .nodes_count = DT_PROP_LEN(inst, nodes), \
+ .nodes = DT_CAT(inst, _nodes), \
+ };
+
+DT_FOREACH_STATUS_OKAY(intel_ap_pwr_test_platform,
+ EMUL_POWER_SIGNAL_TEST_PLATFORM_DEF)
+
+static K_KERNEL_STACK_DEFINE(work_q_stack,
+ CONFIG_EMUL_POWER_SIGNALS_WORK_QUEUE_STACK_SIZE);
+
+struct k_work_q work_q;
+
+static const struct power_signal_emul_test_platform *cur_test_platform;
+
+static bool emul_ready;
+
+/**
+ * @brief Set GPIO type power signal to specified value.
+ *
+ * @param spec Pointer to container for GPIO pin information specified in
+ * devicetree.
+ * @param value Value to be set on GPIO.
+ */
+static void power_signal_emul_set_gpio_value(const struct gpio_dt_spec *spec,
+ int value)
+{
+ gpio_flags_t gpio_flags;
+ int ret;
+
+ ret = gpio_emul_flags_get(spec->port, spec->pin, &gpio_flags);
+ zassert_ok(ret, "Getting GPIO flags!!");
+
+ if (gpio_flags & GPIO_INPUT) {
+ ret = gpio_emul_input_set(spec->port, spec->pin, value);
+ } else if (gpio_flags & GPIO_OUTPUT) {
+ ret = gpio_pin_set(spec->port, spec->pin, value);
+ }
+ zassert_ok(ret, "Setting GPIO value!!");
+}
+
+/**
+ * @brief Set power signal to specified value.
+ *
+ * @param desc Pointer to power signal descriptor.
+ * @param value Value to be set on power signal.
+ */
+static void
+power_signal_emul_set_value(struct power_signal_emul_signal_desc *desc,
+ int value)
+{
+ LOG_DBG("Set Signal %s -> %d", desc->name, value);
+
+ switch (desc->source) {
+ case PWR_SIG_EMUL_SRC_GPIO:
+ power_signal_emul_set_gpio_value(&desc->spec.gpio, !!value);
+ break;
+
+ case PWR_SIG_EMUL_SRC_EXT:
+ zassert_ok(power_signal_set(desc->enum_id, value),
+ "Setting %s Signal value!!", desc->name);
+ __fallthrough;
+
+ case PWR_SIG_EMUL_SRC_VW:
+ power_signal_interrupt(desc->enum_id, value);
+ break;
+
+ default:
+ zassert_unreachable("Undefined Signal %s!!", desc->name);
+ }
+}
+
+/**
+ * @brief Get GPIO type power signal value.
+ *
+ * @param spec Pointer to container for GPIO pin information specified in
+ * devicetree.
+ *
+ * @return GPIO type power signal value.
+ */
+static int power_signal_emul_get_gpio_value(const struct gpio_dt_spec *spec)
+{
+ gpio_flags_t gpio_flags;
+ int ret;
+
+ ret = gpio_emul_flags_get(spec->port, spec->pin, &gpio_flags);
+ zassert_ok(ret, "Getting GPIO flags!!");
+
+ if (gpio_flags & GPIO_INPUT) {
+ ret = gpio_pin_get(spec->port, spec->pin);
+ } else if (gpio_flags & GPIO_OUTPUT) {
+ ret = gpio_emul_output_get(spec->port, spec->pin);
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Get power signal value.
+ *
+ * @param desc Pointer to power signal descriptor.
+ *
+ * @return Power signal value.
+ */
+static int
+power_signal_emul_get_value(struct power_signal_emul_signal_desc *desc)
+{
+ int ret;
+
+ if (desc->source == PWR_SIG_EMUL_SRC_GPIO) {
+ ret = power_signal_emul_get_gpio_value(&desc->spec.gpio);
+ } else {
+ ret = power_signal_get(desc->enum_id);
+ }
+
+ return ret;
+}
+
+/**
+ * @brief Handle GPIO type power signal interrupt.
+ *
+ * @param port Pointer to GPIO device.
+ * @param cb Original struct gpio_callback owning this handler.
+ * @param pins Mask of pins that triggers the callback handler.
+ */
+static void emul_power_signal_gpio_interrupt(const struct device *port,
+ struct gpio_callback *cb,
+ gpio_port_pins_t pins)
+{
+ struct power_signal_emul_input *in_signal =
+ CONTAINER_OF(cb, struct power_signal_emul_input, cb);
+ struct power_signal_emul_node *node =
+ CONTAINER_OF(in_signal, struct power_signal_emul_node, input);
+ int value;
+ int delay;
+
+ value = power_signal_emul_get_value(&in_signal->desc);
+ if (value == in_signal->value) {
+ return;
+ }
+
+ in_signal->value = value;
+
+ if (!emul_ready) {
+ return;
+ }
+
+ if (in_signal->edge == EDGE_ACTIVE_ON_DEASSERT &&
+ value == in_signal->assert_value) {
+ return;
+ } else if (in_signal->edge == EDGE_ACTIVE_ON_ASSERT &&
+ value != in_signal->assert_value) {
+ return;
+ }
+
+ LOG_DBG("INT: Set Signal %s -> %d", in_signal->desc.name, value);
+ for (int i = 0; i < node->outputs_count; i++) {
+ struct power_signal_emul_output *out_signal = &node->outputs[i];
+
+ out_signal->value = (value == in_signal->assert_value) ^
+ out_signal->invert ?
+ out_signal->assert_value :
+ out_signal->deassert_value;
+
+ delay = (value == in_signal->assert_value) ?
+ out_signal->assert_delay_ms :
+ out_signal->deassert_delay_ms;
+
+ LOG_DBG("INT: Delay Signal %s", out_signal->desc.name);
+ k_work_schedule_for_queue(&work_q, &out_signal->d_work,
+ K_MSEC(delay));
+ }
+}
+
+/**
+ * @brief Handle power signal delayed work.
+ *
+ * This will set power signal value accordingly.
+ *
+ * @param work Pointer to work structure.
+ */
+static void emul_signal_work_hanlder(struct k_work *work)
+{
+ struct k_work_delayable *d_work = k_work_delayable_from_work(work);
+ struct power_signal_emul_output *out_signal =
+ CONTAINER_OF(d_work, struct power_signal_emul_output, d_work);
+
+ power_signal_emul_set_value(&out_signal->desc, out_signal->value);
+}
+
+/**
+ * @brief Initialize power signal emulator node.
+ *
+ * This will enable corresponding initiator power signal interruption and
+ * its handler's power signals work structures.
+ *
+ * @param node Pointer to node containing power signals.
+ */
+static int power_signal_init_node(struct power_signal_emul_node *node)
+{
+ struct power_signal_emul_input *in_signal = &node->input;
+ struct power_signal_emul_output *out_signal;
+
+ if (!node->outputs_count) {
+ LOG_ERR("Node does not have output signal!!");
+ return -EINVAL;
+ }
+
+ LOG_DBG("Initializing node: %s", node->name);
+ for (int i = 0; i < node->outputs_count; i++) {
+ out_signal = &node->outputs[i];
+
+ if (out_signal->retain) {
+ out_signal->value =
+ power_signal_emul_get_value(&out_signal->desc);
+ } else {
+ /* Not retaining previous value, override */
+ power_signal_emul_set_value(&out_signal->desc,
+ out_signal->init_value);
+ out_signal->value = out_signal->init_value;
+ }
+ k_work_init_delayable(&out_signal->d_work,
+ emul_signal_work_hanlder);
+ }
+
+ if (in_signal->retain) {
+ in_signal->value =
+ power_signal_emul_get_value(&in_signal->desc);
+ } else {
+ /* Not retaining previous value, override */
+ power_signal_emul_set_value(&in_signal->desc,
+ in_signal->init_value);
+ in_signal->value = in_signal->init_value;
+ }
+ if (in_signal->desc.source == PWR_SIG_EMUL_SRC_GPIO) {
+ gpio_init_callback(&in_signal->cb,
+ emul_power_signal_gpio_interrupt,
+ BIT(in_signal->desc.spec.gpio.pin));
+
+ gpio_add_callback(in_signal->desc.spec.gpio.port,
+ &in_signal->cb);
+
+ gpio_pin_interrupt_configure_dt(&in_signal->desc.spec.gpio,
+ GPIO_INT_EDGE_BOTH);
+ }
+ return 0;
+}
+
+/** See description in emul_power_signals.h */
+int power_signal_emul_load(
+ const struct power_signal_emul_test_platform *test_platform)
+{
+ int ret;
+
+ if (cur_test_platform) {
+ LOG_ERR("Power Signal Emulator Busy!!");
+ return -EBUSY;
+ }
+
+ cur_test_platform = test_platform;
+
+ LOG_DBG("Loading Emulator test: %s", cur_test_platform->name_id);
+
+ for (int i = 0; i < cur_test_platform->nodes_count; i++) {
+ ret = power_signal_init_node(cur_test_platform->nodes[i]);
+ if (ret) {
+ power_signal_emul_unload();
+ return ret;
+ }
+ }
+
+ emul_ready = true;
+ LOG_DBG("Loading Emulator test Done");
+ return 0;
+}
+
+/** See description in emul_power_signals.h */
+int power_signal_emul_unload(void)
+{
+ struct power_signal_emul_node *node;
+ struct power_signal_emul_output *out_signal;
+ struct power_signal_emul_input *in_signal;
+
+ if (!cur_test_platform) {
+ LOG_ERR("No Test Platform Loaded!!");
+ return -EINVAL;
+ }
+
+ emul_ready = false;
+ for (int i = 0; i < cur_test_platform->nodes_count; i++) {
+ node = cur_test_platform->nodes[i];
+ in_signal = &node->input;
+
+ if (in_signal->desc.source != PWR_SIG_EMUL_SRC_GPIO) {
+ /* Currently, Only output GPIO signals are supported */
+ continue;
+ }
+
+ for (int j = 0; j < node->outputs_count; j++) {
+ static struct k_work_sync work_sync;
+
+ out_signal = &node->outputs[j];
+ k_work_cancel_delayable_sync(&out_signal->d_work,
+ &work_sync);
+ }
+ gpio_pin_interrupt_configure_dt(&in_signal->desc.spec.gpio,
+ GPIO_INT_DISABLE);
+ if (in_signal->cb.handler) {
+ gpio_remove_callback(in_signal->desc.spec.gpio.port,
+ &in_signal->cb);
+ }
+ }
+ cur_test_platform = NULL;
+ return 0;
+}
+
+/**
+ * @brief Initialize power signal emulator internal work queue.
+ *
+ * @param dev Unused parameter.
+ *
+ * @return 0 Return success only.
+ */
+static int power_signal_emul_work_q_init(const struct device *dev)
+{
+ ARG_UNUSED(dev);
+ struct k_work_queue_config cfg = {
+ .name = "psignal_emul",
+ .no_yield = true,
+ };
+
+ k_work_queue_start(&work_q, work_q_stack,
+ K_KERNEL_STACK_SIZEOF(work_q_stack),
+ CONFIG_EMUL_POWER_SIGNALS_WORK_QUEUE_PRIO, &cfg);
+ return 0;
+}
+
+SYS_INIT(power_signal_emul_work_q_init, POST_KERNEL,
+ CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
diff --git a/zephyr/test/ap_power/CMakeLists.txt b/zephyr/test/ap_power/CMakeLists.txt
index 7b44013961..4669dac07e 100644
--- a/zephyr/test/ap_power/CMakeLists.txt
+++ b/zephyr/test/ap_power/CMakeLists.txt
@@ -6,6 +6,8 @@ cmake_minimum_required(VERSION 3.13.1)
find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
project(ap_power)
+add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils)
+
# Include the local test directory for shimmed_test_tasks.h
zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
diff --git a/zephyr/test/ap_power/boards/alderlake.dts b/zephyr/test/ap_power/boards/alderlake.dts
new file mode 100644
index 0000000000..30432a9c72
--- /dev/null
+++ b/zephyr/test/ap_power/boards/alderlake.dts
@@ -0,0 +1,269 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <dt-bindings/gpio_defines.h>
+
+/ {
+ common-pwrseq {
+ compatible = "intel,ap-pwrseq";
+ s5-inactivity-timeout = <1>;
+ };
+
+ en_pp5000: pwr-en-pp5000-s5 {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "PP5000_S5 enable output to regulator";
+ enum-name = "PWR_EN_PP5000_A";
+ gpios = <&gpio0 10 0>;
+ output;
+ };
+ en_pp3300: pwr-en-pp3300-s5 {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "PP3300_S5 enable output to LS";
+ enum-name = "PWR_EN_PP3300_A";
+ gpios = <&gpio0 11 0>;
+ output;
+ };
+ rsmrst: pwr-pg-ec-rsmrst-odl {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "RSMRST power good from regulator";
+ enum-name = "PWR_RSMRST";
+ gpios = <&gpio0 12 0>;
+ interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ };
+ ec_pch_rsmrst: pwr-ec-pch-rsmrst-odl {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "RSMRST output to PCH";
+ enum-name = "PWR_EC_PCH_RSMRST";
+ gpios = <&gpio0 13 0>;
+ output;
+ };
+ slp_s0: pwr-slp-s0-l {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SLP_S0_L input from PCH";
+ enum-name = "PWR_SLP_S0";
+ gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
+ interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ no-enable;
+ };
+ slp_s3: pwr-slp-s3-l {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SLP_S3_L input from PCH";
+ enum-name = "PWR_SLP_S3";
+ gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
+ interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ };
+ slp_sus: pwr-slp-sus-l {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SLP_SUS_L input from PCH";
+ enum-name = "PWR_SLP_SUS";
+ gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
+ interrupt-flags = <GPIO_INT_EDGE_BOTH>;
+ };
+ ec_soc_dsw_pwrok: pwr-ec-soc-dsw-pwrok {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "DSW_PWROK output to PCH";
+ enum-name = "PWR_EC_SOC_DSW_PWROK";
+ gpios = <&gpio0 17 0>;
+ output;
+ };
+ pwr-vccst-pwrgd-od {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "VCCST_PWRGD output to PCH";
+ enum-name = "PWR_VCCST_PWRGD";
+ gpios = <&gpio0 18 0>;
+ output;
+ };
+ pwr-imvp9-vrrdy-od {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "VRRDY input from IMVP9";
+ enum-name = "PWR_IMVP9_VRRDY";
+ gpios = <&gpio0 19 0>;
+ };
+ pch_pwrok: pwr-pch-pwrok {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "PCH_PWROK output to PCH";
+ enum-name = "PWR_PCH_PWROK";
+ gpios = <&gpio0 20 0>;
+ output;
+ };
+ pwr-ec-pch-sys-pwrok {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SYS_PWROK output to PCH";
+ enum-name = "PWR_EC_PCH_SYS_PWROK";
+ gpios = <&gpio0 21 0>;
+ output;
+ };
+ pwr-sys-rst-l {
+ compatible = "intel,ap-pwrseq-gpio";
+ dbg-label = "SYS_RESET# output to PCH";
+ enum-name = "PWR_SYS_RST";
+ gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
+ output;
+ };
+ slp_s4: pwr-slp-s4 {
+ compatible = "intel,ap-pwrseq-vw";
+ dbg-label = "SLP_S4 virtual wire input from PCH";
+ enum-name = "PWR_SLP_S4";
+ virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4";
+ vw-invert;
+ };
+ slp_s5: pwr-slp-s5 {
+ compatible = "intel,ap-pwrseq-vw";
+ dbg-label = "SLP_S5 virtual wire input from PCH";
+ enum-name = "PWR_SLP_S5";
+ virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5";
+ vw-invert;
+ };
+ all_sys_pwrgd: pwr-all-sys-pwrgd {
+ compatible = "intel,ap-pwrseq-external";
+ dbg-label = "Combined all power good";
+ enum-name = "PWR_ALL_SYS_PWRGD";
+ };
+ dsw_pwrok: pwr-pp3300-pwrok {
+ compatible = "intel,ap-pwrseq-external";
+ dbg-label = "PP3300 PWROK";
+ enum-name = "PWR_DSW_PWROK";
+ };
+ pwr-pp1p05-pwrok {
+ compatible = "intel,ap-pwrseq-external";
+ dbg-label = "PP1P05 PWROK";
+ enum-name = "PWR_PG_PP1P05";
+ };
+
+ en_pp3300_emul: en-pp3300-emul {
+ compatible = "intel,ap-pwr-signal-emul";
+ input-signal = <&en_pp3300>;
+ init-value = <0>;
+ pp3300-dsw-pwrok-emul {
+ output-signal = <&dsw_pwrok>;
+ assert-delay-ms = <10>;
+ init-value= <0>;
+ };
+ };
+
+ en_pp5000_emul: en-pp5000-emul {
+ compatible = "intel,ap-pwr-signal-emul";
+ input-signal = <&en_pp5000>;
+ init-value = <0>;
+ pp5000-rsmrst-emul {
+ output-signal = <&rsmrst>;
+ assert-delay-ms = <40>;
+ init-value= <0>;
+ };
+ };
+
+ ec_soc_dsw_pwrok_emul: ec-soc-dsw-pwrok-emul {
+ compatible = "intel,ap-pwr-signal-emul";
+ input-signal = <&ec_soc_dsw_pwrok>;
+ init-value = <0>;
+ ec-dsw-pwrok-slp-sus-emul {
+ output-signal = <&slp_sus>;
+ assert-delay-ms = <20>;
+ init-value= <0>;
+ };
+ };
+
+ ec_pch_rsmrst_emul: ec-pch-rsmrst-emul {
+ compatible = "intel,ap-pwr-signal-emul";
+ input-signal = <&ec_pch_rsmrst>;
+ init-value = <0>;
+ ec-pch-rsmrst-slp-s5-emul {
+ output-signal = <&slp_s5>;
+ assert-delay-ms = <20>;
+ invert-value;
+ init-value= <1>;
+ };
+ ec-pch-rsmrst-slp-s4-emul {
+ output-signal = <&slp_s4>;
+ assert-delay-ms = <30>;
+ invert-value;
+ init-value= <1>;
+ };
+ ec-pch-rsmrst-slp-s3-emul {
+ output-signal = <&slp_s3>;
+ assert-delay-ms = <40>;
+ init-value= <0>;
+ };
+ ec-pch-rsmrst-slp-s0-emul {
+ output-signal = <&slp_s0>;
+ assert-delay-ms = <45>;
+ init-value= <0>;
+ };
+ ec-pch-rsmrst-all-sys-pwrgd {
+ output-signal = <&all_sys_pwrgd>;
+ assert-delay-ms = <50>;
+ init-value= <0>;
+ };
+ };
+
+ tp-sys-g3-to-s0 {
+ compatible = "intel,ap-pwr-test-platform";
+ nodes = <&en_pp3300_emul &en_pp5000_emul
+ &ec_soc_dsw_pwrok_emul &ec_pch_rsmrst_emul>;
+ };
+
+ pch_pwrok_power_fail_emul: pch-pwrok-power-fail-emul {
+ compatible = "intel,ap-pwr-signal-emul";
+ input-signal = <&pch_pwrok>;
+ init-value = <0>;
+ pch-pwrok-dsw-pwrok-emul {
+ output-signal = <&dsw_pwrok>;
+ assert-delay-ms = <50>;
+ invert-value;
+ };
+ };
+
+ tp-sys-s0-power-fail {
+ compatible = "intel,ap-pwr-test-platform";
+ nodes = <&pch_pwrok_power_fail_emul>;
+ };
+
+ pch_pwrok_power_down_emul: pch-pwrok-power-down-emul {
+ compatible = "intel,ap-pwr-signal-emul";
+ input-signal = <&pch_pwrok>;
+ init-value = <0>;
+ edge = "EDGE_ACTIVE_ON_ASSERT";
+ pch-pwrok-dsw-pwrok-emul {
+ output-signal = <&dsw_pwrok>;
+ assert-delay-ms = <70>;
+ invert-value;
+ };
+
+ pch_pwrok-rsmrst-emul {
+ output-signal = <&rsmrst>;
+ assert-delay-ms = <60>;
+ invert-value;
+ };
+
+ pch-pwrok-slp-s5-emul {
+ output-signal = <&slp_s5>;
+ assert-delay-ms = <50>;
+ };
+
+ pch-pwrok-slp-s4-emul {
+ output-signal = <&slp_s4>;
+ assert-delay-ms = <30>;
+ };
+
+ pch-pwrok-slp-s3-emul {
+ output-signal = <&slp_s3>;
+ assert-delay-ms = <20>;
+ invert-value;
+ };
+
+ pch-pwrok-slp-s0-emul {
+ output-signal = <&slp_s0>;
+ assert-delay-ms = <15>;
+ invert-value;
+ };
+ };
+
+ tp-sys-g3-to-s0-power-down {
+ compatible = "intel,ap-pwr-test-platform";
+ nodes = <&en_pp3300_emul &en_pp5000_emul
+ &ec_soc_dsw_pwrok_emul &ec_pch_rsmrst_emul
+ &pch_pwrok_power_down_emul>;
+ };
+};
diff --git a/zephyr/test/ap_power/boards/native_posix.overlay b/zephyr/test/ap_power/boards/native_posix.overlay
index c6cd8c3790..b30240a094 100644
--- a/zephyr/test/ap_power/boards/native_posix.overlay
+++ b/zephyr/test/ap_power/boards/native_posix.overlay
@@ -52,131 +52,6 @@
};
};
- common-pwrseq {
- compatible = "intel,ap-pwrseq";
- };
-
- pwr-en-pp5000-s5 {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "PP5000_S5 enable output to regulator";
- enum-name = "PWR_EN_PP5000_A";
- gpios = <&gpio0 10 0>;
- output;
- };
- pwr-en-pp3300-s5 {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "PP3300_S5 enable output to LS";
- enum-name = "PWR_EN_PP3300_A";
- gpios = <&gpio0 11 0>;
- output;
- };
- pwr-pg-ec-rsmrst-odl {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "RSMRST power good from regulator";
- enum-name = "PWR_RSMRST";
- gpios = <&gpio0 12 0>;
- interrupt-flags = <GPIO_INT_EDGE_BOTH>;
- };
- pwr-ec-pch-rsmrst-odl {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "RSMRST output to PCH";
- enum-name = "PWR_EC_PCH_RSMRST";
- gpios = <&gpio0 13 0>;
- output;
- };
- pwr-slp-s0-l {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "SLP_S0_L input from PCH";
- enum-name = "PWR_SLP_S0";
- gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
- interrupt-flags = <GPIO_INT_EDGE_BOTH>;
- no-enable;
- };
- pwr-slp-s3-l {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "SLP_S3_L input from PCH";
- enum-name = "PWR_SLP_S3";
- gpios = <&gpio0 15 GPIO_ACTIVE_LOW>;
- interrupt-flags = <GPIO_INT_EDGE_BOTH>;
- };
- pwr-slp-sus-l {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "SLP_SUS_L input from PCH";
- enum-name = "PWR_SLP_SUS";
- gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
- interrupt-flags = <GPIO_INT_EDGE_BOTH>;
- };
- pwr-ec-soc-dsw-pwrok {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "DSW_PWROK output to PCH";
- enum-name = "PWR_EC_SOC_DSW_PWROK";
- gpios = <&gpio0 17 0>;
- output;
- };
- pwr-vccst-pwrgd-od {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "VCCST_PWRGD output to PCH";
- enum-name = "PWR_VCCST_PWRGD";
- gpios = <&gpio0 18 0>;
- output;
- };
- pwr-imvp9-vrrdy-od {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "VRRDY input from IMVP9";
- enum-name = "PWR_IMVP9_VRRDY";
- gpios = <&gpio0 19 0>;
- };
- pwr-pch-pwrok {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "PCH_PWROK output to PCH";
- enum-name = "PWR_PCH_PWROK";
- gpios = <&gpio0 20 0>;
- output;
- };
- pwr-ec-pch-sys-pwrok {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "SYS_PWROK output to PCH";
- enum-name = "PWR_EC_PCH_SYS_PWROK";
- gpios = <&gpio0 21 0>;
- output;
- };
- pwr-sys-rst-l {
- compatible = "intel,ap-pwrseq-gpio";
- dbg-label = "SYS_RESET# output to PCH";
- enum-name = "PWR_SYS_RST";
- gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
- output;
- };
- pwr-slp-s4 {
- compatible = "intel,ap-pwrseq-vw";
- dbg-label = "SLP_S4 virtual wire input from PCH";
- enum-name = "PWR_SLP_S4";
- virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S4";
- vw-invert;
- };
- pwr-slp-s5 {
- compatible = "intel,ap-pwrseq-vw";
- dbg-label = "SLP_S5 virtual wire input from PCH";
- enum-name = "PWR_SLP_S5";
- virtual-wire = "ESPI_VWIRE_SIGNAL_SLP_S5";
- vw-invert;
- };
- pwr-all-sys-pwrgd {
- compatible = "intel,ap-pwrseq-external";
- dbg-label = "Combined all power good";
- enum-name = "PWR_ALL_SYS_PWRGD";
- };
- pwr-pp3300-pwrok {
- compatible = "intel,ap-pwrseq-external";
- dbg-label = "PP3300 PWROK";
- enum-name = "PWR_DSW_PWROK";
- };
- pwr-pp1p05-pwrok {
- compatible = "intel,ap-pwrseq-external";
- dbg-label = "PP1P05 PWROK";
- enum-name = "PWR_PG_PP1P05";
- };
-
clock: clock {
compatible = "cros,clock-control-emul";
clock-frequency = <DT_FREQ_M(100)>; /* 100 MHz */
diff --git a/zephyr/test/ap_power/include/test_mocks.h b/zephyr/test/ap_power/include/test_mocks.h
new file mode 100644
index 0000000000..05e1d823e0
--- /dev/null
+++ b/zephyr/test/ap_power/include/test_mocks.h
@@ -0,0 +1,23 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __TEST_AP_POWER_TEST_MOCKS_H
+#define __TEST_AP_POWER_TEST_MOCKS_H
+
+#include <stdint.h>
+
+#include <zephyr/fff.h>
+
+/*
+ * Mock declarations
+ */
+
+/* Mocks for common/extpower_gpio.c */
+DECLARE_FAKE_VALUE_FUNC(int, extpower_is_present);
+
+/* Mocks for common/system.c */
+DECLARE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t);
+
+#endif /* __TEST_AP_POWER_TEST_MOCKS_H */
diff --git a/zephyr/test/ap_power/include/test_state.h b/zephyr/test/ap_power/include/test_state.h
index cb91f2b7c7..2a7fbe822d 100644
--- a/zephyr/test/ap_power/include/test_state.h
+++ b/zephyr/test/ap_power/include/test_state.h
@@ -6,6 +6,8 @@
#ifndef ZEPHYR_TEST_AP_POWER_INCLUDE_TEST_STATE_H_
#define ZEPHYR_TEST_AP_POWER_INCLUDE_TEST_STATE_H_
+#include <stdbool.h>
+
struct test_state {
bool ec_app_main_run;
};
diff --git a/zephyr/test/ap_power/prj.conf b/zephyr/test/ap_power/prj.conf
index 4dd31085bd..53c6accdd3 100644
--- a/zephyr/test/ap_power/prj.conf
+++ b/zephyr/test/ap_power/prj.conf
@@ -35,16 +35,10 @@ CONFIG_PLATFORM_EC=y
CONFIG_CROS_EC=y
CONFIG_SHIMMED_TASKS=y
CONFIG_EMUL=y
-CONFIG_LOG=y
CONFIG_GPIO=y
-CONFIG_GPIO_EMUL=y
CONFIG_HEAP_MEM_POOL_SIZE=1024
CONFIG_AP_PWRSEQ=y
-CONFIG_X86_NON_DSX_PWRSEQ_ADL=y
-CONFIG_AP_X86_INTEL_ADL=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
-CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y
CONFIG_AP_PWRSEQ_STACK_SIZE=1024
CONFIG_ESPI=y
@@ -56,6 +50,9 @@ CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD=y
CONFIG_PLATFORM_EC_HOSTCMD=y
CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y
+# Short delay for hibernate
+CONFIG_PLATFORM_EC_HIBERNATE_DELAY_SEC=20
+
# These items are not required.
CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
CONFIG_PLATFORM_EC_SWITCH=n
diff --git a/zephyr/test/ap_power/src/ap_pwrseq.c b/zephyr/test/ap_power/src/ap_pwrseq.c
new file mode 100644
index 0000000000..6c2fd4fd7f
--- /dev/null
+++ b/zephyr/test/ap_power/src/ap_pwrseq.c
@@ -0,0 +1,141 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ap_power/ap_power.h"
+#include "ap_power/ap_power_interface.h"
+#include "chipset.h"
+#include "emul/emul_power_signals.h"
+#include "test_state.h"
+
+#include <zephyr/drivers/espi.h>
+#include <zephyr/drivers/espi_emul.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/ztest.h>
+
+#include <ap_power/ap_pwrseq.h>
+
+static struct ap_power_ev_callback test_cb;
+static int power_resume_count;
+static int power_start_up_count;
+static int power_hard_off_count;
+static int power_shutdown_count;
+static int power_shutdown_complete_count;
+static int power_suspend_count;
+
+static void emul_ev_handler(struct ap_power_ev_callback *callback,
+ struct ap_power_ev_data data)
+{
+ switch (data.event) {
+ case AP_POWER_RESUME:
+ power_resume_count++;
+ break;
+
+ case AP_POWER_STARTUP:
+ power_start_up_count++;
+ break;
+
+ case AP_POWER_HARD_OFF:
+ power_hard_off_count++;
+ break;
+
+ case AP_POWER_SHUTDOWN:
+ power_shutdown_count++;
+ break;
+
+ case AP_POWER_SHUTDOWN_COMPLETE:
+ power_shutdown_complete_count++;
+ break;
+
+ case AP_POWER_SUSPEND:
+ power_suspend_count++;
+ break;
+ default:
+ break;
+ };
+}
+
+ZTEST(ap_pwrseq, test_ap_pwrseq_0)
+{
+ zassert_equal(0,
+ power_signal_emul_load(
+ EMUL_POWER_SIGNAL_TEST_PLATFORM(tp_sys_g3_to_s0)),
+ "Unable to load test platfform `tp_sys_g3_to_s0`");
+
+ k_msleep(500);
+
+ zassert_equal(1, power_start_up_count,
+ "AP_POWER_STARTUP event not generated");
+ zassert_equal(1, power_resume_count,
+ "AP_POWER_RESUME event not generated");
+}
+
+ZTEST(ap_pwrseq, test_ap_pwrseq_1)
+{
+ zassert_equal(0,
+ power_signal_emul_load(EMUL_POWER_SIGNAL_TEST_PLATFORM(
+ tp_sys_s0_power_fail)),
+ "Unable to load test platfform `tp_sys_s0_power_fail`");
+
+ /*
+ * Once emulated power signals are loaded, we need to wake AP power
+ * Sequence thread up to start executing new set of power signals
+ */
+ ap_pwrseq_wake();
+ k_msleep(500);
+ zassert_equal(1, power_shutdown_count,
+ "AP_POWER_SHUTDOWN event not generated");
+ zassert_equal(1, power_shutdown_complete_count,
+ "AP_POWER_SHUTDOWN_COMPLETE event not generated");
+ zassert_equal(0, power_suspend_count,
+ "AP_POWER_SUSPEND event generated");
+}
+
+ZTEST(ap_pwrseq, test_ap_pwrseq_2)
+{
+ zassert_equal(
+ 0,
+ power_signal_emul_load(EMUL_POWER_SIGNAL_TEST_PLATFORM(
+ tp_sys_g3_to_s0_power_down)),
+ "Unable to load test platfform `tp_sys_g3_to_s0_power_down`");
+
+ ap_power_exit_hardoff();
+ k_msleep(2000);
+ zassert_equal(3, power_shutdown_count,
+ "AP_POWER_SHUTDOWN event not generated");
+ zassert_equal(3, power_shutdown_complete_count,
+ "AP_POWER_SHUTDOWN_COMPLETE event not generated");
+ zassert_equal(1, power_suspend_count,
+ "AP_POWER_SUSPEND event generated");
+ zassert_equal(1, power_hard_off_count,
+ "AP_POWER_HARD_OFF event generated");
+}
+
+void ap_pwrseq_after_test(void *data)
+{
+ power_signal_emul_unload();
+}
+
+void *ap_pwrseq_setup_suite(void)
+{
+ ap_power_ev_init_callback(&test_cb, emul_ev_handler,
+ AP_POWER_RESUME | AP_POWER_STARTUP |
+ AP_POWER_HARD_OFF | AP_POWER_SUSPEND |
+ AP_POWER_SHUTDOWN |
+ AP_POWER_SHUTDOWN_COMPLETE);
+
+ ap_power_ev_add_callback(&test_cb);
+
+ return NULL;
+}
+
+void ap_pwrseq_teardown_suite(void *data)
+{
+ ap_power_ev_remove_callback(&test_cb);
+}
+
+ZTEST_SUITE(ap_pwrseq, ap_power_predicate_post_main, ap_pwrseq_setup_suite,
+ NULL, ap_pwrseq_after_test, NULL);
diff --git a/zephyr/test/ap_power/src/board.c b/zephyr/test/ap_power/src/board.c
index 26c9448396..f08ccf9ef7 100644
--- a/zephyr/test/ap_power/src/board.c
+++ b/zephyr/test/ap_power/src/board.c
@@ -6,9 +6,11 @@
#include <zephyr/kernel.h>
#include <zephyr/ztest.h>
-#include <ap_power_override_functions.h>
#include <ap_power/ap_power_interface.h>
+#include <ap_power_override_functions.h>
#include <power_signals.h>
+#include <timer.h>
+#include <x86_power_signals.h>
static bool signal_PWR_ALL_SYS_PWRGD;
static bool signal_PWR_DSW_PWROK;
@@ -59,11 +61,29 @@ void board_ap_power_force_shutdown(void)
int board_ap_power_assert_pch_power_ok(void)
{
+ power_signal_set(PWR_PCH_PWROK, 1);
return 0;
}
+static void generate_ec_soc_dsw_pwrok_handler(void)
+{
+ int in_sig_val = power_signal_get(PWR_DSW_PWROK);
+
+ if (in_sig_val != power_signal_get(PWR_EC_SOC_DSW_PWROK)) {
+ power_signal_set(PWR_EC_SOC_DSW_PWROK, 1);
+ }
+}
+
void board_ap_power_action_g3_s5(void)
{
+ power_signal_enable(PWR_DSW_PWROK);
+
+ power_signal_set(PWR_EN_PP3300_A, 1);
+ power_signal_set(PWR_EN_PP5000_A, 1);
+
+ power_wait_signals_timeout(IN_PGOOD_ALL_CORE, 100 * MSEC);
+
+ generate_ec_soc_dsw_pwrok_handler();
}
void board_ap_power_action_s3_s0(void)
@@ -80,10 +100,5 @@ void board_ap_power_action_s0(void)
bool board_ap_power_check_power_rails_enabled(void)
{
- return false;
-}
-
-int extpower_is_present(void)
-{
- return 0;
+ return true;
}
diff --git a/zephyr/test/ap_power/src/console_command.c b/zephyr/test/ap_power/src/console_command.c
index 9d38e773c7..7789a13919 100644
--- a/zephyr/test/ap_power/src/console_command.c
+++ b/zephyr/test/ap_power/src/console_command.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test_state.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_USER(console_cmd_debug_mode, test_debug_mode_default)
{
zassert_ok(shell_execute_cmd(get_ec_shell(), "debug_mode"),
diff --git a/zephyr/test/ap_power/src/events.c b/zephyr/test/ap_power/src/events.c
index ae7d2b870f..2528d356f6 100644
--- a/zephyr/test/ap_power/src/events.c
+++ b/zephyr/test/ap_power/src/events.c
@@ -8,20 +8,18 @@
* @brief Unit Tests for AP power events
*/
-#include <zephyr/device.h>
+#include "ap_power/ap_power.h"
+#include "ap_power/ap_power_events.h"
+#include "hooks.h"
+#include "test_state.h"
+#include <zephyr/device.h>
#include <zephyr/drivers/espi.h>
#include <zephyr/drivers/espi_emul.h>
-#include <zephyr/logging/log.h>
#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
#include <zephyr/ztest.h>
-#include "ap_power/ap_power.h"
-#include "ap_power/ap_power_events.h"
-
-#include "hooks.h"
-#include "test_state.h"
-
/*
* Structure passed to event listeners.
*/
@@ -173,6 +171,7 @@ DECLARE_HOOK(HOOK_CHIPSET_STARTUP, hook_startup, HOOK_PRIO_DEFAULT);
*/
ZTEST(events, test_hooks)
{
+ count_hook_startup = count_hook_shutdown = 0;
ap_power_ev_send_callbacks(AP_POWER_STARTUP);
zassert_equal(0, count_hook_shutdown, "shutdown hook called");
zassert_equal(1, count_hook_startup, "startup hook not called");
diff --git a/zephyr/test/ap_power/src/hibdelay.c b/zephyr/test/ap_power/src/hibdelay.c
new file mode 100644
index 0000000000..11fac953ea
--- /dev/null
+++ b/zephyr/test/ap_power/src/hibdelay.c
@@ -0,0 +1,37 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "console.h"
+#include "ec_commands.h"
+#include "test_state.h"
+
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
+ZTEST_SUITE(console_cmd_hibdelay, ap_power_predicate_post_main, NULL, NULL,
+ NULL, NULL);
+
+ZTEST_USER(console_cmd_hibdelay, test_too_many_args)
+{
+ zassert_ok(shell_execute_cmd(get_ec_shell(), "hibdelay 1 2"), NULL);
+}
+
+ZTEST_USER(console_cmd_hibdelay, test_no_args)
+{
+ zassert_ok(shell_execute_cmd(get_ec_shell(), "hibdelay"), NULL);
+}
+
+ZTEST_USER(console_cmd_hibdelay, test_invalid_arg)
+{
+ int rv = shell_execute_cmd(get_ec_shell(), "hibdelay 3.4");
+
+ zassert_equal(rv, EC_ERROR_PARAM1, "Expected %d, but got %d",
+ EC_ERROR_PARAM1, rv);
+}
+
+ZTEST_USER(console_cmd_hibdelay, test_valid_args)
+{
+ zassert_ok(shell_execute_cmd(get_ec_shell(), "hibdelay 5"), NULL);
+}
diff --git a/zephyr/test/ap_power/src/hibernate.c b/zephyr/test/ap_power/src/hibernate.c
new file mode 100644
index 0000000000..23030bdcb3
--- /dev/null
+++ b/zephyr/test/ap_power/src/hibernate.c
@@ -0,0 +1,39 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "hooks.h"
+#include "test_mocks.h"
+#include "test_state.h"
+
+#include <zephyr/device.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/ztest.h>
+
+#include <ap_power/ap_power.h>
+#include <ap_power/ap_power_events.h>
+#include <ap_power/ap_power_interface.h>
+
+ZTEST(hibernate, test_g3_hibernate)
+{
+ extpower_is_present_fake.return_val = 0;
+ ap_power_ev_send_callbacks(AP_POWER_HARD_OFF);
+ k_sleep(K_SECONDS(30));
+ zassert_equal(1, system_hibernate_fake.call_count);
+}
+
+ZTEST(hibernate, test_ac_changed)
+{
+ extpower_is_present_fake.return_val = 1;
+ hook_notify(HOOK_AC_CHANGE);
+ k_sleep(K_SECONDS(30));
+ zassert_equal(0, system_hibernate_fake.call_count);
+ extpower_is_present_fake.return_val = 0;
+ hook_notify(HOOK_AC_CHANGE);
+ k_sleep(K_SECONDS(30));
+ zassert_equal(1, system_hibernate_fake.call_count);
+}
+
+ZTEST_SUITE(hibernate, ap_power_predicate_post_main, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/ap_power/src/host_command.c b/zephyr/test/ap_power/src/host_command.c
new file mode 100644
index 0000000000..f0b3b0d732
--- /dev/null
+++ b/zephyr/test/ap_power/src/host_command.c
@@ -0,0 +1,28 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ec_commands.h"
+#include "host_command.h"
+#include "test_state.h"
+
+#include <zephyr/ztest.h>
+
+ZTEST(host_cmd, test_hibernate_get)
+{
+ struct ec_response_hibernation_delay response;
+ struct ec_params_hibernation_delay params = {
+ .seconds = 0,
+ };
+
+ struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
+ EC_CMD_HIBERNATION_DELAY, 0, response, params);
+
+ zassert_ok(host_command_process(&args));
+ params.seconds = 123;
+ zassert_ok(host_command_process(&args));
+ zassert_equal(123, response.hibernate_delay, NULL);
+}
+
+ZTEST_SUITE(host_cmd, ap_power_predicate_post_main, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/ap_power/src/main.c b/zephyr/test/ap_power/src/main.c
index d653b51164..9ed34eee4a 100644
--- a/zephyr/test/ap_power/src/main.c
+++ b/zephyr/test/ap_power/src/main.c
@@ -3,11 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
#include "ec_app_main.h"
#include "test_state.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
bool ap_power_predicate_pre_main(const void *state)
{
return ((struct test_state *)state)->ec_app_main_run == false;
diff --git a/zephyr/test/ap_power/src/signals.c b/zephyr/test/ap_power/src/signals.c
index e8bc6e426c..4eae187564 100644
--- a/zephyr/test/ap_power/src/signals.c
+++ b/zephyr/test/ap_power/src/signals.c
@@ -8,24 +8,22 @@
* @brief Unit Tests for power signals API
*/
-#include <zephyr/device.h>
-
-#include <zephyr/drivers/espi.h>
-#include <zephyr/drivers/espi_emul.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
-#include "power_signals.h"
-
#include "ec_tasks.h"
#include "emul/emul_stub_device.h"
#include "gpio.h"
#include "gpio/gpio.h"
#include "gpio/gpio_int.h"
+#include "power_signals.h"
#include "test_state.h"
+#include <zephyr/device.h>
+#include <zephyr/drivers/espi.h>
+#include <zephyr/drivers/espi_emul.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/ztest.h>
+
extern bool gpio_test_interrupt_triggered;
static const struct device *emul_port;
diff --git a/zephyr/test/ap_power/src/test_mocks.c b/zephyr/test/ap_power/src/test_mocks.c
new file mode 100644
index 0000000000..9eb8834ff5
--- /dev/null
+++ b/zephyr/test/ap_power/src/test_mocks.c
@@ -0,0 +1,30 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "test_mocks.h"
+
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
+/* Mocks for common/extpower_gpio.c */
+DEFINE_FAKE_VALUE_FUNC(int, extpower_is_present);
+
+/* Mocks for common/system.c */
+DEFINE_FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t);
+
+/**
+ * @brief Reset all the fakes before each test.
+ */
+static void fff_reset_rule_before(const struct ztest_unit_test *test,
+ void *data)
+{
+ ARG_UNUSED(test);
+ ARG_UNUSED(data);
+
+ RESET_FAKE(extpower_is_present);
+ RESET_FAKE(system_hibernate);
+}
+
+ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL);
diff --git a/zephyr/test/ap_power/testcase.yaml b/zephyr/test/ap_power/testcase.yaml
index aaf8a530a6..b55e2f3f47 100644
--- a/zephyr/test/ap_power/testcase.yaml
+++ b/zephyr/test/ap_power/testcase.yaml
@@ -1,4 +1,10 @@
common:
platform_allow: native_posix
tests:
- ap_power.default: {}
+ ap_power.alderlake:
+ extra_args: CONFIG_EMUL_POWER_SIGNALS=y
+ CONFIG_X86_NON_DSX_PWRSEQ_ADL=y
+ CONFIG_AP_X86_INTEL_ADL=y
+ CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S4=y
+ CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI_VW_SLP_S5=y
+ DTC_OVERLAY_FILE="boards/native_posix.overlay";"boards/alderlake.dts"
diff --git a/zephyr/test/crc/main.c b/zephyr/test/crc/main.c
index 0b13970d83..f9da78bfde 100644
--- a/zephyr/test/crc/main.c
+++ b/zephyr/test/crc/main.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
+#include "crc8.h"
+
#include <zephyr/ztest_assert.h>
#include <zephyr/ztest_test_new.h>
-#include "crc8.h"
-
ZTEST_SUITE(crc_driver, NULL, NULL, NULL, NULL, NULL);
ZTEST(crc_driver, test_crc8_known_data)
diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt
index b03e3e4edd..78c1274843 100644
--- a/zephyr/test/drivers/CMakeLists.txt
+++ b/zephyr/test/drivers/CMakeLists.txt
@@ -38,16 +38,23 @@ add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USB_PORT_POWER_DUMB usb_port_power
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USB_RETIMER_FW_UPDATE usb_retimer_fw_update)
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_ALT_MODE usbc_alt_mode)
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_CONSOLE_PD usbc_console_pd)
+add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_CTVPD usbc_ctvpd)
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_SVDM_DFP_ONLY usbc_svdm_dfp_only)
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_TBT_MODE usbc_tbt_mode)
+add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_USB4_MODE usbc_usb4_mode)
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_VCONN_SWAP usbc_vconn_swap)
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_OCP usbc_ocp)
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_USBC_PPC usbc_ppc)
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_HOST_COMMANDS host_cmd)
+add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_HOST_COMMAND_READ_MEMMAP host_cmd_read_memmap)
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_SYSTEM system)
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_LOCATE_CHIP_ALTS locate_chip)
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_BUTTON button)
add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_CONSOLE console)
+add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_HOST_CMD_THREAD host_command_thread)
+add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_PI3USB9201 bc12_pi3usb9201)
+add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_MEMMAP memmap)
+add_subdirectory_ifdef(CONFIG_LINK_TEST_SUITE_LED_COMMON led_common)
get_target_property(TEST_SOURCES_NEW app SOURCES)
diff --git a/zephyr/test/drivers/Kconfig b/zephyr/test/drivers/Kconfig
index 9254bb9e31..b2a9648f21 100644
--- a/zephyr/test/drivers/Kconfig
+++ b/zephyr/test/drivers/Kconfig
@@ -33,8 +33,12 @@ config LINK_TEST_SUITE_COMMON_CHARGER
bool "Link and execute the common/charger.c tests"
config LINK_TEST_SUITE_HOST_COMMANDS
+ select PLATFORM_EC_CHARGE_STATE_DEBUG
bool "Link and test the host command tests"
+config LINK_TEST_SUITE_HOST_COMMAND_READ_MEMMAP
+ bool "Link and test the host command read memmap tests"
+
config LINK_TEST_SUITE_ISL923X
bool "Link and test the isl923x tests"
@@ -43,6 +47,8 @@ config LINK_TEST_SUITE_I2C_CONTROLLER
config LINK_TEST_SUITE_KEYBOARD_SCAN
bool "Link and test the keyboard_scan tests"
+ select PLATFORM_EC_MKBP_EVENT_WAKEUP_MASK
+ select PLATFORM_EC_MKBP_HOST_EVENT_WAKEUP_MASK
config LINK_TEST_SUITE_LED_DRIVER
bool "Link and test the led_driver tests"
@@ -98,6 +104,11 @@ config LINK_TEST_SUITE_USBC_ALT_MODE
config LINK_TEST_SUITE_USBC_CONSOLE_PD
bool"Link and test the usbc_console_pd tests"
+config LINK_TEST_SUITE_USBC_CTVPD
+ bool "Link tests for charge-through VCONN-powered device support"
+ select EMUL_TCPCI_PARTNER_VPD
+ select LOG
+
config LINK_TEST_SUITE_USBC_OCP
bool "Link tests for common USBC OCP code"
@@ -110,6 +121,11 @@ config LINK_TEST_SUITE_USBC_SVDM_DFP_ONLY
config LINK_TEST_SUITE_USBC_TBT_MODE
bool "Link and test the usbc_tbt_mode tests"
+config LINK_TEST_SUITE_USBC_USB4_MODE
+ bool "Link and test the usbc_usb4_mode tests"
+ help
+ Include the usbc_usb4 test suite in the binary.
+
config LINK_TEST_SUITE_USBC_VCONN_SWAP
bool "Link and test the usbc_vconn_swap tests"
help
@@ -119,4 +135,19 @@ config LINK_TEST_SUITE_CONSOLE
bool "Link and test the console tests"
select UART_INTERRUPT_DRIVEN
+config LINK_TEST_SUITE_HOST_CMD_THREAD
+ bool "Link and test the host command thread override tests"
+
+config LINK_TEST_SUITE_PI3USB9201
+ bool "Link and test the pi3usb9201 tests"
+
+config LINK_TEST_SUITE_MEMMAP
+ bool "Link and test memory mapped tests for common/flash.c"
+ select PLATFORM_EC_MAPPED_STORAGE
+
+config LINK_TEST_SUITE_LED_COMMON
+ bool "Link and test the led_common.c file"
+ depends on !PLATFORM_EC_LED_DT
+ select PLATFORM_EC_LED_COMMON
+
source "Kconfig.zephyr"
diff --git a/zephyr/test/drivers/anx7447/prj.conf b/zephyr/test/drivers/anx7447/prj.conf
index d297ee0725..18d953d0c6 100644
--- a/zephyr/test/drivers/anx7447/prj.conf
+++ b/zephyr/test/drivers/anx7447/prj.conf
@@ -2,6 +2,5 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-CONFIG_EMUL_ANX7447=y
CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y
CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447=y
diff --git a/zephyr/test/drivers/anx7447/src/low_power_mode.c b/zephyr/test/drivers/anx7447/src/low_power_mode.c
index 67c095b64d..cbcea1955c 100644
--- a/zephyr/test/drivers/anx7447/src/low_power_mode.c
+++ b/zephyr/test/drivers/anx7447/src/low_power_mode.c
@@ -3,9 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/emul.h>
-#include <zephyr/ztest.h>
-
#include "emul/tcpc/emul_tcpci.h"
#include "tcpm/anx7447_public.h"
#include "tcpm/tcpci.h"
@@ -13,6 +10,9 @@
#include "test/drivers/test_state.h"
#include "usb_pd.h"
+#include <zephyr/drivers/emul.h>
+#include <zephyr/ztest.h>
+
#define ANX7447_NODE DT_NODELABEL(anx7447_emul)
static const int tcpm_anx7447_port = USBC_PORT_C0;
diff --git a/zephyr/test/drivers/anx7447/tcpc_policy.dts b/zephyr/test/drivers/anx7447/tcpc_policy.dts
index 9126d55e61..6bdae81e73 100644
--- a/zephyr/test/drivers/anx7447/tcpc_policy.dts
+++ b/zephyr/test/drivers/anx7447/tcpc_policy.dts
@@ -18,7 +18,7 @@
status="okay";
anx7447_emul: anx7447_emul@2c {
- compatible = "cros,anx7447-emul";
+ compatible = "cros,anx7447-tcpc-emul";
reg = <0x2c>;
tcpc-flags = <(
TCPC_FLAGS_VBUS_MONITOR |
diff --git a/zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c b/zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c
index d059870f25..993c6e680c 100644
--- a/zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c
+++ b/zephyr/test/drivers/ap_mux_control/src/ap_mux_control.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
-#include "usb_mux.h"
#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include "usb_mux.h"
+
+#include <zephyr/ztest.h>
static void ap_mux_control_before(void *data)
{
@@ -23,7 +23,7 @@ static void ap_mux_control_before(void *data)
k_sleep(K_SECONDS(1));
/* And test the assumption that setting NONE worked */
- zassume_equal(usb_mux_get(USBC_PORT_C0), USB_PD_MUX_NONE,
+ zassert_equal(usb_mux_get(USBC_PORT_C0), USB_PD_MUX_NONE,
"Failed to set mux to initial state");
}
diff --git a/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c b/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c
index 7c526f0ccb..fe7dab88f4 100644
--- a/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c
+++ b/zephyr/test/drivers/ap_vdm_control/src/ap_vdm_control.c
@@ -3,24 +3,123 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "ec_commands.h"
-#include "usb_mux.h"
#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include "usb_mux.h"
+#include "usb_pd_vdo.h"
+
+#include <stdint.h>
+
+#include <zephyr/kernel.h>
+#include <zephyr/sys/byteorder.h>
+#include <zephyr/ztest.h>
+
+#define TEST_PORT USBC_PORT_C0
+
+struct ap_vdm_control_fixture {
+ const struct emul *tcpci_emul;
+ const struct emul *charger_emul;
+ struct tcpci_partner_data partner;
+ struct tcpci_src_emul_data src_ext;
+};
+
+struct tcpci_cable_data passive_usb3 = {
+ .identity_vdm[VDO_INDEX_HDR] =
+ VDO(USB_SID_PD, /* structured VDM */ true,
+ VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_IDENT),
+ .identity_vdm[VDO_INDEX_IDH] = VDO_IDH(
+ /* USB host */ false, /* USB device */ false, IDH_PTYPE_PCABLE,
+ /* modal operation */ false, USB_VID_GOOGLE),
+ .identity_vdm[VDO_INDEX_CSTAT] = 0,
+ .identity_vdm[VDO_INDEX_PRODUCT] = VDO_PRODUCT(0x1234, 0xABCD),
+ .identity_vdm[VDO_INDEX_PTYPE_CABLE1] =
+ VDO_REV30_PASSIVE(USB_R30_SS_U32_U40_GEN2, USB_VBUS_CUR_3A,
+ USB_REV30_LATENCY_1m, USB_REV30_TYPE_C),
+ .identity_vdos = VDO_INDEX_PTYPE_CABLE1 + 1,
+
+};
+
+static void verify_vdm_req(struct ap_vdm_control_fixture *fixture,
+ struct typec_vdm_req *req)
+{
+ struct tcpci_partner_log_msg *msg;
+ bool message_seen = 0;
+
+ SYS_SLIST_FOR_EACH_CONTAINER(&fixture->partner.msg_log, msg, node)
+ {
+ uint16_t header = sys_get_le16(msg->buf);
+
+ /* Ignore messages from ourselves */
+ if (msg->sender == TCPCI_PARTNER_SENDER_PARTNER)
+ continue;
+
+ /*
+ * Control messages, non-VDMs, and extended messages are not of
+ * interest
+ */
+ if ((PD_HEADER_CNT(header) == 0) ||
+ (PD_HEADER_TYPE(header) != PD_DATA_VENDOR_DEF) ||
+ (PD_HEADER_EXT(header) != 0)) {
+ continue;
+ }
+
+ if (req->partner_type != msg->sop)
+ continue;
+
+ /* We have a VDM, check entry we're interested in */
+ if (memcmp(msg->buf, req->vdm_data,
+ req->vdm_data_objects * sizeof(uint32_t))) {
+ message_seen = true;
+ break;
+ }
+ }
+
+ zassert_true(message_seen, "Expected message not found");
+}
+
+static void *ap_vdm_control_setup(void)
+{
+ static struct ap_vdm_control_fixture fixture;
+ struct tcpci_partner_data *partner = &fixture.partner;
+ struct tcpci_src_emul_data *src_ext = &fixture.src_ext;
+
+ tcpci_partner_init(partner, PD_REV30);
+ partner->extensions = tcpci_src_emul_init(src_ext, partner, NULL);
+ partner->cable = &passive_usb3;
+
+ /* Get references for the emulators */
+ fixture.tcpci_emul = EMUL_DT_GET(DT_NODELABEL(tcpci_emul));
+ fixture.charger_emul = EMUL_DT_GET(DT_NODELABEL(isl923x_emul));
+
+ return &fixture;
+}
static void ap_vdm_control_before(void *data)
{
+ struct ap_vdm_control_fixture *fix = data;
+
/* Set chipset on so the "AP" is on to give us commands */
test_set_chipset_to_s0();
+
+ /* Connect our port partner */
+ connect_source_to_port(&fix->partner, &fix->src_ext, 0, fix->tcpci_emul,
+ fix->charger_emul);
+}
+
+static void ap_vdm_control_after(void *data)
+{
+ struct ap_vdm_control_fixture *fix = data;
+
+ disconnect_source_from_port(fix->tcpci_emul, fix->charger_emul);
+ tcpci_partner_common_clear_logged_msgs(&fix->partner);
}
-ZTEST_SUITE(ap_vdm_control, drivers_predicate_post_main, NULL,
- ap_vdm_control_before, NULL, NULL);
+ZTEST_SUITE(ap_vdm_control, drivers_predicate_post_main, ap_vdm_control_setup,
+ ap_vdm_control_before, ap_vdm_control_after, NULL);
-ZTEST(ap_vdm_control, test_feature_present)
+ZTEST_F(ap_vdm_control, test_feature_present)
{
struct ec_response_get_features feat = host_cmd_get_features();
@@ -28,3 +127,139 @@ ZTEST(ap_vdm_control, test_feature_present)
EC_FEATURE_MASK_1(EC_FEATURE_TYPEC_AP_VDM_SEND),
"Failed to see feature present");
}
+
+ZTEST_F(ap_vdm_control, test_send_vdm_req_bad_port)
+{
+ struct ec_params_typec_control params = {
+ .port = 85,
+ .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
+ .vdm_req_params = {
+ .vdm_data = { 0 },
+ .vdm_data_objects = 1,
+ .partner_type = TYPEC_PARTNER_SOP,
+ },
+ };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
+
+ zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
+ "Failed to see port error");
+}
+
+ZTEST_F(ap_vdm_control, test_send_vdm_req_bad_type)
+{
+ struct ec_params_typec_control params = {
+ .port = TEST_PORT,
+ .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
+ .vdm_req_params = {
+ .vdm_data = { 0 },
+ .vdm_data_objects = 1,
+ .partner_type = TYPEC_PARTNER_SOP_PRIME_PRIME + 1,
+ },
+ };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
+
+ zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
+ "Failed to see port error");
+}
+
+ZTEST_F(ap_vdm_control, test_send_vdm_req_bad_count)
+{
+ struct ec_params_typec_control params = {
+ .port = TEST_PORT,
+ .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
+ .vdm_req_params = {
+ .vdm_data = { 0 },
+ .vdm_data_objects = 0,
+ .partner_type = TYPEC_PARTNER_SOP,
+ },
+ };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
+
+ zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
+ "Failed to see port error");
+}
+
+ZTEST_F(ap_vdm_control, test_send_vdm_sop_req_valid)
+{
+ uint32_t vdm_req_header = VDO(USB_SID_PD, 1, CMD_DISCOVER_IDENT);
+ struct typec_vdm_req req = {
+ .vdm_data = { vdm_req_header },
+ .vdm_data_objects = 1,
+ .partner_type = TYPEC_PARTNER_SOP,
+ };
+
+ tcpci_partner_common_enable_pd_logging(&fixture->partner, true);
+ host_cmd_typec_control_vdm_req(TEST_PORT, req);
+ k_sleep(K_SECONDS(1));
+
+ tcpci_partner_common_enable_pd_logging(&fixture->partner, false);
+
+ /* Look for our REQ */
+ verify_vdm_req(fixture, &req);
+}
+
+ZTEST_F(ap_vdm_control, test_send_vdm_sop_prime_req_valid)
+{
+ uint32_t vdm_req_header = VDO(USB_SID_PD, 1, CMD_DISCOVER_IDENT);
+ struct typec_vdm_req req = {
+ .vdm_data = { vdm_req_header },
+ .vdm_data_objects = 1,
+ .partner_type = TYPEC_PARTNER_SOP_PRIME,
+ };
+
+ tcpci_partner_common_enable_pd_logging(&fixture->partner, true);
+ host_cmd_typec_control_vdm_req(TEST_PORT, req);
+ k_sleep(K_SECONDS(1));
+
+ tcpci_partner_common_enable_pd_logging(&fixture->partner, false);
+
+ /* Look for our REQ */
+ verify_vdm_req(fixture, &req);
+}
+
+ZTEST_F(ap_vdm_control, test_send_vdm_sop_attention_bad)
+{
+ uint32_t vdm_req_header = VDO(USB_SID_DISPLAYPORT, 1, CMD_ATTENTION);
+ struct ec_params_typec_control params = {
+ .port = TEST_PORT,
+ .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
+ .vdm_req_params = {
+ .vdm_data = { vdm_req_header },
+ .vdm_data_objects = 5,
+ .partner_type = TYPEC_PARTNER_SOP,
+ },
+ };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
+
+ zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
+ "Failed to see port error");
+}
+
+ZTEST_F(ap_vdm_control, test_send_vdm_req_in_progress)
+{
+ uint32_t vdm_req_header = VDO(USB_SID_PD, 1, CMD_DISCOVER_IDENT);
+ struct ec_params_typec_control params = {
+ .port = TEST_PORT,
+ .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
+ .vdm_req_params = {
+ .vdm_data = { vdm_req_header },
+ .vdm_data_objects = 1,
+ .partner_type = TYPEC_PARTNER_SOP,
+ },
+ };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
+
+ /*
+ * First command should succeed, but given no time to process the second
+ * should return busy
+ */
+ zassert_equal(host_command_process(&args), EC_RES_SUCCESS,
+ "Failed to send successful request");
+ zassert_equal(host_command_process(&args), EC_RES_BUSY,
+ "Failed to see busy");
+}
diff --git a/zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt b/zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt
new file mode 100644
index 0000000000..2f1925b635
--- /dev/null
+++ b/zephyr/test/drivers/bc12_pi3usb9201/CMakeLists.txt
@@ -0,0 +1,6 @@
+# Copyright 2022 The ChromiumOS Authors
+#Use of this source code is governed by a BSD-style license that can be
+#found in the LICENSE file.
+
+target_sources(app PRIVATE src/pi3usb9201.c)
+target_sources(app PRIVATE src/pi3usb9201_interrupt.c)
diff --git a/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c
new file mode 100644
index 0000000000..0f9e7cbbeb
--- /dev/null
+++ b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201.c
@@ -0,0 +1,279 @@
+/* Copyright 2021 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "emul/emul_pi3usb9201.h"
+#include "extpower.h"
+#include "test/drivers/stubs.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+#include "timer.h"
+#include "usb_charge.h"
+
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/ztest.h>
+LOG_MODULE_REGISTER(test_drivers_bc12, LOG_LEVEL_DBG);
+
+#define EMUL_NODE DT_NODELABEL(pi3usb9201_emul0)
+
+/* Control_1 register bit definitions */
+#define PI3USB9201_REG_CTRL_1_INT_MASK BIT(0)
+#define PI3USB9201_REG_CTRL_1_MODE_SHIFT 1
+#define PI3USB9201_REG_CTRL_1_MODE_MASK \
+ (0x7 << PI3USB9201_REG_CTRL_1_MODE_SHIFT)
+
+/* Control_2 register bit definitions */
+#define PI3USB9201_REG_CTRL_2_AUTO_SW BIT(1)
+#define PI3USB9201_REG_CTRL_2_START_DET BIT(3)
+
+/* Host status register bit definitions */
+#define PI3USB9201_REG_HOST_STS_BC12_DET BIT(0)
+#define PI3USB9201_REG_HOST_STS_DEV_PLUG BIT(1)
+#define PI3USB9201_REG_HOST_STS_DEV_UNPLUG BIT(2)
+
+enum pi3usb9201_mode {
+ PI3USB9201_POWER_DOWN,
+ PI3USB9201_SDP_HOST_MODE,
+ PI3USB9201_DCP_HOST_MODE,
+ PI3USB9201_CDP_HOST_MODE,
+ PI3USB9201_CLIENT_MODE,
+ PI3USB9201_RESERVED_1,
+ PI3USB9201_RESERVED_2,
+ PI3USB9201_USB_PATH_ON,
+};
+
+enum pi3usb9201_client_sts {
+ CHG_OTHER = 0,
+ CHG_2_4A,
+ CHG_2_0A,
+ CHG_1_0A,
+ CHG_RESERVED,
+ CHG_CDP,
+ CHG_SDP,
+ CHG_DCP,
+};
+
+struct bc12_status {
+ enum charge_supplier supplier;
+ int current_limit;
+};
+
+static const struct bc12_status bc12_chg_limits[] = {
+ [CHG_OTHER] = { .supplier = CHARGE_SUPPLIER_OTHER,
+ .current_limit = 500 },
+ [CHG_2_4A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY,
+ .current_limit = USB_CHARGER_MAX_CURR_MA },
+ [CHG_2_0A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY,
+ .current_limit = USB_CHARGER_MAX_CURR_MA },
+ [CHG_1_0A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY,
+ .current_limit = 1000 },
+ [CHG_RESERVED] = { .supplier = CHARGE_SUPPLIER_NONE,
+ /* Not charging, limit is set to default */
+ .current_limit =
+ CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT },
+ [CHG_CDP] = { .supplier = CHARGE_SUPPLIER_BC12_CDP,
+ .current_limit = USB_CHARGER_MAX_CURR_MA },
+ [CHG_SDP] = { .supplier = CHARGE_SUPPLIER_BC12_SDP,
+ .current_limit = 500 },
+#if defined(CONFIG_CHARGE_RAMP_SW) || defined(CONFIG_CHARGE_RAMP_HW)
+ [CHG_DCP] = { .supplier = CHARGE_SUPPLIER_BC12_DCP,
+ .current_limit = USB_CHARGER_MAX_CURR_MA },
+#else
+ [CHG_DCP] = { .supplier = CHARGE_SUPPLIER_BC12_DCP,
+ .current_limit = 500 },
+#endif
+};
+
+#define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl)
+#define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios)
+
+static void test_bc12_pi3usb9201_host_mode(void)
+{
+ const struct emul *emul = EMUL_DT_GET(EMUL_NODE);
+ uint8_t a, b;
+
+ /*
+ * Pretend that the USB-C Port Manager (TCPMv2) has set the port data
+ * role to DFP.
+ */
+ usb_charger_task_set_event(0, USB_CHG_EVENT_DR_DFP);
+ msleep(1);
+ /*
+ * Expect the pi3usb9201 driver to configure CDP host mode and unmask
+ * interrupts.
+ */
+ pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a);
+ b = PI3USB9201_CDP_HOST_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT;
+ zassert_equal(a, b);
+
+ /* Pretend that a device has been plugged in. */
+ msleep(500);
+ pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS,
+ PI3USB9201_REG_HOST_STS_DEV_PLUG);
+ usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
+ msleep(1);
+ /* Expect the pi3usb9201 driver to configure SDP host mode. */
+ pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a);
+ b = PI3USB9201_SDP_HOST_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT;
+ zassert_equal(a, b);
+ pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS, 0);
+
+ /* Pretend that a device has been unplugged. */
+ msleep(500);
+ pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS,
+ PI3USB9201_REG_HOST_STS_DEV_UNPLUG);
+ usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
+ msleep(1);
+ /* Expect the pi3usb9201 driver to configure CDP host mode. */
+ pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a);
+ b = PI3USB9201_CDP_HOST_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT;
+ zassert_equal(a, b);
+ pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS, 0);
+}
+
+static void
+test_bc12_pi3usb9201_client_mode(enum pi3usb9201_client_sts detect_result,
+ enum charge_supplier supplier,
+ int current_limit)
+{
+ const struct emul *emul = EMUL_DT_GET(EMUL_NODE);
+ uint8_t a, b;
+ int port, voltage;
+
+ /*
+ * Pretend that the USB-C Port Manager (TCPMv2) has set the port data
+ * role to UFP and decided charging from the port is allowed.
+ */
+ msleep(500);
+ usb_charger_task_set_event(0, USB_CHG_EVENT_DR_UFP);
+ charge_manager_update_dualrole(USBC_PORT_C0, CAP_DEDICATED);
+ msleep(1);
+ /*
+ * Expect the pi3usb9201 driver to configure client mode and start
+ * detection.
+ */
+ pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a);
+ b = PI3USB9201_CLIENT_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT;
+ zassert_equal(a, b);
+ pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_2, &a);
+ b = PI3USB9201_REG_CTRL_2_START_DET;
+ zassert_equal(a, b);
+
+ /* Pretend that detection completed. */
+ msleep(500);
+ pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_CLIENT_STS,
+ 1 << detect_result);
+ usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
+ msleep(1);
+ /* Expect the pi3usb9201 driver to clear the start bit. */
+ pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_2, &a);
+ zassert_equal(a, 0);
+ pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_CLIENT_STS, 0);
+ /*
+ * Expect the charge manager to select the detected BC1.2 supplier.
+ */
+ port = CHARGE_PORT_NONE;
+ voltage = 0;
+ if (supplier != CHARGE_SUPPLIER_NONE) {
+ port = USBC_PORT_C0;
+ voltage = USB_CHARGER_VOLTAGE_MV;
+ }
+ /* Wait for the charge port to update. */
+ msleep(500);
+ zassert_equal(charge_manager_get_active_charge_port(), port);
+ zassert_equal(charge_manager_get_supplier(), supplier);
+ zassert_equal(charge_manager_get_charger_current(), current_limit,
+ NULL);
+ zassert_equal(charge_manager_get_charger_voltage(), voltage);
+
+ /*
+ * Pretend that the USB-C Port Manager (TCPMv2) has set the port data
+ * role to disconnected.
+ */
+ msleep(500);
+ usb_charger_task_set_event(0, USB_CHG_EVENT_CC_OPEN);
+ msleep(1);
+ /*
+ * Expect the pi3usb9201 driver to configure power down mode and mask
+ * interrupts.
+ */
+ pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a);
+ b = PI3USB9201_POWER_DOWN << PI3USB9201_REG_CTRL_1_MODE_SHIFT;
+ b |= PI3USB9201_REG_CTRL_1_INT_MASK;
+ zassert_equal(a, b);
+ /* Expect the charge manager to have no active supplier. */
+ zassert_equal(charge_manager_get_active_charge_port(), CHARGE_PORT_NONE,
+ NULL);
+ zassert_equal(charge_manager_get_supplier(), CHARGE_SUPPLIER_NONE,
+ NULL);
+ zassert_equal(charge_manager_get_charger_current(),
+ CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT);
+ zassert_equal(charge_manager_get_charger_voltage(), 0);
+}
+
+/*
+ * PI3USB9201 is a dual-role BC1.2 charger detector/advertiser used on USB
+ * ports. It can be programmed to operate in host mode or client mode through
+ * I2C. When operating as a host, PI3USB9201 enables BC1.2 SDP/CDP/DCP
+ * advertisement to the attached USB devices via the D+/- connection. When
+ * operating as a client, PI3USB9201 starts BC1.2 detection to detect the
+ * attached host type. In both host mode and client mode, the detection results
+ * are reported through I2C to the controller.
+ */
+ZTEST_USER(bc12, test_bc12_pi3usb9201)
+{
+ const struct device *batt_pres_dev =
+ DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios));
+ const struct emul *emul = EMUL_DT_GET(EMUL_NODE);
+ uint8_t a, b;
+
+ /* Pretend we have battery and AC so charging works normally. */
+ zassert_ok(gpio_emul_input_set(batt_pres_dev, GPIO_BATT_PRES_ODL_PORT,
+ 0),
+ NULL);
+ zassert_equal(BP_YES, battery_is_present());
+ set_ac_enabled(true);
+
+ /* Wait long enough for TCPMv2 to be idle. */
+ msleep(2000);
+
+ /*
+ * Pretend that the USB-C Port Manager (TCPMv2) has set the port data
+ * role to disconnected.
+ */
+ usb_charger_task_set_event(0, USB_CHG_EVENT_CC_OPEN);
+ usb_charger_task_set_event(1, USB_CHG_EVENT_CC_OPEN);
+ msleep(1);
+ /*
+ * Expect the pi3usb9201 driver to configure power down mode and mask
+ * interrupts.
+ */
+ pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a);
+ b = PI3USB9201_POWER_DOWN << PI3USB9201_REG_CTRL_1_MODE_SHIFT;
+ b |= PI3USB9201_REG_CTRL_1_INT_MASK;
+ zassert_equal(a, b);
+
+ test_bc12_pi3usb9201_host_mode();
+
+ for (int c = CHG_OTHER; c <= CHG_DCP; c++) {
+ LOG_INF("Test client mode supplier %d", c);
+ test_bc12_pi3usb9201_client_mode(
+ c, bc12_chg_limits[c].supplier,
+ bc12_chg_limits[c].current_limit);
+ }
+}
+
+/*
+ * TODO(b/216660795): Cleanup state using a teardown_fn
+ */
+static void bc12_after(void *unused)
+{
+ set_ac_enabled(false);
+}
+
+ZTEST_SUITE(bc12, drivers_predicate_post_main, NULL, NULL, bc12_after, NULL);
diff --git a/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c
new file mode 100644
index 0000000000..959684c23b
--- /dev/null
+++ b/zephyr/test/drivers/bc12_pi3usb9201/src/pi3usb9201_interrupt.c
@@ -0,0 +1,119 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gpio_signal.h"
+#include "task.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+#include "usb_charge.h"
+
+#include <zephyr/device.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
+/* Get reference to externally linked handlers (defined in DTS) */
+#define USBC0_GPIO_PATH DT_PATH(named_gpios, usb_c0_bc12_int_l)
+#define USBC0_GPIO_DEV DEVICE_DT_GET(DT_GPIO_CTLR(USBC0_GPIO_PATH, gpios))
+#define USBC0_GPIO_PORT DT_GPIO_PIN(USBC0_GPIO_PATH, gpios)
+
+#define USBC1_GPIO_PATH DT_PATH(named_gpios, usb_c1_bc12_int_l)
+#define USBC1_GPIO_DEV DEVICE_DT_GET(DT_GPIO_CTLR(USBC1_GPIO_PATH, gpios))
+#define USBC1_GPIO_PORT DT_GPIO_PIN(USBC1_GPIO_PATH, gpios)
+
+static void toggle_gpio(const struct device *dev, gpio_pin_t pin)
+{
+ static const int values[] = { 1, 0, 1 };
+
+ for (int i = 0; i < ARRAY_SIZE(values); ++i) {
+ gpio_emul_input_set(dev, pin, values[i]);
+ }
+}
+
+FAKE_VOID_FUNC(usb_charger_task_event, int, uint32_t);
+
+struct pi3usb9201_fixture {
+ const struct bc12_drv *drv[2];
+ struct bc12_drv mock_drv;
+};
+
+static void *setup(void)
+{
+ static struct pi3usb9201_fixture fixture;
+
+ fixture.mock_drv.usb_charger_task_event = usb_charger_task_event;
+
+ return &fixture;
+}
+
+static void before(void *f)
+{
+ struct pi3usb9201_fixture *fixture = f;
+
+ fixture->drv[0] = bc12_ports[0].drv;
+ fixture->drv[1] = bc12_ports[1].drv;
+
+ RESET_FAKE(usb_charger_task_event);
+ test_set_chipset_to_s0();
+}
+
+static void after(void *f)
+{
+ struct pi3usb9201_fixture *fixture = f;
+
+ bc12_ports[0].drv = fixture->drv[0];
+ bc12_ports[1].drv = fixture->drv[1];
+}
+
+ZTEST_SUITE(pi3usb9201, drivers_predicate_post_main, setup, before, after,
+ NULL);
+
+ZTEST_F(pi3usb9201, test_usb0_evt)
+{
+ /* Set up the driver to use the mock */
+ bc12_ports[0].drv = &fixture->mock_drv;
+
+ /* Trigger the event and verify that port0 was added to the task event
+ * bitmap
+ */
+ toggle_gpio(USBC0_GPIO_DEV, USBC0_GPIO_PORT);
+ zassert_true(*task_get_event_bitmap(TASK_ID_USB_CHG) & BIT(0));
+
+ /* Give the task a bit of time to process the events */
+ task_wake(TASK_ID_USB_CHG);
+ k_msleep(500);
+
+ /* Ensure that the callback was made (it should be the first, but others
+ * may exist).
+ */
+ zassert_true(usb_charger_task_event_fake.call_count > 0);
+ zassert_equal(0, usb_charger_task_event_fake.arg0_history[0]);
+ zassert_equal(USB_CHG_EVENT_BC12,
+ usb_charger_task_event_fake.arg1_history[0]);
+}
+
+ZTEST_F(pi3usb9201, test_usb1_evt)
+{
+ /* Set up the driver to use the mock */
+ bc12_ports[1].drv = &fixture->mock_drv;
+
+ /* Trigger the event and verify that port1 was added to the task event
+ * bitmap
+ */
+ toggle_gpio(USBC1_GPIO_DEV, USBC1_GPIO_PORT);
+ zassert_true(*task_get_event_bitmap(TASK_ID_USB_CHG) & BIT(1));
+
+ /* Give the task a bit of time to process the events */
+ task_wake(TASK_ID_USB_CHG);
+ k_msleep(500);
+
+ /* Ensure that the callback was made (it should be the first, but others
+ * may exist).
+ */
+ zassert_true(usb_charger_task_event_fake.call_count > 0);
+ zassert_equal(1, usb_charger_task_event_fake.arg0_history[0]);
+ zassert_equal(USB_CHG_EVENT_BC12,
+ usb_charger_task_event_fake.arg1_history[0]);
+}
diff --git a/zephyr/test/drivers/boards/native_posix.overlay b/zephyr/test/drivers/boards/native_posix.overlay
index 6a304261cc..1f92686c33 100644
--- a/zephyr/test/drivers/boards/native_posix.overlay
+++ b/zephyr/test/drivers/boards/native_posix.overlay
@@ -8,6 +8,7 @@
#include <cros/thermistor/thermistor.dtsi>
#include <dt-bindings/gpio_defines.h>
#include <dt-bindings/pwm/pwm.h>
+#include <dt-bindings/wake_mask_event_defines.h>
#include <freq.h>
/ {
@@ -26,7 +27,9 @@
bmi160-int = &ms_bmi160_accel;
tcs3400-int = &tcs3400_clear;
gpio-wp = &gpio_wp_l;
+ gpio-cbi-wp = &gpio_ec_cbi_wp;
gpio-kbd-kso2 = &gpio_ec_kso_02_inv;
+ int-wp = &int_wp_l;
};
ec-console {
@@ -34,6 +37,27 @@
disabled = "events", "lpc", "hostcmd";
};
+ ec-mkbp-host-event-wakeup-mask {
+ compatible = "ec-wake-mask-event";
+ wakeup-mask = <(
+ HOST_EVENT_LID_OPEN |
+ HOST_EVENT_POWER_BUTTON |
+ HOST_EVENT_AC_CONNECTED |
+ HOST_EVENT_AC_DISCONNECTED |
+ HOST_EVENT_HANG_DETECT |
+ HOST_EVENT_RTC |
+ HOST_EVENT_MODE_CHANGE |
+ HOST_EVENT_DEVICE |
+ HOST_EVENT_KEYBOARD_RECOVERY)>;
+ };
+
+ ec-mkbp-event-wakeup-mask {
+ compatible = "ec-wake-mask-event";
+ wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | \
+ MKBP_EVENT_HOST_EVENT | \
+ MKBP_EVENT_SENSOR_FIFO)>;
+ };
+
usbc {
#address-cells = <1>;
#size-cells = <0>;
@@ -41,16 +65,41 @@
port0@0 {
compatible = "named-usbc-port";
reg = <0>;
+ bc12 = <&pi3usb9201_emul0>;
chg = <&isl923x_emul>;
tcpc = <&tcpci_emul>;
ppc = <&sn5s330_emul>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&tcpci_mux_c0
+ &virtual_mux_c0>;
+ };
+ };
+ port0-muxes {
+ tcpci_mux_c0: tcpci-mux-c0 {
+ compatible = "cros-ec,usbc-mux-tcpci";
+ };
+ virtual_mux_c0: virtual-mux-c0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
};
port1@1 {
compatible = "named-usbc-port";
reg = <1>;
+ bc12 = <&pi3usb9201_emul1>;
tcpc = <&ps8xxx_emul>;
ppc = <&syv682x_emul>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&usb_c1_bb_retimer_emul
+ &virtual_mux_c1>;
+ };
+ };
+ port1-muxes {
+ virtual_mux_c1: virtual-mux-c1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
};
};
@@ -171,6 +220,7 @@
};
gpio_test: test {
gpios = <&gpio0 27 (GPIO_INPUT | GPIO_OUTPUT)>;
+ enum-name = "GPIO_TEST";
};
ec_batt_pres_odl {
gpios = <&gpio0 28 GPIO_INPUT>;
@@ -181,20 +231,16 @@
no-auto-init;
};
gpio_ec_chg_led_y_c0: ec_chg_led_y_c0 {
- #led-pin-cells = <1>;
gpios = <&gpio0 30 (GPIO_INPUT | GPIO_OUTPUT_LOW)>;
};
gpio_ec_chg_led_w_c0: ec_chg_led_w_c0 {
- #led-pin-cells = <1>;
gpios = <&gpio0 31 (GPIO_INPUT | GPIO_OUTPUT_LOW)>;
};
/* gpio1 */
gpio_ec_chg_led_y_c1: ec_chg_led_y_c1 {
- #led-pin-cells = <1>;
gpios = <&gpio1 0 (GPIO_INPUT | GPIO_OUTPUT_LOW)>;
};
gpio_ec_chg_led_w_c1: ec_chg_led_w_c1 {
- #led-pin-cells = <1>;
gpios = <&gpio1 1 (GPIO_INPUT | GPIO_OUTPUT_LOW)>;
};
gpio_ap_ec_int_l: ap_ec_int_l {
@@ -222,6 +268,15 @@
gpio_brd_id0: brd_id0 {
gpios = <&gpio1 8 GPIO_INPUT>;
};
+ gpio_ec_cbi_wp: ec_cbi_wp {
+ gpios = <&gpio1 9 GPIO_OUTPUT>;
+ };
+ gpio_usb_c0_bc12_int_l: usb_c0_bc12_int_l {
+ gpios = <&gpio1 10 GPIO_INPUT>;
+ };
+ gpio_usb_c1_bc12_int_l: usb_c1_bc12_int_l {
+ gpios = <&gpio1 11 GPIO_INPUT>;
+ };
};
gpio1: gpio@101 {
@@ -234,7 +289,7 @@
low-level;
gpio-controller;
#gpio-cells = <2>;
- ngpios = <9>;
+ ngpios = <12>;
};
gpio-interrupts {
@@ -285,6 +340,21 @@
flags = <GPIO_INT_EDGE_BOTH>;
handler = "power_signal_interrupt";
};
+ int_wp_l: wp_l {
+ irq-pin = <&gpio_wp_l>;
+ flags = <GPIO_INT_EDGE_BOTH>;
+ handler = "switch_interrupt";
+ };
+ int_usb_c0_bc12: usb_c0_bc12 {
+ irq-pin = <&gpio_usb_c0_bc12_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb0_evt";
+ };
+ int_usb_c1_bc12: usb_c1_bc12 {
+ irq-pin = <&gpio_usb_c1_bc12_int_l>;
+ flags = <GPIO_INT_EDGE_FALLING>;
+ handler = "usb1_evt";
+ };
};
named-i2c-ports {
@@ -319,21 +389,34 @@
default_battery: lgc_ac17a8m {
compatible = "lgc,ac17a8m", "battery-smart";
};
+ ap16l5j {
+ compatible = "panasonic,ap16l5j", "battery-smart";
+ ship_mode_wb_support = <1>;
+ sleep_mode_support = <1>;
+ fet_mfgacc_support = <1>;
+ };
+ ap16l8j {
+ compatible = "lgc,ap16l8j", "battery-smart";
+ ship_mode_wb_support = <1>;
+ sleep_mode_support = <1>;
+ fet_cfet_mask = <0>;
+ fet_mfgacc_support = <1>;
+ };
};
cbi-ssfc {
- compatible = "named-cbi-ssfc";
+ compatible = "cros-ec,cbi-ssfc";
cbi_ssfc_base_sensor: base_sensor {
enum-name = "BASE_SENSOR";
size = <2>;
base_sensor_0: base0 {
- compatible = "named-cbi-ssfc-value";
+ compatible = "cros-ec,cbi-ssfc-value";
status = "okay";
value = <1>;
default;
};
base_sensor_1: base1 {
- compatible = "named-cbi-ssfc-value";
+ compatible = "cros-ec,cbi-ssfc-value";
status = "okay";
value = <2>;
};
@@ -473,6 +556,11 @@
power-good-pin = <&gpio_ec_pg_pin_temp>;
sensor = <&temp_fan>;
};
+ named_pct2075: soc {
+ status = "okay";
+ power-good-pin = <&gpio_ec_pg_pin_temp>;
+ sensor = <&pct2075_emul>;
+ };
};
/*
@@ -727,7 +815,7 @@
reg = <0x400 4>;
tcs_emul: tcs@39 {
- compatible = "zephyr,tcs3400";
+ compatible = "zephyr,tcs3400-emul";
reg = <0x39>;
error-on-ro-write;
error-on-reserved-bit-write;
@@ -735,7 +823,7 @@
};
accel_bmi160: bmi160@68 {
- compatible = "zephyr,bmi";
+ compatible = "zephyr,bmi-emul";
reg = <0x68>;
device-model = "BMI_EMUL_160";
error-on-ro-write;
@@ -753,9 +841,10 @@
#size-cells = <0>;
reg = <0x500 4>;
- pi3usb9201_emul: pi3usb9201@5f {
- compatible = "zephyr,pi3usb9201-emul";
+ pi3usb9201_emul0: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
reg = <0x5f>;
+ irq = <&int_usb_c0_bc12>;
};
sn5s330_emul: sn5s330@40 {
@@ -780,6 +869,12 @@
#size-cells = <0>;
reg = <0x600 4>;
+ pi3usb9201_emul1: pi3usb9201@5d {
+ compatible = "pericom,pi3usb9201";
+ reg = <0x5d>;
+ irq = <&int_usb_c1_bc12>;
+ };
+
syv682x_emul: syv682x@41 {
compatible = "zephyr,syv682x-emul";
reg = <0x41>;
@@ -788,11 +883,10 @@
};
usb_c1_bb_retimer_emul: bbretimer@42 {
- compatible = "cros,bb-retimer-emul";
+ compatible = "intel,jhl8040r";
reg = <0x42>;
- vendor = "BB_RETIMER_VENDOR_ID_1";
- error-on-ro-write;
- error-on-reserved-bit-write;
+ reset-pin = <&usb_c1_rt_rst_odl>;
+ ls-en-pin = <&usb_c1_ls_en>;
};
ps8xxx_emul: ps8xxx_emul@b {
@@ -803,6 +897,11 @@
p1-i2c-addr = <0x9>;
gpio-i2c-addr = <0x1a>;
};
+
+ pct2075_emul: pct2075@48 {
+ compatible = "nxp,pct2075";
+ reg = <0x48>;
+ };
};
clock: clock {
@@ -871,22 +970,18 @@
};
pwmleds {
- compatible = "cros-ec,pwm-pin-config";
+ compatible = "pwm-leds";
pwmled_blue_left: pwmled_b_left {
- #led-pin-cells = <1>;
pwms = <&pwm_blue_left 0 1000000 PWM_POLARITY_NORMAL>;
};
pwmled_white_left: pwmled_w_left {
- #led-pin-cells = <1>;
pwms = <&pwm_white_left 0 1000000 PWM_POLARITY_NORMAL>;
};
pwmled_amber_right: pwmled_y_right {
- #led-pin-cells = <1>;
pwms = <&pwm_amber_right 0 1000000 PWM_POLARITY_NORMAL>;
};
pwmled_white_right: pwmled_w_right {
- #led-pin-cells = <1>;
pwms = <&pwm_white_right 0 1000000 PWM_POLARITY_NORMAL>;
};
};
@@ -897,42 +992,42 @@
color-off-left {
led-color = "LED_OFF";
led-id = "EC_LED_ID_LEFT_LED";
- led-pins = <&pwmled_blue_left 0>,
- <&pwmled_white_left 0>;
+ led-pwms = <&pwmled_blue_left &pwmled_white_left>;
+ led-values = <0 0>;
};
color-off-right {
led-color = "LED_OFF";
led-id = "EC_LED_ID_RIGHT_LED";
- led-pins = <&pwmled_amber_right 0>,
- <&pwmled_white_right 0>;
+ led-pwms = <&pwmled_amber_right &pwmled_white_right>;
+ led-values = <0 0>;
};
color-blue-left {
led-color = "LED_BLUE";
led-id = "EC_LED_ID_LEFT_LED";
br-color = "EC_LED_COLOR_BLUE";
- led-pins = <&pwmled_blue_left 100>,
- <&pwmled_white_left 0>;
+ led-pwms = <&pwmled_blue_left &pwmled_white_left>;
+ led-values = <100 0>;
};
color-amber-right {
led-color = "LED_AMBER";
led-id = "EC_LED_ID_RIGHT_LED";
br-color = "EC_LED_COLOR_AMBER";
- led-pins = <&pwmled_amber_right 100>,
- <&pwmled_white_right 0>;
+ led-pwms = <&pwmled_amber_right &pwmled_white_right>;
+ led-values = <100 0>;
};
color-white-left {
led-color = "LED_WHITE";
led-id = "EC_LED_ID_LEFT_LED";
br-color = "EC_LED_COLOR_WHITE";
- led-pins = <&pwmled_blue_left 0>,
- <&pwmled_white_left 100>;
+ led-pwms = <&pwmled_blue_left &pwmled_white_left>;
+ led-values = <0 100>;
};
color-white-right {
led-color = "LED_WHITE";
led-id = "EC_LED_ID_RIGHT_LED";
br-color = "EC_LED_COLOR_WHITE";
- led-pins = <&pwmled_amber_right 0>,
- <&pwmled_white_right 100>;
+ led-pwms = <&pwmled_amber_right &pwmled_white_right>;
+ led-values = <0 100>;
};
};
@@ -956,7 +1051,7 @@
reg = <0x55556666 0x1000>;
status = "okay";
buffer-size = <200>;
- };
+ };
};
@@ -983,7 +1078,7 @@
};
battery: sb@b {
- compatible = "zephyr,smart-battery";
+ compatible = "zephyr,smart-battery-emul";
reg = <0xb>;
cycle-count = <99>;
version = "BATTERY_SPEC_VER_1_1_WITH_PEC";
@@ -994,8 +1089,20 @@
dev-name = "AC17A8M";
};
+ battery2: sb@3a {
+ compatible = "zephyr,smart-battery-emul";
+ reg = <0x3a>;
+ cycle-count = <99>;
+ version = "BATTERY_SPEC_VER_1_1_WITH_PEC";
+ /* Real battery voltages are multiples of 4.4V. */
+ desired-charg-volt = <5000>;
+ desired-charg-cur = <1000>;
+ mf-name = "PANASONIC";
+ dev-name = "AP16L5J";
+ };
+
bma_emul: bma@18 {
- compatible = "zephyr,bma255";
+ compatible = "zephyr,bma255-emul";
reg = <0x18>;
error-on-compensation-not-ready;
error-on-ro-write;
@@ -1004,7 +1111,7 @@
};
accel_bmi260: bmi260@68 {
- compatible = "zephyr,bmi";
+ compatible = "zephyr,bmi-emul";
reg = <0x68>;
device-model = "BMI_EMUL_260";
error-on-ro-write;
diff --git a/zephyr/test/drivers/button/src/main.c b/zephyr/test/drivers/button/src/main.c
index c26a62dfa1..08874d8032 100644
--- a/zephyr/test/drivers/button/src/main.c
+++ b/zephyr/test/drivers/button/src/main.c
@@ -3,11 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/fff.h>
-#include <zephyr/kernel.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "button.h"
#include "console.h"
#include "hooks.h"
@@ -16,6 +11,11 @@
#include "test/drivers/test_state.h"
#include "timer.h"
+#include <zephyr/fff.h>
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
/*
* TODO (b/b/253284635) Timeouts here don't quite align with the button press
* duration. This is caused by an issue with the Zephyr scheduling for delayed
diff --git a/zephyr/test/drivers/chargesplash/src/chargesplash.c b/zephyr/test/drivers/chargesplash/src/chargesplash.c
index 9e5bf17019..27b3678bd8 100644
--- a/zephyr/test/drivers/chargesplash/src/chargesplash.c
+++ b/zephyr/test/drivers/chargesplash/src/chargesplash.c
@@ -3,14 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <stdbool.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/shell/shell_uart.h>
-#include <zephyr/sys/__assert.h>
-#include <zephyr/ztest.h>
-
#include "chipset.h"
#include "config.h"
#include "ec_commands.h"
@@ -18,9 +10,18 @@
#include "hooks.h"
#include "host_command.h"
#include "lid_switch.h"
-#include "timer.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include "timer.h"
+
+#include <stdbool.h>
+
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/shell/shell_uart.h>
+#include <zephyr/sys/__assert.h>
+#include <zephyr/ztest.h>
/* Do a chargesplash host cmd */
static enum ec_status
@@ -85,7 +86,7 @@ static void set_lid(bool open, bool inhibit_boot)
"inhibit_boot should not be used with a lid close");
}
- zassume_ok(gpio_emul_input_set(lid_switch_dev, GPIO_LID_OPEN_EC_PORT,
+ zassert_ok(gpio_emul_input_set(lid_switch_dev, GPIO_LID_OPEN_EC_PORT,
open),
"Failed to set lid switch GPIO");
@@ -123,7 +124,7 @@ static void reset_state(void *unused)
set_ac_enabled(false);
}
- zassume_ok(shell_execute_cmd(get_ec_shell(), "chargesplash reset"),
+ zassert_ok(shell_execute_cmd(get_ec_shell(), "chargesplash reset"),
"'chargesplash reset' shell command failed");
}
diff --git a/zephyr/test/drivers/common/include/test/drivers/stubs.h b/zephyr/test/drivers/common/include/test/drivers/stubs.h
index 98f3fa1d15..63718649f8 100644
--- a/zephyr/test/drivers/common/include/test/drivers/stubs.h
+++ b/zephyr/test/drivers/common/include/test/drivers/stubs.h
@@ -6,14 +6,11 @@
#ifndef __TEST_DRIVERS_STUBS_H
#define __TEST_DRIVERS_STUBS_H
-#include <zephyr/fff.h>
#include "power.h"
-enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
+#include <zephyr/fff.h>
-/* Structure used by usb_mux test. It is part of usb_muxes chain. */
-extern struct usb_mux usbc1_virtual_usb_mux;
-extern struct usb_mux usbc0_mux0;
+enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
/**
* @brief Set product ID that should be returned by board_get_ps8xxx_product_id
diff --git a/zephyr/test/drivers/common/include/test/drivers/test_mocks.h b/zephyr/test/drivers/common/include/test/drivers/test_mocks.h
index 25217dfffe..6644de8d88 100644
--- a/zephyr/test/drivers/common/include/test/drivers/test_mocks.h
+++ b/zephyr/test/drivers/common/include/test/drivers/test_mocks.h
@@ -6,6 +6,8 @@
#ifndef __TEST_DRIVERS_TEST_MOCKS_H
#define __TEST_DRIVERS_TEST_MOCKS_H
+#include <stdint.h>
+
#include <zephyr/fff.h>
/*
@@ -116,4 +118,8 @@ DECLARE_FAKE_VOID_FUNC(assert_post_action, const char *, unsigned int);
/* Mocks for common/lid_angle.c */
DECLARE_FAKE_VOID_FUNC(lid_angle_peripheral_enable, int);
+/* Mocks for gpio.h */
+DECLARE_FAKE_VALUE_FUNC(int, gpio_config_unused_pins);
+DECLARE_FAKE_VALUE_FUNC(int, gpio_configure_port_pin, int, int, int);
+
#endif /* __TEST_DRIVERS_TEST_MOCKS_H */
diff --git a/zephyr/test/drivers/common/include/test/drivers/test_state.h b/zephyr/test/drivers/common/include/test/drivers/test_state.h
index 98cf4a283e..b4496c6af9 100644
--- a/zephyr/test/drivers/common/include/test/drivers/test_state.h
+++ b/zephyr/test/drivers/common/include/test/drivers/test_state.h
@@ -6,6 +6,8 @@
#ifndef ZEPHYR_TEST_DRIVERS_INCLUDE_TEST_STATE_H_
#define ZEPHYR_TEST_DRIVERS_INCLUDE_TEST_STATE_H_
+#include <stdbool.h>
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/zephyr/test/drivers/common/include/test/drivers/utils.h b/zephyr/test/drivers/common/include/test/drivers/utils.h
index 8a703108c3..7be7dd5400 100644
--- a/zephyr/test/drivers/common/include/test/drivers/utils.h
+++ b/zephyr/test/drivers/common/include/test/drivers/utils.h
@@ -6,20 +6,21 @@
#ifndef ZEPHYR_TEST_DRIVERS_INCLUDE_UTILS_H_
#define ZEPHYR_TEST_DRIVERS_INCLUDE_UTILS_H_
-#include <zephyr/drivers/emul.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/ztest.h>
-#include <stddef.h>
-#include <string.h>
-
#include "charger.h"
-#include "lpc.h"
#include "emul/tcpc/emul_tcpci_partner_src.h"
#include "extpower.h"
#include "host_command.h"
+#include "lpc.h"
#include "power.h"
#include "usbc/utils.h"
+#include <stddef.h>
+#include <string.h>
+
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/ztest.h>
+
/**
* @brief Helper macro for EMUL_GET_USBC_BINDING. If @p usbc_id has the same
* port number as @p port, then struct emul* for @p chip phandle is
@@ -71,21 +72,11 @@ void test_set_chipset_to_power_level(enum power_state new_state);
/** @brief Set chipset to G3 state. Call all necessary hooks. */
void test_set_chipset_to_g3(void);
-/*
- * TODO(b/217755888): Implement ztest assume API upstream
- */
-
-/**
- * @brief Assume that this function call won't be reached
- * @param msg Optional message to print if the assumption fails
- */
-#define zassume_unreachable(msg, ...) zassert_unreachable(msg, ##__VA_ARGS__)
-
/**
* Run an ACPI read to the specified address.
*
* This function assumes a successful ACPI read process and will make a
- * call to the zassume_* API. A failure here will skip the calling test.
+ * call to the zassert_* API. A failure here will fail the calling test.
*
* @param acpi_addr Address to query
* @return Byte read
@@ -96,7 +87,7 @@ uint8_t acpi_read(uint8_t acpi_addr);
* Run an ACPI write to the specified address.
*
* This function assumes a successful ACPI write process and will make a
- * call to the zassume_* API. A failure here will skip the calling test.
+ * call to the zassert_* API. A failure here will fail the calling test.
*
* @param acpi_addr Address to write
* @param write_byte Byte to write to address
@@ -107,7 +98,7 @@ void acpi_write(uint8_t acpi_addr, uint8_t write_byte);
* Run the host command to gather our EC feature flags.
*
* This function assumes a successful host command processing and will make a
- * call to the zassume_* API. A failure here will abort the calling test.
+ * call to the zassert_* API. A failure here will fail the calling test.
*
* @return The result of the host command
*/
@@ -117,7 +108,7 @@ static inline struct ec_response_get_features host_cmd_get_features(void)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND_RESPONSE(EC_CMD_GET_FEATURES, 0, response);
- zassume_ok(host_command_process(&args), "Failed to get features");
+ zassert_ok(host_command_process(&args), "Failed to get features");
return response;
}
@@ -125,7 +116,7 @@ static inline struct ec_response_get_features host_cmd_get_features(void)
* Run the host command to get the charge state for a given charger number.
*
* This function assumes a successful host command processing and will make a
- * call to the zassume_* API. A failure here will abort the calling test.
+ * call to the zassert_* API. A failure here will fail the calling test.
*
* @param chgnum The charger number to query.
* @return The result of the query.
@@ -140,7 +131,7 @@ static inline struct ec_response_charge_state host_cmd_charge_state(int chgnum)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND(EC_CMD_CHARGE_STATE, 0, response, params);
- zassume_ok(host_command_process(&args),
+ zassert_ok(host_command_process(&args),
"Failed to get charge state for chgnum %d", chgnum);
return response;
}
@@ -149,7 +140,7 @@ static inline struct ec_response_charge_state host_cmd_charge_state(int chgnum)
* Run the host command to get the USB PD power info for a given port.
*
* This function assumes a successful host command processing and will make a
- * call to the zassume_* API. A failure here will abort the calling test.
+ * call to the zassert_* API. A failure here will fail the calling test.
*
* @param port The USB port to get info from.
* @return The result of the query.
@@ -161,7 +152,7 @@ static inline struct ec_response_usb_pd_power_info host_cmd_power_info(int port)
struct host_cmd_handler_args args = BUILD_HOST_COMMAND(
EC_CMD_USB_PD_POWER_INFO, 0, response, params);
- zassume_ok(host_command_process(&args),
+ zassert_ok(host_command_process(&args),
"Failed to get power info for port %d", port);
return response;
}
@@ -170,7 +161,7 @@ static inline struct ec_response_usb_pd_power_info host_cmd_power_info(int port)
* Run the host command to get the Type-C status information for a given port.
*
* This function assumes a successful host command processing and will make a
- * call to the zassume_* API. A failure here will abort the calling test.
+ * call to the zassert_* API. A failure here will fail the calling test.
*
* @param port The USB port to get info from.
* @return The result of the query.
@@ -182,7 +173,7 @@ static inline struct ec_response_typec_status host_cmd_typec_status(int port)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND(EC_CMD_TYPEC_STATUS, 0, response, params);
- zassume_ok(host_command_process(&args),
+ zassert_ok(host_command_process(&args),
"Failed to get Type-C state for port %d", port);
return response;
}
@@ -195,7 +186,7 @@ host_cmd_usb_pd_control(int port, enum usb_pd_control_swap swap)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND(EC_CMD_USB_PD_CONTROL, 0, response, params);
- zassume_ok(host_command_process(&args),
+ zassert_ok(host_command_process(&args),
"Failed to process usb_pd_control_swap for port %d, swap %d",
port, swap);
return response;
@@ -205,7 +196,7 @@ host_cmd_usb_pd_control(int port, enum usb_pd_control_swap swap)
* Run the host command to suspend/resume PD ports
*
* This function assumes a successful host command processing and will make a
- * call to the zassume_* API. A failure here will skip the calling test.
+ * call to the zassert_* API. A failure here will fail the calling test.
*
* @param port The USB port to operate on
* @param cmd The sub-command to run
@@ -216,7 +207,7 @@ static inline void host_cmd_pd_control(int port, enum ec_pd_control_cmd cmd)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params);
- zassume_ok(host_command_process(&args),
+ zassert_ok(host_command_process(&args),
"Failed to process pd_control for port %d, cmd %d", port,
cmd);
}
@@ -240,7 +231,7 @@ host_cmd_charge_control(enum ec_charge_control_mode mode,
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND(EC_CMD_CHARGE_CONTROL, 2, response, params);
- zassume_ok(host_command_process(&args),
+ zassert_ok(host_command_process(&args),
"Failed to get charge control values");
return response;
@@ -260,7 +251,7 @@ enum ec_status host_cmd_host_event(enum ec_host_event_action action,
/**
* @brief Call the host command MOTION_SENSE with the dump sub-command
*
- * Note: this function uses the zassume_ API. It will skip the test if the host
+ * Note: this function uses the zassert_ API. It will fail the test if the host
* command fails.
*
* @param max_sensor_count The maximum number of sensor data objects to populate
@@ -549,6 +540,15 @@ void host_cmd_typec_control_clear_events(int port, uint32_t events);
*/
void host_cmd_typec_control_bist_share_mode(int port, int enable);
+/**
+ * Run the host command to control PD port behavior, with the sub-command of
+ * TYPEC_CONTROL_COMMAND_SEND_VDM_REQ
+ *
+ * @param port The USB-C port number
+ * @param vdm_req VDM request data
+ */
+void host_cmd_typec_control_vdm_req(int port, struct typec_vdm_req vdm_req);
+
struct host_events_ctx {
host_event_t lpc_host_events;
host_event_t lpc_host_event_mask[LPC_HOST_EVENT_COUNT];
@@ -580,7 +580,7 @@ void host_events_restore(struct host_events_ctx *host_events_ctx);
* If enabled, the device _should_ begin charging.
*
* This function assumes a successful gpio emulator call and will make a call
- * to the zassume_* API. A failure here will abort the calling test.
+ * to the zassert_* API. A failure here will fail the calling test.
*
* This function sleeps to wait for the GPIO interrupt to take place.
*
@@ -591,10 +591,14 @@ static inline void set_ac_enabled(bool enabled)
const struct device *acok_dev =
DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_ACOK_OD_NODE, gpios));
- zassume_ok(gpio_emul_input_set(acok_dev, GPIO_ACOK_OD_PIN, enabled),
+ zassert_ok(gpio_emul_input_set(acok_dev, GPIO_ACOK_OD_PIN, enabled),
NULL);
- k_sleep(K_MSEC(CONFIG_EXTPOWER_DEBOUNCE_MS + 1));
- zassume_equal(enabled, extpower_is_present(), NULL);
+ /*
+ * b/253284635 - Sleep for a full second past the debounce time
+ * to ensure the power button debounce logic runs.
+ */
+ k_sleep(K_MSEC(CONFIG_EXTPOWER_DEBOUNCE_MS + 1000));
+ zassert_equal(enabled, extpower_is_present(), NULL);
}
/**
diff --git a/zephyr/test/drivers/common/src/main.c b/zephyr/test/drivers/common/src/main.c
index 1c8497ab3f..dab681b936 100644
--- a/zephyr/test/drivers/common/src/main.c
+++ b/zephyr/test/drivers/common/src/main.c
@@ -3,12 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
#include "ec_app_main.h"
#include "hooks.h"
#include "test/drivers/test_state.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
/**
* @brief Semaphore that signals when hooks have completed
*/
diff --git a/zephyr/test/drivers/common/src/stubs.c b/zephyr/test/drivers/common/src/stubs.c
index d07683017f..69993d8a89 100644
--- a/zephyr/test/drivers/common/src/stubs.c
+++ b/zephyr/test/drivers/common/src/stubs.c
@@ -7,11 +7,11 @@
#include "battery_fuel_gauge.h"
#include "bc12/pi3usb9201_public.h"
#include "charge_ramp.h"
+#include "charge_state_v2.h"
#include "charger.h"
#include "charger/isl923x_public.h"
#include "charger/isl9241_public.h"
#include "config.h"
-#include <zephyr/fff.h>
#include "gpio/gpio_int.h"
#include "hooks.h"
#include "i2c/i2c.h"
@@ -19,14 +19,14 @@
#include "ppc/sn5s330_public.h"
#include "ppc/syv682x_public.h"
#include "retimer/bb_retimer_public.h"
-#include "test/drivers/stubs.h"
#include "tcpm/ps8xxx_public.h"
#include "tcpm/tcpci.h"
+#include "test/drivers/stubs.h"
#include "usb_mux.h"
#include "usb_pd_tcpm.h"
#include "usbc_ppc.h"
-#include "charge_state_v2.h"
+#include <zephyr/fff.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(stubs);
@@ -40,19 +40,6 @@ LOG_MODULE_REGISTER(stubs);
* device tree.
*/
-/* BC1.2 charger detect configuration */
-const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = {
- [USBC_PORT_C0] = {
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
- },
- [USBC_PORT_C1] = {
- .i2c_port = I2C_PORT_USB_C1,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_1_FLAGS,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(pi3usb9201_bc12_chips) == USBC_PORT_COUNT);
-
int board_set_active_charge_port(int port)
{
int is_real_port = (port >= 0 && port < CONFIG_USB_PD_PORT_MAX_COUNT);
@@ -111,13 +98,6 @@ int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state)
return 0;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
- charge_set_input_current_limit(
- MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv);
-}
-
BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT);
static uint16_t ps8xxx_product_id = PS8805_PRODUCT_ID;
@@ -148,68 +128,6 @@ int board_is_sourcing_vbus(int port)
return ppc_is_sourcing_vbus(port);
}
-/* TODO(b/239457738): Move to dts */
-struct usb_mux_chain usbc0_virtual_usb_mux_chain = {
- .mux =
- &(const struct usb_mux){
- .usb_port = USBC_PORT_C0,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
- },
-};
-
-struct usb_mux usbc1_virtual_usb_mux = {
- .usb_port = USBC_PORT_C1,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
-};
-
-struct usb_mux_chain usbc1_virtual_usb_mux_chain = {
- .mux = &usbc1_virtual_usb_mux,
-};
-
-struct usb_mux usbc0_mux0 = {
- .usb_port = USBC_PORT_C0,
- .driver = &tcpci_tcpm_usb_mux_driver,
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = DT_REG_ADDR(DT_NODELABEL(tcpci_emul)),
-};
-
-struct usb_mux_chain usb_muxes[] = {
- [USBC_PORT_C0] = {
- .mux = &usbc0_mux0,
- .next = &usbc0_virtual_usb_mux_chain,
- },
- [USBC_PORT_C1] = {
-#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB
- .mux = &(const struct usb_mux){
- .usb_port = USBC_PORT_C1,
- .driver = &bb_usb_retimer,
- .hpd_update = bb_retimer_hpd_update,
- .i2c_port = I2C_PORT_USB_C1,
- .i2c_addr_flags = DT_REG_ADDR(DT_NODELABEL(
- usb_c1_bb_retimer_emul)),
- },
- .next = &usbc1_virtual_usb_mux_chain,
-#endif
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
-
-#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB
-struct bb_usb_control bb_controls[] = {
- [USBC_PORT_C0] = {
- /* USB-C port 0 doesn't have a retimer */
- },
- [USBC_PORT_C1] = {
- .usb_ls_en_gpio = GPIO_SIGNAL(DT_NODELABEL(usb_c1_ls_en)),
- .retimer_rst_gpio =
- GPIO_SIGNAL(DT_NODELABEL(usb_c1_rt_rst_odl)),
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(bb_controls) == USBC_PORT_COUNT);
-#endif
-
void pd_power_supply_reset(int port)
{
}
diff --git a/zephyr/test/drivers/common/src/test_mocks.c b/zephyr/test/drivers/common/src/test_mocks.c
index ab6c65313d..21cd4c0c1b 100644
--- a/zephyr/test/drivers/common/src/test_mocks.c
+++ b/zephyr/test/drivers/common/src/test_mocks.c
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "test/drivers/test_mocks.h"
+#include <zephyr/ztest.h>
+
/* Mocks for common/init_rom.c */
DEFINE_FAKE_VALUE_FUNC(const void *, init_rom_map, const void *, int);
DEFINE_FAKE_VOID_FUNC(init_rom_unmap, const void *, int);
@@ -22,6 +22,10 @@ DEFINE_FAKE_VOID_FUNC(assert_post_action, const char *, unsigned int);
/* Mocks for common/lid_angle.c */
DEFINE_FAKE_VOID_FUNC(lid_angle_peripheral_enable, int);
+/* Mocks for gpio.h */
+DEFINE_FAKE_VALUE_FUNC(int, gpio_config_unused_pins);
+DEFINE_FAKE_VALUE_FUNC(int, gpio_configure_port_pin, int, int, int);
+
/**
* @brief Reset all the fakes before each test.
*/
@@ -40,6 +44,8 @@ static void fff_reset_rule_before(const struct ztest_unit_test *test,
RESET_FAKE(software_panic);
RESET_FAKE(assert_post_action);
RESET_FAKE(lid_angle_peripheral_enable);
+ RESET_FAKE(gpio_config_unused_pins);
+ RESET_FAKE(gpio_configure_port_pin);
}
ZTEST_RULE(fff_reset_rule, fff_reset_rule_before, NULL);
diff --git a/zephyr/test/drivers/common/src/test_rules.c b/zephyr/test/drivers/common/src/test_rules.c
index e1b1d59480..42195b25d7 100644
--- a/zephyr/test/drivers/common/src/test_rules.c
+++ b/zephyr/test/drivers/common/src/test_rules.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "emul/tcpc/emul_tcpci.h"
#include "motion_sense_fifo.h"
#include "test/drivers/stubs.h"
#include "test/drivers/utils.h"
#include "usb_pd_tcpm.h"
+#include <zephyr/ztest.h>
+
static void motion_sense_fifo_reset_before(const struct ztest_unit_test *test,
void *data)
{
diff --git a/zephyr/test/drivers/common/src/utils.c b/zephyr/test/drivers/common/src/utils.c
index 719a3fe589..afea5edbac 100644
--- a/zephyr/test/drivers/common/src/utils.c
+++ b/zephyr/test/drivers/common/src/utils.c
@@ -3,38 +3,34 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/shell/shell_dummy.h> /* nocheck */
-#include <zephyr/shell/shell_uart.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "acpi.h"
#include "battery.h"
#include "battery_smart.h"
#include "charge_state.h"
#include "chipset.h"
-#include "lpc.h"
#include "emul/emul_isl923x.h"
#include "emul/emul_smart_battery.h"
#include "emul/emul_stub_device.h"
#include "emul/tcpc/emul_tcpci_partner_src.h"
#include "hooks.h"
+#include "lpc.h"
#include "power.h"
#include "task.h"
#include "tcpm/tcpci.h"
#include "test/drivers/stubs.h"
#include "test/drivers/utils.h"
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/shell/shell_uart.h>
+#include <zephyr/ztest.h>
+
#define BATTERY_NODE DT_NODELABEL(battery)
#define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl)
#define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios)
-/*
- * TODO(b/251281997): Switch zasserts back to zassumes when they loudly fail
- */
-
void test_set_battery_level(int percentage)
{
struct sbat_emul_bat_data *bat;
@@ -592,7 +588,21 @@ void host_cmd_typec_control_bist_share_mode(int port, int enable)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
- zassume_ok(host_command_process(&args),
+ zassert_ok(host_command_process(&args),
+ "Failed to send Type-C control for port %d", port);
+}
+
+void host_cmd_typec_control_vdm_req(int port, struct typec_vdm_req vdm_req)
+{
+ struct ec_params_typec_control params = {
+ .port = port,
+ .command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
+ .vdm_req_params = vdm_req,
+ };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND_PARAMS(EC_CMD_TYPEC_CONTROL, 0, params);
+
+ zassert_ok(host_command_process(&args),
"Failed to send Type-C control for port %d", port);
}
diff --git a/zephyr/test/drivers/common_cbi/src/test_common_cbi.c b/zephyr/test/drivers/common_cbi/src/test_common_cbi.c
index f8348b6770..bf8da93a9e 100644
--- a/zephyr/test/drivers/common_cbi/src/test_common_cbi.c
+++ b/zephyr/test/drivers/common_cbi/src/test_common_cbi.c
@@ -3,13 +3,67 @@
* found in the LICENSE file.
*/
-#include "host_command.h"
-#include <zephyr/ztest.h>
-
#include "cros_board_info.h"
+#include "host_command.h"
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include <zephyr/drivers/eeprom.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/ztest.h>
+
+#define WP_L_GPIO_PATH DT_PATH(named_gpios, wp_l)
+#define CBI_EEPROM_DEV DEVICE_DT_GET(DT_NODELABEL(cbi_eeprom))
+
+FAKE_VALUE_FUNC(int, eeprom_load, uint8_t, uint8_t *, int);
+
+static int gpio_wp_l_set(int value)
+{
+ const struct device *wp_l_gpio_dev =
+ DEVICE_DT_GET(DT_GPIO_CTLR(WP_L_GPIO_PATH, gpios));
+
+ return gpio_emul_input_set(wp_l_gpio_dev,
+ DT_GPIO_PIN(WP_L_GPIO_PATH, gpios), value);
+}
+
+static int __test_eeprom_load_default_impl(uint8_t offset, uint8_t *data,
+ int len)
+{
+ int ret = eeprom_read(CBI_EEPROM_DEV, offset, data, len);
+
+ return ret;
+}
+
+ZTEST(common_cbi, test_cbi_latch_eeprom_wp)
+{
+ const struct gpio_dt_spec *wp = GPIO_DT_FROM_ALIAS(gpio_cbi_wp);
+
+ zassert_equal(gpio_emul_output_get(wp->port, wp->pin), 0);
+
+ cbi_latch_eeprom_wp();
+
+ zassert_equal(gpio_emul_output_get(wp->port, wp->pin), 1);
+}
+
+ZTEST(common_cbi, test_do_cbi_read__cant_load_head)
+{
+ enum cbi_data_tag arbitrary_unused_tag = CBI_TAG_SKU_ID;
+ uint8_t arbitrary_unused_byte_buffer[100];
+ uint8_t unused_data_size;
+
+ /* Force a do_cbi_read() to eeprom */
+ cbi_invalidate_cache();
+
+ /* Return arbitrary nonzero value */
+ eeprom_load_fake.return_val = 1;
+ eeprom_load_fake.custom_fake = NULL;
+
+ zassert_equal(cbi_get_board_info(arbitrary_unused_tag,
+ arbitrary_unused_byte_buffer,
+ &unused_data_size),
+ EC_ERROR_UNKNOWN);
+}
+
ZTEST(common_cbi, test_cbi_set_string__null_str)
{
struct cbi_data data = { 0 };
@@ -26,19 +80,160 @@ ZTEST(common_cbi, test_cbi_set_string__null_str)
ZTEST(common_cbi, test_cbi_set_string)
{
- struct cbi_data data = { 0 };
+ const char arbitrary_str[] = "hello cbi";
enum cbi_data_tag arbitrary_valid_tag = CBI_TAG_SKU_ID;
- const char *arbitrary_str = "hello cbi";
+ struct cbi_data_wrapper {
+ struct cbi_data data;
+ uint8_t value_arr[ARRAY_SIZE(arbitrary_str)];
+ };
+ struct cbi_data_wrapper cbi_data = { 0 };
+
+ /* Set some provided memory then check values */
uint8_t *addr_byte_after_store = cbi_set_string(
- (uint8_t *)&data, arbitrary_valid_tag, arbitrary_str);
+ (uint8_t *)&cbi_data, arbitrary_valid_tag, arbitrary_str);
- zassert_equal(data.tag, arbitrary_valid_tag);
- zassert_equal(data.size, strlen(arbitrary_str) + 1);
- zassert_mem_equal(data.value, arbitrary_str, data.size);
- zassert_equal(addr_byte_after_store -
- (strlen(arbitrary_str) + 1 + sizeof(data)),
- (uint8_t *)&data);
+ zassert_equal(cbi_data.data.tag, arbitrary_valid_tag);
+ zassert_equal(cbi_data.data.size, ARRAY_SIZE(arbitrary_str));
+ zassert_mem_equal(cbi_data.data.value, arbitrary_str,
+ cbi_data.data.size);
+
+ uint32_t expected_added_memory =
+ (ARRAY_SIZE(arbitrary_str) + sizeof(cbi_data.data));
+
+ /* Validate that next address for write was set appropriately */
+ zassert_equal_ptr(addr_byte_after_store - expected_added_memory,
+ &cbi_data.data);
+}
+
+ZTEST_USER(common_cbi, test_hc_cbi_set_then_get)
+{
+ const uint8_t data[] = "I love test coverage! <3";
+
+ struct actual_set_params {
+ struct ec_params_set_cbi params;
+ uint8_t actual_data[ARRAY_SIZE(data)];
+ };
+
+ struct actual_set_params hc_set_params = {
+ .params = {
+ .tag = CBI_TAG_SKU_ID,
+ /* Force a reload */
+ .flag = CBI_SET_INIT,
+ .size = ARRAY_SIZE(data),
+ },
+ };
+ struct host_cmd_handler_args set_args = BUILD_HOST_COMMAND_PARAMS(
+ EC_CMD_SET_CROS_BOARD_INFO, 0, hc_set_params);
+
+ memcpy(hc_set_params.params.data, data, ARRAY_SIZE(data));
+
+ /* Turn off write-protect so we can actually write */
+ gpio_wp_l_set(1);
+
+ zassert_ok(host_command_process(&set_args));
+
+ /* Now verify our write by invoking a get host command */
+
+ struct ec_params_get_cbi hc_get_params = {
+ .flag = CBI_GET_RELOAD,
+ .tag = hc_set_params.params.tag,
+ };
+
+ struct test_ec_params_get_cbi_response {
+ uint8_t data[ARRAY_SIZE(data)];
+ };
+ struct test_ec_params_get_cbi_response hc_get_response;
+ struct host_cmd_handler_args get_args = BUILD_HOST_COMMAND(
+ EC_CMD_GET_CROS_BOARD_INFO, 0, hc_get_response, hc_get_params);
+
+ zassert_ok(host_command_process(&get_args));
+ zassert_mem_equal(hc_get_response.data, hc_set_params.actual_data,
+ hc_set_params.params.size);
+}
+
+ZTEST_USER(common_cbi, test_hc_cbi_set__bad_size)
+{
+ const char data[] = "hello";
+
+ struct actual_set_params {
+ struct ec_params_set_cbi params;
+ /* We want less data than we need for our size */
+ uint8_t actual_data[0];
+ };
+ struct actual_set_params hc_set_params = {
+ .params = {
+ .tag = CBI_TAG_SKU_ID,
+ /* Force a reload */
+ .flag = CBI_SET_INIT,
+ .size = ARRAY_SIZE(data),
+ },
+ };
+ struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
+ EC_CMD_SET_CROS_BOARD_INFO, 0, hc_set_params);
+
+ zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM);
+}
+
+ZTEST_USER(common_cbi, test_hc_cbi_set_then_get__with_too_small_response)
+{
+ const uint8_t data[] = "I'm way too big of a payload for you!";
+
+ struct actual_set_params {
+ struct ec_params_set_cbi params;
+ uint8_t actual_data[ARRAY_SIZE(data)];
+ };
+
+ struct actual_set_params hc_set_params = {
+ .params = {
+ .tag = CBI_TAG_SKU_ID,
+ /* Force a reload */
+ .flag = CBI_SET_INIT,
+ .size = ARRAY_SIZE(data),
+ },
+ };
+ struct host_cmd_handler_args set_args = BUILD_HOST_COMMAND_PARAMS(
+ EC_CMD_SET_CROS_BOARD_INFO, 0, hc_set_params);
+
+ memcpy(hc_set_params.params.data, data, ARRAY_SIZE(data));
+
+ /* Turn off write-protect so we can actually write */
+ gpio_wp_l_set(1);
+
+ zassert_ok(host_command_process(&set_args));
+
+ /* Now verify our write by invoking a get host command */
+
+ struct ec_params_get_cbi hc_get_params = {
+ .flag = CBI_GET_RELOAD,
+ .tag = hc_set_params.params.tag,
+ };
+
+ struct test_ec_params_get_cbi_response {
+ /*
+ * Want want less space than we need to retrieve cbi data, by
+ * allocating an array of size zero, we're implicitly setting
+ * the response_max value of the host command to be zero. So the
+ * host command will fail because it the EC knows it doesn't
+ * have enough response space to actually fetch the data for the
+ * host.
+ */
+ uint8_t data[0];
+ };
+ struct test_ec_params_get_cbi_response hc_get_response;
+ struct host_cmd_handler_args get_args = BUILD_HOST_COMMAND(
+ EC_CMD_GET_CROS_BOARD_INFO, 0, hc_get_response, hc_get_params);
+
+ zassert_equal(host_command_process(&get_args), EC_RES_INVALID_PARAM);
+}
+
+static void test_common_cbi_before_after(void *test_data)
+{
+ RESET_FAKE(eeprom_load);
+ eeprom_load_fake.custom_fake = __test_eeprom_load_default_impl;
+
+ cbi_create();
}
-ZTEST_SUITE(common_cbi, drivers_predicate_post_main, NULL, NULL, NULL, NULL);
+ZTEST_SUITE(common_cbi, drivers_predicate_post_main, NULL,
+ test_common_cbi_before_after, test_common_cbi_before_after, NULL);
diff --git a/zephyr/test/drivers/common_cbi_gpio/src/test_common_cbi_gpio.c b/zephyr/test/drivers/common_cbi_gpio/src/test_common_cbi_gpio.c
index 4af62a3d8b..8e8e4f6a8b 100644
--- a/zephyr/test/drivers/common_cbi_gpio/src/test_common_cbi_gpio.c
+++ b/zephyr/test/drivers/common_cbi_gpio/src/test_common_cbi_gpio.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "cros_board_info.h"
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
FAKE_VALUE_FUNC(int, system_get_board_version);
FAKE_VALUE_FUNC(int, cbi_set_board_info, enum cbi_data_tag, const uint8_t *,
uint8_t);
diff --git a/zephyr/test/drivers/common_charger/CMakeLists.txt b/zephyr/test/drivers/common_charger/CMakeLists.txt
index aeb77d3577..63da1783f1 100644
--- a/zephyr/test/drivers/common_charger/CMakeLists.txt
+++ b/zephyr/test/drivers/common_charger/CMakeLists.txt
@@ -3,4 +3,9 @@
# found in the LICENSE file.
# Add source files
-target_sources(app PRIVATE src/test_common_charger.c)
+target_sources(app
+ PRIVATE
+ src/test_charge_state_v2.c
+ src/test_common_charger.c
+ src/test_common_charger_mocked.c
+)
diff --git a/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c b/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c
new file mode 100644
index 0000000000..9dfeb5e734
--- /dev/null
+++ b/zephyr/test/drivers/common_charger/src/test_charge_state_v2.c
@@ -0,0 +1,129 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "charge_state_v2.h"
+#include "math_util.h"
+#include "test/drivers/test_state.h"
+
+#include <zephyr/ztest.h>
+
+int battery_outside_charging_temperature(void);
+
+struct charge_state_v2_fixture {
+ struct charge_state_data charge_state_data;
+};
+
+static void *setup(void)
+{
+ static struct charge_state_v2_fixture fixture;
+
+ return &fixture;
+}
+
+static void before(void *f)
+{
+ struct charge_state_v2_fixture *fixture = f;
+
+ fixture->charge_state_data = *charge_get_status();
+}
+
+static void after(void *f)
+{
+ struct charge_state_v2_fixture *fixture = f;
+
+ *charge_get_status() = fixture->charge_state_data;
+}
+
+ZTEST_SUITE(charge_state_v2, drivers_predicate_post_main, setup, before, after,
+ NULL);
+
+ZTEST(charge_state_v2, test_battery_flag_bad_temperature)
+{
+ struct charge_state_data *curr = charge_get_status();
+
+ curr->batt.flags |= BATT_FLAG_BAD_TEMPERATURE;
+ zassert_ok(battery_outside_charging_temperature());
+}
+
+ZTEST(charge_state_v2, test_battery_temperature_range)
+{
+ struct charge_state_data *curr = charge_get_status();
+ const struct battery_info *batt_info = battery_get_info();
+
+ curr->batt.flags &= ~BATT_FLAG_BAD_TEMPERATURE;
+
+ /* Start off without a desired voltage/current */
+ curr->batt.desired_voltage = 0;
+ curr->batt.desired_current = 0;
+
+ /* Temperature is too high */
+ curr->batt.temperature =
+ CELSIUS_TO_DECI_KELVIN(batt_info->start_charging_max_c + 1);
+ zassert_equal(1, battery_outside_charging_temperature());
+
+ /* Temperature is too low */
+ curr->batt.temperature =
+ CELSIUS_TO_DECI_KELVIN(batt_info->start_charging_min_c - 1);
+ zassert_equal(1, battery_outside_charging_temperature());
+
+ /* Temperature is just right */
+ curr->batt.temperature =
+ CELSIUS_TO_DECI_KELVIN((batt_info->start_charging_max_c +
+ batt_info->start_charging_min_c) /
+ 2);
+ zassert_ok(battery_outside_charging_temperature());
+
+ /* Set an arbitrary desired current */
+ curr->batt.desired_current = 3;
+
+ /* Temperature is too high */
+ curr->batt.temperature =
+ CELSIUS_TO_DECI_KELVIN(batt_info->charging_max_c + 1);
+ zassert_equal(1, battery_outside_charging_temperature());
+
+ /* Set an arbitrary desired voltage */
+ curr->batt.desired_voltage = 5;
+
+ /* Temperature is too low */
+ curr->batt.temperature =
+ CELSIUS_TO_DECI_KELVIN(batt_info->charging_min_c - 1);
+ zassert_equal(1, battery_outside_charging_temperature());
+
+ /* Temperature is just right */
+ curr->batt.temperature = CELSIUS_TO_DECI_KELVIN(
+ (batt_info->charging_max_c + batt_info->charging_min_c) / 2);
+ zassert_ok(battery_outside_charging_temperature());
+}
+
+ZTEST(charge_state_v2, test_current_limit_derating)
+{
+ int charger_current_limit;
+
+ charge_set_input_current_limit(1000, 5000);
+ zassert_ok(charger_get_input_current_limit(0, &charger_current_limit));
+ /*
+ * ISL923x sets ICL in multiples of 20 mA, so 950 mA gets rounded down
+ * to the nearest multiple of 20.
+ */
+ zassert_equal(
+ charger_current_limit, 944,
+ "%d%% derating of 1A should be 944 mA, but charger is set for %d mA",
+ CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT,
+ charger_current_limit);
+}
+
+ZTEST(charge_state_v2, test_minimum_current_limit)
+{
+ int charger_current_limit;
+
+ charge_set_input_current_limit(50, 5000);
+ zassert_ok(charger_get_input_current_limit(0, &charger_current_limit));
+ zassert_equal(charger_current_limit, 96,
+ "Minimum input current limit should be %d mA,"
+ " but current limit is %d (capped to %d)",
+ 96, charger_current_limit,
+ CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT);
+}
diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger.c b/zephyr/test/drivers/common_charger/src/test_common_charger.c
index ca9469c032..46403636d6 100644
--- a/zephyr/test/drivers/common_charger/src/test_common_charger.c
+++ b/zephyr/test/drivers/common_charger/src/test_common_charger.c
@@ -3,10 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/ztest_assert.h>
-
#include "charge_ramp.h"
#include "driver/charger/isl923x_public.h"
#include "ec_commands.h"
@@ -15,6 +11,10 @@
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+#include <zephyr/ztest_assert.h>
+
/* Tested wrt isl923x without RAA489000 */
/* Only single charger-chip configured for the drivers overlay */
@@ -50,7 +50,7 @@ ZTEST(common_charger, test_chg_ramp_is_detected)
ZTEST(common_charger, test_chg_ramp_get_current_limit)
{
zassert_equal(chg_ramp_get_current_limit(),
- CONFIG_CHARGER_INPUT_CURRENT);
+ CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT);
}
ZTEST(common_charger, test_charger_get_min_bat_pct_for_power_on)
diff --git a/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c
new file mode 100644
index 0000000000..c353b7b6c5
--- /dev/null
+++ b/zephyr/test/drivers/common_charger/src/test_common_charger_mocked.c
@@ -0,0 +1,598 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_ramp.h"
+#include "charger.h"
+#include "test/drivers/charger_utils.h"
+#include "test/drivers/test_state.h"
+
+#include <string.h>
+
+#include <zephyr/fff.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+#include <zephyr/ztest_assert.h>
+
+/* This test suite only works if the chg_chips array is not const. */
+BUILD_ASSERT(IS_ENABLED(CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG),
+ "chg_chips array cannot be const.");
+
+/** Index of the charger chip we are overriding / working with. */
+#define CHG_NUM (0)
+
+/* FFF fakes for driver functions. These get assigned to members of the
+ * charger_drv struct
+ */
+FAKE_VALUE_FUNC(enum ec_error_list, enable_otg_power, int, int);
+FAKE_VALUE_FUNC(enum ec_error_list, set_otg_current_voltage, int, int, int);
+FAKE_VALUE_FUNC(int, is_sourcing_otg_power, int, int);
+FAKE_VALUE_FUNC(enum ec_error_list, get_actual_current, int, int *);
+FAKE_VALUE_FUNC(enum ec_error_list, get_actual_voltage, int, int *);
+FAKE_VALUE_FUNC(enum ec_error_list, set_voltage, int, int);
+FAKE_VALUE_FUNC(enum ec_error_list, get_vsys_voltage, int, int, int *);
+FAKE_VALUE_FUNC(enum ec_error_list, enable_bypass_mode, int, bool);
+FAKE_VALUE_FUNC(enum ec_error_list, set_vsys_compensation, int,
+ struct ocpc_data *, int, int);
+FAKE_VALUE_FUNC(enum ec_error_list, is_icl_reached, int, bool *);
+FAKE_VALUE_FUNC(enum ec_error_list, enable_linear_charge, int, bool);
+FAKE_VALUE_FUNC(enum ec_error_list, get_battery_cells, int, int *);
+
+/**
+ * @brief If non-NULL, board_get_charger_chip_count returns the value this
+ * pointer points to.
+ */
+static uint8_t *fake_charger_count;
+
+/**
+ * @brief Override of definition from common/charger.c. Allows adjusting the
+ * number of chargers. This is not an FFF mock because FFF mock return values
+ * default to 0 until the test code gets a change to update it, which can cause
+ * a race condition as the EC initializes. This function has the correct
+ * count as soon as the program starts, which is CHARGER_NUM chargers.
+ *
+ * @return uint8_t Number of charger chips
+ */
+uint8_t board_get_charger_chip_count(void)
+{
+ if (fake_charger_count) {
+ return *fake_charger_count;
+ }
+
+ /* Default value */
+ return CHARGER_NUM;
+}
+
+struct common_charger_mocked_driver_fixture {
+ /* The original driver pointer that gets restored after the tests */
+ const struct charger_drv *saved_driver_ptr;
+ /* Mock driver that gets substituted */
+ struct charger_drv mock_driver;
+};
+
+ZTEST(common_charger_mocked_driver, test_charger_enable_otg_power__invalid)
+{
+ /* charger number out of bounds */
+ zassert_equal(EC_ERROR_INVAL, charger_enable_otg_power(-1, 0));
+ zassert_equal(EC_ERROR_INVAL, charger_enable_otg_power(INT_MAX, 0));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_enable_otg_power__unimpl)
+{
+ /* enable_otg_power is NULL */
+ zassert_equal(EC_ERROR_UNIMPLEMENTED,
+ charger_enable_otg_power(CHG_NUM, 1));
+}
+
+ZTEST_F(common_charger_mocked_driver, test_charger_enable_otg_power)
+{
+ fixture->mock_driver.enable_otg_power = enable_otg_power;
+ enable_otg_power_fake.return_val = 123;
+
+ zassert_equal(enable_otg_power_fake.return_val,
+ charger_enable_otg_power(CHG_NUM, 1));
+
+ zassert_equal(1, enable_otg_power_fake.call_count);
+ zassert_equal(CHG_NUM, enable_otg_power_fake.arg0_history[0]);
+ zassert_equal(1, enable_otg_power_fake.arg1_history[0]);
+}
+
+ZTEST(common_charger_mocked_driver,
+ test_charger_set_otg_current_voltage__invalid)
+{
+ /* charger number out of bounds */
+ zassert_equal(EC_ERROR_INVAL,
+ charger_set_otg_current_voltage(-1, 0, 0));
+ zassert_equal(EC_ERROR_INVAL,
+ charger_set_otg_current_voltage(INT_MAX, 0, 0));
+}
+
+ZTEST(common_charger_mocked_driver,
+ test_charger_set_otg_current_voltage__unimpl)
+{
+ /* set_otg_current_voltage is NULL */
+ zassert_equal(EC_ERROR_UNIMPLEMENTED,
+ charger_set_otg_current_voltage(CHG_NUM, 0, 0));
+}
+
+ZTEST_F(common_charger_mocked_driver, test_charger_set_otg_current_voltage)
+{
+ fixture->mock_driver.set_otg_current_voltage = set_otg_current_voltage;
+ set_otg_current_voltage_fake.return_val = 123;
+
+ zassert_equal(set_otg_current_voltage_fake.return_val,
+ charger_set_otg_current_voltage(CHG_NUM, 10, 20));
+
+ zassert_equal(1, set_otg_current_voltage_fake.call_count);
+ zassert_equal(CHG_NUM, set_otg_current_voltage_fake.arg0_history[0]);
+ zassert_equal(10, set_otg_current_voltage_fake.arg1_history[0]);
+ zassert_equal(20, set_otg_current_voltage_fake.arg2_history[0]);
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_is_sourcing_otg_power__invalid)
+{
+ /* is_sourcing_otg_power is NULL */
+ zassert_equal(0, charger_is_sourcing_otg_power(0));
+}
+
+ZTEST_F(common_charger_mocked_driver, test_charger_is_sourcing_otg_power)
+{
+ fixture->mock_driver.is_sourcing_otg_power = is_sourcing_otg_power;
+ is_sourcing_otg_power_fake.return_val = 123;
+
+ zassert_equal(is_sourcing_otg_power_fake.return_val,
+ charger_is_sourcing_otg_power(0));
+
+ zassert_equal(1, is_sourcing_otg_power_fake.call_count);
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_actual_current__invalid)
+{
+ /* charger number out of bounds */
+ zassert_equal(EC_ERROR_INVAL, charger_get_actual_current(-1, NULL));
+ zassert_equal(EC_ERROR_INVAL,
+ charger_get_actual_current(INT_MAX, NULL));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_actual_current__unimpl)
+{
+ /* get_actual_current is NULL */
+ zassert_equal(EC_ERROR_UNIMPLEMENTED,
+ charger_get_actual_current(CHG_NUM, NULL));
+}
+
+/**
+ * @brief Custom fake for get_actual_current that can write to the output param
+ */
+static enum ec_error_list get_actual_current_custom_fake(int chgnum,
+ int *current)
+{
+ ARG_UNUSED(chgnum);
+
+ *current = 1000;
+
+ return EC_SUCCESS;
+}
+
+ZTEST_F(common_charger_mocked_driver, test_charger_get_actual_current)
+{
+ int current;
+
+ fixture->mock_driver.get_actual_current = get_actual_current;
+ get_actual_current_fake.custom_fake = get_actual_current_custom_fake;
+
+ zassert_equal(EC_SUCCESS,
+ charger_get_actual_current(CHG_NUM, &current));
+
+ zassert_equal(1, get_actual_current_fake.call_count);
+ zassert_equal(CHG_NUM, get_actual_current_fake.arg0_history[0]);
+ zassert_equal(1000, current);
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_actual_voltage__invalid)
+{
+ /* charger number out of bounds */
+ zassert_equal(EC_ERROR_INVAL, charger_get_actual_voltage(-1, NULL));
+ zassert_equal(EC_ERROR_INVAL,
+ charger_get_actual_voltage(INT_MAX, NULL));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_actual_voltage__unimpl)
+{
+ /* get_actual_voltage is NULL */
+ zassert_equal(EC_ERROR_UNIMPLEMENTED,
+ charger_get_actual_voltage(CHG_NUM, NULL));
+}
+
+/**
+ * @brief Custom fake for get_actual_voltage that can write to the output param
+ */
+static enum ec_error_list get_actual_voltage_custom_fake(int chgnum,
+ int *voltage)
+{
+ ARG_UNUSED(chgnum);
+
+ *voltage = 2000;
+
+ return EC_SUCCESS;
+}
+
+ZTEST_F(common_charger_mocked_driver, test_charger_get_actual_voltage)
+{
+ int voltage;
+
+ fixture->mock_driver.get_actual_voltage = get_actual_voltage;
+ get_actual_voltage_fake.custom_fake = get_actual_voltage_custom_fake;
+
+ zassert_equal(EC_SUCCESS,
+ charger_get_actual_voltage(CHG_NUM, &voltage));
+
+ zassert_equal(1, get_actual_voltage_fake.call_count);
+ zassert_equal(CHG_NUM, get_actual_voltage_fake.arg0_history[0]);
+ zassert_equal(2000, voltage);
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_set_voltage__invalid)
+{
+ /* charger number out of bounds */
+ zassert_equal(EC_ERROR_INVAL, charger_set_voltage(-1, 0));
+ zassert_equal(EC_ERROR_INVAL, charger_set_voltage(INT_MAX, 0));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_set_voltage__unimpl)
+{
+ /* set_voltage is NULL */
+ zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_set_voltage(CHG_NUM, 0));
+}
+
+ZTEST_F(common_charger_mocked_driver, test_charger_set_voltage)
+{
+ fixture->mock_driver.set_voltage = set_voltage;
+ set_voltage_fake.return_val = 123;
+
+ zassert_equal(set_voltage_fake.return_val,
+ charger_set_voltage(CHG_NUM, 2000));
+
+ zassert_equal(1, set_voltage_fake.call_count);
+ zassert_equal(CHG_NUM, set_voltage_fake.arg0_history[0]);
+ zassert_equal(2000, set_voltage_fake.arg1_history[0]);
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_vsys_voltage__invalid)
+{
+ /* Cannot do chgnum bounds checking because
+ * charger_get_valid_chgnum() will convert chgnum to 0 unless
+ * CONFIG_CHARGER_SINGLE_CHIP is turned off.
+ */
+
+ /* get_vsys_voltage is NULL */
+ zassert_equal(EC_ERROR_UNIMPLEMENTED,
+ charger_get_vsys_voltage(CHG_NUM, NULL));
+}
+
+/**
+ * @brief Custom fake for get_vsys_voltage that can write to the output param
+ */
+static enum ec_error_list get_vsys_voltage_custom_fake(int chgnum, int port,
+ int *voltage)
+{
+ ARG_UNUSED(chgnum);
+ ARG_UNUSED(port);
+
+ *voltage = 2000;
+
+ return EC_SUCCESS;
+}
+
+ZTEST_F(common_charger_mocked_driver, test_charger_get_vsys_voltage)
+{
+ int vsys_voltage;
+
+ fixture->mock_driver.get_vsys_voltage = get_vsys_voltage;
+ get_vsys_voltage_fake.custom_fake = get_vsys_voltage_custom_fake;
+
+ zassert_equal(EC_SUCCESS,
+ charger_get_vsys_voltage(CHG_NUM, &vsys_voltage));
+
+ zassert_equal(1, get_vsys_voltage_fake.call_count);
+ zassert_equal(CHG_NUM, get_vsys_voltage_fake.arg0_history[0]);
+ zassert_equal(CHG_NUM, get_vsys_voltage_fake.arg1_history[0]);
+ zassert_equal(2000, vsys_voltage);
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_enable_bypass_mode__invalid)
+{
+ /* enable_bypass_mode is NULL */
+ zassert_equal(EC_ERROR_UNIMPLEMENTED,
+ charger_enable_bypass_mode(CHG_NUM, false));
+}
+
+ZTEST_F(common_charger_mocked_driver, test_charger_enable_bypass_mode)
+{
+ fixture->mock_driver.enable_bypass_mode = enable_bypass_mode;
+ enable_bypass_mode_fake.return_val = 123;
+
+ zassert_equal(123, charger_enable_bypass_mode(CHG_NUM, true));
+
+ zassert_equal(1, enable_bypass_mode_fake.call_count);
+ zassert_true(enable_bypass_mode_fake.arg1_history[0]);
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_params__error_flags)
+{
+ /* When one of the parameters cannot be retrieved, a corresponding flag
+ * is set. Since all of the driver functions are unimplemented by
+ * default, this should cause all error flags to be set.
+ */
+
+ struct charger_params params;
+
+ charger_get_params(&params);
+
+ zassert_true(params.flags & CHG_FLAG_BAD_CURRENT);
+ zassert_true(params.flags & CHG_FLAG_BAD_VOLTAGE);
+ zassert_true(params.flags & CHG_FLAG_BAD_INPUT_CURRENT);
+ zassert_true(params.flags & CHG_FLAG_BAD_STATUS);
+ zassert_true(params.flags & CHG_FLAG_BAD_OPTION);
+}
+
+ZTEST(common_charger_mocked_driver,
+ test_charger_get_input_current_limit__invalid)
+{
+ zassert_equal(EC_ERROR_INVAL,
+ charger_get_input_current_limit(-1, false));
+ zassert_equal(EC_ERROR_INVAL,
+ charger_get_input_current_limit(INT_MAX, false));
+}
+
+ZTEST(common_charger_mocked_driver,
+ test_charger_get_input_current_limit__unimpl)
+{
+ zassert_equal(EC_ERROR_UNIMPLEMENTED,
+ charger_get_input_current_limit(CHG_NUM, false));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_input_current__invalid)
+{
+ zassert_equal(EC_ERROR_INVAL, charger_get_input_current(-1, NULL));
+ zassert_equal(EC_ERROR_INVAL, charger_get_input_current(INT_MAX, NULL));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_input_current__unimpl)
+{
+ zassert_equal(EC_ERROR_UNIMPLEMENTED,
+ charger_get_input_current(CHG_NUM, NULL));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_manufacturer_id__invalid)
+{
+ uint8_t zero = 0;
+
+ fake_charger_count = &zero;
+ zassert_equal(EC_ERROR_INVAL, charger_manufacturer_id(NULL));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_manufacturer_id__unimpl)
+{
+ zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_manufacturer_id(NULL));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_device_id__invalid)
+{
+ uint8_t zero = 0;
+
+ fake_charger_count = &zero;
+ zassert_equal(EC_ERROR_INVAL, charger_device_id(NULL));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_device_id__unimpl)
+{
+ zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_device_id(NULL));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_option__invalid)
+{
+ uint8_t zero = 0;
+
+ fake_charger_count = &zero;
+ zassert_equal(EC_ERROR_INVAL, charger_get_option(NULL));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_option__unimpl)
+{
+ zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_get_option(NULL));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_set_option__invalid)
+{
+ uint8_t zero = 0;
+
+ fake_charger_count = &zero;
+ zassert_equal(EC_ERROR_INVAL, charger_set_option(0));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_set_option__unimpl)
+{
+ zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_set_option(0));
+}
+
+ZTEST(common_charger_mocked_driver, test_chg_ramp_is_stable__invalid)
+{
+ uint8_t zero = 0;
+
+ fake_charger_count = &zero;
+ zassert_false(chg_ramp_is_stable());
+}
+
+ZTEST(common_charger_mocked_driver, test_chg_ramp_is_stable__unimpl)
+{
+ /* Returns 0 if ramp_is_stable not implemented */
+ zassert_false(chg_ramp_is_stable());
+}
+
+ZTEST(common_charger_mocked_driver, test_chg_ramp_is_detected__invalid)
+{
+ uint8_t zero = 0;
+
+ fake_charger_count = &zero;
+ zassert_false(chg_ramp_is_detected());
+}
+
+ZTEST(common_charger_mocked_driver, test_chg_ramp_is_detected__unimpl)
+{
+ /* Returns 0 if ramp_is_detected not implemented */
+ zassert_false(chg_ramp_is_detected());
+}
+
+ZTEST(common_charger_mocked_driver, test_chg_ramp_get_current_limit__invalid)
+{
+ uint8_t zero = 0;
+
+ fake_charger_count = &zero;
+ zassert_false(chg_ramp_get_current_limit());
+}
+
+ZTEST(common_charger_mocked_driver, test_chg_ramp_get_current_limit__unimpl)
+{
+ /* Returns 0 if ramp_get_current_limit not implemented */
+ zassert_false(chg_ramp_get_current_limit());
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_post_init__invalid)
+{
+ uint8_t zero = 0;
+
+ fake_charger_count = &zero;
+ zassert_equal(EC_ERROR_INVAL, charger_post_init());
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_post_init__unimpl)
+{
+ zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_post_init());
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_info__invalid)
+{
+ uint8_t zero = 0;
+
+ fake_charger_count = &zero;
+ zassert_is_null(charger_get_info());
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_info__unimpl)
+{
+ zassert_is_null(charger_get_info());
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_get_status__invalid)
+{
+ uint8_t zero = 0;
+
+ fake_charger_count = &zero;
+ zassert_equal(EC_ERROR_INVAL, charger_get_status(NULL));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_set_mode__invalid)
+{
+ uint8_t zero = 0;
+
+ fake_charger_count = &zero;
+ zassert_equal(EC_ERROR_INVAL, charger_set_mode(0));
+}
+
+ZTEST(common_charger_mocked_driver, test_charger_set_mode__unimpl)
+{
+ zassert_equal(EC_ERROR_UNIMPLEMENTED, charger_set_mode(0));
+}
+
+ZTEST_F(common_charger_mocked_driver, test_charger_set_vsys_compensation)
+{
+ fixture->mock_driver.set_vsys_compensation = set_vsys_compensation;
+ set_vsys_compensation_fake.return_val = 123;
+
+ zassert_equal(123, charger_set_vsys_compensation(CHG_NUM, NULL, 0, 0));
+
+ zassert_equal(1, set_vsys_compensation_fake.call_count);
+}
+
+ZTEST_F(common_charger_mocked_driver, test_charger_is_icl_reached)
+{
+ fixture->mock_driver.is_icl_reached = is_icl_reached;
+ is_icl_reached_fake.return_val = 123;
+
+ zassert_equal(123, charger_is_icl_reached(CHG_NUM, NULL));
+
+ zassert_equal(1, is_icl_reached_fake.call_count);
+}
+
+ZTEST_F(common_charger_mocked_driver, test_charger_enable_linear_charge)
+{
+ fixture->mock_driver.enable_linear_charge = enable_linear_charge;
+ enable_linear_charge_fake.return_val = 123;
+
+ zassert_equal(123, charger_enable_linear_charge(CHG_NUM, 0));
+
+ zassert_equal(1, enable_linear_charge_fake.call_count);
+}
+
+ZTEST_F(common_charger_mocked_driver, test_charger_get_battery_cells)
+{
+ fixture->mock_driver.get_battery_cells = get_battery_cells;
+ get_battery_cells_fake.return_val = 123;
+
+ zassert_equal(123, charger_get_battery_cells(CHG_NUM, NULL));
+
+ zassert_equal(1, get_battery_cells_fake.call_count);
+}
+
+static void *setup(void)
+{
+ static struct common_charger_mocked_driver_fixture f;
+
+ zassert_true(board_get_charger_chip_count() > 0,
+ "Need at least one charger chip present.");
+
+ /* Back up the current charger driver and substitute our own */
+ f.saved_driver_ptr = chg_chips[CHG_NUM].drv;
+ chg_chips[CHG_NUM].drv = &f.mock_driver;
+
+ return &f;
+}
+
+static void reset(void *data)
+{
+ struct common_charger_mocked_driver_fixture *f = data;
+
+ /* Reset the mock driver's function pointer table. Each tests adds these
+ * as-needed
+ */
+ f->mock_driver = (struct charger_drv){ 0 };
+
+ /* Reset fakes */
+ RESET_FAKE(enable_otg_power);
+ RESET_FAKE(set_otg_current_voltage);
+ RESET_FAKE(is_sourcing_otg_power);
+ RESET_FAKE(get_actual_current);
+ RESET_FAKE(get_actual_voltage);
+ RESET_FAKE(set_voltage);
+ RESET_FAKE(get_vsys_voltage);
+ RESET_FAKE(enable_bypass_mode);
+ RESET_FAKE(set_vsys_compensation);
+ RESET_FAKE(is_icl_reached);
+ RESET_FAKE(enable_linear_charge);
+ RESET_FAKE(get_battery_cells);
+
+ fake_charger_count = NULL;
+}
+
+static void teardown(void *data)
+{
+ struct common_charger_mocked_driver_fixture *f = data;
+
+ /* Restore the original driver */
+ chg_chips[CHG_NUM].drv = f->saved_driver_ptr;
+}
+
+ZTEST_SUITE(common_charger_mocked_driver, drivers_predicate_post_main, setup,
+ reset, reset, teardown);
diff --git a/zephyr/test/drivers/console/src/shell.c b/zephyr/test/drivers/console/src/shell.c
index 7345ed2da8..c7a85b8f32 100644
--- a/zephyr/test/drivers/console/src/shell.c
+++ b/zephyr/test/drivers/console/src/shell.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
+#include "console.h"
+#include "test/drivers/test_state.h"
+#include "uart.h"
+
#include <zephyr/device.h>
#include <zephyr/drivers/uart.h>
#include <zephyr/shell/shell.h>
#include <zephyr/ztest.h>
-#include "console.h"
-#include "uart.h"
-#include "test/drivers/test_state.h"
-
void uart_callback(const struct device *dev, void *user_data);
void bypass_cb(const struct shell *shell, uint8_t *data, size_t len);
diff --git a/zephyr/test/drivers/default/CMakeLists.txt b/zephyr/test/drivers/default/CMakeLists.txt
index d3c488e8dd..07688db4f2 100644
--- a/zephyr/test/drivers/default/CMakeLists.txt
+++ b/zephyr/test/drivers/default/CMakeLists.txt
@@ -1,12 +1,12 @@
target_sources(app PRIVATE
src/battery.c
src/bb_retimer.c
- src/bc12.c
src/bma2x2.c
src/bmi_common.c
src/bmi160.c
src/bmi260.c
src/charge_manager.c
+ src/charge_state_prevent_power_on.c
src/console.c
src/console_cmd/adc.c
src/console_cmd/battery.c
@@ -36,11 +36,13 @@ target_sources(app PRIVATE
src/console_cmd/port80.c
src/console_cmd/powerindebug.c
src/console_cmd/power_button.c
+ src/console_cmd/pwr_avg.c
src/console_cmd/rtc.c
src/console_cmd/rw.c
src/console_cmd/shared_mem.c
src/console_cmd/sleepmask.c
src/console_cmd/sleeptimeout.c
+ src/console_cmd/switch.c
src/console_cmd/sysinfo.c
src/console_cmd/tcpci_dump.c
src/console_cmd/usb_pd_console.c
@@ -79,8 +81,10 @@ target_sources(app PRIVATE
src/smart.c
src/stm_mems_common.c
src/tablet_mode.c
+ src/task.c
src/tcpci.c
src/tcpci_test_common.c
+ src/tcpm_header.c
src/tcs3400.c
src/temp_sensor.c
src/thermistor.c
@@ -92,3 +96,7 @@ target_sources(app PRIVATE
src/vstore.c
src/watchdog.c
)
+
+# This test does not work when power functions are mocked, so only run it for
+# the plain `drivers.default` test case.
+zephyr_library_sources_ifndef(CONFIG_POWER_SEQUENCE_MOCK src/chipset.c)
diff --git a/zephyr/test/drivers/default/boards/native_posix.overlay b/zephyr/test/drivers/default/boards/native_posix.overlay
new file mode 100644
index 0000000000..a5e73e5653
--- /dev/null
+++ b/zephyr/test/drivers/default/boards/native_posix.overlay
@@ -0,0 +1,34 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "../../boards/native_posix.overlay"
+
+/*
+ * The TCPCI test verfies the mux behavior in two configurations:
+ * flags = USB_MUX_FLAG_NOT_TCPC;
+ * flags = 0;
+ *
+ * When USB_MUX_FLAG_NOT_TCPC is set, the TCPCI mux driver must initialize
+ * the I2C bus and address from the devicetree.
+ *
+ * The TCPCI mux doesn't have it's owm emulator and sends it's I2C transactions
+ * through the normal TCPCI driver, which then connects to the TCPCI emulator.
+ *
+ * Use 2 compaible strings here so that the same I2C device node gets setup for
+ * both the emulator and the TPCI mux.
+ */
+&tcpci_emul {
+ compatible = "cros,tcpci-generic-emul", "cros-ec,usbc-mux-tcpci";
+};
+
+/ {
+ usbc {
+ port0@0 {
+ usb-mux-chain-0 {
+ usb-muxes = <&tcpci_emul &virtual_mux_c0>;
+ };
+ };
+ };
+};
diff --git a/zephyr/test/drivers/default/prj.conf b/zephyr/test/drivers/default/prj.conf
index 9c112a6ced..c544afd4e7 100644
--- a/zephyr/test/drivers/default/prj.conf
+++ b/zephyr/test/drivers/default/prj.conf
@@ -9,5 +9,6 @@ CONFIG_PLATFORM_EC_LED_DT=y
CONFIG_PLATFORM_EC_RTC=y
CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
CONFIG_PLATFORM_EC_CONSOLE_CHANNEL=y
+CONFIG_TASK_HOSTCMD_THREAD_MAIN=y
CONFIG_SYSTEM_FAKE=y
diff --git a/zephyr/test/drivers/default/src/battery.c b/zephyr/test/drivers/default/src/battery.c
index 2e06725af5..02f85d9662 100644
--- a/zephyr/test/drivers/default/src/battery.c
+++ b/zephyr/test/drivers/default/src/battery.c
@@ -3,26 +3,78 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-
#include "battery.h"
+#include "battery_fuel_gauge.h"
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_smart_battery.h"
#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
#define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl)
#define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios)
+FAKE_VALUE_FUNC(int, battery2_write_func, const struct emul *, int, uint8_t,
+ int, void *);
+FAKE_VALUE_FUNC(int, battery2_read_func, const struct emul *, int, uint8_t *,
+ int, void *);
+
+bool authenticate_battery_type(int index, const char *manuf_name);
+
+extern int battery_fuel_gauge_type_override;
+
+struct battery_fixture {
+ struct i2c_common_emul_data *battery_i2c_common;
+ i2c_common_emul_finish_write_func finish_write_func;
+ i2c_common_emul_start_read_func start_read_func;
+};
+
+static void *battery_setup(void)
+{
+ static struct battery_fixture fixture;
+ static const struct emul *emul = EMUL_DT_GET(DT_NODELABEL(battery));
+
+ fixture.battery_i2c_common =
+ emul_smart_battery_get_i2c_common_data(emul);
+
+ return &fixture;
+}
+
+static void battery_before(void *data)
+{
+ struct battery_fixture *fixture = data;
+
+ RESET_FAKE(battery2_write_func);
+ RESET_FAKE(battery2_read_func);
+ fixture->finish_write_func = fixture->battery_i2c_common->finish_write;
+ fixture->start_read_func = fixture->battery_i2c_common->start_read;
+}
+
static void battery_after(void *data)
{
+ struct battery_fixture *fixture = data;
const struct device *dev =
DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios));
/* Set default state (battery is present) */
gpio_emul_input_set(dev, GPIO_BATT_PRES_ODL_PORT, 0);
+ battery_fuel_gauge_type_override = -1;
+
+ i2c_common_emul_set_write_func(fixture->battery_i2c_common, NULL, NULL);
+ i2c_common_emul_set_read_func(fixture->battery_i2c_common, NULL, NULL);
+ fixture->battery_i2c_common->finish_write = fixture->finish_write_func;
+ fixture->battery_i2c_common->start_read = fixture->start_read_func;
}
+ZTEST_SUITE(battery, drivers_predicate_post_main, battery_setup, battery_before,
+ battery_after, NULL);
+
ZTEST_USER(battery, test_battery_is_present_gpio)
{
const struct device *dev =
@@ -37,5 +89,172 @@ ZTEST_USER(battery, test_battery_is_present_gpio)
zassert_equal(BP_NO, battery_is_present());
}
-ZTEST_SUITE(battery, drivers_predicate_post_main, NULL, NULL, battery_after,
- NULL);
+ZTEST(battery, test_authenticate_battery_type)
+{
+ /* Invalid index */
+ zassert_false(authenticate_battery_type(BATTERY_TYPE_COUNT, NULL));
+ /* Use fuel-gauge 1's manufacturer name for index 0 */
+ zassert_false(authenticate_battery_type(
+ 0, board_battery_info[1].fuel_gauge.manuf_name));
+ /* Use the correct manufacturer name, but wrong device name (because the
+ * index is 1 and not 0)
+ */
+ zassert_false(authenticate_battery_type(
+ 1, board_battery_info[1].fuel_gauge.manuf_name));
+}
+
+ZTEST(battery, test_board_get_default_battery_type)
+{
+ zassert_equal(DEFAULT_BATTERY_TYPE, board_get_default_battery_type());
+}
+
+ZTEST_F(battery, test_board_cutoff_actuates_driver)
+{
+ /* We check the return type because board_is_cut_off() is set outside of
+ * board_cut_off_battery() and may be changed by other factors.
+ */
+
+ /* Try with invalid battery type */
+ battery_fuel_gauge_type_override = BATTERY_TYPE_COUNT;
+ zassert_equal(EC_RES_ERROR, board_cut_off_battery());
+
+ /* Setup error conditions for battery 1*/
+ battery_fuel_gauge_type_override = 1;
+ fixture->battery_i2c_common->finish_write = NULL;
+ i2c_common_emul_set_write_func(fixture->battery_i2c_common,
+ battery2_write_func, NULL);
+
+ /* Check that i2c error returns EC_RES_ERROR */
+ battery2_write_func_fake.return_val = -1;
+ zassert_equal(EC_RES_ERROR, board_cut_off_battery());
+
+ /* Check for OK when i2c succeeds */
+ battery2_write_func_fake.return_val = 0;
+ zassert_ok(board_cut_off_battery());
+}
+
+ZTEST_F(battery, test_sleep)
+{
+ /* Try with invalid battery type */
+ battery_fuel_gauge_type_override = BATTERY_TYPE_COUNT;
+ zassert_equal(EC_ERROR_UNKNOWN, battery_sleep_fuel_gauge());
+
+ /* Check 1st battery (lgc,ac17a8m) */
+ battery_fuel_gauge_type_override = 0;
+ zassert_equal(EC_ERROR_UNIMPLEMENTED, battery_sleep_fuel_gauge());
+
+ /* Check 2nd battery (panasonic,ap15l5j) */
+ battery_fuel_gauge_type_override = 1;
+ fixture->battery_i2c_common->finish_write = NULL;
+ i2c_common_emul_set_write_func(fixture->battery_i2c_common,
+ battery2_write_func, NULL);
+ zassert_ok(battery_sleep_fuel_gauge());
+}
+
+struct battery2_read_data {
+ size_t count;
+ const uint8_t *values;
+};
+
+static int battery2_read(const struct emul *target, int reg, uint8_t *val,
+ int bytes, void *d)
+{
+ struct battery2_read_data *data = d;
+
+ if (bytes < data->count) {
+ *val = data->values[bytes];
+ }
+
+ return 0;
+}
+
+ZTEST(battery, test_is_charge_fet_disabled__invalid_battery_type)
+{
+ battery_fuel_gauge_type_override = BATTERY_TYPE_COUNT;
+ zassert_equal(-1, battery_is_charge_fet_disabled());
+}
+
+ZTEST(battery, test_is_charge_fet_disabled__cfet_mask_is_0)
+{
+ battery_fuel_gauge_type_override = 2;
+ zassert_equal(0, battery_is_charge_fet_disabled());
+}
+
+ZTEST_F(battery, test_is_charge_fet_disabled__i2c_error)
+{
+ /* Set the battery to battery 1 */
+ battery_fuel_gauge_type_override = 1;
+
+ /* Override the finish_write common callback since we don't actually
+ * want to be messing with the emulator.
+ */
+ fixture->battery_i2c_common->finish_write = NULL;
+
+ /* Set up an error condition for battery 1 to fail writing to i2c */
+ battery2_write_func_fake.return_val = -1;
+ i2c_common_emul_set_write_func(fixture->battery_i2c_common,
+ battery2_write_func, NULL);
+
+ /* Verify the error */
+ zassert_equal(-1, battery_is_charge_fet_disabled());
+}
+
+ZTEST_F(battery, test_is_charge_fet_disabled)
+{
+ /* Custom data expected to be read from the battery */
+ static const uint8_t values[] = { 0x20, 0x54, 0x00, 0x00,
+ 0x00, 0x00, 0x00 };
+ static struct battery2_read_data data = {
+ .count = ARRAY_SIZE(values),
+ .values = values,
+ };
+
+ /* Set up the fake read function */
+ battery2_read_func_fake.custom_fake = battery2_read;
+ i2c_common_emul_set_read_func(fixture->battery_i2c_common,
+ battery2_read_func, &data);
+
+ /* Override the finish_write and start_read common callback since we
+ * don't actually want to be messing with the emulator.
+ */
+ fixture->battery_i2c_common->finish_write = NULL;
+ fixture->battery_i2c_common->start_read = NULL;
+
+ zassert_equal(1, battery_is_charge_fet_disabled());
+}
+
+ZTEST(battery, test_get_disconnect_state__invalid_battery_type)
+{
+ battery_fuel_gauge_type_override = BATTERY_TYPE_COUNT;
+ zassert_equal(BATTERY_DISCONNECT_ERROR, battery_get_disconnect_state());
+}
+
+ZTEST_F(battery, test_get_disconnect_state__fail_i2c_read)
+{
+ /* Use battery 0 */
+ battery_fuel_gauge_type_override = 0;
+
+ /* Configure i2c to fail on read */
+ battery2_read_func_fake.return_val = -1;
+ i2c_common_emul_set_read_func(fixture->battery_i2c_common,
+ battery2_read_func, NULL);
+
+ /* Check for disconnect error */
+ zassert_equal(BATTERY_DISCONNECT_ERROR, battery_get_disconnect_state());
+}
+
+ZTEST_F(battery, test_get_disconnect_state)
+{
+ static const uint8_t values[] = { 0x00, 0x20 };
+ static struct battery2_read_data data = {
+ .count = ARRAY_SIZE(values),
+ .values = values,
+ };
+
+ /* Enable i2c reads and set them to always return 0x2000 */
+ battery2_read_func_fake.custom_fake = battery2_read;
+ i2c_common_emul_set_read_func(fixture->battery_i2c_common,
+ battery2_read_func, &data);
+
+ zassert_equal(BATTERY_DISCONNECTED, battery_get_disconnect_state());
+}
diff --git a/zephyr/test/drivers/default/src/bb_retimer.c b/zephyr/test/drivers/default/src/bb_retimer.c
index 1b1ec4bbbc..78d483817a 100644
--- a/zephyr/test/drivers/default/src/bb_retimer.c
+++ b/zephyr/test/drivers/default/src/bb_retimer.c
@@ -3,25 +3,24 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-
+#include "chipset.h"
#include "common.h"
+#include "driver/retimer/bb_retimer.h"
#include "ec_tasks.h"
#include "emul/emul_bb_retimer.h"
#include "emul/emul_common_i2c.h"
#include "hooks.h"
#include "i2c.h"
#include "test/drivers/stubs.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
#include "usb_prl_sm.h"
#include "usb_tc_sm.h"
-#include "chipset.h"
-#include "driver/retimer/bb_retimer.h"
-#include "test/drivers/test_state.h"
-#include "test/drivers/utils.h"
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
#define GPIO_USB_C1_LS_EN_PATH DT_PATH(named_gpios, usb_c1_ls_en)
#define GPIO_USB_C1_LS_EN_PORT DT_GPIO_PIN(GPIO_USB_C1_LS_EN_PATH, gpios)
@@ -66,7 +65,7 @@ ZTEST_USER(bb_retimer_no_tasks, test_bb_set_state)
/* Set UFP role for whole test */
tc_set_data_role(USBC_PORT_C1, PD_ROLE_UFP);
- zassume_equal(PD_ROLE_UFP, pd_get_data_role(USBC_PORT_C1));
+ zassert_equal(PD_ROLE_UFP, pd_get_data_role(USBC_PORT_C1));
/* Test none mode */
bb_emul_set_reg(emul, BB_RETIMER_REG_CONNECTION_STATE, 0x12144678);
@@ -162,7 +161,8 @@ ZTEST_USER(bb_retimer_no_tasks, test_bb_set_state)
zassert_false(ack_required, "ACK is never required for BB retimer");
conn = bb_emul_get_reg(emul, BB_RETIMER_REG_CONNECTION_STATE);
exp_conn = BB_RETIMER_USB_DATA_ROLE |
- BB_RETIMER_DATA_CONNECTION_PRESENT;
+ BB_RETIMER_DATA_CONNECTION_PRESENT |
+ BB_RETIMER_DP_CONNECTION;
zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
exp_conn, conn);
@@ -175,7 +175,8 @@ ZTEST_USER(bb_retimer_no_tasks, test_bb_set_state)
zassert_false(ack_required, "ACK is never required for BB retimer");
conn = bb_emul_get_reg(emul, BB_RETIMER_REG_CONNECTION_STATE);
exp_conn = BB_RETIMER_USB_DATA_ROLE |
- BB_RETIMER_DATA_CONNECTION_PRESENT | BB_RETIMER_IRQ_HPD;
+ BB_RETIMER_DATA_CONNECTION_PRESENT |
+ BB_RETIMER_DP_CONNECTION | BB_RETIMER_IRQ_HPD;
zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
exp_conn, conn);
@@ -188,7 +189,8 @@ ZTEST_USER(bb_retimer_no_tasks, test_bb_set_state)
zassert_false(ack_required, "ACK is never required for BB retimer");
conn = bb_emul_get_reg(emul, BB_RETIMER_REG_CONNECTION_STATE);
exp_conn = BB_RETIMER_USB_DATA_ROLE |
- BB_RETIMER_DATA_CONNECTION_PRESENT | BB_RETIMER_HPD_LVL;
+ BB_RETIMER_DATA_CONNECTION_PRESENT |
+ BB_RETIMER_DP_CONNECTION | BB_RETIMER_HPD_LVL;
zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
exp_conn, conn);
}
@@ -251,7 +253,7 @@ ZTEST_USER(bb_retimer_no_tasks, test_bb_set_dfp_state)
set_test_runner_tid();
tc_set_data_role(USBC_PORT_C1, PD_ROLE_DFP);
- zassume_equal(PD_ROLE_DFP, pd_get_data_role(USBC_PORT_C1));
+ zassert_equal(PD_ROLE_DFP, pd_get_data_role(USBC_PORT_C1));
/* Test PD mux none mode with DFP should clear all bits in state */
bb_emul_set_reg(emul, BB_RETIMER_REG_CONNECTION_STATE, 0x12144678);
diff --git a/zephyr/test/drivers/default/src/bc12.c b/zephyr/test/drivers/default/src/bc12.c
deleted file mode 100644
index db1819ec4c..0000000000
--- a/zephyr/test/drivers/default/src/bc12.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/* Copyright 2021 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-
-#include "emul/emul_pi3usb9201.h"
-
-#include "timer.h"
-#include "usb_charge.h"
-#include "battery.h"
-#include "extpower.h"
-#include "test/drivers/stubs.h"
-#include "test/drivers/test_state.h"
-#include "test/drivers/utils.h"
-
-#include <zephyr/logging/log.h>
-LOG_MODULE_REGISTER(test_drivers_bc12, LOG_LEVEL_DBG);
-
-#define EMUL_NODE DT_NODELABEL(pi3usb9201_emul)
-
-/* Control_1 register bit definitions */
-#define PI3USB9201_REG_CTRL_1_INT_MASK BIT(0)
-#define PI3USB9201_REG_CTRL_1_MODE_SHIFT 1
-#define PI3USB9201_REG_CTRL_1_MODE_MASK \
- (0x7 << PI3USB9201_REG_CTRL_1_MODE_SHIFT)
-
-/* Control_2 register bit definitions */
-#define PI3USB9201_REG_CTRL_2_AUTO_SW BIT(1)
-#define PI3USB9201_REG_CTRL_2_START_DET BIT(3)
-
-/* Host status register bit definitions */
-#define PI3USB9201_REG_HOST_STS_BC12_DET BIT(0)
-#define PI3USB9201_REG_HOST_STS_DEV_PLUG BIT(1)
-#define PI3USB9201_REG_HOST_STS_DEV_UNPLUG BIT(2)
-
-enum pi3usb9201_mode {
- PI3USB9201_POWER_DOWN,
- PI3USB9201_SDP_HOST_MODE,
- PI3USB9201_DCP_HOST_MODE,
- PI3USB9201_CDP_HOST_MODE,
- PI3USB9201_CLIENT_MODE,
- PI3USB9201_RESERVED_1,
- PI3USB9201_RESERVED_2,
- PI3USB9201_USB_PATH_ON,
-};
-
-enum pi3usb9201_client_sts {
- CHG_OTHER = 0,
- CHG_2_4A,
- CHG_2_0A,
- CHG_1_0A,
- CHG_RESERVED,
- CHG_CDP,
- CHG_SDP,
- CHG_DCP,
-};
-
-struct bc12_status {
- enum charge_supplier supplier;
- int current_limit;
-};
-
-static const struct bc12_status bc12_chg_limits[] = {
- [CHG_OTHER] = { .supplier = CHARGE_SUPPLIER_OTHER,
- .current_limit = 500 },
- [CHG_2_4A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY,
- .current_limit = USB_CHARGER_MAX_CURR_MA },
- [CHG_2_0A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY,
- .current_limit = USB_CHARGER_MAX_CURR_MA },
- [CHG_1_0A] = { .supplier = CHARGE_SUPPLIER_PROPRIETARY,
- .current_limit = 1000 },
- [CHG_RESERVED] = { .supplier = CHARGE_SUPPLIER_NONE,
- .current_limit = 0 },
- [CHG_CDP] = { .supplier = CHARGE_SUPPLIER_BC12_CDP,
- .current_limit = USB_CHARGER_MAX_CURR_MA },
- [CHG_SDP] = { .supplier = CHARGE_SUPPLIER_BC12_SDP,
- .current_limit = 500 },
-#if defined(CONFIG_CHARGE_RAMP_SW) || defined(CONFIG_CHARGE_RAMP_HW)
- [CHG_DCP] = { .supplier = CHARGE_SUPPLIER_BC12_DCP,
- .current_limit = USB_CHARGER_MAX_CURR_MA },
-#else
- [CHG_DCP] = { .supplier = CHARGE_SUPPLIER_BC12_DCP,
- .current_limit = 500 },
-#endif
-};
-
-#define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl)
-#define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios)
-
-static void test_bc12_pi3usb9201_host_mode(void)
-{
- const struct emul *emul = EMUL_DT_GET(EMUL_NODE);
- uint8_t a, b;
-
- /*
- * Pretend that the USB-C Port Manager (TCPMv2) has set the port data
- * role to DFP.
- */
- usb_charger_task_set_event(0, USB_CHG_EVENT_DR_DFP);
- msleep(1);
- /*
- * Expect the pi3usb9201 driver to configure CDP host mode and unmask
- * interrupts.
- */
- pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a);
- b = PI3USB9201_CDP_HOST_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT;
- zassert_equal(a, b);
-
- /* Pretend that a device has been plugged in. */
- msleep(500);
- pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS,
- PI3USB9201_REG_HOST_STS_DEV_PLUG);
- usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
- msleep(1);
- /* Expect the pi3usb9201 driver to configure SDP host mode. */
- pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a);
- b = PI3USB9201_SDP_HOST_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT;
- zassert_equal(a, b);
- pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS, 0);
-
- /* Pretend that a device has been unplugged. */
- msleep(500);
- pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS,
- PI3USB9201_REG_HOST_STS_DEV_UNPLUG);
- usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
- msleep(1);
- /* Expect the pi3usb9201 driver to configure CDP host mode. */
- pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a);
- b = PI3USB9201_CDP_HOST_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT;
- zassert_equal(a, b);
- pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_HOST_STS, 0);
-}
-
-static void
-test_bc12_pi3usb9201_client_mode(enum pi3usb9201_client_sts detect_result,
- enum charge_supplier supplier,
- int current_limit)
-{
- const struct emul *emul = EMUL_DT_GET(EMUL_NODE);
- uint8_t a, b;
- int port, voltage;
-
- /*
- * Pretend that the USB-C Port Manager (TCPMv2) has set the port data
- * role to UFP and decided charging from the port is allowed.
- */
- msleep(500);
- usb_charger_task_set_event(0, USB_CHG_EVENT_DR_UFP);
- charge_manager_update_dualrole(USBC_PORT_C0, CAP_DEDICATED);
- msleep(1);
- /*
- * Expect the pi3usb9201 driver to configure client mode and start
- * detection.
- */
- pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a);
- b = PI3USB9201_CLIENT_MODE << PI3USB9201_REG_CTRL_1_MODE_SHIFT;
- zassert_equal(a, b);
- pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_2, &a);
- b = PI3USB9201_REG_CTRL_2_START_DET;
- zassert_equal(a, b);
-
- /* Pretend that detection completed. */
- msleep(500);
- pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_CLIENT_STS,
- 1 << detect_result);
- usb_charger_task_set_event(0, USB_CHG_EVENT_BC12);
- msleep(1);
- /* Expect the pi3usb9201 driver to clear the start bit. */
- pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_2, &a);
- zassert_equal(a, 0);
- pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_CLIENT_STS, 0);
- /*
- * Expect the charge manager to select the detected BC1.2 supplier.
- */
- port = CHARGE_PORT_NONE;
- voltage = 0;
- if (supplier != CHARGE_SUPPLIER_NONE) {
- port = USBC_PORT_C0;
- voltage = USB_CHARGER_VOLTAGE_MV;
- }
- /* Wait for the charge port to update. */
- msleep(500);
- zassert_equal(charge_manager_get_active_charge_port(), port);
- zassert_equal(charge_manager_get_supplier(), supplier);
- zassert_equal(charge_manager_get_charger_current(), current_limit,
- NULL);
- zassert_equal(charge_manager_get_charger_voltage(), voltage);
-
- /*
- * Pretend that the USB-C Port Manager (TCPMv2) has set the port data
- * role to disconnected.
- */
- msleep(500);
- usb_charger_task_set_event(0, USB_CHG_EVENT_CC_OPEN);
- msleep(1);
- /*
- * Expect the pi3usb9201 driver to configure power down mode and mask
- * interrupts.
- */
- pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a);
- b = PI3USB9201_POWER_DOWN << PI3USB9201_REG_CTRL_1_MODE_SHIFT;
- b |= PI3USB9201_REG_CTRL_1_INT_MASK;
- zassert_equal(a, b);
- /* Expect the charge manager to have no active supplier. */
- zassert_equal(charge_manager_get_active_charge_port(), CHARGE_PORT_NONE,
- NULL);
- zassert_equal(charge_manager_get_supplier(), CHARGE_SUPPLIER_NONE,
- NULL);
- zassert_equal(charge_manager_get_charger_current(), 0);
- zassert_equal(charge_manager_get_charger_voltage(), 0);
-}
-
-/*
- * PI3USB9201 is a dual-role BC1.2 charger detector/advertiser used on USB
- * ports. It can be programmed to operate in host mode or client mode through
- * I2C. When operating as a host, PI3USB9201 enables BC1.2 SDP/CDP/DCP
- * advertisement to the attached USB devices via the D+/- connection. When
- * operating as a client, PI3USB9201 starts BC1.2 detection to detect the
- * attached host type. In both host mode and client mode, the detection results
- * are reported through I2C to the controller.
- */
-ZTEST_USER(bc12, test_bc12_pi3usb9201)
-{
- const struct device *batt_pres_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios));
- const struct emul *emul = EMUL_DT_GET(EMUL_NODE);
- uint8_t a, b;
-
- /* Pretend we have battery and AC so charging works normally. */
- zassert_ok(gpio_emul_input_set(batt_pres_dev, GPIO_BATT_PRES_ODL_PORT,
- 0),
- NULL);
- zassert_equal(BP_YES, battery_is_present());
- set_ac_enabled(true);
-
- /* Wait long enough for TCPMv2 to be idle. */
- msleep(2000);
-
- /*
- * Pretend that the USB-C Port Manager (TCPMv2) has set the port data
- * role to disconnected.
- */
- usb_charger_task_set_event(0, USB_CHG_EVENT_CC_OPEN);
- usb_charger_task_set_event(1, USB_CHG_EVENT_CC_OPEN);
- msleep(1);
- /*
- * Expect the pi3usb9201 driver to configure power down mode and mask
- * interrupts.
- */
- pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_1, &a);
- b = PI3USB9201_POWER_DOWN << PI3USB9201_REG_CTRL_1_MODE_SHIFT;
- b |= PI3USB9201_REG_CTRL_1_INT_MASK;
- zassert_equal(a, b);
-
- test_bc12_pi3usb9201_host_mode();
-
- for (int c = CHG_OTHER; c <= CHG_DCP; c++) {
- test_bc12_pi3usb9201_client_mode(
- c, bc12_chg_limits[c].supplier,
- bc12_chg_limits[c].current_limit);
- }
-}
-
-/*
- * TODO(b/216660795): Cleanup state using a teardown_fn
- */
-static void bc12_after(void *unused)
-{
- set_ac_enabled(false);
-}
-
-ZTEST_SUITE(bc12, drivers_predicate_post_main, NULL, NULL, bc12_after, NULL);
diff --git a/zephyr/test/drivers/default/src/bma2x2.c b/zephyr/test/drivers/default/src/bma2x2.c
index ce6665790d..b66fc9d056 100644
--- a/zephyr/test/drivers/default/src/bma2x2.c
+++ b/zephyr/test/drivers/default/src/bma2x2.c
@@ -3,19 +3,18 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
+#include "accelgyro.h"
#include "common.h"
-#include "i2c.h"
+#include "driver/accel_bma2x2.h"
#include "emul/emul_bma255.h"
#include "emul/emul_common_i2c.h"
-
-#include "accelgyro.h"
+#include "i2c.h"
#include "motion_sense.h"
-#include "driver/accel_bma2x2.h"
#include "test/drivers/test_state.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
/** How accurate comparision of vectors should be. */
#define V_EPS 8
diff --git a/zephyr/test/drivers/default/src/bmi160.c b/zephyr/test/drivers/default/src/bmi160.c
index 01957672f7..257040b6dd 100644
--- a/zephyr/test/drivers/default/src/bmi160.c
+++ b/zephyr/test/drivers/default/src/bmi160.c
@@ -3,20 +3,19 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "common.h"
-#include "i2c.h"
+#include "driver/accelgyro_bmi160.h"
+#include "driver/accelgyro_bmi_common.h"
#include "emul/emul_bmi.h"
#include "emul/emul_common_i2c.h"
-#include "test/drivers/test_mocks.h"
-
+#include "i2c.h"
#include "motion_sense_fifo.h"
-#include "driver/accelgyro_bmi160.h"
-#include "driver/accelgyro_bmi_common.h"
+#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
#define BMI_NODE DT_NODELABEL(accel_bmi160)
#define BMI_ACC_SENSOR_ID SENSOR_ID(DT_NODELABEL(ms_bmi160_accel))
#define BMI_GYR_SENSOR_ID SENSOR_ID(DT_NODELABEL(ms_bmi160_gyro))
@@ -2139,9 +2138,9 @@ static void bmi160_before(void *fixture)
gyr_ms->rot_standard_ref = NULL;
acc_ms->rot_standard_ref = NULL;
- zassume_equal(EC_SUCCESS, acc_ms->drv->set_data_rate(acc_ms, 50000, 0),
+ zassert_equal(EC_SUCCESS, acc_ms->drv->set_data_rate(acc_ms, 50000, 0),
NULL);
- zassume_equal(EC_SUCCESS, gyr_ms->drv->set_data_rate(gyr_ms, 50000, 0),
+ zassert_equal(EC_SUCCESS, gyr_ms->drv->set_data_rate(gyr_ms, 50000, 0),
NULL);
}
diff --git a/zephyr/test/drivers/default/src/bmi260.c b/zephyr/test/drivers/default/src/bmi260.c
index 5e44d1c499..1bc45b3883 100644
--- a/zephyr/test/drivers/default/src/bmi260.c
+++ b/zephyr/test/drivers/default/src/bmi260.c
@@ -3,21 +3,20 @@
* found in the LICENSE file.
*/
-#include <zephyr/fff.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "common.h"
-#include "i2c.h"
+#include "driver/accelgyro_bmi260.h"
+#include "driver/accelgyro_bmi_common.h"
#include "emul/emul_bmi.h"
#include "emul/emul_common_i2c.h"
-
+#include "i2c.h"
#include "motion_sense_fifo.h"
-#include "driver/accelgyro_bmi260.h"
-#include "driver/accelgyro_bmi_common.h"
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include <zephyr/fff.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
#define BMI_NODE DT_NODELABEL(accel_bmi260)
#define BMI_ACC_SENSOR_ID SENSOR_ID(DT_NODELABEL(ms_bmi260_accel))
#define BMI_GYR_SENSOR_ID SENSOR_ID(DT_NODELABEL(ms_bmi260_gyro))
diff --git a/zephyr/test/drivers/default/src/bmi_common.c b/zephyr/test/drivers/default/src/bmi_common.c
index 302c59d27e..bdd3999d65 100644
--- a/zephyr/test/drivers/default/src/bmi_common.c
+++ b/zephyr/test/drivers/default/src/bmi_common.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/fff.h>
-#include <zephyr/ztest.h>
-
#include "accelgyro_bmi_common.h"
-#include "i2c.h"
#include "emul/emul_bmi.h"
#include "emul/emul_common_i2c.h"
+#include "i2c.h"
#include "test/drivers/test_state.h"
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
#define BMI_NODE DT_NODELABEL(accel_bmi160)
#define BMI_ACC_SENSOR_ID SENSOR_ID(DT_NODELABEL(ms_bmi160_accel))
diff --git a/zephyr/test/drivers/default/src/charge_manager.c b/zephyr/test/drivers/default/src/charge_manager.c
index 2729816a76..d5affff95e 100644
--- a/zephyr/test/drivers/default/src/charge_manager.c
+++ b/zephyr/test/drivers/default/src/charge_manager.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "charge_manager.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
ZTEST_SUITE(charge_manager, drivers_predicate_post_main, NULL, NULL, NULL,
NULL);
diff --git a/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c b/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c
new file mode 100644
index 0000000000..ce47ff8042
--- /dev/null
+++ b/zephyr/test/drivers/default/src/charge_state_prevent_power_on.c
@@ -0,0 +1,91 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "charge_state.h"
+#include "charge_state_v2.h"
+#include "test/drivers/test_state.h"
+
+#include <zephyr/ztest.h>
+
+/* Test external variable defined in charge_state_v2 */
+extern int charge_prevent_power_on_automatic_power_on;
+
+struct charge_state_prevent_power_on_fixture {
+ struct charge_state_data charge_state_backup;
+ int automatic_power_on;
+};
+
+static void *setup(void)
+{
+ static struct charge_state_prevent_power_on_fixture fixture;
+
+ return &fixture;
+}
+
+static void before(void *f)
+{
+ struct charge_state_prevent_power_on_fixture *fixture = f;
+
+ /* Backup the current state */
+ fixture->charge_state_backup = *charge_get_status();
+ fixture->automatic_power_on =
+ charge_prevent_power_on_automatic_power_on;
+
+ /* Reset the automatic_power_on global */
+ charge_prevent_power_on_automatic_power_on = 1;
+}
+
+static void after(void *f)
+{
+ struct charge_state_prevent_power_on_fixture *fixture = f;
+
+ /* Restore the state from 'before' */
+ *charge_get_status() = fixture->charge_state_backup;
+ charge_prevent_power_on_automatic_power_on =
+ fixture->automatic_power_on;
+}
+
+ZTEST_SUITE(charge_state_prevent_power_on, drivers_predicate_post_main, setup,
+ before, after, NULL);
+
+ZTEST(charge_state_prevent_power_on, test_allow_power_on)
+{
+ struct batt_params *params = &charge_get_status()->batt;
+
+ /* Force a call to refresh the battery parameters */
+ params->is_present = BP_NOT_SURE;
+ /* Set the charge state to be high enough */
+ params->state_of_charge =
+ CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON;
+
+ /* Verify that we can power on when the power button was pressed */
+ zassert_false(charge_prevent_power_on(true));
+}
+
+ZTEST(charge_state_prevent_power_on, test_low_charge)
+{
+ struct batt_params *params = &charge_get_status()->batt;
+
+ /* Force a low charge state */
+ params->state_of_charge =
+ CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON - 1;
+
+ /* Verify that we cannot power on during an automatic power-on */
+ zassert_true(charge_prevent_power_on(false));
+}
+
+ZTEST(charge_state_prevent_power_on, test_consuming_full_input_current)
+{
+ struct batt_params *params = &charge_get_status()->batt;
+
+ params->state_of_charge = 50;
+ zassert_true(charge_is_consuming_full_input_current());
+
+ params->state_of_charge = 0;
+ zassert_false(charge_is_consuming_full_input_current());
+
+ params->state_of_charge = 100;
+ zassert_false(charge_is_consuming_full_input_current());
+}
diff --git a/zephyr/test/drivers/default/src/chipset.c b/zephyr/test/drivers/default/src/chipset.c
new file mode 100644
index 0000000000..89ba761c23
--- /dev/null
+++ b/zephyr/test/drivers/default/src/chipset.c
@@ -0,0 +1,101 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "chipset.h"
+#include "console.h"
+#include "test/drivers/test_state.h"
+
+#include <stdint.h>
+
+#include <zephyr/fff.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
+#include <ap_power/ap_power.h>
+#include <ap_power/ap_power_events.h>
+
+ZTEST(chipset, test_get_ap_reset_stats__bad_pointers)
+{
+ zassert_equal(EC_ERROR_INVAL, get_ap_reset_stats(NULL, 0, NULL));
+}
+
+ZTEST(chipset, test_get_ap_reset_stats__happy_path)
+{
+ struct ap_reset_log_entry reset_log_entries[4];
+ uint32_t actual_reset_count, reset_count;
+
+ memset(reset_log_entries, 0, sizeof(reset_log_entries));
+
+ /* Report two AP resets */
+ report_ap_reset(CHIPSET_RESET_AP_WATCHDOG);
+ report_ap_reset(CHIPSET_RESET_HANG_REBOOT);
+
+ zassert_equal(EC_SUCCESS,
+ get_ap_reset_stats(reset_log_entries,
+ ARRAY_SIZE(reset_log_entries),
+ &reset_count));
+
+ /* Check the reset causes. The reset entry log is not a FIFO, so we get
+ * the last two empty slots followed by the two we triggered above.
+ */
+ zassert_equal(0, reset_log_entries[0].reset_cause);
+ zassert_equal(0, reset_log_entries[1].reset_cause);
+ zassert_equal(CHIPSET_RESET_AP_WATCHDOG,
+ reset_log_entries[2].reset_cause);
+ zassert_equal(CHIPSET_RESET_HANG_REBOOT,
+ reset_log_entries[3].reset_cause);
+
+ /* Check reset count */
+ actual_reset_count = test_chipset_get_ap_resets_since_ec_boot();
+ zassert_equal(actual_reset_count, reset_count,
+ "Found %d resets, expected %d", reset_count,
+ actual_reset_count);
+}
+
+ZTEST(chipset, test_console_cmd_apreset)
+{
+ struct ap_reset_log_entry reset_log_entries[4];
+ uint32_t reset_count;
+
+ zassert_ok(shell_execute_cmd(get_ec_shell(), "apreset"));
+
+ /* Make sure an AP reset happened. The expected reset log entry is at
+ * index 3 because we read out 3 empty slots first.
+ */
+ zassert_ok(get_ap_reset_stats(reset_log_entries,
+ ARRAY_SIZE(reset_log_entries),
+ &reset_count));
+
+ zassert_equal(CHIPSET_RESET_CONSOLE_CMD,
+ reset_log_entries[3].reset_cause);
+}
+
+ZTEST(chipset, test_console_cmd_apshutdown)
+{
+ struct ap_reset_log_entry reset_log_entries[4];
+ uint32_t reset_count;
+
+ zassert_ok(shell_execute_cmd(get_ec_shell(), "apshutdown"));
+
+ /* Make sure an AP reset happened. The expected reset log entry is at
+ * index 3 because we read out 3 empty slots first.
+ */
+ zassert_ok(get_ap_reset_stats(reset_log_entries,
+ ARRAY_SIZE(reset_log_entries),
+ &reset_count));
+
+ zassert_equal(CHIPSET_SHUTDOWN_CONSOLE_CMD,
+ reset_log_entries[3].reset_cause);
+}
+
+static void reset(void *arg)
+{
+ ARG_UNUSED(arg);
+
+ test_chipset_corrupt_reset_log_checksum();
+ init_reset_log();
+}
+
+ZTEST_SUITE(chipset, drivers_predicate_post_main, NULL, reset, reset, NULL);
diff --git a/zephyr/test/drivers/default/src/console.c b/zephyr/test/drivers/default/src/console.c
index 9e6c55c198..c5148baf76 100644
--- a/zephyr/test/drivers/default/src/console.c
+++ b/zephyr/test/drivers/default/src/console.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/shell/shell_dummy.h>
-
#include "builtin/stdio.h"
-#include "test/drivers/test_state.h"
#include "console.h"
-#include "uart.h"
#include "ec_commands.h"
+#include "test/drivers/test_state.h"
+#include "uart.h"
+
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
ZTEST_USER(console, test_printf_overflow)
{
diff --git a/zephyr/test/drivers/default/src/console_cmd/accelinfo.c b/zephyr/test/drivers/default/src/console_cmd/accelinfo.c
index 39556fab43..aac63c01b7 100644
--- a/zephyr/test/drivers/default/src/console_cmd/accelinfo.c
+++ b/zephyr/test/drivers/default/src/console_cmd/accelinfo.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "config.h"
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "timer.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
static void console_cmd_accelinfo_after(void *fixture)
{
ARG_UNUSED(fixture);
diff --git a/zephyr/test/drivers/default/src/console_cmd/accelinit.c b/zephyr/test/drivers/default/src/console_cmd/accelinit.c
index e722409298..2633c05f58 100644
--- a/zephyr/test/drivers/default/src/console_cmd/accelinit.c
+++ b/zephyr/test/drivers/default/src/console_cmd/accelinit.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
-#include <zephyr/fff.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "accelgyro.h"
#include "console.h"
#include "motion_sense.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/fff.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
FAKE_VALUE_FUNC(int, mock_init, struct motion_sensor_t *);
struct console_cmd_accelinit_fixture {
diff --git a/zephyr/test/drivers/default/src/console_cmd/accelrange.c b/zephyr/test/drivers/default/src/console_cmd/accelrange.c
index 57e81eada4..04ec7e6004 100644
--- a/zephyr/test/drivers/default/src/console_cmd/accelrange.c
+++ b/zephyr/test/drivers/default/src/console_cmd/accelrange.c
@@ -3,10 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/devicetree.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "driver/accel_bma2x2.h"
#include "ec_commands.h"
@@ -16,6 +12,10 @@
#include "motion_sense.h"
#include "test/drivers/test_state.h"
+#include <zephyr/devicetree.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
#define EMUL_NODE DT_NODELABEL(bma_emul)
#define BMA_ORD DT_DEP_ORD(EMUL_LABEL)
diff --git a/zephyr/test/drivers/default/src/console_cmd/accelrate.c b/zephyr/test/drivers/default/src/console_cmd/accelrate.c
index ca5bcf338a..3a5b2cd9bf 100644
--- a/zephyr/test/drivers/default/src/console_cmd/accelrate.c
+++ b/zephyr/test/drivers/default/src/console_cmd/accelrate.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "motion_sense.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
static int original_sensor_0_s0_config_odr;
static void *console_cmd_accelrate_setup(void)
diff --git a/zephyr/test/drivers/default/src/console_cmd/accelread.c b/zephyr/test/drivers/default/src/console_cmd/accelread.c
index 4a129badc1..e622faf58f 100644
--- a/zephyr/test/drivers/default/src/console_cmd/accelread.c
+++ b/zephyr/test/drivers/default/src/console_cmd/accelread.c
@@ -3,10 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/fff.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "accelgyro.h"
#include "console.h"
#include "ec_commands.h"
@@ -14,6 +10,10 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/fff.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
FAKE_VALUE_FUNC(int, mock_read, const struct motion_sensor_t *, int *);
FAKE_VALUE_FUNC(int, mock_set_data_rate, const struct motion_sensor_t *, int,
int);
diff --git a/zephyr/test/drivers/default/src/console_cmd/accelres.c b/zephyr/test/drivers/default/src/console_cmd/accelres.c
index 38bd4ed697..21c0075b0f 100644
--- a/zephyr/test/drivers/default/src/console_cmd/accelres.c
+++ b/zephyr/test/drivers/default/src/console_cmd/accelres.c
@@ -3,10 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/fff.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "accelgyro.h"
#include "console.h"
#include "driver/accel_bma2x2.h"
@@ -14,6 +10,10 @@
#include "motion_sense.h"
#include "test/drivers/test_state.h"
+#include <zephyr/fff.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
FAKE_VALUE_FUNC(int, set_resolution, const struct motion_sensor_t *, int, int);
struct console_cmd_accelres_fixture {
diff --git a/zephyr/test/drivers/default/src/console_cmd/accelspoof.c b/zephyr/test/drivers/default/src/console_cmd/accelspoof.c
index 50f8c1e650..fe11525531 100644
--- a/zephyr/test/drivers/default/src/console_cmd/accelspoof.c
+++ b/zephyr/test/drivers/default/src/console_cmd/accelspoof.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "motion_sense.h"
#include "test/drivers/test_state.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
static void console_cmd_accelspoof_after(void *fixture)
{
ARG_UNUSED(fixture);
diff --git a/zephyr/test/drivers/default/src/console_cmd/adc.c b/zephyr/test/drivers/default/src/console_cmd/adc.c
index 85dfda939a..b366db36f6 100644
--- a/zephyr/test/drivers/default/src/console_cmd/adc.c
+++ b/zephyr/test/drivers/default/src/console_cmd/adc.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
/* Default adc command, lists out channels */
ZTEST_USER(console_cmd_adc, test_adc_noname)
{
diff --git a/zephyr/test/drivers/default/src/console_cmd/battery.c b/zephyr/test/drivers/default/src/console_cmd/battery.c
index 9c3e21fcf1..f5fa78d684 100644
--- a/zephyr/test/drivers/default/src/console_cmd/battery.c
+++ b/zephyr/test/drivers/default/src/console_cmd/battery.c
@@ -3,10 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/emul.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "battery_smart.h"
#include "console.h"
#include "ec_commands.h"
@@ -15,6 +11,10 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/drivers/emul.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
struct console_cmd_battery_fixture {
const struct emul *emul;
struct i2c_common_emul_data *i2c_emul;
diff --git a/zephyr/test/drivers/default/src/console_cmd/button.c b/zephyr/test/drivers/default/src/console_cmd/button.c
index 9272b2ce2d..0df137e90b 100644
--- a/zephyr/test/drivers/default/src/console_cmd/button.c
+++ b/zephyr/test/drivers/default/src/console_cmd/button.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_USER(console_cmd_button, test_button_no_arg)
{
int rv;
diff --git a/zephyr/test/drivers/default/src/console_cmd/cbi.c b/zephyr/test/drivers/default/src/console_cmd/cbi.c
index 495ffd7e4c..297431657e 100644
--- a/zephyr/test/drivers/default/src/console_cmd/cbi.c
+++ b/zephyr/test/drivers/default/src/console_cmd/cbi.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "test/drivers/test_state.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
static void set_wp(bool value)
{
const struct gpio_dt_spec *wp = GPIO_DT_FROM_NODELABEL(gpio_wp_l);
diff --git a/zephyr/test/drivers/default/src/console_cmd/charge_manager.c b/zephyr/test/drivers/default/src/console_cmd/charge_manager.c
index a4679ddd25..698db8b316 100644
--- a/zephyr/test/drivers/default/src/console_cmd/charge_manager.c
+++ b/zephyr/test/drivers/default/src/console_cmd/charge_manager.c
@@ -3,9 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "charge_manager.h"
#include "console.h"
#include "emul/emul_isl923x.h"
@@ -15,6 +12,9 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
struct console_cmd_charge_manager_fixture {
struct tcpci_partner_data sink_5v_3a;
struct tcpci_snk_emul_data sink_ext;
@@ -111,7 +111,7 @@ ZTEST_USER(console_cmd_charge_manager, test_chgoverride_invalid_port)
{
char cmd[256];
- zassume_true(sprintf(cmd, "chgoverride %d", CHARGE_PORT_COUNT) > 0,
+ zassert_true(sprintf(cmd, "chgoverride %d", CHARGE_PORT_COUNT) > 0,
NULL);
zassert_equal(shell_execute_cmd(get_ec_shell(), cmd), EC_ERROR_PARAM1,
NULL);
diff --git a/zephyr/test/drivers/default/src/console_cmd/charge_state.c b/zephyr/test/drivers/default/src/console_cmd/charge_state.c
index 7ee91049ae..8cfd11324f 100644
--- a/zephyr/test/drivers/default/src/console_cmd/charge_state.c
+++ b/zephyr/test/drivers/default/src/console_cmd/charge_state.c
@@ -3,9 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "charge_state.h"
#include "charge_state_v2.h"
#include "console.h"
@@ -13,6 +10,9 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_USER(console_cmd_charge_state, test_idle_too_few_args)
{
int rv;
@@ -116,7 +116,7 @@ ZTEST_USER(console_cmd_charge_state, test_debug_on_show_charging_progress)
charging_progress_displayed();
/* Enable debug printing */
- zassume_ok(shell_execute_cmd(get_ec_shell(), "chgstate debug on"),
+ zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate debug on"),
NULL);
/* Sleep at least 1 full iteration of the charge state loop */
@@ -159,6 +159,16 @@ ZTEST_USER(console_cmd_charge_state, test_sustain_invalid_params)
zassert_equal(shell_execute_cmd(get_ec_shell(),
"chgstate sustain 50 101"),
EC_ERROR_INVAL, NULL);
+
+ /* Verify invalid lower bound (not a number) */
+ zassert_equal(shell_execute_cmd(get_ec_shell(),
+ "chgstate sustain a 50"),
+ EC_ERROR_PARAM2);
+
+ /* Verify invalid uppoer bound (not a number) */
+ zassert_equal(shell_execute_cmd(get_ec_shell(),
+ "chgstate sustain 30 a"),
+ EC_ERROR_PARAM3);
}
struct console_cmd_charge_state_fixture {
@@ -206,7 +216,7 @@ ZTEST_USER_F(console_cmd_charge_state, test_idle_on_from_normal)
fixture->tcpci_emul, fixture->charger_emul);
/* Verify that we're in "normal" mode */
- zassume_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL);
+ zassert_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL);
/* Move to idle */
zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate idle on"));
@@ -220,11 +230,11 @@ ZTEST_USER_F(console_cmd_charge_state, test_normal_from_idle)
fixture->tcpci_emul, fixture->charger_emul);
/* Verify that we're in "normal" mode */
- zassume_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL);
+ zassert_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL);
/* Move to idle */
- zassume_ok(shell_execute_cmd(get_ec_shell(), "chgstate idle on"));
- zassume_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_IDLE);
+ zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate idle on"));
+ zassert_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_IDLE);
/* Move back to normal */
zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate idle off"),
@@ -239,7 +249,7 @@ ZTEST_USER_F(console_cmd_charge_state, test_discharge_on)
fixture->tcpci_emul, fixture->charger_emul);
/* Verify that we're in "normal" mode */
- zassume_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL);
+ zassert_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL);
/* Enable discharge */
zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate discharge on"),
@@ -254,12 +264,12 @@ ZTEST_USER_F(console_cmd_charge_state, test_discharge_off)
fixture->tcpci_emul, fixture->charger_emul);
/* Verify that we're in "normal" mode */
- zassume_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL);
+ zassert_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_NORMAL);
/* Enable discharge */
- zassume_ok(shell_execute_cmd(get_ec_shell(), "chgstate discharge on"),
+ zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate discharge on"),
NULL);
- zassume_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_DISCHARGE);
+ zassert_equal(get_chg_ctrl_mode(), CHARGE_CONTROL_DISCHARGE);
/* Disable discharge */
zassert_ok(shell_execute_cmd(get_ec_shell(), "chgstate discharge off"),
diff --git a/zephyr/test/drivers/default/src/console_cmd/chargen.c b/zephyr/test/drivers/default/src/console_cmd/chargen.c
index 649a1b0b1f..473ad78abb 100644
--- a/zephyr/test/drivers/default/src/console_cmd/chargen.c
+++ b/zephyr/test/drivers/default/src/console_cmd/chargen.c
@@ -3,17 +3,18 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/emul.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/ztest.h>
-#include <stdio.h>
-#include <zephyr/drivers/uart/serial_test.h>
-
#include "console.h"
-#include "uart.h"
+#include "system.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include "system.h"
+#include "uart.h"
+
+#include <stdio.h>
+
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/uart/serial_test.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
const char expected_output[] =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
diff --git a/zephyr/test/drivers/default/src/console_cmd/charger.c b/zephyr/test/drivers/default/src/console_cmd/charger.c
index 9adda29a8d..420ef67fe4 100644
--- a/zephyr/test/drivers/default/src/console_cmd/charger.c
+++ b/zephyr/test/drivers/default/src/console_cmd/charger.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "dptf.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
/* Tests which need no fixture */
ZTEST_USER(console_cmd_charger, test_default_dump)
{
@@ -81,7 +81,7 @@ ZTEST_USER(console_cmd_charger, test_good_input_current)
zassert_ok(shell_execute_cmd(get_ec_shell(), "charger input 1000"),
"Failed to set input current");
- zassume_ok(charger_get_input_current_limit(0, &input_current),
+ zassert_ok(charger_get_input_current_limit(0, &input_current),
"Failed to get input current");
zassert_equal(input_current, 1000,
"Input current not set in charger: %d", input_current);
@@ -117,7 +117,7 @@ static void *console_cmd_charger_setup(void)
static struct console_cmd_charger_fixture fixture;
/* Assume we have one charger at index 0 */
- zassume_true(board_get_charger_chip_count() > 0,
+ zassert_true(board_get_charger_chip_count() > 0,
"Insufficient chargers found");
/* Get references for the emulators */
@@ -158,7 +158,7 @@ ZTEST_USER_F(console_cmd_charger, test_good_current)
/* Give the charger task time to pick up the manual current */
k_sleep(K_SECONDS(1));
- zassume_ok(charger_get_current(0, &current), "Failed to get current");
+ zassert_ok(charger_get_current(0, &current), "Failed to get current");
zassert_equal(current, 1000, "Current not set in charger: %d", current);
}
@@ -176,7 +176,7 @@ ZTEST_USER_F(console_cmd_charger, test_good_voltage)
/* Give the charger task time to pick up the manual voltage */
k_sleep(K_SECONDS(1));
- zassume_ok(charger_get_voltage(0, &voltage), "Failed to get voltage");
+ zassert_ok(charger_get_voltage(0, &voltage), "Failed to get voltage");
zassert_equal(voltage, 3000, "Voltage not set in charger: %d", voltage);
}
diff --git a/zephyr/test/drivers/default/src/console_cmd/crash.c b/zephyr/test/drivers/default/src/console_cmd/crash.c
index bc0b5d0254..4218aa74d6 100644
--- a/zephyr/test/drivers/default/src/console_cmd/crash.c
+++ b/zephyr/test/drivers/default/src/console_cmd/crash.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "builtin/assert.h"
#include "console.h"
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_SUITE(console_cmd_crash, drivers_predicate_post_main, NULL, NULL, NULL,
NULL);
diff --git a/zephyr/test/drivers/default/src/console_cmd/cutoff.c b/zephyr/test/drivers/default/src/console_cmd/cutoff.c
index 00ce40660f..2b5a9c67d2 100644
--- a/zephyr/test/drivers/default/src/console_cmd/cutoff.c
+++ b/zephyr/test/drivers/default/src/console_cmd/cutoff.c
@@ -3,9 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "battery.h"
#include "console.h"
#include "ec_commands.h"
@@ -13,6 +10,9 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
static void console_cmd_cutoff_after(void *unused)
{
ARG_UNUSED(unused);
@@ -58,7 +58,7 @@ ZTEST_USER(console_cmd_cutoff, test_clear_pending_shutdown)
{
int rv = shell_execute_cmd(get_ec_shell(), "cutoff at-shutdown");
- zassume_true(extpower_is_present(), NULL);
+ zassert_true(extpower_is_present(), NULL);
zassert_equal(EC_RES_SUCCESS, rv, "Expected %d, but got %d",
EC_RES_SUCCESS, rv);
diff --git a/zephyr/test/drivers/default/src/console_cmd/ec_features.c b/zephyr/test/drivers/default/src/console_cmd/ec_features.c
index b33ca565bc..48e6eec819 100644
--- a/zephyr/test/drivers/default/src/console_cmd/ec_features.c
+++ b/zephyr/test/drivers/default/src/console_cmd/ec_features.c
@@ -3,23 +3,27 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
+#include "builtin/stdio.h"
#include "console.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_SUITE(console_cmd_ec_features, drivers_predicate_post_main, NULL, NULL,
NULL, NULL);
ZTEST_USER(console_cmd_ec_features, test_feat)
{
- char expected[32];
+ char expected[50];
+ int ret;
- snprintf(expected, sizeof(expected), " 0-31: 0x%08x\r\n32-63: 0x%08x",
- get_feature_flags0(), get_feature_flags1());
+ ret = snprintf(expected, sizeof(expected),
+ " 0-31: 0x%08x\r\n32-63: 0x%08x", get_feature_flags0(),
+ get_feature_flags1());
+ zassert_true(ret >= 0 && ret < sizeof(expected));
CHECK_CONSOLE_CMD("feat", expected, EC_SUCCESS);
}
diff --git a/zephyr/test/drivers/default/src/console_cmd/gpio.c b/zephyr/test/drivers/default/src/console_cmd/gpio.c
index 164f272e27..c4b83b8ab4 100644
--- a/zephyr/test/drivers/default/src/console_cmd/gpio.c
+++ b/zephyr/test/drivers/default/src/console_cmd/gpio.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_USER(console_cmd_gpio, test_read_invoke_success)
{
zassert_ok(shell_execute_cmd(get_ec_shell(), "gpioget test"), NULL);
diff --git a/zephyr/test/drivers/default/src/console_cmd/hcdebug.c b/zephyr/test/drivers/default/src/console_cmd/hcdebug.c
index 71adb02690..68dc6c72be 100644
--- a/zephyr/test/drivers/default/src/console_cmd/hcdebug.c
+++ b/zephyr/test/drivers/default/src/console_cmd/hcdebug.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
static void console_cmd_hcdebug_after(void *fixture)
{
ARG_UNUSED(fixture);
diff --git a/zephyr/test/drivers/default/src/console_cmd/hibdelay.c b/zephyr/test/drivers/default/src/console_cmd/hibdelay.c
index c72a2bf66a..8275ece94d 100644
--- a/zephyr/test/drivers/default/src/console_cmd/hibdelay.c
+++ b/zephyr/test/drivers/default/src/console_cmd/hibdelay.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_SUITE(console_cmd_hibdelay, drivers_predicate_post_main, NULL, NULL, NULL,
NULL);
diff --git a/zephyr/test/drivers/default/src/console_cmd/hostevent.c b/zephyr/test/drivers/default/src/console_cmd/hostevent.c
index af9b37edd1..85717e88d1 100644
--- a/zephyr/test/drivers/default/src/console_cmd/hostevent.c
+++ b/zephyr/test/drivers/default/src/console_cmd/hostevent.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "include/lpc.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
#ifdef CONFIG_HOST_EVENT64
#define HOSTEVENT_PRINT_FORMAT "016" PRIx64
#else
@@ -52,7 +52,7 @@ static int console_cmd_hostevent(const char *subcommand, host_event_t mask)
"hostevent %s 0x%" HOSTEVENT_PRINT_FORMAT, subcommand,
mask);
- zassume_between_inclusive(rv, 0, CONFIG_SHELL_CMD_BUFF_SIZE,
+ zassert_between_inclusive(rv, 0, CONFIG_SHELL_CMD_BUFF_SIZE,
"hostevent console command too long");
return shell_execute_cmd(get_ec_shell(), cmd_buf);
diff --git a/zephyr/test/drivers/default/src/console_cmd/i2c_portmap.c b/zephyr/test/drivers/default/src/console_cmd/i2c_portmap.c
index 4b2ec548a2..7651127218 100644
--- a/zephyr/test/drivers/default/src/console_cmd/i2c_portmap.c
+++ b/zephyr/test/drivers/default/src/console_cmd/i2c_portmap.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_SUITE(console_cmd_i2c_portmap, drivers_predicate_post_main, NULL, NULL,
NULL, NULL);
diff --git a/zephyr/test/drivers/default/src/console_cmd/md.c b/zephyr/test/drivers/default/src/console_cmd/md.c
index c8c3e2c130..0db049a635 100644
--- a/zephyr/test/drivers/default/src/console_cmd/md.c
+++ b/zephyr/test/drivers/default/src/console_cmd/md.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "test/drivers/test_state.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_SUITE(console_cmd_md, drivers_predicate_post_main, NULL, NULL, NULL,
NULL);
@@ -36,7 +36,7 @@ ZTEST_USER(console_cmd_md, test_default_count)
uint8_t memory[] = { 0x01, 0x02, 0x03, 0x04 };
char cmd[128] = { 0 };
- zassume_true(sprintf(cmd, "md %" PRIuPTR, (uintptr_t)memory) != 0,
+ zassert_true(sprintf(cmd, "md %" PRIuPTR, (uintptr_t)memory) != 0,
NULL);
zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL);
}
@@ -46,7 +46,7 @@ ZTEST_USER(console_cmd_md, test_count_arg)
uint8_t memory[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
char cmd[128] = { 0 };
- zassume_true(sprintf(cmd, "md %" PRIuPTR " 2", (uintptr_t)memory) != 0,
+ zassert_true(sprintf(cmd, "md %" PRIuPTR " 2", (uintptr_t)memory) != 0,
NULL);
zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL);
}
@@ -56,7 +56,7 @@ ZTEST_USER(console_cmd_md, test_byte_format)
uint8_t memory[] = { 0x01, 0x02, 0x03, 0x04 };
char cmd[128] = { 0 };
- zassume_true(sprintf(cmd, "md .b %" PRIuPTR, (uintptr_t)memory) != 0,
+ zassert_true(sprintf(cmd, "md .b %" PRIuPTR, (uintptr_t)memory) != 0,
NULL);
zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL);
}
@@ -66,7 +66,7 @@ ZTEST_USER(console_cmd_md, test_half_format)
uint8_t memory[] = { 0x01, 0x02, 0x03, 0x04 };
char cmd[128] = { 0 };
- zassume_true(sprintf(cmd, "md .h %" PRIuPTR, (uintptr_t)memory) != 0,
+ zassert_true(sprintf(cmd, "md .h %" PRIuPTR, (uintptr_t)memory) != 0,
NULL);
zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL);
}
@@ -76,7 +76,7 @@ ZTEST_USER(console_cmd_md, test_string_format)
char memory[] = "hello world";
char cmd[128] = { 0 };
- zassume_true(sprintf(cmd, "md .s %" PRIuPTR " 12", (uintptr_t)memory) !=
+ zassert_true(sprintf(cmd, "md .s %" PRIuPTR " 12", (uintptr_t)memory) !=
0,
NULL);
zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL);
diff --git a/zephyr/test/drivers/default/src/console_cmd/panic_output.c b/zephyr/test/drivers/default/src/console_cmd/panic_output.c
index 7cc809e835..0d98ec6d08 100644
--- a/zephyr/test/drivers/default/src/console_cmd/panic_output.c
+++ b/zephyr/test/drivers/default/src/console_cmd/panic_output.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "panic.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
/* Test panicinfo when a panic hasn't occurred */
ZTEST_USER(console_cmd_panic_output, test_panicinfo)
{
diff --git a/zephyr/test/drivers/default/src/console_cmd/port80.c b/zephyr/test/drivers/default/src/console_cmd/port80.c
index 792895eb27..1d7eb2ad03 100644
--- a/zephyr/test/drivers/default/src/console_cmd/port80.c
+++ b/zephyr/test/drivers/default/src/console_cmd/port80.c
@@ -8,18 +8,17 @@
* @brief Unit Tests for ESPI port 80 console command
*/
-#include <zephyr/logging/log.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "port80.h"
-
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
/**
* @brief TestPurpose: Verify port 80 console commands
*
diff --git a/zephyr/test/drivers/default/src/console_cmd/power_button.c b/zephyr/test/drivers/default/src/console_cmd/power_button.c
index 92d0aeaf78..d9900e8667 100644
--- a/zephyr/test/drivers/default/src/console_cmd/power_button.c
+++ b/zephyr/test/drivers/default/src/console_cmd/power_button.c
@@ -4,6 +4,7 @@
*/
#include <zephyr/ztest.h>
+
#include <console.h>
ZTEST_SUITE(console_cmd_power_button, NULL, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/drivers/default/src/console_cmd/powerindebug.c b/zephyr/test/drivers/default/src/console_cmd/powerindebug.c
index 9f52a9b569..946960ea86 100644
--- a/zephyr/test/drivers/default/src/console_cmd/powerindebug.c
+++ b/zephyr/test/drivers/default/src/console_cmd/powerindebug.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_USER(console_cmd_powerindebug, test_no_params)
{
zassert_ok(shell_execute_cmd(get_ec_shell(), "powerindebug"),
diff --git a/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c b/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c
new file mode 100644
index 0000000000..b21755a465
--- /dev/null
+++ b/zephyr/test/drivers/default/src/console_cmd/pwr_avg.c
@@ -0,0 +1,47 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "battery.h"
+#include "console.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+
+#include <stdio.h>
+
+#include <zephyr/shell/shell.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
+
+ZTEST_SUITE(console_cmd_pwr_avg, drivers_predicate_post_main, NULL, NULL, NULL,
+ NULL);
+
+ZTEST_USER(console_cmd_pwr_avg, test_too_many_args)
+{
+ zassert_equal(EC_ERROR_PARAM_COUNT,
+ shell_execute_cmd(get_ec_shell(), "pwr_avg 5"));
+}
+
+ZTEST_USER(console_cmd_pwr_avg, test_printout)
+{
+ int mv = battery_get_avg_voltage();
+ int ma = battery_get_avg_current();
+ char expected_output[1024];
+ const char *buffer;
+ size_t buffer_size;
+
+ shell_backend_dummy_clear_output(get_ec_shell());
+ zassert_ok(shell_execute_cmd(get_ec_shell(), "pwr_avg"));
+
+ buffer = shell_backend_dummy_get_output(get_ec_shell(), &buffer_size);
+
+ sprintf(expected_output, "mv = %d", mv);
+ zassert_true(strstr(buffer, expected_output));
+
+ sprintf(expected_output, "ma = %d", ma);
+ zassert_true(strstr(buffer, expected_output));
+
+ sprintf(expected_output, "mw = %d", mv * ma / 1000);
+ zassert_true(strstr(buffer, expected_output));
+}
diff --git a/zephyr/test/drivers/default/src/console_cmd/rtc.c b/zephyr/test/drivers/default/src/console_cmd/rtc.c
index 80530129af..974d3709b7 100644
--- a/zephyr/test/drivers/default/src/console_cmd/rtc.c
+++ b/zephyr/test/drivers/default/src/console_cmd/rtc.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "system.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/ztest.h>
+
ZTEST_USER(console_cmd_rtc, test_rtc_no_arg)
{
char expected_buffer[32];
diff --git a/zephyr/test/drivers/default/src/console_cmd/rw.c b/zephyr/test/drivers/default/src/console_cmd/rw.c
index aac37680f5..1560254f92 100644
--- a/zephyr/test/drivers/default/src/console_cmd/rw.c
+++ b/zephyr/test/drivers/default/src/console_cmd/rw.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "test/drivers/test_state.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_SUITE(console_cmd_rw, drivers_predicate_post_main, NULL, NULL, NULL,
NULL);
@@ -43,15 +43,15 @@ ZTEST_USER(console_cmd_rw, test_read)
uint8_t memory[] = { 0x01, 0x02, 0x03, 0x04 };
char cmd[128] = { 0 };
- zassume_true(sprintf(cmd, "rw .b %" PRIuPTR, (uintptr_t)memory) != 0,
+ zassert_true(sprintf(cmd, "rw .b %" PRIuPTR, (uintptr_t)memory) != 0,
NULL);
zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL);
- zassume_true(sprintf(cmd, "rw .h %" PRIuPTR, (uintptr_t)memory) != 0,
+ zassert_true(sprintf(cmd, "rw .h %" PRIuPTR, (uintptr_t)memory) != 0,
NULL);
zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL);
- zassume_true(sprintf(cmd, "rw %" PRIuPTR, (uintptr_t)memory) != 0,
+ zassert_true(sprintf(cmd, "rw %" PRIuPTR, (uintptr_t)memory) != 0,
NULL);
zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL);
}
@@ -71,7 +71,7 @@ ZTEST_USER(console_cmd_rw, test_write)
uint8_t memory[4] = { 0 };
char cmd[128] = { 0 };
- zassume_true(sprintf(cmd, "rw .b %" PRIuPTR " 1", (uintptr_t)memory) !=
+ zassert_true(sprintf(cmd, "rw .b %" PRIuPTR " 1", (uintptr_t)memory) !=
0,
NULL);
zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL);
@@ -81,7 +81,7 @@ ZTEST_USER(console_cmd_rw, test_write)
zassert_equal(0, memory[3], "memory[3] was %u", memory[3]);
memset(memory, 0, 4);
- zassume_true(sprintf(cmd, "rw .h %" PRIuPTR " 258",
+ zassert_true(sprintf(cmd, "rw .h %" PRIuPTR " 258",
(uintptr_t)memory) != 0,
NULL);
zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL);
@@ -91,7 +91,7 @@ ZTEST_USER(console_cmd_rw, test_write)
zassert_equal(0, memory[3], "memory[3] was %u", memory[3]);
memset(memory, 0, 4);
- zassume_true(sprintf(cmd, "rw %" PRIuPTR " 16909060",
+ zassert_true(sprintf(cmd, "rw %" PRIuPTR " 16909060",
(uintptr_t)memory) != 0,
NULL);
zassert_ok(shell_execute_cmd(get_ec_shell(), cmd), NULL);
diff --git a/zephyr/test/drivers/default/src/console_cmd/shared_mem.c b/zephyr/test/drivers/default/src/console_cmd/shared_mem.c
index e7b9396509..ed796124e4 100644
--- a/zephyr/test/drivers/default/src/console_cmd/shared_mem.c
+++ b/zephyr/test/drivers/default/src/console_cmd/shared_mem.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "shared_mem.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_SUITE(console_cmd_shared_mem, drivers_predicate_post_main, NULL, NULL,
NULL, NULL);
diff --git a/zephyr/test/drivers/default/src/console_cmd/sleepmask.c b/zephyr/test/drivers/default/src/console_cmd/sleepmask.c
index 6ae017dc66..40d174e6af 100644
--- a/zephyr/test/drivers/default/src/console_cmd/sleepmask.c
+++ b/zephyr/test/drivers/default/src/console_cmd/sleepmask.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/emul.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
+#include "system.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include "system.h"
+
+#include <zephyr/drivers/emul.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
ZTEST_USER(console_cmd_sleepmask, test_no_args)
{
diff --git a/zephyr/test/drivers/default/src/console_cmd/sleeptimeout.c b/zephyr/test/drivers/default/src/console_cmd/sleeptimeout.c
index d802eb5948..3bd8a39f3f 100644
--- a/zephyr/test/drivers/default/src/console_cmd/sleeptimeout.c
+++ b/zephyr/test/drivers/default/src/console_cmd/sleeptimeout.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_USER(console_cmd_sleeptimeout, test_no_params)
{
zassert_ok(shell_execute_cmd(get_ec_shell(), "sleeptimeout"),
diff --git a/zephyr/test/drivers/default/src/console_cmd/switch.c b/zephyr/test/drivers/default/src/console_cmd/switch.c
new file mode 100644
index 0000000000..f533ebe7b9
--- /dev/null
+++ b/zephyr/test/drivers/default/src/console_cmd/switch.c
@@ -0,0 +1,31 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "console.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
+ZTEST_SUITE(console_cmd_switch, drivers_predicate_post_main, NULL, NULL, NULL,
+ NULL);
+
+ZTEST_USER(console_cmd_switch, test_mmapinfo)
+{
+ uint8_t *memmap_switches = host_get_memmap(EC_MEMMAP_SWITCHES);
+ uint8_t before = *memmap_switches;
+ char expected[32];
+
+ *memmap_switches = 0x3;
+ snprintf(expected, sizeof(expected), "memmap switches = 0x%x",
+ *memmap_switches);
+
+ CHECK_CONSOLE_CMD("mmapinfo", expected, EC_SUCCESS);
+ CHECK_CONSOLE_CMD("mmapinfo", "lid_open", EC_SUCCESS);
+ CHECK_CONSOLE_CMD("mmapinfo", "powerbtn", EC_SUCCESS);
+
+ *memmap_switches = before;
+}
diff --git a/zephyr/test/drivers/default/src/console_cmd/sysinfo.c b/zephyr/test/drivers/default/src/console_cmd/sysinfo.c
index 3aeef6510c..ba14e9158f 100644
--- a/zephyr/test/drivers/default/src/console_cmd/sysinfo.c
+++ b/zephyr/test/drivers/default/src/console_cmd/sysinfo.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/emul.h>
-#include <zephyr/fff.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
+#include "system.h"
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include "system.h"
+
+#include <zephyr/drivers/emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
ZTEST_USER(console_cmd_sysinfo, test_no_args)
{
diff --git a/zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c b/zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c
index 9652519cab..fc8533280b 100644
--- a/zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c
+++ b/zephyr/test/drivers/default/src/console_cmd/tcpci_dump.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_USER(console_cmd_tcpci_dump, test_no_params)
{
int rv = shell_execute_cmd(get_ec_shell(), "tcpci_dump");
@@ -38,7 +38,7 @@ static void console_cmd_tcpci_dump_begin(void *data)
ARG_UNUSED(data);
/* Assume we have at least one TCPC */
- zassume_true(board_get_charger_chip_count() > 0,
+ zassert_true(board_get_charger_chip_count() > 0,
"Insufficient TCPCs found");
}
diff --git a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c
index d521f7bb06..859205f403 100644
--- a/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c
+++ b/zephyr/test/drivers/default/src/console_cmd/usb_pd_console.c
@@ -3,17 +3,17 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
#include "usb_pd.h"
-#include "usb_pd_dpm.h"
+#include "usb_pd_dpm_sm.h"
#include "usb_prl_sm.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
static void console_cmd_usb_pd_after(void *fixture)
{
ARG_UNUSED(fixture);
@@ -188,6 +188,10 @@ ZTEST_USER(console_cmd_usb_pd, test_bistsharemode)
rv = shell_execute_cmd(get_ec_shell(), "pd bistsharemode disable");
zassert_equal(rv, EC_SUCCESS, "Expected %d, but got %d", EC_SUCCESS,
rv);
+
+ rv = shell_execute_cmd(get_ec_shell(), "pd bistsharemode foo");
+ zassert_equal(rv, EC_ERROR_PARAM2, "Expected %d, but got %d",
+ EC_ERROR_PARAM2, rv);
}
ZTEST_USER(console_cmd_usb_pd, test_hard)
@@ -264,6 +268,22 @@ ZTEST_USER(console_cmd_usb_pd, test_dualrole)
rv = shell_execute_cmd(get_ec_shell(), "pd 0 dualrole x");
zassert_equal(rv, EC_ERROR_PARAM4, "Expected %d, but got %d",
EC_ERROR_PARAM4, rv);
+
+ pd_set_dual_role(0, PD_DRP_TOGGLE_OFF);
+ CHECK_CONSOLE_CMD("pd 0 dualrole", "dual-role toggling: off",
+ EC_SUCCESS);
+
+ pd_set_dual_role(0, PD_DRP_FREEZE);
+ CHECK_CONSOLE_CMD("pd 0 dualrole", "dual-role toggling: freeze",
+ EC_SUCCESS);
+
+ pd_set_dual_role(0, PD_DRP_FORCE_SINK);
+ CHECK_CONSOLE_CMD("pd 0 dualrole", "dual-role toggling: force sink",
+ EC_SUCCESS);
+
+ pd_set_dual_role(0, PD_DRP_FORCE_SOURCE);
+ CHECK_CONSOLE_CMD("pd 0 dualrole", "dual-role toggling: force source",
+ EC_SUCCESS);
}
ZTEST_USER(console_cmd_usb_pd, test_state)
@@ -293,6 +313,15 @@ ZTEST_USER(console_cmd_usb_pd, test_timer)
rv);
}
+ZTEST_USER(console_cmd_usb_pd, test_cc)
+{
+ char expected_output[10];
+
+ snprintf(expected_output, sizeof(expected_output), "C0 CC%d",
+ pd_get_task_cc_state(0));
+ CHECK_CONSOLE_CMD("pd 0 cc", expected_output, EC_SUCCESS);
+}
+
static void set_device_vdo(int port, enum tcpci_msg_type type)
{
union tbt_mode_resp_device device_resp;
diff --git a/zephyr/test/drivers/default/src/console_cmd/vboot_hash.c b/zephyr/test/drivers/default/src/console_cmd/vboot_hash.c
index b475f344c8..bdc9dddc66 100644
--- a/zephyr/test/drivers/default/src/console_cmd/vboot_hash.c
+++ b/zephyr/test/drivers/default/src/console_cmd/vboot_hash.c
@@ -2,12 +2,6 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <string.h>
-#include <zephyr/fff.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/sys/util.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "flash.h"
#include "printf.h"
@@ -16,6 +10,13 @@
#include "test/drivers/test_state.h"
#include "vboot_hash.h"
+#include <string.h>
+
+#include <zephyr/fff.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/sys/util.h>
+#include <zephyr/ztest.h>
+
#define CUSTOM_HASH_LENGTH (32)
struct console_cmd_hash_fixture {
diff --git a/zephyr/test/drivers/default/src/console_cmd/version.c b/zephyr/test/drivers/default/src/console_cmd/version.c
index 932cc51449..e3606b5d0e 100644
--- a/zephyr/test/drivers/default/src/console_cmd/version.c
+++ b/zephyr/test/drivers/default/src/console_cmd/version.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/emul.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
+#include "system.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include "system.h"
+
+#include <zephyr/drivers/emul.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
ZTEST_USER(console_cmd_version, test_no_args)
{
diff --git a/zephyr/test/drivers/default/src/console_cmd/waitms.c b/zephyr/test/drivers/default/src/console_cmd/waitms.c
index 0d03ee7414..703e233568 100644
--- a/zephyr/test/drivers/default/src/console_cmd/waitms.c
+++ b/zephyr/test/drivers/default/src/console_cmd/waitms.c
@@ -3,13 +3,14 @@
* found in the LICENSE file.
*/
+#include "console.h"
+#include "timer.h"
+
#include <stdio.h>
+
#include <zephyr/shell/shell.h>
#include <zephyr/ztest.h>
-#include "console.h"
-#include "timer.h"
-
static void test_int(int ms)
{
char cmd[32];
diff --git a/zephyr/test/drivers/default/src/cros_cbi.c b/zephyr/test/drivers/default/src/cros_cbi.c
index e92765cb52..2669abe21e 100644
--- a/zephyr/test/drivers/default/src/cros_cbi.c
+++ b/zephyr/test/drivers/default/src/cros_cbi.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/device.h>
-#include <zephyr/ztest.h>
-
#include "cros_cbi.h"
#include "test/drivers/test_state.h"
+#include <zephyr/device.h>
+#include <zephyr/ztest.h>
+
ZTEST(cros_cbi, test_check_match)
{
int value;
diff --git a/zephyr/test/drivers/default/src/espi.c b/zephyr/test/drivers/default/src/espi.c
index ac6c93f3fc..e526980ef1 100644
--- a/zephyr/test/drivers/default/src/espi.c
+++ b/zephyr/test/drivers/default/src/espi.c
@@ -3,11 +3,6 @@
* found in the LICENSE file.
*/
-#include <string.h>
-#include <zephyr/fff.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "ec_commands.h"
#include "gpio.h"
#include "host_command.h"
@@ -16,6 +11,12 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <string.h>
+
+#include <zephyr/fff.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
#define PORT 0
#define AC_OK_OD_GPIO_NAME "acok_od"
@@ -214,7 +215,7 @@ ZTEST_USER(espi, test_host_command_gpio_set)
BUILD_HOST_COMMAND_PARAMS(EC_CMD_GPIO_SET, 0, p);
/* Force value to 1 to see change */
- zassume_ok(gpio_pin_set_dt(gp, 1), NULL);
+ zassert_ok(gpio_pin_set_dt(gp, 1), NULL);
zassert_ok(host_command_process(&args), NULL);
zassert_equal(gpio_pin_get_dt(gp), p.val, NULL);
diff --git a/zephyr/test/drivers/default/src/flash.c b/zephyr/test/drivers/default/src/flash.c
index 6794ca2878..e0c6743cde 100644
--- a/zephyr/test/drivers/default/src/flash.c
+++ b/zephyr/test/drivers/default/src/flash.c
@@ -3,13 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/emul.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/kernel.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/ztest.h>
-
#include "ec_commands.h"
#include "emul/emul_flash.h"
#include "flash.h"
@@ -17,6 +10,13 @@
#include "system.h"
#include "test/drivers/test_state.h"
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
+
#define WP_L_GPIO_PATH DT_PATH(named_gpios, wp_l)
static int gpio_wp_l_set(int value)
@@ -135,6 +135,17 @@ ZTEST_USER(flash, test_hostcmd_flash_protect_wp_deasserted)
response.flags);
}
+ZTEST_USER(flash, test_hostcmd_flash_read__overflow)
+{
+ struct ec_params_flash_read params = {
+ .size = 32,
+ };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND_PARAMS(EC_CMD_FLASH_READ, 0, params);
+
+ zassert_equal(EC_RES_OVERFLOW, host_command_process(&args));
+}
+
#define TEST_BUF_SIZE 0x100
ZTEST_USER(flash, test_hostcmd_flash_write_and_erase)
@@ -252,7 +263,7 @@ ZTEST_USER(flash, test_hostcmd_flash_region_info_active_invalid)
zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM, NULL);
}
-ZTEST_USER(flash, test_hostcmd_flash_info)
+ZTEST_USER(flash, test_hostcmd_flash_info_1)
{
struct ec_response_flash_info_1 response;
struct host_cmd_handler_args args =
@@ -280,6 +291,50 @@ ZTEST_USER(flash, test_hostcmd_flash_info)
"response.write_ideal_size = %d", response.write_ideal_size);
}
+ZTEST_USER(flash, test_hostcmd_flash_info_2)
+{
+ uint8_t response_buffer[sizeof(struct ec_response_flash_info_2) +
+ sizeof(struct ec_flash_bank)];
+ struct ec_response_flash_info_2 *response =
+ (struct ec_response_flash_info_2 *)response_buffer;
+ struct ec_params_flash_info_2 params = {
+ .num_banks_desc = 1,
+ };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND(EC_CMD_FLASH_INFO, 2, *response, params);
+
+ /* Get the flash info. */
+ zassert_ok(host_command_process(&args), NULL);
+ zassert_equal(response->flash_size,
+ CONFIG_FLASH_SIZE_BYTES - EC_FLASH_REGION_START, "got %d",
+ response->flash_size);
+ zassert_equal(response->flags, 0, "got %d", response->flags);
+ zassert_equal(
+ response->write_ideal_size,
+ (args.response_max - sizeof(struct ec_params_flash_write)) &
+ ~(CONFIG_FLASH_WRITE_SIZE - 1),
+ "got %d", response->write_ideal_size);
+ zassert_equal(response->num_banks_total, 1, "got %d",
+ response->num_banks_total);
+ zassert_equal(response->num_banks_desc, 1, "got %d",
+ response->num_banks_desc);
+ zassert_equal(response->banks[0].count,
+ CONFIG_FLASH_SIZE_BYTES / CONFIG_FLASH_BANK_SIZE,
+ "got %d", response->banks[0].count);
+ zassert_equal(response->banks[0].size_exp,
+ __fls(CONFIG_FLASH_BANK_SIZE), "got %d",
+ response->banks[0].size_exp);
+ zassert_equal(response->banks[0].write_size_exp,
+ __fls(CONFIG_FLASH_WRITE_SIZE), "got %d",
+ response->banks[0].write_size_exp);
+ zassert_equal(response->banks[0].erase_size_exp,
+ __fls(CONFIG_FLASH_ERASE_SIZE), "got %d",
+ response->banks[0].erase_size_exp);
+ zassert_equal(response->banks[0].protect_size_exp,
+ __fls(CONFIG_FLASH_BANK_SIZE), "got %d",
+ response->banks[0].protect_size_exp);
+}
+
ZTEST_USER(flash, test_console_cmd_flash_info)
{
const struct shell *shell_zephyr = get_ec_shell();
@@ -309,12 +364,15 @@ ZTEST_USER(flash, test_console_cmd_flash_info)
sprintf(format_buffer, "Protect: %4d B", CONFIG_FLASH_BANK_SIZE);
zassert_not_null(strstr(outbuffer, format_buffer));
- zassert_not_null(strstr(outbuffer, "wp_gpio_asserted"));
+ zassert_not_null(strstr(outbuffer, "wp_gpio_asserted: ON"));
+ zassert_not_null(strstr(outbuffer, "ro_at_boot: OFF"));
+ zassert_not_null(strstr(outbuffer, "all_at_boot: OFF"));
+ zassert_not_null(strstr(outbuffer, "ro_now: OFF"));
+ zassert_not_null(strstr(outbuffer, "all_now: OFF"));
+ zassert_not_null(strstr(outbuffer, "STUCK: OFF"));
+ zassert_not_null(strstr(outbuffer, "INCONSISTENT: OFF"));
+ zassert_not_null(strstr(outbuffer, "UNKNOWN_ERROR: OFF"));
zassert_not_null(strstr(outbuffer, "Protected now"));
- /*
- * TODO(b/254926324): Fake crec_flash_get_protect() to get more
- * flag messages.
- */
}
ZTEST_USER(flash, test_console_cmd_flashwp__invalid)
@@ -414,7 +472,7 @@ static void setup_flash_region_helper(uint32_t offset, uint32_t size,
int rv;
rv = host_command_process(&erase_args);
- zassume_ok(rv, "Got %d", rv);
+ zassert_ok(rv, "Got %d", rv);
if (make_write) {
/* Sized for flash_write header plus one byte of data */
@@ -434,7 +492,7 @@ static void setup_flash_region_helper(uint32_t offset, uint32_t size,
/* Write one byte at start of region */
out_buf[sizeof(*write_params)] = 0xec;
- zassume_ok(host_command_process(&write_args), NULL);
+ zassert_ok(host_command_process(&write_args), NULL);
}
}
diff --git a/zephyr/test/drivers/default/src/gpio.c b/zephyr/test/drivers/default/src/gpio.c
index 3dd62aaa05..7304324532 100644
--- a/zephyr/test/drivers/default/src/gpio.c
+++ b/zephyr/test/drivers/default/src/gpio.c
@@ -8,23 +8,27 @@
* @brief Unit Tests for GPIO.
*/
-#include <zephyr/device.h>
-
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "common.h"
#include "ec_tasks.h"
#include "gpio.h"
#include "gpio/gpio.h"
#include "gpio/gpio_int.h"
#include "test/drivers/stubs.h"
-#include "util.h"
+#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include "util.h"
+
+#include <zephyr/device.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/ztest.h>
extern bool gpio_test_interrupt_triggered;
+
+/* Function signature for shim/src/gpio.c test_export_static */
+int init_gpios(const struct device *unused);
+
/**
* @brief TestPurpose: Verify Zephyr to EC GPIO bitmask conversion.
*
@@ -135,14 +139,22 @@ ZTEST(gpio, test_legacy_gpio_get_set_level)
{
enum gpio_signal signal = GPIO_SIGNAL(DT_NODELABEL(gpio_test));
int level;
+
/* Test invalid signal */
gpio_set_level(GPIO_COUNT, 0);
zassert_equal(0, gpio_get_level(GPIO_COUNT), "Expected level==0");
+
/* Test valid signal */
gpio_set_level(signal, 0);
+ zassert_ok(gpio_or_ioex_get_level(signal, &level));
zassert_equal(0, gpio_get_level(signal), "Expected level==0");
+ zassert_equal(0, level);
+
gpio_set_level(signal, 1);
+ zassert_ok(gpio_or_ioex_get_level(signal, &level));
zassert_equal(1, gpio_get_level(signal), "Expected level==1");
+ zassert_equal(1, level);
+
level = gpio_get_ternary(signal);
gpio_set_level_verbose(CC_CHIPSET, signal, 0);
zassert_equal(0, gpio_get_level(signal), "Expected level==0");
@@ -369,6 +381,62 @@ ZTEST(gpio, test_gpio_reset)
flags);
}
+ZTEST(gpio, test_gpio_reset_port)
+{
+ const struct device *port =
+ DEVICE_DT_GET(DT_GPIO_CTLR(DT_NODELABEL(gpio_test), gpios));
+ enum gpio_signal signal = GPIO_SIGNAL(DT_NODELABEL(gpio_test));
+ gpio_flags_t flags;
+ gpio_flags_t flags_at_start[GPIO_COUNT];
+
+ /* Snapshot of GPIO flags before testing */
+ for (int i = 0; i < GPIO_COUNT; i++)
+ flags_at_start[i] = gpio_helper_get_flags(i);
+
+ /* Test reset on invalid signal */
+ gpio_reset_port(NULL);
+
+ /* Verify flags didn't change */
+ for (int i = 0; i < GPIO_COUNT; i++) {
+ flags = gpio_helper_get_flags(i);
+ zassert_equal(flags_at_start[i], flags,
+ "%s[%d] flags_at_start=0x%x, flags=0x%x",
+ gpio_get_name(i), i, flags_at_start[i], flags);
+ }
+
+ /* Test reset on valid signal */
+ gpio_set_flags(signal, GPIO_OUTPUT);
+ flags = gpio_helper_get_flags(signal);
+ zassert_equal(flags, GPIO_OUTPUT, "Flags set 0x%x", flags);
+
+ gpio_reset_port(port);
+
+ flags = gpio_helper_get_flags(signal);
+ zassert_equal(flags, gpio_get_default_flags(signal), "Flags set 0x%x",
+ flags);
+
+ for (int i = 0; i < GPIO_COUNT; ++i) {
+ gpio_set_flags(i, flags_at_start[i]);
+ }
+}
+
+ZTEST(gpio, test_gpio_set_flags_by_mask)
+{
+ gpio_set_flags_by_mask(0, BIT(27), GPIO_OUTPUT);
+ zassert_equal(gpio_configure_port_pin_fake.call_count, 1);
+ zassert_equal(gpio_configure_port_pin_fake.arg0_val, 0);
+ zassert_equal(gpio_configure_port_pin_fake.arg1_val, 27);
+ zassert_equal(gpio_configure_port_pin_fake.arg2_val,
+ convert_to_zephyr_flags(GPIO_OUTPUT));
+}
+
+ZTEST(gpio, test_init_gpios_fail_on_unused_pins_custom_func)
+{
+ gpio_config_unused_pins_fake.return_val = -1;
+
+ zassert_equal(-1, init_gpios(NULL));
+}
+
/**
* @brief TestPurpose: Verify GPIO enable/disable interrupt.
*
@@ -418,4 +486,4 @@ static void gpio_before(void *state)
/**
* @brief Test Suite: Verifies GPIO functionality.
*/
-ZTEST_SUITE(gpio, drivers_predicate_post_main, NULL, gpio_before, NULL, NULL);
+ZTEST_SUITE(gpio, drivers_predicate_pre_main, NULL, gpio_before, NULL, NULL);
diff --git a/zephyr/test/drivers/default/src/i2c.c b/zephyr/test/drivers/default/src/i2c.c
index caced4aedf..ca27fedbb2 100644
--- a/zephyr/test/drivers/default/src/i2c.c
+++ b/zephyr/test/drivers/default/src/i2c.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "ec_commands.h"
#include "host_command.h"
#include "i2c.h"
#include "test/drivers/test_state.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
ZTEST_USER(i2c, test_i2c_set_speed_success)
{
struct ec_response_i2c_control response;
@@ -52,12 +52,29 @@ ZTEST_USER(i2c, test_i2c_set_speed_success)
"response.cmd_response.speed_khz = %d",
response.cmd_response.speed_khz);
+ /* Set the speed to 1000. */
+ set_params.cmd_params.speed_khz = 1000;
+ zassert_ok(host_command_process(&set_args), NULL);
+ zassert_ok(set_args.result, NULL);
+ zassert_equal(set_args.response_size, sizeof(response), NULL);
+ zassert_equal(response.cmd_response.speed_khz, 400,
+ "response.cmd_response.speed_khz = %d",
+ response.cmd_response.speed_khz);
+
+ /* Get the speed to verify. */
+ zassert_ok(host_command_process(&get_args), NULL);
+ zassert_ok(get_args.result, NULL);
+ zassert_equal(get_args.response_size, sizeof(response), NULL);
+ zassert_equal(response.cmd_response.speed_khz, 1000,
+ "response.cmd_response.speed_khz = %d",
+ response.cmd_response.speed_khz);
+
/* Set the speed back to 100. */
set_params.cmd_params.speed_khz = 100;
zassert_ok(host_command_process(&set_args), NULL);
zassert_ok(set_args.result, NULL);
zassert_equal(set_args.response_size, sizeof(response), NULL);
- zassert_equal(response.cmd_response.speed_khz, 400,
+ zassert_equal(response.cmd_response.speed_khz, 1000,
"response.cmd_response.speed_khz = %d",
response.cmd_response.speed_khz);
}
diff --git a/zephyr/test/drivers/default/src/i2c_passthru.c b/zephyr/test/drivers/default/src/i2c_passthru.c
index 67e1317876..afefc4b553 100644
--- a/zephyr/test/drivers/default/src/i2c_passthru.c
+++ b/zephyr/test/drivers/default/src/i2c_passthru.c
@@ -3,15 +3,25 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "driver/ln9310.h"
#include "ec_commands.h"
#include "host_command.h"
#include "i2c.h"
+#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
+FAKE_VALUE_FUNC(int, board_allow_i2c_passthru, const struct i2c_cmd_desc_t *);
+
+int board_allow_i2c_passthru_custom_fake(const struct i2c_cmd_desc_t *cmd_desc)
+{
+ /* Only allow passthru on I2C_PORT_USB_C0 */
+ return i2c_get_device_for_port(cmd_desc->port) ==
+ i2c_get_device_for_port(I2C_PORT_USB_C0);
+}
+
ZTEST_USER(i2c_passthru, test_read_without_write)
{
uint8_t param_buf[sizeof(struct ec_params_i2c_passthru) +
@@ -40,6 +50,55 @@ ZTEST_USER(i2c_passthru, test_read_without_write)
sizeof(struct ec_response_i2c_passthru), NULL);
}
+ZTEST_USER(i2c_passthru, test_passthru_invalid_params)
+{
+ uint16_t tcpc_addr = DT_REG_ADDR(DT_NODELABEL(tcpci_emul));
+ uint8_t *out_data;
+ uint8_t param_buf[sizeof(struct ec_params_i2c_passthru) +
+ 2 * sizeof(struct ec_params_i2c_passthru_msg) + 1];
+ uint8_t response_buf[sizeof(struct ec_response_i2c_passthru) + 2];
+ struct ec_params_i2c_passthru *passthru_params =
+ (struct ec_params_i2c_passthru *)&param_buf;
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND_SIMPLE(EC_CMD_I2C_PASSTHRU, 0);
+
+ passthru_params->port = I2C_PORT_USB_C0;
+ passthru_params->num_msgs = 2;
+ passthru_params->msg[0].addr_flags = tcpc_addr;
+ passthru_params->msg[0].len = 1;
+ passthru_params->msg[1].addr_flags = tcpc_addr | EC_I2C_FLAG_READ;
+ passthru_params->msg[1].len = 2; /* 2 byte vendor ID */
+
+ /* Write data follows the passthru messages */
+ out_data = (uint8_t *)&passthru_params->msg[2];
+ out_data[0] = 0; /* TCPC_REG_VENDOR_ID 0x0 */
+
+ args.params = &param_buf;
+ args.params_size = sizeof(param_buf);
+ args.response = &response_buf;
+ args.response_max = sizeof(response_buf);
+
+ /* Set the params_size to smaller than struct ec_params_i2c_passthru */
+ args.params_size = 1;
+ zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM);
+
+ /* Set the params_size so it truncates the 2nd I2C message */
+ args.params_size = sizeof(struct ec_params_i2c_passthru) +
+ sizeof(struct ec_params_i2c_passthru_msg);
+ zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM);
+
+ /* Don't provide enough room for the response */
+ args.params_size = sizeof(param_buf);
+ args.response_max = sizeof(struct ec_response_i2c_passthru) + 1;
+ zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM);
+
+ /* Don't provide the write data */
+ args.response_max = sizeof(response_buf);
+ args.params_size = sizeof(struct ec_params_i2c_passthru) +
+ 2 * sizeof(struct ec_params_i2c_passthru_msg);
+ zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM);
+}
+
ZTEST_USER(i2c_passthru, test_passthru_protect)
{
struct ec_response_i2c_passthru_protect response;
@@ -107,10 +166,166 @@ ZTEST_USER(i2c_passthru, test_passthru_protect_tcpcs)
};
struct host_cmd_handler_args enable_args = BUILD_HOST_COMMAND_PARAMS(
EC_CMD_I2C_PASSTHRU_PROTECT, 0, enable_params);
+ uint16_t tcpc_addr = DT_REG_ADDR(DT_NODELABEL(tcpci_emul));
+ uint8_t *out_data;
+ uint8_t param_buf[sizeof(struct ec_params_i2c_passthru) +
+ 2 * sizeof(struct ec_params_i2c_passthru_msg) + 1];
+ uint8_t response_buf[sizeof(struct ec_response_i2c_passthru) + 2];
+ struct ec_params_i2c_passthru *passthru_params =
+ (struct ec_params_i2c_passthru *)&param_buf;
+ struct ec_response_i2c_passthru *passthru_response =
+ (struct ec_response_i2c_passthru *)&response_buf;
+ struct host_cmd_handler_args passthru_args =
+ BUILD_HOST_COMMAND_SIMPLE(EC_CMD_I2C_PASSTHRU, 0);
+
+ /* If the system is unlocked, TCPC protection is disabled */
+ system_is_locked_fake.return_val = false;
+
+ /* Protect the all TCPC buses */
+ zassert_ok(host_command_process(&enable_args), NULL);
+ zassert_ok(enable_args.result, NULL);
+
+ passthru_params->port = I2C_PORT_USB_C0;
+ passthru_params->num_msgs = 2;
+ passthru_params->msg[0].addr_flags = tcpc_addr;
+ passthru_params->msg[0].len = 1;
+ passthru_params->msg[1].addr_flags = tcpc_addr | EC_I2C_FLAG_READ;
+ passthru_params->msg[1].len = 2; /* 2 byte vendor ID */
+
+ /* Write data follows the passthru messages */
+ out_data = (uint8_t *)&passthru_params->msg[2];
+ out_data[0] = 0; /* TCPC_REG_VENDOR_ID 0x0 */
+
+ passthru_args.params = &param_buf;
+ passthru_args.params_size = sizeof(param_buf);
+ passthru_args.response = &response_buf;
+ passthru_args.response_max = sizeof(response_buf);
+
+ zassert_ok(host_command_process(&passthru_args));
+ zassert_ok(passthru_args.result);
+ zassert_ok(passthru_response->i2c_status);
+ zassert_equal(passthru_args.response_size,
+ sizeof(struct ec_response_i2c_passthru) + 2, NULL);
+
+ /* Now attempt TCPC protection while the system is locked */
+ system_is_locked_fake.return_val = true;
/* Protect the all TCPC buses */
zassert_ok(host_command_process(&enable_args), NULL);
zassert_ok(enable_args.result, NULL);
+
+ zassert_equal(host_command_process(&passthru_args),
+ EC_RES_ACCESS_DENIED);
+}
+
+ZTEST_USER(i2c_passthru, test_passthru_restricted)
+{
+ uint16_t tcpc_addr = DT_REG_ADDR(DT_NODELABEL(tcpci_emul));
+ uint16_t ps8xxx_addr = DT_REG_ADDR(DT_NODELABEL(ps8xxx_emul));
+ uint8_t *out_data;
+ uint8_t tcpc_param_buf[sizeof(struct ec_params_i2c_passthru) +
+ 2 * sizeof(struct ec_params_i2c_passthru_msg) +
+ 1];
+ uint8_t tcpc_rsp_buf[sizeof(struct ec_response_i2c_passthru) + 2];
+ struct ec_params_i2c_passthru *tcpc_params =
+ (struct ec_params_i2c_passthru *)&tcpc_param_buf;
+ struct ec_response_i2c_passthru *tcpc_response =
+ (struct ec_response_i2c_passthru *)&tcpc_rsp_buf;
+ struct host_cmd_handler_args tcpc_args =
+ BUILD_HOST_COMMAND_SIMPLE(EC_CMD_I2C_PASSTHRU, 0);
+
+ uint8_t ps8xxx_param_buf[sizeof(struct ec_params_i2c_passthru) +
+ 2 * sizeof(struct ec_params_i2c_passthru_msg) +
+ 1];
+ uint8_t ps8xxx_rsp_buf[sizeof(struct ec_response_i2c_passthru) + 2];
+ struct ec_params_i2c_passthru *ps8xxx_params =
+ (struct ec_params_i2c_passthru *)&ps8xxx_param_buf;
+ struct ec_response_i2c_passthru *ps8xxx_response =
+ (struct ec_response_i2c_passthru *)&ps8xxx_rsp_buf;
+ struct host_cmd_handler_args ps8xxx_args =
+ BUILD_HOST_COMMAND_SIMPLE(EC_CMD_I2C_PASSTHRU, 0);
+
+ if (!IS_ENABLED(CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED)) {
+ ztest_test_skip();
+ return;
+ }
+
+ /*
+ * Setup passthru command to the TCPCI emulator - which is always
+ * permitted by our board_allow_i2c_passthru() fake.
+ */
+ tcpc_params->port = I2C_PORT_USB_C0;
+ tcpc_params->num_msgs = 2;
+ tcpc_params->msg[0].addr_flags = tcpc_addr;
+ tcpc_params->msg[0].len = 1;
+ tcpc_params->msg[1].addr_flags = tcpc_addr | EC_I2C_FLAG_READ;
+ tcpc_params->msg[1].len = 2; /* 2 byte vendor ID */
+
+ /* Write data follows the passthru messages */
+ out_data = (uint8_t *)&tcpc_params->msg[2];
+ out_data[0] = 0; /* TCPC_REG_VENDOR_ID 0x0 */
+
+ tcpc_args.params = &tcpc_param_buf;
+ tcpc_args.params_size = sizeof(tcpc_param_buf);
+ tcpc_args.response = &tcpc_rsp_buf;
+ tcpc_args.response_max = sizeof(tcpc_rsp_buf);
+
+ /*
+ * Setup passthru command to the PS8xxx emulator, which should be
+ * rejected when the system is locked.
+ */
+ ps8xxx_params->port = I2C_PORT_USB_C1;
+ ps8xxx_params->num_msgs = 2;
+ ps8xxx_params->msg[0].addr_flags = ps8xxx_addr;
+ ps8xxx_params->msg[0].len = 1;
+ ps8xxx_params->msg[1].addr_flags = ps8xxx_addr | EC_I2C_FLAG_READ;
+ ps8xxx_params->msg[1].len = 2; /* 2-byte vendor ID */
+
+ /* Write data follows the passthru messages */
+ out_data = (uint8_t *)&ps8xxx_params->msg[2];
+ out_data[0] = 0; /* TCPC_REG_VENDOR_ID 0x0 */
+
+ ps8xxx_args.params = &ps8xxx_param_buf;
+ ps8xxx_args.params_size = sizeof(ps8xxx_param_buf);
+ ps8xxx_args.response = &ps8xxx_rsp_buf;
+ ps8xxx_args.response_max = sizeof(ps8xxx_rsp_buf);
+
+ /* Install our board_allow_i2c_passthru() handler */
+ board_allow_i2c_passthru_fake.custom_fake =
+ board_allow_i2c_passthru_custom_fake;
+
+ /* When the system is unlocked, no restrictions apply */
+ system_is_locked_fake.return_val = false;
+
+ zassert_ok(host_command_process(&tcpc_args));
+ zassert_ok(tcpc_args.result);
+ zassert_ok(tcpc_response->i2c_status);
+ zassert_equal(tcpc_args.response_size,
+ sizeof(struct ec_response_i2c_passthru) + 2, NULL);
+
+ zassert_ok(host_command_process(&ps8xxx_args));
+ zassert_ok(ps8xxx_args.result);
+ zassert_ok(ps8xxx_response->i2c_status);
+ zassert_equal(ps8xxx_args.response_size,
+ sizeof(struct ec_response_i2c_passthru) + 2, NULL);
+
+ /* Lock the system which enables board_allow_i2c_passthru() */
+ system_is_locked_fake.return_val = true;
+
+ zassert_ok(host_command_process(&tcpc_args));
+ zassert_ok(tcpc_args.result);
+ zassert_ok(tcpc_response->i2c_status);
+ zassert_equal(tcpc_args.response_size,
+ sizeof(struct ec_response_i2c_passthru) + 2, NULL);
+
+ zassert_equal(host_command_process(&ps8xxx_args), EC_RES_ACCESS_DENIED);
+}
+
+static void i2c_passthru_before(void *state)
+{
+ ARG_UNUSED(state);
+ RESET_FAKE(board_allow_i2c_passthru);
+ board_allow_i2c_passthru_fake.return_val = 1;
}
static void i2c_passthru_after(void *state)
@@ -119,5 +334,5 @@ static void i2c_passthru_after(void *state)
i2c_passthru_protect_reset();
}
-ZTEST_SUITE(i2c_passthru, drivers_predicate_post_main, NULL, NULL,
- i2c_passthru_after, NULL);
+ZTEST_SUITE(i2c_passthru, drivers_predicate_post_main, NULL,
+ i2c_passthru_before, i2c_passthru_after, NULL);
diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb.c b/zephyr/test/drivers/default/src/integration/usbc/usb.c
index 9fc8f66505..31c8887bf1 100644
--- a/zephyr/test/drivers/default/src/integration/usbc/usb.c
+++ b/zephyr/test/drivers/default/src/integration/usbc/usb.c
@@ -3,14 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-
#include "battery_smart.h"
+#include "driver/tcpm/ps8xxx_public.h"
#include "ec_commands.h"
#include "ec_tasks.h"
-#include "driver/tcpm/ps8xxx_public.h"
#include "emul/emul_isl923x.h"
#include "emul/emul_smart_battery.h"
#include "emul/tcpc/emul_ps8xxx.h"
@@ -27,6 +23,10 @@
#include "test/usb_pe.h"
#include "usb_tc_sm.h"
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
#define BATTERY_NODE DT_NODELABEL(battery)
#define GPIO_AC_OK_PATH DT_PATH(named_gpios, acok_od)
diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c b/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c
index 07b1b5143e..f2afa5be9a 100644
--- a/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c
+++ b/zephyr/test/drivers/default/src/integration/usbc/usb_20v_3a_pd_charger.c
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "battery_smart.h"
#include "emul/emul_isl923x.h"
#include "emul/emul_smart_battery.h"
@@ -13,6 +11,8 @@
#include "test/drivers/utils.h"
#include "usb_pd.h"
+#include <zephyr/ztest.h>
+
#define BATTERY_NODE DT_NODELABEL(battery)
struct usb_attach_20v_3a_pd_charger_fixture {
@@ -26,7 +26,7 @@ static inline void
connect_charger_to_port(struct usb_attach_20v_3a_pd_charger_fixture *fixture)
{
set_ac_enabled(true);
- zassume_ok(tcpci_partner_connect_to_tcpci(&fixture->charger_20v,
+ zassert_ok(tcpci_partner_connect_to_tcpci(&fixture->charger_20v,
fixture->tcpci_emul),
NULL);
@@ -43,7 +43,7 @@ static inline void disconnect_charger_from_port(
struct usb_attach_20v_3a_pd_charger_fixture *fixture)
{
set_ac_enabled(false);
- zassume_ok(tcpci_emul_disconnect_partner(fixture->tcpci_emul));
+ zassert_ok(tcpci_emul_disconnect_partner(fixture->tcpci_emul));
isl923x_emul_set_adc_vbus(fixture->charger_emul, 0);
k_sleep(K_SECONDS(1));
}
@@ -88,7 +88,7 @@ ZTEST(usb_attach_20v_3a_pd_charger, test_battery_is_charging)
const struct emul *emul = EMUL_DT_GET(BATTERY_NODE);
uint16_t battery_status;
- zassume_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS,
+ zassert_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS,
&battery_status),
NULL);
zassert_equal(battery_status & STATUS_DISCHARGING, 0,
@@ -176,9 +176,9 @@ ZTEST_F(usb_attach_20v_3a_pd_charger, test_disconnect_charge_state)
"Max charge current expected 0mA, but was %dmA",
charge_state.get_state.chg_current);
zassert_equal(charge_state.get_state.chg_input_current,
- CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT,
+ CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT,
"Charge input current limit expected %dmA, but was %dmA",
- CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT,
+ CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT,
charge_state.get_state.chg_input_current);
}
diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c
index e3584470a0..6795e72c11 100644
--- a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c
+++ b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_sink.c
@@ -3,9 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-#include <zephyr/ztest.h>
-
#include "battery_smart.h"
#include "emul/emul_isl923x.h"
#include "emul/emul_smart_battery.h"
@@ -16,6 +13,10 @@
#include "timer.h"
#include "usb_pd.h"
+#include <stdint.h>
+
+#include <zephyr/ztest.h>
+
struct usb_attach_5v_3a_pd_sink_fixture {
struct tcpci_partner_data sink_5v_3a;
struct tcpci_snk_emul_data snk_ext;
@@ -85,7 +86,7 @@ ZTEST(usb_attach_5v_3a_pd_sink, test_battery_is_discharging)
const struct emul *emul = EMUL_DT_GET(DT_NODELABEL(battery));
uint16_t battery_status;
- zassume_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS,
+ zassert_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS,
&battery_status));
zassert_equal(battery_status & STATUS_DISCHARGING, STATUS_DISCHARGING,
"Battery is not discharging: %d", battery_status);
@@ -158,9 +159,9 @@ ZTEST_F(usb_attach_5v_3a_pd_sink, test_disconnect_charge_state)
"Max charge current expected 0mA, but was %dmA",
charge_state.get_state.chg_current);
zassert_equal(charge_state.get_state.chg_input_current,
- CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT,
+ CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT,
"Charge input current limit expected %dmA, but was %dmA",
- CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT,
+ CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT,
charge_state.get_state.chg_input_current);
}
diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c
index c73cf26f37..c57054881d 100644
--- a/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c
+++ b/zephyr/test/drivers/default/src/integration/usbc/usb_5v_3a_pd_source.c
@@ -3,10 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/sys/byteorder.h>
-#include <zephyr/sys/slist.h>
-#include <zephyr/ztest.h>
-
#include "battery.h"
#include "battery_smart.h"
#include "dps.h"
@@ -19,11 +15,18 @@
#include "test/drivers/utils.h"
#include "usb_pd.h"
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/sys/byteorder.h>
+#include <zephyr/sys/slist.h>
+#include <zephyr/ztest.h>
+
#define BATTERY_NODE DT_NODELABEL(battery)
#define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl)
#define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios)
+#define TEST_PORT 0
+
struct usb_attach_5v_3a_pd_source_fixture {
struct tcpci_partner_data source_5v_3a;
struct tcpci_src_emul_data src_ext;
@@ -36,8 +39,8 @@ static void *usb_attach_5v_3a_pd_source_setup(void)
static struct usb_attach_5v_3a_pd_source_fixture test_fixture;
/* Get references for the emulators */
- test_fixture.tcpci_emul = EMUL_GET_USBC_BINDING(0, tcpc);
- test_fixture.charger_emul = EMUL_GET_USBC_BINDING(0, chg);
+ test_fixture.tcpci_emul = EMUL_GET_USBC_BINDING(TEST_PORT, tcpc);
+ test_fixture.charger_emul = EMUL_GET_USBC_BINDING(TEST_PORT, chg);
/* Initialized the charger to supply 5V and 3A */
tcpci_partner_init(&test_fixture.source_5v_3a, PD_REV20);
@@ -70,7 +73,7 @@ static void control_battery_present(bool present)
DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios));
/* 0 means battery present */
- zassume_ok(gpio_emul_input_set(dev, GPIO_BATT_PRES_ODL_PORT, !present));
+ zassert_ok(gpio_emul_input_set(dev, GPIO_BATT_PRES_ODL_PORT, !present));
}
ZTEST_SUITE(usb_attach_5v_3a_pd_source, drivers_predicate_post_main,
@@ -82,7 +85,7 @@ ZTEST(usb_attach_5v_3a_pd_source, test_battery_is_charging)
const struct emul *emul = EMUL_DT_GET(BATTERY_NODE);
uint16_t battery_status;
- zassume_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS,
+ zassert_ok(sbat_emul_get_word_val(emul, SB_BATTERY_STATUS,
&battery_status));
zassert_equal(battery_status & STATUS_DISCHARGING, 0,
"Battery is discharging: %d", battery_status);
@@ -90,7 +93,8 @@ ZTEST(usb_attach_5v_3a_pd_source, test_battery_is_charging)
ZTEST(usb_attach_5v_3a_pd_source, test_charge_state)
{
- struct ec_response_charge_state state = host_cmd_charge_state(0);
+ struct ec_response_charge_state state =
+ host_cmd_charge_state(TEST_PORT);
zassert_true(state.get_state.ac, "AC_OK not triggered");
zassert_true(state.get_state.chg_voltage > 0,
@@ -161,16 +165,16 @@ ZTEST_F(usb_attach_5v_3a_pd_source, test_disconnect_charge_state)
struct ec_response_charge_state charge_state;
disconnect_source_from_port(fixture->tcpci_emul, fixture->charger_emul);
- charge_state = host_cmd_charge_state(0);
+ charge_state = host_cmd_charge_state(TEST_PORT);
zassert_false(charge_state.get_state.ac, "AC_OK not triggered");
zassert_equal(charge_state.get_state.chg_current, 0,
"Max charge current expected 0mA, but was %dmA",
charge_state.get_state.chg_current);
zassert_equal(charge_state.get_state.chg_input_current,
- CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT,
+ CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT,
"Charge input current limit expected %dmA, but was %dmA",
- CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT,
+ CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT,
charge_state.get_state.chg_input_current);
}
@@ -321,3 +325,39 @@ ZTEST_F(usb_attach_5v_3a_pd_source, test_dps_enable)
dps_enable(true);
zassert_true(dps_is_enabled());
}
+
+ZTEST_F(usb_attach_5v_3a_pd_source, test_dps_info)
+{
+ const struct shell *shell_zephyr = get_ec_shell();
+
+ const char *outbuffer;
+ uint32_t buffer_size;
+ /* Arbitrary array size for sprintf should not need this amount */
+ char format_buffer[100];
+
+ shell_backend_dummy_clear_output(shell_zephyr);
+
+ /* Print current status to console */
+ zassert_ok(shell_execute_cmd(shell_zephyr, "dps"), NULL);
+ outbuffer = shell_backend_dummy_get_output(shell_zephyr, &buffer_size);
+
+ /* Should include extra information about the charging port */
+ /* Charging Port */
+ sprintf(format_buffer, "C%d", TEST_PORT);
+ zassert_not_null(strstr(outbuffer, format_buffer));
+ /* We are a sink to a 5v3a source, so check requested mv/ma */
+ sprintf(format_buffer, "Requested: %dmV/%dmA", 5000, 3000);
+ zassert_not_null(strstr(outbuffer, format_buffer));
+ /*
+ * Measured input power is shown (values vary so not asserting on
+ * numbers)
+ */
+ zassert_not_null(strstr(outbuffer, "Measured:"));
+ /* Efficient Voltage - Value varies based on battery*/
+ zassert_not_null(strstr(outbuffer, "Efficient:"));
+ /* Battery Design Voltage (varies based on battery) */
+ zassert_not_null(strstr(outbuffer, "Batt:"));
+ /* PDMaxMV */
+ sprintf(format_buffer, "PDMaxMV: %dmV", pd_get_max_voltage());
+ zassert_not_null(strstr(outbuffer, format_buffer));
+}
diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c b/zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c
index 0b65f9b135..401a89cb11 100644
--- a/zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c
+++ b/zephyr/test/drivers/default/src/integration/usbc/usb_attach_src_snk.c
@@ -3,24 +3,24 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-
+#include "driver/tcpm/ps8xxx_public.h"
#include "ec_commands.h"
#include "ec_tasks.h"
-#include "driver/tcpm/ps8xxx_public.h"
#include "emul/emul_isl923x.h"
#include "emul/tcpc/emul_ps8xxx.h"
#include "emul/tcpc/emul_tcpci.h"
#include "emul/tcpc/emul_tcpci_partner_snk.h"
#include "emul/tcpc/emul_tcpci_partner_src.h"
#include "host_command.h"
-#include "test/drivers/stubs.h"
#include "tcpm/tcpci.h"
-#include "test/usb_pe.h"
-#include "test/drivers/utils.h"
+#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+#include "test/usb_pe.h"
+
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
#define SNK_PORT USBC_PORT_C0
#define SRC_PORT USBC_PORT_C1
@@ -117,21 +117,21 @@ static void attach_src_snk_common_before(struct emul_state *my_emul_state)
/* TODO(b/217737667): Remove driver specific code. */
isl923x_emul_set_adc_vbus(charger_emul, 0);
- zassume_ok(tcpc_config[SNK_PORT].drv->init(SNK_PORT));
+ zassert_ok(tcpc_config[SNK_PORT].drv->init(SNK_PORT));
/*
* Arbitrary FW ver. The emulator should really be setting this
* during its init.
*/
tcpci_emul_set_reg(tcpci_emul_snk, PS8XXX_REG_FW_REV, 0x31);
- zassume_ok(tcpc_config[SRC_PORT].drv->init(SRC_PORT));
+ zassert_ok(tcpc_config[SRC_PORT].drv->init(SRC_PORT));
pd_set_suspend(SNK_PORT, false);
pd_set_suspend(SRC_PORT, false);
/* Reset to disconnected state. */
- zassume_ok(tcpci_emul_disconnect_partner(tcpci_emul_src));
- zassume_ok(tcpci_emul_disconnect_partner(tcpci_emul_snk));
+ zassert_ok(tcpci_emul_disconnect_partner(tcpci_emul_src));
+ zassert_ok(tcpci_emul_disconnect_partner(tcpci_emul_snk));
/* Set chipset to ON, this will set TCPM to DRP */
test_set_chipset_to_s0();
@@ -177,7 +177,7 @@ static void attach_emulated_snk(struct emul_state *my_emul_state)
tcpci_emul_set_reg(tcpci_emul_snk, TCPC_REG_EXT_STATUS,
TCPC_REG_EXT_STATUS_SAFE0V);
- zassume_ok(tcpci_partner_connect_to_tcpci(my_snk, tcpci_emul_snk),
+ zassert_ok(tcpci_partner_connect_to_tcpci(my_snk, tcpci_emul_snk),
NULL);
/* TODO(b/214401892): Check why need to give time TCPM to spin */
@@ -207,7 +207,7 @@ static void attach_emulated_src(struct emul_state *my_emul_state)
tcpci_emul_set_reg(tcpci_emul_src, TCPC_REG_EXT_STATUS,
TCPC_REG_EXT_STATUS_SAFE0V);
- zassume_ok(tcpci_partner_connect_to_tcpci(my_src, tcpci_emul_src),
+ zassert_ok(tcpci_partner_connect_to_tcpci(my_src, tcpci_emul_src),
NULL);
isl923x_emul_set_adc_vbus(charger_emul, DEFAULT_VBUS_MV);
}
@@ -542,7 +542,7 @@ struct usb_detach_test_fixture {
static void integration_usb_test_detach(const struct emul *e)
{
- zassume_ok(tcpci_emul_disconnect_partner(e));
+ zassert_ok(tcpci_emul_disconnect_partner(e));
}
static void integration_usb_test_sink_detach(struct emul_state *fixture)
diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c
index 47e26f97d6..36a417d22c 100644
--- a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c
+++ b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_bist_shared.c
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "emul/emul_isl923x.h"
#include "emul/emul_smart_battery.h"
#include "emul/tcpc/emul_tcpci_partner_snk.h"
@@ -15,6 +13,8 @@
#include "usb_pd.h"
#include "util.h"
+#include <zephyr/ztest.h>
+
struct usb_pd_bist_shared_fixture {
struct tcpci_partner_data sink_5v_500ma;
struct tcpci_snk_emul_data snk_ext_500ma;
@@ -99,7 +99,7 @@ ZTEST_F(usb_pd_bist_shared, verify_bist_shared_mode)
/* Start up BIST shared test mode */
bist_data = BDO(BDO_MODE_SHARED_ENTER, 0);
- zassume_ok(tcpci_partner_send_data_msg(&fixture->sink_5v_500ma,
+ zassert_ok(tcpci_partner_send_data_msg(&fixture->sink_5v_500ma,
PD_DATA_BIST, &bist_data, 1, 0),
"Failed to send BIST enter message");
@@ -116,7 +116,7 @@ ZTEST_F(usb_pd_bist_shared, verify_bist_shared_mode)
/* Leave BIST shared test mode */
bist_data = BDO(BDO_MODE_SHARED_EXIT, 0);
- zassume_ok(tcpci_partner_send_data_msg(&fixture->sink_5v_500ma,
+ zassert_ok(tcpci_partner_send_data_msg(&fixture->sink_5v_500ma,
PD_DATA_BIST, &bist_data, 1, 0),
"Failed to send BIST exit message");
@@ -152,7 +152,7 @@ ZTEST_F(usb_pd_bist_shared, verify_bist_shared_no_snk_entry)
/* Have the source send the BIST Enter Mode */
bist_data = BDO(BDO_MODE_SHARED_ENTER, 0);
- zassume_ok(tcpci_partner_send_data_msg(&fixture->src, PD_DATA_BIST,
+ zassert_ok(tcpci_partner_send_data_msg(&fixture->src, PD_DATA_BIST,
&bist_data, 1, 0),
"Failed to send BIST enter message");
@@ -181,7 +181,7 @@ ZTEST_F(usb_pd_bist_shared, verify_bist_shared_exit_no_action)
tcpci_snk_emul_clear_last_5v_cap(&fixture->snk_ext_500ma);
bist_data = BDO(BDO_MODE_SHARED_EXIT, 0);
- zassume_ok(tcpci_partner_send_data_msg(&fixture->sink_5v_500ma,
+ zassert_ok(tcpci_partner_send_data_msg(&fixture->sink_5v_500ma,
PD_DATA_BIST, &bist_data, 1, 0),
"Failed to send BIST exit message");
@@ -198,7 +198,7 @@ ZTEST_F(usb_pd_bist_shared, verify_control_bist_shared_mode)
uint32_t f5v_cap;
host_cmd_typec_control_bist_share_mode(USBC_PORT_C0, 1);
- zassume_ok(tcpci_partner_send_control_msg(&fixture->sink_5v_500ma,
+ zassert_ok(tcpci_partner_send_control_msg(&fixture->sink_5v_500ma,
PD_CTRL_GET_SOURCE_CAP, 0),
"Failed to send get src cap");
/* wait tSenderResponse (26 ms) */
diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c
index e35e2a7ec1..1d3da4921f 100644
--- a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c
+++ b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_ctrl_msg.c
@@ -3,9 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-#include <zephyr/ztest.h>
-
#include "common.h"
#include "ec_tasks.h"
#include "emul/emul_isl923x.h"
@@ -17,6 +14,10 @@
#include "test/usb_pe.h"
#include "usb_pd.h"
+#include <stdint.h>
+
+#include <zephyr/ztest.h>
+
#define TEST_USB_PORT 0
BUILD_ASSERT(TEST_USB_PORT == USBC_PORT_C0);
@@ -59,13 +60,13 @@ tcpci_drp_emul_connect_partner(struct tcpci_partner_data *partner_emul,
tcpci_tcpc_alert(TEST_USB_PORT);
- zassume_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpci_emul),
+ zassert_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpci_emul),
NULL);
}
static void disconnect_partner(struct usb_pd_ctrl_msg_test_fixture *fixture)
{
- zassume_ok(tcpci_emul_disconnect_partner(fixture->tcpci_emul));
+ zassert_ok(tcpci_emul_disconnect_partner(fixture->tcpci_emul));
k_sleep(K_SECONDS(1));
}
diff --git a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c
index fdea74a691..781a0cc06a 100644
--- a/zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c
+++ b/zephyr/test/drivers/default/src/integration/usbc/usb_pd_rev3.c
@@ -3,10 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/sys/byteorder.h>
-#include <zephyr/sys/slist.h>
-#include <zephyr/ztest.h>
-
#include "battery.h"
#include "battery_smart.h"
#include "chipset.h"
@@ -21,6 +17,10 @@
#include "usb_pd.h"
#include "util.h"
+#include <zephyr/sys/byteorder.h>
+#include <zephyr/sys/slist.h>
+#include <zephyr/ztest.h>
+
struct usb_attach_5v_3a_pd_source_rev3_fixture {
struct tcpci_partner_data source_5v_3a;
struct tcpci_src_emul_data src_ext;
@@ -62,11 +62,11 @@ static void usb_attach_5v_3a_pd_source_before(void *data)
/* Clear Alert and Status receive checks */
tcpci_src_emul_clear_alert_received(&fixture->src_ext);
tcpci_src_emul_clear_status_received(&fixture->src_ext);
- zassume_false(fixture->src_ext.alert_received);
- zassume_false(fixture->src_ext.status_received);
+ zassert_false(fixture->src_ext.alert_received);
+ zassert_false(fixture->src_ext.status_received);
/* Initial check on power state */
- zassume_true(chipset_in_state(CHIPSET_STATE_ON));
+ zassert_true(chipset_in_state(CHIPSET_STATE_ON));
}
static void usb_attach_5v_3a_pd_source_after(void *data)
@@ -112,8 +112,8 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, test_batt_cap)
/* See pe_give_battery_cap_entry() in common/usbc/usb_pe_drp_sm.c */
- zassume_true(battery_is_present(), "Battery must be present");
- zassume_true(IS_ENABLED(HAS_TASK_HOSTCMD) &&
+ zassert_true(battery_is_present(), "Battery must be present");
+ zassert_true(IS_ENABLED(HAS_TASK_HOSTCMD) &&
*host_get_memmap(EC_MEMMAP_BATTERY_VERSION) != 0,
"Cannot access battery data");
@@ -171,7 +171,7 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, test_batt_cap_invalid)
ZTEST_F(usb_attach_5v_3a_pd_source_rev3, verify_alert_msg)
{
- zassume_equal(pd_broadcast_alert_msg(ADO_OTP_EVENT), EC_SUCCESS);
+ zassert_equal(pd_broadcast_alert_msg(ADO_OTP_EVENT), EC_SUCCESS);
k_sleep(K_SECONDS(2));
zassert_true(fixture->src_ext.alert_received);
@@ -186,8 +186,8 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, verify_alert_on_power_state_change)
zassert_true(fixture->src_ext.status_received);
tcpci_src_emul_clear_alert_received(&fixture->src_ext);
tcpci_src_emul_clear_status_received(&fixture->src_ext);
- zassume_false(fixture->src_ext.alert_received);
- zassume_false(fixture->src_ext.status_received);
+ zassert_false(fixture->src_ext.alert_received);
+ zassert_false(fixture->src_ext.status_received);
/* Shutdown and check partner received Alert and Status messages */
hook_notify(HOOK_CHIPSET_SHUTDOWN);
@@ -196,8 +196,8 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, verify_alert_on_power_state_change)
zassert_true(fixture->src_ext.status_received);
tcpci_src_emul_clear_alert_received(&fixture->src_ext);
tcpci_src_emul_clear_status_received(&fixture->src_ext);
- zassume_false(fixture->src_ext.alert_received);
- zassume_false(fixture->src_ext.status_received);
+ zassert_false(fixture->src_ext.alert_received);
+ zassert_false(fixture->src_ext.status_received);
/* Startup and check partner received Alert and Status messages */
hook_notify(HOOK_CHIPSET_STARTUP);
@@ -206,8 +206,8 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, verify_alert_on_power_state_change)
zassert_true(fixture->src_ext.status_received);
tcpci_src_emul_clear_alert_received(&fixture->src_ext);
tcpci_src_emul_clear_status_received(&fixture->src_ext);
- zassume_false(fixture->src_ext.alert_received);
- zassume_false(fixture->src_ext.status_received);
+ zassert_false(fixture->src_ext.alert_received);
+ zassert_false(fixture->src_ext.status_received);
/* Resume and check partner received Alert and Status messages */
hook_notify(HOOK_CHIPSET_RESUME);
@@ -247,9 +247,9 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3,
/* Clear alert and status flags set during shutdown */
tcpci_src_emul_clear_alert_received(&fixture->src_ext);
tcpci_src_emul_clear_status_received(&fixture->src_ext);
- zassume_false(fixture->src_ext.alert_received);
- zassume_false(fixture->src_ext.status_received);
- zassume_true(chipset_in_state(CHIPSET_STATE_ANY_OFF));
+ zassert_false(fixture->src_ext.alert_received);
+ zassert_false(fixture->src_ext.status_received);
+ zassert_true(chipset_in_state(CHIPSET_STATE_ANY_OFF));
/* While in S5/G3 expect nothing on invalid (too long) press */
ado = ADO_EXTENDED_ALERT_EVENT | ADO_POWER_BUTTON_PRESS;
@@ -283,9 +283,9 @@ ZTEST_F(usb_attach_5v_3a_pd_source_rev3, verify_startup_on_pd_button_press)
/* Clear alert and status flags set during shutdown */
tcpci_src_emul_clear_alert_received(&fixture->src_ext);
tcpci_src_emul_clear_status_received(&fixture->src_ext);
- zassume_false(fixture->src_ext.alert_received);
- zassume_false(fixture->src_ext.status_received);
- zassume_true(chipset_in_state(CHIPSET_STATE_ANY_OFF));
+ zassert_false(fixture->src_ext.alert_received);
+ zassert_false(fixture->src_ext.status_received);
+ zassert_true(chipset_in_state(CHIPSET_STATE_ANY_OFF));
/* While in S5/G3 expect Alert->Get_Status->Status on valid press */
ado = ADO_EXTENDED_ALERT_EVENT | ADO_POWER_BUTTON_PRESS;
diff --git a/zephyr/test/drivers/default/src/isl923x.c b/zephyr/test/drivers/default/src/isl923x.c
index e17dbbe797..1393466c76 100644
--- a/zephyr/test/drivers/default/src/isl923x.c
+++ b/zephyr/test/drivers/default/src/isl923x.c
@@ -3,21 +3,21 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/emul.h>
-#include <zephyr/fff.h>
-
#include "battery.h"
#include "battery_smart.h"
-#include "test/drivers/charger_utils.h"
#include "driver/charger/isl923x.h"
#include "driver/charger/isl923x_public.h"
#include "emul/emul_common_i2c.h"
#include "emul/emul_isl923x.h"
#include "system.h"
+#include "test/drivers/charger_utils.h"
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include <zephyr/drivers/emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
BUILD_ASSERT(CONFIG_CHARGER_SENSE_RESISTOR == 10 ||
CONFIG_CHARGER_SENSE_RESISTOR == 5);
@@ -681,9 +681,9 @@ ZTEST(isl923x, test_init_late_jump)
isl923x_drv.get_input_current_limit(CHARGER_NUM,
&input_current),
"Could not read input current limit.");
- zassert_equal(CONFIG_CHARGER_INPUT_CURRENT, input_current,
+ zassert_equal(CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT, input_current,
"Input current (%d) not at (%d)", input_current,
- CONFIG_CHARGER_INPUT_CURRENT);
+ CONFIG_CHARGER_DEFAULT_CURRENT_LIMIT);
}
ZTEST(isl923x, test_isl923x_is_acok)
diff --git a/zephyr/test/drivers/default/src/led.c b/zephyr/test/drivers/default/src/led.c
index e89a3d8b66..3f727599b4 100644
--- a/zephyr/test/drivers/default/src/led.c
+++ b/zephyr/test/drivers/default/src/led.c
@@ -3,12 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/ztest_assert.h>
-
-#include <zephyr/device.h>
-#include <zephyr/drivers/pwm.h>
-
#include "ec_commands.h"
#include "led.h"
#include "led_common.h"
@@ -16,6 +10,11 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/device.h>
+#include <zephyr/drivers/pwm.h>
+#include <zephyr/ztest.h>
+#include <zephyr/ztest_assert.h>
+
ZTEST_SUITE(pwm_led_driver, drivers_predicate_post_main, NULL, NULL, NULL,
NULL);
diff --git a/zephyr/test/drivers/default/src/lid_angle.c b/zephyr/test/drivers/default/src/lid_angle.c
index 568057d95a..3611e176d4 100644
--- a/zephyr/test/drivers/default/src/lid_angle.c
+++ b/zephyr/test/drivers/default/src/lid_angle.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "ec_commands.h"
#include "lid_angle.h"
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
#define LID_ANGLE_MIN_LARGE_ANGLE 0
#define LID_ANGLE_MAX_LARGE_ANGLE 360
diff --git a/zephyr/test/drivers/default/src/lid_switch.c b/zephyr/test/drivers/default/src/lid_switch.c
index b5da1f6608..2fe7daa85a 100644
--- a/zephyr/test/drivers/default/src/lid_switch.c
+++ b/zephyr/test/drivers/default/src/lid_switch.c
@@ -3,18 +3,19 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
+#include "ec_commands.h"
+#include "host_command.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+
#include <zephyr/drivers/emul.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <lid_switch.h>
#include <zephyr/shell/shell_dummy.h>
-#include <console.h>
+#include <zephyr/ztest.h>
-#include "test/drivers/test_state.h"
-#include "test/drivers/utils.h"
-#include "ec_commands.h"
-#include "host_command.h"
+#include <console.h>
+#include <lid_switch.h>
#define LID_GPIO_PATH DT_PATH(named_gpios, lid_open_ec)
#define LID_GPIO_PIN DT_GPIO_PIN(LID_GPIO_PATH, gpios)
@@ -49,8 +50,8 @@ static void *lid_switch_setup(void)
static void lid_switch_before(void *unused)
{
/* Make sure that interrupt fire at the next lid open/close */
- zassume_ok(emul_lid_close());
- zassume_ok(emul_lid_open());
+ zassert_ok(emul_lid_close());
+ zassert_ok(emul_lid_open());
k_sleep(K_MSEC(100));
}
diff --git a/zephyr/test/drivers/default/src/lis2dw12.c b/zephyr/test/drivers/default/src/lis2dw12.c
index 8f5e30e559..4cacf725ba 100644
--- a/zephyr/test/drivers/default/src/lis2dw12.c
+++ b/zephyr/test/drivers/default/src/lis2dw12.c
@@ -3,13 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/emul.h>
#include "driver/accel_lis2dw12.h"
#include "emul/emul_common_i2c.h"
#include "emul/emul_lis2dw12.h"
#include "test/drivers/test_state.h"
+#include <zephyr/drivers/emul.h>
+#include <zephyr/ztest.h>
+
#define LIS2DW12_NODELABEL DT_NODELABEL(ms_lis2dw12_accel)
#define LIS2DW12_SENSOR_ID SENSOR_ID(LIS2DW12_NODELABEL)
#define LIS2DW12_EMUL_NODE DT_NODELABEL(lis2dw12_emul)
diff --git a/zephyr/test/drivers/default/src/ln9310.c b/zephyr/test/drivers/default/src/ln9310.c
index 414c62287c..509d6831ec 100644
--- a/zephyr/test/drivers/default/src/ln9310.c
+++ b/zephyr/test/drivers/default/src/ln9310.c
@@ -3,17 +3,17 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/emul.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest_assert.h>
-#include <zephyr/drivers/i2c_emul.h>
-
#include "driver/ln9310.h"
-#include "emul/emul_ln9310.h"
#include "emul/emul_common_i2c.h"
-#include "timer.h"
+#include "emul/emul_ln9310.h"
#include "test/drivers/test_state.h"
+#include "timer.h"
+
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+#include <zephyr/ztest_assert.h>
/*
* TODO(b/201420132): Implement approach for tests to immediately schedule work
diff --git a/zephyr/test/drivers/default/src/locate_chip.c b/zephyr/test/drivers/default/src/locate_chip.c
index 6842543971..c54031c5df 100644
--- a/zephyr/test/drivers/default/src/locate_chip.c
+++ b/zephyr/test/drivers/default/src/locate_chip.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
+#include "host_command.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+
#include <zephyr/fff.h>
-#include <zephyr/shell/shell.h>
#include <zephyr/kernel.h>
+#include <zephyr/shell/shell.h>
#include <zephyr/ztest.h>
-#include "test/drivers/test_state.h"
-#include "test/drivers/utils.h"
-#include "host_command.h"
-
/**
* @brief TestPurpose: test the TCPC locate valid case.
*/
diff --git a/zephyr/test/drivers/default/src/motion_sense/motion_sense.c b/zephyr/test/drivers/default/src/motion_sense/motion_sense.c
index 42ee056874..8291e0e1c6 100644
--- a/zephyr/test/drivers/default/src/motion_sense/motion_sense.c
+++ b/zephyr/test/drivers/default/src/motion_sense/motion_sense.c
@@ -3,11 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "motion_sense.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
+extern enum chipset_state_mask sensor_active;
+
ZTEST_SUITE(motion_sense, drivers_predicate_post_main, NULL, NULL, NULL, NULL);
ZTEST_USER(motion_sense, ec_motion_sensor_fill_values)
@@ -33,3 +35,17 @@ ZTEST_USER(motion_sense, ec_motion_sensor_clamp_i16)
zassert_equal(ec_motion_sensor_clamp_i16(INT16_MIN - 1), INT16_MIN,
NULL);
}
+
+ZTEST_USER(motion_sense, ec_motion_sense_get_ec_config)
+{
+ /* illegal state, should be translated to S5 */
+ sensor_active = 42;
+ zassert_equal(motion_sense_get_ec_config(), SENSOR_CONFIG_EC_S5);
+ /* all valid states */
+ sensor_active = SENSOR_ACTIVE_S0;
+ zassert_equal(motion_sense_get_ec_config(), SENSOR_CONFIG_EC_S0);
+ sensor_active = SENSOR_ACTIVE_S3;
+ zassert_equal(motion_sense_get_ec_config(), SENSOR_CONFIG_EC_S3);
+ sensor_active = SENSOR_ACTIVE_S5;
+ zassert_equal(motion_sense_get_ec_config(), SENSOR_CONFIG_EC_S5);
+}
diff --git a/zephyr/test/drivers/default/src/panic.c b/zephyr/test/drivers/default/src/panic.c
index 7dcb18e4cf..a2addc786d 100644
--- a/zephyr/test/drivers/default/src/panic.c
+++ b/zephyr/test/drivers/default/src/panic.c
@@ -8,18 +8,17 @@
* @brief Unit Tests for panic.
*/
-#include <zephyr/device.h>
-
-#include <zephyr/logging/log.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "common.h"
#include "ec_tasks.h"
#include "panic.h"
#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
+#include <zephyr/device.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/ztest.h>
+
struct panic_test_fixture {
struct panic_data saved_pdata;
};
diff --git a/zephyr/test/drivers/default/src/panic_output.c b/zephyr/test/drivers/default/src/panic_output.c
index 210c862901..f815744d8c 100644
--- a/zephyr/test/drivers/default/src/panic_output.c
+++ b/zephyr/test/drivers/default/src/panic_output.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "panic.h"
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
ZTEST_SUITE(panic_output, drivers_predicate_post_main, NULL, NULL, NULL, NULL);
ZTEST(panic_output, test_panic_printf)
diff --git a/zephyr/test/drivers/default/src/port80.c b/zephyr/test/drivers/default/src/port80.c
index 8563c2e478..6bde1392c7 100644
--- a/zephyr/test/drivers/default/src/port80.c
+++ b/zephyr/test/drivers/default/src/port80.c
@@ -8,19 +8,18 @@
* @brief Unit Tests for ESPI port 80 writes
*/
-#include <zephyr/logging/log.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "host_command.h"
#include "port80.h"
-
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
/*
* Flush any existing writes.
*/
diff --git a/zephyr/test/drivers/default/src/power_common.c b/zephyr/test/drivers/default/src/power_common.c
index f96fed9f05..2b8ba4ac88 100644
--- a/zephyr/test/drivers/default/src/power_common.c
+++ b/zephyr/test/drivers/default/src/power_common.c
@@ -3,31 +3,30 @@
* found in the LICENSE file.
*/
-#include <string.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/shell/shell_uart.h>
-
+#include "battery.h"
+#include "battery_smart.h"
#include "chipset.h"
#include "common.h"
+#include "ec_tasks.h"
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_smart_battery.h"
#include "extpower.h"
#include "hooks.h"
#include "host_command.h"
#include "power.h"
-#include "test/drivers/stubs.h"
#include "task.h"
-#include "ec_tasks.h"
+#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_smart_battery.h"
+#include <string.h>
-#include "battery.h"
-#include "battery_smart.h"
-#include "test/drivers/utils.h"
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/shell/shell_uart.h>
+#include <zephyr/ztest.h>
#define BATTERY_NODE DT_NODELABEL(battery)
@@ -488,6 +487,19 @@ ZTEST(power_common, power_console_cmd)
}
/**
+ * Test powerinfo console command
+ */
+ZTEST_USER(power_common, powerinfo_console_cmd)
+{
+ char expected_buffer[32];
+
+ snprintf(expected_buffer, sizeof(expected_buffer), "power state %d",
+ power_get_state());
+
+ CHECK_CONSOLE_CMD("powerinfo", expected_buffer, EC_SUCCESS);
+}
+
+/**
* Common setup for hibernation delay tests. Smart discharge zone is setup,
* battery is set in safe zone (which trigger hibernation), power state is
* set to G3 and AC is disabled. system_hibernate mock is reset.
diff --git a/zephyr/test/drivers/default/src/ppc_sn5s330.c b/zephyr/test/drivers/default/src/ppc_sn5s330.c
index eb595939fc..664d9fed36 100644
--- a/zephyr/test/drivers/default/src/ppc_sn5s330.c
+++ b/zephyr/test/drivers/default/src/ppc_sn5s330.c
@@ -3,20 +3,20 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/device.h>
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/emul.h>
-#include <zephyr/ztest.h>
-#include <zephyr/fff.h>
-
#include "driver/ppc/sn5s330.h"
#include "driver/ppc/sn5s330_public.h"
#include "emul/emul_common_i2c.h"
#include "emul/emul_sn5s330.h"
-#include "usbc_ppc.h"
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include "usbc_ppc.h"
+
+#include <zephyr/device.h>
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
/** This must match the index of the sn5s330 in ppc_chips[] */
#define SN5S330_PORT 0
diff --git a/zephyr/test/drivers/default/src/ppc_syv682x.c b/zephyr/test/drivers/default/src/ppc_syv682x.c
index ba2e68f2ff..6e1602804e 100644
--- a/zephyr/test/drivers/default/src/ppc_syv682x.c
+++ b/zephyr/test/drivers/default/src/ppc_syv682x.c
@@ -3,24 +3,24 @@
* found in the LICENSE file.
*/
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_syv682x.h"
+#include "syv682x.h"
+#include "test/drivers/stubs.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+#include "timer.h"
+#include "usbc_ppc.h"
+
#include <zephyr/device.h>
#include <zephyr/devicetree/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
#include <zephyr/fff.h>
#include <zephyr/kernel.h>
#include <zephyr/ztest.h>
#include <zephyr/ztest_assert.h>
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_syv682x.h"
-#include "test/drivers/stubs.h"
-#include "syv682x.h"
-#include "timer.h"
-#include "test/drivers/test_state.h"
-#include "test/drivers/utils.h"
-#include "usbc_ppc.h"
-
#define SYV682X_NODE DT_NODELABEL(syv682x_emul)
#define GPIO_USB_C1_FRS_EN_PATH DT_PATH(named_gpios, usb_c1_frs_en)
@@ -46,10 +46,10 @@ static void *syv682x_test_setup(void)
fixture.ppc_emul = EMUL_DT_GET(SYV682X_NODE);
fixture.common_data =
emul_syv682x_get_i2c_common_data(fixture.ppc_emul);
- zassume_not_null(fixture.ppc_emul, NULL);
+ zassert_not_null(fixture.ppc_emul, NULL);
fixture.frs_en_gpio_port =
DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_USB_C1_FRS_EN_PATH, gpios));
- zassume_not_null(fixture.frs_en_gpio_port, NULL);
+ zassert_not_null(fixture.frs_en_gpio_port, NULL);
fixture.frs_en_gpio_pin = DT_GPIO_PIN(GPIO_USB_C1_FRS_EN_PATH, gpios);
return &fixture;
@@ -62,7 +62,7 @@ static void syv682x_test_after(void *data)
struct i2c_common_emul_data *common_data = fixture->common_data;
/* Disable the power path and clear interrupt conditions. */
- zassume_ok(syv682x_emul_set_reg(emul, SYV682X_CONTROL_1_REG,
+ zassert_ok(syv682x_emul_set_reg(emul, SYV682X_CONTROL_1_REG,
SYV682X_CONTROL_1_PWR_ENB),
NULL);
syv682x_emul_set_condition(emul, SYV682X_STATUS_NONE,
@@ -120,14 +120,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_init_dead_battery)
* With a dead battery, the device powers up sinking VBUS, and the
* driver should keep that going.
*/
- zassume_ok(syv682x_emul_set_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_set_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG,
SYV682X_CONTROL_1_CH_SEL),
NULL);
syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_VSAFE_5V,
SYV682X_CONTROL_4_NONE);
zassert_ok(ppc_init(syv682x_port), "PPC init failed");
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
NULL);
zassert_true(reg & SYV682X_CONTROL_1_CH_SEL,
@@ -144,14 +144,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_init_vsafe0v)
uint8_t reg;
/* With VBUS at vSafe0V, init should set the default configuration. */
- zassume_ok(syv682x_emul_set_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_set_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG,
SYV682X_CONTROL_1_PWR_ENB),
NULL);
syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_VSAFE_0V,
SYV682X_CONTROL_4_NONE);
zassert_ok(ppc_init(syv682x_port), "PPC init failed");
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
NULL);
check_control_1_default_init(reg);
@@ -162,14 +162,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_init_sink_disabled)
uint8_t reg;
/* With sink disabled, init should do the same thing. */
- zassume_ok(syv682x_emul_set_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_set_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG,
SYV682X_CONTROL_1_CH_SEL),
NULL);
syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_VSAFE_0V,
SYV682X_CONTROL_4_NONE);
zassert_ok(ppc_init(syv682x_port), "PPC init failed");
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
NULL);
check_control_1_default_init(reg);
@@ -181,7 +181,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_init_common)
int ilim;
zassert_ok(ppc_init(syv682x_port), "PPC init failed");
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
NULL);
@@ -196,7 +196,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_init_common)
ilim = (reg & SYV682X_5V_ILIM_MASK) >> SYV682X_5V_ILIM_BIT_SHIFT;
zassert_equal(ilim, CONFIG_PLATFORM_EC_USB_PD_PULLUP,
"Default init, but 5V current limit set to %d", ilim);
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_2_REG, &reg),
NULL);
zassert_equal(reg,
@@ -205,14 +205,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_init_common)
<< SYV682X_DSG_RON_SHIFT) |
(SYV682X_DSG_TIME_50MS << SYV682X_DSG_TIME_SHIFT),
"Default init, but CONTROL_2 is 0x%x", reg);
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_3_REG, &reg),
NULL);
zassert_equal(reg,
(SYV682X_OVP_23_7 << SYV682X_OVP_BIT_SHIFT) |
SYV682X_RVS_MASK,
"Default init, but CONTROL_3 is 0x%x", reg);
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_4_REG, &reg),
NULL);
zassert_equal(reg & ~SYV682X_CONTROL_4_INT_MASK,
@@ -226,7 +226,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_vbus_source_enable)
zassert_ok(ppc_vbus_source_enable(syv682x_port, true),
"VBUS enable failed");
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
"Reading CONTROL_1 failed");
zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB, 0,
@@ -245,7 +245,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_vbus_source_disable)
ZTEST_F(ppc_syv682x, test_syv682x_interrupt_source_oc)
{
- zassume_ok(ppc_vbus_source_enable(syv682x_port, true),
+ zassert_ok(ppc_vbus_source_enable(syv682x_port, true),
"VBUS enable failed");
/* An OC event less than 100 ms should not cause VBUS to turn off. */
syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_OC_5V,
@@ -266,7 +266,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_tsd)
* (The device will have already physically disabled them.) The state of
* the sink path is not part of the driver's API.
*/
- zassume_ok(ppc_vbus_source_enable(syv682x_port, true),
+ zassert_ok(ppc_vbus_source_enable(syv682x_port, true),
"Source enable failed");
syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_TSD,
SYV682X_CONTROL_4_NONE);
@@ -278,7 +278,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_tsd)
ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vbus_ovp)
{
/* An OVP event should cause the driver to disable the source path. */
- zassume_ok(ppc_vbus_source_enable(syv682x_port, true),
+ zassert_ok(ppc_vbus_source_enable(syv682x_port, true),
"Source enable failed");
syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_OVP,
SYV682X_CONTROL_4_NONE);
@@ -296,12 +296,12 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vbus_hv_oc)
* re-enable the sink path until the OC count limit is reached, at which
* point the driver should leave it disabled.
*/
- zassume_ok(ppc_vbus_sink_enable(syv682x_port, true),
+ zassert_ok(ppc_vbus_sink_enable(syv682x_port, true),
"Sink enable failed");
syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_OC_HV,
SYV682X_CONTROL_4_NONE);
msleep(1);
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
"Reading CONTROL_1 failed");
zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB, 0,
@@ -310,7 +310,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vbus_hv_oc)
SYV682X_CONTROL_4_NONE);
/* Alert GPIO doesn't change so wait for delayed syv682x interrupt */
msleep(15);
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
"Reading CONTROL_1 failed");
zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB, 0,
@@ -319,7 +319,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vbus_hv_oc)
SYV682X_CONTROL_4_NONE);
/* Alert GPIO doesn't change so wait for delayed syv682x interrupt */
msleep(15);
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
"Reading CONTROL_1 failed");
zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB,
@@ -339,14 +339,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vconn_oc)
syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_NONE,
SYV682X_CONTROL_4_VCONN_OCP);
msleep(1);
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_4_REG, &reg),
"Reading CONTROL_4 failed");
zassert_true(reg & (SYV682X_CONTROL_4_VCONN1 |
SYV682X_CONTROL_4_VCONN2),
"VCONN disabled after initial VCONN OC");
msleep(50);
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_4_REG, &reg),
"Reading CONTROL_4 failed");
zassert_true(reg & (SYV682X_CONTROL_4_VCONN1 |
@@ -357,7 +357,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vconn_oc)
* should turn VCONN off.
*/
msleep(60);
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_4_REG, &reg),
"Reading CONTROL_4 failed");
zassert_false(reg & (SYV682X_CONTROL_4_VCONN1 |
@@ -379,7 +379,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_interrupt_vconn_ov)
syv682x_emul_set_condition(fixture->ppc_emul, SYV682X_STATUS_NONE,
SYV682X_CONTROL_4_VBAT_OVP);
msleep(1);
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_4_REG, &reg),
"Reading CONTROL_4 failed");
zassert_true(reg & SYV682X_CONTROL_4_CC1_BPS,
@@ -402,7 +402,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_frs_enable)
* polarity. Disabling FRS should enable both CC lines.
*/
ppc_vbus_sink_enable(syv682x_port, true);
- zassume_false(ppc_is_sourcing_vbus(syv682x_port),
+ zassert_false(ppc_is_sourcing_vbus(syv682x_port),
"PPC is sourcing VBUS after sink enabled");
ppc_set_polarity(syv682x_port, 0 /* CC1 */);
ppc_set_frs_enable(syv682x_port, true);
@@ -424,14 +424,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_frs_disable)
uint8_t reg;
ppc_vbus_sink_enable(syv682x_port, true);
- zassume_false(ppc_is_sourcing_vbus(syv682x_port),
+ zassert_false(ppc_is_sourcing_vbus(syv682x_port),
"PPC is sourcing VBUS after sink enabled");
ppc_set_polarity(syv682x_port, 0 /* CC1 */);
ppc_set_frs_enable(syv682x_port, false);
zassert_equal(gpio_emul_output_get(gpio_dev, fixture->frs_en_gpio_pin),
0, "FRS disabled, but FRS GPIO not deasserted");
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_4_REG, &reg),
"Reading CONTROL_4 failed");
zassert_equal(
@@ -463,7 +463,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_source_current_limit_usb_default)
zassert_ok(ppc_set_vbus_source_current_limit(syv682x_port,
TYPEC_RP_USB),
"Could not set source current limit");
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
"Reading CONTROL_1 failed");
ilim_val = (reg & SYV682X_5V_ILIM_MASK) >> SYV682X_5V_ILIM_BIT_SHIFT;
@@ -479,7 +479,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_source_current_limit_1500ma)
zassert_ok(ppc_set_vbus_source_current_limit(syv682x_port,
TYPEC_RP_1A5),
"Could not set source current limit");
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
"Reading CONTROL_1 failed");
ilim_val = (reg & SYV682X_5V_ILIM_MASK) >> SYV682X_5V_ILIM_BIT_SHIFT;
@@ -495,7 +495,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_source_current_limit_3000ma)
zassert_ok(ppc_set_vbus_source_current_limit(syv682x_port,
TYPEC_RP_3A0),
"Could not set source current limit");
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
"Reading CONTROL_1 failed");
ilim_val = (reg & SYV682X_5V_ILIM_MASK) >> SYV682X_5V_ILIM_BIT_SHIFT;
@@ -561,7 +561,7 @@ ZTEST_F(ppc_syv682x, test_syv682x_vbus_sink_enable_trivial)
* If VBUS source is already enabled, disabling VBUS sink should
* trivially succeed.
*/
- zassume_ok(ppc_vbus_source_enable(syv682x_port, true),
+ zassert_ok(ppc_vbus_source_enable(syv682x_port, true),
"VBUS enable failed");
zassert_ok(ppc_vbus_sink_enable(syv682x_port, false),
"Sink disable failed");
@@ -576,11 +576,11 @@ ZTEST_F(ppc_syv682x, test_syv682x_vbus_sink_enable_power_path)
* After enabling VBUS sink, the HV power path should be enabled in sink
* mode with the configured current limit.
*/
- zassume_ok(ppc_vbus_source_enable(syv682x_port, false),
+ zassert_ok(ppc_vbus_source_enable(syv682x_port, false),
"VBUS enable failed");
zassert_ok(ppc_vbus_sink_enable(syv682x_port, true),
"Sink disable failed");
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
NULL);
zassert_true(reg & SYV682X_CONTROL_1_CH_SEL,
@@ -598,14 +598,14 @@ ZTEST_F(ppc_syv682x, test_syv682x_vbus_sink_disable)
{
uint8_t reg;
- zassume_ok(ppc_vbus_source_enable(syv682x_port, false),
+ zassert_ok(ppc_vbus_source_enable(syv682x_port, false),
"VBUS enable failed");
zassert_ok(ppc_vbus_sink_enable(syv682x_port, true),
"Sink disable failed");
zassert_ok(ppc_vbus_sink_enable(syv682x_port, false),
"Sink disable failed");
- zassume_ok(syv682x_emul_get_reg(fixture->ppc_emul,
+ zassert_ok(syv682x_emul_get_reg(fixture->ppc_emul,
SYV682X_CONTROL_1_REG, &reg),
NULL);
zassert_true(reg & SYV682X_CONTROL_1_PWR_ENB,
diff --git a/zephyr/test/drivers/default/src/ps8xxx.c b/zephyr/test/drivers/default/src/ps8xxx.c
index 2aa1844c10..cb0ac7d2d5 100644
--- a/zephyr/test/drivers/default/src/ps8xxx.c
+++ b/zephyr/test/drivers/default/src/ps8xxx.c
@@ -3,22 +3,21 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "common.h"
+#include "driver/tcpm/ps8xxx.h"
+#include "driver/tcpm/ps8xxx_public.h"
#include "emul/emul_common_i2c.h"
-#include "emul/tcpc/emul_tcpci.h"
#include "emul/tcpc/emul_ps8xxx.h"
-#include "timer.h"
+#include "emul/tcpc/emul_tcpci.h"
#include "i2c.h"
+#include "tcpm/tcpci.h"
#include "test/drivers/stubs.h"
#include "test/drivers/tcpci_test_common.h"
-
-#include "tcpm/tcpci.h"
-#include "driver/tcpm/ps8xxx.h"
-#include "driver/tcpm/ps8xxx_public.h"
#include "test/drivers/test_state.h"
+#include "timer.h"
+
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
#define PS8XXX_EMUL_NODE DT_NODELABEL(ps8xxx_emul)
@@ -1411,7 +1410,7 @@ static void ps8805_before(void *state)
board_set_ps8xxx_product_id(PS8805_PRODUCT_ID);
ps8xxx_emul_set_product_id(ps8xxx_emul, PS8805_PRODUCT_ID);
setup_no_fail_all();
- zassume_equal(EC_SUCCESS, ps8xxx_tcpm_drv.init(USBC_PORT_C1));
+ zassert_equal(EC_SUCCESS, ps8xxx_tcpm_drv.init(USBC_PORT_C1));
}
static void ps8805_after(void *state)
@@ -1436,7 +1435,7 @@ static void ps8815_before(void *state)
ps8xxx_emul_set_reg_id(ps8xxx_emul, PS8815_REG_ID);
ps8xxx_emul_set_product_id(ps8xxx_emul, PS8815_PRODUCT_ID);
setup_no_fail_all();
- zassume_equal(EC_SUCCESS, ps8xxx_tcpm_drv.init(USBC_PORT_C1));
+ zassert_equal(EC_SUCCESS, ps8xxx_tcpm_drv.init(USBC_PORT_C1));
}
static void ps8815_after(void *state)
@@ -1461,7 +1460,7 @@ static void ps8745_before(void *state)
ps8xxx_emul_set_product_id(ps8xxx_emul, PS8815_PRODUCT_ID);
ps8xxx_emul_set_reg_id(ps8xxx_emul, PS8745_REG_ID);
setup_no_fail_all();
- zassume_equal(EC_SUCCESS, ps8xxx_tcpm_drv.init(USBC_PORT_C1), NULL);
+ zassert_equal(EC_SUCCESS, ps8xxx_tcpm_drv.init(USBC_PORT_C1), NULL);
}
static void ps8745_after(void *state)
diff --git a/zephyr/test/drivers/default/src/smart.c b/zephyr/test/drivers/default/src/smart.c
index 9db292ac96..a26d84b93c 100644
--- a/zephyr/test/drivers/default/src/smart.c
+++ b/zephyr/test/drivers/default/src/smart.c
@@ -3,21 +3,20 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/shell/shell_uart.h>
-
+#include "battery.h"
+#include "battery_smart.h"
#include "common.h"
#include "console.h"
-#include "i2c.h"
#include "emul/emul_common_i2c.h"
#include "emul/emul_smart_battery.h"
-
-#include "battery.h"
-#include "battery_smart.h"
+#include "i2c.h"
#include "test/drivers/test_state.h"
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/shell/shell_uart.h>
+#include <zephyr/ztest.h>
+
#define BATTERY_NODE DT_NODELABEL(battery)
/** Test all simple getters */
diff --git a/zephyr/test/drivers/default/src/stm_mems_common.c b/zephyr/test/drivers/default/src/stm_mems_common.c
index f7c59105b0..09f1cf8506 100644
--- a/zephyr/test/drivers/default/src/stm_mems_common.c
+++ b/zephyr/test/drivers/default/src/stm_mems_common.c
@@ -3,11 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/device.h>
-#include <zephyr/devicetree.h>
-#include <errno.h>
-
#include "common.h"
#include "driver/stm_mems_common.h"
#include "emul/emul_common_i2c.h"
@@ -15,6 +10,12 @@
#include "i2c/i2c.h"
#include "test/drivers/test_state.h"
+#include <errno.h>
+
+#include <zephyr/device.h>
+#include <zephyr/devicetree.h>
+#include <zephyr/ztest.h>
+
#define MOCK_EMUL EMUL_DT_GET(DT_NODELABEL(i2c_mock))
#define COMMON_DATA emul_i2c_mock_get_i2c_common_data(MOCK_EMUL)
diff --git a/zephyr/test/drivers/default/src/tablet_mode.c b/zephyr/test/drivers/default/src/tablet_mode.c
index d600d26072..773f2c2bf8 100644
--- a/zephyr/test/drivers/default/src/tablet_mode.c
+++ b/zephyr/test/drivers/default/src/tablet_mode.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
-#include <zephyr/fff.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "tablet_mode.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/fff.h>
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
static void tabletmode_before(void *state)
{
ARG_UNUSED(state);
@@ -34,27 +34,31 @@ ZTEST_USER(tabletmode, test_tablet_set_mode)
int ret;
ret = tablet_get_mode();
- zassert_equal(ret, 0, "unexepcted tablet initial mode: %d", ret);
+ zassert_equal(ret, 0, "unexpected tablet initial mode: %d", ret);
tablet_set_mode(1, TABLET_TRIGGER_LID);
-
ret = tablet_get_mode();
- zassert_equal(ret, 1, "unexepcted tablet mode: %d", ret);
+ zassert_equal(ret, 1, "unexpected tablet mode: %d", ret);
tablet_set_mode(1, TABLET_TRIGGER_BASE);
-
ret = tablet_get_mode();
- zassert_equal(ret, 1, "unexepcted tablet mode: %d", ret);
+ zassert_equal(ret, 1, "unexpected tablet mode: %d", ret);
+ /**
+ * Tablet mode should remain enabled, since both _LID and _BASE were set
+ * previously, and this only clears _LID.
+ */
tablet_set_mode(0, TABLET_TRIGGER_LID);
-
ret = tablet_get_mode();
- zassert_equal(ret, 1, "unexepcted tablet mode: %d", ret);
+ zassert_equal(ret, 1, "unexpected tablet mode: %d", ret);
+ /**
+ * Both _LID and _BASE are now cleared, so DUT is no longer in tablet
+ * mode.
+ */
tablet_set_mode(0, TABLET_TRIGGER_BASE);
-
ret = tablet_get_mode();
- zassert_equal(ret, 0, "unexepcted tablet mode: %d", ret);
+ zassert_equal(ret, 0, "unexpected tablet mode: %d", ret);
}
/**
@@ -65,13 +69,13 @@ ZTEST_USER(tabletmode, test_tablet_disable)
int ret;
ret = tablet_get_mode();
- zassert_equal(ret, 0, "unexepcted tablet initial mode: %d", ret);
+ zassert_equal(ret, 0, "unexpected tablet initial mode: %d", ret);
tablet_disable();
tablet_set_mode(1, TABLET_TRIGGER_LID);
ret = tablet_get_mode();
- zassert_equal(ret, 0, "unexepcted tablet mode: %d", ret);
+ zassert_equal(ret, 0, "unexpected tablet mode: %d", ret);
}
/**
@@ -82,28 +86,28 @@ ZTEST_USER(tabletmode, test_settabletmode_on_off)
int ret;
ret = tablet_get_mode();
- zassert_equal(ret, 0, "unexepcted tablet initial mode: %d", ret);
+ zassert_equal(ret, 0, "unexpected tablet initial mode: %d", ret);
ret = shell_execute_cmd(get_ec_shell(), "tabletmode");
- zassert_equal(ret, EC_SUCCESS, "unexepcted command return status: %d",
+ zassert_equal(ret, EC_SUCCESS, "unexpected command return status: %d",
ret);
ret = tablet_get_mode();
- zassert_equal(ret, 0, "unexepcted tablet mode: %d", ret);
+ zassert_equal(ret, 0, "unexpected tablet mode: %d", ret);
ret = shell_execute_cmd(get_ec_shell(), "tabletmode on");
- zassert_equal(ret, EC_SUCCESS, "unexepcted command return status: %d",
+ zassert_equal(ret, EC_SUCCESS, "unexpected command return status: %d",
ret);
ret = tablet_get_mode();
- zassert_equal(ret, 1, "unexepcted tablet mode: %d", ret);
+ zassert_equal(ret, 1, "unexpected tablet mode: %d", ret);
ret = shell_execute_cmd(get_ec_shell(), "tabletmode off");
- zassert_equal(ret, EC_SUCCESS, "unexepcted command return status: %d",
+ zassert_equal(ret, EC_SUCCESS, "unexpected command return status: %d",
ret);
ret = tablet_get_mode();
- zassert_equal(ret, 0, "unexepcted tablet mode: %d", ret);
+ zassert_equal(ret, 0, "unexpected tablet mode: %d", ret);
}
/**
@@ -115,28 +119,28 @@ ZTEST_USER(tabletmode, test_settabletmode_forced)
int ret;
ret = tablet_get_mode();
- zassert_equal(ret, 0, "unexepcted tablet initial mode: %d", ret);
+ zassert_equal(ret, 0, "unexpected tablet initial mode: %d", ret);
ret = shell_execute_cmd(get_ec_shell(), "tabletmode on");
- zassert_equal(ret, EC_SUCCESS, "unexepcted command return status: %d",
+ zassert_equal(ret, EC_SUCCESS, "unexpected command return status: %d",
ret);
ret = tablet_get_mode();
- zassert_equal(ret, 1, "unexepcted tablet mode: %d", ret);
+ zassert_equal(ret, 1, "unexpected tablet mode: %d", ret);
tablet_set_mode(0, TABLET_TRIGGER_LID);
ret = tablet_get_mode();
- zassert_equal(ret, 1, "unexepcted tablet mode: %d", ret);
+ zassert_equal(ret, 1, "unexpected tablet mode: %d", ret);
ret = shell_execute_cmd(get_ec_shell(), "tabletmode reset");
- zassert_equal(ret, EC_SUCCESS, "unexepcted command return status: %d",
+ zassert_equal(ret, EC_SUCCESS, "unexpected command return status: %d",
ret);
tablet_set_mode(0, TABLET_TRIGGER_LID);
ret = tablet_get_mode();
- zassert_equal(ret, 0, "unexepcted tablet mode: %d", ret);
+ zassert_equal(ret, 0, "unexpected tablet mode: %d", ret);
}
/**
@@ -149,7 +153,7 @@ ZTEST_USER(tabletmode, test_settabletmode_too_many_args)
ret = shell_execute_cmd(get_ec_shell(),
"tabletmode too many arguments");
zassert_equal(ret, EC_ERROR_PARAM_COUNT,
- "unexepcted command return status: %d", ret);
+ "unexpected command return status: %d", ret);
}
/**
@@ -161,7 +165,7 @@ ZTEST_USER(tabletmode, test_settabletmode_unknown_arg)
ret = shell_execute_cmd(get_ec_shell(), "tabletmode X");
zassert_equal(ret, EC_ERROR_PARAM1,
- "unexepcted command return status: %d", ret);
+ "unexpected command return status: %d", ret);
}
ZTEST_SUITE(tabletmode, drivers_predicate_post_main, NULL, tabletmode_before,
diff --git a/zephyr/test/drivers/default/src/task.c b/zephyr/test/drivers/default/src/task.c
new file mode 100644
index 0000000000..4c4087c5a1
--- /dev/null
+++ b/zephyr/test/drivers/default/src/task.c
@@ -0,0 +1,84 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "task.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+#include "timer.h"
+
+#include <zephyr/ztest.h>
+
+struct tasks_fixture {
+ timestamp_t fake_time;
+};
+
+static void *setup(void)
+{
+ static struct tasks_fixture fixture;
+
+ return &fixture;
+}
+
+static void before(void *f)
+{
+ struct tasks_fixture *fixture = f;
+
+ fixture->fake_time.val = 0;
+}
+
+static void after(void *f)
+{
+ ARG_UNUSED(f);
+
+ get_time_mock = NULL;
+}
+
+ZTEST_SUITE(tasks, drivers_predicate_post_main, setup, before, after, NULL);
+
+ZTEST(tasks, test_enable_irq)
+{
+ arch_irq_disable(0);
+ task_enable_irq(0);
+ zassert_true(arch_irq_is_enabled(0));
+}
+
+ZTEST(tasks, test_interrupt_context)
+{
+ zassert_false(in_interrupt_context());
+}
+
+ZTEST_F(tasks, test_timer_arm_before_now)
+{
+ timestamp_t deadline = {
+ .val = 5,
+ };
+
+ fixture->fake_time.val = 15;
+ get_time_mock = &fixture->fake_time;
+
+ zassert_ok(timer_arm(deadline, TASK_ID_MOTIONSENSE));
+ zassert_equal(*task_get_event_bitmap(TASK_ID_MOTIONSENSE) &
+ TASK_EVENT_TIMER,
+ TASK_EVENT_TIMER);
+}
+
+ZTEST_F(tasks, test_timer_arm_busy)
+{
+ timestamp_t deadline = {
+ .val = UINT64_C(5000000),
+ };
+
+ fixture->fake_time.val = 0;
+ get_time_mock = &fixture->fake_time;
+
+ zassert_ok(timer_arm(deadline, TASK_ID_MOTIONSENSE));
+ zassert_equal(EC_ERROR_BUSY, timer_arm(deadline, TASK_ID_MOTIONSENSE));
+}
+
+ZTEST(tasks, test_get_event_bitmap_invalid_tid)
+{
+ zassert_is_null(
+ task_get_event_bitmap(TASK_ID_COUNT + EXTRA_TASK_COUNT));
+}
diff --git a/zephyr/test/drivers/default/src/tcpci.c b/zephyr/test/drivers/default/src/tcpci.c
index db0ad076ab..f648b43a96 100644
--- a/zephyr/test/drivers/default/src/tcpci.c
+++ b/zephyr/test/drivers/default/src/tcpci.c
@@ -3,25 +3,27 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-
#include "common.h"
#include "ec_tasks.h"
#include "emul/emul_common_i2c.h"
#include "emul/tcpc/emul_tcpci.h"
#include "hooks.h"
#include "i2c.h"
+#include "tcpm/tcpci.h"
#include "test/drivers/stubs.h"
#include "test/drivers/tcpci_test_common.h"
-
-#include "tcpm/tcpci.h"
#include "test/drivers/test_state.h"
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
#define TCPCI_EMUL_NODE DT_NODELABEL(tcpci_emul)
+/* Convenience pointer directly to the TCPCI mux under test */
+static struct usb_mux *tcpci_usb_mux;
+
/** Test TCPCI init and vbus level */
ZTEST(tcpci, test_generic_tcpci_init)
{
@@ -288,13 +290,13 @@ ZTEST(tcpci, test_generic_tcpci_debug_accessory)
/* Setup TCPCI usb mux to behave as it is used only for usb mux */
static void set_usb_mux_not_tcpc(void)
{
- usbc0_mux0.flags = USB_MUX_FLAG_NOT_TCPC;
+ tcpci_usb_mux->flags = USB_MUX_FLAG_NOT_TCPC;
}
/* Setup TCPCI usb mux to behave as it is used for usb mux and TCPC */
static void set_usb_mux_tcpc(void)
{
- usbc0_mux0.flags = 0;
+ tcpci_usb_mux->flags = 0;
}
/** Test TCPCI mux init */
@@ -531,7 +533,6 @@ void validate_mux_read_write16(const struct usb_mux *tcpci_usb_mux)
/** Test usb_mux read/write APIs */
ZTEST(tcpci, test_usb_mux_read_write)
{
- struct usb_mux *tcpci_usb_mux = &usbc0_mux0;
const int flags_restore = tcpci_usb_mux->flags;
/* Configure mux read/writes for TCPC APIs */
@@ -552,6 +553,8 @@ static void *tcpci_setup(void)
&tcpci_tcpm_usb_mux_driver,
"Invalid config of usb_muxes in test/drivers/src/stubs.c");
+ tcpci_usb_mux = (struct usb_mux *)usb_muxes[USBC_PORT_C0].mux;
+
return NULL;
}
diff --git a/zephyr/test/drivers/default/src/tcpci_test_common.c b/zephyr/test/drivers/default/src/tcpci_test_common.c
index bbc1e3f8b0..06f03d4834 100644
--- a/zephyr/test/drivers/default/src/tcpci_test_common.c
+++ b/zephyr/test/drivers/default/src/tcpci_test_common.c
@@ -3,15 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "common.h"
#include "emul/emul_common_i2c.h"
#include "emul/tcpc/emul_tcpci.h"
+#include "tcpm/tcpci.h"
#include "test/drivers/tcpci_test_common.h"
-#include "tcpm/tcpci.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
/** Check TCPC register value */
void check_tcpci_reg_f(const struct emul *emul, int reg, uint16_t exp_val,
@@ -1020,7 +1019,7 @@ void test_tcpci_hard_reset_reinit(const struct emul *emul,
uint16_t power_status_mask;
uint16_t alert_mask;
- zassume_equal(EC_SUCCESS, drv->init(port), NULL);
+ zassert_equal(EC_SUCCESS, drv->init(port), NULL);
tcpci_emul_get_reg(emul, TCPC_REG_POWER_STATUS_MASK,
&power_status_mask);
tcpci_emul_get_reg(emul, TCPC_REG_ALERT_MASK, &alert_mask);
diff --git a/zephyr/test/drivers/default/src/tcpm_header.c b/zephyr/test/drivers/default/src/tcpm_header.c
new file mode 100644
index 0000000000..e03e09aaa5
--- /dev/null
+++ b/zephyr/test/drivers/default/src/tcpm_header.c
@@ -0,0 +1,235 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "tcpm/tcpm.h"
+#include "test/drivers/stubs.h"
+#include "test/drivers/test_state.h"
+
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
+#define TCPM_TEST_PORT USBC_PORT_C0
+
+FAKE_VALUE_FUNC(int, set_vconn, int, int);
+FAKE_VALUE_FUNC(int, reset_bist_type_2, int);
+FAKE_VALUE_FUNC(int, debug_accessory, int, bool);
+FAKE_VALUE_FUNC(int, debug_detach, int);
+FAKE_VALUE_FUNC(int, hard_reset_reinit, int);
+FAKE_VALUE_FUNC(int, set_frs_enable, int, int);
+FAKE_VOID_FUNC(tcpc_dump_std_registers, int);
+
+struct tcpm_header_fixture {
+ /* The original driver pointer that gets restored after the tests */
+ const struct tcpm_drv *saved_driver_ptr;
+ /* Mock driver that gets substituted */
+ struct tcpm_drv mock_driver;
+ /* Saved tcpc config flags that get restored after the tests */
+ uint32_t saved_tcpc_flags;
+};
+
+ZTEST_F(tcpm_header, test_tcpm_header_drv_set_vconn_failure)
+{
+ int res;
+
+ tcpc_config[TCPM_TEST_PORT].flags = TCPC_FLAGS_CONTROL_VCONN;
+
+ fixture->mock_driver.set_vconn = set_vconn;
+ set_vconn_fake.return_val = -1;
+
+ res = tcpm_set_vconn(TCPM_TEST_PORT, true);
+
+ zassert_true(set_vconn_fake.call_count > 0);
+ zassert_equal(-1, res);
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_reset_bist_type_2__unimplemented)
+{
+ zassert_ok(tcpm_reset_bist_type_2(TCPM_TEST_PORT));
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_reset_bist_type_2__implemented)
+{
+ int res;
+ const int driver_return_code = 7458; /* arbitrary */
+
+ fixture->mock_driver.reset_bist_type_2 = reset_bist_type_2;
+ reset_bist_type_2_fake.return_val = driver_return_code;
+ res = tcpm_reset_bist_type_2(TCPM_TEST_PORT);
+
+ zassert_equal(1, reset_bist_type_2_fake.call_count);
+ zassert_equal(TCPM_TEST_PORT, reset_bist_type_2_fake.arg0_history[0]);
+ zassert_equal(driver_return_code, res);
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_debug_accessory__unimplemented)
+{
+ zassert_ok(tcpm_debug_accessory(TCPM_TEST_PORT, true));
+ zassert_ok(tcpm_debug_accessory(TCPM_TEST_PORT, false));
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_debug_accessory__implemented)
+{
+ int res;
+ const int driver_return_code = 7458; /* arbitrary */
+
+ fixture->mock_driver.debug_accessory = debug_accessory;
+ debug_accessory_fake.return_val = driver_return_code;
+ res = tcpm_debug_accessory(TCPM_TEST_PORT, true);
+
+ zassert_equal(1, debug_accessory_fake.call_count);
+ zassert_equal(TCPM_TEST_PORT, debug_accessory_fake.arg0_history[0]);
+ zassert_true(debug_accessory_fake.arg1_history[0]);
+ zassert_equal(driver_return_code, res);
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_debug_detach__unimplemented)
+{
+ zassert_ok(tcpm_debug_detach(TCPM_TEST_PORT));
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_debug_detach__implemented)
+{
+ int res;
+ const int driver_return_code = 7458; /* arbitrary */
+
+ fixture->mock_driver.debug_detach = debug_detach;
+ debug_detach_fake.return_val = driver_return_code;
+ res = tcpm_debug_detach(TCPM_TEST_PORT);
+
+ zassert_equal(1, debug_detach_fake.call_count);
+ zassert_equal(TCPM_TEST_PORT, debug_detach_fake.arg0_history[0]);
+ zassert_equal(driver_return_code, res);
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_hard_reset_reinit__unimplemented)
+{
+ int res;
+
+ res = tcpm_hard_reset_reinit(TCPM_TEST_PORT);
+
+ zassert_equal(EC_ERROR_UNIMPLEMENTED, res);
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_hard_reset_reinit__implemented)
+{
+ int res;
+ const int driver_return_code = 7458; /* arbitrary */
+
+ fixture->mock_driver.hard_reset_reinit = hard_reset_reinit;
+ hard_reset_reinit_fake.return_val = driver_return_code;
+ res = tcpm_hard_reset_reinit(TCPM_TEST_PORT);
+
+ zassert_equal(1, hard_reset_reinit_fake.call_count);
+ zassert_equal(TCPM_TEST_PORT, hard_reset_reinit_fake.arg0_history[0]);
+ zassert_equal(driver_return_code, res);
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_tcpc_has_frs_control__flag)
+{
+ Z_TEST_SKIP_IFNDEF(CONFIG_PLATFORM_EC_USB_PD_FRS);
+ Z_TEST_SKIP_IFDEF(CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC);
+
+ /* Determined by tcpc flag when USB_PD_FRS_TCPC is not set. */
+
+ tcpc_config[TCPM_TEST_PORT].flags = 0;
+ zassert_equal(0, tcpm_tcpc_has_frs_control(TCPM_TEST_PORT));
+
+ tcpc_config[TCPM_TEST_PORT].flags = TCPC_FLAGS_CONTROL_FRS;
+ zassert_equal(1, tcpm_tcpc_has_frs_control(TCPM_TEST_PORT));
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_set_frs_enable__unimplemented)
+{
+ Z_TEST_SKIP_IFNDEF(CONFIG_PLATFORM_EC_USB_PD_FRS);
+
+ zassert_ok(tcpm_set_frs_enable(TCPM_TEST_PORT, 1));
+ zassert_ok(tcpm_set_frs_enable(TCPM_TEST_PORT, 0));
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_set_frs_enable__implemented)
+{
+ int res;
+ const int driver_return_code = 7458; /* arbitrary */
+
+ Z_TEST_SKIP_IFNDEF(CONFIG_PLATFORM_EC_USB_PD_FRS);
+
+ fixture->mock_driver.set_frs_enable = set_frs_enable;
+ set_frs_enable_fake.return_val = driver_return_code;
+ res = tcpm_set_frs_enable(TCPM_TEST_PORT, 1);
+
+ zassert_equal(1, set_frs_enable_fake.call_count);
+ zassert_equal(TCPM_TEST_PORT, set_frs_enable_fake.arg0_history[0]);
+ zassert_equal(1, set_frs_enable_fake.arg1_history[0]);
+ zassert_equal(driver_return_code, res);
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_tcpc_get_bist_test_mode__unimplemented)
+{
+ int res;
+ bool enabled = true; /* Should be overwritten to false */
+
+ res = tcpc_get_bist_test_mode(TCPM_TEST_PORT, &enabled);
+
+ zassert_equal(EC_ERROR_UNIMPLEMENTED, res);
+ zassert_false(enabled);
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_get_chip_info__unimplemented)
+{
+ zassert_equal(EC_ERROR_UNIMPLEMENTED,
+ tcpm_get_chip_info(TCPM_TEST_PORT, 0, NULL));
+}
+
+ZTEST_F(tcpm_header, test_tcpm_header_dump_registers__std)
+{
+ Z_TEST_SKIP_IFNDEF(CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP);
+
+ /*
+ * The driver does not implement dump_registers, so the
+ * standard ones should be dumped instead.
+ */
+ tcpm_dump_registers(TCPM_TEST_PORT);
+
+ zassert_equal(1, tcpc_dump_std_registers_fake.call_count);
+ zassert_equal(TCPM_TEST_PORT,
+ tcpc_dump_std_registers_fake.arg0_history[0]);
+}
+
+static void *tcpm_header_setup(void)
+{
+ static struct tcpm_header_fixture fixture;
+
+ return &fixture;
+}
+
+static void tcpm_header_before(void *state)
+{
+ struct tcpm_header_fixture *fixture = state;
+
+ RESET_FAKE(set_vconn);
+ RESET_FAKE(reset_bist_type_2);
+ RESET_FAKE(debug_accessory);
+ RESET_FAKE(debug_detach);
+ RESET_FAKE(hard_reset_reinit);
+ RESET_FAKE(set_frs_enable);
+ RESET_FAKE(tcpc_dump_std_registers);
+
+ fixture->mock_driver = (struct tcpm_drv){ 0 };
+ fixture->saved_driver_ptr = tcpc_config[TCPM_TEST_PORT].drv;
+ tcpc_config[TCPM_TEST_PORT].drv = &fixture->mock_driver;
+
+ fixture->saved_tcpc_flags = tcpc_config[TCPM_TEST_PORT].flags;
+}
+
+static void tcpm_header_after(void *state)
+{
+ struct tcpm_header_fixture *fixture = state;
+
+ tcpc_config[TCPM_TEST_PORT].drv = fixture->saved_driver_ptr;
+ tcpc_config[TCPM_TEST_PORT].flags = fixture->saved_tcpc_flags;
+}
+
+ZTEST_SUITE(tcpm_header, drivers_predicate_pre_main, tcpm_header_setup,
+ tcpm_header_before, tcpm_header_after, NULL);
diff --git a/zephyr/test/drivers/default/src/tcs3400.c b/zephyr/test/drivers/default/src/tcs3400.c
index 045451169e..dba8dc5c56 100644
--- a/zephyr/test/drivers/default/src/tcs3400.c
+++ b/zephyr/test/drivers/default/src/tcs3400.c
@@ -3,19 +3,18 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "common.h"
-#include "i2c.h"
-#include "emul/emul_tcs3400.h"
+#include "driver/als_tcs3400.h"
#include "emul/emul_common_i2c.h"
-
+#include "emul/emul_tcs3400.h"
+#include "i2c.h"
#include "motion_sense.h"
#include "motion_sense_fifo.h"
-#include "driver/als_tcs3400.h"
#include "test/drivers/test_state.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
#define TCS_NODE DT_NODELABEL(tcs_emul)
#define TCS_CLR_SENSOR_ID SENSOR_ID(DT_NODELABEL(tcs3400_clear))
#define TCS_RGB_SENSOR_ID SENSOR_ID(DT_NODELABEL(tcs3400_rgb))
diff --git a/zephyr/test/drivers/default/src/temp_sensor.c b/zephyr/test/drivers/default/src/temp_sensor.c
index 61441a0229..83d9aa3812 100644
--- a/zephyr/test/drivers/default/src/temp_sensor.c
+++ b/zephyr/test/drivers/default/src/temp_sensor.c
@@ -3,19 +3,24 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/adc.h>
-#include <zephyr/drivers/adc/adc_emul.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-
-#include <math.h>
-
#include "common.h"
+#include "driver/temp_sensor/pct2075.h"
+#include "emul/emul_pct2075.h"
+#include "math_util.h"
#include "temp_sensor.h"
#include "temp_sensor/temp_sensor.h"
#include "test/drivers/test_state.h"
+#include "timer.h"
+
+#include <math.h>
+
+#include <zephyr/drivers/adc.h>
+#include <zephyr/drivers/adc/adc_emul.h>
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
#define GPIO_PG_EC_DSW_PWROK_PATH DT_PATH(named_gpios, pg_ec_dsw_pwrok)
#define GPIO_PG_EC_DSW_PWROK_PORT DT_GPIO_PIN(GPIO_PG_EC_DSW_PWROK_PATH, gpios)
@@ -110,6 +115,11 @@ ZTEST_USER(temp_sensor, test_temp_sensor_pg_pin)
named_temp_pp3300_regulator)),
&temp),
NULL);
+ zassert_equal(
+ EC_ERROR_NOT_POWERED,
+ temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL(named_pct2075)),
+ &temp),
+ NULL);
/* power ADC */
zassert_ok(gpio_emul_input_set(gpio_dev, GPIO_EC_PG_PIN_TEMP_PORT, 1),
@@ -179,12 +189,92 @@ ZTEST_USER(temp_sensor, test_temp_sensor_read)
}
}
+/** Test if temp_sensor_read() returns temperature on success for PCT2075 */
+ZTEST_USER(temp_sensor, test_temp_sensor_pct2075)
+{
+ int temp;
+ const struct emul *dev = EMUL_DT_GET(DT_NODELABEL(pct2075_emul));
+ int mk[] = {
+ MILLI_CELSIUS_TO_MILLI_KELVIN(127000),
+ MILLI_CELSIUS_TO_MILLI_KELVIN(126850),
+ MILLI_CELSIUS_TO_MILLI_KELVIN(125),
+ MILLI_CELSIUS_TO_MILLI_KELVIN(0),
+ MILLI_CELSIUS_TO_MILLI_KELVIN(-125),
+ MILLI_CELSIUS_TO_MILLI_KELVIN(-54875),
+ MILLI_CELSIUS_TO_MILLI_KELVIN(-55000),
+ };
+
+ for (int i = 0; i < ARRAY_SIZE(mk); i++) {
+ pct2075_emul_set_temp(dev, mk[i]);
+ /* Highly dependent on current implementation. The sensor
+ * update temperature in the 1 second periodic hook, so
+ * we need to wait for it.
+ */
+ msleep(1100);
+ zassert_equal(EC_SUCCESS,
+ temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL(
+ named_pct2075)),
+ &temp));
+ zassert_equal(MILLI_KELVIN_TO_KELVIN(mk[i]), temp);
+ }
+}
+
+/** Test if temperature is not updated on I2C read fail.
+ * The test highly dependent on current implementation - temp_sensor_read
+ * doesn't return an error on the i2c read fail, which can/should be changed
+ * in the future.
+ */
+ZTEST_USER(temp_sensor, test_temp_sensor_pct2075_fail)
+{
+ const struct emul *dev = EMUL_DT_GET(DT_NODELABEL(pct2075_emul));
+ struct pct2075_data *data = (struct pct2075_data *)dev->data;
+ int mk1 = 373000, mk2 = 273000;
+ int temp;
+
+ /* Set initial temperature */
+ pct2075_emul_set_temp(dev, mk1);
+ msleep(1100);
+
+ zassert_equal(EC_SUCCESS, temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL(
+ named_pct2075)),
+ &temp));
+ /* Make sure the temperature is read correctly */
+ zassert_equal(MILLI_KELVIN_TO_KELVIN(mk1), temp);
+
+ /* Set I2C fail on the temperature register */
+ i2c_common_emul_set_read_fail_reg(&data->common, PCT2075_REG_TEMP);
+ pct2075_emul_set_temp(dev, mk2);
+ /* Wait for potential update */
+ msleep(1100);
+
+ /* Make sure the temperature is not changed */
+ zassert_equal(EC_SUCCESS, temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL(
+ named_pct2075)),
+ &temp));
+ zassert_equal(MILLI_KELVIN_TO_KELVIN(mk1), temp);
+
+ /* Restore I2C */
+ i2c_common_emul_set_read_fail_reg(&data->common,
+ I2C_COMMON_EMUL_NO_FAIL_REG);
+ /* Wait for update */
+ msleep(1100);
+ /* Make sure the temperature is updated */
+ zassert_equal(EC_SUCCESS, temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL(
+ named_pct2075)),
+ &temp));
+ zassert_equal(MILLI_KELVIN_TO_KELVIN(mk2), temp);
+}
+
static void *temp_sensor_setup(void)
{
const struct device *dev =
DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_PG_EC_DSW_PWROK_PATH, gpios));
const struct device *dev_pin =
DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_EC_PG_PIN_TEMP_PATH, gpios));
+ const struct emul *pct2075_dev =
+ EMUL_DT_GET(DT_NODELABEL(pct2075_emul));
+ struct pct2075_data *pct2075_data =
+ (struct pct2075_data *)pct2075_dev->data;
zassert_not_null(dev, NULL);
/* Before tests make sure that power pins are set. */
@@ -193,6 +283,9 @@ static void *temp_sensor_setup(void)
zassert_ok(gpio_emul_input_set(dev_pin, GPIO_EC_PG_PIN_TEMP_PORT, 1),
NULL);
+ i2c_common_emul_set_read_fail_reg(&pct2075_data->common,
+ I2C_COMMON_EMUL_NO_FAIL_REG);
+
return NULL;
}
diff --git a/zephyr/test/drivers/default/src/thermistor.c b/zephyr/test/drivers/default/src/thermistor.c
index 417b482d99..edbe7acad5 100644
--- a/zephyr/test/drivers/default/src/thermistor.c
+++ b/zephyr/test/drivers/default/src/thermistor.c
@@ -3,18 +3,19 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
+#include "../driver/temp_sensor/thermistor.h"
+#include "common.h"
+#include "temp_sensor/temp_sensor.h"
+#include "test/drivers/test_state.h"
+
#include <zephyr/drivers/adc.h>
#include <zephyr/drivers/adc/adc_emul.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <temp_sensor.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
-#include "common.h"
-#include "../driver/temp_sensor/thermistor.h"
-#include "temp_sensor/temp_sensor.h"
-#include "test/drivers/test_state.h"
+#include <temp_sensor.h>
#define GPIO_PG_EC_DSW_PWROK_PATH DT_PATH(named_gpios, pg_ec_dsw_pwrok)
#define GPIO_PG_EC_DSW_PWROK_PORT DT_GPIO_PIN(GPIO_PG_EC_DSW_PWROK_PATH, gpios)
@@ -58,6 +59,10 @@ ZTEST_USER(thermistor, test_thermistor_power_pin)
sensor_idx++) {
const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
+ /* Skip for sensors that are not thermistors */
+ if (sensor->zephyr_info->thermistor == NULL)
+ continue;
+
zassert_ok(adc_emul_const_value_set(adc_dev, sensor->idx,
A_VALID_VOLTAGE),
"adc_emul_value_func_set() failed on %s",
@@ -72,6 +77,10 @@ ZTEST_USER(thermistor, test_thermistor_power_pin)
sensor_idx++) {
const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
+ /* Skip for sensors that are not thermistors */
+ if (sensor->zephyr_info->thermistor == NULL)
+ continue;
+
zassert_equal(EC_ERROR_NOT_POWERED,
sensor->zephyr_info->read(sensor, &temp),
"%s failed", sensor->name);
@@ -85,6 +94,10 @@ ZTEST_USER(thermistor, test_thermistor_power_pin)
sensor_idx++) {
const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
+ /* Skip for sensors that are not thermistors */
+ if (sensor->zephyr_info->thermistor == NULL)
+ continue;
+
zassert_equal(EC_SUCCESS,
sensor->zephyr_info->read(sensor, &temp),
"%s failed", sensor->name);
@@ -113,6 +126,10 @@ ZTEST_USER(thermistor, test_thermistor_adc_read_error)
sensor_idx++) {
const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
+ /* Skip for sensors that are not thermistors */
+ if (sensor->zephyr_info->thermistor == NULL)
+ continue;
+
zassert_ok(adc_emul_value_func_set(adc_dev, sensor->idx,
adc_error_func, NULL),
"adc_emul_value_func_set() failed on %s",
@@ -123,6 +140,10 @@ ZTEST_USER(thermistor, test_thermistor_adc_read_error)
sensor_idx++) {
const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
+ /* Skip for sensors that are not thermistors */
+ if (sensor->zephyr_info->thermistor == NULL)
+ continue;
+
zassert_equal(EC_ERROR_UNKNOWN,
sensor->zephyr_info->read(sensor, &temp),
"%s failed", sensor->name);
@@ -265,10 +286,16 @@ ZTEST_USER(thermistor, test_thermistors_adc_temperature_conversion)
const static int reference_res_arr[] = { DT_FOREACH_STATUS_OKAY(
THERMISTOR_COMPAT, GET_THERMISTOR_REF_RES) };
- for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE; sensor_idx++)
+ for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE;
+ sensor_idx++) {
+ /* Skip for sensors that are not thermistors */
+ if (temp_sensors[sensor_idx].zephyr_info->thermistor == NULL)
+ continue;
+
do_thermistor_test(&temp_sensors[sensor_idx],
reference_mv_arr[sensor_idx],
reference_res_arr[sensor_idx]);
+ }
}
ZTEST_USER(thermistor, test_device_nodes_enabled)
@@ -312,6 +339,10 @@ static void thermistor_cleanup(void *state)
for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE;
sensor_idx++) {
+ /* Skip for sensors that are not thermistors */
+ if (temp_sensors[sensor_idx].zephyr_info->thermistor == NULL)
+ continue;
+
/* Setup ADC to return 27*C (300K) which is reasonable value */
adc_emul_const_value_set(
adc_dev, temp_sensors[sensor_idx].idx,
diff --git a/zephyr/test/drivers/default/src/uart_hostcmd.c b/zephyr/test/drivers/default/src/uart_hostcmd.c
index 5e1e200fa9..907dba929f 100644
--- a/zephyr/test/drivers/default/src/uart_hostcmd.c
+++ b/zephyr/test/drivers/default/src/uart_hostcmd.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "host_command.h"
-#include "uart.h"
#include "test/drivers/test_state.h"
+#include "uart.h"
+
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
/** Messages used in test */
static const char msg1[] = "test";
diff --git a/zephyr/test/drivers/default/src/usb_mux.c b/zephyr/test/drivers/default/src/usb_mux.c
index 62d39e28d4..0e89cf2398 100644
--- a/zephyr/test/drivers/default/src/usb_mux.c
+++ b/zephyr/test/drivers/default/src/usb_mux.c
@@ -3,33 +3,33 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/shell/shell_uart.h>
-
#include "common.h"
#include "ec_commands.h"
#include "ec_tasks.h"
-#include <zephyr/fff.h>
#include "hooks.h"
#include "host_command.h"
#include "i2c.h"
-#include "test/drivers/stubs.h"
#include "task.h"
#include "tcpm/ps8xxx_public.h"
#include "tcpm/tcpci.h"
+#include "test/drivers/stubs.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+#include "usb_mux.h"
#include "usb_prl_sm.h"
#include "usb_tc_sm.h"
-#include "usb_mux.h"
-#include "test/drivers/test_state.h"
-#include "test/drivers/utils.h"
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/shell/shell_uart.h>
+#include <zephyr/ztest.h>
/** Copy of original usb_muxes[USB_PORT_C1] */
-struct usb_mux_chain usb_mux_c1;
+static struct usb_mux_chain usb_mux_c1;
+static struct usb_mux *usbc1_virtual_usb_mux;
/** Number of usb mux proxies in chain */
#define NUM_OF_PROXY 3
@@ -344,6 +344,26 @@ struct usb_mux_chain proxy_chain_0 = {
.next = &proxy_chain_1,
};
+static void find_virtual_mux(void)
+{
+ const struct usb_mux_chain *mux_chain;
+
+ mux_chain = &usb_muxes[1];
+ usbc1_virtual_usb_mux = NULL;
+ while (mux_chain) {
+ if (mux_chain->mux &&
+ mux_chain->mux->driver == &virtual_usb_mux_driver) {
+ usbc1_virtual_usb_mux =
+ (struct usb_mux *)mux_chain->mux;
+ break;
+ }
+ mux_chain = mux_chain->next;
+ }
+
+ __ASSERT(usbc1_virtual_usb_mux,
+ "USB-C port 1 must contain a virtual mux");
+}
+
/** Setup first 3 usb muxes of port 1 with proxy */
static void setup_usb_mux_proxy_chain(void)
{
@@ -693,13 +713,13 @@ ZTEST(usb_uninit_mux, test_usb_mux_hpd_update)
mux_state_t exp_mode, mode, virt_mode;
/* Get current state of virtual usb mux and set mock */
- usbc1_virtual_usb_mux.driver->get(&usbc1_virtual_usb_mux, &virt_mode);
+ usbc1_virtual_usb_mux->driver->get(usbc1_virtual_usb_mux, &virt_mode);
/* Test no hpd level and no irq */
exp_mode = virt_mode;
usb_mux_hpd_update(USBC_PORT_C1, exp_mode);
/* Check if virtual usb mux mode is updated correctly */
- usbc1_virtual_usb_mux.driver->get(&usbc1_virtual_usb_mux, &mode);
+ usbc1_virtual_usb_mux->driver->get(usbc1_virtual_usb_mux, &mode);
zassert_equal(exp_mode, mode, "virtual mux mode is 0x%x (!= 0x%x)",
mode, exp_mode);
CHECK_PROXY_FAKE_CALL_CNT(proxy_init, NUM_OF_PROXY);
@@ -711,7 +731,7 @@ ZTEST(usb_uninit_mux, test_usb_mux_hpd_update)
exp_mode = virt_mode | USB_PD_MUX_HPD_LVL | USB_PD_MUX_HPD_IRQ;
usb_mux_hpd_update(USBC_PORT_C1, exp_mode);
/* Check if virtual usb mux mode is updated correctly */
- usbc1_virtual_usb_mux.driver->get(&usbc1_virtual_usb_mux, &mode);
+ usbc1_virtual_usb_mux->driver->get(usbc1_virtual_usb_mux, &mode);
zassert_equal(exp_mode, mode, "virtual mux mode is 0x%x (!= 0x%x)",
mode, exp_mode);
CHECK_PROXY_FAKE_CALL_CNT(proxy_init, 0);
@@ -723,7 +743,7 @@ ZTEST(usb_uninit_mux, test_usb_mux_hpd_update)
exp_mode = virt_mode | USB_PD_MUX_HPD_IRQ;
usb_mux_hpd_update(USBC_PORT_C1, exp_mode);
/* Check if virtual usb mux mode is updated correctly */
- usbc1_virtual_usb_mux.driver->get(&usbc1_virtual_usb_mux, &mode);
+ usbc1_virtual_usb_mux->driver->get(usbc1_virtual_usb_mux, &mode);
zassert_equal(exp_mode, mode, "virtual mux mode is 0x%x (!= 0x%x)",
mode, exp_mode);
CHECK_PROXY_FAKE_CALL_CNT(proxy_init, 0);
@@ -735,7 +755,7 @@ ZTEST(usb_uninit_mux, test_usb_mux_hpd_update)
exp_mode = virt_mode | USB_PD_MUX_HPD_LVL;
usb_mux_hpd_update(USBC_PORT_C1, exp_mode);
/* Check if virtual usb mux mode is updated correctly */
- usbc1_virtual_usb_mux.driver->get(&usbc1_virtual_usb_mux, &mode);
+ usbc1_virtual_usb_mux->driver->get(usbc1_virtual_usb_mux, &mode);
zassert_equal(exp_mode, mode, "virtual mux mode is 0x%x (!= 0x%x)",
mode, exp_mode);
CHECK_PROXY_FAKE_CALL_CNT(proxy_init, 0);
@@ -916,6 +936,7 @@ ZTEST(usb_init_mux, test_usb_mux_typec_command)
void usb_uninit_mux_before(void *state)
{
ARG_UNUSED(state);
+ find_virtual_mux();
setup_usb_mux_proxy_chain();
set_test_runner_tid();
@@ -935,6 +956,7 @@ void usb_uninit_mux_after(void *state)
void usb_init_mux_before(void *state)
{
ARG_UNUSED(state);
+ find_virtual_mux();
setup_usb_mux_proxy_chain();
set_test_runner_tid();
diff --git a/zephyr/test/drivers/default/src/util.c b/zephyr/test/drivers/default/src/util.c
index 32f989bb0f..342ce9b971 100644
--- a/zephyr/test/drivers/default/src/util.c
+++ b/zephyr/test/drivers/default/src/util.c
@@ -2,11 +2,11 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/fff.h>
-
-#include "util.h"
#include "test/drivers/test_state.h"
+#include "util.h"
+
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
ZTEST(util, reverse)
{
diff --git a/zephyr/test/drivers/default/src/vboot_hash.c b/zephyr/test/drivers/default/src/vboot_hash.c
index 04f535a89c..61d4260a23 100644
--- a/zephyr/test/drivers/default/src/vboot_hash.c
+++ b/zephyr/test/drivers/default/src/vboot_hash.c
@@ -3,14 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <sha256.h>
-
#include "ec_commands.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
+#include <sha256.h>
+
ZTEST_USER(vboot_hash, test_hostcmd_abort)
{
struct ec_response_vboot_hash response;
diff --git a/zephyr/test/drivers/default/src/virtual_battery.c b/zephyr/test/drivers/default/src/virtual_battery.c
index fc29e39777..3b265443e8 100644
--- a/zephyr/test/drivers/default/src/virtual_battery.c
+++ b/zephyr/test/drivers/default/src/virtual_battery.c
@@ -3,15 +3,19 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "battery.h"
#include "battery_smart.h"
#include "ec_commands.h"
#include "emul/emul_smart_battery.h"
+#include "gpio.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
+#include "virtual_battery.h"
+
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
void copy_memmap_string(uint8_t *dest, int offset, int len);
@@ -226,11 +230,11 @@ ZTEST_USER(virtual_battery, test_read_regs)
word = virtual_battery_read16(SB_SPECIFICATION_INFO);
zassert_equal(expected, word, "%d != %d", expected, word);
- zassume_ok(battery_status(&expected));
+ zassert_ok(battery_status(&expected));
word = virtual_battery_read16(SB_BATTERY_STATUS);
zassert_equal(expected, word, "%d != %d", expected, word);
- zassume_ok(battery_design_voltage(&expected));
+ zassert_ok(battery_design_voltage(&expected));
word = virtual_battery_read16(SB_DESIGN_VOLTAGE);
zassert_equal(expected, word, "%d != %d", expected, word);
@@ -285,3 +289,144 @@ ZTEST(virtual_battery, test_read_data_from_host_memmap)
ZTEST_SUITE(virtual_battery, drivers_predicate_post_main, NULL, NULL, NULL,
NULL);
+
+ZTEST(virtual_battery_direct, test_bad_reg_write)
+{
+ struct ec_response_i2c_passthru resp;
+
+ /* Start with a zero-length write. The state machine is expecting a
+ * register address to be written, so this will fail.
+ */
+ zassert_equal(EC_ERROR_INVAL,
+ virtual_battery_handler(&resp, 0, NULL, 0, 0,
+ /* write_len = */ 0, NULL));
+
+ zassert_equal(EC_I2C_STATUS_NAK, resp.i2c_status);
+}
+
+ZTEST(virtual_battery_direct, test_aborted_write)
+{
+ struct ec_response_i2c_passthru resp;
+ int error_code;
+
+ /* Arbitrary packet of bytes */
+ const uint8_t packet[] = { 0xAA, 0xBB, 0xCC };
+
+ /* Start with a length 1 write to set a register address. */
+ zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0, 0,
+ /* write_len = */ 1, &packet[0]));
+
+ /* Now write two more bytes successfully... */
+ zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0, 0,
+ /* write_len = */ 1, &packet[1]));
+ zassert_ok(error_code);
+
+ zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0, 0,
+ /* write_len = */ 1, &packet[2]));
+ zassert_ok(error_code);
+
+ /* ...and abruptly write 0 bytes. This will cause an error */
+ zassert_equal(EC_ERROR_INVAL,
+ virtual_battery_handler(&resp, 0, &error_code, 0, 0,
+ /* write_len = */ 0, NULL));
+
+ zassert_equal(EC_I2C_STATUS_NAK, resp.i2c_status);
+}
+
+ZTEST(virtual_battery_direct, test_aborted_read)
+{
+ struct ec_response_i2c_passthru resp;
+ int error_code;
+
+ /* Arbitrary packet to set a register plus a buffer to read to */
+ const uint8_t write_packet[] = { SB_MANUFACTURER_NAME };
+ uint8_t read_packet[3] = { 0 };
+
+ /* Start with a length 1 write to set a register address. */
+ zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0, 0,
+ /* write_len = */ 1,
+ &write_packet[0]));
+
+ /* Now read two bytes successfully... */
+ zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0,
+ /* read_len = */ 1, 0,
+ &read_packet[0]));
+ zassert_ok(error_code);
+
+ zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0,
+ /* read_len = */ 1, 0,
+ &read_packet[1]));
+ zassert_ok(error_code);
+
+ /* ...and abruptly read 0 bytes. This will cause an error */
+ zassert_equal(EC_ERROR_INVAL,
+ virtual_battery_handler(&resp, 0, &error_code, 0,
+ /* read_len = */ 0, 0,
+ &read_packet[2]));
+
+ zassert_equal(EC_I2C_STATUS_NAK, resp.i2c_status);
+}
+
+ZTEST(virtual_battery_direct, test_read_bad_reg)
+{
+ struct ec_response_i2c_passthru resp;
+ int error_code;
+
+ /* Try to read from an invalid register */
+ const uint8_t write_packet[] = { 0xFF };
+ uint8_t read_packet[3] = { 0 };
+
+ /* Start with a length 1 write to set a register address. */
+ zassert_ok(virtual_battery_handler(&resp, 0, &error_code, 0, 0,
+ /* write_len = */ 1,
+ &write_packet[0]));
+
+ /* Now try to read */
+ zassert_equal(EC_ERROR_INVAL,
+ virtual_battery_handler(&resp, 0, &error_code, 0,
+ /* read_len = */ 1, 0,
+ &read_packet[0]));
+ zassert_equal(EC_ERROR_INVAL, error_code);
+}
+
+#define GPIO_BATT_PRES_ODL_PATH DT_PATH(named_gpios, ec_batt_pres_odl)
+#define GPIO_BATT_PRES_ODL_PORT DT_GPIO_PIN(GPIO_BATT_PRES_ODL_PATH, gpios)
+
+static int set_battery_present(bool batt_present)
+{
+ const struct device *batt_pres_dev =
+ DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios));
+
+ return gpio_emul_input_set(batt_pres_dev, GPIO_BATT_PRES_ODL_PORT,
+ !batt_present);
+}
+
+ZTEST(virtual_battery_direct, test_no_battery)
+{
+ struct ec_response_i2c_passthru resp;
+
+ set_battery_present(false);
+
+ /* Arbitrary packet of bytes */
+ const uint8_t packet[] = { 0xAA, 0xBB, 0xCC };
+
+ /* Attempt a valid write operation, which will fail due to no battery */
+ zassert_equal(EC_ERROR_INVAL,
+ virtual_battery_handler(&resp, 0, NULL, 0, 0,
+ /* write_len = */ 1, &packet[0]));
+
+ zassert_equal(EC_I2C_STATUS_NAK, resp.i2c_status);
+}
+
+static void virtual_battery_direct_reset(void *arg)
+{
+ reset_parse_state();
+
+ set_battery_present(true);
+}
+
+/* The virtual_battery_direct suite tests the virtual battery handler directly
+ * without performing I2C ops. This makes it easier to test certain corner-cases
+ */
+ZTEST_SUITE(virtual_battery_direct, drivers_predicate_post_main, NULL,
+ virtual_battery_direct_reset, virtual_battery_direct_reset, NULL);
diff --git a/zephyr/test/drivers/default/src/vstore.c b/zephyr/test/drivers/default/src/vstore.c
index b4264aaeb3..923d14ff00 100644
--- a/zephyr/test/drivers/default/src/vstore.c
+++ b/zephyr/test/drivers/default/src/vstore.c
@@ -3,19 +3,20 @@
* found in the LICENSE file.
*/
+#include "ec_commands.h"
+#include "host_command.h"
+#include "system.h"
+#include "system_fake.h"
+#include "test/drivers/test_state.h"
+#include "vstore.h"
+
#include <setjmp.h>
-#include <console.h>
#include <zephyr/fff.h>
#include <zephyr/shell/shell_dummy.h>
#include <zephyr/ztest.h>
-#include "ec_commands.h"
-#include "host_command.h"
-#include "system.h"
-#include "system_fake.h"
-#include "vstore.h"
-#include "test/drivers/test_state.h"
+#include <console.h>
ZTEST_SUITE(vstore, drivers_predicate_post_main, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/drivers/default/src/watchdog.c b/zephyr/test/drivers/default/src/watchdog.c
index 958aa3eaaa..a82800a6de 100644
--- a/zephyr/test/drivers/default/src/watchdog.c
+++ b/zephyr/test/drivers/default/src/watchdog.c
@@ -8,20 +8,19 @@
* @brief Unit Tests for watchdog.
*/
-#include <zephyr/device.h>
-#include <zephyr/drivers/watchdog.h>
-
-#include <zephyr/logging/log.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "common.h"
#include "ec_tasks.h"
-#include <zephyr/fff.h>
#include "hooks.h"
#include "test/drivers/stubs.h"
-#include "watchdog.h"
#include "test/drivers/test_state.h"
+#include "watchdog.h"
+
+#include <zephyr/device.h>
+#include <zephyr/drivers/watchdog.h>
+#include <zephyr/fff.h>
+#include <zephyr/kernel.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/ztest.h>
#define wdt DEVICE_DT_GET(DT_CHOSEN(cros_ec_watchdog))
diff --git a/zephyr/test/drivers/dps/src/dps.c b/zephyr/test/drivers/dps/src/dps.c
index d445767df4..a573da670b 100644
--- a/zephyr/test/drivers/dps/src/dps.c
+++ b/zephyr/test/drivers/dps/src/dps.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "builtin/stdio.h"
#include "console.h"
#include "dps.h"
#include "test/drivers/test_state.h"
#include "timer.h"
+#include <zephyr/ztest.h>
+
struct dps_fixture {
struct dps_config_t saved_config;
int saved_debug_level;
@@ -89,7 +89,7 @@ ZTEST(dps, console_cmd__enable)
ZTEST(dps, console_cmd__disable)
{
/* Should already by enabled due to before() function */
- zassume_true(dps_is_enabled(), NULL);
+ zassert_true(dps_is_enabled(), NULL);
zassert_ok(shell_execute_cmd(get_ec_shell(), "dps dis"), NULL);
@@ -104,7 +104,7 @@ ZTEST(dps, console_cmd__fakepwr_print)
ZTEST(dps, console_cmd__fakepwr_enable_disable)
{
- zassume_false(dps_is_fake_enabled(),
+ zassert_false(dps_is_fake_enabled(),
"fakepwr shouldn't be enabled by default");
zassert_ok(shell_execute_cmd(get_ec_shell(), "dps fakepwr 100 200"),
diff --git a/zephyr/test/drivers/host_cmd/CMakeLists.txt b/zephyr/test/drivers/host_cmd/CMakeLists.txt
index d1567ec635..14733253c3 100644
--- a/zephyr/test/drivers/host_cmd/CMakeLists.txt
+++ b/zephyr/test/drivers/host_cmd/CMakeLists.txt
@@ -21,6 +21,7 @@ target_sources(app PRIVATE
src/pd_chip_info.c
src/pd_control.c
src/pd_log.c
+ src/tablet_mode.c
src/usb_pd_control.c
src/usb_pd_host_cmd.c
)
diff --git a/zephyr/test/drivers/host_cmd/src/adc.c b/zephyr/test/drivers/host_cmd/src/adc.c
index 6b2bef1165..f283ef17d5 100644
--- a/zephyr/test/drivers/host_cmd/src/adc.c
+++ b/zephyr/test/drivers/host_cmd/src/adc.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/emul.h>
-#include <zephyr/fff.h>
-#include <zephyr/ztest.h>
-
#include "adc.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/drivers/emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
FAKE_VALUE_FUNC(int, adc_read_channel, enum adc_channel);
ZTEST(hc_adc, normal_path)
diff --git a/zephyr/test/drivers/host_cmd/src/battery_cut_off.c b/zephyr/test/drivers/host_cmd/src/battery_cut_off.c
index ed9d96481d..019362f3c8 100644
--- a/zephyr/test/drivers/host_cmd/src/battery_cut_off.c
+++ b/zephyr/test/drivers/host_cmd/src/battery_cut_off.c
@@ -3,9 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/emul.h>
-#include <zephyr/ztest.h>
-
#include "battery.h"
#include "emul/emul_common_i2c.h"
#include "emul/emul_smart_battery.h"
@@ -14,6 +11,9 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/drivers/emul.h>
+#include <zephyr/ztest.h>
+
struct host_cmd_battery_cut_off_fixture {
const struct emul *emul;
struct i2c_common_emul_data *i2c_emul;
diff --git a/zephyr/test/drivers/host_cmd/src/battery_display_soc.c b/zephyr/test/drivers/host_cmd/src/battery_display_soc.c
index 029551a49b..6af3d35043 100644
--- a/zephyr/test/drivers/host_cmd/src/battery_display_soc.c
+++ b/zephyr/test/drivers/host_cmd/src/battery_display_soc.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "battery.h"
#include "charge_state.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
ZTEST_USER(battery_display_soc, happy_path)
{
const uint32_t full_charge_as_tenths =
diff --git a/zephyr/test/drivers/host_cmd/src/battery_v2.c b/zephyr/test/drivers/host_cmd/src/battery_v2.c
index 3e0ac969f9..a6fab89b8c 100644
--- a/zephyr/test/drivers/host_cmd/src/battery_v2.c
+++ b/zephyr/test/drivers/host_cmd/src/battery_v2.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "battery.h"
#include "ec_commands.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
ZTEST(host_cmd_battery_v2, test_get_static__invalid_index)
{
struct ec_response_battery_static_info response;
diff --git a/zephyr/test/drivers/host_cmd/src/charge_manager.c b/zephyr/test/drivers/host_cmd/src/charge_manager.c
index 7298b8e135..6bbf7a3ae3 100644
--- a/zephyr/test/drivers/host_cmd/src/charge_manager.c
+++ b/zephyr/test/drivers/host_cmd/src/charge_manager.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "charge_manager.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
ZTEST_USER(charge_manager, test_port_count)
{
struct ec_response_charge_port_count response = { 0 };
@@ -44,5 +44,49 @@ ZTEST_USER(charge_manager, test_port_override__0_from_off)
zassert_ok(host_command_process(&args));
}
+ZTEST_USER(charge_manager, test_charge_state_get_debug_params)
+{
+ struct ec_params_charge_state params = {
+ .cmd = CHARGE_STATE_CMD_GET_PARAM,
+ };
+ struct ec_response_charge_state response = { 0 };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND(EC_CMD_CHARGE_STATE, 0, response, params);
+
+ /* Check that the following get commands work on these debug parameters.
+ * The values being asserted are the default values when nothing is
+ * plugged in. This should be enough since the test only needs to verify
+ * that the command gets the current value. Tests that verify the
+ * charging behavior exist elsewhere (under
+ * default/src/integration/usbc).
+ */
+ params.get_param.param = CS_PARAM_DEBUG_CTL_MODE;
+ zassert_ok(host_command_process(&args));
+ zassert_equal(0, response.get_param.value);
+
+ params.get_param.param = CS_PARAM_DEBUG_MANUAL_CURRENT;
+ zassert_ok(host_command_process(&args));
+ zassert_equal(0xffffffff, response.get_param.value);
+
+ params.get_param.param = CS_PARAM_DEBUG_MANUAL_VOLTAGE;
+ zassert_ok(host_command_process(&args));
+ zassert_equal(0xffffffff, response.get_param.value);
+
+ params.get_param.param = CS_PARAM_DEBUG_SEEMS_DEAD;
+ zassert_ok(host_command_process(&args));
+ zassert_equal(0, response.get_param.value);
+
+ params.get_param.param = CS_PARAM_DEBUG_SEEMS_DISCONNECTED;
+ zassert_ok(host_command_process(&args));
+ zassert_equal(0, response.get_param.value);
+
+ params.get_param.param = CS_PARAM_DEBUG_BATT_REMOVED;
+ zassert_ok(host_command_process(&args));
+ zassert_equal(0, response.get_param.value);
+
+ params.get_param.param = CS_PARAM_DEBUG_MAX;
+ zassert_equal(EC_ERROR_INVAL, host_command_process(&args));
+}
+
ZTEST_SUITE(charge_manager, drivers_predicate_post_main, NULL, NULL, NULL,
NULL);
diff --git a/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c b/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c
index b935b69e46..0fa7ab3770 100644
--- a/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c
+++ b/zephyr/test/drivers/host_cmd/src/get_cmd_versions.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "battery.h"
#include "charge_state.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
ZTEST_USER(hc_get_cmd_versions, test_v0__both_versions)
{
struct ec_params_get_cmd_versions params = {
diff --git a/zephyr/test/drivers/host_cmd/src/get_panic_info.c b/zephyr/test/drivers/host_cmd/src/get_panic_info.c
index bdb19d9a98..85d5fdd6f2 100644
--- a/zephyr/test/drivers/host_cmd/src/get_panic_info.c
+++ b/zephyr/test/drivers/host_cmd/src/get_panic_info.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "host_command.h"
#include "panic.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
struct host_cmd_get_panic_info_fixture {
struct panic_data saved_pdata;
};
diff --git a/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c b/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c
index 907329f8a1..2d9410232d 100644
--- a/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c
+++ b/zephyr/test/drivers/host_cmd/src/get_pd_port_caps.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
ZTEST_USER(host_cmd_get_pd_port_caps, test_good_index)
{
struct ec_params_get_pd_port_caps params = { .port = 0 };
@@ -50,7 +50,7 @@ static void host_cmd_get_pd_port_caps_begin(void *data)
ARG_UNUSED(data);
/* Assume we have at least one USB-C port */
- zassume_true(board_get_usb_pd_port_count() > 0,
+ zassert_true(board_get_usb_pd_port_count() > 0,
"Insufficient TCPCs found");
}
diff --git a/zephyr/test/drivers/host_cmd/src/host_command.c b/zephyr/test/drivers/host_cmd/src/host_command.c
index 49e41acc89..a9f0fcb941 100644
--- a/zephyr/test/drivers/host_cmd/src/host_command.c
+++ b/zephyr/test/drivers/host_cmd/src/host_command.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "ec_commands.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
ZTEST(host_cmd_host_commands, get_command_versions__v1)
{
struct ec_response_get_cmd_versions response;
diff --git a/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c b/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c
index 9d29aeb7de..f4bf956e9b 100644
--- a/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c
+++ b/zephyr/test/drivers/host_cmd/src/host_command_test_protocol.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "host_command.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
ZTEST_USER(hc_test_protocol, test_echo_max_buffer_size)
{
struct ec_params_test_protocol params = {
diff --git a/zephyr/test/drivers/host_cmd/src/host_event_commands.c b/zephyr/test/drivers/host_cmd/src/host_event_commands.c
index c2f7e72045..8e7fff0fe2 100644
--- a/zephyr/test/drivers/host_cmd/src/host_event_commands.c
+++ b/zephyr/test/drivers/host_cmd/src/host_event_commands.c
@@ -3,11 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
#include "include/lpc.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/ztest.h>
+
struct host_cmd_host_event_commands_fixture {
struct host_events_ctx ctx;
};
diff --git a/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c b/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c
index 6d0a386d6e..b0ba438bbb 100644
--- a/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c
+++ b/zephyr/test/drivers/host_cmd/src/host_event_commands_deprecated.c
@@ -5,39 +5,30 @@
/* Tests for deprecated EC_CMD_HOST_EVENT_* commands */
-#include <zephyr/ztest.h>
#include "include/lpc.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/ztest.h>
+
#define HOST_EVENT_TEST_MASK_VAL EC_HOST_EVENT_MASK(EC_HOST_EVENT_LID_OPEN)
-static void
+static enum ec_status
host_event_get_wake_mask_helper(struct ec_response_host_event_mask *r)
{
- enum ec_status ret_val;
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
EC_CMD_HOST_EVENT_GET_WAKE_MASK, 0, *r);
- ret_val = host_command_process(&args);
-
- /* EC_CMD_HOST_EVENT_GET_WAKE_MASK always returns success */
- zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
- EC_RES_SUCCESS, ret_val);
+ return host_command_process(&args);
}
-static void host_event_set_wake_mask_helper(uint32_t mask)
+static enum ec_status host_event_set_wake_mask_helper(uint32_t mask)
{
- enum ec_status ret_val;
struct ec_params_host_event_mask params = { .mask = mask };
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
EC_CMD_HOST_EVENT_SET_WAKE_MASK, 0, params);
- ret_val = host_command_process(&args);
-
- /* EC_CMD_HOST_EVENT_SET_WAKE_MASK always returns success */
- zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
- EC_RES_SUCCESS, ret_val);
+ return host_command_process(&args);
}
/**
@@ -45,13 +36,17 @@ static void host_event_set_wake_mask_helper(uint32_t mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_wake_mask)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
- host_event_get_wake_mask_helper(&result);
-#else
- ztest_test_skip();
-#endif
+ rv = host_event_get_wake_mask_helper(&result);
+ if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
+ zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
+ } else {
+ zassert_equal(EC_RES_INVALID_COMMAND, rv,
+ "Expected %d, returned %d",
+ EC_RES_INVALID_COMMAND, rv);
+ }
}
/**
@@ -59,16 +54,24 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_wake_mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_wake_mask)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
- host_event_get_wake_mask_helper(&result);
+ rv = host_event_get_wake_mask_helper(&result);
+ if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
+ zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
+ } else {
+ zassert_equal(EC_RES_INVALID_COMMAND, rv,
+ "Expected %d, returned %d",
+ EC_RES_INVALID_COMMAND, rv);
+ return;
+ }
/* Default mask is expected to be clear */
zassert_false(result.mask, "Default host event wake mask is not clear");
- host_event_set_wake_mask_helper(HOST_EVENT_TEST_MASK_VAL);
+ zassert_ok(host_event_set_wake_mask_helper(HOST_EVENT_TEST_MASK_VAL));
/* Verify the mask changed */
host_event_get_wake_mask_helper(&result);
@@ -78,38 +81,25 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_wake_mask)
HOST_EVENT_TEST_MASK_VAL, result.mask);
/* Clean up the mask */
- host_event_set_wake_mask_helper(0);
-#else
- ztest_test_skip();
-#endif
+ zassert_ok(host_event_set_wake_mask_helper(0));
}
-static void
+static enum ec_status
host_event_get_smi_mask_helper(struct ec_response_host_event_mask *r)
{
- enum ec_status ret_val;
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
EC_CMD_HOST_EVENT_GET_SMI_MASK, 0, *r);
- ret_val = host_command_process(&args);
-
- /* EC_CMD_HOST_EVENT_GET_SMI_MASK always returns success */
- zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
- EC_RES_SUCCESS, ret_val);
+ return host_command_process(&args);
}
-static void host_event_set_smi_mask_helper(uint32_t mask)
+static enum ec_status host_event_set_smi_mask_helper(uint32_t mask)
{
- enum ec_status ret_val;
struct ec_params_host_event_mask params = { .mask = mask };
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
EC_CMD_HOST_EVENT_SET_SMI_MASK, 0, params);
- ret_val = host_command_process(&args);
-
- /* EC_CMD_HOST_EVENT_SET_SMI_MASK always returns success */
- zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
- EC_RES_SUCCESS, ret_val);
+ return host_command_process(&args);
}
/**
@@ -117,13 +107,18 @@ static void host_event_set_smi_mask_helper(uint32_t mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_smi_mask)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
- host_event_get_smi_mask_helper(&result);
-#else
- ztest_test_skip();
-#endif
+ rv = host_event_get_smi_mask_helper(&result);
+ if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
+ zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
+ } else {
+ zassert_equal(EC_RES_INVALID_COMMAND, rv,
+ "Expected %d, returned %d",
+ EC_RES_INVALID_COMMAND, rv);
+ return;
+ }
}
/**
@@ -131,42 +126,43 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_smi_mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_smi_mask)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
- host_event_get_smi_mask_helper(&result);
+ rv = host_event_get_smi_mask_helper(&result);
+ if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
+ zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
+ } else {
+ zassert_equal(EC_RES_INVALID_COMMAND, rv,
+ "Expected %d, returned %d",
+ EC_RES_INVALID_COMMAND, rv);
+ return;
+ }
/* Default mask is expected to be clear */
zassert_false(result.mask, "Default host event SMI mask is not clear");
- host_event_set_smi_mask_helper(HOST_EVENT_TEST_MASK_VAL);
+ zassert_ok(host_event_set_smi_mask_helper(HOST_EVENT_TEST_MASK_VAL));
/* Verify the mask changed */
- host_event_get_smi_mask_helper(&result);
+ zassert_ok(host_event_get_smi_mask_helper(&result));
zassert_equal(result.mask, HOST_EVENT_TEST_MASK_VAL,
"Expected SMI mask 0x%08x, returned mask 0x%08x",
HOST_EVENT_TEST_MASK_VAL, result.mask);
/* Clean up the mask */
- host_event_set_smi_mask_helper(0);
-#else
- ztest_test_skip();
-#endif
+ zassert_ok(host_event_set_smi_mask_helper(0));
}
-static void host_event_get_b_helper(struct ec_response_host_event_mask *r)
+static enum ec_status
+host_event_get_b_helper(struct ec_response_host_event_mask *r)
{
- enum ec_status ret_val;
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND_RESPONSE(EC_CMD_HOST_EVENT_GET_B, 0, *r);
- ret_val = host_command_process(&args);
-
- /* EC_CMD_HOST_EVENT_GET_B always returns success */
- zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
- EC_RES_SUCCESS, ret_val);
+ return host_command_process(&args);
}
/**
@@ -174,41 +170,36 @@ static void host_event_get_b_helper(struct ec_response_host_event_mask *r)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_b)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
- host_event_get_b_helper(&result);
-#else
- ztest_test_skip();
-#endif
+ rv = host_event_get_b_helper(&result);
+ if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
+ zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
+ } else {
+ zassert_equal(EC_RES_INVALID_COMMAND, rv,
+ "Expected %d, returned %d",
+ EC_RES_INVALID_COMMAND, rv);
+ return;
+ }
}
-static void
+static enum ec_status
host_event_get_sci_mask_helper(struct ec_response_host_event_mask *r)
{
- enum ec_status ret_val;
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_RESPONSE(
EC_CMD_HOST_EVENT_GET_SCI_MASK, 0, *r);
- ret_val = host_command_process(&args);
-
- /* EC_CMD_HOST_EVENT_GET_SCI_MASK always returns success */
- zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
- EC_RES_SUCCESS, ret_val);
+ return host_command_process(&args);
}
-static void host_event_set_sci_mask_helper(uint32_t mask)
+static enum ec_status host_event_set_sci_mask_helper(uint32_t mask)
{
- enum ec_status ret_val;
struct ec_params_host_event_mask params = { .mask = mask };
struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
EC_CMD_HOST_EVENT_SET_SCI_MASK, 0, params);
- ret_val = host_command_process(&args);
-
- /* EC_CMD_HOST_EVENT_SET_SCI_MASK always returns success */
- zassert_equal(ret_val, EC_RES_SUCCESS, "Expected %d, returned %d",
- EC_RES_SUCCESS, ret_val);
+ return host_command_process(&args);
}
/**
@@ -216,13 +207,18 @@ static void host_event_set_sci_mask_helper(uint32_t mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_sci_mask)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
- host_event_get_sci_mask_helper(&result);
-#else
- ztest_test_skip();
-#endif
+ rv = host_event_get_sci_mask_helper(&result);
+ if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
+ zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
+ } else {
+ zassert_equal(EC_RES_INVALID_COMMAND, rv,
+ "Expected %d, returned %d",
+ EC_RES_INVALID_COMMAND, rv);
+ return;
+ }
}
/**
@@ -230,27 +226,32 @@ ZTEST_USER(host_cmd_host_event_commands, test_host_event_get_sci_mask)
*/
ZTEST_USER(host_cmd_host_event_commands, test_host_event_set_sci_mask)
{
-#ifdef CONFIG_HOSTCMD_X86
+ enum ec_status rv;
struct ec_response_host_event_mask result = { 0 };
/* Read the current mask */
- host_event_get_sci_mask_helper(&result);
+ rv = host_event_get_sci_mask_helper(&result);
+ if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
+ zassert_ok(rv, "Expected %d, returned %d", EC_RES_SUCCESS, rv);
+ } else {
+ zassert_equal(EC_RES_INVALID_COMMAND, rv,
+ "Expected %d, returned %d",
+ EC_RES_INVALID_COMMAND, rv);
+ return;
+ }
/* Default mask is expected to be clear */
zassert_false(result.mask, "Default host event SCI mask is not clear");
- host_event_set_sci_mask_helper(HOST_EVENT_TEST_MASK_VAL);
+ zassert_ok(host_event_set_sci_mask_helper(HOST_EVENT_TEST_MASK_VAL));
/* Verify the mask changed */
- host_event_get_sci_mask_helper(&result);
+ zassert_ok(host_event_get_sci_mask_helper(&result));
zassert_equal(result.mask, HOST_EVENT_TEST_MASK_VAL,
"Expected SCI mask 0x%08x, returned mask 0x%08x",
HOST_EVENT_TEST_MASK_VAL, result.mask);
/* Clean up the mask */
- host_event_set_sci_mask_helper(0);
-#else
- ztest_test_skip();
-#endif
+ zassert_ok(host_event_set_sci_mask_helper(0));
}
diff --git a/zephyr/test/drivers/host_cmd/src/host_request_expected_size.c b/zephyr/test/drivers/host_cmd/src/host_request_expected_size.c
index 30ff8c11b2..19fdd9ea4a 100644
--- a/zephyr/test/drivers/host_cmd/src/host_request_expected_size.c
+++ b/zephyr/test/drivers/host_cmd/src/host_request_expected_size.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "host_command.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
ZTEST(host_request_expected_size, test_mismatched_host_request_version)
{
const struct ec_host_request request = {
diff --git a/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c b/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c
index 4c74a48ab4..e77230cfaf 100644
--- a/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c
+++ b/zephyr/test/drivers/host_cmd/src/keyboard_mkbp.c
@@ -3,11 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
#include "include/keyboard_mkbp.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/ztest.h>
+
struct keyboard_mkbp_commands_fixture {
struct ec_mkbp_config config;
};
diff --git a/zephyr/test/drivers/host_cmd/src/motion_sense.c b/zephyr/test/drivers/host_cmd/src/motion_sense.c
index 371ca4ae11..919baf7219 100644
--- a/zephyr/test/drivers/host_cmd/src/motion_sense.c
+++ b/zephyr/test/drivers/host_cmd/src/motion_sense.c
@@ -3,10 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/fff.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "atomic.h"
#include "console.h"
#include "driver/accel_bma2x2.h"
@@ -17,6 +13,10 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/fff.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
FAKE_VALUE_FUNC(int, mock_set_range, struct motion_sensor_t *, int, int);
FAKE_VALUE_FUNC(int, mock_set_offset, const struct motion_sensor_t *,
const int16_t *, int16_t);
@@ -72,7 +72,7 @@ static void host_cmd_motion_sense_before(void *fixture)
RESET_FAKE(mock_perform_calib);
FFF_RESET_HISTORY();
- zassume_ok(shell_execute_cmd(get_ec_shell(), "accelinit 0"));
+ zassert_ok(shell_execute_cmd(get_ec_shell(), "accelinit 0"));
atomic_clear(&motion_sensors[0].flush_pending);
motion_sensors[0].config[SENSOR_CONFIG_AP].odr = 0;
@@ -305,7 +305,7 @@ ZTEST_USER(host_cmd_motion_sense, test_odr_get)
{
struct ec_response_motion_sense response;
- zassume_ok(motion_sensors[0].drv->set_data_rate(&motion_sensors[0],
+ zassert_ok(motion_sensors[0].drv->set_data_rate(&motion_sensors[0],
1000000, false),
NULL);
zassert_ok(host_cmd_motion_sense_odr(/*sensor_num=*/0,
@@ -322,7 +322,7 @@ ZTEST_USER(host_cmd_motion_sense, test_odr_set)
{
struct ec_response_motion_sense response;
- zassume_ok(motion_sensors[0].drv->set_data_rate(&motion_sensors[0], 0,
+ zassert_ok(motion_sensors[0].drv->set_data_rate(&motion_sensors[0], 0,
false),
NULL);
zassert_ok(host_cmd_motion_sense_odr(/*sensor_num=*/0,
@@ -774,7 +774,7 @@ ZTEST(host_cmd_motion_sense, test_int_enable)
host_cmd_motion_sense_int_enable(2, &response), NULL);
/* Make sure we start off disabled */
- zassume_ok(host_cmd_motion_sense_int_enable(0, &response));
+ zassert_ok(host_cmd_motion_sense_int_enable(0, &response));
/* Test enable */
zassert_ok(host_cmd_motion_sense_int_enable(1, &response));
diff --git a/zephyr/test/drivers/host_cmd/src/pd_chip_info.c b/zephyr/test/drivers/host_cmd/src/pd_chip_info.c
index 95e2339899..c04e74810a 100644
--- a/zephyr/test/drivers/host_cmd/src/pd_chip_info.c
+++ b/zephyr/test/drivers/host_cmd/src/pd_chip_info.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
#define TEST_PORT USBC_PORT_C0
#define BAD_PORT 65
@@ -20,7 +20,7 @@ static enum ec_status run_pd_chip_info(int port,
{
struct ec_params_pd_chip_info params = { .port = port, .live = true };
struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_PD_CHIP_INFO, 1, resp, params);
+ BUILD_HOST_COMMAND(EC_CMD_PD_CHIP_INFO, 1, *resp, params);
return host_command_process(&args);
}
@@ -41,7 +41,7 @@ ZTEST_USER(host_cmd_pd_chip_info, test_bad_index)
{
struct ec_response_pd_chip_info_v1 response;
- zassume_true(board_get_usb_pd_port_count() < BAD_PORT,
+ zassert_true(board_get_usb_pd_port_count() < BAD_PORT,
"Intended bad port exists");
zassert_equal(run_pd_chip_info(BAD_PORT, &response),
EC_RES_INVALID_PARAM,
@@ -53,7 +53,7 @@ static void host_cmd_pd_chip_info_begin(void *data)
ARG_UNUSED(data);
/* Assume we have at least one USB-C port */
- zassume_true(board_get_usb_pd_port_count() > 0,
+ zassert_true(board_get_usb_pd_port_count() > 0,
"Insufficient TCPCs found");
/* Set the system into S0, since the AP would drive these commands */
diff --git a/zephyr/test/drivers/host_cmd/src/pd_control.c b/zephyr/test/drivers/host_cmd/src/pd_control.c
index e8de27f6ce..a881a8e0ea 100644
--- a/zephyr/test/drivers/host_cmd/src/pd_control.c
+++ b/zephyr/test/drivers/host_cmd/src/pd_control.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
-#include <zephyr/fff.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/fff.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
#define TEST_PORT USBC_PORT_C0
#define BAD_PORT 82
@@ -23,7 +23,7 @@ ZTEST_USER(host_cmd_pd_control, test_bad_index)
struct host_cmd_handler_args args =
BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params);
- zassume_true(board_get_usb_pd_port_count() < BAD_PORT,
+ zassert_true(board_get_usb_pd_port_count() < BAD_PORT,
"Intended bad port exists");
zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM,
"Failed to fail pd_control for port %d", params.chip);
@@ -47,7 +47,7 @@ ZTEST_USER(host_cmd_pd_control, test_pd_reset_resume)
* the only HC return which would cover this is a state string, which
* could be brittle.
*/
- zassume_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning");
+ zassert_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning");
host_cmd_pd_control(TEST_PORT, PD_RESET);
@@ -76,7 +76,7 @@ ZTEST_USER(host_cmd_pd_control, test_suspend_resume)
* the only HC return which would cover this is a state string, which
* could be brittle.
*/
- zassume_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning");
+ zassert_true(pd_is_port_enabled(TEST_PORT), "Port not up at beginning");
host_cmd_pd_control(TEST_PORT, PD_SUSPEND);
@@ -93,6 +93,20 @@ ZTEST_USER(host_cmd_pd_control, test_suspend_resume)
zassert_true(pd_is_port_enabled(TEST_PORT), "Port failed to resume");
}
+ZTEST_USER(host_cmd_pd_control, test_suspend_low_battery)
+{
+ struct ec_params_pd_control params = { .chip = TEST_PORT,
+ .subcmd = PD_SUSPEND };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND_PARAMS(EC_CMD_PD_CONTROL, 0, params);
+
+ /* Suspending the port for firmware update should fail at critical low
+ * battery.
+ */
+ test_set_battery_level(1);
+ zassert_equal(host_command_process(&args), EC_RES_BUSY);
+}
+
ZTEST_USER(host_cmd_pd_control, test_control_disable)
{
struct ec_params_pd_control params = { .chip = TEST_PORT,
@@ -117,7 +131,7 @@ static void host_cmd_pd_control_begin(void *data)
ARG_UNUSED(data);
/* Assume we have at least one USB-C port */
- zassume_true(board_get_usb_pd_port_count() > 0,
+ zassert_true(board_get_usb_pd_port_count() > 0,
"Insufficient TCPCs found");
/* Set the system into S0, since the AP would drive these commands */
diff --git a/zephyr/test/drivers/host_cmd/src/pd_log.c b/zephyr/test/drivers/host_cmd/src/pd_log.c
index a6022d8bb1..819f020890 100644
--- a/zephyr/test/drivers/host_cmd/src/pd_log.c
+++ b/zephyr/test/drivers/host_cmd/src/pd_log.c
@@ -3,13 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "event_log.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
#include "usb_pd.h"
+#include "util.h"
+
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
/**
* @brief This is the maximum size of a single log entry.
@@ -20,6 +21,14 @@
#define MAX_EVENT_LOG_ENTRY_SIZE (sizeof(struct event_log_entry) + 16)
/**
+ * @brief This is the maximum size of a response pd log entry.
+ *
+ * Each entry must contain some common data + up to 16 bytes of additional type
+ * specific data.
+ */
+#define MAX_RESPONSE_PD_LOG_ENTRY_SIZE (sizeof(struct ec_response_pd_log) + 16)
+
+/**
* @brief The size of the PD log entry data
*
* Logs from the PD include an additional 8 bytes of data to be sent to the AP.
@@ -120,7 +129,7 @@ ZTEST_USER_F(pd_log, test_mcu_connect)
ZTEST_USER_F(pd_log, test_read_log_entry)
{
- uint8_t response_buffer[sizeof(struct ec_response_pd_log) + 16];
+ uint8_t response_buffer[MAX_RESPONSE_PD_LOG_ENTRY_SIZE];
struct ec_response_pd_log *response =
(struct ec_response_pd_log *)response_buffer;
struct host_cmd_handler_args args =
@@ -133,3 +142,25 @@ ZTEST_USER_F(pd_log, test_read_log_entry)
zassert_equal(sizeof(struct event_log_entry), args.response_size, NULL);
zassert_equal(PD_EVENT_NO_ENTRY, response->type, NULL);
}
+
+ZTEST_USER_F(pd_log, test_log_recv_vdm)
+{
+ uint8_t response_buffer[MAX_RESPONSE_PD_LOG_ENTRY_SIZE];
+ uint32_t *payload = (uint32_t *)response_buffer;
+ struct ec_response_pd_log *response =
+ (struct ec_response_pd_log *)&payload[1];
+
+ memset(response_buffer, 0, sizeof(response_buffer));
+ payload[0] |= VDO_SRC_RESPONDER;
+ response->type = PD_EVENT_MCU_CONNECT;
+ response->size_port = 8;
+ int cnt = DIV_ROUND_UP(response->size_port, sizeof(uint32_t)) + 2;
+
+ pd_log_recv_vdm(0, cnt, payload);
+
+ (void)log_dequeue_event(&fixture->log_entry);
+
+ zassert_equal(response->type, fixture->log_entry.type,
+ "type=%d, received=%d", response->type,
+ fixture->log_entry.type);
+}
diff --git a/zephyr/test/drivers/host_cmd/src/tablet_mode.c b/zephyr/test/drivers/host_cmd/src/tablet_mode.c
new file mode 100644
index 0000000000..a84faa035f
--- /dev/null
+++ b/zephyr/test/drivers/host_cmd/src/tablet_mode.c
@@ -0,0 +1,111 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_smart_battery.h"
+#include "hooks.h"
+#include "host_command.h"
+#include "tablet_mode.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+
+#include <zephyr/drivers/emul.h>
+#include <zephyr/ztest.h>
+
+struct host_cmd_tablet_mode_fixture {
+ const struct emul *emul;
+ struct i2c_common_emul_data *i2c_emul;
+};
+
+static void host_cmd_tablet_mode_before(void *f)
+{
+ ARG_UNUSED(f);
+ tablet_reset();
+}
+
+static void host_cmd_tablet_mode_after(void *f)
+{
+ ARG_UNUSED(f);
+ tablet_reset();
+}
+
+ZTEST_SUITE(host_cmd_tablet_mode, drivers_predicate_post_main, NULL,
+ host_cmd_tablet_mode_before, host_cmd_tablet_mode_after, NULL);
+
+/* Test tablet mode can be enabled with a host command. */
+ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_on)
+{
+ int rv;
+ struct ec_params_set_tablet_mode params = {
+ .tablet_mode = TABLET_MODE_FORCE_TABLET
+ };
+
+ struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
+ EC_CMD_SET_TABLET_MODE, UINT8_C(0), params);
+
+ rv = host_command_process(&args);
+ zassert_equal(EC_RES_SUCCESS, rv, "Expected EC_RES_SUCCESS, but got %d",
+ rv);
+ /* Return 1 if in tablet mode, 0 otherwise */
+ rv = tablet_get_mode();
+ zassert_equal(rv, 1, "unexpected tablet mode: %d", rv);
+}
+
+/* Test tablet mode can be disabled with a host command. */
+ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_off)
+{
+ int rv;
+ struct ec_params_set_tablet_mode params = {
+ .tablet_mode = TABLET_MODE_FORCE_CLAMSHELL
+ };
+
+ struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
+ EC_CMD_SET_TABLET_MODE, UINT8_C(0), params);
+
+ rv = host_command_process(&args);
+ zassert_equal(EC_RES_SUCCESS, rv, "Expected EC_RES_SUCCESS, but got %d",
+ rv);
+ /* Return 1 if in tablet mode, 0 otherwise */
+ rv = tablet_get_mode();
+ zassert_equal(rv, 0, "unexpected tablet mode: %d", rv);
+}
+
+/* Test tablet mode can be reset with a host command. */
+ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_reset)
+{
+ int rv;
+ struct ec_params_set_tablet_mode params = {
+ .tablet_mode = TABLET_MODE_DEFAULT
+ };
+
+ struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
+ EC_CMD_SET_TABLET_MODE, UINT8_C(0), params);
+
+ rv = host_command_process(&args);
+ zassert_equal(EC_RES_SUCCESS, rv, "Expected EC_RES_SUCCESS, but got %d",
+ rv);
+ /* Return 1 if in tablet mode, 0 otherwise */
+ rv = tablet_get_mode();
+ zassert_equal(rv, 0, "unexpected tablet mode: %d", rv);
+}
+
+/* Test tablet mode can handle invalid host command parameters. */
+ZTEST_USER_F(host_cmd_tablet_mode, test_tablet_mode_invalid_parameter)
+{
+ int rv;
+ struct ec_params_set_tablet_mode params = {
+ .tablet_mode = 0xEE /* Sufficiently random, bad value.*/
+ };
+
+ struct host_cmd_handler_args args = BUILD_HOST_COMMAND_PARAMS(
+ EC_CMD_SET_TABLET_MODE, UINT8_C(0), params);
+
+ rv = host_command_process(&args);
+ zassert_equal(EC_RES_INVALID_PARAM, rv,
+ "Expected EC_RES_INVALID_PARAM, but got %d", rv);
+ /* Return 1 if in tablet mode, 0 otherwise */
+ rv = tablet_get_mode();
+ zassert_equal(rv, 0, "unexpected tablet mode: %d", rv);
+}
diff --git a/zephyr/test/drivers/host_cmd/src/usb_pd_control.c b/zephyr/test/drivers/host_cmd/src/usb_pd_control.c
index c439141da9..f926c2b7ca 100644
--- a/zephyr/test/drivers/host_cmd/src/usb_pd_control.c
+++ b/zephyr/test/drivers/host_cmd/src/usb_pd_control.c
@@ -3,9 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "ec_commands.h"
#include "emul/emul_isl923x.h"
@@ -16,6 +13,9 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
#define TEST_PORT USBC_PORT_C0
#define BAD_PORT 42
@@ -99,7 +99,7 @@ ZTEST_USER(host_cmd_usb_pd_control, test_bad_index)
{
struct ec_response_usb_pd_control_v2 response;
- zassume_true(board_get_usb_pd_port_count() < BAD_PORT,
+ zassert_true(board_get_usb_pd_port_count() < BAD_PORT,
"Intended bad port exists");
zassert_equal(run_usb_pd_control(BAD_PORT, &response),
EC_RES_INVALID_PARAM,
@@ -130,7 +130,7 @@ static void host_cmd_usb_pd_control_before(void *data)
ARG_UNUSED(data);
/* Assume we have at least one USB-C port */
- zassume_true(board_get_usb_pd_port_count() > 0,
+ zassert_true(board_get_usb_pd_port_count() > 0,
"Insufficient TCPCs found");
/* Set the system into S0, since the AP would drive these commands */
diff --git a/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c b/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c
index 3afc90760a..d95461f274 100644
--- a/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c
+++ b/zephyr/test/drivers/host_cmd/src/usb_pd_host_cmd.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "ec_commands.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
#include "usb_pd.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
ZTEST_USER(usb_pd_host_cmd, test_hc_pd_host_event_status)
{
struct ec_response_host_event_status response;
diff --git a/zephyr/test/drivers/host_cmd_read_memmap/CMakeLists.txt b/zephyr/test/drivers/host_cmd_read_memmap/CMakeLists.txt
new file mode 100644
index 0000000000..dedb9f801f
--- /dev/null
+++ b/zephyr/test/drivers/host_cmd_read_memmap/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+target_sources(app PRIVATE
+ src/read_memmap.c
+)
diff --git a/zephyr/test/drivers/host_cmd_read_memmap/src/read_memmap.c b/zephyr/test/drivers/host_cmd_read_memmap/src/read_memmap.c
new file mode 100644
index 0000000000..17ae4109f9
--- /dev/null
+++ b/zephyr/test/drivers/host_cmd_read_memmap/src/read_memmap.c
@@ -0,0 +1,96 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ec_commands.h"
+#include "host_command.h"
+#include "test/drivers/test_state.h"
+
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
+#ifndef CONFIG_PLATFORM_EC_SWITCH
+FAKE_VOID_FUNC(switch_interrupt, int);
+#endif
+
+ZTEST(ec_cmd_read_memmap, id)
+{
+ struct ec_params_read_memmap params = {
+ .offset = EC_MEMMAP_ID,
+ .size = 2,
+ };
+ uint8_t response[2];
+ int rv;
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND(EC_CMD_READ_MEMMAP, 0, response, params);
+
+ rv = host_command_process(&args);
+
+ if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
+ zassert_equal(rv, EC_RES_INVALID_COMMAND, "Got %d", rv);
+ return;
+ }
+
+ zassert_ok(rv, "Got %d", rv);
+ /* Response should be 'E' 'C' */
+ zassert_equal('E', response[0]);
+ zassert_equal('C', response[1]);
+}
+
+ZTEST(ec_cmd_read_memmap, switches)
+{
+ struct ec_params_read_memmap params = {
+ .offset = EC_MEMMAP_SWITCHES,
+ .size = 1,
+ };
+ uint8_t response[1];
+ int rv;
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND(EC_CMD_READ_MEMMAP, 0, response, params);
+
+ rv = host_command_process(&args);
+
+ if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
+ zassert_equal(rv, EC_RES_INVALID_COMMAND, "Got %d", rv);
+ return;
+ }
+
+ /* This test suite is run with CONFIG_PLATFORM_EC_SWITCH enabled
+ * and disabled.
+ */
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_SWITCH)) {
+ zassert_ok(rv, "Got %d", rv);
+ } else {
+ zassert_equal(rv, EC_RES_UNAVAILABLE, "Got %d", rv);
+ }
+}
+
+ZTEST(ec_cmd_read_memmap, invalid)
+{
+ struct ec_params_read_memmap params = {
+ .offset = EC_MEMMAP_ID,
+ .size = UINT8_MAX,
+ };
+ uint8_t response[2];
+ int rv;
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND(EC_CMD_READ_MEMMAP, 0, response, params);
+
+ rv = host_command_process(&args);
+
+ if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
+ zassert_equal(rv, EC_RES_INVALID_COMMAND, "Got %d", rv);
+ return;
+ }
+
+ /* Verify offset+size exceeding max fails */
+ zassert_equal(rv, EC_RES_INVALID_PARAM, "Got %d", rv);
+
+ /* Verify params.size > response_max fails */
+ params.size = 4;
+ zassert_equal(host_command_process(&args), EC_RES_INVALID_PARAM);
+}
+
+ZTEST_SUITE(ec_cmd_read_memmap, drivers_predicate_post_main, NULL, NULL, NULL,
+ NULL);
diff --git a/zephyr/test/drivers/host_command_thread/CMakeLists.txt b/zephyr/test/drivers/host_command_thread/CMakeLists.txt
new file mode 100644
index 0000000000..9386414deb
--- /dev/null
+++ b/zephyr/test/drivers/host_command_thread/CMakeLists.txt
@@ -0,0 +1,5 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+target_sources(app PRIVATE src/main.c)
diff --git a/zephyr/test/drivers/host_command_thread/src/main.c b/zephyr/test/drivers/host_command_thread/src/main.c
new file mode 100644
index 0000000000..8b315dd950
--- /dev/null
+++ b/zephyr/test/drivers/host_command_thread/src/main.c
@@ -0,0 +1,83 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/**
+ * @file main.c
+ *
+ * WARNING:
+ * Do not add tests to this binary. This test messes with the main thread and
+ * can only run a single test function.
+ */
+#include "host_command.h"
+#include "task.h"
+#include "test/drivers/test_state.h"
+
+#include <string.h>
+
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
+#define CUSTOM_COMMAND_ID 0x0088
+
+/* Pointer to the main thread, defined in kernel/init.c */
+extern struct k_thread z_main_thread;
+
+/* 0 - did not run, 1 - true, -1 - false */
+static int last_check_main_thread_result;
+
+static enum ec_status check_main_thread(struct host_cmd_handler_args *args)
+{
+ last_check_main_thread_result = in_host_command_main() ? 1 : -1;
+ return EC_RES_SUCCESS;
+}
+
+DECLARE_HOST_COMMAND(CUSTOM_COMMAND_ID, check_main_thread, EC_VER_MASK(0));
+
+static void fake_main_thread(void *a, void *b, void *c)
+{
+ host_command_main();
+}
+
+K_THREAD_STACK_DEFINE(fake_main_thread_stack, 4000);
+
+ZTEST_SUITE(host_cmd_thread, drivers_predicate_post_main, NULL, NULL, NULL,
+ NULL);
+
+ZTEST(host_cmd_thread, test_takeover)
+{
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND_SIMPLE(CUSTOM_COMMAND_ID, 0);
+ const char expected_thread_name[] = "HOSTCMD";
+ struct k_thread fake_main_thread_data;
+ k_tid_t tid = k_thread_create(
+ &fake_main_thread_data, fake_main_thread_stack,
+ K_THREAD_STACK_SIZEOF(fake_main_thread_stack), fake_main_thread,
+ NULL, NULL, NULL, 1, 0, K_NO_WAIT);
+
+ /* Wait for the thread to start */
+ k_msleep(500);
+
+ /* Get the name of the thread (must be done after the sleep) */
+ const char *main_thread_name = k_thread_name_get(&z_main_thread);
+
+ /* Verify that the thread is not the hostcmd thread */
+ zassert_equal(EC_TASK_PRIORITY(EC_TASK_HOSTCMD_PRIO),
+ k_thread_priority_get(&z_main_thread));
+ zassert_equal(strlen(expected_thread_name), strlen(main_thread_name));
+ zassert_mem_equal(expected_thread_name, main_thread_name,
+ strlen(expected_thread_name));
+
+ /* Try running a host command */
+ host_command_received(&args);
+ k_msleep(1000);
+
+ /* Make sure that the host command ran, the result should be -1 because
+ * it's not the original main thread.
+ */
+ zassert_equal(-1, last_check_main_thread_result);
+
+ /* Kill the extra thread */
+ k_thread_abort(tid);
+}
diff --git a/zephyr/test/drivers/i2c_controller/include/basic_i2c_device_emul.h b/zephyr/test/drivers/i2c_controller/include/basic_i2c_device_emul.h
index c60c455dfa..c235d64825 100644
--- a/zephyr/test/drivers/i2c_controller/include/basic_i2c_device_emul.h
+++ b/zephyr/test/drivers/i2c_controller/include/basic_i2c_device_emul.h
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-
#include "emul/emul_common_i2c.h"
+#include <stdint.h>
+
#define BASIC_I2C_DEV_EXT_ACCESS_REG 0xFF
/**
diff --git a/zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c b/zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c
index 1b7810ad84..8d00d5d3ba 100644
--- a/zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c
+++ b/zephyr/test/drivers/i2c_controller/src/basic_i2c_device_emul.c
@@ -2,13 +2,14 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <string.h>
-#include <zephyr/device.h>
-
#include "basic_i2c_device_emul.h"
#include "emul/emul_common_i2c.h"
#include "emul/emul_stub_device.h"
+#include <string.h>
+
+#include <zephyr/device.h>
+
#define DT_DRV_COMPAT basic_i2c_device
void basic_i2c_device_reset(const struct emul *emul)
diff --git a/zephyr/test/drivers/i2c_controller/src/i2c_controller.c b/zephyr/test/drivers/i2c_controller/src/i2c_controller.c
index 0beb773297..594c3e6888 100644
--- a/zephyr/test/drivers/i2c_controller/src/i2c_controller.c
+++ b/zephyr/test/drivers/i2c_controller/src/i2c_controller.c
@@ -2,15 +2,15 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "basic_i2c_device_emul.h"
+#include "i2c.h"
+#include "test/drivers/test_state.h"
+
#include <zephyr/device.h>
#include <zephyr/fff.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/ztest.h>
-#include "basic_i2c_device_emul.h"
-#include "i2c.h"
-#include "test/drivers/test_state.h"
-
struct i2c_controller_fixture {
int port;
int addr;
@@ -61,6 +61,29 @@ ZTEST_F(i2c_controller, write_read32_be)
expected);
}
+ZTEST_F(i2c_controller, write_read16_be)
+{
+ uint16_t expected = 0x1122;
+ int actual;
+
+ zassert_ok(i2c_write16(fixture->port,
+ fixture->addr | I2C_FLAG_BIG_ENDIAN, 0,
+ expected));
+
+ /* Get the first two bytes of the register space as a uint16_t */
+ actual = __bswap_16(*((uint16_t *)&fixture->emul_data->regs[0]));
+
+ zassert_equal(expected, actual, "got %04x, expected %08x", actual,
+ expected);
+
+ /* Now read back through I2C API */
+ zassert_ok(i2c_read16(fixture->port,
+ fixture->addr | I2C_FLAG_BIG_ENDIAN, 0, &actual));
+
+ zassert_equal(expected, actual, "got %04x, expected %04x",
+ (uint16_t)actual, expected);
+}
+
ZTEST_F(i2c_controller, read32_fail)
{
int ret;
@@ -98,6 +121,14 @@ ZTEST_F(i2c_controller, field_update16)
zassert_equal(set_value, actual, "got %04x, expected %04x", actual,
set_value);
+
+ /* Force a failure */
+ set_value = 0x0001;
+ mask = 0x0001;
+ i2c_common_emul_set_read_fail_reg(&fixture->emul_data->common, 0);
+ zassert_equal(i2c_field_update16(fixture->port, fixture->addr, 0, mask,
+ set_value),
+ EC_ERROR_INVAL);
}
ZTEST_F(i2c_controller, read_offset16__one_byte)
@@ -273,6 +304,89 @@ ZTEST_F(i2c_controller, write_offset16_block)
expected);
}
+ZTEST_F(i2c_controller, pec_disabled)
+{
+ uint16_t addr_flags;
+ uint8_t write_data[] = {
+ 0xAA,
+ 0xBB,
+ 0xCC,
+ 0xDD,
+ };
+ int write_data32 = 0x11223344;
+ uint8_t read_data[4];
+ int actual_read_len;
+ uint16_t reg = 0x01;
+
+ /*
+ * Verify I2C reads and writes through the various APIs fail when
+ * CONFIG_PLATFORM_EC_SMBUS_PEC=n
+ */
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_SMBUS_PEC)) {
+ ztest_test_skip();
+ return;
+ }
+
+ addr_flags = fixture->addr | I2C_FLAG_PEC;
+
+ zassert_equal(i2c_read32(fixture->port, addr_flags, reg,
+ (int *)read_data),
+ EC_ERROR_UNIMPLEMENTED);
+ zassert_equal(i2c_write32(fixture->port, addr_flags, reg, write_data32),
+ EC_ERROR_UNIMPLEMENTED);
+ zassert_equal(i2c_read_sized_block(fixture->port, addr_flags, reg,
+ read_data, sizeof(read_data),
+ &actual_read_len),
+ EC_ERROR_UNIMPLEMENTED);
+ zassert_equal(i2c_read_sized_block(fixture->port, addr_flags, reg,
+ read_data, 0, &actual_read_len),
+ EC_ERROR_INVAL);
+ zassert_equal(i2c_write_block(fixture->port, addr_flags, reg,
+ write_data, sizeof(write_data)),
+ EC_ERROR_UNIMPLEMENTED);
+}
+
+ZTEST_F(i2c_controller, i2c_xfer_unlocked__error_paths)
+{
+ uint8_t out_buffer[1];
+ int out_size;
+ uint8_t in_buffer[1];
+ int in_size;
+ int flags;
+
+ /* First confirm i2c_xfer_unlocked() works with a lock. */
+ out_buffer[0] = 0;
+ out_size = 1;
+ in_size = 1;
+ flags = I2C_XFER_STOP;
+
+ i2c_lock(fixture->port, 1);
+ zassert_equal(i2c_port_is_locked(fixture->port), 1,
+ "Port %d not locked", fixture->port);
+ zassert_ok(i2c_xfer_unlocked(fixture->port, fixture->addr, out_buffer,
+ out_size, in_buffer, in_size, flags));
+ i2c_lock(fixture->port, 0);
+ zassert_equal(i2c_port_is_locked(fixture->port), 0, "Port %d is locked",
+ fixture->port);
+
+ /* Try the transfer without a lock. */
+ zassert_equal(i2c_xfer_unlocked(fixture->port, fixture->addr,
+ out_buffer, out_size, in_buffer,
+ in_size, flags),
+ EC_ERROR_INVAL);
+
+ /* Set an invalid flag on the transfer, expected to still pass */
+ i2c_lock(fixture->port, 1);
+ zassert_equal(i2c_port_is_locked(fixture->port), 1,
+ "Port %d not locked", fixture->port);
+ zassert_ok(i2c_xfer_unlocked(
+ fixture->port, fixture->addr | I2C_FLAG_ADDR_IS_SPI, out_buffer,
+ out_size, in_buffer, in_size, flags));
+ i2c_lock(fixture->port, 0);
+ zassert_equal(i2c_port_is_locked(fixture->port), 0, "Port %d is locked",
+ fixture->port);
+}
+
static struct i2c_controller_fixture i2c_controller_fixture;
static void *setup(void)
diff --git a/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c b/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c
index f27791949e..a4e326bcec 100644
--- a/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c
+++ b/zephyr/test/drivers/isl923x/src/charge_ramp_hw.c
@@ -3,8 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "driver/charger/isl923x.h"
#include "driver/charger/isl923x_public.h"
#include "emul/emul_common_i2c.h"
@@ -12,6 +10,8 @@
#include "test/drivers/charger_utils.h"
#include "test/drivers/test_state.h"
+#include <zephyr/ztest.h>
+
#define CHARGER_NUM get_charger_num(&isl923x_drv)
#define ISL923X_EMUL EMUL_DT_GET(DT_NODELABEL(isl923x_emul))
diff --git a/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c b/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c
index f8cd76d524..8eef7ea748 100644
--- a/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c
+++ b/zephyr/test/drivers/isl923x/src/console_cmd_amon_bmon.c
@@ -3,11 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/adc.h>
-#include <zephyr/drivers/adc/adc_emul.h>
-#include <zephyr/shell/shell.h>
-#include <zephyr/ztest.h>
-
#include "adc.h"
#include "console.h"
#include "driver/charger/isl923x.h"
@@ -19,6 +14,11 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/drivers/adc.h>
+#include <zephyr/drivers/adc/adc_emul.h>
+#include <zephyr/shell/shell.h>
+#include <zephyr/ztest.h>
+
#define ADC_DEVICE_NODE DT_NODELABEL(adc0)
#define CHARGER_NUM get_charger_num(&isl923x_drv)
#define ISL923X_EMUL EMUL_DT_GET(DT_NODELABEL(isl923x_emul))
diff --git a/zephyr/test/drivers/keyboard_scan/include/keyboard_test_utils.h b/zephyr/test/drivers/keyboard_scan/include/keyboard_test_utils.h
index 0117fea09c..c8b127ca70 100644
--- a/zephyr/test/drivers/keyboard_scan/include/keyboard_test_utils.h
+++ b/zephyr/test/drivers/keyboard_scan/include/keyboard_test_utils.h
@@ -1,4 +1,4 @@
-/* Copyright 2022 The ChromiumOS Authors.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c
index 149f25dfdd..2865d7efc3 100644
--- a/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c
+++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_backlight.c
@@ -3,17 +3,24 @@
* found in the LICENSE file.
*/
+#include "console.h"
+#include "host_command.h"
+#include "keyboard_backlight.h"
+#include "pwm_mock.h"
+#include "test/drivers/test_state.h"
+
#include <stdint.h>
#include <string.h>
-#include <zephyr/ztest.h>
+
+#include <zephyr/drivers/pwm.h>
#include <zephyr/kernel.h>
#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
#include <zephyr/ztest_assert.h>
-#include "console.h"
-#include "host_command.h"
-#include "keyboard_backlight.h"
-#include "test/drivers/test_state.h"
+#define KBLIGHT_PWM_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(cros_ec_kblight_pwm)
+
+extern const struct kblight_drv kblight_pwm;
/**
* @brief Send host command to set the backlight percentage
@@ -56,7 +63,7 @@ ZTEST(keyboard_backlight, host_command_get_backlight__normal)
uint8_t expected_percentage = 50;
int ret;
- zassume_ok(set_backlight_percent_helper(expected_percentage), NULL);
+ zassert_ok(set_backlight_percent_helper(expected_percentage), NULL);
/* Brief delay to allow a deferred function to enable the backlight */
k_sleep(K_MSEC(50));
@@ -78,7 +85,7 @@ ZTEST(keyboard_backlight, console_command__noargs)
const char *outbuffer;
size_t buffer_size;
- zassume_ok(set_backlight_percent_helper(70), NULL);
+ zassert_ok(set_backlight_percent_helper(70), NULL);
k_sleep(K_MSEC(50));
/* With no args, print current state */
@@ -102,7 +109,7 @@ ZTEST(keyboard_backlight, console_command__set_on)
ZTEST(keyboard_backlight, console_command__set_off)
{
- zassume_ok(set_backlight_percent_helper(40), NULL);
+ zassert_ok(set_backlight_percent_helper(40), NULL);
k_sleep(K_MSEC(50));
/* Turn back off */
@@ -121,6 +128,26 @@ ZTEST(keyboard_backlight, console_command__bad_params)
shell_execute_cmd(get_ec_shell(), "kblight 101"), NULL);
}
+ZTEST(keyboard_backlight, set_backlight__device_not_ready)
+{
+ const struct pwm_dt_spec kblight_pwm_dt =
+ PWM_DT_SPEC_GET(KBLIGHT_PWM_NODE);
+ const struct device *pwm_dev = kblight_pwm_dt.dev;
+ int initial_duty;
+ int initialized_saved;
+
+ initial_duty = pwm_mock_get_duty(pwm_dev, kblight_pwm_dt.channel);
+
+ initialized_saved = pwm_dev->state->initialized;
+ pwm_dev->state->initialized = 0;
+
+ zassert_ok(kblight_pwm.set(initial_duty + 10), NULL);
+ zassert_equal(initial_duty,
+ pwm_mock_get_duty(pwm_dev, kblight_pwm_dt.channel), NULL);
+
+ pwm_dev->state->initialized = initialized_saved;
+}
+
static void reset(void *data)
{
ARG_UNUSED(data);
diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c
index 03fb71f828..91b69562b1 100644
--- a/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c
+++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_scan.c
@@ -2,15 +2,6 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <string.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/emul.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/fff.h>
-#include <emul/emul_kb_raw.h>
-
#include "console.h"
#include "host_command.h"
#include "keyboard_scan.h"
@@ -18,6 +9,17 @@
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include <string.h>
+
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
+
+#include <emul/emul_kb_raw.h>
+
ZTEST(keyboard_scan, test_boot_key)
{
const struct device *dev = DEVICE_DT_GET(DT_NODELABEL(cros_kb_raw));
@@ -130,7 +132,7 @@ ZTEST(keyboard_scan, console_command_ksstate__force)
*/
keyboard_scan_enable(false, -1);
- zassume_false(keyboard_scan_is_enabled());
+ zassert_false(keyboard_scan_is_enabled());
zassert_ok(shell_execute_cmd(get_ec_shell(), "ksstate force"));
@@ -142,7 +144,7 @@ ZTEST(keyboard_scan, console_command_ksstate__on_off)
{
/* This command turns state change printing on/off */
- zassume_false(keyboard_scan_get_print_state_changes());
+ zassert_false(keyboard_scan_get_print_state_changes());
zassert_ok(shell_execute_cmd(get_ec_shell(), "ksstate on"));
zassert_true(keyboard_scan_get_print_state_changes());
@@ -235,7 +237,7 @@ ZTEST(keyboard_scan, host_command_simulate_key__locked)
{
uint16_t ret;
- zassume_true(system_is_locked(), "Expecting locked system.");
+ zassert_true(system_is_locked(), "Expecting locked system.");
struct ec_response_keyboard_factory_test response;
struct ec_params_mkbp_simulate_key params;
@@ -251,7 +253,7 @@ ZTEST(keyboard_scan, host_command_simulate_key__bad_params)
uint16_t ret;
system_is_locked_fake.return_val = 0;
- zassume_false(system_is_locked(), "Expecting unlocked system.");
+ zassert_false(system_is_locked(), "Expecting unlocked system.");
struct ec_response_keyboard_factory_test response;
struct ec_params_mkbp_simulate_key params = {
@@ -293,7 +295,7 @@ ZTEST(keyboard_scan, host_command_simulate__key_press)
uint16_t ret;
system_is_locked_fake.return_val = 0;
- zassume_false(system_is_locked(), "Expecting unlocked system.");
+ zassert_false(system_is_locked(), "Expecting unlocked system.");
ret = send_keypress_host_command(1, 2, 1);
zassert_equal(EC_RES_SUCCESS, ret, "Command returned %u", ret);
@@ -323,7 +325,7 @@ FAKE_VOID_FUNC(chipset_reset, int);
ZTEST(keyboard_scan, special_key_combos)
{
system_is_locked_fake.return_val = 0;
- zassume_false(system_is_locked(), "Expecting unlocked system.");
+ zassert_false(system_is_locked(), "Expecting unlocked system.");
/* Set the volume up key coordinates to something arbitrary */
int vol_up_col = 1;
@@ -332,7 +334,7 @@ ZTEST(keyboard_scan, special_key_combos)
set_vol_up_key(vol_up_row, vol_up_col);
/* Vol up and the alt keys must be in different columns */
- zassume_false(vol_up_col == KEYBOARD_COL_LEFT_ALT, NULL);
+ zassert_false(vol_up_col == KEYBOARD_COL_LEFT_ALT, NULL);
/* Hold down volume up, left alt (either alt key works), and R */
zassert_ok(send_keypress_host_command(vol_up_col, vol_up_row, 1));
diff --git a/zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c b/zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c
index 7b49bd1df4..4141028408 100644
--- a/zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c
+++ b/zephyr/test/drivers/keyboard_scan/src/keyboard_test_utils.c
@@ -1,11 +1,12 @@
-/* Copyright 2022 The ChromiumOS Authors.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <emul/emul_kb_raw.h>
#include <zephyr/drivers/emul.h>
+#include <emul/emul_kb_raw.h>
+
const static struct device *dev = DEVICE_DT_GET(DT_NODELABEL(cros_kb_raw));
int emulate_keystate(int row, int col, int pressed)
diff --git a/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c b/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c
index dee2ba2d1b..2d6560fd1e 100644
--- a/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c
+++ b/zephyr/test/drivers/keyboard_scan/src/mkbp_event.c
@@ -2,19 +2,23 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/emul.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/fff.h>
-#include <emul/emul_kb_raw.h>
+#include "chipset.h"
#include "console.h"
#include "host_command.h"
#include "mkbp_event.h"
#include "mkbp_fifo.h"
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
+#include <emul/emul_kb_raw.h>
/**
* @brief FFF fake that will be registered as a callback to monitor the EC->AP
@@ -33,7 +37,7 @@ struct event_fixture {
static struct event_fixture fixture;
-ZTEST(mkbp_event, host_command_get_events__empty)
+ZTEST(mkbp_event, test_host_command_get_events__empty)
{
/* Issue a host command to get the next event (from any source) */
uint16_t ret;
@@ -46,7 +50,102 @@ ZTEST(mkbp_event, host_command_get_events__empty)
"Expected EC_RES_UNAVAILABLE but got %d", ret);
}
-ZTEST(mkbp_event, host_command_get_events__get_event)
+ZTEST(mkbp_event, test_activate_with_events)
+{
+ const struct device *gpio_dev = DEVICE_DT_GET(
+ DT_GPIO_CTLR(DT_NODELABEL(gpio_ap_ec_int_l), gpios));
+ const int gpio_pin = DT_GPIO_PIN(DT_NODELABEL(gpio_ap_ec_int_l), gpios);
+
+ /* Put the chipset to sleep */
+ chipset_force_shutdown(CHIPSET_SHUTDOWN_BUTTON);
+ k_sleep(K_SECONDS(15));
+
+ /* Activate with no events, should not trigger an interrupt */
+ activate_mkbp_with_events(0);
+
+ /* Check that GPIO is still 1 */
+ zassert_equal(1, gpio_emul_output_get(gpio_dev, gpio_pin));
+}
+
+ZTEST(mkbp_event, test_host_command_host_event_wake_mask)
+{
+ struct ec_response_mkbp_event_wake_mask response = { 0 };
+ struct ec_params_mkbp_event_wake_mask params = { 0 };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND(EC_CMD_MKBP_WAKE_MASK, 0, response, params);
+
+ /* Set the wake mask to 0x12345678 */
+ params.action = SET_WAKE_MASK;
+ params.mask_type = EC_MKBP_HOST_EVENT_WAKE_MASK;
+ params.new_wake_mask = 0x12345678;
+
+ zassert_ok(host_command_process(&args));
+
+ /* Get the wake mask */
+ params.action = GET_WAKE_MASK;
+
+ zassert_ok(host_command_process(&args));
+ zassert_equal(0x12345678, response.wake_mask);
+}
+
+ZTEST(mkbp_event, test_host_command_event_wake_mask)
+{
+ struct ec_response_mkbp_event_wake_mask response = { 0 };
+ struct ec_params_mkbp_event_wake_mask params = { 0 };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND(EC_CMD_MKBP_WAKE_MASK, 0, response, params);
+
+ /* Set the wake mask to 0x87654321 */
+ params.action = SET_WAKE_MASK;
+ params.mask_type = EC_MKBP_EVENT_WAKE_MASK;
+ params.new_wake_mask = 0x87654321;
+
+ zassert_ok(host_command_process(&args));
+
+ /* Get the wake mask */
+ params.action = GET_WAKE_MASK;
+
+ zassert_ok(host_command_process(&args));
+ zassert_equal(0x87654321, response.wake_mask);
+}
+
+ZTEST(mkbp_event, test_host_command_wake_mask__invalid_args)
+{
+ struct ec_response_mkbp_event_wake_mask response = { 0 };
+ struct ec_params_mkbp_event_wake_mask params = {
+ .action = -1,
+ .mask_type = -1,
+ };
+ struct host_cmd_handler_args args =
+ BUILD_HOST_COMMAND(EC_CMD_MKBP_WAKE_MASK, 0, response, params);
+
+ /* Check invalid action */
+ zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args));
+
+ /* Check invalid mask type in getter */
+ params.action = GET_WAKE_MASK;
+ zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args));
+
+ /* Check invalid mask type in setter */
+ params.action = SET_WAKE_MASK;
+ zassert_equal(EC_RES_INVALID_PARAM, host_command_process(&args));
+}
+
+ZTEST(mkbp_event, test_console_command_wake_mask_event)
+{
+ check_console_cmd("mkbpwakemask event 500",
+ "MKBP event wake mask: 0x000001f4", 0, __FILE__,
+ __LINE__);
+ check_console_cmd("mkbpwakemask hostevent 7934",
+ "MKBP host event wake mask: 0x00001efe", 0, __FILE__,
+ __LINE__);
+ check_console_cmd("mkbpwakemask event f", NULL, EC_ERROR_PARAM2,
+ __FILE__, __LINE__);
+ check_console_cmd("mkbpwakemask event", NULL, EC_ERROR_PARAM_COUNT,
+ __FILE__, __LINE__);
+}
+
+ZTEST(mkbp_event, test_host_command_get_events__get_event)
{
/* Dispatch a fake keyboard event and ensure it gets returned by the
* host command.
@@ -98,7 +197,7 @@ ZTEST(mkbp_event, host_command_get_events__get_event)
interrupt_gpio_monitor_fake.call_count);
}
-ZTEST(mkbp_event, no_ap_response)
+ZTEST(mkbp_event, test_no_ap_response)
{
/* Cause an event but do not send any host commands. This should cause
* the EC to send the interrupt to the AP 3 times before giving up.
@@ -153,7 +252,7 @@ static void *setup(void)
.handler = interrupt_gpio_monitor,
};
- zassume_ok(gpio_add_callback(interrupt_pin->port,
+ zassert_ok(gpio_add_callback(interrupt_pin->port,
&fixture.callback_config),
"Could not configure GPIO callback.");
@@ -183,6 +282,8 @@ static void reset_events(void *data)
RESET_FAKE(interrupt_gpio_monitor);
RESET_FAKE(mkbp_send_event);
mkbp_send_event_fake.return_val = 1;
+
+ test_set_chipset_to_s0();
}
ZTEST_SUITE(mkbp_event, drivers_predicate_post_main, setup, reset_events,
diff --git a/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c b/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c
index b0d64eb1da..6fd1b0f975 100644
--- a/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c
+++ b/zephyr/test/drivers/keyboard_scan/src/mkbp_info.c
@@ -1,11 +1,7 @@
-/* Copyright 2022 The ChromiumOS Authors.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/fff.h>
-#include <emul/emul_kb_raw.h>
-
#include "console.h"
#include "host_command.h"
#include "keyboard_scan.h"
@@ -14,6 +10,11 @@
#include "mkbp_input_devices.h"
#include "test/drivers/test_state.h"
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
+#include <emul/emul_kb_raw.h>
+
ZTEST(mkbp_info, host_command_mkbp_info__keyboard_info)
{
/* Get the number of keyboard rows and columns */
diff --git a/zephyr/test/drivers/led_common/CMakeLists.txt b/zephyr/test/drivers/led_common/CMakeLists.txt
new file mode 100644
index 0000000000..9386414deb
--- /dev/null
+++ b/zephyr/test/drivers/led_common/CMakeLists.txt
@@ -0,0 +1,5 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+target_sources(app PRIVATE src/main.c)
diff --git a/zephyr/test/drivers/led_common/src/main.c b/zephyr/test/drivers/led_common/src/main.c
new file mode 100644
index 0000000000..4a712a3779
--- /dev/null
+++ b/zephyr/test/drivers/led_common/src/main.c
@@ -0,0 +1,31 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "led_common.h"
+#include "test/drivers/test_state.h"
+
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
+const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED,
+ EC_LED_ID_POWER_LED };
+const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
+
+FAKE_VOID_FUNC(led_get_brightness_range, enum ec_led_id, uint8_t *);
+FAKE_VALUE_FUNC(int, led_set_brightness, enum ec_led_id, const uint8_t *);
+
+ZTEST_SUITE(led_common, drivers_predicate_post_main, NULL, NULL, NULL, NULL);
+
+ZTEST(led_common, test_led_is_supported)
+{
+ zassert_true(led_is_supported(EC_LED_ID_BATTERY_LED));
+ zassert_true(led_is_supported(EC_LED_ID_POWER_LED));
+
+ zassert_false(led_is_supported(EC_LED_ID_ADAPTER_LED));
+ zassert_false(led_is_supported(EC_LED_ID_LEFT_LED));
+ zassert_false(led_is_supported(EC_LED_ID_RIGHT_LED));
+ zassert_false(led_is_supported(EC_LED_ID_RECOVERY_HW_REINIT_LED));
+ zassert_false(led_is_supported(EC_LED_ID_SYSRQ_DEBUG_LED));
+}
diff --git a/zephyr/test/drivers/led_driver/led_pins.dts b/zephyr/test/drivers/led_driver/led_pins.dts
index f1488a59d8..cf57102a3c 100644
--- a/zephyr/test/drivers/led_driver/led_pins.dts
+++ b/zephyr/test/drivers/led_driver/led_pins.dts
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
- /* Based off of `ec/zephyr/projects/herobrine/led_pins_herobrine.dts`
+ /* Based off of `ec/zephyr/program/herobrine/led_pins_herobrine.dts`
* Modified led-colors to obtain better test coverage.
*/
/ {
@@ -17,42 +17,48 @@
color_off_left: color-off-left {
led-color = "LED_OFF";
led-id = "EC_LED_ID_SYSRQ_DEBUG_LED";
- led-pins = <&gpio_ec_chg_led_y_c1 0>,
- <&gpio_ec_chg_led_w_c1 0>;
+ led-pins = <&gpio_ec_chg_led_y_c1
+ &gpio_ec_chg_led_w_c1>;
+ led-values = <0 0>;
};
color_off_right: color-off-right {
led-color = "LED_OFF";
led-id = "EC_LED_ID_RIGHT_LED";
- led-pins = <&gpio_ec_chg_led_y_c0 0>,
- <&gpio_ec_chg_led_w_c0 0>;
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_w_c0>;
+ led-values = <0 0>;
};
color_blue_left: color-blue-left {
led-color = "LED_BLUE";
led-id = "EC_LED_ID_SYSRQ_DEBUG_LED";
br-color = "EC_LED_COLOR_BLUE";
- led-pins = <&gpio_ec_chg_led_y_c1 1>,
- <&gpio_ec_chg_led_w_c1 0>;
+ led-pins = <&gpio_ec_chg_led_y_c1
+ &gpio_ec_chg_led_w_c1>;
+ led-values = <1 0>;
};
color_blue_right: color-blue-right {
led-color = "LED_BLUE";
led-id = "EC_LED_ID_RIGHT_LED";
br-color = "EC_LED_COLOR_BLUE";
- led-pins = <&gpio_ec_chg_led_y_c0 1>,
- <&gpio_ec_chg_led_w_c0 0>;
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_w_c0>;
+ led-values = <1 0>;
};
color_white_left: color-white-left {
led-color = "LED_WHITE";
led-id = "EC_LED_ID_SYSRQ_DEBUG_LED";
br-color = "EC_LED_COLOR_WHITE";
- led-pins = <&gpio_ec_chg_led_y_c1 0>,
- <&gpio_ec_chg_led_w_c1 1>;
+ led-pins = <&gpio_ec_chg_led_y_c1
+ &gpio_ec_chg_led_w_c1>;
+ led-values = <0 1>;
};
color_white_right: color-white-right {
led-color = "LED_WHITE";
led-id = "EC_LED_ID_RIGHT_LED";
br-color = "EC_LED_COLOR_WHITE";
- led-pins = <&gpio_ec_chg_led_y_c0 0>,
- <&gpio_ec_chg_led_w_c0 1>;
+ led-pins = <&gpio_ec_chg_led_y_c0
+ &gpio_ec_chg_led_w_c0>;
+ led-values = <0 1>;
};
};
};
diff --git a/zephyr/test/drivers/led_driver/led_policy.dts b/zephyr/test/drivers/led_driver/led_policy.dts
index fb6d37cb05..cad972bf11 100644
--- a/zephyr/test/drivers/led_driver/led_policy.dts
+++ b/zephyr/test/drivers/led_driver/led_policy.dts
@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
-/* Based off of `ec/zephyr/projects/herobrine/led_policy_herobrine.dts`
+/* Based off of `ec/zephyr/program/herobrine/led_policy_herobrine.dts`
* Modified led-colors to obtain better test coverage.
*/
diff --git a/zephyr/test/drivers/led_driver/src/led.c b/zephyr/test/drivers/led_driver/src/led.c
index 4e4023beb4..135f2eab01 100644
--- a/zephyr/test/drivers/led_driver/src/led.c
+++ b/zephyr/test/drivers/led_driver/src/led.c
@@ -3,7 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
#include "ec_commands.h"
#include "gpio.h"
#include "include/power.h"
@@ -12,6 +11,8 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/ztest.h>
+
#define VERIFY_LED_COLOR(color, led_id) \
{ \
const struct led_pins_node_t *pin_node = \
diff --git a/zephyr/test/drivers/led_driver/src/led_common.c b/zephyr/test/drivers/led_driver/src/led_common.c
index e11a1f1952..2b113499a0 100644
--- a/zephyr/test/drivers/led_driver/src/led_common.c
+++ b/zephyr/test/drivers/led_driver/src/led_common.c
@@ -2,13 +2,13 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/fff.h>
-
#include "host_command.h"
#include "led_common.h"
#include "test/drivers/test_state.h"
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
ZTEST(led_common, host_command__query)
{
/* Gets the brightness range for an LED */
diff --git a/zephyr/test/drivers/locate_chip/src/locate_chip.c b/zephyr/test/drivers/locate_chip/src/locate_chip.c
index 5e4fd078d7..881b17a54c 100644
--- a/zephyr/test/drivers/locate_chip/src/locate_chip.c
+++ b/zephyr/test/drivers/locate_chip/src/locate_chip.c
@@ -3,10 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
-#include "test/drivers/test_state.h"
#include "host_command.h"
+#include "test/drivers/test_state.h"
+
+#include <zephyr/ztest.h>
ZTEST_SUITE(locate_chip, drivers_predicate_post_main, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/drivers/memmap/CMakeLists.txt b/zephyr/test/drivers/memmap/CMakeLists.txt
new file mode 100644
index 0000000000..9386414deb
--- /dev/null
+++ b/zephyr/test/drivers/memmap/CMakeLists.txt
@@ -0,0 +1,5 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+target_sources(app PRIVATE src/main.c)
diff --git a/zephyr/test/drivers/memmap/src/main.c b/zephyr/test/drivers/memmap/src/main.c
new file mode 100644
index 0000000000..89ea2c52cd
--- /dev/null
+++ b/zephyr/test/drivers/memmap/src/main.c
@@ -0,0 +1,89 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "flash.h"
+#include "host_command.h"
+#include "test/drivers/test_state.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#include <zephyr/ztest.h>
+
+extern const char *flash_physical_dataptr_override;
+
+static char flash[CONFIG_FLASH_SIZE_BYTES];
+
+static void after(void *f)
+{
+ ARG_UNUSED(f);
+ flash_physical_dataptr_override = NULL;
+}
+
+ZTEST_SUITE(memmap, drivers_predicate_post_main, NULL, NULL, after, NULL);
+
+ZTEST(memmap, test_crec_flash_dataptr__invalid)
+{
+ zassert_equal(-1, crec_flash_dataptr(/*offset=*/-1, /*size_req=*/1,
+ /*align=*/1, /*ptrp=*/NULL));
+}
+
+ZTEST(memmap, test_crec_flash_dataptr)
+{
+ const char *ptr = NULL;
+
+ zassert_equal(CONFIG_PLATFORM_EC_FLASH_SIZE_BYTES,
+ crec_flash_dataptr(0, 1, 1, &ptr));
+ zassert_equal(CONFIG_PLATFORM_EC_MAPPED_STORAGE_BASE, (uintptr_t)ptr);
+}
+
+ZTEST(memmap, test_crec_flash_is_erased__invalid_args)
+{
+ zassert_equal(0, crec_flash_is_erased(/*offset=*/0, /*size=*/-1));
+}
+
+ZTEST(memmap, test_crec_flash_is_erased__fail)
+{
+ sprintf(flash, "non empty data");
+ flash_physical_dataptr_override = flash;
+ zassert_equal(0, crec_flash_is_erased(/*offset=*/0, /*size=*/8));
+}
+
+ZTEST(memmap, test_crec_flash_is_erased__pass)
+{
+ memset(flash, 0xff, 32);
+ flash_physical_dataptr_override = flash;
+ zassert_equal(1, crec_flash_is_erased(/*offset=*/0, /*size=*/32));
+}
+
+ZTEST(memmap, test_crec_flash_read__invalid_args)
+{
+ zassert_equal(EC_ERROR_INVAL, crec_flash_read(/*offset=*/-1, /*size=*/0,
+ /*data=*/NULL));
+}
+
+ZTEST(memmap, test_crec_flash_read)
+{
+ char output[16] = { 0 };
+
+ sprintf(flash, "0123456789abcdef");
+ flash_physical_dataptr_override = flash;
+
+ zassert_ok(crec_flash_read(/*offset=*/0, ARRAY_SIZE(output), output));
+ zassert_mem_equal(output, flash, ARRAY_SIZE(output));
+}
+
+ZTEST(memmap, test_crec_flash_write__invalid_args)
+{
+ zassert_equal(EC_ERROR_INVAL,
+ crec_flash_write(/*offset=*/-1, /*size=*/0,
+ /*data=*/NULL));
+}
+
+ZTEST(memmap, test_crec_flash_erase__invalid_args)
+{
+ zassert_equal(EC_ERROR_INVAL,
+ crec_flash_erase(/*offset=*/-1, /*size=*/0));
+}
diff --git a/zephyr/test/drivers/mkbp/src/mkbp_fifo.c b/zephyr/test/drivers/mkbp/src/mkbp_fifo.c
index b80febbec9..5d59dababd 100644
--- a/zephyr/test/drivers/mkbp/src/mkbp_fifo.c
+++ b/zephyr/test/drivers/mkbp/src/mkbp_fifo.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/emul.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest_assert.h>
-#include <zephyr/drivers/i2c_emul.h>
-
#include "keyboard_config.h"
#include "mkbp_fifo.h"
#include "test/drivers/test_state.h"
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+#include <zephyr/ztest_assert.h>
+
/* Tests for Matrix Keyboard Protocol (MKBP) */
/* Largest event size that we support */
diff --git a/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c b/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c
index a76400a98a..521b4c735b 100644
--- a/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c
+++ b/zephyr/test/drivers/power_host_sleep/src/test_power_host_sleep.c
@@ -3,10 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/ztest_assert.h>
-
#include "ec_commands.h"
#include "hooks.h"
#include "host_command.h"
@@ -15,6 +11,10 @@
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+#include <zephyr/ztest_assert.h>
+
#define ARBITRARY_SLEEP_TRANSITIONS 1
/*
diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf
index 70ecb04422..167994a11c 100644
--- a/zephyr/test/drivers/prj.conf
+++ b/zephyr/test/drivers/prj.conf
@@ -44,28 +44,11 @@ CONFIG_PLATFORM_EC=y
CONFIG_CROS_EC=y
CONFIG_SHIMMED_TASKS=y
CONFIG_EMUL=y
-CONFIG_LOG=y
-CONFIG_I2C=y
-CONFIG_I2C_EMUL=y
CONFIG_GPIO=y
-CONFIG_GPIO_EMUL=y
CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY=49
CONFIG_EEPROM=y
-CONFIG_EEPROM_AT24=y
CONFIG_EEPROM_SIMULATOR=n
CONFIG_EMUL_EEPROM_AT2X=y
-CONFIG_EMUL_SMART_BATTERY=y
-CONFIG_EMUL_BC12_DETECT_PI3USB9201=y
-CONFIG_EMUL_PPC_SYV682X=y
-CONFIG_ADC=y
-CONFIG_ADC_EMUL=y
-CONFIG_EMUL_BMA255=y
-CONFIG_EMUL_BMI=y
-CONFIG_EMUL_TCS3400=y
-CONFIG_EMUL_BB_RETIMER=y
-CONFIG_EMUL_TCPCI=y
-CONFIG_EMUL_PS8XXX=y
-CONFIG_EMUL_RTC=y
CONFIG_EMUL_TCPCI_PARTNER_DRP=y
CONFIG_EMUL_TCPCI_PARTNER_FAULTY_EXT=y
CONFIG_PLATFORM_EC_CHARGE_MANAGER=y
@@ -73,6 +56,7 @@ CONFIG_PLATFORM_EC_CHARGE_RAMP_SW=y
CONFIG_PLATFORM_EC_CHARGESPLASH=y
CONFIG_PLATFORM_EC_POWERSEQ=y
+CONFIG_PLATFORM_EC_CMD_PWR_AVG=y
CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
@@ -80,10 +64,8 @@ CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
CONFIG_PLATFORM_EC_USB_PID=0x5000
CONFIG_PLATFORM_EC_USBC=y
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_BATTERY=y
CONFIG_PLATFORM_EC_BATTERY_SMART=y
CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y
@@ -99,11 +81,11 @@ CONFIG_PLATFORM_EC_USB_PD_REV30=y
CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
CONFIG_PLATFORM_EC_HOSTCMD=y
CONFIG_PLATFORM_EC_USB_PD_TCPM_TUSB422=y
+CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y
CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y
-CONFIG_PLATFORM_EC_TEMP_SENSOR=y
CONFIG_PLATFORM_EC_TEMP_SENSOR_POWER=y
-CONFIG_PLATFORM_EC_THERMISTOR=y
+CONFIG_PLATFORM_EC_SWITCH=y
CONFIG_PLATFORM_EC_SWITCHCAP_LN9310=y
CONFIG_PLATFORM_EC_ACCEL_BMA255=y
CONFIG_PLATFORM_EC_MOTIONSENSE=y
@@ -139,7 +121,6 @@ CONFIG_ESPI_PERIPHERAL_EC_HOST_CMD=y
# Things that default to on, but aren't working yet
CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-CONFIG_PLATFORM_EC_SWITCH=n
CONFIG_PLATFORM_EC_VBOOT_HASH=n
CONFIG_PLATFORM_EC_POWERSEQ_INTEL=n
CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
@@ -166,9 +147,7 @@ CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y
CONFIG_PLATFORM_EC_MKBP_EVENT=y
CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y
CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
-CONFIG_EMUL_KB_RAW=y
CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y
-CONFIG_EMUL_CROS_FLASH=y
CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH=y
CONFIG_PLATFORM_EC_VBOOT_HASH=y
@@ -190,5 +169,3 @@ CONFIG_PLATFORM_EC_TABLET_MODE=y
# Power Management (Herobrine arch enables this)
CONFIG_PM=y
-
-CONFIG_PWM_MOCK=y
diff --git a/zephyr/test/drivers/rt9490/charger.dts b/zephyr/test/drivers/rt9490/charger.dts
index 5a3815490f..4d4a2a4f35 100644
--- a/zephyr/test/drivers/rt9490/charger.dts
+++ b/zephyr/test/drivers/rt9490/charger.dts
@@ -4,26 +4,21 @@
compatible = "named-usbc-port";
reg = <0>;
chg = <&rt9490>;
- bc12 = <&rt9490_bc12>;
+ bc12 = <&rt9490>;
tcpc = <&tcpci_emul>;
};
port1@1 {
- bc12 = <&rt9490_bc12>;
+ bc12 = <&rt9490>;
};
};
-
- rt9490_bc12: rt9490-bc12 {
- compatible = "richtek,rt9490-bc12";
- status = "okay";
- };
};
&i2c0 {
- status="okay";
+ status = "okay";
rt9490: rt9490@53 {
- compatible = "zephyr,rt9490-emul";
+ compatible = "zephyr,rt9490-emul", "richtek,rt9490";
status = "okay";
reg = <0x53>;
};
diff --git a/zephyr/test/drivers/rt9490/prj.conf b/zephyr/test/drivers/rt9490/prj.conf
index 29c63c48f3..1d1b6c4c71 100644
--- a/zephyr/test/drivers/rt9490/prj.conf
+++ b/zephyr/test/drivers/rt9490/prj.conf
@@ -2,10 +2,8 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-CONFIG_EMUL_RT9490=y
CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n
CONFIG_PLATFORM_EC_CHARGER_OTG=y
-CONFIG_PLATFORM_EC_CHARGER_RT9490=y
CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y
CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y
CONFIG_PLATFORM_EC_HOOKS=y
diff --git a/zephyr/test/drivers/rt9490/src/bc12.c b/zephyr/test/drivers/rt9490/src/bc12.c
index eae2308c93..b32d50768e 100644
--- a/zephyr/test/drivers/rt9490/src/bc12.c
+++ b/zephyr/test/drivers/rt9490/src/bc12.c
@@ -3,11 +3,8 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/fff.h>
-
-#include "charger.h"
#include "charge_manager.h"
+#include "charger.h"
#include "driver/charger/rt9490.h"
#include "driver/tcpm/tcpci.h"
#include "emul/emul_rt9490.h"
@@ -17,11 +14,16 @@
#include "timer.h"
#include "usb_charge.h"
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
+FAKE_VALUE_FUNC(int, board_tcpc_post_init, int);
+
static const struct emul *emul = EMUL_DT_GET(DT_NODELABEL(rt9490));
static const struct emul *tcpci_emul = EMUL_DT_GET(DT_NODELABEL(tcpci_emul));
static const int chgnum = CHARGER_SOLO;
-void run_bc12_test(int reg_value, enum charge_supplier expected_result)
+static void run_bc12_test(int reg_value, enum charge_supplier expected_result)
{
int port = 0;
@@ -29,7 +31,19 @@ void run_bc12_test(int reg_value, enum charge_supplier expected_result)
tcpci_emul_set_reg(tcpci_emul, TCPC_REG_POWER_STATUS,
TCPC_REG_POWER_STATUS_VBUS_PRES |
TCPC_REG_POWER_STATUS_VBUS_DET);
- zassert_ok(tcpc_config[port].drv->init(port), NULL);
+
+ /* This is the same as calling tcpc_config[port].drv->init(port) but
+ * also calls our board_tcpc_post_init_fake stub. During the init, the
+ * other tasks are also running and will at times also call the same
+ * function. So the verification just checks that the call count
+ * increased and that the first history element matches the port we
+ * provided.
+ */
+ RESET_FAKE(board_tcpc_post_init);
+ zassert_ok(tcpm_init(port));
+ zassert_true(board_tcpc_post_init_fake.call_count > 0);
+ zassert_equal(port, board_tcpc_post_init_fake.arg0_history[0]);
+
zassert_true(tcpc_config[port].drv->check_vbus_level(port,
VBUS_PRESENT),
NULL);
diff --git a/zephyr/test/drivers/rt9490/src/charger.c b/zephyr/test/drivers/rt9490/src/charger.c
index f0d3510b89..2d892f9432 100644
--- a/zephyr/test/drivers/rt9490/src/charger.c
+++ b/zephyr/test/drivers/rt9490/src/charger.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "battery_smart.h"
#include "charger.h"
#include "driver/charger/rt9490.h"
#include "emul/emul_rt9490.h"
#include "i2c.h"
+#include <zephyr/ztest.h>
+
static const struct emul *emul = EMUL_DT_GET(DT_NODELABEL(rt9490));
static const int chgnum = CHARGER_SOLO;
diff --git a/zephyr/test/drivers/shim_gpio_id/gpio_id.dts b/zephyr/test/drivers/shim_gpio_id/gpio_id.dts
index 050272141f..cd2303cfa9 100644
--- a/zephyr/test/drivers/shim_gpio_id/gpio_id.dts
+++ b/zephyr/test/drivers/shim_gpio_id/gpio_id.dts
@@ -5,20 +5,16 @@
/ {
/* Required to compile board_get_sku_id() from shim/gpio_id.c */
- sku {
+ gpio_id_sku: sku {
compatible = "cros-ec,gpio-id";
-
bits = <&gpio_sku_id0>;
-
system = "ternary";
};
/* Required to compile board_get_version() from shim/gpio_id.c */
- board {
+ gpio_id_board: board {
compatible = "cros-ec,gpio-id";
-
bits = <&gpio_brd_id0>;
-
system = "ternary";
};
};
diff --git a/zephyr/test/drivers/shim_gpio_id/src/test_shim_gpio_id.c b/zephyr/test/drivers/shim_gpio_id/src/test_shim_gpio_id.c
index 035d0c1b48..5e9381c2a5 100644
--- a/zephyr/test/drivers/shim_gpio_id/src/test_shim_gpio_id.c
+++ b/zephyr/test/drivers/shim_gpio_id/src/test_shim_gpio_id.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "system.h"
#include "test/drivers/test_state.h"
#include "util.h"
+#include <zephyr/ztest.h>
+
/*
* TODO(b/254924012): Test alternative GPIO when emulated gpio tristate is
* supported upstream.
diff --git a/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c b/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c
index 847326c0ba..ddc406e58c 100644
--- a/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c
+++ b/zephyr/test/drivers/shim_pwm_hc/src/test_shim_pwm_hc.c
@@ -3,12 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/emul.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest_assert.h>
-#include <zephyr/drivers/i2c_emul.h>
-
#include "drivers/cros_displight.h"
#include "ec_commands.h"
#include "host_command.h"
@@ -16,6 +10,12 @@
#include "pwm.h"
#include "test/drivers/test_state.h"
+#include <zephyr/drivers/emul.h>
+#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+#include <zephyr/ztest_assert.h>
+
ZTEST(shim_pwm_hc, test_pwm_set_duty_hc__kblight)
{
struct ec_params_pwm_set_duty p = {
@@ -35,8 +35,8 @@ ZTEST(shim_pwm_hc, test_pwm_set_duty_hc__kblight)
ZTEST(shim_pwm_hc, test_pwm_set_duty_hc__displight)
{
struct ec_params_pwm_set_duty p = {
- p.index = DT_REG_ADDR(DT_NODELABEL(pwm_displight)),
- p.pwm_type = EC_PWM_TYPE_DISPLAY_LIGHT,
+ .index = DT_REG_ADDR(DT_NODELABEL(pwm_displight)),
+ .pwm_type = EC_PWM_TYPE_DISPLAY_LIGHT,
/* Arbitrary 72% */
.duty = PWM_PERCENT_TO_RAW(72)
};
diff --git a/zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c b/zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c
index b3d2dfa465..6f4f9a43e2 100644
--- a/zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c
+++ b/zephyr/test/drivers/shim_rtc/src/test_shim_rtc.c
@@ -3,17 +3,17 @@
* found in the LICENSE file.
*/
-#include <zephyr/drivers/i2c_emul.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/ztest_assert.h>
-
#include "ec_commands.h"
#include "host_command.h"
#include "lpc.h"
#include "system.h"
#include "test/drivers/test_state.h"
+#include <zephyr/drivers/i2c_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+#include <zephyr/ztest_assert.h>
+
ZTEST_USER(rtc_shim, test_hc_rtc_set_get_value)
{
struct ec_params_rtc set_value;
diff --git a/zephyr/test/drivers/system/src/system.c b/zephyr/test/drivers/system/src/system.c
index 4e3009ceab..b615dfc2df 100644
--- a/zephyr/test/drivers/system/src/system.c
+++ b/zephyr/test/drivers/system/src/system.c
@@ -3,19 +3,19 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/ztest.h>
-
#include "ec_commands.h"
#include "host_command.h"
+#include "mock/power.h"
#include "panic.h"
#include "system.h"
#include "test/drivers/stubs.h"
#include "test/drivers/test_mocks.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include "mock/power.h"
+
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
FAKE_VALUE_FUNC(int, system_run_image_copy_with_flags, enum ec_image, int);
FAKE_VOID_FUNC(system_disable_jump);
diff --git a/zephyr/test/drivers/system/src/system_board_version_cbi.c b/zephyr/test/drivers/system/src/system_board_version_cbi.c
index d076716e23..cd4e40eef2 100644
--- a/zephyr/test/drivers/system/src/system_board_version_cbi.c
+++ b/zephyr/test/drivers/system/src/system_board_version_cbi.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "ec_commands.h"
#include "host_command.h"
#include "system.h"
-#include "test/drivers/test_state.h"
#include "test/drivers/test_mocks.h"
+#include "test/drivers/test_state.h"
+
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
FAKE_VALUE_FUNC(int, cbi_get_board_version, uint32_t *);
diff --git a/zephyr/test/drivers/system/src/system_board_version_default.c b/zephyr/test/drivers/system/src/system_board_version_default.c
index bcd28cc3de..0ef11a8c39 100644
--- a/zephyr/test/drivers/system/src/system_board_version_default.c
+++ b/zephyr/test/drivers/system/src/system_board_version_default.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "ec_commands.h"
#include "host_command.h"
+#include <zephyr/ztest.h>
+
ZTEST_USER(system, test_hostcmd_board_version)
{
struct ec_response_board_version response;
diff --git a/zephyr/test/drivers/system/src/system_not_board_ap_set_sku_id.c b/zephyr/test/drivers/system/src/system_not_board_ap_set_sku_id.c
index 8f71531bb8..2d4e60fdcb 100644
--- a/zephyr/test/drivers/system/src/system_not_board_ap_set_sku_id.c
+++ b/zephyr/test/drivers/system/src/system_not_board_ap_set_sku_id.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
+#include "system.h"
+
#include <zephyr/kernel.h>
#include <zephyr/ztest.h>
-#include "system.h"
-
/* Tests for !CONFIG_HOST_CMD_AP_SET_SKUID */
#define DEFAULT_BOARD_PROVIDED_SKU_ID 0
diff --git a/zephyr/test/drivers/testcase.yaml b/zephyr/test/drivers/testcase.yaml
index 0aa89b560d..68e77fab94 100644
--- a/zephyr/test/drivers/testcase.yaml
+++ b/zephyr/test/drivers/testcase.yaml
@@ -4,24 +4,39 @@ tests:
drivers.default:
timeout: 240
extra_args: CONF_FILE="prj.conf;default/prj.conf"
+ DTC_OVERLAY_FILE="default/boards/native_posix.overlay"
extra_configs:
- CONFIG_LINK_TEST_SUITE_DEFAULT=y
- CONFIG_LINK_TEST_SUITE_USB_MALFUNCTION_SINK=y
- CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
- CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
- - CONFIG_PLATFORM_EC_CBI_EEPROM=y
- CONFIG_PLATFORM_EC_USB_PD_DPS=y
+ - CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y
+ - CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=y
+ drivers.default.bring_up:
+ timeout: 240
+ extra_args: CONF_FILE="prj.conf;default/prj.conf"
+ DTC_OVERLAY_FILE="default/boards/native_posix.overlay"
+ extra_configs:
+ - CONFIG_LINK_TEST_SUITE_DEFAULT=y
+ - CONFIG_LINK_TEST_SUITE_USB_MALFUNCTION_SINK=y
+ - CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
+ - CONFIG_PLATFORM_EC_BRINGUP=y
+ - CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
+ - CONFIG_PLATFORM_EC_USB_PD_DPS=y
+ - CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y
drivers.default.mock_power:
timeout: 240
extra_args: CONF_FILE="prj.conf;default/prj.conf"
+ DTC_OVERLAY_FILE="default/boards/native_posix.overlay"
extra_configs:
- CONFIG_LINK_TEST_SUITE_DEFAULT=y
- CONFIG_LINK_TEST_SUITE_USB_MALFUNCTION_SINK=y
- CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y
- CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
- CONFIG_POWER_SEQUENCE_MOCK=y
- - CONFIG_PLATFORM_EC_CBI_EEPROM=y
- CONFIG_PLATFORM_EC_USB_PD_DPS=y
+ - CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y
drivers.anx7447:
extra_args: CONF_FILE="prj.conf;anx7447/prj.conf" DTC_OVERLAY_FILE="./boards/native_posix.overlay;./anx7447/tcpc_policy.dts"
extra_configs:
@@ -44,17 +59,20 @@ tests:
drivers.common_cbi:
extra_configs:
- CONFIG_LINK_TEST_SUITE_COMMON_CBI=y
- - CONFIG_PLATFORM_EC_CBI_EEPROM=y
+ - CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y
drivers.common_cbi_gpio:
extra_configs:
- CONFIG_LINK_TEST_SUITE_COMMON_CBI_GPIO=y
- CONFIG_PLATFORM_EC_CBI_GPIO=y
drivers.common_charger:
extra_configs:
+ - CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=5
+ - CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=100
- CONFIG_LINK_TEST_SUITE_COMMON_CHARGER=y
# Set to focus testing for Herobrine
# Config is y only in nissa
- CONFIG_PLATFORM_EC_CHARGER_RAA489000=n
+ - CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y
drivers.chargesplash:
timeout: 240
extra_configs:
@@ -78,6 +96,19 @@ tests:
- CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
- CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y
- CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y
+ drivers.host_cmd_read_memmap:
+ extra_configs:
+ - CONFIG_LINK_TEST_SUITE_HOST_COMMAND_READ_MEMMAP=y
+ - CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y
+ - CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI=n
+ - CONFIG_PLATFORM_EC_HOST_INTERFACE_SHI=y
+ drivers.host_cmd_read_memmap.no_switches:
+ extra_configs:
+ - CONFIG_LINK_TEST_SUITE_HOST_COMMAND_READ_MEMMAP=y
+ - CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y
+ - CONFIG_PLATFORM_EC_HOST_INTERFACE_ESPI=n
+ - CONFIG_PLATFORM_EC_HOST_INTERFACE_SHI=y
+ - CONFIG_PLATFORM_EC_SWITCH=n
drivers.isl923x:
extra_configs:
- CONFIG_LINK_TEST_SUITE_ISL923X=y
@@ -89,7 +120,6 @@ tests:
extra_args: DTC_OVERLAY_FILE="./boards/native_posix.overlay;i2c_controller/i2c.dts"
extra_configs:
- CONFIG_LINK_TEST_SUITE_I2C_CONTROLLER=y
- - CONFIG_PLATFORM_EC_CBI_EEPROM=y
drivers.keyboard_scan:
extra_configs:
- CONFIG_LINK_TEST_SUITE_KEYBOARD_SCAN=y
@@ -97,9 +127,14 @@ tests:
extra_args: CONF_FILE="prj.conf;led_driver/prj.conf" DTC_OVERLAY_FILE="./boards/native_posix.overlay;./led_driver/led_pins.dts;./led_driver/led_policy.dts"
extra_configs:
- CONFIG_LINK_TEST_SUITE_LED_DRIVER=y
+ drivers.led_common:
+ extra_configs:
+ - CONFIG_LINK_TEST_SUITE_LED_COMMON=y
+ - CONFIG_PLATFORM_EC_LED_DT=n
drivers.locate_chip:
extra_configs:
- CONFIG_LINK_TEST_SUITE_LOCATE_CHIP_ALTS=y
+ - CONFIG_PLATFORM_EC_CBI=n
drivers.mkbp:
extra_configs:
- CONFIG_LINK_TEST_SUITE_MKBP=y
@@ -136,7 +171,6 @@ tests:
- CONFIG_PLATFORM_EC_RTC=y
- CONFIG_PLATFORM_EC_HOSTCMD=y
- CONFIG_PLATFORM_EC_HOSTCMD_RTC=y
- - CONFIG_EMUL_RTC=y
drivers.system:
tags:
common
@@ -151,16 +185,17 @@ tests:
extra_configs:
- CONFIG_LINK_TEST_SUITE_SYSTEM=y
- CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
- - CONFIG_PLATFORM_EC_CBI_EEPROM=y
- CONFIG_POWER_SEQUENCE_MOCK=y
drivers.timer:
extra_configs:
- CONFIG_LINK_TEST_SUITE_TIMER=y
+ drivers.usb_common:
+ extra_configs:
+ - CONFIG_LINK_TEST_SUITE_USB_COMMON=y
drivers.usb_port_power_dumb:
extra_args: DTC_OVERLAY_FILE="./boards/native_posix.overlay;./usb_port_power_dumb/usba.dts"
extra_configs:
- CONFIG_LINK_TEST_SUITE_USB_PORT_POWER_DUMB=y
- - CONFIG_PLATFORM_EC_USBA=y
- CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB=y
drivers.usb_pd_discharge:
extra_configs:
@@ -182,13 +217,17 @@ tests:
- CONFIG_LINK_TEST_SUITE_USBC_ALT_MODE=y
timeout: 120
drivers.usbc_alt_mode_ec_entry:
- extra_configs:
+ timeout: 120
+ extra_configs:
- CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY=n
- CONFIG_LINK_TEST_SUITE_USBC_ALT_MODE=y
- CONFIG_POWER_SEQUENCE_MOCK=y
drivers.usbc_console_pd:
extra_configs:
- CONFIG_LINK_TEST_SUITE_USBC_CONSOLE_PD=y
+ drivers.usbc_ctvpd:
+ extra_configs:
+ - CONFIG_LINK_TEST_SUITE_USBC_CTVPD=y
drivers.usbc_ocp:
extra_configs:
- CONFIG_LINK_TEST_SUITE_USBC_OCP=y
@@ -197,11 +236,25 @@ tests:
- CONFIG_LINK_TEST_SUITE_USBC_PPC=y
drivers.usbc_svdm_dfp_only:
extra_args: CONF_FILE="prj.conf;usbc_svdm_dfp_only/prj.conf"
+ DTC_OVERLAY_FILE="usbc_svdm_dfp_only/boards/native_posix.overlay"
extra_configs:
- CONFIG_LINK_TEST_SUITE_USBC_SVDM_DFP_ONLY=y
drivers.usbc_tbt_mode:
extra_configs:
- CONFIG_LINK_TEST_SUITE_USBC_TBT_MODE=y
+ drivers.usbc_usb4_mode:
+ extra_configs:
+ - CONFIG_LINK_TEST_SUITE_USBC_USB4_MODE=y
+ - CONFIG_PLATFORM_EC_USB_PD_DATA_RESET_MSG=y
drivers.usbc_vconn_swap:
extra_configs:
- CONFIG_LINK_TEST_SUITE_USBC_VCONN_SWAP=y
+ drivers.host_cmd_thread:
+ extra_configs:
+ - CONFIG_LINK_TEST_SUITE_HOST_CMD_THREAD=y
+ drivers.pi3usb9201:
+ extra_configs:
+ - CONFIG_LINK_TEST_SUITE_PI3USB9201=y
+ drivers.memmap:
+ extra_configs:
+ - CONFIG_LINK_TEST_SUITE_MEMMAP=y
diff --git a/zephyr/test/drivers/timer/src/timer.c b/zephyr/test/drivers/timer/src/timer.c
index d94eb7811e..5cbdae1ea8 100644
--- a/zephyr/test/drivers/timer/src/timer.c
+++ b/zephyr/test/drivers/timer/src/timer.c
@@ -2,15 +2,15 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-#include <zephyr/fff.h>
-#include <zephyr/shell/shell_dummy.h>
-
#include "console.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
#include "timer.h"
+#include <zephyr/fff.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
+
BUILD_ASSERT(IS_ENABLED(CONFIG_HWTIMER_64BIT),
"Tests expect the 64-bit HW timer");
diff --git a/zephyr/test/drivers/usb_common/CMakeLists.txt b/zephyr/test/drivers/usb_common/CMakeLists.txt
index 282d4f2ae4..0f05eb1e54 100644
--- a/zephyr/test/drivers/usb_common/CMakeLists.txt
+++ b/zephyr/test/drivers/usb_common/CMakeLists.txt
@@ -8,7 +8,7 @@ project(usb_flags)
target_include_directories(app PRIVATE "include")
-target_sources(app PRIVATE "src/suite.c")
+target_sources(app PRIVATE "src/suite.c" "src/usb_common.c")
target_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_RUNTIME_FLAGS app PRIVATE
"src/usb_pd_flags.c")
target_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_DISCHARGE app PRIVATE
diff --git a/zephyr/test/drivers/usb_common/src/suite.c b/zephyr/test/drivers/usb_common/src/suite.c
index 56f3434d4c..36d3031881 100644
--- a/zephyr/test/drivers/usb_common/src/suite.c
+++ b/zephyr/test/drivers/usb_common/src/suite.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
+#include "suite.h"
+
#include <zephyr/fff.h>
#include <zephyr/ztest_test_new.h>
-#include "suite.h"
-
DEFINE_FAKE_VALUE_FUNC(int, board_vbus_source_enabled, int);
DEFINE_FAKE_VALUE_FUNC(int, ppc_discharge_vbus, int, int);
diff --git a/zephyr/test/drivers/usb_common/src/usb_common.c b/zephyr/test/drivers/usb_common/src/usb_common.c
new file mode 100644
index 0000000000..f286a4ffc9
--- /dev/null
+++ b/zephyr/test/drivers/usb_common/src/usb_common.c
@@ -0,0 +1,298 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ec_commands.h"
+#include "suite.h"
+#include "timer.h"
+#include "usb_common.h"
+#include "usb_pd.h"
+
+#include <stdint.h>
+
+#include <zephyr/fff.h>
+#include <zephyr/ztest_assert.h>
+#include <zephyr/ztest_test_new.h>
+
+#define TEST_PORT 0
+
+ZTEST_USER(usb_common, test_get_typec_current_limit_detached)
+{
+ /* If both CC lines are open, current limit should be 0 A. */
+ typec_current_t current = usb_get_typec_current_limit(
+ POLARITY_CC1, TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN);
+ zassert_equal(current & TYPEC_CURRENT_ILIM_MASK, 0);
+ zassert_equal(current & TYPEC_CURRENT_DTS_MASK, 0);
+}
+
+ZTEST_USER(usb_common, test_get_typec_current_limit_rp_default)
+{
+ /* USB Default current is 500 mA. */
+ typec_current_t current = usb_get_typec_current_limit(
+ POLARITY_CC1, TYPEC_CC_VOLT_RP_DEF, TYPEC_CC_VOLT_OPEN);
+ zassert_equal(current & TYPEC_CURRENT_ILIM_MASK, 500);
+ zassert_equal(current & TYPEC_CURRENT_DTS_MASK, 0);
+}
+
+ZTEST_USER(usb_common, test_get_typec_current_limit_rp_1500)
+{
+ typec_current_t current = usb_get_typec_current_limit(
+ POLARITY_CC1, TYPEC_CC_VOLT_RP_1_5, TYPEC_CC_VOLT_OPEN);
+ zassert_equal(current & TYPEC_CURRENT_ILIM_MASK, 1500);
+ zassert_equal(current & TYPEC_CURRENT_DTS_MASK, 0);
+}
+
+ZTEST_USER(usb_common, test_get_typec_current_limit_rp_3000)
+{
+ typec_current_t current = usb_get_typec_current_limit(
+ POLARITY_CC1, TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_OPEN);
+ zassert_equal(current & TYPEC_CURRENT_ILIM_MASK, 3000);
+ zassert_equal(current & TYPEC_CURRENT_DTS_MASK, 0);
+}
+
+ZTEST_USER(usb_common, test_get_typec_current_limit_rp_dts)
+{
+ /* For a DTS source, Rp 3A/Rp 1.5A indicates USB default current. The
+ * DTS flag should be set.
+ */
+ typec_current_t current = usb_get_typec_current_limit(
+ POLARITY_CC1, TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_RP_1_5);
+ zassert_equal(current & TYPEC_CURRENT_ILIM_MASK, 500);
+ zassert_equal(current & TYPEC_CURRENT_DTS_MASK, TYPEC_CURRENT_DTS_MASK);
+}
+
+ZTEST_USER(usb_common, test_get_snk_polarity)
+{
+ zassert_equal(get_snk_polarity(TYPEC_CC_VOLT_RP_3_0,
+ TYPEC_CC_VOLT_OPEN),
+ POLARITY_CC1);
+ zassert_equal(get_snk_polarity(TYPEC_CC_VOLT_OPEN,
+ TYPEC_CC_VOLT_RP_3_0),
+ POLARITY_CC2);
+}
+
+ZTEST_USER(usb_common, test_get_snk_polarity_dts)
+{
+ zassert_equal(get_snk_polarity(TYPEC_CC_VOLT_RP_3_0,
+ TYPEC_CC_VOLT_RP_DEF),
+ POLARITY_CC1_DTS);
+ zassert_equal(get_snk_polarity(TYPEC_CC_VOLT_RP_DEF,
+ TYPEC_CC_VOLT_RP_3_0),
+ POLARITY_CC2_DTS);
+}
+
+ZTEST_USER(usb_common, test_get_src_polarity)
+{
+ zassert_equal(get_src_polarity(TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN),
+ POLARITY_CC1);
+ zassert_equal(get_src_polarity(TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_RD),
+ POLARITY_CC2);
+}
+
+ZTEST_USER(usb_common, test_pd_get_cc_state)
+{
+ zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_RD),
+ PD_CC_UFP_DEBUG_ACC);
+ zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN),
+ PD_CC_UFP_ATTACHED);
+ zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_RA, TYPEC_CC_VOLT_RA),
+ PD_CC_UFP_AUDIO_ACC);
+
+ zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_RP_3_0,
+ TYPEC_CC_VOLT_RP_DEF),
+ PD_CC_DFP_DEBUG_ACC);
+ zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_OPEN),
+ PD_CC_DFP_ATTACHED);
+
+ zassert_equal(pd_get_cc_state(TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN),
+ PD_CC_NONE);
+}
+
+ZTEST_USER(usb_common, test_pd_board_check_request_default)
+{
+ /* The default implementation accepts any RDO. Just use a basic one. */
+ zassert_ok(pd_board_check_request(RDO_FIXED(0, 3000, 3000, 0), 1));
+}
+
+ZTEST_USER(usb_common, test_pd_check_requested_voltage)
+{
+ uint32_t rdo;
+
+ rdo = RDO_FIXED(1, 1000, 1500, 0);
+ zassert_ok(pd_check_requested_voltage(rdo, 0));
+
+ /* An index of 0 is invalid. */
+ rdo = RDO_FIXED(0, 1000, 1500, 0);
+ zassert_equal(pd_check_requested_voltage(rdo, 0), EC_ERROR_INVAL);
+ /* So is an index larger than the number of source PDOs, which is 1 by
+ * default.
+ */
+ rdo = RDO_FIXED(5, 1000, 1500, 0);
+ zassert_equal(pd_check_requested_voltage(rdo, 0), EC_ERROR_INVAL);
+
+ /* So is operating current too high. (This RDO doesn't make sense.) */
+ rdo = RDO_FIXED(1, 1800, 1500, 0);
+ zassert_equal(pd_check_requested_voltage(rdo, 0), EC_ERROR_INVAL);
+ /* So is maximum current too high. */
+ rdo = RDO_FIXED(1, 1000, 1800, 0);
+ zassert_equal(pd_check_requested_voltage(rdo, 0), EC_ERROR_INVAL);
+}
+
+ZTEST_USER(usb_common, test_board_is_usb_pd_port_present)
+{
+ zassert_true(board_is_usb_pd_port_present(TEST_PORT));
+ zassert_false(board_is_usb_pd_port_present(-1));
+ zassert_false(board_is_usb_pd_port_present(100));
+}
+
+ZTEST_USER(usb_common, test_board_is_dts_port)
+{
+ zassert_true(board_is_dts_port(TEST_PORT));
+}
+
+ZTEST_USER(usb_common, test_drp_auto_toggle_next_state_detached)
+{
+ uint64_t drp_sink_time = 0;
+
+ /* If the port is detached and toggle is disabled, the next state should
+ * be the configured default state.
+ */
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_OFF,
+ TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, true),
+ DRP_TC_DEFAULT);
+
+ /* If toggle is frozen, the next state should be the current state. */
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SINK, PD_DRP_FREEZE,
+ TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, true),
+ DRP_TC_UNATTACHED_SNK);
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SOURCE, PD_DRP_FREEZE,
+ TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, true),
+ DRP_TC_UNATTACHED_SRC);
+
+ /* If role is forced, the next state should be the forced state. */
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SINK, PD_DRP_FORCE_SINK,
+ TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, true),
+ DRP_TC_UNATTACHED_SNK);
+ zassert_equal(drp_auto_toggle_next_state(&drp_sink_time, PD_ROLE_SOURCE,
+ PD_DRP_FORCE_SOURCE,
+ TYPEC_CC_VOLT_OPEN,
+ TYPEC_CC_VOLT_OPEN, true),
+ DRP_TC_UNATTACHED_SRC);
+
+ /* If toggle is enabled but auto-toggle is not supported, the next state
+ * should be based on the power role. If auto-toggle is supported, the
+ * next state should be auto-toggle.
+ */
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_ON,
+ TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, false),
+ DRP_TC_UNATTACHED_SNK);
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SOURCE, PD_DRP_TOGGLE_ON,
+ TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, false),
+ DRP_TC_UNATTACHED_SRC);
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SOURCE, PD_DRP_TOGGLE_ON,
+ TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_OPEN, true),
+ DRP_TC_DRP_AUTO_TOGGLE);
+}
+
+ZTEST_USER(usb_common, test_drp_auto_toggle_next_state_attached_to_source)
+{
+ uint64_t drp_sink_time = 0;
+
+ /* If the CC lines show a source attached, then the next state should be
+ * a sink state. If auto-toggle is enabled, then the next state should
+ * assume that the TCPC is already in AttachWait.SNK.
+ */
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_ON,
+ TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_OPEN, false),
+ DRP_TC_UNATTACHED_SNK);
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_ON,
+ TYPEC_CC_VOLT_OPEN, TYPEC_CC_VOLT_RP_3_0, false),
+ DRP_TC_UNATTACHED_SNK);
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_ON,
+ TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_OPEN, true),
+ DRP_TC_ATTACHED_WAIT_SNK);
+
+ /* If the DRP state is force-source, keep toggling. */
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SINK, PD_DRP_FORCE_SOURCE,
+ TYPEC_CC_VOLT_RP_3_0, TYPEC_CC_VOLT_OPEN, false),
+ DRP_TC_UNATTACHED_SNK);
+ zassert_equal(drp_auto_toggle_next_state(&drp_sink_time, PD_ROLE_SOURCE,
+ PD_DRP_FORCE_SOURCE,
+ TYPEC_CC_VOLT_RP_3_0,
+ TYPEC_CC_VOLT_OPEN, false),
+ DRP_TC_UNATTACHED_SRC);
+ zassert_equal(drp_auto_toggle_next_state(&drp_sink_time, PD_ROLE_SOURCE,
+ PD_DRP_FORCE_SOURCE,
+ TYPEC_CC_VOLT_RP_3_0,
+ TYPEC_CC_VOLT_OPEN, true),
+ DRP_TC_DRP_AUTO_TOGGLE);
+}
+
+ZTEST_USER(usb_common, test_drp_auto_toggle_next_state_attached_to_sink)
+{
+ uint64_t drp_sink_time = 0;
+ timestamp_t fake_time;
+
+ /* If the CC lines show a sink, then the next state should be a source
+ * state. If auto-toggle is enabled, then the next state should assume
+ * that the TCPC is already in AttachWait.SRC.
+ */
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SOURCE, PD_DRP_TOGGLE_ON,
+ TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN, false),
+ DRP_TC_UNATTACHED_SRC);
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SOURCE, PD_DRP_TOGGLE_ON,
+ TYPEC_CC_VOLT_RA, TYPEC_CC_VOLT_OPEN, false),
+ DRP_TC_UNATTACHED_SRC);
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_ON,
+ TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN, true),
+ DRP_TC_ATTACHED_WAIT_SRC);
+
+ /* If the DRP state is off or force-sink, the TCPC might be in
+ * auto-toggle anyway. If the CC lines have been in this state for less
+ * than 100 ms, the TCPM should stay in Unattached.SNK and wait for the
+ * partner to toggle.
+ */
+ drp_sink_time = 0;
+ fake_time.val = drp_sink_time;
+ get_time_mock = &fake_time;
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_OFF,
+ TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN, true),
+ DRP_TC_UNATTACHED_SNK);
+ /* After 100 ms, the next state should be auto-toggle. */
+ drp_sink_time = 0;
+ fake_time.val = drp_sink_time + 105 * MSEC;
+ get_time_mock = &fake_time;
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_OFF,
+ TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN, true),
+ DRP_TC_DRP_AUTO_TOGGLE);
+ /* After 200 ms, the next state should be Unattached.SNK, and
+ * drp_sink_time should be updated.
+ */
+ drp_sink_time = 0;
+ fake_time.val = drp_sink_time + 205 * MSEC;
+ get_time_mock = &fake_time;
+ zassert_equal(drp_auto_toggle_next_state(
+ &drp_sink_time, PD_ROLE_SINK, PD_DRP_TOGGLE_OFF,
+ TYPEC_CC_VOLT_RD, TYPEC_CC_VOLT_OPEN, true),
+ DRP_TC_UNATTACHED_SNK);
+ zassert_equal(drp_sink_time, fake_time.val);
+
+ get_time_mock = NULL;
+}
diff --git a/zephyr/test/drivers/usb_common/src/usb_pd_discharge.c b/zephyr/test/drivers/usb_common/src/usb_pd_discharge.c
index e691d8e76b..847840e3e5 100644
--- a/zephyr/test/drivers/usb_common/src/usb_pd_discharge.c
+++ b/zephyr/test/drivers/usb_common/src/usb_pd_discharge.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/fff.h>
-#include <zephyr/ztest_assert.h>
-#include <zephyr/ztest_test_new.h>
-
#include "suite.h"
#include "usb_pd.h"
#include "usb_pd_flags.h"
+#include <zephyr/fff.h>
+#include <zephyr/ztest_assert.h>
+#include <zephyr/ztest_test_new.h>
+
#define TEST_PORT 0
ZTEST_USER(usb_common, test_pd_set_vbus_discharge)
diff --git a/zephyr/test/drivers/usb_common/src/usb_pd_flags.c b/zephyr/test/drivers/usb_common/src/usb_pd_flags.c
index 8fe73bd141..05765da7b8 100644
--- a/zephyr/test/drivers/usb_common/src/usb_pd_flags.c
+++ b/zephyr/test/drivers/usb_common/src/usb_pd_flags.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest_assert.h>
-#include <zephyr/ztest_test_new.h>
-
#include "usb_pd.h"
#include "usb_pd_flags.h"
+#include <zephyr/ztest_assert.h>
+#include <zephyr/ztest_test_new.h>
+
ZTEST_USER(usb_common, test_usb_pd_charger_otg)
{
set_usb_pd_charger_otg(USB_PD_CHARGER_OTG_ENABLED);
diff --git a/zephyr/test/drivers/usb_malfunction_sink/src/usb_malfunction_sink.c b/zephyr/test/drivers/usb_malfunction_sink/src/usb_malfunction_sink.c
index 1a78d73c7b..fd6cab7bad 100644
--- a/zephyr/test/drivers/usb_malfunction_sink/src/usb_malfunction_sink.c
+++ b/zephyr/test/drivers/usb_malfunction_sink/src/usb_malfunction_sink.c
@@ -3,22 +3,23 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-#include <zephyr/sys/byteorder.h>
-#include <zephyr/ztest.h>
-
#include "battery_smart.h"
#include "emul/emul_isl923x.h"
#include "emul/emul_smart_battery.h"
#include "emul/tcpc/emul_tcpci_partner_faulty_ext.h"
#include "emul/tcpc/emul_tcpci_partner_snk.h"
#include "tcpm/tcpci.h"
+#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
-#include "test/drivers/stubs.h"
+#include "timer.h"
#include "usb_pd.h"
#include "usb_tc_sm.h"
-#include "timer.h"
+
+#include <stdint.h>
+
+#include <zephyr/sys/byteorder.h>
+#include <zephyr/ztest.h>
/* USB-C port used to connect port partner in this testsuite */
#define TEST_PORT 0
diff --git a/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c b/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c
index 25331acc20..7594a6158e 100644
--- a/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c
+++ b/zephyr/test/drivers/usb_port_power_dumb/src/usb_port_power_dumb.c
@@ -3,19 +3,20 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-#include <string.h>
-#include <zephyr/kernel.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/ztest_assert.h>
-#include <zephyr/ztest.h>
-
#include "console.h"
#include "gpio.h"
#include "host_command.h"
#include "test/drivers/test_state.h"
#include "usb_charge.h"
+#include <stdint.h>
+#include <string.h>
+
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
+#include <zephyr/ztest_assert.h>
+
/* Expecting at least one port */
BUILD_ASSERT(ARRAY_SIZE(usb_port_enable) >= 1);
BUILD_ASSERT(USB_PORT_COUNT >= 1);
@@ -141,7 +142,7 @@ static void reset(void *data)
ARG_UNUSED(data);
/* Turn the port off */
- zassume_ok(usb_charge_set_mode(PORT_ID, USB_CHARGE_MODE_DISABLED,
+ zassert_ok(usb_charge_set_mode(PORT_ID, USB_CHARGE_MODE_DISABLED,
USB_DISALLOW_SUSPEND_CHARGE),
NULL);
}
diff --git a/zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c b/zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c
index 9a360761ab..21a471f22a 100644
--- a/zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c
+++ b/zephyr/test/drivers/usb_retimer_fw_update/src/usb_retimer_fw_update.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
#include "usb_common.h"
#include "usb_pd.h"
+#include <zephyr/ztest.h>
+
#define BB_RETIMER_NODE DT_NODELABEL(usb_c1_bb_retimer_emul)
#define TEST_PORT USBC_PORT_C1
@@ -40,7 +40,7 @@ static void usb_retimer_fw_update_suspend_port(void)
/* Give PD task time to suspend port */
k_sleep(K_SECONDS(1));
- zassume_true(acpi_read_and_verify() == 0,
+ zassert_true(acpi_read_and_verify() == 0,
"Failed to see successful suspend");
}
@@ -50,7 +50,7 @@ static void usb_retimer_fw_update_before(void *data)
ARG_UNUSED(data);
/* Assume our common setup of a BB retimer on C1 */
- zassume_true(EMUL_DT_GET(BB_RETIMER_NODE) != NULL,
+ zassert_true(EMUL_DT_GET(BB_RETIMER_NODE) != NULL,
"No BB retimer found on C1");
/* Set chipset to ON, since AP would drive this process */
diff --git a/zephyr/test/drivers/usbc_alt_mode/include/test_usbc_alt_mode.h b/zephyr/test/drivers/usbc_alt_mode/include/test_usbc_alt_mode.h
index 2d494af8cf..ea178fcfaa 100644
--- a/zephyr/test/drivers/usbc_alt_mode/include/test_usbc_alt_mode.h
+++ b/zephyr/test/drivers/usbc_alt_mode/include/test_usbc_alt_mode.h
@@ -33,4 +33,11 @@ struct usbc_alt_mode_dp_unsupported_fixture {
struct tcpci_src_emul_data src_ext;
};
+struct usbc_alt_mode_minus_dp_configure_fixture {
+ const struct emul *tcpci_emul;
+ const struct emul *charger_emul;
+ struct tcpci_partner_data partner;
+ struct tcpci_src_emul_data src_ext;
+};
+
#endif /* ZEPHYR_TEST_DRIVERS_USBC_ALT_MODE_TEST_USBC_ALT_MODE_H_ */
diff --git a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c
index 43ccc3b3f3..c6387aae64 100644
--- a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c
+++ b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode.c
@@ -3,11 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-
#include "ec_commands.h"
#include "ec_tasks.h"
#include "emul/emul_isl923x.h"
@@ -16,12 +11,18 @@
#include "emul/tcpc/emul_tcpci_partner_common.h"
#include "emul/tcpc/emul_tcpci_partner_snk.h"
#include "host_command.h"
-#include "test/drivers/stubs.h"
#include "tcpm/tcpci.h"
-#include "test/drivers/utils.h"
+#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
#include "test_usbc_alt_mode.h"
+#include <stdint.h>
+
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
#define TEST_PORT 0
/* Arbitrary */
@@ -41,7 +42,7 @@ static void connect_partner_to_port(const struct emul *tcpc_emul,
* function.
*/
set_ac_enabled(true);
- zassume_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpc_emul),
+ zassert_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpc_emul),
NULL);
isl923x_emul_set_adc_vbus(charger_emul,
@@ -54,7 +55,7 @@ static void connect_partner_to_port(const struct emul *tcpc_emul,
static void disconnect_partner_from_port(const struct emul *tcpc_emul,
const struct emul *charger_emul)
{
- zassume_ok(tcpci_emul_disconnect_partner(tcpc_emul));
+ zassert_ok(tcpci_emul_disconnect_partner(tcpc_emul));
isl923x_emul_set_adc_vbus(charger_emul, 0);
k_sleep(K_SECONDS(1));
}
@@ -129,6 +130,40 @@ static void add_displayport_mode_responses(struct tcpci_partner_data *partner)
partner->dp_config_vdos = VDO_INDEX_HDR + 1;
}
+static void add_displayport_mode_responses__minus_configure_responses(
+ struct tcpci_partner_data *partner)
+{
+ /*
+ * This is the same function as add_displayport_mode_responses() but
+ * does not include the configure response so as to induce a failure to
+ * enter dp alt mode
+ */
+
+ /* Add DisplayPort EnterMode response */
+ partner->enter_mode_vdm[VDO_INDEX_HDR] =
+ VDO(USB_SID_DISPLAYPORT, /* structured VDM */ true,
+ VDO_CMDT(CMDT_RSP_ACK) | CMD_ENTER_MODE);
+ partner->enter_mode_vdos = VDO_INDEX_HDR + 1;
+
+ /* Add DisplayPort StatusUpdate response */
+ partner->dp_status_vdm[VDO_INDEX_HDR] =
+ VDO(USB_SID_DISPLAYPORT, /* structured VDM */ true,
+ VDO_CMDT(CMDT_RSP_ACK) | CMD_DP_STATUS);
+ partner->dp_status_vdm[VDO_INDEX_HDR + 1] =
+ /* Mainly copied from hoho */
+ VDO_DP_STATUS(0, /* IRQ_HPD */
+ false, /* HPD_HI|LOW - Changed*/
+ 0, /* request exit DP */
+ 0, /* request exit USB */
+ 0, /* MF pref */
+ true, /* DP Enabled */
+ 0, /* power low e.g. normal */
+ 0x2 /* Connected as Sink */);
+ partner->dp_status_vdos = VDO_INDEX_HDR + 2;
+
+ /* NO DisplayPort Configure Response */
+}
+
static void *usbc_alt_mode_setup(void)
{
static struct usbc_alt_mode_fixture fixture;
@@ -394,3 +429,79 @@ ZTEST_SUITE(usbc_alt_mode_dp_unsupported, drivers_predicate_post_main,
usbc_alt_mode_dp_unsupported_setup,
usbc_alt_mode_dp_unsupported_before,
usbc_alt_mode_dp_unsupported_after, NULL);
+
+static void *usbc_alt_mode_minus_dp_configure_setup(void)
+{
+ static struct usbc_alt_mode_minus_dp_configure_fixture fixture;
+ struct tcpci_partner_data *partner = &fixture.partner;
+ struct tcpci_src_emul_data *src_ext = &fixture.src_ext;
+
+ tcpci_partner_init(partner, PD_REV20);
+ partner->extensions = tcpci_src_emul_init(src_ext, partner, NULL);
+
+ /* Get references for the emulators */
+ fixture.tcpci_emul = EMUL_GET_USBC_BINDING(TEST_PORT, tcpc);
+ fixture.charger_emul = EMUL_GET_USBC_BINDING(TEST_PORT, chg);
+
+ add_discovery_responses(partner);
+ add_displayport_mode_responses__minus_configure_responses(partner);
+
+ return &fixture;
+}
+
+static void usbc_alt_mode_minus_dp_configure_before(void *data)
+{
+ /* 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));
+
+ struct usbc_alt_mode_minus_dp_configure_fixture *fixture = data;
+
+ connect_partner_to_port(fixture->tcpci_emul, fixture->charger_emul,
+ &fixture->partner, &fixture->src_ext);
+}
+
+static void usbc_alt_mode_minus_dp_configure_after(void *data)
+{
+ struct usbc_alt_mode_fixture *fixture = data;
+
+ disconnect_partner_from_port(fixture->tcpci_emul,
+ fixture->charger_emul);
+}
+
+ZTEST_F(usbc_alt_mode_minus_dp_configure, test_dp_mode_entry_minus_config)
+{
+ if (IS_ENABLED(CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY)) {
+ host_cmd_typec_control_enter_mode(TEST_PORT, TYPEC_MODE_DP);
+ k_sleep(K_SECONDS(1));
+ }
+
+ /* Verify host command when VDOs are present. */
+ struct ec_response_typec_status status;
+ struct ec_params_usb_pd_get_mode_response response;
+ int response_size;
+
+ host_cmd_usb_pd_get_amode(TEST_PORT, 0, &response, &response_size);
+
+ /* Response should be populated with a DisplayPort VDO */
+ zassert_equal(response_size, sizeof(response));
+ zassert_equal(response.svid, USB_SID_DISPLAYPORT);
+ zassert_equal(response.vdo[0],
+ fixture->partner.modes_vdm[response.opos], NULL);
+
+ /* DPM configures the partner on DP mode entry */
+ /* Verify port partner thinks it's *NOT* configured for DisplayPort */
+ zassert_false(fixture->partner.displayport_configured);
+ /* Also verify DP config is missing from mux */
+ status = host_cmd_typec_status(TEST_PORT);
+ zassert_not_equal((status.mux_state & USB_PD_MUX_DP_ENABLED),
+ USB_PD_MUX_DP_ENABLED,
+ "Failed to *NOT* see DP set in mux");
+}
+
+ZTEST_SUITE(usbc_alt_mode_minus_dp_configure, drivers_predicate_post_main,
+ usbc_alt_mode_minus_dp_configure_setup,
+ usbc_alt_mode_minus_dp_configure_before,
+ usbc_alt_mode_minus_dp_configure_after, NULL);
diff --git a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c
index dc8806151b..597aac4179 100644
--- a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c
+++ b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode__require_ap_mode_entry.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-
#include "test/drivers/utils.h"
#include "test_usbc_alt_mode.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
/* Tests that require CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY enabled */
ZTEST_F(usbc_alt_mode, verify_displayport_mode_reentry)
@@ -97,9 +97,9 @@ ZTEST_F(usbc_alt_mode, verify_mode_exit_via_pd_host_cmd)
* entering an alternate most (DisplayPort specifically) has already
* been verified in another test
*/
- zassume_equal(response_size, sizeof(get_mode_response));
- zassume_equal(get_mode_response.svid, USB_SID_DISPLAYPORT);
- zassume_equal(get_mode_response.vdo[0],
+ zassert_equal(response_size, sizeof(get_mode_response));
+ zassert_equal(get_mode_response.svid, USB_SID_DISPLAYPORT);
+ zassert_equal(get_mode_response.vdo[0],
fixture->partner.modes_vdm[get_mode_response.opos]);
struct ec_params_usb_pd_set_mode_request set_mode_params = {
diff --git a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode_ec_mode_entry.c b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode_ec_mode_entry.c
index 26db31318d..ef56332f55 100644
--- a/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode_ec_mode_entry.c
+++ b/zephyr/test/drivers/usbc_alt_mode/src/usbc_alt_mode_ec_mode_entry.c
@@ -3,17 +3,17 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/ztest_assert.h>
-#include <zephyr/ztest_test_new.h>
-
#include "ec_commands.h"
#include "emul/tcpc/emul_tcpci_partner_common.h"
#include "mock/power.h"
#include "test/drivers/utils.h"
#include "test_usbc_alt_mode.h"
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+#include <zephyr/ztest_assert.h>
+#include <zephyr/ztest_test_new.h>
+
/* Tests that require CONFIG_PLATFORM_EC_USB_PD_REQUIRE_AP_MODE_ENTRY disabled
*/
diff --git a/zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c b/zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c
index c1c7d7eb1a..37908ce1e4 100644
--- a/zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c
+++ b/zephyr/test/drivers/usbc_console_pd/src/usbc_console_pd.c
@@ -3,12 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-#include <zephyr/kernel.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-
#include "console.h"
#include "ec_commands.h"
#include "ec_tasks.h"
@@ -18,12 +12,19 @@
#include "emul/tcpc/emul_tcpci_partner_drp.h"
#include "emul/tcpc/emul_tcpci_partner_src.h"
#include "host_command.h"
-#include "test/drivers/stubs.h"
#include "tcpm/tcpci.h"
-#include "test/drivers/utils.h"
+#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
#include "usb_pd.h"
+#include <stdint.h>
+
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
+
#define TEST_PORT 0
struct common_fixture {
@@ -50,7 +51,7 @@ static void connect_partner_to_port(const struct emul *tcpc_emul,
* function.
*/
set_ac_enabled(true);
- zassume_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpc_emul),
+ zassert_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpc_emul),
NULL);
isl923x_emul_set_adc_vbus(charger_emul,
@@ -63,7 +64,7 @@ static void connect_partner_to_port(const struct emul *tcpc_emul,
static void disconnect_partner_from_port(const struct emul *tcpc_emul,
const struct emul *charger_emul)
{
- zassume_ok(tcpci_emul_disconnect_partner(tcpc_emul), NULL);
+ zassert_ok(tcpci_emul_disconnect_partner(tcpc_emul), NULL);
isl923x_emul_set_adc_vbus(charger_emul, 0);
k_sleep(K_SECONDS(1));
}
diff --git a/zephyr/test/drivers/usbc_ctvpd/CMakeLists.txt b/zephyr/test/drivers/usbc_ctvpd/CMakeLists.txt
new file mode 100644
index 0000000000..36f88dfcbb
--- /dev/null
+++ b/zephyr/test/drivers/usbc_ctvpd/CMakeLists.txt
@@ -0,0 +1,7 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+target_sources(app PRIVATE src/main.c)
diff --git a/zephyr/test/drivers/usbc_ctvpd/include/test_usbc_ctvpd.h b/zephyr/test/drivers/usbc_ctvpd/include/test_usbc_ctvpd.h
new file mode 100644
index 0000000000..9ebb740da8
--- /dev/null
+++ b/zephyr/test/drivers/usbc_ctvpd/include/test_usbc_ctvpd.h
@@ -0,0 +1,29 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef ZEPHYR_TEST_DRIVERS_USBC_ALT_MODE_TEST_USBC_ALT_MODE_H_
+#define ZEPHYR_TEST_DRIVERS_USBC_ALT_MODE_TEST_USBC_ALT_MODE_H_
+
+#include "compile_time_macros.h"
+#include "emul/tcpc/emul_tcpci.h"
+#include "emul/tcpc/emul_tcpci_partner_snk.h"
+#include "emul/tcpc/emul_tcpci_partner_src.h"
+#include "emul/tcpc/emul_tcpci_partner_vpd.h"
+#include "test/drivers/stubs.h"
+
+struct common_fixture {
+ const struct emul *tcpci_emul;
+ const struct emul *charger_emul;
+ struct tcpci_partner_data partner;
+ struct tcpci_src_emul_data src_ext;
+ struct tcpci_snk_emul_data snk_ext;
+ struct tcpci_vpd_emul_data vpd_ext;
+};
+
+struct usbc_ctvpd_fixture {
+ struct common_fixture common;
+};
+
+#endif /* ZEPHYR_TEST_DRIVERS_USBC_ALT_MODE_TEST_USBC_ALT_MODE_H_ */
diff --git a/zephyr/test/drivers/usbc_ctvpd/src/main.c b/zephyr/test/drivers/usbc_ctvpd/src/main.c
new file mode 100644
index 0000000000..0bd6639d83
--- /dev/null
+++ b/zephyr/test/drivers/usbc_ctvpd/src/main.c
@@ -0,0 +1,169 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ec_commands.h"
+#include "ec_tasks.h"
+#include "emul/emul_isl923x.h"
+#include "emul/tcpc/emul_tcpci.h"
+#include "emul/tcpc/emul_tcpci_partner_common.h"
+#include "emul/tcpc/emul_tcpci_partner_snk.h"
+#include "emul/tcpc/emul_tcpci_partner_src.h"
+#include "host_command.h"
+#include "tcpm/tcpci.h"
+#include "test/drivers/stubs.h"
+#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+#include "test_usbc_ctvpd.h"
+#include "usb_pd_vdo.h"
+
+#include <stdint.h>
+
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
+#define TEST_PORT 0
+BUILD_ASSERT(TEST_PORT == USBC_PORT_C0);
+
+struct tcpci_cable_data charge_through_vpd = {
+ .identity_vdm[VDO_INDEX_HDR] =
+ VDO(USB_SID_PD, /* structured VDM */ true,
+ VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_IDENT),
+ .identity_vdm[VDO_INDEX_IDH] = VDO_IDH(
+ /* USB host */ false, /* USB device */ false, IDH_PTYPE_VPD,
+ /* modal operation */ false, USB_VID_GOOGLE),
+ .identity_vdm[VDO_INDEX_CSTAT] = 0xabcdabcd,
+ .identity_vdm[VDO_INDEX_PRODUCT] = VDO_PRODUCT(0x1234, 0xabcd),
+ /* Hardware version 1, firmware version 2 */
+ .identity_vdm[VDO_INDEX_PTYPE_UFP1_VDO] =
+ VDO_VPD(1, 2, VPD_MAX_VBUS_20V, VPD_CT_CURRENT_3A,
+ VPD_VBUS_IMP(10), VPD_GND_IMP(10), VPD_CTS_SUPPORTED),
+ .identity_vdos = VDO_INDEX_PTYPE_UFP1_VDO + 1,
+};
+
+static void disconnect_partner_from_port(const struct emul *tcpc_emul,
+ const struct emul *charger_emul)
+{
+ zassert_ok(tcpci_emul_disconnect_partner(tcpc_emul));
+ isl923x_emul_set_adc_vbus(charger_emul, 0);
+ k_sleep(K_SECONDS(1));
+}
+
+static void add_discovery_responses(struct tcpci_partner_data *partner)
+{
+ partner->cable = &charge_through_vpd;
+ struct tcpci_cable_data *cable = partner->cable;
+
+ /* Add Discover Identity response */
+ cable->identity_vdm[VDO_INDEX_HDR] =
+ VDO(USB_SID_PD, /* structured VDM */ true,
+ VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_IDENT);
+ cable->identity_vdm[VDO_INDEX_IDH] = VDO_IDH(
+ /* USB host */ false, /* USB device */ false, IDH_PTYPE_VPD,
+ /* modal operation */ false, USB_VID_GOOGLE);
+ cable->identity_vdm[VDO_INDEX_CSTAT] = 0xabcdabcd;
+ cable->identity_vdm[VDO_INDEX_PRODUCT] = VDO_PRODUCT(0x1234, 0x5678);
+ /* Hardware version 1, firmware version 2 */
+ cable->identity_vdm[VDO_INDEX_PTYPE_UFP1_VDO] =
+ VDO_VPD(1, 2, VPD_MAX_VBUS_20V, VPD_CT_CURRENT_3A,
+ VPD_VBUS_IMP(10), VPD_GND_IMP(10), VPD_CTS_SUPPORTED);
+ cable->identity_vdos = VDO_INDEX_PTYPE_UFP1_VDO + 1;
+}
+
+static void common_before(struct common_fixture *common)
+{
+ /* 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));
+
+ connect_sink_to_port(&common->partner, common->tcpci_emul,
+ common->charger_emul);
+}
+
+static void common_after(struct common_fixture *common)
+{
+ disconnect_partner_from_port(common->tcpci_emul, common->charger_emul);
+}
+
+static void *usbc_ctvpd_setup(void)
+{
+ static struct usbc_ctvpd_fixture fixture;
+ struct common_fixture *common = &fixture.common;
+ struct tcpci_partner_data *partner = &common->partner;
+ struct tcpci_vpd_emul_data *vpd_ext = &common->vpd_ext;
+
+ tcpci_partner_init(partner, PD_REV30);
+ partner->extensions = tcpci_vpd_emul_init(vpd_ext, partner, NULL);
+
+ /* Get references for the emulators */
+ common->tcpci_emul = EMUL_GET_USBC_BINDING(TEST_PORT, tcpc);
+ common->charger_emul = EMUL_GET_USBC_BINDING(TEST_PORT, chg);
+
+ add_discovery_responses(partner);
+
+ return &fixture;
+}
+
+static void usbc_ctvpd_before(void *data)
+{
+ struct usbc_ctvpd_fixture *fixture = data;
+
+ common_before(&fixture->common);
+}
+
+static void usbc_ctvpd_after(void *data)
+{
+ struct usbc_ctvpd_fixture *fixture = data;
+
+ common_after(&fixture->common);
+}
+
+ZTEST_SUITE(usbc_ctvpd, drivers_predicate_post_main, usbc_ctvpd_setup,
+ usbc_ctvpd_before, usbc_ctvpd_after, NULL);
+
+ZTEST_USER_F(usbc_ctvpd, verify_discovery)
+{
+ uint8_t response_buffer[EC_LPC_HOST_PACKET_SIZE];
+ struct ec_response_typec_discovery *discovery =
+ (struct ec_response_typec_discovery *)response_buffer;
+ struct common_fixture *common = &fixture->common;
+
+ host_cmd_typec_discovery(TEST_PORT, TYPEC_PARTNER_SOP_PRIME,
+ response_buffer, sizeof(response_buffer));
+
+ /* The host command does not count the VDM header in identity_count. */
+ zassert_equal(discovery->identity_count,
+ common->partner.cable->identity_vdos - 1,
+ "Expected %d identity VDOs, got %d",
+ common->partner.cable->identity_vdos - 1,
+ discovery->identity_count);
+ zassert_mem_equal(discovery->discovery_vdo,
+ common->partner.cable->identity_vdm + 1,
+ discovery->identity_count *
+ sizeof(*discovery->discovery_vdo),
+ "Discovered SOP identity ACK did not match");
+}
+
+ZTEST_USER_F(usbc_ctvpd, verify_no_vconn_swap)
+{
+ struct ec_response_typec_status status =
+ host_cmd_typec_status(TEST_PORT);
+ enum pd_vconn_role initial_vconn_role = status.vconn_role;
+
+ /* Upon initial attachment to the host port of a CT-VPD, the host (TCPM)
+ * should be Source and thus VCONN Source. After entry into
+ * CTAttached.SNK, the host should remain VCONN Source.
+ */
+ zassert_equal(initial_vconn_role, PD_ROLE_VCONN_SRC);
+
+ /* The TCPM should refuse to VCONN Swap while in CTAttached.SNK. */
+ zassert_ok(tcpci_partner_send_control_msg(&fixture->common.partner,
+ PD_CTRL_VCONN_SWAP, 0));
+ k_sleep(K_SECONDS(1));
+ status = host_cmd_typec_status(TEST_PORT);
+ zassert_equal(status.vconn_role, initial_vconn_role);
+}
diff --git a/zephyr/test/drivers/usbc_ocp/src/usbc_ocp.c b/zephyr/test/drivers/usbc_ocp/src/usbc_ocp.c
index f269c1e81f..a7828eb878 100644
--- a/zephyr/test/drivers/usbc_ocp/src/usbc_ocp.c
+++ b/zephyr/test/drivers/usbc_ocp/src/usbc_ocp.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
+#include "test/drivers/test_state.h"
+#include "timer.h"
+#include "usbc_ocp.h"
+
#include <zephyr/kernel.h>
#include <zephyr/ztest.h>
#include <zephyr/ztest_assert.h>
-#include "usbc_ocp.h"
-#include "test/drivers/test_state.h"
-#include "timer.h"
-
/* Tests for USBC OCP (Overcurrent Protection) Common Code */
#define TEST_PORT 0
diff --git a/zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c b/zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c
index 70bf887968..c0cd438511 100644
--- a/zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c
+++ b/zephyr/test/drivers/usbc_ppc/src/usbc_ppc.c
@@ -3,16 +3,16 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/ztest.h>
-#include <zephyr/ztest_assert.h>
-
#include "console.h"
#include "test/drivers/test_state.h"
#include "timer.h"
#include "usbc_ppc.h"
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
+#include <zephyr/ztest_assert.h>
+
/* Tests for USBC PPC Common Code */
ZTEST(usbc_ppc, test_ppc_dump__no_args)
diff --git a/zephyr/test/drivers/usbc_svdm_dfp_only/boards/native_posix.overlay b/zephyr/test/drivers/usbc_svdm_dfp_only/boards/native_posix.overlay
new file mode 100644
index 0000000000..0e428e271a
--- /dev/null
+++ b/zephyr/test/drivers/usbc_svdm_dfp_only/boards/native_posix.overlay
@@ -0,0 +1,23 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "../../boards/native_posix.overlay"
+
+/*
+ * The SVDM DFP only tests explicitly do not support USB4/TBT which
+ * automatically get turned on if the Burnside Bridge retimer is used.
+ * Remove this device from the devicetree.
+ */
+ /delete-node/ &usb_c1_bb_retimer_emul;
+
+ / {
+ usbc {
+ port1@1 {
+ usb-mux-chain-1 {
+ usb-muxes = <&virtual_mux_c1>;
+ };
+ };
+ };
+};
diff --git a/zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf b/zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf
index 96c16cbd01..98cac2ca80 100644
--- a/zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf
+++ b/zephyr/test/drivers/usbc_svdm_dfp_only/prj.conf
@@ -2,7 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-
CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=n
CONFIG_PLATFORM_EC_USB_PD_USB4=n
CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
diff --git a/zephyr/test/drivers/usbc_svdm_dfp_only/src/usbc_svdm_dfp_only.c b/zephyr/test/drivers/usbc_svdm_dfp_only/src/usbc_svdm_dfp_only.c
index 33bc767407..5e55042d33 100644
--- a/zephyr/test/drivers/usbc_svdm_dfp_only/src/usbc_svdm_dfp_only.c
+++ b/zephyr/test/drivers/usbc_svdm_dfp_only/src/usbc_svdm_dfp_only.c
@@ -9,15 +9,15 @@
* The tests correspond to TEST.PD.PVDM.SRC.1 Discovery Process and Enter Mode
* as defined by the USB Power Delivery Compliance Test Specification.
*/
-#include <zephyr/sys/byteorder.h>
-#include <zephyr/ztest.h>
-
-#include "usb_pd.h"
#include "emul/tcpc/emul_tcpci.h"
#include "emul/tcpc/emul_tcpci_partner_common.h"
#include "emul/tcpc/emul_tcpci_partner_src.h"
#include "test/drivers/test_state.h"
#include "test/drivers/utils.h"
+#include "usb_pd.h"
+
+#include <zephyr/sys/byteorder.h>
+#include <zephyr/ztest.h>
struct usbc_svdm_dfp_only_fixture {
const struct emul *tcpci_emul;
diff --git a/zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c b/zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c
index 66a145c475..2fc895bb27 100644
--- a/zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c
+++ b/zephyr/test/drivers/usbc_tbt_mode/src/usbc_tbt_mode.c
@@ -3,11 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-#include <zephyr/kernel.h>
-#include <zephyr/sys/byteorder.h>
-#include <zephyr/ztest.h>
-
#include "ec_commands.h"
#include "ec_tasks.h"
#include "emul/emul_isl923x.h"
@@ -15,12 +10,18 @@
#include "emul/tcpc/emul_tcpci.h"
#include "emul/tcpc/emul_tcpci_partner_snk.h"
#include "host_command.h"
-#include "test/drivers/stubs.h"
#include "tcpm/tcpci.h"
-#include "test/drivers/utils.h"
+#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
#include "usb_pd_vdo.h"
+#include <stdint.h>
+
+#include <zephyr/kernel.h>
+#include <zephyr/sys/byteorder.h>
+#include <zephyr/ztest.h>
+
#define TEST_PORT USBC_PORT_C0
/* Remove polarity for any mux checks */
#define USB_MUX_CHECK_MASK ~USB_PD_MUX_POLARITY_INVERTED
@@ -255,7 +256,7 @@ ZTEST_F(usbc_tbt_mode, verify_tbt_entry_fail)
fixture->charger_emul);
status = host_cmd_typec_status(TEST_PORT);
- zassume_equal((status.mux_state & USB_MUX_CHECK_MASK),
+ zassert_equal((status.mux_state & USB_MUX_CHECK_MASK),
USB_PD_MUX_USB_ENABLED, "Unexpected starting mux: 0x%02x",
status.mux_state);
@@ -295,7 +296,7 @@ ZTEST_F(usbc_tbt_mode, verify_tbt_passive_entry_exit)
verify_cable_found(fixture->partner.cable);
status = host_cmd_typec_status(TEST_PORT);
- zassume_equal((status.mux_state & USB_MUX_CHECK_MASK),
+ zassert_equal((status.mux_state & USB_MUX_CHECK_MASK),
USB_PD_MUX_USB_ENABLED, "Unexpected starting mux: 0x%02x",
status.mux_state);
diff --git a/zephyr/test/drivers/usbc_usb4_mode/CMakeLists.txt b/zephyr/test/drivers/usbc_usb4_mode/CMakeLists.txt
new file mode 100644
index 0000000000..dcf03ae2f6
--- /dev/null
+++ b/zephyr/test/drivers/usbc_usb4_mode/CMakeLists.txt
@@ -0,0 +1,5 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+target_sources(app PRIVATE src/usbc_usb4_mode.c)
diff --git a/zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c b/zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c
new file mode 100644
index 0000000000..536f41577e
--- /dev/null
+++ b/zephyr/test/drivers/usbc_usb4_mode/src/usbc_usb4_mode.c
@@ -0,0 +1,269 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ec_commands.h"
+#include "ec_tasks.h"
+#include "emul/tcpc/emul_tcpci.h"
+#include "emul/tcpc/emul_tcpci_partner_snk.h"
+#include "host_command.h"
+#include "test/drivers/stubs.h"
+#include "tcpm/tcpci.h"
+#include "test/drivers/utils.h"
+#include "test/drivers/test_state.h"
+#include "usb_pd_vdo.h"
+
+#include <zephyr/kernel.h>
+#include <zephyr/sys/byteorder.h>
+#include <zephyr/ztest.h>
+
+#include <stdint.h>
+
+#define TEST_PORT USBC_PORT_C0
+/* Remove polarity for any mux checks */
+#define USB_MUX_CHECK_MASK ~USB_PD_MUX_POLARITY_INVERTED
+
+struct usbc_usb4_mode_fixture {
+ const struct emul *tcpci_emul;
+ const struct emul *charger_emul;
+ struct tcpci_partner_data partner;
+ struct tcpci_snk_emul_data snk_ext;
+};
+
+/* Passive USB4 cable */
+struct tcpci_cable_data passive_usb4 = {
+ .identity_vdm[VDO_INDEX_HDR] =
+ VDO(USB_SID_PD, /* structured VDM */ true,
+ VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_IDENT),
+ .identity_vdm[VDO_INDEX_IDH] = VDO_IDH(
+ /* USB host */ false, /* USB device */ false, IDH_PTYPE_PCABLE,
+ /* modal operation */ false, USB_VID_GOOGLE),
+ .identity_vdm[VDO_INDEX_CSTAT] = 0,
+ .identity_vdm[VDO_INDEX_PRODUCT] = VDO_PRODUCT(0x1234, 0xABCD),
+ .identity_vdm[VDO_INDEX_PTYPE_CABLE1] =
+ VDO_REV30_PASSIVE(USB_R30_SS_U40_GEN3, USB_VBUS_CUR_3A,
+ USB_REV30_LATENCY_1m, USB_REV30_TYPE_C),
+ .identity_vdos = VDO_INDEX_PTYPE_CABLE1 + 1,
+
+};
+
+static void add_sop_vdm_responses(struct tcpci_partner_data *partner)
+{
+ /* Add Discover Identity response */
+ partner->identity_vdm[VDO_INDEX_HDR] =
+ VDO(USB_SID_PD, /* structured VDM */ true,
+ VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_IDENT);
+ partner->identity_vdm[VDO_INDEX_IDH] = VDO_IDH_REV30(
+ /* USB host */ false, /* USB device */ true,
+ /* ptype_u */ IDH_PTYPE_HUB, /* modal */ false,
+ /* ptype_d */ IDH_PTYPE_UNDEF, /* ctype */ USB_TYPEC_RECEPTACLE,
+ USB_VID_GOOGLE);
+ partner->identity_vdm[VDO_INDEX_CSTAT] = 0;
+ partner->identity_vdm[VDO_INDEX_PRODUCT] = VDO_PRODUCT(0x1234, 0x5678);
+ partner->identity_vdm[VDO_INDEX_PTYPE_UFP1_VDO] = VDO_UFP1(
+ /* capability */ (VDO_UFP1_CAPABILITY_USB20 |
+ VDO_UFP1_CAPABILITY_USB32 |
+ VDO_UFP1_CAPABILITY_USB4),
+ /* ctype */ USB_TYPEC_RECEPTACLE,
+ /* alt modes */ VDO_UFP1_ALT_MODE_TBT3,
+ /* speed */ USB_R30_SS_U40_GEN3);
+ partner->identity_vdm[VDO_INDEX_PTYPE_UFP2_VDO] = 0;
+ partner->identity_vdos = VDO_INDEX_PTYPE_UFP2_VDO + 1;
+
+ /* Add Discover SVIDs response */
+ /*
+ * TODO(b/260095516): USB4 entry does not depend on the contents of
+ * Discover SVIDs, but a valid Discover SVID response needs to to exist
+ * to ensure that discovery completes as that's a dependency in the DPM
+ * module to attempt either Enter_USB or DATA_RESET.
+ */
+ partner->svids_vdm[VDO_INDEX_HDR] =
+ VDO(USB_SID_PD, /* structured VDM */ true,
+ VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_SVID);
+ partner->svids_vdm[VDO_INDEX_HDR + 1] = VDO_SVID(USB_VID_INTEL, 0);
+ partner->svids_vdos = VDO_INDEX_HDR + 2;
+
+ /* Add Discover Modes response */
+ /*
+ * TODO(b/260095516): USB4 entry does not depend on the contents of
+ * Discover Modes, but a valid Discover Modes response needs to to exist
+ * to ensure that discovery completes as that's a dependency in the DPM
+ * module to attempt either Enter_USB or DATA_RESET.
+ */
+ /* Support one mode for TBT (Intel) VID */
+ partner->modes_vdm[VDO_INDEX_HDR] =
+ VDO(USB_VID_INTEL, /* structured VDM */ true,
+ VDO_CMDT(CMDT_RSP_ACK) | CMD_DISCOVER_MODES);
+ partner->modes_vdm[VDO_INDEX_HDR + 1] = TBT_ALTERNATE_MODE;
+ partner->modes_vdos = VDO_INDEX_HDR + 2;
+}
+
+static void verify_cable_found(struct tcpci_cable_data *cable)
+{
+ uint8_t response_buffer[EC_LPC_HOST_PACKET_SIZE];
+ struct ec_response_typec_discovery *discovery =
+ (struct ec_response_typec_discovery *)response_buffer;
+
+ host_cmd_typec_discovery(TEST_PORT, TYPEC_PARTNER_SOP_PRIME,
+ response_buffer, sizeof(response_buffer));
+
+ /* The host command does not count the VDM header in identity_count. */
+ zassert_equal(discovery->identity_count, cable->identity_vdos - 1,
+ "Expected %d identity VDOs, got %d",
+ cable->identity_vdos - 1, discovery->identity_count);
+ zassert_mem_equal(discovery->discovery_vdo, cable->identity_vdm + 1,
+ discovery->identity_count *
+ sizeof(*discovery->discovery_vdo),
+ "Discovered SOP' identity ACK did not match");
+}
+
+static void *usbc_usb4_mode_setup(void)
+{
+ static struct usbc_usb4_mode_fixture fixture;
+ struct tcpci_partner_data *partner = &fixture.partner;
+ struct tcpci_snk_emul_data *snk_ext = &fixture.snk_ext;
+
+ tcpci_partner_init(partner, PD_REV30);
+ partner->extensions = tcpci_snk_emul_init(snk_ext, partner, NULL);
+
+ /* Get references for the emulators */
+ fixture.tcpci_emul = EMUL_DT_GET(DT_NODELABEL(tcpci_emul));
+ fixture.charger_emul = EMUL_DT_GET(DT_NODELABEL(isl923x_emul));
+
+ add_sop_vdm_responses(partner);
+ /* Note: cable behavior will vary by test case */
+
+ return &fixture;
+}
+
+static void usbc_usb4_mode_before(void *data)
+{
+ struct usbc_usb4_mode_fixture *fix = data;
+
+ /* Set chipset to ON, this will set TCPM to DRP */
+ test_set_chipset_to_s0();
+
+ /* TODO(b/214401892): Check why need to give TCPM time to spin */
+ k_sleep(K_SECONDS(1));
+
+ /* Enable message logging after TCPM spin */
+ tcpci_partner_common_enable_pd_logging(&fix->partner, true);
+
+ /* Initialize parter port Enter_USB msg accept/reject state */
+ fix->partner.enter_usb_accept = false;
+}
+
+static void usbc_usb4_mode_after(void *data)
+{
+ struct usbc_usb4_mode_fixture *fix = data;
+
+ disconnect_sink_from_port(fix->tcpci_emul);
+ tcpci_partner_common_enable_pd_logging(&fix->partner, false);
+ tcpci_partner_common_clear_logged_msgs(&fix->partner);
+}
+
+ZTEST_F(usbc_usb4_mode, verify_discovery)
+{
+ uint8_t response_buffer[EC_LPC_HOST_PACKET_SIZE];
+ struct ec_response_typec_discovery *discovery =
+ (struct ec_response_typec_discovery *)response_buffer;
+
+ connect_sink_to_port(&fixture->partner, fixture->tcpci_emul,
+ fixture->charger_emul);
+
+ host_cmd_typec_discovery(TEST_PORT, TYPEC_PARTNER_SOP, response_buffer,
+ sizeof(response_buffer));
+
+ /* The host command does not count the VDM header in identity_count. */
+ zassert_equal(discovery->identity_count,
+ fixture->partner.identity_vdos - 1,
+ "Expected %d identity VDOs, got %d",
+ fixture->partner.identity_vdos - 1,
+ discovery->identity_count);
+ zassert_mem_equal(
+ discovery->discovery_vdo, fixture->partner.identity_vdm + 1,
+ discovery->identity_count * sizeof(*discovery->discovery_vdo),
+ "Discovered SOP identity ACK did not match");
+}
+
+/* Without an e-marked cable, USB4 mode cannot be entered */
+ZTEST_F(usbc_usb4_mode, verify_usb4_entry_fail)
+{
+ struct ec_response_typec_status status;
+
+ fixture->partner.cable = NULL;
+ connect_sink_to_port(&fixture->partner, fixture->tcpci_emul,
+ fixture->charger_emul);
+
+ status = host_cmd_typec_status(TEST_PORT);
+ zassert_equal((status.mux_state & USB_MUX_CHECK_MASK),
+ USB_PD_MUX_USB_ENABLED, "Unexpected starting mux: 0x%02x",
+ status.mux_state);
+
+ host_cmd_typec_control_enter_mode(TEST_PORT, TYPEC_MODE_USB4);
+ k_sleep(K_SECONDS(1));
+
+ /*
+ * TODO(b/260095516): Notify the AP that the enter mode request
+ * failed.
+ */
+
+ status = host_cmd_typec_status(TEST_PORT);
+ zassert_equal((status.mux_state & USB_MUX_CHECK_MASK),
+ USB_PD_MUX_USB_ENABLED, "Failed to see USB still set");
+ zassert_not_equal((status.mux_state & USB_MUX_CHECK_MASK),
+ USB_PD_MUX_USB4_ENABLED, "Unexpected USB4 mode set");
+}
+
+/* With passive e-marked cable, USB4 mode can be entered on SOP only */
+ZTEST_F(usbc_usb4_mode, verify_usb4_passive_entry_exit)
+{
+ struct ec_response_typec_status status;
+
+ fixture->partner.cable = &passive_usb4;
+ connect_sink_to_port(&fixture->partner, fixture->tcpci_emul,
+ fixture->charger_emul);
+
+ /* Instruct partner port to accept Enter_USB message */
+ fixture->partner.enter_usb_accept = true;
+
+ /* Verify that we properly identify a USB4 capable passive cable */
+ verify_cable_found(fixture->partner.cable);
+
+ status = host_cmd_typec_status(TEST_PORT);
+ zassert_equal((status.mux_state & USB_MUX_CHECK_MASK),
+ USB_PD_MUX_USB_ENABLED, "Unexpected starting mux: 0x%02x",
+ status.mux_state);
+
+ host_cmd_typec_control_enter_mode(TEST_PORT, TYPEC_MODE_USB4);
+ k_sleep(K_SECONDS(2));
+
+ /*
+ * TODO(b/260095516): Notify the AP that the enter mode request
+ * succeeded.
+ */
+
+ /* Verify we entered USB4 mode */
+ status = host_cmd_typec_status(TEST_PORT);
+ zassert_equal((status.mux_state & USB_MUX_CHECK_MASK),
+ USB_PD_MUX_USB4_ENABLED, "Failed to see USB4 set");
+
+ /* Exit modes now */
+ host_cmd_typec_control_exit_modes(TEST_PORT);
+ k_sleep(K_SECONDS(1));
+
+ /* Verify that USB4 mode was exited by checking current mux state. */
+ status = host_cmd_typec_status(TEST_PORT);
+ zassert_equal((status.mux_state & USB_MUX_CHECK_MASK),
+ USB_PD_MUX_USB_ENABLED, "Failed to see USB set");
+}
+
+/*
+ * TODO(b/260095516): This test suite is only testing the default good case, and
+ * one error case where the cable doesn't support USB4. This suite needs to be
+ * expanded to cover cases where the port partner rejects Enter_USB along with
+ * active cable cases.
+ */
+ZTEST_SUITE(usbc_usb4_mode, drivers_predicate_post_main, usbc_usb4_mode_setup,
+ usbc_usb4_mode_before, usbc_usb4_mode_after, NULL);
diff --git a/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c b/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c
index 324df08826..bc1eb6cd0d 100644
--- a/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c
+++ b/zephyr/test/drivers/usbc_vconn_swap/src/usbc_vconn_swap.c
@@ -3,11 +3,6 @@
* found in the LICENSE file.
*/
-#include <stdint.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-
#include "ec_commands.h"
#include "ec_tasks.h"
#include "emul/emul_isl923x.h"
@@ -17,10 +12,16 @@
#include "emul/tcpc/emul_tcpci_partner_drp.h"
#include "emul/tcpc/emul_tcpci_partner_snk.h"
#include "host_command.h"
-#include "test/drivers/stubs.h"
#include "tcpm/tcpci.h"
-#include "test/drivers/utils.h"
+#include "test/drivers/stubs.h"
#include "test/drivers/test_state.h"
+#include "test/drivers/utils.h"
+
+#include <stdint.h>
+
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
#define TEST_PORT 0
@@ -52,7 +53,7 @@ static void connect_partner_to_port(const struct emul *tcpc_emul,
* function.
*/
set_ac_enabled(true);
- zassume_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpc_emul),
+ zassert_ok(tcpci_partner_connect_to_tcpci(partner_emul, tcpc_emul),
NULL);
isl923x_emul_set_adc_vbus(charger_emul,
@@ -65,7 +66,7 @@ static void connect_partner_to_port(const struct emul *tcpc_emul,
static void disconnect_partner_from_port(const struct emul *tcpc_emul,
const struct emul *charger_emul)
{
- zassume_ok(tcpci_emul_disconnect_partner(tcpc_emul), NULL);
+ zassert_ok(tcpci_emul_disconnect_partner(tcpc_emul), NULL);
isl923x_emul_set_adc_vbus(charger_emul, 0);
k_sleep(K_SECONDS(1));
}
@@ -166,7 +167,7 @@ ZTEST_F(usbc_vconn_swap, vconn_swap_via_host_command)
struct ec_response_typec_status status =
host_cmd_typec_status(TEST_PORT);
- zassume_equal(status.vconn_role, PD_ROLE_VCONN_SRC,
+ zassert_equal(status.vconn_role, PD_ROLE_VCONN_SRC,
"TCPM did not initiate VCONN Swap after attach");
host_cmd_usb_pd_control(TEST_PORT, USB_PD_CTRL_SWAP_VCONN);
diff --git a/zephyr/test/ec_app/prj.conf b/zephyr/test/ec_app/prj.conf
index 3b44c56b6b..502f5bbdc6 100644
--- a/zephyr/test/ec_app/prj.conf
+++ b/zephyr/test/ec_app/prj.conf
@@ -13,7 +13,6 @@ CONFIG_SHELL_BACKEND_SERIAL=n
CONFIG_SERIAL=y
CONFIG_RING_BUFFER=y
-CONFIG_EMUL_CROS_FLASH=y
CONFIG_PLATFORM_EC_VBOOT_EFS2=y
CONFIG_PLATFORM_EC_VBOOT_HASH=y
CONFIG_PLATFORM_EC_HOSTCMD=y
diff --git a/zephyr/test/ec_app/src/main.c b/zephyr/test/ec_app/src/main.c
index b106754d47..3c317d2a08 100644
--- a/zephyr/test/ec_app/src/main.c
+++ b/zephyr/test/ec_app/src/main.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest_assert.h>
-#include <zephyr/ztest_test_new.h>
-#include <zephyr/shell/shell_dummy.h>
-
#include "ec_app_main.h"
#include "hooks.h"
#include "task.h"
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest_assert.h>
+#include <zephyr/ztest_test_new.h>
+
#ifdef CONFIG_CMD_AP_RESET_LOG
ZTEST(ec_app_tests, test_init_reset_log)
{
diff --git a/zephyr/test/herobrine/CMakeLists.txt b/zephyr/test/herobrine/CMakeLists.txt
index 8209eb77fb..17b3d973a1 100644
--- a/zephyr/test/herobrine/CMakeLists.txt
+++ b/zephyr/test/herobrine/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2022 The ChromiumOS Authors.
+# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -6,9 +6,9 @@ cmake_minimum_required(VERSION 3.13.1)
find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
project(herobrine)
-zephyr_include_directories("${PLATFORM_EC}/zephyr/projects/herobrine/include")
+zephyr_include_directories("${PLATFORM_EC_PROGRAM_DIR}/herobrine/include")
target_sources_ifdef(CONFIG_TEST_BOARD_CHIPSET
app PRIVATE src/board_chipset.c)
target_sources_ifdef(CONFIG_TEST_BOARD_CHIPSET
- app PRIVATE ${PLATFORM_EC}/zephyr/projects/herobrine/src/board_chipset.c)
+ app PRIVATE ${PLATFORM_EC_PROGRAM_DIR}/herobrine/src/board_chipset.c)
diff --git a/zephyr/test/herobrine/Kconfig b/zephyr/test/herobrine/Kconfig
index 415e6e58af..8c3dc24727 100644
--- a/zephyr/test/herobrine/Kconfig
+++ b/zephyr/test/herobrine/Kconfig
@@ -1,4 +1,4 @@
-# Copyright 2022 The ChromiumOS Authors.
+# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
diff --git a/zephyr/test/herobrine/README.md b/zephyr/test/herobrine/README.md
index 398b27e304..646c7ad985 100644
--- a/zephyr/test/herobrine/README.md
+++ b/zephyr/test/herobrine/README.md
@@ -1,3 +1,3 @@
-Tests for board specific code under `zephyr/projects/herobrine/src`.
+Tests for board specific code under `zephyr/program/herobrine/src`.
Run with ./twister -T zephyr/test/herobrine
diff --git a/zephyr/test/herobrine/boards/native_posix.overlay b/zephyr/test/herobrine/boards/native_posix.overlay
index bfecc9a7d5..d2afb38db1 100644
--- a/zephyr/test/herobrine/boards/native_posix.overlay
+++ b/zephyr/test/herobrine/boards/native_posix.overlay
@@ -1,4 +1,4 @@
-/* Copyright 2022 The ChromiumOS Authors.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/test/herobrine/prj.conf b/zephyr/test/herobrine/prj.conf
index 3334f11939..89165e36a8 100644
--- a/zephyr/test/herobrine/prj.conf
+++ b/zephyr/test/herobrine/prj.conf
@@ -1,4 +1,4 @@
-# Copyright 2022 The ChromiumOS Authors.
+# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
diff --git a/zephyr/test/herobrine/src/board_chipset.c b/zephyr/test/herobrine/src/board_chipset.c
index 77bdb14e16..1463547012 100644
--- a/zephyr/test/herobrine/src/board_chipset.c
+++ b/zephyr/test/herobrine/src/board_chipset.c
@@ -1,14 +1,14 @@
-/* Copyright 2022 The ChromiumOS Authors.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
+#include "board_chipset.h"
+#include "hooks.h"
+
#include <zephyr/kernel.h>
#include <zephyr/ztest.h>
-#include "hooks.h"
-#include "board_chipset.h"
-
static int battery_soc_abs_value = 50;
int battery_state_of_charge_abs(int *percent)
diff --git a/zephyr/test/herobrine/testcase.yaml b/zephyr/test/herobrine/testcase.yaml
index e5f17a3848..1ccb56582f 100644
--- a/zephyr/test/herobrine/testcase.yaml
+++ b/zephyr/test/herobrine/testcase.yaml
@@ -1,4 +1,4 @@
-# Copyright 2022 The ChromiumOS Authors.
+# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
diff --git a/zephyr/test/hooks/hooks.c b/zephyr/test/hooks/hooks.c
index 7d784aa65f..bc2840eae5 100644
--- a/zephyr/test/hooks/hooks.c
+++ b/zephyr/test/hooks/hooks.c
@@ -3,12 +3,13 @@
* found in the LICENSE file.
*/
-#include <stdbool.h>
-#include <zephyr/ztest.h>
-
#include "ap_power/ap_power.h"
#include "hooks.h"
+#include <stdbool.h>
+
+#include <zephyr/ztest.h>
+
static bool h1_called;
static bool h2_called;
static bool h3_called;
diff --git a/zephyr/test/i2c/prj.conf b/zephyr/test/i2c/prj.conf
index ee6c43f51a..fbf4b53cc3 100644
--- a/zephyr/test/i2c/prj.conf
+++ b/zephyr/test/i2c/prj.conf
@@ -3,11 +3,9 @@
# found in the LICENSE file.
CONFIG_ZTEST=y
-CONFIG_LOG=y
+CONFIG_ZTEST_NEW_API=y
CONFIG_EMUL=y
-CONFIG_I2C=y
-CONFIG_I2C_EMUL=y
CONFIG_BMI160=y
CONFIG_EMUL_BMI160=y
CONFIG_SENSOR=y
diff --git a/zephyr/test/i2c/src/main.c b/zephyr/test/i2c/src/main.c
index 364353f06d..759fe01151 100644
--- a/zephyr/test/i2c/src/main.c
+++ b/zephyr/test/i2c/src/main.c
@@ -3,26 +3,37 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-#include <zephyr/ztest.h>
-
#include "common.h"
-#include "i2c/i2c.h"
#include "i2c.h"
+#include "i2c/i2c.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/ztest.h>
/* Unused: required for shimming i2c. */
void watchdog_reload(void)
{
}
-static void test_i2c_port_count(void)
+ZTEST_USER(i2c, test_i2c_port_count)
{
zassert_equal(I2C_PORT_COUNT, 2,
"I2C_PORT_COUNT expected to be 2 but was %d",
I2C_PORT_COUNT);
}
-static void test_i2c_lock(void)
+ZTEST_USER(i2c, test_i2c_lock_invalid_port)
+{
+ i2c_lock(-1, 1);
+ zassert_equal(i2c_port_is_locked(-1), 0,
+ "Negative I2C port locked, but should have failed");
+
+ i2c_lock(INT_MAX, 1);
+ zassert_equal(i2c_port_is_locked(INT_MAX), 0,
+ "MAX_INT I2C port locked, but should have failed");
+}
+
+ZTEST_USER(i2c, test_i2c_lock)
{
i2c_lock(I2C_PORT_ACCEL, 1);
zassert_equal(i2c_port_is_locked(I2C_PORT_EEPROM), 1,
@@ -54,10 +65,4 @@ static void test_i2c_lock(void)
i2c_lock(I2C_PORT_EEPROM, 0);
}
-/* Test case main entry. */
-void test_main(void)
-{
- ztest_test_suite(test_i2c, ztest_user_unit_test(test_i2c_port_count),
- ztest_user_unit_test(test_i2c_lock));
- ztest_run_test_suite(test_i2c);
-}
+ZTEST_SUITE(i2c, NULL, NULL, NULL, NULL, NULL);
diff --git a/zephyr/test/i2c_dts/prj.conf b/zephyr/test/i2c_dts/prj.conf
index 6c008faf64..75a6e70ff7 100644
--- a/zephyr/test/i2c_dts/prj.conf
+++ b/zephyr/test/i2c_dts/prj.conf
@@ -4,11 +4,8 @@
CONFIG_ZTEST=y
CONFIG_ZTEST_NEW_API=y
-CONFIG_LOG=y
CONFIG_EMUL=y
-CONFIG_I2C=y
-CONFIG_I2C_EMUL=y
CONFIG_BMI160=y
CONFIG_EMUL_BMI160=y
CONFIG_SENSOR=y
diff --git a/zephyr/test/jump_tags/CMakeLists.txt b/zephyr/test/jump_tags/CMakeLists.txt
new file mode 100644
index 0000000000..710195275e
--- /dev/null
+++ b/zephyr/test/jump_tags/CMakeLists.txt
@@ -0,0 +1,13 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+cmake_minimum_required(VERSION 3.20.0)
+find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
+project(jump_tags)
+
+# Include FFF fakes
+add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils)
+
+FILE(GLOB test_sources src/*.c)
+target_sources(app PRIVATE ${test_sources})
diff --git a/zephyr/test/jump_tags/boards/native_posix.overlay b/zephyr/test/jump_tags/boards/native_posix.overlay
new file mode 100644
index 0000000000..9f3238d076
--- /dev/null
+++ b/zephyr/test/jump_tags/boards/native_posix.overlay
@@ -0,0 +1,33 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <board-overlays/native_posix.dts>
+#include <cros/binman.dtsi>
+
+/ {
+ chosen {
+ cros-ec,flash = &flash1;
+ cros-ec,flash-controller = &cros_flash;
+ };
+ aliases {
+ gpio-wp = &gpio_wp_l;
+ };
+ named-gpios {
+ compatible = "named-gpios";
+ gpio_wp_l: wp_l {
+ gpios = <&gpio0 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>;
+ };
+ };
+ cros_flash: cros-flash {
+ compatible = "cros-ec,flash-emul";
+ };
+ flash1: flash@64000000 {
+ reg = <0x64000000 DT_SIZE_K(512)>;
+ };
+};
+
+&gpio0 {
+ ngpios = <4>;
+};
diff --git a/zephyr/test/jump_tags/prj.conf b/zephyr/test/jump_tags/prj.conf
new file mode 100644
index 0000000000..4e39830c0a
--- /dev/null
+++ b/zephyr/test/jump_tags/prj.conf
@@ -0,0 +1,14 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_CROS_EC=y
+CONFIG_FLASH=y
+CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGEN=n
+CONFIG_PLATFORM_EC=y
+CONFIG_SERIAL=y
+CONFIG_SHELL_BACKEND_DUMMY=y
+CONFIG_SHELL_BACKEND_SERIAL=n
+CONFIG_SHIMMED_TASKS=y
+CONFIG_ZTEST_NEW_API=y
+CONFIG_ZTEST=y
diff --git a/zephyr/test/jump_tags/src/jump_tags.c b/zephyr/test/jump_tags/src/jump_tags.c
new file mode 100644
index 0000000000..a2a377bb35
--- /dev/null
+++ b/zephyr/test/jump_tags/src/jump_tags.c
@@ -0,0 +1,176 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "ec_commands.h"
+#include "hooks.h"
+#include "host_command.h"
+#include "sysjump.h"
+#include "system.h"
+#include "system_fake.h"
+
+#include <setjmp.h>
+
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
+#define TEST_BASIC_JUMP_TAG 0x9901
+#define TEST_MISSING_JUMP_TAG 0x9902
+#define TEST_MAX_JUMP_TAG 0x9903
+#define TEST_TOO_BIG_JUMP_TAG 0x9904
+
+#define TEST_JUMP_TAG_VERSION 1
+
+#define SOME_STR_VAL "JumpTagTest"
+
+void (*add_tag_func)(void);
+
+struct test_basic_jump_data_struct {
+ char some_str[32];
+};
+
+struct test_max_jump_data_struct {
+ char some_str[JUMP_TAG_MAX_SIZE];
+};
+
+struct test_too_big_jump_data_struct {
+ char some_str[JUMP_TAG_MAX_SIZE + 1];
+};
+
+static void system_before(void *data)
+{
+ add_tag_func = NULL;
+ system_common_pre_init();
+ system_set_shrspi_image_copy(EC_IMAGE_RO);
+}
+
+static void do_fake_sysjump(void)
+{
+ jmp_buf env;
+ enum ec_image target_image = system_get_image_copy() == EC_IMAGE_RO ?
+ EC_IMAGE_RW :
+ EC_IMAGE_RO;
+
+ if (!setjmp(env)) {
+ system_fake_setenv(&env);
+ system_run_image_copy(target_image);
+ zassert_unreachable();
+ }
+
+ system_set_shrspi_image_copy(target_image);
+ zassert_equal(system_get_image_copy(), target_image);
+}
+
+static void add_max_jump_tag(void)
+{
+ struct test_max_jump_data_struct max_tag = {
+ .some_str = SOME_STR_VAL,
+ };
+ zassert_ok(system_add_jump_tag(TEST_MAX_JUMP_TAG, TEST_JUMP_TAG_VERSION,
+ sizeof(max_tag), &max_tag));
+}
+
+static void add_too_big_jump_tag(void)
+{
+ struct test_too_big_jump_data_struct too_big_tag = {
+ .some_str = SOME_STR_VAL,
+ };
+ zassert_equal(system_add_jump_tag(TEST_TOO_BIG_JUMP_TAG,
+ TEST_JUMP_TAG_VERSION,
+ sizeof(too_big_tag), &too_big_tag),
+ EC_ERROR_INVAL);
+}
+
+static void add_too_many_jump_tags(void)
+{
+ int rv;
+ struct test_max_jump_data_struct max_tag = {
+ .some_str = SOME_STR_VAL,
+ };
+ /* Ensure at least one tag can be added, but not 10 */
+ for (int i = 0; i < 10; i++) {
+ rv = system_add_jump_tag(TEST_MAX_JUMP_TAG,
+ TEST_JUMP_TAG_VERSION, sizeof(max_tag),
+ &max_tag);
+ if (rv != 0) {
+ zassert_equal(rv, EC_ERROR_INVAL);
+ zassert_true(i > 0);
+ return;
+ }
+ }
+ zassert_unreachable(
+ "Adding too many jump tags failed to result in an error");
+}
+
+static void add_basic_jump_tag(void)
+{
+ struct test_basic_jump_data_struct basic_tag = {
+ .some_str = SOME_STR_VAL,
+ };
+ zassert_ok(system_add_jump_tag(TEST_BASIC_JUMP_TAG,
+ TEST_JUMP_TAG_VERSION, sizeof(basic_tag),
+ &basic_tag));
+}
+
+static void test_sysjump_hook(void)
+{
+ if (add_tag_func)
+ add_tag_func();
+}
+DECLARE_HOOK(HOOK_SYSJUMP, test_sysjump_hook, HOOK_PRIO_DEFAULT);
+
+static void check_for_jump_tag(int jump_tag, int expected_size)
+{
+ int version;
+ int size;
+ const unsigned char *data;
+
+ data = system_get_jump_tag(jump_tag, &version, &size);
+ zassert_equal(size, expected_size);
+ zassert_equal(version, TEST_JUMP_TAG_VERSION);
+ zassert_equal(strcmp(data, SOME_STR_VAL), 0);
+}
+
+ZTEST(jump_tags, test_get_missing_jump_tag)
+{
+ int version;
+ int size;
+ struct test_jump_data_struct *data;
+
+ data = (struct test_jump_data_struct *)system_get_jump_tag(
+ TEST_MISSING_JUMP_TAG, &version, &size);
+ zassert_equal(data, NULL);
+}
+
+ZTEST(jump_tags, test_add_max_jump_tag)
+{
+ add_tag_func = add_max_jump_tag;
+ do_fake_sysjump();
+ check_for_jump_tag(TEST_MAX_JUMP_TAG,
+ sizeof(struct test_max_jump_data_struct));
+}
+
+ZTEST(jump_tags, test_too_big_jump_tag)
+{
+ add_tag_func = add_too_big_jump_tag;
+ do_fake_sysjump();
+}
+
+ZTEST(jump_tags, test_too_many_jump_tags)
+{
+ add_tag_func = add_too_many_jump_tags;
+ do_fake_sysjump();
+ check_for_jump_tag(TEST_MAX_JUMP_TAG,
+ sizeof(struct test_max_jump_data_struct));
+}
+
+ZTEST(jump_tags, test_add_basic_jump_tag)
+{
+ add_tag_func = add_basic_jump_tag;
+ do_fake_sysjump();
+ check_for_jump_tag(TEST_BASIC_JUMP_TAG,
+ sizeof(struct test_basic_jump_data_struct));
+}
+
+ZTEST_SUITE(jump_tags, NULL, NULL, system_before, NULL, NULL);
diff --git a/zephyr/test/jump_tags/testcase.yaml b/zephyr/test/jump_tags/testcase.yaml
new file mode 100644
index 0000000000..11ef8d73ec
--- /dev/null
+++ b/zephyr/test/jump_tags/testcase.yaml
@@ -0,0 +1,13 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+common:
+ platform_allow: native_posix
+tests:
+ jump_tags.default:
+ extra_configs:
+ - CONFIG_PLATFORM_EC_PRESERVED_END_OF_RAM_SIZE=1024
+ tags:
+ common
+ system
diff --git a/zephyr/test/kingler/CMakeLists.txt b/zephyr/test/kingler/CMakeLists.txt
index 6747b2ed99..725831d2db 100644
--- a/zephyr/test/kingler/CMakeLists.txt
+++ b/zephyr/test/kingler/CMakeLists.txt
@@ -8,25 +8,28 @@ project(kingler)
add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils)
-zephyr_include_directories("${PLATFORM_EC}/zephyr/projects/corsola/include")
+zephyr_include_directories("${PLATFORM_EC_PROGRAM_DIR}/corsola/include")
target_sources(app PRIVATE src/fakes.c)
target_sources_ifdef(CONFIG_TEST_STEELIX_RUSTY
-app PRIVATE ${PLATFORM_EC}/zephyr/projects/corsola/src/kingler/board_steelix.c)
+app PRIVATE ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/kingler/board_steelix.c)
target_sources_ifdef(CONFIG_TEST_FORM_FACTOR_CONVERTIBLE
app PRIVATE src/tablet.c)
target_sources_ifdef(CONFIG_TEST_FORM_FACTOR_CLAMSHELL
app PRIVATE src/clamshell.c)
target_sources_ifdef(CONFIG_VARIANT_CORSOLA_DB_DETECTION
-app PRIVATE ${PLATFORM_EC}/zephyr/projects/corsola/src/variant_db_detection.c)
+app PRIVATE ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/variant_db_detection.c)
target_sources_ifdef(CONFIG_TEST_DB_DETECT_TYPEC
app PRIVATE src/db_detect_typec.c)
target_sources_ifdef(CONFIG_TEST_DB_DETECT_HDMI
- app PRIVATE src/db_detect_hdmi.c)
+ app PRIVATE src/db_detect_hdmi.c
+ ${PLATFORM_EC}/zephyr/shim/src/usb_muxes.c
+ ${PLATFORM_EC}/driver/usb_mux/usb_mux.c
+ ${PLATFORM_EC}/driver/usb_mux/virtual.c)
target_sources_ifdef(CONFIG_TEST_DB_DETECT_NONE
app PRIVATE src/db_detect_none.c)
target_sources_ifdef(CONFIG_TEST_ALT_SENSOR_PROBE
app PRIVATE src/alt_sensor.c)
target_sources_ifdef(CONFIG_TEST_KINGLER_CCD
-app PRIVATE src/ccd.c ${PLATFORM_EC}/zephyr/projects/corsola/src/board.c)
+app PRIVATE src/ccd.c ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/board.c)
diff --git a/zephyr/test/kingler/README.md b/zephyr/test/kingler/README.md
index bac3afced2..84dadc105b 100644
--- a/zephyr/test/kingler/README.md
+++ b/zephyr/test/kingler/README.md
@@ -1,3 +1,3 @@
-Tests for board specific code under `zephyr/projects/corsola/src/kingler`.
+Tests for board specific code under `zephyr/program/corsola/src/kingler`.
Run with ./twister -T zephyr/test/kingler
diff --git a/zephyr/test/kingler/common.dts b/zephyr/test/kingler/common.dts
index 39b6f25036..c04844f227 100644
--- a/zephyr/test/kingler/common.dts
+++ b/zephyr/test/kingler/common.dts
@@ -13,10 +13,28 @@
port0@0 {
compatible = "named-usbc-port";
reg = <0>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_0>;
+ };
};
port1@1 {
compatible = "named-usbc-port";
reg = <1>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_1>;
+ };
+ };
+ port0-muxes {
+ virtual_mux_0: virtual-mux-0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
+ port1-muxes {
+ virtual_mux_1: virtual-mux-1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
};
};
diff --git a/zephyr/test/kingler/prj.conf b/zephyr/test/kingler/prj.conf
index 2eb14afb0e..c8ef8e4304 100644
--- a/zephyr/test/kingler/prj.conf
+++ b/zephyr/test/kingler/prj.conf
@@ -18,13 +18,9 @@ CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y
CONFIG_PLATFORM_EC_TABLET_MODE=y
CONFIG_PLATFORM_EC_LID_ANGLE=y
-CONFIG_I2C=y
CONFIG_I2C_NPCX=n
-CONFIG_PLATFORM_EC_CBI_EEPROM=y
CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y
CONFIG_EEPROM=y
-CONFIG_EEPROM_AT24=y
CONFIG_EEPROM_SIMULATOR=n
CONFIG_EMUL_EEPROM_AT2X=y
-CONFIG_EEPROM_SHELL=n
diff --git a/zephyr/test/kingler/src/alt_sensor.c b/zephyr/test/kingler/src/alt_sensor.c
index fa00a5e874..7cd0ceddfa 100644
--- a/zephyr/test/kingler/src/alt_sensor.c
+++ b/zephyr/test/kingler/src/alt_sensor.c
@@ -1,18 +1,18 @@
-/* Copyright 2022 The ChromiumOS Authors.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-#include "zephyr/kernel.h"
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/ztest.h>
-
#include "cros_board_info.h"
#include "cros_cbi.h"
#include "gpio_signal.h"
#include "hooks.h"
+#include "zephyr/kernel.h"
+
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/ztest.h>
-/* SSFC field defined in zephyr/projects/corsola/cbi_steelix.dts */
+/* SSFC field defined in zephyr/program/corsola/cbi_steelix.dts */
#define SSFC_BASE_MAIN_SENSOR (0x1)
#define SSFC_BASE_ALT_SENSOR (0x1 << 1)
diff --git a/zephyr/test/kingler/src/ccd.c b/zephyr/test/kingler/src/ccd.c
index 1b46631dc6..eb375fcfe7 100644
--- a/zephyr/test/kingler/src/ccd.c
+++ b/zephyr/test/kingler/src/ccd.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include "zephyr/kernel.h"
+#include "gpio/gpio_int.h"
+#include "gpio_signal.h"
+#include "hooks.h"
+
#include <zephyr/drivers/gpio/gpio_emul.h>
#include <zephyr/fff.h>
+#include <zephyr/kernel.h>
#include <zephyr/ztest.h>
-#include "gpio_signal.h"
-#include "gpio/gpio_int.h"
-#include "hooks.h"
-
FAKE_VOID_FUNC(typec_set_sbu, int, bool);
/* fake definitions to pass build */
FAKE_VOID_FUNC(bmi3xx_interrupt, enum gpio_signal);
diff --git a/zephyr/test/kingler/src/clamshell.c b/zephyr/test/kingler/src/clamshell.c
index 88595cc114..9871db1ca0 100644
--- a/zephyr/test/kingler/src/clamshell.c
+++ b/zephyr/test/kingler/src/clamshell.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include "zephyr/kernel.h"
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/ztest.h>
-
#include "cros_board_info.h"
#include "cros_cbi.h"
#include "gpio_signal.h"
#include "hooks.h"
#include "tablet_mode.h"
+#include "zephyr/kernel.h"
+
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/ztest.h>
static void *clamshell_setup(void)
{
diff --git a/zephyr/test/kingler/src/db_detect_hdmi.c b/zephyr/test/kingler/src/db_detect_hdmi.c
index 35cf92ae5e..04a65269ad 100644
--- a/zephyr/test/kingler/src/db_detect_hdmi.c
+++ b/zephyr/test/kingler/src/db_detect_hdmi.c
@@ -3,13 +3,43 @@
* found in the LICENSE file.
*/
+#include "baseboard_usbc_config.h"
+#include "ec_commands.h"
+#include "gpio_signal.h"
+#include "hooks.h"
+#include "usb_mux.h"
+#include "variant_db_detection.h"
#include "zephyr/kernel.h"
+
#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/fff.h>
#include <zephyr/ztest.h>
-#include "gpio_signal.h"
-#include "hooks.h"
-#include "variant_db_detection.h"
+FAKE_VALUE_FUNC(int, corsola_is_dp_muxable, int);
+FAKE_VOID_FUNC(svdm_set_hpd_gpio, int, int);
+
+#define FFF_FAKES_LIST(FAKE) \
+ FAKE(corsola_is_dp_muxable) \
+ FAKE(svdm_set_hpd_gpio)
+
+static void db_hdmi_rule_before(const struct ztest_unit_test *test, void *data)
+{
+ ARG_UNUSED(test);
+ ARG_UNUSED(data);
+ FFF_FAKES_LIST(RESET_FAKE);
+ FFF_RESET_HISTORY();
+}
+ZTEST_RULE(db_hdmi_rule, db_hdmi_rule_before, NULL);
+
+uint8_t board_get_usb_pd_port_count(void)
+{
+ return 2;
+}
+
+enum tcpc_cc_polarity pd_get_polarity(int port)
+{
+ return 0;
+}
static void *db_detection_setup(void)
{
@@ -73,11 +103,31 @@ ZTEST(db_detection, test_db_detect_hdmi)
gpio_emul_output_get(ps185_pwrdn_gpio, ps185_pwrdn_pin),
NULL);
- /* Verify x_ec_interrupt is enabled */
+ /* Verify x_ec_interrupt is enabled, and plug */
interrupt_count = 0;
zassert_ok(gpio_emul_input_set(int_x_ec_gpio, int_x_ec_pin, 1), NULL);
k_sleep(K_MSEC(100));
+ corsola_is_dp_muxable_fake.return_val = 1;
+
zassert_equal(interrupt_count, 1, "interrupt_count=%d",
interrupt_count);
+
+ zassert_false(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED, NULL);
+
+ /* invoke hdmi interrupt, the argument doesn't care, just pass 0 */
+ hdmi_hpd_interrupt(0);
+
+ k_sleep(K_MSEC(500));
+
+ zassert_equal(svdm_set_hpd_gpio_fake.call_count, 1);
+ zassert_true(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED, NULL);
+
+ /* unplug */
+ zassert_ok(gpio_emul_input_set(int_x_ec_gpio, int_x_ec_pin, 0), NULL);
+
+ hdmi_hpd_interrupt(0);
+ k_sleep(K_MSEC(500));
+
+ zassert_false(usb_mux_get(USBC_PORT_C1) & USB_PD_MUX_DP_ENABLED, NULL);
}
diff --git a/zephyr/test/kingler/src/db_detect_none.c b/zephyr/test/kingler/src/db_detect_none.c
index 9f37db04af..1bf9c05701 100644
--- a/zephyr/test/kingler/src/db_detect_none.c
+++ b/zephyr/test/kingler/src/db_detect_none.c
@@ -3,17 +3,18 @@
* found in the LICENSE file.
*/
-#include <stdlib.h>
-#include <zephyr/kernel.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/ztest.h>
-
#include "cros_board_info.h"
#include "cros_cbi.h"
#include "gpio_signal.h"
#include "hooks.h"
#include "variant_db_detection.h"
+#include <stdlib.h>
+
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
static void *db_detection_setup(void)
{
const struct device *wp_gpio =
diff --git a/zephyr/test/kingler/src/db_detect_typec.c b/zephyr/test/kingler/src/db_detect_typec.c
index 53716fe552..6662f485bc 100644
--- a/zephyr/test/kingler/src/db_detect_typec.c
+++ b/zephyr/test/kingler/src/db_detect_typec.c
@@ -3,13 +3,13 @@
* found in the LICENSE file.
*/
-#include "zephyr/kernel.h"
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/ztest.h>
-
#include "gpio_signal.h"
#include "hooks.h"
#include "variant_db_detection.h"
+#include "zephyr/kernel.h"
+
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/ztest.h>
static void *db_detection_setup(void)
{
diff --git a/zephyr/test/kingler/src/fakes.c b/zephyr/test/kingler/src/fakes.c
index 9b3194f18a..f5a3c30b0b 100644
--- a/zephyr/test/kingler/src/fakes.c
+++ b/zephyr/test/kingler/src/fakes.c
@@ -3,9 +3,10 @@
* found in the LICENSE file.
*/
-#include <zephyr/fff.h>
#include "gpio_signal.h"
+#include <zephyr/fff.h>
+
FAKE_VOID_FUNC(power_button_interrupt, enum gpio_signal);
FAKE_VOID_FUNC(button_interrupt, enum gpio_signal);
FAKE_VOID_FUNC(lid_interrupt, enum gpio_signal);
diff --git a/zephyr/test/kingler/src/tablet.c b/zephyr/test/kingler/src/tablet.c
index 68be2b2b68..a2355e2b9d 100644
--- a/zephyr/test/kingler/src/tablet.c
+++ b/zephyr/test/kingler/src/tablet.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include "zephyr/kernel.h"
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/ztest.h>
-
#include "cros_board_info.h"
#include "cros_cbi.h"
#include "gpio_signal.h"
#include "hooks.h"
#include "tablet_mode.h"
+#include "zephyr/kernel.h"
+
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/ztest.h>
static void *tablet_setup(void)
{
diff --git a/zephyr/test/kingler/testcase.yaml b/zephyr/test/kingler/testcase.yaml
index 9b7e9f58ff..282ece6e63 100644
--- a/zephyr/test/kingler/testcase.yaml
+++ b/zephyr/test/kingler/testcase.yaml
@@ -6,36 +6,36 @@ common:
platform_allow: native_posix
tests:
kingler.steelix:
- extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/cbi_steelix.dts;../projects/corsola/gpio_steelix.dts"
+ extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/steelix/cbi.dtsi;../program/corsola/npcx_gpio.dtsi"
extra_configs:
- CONFIG_TEST_STEELIX_RUSTY=y
- CONFIG_TEST_FORM_FACTOR_CONVERTIBLE=y
kingler.rusty:
- extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/cbi_steelix.dts;../projects/corsola/gpio_steelix.dts"
+ extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/steelix/cbi.dtsi;../program/corsola/npcx_gpio.dtsi"
extra_configs:
- CONFIG_TEST_STEELIX_RUSTY=y
- CONFIG_TEST_FORM_FACTOR_CLAMSHELL=y
kingler.db_detect_typec:
- extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/gpio_steelix.dts;"
+ extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/npcx_gpio.dtsi;"
extra_configs:
- CONFIG_TEST_DB_DETECT_TYPEC=y
- CONFIG_VARIANT_CORSOLA_DB_DETECTION=y
kingler.db_detect_hdmi:
- extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/gpio_steelix.dts"
+ extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/npcx_gpio.dtsi"
extra_configs:
- CONFIG_TEST_DB_DETECT_HDMI=y
- CONFIG_VARIANT_CORSOLA_DB_DETECTION=y
kingler.db_detect_none:
- extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/cbi_steelix.dts;../projects/corsola/gpio_steelix.dts"
+ extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/steelix/cbi.dtsi;../program/corsola/npcx_gpio.dtsi"
extra_configs:
- CONFIG_TEST_DB_DETECT_NONE=y
- CONFIG_VARIANT_CORSOLA_DB_DETECTION=y
kingler.ccd:
- extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/cbi_steelix.dts;../projects/corsola/gpio_steelix.dts"
+ extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/steelix/cbi.dtsi;../program/corsola/npcx_gpio.dtsi"
extra_configs:
- CONFIG_TEST_KINGLER_CCD=y
kingler.alt_sensor:
- extra_args: DTC_OVERLAY_FILE="./common.dts;../projects/corsola/interrupts_kingler.dts;../projects/corsola/interrupts_steelix.dts;../projects/corsola/cbi_steelix.dts;../projects/corsola/gpio_steelix.dts"
+ extra_args: DTC_OVERLAY_FILE="./common.dts;../program/corsola/npcx_interrupts.dtsi;../program/corsola/steelix/interrupts.dtsi;../program/corsola/steelix/cbi.dtsi;../program/corsola/npcx_gpio.dtsi"
extra_configs:
- CONFIG_TEST_STEELIX_RUSTY=y
- CONFIG_TEST_ALT_SENSOR_PROBE=y
diff --git a/zephyr/test/krabby/CMakeLists.txt b/zephyr/test/krabby/CMakeLists.txt
index bb96633d5b..dbab1bd19c 100644
--- a/zephyr/test/krabby/CMakeLists.txt
+++ b/zephyr/test/krabby/CMakeLists.txt
@@ -8,19 +8,21 @@ project(krabby)
add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils)
-zephyr_include_directories("${PLATFORM_EC}/zephyr/projects/corsola/include")
+zephyr_include_directories("${PLATFORM_EC_PROGRAM_DIR}/corsola/include")
target_sources(app PRIVATE
src/stubs.c
- ${PLATFORM_EC}/zephyr/projects/corsola/src/krabby/usbc_config.c)
+ ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/krabby/usbc_config.c
+ ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/krabby/usb_pd_policy.c)
target_sources_ifdef(CONFIG_TEST_KRABBY
app PRIVATE
src/charger_workaround.c
src/usb_mux_init.c
- ${PLATFORM_EC}/zephyr/projects/corsola/src/krabby/charger_workaround.c)
+ src/usbc_config.c
+ ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/krabby/charger_workaround.c)
target_sources_ifdef(CONFIG_TEST_TENTACRUEL
app PRIVATE
src/temp_tentacruel.c
- ${PLATFORM_EC}/zephyr/projects/corsola/src/krabby/temp_tentacruel.c)
+ ${PLATFORM_EC_PROGRAM_DIR}/corsola/src/krabby/temp_tentacruel.c)
diff --git a/zephyr/test/krabby/README.md b/zephyr/test/krabby/README.md
index 8262d85fcc..027cdec4a4 100644
--- a/zephyr/test/krabby/README.md
+++ b/zephyr/test/krabby/README.md
@@ -1,3 +1,3 @@
-Tests for board specific code under `zephyr/projects/corsola/src/krabby`.
+Tests for board specific code under `zephyr/program/corsola/src/krabby`.
Run with ./twister -T zephyr/test/krabby
diff --git a/zephyr/test/krabby/adc_temp.dts b/zephyr/test/krabby/adc_temp.dts
index 28e98adf64..c0d17cca13 100644
--- a/zephyr/test/krabby/adc_temp.dts
+++ b/zephyr/test/krabby/adc_temp.dts
@@ -6,28 +6,11 @@
#include <cros/thermistor/thermistor.dtsi>
/ {
- adc0: adc {
- compatible = "zephyr,adc-emul";
- nchannels = <1>;
- ref-internal-mv = <3300>;
- #io-channel-cells = <1>;
- status = "okay";
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- adc_charger: charger {
- enum-name = "ADC_TEMP_SENSOR_CHARGER";
- io-channels = <&adc0 0>;
- };
- };
-
name_temp_charger: charger {
- compatible = "cros-ec,temp-sensor-thermistor";
+ compatible = "cros-ec,temp-sensor-thermistor";
- thermistor = <&thermistor_rt9490>;
- adc = <&adc_charger>;
+ thermistor = <&thermistor_rt9490>;
+ adc = <&adc_charger>;
};
named-temp-sensors {
diff --git a/zephyr/test/krabby/common.dts b/zephyr/test/krabby/common.dts
index b8f1eb0733..9e94392561 100644
--- a/zephyr/test/krabby/common.dts
+++ b/zephyr/test/krabby/common.dts
@@ -31,17 +31,34 @@
reg = <0>;
chg = <&charger>;
tcpc = <&tcpci_emul>;
+ ppc = <&ppc0_emul>;
+ usb-mux-chain-0 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&virtual_mux_0>;
+ };
+ };
+ port0-muxes {
+ virtual_mux_0: virtual-mux-0 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
};
port1@1 {
compatible = "named-usbc-port";
status = "okay";
reg = <1>;
+ tcpc = <&tcpci_emul>;
+ ppc = <&ppc1_emul>;
usb-mux-chain-1 {
compatible = "cros-ec,usb-mux-chain";
usb-muxes = <&tusb1064_mux_1>;
};
};
+ port1-muxes {
+ virtual_mux_1: virtual-mux-1 {
+ compatible = "cros-ec,usbc-mux-virtual";
+ };
+ };
};
batteries {
@@ -49,6 +66,33 @@
compatible = "lgc,ac17a8m", "battery-smart";
};
};
+
+ named-adc-channels {
+ compatible = "named-adc-channels";
+
+ adc_vbus_c0 {
+ enum-name = "ADC_VBUS_C0";
+ io-channels = <&adc0 0>;
+ mul = <10>;
+ };
+ adc_board_id0 {
+ enum-name = "ADC_BOARD_ID_0";
+ io-channels = <&adc0 1>;
+ };
+ adc_board_id1 {
+ enum-name = "ADC_BOARD_ID_1";
+ io-channels = <&adc0 2>;
+ };
+ adc_vbus_c1 {
+ enum-name = "ADC_VBUS_C1";
+ io-channels = <&adc0 7>;
+ mul = <10>;
+ };
+ adc_charger: charger {
+ enum-name = "ADC_TEMP_SENSOR_CHARGER";
+ io-channels = <&adc0 5>;
+ };
+ };
};
&i2c_ctrl0 {
@@ -61,7 +105,7 @@
};
battery: sb@b {
- compatible = "zephyr,smart-battery";
+ compatible = "zephyr,smart-battery-emul";
reg = <0xb>;
cycle-count = <99>;
version = "BATTERY_SPEC_VER_1_1_WITH_PEC";
@@ -77,6 +121,31 @@
status = "okay";
reg = <0x82>;
};
+
+ ppc0_emul: syv682x@42 {
+ compatible = "zephyr,syv682x-emul";
+ status = "okay";
+ reg = <0x42>;
+ frs_en_gpio = <&gpio_ec_x_gpio1>;
+ alert_gpio = <&gpio_x_ec_gpio2>;
+ };
+
+ ppc1_emul: syv682x@43 {
+ compatible = "zephyr,syv682x-emul";
+ status = "okay";
+ reg = <0x43>;
+ /*
+ * the gpio pins are intentionally reused in both ppc emuls, to
+ * avoid handling different frs-en pin names on krabby and
+ * tentacruel.
+ */
+ frs_en_gpio = <&gpio_ec_x_gpio1>;
+ alert_gpio = <&gpio_x_ec_gpio2>;
+ };
+};
+
+&adc0 {
+ status = "okay";
};
&i2c_ctrl4 {
diff --git a/zephyr/test/krabby/pinctrl.dts b/zephyr/test/krabby/pinctrl.dts
index 9d01591238..ecc7b88538 100644
--- a/zephyr/test/krabby/pinctrl.dts
+++ b/zephyr/test/krabby/pinctrl.dts
@@ -5,3 +5,5 @@
/* remove pinctrl to avoid pull in too many unwanted dependency */
/delete-node/ &pinctrl;
+
+/delete-node/ &{/hibernate-wake-pins};
diff --git a/zephyr/test/krabby/prj.conf b/zephyr/test/krabby/prj.conf
index ddf5a29c21..2f2a03923b 100644
--- a/zephyr/test/krabby/prj.conf
+++ b/zephyr/test/krabby/prj.conf
@@ -6,34 +6,34 @@ CONFIG_ZTEST=y
CONFIG_ZTEST_ASSERT_VERBOSE=1
CONFIG_ZTEST_NEW_API=y
-CONFIG_ADC=y
CONFIG_ASSERT=y
+CONFIG_ADC=y
CONFIG_CROS_EC=y
CONFIG_EMUL=y
-CONFIG_EMUL_RT9490=y
-CONFIG_EMUL_SMART_BATTERY=y
-CONFIG_EMUL_TCPCI=y
-CONFIG_EMUL_TUSB1064=y
-CONFIG_I2C=y
-CONFIG_I2C_EMUL=y
CONFIG_PLATFORM_EC=y
CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-CONFIG_PLATFORM_EC_BATTERY=y
CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
-CONFIG_PLATFORM_EC_CHARGER=y
-CONFIG_PLATFORM_EC_CHARGER_RT9490=y
CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20
-CONFIG_PLATFORM_EC_CHARGE_MANAGER=n
+CONFIG_PLATFORM_EC_CHARGE_MANAGER=y
+CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y
+CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY=49
CONFIG_PLATFORM_EC_HOOKS=y
CONFIG_PLATFORM_EC_HOSTCMD=y
CONFIG_PLATFORM_EC_LID_SWITCH=n
CONFIG_PLATFORM_EC_SWITCH=n
CONFIG_PLATFORM_EC_USBC=y
-CONFIG_PLATFORM_EC_USB_CHARGER=n
+CONFIG_PLATFORM_EC_USB_CHARGER=y
+CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y
CONFIG_PLATFORM_EC_USB_MUX_TUSB546=y
+CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
+CONFIG_PLATFORM_EC_USB_PD_DISCHARGE=y
CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y
+CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT=y
CONFIG_PLATFORM_EC_USB_POWER_DELIVERY=y
CONFIG_PLATFORM_EC_VBOOT_HASH=n
+
+CONFIG_PLATFORM_EC_USBC_PPC=y
+CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y
diff --git a/zephyr/test/krabby/src/charger_workaround.c b/zephyr/test/krabby/src/charger_workaround.c
index afd3fe5f0c..5582fe5c64 100644
--- a/zephyr/test/krabby/src/charger_workaround.c
+++ b/zephyr/test/krabby/src/charger_workaround.c
@@ -3,11 +3,6 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/emul.h>
-#include <zephyr/fff.h>
-#include <zephyr/ztest.h>
-
#include "charger.h"
#include "driver/charger/rt9490.h"
#include "emul/emul_rt9490.h"
@@ -15,6 +10,11 @@
#include "i2c.h"
#include "system.h"
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
FAKE_VALUE_FUNC(int, board_get_version);
const struct emul *emul = EMUL_DT_GET(DT_NODELABEL(charger));
diff --git a/zephyr/test/krabby/src/stubs.c b/zephyr/test/krabby/src/stubs.c
index 7731aad43f..df1613528d 100644
--- a/zephyr/test/krabby/src/stubs.c
+++ b/zephyr/test/krabby/src/stubs.c
@@ -4,38 +4,12 @@
*/
#include "adc.h"
-#include "usbc_ppc.h"
#include "charge_ramp.h"
#include "charge_state.h"
+#include "usbc_ppc.h"
-int board_set_active_charge_port(int port)
-{
- return 0;
-}
-
-int board_is_vbus_too_low(int port, enum chg_ramp_vbus_state ramp_state)
-{
- return 0;
-}
-
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
-{
-}
-
-const struct batt_params *charger_current_battery_params(void)
-{
- static const struct batt_params params = {};
-
- return &params;
-}
-
-int board_get_battery_soc(void)
-{
- return 0;
-}
-
-void pd_power_supply_reset(void)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
}
@@ -44,29 +18,7 @@ int pd_check_vconn_swap(int port)
return 0;
}
-void pd_set_input_current_limit(int port, uint32_t max_ma,
- uint32_t supply_voltage)
+int board_get_adjusted_usb_pd_port_count(int port)
{
+ return 2;
}
-
-int pd_set_power_supply_ready(int port)
-{
- return 0;
-}
-
-void usb_charger_vbus_change(int port, int vbus_level)
-{
-}
-
-int charge_manager_get_active_charge_port(void)
-{
- return 0;
-}
-
-struct ppc_config_t ppc_chips[] = {};
-
-unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
-
-#ifdef CONFIG_MUX_INIT_ADC
-const struct adc_t adc_channels[] = {};
-#endif
diff --git a/zephyr/test/krabby/src/temp_tentacruel.c b/zephyr/test/krabby/src/temp_tentacruel.c
index 863adfaf81..1eaefad988 100644
--- a/zephyr/test/krabby/src/temp_tentacruel.c
+++ b/zephyr/test/krabby/src/temp_tentacruel.c
@@ -3,25 +3,24 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/adc.h>
-#include <zephyr/drivers/adc/adc_emul.h>
-
-#include "charger.h"
#include "charge_state.h"
+#include "charger.h"
#include "charger_profile_override.h"
#include "common.h"
#include "config.h"
#include "hooks.h"
-#include "util.h"
#include "temp_sensor.h"
#include "temp_sensor/temp_sensor.h"
+#include "util.h"
+
+#include <zephyr/drivers/adc.h>
+#include <zephyr/drivers/adc/adc_emul.h>
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
#define ADC_DEVICE_NODE DT_NODELABEL(adc0)
#define CHARGER_TEMP TEMP_SENSOR_ID(DT_NODELABEL(temp_charger))
#define ORIGINAL_CURRENT 5000
-#define TEMP_THRESHOLD 55
struct charge_state_data curr;
static int fake_voltage;
@@ -34,16 +33,17 @@ static uint16_t current_table[] = {
3600,
3000,
2400,
- 1800,
+ 1600,
};
int setup_faketemp(int fake_voltage)
{
const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
+ const uint8_t channel_id =
+ DT_IO_CHANNELS_INPUT(DT_NODELABEL(adc_charger));
int emul_temp;
- emul_temp = adc_emul_const_value_set(
- adc_dev, temp_sensors[CHARGER_TEMP].idx, fake_voltage);
+ emul_temp = adc_emul_const_value_set(adc_dev, channel_id, fake_voltage);
return emul_temp;
}
@@ -56,7 +56,7 @@ static void ignore_first_minute(void)
ZTEST(temp_tentacruel, test_decrease_current)
{
- fake_voltage = 376;
+ fake_voltage = 411;
curr.batt.flags |= BATT_FLAG_RESPONSIVE;
count = 0;
@@ -80,7 +80,7 @@ ZTEST(temp_tentacruel, test_decrease_current)
ZTEST(temp_tentacruel, test_increase_current)
{
- fake_voltage = 380;
+ fake_voltage = 446;
curr.batt.flags |= BATT_FLAG_RESPONSIVE;
count = 3;
diff --git a/zephyr/test/krabby/src/usb_mux_init.c b/zephyr/test/krabby/src/usb_mux_init.c
index 665f1c7b7e..8d1e4e81eb 100644
--- a/zephyr/test/krabby/src/usb_mux_init.c
+++ b/zephyr/test/krabby/src/usb_mux_init.c
@@ -3,15 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/devicetree.h>
-#include <zephyr/drivers/emul.h>
-#include <zephyr/ztest.h>
-
#include "driver/usb_mux/tusb1064.h"
#include "emul/emul_tusb1064.h"
#include "usb_mux.h"
#include "usbc/usb_muxes.h"
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/emul.h>
+#include <zephyr/ztest.h>
+
const static struct emul *emul = EMUL_DT_GET(DT_NODELABEL(tusb1064_mux_1));
const static int tusb1064_port = USB_MUX_PORT(DT_NODELABEL(tusb1064_mux_1));
diff --git a/zephyr/test/krabby/src/usbc_config.c b/zephyr/test/krabby/src/usbc_config.c
new file mode 100644
index 0000000000..0b6c8bc80d
--- /dev/null
+++ b/zephyr/test/krabby/src/usbc_config.c
@@ -0,0 +1,131 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "adc.h"
+#include "charge_manager.h"
+#include "driver/ppc/syv682x.h"
+#include "driver/ppc/syv682x_public.h"
+#include "emul/emul_common_i2c.h"
+#include "emul/emul_syv682x.h"
+#include "i2c/i2c.h"
+#include "usb_pd.h"
+#include "usbc_ppc.h"
+
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/emul.h>
+#include <zephyr/ztest.h>
+
+bool ppc_sink_enabled(int port)
+{
+ const struct emul *emul = (port == 0) ?
+ EMUL_DT_GET(DT_NODELABEL(ppc0_emul)) :
+ EMUL_DT_GET(DT_NODELABEL(ppc1_emul));
+ uint8_t val = 0;
+
+ syv682x_emul_get_reg(emul, SYV682X_CONTROL_1_REG, &val);
+
+ return !(val & (SYV682X_CONTROL_1_PWR_ENB | SYV682X_CONTROL_1_HV_DR));
+}
+
+ZTEST(usbc_config, test_set_active_charge_port)
+{
+ /* reset ppc state */
+ zassert_ok(board_set_active_charge_port(CHARGE_PORT_NONE), NULL);
+ zassert_false(ppc_sink_enabled(0), NULL);
+ zassert_false(ppc_sink_enabled(1), NULL);
+
+ /* sourcing port 0, expect port 0 not sinkable */
+ zassert_ok(pd_set_power_supply_ready(0));
+ zassert_not_equal(board_set_active_charge_port(0), 0, NULL);
+ zassert_true(board_vbus_source_enabled(0), NULL);
+ zassert_false(board_vbus_source_enabled(1), NULL);
+ zassert_false(ppc_sink_enabled(0), NULL);
+ zassert_false(ppc_sink_enabled(1), NULL);
+
+ /* sinking port 1 */
+ zassert_ok(board_set_active_charge_port(1), NULL);
+ zassert_false(ppc_sink_enabled(0), NULL);
+ zassert_true(ppc_sink_enabled(1), NULL);
+
+ /*
+ * sinking an invalid port should return error and doesn't change
+ * any state
+ */
+ zassert_not_equal(board_set_active_charge_port(2), 0, NULL);
+ zassert_true(board_vbus_source_enabled(0), NULL);
+ zassert_false(board_vbus_source_enabled(1), NULL);
+ zassert_false(ppc_sink_enabled(0), NULL);
+ zassert_true(ppc_sink_enabled(1), NULL);
+
+ /* turn of sourcing, sinking port 0 */
+ pd_power_supply_reset(0);
+ zassert_ok(board_set_active_charge_port(0), NULL);
+ zassert_true(ppc_sink_enabled(0), NULL);
+ zassert_false(ppc_sink_enabled(1), NULL);
+
+ /* sinking port 1 */
+ zassert_ok(board_set_active_charge_port(1), NULL);
+ zassert_false(ppc_sink_enabled(0), NULL);
+ zassert_true(ppc_sink_enabled(1), NULL);
+
+ /* back to port 0 */
+ zassert_ok(board_set_active_charge_port(0), NULL);
+ zassert_true(ppc_sink_enabled(0), NULL);
+ zassert_false(ppc_sink_enabled(1), NULL);
+
+ /* reset */
+ zassert_ok(board_set_active_charge_port(CHARGE_PORT_NONE), NULL);
+ zassert_false(board_vbus_source_enabled(0), NULL);
+ zassert_false(board_vbus_source_enabled(1), NULL);
+ zassert_false(ppc_sink_enabled(0), NULL);
+ zassert_false(ppc_sink_enabled(1), NULL);
+}
+
+ZTEST(usbc_config, test_set_active_charge_port_fail)
+{
+ const struct emul *ppc0 = EMUL_DT_GET(DT_NODELABEL(ppc0_emul));
+
+ /* Verify that failure on ppc0 doesn't affect ppc1 */
+ i2c_common_emul_set_write_fail_reg(
+ emul_syv682x_get_i2c_common_data(ppc0),
+ I2C_COMMON_EMUL_FAIL_ALL_REG);
+
+ zassert_ok(board_set_active_charge_port(1), NULL);
+ zassert_true(ppc_sink_enabled(1), NULL);
+ zassert_ok(board_set_active_charge_port(CHARGE_PORT_NONE), NULL);
+ zassert_false(ppc_sink_enabled(1), NULL);
+ zassert_ok(board_set_active_charge_port(1), NULL);
+ zassert_true(ppc_sink_enabled(1), NULL);
+
+ /* trying to enable ppc0 results in error */
+ zassert_not_equal(board_set_active_charge_port(0), 0, NULL);
+ zassert_false(ppc_sink_enabled(1), NULL);
+}
+
+ZTEST(usbc_config, test_adc_channel)
+{
+ zassert_equal(board_get_vbus_adc(0), ADC_VBUS_C0, NULL);
+ zassert_equal(board_get_vbus_adc(1), ADC_VBUS_C1, NULL);
+ zassert_equal(board_get_vbus_adc(99), ADC_VBUS_C0, NULL);
+}
+
+static void reset_ppc_state(void *fixture)
+{
+ const struct emul *ppc0 = EMUL_DT_GET(DT_NODELABEL(ppc0_emul));
+ const struct emul *ppc1 = EMUL_DT_GET(DT_NODELABEL(ppc1_emul));
+
+ i2c_common_emul_set_write_fail_reg(
+ emul_syv682x_get_i2c_common_data(ppc0),
+ I2C_COMMON_EMUL_NO_FAIL_REG);
+ i2c_common_emul_set_write_fail_reg(
+ emul_syv682x_get_i2c_common_data(ppc1),
+ I2C_COMMON_EMUL_NO_FAIL_REG);
+
+ ppc_vbus_source_enable(0, false);
+ ppc_vbus_source_enable(1, false);
+ board_set_active_charge_port(CHARGE_PORT_NONE);
+}
+
+ZTEST_SUITE(usbc_config, NULL, NULL, reset_ppc_state, NULL, NULL);
diff --git a/zephyr/test/krabby/testcase.yaml b/zephyr/test/krabby/testcase.yaml
index a748e45be5..781d82db4b 100644
--- a/zephyr/test/krabby/testcase.yaml
+++ b/zephyr/test/krabby/testcase.yaml
@@ -6,15 +6,12 @@ common:
platform_allow: native_posix
tests:
krabby.default:
- extra_args: DTC_OVERLAY_FILE="common.dts;../projects/corsola/interrupts_krabby.dts;../projects/corsola/gpio_krabby.dts;pinctrl.dts"
+ extra_args: DTC_OVERLAY_FILE="common.dts;../program/corsola/ite_interrupts.dtsi;../program/corsola/ite_gpio.dtsi;pinctrl.dts"
extra_configs:
- CONFIG_TEST_KRABBY=y
- CONFIG_MUX_INIT_ADC=y
krabby.tentacruel:
- extra_args: DTC_OVERLAY_FILE="common.dts;adc_temp.dts;../projects/corsola/interrupts_tentacruel.dts;../projects/corsola/gpio_tentacruel.dts;../projects/corsola/thermistor_tentacruel.dts;pinctrl.dts"
+ extra_args: DTC_OVERLAY_FILE="common.dts;adc_temp.dts;../program/corsola/interrupts_tentacruel.dtsi;../program/corsola/gpio_tentacruel.dtsi;../program/corsola/thermistor_tentacruel.dtsi;pinctrl.dts"
extra_configs:
- CONFIG_TEST_TENTACRUEL=y
- - CONFIG_PLATFORM_EC_TEMP_SENSOR=y
- - CONFIG_PLATFORM_EC_THERMISTOR=y
- CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y
- - CONFIG_ADC_EMUL=y
diff --git a/zephyr/test/math/src/fixed_point_int_sqrtf.c b/zephyr/test/math/src/fixed_point_int_sqrtf.c
index a76567b9d7..4403980a96 100644
--- a/zephyr/test/math/src/fixed_point_int_sqrtf.c
+++ b/zephyr/test/math/src/fixed_point_int_sqrtf.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "math.h"
#include "math_util.h"
+#include <zephyr/ztest.h>
+
ZTEST_USER(math, int_sqrtf_negative)
{
zassert_equal(int_sqrtf(-100), 0);
diff --git a/zephyr/test/math/src/mask.c b/zephyr/test/math/src/mask.c
index c38b756eda..c986834eb8 100644
--- a/zephyr/test/math/src/mask.c
+++ b/zephyr/test/math/src/mask.c
@@ -3,12 +3,13 @@
* found in the LICENSE file.
*/
-#include <inttypes.h>
-#include <zephyr/ztest.h>
-
#include "math.h"
#include "math_util.h"
+#include <inttypes.h>
+
+#include <zephyr/ztest.h>
+
ZTEST_USER(math, bitmask_uint64)
{
zassert_equal(bitmask_uint64(-1), 0);
diff --git a/zephyr/test/math/src/math_util.c b/zephyr/test/math/src/math_util.c
index a3f26d3fea..184dd2b999 100644
--- a/zephyr/test/math/src/math_util.c
+++ b/zephyr/test/math/src/math_util.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
+#include "builtin/stdio.h"
#include "common.h"
#include "math.h"
#include "math_util.h"
-#include "builtin/stdio.h"
+
+#include <zephyr/ztest.h>
ZTEST_USER(math, arc_cos__x_below_range)
{
diff --git a/zephyr/test/math/src/vector.c b/zephyr/test/math/src/vector.c
index 87dad3a78d..e588be52af 100644
--- a/zephyr/test/math/src/vector.c
+++ b/zephyr/test/math/src/vector.c
@@ -3,11 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/ztest.h>
-
#include "math.h"
#include "math_util.h"
+#include <zephyr/ztest.h>
+
ZTEST_USER(math, cosine_of_angle_diff__zero_magnitude_vector)
{
intv3_t v0 = { 0, 0, 0 };
diff --git a/zephyr/test/qcom_power/boards/native_posix.overlay b/zephyr/test/qcom_power/boards/native_posix.overlay
index f062f27614..9af8f4cd13 100644
--- a/zephyr/test/qcom_power/boards/native_posix.overlay
+++ b/zephyr/test/qcom_power/boards/native_posix.overlay
@@ -65,7 +65,10 @@
enum-name = "GPIO_PMIC_KPD_PWR_ODL";
};
gpio_pmic_resin_l: pmic_resin_l {
- gpios = <&gpio0 21 GPIO_OUTPUT_HIGH>;
+ /* Real hardware will allow reading even if GPIO_INPUT
+ * is not set, but the gpio_emul will not.
+ */
+ gpios = <&gpio0 21 (GPIO_INPUT | GPIO_OUTPUT_HIGH)>;
enum-name = "GPIO_PMIC_RESIN_L";
};
gpio_warm_reset_l: warm_reset_l {
@@ -87,6 +90,10 @@
gpios = <&gpio0 25 (GPIO_INPUT | GPIO_PULL_UP)>;
enum-name = "GPIO_POWER_BUTTON_L";
};
+ gpio_switchcap_pg: src_vph_pwr_pg {
+ gpios = <&gpio0 26 GPIO_INPUT_PULL_DOWN>;
+ enum-name = "GPIO_SWITCHCAP_PG";
+ };
};
gpio-interrupts {
@@ -133,9 +140,10 @@
};
switchcap {
- compatible = "switchcap-gpio";
+ compatible = "cros-ec,switchcap-gpio";
enable-pin = <&gpio_switchcap_on>;
- power-good-pin = <&gpio_switchcap_pg_int_l>;
+ power-good-pin = <&gpio_switchcap_pg>;
+ poff-delay-ms = <1>;
};
};
diff --git a/zephyr/test/qcom_power/prj.conf b/zephyr/test/qcom_power/prj.conf
index a74109ddde..2a160bd7da 100644
--- a/zephyr/test/qcom_power/prj.conf
+++ b/zephyr/test/qcom_power/prj.conf
@@ -14,12 +14,9 @@ CONFIG_NATIVE_UART_0_ON_STDINOUT=y
CONFIG_CROS_EC=y
CONFIG_EMUL=y
-CONFIG_EMUL_CROS_FLASH=y
CONFIG_FLASH=y
CONFIG_GPIO=y
-CONFIG_GPIO_EMUL=y
CONFIG_GPIO_GET_CONFIG=y
-CONFIG_LOG=y
CONFIG_PLATFORM_EC=y
CONFIG_RING_BUFFER=y
CONFIG_SERIAL=y
@@ -40,4 +37,3 @@ CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y
CONFIG_PLATFORM_EC_POWERSEQ_SC7280=y
CONFIG_PLATFORM_EC_POWER_BUTTON=y
CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
-CONFIG_PLATFORM_EC_SWITCHCAP_GPIO=y
diff --git a/zephyr/test/qcom_power/src/main.c b/zephyr/test/qcom_power/src/main.c
index 22dd1fe2ec..8de3f051d6 100644
--- a/zephyr/test/qcom_power/src/main.c
+++ b/zephyr/test/qcom_power/src/main.c
@@ -3,35 +3,55 @@
* found in the LICENSE file.
*/
-#include <zephyr/device.h>
-#include <zephyr/devicetree.h>
-#include <zephyr/kernel.h>
-#include <zephyr/ztest.h>
-#include <zephyr/drivers/gpio/gpio_emul.h>
-#include <zephyr/drivers/gpio.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/fff.h>
-
-#include <setjmp.h>
-
-#include "gpio_signal.h"
-#include "power/qcom.h"
-#include "battery.h"
-#include "ec_app_main.h"
-#include "power.h"
#include "console.h"
-#include "task.h"
+#include "ec_app_main.h"
+#include "gpio.h"
+#include "gpio_signal.h"
#include "hooks.h"
#include "host_command.h"
#include "lid_switch.h"
+#include "power.h"
+#include "power/qcom.h"
+#include "task.h"
-#define AP_RST_L_NODE DT_PATH(named_gpios, ap_rst_l)
-#define POWER_GOOD_NODE DT_PATH(named_gpios, mb_power_good)
-#define AP_SUSPEND_NODE DT_PATH(named_gpios, ap_suspend)
-#define SWITCHCAP_PG_NODE DT_PATH(named_gpios, switchcap_pg_int_l)
-#define PMIC_RESIN_L_NODE DT_PATH(named_gpios, pmic_resin_l)
-#define EC_PWR_BTN_ODL_NODE DT_PATH(named_gpios, ec_pwr_btn_odl)
-#define LID_OPEN_EC_NODE DT_PATH(named_gpios, lid_open_ec)
+#include <setjmp.h>
+
+#include <zephyr/device.h>
+#include <zephyr/devicetree.h>
+#include <zephyr/drivers/gpio.h>
+#include <zephyr/drivers/gpio/gpio_emul.h>
+#include <zephyr/fff.h>
+#include <zephyr/kernel.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest.h>
+
+/* For simplicity, enforce that all the gpios are on the same controller. */
+#define GPIO_DEVICE \
+ DEVICE_DT_GET(DT_GPIO_CTLR(DT_PATH(named_gpios, ap_rst_l), gpios))
+#define ASSERT_SAME_CONTROLLER(x) \
+ BUILD_ASSERT(DT_DEP_ORD(DT_GPIO_CTLR(DT_PATH(named_gpios, ap_rst_l), \
+ gpios)) == \
+ DT_DEP_ORD(DT_GPIO_CTLR(DT_PATH(named_gpios, x), gpios)))
+
+#define AP_RST_L_PIN DT_GPIO_PIN(DT_PATH(named_gpios, ap_rst_l), gpios)
+ASSERT_SAME_CONTROLLER(ap_rst_l);
+#define POWER_GOOD_PIN DT_GPIO_PIN(DT_PATH(named_gpios, mb_power_good), gpios)
+ASSERT_SAME_CONTROLLER(mb_power_good);
+#define AP_SUSPEND_PIN DT_GPIO_PIN(DT_PATH(named_gpios, ap_suspend), gpios)
+ASSERT_SAME_CONTROLLER(ap_suspend);
+#define SWITCHCAP_PG_PIN \
+ DT_GPIO_PIN(DT_PATH(named_gpios, src_vph_pwr_pg), gpios)
+ASSERT_SAME_CONTROLLER(src_vph_pwr_pg);
+#define PMIC_RESIN_L_PIN DT_GPIO_PIN(DT_PATH(named_gpios, pmic_resin_l), gpios)
+ASSERT_SAME_CONTROLLER(pmic_resin_l);
+#define EC_PWR_BTN_ODL_PIN \
+ DT_GPIO_PIN(DT_PATH(named_gpios, ec_pwr_btn_odl), gpios)
+ASSERT_SAME_CONTROLLER(ec_pwr_btn_odl);
+#define LID_OPEN_EC_PIN DT_GPIO_PIN(DT_PATH(named_gpios, lid_open_ec), gpios)
+ASSERT_SAME_CONTROLLER(lid_open_ec);
+#define PMIC_KPD_PWR_ODL_PIN \
+ DT_GPIO_PIN(DT_PATH(named_gpios, pmic_kpd_pwr_odl), gpios)
+ASSERT_SAME_CONTROLLER(pmic_kpd_pwr_odl);
static int chipset_reset_count;
static bool set_power_good_on_reset;
@@ -45,11 +65,9 @@ DECLARE_HOOK(HOOK_CHIPSET_RESET, do_chipset_reset, HOOK_PRIO_DEFAULT);
static void do_chipset_shutdown(void)
{
if (set_power_good_on_reset) {
- static const struct device *power_good_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(POWER_GOOD_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
- gpio_emul_input_set(power_good_dev,
- DT_GPIO_PIN(POWER_GOOD_NODE, gpios), 1);
+ gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 1);
}
}
DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, do_chipset_shutdown, HOOK_PRIO_DEFAULT);
@@ -58,6 +76,10 @@ DEFINE_FFF_GLOBALS;
FAKE_VALUE_FUNC(int, system_can_boot_ap);
FAKE_VALUE_FUNC(int, battery_wait_for_stable);
+int battery_is_present(void)
+{
+ return 1;
+}
/* Tests the chipset_ap_rst_interrupt() handler when in S3.
*
@@ -68,15 +90,11 @@ FAKE_VALUE_FUNC(int, battery_wait_for_stable);
*/
static void do_chipset_ap_rst_interrupt_in_s3(int times)
{
- static const struct device *ap_rst_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(AP_RST_L_NODE, gpios));
- static const struct device *ap_suspend_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(AP_SUSPEND_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
/* Preconditions */
power_signal_enable_interrupt(GPIO_AP_SUSPEND);
- zassert_ok(gpio_emul_input_set(ap_suspend_dev,
- DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 1));
power_set_state(POWER_S3);
task_wake(TASK_ID_CHIPSET);
k_sleep(K_MSEC(10));
@@ -87,18 +105,15 @@ static void do_chipset_ap_rst_interrupt_in_s3(int times)
/* Pulse gpio_ap_rst_l `times` */
for (int i = 0; i < times; ++i) {
- zassert_ok(gpio_emul_input_set(
- ap_rst_dev, DT_GPIO_PIN(AP_RST_L_NODE, gpios), 0));
- zassert_ok(gpio_emul_input_set(
- ap_rst_dev, DT_GPIO_PIN(AP_RST_L_NODE, gpios), 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 1));
}
/* Wait for timeout AP_RST_TRANSITION_TIMEOUT. */
k_sleep(K_MSEC(500));
/* Verify that gpio_ap_suspend is ignored. */
- zassert_ok(gpio_emul_input_set(ap_suspend_dev,
- DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 0));
k_sleep(K_MSEC(10));
zassert_equal(power_get_state(), POWER_S3);
/* Verify that HOOK_CHIPSET_RESET was called once. */
@@ -140,18 +155,15 @@ ZTEST(qcom_power, test_notify_chipset_reset_s3)
*/
static void do_chipset_ap_rst_interrupt_in_s0(int times)
{
- static const struct device *ap_rst_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(AP_RST_L_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
shell_backend_dummy_clear_output(get_ec_shell());
chipset_reset_count = 0;
/* Pulse gpio_ap_rst_l `times` */
for (int i = 0; i < times; ++i) {
- zassert_ok(gpio_emul_input_set(
- ap_rst_dev, DT_GPIO_PIN(AP_RST_L_NODE, gpios), 0));
- zassert_ok(gpio_emul_input_set(
- ap_rst_dev, DT_GPIO_PIN(AP_RST_L_NODE, gpios), 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 1));
}
/* Wait for timeout AP_RST_TRANSITION_TIMEOUT. */
@@ -218,39 +230,57 @@ void warm_reset_callback(const struct device *gpio_dev,
struct gpio_callback *callback_struct,
gpio_port_pins_t pins)
{
- if ((pins & BIT(DT_GPIO_PIN(PMIC_RESIN_L_NODE, gpios))) == 0) {
+ if ((pins & BIT(PMIC_RESIN_L_PIN)) == 0) {
return;
}
- if (gpio_emul_output_get(gpio_dev,
- DT_GPIO_PIN(PMIC_RESIN_L_NODE, gpios))) {
- static const struct device *ap_rst_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(AP_RST_L_NODE, gpios));
+ if (gpio_emul_output_get(gpio_dev, PMIC_RESIN_L_PIN)) {
+ gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 0);
+ }
+}
+
+static void set_power_good(struct k_work *work)
+{
+ static const struct device *gpio_dev = GPIO_DEVICE;
+
+ gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 1);
+}
+K_WORK_DEFINE(set_power_good_work, set_power_good);
- gpio_emul_input_set(ap_rst_dev,
- DT_GPIO_PIN(AP_RST_L_NODE, gpios), 0);
+/* PMIC_KPD_PWR_ODL is a signal to turn the power on. The signal that
+ * it worked is POWER_GOOD.
+ */
+void power_good_callback(const struct device *gpio_dev,
+ struct gpio_callback *callback_struct,
+ gpio_port_pins_t pins)
+{
+ if ((pins & BIT(PMIC_KPD_PWR_ODL_PIN)) == 0) {
+ return;
+ }
+ if (!gpio_emul_output_get(gpio_dev, PMIC_KPD_PWR_ODL_PIN)) {
+ /* Set power good in the work queue, instead of now. */
+ k_work_submit(&set_power_good_work);
}
}
/* Call chipset_reset, wait for PMIC_RESIN_L, pulse ap_rsl_l. */
ZTEST(qcom_power, test_chipset_reset_success)
{
- static const struct device *ap_rst_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(AP_RST_L_NODE, gpios));
- static const struct device *pmic_resin_l_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(PMIC_RESIN_L_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
const char *buffer;
size_t buffer_size;
/* Setup callback. */
gpio_init_callback(&gpio_callback, warm_reset_callback,
- BIT(DT_GPIO_PIN(PMIC_RESIN_L_NODE, gpios)));
- zassert_ok(gpio_add_callback(pmic_resin_l_dev, &gpio_callback));
+ BIT(PMIC_RESIN_L_PIN));
+ zassert_ok(gpio_add_callback(gpio_dev, &gpio_callback));
+ zassert_ok(gpio_pin_interrupt_configure(gpio_dev, PMIC_RESIN_L_PIN,
+ GPIO_INT_EDGE_BOTH));
/* Reset. The reason doesn't really matter. */
shell_backend_dummy_clear_output(get_ec_shell());
chipset_reset(CHIPSET_RESET_KB_WARM_REBOOT);
k_sleep(K_MSEC(100));
- gpio_emul_input_set(ap_rst_dev, DT_GPIO_PIN(AP_RST_L_NODE, gpios), 1);
+ gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 1);
/* Long enough for a cold reset, although we don't expect one. */
k_sleep(K_MSEC(1000));
@@ -268,8 +298,7 @@ ZTEST(qcom_power, test_chipset_reset_success)
/* Sent the host command, set the gpio, wait for transition to S3. */
ZTEST(qcom_power, test_request_sleep)
{
- static const struct device *ap_suspend_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(AP_SUSPEND_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
struct ec_params_host_sleep_event params = {
.sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND,
};
@@ -277,8 +306,7 @@ ZTEST(qcom_power, test_request_sleep)
EC_CMD_HOST_SLEEP_EVENT, UINT8_C(0), params);
zassert_ok(host_command_process(&args));
- zassert_ok(gpio_emul_input_set(ap_suspend_dev,
- DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 1));
k_sleep(K_SECONDS(16));
zassert_equal(power_get_state(), POWER_S3);
zassert_false(host_is_event_set(EC_HOST_EVENT_HANG_DETECT));
@@ -314,53 +342,88 @@ ZTEST(qcom_power, test_chipset_force_shutdown)
ZTEST(qcom_power, test_power_button)
{
- static const struct device *ec_pwr_btn_odl_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(EC_PWR_BTN_ODL_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
+
+ /* Setup callback. */
+ gpio_init_callback(&gpio_callback, power_good_callback,
+ BIT(PMIC_KPD_PWR_ODL_PIN));
+ zassert_ok(gpio_add_callback(gpio_dev, &gpio_callback));
power_set_state(POWER_G3);
+ zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, PMIC_RESIN_L_PIN, 1));
k_sleep(K_MSEC(10));
zassert_equal(power_get_state(), POWER_G3);
- zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev,
- DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios),
- 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0));
k_sleep(K_MSEC(100));
- zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev,
- DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios),
- 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1));
k_sleep(K_MSEC(500));
zassert_equal(power_get_state(), POWER_S0);
}
ZTEST(qcom_power, test_power_button_no_power_good)
{
- static const struct device *ec_pwr_btn_odl_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(EC_PWR_BTN_ODL_NODE, gpios));
- static const struct device *power_good_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(POWER_GOOD_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
- zassert_ok(gpio_emul_input_set(power_good_dev,
- DT_GPIO_PIN(POWER_GOOD_NODE, gpios), 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 0));
power_set_state(POWER_G3);
k_sleep(K_MSEC(10));
zassert_equal(power_get_state(), POWER_G3);
- zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev,
- DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios),
- 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0));
k_sleep(K_MSEC(100));
- zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev,
- DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios),
- 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1));
k_sleep(K_MSEC(1500));
zassert_equal(power_get_state(), POWER_S5, "power_state=%d",
power_get_state());
}
+ZTEST(qcom_power, test_power_button_no_switchcap_good)
+{
+ static const struct device *gpio_dev = GPIO_DEVICE;
+
+ zassert_ok(gpio_emul_input_set(gpio_dev, SWITCHCAP_PG_PIN, 0));
+ power_set_state(POWER_G3);
+ k_sleep(K_MSEC(10));
+ zassert_equal(power_get_state(), POWER_G3);
+
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0));
+ k_sleep(K_MSEC(100));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1));
+ k_sleep(K_SECONDS(10));
+ zassert_equal(power_get_state(), POWER_S5, "power_state=%d",
+ power_get_state());
+}
+
+ZTEST(qcom_power, test_power_button_no_pmic_resin_pullup)
+{
+ const char *buffer;
+ size_t buffer_size;
+ static const struct device *gpio_dev = GPIO_DEVICE;
+
+ power_set_state(POWER_G3);
+ k_sleep(K_MSEC(10));
+ zassert_equal(power_get_state(), POWER_G3);
+
+ shell_backend_dummy_clear_output(get_ec_shell());
+ zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, PMIC_RESIN_L_PIN, 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0));
+ k_sleep(K_MSEC(100));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1));
+ k_sleep(K_SECONDS(10));
+ zassert_equal(power_get_state(), POWER_S5, "power_state=%d",
+ power_get_state());
+
+ buffer = shell_backend_dummy_get_output(get_ec_shell(), &buffer_size);
+ zassert_not_null(strstr(buffer, "PMIC_RESIN_L not pulled up by PMIC"),
+ "Invalid console output %s", buffer);
+}
+
ZTEST(qcom_power, test_power_button_battery_low)
{
- static const struct device *ec_pwr_btn_odl_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(EC_PWR_BTN_ODL_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
RESET_FAKE(system_can_boot_ap);
system_can_boot_ap_fake.return_val = 0;
@@ -369,13 +432,9 @@ ZTEST(qcom_power, test_power_button_battery_low)
k_sleep(K_MSEC(10));
zassert_equal(power_get_state(), POWER_G3);
- zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev,
- DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios),
- 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0));
k_sleep(K_MSEC(100));
- zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev,
- DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios),
- 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1));
/* > CAN_BOOT_AP_CHECK_TIMEOUT + CAN_BOOT_AP_CHECK_WAIT */
k_sleep(K_MSEC(1800));
zassert_equal(power_get_state(), POWER_S5);
@@ -383,8 +442,7 @@ ZTEST(qcom_power, test_power_button_battery_low)
ZTEST(qcom_power, test_host_sleep_event_resume)
{
- static const struct device *ap_suspend_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(AP_SUSPEND_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
struct ec_params_host_sleep_event params = {
.sleep_event = HOST_SLEEP_EVENT_S3_RESUME,
};
@@ -393,16 +451,14 @@ ZTEST(qcom_power, test_host_sleep_event_resume)
/* Get into S3 first */
power_signal_enable_interrupt(GPIO_AP_SUSPEND);
- zassert_ok(gpio_emul_input_set(ap_suspend_dev,
- DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 1));
power_set_state(POWER_S3);
task_wake(TASK_ID_CHIPSET);
k_sleep(K_MSEC(10));
zassert_equal(power_get_state(), POWER_S3);
/* Exit suspend via gpio. */
- zassert_ok(gpio_emul_input_set(ap_suspend_dev,
- DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 0));
k_sleep(K_MSEC(100));
zassert_equal(power_get_state(), POWER_S0, "power_state=%d",
power_get_state());
@@ -414,40 +470,29 @@ ZTEST(qcom_power, test_host_sleep_event_resume)
power_get_state());
/* Check that AP_SUSPEND interrupts are disabled & we are in S0. */
- zassert_ok(gpio_emul_input_set(ap_suspend_dev,
- DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 1));
k_sleep(K_MSEC(100));
zassert_equal(power_get_state(), POWER_S0);
}
ZTEST(qcom_power, test_power_button_off)
{
- static const struct device *ec_pwr_btn_odl_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(EC_PWR_BTN_ODL_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
- zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev,
- DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios),
- 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0));
k_sleep(K_SECONDS(9));
- zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev,
- DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios),
- 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1));
k_sleep(K_MSEC(500));
zassert_equal(power_get_state(), POWER_S5);
}
ZTEST(qcom_power, test_power_button_off_cancel)
{
- static const struct device *ec_pwr_btn_odl_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(EC_PWR_BTN_ODL_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
- zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev,
- DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios),
- 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 0));
k_sleep(K_SECONDS(4));
- zassert_ok(gpio_emul_input_set(ec_pwr_btn_odl_dev,
- DT_GPIO_PIN(EC_PWR_BTN_ODL_NODE, gpios),
- 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, EC_PWR_BTN_ODL_PIN, 1));
k_sleep(K_MSEC(500));
zassert_equal(power_get_state(), POWER_S0);
}
@@ -456,12 +501,10 @@ ZTEST(qcom_power, test_no_power_good)
{
const char *buffer;
size_t buffer_size;
- static const struct device *power_good_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(POWER_GOOD_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
shell_backend_dummy_clear_output(get_ec_shell());
- zassert_ok(gpio_emul_input_set(power_good_dev,
- DT_GPIO_PIN(POWER_GOOD_NODE, gpios), 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 0));
k_sleep(K_MSEC(500));
zassert_equal(power_get_state(), POWER_S5, "power_state=%d",
power_get_state());
@@ -474,12 +517,10 @@ ZTEST(qcom_power, test_no_power_good_then_good)
{
const char *buffer;
size_t buffer_size;
- static const struct device *power_good_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(POWER_GOOD_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
shell_backend_dummy_clear_output(get_ec_shell());
- zassert_ok(gpio_emul_input_set(power_good_dev,
- DT_GPIO_PIN(POWER_GOOD_NODE, gpios), 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 0));
set_power_good_on_reset = true;
k_sleep(K_MSEC(500));
zassert_equal(power_get_state(), POWER_S5, "power_state=%d",
@@ -493,18 +534,15 @@ ZTEST(qcom_power, test_no_power_good_then_good)
ZTEST(qcom_power, test_lid_open_power_on)
{
- static const struct device *lid_open_ec_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(LID_OPEN_EC_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
- zassert_ok(gpio_emul_input_set(
- lid_open_ec_dev, DT_GPIO_PIN(LID_OPEN_EC_NODE, gpios), 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, LID_OPEN_EC_PIN, 0));
power_set_state(POWER_G3);
k_sleep(K_MSEC(100));
zassert_equal(power_get_state(), POWER_G3);
zassert_false(lid_is_open());
- zassert_ok(gpio_emul_input_set(
- lid_open_ec_dev, DT_GPIO_PIN(LID_OPEN_EC_NODE, gpios), 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, LID_OPEN_EC_PIN, 1));
k_sleep(K_MSEC(500));
zassert_equal(power_get_state(), POWER_S0, "power_state=%d",
power_get_state());
@@ -556,11 +594,9 @@ ZTEST(qcom_power, test_power_chipset_init_sysjump_power_good)
ZTEST(qcom_power, test_power_chipset_init_sysjump_power_off)
{
- static const struct device *power_good_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(POWER_GOOD_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
- zassert_ok(gpio_emul_input_set(power_good_dev,
- DT_GPIO_PIN(POWER_GOOD_NODE, gpios), 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 0));
system_set_reset_flags(EC_RESET_FLAG_SYSJUMP);
zassert_equal(power_chipset_init(), POWER_G3);
power_set_state(POWER_G3);
@@ -585,18 +621,7 @@ ZTEST(qcom_power, test_power_chipset_init_ap_off)
void start_in_s0(void *fixture)
{
- static const struct device *ap_rst_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(AP_RST_L_NODE, gpios));
- static const struct device *power_good_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(POWER_GOOD_NODE, gpios));
- static const struct device *ap_suspend_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(AP_SUSPEND_NODE, gpios));
- static const struct device *switchcap_pg_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(SWITCHCAP_PG_NODE, gpios));
- static const struct device *pmic_resin_l_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(PMIC_RESIN_L_NODE, gpios));
- static const struct device *lid_open_ec_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(LID_OPEN_EC_NODE, gpios));
+ static const struct device *gpio_dev = GPIO_DEVICE;
RESET_FAKE(system_can_boot_ap);
system_can_boot_ap_fake.return_val = 1;
@@ -604,18 +629,12 @@ void start_in_s0(void *fixture)
power_signal_disable_interrupt(GPIO_AP_SUSPEND);
power_signal_enable_interrupt(GPIO_AP_RST_L);
- zassert_ok(gpio_emul_input_set(power_good_dev,
- DT_GPIO_PIN(POWER_GOOD_NODE, gpios), 1));
- zassert_ok(gpio_emul_input_set(ap_suspend_dev,
- DT_GPIO_PIN(AP_SUSPEND_NODE, gpios), 0));
- zassert_ok(gpio_emul_input_set(ap_rst_dev,
- DT_GPIO_PIN(AP_RST_L_NODE, gpios), 1));
- zassert_ok(gpio_emul_input_set(
- switchcap_pg_dev, DT_GPIO_PIN(SWITCHCAP_PG_NODE, gpios), 1));
- zassert_ok(gpio_pin_set(pmic_resin_l_dev,
- DT_GPIO_PIN(PMIC_RESIN_L_NODE, gpios), 1));
- zassert_ok(gpio_emul_input_set(
- lid_open_ec_dev, DT_GPIO_PIN(LID_OPEN_EC_NODE, gpios), 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, POWER_GOOD_PIN, 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, AP_SUSPEND_PIN, 0));
+ zassert_ok(gpio_emul_input_set(gpio_dev, AP_RST_L_PIN, 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, SWITCHCAP_PG_PIN, 1));
+ zassert_ok(gpio_pin_set(gpio_dev, PMIC_RESIN_L_PIN, 1));
+ zassert_ok(gpio_emul_input_set(gpio_dev, LID_OPEN_EC_PIN, 1));
power_set_state(POWER_S0);
power_signal_interrupt(GPIO_AP_SUSPEND);
task_wake(TASK_ID_CHIPSET);
@@ -629,9 +648,9 @@ void start_in_s0(void *fixture)
void qcom_cleanup(void *fixture)
{
if (gpio_callback.handler != NULL) {
- static const struct device *pmic_resin_l_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(PMIC_RESIN_L_NODE, gpios));
- gpio_remove_callback(pmic_resin_l_dev, &gpio_callback);
+ static const struct device *gpio_dev = GPIO_DEVICE;
+
+ gpio_remove_callback(gpio_dev, &gpio_callback);
gpio_callback.handler = NULL;
}
host_clear_events(EC_HOST_EVENT_MASK(EC_HOST_EVENT_HANG_DETECT));
diff --git a/zephyr/test/rex/CMakeLists.txt b/zephyr/test/rex/CMakeLists.txt
index 3bca2df494..ddee5d0120 100644
--- a/zephyr/test/rex/CMakeLists.txt
+++ b/zephyr/test/rex/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright 2022 The ChromiumOS Authors.
+# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
@@ -6,9 +6,9 @@ cmake_minimum_required(VERSION 3.13.1)
find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}")
project(rex)
-zephyr_include_directories("${PLATFORM_EC}/zephyr/projects/rex/include")
+zephyr_include_directories("${PLATFORM_EC_PROGRAM_DIR}/rex/include")
add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils)
target_sources_ifdef(CONFIG_TEST_USB_PD_POLICY app PRIVATE src/usb_pd_policy.c)
-target_sources_ifdef(CONFIG_TEST_USB_PD_POLICY app PRIVATE ${PLATFORM_EC}/zephyr/projects/rex/src/usb_pd_policy.c)
+target_sources_ifdef(CONFIG_TEST_USB_PD_POLICY app PRIVATE ${PLATFORM_EC_PROGRAM_DIR}/rex/src/usb_pd_policy.c)
diff --git a/zephyr/test/rex/README.md b/zephyr/test/rex/README.md
index ef1848a627..454ed6ebb8 100644
--- a/zephyr/test/rex/README.md
+++ b/zephyr/test/rex/README.md
@@ -1,3 +1,3 @@
-Tests for board specific code under `zephyr/projects/rex/src`.
+Tests for board specific code under `zephyr/program/rex/src`.
Run with ./twister -T zephyr/test/rex
diff --git a/zephyr/test/rex/boards/native_posix.overlay b/zephyr/test/rex/boards/native_posix.overlay
index b27b199a12..c4d4413ad7 100644
--- a/zephyr/test/rex/boards/native_posix.overlay
+++ b/zephyr/test/rex/boards/native_posix.overlay
@@ -1,4 +1,4 @@
-/* Copyright 2022 The ChromiumOS Authors.
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
diff --git a/zephyr/test/rex/src/usb_pd_policy.c b/zephyr/test/rex/src/usb_pd_policy.c
index d977bec0a1..3f7406bdad 100644
--- a/zephyr/test/rex/src/usb_pd_policy.c
+++ b/zephyr/test/rex/src/usb_pd_policy.c
@@ -3,15 +3,16 @@
* found in the LICENSE file.
*/
-#include <zephyr/fff.h>
-#include <zephyr/ztest.h>
-
#include "charge_manager.h"
#include "chipset.h"
#include "ec_commands.h"
+#include "usb_charge.h"
#include "usb_pd.h"
#include "usbc_ppc.h"
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
DECLARE_FAKE_VALUE_FUNC(int, chipset_in_state, int);
DEFINE_FAKE_VALUE_FUNC(int, chipset_in_state, int);
DECLARE_FAKE_VALUE_FUNC(int, ppc_vbus_source_enable, int, int);
diff --git a/zephyr/test/rex/testcase.yaml b/zephyr/test/rex/testcase.yaml
index a05855ea52..54e6f6cb55 100644
--- a/zephyr/test/rex/testcase.yaml
+++ b/zephyr/test/rex/testcase.yaml
@@ -1,4 +1,4 @@
-# Copyright 2022 The ChromiumOS Authors.
+# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
diff --git a/zephyr/test/system_common/prj.conf b/zephyr/test/system_common/prj.conf
index 02ba4c42a1..67dc659eed 100644
--- a/zephyr/test/system_common/prj.conf
+++ b/zephyr/test/system_common/prj.conf
@@ -5,7 +5,6 @@
CONFIG_ZTEST=y
CONFIG_ZTEST_NEW_API=y
CONFIG_CROS_EC=y
-CONFIG_LOG=y
CONFIG_PLATFORM_EC_CROS_FWID_VERSION=y
CONFIG_PLATFORM_EC=y
diff --git a/zephyr/test/system_common/src/build_info.c b/zephyr/test/system_common/src/build_info.c
index 7983c1f0a4..1057a3c013 100644
--- a/zephyr/test/system_common/src/build_info.c
+++ b/zephyr/test/system_common/src/build_info.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
+#include "host_command.h"
+#include "system.h"
+
#include <zephyr/device.h>
#include <zephyr/fff.h>
#include <zephyr/ztest_assert.h>
#include <zephyr/ztest_test_new.h>
-#include "host_command.h"
-#include "system.h"
-
ZTEST_SUITE(host_cmd_get_build_info, NULL, NULL, NULL, NULL, NULL);
FAKE_VALUE_FUNC(const char *, system_get_build_info);
diff --git a/zephyr/test/system_common/src/get_version.c b/zephyr/test/system_common/src/get_version.c
index 87a41bad58..a5e4fd5365 100644
--- a/zephyr/test/system_common/src/get_version.c
+++ b/zephyr/test/system_common/src/get_version.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
+#include "host_command.h"
+#include "system.h"
+
#include <zephyr/device.h>
#include <zephyr/fff.h>
#include <zephyr/ztest_assert.h>
#include <zephyr/ztest_test_new.h>
-#include "host_command.h"
-#include "system.h"
-
ZTEST_SUITE(host_cmd_get_version, NULL, NULL, NULL, NULL, NULL);
__override const char *system_get_version(enum ec_image copy)
diff --git a/zephyr/test/system_common/src/reboot.c b/zephyr/test/system_common/src/reboot.c
index 759b93d89f..18b5f0fd38 100644
--- a/zephyr/test/system_common/src/reboot.c
+++ b/zephyr/test/system_common/src/reboot.c
@@ -3,14 +3,14 @@
* found in the LICENSE file.
*/
+#include "host_command.h"
+#include "system.h"
+
#include <zephyr/device.h>
#include <zephyr/fff.h>
#include <zephyr/ztest_assert.h>
#include <zephyr/ztest_test_new.h>
-#include "host_command.h"
-#include "system.h"
-
FAKE_VOID_FUNC(system_reset, int);
FAKE_VOID_FUNC(system_hibernate, uint32_t, uint32_t);
diff --git a/zephyr/test/system_common/src/system_is_locked.c b/zephyr/test/system_common/src/system_is_locked.c
index 2ea9f3038b..d880e4e117 100644
--- a/zephyr/test/system_common/src/system_is_locked.c
+++ b/zephyr/test/system_common/src/system_is_locked.c
@@ -3,12 +3,12 @@
* found in the LICENSE file.
*/
+#include "system.h"
+
#include <zephyr/shell/shell_dummy.h>
#include <zephyr/ztest_assert.h>
#include <zephyr/ztest_test_new.h>
-#include "system.h"
-
ZTEST_USER(system_is_locked, test_syslock_console_cmd)
{
/*
diff --git a/zephyr/test/system_shim/CMakeLists.txt b/zephyr/test/system_shim/CMakeLists.txt
index 5db9cb285d..92b55a47e6 100644
--- a/zephyr/test/system_shim/CMakeLists.txt
+++ b/zephyr/test/system_shim/CMakeLists.txt
@@ -9,5 +9,16 @@ project(system_shim_test)
# Include FFF fakes
add_subdirectory(${PLATFORM_EC}/zephyr/test/test_utils test_utils)
-target_sources(app PRIVATE test_system.c
- ${PLATFORM_EC}/zephyr/shim/src/system.c)
+target_sources(app
+ PRIVATE
+ src/suite.c
+ ${PLATFORM_EC}/zephyr/shim/src/system.c
+)
+target_include_directories(app PRIVATE include)
+
+dt_has_chosen(has_bbram PROPERTY "cros-ec,bbram")
+if(has_bbram)
+ target_sources(app PRIVATE src/test_system.c)
+else()
+ target_sources(app PRIVATE src/no_chosen.c)
+endif()
diff --git a/zephyr/test/system_shim/boards/native_posix.overlay b/zephyr/test/system_shim/boards/native_posix.overlay
index 0bcda0f513..b08ea4bf7a 100644
--- a/zephyr/test/system_shim/boards/native_posix.overlay
+++ b/zephyr/test/system_shim/boards/native_posix.overlay
@@ -6,9 +6,6 @@
#include <board-overlays/native_posix.dts>
/ {
- chosen {
- cros-ec,bbram = &bbram;
- };
bbram: test-bbram-dev {
compatible = "zephyr,bbram-emul";
@@ -33,7 +30,7 @@
offset = <0x07>;
size = <0x05>;
};
- scratchpad {
+ scratchpad: scratchpad {
offset = <0x0c>;
size = <0x04>;
};
diff --git a/zephyr/test/system_shim/default.overlay b/zephyr/test/system_shim/default.overlay
new file mode 100644
index 0000000000..13ceee9c19
--- /dev/null
+++ b/zephyr/test/system_shim/default.overlay
@@ -0,0 +1,12 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "boards/native_posix.overlay"
+
+/ {
+ chosen {
+ cros-ec,bbram = &bbram;
+ };
+};
diff --git a/zephyr/test/system_shim/include/fakes.h b/zephyr/test/system_shim/include/fakes.h
new file mode 100644
index 0000000000..29031a10b7
--- /dev/null
+++ b/zephyr/test/system_shim/include/fakes.h
@@ -0,0 +1,31 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef ZEPHYR_TEST_SYSTEM_SHIM_INCLUDE_FAKES_H_
+#define ZEPHYR_TEST_SYSTEM_SHIM_INCLUDE_FAKES_H_
+
+#include <stdint.h>
+
+#include <zephyr/fff.h>
+
+DECLARE_FAKE_VALUE_FUNC(int, cros_system_native_posix_get_reset_cause,
+ const struct device *);
+DECLARE_FAKE_VALUE_FUNC(uint64_t, cros_system_native_posix_deep_sleep_ticks,
+ const struct device *);
+DECLARE_FAKE_VALUE_FUNC(int, cros_system_native_posix_hibernate,
+ const struct device *, uint32_t, uint32_t);
+DECLARE_FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_vendor,
+ const struct device *);
+DECLARE_FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_name,
+ const struct device *);
+DECLARE_FAKE_VALUE_FUNC(const char *,
+ cros_system_native_posix_get_chip_revision,
+ const struct device *);
+DECLARE_FAKE_VALUE_FUNC(int, cros_system_native_posix_soc_reset,
+ const struct device *);
+DECLARE_FAKE_VOID_FUNC(watchdog_reload);
+DECLARE_FAKE_VOID_FUNC(board_hibernate);
+
+#endif /* ZEPHYR_TEST_SYSTEM_SHIM_INCLUDE_FAKES_H_ */
diff --git a/zephyr/test/system_shim/prj.conf b/zephyr/test/system_shim/prj.conf
index fa7bd9fc04..6888f70a53 100644
--- a/zephyr/test/system_shim/prj.conf
+++ b/zephyr/test/system_shim/prj.conf
@@ -6,6 +6,17 @@ CONFIG_ZTEST=y
CONFIG_ZTEST_NEW_API=y
CONFIG_PLATFORM_EC=y
CONFIG_CROS_EC=y
-CONFIG_LOG=y
CONFIG_BBRAM=y
CONFIG_BBRAM_EMUL=y
+
+CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y
+
+# Make console work
+CONFIG_SERIAL=y
+CONFIG_SHELL_BACKEND_DUMMY=y
+CONFIG_SHELL_BACKEND_DUMMY_BUF_SIZE=1000
+CONFIG_SHELL_BACKEND_SERIAL=n
+
+# Make cros_system driver work
+CONFIG_PM=y
+CONFIG_CROS_SYSTEM_NATIVE_POSIX=y
diff --git a/zephyr/test/system_shim/src/no_chosen.c b/zephyr/test/system_shim/src/no_chosen.c
new file mode 100644
index 0000000000..0e41d562b9
--- /dev/null
+++ b/zephyr/test/system_shim/src/no_chosen.c
@@ -0,0 +1,24 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "fakes.h"
+#include "system.h"
+
+#include <zephyr/ztest.h>
+
+ZTEST(system, test_fail_get_bbram_no_device)
+{
+ zassert_equal(EC_ERROR_INVAL, system_get_bbram(0, NULL));
+}
+
+ZTEST(system, test_fail_set_scratchpad)
+{
+ zassert_equal(-EC_ERROR_INVAL, system_set_scratchpad(0));
+}
+
+ZTEST(system, test_fail_get_scratchpad)
+{
+ zassert_equal(-EC_ERROR_INVAL, system_get_scratchpad(NULL));
+}
diff --git a/zephyr/test/system_shim/src/suite.c b/zephyr/test/system_shim/src/suite.c
new file mode 100644
index 0000000000..b430780d0a
--- /dev/null
+++ b/zephyr/test/system_shim/src/suite.c
@@ -0,0 +1,50 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "fakes.h"
+
+#include <zephyr/device.h>
+#include <zephyr/drivers/bbram.h>
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
+DEFINE_FAKE_VALUE_FUNC(int, cros_system_native_posix_get_reset_cause,
+ const struct device *);
+DEFINE_FAKE_VALUE_FUNC(uint64_t, cros_system_native_posix_deep_sleep_ticks,
+ const struct device *);
+DEFINE_FAKE_VALUE_FUNC(int, cros_system_native_posix_hibernate,
+ const struct device *, uint32_t, uint32_t);
+DEFINE_FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_vendor,
+ const struct device *);
+DEFINE_FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_name,
+ const struct device *);
+DEFINE_FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_revision,
+ const struct device *);
+DEFINE_FAKE_VALUE_FUNC(int, cros_system_native_posix_soc_reset,
+ const struct device *);
+DEFINE_FAKE_VOID_FUNC(watchdog_reload);
+DEFINE_FAKE_VOID_FUNC(board_hibernate);
+
+static void system_before_after(void *test_data)
+{
+ const struct device *bbram_dev =
+ DEVICE_DT_GET_OR_NULL(DT_CHOSEN(cros_ec_bbram));
+
+ RESET_FAKE(cros_system_native_posix_get_reset_cause);
+ RESET_FAKE(cros_system_native_posix_deep_sleep_ticks);
+ RESET_FAKE(cros_system_native_posix_hibernate);
+ RESET_FAKE(cros_system_native_posix_get_chip_vendor);
+ RESET_FAKE(cros_system_native_posix_get_chip_name);
+ RESET_FAKE(cros_system_native_posix_get_chip_revision);
+ RESET_FAKE(cros_system_native_posix_soc_reset);
+ RESET_FAKE(watchdog_reload);
+ RESET_FAKE(board_hibernate);
+
+ if (bbram_dev != NULL) {
+ bbram_emul_set_invalid(bbram_dev, false);
+ }
+}
+
+ZTEST_SUITE(system, NULL, NULL, system_before_after, system_before_after, NULL);
diff --git a/zephyr/test/system_shim/src/test_system.c b/zephyr/test/system_shim/src/test_system.c
new file mode 100644
index 0000000000..56031a4b67
--- /dev/null
+++ b/zephyr/test/system_shim/src/test_system.c
@@ -0,0 +1,299 @@
+/* Copyright 2020 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "drivers/cros_system.h"
+#include "fakes.h"
+#include "system.h"
+
+#include <setjmp.h>
+
+#include <zephyr/device.h>
+#include <zephyr/drivers/bbram.h>
+#include <zephyr/fff.h>
+#include <zephyr/logging/log.h>
+#include <zephyr/shell/shell_dummy.h>
+#include <zephyr/ztest_assert.h>
+#include <zephyr/ztest_test_new.h>
+
+LOG_MODULE_REGISTER(test);
+
+#define BBRAM_REGION_OFF(name) \
+ DT_PROP(DT_PATH(named_bbram_regions, name), offset)
+#define BBRAM_REGION_SIZE(name) \
+ DT_PROP(DT_PATH(named_bbram_regions, name), size)
+
+static char mock_data[64] =
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@";
+
+int system_preinitialize(const struct device *unused);
+
+ZTEST(system, test_invalid_bbram_index)
+{
+ zassert_equal(EC_ERROR_INVAL,
+ system_get_bbram(SYSTEM_BBRAM_IDX_TRY_SLOT + 1, NULL));
+}
+
+ZTEST(system, test_bbram_get)
+{
+ const struct device *const bbram_dev =
+ DEVICE_DT_GET(DT_CHOSEN(cros_ec_bbram));
+ uint8_t output[10];
+ int rc;
+
+ /* Write expected data to read back */
+ rc = bbram_write(bbram_dev, 0, ARRAY_SIZE(mock_data), mock_data);
+ zassert_ok(rc);
+
+ rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD0, output);
+ zassert_ok(rc);
+ zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(pd0),
+ BBRAM_REGION_SIZE(pd0), NULL);
+
+ rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD1, output);
+ zassert_ok(rc);
+ zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(pd1),
+ BBRAM_REGION_SIZE(pd1), NULL);
+
+ rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD2, output);
+ zassert_ok(rc);
+ zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(pd2),
+ BBRAM_REGION_SIZE(pd2), NULL);
+
+ rc = system_get_bbram(SYSTEM_BBRAM_IDX_TRY_SLOT, output);
+ zassert_ok(rc);
+ zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(try_slot),
+ BBRAM_REGION_SIZE(try_slot), NULL);
+}
+
+ZTEST(system, test_save_read_chip_reset_flags)
+{
+ uint32_t arbitrary_flags = 0x1234;
+
+ chip_save_reset_flags(0);
+ chip_save_reset_flags(arbitrary_flags);
+ zassert_equal(chip_read_reset_flags(), arbitrary_flags);
+}
+
+ZTEST(system, test_system_set_get_scratchpad)
+{
+ /* Arbitrary values */
+ uint32_t scratch_set = 0x1234;
+ uint32_t scratch_read;
+
+ system_set_scratchpad(scratch_set);
+ system_get_scratchpad(&scratch_read);
+ zassert_equal(scratch_read, scratch_set);
+}
+
+ZTEST(system, test_system_get_scratchpad_fail)
+{
+ const struct device *bbram_dev =
+ DEVICE_DT_GET(DT_CHOSEN(cros_ec_bbram));
+
+ zassert_ok(bbram_emul_set_invalid(bbram_dev, true));
+ zassert_equal(-EC_ERROR_INVAL, system_get_scratchpad(NULL));
+}
+
+static jmp_buf jmp_hibernate;
+
+static int _test_cros_system_native_posix_hibernate(const struct device *dev,
+ uint32_t seconds,
+ uint32_t microseconds)
+{
+ longjmp(jmp_hibernate, 1);
+
+ return 0;
+}
+
+ZTEST(system, test_system_hibernate)
+{
+ /*
+ * Due to setjmp usage, this test provides no coverage, but does
+ * actually cover the code. This is due to a bug in LCOV.
+ */
+ const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
+ int ret = setjmp(jmp_hibernate);
+ /* Validate 0th and last bit preserved*/
+ uint32_t secs = BIT(31) + 1;
+ uint32_t msecs = BIT(31) + 3;
+
+ zassert_not_null(sys_dev);
+
+ cros_system_native_posix_hibernate_fake.custom_fake =
+ _test_cros_system_native_posix_hibernate;
+
+ if (ret == 0) {
+ system_hibernate(secs, msecs);
+ }
+
+ zassert_not_equal(ret, 0);
+
+ zassert_equal(cros_system_native_posix_hibernate_fake.call_count, 1);
+ zassert_equal(cros_system_native_posix_hibernate_fake.arg0_val,
+ sys_dev);
+ zassert_equal(cros_system_native_posix_hibernate_fake.arg1_val, secs);
+ zassert_equal(cros_system_native_posix_hibernate_fake.arg2_val, msecs);
+ zassert_equal(board_hibernate_fake.call_count, 1);
+}
+
+ZTEST(system, test_system_hibernate__failure)
+{
+ const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
+ /* Validate 0th and last bit preserved*/
+ uint32_t secs = BIT(31) + 1;
+ uint32_t msecs = BIT(31) + 3;
+
+ zassert_not_null(sys_dev);
+
+ cros_system_native_posix_hibernate_fake.return_val = -1;
+
+ system_hibernate(secs, msecs);
+
+ zassert_equal(cros_system_native_posix_hibernate_fake.call_count, 1);
+ zassert_equal(cros_system_native_posix_hibernate_fake.arg0_val,
+ sys_dev);
+ zassert_equal(cros_system_native_posix_hibernate_fake.arg1_val, secs);
+ zassert_equal(cros_system_native_posix_hibernate_fake.arg2_val, msecs);
+}
+
+ZTEST(system, test_system_get_chip_values)
+{
+ const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
+
+ zassert_not_null(sys_dev);
+
+ /* Vendor */
+ cros_system_native_posix_get_chip_vendor_fake.return_val = "a";
+ zassert_mem_equal(system_get_chip_vendor(), "a", sizeof("a"));
+ zassert_equal(cros_system_native_posix_get_chip_vendor_fake.call_count,
+ 1);
+ zassert_equal(cros_system_native_posix_get_chip_vendor_fake.arg0_val,
+ sys_dev);
+
+ /* Name */
+ cros_system_native_posix_get_chip_name_fake.return_val = "b";
+ zassert_mem_equal(system_get_chip_name(), "b", sizeof("b"));
+ zassert_equal(cros_system_native_posix_get_chip_name_fake.call_count,
+ 1);
+ zassert_equal(cros_system_native_posix_get_chip_name_fake.arg0_val,
+ sys_dev);
+
+ /* Revision */
+ cros_system_native_posix_get_chip_revision_fake.return_val = "c";
+ zassert_mem_equal(system_get_chip_revision(), "c", sizeof("c"));
+ zassert_equal(
+ cros_system_native_posix_get_chip_revision_fake.call_count, 1);
+ zassert_equal(cros_system_native_posix_get_chip_revision_fake.arg0_val,
+ sys_dev);
+}
+
+static int _test_cros_system_native_posix_soc_reset(const struct device *dev)
+{
+ printf("called from soc reset");
+ longjmp(jmp_hibernate, 1);
+
+ return 0;
+}
+
+ZTEST(system, test_system_reset)
+{
+ /*
+ * Despite using setjmp this test consistently covers the code under
+ * test. Context: https://github.com/llvm/llvm-project/issues/50119
+ */
+ const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
+ int ret = setjmp(jmp_hibernate);
+ uint32_t arbitrary_flags_w_reset_wait_ext = 0x1234 |
+ SYSTEM_RESET_WAIT_EXT;
+ uint32_t encoded_arbitrary_flags_w_reset_wait_ext;
+
+ system_encode_save_flags(arbitrary_flags_w_reset_wait_ext,
+ &encoded_arbitrary_flags_w_reset_wait_ext);
+
+ zassert_not_null(sys_dev);
+
+ cros_system_native_posix_soc_reset_fake.custom_fake =
+ _test_cros_system_native_posix_soc_reset;
+
+ if (ret == 0) {
+ system_reset(arbitrary_flags_w_reset_wait_ext);
+ }
+
+ zassert_not_null(sys_dev);
+
+ zassert_equal(chip_read_reset_flags(),
+ encoded_arbitrary_flags_w_reset_wait_ext);
+
+ zassert_equal(watchdog_reload_fake.call_count, 1000);
+ zassert_equal(cros_system_native_posix_soc_reset_fake.call_count, 1);
+ zassert_equal(cros_system_native_posix_soc_reset_fake.arg0_val,
+ sys_dev);
+}
+
+ZTEST_USER(system, test_system_console_cmd__idlestats)
+{
+ const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
+ const struct shell *shell_zephyr = get_ec_shell();
+ const char *outbuffer;
+ size_t buffer_size;
+
+ zassert_not_null(sys_dev);
+
+ shell_backend_dummy_clear_output(shell_zephyr);
+
+ k_sleep(K_SECONDS(1));
+ zassert_ok(shell_execute_cmd(shell_zephyr, "idlestats"), NULL);
+
+ /* Weakly verify contents */
+ outbuffer = shell_backend_dummy_get_output(shell_zephyr, &buffer_size);
+ zassert_not_equal(buffer_size, 0);
+ zassert_not_null(strstr(outbuffer, "Time spent in deep-sleep:"));
+ zassert_not_null(strstr(outbuffer, "Total time on:"));
+
+ zassert_equal(cros_system_native_posix_deep_sleep_ticks_fake.call_count,
+ 1);
+}
+
+ZTEST(system, test_init_invalid_reset_cause)
+{
+ cros_system_native_posix_get_reset_cause_fake.return_val = -1;
+ zassert_equal(-1, system_preinitialize(NULL));
+}
+
+ZTEST(system, test_init_cause_vcc1_rst_pin)
+{
+ cros_system_native_posix_get_reset_cause_fake.return_val = VCC1_RST_PIN;
+ chip_save_reset_flags(0);
+ system_clear_reset_flags(0xffffffff);
+
+ zassert_ok(system_preinitialize(NULL));
+ zassert_equal(EC_RESET_FLAG_RESET_PIN, system_get_reset_flags());
+
+ chip_save_reset_flags(EC_RESET_FLAG_INITIAL_PWR);
+ zassert_ok(system_preinitialize(NULL));
+ zassert_equal(EC_RESET_FLAG_RESET_PIN | EC_RESET_FLAG_POWER_ON |
+ EC_RESET_FLAG_POWER_ON,
+ system_get_reset_flags());
+}
+
+ZTEST(system, test_init_cause_debug_rst)
+{
+ cros_system_native_posix_get_reset_cause_fake.return_val = DEBUG_RST;
+ chip_save_reset_flags(0);
+ system_clear_reset_flags(0xffffffff);
+
+ zassert_ok(system_preinitialize(NULL));
+ zassert_equal(EC_RESET_FLAG_SOFT, system_get_reset_flags());
+}
+
+ZTEST(system, test_init_cause_watchdog_rst)
+{
+ cros_system_native_posix_get_reset_cause_fake.return_val = WATCHDOG_RST;
+ chip_save_reset_flags(0);
+ system_clear_reset_flags(0xffffffff);
+
+ zassert_ok(system_preinitialize(NULL));
+ zassert_equal(EC_RESET_FLAG_WATCHDOG, system_get_reset_flags());
+}
diff --git a/zephyr/test/system_shim/test_system.c b/zephyr/test/system_shim/test_system.c
deleted file mode 100644
index 3bf43d6669..0000000000
--- a/zephyr/test/system_shim/test_system.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/* Copyright 2020 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <setjmp.h>
-#include <zephyr/device.h>
-#include <zephyr/drivers/bbram.h>
-#include <zephyr/fff.h>
-#include <zephyr/logging/log.h>
-#include <zephyr/shell/shell_dummy.h>
-#include <zephyr/ztest_assert.h>
-#include <zephyr/ztest_test_new.h>
-
-#include "system.h"
-
-LOG_MODULE_REGISTER(test);
-
-#define BBRAM_REGION_OFF(name) \
- DT_PROP(DT_PATH(named_bbram_regions, name), offset)
-#define BBRAM_REGION_SIZE(name) \
- DT_PROP(DT_PATH(named_bbram_regions, name), size)
-
-static char mock_data[64] =
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@";
-
-FAKE_VALUE_FUNC(uint64_t, cros_system_native_posix_deep_sleep_ticks,
- const struct device *);
-FAKE_VALUE_FUNC(int, cros_system_native_posix_hibernate, const struct device *,
- uint32_t, uint32_t);
-FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_vendor,
- const struct device *);
-FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_name,
- const struct device *);
-FAKE_VALUE_FUNC(const char *, cros_system_native_posix_get_chip_revision,
- const struct device *);
-FAKE_VALUE_FUNC(int, cros_system_native_posix_soc_reset, const struct device *);
-FAKE_VOID_FUNC(watchdog_reload);
-
-static void system_before_after(void *test_data)
-{
- RESET_FAKE(cros_system_native_posix_deep_sleep_ticks);
- RESET_FAKE(cros_system_native_posix_hibernate);
-}
-
-ZTEST_SUITE(system, NULL, NULL, system_before_after, system_before_after, NULL);
-
-ZTEST(system, test_bbram_get)
-{
- const struct device *const bbram_dev =
- DEVICE_DT_GET(DT_CHOSEN(cros_ec_bbram));
- uint8_t output[10];
- int rc;
-
- /* Write expected data to read back */
- rc = bbram_write(bbram_dev, 0, ARRAY_SIZE(mock_data), mock_data);
- zassert_ok(rc);
-
- rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD0, output);
- zassert_ok(rc);
- zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(pd0),
- BBRAM_REGION_SIZE(pd0), NULL);
-
- rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD1, output);
- zassert_ok(rc);
- zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(pd1),
- BBRAM_REGION_SIZE(pd1), NULL);
-
- rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD2, output);
- zassert_ok(rc);
- zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(pd2),
- BBRAM_REGION_SIZE(pd2), NULL);
-
- rc = system_get_bbram(SYSTEM_BBRAM_IDX_TRY_SLOT, output);
- zassert_ok(rc);
- zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(try_slot),
- BBRAM_REGION_SIZE(try_slot), NULL);
-}
-
-ZTEST(system, test_save_read_chip_reset_flags)
-{
- uint32_t arbitrary_flags = 0x1234;
-
- chip_save_reset_flags(0);
- chip_save_reset_flags(arbitrary_flags);
- zassert_equal(chip_read_reset_flags(), arbitrary_flags);
-}
-
-ZTEST(system, test_system_set_get_scratchpad)
-{
- /* Arbitrary values */
- uint32_t scratch_set = 0x1234;
- uint32_t scratch_read;
-
- system_set_scratchpad(scratch_set);
- system_get_scratchpad(&scratch_read);
- zassert_equal(scratch_read, scratch_set);
-}
-
-static jmp_buf jmp_hibernate;
-
-static int _test_cros_system_native_posix_hibernate(const struct device *dev,
- uint32_t seconds,
- uint32_t microseconds)
-{
- longjmp(jmp_hibernate, 1);
-
- return 0;
-}
-
-ZTEST(system, test_system_hibernate)
-{
- /*
- * Due to setjmp usage, this test provides no coverage, but does
- * actually cover the code. This is due to a bug in LCOV.
- */
- const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
- int ret = setjmp(jmp_hibernate);
- /* Validate 0th and last bit preserved*/
- uint32_t secs = BIT(31) + 1;
- uint32_t msecs = BIT(31) + 3;
-
- zassert_not_null(sys_dev);
-
- cros_system_native_posix_hibernate_fake.custom_fake =
- _test_cros_system_native_posix_hibernate;
-
- if (ret == 0) {
- system_hibernate(secs, msecs);
- }
-
- zassert_not_equal(ret, 0);
-
- zassert_equal(cros_system_native_posix_hibernate_fake.call_count, 1);
- zassert_equal(cros_system_native_posix_hibernate_fake.arg0_val,
- sys_dev);
- zassert_equal(cros_system_native_posix_hibernate_fake.arg1_val, secs);
- zassert_equal(cros_system_native_posix_hibernate_fake.arg2_val, msecs);
-}
-
-ZTEST(system, test_system_hibernate__failure)
-{
- const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
- /* Validate 0th and last bit preserved*/
- uint32_t secs = BIT(31) + 1;
- uint32_t msecs = BIT(31) + 3;
-
- zassert_not_null(sys_dev);
-
- cros_system_native_posix_hibernate_fake.return_val = -1;
-
- system_hibernate(secs, msecs);
-
- zassert_equal(cros_system_native_posix_hibernate_fake.call_count, 1);
- zassert_equal(cros_system_native_posix_hibernate_fake.arg0_val,
- sys_dev);
- zassert_equal(cros_system_native_posix_hibernate_fake.arg1_val, secs);
- zassert_equal(cros_system_native_posix_hibernate_fake.arg2_val, msecs);
-}
-
-ZTEST(system, test_system_get_chip_values)
-{
- const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
-
- zassert_not_null(sys_dev);
-
- /* Vendor */
- cros_system_native_posix_get_chip_vendor_fake.return_val = "a";
- zassert_mem_equal(system_get_chip_vendor(), "a", sizeof("a"));
- zassert_equal(cros_system_native_posix_get_chip_vendor_fake.call_count,
- 1);
- zassert_equal(cros_system_native_posix_get_chip_vendor_fake.arg0_val,
- sys_dev);
-
- /* Name */
- cros_system_native_posix_get_chip_name_fake.return_val = "b";
- zassert_mem_equal(system_get_chip_name(), "b", sizeof("b"));
- zassert_equal(cros_system_native_posix_get_chip_name_fake.call_count,
- 1);
- zassert_equal(cros_system_native_posix_get_chip_name_fake.arg0_val,
- sys_dev);
-
- /* Revision */
- cros_system_native_posix_get_chip_revision_fake.return_val = "c";
- zassert_mem_equal(system_get_chip_revision(), "c", sizeof("c"));
- zassert_equal(
- cros_system_native_posix_get_chip_revision_fake.call_count, 1);
- zassert_equal(cros_system_native_posix_get_chip_revision_fake.arg0_val,
- sys_dev);
-}
-
-static int _test_cros_system_native_posix_soc_reset(const struct device *dev)
-{
- printf("called from soc reset");
- longjmp(jmp_hibernate, 1);
-
- return 0;
-}
-
-ZTEST(system, test_system_reset)
-{
- /*
- * Despite using setjmp this test consistently covers the code under
- * test. Context: https://github.com/llvm/llvm-project/issues/50119
- */
- const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
- int ret = setjmp(jmp_hibernate);
- uint32_t arbitrary_flags_w_reset_wait_ext = 0x1234 |
- SYSTEM_RESET_WAIT_EXT;
- uint32_t encoded_arbitrary_flags_w_reset_wait_ext;
-
- system_encode_save_flags(arbitrary_flags_w_reset_wait_ext,
- &encoded_arbitrary_flags_w_reset_wait_ext);
-
- zassert_not_null(sys_dev);
-
- cros_system_native_posix_soc_reset_fake.custom_fake =
- _test_cros_system_native_posix_soc_reset;
-
- if (ret == 0) {
- system_reset(arbitrary_flags_w_reset_wait_ext);
- }
-
- zassert_not_null(sys_dev);
-
- zassert_equal(chip_read_reset_flags(),
- encoded_arbitrary_flags_w_reset_wait_ext);
-
- zassert_equal(watchdog_reload_fake.call_count, 1000);
- zassert_equal(cros_system_native_posix_soc_reset_fake.call_count, 1);
- zassert_equal(cros_system_native_posix_soc_reset_fake.arg0_val,
- sys_dev);
-}
-
-ZTEST_USER(system, test_system_console_cmd__idlestats)
-{
- const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
- const struct shell *shell_zephyr = get_ec_shell();
- const char *outbuffer;
- size_t buffer_size;
-
- zassert_not_null(sys_dev);
-
- shell_backend_dummy_clear_output(shell_zephyr);
-
- k_sleep(K_SECONDS(1));
- zassert_ok(shell_execute_cmd(shell_zephyr, "idlestats"), NULL);
-
- /* Weakly verify contents */
- outbuffer = shell_backend_dummy_get_output(shell_zephyr, &buffer_size);
- zassert_not_equal(buffer_size, 0);
- zassert_not_null(strstr(outbuffer, "Time spent in deep-sleep:"));
- zassert_not_null(strstr(outbuffer, "Total time on:"));
-
- zassert_equal(cros_system_native_posix_deep_sleep_ticks_fake.call_count,
- 1);
-}
diff --git a/zephyr/test/system_shim/testcase.yaml b/zephyr/test/system_shim/testcase.yaml
index 3374c7f5f3..29b5fa55c0 100644
--- a/zephyr/test/system_shim/testcase.yaml
+++ b/zephyr/test/system_shim/testcase.yaml
@@ -1,15 +1,8 @@
common:
platform_allow: native_posix
+ tags:
+ system
tests:
system_shim.default:
- tags:
- system
- extra_configs:
- # Make console work
- - CONFIG_SERIAL=y
- - CONFIG_SHELL_BACKEND_DUMMY=y
- - CONFIG_SHELL_BACKEND_DUMMY_BUF_SIZE=1000
- - CONFIG_SHELL_BACKEND_SERIAL=n
- # Make cros_system driver work
- - CONFIG_PM=y
- - CONFIG_CROS_SYSTEM_NATIVE_POSIX=y
+ extra_args: DTC_OVERLAY_FILE="./default.overlay"
+ system_shim.no_chosen: {}
diff --git a/zephyr/test/tasks/main.c b/zephyr/test/tasks/main.c
index 8bfe9eb602..bbf752c656 100644
--- a/zephyr/test/tasks/main.c
+++ b/zephyr/test/tasks/main.c
@@ -3,14 +3,15 @@
* found in the LICENSE file.
*/
-#include <zephyr/kernel.h>
-#include <stdbool.h>
-#include <zephyr/ztest.h>
-
#include "ec_tasks.h"
#include "task.h"
#include "timer.h"
+#include <stdbool.h>
+
+#include <zephyr/kernel.h>
+#include <zephyr/ztest.h>
+
/* Second for platform/ec task API (in microseconds). */
#define TASK_SEC(s) (s * 1000 * 1000)
diff --git a/zephyr/test/test_utils/tasks_fakes.c b/zephyr/test/test_utils/tasks_fakes.c
index b4068afa21..d688c6cc24 100644
--- a/zephyr/test/test_utils/tasks_fakes.c
+++ b/zephyr/test/test_utils/tasks_fakes.c
@@ -3,10 +3,11 @@
* found in the LICENSE file.
*/
-#include <zephyr/sys/atomic.h>
-#include <zephyr/fff.h>
#include "task_id.h"
+#include <zephyr/fff.h>
+#include <zephyr/sys/atomic.h>
+
/*
* The fakes below are needed to satisfy the final link, but are never
* actually called at runtime. Exclude from the coverage report to avoid
diff --git a/zephyr/test/uart_printf/CMakeLists.txt b/zephyr/test/uart_printf/CMakeLists.txt
new file mode 100644
index 0000000000..8844bfb7be
--- /dev/null
+++ b/zephyr/test/uart_printf/CMakeLists.txt
@@ -0,0 +1,20 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+cmake_minimum_required(VERSION 3.20.0)
+
+find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
+project(uart_printf)
+
+target_sources(testbinary
+ PRIVATE
+ ../../../common/uart_printf.c
+ src/fakes.cc
+ src/main.cc
+)
+
+target_include_directories(testbinary
+ PRIVATE
+ include
+)
diff --git a/zephyr/test/uart_printf/include/common.h b/zephyr/test/uart_printf/include/common.h
new file mode 100644
index 0000000000..79af9594b3
--- /dev/null
+++ b/zephyr/test/uart_printf/include/common.h
@@ -0,0 +1,12 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_
+#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_
+
+#define EC_SUCCESS 0
+#define EC_ERROR_OVERFLOW -1
+
+#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_ */
diff --git a/zephyr/test/uart_printf/include/printf.h b/zephyr/test/uart_printf/include/printf.h
new file mode 100644
index 0000000000..b6fcf6337d
--- /dev/null
+++ b/zephyr/test/uart_printf/include/printf.h
@@ -0,0 +1,23 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_
+#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_
+
+#include <zephyr/fff.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int (*vfnprintf_addchar_t)(void *, int);
+DECLARE_FAKE_VALUE_FUNC(int, vfnprintf, vfnprintf_addchar_t, void *,
+ const char *, va_list);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_ */
diff --git a/zephyr/test/uart_printf/include/uart.h b/zephyr/test/uart_printf/include/uart.h
new file mode 100644
index 0000000000..51fd42a17e
--- /dev/null
+++ b/zephyr/test/uart_printf/include/uart.h
@@ -0,0 +1,28 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_
+#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_
+
+#include <zephyr/fff.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int uart_putc(int c);
+int uart_puts(const char *outstr);
+int uart_put(const char *out, int len);
+int uart_put_raw(const char *out, int len);
+int uart_printf(const char *format, ...);
+
+DECLARE_FAKE_VALUE_FUNC(int, uart_tx_char_raw, void *, int);
+DECLARE_FAKE_VOID_FUNC(uart_tx_start);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_ */
diff --git a/zephyr/test/uart_printf/prj.conf b/zephyr/test/uart_printf/prj.conf
new file mode 100644
index 0000000000..744afcce87
--- /dev/null
+++ b/zephyr/test/uart_printf/prj.conf
@@ -0,0 +1,9 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+CONFIG_ZTEST=y
+CONFIG_ZTEST_NEW_API=y
+CONFIG_CPLUSPLUS=y
+CONFIG_STD_CPP20=y
+CONFIG_LIB_CPLUSPLUS=y
diff --git a/zephyr/test/uart_printf/src/fakes.cc b/zephyr/test/uart_printf/src/fakes.cc
new file mode 100644
index 0000000000..0bb5fea1eb
--- /dev/null
+++ b/zephyr/test/uart_printf/src/fakes.cc
@@ -0,0 +1,36 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <zephyr/fff.h>
+#include <zephyr/ztest.h>
+
+#include "printf.h"
+#include "uart.h"
+
+DEFINE_FFF_GLOBALS;
+
+/* printf.h */
+DEFINE_FAKE_VALUE_FUNC(int, vfnprintf, vfnprintf_addchar_t, void *,
+ const char *, va_list);
+
+/* uart.h */
+DEFINE_FAKE_VALUE_FUNC(int, uart_tx_char_raw, void *, int);
+DEFINE_FAKE_VOID_FUNC(uart_tx_start);
+
+static void fake_reset_rule_before(const struct ztest_unit_test *test,
+ void *data)
+{
+ ARG_UNUSED(test);
+ ARG_UNUSED(data);
+
+ /* printf.h */
+ RESET_FAKE(vfnprintf);
+
+ /* uart.h */
+ RESET_FAKE(uart_tx_char_raw);
+ RESET_FAKE(uart_tx_start);
+}
+
+ZTEST_RULE(fake_reset, fake_reset_rule_before, nullptr);
diff --git a/zephyr/test/uart_printf/src/main.cc b/zephyr/test/uart_printf/src/main.cc
new file mode 100644
index 0000000000..9feb6a7ae9
--- /dev/null
+++ b/zephyr/test/uart_printf/src/main.cc
@@ -0,0 +1,101 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include <cstring>
+#include <string>
+
+#include <zephyr/ztest.h>
+
+#include "common.h"
+#include "printf.h"
+#include "uart.h"
+
+ZTEST_SUITE(uart_printf, nullptr, nullptr, nullptr, nullptr, nullptr);
+
+ZTEST(uart_printf, test_uart_putc)
+{
+ int return_vals[] = { 0, -1 };
+
+ SET_RETURN_SEQ(uart_tx_char_raw, return_vals, 2);
+
+ zassert_ok(uart_putc(5));
+ zassert_equal(EC_ERROR_OVERFLOW, uart_putc(5));
+}
+
+ZTEST(uart_printf, test_uart_put_success)
+{
+ const std::string test_string = "test string";
+ std::string output_string;
+
+ /* Print the whole string */
+ zassert_equal(test_string.size(),
+ static_cast<size_t>(uart_put(test_string.c_str(),
+ test_string.size())));
+ zassert_equal(test_string.size(), uart_tx_char_raw_fake.call_count);
+
+ /* Copy the history so it's easier to assert */
+ for (size_t i = 0; i < test_string.size(); ++i) {
+ output_string += uart_tx_char_raw_fake.arg1_history[i];
+ }
+
+ /* Verify that the string was passed to uart_tx_char_raw() */
+ zassert_equal(test_string, output_string);
+}
+
+ZTEST(uart_printf, test_uart_put_fail_tx)
+{
+ const char test_string[] = "\n";
+
+ uart_tx_char_raw_fake.return_val = -1;
+
+ /* Try printing the newline */
+ zassert_equal(0, uart_put(test_string, 1));
+ zassert_equal(1, uart_tx_char_raw_fake.call_count);
+ zassert_equal('\r', uart_tx_char_raw_fake.arg1_val);
+}
+
+ZTEST(uart_printf, test_uart_puts_fail_tx)
+{
+ const char test_string[] = "\n\0";
+
+ uart_tx_char_raw_fake.return_val = -1;
+
+ /* Try printing the newline */
+ zassert_equal(EC_ERROR_OVERFLOW, uart_puts(test_string));
+ zassert_equal(1, uart_tx_char_raw_fake.call_count);
+ zassert_equal('\r', uart_tx_char_raw_fake.arg1_val);
+}
+
+ZTEST(uart_printf, test_uart_put_raw_fail_tx)
+{
+ const char test_string[] = "\n";
+
+ uart_tx_char_raw_fake.return_val = -1;
+
+ /* Try printing the newline */
+ zassert_equal(0, uart_put_raw(test_string, 1));
+ zassert_equal(1, uart_tx_char_raw_fake.call_count);
+ zassert_equal('\n', uart_tx_char_raw_fake.arg1_val);
+}
+
+static int vfnprintf_custom_fake_expect_int_arg;
+static int vfnprintf_custom_fake(vfnprintf_addchar_t, void *, const char *,
+ va_list alist)
+{
+ zassert_equal(vfnprintf_custom_fake_expect_int_arg, va_arg(alist, int));
+ return 0;
+}
+ZTEST(uart_printf, test_uart_printf)
+{
+ const char test_format[] = "d=%d";
+
+ vfnprintf_custom_fake_expect_int_arg = 5;
+ vfnprintf_fake.custom_fake = vfnprintf_custom_fake;
+
+ zassert_ok(
+ uart_printf(test_format, vfnprintf_custom_fake_expect_int_arg));
+ zassert_equal(1, vfnprintf_fake.call_count);
+ zassert_equal(test_format, vfnprintf_fake.arg2_val);
+}
diff --git a/zephyr/test/uart_printf/testcase.yaml b/zephyr/test/uart_printf/testcase.yaml
new file mode 100644
index 0000000000..0315abab6f
--- /dev/null
+++ b/zephyr/test/uart_printf/testcase.yaml
@@ -0,0 +1,8 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+tests:
+ uart.printf:
+ tags: uart
+ type: unit
diff --git a/zephyr/test/vboot_efs2/boards/native_posix.overlay b/zephyr/test/vboot_efs2/boards/native_posix.overlay
index ced94c28b1..83b9e9b365 100644
--- a/zephyr/test/vboot_efs2/boards/native_posix.overlay
+++ b/zephyr/test/vboot_efs2/boards/native_posix.overlay
@@ -59,8 +59,18 @@
port0@0 {
compatible = "named-usbc-port";
reg = <0>;
+ bc12 = <&pi3usb9201_emul>;
chg = <&isl923x_emul>;
tcpc = <&tcpci_emul>;
+ usb-mux-chain-1 {
+ compatible = "cros-ec,usb-mux-chain";
+ usb-muxes = <&tcpci_mux_c0>;
+ };
+ };
+ port0-muxes {
+ tcpci_mux_c0: tcpci-mux-c0 {
+ compatible = "cros-ec,usbc-mux-tcpci";
+ };
};
};
i2c2: i2c@500 {
@@ -71,6 +81,10 @@
#size-cells = <0>;
reg = <0x500 4>;
+ pi3usb9201_emul: pi3usb9201@5f {
+ compatible = "pericom,pi3usb9201";
+ reg = <0x5f>;
+ };
tcpci_emul: tcpci_emul@82 {
compatible = "cros,tcpci-generic-emul";
status = "okay";
@@ -112,7 +126,7 @@
&i2c0 {
battery: sb@b {
- compatible = "zephyr,smart-battery";
+ compatible = "zephyr,smart-battery-emul";
reg = <0xb>;
cycle-count = <99>;
version = "BATTERY_SPEC_VER_1_1_WITH_PEC";
diff --git a/zephyr/test/vboot_efs2/prj.conf b/zephyr/test/vboot_efs2/prj.conf
index f085fa8f73..0b894dd082 100644
--- a/zephyr/test/vboot_efs2/prj.conf
+++ b/zephyr/test/vboot_efs2/prj.conf
@@ -2,22 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-CONFIG_ADC=y
-CONFIG_ADC_EMUL=y
CONFIG_CROS_EC=y
-CONFIG_EMUL_CROS_FLASH=y
-CONFIG_EMUL_SMART_BATTERY=y
-CONFIG_EMUL_TCPCI=y
CONFIG_FLASH=y
-CONFIG_I2C=y
-CONFIG_I2C_EMUL=y
CONFIG_PLATFORM_EC=y
CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-CONFIG_PLATFORM_EC_BATTERY=y
CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y
CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
CONFIG_PLATFORM_EC_BATTERY_SMART=y
-CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
+CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=y
CONFIG_PLATFORM_EC_CHARGER_ISL9238=y
CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10
diff --git a/zephyr/test/vboot_efs2/src/main.c b/zephyr/test/vboot_efs2/src/main.c
index 1558fb75f0..6fb9e8ba02 100644
--- a/zephyr/test/vboot_efs2/src/main.c
+++ b/zephyr/test/vboot_efs2/src/main.c
@@ -14,8 +14,8 @@
#include "usb_mux.h"
#include "usbc_ppc.h"
#include "vboot.h"
-
#include "zephyr/devicetree.h"
+
#include <stdint.h>
#include <zephyr/drivers/gpio/gpio_emul.h>
@@ -372,8 +372,8 @@ int board_set_active_charge_port(int port)
return EC_ERROR_INVAL;
}
-void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma,
- int charge_mv)
+__override void board_set_charge_limit(int port, int supplier, int charge_ma,
+ int max_ma, int charge_mv)
{
}
@@ -393,25 +393,6 @@ int pd_set_power_supply_ready(int port)
enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_COUNT };
-/* BC1.2 charger detect configuration */
-const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = {
- [USBC_PORT_C0] = {
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
- },
-};
-
-struct usb_mux_chain usb_muxes[] = {
- [USBC_PORT_C0] = {
- .mux = &(struct usb_mux) {
- .usb_port = USBC_PORT_C0,
- .driver = &tcpci_tcpm_usb_mux_driver,
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = DT_REG_ADDR(DT_NODELABEL(tcpci_emul)),
- },
- },
-};
-
/* USBC PPC configuration */
struct ppc_config_t ppc_chips[] = {
[USBC_PORT_C0] = {
diff --git a/zephyr/zmake/tests/test_jobserver.py b/zephyr/zmake/tests/test_jobserver.py
new file mode 100644
index 0000000000..a79e6dc280
--- /dev/null
+++ b/zephyr/zmake/tests/test_jobserver.py
@@ -0,0 +1,201 @@
+# Copyright 2022 The ChromiumOS Authors
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Test jobserver functionality."""
+
+import logging
+import os
+import threading
+from asyncio import subprocess
+
+import pytest # pylint:disable=import-error
+import zmake.jobserver
+
+
+def _do_test_jobserver(
+ jobs, commandline_jobs=0, use_client=False, open_pipe=True
+):
+ """Test a jobserver configured with a specified number of jobs."""
+
+ effective_jobs = jobs
+ pipe = None
+ if use_client:
+ makeflags = f" -j{jobs}"
+ if jobs > 1:
+ pipe = os.pipe()
+ # GNU make puts one less job in the pipe than allowed, since you
+ # get one job "for free" without contacting the jobserver. Or
+ # another way of looking at is that make consumes one slot for you
+ # before calling your job just in case you aren't jobserver aware.
+ os.write(pipe[1], b"A" * (jobs - 1))
+ os.set_inheritable(pipe[0], True)
+ os.set_inheritable(pipe[1], True)
+ makeflags += f" --jobserver-auth={pipe[0]},{pipe[1]}"
+ if not open_pipe:
+ os.close(pipe[0])
+ os.close(pipe[1])
+ effective_jobs = 1
+ jobserver = zmake.jobserver.GNUMakeJobClient.from_environ(
+ env={"MAKEFLAGS": makeflags}, jobs=commandline_jobs
+ )
+ else:
+ jobserver = zmake.jobserver.GNUMakeJobServer(jobs=jobs)
+ pipe = jobserver._inheritable_pipe # pylint:disable=protected-access
+ if jobs == 1:
+ makeflags = " -j1"
+ else:
+ makeflags = f" -j{jobs} --jobserver-auth={pipe[0]},{pipe[1]}"
+
+ lock = threading.Condition()
+ started_threads = 0
+ ended_threads = 0
+ active_threads = 0
+ please_exit = threading.Semaphore(0)
+ thread_count = jobs + 5
+ if commandline_jobs:
+ effective_jobs = commandline_jobs
+
+ def _my_thread():
+ nonlocal started_threads
+ nonlocal active_threads
+ nonlocal ended_threads
+ nonlocal pipe
+
+ with lock:
+ started_threads += 1
+ lock.notify_all()
+ with jobserver.get_job():
+ with lock:
+ active_threads += 1
+ lock.notify_all()
+ proc = jobserver.popen(
+ [
+ "sh",
+ "-c",
+ 'echo "MAKEFLAGS=${MAKEFLAGS}"; ls /proc/self/fd',
+ ],
+ stdout=subprocess.PIPE,
+ universal_newlines=True,
+ )
+ proc.wait()
+ output = proc.stdout.readlines()
+ assert output[0] == f"MAKEFLAGS={makeflags}\n"
+ if pipe:
+ if effective_jobs > 1:
+ assert f"{pipe[0]}\n" in output
+ assert f"{pipe[1]}\n" in output
+ else:
+ assert f"{pipe[0]}\n" not in output
+ assert f"{pipe[1]}\n" not in output
+
+ please_exit.acquire() # pylint:disable=consider-using-with
+ with lock:
+ active_threads -= 1
+ ended_threads += 1
+ lock.notify_all()
+
+ logging.debug("Starting %s threads", thread_count)
+ for _ in range(thread_count):
+ threading.Thread(target=_my_thread, daemon=True).start()
+
+ with lock:
+ lock.wait_for(
+ lambda: started_threads == thread_count
+ and active_threads == effective_jobs,
+ 10,
+ )
+ logging.debug("Asserting %s active_threads", effective_jobs)
+ assert started_threads == thread_count
+ assert active_threads == effective_jobs
+ assert ended_threads == 0
+
+ logging.debug("Ending %s threads", 5)
+ for _ in range(5):
+ please_exit.release()
+
+ with lock:
+ lock.wait_for(
+ lambda: active_threads == effective_jobs and ended_threads == 5, 10
+ )
+ logging.debug("Asserting %s active_threads", effective_jobs)
+ assert started_threads == thread_count
+ assert active_threads == effective_jobs
+ assert ended_threads == 5
+
+ logging.debug("Ending %s threads", thread_count - 5)
+ for _ in range(thread_count - 5):
+ please_exit.release()
+
+ with lock:
+ lock.wait_for(lambda: ended_threads == thread_count, 10)
+ logging.debug("Asserting %s active_threads", 0)
+ assert started_threads == thread_count
+ assert active_threads == 0
+ assert ended_threads == thread_count
+
+
+def test_jobserver_10():
+ """Test a jobserver configured with 10 jobs."""
+ _do_test_jobserver(10)
+
+
+def test_jobserver_2():
+ """Test a jobserver configured with 2 jobs."""
+ _do_test_jobserver(2)
+
+
+def test_jobserver_1():
+ """Test a jobserver configured with 1 job."""
+ _do_test_jobserver(1)
+
+
+def test_jobclient_10():
+ """Test a jobclient configured with 10 jobs."""
+ _do_test_jobserver(10, use_client=True)
+
+
+def test_jobclient_2():
+ """Test a jobserver configured with 2 jobs."""
+ _do_test_jobserver(2, use_client=True)
+
+
+def test_jobclient_1():
+ """Test a jobserver configured with 1 job."""
+ _do_test_jobserver(1, use_client=True)
+
+
+def test_jobclient_10_j1():
+ """Test a jobclient configured with 10 jobs but zmake -j1 was called."""
+ _do_test_jobserver(10, commandline_jobs=1, use_client=True)
+
+
+def test_jobclient_1_j1():
+ """Test a jobserver configured with 1 job but zmake -j1 was called."""
+ _do_test_jobserver(1, commandline_jobs=1, use_client=True)
+
+
+def test_jobclient_missing():
+ """Test a jobclient with no MAKEFLAGS."""
+ jobserver = zmake.jobserver.GNUMakeJobClient.from_environ(env={})
+ assert jobserver is None
+
+
+def test_jobclient_dryrun():
+ """Test a jobclient make dryrun in MAKEFLAGS."""
+ with pytest.raises(SystemExit) as pytest_wrapped_e:
+ zmake.jobserver.GNUMakeJobClient.from_environ(
+ env={"MAKEFLAGS": "n -j1"}
+ )
+ assert pytest_wrapped_e.type == SystemExit
+ assert pytest_wrapped_e.value.code == 0
+
+
+def test_jobclient_10_no_pipes():
+ """Test a jobclient configured with 10 jobs but the file descriptors are missing."""
+ _do_test_jobserver(10, use_client=True, open_pipe=False)
+
+
+def test_jobclient_1_no_pipes():
+ """Test a jobclient configured with 1 job but the file descriptors are missing."""
+ _do_test_jobserver(1, use_client=True, open_pipe=False)
diff --git a/zephyr/zmake/zmake/__main__.py b/zephyr/zmake/zmake/__main__.py
index 23fb58eca6..2b7358d1f1 100644
--- a/zephyr/zmake/zmake/__main__.py
+++ b/zephyr/zmake/zmake/__main__.py
@@ -10,6 +10,7 @@ import os
import pathlib
import sys
+import zmake.jobserver as jobserver
import zmake.multiproc as multiproc
import zmake.zmake as zm
@@ -63,7 +64,7 @@ def maybe_reexec(argv):
os.execve(sys.executable, [sys.executable, "-m", "zmake", *argv], env)
-def call_with_namespace(func, namespace):
+def call_with_namespace(func, namespace, **kwds):
"""Call a function with arguments applied from a Namespace.
Args:
@@ -73,7 +74,6 @@ def call_with_namespace(func, namespace):
Returns:
The result of calling the callable.
"""
- kwds = {}
sig = inspect.signature(func)
names = [p.name for p in sig.parameters.values()]
for name, value in vars(namespace).items():
@@ -392,8 +392,11 @@ def main(argv=None):
multiproc.LOG_JOB_NAMES = False
logging.basicConfig(format=log_format, level=opts.log_level)
+ # Create the jobserver client BEFORE any pipes get opened in LogWriter
+ jobserver_client = jobserver.GNUMakeJobClient.from_environ(jobs=opts.jobs)
+ multiproc.LogWriter.reset()
- zmake = call_with_namespace(zm.Zmake, opts)
+ zmake = call_with_namespace(zm.Zmake, opts, jobserver=jobserver_client)
try:
subcommand_method = getattr(zmake, opts.subcommand.replace("-", "_"))
result = call_with_namespace(subcommand_method, opts)
diff --git a/zephyr/zmake/zmake/jobserver.py b/zephyr/zmake/zmake/jobserver.py
index a3d6287da2..c1c9538b35 100644
--- a/zephyr/zmake/zmake/jobserver.py
+++ b/zephyr/zmake/zmake/jobserver.py
@@ -3,13 +3,17 @@
# found in the LICENSE file.
"""Module for job counters, limiting the amount of concurrent executions."""
+import fcntl
+import functools
import logging
import multiprocessing
import os
import re
import select
+import selectors
import shlex
import subprocess
+import sys
import zmake
@@ -26,7 +30,8 @@ class JobHandle:
pass
def __exit__(self, exc_type, exc_value, traceback):
- self.release_func(*self.args, **self.kwargs)
+ if self.release_func:
+ self.release_func(*self.args, **self.kwargs)
class JobClient:
@@ -41,6 +46,16 @@ class JobClient:
"""Get the environment variables necessary to share the job server."""
return {}
+ @staticmethod
+ def is_sequential():
+ """Returns True if the jobserver is using -j1."""
+ return False
+
+ @staticmethod
+ def pass_fds():
+ """Returns the file descriptors that should be passed to subprocesses."""
+ return []
+
def popen(self, argv, **kwargs):
"""Start a process using subprocess.Popen
@@ -53,7 +68,9 @@ class JobClient:
# the bare minimum (PATH only). This prevents us from building obscure
# dependencies on the environment variables.
kwargs.setdefault("env", {"PATH": "/bin:/usr/bin"})
+ kwargs.setdefault("pass_fds", [])
kwargs["env"].update(self.env())
+ kwargs["pass_fds"] += self.pass_fds()
logger = logging.getLogger(self.__class__.__name__)
logger.debug(
@@ -62,17 +79,53 @@ class JobClient:
" " if kwargs["env"] else "",
zmake.util.repr_command(argv),
)
- return subprocess.Popen(argv, **kwargs)
+ return subprocess.Popen( # pylint:disable=consider-using-with
+ argv, **kwargs
+ )
class GNUMakeJobClient(JobClient):
- """A job client for GNU make."""
+ """A job client for GNU make.
- def __init__(self, read_fd, write_fd):
- self._pipe = [read_fd, write_fd]
+ A client of jobserver is allowed to run 1 job without contacting the
+ jobserver, so maintain an optional self._internal_pipe to hold that
+ job.
+ """
+
+ def __init__(self, inheritable_pipe, jobs, internal_jobs=0, makeflags=None):
+ self._makeflags = makeflags
+ self._inheritable_pipe = inheritable_pipe
+ self.jobs = jobs
+ self._selector = selectors.DefaultSelector()
+ if internal_jobs:
+ self._internal_pipe = os.pipe()
+ os.write(self._internal_pipe[1], b"+" * internal_jobs)
+ os.set_blocking(self._internal_pipe[0], False)
+ self._selector.register(
+ self._internal_pipe[0],
+ selectors.EVENT_READ,
+ self._internal_pipe[1],
+ )
+ else:
+ self._internal_pipe = None
+ if self._inheritable_pipe is not None:
+ os.set_blocking(self._inheritable_pipe[0], False)
+ self._selector.register(
+ self._inheritable_pipe[0],
+ selectors.EVENT_READ,
+ self._inheritable_pipe[1],
+ )
+
+ def __del__(self):
+ if self._inheritable_pipe:
+ os.close(self._inheritable_pipe[0])
+ os.close(self._inheritable_pipe[1])
+ if self._internal_pipe:
+ os.close(self._internal_pipe[0])
+ os.close(self._internal_pipe[1])
@classmethod
- def from_environ(cls, env=None):
+ def from_environ(cls, env=None, jobs=0):
"""Create a job client from an environment with the MAKEFLAGS variable.
If we are started under a GNU Make Job Server, we can search
@@ -81,22 +134,57 @@ class GNUMakeJobClient(JobClient):
respectively. If we don't find this environment variable (or
the string inside of it), this will raise an OSError.
+ The specification for MAKEFLAGS is:
+ * If the first char is "n", this is a dry run, just exit.
+ * If the flags contains -j1, go to sequential mode.
+ * If the flags contains --jobserver-auth=R,W AND those file
+ descriptors are valid, use the jobserver. Otherwise output a
+ warning.
+
Args:
env: Optionally, the environment to search.
+ jobs: The number of jobs set by the user on the command line.
Returns:
- A GNUMakeJobClient configured appropriately.
+ A GNUMakeJobClient configured appropriately or None if there is
+ no MAKEFLAGS environment variable.
"""
if env is None:
env = os.environ
makeflags = env.get("MAKEFLAGS")
if not makeflags:
- raise OSError("MAKEFLAGS is not set in the environment")
+ return None
match = re.search(r"--jobserver-auth=(\d+),(\d+)", makeflags)
- if not match:
- raise OSError("MAKEFLAGS did not contain jobserver flags")
- read_fd, write_fd = map(int, match.groups())
- return cls(read_fd, write_fd)
+ if match:
+ pipe = [int(x) for x in match.groups()]
+ if jobs:
+ pipe = None
+ logging.warning(
+ "-jN forced on command line; ignoring GNU make jobserver"
+ )
+ else:
+ try:
+ # Use F_GETFD to see if file descriptors are valid
+ fcntl.fcntl(pipe[0], fcntl.F_GETFD)
+ fcntl.fcntl(pipe[1], fcntl.F_GETFD)
+ logging.info("using GNU make jobserver")
+ except OSError:
+ pipe = None
+ logging.warning(
+ "No file descriptors; ignoring GNU make jobserver"
+ )
+ else:
+ pipe = None
+ if not jobs:
+ match = re.search(r"-j(\d+)", makeflags)
+ if match:
+ jobs = int(match.group(1))
+ if jobs == 1:
+ logging.info("Running in sequential mode (-j1)")
+ if makeflags[0] == "n":
+ logging.info("MAKEFLAGS contained dry-run flag")
+ sys.exit(0)
+ return cls(pipe, jobs, internal_jobs=1, makeflags=makeflags)
def get_job(self):
"""Claim a job.
@@ -104,12 +192,38 @@ class GNUMakeJobClient(JobClient):
Returns:
A JobHandle object.
"""
- byte = os.read(self._pipe[0], 1)
- return JobHandle(lambda: os.write(self._pipe[1], byte))
+ while True:
+ ready_items = self._selector.select()
+ if len(ready_items) > 0:
+ read_fd = ready_items[0][0].fd
+ write_fd = ready_items[0][0].data
+ try:
+ byte = os.read(read_fd, 1)
+ return JobHandle(
+ functools.partial(os.write, write_fd, byte)
+ )
+ except BlockingIOError:
+ pass
def env(self):
"""Get the environment variables necessary to share the job server."""
- return {"MAKEFLAGS": "--jobserver-auth={},{}".format(*self._pipe)}
+ if self._makeflags:
+ return {"MAKEFLAGS": self._makeflags}
+ flag = ""
+ if self.jobs:
+ flag += f" -j{self.jobs}"
+ if self.jobs != 1 and self._inheritable_pipe is not None:
+ flag += " --jobserver-auth={},{}".format(*self._inheritable_pipe)
+ return {"MAKEFLAGS": flag}
+
+ def is_sequential(self):
+ return self.jobs == 1
+
+ def pass_fds(self):
+ """Returns the file descriptors that should be passed to subprocesses."""
+ if self.jobs != 1 and self._inheritable_pipe is not None:
+ return self._inheritable_pipe
+ return []
class GNUMakeJobServer(GNUMakeJobClient):
@@ -120,11 +234,10 @@ class GNUMakeJobServer(GNUMakeJobClient):
"""
def __init__(self, jobs=0):
- [read_fd, write_fd] = os.pipe()
- super().__init__(read_fd, write_fd)
if not jobs:
jobs = multiprocessing.cpu_count()
elif jobs > select.PIPE_BUF:
jobs = select.PIPE_BUF
+ super().__init__(os.pipe(), jobs)
- os.write(self._pipe[1], b"+" * jobs)
+ os.write(self._inheritable_pipe[1], b"+" * jobs)
diff --git a/zephyr/zmake/zmake/multiproc.py b/zephyr/zmake/zmake/multiproc.py
index 0838f5f1f8..a668bcb961 100644
--- a/zephyr/zmake/zmake/multiproc.py
+++ b/zephyr/zmake/zmake/multiproc.py
@@ -43,7 +43,8 @@ class LogWriter:
# A local pipe use to signal the look that a new file descriptor was added and
# should be included in the select statement.
- _logging_interrupt_pipe = os.pipe()
+ _logging_interrupt_pipe = []
+
# A condition variable used to synchronize logging operations.
_logging_cv = threading.Condition()
# A map of file descriptors to their LogWriter
@@ -54,7 +55,14 @@ class LogWriter:
@classmethod
def reset(cls):
"""Reset this module to its starting state (useful for tests)"""
- LogWriter._logging_map.clear()
+ with LogWriter._logging_cv:
+ LogWriter._logging_map.clear()
+ if len(LogWriter._logging_interrupt_pipe) > 1:
+ os.write(LogWriter._logging_interrupt_pipe[1], b"x")
+ else:
+ cls._logging_interrupt_pipe = os.pipe()
+ LogWriter._logging_thread = None
+ LogWriter._logging_cv.notify_all()
def __init__(
self,
@@ -135,20 +143,21 @@ class LogWriter:
removed from the map as it is no longer valid.
"""
with LogWriter._logging_cv:
- writer = LogWriter._logging_map[file_descriptor]
- if file_descriptor.closed:
- del LogWriter._logging_map[file_descriptor]
- LogWriter._logging_cv.notify_all()
- return
- line = file_descriptor.readline()
- if not line:
- # EOF
- del LogWriter._logging_map[file_descriptor]
- LogWriter._logging_cv.notify_all()
- return
- line = line.rstrip("\n")
- if line:
- writer.log_line(line)
+ if file_descriptor in LogWriter._logging_map:
+ writer = LogWriter._logging_map[file_descriptor]
+ if file_descriptor.closed:
+ del LogWriter._logging_map[file_descriptor]
+ LogWriter._logging_cv.notify_all()
+ return
+ line = file_descriptor.readline()
+ if not line:
+ # EOF
+ del LogWriter._logging_map[file_descriptor]
+ LogWriter._logging_cv.notify_all()
+ return
+ line = line.rstrip("\n")
+ if line:
+ writer.log_line(line)
@classmethod
def _prune_logging_fds(cls):
@@ -295,6 +304,9 @@ class Executor:
Args:
func: A function which returns an int result code or throws an
exception.
+
+ Returns:
+ A join function which will wait until this task is finished.
"""
with self.lock:
thread = threading.Thread(
@@ -302,6 +314,7 @@ class Executor:
)
thread.start()
self.threads.append(thread)
+ return thread.join
def wait(self):
"""Wait for a result to be available.
diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py
index f81f157054..fb88dae7e9 100644
--- a/zephyr/zmake/zmake/zmake.py
+++ b/zephyr/zmake/zmake/zmake.py
@@ -187,13 +187,10 @@ class Zmake:
if jobserver:
self.jobserver = jobserver
else:
- try:
- self.jobserver = zmake.jobserver.GNUMakeJobClient.from_environ()
- except OSError:
- self.jobserver = zmake.jobserver.GNUMakeJobServer(jobs=jobs)
+ self.jobserver = zmake.jobserver.GNUMakeJobServer(jobs=jobs)
self.executor = zmake.multiproc.Executor()
- self._sequential = jobs == 1 and not goma
+ self._sequential = self.jobserver.is_sequential() and not goma
self.failed_projects = []
@property
@@ -243,6 +240,7 @@ class Zmake:
delete_intermediates=False,
static_version=False,
save_temps=False,
+ wait_for_executor=True,
):
"""Locate and configure the specified projects."""
# Resolve build_dir if needed.
@@ -269,7 +267,6 @@ class Zmake:
coverage=coverage,
allow_warnings=allow_warnings,
extra_cflags=extra_cflags,
- multiproject=len(projects) > 1,
delete_intermediates=delete_intermediates,
static_version=static_version,
save_temps=save_temps,
@@ -279,11 +276,11 @@ class Zmake:
result = self.executor.wait()
if result:
return result
- result = self.executor.wait()
- if result:
- return result
non_test_projects = [p for p in projects if not p.config.is_test]
if len(non_test_projects) > 1 and coverage and build_after_configure:
+ result = self.executor.wait()
+ if result:
+ return result
result = self._merge_lcov_files(
projects=non_test_projects,
build_dir=build_dir,
@@ -292,6 +289,11 @@ class Zmake:
if result:
self.failed_projects.append(str(build_dir / "all_builds.info"))
return result
+ elif wait_for_executor:
+ result = self.executor.wait()
+ if result:
+ return result
+
return 0
def build(
@@ -385,8 +387,10 @@ class Zmake:
delete_intermediates=False,
static_version=True,
save_temps=False,
+ wait_for_executor=False,
)
-
+ if not result:
+ result = self.executor.wait()
if result:
self.logger.error(
"compare-builds failed to build all projects at %s",
@@ -440,372 +444,364 @@ class Zmake:
coverage=False,
allow_warnings=False,
extra_cflags=None,
- multiproject=False,
delete_intermediates=False,
static_version=False,
save_temps=False,
):
"""Set up a build directory to later be built by "zmake build"."""
try:
- # Clobber build directory if requested.
- if clobber and build_dir.exists():
- self.logger.info(
- "Clearing build directory %s due to --clobber", build_dir
- )
- shutil.rmtree(build_dir)
-
- generated_include_dir = (build_dir / "include").resolve()
- base_config = zmake.build_config.BuildConfig(
- cmake_defs={
- "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
- "DTS_ROOT": str(self.module_paths["ec"] / "zephyr"),
- "SYSCALL_INCLUDE_DIRS": str(
- self.module_paths["ec"]
- / "zephyr"
- / "include"
- / "drivers"
- ),
- "USER_CACHE_DIR": str(
- self.module_paths["ec"]
- / "build"
- / "zephyr"
- / "user-cache"
- ),
- "ZEPHYR_BASE": str(self.zephyr_base),
- "ZMAKE_INCLUDE_DIR": str(generated_include_dir),
- "ZMAKE_PROJECT_NAME": project.config.project_name,
- **(
- {"EXTRA_EC_VERSION_FLAGS": "--static"}
- if static_version
- else {}
- ),
- **(
- {"EXTRA_CFLAGS": "-save-temps=obj"}
- if save_temps
- else {}
- ),
- },
- )
-
- # Prune the module paths to just those required by the project.
- module_paths = project.prune_modules(self.module_paths)
-
- module_config = zmake.modules.setup_module_symlinks(
- build_dir / "modules", module_paths
- )
-
- # Symlink the Zephyr base into the build directory so it can
- # be used in the build phase.
- util.update_symlink(self.zephyr_base, build_dir / "zephyr_base")
-
- dts_overlay_config = project.find_dts_overlays(module_paths)
-
- toolchain_support = project.get_toolchain(
- module_paths, override=toolchain
- )
- toolchain_config = toolchain_support.get_build_config()
+ with self.jobserver.get_job():
+ # Clobber build directory if requested.
+ if clobber and build_dir.exists():
+ self.logger.info(
+ "Clearing build directory %s due to --clobber",
+ build_dir,
+ )
+ shutil.rmtree(build_dir)
- if bringup:
- base_config |= zmake.build_config.BuildConfig(
- kconfig_defs={"CONFIG_PLATFORM_EC_BRINGUP": "y"}
- )
- if coverage:
- base_config |= zmake.build_config.BuildConfig(
- kconfig_defs={"CONFIG_COVERAGE": "y"}
- )
- if allow_warnings:
- base_config |= zmake.build_config.BuildConfig(
- cmake_defs={"ALLOW_WARNINGS": "ON"}
- )
- if extra_cflags:
- base_config |= zmake.build_config.BuildConfig(
- cmake_defs={"EXTRA_CFLAGS": extra_cflags},
- )
- if self.goma:
- base_config |= zmake.build_config.BuildConfig(
+ generated_include_dir = (build_dir / "include").resolve()
+ base_config = zmake.build_config.BuildConfig(
cmake_defs={
- "CMAKE_C_COMPILER_LAUNCHER": self.gomacc,
- "CMAKE_CXX_COMPILER_LAUNCHER": self.gomacc,
+ "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
+ "DTS_ROOT": str(self.module_paths["ec"] / "zephyr"),
+ "SYSCALL_INCLUDE_DIRS": str(
+ self.module_paths["ec"]
+ / "zephyr"
+ / "include"
+ / "drivers"
+ ),
+ "USER_CACHE_DIR": str(
+ self.module_paths["ec"]
+ / "build"
+ / "zephyr"
+ / "user-cache"
+ ),
+ "ZEPHYR_BASE": str(self.zephyr_base),
+ "ZMAKE_INCLUDE_DIR": str(generated_include_dir),
+ "ZMAKE_PROJECT_NAME": project.config.project_name,
+ **(
+ {"EXTRA_EC_VERSION_FLAGS": "--static"}
+ if static_version
+ else {}
+ ),
+ **(
+ {"EXTRA_CFLAGS": "-save-temps=obj"}
+ if save_temps
+ else {}
+ ),
},
)
- if not build_dir.exists():
- build_dir.mkdir()
- if not generated_include_dir.exists():
- generated_include_dir.mkdir()
- processes = []
- files_to_write = []
- self.logger.info(
- "Building %s in %s.", project.config.project_name, build_dir
- )
- for build_name, build_config in project.iter_builds():
- config: zmake.build_config.BuildConfig = (
- base_config
- | toolchain_config
- | module_config
- | dts_overlay_config
- | build_config
+ # Prune the module paths to just those required by the project.
+ module_paths = project.prune_modules(self.module_paths)
+
+ module_config = zmake.modules.setup_module_symlinks(
+ build_dir / "modules", module_paths
)
- config_json = config.as_json()
- config_json_file = build_dir / f"cfg-{build_name}.json"
- if config_json_file.is_file():
- if config_json_file.read_text() == config_json:
- self.logger.info(
- "Skip reconfiguring %s:%s due to previous cmake run of "
- "equivalent configuration. Run with --clobber if this "
- "optimization is undesired.",
- project.config.project_name,
- build_name,
- )
- continue
- config_json_file.unlink()
+ # Symlink the Zephyr base into the build directory so it can
+ # be used in the build phase.
+ util.update_symlink(self.zephyr_base, build_dir / "zephyr_base")
- files_to_write.append((config_json_file, config_json))
+ dts_overlay_config = project.find_dts_overlays(module_paths)
- output_dir = build_dir / "build-{}".format(build_name)
- if output_dir.exists():
- self.logger.info(
- "Clobber %s due to configuration changes.", output_dir
+ toolchain_support = project.get_toolchain(
+ module_paths, override=toolchain
+ )
+ toolchain_config = toolchain_support.get_build_config()
+
+ if bringup:
+ base_config |= zmake.build_config.BuildConfig(
+ kconfig_defs={"CONFIG_PLATFORM_EC_BRINGUP": "y"}
+ )
+ if coverage:
+ base_config |= zmake.build_config.BuildConfig(
+ kconfig_defs={"CONFIG_COVERAGE": "y"}
+ )
+ if allow_warnings:
+ base_config |= zmake.build_config.BuildConfig(
+ cmake_defs={"ALLOW_WARNINGS": "ON"}
+ )
+ if extra_cflags:
+ base_config |= zmake.build_config.BuildConfig(
+ cmake_defs={"EXTRA_CFLAGS": extra_cflags},
+ )
+ if self.goma:
+ base_config |= zmake.build_config.BuildConfig(
+ cmake_defs={
+ "CMAKE_C_COMPILER_LAUNCHER": self.gomacc,
+ "CMAKE_CXX_COMPILER_LAUNCHER": self.gomacc,
+ },
)
- shutil.rmtree(output_dir)
+ if not build_dir.exists():
+ build_dir.mkdir()
+ if not generated_include_dir.exists():
+ generated_include_dir.mkdir()
self.logger.info(
- "Configuring %s:%s.",
- project.config.project_name,
- build_name,
- )
-
- kconfig_file = build_dir / "kconfig-{}.conf".format(build_name)
- proc = config.popen_cmake(
- self.jobserver,
- project.config.project_dir,
- output_dir,
- kconfig_file,
- stdin=subprocess.DEVNULL,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- encoding="utf-8",
- errors="replace",
+ "Building %s in %s.", project.config.project_name, build_dir
)
- job_id = "{}:{}".format(project.config.project_name, build_name)
- zmake.multiproc.LogWriter.log_output(
- self.logger,
- logging.DEBUG,
- proc.stdout,
- log_level_override_func=cmake_log_level_override,
- job_id=job_id,
+ # To reconstruct a Project object later, we need to know the
+ # name and project directory.
+ (build_dir / "project_name.txt").write_text(
+ project.config.project_name
)
- zmake.multiproc.LogWriter.log_output(
- self.logger,
- logging.ERROR,
- proc.stderr,
- log_level_override_func=cmake_log_level_override,
- job_id=job_id,
+ util.update_symlink(
+ project.config.project_dir, build_dir / "project"
)
- if self._sequential:
- if proc.wait():
- raise OSError(get_process_failure_msg(proc))
- else:
- processes.append(proc)
- for proc in processes:
- if proc.wait():
- raise OSError(get_process_failure_msg(proc))
-
- for path, contents in files_to_write:
- path.write_text(contents)
-
- # To reconstruct a Project object later, we need to know the
- # name and project directory.
- (build_dir / "project_name.txt").write_text(
- project.config.project_name
- )
- util.update_symlink(
- project.config.project_dir, build_dir / "project"
- )
- output_files = []
+ wait_funcs = []
+ for build_name, build_config in project.iter_builds():
+ config: zmake.build_config.BuildConfig = (
+ base_config
+ | toolchain_config
+ | module_config
+ | dts_overlay_config
+ | build_config
+ )
+
+ wait_func = self.executor.append(
+ func=functools.partial(
+ self._configure_one_build,
+ config=config,
+ build_dir=build_dir,
+ build_name=build_name,
+ project=project,
+ )
+ )
+ wait_funcs.append(wait_func)
+ # Outside the with...get_job above.
+ for wait_func in wait_funcs:
+ wait_func()
+
if build_after_configure:
- result = self._build(
+ self._build(
build_dir=build_dir,
project=project,
coverage=coverage,
- output_files_out=output_files,
- multiproject=multiproject,
static_version=static_version,
+ delete_intermediates=delete_intermediates,
)
- if result:
- self.failed_projects.append(project.config.project_name)
- return result
-
- if delete_intermediates:
- outdir = build_dir / "output"
- for child in build_dir.iterdir():
- if child != outdir:
- logging.debug("Deleting %s", child)
- if not child.is_symlink() and child.is_dir():
- shutil.rmtree(child)
- else:
- child.unlink()
return 0
except Exception:
self.failed_projects.append(project.config.project_name)
raise
+ def _configure_one_build(
+ self,
+ config,
+ build_dir,
+ build_name,
+ project,
+ ):
+ """Run cmake and maybe ninja on one build dir."""
+ with self.jobserver.get_job():
+ config_json = config.as_json()
+ config_json_file = build_dir / f"cfg-{build_name}.json"
+ if config_json_file.is_file():
+ if config_json_file.read_text() == config_json:
+ self.logger.info(
+ "Skip reconfiguring %s:%s due to previous cmake run of "
+ "equivalent configuration. Run with --clobber if this "
+ "optimization is undesired.",
+ project.config.project_name,
+ build_name,
+ )
+ return 0
+ config_json_file.unlink()
+
+ output_dir = build_dir / "build-{}".format(build_name)
+ if output_dir.exists():
+ self.logger.info(
+ "Clobber %s due to configuration changes.",
+ output_dir,
+ )
+ shutil.rmtree(output_dir)
+
+ self.logger.info(
+ "Configuring %s:%s.",
+ project.config.project_name,
+ build_name,
+ )
+
+ kconfig_file = build_dir / "kconfig-{}.conf".format(build_name)
+ proc = config.popen_cmake(
+ self.jobserver,
+ project.config.project_dir,
+ output_dir,
+ kconfig_file,
+ stdin=subprocess.DEVNULL,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ encoding="utf-8",
+ errors="replace",
+ )
+ job_id = "{}:{}".format(project.config.project_name, build_name)
+ zmake.multiproc.LogWriter.log_output(
+ self.logger,
+ logging.DEBUG,
+ proc.stdout,
+ log_level_override_func=cmake_log_level_override,
+ job_id=job_id,
+ )
+ zmake.multiproc.LogWriter.log_output(
+ self.logger,
+ logging.ERROR,
+ proc.stderr,
+ log_level_override_func=cmake_log_level_override,
+ job_id=job_id,
+ )
+ if proc.wait():
+ raise OSError(get_process_failure_msg(proc))
+ config_json_file.write_text(config_json)
+ return 0
+
def _build(
self,
build_dir,
project: zmake.project.Project,
- output_files_out=None,
coverage=False,
- multiproject=False,
static_version=False,
+ delete_intermediates=False,
):
"""Build a pre-configured build directory."""
- def wait_and_check_success(procs, writers):
- """Wait for processes to complete and check for errors
-
- Args:
- procs: List of subprocess.Popen objects to check
- writers: List of LogWriter objects to check
-
- Returns:
- True if all if OK
- False if an error was found (so that zmake should exit)
- """
- bad = None
- for proc in procs:
- if proc.wait() and not bad:
- bad = proc
- if bad:
- # Just show the first bad process for now. Both builds likely
- # produce the same error anyway. If they don't, the user can
- # still take action on the errors/warnings provided. Showing
- # multiple 'Execution failed' messages is not very friendly
- # since it exposes the fragmented nature of the build.
- raise OSError(get_process_failure_msg(bad))
+ with self.jobserver.get_job():
+ dirs: Dict[str, pathlib.Path] = {}
- # Let all output be produced before exiting
- for writer in writers:
- writer.wait()
- return True
-
- procs = []
- log_writers = []
- dirs: Dict[str, pathlib.Path] = {}
-
- build_dir = build_dir.resolve()
-
- # Compute the version string.
- version_string = zmake.version.get_version_string(
- project.config.project_name,
- build_dir / "zephyr_base",
- zmake.modules.locate_from_directory(build_dir / "modules"),
- static=static_version,
- )
+ build_dir = build_dir.resolve()
- # The version header needs to generated during the build phase
- # instead of configure, as the tree may have changed since
- # configure was run.
- zmake.version.write_version_header(
- version_string,
- build_dir / "include" / "ec_version.h",
- "zmake",
- static=static_version,
- )
+ # Compute the version string.
+ version_string = zmake.version.get_version_string(
+ project.config.project_name,
+ build_dir / "zephyr_base",
+ zmake.modules.locate_from_directory(build_dir / "modules"),
+ static=static_version,
+ )
- gcov = "gcov.sh-not-found"
- for build_name, _ in project.iter_builds():
- with self.jobserver.get_job():
+ # The version header needs to generated during the build phase
+ # instead of configure, as the tree may have changed since
+ # configure was run.
+ zmake.version.write_version_header(
+ version_string,
+ build_dir / "include" / "ec_version.h",
+ "zmake",
+ static=static_version,
+ )
+
+ gcov = "gcov.sh-not-found"
+ wait_funcs = []
+ for build_name, _ in project.iter_builds():
dirs[build_name] = build_dir / "build-{}".format(build_name)
gcov = dirs[build_name] / "gcov.sh"
- cmd = ["/usr/bin/ninja", "-C", dirs[build_name].as_posix()]
- if self.goma:
- # Go nuts ninja, goma does the heavy lifting!
- cmd.append("-j1024")
- elif multiproject:
- cmd.append("-j1")
- # Only tests will actually build with coverage enabled.
- if coverage and not project.config.is_test:
- cmd.append("all.libraries")
- self.logger.info(
- "Building %s:%s: %s",
- project.config.project_name,
- build_name,
- util.repr_command(cmd),
- )
- proc = self.jobserver.popen(
- cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- encoding="utf-8",
- errors="replace",
- # TODO(b/239619222): Filter os.environ for ninja.
- env=os.environ,
- )
- job_id = "{}:{}".format(project.config.project_name, build_name)
- dirs[build_name].mkdir(parents=True, exist_ok=True)
- build_log = open( # pylint:disable=consider-using-with
- dirs[build_name] / "build.log",
- "w",
- )
- out = zmake.multiproc.LogWriter.log_output(
- logger=self.logger,
- log_level=logging.INFO,
- file_descriptor=proc.stdout,
- log_level_override_func=ninja_stdout_log_level_override,
- job_id=job_id,
- tee_output=build_log,
- )
- err = zmake.multiproc.LogWriter.log_output(
- self.logger,
- logging.ERROR,
- proc.stderr,
- job_id=job_id,
+ wait_func = self.executor.append(
+ func=functools.partial(
+ self._build_one_dir,
+ build_name=build_name,
+ dirs=dirs,
+ coverage=coverage,
+ project=project,
+ )
)
+ wait_funcs.append(wait_func)
+ # Outside the with...get_job above.
+ for wait_func in wait_funcs:
+ wait_func()
- if self._sequential:
- if not wait_and_check_success([proc], [out, err]):
- return 2
- else:
- procs.append(proc)
- log_writers += [out, err]
-
- if not wait_and_check_success(procs, log_writers):
- return 2
-
- # Run the packer.
- packer_work_dir = build_dir / "packer"
- output_dir = build_dir / "output"
- for newdir in output_dir, packer_work_dir:
- if not newdir.exists():
- newdir.mkdir()
-
- if output_files_out is None:
- output_files_out = []
- # For non-tests, they won't link with coverage, so don't pack the
- # firmware. Also generate a lcov file.
- if coverage and not project.config.is_test:
- with self.jobserver.get_job():
+ with self.jobserver.get_job():
+ # Run the packer.
+ packer_work_dir = build_dir / "packer"
+ output_dir = build_dir / "output"
+ for newdir in output_dir, packer_work_dir:
+ if not newdir.exists():
+ newdir.mkdir()
+
+ # For non-tests, they won't link with coverage, so don't pack the
+ # firmware. Also generate a lcov file.
+ if coverage and not project.config.is_test:
self._run_lcov(
build_dir,
output_dir / "zephyr.info",
initial=True,
gcov=gcov,
)
- else:
- for output_file, output_name in project.packer.pack_firmware(
- packer_work_dir,
- self.jobserver,
- dirs,
- version_string=version_string,
- ):
- shutil.copy2(output_file, output_dir / output_name)
- self.logger.debug("Output file '%s' created.", output_file)
- output_files_out.append(output_file)
+ else:
+ for output_file, output_name in project.packer.pack_firmware(
+ packer_work_dir,
+ self.jobserver,
+ dirs,
+ version_string=version_string,
+ ):
+ shutil.copy2(output_file, output_dir / output_name)
+ self.logger.debug("Output file '%s' created.", output_file)
- return 0
+ if delete_intermediates:
+ outdir = build_dir / "output"
+ for child in build_dir.iterdir():
+ if child != outdir:
+ logging.debug("Deleting %s", child)
+ if not child.is_symlink() and child.is_dir():
+ shutil.rmtree(child)
+ else:
+ child.unlink()
+ return 0
+
+ def _build_one_dir(self, build_name, dirs, coverage, project):
+ """Builds one sub-dir of a configured project (build-ro, etc)."""
+
+ with self.jobserver.get_job():
+ cmd = ["/usr/bin/ninja", "-C", dirs[build_name].as_posix()]
+ if self.goma:
+ # Go nuts ninja, goma does the heavy lifting!
+ cmd.append("-j1024")
+ elif self._sequential:
+ cmd.append("-j1")
+ # Only tests will actually build with coverage enabled.
+ if coverage and not project.config.is_test:
+ cmd.append("all.libraries")
+ self.logger.info(
+ "Building %s:%s: %s",
+ project.config.project_name,
+ build_name,
+ util.repr_command(cmd),
+ )
+ proc = self.jobserver.popen(
+ cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ encoding="utf-8",
+ errors="replace",
+ # TODO(b/239619222): Filter os.environ for ninja.
+ env=os.environ,
+ )
+ job_id = "{}:{}".format(project.config.project_name, build_name)
+ dirs[build_name].mkdir(parents=True, exist_ok=True)
+ build_log = open( # pylint:disable=consider-using-with
+ dirs[build_name] / "build.log",
+ "w",
+ )
+ out = zmake.multiproc.LogWriter.log_output(
+ logger=self.logger,
+ log_level=logging.INFO,
+ file_descriptor=proc.stdout,
+ log_level_override_func=ninja_stdout_log_level_override,
+ job_id=job_id,
+ tee_output=build_log,
+ )
+ err = zmake.multiproc.LogWriter.log_output(
+ self.logger,
+ logging.ERROR,
+ proc.stderr,
+ job_id=job_id,
+ )
+
+ if proc.wait():
+ raise OSError(get_process_failure_msg(proc))
+
+ # Let all output be produced before exiting
+ out.wait()
+ err.wait()
+ return 0
def _run_lcov(
self,
@@ -869,34 +865,33 @@ class Zmake:
pathlib.Path(build_dir) / project.config.project_name
)
all_lcov_files.append(project_build_dir / "output" / "zephyr.info")
- with self.jobserver.get_job():
- # Merge info files into a single lcov.info
- self.logger.info("Merging coverage data into %s.", output_file)
- cmd = [
- "/usr/bin/lcov",
- "-o",
- output_file,
- "--rc",
- "lcov_branch_coverage=1",
- ]
- for info in all_lcov_files:
- cmd += ["-a", info]
- proc = self.jobserver.popen(
- cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- encoding="utf-8",
- errors="replace",
- )
- zmake.multiproc.LogWriter.log_output(
- self.logger, logging.ERROR, proc.stderr, job_id="lcov"
- )
- zmake.multiproc.LogWriter.log_output(
- self.logger, logging.DEBUG, proc.stdout, job_id="lcov"
- )
- if proc.wait():
- raise OSError(get_process_failure_msg(proc))
- return 0
+ # Merge info files into a single lcov.info
+ self.logger.info("Merging coverage data into %s.", output_file)
+ cmd = [
+ "/usr/bin/lcov",
+ "-o",
+ output_file,
+ "--rc",
+ "lcov_branch_coverage=1",
+ ]
+ for info in all_lcov_files:
+ cmd += ["-a", info]
+ proc = self.jobserver.popen(
+ cmd,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ encoding="utf-8",
+ errors="replace",
+ )
+ zmake.multiproc.LogWriter.log_output(
+ self.logger, logging.ERROR, proc.stderr, job_id="lcov"
+ )
+ zmake.multiproc.LogWriter.log_output(
+ self.logger, logging.DEBUG, proc.stdout, job_id="lcov"
+ )
+ if proc.wait():
+ raise OSError(get_process_failure_msg(proc))
+ return 0
def list_projects(self, fmt, search_dir):
"""List project names known to zmake on stdout.