summaryrefslogtreecommitdiff
path: root/zephyr
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr')
-rw-r--r--zephyr/CMakeLists.txt407
-rw-r--r--zephyr/Kconfig879
-rw-r--r--zephyr/Kconfig.accelgyro_bmi33
-rw-r--r--zephyr/Kconfig.accelgyro_icm33
-rw-r--r--zephyr/Kconfig.adc62
-rw-r--r--zephyr/Kconfig.battery491
-rw-r--r--zephyr/Kconfig.board_version34
-rw-r--r--zephyr/Kconfig.console69
-rw-r--r--zephyr/Kconfig.console_cmd_mem32
-rw-r--r--zephyr/Kconfig.debug_assert45
-rw-r--r--zephyr/Kconfig.defaults10
-rw-r--r--zephyr/Kconfig.espi28
-rw-r--r--zephyr/Kconfig.flash107
-rw-r--r--zephyr/Kconfig.header30
-rw-r--r--zephyr/Kconfig.init_priority26
-rw-r--r--zephyr/Kconfig.keyboard177
-rw-r--r--zephyr/Kconfig.led48
-rw-r--r--zephyr/Kconfig.mkbp_event49
-rw-r--r--zephyr/Kconfig.motionsense190
-rw-r--r--zephyr/Kconfig.panic43
-rw-r--r--zephyr/Kconfig.pmic27
-rw-r--r--zephyr/Kconfig.port8014
-rw-r--r--zephyr/Kconfig.powerseq190
-rw-r--r--zephyr/Kconfig.rtc40
-rw-r--r--zephyr/Kconfig.sensor_devices113
-rw-r--r--zephyr/Kconfig.stacks111
-rw-r--r--zephyr/Kconfig.system49
-rw-r--r--zephyr/Kconfig.tasks303
-rw-r--r--zephyr/Kconfig.temperature65
-rw-r--r--zephyr/Kconfig.throttle_ap32
-rw-r--r--zephyr/Kconfig.timer50
-rw-r--r--zephyr/Kconfig.usbc1231
-rw-r--r--zephyr/Kconfig.watchdog29
-rw-r--r--zephyr/README.md30
-rw-r--r--zephyr/app/CMakeLists.txt5
-rw-r--r--zephyr/app/Kconfig5
-rw-r--r--zephyr/app/ec/CMakeLists.txt9
-rw-r--r--zephyr/app/ec/Kconfig137
-rw-r--r--zephyr/app/ec/chip/arm/nuvoton_npcx/Kconfig.npcx53
-rw-r--r--zephyr/app/ec/chip/arm/nuvoton_npcx/Kconfig.npcx753
-rw-r--r--zephyr/app/ec/chip/arm/nuvoton_npcx/Kconfig.npcx951
-rw-r--r--zephyr/app/ec/chip/riscv/riscv-ite/Kconfig.it8xxx241
-rw-r--r--zephyr/app/ec/ec_app_main.c119
-rw-r--r--zephyr/app/ec/include/ec_app_main.h6
-rw-r--r--zephyr/app/ec/main_shim.c22
-rw-r--r--zephyr/app/ec/soc/Kconfig82
-rw-r--r--zephyr/boards/arm/brya/Kconfig.board15
-rw-r--r--zephyr/boards/arm/brya/Kconfig.defconfig10
-rw-r--r--zephyr/boards/arm/brya/board.cmake6
-rw-r--r--zephyr/boards/arm/brya/brya.dts188
-rw-r--r--zephyr/boards/arm/brya/brya_defconfig41
-rw-r--r--zephyr/boards/arm/herobrine_npcx9/Kconfig.board15
-rw-r--r--zephyr/boards/arm/herobrine_npcx9/Kconfig.defconfig10
-rw-r--r--zephyr/boards/arm/herobrine_npcx9/herobrine_npcx9.dts144
-rw-r--r--zephyr/boards/arm/herobrine_npcx9/herobrine_npcx9_defconfig40
-rw-r--r--zephyr/boards/arm/kohaku/Kconfig.board10
-rw-r--r--zephyr/boards/arm/kohaku/Kconfig.defconfig10
-rw-r--r--zephyr/boards/arm/kohaku/board.cmake5
-rw-r--r--zephyr/boards/arm/kohaku/kohaku.dts418
-rw-r--r--zephyr/boards/arm/kohaku/kohaku.yaml19
-rw-r--r--zephyr/boards/arm/kohaku/kohaku_defconfig34
-rw-r--r--zephyr/boards/arm/npcx9/Kconfig.board10
-rw-r--r--zephyr/boards/arm/npcx9/Kconfig.defconfig10
-rw-r--r--zephyr/boards/arm/npcx9/board.cmake5
-rw-r--r--zephyr/boards/arm/npcx9/npcx9.dts199
-rw-r--r--zephyr/boards/arm/npcx9/npcx9_defconfig33
-rw-r--r--zephyr/boards/arm/npcx_evb/Kconfig.board18
-rw-r--r--zephyr/boards/arm/npcx_evb/Kconfig.defconfig7
-rw-r--r--zephyr/boards/arm/npcx_evb/npcx7_evb.dts22
-rw-r--r--zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig55
-rw-r--r--zephyr/boards/arm/npcx_evb/npcx9_evb.dts21
-rw-r--r--zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig54
-rw-r--r--zephyr/boards/arm/npcx_evb/npcx_evb.dtsi169
-rw-r--r--zephyr/boards/arm/trogdor/Kconfig.board15
-rw-r--r--zephyr/boards/arm/trogdor/Kconfig.defconfig10
-rw-r--r--zephyr/boards/arm/trogdor/board.cmake5
-rw-r--r--zephyr/boards/arm/trogdor/trogdor.dts272
-rw-r--r--zephyr/boards/arm/trogdor/trogdor_defconfig40
-rw-r--r--zephyr/boards/arm/volteer/Kconfig.board13
-rw-r--r--zephyr/boards/arm/volteer/Kconfig.defconfig11
-rw-r--r--zephyr/boards/arm/volteer/board.cmake3
-rw-r--r--zephyr/boards/arm/volteer/volteer.dts322
-rw-r--r--zephyr/boards/arm/volteer/volteer_defconfig45
-rw-r--r--zephyr/boards/riscv/asurada/Kconfig.board14
-rw-r--r--zephyr/boards/riscv/asurada/Kconfig.defconfig56
-rw-r--r--zephyr/boards/riscv/asurada/asurada.dts200
-rw-r--r--zephyr/boards/riscv/asurada/asurada_defconfig99
-rw-r--r--zephyr/boards/riscv/it8xxx2_evb/Kconfig.board9
-rw-r--r--zephyr/boards/riscv/it8xxx2_evb/Kconfig.defconfig10
-rw-r--r--zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb.dts255
-rw-r--r--zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb_defconfig75
-rw-r--r--zephyr/cmake/bintools/gnu/target.cmake7
-rw-r--r--zephyr/cmake/bintools/llvm/generic.cmake10
-rw-r--r--zephyr/cmake/bintools/llvm/target.cmake9
-rw-r--r--zephyr/cmake/compiler/clang/compiler_flags.cmake10
-rw-r--r--zephyr/cmake/compiler/clang/generic.cmake6
-rw-r--r--zephyr/cmake/compiler/clang/target.cmake6
-rw-r--r--zephyr/cmake/compiler/gcc/compiler_flags.cmake7
-rw-r--r--zephyr/cmake/compiler/gcc/target.cmake14
-rw-r--r--zephyr/cmake/linker/ld/linker_flags.cmake7
-rw-r--r--zephyr/cmake/linker/ld/target.cmake7
-rw-r--r--zephyr/cmake/linker/lld/linker_flags.cmake9
-rw-r--r--zephyr/cmake/linker/lld/target.cmake26
-rw-r--r--zephyr/cmake/toolchain/coreboot-sdk/generic.cmake9
-rw-r--r--zephyr/cmake/toolchain/coreboot-sdk/target.cmake39
-rw-r--r--zephyr/cmake/toolchain/llvm/generic.cmake7
-rw-r--r--zephyr/cmake/toolchain/llvm/target.cmake16
-rw-r--r--zephyr/drivers/CMakeLists.txt10
-rw-r--r--zephyr/drivers/Kconfig9
-rw-r--r--zephyr/drivers/cros_cbi/CMakeLists.txt4
-rw-r--r--zephyr/drivers/cros_cbi/cros_cbi.c218
-rw-r--r--zephyr/drivers/cros_flash/CMakeLists.txt4
-rw-r--r--zephyr/drivers/cros_flash/Kconfig22
-rw-r--r--zephyr/drivers/cros_flash/cros_flash_it8xxx2.c327
-rw-r--r--zephyr/drivers/cros_flash/cros_flash_npcx.c821
-rw-r--r--zephyr/drivers/cros_kb_raw/CMakeLists.txt4
-rw-r--r--zephyr/drivers/cros_kb_raw/Kconfig34
-rw-r--r--zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c187
-rw-r--r--zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c241
-rw-r--r--zephyr/drivers/cros_rtc/CMakeLists.txt9
-rw-r--r--zephyr/drivers/cros_rtc/Kconfig36
-rw-r--r--zephyr/drivers/cros_rtc/cros_rtc_npcx.c241
-rw-r--r--zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c450
-rw-r--r--zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h58
-rw-r--r--zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c480
-rw-r--r--zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.h60
-rw-r--r--zephyr/drivers/cros_shi/CMakeLists.txt6
-rw-r--r--zephyr/drivers/cros_shi/Kconfig57
-rw-r--r--zephyr/drivers/cros_shi/cros_shi_it8xxx2.c407
-rw-r--r--zephyr/drivers/cros_shi/cros_shi_npcx.c899
-rw-r--r--zephyr/drivers/cros_system/CMakeLists.txt6
-rw-r--r--zephyr/drivers/cros_system/Kconfig47
-rw-r--r--zephyr/drivers/cros_system/cros_system_it8xxx2.c246
-rw-r--r--zephyr/drivers/cros_system/cros_system_npcx.c556
-rw-r--r--zephyr/dts/bindings/adc/named-adc.yaml107
-rw-r--r--zephyr/dts/bindings/battery/as3gwrc3ka,c235-41.yaml56
-rw-r--r--zephyr/dts/bindings/battery/battery-fuel-gauge.yaml85
-rw-r--r--zephyr/dts/bindings/battery/battery-info.yaml71
-rw-r--r--zephyr/dts/bindings/battery/battery-smart.yaml19
-rw-r--r--zephyr/dts/bindings/battery/lgc,ap16l8j.yaml55
-rw-r--r--zephyr/dts/bindings/battery/lgc,ap18c8k.yaml57
-rw-r--r--zephyr/dts/bindings/battery/murata,ap18c4k.yaml57
-rw-r--r--zephyr/dts/bindings/battery/named-batteries.yaml20
-rw-r--r--zephyr/dts/bindings/battery/panasonic,ap16l5j-009.yaml59
-rw-r--r--zephyr/dts/bindings/battery/panasonic,ap16l5j.yaml59
-rw-r--r--zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml22
-rw-r--r--zephyr/dts/bindings/cbi/named-cbi-ssfc.yaml55
-rw-r--r--zephyr/dts/bindings/charger/intersil,isl9238.yaml9
-rw-r--r--zephyr/dts/bindings/charger/intersil,isl9241.yaml18
-rw-r--r--zephyr/dts/bindings/console/ec-console.yaml14
-rw-r--r--zephyr/dts/bindings/cros_bbram/named-bbram-regions.yaml15
-rw-r--r--zephyr/dts/bindings/cros_dbg/nuvoton,npcx-cros-dbg.yaml17
-rw-r--r--zephyr/dts/bindings/cros_flash/cros-ec,flash-layout.yaml39
-rw-r--r--zephyr/dts/bindings/cros_flash/cros-flash-controller.yaml12
-rw-r--r--zephyr/dts/bindings/cros_flash/nuvoton,npcx-cros-flash.yaml24
-rw-r--r--zephyr/dts/bindings/cros_kb_raw/cros-kb-raw-controller.yaml12
-rw-r--r--zephyr/dts/bindings/cros_kb_raw/nuvoton,npcx-cros-kb-raw.yaml32
-rw-r--r--zephyr/dts/bindings/cros_mkbp_event/ec-mkbp-event.yaml29
-rw-r--r--zephyr/dts/bindings/cros_rtc/cros-rtc.yaml12
-rw-r--r--zephyr/dts/bindings/cros_rtc/nuvoton,npcx-cros-mtc.yaml26
-rw-r--r--zephyr/dts/bindings/cros_rtc/nxp,rtc-pcf85063a.yaml17
-rw-r--r--zephyr/dts/bindings/cros_rtc/renesas,rtc-idt1337ag.yaml17
-rw-r--r--zephyr/dts/bindings/cros_shi/ite,it8xxx2-cros-shi.yaml18
-rw-r--r--zephyr/dts/bindings/cros_shi/nuvoton,npcx-cros-shi.yaml31
-rw-r--r--zephyr/dts/bindings/emul/cros,bb-retimer-emul.yaml30
-rw-r--r--zephyr/dts/bindings/emul/cros,i2c-mock.yaml12
-rw-r--r--zephyr/dts/bindings/emul/cros,lis2dw12-emul.yaml12
-rw-r--r--zephyr/dts/bindings/emul/cros,ln9310-emul.yaml13
-rw-r--r--zephyr/dts/bindings/emul/zephyr,bma255.yaml83
-rw-r--r--zephyr/dts/bindings/emul/zephyr,bmi.yaml42
-rw-r--r--zephyr/dts/bindings/emul/zephyr,pi3usb9201.yaml9
-rw-r--r--zephyr/dts/bindings/emul/zephyr,smart-battery.yaml155
-rw-r--r--zephyr/dts/bindings/emul/zephyr,syv682x.yaml9
-rw-r--r--zephyr/dts/bindings/emul/zephyr,tcs3400.yaml44
-rw-r--r--zephyr/dts/bindings/fan/named-fans.yaml63
-rw-r--r--zephyr/dts/bindings/gpio/gpio-enum-name.yaml180
-rw-r--r--zephyr/dts/bindings/gpio/gpio-id.yaml27
-rw-r--r--zephyr/dts/bindings/gpio/hibernate-wake-pins.yaml13
-rw-r--r--zephyr/dts/bindings/gpio/named-gpios.yaml21
-rw-r--r--zephyr/dts/bindings/gpio/unused-gpios.yaml11
-rw-r--r--zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml56
-rw-r--r--zephyr/dts/bindings/i2c/named-i2c-ports.yaml10
-rw-r--r--zephyr/dts/bindings/keyboard/cros-keyscan.yaml82
-rw-r--r--zephyr/dts/bindings/led/cros-ec,pwm-leds.yaml75
-rw-r--r--zephyr/dts/bindings/motionsense/cros-ec,motionsense-mutex.yaml34
-rw-r--r--zephyr/dts/bindings/motionsense/cros-ec,motionsense-rotation-ref.yaml55
-rw-r--r--zephyr/dts/bindings/motionsense/cros-ec,motionsense-sensor-config.yaml66
-rw-r--r--zephyr/dts/bindings/motionsense/cros-ec,motionsense-sensor-info.yaml56
-rw-r--r--zephyr/dts/bindings/motionsense/driver/bmi160.yaml16
-rw-r--r--zephyr/dts/bindings/motionsense/driver/bmi260.yaml16
-rw-r--r--zephyr/dts/bindings/motionsense/driver/cros-ec,bma255.yaml21
-rw-r--r--zephyr/dts/bindings/motionsense/driver/cros-ec,bmi160-accel.yaml13
-rw-r--r--zephyr/dts/bindings/motionsense/driver/cros-ec,bmi160-gyro.yaml13
-rw-r--r--zephyr/dts/bindings/motionsense/driver/cros-ec,bmi260-accel.yaml13
-rw-r--r--zephyr/dts/bindings/motionsense/driver/cros-ec,bmi260-gyro.yaml13
-rw-r--r--zephyr/dts/bindings/motionsense/driver/cros-ec,kx022.yaml21
-rw-r--r--zephyr/dts/bindings/motionsense/driver/cros-ec,lis2dw12.yaml21
-rw-r--r--zephyr/dts/bindings/motionsense/driver/cros-ec,tcs3400-clear.yaml9
-rw-r--r--zephyr/dts/bindings/motionsense/driver/cros-ec,tcs3400-rgb.yaml9
-rw-r--r--zephyr/dts/bindings/motionsense/driver/tcs3400.yaml18
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/cros-ec,accelgyro-als-channel-scale.yaml29
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/cros-ec,accelgyro-als-drv-data.yaml44
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/cros-ec,accelgyro-rgb-calibration.yaml63
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bma255.yaml18
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bmi160.yaml18
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bmi260.yaml18
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-kionix.yaml18
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-lis2dw12.yaml18
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-tcs3400-clear.yaml32
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-tcs3400-rgb.yaml21
-rw-r--r--zephyr/dts/bindings/motionsense/drvdata/drvdata-base.yaml11
-rw-r--r--zephyr/dts/bindings/motionsense/motionsense-sensor-base.yaml82
-rw-r--r--zephyr/dts/bindings/pwm/named-pwms.yaml24
-rw-r--r--zephyr/dts/bindings/retimer/intel,jhl8040r.yaml22
-rw-r--r--zephyr/dts/bindings/switchcap/switchcap-gpio.yaml16
-rw-r--r--zephyr/dts/bindings/switchcap/switchcap-ln9310.yaml27
-rw-r--r--zephyr/dts/bindings/temp/cros_ec_temp_sensor.yaml86
-rw-r--r--zephyr/dts/bindings/temp/cros_ec_thermistor.yaml57
-rw-r--r--zephyr/dts/bindings/vendor-prefixes.txt8
-rw-r--r--zephyr/dts/board-overlays/native_posix.dts6
-rw-r--r--zephyr/emul/CMakeLists.txt17
-rw-r--r--zephyr/emul/Kconfig72
-rw-r--r--zephyr/emul/Kconfig.i2c_mock22
-rw-r--r--zephyr/emul/Kconfig.lis2dw1223
-rw-r--r--zephyr/emul/Kconfig.ln931022
-rw-r--r--zephyr/emul/emul_bb_retimer.c365
-rw-r--r--zephyr/emul/emul_bma255.c1042
-rw-r--r--zephyr/emul/emul_bmi.c1116
-rw-r--r--zephyr/emul/emul_bmi160.c770
-rw-r--r--zephyr/emul/emul_bmi260.c571
-rw-r--r--zephyr/emul/emul_common_i2c.c432
-rw-r--r--zephyr/emul/emul_lis2dw12.c161
-rw-r--r--zephyr/emul/emul_ln9310.c388
-rw-r--r--zephyr/emul/emul_pi3usb9201.c195
-rw-r--r--zephyr/emul/emul_smart_battery.c893
-rw-r--r--zephyr/emul/emul_syv682x.c219
-rw-r--r--zephyr/emul/emul_tcs3400.c650
-rw-r--r--zephyr/emul/i2c_mock.c70
-rwxr-xr-xzephyr/firmware_builder.py226
-rw-r--r--zephyr/fpu.cmake40
-rwxr-xr-xzephyr/gcov.tmpl.sh7
-rwxr-xr-xzephyr/hayato_get_cfg.sh45
-rw-r--r--zephyr/include/cros/binman.dtsi51
-rw-r--r--zephyr/include/cros/ite/it8xxx2.dtsi83
-rw-r--r--zephyr/include/cros/nuvoton/npcx.dtsi159
-rw-r--r--zephyr/include/cros/nuvoton/npcx7.dtsi24
-rw-r--r--zephyr/include/cros/nuvoton/npcx9.dtsi15
-rw-r--r--zephyr/include/cros/thermistor/thermistor.dtsi308
-rw-r--r--zephyr/include/drivers/cros_cbi.h102
-rw-r--r--zephyr/include/drivers/cros_flash.h288
-rw-r--r--zephyr/include/drivers/cros_kb_raw.h169
-rw-r--r--zephyr/include/drivers/cros_rtc.h224
-rw-r--r--zephyr/include/drivers/cros_shi.h89
-rw-r--r--zephyr/include/drivers/cros_system.h302
-rw-r--r--zephyr/include/dt-bindings/charger/intersil_isl9241.h18
-rw-r--r--zephyr/include/dt-bindings/cros-kb-raw/ite_cros_kb_raw.h8
-rw-r--r--zephyr/include/dt-bindings/cros-kb-raw/npcx_cros_kb_raw.h9
-rw-r--r--zephyr/include/dt-bindings/gpio_defines.h59
-rw-r--r--zephyr/include/dt-bindings/motionsense/utils.h14
-rw-r--r--zephyr/include/dt-bindings/wake_mask_event_defines.h73
-rw-r--r--zephyr/include/emul/emul_bb_retimer.h89
-rw-r--r--zephyr/include/emul/emul_bma255.h191
-rw-r--r--zephyr/include/emul/emul_bmi.h431
-rw-r--r--zephyr/include/emul/emul_common_i2c.h369
-rw-r--r--zephyr/include/emul/emul_lis2dw12.h48
-rw-r--r--zephyr/include/emul/emul_ln9310.h73
-rw-r--r--zephyr/include/emul/emul_pi3usb9201.h55
-rw-r--r--zephyr/include/emul/emul_smart_battery.h193
-rw-r--r--zephyr/include/emul/emul_syv682x.h143
-rw-r--r--zephyr/include/emul/emul_tcs3400.h156
-rw-r--r--zephyr/include/emul/i2c_mock.h35
-rw-r--r--zephyr/include/soc/ite_it8xxx2/reg_def_cros.h97
-rw-r--r--zephyr/include/soc/nuvoton_npcx/reg_def_cros.h251
-rw-r--r--zephyr/linker/CMakeLists.txt19
-rw-r--r--zephyr/linker/fixed-sections.ld8
-rw-r--r--zephyr/linker/image_size.ld17
-rw-r--r--zephyr/linker/iram_text.ld23
-rw-r--r--zephyr/linker/iterables-ram.ld3
-rw-r--r--zephyr/linker/iterables-rom.ld7
-rw-r--r--zephyr/linker/npcx-lfw.ld24
-rw-r--r--zephyr/module.yml9
-rw-r--r--zephyr/projects/asurada/hayato/CMakeLists.txt27
-rw-r--r--zephyr/projects/asurada/hayato/battery.dts12
-rw-r--r--zephyr/projects/asurada/hayato/gpio.dts347
-rw-r--r--zephyr/projects/asurada/hayato/include/gpio_map.h75
-rw-r--r--zephyr/projects/asurada/hayato/include/i2c_map.h13
-rw-r--r--zephyr/projects/asurada/hayato/include/pwm_map.h23
-rw-r--r--zephyr/projects/asurada/hayato/motionsense.dts157
-rw-r--r--zephyr/projects/asurada/hayato/prj.conf120
-rw-r--r--zephyr/projects/asurada/hayato/pwm.dts48
-rw-r--r--zephyr/projects/asurada/hayato/src/i2c.c17
-rw-r--r--zephyr/projects/asurada/hayato/zmake.yaml16
-rw-r--r--zephyr/projects/brya/brya/CMakeLists.txt10
-rw-r--r--zephyr/projects/brya/brya/gpio.dts75
-rw-r--r--zephyr/projects/brya/brya/include/gpio_map.h37
-rw-r--r--zephyr/projects/brya/brya/prj.conf45
-rw-r--r--zephyr/projects/brya/brya/zmake.yaml13
-rw-r--r--zephyr/projects/guybrush/CMakeLists.txt17
-rw-r--r--zephyr/projects/guybrush/gpio.dts336
-rw-r--r--zephyr/projects/guybrush/include/gpio_map.h63
-rw-r--r--zephyr/projects/guybrush/power_signals.c95
-rw-r--r--zephyr/projects/guybrush/prj.conf47
-rw-r--r--zephyr/projects/guybrush/zmake.yaml13
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/CMakeLists.txt19
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/battery.dts12
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/gpio.dts388
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/i2c.dts160
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/include/gpio_map.h60
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/include/pwm_map.h16
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/motionsense.dts157
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/prj.conf168
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/src/i2c.c17
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/src/led.c163
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/src/usb_pd_policy.c262
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/src/usbc_config.c365
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/switchcap.dts12
-rw-r--r--zephyr/projects/herobrine/herobrine_npcx9/zmake.yaml17
-rw-r--r--zephyr/projects/it8xxx2_evb/CMakeLists.txt11
-rw-r--r--zephyr/projects/it8xxx2_evb/include/gpio_map.h37
-rw-r--r--zephyr/projects/it8xxx2_evb/include/i2c_map.h16
-rw-r--r--zephyr/projects/it8xxx2_evb/include/pwm_map.h22
-rw-r--r--zephyr/projects/it8xxx2_evb/prj.conf40
-rw-r--r--zephyr/projects/it8xxx2_evb/zmake.yaml11
-rw-r--r--zephyr/projects/kohaku/CMakeLists.txt10
-rw-r--r--zephyr/projects/kohaku/include/gpio_map.h48
-rw-r--r--zephyr/projects/kohaku/prj.conf38
-rw-r--r--zephyr/projects/kohaku/zmake.yaml11
-rw-r--r--zephyr/projects/npcx_evb/npcx7/CMakeLists.txt10
-rw-r--r--zephyr/projects/npcx_evb/npcx7/fan.dts29
-rw-r--r--zephyr/projects/npcx_evb/npcx7/gpio.dts78
-rw-r--r--zephyr/projects/npcx_evb/npcx7/include/gpio_map.h35
-rw-r--r--zephyr/projects/npcx_evb/npcx7/include/pwm_map.h16
-rw-r--r--zephyr/projects/npcx_evb/npcx7/keyboard.dts31
-rw-r--r--zephyr/projects/npcx_evb/npcx7/prj.conf55
-rw-r--r--zephyr/projects/npcx_evb/npcx7/pwm.dts32
-rw-r--r--zephyr/projects/npcx_evb/npcx7/zmake.yaml16
-rw-r--r--zephyr/projects/npcx_evb/npcx9/CMakeLists.txt10
-rw-r--r--zephyr/projects/npcx_evb/npcx9/fan.dts29
-rw-r--r--zephyr/projects/npcx_evb/npcx9/gpio.dts78
-rw-r--r--zephyr/projects/npcx_evb/npcx9/include/gpio_map.h35
-rw-r--r--zephyr/projects/npcx_evb/npcx9/include/pwm_map.h16
-rw-r--r--zephyr/projects/npcx_evb/npcx9/keyboard.dts31
-rw-r--r--zephyr/projects/npcx_evb/npcx9/prj.conf59
-rw-r--r--zephyr/projects/npcx_evb/npcx9/pwm.dts32
-rw-r--r--zephyr/projects/npcx_evb/npcx9/zmake.yaml16
-rw-r--r--zephyr/projects/posix-ec/CMakeLists.txt10
-rw-r--r--zephyr/projects/posix-ec/prj.conf18
-rw-r--r--zephyr/projects/posix-ec/zmake.yaml7
-rw-r--r--zephyr/projects/trogdor/lazor/CMakeLists.txt34
-rw-r--r--zephyr/projects/trogdor/lazor/battery.dts24
-rw-r--r--zephyr/projects/trogdor/lazor/gpio.dts446
-rw-r--r--zephyr/projects/trogdor/lazor/include/gpio_map.h67
-rw-r--r--zephyr/projects/trogdor/lazor/include/pwm_map.h16
-rw-r--r--zephyr/projects/trogdor/lazor/keyboard.dts26
-rw-r--r--zephyr/projects/trogdor/lazor/motionsense.dts193
-rw-r--r--zephyr/projects/trogdor/lazor/prj.conf165
-rw-r--r--zephyr/projects/trogdor/lazor/src/i2c.c17
-rw-r--r--zephyr/projects/trogdor/lazor/src/led.c155
-rw-r--r--zephyr/projects/trogdor/lazor/zmake.yaml16
-rw-r--r--zephyr/projects/trogdor/trogdor/CMakeLists.txt32
-rw-r--r--zephyr/projects/trogdor/trogdor/battery.dts12
-rw-r--r--zephyr/projects/trogdor/trogdor/gpio.dts370
-rw-r--r--zephyr/projects/trogdor/trogdor/include/gpio_map.h63
-rw-r--r--zephyr/projects/trogdor/trogdor/include/pwm_map.h16
-rw-r--r--zephyr/projects/trogdor/trogdor/motionsense.dts157
-rw-r--r--zephyr/projects/trogdor/trogdor/prj.conf152
-rw-r--r--zephyr/projects/trogdor/trogdor/src/i2c.c17
-rw-r--r--zephyr/projects/trogdor/trogdor/zmake.yaml15
-rw-r--r--zephyr/projects/volteer/delbin/CMakeLists.txt23
-rw-r--r--zephyr/projects/volteer/delbin/gpio.dts349
-rw-r--r--zephyr/projects/volteer/delbin/include/gpio_map.h70
-rw-r--r--zephyr/projects/volteer/delbin/motionsense.dts162
-rw-r--r--zephyr/projects/volteer/delbin/prj.conf51
-rw-r--r--zephyr/projects/volteer/delbin/zmake.yaml14
-rw-r--r--zephyr/projects/volteer/volteer/CMakeLists.txt45
-rw-r--r--zephyr/projects/volteer/volteer/bb_retimer.dts18
-rw-r--r--zephyr/projects/volteer/volteer/cbi_eeprom.dts68
-rw-r--r--zephyr/projects/volteer/volteer/fan.dts29
-rw-r--r--zephyr/projects/volteer/volteer/gpio.dts406
-rw-r--r--zephyr/projects/volteer/volteer/include/gpio_map.h112
-rw-r--r--zephyr/projects/volteer/volteer/include/pwm_map.h25
-rw-r--r--zephyr/projects/volteer/volteer/keyboard.dts28
-rw-r--r--zephyr/projects/volteer/volteer/motionsense.dts263
-rw-r--r--zephyr/projects/volteer/volteer/prj.conf152
-rw-r--r--zephyr/projects/volteer/volteer/pwm.dts80
-rw-r--r--zephyr/projects/volteer/volteer/pwm_leds.dts32
-rw-r--r--zephyr/projects/volteer/volteer/zmake.yaml20
-rw-r--r--zephyr/shim/CMakeLists.txt7
-rw-r--r--zephyr/shim/chip/CMakeLists.txt12
-rw-r--r--zephyr/shim/chip/it8xxx2/CMakeLists.txt10
-rw-r--r--zephyr/shim/chip/it8xxx2/clock.c41
-rw-r--r--zephyr/shim/chip/it8xxx2/include/flash_chip.h41
-rw-r--r--zephyr/shim/chip/it8xxx2/keyboard_raw.c26
-rw-r--r--zephyr/shim/chip/it8xxx2/pinmux.c112
-rw-r--r--zephyr/shim/chip/it8xxx2/system.c16
-rw-r--r--zephyr/shim/chip/npcx/CMakeLists.txt25
-rw-r--r--zephyr/shim/chip/npcx/Kconfig.npcx18
-rw-r--r--zephyr/shim/chip/npcx/clock.c69
-rw-r--r--zephyr/shim/chip/npcx/espi.c53
-rw-r--r--zephyr/shim/chip/npcx/gpio.c55
-rw-r--r--zephyr/shim/chip/npcx/include/clock_chip.h14
-rw-r--r--zephyr/shim/chip/npcx/include/flash_chip.h31
-rw-r--r--zephyr/shim/chip/npcx/include/rom_chip.h57
-rw-r--r--zephyr/shim/chip/npcx/include/system_chip.h80
-rw-r--r--zephyr/shim/chip/npcx/keyboard_raw.c25
-rw-r--r--zephyr/shim/chip/npcx/npcx_monitor/CMakeLists.txt47
-rw-r--r--zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c343
-rw-r--r--zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.h33
-rw-r--r--zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.ld52
-rw-r--r--zephyr/shim/chip/npcx/npcx_monitor/registers.h360
-rw-r--r--zephyr/shim/chip/npcx/power_policy.c34
-rw-r--r--zephyr/shim/chip/npcx/shi.c87
-rw-r--r--zephyr/shim/chip/npcx/system.c97
-rw-r--r--zephyr/shim/chip/npcx/system_download_from_flash.c159
-rw-r--r--zephyr/shim/chip/npcx/system_external_storage.c157
-rw-r--r--zephyr/shim/chip/posix/CMakeLists.txt5
-rw-r--r--zephyr/shim/chip/posix/espi.c49
-rw-r--r--zephyr/shim/core/CMakeLists.txt7
-rw-r--r--zephyr/shim/core/cortex-m/CMakeLists.txt5
-rw-r--r--zephyr/shim/core/cortex-m/mpu.c38
-rw-r--r--zephyr/shim/include/adc_chip.h16
-rw-r--r--zephyr/shim/include/atomic.h16
-rw-r--r--zephyr/shim/include/battery_enum.h36
-rw-r--r--zephyr/shim/include/bbram.h16
-rw-r--r--zephyr/shim/include/board.h33
-rw-r--r--zephyr/shim/include/builtin/assert.h16
-rw-r--r--zephyr/shim/include/config_chip.h1811
-rw-r--r--zephyr/shim/include/cpu.h14
-rw-r--r--zephyr/shim/include/ec_tasks.h30
-rw-r--r--zephyr/shim/include/fpu.h56
-rw-r--r--zephyr/shim/include/gpio/gpio.h95
-rw-r--r--zephyr/shim/include/i2c/i2c.h54
-rw-r--r--zephyr/shim/include/linker.h12
-rw-r--r--zephyr/shim/include/motionsense_sensors.h103
-rw-r--r--zephyr/shim/include/mpu.h35
-rw-r--r--zephyr/shim/include/pwm/pwm.h26
-rw-r--r--zephyr/shim/include/registers.h16
-rw-r--r--zephyr/shim/include/shimmed_task_id.h119
-rw-r--r--zephyr/shim/include/shimmed_tasks.h90
-rw-r--r--zephyr/shim/include/temp_sensor/temp_sensor.h28
-rw-r--r--zephyr/shim/include/zephyr_adc.h41
-rw-r--r--zephyr/shim/include/zephyr_console_shim.h85
-rw-r--r--zephyr/shim/include/zephyr_espi_shim.h67
-rw-r--r--zephyr/shim/include/zephyr_gpio_signal.h57
-rw-r--r--zephyr/shim/include/zephyr_hooks_shim.h56
-rw-r--r--zephyr/shim/include/zephyr_host_command.h34
-rw-r--r--zephyr/shim/include/zephyr_mkbp_event.h23
-rw-r--r--zephyr/shim/src/CMakeLists.txt48
-rw-r--r--zephyr/shim/src/adc.c83
-rw-r--r--zephyr/shim/src/battery.c69
-rw-r--r--zephyr/shim/src/cbi.c22
-rw-r--r--zephyr/shim/src/console.c353
-rw-r--r--zephyr/shim/src/console_buffer.c128
-rw-r--r--zephyr/shim/src/crc.c21
-rw-r--r--zephyr/shim/src/espi.c563
-rw-r--r--zephyr/shim/src/fan.c380
-rw-r--r--zephyr/shim/src/flash.c150
-rw-r--r--zephyr/shim/src/gpio.c441
-rw-r--r--zephyr/shim/src/gpio_id.c73
-rw-r--r--zephyr/shim/src/hooks.c122
-rw-r--r--zephyr/shim/src/host_command.c16
-rw-r--r--zephyr/shim/src/hwtimer.c29
-rw-r--r--zephyr/shim/src/i2c.c135
-rw-r--r--zephyr/shim/src/keyboard_raw.c77
-rw-r--r--zephyr/shim/src/keyscan.c34
-rw-r--r--zephyr/shim/src/libgcc_arm.S11
-rw-r--r--zephyr/shim/src/mkbp_event.c16
-rw-r--r--zephyr/shim/src/motionsense_driver/bma255-drvinfo.inc44
-rw-r--r--zephyr/shim/src/motionsense_driver/bmi160-drvinfo.inc57
-rw-r--r--zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc57
-rw-r--r--zephyr/shim/src/motionsense_driver/drvdata-accelgyro.h127
-rw-r--r--zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc44
-rw-r--r--zephyr/shim/src/motionsense_driver/lis2dw12-drvinfo.inc44
-rw-r--r--zephyr/shim/src/motionsense_driver/sensor_drv_list.inc39
-rw-r--r--zephyr/shim/src/motionsense_driver/tcs3400-drvinfo.inc79
-rw-r--r--zephyr/shim/src/motionsense_sensors.c403
-rw-r--r--zephyr/shim/src/panic.c160
-rw-r--r--zephyr/shim/src/pwm.c190
-rw-r--r--zephyr/shim/src/pwm_led.c60
-rw-r--r--zephyr/shim/src/rtc.c235
-rw-r--r--zephyr/shim/src/switchcap_gpio.c47
-rw-r--r--zephyr/shim/src/switchcap_ln9310.c49
-rw-r--r--zephyr/shim/src/system.c378
-rw-r--r--zephyr/shim/src/tasks.c353
-rw-r--r--zephyr/shim/src/temp_sensors.c52
-rw-r--r--zephyr/shim/src/test_util.c20
-rw-r--r--zephyr/shim/src/thermal.c52
-rw-r--r--zephyr/shim/src/watchdog.c78
-rw-r--r--zephyr/shim/src/ztest_system.c69
-rw-r--r--zephyr/test/accel_cal/CMakeLists.txt24
-rw-r--r--zephyr/test/accel_cal/prj.conf8
-rw-r--r--zephyr/test/accel_cal/shimmed_test_tasks.h6
-rw-r--r--zephyr/test/accel_cal/zmake.yaml12
-rw-r--r--zephyr/test/base32/CMakeLists.txt9
-rw-r--r--zephyr/test/base32/prj.conf7
-rw-r--r--zephyr/test/base32/zmake.yaml12
-rw-r--r--zephyr/test/crc/CMakeLists.txt10
-rw-r--r--zephyr/test/crc/main.c27
-rw-r--r--zephyr/test/crc/prj.conf7
-rw-r--r--zephyr/test/crc/zmake.yaml12
-rw-r--r--zephyr/test/drivers/CMakeLists.txt17
-rw-r--r--zephyr/test/drivers/README.md50
-rw-r--r--zephyr/test/drivers/include/gpio_map.h25
-rw-r--r--zephyr/test/drivers/include/stubs.h10
-rw-r--r--zephyr/test/drivers/overlay.dts561
-rw-r--r--zephyr/test/drivers/prj.conf90
-rw-r--r--zephyr/test/drivers/src/battery.c35
-rw-r--r--zephyr/test/drivers/src/bb_retimer.c528
-rw-r--r--zephyr/test/drivers/src/bc12.c280
-rw-r--r--zephyr/test/drivers/src/bma2x2.c926
-rw-r--r--zephyr/test/drivers/src/bmi160.c1873
-rw-r--r--zephyr/test/drivers/src/bmi260.c1864
-rw-r--r--zephyr/test/drivers/src/espi.c35
-rw-r--r--zephyr/test/drivers/src/lis2dw12.c119
-rw-r--r--zephyr/test/drivers/src/ln9310.c50
-rw-r--r--zephyr/test/drivers/src/main.c50
-rw-r--r--zephyr/test/drivers/src/ppc.c84
-rw-r--r--zephyr/test/drivers/src/smart.c281
-rw-r--r--zephyr/test/drivers/src/stm_mems_common.c56
-rw-r--r--zephyr/test/drivers/src/stubs.c233
-rw-r--r--zephyr/test/drivers/src/tcs3400.c622
-rw-r--r--zephyr/test/drivers/src/temp_sensor.c139
-rw-r--r--zephyr/test/drivers/src/thermistor.c295
-rw-r--r--zephyr/test/drivers/zmake.yaml14
-rw-r--r--zephyr/test/ec_app/CMakeLists.txt10
-rw-r--r--zephyr/test/ec_app/prj.conf7
-rw-r--r--zephyr/test/ec_app/src/main.c127
-rw-r--r--zephyr/test/ec_app/zmake.yaml12
-rw-r--r--zephyr/test/hooks/CMakeLists.txt9
-rw-r--r--zephyr/test/hooks/hooks.c156
-rw-r--r--zephyr/test/hooks/prj.conf8
-rw-r--r--zephyr/test/hooks/zmake.yaml12
-rw-r--r--zephyr/test/i2c/CMakeLists.txt9
-rw-r--r--zephyr/test/i2c/overlay.dts23
-rw-r--r--zephyr/test/i2c/prj.conf22
-rw-r--r--zephyr/test/i2c/src/main.c34
-rw-r--r--zephyr/test/i2c/zmake.yaml14
-rw-r--r--zephyr/test/i2c_dts/CMakeLists.txt10
-rw-r--r--zephyr/test/i2c_dts/overlay.dts23
-rw-r--r--zephyr/test/i2c_dts/prj.conf14
-rw-r--r--zephyr/test/i2c_dts/src/main.c30
-rw-r--r--zephyr/test/i2c_dts/zmake.yaml14
-rw-r--r--zephyr/test/system/CMakeLists.txt10
-rw-r--r--zephyr/test/system/overlay.dts34
-rw-r--r--zephyr/test/system/prj.conf4
-rw-r--r--zephyr/test/system/test_system.c76
-rw-r--r--zephyr/test/system/zmake.yaml14
-rw-r--r--zephyr/test/tasks/CMakeLists.txt14
-rw-r--r--zephyr/test/tasks/main.c298
-rw-r--r--zephyr/test/tasks/prj.conf9
-rw-r--r--zephyr/test/tasks/shimmed_test_tasks.h22
-rw-r--r--zephyr/test/tasks/zmake.yaml12
-rw-r--r--zephyr/zmake/.flake89
-rw-r--r--zephyr/zmake/.isort.cfg2
-rwxr-xr-xzephyr/zmake/run_tests.sh35
-rw-r--r--zephyr/zmake/setup.py38
-rw-r--r--zephyr/zmake/tests/conftest.py9
-rw-r--r--zephyr/zmake/tests/files/sample_err.txt321
-rw-r--r--zephyr/zmake/tests/files/sample_ro.txt318
-rw-r--r--zephyr/zmake/tests/files/sample_ro_INFO.txt4
-rw-r--r--zephyr/zmake/tests/files/sample_rw.txt315
-rw-r--r--zephyr/zmake/tests/files/sample_rw_INFO.txt4
-rw-r--r--zephyr/zmake/tests/test_build_config.py202
-rw-r--r--zephyr/zmake/tests/test_modules.py38
-rw-r--r--zephyr/zmake/tests/test_multiproc_executor.py52
-rw-r--r--zephyr/zmake/tests/test_multiproc_logging.py106
-rw-r--r--zephyr/zmake/tests/test_packers.py57
-rw-r--r--zephyr/zmake/tests/test_project.py173
-rw-r--r--zephyr/zmake/tests/test_reexec.py59
-rw-r--r--zephyr/zmake/tests/test_toolchains.py155
-rw-r--r--zephyr/zmake/tests/test_util.py107
-rw-r--r--zephyr/zmake/tests/test_version.py183
-rw-r--r--zephyr/zmake/tests/test_zmake.py224
-rw-r--r--zephyr/zmake/zmake/__init__.py0
-rw-r--r--zephyr/zmake/zmake/__main__.py273
-rw-r--r--zephyr/zmake/zmake/build_config.py100
-rw-r--r--zephyr/zmake/zmake/jobserver.py144
-rw-r--r--zephyr/zmake/zmake/modules.py99
-rw-r--r--zephyr/zmake/zmake/multiproc.py322
-rw-r--r--zephyr/zmake/zmake/output_packers.py230
-rw-r--r--zephyr/zmake/zmake/project.py248
-rw-r--r--zephyr/zmake/zmake/toolchains.py154
-rw-r--r--zephyr/zmake/zmake/util.py255
-rw-r--r--zephyr/zmake/zmake/version.py166
-rw-r--r--zephyr/zmake/zmake/zmake.py757
585 files changed, 0 insertions, 62279 deletions
diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt
deleted file mode 100644
index e896f6d841..0000000000
--- a/zephyr/CMakeLists.txt
+++ /dev/null
@@ -1,407 +0,0 @@
-# Copyright 2020 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.
-
-# Note: this cmake system implements only a zephyr module, and is not
-# intended to build a complete EC. To build projects in platform/ec,
-# you should continue to use the Makefile system.
-#
-# Googlers can find the design doc at go/zephyr-shim.
-
-if(NOT DEFINED ZEPHYR_CURRENT_MODULE_DIR)
- message(FATAL_ERROR "This Cmake system implements only a Zephyr module, and
- should not be invoked directly. Please continue to use the Makefile
- system for non-Zephyr builds.")
-endif()
-
-set(PLATFORM_EC "${ZEPHYR_CURRENT_MODULE_DIR}" CACHE PATH
- "Path to the platform/ec repo.")
-# Zephyr 2.3 will set ZEPHYR_CURRENT_MODULE_DIR to the directory of the
-# CMakeLists.txt file, whereas 2.4 will set it to the actual module
-# directory. Try to detect the condition by searching for
-# zephyr/module.yml.
-if(NOT EXISTS "${PLATFORM_EC}/zephyr/module.yml")
- set(PLATFORM_EC "${PLATFORM_EC}/..")
- assert_exists("${PLATFORM_EC}/zephyr/module.yml")
-endif()
-
-if(DEFINED ZMAKE_INCLUDE_DIR)
- zephyr_include_directories("${ZMAKE_INCLUDE_DIR}")
-endif()
-
-if(DEFINED CONFIG_PLATFORM_EC)
- # Add CHROMIUM_EC definition, which is used by ec_commands.h to
- # determine that the header is being compiled for the EC instead of
- # by another third-party C codebase.
- zephyr_compile_definitions("CHROMIUM_EC")
-
- # Add CONFIG_ZEPHYR, which is commonly used to guard code for use
- # with Zephyr builds only.
- zephyr_compile_definitions("CONFIG_ZEPHYR")
-
- # Force compiler warnings to generate errors
- zephyr_compile_options(-Werror)
-
- include(fpu.cmake)
-
- # When LTO is enabled, enable only for the "app" library, which compiles
- # and links all Chromium OS sources.
- # TODO: Enable LTO for all sources when Zephyr supports it.
- # See https://github.com/zephyrproject-rtos/zephyr/issues/2112
- if (DEFINED CONFIG_LTO)
- # The Zephyr toolchain generates linker errors if both CONFIG_LTO and
- # CONFIG_FPU are used. See b/184302085.
- if(("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "zephyr") AND
- (DEFINED CONFIG_FPU))
- message(STATUS "Zephyr toolchain and CONFIG_FPU detected: disabling LTO")
- else()
- set_property(TARGET app PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
- endif()
- endif()
-endif()
-
-# Switch from the "zephyr" library to the "app" library for all Chromium OS
-# sources.
-set(ZEPHYR_CURRENT_LIBRARY app)
-
-add_subdirectory(linker)
-
-zephyr_library_include_directories(include)
-
-if (DEFINED CONFIG_PLATFORM_EC)
- zephyr_library_include_directories(
- "${PLATFORM_EC}/zephyr/shim/include"
- "${PLATFORM_EC}/fuzz"
- "${PLATFORM_EC}/test"
- "${PLATFORM_EC}"
- "${PLATFORM_EC}/include"
- "${PLATFORM_EC}/include/driver"
- "${PLATFORM_EC}/third_party")
-endif()
-
-add_subdirectory("app")
-add_subdirectory("drivers")
-add_subdirectory("emul")
-
-add_subdirectory_ifdef(CONFIG_PLATFORM_EC "shim")
-# Creates a phony target all.libraries in case you only want to build the
-# libraries and not the binaries. For example for creating the initial zero
-# coverage files.
-get_property(ZEPHYR_LIBS_PROPERTY GLOBAL PROPERTY ZEPHYR_LIBS)
-add_custom_target(
- all.libraries
- DEPENDS
- ${ZEPHYR_LIBS_PROPERTY}
- kernel
- ${CMAKE_BINARY_DIR}/gcov.sh
- )
-configure_file(gcov.tmpl.sh ${CMAKE_BINARY_DIR}/gcov.sh)
-
-# CONFIG_PLATFORM_EC files that don't relate to something below should be
-# included here, sorted by filename. This is common functionality which is
-# supported by all boards and emulators (including unit tests) using the shim
-# layer.
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/base32.c"
- "${PLATFORM_EC}/common/console_output.c"
- "${PLATFORM_EC}/common/ec_features.c"
- "${PLATFORM_EC}/common/gpio_commands.c"
- "${PLATFORM_EC}/common/peripheral.c"
- "${PLATFORM_EC}/common/printf.c"
- "${PLATFORM_EC}/common/queue.c"
- "${PLATFORM_EC}/common/shared_mem.c"
- "${PLATFORM_EC}/common/uart_printf.c"
- "${PLATFORM_EC}/common/util.c"
- "${PLATFORM_EC}/common/version.c")
-
-# Now include files that depend on or relate to other CONFIG options, sorted by
-# CONFIG
-zephyr_library_sources_ifdef(CONFIG_HAS_TASK_POWERBTN
- "${PLATFORM_EC}/common/power_button_x86.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCEL_BMA255
- "${PLATFORM_EC}/driver/accel_bma2x2.c"
- "${PLATFORM_EC}/common/math_util.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCEL_KX022
- "${PLATFORM_EC}/driver/accel_kionix.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCEL_LIS2DW12
- "${PLATFORM_EC}/driver/accel_lis2dw12.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCELGYRO_BMI
- "${PLATFORM_EC}/driver/accelgyro_bmi_common.c"
- "${PLATFORM_EC}/common/math_util.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCELGYRO_BMI160
- "${PLATFORM_EC}/driver/accelgyro_bmi160.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCELGYRO_BMI260
- "${PLATFORM_EC}/driver/accelgyro_bmi260.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCELGYRO_ICM
- "${PLATFORM_EC}/driver/accelgyro_icm_common.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCELGYRO_ICM426XX
- "${PLATFORM_EC}/driver/accelgyro_icm426xx.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACCEL_FIFO
- "${PLATFORM_EC}/common/motion_sense_fifo.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ADC_CMD
- "${PLATFORM_EC}/common/adc.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ALS_TCS3400
- "${PLATFORM_EC}/driver/als_tcs3400.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ACPI
- "${PLATFORM_EC}/common/acpi.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BACKLIGHT_LID
- "${PLATFORM_EC}/common/backlight_lid.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY
- "${PLATFORM_EC}/common/battery.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE
- "${PLATFORM_EC}/common/battery_fuel_gauge.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY_SMART
- "${PLATFORM_EC}/driver/battery/smart.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201
- "${PLATFORM_EC}/driver/bc12/pi3usb9201.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BC12_DETECT_MT6360
- "${PLATFORM_EC}/driver/bc12/mt6360.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER_ISL9237
- "${PLATFORM_EC}/driver/charger/isl923x.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER_ISL9238
- "${PLATFORM_EC}/driver/charger/isl923x.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER_ISL9238C
- "${PLATFORM_EC}/driver/charger/isl923x.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER_ISL9241
- "${PLATFORM_EC}/driver/charger/isl9241.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER_BQ25710
- "${PLATFORM_EC}/driver/charger/bq25710.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGER_BQ25720
- "${PLATFORM_EC}/driver/charger/bq25710.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGE_MANAGER
- "${PLATFORM_EC}/common/charger.c"
- "${PLATFORM_EC}/common/charge_manager.c"
- "${PLATFORM_EC}/common/charge_state_v2.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGE_RAMP_HW
- "${PLATFORM_EC}/common/charge_ramp.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGE_RAMP_SW
- "${PLATFORM_EC}/common/charge_ramp.c"
- "${PLATFORM_EC}/common/charge_ramp_sw.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM
- "${PLATFORM_EC}/common/cbi.c"
- "${PLATFORM_EC}/common/cbi_eeprom.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")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_DPTF
- "${PLATFORM_EC}/common/dptf.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ
- "${PLATFORM_EC}/common/chipset.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ESPI
- "${PLATFORM_EC}/common/espi.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC "${PLATFORM_EC}/common/extpower_common.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_EXTPOWER_GPIO
- "${PLATFORM_EC}/common/extpower_gpio.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN
- "${PLATFORM_EC}/common/fan.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FLASH_CROS
- "${PLATFORM_EC}/common/flash.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD
- "${PLATFORM_EC}/common/host_command.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD
- "${PLATFORM_EC}/common/host_event_commands.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE
- "${PLATFORM_EC}/common/uart_hostcmd.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD_GET_UPTIME_INFO
- "${PLATFORM_EC}/common/uptime.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD_REGULATOR
- "${PLATFORM_EC}/common/regulator.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C
- "${PLATFORM_EC}/common/i2c_controller.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C_DEBUG
- "${PLATFORM_EC}/common/i2c_trace.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY
- "${PLATFORM_EC}/common/virtual_battery.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD
- "${PLATFORM_EC}/common/keyboard_scan.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042
- "${PLATFORM_EC}/common/keyboard_8042.c"
- "${PLATFORM_EC}/common/keyboard_8042_sharedlib.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP
- "${PLATFORM_EC}/common/keyboard_mkbp.c"
- "${PLATFORM_EC}/common/mkbp_fifo.c"
- "${PLATFORM_EC}/common/mkbp_info.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES
- "${PLATFORM_EC}/common/mkbp_input_devices.c"
- "${PLATFORM_EC}/common/mkbp_fifo.c"
- "${PLATFORM_EC}/common/mkbp_info.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_VIVALDI
- "${PLATFORM_EC}/common/keyboard_vivaldi.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PWM_KBLIGHT
- "${PLATFORM_EC}/common/keyboard_backlight.c"
- "${PLATFORM_EC}/common/pwm_kblight.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON
- "${PLATFORM_EC}/common/led_common.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_PWM
- "${PLATFORM_EC}/common/led_pwm.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LID_ANGLE
- "${PLATFORM_EC}/common/motion_lid.c"
- "${PLATFORM_EC}/common/math_util.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE
- "${PLATFORM_EC}/common/lid_angle.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LID_SWITCH
- "${PLATFORM_EC}/common/lid_switch.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MKBP_EVENT
- "${PLATFORM_EC}/common/mkbp_event.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MOTIONSENSE
- "${PLATFORM_EC}/common/motion_sense.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MP2964
- "${PLATFORM_EC}/driver/mp2964.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PORT80
- "${PLATFORM_EC}/common/port80.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWER_BUTTON
- "${PLATFORM_EC}/common/power_button.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ
- "${PLATFORM_EC}/power/common.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_AMD
- "${PLATFORM_EC}/power/amd_x86.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_COMETLAKE
- "${PLATFORM_EC}/power/cometlake.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_ICELAKE
- "${PLATFORM_EC}/power/icelake.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_INTEL
- "${PLATFORM_EC}/power/intel_x86.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP
- "${PLATFORM_EC}/power/host_sleep.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ_MT8192
- "${PLATFORM_EC}/power/mt8192.c")
-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")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PANIC
- "${PLATFORM_EC}/common/panic_output.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_PWM
- "${PLATFORM_EC}/common/pwm.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SHA256_SW
- "${PLATFORM_EC}/common/sha256.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SWITCH
- "${PLATFORM_EC}/common/switch.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SWITCHCAP_LN9310
- "${PLATFORM_EC}/driver/ln9310.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_SPI_FLASH_REGS
- "${PLATFORM_EC}/common/spi_flash_reg.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_STM_MEMS_COMMON
- "${PLATFORM_EC}/driver/stm_mems_common.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TABLET_MODE
- "${PLATFORM_EC}/common/tablet_mode.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TEMP_SENSOR
- "${PLATFORM_EC}/common/thermal.c"
- "${PLATFORM_EC}/common/temp_sensor.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_THERMISTOR
- "${PLATFORM_EC}/driver/temp_sensor/thermistor.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_THROTTLE_AP
- "${PLATFORM_EC}/common/throttle_ap.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TIMER
- "${PLATFORM_EC}/common/timer.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_CHARGER
- "${PLATFORM_EC}/common/usb_charger.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB
- "${PLATFORM_EC}/common/usb_port_power_dumb.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_POWER_DELIVERY
- "${PLATFORM_EC}/common/usb_common.c"
- "${PLATFORM_EC}/common/usbc/usbc_task.c"
- "${PLATFORM_EC}/common/usbc/usb_pd_timer.c"
- "${PLATFORM_EC}/common/usbc/usb_sm.c"
- "${PLATFORM_EC}/common/usbc_intr_task.c"
- "${PLATFORM_EC}/common/usb_pd_flags.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGEN
- "${PLATFORM_EC}/common/chargen.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CONSOLE_CMD_PD
- "${PLATFORM_EC}/common/usbc/usb_pd_console.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE
- "${PLATFORM_EC}/common/usbc/usb_retimer_fw_update.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB
- "${PLATFORM_EC}/driver/retimer/bb_retimer.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_SS_MUX
- "${PLATFORM_EC}/driver/usb_mux/usb_mux.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_MUX_IT5205
- "${PLATFORM_EC}/driver/usb_mux/it5205.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_MUX_PS8743
- "${PLATFORM_EC}/driver/usb_mux/ps8743.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL
- "${PLATFORM_EC}/driver/usb_mux/virtual.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_LOGGING
- "${PLATFORM_EC}/common/event_log.c"
- "${PLATFORM_EC}/common/pd_log.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE
- "${PLATFORM_EC}/common/usbc/tbt_alt_mode.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_USB4
- "${PLATFORM_EC}/common/usbc/usb_mode.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_OCP
- "${PLATFORM_EC}/common/usbc_ocp.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_ALT_MODE_DFP
- "${PLATFORM_EC}/common/usb_pd_alt_mode_dfp.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_ALT_MODE_UFP
- "${PLATFORM_EC}/common/usb_pd_alt_mode_ufp.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE
- "${PLATFORM_EC}/common/usb_pd_dual_role.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_CONSOLE_CMD
- "${PLATFORM_EC}/common/usb_pd_console_cmd.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_HOST_CMD
- "${PLATFORM_EC}/common/usb_pd_host_cmd.c"
- "${PLATFORM_EC}/common/usbc/usb_pd_host.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_VPD
- "${PLATFORM_EC}/common/usbc/usb_tc_vpd_sm.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_CTVPD
- "${PLATFORM_EC}/common/usbc/usb_tc_ctvpd_sm.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC
- "${PLATFORM_EC}/common/usbc/usb_tc_drp_acc_trysrc_sm.c"
- "${PLATFORM_EC}/common/usbc/usb_pe_drp_sm.c"
- "${PLATFORM_EC}/common/usbc/usb_pd_dpm.c"
- "${PLATFORM_EC}/common/usbc/usbc_pd_policy.c"
- "${PLATFORM_EC}/common/usbc/dp_alt_mode.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PRL_SM
- "${PLATFORM_EC}/common/usbc/usb_prl_sm.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8751
- "${PLATFORM_EC}/driver/tcpm/ps8xxx.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805
- "${PLATFORM_EC}/driver/tcpm/ps8xxx.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815
- "${PLATFORM_EC}/driver/tcpm/ps8xxx.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1715
- "${PLATFORM_EC}/driver/tcpm/rt1715.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_TCPM_TUSB422
- "${PLATFORM_EC}/driver/tcpm/tusb422.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI
- "${PLATFORM_EC}/driver/tcpm/tcpci.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP
- "${PLATFORM_EC}/driver/tcpm/ite_pd_intc.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT83XX
- "${PLATFORM_EC}/driver/tcpm/it83xx.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2
- "${PLATFORM_EC}/driver/tcpm/it8xxx2.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_PPC
- "${PLATFORM_EC}/common/usbc_ppc.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_PPC_SN5S330
- "${PLATFORM_EC}/driver/ppc/sn5s330.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC_PPC_SYV682X
- "${PLATFORM_EC}/driver/ppc/syv682x.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_VBOOT_HASH
- "${PLATFORM_EC}/common/vboot_hash.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_VOLUME_BUTTONS
- "${PLATFORM_EC}/common/button.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_VBOOT_EFS2
- "${PLATFORM_EC}/common/vboot/efs2.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_VSTORE
- "${PLATFORM_EC}/common/vstore.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_RTC
- "${PLATFORM_EC}/common/rtc.c")
diff --git a/zephyr/Kconfig b/zephyr/Kconfig
deleted file mode 100644
index 07f09ae46e..0000000000
--- a/zephyr/Kconfig
+++ /dev/null
@@ -1,879 +0,0 @@
-# Copyright 2020 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.
-
-rsource "app/Kconfig"
-rsource "drivers/Kconfig"
-rsource "emul/Kconfig"
-
-if ZTEST
-
-config HAS_TEST_TASKS
- bool "Whether or not this test includes custom tasks"
- help
- This enables custom tasks for tests. When set to 'y', the file
- "shimmed_test_tasks.h" will be included and is expected to set
- CROS_EC_TASK_LIST.
-
-endif # ZTEST
-
-menuconfig PLATFORM_EC
- bool "Chromium OS EC shim"
- imply PRINTK
- imply SHELL
- help
- The platform/ec Zephyr module allows some code from the
- existing Chromium OS EC project to be "shimmed" into Zephyr. With
- this it is possible to use the existing code base within Zephyr.
-
- Once we manage to get a platform fully running with Zephyr we will
- progressively upstream components and turn off the shim for each
- one until eventually all code is on the Zephyr side.
-
-if PLATFORM_EC
-
-rsource "shim/chip/npcx/Kconfig.npcx"
-rsource "Kconfig.adc"
-rsource "Kconfig.battery"
-rsource "Kconfig.board_version"
-rsource "Kconfig.console"
-rsource "Kconfig.console_cmd_mem"
-rsource "Kconfig.debug_assert"
-rsource "Kconfig.defaults"
-rsource "Kconfig.espi"
-rsource "Kconfig.flash"
-rsource "Kconfig.header"
-rsource "Kconfig.init_priority"
-rsource "Kconfig.keyboard"
-rsource "Kconfig.led"
-rsource "Kconfig.panic"
-rsource "Kconfig.port80"
-rsource "Kconfig.powerseq"
-rsource "Kconfig.pmic"
-rsource "Kconfig.mkbp_event"
-rsource "Kconfig.motionsense"
-rsource "Kconfig.rtc"
-rsource "Kconfig.stacks"
-rsource "Kconfig.system"
-rsource "Kconfig.tasks"
-rsource "Kconfig.temperature"
-rsource "Kconfig.timer"
-rsource "Kconfig.throttle_ap"
-rsource "Kconfig.usbc"
-rsource "Kconfig.watchdog"
-
-# Define PLATFORM_EC_... options to enable EC features. Each Kconfig should be
-# matched by a line in zephyr/shim/include/config_chip.h which #defines the
-# corresponding EC CONFIG if this Kconfig is enabled.
-#
-# Please keep these in alphabetical order
-
-config PLATFORM_EC_ACPI
- bool "Advanced Confiugration and Power Interface (ACPI)"
- default y if AP_X86 && PLATFORM_EC_ESPI
- help
- Enable the Advanced Configuration and Power Interface (ACPI) in the
- EC. ACPI is a standard interface to the Application Processor (AP)
- that abstracts the hardware specific details for controlling and
- managing the board.
-
- This includes interfaces for monitoring or controlling features,
- including:
- keyboard backlight
- fan speed
- temperature sensors
- charging properties
- device orientation (tablet or laptop mode)
-
- https://uefi.org/sites/default/files/resources/ACPI_Spec_6_4_Jan22.pdf
-
-config PLATFORM_EC_AP_RESET_LOG
- bool "Enable the Application Processor reset log"
- depends on PLATFORM_EC_HOSTCMD_GET_UPTIME_INFO
- default y if PLATFORM_EC_POWERSEQ
- help
- Enable logging of AP reset events. This information is provided in
- response to the EC_CMD_GET_UPTIME_INFO host command.
-
-config PLATFORM_EC_BACKLIGHT_LID
- bool "Control the display backlight based on the lid switch"
- depends on PLATFORM_EC_HOSTCMD
- default y
- help
- Support controlling the display backlight based on the state of the
- lid switch. The EC will disable the backlight when the lid is closed.
-
- This option enables the EC_CMD_SWITCH_ENABLE_BKLIGHT host command,
- which allows the AP to override the backlight setting until the next
- change in the lid state.
-
-config PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON
- bool "Work around H1 reset issue"
- help
- Enable this if H1 resets the EC after power-on. This is needed so the EC
- can delay its start-up until the reset happens. Without this option
- the EC starts up, performs some amount of processing and then gets a
- reset that it is not expecting.
-
-config PLATFORM_EC_WAIT_RESET_CYCLES_PER_ITERATION
- int "CPU execution cycle per iteration for waiting the H1 reset"
- default 4
- depends on PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON
- help
- This options specifies the number of CPU execution cycles per delay
- loop iteration, while waiting for the H1 to reset.
-
-config PLATFORM_EC_PREINIT_HW_CYCLES_PER_SEC
- int "CPU power up clock cycle per second"
- default 100000000
- depends on PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON
- help
- This option specifies the frequency (in Hz) of the CPU core when
- coming out of a power on reset.
-
-config PLATFORM_EC_BRINGUP
- bool "Enable early bringup debugging features"
- help
- Enable the CONFIG_BRINGUP platform/ec configuration option,
- turning on a variety of miscellaneous early bringup
- debugging features.
-
- These features include:
- - The device will not power on when the EC starts. The
- power button will need to be pressed, or the "powerbtn"
- command issued.
- - Enable power signal logging, showing relative timestamps
- for each power signal change.
- - And more! You can search the codebase for CONFIG_BRINGUP
- to see all of the features this flag will toggle.
-
-config PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK
- bool "Bypass CBI EEPROM Write Protect"
- help
- Bypass the CBI EEPROM write protect checks. This should ONLY be
- defined during bringup, and should never be defined on a shipping or
- release platform.
-
- When defined, ectool can be used to reprogram all CBI fields,
- regardless of the state of the hardware write protect.
-
-config PLATFORM_EC_EEPROM_CBI_WP
- bool "EC can independently set the CBI EEPROM WP signal"
- help
- Define this if the EC can independently set the CBI EEPROM WP
- signal. The accompanying hardware must ensure that the CBI WP gets
- latched and is only reset when EC_RST_ODL is asserted.
- select PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK
-
-choice PLATFORM_EC_CBI_STORAGE_TYPE
- prompt "Select CBI storage Type"
- optional
- help
- CBI is a means for accessing board information, typically set
- during the factory process. This allows selection of the physical
- storage of CBI source.
-
- See here for detailed information on CBI:
-
- https://chromium.googlesource.com/chromiumos/docs/+/master/design_docs/cros_board_info.md
-
-config PLATFORM_EC_CBI_EEPROM
- bool "CBI EEPROM support"
- depends on PLATFORM_EC_I2C
- help
- Enables Chromium OS Board Info (CBI) from EEPROM.
-
- One must specify both I2C_PORT_EEPROM and I2C_ADDR_EEPROM_FLAGS to the
- CBI EEPROM's i2c port and 7-bit i2c address.
-
-config PLATFORM_EC_CBI_GPIO
- bool "CBI GPIO support"
- help
- Enables Chromium OS Board Info (CBI) from strapping pins. EC reads
- the BOARD ID and SKU ID from GPIOs and then substantiate in-memory
- CBI for AP to query.
-
-endchoice
-
-config PLATFORM_EC_CHIPSET_RESET_HOOK
- bool "Provide a hook for when the AP resets"
- default y
- help
- Enables support for the HOOK_CHIPSET_RESET hook. This can be used by
- code that needs to run before a programmatic reset actually happens.
- Note that these hooks don't run with a cold reset, only when the AP
- decides to reset itself.
-
- You can declare a hook like this:
-
- DECLARE_HOOK(HOOK_CHIPSET_RESET, do_something, HOOK_PRIO_DEFAULT);
-
- Then do_something() will be called just before the reset happens.
-
-config PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK
- bool "Enable chipset resume-init and suspend-complete hooks"
- help
- Enables support for the HOOK_CHIPSET_RESUME_INIT and
- HOOK_CHIPSET_SUSPEND_COMPLETE hooks. These hooks are usually used to
- initialize/disable the SPI driver, which goes to sleep on suspend.
- Require to initialize it first such that it can receive a host resume
- event, that notifies the normal resume hook.
-
-config PLATFORM_EC_CONSOLE_CMD_HCDEBUG
- bool "Console command: hcdebug"
- default y
- depends on PLATFORM_EC_HOSTCMD
- help
- Enable the 'hcdebug' console command. This comamnd is used to change,
- at runtime, the amount of debug generated by the host command
- processing.
-
- hcdebug [off | normal | every | params]
-
- See PLATFORM_EC_HOSTCMD_DEBUG_MODE for more detail.
-
-config PLATFORM_EC_CONSOLE_CMD_MEM
- bool "Console command: md, rw"
- default y
- help
- Enable memory related console commands.
-
- md - dump memory values
- rw - read or write in memory
-
-config PLATFORM_EC_CONSOLE_CMD_SLEEPMASK
- bool "Console command: sleepmask read"
- default y if PM
- help
- Enable the 'sleepmask' console command. This command is used to
- display the state of the sleep mask, which controls whether the EC
- chip is allowed to enter deep sleep states to save power.
-
-config PLATFORM_EC_CONSOLE_CMD_SLEEPMASK_SET
- bool "Console command: sleepmask set"
- depends on PLATFORM_EC_CONSOLE_CMD_SLEEPMASK
- default y
- help
- Enable changing the state of the current sleep mask.
-
- sleepmask on - Sets the SLEEP_MASK_FORCE_NO_DSLEEP bit in the
- sleep mask, preventing the system from entering
- sleep.
- sleepmask off - Clears the SLEEP_MASK_FORCE_NO_DSLEEP bit in the
- sleep mask. The system may enter deep sleep
- depending on the state of other mask bits.
- sleepmask <value> - Sets the sleepmask to <value>, overriding all
- bits with the specified value.
-
-config PLATFORM_EC_CONSOLE_CMD_S5_TIMEOUT
- bool "Console command: s5_timeout"
- default n
- help
- This command allows the user to specify a time to remain in S5 before
- dropping to G3, in order to help power testing.
-
-config PLATFORM_EC_CONSOLE_CMD_SHMEM
- bool "Console command: shmem"
- default y
- help
- This command prints basic information about the EC shared memory,
- located at the top of RAM, above all RAM symbols: total size, bytes
- used and the maximum number of bytes that have been used since
- the EC started running.
-
-config PLATFORM_EC_CROS_FWID_VERSION
- bool "Include CrOS FWID version"
- default y
- help
- Include Chrome OS FWID in version output. The CrOS FWID will be common
- across OS, AP firmware and EC firmware when built together.
-
-config PLATFORM_EC_DEBUG_ASSERT
- bool "Enable assertion failures"
- default y
- help
- Assertion failures are used to flag conditions which should not occur
- and thus indicate the software is unable to continue execution. This
- option can be disabled so that the assert() macro becomes a NOP. In
- this case, execution will continue but the results are unpredictable.
-
- Messages are of the form:
-
- ASSERTION FAILURE '<expr>' in function() at file:line
-
- Note: There is also ASSERT() which is an alias of assert(), used in
- host code where cstdlib is used.
-
-config PLATFORM_EC_DP_REDRIVER_TDP142
- bool "Include TDP142 DisplayPort redriver driver"
- default n
- help
- Include a driver for the Texas Instruments TDP142 DisplayPort linear
- redriver chip.
-
-config PLATFORM_EC_EMULATED_SYSRQ
- bool "Emulate sysrq events to AP"
- help
- The magic SysRq key is a key combo which allows the user to perform
- various low-level commands regardless of the system's state.
-
- See here for the key combos:
-
- https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html
-
- This option enables support for sending emulated SysRq events to AP
- (on designs with a keyboard, SysRq is passed as normal key presses).
-
-menuconfig PLATFORM_EC_ESPI
- bool "eSPI"
- depends on ESPI && AP
- default y
- help
- Enable the Enhanced Serial Peripheral Interface (eSPI) shim layer.
- eSPI supports a shared physical connection between several on-board
- devices, similar to SPI. It adds a few optional signals and a protocol
- layer to provide independent 'channels' for each device to communicate
- over.
-
- eSPI is the replacement for LPC (Low-Pin-Count bus).
-
- See here for information about eSPI:
-
- https://www.intel.com/content/dam/support/us/en/documents/software/chipset-software/327432-004_espi_base_specification_rev1.0_cb.pdf
-
-config PLATFORM_EC_EXTPOWER_GPIO
- bool "GPIO-based external power detection"
- depends on PLATFORM_EC_HOOKS && PLATFORM_EC_HOSTCMD
- help
- Enable shimming the extpower_gpio module, which provides
- GPIO-based external power presence detection features. The
- project should define a GPIO pin named GPIO_AC_PRESENT, with
- extpower_interrupt configured as the handler in gpio_map.h.
-
-config PLATFORM_EC_FLASH_CROS
- bool "Enable flash support"
- default y if FLASH_SIZE > 0
- help
- Enables access to the device's flash through a simple API. With
- this is it possible for the EC to update its flash while running,
- 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 && !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.
-
- For now this is only supported on Cortex-M4.
-
-config PLATFORM_EC_HOOKS
- bool "Hooks and deferred compatibility shim"
- default y
- help
- Enable translation of DECLARE_DEFERRED() and hook_call_deferred()
- to Zephyr's work queues, along with a compatible DECLARE_HOOK
- implementation.
-
- This option is needed by many features in the EC. Disabling it will
- likely cause build errors.
-
-menuconfig PLATFORM_EC_HOSTCMD
- bool "Host commands"
- default n if ARCH_POSIX
- default y if AP
- select HAS_TASK_HOSTCMD
- help
- Enable the host commands shim in platform/ec. This handles
- communication with the AP. The AP sends a command to the EC and it
- responds when able. An interrupt can be used to indicate to the AP
- that the EC has something for it.
-
-config PLATFORM_EC_HOSTCMD_GET_UPTIME_INFO
- bool "Host command: EC_CMD_GET_UPTIME_INFO"
- default PLATFORM_EC_HOSTCMD
- help
- Enable the EC_CMD_GET_UPTIME_INFO host command which reports the time
- the EC has been powered up, the number of AP resets, an optional log
- of AP-reset events and some flags.
-
-config PLATFORM_EC_HOSTCMD_REGULATOR
- bool "Host command of voltage regulator control"
- help
- Enable host commands (EC_CMD_REGULATOR_) for controlling voltage
- regulator. The board should also implement board functions defined in
- include/regulator.h.
-
-choice PLATFORM_EC_HOSTCMD_DEBUG_MODE
- prompt "Select method to use for HostCmd Debug Mode"
- depends on PLATFORM_EC_HOSTCMD
- default HCDEBUG_NORMAL
- help
- Sets the value of the host command debug mode to use on
- startup.
-
-config HCDEBUG_OFF
- bool "Host command debug mode OFF"
- help
- No host command debug messages are shown. Host
- command error messages will still output.
-
-config HCDEBUG_NORMAL
- bool "Host command debug mode NORMAL"
- help
- Display host commands receieved from the AP. Repeated
- commands are shown with a "+" and "++" symbol.
-
-config HCDEBUG_EVERY
- bool "Host command debug mode EVERY"
- help
- Display all host commands received from the AP,
- including repeated commands.
-
-config HCDEBUG_PARAMS
- bool "Host command debug mode PARAMS"
- help
- Display all host commands and the parameters received
- from the AP.
-
-endchoice # PLATFORM_EC_HOSTCMD_DEBUG_MODE
-
-config PLATFORM_EC_I2C
- bool "I2C shim"
- default n if ARCH_POSIX
- default y
- imply I2C
- help
- Enable compilation of the EC i2c module. Once enabled, it will be
- possible to make calls using the old platform/ec i2c APIs defined
- in include/i2c.h and implemented in common/i2c_master.c. Doing so
- should make shimming other platform/ec modules which rely on i2c
- communication "just work" without requiring any further code changes.
-
-config PLATFORM_EC_I2C_DEBUG
- bool "I2C Tracing"
- default n if ARCH_POSIX
- depends on PLATFORM_EC_I2C
- help
- This option enables I2C bus communication tracing. Use the console
- command "i2ctrace" to enable and disable tracing on specific I2C
- peripherals.
-
- Please see the I2C debugging documentation for more details:
-
- https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/ec/docs/i2c-debugging.md
-
-config PLATFORM_EC_I2C_DEBUG_PASSTHRU
- bool "I2C Passthru Debug"
- default n if ARCH_POSIX
- depends on PLATFORM_EC_I2C
- help
- This option enables extra debug for I2C passthru operations initiated
- by the AP.
-
-config PLATFORM_EC_CONSOLE_CMD_I2C_PORTMAP
- bool "Console command: i2c_portmap"
- default y
- depends on PLATFORM_EC_I2C
- help
- Enable the 'i2c_portmap' console command. This comamnd is used to
- display the mapping of the I2C ports defined by the named-i2c-ports
- node to the physical port and remote port indexes.
-
-config PLATFORM_EC_CONSOLE_CMD_I2C_SPEED
- bool "Console command: i2cspeed"
- default n
- depends on PLATFORM_EC_I2C
- help
- Enable the 'i2cspeed' console command. This comamnd is used to
- display an I2C port's bus speed. Additionally, for ports with
- the DYNAMIC_SPEED port flag set, the speed can be set. In all
- cases, the bus speed is in units of kHz.
-
-config PLATFORM_EC_SMBUS_PEC
- bool "Packet error checking support for SMBus"
- help
- If enabled, adds error checking support for i2c_readN, i2c_writeN,
- i2c_read_string and i2c_write_block. Where
- - write operation appends an error checking byte at end of transfer, and
- - read operatoin verifies the correctness of error checking byte from the
- slave.
- Set I2C_FLAG on addr_flags parameter to use this feature.
-
- This option also enables error checking function on smart batteries.
-
-config PLATFORM_EC_LID_SWITCH
- bool "Lid switch"
- help
- Enable shimming the lid switch implementation and related
- commands in platform/ec. The lid switch can affect power-on
- behaviour. For example, when the lid is opened, the device may
- automatically power on.
-
- This requires a GPIO named GPIO_LID_OPEN to be defined in gpio_map.h.
-
-config PLATFORM_EC_MKBP_INPUT_DEVICES
- bool "Input devices via MKBP"
- help
- Enable passing events from various input sources to AP via MKBP.
- This include buttons (power, volume); switches (lid, tablet mode)
- and sysrq.
-
-config PLATFORM_EC_LOW_POWER_IDLE
- bool
- default y if PM
- help
- Enable low power idle modes in the EC chipset. This is automatically
- enabled when the Zephyr power management options are enabled with the
- PM option.
-
-config PLATFORM_EC_MKBP_EVENT
- bool "MKBP event"
- help
- Enable this to support MKBP event. MKBP event is used not only
- for matrix keyboard but also for other many events like button,
- switch, fingerprint, and etc.
-
- This requires a MKBP event delivery method(GPIO, HOST_EVENT, and etc)
-
-config PLATFORM_EC_MKBP_EVENT_WAKEUP_MASK
- bool "MKBP event wakeup mask"
- depends on PLATFORM_EC_MKBP_EVENT
- help
- Enable which MKBP events should wakeup the system in suspend.
- For example:
- The MKBP events are enabled in the devicetree by the wakeup-mask
- property of the ec-mkbp-event-wakeup-mask node as follows:
- wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | \
- MKBP_EVENT_HOST_EVENT | \
- MKBP_EVENT_SENSOR_FIFO)>;
- The mkbp events are defined in dt-bindings/wake_mask_event_defines.h
-
-config PLATFORM_EC_MKBP_HOST_EVENT_WAKEUP_MASK
- bool "MKBP host event wakeup mask"
- depends on PLATFORM_EC_MKBP_EVENT
- help
- Enable which host events should wakeup the system in suspend.
- For example:
- The host events are enabled in the devicetree by the wakeup-mask
- property of the ec-mkbp-host-event-wakeup-mask node as follows:
- wakeup-mask = <(HOST_EVENT_LID_OPEN | \
- HOST_EVENT_POWER_BUTTON | \
- HOST_EVENT_AC_CONNECTED)>;
- The host events are defined in dt-bindings/wake_mask_event_defines.h
-
-config PLATFORM_EC_MPU
- bool "Support Memory-Protection Unit (MPU)"
- depends on CPU_CORTEX_M
- select ARM_MPU
- default y
- help
- This enables support a Memory-Protection Unit which can limit access
- to certain areas of memory. This can be used to protect code or data
- from being written to improve security or to find bugs.
-
- It causes any code in the iram.text section to be protected when
- system jump is disabled (see system_disable_jump()). It also stops
- execution of the image that is not currently being executed (read-only
- or read-write). If internal storage is used, this is achieved by not
- allowing code execution in that area. For external storage, it
- disallows loading any code into RAM.
-
-config PLATFORM_EC_PANIC
- bool "Panic output"
- default y
- help
- Enable support for collecting and reporting panic information,
- caused by exceptions in the EC. This can be the result of a watchdog
- firing, a division by zero, unaligned access, stack overflow or
- assertion failure.
-
- The panic information is made available to the AP via the
- EC_CMD_GET_PANIC_INFO host command and a 'panicinfo' console command
-
-config PLATFORM_EC_PORT80
- bool "Port 80 support"
- default y if AP_X86 && PLATFORM_EC_POWERSEQ
- help
- Enable the port80 module, a way to report progress of the AP's boot
- sequence, assuming that the EC can detect these writes on the I/O
- bus. The EC buffers calls to port_80_write() and occasionally prints
- a message when there are new writes.
-
- See here for more information:
-
- https://en.wikipedia.org/wiki/Power-on_self-test#Progress_and_error_reporting
-
-config PLATFORM_EC_POWER_BUTTON
- bool "Power-button support"
- depends on PLATFORM_EC_HOSTCMD
- help
- Enable shimming the power button implementation and related
- commands in platform/ec. This is used to implement the Chromium OS
- shutdown sequence.
-
- This requires a GPIO named GPIO_POWER_BUTTON_L in gpio_map.h.
-
-config PLATFORM_EC_PWM
- bool "PWM (Pulse Width Modulation) module"
- help
- Enable the PWM (Pulse Width Modulation) module. This module is used to
- support variable brightness LEDs, backlight controls, and
- variable-speed fans.
-
-config PLATFORM_EC_PWM_DISPLIGHT
- bool "PWM display backlight"
- depends on PLATFORM_EC_PWM
- help
- Enables display backlight controlled by a PWM signal connected
- directly to the EC chipset. The board files must define the C
- reference PWM_CH_DISPLIGHT to the PWM channel used for the
- display backlight control.
-
-config PLATFORM_EC_RTC
- bool "Real-time clock (RTC)"
- help
- Enable support for a real-time clock. Typically this is available
- on-chip in the EC. It provides a way to track the passage of time
- in terms of second and minutes. Once set, and provided that it has a
- suitable power source, it should be able to keep reasonably accurate
- time over a period of days and weeks.
-
- The starting EC clock is typically set by the AP, since it has access
- to the outside world and can often obtain the current time when
- desired.
-
-choice "SHA256 method"
- prompt "Select method to use for computing SHA256 hashes"
- help
- The verified boot mechanism requests the hash of the entire read-write
- portion of the EC image. This is typically done using a hashing block
- in the EC, so that it is as fast as possible. A fallback software
- algorithm is available if needed.
-
-config PLATFORM_EC_SHA256_SW
- bool "Compute SHA256 in software"
- help
- Enable this if your EC chip does not support hardware-accelerated
- SHA256 computation. This enables the software algorithm which is
- quite slow but will work in a pinch.
-
-config PLATFORM_EC_SHA256_HW_ACCELERATE
- bool "Compute SHA256 in hardware"
- help
- Enable this if your EC chip supports hardware-accelerated SHA256
- computation. This is faster than running the algorithm in software,
- so is desirable.
-
- The chip support must implement the functions in sha256.h
-
-endchoice # SHA256 method
-
-config PLATFORM_EC_SWITCH
- bool "Memory mapped switches"
- depends on PLATFORM_EC_HOSTCMD
- default y
- help
- Enable the reporting of the platform switches state to the AP using
- memory mapped storage provided by the host command interface.
-
- The platform switches include:
- LID open
- power button pressed
- write protect disabled
- recovery 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"
- 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
- help
- Enable support for the LION Semiconductor LN9310 switched
- capacitor converter. This will export definitions for
- ln9310_init, ln9310_interrupt, and ln9310_power_good, which
- project-specific code should call appropriately if there's
- no switchcap node in device tree.
-
-endchoice
-
-config PLATFORM_EC_SYSTEM_UNLOCKED
- bool "System unlocked: allow dangerous commands while in development"
- default y if PLATFORM_EC_BRINGUP
- help
- System should remain unlocked even if write protect is enabled.
-
- NOTE: This should ONLY be defined during bringup, and should never be
- defined on a shipping / released platform.
-
- When defined, CBI allows ectool to reprogram all the fields.
- Normally, it refuses to change certain fields. (e.g. board version,
- OEM ID)
-
- Also, this enables PD in RO for TCPMv2.
-
-config PLATFORM_EC_THROTTLE_AP
- bool "CPU throttling"
- help
- Enable throttling the CPU based on the temperature sensors. When they
- detect that the CPU is getting too hot, the CPU is throttled to
- a lower speed. This reduce the CPU's power output and eventually
- results in a lower temperature.
-
-menuconfig PLATFORM_EC_TIMER
- bool "Timer module"
- default y
- help
- Enable compilation of the EC timer module. This provides support for
- delays, getting the current time and setting alarms.
-
- This option is needed by many features in the EC. Disabling it will
- likely cause build errors.
-
-config PLATFORM_EC_VBOOT_EFS2
- bool "EFS2 verified EC boot"
- default y if !SOC_POSIX
- help
- Enables Early Firmware Selection v2 (EFS2) verified boot. When booting
- a Chromium OS image we're actually packing both an RO image and an RW
- image into flash. The RO image is loaded first. EFS2 runs at boot and
- verifies the integrity of the RW image by sending a hash of the image
- to the Google Security Chip (GSC). Once the GSC verifies the hash,
- EFS2 calls sysjump and reboot the EC using the RW image.
-
-config PLATFORM_EC_VBOOT_HASH
- bool "Host command: EC_CMD_VBOOT_HASH"
- depends on PLATFORM_EC_HOSTCMD
- default y
- help
- Allows the AP to request hashing functions from the EC.
-
- Verified boot can update the EC's read/write code when it detects
- that it is an incorrect version. It detects this by asking the EC to
- hash itself. If the hash is incorrect, new code is write to the EC's
- read/write area.
-
-config PLATFORM_EC_VSTORE
- bool "Secure temporary storage for verified boot"
- default y
- help
- Enable support for storing a block of data received from the AP so it
- can be read back later by the AP. This is helpful since the AP may
- reboot or resume and want the data early in its start-up before it
- has access to SDRAM.
-
- There are a fixed number of slots and each can hold a fixed amount of
- data (EC_VSTORE_SLOT_SIZE bytes). Once a slot is written it is locked
- and cannot be written again unless explicitly unlocked.
-
- Stored data is preserved when the EC moved from RO to RW.
-
-config PLATFORM_EC_VSTORE_SLOT_COUNT
- int "Number of slots"
- depends on PLATFORM_EC_VSTORE
- default 1
- help
- Set the number of slots available in the verified-boot store. The
- number required depends on the AP firmware. Typically the vstore is
- used only for recording a hash of the read-write AP firmware for
- checking on resume. For this, one slot is enough.
-
-menuconfig PLATFORM_EC_WATCHDOG
- bool "Watchdog"
- depends on WATCHDOG
- default y
- help
- Enable the watchdog functionality. The watchdog timer will reboot the
- system if the hook task (which is the lowest-priority task on the
- system) gets starved for CPU time and isn't able to fire its
- HOOK_TICK event.
-
- Chromium EC system uses an auxiliary timer to handle the system
- warning event. This leaves some time to the system for preparing &
- printing the debug information. The interval between reloads of the
- watchdog timer should be less than half of the auxiliary timer
- (PLATFORM_EC_WATCHDOG_PERIOD_MS -
- PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS).
-
-config PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API
- bool "Workaround needed for npcx9 ES1 chip"
- depends on SOC_SERIES_NPCX9
- help
- There's a bug in the flash download API on the ES1 version of the
- npcx9 chips that requires some workarounds. This is needed for sysjump
- to work properly.
-
-config PLATFORM_EC_ASSERT_CCD_MODE_ON_DTS_CONNECT
- bool "Assert CCD Mode"
- help
- Assert CCD_MODE_ODL when a DTS debug accessory is connected to the
- CCD USBC port. GPIO_CCD_MODE_ODL should be configured with
- GPIO_ODR_HIGH flag.
-
-config PLATFORM_EC_CCD_USBC_PORT_NUMBER
- int "CCD USB Port Number"
- default 0
- help
- USB port number of the CCD enabled USBC port.
-
-config PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
- bool "Restrict I2C PASSTHRU command"
- depends on PLATFORM_EC_I2C
- help
- Enables board-specific restrictions for the I2C PASSTHRU host command.
- Once enabled, board_allow_i2c_passthru function has to be implemented,
- which defines the allowed usage of the command.
-
-config PLATFORM_EC_HOST_COMMAND_STATUS
- bool "Return in-progress status for slow host commands"
- default n
- help
- When the AP is attached to the EC via a serialized bus such as I2C or
- SPI, it needs a way to minimize the length of time an EC command will
- tie up the bus (and the kernel driver on the AP). If this config is
- defined, the EC may return an in-progress result code for slow
- commands such as flash erase/write instead of stalling until the
- command finishes processing, and the AP may then inquire the status
- of the current command and/or the result of the previous command.
-
-config PLATFORM_EC_AMD_SB_RMI
- bool "Enable driver for AMD SB-RMI interface"
- help
- AMD platforms provide the Side-Band Remote Management Interface.
- SB-RMI provides an interface for an external SMBus master to perform
- tasks such as managing power consumption and power limits of the CPU
- socket.
-
-config PLATFORM_EC_AMD_STT
- bool "Enable driver for AMD STT interface"
- depends on PLATFORM_EC_AMD_SB_RMI
- help
- AMD platforms provide the Skin Temperature Tracking (STT) interface.
- Skin temperature management can be used to maximize the system
- performance while keeping the skin temperature within its
- specification. It makes use of the thermal capacitance of the system
- to temporarily boost above the sustainable power limit, while the
- chassis skin temperatures are below limits.
-
-endif # PLATFORM_EC
diff --git a/zephyr/Kconfig.accelgyro_bmi b/zephyr/Kconfig.accelgyro_bmi
deleted file mode 100644
index bb8239f6d8..0000000000
--- a/zephyr/Kconfig.accelgyro_bmi
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-
-if PLATFORM_EC_ACCELGYRO_BMI
-menu "BMI Sensor Common"
-
-choice PLATFORM_EC_ACCELGYRO_BMI_COMM
- prompt "Accelgyro BMI's communication mode"
- help
- When using the BMI drivers, there's the option to communicate with the
- chip via several methods. This choice helps improve code size by only
- compiling the needed communication channels.
-
-config PLATFORM_EC_ACCELGYRO_BMI_COMM_SPI
- bool "Use SPI communication"
- help
- The BMI chip is using SPI communication. This config value is used to
- save on code size as only the SPI communication code will be included
- for the BMI chip.
-
-config PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C
- bool "Use I2C communication"
- help
- The BMI chip is using I2C communication. This config value is used to
- save on code size as only the I2C communication code will be included
- for the BMI chip.
-
-endchoice
-
-endmenu # BMI Sensor
-endif # PLATFORM_EC_ACCELGYRO_BMI \ No newline at end of file
diff --git a/zephyr/Kconfig.accelgyro_icm b/zephyr/Kconfig.accelgyro_icm
deleted file mode 100644
index 2bee9184b5..0000000000
--- a/zephyr/Kconfig.accelgyro_icm
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-
-if PLATFORM_EC_ACCELGYRO_ICM
-menu "ICM Sensor Common"
-
-choice PLATFORM_EC_ACCELGYRO_ICM_COMM
- prompt "Accelgyro ICM's communication mode"
- help
- When using the ICM drivers, there's the option to communicate with the
- chip via several methods. This choice helps improve code size by only
- compiling the needed communication channels.
-
-config PLATFORM_EC_ACCELGYRO_ICM_COMM_SPI
- bool "Use SPI communication"
- help
- The ICM chip is using SPI communication. This config value is used to
- save on code size as only the SPI communication code will be included
- for the ICM chip.
-
-config PLATFORM_EC_ACCELGYRO_ICM_COMM_I2C
- bool "Use I2C communication"
- help
- The ICM chip is using I2C communication. This config value is used to
- save on code size as only the I2C communication code will be included
- for the ICM chip.
-
-endchoice
-
-endmenu # ICM Sensor
-endif # PLATFORM_EC_ACCELGYRO_ICM \ No newline at end of file
diff --git a/zephyr/Kconfig.adc b/zephyr/Kconfig.adc
deleted file mode 100644
index a1e3bd63eb..0000000000
--- a/zephyr/Kconfig.adc
+++ /dev/null
@@ -1,62 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-menuconfig PLATFORM_EC_ADC
- bool "ADC shim"
- default n if ARCH_POSIX
- default y
- imply ADC
- help
- Enable compilation of the EC ADC module. Once enabled, it is
- possible to call platform/ec adc_read_channel() function.
-
-if PLATFORM_EC_ADC
-
-# Chromium EC provides it's own "adc" command. Disable the Zephyr
-# built-in ADC shell command.
-# TODO(b:188434233) Investigate moving to zephyr adc shell
-config ADC_SHELL
- default n
-
-config PLATFORM_EC_ADC_CMD
- bool "ADC host/console command"
- default y
- help
- Enables support for printing ADC channels state with the "adc"
- console command and reading a state of ADC channel with the
- EC_CMD_ADC_READ host command. Replaces generic Zephyr "adc"
- command.
-
-config PLATFORM_EC_ADC_RESOLUTION
- int "ADC resolution"
- default 10
- help
- The resolution, in bits, to use for the ADC conversion. Determines
- the sample values range: 0 .. 2^resolution -1. The supported
- resolution values depend on specific hardware.
-
-config PLATFORM_EC_ADC_OVERSAMPLING
- int "ADC oversampling"
- default 0
- help
- ADC oversampling to use for the ADC conversion. Each sample is
- averaged from 2^oversampling conversion results. Oversampling can
- help in providing more stable readings. The supported oversampling
- values depend on specific hardware.
-
-config PLATFORM_EC_ADC_CHANNELS_RUNTIME_CONFIG
- bool "ADC runtime config"
- default n
- help
- Allows the configuration of the ADC channels to be set up at
- runtime. This makes the adc_channels[] array writable,
- i.e. not const. It should be declared as such in the board
- config.
-
- This is useful when the board has runtime information that
- changes the configuration, such as board revision information.
- Without this, multiple EC images would need to be installed
- depending on the board.
-
-endif # PLATFORM_EC_ADC
diff --git a/zephyr/Kconfig.battery b/zephyr/Kconfig.battery
deleted file mode 100644
index c1753ccefc..0000000000
--- a/zephyr/Kconfig.battery
+++ /dev/null
@@ -1,491 +0,0 @@
-# Copyright 2020 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.
-
-menuconfig PLATFORM_EC_BATTERY
- bool "Battery support"
- select HAS_TASK_CHARGER
- help
- Enables battery support on the board. Requires selection of a battery
- and a charger IC.
-
- If using I2C batteries, you must define I2C_PORT_BATTERY in your
- board's i2c_map.h file so that the EC code will know which I2C
- port the battery is on.
-
-if PLATFORM_EC_BATTERY
-
-choice "Battery select"
- prompt "Select the battery to use"
- help
- Select the battery used on the board. If you are ensure, select the
- smart battery option.
-
-config PLATFORM_EC_BATTERY_SMART
- bool "Support a smart battery"
- depends on PLATFORM_EC_I2C
- help
- Many batteries support the Smart Battery Specification and therefore
- have common registers which can be accessed to control and monitor
- the battery.
-
- See here for the spec: http://sbs-forum.org/specs/sbdat110.pdf
-
-endchoice
-
-choice "Battery presence detection"
- prompt "Method to use to detect the battery"
- help
- This selects the method to use to detect the presence of a battery.
-
- Battery detection is important since it can be used to indicate that
- the case is open, so security features can be disabled. It is also
- useful to report to the user when the battery is missing, e.g. with
- a desktop icon.
-
-config PLATFORM_EC_BATTERY_PRESENT_CUSTOM
- bool "Call a board-provided function"
- help
- Use this method to provide a board-provided battery_is_present()
- function to determine whether the battery is currently present.
- This should be implemented in the board code and can use any
- reasonable method to detect the battery.
-
-config PLATFORM_EC_BATTERY_PRESENT_GPIO
- bool "Check a GPIO"
- help
- Use this method if a GPIO signals whether the battery is present. The
- GPIO should read low if the battery is present, high if absent.
-
- The GPIO is hard-coded to GPIO_BATT_PRES_ODL so you should define this
- in the device tree and GPIO map. The convention is to use the signal
- name from schematic as both the node name and label for the GPIO. For
- example:
-
- /* gpio.dts */
- ec_batt_pres_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- label = "EC_BATT_PRES_ODL";
- };
-
- /* gpio_map.h */
- #define GPIO_BATT_PRES_ODL NAMED_GPIO(ec_batt_pres_odl)
-
-endchoice # battery presence
-
-config PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY
- bool "Provide information about battery chemistry"
- help
- Enable this to specify the chemistry of the battery device. It is
- only used for stress testing of reading the battery information over
- I2C.
-
-config PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY
- string "Battery-device chemistry"
- depends on PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY
- help
- Specify the battery chemistry for use with the I2C stress test.
- The value provided here must match what is read from the real
- battery. This is used in sb_i2c_test_read() to check that the battery
- is returning the right information. If it is not, there might be
- something wrong with the I2C implementation.
-
-config PLATFORM_EC_I2C_VIRTUAL_BATTERY
- bool "I2C virtual battery"
- help
- Enables driver for a virtual battery. It is used to minimalize I2C
- traffic which is generated by the I2C_PASSTHRU host command.
- The battery parameters, which are already cached in EC are used to
- return desired data to host instead of issuing I2C transaction every
- time.
-
-choice "Charger select"
- prompt "Select the charger to use"
- help
- Select the battery charger IC used on the board. Only one charger may
- be selected.
-
-config PLATFORM_EC_CHARGER_ISL9237
- bool "Use the ISL9237 charger"
- depends on PLATFORM_EC_I2C
- select PLATFORM_EC_CHARGER_NARROW_VDC
- select PLATFORM_EC_CHARGER_OTG_SUPPORTED
- help
- Enables a driver for the ISL9237 VCD Battery Charger. This is a
- digitally-configurable, buck-boost battery charger that supporting
- Narrow Voltage Direct Charging (NVDC). It supports an input voltage
- range of 3.2-23.4V and output of 2.4-13.8V. It provides an I2C
- interface for configuration an provides a USB On-The-Go (OTG)
- function for 2- and 3-cell battery applications.
-
-config PLATFORM_EC_CHARGER_ISL9238
- bool "Use the ISL9238 charger"
- depends on PLATFORM_EC_I2C
- select PLATFORM_EC_CHARGER_NARROW_VDC
- select PLATFORM_EC_CHARGER_OTG_SUPPORTED
- help
- Enables a driver for the ISL9238 VCD Battery Charger. This is a
- digitally-configurable, buck-boost battery charger that supporting
- Narrow Voltage Direct Charging (NVDC). It supports an input voltage
- range of 3.2-23.4V and output of 2.4-18.3V. It provides an I2C
- interface for configuration.
-
-config PLATFORM_EC_CHARGER_ISL9238C
- bool "Use the ISL9238 Rev C charger"
- depends on PLATFORM_EC_I2C
- select PLATFORM_EC_CHARGER_NARROW_VDC
- select PLATFORM_EC_CHARGER_OTG_SUPPORTED
- help
- Enable a driver for the ISL9238 Rev C VCD Battery Charger. This
- is a digitally-configurable, buck-boost battery charger that
- supporting Narrow Voltage Direct Charging (NVDC). It supports an input
- voltage range of 3.2-23.4V and output of 2.4-18.3V. It provides an I2C
- interface for configuration.
-
- This option is separate from PLATFORM_EC_CHARGER_ISL9238 since there
- is no way in software to distinguish between rev. A/B and rev. C.
-
-config PLATFORM_EC_CHARGER_ISL9241
- bool "Use the ISL9241 charger"
- depends on PLATFORM_EC_I2C
- # Hardware based charge ramp is broken in the ISL9241 (b/169350714)
- select PLATFORM_EC_CHARGER_CHGRAMP_BROKEN
- help
- Enables a driver for the ISL9241 VCD Battery Charger. This is a
- digitally-configurable, buck-boost battery charger that can support
- both Narrow Voltage Direct Charging (NVDC) and Hybrid Power Buck Boost
- (HPBB/Bypass) charging and switch between the modes under firmware
- control. It supports an input voltage range of 3.9-23.4V and output
- of 3.9-18.3V. It provides an I2C interface for configuration.
-
-config PLATFORM_EC_CHARGER_BQ25710
- bool "Use the BQ25710 charger"
- depends on PLATFORM_EC_I2C
- select PLATFORM_EC_CHARGER_NARROW_VDC
- help
- Enables the driver for the TI BQ25710 battery charger
- controller. This is a synchronous narrow voltage DC buck-boost
- battery charger for one to four battery cell applications. A
- wide range of input power sources are supported such as high
- voltage USB-C power delivery.
-
-config PLATFORM_EC_CHARGER_BQ25720
- bool "Use the BQ25720 charger"
- depends on PLATFORM_EC_I2C
- select PLATFORM_EC_CHARGER_NARROW_VDC
- help
- Enables the driver for the TI BQ25720 battery charger
- controller. This is a synchronous narrow voltage DC buck-boost
- battery charger for one to four battery cell applications. A
- wide range of input power sources are supported such as high
- voltage USB-C power delivery.
-
-endchoice # "Charger select"
-
-config PLATFORM_EC_CHARGER_DISCHARGE_ON_AC
- bool "Board supports discharge mode"
- help
- Enable this if the board supports discharging the battery even when
- AC power is present. This is used for testing. The function is
- provided either by the charger or by custom code in the board.
-
-if PLATFORM_EC_CHARGER_DISCHARGE_ON_AC
-
-choice "Discharge control method"
- prompt "Select the method of controlling discharge"
- help
- Select which method is provided to enable and disable the discharge
- mode.
-
-config PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER
- bool "Charger controls discharge mode"
- help
- Enable this if the charger controls selection of discharge mode.
- In this case the charger must provide a function:
-
- int charger_discharge_on_ac(int enabled)
-
- It should enable this feature if enabled is true, else disable it.
- The function should return EC_SUCCESS
-
-config PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CUSTOM
- bool "Custom control of discharge mode"
- help
- Enable this if the discharge mode is controlled by a custom function.
- This function is typically provided by the board implementation:
-
- int board_discharge_on_ac(int enabled)
-
- It should enable this feature if enabled is true, else disable it.
- The function should return EC_SUCCESS
-
-endchoice # "Discharge control method"
-
-endif # PLATFORM_EC_CHARGER_DISCHARGE_ON_AC
-
-config PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM
- bool "VSYS_TH2 override"
- depends on PLATFORM_EC_CHARGER_BQ25720
- help
- Enable customizing the charger's VSYS_TH2 threshold.
-
-config PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_DV
- int "VSYS threshold 2 in deci-volts"
- range 32 95
- default 32
- depends on PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM
- help
- Sets the VSYS threshold 2 in deci volts. This is the first
- threshold that will be encountered when VSYS droops, typically
- due to high power demand from the main processor. The charger
- chip reacts by asserting PROCHOT which the main processor uses
- as an indication to throttle back and reduce power demand. The
- charger chip uses default thresholds which may be low enough
- to cause system instability. The default for 1S batteries is
- 3.2v and 5.9v for 2S or higher batteries. The valid range is
- 3.2v - 3.9v for 1S and 3.2 - 9.5v for 2S or higher batteries.
-
-config PLATFORM_EC_CHARGER_MAINTAIN_VBAT
- bool "Maintain VBAT voltage regardless of AC state"
- help
- Leave the charger VBAT configured to battery-requested voltage under
- all conditions, even when AC is not present. This may be necessary to
- work around quirks of certain charger chips, such as the BD9995X.
-
-config PLATFORM_EC_CHARGER_NARROW_VDC
- bool
- help
- Select this if the charger uses a Narrow Voltage Direct Charging.
- Narrow VDC (NVDC) reduces power loss by reducing the voltage range of
- the VDC node. This reduction is accomplished by replacing the
- battery-charger circuit with a system-charger voltage regulator, thus
- narrowing the VDC range. This in turn enables DC/DC converter
- optimisations in the system and allows the removal of the power-path
- switch, saving additional power, board area, and cost.
-
- This should be enabled by charger drivers which need it. It cannot
- be set otherwise, even in prj.conf
-
-config PLATFORM_EC_CHARGER_OTG_SUPPORTED
- bool
- help
- Indicates that the charger supports an OTG (On-The-Go) function,
- which allows supplying output power from the battery to a connected
- device.
-
- This should be enabled by charger drivers which support it. It cannot
- be set otherwise, even in prj.conf
-
-config PLATFORM_EC_CHARGER_OTG
- bool "Allow supplying output power from the battery"
- depends on PLATFORM_EC_CHARGER_OTG_SUPPORTED
- help
- Enable charger's OTG functions, i.e. make it possible to supply
- output power from the battery. This option is available if the
- selected charger supports it.
-
-config PLATFORM_EC_CHARGER_PROFILE_OVERRIDE
- bool "Override the charger profile"
- help
- Select this if the charger should call battery_override_params() to
- limit/correct the voltage and current requested by the battery pack
- before acting on the request.
-
- The board must provide this function:
-
- void battery_override_params(struct batt_params *batt);
-
- It may modify the parameters as needed.
-
-config PLATFORM_EC_CHARGER_PSYS
- bool "Support system power-monitor (PSYS) function"
- help
- Enable this to support monitoring of system power using the charger's
- PSYS function. The charger provides an output which can be read
- using an ADC channel on the EC.
-
-config PLATFORM_EC_CHARGER_PSYS_READ
- bool "Allow reading PSYS (system power) value"
- depends on PLATFORM_EC_CHARGER_PSYS
- help
- Enable support for reading the system-power value (PSYS). This
- calls the function charger_get_system_power() which is provided
- by the charger.
-
- It also enables the "psys" console command.
-
- Sample output:
-
- PSYS from chg_adc: 456 mW
-
-config PLATFORM_EC_CHARGER_SENSE_RESISTOR
- int "Value of the charge sense-resistor, in mOhms"
- help
- The charge sense-resistor is used to detect the charge current to the
- battery. Its value must be known for the calculation to be correct.
- The value is typically around 10 mOhms.
-
-config PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC
- int "Value of the input sense-resistor, in mOhms"
- help
- The input sense-resistor is used to detect the input current from the
- external AC power supply. Its value must be known for the calculation
- to be correct. The value is typically around 10 mOhms.
-
-config PLATFORM_EC_BATTERY_FUEL_GAUGE
- bool "Board supplies battery info"
- help
- The fuel gauge information is used to cut off the battery for shipping
- mode and to check the charge/discharge FET status. The battery
- information is used to set voltage, current and temperature operating
- limits for the battery.
-
-config PLATFORM_EC_CHARGER_CHGRAMP_BROKEN
- bool
- help
- This is selected if the charger's support for hardware-controlled
- charge ramping is broken. In some cases the charger has problems
- which make it unusable and we must fall back to software-controlled
- charge ramping.
-
- This should be enabled by charger drivers which need it. It cannot
- be set otherwise, even in prj.conf
-
-choice "Charge-ramp method"
- prompt "Select the charge-ramp method"
- help
- Select the method used for ramping up charging of a battery. It is
- preferred to use the hardware method if the charger chip can support
- it. If not, software-controlled charging can be used, with a slight
- increase in code size.
-
-config PLATFORM_EC_CHARGE_RAMP_HW
- bool "Hardware-controlled charging"
- depends on !PLATFORM_EC_CHARGER_CHGRAMP_BROKEN
- help
- Disables software control of ramping up charging. This is used when
- the hardware has a a mechanism for ramping input current and
- backing-off as needed.
-
-config PLATFORM_EC_CHARGE_RAMP_SW
- bool "Software-controlled charging"
- select HAS_TASK_CHG_RAMP
- help
- Enables ramping up charging from an external source to the maximum
- available within the source's limits and taking into account the
- current needs of the device. It handles the user plugging chargers in
- and removing them.
-
-endchoice # "Charge-ramp method"
-
-config PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON
- bool "Console command: amonbmon"
- help
- Enable the 'amonbmon' command. This shows the charger adapter-current
- monitor (AMON) and battery-charging current monitor (BMON).
-
- amonbmon a | b
-
-config PLATFORM_EC_CONSOLE_CMD_CHGRAMP
- bool "Console command: chgramp"
- depends on PLATFORM_EC_CHARGE_RAMP_SW
- default y
- help
- Enable the "chgramp" command. This shows the current state of the
- chg_ramp task. It shows the state of each port and the current limit
- for each port. The 'State' shown is from enum chg_ramp_state.
-
- Chg Ramp:
- State: 5
- Min ICL: 2000
- Active ICL: 2000
- Port 0:
- OC idx:0
- OC 0: s-1 oc_det0 icl0
- OC 1: s0 oc_det0 icl0
- OC 2: s0 oc_det0 icl0
- Port 1:
- OC idx:0
- OC 0: s-1 oc_det0 icl0
- OC 1: s0 oc_det0 icl0
- OC 2: s0 oc_det0 icl0
-
-config PLATFORM_EC_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF
- bool "Enable battery cut off on critical power level"
- help
- If this option is enabled, the battery will enter cut-off
- mode in case of critical power level.
-
-config PLATFORM_EC_BATTERY_CHECK_CHARGE_TEMP_LIMITS
- bool "Monitor battery temperature while charging"
- help
- Enable monitoring of battery temperature while charging and
- stop charging if is outside of the safe range.
-
-config PLATFORM_EC_BATTERY_CUT_OFF
- bool "Host/Console command: battery cut-off"
- help
- Enables support for disconnecting the battery using the "cutoff"
- console command and the EC_CMD_BATTERY_CUT_OFF host command.
- Once defined, a board specific board_cut_off_battery() function
- has to be provided.
-
-config PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM
- bool "Hardware check of battery presence"
- help
- Once defined, the charger will check a board specific function
- battery_hw_present() for battery hw presence as an additional
- condition to determine if power on is allowed for factory override,
- where allowing booting of a bare board with no battery and no power
- button press is required.
-
-config PLATFORM_EC_BATTERY_REVIVE_DISCONNECT
- bool "Check battery disconnect state"
- help
- Check for battery in disconnect state (similar to cut-off state).
- If this battery is found to be in disconnect state, take it out of
- this state by force-applying a charge current. Once defined,
- a battery_get_disconnect_state() function has to be provided.
-
-config PLATFORM_EC_BATTERY_MEASURE_IMBALANCE
- bool "Measure the battery cells imbalance"
- help
- Smart battery driver should measure the voltage cell imbalance in the
- battery pack.
- This requires a battery driver capable of the measurement.
- If enabled, the AP enabling may be prevented if battery is too
- imbalanced.
-
-config PLATFORM_EC_BATTERY_MAX_IMBALANCE_MV
- int "Max battery imbalance in millivolts"
- depends on PLATFORM_EC_BATTERY_MEASURE_IMBALANCE
- default 200
- help
- Imbalanced battery packs in this situation appear to have balanced
- charge very quickly after beginning the charging cycle, since dV/dQ
- rapidly decreases as the cell is charged out of deep discharge.
- Increasing the value of
- CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_IMBALANCED_POWER_ON will make a
- system tolerant of larger values of
- CONFIG_PLATFORM_EC_BATTERY_MAX_IMBALANCE_MV.
-
-config PLATFORM_EC_CHARGER_MIN_BAT_PCT_IMBALANCED_POWER_ON
- int "Minimum battery percentage for power on with an imbalanced pack"
- depends on PLATFORM_EC_BATTERY_MEASURE_IMBALANCE
- default 5
- range 0 100
- help
- If battery pack is in imbalanced state and current state of charge is
- below this value, the AP won't be powered on.
-
-config PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV
- int "Voltage limit in mV when battery is full and AP is off"
- depends on PLATFORM_EC_USB_PE_SM && PLATFORM_EC_CHARGE_MANAGER
- default -1
- help
- If set to a non-negative value, input voltage will be reduced to given
- value when chipset is in S5/G3 state and battery is fully charged.
- This condition is checked on chipset shutdown and startup, AC change
- and battery SOC change.
-
-endif # PLATFORM_EC_BATTERY
diff --git a/zephyr/Kconfig.board_version b/zephyr/Kconfig.board_version
deleted file mode 100644
index e24957764d..0000000000
--- a/zephyr/Kconfig.board_version
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-choice PLATFORM_EC_BOARD_VERSION_SOURCE
- prompt "Select the source of the board version number"
- optional
- help
- This allow selection of the source of the board version number
- information. Several options are available, but BOARD_VERSION_CBI is
- preferred for new boards, so long as the hardware supports it (i.e.
- has an EEPROM).
-
-config PLATFORM_EC_BOARD_VERSION_CBI
- bool "Chromium OS Board Info (CBI)"
- depends on PLATFORM_EC_CBI_EEPROM
- help
- Choose this if the board version comes from Chromium Board Info
- within the EEPROM. This is the recommended approach and is used on
- newer boards. The version information is written into the EEPROM as
- part of the factory process.
-
-config PLATFORM_EC_BOARD_VERSION_GPIO
- bool "Strapping GPIOs"
- help
- Choose this if the board version is encoded with three GPIO signals
- (GPIO_BOARD_VERSION1, GPIO_BOARD_VERSION2 and GPIO_BOARD_VERSION3)
- forming the 3-digit binary number. GPIO_BOARD_VERSION1 is the LSB.
- This provides 8 possible combinations.
-
- The GPIOs should have external pull-up/pull-down resistors installed
- at the factory to select the correct value.
-
-endchoice
diff --git a/zephyr/Kconfig.console b/zephyr/Kconfig.console
deleted file mode 100644
index 04e1d137bd..0000000000
--- a/zephyr/Kconfig.console
+++ /dev/null
@@ -1,69 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-config PLATFORM_EC_CONSOLE_CHANNEL
- bool "Console channels"
- depends on CONSOLE
- default y
- help
- Make it possible for console to be output to different channels that
- can be turned on and off. Channels are organized by functional area
- such as "charger", "motionsense", "usbpd" and others.
-
- This is useful as a developer convenience when the console is crowded
- with messages, to make it easier to use the interactive console.
-
- The `chan` console command with no arguments shows all available
- channels.
-
- FAFT and servod also use this feature.
-
- Boards may #undef this to reduce image size.
-
-# Adjusted to the longest print message from the timer_info command
-config SHELL_PRINTF_BUFF_SIZE
- default 130
-
-# Some boards may need to increase the size, depending on the amount of output
-#
-# TODO(b/196627937): zephyr: hang when running help with CONFIG_SHELL_HELP
-# enabled. Increase the TX buffer size to workaround the hang when the help
-# is enabled.
-config SHELL_BACKEND_SERIAL_TX_RING_BUFFER_SIZE
- default 4096 if SHELL_HELP
- default 1024
-
-menuconfig PLATFORM_EC_HOSTCMD_CONSOLE
- bool "Console Host Command"
- depends on PLATFORM_EC_HOSTCMD
- default y
- help
- Enable the EC_CMD_CONSOLE_SNAPSHOT and EC_CMD_CONSOLE_READ
- host commands, used for reading the EC console from the AP.
-
-if PLATFORM_EC_HOSTCMD_CONSOLE
-
-config PLATFORM_EC_HOSTCMD_CONSOLE_BUF_SIZE
- int "Console buffer size"
- default 4096
- help
- The EC will use a circular buffer to store bytes outputted
- to the console for the AP to read. This changes the maximal
- number of bytes from the console output which can be saved.
-
- Choosing a power-of-two for this value is optimal, as
- modular arithmetic is used.
-
-endif # PLATFORM_EC_HOSTCMD_CONSOLE
-
-config PLATFORM_EC_CONSOLE_USES_PRINTK
- bool "Console uses printk"
- depends on CONSOLE
- help
- Implement zephyr_print using printk for all cases instead
- of using shell_fprintf for non-ISR uses in
- shim/common/console.c.
- Some devices have not been able to output to the console
- fast enough using shell_fprintf and end up timing out
- unrelated functionality.
diff --git a/zephyr/Kconfig.console_cmd_mem b/zephyr/Kconfig.console_cmd_mem
deleted file mode 100644
index 4b69cc1778..0000000000
--- a/zephyr/Kconfig.console_cmd_mem
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC_CONSOLE_CMD_MEM
-config PLATFORM_EC_CONSOLE_CMD_MD
- bool "Console command: md"
- default y
- help
- Enable the "md" command. This dumps memory value from a specified
- address, optionally specifying the format.
-
- Example:
- md 0x64000000 10
-
- 64000000: 2a3b4d5e 030054e1 07000000 09297110
- 64000010: 00000010 03db4f00 03db5000 00000100
- 64000020: 00000000 00000000
-
-config PLATFORM_EC_CONSOLE_CMD_RW
- bool "Console command: rw"
- default y
- help
- Enable the "rw" command. This Read or write in memory optionally
- specifying the size.
-
- Example:
- rw 0x64000000
-
- read 0x64000000 = 0x2a3b4d5e
-
-endif # PLATFORM_EC_CONSOLE_CMD_MEM
diff --git a/zephyr/Kconfig.debug_assert b/zephyr/Kconfig.debug_assert
deleted file mode 100644
index d568bc7e34..0000000000
--- a/zephyr/Kconfig.debug_assert
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC_DEBUG_ASSERT
-choice "Behaviour on assertion failure"
- prompt "Select behaviour on assertion failure"
- help
- This selects the action taken when the board hits an assertion
- failure in the code. This should not happen in normal operation,
- but can appear during development when the code is not yet fully
- tested.
-
-config PLATFORM_EC_DEBUG_ASSERT_REBOOTS
- bool "Reboot"
- help
- Prints a message and reboot if an assert() macro fails at runtime.
- If PLATFORM_EC_SOFTWARE_PANIC is enabled then the information is
- written to the panic log before rebooting.
-
-config PLATFORM_EC_DEBUG_ASSERT_BREAKPOINT
- bool "Generate a breakpoint"
- help
- Immediately hits a breakpoint instruction (without printing a message)
- so that a connected JTAG debugger can be used to debug the problem
- from there. If there is no debugger connected then the breakpoint
- instruction will cause the board to reboot immediately.
-
-endchoice # "Behaviour on assertion failure"
-
-config PLATFORM_EC_DEBUG_ASSERT_BRIEF
- bool "Use brief assertion-failure messages"
- depends on PLATFORM_EC_DEBUG_ASSERT_REBOOTS
- help
- Normally the assertion-failure messages include the expression that
- failed and the function name where the failure occurred. These are
- both stored as strings and can add a lot to the size of the image,
- since they are generated for every call to assert(). Use this option
- to drop them so that only the file and line number are shown.
-
- This option is of course not available with
- PLATFORM_EC_DEBUG_ASSERT_BREAKPOINT, since that does not print a
- message at all.
-
-endif # PLATFORM_EC_DEBUG_ASSERT
diff --git a/zephyr/Kconfig.defaults b/zephyr/Kconfig.defaults
deleted file mode 100644
index 2b55e72156..0000000000
--- a/zephyr/Kconfig.defaults
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Kconfig overrides that applies to all platforms.
-
-# Disable timeslicing, it's compiled in by default and can be enabled at
-# runtime but not used in Zephyr EC.
-config TIMESLICING
- default n
diff --git a/zephyr/Kconfig.espi b/zephyr/Kconfig.espi
deleted file mode 100644
index 81b9f11e57..0000000000
--- a/zephyr/Kconfig.espi
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC_ESPI
-
-config PLATFORM_EC_ESPI_VW_SLP_S3
- bool "SLP_S3 is an eSPI virtual wire instead of a GPIO"
- help
- For power sequencing, use an eSPI virtual wire instead of
- defining GPIO_PCH_SLP_S3 in gpio_map.h.
-
-config PLATFORM_EC_ESPI_VW_SLP_S4
- bool "SLP_S4 is an eSPI virtual wire instead of a GPIO"
- help
- For power sequencing, use an eSPI virtual wire instead of
- defining GPIO_PCH_SLP_S4 in gpio_map.h.
-
-config PLATFORM_EC_ESPI_RESET_SLP_SX_VW_ON_ESPI_RST
- bool "Reset SLP VW signals on eSPI reset"
- help
- Enable this config to reset SLP* VW when eSPI_RST is asserted
- for the Global Reset event case. Don't enable this config if
- the platform implements the Deep-Sx entry as EC needs to
- maintain these pins' states per request. Note that this is
- currently unimplemented for Zephyr. Please see b/183148073.
-
-endif # PLATFORM_EC_ESPI \ No newline at end of file
diff --git a/zephyr/Kconfig.flash b/zephyr/Kconfig.flash
deleted file mode 100644
index f6a8b2d103..0000000000
--- a/zephyr/Kconfig.flash
+++ /dev/null
@@ -1,107 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC_FLASH_CROS
-
-config PLATFORM_EC_SPI_FLASH_REGS
- bool "Enable SPI flash registers"
- default y if SOC_FAMILY_NPCX
- help
- Enables flash registers for SPI flash (both internal and external).
- When enabled, two new functions will become available: (1) a function
- to compute the block write protection range from a set of status
- registers, and (2) the inverse function to set the status registers
- based on the desired protection offset/length.
-
-config PLATFORM_EC_CONSOLE_CMD_CHARGEN
- bool "Console command: chargen"
- depends on UART_INTERRUPT_DRIVEN
- help
- Enables the "chargen" console command, which sends a continuous
- stream of characters to the EC console.
-
- This allows to create tests which validate console output by
- verifying that no characters in the received sequence were lost.
-
-config PLATFORM_EC_CONSOLE_CMD_FLASH
- bool "Console commands: flasherase, flashread, flashwrite"
- help
- Enables various console commands:
-
- flasherase - erase flash region
- flashread - read from flash to memory
- flashwrite - write memory to flash
-
-config PLATFORM_EC_CONSOLE_CMD_FLASHINFO
- bool "Console commands: flashinfo"
- default y
- help
- Enables various console commands:
-
- flashinfo - displays information about the flash storage
-
-config PLATFORM_EC_CONSOLE_CMD_FLASH_WP
- bool "Console commands: flashwp"
- default y
- help
- Enables various console commands:
-
- flashwp - change write-protection settings
-
-config PLATFORM_EC_CONSOLE_CMD_SYSJUMP
- bool "Console command: sysjump"
- default y
- help
- Enables the sysjump console command used for testing and verifying
- that we're able to jump between images. Normally, in an EC build,
- there will exist 2 images (sometimes more): read-only (RO) and
- read-write (RW). This console command allows us to manually jump
- between the various images (or even to a random starting address) by
- copying the image data from flash to ram, then jumping to the image's
- entry point.
-
-choice PLATFORM_EC_STORAGE_TYPE
- prompt "Code storage type"
- default PLATFORM_EC_EXTERNAL_STORAGE if SOC_FAMILY_NPCX
- default PLATFORM_EC_INTERNAL_STORAGE if SOC_FAMILY_RISCV_ITE
- help
- Sets the EC code storage type.
-
-config PLATFORM_EC_EXTERNAL_STORAGE
- bool "Flash is stored external to the EC"
- help
- This indicates that the EC's flash is stored separately and is it
- not possible execute directly from it. Code must be loaded from
- the flash into internal SRAM before it can be executed. It is still
- possible to read and write the flash.
-
-config PLATFORM_EC_INTERNAL_STORAGE
- bool "Flash is stored internal to the EC"
- help
- This indicates that the EC code can reside on internal storage.
- This option implies XIP(eXecute-In-Place) semantics.
- i.e. code is being fetched directly from storage media.
-
-endchoice
-
-config PLATFORM_EC_MAPPED_STORAGE
- bool "Flash is mapped into the EC's address space"
- default y if SOC_FAMILY_NPCX || SOC_FAMILY_RISCV_ITE
- help
- This indicates that the EC's flash is directly mapped into
- its address space. This makes it easier to read and write the flash.
- If this is not defined, the flash driver must implement
- flash_physical_read().
-
-config PLATFORM_EC_FLASH_PSTATE
- bool "Store persistent write protect for the flash inside"
- default y if SOC_FAMILY_RISCV_ITE
- help
- Store persistent write protect for the flash inside the flash data
- itself. This allows ECs with internal flash to emulate something
- closer to a SPI flash write protect register. If this is not
- defined, write protect state is maintained solely by the physical
- flash driver.
-
-endif # PLATFORM_EC_FLASH_CROS
diff --git a/zephyr/Kconfig.header b/zephyr/Kconfig.header
deleted file mode 100644
index 43e66ec3e4..0000000000
--- a/zephyr/Kconfig.header
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-config PLATFORM_EC_RO_HEADER
- bool "RO section includes a header"
- default y
- depends on CROS_EC_RO
- depends on SOC_FAMILY_NPCX
- help
- The RO image residing on flash memory has a header section. The header
- is used on some chips (such as the npcx) to load the image correctly
- from flash. The values for offset and size are used by the linker
- scripts to generate the header. See core/cortex-m/ec.lds.S for
- reference.
-
-config PLATFORM_EC_RO_HEADER_OFFSET
- hex "Offset in memory for the location of the header"
- default 0x0
- help
- The offset (in bytes) of the header relative to the start address of
- the RO image.
-
-config PLATFORM_EC_RO_HEADER_SIZE
- hex "Size of the RO header"
- default 0x40 if SOC_FAMILY_NPCX
- default 0x0
- help
- The size of the RO header in bytes. This values should come from the
- datasheet of the chip being used.
diff --git a/zephyr/Kconfig.init_priority b/zephyr/Kconfig.init_priority
deleted file mode 100644
index af858a5296..0000000000
--- a/zephyr/Kconfig.init_priority
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-config PLATFORM_EC_FLASH_INIT_PRIORITY
- int "Init priority of the flash module"
- default 52
- help
- The initialization priority of the flash module. This should always be
- greater than PLATFORM_EC_GPIO_INIT_PRIORITY.
-
-config PLATFORM_EC_GPIO_INIT_PRIORITY
- int "Init priority of the GPIO module"
- default 51
- help
- The initialization priority of the GPIO module. This should always happen
- after the gpio drivers are initialized.
-
-config PLATFORM_EC_PWM_INIT_PRIORITY
- int "Initialization priority of the PWM module"
- depends on PLATFORM_EC_PWM
- default 51
- help
- Sets the initialization priority of the PWM module. This MUST be a
- value greater than the PWM driver's initialization priority which
- currently defaults to KERNEL_INIT_PRIORITY_DEVICE.
diff --git a/zephyr/Kconfig.keyboard b/zephyr/Kconfig.keyboard
deleted file mode 100644
index 9ad7fb8316..0000000000
--- a/zephyr/Kconfig.keyboard
+++ /dev/null
@@ -1,177 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-menuconfig PLATFORM_EC_KEYBOARD
- bool "Keyboard support"
- select HAS_TASK_KEYSCAN
- default n if ARCH_POSIX
- default y
- help
- Enable compilation of support for scanning a keyboard and providing
- the resulting input to the AP over the host interface. This consists
- of a keyboard-scanning task which provides key scans via it calling
- keyboard_state_changed() (for i8042) or its client calling
- keyboard_scan_get_state() (for MKBP).
-
- Enabling this automatically enables HAS_TASK_KEYSCAN since keyboard
- scanning must run in its own task.
-
-if PLATFORM_EC_KEYBOARD
-
-choice "Protocol select"
- prompt "Select the keyboard protocol to use"
- help
- Select the keyboard protocol used to communicate key presses to the
- AP. PLATFORM_EC_KEYBOARD_PROTOCOL_8042 is supported by x86-compatible
- application processors, and PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP is
- used for ARM application processors.
-
-config PLATFORM_EC_KEYBOARD_PROTOCOL_8042
- bool "i8042"
- select HAS_TASK_KEYPROTO
- help
- Use the i8042 protocol to communicate with the AP. This dates from the
- Intel 8042 keyboard controller chip released in 1976. It uses two-way
- communication via a few 8-bit registers, allowing key codes to be
- sent to the AP when keys are pressed and released.
-
- See here for docs: https://wiki.osdev.org/%228042%22_PS/2_Controller
-
-config PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP
- bool "mkbp"
- help
- Use the MKBP protocol to communicate with the AP. This protocol is
- usually used on ARM-based platforms. It sends the raw scan code, like
- (row, col), to the AP and the kernel driver will map this scan code to
- a key.
-
-endchoice # PLATFORM_EC_KEYBOARD
-
-config PLATFORM_EC_KEYBOARD_KEYPAD
- bool "Support a numeric keypad"
- help
- Enable support for a keypad, a palm-sized keyboard section usually
- placed on the far right. This contains nuumber keys and also some
- commonly used symbols, to help speed up numeric data entry.
-
-config PLATFORM_EC_KEYBOARD_VIVALDI
- bool "Vivaldi keyboard support"
- depends on PLATFORM_EC_KEYBOARD_PROTOCOL_8042
- default y
- help
- Enable code for Vivaldi keyboard (standard for new Chromium OS
- devices). A Chromium OS device is Vivaldi compatible if the keyboard
- matrix complies with: go/vivaldi-matrix.
-
- Vivaldi code enables:
- - A response to EC_CMD_GET_KEYBD_CONFIG command.
- - Boards can specify their custom layout for top keys.
-
-choice "Power button interference"
- prompt "Select the impact of pressing the power button"
- help
- On some boards one of the keyboard-scan inputs is affected by pressing
- the power button. When the power button is pressed, that input needs
- to be ignored in that case.
-
-config PLATFORM_EC_KEYBOARD_PWRBTN_INDEPENDENT
- bool "No impact on keyboard-scan inputs"
- help
- Select this if pressing the power button does not affect any
- keyboard-scan inputs.
-
-config PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2
- bool "Forces KSI2 to be asserted"
- help
- Enable this if KSI2 is stuck 'asserted' for all scan columns if the
- power button is held. We must be aware of this case in order to
- correctly handle recovery-mode key combinations.
-
-config PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3
- bool "Forces KSI3 to be asserted"
- help
- Enable this if KSI3 is stuck 'asserted' for all scan columns if the
- power button is held. We must be aware of this case in order to
- correctly handle recovery-mode key combinations.
-
-endchoice # "Power button interference"
-
-config PLATFORM_EC_KEYBOARD_COL2_INVERTED
- bool "A mechanism for passing KSO2 to H1 which inverts the signal"
- help
- This option enables a mechanism for passing the column 2
- to H1 which inverts the signal. The signal passing through H1
- adds more delay. Need a larger delay value. Otherwise, pressing
- Refresh key will also trigger T key, which is in the next scanning
- column line. See http://b/156007029.
-
-config PLATFORM_EC_KEYBOARD_REFRESH_ROW3
- bool "Move the refresh key matrix to row 3 instead of row 2"
- help
- The Vivaldi keyboards have the refresh key on row 3 instead of row 2.
- The legacy keyboards with the assistant key also move the refresh key
- matrix to row 3. This is used by the boot key detection code to
- determine if the refresh key is held down at boot.
-
-config PLATFORM_EC_VOLUME_BUTTONS
- bool "Board has volume-up and volume-down buttons"
- help
- Enable this if the board has physical buttons for the volume controls.
- These are buttons controlled by GPIOs and are not part of the keyboard
- matrix.
-
- Your board must define GPIO_VOLUME_UP_L and GPIO_VOLUME_DOWN_L in
- gpio_map.h
-
-config PLATFORM_EC_CMD_BUTTON
- bool "Console command: button"
- help
- This command simulates button press. The buttons are like volume-up,
- volume-down, and recovery buttons.
-
-config PLATFORM_EC_CONSOLE_CMD_KEYBOARD
- bool "Console command: ksstate, kbpress, 8042"
- default y if PLATFORM_EC_KEYBOARD
- help
- Enable keyboard related console commands.
-
- ksstate - Show or toggle printing keyboard scan state
- kbpress - Simulate keypress
-
- If PLATFORM_EC_KEYBOARD_PROTOCOL_8042 is enabled, it includes 8042
- command which prints the state of the i8042 keyboard protocol and
- includes the following subcommands:
-
- codeset - Get/set keyboard codeset
- ctrlram - Get/set keyboard controller RAM
- internal - Show internal information
- kbd - Print or toggle keyboard info
- kblog - Print or toggle keyboard event log (current disabled)
- typematic - Get/set typematic delays
-
-choice
- prompt "Keyboard backlight"
- optional
- help
- Enable support for EC control of a keyboard backlight. This enables
- the "kblight" console command for manual control of the keyboard
- backlight. This also enables the EC_CMD_PWM_SET_KEYBOARD_BACKLIGHT and
- EC_CMD_PWM_GET_KEYBOARD_BACKLIGHT host commands for automatic control
- by the AP.
-
- TODO: support CONFIG_IO_EXPANDER_IT8801 driver which provides
- PWM keyboard support.
-
-config PLATFORM_EC_PWM_KBLIGHT
- bool "PWM keyboard backlight"
- depends on PLATFORM_EC_PWM
- help
- Enables a PWM-controlled keyboard backlight controlled by a PWM signal
- connected directly to the EC chipset. The board files must define
- the C reference PWM_CH_KBLIGHT to the PWM channel used for the
- keyboard backlight control.
-
-endchoice # Keyboard backlight
-
-endif # PLATFORM_EC_KEYBOARD
diff --git a/zephyr/Kconfig.led b/zephyr/Kconfig.led
deleted file mode 100644
index 8955675d92..0000000000
--- a/zephyr/Kconfig.led
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-menuconfig PLATFORM_EC_LED_COMMON
- bool "LED Support"
- help
- Enable the common LED module supporting automatic control of the
- battery and power LEDs.
-
-if PLATFORM_EC_LED_COMMON
-
-# TODO: Add other choices
-# CONFIG_LED_POLICY_STD
-# CONFIG_LED_PWM_CHARGE_STATE_ONLY
-# CONFIG_LED_PWM_ACTIVE_CHARGE_PORT_ONLY
-# CONFIG_LED_ONOFF_STATES
-
-config PLATFORM_EC_LED_PWM
- bool "PWM (Pulse Width Modulation) LEDs"
- depends on PLATFORM_EC_PWM
- help
- Enable PWM (Pulse Width Modulation) controlled LEDs that conform to
- the Chromium OS LED behavior specification.
-
- Your board files must implement led_set_brightness() function, which
- is used by the LED PWM module to set the board LEDs in response to
- power and charging events.
-
-if PLATFORM_EC_LED_PWM
-
-config PLATFORM_EC_CONSOLE_CMD_LEDTEST
- bool "Console command: ledtest"
- default y
- help
- Enable the "ledtest" command. This command lets you override the
- automatic control of the platform LEDs. For example:
-
- ledtest 0 enable red
-
- disables automatic control of the first PWM LED and forces the LED
- color to red. Set the 2nd parameter to "disable" to return back
- to automatic control:
-
- ledtest 0 disable
-
-endif # PLATFORM_EC_LED_PWM
-endif # PLATFORM_EC_LED_COMMON
diff --git a/zephyr/Kconfig.mkbp_event b/zephyr/Kconfig.mkbp_event
deleted file mode 100644
index e24cf370d2..0000000000
--- a/zephyr/Kconfig.mkbp_event
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC_MKBP_EVENT
-
-choice
- prompt "MKBP delivery method"
- default PLATFORM_EC_MKBP_USE_GPIO
- help
- Select MKBP delivery method
-
-config PLATFORM_EC_MKBP_USE_GPIO
- bool "Use GPIO"
- help
- Select to send MKBP events via GPIO. You should define GPIO_EC_INT_L
- in gpio_map.h as output from the EC. The GPIO is used to indicate an
- event is ready for serving by the AP.
-
-config PLATFORM_EC_MKBP_USE_HOST_EVENT
- bool "Use host event"
- help
- Select to send MKBP events via host event.
-
-config PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT
- bool "Use GPIO and host event"
- help
- MKBP events are notified by using both a GPIO and a host event.
-
- You should use this if you are using a GPIO to notify the AP of an MKBP
- event, and you need an MKBP event to wake the AP in suspend and the
- AP cannot wake from the GPIO. Since you are using both a GPIO and
- a hostevent for the notification, make sure that the S0 hostevent mask
- does NOT include MKBP events. Otherwise, you will have multiple
- consumers for a single event. However, make sure to configure the
- host event *sleep* mask in coreboot to include MKBP events. In order to
- prevent all MKBP events from waking the AP, use
- CONFIG_MKBP_EVENT_WAKEUP_MASK to filter the events.
-
-config PLATFORM_EC_MKBP_USE_CUSTOM
- bool "Use custom method"
- help
- Select to send MKBP events using custom method. You need to define
- mkbp_set_host_active_via_custom() which is called when there's a MKBP event
- to be sent. for more about the function, refer to mkbp_event.h.
-
-endchoice
-
-endif # PLATFORM_EC_MKBP_EVENT
diff --git a/zephyr/Kconfig.motionsense b/zephyr/Kconfig.motionsense
deleted file mode 100644
index daf2bbcdf8..0000000000
--- a/zephyr/Kconfig.motionsense
+++ /dev/null
@@ -1,190 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-menuconfig PLATFORM_EC_MOTIONSENSE
- bool "Motion Sense"
- select HAS_TASK_MOTIONSENSE
- help
- Enable motion sense task. The task collects data from available sensors
- and report them to AP. Besides the task reports the sensor data to AP.
- Based on the data, it also does other things like calculating lid angle
- and detect tablet mode.
-
-config PLATFORM_EC_ACCEL_FIFO
- bool "Sensor FIFO"
- help
- Enable this to add the sensor FIFO used by sensor device drivers to fill.
- Using FIFO reduces power consumption since it reduces the number of
- AP wake-ups.
-
-if PLATFORM_EC_ACCEL_FIFO
-
-config PLATFORM_EC_ACCEL_FIFO_SIZE
- int "Motion Sense FIFO Size"
- default 256
- help
- This sets the size of the sensor FIFO, must be a power of 2.
-
-config PLATFORM_EC_ACCEL_FIFO_THRES
- int "FIFO Threshold"
- default 85 # (PLATFORM_EC_ACCEL_FIFO_SIZE / 3)
- help
- This sets the amount of free entries that trigger an interrupt to the AP.
-
-endif # PLATFORM_EC_ACCEL_FIFO
-
-config PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS
- bool "Extra Sensor Timestamp"
- help
- If this is defined, motion_sense sends
- sensor events to the AP in the format
- +-----------+
- | Timestamp |
- | Payload |
- | Timestamp |
- | Payload |
- | ... |
- +-----------+
- If this is not defined, the events will be sent in the format
- +-----------+
- | Payload |
- | Payload |
- | Payload |
- | ... |
- | Timestamp |
- +-----------+
- The former format enables improved filtering of sensor event
- timestamps on the AP, but comes with stricter jitter requirements.
-
-config PLATFORM_EC_ACCEL_INTERRUPTS
- bool "Accelerometer Interrupts"
- help
- Enable this to allow a sensor driver to send an event to motion task when
- the sensor gets the data ready interrupt. On the event, motion task calls
- the driver's irq_handler to collect data.
-
-# TODO(b/173507858) config PLATFORM_EC_MOTION_FILL_LPC_SENSE_DATA
-# if PLATFORM_EC_MOTION_FILL_LPC_SENSE_DATA
-#endif # PLATFORM_EC_MOTION_FILL_LPC_SENSE_DATA
-
-config PLATFORM_EC_ALS
- bool "Ambient Light Sensor(ALS)"
- default y if HAS_TASK_ALS
- help
- Enable this to indicate there's at least one or more ALS devices available.
- If PLATFORM_EC_MOTION_FILL_LPC_SENSE_DATA is set, then motion task updates
- the designated part of EC memmap with the ALS data. The updating EC memmap
- can be also done by the dedicated ALS task with HAS_ALS_TASK set.
- Number of ALS entries reserved in EC memmap are defined by EC_ALS_ENTRIES
- in ec_commands.h.
-
-if PLATFORM_EC_ALS
-
-config PLATFORM_EC_ALS_COUNT
- int "Number of ALS devices"
- default 1
- help
- This sets the number of ALS devices. This should be less than or equal to
- EC_ALS_ENTRIES in ec_commands.h
- TODO(b/173507858) move this to device tree
-
-endif # PLATFORM_EC_ALS
-
-config PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT
- bool "Dynamic Motion Sensor Count"
- help
- Enable this to allow changing motion sensor count dynamically.
-
-config PLATFORM_EC_LID_ANGLE
- bool "Lid Angle"
- help
- Enable this to detect lid angle with two accelerometers. The andgle
- calculation requires the information about which sensor is on the lid
- and which one is on the base. The measured lid angle can be used for
- tablet mode detection(refer "Tablet Mode below") and enabling/disabling
- 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"
- help
- Enable this to allow using the lid angle measurement to determine if
- peripheral devices should be enabled or disabled, like key scanning,
- trackpad interrupt.
-
-config PLATFORM_EC_TABLET_MODE
- bool "Tablet Mode"
- help
- Enable this for a device which can be a tablet as well as a clamshell.
- Tablet mode detection is done either by using the lid angle measurement
- or by the dedicated GMR sensor.
-
-if PLATFORM_EC_TABLET_MODE
-
-config PLATFORM_EC_TABLET_MODE_SWITCH
- bool "Tablet Mode Switch"
- depends on PLATFORM_EC_MKBP_INPUT_DEVICES
- help
- Enable a virtual switch to indicate when we are in tablet mode. The tablet
- mode state is sent to AP via MKBP protocol(switch event).
-
-config PLATFORM_EC_GMR_TABLET_MODE
- bool "Giant Magnetoresistance(GMR) Tablet Mode"
- help
- Enable this to use GMR sensor to detect tablet mode.
- It requires to set GMR_TABLET_MODE_GPIO_L to map the interrupt from
- the sensor and direct its mapping to gmr_tablet_switch_isr
- 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."
- help
- Enables console commands:
-
- accelrange <sensor id> <data> <roundup> - Read or write accelerometer
- range
- accelres <sensor id> <data> <roundup> - Read or write accelerometer
- resolution
- accelrate <sensor id> <data> <roundup> - Read or write accelerometer
- ODR
- accelread <sensor id> [n(iteration)] - Read sensor x/y/z
- accelinit <sensor id> - Init sensor
-
-if PLATFORM_EC_CONSOLE_CMD_ACCELS
-
-config PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO
- bool "Console Command: accelinfo"
- help
- Enable console command:
-
- accelinfo on/off [interval] - Print motion sensor info, lid angle
- calculations and set calculation frequency.
-
-endif # PLATFORM_EC_CONSOLE_CMD_ACCELS
-
-config PLATFORM_EC_ACCEL_SPOOF_MODE
- bool "Sensor spoof mode"
- help
- Enable this to allow sensors values spoofed to any arbitrary value.
- This is useful for testing the motion sense framework if the hardware
- sensor or the sensor driver code is not ready.
-
-if PLATFORM_EC_ACCEL_SPOOF_MODE
-
-config PLATFORM_EC_CONSOLE_CMD_ACCEL_SPOOF
- bool "Console Command: accelspoof"
- help
- Enable console command:
-
- accelspoof id [on/off] [X] [Y] [Z] - Enable/Disable spoofing of
- sensor readings.
-
-endif # PLATFORM_EC_ACCEL_SPOOF_MODE
-
-rsource "Kconfig.sensor_devices"
diff --git a/zephyr/Kconfig.panic b/zephyr/Kconfig.panic
deleted file mode 100644
index 322aaee25d..0000000000
--- a/zephyr/Kconfig.panic
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC_PANIC
-
-config PLATFORM_EC_SOFTWARE_PANIC
- bool "Software panic"
- default y
- help
- Sometimes the EC has bugs that are provoked by unexpected events.
- This enables storing a panic log and halt the system for
- software-related reasons, such as stack overflow or assertion
- failure.
-
-config PLATFORM_EC_CONSOLE_CMD_CRASH
- bool "Console command: crash"
- default y
- help
- For testing purposes it is useful to be able to generation exceptions
- to check that the panic reporting is working correctly. The enables
- the 'crash' command which supports generating various exceptions,
- selected by its parameter:
-
- assert - assertion failure (ASSERT() macro)
- divzero - division by zero
- udivzero - division of unsigned value by zero
- stack (if enabled) - stack overflow
- unaligned - unaligned access (e.g. word load from 0x123)
- watchdog - watchdog timer fired
- hang - infinite loop in the EC code
-
-config PLATFORM_EC_STACKOVERFLOW
- bool "Console command: crash stack"
- depends on PLATFORM_EC_CONSOLE_CMD_CRASH
- default y if !ZTEST && !SOC_POSIX
- help
- This enables the 'stack' parameter for the 'crash' command. This
- causes a stack overflow by recursing repeatedly while task switching.
- This can be used to check that stack-overflow detection is working
- as expected.
-
-endif # PLATFORM_EC_PANIC
diff --git a/zephyr/Kconfig.pmic b/zephyr/Kconfig.pmic
deleted file mode 100644
index dc79305439..0000000000
--- a/zephyr/Kconfig.pmic
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-menuconfig PLATFORM_EC_PMIC
- bool "Power Management IC support"
- help
- Enables support for controlling PMICs (Power Management ICs).
- A system may have one or more PMICs to control various power
- rails. These devices operate autonomously, but can sometimes
- be accessed to tune operational parameters or read fault
- codes.
-
-if PLATFORM_EC_PMIC
-
-config PLATFORM_EC_MP2964
- bool "Enable MP2964 PMIC support"
- depends on AP_X86_INTEL
- depends on PLATFORM_EC_I2C
- help
- Enables support for the MPS MP2964 PMIC (Power Management IC).
- This is a dual rail IMVP8 - IMVP9.1 compatible Digital
- Multi-Phase Controller with an I2C interface. This driver
- enables reprogramming configuration registers when initial the
- factory settings need to be tuned in prototype devices.
-
-endif # PLATFORM_EC_PMIC
diff --git a/zephyr/Kconfig.port80 b/zephyr/Kconfig.port80
deleted file mode 100644
index b3ff8ab60b..0000000000
--- a/zephyr/Kconfig.port80
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC_ESPI
-
-config PLATFORM_EC_PORT80_4_BYTE
- bool "Allow accept 4-byte Port80 codes"
- help
- Enable this config to allow the common Port80 layer to accept 4-byte
- codes when AP sends 4-byte Port80 codes via eSPI PUT_IOWR_SHORT
- protocol in a single transaction.
-
-endif # PLATFORM_EC_ESPI
diff --git a/zephyr/Kconfig.powerseq b/zephyr/Kconfig.powerseq
deleted file mode 100644
index 0045a69ad8..0000000000
--- a/zephyr/Kconfig.powerseq
+++ /dev/null
@@ -1,190 +0,0 @@
-# Copyright 2020 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.
-
-menuconfig PLATFORM_EC_POWERSEQ
- bool "Power sequencing"
- depends on AP
- select HAS_TASK_CHIPSET
- help
- Enable shimming the platform/ec AP power sequencing code. This
- handles powering the chipset on and off.
-
- Enabling this automatically enables HAS_TASK_CHIPSET since power
- sequencing must run in its own task.
-
-if PLATFORM_EC_POWERSEQ
-
-config PLATFORM_EC_POWERSEQ_HOST_SLEEP
- bool "Track host sleep states"
- help
- Enable EC code to track the AP sleep states. This is
- required for S0ix support on Intel platforms, and optional
- for boards without S0ix support.
-
-config PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION
- bool "Detect failure to enter a sleep state (S0ix/S3)"
- depends on PLATFORM_EC_POWERSEQ_HOST_SLEEP
- help
- Enables detection of the AP failing to go to sleep, perhaps due to a
- bug in the internal SoC periodic housekeeping code.
-
- Failure information is reported via the EC_CMD_HOST_SLEEP_EVENT host
- command.
-
-config PLATFORM_EC_HOSTCMD_AP_RESET
- bool "Host command: EC_CMD_AP_RESET"
- depends on PLATFORM_EC_HOSTCMD
- help
- Enable support for EC_CMD_AP_RESET, used by the AP to request that
- the EC perform a reset of the AP.
-
- Warning: This command skips the normal reset mechanism on the AP and
- may leave data unsaved.
-
-config PLATFORM_EC_POWERSEQ_PP5000_CONTROL
- bool "Enable a task-safe way to control the PP5000 rail"
- depends on !AP_X86_AMD
- default y
- help
- Guard access to the PP5000 GPIO using mutex locks, allowing
- the rail to be changed in a task-safe manner.
-
-menuconfig PLATFORM_EC_POWERSEQ_AMD
- bool "AMD power sequencing"
- depends on AP_X86_AMD
- select HAS_TASK_POWERBTN
- default y
- help
- Enable AMD power sequencing code.
-
-if PLATFORM_EC_POWERSEQ_AMD
-
-config PLATFORM_EC_POWER_BUTTON_TO_PCH_CUSTOM
- bool "Custom board_pwrbtn_to_pch"
- help
- The board support code provides a custom function,
- board_pwrbtn_to_pch, that replaces the standard GPIO set
- level to the SoC.
-
-endif # PLATFORM_EC_POWERSEQ_AMD
-
-menuconfig PLATFORM_EC_POWERSEQ_INTEL
- bool "Enable shimming common Intel power sequencing code"
- depends on AP_X86_INTEL
- select HAS_TASK_POWERBTN
- default y
- help
- Enable shimming platform/ec AP power sequencing code for
- Intel.
-
-if PLATFORM_EC_POWERSEQ_INTEL
-
-config PLATFORM_EC_POWERSEQ_CPU_PROCHOT_ACTIVE_LOW
- bool "The CPU_PROCHOT signal is an active low signal"
- default y
- help
- If CPU_PROCHOT should be treated as active-low, enable this
- configuration option.
-
-config PLATFORM_EC_POWERSEQ_RSMRST_DELAY
- bool "Wait at least 10ms before deasserting RSMRST to PCH"
- default y if AP_X86_INTEL_TGL
- help
- Wait at least 10ms between power signals going high and
- deasserting RSMRST to PCH.
-
-config PLATFORM_EC_POWERSEQ_RTC_RESET
- bool "Board has an RTC reset"
- help
- This project has a gpio named GPIO_PCH_RTCRST defined in
- gpio_map.h, which can be used to reset the AP's RTC when set
- high.
-
-config PLATFORM_EC_POWERSEQ_S0IX
- bool "Enable S0ix sleep states"
- select PLATFORM_EC_POWERSEQ_HOST_SLEEP
- help
- Enable the CONFIG_POWER_S0IX platform/ec configuration
- option, Intel's low-power idle sleep state, also known as
- "modern sleep".
-
-config PLATFORM_EC_POWERSEQ_COMETLAKE
- bool "Use common Comet Lake code for power sequencing"
- depends on AP_X86_INTEL_CML
- default y
- help
- Use the Comet Lake code for power sequencing.
-
-menuconfig PLATFORM_EC_POWERSEQ_ICELAKE
- bool "Use common Icelake code for power sequencing"
- default y if AP_X86_INTEL_TGL
- default y if AP_X86_INTEL_ADL
- help
- Use the Icelake common code for power sequencing. Note that
- this applies to more platforms than just Icelake. For
- example, Tigerlake uses this code too.
-
-if PLATFORM_EC_POWERSEQ_ICELAKE
-
-config PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE
- bool "Enable a quirk to release SLP_S3_L after DSW_PWROK is high"
- default y if AP_X86_INTEL_TGL
- help
- Enable a quirk to reconfigure SLP_S3_L back to an input a
- short delay after DSW_PWROK goes high.
-
-config PLATFORM_EC_POWERSEQ_PP3300_RAIL_FIRST
- bool "Turn on the PP3300 rail before PP5000"
- default y if AP_X86_INTEL_TGL
- help
- When switching from G3 to S5, turn on the PP3300 rail before
- the PP5500 rail.
-
-endif # PLATFORM_EC_POWERSEQ_ICELAKE
-
-endif # PLATFORM_EC_POWERSEQ_INTEL
-
-menuconfig PLATFORM_EC_POWERSEQ_IT8XXX2
- bool "Enable shimming common ITE8xxx2 power sequencing code"
- depends on AP_ARM_MTK_MT8192
- default y
- help
- Enable shimming platform/ec AP power sequencing code for
- IT8xxx2.
-
-if PLATFORM_EC_POWERSEQ_IT8XXX2
-
-config PLATFORM_EC_POWERSEQ_MT8192
- bool "Use common MT8192 code for power sequencing"
- default y
- help
- Use the Comet Lake code for power sequencing.
-
-endif # PLATFORM_EC_POWERSEQ_ITE8XXX2
-
-config PLATFORM_EC_POWERSEQ_SC7180
- bool "SC7180 power sequencing"
- depends on AP_ARM_QUALCOMM_SC7180
- default y
- help
- Enable power sequencing for the Qualcomm Snapdragon SC7180
- chipset.
-
-config PLATFORM_EC_POWERSEQ_SC7280
- bool "SC7280 power sequencing"
- depends on AP_ARM_QUALCOMM_SC7280
- default y
- help
- Enable power sequencing for the Qualcomm Snapdragon SC7280
- chipset.
-
-config PLATFORM_EC_CONSOLE_CMD_S5_TIMEOUT
- bool "Console command: s5_timeout"
- help
- Enable the console command 's5_timeout'. This command is used to
- change the timeout waiting for inactivity in the S5 power state before
- transitioning to the G3 state. This command is useful for power
- testing.
-
-endif # PLATFORM_EC_POWERSEQ
diff --git a/zephyr/Kconfig.rtc b/zephyr/Kconfig.rtc
deleted file mode 100644
index 5f36893122..0000000000
--- a/zephyr/Kconfig.rtc
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC_RTC
-
-config PLATFORM_EC_CONSOLE_CMD_RTC
- bool "Console command: rtc"
- help
- This command allows getting and setting the current RTC value. The
- value is in seconds since the Epoch (midnight on 1/1/70). You can
- convert this to a human date on the command line with 'date -u -d @n'
- where n is the numeric value. To convert a time to seconds, use:
-
- date -d '1970-01-01 UTC + n seconds'
-
-config PLATFORM_EC_CONSOLE_CMD_RTC_ALARM
- bool "Console command: rtc_alarm"
- depends on PLATFORM_EC_CONSOLE_CMD_RTC
- help
- This command supports setting a real-time-clock (RTC) alarm that
- causes an interrupt when the timer reaches that point. To set the
- alarm:
-
- rtc <sec> [<usec>]
-
- where:
- <sec> is the number of seconds since the epoch
- <usec> is the optional number of microseconds (fractional seconds)
-
-config PLATFORM_EC_HOSTCMD_RTC
- bool "Host command: EC_CMD_RTC_GET_VALUE etc."
- depends on PLATFORM_EC_HOSTCMD
- help
- Enables support for EC_CMD_RTC_GET_VALUE, EC_CMD_RTC_SET_VALUE,
- EC_CMD_RTC_GET_ALARM and EC_CMD_RTC_SET_ALARM which colectively allow
- the AP to control the EC's real-time-clock. The AP typically makes
- use of the EC's RTC to avoid needing a discrete RTC chip on the board.
-
-endif # PLATFORM_EC_RTC
diff --git a/zephyr/Kconfig.sensor_devices b/zephyr/Kconfig.sensor_devices
deleted file mode 100644
index 623919d775..0000000000
--- a/zephyr/Kconfig.sensor_devices
+++ /dev/null
@@ -1,113 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-menu "Sensor Devices"
-
-config PLATFORM_EC_ACCELGYRO_BMI
- bool "Config used to include common accelgyro BMI features"
- help
- Do not set this directly in a .conf file. This value should be set
- using an `select` statement in other BMI family of drivers such as
- BMI260.
-
-config PLATFORM_EC_ACCELGYRO_ICM
- bool "Config used to include common accelgyro ICM features"
- help
- Do not set this directly in a .conf file. This value should be set
- using an `select` statement in other ICM family of drivers such as
- ICM426XX.
-
-config PLATFORM_EC_ACCEL_BMA255
- bool "BMA2X2 Accelerometer Family Driver"
- help
- The driver supports Bosch's a triaxial, low-g acceleration sensor.
- It allows measurements of acceleration in three perpendicular axes.
- Currently the driver supports BMA253, BMA255, BMA355, BMA280, BMA282,
- BMA223, BMA254, BMA284, BMA250E, BMA222E, BMC150 BMC056, BMC156.
-
-config PLATFORM_EC_ACCEL_BMA4XX
- bool "BMA4XX Accelerometer Family Driver"
- help
- The driver supports Bosch's a triaxial, low-g acceleration sensor.
- It allows measurements of acceleration in three perpendicular axes.
- Currently the driver supports BMA4XX.
-
-config PLATFORM_EC_ACCEL_KX022
- bool "KX022 Accelerometer Driver"
- help
- The driver supports Kionix's KX022 triaxial low-g acceleration sensor.
- It allows measurements of acceleration in three perpendicular axes.
-
-config PLATFORM_EC_ACCEL_LIS2DW12
- bool "LIS2DW12 Accelerometer Driver"
- select PLATFORM_EC_STM_MEMS_COMMON
- help
- The driver supports ST's LIS2DW12 3D digital accelerometer sensor.
- It allows measurements of acceleration in three perpendicular axes.
-
-config PLATFORM_EC_ACCEL_LIS2DW12_AS_BASE
- bool "LIS2DW12 Interrupt force mode"
- depends on PLATFORM_EC_ACCEL_LIS2DW12
- help
- The LIS2DW driver supports fifo and interrupt, but letting lid accel
- sensor work at polling mode is a common selection in current usage
- model. This option will select interrupt (foced mode).
-
-config PLATFORM_EC_ACCELGYRO_BMI160
- bool "BMI160 Accelgyrometer Driver"
- select PLATFORM_EC_ACCELGYRO_BMI
- help
- The driver supports Bosch's BMI160 which is an Inertial Measurement
- Unit (IMU) consisting of a 16-bit tri-axial gyroscope and a 16-bit
- tri-axial accelerometer.
-
-config PLATFORM_EC_ACCELGYRO_BMI260
- bool "BMI260 Accelgyrometer Driver"
- select PLATFORM_EC_ACCELGYRO_BMI
- help
- The driver supports Bosch's BMI260 which is an Inertial Measurement
- Unit (IMU) consisting of a 16-bit tri-axial gyroscope and a 16-bit
- tri-axial accelerometer.
-
-config PLATFORM_EC_ACCELGYRO_BMI3XX
- bool "BMI3XX Accelgyrometer Driver"
- select PLATFORM_EC_ACCELGYRO_BMI
- help
- The driver supports Bosch's BMI3XX which is an Inertial Measurement
- Unit (IMU) consisting of a 16-bit tri-axial gyroscope and a 16-bit
- tri-axial accelerometer.
-
-config PLATFORM_EC_ALS_TCS3400
- bool "TCS3400 Ambient Light Senseor Driver"
- help
- The driver supports TCS3400 which provides color and
- IR (red, green, blue, clear and IR) ambient light sensing.
-
-config PLATFORM_EC_ACCELGYRO_ICM426XX
- bool "ICM426XX Accelgyro Driver"
- select PLATFORM_EC_ACCELGYRO_ICM
- help
- The driver supports ICM425XX which provides both accelerometer and
- gyroscope readings.
-
-config PLATFORM_EC_ACCELGYRO_ICM42607
- bool "ICM42607 Accelgyro Driver"
- select PLATFORM_EC_ACCELGYRO_ICM
- help
- The driver supports ICM42607 which provides both accelerometer and
- gyroscope readings.
-
-config PLATFORM_EC_STM_MEMS_COMMON
- bool
- help
- The driver supports functionality that is common to
- STMicroelectronics(STM) micro-electromechanical system(MEMS)
- sensor devices. This should be enabled by drivers that use
- this common framework. It cannot be set otherwise, even in
- prj.conf.
-
-rsource "Kconfig.accelgyro_bmi"
-rsource "Kconfig.accelgyro_icm"
-
-endmenu # Sensor devices
diff --git a/zephyr/Kconfig.stacks b/zephyr/Kconfig.stacks
deleted file mode 100644
index 8df0ca23f1..0000000000
--- a/zephyr/Kconfig.stacks
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-##############################################################################
-if SOC_SERIES_NPCX7
-
-# Zephyr internal stack sizes
-
-config IDLE_STACK_SIZE
- default 192
-
-config ISR_STACK_SIZE
- default 1024
-
-config SHELL_STACK_SIZE
- default 1536
-
-config SYSTEM_WORKQUEUE_STACK_SIZE
- default 704
-
-# Chromium EC stack sizes
-
-config TASK_CHARGER_STACK_SIZE
- default 704
-
-config TASK_CHG_RAMP_STACK_SIZE
- default 608
-
-config TASK_CHIPSET_STACK_SIZE
- default 1056
-
-config TASK_HOOKS_STACK_SIZE
- default 672
-
-config TASK_HOSTCMD_STACK_SIZE
- default 672
-
-config TASK_KEYPROTO_STACK_SIZE
- default 640
-
-config TASK_KEYSCAN_STACK_SIZE
- default 640
-
-config TASK_MOTIONSENSE_STACK_SIZE
- default 800
-
-config TASK_POWERBTN_STACK_SIZE
- default 672
-
-config TASK_PD_STACK_SIZE
- default 1184
-
-config TASK_PD_INT_STACK_SIZE
- default 736
-
-config TASK_USB_CHG_STACK_SIZE
- default 544
-
-endif # SOC_SERIES_NPCX7
-##############################################################################
-
-
-##############################################################################
-if SOC_SERIES_NPCX9
-
-# Zephyr internal stack sizes
-
-config IDLE_STACK_SIZE
- default 192
-
-config ISR_STACK_SIZE
- default 1024
-
-config SHELL_STACK_SIZE
- default 1536
-
-config SYSTEM_WORKQUEUE_STACK_SIZE
- default 800
-
-# Chromium EC stack sizes
-
-config TASK_CHARGER_STACK_SIZE
- default 750
-
-config TASK_CHIPSET_STACK_SIZE
- default 684
-
-config TASK_HOOKS_STACK_SIZE
- default 672
-
-config TASK_HOSTCMD_STACK_SIZE
- default 700
-
-config TASK_KEYSCAN_STACK_SIZE
- default 700
-
-config TASK_MOTIONSENSE_STACK_SIZE
- default 812
-
-config TASK_PD_STACK_SIZE
- default 1184
-
-config TASK_PD_INT_STACK_SIZE
- default 736
-
-config TASK_USB_CHG_STACK_SIZE
- default 544
-
-endif # SOC_SERIES_NPCX9
-##############################################################################
diff --git a/zephyr/Kconfig.system b/zephyr/Kconfig.system
deleted file mode 100644
index c9b67a6ab7..0000000000
--- a/zephyr/Kconfig.system
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC
-
-config PLATFORM_EC_CONSOLE_CMD_SCRATCHPAD
- bool "Console Command: scratchpad"
- help
- Enable the scratchpad console command. The scratchpad register
- maintain its contents across a software-requested warm reset. The
- command is used to set or get the scratchpad.
-
-config PLATFORM_EC_CONSOLE_CMD_SYSINFO
- bool "Console Command: sysinfo"
- default y
- help
- Enable the sysinfo console command, which shows statistics
- about the current image copy running, reset flags, etc.
-
-config PLATFORM_EC_HIBERNATE_PSL
- bool "System hibernating with PSL (Power Switch Logic) mechanism"
- depends on SOC_FAMILY_NPCX
- 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_SYSTEM_PRE_INIT_PRIORITY
- int "System pre-initialization priority"
- default 20
- range 0 99
- help
- This defines the initialization priority for the CROS
- system_pre_init() function. system_pre_init() reads chip level reset
- cause and stores it into the system reset flags. All drivers, except
- those critical to determining the reset type, should be initialized at
- lower priority so that the system reset flags are valid.
-
-config PLATFORM_EC_FW_RESET_VECTOR
- bool "Firmware Reset Vector chip specific retrieval"
- default y if SOC_FAMILY_RISCV_ITE
- help
- This defines if there is a chip specific machanism for
- retrieving the firmware reset vector. The function that
- needs to be provided is system_get_fw_reset_vector that
- will return the address of the reset vector.
-
-endif # PLATFORM_EC
diff --git a/zephyr/Kconfig.tasks b/zephyr/Kconfig.tasks
deleted file mode 100644
index 35dfc1c2f1..0000000000
--- a/zephyr/Kconfig.tasks
+++ /dev/null
@@ -1,303 +0,0 @@
-# Copyright 2020 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.
-
-# Please keep these tasks in alphabetical order
-
-menu "Tasks"
-
-config HAS_TASK_CHARGER
- bool "Charger task"
- depends on PLATFORM_EC_BATTERY
- help
- This turns on the charger task. This deals with monitoring the
- battery to make sure it is present and is responding properly to
- requests. If the battery is not full, it enables charging from a
- suitable power source.
-
-if HAS_TASK_CHARGER
-
-config TASK_CHARGER_STACK_SIZE
- int "Stack size"
- default 1024 # EC uses VENTI_TASK_STACK_SIZE which is 896
- help
- The stack size of the charger task.
-
- See b/176180736 for checking these stack sizes.
-
-endif # HAS_TASK_CHARGER
-
-config HAS_TASK_CHG_RAMP
- bool "Charger-ramp task"
- depends on PLATFORM_EC_BATTERY
- help
- This turns on the charger ramp task. This attempts to ramp up the
- current from an attached charger to the maximum available current.
- It handles the incoming VBUS voltage sagging as well as the user
- attaching different chargers.
-
-if HAS_TASK_CHG_RAMP
-
-config TASK_CHG_RAMP_STACK_SIZE
- int "Stack size"
- default 768 # EC uses TASK_STACK_SIZE which is 512 for npcx
- help
- The stack size of the charger task.
-
- See b/176180736 for checking these stack sizes.
-
-endif # HAS_TASK_CHG_RAMP
-
-config HAS_TASK_CHIPSET
- bool "Chipset task"
- depends on PLATFORM_EC_POWERSEQ
- help
- This turns on the chipset task which handles powering the chipset
- on and off. Powering on involves going through a sequence of enabling
- different power rails (e.g. by enabling GPIOs that control a PMIC)
- and monitoring power-good indicators to meet the specifications
- defined by the vendor.
-
-if HAS_TASK_CHIPSET
-
-config TASK_CHIPSET_STACK_SIZE
- int "Stack size"
- default 1024
- help
- The stack size of the power button task.
-
-endif # HAS_TASK_CHIPSET
-
-config HAS_TASK_HOOKS
- bool "Hooks task"
- default y
- help
- This required task runs periodic routines connected to the HOOK_TICK
- and HOOK_SECOND events. This task is responsible for running
- deferred routines.
-
-if HAS_TASK_HOOKS
-
-config TASK_HOOKS_STACK_SIZE
- int "Stack size"
- default 1024
- help
- The stack size of the hooks task.
-
- See b/176180736 for checking these stack sizes.
-
-endif # HAS_TASK_HOOKS
-
-config HAS_TASK_HOSTCMD
- bool "Host-command task"
- depends on PLATFORM_EC_HOSTCMD
- help
- This turns on the hostcmd task which handles communication with the
- AP. The AP sends a command to the EC and it responds when able. An
- interrupt can be used to indicate to the AP that the EC has something
- for it.
-
-if HAS_TASK_HOSTCMD
-
-config TASK_HOSTCMD_STACK_SIZE
- int "Stack size"
- default 1024
- help
- The size of the host-command task stack.
-
-endif # HAS_TASK_HOSTCMD
-
-config HAS_TASK_KEYPROTO
- bool "Keyboard-protocol task (x86)"
- depends on PLATFORM_EC_KEYBOARD_PROTOCOL_8042
- help
- This turns on the keyproto task which handles conversion of keyboard
- scans into i8042 messages on x86 platforms. This is not used or needed
- on ARM platforms, which send the raw keyboard scans to the AP for
- processing.
-
-if HAS_TASK_KEYPROTO
-
-config TASK_KEYPROTO_STACK_SIZE
- int "Stack size"
- default 768
- help
- The stack size of the keyproto task.
-
-endif # HAS_TASK_KEYPROTO
-
-config HAS_TASK_KEYSCAN
- bool "Keyboard-scanning task"
- depends on PLATFORM_EC_KEYBOARD
- help
- This turns on the keyscan task which handles scanning the keyboard
- and producing a list of changes in the key state. This list can either
- be sent to the keyboard-protocol task or directly to the AP for
- processing.
-
-if HAS_TASK_KEYSCAN
-
-config TASK_KEYSCAN_STACK_SIZE
- int "Stack size"
- default 768
- help
- The stack size of the keyscan task.
-
-endif # HAS_TASK_KEYSCAN
-
-config HAS_TASK_MOTIONSENSE
- bool "Enable motionsense task"
- help
- This turns on the motion sense task which collects sensor data from the
- sensors and reports them to AP. Using the data, it also produces other
- meaningful reports to AP like lid angle and tablet mode.
-
-if HAS_TASK_MOTIONSENSE
-
-config TASK_MOTIONSENSE_STACK_SIZE
- int "motionsense task stack size"
- default 4096
- help
- The size of the motion sense task stack.
-
-endif # HAS_TASK_MOTIONSENSE
-
-config HAS_TASK_POWERBTN
- bool "Power-button task (x86)"
- depends on PLATFORM_EC_POWER_BUTTON
- help
- This turns on the powerbtn task which handles monitoring the power
- button. When the application processor (AP) is off (S5 or G3 states),
- this task triggers a power-up sequence on a power-button press. When
- the AP is on (S3 or above state) x86 machines normally reset when the
- power button is held for 4 seconds but this tasks adjusts that to 8
- seconds, to allow time for the usual Chromium OS shutdown sequence.
-
-if HAS_TASK_POWERBTN
-
-config TASK_POWERBTN_STACK_SIZE
- int "Stack size"
- default 1024
- help
- The stack size of the power-button task.
-
-endif # HAS_TASK_POWERBTN
-
-config HAS_TASK_PD_C0
- bool "USB Power Delivery task"
- depends on PLATFORM_EC_USB_POWER_DELIVERY
- default y
- help
- This turns on the PD_C0 task which handles the rather complex USB
- Power Delivery protocol for port 0. There is one of these tasks for
- each USB-C port on the device, but they are enabled separately
- depending on how many ports are present.
-
-if HAS_TASK_PD_C0
-
-config TASK_PD_STACK_SIZE
- int "Stack size"
- default 1024 # EC uses VENTI_TASK_STACK_SIZE which is 896
- help
- The stack size of the PD_Cx tasks.
-
-endif # HAS_TASK_PD_C0
-
-config HAS_TASK_PD_C1
- bool "USB Power Delivery task"
- depends on PLATFORM_EC_USB_POWER_DELIVERY
- help
- This turns on the PD_C1 task for devices with >=2 ports.
-
-config HAS_TASK_PD_C2
- bool "USB Power Delivery task"
- depends on PLATFORM_EC_USB_POWER_DELIVERY
- help
- This turns on the PD_C2 task for devices with >=3 ports.
-
-config HAS_TASK_PD_C3
- bool "USB Power Delivery task"
- depends on PLATFORM_EC_USB_POWER_DELIVERY
- help
- This turns on the PD_C3 task for devices with 4 ports.
-
-config HAS_TASK_PD_INT_C0
- bool "USB Power Delivery task"
- depends on PLATFORM_EC_USB_POWER_DELIVERY
- default y
- help
- This turns on the PD_INT_C0 task which handles servicing of Power
- Delivery (PD) message interrupts for port 0. There is one of these
- tasks for each USB-C port on the device, but they are enabled
- separately depending on how many ports are present.
-
-if HAS_TASK_PD_INT_C0
-
-config TASK_PD_INT_STACK_SIZE
- int "Stack size"
- default 1280
- help
- The stack size of the PD_Cn_INT tasks.
-
-endif # HAS_TASK_PD_INT_C0
-
-config HAS_TASK_PD_INT_C1
- bool "USB Power Delivery task"
- depends on PLATFORM_EC_USB_POWER_DELIVERY
- help
- This turns on the PD_INT_C1 task for devices with >=2 ports.
-
-config HAS_TASK_PD_INT_C2
- bool "USB Power Delivery task"
- depends on PLATFORM_EC_USB_POWER_DELIVERY
- help
- This turns on the PD_INT_C2 task for devices with >=3 ports.
-
-config HAS_TASK_PD_INT_C3
- bool "USB Power Delivery task"
- depends on PLATFORM_EC_USB_POWER_DELIVERY
- help
- This turns on the PD_INT_C3 task for devices with 4 ports.
-
-config HAS_TASK_USB_CHG_P0
- bool "USB Charger (port 0)"
- depends on PLATFORM_EC_USB_CHARGER
- help
- This turns on the USB charger task for port 0. This handles
- negotiating power from an attached charger, trying to get the maximum
- available power consistent with the needs of the device.
-
- There is one of these tasks for each USB-C port on the device.
-
-if HAS_TASK_USB_CHG_P0
-
-config TASK_USB_CHG_STACK_SIZE
- int "(all ports) task stack size"
- default 1280 # EC uses VENTI_TASK_STACK_SIZE which is 896
- help
- The stack size of the USB charger task. If there are multiple tasks,
- each one gets the same stack size.
-
- See b/176180736 for checking these stack sizes.
-
-endif # HAS_TASK_USB_CHG_P0
-
-config HAS_TASK_USB_CHG_P1
- bool "USB Charger (port 1)"
- help
- This turns on the USB charger task for port 1. This handles
- negotiating power from an attached charger, trying to get the maximum
- available power consistent with the needs of the device.
-
- There is one of these tasks for each USB-C port on the device.
-
-config HAS_TASK_USB_CHG_P2
- bool "USB Charger (port 2)"
- help
- This turns on the USB charger task for port 2. This handles
- negotiating power from an attached charger, trying to get the maximum
- available power consistent with the needs of the device.
-
- There is one of these tasks for each USB-C port on the device.
-
-endmenu # Tasks
diff --git a/zephyr/Kconfig.temperature b/zephyr/Kconfig.temperature
deleted file mode 100644
index 4af5aa99f8..0000000000
--- a/zephyr/Kconfig.temperature
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-menuconfig PLATFORM_EC_TEMP_SENSOR
- bool "Temperature sensors"
- help
- Support for temperature sensors. Once enabled, "temps" console
- command and EC_CMD_TEMP_SENSOR_GET_INFO host command are available.
-
-if PLATFORM_EC_TEMP_SENSOR
-
-config PLATFORM_EC_DPTF
- bool "Dynamic Platform and Thermal Framework"
- default y if PLATFORM_EC_ACPI
- help
- Enables the Dynamic Platform and Thermal Framework (DPTF). DPTF
- exposes the temperature sensors and the fan controls to the
- Applicaiton Processor (AP) using Advanced Configuration and Power
- Interface (ACPI). This permits the AP to control thermal management
- independent of the EC.
-
- Even when DPTF is enabled, the EC still monitors temperature sensors
- and will take corrective actions for high temperatures such as turning
- on the fans or powering down the AP.
-
-config PLATFORM_EC_THERMISTOR
- bool "Thermistor support"
- depends on PLATFORM_EC_ADC
- help
- Enables support for thermistors (resistor whose resistance is
- strongly dependent on temperature) as temperature-sensor type.
-
-endif # PLATFORM_EC_TEMP_SENSOR
-
-
-config PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY
- bool "Enable a delay before reading temperature seensors"
- help
- Enables a delay on the first read of temperature sensors after
- the EC powers on. This allows for setting of any power rails that
- control the temperature sensors on the platform.
-
-if PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY
-
-config PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY_MS
- int "Temperature sensor read delay time"
- default 500
- help
- Sets the delay time, in milliseconds, before the first the EC will
- read any temperature sensors and perform any thermal management.
-
-endif # PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY
-
-config PLATFORM_EC_FAN
- bool "Fan support"
- depends on PLATFORM_EC_PWM
- help
- Enables support for fans. Allows periodic thermal task to
- automatically set the fan speed (control temperature).
- Once enabled fanduty, fanset, faninfo, fanauto consol command and
- EC_CMD_PWM_GET_FAN_TARGET_RPM, EC_CMD_PWM_SET_FAN_TARGET_RPM,
- EC_CMD_PWM_SET_FAN_DUTY, EC_CMD_THERMAL_AUTO_FAN_CTRL are
- available. Also enables a periodic task (1s) to verify fan is
- running (is not stalled).
diff --git a/zephyr/Kconfig.throttle_ap b/zephyr/Kconfig.throttle_ap
deleted file mode 100644
index 153aefd085..0000000000
--- a/zephyr/Kconfig.throttle_ap
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC_THROTTLE_AP
-
-# TODO(b/177676794): Add the CONFIG_THROTTLE_AP_ON_... options
-
-config PLATFORM_EC_CHIPSET_CAN_THROTTLE
- bool "CPU can support throttling"
- default y
- help
- Indicates that the SoC supports throttling. This means that a
- chipset_throttle_cpu() function is provided by the chipset, to be
- called to set the throttle state. The typical implementation asserts
- GPIO_CPU_PROCHOT, to make the CPU slow down.
-
-config PLATFORM_EC_CONSOLE_CMD_APTHROTTLE
- bool "Console command: apthrottle"
- default y
- help
- This command shows the current status of AP throttling. Both soft
- (type 0) and hard (type 1) throttling are supported. Soft throttling
- is typically controlled by the AP via a host event. Hard throttling
- typically uses the PROCHOT (Processor Hot) signal on x86 CPUs.
-
- Example output:
-
- AP throttling type 0 is off (0x00000000)
- AP throttling type 1 is off (0x00000000)
-
-endif # PLATFORM_EC_THROTTLE_AP
diff --git a/zephyr/Kconfig.timer b/zephyr/Kconfig.timer
deleted file mode 100644
index 5b615961eb..0000000000
--- a/zephyr/Kconfig.timer
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC_TIMER
-
-config PLATFORM_EC_CONSOLE_CMD_GETTIME
- bool "Console command: gettime"
- default y
- help
- Enable the "gettime" command. This shows the current time (in
- microseconds since boot) in both hex and in decimal converted to
- seconds. For example:
-
- Time: 0x0000000002706a62 = 40.921698 s
-
-
-config PLATFORM_EC_CONSOLE_CMD_TIMERINFO
- bool "Console command: timerinfo"
- default y
- help
- Enable the "timerinfo" command which shows the current time (in
- microseconds and seconds since boot), the deadline (next time the EC
- needs to wake up) and a list of active timers along with when they
- will next fire.
-
- Example:
-
- Time: 0x0000000002706a62 us, 40.921698 s
- Deadline: 0x000000000270774d -> 0.003307 s from now
- Active timers:
- Tsk 1 0x000000000271db8f -> 0.094509
- Tsk 4 0x00000000027396b3 -> 0.207953
- Tsk 13 0x00000000027133a1 -> 0.051519
-
-
-config PLATFORM_EC_CONSOLE_CMD_WAITMS
- bool "Console command: waitms"
- default y
- help
- Enable the "waitms" command. This waits for a given number of
- milliseconds. For example:
-
- waitms 100
-
- waits for 100ms. Note that long waits can introduce problems since
- it stops the EC from executing its normal tasks. For example, a
- two-second wait can cause the EC to reset.
-
-endif # PLATFORM_EC_TIMER
diff --git a/zephyr/Kconfig.usbc b/zephyr/Kconfig.usbc
deleted file mode 100644
index ee79eb1d04..0000000000
--- a/zephyr/Kconfig.usbc
+++ /dev/null
@@ -1,1231 +0,0 @@
-# Copyright 2020 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.
-
-# TODO(sjg): Not USB-C: perhaps we should have a 'power' thing at the top level?
-config PLATFORM_EC_USB_A_PORT_COUNT
- int "Number of USB-A ports"
- default 0
- help
- This sets the number of USB-A ports on the device. These ports do
- not support USB Power Delivery features but can be used to power
- external devices (according to the USB 3 spec, not the Battery Charger
- standard) and to charge devices slowly if power is enabled to them.
-
-config PLATFORM_EC_USB_PORT_POWER_DUMB
- bool "Simple control of power to USB-A ports"
- depends on PLATFORM_EC_USB_A_PORT_COUNT > 0
- default y
- help
- Enable this to provide simple control of the power to USB ports
- using GPIOs. To use this your board code must provide a
- usb_port_enable[] array with the GPIOs to use for each port. This
- implements the EC_CMD_USB_CHARGE_SET_MODE host command and provides
- a 'usbchargemode' console command.
-
-config PLATFORM_EC_USB_PORT_POWER_DUMB_CUSTOM_HOOK
- bool "Simple control of power to USB-A ports"
- depends on PLATFORM_EC_USB_PORT_POWER_DUMB
- help
- Enable this if your board does not want to use the default S3 hooks
- from USB_PORT_POWER_DUMB.
-
-menuconfig PLATFORM_EC_USBC
- bool "USB Type-C"
- default y if PLATFORM_EC_BATTERY
- help
- Enable this to support various USB Type-C features chosen by the
- options below. USB-C is widely used on modern Chromebooks and the EC's
- role is to negotiate power contracts (for sourcing or sinking power
- over USB). The EC is also responsible for discovering the capabilities
- of attached USB-C partners and enabling alternate operational modes,
- including Display Port, Thunderbolt, and USB4.
-
-if PLATFORM_EC_USBC
-
-config PLATFORM_EC_CHARGE_MANAGER
- bool "Charge manager"
- default y
- help
- The EC charge manager manages charging the battery from all supported
- power sources. This includes dedicated charge ports (such as a
- barrel jack connector), BC1.2 (Battery Charging 1.2) sources, and
- USB-C sources. When multiple charge sources are connected to a
- Chromebook simultaneously, the charge manager is responsible for
- picking the best source.
-
- Note that the charge manager assumes that at least one USB-C power
- source is available on the hardware, so cannot be built without
- PLATFORM_EC_USBC.
-
-config PLATFORM_EC_CHARGER_INPUT_CURRENT
- 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.
-
- 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
-
-menuconfig PLATFORM_EC_BOOT_AP_POWER_REQUIREMENTS
- bool "Power requirements to boot AP"
- default y
- help
- Power thresholds for AP boot.
- If one of the following conditions is met, EC boots AP:
- 1. Battery charge >= CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON.
- 2. AC power >= CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON.
- 3. Battery charge >= CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC
- and
- AC power >= CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT.
-
-if PLATFORM_EC_BOOT_AP_POWER_REQUIREMENTS
-
-config PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
- int "Minimal battery level to boot AP without AC"
- depends on PLATFORM_EC_BATTERY
- default 3
- help
- Sets the minimum battery capacity, as a percentage, needed to boot
- the AP when AC power is not supplied.
-
-config PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC
- int "Minimal battery level to boot AP with AC"
- depends on PLATFORM_EC_BATTERY && PLATFORM_EC_CHARGE_MANAGER
- default 1
- help
- Sets the minimum battery capacity, as a percentage, needed to boot
- the AP when AC power is supplied. The AC power supplied must also
- be greater than CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT.
-
-config PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT
- int "Minimal AC power to boot AP with battery"
- depends on PLATFORM_EC_BATTERY && PLATFORM_EC_CHARGE_MANAGER
- default 15000
- help
- Sets the minimum power, in milliwatts, supplied by an external
- charger required to boot the AP when the battery capacity is also
- above CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC.
-
-config PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON
- int "Minimal AC power to boot AP without battery"
- depends on PLATFORM_EC_CHARGE_MANAGER
- default 15000
- help
- Sets the minimum power, in milliwatts, supplied by an external
- charger requires to boot the AP when no battery is present or
- under dead battery conditions. If the AP requires greater than
- 15W to boot, check the
- CONFIG_PLATFORM_EC_CHARGER_LIMIT_POWER_THRESH_CHG_MW setting.
-
-endif # PLATFORM_EC_BOOT_AP_POWER_REQUIREMENTS
-
-config PLATFORM_EC_USBC_OCP
- bool
- help
- USB-C overcurrent protection: Enable this to detect when a connected
- USB-C partner draws too much power from the Chromebook and
- automatically shut off power to the USB-C partner.
-
- This should be enabled by drivers which can detect over-current. It
- cannot be set otherwise, even in prj.conf
-
-config PLATFORM_EC_USB_PID
- hex "USB Product ID"
- help
- Each platform (e.g. baseboard set) should have a single VID/PID
- combination. If there is a big enough change within a platform,
- then we can differentiate USB topologies by varying the hardware
- version field in the Sink and Source Capabilities Extended messages.
-
- To reserve a new PID within Google, use go/usb and see
- http://google3/hardware/standards/usb
-
-config PLATFORM_EC_USB_BCD_DEV
- hex "USB Device ID"
- default 0
- help
- This specifies the USB device version, reported by board when acting
- as the upstream facing port (UFP). This is a 16-bit unsigned integer
- and should be set to a version number relevant to the release version
- of the product.
-
-config PLATFORM_EC_USB_VID
- hex "USB Vendor ID"
- default 0x18d1
- help
- This specifies the USB vendor ID used for boards which expose a
- USB endpont when the port is in UFP mode. The default value is
- set to Google's assigned VID and typically would not need to be
- changed. But, in certain cases this may need to be changed to
- match an OEM's vendor ID.
-
-config PLATFORM_EC_USBC_RETIMER_INTEL_BB
- bool "Support Intel Burnside Bridge retimer"
- help
- Enable this to support the Intel Burnside Bridge Thunderbolt / USB /
- DisplayPort retimer.
-
- Intel Burnside Bridge is a Type-C multi-protocol retimer to be used
- in on-board applications. Burnside Bridge offers the ability to latch
- protocol signals into on-chip memory before retransmitting them
- onwards. It can be used to extend the physical length of the system
- without increasing high-frequency jitter.
-
- Burnside Bridge supports spec compliant retimer of following
- protocols:
-
- - Display Port: four unidirectional DP lanes
- - USB3.1 Gen1/2: one bi-directional USB lane
- - Thunderbolt: two bi-directional CIO lanes
- - Multifunction Display (MFD): two unidirectional lanes of DP and
- one bidirectional lane of USB3.1 Gen1/2
-
-config PLATFORM_EC_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG
- bool "Use runtime configuration of Intel Burnside Bridge"
- depends on PLATFORM_EC_USBC_RETIMER_INTEL_BB
- default y
- help
- Enable this to allow run-time configuration of the Burnside Bridge
- driver structure. This makes the bb_controls[] array writable, i.e.
- not const. It should be declared as such in the board config.
-
- This is useful when the board has runtime information that changes
- the configuration, such as Chromium OS Board Info (CBI set in the
- factory. Without this, multiple EC images would need to be installed
- depending on the board.
-
-config PLATFORM_EC_USBC_RETIMER_ANX7451
- bool "Support Analogix ANX7451 10G Active Mux and Retimer"
- help
- ANX7451 is a 4x4 re-timing mux capable of switching DisplayPort (DP)
- and USB3.2 Gen 2 10Gbps signals to support a single USB Type-C port.
- ANX7451 has built-in re-timers to recover both the USB and DP signals
- with loss compensation of 23dB for USB and up to 27dB for DP.
-
-config PLATFORM_EC_USBC_RETIMER_PS8811
- bool "Support Parade PS8811 Single Port USB 3.1 Gen 2 10G Retimer"
- help
- The PS8811 is a one-port bidirectional USB 3.1 Gen 2 retimer that
- integrates the UniEye equalizer and a retimer to re-condition USB 3.1
- signals for long media link applications. It supports USB 3.1 Gen 2
- with operation speed up to 10Gbps as well as Gen 1 operation at 5Gbps.
-
-config PLATFORM_EC_USBC_RETIMER_KB800X
- bool "Enable KB800X retimer"
- help
- The KB8001 is a Universal Serial Bus (USB) Type-C 40 Gb/s multiprotocol
- switch and bidirectional Bit-Level Retimer (BLR) which supports:
- - Display Port: four unidirectional DP lanes
- - USB3.1 Gen1/2: one bi-directional USB lane
- - USB4/Thunderbolt: two bi-directional CIO lanes
- - Multifunction Display (MFD): two unidirectional lanes of DP and
- one bidirectional lane of USB3.1 Gen1/2
-
-config PLATFORM_EC_KB800X_CUSTOM_XBAR
- bool "Use custom remapping of HSIO XBAR"
- depends on PLATFORM_EC_USBC_RETIMER_KB800X
- default n
- help
- Enable this to allow using a custom crossbar configuration for the HSIO
- lanes.
-
-menuconfig PLATFORM_EC_USB_POWER_DELIVERY
- bool "USB Type-C Power Delivery (PD)"
- default y
- select HAS_TASK_PD_C0
- help
- USB has always provided basic power to an attached peripheral. USB-C
- PD is part of the USB 3.0 standard and allows a lot more functionality
- than the basic 500mA @ 5V. It allows negotiating power delivery over
- the USB cable to select voltages up to 20V with current up to 5A.
-
- This option also enables the Type-C Port Manager (TCPM) on the EC. The
- TCPM deals with the various state changes in the system as devices are
- plugged and unplugged, as well as changes in power requirements from
- those devices.
-
-if PLATFORM_EC_USB_POWER_DELIVERY
-
-config PLATFORM_EC_USB_PD_HOST_CMD
- bool "Host commands related to USB Power Delivery"
- default y
- help
- This enables host commands which allow finding out the capabilities
- of USB PD, checking is status and controlling how it operates. For
- devices which support firmware update, this is provided as well,
- with the firmware being sent from the AP.
-
-config PLATFORM_EC_USB_PD_PORT_MAX_COUNT
- int "Maximum number of USB PD ports supported"
- default 2
- help
- This sets the limit on the number of PD ports supported on the
- device. This is used to set the size for tables used by devices.
-
- TODO(b/176237074): Can we calculate this from the devicetree at some
- point? Or update the sn5S330 driver to use an 8-bit flag byte for
- source_enabled[] so that plenty of ports are supported without this
- configuration option?
-
-config PLATFORM_EC_CONSOLE_CMD_MFALLOW
- bool "Console command: mfallow"
- default y
- help
- Controls whether multi-function support is allowed for DP (Display
- Port) connections. Default setting allows multi-function support when
- the attached device also supports multi-function mode.
-
- mfallow <port> [true | false]
-
-config PLATFORM_EC_CONSOLE_CMD_PD
- bool "Console command: pd"
- default y
- help
- Provides information about the current USB Power Delivery state and
- also allows various changes to be made for testing purposes.
-
- It has a number of subcommands:
-
- pd dump <n> - sets the debug level (0-3). This affects all layers
- of the stack
- pd trysrc [0/1/2] - prints or sets the Try.SRC override. Use 0 to
- force Try.SRC off, 1 to force Try.SRC on, and 2 to
- let USB PD stack control the Try.SRC behavior.
- pd version - show PD version in use
- pd <port> state - show start for a PD port
-
- Ssee usb_pd_console.c for full details including various commands
- for role swap, reset, enable/disable, requesting SNK or SRC, etc.
-
-config PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL
- bool "USB Power Delivery debug level is fixed at build time"
- help
- Enable this to set the debug level to a fixed value in the build.
- This saves space but means that the level cannot be changed using
- commands like 'pd dump'. Typically this should be set when a platform
- is shipped.
-
-config PLATFORM_EC_USB_PD_DEBUG_LEVEL
- int "Debug level to use"
- depends on PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL
- help
- Sets the value of the debug level to use. If this is 0 then no
- debugging output is available from the USB Power Delivery stack.
- The meaning of each level depends on the module in question, but
- the maximum available level is 3.
-
-config PLATFORM_EC_USB_PD_5V_EN_CUSTOM
- bool "Custom method of detecting VBUS"
- help
- Enable this if your board needs a custom method to determine if VBUS
- is enabled on a source port. You must provide an implementation of:
-
- int board_is_sourcing_vbus(int port)
-
- It should return 0 if not sourcing VBUS on that port and non-zero
- if sourcing.
-
-choice "Measuring VBUS voltage"
- prompt "Select how VBUS voltage is measured"
-
-config PLATFORM_EC_USB_PD_VBUS_MEASURE_NOT_PRESENT
- bool "VBUS voltage cannot be read"
- help
- Enable this if the board does not provide any mechanism for the EC to
- read the analog VBUS voltage.
-
-config PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER
- bool "On-board charger supports VBUS measurement"
- help
- Enable this if the VBUS voltage can be read using a charger on the
- board.
-
-config PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC
- bool "Type-C Port Controller supports VBUS measurement"
- help
- Enable this if the VBUS voltage can be read using the on-board
- TCPC.
-
-config PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT
- bool "VBUS on each port is measured using an ADC channel"
- help
- Enable this is there is a separate ADC channel for each USB-C VBUS
- voltage.
-
-endchoice # Measuring VBUS voltage
-
-config PLATFORM_EC_USBC_VCONN
- bool "Support USB Type-C VCONN"
- default y
- help
- This enables support for USB Type-C connector voltage (VCONN). This
- option must be enabled to communicate with electronically marked
- (E-Mark) cables. This option is required for operation with USB4 and
- Thunderbolt devices.
-
- This is not needed for captive cables.
-
-config PLATFORM_EC_USB_PD_DUAL_ROLE
- bool "Board can act as a dual-role Power Delivery port"
- default y
- help
- This enables support for switching between source and sink during
- operation. This means that the port can accept power (e.g. to charge
- up its battery), or send out power to an attached device on the same
- port.
-
-config PLATFORM_EC_USB_PD_FRS
- bool "Support Fast Role Swap protocol"
- help
- Enables the protocol side of Fast Role Swap (FRS). This allows the
- device to switch from a SNK to a SRC (or vice versa) based on
- communication with the partner device.
-
- For this to work the trigger must be implemented in either the
- Type-C Port Controller (TCPC) or Power Path Controller (PPC).
-
- FRS differs from the traditional power-role swap in that FRS
- guarantees there is no interruption of power nor disruption of data
- communication to any downstream devices (such as devices connected
- to a USB-C hub or dock).
-
-if PLATFORM_EC_USB_PD_FRS
-
-choice "Trigger implementation"
- prompt "Select where the trigger is implemented"
- help
- The Fast Role Swap (protocol requires that a trigger be implemented to
- initiate the swap. Use this option to select which of the available
- options should be used.
-
-config PLATFORM_EC_USB_PD_FRS_PPC
- bool "PPC"
- depends on PLATFORM_EC_USBC_PPC
- help
- Enable this if the Fast Role Swap trigger is implemented in the
- Power Path Controller (PPC).
-
-config PLATFORM_EC_USB_PD_FRS_TCPC
- bool "TCPC"
- depends on PLATFORM_EC_USBC_TCPC
- help
- Enable this if the Fast Role Swap trigger is implemented in the
- Type-C Port Controller (TCPC).
-
-endchoice # Trigger implementation
-
-endif # PLATFORM_EC_USB_PD_FRS
-
-config PLATFORM_EC_USB_PD_DPS
- bool "Board can support Dynamic PDO Selection"
- depends on PLATFORM_EC_BATTERY
- default n
- 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 overrided by `dps_config` to adapt
- to each board's need.
-
-config PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE
- bool "Board can use TCPC-controlled DRP toggle"
- depends on PLATFORM_EC_USB_PD_DUAL_ROLE
- default y
- help
- Enable this if the USB Type-C Port Controllers (TCPC) used on the
- board supports toggling of the power role autonomously. When this is
- disabled, the USB power delivery task is responsible for manually
- toggling the power role.
-
-config PLATFORM_EC_USB_PD_DISCHARGE
- bool "Board can discharge VBUS"
- default y
- help
- Enable this if the board can enable VBUS discharge (eg. through a
- GPIO-controlled discharge circuit, or through port controller
- registers) to discharge VBUS rapidly on disconnect
-
-choice "Discharge method"
- prompt "Select the discharge method"
- depends on PLATFORM_EC_USB_PD_DISCHARGE
-
-config PLATFORM_EC_USB_PD_DISCHARGE_GPIO
- bool "GPIO control"
- help
- Enable this if the discharge circuit is controlled by a GPIO
-
- TODO: How to specify the GPIO?
-
-config PLATFORM_EC_USB_PD_DISCHARGE_TCPC
- bool "Discharge circuit is provided by the TCPC"
- help
- Enable this if the discharge circuit is provided by Power-Delivery
- resistors on the USB Type-C Port Controller (TCPC).
-
-config PLATFORM_EC_USB_PD_DISCHARGE_PPC
- bool "Discharge circuit is provided by the PPC"
- help
- Enable this if the discharge circuit is using Power Delivery
- resistors on the Power Path Controller.
-
-endchoice # Discharge method
-
-config PLATFORM_EC_USB_PD_REV30
- bool "USB PD Rev3.0 functionality"
- default y
- help
- Enable this to allow Rev3.0 functionality, including features such as
- Fast Role Swap, advertising the available power across all ports of a
- multi-port charger, and USB4. If disabled, only USB Power Delivery
- Rev2.0 functionality is supported.
-
- This defaults to y because PD Rev3.0 is required for USB4
- functionality.
-
-config PLATFORM_EC_USB_PD_ALT_MODE
- bool "USB Power Delivery alternate mode"
- default y
- help
- Enable this to support USB PD alternate mode. This allows negotiation
- of a different mode of operation to allow non-USB traffic to pass over
- a USB Type-C link. This makes use of some or all of the USB 3.0 bus
- differential pairs. If all are used for the alternate mode, then USB
- transmission is not available at all while in this mode.
-
-config PLATFORM_EC_USB_PD_ALT_MODE_DFP
- bool "Downward Facing Port support"
- default y
- help
- Enable support for USB Power Delivery alternate mode of Downward
- Facing Port.
-
- TODO: Add more help here
-
-config PLATFORM_EC_USB_PD_ALT_MODE_UFP
- bool "Upward Facing Port support"
- help
- Enable support for USB Power Delivery alternate mode of Upward
- Facing Port (UFP).
-
- By default, Chromium OS only enables alternate modes (Display Port,
- USB4, Thuderbolt, etc) when the USB data role resolves to the
- Downstream Facing Port (DFP) role. Enable this option to support
- USB4 and ThunderBolt operation when the Chromium OS data role
- resolves to the UFP role.
-
-config PLATFORM_EC_USB_PD_USB32_DRD
- bool "Port is cable of operating as an USB3.2 device"
- default y
- help
- Enable this if the board's USB Power Delivery Downward Facing Port is
- able to support the USB3.2 standard. This is advertised to the
- other end so that it can potentially take advantage of the additional
- features available.
-
-config PLATFORM_EC_USB_PD_DP_HPD_GPIO
- bool "Hotplug Detect (HPD) is controlled by an EC GPIO"
- help
- Enable this if the EC must send the Hotplug Detect (HPD) signal to
- the DisplayPort Graphics Processing Unit (GPU) via a GPIO. Otherwise
- this is sent by the display device.
-
-config PLATFORM_EC_USB_PD_DP_HPD_GPIO_CUSTOM
- bool "Custom handling of HPD GPIO"
- depends on PLATFORM_EC_USB_PD_DP_HPD_GPIO
- help
- Enable this if the Hotplug Detect (HPD) GPIO level has to be handled
- by custom functions. In this case your board must implement a
- function to enable the feature for a port and another function to
- check the current state:
-
- void svdm_set_hpd_gpio(int port, int enable);
-
- int svdm_get_hpd_gpio(int port);
-
-choice "VBUS detection method"
- prompt "Select the method to detect VBUS"
-
-config PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC
- bool "TCPC detects VBUS"
- help
- Choose this option if the TCPC can detect the presence of VBUS
-
-config PLATFORM_EC_USB_PD_VBUS_DETECT_CHARGER
- bool "Charger detects VBUS"
- help
- Choose this option if the battery charger can detect the presence
- of VBUS
-
-config PLATFORM_EC_USB_PD_VBUS_DETECT_PPC
- bool "PPC detects VBUS"
- help
- Choose this option if the Power-Path Controller (PPC) can detect the
- presence of VBUS
-
-config PLATFORM_EC_USB_PD_VBUS_DETECT_NONE
- bool "No way to detect VBUS"
- help
- Choose this option if it is not possible to detect VBUS.
-
-endchoice # VBUS detection method
-
-config PLATFORM_EC_USB_TYPEC_SM
- bool "Type-C (TC) physical-layer state machine"
- default y
- help
- This enables the bottom layer of the TCPMv2 state machine which
- handles using CC lines to set the voltage-level of the power supplied.
- You should normally define this unless you want to override it in your
- board code, which is not recommended.
-
-config PLATFORM_EC_USB_PRL_SM
- bool "Protocol layer (PRL) state machine"
- default y
- help
- This enables the middle layer of the power-delivery (PD) protocol,
- which deals with the flow of power messages across the USB Type-C
- interface. You should normally define this unless you want to override
- it in your board code, which is not recommended.
-
-config PLATFORM_EC_USB_PE_SM
- bool "Policy engine (PE) state machine"
- default y
- help
- This enables the top layer of the power-delivery (PD) protocol, which
- deals with the actually PD messages that are exchanged with attached
- 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_PD_DECODE_SOP
- def_bool y # Required for TCPMV2
- help
- This enables support for encoding of the message's Start Of Packet
- (SOP, SOP' and SOP'', collectively called SOP*) in bits 31-28 of the
- 32-bit msg header type.
-
-config PLATFORM_EC_HOSTCMD_PD_CONTROL
- bool "Host command: EC_CMD_PD_CONTROL"
- default y
- help
- Enable the EC_CMD_PD_CONTROL host command. This allows control
- of the USB-PD chip from the AP, including reset, suspend/resume
- and enabling power.
-
- This host command can be manually executed using the
- "ectool pdcontrol" command from the Chromium OS shell.
-
-config PLATFORM_EC_USB_PD_LOGGING
- bool "Host command: EC_CMD_PD_GET_LOG_ENTRY"
- help
- Enable logging of USB Power Delivery events. The AP can request the
- log to see what has happened recently.
-
- The log events are stored in a circular buffer, each one being a
- struct event_log_entry.
-
-menuconfig PLATFORM_EC_USB_PD_CONSOLE_CMD
- bool "Enable USB PD console commands"
- default y if PLATFORM_EC_USB_PD_ALT_MODE_DFP
- help
- Enables various USB-C PD related console commands.
-
-if PLATFORM_EC_USB_PD_CONSOLE_CMD
-
-config PLATFORM_EC_CONSOLE_CMD_USB_PD_PE
- bool "Console command: pe"
- default y
- help
- This command dumps information about the USB PD alternate mode options
- discovered from the partner device. It can be useful for debugging.
-
- Example: pe 1 dump
- IDENT SOP:
-
- [ID Header] 2c000bda :: AMA, VID:0bda
- [Cert Stat] 00000000
- [2] 00000209 [3] 11000f09
- IDENT SOP':
- [ID Header] 1c000489 :: PCable, VID:0489
- [Cert Stat] 000001c6
- [2] f6810000 [3] 11082051
- SVID[0]: ff01 MODES: [1] 000c0045
- MODE[1]: svid:ff01 caps:000c0045
-
-config PLATFORM_EC_CONSOLE_CMD_USB_PD_CABLE
- bool "Console command: pdcable"
- default y
- help
- This commands shows the USB cable charactistics as detected from the
- device. It can be useful for debugging problems with cables and the
- device's response to them.
-
- Example: pdcable 1
- Cable Type: Passive
- Cable Rev: 1.0
- Connector Type: 2
- Cable Current: 5A
- USB Superspeed Signaling support: 1
- Rounded support: No
- Optical cable: No
- Retimer support: No
- Link training: Bi-directional
- Thunderbolt cable type: Passive
-
-endif # PLATFORM_EC_USB_PD_CONSOLE_CMD
-
-choice "USB-C device type"
- prompt "Select the USB-C device type"
- default PLATFORM_EC_USB_DRP_ACC_TRYSRC
-
-config PLATFORM_EC_USB_VPD
- bool "VCONN-Powered Device"
- help
- This enables support for supplying power to devices that accept power
- over the USB VCONN line.
-
- See here for details:
-
- https://www.usb.org/sites/default/files/D1T2-3a%20-%20CTVPDs%20and%20Making%20Your%20Own%20USB-C%20Thingamajig.pdf
-
-config PLATFORM_EC_USB_CTVPD
- bool "Charge-Through VCONN-Powered Device"
- help
- This enables support for supplying power to devices, with a circuit
- that deals with this without needing the involvement of the main
- device.
-
-config PLATFORM_EC_USB_DRP_ACC_TRYSRC
- bool "Dual-Role Port, Audio Accessory, and Try.SRC Device"
- help
- This is the most flexible option, allowing the port to operate in
- a dual-role capacity, so that power can be accepted or supplied on
- a port.
-
-endchoice # USB-C device type
-
-config PLATFORM_EC_USB_PD_TRY_SRC
- bool "Enable Try.SRC mode"
- depends on PLATFORM_EC_USB_DRP_ACC_TRYSRC
- default y
- help
- This enables Try.SRC mode so that the board will try to be a source
- for power if the other end offers both options. This can be useful
- for laptops, for example, since when attaching to a cellphone we want
- the laptop to charge the phone, not vice versa.
-
-config PLATFORM_EC_USB_PD_USB4
- bool "USB4 support"
- depends on PLATFORM_EC_USB_PD_REV30
- default y
- help
- This enables support for entering into USB4 mode between two port
- partners. The provides new features such as higher speeds and more
- flexible multiplexing of data on the cable for different purposes,
- e.g. attaching multiple displays and storage devices on the same bus.
-
-config PLATFORM_EC_USB_PD_TBT_COMPAT_MODE
- bool "Thunderbolt-compatible mode support"
- depends on PLATFORM_EC_USB_PD_REV30
- default y
- help
- Enable this to allow entering into Thunderbolt-compatible mode between
- two port partners. This does not require that USB4 mode be enabled.
-
-endif # PLATFORM_EC_USB_POWER_DELIVERY
-
-menuconfig PLATFORM_EC_USBC_PPC
- bool "USB Type-C Power Path Controller"
- default y
- help
- Enable this to support the USB Type-C PPC on your board. This enables
- common routines for things like figuring out whether power is being
- supplied to the Chromebook over USB-C, whether the Chromebook is
- supplying power to another device, etc.
-
-if PLATFORM_EC_USBC_PPC
-
-config PLATFORM_EC_USBC_PPC_POLARITY
- bool
- help
- Enable this if a Power Path Controller needs to be informed of
- the polarity of the Configuration Channel (CC) pins. This can change
- depending on which way up the USB-C cable is inserted into the
- device.
-
- This should be enabled by drivers which can detect this. It cannot be
- set otherwise, even in prj.conf
-
-config PLATFORM_EC_USBC_PPC_SBU
- bool
- help
- Enable this if a Power Path Controller is capable of gating the
- Sideband Use (SBU) lines. If so, the USB mux will use this feature
- to isolate the lines before entering into alternate mode.
-
- This should be enabled by drivers which can detect this. It cannot be
- set otherwise, even in prj.conf
-
-config PLATFORM_EC_USBC_PPC_VCONN
- bool
- depends on PLATFORM_EC_USBC_VCONN
- help
- Enable this if a Power Path Controller is capable of providing
- VCONN. If so, the USB stack will enable / disable VCONN as needed.
-
- This should be enabled by drivers which can detect this. It cannot be
- set otherwise, even in prj.conf
-
- Note: This may not be true, as there may be scenarios where the board
- might need to disable this feature (for instance when both the PPC and
- TCPC can supply VCONN). We can cross that bridge when we come to it.
-
-config PLATFORM_EC_USBC_PPC_SN5S330
- bool "TI SN5S330 PD 3.0 power mux"
- select PLATFORM_EC_USBC_OCP
- select PLATFORM_EC_USBC_PPC_POLARITY
- select PLATFORM_EC_USBC_PPC_SBU
- select PLATFORM_EC_USBC_PPC_VCONN if PLATFORM_EC_USBC_VCONN
- help
- This is a USB Type-C Power Delivery 3.0 Bidirectional Power Mux with
- CC and SBU short-to-VBUS Protection and Integrated Dead Battery
- LDO. This chips provides protection against pins shorting to Vbus as
- well as ESD (Electostatic discharge) protection. It provides a simple
- I2C interface for for Mode Selection, Fast Role Swap, and Fault
- Reporting.
-
-config PLATFORM_EC_USBC_PPC_SYV682X
- bool "SYV682X which is a Power Mux for USB PD"
- select PLATFORM_EC_USBC_OCP
- select PLATFORM_EC_USBC_PPC_POLARITY
- select PLATFORM_EC_USBC_PPC_VCONN if PLATFORM_EC_USBC_VCONN
- help
- The SYV682A is a 2 to 1 power mux switch for USB PD applications. The
- SYV682A supports dead battery wake up function and Fast Role Swap
- features. It provides protection against overcurrent, overvoltage,
- thermal shutdown, and undervoltage conditions.
-
-config PLATFORM_EC_USBC_PPC_SYV682C
- bool "SYV682C Power Mux for USB PD (subset of SYV682X)"
- depends on PLATFORM_EC_USBC_PPC_SYV682X
- help
- The C version of this chip won't block I2C accessing to the CONTROL4
- rer (to on/off Vconn) when smart discahrge is enabled. This allows us
- to re-enable the smart discharge on boards using SYV682C.
-
-config PLATFORM_EC_USBC_PPC_SYV682X_NO_CC
- bool "SYV682X does not pass through CC"
- help
- Enable this if a SYV682X does not pass through CC.
- There is a 3.6V limit on the HOST_CC signals, so the TCPC
- should not source 5V VCONN. This config determines if
- sourcing VCONN should be enabled by default.
-
-config PLATFORM_EC_USBC_PPC_SYV682X_SMART_DISCHARGE
- bool "Enable smart discharge on the SYV682X PPC"
- help
- Enable the smart discharge feature on VBUS provided by the SYV682x
- PPC. This should be enabled for revision C and above of the SYV682X.
- Earlier revisions of the chip block I2C transactions during smart
- discharge, causing USB PD compliance issues.
-
-config PLATFORM_EC_USBC_PPC_DEDICATED_INT
- bool "Power Power Controller has a dedicated interrupt pin"
- help
- Enable this if the Power Power Controller (PPC) has level interrupts
- (as opposed to edge) and a dedicated interrupt pin to check the
- current state.
-
- If this is enabled the USB Power Delivery (PD) stack will call
- ppc_get_alert_status() to find out he interrupt status for a port.
- This function should be provided by the board code.
-
-config PLATFORM_EC_USB_PD_TCPC_LOW_POWER
- bool "Allow Type-C Port Controller to enter low-power mode"
- default y
- help
- Allows entry to a low power mode when the USB port is idle.
- When enabled, an enter_low_power_mode member is present in tcpm_drv
- and should be set to a function that selects that mode, such as
- tcpci_enter_low_power_mode() for TCPCI-compatible TCPCs.
-
-config PLATFORM_EC_USB_PD_TCPC_LPM_EXIT_DEBOUNCE_US
- int "Debounce delay when exiting low-power mode (uS)"
- depends on PLATFORM_EC_USB_PD_TCPC_LOW_POWER
- default 25000
- help
- Some TCPCs need additional time following a VBUS change to internally
- debounce the CC line status and update the CC_STATUS register. This
- is the delay in microseconds to allow before checking the CC line
- status in the EC.
-
-config PLATFORM_EC_USB_PD_TCPC_VCONN
- bool "If VCONN is enabled, the TCPC will provide VCONN"
- default y if !PLATFORM_EC_USBC_PPC_SYV682X
- default y if PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP
- default y if PLATFORM_EC_USBC_PPC_SYV682X_NO_CC
- help
- Source USB Type-C connector voltage (VCONN) from the Type-C Port
- Controller (TCPC), and also the Power Path Controller (PPC) if
- present. Some TCPC/PPC can't handle 5V on its host-side CC pins, so
- disable this config in those cases.
-
-choice "Type-C Port Manager (TCPM)"
- prompt "Choose a Type-C Port Manager (TCPM) to manage TCPC"
-
-config PLATFORM_EC_USB_PD_TCPM_TCPCI
- bool "Use TCPCI"
- help
- Enable a TCPC compatible with the Type-C Port Controller Interface
- (TCPCI) Specification. This driver supports both Rev1 v1.2 and Rev2
- v1.0 of the TCPCI specification. Select this driver directly only
- if your specific TCPC chip is not listed as a separate config option.
-
- Note: most of the TCPC will depend on PLATFORM_EC_USB_PD_TCPM_TCPCI.
-
-# TODO: Add other choices:
-# CONFIG_USB_PD_TCPM_STUB
-# CONFIG_USB_PD_TCPM_FUSB302
-# CONFIG_USB_PD_TCPM_ANX3429
-# CONFIG_USB_PD_TCPM_ANX740X
-# CONFIG_USB_PD_TCPM_ANX741X
-# CONFIG_USB_PD_TCPM_ANX7447
-# CONFIG_USB_PD_TCPM_ANX7688
-# CONFIG_USB_PD_TCPM_NCT38XX
-# CONFIG_USB_PD_TCPM_MT6370
-# CONFIG_USB_PD_TCPM_RAA489000
-# CONFIG_USB_PD_TCPM_FUSB307
-# CONFIG_USB_PD_TCPM_STM32GX
-# CONFIG_USB_PD_TCPM_CCGXXF
-
-endchoice # Type-C Port Manager (TCPM)
-
-menuconfig PLATFORM_EC_USB_MUX
- bool "USB muxes"
- default y
- help
- Enables support for USB muxes. These allow multiplexing
-
-if PLATFORM_EC_USB_MUX
-
-config PLATFORM_EC_USB_MUX_IT5205
- bool "ITE IT5205 USB Type-C 3:2 Alternative mode passive mux"
- help
- This is a USB Type-C 3:2 Alternative mode mux, supporting USB 3.1
- Gen 2 10Gbps as well as DisplayPort (DP1.4) at 8Gbps. It provides a
- cross-point mux for low-speed Side-Band-Use (SBU) pins. The mux can
- be controlled via I2C.
-
-config PLATFORM_EC_USB_MUX_PS8743
- bool "Parade PS8743 USB-C Host Switch with redriver"
- help
- This is a Parade USB 3.1 Gen 1 / DisplayPort (DP) Alt Mode
- High-Bit-Rate 2 (HBR2) redriver. It provides control of switching
- modes through either GPIO or I2C.
-
-endif
-
-config PLATFORM_EC_USBC_SS_MUX
- bool "SuperSpeed mux"
- default y
- help
- Enable this to support the USB Type-C SuperSpeed Mux. If enabled,
- the USB stack will call usb_mux_set() to change the mux settings.
- The board must provide a driver in usb_muxes[] for each port so
- that this can work.
-
-if PLATFORM_EC_USBC_SS_MUX
-
-config PLATFORM_EC_USB_MUX_RUNTIME_CONFIG
- bool "USB mux runtime config"
- default y
- help
- Allows the configuration of the USB mux to be set up at runtime. This
- makes the usb_muxes[] array writable, i.e. not const. It should be
- declared as such in the board config.
-
- This is useful when the board has runtime information that changes
- the configuration, such as Chromium OS Board Info (CBI set in the
- factory. Without this, multiple EC images would need to be installed
- depending on the board.
-
-config PLATFORM_EC_USBC_SS_MUX_DFP_ONLY
- bool "Use SuperSpeed mux only when DFP"
- help
- Only configure the USB Type-C SuperSpeed Mux when a port is a
- Downstream Facing Port (DFP). This is needed for chipsets which
- don't support being an Upstream Facing Port UFP).
-
-config PLATFORM_EC_USB_MUX_VIRTUAL
- bool "USB Mux is virtual"
- depends on PLATFORM_EC_USBC_SS_MUX
- help
- Enable this if a virtual USB mux is supported on the EC, which is
- actually handled by the AP. In this case the AP gets an interrupt
- and is is informed when status changes, via the
- EC_CMD_USB_PD_MUX_INFO host command.
-
-config PLATFORM_EC_USBC_RETIMER_FW_UPDATE
- bool "Support firmware update of USB Type-C retimers"
- default y
- depends on PLATFORM_EC_USBC_SS_MUX
- help
- Enable this to support USB Type-C retimer firmware update. Each
- Type-C retimer indicates its capability of supporting firmware update
- independently in its usb_mux_driver.
-
- During AP boot-up, the AP scans each PD port for retimers but only
- if there are no Type-C devices attached to the port. The firmware
- update can only be performed on retimers which show up in the AP
- thunderbolt device entries.
-
-endif # PLATFORM_EC_USBC_SS_MUX
-
-config PLATFORM_EC_CONSOLE_CMD_PPC_DUMP
- bool "Console command: ppc_dump"
- depends on PLATFORM_EC_USBC_PPC
- default y
- help
- Allows dumping of the Power Path Controller (PPC) state, which is
- basically a list of registers and their values. The actual dump
- function is driver-specific (the reg_dump member of ppc_drv). By
- reference to the datasheet for the part this can help you figure out
- what is going on.
-
-if PLATFORM_EC_USB_PD_TCPM_TCPCI
-
-config PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP
- bool "Use on-chip ITE"
- help
- Use the ITE-series TCPM driver built into the EC chip.
-
- This is selected by the ITE USB Type-C drivers. It cannot be set
- otherwise, even in prj.conf
-
-config PLATFORM_EC_USB_PD_ITE_ACTIVE_PORT_COUNT
- int "Number of ITE USB PD active ports"
- depends on PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP
- default 1
- help
- This sets the number of active USB Power Delivery (USB PD) ports
- in use on the ITE microcontroller. The active port usage should
- follow the order of ITE TCPC port index.
-
-config PLATFORM_EC_USB_PD_PPC
- bool "Enable Power Path Control from PD"
- default n
- help
- Some PD chips have integrated SRC FET and control the SRC/SINK FET
- from internal GPIOs. Enable this if the Power Path Control is
- controlled by the PD chip without EC GPIOs.
-
-config PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG
- bool "Type-C Port Controller runtime config"
- default y
- help
- Allows the configuration of the TCPC to be set up at runtime. This
- makes the tcpc_config[] array writable, i.e. not const. It should be
- declared as such in the board config.
-
- This is useful when the board has runtime information that sets
- the configuration, such as Chromium OS Board Info (CBI set in the
- factory. Without this, multiple EC images would need to be installed
- depending on the board.
-
-config PLATFORM_EC_USB_PD_TCPM_MULTI_PS8XXX
- bool "Support multiple PS8xxx devices"
- help
- PS8XXX-series chips are all supported by a single driver. Enable
- this If a board with the same EC firmware is expected to support
- multiple products here. Then enable the required PS8xxx options
- below.
-
- In this case the board must provide a function to return the correct
- product ID actually used by a particular board:
-
- uint16_t board_get_ps8xxx_product_id(int port)
-
- Supported return values are:
-
- PS8705_PRODUCT_ID
- PS8751_PRODUCT_ID
- PS8755_PRODUCT_ID
- PS8805_PRODUCT_ID
- PS8815_PRODUCT_ID
-
-config PLATFORM_EC_USB_PD_TCPM_PS8751
- bool "Parade PS8751 USB-C Gen 2 Type-C Port Controller"
- select PLATFORM_EC_USB_PD_TCPM_MUX
- help
- The Parade Technologies PS8751 is a USB Type-C Port Controller (TCPC)
- for USB Type-C Host and DisplayPort applications. It supports
- Power Delivery Rev. 2.0 and the DisplayPort Alt Mode version 1.0a.
-
-config PLATFORM_EC_USB_PD_TCPM_PS8805
- bool "Parade PS8805 USB-C Gen 2 Type-C Port Controller"
- select PLATFORM_EC_USB_PD_TCPM_MUX
- help
- The Parade Technologies PS8805 is an active retiming/redriving
- (respectively for USB 3.1 Gen 2 / DisplayPort 1.4a HBR3) integrated
- with a USB Type-C Port Controller (TCPC) for USB Type-C Host and
- DisplayPort applications. It supports Power Delivery and the
- DisplayPort Alt Mode.
-
-if PLATFORM_EC_USB_PD_TCPM_PS8805
-config PLATFORM_EC_USB_PD_TCPM_PS8805_FORCE_DID
- bool "Parade PS8805 Force Device ID"
- default y
- help
- Early firmware versions of the PS8805 report an incorrect device ID
- value for A3 silicon. Enable this option to check the vendor specific
- chip version register and force the correct device ID.
-endif # PLATFORM_EC_USB_PD_TCPM_PS8805
-
-config PLATFORM_EC_USB_PD_TCPM_PS8815
- bool "Parade PS8815 USB-C Gen 2 Type-C Port Controller"
- select PLATFORM_EC_USB_PD_TCPM_MUX
- help
- The Parade Technologies PS8815 is an active retiming/redriving
- (respectively for USB 3.1 Gen 2 / DisplayPort 1.4a HBR3) integrated
- with a USB Type-C Port Controller (TCPC) for USB Type-C Host and
- DisplayPort applications. It supports Power Delivery and the
- DisplayPort Alt Mode.
-
-if PLATFORM_EC_USB_PD_TCPM_PS8815
-config PLATFORM_EC_USB_PD_TCPM_PS8815_FORCE_DID
- bool "Parade PS8815 Force Device ID"
- default y
- help
- Early firmware versions of the PS8815 report an incorrect device ID
- value for A1 silicon. Enable this option to check the vendor specific
- chip version register and force the correct device ID.
-endif # PLATFORM_EC_USB_PD_TCPM_PS8815
-
-config PLATFORM_EC_USB_PD_TCPM_RT1715
- bool "Ricktek RT1715 Type-C Port Controller"
- help
- The RT1715 is a USB Type-C controller, integrating a complete Type-C
- Transceiver including the Rp and Rd resistors. It does the USB Type-C
- detection including attach and orientation. The RT1715 integrates the
- physical layer of the USB BMC power delivery protocol to allow up to
- 100W of power and role swap. The BMC PD block enables full support
- for alternative interfaces of the Type-C specification.
-
-config PLATFORM_EC_USB_PD_TCPM_TUSB422
- bool "TI TUSB422 Port Control with USB PD"
- help
- This is a a USB PD PHY that enables a USB Type-C port with the
- Configuration Channel (CC) logic needed for USB Type-C ecosystems. It
- integrates the physical layer of the USB BMC power delivery (PD)
- protocol to allow up to 100-W of power and support for alternate mode
- interfaces. An external microprocessor, containing USB Type-C Port
- Manager (TCPM), communicates with the TUSB422 through an I2C
- interface.
-
-config PLATFORM_EC_USB_PD_TCPM_MUX
- bool "Support optional register 18h steer the high-speed muxes"
- help
- Enable this option if the TCPC port controller supports the optional
- register 18h CONFIG_STANDARD_OUTPUT to steer the high-speed muxes.
-
- See section 4.4.4 (CONFIGURE STANDARD OUTPUT) of the USB Type-C Port
- Controller Interface Specification, Revision 2.0, Version 1.2 for more
- information.
-
-config PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP
- bool "Console command: tcpc_dump"
- # anx7447 also supports this command, but is not yet enabled
- default y
- help
- Allows dumping of the Type-C Port Controller (TCPC) state, which is
- basically a list of registers and their values. By reference to the
- Universal Serial Bus Type-C Port Controller Interface Specification
- this can help you figure out what is going on.
-
-endif # PLATFORM_EC_USB_PD_TCPM_TCPCI
-
-config PLATFORM_EC_USB_PD_TCPM_DRIVER_IT83XX
- bool "Enable IT83XX driver"
- depends on PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP
- help
- Enable a driver for the ITE IT83XX on-chip UBB Type-C Port Manager.
- This supports up to two USB Type-C ports with Dual Role function
- (provider and consumer) and Fast Role Swap detection.
-
-config PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2
- bool "Enable IT8XXX2 driver"
- depends on PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP
- help
- Enable a driver for the ITE IT8XXX2 on-chip UBB Type-C Port Manager.
- This supports up to two USB Type-C ports with Dual Role function
- (provider and consumer) and Fast Role Swap detection.
-
-endif # PLATFORM_EC_USBC_PPC
-
-config PLATFORM_EC_USB_PD_ONLY_FIXED_PDOS
- bool "Only support FIXED type PDOs"
- help
- Ignore all non-fixed PDOs received from a src_caps message. Enable
- this for boards (like servo_v4) which only support FIXED PDO types.
-
-config PLATFORM_EC_USB_CHARGER
- bool "Support charging from a USB-C port"
- default y
- select HAS_TASK_USB_CHG_P0
- help
- This enables common BC1.2 (Battery-Charging Specification Rev1.2)
- charger-detection routines. With this is possible to negotiate a
- power contract with an attached battery charger and use this to
- charge the device's battery.
-
-if PLATFORM_EC_USB_CHARGER
-
-config PLATFORM_EC_BC12_DETECT_PI3USB9201
- bool "Enable support for Pericom PI3USB9201"
- help
- This is a Dual-Role USB Charging-Type Detector. It can operate in
- host or client mode. It supports Battery Charging Specification, rev
- 1.2 (BC1.2) with Standard/Charging/Dedicated downstream port
- (SDP/CDP/DCP) advertisement when in host mode. In client mode it
- starts BC1.2 detection to detect the attached host type. It provides
- an I2C interface to report detection results.
-
-config PLATFORM_EC_BC12_DETECT_MT6360
- bool "MediaTek MT6360P PMIC"
- help
- This PMIC includes a battery charger with an On-The-Go (OTG) output
- range of 4.85 to 5.825V. It provides integrated ADCs for system
- monitoring. The MT6360 also supports USB Power Delivery 3.0 with
- Dual-Role, with host or client mode. It supports alternate mode as
- well as VCONN with programmable over-current protection (OCP).
-
-config PLATFORM_EC_MT6360_BC12_GPIO
- bool "USB-PHY connection is controlled by a GPIO"
- depends on PLATFORM_EC_BC12_DETECT_MT6360
- help
- If enabled, the MT6360 USB-PHY connection is controlled by
- a GPIO: GPIO_BC12_DET_EN. Assert GPIO_BC12_DET_EN to detect a BC1.2
- device, and deassert GPIO_BC12_DET_EN to mux the USB-PHY back.
-
-config PLATFORM_EC_BC12_SINGLE_DRIVER
- bool "Only support a single BC12 driver"
- default y
- help
- Enable this if the board only needs one BC12 driver. This includes
- the case that has multiple chips that use the same driver.
-
- If undefined, the board should define a bc12_ports[] array which
- associates each port to its bc12 driver:
-
- struct bc12_config bc12_ports[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- { .drv = &xxx_drv },
- { .drv = &yyy_drv },
- };
-
-endif # PLATFORM_EC_USB_CHARGER
-
-endif # PLATFORM_EC_USBC
diff --git a/zephyr/Kconfig.watchdog b/zephyr/Kconfig.watchdog
deleted file mode 100644
index 7d5860ce34..0000000000
--- a/zephyr/Kconfig.watchdog
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC_WATCHDOG
-
-config PLATFORM_EC_WATCHDOG_PERIOD_MS
- int "Watchdog timeout in ms"
- default 1600
- help
- Set the timeout of the watchdog timer. The watchdog timer reboots
- the system if no one reloads the watchdog timer before the timeout.
-
-config PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS
- int "Leading time of the watchdog warning timer in ms"
- default 500
- depends on !WDT_NPCX && !WDT_ITE_IT8XXX2
- help
- Set the leading time of the watchdog warning timer. Chromium EC system
- uses an auxiliary timer to handle the system warning event. The
- auxiliary timer period (CONFIG_AUX_TIMER_PERIOD_MS) is set to
- PLATFORM_EC_WATCHDOG_PERIOD_MS -
- PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS.
-
- For the NPCX chip, use WDT_NPCX_DELAY_CYCLES instead of this config.
- For the ITE chip, use CONFIG_WDT_ITE_WARNING_LEADING_TIME_MS instead
- of this config.
-
-endif # PLATFORM_EC_WATCHDOG
diff --git a/zephyr/README.md b/zephyr/README.md
deleted file mode 100644
index fc9f7e7c72..0000000000
--- a/zephyr/README.md
+++ /dev/null
@@ -1,30 +0,0 @@
-# Zephyr EC
-
-[TOC]
-
-## Introduction
-
-Zephyr EC is an effort to create an industry-standard Embedded Controller
-implementation for use primarily on laptops. It is born out of the Chromium OS
-EC.
-
-## Gitlab integration
-
-As an experiment we have a basic gitlab integration. It watches the EC repo and
-kicks of a build when new commits appear. So far it just builds for volteer and
-does not run any tests. For firmware branches, it also builds, but fails.
-
-The gitlab builder works without a chroot and uses the Zephyr toolchain. This
-is intended to ensure that we have a path to upstreaming our code eventually and
-do not rely on Chrome OS-specific tools. It does make use of 'zmake', however.
-
-See the piplines [here](https://gitlab.com/zephyr-ec/ec/-/pipelines).
-
-## News and Breaking Changes
-
-* Support for Zephyr v2.4 has been dropped as of
- [CL:2715345](https://crrev.com/c/2715345). If you wish to build for
- kernel v2.4 now, you must invoke `zmake configure` similar to below:
-
- $ zmake --zephyr-base ~/trunk/src/third_party/zephyr/main/v2.4 \
- configure --ignore-unsupported-zephyr-version ...
diff --git a/zephyr/app/CMakeLists.txt b/zephyr/app/CMakeLists.txt
deleted file mode 100644
index dfc45f19f9..0000000000
--- a/zephyr/app/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2020 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.
-
-add_subdirectory_ifdef(CONFIG_CROS_EC ec)
diff --git a/zephyr/app/Kconfig b/zephyr/app/Kconfig
deleted file mode 100644
index 3cac46afa7..0000000000
--- a/zephyr/app/Kconfig
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2020 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.
-
-rsource "ec/Kconfig"
diff --git a/zephyr/app/ec/CMakeLists.txt b/zephyr/app/ec/CMakeLists.txt
deleted file mode 100644
index f12067a5b5..0000000000
--- a/zephyr/app/ec/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-zephyr_library_include_directories(include)
-zephyr_library_sources(ec_app_main.c)
-if(NOT DEFINED CONFIG_ZTEST)
- zephyr_library_sources(main_shim.c)
-endif()
diff --git a/zephyr/app/ec/Kconfig b/zephyr/app/ec/Kconfig
deleted file mode 100644
index 9f4bdd95a1..0000000000
--- a/zephyr/app/ec/Kconfig
+++ /dev/null
@@ -1,137 +0,0 @@
-# Copyright 2020 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.
-
-menuconfig CROS_EC
- bool "Chromium OS EC app"
- imply SHELL
- imply SHELL_MINIMAL
- imply PRINTK
- help
- Enable the common Chromium OS EC application. This prints a message,
- starts the EC tasks and sets up any drivers that are needed.
-
- This depends on PLATFORM_EC at present, since without the shimmed
- tasks, almost nothing can operate.
-
-if CROS_EC
-
-rsource "soc/Kconfig"
-orsource "chip/$(ARCH)/*/Kconfig.*"
-
-config LTO
- bool "Link Time Optimization (LTO)"
- default y if !SOC_POSIX
- help
- Enable the Link Time Optimization (LTO) feature for the toolchain.
- LTO expands the scope of optimizations to encompass the whole program,
- reducing the image size.
-
- At this time, LTO is only enabled for Chromium OS source files and
- is not enabled for the Zephyr kernel or drivers due.
- https://github.com/zephyrproject-rtos/zephyr/issues/2112
-
-choice CBPRINTF_IMPLEMENTATION
- default CBPRINTF_NANO
-
-endchoice
-
-choice
- prompt "Chromium OS EC firmware section"
-
-config CROS_EC_RO
- bool "This build is will be for the RO copy of the EC"
- help
- This build will be used to produce a copy for the read-only
- section of the EC firmware.
-
-config CROS_EC_RW
- bool "This build is will be for the RW copy of the EC"
- help
- This build will be used to produce a copy for the read-write
- section of the EC firmware.
-
-endchoice
-
-config CROS_EC_ACTIVE_COPY
- string
- default "RO" if CROS_EC_RO
- default "RW" if CROS_EC_RW
- help
- When the active copy name is output to a console, this
- string will be displayed.
-
-config CROS_EC_HOOK_TICK_INTERVAL
- int "The interval time for the HOOK_TICK"
- default 250000
- help
- Specificies the interval time for the HOOK_TICK, specified in
- microseconds. Modules register with HOOK_TICK to be called
- periodically by the HOOKS task. The interval must be shorter than
- 1 second and is set according the EC chipset's sleep requirements.
-
-# When building for the host, we still need values for the various memory
-# sizes, though they aren't actually used, so just set some reasonable-looking
-# values and then ignore them.
-config CROS_EC_RAM_SIZE
- hex "The total available RAM size."
- default 0x0000f800 if ARCH_POSIX
- help
- This value describes the total available RAM size for the chip.
-
-config CROS_EC_DATA_RAM_SIZE
- hex "The total available RAM size for data."
- default 0x00010000 if ARCH_POSIX
- help
- This value describes the total available RAM size for data on the chip.
-
-config CROS_EC_RAM_BASE
- hex "Base address of RAM for the chip."
- default 0x200c0000 if ARCH_POSIX
- help
- Base address of RAM for the chip.
-
-config CROS_EC_PROGRAM_MEMORY_BASE
- hex "The base address of the program memory region."
- default 0x10090000 if ARCH_POSIX
- help
- This will be used (among other things) to calculate the current PC's
- offset within the program memory.
-
-config CROS_EC_RO_MEM_OFF
- hex "The RO region's offset."
- default 0x0 if ARCH_POSIX
- help
- This will be used to determine if the current PC is in the RO section.
-
-config CROS_EC_RO_SIZE
- hex "The size of the RO region."
- default 0xb000 if ARCH_POSIX
- help
- This will be used (along with SYSTEM_RO_MEM_OFF) to determine if the
- current PC is in the RO section.
-
-config CROS_EC_RW_MEM_OFF
- hex "The RW region's offset."
- default 0xb000 if ARCH_POSIX
- help
- This will be used to determine if the current PC is in the RW section.
-
-config CROS_EC_RW_SIZE
- hex "The size of the RW region."
- default 0x75000 if ARCH_POSIX
- help
- This will be used (along with SYSTEM_RW_MEM_OFF) to determine if the
- current PC is in the RW section.
-
-# By default, a unit test doesn't need shimmed tasks.
-config SHIMMED_TASKS
- bool "Add support for shimming in platform/ec tasks as Zephyr threads"
- default n if ARCH_POSIX
- help
- When this option is enabled, a shimmed_tasks.h header with the
- CROS_EC_TASK_LIST defined needs to be included for the project to
- build. The CROS_EC_TASK_LIST defines a list of CROS_EC_TASK that
- should be shimmed in.
-
-endif # CROS_EC
diff --git a/zephyr/app/ec/chip/arm/nuvoton_npcx/Kconfig.npcx b/zephyr/app/ec/chip/arm/nuvoton_npcx/Kconfig.npcx
deleted file mode 100644
index 2da9252775..0000000000
--- a/zephyr/app/ec/chip/arm/nuvoton_npcx/Kconfig.npcx
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-#
-# This file defines the default config values shared by all NPCX chipsets
-#
-
-if SOC_FAMILY_NPCX
-
-# Enable NPCX firmware header generator
-config NPCX_HEADER
- default y
-
-choice NPCX_HEADER_SPI_MAX_CLOCK_CHOICE
- default NPCX_HEADER_SPI_MAX_CLOCK_50
-endchoice
-
-choice NPCX_HEADER_SPI_READ_MODE_CHOICE
- default NPCX_HEADER_SPI_READ_MODE_DUAL
-endchoice
-
-choice NPCX_HEADER_CORE_CLOCK_SPI_CLOCK_RATIO_CHOICE
- default NPCX_HEADER_CORE_CLOCK_SPI_CLOCK_RATIO_2
-endchoice
-
-# ADC
-# The resolution and oversamplig values are fixed by the NPCX ADC driver
-config PLATFORM_EC_ADC_RESOLUTION
- default 10
-
-config PLATFORM_EC_ADC_OVERSAMPLING
- default 0
-
-# Set the system clock to 15MHz.
-config SYS_CLOCK_HW_CYCLES_PER_SEC
- default 15000000
-
-if WATCHDOG
-
-# Set the delay time for printing panic data.
-# 1 cycle is about 32ms. 500ms is about 16 cycles.
-config WDT_NPCX_DELAY_CYCLES
- default 16
-
-endif # WATCHDOG
-
-# The maximum supported time the NPCX can spend in deep-sleep with instant
-# wake is 200 ms, so the hook tick interval is set to match.
-config CROS_EC_HOOK_TICK_INTERVAL
- default 200000
-
-endif # SOC_FAMILY_NPCX
diff --git a/zephyr/app/ec/chip/arm/nuvoton_npcx/Kconfig.npcx7 b/zephyr/app/ec/chip/arm/nuvoton_npcx/Kconfig.npcx7
deleted file mode 100644
index 3c59d5405e..0000000000
--- a/zephyr/app/ec/chip/arm/nuvoton_npcx/Kconfig.npcx7
+++ /dev/null
@@ -1,53 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-#
-# This file defines the correct defaults when using the NPCX7 series chipset
-#
-
-if SOC_SERIES_NPCX7
-
-#
-# NPCX796FB: 1024 KiB Flash, 192 KiB code RAM, 62 KiB data RAM
-# NPCX796FC: 512 KiB Flash, 192 KiB code RAM, 62 KiB data RAM
-# NPCX797FC: 512 KiB Flash, 320 KiB code RAM, 62 KiB data RAM
-#
-
-# Code RAM base for NPCX7 series
-config CROS_EC_PROGRAM_MEMORY_BASE
- default 0x10090000 if SOC_NPCX7M6FB || SOC_NPCX7M6FC
- default 0x10070000 if SOC_NPCX7M7FC
-
-config CROS_EC_RAM_BASE
- default 0x200c0000
-
-config CROS_EC_DATA_RAM_SIZE
- default 0x00010000
-
-config CROS_EC_RAM_SIZE
- default 0x0000f800
-
-config FLASH_SIZE
- default 1024 if SOC_NPCX7M6FB
- default 512 if SOC_NPCX7M6FC || SOC_NPCX7M7FC
-
-config CROS_EC_RO_MEM_OFF
- default 0x0
-
-# NPCX796FB/NPCX796FC: Image size limited by code RAM size (192 KiB)
-# NPCX797FC: Image size limited by 1/2 Flash size (256 KiB)
-config CROS_EC_RO_SIZE
- default 0x30000 if SOC_NPCX7M6FB || SOC_NPCX7M6FC
- default 0x40000 if SOC_NPCX7M7FC
-
-# RW firmware in program memory - Identical to RO, only one image loaded at a
-# time.
-config CROS_EC_RW_MEM_OFF
- default 0x0
-
-config CROS_EC_RW_SIZE
- default 0x30000 if SOC_NPCX7M6FB || SOC_NPCX7M6FC
- default 0x40000 if SOC_NPCX7M7FC
-
-endif # SOC_SERIES_NPCX7
diff --git a/zephyr/app/ec/chip/arm/nuvoton_npcx/Kconfig.npcx9 b/zephyr/app/ec/chip/arm/nuvoton_npcx/Kconfig.npcx9
deleted file mode 100644
index 5fd1fbd308..0000000000
--- a/zephyr/app/ec/chip/arm/nuvoton_npcx/Kconfig.npcx9
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-#
-# This file defines the correct defaults when using the NPCX9 series chipset
-#
-
-if SOC_SERIES_NPCX9
-
-#
-# NPCX993F: 512 KiB Flash, 256 KiB code RAM, 64 KiB data RAM
-# NPCX996F: 512 KiB Flash, 192 KiB code RAM, 64 KiB data RAM
-#
-
-# Code RAM base for NPCX9 series
-config CROS_EC_PROGRAM_MEMORY_BASE
- default 0x10080000 if SOC_NPCX9M3F
- default 0x10090000 if SOC_NPCX9M6F
-
-config CROS_EC_RAM_BASE
- default 0x200c0000
-
-config CROS_EC_DATA_RAM_SIZE
- default 0x0000f800
-
-config CROS_EC_RAM_SIZE
- default 0x0000f800
-
-config FLASH_SIZE
- default 512
-
-config CROS_EC_RO_MEM_OFF
- default 0x0
-
-# NPCX993F: Image size limited by 1/2 Flash size (256 KiB) and
-# code RAM size (256 KiB)
-# NPCX996F: Image size limited by code RAM size (192 KiB)
-
-config CROS_EC_RO_SIZE
- default 0x40000 if SOC_NPCX9M3F
- default 0x30000 if SOC_NPCX9M6F
-
-config CROS_EC_RW_MEM_OFF
- default 0x0
-
-config CROS_EC_RW_SIZE
- default 0x40000 if SOC_NPCX9M3F
- default 0x30000 if SOC_NPCX9M6F
-
-endif # SOC_SERIES_NPCX9
diff --git a/zephyr/app/ec/chip/riscv/riscv-ite/Kconfig.it8xxx2 b/zephyr/app/ec/chip/riscv/riscv-ite/Kconfig.it8xxx2
deleted file mode 100644
index dab9e6b8b2..0000000000
--- a/zephyr/app/ec/chip/riscv/riscv-ite/Kconfig.it8xxx2
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if SOC_FAMILY_RISCV_ITE
-
-# Code RAM base for IT8XXX2
-config CROS_EC_PROGRAM_MEMORY_BASE
- default 0x80000000
-
-# The total RAM size of IT8xxx2 is 60 KB.
-# The first 4KB block be always reserved for ram code functions,
-# so the total available RAM size will be 56KB.
-config CROS_EC_RAM_BASE
- default 0x80101000
-
-config CROS_EC_DATA_RAM_SIZE
- default 0x0000e000
-
-config CROS_EC_RAM_SIZE
- default 0x0000e000
-
-# The 512KB flash space layout are as the below:
-# - RO image starts at the beginning of flash.
-# - RW image starts at the second half of flash.
-config CROS_EC_RO_MEM_OFF
- default 0x0
-
-config CROS_EC_RO_SIZE
- default 0x40000
-
-config CROS_EC_RW_MEM_OFF
- default 0x40000
-
-config CROS_EC_RW_SIZE
- default 0x40000
-
-config FLASH_LOAD_OFFSET
- default CROS_EC_RW_MEM_OFF if CROS_EC_RW
-
-endif # SOC_FAMILY_RISCV_ITE
diff --git a/zephyr/app/ec/ec_app_main.c b/zephyr/app/ec/ec_app_main.c
deleted file mode 100644
index 7cc5b170f1..0000000000
--- a/zephyr/app/ec/ec_app_main.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <kernel.h>
-#include <sys/printk.h>
-#include <shell/shell_uart.h>
-#include <zephyr.h>
-
-#include "button.h"
-#include "chipset.h"
-#include "ec_tasks.h"
-#include "hooks.h"
-#include "keyboard_scan.h"
-#include "lpc.h"
-#include "system.h"
-#include "vboot.h"
-#include "watchdog.h"
-#include "zephyr_espi_shim.h"
-#include "ec_app_main.h"
-
-/* For testing purposes this is not named main. See main_shim.c for the real
- * main() function.
- */
-void ec_app_main(void)
-{
- system_common_pre_init();
-
- /*
- * Initialize reset logs. This needs to be done before any updates of
- * reset logs because we need to verify if the values remain the same
- * after every EC reset.
- */
- if (IS_ENABLED(CONFIG_CMD_AP_RESET_LOG)) {
- init_reset_log();
- }
-
- system_print_banner();
-
- if (IS_ENABLED(CONFIG_PLATFORM_EC_WATCHDOG)) {
- watchdog_init();
- }
-
- /*
- * Keyboard scan init/Button init can set recovery events to
- * indicate to host entry into recovery mode. Before this is
- * done, LPC_HOST_EVENT_ALWAYS_REPORT mask needs to be initialized
- * correctly.
- */
- if (IS_ENABLED(CONFIG_HOSTCMD_X86)) {
- lpc_init_mask();
- }
-
- if (IS_ENABLED(HAS_TASK_KEYSCAN)) {
- keyboard_scan_init();
- }
-
- if (IS_ENABLED(CONFIG_DEDICATED_RECOVERY_BUTTON) ||
- IS_ENABLED(CONFIG_VOLUME_BUTTONS)) {
- button_init();
- }
-
- if (IS_ENABLED(CONFIG_PLATFORM_EC_ESPI)) {
- if (zephyr_shim_setup_espi() < 0) {
- printk("Failed to init eSPI!\n");
- }
- }
-
- if (IS_ENABLED(CONFIG_PLATFORM_EC_VBOOT_EFS2)) {
- /*
- * For RO, it behaves as follows:
- * In recovery, it enables PD communication and returns.
- * In normal boot, it verifies and jumps to RW.
- * For RW, it returns immediately.
- */
- vboot_main();
- }
-
- /*
- * Hooks run from the system workqueue and must be the lowest priority
- * thread. By default, the system workqueue is run at the lowest
- * cooperative thread priority, blocking all preemptive threads until
- * the deferred work is completed.
- */
- k_thread_priority_set(&k_sys_work_q.thread, LOWEST_THREAD_PRIORITY);
-
- /* Call init hooks before main tasks start */
- if (IS_ENABLED(CONFIG_PLATFORM_EC_HOOKS)) {
- hook_notify(HOOK_INIT);
- }
-
-
- /*
- * Increase priority of shell thread.
- * This is temporary code that'll be removed
- * after the feature outlined in bug b/191795553
- * is implemented.
- */
- {
- static const struct shell *shell;
-
- shell = shell_backend_uart_get_ptr();
- k_thread_priority_set(shell->ctx->tid,
- K_HIGHEST_APPLICATION_THREAD_PRIO);
- }
-
- /*
- * Print the init time. Not completely accurate because it can't take
- * into account the time before timer_init(), but it'll at least catch
- * the majority of the time.
- */
- cprints(CC_SYSTEM, "Inits done");
-
- /* Start the EC tasks after performing all main initialization */
- if (IS_ENABLED(CONFIG_SHIMMED_TASKS)) {
- start_ec_tasks();
- }
-}
diff --git a/zephyr/app/ec/include/ec_app_main.h b/zephyr/app/ec/include/ec_app_main.h
deleted file mode 100644
index a5043be84a..0000000000
--- a/zephyr/app/ec/include/ec_app_main.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-void ec_app_main(void);
diff --git a/zephyr/app/ec/main_shim.c b/zephyr/app/ec/main_shim.c
deleted file mode 100644
index 35f45e0286..0000000000
--- a/zephyr/app/ec/main_shim.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <kernel.h>
-#include "ec_app_main.h"
-
-/** A stub main to call the real ec app main function. LCOV_EXCL_START */
-void main(void)
-{
- ec_app_main();
-
-#ifdef CONFIG_THREAD_MONITOR
- /*
- * Avoid returning so that the main stack is displayed by the
- * "kernel stacks" shell command.
- */
- k_sleep(K_FOREVER);
-#endif
-}
-/* LCOV_EXCL_STOP */
diff --git a/zephyr/app/ec/soc/Kconfig b/zephyr/app/ec/soc/Kconfig
deleted file mode 100644
index d7befb39b7..0000000000
--- a/zephyr/app/ec/soc/Kconfig
+++ /dev/null
@@ -1,82 +0,0 @@
-menuconfig AP
- bool "Enable AP SoC support code"
- default y
- help
- This device has an application processor (AP) on-board and
- support code should be enabled.
-
-if AP
-
-choice
- prompt "SoC chipset generation"
-
-config AP_X86_INTEL_CML
- bool "AP is CML chipset"
- select AP_X86_INTEL
- help
- The application processor is Intel Comet Lake (CML) chipset.
-
-config AP_X86_INTEL_TGL
- bool "AP is TGL chipset"
- select AP_X86_INTEL
- help
- The application processor is Intel Tiger Lake (TGL) chipset.
-
-config AP_X86_INTEL_ADL
- bool "AP is ADL chipset"
- select AP_X86_INTEL
- help
- The application processor is Intel Alder Lake (ADL) chipset.
-
-config AP_X86_AMD
- bool "AP is an AMD chipset"
- select AP_x86
- help
- The application processor is a product of AMD.
-
-config AP_ARM_MTK_MT8192
- bool "MediaTek MT8192"
- select AP_AARCH64
- help
- The application processor is a MediaTek MT8192 processor.
-
-config AP_ARM_QUALCOMM_SC7180
- bool "Qualcomm Snapdragon SC7180"
- select AP_AARCH64
- help
- The application processor is a Qualcomm Snapdragon SC7180
- ARMv8 processor.
-
-config AP_ARM_QUALCOMM_SC7280
- bool "Qualcomm Snapdragon SC7280"
- select AP_AARCH64
- help
- The application processor is a Qualcomm Snapdragon SC7280
- ARMv8 processor.
-
-endchoice
-
-# Invisible meta-symbols generated by the selected chipset.
-config AP_X86_INTEL
- bool
- select AP_X86
- help
- The application processor (AP) is an Intel SoC.
-
-config AP_X86
- bool
- help
- The application processor (AP) is X86-like.
-
-config AP_AARCH64
- bool
- select AP_ARM
- help
- The application processor (AP) is 64-bit ARMv8 architecture.
-
-config AP_ARM
- bool
- help
- The application processor (AP) is ARM-like.
-
-endif # AP
diff --git a/zephyr/boards/arm/brya/Kconfig.board b/zephyr/boards/arm/brya/Kconfig.board
deleted file mode 100644
index 8add483941..0000000000
--- a/zephyr/boards/arm/brya/Kconfig.board
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# "BOARD" below refers to a Zephyr board, which does not have a 1:1
-# mapping with the Chrome OS concept of a board. By Zephyr's
-# conventions, we'll still call it "BOARD_*" to make this more
-# applicable to be upstreamed, even though this code is shared by all
-# projects using Brya baseboard.
-config BOARD_BRYA
- bool "Google Brya Baseboard"
- depends on SOC_NPCX9M3F
- # NPCX doesn't actually have enough ram for coverage, but this will
- # allow generating initial 0 line coverage.
- select HAS_COVERAGE_SUPPORT
diff --git a/zephyr/boards/arm/brya/Kconfig.defconfig b/zephyr/boards/arm/brya/Kconfig.defconfig
deleted file mode 100644
index e4de179311..0000000000
--- a/zephyr/boards/arm/brya/Kconfig.defconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if BOARD_BRYA
-
-config BOARD
- default "brya"
-
-endif # BOARD_BRYA
diff --git a/zephyr/boards/arm/brya/board.cmake b/zephyr/boards/arm/brya/board.cmake
deleted file mode 100644
index 67ade59f57..0000000000
--- a/zephyr/boards/arm/brya/board.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-set(NPCX_IMAGE_FILE ${PROJECT_BINARY_DIR}/zephyr.npcx.bin)
-
diff --git a/zephyr/boards/arm/brya/brya.dts b/zephyr/boards/arm/brya/brya.dts
deleted file mode 100644
index 4ba8704cd2..0000000000
--- a/zephyr/boards/arm/brya/brya.dts
+++ /dev/null
@@ -1,188 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/dts-v1/;
-
-#include <cros/nuvoton/npcx9.dtsi>
-#include <dt-bindings/gpio_defines.h>
-#include <nuvoton/npcx9m3f.dtsi>
-
-/ {
- model = "Google Brya Baseboard";
-
- chosen {
- zephyr,sram = &sram0;
- zephyr,console = &uart1;
- zephyr,shell-uart = &uart1;
- zephyr,flash = &flash0;
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
- i2c_sensor: sensor {
- i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_SENSOR";
- label = "SENSOR";
- };
- tcpc0_2 {
- i2c-port = <&i2c1_0>;
- enum-name = "I2C_PORT_USB_C0_C2_TCPC";
- label = "TCPC0,2";
- };
- tcpc1 {
- i2c-port = <&i2c4_1>;
- enum-name = "I2C_PORT_USB_C1_TCPC";
- label = "TCPC1";
- };
- ppc0_2 {
- i2c-port = <&i2c2_0>;
- enum-name = "I2C_PORT_USB_C0_C2_PPC";
- label = "PPC0,2";
- };
- ppc1 {
- i2c-port = <&i2c6_1>;
- enum-name = "I2C_PORT_USB_C1_PPC";
- label = "PPC1";
- };
- retimer0_2 {
- i2c-port = <&i2c3_0>;
- enum-name = "I2C_PORT_USB_C0_C2_MUX";
- label = "RETIMER0,2";
- };
- battery {
- i2c-port = <&i2c5_0>;
- enum-name = "I2C_PORT_BATTERY";
- label = "BATTERY";
- };
- eeprom {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_EEPROM";
- label = "EEPROM";
- };
- charger {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_CHARGER";
- label = "EEPROM";
- };
- };
-
- named-pwms {
- compatible = "named-pwms";
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
- };
-
- def-lvol-io-list {
- compatible = "nuvoton,npcx-lvolctrl-def";
- };
-};
-
-&uart1 {
- status = "okay";
- current-speed = <115200>;
- pinctrl-0 = <&altj_cr_sin1_sl2 &altj_cr_sout1_sl2>;
-};
-
-&i2c0_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c1_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c2_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl2 {
- status = "okay";
-};
-
-&i2c3_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&i2c4_1 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl4 {
- status = "okay";
-};
-
-&i2c5_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c_ctrl5 {
- status = "okay";
-};
-
-&i2c6_1 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl6 {
- status = "okay";
-};
-
-&i2c7_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
-
-&cros_kb_raw {
- status = "okay";
- /* No KSO2 (it's inverted and implemented by GPIO) */
- pinctrl-0 = <&alt7_no_ksi0_sl
- &alt7_no_ksi1_sl
- &alt7_no_ksi2_sl
- &alt7_no_ksi3_sl
- &alt7_no_ksi4_sl
- &alt7_no_ksi5_sl
- &alt7_no_ksi6_sl
- &alt7_no_ksi7_sl
- &alt8_no_kso00_sl
- &alt8_no_kso01_sl
- &alt8_no_kso03_sl
- &alt8_no_kso04_sl
- &alt8_no_kso05_sl
- &alt8_no_kso06_sl
- &alt8_no_kso07_sl
- &alt9_no_kso08_sl
- &alt9_no_kso09_sl
- &alt9_no_kso10_sl
- &alt9_no_kso11_sl
- &alt9_no_kso12_sl
- &alt9_no_kso13_sl
- &alt9_no_kso14_sl
- >;
-};
diff --git a/zephyr/boards/arm/brya/brya_defconfig b/zephyr/boards/arm/brya/brya_defconfig
deleted file mode 100644
index e8c412a592..0000000000
--- a/zephyr/boards/arm/brya/brya_defconfig
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Kernel Configuration
-CONFIG_SOC_SERIES_NPCX9=y
-
-# Platform Configuration
-CONFIG_SOC_NPCX9M3F=y
-CONFIG_BOARD_BRYA=y
-
-# Serial Drivers
-CONFIG_SERIAL=y
-CONFIG_UART_INTERRUPT_DRIVEN=y
-
-# Enable console
-CONFIG_CONSOLE=y
-CONFIG_UART_CONSOLE=y
-
-# Pinmux Driver
-CONFIG_PINMUX=y
-
-# GPIO Controller
-CONFIG_GPIO=y
-
-# Clock configuration
-CONFIG_CLOCK_CONTROL=y
-
-# Power Management
-CONFIG_SOC_POWER_MANAGEMENT=y
-CONFIG_PM=y
-CONFIG_PM_POLICY_APP=y
-CONFIG_UART_CONSOLE_INPUT_EXPIRED=y
-CONFIG_SOC_POWER_MANAGEMENT_TRACE=y
-
-# WATCHDOG configuration
-CONFIG_WATCHDOG=y
-
-# BBRAM
-CONFIG_BBRAM=y
-CONFIG_BBRAM_NPCX=y
diff --git a/zephyr/boards/arm/herobrine_npcx9/Kconfig.board b/zephyr/boards/arm/herobrine_npcx9/Kconfig.board
deleted file mode 100644
index d9e7faf3af..0000000000
--- a/zephyr/boards/arm/herobrine_npcx9/Kconfig.board
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# "BOARD" below refers to a Zephyr board, which does not have a 1:1
-# mapping with the Chrome OS concept of a board. By Zephyr's
-# conventions, we'll still call it "BOARD_*" to make this more
-# applicable to be upstreamed, even though this code is shared by all
-# projects using Herobrine-NPCX9 baseboard.
-config BOARD_HEROBRINE_NPCX9
- bool "Google Herobrine-NPCX9 Baseboard"
- depends on SOC_NPCX9M3F
- # NPCX doesn't actually have enough ram for coverage, but this will
- # allow generating initial 0 line coverage.
- select HAS_COVERAGE_SUPPORT
diff --git a/zephyr/boards/arm/herobrine_npcx9/Kconfig.defconfig b/zephyr/boards/arm/herobrine_npcx9/Kconfig.defconfig
deleted file mode 100644
index 65f3225d91..0000000000
--- a/zephyr/boards/arm/herobrine_npcx9/Kconfig.defconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if BOARD_HEROBRINE_NPCX9
-
-config BOARD
- default "herobrine_npcx9"
-
-endif # BOARD_HEROBRINE_NPCX9
diff --git a/zephyr/boards/arm/herobrine_npcx9/herobrine_npcx9.dts b/zephyr/boards/arm/herobrine_npcx9/herobrine_npcx9.dts
deleted file mode 100644
index 34884a8275..0000000000
--- a/zephyr/boards/arm/herobrine_npcx9/herobrine_npcx9.dts
+++ /dev/null
@@ -1,144 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/dts-v1/;
-
-#include <cros/nuvoton/npcx9.dtsi>
-#include <dt-bindings/adc/adc.h>
-#include <dt-bindings/gpio_defines.h>
-#include <dt-bindings/wake_mask_event_defines.h>
-#include <nuvoton/npcx9m3f.dtsi>
-
-/ {
- model = "Google Herobrine-NPCX9 Baseboard";
-
- chosen {
- zephyr,sram = &sram0;
- zephyr,console = &uart1;
- zephyr,shell-uart = &uart1;
- zephyr,flash = &flash0;
- cros,rtc = &pcf85063a;
- };
-
- ec-console {
- compatible = "ec-console";
-
- disabled = "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)>;
- };
-
- ec-mkbp-event-wakeup-mask {
- compatible = "ec-wake-mask-event";
- wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | \
- MKBP_EVENT_HOST_EVENT | \
- MKBP_EVENT_SENSOR_FIFO)>;
- };
-
- named-pwms {
- compatible = "named-pwms";
-
- kblight {
- pwms = <&pwm3 0 0>;
- label = "KBLIGHT";
- frequency = <10000>;
- };
- displight {
- pwms = <&pwm5 0 0>;
- label = "DISPLIGHT";
- frequency = <4800>;
- };
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- vbus {
- label = "ADC_VBUS";
- enum-name = "ADC_VBUS";
- channel = <1>;
- /* Measure VBUS through a 1/10 voltage divider */
- mul = <10>;
- };
- amon_bmon {
- label = "ADC_AMON_BMON";
- enum-name = "ADC_AMON_BMON";
- channel = <2>;
- /*
- * Adapter current output or battery charging/
- * discharging current (uV) 18x amplification on
- * charger side.
- */
- mul = <1000>;
- div = <18>;
- };
- psys {
- label = "ADC_PSYS";
- enum-name = "ADC_PSYS";
- channel = <3>;
- /*
- * ISL9238 PSYS output is 1.44 uA/W over 5.6K resistor,
- * to read 0.8V @ 99 W, i.e. 124000 uW/mV.
- */
- mul = <124000>;
- };
- };
-};
-
-&uart1 {
- status = "okay";
- current-speed = <115200>;
- pinctrl-0 = <&altj_cr_sin1_sl2 &altj_cr_sout1_sl2>;
-};
-
-/* Keyboard backlight */
-&pwm3 {
- status = "okay";
-};
-
-/* Display backlight */
-&pwm5 {
- status = "okay";
-};
-
-&adc0 {
- status = "okay";
-};
-
-&cros_kb_raw {
- status = "okay";
- /* No KSO2 (it's inverted and implemented by GPIO) */
- pinctrl-0 = <&alt7_no_ksi0_sl
- &alt7_no_ksi1_sl
- &alt7_no_ksi2_sl
- &alt7_no_ksi3_sl
- &alt7_no_ksi4_sl
- &alt7_no_ksi5_sl
- &alt7_no_ksi6_sl
- &alt7_no_ksi7_sl
- &alt8_no_kso00_sl
- &alt8_no_kso01_sl
- &alt8_no_kso03_sl
- &alt8_no_kso04_sl
- &alt8_no_kso05_sl
- &alt8_no_kso06_sl
- &alt8_no_kso07_sl
- &alt9_no_kso08_sl
- &alt9_no_kso09_sl
- &alt9_no_kso10_sl
- &alt9_no_kso11_sl
- &alt9_no_kso12_sl
- >;
-};
diff --git a/zephyr/boards/arm/herobrine_npcx9/herobrine_npcx9_defconfig b/zephyr/boards/arm/herobrine_npcx9/herobrine_npcx9_defconfig
deleted file mode 100644
index 907ae9ed34..0000000000
--- a/zephyr/boards/arm/herobrine_npcx9/herobrine_npcx9_defconfig
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Kernel Configuration
-CONFIG_SOC_SERIES_NPCX9=y
-CONFIG_SOC_NPCX9M3F=y
-
-# Platform Configuration
-CONFIG_BOARD_HEROBRINE_NPCX9=y
-
-# Serial Drivers
-CONFIG_SERIAL=y
-CONFIG_UART_INTERRUPT_DRIVEN=y
-
-# Enable console
-CONFIG_CONSOLE=y
-CONFIG_UART_CONSOLE=y
-
-# Pinmux Driver
-CONFIG_PINMUX=y
-
-# GPIO Controller
-CONFIG_GPIO=y
-
-# Clock configuration
-CONFIG_CLOCK_CONTROL=y
-
-# WATCHDOG configuration
-CONFIG_WATCHDOG=y
-
-# Power Management
-CONFIG_SOC_POWER_MANAGEMENT=y
-CONFIG_PM_POLICY_APP=y
-CONFIG_UART_CONSOLE_INPUT_EXPIRED=y
-CONFIG_SOC_POWER_MANAGEMENT_TRACE=y
-
-# BBRAM
-CONFIG_BBRAM=y
-CONFIG_BBRAM_NPCX=y
diff --git a/zephyr/boards/arm/kohaku/Kconfig.board b/zephyr/boards/arm/kohaku/Kconfig.board
deleted file mode 100644
index c1a1718847..0000000000
--- a/zephyr/boards/arm/kohaku/Kconfig.board
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-config BOARD_KOHAKU
- bool "Google Kohaku EC"
- depends on SOC_NPCX7M6FC
- # NPCX doesn't actually have enough ram for coverage, but this will
- # allow generating initial 0 line coverage.
- select HAS_COVERAGE_SUPPORT
diff --git a/zephyr/boards/arm/kohaku/Kconfig.defconfig b/zephyr/boards/arm/kohaku/Kconfig.defconfig
deleted file mode 100644
index 83b97d8ef7..0000000000
--- a/zephyr/boards/arm/kohaku/Kconfig.defconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if BOARD_KOHAKU
-
-config BOARD
- default "kohaku"
-
-endif # BOARD_KOHAKU
diff --git a/zephyr/boards/arm/kohaku/board.cmake b/zephyr/boards/arm/kohaku/board.cmake
deleted file mode 100644
index a204305534..0000000000
--- a/zephyr/boards/arm/kohaku/board.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-set(NPCX_IMAGE_FILE ${PROJECT_BINARY_DIR}/zephyr.npcx.bin)
diff --git a/zephyr/boards/arm/kohaku/kohaku.dts b/zephyr/boards/arm/kohaku/kohaku.dts
deleted file mode 100644
index 00e340faea..0000000000
--- a/zephyr/boards/arm/kohaku/kohaku.dts
+++ /dev/null
@@ -1,418 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/dts-v1/;
-
-#include <cros/nuvoton/npcx7.dtsi>
-#include <dt-bindings/gpio_defines.h>
-#include <nuvoton/npcx7m6fc.dtsi>
-
-/ {
- model = "Google Kohaku EC";
-
- aliases {
- i2c-0 = &i2c0_0;
- i2c-1 = &i2c1_0;
- i2c-2 = &i2c2_0;
- i2c-3 = &i2c3_0;
- i2c-5 = &i2c5_0;
- i2c-7 = &i2c7_0;
- };
-
- chosen {
- zephyr,sram = &sram0;
- zephyr,console = &uart1;
- zephyr,shell-uart = &uart1;
- zephyr,flash = &flash0;
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- lid_open {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- label = "LID_OPEN";
- };
- wp_l {
- gpios = <&gpioa 1 GPIO_INPUT>;
- enum-name = "GPIO_WP_L";
- label = "WP_L";
- };
- power_button_l {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- label = "POWER_BUTTON_L";
- };
- acok_od {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- label = "ACOK_OD";
- };
- slp_s0_l {
- gpios = <&gpiod 5 GPIO_INPUT>;
- enum-name = "GPIO_PCH_SLP_S0_L";
- label = "SLP_S0_L";
- };
- slp_s3_l {
- gpios = <&gpioa 5 GPIO_INPUT>;
- enum-name = "GPIO_PCH_SLP_S3_L";
- label = "SLP_S3_L";
- };
- slp_s4_l {
- gpios = <&gpiod 4 GPIO_INPUT>;
- enum-name = "GPIO_PCH_SLP_S4_L";
- label = "SLP_S4_L";
- };
- pg_ec_rsmrst_l {
- gpios = <&gpioe 2 GPIO_INPUT>;
- enum-name = "GPIO_RSMRST_L_PGOOD";
- label = "PG_EC_RSMRST_L";
- };
- pg_ec_all_sys_pwrgd {
- gpios = <&gpiof 4 GPIO_INPUT>;
- enum-name = "GPIO_PG_EC_ALL_SYS_PWRGD";
- label = "PG_EC_ALL_SYS_PWRGD";
- };
- pp5000_a_pg_od {
- gpios = <&gpiod 7 GPIO_INPUT>;
- enum-name = "GPIO_PP5000_A_PG_OD";
- label = "PP5000_A_PG_OD";
- };
- base_sixaxis_int_l {
- gpios = <&gpio5 6 GPIO_INPUT>;
- label = "BASE_SIXAXIS_INT_L";
- };
- wfcam_vsync {
- gpios = <&gpiob 7 GPIO_INPUT>;
- label = "WFCAM_VSYNC";
- };
- tcs3400_int_odl {
- gpios = <&gpio7 2 GPIO_INPUT>;
- label = "TCS3400_INT_ODL";
- };
- usb_c0_ppc_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- label = "USB_C0_PPC_INT_ODL";
- };
- usb_c1_ppc_int_odl {
- gpios = <&gpioa 2 GPIO_INPUT>;
- label = "USB_C1_PPC_INT_ODL";
- };
- usb_c0_tcpc_int_odl {
- gpios = <&gpio6 2 GPIO_INPUT>;
- label = "USB_C0_TCPC_INT_ODL";
- };
- usb_c1_tcpc_int_odl {
- gpios = <&gpiof 5 GPIO_INPUT>;
- label = "USB_C1_TCPC_INT_ODL";
- };
- usb_c0_bc12_int_odl {
- gpios = <&gpio9 5 GPIO_INPUT>;
- label = "USB_C0_BC12_INT_ODL";
- };
- usb_c1_bc12_int_odl {
- gpios = <&gpioe 4 GPIO_INPUT>;
- label = "USB_C1_BC12_INT_ODL";
- };
- ec_voldn_btn_odl {
- gpios = <&gpio9 3 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_VOLDN_BTN_ODL";
- };
- ec_volup_btn_odl {
- gpios = <&gpio7 5 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_VOLUP_BTN_ODL";
- };
- sys_reset_l {
- gpios = <&gpioc 5 GPIO_ODR_HIGH>;
- enum-name = "GPIO_SYS_RESET_L";
- label = "SYS_RESET_L";
- };
- entering_rw {
- gpios = <&gpioe 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- label = "ENTERING_RW";
- };
- pch_wake_l {
- gpios = <&gpio7 4 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_PCH_WAKE_ODL";
- label = "PCH_WAKE_L";
- };
- pch_pwrbtn_l {
- gpios = <&gpioc 1 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PCH_PWRBTN_L";
- label = "PCH_PWRBTN_L";
- };
- en_pp5000_a {
- gpios = <&gpioa 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP5000_A";
- label = "EN_PP5000_A";
- };
- en_pp5000 {
- gpios = <&gpioa 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP5000";
- label = "EN_PP5000";
- };
- gpio_edp_bklten_od {
- gpios = <&gpiod 3 GPIO_ODR_HIGH>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- label = "EDP_BKLTEN_OD";
- };
- en_a_rails {
- gpios = <&gpioa 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_A_RAILS";
- label = "EN_A_RAILS";
- };
- ec_pch_rsmrst_l {
- gpios = <&gpioa 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_PCH_RSMRST_L";
- label = "EC_PCH_RSMRST_L";
- };
- ec_prochot_odl {
- gpios = <&gpio6 3 GPIO_ODR_HIGH>;
- enum-name = "GPIO_CPU_PROCHOT";
- label = "EC_PROCHOT_ODL";
- };
- ec_prochot_in_od {
- gpios = <&gpio3 4 GPIO_INPUT>;
- label = "EC_PROCHOT_IN_OD";
- };
- ec_pch_sys_pwrok {
- gpios = <&gpio3 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_PCH_SYS_PWROK";
- label = "EC_PCH_SYS_PWROK";
- };
- cpu_c10_gate_l {
- gpios = <&gpio6 7 GPIO_INPUT>;
- label = "CPU_C10_GATE_L";
- };
- ec_int_l {
- gpios = <&gpio7 0 GPIO_ODR_HIGH>;
- label = "EC_INT_L";
- };
- ec_rst_odl {
- gpios = <&gpio0 2 GPIO_INPUT>;
- label = "EC_RST_ODL";
- };
- usb_c_oc_odl {
- gpios = <&gpiob 1 GPIO_ODR_HIGH>;
- label = "USB_C_OC_ODL";
- };
- usb_c0_tcpc_rst_odl {
- gpios = <&gpio9 7 GPIO_ODR_HIGH>;
- label = "USB_C0_TCPC_RST_ODL";
- };
- usb_c1_tcpc_rst_odl {
- gpios = <&gpio3 2 GPIO_ODR_HIGH>;
- label = "USB_C1_TCPC_RST_ODL";
- };
- usb_c0_bc12_chg_det_l {
- gpios = <&gpio6 0 GPIO_INPUT>;
- label = "USB_C0_BC12_CHG_DET_L";
- };
- usb_c1_bc12_chg_det_l {
- gpios = <&gpio9 6 GPIO_INPUT>;
- label = "USB_C1_BC12_CHG_DET_L";
- };
- usb_c0_bc12_vbus_on {
- gpios = <&gpio9 4 GPIO_OUT_LOW>;
- label = "USB_C0_BC12_VBUS_ON";
- };
- usb_c1_bc12_vbus_on {
- gpios = <&gpioc 6 GPIO_OUT_LOW>;
- label = "USB_C1_BC12_VBUS_ON";
- };
- ec_batt_pres_odl {
- gpios = <&gpioe 1 GPIO_INPUT>;
- label = "EC_BATT_PRES_ODL";
- };
- led_1_l {
- gpios = <&gpioc 4 GPIO_OUT_HIGH>;
- label = "LED_1_L";
- };
- led_2_l {
- gpios = <&gpioc 3 GPIO_OUT_HIGH>;
- label = "LED_2_L";
- };
- led_3_l {
- gpios = <&gpioc 2 GPIO_OUT_HIGH>;
- label = "LED_3_L";
- };
- ec_kb_bl_en {
- gpios = <&gpio8 6 GPIO_OUT_LOW>;
- label = "EC_KB_BL_EN";
- };
- edp_bklten_od {
- gpios = <&gpiod 3 GPIO_ODR_HIGH>;
- label = "EDP_BKLTEN_OD";
- };
- lid_accel_int_l {
- gpios = <&gpio5 0 GPIO_INPUT>;
- label = "LID_ACCEL_INT_L";
- };
- m2_sd_pln {
- gpios = <&gpioa 0 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "M2_SD_PLN";
- };
- imvp8_pe {
- gpios = <&gpioa 7 GPIO_INPUT>;
- label = "IMVP8_PE";
- };
- i2c0_scl {
- gpios = <&gpiob 5 GPIO_INPUT>;
- label = "I2C0_SCL";
- };
- i2c0_sda {
- gpios = <&gpiob 4 GPIO_INPUT>;
- label = "I2C0_SDA";
- };
- i2c1_scl {
- gpios = <&gpio9 0 GPIO_INPUT>;
- label = "I2C1_SCL";
- };
- i2c1_sda {
- gpios = <&gpio8 7 GPIO_INPUT>;
- label = "I2C1_SDA";
- };
- i2c2_scl {
- gpios = <&gpio9 2 GPIO_INPUT>;
- label = "I2C2_SCL";
- };
- i2c2_sda {
- gpios = <&gpio9 1 GPIO_INPUT>;
- label = "I2C2_SDA";
- };
- i2c3_scl {
- gpios = <&gpiod 1 GPIO_INPUT>;
- label = "I2C3_SCL";
- };
- i2c3_sda {
- gpios = <&gpiod 0 GPIO_INPUT>;
- label = "I2C3_SDA";
- };
- i2c5_scl {
- gpios = <&gpio3 3 GPIO_INPUT>;
- label = "I2C5_SCL";
- };
- i2c5_sda {
- gpios = <&gpio3 6 GPIO_INPUT>;
- label = "I2C5_SDA";
- };
- i2c7_scl {
- gpios = <&gpiob 3 GPIO_INPUT>;
- label = "I2C7_SCL";
- };
- i2c7_sda {
- gpios = <&gpiob 2 GPIO_INPUT>;
- label = "I2C7_SDA";
- };
- tp58 {
- gpios = <&gpio0 4 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "TP58";
- };
- tp73 {
- gpios = <&gpio8 2 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "TP73";
- };
- tp18 {
- gpios = <&gpioc 0 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "TP18";
- };
- tp54 {
- gpios = <&gpio4 0 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "TP54";
- };
- tp56 {
- gpios = <&gpio6 1 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "TP56";
- };
- tp57 {
- gpios = <&gpio8 1 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "TP57";
- };
- tp55 {
- gpios = <&gpio7 3 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "TP55";
- };
- tp59 {
- gpios = <&gpiob 0 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "TP59";
- };
- kbd_kso2 {
- gpios = <&gpio1 7 GPIO_OUT_LOW>;
- label = "KBD_KSO2";
- };
- };
-
- def-lvol-io-list {
- compatible = "nuvoton,npcx-lvolctrl-def";
- lvol-io-pads = <&lvol_iob4 &lvol_iob5 /* I2C_SDA0 & SCL0 */
- &lvol_io50>; /* GPIO50 */
- };
-};
-
-&uart1 {
- status = "okay";
- current-speed = <115200>;
- pinctrl-0 = <&altc_uart1_sl2>; /* Use UART1_SL2 ie. PIN64.65 */
-};
-
-&i2c0_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c1_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c2_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl2 {
- status = "okay";
-};
-
-&i2c3_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&i2c5_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c_ctrl5 {
- status = "okay";
-};
-
-&i2c7_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
diff --git a/zephyr/boards/arm/kohaku/kohaku.yaml b/zephyr/boards/arm/kohaku/kohaku.yaml
deleted file mode 100644
index 48cc85e7df..0000000000
--- a/zephyr/boards/arm/kohaku/kohaku.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Copyright (c) 2020 Google LLC.
-#
-# SPDX-License-Identifier: Apache-2.0
-#
-
-identifier: kohaku
-name: "Google Kohaku (Samsung Galaxy Chromebook) Embedded Controller"
-type: mcu
-arch: arm
-toolchain:
- - zephyr
- - gnuarmemb
-ram: 64
-flash: 512
-testing:
- ignore_tags:
- - net
- - bluetooth
diff --git a/zephyr/boards/arm/kohaku/kohaku_defconfig b/zephyr/boards/arm/kohaku/kohaku_defconfig
deleted file mode 100644
index eccf6da6ab..0000000000
--- a/zephyr/boards/arm/kohaku/kohaku_defconfig
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Kernel Configuration
-CONFIG_SOC_SERIES_NPCX7=y
-CONFIG_SOC_NPCX7M6FC=y
-
-# Platform Configuration
-CONFIG_BOARD_KOHAKU=y
-
-# Serial Drivers
-CONFIG_SERIAL=y
-CONFIG_UART_INTERRUPT_DRIVEN=y
-
-# Enable console
-CONFIG_CONSOLE=y
-CONFIG_UART_CONSOLE=y
-
-# Pinmux Driver
-CONFIG_PINMUX=y
-
-# GPIO Controller
-CONFIG_GPIO=y
-
-# Clock configuration
-CONFIG_CLOCK_CONTROL=y
-
-# WATCHDOG configuration
-CONFIG_WATCHDOG=y
-
-# BBRAM
-CONFIG_BBRAM=y
-CONFIG_BBRAM_NPCX=y
diff --git a/zephyr/boards/arm/npcx9/Kconfig.board b/zephyr/boards/arm/npcx9/Kconfig.board
deleted file mode 100644
index e4b184d83e..0000000000
--- a/zephyr/boards/arm/npcx9/Kconfig.board
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-config BOARD_NPCX9
- bool "NPCX9 Zephyr Board"
- depends on SOC_NPCX9M3F
- # NPCX doesn't actually have enough ram for coverage, but this will
- # allow generating initial 0 line coverage.
- select HAS_COVERAGE_SUPPORT
diff --git a/zephyr/boards/arm/npcx9/Kconfig.defconfig b/zephyr/boards/arm/npcx9/Kconfig.defconfig
deleted file mode 100644
index 9b83915f04..0000000000
--- a/zephyr/boards/arm/npcx9/Kconfig.defconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if BOARD_NPCX9
-
-config BOARD
- default "npcx9"
-
-endif # BOARD_TROGDOR
diff --git a/zephyr/boards/arm/npcx9/board.cmake b/zephyr/boards/arm/npcx9/board.cmake
deleted file mode 100644
index a204305534..0000000000
--- a/zephyr/boards/arm/npcx9/board.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-set(NPCX_IMAGE_FILE ${PROJECT_BINARY_DIR}/zephyr.npcx.bin)
diff --git a/zephyr/boards/arm/npcx9/npcx9.dts b/zephyr/boards/arm/npcx9/npcx9.dts
deleted file mode 100644
index ab44d8119e..0000000000
--- a/zephyr/boards/arm/npcx9/npcx9.dts
+++ /dev/null
@@ -1,199 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/dts-v1/;
-
-#include <cros/nuvoton/npcx9.dtsi>
-#include <dt-bindings/adc/adc.h>
-#include <dt-bindings/gpio_defines.h>
-#include <dt-bindings/wake_mask_event_defines.h>
-#include <nuvoton/npcx9m3f.dtsi>
-
-/ {
- model = "NPCX9";
-
- aliases {
- i2c-0 = &i2c0_0;
- i2c-1 = &i2c1_0;
- i2c-2 = &i2c2_0;
- i2c-3 = &i2c3_0;
- i2c-5 = &i2c5_0;
- i2c-7 = &i2c7_0;
- };
-
- chosen {
- zephyr,sram = &sram0;
- zephyr,console = &uart1;
- zephyr,shell-uart = &uart1;
- zephyr,flash = &flash0;
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
- i2c_sensor: sensor {
- i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_SENSOR";
- label = "SENSOR";
- };
- tcpc0_2 {
- i2c-port = <&i2c1_0>;
- enum-name = "I2C_PORT_USB_C0_C2_TCPC";
- label = "TCPC0,2";
- };
- tcpc1 {
- i2c-port = <&i2c4_1>;
- enum-name = "I2C_PORT_USB_C1_TCPC";
- label = "TCPC1";
- };
- ppc0_2 {
- i2c-port = <&i2c2_0>;
- enum-name = "I2C_PORT_USB_C0_C2_PPC";
- label = "PPC0,2";
- };
- ppc1 {
- i2c-port = <&i2c6_1>;
- enum-name = "I2C_PORT_USB_C1_PPC";
- label = "PPC1";
- };
- retimer0_2 {
- i2c-port = <&i2c3_0>;
- enum-name = "I2C_PORT_USB_C0_C2_MUX";
- label = "RETIMER0,2";
- };
- battery {
- i2c-port = <&i2c5_0>;
- enum-name = "I2C_PORT_BATTERY";
- label = "BATTERY";
- };
- eeprom {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_EEPROM";
- label = "EEPROM";
- };
- charger {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_CHARGER";
- label = "EEPROM";
- };
- };
-
- named-pwms {
- compatible = "named-pwms";
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
- };
-
- def-lvol-io-list {
- compatible = "nuvoton,npcx-lvolctrl-def";
- };
-};
-
-&uart1 {
- status = "okay";
- current-speed = <115200>;
- pinctrl-0 = <&altj_cr_sin1_sl2 &altj_cr_sout1_sl2>;
-};
-
-&i2c0_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c1_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c2_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl2 {
- status = "okay";
-};
-
-&i2c3_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&i2c4_1 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl4 {
- status = "okay";
-};
-
-&i2c5_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c_ctrl5 {
- status = "okay";
-};
-
-&i2c6_1 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl6 {
- status = "okay";
-};
-
-&i2c7_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
-
-&cros_kb_raw {
- status = "okay";
- /* No KSO2 (it's inverted and implemented by GPIO) */
- pinctrl-0 = <&alt7_no_ksi0_sl
- &alt7_no_ksi1_sl
- &alt7_no_ksi2_sl
- &alt7_no_ksi3_sl
- &alt7_no_ksi4_sl
- &alt7_no_ksi5_sl
- &alt7_no_ksi6_sl
- &alt7_no_ksi7_sl
- &alt8_no_kso00_sl
- &alt8_no_kso01_sl
- &alt8_no_kso03_sl
- &alt8_no_kso04_sl
- &alt8_no_kso05_sl
- &alt8_no_kso06_sl
- &alt8_no_kso07_sl
- &alt9_no_kso08_sl
- &alt9_no_kso09_sl
- &alt9_no_kso10_sl
- &alt9_no_kso11_sl
- &alt9_no_kso12_sl
- &alt9_no_kso13_sl
- &alt9_no_kso14_sl
- >;
-};
diff --git a/zephyr/boards/arm/npcx9/npcx9_defconfig b/zephyr/boards/arm/npcx9/npcx9_defconfig
deleted file mode 100644
index d20fd87f3a..0000000000
--- a/zephyr/boards/arm/npcx9/npcx9_defconfig
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Kernel Configuration
-CONFIG_SOC_SERIES_NPCX9=y
-CONFIG_SOC_NPCX9M3F=y
-
-# Platform Configuration
-CONFIG_BOARD_NPCX9=y
-
-# Serial Drivers
-CONFIG_SERIAL=y
-CONFIG_UART_INTERRUPT_DRIVEN=y
-
-# Enable console
-CONFIG_CONSOLE=y
-CONFIG_UART_CONSOLE=y
-
-# Pinmux Driver
-CONFIG_PINMUX=y
-
-# GPIO Controller
-CONFIG_GPIO=y
-
-# Clock configuration
-CONFIG_CLOCK_CONTROL=y
-
-# WATCHDOG configuration
-CONFIG_WATCHDOG=y
-
-CONFIG_BBRAM=y
-CONFIG_BBRAM_NPCX=y
diff --git a/zephyr/boards/arm/npcx_evb/Kconfig.board b/zephyr/boards/arm/npcx_evb/Kconfig.board
deleted file mode 100644
index 0ac4a80833..0000000000
--- a/zephyr/boards/arm/npcx_evb/Kconfig.board
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Note: this Zephyr board more closely represents the Chrome OS
-# concept of a baseboard. Zephyr boards and Chrome OS boards do not
-# have a 1:1 mapping.
-config BOARD_NPCX7_EVB
- bool "NPCX7 Evaluation Board"
- depends on SOC_NPCX7M6FB || SOC_NPCX7M6FC || SOC_NPCX7M7FC
- # Allow generating initial 0 line coverage.
- select HAS_COVERAGE_SUPPORT
-
-config BOARD_NPCX9_EVB
- bool "NPCX9 Evaluation Board"
- depends on SOC_NPCX9M3F || SOC_NPCX9M6F
- # Allow generating initial 0 line coverage.
- select HAS_COVERAGE_SUPPORT
diff --git a/zephyr/boards/arm/npcx_evb/Kconfig.defconfig b/zephyr/boards/arm/npcx_evb/Kconfig.defconfig
deleted file mode 100644
index c0c874ad26..0000000000
--- a/zephyr/boards/arm/npcx_evb/Kconfig.defconfig
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-config BOARD
- default "npcx7_evb" if BOARD_NPCX7_EVB
- default "npcx9_evb" if BOARD_NPCX9_EVB
diff --git a/zephyr/boards/arm/npcx_evb/npcx7_evb.dts b/zephyr/boards/arm/npcx_evb/npcx7_evb.dts
deleted file mode 100644
index c20589d637..0000000000
--- a/zephyr/boards/arm/npcx_evb/npcx7_evb.dts
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/dts-v1/;
-
-#include <cros/nuvoton/npcx7.dtsi>
-
-/*
- * #include <nuvoton/npcx7m6fb.dtsi>
- * #include <nuvoton/npcx7m6fc.dtsi>
- * #include <nuvoton/npcx7m7fc.dtsi>
- */
-#include <nuvoton/npcx7m6fc.dtsi>
-#include "npcx_evb.dtsi"
-
-&uart1 {
- status = "okay";
- current-speed = <115200>;
- pinctrl-0 = <&altc_uart1_sl2>; /* Use UART1_SL2 ie. PIN64.65 */
-};
diff --git a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig
deleted file mode 100644
index b2fc879cbc..0000000000
--- a/zephyr/boards/arm/npcx_evb/npcx7_evb_defconfig
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Kernel Configuration
-CONFIG_SOC_SERIES_NPCX7=y
-# NPCX7 soc list
-# CONFIG_SOC_NPCX7M6FB
-# CONFIG_SOC_NPCX7M6FC
-# CONFIG_SOC_NPCX7M7FC
-CONFIG_SOC_NPCX7M6FC=y
-
-# Platform Configuration
-CONFIG_BOARD_NPCX7_EVB=y
-
-# Serial Drivers
-CONFIG_SERIAL=y
-CONFIG_UART_INTERRUPT_DRIVEN=y
-
-# Enable console
-CONFIG_CONSOLE=y
-CONFIG_UART_CONSOLE=y
-
-# Pinmux Driver
-CONFIG_PINMUX=y
-
-# GPIO Controller
-CONFIG_GPIO=y
-
-# Clock configuration
-CONFIG_CLOCK_CONTROL=y
-
-# 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_SOC_POWER_MANAGEMENT=y
-CONFIG_PM_POLICY_APP=y
-CONFIG_UART_CONSOLE_INPUT_EXPIRED=y
-CONFIG_SOC_POWER_MANAGEMENT_TRACE=y
-
-# BBRAM
-CONFIG_BBRAM=y
-CONFIG_BBRAM_NPCX=y
diff --git a/zephyr/boards/arm/npcx_evb/npcx9_evb.dts b/zephyr/boards/arm/npcx_evb/npcx9_evb.dts
deleted file mode 100644
index 4ab68cdde1..0000000000
--- a/zephyr/boards/arm/npcx_evb/npcx9_evb.dts
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/dts-v1/;
-
-#include <cros/nuvoton/npcx9.dtsi>
-
-/*
- * #include <nuvoton/npcx9m3f.dtsi>
- * #include <nuvoton/npcx9m6f.dtsi>
- */
-#include <nuvoton/npcx9m6f.dtsi>
-#include "npcx_evb.dtsi"
-
-&uart1 {
- status = "okay";
- current-speed = <115200>;
- pinctrl-0 = <&altj_cr_sin1_sl2 &altj_cr_sout1_sl2>;
-};
diff --git a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig b/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig
deleted file mode 100644
index 9a946584ef..0000000000
--- a/zephyr/boards/arm/npcx_evb/npcx9_evb_defconfig
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Kernel Configuration
-CONFIG_SOC_SERIES_NPCX9=y
-# NPCX9 soc list
-# CONFIG_SOC_NPCX9M3F
-# CONFIG_SOC_NPCX9M6F
-CONFIG_SOC_NPCX9M6F=y
-
-# Platform Configuration
-CONFIG_BOARD_NPCX9_EVB=y
-
-# Serial Drivers
-CONFIG_SERIAL=y
-CONFIG_UART_INTERRUPT_DRIVEN=y
-
-# Enable console
-CONFIG_CONSOLE=y
-CONFIG_UART_CONSOLE=y
-
-# Pinmux Driver
-CONFIG_PINMUX=y
-
-# GPIO Controller
-CONFIG_GPIO=y
-
-# Clock configuration
-CONFIG_CLOCK_CONTROL=y
-
-# 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_SOC_POWER_MANAGEMENT=y
-CONFIG_PM_POLICY_APP=y
-CONFIG_UART_CONSOLE_INPUT_EXPIRED=y
-CONFIG_SOC_POWER_MANAGEMENT_TRACE=y
-
-# BBRAM
-CONFIG_BBRAM=y
-CONFIG_BBRAM_NPCX=y
diff --git a/zephyr/boards/arm/npcx_evb/npcx_evb.dtsi b/zephyr/boards/arm/npcx_evb/npcx_evb.dtsi
deleted file mode 100644
index 61a1e79783..0000000000
--- a/zephyr/boards/arm/npcx_evb/npcx_evb.dtsi
+++ /dev/null
@@ -1,169 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <dt-bindings/gpio_defines.h>
-
-/ {
- model = "Nuvoton NPCX Evaluation Board";
-
- chosen {
- zephyr,sram = &sram0;
- zephyr,console = &uart1;
- zephyr,shell-uart = &uart1;
- zephyr,flash = &flash0;
- cros,rtc = &mtc;
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- i2c_evb_0_0 {
- i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_EVB_0";
- label = "I2C0_0";
- };
- i2c_evb_1_0 {
- i2c-port = <&i2c1_0>;
- enum-name = "I2C_PORT_EVB_1";
- label = "I2C1_0";
- };
- i2c_evb_2_0 {
- i2c-port = <&i2c2_0>;
- enum-name = "I2C_PORT_EVB_2";
- label = "I2C2_0";
- };
- i2c_evb_3_0 {
- i2c-port = <&i2c3_0>;
- enum-name = "I2C_PORT_EVB_3";
- label = "I2C3_0";
- };
- i2c_evb_7_0 {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_EVB_7";
- label = "I2C7_0";
- };
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- adc_ch_0 {
- label = "ADC0";
- enum-name = "ADC_EVB_CH_0";
- channel = <0>;
- };
- adc_ch_1 {
- label = "ADC1";
- enum-name = "ADC_EVB_CH_1";
- channel = <1>;
- };
- adc_ch_2 {
- label = "ADC2";
- enum-name = "ADC_EVB_CH_2";
- channel = <2>;
- };
- adc_ch_3 {
- label = "ADC3";
- enum-name = "ADC_EVB_CH_3";
- channel = <3>;
- };
- adc_ch_4 {
- label = "ADC4";
- enum-name = "ADC_EVB_CH_4";
- channel = <4>;
- };
- };
-
- vsby-psl-in-list {
- /* Use PSL_IN1/2/3 as detection pins from hibernate mode */
- psl-in-pads = <&psl_in1 &psl_in2 &psl_in3>;
- };
-};
-
-&i2c0_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c1_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c2_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c_ctrl2 {
- status = "okay";
-};
-
-&i2c3_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&i2c7_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
-
-&adc0 {
- status = "okay";
-};
-
-/* Power switch logic input pads */
-&psl_in1 {
- flag = <NPCX_PSL_FALLING_EDGE>;
-};
-&psl_in2 {
- flag = <NPCX_PSL_FALLING_EDGE>;
-};
-&psl_in3 {
- flag = <NPCX_PSL_RISING_EDGE>;
-};
-
-&cros_kb_raw {
- status = "okay";
- pinctrl-0 = <&alt7_no_ksi0_sl
- &alt7_no_ksi1_sl
- &alt7_no_ksi2_sl
- &alt7_no_ksi3_sl
- &alt7_no_ksi4_sl
- &alt7_no_ksi5_sl
- &alt7_no_ksi6_sl
- &alt7_no_ksi7_sl
- &alt8_no_kso00_sl
- &alt8_no_kso01_sl
- &alt8_no_kso02_sl
- &alt8_no_kso03_sl
- &alt8_no_kso04_sl
- &alt8_no_kso05_sl
- &alt8_no_kso06_sl
- &alt8_no_kso07_sl
- &alt9_no_kso08_sl
- &alt9_no_kso09_sl
- &alt9_no_kso10_sl
- &alt9_no_kso11_sl
- &alt9_no_kso12_sl
- >;
-};
diff --git a/zephyr/boards/arm/trogdor/Kconfig.board b/zephyr/boards/arm/trogdor/Kconfig.board
deleted file mode 100644
index 4bfa4e50ac..0000000000
--- a/zephyr/boards/arm/trogdor/Kconfig.board
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# "BOARD" below refers to a Zephyr board, which does not have a 1:1
-# mapping with the Chrome OS concept of a board. By Zephyr's
-# conventions, we'll still call it "BOARD_*" to make this more
-# applicable to be upstreamed, even though this code is shared by all
-# projects using Trogdor baseboard.
-config BOARD_TROGDOR
- bool "Google Trogdor Baseboard"
- depends on SOC_NPCX7M7FC
- # NPCX doesn't actually have enough ram for coverage, but this will
- # allow generating initial 0 line coverage.
- select HAS_COVERAGE_SUPPORT
diff --git a/zephyr/boards/arm/trogdor/Kconfig.defconfig b/zephyr/boards/arm/trogdor/Kconfig.defconfig
deleted file mode 100644
index bfd2e43bbf..0000000000
--- a/zephyr/boards/arm/trogdor/Kconfig.defconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if BOARD_TROGDOR
-
-config BOARD
- default "trogdor"
-
-endif # BOARD_TROGDOR
diff --git a/zephyr/boards/arm/trogdor/board.cmake b/zephyr/boards/arm/trogdor/board.cmake
deleted file mode 100644
index a204305534..0000000000
--- a/zephyr/boards/arm/trogdor/board.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-set(NPCX_IMAGE_FILE ${PROJECT_BINARY_DIR}/zephyr.npcx.bin)
diff --git a/zephyr/boards/arm/trogdor/trogdor.dts b/zephyr/boards/arm/trogdor/trogdor.dts
deleted file mode 100644
index 4bc7f7efc1..0000000000
--- a/zephyr/boards/arm/trogdor/trogdor.dts
+++ /dev/null
@@ -1,272 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/dts-v1/;
-
-#include <cros/nuvoton/npcx7.dtsi>
-#include <dt-bindings/adc/adc.h>
-#include <dt-bindings/gpio_defines.h>
-#include <dt-bindings/wake_mask_event_defines.h>
-#include <nuvoton/npcx7m7fc.dtsi>
-
-/ {
- model = "Google Trogdor Baseboard";
-
- aliases {
- i2c-0 = &i2c0_0;
- i2c-1 = &i2c1_0;
- i2c-2 = &i2c2_0;
- i2c-3 = &i2c3_0;
- i2c-5 = &i2c5_0;
- i2c-7 = &i2c7_0;
- };
-
- chosen {
- zephyr,sram = &sram0;
- zephyr,console = &uart1;
- zephyr,shell-uart = &uart1;
- zephyr,flash = &flash0;
- cros,rtc = &mtc;
- };
-
- ec-console {
- compatible = "ec-console";
-
- disabled = "hostcmd";
- };
-
- ec-mkbp-host-event-wakeup-mask {
- compatible = "ec-wake-mask-event";
- wakeup-mask = <(
- HOST_EVENT_MASK(HOST_EVENT_LID_OPEN) |
- HOST_EVENT_MASK(HOST_EVENT_POWER_BUTTON) |
- HOST_EVENT_MASK(HOST_EVENT_AC_CONNECTED) |
- HOST_EVENT_MASK(HOST_EVENT_AC_DISCONNECTED) |
- HOST_EVENT_MASK(HOST_EVENT_HANG_DETECT) |
- HOST_EVENT_MASK(HOST_EVENT_RTC) |
- HOST_EVENT_MASK(HOST_EVENT_MODE_CHANGE) |
- HOST_EVENT_MASK(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)>;
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- power {
- i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_POWER";
- label = "POWER";
- };
- battery {
- i2c-port = <&i2c0_0>;
- remote-port = <0>;
- enum-name = "I2C_PORT_BATTERY";
- label = "BATTERY";
- };
- virtual {
- i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_VIRTUAL";
- label = "VIRTUAL";
- };
- charger {
- i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_CHARGER";
- label = "CHARGER";
- };
- tcpc0 {
- i2c-port = <&i2c1_0>;
- enum-name = "I2C_PORT_TCPC0";
- label = "TCPC0";
- };
- tcpc1 {
- i2c-port = <&i2c2_0>;
- enum-name = "I2C_PORT_TCPC1";
- label = "TCPC1";
- };
- eeprom {
- i2c-port = <&i2c5_0>;
- enum-name = "I2C_PORT_EEPROM";
- label = "EEPROM";
- };
- i2c_sensor: sensor {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_SENSOR";
- label = "SENSOR";
- };
- accel {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_ACCEL";
- label = "ACCEL";
- };
- };
-
- named-pwms {
- compatible = "named-pwms";
-
- kblight {
- pwms = <&pwm3 0 0>;
- label = "KBLIGHT";
- frequency = <10000>;
- };
- displight {
- pwms = <&pwm5 0 0>;
- label = "DISPLIGHT";
- frequency = <4800>;
- };
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- vbus {
- label = "ADC_VBUS";
- enum-name = "ADC_VBUS";
- channel = <1>;
- /* Measure VBUS through a 1/10 voltage divider */
- mul = <10>;
- };
- amon_bmon {
- label = "ADC_AMON_BMON";
- enum-name = "ADC_AMON_BMON";
- channel = <2>;
- /*
- * Adapter current output or battery charging/
- * discharging current (uV) 18x amplification on
- * charger side.
- */
- mul = <1000>;
- div = <18>;
- };
- psys {
- label = "ADC_PSYS";
- enum-name = "ADC_PSYS";
- channel = <3>;
- /*
- * ISL9238 PSYS output is 1.44 uA/W over 5.6K resistor,
- * to read 0.8V @ 99 W, i.e. 124000 uW/mV.
- */
- mul = <124000>;
- };
- };
-
- def-lvol-io-list {
- compatible = "nuvoton,npcx-lvolctrl-def";
-
- /* I2C_SDA0 & SCL0 */
- lvol-io-pads = <&lvol_iob4 &lvol_iob5>;
- };
-};
-
-&uart1 {
- status = "okay";
- current-speed = <115200>;
- pinctrl-0 = <&altc_uart1_sl2>; /* Use UART1_SL2 ie. PIN64.65 */
-};
-
-&i2c0_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-
- isl9238: isl9238@9 {
- compatible = "intersil,isl9238";
- reg = <0x09>;
- label = "ISL9238_CHARGER";
- };
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c1_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c2_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl2 {
- status = "okay";
-};
-
-&i2c3_0 {
- /* Not used as no WLC connected */
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&i2c5_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl5 {
- status = "okay";
-};
-
-&i2c7_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
-
-/* Keyboard backlight */
-&pwm3 {
- status = "okay";
-};
-
-/* Display backlight */
-&pwm5 {
- status = "okay";
-};
-
-&adc0 {
- status = "okay";
-};
-
-&cros_kb_raw {
- status = "okay";
- /* No KSO2 (it's inverted and implemented by GPIO) */
- pinctrl-0 = <&alt7_no_ksi0_sl
- &alt7_no_ksi1_sl
- &alt7_no_ksi2_sl
- &alt7_no_ksi3_sl
- &alt7_no_ksi4_sl
- &alt7_no_ksi5_sl
- &alt7_no_ksi6_sl
- &alt7_no_ksi7_sl
- &alt8_no_kso00_sl
- &alt8_no_kso01_sl
- &alt8_no_kso03_sl
- &alt8_no_kso04_sl
- &alt8_no_kso05_sl
- &alt8_no_kso06_sl
- &alt8_no_kso07_sl
- &alt9_no_kso08_sl
- &alt9_no_kso09_sl
- &alt9_no_kso10_sl
- &alt9_no_kso11_sl
- &alt9_no_kso12_sl
- >;
-};
diff --git a/zephyr/boards/arm/trogdor/trogdor_defconfig b/zephyr/boards/arm/trogdor/trogdor_defconfig
deleted file mode 100644
index 2a61f3dd5c..0000000000
--- a/zephyr/boards/arm/trogdor/trogdor_defconfig
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Kernel Configuration
-CONFIG_SOC_SERIES_NPCX7=y
-CONFIG_SOC_NPCX7M7FC=y
-
-# Platform Configuration
-CONFIG_BOARD_TROGDOR=y
-
-# Serial Drivers
-CONFIG_SERIAL=y
-CONFIG_UART_INTERRUPT_DRIVEN=y
-
-# Enable console
-CONFIG_CONSOLE=y
-CONFIG_UART_CONSOLE=y
-
-# Pinmux Driver
-CONFIG_PINMUX=y
-
-# GPIO Controller
-CONFIG_GPIO=y
-
-# Clock configuration
-CONFIG_CLOCK_CONTROL=y
-
-# WATCHDOG configuration
-CONFIG_WATCHDOG=y
-
-# Power Management
-CONFIG_SOC_POWER_MANAGEMENT=y
-CONFIG_PM_POLICY_APP=y
-CONFIG_UART_CONSOLE_INPUT_EXPIRED=y
-CONFIG_SOC_POWER_MANAGEMENT_TRACE=y
-
-# BBRAM
-CONFIG_BBRAM=y
-CONFIG_BBRAM_NPCX=y
diff --git a/zephyr/boards/arm/volteer/Kconfig.board b/zephyr/boards/arm/volteer/Kconfig.board
deleted file mode 100644
index 5a0390e16f..0000000000
--- a/zephyr/boards/arm/volteer/Kconfig.board
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Note: this Zephyr board more closely represents the Chrome OS
-# concept of a baseboard. Zephyr boards and Chrome OS boards do not
-# have a 1:1 mapping.
-config BOARD_VOLTEER
- bool "Google Volteer Baseboard"
- depends on SOC_NPCX7M6FC || SOC_NPCX7M7FC
- # NPCX doesn't actually have enough ram for coverage, but this will
- # allow generating initial 0 line coverage.
- select HAS_COVERAGE_SUPPORT
diff --git a/zephyr/boards/arm/volteer/Kconfig.defconfig b/zephyr/boards/arm/volteer/Kconfig.defconfig
deleted file mode 100644
index 05361962d9..0000000000
--- a/zephyr/boards/arm/volteer/Kconfig.defconfig
+++ /dev/null
@@ -1,11 +0,0 @@
-# Google Volteer EC
-
-# Copyright 2020 The Chromium OS Authors
-# SPDX-License-Identifier: Apache-2.0
-
-if BOARD_VOLTEER
-
-config BOARD
- default "volteer"
-
-endif # BOARD_VOLTEER
diff --git a/zephyr/boards/arm/volteer/board.cmake b/zephyr/boards/arm/volteer/board.cmake
deleted file mode 100644
index e29e12278d..0000000000
--- a/zephyr/boards/arm/volteer/board.cmake
+++ /dev/null
@@ -1,3 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-
-set(NPCX_IMAGE_FILE ${PROJECT_BINARY_DIR}/zephyr.npcx.bin)
diff --git a/zephyr/boards/arm/volteer/volteer.dts b/zephyr/boards/arm/volteer/volteer.dts
deleted file mode 100644
index d837f8ab55..0000000000
--- a/zephyr/boards/arm/volteer/volteer.dts
+++ /dev/null
@@ -1,322 +0,0 @@
-/*
- * Copyright (c) 2020 The Chromium OS Authors
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-/dts-v1/;
-
-#include <cros/nuvoton/npcx7.dtsi>
-#include <dt-bindings/adc/adc.h>
-#include <dt-bindings/charger/intersil_isl9241.h>
-#include <dt-bindings/gpio_defines.h>
-#include <nuvoton/npcx7m7fc.dtsi>
-#include <cros/thermistor/thermistor.dtsi>
-
-/ {
- model = "Google Volteer EC";
-
- aliases {
- i2c-0 = &i2c0_0;
- i2c-1 = &i2c1_0;
- i2c-2 = &i2c2_0;
- i2c-3 = &i2c3_0;
- i2c-5 = &i2c5_0;
- i2c-7 = &i2c7_0;
- };
-
- chosen {
- zephyr,sram = &sram0;
- zephyr,console = &uart1;
- zephyr,shell-uart = &uart1;
- zephyr,flash = &flash0;
- cros,rtc = &mtc;
- };
-
- ec-console {
- compatible = "ec-console";
-
- disabled = "hostcmd";
- };
-
- named-batteries {
- compatible = "named-batteries";
-
- lgc011 {
- enum-name = "lgc011";
- };
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- i2c_sensor: sensor {
- i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_SENSOR";
- label = "SENSOR";
- };
- i2c-accel {
- i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_ACCEL";
- label = "ACCEL";
- };
- usb-c0 {
- i2c-port = <&i2c1_0>;
- enum-name = "I2C_PORT_USB_C0";
- label = "USB_C0";
- };
- usb-c1 {
- i2c-port = <&i2c2_0>;
- enum-name = "I2C_PORT_USB_C1";
- label = "USB_C1";
- };
- usb1-mix {
- i2c-port = <&i2c3_0>;
- enum-name = "I2C_PORT_USB_1_MIX";
- label = "USB_1_MIX";
- };
- power {
- i2c-port = <&i2c5_0>;
- enum-name = "I2C_PORT_POWER";
- label = "POWER";
- };
- battery {
- i2c-port = <&i2c5_0>;
- enum-name = "I2C_PORT_BATTERY";
- label = "BATTERY";
- };
- eeprom {
- i2c-port = <&i2c7_0>;
- remote-port = <7>;
- enum-name = "I2C_PORT_EEPROM";
- label = "EEPROM";
- };
- charger {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_CHARGER";
- label = "CHARGER";
- };
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- adc_charger: charger {
- label = "ADC_TEMP_SENSOR_CHARGER";
- enum-name = "ADC_TEMP_SENSOR_CHARGER";
- channel = <0>;
- };
- adc_pp3300_regulator: pp3300_regulator {
- label = "ADC_TEMP_SENSOR_PP3300_REGULATOR";
- enum-name = "ADC_TEMP_SENSOR_PP3300_REGULATOR";
- channel = <1>;
- };
- adc_ddr_soc: ddr_soc {
- label = "ADC_TEMP_SENSOR_DDR_SOC";
- enum-name = "ADC_TEMP_SENSOR_DDR_SOC";
- channel = <8>;
- };
- adc_fan: fan {
- label = "ADC_TEMP_SENSOR_FAN";
- enum-name = "ADC_TEMP_SENSOR_FAN";
- channel = <3>;
- };
- };
-
- named-temp-sensors {
- charger {
- compatible = "cros-ec,temp-sensor";
- thermistor = <&thermistor_3V3_30K9_47K_4050B>;
- label = "TEMP_SENSOR_CHARGER";
- enum-name = "TEMP_SENSOR_CHARGER";
- temp_fan_off = <40>;
- temp_fan_max = <55>;
- temp_host_high = <75>;
- temp_host_halt = <80>;
- temp_host_release_high = <65>;
- adc = <&adc_charger>;
- };
- pp3300_regulator {
- compatible = "cros-ec,temp-sensor";
- thermistor = <&thermistor_3V3_30K9_47K_4050B>;
- label = "TEMP_SENSOR_PP3300_REGULATOR";
- enum-name = "TEMP_SENSOR_PP3300_REGULATOR";
- temp_fan_off = <40>;
- temp_fan_max = <55>;
- temp_host_high = <75>;
- temp_host_halt = <80>;
- temp_host_release_high = <65>;
- adc = <&adc_pp3300_regulator>;
- };
- ddr_soc {
- compatible = "cros-ec,temp-sensor";
- thermistor = <&thermistor_3V3_30K9_47K_4050B>;
- label = "TEMP_SENSOR_DDR_SOC";
- enum-name = "TEMP_SENSOR_DDR_SOC";
- temp_fan_off = <35>;
- temp_fan_max = <50>;
- temp_host_high = <70>;
- temp_host_halt = <80>;
- temp_host_release_high = <65>;
- adc = <&adc_ddr_soc>;
- };
- fan {
- compatible = "cros-ec,temp-sensor";
- thermistor = <&thermistor_3V3_30K9_47K_4050B>;
- label = "TEMP_SENSOR_FAN";
- enum-name = "TEMP_SENSOR_FAN";
- temp_fan_off = <35>;
- temp_fan_max = <50>;
- temp_host_high = <70>;
- temp_host_halt = <80>;
- temp_host_release_high = <65>;
- adc = <&adc_fan>;
- };
- };
-
- vsby-psl-in-list {
- /* Use PSL_IN1/2/3/4 as detection pins from hibernate mode */
- psl-in-pads = <&psl_in1 &psl_in2 &psl_in3 &psl_in4>;
- };
-
- /*
- * The CBI Second Source Factory Cache (SSFC) layout definition.
- * Specific fields values are defined per board.
- */
- cbi-ssfc {
- compatible = "named-cbi-ssfc";
-
- cbi_ssfc_base_sensor: base_sensor {
- enum-name = "BASE_SENSOR";
- size = <3>;
- };
- cbi_ssfc_lid_sensor: lid_sensor {
- enum-name = "LID_SENSOR";
- size = <3>;
- };
- cbi_ssfc_lightbar: lightbar {
- enum-name = "LIGHTBAR";
- size = <2>;
- };
- };
-};
-
-&uart1 {
- status = "okay";
- current-speed = <115200>;
- pinctrl-0 = <&altc_uart1_sl2>; /* Use UART1_SL2 ie. PIN64.65 */
-};
-
-&i2c0_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c1_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c2_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST_PLUS>;
-};
-
-&i2c_ctrl2 {
- status = "okay";
-};
-
-&i2c3_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&i2c5_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c_ctrl5 {
- status = "okay";
-};
-
-&i2c7_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- isl9241: isl9241@9 {
- compatible = "intersil,isl9241";
- reg = <0x09>;
- label = "ISL9241_CHARGER";
- switching-frequency = <SWITCHING_FREQ_724KHZ>;
- };
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
-
-&cros_kb_raw {
- status = "okay";
- /* No KSO2 (it's inverted and implemented by GPIO) */
- pinctrl-0 = <&alt7_no_ksi0_sl
- &alt7_no_ksi1_sl
- &alt7_no_ksi2_sl
- &alt7_no_ksi3_sl
- &alt7_no_ksi4_sl
- &alt7_no_ksi5_sl
- &alt7_no_ksi6_sl
- &alt7_no_ksi7_sl
- &alt8_no_kso00_sl
- &alt8_no_kso01_sl
- &alt8_no_kso03_sl
- &alt8_no_kso04_sl
- &alt8_no_kso05_sl
- &alt8_no_kso06_sl
- &alt8_no_kso07_sl
- &alt9_no_kso08_sl
- &alt9_no_kso09_sl
- &alt9_no_kso10_sl
- &alt9_no_kso11_sl
- &alt9_no_kso12_sl
- &alt9_no_kso13_sl
- &alt9_no_kso14_sl
- >;
-};
-
-&adc0 {
- status = "okay";
-};
-
-/* Power switch logic input pads */
-&psl_in1 {
- flag = <NPCX_PSL_RISING_EDGE>;
-};
-
-&psl_in2 {
- flag = <NPCX_PSL_RISING_EDGE>;
-};
-
-&psl_in3 {
- flag = <NPCX_PSL_FALLING_EDGE>;
-};
-
-&psl_in4 {
- flag = <NPCX_PSL_RISING_EDGE>;
-};
-
-&thermistor_3V3_30K9_47K_4050B {
- status = "okay";
-};
diff --git a/zephyr/boards/arm/volteer/volteer_defconfig b/zephyr/boards/arm/volteer/volteer_defconfig
deleted file mode 100644
index a3f184dff8..0000000000
--- a/zephyr/boards/arm/volteer/volteer_defconfig
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Kernel Configuration
-CONFIG_SOC_SERIES_NPCX7=y
-CONFIG_SOC_NPCX7M7FC=y
-
-# Platform Configuration
-CONFIG_BOARD_VOLTEER=y
-
-# Serial Drivers
-CONFIG_SERIAL=y
-CONFIG_UART_INTERRUPT_DRIVEN=y
-
-# Enable console
-CONFIG_CONSOLE=y
-CONFIG_UART_CONSOLE=y
-
-# Pinmux Driver
-CONFIG_PINMUX=y
-
-# GPIO Controller
-CONFIG_GPIO=y
-
-# Clock configuration
-CONFIG_CLOCK_CONTROL=y
-
-# WATCHDOG configuration
-CONFIG_WATCHDOG=y
-
-# ADC
-# The resolution and oversamplig values are fixed by the NPCX ADC driver
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
-# Power Management
-CONFIG_SOC_POWER_MANAGEMENT=y
-CONFIG_PM_POLICY_APP=y
-CONFIG_UART_CONSOLE_INPUT_EXPIRED=y
-CONFIG_SOC_POWER_MANAGEMENT_TRACE=y
-
-# BBRAM
-CONFIG_BBRAM=y
-CONFIG_BBRAM_NPCX=y
diff --git a/zephyr/boards/riscv/asurada/Kconfig.board b/zephyr/boards/riscv/asurada/Kconfig.board
deleted file mode 100644
index f17a00d2fd..0000000000
--- a/zephyr/boards/riscv/asurada/Kconfig.board
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# "BOARD" below refers to a Zephyr board, which does not have a 1:1
-# mapping with the Chrome OS concept of a board. By Zephyr's
-# conventions, we'll still call it "BOARD_*" to make this more
-# applicable to be upstreamed, even though this code is shared by all
-# projects using Trogdor baseboard.
-config BOARD_ASURADA
- bool "Google Asurada Baseboard"
- depends on SOC_IT8XXX2
- # Allow generating initial 0 line coverage.
- select HAS_COVERAGE_SUPPORT
diff --git a/zephyr/boards/riscv/asurada/Kconfig.defconfig b/zephyr/boards/riscv/asurada/Kconfig.defconfig
deleted file mode 100644
index cc3e4b000c..0000000000
--- a/zephyr/boards/riscv/asurada/Kconfig.defconfig
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if BOARD_ASURADA
-
-config BOARD
- default "asurada"
-
-# Zephyr internal stack sizes
-
-config IDLE_STACK_SIZE
- default 256
-
-config ISR_STACK_SIZE
- default 800
-
-config SHELL_STACK_SIZE
- default 1048
-
-config SYSTEM_WORKQUEUE_STACK_SIZE
- default 1024
-
-
-# Chromium EC stack sizes
-
-config TASK_CHARGER_STACK_SIZE
- default 960
-
-config TASK_CHIPSET_STACK_SIZE
- default 820
-
-config TASK_HOOKS_STACK_SIZE
- default 672
-
-config TASK_HOSTCMD_STACK_SIZE
- default 1024
-
-config TASK_KEYSCAN_STACK_SIZE
- default 920
-
-config TASK_MOTIONSENSE_STACK_SIZE
- default 920
-
-config TASK_PD_STACK_SIZE
- default 1024
-
-config TASK_USB_CHG_STACK_SIZE
- default 800
-
-
-choice PLATFORM_EC_HOSTCMD_DEBUG_MODE
- default HCDEBUG_OFF
-endchoice # PLATFORM_EC_HOSTCMD_DEBUG_MODE
-
-endif # BOARD_ASURADA
diff --git a/zephyr/boards/riscv/asurada/asurada.dts b/zephyr/boards/riscv/asurada/asurada.dts
deleted file mode 100644
index 7b4519c0e1..0000000000
--- a/zephyr/boards/riscv/asurada/asurada.dts
+++ /dev/null
@@ -1,200 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/dts-v1/;
-
-#include <cros/ite/it8xxx2.dtsi>
-#include <dt-bindings/adc/adc.h>
-#include <dt-bindings/gpio_defines.h>
-#include <it8xxx2.dtsi>
-#include <dt-bindings/wake_mask_event_defines.h>
-
-/ {
- model = "Google Asurada Baseboard";
-
- chosen {
- zephyr,sram = &sram0;
- zephyr,console = &uart1;
- zephyr,shell-uart = &uart1;
- zephyr,flash = &flash0;
- zephyr,flash-controller = &flashctrl;
- };
-
- ec-mkbp-host-event-wakeup-mask {
- compatible = "ec-wake-mask-event";
- wakeup-mask = <(
- HOST_EVENT_MASK(HOST_EVENT_AC_CONNECTED) |
- HOST_EVENT_MASK(HOST_EVENT_AC_DISCONNECTED) |
- HOST_EVENT_MASK(HOST_EVENT_LID_OPEN) |
- HOST_EVENT_MASK(HOST_EVENT_POWER_BUTTON) |
- HOST_EVENT_MASK(HOST_EVENT_HANG_DETECT) |
- HOST_EVENT_MASK(HOST_EVENT_MODE_CHANGE))>;
- };
-
- ec-mkbp-event-wakeup-mask {
- compatible = "ec-wake-mask-event";
- wakeup-mask = <(MKBP_EVENT_KEY_MATRIX |
- MKBP_EVENT_HOST_EVENT)>;
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- adc_vbus_c0 {
- label = "ADC_VBUS_C0";
- enum-name = "ADC_VBUS_C0";
- channel = <0>;
- mul = <10>;
- };
- adc_board_id0 {
- label = "ADC_BOARD_ID_0";
- enum-name = "ADC_BOARD_ID_0";
- channel = <1>;
- };
- adc_board_id1 {
- label = "ADC_BOARD_ID_1";
- enum-name = "ADC_BOARD_ID_1";
- channel = <2>;
- };
- adc_charger_amon_r {
- label = "ADC_AMON_BMON";
- enum-name = "ADC_AMON_BMON";
- channel = <3>;
- mul = <1000>;
- div = <18>;
- };
- adc_vbus_c1 {
- label = "ADC_VBUS_C1";
- enum-name = "ADC_VBUS_C1";
- channel = <5>;
- mul = <10>;
- };
- adc_charger_pmon {
- label = "ADC_PMON";
- enum-name = "ADC_PMON";
- channel = <6>;
- };
- adc-psys {
- label = "ADC_PSYS";
- enum-name = "ADC_PSYS";
- channel = <6>;
- };
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- power {
- i2c-port = <&i2c0>;
- enum-name = "I2C_PORT_POWER";
- label = "POWER";
- };
- battery {
- i2c-port = <&i2c0>;
- remote-port = <0>;
- enum-name = "I2C_PORT_BATTERY";
- label = "BATTERY";
- };
- eeprom {
- i2c-port = <&i2c0>;
- enum-name = "I2C_PORT_EEPROM";
- label = "EEPROM";
- };
- charger {
- i2c-port = <&i2c0>;
- enum-name = "I2C_PORT_CHARGER";
- label = "CHARGER";
- };
- i2c_sensor: sensor {
- i2c-port = <&i2c1>;
- enum-name = "I2C_PORT_SENSOR";
- label = "SENSOR";
- };
- i2c-accel {
- i2c-port = <&i2c1>;
- enum-name = "I2C_PORT_ACCEL";
- label = "ACCEL";
- };
- ppc0 {
- i2c-port = <&i2c2>;
- enum-name = "I2C_PORT_PPC0";
- label = "PPC0";
- };
- ppc1 {
- i2c-port = <&i2c4>;
- enum-name = "I2C_PORT_PPC1";
- label = "PPC1";
- };
- usb-c0 {
- i2c-port = <&i2c2>;
- enum-name = "I2C_PORT_USB_C0";
- label = "USB_C0";
- };
- usb-c1 {
- i2c-port = <&i2c4>;
- enum-name = "I2C_PORT_USB_C1";
- label = "USB_C1";
- };
- usb-mux0 {
- i2c-port = <&i2c2>;
- enum-name = "I2C_PORT_USB_MUX0";
- label = "USB_MUX0";
- };
- usb-mux1 {
- i2c-port = <&i2c4>;
- enum-name = "I2C_PORT_USB_MUX1";
- label = "USB_MUX1";
- };
- };
-
- soc {
- cros_kb_raw: cros-kb-raw@f01d00 {
- compatible = "ite,it8xxx2-cros-kb-raw";
- reg = <0x00f01d00 0x29>;
- label = "CROS_KB_RAW_0";
- interrupt-parent = <&intc>;
- interrupts = <13 IRQ_TYPE_LEVEL_HIGH>;
- status = "disabled";
- };
- };
-};
-
-&uart1 {
- status = "okay";
- current-speed = <115200>;
- clock-frequency = <1804800>;
-};
-
-&adc0 {
- status = "okay";
-};
-
-&i2c0 {
- /* EC_I2C_PWR_CBI */
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c1 {
- /* EC_I2C_SENSOR */
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c2 {
- /* EC_I2C_USB_C0 */
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c4{
- /* EC_I2C_USB_C1 */
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&cros_kb_raw {
- status = "okay";
-};
diff --git a/zephyr/boards/riscv/asurada/asurada_defconfig b/zephyr/boards/riscv/asurada/asurada_defconfig
deleted file mode 100644
index be85cd0f07..0000000000
--- a/zephyr/boards/riscv/asurada/asurada_defconfig
+++ /dev/null
@@ -1,99 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Kernel Configuration
-CONFIG_SOC_SERIES_RISCV32_IT8XXX2=y
-
-# Platform Configuration
-CONFIG_SOC_IT8XXX2=y
-CONFIG_BOARD_ASURADA=y
-
-# SoC configuration
-CONFIG_AP=y
-CONFIG_AP_ARM_MTK_MT8192=y
-CONFIG_HAS_TASK_CHIPSET=y
-
-# Console
-CONFIG_CONSOLE=y
-CONFIG_UART_CONSOLE=y
-CONFIG_UART_NS16550=y
-CONFIG_SHELL_TAB=y
-CONFIG_SHELL_TAB_AUTOCOMPLETION=y
-CONFIG_SHELL_HISTORY=y
-
-# GPIO Controller
-CONFIG_GPIO=y
-CONFIG_GPIO_ITE_IT8XXX2=y
-
-# ADC Driver
-CONFIG_ADC_ITE_IT8XXX2=y
-CONFIG_PLATFORM_EC_ADC=y
-CONFIG_PLATFORM_EC_ADC_RESOLUTION=10
-
-# Clock configuration
-CONFIG_CLOCK_CONTROL=y
-CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32768
-CONFIG_SYS_CLOCK_TICKS_PER_SEC=32768
-
-# Flash
-CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=y
-CONFIG_PLATFORM_EC_FLASH_CROS=y
-CONFIG_SOC_FLASH_ITE_IT8XXX2=y
-
-# I2C
-CONFIG_I2C_ITE_IT8XXX2=y
-CONFIG_PLATFORM_EC_I2C=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD=y
-CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
-
-# Lid Switch
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-
-# MKBP
-CONFIG_PLATFORM_EC_MKBP_EVENT=y
-CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y
-CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP=y
-CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y
-
-# Pinmux Driver
-CONFIG_PINMUX=y
-CONFIG_PINMUX_ITE_IT8XXX2=y
-
-# Power Button
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-
-# Power Sequencing
-CONFIG_PLATFORM_EC_POWERSEQ=y
-CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y
-CONFIG_PLATFORM_EC_POWERSEQ_IT8XXX2=y
-CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-CONFIG_PLATFORM_EC_PWM=y
-CONFIG_PWM_ITE_IT8XXX2=y
-
-# Serial Drivers
-CONFIG_SERIAL=y
-CONFIG_UART_INTERRUPT_DRIVEN=y
-
-# Serial Host Interface (SHI) device.
-CONFIG_CROS_SHI_IT8XXX2=y
-
-# Timer configuration
-CONFIG_ITE_IT8XXX2_TIMER=y
-
-# WATCHDOG configuration
-CONFIG_WATCHDOG=y
-CONFIG_PLATFORM_EC_WATCHDOG_PERIOD_MS=2500
-CONFIG_WDT_ITE_WARNING_LEADING_TIME_MS=500
-
-# BBRAM
-CONFIG_BBRAM=y
-CONFIG_BBRAM_IT8XXX2=y
diff --git a/zephyr/boards/riscv/it8xxx2_evb/Kconfig.board b/zephyr/boards/riscv/it8xxx2_evb/Kconfig.board
deleted file mode 100644
index f0691edb39..0000000000
--- a/zephyr/boards/riscv/it8xxx2_evb/Kconfig.board
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-config BOARD_IT8XXX2_EVB
- bool "IT8XXX2 EV-board"
- depends on SOC_IT8XXX2
- # Allow generating initial 0 line coverage.
- select HAS_COVERAGE_SUPPORT
diff --git a/zephyr/boards/riscv/it8xxx2_evb/Kconfig.defconfig b/zephyr/boards/riscv/it8xxx2_evb/Kconfig.defconfig
deleted file mode 100644
index de08d278de..0000000000
--- a/zephyr/boards/riscv/it8xxx2_evb/Kconfig.defconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if BOARD_IT8XXX2_EVB
-
-config BOARD
- default "it8xxx2_evb"
-
-endif # BOARD_IT8XXX2_EVB
diff --git a/zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb.dts b/zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb.dts
deleted file mode 100644
index a1b61d02ec..0000000000
--- a/zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb.dts
+++ /dev/null
@@ -1,255 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/dts-v1/;
-
-#include <cros/ite/it8xxx2.dtsi>
-#include <dt-bindings/gpio_defines.h>
-#include <it8xxx2.dtsi>
-
-/ {
- model = "IT8XXX2 EV-Board";
-
- chosen {
- zephyr,sram = &sram0;
- zephyr,console = &uart1;
- zephyr,shell-uart = &uart1;
- zephyr,flash = &flash0;
- zephyr,flash-controller = &flashctrl;
- };
-
- named-gpios {
- compatible = "named-gpios";
-
- power_button_l: power_button_l {
- gpios = <&gpioe 4 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_POWER_BUTTON_L";
- label = "POWER_BUTTON_L";
- };
- lid_open: lid_open {
- gpios = <&gpioe 2 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_LID_OPEN";
- label = "LID_OPEN";
- };
- wp_l {
- gpios = <&gpioi 4 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_WP_L";
- label = "WP_L";
- };
- pch_pltrst_l {
- gpios = <&gpioe 3 GPIO_INPUT_PULL_UP>;
- enum-name = "GPIO_PCH_RSMRST_L";
- label = "PCH_PLTRST_L";
- };
- uart1_rx {
- gpios = <&gpiob 0 GPIO_INPUT_PULL_UP>;
- #enum-name = "GPIO_UART1_RX";
- label = "UART1_RX";
- };
- pch_smi_l {
- gpios = <&gpiod 3 GPIO_OUT_HIGH>;
- #enum-name = "GPIO_PCH_SMI_L";
- label = "PCH_SMI_L";
- };
- pch_sci_l {
- gpios = <&gpiod 4 GPIO_OUT_HIGH>;
- #enum-name = "GPIO_PCH_SCI_L";
- label = "PCH_SCI_L";
- };
- gate_a20_h {
- gpios = <&gpiob 5 GPIO_OUT_HIGH>;
- #enum-name = "GPIO_GATE_A20_H";
- label = "GATE_A20_H";
- };
- sys_reset_l {
- gpios = <&gpiob 6 GPIO_OUT_HIGH>;
- enum-name = "GPIO_SYS_RESET_L";
- label = "SYS_RESET_L";
- };
- lpc_clkrun_l {
- gpios = <&gpioh 0 GPIO_OUT_LOW>;
- #enum-name = "GPIO_LPC_CLKRUN_L";
- label = "LPC_CLKRUN_L";
- };
- pch_wake_l {
- gpios = <&gpiob 7 GPIO_OUT_HIGH>;
- enum-name = "GPIO_EC_PCH_WAKE_ODL";
- label = "PCH_WAKE_L";
- };
- i2c_a_scl {
- gpios = <&gpiob 3 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C0_SENSOR_SCL";
- label = "I2C_A_SCL";
- };
- i2c_a_sda {
- gpios = <&gpiob 4 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C0_SENSOR_SDA";
- label = "I2C_A_SDA";
- };
- i2c_b_scl {
- gpios = <&gpioc 1 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C1_USB_C0_SCL";
- label = "I2C_B_SCL";
- };
- i2c_b_sda {
- gpios = <&gpioc 2 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C1_USB_C0_SDA";
- label = "I2C_B_SDA";
- };
- i2c_c_scl {
- gpios = <&gpiof 6 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C2_USB_C1_SCL";
- label = "I2C_C_SCL";
- };
- i2c_c_sda {
- gpios = <&gpiof 7 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C2_USB_C1_SDA";
- label = "I2C_C_SDA";
- };
- i2c_e_scl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C5_BATTERY_SCL";
- label = "I2C_E_SCL";
- };
- i2c_e_sda {
- gpios = <&gpioe 7 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C5_BATTERY_SDA";
- label = "I2C_E_SDA";
- };
-
- spi0_cs {
- gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_SPI0_CS";
- label = "SPI0_CS";
- };
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-pins = <&power_button_l
- &lid_open>;
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- adc_vbussa: vbussa {
- label = "ADC_VBUSSA";
- enum-name = "ADC_VBUS";
- channel = <0>;
- };
- adc_vbussb: vbussb {
- label = "ADC_VBUSSB";
- enum-name = "ADC_PSYS";
- channel = <1>;
- };
- adc_evb_ch_13: evb_ch_13 {
- label = "ADC_EVB_CH_13";
- enum-name = "ADC_AMON_BMON";
- channel = <2>;
- };
- adc_evb_ch_14: evb_ch_14 {
- label = "ADC_EVB_CH_14";
- enum-name = "ADC_TEMP_SENSOR_FAN";
- channel = <3>;
- };
- adc_evb_ch_15: evb_ch_15 {
- label = "ADC_EVB_CH_15";
- enum-name = "ADC_TEMP_SENSOR_DDR_SOC";
- channel = <4>;
- };
- adc_evb_ch_16: evb_ch_16 {
- label = "ADC_EVB_CH_16";
- enum-name = "ADC_TEMP_SENSOR_CHARGER";
- channel = <5>;
- };
- };
-
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- battery {
- i2c-port = <&i2c2>;
- enum-name = "I2C_PORT_BATTERY";
- label = "BATTERY";
- };
- evb-1 {
- i2c-port = <&i2c0>;
- enum-name = "I2C_PORT_EVB_1";
- label = "EVB_1";
- };
- evb-2 {
- i2c-port = <&i2c1>;
- enum-name = "I2C_PORT_EVB_2";
- label = "EVB_2";
- };
- opt-4 {
- i2c-port = <&i2c4>;
- enum-name = "I2C_PORT_OPT_4";
- label = "OPT_4";
- };
- };
-
- named-pwms {
- compatible = "named-pwms";
- /* NOTE: &pwm number needs same with channel number */
- test0 {
- pwms = <&pwm7 PWM_CHANNEL_7 PWM_POLARITY_INVERTED>;
- label = "TEST0";
- /*
- * If we need pwm output in ITE chip power saving
- * mode, then we should set frequency <=324Hz.
- */
- frequency = <324>;
- };
- test1 {
- pwms = <&pwm0 PWM_CHANNEL_0 PWM_POLARITY_NORMAL>;
- label = "TEST1";
- frequency = <30000>;
- };
- };
-};
-
-&adc0 {
- status = "okay";
-};
-
-&i2c0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c1 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c2 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&i2c4 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-};
-
-&uart1 {
- status = "okay";
- current-speed = <115200>;
- clock-frequency = <1804800>;
-};
-
-/* TEST1 */
-&pwm0 {
- status = "okay";
- prescaler-cx = <PWM_PRESCALER_C6>;
-};
-
-/* TEST0 */
-&pwm7 {
- status = "okay";
- prescaler-cx = <PWM_PRESCALER_C4>;
-};
diff --git a/zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb_defconfig b/zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb_defconfig
deleted file mode 100644
index d667fac5a1..0000000000
--- a/zephyr/boards/riscv/it8xxx2_evb/it8xxx2_evb_defconfig
+++ /dev/null
@@ -1,75 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr Kernel Configuration
-CONFIG_SOC_SERIES_RISCV32_IT8XXX2=y
-
-# Platform Configuration
-CONFIG_SOC_IT8XXX2=y
-CONFIG_BOARD_IT8XXX2_EVB=y
-
-# Serial Drivers
-CONFIG_SERIAL=y
-CONFIG_UART_INTERRUPT_DRIVEN=y
-
-# Enable console
-CONFIG_CONSOLE=y
-CONFIG_UART_CONSOLE=y
-CONFIG_UART_NS16550=y
-CONFIG_SHELL_TAB=y
-CONFIG_SHELL_TAB_AUTOCOMPLETION=y
-CONFIG_SHELL_HISTORY=y
-
-# Pinmux Driver
-CONFIG_PINMUX=y
-CONFIG_PINMUX_ITE_IT8XXX2=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-CONFIG_PLATFORM_EC_PWM=y
-CONFIG_PWM_ITE_IT8XXX2=y
-
-# GPIO Controller
-CONFIG_GPIO=y
-CONFIG_GPIO_ITE_IT8XXX2=y
-
-# Clock configuration
-CONFIG_CLOCK_CONTROL=y
-
-# WATCHDOG configuration
-CONFIG_WATCHDOG=y
-CONFIG_WDT_ITE_WARNING_LEADING_TIME_MS=500
-
-# I2C Controller
-CONFIG_I2C_ITE_IT8XXX2=y
-
-CONFIG_ITE_IT8XXX2_TIMER=y
-
-# ADC
-CONFIG_ADC=y
-CONFIG_ADC_ITE_IT8XXX2=y
-CONFIG_PLATFORM_EC_ADC_RESOLUTION=10
-
-CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32768
-CONFIG_SYS_CLOCK_TICKS_PER_SEC=32768
-
-# Flash
-CONFIG_SOC_FLASH_ITE_IT8XXX2=y
-
-# Code RAM base for IT8XXX2
-CONFIG_CROS_EC_PROGRAM_MEMORY_BASE=0x80000000
-CONFIG_CROS_EC_RAM_BASE=0x80100000
-CONFIG_CROS_EC_DATA_RAM_SIZE=0x00100000
-CONFIG_CROS_EC_RAM_SIZE=0x0000f000
-
-
-CONFIG_CROS_EC_RO_MEM_OFF=0x0
-CONFIG_CROS_EC_RO_SIZE=0x80000
-CONFIG_CROS_EC_RW_MEM_OFF=0x0
-CONFIG_CROS_EC_RW_SIZE=0x80000
-
-# BBRAM
-CONFIG_BBRAM=y
-CONFIG_BBRAM_IT8XXX2=y
diff --git a/zephyr/cmake/bintools/gnu/target.cmake b/zephyr/cmake/bintools/gnu/target.cmake
deleted file mode 100644
index 2ec9d075dc..0000000000
--- a/zephyr/cmake/bintools/gnu/target.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr cmake system looks into ${TOOLCHAIN_ROOT}, but we just send
-# this out to the copy in ${ZEPHYR_BASE}.
-include("${ZEPHYR_BASE}/cmake/bintools/gnu/target.cmake")
diff --git a/zephyr/cmake/bintools/llvm/generic.cmake b/zephyr/cmake/bintools/llvm/generic.cmake
deleted file mode 100644
index 94b35ed51d..0000000000
--- a/zephyr/cmake/bintools/llvm/generic.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-set(CMAKE_AR "/usr/bin/llvm-ar")
-set(CMAKE_NM "/usr/bin/llvm-nm")
-set(CMAKE_OBJCOPY "/usr/bin/llvm-objcopy")
-set(CMAKE_OBJDUMP "/usr/bin/llvm-objdump")
-set(CMAKE_RANLIB "/usr/bin/llvm-ranlib")
-set(CMAKE_READELF "/usr/bin/llvm-readelf")
diff --git a/zephyr/cmake/bintools/llvm/target.cmake b/zephyr/cmake/bintools/llvm/target.cmake
deleted file mode 100644
index a77d459288..0000000000
--- a/zephyr/cmake/bintools/llvm/target.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2020 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.
-
-# Use generic bintools.
-include("${TOOLCHAIN_ROOT}/cmake/bintools/llvm/generic.cmake")
-
-# Include the GNU bintools properties as a base.
-include("${ZEPHYR_BASE}/cmake/bintools/gnu/target_bintools.cmake")
diff --git a/zephyr/cmake/compiler/clang/compiler_flags.cmake b/zephyr/cmake/compiler/clang/compiler_flags.cmake
deleted file mode 100644
index d247bd622d..0000000000
--- a/zephyr/cmake/compiler/clang/compiler_flags.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-include("${ZEPHYR_BASE}/cmake/compiler/clang/compiler_flags.cmake")
-
-# Disable -fno-freestanding.
-set_compiler_property(PROPERTY hosted)
-
-check_set_compiler_property(APPEND PROPERTY warning_extended -Wunused-variable -Werror=unused-variable)
diff --git a/zephyr/cmake/compiler/clang/generic.cmake b/zephyr/cmake/compiler/clang/generic.cmake
deleted file mode 100644
index aa3665ad39..0000000000
--- a/zephyr/cmake/compiler/clang/generic.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-set(CMAKE_C_COMPILER "/usr/bin/x86_64-pc-linux-gnu-clang")
-set(CMAKE_GCOV "/usr/bin/llvm-cov gcov")
diff --git a/zephyr/cmake/compiler/clang/target.cmake b/zephyr/cmake/compiler/clang/target.cmake
deleted file mode 100644
index 6702087df5..0000000000
--- a/zephyr/cmake/compiler/clang/target.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-set(CMAKE_C_COMPILER "${CROSS_COMPILE}clang")
-set(CMAKE_CXX_COMPILER "${CROSS_COMPILE}clang++")
diff --git a/zephyr/cmake/compiler/gcc/compiler_flags.cmake b/zephyr/cmake/compiler/gcc/compiler_flags.cmake
deleted file mode 100644
index 125f909c87..0000000000
--- a/zephyr/cmake/compiler/gcc/compiler_flags.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr cmake system looks into ${TOOLCHAIN_ROOT}, but we just send
-# this out to the copy in ${ZEPHYR_BASE}.
-include("${ZEPHYR_BASE}/cmake/compiler/gcc/compiler_flags.cmake")
diff --git a/zephyr/cmake/compiler/gcc/target.cmake b/zephyr/cmake/compiler/gcc/target.cmake
deleted file mode 100644
index 5bdb6fc5f6..0000000000
--- a/zephyr/cmake/compiler/gcc/target.cmake
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr cmake system looks into ${TOOLCHAIN_ROOT}, but we just send
-# this out to the copy in ${ZEPHYR_BASE}.
-include("${ZEPHYR_BASE}/cmake/compiler/gcc/target.cmake")
-
-# no_libgcc support has been removed in upstream zephyr, but we still
-# depend on it. This ugly hack emulates what it used to do by undoing
-# what some of target.cmake does.
-if(no_libgcc)
- list(REMOVE_ITEM TOOLCHAIN_LIBS gcc)
-endif()
diff --git a/zephyr/cmake/linker/ld/linker_flags.cmake b/zephyr/cmake/linker/ld/linker_flags.cmake
deleted file mode 100644
index c80d1d2452..0000000000
--- a/zephyr/cmake/linker/ld/linker_flags.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr cmake system looks into ${TOOLCHAIN_ROOT}, but we just send
-# this out to the copy in ${ZEPHYR_BASE}.
-include("${ZEPHYR_BASE}/cmake/linker/ld/linker_flags.cmake")
diff --git a/zephyr/cmake/linker/ld/target.cmake b/zephyr/cmake/linker/ld/target.cmake
deleted file mode 100644
index 0e2ad1f4d7..0000000000
--- a/zephyr/cmake/linker/ld/target.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Zephyr cmake system looks into ${TOOLCHAIN_ROOT}, but we just send
-# this out to the copy in ${ZEPHYR_BASE}.
-include("${ZEPHYR_BASE}/cmake/linker/ld/target.cmake")
diff --git a/zephyr/cmake/linker/lld/linker_flags.cmake b/zephyr/cmake/linker/lld/linker_flags.cmake
deleted file mode 100644
index 5055e4c5a4..0000000000
--- a/zephyr/cmake/linker/lld/linker_flags.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Include definitions for bfd as a base.
-include("${ZEPHYR_BASE}/cmake/linker/ld/linker_flags.cmake")
-# ld/linker_flags.cmake includes ${LINKER}/${COMPILER}/linker_flags.cmake but
-# that doesn't exist for ldd, so import the path that actually exists.
-include("${ZEPHYR_BASE}/cmake/linker/ld/${COMPILER}/linker_flags.cmake" OPTIONAL)
diff --git a/zephyr/cmake/linker/lld/target.cmake b/zephyr/cmake/linker/lld/target.cmake
deleted file mode 100644
index 1bbc6f479d..0000000000
--- a/zephyr/cmake/linker/lld/target.cmake
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Include definitions for bfd as a base. We need to pretend that
-# LINKER=ld to do this.
-set(LINKER ld)
-include("${ZEPHYR_BASE}/cmake/linker/ld/target.cmake")
-set(LINKER lld)
-
-# Override the path to the linker.
-set(CMAKE_LINKER "${CROSS_COMPILE}ld.lld")
-
-# Zephyr CMake system expects this macro to be defined to provide
-# default linker flags.
-macro(toolchain_ld_base)
- # For linker scripts, we pretend to bfd-like
- set_property(GLOBAL PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES
- -D__GCC_LINKER_CMD__)
-
- # Default flags
- zephyr_ld_options(
- ${TOOLCHAIN_LD_FLAGS}
- -Wl,--gc-sections
- --build-id=none)
-endmacro()
diff --git a/zephyr/cmake/toolchain/coreboot-sdk/generic.cmake b/zephyr/cmake/toolchain/coreboot-sdk/generic.cmake
deleted file mode 100644
index 1b86948bcd..0000000000
--- a/zephyr/cmake/toolchain/coreboot-sdk/generic.cmake
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2020 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.
-
-# generic.cmake is used for host-side compilation and preprocessing
-# (e.g., for device-tree). Thus, we should use LLVM for this
-# actually, as that's what's currently supported compiler-wise in the
-# chroot right now.
-include("${TOOLCHAIN_ROOT}/cmake/toolchain/llvm/generic.cmake")
diff --git a/zephyr/cmake/toolchain/coreboot-sdk/target.cmake b/zephyr/cmake/toolchain/coreboot-sdk/target.cmake
deleted file mode 100644
index 5f3d86459b..0000000000
--- a/zephyr/cmake/toolchain/coreboot-sdk/target.cmake
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 2020 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.
-
-# Coreboot SDK uses GCC
-set(COMPILER gcc)
-set(LINKER ld)
-set(BINTOOLS gnu)
-
-# Mapping of Zephyr architecture -> coreboot-sdk toolchain
-set(CROSS_COMPILE_TARGET_arm arm-eabi)
-set(CROSS_COMPILE_TARGET_riscv riscv64-elf)
-set(CROSS_COMPILE_TARGET_x86 i386-elf)
-
-set(CROSS_COMPILE_TARGET ${CROSS_COMPILE_TARGET_${ARCH}})
-
-if("${ARCH}" STREQUAL "arm" AND CONFIG_ARM64)
- set(CROSS_COMPILE_TARGET aarch64-elf)
-elseif("${ARCH}" STREQUAL "x86" AND CONFIG_X86_64)
- set(CROSS_COMPILE_TARGET x86_64-elf)
-endif()
-
-set(CC gcc)
-set(CROSS_COMPILE "/opt/coreboot-sdk/bin/${CROSS_COMPILE_TARGET}-")
-
-set(CMAKE_AR "${CROSS_COMPILE}ar")
-set(CMAKE_NM "${CROSS_COMPILE}nm")
-set(CMAKE_OBJCOPY "${CROSS_COMPILE}objcopy")
-set(CMAKE_OBJDUMP "${CROSS_COMPILE}objdump")
-set(CMAKE_RANLIB "${CROSS_COMPILE}ranlib")
-set(CMAKE_READELF "${CROSS_COMPILE}readelf")
-
-# On ARM, we don't use libgcc: It's built against a fixed target (e.g.
-# used instruction set, ABI, ISA extensions) and doesn't adapt when
-# compiler flags change any of these assumptions. Use our own mini-libgcc
-# instead.
-if("${ARCH}" STREQUAL "arm")
- set(no_libgcc True)
-endif()
diff --git a/zephyr/cmake/toolchain/llvm/generic.cmake b/zephyr/cmake/toolchain/llvm/generic.cmake
deleted file mode 100644
index 6a248a13cf..0000000000
--- a/zephyr/cmake/toolchain/llvm/generic.cmake
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-set(COMPILER clang)
-set(LINKER lld)
-set(BINTOOLS llvm)
diff --git a/zephyr/cmake/toolchain/llvm/target.cmake b/zephyr/cmake/toolchain/llvm/target.cmake
deleted file mode 100644
index d79d73d1ae..0000000000
--- a/zephyr/cmake/toolchain/llvm/target.cmake
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-set(COMPILER clang)
-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 ${CROSS_COMPILE_TARGET_${ARCH}})
-
-set(CC clang)
-set(CROSS_COMPILE "/usr/bin/${CROSS_COMPILE_TARGET}-")
diff --git a/zephyr/drivers/CMakeLists.txt b/zephyr/drivers/CMakeLists.txt
deleted file mode 100644
index d246f31703..0000000000
--- a/zephyr/drivers/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-add_subdirectory(cros_cbi)
-add_subdirectory(cros_flash)
-add_subdirectory(cros_kb_raw)
-add_subdirectory(cros_rtc)
-add_subdirectory(cros_shi)
-add_subdirectory(cros_system)
diff --git a/zephyr/drivers/Kconfig b/zephyr/drivers/Kconfig
deleted file mode 100644
index 041a6cf212..0000000000
--- a/zephyr/drivers/Kconfig
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2020 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.
-
-rsource "cros_flash/Kconfig"
-rsource "cros_kb_raw/Kconfig"
-rsource "cros_rtc/Kconfig"
-rsource "cros_system/Kconfig"
-rsource "cros_shi/Kconfig"
diff --git a/zephyr/drivers/cros_cbi/CMakeLists.txt b/zephyr/drivers/cros_cbi/CMakeLists.txt
deleted file mode 100644
index 644865ae77..0000000000
--- a/zephyr/drivers/cros_cbi/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM cros_cbi.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_GPIO cros_cbi.c)
diff --git a/zephyr/drivers/cros_cbi/cros_cbi.c b/zephyr/drivers/cros_cbi/cros_cbi.c
deleted file mode 100644
index a36a4e9143..0000000000
--- a/zephyr/drivers/cros_cbi/cros_cbi.c
+++ /dev/null
@@ -1,218 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <drivers/cros_cbi.h>
-#include "cros_board_info.h"
-#include <logging/log.h>
-
-LOG_MODULE_REGISTER(cros_cbi, LOG_LEVEL_ERR);
-
-/* CBI SSFC part */
-
-/* This part of the driver is about CBI SSFC part.
- * 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.
- */
-#define DT_DRV_COMPAT named_cbi_ssfc_value
-
-BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(named_cbi_ssfc) < 2,
- "More than 1 CBI SSFS node");
-#define CBI_SSFC_NODE DT_INST(0, named_cbi_ssfc)
-
-#define CBI_SSFC_INIT_DEFAULT_ID(id) \
- do { \
- if (DT_PROP(id, default)) { \
- cached_ssfc.CBI_SSFC_UNION_ENTRY_NAME(DT_PARENT(id)) = \
- DT_PROP(id, value); \
- } \
- } while (0);
-
-#define CBI_SSFC_INIT_DEFAULT(inst) CBI_SSFC_INIT_DEFAULT_ID(DT_DRV_INST(inst))
-
-#define CBI_SSFC_VALUE_ARRAY_ID(id) \
- [CBI_SSFC_VALUE_ID(id)] = DT_PROP(id, value),
-
-#define CBI_SSFC_VALUE_ARRAY(inst) CBI_SSFC_VALUE_ARRAY_ID(DT_DRV_INST(inst))
-
-#define CBI_SSFC_VALUE_BUILD_ASSERT(inst) \
- BUILD_ASSERT(DT_INST_PROP(inst, value) <= UINT8_MAX, \
- "CBI SSFS value too big");
-
-#define CBI_SSFC_PARENT_VALUE_CASE_GENERATE(value_id, value_parent) \
- case value_id: \
- return value_parent;
-
-#define CBI_SSFC_PARENT_VALUE_CASE_ID(id) \
- CBI_SSFC_PARENT_VALUE_CASE_GENERATE( \
- CBI_SSFC_VALUE_ID(id), \
- cached_ssfc.CBI_SSFC_UNION_ENTRY_NAME(DT_PARENT(id)))
-
-#define CBI_SSFC_PARENT_VALUE_CASE(inst) \
- CBI_SSFC_PARENT_VALUE_CASE_ID(DT_DRV_INST(inst))
-
-#define CBI_SSFC_UNION_ENTRY_NAME(id) DT_CAT(cbi_ssfc_, id)
-#define CBI_SSFC_UNION_ENTRY(id) \
- uint32_t CBI_SSFC_UNION_ENTRY_NAME(id) \
- : DT_PROP(id, size);
-
-#define CBI_SSFC_PLUS_FIELD_SIZE(id) +DT_PROP(id, size)
-#define CBI_SSFC_FIELDS_SIZE \
- (0 COND_CODE_1( \
- DT_NODE_EXISTS(CBI_SSFC_NODE), \
- (DT_FOREACH_CHILD(CBI_SSFC_NODE, CBI_SSFC_PLUS_FIELD_SIZE)), \
- ()))
-
-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";
- *
- * base_sensor {
- * enum-name = "BASE_SENSOR";
- * size = <3>;
- * bmi160 {
- * compatible = "named-cbi-ssfc-value";
- * status = "okay";
- * value = <1>;
- * };
- * };
- * lid_sensor {
- * enum-name = "LID_SENSOR";
- * size = <3>;
- * bma255 {
- * compatible = "named-cbi-ssfc-value";
- * status = "okay";
- * value = <1>;
- * };
- * };
- * lightbar {
- * enum-name = "LIGHTBAR";
- * size = <2>;
- * 10_led {
- * compatible = "named-cbi-ssfc-value";
- * status = "okay";
- * value = <1>;
- * };
- * };
- * };
- * Should be converted into
- * union cbi_ssfc {
- * struct {
- * uint32_t cbi_ssfc_DT_N_S_cbi_ssfc_S_base_sensor:3
- * uint32_t cbi_ssfc_DT_N_S_cbi_ssfc_S_lid_sensor:3
- * uint32_t cbi_ssfc_DT_N_S_cbi_ssfc_S_lightbar:2
- * uint32_t reserved : 24;
- * };
- * uint32_t raw_value;
- * };
- */
-union cbi_ssfc {
- struct {
-#if DT_NODE_EXISTS(CBI_SSFC_NODE)
- DT_FOREACH_CHILD(CBI_SSFC_NODE, CBI_SSFC_UNION_ENTRY)
- uint32_t reserved : (32 - CBI_SSFC_FIELDS_SIZE);
-#endif
- };
- uint32_t raw_value;
-};
-
-BUILD_ASSERT(sizeof(union cbi_ssfc) == sizeof(uint32_t),
- "CBI SSFS structure exceedes 32 bits");
-
-DT_INST_FOREACH_STATUS_OKAY(CBI_SSFC_VALUE_BUILD_ASSERT)
-
-static const uint8_t ssfc_values[] = {
- DT_INST_FOREACH_STATUS_OKAY(CBI_SSFC_VALUE_ARRAY)
-};
-static union cbi_ssfc cached_ssfc __attribute__((unused));
-
-/* CBI SSFC part end */
-
-/* Device config */
-struct cros_cbi_config {
- /* SSFC values for specific configs */
- const uint8_t *ssfc_values;
-};
-
-/* Device data */
-struct cros_cbi_data {
- /* Cached SSFC configs */
- union cbi_ssfc cached_ssfc;
-};
-
-/* CBI SSFC part */
-
-static void cros_cbi_ssfc_init(const struct device *dev)
-{
- struct cros_cbi_data *data = (struct cros_cbi_data *)(dev->data);
-
- if (cbi_get_ssfc(&data->cached_ssfc.raw_value) != EC_SUCCESS) {
- DT_INST_FOREACH_STATUS_OKAY(CBI_SSFC_INIT_DEFAULT)
- }
-
- LOG_INF("Read CBI SSFC : 0x%08X\n", data->cached_ssfc.raw_value);
-}
-
-static uint32_t cros_cbi_ssfc_get_parent_field_value(union cbi_ssfc cached_ssfc,
- enum cbi_ssfc_value_id value_id)
-{
- switch (value_id) {
- DT_INST_FOREACH_STATUS_OKAY(CBI_SSFC_PARENT_VALUE_CASE)
- default:
- LOG_ERR("CBI SSFC parent field value not found: %d\n",
- value_id);
- return 0;
- }
-}
-
-static int cros_cbi_ec_ssfc_check_match(const struct device *dev,
- enum cbi_ssfc_value_id value_id)
-{
- struct cros_cbi_data *data = (struct cros_cbi_data *)(dev->data);
- struct cros_cbi_config *cfg = (struct cros_cbi_config *)(dev->config);
-
- return cros_cbi_ssfc_get_parent_field_value(data->cached_ssfc,
- value_id) ==
- cfg->ssfc_values[value_id];
-}
-
-/* CBI SSFC part end */
-#undef DT_DRV_COMPAT
-
-static int cros_cbi_ec_init(const struct device *dev)
-{
- cros_cbi_ssfc_init(dev);
-
- return 0;
-}
-
-/* cros ec cbi driver registration */
-static const struct cros_cbi_driver_api cros_cbi_driver_api = {
- .init = cros_cbi_ec_init,
- .ssfc_check_match = cros_cbi_ec_ssfc_check_match,
-};
-
-static int cbi_init(const struct device *dev)
-{
- ARG_UNUSED(dev);
-
- return 0;
-}
-
-static const struct cros_cbi_config cros_cbi_cfg = {
- .ssfc_values = ssfc_values,
-};
-
-static struct cros_cbi_data cros_cbi_data;
-
-DEVICE_DEFINE(cros_cbi, CROS_CBI_LABEL, cbi_init, NULL, &cros_cbi_data,
- &cros_cbi_cfg, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
- &cros_cbi_driver_api);
diff --git a/zephyr/drivers/cros_flash/CMakeLists.txt b/zephyr/drivers/cros_flash/CMakeLists.txt
deleted file mode 100644
index 6611589ad4..0000000000
--- a/zephyr/drivers/cros_flash/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-
-zephyr_library_sources_ifdef(CONFIG_CROS_FLASH_IT8XXX2 cros_flash_it8xxx2.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_FLASH_NPCX cros_flash_npcx.c)
diff --git a/zephyr/drivers/cros_flash/Kconfig b/zephyr/drivers/cros_flash/Kconfig
deleted file mode 100644
index 1d100a6068..0000000000
--- a/zephyr/drivers/cros_flash/Kconfig
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2020 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.
-
-menuconfig CROS_FLASH_NPCX
- bool "Nuvoton NPCX flash driver for the Zephyr shim"
- depends on SOC_FAMILY_NPCX
- default y if FLASH_SIZE > 0
- help
- This option enables a flash unit interface (FIU) driver for the NPCX
- chip. This is used instead of the flash memory interface so we can
- continue to use most of the existing flash memory processing code in
- ECOS.
-
-config CROS_FLASH_IT8XXX2
- bool "ITE IT81202 flash driver for the Zephyr shim"
- depends on SOC_FAMILY_RISCV_ITE
- default y
- help
- This option enables the flash driver for the it8xxx2 chip. We can
- access the flash by read, write and erase. The it8xxx2 flash size
- is 1M byte.
diff --git a/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c b/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c
deleted file mode 100644
index f238b1557b..0000000000
--- a/zephyr/drivers/cros_flash/cros_flash_it8xxx2.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT ite_it8xxx2_cros_flash
-
-#include <drivers/cros_flash.h>
-#include <drivers/flash.h>
-#include <kernel.h>
-#include <logging/log.h>
-#include <soc.h>
-
-#include "flash.h"
-#include "host_command.h"
-#include "system.h"
-#include "watchdog.h"
-
-LOG_MODULE_REGISTER(cros_flash, LOG_LEVEL_ERR);
-
-/* Device data */
-struct cros_flash_it8xxx2_data {
- bool stuck_locked;
- bool inconsistent_locked;
- bool all_protected;
-};
-
-/* Driver convenience defines */
-#define DRV_DATA(dev) ((struct cros_flash_it8xxx2_data *)(dev)->data)
-
-#define FLASH_DEV_NAME DT_CHOSEN_ZEPHYR_FLASH_CONTROLLER_LABEL
-static const struct device *flash_controller;
-
-#define FWP_REG(bank) (bank / 8)
-#define FWP_MASK(bank) (1 << (bank % 8))
-
-enum flash_wp_interface {
- FLASH_WP_HOST = 0x01,
- FLASH_WP_DBGR = 0x02,
- FLASH_WP_EC = 0x04,
-};
-
-enum flash_wp_status {
- FLASH_WP_STATUS_PROTECT_RO = EC_FLASH_PROTECT_RO_NOW,
- FLASH_WP_STATUS_PROTECT_ALL = EC_FLASH_PROTECT_ALL_NOW,
-};
-
-/**
- * Protect flash banks until reboot.
- *
- * @param start_bank Start bank to protect
- * @param bank_count Number of banks to protect
- */
-static void flash_protect_banks(int start_bank, int bank_count,
- enum flash_wp_interface wp_if)
-{
- int bank;
-
- for (bank = start_bank; bank < start_bank + bank_count; bank++) {
- if (wp_if & FLASH_WP_EC)
- IT83XX_GCTRL_EWPR0PFEC(FWP_REG(bank)) |= FWP_MASK(bank);
- if (wp_if & FLASH_WP_HOST)
- IT83XX_GCTRL_EWPR0PFH(FWP_REG(bank)) |= FWP_MASK(bank);
- if (wp_if & FLASH_WP_DBGR)
- IT83XX_GCTRL_EWPR0PFD(FWP_REG(bank)) |= FWP_MASK(bank);
- }
-}
-
-static enum flash_wp_status flash_check_wp(void)
-{
- enum flash_wp_status wp_status;
- int all_bank_count, bank;
-
- all_bank_count = CONFIG_FLASH_SIZE_BYTES / CONFIG_FLASH_BANK_SIZE;
-
- for (bank = 0; bank < all_bank_count; bank++) {
- if (!(IT83XX_GCTRL_EWPR0PFEC(FWP_REG(bank)) & FWP_MASK(bank)))
- break;
- }
-
- if (bank == WP_BANK_COUNT)
- wp_status = FLASH_WP_STATUS_PROTECT_RO;
- else if (bank == (WP_BANK_COUNT + PSTATE_BANK_COUNT))
- wp_status = FLASH_WP_STATUS_PROTECT_RO;
- else if (bank == all_bank_count)
- wp_status = FLASH_WP_STATUS_PROTECT_ALL;
- else
- wp_status = 0;
-
- return wp_status;
-}
-
-/* cros ec flash api functions */
-static int cros_flash_it8xxx2_init(const struct device *dev)
-{
- struct cros_flash_it8xxx2_data *const data = DRV_DATA(dev);
- int32_t reset_flags, prot_flags, unwanted_prot_flags;
-
- reset_flags = system_get_reset_flags();
- prot_flags = crec_flash_get_protect();
- unwanted_prot_flags = EC_FLASH_PROTECT_ALL_NOW |
- EC_FLASH_PROTECT_ERROR_INCONSISTENT;
-
- /*
- * If we have already jumped between images, an earlier image could
- * have applied write protection. Nothing additional needs to be done.
- */
- if (reset_flags & EC_RESET_FLAG_SYSJUMP)
- return EC_SUCCESS;
-
- if (prot_flags & EC_FLASH_PROTECT_GPIO_ASSERTED) {
- /* Protect the entire flash of host interface */
- flash_protect_banks(0,
- CONFIG_FLASH_SIZE_BYTES / CONFIG_FLASH_BANK_SIZE,
- FLASH_WP_HOST);
- /* Protect the entire flash of DBGR interface */
- flash_protect_banks(0,
- CONFIG_FLASH_SIZE_BYTES / CONFIG_FLASH_BANK_SIZE,
- FLASH_WP_DBGR);
- /*
- * Write protect is asserted. If we want RO flash protected,
- * protect it now.
- */
- if ((prot_flags & EC_FLASH_PROTECT_RO_AT_BOOT) &&
- !(prot_flags & EC_FLASH_PROTECT_RO_NOW)) {
- int rv = crec_flash_set_protect(EC_FLASH_PROTECT_RO_NOW,
- EC_FLASH_PROTECT_RO_NOW);
- if (rv)
- return rv;
-
- /* Re-read flags */
- prot_flags = crec_flash_get_protect();
- }
- } else {
- /* Don't want RO flash protected */
- unwanted_prot_flags |= EC_FLASH_PROTECT_RO_NOW;
- }
-
- /* If there are no unwanted flags, done */
- if (!(prot_flags & unwanted_prot_flags))
- return EC_SUCCESS;
-
- /*
- * If the last reboot was a power-on reset, it should have cleared
- * write-protect. If it didn't, then the flash write protect registers
- * have been permanently committed and we can't fix that.
- */
- if (reset_flags & EC_RESET_FLAG_POWER_ON) {
- data->stuck_locked = 1;
- return EC_ERROR_ACCESS_DENIED;
- } else {
- /*
- * Set inconsistent flag, because there is no software
- * reset can clear write-protect.
- */
- data->inconsistent_locked = 1;
- return EC_ERROR_ACCESS_DENIED;
- }
-
- /* That doesn't return, so if we're still here that's an error */
- return EC_ERROR_UNKNOWN;
-}
-
-static int cros_flash_it8xxx2_read(const struct device *dev, int offset,
- int size, char *dst_data)
-{
- ARG_UNUSED(dev);
-
- return flash_read(flash_controller, offset, dst_data, size);
-}
-
-static int cros_flash_it8xxx2_write(const struct device *dev, int offset,
- int size, const char *src_data)
-{
- struct cros_flash_it8xxx2_data *const data = DRV_DATA(dev);
-
- if (data->all_protected) {
- return -EACCES;
- }
-
- /*
- * If AP sends write flash command continuously, EC might not have
- * chance to go back to hook task to touch watchdog. Reload watchdog
- * on each flash write to prevent the reset.
- */
- if (IS_ENABLED(CONFIG_PLATFORM_EC_WATCHDOG))
- watchdog_reload();
-
- return flash_write(flash_controller, offset, src_data, size);
-}
-
-static int cros_flash_it8xxx2_erase(const struct device *dev, int offset,
- int size)
-{
- struct cros_flash_it8xxx2_data *const data = DRV_DATA(dev);
- int ret = 0;
-
- if (data->all_protected) {
- return -EACCES;
- }
- /*
- * Before the flash erasing, the interrupts should be disabled. In
- * the flash erasing loop, the SHI interrupt should be enabled to
- * handle AP's command, so irq_lock() is not used here.
- */
- if (IS_ENABLED(CONFIG_ITE_IT8XXX2_INTC)) {
- ite_intc_save_and_disable_interrupts();
- }
- /*
- * EC still need to handle AP's EC_CMD_GET_COMMS_STATUS command
- * during erasing.
- */
- if (IS_ENABLED(HAS_TASK_HOSTCMD) &&
- IS_ENABLED(CONFIG_HOST_COMMAND_STATUS)) {
- irq_enable(DT_IRQN(DT_NODELABEL(shi)));
- }
- /* Always use sector erase command */
- for (; size > 0; size -= CONFIG_FLASH_ERASE_SIZE) {
- ret = flash_erase(flash_controller, offset,
- CONFIG_FLASH_ERASE_SIZE);
- if (ret)
- break;
-
- offset += CONFIG_FLASH_ERASE_SIZE;
- /*
- * If requested erase size is too large at one time on KGD
- * flash, we need to reload watchdog to prevent the reset.
- */
- if (IS_ENABLED(CONFIG_PLATFORM_EC_WATCHDOG) && (size > 0x10000))
- watchdog_reload();
- }
- /* Restore interrupts */
- if (IS_ENABLED(CONFIG_ITE_IT8XXX2_INTC)) {
- ite_intc_restore_interrupts();
- }
-
- return ret;
-}
-
-static int cros_flash_it8xxx2_get_protect(const struct device *dev, int bank)
-{
- ARG_UNUSED(dev);
-
- return IT83XX_GCTRL_EWPR0PFEC(FWP_REG(bank)) & FWP_MASK(bank);
-}
-
-static uint32_t cros_flash_it8xxx2_get_protect_flags(const struct device *dev)
-{
- struct cros_flash_it8xxx2_data *const data = DRV_DATA(dev);
- uint32_t flags = 0;
-
- flags |= flash_check_wp();
-
- if (data->all_protected)
- flags |= EC_FLASH_PROTECT_ALL_NOW;
-
- /* Check if blocks were stuck locked at pre-init */
- if (data->stuck_locked)
- flags |= EC_FLASH_PROTECT_ERROR_STUCK;
-
- /* Check if flash protection is in inconsistent state at pre-init */
- if (data->inconsistent_locked)
- flags |= EC_FLASH_PROTECT_ERROR_INCONSISTENT;
-
- return flags;
-}
-
-static int cros_flash_it8xxx2_protect_at_boot(const struct device *dev,
- uint32_t new_flags)
-{
- return -ENOTSUP;
-}
-
-static int cros_flash_it8xxx2_protect_now(const struct device *dev, int all)
-{
- struct cros_flash_it8xxx2_data *const data = DRV_DATA(dev);
-
- if (all) {
- /* Protect the entire flash */
- flash_protect_banks(0,
- CONFIG_FLASH_SIZE_BYTES / CONFIG_FLASH_BANK_SIZE,
- FLASH_WP_EC);
- data->all_protected = 1;
- } else {
- /* Protect the read-only section and persistent state */
- flash_protect_banks(WP_BANK_OFFSET,
- WP_BANK_COUNT, FLASH_WP_EC);
-#ifdef PSTATE_BANK
- flash_protect_banks(PSTATE_BANK,
- PSTATE_BANK_COUNT, FLASH_WP_EC);
-#endif
- }
-
- return EC_SUCCESS;
-}
-
-/* cros ec flash driver registration */
-static const struct cros_flash_driver_api cros_flash_it8xxx2_driver_api = {
- .init = cros_flash_it8xxx2_init,
- .physical_read = cros_flash_it8xxx2_read,
- .physical_write = cros_flash_it8xxx2_write,
- .physical_erase = cros_flash_it8xxx2_erase,
- .physical_get_protect = cros_flash_it8xxx2_get_protect,
- .physical_get_protect_flags = cros_flash_it8xxx2_get_protect_flags,
- .physical_protect_at_boot = cros_flash_it8xxx2_protect_at_boot,
- .physical_protect_now = cros_flash_it8xxx2_protect_now,
-};
-
-static int flash_it8xxx2_init(const struct device *dev)
-{
- ARG_UNUSED(dev);
-
- flash_controller = device_get_binding(FLASH_DEV_NAME);
- if (!flash_controller) {
- LOG_ERR("Fail to find %s", FLASH_DEV_NAME);
- return -ENODEV;
- }
-
- return 0;
-}
-
-static struct cros_flash_it8xxx2_data cros_flash_data;
-
-DEVICE_DEFINE(cros_flash_it8xxx2_0, DT_INST_LABEL(0), flash_it8xxx2_init, NULL,
- &cros_flash_data, NULL, PRE_KERNEL_1,
- CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
- &cros_flash_it8xxx2_driver_api);
diff --git a/zephyr/drivers/cros_flash/cros_flash_npcx.c b/zephyr/drivers/cros_flash/cros_flash_npcx.c
deleted file mode 100644
index bb1bd12d89..0000000000
--- a/zephyr/drivers/cros_flash/cros_flash_npcx.c
+++ /dev/null
@@ -1,821 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT nuvoton_npcx_cros_flash
-
-#include <dt-bindings/clock/npcx_clock.h>
-#include <drivers/cros_flash.h>
-#include <drivers/clock_control.h>
-#include <drivers/gpio.h>
-#include <kernel.h>
-#include <logging/log.h>
-#include <soc.h>
-#include <soc/nuvoton_npcx/reg_def_cros.h>
-#include <sys/__assert.h>
-#include "ec_tasks.h"
-#include "flash.h"
-#include "gpio.h"
-#include "soc_miwu.h"
-#include "spi_flash_reg.h"
-#include "task.h"
-#include "../drivers/flash/spi_nor.h"
-
-LOG_MODULE_REGISTER(cros_flash, LOG_LEVEL_ERR);
-
-static int all_protected; /* Has all-flash protection been requested? */
-static int addr_prot_start;
-static int addr_prot_length;
-static uint8_t flag_prot_inconsistent;
-static uint8_t saved_sr1;
-static uint8_t saved_sr2;
-
-#define CMD_READ_STATUS_REG 0x05
-#define CMD_READ_STATUS_REG2 0x35
-
-/* Device config */
-struct cros_flash_npcx_config {
- /* flash interface unit base address */
- uintptr_t base;
- /* clock configuration */
- struct npcx_clk_cfg clk_cfg;
- /* Flash size (Unit:bytes) */
- int size;
- /* pinmux configuration */
- const uint8_t alts_size;
- const struct npcx_alt *alts_list;
-};
-
-/* Device data */
-struct cros_flash_npcx_data {
- /* flag of flash write protection */
- bool write_protectied;
- /* mutex of flash interface controller */
- struct k_sem lock_sem;
-};
-
-/* TODO: Should we replace them with Kconfig variables */
-#define CONFIG_FLASH_WRITE_SIZE 0x1 /* minimum write size */
-#define CONFIG_FLASH_WRITE_IDEAL_SIZE 256 /* one page size for write */
-
-/* TODO: It should be defined in the spi_nor.h in the zephyr repository */
-#define SPI_NOR_CMD_FAST_READ 0x0B
-
-/* Driver convenience defines */
-#define DRV_CONFIG(dev) ((const struct cros_flash_npcx_config *)(dev)->config)
-#define DRV_DATA(dev) ((struct cros_flash_npcx_data *)(dev)->data)
-#define HAL_INSTANCE(dev) (struct fiu_reg *)(DRV_CONFIG(dev)->base)
-
-/* cros ec flash local inline functions */
-static inline void cros_flash_npcx_mutex_lock(const struct device *dev)
-{
- struct cros_flash_npcx_data *data = DRV_DATA(dev);
-
- k_sem_take(&data->lock_sem, K_FOREVER);
-}
-
-static inline void cros_flash_npcx_mutex_unlock(const struct device *dev)
-{
- struct cros_flash_npcx_data *data = DRV_DATA(dev);
-
- k_sem_give(&data->lock_sem);
-}
-
-static inline void cros_flash_npcx_set_address(const struct device *dev,
- uint32_t qspi_addr)
-{
- struct fiu_reg *const inst = HAL_INSTANCE(dev);
- uint8_t *addr = (uint8_t *)&qspi_addr;
-
- /* Write 3 bytes address to UMA registers */
- inst->UMA_AB2 = addr[2];
- inst->UMA_AB1 = addr[1];
- inst->UMA_AB0 = addr[0];
-}
-
-static inline void cros_flash_npcx_cs_level(const struct device *dev, int level)
-{
- struct fiu_reg *const inst = HAL_INSTANCE(dev);
-
- /* Set chip select to high/low level */
- if (level == 0)
- inst->UMA_ECTS &= ~BIT(NPCX_UMA_ECTS_SW_CS1);
- else
- inst->UMA_ECTS |= BIT(NPCX_UMA_ECTS_SW_CS1);
-}
-
-static inline void cros_flash_npcx_exec_cmd(const struct device *dev,
- uint8_t code, uint8_t cts)
-{
- struct fiu_reg *const inst = HAL_INSTANCE(dev);
-
-#ifdef CONFIG_ASSERT
- struct cros_flash_npcx_data *data = DRV_DATA(dev);
-
- /* Flash mutex must be held while executing UMA commands */
- __ASSERT((k_sem_count_get(&data->lock_sem) == 0), "UMA is not locked");
-#endif
-
- /* set UMA_CODE */
- inst->UMA_CODE = code;
- /* execute UMA flash transaction */
- inst->UMA_CTS = cts;
- while (IS_BIT_SET(inst->UMA_CTS, NPCX_UMA_CTS_EXEC_DONE))
- ;
-}
-
-static inline void cros_flash_npcx_burst_read(const struct device *dev,
- char *dst_data, int dst_size)
-{
- struct fiu_reg *const inst = HAL_INSTANCE(dev);
-
- /* Burst read transaction */
- for (int idx = 0; idx < dst_size; idx++) {
- /* 1101 0101 - EXEC, RD, NO CMD, NO ADDR, 4 bytes */
- inst->UMA_CTS = UMA_CODE_RD_BYTE(1);
- /* wait for UMA to complete */
- while (IS_BIT_SET(inst->UMA_CTS, NPCX_UMA_CTS_EXEC_DONE))
- ;
- /* Get read transaction results*/
- dst_data[idx] = inst->UMA_DB0;
- }
-}
-
-static inline int cros_flash_npcx_wait_busy_bit_clear(const struct device *dev)
-{
- struct fiu_reg *const inst = HAL_INSTANCE(dev);
- int wait_period = 10; /* 10 us period t0 check status register */
- int timeout = (10 * USEC_PER_SEC) / wait_period; /* 10 seconds */
-
- do {
- /* Read status register */
- inst->UMA_CTS = UMA_CODE_RD_BYTE(1);
- while (IS_BIT_SET(inst->UMA_CTS, NPCX_UMA_CTS_EXEC_DONE))
- ;
- /* Status bit is clear */
- if ((inst->UMA_DB0 & SPI_NOR_WIP_BIT) == 0)
- break;
- k_usleep(wait_period);
- } while (--timeout); /* Wait for busy bit clear */
-
- if (timeout) {
- return 0;
- } else {
- return -ETIMEDOUT;
- }
-}
-
-/* cros ec flash local functions */
-static int cros_flash_npcx_wait_ready(const struct device *dev)
-{
- int ret = 0;
-
- /* Drive CS to low */
- cros_flash_npcx_cs_level(dev, 0);
-
- /* Command for Read status register of flash */
- cros_flash_npcx_exec_cmd(dev, SPI_NOR_CMD_RDSR, UMA_CODE_CMD_ONLY);
- /* Wait busy bit is clear */
- ret = cros_flash_npcx_wait_busy_bit_clear(dev);
- /* Drive CS to low */
- cros_flash_npcx_cs_level(dev, 1);
-
- return ret;
-}
-
-static int cros_flash_npcx_set_write_enable(const struct device *dev)
-{
- struct fiu_reg *const inst = HAL_INSTANCE(dev);
- int ret;
-
- /* Wait for previous operation to complete */
- ret = cros_flash_npcx_wait_ready(dev);
- if (ret != 0)
- return ret;
-
- /* Write enable command */
- cros_flash_npcx_exec_cmd(dev, SPI_NOR_CMD_WREN, UMA_CODE_CMD_ONLY);
-
- /* Wait for flash is not busy */
- ret = cros_flash_npcx_wait_ready(dev);
- if (ret != 0)
- return ret;
-
- if ((inst->UMA_DB0 & SPI_NOR_WEL_BIT) != 0)
- return 0;
- else
- return -EINVAL;
-}
-
-static void cros_flash_npcx_burst_write(const struct device *dev,
- unsigned int dest_addr,
- unsigned int bytes,
- const char *src_data)
-{
- /* Chip Select down */
- cros_flash_npcx_cs_level(dev, 0);
-
- /* Set write address */
- cros_flash_npcx_set_address(dev, dest_addr);
- /* Start programming */
- cros_flash_npcx_exec_cmd(dev, SPI_NOR_CMD_PP, UMA_CODE_CMD_WR_ADR);
- for (int i = 0; i < bytes; i++) {
- cros_flash_npcx_exec_cmd(dev, *src_data, UMA_CODE_CMD_WR_ONLY);
- src_data++;
- }
-
- /* Chip Select up */
- cros_flash_npcx_cs_level(dev, 1);
-}
-
-static int cros_flash_npcx_program_bytes(const struct device *dev,
- uint32_t offset, uint32_t bytes,
- const uint8_t *src_data)
-{
- int write_size;
- int ret = 0;
-
- while (bytes > 0) {
- /* Write length can not go beyond the end of the flash page */
- write_size = MIN(bytes,
- CONFIG_FLASH_WRITE_IDEAL_SIZE -
- (offset &
- (CONFIG_FLASH_WRITE_IDEAL_SIZE - 1)));
-
- /* Enable write */
- ret = cros_flash_npcx_set_write_enable(dev);
- if (ret != 0)
- return ret;
-
- /* Executr UMA burst write transaction */
- cros_flash_npcx_burst_write(dev, offset, write_size, src_data);
-
- /* Wait write completed */
- ret = cros_flash_npcx_wait_ready(dev);
- if (ret != 0)
- return ret;
-
- src_data += write_size;
- offset += write_size;
- bytes -= write_size;
- }
-
- return ret;
-}
-
-static int cros_flash_npcx_get_status_reg(const struct device *dev,
- char cmd_code, char *data)
-{
- int ret = 0;
- struct fiu_reg *const inst = HAL_INSTANCE(dev);
-
- if (data == 0) {
- return -EINVAL;
- }
-
- /* Lock flash interface device during reading status register */
- cros_flash_npcx_mutex_lock(dev);
-
- cros_flash_npcx_exec_cmd(dev, cmd_code, UMA_CODE_CMD_RD_BYTE(1));
- *data = inst->UMA_DB0;
- /* Unlock flash interface device */
- cros_flash_npcx_mutex_unlock(dev);
-
- return ret;
-}
-
-static int cros_flash_npcx_set_status_reg(const struct device *dev, char *data)
-{
- int ret = 0;
- struct fiu_reg *const inst = HAL_INSTANCE(dev);
-
- /* Lock flash interface device */
- cros_flash_npcx_mutex_lock(dev);
- /* Enable write */
- ret = cros_flash_npcx_set_write_enable(dev);
- if (ret != 0)
- return ret;
-
- inst->UMA_DB0 = data[0];
- inst->UMA_DB1 = data[1];
- /* Write status register 1/2 */
- cros_flash_npcx_exec_cmd(dev, SPI_NOR_CMD_WRSR,
- UMA_CODE_CMD_WR_BYTE(2));
- /* Unlock flash interface device */
- cros_flash_npcx_mutex_unlock(dev);
-
- return ret;
-}
-
-static int cros_flash_npcx_write_protection_set(const struct device *dev,
- bool enable)
-{
- int ret = 0;
-
- /* Write protection can be cleared only by core domain reset */
- if (!enable) {
- LOG_ERR("WP can be disabled only via core domain reset ");
- return -ENOTSUP;
- }
- /* Lock flash interface device */
- cros_flash_npcx_mutex_lock(dev);
- ret = npcx_pinctrl_flash_write_protect_set();
- /* Unlock flash interface device */
- cros_flash_npcx_mutex_unlock(dev);
-
- return ret;
-}
-
-static int cros_flash_npcx_write_protection_is_set(const struct device *dev)
-{
- return npcx_pinctrl_flash_write_protect_is_set();
-}
-
-static int cros_flash_npcx_uma_lock(const struct device *dev, bool enable)
-{
- struct fiu_reg *const inst = HAL_INSTANCE(dev);
-
- if (enable) {
- inst->UMA_ECTS |= BIT(NPCX_UMA_ECTS_UMA_LOCK);
- } else {
- inst->UMA_ECTS &= ~BIT(NPCX_UMA_ECTS_UMA_LOCK);
- }
-
- return 0;
-}
-
-static int flash_get_status1(const struct device *dev)
-{
- uint8_t reg;
-
- if (all_protected)
- return saved_sr1;
-
- /* Lock physical flash operations */
- crec_flash_lock_mapped_storage(1);
-
- cros_flash_npcx_get_status_reg(dev, CMD_READ_STATUS_REG, &reg);
-
- /* Unlock physical flash operations */
- crec_flash_lock_mapped_storage(0);
-
- return reg;
-}
-
-static int flash_get_status2(const struct device *dev)
-{
- uint8_t reg;
-
- if (all_protected)
- return saved_sr1;
-
- /* Lock physical flash operations */
- crec_flash_lock_mapped_storage(1);
-
- cros_flash_npcx_get_status_reg(dev, CMD_READ_STATUS_REG2, &reg);
-
- /* Unlock physical flash operations */
- crec_flash_lock_mapped_storage(0);
-
- return reg;
-}
-
-static int flash_write_status_reg(const struct device *dev, uint8_t *data)
-{
- return cros_flash_npcx_set_status_reg(dev, data);
-}
-
-static int is_int_flash_protected(const struct device *dev)
-{
- return cros_flash_npcx_write_protection_is_set(dev);
-}
-
-static void flash_protect_int_flash(const struct device *dev, int enable)
-{
- /*
- * Please notice the type of WP_IF bit is R/W1S. Once it's set,
- * only rebooting EC can clear it.
- */
- if (enable)
- cros_flash_npcx_write_protection_set(dev, enable);
-}
-
-static void flash_uma_lock(const struct device *dev, int enable)
-{
- if (enable && !all_protected) {
- /*
- * Store SR1 / SR2 for later use since we're about to lock
- * out all access (including read access) to these regs.
- */
- saved_sr1 = flash_get_status1(dev);
- saved_sr2 = flash_get_status2(dev);
- }
-
- cros_flash_npcx_uma_lock(dev, enable);
- all_protected = enable;
-}
-
-static int flash_set_status_for_prot(const struct device *dev, int reg1,
- int reg2)
-{
- uint8_t regs[2];
-
- /*
- * Writing SR regs will fail if our UMA lock is enabled. If WP
- * is deasserted then remove the lock and allow the write.
- */
- if (all_protected) {
- if (is_int_flash_protected(dev))
- return EC_ERROR_ACCESS_DENIED;
-
- if (crec_flash_get_protect() & EC_FLASH_PROTECT_GPIO_ASSERTED)
- return EC_ERROR_ACCESS_DENIED;
- flash_uma_lock(dev, 0);
- }
-
- /*
- * If WP# is active and ec doesn't protect the status registers of
- * internal spi-flash, protect it now before setting them.
- */
-#ifdef CONFIG_WP_ACTIVE_HIGH
- flash_protect_int_flash(dev, gpio_get_level(GPIO_WP));
-#else
- flash_protect_int_flash(dev, !gpio_get_level(GPIO_WP_L));
-#endif /*_CONFIG_WP_ACTIVE_HIGH_*/
-
- /* Lock physical flash operations */
- crec_flash_lock_mapped_storage(1);
-
- regs[0] = reg1;
- regs[1] = reg2;
- flash_write_status_reg(dev, regs);
-
- /* Unlock physical flash operations */
- crec_flash_lock_mapped_storage(0);
-
- spi_flash_reg_to_protect(reg1, reg2, &addr_prot_start,
- &addr_prot_length);
-
- return EC_SUCCESS;
-}
-
-static int flash_check_prot_reg(const struct device *dev, unsigned int offset,
- unsigned int bytes)
-{
- unsigned int start;
- unsigned int len;
- uint8_t sr1, sr2;
- int rv = EC_SUCCESS;
-
- /*
- * If WP# is active and ec doesn't protect the status registers of
- * internal spi-flash, protect it now.
- */
-#ifdef CONFIG_WP_ACTIVE_HIGH
- flash_protect_int_flash(dev, gpio_get_level(GPIO_WP));
-#else
- flash_protect_int_flash(dev, !gpio_get_level(GPIO_WP_L));
-#endif /* CONFIG_WP_ACTIVE_HIGH */
-
- sr1 = flash_get_status1(dev);
- sr2 = flash_get_status2(dev);
-
- /* Invalid value */
- if (offset + bytes > CONFIG_FLASH_SIZE_BYTES)
- return EC_ERROR_INVAL;
-
- /* Compute current protect range */
- rv = spi_flash_reg_to_protect(sr1, sr2, &start, &len);
- if (rv)
- return rv;
-
- /* Check if ranges overlap */
- if (MAX(start, offset) < MIN(start + len, offset + bytes))
- return EC_ERROR_ACCESS_DENIED;
-
- return EC_SUCCESS;
-}
-
-static int flash_write_prot_reg(const struct device *dev, unsigned int offset,
- unsigned int bytes, int hw_protect)
-{
- int rv;
- uint8_t sr1 = flash_get_status1(dev);
- uint8_t sr2 = flash_get_status2(dev);
-
- /* Invalid values */
- if (offset + bytes > CONFIG_FLASH_SIZE_BYTES)
- return EC_ERROR_INVAL;
-
- /* Compute desired protect range */
- rv = spi_flash_protect_to_reg(offset, bytes, &sr1, &sr2);
- if (rv)
- return rv;
-
- if (hw_protect)
- sr1 |= SPI_FLASH_SR1_SRP0;
-
- return flash_set_status_for_prot(dev, sr1, sr2);
-}
-
-static int flash_check_prot_range(unsigned int offset, unsigned int bytes)
-{
- /* Invalid value */
- if (offset + bytes > CONFIG_FLASH_SIZE_BYTES)
- return EC_ERROR_INVAL;
-
- /* Check if ranges overlap */
- if (MAX(addr_prot_start, offset) <
- MIN(addr_prot_start + addr_prot_length, offset + bytes))
- return EC_ERROR_ACCESS_DENIED;
-
- return EC_SUCCESS;
-}
-
-/* cros ec flash api functions */
-static int cros_flash_npcx_init(const struct device *dev)
-{
- const struct cros_flash_npcx_config *const config = DRV_CONFIG(dev);
- struct cros_flash_npcx_data *data = DRV_DATA(dev);
-
- /* initialize mutux for flash interface controller */
- k_sem_init(&data->lock_sem, 1, 1);
-
- /* Configure pin-mux for FIU device */
- npcx_pinctrl_mux_configure(config->alts_list, config->alts_size, 1);
-
- /*
- * Protect status registers of internal spi-flash if WP# is active
- * during ec initialization.
- */
-#ifdef CONFIG_WP_ACTIVE_HIGH
- flash_protect_int_flash(dev, gpio_get_level(GPIO_WP));
-#else
- flash_protect_int_flash(dev, !gpio_get_level(GPIO_WP_L));
-#endif /*CONFIG_WP_ACTIVE_HIGH */
-
- /* Initialize UMA to unlocked */
- flash_uma_lock(dev, 0);
-
- return 0;
-}
-
-static int cros_flash_npcx_read(const struct device *dev, int offset, int size,
- char *dst_data)
-{
- int ret = 0;
-
- /* Unlock flash interface device during reading flash */
- cros_flash_npcx_mutex_lock(dev);
-
- /* Chip Select down */
- cros_flash_npcx_cs_level(dev, 0);
-
- /* Set read address */
- cros_flash_npcx_set_address(dev, offset);
- /* Start with fast read command (skip one dummy byte) */
- cros_flash_npcx_exec_cmd(dev, SPI_NOR_CMD_FAST_READ,
- UMA_CODE_CMD_ADR_WR_BYTE(1));
- /* Execute burst read */
- cros_flash_npcx_burst_read(dev, dst_data, size);
-
- /* Chip Select up */
- cros_flash_npcx_cs_level(dev, 1);
-
- /* Unlock flash interface device */
- cros_flash_npcx_mutex_unlock(dev);
-
- return ret;
-}
-
-static int cros_flash_npcx_write(const struct device *dev, int offset, int size,
- const char *src_data)
-{
- struct cros_flash_npcx_data *const data = DRV_DATA(dev);
- int ret = 0;
-
- /* check protection */
- if (all_protected)
- return EC_ERROR_ACCESS_DENIED;
-
- /* check protection */
- if (flash_check_prot_range(offset, size))
- return EC_ERROR_ACCESS_DENIED;
-
- /* Is write protection enabled? */
- if (data->write_protectied) {
- return -EACCES;
- }
-
- /* Invalid data pointer? */
- if (src_data == 0) {
- return -EINVAL;
- }
-
- /* Unlock flash interface device during writing flash */
- cros_flash_npcx_mutex_lock(dev);
-
- while (size > 0) {
- /* First write multiples of 256, then (size % 256) last */
- int write_len =
- ((size % CONFIG_FLASH_WRITE_IDEAL_SIZE) == size) ?
- size :
- CONFIG_FLASH_WRITE_IDEAL_SIZE;
-
- ret = cros_flash_npcx_program_bytes(dev, offset, write_len,
- src_data);
- if (ret != 0)
- break;
-
- src_data += write_len;
- offset += write_len;
- size -= write_len;
- }
-
- /* Unlock flash interface device */
- cros_flash_npcx_mutex_unlock(dev);
-
- return ret;
-}
-
-static int cros_flash_npcx_erase(const struct device *dev, int offset, int size)
-{
- const struct cros_flash_npcx_config *const config = DRV_CONFIG(dev);
- struct cros_flash_npcx_data *const data = DRV_DATA(dev);
- int ret = 0;
-
- /* check protection */
- if (all_protected)
- return EC_ERROR_ACCESS_DENIED;
-
- /* check protection */
- if (flash_check_prot_range(offset, size))
- return EC_ERROR_ACCESS_DENIED;
-
- /* Is write protection enabled? */
- if (data->write_protectied) {
- return -EACCES;
- }
- /* affected region should be within device */
- if (offset < 0 || (offset + size) > config->size) {
- LOG_ERR("Flash erase address or size exceeds expected values. "
- "Addr: 0x%lx size %zu",
- (long)offset, size);
- return -EINVAL;
- }
-
- /* address must be aligned to erase size */
- if ((offset % CONFIG_FLASH_ERASE_SIZE) != 0) {
- return -EINVAL;
- }
-
- /* Erase size must be a non-zero multiple of sectors */
- if ((size == 0) || (size % CONFIG_FLASH_ERASE_SIZE) != 0) {
- return -EINVAL;
- }
-
- /* Unlock flash interface device during erasing flash */
- cros_flash_npcx_mutex_lock(dev);
-
- /* Alignment has been checked in upper layer */
- for (; size > 0; size -= CONFIG_FLASH_ERASE_SIZE,
- offset += CONFIG_FLASH_ERASE_SIZE) {
-
- /* Enable write */
- ret = cros_flash_npcx_set_write_enable(dev);
- if (ret != 0)
- break;
-
- /* Set erase address */
- cros_flash_npcx_set_address(dev, offset);
- /* Start erasing */
- cros_flash_npcx_exec_cmd(dev, SPI_NOR_CMD_BE, UMA_CODE_CMD_ADR);
-
- /* Wait erase completed */
- ret = cros_flash_npcx_wait_ready(dev);
- if (ret != 0) {
- break;
- }
- }
-
- /* Unlock flash interface device */
- cros_flash_npcx_mutex_unlock(dev);
-
- return ret;
-}
-
-static int cros_flash_npcx_get_protect(const struct device *dev, int bank)
-{
- uint32_t addr = bank * CONFIG_FLASH_BANK_SIZE;
-
- return flash_check_prot_reg(dev, addr, CONFIG_FLASH_BANK_SIZE);
-}
-
-static uint32_t cros_flash_npcx_get_protect_flags(const struct device *dev)
-{
- uint32_t flags = 0;
-
- /* Check if WP region is protected in status register */
- if (flash_check_prot_reg(dev, WP_BANK_OFFSET * CONFIG_FLASH_BANK_SIZE,
- WP_BANK_COUNT * CONFIG_FLASH_BANK_SIZE))
- flags |= EC_FLASH_PROTECT_RO_AT_BOOT;
-
- /*
- * TODO: If status register protects a range, but SRP0 is not set,
- * flags should indicate EC_FLASH_PROTECT_ERROR_INCONSISTENT.
- */
- if (flag_prot_inconsistent)
- flags |= EC_FLASH_PROTECT_ERROR_INCONSISTENT;
-
- /* Read all-protected state from our shadow copy */
- if (all_protected)
- flags |= EC_FLASH_PROTECT_ALL_NOW;
-
- return flags;
-}
-
-static int cros_flash_npcx_protect_at_boot(const struct device *dev,
- uint32_t new_flags)
-{
- int ret;
-
- if ((new_flags & (EC_FLASH_PROTECT_RO_AT_BOOT |
- EC_FLASH_PROTECT_ALL_AT_BOOT)) == 0) {
- /* Clear protection bits in status register */
- return flash_set_status_for_prot(dev, 0, 0);
- }
-
- ret = flash_write_prot_reg(dev, CONFIG_WP_STORAGE_OFF,
- CONFIG_WP_STORAGE_SIZE, 1);
-
- /*
- * Set UMA_LOCK bit for locking all UMA transaction.
- * But we still can read directly from flash mapping address
- */
- if (new_flags & EC_FLASH_PROTECT_ALL_AT_BOOT)
- flash_uma_lock(dev, 1);
-
- return ret;
-}
-
-static int cros_flash_npcx_protect_now(const struct device *dev, int all)
-{
- if (all) {
- /*
- * Set UMA_LOCK bit for locking all UMA transaction.
- * But we still can read directly from flash mapping address
- */
- flash_uma_lock(dev, 1);
- } else {
- /* TODO: Implement RO "now" protection */
- }
-
- return EC_SUCCESS;
-}
-
-/* cros ec flash driver registration */
-static const struct cros_flash_driver_api cros_flash_npcx_driver_api = {
- .init = cros_flash_npcx_init,
- .physical_read = cros_flash_npcx_read,
- .physical_write = cros_flash_npcx_write,
- .physical_erase = cros_flash_npcx_erase,
- .physical_get_protect = cros_flash_npcx_get_protect,
- .physical_get_protect_flags = cros_flash_npcx_get_protect_flags,
- .physical_protect_at_boot = cros_flash_npcx_protect_at_boot,
- .physical_protect_now = cros_flash_npcx_protect_now,
-};
-
-static int flash_npcx_init(const struct device *dev)
-{
- const struct cros_flash_npcx_config *const config = DRV_CONFIG(dev);
- const struct device *clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
-
- int ret;
-
- /* Turn on device clock first and get source clock freq. */
- ret = clock_control_on(clk_dev,
- (clock_control_subsys_t *)&config->clk_cfg);
- if (ret < 0) {
- LOG_ERR("Turn on FIU clock fail %d", ret);
- return ret;
- }
-
- return ret;
-}
-
-static const struct npcx_alt cros_flash_alts[] = NPCX_DT_ALT_ITEMS_LIST(0);
-static const struct cros_flash_npcx_config cros_flash_cfg = {
- .base = DT_INST_REG_ADDR(0),
- .clk_cfg = NPCX_DT_CLK_CFG_ITEM(0),
- .size = DT_INST_PROP(0, size),
- .alts_size = ARRAY_SIZE(cros_flash_alts),
- .alts_list = cros_flash_alts,
-};
-
-static struct cros_flash_npcx_data cros_flash_data;
-
-DEVICE_DT_INST_DEFINE(0, flash_npcx_init, NULL, &cros_flash_data,
- &cros_flash_cfg, PRE_KERNEL_1,
- CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
- &cros_flash_npcx_driver_api);
diff --git a/zephyr/drivers/cros_kb_raw/CMakeLists.txt b/zephyr/drivers/cros_kb_raw/CMakeLists.txt
deleted file mode 100644
index a9ef2b4bb2..0000000000
--- a/zephyr/drivers/cros_kb_raw/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-# SPDX-License-Identifier: Apache-2.0
-
-zephyr_library_sources_ifdef(CONFIG_CROS_KB_RAW_NPCX cros_kb_raw_npcx.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_KB_RAW_ITE cros_kb_raw_ite.c)
diff --git a/zephyr/drivers/cros_kb_raw/Kconfig b/zephyr/drivers/cros_kb_raw/Kconfig
deleted file mode 100644
index a037cdd451..0000000000
--- a/zephyr/drivers/cros_kb_raw/Kconfig
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-menuconfig CROS_KB_RAW_NPCX
- bool "Nuvoton NPCX raw-keyboard-scan driver for the Zephyr shim"
- depends on SOC_FAMILY_NPCX
- default y
- help
- This option enables a driver for providing raw access to the
- keyboard-scan peripheral in the chip. This is used instead of the
- kscan interface so we can continue to use most of the existing
- keyboard-scanning code in ECOS.
-
-if CROS_KB_RAW_NPCX
-
-config CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE
- bool "Enable quasi-bidirectional buffers for KSO pins"
- help
- This option enables quasi-bidirectional buffers for KSO pins. The
- low-impedance high drive is active when ec changes the output data
- buffers from 0 to 1, thereby reducing the low-to-high transition time.
-
-endif # CROS_KB_RAW_NPCX
-
-menuconfig CROS_KB_RAW_ITE
- bool "ITE raw-keyboard-scan driver for the Zephyr shim"
- depends on SOC_FAMILY_RISCV_ITE
- default y
- help
- This option enables a driver for providing raw access to the
- keyboard-scan peripheral in the chip. This is used instead of the
- kscan interface so we can continue to use most of the existing
- keyboard-scanning code in ECOS.
diff --git a/zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c b/zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c
deleted file mode 100644
index 85b2a1a8ee..0000000000
--- a/zephyr/drivers/cros_kb_raw/cros_kb_raw_ite.c
+++ /dev/null
@@ -1,187 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT ite_it8xxx2_cros_kb_raw
-
-#include <assert.h>
-#include <drivers/cros_kb_raw.h>
-#include <drivers/clock_control.h>
-#include <drivers/gpio.h>
-#include <kernel.h>
-#include <soc.h>
-#include <soc/ite_it8xxx2/reg_def_cros.h>
-
-#include "ec_tasks.h"
-#include "keyboard_raw.h"
-#include "task.h"
-
-#include <logging/log.h>
-LOG_MODULE_REGISTER(cros_kb_raw, LOG_LEVEL_ERR);
-
-#define KSOH_PIN_MASK (((1 << (KEYBOARD_COLS_MAX - 8)) - 1) & 0xff)
-
-/* Device config */
-struct cros_kb_raw_ite_config {
- /* keyboard scan controller base address */
- uintptr_t base;
- /* Keyboard scan input (KSI) wake-up irq */
- int irq;
-};
-
-/* Driver convenience defines */
-#define DRV_CONFIG(dev) ((const struct cros_kb_raw_ite_config *)(dev)->config)
-#define HAL_INSTANCE(dev) (struct kbs_reg *)(DRV_CONFIG(dev)->base)
-
-static int kb_raw_ite_init(const struct device *dev)
-{
- ARG_UNUSED(dev);
-
- /* Clock default is on */
- return 0;
-}
-
-/* Cros ec keyboard raw api functions */
-static int cros_kb_raw_ite_enable_interrupt(const struct device *dev,
- int enable)
-{
- const struct cros_kb_raw_ite_config *const config = DRV_CONFIG(dev);
-
- if (enable) {
- ECREG(IT8XXX2_WUC_WUESR3) = 0xFF;
- ite_intc_isr_clear(config->irq);
- irq_enable(config->irq);
- } else {
- irq_disable(config->irq);
- }
-
- return 0;
-}
-
-static int cros_kb_raw_ite_read_row(const struct device *dev)
-{
- struct kbs_reg *const inst = HAL_INSTANCE(dev);
-
- /* Bits are active-low, so invert returned levels */
- return ((inst->KBS_KSI) ^ 0xff);
-}
-
-static int cros_kb_raw_ite_drive_column(const struct device *dev, int col)
-{
- int mask;
- unsigned int key;
- struct kbs_reg *const inst = HAL_INSTANCE(dev);
-
- /* Tri-state all outputs */
- if (col == KEYBOARD_COLUMN_NONE)
- mask = 0xffff;
- /* Assert all outputs */
- else if (col == KEYBOARD_COLUMN_ALL)
- mask = 0;
- /* Assert a single output */
- else
- mask = 0xffff ^ BIT(col);
-#ifdef CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED
- /* KSO[2] is inverted. */
- mask ^= BIT(2);
-#endif
- inst->KBS_KSOL = mask & 0xff;
- /* critical section with interrupts off */
- key = irq_lock();
- /*
- * Because IT8XXX2_KBS_KSOH1 register is shared by keyboard scan
- * out and GPIO output mode, so we don't drive all KSOH pins
- * here (this depends on how many keyboard matrix output pin
- * we are using).
- */
- inst->KBS_KSOH1 = ((inst->KBS_KSOH1) & ~KSOH_PIN_MASK) |
- ((mask >> 8) & KSOH_PIN_MASK);
- /* restore interrupts */
- irq_unlock(key);
-
- return 0;
-}
-
-static void cros_kb_raw_ite_ksi_isr(const struct device *dev)
-{
- ARG_UNUSED(dev);
-
- /*
- * We clear IT8XXX2_IRQ_WKINTC irq status in
- * ite_intc_irq_handler(), after interrupt was fired.
- */
- /* W/C wakeup interrupt status for KSI[0-7] */
- ECREG(IT8XXX2_WUC_WUESR3) = 0xFF;
-
- /* Wake-up keyboard scan task */
- task_wake(TASK_ID_KEYSCAN);
-}
-
-static int cros_kb_raw_ite_init(const struct device *dev)
-{
- unsigned int key;
- const struct cros_kb_raw_ite_config *const config = DRV_CONFIG(dev);
- struct kbs_reg *const inst = HAL_INSTANCE(dev);
-
- /* Ensure top-level interrupt is disabled */
- cros_kb_raw_ite_enable_interrupt(dev, 0);
-
- /*
- * bit2, Setting 1 enables the internal pull-up of the KSO[15:0] pins.
- * To pull up KSO[17:16], set the GPCR registers of their
- * corresponding GPIO ports.
- * bit0, Setting 1 enables the open-drain mode of the KSO[17:0] pins.
- */
- inst->KBS_KSOCTRL = (IT8XXX2_KBS_KSOPU | IT8XXX2_KBS_KSOOD);
- /* bit2, 1 enables the internal pull-up of the KSI[7:0] pins. */
- inst->KBS_KSICTRL = IT8XXX2_KBS_KSIPU;
-#ifdef CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED
- /* KSO[2] output high, others output low. */
- inst->KBS_KSOL = BIT(2);
- /* Enable KSO2's push-pull */
- inst->KBS_KSOLGCTRL |= IT8XXX2_KBS_KSO2GCTRL;
- inst->KBS_KSOLGOEN |= IT8XXX2_KBS_KSO2GOEN;
-#else
- /* KSO[7:0] pins output low. */
- inst->KBS_KSOL = 0x00;
-#endif
- /* critical section with interrupts off */
- key = irq_lock();
- /*
- * KSO[COLS_MAX:8] pins low.
- * NOTE: KSO[15:8] pins can part be enabled for keyboard function and
- * rest be configured as GPIO output mode. In this case that we
- * disable the ISR in critical section to avoid race condition.
- */
- inst->KBS_KSOH1 &= ~KSOH_PIN_MASK;
- /* restore interrupts */
- irq_unlock(key);
- /* Select falling-edge triggered of wakeup interrupt for KSI[0-7] */
- ECREG(IT8XXX2_WUC_WUEMR3) = 0xFF;
- /* W/C wakeup interrupt status for KSI[0-7] */
- ECREG(IT8XXX2_WUC_WUESR3) = 0xFF;
- ite_intc_isr_clear(config->irq);
- /* Enable wakeup interrupt for KSI[0-7] */
- ECREG(IT8XXX2_WUC_WUENR3) = 0xFF;
-
- IRQ_CONNECT(DT_INST_IRQN(0), 0, cros_kb_raw_ite_ksi_isr, NULL, 0);
-
- return 0;
-}
-
-static const struct cros_kb_raw_driver_api cros_kb_raw_ite_driver_api = {
- .init = cros_kb_raw_ite_init,
- .drive_colum = cros_kb_raw_ite_drive_column,
- .read_rows = cros_kb_raw_ite_read_row,
- .enable_interrupt = cros_kb_raw_ite_enable_interrupt,
-};
-
-static const struct cros_kb_raw_ite_config cros_kb_raw_cfg = {
- .base = DT_INST_REG_ADDR(0),
- .irq = DT_INST_IRQN(0),
-};
-
-DEVICE_DT_INST_DEFINE(0, kb_raw_ite_init, NULL, NULL, &cros_kb_raw_cfg,
- PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
- &cros_kb_raw_ite_driver_api);
diff --git a/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c b/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c
deleted file mode 100644
index 00965b74ca..0000000000
--- a/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT nuvoton_npcx_cros_kb_raw
-
-#include <assert.h>
-#include <dt-bindings/clock/npcx_clock.h>
-#include <drivers/cros_kb_raw.h>
-#include <drivers/clock_control.h>
-#include <drivers/gpio.h>
-#include <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 <logging/log.h>
-LOG_MODULE_REGISTER(cros_kb_raw, LOG_LEVEL_ERR);
-
-#define NPCX_MAX_KEY_COLS 18 /* Maximum rows of keyboard matrix */
-#define NPCX_MAX_KEY_ROWS 8 /* Maximum columns of keyboard matrix */
-#define NPCX_KB_ROW_MASK (BIT(NPCX_MAX_KEY_ROWS) - 1)
-
-/* Device config */
-struct cros_kb_raw_npcx_config {
- /* keyboard scan controller base address */
- uintptr_t base;
- /* clock configuration */
- struct npcx_clk_cfg clk_cfg;
- /* pinmux configuration */
- const uint8_t alts_size;
- const struct npcx_alt *alts_list;
- /* Keyboard scan input (KSI) wake-up irq */
- int irq;
- /* Size of keyboard inputs-wui mapping array */
- int wui_size;
- /* Mapping table between keyboard inputs and wui */
- struct npcx_wui wui_maps[];
-};
-
-/* Driver convenience defines */
-#define DRV_CONFIG(dev) ((const struct cros_kb_raw_npcx_config *)(dev)->config)
-#define HAL_INSTANCE(dev) (struct kbs_reg *)(DRV_CONFIG(dev)->base)
-
-/* Keyboard Scan local functions */
-static struct miwu_dev_callback ksi_callback[NPCX_MAX_KEY_ROWS];
-
-static void kb_raw_npcx_init_ksi_wui_callback(
- const struct device *dev, struct miwu_dev_callback *callback,
- const struct npcx_wui *wui, miwu_dev_callback_handler_t handler)
-{
- /* KSI signal which has no wake-up input source */
- if (wui->table == NPCX_MIWU_TABLE_NONE)
- return;
-
- /* Install callback function */
- npcx_miwu_init_dev_callback(callback, wui, handler, dev);
- npcx_miwu_manage_dev_callback(callback, 1);
-
- /* Configure MIWU setting and enable its interrupt */
- npcx_miwu_interrupt_configure(wui, NPCX_MIWU_MODE_EDGE,
- NPCX_MIWU_TRIG_BOTH);
- npcx_miwu_irq_enable(wui);
-}
-
-static int kb_raw_npcx_init(const struct device *dev)
-{
- const struct cros_kb_raw_npcx_config *const config = DRV_CONFIG(dev);
- const struct device *clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
- int ret;
-
- /* Turn on device clock first and get source clock freq. */
- ret = clock_control_on(clk_dev,
- (clock_control_subsys_t *)&config->clk_cfg);
- if (ret < 0) {
- LOG_ERR("Turn on KSCAN clock fail %d", ret);
- return ret;
- }
-
- return 0;
-}
-
-/* Cros ec keyboard raw api functions */
-static int cros_kb_raw_npcx_enable_interrupt(const struct device *dev,
- int enable)
-{
- const struct cros_kb_raw_npcx_config *const config = DRV_CONFIG(dev);
-
- if (enable)
- irq_enable(config->irq);
- else
- irq_disable(config->irq);
-
- return 0;
-}
-
-static int cros_kb_raw_npcx_read_row(const struct device *dev)
-{
- struct kbs_reg *const inst = HAL_INSTANCE(dev);
- int val;
-
- val = inst->KBSIN;
- LOG_DBG("rows raw %02x", val);
-
- /* 1 means key pressed, otherwise means key released. */
- return (~val & NPCX_KB_ROW_MASK);
-}
-
-static int cros_kb_raw_npcx_drive_column(const struct device *dev, int col)
-{
- struct kbs_reg *const inst = HAL_INSTANCE(dev);
-
- /*
- * Nuvoton 'Keyboard Scan' module supports 18x8 matrix
- * It also support automatic scan functionality.
- */
- uint32_t mask, col_out;
-
- /* Add support for CONFIG_KEYBOARD_KSO_BASE shifting */
- col_out = col + CONFIG_KEYBOARD_KSO_BASE;
-
- /* Drive all lines to high. ie. Key detection is disabled. */
- if (col == KEYBOARD_COLUMN_NONE) {
- mask = ~0;
- if (IS_ENABLED(CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED)) {
- gpio_set_level(GPIO_KBD_KSO2, 0);
- }
- }
- /* Drive all lines to low for detection any key press */
- else if (col == KEYBOARD_COLUMN_ALL) {
- mask = ~(BIT(keyboard_cols) - 1);
- if (IS_ENABLED(CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED)) {
- gpio_set_level(GPIO_KBD_KSO2, 1);
- }
- }
- /* Drive one line to low for determining which key's state changed. */
- else {
- if (IS_ENABLED(CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED)) {
- if (col == 2)
- gpio_set_level(GPIO_KBD_KSO2, 1);
- else
- gpio_set_level(GPIO_KBD_KSO2, 0);
- }
- mask = ~BIT(col_out);
- }
-
- /* Set KBSOUT */
- inst->KBSOUT0 = (mask & 0xFFFF);
- inst->KBSOUT1 = ((mask >> 16) & 0x03);
-
- return 0;
-}
-
-static void cros_kb_raw_npcx_ksi_isr(const struct device *dev,
- struct npcx_wui *wui)
-{
- ARG_UNUSED(dev);
- ARG_UNUSED(wui);
-
- LOG_DBG("%s: KSI%d is changed", __func__, wui->bit);
- /* Wake-up keyboard scan task */
- task_wake(TASK_ID_KEYSCAN);
-}
-
-static int cros_kb_raw_npcx_init(const struct device *dev)
-{
- const struct cros_kb_raw_npcx_config *const config = DRV_CONFIG(dev);
- struct kbs_reg *const inst = HAL_INSTANCE(dev);
-
- /* Pull-up KBSIN0-7 internally */
- inst->KBSINPU = 0xFF;
-
- /*
- * Keyboard Scan Control Register
- *
- * [6:7] - KBHDRV KBSOUTn signals output buffers are open-drain.
- * [3] - KBSINC Auto-increment of Buffer Data register is disabled
- * [2] - KBSIEN Interrupt of Auto-Scan is disabled
- * [1] - KBSMODE Key detection mechanism is implemented by firmware
- * [0] - START Write 0 to this field is not affected
- */
- inst->KBSCTL = 0x00;
-
- /*
- * Select quasi-bidirectional buffers for KSO pins. It reduces the
- * low-to-high transition time. This feature only supports in npcx7.
- */
- if (IS_ENABLED(CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE)) {
- SET_FIELD(inst->KBSCTL, NPCX_KBSCTL_KBHDRV_FIELD, 0x01);
- }
-
- /* Configure pin-mux for kscan device */
- npcx_pinctrl_mux_configure(config->alts_list, config->alts_size, 1);
-
- /* Drive all column lines to low for detection any key press */
- cros_kb_raw_npcx_drive_column(dev, KEYBOARD_COLUMN_ALL);
-
- /* Configure wake-up input and callback for keyboard input signal */
- for (int i = 0; i < ARRAY_SIZE(ksi_callback); i++)
- kb_raw_npcx_init_ksi_wui_callback(dev, &ksi_callback[i],
- &config->wui_maps[i],
- cros_kb_raw_npcx_ksi_isr);
-
- return 0;
-}
-
-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,
-};
-
-static const struct npcx_alt cros_kb_raw_alts[] = NPCX_DT_ALT_ITEMS_LIST(0);
-
-static const struct cros_kb_raw_npcx_config cros_kb_raw_cfg = {
- .base = DT_INST_REG_ADDR(0),
- .alts_size = ARRAY_SIZE(cros_kb_raw_alts),
- .alts_list = cros_kb_raw_alts,
- .clk_cfg = NPCX_DT_CLK_CFG_ITEM(0),
- .irq = DT_INST_IRQN(0),
- .wui_size = NPCX_DT_WUI_ITEMS_LEN(0),
- .wui_maps = NPCX_DT_WUI_ITEMS_LIST(0),
-};
-
-/* Verify there's exactly 1 enabled cros,kb-raw-npcx node. */
-BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1);
-DEVICE_DT_INST_DEFINE(0, kb_raw_npcx_init, NULL, NULL, &cros_kb_raw_cfg,
- PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
- &cros_kb_raw_npcx_driver_api);
-
-/* KBS register structure check */
-NPCX_REG_SIZE_CHECK(kbs_reg, 0x010);
-NPCX_REG_OFFSET_CHECK(kbs_reg, KBSIN, 0x004);
-NPCX_REG_OFFSET_CHECK(kbs_reg, KBSOUT0, 0x006);
-NPCX_REG_OFFSET_CHECK(kbs_reg, KBS_BUF_INDX, 0x00a);
diff --git a/zephyr/drivers/cros_rtc/CMakeLists.txt b/zephyr/drivers/cros_rtc/CMakeLists.txt
deleted file mode 100644
index f6ce9b6890..0000000000
--- a/zephyr/drivers/cros_rtc/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-zephyr_library_sources_ifdef(CONFIG_CROS_RTC_NPCX cros_rtc_npcx.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_RTC_NXP_PCF85063A
- nxp_rtc_pcf85063a.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_RTC_RENESAS_IDT1337AG
- renesas_rtc_idt1337ag.c)
diff --git a/zephyr/drivers/cros_rtc/Kconfig b/zephyr/drivers/cros_rtc/Kconfig
deleted file mode 100644
index 9abe8e27e0..0000000000
--- a/zephyr/drivers/cros_rtc/Kconfig
+++ /dev/null
@@ -1,36 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC_RTC
-
-choice CROS_RTC_TYPE
- prompt "Select the RTC to use"
- default CROS_RTC_NPCX if SOC_FAMILY_NPCX
- help
- Select the RTC used on the board.
-
-config CROS_RTC_NPCX
- bool "Nuvoton NPCX Real-Time Clock (RTC) driver for the Zephyr shim"
- depends on SOC_FAMILY_NPCX
- help
- This option enables a driver for providing the support of Real-Time
- Clock (RTC) on the NPCX chip.
-
-config CROS_RTC_NXP_PCF85063A
- bool "NXP PCF85063A Real-Time Clock (RTC) driver for the Zephyr shim"
- depends on PLATFORM_EC_I2C
- help
- This option enables a driver for providing the support of NXP
- Real-Time Clock (RTC) on the the I2C bus.
-
-config CROS_RTC_RENESAS_IDT1337AG
- bool "RENESAS IDT1337AG Real-Time Clock (RTC) driver for the Zephyr shim"
- depends on PLATFORM_EC_I2C
- help
- This option enables a driver for providing the support of RENESAS
- Real-Time Clock (RTC) on the the I2C bus.
-
-endchoice # RTC Select
-
-endif # PLATFORM_EC_RTC
diff --git a/zephyr/drivers/cros_rtc/cros_rtc_npcx.c b/zephyr/drivers/cros_rtc/cros_rtc_npcx.c
deleted file mode 100644
index 0ecbe5f47c..0000000000
--- a/zephyr/drivers/cros_rtc/cros_rtc_npcx.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright 2021 Google LLC
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-#define DT_DRV_COMPAT nuvoton_npcx_cros_mtc
-
-#include <assert.h>
-#include <drivers/cros_rtc.h>
-#include <drivers/gpio.h>
-#include <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 <logging/log.h>
-LOG_MODULE_REGISTER(cros_rtc, LOG_LEVEL_ERR);
-
-#define NPCX_MTC_TTC_LOAD_DELAY_US 250 /* Delay after writing TTC */
-#define NPCX_MTC_ALARM_MASK GENMASK(24, 0) /* Valid field of alarm in WTC */
-
-/* Driver config */
-struct cros_rtc_npcx_config {
- /* Monotonic counter base address */
- uintptr_t base;
- /* Monotonic counter wake-up input source configuration */
- const struct npcx_wui mtc_alarm;
-};
-
-/* Driver data */
-struct cros_rtc_npcx_data {
- /* Monotonic counter wake-up callback object */
- struct miwu_dev_callback miwu_mtc_cb;
- cros_rtc_alarm_callback_t alarm_callback;
-};
-
-/* Driver convenience defines */
-#define DRV_CONFIG(dev) ((const struct cros_rtc_npcx_config *)(dev)->config)
-
-#define DRV_DATA(dev) ((struct cros_rtc_npcx_data *)(dev)->data)
-
-#define HAL_INSTANCE(dev) (struct mtc_reg *)(DRV_CONFIG(dev)->base)
-
-/* Counter internal local functions */
-static uint32_t counter_npcx_get_val(const struct device *dev)
-{
- struct mtc_reg *const inst = HAL_INSTANCE(dev);
-
- /*
- * Get value of monotonic counter which keeps counting when VCC1 power
- * domain exists (Unit:sec)
- */
- return inst->TTC;
-}
-
-static void counter_npcx_set_val(const struct device *dev, uint32_t val)
-{
- struct mtc_reg *const inst = HAL_INSTANCE(dev);
-
- /*
- * Set monotonic counter. Write it twice to ensure the value latch to
- * TTC register. A delay (~250 us) is also needed before writing again.
- */
- inst->TTC = val;
- k_busy_wait(NPCX_MTC_TTC_LOAD_DELAY_US);
-
- inst->TTC = val;
- k_busy_wait(NPCX_MTC_TTC_LOAD_DELAY_US);
-}
-
-static uint32_t counter_npcx_get_alarm_val(const struct device *dev)
-{
- struct mtc_reg *const inst = HAL_INSTANCE(dev);
-
- /*
- * If alarm is not set or it is set and has already gone off, return
- * zero directly.
- */
- if (!IS_BIT_SET(inst->WTC, NPCX_WTC_WIE) ||
- IS_BIT_SET(inst->WTC, NPCX_WTC_PTO)) {
- return 0;
- }
-
- /* Return 25-bit alarm value */
- return inst->WTC & NPCX_MTC_ALARM_MASK;
-}
-
-static void counter_npcx_set_alarm_val(const struct device *dev, uint32_t val)
-{
- struct mtc_reg *const inst = HAL_INSTANCE(dev);
-
- /* Disable alarm interrupt */
- inst->WTC &= ~BIT(NPCX_WTC_WIE);
-
- /* Set new alarm value */
- inst->WTC = val & NPCX_MTC_ALARM_MASK;
-
- /* Enable alarm interrupt */
- inst->WTC |= BIT(NPCX_WTC_WIE);
-}
-
-static void counter_npcx_reset_alarm(const struct device *dev)
-{
- struct mtc_reg *const inst = HAL_INSTANCE(dev);
-
- /* Disable alarm interrupt first */
- if (IS_BIT_SET(inst->WTC, NPCX_WTC_WIE)) {
- inst->WTC &= ~BIT(NPCX_WTC_WIE);
- }
-
- /* Set alarm to maximum value and clear its pending bit */
- if (IS_BIT_SET(inst->WTC, NPCX_WTC_PTO)) {
- inst->WTC = NPCX_MTC_ALARM_MASK;
- inst->WTC |= BIT(NPCX_WTC_PTO);
- }
-}
-
-/* Counter local functions */
-static void counter_npcx_isr(const struct device *dev, struct npcx_wui *wui)
-{
- struct cros_rtc_npcx_data *data = DRV_DATA(dev);
-
- LOG_DBG("%s", __func__);
-
- /* Alarm is one-shot, so reset alarm to default */
- counter_npcx_reset_alarm(dev);
-
- /* Call callback function */
- if (data->alarm_callback) {
- data->alarm_callback(dev);
- }
-}
-
-/* cros ec RTC api functions */
-static int cros_rtc_npcx_configure(const struct device *dev,
- cros_rtc_alarm_callback_t callback)
-{
- struct cros_rtc_npcx_data *data = DRV_DATA(dev);
-
- if (callback == NULL) {
- return -EINVAL;
- }
-
- data->alarm_callback = callback;
- return 0;
-}
-
-static int cros_rtc_npcx_get_value(const struct device *dev, uint32_t *value)
-{
- *value = counter_npcx_get_val(dev);
-
- return 0;
-}
-
-static int cros_rtc_npcx_set_value(const struct device *dev, uint32_t value)
-{
- counter_npcx_set_val(dev, value);
-
- return 0;
-}
-static int cros_rtc_npcx_get_alarm(const struct device *dev, uint32_t *seconds,
- uint32_t *microseconds)
-{
- *seconds = counter_npcx_get_alarm_val(dev);
- *microseconds = 0;
-
- return 0;
-}
-static int cros_rtc_npcx_set_alarm(const struct device *dev, uint32_t seconds,
- uint32_t microseconds)
-{
- const struct cros_rtc_npcx_config *config = DRV_CONFIG(dev);
- ARG_UNUSED(microseconds);
-
- /* Enable interrupt of the MTC alarm wake-up input source */
- npcx_miwu_irq_enable(&config->mtc_alarm);
-
- /* Make sure alarm restore to default state */
- counter_npcx_reset_alarm(dev);
- counter_npcx_set_alarm_val(dev, seconds);
-
- return 0;
-}
-
-static int cros_rtc_npcx_reset_alarm(const struct device *dev)
-{
- const struct cros_rtc_npcx_config *config = DRV_CONFIG(dev);
-
- /* Disable interrupt of the MTC alarm wake-up input source */
- npcx_miwu_irq_disable(&config->mtc_alarm);
-
- counter_npcx_reset_alarm(dev);
-
- return 0;
-}
-
-/* cros ec RTC driver registration */
-static const struct cros_rtc_driver_api cros_rtc_npcx_driver_api = {
- .configure = cros_rtc_npcx_configure,
- .get_value = cros_rtc_npcx_get_value,
- .set_value = cros_rtc_npcx_set_value,
- .get_alarm = cros_rtc_npcx_get_alarm,
- .set_alarm = cros_rtc_npcx_set_alarm,
- .reset_alarm = cros_rtc_npcx_reset_alarm,
-};
-
-static int cros_rtc_npcx_init(const struct device *dev)
-{
- const struct cros_rtc_npcx_config *config = DRV_CONFIG(dev);
- struct cros_rtc_npcx_data *data = DRV_DATA(dev);
-
- /* Initialize the miwu input and its callback for monotonic counter */
- npcx_miwu_init_dev_callback(&data->miwu_mtc_cb, &config->mtc_alarm,
- counter_npcx_isr, dev);
- npcx_miwu_manage_dev_callback(&data->miwu_mtc_cb, true);
-
- /*
- * Configure the monotonic counter wake-up event triggered from a rising
- * edge on its signal.
- */
- npcx_miwu_interrupt_configure(&config->mtc_alarm, NPCX_MIWU_MODE_EDGE,
- NPCX_MIWU_TRIG_HIGH);
-
- return 0;
-}
-
-static const struct cros_rtc_npcx_config cros_rtc_npcx_cfg_0 = {
- .base = DT_INST_REG_ADDR(0),
- .mtc_alarm = NPCX_DT_WUI_ITEM_BY_NAME(0, mtc_alarm)
-};
-
-static struct cros_rtc_npcx_data cros_rtc_npcx_data_0;
-
-DEVICE_DT_INST_DEFINE(0, cros_rtc_npcx_init, /* pm_control_fn= */ NULL,
- &cros_rtc_npcx_data_0, &cros_rtc_npcx_cfg_0, POST_KERNEL,
- CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
- &cros_rtc_npcx_driver_api);
diff --git a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c
deleted file mode 100644
index 94632947c6..0000000000
--- a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT nxp_rtc_pcf85063a
-
-#include <assert.h>
-#include <device.h>
-#include <drivers/cros_rtc.h>
-#include <drivers/gpio.h>
-#include <drivers/i2c.h>
-#include <kernel.h>
-#include <rtc.h>
-#include <soc.h>
-
-#include "nxp_rtc_pcf85063a.h"
-
-#include <logging/log.h>
-LOG_MODULE_REGISTER(cros_rtc, LOG_LEVEL_ERR);
-
-/* Driver config */
-struct nxp_rtc_pcf85063a_config {
- const struct device *bus;
- const uint16_t i2c_addr_flags;
- const struct gpio_dt_spec gpio_alert;
-};
-
-/* Driver data */
-struct nxp_rtc_pcf85063a_data {
- const struct device *dev;
- uint8_t time_reg[NUM_TIMER_REGS];
- struct gpio_callback gpio_cb;
- cros_rtc_alarm_callback_t alarm_callback;
-};
-
-/* Driver convenience defines */
-#define DRV_CONFIG(dev) ((const struct nxp_rtc_pcf85063a_config *)(dev)->config)
-#define DRV_DATA(dev) ((struct nxp_rtc_pcf85063a_data *)(dev)->data)
-
-/*
- * is_alarm == true: Reads alarm registers SECONDS, MINUTES, HOURS, and DAYS
- * is_alarm == false: Reads time registers SECONDS, MINUTES, HOURS, DAYS, and
- * MONTHS, YEARS
- */
-static int pcf85063a_read_time_regs(const struct device *dev, bool is_alarm)
-{
- const struct nxp_rtc_pcf85063a_config *const config = DRV_CONFIG(dev);
- struct nxp_rtc_pcf85063a_data *data = DRV_DATA(dev);
- uint8_t start_reg;
- uint8_t num_reg;
-
- if (is_alarm) {
- start_reg = REG_SECOND_ALARM;
- num_reg = NUM_ALARM_REGS;
- } else {
- start_reg = REG_SECONDS;
- num_reg = NUM_TIMER_REGS;
- }
-
- return i2c_burst_read(config->bus,
- config->i2c_addr_flags, start_reg, data->time_reg, num_reg);
-}
-
-static int pcf85063a_read_reg(const struct device *dev,
- uint8_t reg, uint8_t *val)
-{
- const struct nxp_rtc_pcf85063a_config *const config = DRV_CONFIG(dev);
-
- return i2c_reg_read_byte(config->bus, config->i2c_addr_flags, reg, val);
-}
-
-/*
- * is_alarm == true: Writes alarm registers SECONDS, MINUTES, HOURS, and DAYS
- * is_alarm == false: Writes time registers SECONDS, MINUTES, HOURS, DAYS, and
- * MONTHS, YEARS
- */
-static int pcf85063a_write_time_regs(const struct device *dev, bool is_alarm)
-{
- const struct nxp_rtc_pcf85063a_config *const config = DRV_CONFIG(dev);
- struct nxp_rtc_pcf85063a_data *data = DRV_DATA(dev);
- uint8_t tx_buf[NUM_TIMER_REGS];
- uint8_t start_reg;
- uint8_t num_reg;
-
- if (is_alarm) {
- start_reg = REG_SECOND_ALARM;
- num_reg = NUM_ALARM_REGS;
- } else {
- start_reg = REG_SECONDS;
- num_reg = NUM_TIMER_REGS;
- }
-
- for (int i = 0; i < num_reg; i++) {
- tx_buf[i] = data->time_reg[i];
- }
-
- return i2c_burst_write(config->bus,
- config->i2c_addr_flags, start_reg, tx_buf, num_reg);
-}
-
-
-static int pcf85063a_write_reg(const struct device *dev,
- uint8_t reg, uint8_t val)
-{
- const struct nxp_rtc_pcf85063a_config *const config = DRV_CONFIG(dev);
- uint8_t tx_buf[2];
-
- tx_buf[0] = reg;
- tx_buf[1] = val;
-
- return i2c_write(config->bus,
- tx_buf, sizeof(tx_buf), config->i2c_addr_flags);
-}
-
-/*
- * val bits 7 to 4 - tens place
- * val bits 3 to 0 - ones place
- */
-static int bcd_to_dec(uint8_t val, enum bcd_mask mask)
-{
- int tens = ((val & mask) >> 4) * 10;
- int ones = (val & 0xf);
-
- return tens + ones;
-}
-
-/*
- * val bits 7 to 4 - tens place
- * val bits 3 to 0 - ones place
- */
-static uint8_t dec_to_bcd(uint32_t val, enum bcd_mask mask)
-{
- int tens = val / 10;
- int ones = val - (tens * 10);
-
- return ((tens << 4) & mask) | ones;
-}
-
-static int nxp_rtc_pcf85063a_read_seconds(const struct device *dev,
- uint32_t *value, bool is_alarm)
-{
- struct nxp_rtc_pcf85063a_data *data = DRV_DATA(dev);
- struct calendar_date time;
- int ret;
-
- ret = pcf85063a_read_time_regs(dev, is_alarm);
-
- if (ret < 0) {
- return ret;
- }
-
- if (is_alarm) {
- *value = (bcd_to_dec(data->time_reg[DAYS], DAYS_MASK) *
- SECS_PER_DAY) +
- (bcd_to_dec(data->time_reg[HOURS], HOURS24_MASK) *
- SECS_PER_HOUR) +
- (bcd_to_dec(data->time_reg[MINUTES], MINUTES_MASK) *
- SECS_PER_MINUTE) +
- bcd_to_dec(data->time_reg[SECONDS], SECONDS_MASK);
- } else {
- time.year = bcd_to_dec(data->time_reg[YEARS], YEARS_MASK);
- time.month =
- bcd_to_dec(data->time_reg[MONTHS], MONTHS_MASK);
- time.day = bcd_to_dec(data->time_reg[DAYS], DAYS_MASK);
-
- *value = date_to_sec(time) - SECS_TILL_YEAR_2K +
- (bcd_to_dec(data->time_reg[HOURS], HOURS24_MASK) *
- SECS_PER_HOUR) +
- (bcd_to_dec(data->time_reg[MINUTES], MINUTES_MASK) *
- SECS_PER_MINUTE) +
- bcd_to_dec(data->time_reg[SECONDS], SECONDS_MASK);
- }
-
- return ret;
-}
-
-static int nxp_rtc_pcf85063a_write_seconds(const struct device *dev,
- uint32_t value, bool is_alarm)
-{
- struct nxp_rtc_pcf85063a_data *data = DRV_DATA(dev);
- struct calendar_date time;
- uint32_t tmp_sec;
-
- time = sec_to_date(value + SECS_TILL_YEAR_2K);
-
- if (!is_alarm) {
- data->time_reg[YEARS] = dec_to_bcd(time.year, YEARS_MASK);
- data->time_reg[MONTHS] =
- dec_to_bcd(time.month, MONTHS_MASK);
- }
-
- data->time_reg[DAYS] = dec_to_bcd(time.day, DAYS_MASK);
-
- if (is_alarm && data->time_reg[DAYS] == 0) {
- data->time_reg[DAYS] |= DISABLE_ALARM;
- }
-
- value %= SECS_PER_DAY;
- tmp_sec = value / SECS_PER_HOUR;
- data->time_reg[HOURS] = dec_to_bcd(tmp_sec, HOURS24_MASK);
-
- if (is_alarm && data->time_reg[HOURS] == 0) {
- data->time_reg[HOURS] |= DISABLE_ALARM;
- }
-
- value -= (tmp_sec * SECS_PER_HOUR);
- tmp_sec = value / SECS_PER_MINUTE;
- data->time_reg[MINUTES] = dec_to_bcd(tmp_sec, MINUTES_MASK);
-
- if (is_alarm && data->time_reg[MINUTES] == 0) {
- data->time_reg[MINUTES] |= DISABLE_ALARM;
- }
-
- value -= (tmp_sec * SECS_PER_MINUTE);
- data->time_reg[SECONDS] = dec_to_bcd(value, SECONDS_MASK);
-
- if (is_alarm && data->time_reg[SECONDS] == 0) {
- data->time_reg[SECONDS] |= DISABLE_ALARM;
- }
-
- return pcf85063a_write_time_regs(dev, is_alarm);
-}
-
-static int nxp_rtc_pcf85063a_configure(const struct device *dev,
- cros_rtc_alarm_callback_t callback)
-{
- struct nxp_rtc_pcf85063a_data *data = DRV_DATA(dev);
-
- if (callback == NULL) {
- return -EINVAL;
- }
-
- data->alarm_callback = callback;
-
- return 0;
-}
-
-static int nxp_rtc_pcf85063a_get_value(const struct device *dev,
- uint32_t *value)
-{
- return nxp_rtc_pcf85063a_read_seconds(dev, value, false);
-}
-
-static int nxp_rtc_pcf85063a_set_value(const struct device *dev, uint32_t value)
-{
- return nxp_rtc_pcf85063a_write_seconds(dev, value, false);
-}
-
-static int nxp_rtc_pcf85063a_get_alarm(const struct device *dev,
- uint32_t *seconds, uint32_t *microseconds)
-{
- *microseconds = 0;
- return nxp_rtc_pcf85063a_read_seconds(dev, seconds, true);
-}
-
-static int nxp_rtc_pcf85063a_reset_alarm(const struct device *dev)
-{
- struct nxp_rtc_pcf85063a_data *data = DRV_DATA(dev);
- int ret;
-
- /* Disable alarm interrupt and clear pending alarm flag */
- ret = pcf85063a_write_reg(dev, REG_CONTROL_2, 0);
- if (ret < 0) {
- return ret;
- }
-
- /* Clear and disable the alarm registers */
- data->time_reg[SECONDS] = DISABLE_ALARM;
- data->time_reg[MINUTES] = DISABLE_ALARM;
- data->time_reg[HOURS] = DISABLE_ALARM;
- data->time_reg[DAYS] = DISABLE_ALARM;
-
- return pcf85063a_write_time_regs(dev, true);
-}
-
-static int nxp_rtc_pcf85063a_set_alarm(const struct device *dev,
- uint32_t seconds, uint32_t microseconds)
-{
- int ret;
-
- ARG_UNUSED(microseconds);
-
- ret = nxp_rtc_pcf85063a_reset_alarm(dev);
-
- if (ret < 0) {
- return ret;
- }
-
- ret = nxp_rtc_pcf85063a_write_seconds(dev, seconds, true);
-
- if (ret < 0) {
- return ret;
- }
-
- return pcf85063a_write_reg(dev, REG_CONTROL_2, ENABLE_ALARM_INTERRUPT);
-}
-
-static void nxp_pcf85063a_isr(const struct device *port,
- struct gpio_callback *cb, uint32_t pin)
-{
- struct nxp_rtc_pcf85063a_data *data =
- CONTAINER_OF(cb, struct nxp_rtc_pcf85063a_data, gpio_cb);
- const struct device *dev = (const struct device *)data->dev;
-
- ARG_UNUSED(port);
- ARG_UNUSED(pin);
- ARG_UNUSED(cb);
-
- LOG_DBG("%s", __func__);
-
- /* Call callback function */
- if (data->alarm_callback) {
- data->alarm_callback(dev);
- }
-}
-
-static const struct cros_rtc_driver_api nxp_rtc_pcf85063a_driver_api = {
- .configure = nxp_rtc_pcf85063a_configure,
- .get_value = nxp_rtc_pcf85063a_get_value,
- .set_value = nxp_rtc_pcf85063a_set_value,
- .get_alarm = nxp_rtc_pcf85063a_get_alarm,
- .set_alarm = nxp_rtc_pcf85063a_set_alarm,
- .reset_alarm = nxp_rtc_pcf85063a_reset_alarm,
-};
-
-static int nxp_rtc_pcf85063a_init(const struct device *dev)
-{
- const struct nxp_rtc_pcf85063a_config *const config = DRV_CONFIG(dev);
- struct nxp_rtc_pcf85063a_data *data = DRV_DATA(dev);
- uint8_t val;
- int ret;
-
- if (!device_is_ready(config->bus)) {
- LOG_ERR("Device %s is not ready", config->bus->name);
- return -ENODEV;
- }
-
- /*
- * Read Control_1 register. For normal operation,
- * the values should be as follows:
- * Bit 7 (external clock test mode) : (0) normal mode
- * Bit 6 (unused) : (0)
- * Bit 5 (STOP bit) : (0) RTC clock runs
- * BIT 4 (software reset) : (0) no software reset
- * BIT 3 (unused) : (0)
- * BIT 2 (correction interrupt enable) : (0) no correction
- * interrupt generated
- * BIT 1 (12 or 24-hour mode) : (0) 24-hour mode
- * BIT 0 (internal oscillator capacitor: (0) 7pF
- */
- ret = pcf85063a_read_reg(dev, REG_CONTROL_1, &val);
-
- if (ret < 0) {
- return ret;
- }
-
- if (val != CONTROL_1_DEFAULT_VALUE) {
- /* PCF85063A is not initialized, so send soft reset */
- ret = pcf85063a_write_reg(dev, REG_CONTROL_1, SOFT_RESET);
-
- if (ret < 0) {
- return ret;
- }
- }
-
- /*
- * Read Seconds register and check if oscillator is stopped.
- * If so, clear the bit.
- */
- ret = pcf85063a_read_reg(dev, REG_SECONDS, &val);
-
- if (ret < 0) {
- return ret;
- }
-
- if (val & OS_BIT) {
- /* Oscillator stop bit is set, clear it. */
- val &= ~OS_BIT;
- ret = pcf85063a_write_reg(dev, REG_SECONDS, val);
-
- if (ret < 0) {
- return ret;
- }
- }
-
- nxp_rtc_pcf85063a_reset_alarm(dev);
-
- /* Configure GPIO interrupt pin for PCF85063A alarm pin */
-
- if (!device_is_ready(config->gpio_alert.port)) {
- LOG_ERR("Alert GPIO device not ready");
- return -ENODEV;
- }
-
- ret = gpio_pin_configure_dt(&config->gpio_alert, GPIO_INPUT);
-
- if (ret < 0) {
- LOG_ERR("Could not configure RTC alert pin");
- return ret;
- }
-
- gpio_init_callback(&data->gpio_cb,
- nxp_pcf85063a_isr, BIT(config->gpio_alert.pin));
-
- ret = gpio_add_callback(config->gpio_alert.port, &data->gpio_cb);
-
- if (ret < 0) {
- LOG_ERR("Could not set RTC alert pin callback");
- return ret;
- }
-
- data->dev = dev;
-
- return gpio_pin_interrupt_configure_dt(&config->gpio_alert,
- GPIO_INT_EDGE_FALLING);
-}
-
-#define PCF85063A_INT_GPIOS \
- DT_PHANDLE_BY_IDX(DT_NODELABEL(pcf85063a), int_gpios, 0)
-
-/*
- * dt_flags is a uint8_t type. However, for platform/ec
- * the GPIO flags in the devicetree are expanded past 8 bits
- * to support the INPUT/OUTPUT and PULLUP/PULLDOWN properties.
- * Cast back to a gpio_dt_flags to compile, discarding the bits
- * that are not supported by the Zephyr GPIO API.
- */
-#define CROS_EC_GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, idx) \
- { \
- .port = \
- DEVICE_DT_GET(DT_GPIO_CTLR_BY_IDX(node_id, prop, idx)), \
- .pin = DT_GPIO_PIN_BY_IDX(node_id, prop, idx), \
- .dt_flags = \
- (gpio_dt_flags_t)DT_GPIO_FLAGS_BY_IDX(node_id, prop, idx), \
- }
-
-static const struct nxp_rtc_pcf85063a_config nxp_rtc_pcf85063a_cfg_0 = {
- .bus = DEVICE_DT_GET(DT_INST_BUS(0)),
- .i2c_addr_flags = DT_INST_REG_ADDR(0),
- .gpio_alert =
- CROS_EC_GPIO_DT_SPEC_GET_BY_IDX(PCF85063A_INT_GPIOS, gpios, 0)
-};
-
-static struct nxp_rtc_pcf85063a_data nxp_rtc_pcf85063a_data_0;
-
-DEVICE_DT_INST_DEFINE(0, nxp_rtc_pcf85063a_init, /* pm_control_fn= */ NULL,
- &nxp_rtc_pcf85063a_data_0, &nxp_rtc_pcf85063a_cfg_0,
- POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
- &nxp_rtc_pcf85063a_driver_api);
diff --git a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h b/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h
deleted file mode 100644
index dc4fcd24fc..0000000000
--- a/zephyr/drivers/cros_rtc/nxp_rtc_pcf85063a.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_RTC_PCF85063A_H
-#define __CROS_EC_RTC_PCF85063A_H
-
-#define PCF85063A_REG_NUM 18
-#define SOFT_RESET 0x58
-#define CONTROL_1_DEFAULT_VALUE 0
-#define OS_BIT 0x80
-#define DISABLE_ALARM 0x80
-#define ENABLE_ALARM_INTERRUPT 0x80
-#define RTC_STOP_CLOCKS 0x20
-#define RTC_START_CLOCKS 0x00
-
-#define NUM_TIMER_REGS 7
-#define NUM_ALARM_REGS 4
-
-#define REG_CONTROL_1 0x00
-#define REG_CONTROL_2 0x01
-#define REG_OFFSET 0x02
-#define REG_RAM_BYTE 0x03
-#define REG_SECONDS 0x04
-#define REG_MINUTES 0x05
-#define REG_HOURS 0x06
-#define REG_DAYS 0x07
-#define REG_WEEKDAYS 0x08
-#define REG_MONTHS 0x09
-#define REG_YEARS 0x0a
-#define REG_SECOND_ALARM 0x0b
-#define REG_MINUTE_ALARM 0x0c
-#define REG_HOUR_ALARM 0x0d
-#define REG_DAY_ALARM 0x0e
-#define REG_WEEKDAY_ALARM 0x0f
-#define REG_TIMER_VALUE 0x10
-#define REG_TIMER_MODE 0x11
-
-/* Macros for indexing time_reg buffer */
-#define SECONDS 0
-#define MINUTES 1
-#define HOURS 2
-#define DAYS 3
-#define WEEKDAYS 4
-#define MONTHS 5
-#define YEARS 6
-
-enum bcd_mask {
- SECONDS_MASK = 0x70,
- MINUTES_MASK = 0x70,
- HOURS24_MASK = 0x30,
- DAYS_MASK = 0x30,
- MONTHS_MASK = 0x10,
- YEARS_MASK = 0xf0
-};
-
-#endif /* __CROS_EC_RTC_PCF85063A_H */
diff --git a/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c b/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c
deleted file mode 100644
index bbe76f5286..0000000000
--- a/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.c
+++ /dev/null
@@ -1,480 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT renesas_rtc_idt1337ag
-
-#include <assert.h>
-#include <device.h>
-#include <drivers/cros_rtc.h>
-#include <drivers/gpio.h>
-#include <drivers/i2c.h>
-#include <kernel.h>
-#include <rtc.h>
-#include <soc.h>
-
-#include "renesas_rtc_idt1337ag.h"
-
-#include <logging/log.h>
-LOG_MODULE_REGISTER(cros_rtc, LOG_LEVEL_ERR);
-
-/* Driver config */
-struct renesas_rtc_idt1337ag_config {
- const struct device *bus;
- const uint16_t i2c_addr_flags;
- const struct gpio_dt_spec gpio_alert;
-};
-
-/* Driver data */
-struct renesas_rtc_idt1337ag_data {
- const struct device *dev;
- struct gpio_callback gpio_cb;
- cros_rtc_alarm_callback_t alarm_callback;
-};
-
-enum timer_type {
- RTC_TIMER,
- ALARM_TIMER,
-};
-
-/*
- * type == ALARM_TIMER: Reads alarm registers SECONDS, MINUTES, HOURS, and DAYS
- * type == RTC_TIMER: Reads time registers SECONDS, MINUTES, HOURS, DAYS, and
- * MONTHS, YEARS
- */
-static int idt1337ag_read_time_regs(const struct device *dev,
- uint8_t *time_reg, enum timer_type type)
-{
- const struct renesas_rtc_idt1337ag_config *const config = dev->config;
- uint8_t start_reg;
- uint8_t num_reg;
-
- if (type == ALARM_TIMER) {
- start_reg = REG_SECOND_ALARM1;
- num_reg = NUM_ALARM_REGS;
- } else {
- start_reg = REG_SECONDS;
- num_reg = NUM_TIMER_REGS;
- }
-
- return i2c_burst_read(config->bus,
- config->i2c_addr_flags, start_reg, time_reg, num_reg);
-}
-
-static int idt1337ag_read_reg(const struct device *dev,
- uint8_t reg, uint8_t *val)
-{
- const struct renesas_rtc_idt1337ag_config *const config = dev->config;
-
- return i2c_reg_read_byte(config->bus, config->i2c_addr_flags, reg, val);
-}
-
-/*
- * type == ALARM_TIMER: Writes alarm registers SECONDS, MINUTES, HOURS, and DAYS
- * type == RTC_TIMER: Writes time registers SECONDS, MINUTES, HOURS, DAYS, and
- * MONTHS, YEARS
- */
-static int idt1337ag_write_time_regs(const struct device *dev,
- uint8_t *time_reg, enum timer_type type)
-{
- const struct renesas_rtc_idt1337ag_config *const config = dev->config;
- uint8_t start_reg;
- uint8_t num_reg;
-
- if (type == ALARM_TIMER) {
- /*
- * Register 0x0A bit 6 determines if the DAY(1b) or DATE(0b)
- * alarm is selected.
- * Select the DAY alarm
- */
- time_reg[DAYS] |= SELECT_DAYS_ALARM;
-
- start_reg = REG_SECOND_ALARM1;
- num_reg = NUM_ALARM_REGS;
- } else {
- start_reg = REG_SECONDS;
- num_reg = NUM_TIMER_REGS;
- }
-
- return i2c_burst_write(config->bus,
- config->i2c_addr_flags, start_reg, time_reg, num_reg);
-}
-
-static int idt1337ag_write_reg(const struct device *dev,
- uint8_t reg, uint8_t val)
-{
- const struct renesas_rtc_idt1337ag_config *const config = dev->config;
- uint8_t tx_buf[2];
-
- tx_buf[0] = reg;
- tx_buf[1] = val;
-
- return i2c_write(config->bus,
- tx_buf, sizeof(tx_buf), config->i2c_addr_flags);
-}
-
-/*
- * val bits 7 to 4 - tens place
- * val bits 3 to 0 - ones place
- */
-static int bcd_to_dec(uint8_t val, enum bcd_mask mask)
-{
- int tens = ((val & mask) >> 4) * 10;
- int ones = (val & 0xf);
-
- return tens + ones;
-}
-
-/*
- * val bits 7 to 4 - tens place
- * val bits 3 to 0 - ones place
- */
-static uint8_t dec_to_bcd(uint32_t val, enum bcd_mask mask)
-{
- int tens = val / 10;
- int ones = val - (tens * 10);
-
- return ((tens << 4) & mask) | ones;
-}
-
-static int renesas_rtc_idt1337ag_read_seconds(const struct device *dev,
- uint32_t *value, enum timer_type type)
-{
- uint8_t time_reg[NUM_TIMER_REGS];
- struct calendar_date time;
- int ret;
-
- ret = idt1337ag_read_time_regs(dev, time_reg, type);
-
- if (ret < 0) {
- return ret;
- }
-
- if (type == ALARM_TIMER) {
- *value = (bcd_to_dec(time_reg[DAYS], DAYS_MASK) *
- SECS_PER_DAY) +
- (bcd_to_dec(time_reg[HOURS], HOURS24_MASK) *
- SECS_PER_HOUR) +
- (bcd_to_dec(time_reg[MINUTES], MINUTES_MASK) *
- SECS_PER_MINUTE) +
- bcd_to_dec(time_reg[SECONDS], SECONDS_MASK);
- } else {
- time.year = bcd_to_dec(time_reg[YEARS], YEARS_MASK);
- time.month = bcd_to_dec(time_reg[MONTHS], MONTHS_MASK);
- time.day = bcd_to_dec(time_reg[DAYS], DAYS_MASK);
-
- *value = date_to_sec(time) - SECS_TILL_YEAR_2K +
- (bcd_to_dec(time_reg[HOURS], HOURS24_MASK) *
- SECS_PER_HOUR) +
- (bcd_to_dec(time_reg[MINUTES], MINUTES_MASK) *
- SECS_PER_MINUTE) +
- bcd_to_dec(time_reg[SECONDS], SECONDS_MASK);
- }
-
- return ret;
-}
-
-static int renesas_rtc_idt1337ag_write_seconds(const struct device *dev,
- uint32_t value, enum timer_type type)
-{
- uint8_t time_reg[NUM_TIMER_REGS];
- struct calendar_date time;
- uint32_t tmp_sec;
-
- time = sec_to_date(value + SECS_TILL_YEAR_2K);
-
- if (type == RTC_TIMER) {
- time_reg[YEARS] = dec_to_bcd(time.year, YEARS_MASK);
- time_reg[MONTHS] = dec_to_bcd(time.month, MONTHS_MASK);
- }
-
- time_reg[DAYS] = dec_to_bcd(time.day, DAYS_MASK);
-
- value %= SECS_PER_DAY;
- tmp_sec = value / SECS_PER_HOUR;
- time_reg[HOURS] = dec_to_bcd(tmp_sec, HOURS24_MASK);
-
- value -= (tmp_sec * SECS_PER_HOUR);
- tmp_sec = value / SECS_PER_MINUTE;
- time_reg[MINUTES] = dec_to_bcd(tmp_sec, MINUTES_MASK);
-
- value -= (tmp_sec * SECS_PER_MINUTE);
- time_reg[SECONDS] = dec_to_bcd(value, SECONDS_MASK);
-
- return idt1337ag_write_time_regs(dev, time_reg, type);
-}
-
-static int renesas_rtc_idt1337ag_configure(const struct device *dev,
- cros_rtc_alarm_callback_t callback)
-{
- struct renesas_rtc_idt1337ag_data *data = dev->data;
-
- if (callback == NULL) {
- return -EINVAL;
- }
-
- data->alarm_callback = callback;
-
- return 0;
-}
-
-static int renesas_rtc_idt1337ag_get_value(const struct device *dev,
- uint32_t *value)
-{
- return renesas_rtc_idt1337ag_read_seconds(dev, value, RTC_TIMER);
-}
-
-static int renesas_rtc_idt1337ag_set_value(const struct device *dev,
- uint32_t value)
-{
- return renesas_rtc_idt1337ag_write_seconds(dev, value, RTC_TIMER);
-}
-
-static int renesas_rtc_idt1337ag_get_alarm(const struct device *dev,
- uint32_t *seconds, uint32_t *microseconds)
-{
- *microseconds = 0;
- return renesas_rtc_idt1337ag_read_seconds(dev, seconds, ALARM_TIMER);
-}
-
-static int renesas_rtc_idt1337ag_reset_alarm(const struct device *dev)
-{
- uint8_t time_reg[NUM_ALARM_REGS];
- int ret;
- uint8_t val;
-
- ret = idt1337ag_read_reg(dev, REG_CONTROL, &val);
-
- if (ret < 0) {
- return ret;
- }
-
- /* Disable alarm interrupt and clear pending alarm flag */
- val &= ~CONTROL_A1IE;
- ret = idt1337ag_write_reg(dev, REG_CONTROL, val);
-
- if (ret < 0) {
- return ret;
- }
-
- /* Clear alarm1 flag if set */
- ret = idt1337ag_read_reg(dev, REG_STATUS, &val);
-
- if (ret < 0) {
- return ret;
- }
-
- /* Clear the alarm1 and alarm2 flag */
- val &= ~(STATUS_A1F | STATUS_A2F);
- ret = idt1337ag_write_reg(dev, REG_STATUS, val);
-
- if (ret < 0) {
- return ret;
- }
-
- /* Clear and disable the alarm registers */
- time_reg[SECONDS] = DISABLE_ALARM;
- time_reg[MINUTES] = DISABLE_ALARM;
- time_reg[HOURS] = DISABLE_ALARM;
- time_reg[DAYS] = DISABLE_ALARM;
-
- return idt1337ag_write_time_regs(dev, time_reg, ALARM_TIMER);
-}
-
-static int renesas_rtc_idt1337ag_set_alarm(const struct device *dev,
- uint32_t seconds, uint32_t microseconds)
-{
- int ret;
- uint8_t val;
-
- ARG_UNUSED(microseconds);
-
- ret = renesas_rtc_idt1337ag_reset_alarm(dev);
- if (ret < 0) {
- return ret;
- }
-
- ret = renesas_rtc_idt1337ag_write_seconds(dev, seconds, ALARM_TIMER);
- if (ret < 0) {
- return ret;
- }
-
- ret = idt1337ag_read_reg(dev, REG_CONTROL, &val);
- if (ret < 0) {
- return ret;
- }
-
- val |= CONTROL_A1IE;
- idt1337ag_write_reg(dev, REG_CONTROL, val);
-
- return 0;
-}
-
-static void renesas_rtc_idt1337ag_isr(const struct device *port,
- struct gpio_callback *cb, uint32_t pin)
-{
- struct renesas_rtc_idt1337ag_data *data =
- CONTAINER_OF(cb, struct renesas_rtc_idt1337ag_data, gpio_cb);
- const struct device *dev = data->dev;
-
- ARG_UNUSED(port);
- ARG_UNUSED(pin);
- ARG_UNUSED(cb);
-
- LOG_DBG("%s", __func__);
-
- /* Call callback function */
- if (data->alarm_callback) {
- data->alarm_callback(dev);
- }
-}
-
-static const struct cros_rtc_driver_api renesas_rtc_idt1337ag_driver_api = {
- .configure = renesas_rtc_idt1337ag_configure,
- .get_value = renesas_rtc_idt1337ag_get_value,
- .set_value = renesas_rtc_idt1337ag_set_value,
- .get_alarm = renesas_rtc_idt1337ag_get_alarm,
- .set_alarm = renesas_rtc_idt1337ag_set_alarm,
- .reset_alarm = renesas_rtc_idt1337ag_reset_alarm,
-};
-
-static int renesas_rtc_idt1337ag_init(const struct device *dev)
-{
- const struct renesas_rtc_idt1337ag_config *const config = dev->config;
- struct renesas_rtc_idt1337ag_data *data = dev->data;
- uint8_t val;
- int ret;
-
- if (!device_is_ready(config->bus)) {
- LOG_ERR("Device %s is not ready", config->bus->name);
- return -ENODEV;
- }
-
- /*
- * Read Control register. For normal operation,
- * the values should be as follows:
- * Bit 7 (enable oscillator) : (0) normal mode
- * Bit 6 (unused) : (0)
- * Bit 5 (unused) : (0)
- * BIT 4 (RS2) : (0) Not used when INTCN == 1
- * BIT 3 (RS1) : (0) Not used when INTCN == 1
- * BIT 2 (INTCN) : (1) a match between the timekeeping
- * registers and the alarm 1
- * registers activate the INTA pin
- * BIT 1 (A2IE) : (0) Alarm 2 is not used
- * BIT 0 (A1IE) : (1) Enables Alarm 1
- */
- ret = idt1337ag_read_reg(dev, REG_CONTROL, &val);
-
- if (ret < 0) {
- return ret;
- }
-
- /* Enable IDT1337AG oscillator */
- val &= ~CONTROL_EOSC;
-
- /* Disable Alarm 2 */
- val &= ~CONTROL_A2IE;
-
- /* Alarm 1 assert INTA pin */
- val |= CONTROL_INTCN;
-
- ret = idt1337ag_write_reg(dev, REG_CONTROL, val);
-
- if (ret < 0) {
- return ret;
- }
-
- /* Date register isn't used. Set it to zero */
- ret = idt1337ag_write_reg(dev, REG_DATE, 0);
-
- /* Make sure the oscillator is running */
- ret = idt1337ag_read_reg(dev, REG_STATUS, &val);
-
- if (ret < 0) {
- return ret;
- }
-
- /* Clear IDT1337AG oscillator not running flag */
- val &= ~STATUS_OSF;
-
- /* Clear Alarm 2 flag */
- val &= ~STATUS_A2F;
-
- ret = idt1337ag_write_reg(dev, REG_STATUS, val);
-
- if (ret < 0) {
- return ret;
- }
-
- renesas_rtc_idt1337ag_reset_alarm(dev);
-
- /* Disable Alarm2 */
- idt1337ag_write_reg(dev, REG_MINUTE_ALARM2, DISABLE_ALARM);
- idt1337ag_write_reg(dev, REG_HOUR_ALARM2, DISABLE_ALARM);
- idt1337ag_write_reg(dev, REG_DAY_ALARM2, DISABLE_ALARM);
-
- /* Configure GPIO interrupt pin for IDT1337AG alarm pin */
-
- if (!device_is_ready(config->gpio_alert.port)) {
- LOG_ERR("Alert GPIO device not ready");
- return -ENODEV;
- }
-
- ret = gpio_pin_configure_dt(&config->gpio_alert, GPIO_INPUT);
-
- if (ret < 0) {
- LOG_ERR("Could not configure RTC alert pin");
- return ret;
- }
-
- gpio_init_callback(&data->gpio_cb,
- renesas_rtc_idt1337ag_isr, BIT(config->gpio_alert.pin));
-
- ret = gpio_add_callback(config->gpio_alert.port, &data->gpio_cb);
-
- if (ret < 0) {
- LOG_ERR("Could not set RTC alert pin callback");
- return ret;
- }
-
- data->dev = dev;
-
- return gpio_pin_interrupt_configure_dt(&config->gpio_alert,
- GPIO_INT_EDGE_FALLING);
-}
-
-#define IDT1337AG_INT_GPIOS \
- DT_PHANDLE_BY_IDX(DT_NODELABEL(idt1337ag), int_gpios, 0)
-
-/*
- * dt_flags is a uint8_t type. However, for platform/ec
- * the GPIO flags in the devicetree are expanded past 8 bits
- * to support the INPUT/OUTPUT and PULLUP/PULLDOWN properties.
- * Cast back to a gpio_dt_flags to compile, discarding the bits
- * that are not supported by the Zephyr GPIO API.
- */
-#define CROS_EC_GPIO_DT_SPEC_GET_BY_IDX(node_id, prop, idx) \
- { \
- .port = \
- DEVICE_DT_GET(DT_GPIO_CTLR_BY_IDX(node_id, prop, idx)), \
- .pin = DT_GPIO_PIN_BY_IDX(node_id, prop, idx), \
- .dt_flags = \
- (gpio_dt_flags_t)DT_GPIO_FLAGS_BY_IDX(node_id, prop, idx), \
- }
-
-static const struct renesas_rtc_idt1337ag_config renesas_rtc_idt1337ag_cfg_0 = {
- .bus = DEVICE_DT_GET(DT_INST_BUS(0)),
- .i2c_addr_flags = DT_INST_REG_ADDR(0),
- .gpio_alert =
- CROS_EC_GPIO_DT_SPEC_GET_BY_IDX(IDT1337AG_INT_GPIOS, gpios, 0)
-};
-
-static struct renesas_rtc_idt1337ag_data renesas_rtc_idt1337ag_data_0;
-
-DEVICE_DT_INST_DEFINE(0, renesas_rtc_idt1337ag_init, /* pm_control_fn= */ NULL,
- &renesas_rtc_idt1337ag_data_0,
- &renesas_rtc_idt1337ag_cfg_0,
- POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE,
- &renesas_rtc_idt1337ag_driver_api);
diff --git a/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.h b/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.h
deleted file mode 100644
index 3296f80992..0000000000
--- a/zephyr/drivers/cros_rtc/renesas_rtc_idt1337ag.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_RTC_IDT1337AG_H
-#define __CROS_EC_RTC_IDT1337AG_H
-
-/* Setting bit 6 of register 0Ah selects the DAY as alarm source */
-#define SELECT_DAYS_ALARM 0x40
-#define DISABLE_ALARM 0x80
-
-#define CONTROL_A1IE BIT(0)
-#define CONTROL_A2IE BIT(1)
-#define CONTROL_INTCN BIT(2)
-#define CONTROL_EOSC BIT(7)
-
-#define STATUS_A1F BIT(0)
-#define STATUS_A2F BIT(1)
-#define STATUS_OSF BIT(7)
-
-#define NUM_TIMER_REGS 7
-#define NUM_ALARM_REGS 4
-
-#define REG_SECONDS 0x00
-#define REG_MINUTES 0x01
-#define REG_HOURS 0x02
-#define REG_DAYS 0x03
-#define REG_DATE 0x04
-#define REG_MONTHS 0x05
-#define REG_YEARS 0x06
-#define REG_SECOND_ALARM1 0x07
-#define REG_MINUTE_ALARM1 0x08
-#define REG_HOUR_ALARM1 0x09
-#define REG_DAY_ALARM1 0x0a
-#define REG_MINUTE_ALARM2 0x0b
-#define REG_HOUR_ALARM2 0x0c
-#define REG_DAY_ALARM2 0x0d
-#define REG_CONTROL 0x0e
-#define REG_STATUS 0x0f
-
-/* Macros for indexing time_reg buffer */
-#define SECONDS 0
-#define MINUTES 1
-#define HOURS 2
-#define DAYS 3
-#define DATE 4
-#define MONTHS 5
-#define YEARS 6
-
-enum bcd_mask {
- SECONDS_MASK = 0x70,
- MINUTES_MASK = 0x70,
- HOURS24_MASK = 0x30,
- DAYS_MASK = 0x00,
- MONTHS_MASK = 0x10,
- YEARS_MASK = 0xf0
-};
-
-#endif /* __CROS_EC_RTC_IDT1337AG_H */
diff --git a/zephyr/drivers/cros_shi/CMakeLists.txt b/zephyr/drivers/cros_shi/CMakeLists.txt
deleted file mode 100644
index f0b3c8bb5a..0000000000
--- a/zephyr/drivers/cros_shi/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-zephyr_library_sources_ifdef(CONFIG_CROS_SHI_IT8XXX2 cros_shi_it8xxx2.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_SHI_NPCX cros_shi_npcx.c)
diff --git a/zephyr/drivers/cros_shi/Kconfig b/zephyr/drivers/cros_shi/Kconfig
deleted file mode 100644
index 0baa8a5d80..0000000000
--- a/zephyr/drivers/cros_shi/Kconfig
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-menuconfig CROS_SHI_NPCX
- bool "Nuvoton NPCX Serial Host Interface driver for the Zephyr shim"
- depends on SOC_FAMILY_NPCX
- 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
- help
- This option indicates maximum data size for a version 3 request
- packet. This must be big enough to handle a request header of host
- command, flash write offset/size, and 512 bytes of flash data.
-
-config CROS_SHI_MAX_RESPONSE
- hex "Max data size for the version 3 response packet"
- default 0x220
- help
- This option indicates maximum data size for a version 3 response
- packet. This must be big enough to handle a response header of host
- command, flash read offset/size, and 512 bytes of flash data.
-
-config CROS_SHI_NPCX_DEBUG
- bool "Enable SHI debug"
- help
- print the debug messages for SHI module
-
-endif # CROS_SHI_NPCX
-
-config CROS_SHI_IT8XXX2
- bool "ITE it81202 spi host interface driver for Zephyr"
- depends on SOC_FAMILY_RISCV_ITE && AP_ARM
- default y if PLATFORM_EC_HOSTCMD
- help
- This option enables spi host interface driver which is required to
- communicate with the EC when the CPU is the ARM processor.
-
-if CROS_SHI_IT8XXX2
-
-config CROS_SHI_IT8XXX2_INIT_PRIORITY
- int "cros_shi it8xxx2 initialization priority"
- default 52
- help
- This sets the it8xxx2 cros_shi driver initialization priority.
- In the GPIO shim, the alt function of SHI will be configured
- as GPIO input pin. So the priority of cros_shi driver must be
- lower than CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY, and
- configuration these pins to alt function of SHI.
-
-endif # CROS_SHI_IT8XXX2
diff --git a/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c b/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c
deleted file mode 100644
index 522d48ff09..0000000000
--- a/zephyr/drivers/cros_shi/cros_shi_it8xxx2.c
+++ /dev/null
@@ -1,407 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT ite_it8xxx2_cros_shi
-
-#include <device.h>
-#include <errno.h>
-#include <init.h>
-#include <kernel.h>
-#include <logging/log.h>
-#include <soc.h>
-#include <soc_dt.h>
-#include <drivers/pinmux.h>
-#include <dt-bindings/pinctrl/it8xxx2-pinctrl.h>
-
-#include "chipset.h"
-#include "console.h"
-#include "host_command.h"
-
-/* Console output macros */
-#define CPRINTS(format, args...) cprints(CC_SPI, format, ## args)
-#define CPRINTF(format, args...) cprintf(CC_SPI, format, ## args)
-
-LOG_MODULE_REGISTER(cros_shi, LOG_LEVEL_ERR);
-
-#define DRV_CONFIG(dev) ((struct cros_shi_it8xxx2_cfg * const)(dev)->config)
-
-/*
- * Strcture cros_shi_it8xxx2_cfg is about the setting of SHI,
- * this config will be used at initial time
- */
-struct cros_shi_it8xxx2_cfg {
- /* Pinmux control group */
- const struct device *pinctrls;
- /* GPIO pin */
- uint8_t pin;
- /* Alternate function */
- uint8_t alt_fun;
-};
-
-#define SPI_RX_MAX_FIFO_SIZE 256
-#define SPI_TX_MAX_FIFO_SIZE 256
-
-#define EC_SPI_PREAMBLE_LENGTH 4
-#define EC_SPI_PAST_END_LENGTH 4
-
-/* Max data size for a version 3 request/response packet. */
-#define SPI_MAX_REQUEST_SIZE SPI_RX_MAX_FIFO_SIZE
-#define SPI_MAX_RESPONSE_SIZE (SPI_TX_MAX_FIFO_SIZE - \
- EC_SPI_PREAMBLE_LENGTH - EC_SPI_PAST_END_LENGTH)
-
-static const uint8_t out_preamble[EC_SPI_PREAMBLE_LENGTH] = {
- EC_SPI_PROCESSING,
- EC_SPI_PROCESSING,
- EC_SPI_PROCESSING,
- /* This is the byte which matters */
- EC_SPI_FRAME_START,
-};
-
-/* Store read and write data buffer */
-static uint8_t in_msg[SPI_RX_MAX_FIFO_SIZE] __aligned(4);
-static uint8_t out_msg[SPI_TX_MAX_FIFO_SIZE] __aligned(4);
-
-/* Parameters used by host protocols */
-static struct host_packet spi_packet;
-
-enum shi_state_machine {
- /* Ready to receive next request */
- SPI_STATE_READY_TO_RECV,
- /* Receiving request */
- SPI_STATE_RECEIVING,
- /* Processing request */
- SPI_STATE_PROCESSING,
- /* Received bad data */
- SPI_STATE_RX_BAD,
-
- SPI_STATE_COUNT,
-};
-
-static enum shi_state_machine shi_state;
-
-static const int spi_response_state[] = {
- [SPI_STATE_READY_TO_RECV] = EC_SPI_OLD_READY,
- [SPI_STATE_RECEIVING] = EC_SPI_RECEIVING,
- [SPI_STATE_PROCESSING] = EC_SPI_PROCESSING,
- [SPI_STATE_RX_BAD] = EC_SPI_RX_BAD_DATA,
-};
-BUILD_ASSERT(ARRAY_SIZE(spi_response_state) == SPI_STATE_COUNT);
-
-static void spi_set_state(int state)
-{
- /* SPI slave state machine */
- shi_state = state;
- /* Response spi slave state */
- IT83XX_SPI_SPISRDR = spi_response_state[state];
-}
-
-static void reset_rx_fifo(void)
-{
- /* End Rx FIFO access */
- IT83XX_SPI_TXRXFAR = 0x00;
- /* Rx FIFO reset and count monitor reset */
- IT83XX_SPI_FCR = IT83XX_SPI_RXFR | IT83XX_SPI_RXFCMR;
-}
-
-/* This routine handles spi received unexcepted data */
-static void spi_bad_received_data(int count)
-{
- /* State machine mismatch, timeout, or protocol we can't handle. */
- spi_set_state(SPI_STATE_RX_BAD);
- /* End CPU access Rx FIFO, so it can clock in bytes from AP again. */
- IT83XX_SPI_TXRXFAR = 0;
-
- CPRINTS("SPI rx bad data");
- CPRINTF("in_msg=[");
- for (int i = 0; i < count; i++)
- CPRINTF("%02x ", in_msg[i]);
- CPRINTF("]\n");
-}
-
-static void spi_response_host_data(uint8_t *out_msg_addr, int tx_size)
-{
- /*
- * Protect sequence of filling response packet for host.
- * This will ensure CPU access FIFO is disabled at SPI end interrupt no
- * matter the interrupt is triggered before or after the sequence.
- */
- unsigned int key = irq_lock();
-
- if (shi_state == SPI_STATE_PROCESSING) {
- /* Tx FIFO reset and count monitor reset */
- IT83XX_SPI_TXFCR = IT83XX_SPI_TXFR | IT83XX_SPI_TXFCMR;
- /* CPU Tx FIFO1 and FIFO2 access */
- IT83XX_SPI_TXRXFAR = IT83XX_SPI_CPUTFA;
-
- for (int i = 0; i < tx_size; i += 4) {
- /* Write response data from out_msg buffer to Tx FIFO */
- IT83XX_SPI_CPUWTFDB0 = *(uint32_t *)(out_msg_addr + i);
- }
-
- /*
- * After writing data to Tx FIFO is finished, this bit will
- * be to indicate the SPI slave controller.
- */
- IT83XX_SPI_TXFCR = IT83XX_SPI_TXFS;
- /* End Tx FIFO access */
- IT83XX_SPI_TXRXFAR = 0;
- /* SPI slave read Tx FIFO */
- IT83XX_SPI_FCR = IT83XX_SPI_SPISRTXF;
- }
-
- irq_unlock(key);
-}
-
-/*
- * Called to send a response back to the host.
- *
- * Some commands can continue for a while. This function is called by
- * host_command when it completes.
- *
- */
-static void spi_send_response_packet(struct host_packet *pkt)
-{
- int tx_size;
-
- if (shi_state != SPI_STATE_PROCESSING) {
- CPRINTS("The request data is not processing.");
- return;
- }
-
- /* Append our past-end byte, which we reserved space for. */
- for (int i = 0; i < EC_SPI_PAST_END_LENGTH; i++) {
- ((uint8_t *)pkt->response)[pkt->response_size + i]
- = EC_SPI_PAST_END;
- }
-
- tx_size = pkt->response_size + EC_SPI_PREAMBLE_LENGTH +
- EC_SPI_PAST_END_LENGTH;
-
- /* Transmit the reply */
- spi_response_host_data(out_msg, tx_size);
-}
-
-/* Store request data from Rx FIFO to in_msg buffer */
-static void spi_host_request_data(uint8_t *in_msg_addr, int count)
-{
- /* CPU Rx FIFO1 access */
- IT83XX_SPI_TXRXFAR = IT83XX_SPI_CPURXF1A;
- /*
- * In spi_parse_header, the request data will separate to
- * write in_msg buffer so we cannot set CPU to end accessing
- * Rx FIFO in this function. We will set IT83XX_SPI_TXRXFAR = 0
- * in reset_rx_fifo.
- */
-
- for (int i = 0; i < count; i += 4) {
- /* Get data from master to buffer */
- *(uint32_t *)(in_msg_addr + i) = IT83XX_SPI_RXFRDRB0;
- }
-}
-
-/* Parse header for version of spi-protocol */
-static void spi_parse_header(void)
-{
- struct ec_host_request *r = (struct ec_host_request *)in_msg;
-
- /* Store request data from Rx FIFO to in_msg buffer */
- spi_host_request_data(in_msg, sizeof(*r));
-
- /* Protocol version 3 */
- if (in_msg[0] == EC_HOST_REQUEST_VERSION) {
- int pkt_size;
-
- /* Check how big the packet should be */
- pkt_size = host_request_expected_size(r);
-
- if (pkt_size == 0 || pkt_size > sizeof(in_msg)) {
- spi_bad_received_data(pkt_size);
- return;
- }
-
- /* Store request data from Rx FIFO to in_msg buffer */
- spi_host_request_data(in_msg + sizeof(*r),
- pkt_size - sizeof(*r));
-
- /* Set up parameters for host request */
- spi_packet.send_response = spi_send_response_packet;
- spi_packet.request = in_msg;
- spi_packet.request_temp = NULL;
- spi_packet.request_max = sizeof(in_msg);
- spi_packet.request_size = pkt_size;
-
- /* Response must start with the preamble */
- memcpy(out_msg, out_preamble, sizeof(out_preamble));
-
- spi_packet.response = out_msg + EC_SPI_PREAMBLE_LENGTH;
- /* Reserve space for frame start and trailing past-end byte */
- spi_packet.response_max = SPI_MAX_RESPONSE_SIZE;
- spi_packet.response_size = 0;
- spi_packet.driver_result = EC_RES_SUCCESS;
-
- /* Go to common-layer to handle request */
- host_packet_receive(&spi_packet);
- } else {
- /* Invalid version number */
- CPRINTS("Invalid version number");
- spi_bad_received_data(1);
- }
-}
-
-static void shi_ite_int_handler(const void *arg)
-{
- /*
- * The status of SPI end detection interrupt bit is set, it
- * means that host command parse has been completed and AP
- * has received the last byte which is EC_SPI_PAST_END from
- * EC responded data, then AP ended the transaction.
- */
- if (IT83XX_SPI_ISR & IT83XX_SPI_ENDDETECTINT) {
- /* Disable CPU access Rx FIFO to clock in data from AP again */
- IT83XX_SPI_TXRXFAR = 0;
- /* Ready to receive */
- spi_set_state(SPI_STATE_READY_TO_RECV);
- /*
- * Once there is no SPI active, enable idle task deep
- * sleep bit of SPI in S3 or lower.
- * TODO(b:185176098): enable_sleep(SLEEP_MASK_SPI);
- */
-
- /* CS# is deasserted, so write clear all slave status */
- IT83XX_SPI_ISR = 0xff;
- }
- /*
- * The status of Rx valid length interrupt bit is set that
- * indicates reached target count(IT83XX_SPI_FTCB1R,
- * IT83XX_SPI_FTCB0R) and the length field of the host
- * requested data.
- */
- if (IT83XX_SPI_RX_VLISR & IT83XX_SPI_RVLI) {
- /* write clear slave status */
- IT83XX_SPI_RX_VLISR = IT83XX_SPI_RVLI;
- /* Move to processing state */
- spi_set_state(SPI_STATE_PROCESSING);
- /* Parse header for version of spi-protocol */
- spi_parse_header();
- }
-}
-
-void spi_event(enum gpio_signal signal)
-{
- if (chipset_in_state(CHIPSET_STATE_ON)) {
- /* Move to processing state */
- spi_set_state(SPI_STATE_PROCESSING);
- /* Disable idle task deep sleep bit of SPI in S0. */
- /* TODO(b:185176098): disable_sleep(SLEEP_MASK_SPI); */
- }
-}
-
-/*
- * SHI init priority is behind CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY to
- * overwrite GPIO_INPUT setting of spi chip select pin.
- */
-static int cros_shi_ite_init(const struct device *dev)
-{
- const struct cros_shi_it8xxx2_cfg *const config = DRV_CONFIG(dev);
- /* Set FIFO data target count */
- struct ec_host_request cmd_head;
-
- /*
- * Target count means the size of host request.
- * And plus extra 4 bytes because the CPU accesses FIFO base on
- * word. If host requested data length is one byte, we need to
- * align the data length to 4 bytes.
- */
- int target_count = sizeof(cmd_head) + 4;
- /* Offset of data_len member of host request. */
- int offset = (char *)&cmd_head.data_len - (char *)&cmd_head;
-
- IT83XX_SPI_FTCB1R = (target_count >> 8) & 0xff;
- IT83XX_SPI_FTCB0R = target_count & 0xff;
- /*
- * The register setting can capture the length field of host
- * request.
- */
- IT83XX_SPI_TCCB1 = (offset >> 8) & 0xff;
- IT83XX_SPI_TCCB0 = offset & 0xff;
-
- /*
- * Memory controller configuration register 3.
- * bit6 : SPI pin function select (0b:Enable, 1b:Mask)
- */
- IT83XX_GCTRL_MCCR3 |= IT83XX_GCTRL_SPISLVPFE;
- /* Set unused blocked byte */
- IT83XX_SPI_HPR2 = 0x00;
- /* Rx valid length interrupt enabled */
- IT83XX_SPI_RX_VLISMR &= ~IT83XX_SPI_RVLIM;
- /*
- * General control register2
- * bit4 : Rx FIFO2 will not be overwrited once it's full.
- * bit3 : Rx FIFO1 will not be overwrited once it's full.
- * bit0 : Rx FIFO1/FIFO2 will reset after each CS_N goes high.
- */
- IT83XX_SPI_GCR2 = IT83XX_SPI_RXF2OC | IT83XX_SPI_RXF1OC
- | IT83XX_SPI_RXFAR;
- /*
- * Interrupt mask register (0b:Enable, 1b:Mask)
- * bit5 : Rx byte reach interrupt mask
- * bit2 : SPI end detection interrupt mask
- */
- IT83XX_SPI_IMR &= ~IT83XX_SPI_EDIM;
- /* Reset fifo and prepare to for next transaction */
- reset_rx_fifo();
- /* Ready to receive */
- spi_set_state(SPI_STATE_READY_TO_RECV);
- /* Interrupt status register(write one to clear) */
- IT83XX_SPI_ISR = 0xff;
- /* SPI slave controller enable (after settings are ready) */
- IT83XX_SPI_SPISGCR = IT83XX_SPI_SPISCEN;
-
- /* Ensure spi chip select alt function is enabled. */
- for (int i = 0; i < DT_INST_PROP_LEN(0, pinctrl_0); i++) {
- pinmux_pin_set(config[i].pinctrls, config[i].pin,
- config[i].alt_fun);
- }
-
- /* Enable SPI slave interrupt */
- IRQ_CONNECT(DT_INST_IRQN(0), 0, shi_ite_int_handler, 0, 0);
- irq_enable(DT_INST_IRQN(0));
-
- /* Enable SPI chip select pin interrupt */
- gpio_enable_interrupt(GPIO_SPI0_CS);
-
- return 0;
-}
-
-static const struct cros_shi_it8xxx2_cfg cros_shi_cfg[] =
- IT8XXX2_DT_ALT_ITEMS_LIST(0);
-
-#if CONFIG_CROS_SHI_IT8XXX2_INIT_PRIORITY <= \
- CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY
-#error "CROS_SHI must initialize after the GPIOs initialization"
-#endif
-DEVICE_DT_INST_DEFINE(0, cros_shi_ite_init, NULL,
- NULL, &cros_shi_cfg, POST_KERNEL,
- CONFIG_CROS_SHI_IT8XXX2_INIT_PRIORITY,
- NULL);
-
-/* Get protocol information */
-enum ec_status spi_get_protocol_info(struct host_cmd_handler_args *args)
-{
- struct ec_response_get_protocol_info *r = args->response;
-
- memset(r, 0, sizeof(*r));
- r->protocol_versions = BIT(3);
- r->max_request_packet_size = SPI_MAX_REQUEST_SIZE;
- r->max_response_packet_size = SPI_MAX_RESPONSE_SIZE;
- r->flags = EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED;
-
- args->response_size = sizeof(*r);
-
- return EC_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_GET_PROTOCOL_INFO,
- spi_get_protocol_info,
- EC_VER_MASK(0));
diff --git a/zephyr/drivers/cros_shi/cros_shi_npcx.c b/zephyr/drivers/cros_shi/cros_shi_npcx.c
deleted file mode 100644
index a290e320fc..0000000000
--- a/zephyr/drivers/cros_shi/cros_shi_npcx.c
+++ /dev/null
@@ -1,899 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT nuvoton_npcx_cros_shi
-
-#include <arch/arm/aarch32/cortex_m/cmsis.h>
-#include <assert.h>
-#include <dt-bindings/clock/npcx_clock.h>
-#include <drivers/clock_control.h>
-#include <drivers/cros_shi.h>
-#include <drivers/gpio.h>
-#include <logging/log.h>
-#include <kernel.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)
-#else
-#define DEBUG_CPRINTS(...)
-#define DEBUG_CPRINTF(...)
-#endif
-
-LOG_MODULE_REGISTER(cros_shi, LOG_LEVEL_DBG);
-
-#define SHI_NODE DT_NODELABEL(shi)
-#define SHI_VER_CTRL_PH DT_PHANDLE_BY_IDX(SHI_NODE, ver_ctrl, 0)
-#define SHI_VER_CTRL_ALT_FILED(f) DT_PHA_BY_IDX(SHI_VER_CTRL_PH, alts, 0, f)
-
-/* Full output buffer size */
-#define SHI_OBUF_FULL_SIZE 128
-/* Full input buffer size */
-#define SHI_IBUF_FULL_SIZE 128
-/* Configure the IBUFLVL2 = the size of V3 protocol header */
-#define SHI_IBUFLVL2_THRESHOLD (sizeof(struct ec_host_request))
-/* Half output buffer size */
-#define SHI_OBUF_HALF_SIZE (SHI_OBUF_FULL_SIZE / 2)
-/* Half input buffer size */
-#define SHI_IBUF_HALF_SIZE (SHI_IBUF_FULL_SIZE / 2)
-
-/*
- * Timeout to wait for SHI request packet
- *
- * This affects the slowest SPI clock we can support. A delay of 8192 us
- * permits a 512-byte request at 500 KHz, assuming the SPI controller starts
- * sending bytes as soon as it asserts chip select. That's as slow as we would
- * practically want to run the SHI interface, since running it slower
- * significantly impacts firmware update times.
- */
-#define SHI_CMD_RX_TIMEOUT_MS 9
-
-/*
- * The AP blindly clocks back bytes over the SPI interface looking for a
- * framing byte. So this preamble must always precede the actual response
- * packet.
- */
-#define SHI_OUT_PREAMBLE_LENGTH 2
-
-/*
- * Space allocation of the past-end status byte (EC_SPI_PAST_END) in the out_msg
- * buffer.
- */
-#define EC_SPI_PAST_END_LENGTH 1
-/*
- * Space allocation of the frame status byte (EC_SPI_FRAME_START) in the out_msg
- * buffer.
- */
-#define EC_SPI_FRAME_START_LENGTH 1
-
-/*
- * Offset of output parameters needs to account for pad and framing bytes and
- * one last past-end byte at the end so any additional bytes clocked out by
- * the AP will have a known and identifiable value.
- */
-#define SHI_PROTO3_OVERHEAD (EC_SPI_PAST_END_LENGTH + EC_SPI_FRAME_START_LENGTH)
-
-/*
- * Max data size for a version 3 request/response packet. This is big enough
- * to handle a request/response header, flash write offset/size, and 512 bytes
- * of flash data:
- * sizeof(ec_host_request): 8
- * sizeof(ec_params_flash_write): 8
- * payload 512
- */
-#define SHI_MAX_REQUEST_SIZE CONFIG_CROS_SHI_MAX_REQUEST
-#define SHI_MAX_RESPONSE_SIZE CONFIG_CROS_SHI_MAX_RESPONSE
-
-/*
- * Our input and output msg buffers. These must be large enough for our largest
- * message, including protocol overhead. The pointers after the protocol
- * overhead, as passed to the host command handler, must be 32-bit aligned.
- */
-#define SHI_OUT_START_PAD (4 * (EC_SPI_FRAME_START_LENGTH / 4 + 1))
-#define SHI_OUT_END_PAD (4 * (EC_SPI_PAST_END_LENGTH / 4 + 1))
-static uint8_t out_msg_padded[SHI_OUT_START_PAD + SHI_MAX_RESPONSE_SIZE +
- SHI_OUT_END_PAD] __aligned(4);
-static uint8_t *const out_msg =
- out_msg_padded + SHI_OUT_START_PAD - EC_SPI_FRAME_START_LENGTH;
-static uint8_t in_msg[SHI_MAX_REQUEST_SIZE] __aligned(4);
-
-/* Parameters used by host protocols */
-static struct host_packet shi_packet;
-
-enum cros_shi_npcx_state {
- SHI_STATE_NONE = -1,
- /* SHI not enabled (initial state, and when chipset is off) */
- SHI_STATE_DISABLED = 0,
- /* Ready to receive next request */
- SHI_STATE_READY_TO_RECV,
- /* Receiving request */
- SHI_STATE_RECEIVING,
- /* Processing request */
- SHI_STATE_PROCESSING,
- /* Canceling response since CS deasserted and output NOT_READY byte */
- SHI_STATE_CNL_RESP_NOT_RDY,
- /* Sending response */
- SHI_STATE_SENDING,
- /* Received data is invalid */
- SHI_STATE_BAD_RECEIVED_DATA,
-};
-
-static enum cros_shi_npcx_state state;
-
-/* Device config */
-struct cros_shi_npcx_config {
- /* Serial Host Interface (SHI) base address */
- uintptr_t base;
- /* clock configuration */
- struct npcx_clk_cfg clk_cfg;
- /* pinmux configuration */
- const uint8_t alts_size;
- const struct npcx_alt *alts_list;
- /* SHI IRQ */
- int irq;
- struct npcx_wui shi_cs_wui;
-};
-
-/* SHI bus parameters */
-struct shi_bus_parameters {
- uint8_t *rx_msg; /* Entry pointer of msg rx buffer */
- uint8_t *tx_msg; /* Entry pointer of msg tx buffer */
- volatile uint8_t *rx_buf; /* Entry pointer of receive buffer */
- volatile uint8_t *tx_buf; /* Entry pointer of transmit buffer */
- uint16_t sz_received; /* Size of received data in bytes */
- uint16_t sz_sending; /* Size of sending data in bytes */
- uint16_t sz_request; /* request bytes need to receive */
- uint16_t sz_response; /* response bytes need to receive */
- uint64_t rx_deadline; /* deadline of receiving */
-} shi_params;
-
-static const struct npcx_alt cros_shi_alts[] = NPCX_DT_ALT_ITEMS_LIST(0);
-
-static const struct cros_shi_npcx_config cros_shi_cfg = {
- .base = DT_INST_REG_ADDR(0),
- .clk_cfg = NPCX_DT_CLK_CFG_ITEM(0),
- .alts_size = ARRAY_SIZE(cros_shi_alts),
- .alts_list = cros_shi_alts,
- .irq = DT_INST_IRQN(0),
- .shi_cs_wui = NPCX_DT_WUI_ITEM_BY_NAME(0, shi_cs_wui),
-};
-
-struct cros_shi_npcx_data {
- struct host_packet shi_packet;
- sys_slist_t callbacks;
-};
-
-/* Driver convenience defines */
-#define DRV_CONFIG(dev) ((const struct cros_shi_npcx_config *)(dev)->config)
-#define DRV_DATA(dev) ((struct cros_shi_npcx_data *)(dev)->data)
-#define HAL_INSTANCE(dev) (struct shi_reg *)(DRV_CONFIG(dev)->base)
-
-/* Forward declaration */
-static void cros_shi_npcx_reset_prepare(struct shi_reg *const inst);
-
-/* Read pointer of input or output buffer by consecutive reading */
-static uint32_t shi_read_buf_pointer(struct shi_reg *const inst)
-{
- uint8_t stat;
-
- /* Wait for two consecutive equal values are read */
- do {
- stat = inst->IBUFSTAT;
- } while (stat != inst->IBUFSTAT);
-
- return (uint32_t)stat;
-}
-
-/*
- * Valid offset of SHI output buffer to write.
- * When SIMUL bit is set, IBUFPTR can be used instead of OBUFPTR
- */
-static uint32_t shi_valid_obuf_offset(struct shi_reg *const inst)
-{
- return (shi_read_buf_pointer(inst) + SHI_OUT_PREAMBLE_LENGTH) %
- SHI_OBUF_FULL_SIZE;
-}
-
-/*
- * This routine write SHI next half output buffer from msg buffer
- */
-static void shi_write_half_outbuf(void)
-{
- const uint32_t size =
- MIN(SHI_OBUF_HALF_SIZE,
- shi_params.sz_response - shi_params.sz_sending);
- uint8_t *obuf_ptr = (uint8_t *)shi_params.tx_buf;
- const uint8_t *obuf_end = obuf_ptr + size;
- uint8_t *msg_ptr = shi_params.tx_msg;
-
- /* Fill half output buffer */
- while (obuf_ptr != obuf_end)
- *obuf_ptr++ = *msg_ptr++;
-
- shi_params.sz_sending += size;
- shi_params.tx_buf = obuf_ptr;
- shi_params.tx_msg = msg_ptr;
-}
-
-/*
- * This routine read SHI input buffer to msg buffer until
- * we have received a certain number of bytes
- */
-static int shi_read_inbuf_wait(struct shi_reg *const inst, uint32_t szbytes)
-{
- /* Copy data to msg buffer from input buffer */
- for (uint32_t i = 0; i < szbytes; i++, shi_params.sz_received++) {
- /*
- * If input buffer pointer equals pointer which wants to read,
- * it means data is not ready.
- */
- while (shi_params.rx_buf ==
- inst->IBUF + shi_read_buf_pointer(inst)) {
- if (k_uptime_get() > shi_params.rx_deadline) {
- return 0;
- }
- }
- /* Restore data to msg buffer */
- *shi_params.rx_msg++ = *shi_params.rx_buf++;
- }
- return 1;
-}
-
-/* This routine fills out all SHI output buffer with status byte */
-static void shi_fill_out_status(struct shi_reg *const inst, uint8_t status)
-{
- uint8_t start, end;
- volatile uint8_t *fill_ptr;
- volatile uint8_t *fill_end;
- volatile uint8_t *obuf_end;
-
- /*
- * Disable interrupts in case the interfere by the other interrupts.
- * Use __disable_irq/__enable_irq instead of using irq_lock/irq_unlock
- * here because irq_lock/irq_unlock leave some system exceptions (like
- * SVC, NMI, and faults) still enabled.
- */
- __disable_irq();
-
- /*
- * Fill out output buffer with status byte and leave a gap for PREAMBLE.
- * The gap guarantees the synchronization. The critical section should
- * be done within this gap. No racing happens.
- */
- start = shi_valid_obuf_offset(inst);
- end = (start + SHI_OBUF_FULL_SIZE - SHI_OUT_PREAMBLE_LENGTH) %
- SHI_OBUF_FULL_SIZE;
-
- fill_ptr = inst->OBUF + start;
- fill_end = inst->OBUF + end;
- obuf_end = inst->OBUF + SHI_OBUF_FULL_SIZE;
- while (fill_ptr != fill_end) {
- *fill_ptr++ = status;
- if (fill_ptr == obuf_end)
- fill_ptr = inst->OBUF;
- }
-
- /* End of critical section */
- __enable_irq();
-}
-
-/* This routine handles shi received unexpected data */
-static void shi_bad_received_data(struct shi_reg *const inst)
-{
- /* State machine mismatch, timeout, or protocol we can't handle. */
- shi_fill_out_status(inst, EC_SPI_RX_BAD_DATA);
- state = SHI_STATE_BAD_RECEIVED_DATA;
-
- DEBUG_CPRINTF("BAD-");
- DEBUG_CPRINTF("in_msg=[");
- for (uint32_t i = 0; i < shi_params.sz_received; i++)
- DEBUG_CPRINTF("%02x ", in_msg[i]);
- DEBUG_CPRINTF("]\n");
-
- /* Reset shi's state machine for error recovery */
- cros_shi_npcx_reset_prepare(inst);
-
- DEBUG_CPRINTF("END\n");
-}
-
-/*
- * This routine write SHI output buffer from msg buffer over halt of it.
- * It make sure we have enough time to handle next operations.
- */
-static void shi_write_first_pkg_outbuf(struct shi_reg *const inst,
- uint16_t szbytes)
-{
- uint8_t size, offset;
- volatile uint8_t *obuf_ptr;
- volatile uint8_t *obuf_end;
- uint8_t *msg_ptr;
- uint32_t half_buf_remain; /* Remains in half buffer are free to write */
-
- /* Start writing at our current OBUF position */
- offset = shi_valid_obuf_offset(inst);
- obuf_ptr = inst->OBUF + offset;
- msg_ptr = shi_params.tx_msg;
-
- /* Fill up to OBUF mid point, or OBUF end */
- half_buf_remain = SHI_OBUF_HALF_SIZE - (offset % SHI_OBUF_HALF_SIZE);
- size = MIN(half_buf_remain, szbytes - shi_params.sz_sending);
- obuf_end = obuf_ptr + size;
- while (obuf_ptr != obuf_end)
- *obuf_ptr++ = *msg_ptr++;
-
- /* Track bytes sent for later accounting */
- shi_params.sz_sending += size;
-
- /* Write data to beginning of OBUF if we've reached the end */
- if (obuf_ptr == inst->OBUF + SHI_IBUF_FULL_SIZE)
- obuf_ptr = inst->OBUF;
-
- /* Fill next half output buffer */
- size = MIN(SHI_OBUF_HALF_SIZE, szbytes - shi_params.sz_sending);
- obuf_end = obuf_ptr + size;
- while (obuf_ptr != obuf_end)
- *obuf_ptr++ = *msg_ptr++;
-
- /* Track bytes sent / last OBUF position written for later accounting */
- shi_params.sz_sending += size;
- shi_params.tx_buf = obuf_ptr;
- shi_params.tx_msg = msg_ptr;
-}
-
-/**
- * Called to send a response back to the host.
- *
- * Some commands can continue for a while. This function is called by
- * host_command task after processing request is completed. It fills up the
- * FIFOs with response package and the remaining data is handled in shi's ISR.
- */
-static void shi_send_response_packet(struct host_packet *pkt)
-{
- struct shi_reg *const inst = (struct shi_reg *)(cros_shi_cfg.base);
-
- /*
- * Disable interrupts. This routine is not called from interrupt
- * context and buffer underrun will likely occur if it is
- * preempted after writing its initial reply byte. Also, we must be
- * sure our state doesn't unexpectedly change, in case we're expected
- * to take RESP_NOT_RDY actions.
- */
- __disable_irq();
-
- if (state == SHI_STATE_PROCESSING) {
- /* Append our past-end byte, which we reserved space for. */
- ((uint8_t *)pkt->response)[pkt->response_size] =
- EC_SPI_PAST_END;
-
- /* Computing sending bytes of response */
- shi_params.sz_response =
- pkt->response_size + SHI_PROTO3_OVERHEAD;
-
- /* Start to fill output buffer with msg buffer */
- shi_write_first_pkg_outbuf(inst, shi_params.sz_response);
- /* Transmit the reply */
- state = SHI_STATE_SENDING;
- DEBUG_CPRINTF("SND-");
- } else if (state == SHI_STATE_CNL_RESP_NOT_RDY) {
- /*
- * If we're not processing, then the AP has already terminated
- * the transaction, and won't be listening for a response.
- * Reset state machine for next transaction.
- */
- cros_shi_npcx_reset_prepare(inst);
- DEBUG_CPRINTF("END\n");
- } else
- DEBUG_CPRINTS("Unexpected state %d in response handler", state);
-
- __enable_irq();
-}
-
-void shi_handle_host_package(struct shi_reg *const inst)
-{
- uint32_t sz_inbuf_int = shi_params.sz_request / SHI_IBUF_HALF_SIZE;
- uint32_t cnt_inbuf_int = shi_params.sz_received / SHI_IBUF_HALF_SIZE;
-
- if (sz_inbuf_int - cnt_inbuf_int)
- /* Need to receive data from buffer */
- return;
- uint32_t remain_bytes = shi_params.sz_request - shi_params.sz_received;
-
- /* Read remaining bytes from input buffer */
- if (!shi_read_inbuf_wait(inst, remain_bytes))
- return shi_bad_received_data(inst);
-
- /* Move to processing state */
- state = SHI_STATE_PROCESSING;
- DEBUG_CPRINTF("PRC-");
-
- /* Fill output buffer to indicate we`re processing request */
- shi_fill_out_status(inst, EC_SPI_PROCESSING);
-
- /* Set up parameters for host request */
- shi_packet.send_response = shi_send_response_packet;
-
- shi_packet.request = in_msg;
- shi_packet.request_temp = NULL;
- shi_packet.request_max = sizeof(in_msg);
- shi_packet.request_size = shi_params.sz_request;
-
- /* Put FRAME_START in first byte */
- out_msg[0] = EC_SPI_FRAME_START;
- shi_packet.response = out_msg + EC_SPI_FRAME_START_LENGTH;
-
- /* Reserve space for frame start and trailing past-end byte */
- shi_packet.response_max = SHI_MAX_RESPONSE_SIZE;
- shi_packet.response_size = 0;
- shi_packet.driver_result = EC_RES_SUCCESS;
-
- /* Go to common layer to handle request */
- host_packet_receive(&shi_packet);
-}
-
-static void shi_parse_header(struct shi_reg *const inst)
-{
- /* We're now inside a transaction */
- state = SHI_STATE_RECEIVING;
- DEBUG_CPRINTF("RV-");
-
- /* Setup deadline time for receiving */
- shi_params.rx_deadline = k_uptime_get() + SHI_CMD_RX_TIMEOUT_MS;
-
- /* Wait for version, command, length bytes */
- if (!shi_read_inbuf_wait(inst, 3))
- return shi_bad_received_data(inst);
-
- if (in_msg[0] == EC_HOST_REQUEST_VERSION) {
- /* Protocol version 3 */
- struct ec_host_request *r = (struct ec_host_request *)in_msg;
- int pkt_size;
- /*
- * If request is over half of input buffer,
- * we need to modified the algorithm again.
- */
- __ASSERT_NO_MSG(sizeof(*r) < SHI_IBUF_HALF_SIZE);
-
- /* Wait for the rest of the command header */
- if (!shi_read_inbuf_wait(inst, sizeof(*r) - 3))
- return shi_bad_received_data(inst);
-
- /* Check how big the packet should be */
- pkt_size = host_request_expected_size(r);
- if (pkt_size == 0 || pkt_size > sizeof(in_msg))
- return shi_bad_received_data(inst);
-
- /* Computing total bytes need to receive */
- shi_params.sz_request = pkt_size;
-
- shi_handle_host_package(inst);
- } else {
- /* Invalid version number */
- return shi_bad_received_data(inst);
- }
-}
-
-static void shi_sec_ibf_int_enable(struct shi_reg *const inst, int enable)
-{
- if (enable) {
- /* Setup IBUFLVL2 threshold and enable it */
- inst->SHICFG5 |= BIT(NPCX_SHICFG5_IBUFLVL2DIS);
- SET_FIELD(inst->SHICFG5, NPCX_SHICFG5_IBUFLVL2,
- SHI_IBUFLVL2_THRESHOLD);
- inst->SHICFG5 &= ~BIT(NPCX_SHICFG5_IBUFLVL2DIS);
- /* Enable IBHF2 event */
- inst->EVENABLE2 |= BIT(NPCX_EVENABLE2_IBHF2EN);
- } else {
- /* Disable IBHF2 event first */
- inst->EVENABLE2 &= ~BIT(NPCX_EVENABLE2_IBHF2EN);
- /* Disable IBUFLVL2 and set threshold back to zero */
- inst->SHICFG5 |= BIT(NPCX_SHICFG5_IBUFLVL2DIS);
- SET_FIELD(inst->SHICFG5, NPCX_SHICFG5_IBUFLVL2, 0);
- }
-}
-
-/* This routine copies SHI half input buffer data to msg buffer */
-static void shi_read_half_inbuf(void)
-{
- /*
- * Copy to read buffer until reaching middle/top address of
- * input buffer or completing receiving data
- */
- do {
- /* Restore data to msg buffer */
- *shi_params.rx_msg++ = *shi_params.rx_buf++;
- shi_params.sz_received++;
- } while (shi_params.sz_received % SHI_IBUF_HALF_SIZE &&
- shi_params.sz_received != shi_params.sz_request);
-}
-
-/*
- * Avoid spamming the console with prints every IBF / IBHF interrupt, if
- * we find ourselves in an unexpected state.
- */
-static enum cros_shi_npcx_state last_error_state = SHI_STATE_NONE;
-
-static void log_unexpected_state(char *isr_name)
-{
- if (state != last_error_state)
- DEBUG_CPRINTF("Unexpected state %d in %s ISR", state, isr_name);
- last_error_state = state;
-}
-
-static void shi_handle_cs_assert(struct shi_reg *const inst)
-{
- /* If not enabled, ignore glitches on SHI_CS_L */
- if (state == SHI_STATE_DISABLED)
- return;
-
- /* NOT_READY should be sent and there're no spi transaction now. */
- if (state == SHI_STATE_CNL_RESP_NOT_RDY)
- return;
-
- /* Chip select is low = asserted */
- if (state != SHI_STATE_READY_TO_RECV) {
- /* State machine should be reset in EVSTAT_EOR ISR */
- DEBUG_CPRINTF("Unexpected state %d in CS ISR", state);
- return;
- }
-
- DEBUG_CPRINTF("CSL-");
-
- /*
- * Clear possible EOR event from previous transaction since it's
- * irrelevant now that CS is re-asserted.
- */
- inst->EVSTAT = BIT(NPCX_EVSTAT_EOR);
-
- /* Do not deep sleep during SHI transaction */
- disable_sleep(SLEEP_MASK_SPI);
-}
-
-static void shi_handle_cs_deassert(struct shi_reg *const inst)
-{
- /*
- * If the buffer is still used by the host command.
- * Change state machine for response handler.
- */
- if (state == SHI_STATE_PROCESSING) {
- /*
- * Mark not ready to prevent the other
- * transaction immediately
- */
- shi_fill_out_status(inst, EC_SPI_NOT_READY);
-
- state = SHI_STATE_CNL_RESP_NOT_RDY;
-
- /*
- * Disable SHI interrupt, it will remain disabled
- * until shi_send_response_packet() is called and
- * CS is asserted for a new transaction.
- */
- irq_disable(DT_INST_IRQN(0));
-
- DEBUG_CPRINTF("CNL-");
- return;
- /* Next transaction but we're not ready */
- } else if (state == SHI_STATE_CNL_RESP_NOT_RDY) {
- return;
- }
-
- /* Error state for checking*/
- if (state != SHI_STATE_SENDING) {
- log_unexpected_state("CSNRE");
- }
- /* reset SHI and prepare to next transaction again */
- cros_shi_npcx_reset_prepare(inst);
- DEBUG_CPRINTF("END\n");
-}
-
-static void shi_handle_input_buf_half_full(struct shi_reg *const inst)
-{
- if (state == SHI_STATE_RECEIVING) {
- /* Read data from input to msg buffer */
- shi_read_half_inbuf();
- return shi_handle_host_package(inst);
- } else if (state == SHI_STATE_SENDING) {
- /* Write data from msg buffer to output buffer */
- if (shi_params.tx_buf == inst->OBUF + SHI_OBUF_FULL_SIZE) {
- /* Write data from bottom address again */
- shi_params.tx_buf = inst->OBUF;
- return shi_write_half_outbuf();
- } else /* ignore it */
- return;
- } else if (state == SHI_STATE_PROCESSING) {
- /* Wait for host to handle request */
- } else {
- /* Unexpected status */
- log_unexpected_state("IBHF");
- }
-}
-
-static void shi_handle_input_buf_full(struct shi_reg *const inst)
-{
- if (state == SHI_STATE_RECEIVING) {
- /* read data from input to msg buffer */
- shi_read_half_inbuf();
- /* Read to bottom address again */
- shi_params.rx_buf = inst->IBUF;
- return shi_handle_host_package(inst);
- } else if (state == SHI_STATE_SENDING) {
- /* Write data from msg buffer to output buffer */
- if (shi_params.tx_buf == inst->OBUF + SHI_OBUF_HALF_SIZE)
- return shi_write_half_outbuf();
- else /* ignore it */
- return;
- } else if (state == SHI_STATE_PROCESSING) {
- /* Wait for host to handle request */
- return;
- }
- /* Unexpected status */
- log_unexpected_state("IBF");
-}
-
-static void cros_shi_npcx_isr(const struct device *dev)
-{
- uint8_t stat;
- uint8_t stat2;
- struct shi_reg *const inst = HAL_INSTANCE(dev);
-
- /* Read status register and clear interrupt status early */
- stat = inst->EVSTAT;
- inst->EVSTAT = stat;
- stat2 = inst->EVSTAT2;
-
- /* SHI CS pin is asserted in EVSTAT2 */
- if (IS_BIT_SET(stat2, NPCX_EVSTAT2_CSNFE)) {
- /* Clear pending bit of CSNFE */
- inst->EVSTAT2 = BIT(NPCX_EVSTAT2_CSNFE);
- DEBUG_CPRINTF("CSNFE-");
- /*
- * BUSY bit is set when SHI_CS is asserted. If not, leave it for
- * SHI_CS de-asserted event.
- */
- if (!IS_BIT_SET(inst->SHICFG2, NPCX_SHICFG2_BUSY)) {
- DEBUG_CPRINTF("CSNB-");
- return;
- }
- shi_handle_cs_assert(inst);
- }
-
- /*
- * End of data for read/write transaction. i.e. SHI_CS is deasserted.
- * Host completed or aborted transaction
- *
- * EOR has the limitation that it will not be set even if the SHI_CS is
- * deasserted without SPI clocks. The new SHI module introduce the
- * CSNRE bit which will be set when SHI_CS is deasserted regardless of
- * SPI clocks.
- */
- if (IS_BIT_SET(stat2, NPCX_EVSTAT2_CSNRE)) {
- /* Clear pending bit of CSNRE */
- inst->EVSTAT2 = BIT(NPCX_EVSTAT2_CSNRE);
- /*
- * We're not in proper state.
- * Mark not ready to abort next transaction
- */
- DEBUG_CPRINTF("CSH-");
- return shi_handle_cs_deassert(inst);
- }
-
- /*
- * The number of bytes received reaches the size of
- * protocol V3 header(=8) after CS asserted.
- */
- if (IS_BIT_SET(stat2, NPCX_EVSTAT2_IBHF2)) {
- /* Clear IBHF2 */
- inst->EVSTAT2 = BIT(NPCX_EVSTAT2_IBHF2);
- DEBUG_CPRINTF("HDR-");
- /* Disable second IBF interrupt and start to parse header */
- shi_sec_ibf_int_enable(inst, 0);
- shi_parse_header(inst);
- }
-
- /*
- * Indicate input/output buffer pointer reaches the half buffer size.
- * Transaction is processing.
- */
- if (IS_BIT_SET(stat, NPCX_EVSTAT_IBHF)) {
- return shi_handle_input_buf_half_full(inst);
- }
-
- /*
- * Indicate input/output buffer pointer reaches the full buffer size.
- * Transaction is processing.
- */
- if (IS_BIT_SET(stat, NPCX_EVSTAT_IBF)) {
- return shi_handle_input_buf_full(inst);
- }
-}
-
-static void cros_shi_npcx_reset_prepare(struct shi_reg *const inst)
-{
- uint32_t i;
-
- state = SHI_STATE_DISABLED;
-
- irq_disable(DT_INST_IRQN(0));
-
- /* Disable SHI unit to clear all status bits */
- inst->SHICFG1 &= ~BIT(NPCX_SHICFG1_EN);
-
- /* Initialize parameters of next transaction */
- shi_params.rx_msg = in_msg;
- shi_params.tx_msg = out_msg;
- shi_params.rx_buf = inst->IBUF;
- shi_params.tx_buf = inst->IBUF + SHI_OBUF_HALF_SIZE;
- shi_params.sz_received = 0;
- shi_params.sz_sending = 0;
- shi_params.sz_request = 0;
- shi_params.sz_response = 0;
-
- /*
- * Fill output buffer to indicate we`re
- * ready to receive next transaction.
- */
- for (i = 1; i < SHI_OBUF_FULL_SIZE; i++)
- inst->OBUF[i] = EC_SPI_RECEIVING;
- inst->OBUF[0] = EC_SPI_OLD_READY;
-
- /* SHI/Host Write/input buffer wrap-around enable */
- inst->SHICFG1 = BIT(NPCX_SHICFG1_IWRAP) | BIT(NPCX_SHICFG1_WEN) |
- BIT(NPCX_SHICFG1_EN);
-
- state = SHI_STATE_READY_TO_RECV;
- last_error_state = SHI_STATE_NONE;
-
- shi_sec_ibf_int_enable(inst, 1);
- irq_enable(DT_INST_IRQN(0));
-
- /* Allow deep sleep at the end of SHI transaction */
- enable_sleep(SLEEP_MASK_SPI);
-
- DEBUG_CPRINTF("RDY-");
-}
-
-static int cros_shi_npcx_enable(const struct device *dev)
-{
- const struct cros_shi_npcx_config *const config = DRV_CONFIG(dev);
- struct shi_reg *const inst = HAL_INSTANCE(dev);
-
- cros_shi_npcx_reset_prepare(inst);
- npcx_miwu_irq_disable(&config->shi_cs_wui);
-
- /* Configure pin-mux from GPIO to SHI. */
- npcx_pinctrl_mux_configure(config->alts_list, config->alts_size, 1);
-
- NVIC_ClearPendingIRQ(DT_INST_IRQN(0));
- npcx_miwu_irq_enable(&config->shi_cs_wui);
- irq_enable(DT_INST_IRQN(0));
-
- return 0;
-}
-
-static int cros_shi_npcx_disable(const struct device *dev)
-{
- const struct cros_shi_npcx_config *const config = DRV_CONFIG(dev);
-
- state = SHI_STATE_DISABLED;
-
- irq_disable(DT_INST_IRQN(0));
- npcx_miwu_irq_disable(&config->shi_cs_wui);
-
- /* Configure pin-mux from SHI to GPIO. */
- npcx_pinctrl_mux_configure(config->alts_list, config->alts_size, 0);
-
- /*
- * Allow deep sleep again in case CS dropped before ec was
- * informed in hook function and turn off SHI's interrupt in time.
- */
- enable_sleep(SLEEP_MASK_SPI);
-
- return 0;
-}
-
-static int shi_npcx_init(const struct device *dev)
-{
- int ret;
- const struct cros_shi_npcx_config *const config = DRV_CONFIG(dev);
- struct shi_reg *const inst = HAL_INSTANCE(dev);
- const struct device *clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
-
- /* Turn on shi device clock first */
- ret = clock_control_on(clk_dev,
- (clock_control_subsys_t *)&config->clk_cfg);
- if (ret < 0) {
- DEBUG_CPRINTF("Turn on SHI clock fail %d", ret);
- return ret;
- }
-
- /* If booter doesn't set the host interface type */
- if (!NPCX_BOOTER_IS_HIF_TYPE_SET()) {
- npcx_host_interface_sel(NPCX_HIF_TYPE_ESPI_SHI);
- }
-
- /*
- * SHICFG1 (SHI Configuration 1) setting
- * [7] - IWRAP = 1: Wrap input buffer to the first address
- * [6] - CPOL = 0: Sampling on rising edge and output on falling edge
- * [5] - DAS = 0: return STATUS reg data after Status command
- * [4] - AUTOBE = 0: Automatically update the OBES bit in STATUS reg
- * [3] - AUTIBF = 0: Automatically update the IBFS bit in STATUS reg
- * [2] - WEN = 0: Enable host write to input buffer
- * [1] - Reserved 0
- * [0] - ENABLE = 0: Disable SHI at the beginning
- */
- inst->SHICFG1 = 0x80;
-
- /*
- * SHICFG2 (SHI Configuration 2) setting
- * [7] - Reserved 0
- * [6] - REEVEN = 0: Restart events are not used
- * [5] - Reserved 0
- * [4] - REEN = 0: Restart transactions are not used
- * [3] - SLWU = 0: Seem-less wake-up is enabled by default
- * [2] - ONESHOT= 0: WEN is cleared at the end of a write transaction
- * [1] - BUSY = 0: SHI bus is busy 0: idle.
- * [0] - SIMUL = 1: Turn on simultaneous Read/Write
- */
- inst->SHICFG2 = 0x01;
-
- /*
- * EVENABLE (Event Enable) setting
- * [7] - IBOREN = 0: Input buffer overrun interrupt enable
- * [6] - STSREN = 0: status read interrupt disable
- * [5] - EOWEN = 0: End-of-Data for Write Transaction Interrupt Enable
- * [4] - EOREN = 1: End-of-Data for Read Transaction Interrupt Enable
- * [3] - IBHFEN = 1: Input Buffer Half Full Interrupt Enable
- * [2] - IBFEN = 1: Input Buffer Full Interrupt Enable
- * [1] - OBHEEN = 0: Output Buffer Half Empty Interrupt Enable
- * [0] - OBEEN = 0: Output Buffer Empty Interrupt Enable
- */
- inst->EVENABLE = 0x1C;
-
- /*
- * EVENABLE2 (Event Enable 2) setting
- * [2] - CSNFEEN = 1: SHI_CS Falling Edge Interrupt Enable
- * [1] - CSNREEN = 1: SHI_CS Rising Edge Interrupt Enable
- * [0] - IBHF2EN = 0: Input Buffer Half Full 2 Interrupt Enable
- */
- inst->EVENABLE2 = 0x06;
-
- /* Clear SHI events status register */
- inst->EVSTAT = 0xff;
-
- npcx_miwu_interrupt_configure(&config->shi_cs_wui, NPCX_MIWU_MODE_EDGE,
- NPCX_MIWU_TRIG_LOW);
- /* SHI interrupt installation */
- IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
- cros_shi_npcx_isr, DEVICE_DT_INST_GET(0), 0);
-
- return ret;
-}
-
-static const struct cros_shi_driver_api cros_shi_npcx_driver_api = {
- .enable = cros_shi_npcx_enable,
- .disable = cros_shi_npcx_disable,
-};
-
-static struct cros_shi_npcx_data cros_shi_data;
-DEVICE_DT_INST_DEFINE(0, shi_npcx_init, /* pm_control_fn= */ NULL,
- &cros_shi_data, &cros_shi_cfg, PRE_KERNEL_1,
- CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
- &cros_shi_npcx_driver_api);
-
-/* KBS register structure check */
-NPCX_REG_SIZE_CHECK(shi_reg, 0x120);
-NPCX_REG_OFFSET_CHECK(shi_reg, SHICFG1, 0x001);
-NPCX_REG_OFFSET_CHECK(shi_reg, EVENABLE, 0x005);
-NPCX_REG_OFFSET_CHECK(shi_reg, IBUFSTAT, 0x00a);
-NPCX_REG_OFFSET_CHECK(shi_reg, EVENABLE2, 0x010);
-NPCX_REG_OFFSET_CHECK(shi_reg, OBUF, 0x020);
-NPCX_REG_OFFSET_CHECK(shi_reg, IBUF, 0x0A0);
diff --git a/zephyr/drivers/cros_system/CMakeLists.txt b/zephyr/drivers/cros_system/CMakeLists.txt
deleted file mode 100644
index 733b8be450..0000000000
--- a/zephyr/drivers/cros_system/CMakeLists.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-zephyr_library_sources_ifdef(CONFIG_CROS_SYSTEM_IT8XXX2 cros_system_it8xxx2.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_SYSTEM_NPCX cros_system_npcx.c)
diff --git a/zephyr/drivers/cros_system/Kconfig b/zephyr/drivers/cros_system/Kconfig
deleted file mode 100644
index c5d98b6081..0000000000
--- a/zephyr/drivers/cros_system/Kconfig
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-menuconfig CROS_SYSTEM_NPCX
- bool "Nuvoton NPCX cros system driver"
- depends on SOC_FAMILY_NPCX
- default y
- help
- This option enables the cros system driver for the NPCX family of
- processors. Currently, Zephyr doesn't provide the system related API.
- The cros system driver provides the low-level driver related to
- chromium ec system functionality.
-
-if CROS_SYSTEM_NPCX
-
-config CROS_SYSTEM_NPCX_INIT_PRIORITY
- int "cros_system npcx initialization priority"
- default 10
- range 10 19
- help
- This sets the npcx cros_system driver initialization priority. The
- cros_system driver provides access to the NPCX reset cause and must be
- higher priority than CONFIG_SYSTEM_PRE_INIT_PRIORITY.
-
-endif # CROS_SYSTEM_NPCX
-
-config CROS_SYSTEM_IT8XXX2
- bool "ITE IT8XXX2 cros system driver"
- depends on SOC_FAMILY_RISCV_ITE
- default y
- help
- This option enables the cros system driver for the it8xxx2 family of
- processors.
-
-if CROS_SYSTEM_IT8XXX2
-
-config CROS_SYSTEM_IT8XXX2_INIT_PRIORITY
- int "cros_system it8xxx2 initialization priority"
- default 10
- help
- This sets the it8xxx2 cros_system driver initialization priority.
- The cros_system driver provides access to the it8xxx2 reset cause
- and must be higher priority than
- CONFIG_PLATFORM_EC_SYSTEM_PRE_INIT_PRIORITY.
-
-endif # CROS_SYSTEM_IT8XXX2
diff --git a/zephyr/drivers/cros_system/cros_system_it8xxx2.c b/zephyr/drivers/cros_system/cros_system_it8xxx2.c
deleted file mode 100644
index 5731dcf984..0000000000
--- a/zephyr/drivers/cros_system/cros_system_it8xxx2.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT ite_it8xxx2_gctrl
-
-#include <device.h>
-#include <drivers/cros_system.h>
-#include <logging/log.h>
-#include <soc.h>
-#include <soc/ite_it8xxx2/reg_def_cros.h>
-
-#include "gpio.h"
-#include "system.h"
-#include "util.h"
-
-LOG_MODULE_REGISTER(cros_system, LOG_LEVEL_ERR);
-
-#define GCTRL_IT8XXX2_REG_BASE \
- ((struct gctrl_it8xxx2_regs *)DT_INST_REG_ADDR(0))
-
-#define WDT_IT8XXX2_REG_BASE \
- ((struct wdt_it8xxx2_regs *)DT_REG_ADDR(DT_NODELABEL(twd0)))
-
-static const char *cros_system_it8xxx2_get_chip_vendor(const struct device *dev)
-{
- ARG_UNUSED(dev);
-
- return "ite";
-}
-
-static uint32_t system_get_chip_id(void)
-{
- struct gctrl_it8xxx2_regs *const gctrl_base = GCTRL_IT8XXX2_REG_BASE;
-
- return (gctrl_base->GCTRL_ECHIPID1 << 16) |
- (gctrl_base->GCTRL_ECHIPID2 << 8) |
- gctrl_base->GCTRL_ECHIPID3;
-}
-
-static uint8_t system_get_chip_version(void)
-{
- struct gctrl_it8xxx2_regs *const gctrl_base = GCTRL_IT8XXX2_REG_BASE;
-
- /* bit[3-0], chip version */
- return gctrl_base->GCTRL_ECHIPVER & 0x0F;
-}
-
-static const char *cros_system_it8xxx2_get_chip_name(const struct device *dev)
-{
- ARG_UNUSED(dev);
-
- static char buf[8] = {'i', 't'};
- uint32_t chip_id = system_get_chip_id();
- int num = 4;
-
- for (int n = 2; num >= 0; n++, num--)
- snprintf(buf+n, (sizeof(buf)-n), "%x",
- chip_id >> (num * 4) & 0xF);
-
- return buf;
-}
-
-static const char *cros_system_it8xxx2_get_chip_revision(const struct device
- *dev)
-{
- ARG_UNUSED(dev);
-
- static char buf[3];
- uint8_t rev = system_get_chip_version();
-
- snprintf(buf, sizeof(buf), "%1xx", rev+0xa);
-
- return buf;
-}
-
-static int cros_system_it8xxx2_get_reset_cause(const struct device *dev)
-{
- ARG_UNUSED(dev);
- struct gctrl_it8xxx2_regs *const gctrl_base = GCTRL_IT8XXX2_REG_BASE;
- /* system reset flag */
- uint32_t system_flags = chip_read_reset_flags();
- int chip_reset_cause = 0;
- uint8_t raw_reset_cause = gctrl_base->GCTRL_RSTS & IT8XXX2_GCTRL_LRS;
- uint8_t raw_reset_cause2 = gctrl_base->GCTRL_SPCTRL4 &
- (IT8XXX2_GCTRL_LRSIWR | IT8XXX2_GCTRL_LRSIPWRSWTR |
- IT8XXX2_GCTRL_LRSIPGWR);
-
- /* Clear reset cause. */
- gctrl_base->GCTRL_RSTS |= IT8XXX2_GCTRL_LRS;
- gctrl_base->GCTRL_SPCTRL4 |= (IT8XXX2_GCTRL_LRSIWR |
- IT8XXX2_GCTRL_LRSIPWRSWTR | IT8XXX2_GCTRL_LRSIPGWR);
-
- /* Determine if watchdog reset or power on reset. */
- if (raw_reset_cause & IT8XXX2_GCTRL_IWDTR) {
- system_flags |= EC_RESET_FLAG_WATCHDOG;
- chip_reset_cause = WATCHDOG_RST;
- } else if (raw_reset_cause < 2) {
- system_flags |= EC_RESET_FLAG_POWER_ON;
- chip_reset_cause = POWERUP;
- }
- /* Determine reset-pin reset. */
- if (raw_reset_cause2 & IT8XXX2_GCTRL_LRSIWR) {
- system_flags |= EC_RESET_FLAG_RESET_PIN;
- chip_reset_cause = VCC1_RST_PIN;
- }
-
- /* watchdog module triggers these reset */
- if (system_flags & (EC_RESET_FLAG_HARD | EC_RESET_FLAG_SOFT))
- system_flags &= ~EC_RESET_FLAG_WATCHDOG;
-
- /* Set the system reset flags. */
- system_set_reset_flags(system_flags);
-
- return chip_reset_cause;
-}
-
-static int cros_system_it8xxx2_init(const struct device *dev)
-{
- struct gctrl_it8xxx2_regs *const gctrl_base = GCTRL_IT8XXX2_REG_BASE;
-
- /* System triggers a soft reset by default (command: reboot). */
- gctrl_base->GCTRL_ETWDUARTCR &= ~IT8XXX2_GCTRL_ETWD_HW_RST_EN;
-
- return 0;
-}
-
-static int cros_system_it8xxx2_soc_reset(const struct device *dev)
-{
- struct gctrl_it8xxx2_regs *const gctrl_base = GCTRL_IT8XXX2_REG_BASE;
- struct wdt_it8xxx2_regs *const wdt_base = WDT_IT8XXX2_REG_BASE;
- uint32_t chip_reset_flags = chip_read_reset_flags();
-
- /* Disable interrupts to avoid task swaps during reboot. */
- interrupt_disable_all();
-
- if (chip_reset_flags & (EC_RESET_FLAG_HARD | EC_RESET_FLAG_HIBERNATE))
- gctrl_base->GCTRL_ETWDUARTCR |= IT8XXX2_GCTRL_ETWD_HW_RST_EN;
-
- /*
- * Writing invalid key to watchdog module triggers a soft or hardware
- * reset. It depends on the setting of bit0 at ETWDUARTCR register.
- */
- wdt_base->ETWCFG |= IT8XXX2_WDT_EWDKEYEN;
- wdt_base->EWDKEYR = 0x00;
-
- /* Spin and wait for reboot */
- while (1)
- ;
-
- /* Should never return */
- return 0;
-}
-
-static int cros_system_it8xxx2_hibernate(const struct device *dev,
- uint32_t seconds,
- uint32_t microseconds)
-{
- struct wdt_it8xxx2_regs *const wdt_base = WDT_IT8XXX2_REG_BASE;
-
- /* Disable all interrupts. */
- interrupt_disable_all();
-
- /* Save and disable interrupts */
- if (IS_ENABLED(CONFIG_ITE_IT8XXX2_INTC))
- ite_intc_save_and_disable_interrupts();
-
- /* bit5: watchdog is disabled. */
- wdt_base->ETWCTRL |= IT8XXX2_WDT_EWDSCEN;
-
- /*
- * Setup GPIOs for hibernate. On some boards, it's possible that this
- * may not return at all. On those boards, power to the EC is likely
- * being turn off entirely.
- */
- if (board_hibernate_late) {
- /*
- * Set reset flag in case board_hibernate_late() doesn't
- * return.
- */
- chip_save_reset_flags(EC_RESET_FLAG_HIBERNATE);
- board_hibernate_late();
- }
-
- if (seconds || microseconds) {
- /*
- * Convert milliseconds(or at least 1 ms) to 32 Hz
- * free run timer count for hibernate.
- */
- uint32_t c = (seconds * 1000 + microseconds / 1000 + 1) *
- 32 / 1000;
-
- /* Enable a 32-bit timer and clock source is 32 Hz */
- /* Disable external timer x */
- IT8XXX2_EXT_CTRLX(FREE_RUN_TIMER) &= ~IT8XXX2_EXT_ETXEN;
- irq_disable(FREE_RUN_TIMER_IRQ);
- IT8XXX2_EXT_PSRX(FREE_RUN_TIMER) = EXT_PSR_32;
- IT8XXX2_EXT_CNTX(FREE_RUN_TIMER) = c & FREE_RUN_TIMER_MAX_CNT;
- /* Enable and re-start external timer x */
- IT8XXX2_EXT_CTRLX(FREE_RUN_TIMER) |=
- (IT8XXX2_EXT_ETXEN | IT8XXX2_EXT_ETXRST);
- irq_enable(FREE_RUN_TIMER_IRQ);
- }
-
- static const int wakeup_pin_list[] = {
-#if DT_NODE_EXISTS(SYSTEM_DT_NODE_HIBERNATE_CONFIG)
- UTIL_LISTIFY(SYSTEM_DT_NODE_WAKEUP_PIN_LEN,
- SYSTEM_DT_WAKEUP_GPIO_ENUM_BY_IDX, _)
-#endif
- };
-
- /* Reconfigure wake-up GPIOs */
- for (int i = 0; i < ARRAY_SIZE(wakeup_pin_list); i++)
- /* Re-enable interrupt for wake-up inputs */
- gpio_enable_interrupt(wakeup_pin_list[i]);
-
- /* EC sleep mode */
- chip_pll_ctrl(CHIP_PLL_SLEEP);
-
- /* Chip sleep and wait timer wake it up */
- __asm__ volatile ("wfi");
-
- /* Reset EC when wake up from sleep mode (system hibernate) */
- system_reset(SYSTEM_RESET_HIBERNATE);
-
- return 0;
-}
-
-static const struct cros_system_driver_api cros_system_driver_it8xxx2_api = {
- .get_reset_cause = cros_system_it8xxx2_get_reset_cause,
- .soc_reset = cros_system_it8xxx2_soc_reset,
- .hibernate = cros_system_it8xxx2_hibernate,
- .chip_vendor = cros_system_it8xxx2_get_chip_vendor,
- .chip_name = cros_system_it8xxx2_get_chip_name,
- .chip_revision = cros_system_it8xxx2_get_chip_revision,
-};
-
-#if CONFIG_CROS_SYSTEM_IT8XXX2_INIT_PRIORITY >= \
- CONFIG_PLATFORM_EC_SYSTEM_PRE_INIT_PRIORITY
-#error "CROS_SYSTEM must initialize before the SYSTEM_PRE initialization"
-#endif
-DEVICE_DEFINE(cros_system_it8xxx2_0, "CROS_SYSTEM", cros_system_it8xxx2_init,
- NULL, NULL, NULL, PRE_KERNEL_1,
- CONFIG_CROS_SYSTEM_IT8XXX2_INIT_PRIORITY,
- &cros_system_driver_it8xxx2_api);
diff --git a/zephyr/drivers/cros_system/cros_system_npcx.c b/zephyr/drivers/cros_system/cros_system_npcx.c
deleted file mode 100644
index e3d3bc29b2..0000000000
--- a/zephyr/drivers/cros_system/cros_system_npcx.c
+++ /dev/null
@@ -1,556 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <arch/arm/aarch32/cortex_m/cmsis.h>
-#include <drivers/cros_system.h>
-#include <drivers/gpio.h>
-#include <drivers/watchdog.h>
-#include <logging/log.h>
-#include <soc.h>
-#include <soc/nuvoton_npcx/reg_def_cros.h>
-#include <sys/util.h>
-
-#include "gpio.h"
-#include "rom_chip.h"
-#include "soc_gpio.h"
-#include "soc_miwu.h"
-#include "system.h"
-
-LOG_MODULE_REGISTER(cros_system, LOG_LEVEL_ERR);
-
-/* Driver config */
-struct cros_system_npcx_config {
- /* hardware module base address */
- uintptr_t base_scfg;
- uintptr_t base_twd;
- uintptr_t base_mswc;
-};
-
-/* Driver data */
-struct cros_system_npcx_data {
- int reset; /* reset cause */
-};
-
-/* Driver convenience defines */
-#define DRV_CONFIG(dev) ((const struct cros_system_npcx_config *)(dev)->config)
-
-#define HAL_SCFG_INST(dev) (struct scfg_reg *)(DRV_CONFIG(dev)->base_scfg)
-#define HAL_TWD_INST(dev) (struct twd_reg *)(DRV_CONFIG(dev)->base_twd)
-#define HAL_MSWC_INST(dev) (struct mswc_reg *)(DRV_CONFIG(dev)->base_mswc)
-
-#define DRV_DATA(dev) ((struct cros_system_npcx_data *)(dev)->data)
-
-#define SYSTEM_DT_NODE_SOC_ID_CONFIG DT_INST(0, nuvoton_npcx_soc_id)
-
-/* Chip info devicetree data */
-#define NPCX_FAMILY_ID DT_PROP(SYSTEM_DT_NODE_SOC_ID_CONFIG, family_id)
-
-#define NPCX_CHIP_ID DT_PROP(SYSTEM_DT_NODE_SOC_ID_CONFIG, chip_id)
-
-#define NPCX_DEVICE_ID DT_PROP(SYSTEM_DT_NODE_SOC_ID_CONFIG, device_id)
-
-#define NPCX_REVISION_ADDR \
- DT_PROP_BY_IDX(SYSTEM_DT_NODE_SOC_ID_CONFIG, revision_reg, 0)
-#define NPCX_REVISION_LEN \
- DT_PROP_BY_IDX(SYSTEM_DT_NODE_SOC_ID_CONFIG, revision_reg, 1)
-
-/* RAM block size in npcx family (Unit: bytes) */
-#define NPCX_RAM_BLOCK_SIZE (32 * 1024)
-/* RAM block number in npcx7 series */
-
-/* Calculate the number of RAM blocks:
- * total RAM size = code ram + data ram + extra 2K for ROM functions
- * divided by the block size 32k.
- */
-#define DATA_RAM_SIZE DT_REG_SIZE(DT_NODELABEL(sram0))
-#define CODE_RAM_SIZE DT_REG_SIZE(DT_NODELABEL(flash0))
-#define NPCX_RAM_BLOCK_COUNT \
- ((DATA_RAM_SIZE + CODE_RAM_SIZE + KB(2)) / NPCX_RAM_BLOCK_SIZE)
-
-/* Valid bit-depth of RAM block Power-Down control (RAM_PD) registers. Use its
- * mask to power down all unnecessary RAM blocks before hibernating.
- */
-#define NPCX_RAM_PD_DEPTH DT_PROP(DT_NODELABEL(pcc), ram_pd_depth)
-#define NPCX_RAM_BLOCK_PD_MASK (BIT(NPCX_RAM_PD_DEPTH) - 1)
-
-/* Get saved reset flag address in battery-backed ram */
-#define BBRAM_SAVED_RESET_FLAG_ADDR \
- (DT_REG_ADDR(DT_INST(0, nuvoton_npcx_bbram)) + \
- DT_PROP(DT_PATH(named_bbram_regions, saved_reset_flags), offset))
-
-/* Soc specific system local functions */
-static int system_npcx_watchdog_stop(void)
-{
- if (IS_ENABLED(CONFIG_WATCHDOG)) {
- const struct device *wdt_dev = DEVICE_DT_GET(
- DT_NODELABEL(twd0));
- if (!device_is_ready(wdt_dev)) {
- LOG_ERR("Error: device %s is not ready", wdt_dev->name);
- return -ENODEV;
- }
-
- wdt_disable(wdt_dev);
- }
-
- return 0;
-}
-
-static void system_npcx_set_flash_pins_tri_state(const struct device *dev)
-{
- struct scfg_reg *const inst_scfg = HAL_SCFG_INST(dev);
-
- inst_scfg->DEVCNT |= BIT(NPCX_DEVCNT_F_SPI_TRIS);
-}
-
-static void system_npcx_init_watchdog_reset(const struct device *dev)
-{
- struct twd_reg *const inst_twd = HAL_TWD_INST(dev);
-
- /* Enable early touch */
- inst_twd->T0CSR &= ~BIT(NPCX_T0CSR_TESDIS);
- /* watchdog touched by writing 5Ch to WDSDM */
- inst_twd->TWCFG |= BIT(NPCX_TWCFG_WDSDME);
-}
-
-static void system_npcx_turn_off_adc(void)
-{
- struct adc_reg *const inst_adc =
- (struct adc_reg *)(DT_REG_ADDR(DT_INST(0, nuvoton_npcx_adc)));
-
- inst_adc->ADCCNF = 0;
- /* Wait for 1000 us to make sure conversion is completed. */
- k_busy_wait(1000);
-}
-
-static void system_npcx_turn_off_kernel_timer(void)
-{
- static struct itim32_reg *const evt_tmr =
- (struct itim32_reg *)DT_REG_ADDR_BY_NAME(
- DT_INST(0, nuvoton_npcx_itim_timer), evt_itim);
-
- evt_tmr->ITCTS32 &= ~BIT(NPCX_ITCTSXX_ITEN);
-}
-
-static void system_npcx_disable_instant_wakeup(void)
-{
- struct pmc_reg *const inst_pmc = (struct pmc_reg *)(DT_REG_ADDR_BY_NAME(
- DT_INST(0, nuvoton_npcx_pcc), pmc));
-
- inst_pmc->ENIDL_CTL &= ~BIT(NPCX_ENIDL_CTL_LP_WK_CTL);
-}
-
-static void system_npcx_set_wakeup_gpios_before_hibernate(void)
-{
- const uintptr_t miwu_base[] = {
- DT_REG_ADDR(DT_INST(0, nuvoton_npcx_miwu)),
- DT_REG_ADDR(DT_INST(1, nuvoton_npcx_miwu)),
- DT_REG_ADDR(DT_INST(2, nuvoton_npcx_miwu)),
- };
-
- /* Disable all MIWU inputs before entering hibernate */
- for (int table = 0; table < ARRAY_SIZE(miwu_base); table++) {
- for (int group = 0; group < NPCX_MIWU_GROUP_COUNT; group++) {
- /* Disable all wake-ups */
- NPCX_WKEN(miwu_base[table], group) = 0x00;
- /* Clear all pending bits of wake-ups */
- NPCX_WKPCL(miwu_base[table], group) = 0xFF;
- /*
- * Disable all inputs of wake-ups to prevent leakage
- * caused by input floating.
- */
- NPCX_WKINEN(miwu_base[table], group) = 0x00;
- }
- }
-
- static const int wakeup_pin_list[] = {
-#if DT_NODE_EXISTS(SYSTEM_DT_NODE_HIBERNATE_CONFIG)
- UTIL_LISTIFY(SYSTEM_DT_NODE_WAKEUP_PIN_LEN,
- SYSTEM_DT_WAKEUP_GPIO_ENUM_BY_IDX, _)
-#endif
- };
-
- /* Reconfigure wake-up GPIOs */
- for (int i = 0; i < ARRAY_SIZE(wakeup_pin_list); i++) {
- gpio_reset(wakeup_pin_list[i]);
- /* Re-enable interrupt for wake-up inputs */
- gpio_enable_interrupt(wakeup_pin_list[i]);
- }
-}
-
-/*
- * Hibernate function locates in the last 32K ram block in npcx7 series.
- * Do not use global variables or call functions since we have turned off
- * the other ram blocks.
- */
-noreturn void __keep __attribute__((section(".lfw.hiber")))
-system_npcx_hibernate_by_lfw_in_last_ram(const struct device *dev,
- uint32_t pd_ram_mask)
-{
- /* Modules used for hibernating */
- struct twd_reg *const inst_twd = HAL_TWD_INST(dev);
- struct mtc_reg *const inst_mtc = (struct mtc_reg *)(DT_REG_ADDR(
- DT_INST(0, nuvoton_npcx_cros_mtc)));
- struct pmc_reg *const inst_pmc = (struct pmc_reg *)(DT_REG_ADDR_BY_NAME(
- DT_INST(0, nuvoton_npcx_pcc), pmc));
- uint32_t reset_flags;
- volatile uint8_t *saved_reset_flags =
- (volatile uint8_t *)BBRAM_SAVED_RESET_FLAG_ADDR;
-
- /* Turn off all blocks except last one for better power consumption */
- inst_pmc->RAM_PD[0] = (uint8_t)pd_ram_mask;
- inst_pmc->RAM_PD[1] = (uint8_t)(pd_ram_mask >> 8);
-
- /* Set deep idle mode */
- inst_pmc->PMCSR = BIT(NPCX_PMCSR_IDLE) | BIT(NPCX_PMCSR_DHF);
-
- /* Enter system sleep mode */
- __asm__ volatile("wfi");
-
- /*
- * Mark wake-up reason for hibernate. Do not call bbram utilities
- * directly since the other ram blocks are power down.
- */
- if (IS_BIT_SET(inst_mtc->WTC, NPCX_WTC_PTO)) {
- /* Save wake-up reason as RTC alarm. */
- reset_flags = EC_RESET_FLAG_RTC_ALARM;
- } else {
- /* Otherwise, we treat it as GPIOs wake-up */
- reset_flags = EC_RESET_FLAG_WAKE_PIN;
- }
-
- saved_reset_flags[0] |= reset_flags;
- saved_reset_flags[1] |= reset_flags >> 8;
- saved_reset_flags[2] |= reset_flags >> 16;
- saved_reset_flags[3] |= reset_flags >> 24;
-
- /*
- * The trigger of a watchdog event by a "too early service" condition.
- * When the watchdog is written more than once during three watchdog
- * clock cycle.
- */
- inst_twd->WDSDM = 0x5C;
- inst_twd->WDSDM = 0x5C;
-
- /* Spin and wait for reboot; should never return */
- while (1)
- continue;
-}
-
-static inline int system_npcx_get_ram_blk_by_lfw_addr(char *address)
-{
- return NPCX_RAM_BLOCK_COUNT -
- ceiling_fraction((uint32_t)address -
- CONFIG_CROS_EC_PROGRAM_MEMORY_BASE,
- NPCX_RAM_BLOCK_SIZE);
-}
-
-static void system_npcx_hibernate_by_disable_ram(const struct device *dev,
- uint32_t seconds,
- uint32_t microseconds)
-{
- /* Get 32kb ram block order of lfw function */
- extern char __lfw_text_start[], __lfw_text_end[];
- int lfw_block = system_npcx_get_ram_blk_by_lfw_addr(__lfw_text_start);
- uint32_t pd_ram_mask = ~BIT(lfw_block) & NPCX_RAM_BLOCK_PD_MASK;
-
- if (lfw_block != system_npcx_get_ram_blk_by_lfw_addr(__lfw_text_end)) {
- LOG_ERR("LFW cannot cross ram blocks!");
- return;
- }
-
- /*
- * Set status of pins which connect to flash to tri-state in case
- * the leakage current.
- */
- system_npcx_set_flash_pins_tri_state(dev);
-
- /* Initialize watchdog for reset after wake-up from hibernating */
- system_npcx_init_watchdog_reset(dev);
-
- /* Disable ADC and wait for 1000 us to make sure conversion is done */
- if (IS_ENABLED(CONFIG_ADC))
- system_npcx_turn_off_adc();
-
- /* Disable kernel timer */
- system_npcx_turn_off_kernel_timer();
-
- /* Disable instant wake up mode for better power consumption */
- system_npcx_disable_instant_wakeup();
-
- /*
- * Set wake-up input GPIOs and turn off the other sources for better
- * power consumption before entering hibernate mode.
- */
- system_npcx_set_wakeup_gpios_before_hibernate();
-
- /*
- * Give the board a chance to do any late stage hibernation work. This
- * is likely going to configure GPIOs for hibernation. On some boards,
- * it's possible that this may not return at all. On those boards,
- * power to the EC is likely being turn off entirely.
- */
- if (board_hibernate_late) {
- board_hibernate_late();
- }
-
- /* Setup a RTC alarm if needed */
- if (IS_ENABLED(CONFIG_RTC) && (seconds || microseconds)) {
- system_set_rtc_alarm(seconds, microseconds);
- }
-
- /* Clear all pending IRQs in case wake-up immediately after sleeping */
- for (int i = 0; i < CONFIG_NUM_IRQS; i++) {
- NVIC_ClearPendingIRQ(i);
- }
-
- /* Execute hibernate by lfw which locates in last 32K block ram */
- system_npcx_hibernate_by_lfw_in_last_ram(dev, pd_ram_mask);
-}
-
-static const char *cros_system_npcx_get_chip_vendor(const struct device *dev)
-{
- struct mswc_reg *const inst_mswc = HAL_MSWC_INST(dev);
- static char str[11] = "Unknown-XX";
- char *p = str + 8;
- uint8_t fam_id = inst_mswc->SID_CR;
-
-#if DT_NODE_EXISTS(SYSTEM_DT_NODE_SOC_ID_CONFIG)
- if (fam_id == NPCX_FAMILY_ID) {
- return "Nuvoton";
- }
-#endif
-
- hex2char(fam_id >> 4, p++);
- hex2char(fam_id & 0xf, p);
- return str;
-}
-
-static const char *cros_system_npcx_get_chip_name(const struct device *dev)
-{
- struct mswc_reg *const inst_mswc = HAL_MSWC_INST(dev);
- static char str[13] = "Unknown-XXXX";
- char *p = str + 8;
- uint8_t chip_id = inst_mswc->SRID_CR;
- uint8_t device_id = inst_mswc->DEVICE_ID_CR;
-
-#if DT_NODE_EXISTS(SYSTEM_DT_NODE_SOC_ID_CONFIG)
- if (chip_id == NPCX_CHIP_ID && device_id == NPCX_DEVICE_ID) {
- return CONFIG_SOC;
- }
-#endif
-
- hex2char(chip_id >> 4, p++);
- hex2char(chip_id & 0xf, p++);
- hex2char(device_id >> 4, p++);
- hex2char(device_id & 0xf, p);
- return str;
-}
-
-static const char *cros_system_npcx_get_chip_revision(const struct device *dev)
-{
- ARG_UNUSED(dev);
-#if DT_NODE_EXISTS(SYSTEM_DT_NODE_SOC_ID_CONFIG)
- static char rev[NPCX_REVISION_LEN * 2 + 1];
-#else
- static char rev[1];
-#endif
- char *p = rev;
-
-#if DT_NODE_EXISTS(SYSTEM_DT_NODE_SOC_ID_CONFIG)
- /*
- * For NPCX7, the revision number is 1 byte.
- * For NPCX9 and later chips, the revision number is 4 bytes.
- */
- for (int s = NPCX_REVISION_ADDR + NPCX_REVISION_LEN - 1;
- s >= NPCX_REVISION_ADDR; s--) {
- uint8_t r = *((volatile uint8_t *)s);
- hex2char(r >> 4, p++);
- hex2char(r & 0xf, p++);
- }
-#endif
- *p = '\0';
-
- return rev;
-}
-
-static void system_npcx_hibernate_by_psl(const struct device *dev,
- uint32_t seconds,
- uint32_t microseconds)
-{
- ARG_UNUSED(dev);
- /*
- * TODO(b/178230662): RTC wake-up in PSL mode only support in npcx9
- * series. Nuvoton will introduce CLs for it later.
- */
- ARG_UNUSED(seconds);
- ARG_UNUSED(microseconds);
-
- /*
- * Configure PSL input pads from "psl-in-pads" property in device tree
- * file.
- */
- npcx_pinctrl_psl_input_configure();
-
- /*
- * Give the board a chance to do any late stage hibernation work. This
- * is likely going to configure GPIOs for hibernation. On some boards,
- * it's possible that this may not return at all. On those boards,
- * power to the EC is likely being turn off entirely.
- */
- if (board_hibernate_late)
- board_hibernate_late();
-
- /* Turn off VCC1 to enter ultra-low-power mode for hibernating */
- npcx_pinctrl_psl_output_set_inactive();
-}
-
-static int cros_system_npcx_get_reset_cause(const struct device *dev)
-{
- struct cros_system_npcx_data *data = DRV_DATA(dev);
-
- return data->reset;
-}
-
-static int cros_system_npcx_init(const struct device *dev)
-{
- struct scfg_reg *const inst_scfg = HAL_SCFG_INST(dev);
- struct twd_reg *const inst_twd = HAL_TWD_INST(dev);
- struct cros_system_npcx_data *data = DRV_DATA(dev);
-
- /* check reset cause */
- if (IS_BIT_SET(inst_twd->T0CSR, NPCX_T0CSR_WDRST_STS)) {
- data->reset = WATCHDOG_RST;
- inst_twd->T0CSR |= BIT(NPCX_T0CSR_WDRST_STS);
- } else if (IS_BIT_SET(inst_scfg->RSTCTL, NPCX_RSTCTL_DBGRST_STS)) {
- data->reset = DEBUG_RST;
- inst_scfg->RSTCTL |= BIT(NPCX_RSTCTL_DBGRST_STS);
- } else if (IS_BIT_SET(inst_scfg->RSTCTL, NPCX_RSTCTL_VCC1_RST_STS)) {
- data->reset = VCC1_RST_PIN;
- } else {
- data->reset = POWERUP;
- }
-
- return 0;
-}
-
-static int cros_system_npcx_soc_reset(const struct device *dev)
-{
- struct twd_reg *const inst_twd = HAL_TWD_INST(dev);
-
- /* Disable interrupts to avoid task swaps during reboot */
- interrupt_disable_all();
-
- /*
- * NPCX chip doesn't have the specific system reset functionality. Use
- * watchdog reset as a system reset.
- */
-
- /* Stop the watchdog */
- system_npcx_watchdog_stop();
-
- /* Initialize watchdog for reset */
- system_npcx_init_watchdog_reset(dev);
-
- /*
- * The trigger of a watchdog event by a "too early service" condition.
- * When the watchdog is written more than once during three watchdog
- * clock cycle.
- */
- inst_twd->WDSDM = 0x5C;
- inst_twd->WDSDM = 0x5C;
-
- /* Wait for the soc reset. */
- while (1) {
- ;
- }
-
- /* should never return */
- return 0;
-}
-
-static int cros_system_npcx_hibernate(const struct device *dev,
- uint32_t seconds, uint32_t microseconds)
-{
- /* Disable interrupt first */
- interrupt_disable_all();
-
- /* Stop the watchdog */
- system_npcx_watchdog_stop();
-
- /* Enter hibernate mode */
- if (IS_ENABLED(CONFIG_PLATFORM_EC_HIBERNATE_PSL)) {
- system_npcx_hibernate_by_psl(dev, seconds, microseconds);
- } else {
- system_npcx_hibernate_by_disable_ram(dev, seconds,
- microseconds);
- }
-
- return 0;
-}
-
-__maybe_unused static uint64_t
-cros_system_npcx_deep_sleep_ticks(const struct device *dev)
-{
- return npcx_clock_get_sleep_ticks();
-}
-
-static struct cros_system_npcx_data cros_system_npcx_dev_data;
-
-static const struct cros_system_npcx_config cros_system_dev_cfg = {
- .base_scfg = DT_REG_ADDR(DT_INST(0, nuvoton_npcx_scfg)),
- .base_twd = DT_REG_ADDR(DT_INST(0, nuvoton_npcx_watchdog)),
- .base_mswc =
- DT_REG_ADDR_BY_NAME(DT_INST(0, nuvoton_npcx_host_sub), mswc),
-};
-
-static const struct cros_system_driver_api cros_system_driver_npcx_api = {
- .get_reset_cause = cros_system_npcx_get_reset_cause,
- .soc_reset = cros_system_npcx_soc_reset,
- .hibernate = cros_system_npcx_hibernate,
- .chip_vendor = cros_system_npcx_get_chip_vendor,
- .chip_name = cros_system_npcx_get_chip_name,
- .chip_revision = cros_system_npcx_get_chip_revision,
-#ifdef CONFIG_SOC_POWER_MANAGEMENT_TRACE
- .deep_sleep_ticks = cros_system_npcx_deep_sleep_ticks,
-#endif
-};
-
-DEVICE_DEFINE(cros_system_npcx_0, "CROS_SYSTEM", cros_system_npcx_init, NULL,
- &cros_system_npcx_dev_data, &cros_system_dev_cfg, PRE_KERNEL_1,
- CONFIG_CROS_SYSTEM_NPCX_INIT_PRIORITY,
- &cros_system_driver_npcx_api);
-
-#if DT_NODE_EXISTS(DT_NODELABEL(dbg))
-#define HAL_DBG_REG_BASE_ADDR \
- ((struct dbg_reg *)DT_REG_ADDR(DT_INST(0, nuvoton_npcx_cros_dbg)))
-
-#define DBG_NODE DT_NODELABEL(dbg)
-#define DBG_PINCTRL_PH DT_PHANDLE_BY_IDX(DBG_NODE, pinctrl_0, 0)
-#define DBG_ALT_FILED(f) DT_PHA_BY_IDX(DBG_PINCTRL_PH, alts, 0, f)
-
-static int jtag_init(const struct device *dev)
-{
- ARG_UNUSED(dev);
- struct dbg_reg *const dbg_reg_base = HAL_DBG_REG_BASE_ADDR;
- const struct npcx_alt jtag_alts[] = {
- {
- .group = DBG_ALT_FILED(group),
- .bit = DBG_ALT_FILED(bit),
- .inverted = DBG_ALT_FILED(inv)
- }
- };
-
- dbg_reg_base->DBGCTRL = 0x04;
- dbg_reg_base->DBGFRZEN3 &= ~BIT(NPCX_DBGFRZEN3_GLBL_FRZ_DIS);
- if (DT_NODE_HAS_STATUS(DT_NODELABEL(dbg), okay))
- npcx_pinctrl_mux_configure(jtag_alts, 1, 1);
-
- return 0;
-}
-#if CONFIG_KERNEL_INIT_PRIORITY_DEFAULT >= 41
-#error "jtag_init must be called after default kernel init"
-#endif
-SYS_INIT(jtag_init, PRE_KERNEL_1, 41);
-#endif /* DT_NODE_EXISTS(DT_NODELABEL(dbg)) */
diff --git a/zephyr/dts/bindings/adc/named-adc.yaml b/zephyr/dts/bindings/adc/named-adc.yaml
deleted file mode 100644
index 6f06d73b86..0000000000
--- a/zephyr/dts/bindings/adc/named-adc.yaml
+++ /dev/null
@@ -1,107 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: ADC parent node
-
-compatible: "named-adc-channels"
-
-child-binding:
- description: Named ADCs child node
- properties:
- label:
- required: true
- type: string
- description:
- Human-readable string describing the device (used as
- device_get_binding() argument)
- channel:
- required: true
- type: int
- description: ADC channel used
- mul:
- required: false
- type: int
- default: 1
- description: Multiplication factor of ADC measurement
- div:
- required: false
- type: int
- default: 1
- description: Division factor of ADC measurement
- gain:
- required: false
- type: string
- description:
- Gain selection for the ADC channel. Source of valid gain settings is
- "enum adc_gain" found in <zephyr-base>/include/drivers/adc.h
- enum:
- - ADC_GAIN_1_6
- - ADC_GAIN_1_5
- - ADC_GAIN_1_4
- - ADC_GAIN_1_3
- - ADC_GAIN_1_2
- - ADC_GAIN_2_3
- - ADC_GAIN_1
- - ADC_GAIN_2
- - ADC_GAIN_3
- - ADC_GAIN_4
- - ADC_GAIN_8
- - ADC_GAIN_16
- - ADC_GAIN_32
- - ADC_GAIN_64
- - ADC_GAIN_128
- default: ADC_GAIN_1
- reference:
- required: false
- type: string
- description:
- Sets the reference voltage for the ADC channel. Source of valid
- reference voltages is "enum adc_reference" found in
- <zephyr-base>/include/drivers/adc.
- enum:
- - ADC_REF_VDD_1
- - ADC_REF_VDD_1_2
- - ADC_REF_VDD_1_3
- - ADC_REF_VDD_1_4
- - ADC_REF_INTERNAL
- - ADC_REF_EXTERNAL0
- - ADC_REF_EXTERNAL1
- default: ADC_REF_INTERNAL
- acquisition-time:
- required: false
- type: int
- description:
- Set the acquisition time for ADC conversion. Use the ADC_ACQ_TIME macro
- to compose this value. If the hardware doesn't support a configurable
- acquisition time, use ADC_ACQ_TIME_DEFAULT (0).
- default: 0
- differential:
- required: false
- type: boolean
- description:
- Set the ADC acquisition mode to differential. Default mode is
- single-ended acquisition.
- enum-name:
- type: string
- required: true
- description:
- Enum values used in the source code to refer to the ADC channels
- enum:
- - ADC_AMON_BMON
- - ADC_BOARD_ID_0
- - ADC_BOARD_ID_1
- - ADC_PMON
- - ADC_PSYS
- - ADC_TEMP_SENSOR_CHARGER
- - ADC_TEMP_SENSOR_DDR_SOC
- - ADC_TEMP_SENSOR_FAN
- - ADC_TEMP_SENSOR_PP3300_REGULATOR
- - ADC_VBUS
- - ADC_VBUS_C0
- - ADC_VBUS_C1
- - ADC_EVB_CH_0
- - ADC_EVB_CH_1
- - ADC_EVB_CH_2
- - ADC_EVB_CH_3
- - ADC_EVB_CH_4
diff --git a/zephyr/dts/bindings/battery/as3gwrc3ka,c235-41.yaml b/zephyr/dts/bindings/battery/as3gwrc3ka,c235-41.yaml
deleted file mode 100644
index c4359b29d2..0000000000
--- a/zephyr/dts/bindings/battery/as3gwrc3ka,c235-41.yaml
+++ /dev/null
@@ -1,56 +0,0 @@
-description: "AS3GWRc3KA C235-41"
-compatible: "as3gwrc3ka,c235-41"
-
-include: battery-smart.yaml
-
-properties:
- enum-name:
- type: string
- default: "as3gwrc3ka,c235-41"
-
- # Fuel gauge
- manuf_name:
- default: "AS3GWRc3KA"
- device_name:
- default: "C235-41"
- ship_mode_reg_addr:
- default: 0x00
- ship_mode_reg_data:
- default: [ 0x10, 0x10 ]
- # Documentation: b/150833879
- # Charging/Discharging FETs Status
- # Register SBS_PackStatus_ACCESS (0x99)
- # Bit-3: XDSG
- # Bit-2: XCHG
- fet_reg_addr:
- default: 0x99
- fet_reg_mask:
- default: 0x08
- fet_disconnect_val:
- default: 0x08
- fet_cfet_mask:
- default: 0x04
- fet_cfet_off_val:
- default: 0x04
-
- # Battery info
- voltage_max:
- default: 8800
- voltage_normal:
- default: 7700
- voltage_min:
- default: 6000
- precharge_current:
- default: 256
- start_charging_min_c:
- default: 0
- start_charging_max_c:
- default: 45
- charging_min_c:
- default: 0
- charging_max_c:
- default: 60
- discharging_min_c:
- default: 0
- discharging_max_c:
- default: 60
diff --git a/zephyr/dts/bindings/battery/battery-fuel-gauge.yaml b/zephyr/dts/bindings/battery/battery-fuel-gauge.yaml
deleted file mode 100644
index 2572090024..0000000000
--- a/zephyr/dts/bindings/battery/battery-fuel-gauge.yaml
+++ /dev/null
@@ -1,85 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: |
- Battery fuel gauge parameters
-
-compatible: "battery-fuel-gauge"
-
-properties:
- manuf_name:
- description: Manufacturer name
- type: string
- device_name:
- description: Model/Device name
- type: string
- ship_mode_wb_support:
- description: |
- Write Block support. If this is true, then i2c write block command
- will be used instead of a 16-bit write
- Value must be either 0 or 1.
- type: int
- ship_mode_reg_addr:
- description: |
- Address of register responsible for enabling ship mode.
- type: int
- ship_mode_reg_data:
- description: |
- Values written to register to enable ship mode.
- type: array
- sleep_mode_support:
- description: |
- Defines if battery support fuel gauge sleep command.
- Value must be either 0 or 1.
- type: int
- sleep_mode_reg_addr:
- description: |
- Defines address where command will be sent to go into sleep mode.
- type: int
- sleep_mode_reg_data:
- description: |
- Defines value which will be sent to register to go into sleep mode.
- type: int
- fet_mfgacc_support:
- description: |
- Defines if battery supports manufacturer access command.
- If enabled, FET status is read using the ManufacturerBlockAccess (0x44)
- to read the OperationStatus (0x54) register.
- The fet_reg_mask and fet_disconnect_val properties must still be
- defined.
- Value must be either 0 or 1.
- type: int
- fet_reg_addr:
- description: |
- Address of register which reports charging and discharging FETs status.
- This property is ignored if fet_mfgacc_support is true.
- type: int
- fet_reg_mask:
- description: |
- Mask which determines which bit in status value contains the
- discharge FET status.
- type: int
- fet_disconnect_val:
- description: |
- Value that describes which bits must be set to determine that
- discharge FET has disconnected the battery.
- type: int
- fet_cfet_mask:
- description: |
- Mask which determines which bit in status value contains the
- charge FET status. If this value is 0, this means there's
- no charge FET.
- type: int
- fet_cfet_off_val:
- description: |
- Value that describes which bits must be set to determine that
- charge FET has disconnected the battery.
- type: int
- imbalance_mv:
- description: |
- This property is used only if
- CONFIG_PLATFORM_EC_BATTERY_MEASURE_IMBALANCE is enabled.
- It should be an enum and its value should be a name of function
- which will be assigned to imbalance_mv pointer.
- type: string
diff --git a/zephyr/dts/bindings/battery/battery-info.yaml b/zephyr/dts/bindings/battery/battery-info.yaml
deleted file mode 100644
index 3a4cb875e7..0000000000
--- a/zephyr/dts/bindings/battery/battery-info.yaml
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description:
- Information about battery
- Voltage is in millivolts
- Current is in milliamperes
- Temperature is in Celsius degrees
-
-compatible: "battery-info"
-
-properties:
- voltage_max:
- description: |
- Maximum voltage that can be applied to the battery.
- type: int
- voltage_normal:
- description: |
- Nominal voltage of the battery.
- type: int
- voltage_min:
- description: |
- Minimum voltage of the battery.
- If current voltage is below this value, system will shutdown.
- type: int
- precharge_voltage:
- description: |
- Voltage used during the precharge phase. Not all chargers
- may take these into account.
- type: int
- precharge_current:
- description: |
- Maximum current used during the precharge phase.
- type: int
- start_charging_min_c:
- description: |
- Minimum temperature of battery to start charging it.
- This value is used only if
- CONFIG_PLATFORM_EC_BATTERY_CHECK_CHARGE_TEMP_LIMITS is enabled.
- type: int
- start_charging_max_c:
- description: |
- Maximum temperature of battery to start charging it.
- This value is used only if
- CONFIG_PLATFORM_EC_BATTERY_CHECK_CHARGE_TEMP_LIMITS is enabled.
- type: int
- charging_min_c:
- description: |
- Minimum temperature of battery during charging it. If the battery
- temperature falls below this value, charging will be stopped.
- This value is used only if
- CONFIG_PLATFORM_EC_BATTERY_CHECK_CHARGE_TEMP_LIMITS is enabled.
- type: int
- charging_max_c:
- description: |
- Maximum temperature of battery during charging it. If the battery
- temperature raises above this value, charging will be stopped.
- This value is used only if
- CONFIG_PLATFORM_EC_BATTERY_CHECK_CHARGE_TEMP_LIMITS is enabled.
- type: int
- discharging_min_c:
- description: |
- Minimum working temperature of battery.
- If temperature is below this value, the system will shutdown.
- type: int
- discharging_max_c:
- description: |
- Maximum working temperature of battery.
- If temperature is above this value, the system will shutdown.
- type: int
diff --git a/zephyr/dts/bindings/battery/battery-smart.yaml b/zephyr/dts/bindings/battery/battery-smart.yaml
deleted file mode 100644
index ce0a330077..0000000000
--- a/zephyr/dts/bindings/battery/battery-smart.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-compatible: "battery-smart"
-
-include: [ "base.yaml", "battery-info.yaml", "battery-fuel-gauge.yaml" ]
-
-properties:
- enum-name:
- description: Unique value used for creating enum of batteries types
- type: string
- enum:
- - "as3gwrc3ka,c235-41"
- - "lgc,ap16l8j"
- - "lgc,ap18c8k"
- - "murata,ap18c4k"
- - "panasonic,ap16l5j"
- - "panasonic,ap16l5j-009"
diff --git a/zephyr/dts/bindings/battery/lgc,ap16l8j.yaml b/zephyr/dts/bindings/battery/lgc,ap16l8j.yaml
deleted file mode 100644
index e57cf48e24..0000000000
--- a/zephyr/dts/bindings/battery/lgc,ap16l8j.yaml
+++ /dev/null
@@ -1,55 +0,0 @@
-description: "LGC KT0020G010 AP16L8J"
-compatible: "lgc,ap16l8j"
-
-include: battery-smart.yaml
-
-properties:
- enum-name:
- type: string
- default: "lgc,ap16l8j"
-
- # Fuel gauge
- manuf_name:
- default: "LGC KT0020G010"
- device_name:
- default: "AP16L8J"
- ship_mode_reg_addr:
- default: 0x3A
- ship_mode_reg_data:
- default: [ 0xC574, 0xC574 ]
- # Documentation: b/148625782
- # ManufacturerAccess() 0x0054 OperationStatus
- # CHG (Bit 2): CHG FET status (1 = Active 0 = Inactive)
- # DSG (Bit 1): DSG FET status (1 = Active 0 = Inactive)
- fet_mfgacc_support:
- default: 1
- fet_reg_mask:
- default: 0x0002
- fet_disconnect_val:
- default: 0x0000
- fet_cfet_mask:
- default: 0x0004
- fet_cfet_off_val:
- default: 0x0000
-
- # Battery info
- voltage_max:
- default: 8700
- voltage_normal:
- default: 7500
- voltage_min:
- default: 6000
- precharge_current:
- default: 256
- start_charging_min_c:
- default: 0
- start_charging_max_c:
- default: 50
- charging_min_c:
- default: 0
- charging_max_c:
- default: 60
- discharging_min_c:
- default: -20
- discharging_max_c:
- default: 75
diff --git a/zephyr/dts/bindings/battery/lgc,ap18c8k.yaml b/zephyr/dts/bindings/battery/lgc,ap18c8k.yaml
deleted file mode 100644
index b997004f3d..0000000000
--- a/zephyr/dts/bindings/battery/lgc,ap18c8k.yaml
+++ /dev/null
@@ -1,57 +0,0 @@
-description: "LGC KT0030G020 AP18C8K"
-compatible: "lgc,ap18c8k"
-
-include: battery-smart.yaml
-
-properties:
- enum-name:
- type: string
- default: "lgc,ap18c8k"
-
- # Fuel gauge
- manuf_name:
- default: "LGC KT0030G020"
- device_name:
- default: "AP18C8K"
- ship_mode_reg_addr:
- default: 0x3A
- ship_mode_reg_data:
- default: [ 0xC574, 0xC574 ]
- # Documentation: b/130608940
- # Command Code: 0x43
- # Bit 0 - DFET - Condition of D-FET ( 0=OFF, 1=ON )
- # Bit 1 - CFET - Condition of C-FET ( 0=OFF, 1=ON )
- 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: 13050
- voltage_normal:
- default: 11250
- voltage_min:
- default: 9000
- precharge_current:
- default: 256
- start_charging_min_c:
- default: 0
- start_charging_max_c:
- default: 50
- charging_min_c:
- default: 0
- charging_max_c:
- default: 60
- discharging_min_c:
- default: -20
- discharging_max_c:
- default: 75
diff --git a/zephyr/dts/bindings/battery/murata,ap18c4k.yaml b/zephyr/dts/bindings/battery/murata,ap18c4k.yaml
deleted file mode 100644
index ca028b82cb..0000000000
--- a/zephyr/dts/bindings/battery/murata,ap18c4k.yaml
+++ /dev/null
@@ -1,57 +0,0 @@
-description: "Murata KT00304012 AP18C4K"
-compatible: "murata,ap18c4k"
-
-include: battery-smart.yaml
-
-properties:
- enum-name:
- type: string
- default: "murata,ap18c4k"
-
- # Fuel gauge
- manuf_name:
- default: "Murata KT00304012"
- device_name:
- default: "AP18C4K"
- ship_mode_reg_addr:
- default: 0x3A
- ship_mode_reg_data:
- default: [ 0xC574, 0xC574 ]
- # Documentation: b/130615670
- # Manufacturer Access 0x00
- # b14: Charging Disabled (0: Off, 1: On)
- # b13: Discharging Disabled (0: Off, 1: On)
- fet_mfgacc_support:
- default: 0
- fet_reg_addr:
- default: 0x0
- fet_reg_mask:
- default: 0x2000
- fet_disconnect_val:
- default: 0x2000
- fet_cfet_mask:
- default: 0x4000
- fet_cfet_off_val:
- default: 0x4000
-
- # Battery info
- voltage_max:
- default: 13200
- voltage_normal:
- default: 11400
- voltage_min:
- default: 9000
- precharge_current:
- default: 256
- start_charging_min_c:
- default: 0
- start_charging_max_c:
- default: 50
- charging_min_c:
- default: 0
- charging_max_c:
- default: 60
- discharging_min_c:
- default: -20
- discharging_max_c:
- default: 75
diff --git a/zephyr/dts/bindings/battery/named-batteries.yaml b/zephyr/dts/bindings/battery/named-batteries.yaml
deleted file mode 100644
index 1c922e2100..0000000000
--- a/zephyr/dts/bindings/battery/named-batteries.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-description: Named Batteries parent node
-
-compatible: "named-batteries"
-
-# TODO(b/183544739): Move this to use compatible strings
-
-child-binding:
- description: Named batteries child node
- properties:
- enum-name:
- type: string
- required: true
- enum:
- - "ap16l5j"
- - "ap16l5j_009"
- - "ap16l8j"
- - "c235"
- - "lgc011"
- - "lgc_ap18c8k"
- - "murata_ap18c4k"
diff --git a/zephyr/dts/bindings/battery/panasonic,ap16l5j-009.yaml b/zephyr/dts/bindings/battery/panasonic,ap16l5j-009.yaml
deleted file mode 100644
index 5791549092..0000000000
--- a/zephyr/dts/bindings/battery/panasonic,ap16l5j-009.yaml
+++ /dev/null
@@ -1,59 +0,0 @@
-description: "Panasonic KT00205009 AP16L5J"
-compatible: "panasonic,ap16l5j-009"
-
-include: battery-smart.yaml
-
-properties:
- enum-name:
- type: string
- default: "panasonic,ap16l5j-009"
-
- # Fuel gauge
- manuf_name:
- default: "PANASONIC KT00205009"
- device_name:
- default: "AP16L5J"
- ship_mode_reg_addr:
- default: 0x3A
- ship_mode_reg_data:
- default: [ 0xC574, 0xC574 ]
- # Documentation: b/144674480
- # ManufacturerAccess() 0x00
- # Bit14 Discharge FET status
- # Set - Discharge FET is ON, Reset - Discharge FET is OFF
- # Bit15 Charge FET status
- # Set - Charge FET is ON, Reset - Charge FET is OFF
- fet_mfgacc_support:
- default: 0
- fet_reg_addr:
- default: 0x0
- fet_reg_mask:
- default: 0x4000
- fet_disconnect_val:
- default: 0x0000
- fet_cfet_mask:
- default: 0x8000
- fet_cfet_off_val:
- default: 0x0000
-
- # Battery info
- voltage_max:
- default: 8800
- voltage_normal:
- default: 7700
- voltage_min:
- default: 6000
- precharge_current:
- default: 256
- start_charging_min_c:
- default: 0
- start_charging_max_c:
- default: 50
- charging_min_c:
- default: 0
- charging_max_c:
- default: 60
- discharging_min_c:
- default: -20
- discharging_max_c:
- default: 75
diff --git a/zephyr/dts/bindings/battery/panasonic,ap16l5j.yaml b/zephyr/dts/bindings/battery/panasonic,ap16l5j.yaml
deleted file mode 100644
index fe0923dd87..0000000000
--- a/zephyr/dts/bindings/battery/panasonic,ap16l5j.yaml
+++ /dev/null
@@ -1,59 +0,0 @@
-description: "Panasonic AP16L5J"
-compatible: "panasonic,ap16l5j"
-
-include: battery-smart.yaml
-
-properties:
- enum-name:
- type: string
- default: "panasonic,ap16l5j"
-
- # Fuel gauge
- manuf_name:
- default: "PANASONIC"
- device_name:
- default: "AP16L5J"
- ship_mode_reg_addr:
- default: 0x3A
- ship_mode_reg_data:
- default: [ 0xC574, 0xC574 ]
- # Documentation: b/144674480
- # ManufacturerAccess() 0x00
- # Bit14 Discharge FET status
- # Set - Discharge FET is ON, Reset - Discharge FET is OFF
- # Bit15 Charge FET status
- # Set - Charge FET is ON, Reset - Charge FET is OFF
- fet_mfgacc_support:
- default: 0
- fet_reg_addr:
- default: 0x0
- fet_reg_mask:
- default: 0x4000
- fet_disconnect_val:
- default: 0x0000
- fet_cfet_mask:
- default: 0x8000
- fet_cfet_off_val:
- default: 0x0000
-
- # Battery info
- voltage_max:
- default: 8800
- voltage_normal:
- default: 7700
- voltage_min:
- default: 6000
- precharge_current:
- default: 256
- start_charging_min_c:
- default: 0
- start_charging_max_c:
- default: 50
- charging_min_c:
- default: 0
- charging_max_c:
- default: 60
- discharging_min_c:
- default: -20
- discharging_max_c:
- default: 75
diff --git a/zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml b/zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml
deleted file mode 100644
index f97d688727..0000000000
--- a/zephyr/dts/bindings/cbi/named-cbi-ssfc-value.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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 bd6c1d535b..0000000000
--- a/zephyr/dts/bindings/cbi/named-cbi-ssfc.yaml
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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:
- - 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/intersil,isl9238.yaml b/zephyr/dts/bindings/charger/intersil,isl9238.yaml
deleted file mode 100644
index 08e00bf313..0000000000
--- a/zephyr/dts/bindings/charger/intersil,isl9238.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Intersil ISL9238 Charger IC
-
-compatible: "intersil,isl9238"
-
-include: i2c-device.yaml
diff --git a/zephyr/dts/bindings/charger/intersil,isl9241.yaml b/zephyr/dts/bindings/charger/intersil,isl9241.yaml
deleted file mode 100644
index 7557b949d8..0000000000
--- a/zephyr/dts/bindings/charger/intersil,isl9241.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Intersil ISL9241 Charger IC
-
-compatible: "intersil,isl9241"
-
-include: i2c-device.yaml
-
-properties:
- switching-frequency:
- type: int
- required: false
- description:
- Sets the charger switching frequency. If not defined then the switching
- frequency is configured by the resistor connected to the PROG pin on
- the board.
diff --git a/zephyr/dts/bindings/console/ec-console.yaml b/zephyr/dts/bindings/console/ec-console.yaml
deleted file mode 100644
index f79ddd67b0..0000000000
--- a/zephyr/dts/bindings/console/ec-console.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: EC Console node
-
-compatible: "ec-console"
-
-properties:
- disabled:
- required: false
- type: string-array
- description:
- List of EC channel names that are disabled in the output by default.
diff --git a/zephyr/dts/bindings/cros_bbram/named-bbram-regions.yaml b/zephyr/dts/bindings/cros_bbram/named-bbram-regions.yaml
deleted file mode 100644
index 8b12473d0a..0000000000
--- a/zephyr/dts/bindings/cros_bbram/named-bbram-regions.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright (c) 2021 Google Inc.
-# SPDX-License-Identifier: Apache-2.0
-description: Named battery-backed RAM parent node
-
-compatible: "named-bbram-regions"
-
-child-binding:
- description: Named battery-backed RAM child node
- properties:
- offset:
- type: int
- required: true
- size:
- type: int
- required: true
diff --git a/zephyr/dts/bindings/cros_dbg/nuvoton,npcx-cros-dbg.yaml b/zephyr/dts/bindings/cros_dbg/nuvoton,npcx-cros-dbg.yaml
deleted file mode 100644
index 109fa11d50..0000000000
--- a/zephyr/dts/bindings/cros_dbg/nuvoton,npcx-cros-dbg.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (c) 2021 Google Inc.
-# SPDX-License-Identifier: Apache-2.0
-
-description: Nuvoton, NPCX Debug Interface
-
-compatible: "nuvoton,npcx-cros-dbg"
-
-include: base.yaml
-
-properties:
- reg:
- required: true
-
- pinctrl-0:
- type: phandles
- required: true
- description: configurations of pinmux controllers
diff --git a/zephyr/dts/bindings/cros_flash/cros-ec,flash-layout.yaml b/zephyr/dts/bindings/cros_flash/cros-ec,flash-layout.yaml
deleted file mode 100644
index 991f3c71cf..0000000000
--- a/zephyr/dts/bindings/cros_flash/cros-ec,flash-layout.yaml
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Describes the size and offset of the RO and RW regions
-
-compatible: "cros-ec,flash-layout"
-
-include: base.yaml
-
-properties:
- type:
- type: string
- required: true
- description: >-
- A property required by the binman utility, defined here only to
- prevent Zephyr's binding generator from erroring about
- additional properties.
-
- The property should be set to the value "section" (done by
- binman.dtsi) and should not be used anywhere in C code.
-
- See README.entries in binman for a description of what binman
- uses this for.
- offset:
- type: int
- required: true
- description: >-
- The offset of the flash region from the base of the flash.
- size:
- type: int
- required: true
- description: >-
- The size of the flash region, in bytes.
- read-only:
- type: boolean
- required: false
- description: >-
- Set if the section should be read-only.
diff --git a/zephyr/dts/bindings/cros_flash/cros-flash-controller.yaml b/zephyr/dts/bindings/cros_flash/cros-flash-controller.yaml
deleted file mode 100644
index b9c8a9f149..0000000000
--- a/zephyr/dts/bindings/cros_flash/cros-flash-controller.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2020 Google LLC
-# SPDX-License-Identifier: Apache-2.0
-
-# Common fields for Chrome OS flash devices
-
-include: base.yaml
-
-bus: crosflash
-
-properties:
- label:
- required: true
diff --git a/zephyr/dts/bindings/cros_flash/nuvoton,npcx-cros-flash.yaml b/zephyr/dts/bindings/cros_flash/nuvoton,npcx-cros-flash.yaml
deleted file mode 100644
index 23c0f92c9c..0000000000
--- a/zephyr/dts/bindings/cros_flash/nuvoton,npcx-cros-flash.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2020 Google LLC
-# SPDX-License-Identifier: Apache-2.0
-
-description: Nuvoton, NPCX-cros-flash node
-
-compatible: "nuvoton,npcx-cros-flash"
-
-include: cros-flash-controller.yaml
-
-properties:
- reg:
- required: true
-
- clocks:
- required: true
-
- size:
- type: int
- required: true
-
- pinctrl-0:
- type: phandles
- required: true
- description: configurations of pinmux controllers
diff --git a/zephyr/dts/bindings/cros_kb_raw/cros-kb-raw-controller.yaml b/zephyr/dts/bindings/cros_kb_raw/cros-kb-raw-controller.yaml
deleted file mode 100644
index e8c95419e1..0000000000
--- a/zephyr/dts/bindings/cros_kb_raw/cros-kb-raw-controller.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2020 Google LLC
-# SPDX-License-Identifier: Apache-2.0
-
-# Common fields for Chrome OS raw keyboard devices
-
-include: base.yaml
-
-bus: croskb
-
-properties:
- label:
- required: true
diff --git a/zephyr/dts/bindings/cros_kb_raw/nuvoton,npcx-cros-kb-raw.yaml b/zephyr/dts/bindings/cros_kb_raw/nuvoton,npcx-cros-kb-raw.yaml
deleted file mode 100644
index 7544039ffc..0000000000
--- a/zephyr/dts/bindings/cros_kb_raw/nuvoton,npcx-cros-kb-raw.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2020 Google LLC
-# SPDX-License-Identifier: Apache-2.0
-
-description: Nuvoton, NPCX-cros-kb-raw node
-
-compatible: "nuvoton,npcx-cros-kb-raw"
-
-include: cros-kb-raw-controller.yaml
-
-properties:
- reg:
- required: true
-
- clocks:
- required: true
-
- pinctrl-0:
- type: phandles
- required: true
- description: configurations of pinmux controllers
-
- wui_maps:
- type: phandles
- required: true
- description: |
- Mapping table between Wake-Up Input (WUI) and 8 IOs belong to this device.
- Please notice not all IOs connect to WUIs.
-
- In this case, it will be presented by wui_none.
- For example the WUI mapping on NPCX7 KSI pads would be
- wui_maps = <&wui_io30 &wui_io31 &wui_io27 &wui_io26
- &wui_io25 &wui_io24 &wui_io23 &wui_io22>;
diff --git a/zephyr/dts/bindings/cros_mkbp_event/ec-mkbp-event.yaml b/zephyr/dts/bindings/cros_mkbp_event/ec-mkbp-event.yaml
deleted file mode 100644
index 73f0e8fdca..0000000000
--- a/zephyr/dts/bindings/cros_mkbp_event/ec-mkbp-event.yaml
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: EC MKBP Event node
-
-compatible: "ec-wake-mask-event"
-
-properties:
- wakeup-mask:
- required: false
- type: int
- default: 0
- description:
- Define the MKBP or host events that will wake up the application
- processor from suspend mode.
- HOST_EVENT_MASK should be used for ec-mkbp-host-event-wakeup-mask e.g.
- ec-mkbp-host-event-wakeup-mask {
- compatible = "ec-wake-mask-event";
- wakeup-mask = <(
- HOST_EVENT_MASK(HOST_EVENT_LID_OPEN) |
- HOST_EVENT_MASK(HOST_EVENT_POWER_BUTTON) |
- HOST_EVENT_MASK(HOST_EVENT_AC_CONNECTED) |
- HOST_EVENT_MASK(HOST_EVENT_AC_DISCONNECTED) |
- HOST_EVENT_MASK(HOST_EVENT_HANG_DETECT) |
- HOST_EVENT_MASK(HOST_EVENT_RTC) |
- HOST_EVENT_MASK(HOST_EVENT_MODE_CHANGE) |
- HOST_EVENT_MASK(HOST_EVENT_DEVICE))>;
- };
diff --git a/zephyr/dts/bindings/cros_rtc/cros-rtc.yaml b/zephyr/dts/bindings/cros_rtc/cros-rtc.yaml
deleted file mode 100644
index f754826404..0000000000
--- a/zephyr/dts/bindings/cros_rtc/cros-rtc.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2021 Google LLC
-# SPDX-License-Identifier: Apache-2.0
-
-# Common fields for Chrome OS RTC devices
-
-include: base.yaml
-
-bus: crosrtc
-
-properties:
- label:
- required: true
diff --git a/zephyr/dts/bindings/cros_rtc/nuvoton,npcx-cros-mtc.yaml b/zephyr/dts/bindings/cros_rtc/nuvoton,npcx-cros-mtc.yaml
deleted file mode 100644
index 547b6897e8..0000000000
--- a/zephyr/dts/bindings/cros_rtc/nuvoton,npcx-cros-mtc.yaml
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2021 Google LLC
-# SPDX-License-Identifier: Apache-2.0
-
-description: Nuvoton, NPCX Monotonic Counter (MTC) node
-
-compatible: "nuvoton,npcx-cros-mtc"
-
-include: base.yaml
-
-properties:
- reg:
- required: true
-
- label:
- required: true
-
- mtc-alarm:
- type: phandle
- required: true
- description: |
- Mapping table between Wake-Up Input (WUI) and monotonic counter alarm
- signal.
-
- For example, the WUI mapping on NPCX7 monotonic counter alarm would be
- mtc-alarm = <&wui_mtc>;
-
diff --git a/zephyr/dts/bindings/cros_rtc/nxp,rtc-pcf85063a.yaml b/zephyr/dts/bindings/cros_rtc/nxp,rtc-pcf85063a.yaml
deleted file mode 100644
index 7717649ede..0000000000
--- a/zephyr/dts/bindings/cros_rtc/nxp,rtc-pcf85063a.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2021 Google LLC
-# SPDX-License-Identifier: Apache-2.0
-
-description: NXP, Real-Time Clock
-
-compatible: "nxp,rtc-pcf85063a"
-
-include: [base.yaml, i2c-device.yaml]
-
-properties:
- label:
- required: true
-
- int-gpios:
- type: phandle-array
- required: true
- description: Interrupt from RTC
diff --git a/zephyr/dts/bindings/cros_rtc/renesas,rtc-idt1337ag.yaml b/zephyr/dts/bindings/cros_rtc/renesas,rtc-idt1337ag.yaml
deleted file mode 100644
index a741a98aef..0000000000
--- a/zephyr/dts/bindings/cros_rtc/renesas,rtc-idt1337ag.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2021 Google LLC
-# SPDX-License-Identifier: Apache-2.0
-
-description: RENESAS, Real-Time Clock
-
-compatible: "renesas,rtc-idt1337ag"
-
-include: [base.yaml, i2c-device.yaml]
-
-properties:
- label:
- required: true
-
- int-gpios:
- type: phandle-array
- required: true
- description: Interrupt from RTC
diff --git a/zephyr/dts/bindings/cros_shi/ite,it8xxx2-cros-shi.yaml b/zephyr/dts/bindings/cros_shi/ite,it8xxx2-cros-shi.yaml
deleted file mode 100644
index 3e5a32f63f..0000000000
--- a/zephyr/dts/bindings/cros_shi/ite,it8xxx2-cros-shi.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: ITE, IT8XXX2 Serial Host Interface (SHI) node
-
-compatible: "ite,it8xxx2-cros-shi"
-
-include: base.yaml
-
-properties:
- reg:
- required: true
-
- pinctrl-0:
- type: phandles
- required: true
- description: Configuration of SHI pinmux controller
diff --git a/zephyr/dts/bindings/cros_shi/nuvoton,npcx-cros-shi.yaml b/zephyr/dts/bindings/cros_shi/nuvoton,npcx-cros-shi.yaml
deleted file mode 100644
index c13f3e2b5a..0000000000
--- a/zephyr/dts/bindings/cros_shi/nuvoton,npcx-cros-shi.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (c) 2021 Google Inc.
-# SPDX-License-Identifier: Apache-2.0
-
-description: Nuvoton, NPCX Serial Host Interface (SHI) node
-
-compatible: "nuvoton,npcx-cros-shi"
-
-include: base.yaml
-
-properties:
- reg:
- description: mmio register space
- required: true
-
- clocks:
- required: true
- description: configurations of device source clock controller
-
- pinctrl-0:
- type: phandles
- required: true
- description: configurations of pinmux controllers
-
- shi-cs-wui:
- type: phandle
- required: true
- description: |
- Mapping table between Wake-Up Input (WUI) and SHI_CS signal.
-
- For example the WUI mapping on NPCX7 would be
- shi-cs-wui = <&wui_io53>;
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 007a73b17b..0000000000
--- a/zephyr/dts/bindings/emul/cros,bb-retimer-emul.yaml
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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/cros,i2c-mock.yaml b/zephyr/dts/bindings/emul/cros,i2c-mock.yaml
deleted file mode 100644
index 7da69028bd..0000000000
--- a/zephyr/dts/bindings/emul/cros,i2c-mock.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2021 The chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: A generic I2C mock
-
-compatible: "cros,i2c-mock"
-
-include: base.yaml
-properties:
- reg:
- required: true
diff --git a/zephyr/dts/bindings/emul/cros,lis2dw12-emul.yaml b/zephyr/dts/bindings/emul/cros,lis2dw12-emul.yaml
deleted file mode 100644
index 44c29fbe56..0000000000
--- a/zephyr/dts/bindings/emul/cros,lis2dw12-emul.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2021 The chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: CROS implementation of the LIS2DW12 emulator
-
-compatible: "cros,lis2dw12-emul"
-
-include: base.yaml
-properties:
- reg:
- required: true
diff --git a/zephyr/dts/bindings/emul/cros,ln9310-emul.yaml b/zephyr/dts/bindings/emul/cros,ln9310-emul.yaml
deleted file mode 100644
index 811f77206f..0000000000
--- a/zephyr/dts/bindings/emul/cros,ln9310-emul.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Cros LN9310 Emulator
-
-compatible: "cros,ln9310-emul"
-
-include: base.yaml
-
-properties:
- reg:
- required: true
diff --git a/zephyr/dts/bindings/emul/zephyr,bma255.yaml b/zephyr/dts/bindings/emul/zephyr,bma255.yaml
deleted file mode 100644
index 40750196c1..0000000000
--- a/zephyr/dts/bindings/emul/zephyr,bma255.yaml
+++ /dev/null
@@ -1,83 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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.yaml b/zephyr/dts/bindings/emul/zephyr,bmi.yaml
deleted file mode 100644
index a754287bcc..0000000000
--- a/zephyr/dts/bindings/emul/zephyr,bmi.yaml
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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.yaml b/zephyr/dts/bindings/emul/zephyr,pi3usb9201.yaml
deleted file mode 100644
index 856703e9d7..0000000000
--- a/zephyr/dts/bindings/emul/zephyr,pi3usb9201.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Zephyr pi3usb9201 Emulator
-
-compatible: "zephyr,pi3usb9201-emul"
-
-include: base.yaml
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 cc1d2f368d..0000000000
--- a/zephyr/dts/bindings/emul/zephyr,smart-battery.yaml
+++ /dev/null
@@ -1,155 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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.
diff --git a/zephyr/dts/bindings/emul/zephyr,syv682x.yaml b/zephyr/dts/bindings/emul/zephyr,syv682x.yaml
deleted file mode 100644
index 75de7cf743..0000000000
--- a/zephyr/dts/bindings/emul/zephyr,syv682x.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Zephyr SYV682X Emulator
-
-compatible: "zephyr,syv682x-emul"
-
-include: base.yaml
diff --git a/zephyr/dts/bindings/emul/zephyr,tcs3400.yaml b/zephyr/dts/bindings/emul/zephyr,tcs3400.yaml
deleted file mode 100644
index a4474ec279..0000000000
--- a/zephyr/dts/bindings/emul/zephyr,tcs3400.yaml
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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/fan/named-fans.yaml b/zephyr/dts/bindings/fan/named-fans.yaml
deleted file mode 100644
index 0595a20f54..0000000000
--- a/zephyr/dts/bindings/fan/named-fans.yaml
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Fan parent node
-
-compatible: "named-fans"
-
-child-binding:
- description: Named fan's child node
- properties:
- label:
- required: true
- type: string
- description:
- Human-readable string describing the device (used as
- device_get_binding() argument)
- rpm_min:
- required: true
- type: int
- description:
- Minimum fan speed (in RPM) to keep turning
- rpm_start:
- required: true
- type: int
- description:
- Fan speed (in RPM) to begin turning
- rpm_max:
- required: true
- type: int
- description:
- Maximum fan speed (in RPM)
- pwm:
- type: phandle
- required: true
- description:
- PWM channel to control the fan
- tach:
- type: phandle
- required: false
- description:
- Tachometer to measure the fan speed
- not_use_rpm_mode:
- required: false
- type: boolean
- description:
- Disable automatic RPM control using tachometer input
- use_fast_start:
- required: false
- type: boolean
- description:
- Fan requires a higher duty cycle to start up than to keep
- running
- pgood_gpio:
- required: false
- type: phandle
- description:
- Active high input GPIO which signals the power is good
- enable_gpio:
- required: false
- type: phandle
- description:
- Active high output GPIO to enable the power
diff --git a/zephyr/dts/bindings/gpio/gpio-enum-name.yaml b/zephyr/dts/bindings/gpio/gpio-enum-name.yaml
deleted file mode 100644
index b7fc3809ac..0000000000
--- a/zephyr/dts/bindings/gpio/gpio-enum-name.yaml
+++ /dev/null
@@ -1,180 +0,0 @@
-description: Named GPIOs parent node
-properties:
- enum-name:
- type: string
- description:
- Enum used in code.
- enum:
- - GPIO_ACCEL_GYRO_INT_L
- - GPIO_AC_PRESENT
- - GPIO_ALS_RGB_INT_ODL
- - GPIO_AP_EC_WARM_RST_REQ
- - GPIO_AP_EC_WATCHDOG_L
- - GPIO_AP_IN_SLEEP_L
- - GPIO_AP_RST_L
- - GPIO_AP_SUSPEND
- - GPIO_AP_XHCI_INIT_DONE
- - GPIO_BASE_IMU_INT_L
- - GPIO_BATT_PRES_ODL
- - GPIO_BC12_DET_EN
- - GPIO_BOARD_VERSION1
- - GPIO_BOARD_VERSION2
- - GPIO_BOARD_VERSION3
- - GPIO_CCD_MODE_ODL
- - GPIO_CHARGER_PROCHOT_ODL
- - GPIO_CPU_PROCHOT
- - GPIO_DA9313_GPIO0
- - GPIO_DEPRECATED_AP_RST_REQ
- - GPIO_DP_AUX_PATH_SEL
- - GPIO_DP_HOT_PLUG_DET
- - GPIO_DP_MUX_OE_L
- - GPIO_DP_MUX_SEL
- - GPIO_EC_ACCEL_INT
- - GPIO_EC_ALS_RGB_INT_L
- - GPIO_EC_BL_EN_OD
- - GPIO_EC_CHG_LED_W_C0
- - GPIO_EC_CHG_LED_Y_C0
- - GPIO_EC_CHG_LED_B_C1
- - GPIO_EC_CHG_LED_W_C1
- - GPIO_EC_CHG_LED_Y_C1
- - GPIO_EC_DPBRDG_HPD_ODL
- - GPIO_EC_I2C_SENSOR_SCL
- - GPIO_EC_I2C_SENSOR_SDA
- - GPIO_EC_I2C0_SENSOR_SCL
- - GPIO_EC_I2C0_SENSOR_SDA
- - GPIO_EC_I2C1_USB_C0_SCL
- - GPIO_EC_I2C1_USB_C0_SDA
- - GPIO_EC_I2C2_USB_C1_SCL
- - GPIO_EC_I2C2_USB_C1_SDA
- - GPIO_EC_I2C3_USB_1_MIX_SCL
- - GPIO_EC_I2C3_USB_1_MIX_SDA
- - GPIO_EC_I2C5_BATTERY_SCL
- - GPIO_EC_I2C5_BATTERY_SDA
- - GPIO_EC_I2C7_EEPROM_PWR_SCL_R
- - GPIO_EC_I2C7_EEPROM_PWR_SDA_R
- - GPIO_EC_IMU_INT_L
- - GPIO_EC_INT_L
- - GPIO_EC_PCH_SYS_PWROK
- - GPIO_EC_PCH_WAKE_ODL
- - GPIO_EC_PCORE_INT_ODL
- - GPIO_EC_PMIC_EN_ODL
- - GPIO_EC_PMIC_WATCHDOG_L
- - GPIO_EC_PROCHOT_IN_L
- - GPIO_EC_PWR_BTN_ODL
- - GPIO_EC_RST_ODL
- - GPIO_EC_WP_L
- - GPIO_EC_X_GPIO1
- - GPIO_EC_X_GPIO3
- - GPIO_EN_5V_USM
- - GPIO_EN_A_RAILS
- - GPIO_EN_EC_ID_ODL
- - GPIO_EN_PP3000_SD_U
- - GPIO_EN_PP3000_VMC_PMU
- - GPIO_EN_PP3300_A
- - GPIO_EN_PP5000
- - GPIO_EN_PP5000_A
- - GPIO_EN_PP5000_FAN
- - GPIO_EN_PP5000_USB_A0_VBUS
- - GPIO_EN_PP5000_USBA
- - GPIO_EN_PPVAR_VCCIN
- - GPIO_EN_PWR_A
- - GPIO_EN_PWR_PCORE_S0_R
- - GPIO_EN_PWR_S0_R
- - GPIO_EN_SLP_Z
- - GPIO_EN_USB_A_5V
- - GPIO_ENABLE_BACKLIGHT
- - GPIO_ENTERING_RW
- - GPIO_HIBERNATE_L
- - GPIO_I2C_B_SCL
- - GPIO_I2C_B_SDA
- - GPIO_I2C_C_SCL
- - GPIO_I2C_C_SDA
- - GPIO_I2C_E_SCL
- - GPIO_I2C_E_SDA
- - GPIO_I2C_F_SCL
- - GPIO_I2C_F_SDA
- - GPIO_KBD_KSO2
- - GPIO_LID_ACCEL_INT_L
- - GPIO_LID_OPEN
- - GPIO_M2_SSD_PLN
- - GPIO_PACKET_MODE_EN
- - GPIO_PCH_DSW_PWROK
- - GPIO_PCH_PWRBTN_L
- - GPIO_PCH_RSMRST_L
- - GPIO_PCH_RTCRST
- - GPIO_PCH_SLP_S0_L
- - GPIO_PCH_SLP_S3_L
- - GPIO_PCH_SLP_S4_L
- - GPIO_PCH_SLP_S5_L
- - GPIO_PCH_SLP_SUS_L
- - GPIO_PCH_SYS_PWROK
- - GPIO_PG_EC_ALL_SYS_PWRGD
- - GPIO_PG_EC_DSW_PWROK
- - GPIO_PG_EC_RSMRST_ODL
- - GPIO_PG_GROUPC_S0_OD
- - GPIO_PG_LPDDR4X_S3_OD
- - GPIO_PG_MT6360_ODL
- - GPIO_PG_MT6315_GPU_ODL
- - GPIO_PG_MT6315_PROC_ODL
- - GPIO_PG_PP5000_A_ODL
- - GPIO_PGOOD_FAN
- - GPIO_PMIC_EC_PWRGD
- - GPIO_PMIC_KPD_PWR_ODL
- - GPIO_PMIC_RESIN_L
- - GPIO_POWER_BUTTON_L
- - GPIO_POWER_GOOD
- - GPIO_PP5000_A_PG_OD
- - GPIO_PS_HOLD
- - GPIO_QSIP_ON
- - GPIO_RSMRST_L_PGOOD
- - GPIO_S0_PGOOD
- - GPIO_S5_PGOOD
- - GPIO_SET_VMC_VOLT_AT_1V8
- - GPIO_SKU_ID0
- - GPIO_SKU_ID1
- - GPIO_SKU_ID2
- - GPIO_SLP_SUS_L
- - GPIO_SPI_CLK_GPG6
- - GPIO_SPI_CS_GPG7
- - GPIO_SPI_MISO_GPG5
- - GPIO_SPI_MOSI_GPG4
- - GPIO_SPI0_CS
- - GPIO_SWITCHCAP_ON
- - GPIO_SWITCHCAP_ON_L
- - GPIO_SWITCHCAP_PG
- - GPIO_SWITCHCAP_PG_INT_L
- - GPIO_SYS_RESET_L
- - GPIO_SYS_RST_ODL
- - GPIO_TABLET_MODE_L
- - GPIO_TRACKPAD_INT_GATE
- - GPIO_USB_A_LOW_PWR_OD
- - GPIO_USB_A0_FAULT_ODL
- - GPIO_USB_A0_OC_ODL
- - GPIO_USB_C0_BC12_INT_L
- - GPIO_USB_C0_BC12_INT_ODL
- - GPIO_USB_C0_FRS_EN
- - GPIO_USB_C0_OC_ODL
- - GPIO_USB_C0_PD_INT_ODL
- - GPIO_USB_C0_PD_RST_L
- - GPIO_USB_C0_PPC_INT_ODL
- - GPIO_USB_C0_SWCTL_INT_ODL
- - GPIO_USB_C0_TCPC_INT_ODL
- - GPIO_USB_C1_BC12_INT_L
- - GPIO_USB_C1_BC12_INT_ODL
- - GPIO_USB_C1_FRS_EN
- - GPIO_USB_C1_LS_EN
- - GPIO_USB_C1_MIX_INT_ODL
- - GPIO_USB_C1_OC_ODL
- - GPIO_USB_C1_PD_INT_ODL
- - GPIO_USB_C1_PD_RST_L
- - GPIO_USB_C1_PPC_INT_ODL
- - GPIO_USB_C1_RT_RST_ODL
- - GPIO_USB_C1_SWCTL_INT_ODL
- - GPIO_USB_C1_TCPC_INT_ODL
- - GPIO_VBOB_EN
- - GPIO_VOLUME_DOWN_L
- - GPIO_VOLUME_UP_L
- - GPIO_WARM_RESET_L
- - GPIO_WP
- - GPIO_WP_L
- - GPIO_X_EC_GPIO2
diff --git a/zephyr/dts/bindings/gpio/gpio-id.yaml b/zephyr/dts/bindings/gpio/gpio-id.yaml
deleted file mode 100644
index 24322b3de8..0000000000
--- a/zephyr/dts/bindings/gpio/gpio-id.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-description: Defines board version and sku id gpios
-
-compatible: cros-ec,gpio-id
-
-properties:
- bits:
- type: phandles
- required: true
- description: GPIO list to read, LSB to MSB
-
- system:
- type: string
- description:
- Numeral system used to decode values
- - binary - expects array with values of 0 and 1.
- - binary_first_base3 - non-standard ternary number system
- where the first 2^n natural numbers are represented as
- they would be in a binary system (without any Z digits)
- and the following 3^n-2^n numbers use the remaining
- ternary representations in the normal ternary system order
- - ternary - expects array with values of 0, 1 and 2.
- It treats 'Z' state as digit '2'.
- enum:
- - binary
- - binary_first_base3
- - ternary
-
diff --git a/zephyr/dts/bindings/gpio/hibernate-wake-pins.yaml b/zephyr/dts/bindings/gpio/hibernate-wake-pins.yaml
deleted file mode 100644
index 64435f7b3b..0000000000
--- a/zephyr/dts/bindings/gpio/hibernate-wake-pins.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Hibernate Wake-up Pins Configurations
-
-compatible: "cros-ec,hibernate-wake-pins"
-
-properties:
- wakeup-pins:
- type: phandles
- required: true
- description: GPIO list for hibernate wake-up
diff --git a/zephyr/dts/bindings/gpio/named-gpios.yaml b/zephyr/dts/bindings/gpio/named-gpios.yaml
deleted file mode 100644
index 563c841f54..0000000000
--- a/zephyr/dts/bindings/gpio/named-gpios.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-description: Named GPIOs parent node
-
-compatible: "named-gpios"
-
-child-binding:
- description: Named GPIOs child node
- include: gpio-enum-name.yaml
- properties:
- gpios:
- type: phandle-array
- required: true
- label:
- required: true
- type: string
- description: |
- Human readable string describing the device (used as
- device_get_binding() argument)
- "#gpio-cells":
- type: int
- required: false
- const: 0
diff --git a/zephyr/dts/bindings/gpio/unused-gpios.yaml b/zephyr/dts/bindings/gpio/unused-gpios.yaml
deleted file mode 100644
index 99f649e25e..0000000000
--- a/zephyr/dts/bindings/gpio/unused-gpios.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-description: Unused GPIOs node
-
-compatible: "unused-gpios"
-
-properties:
- unused-gpios:
- type: phandle-array
- required: true
- description: |
- A list contains unused GPIOs. The chip vendor needs to configure them for
- better power consumption in the lowest power state.
diff --git a/zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml b/zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml
deleted file mode 100644
index ba2cc7b172..0000000000
--- a/zephyr/dts/bindings/i2c/cros-ec-i2c-port-base.yaml
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright (c) 2021 The Chromium OS Authors
-# SPDX-License-Identifier: Apache-2.0
-
-description: I2C port base properties
-
-properties:
- i2c-port:
- type: phandle
- required: true
- remote-port:
- type: int
- required: false
- description:
- A port number used by remote components like Kernel via the I2C_PASSTHRU
- Host Command
- enum-name:
- type: string
- required: true
- description:
- Enum values used in the source code to refer to the i2c port
- enum:
- - I2C_PORT_ACCEL
- - I2C_PORT_BATTERY
- - I2C_PORT_CHARGER
- - I2C_PORT_EEPROM
- - I2C_PORT_EVB_0
- - I2C_PORT_EVB_1
- - I2C_PORT_EVB_2
- - I2C_PORT_EVB_3
- - I2C_PORT_EVB_7
- - I2C_PORT_OPT_4
- - I2C_PORT_POWER
- - I2C_PORT_PPC0
- - I2C_PORT_PPC1
- - I2C_PORT_RTC
- - I2C_PORT_SENSOR
- - I2C_PORT_TCPC0
- - I2C_PORT_TCPC1
- - I2C_PORT_USB_1_MIX
- - I2C_PORT_USB_C0
- - I2C_PORT_USB_C0_C2_MUX
- - I2C_PORT_USB_C0_C2_PPC
- - I2C_PORT_USB_C0_C2_TCPC
- - I2C_PORT_USB_C1
- - I2C_PORT_USB_C1_PPC
- - I2C_PORT_USB_C1_TCPC
- - I2C_PORT_USB_MUX0
- - I2C_PORT_USB_MUX1
- - I2C_PORT_VIRTUAL
- - I2C_PORT_WLC
- label:
- required: true
- type: string
- description:
- Human readable string describing the device (used as device_get_binding()
- argument).
diff --git a/zephyr/dts/bindings/i2c/named-i2c-ports.yaml b/zephyr/dts/bindings/i2c/named-i2c-ports.yaml
deleted file mode 100644
index 4fce9c3229..0000000000
--- a/zephyr/dts/bindings/i2c/named-i2c-ports.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright (c) 2020 The Chromium OS Authors
-# SPDX-License-Identifier: Apache-2.0
-
-description: Named I2C ports parent node
-
-compatible: "named-i2c-ports"
-
-child-binding:
- description: Named I2C ports child node
- include: [cros-ec-i2c-port-base.yaml]
diff --git a/zephyr/dts/bindings/keyboard/cros-keyscan.yaml b/zephyr/dts/bindings/keyboard/cros-keyscan.yaml
deleted file mode 100644
index 11caf7fd11..0000000000
--- a/zephyr/dts/bindings/keyboard/cros-keyscan.yaml
+++ /dev/null
@@ -1,82 +0,0 @@
- # Copyright 2021 The Chromium OS Authors. All rights reserved.
- # Use of this source code is governed by a BSD-style license that can be
- # found in the LICENSE file.
-
-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/cros-ec,pwm-leds.yaml b/zephyr/dts/bindings/led/cros-ec,pwm-leds.yaml
deleted file mode 100644
index fd99e3202a..0000000000
--- a/zephyr/dts/bindings/led/cros-ec,pwm-leds.yaml
+++ /dev/null
@@ -1,75 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: PWM LED configuration
-
-compatible: "cros-ec,pwm-leds"
-
-include: base.yaml
-
-properties:
- leds:
- type: phandles
- required: true
- description: |
- List of pwm-leds nodes. These are expected to have a pwms property
- pointing to the relevant PWMs, in red, green, blue and optionally sidesel
- order.
-
- For example
- pwmleds {
- compatible = "pwm-leds";
- pwm_led0: pwm_led_0 {
- pwms = <&led3_red
- &led2_green
- &led1_blue
- &led3_sidesel
- >;
- };
- };
- cros-pwmleds {
- compatible = "cros-ec,pwm-leds";
- leds = <&pwm_led0>;
- };
-
- color-map-red:
- type: array
- required: true
- description: |
- A map of PWM duty cycles per color, up to three channels.
-
- For example
- color-map-red = <100 0 0>;
- color-map-green = < 0 100 0>;
- color-map-blue = < 0 0 100>;
- color-map-yellow = <100 70 0>;
- color-map-white = <100 70 100>;
- color-map-amber = <100 20 0>;
-
- color-map-green:
- type: array
- required: true
-
- color-map-blue:
- type: array
- required: true
-
- color-map-yellow:
- type: array
- required: true
-
- color-map-white:
- type: array
- required: true
-
- color-map-amber:
- type: array
- required: true
-
- brightness-range:
- type: array
- required: true
- description: |
- A list of brigthness range value for all supported channels in order,
- Red, Green, Blue, Yellow, White, Amber (0 to 255).
diff --git a/zephyr/dts/bindings/motionsense/cros-ec,motionsense-mutex.yaml b/zephyr/dts/bindings/motionsense/cros-ec,motionsense-mutex.yaml
deleted file mode 100644
index c988af258d..0000000000
--- a/zephyr/dts/bindings/motionsense/cros-ec,motionsense-mutex.yaml
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (c) 2021 The Chromium OS Authors
-# SPDX-License-Identifier: Apache-2.0
-
-description: Motion sense mutex parent node
-
-compatible: "cros-ec,motionsense-mutex"
-
-child-binding:
- description: A mutex node is used to create an instance of mutex_t.
- A mutex node is referenced by one or more sensor nodes in
- "/motionsense-sensors" node.
- properties:
- label:
- required: true
- type: string
- description: Human readable string describing the mutex.
- This is a brief explanation about the mutex.
- The property is not actually used in code.
-
-
-#
-# examples:
-#
-# motionsense-mutex {
-# compatible = "cros-ec,motionsense-mutex";
-# mutex_bma255: bma255-mutex {
-# label = "BMA255_MUTEX";
-# };
-#
-# mutex_bmi260: bmi260-mutex {
-# label = "BMI260_MUTEX";
-# };
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/cros-ec,motionsense-rotation-ref.yaml b/zephyr/dts/bindings/motionsense/cros-ec,motionsense-rotation-ref.yaml
deleted file mode 100644
index 7de86ec8db..0000000000
--- a/zephyr/dts/bindings/motionsense/cros-ec,motionsense-rotation-ref.yaml
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: rotation reference parent node
-
-compatible: "cros-ec,motionsense-rotation-ref"
-
-child-binding:
- description: |
- A rotation matrix node is used to create
- an instance of mat33_fp_t which is used by
- sensor drivers.
- properties:
- mat33:
- required: true
- type: array
- description: |
- 3x3 matrix to rotate x, y, and z axes.
- Applications with the sensor API expects sansor data
- based on the same defined coordinate system.
- * X-axis is horizontal and positive toward the right
- * Y-axis is vertical and positive toward the top
- * Z-axis points toward the user
-
- Depending on how the sensor is mounted on board(PCB), we
- may need to change the direction of a axis and swap X and
- Y-axis. Using the 3x3 matrix, it generates the correct
- X,Y, and Z on the defined coordinate system.
-
- +- -+ +- -+ +- -+
- | v1 v2 v3 | | sensor_X | | X |
- | v4 v5 v6 | * | sensor_Y | = | Y |
- | v7 v8 v9 | | sensor_Z | | Z |
- +- -+ +- -+ +- -+
-
-#
-# examples:
-#
-# motionsense-rotation-ref {
-# compatible = "cros-ec,motionsense-rotation-ref";
-# /* change the direction of Y and Z-axis */
-# lid_rot_ref: lid-rotation-ref {
-# mat33 = <1 0 0
-# 0 (-1) 0
-# 0 0 (-1)>;
-# };
-# /* swap X and Y-axis, and then change the direction of Y-axis */
-# base_rot_ref: base-rotation-ref {
-# mat33 = <0 1 0
-# (-1) 0 0
-# 0 0 1>;
-# };
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/cros-ec,motionsense-sensor-config.yaml b/zephyr/dts/bindings/motionsense/cros-ec,motionsense-sensor-config.yaml
deleted file mode 100644
index 68cdd15637..0000000000
--- a/zephyr/dts/bindings/motionsense/cros-ec,motionsense-sensor-config.yaml
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: |
- There are 4 configuration parameters to deal with different
- configuration
- Power | S0 | S3 | S5
- --------+-------------------+-------------------+-----------------
- From AP | <------- SENSOR_CONFIG_AP ----------> |
- | Use for normal | While sleeping | Always disabled
- | operation (game, | For Activity |
- | screen rotation) | Recognition |
- --------+-------------------+-------------------+------------------
- From EC |SENSOR_CONFIG_EC_S0|SENSOR_CONFIG_EC_S3|SENSOR_CONFIG_EC_S5
- | Background | Gesture Recognition (Double tap, ...)
- | Activity (compass,|
- | ambient light) |
-
-compatible: "cros-ec,motionsense-sensor-config"
-
-child-binding:
- description: |
- A config node is used to create a motion_data_t instance.
- Node name can only be either ap, ec-s0, ec-s3, or ec-s5,
- and it is used to indicate one of the 4 configurations.
- For example, node name ec-s0 is for SENSOR_CONFIG_EC_S0.
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <1000>;
- ec_rate = <1000>;
- };
- properties:
- label:
- type: string
- required: false
- description: |
- Human-readable string describing the config.
- see the example the above.
- odr:
- type: int
- required: false
- description: |
- Sensor output data rate in mHz.
- MSB is used to know if we are rounding up.
- ec-rate:
- type: int
- required: false
- description: Delay between collection by EC, in us.
-
-#
-# examples:
-#
-# configs {
-# compatible =
-# "cros-ec,motionsense-sensor-config";
-# ec-s0 {
-# label = "SENSOR_CONFIG_EC_S0";
-# odr = <(10000 | ROUND_UP_FLAG)>;
-# };
-# ec-s3 {
-# label = "SENSOR_CONFIG_EC_S3";
-# odr = <(10000 | ROUND_UP_FLAG)>;
-# };
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/cros-ec,motionsense-sensor-info.yaml b/zephyr/dts/bindings/motionsense/cros-ec,motionsense-sensor-info.yaml
deleted file mode 100644
index e413e2bfff..0000000000
--- a/zephyr/dts/bindings/motionsense/cros-ec,motionsense-sensor-info.yaml
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: The node has the information required by motion sense running
-
-compatible: "cros-ec,motionsense-sensor-info"
-
-properties:
- als-sensors:
- type: phandles
- required: false
- description: |
- List of ALS sensors to create motion_als_sensors array.
- The ALS sensors listed in the motion_als_sensors array
- are managed by motion sense task. The task reads the sensor
- data from the sensors and put them into the designated part
- in the ec mmap. For example, als_clear and als_rgb are aliases
- of ALS sensor noded defined in motionsense-sensor node.
- als-sensors = <&als_clear, &als_rgb>;
- This will automatically generate motion_als_sensors array from it.
- sensor-irqs:
- type: phandles
- required: false
- description: |
- List of GPIO interrupts from sensors to be enabled.
- GPIOs specified here will be enabled before motion sense task starts.
- sensor-irqs = <&gpio_ec_imu_int_l &gpio_ec_als_rgb_int_l>;
- accel-force-mode-sensors:
- type: phandles
- required: false
- description: |
- List of sensors should be handled in force mode. Sensors listed will be
- used to define CONFIG_ACCEL_FORCE_MODE_MASK so that motion sense task can
- manage them in force mode.
- accel-force-mode-sensors = <&lid_accel &als_clear>;
-
-#
-# examples:
-#
-# motionsense-sensor-info {
-# compatible = "cros-ec,motionsense-sensor-info";
-#
-# /* list of entries for motion_als_sensors */
-# als-sensors = <&als_clear>;
-#
-# /*
-# * list of GPIO interrupts that have to
-# * be enabled at initial stage
-# */
-# sensor-irqs = <&gpio_ec_imu_int_l &gpio_ec_als_rgb_int_l>;
-#
-# /* list of sensors in force mode */
-# accel-force-mode-sensors = <&lid_accel &als_clear>;
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/driver/bmi160.yaml b/zephyr/dts/bindings/motionsense/driver/bmi160.yaml
deleted file mode 100644
index 8f490254a3..0000000000
--- a/zephyr/dts/bindings/motionsense/driver/bmi160.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# common fields for both BMI160 accel and BMI160 gyro
-
-# every motionsense sensor node should include motionsense-sensor-base.yaml
-include: motionsense-sensor-base.yaml
-
-properties:
- i2c-spi-addr-flags:
- type: string
- description: i2c address or SPI slave logic GPIO
- enum:
- - "BMI160_ADDR0_FLAGS"
- default: "BMI160_ADDR0_FLAGS"
diff --git a/zephyr/dts/bindings/motionsense/driver/bmi260.yaml b/zephyr/dts/bindings/motionsense/driver/bmi260.yaml
deleted file mode 100644
index f308472ec3..0000000000
--- a/zephyr/dts/bindings/motionsense/driver/bmi260.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# common fields for both BMI260 accel and BMI260 gyro
-
-# every motionsense sensor node should include motionsense-sensor-base.yaml
-include: motionsense-sensor-base.yaml
-
-properties:
- i2c-spi-addr-flags:
- type: string
- description: i2c address or SPI slave logic GPIO
- enum:
- - "BMI260_ADDR0_FLAGS"
- default: "BMI260_ADDR0_FLAGS"
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,bma255.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,bma255.yaml
deleted file mode 100644
index 77d6282d7f..0000000000
--- a/zephyr/dts/bindings/motionsense/driver/cros-ec,bma255.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: motionsense sensor node for BMA255
-
-compatible: "cros-ec,bma255"
-
-# every motionsense sensor node should include motionsense-sensor-base.yaml
-include: motionsense-sensor-base.yaml
-
-properties:
- i2c-spi-addr-flags:
- type: string
- description: i2c address or SPI slave logic GPIO
- enum:
- - "BMA2x2_I2C_ADDR1_FLAGS"
- - "BMA2x2_I2C_ADDR2_FLAGS"
- - "BMA2x2_I2C_ADDR3_FLAGS"
- - "BMA2x2_I2C_ADDR4_FLAGS"
- default: "BMA2x2_I2C_ADDR1_FLAGS"
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi160-accel.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi160-accel.yaml
deleted file mode 100644
index 4eabf12cd5..0000000000
--- a/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi160-accel.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: motion sense sensor node for BMI160 accel
-
-compatible: "cros-ec,bmi160-accel"
-
-include: bmi160.yaml
-
-properties:
- default-range:
- default: 4
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi160-gyro.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi160-gyro.yaml
deleted file mode 100644
index b7a0b38290..0000000000
--- a/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi160-gyro.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: motion sense sensor node for BMI160 gyro
-
-compatible: "cros-ec,bmi160-gyro"
-
-include: bmi160.yaml
-
-properties:
- default-range:
- default: 1000
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi260-accel.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi260-accel.yaml
deleted file mode 100644
index 130600cca2..0000000000
--- a/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi260-accel.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: motion sense sensor node for BMI260 accel
-
-compatible: "cros-ec,bmi260-accel"
-
-include: bmi260.yaml
-
-properties:
- default-range:
- default: 4
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi260-gyro.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi260-gyro.yaml
deleted file mode 100644
index 00226d0304..0000000000
--- a/zephyr/dts/bindings/motionsense/driver/cros-ec,bmi260-gyro.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: motion sense sensor node for BMI260 gyro
-
-compatible: "cros-ec,bmi260-gyro"
-
-include: bmi260.yaml
-
-properties:
- default-range:
- default: 1000
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,kx022.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,kx022.yaml
deleted file mode 100644
index b90d824575..0000000000
--- a/zephyr/dts/bindings/motionsense/driver/cros-ec,kx022.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: motionsense sensor node for KX022
-
-compatible: "cros-ec,kx022"
-
-# every motionsense sensor node should include motionsense-sensor-base.yaml
-include: motionsense-sensor-base.yaml
-
-properties:
- i2c-spi-addr-flags:
- type: string
- description: i2c address or SPI slave logic GPIO
- enum:
- - "KX022_ADDR0_FLAGS"
- - "KX022_ADDR1_FLAGS"
- default: "KX022_ADDR0_FLAGS"
- default-range:
- default: 2
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,lis2dw12.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,lis2dw12.yaml
deleted file mode 100644
index bacf8f2c75..0000000000
--- a/zephyr/dts/bindings/motionsense/driver/cros-ec,lis2dw12.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: motionsense sensor node for LIS2DW12 Accelerometer
-
-compatible: "cros-ec,lis2dw12"
-
-# every motionsense sensor node should include motionsense-sensor-base.yaml
-include: motionsense-sensor-base.yaml
-
-properties:
- i2c-spi-addr-flags:
- type: string
- description: i2c address or SPI peripheral logic GPIO
- enum:
- - "LIS2DWL_ADDR0_FLAGS"
- - "LIS2DWL_ADDR1_FLAGS"
- default: "LIS2DWL_ADDR1_FLAGS"
- default-range:
- default: 2
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,tcs3400-clear.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,tcs3400-clear.yaml
deleted file mode 100644
index 323286c462..0000000000
--- a/zephyr/dts/bindings/motionsense/driver/cros-ec,tcs3400-clear.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: motion sense sensor node for TCS3400 CLEAR
-
-compatible: "cros-ec,tcs3400-clear"
-
-include: tcs3400.yaml
diff --git a/zephyr/dts/bindings/motionsense/driver/cros-ec,tcs3400-rgb.yaml b/zephyr/dts/bindings/motionsense/driver/cros-ec,tcs3400-rgb.yaml
deleted file mode 100644
index e2987cf44b..0000000000
--- a/zephyr/dts/bindings/motionsense/driver/cros-ec,tcs3400-rgb.yaml
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: motion sense sensor node for TCS3400 RGB
-
-compatible: "cros-ec,tcs3400-rgb"
-
-include: tcs3400.yaml
diff --git a/zephyr/dts/bindings/motionsense/driver/tcs3400.yaml b/zephyr/dts/bindings/motionsense/driver/tcs3400.yaml
deleted file mode 100644
index 2fc3d7eacd..0000000000
--- a/zephyr/dts/bindings/motionsense/driver/tcs3400.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# common fields for both TCS3400 clear and TCS3400 rgb
-
-# every motionsense sensor node should include motionsense-sensor-base.yaml
-include: motionsense-sensor-base.yaml
-
-properties:
- i2c-spi-addr-flags:
- type: string
- description: i2c address or SPI slave logic GPIO
- enum:
- - "TCS3400_I2C_ADDR_FLAGS"
- default: "TCS3400_I2C_ADDR_FLAGS"
- default-range:
- default: 0x10000 # scale = 1x, uscale = 0
diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,accelgyro-als-channel-scale.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,accelgyro-als-channel-scale.yaml
deleted file mode 100644
index 753edc7ea8..0000000000
--- a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,accelgyro-als-channel-scale.yaml
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: |
- Bindings for als_channel_scale_t in accelgyro.h.
- Each channel has scaling factor for normalization & cover
-
-compatible: cros-ec,accelgyro-als-channel-scale
-
-properties:
- k-channel-scale:
- type: int
- required: true
- description: Channel scale factor
- cover-scale:
- type: int
- required: true
- description: Cover compensation scale factor
-
-#
-# examples:
-#
-# als-channel-scale {
-# compatible = "cros-ec,accelgyro-als-channel-scale";
-# k-channel-scale = <1>;
-# cover-scale = <1>;
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,accelgyro-als-drv-data.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,accelgyro-als-drv-data.yaml
deleted file mode 100644
index 7d64689cf2..0000000000
--- a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,accelgyro-als-drv-data.yaml
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: ALS driver data
-
-compatible: "cros-ec,accelgyro-als-drv-data"
-
-child-binding:
- description: ALS calibration data
- properties:
- scale:
- type: int
- required: true
- description: |
- Scale, uscale, and offset are used to correct the raw 16 bit ALS data
- and then to convert it to 32 bit using the following equations
- raw_value += offset;\n
- adjusted_value = raw_value * scale + raw_value * uscale / 10000;
- uscale:
- type: int
- required: true
- description: uscale
- offset:
- type: int
- required: true
- description: offset
-
-#
-# examples:
-# als-drv-data {
-# compatible = "cros-ec,accelgyro-als-drv-data";
-# als-cal {
-# scale = <1>;
-# uscale = <0>;
-# offset = <0>;
-# als-channel-scale {
-# compatible = "cros-ec,accelgyro-als-channel-scale";
-# k-channel-scale = <1>;
-# cover-scale = <1>;
-# };
-# };
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,accelgyro-rgb-calibration.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,accelgyro-rgb-calibration.yaml
deleted file mode 100644
index 4204a63cff..0000000000
--- a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,accelgyro-rgb-calibration.yaml
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: bindings for rgb_calibration_t in accelgyro.h
-
-compatible: "cros-ec,accelgyro-rgb-calibration"
-
-properties:
- irt:
- type: int
- required: true
- description: incandecent scaling factor
-
-child-binding:
- description: RGB ALS Calibration Data
- properties:
- offset:
- type: int
- required: true
- description: Any offset to add to raw channel data
- coeff:
- type: array
- required: true
- description: Clear, R, G, and B coefficients for this channel
-
-#
-# examples:
-#
-# rgb_calibration {
-# compatible = "cros-ec,accelgyro-rgb-calibration";
-#
-# irt = <1>;
-#
-# rgb-cal-x {
-# offset = <0>;
-# coeff = <0 0 0 0>;
-# als-channel-scale {
-# compatible = "cros-ec,accelgyro-als-channel-scale";
-# k-channel-scale = <1>;
-# cover-scale = <1>;
-# };
-# };
-# rgb-cal-y {
-# offset = <0>;
-# coeff = <0 0 0 0>;
-# als-channel-scale {
-# compatible = "cros-ec,accelgyro-als-channel-scale";
-# k-channel-scale = <1>;
-# cover-scale = <1>;
-# };
-# };
-# rgb-cal-z {
-# offset = <0>;
-# coeff = <0 0 0 0>;
-# als-channel-scale {
-# compatible = "cros-ec,accelgyro-als-channel-scale";
-# k-channel-scale = <1>;
-# cover-scale = <1>;
-# };
-# };
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bma255.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bma255.yaml
deleted file mode 100644
index 4cabd620da..0000000000
--- a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bma255.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: BMA255 driver data node
-
-compatible: "cros-ec,drvdata-bma255"
-
-include: drvdata-base.yaml
-
-#
-# examples:
-#
-# bma255_data: bma255-drv-data {
-# compatible = "cros-ec,drvdata-bma255";
-# status = "okay";
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bmi160.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bmi160.yaml
deleted file mode 100644
index 52f5c346fc..0000000000
--- a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bmi160.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: BMI160 driver data node
-
-compatible: "cros-ec,drvdata-bmi160"
-
-include: drvdata-base.yaml
-
-#
-# examples:
-#
-# bmi160_data: bmi160-drv-data {
-# compatible = "cros-ec,drvdata-bmi160";
-# status = "okay";
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bmi260.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bmi260.yaml
deleted file mode 100644
index 4d414121d1..0000000000
--- a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-bmi260.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: BMI260 driver data node
-
-compatible: "cros-ec,drvdata-bmi260"
-
-include: drvdata-base.yaml
-
-#
-# examples:
-#
-# bmi260_data: bmi260-drv-data {
-# compatible = "cros-ec,drvdata-bmi260";
-# status = "okay";
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-kionix.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-kionix.yaml
deleted file mode 100644
index 3151412b79..0000000000
--- a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-kionix.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Kionix driver data node
-
-compatible: "cros-ec,drvdata-kionix"
-
-include: drvdata-base.yaml
-
-#
-# examples:
-#
-# kx022_data: kx022-drv-data {
-# compatible = "cros-ec,drvdata-kionix";
-# status = "okay";
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-lis2dw12.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-lis2dw12.yaml
deleted file mode 100644
index ecb182a4fd..0000000000
--- a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-lis2dw12.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: LIS2DW12 driver data node
-
-compatible: "cros-ec,drvdata-lis2dw12"
-
-include: drvdata-base.yaml
-
-#
-# examples:
-#
-# lis2dw12_data: lis2dw12-drv-data {
-# compatible = "cros-ec,drvdata-lis2dw12";
-# status = "okay";
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-tcs3400-clear.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-tcs3400-clear.yaml
deleted file mode 100644
index c1059d40be..0000000000
--- a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-tcs3400-clear.yaml
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: TCS3400 CLEAR driver data
-
-compatible: "cros-ec,drvdata-tcs3400-clear"
-
-include: drvdata-base.yaml
-
-#
-# examples:
-#
-# tcs_clear_data: tcs3400-clear-drv-data {
-# compatible = "cros-ec,drvdata-tcs3400-clear";
-# status = "okay";
-#
-# als-drv-data {
-# compatible = "cros-ec,accelgyro-als-drv-data";
-# als-cal {
-# scale = <1>;
-# uscale = <0>;
-# offset = <0>;
-# als-channel-scale {
-# compatible = "cros-ec,accelgyro-als-channel-scale";
-# k-channel-scale = <1>;
-# cover-scale = <1>;
-# };
-# };
-# };
-# };
-#
diff --git a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-tcs3400-rgb.yaml b/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-tcs3400-rgb.yaml
deleted file mode 100644
index 7ae7bc5983..0000000000
--- a/zephyr/dts/bindings/motionsense/drvdata/cros-ec,drvdata-tcs3400-rgb.yaml
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: TCS3400 RGB driver data
-
-compatible: "cros-ec,drvdata-tcs3400-rgb"
-
-include: drvdata-base.yaml
-
-child-binding:
- description: saturation auto-adjustment
- properties:
- again:
- type: int
- required: false
- description: Gain Scaling; must be value between 0 and 3
- atime:
- type: int
- required: false
- description: Acquisition Time, controlled by the ATIME register
diff --git a/zephyr/dts/bindings/motionsense/drvdata/drvdata-base.yaml b/zephyr/dts/bindings/motionsense/drvdata/drvdata-base.yaml
deleted file mode 100644
index dc32d69d21..0000000000
--- a/zephyr/dts/bindings/motionsense/drvdata/drvdata-base.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# common fields for driver data
-
-include: base.yaml
-
-properties:
- status:
- required: true
diff --git a/zephyr/dts/bindings/motionsense/motionsense-sensor-base.yaml b/zephyr/dts/bindings/motionsense/motionsense-sensor-base.yaml
deleted file mode 100644
index 6948ce6997..0000000000
--- a/zephyr/dts/bindings/motionsense/motionsense-sensor-base.yaml
+++ /dev/null
@@ -1,82 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Common fields for motion sensors
-
-include: base.yaml
-
-properties:
- status:
- required: true
- label:
- type: string
- required: true
- description: |
- Human readable string describing the motion sensor.
- This is used as the name of the motion sensor.
- e.g) label = "Lid Accel";
- active-mask:
- type: string
- description: indicates system power state for sensor to be active
- enum:
- - "SENSOR_ACTIVE_S5"
- - "SENSOR_ACTIVE_S3"
- - "SENSOR_ACTIVE_S0"
- - "SENSOR_ACTIVE_S0_S3"
- - "SENSOR_ACTIVE_S0_S3_S5"
- default: "SENSOR_ACTIVE_S0_S3"
- location:
- type: string
- required: true
- description: location of the motion sensor
- enum:
- - "MOTIONSENSE_LOC_BASE"
- - "MOTIONSENSE_LOC_LID"
- - "MOTIONSENSE_LOC_CAMERA"
- mutex:
- type: phandle
- required: false
- description: mutex used by chip driver
- port:
- type: phandle
- required: false
- description: phandle to the named i2c port
- rot-standard-ref:
- type: phandle
- required: false
- description: phandle to 3x3 rotation matrix
- default-range:
- type: int
- required: false
- description: default range of sensor read
- drv-data:
- type: phandle
- required: false
- description: phandle to driver data to be used for the motion sensor
- alternate-for:
- type: phandle
- description: phandle to another sensor that can be swapped with this one
- at runtime.
- alternate-indicator:
- type: phandle
- description: phandle to CBI SSGC value indicating that the sensor
- should be used
-
-#
-# examples:
-#
-# lid_accel: lid-accel {
-# compatible = "cros-ec,bma255";
-# status = "okay";
-#
-# label = "Lid Accel";
-# active-mask = "SENSOR_ACTIVE_S0_S3";
-# location = "MOTIONSENSE_LOC_LID";
-# mutex = <&mutex_bma255>;
-# port = <&i2c_sensor>;
-# rot-standard-ref = <&lid_rot_ref>;
-# default-range = <2>;
-# drv-data = <&bma255_data>;
-# };
-#
diff --git a/zephyr/dts/bindings/pwm/named-pwms.yaml b/zephyr/dts/bindings/pwm/named-pwms.yaml
deleted file mode 100644
index f01fd5a30a..0000000000
--- a/zephyr/dts/bindings/pwm/named-pwms.yaml
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: PWM KEYS parent node
-
-compatible: "named-pwms"
-
-child-binding:
- description: Named PWMs child node
- properties:
- pwms:
- type: phandle-array
- required: true
- label:
- required: true
- type: string
- description:
- Human readable string describing the device (used as
- device_get_binding() argument)
- frequency:
- required: true
- type: int
- description: PWM frequency, in Hz
diff --git a/zephyr/dts/bindings/retimer/intel,jhl8040r.yaml b/zephyr/dts/bindings/retimer/intel,jhl8040r.yaml
deleted file mode 100644
index 6b39833048..0000000000
--- a/zephyr/dts/bindings/retimer/intel,jhl8040r.yaml
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: Intel JHL8040R Thunderbolt 4 Retimer
-
-compatible: "intel,jhl8040r"
-
-include: i2c-device.yaml
-
-properties:
- reset-gpios:
- type: phandle-array
- required: true
-
- int-gpios:
- type: phandle-array
- required: false
-
- ls-en-gpios:
- type: phandle-array
- required: false
diff --git a/zephyr/dts/bindings/switchcap/switchcap-gpio.yaml b/zephyr/dts/bindings/switchcap/switchcap-gpio.yaml
deleted file mode 100644
index 5d1a25bf94..0000000000
--- a/zephyr/dts/bindings/switchcap/switchcap-gpio.yaml
+++ /dev/null
@@ -1,16 +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
diff --git a/zephyr/dts/bindings/switchcap/switchcap-ln9310.yaml b/zephyr/dts/bindings/switchcap/switchcap-ln9310.yaml
deleted file mode 100644
index afd89aacc6..0000000000
--- a/zephyr/dts/bindings/switchcap/switchcap-ln9310.yaml
+++ /dev/null
@@ -1,27 +0,0 @@
-description: SwitchCap controlled by LN9310
-
-compatible: "switchcap-ln9310"
-
-properties:
- enable-l-pin:
- type: phandle
- required: true
- description: |
- GPIO used to enable the switch cap - active low
-
- 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/temp/cros_ec_temp_sensor.yaml b/zephyr/dts/bindings/temp/cros_ec_temp_sensor.yaml
deleted file mode 100644
index 288dc2d1c8..0000000000
--- a/zephyr/dts/bindings/temp/cros_ec_temp_sensor.yaml
+++ /dev/null
@@ -1,86 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-description: >
- Common properties for temperature sensors
- Zero values in degrees K(-273 in degrees C)in thermal thresholds will
- be ignored
-
-compatible: cros-ec,temp-sensor
-
-properties:
- adc:
- required: true
- type: phandle
- description: The named adc channel
-
- thermistor:
- type: phandle
- description: Underlying thermistor device if used
-
- label:
- required: true
- type: string
- description:
- Human-readable string describing the device (used as
- device_get_binding() argument)
-
- enum-name:
- type: string
- required: true
- description:
- Enum values used in the source code to refer to the temperature sensors
- enum:
- - TEMP_SENSOR_CHARGER
- - TEMP_SENSOR_DDR_SOC
- - TEMP_SENSOR_FAN
- - TEMP_SENSOR_PP3300_REGULATOR
-
- temp_fan_off:
- type: int
- description:
- Temperature threshold in degrees C when no active cooling
- is needed
-
- temp_fan_max:
- type: int
- description:
- Temperature threshold in degrees C when max active cooling
- is needed
-
- temp_host_warn:
- type: int
- description:
- Temperature threshold in degrees C of thermal warn.
- Temperatures above the thermal warn threshold generate a
- request to the AP to throttle itself.
-
- temp_host_high:
- type: int
- description:
- Temperature threshold in degrees C of thermal high.
- Temperatures above the thermal high threshold cause the EC to
- assert a signal (usually PROCHOT) to the AP and force the AP to
- throttle.
-
- temp_host_halt:
- type: int
- description:
- Temperature threshold in degrees C that forces AP to shutdown
- due to thermal reason
-
- temp_host_release_warn:
- type: int
- description:
- Temperature release threshold in degrees C of thermal warn
-
- temp_host_release_high:
- type: int
- description:
- Temperature release threshold in degrees C of thermal high
-
- temp_host_release_halt:
- type: int
- description:
- Temperature release threshold in degrees C of thermal shutdown
diff --git a/zephyr/dts/bindings/temp/cros_ec_thermistor.yaml b/zephyr/dts/bindings/temp/cros_ec_thermistor.yaml
deleted file mode 100644
index d4bc32ed3c..0000000000
--- a/zephyr/dts/bindings/temp/cros_ec_thermistor.yaml
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# For more information:
-# https://www.electronics-tutorials.ws/io/thermistors.html
-
-description: Common properties for thermistors
-
-compatible: cros-ec,thermistor
-
-properties:
- scaling-factor:
- required: true
- type: int
- description: Scaling factor for voltage pairs
-
- num-pairs:
- required: true
- type: int
- description: Number of sample data points for linear interpolation
-
- steinhart-reference-mv:
- required: true
- type: int
- description: >
- Used only for testing.
- Is the reference voltage for temperature 25C.
-
- steinhart-reference-res:
- required: true
- type: int
- description: >
- Used only for testing.
- Is the reference resistance for temperature 25C.
-
-child-binding:
- description: >
- Data samples derived from Steinhart-Hart
- equation in a resistor divider circuit.
- Used in linear interpolation.
-
- properties:
- milivolt:
- type: int
- required: true
- description: Voltage reading for a given temperature sample
-
- temp:
- type: int
- required: true
- description: Temperature (Celcius) in a sample
-
- sample-index:
- type: int
- required: true
- description: The index of a datum to maintain sample order to interpolate.
diff --git a/zephyr/dts/bindings/vendor-prefixes.txt b/zephyr/dts/bindings/vendor-prefixes.txt
deleted file mode 100644
index 856fa81426..0000000000
--- a/zephyr/dts/bindings/vendor-prefixes.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Valid device-tree compatible string prefixes used in this
-# Zephyr module. The format is:
-# vendor-prefix<TAB>vendor name
-cros-ec The Chromium OS Embedded Controller Project
diff --git a/zephyr/dts/board-overlays/native_posix.dts b/zephyr/dts/board-overlays/native_posix.dts
deleted file mode 100644
index b8faf65842..0000000000
--- a/zephyr/dts/board-overlays/native_posix.dts
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* TODO(sjg): add things */
diff --git a/zephyr/emul/CMakeLists.txt b/zephyr/emul/CMakeLists.txt
deleted file mode 100644
index 02b176b942..0000000000
--- a/zephyr/emul/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-zephyr_library_sources_ifdef(CONFIG_EMUL_COMMON_I2C emul_common_i2c.c)
-zephyr_library_sources_ifdef(CONFIG_EMUL_SMART_BATTERY emul_smart_battery.c)
-zephyr_library_sources_ifdef(CONFIG_EMUL_BMA255 emul_bma255.c)
-zephyr_library_sources_ifdef(CONFIG_EMUL_BC12_DETECT_PI3USB9201 emul_pi3usb9201.c)
-zephyr_library_sources_ifdef(CONFIG_EMUL_PPC_SYV682X emul_syv682x.c)
-zephyr_library_sources_ifdef(CONFIG_EMUL_BMI emul_bmi.c)
-zephyr_library_sources_ifdef(CONFIG_EMUL_BMI emul_bmi160.c)
-zephyr_library_sources_ifdef(CONFIG_EMUL_BMI emul_bmi260.c)
-zephyr_library_sources_ifdef(CONFIG_EMUL_TCS3400 emul_tcs3400.c)
-zephyr_library_sources_ifdef(CONFIG_EMUL_BB_RETIMER emul_bb_retimer.c)
-zephyr_library_sources_ifdef(CONFIG_EMUL_LN9310 emul_ln9310.c)
-zephyr_library_sources_ifdef(CONFIG_EMUL_LIS2DW12 emul_lis2dw12.c)
-zephyr_library_sources_ifdef(CONFIG_I2C_MOCK i2c_mock.c)
diff --git a/zephyr/emul/Kconfig b/zephyr/emul/Kconfig
deleted file mode 100644
index 8d9c8e42ea..0000000000
--- a/zephyr/emul/Kconfig
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-config EMUL_COMMON_I2C
- bool "Common handler for I2C emulator messages"
- help
- Enable common code that is used by many emulators of devices on I2C
- bus. It allows to share code for handling I2C messages, locking and
- custom user handlers between these emulators.
-
-config EMUL_SMART_BATTERY
- bool "Smart Battery emulator"
- select EMUL_COMMON_I2C
- help
- Enable the Smart Battery emulator. This driver use emulated I2C bus.
-
-config EMUL_BMA255
- bool "BMA255 emulator"
- select EMUL_COMMON_I2C
- help
- Enable the BMA255 emulator. This driver use emulated I2C bus.
- It is used to test bma2x2 driver. Emulators API is available in
- zephyr/include/emul/emul_bma255.h
-
-config EMUL_BC12_DETECT_PI3USB9201
- bool "PI3USB9201 emulator"
- help
- Enable the PI3USB9201 emulator. PI3USB9201 is a BC1.2 charger
- detector/advertiser. The emulator supports reading and writing the
- 4 I2C registers of the PI3USB9201 using the emulated I2C bus.
-
-config EMUL_PPC_SYV682X
- bool "Silergy SYV682x PPC emulator"
- select PLATFORM_EC_USBC_PPC_SYV682X
- help
- Enable the SYV682x emulator. SYV682 is a USB Type-C PPC. This driver
- uses the emulated I2C bus.
-
-config EMUL_BMI
- bool "BMI emulator"
- select EMUL_COMMON_I2C
- help
- Enable the BMI emulator. This driver use emulated I2C bus.
- It is used to test bmi 160 and 260 drivers. Emulators API is
- available in zephyr/include/emul/emul_bmi.h
-
-config EMUL_TCS3400
- bool "TCS3400 emulator"
- select EMUL_COMMON_I2C
- help
- Enable the TCS3400 light sensor. This driver use emulated I2C bus.
- It is used to test als_tcs3400 driver. It supports reading sensor
- values which are correctly scaled using current gain and integration
- time configuration, switching between IR and clear sensor and
- clearing status register using clear interrupt registers. Other
- TCS3400 registers support read and write with optional checking
- of proper access to reserved bits. Emulators API is available in
- zephyr/include/emul/emul_tcs3400.h
-
-config EMUL_BB_RETIMER
- bool "BB retimer emulator"
- select EMUL_COMMON_I2C
- help
- Enable the BB (Burnside Bridge) retimer emulator. This driver use
- emulated I2C bus. It is used to test bb_retimer driver. It supports
- reads and writes to all emulator registers. Emulators API is
- available in zephyr/include/emul/emul_bb_retimer.h
-
-rsource "Kconfig.ln9310"
-rsource "Kconfig.lis2dw12"
-rsource "Kconfig.i2c_mock"
diff --git a/zephyr/emul/Kconfig.i2c_mock b/zephyr/emul/Kconfig.i2c_mock
deleted file mode 100644
index 6c98a32739..0000000000
--- a/zephyr/emul/Kconfig.i2c_mock
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-DT_COMPAT_I2C_MOCK := cros,i2c-mock
-
-menuconfig I2C_MOCK
- bool "Mock implementation of an I2C device"
- default $(dt_compat_enabled,$(DT_COMPAT_I2C_MOCK))
- depends on I2C_EMUL
- help
- Enable the I2C mock. This driver is a pure mock and does nothing by
- default. It is used to test common i2c code. Mock API is available in
- zephyr/include/emul/i2c_mock.h
-
-if I2C_MOCK
-
-module = I2C_MOCK
-module-str = i2c_mock
-source "subsys/logging/Kconfig.template.log_config"
-
-endif # I2C_MOCK
diff --git a/zephyr/emul/Kconfig.lis2dw12 b/zephyr/emul/Kconfig.lis2dw12
deleted file mode 100644
index 2263255418..0000000000
--- a/zephyr/emul/Kconfig.lis2dw12
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-DT_COMPAT_LIS2DW12_EMUL := cros,lis2dw12-emul
-
-menuconfig EMUL_LIS2DW12
- bool "LIS2DW12 accelerometer emulator"
- default $(dt_compat_enabled,$(DT_COMPAT_LIS2DW12_EMUL))
- depends on I2C_EMUL
- select PLATFORM_EC_ACCEL_LIS2DW12
- help
- Enable the LIS2DW12 emulator. This driver uses the emulated I2C bus.
- It is used to test the lis2dw12 driver. Emulator API is available in
- zephyr/include/emul/emul_lis2dw12.h
-
-if EMUL_LIS2DW12
-
-module = LIS2DW12_EMUL
-module-str = lis2dw12_emul
-source "subsys/logging/Kconfig.template.log_config"
-
-endif # EMUL_LIS2DW12
diff --git a/zephyr/emul/Kconfig.ln9310 b/zephyr/emul/Kconfig.ln9310
deleted file mode 100644
index 5773cf3721..0000000000
--- a/zephyr/emul/Kconfig.ln9310
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-DT_COMPAT_LN9310_EMUL := cros,ln9310-emul
-
-menuconfig EMUL_LN9310
- bool "LN9310 switchcap emulator"
- default $(dt_compat_enabled,$(DT_COMPAT_LN9310_EMUL))
- depends on I2C_EMUL
- help
- Enable the LN9310 emulator. This driver uses the emulated I2C bus. It
- is used to test the ln9310 driver. Emulator API is available in
- zephyr/include/emul/emul_ln9310.h
-
-if EMUL_LN9310
-
-module = LN9310_EMUL
-module-str = ln9310_emul
-source "subsys/logging/Kconfig.template.log_config"
-
-endif # EMUL_LN9310
diff --git a/zephyr/emul/emul_bb_retimer.c b/zephyr/emul/emul_bb_retimer.c
deleted file mode 100644
index b391070b1f..0000000000
--- a/zephyr/emul/emul_bb_retimer.c
+++ /dev/null
@@ -1,365 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT cros_bb_retimer_emul
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <logging/log.h>
-LOG_MODULE_REGISTER(emul_bb_retimer);
-
-#include <device.h>
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_bb_retimer.h"
-
-#include "driver/retimer/bb_retimer.h"
-
-#define BB_DATA_FROM_I2C_EMUL(_emul) \
- CONTAINER_OF(CONTAINER_OF(_emul, struct i2c_common_emul_data, emul), \
- struct bb_emul_data, common)
-
-/** Run-time data used by the emulator */
-struct bb_emul_data {
- /** Common I2C data */
- struct i2c_common_emul_data common;
-
- /** Current state of all emulated BB retimer registers */
- uint32_t reg[BB_RETIMER_REG_COUNT];
-
- /** Vendor ID of emulated device */
- uint32_t vendor_id;
-
- /** Return error when trying to write to RO register */
- bool error_on_ro_write;
- /** Return error when trying to write 1 to reserved bit */
- bool error_on_rsvd_write;
-
- /** Value of data dword in ongoing i2c message */
- uint32_t data_dword;
-};
-
-/** Check description in emul_bb_retimer.h */
-void bb_emul_set_reg(struct i2c_emul *emul, int reg, uint32_t val)
-{
- struct bb_emul_data *data;
-
- if (reg < 0 || reg > BB_RETIMER_REG_COUNT) {
- return;
- }
-
- data = BB_DATA_FROM_I2C_EMUL(emul);
- data->reg[reg] = val;
-}
-
-/** Check description in emul_bb_retimer.h */
-uint32_t bb_emul_get_reg(struct i2c_emul *emul, int reg)
-{
- struct bb_emul_data *data;
-
- if (reg < 0 || reg > BB_RETIMER_REG_COUNT) {
- return 0;
- }
-
- data = BB_DATA_FROM_I2C_EMUL(emul);
-
- return data->reg[reg];
-}
-
-/** Check description in emul_bb_retimer.h */
-void bb_emul_set_err_on_ro_write(struct i2c_emul *emul, bool set)
-{
- struct bb_emul_data *data;
-
- data = BB_DATA_FROM_I2C_EMUL(emul);
- data->error_on_ro_write = set;
-}
-
-/** Check description in emul_bb_retimer.h */
-void bb_emul_set_err_on_rsvd_write(struct i2c_emul *emul, bool set)
-{
- struct bb_emul_data *data;
-
- data = BB_DATA_FROM_I2C_EMUL(emul);
- data->error_on_rsvd_write = set;
-}
-
-/** Mask reserved bits in each register of BB retimer */
-static const uint32_t bb_emul_rsvd_mask[] = {
- [BB_RETIMER_REG_VENDOR_ID] = 0x00000000,
- [BB_RETIMER_REG_DEVICE_ID] = 0x00000000,
- [0x02] = 0xffffffff, /* Reserved */
- [0x03] = 0xffffffff, /* Reserved */
- [BB_RETIMER_REG_CONNECTION_STATE] = 0xc0201000,
- [BB_RETIMER_REG_TBT_CONTROL] = 0xffffdfff,
- [0x06] = 0xffffffff, /* Reserved */
- [BB_RETIMER_REG_EXT_CONNECTION_MODE] = 0x08007f00,
-};
-
-/**
- * @brief Reset registers to default values
- *
- * @param emul Pointer to BB retimer emulator
- */
-static void bb_emul_reset(struct i2c_emul *emul)
-{
- struct bb_emul_data *data;
-
- data = BB_DATA_FROM_I2C_EMUL(emul);
-
- data->reg[BB_RETIMER_REG_VENDOR_ID] = data->vendor_id;
- data->reg[BB_RETIMER_REG_DEVICE_ID] = BB_RETIMER_DEVICE_ID;
- data->reg[0x02] = 0x00; /* Reserved */
- data->reg[0x03] = 0x00; /* Reserved */
- data->reg[BB_RETIMER_REG_CONNECTION_STATE] = 0x00;
- data->reg[BB_RETIMER_REG_TBT_CONTROL] = 0x00;
- data->reg[0x06] = 0x00; /* Reserved */
- data->reg[BB_RETIMER_REG_EXT_CONNECTION_MODE] = 0x00;
-}
-
-/**
- * @brief Handle I2C write message. It is checked if accessed register isn't RO
- * and reserved bits are set to 0. Write set value of reg field of BB
- * retimer emulator data ignoring reserved bits and write only bits.
- *
- * @param emul Pointer to BB retimer emulator
- * @param reg Register which is written
- * @param msg_len Length of handled I2C message
- *
- * @return 0 on success
- * @return -EIO on error
- */
-static int bb_emul_handle_write(struct i2c_emul *emul, int reg, int msg_len)
-{
- struct bb_emul_data *data;
- uint32_t val;
-
- data = BB_DATA_FROM_I2C_EMUL(emul);
-
- /* This write only selected register for I2C read message */
- if (msg_len < 2) {
- return 0;
- }
-
- val = data->data_dword;
-
- /*
- * BB retimer ignores data bytes above 4 and use zeros if there is less
- * then 4 data bytes. Emulator prints warning in that case.
- */
- if (msg_len != 6) {
- LOG_WRN("Got %d bytes of WR data, expected 4", msg_len - 2);
- }
-
- if (reg <= BB_RETIMER_REG_DEVICE_ID ||
- reg >= BB_RETIMER_REG_COUNT ||
- reg == BB_RETIMER_REG_TBT_CONTROL) {
- if (data->error_on_ro_write) {
- LOG_ERR("Writing to reg 0x%x which is RO", reg);
- return -EIO;
- }
-
- return 0;
- }
-
- if (data->error_on_rsvd_write && bb_emul_rsvd_mask[reg] & val) {
- LOG_ERR("Writing 0x%x to reg 0x%x with rsvd bits mask 0x%x",
- val, reg, bb_emul_rsvd_mask[reg]);
- return -EIO;
- }
-
- /* Ignore all reserved bits */
- val &= ~bb_emul_rsvd_mask[reg];
- val |= data->reg[reg] & bb_emul_rsvd_mask[reg];
-
- data->reg[reg] = val;
-
- return 0;
-}
-
-/**
- * @brief Handle I2C read message. Response is obtained from reg field of bb
- * emul data.
- *
- * @param emul Pointer to BB retimer emulator
- * @param reg Register address to read
- *
- * @return 0 on success
- * @return -EIO on error
- */
-static int bb_emul_handle_read(struct i2c_emul *emul, int reg)
-{
- struct bb_emul_data *data;
-
- data = BB_DATA_FROM_I2C_EMUL(emul);
-
- if (reg >= BB_RETIMER_REG_COUNT) {
- LOG_ERR("Read unknown register 0x%x", reg);
-
- return -EIO;
- }
-
- data->data_dword = data->reg[reg];
-
- return 0;
-}
-
-/**
- * @brief Function called for each byte of write message. Data are stored
- * in data_dword field of bb_emul_data
- *
- * @param emul Pointer to BB retimer emulator
- * @param reg First byte of write message
- * @param val Received byte of write message
- * @param bytes Number of bytes already received
- *
- * @return 0 on success
- */
-static int bb_emul_write_byte(struct i2c_emul *emul, int reg, uint8_t val,
- int bytes)
-{
- struct bb_emul_data *data;
-
- data = BB_DATA_FROM_I2C_EMUL(emul);
-
- if (bytes == 1) {
- data->data_dword = 0;
- if (val != 4) {
- LOG_WRN("Invalid write size");
- }
- } else if (bytes < 6) {
- data->data_dword |= val << (8 * (bytes - 2));
- }
-
- return 0;
-}
-
-/**
- * @brief Function called for each byte of read message. data_dword is converted
- * to read message response.
- *
- * @param emul Pointer to BB retimer emulator
- * @param reg First byte of last write message
- * @param val Pointer where byte to read should be stored
- * @param bytes Number of bytes already readed
- *
- * @return 0 on success
- */
-static int bb_emul_read_byte(struct i2c_emul *emul, int reg, uint8_t *val,
- int bytes)
-{
- struct bb_emul_data *data;
-
- data = BB_DATA_FROM_I2C_EMUL(emul);
-
- /* First byte of read message is read size which is always 4 */
- if (bytes == 0) {
- *val = 4;
- return 0;
- }
-
- *val = data->data_dword & 0xff;
- data->data_dword >>= 8;
-
- return 0;
-}
-
-/**
- * @brief Get currently accessed register, which always equals to selected
- * register.
- *
- * @param emul Pointer to BB retimer emulator
- * @param reg First byte of last write message
- * @param bytes Number of bytes already handled from current message
- * @param read If currently handled is read message
- *
- * @return Currently accessed register
- */
-static int bb_emul_access_reg(struct i2c_emul *emul, int reg, int bytes,
- bool read)
-{
- return reg;
-}
-
-/* Device instantiation */
-
-static struct i2c_emul_api bb_emul_api = {
- .transfer = i2c_common_emul_transfer,
-};
-
-/**
- * @brief Set up a new BB retimer emulator
- *
- * This should be called for each BB retimer device that needs to be
- * emulated. It registers it with the I2C emulation controller.
- *
- * @param emul Emulation information
- * @param parent Device to emulate
- *
- * @return 0 indicating success (always)
- */
-static int bb_emul_init(const struct emul *emul,
- const struct device *parent)
-{
- const struct i2c_common_emul_cfg *cfg = emul->cfg;
- struct i2c_common_emul_data *data = cfg->data;
- int ret;
-
- data->emul.api = &bb_emul_api;
- data->emul.addr = cfg->addr;
- data->i2c = parent;
- data->cfg = cfg;
- i2c_common_emul_init(data);
-
- ret = i2c_emul_register(parent, emul->dev_label, &data->emul);
-
- bb_emul_reset(&data->emul);
-
- return ret;
-}
-
-#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), \
- .common = { \
- .start_write = NULL, \
- .write_byte = bb_emul_write_byte, \
- .finish_write = bb_emul_handle_write, \
- .start_read = bb_emul_handle_read, \
- .read_byte = bb_emul_read_byte, \
- .finish_read = NULL, \
- .access_reg = bb_emul_access_reg, \
- }, \
- }; \
- \
- static const struct i2c_common_emul_cfg bb_emul_cfg_##n = { \
- .i2c_label = DT_INST_BUS_LABEL(n), \
- .dev_label = DT_INST_LABEL(n), \
- .data = &bb_emul_data_##n.common, \
- .addr = DT_INST_REG_ADDR(n), \
- }; \
- EMUL_DEFINE(bb_emul_init, DT_DRV_INST(n), &bb_emul_cfg_##n, \
- &bb_emul_data_##n)
-
-DT_INST_FOREACH_STATUS_OKAY(BB_RETIMER_EMUL)
-
-#define BB_RETIMER_EMUL_CASE(n) \
- case DT_INST_DEP_ORD(n): return &bb_emul_data_##n.common.emul;
-
-/** Check description in emul_bb_emulator.h */
-struct i2c_emul *bb_emul_get(int ord)
-{
- switch (ord) {
- DT_INST_FOREACH_STATUS_OKAY(BB_RETIMER_EMUL_CASE)
-
- default:
- return NULL;
- }
-}
diff --git a/zephyr/emul/emul_bma255.c b/zephyr/emul/emul_bma255.c
deleted file mode 100644
index 77b1f5246c..0000000000
--- a/zephyr/emul/emul_bma255.c
+++ /dev/null
@@ -1,1042 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT zephyr_bma255
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <logging/log.h>
-LOG_MODULE_REGISTER(emul_bma255);
-
-#include <device.h>
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_bma255.h"
-
-#include "driver/accel_bma2x2.h"
-
-#define BMA_DATA_FROM_I2C_EMUL(_emul) \
- CONTAINER_OF(CONTAINER_OF(_emul, struct i2c_common_emul_data, emul), \
- struct bma_emul_data, common)
-
-/** Run-time data used by the emulator */
-struct bma_emul_data {
- /** Common I2C data */
- struct i2c_common_emul_data common;
-
- /** Value of data byte in ongoing write message */
- uint8_t write_byte;
-
- /** Current state of all emulated BMA255 registers */
- uint8_t reg[0x40];
- /** Current state of NVM where offset and GP0/1 can be saved */
- uint8_t nvm_x;
- uint8_t nvm_y;
- uint8_t nvm_z;
- uint8_t nvm_gp0;
- uint8_t nvm_gp1;
- /** Internal offset values used in calculations */
- int16_t off_x;
- int16_t off_y;
- int16_t off_z;
- /** Internal values of accelerometr */
- int16_t acc_x;
- int16_t acc_y;
- int16_t acc_z;
-
- /**
- * Return error when trying to start offset compensation when not ready
- * flag is set.
- */
- bool error_on_cal_trg_nrdy;
- /**
- * Return error when trying to start offset compensation with range
- * set to value different than 2G.
- */
- bool error_on_cal_trg_bad_range;
- /** Return error when trying to write to RO register */
- bool error_on_ro_write;
- /** Return error when trying to write 1 to reserved bit */
- bool error_on_rsvd_write;
- /** Return error when trying to access MSB before LSB */
- bool error_on_msb_first;
- /**
- * Flag set when LSB register is accessed and cleared when MSB is
- * accessed. Allows to track order of accessing acc registers
- */
- bool lsb_x_read;
- bool lsb_y_read;
- bool lsb_z_read;
-};
-
-/** Check description in emul_bma255.h */
-void bma_emul_set_reg(struct i2c_emul *emul, int reg, uint8_t val)
-{
- struct bma_emul_data *data;
-
- if (reg < 0 || reg > BMA2x2_FIFO_DATA_OUTPUT_ADDR) {
- return;
- }
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
- data->reg[reg] = val;
-}
-
-/** Check description in emul_bma255.h */
-uint8_t bma_emul_get_reg(struct i2c_emul *emul, int reg)
-{
- struct bma_emul_data *data;
-
- if (reg < 0 || reg > BMA2x2_FIFO_DATA_OUTPUT_ADDR) {
- return 0;
- }
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- return data->reg[reg];
-}
-
-/**
- * @brief Convert @p val to two's complement representation. It makes sure that
- * bit representation is correct even on platforms which represent
- * signed inteager in different format. Unsigned bit representation
- * allows to use well defined bitwise operations on returned value.
- *
- * @param val Inteager that is converted
- *
- * @return two's complement representation of @p val
- */
-static uint16_t bma_emul_val_to_twos_comp(int16_t val)
-{
- uint16_t twos_comp_val;
-
- /* Make sure that value is converted to twos compliment format */
- if (val < 0) {
- twos_comp_val = (uint16_t)(-val);
- twos_comp_val = ~twos_comp_val + 1;
- } else {
- twos_comp_val = (uint16_t)val;
- }
-
- return twos_comp_val;
-}
-
-/**
- * @brief Convert value from NVM format (8bit, 0x01 == 7.8mg) to internal
- * offset format (16bit, 0x01 == 0.97mg).
- *
- * @param nvm Value in NVM format (8bit, 0x01 == 7.8mg). This is binary
- * representation of two's complement signed number.
- *
- * @return offset Internal representation of @p nvm (16bit, 0x01 == 0.97mg)
- */
-static int16_t bma_emul_nvm_to_off(uint8_t nvm)
-{
- int16_t offset;
- int8_t sign;
-
- if (nvm & BIT(7)) {
- sign = -1;
- /* NVM value is in two's complement format */
- nvm = ~nvm + 1;
- } else {
- sign = 1;
- }
-
- offset = (int16_t)nvm;
- /* LSB in NVM is 7.8mg, while LSB in internal offset is 0.97mg */
- offset *= sign * 8;
-
- return offset;
-}
-
-/**
- * @brief Convert value from internal offset format (16bit, 0x01 == 0.97mg) to
- * NVM format (8bit, 0x01 == 7.8mg). Function makes sure that NVM value
- * is representation of two's complement signed number.
- *
- * @param val Value in internal offset format (16bit, 0x01 == 0.97mg).
- *
- * @return nvm NVM format representation of @p val (8bit, 0x01 == 7.8mg)
- */
-static uint8_t bma_emul_off_to_nvm(int16_t off)
-{
- uint16_t twos_comp_val;
- uint8_t nvm = 0;
-
- twos_comp_val = bma_emul_val_to_twos_comp(off);
-
- /*
- * LSB in internal representation has value 0.97mg, while in NVM
- * LSB is 7.8mg. Skip 0.97mg, 1.9mg and 3.9mg bits.
- */
- nvm |= (twos_comp_val >> 3) & 0x7f;
- /* Set sign bit */
- nvm |= (twos_comp_val & BIT(15)) ? BIT(7) : 0x00;
-
- return nvm;
-}
-
-/** Check description in emul_bma255.h */
-int16_t bma_emul_get_off(struct i2c_emul *emul, int axis)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- switch (axis) {
- case BMA_EMUL_AXIS_X:
- return data->off_x;
- case BMA_EMUL_AXIS_Y:
- return data->off_y;
- case BMA_EMUL_AXIS_Z:
- return data->off_z;
- }
-
- return 0;
-}
-
-/** Check description in emul_bma255.h */
-void bma_emul_set_off(struct i2c_emul *emul, int axis, int16_t val)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- switch (axis) {
- case BMA_EMUL_AXIS_X:
- data->off_x = val;
- data->reg[BMA2x2_OFFSET_X_AXIS_ADDR] = bma_emul_off_to_nvm(
- data->off_x);
- break;
- case BMA_EMUL_AXIS_Y:
- data->off_y = val;
- data->reg[BMA2x2_OFFSET_Y_AXIS_ADDR] = bma_emul_off_to_nvm(
- data->off_y);
- break;
- case BMA_EMUL_AXIS_Z:
- data->off_z = val;
- data->reg[BMA2x2_OFFSET_Z_AXIS_ADDR] = bma_emul_off_to_nvm(
- data->off_z);
- break;
- }
-}
-
-/** Check description in emul_bma255.h */
-int16_t bma_emul_get_acc(struct i2c_emul *emul, int axis)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- switch (axis) {
- case BMA_EMUL_AXIS_X:
- return data->acc_x;
- case BMA_EMUL_AXIS_Y:
- return data->acc_y;
- case BMA_EMUL_AXIS_Z:
- return data->acc_z;
- }
-
- return 0;
-}
-
-/** Check description in emul_bma255.h */
-void bma_emul_set_acc(struct i2c_emul *emul, int axis, int16_t val)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- switch (axis) {
- case BMA_EMUL_AXIS_X:
- data->acc_x = val;
- break;
- case BMA_EMUL_AXIS_Y:
- data->acc_y = val;
- break;
- case BMA_EMUL_AXIS_Z:
- data->acc_z = val;
- break;
- }
-}
-
-/** Check description in emul_bma255.h */
-void bma_emul_set_err_on_cal_nrdy(struct i2c_emul *emul, bool set)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
- data->error_on_cal_trg_nrdy = set;
-}
-
-/** Check description in emul_bma255.h */
-void bma_emul_set_err_on_cal_bad_range(struct i2c_emul *emul, bool set)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
- data->error_on_cal_trg_bad_range = set;
-}
-
-/** Check description in emul_bma255.h */
-void bma_emul_set_err_on_ro_write(struct i2c_emul *emul, bool set)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
- data->error_on_ro_write = set;
-}
-
-/** Check description in emul_bma255.h */
-void bma_emul_set_err_on_rsvd_write(struct i2c_emul *emul, bool set)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
- data->error_on_rsvd_write = set;
-}
-
-/** Check description in emul_bma255.h */
-void bma_emul_set_err_on_msb_first(struct i2c_emul *emul, bool set)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
- data->error_on_msb_first = set;
-}
-
-/** Mask reserved bits in each register of BMA255 */
-static const uint8_t bma_emul_rsvd_mask[] = {
- [BMA2x2_CHIP_ID_ADDR] = 0x00,
- [0x01] = 0xff, /* Reserved */
- [BMA2x2_X_AXIS_LSB_ADDR] = 0x0e,
- [BMA2x2_X_AXIS_MSB_ADDR] = 0x00,
- [BMA2x2_Y_AXIS_LSB_ADDR] = 0x0e,
- [BMA2x2_Y_AXIS_MSB_ADDR] = 0x00,
- [BMA2x2_Z_AXIS_LSB_ADDR] = 0x0e,
- [BMA2x2_Z_AXIS_MSB_ADDR] = 0x00,
- [BMA2x2_TEMP_ADDR] = 0x00,
- [BMA2x2_STAT1_ADDR] = 0x00,
- [BMA2x2_STAT2_ADDR] = 0x1f,
- [BMA2x2_STAT_TAP_SLOPE_ADDR] = 0x00,
- [BMA2x2_STAT_ORIENT_HIGH_ADDR] = 0x00,
- [0x0d] = 0xff, /* Reserved */
- [BMA2x2_STAT_FIFO_ADDR] = 0x00,
- [BMA2x2_RANGE_SELECT_ADDR] = 0xf0,
- [BMA2x2_BW_SELECT_ADDR] = 0xe0,
- [BMA2x2_MODE_CTRL_ADDR] = 0x01,
- [BMA2x2_LOW_NOISE_CTRL_ADDR] = 0x9f,
- [BMA2x2_DATA_CTRL_ADDR] = 0x3f,
- [BMA2x2_RST_ADDR] = 0x00,
- [0x15] = 0xff, /* Reserved */
- [BMA2x2_INTR_ENABLE1_ADDR] = 0x08,
- [BMA2x2_INTR_ENABLE2_ADDR] = 0x80,
- [BMA2x2_INTR_SLOW_NO_MOTION_ADDR] = 0xf0,
- [BMA2x2_INTR1_PAD_SELECT_ADDR] = 0x00,
- [BMA2x2_INTR_DATA_SELECT_ADDR] = 0x18,
- [BMA2x2_INTR2_PAD_SELECT_ADDR] = 0x00,
- [0x1c] = 0xff, /* Reserved */
- [0x1d] = 0xff, /* Reserved */
- [BMA2x2_INTR_SOURCE_ADDR] = 0xc0,
- [0x1f] = 0xff, /* Reserved */
- [BMA2x2_INTR_SET_ADDR] = 0xf0,
- [BMA2x2_INTR_CTRL_ADDR] = 0x70,
- [BMA2x2_LOW_DURN_ADDR] = 0x00,
- [BMA2x2_LOW_THRES_ADDR] = 0x00,
- [BMA2x2_LOW_HIGH_HYST_ADDR] = 0x38,
- [BMA2x2_HIGH_DURN_ADDR] = 0x00,
- [BMA2x2_HIGH_THRES_ADDR] = 0x00,
- [BMA2x2_SLOPE_DURN_ADDR] = 0x00,
- [BMA2x2_SLOPE_THRES_ADDR] = 0x00,
- [BMA2x2_SLOW_NO_MOTION_THRES_ADDR] = 0x00,
- [BMA2x2_TAP_PARAM_ADDR] = 0x38,
- [BMA2x2_TAP_THRES_ADDR] = 0x20,
- [BMA2x2_ORIENT_PARAM_ADDR] = 0x80,
- [BMA2x2_THETA_BLOCK_ADDR] = 0x80,
- [BMA2x2_THETA_FLAT_ADDR] = 0xc0,
- [BMA2x2_FLAT_HOLD_TIME_ADDR] = 0xc8,
- [BMA2x2_FIFO_WML_TRIG] = 0xc0,
- [0x31] = 0xff, /* Reserved */
- [BMA2x2_SELFTEST_ADDR] = 0xf8,
- [BMA2x2_EEPROM_CTRL_ADDR] = 0x00,
- [BMA2x2_SERIAL_CTRL_ADDR] = 0xf8,
- [0x35] = 0xff, /* Reserved */
- [BMA2x2_OFFSET_CTRL_ADDR] = 0x08,
- [BMA2x2_OFC_SETTING_ADDR] = 0x80,
- [BMA2x2_OFFSET_X_AXIS_ADDR] = 0x00,
- [BMA2x2_OFFSET_Y_AXIS_ADDR] = 0x00,
- [BMA2x2_OFFSET_Z_AXIS_ADDR] = 0x00,
- [BMA2x2_GP0_ADDR] = 0x00,
- [BMA2x2_GP1_ADDR] = 0x00,
- [0x3d] = 0xff, /* Reserved */
- [BMA2x2_FIFO_MODE_ADDR] = 0x3c,
- [BMA2x2_FIFO_DATA_OUTPUT_ADDR] = 0x00,
-};
-
-/**
- * @brief Reset register values and internal representation of offset and two
- * general purpose registers
- *
- * @param emul Pointer to BMA255 emulator
- */
-static void bma_emul_restore_nvm(struct i2c_emul *emul)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- /* Restore registers values */
- data->reg[BMA2x2_OFFSET_X_AXIS_ADDR] = data->nvm_x;
- data->reg[BMA2x2_OFFSET_Y_AXIS_ADDR] = data->nvm_y;
- data->reg[BMA2x2_OFFSET_Z_AXIS_ADDR] = data->nvm_z;
- data->reg[BMA2x2_GP0_ADDR] = data->nvm_gp0;
- data->reg[BMA2x2_GP1_ADDR] = data->nvm_gp1;
-
- /* Restore internal offset values */
- data->off_x = bma_emul_nvm_to_off(data->nvm_x);
- data->off_y = bma_emul_nvm_to_off(data->nvm_y);
- data->off_z = bma_emul_nvm_to_off(data->nvm_z);
-}
-
-/**
- * @brief Reset registers to default values and restore registers backed by NVM
- *
- * @param emul Pointer to BMA255 emulator
- */
-static void bma_emul_reset(struct i2c_emul *emul)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- data->reg[BMA2x2_CHIP_ID_ADDR] = 0xfa;
- data->reg[0x01] = 0x00; /* Reserved */
- data->reg[BMA2x2_X_AXIS_LSB_ADDR] = 0x00;
- data->reg[BMA2x2_X_AXIS_MSB_ADDR] = 0x00;
- data->reg[BMA2x2_Y_AXIS_LSB_ADDR] = 0x00;
- data->reg[BMA2x2_Y_AXIS_MSB_ADDR] = 0x00;
- data->reg[BMA2x2_Z_AXIS_LSB_ADDR] = 0x00;
- data->reg[BMA2x2_Z_AXIS_MSB_ADDR] = 0x00;
- data->reg[BMA2x2_TEMP_ADDR] = 0x00;
- data->reg[BMA2x2_STAT1_ADDR] = 0x00;
- data->reg[BMA2x2_STAT2_ADDR] = 0x00;
- data->reg[BMA2x2_STAT_TAP_SLOPE_ADDR] = 0x00;
- data->reg[BMA2x2_STAT_ORIENT_HIGH_ADDR] = 0x00;
- data->reg[0x0d] = 0xff; /* Reserved */
- data->reg[BMA2x2_STAT_FIFO_ADDR] = 0x00;
- data->reg[BMA2x2_RANGE_SELECT_ADDR] = 0x03;
- data->reg[BMA2x2_BW_SELECT_ADDR] = 0x0f;
- data->reg[BMA2x2_MODE_CTRL_ADDR] = 0x00;
- data->reg[BMA2x2_LOW_NOISE_CTRL_ADDR] = 0x00;
- data->reg[BMA2x2_DATA_CTRL_ADDR] = 0x00;
- data->reg[BMA2x2_RST_ADDR] = 0x00;
- data->reg[0x15] = 0xff; /* Reserved */
- data->reg[BMA2x2_INTR_ENABLE1_ADDR] = 0x00;
- data->reg[BMA2x2_INTR_ENABLE2_ADDR] = 0x00;
- data->reg[BMA2x2_INTR_SLOW_NO_MOTION_ADDR] = 0x00;
- data->reg[BMA2x2_INTR1_PAD_SELECT_ADDR] = 0x00;
- data->reg[BMA2x2_INTR_DATA_SELECT_ADDR] = 0x00;
- data->reg[BMA2x2_INTR2_PAD_SELECT_ADDR] = 0x00;
- data->reg[0x1c] = 0xff; /* Reserved */
- data->reg[0x1d] = 0xff; /* Reserved */
- data->reg[BMA2x2_INTR_SOURCE_ADDR] = 0x00;
- data->reg[0x1f] = 0xff; /* Reserved */
- data->reg[BMA2x2_INTR_SET_ADDR] = 0x05;
- data->reg[BMA2x2_INTR_CTRL_ADDR] = 0x00;
- data->reg[BMA2x2_LOW_DURN_ADDR] = 0x09;
- data->reg[BMA2x2_LOW_THRES_ADDR] = 0x30;
- data->reg[BMA2x2_LOW_HIGH_HYST_ADDR] = 0x81;
- data->reg[BMA2x2_HIGH_DURN_ADDR] = 0x0f;
- data->reg[BMA2x2_HIGH_THRES_ADDR] = 0xc0;
- data->reg[BMA2x2_SLOPE_DURN_ADDR] = 0x00;
- data->reg[BMA2x2_SLOPE_THRES_ADDR] = 0x14;
- data->reg[BMA2x2_SLOW_NO_MOTION_THRES_ADDR] = 0x14;
- data->reg[BMA2x2_TAP_PARAM_ADDR] = 0x04;
- data->reg[BMA2x2_TAP_THRES_ADDR] = 0x0a;
- data->reg[BMA2x2_ORIENT_PARAM_ADDR] = 0x18;
- data->reg[BMA2x2_THETA_BLOCK_ADDR] = 0x48;
- data->reg[BMA2x2_THETA_FLAT_ADDR] = 0x08;
- data->reg[BMA2x2_FLAT_HOLD_TIME_ADDR] = 0x11;
- data->reg[BMA2x2_FIFO_WML_TRIG] = 0x00;
- data->reg[0x31] = 0xff; /* Reserved */
- data->reg[BMA2x2_SELFTEST_ADDR] = 0x00;
- data->reg[BMA2x2_EEPROM_CTRL_ADDR] = 0xf0;
- data->reg[BMA2x2_SERIAL_CTRL_ADDR] = 0x00;
- data->reg[0x35] = 0x00; /* Reserved */
- data->reg[BMA2x2_OFFSET_CTRL_ADDR] = 0x10;
- data->reg[BMA2x2_OFC_SETTING_ADDR] = 0x00;
- data->reg[0x3d] = 0xff; /* Reserved */
- data->reg[BMA2x2_FIFO_MODE_ADDR] = 0x00;
- data->reg[BMA2x2_FIFO_DATA_OUTPUT_ADDR] = 0x00;
-
- /* Restore registers backed in NVM */
- bma_emul_restore_nvm(emul);
-}
-
-/**
- * @brief Convert range in format of RANGE_SELECT register to number of bits
- * that should be shifted right to obtain 12 bit reported accelerometer
- * value from internal 16 bit value
- *
- * @param range Value of RANGE_SELECT register
- *
- * @return shift Number of LSB that should be ignored from internal
- * accelerometer value
- */
-static int bma_emul_range_to_shift(uint8_t range)
-{
- switch (range & BMA2x2_RANGE_SELECT_MSK) {
- case BMA2x2_RANGE_2G:
- return 0;
- case BMA2x2_RANGE_4G:
- return 1;
- case BMA2x2_RANGE_8G:
- return 2;
- case BMA2x2_RANGE_16G:
- return 3;
- default:
- return -1;
- }
-}
-
-/**
- * @brief Handle write requests to NVM control register. Allows to load/store
- * NVM only when ready in current NVM control register is set. Load and
- * stores to NVM are backed in bma_emul_data structure
- *
- * @param emul Pointer to BMA255 emulator
- * @param val Value that is being written to NVM contorl register
- *
- * @return 0 on success
- */
-static int bma_emul_handle_nvm_write(struct i2c_emul *emul, uint8_t val)
-{
- struct bma_emul_data *data;
- uint8_t writes_rem;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- /* NVM not ready, ignore write/load requests */
- if (!(data->reg[BMA2x2_EEPROM_CTRL_ADDR] & BMA2x2_EEPROM_RDY)) {
- return 0;
- }
-
- /* Restore data from NVM */
- if (val & BMA2x2_EEPROM_LOAD) {
- bma_emul_restore_nvm(emul);
- }
-
- writes_rem = (data->reg[BMA2x2_EEPROM_CTRL_ADDR] &
- BMA2x2_EEPROM_REMAIN_MSK) >> BMA2x2_EEPROM_REMAIN_OFF;
- /* Trigger write is set, write is unlocked and writes remaining */
- if (val & BMA2x2_EEPROM_PROG &&
- data->reg[BMA2x2_EEPROM_CTRL_ADDR] & BMA2x2_EEPROM_PROG_EN &&
- writes_rem > 0) {
- data->nvm_x = data->reg[BMA2x2_OFFSET_X_AXIS_ADDR];
- data->nvm_y = data->reg[BMA2x2_OFFSET_Y_AXIS_ADDR];
- data->nvm_z = data->reg[BMA2x2_OFFSET_Z_AXIS_ADDR];
- data->nvm_gp0 = data->reg[BMA2x2_GP0_ADDR];
- data->nvm_gp1 = data->reg[BMA2x2_GP1_ADDR];
- /* Decrement number of remaining writes and save it in reg */
- writes_rem--;
- data->reg[BMA2x2_EEPROM_CTRL_ADDR] &=
- ~BMA2x2_EEPROM_REMAIN_MSK;
- data->reg[BMA2x2_EEPROM_CTRL_ADDR] |=
- writes_rem << BMA2x2_EEPROM_REMAIN_OFF;
- }
-
- return 0;
-}
-
-/**
- * @brief Clear all interrupt registers
- *
- * @param emul Pointer to BMA255 emulator
- */
-static void bma_emul_clear_int(struct i2c_emul *emul)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- data->reg[BMA2x2_STAT1_ADDR] = 0x00;
- data->reg[BMA2x2_STAT2_ADDR] = 0x00;
- data->reg[BMA2x2_STAT_TAP_SLOPE_ADDR] = 0x00;
- data->reg[BMA2x2_STAT_ORIENT_HIGH_ADDR] = 0x00;
-}
-
-/**
- * @brief Get target value from offset compensation setting register for given
- * @p axis
- *
- * @param emul Pointer to BMA255 emulator
- * @param axis Axis to access: 0 - X, 1 - Y, 2 - Z
- *
- * @return target Value to which offset compensation should be calculated
- */
-static int16_t bma_emul_get_target(struct i2c_emul *emul, int axis)
-{
- struct bma_emul_data *data;
- uint8_t target;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- target = data->reg[BMA2x2_OFC_SETTING_ADDR] >>
- BMA2x2_OFC_TARGET_AXIS(axis);
- switch (target) {
- case BMA2x2_OFC_TARGET_0G:
- return 0;
- case BMA2x2_OFC_TARGET_PLUS_1G:
- return BMA_EMUL_1G;
- case BMA2x2_OFC_TARGET_MINUS_1G:
- return -((int)BMA_EMUL_1G);
- }
-
- return 0;
-}
-
-/**
- * @brief Handle writes to offset compensation control register. It allows to
- * reset offset registers. It check if offset compenstation is ready
- * and if range is set to 2G (required for fast compensation according
- * to BMA255 documentation). If fast compensation is successfully
- * triggered, internal offset value is set to
- * (target - internal accelerometer value).
- *
- * @param emul Pointer to BMA255 emulator
- * @param val Value being written to offset compensation control register
- *
- * @return 0 on success
- * @return -EIO when trying to start fast compensation in wrong emulator state
- */
-static int bma_emul_handle_off_comp(struct i2c_emul *emul, uint8_t val)
-{
- struct bma_emul_data *data;
- uint8_t trigger;
- int16_t target;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- if (val & BMA2x2_OFFSET_RESET) {
- data->off_x = 0;
- data->off_y = 0;
- data->off_z = 0;
- data->reg[BMA2x2_OFFSET_X_AXIS_ADDR] = 0;
- data->reg[BMA2x2_OFFSET_Y_AXIS_ADDR] = 0;
- data->reg[BMA2x2_OFFSET_Z_AXIS_ADDR] = 0;
- }
-
-
- trigger = (val & BMA2x2_OFFSET_TRIGGER_MASK) >>
- BMA2x2_OFFSET_TRIGGER_OFF;
-
- if (!(data->reg[BMA2x2_OFFSET_CTRL_ADDR] & BMA2x2_OFFSET_CAL_READY)) {
- if (data->error_on_cal_trg_nrdy && trigger) {
- LOG_ERR("Trying to start offset comp when not ready");
- return -EIO;
- }
-
- return 0;
- }
-
- if (bma_emul_range_to_shift(data->reg[BMA2x2_RANGE_SELECT_ADDR]) != 0 &&
- trigger && data->error_on_cal_trg_bad_range) {
- LOG_ERR("Trying to start offset comp with range other than 2G");
- return -EIO;
- }
-
- switch (trigger) {
- case 1:
- target = bma_emul_get_target(emul, BMA_EMUL_AXIS_X);
- bma_emul_set_off(emul, BMA_EMUL_AXIS_X, target - data->acc_x);
- break;
- case 2:
- target = bma_emul_get_target(emul, BMA_EMUL_AXIS_Y);
- bma_emul_set_off(emul, BMA_EMUL_AXIS_Y, target - data->acc_y);
- break;
- case 3:
- target = bma_emul_get_target(emul, BMA_EMUL_AXIS_Z);
- bma_emul_set_off(emul, BMA_EMUL_AXIS_Z, target - data->acc_z);
- break;
- }
-
- return 0;
-}
-
-/**
- * @brief Handle I2C write message. It is checked if accessed register isn't RO
- * and reserved bits are set to 0. Write set value of reg field of bma
- * emulator data ignoring reserved bits and write only bits. Some
- * commands are handled specialy.
- *
- * @param emul Pointer to BMA255 emulator
- * @param reg Register which is written
- * @param bytes Number of bytes in I2C write message
- *
- * @return 0 on success
- * @return -EIO on error
- */
-static int bma_emul_handle_write(struct i2c_emul *emul, int reg, int bytes)
-{
- struct bma_emul_data *data;
- uint8_t val;
- int ret;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- val = data->write_byte;
-
- if (bytes > 2) {
- LOG_ERR("Too long write command");
- return -EIO;
- }
-
- /* This write only selected register for I2C read message */
- if (bytes < 2) {
- return 0;
- }
-
- if (reg <= BMA2x2_STAT_FIFO_ADDR ||
- reg >= BMA2x2_FIFO_DATA_OUTPUT_ADDR) {
- if (data->error_on_ro_write) {
- LOG_ERR("Writing to reg 0x%x which is RO", reg);
- return -EIO;
- }
-
- return 0;
- }
-
- if (data->error_on_rsvd_write && bma_emul_rsvd_mask[reg] & val) {
- LOG_ERR("Writing 0x%x to reg 0x%x with rsvd bits mask 0x%x",
- val, reg, bma_emul_rsvd_mask[reg]);
- return -EIO;
- }
-
-
- switch (reg) {
- case BMA2x2_RST_ADDR:
- if (val == BMA2x2_CMD_SOFT_RESET) {
- bma_emul_reset(emul);
- }
- return 0;
- case BMA2x2_INTR_CTRL_ADDR:
- if (val & BMA2x2_INTR_CTRL_RST_INT) {
- bma_emul_clear_int(emul);
- }
- /* Don't set write only bit in register */
- val &= ~BMA2x2_INTR_CTRL_RST_INT;
- break;
- case BMA2x2_EEPROM_CTRL_ADDR:
- bma_emul_handle_nvm_write(emul, val);
- /* Only programing enable bit is RW */
- val &= BMA2x2_EEPROM_PROG_EN;
- val |= data->reg[reg] & ~BMA2x2_EEPROM_PROG_EN;
- break;
- case BMA2x2_OFFSET_CTRL_ADDR:
- ret = bma_emul_handle_off_comp(emul, val);
- if (ret) {
- return -EIO;
- }
- /* Only slow compensation bits are RW */
- val &= BMA2x2_OFFSET_CAL_SLOW_X | BMA2x2_OFFSET_CAL_SLOW_Y |
- BMA2x2_OFFSET_CAL_SLOW_Z;
- val |= data->reg[reg] & ~(BMA2x2_OFFSET_CAL_SLOW_X |
- BMA2x2_OFFSET_CAL_SLOW_Y |
- BMA2x2_OFFSET_CAL_SLOW_Z);
- break;
- /* Change internal offset to value set in I2C message */
- case BMA2x2_OFFSET_X_AXIS_ADDR:
- data->off_x = bma_emul_nvm_to_off(val);
- break;
- case BMA2x2_OFFSET_Y_AXIS_ADDR:
- data->off_y = bma_emul_nvm_to_off(val);
- break;
- case BMA2x2_OFFSET_Z_AXIS_ADDR:
- data->off_z = bma_emul_nvm_to_off(val);
- break;
- case BMA2x2_RANGE_SELECT_ADDR:
- ret = bma_emul_range_to_shift(val);
- if (ret < 0) {
- LOG_ERR("Unknown range select value 0x%x", val);
- return -EIO;
- }
- break;
- }
-
- /* Ignore all reserved bits */
- val &= ~bma_emul_rsvd_mask[reg];
- val |= data->reg[reg] & bma_emul_rsvd_mask[reg];
-
- data->reg[reg] = val;
-
- return 0;
-}
-
-/**
- * @brief Get set accelerometer value for given register using internal axis
- * state @p val. In case of accessing MSB with enabled shadowing,
- * check if LSB was accessed first.
- *
- * @param emul Pointer to BMA255 emulator
- * @param lsb_reg LSB register address (BMA2x2_X_AXIS_LSB_ADDR,
- * BMA2x2_Y_AXIS_LSB_ADDR, BMA2x2_Z_AXIS_LSB_ADDR)
- * @param lsb_read Pointer to variable which represent if last access to this
- * accelerometer value was through LSB register
- * @param lsb True if now accessing LSB, Flase if now accessing MSB
- * @param val Internal value of accessed accelerometer axis
- *
- * @return 0 on success
- * @return -EIO when accessing MSB before LSB with enabled shadowing
- */
-static int bma_emul_get_acc_val(struct i2c_emul *emul, int lsb_reg,
- bool *lsb_read, bool lsb, int16_t val)
-{
- struct bma_emul_data *data;
- uint16_t twos_comp_val;
- uint8_t new_data;
- int msb_reg;
- int shift;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- if (lsb) {
- *lsb_read = 1;
- } else if (!(data->reg[BMA2x2_DATA_CTRL_ADDR] &
- BMA2x2_DATA_SHADOW_DIS)) {
- /*
- * If shadowing is enabled, error on first accessing MSB and
- * LSB wasn't accessed before, then return error.
- */
- if (data->error_on_msb_first && !(*lsb_read)) {
- return -EIO;
- }
- *lsb_read = 0;
- /* If shadowing is enabled, LSB read should set correct value */
- return 0;
- }
-
- twos_comp_val = bma_emul_val_to_twos_comp(val);
- msb_reg = lsb_reg + 1;
- shift = bma_emul_range_to_shift(data->reg[BMA2x2_RANGE_SELECT_ADDR]);
-
- /* Save new data bit from register */
- new_data = data->reg[lsb_reg] & BMA2x2_AXIS_LSB_NEW_DATA;
- /* Shift 16 bit value to 12 bit set in range register */
- twos_comp_val >>= shift;
- /* Set [3:0] bits in first register */
- data->reg[lsb_reg] = ((twos_comp_val << 4) & 0xf0) | new_data;
- /* Set [11:4] bits in second register */
- data->reg[msb_reg] = (twos_comp_val >> 4) & 0xff;
-
- return 0;
-}
-
-/** Check description in emul_bma255.h */
-int bma_emul_access_reg(struct i2c_emul *emul, int reg, int bytes, bool read)
-{
- /*
- * Exclude first byte (select register) from total number of bytes
- * in I2C write message
- */
- if (!read) {
- bytes--;
- }
-
- if (reg <= BMA2x2_FIFO_DATA_OUTPUT_ADDR &&
- reg + bytes >= BMA2x2_FIFO_DATA_OUTPUT_ADDR) {
- return BMA2x2_FIFO_DATA_OUTPUT_ADDR;
- }
-
- return reg + bytes;
-}
-
-/**
- * @brief Handle I2C read message. Response is obtained from reg field of bma
- * emul data. When accessing accelerometer value, register data is first
- * computed using internal emulator state.
- *
- * @param emul Pointer to BMA255 emulator
- * @param reg Register address to read
- * @param val Pointer where resultat should be stored
- * @param bytes Number of bytes in I2C read message
- *
- * @return 0 on success
- * @return -EIO on error
- */
-static int bma_emul_handle_read(struct i2c_emul *emul, int reg, uint8_t *val,
- int bytes)
-{
- struct bma_emul_data *data;
- int ret;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- reg = bma_emul_access_reg(emul, reg, bytes, true /* = read */);
-
- switch (reg) {
- case BMA2x2_X_AXIS_LSB_ADDR:
- /* Shouldn't fail for LSB */
- ret = bma_emul_get_acc_val(emul, reg, &data->lsb_x_read, true,
- data->acc_x + data->off_x);
- break;
- case BMA2x2_X_AXIS_MSB_ADDR:
- ret = bma_emul_get_acc_val(emul, reg - 1, &data->lsb_x_read,
- false, data->acc_x + data->off_x);
- if (ret) {
- LOG_ERR("MSB X readed before LSB X");
- return -EIO;
- }
- break;
- case BMA2x2_Y_AXIS_LSB_ADDR:
- /* Shouldn't fail for LSB */
- ret = bma_emul_get_acc_val(emul, reg, &data->lsb_y_read, true,
- data->acc_y + data->off_y);
- break;
- case BMA2x2_Y_AXIS_MSB_ADDR:
- ret = bma_emul_get_acc_val(emul, reg - 1, &data->lsb_y_read,
- false, data->acc_y + data->off_y);
- if (ret) {
- LOG_ERR("MSB Y readed before LSB Y");
- return -EIO;
- }
- break;
- case BMA2x2_Z_AXIS_LSB_ADDR:
- /* Shouldn't fail for LSB */
- ret = bma_emul_get_acc_val(emul, reg, &data->lsb_z_read, true,
- data->acc_z + data->off_z);
- break;
- case BMA2x2_Z_AXIS_MSB_ADDR:
- ret = bma_emul_get_acc_val(emul, reg - 1, &data->lsb_z_read,
- false, data->acc_z + data->off_z);
- if (ret) {
- LOG_ERR("MSB Z readed before LSB Z");
- return -EIO;
- }
- break;
- }
-
- *val = data->reg[reg];
-
- return 0;
-}
-
-/**
- * @brief Handle I2C write message. Saves data that will be stored in register.
- *
- * @param emul Pointer to BMA emulator
- * @param reg Register address that is accessed
- * @param val Data to write to the register
- * @param bytes Number of bytes already handled in this read message
- *
- * @return 0 on success
- * @return -EIO on error
- */
-static int bma_emul_write_byte(struct i2c_emul *emul, int reg, uint8_t val,
- int bytes)
-{
- struct bma_emul_data *data;
-
- data = BMA_DATA_FROM_I2C_EMUL(emul);
-
- data->write_byte = val;
-
- return 0;
-}
-
-/* Device instantiation */
-
-static struct i2c_emul_api bma_emul_api = {
- .transfer = i2c_common_emul_transfer,
-};
-
-/**
- * @brief Set up a new BMA255 emulator
- *
- * This should be called for each BMA255 device that needs to be
- * emulated. It registers it with the I2C emulation controller.
- *
- * @param emul Emulation information
- * @param parent Device to emulate
- *
- * @return 0 indicating success (always)
- */
-static int bma_emul_init(const struct emul *emul,
- const struct device *parent)
-{
- const struct i2c_common_emul_cfg *cfg = emul->cfg;
- struct i2c_common_emul_data *data = cfg->data;
- int ret;
-
- data->emul.api = &bma_emul_api;
- data->emul.addr = cfg->addr;
- data->i2c = parent;
- data->cfg = cfg;
- i2c_common_emul_init(data);
-
- ret = i2c_emul_register(parent, emul->dev_label, &data->emul);
-
- bma_emul_reset(&data->emul);
-
- return ret;
-}
-
-#define BMA255_EMUL(n) \
- static struct bma_emul_data bma_emul_data_##n = { \
- .nvm_x = DT_INST_PROP(n, nvm_off_x), \
- .nvm_y = DT_INST_PROP(n, nvm_off_y), \
- .nvm_z = DT_INST_PROP(n, nvm_off_z), \
- .nvm_gp0 = DT_INST_PROP(n, nvm_gp0), \
- .nvm_gp1 = DT_INST_PROP(n, nvm_gp1), \
- .acc_x = DT_INST_PROP(n, nvm_acc_x), \
- .acc_y = DT_INST_PROP(n, nvm_acc_y), \
- .acc_z = DT_INST_PROP(n, nvm_acc_z), \
- .error_on_cal_trg_nrdy = DT_INST_PROP(n, \
- error_on_compensation_not_ready), \
- .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), \
- .error_on_msb_first = DT_INST_PROP(n, \
- error_on_msb_first_access), \
- .lsb_x_read = 0, \
- .lsb_y_read = 0, \
- .lsb_z_read = 0, \
- .common = { \
- .start_write = NULL, \
- .write_byte = bma_emul_write_byte, \
- .finish_write = bma_emul_handle_write, \
- .start_read = NULL, \
- .read_byte = bma_emul_handle_read, \
- .finish_read = NULL, \
- .access_reg = bma_emul_access_reg, \
- }, \
- }; \
- \
- static const struct i2c_common_emul_cfg bma_emul_cfg_##n = { \
- .i2c_label = DT_INST_BUS_LABEL(n), \
- .dev_label = DT_INST_LABEL(n), \
- .data = &bma_emul_data_##n.common, \
- .addr = DT_INST_REG_ADDR(n), \
- }; \
- EMUL_DEFINE(bma_emul_init, DT_DRV_INST(n), &bma_emul_cfg_##n, \
- &bma_emul_data_##n)
-
-DT_INST_FOREACH_STATUS_OKAY(BMA255_EMUL)
-
-#define BMA255_EMUL_CASE(n) \
- case DT_INST_DEP_ORD(n): return &bma_emul_data_##n.common.emul;
-
-/** Check description in emul_bma255.h */
-struct i2c_emul *bma_emul_get(int ord)
-{
- switch (ord) {
- DT_INST_FOREACH_STATUS_OKAY(BMA255_EMUL_CASE)
-
- default:
- return NULL;
- }
-}
diff --git a/zephyr/emul/emul_bmi.c b/zephyr/emul/emul_bmi.c
deleted file mode 100644
index 7923fe0eb5..0000000000
--- a/zephyr/emul/emul_bmi.c
+++ /dev/null
@@ -1,1116 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT zephyr_bmi
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <logging/log.h>
-LOG_MODULE_REGISTER(emul_bmi);
-
-#include <device.h>
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_bmi.h"
-
-#include "driver/accelgyro_bmi160.h"
-#include "driver/accelgyro_bmi260.h"
-#include "driver/accelgyro_bmi_common.h"
-
-#define BMI_DATA_FROM_I2C_EMUL(_emul) \
- CONTAINER_OF(CONTAINER_OF(_emul, struct i2c_common_emul_data, emul), \
- struct bmi_emul_data, common)
-
-/** Run-time data used by the emulator */
-struct bmi_emul_data {
- /** Common I2C data */
- struct i2c_common_emul_data common;
-
- /** Current state of all emulated BMI registers */
- uint8_t reg[BMI_EMUL_MAX_REG];
- /** Internal offset values used in calculations */
- int16_t off_acc_x;
- int16_t off_acc_y;
- int16_t off_acc_z;
- int16_t off_gyr_x;
- int16_t off_gyr_y;
- int16_t off_gyr_z;
- /** Internal values of sensors */
- int32_t acc_x;
- int32_t acc_y;
- int32_t acc_z;
- int32_t gyr_x;
- int32_t gyr_y;
- int32_t gyr_z;
- /** Current state of NVM where offset and configuration can be saved */
- uint8_t nvm[BMI_EMUL_MAX_NVM_REGS];
-
- /** Return error when trying to write to RO register */
- bool error_on_ro_write;
- /** Return error when trying to write 1 to reserved bit */
- bool error_on_rsvd_write;
- /**
- * If effect of command is vissable after simulated time from issuing
- * command
- */
- bool simulate_command_exec_time;
- /** Return error when trying to read WO register */
- bool error_on_wo_read;
-
- /** Value of data byte in ongoing write message */
- uint8_t write_byte;
-
- /** List of FIFO frames */
- struct bmi_emul_frame *fifo_frame;
- /** First FIFO frame in byte format */
- uint8_t fifo[21];
- /** Number of FIFO frames that were skipped */
- uint8_t fifo_skip;
- /** Currently accessed byte of first frame */
- int fifo_frame_byte;
- /** Length of first frame */
- int fifo_frame_len;
-
- /** Last time when emulator was resetted in sensor time units */
- int64_t zero_time;
- /** Time when current command should end */
- uint32_t cmd_end_time;
-
- /** Emulated model of BMI */
- int type;
- /** Pointer to data specific for emulated model of BMI */
- const struct bmi_emul_type_data *type_data;
-};
-
-/** Check description in emul_bmi.h */
-void bmi_emul_set_reg(struct i2c_emul *emul, int reg, uint8_t val)
-{
- struct bmi_emul_data *data;
-
- if (reg < 0 || reg > BMI_EMUL_MAX_REG) {
- return;
- }
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
- data->reg[reg] = val;
-}
-
-/** Check description in emul_bmi.h */
-uint8_t bmi_emul_get_reg(struct i2c_emul *emul, int reg)
-{
- struct bmi_emul_data *data;
-
- if (reg < 0 || reg > BMI_EMUL_MAX_REG) {
- return 0;
- }
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- return data->reg[reg];
-}
-
-/**
- * @brief Convert @p val to two's complement representation. It makes sure that
- * bit representation is correct even on platforms which represent
- * signed inteager in different format. Unsigned bit representation
- * allows to use well defined bitwise operations on returned value.
- *
- * @param val Inteager that is converted
- *
- * @return two's complement representation of @p val
- */
-static uint32_t bmi_emul_val_to_twos_comp(int32_t val)
-{
- uint32_t twos_comp_val;
-
- /* Make sure that value is converted to twos compliment format */
- if (val < 0) {
- twos_comp_val = (uint32_t)(-val);
- twos_comp_val = ~twos_comp_val + 1;
- } else {
- twos_comp_val = (uint32_t)val;
- }
-
- return twos_comp_val;
-}
-
-/**
- * @brief Convert accelerometer value from NVM format (8bit, 0x01 == 3.9mg)
- * to internal offset format (16bit, 0x01 == 0.061mg).
- *
- * @param nvm Value in NVM format (8bit, 0x01 == 3.9mg). This is binary
- * representation of two's complement signed number.
- *
- * @return offset Internal representation of @p nvm (16bit, 0x01 == 0.061mg)
- */
-static int16_t bmi_emul_acc_nvm_to_off(uint8_t nvm)
-{
- int16_t offset;
- int8_t sign;
-
- if (nvm & BIT(7)) {
- sign = -1;
- /* NVM value is in two's complement format */
- nvm = ~nvm + 1;
- } else {
- sign = 1;
- }
-
- offset = (int16_t)nvm;
- /* LSB in NVM is 3.9mg, while LSB in internal offset is 0.061mg */
- offset *= sign * 64;
-
- return offset;
-}
-
-/**
- * @brief Convert gyroscope value from NVM format (10bit, 0x01 == 0.061 °/s)
- * to internal offset format (16bit, 0x01 == 0.0038 °/s)
- *
- * @param nvm Value in NVM format (10bit, 0x01 == 0.061 °/s). This is binary
- * representation of two's complement signed number.
- *
- * @return offset Internal representation of @p nvm (16bit, 0x01 == 0.0038 °/s)
- */
-static int16_t bmi_emul_gyr_nvm_to_off(uint16_t nvm)
-{
- int16_t offset;
- int8_t sign;
-
- if (nvm & BIT(9)) {
- sign = -1;
- /* NVM value is in two's complement format */
- nvm = ~nvm + 1;
- } else {
- sign = 1;
- }
-
- /* Mask 10 bits which holds value */
- nvm &= 0x3ff;
-
- offset = (int16_t)nvm;
- /* LSB in NVM is 0.061°/s, while LSB in internal offset is 0.0038°/s */
- offset *= sign * 16;
-
- return offset;
-}
-
-/**
- * @brief Convert accelerometer value from internal offset format
- * (16bit, 0x01 == 0.061mg) to NVM format (8bit, 0x01 == 7.8mg).
- * Function makes sure that NVM value is representation of two's
- * complement signed number.
- *
- * @param val Value in internal offset format (16bit, 0x01 == 0.061mg).
- *
- * @return nvm NVM format representation of @p val (8bit, 0x01 == 3.9mg)
- */
-static uint8_t bmi_emul_acc_off_to_nvm(int16_t off)
-{
- uint32_t twos_comp_val;
- uint8_t nvm = 0;
-
- twos_comp_val = bmi_emul_val_to_twos_comp(off);
-
- /*
- * LSB in internal representation has value 0.061mg, while in NVM
- * LSB is 3.9mg. Skip 0.06mg, 0.12mg, 0.24mg, 0.48mg, 0.97mg and
- * 1.9mg bits.
- */
- nvm |= (twos_comp_val >> 6) & 0x7f;
- /* Set sign bit */
- nvm |= (twos_comp_val & BIT(31)) ? BIT(7) : 0x00;
-
- return nvm;
-}
-
-/**
- * @brief Convert gyroscope value from internal offset format
- * (16bit, 0x01 == 0.0038°/s) to NVM format (10bit, 0x01 == 0.061°/s).
- * Function makes sure that NVM value is representation of two's
- * complement signed number.
- *
- * @param val Value in internal offset format (16bit, 0x01 == 0.0038°/s).
- *
- * @return nvm NVM format representation of @p val (10bit, 0x01 == 0.061°/s)
- */
-static uint16_t bmi_emul_gyr_off_to_nvm(int16_t off)
-{
- uint32_t twos_comp_val;
- uint16_t nvm = 0;
-
- twos_comp_val = bmi_emul_val_to_twos_comp(off);
-
- /*
- * LSB in internal representation has value 0.0038°/s, while in NVM
- * LSB is 0.061°/s. Skip 0.0038°/s, 0.0076°/s, 0.015°/s, and
- * 0.03°/s bits.
- */
- nvm |= (twos_comp_val >> 4) & 0x1ff;
- /* Set sign bit */
- nvm |= (twos_comp_val & BIT(31)) ? BIT(9) : 0x00;
-
- return nvm;
-}
-
-/** Check description in emul_bmi.h */
-int16_t bmi_emul_get_off(struct i2c_emul *emul, enum bmi_emul_axis axis)
-{
- struct bmi_emul_data *data;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- switch (axis) {
- case BMI_EMUL_ACC_X:
- return data->off_acc_x;
- case BMI_EMUL_ACC_Y:
- return data->off_acc_y;
- case BMI_EMUL_ACC_Z:
- return data->off_acc_z;
- case BMI_EMUL_GYR_X:
- return data->off_gyr_x;
- case BMI_EMUL_GYR_Y:
- return data->off_gyr_y;
- case BMI_EMUL_GYR_Z:
- return data->off_gyr_z;
- }
-
- return 0;
-}
-
-/** Check description in emul_bmi.h */
-void bmi_emul_set_off(struct i2c_emul *emul, enum bmi_emul_axis axis,
- int16_t val)
-{
- struct bmi_emul_data *data;
- uint16_t gyr_off;
- uint8_t gyr98_shift;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- switch (axis) {
- case BMI_EMUL_ACC_X:
- data->off_acc_x = val;
- data->reg[data->type_data->acc_off_reg] =
- bmi_emul_acc_off_to_nvm(data->off_acc_x);
- break;
- case BMI_EMUL_ACC_Y:
- data->off_acc_y = val;
- data->reg[data->type_data->acc_off_reg + 1] =
- bmi_emul_acc_off_to_nvm(data->off_acc_y);
- break;
- case BMI_EMUL_ACC_Z:
- data->off_acc_z = val;
- data->reg[data->type_data->acc_off_reg + 2] =
- bmi_emul_acc_off_to_nvm(data->off_acc_z);
- break;
- case BMI_EMUL_GYR_X:
- data->off_gyr_x = val;
- gyr_off = bmi_emul_gyr_off_to_nvm(data->off_gyr_x);
- data->reg[data->type_data->gyr_off_reg] = gyr_off & 0xff;
- gyr98_shift = 0;
- data->reg[data->type_data->gyr98_off_reg] &=
- ~(0x3 << gyr98_shift);
- data->reg[data->type_data->gyr98_off_reg] |=
- (gyr_off & 0x300) >> (8 - gyr98_shift);
- break;
- case BMI_EMUL_GYR_Y:
- data->off_gyr_y = val;
- gyr_off = bmi_emul_gyr_off_to_nvm(data->off_gyr_y);
- data->reg[data->type_data->gyr_off_reg + 1] = gyr_off & 0xff;
- gyr98_shift = 2;
- data->reg[data->type_data->gyr98_off_reg] &=
- ~(0x3 << gyr98_shift);
- data->reg[data->type_data->gyr98_off_reg] |=
- (gyr_off & 0x300) >> (8 - gyr98_shift);
- break;
- case BMI_EMUL_GYR_Z:
- data->off_gyr_z = val;
- gyr_off = bmi_emul_gyr_off_to_nvm(data->off_gyr_z);
- data->reg[data->type_data->gyr_off_reg + 2] = gyr_off & 0xff;
- gyr98_shift = 4;
- data->reg[data->type_data->gyr98_off_reg] &=
- ~(0x3 << gyr98_shift);
- data->reg[data->type_data->gyr98_off_reg] |=
- (gyr_off & 0x300) >> (8 - gyr98_shift);
- break;
- }
-}
-
-/** Check description in emul_bmi.h */
-int32_t bmi_emul_get_value(struct i2c_emul *emul, enum bmi_emul_axis axis)
-{
- struct bmi_emul_data *data;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- switch (axis) {
- case BMI_EMUL_ACC_X:
- return data->acc_x;
- case BMI_EMUL_ACC_Y:
- return data->acc_y;
- case BMI_EMUL_ACC_Z:
- return data->acc_z;
- case BMI_EMUL_GYR_X:
- return data->gyr_x;
- case BMI_EMUL_GYR_Y:
- return data->gyr_y;
- case BMI_EMUL_GYR_Z:
- return data->gyr_z;
- }
-
- return 0;
-}
-
-/** Check description in emul_bmi.h */
-void bmi_emul_set_value(struct i2c_emul *emul, enum bmi_emul_axis axis,
- int32_t val)
-{
- struct bmi_emul_data *data;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- switch (axis) {
- case BMI_EMUL_ACC_X:
- data->acc_x = val;
- break;
- case BMI_EMUL_ACC_Y:
- data->acc_y = val;
- break;
- case BMI_EMUL_ACC_Z:
- data->acc_z = val;
- break;
- case BMI_EMUL_GYR_X:
- data->gyr_x = val;
- break;
- case BMI_EMUL_GYR_Y:
- data->gyr_y = val;
- break;
- case BMI_EMUL_GYR_Z:
- data->gyr_z = val;
- break;
- }
-}
-
-/** Check description in emul_bmi.h */
-void bmi_emul_set_err_on_ro_write(struct i2c_emul *emul, bool set)
-{
- struct bmi_emul_data *data;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
- data->error_on_ro_write = set;
-}
-
-/** Check description in emul_bmi.h */
-void bmi_emul_set_err_on_rsvd_write(struct i2c_emul *emul, bool set)
-{
- struct bmi_emul_data *data;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
- data->error_on_rsvd_write = set;
-}
-
-/** Check description in emul_bmi.h */
-void bmi_emul_set_err_on_wo_read(struct i2c_emul *emul, bool set)
-{
- struct bmi_emul_data *data;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
- data->error_on_wo_read = set;
-}
-
-/** Check description in emul_bmi.h */
-void bmi_emul_simulate_cmd_exec_time(struct i2c_emul *emul, bool set)
-{
- struct bmi_emul_data *data;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
- data->simulate_command_exec_time = set;
-}
-
-/** Check description in emul_bmi.h */
-void bmi_emul_set_skipped_frames(struct i2c_emul *emul, uint8_t skip)
-{
- struct bmi_emul_data *data;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- data->fifo_skip = skip;
-}
-
-/**
- * @brief Convert current time to sensor time (39 us units)
- *
- * @return time in 39 us units
- */
-static int64_t bmi_emul_get_sensortime(void)
-{
- return k_uptime_ticks() * 1000000 / 39 / CONFIG_SYS_CLOCK_TICKS_PER_SEC;
-}
-
-/**
- * @brief Set registers at address @p reg with sensor time that elapsed since
- * last reset of emulator
- *
- * @param emul Pointer to BMI emulator
- * @param reg Pointer to 3 byte array, where current sensor time should be
- * stored
- */
-static void bmi_emul_set_sensortime_reg(struct i2c_emul *emul, uint8_t *reg)
-{
- struct bmi_emul_data *data;
- uint32_t twos_comp_val;
- int64_t time;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- time = bmi_emul_get_sensortime();
-
- twos_comp_val = bmi_emul_val_to_twos_comp(time - data->zero_time);
-
- *reg = twos_comp_val & 0xff;
- *(reg + 1) = (twos_comp_val >> 8) & 0xff;
- *(reg + 2) = (twos_comp_val >> 16) & 0xff;
-}
-
-/**
- * @brief Convert given sensor axis @p val from internal units to register
- * units. It shifts value by @p shift bits to the right to account
- * range set in emulator's registers. Result is saved at address @p reg
- *
- * @param emul Pointer to BMI emulator
- * @param val Accelerometer or gyroscope value in internal units
- * @param reg Pointer to 2 byte array, where sensor value should be stored
- * @param shift How many bits should be shift to the right
- */
-static void bmi_emul_set_data_reg(struct i2c_emul *emul, int32_t val,
- uint8_t *reg, int shift)
-{
- struct bmi_emul_data *data;
- uint32_t twos_comp_val;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- twos_comp_val = bmi_emul_val_to_twos_comp(val);
-
- /* Shift unused bits because of selected range */
- twos_comp_val >>= shift;
-
- *reg = twos_comp_val & 0xff;
- *(reg + 1) = (twos_comp_val >> 8) & 0xff;
-}
-
-/**
- * @brief Compute length of given FIFO @p frame. If frame is null then length
- * of empty frame is returned.
- *
- * @param emul Pointer to BMI emulator
- * @param frame Pointer to FIFO frame
- * @param tag_time Indicate if sensor time should be included in empty frame
- * @param header Indicate if header should be included in frame
- *
- * @return length of frame
- */
-static uint8_t bmi_emul_get_frame_len(struct i2c_emul *emul,
- struct bmi_emul_frame *frame,
- bool tag_time, bool header)
-{
- struct bmi_emul_data *data;
- int len;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- /* Empty FIFO frame */
- if (frame == NULL) {
- if (tag_time && header) {
- /* Header of sensortime + sensortime + empty FIFO */
- return 5;
- }
-
- /* Empty fifo */
- return 1;
- }
-
- /* Config FIFO frame */
- if (frame->type & BMI_EMUL_FRAME_CONFIG) {
- if (header) {
- /* Header + byte of data */
- len = 2;
- if (data->type_data->sensortime_follow_config_frame) {
- /* Sensortime data */
- len += 3;
- }
-
- return len;
- }
-
- /* This frame doesn't exist in headerless mode */
- return 0;
- }
-
- /* Sensor data FIFO frame */
- if (header) {
- len = 1;
- } else {
- len = 0;
- }
-
- if (frame->type & BMI_EMUL_FRAME_ACC) {
- len += 6;
- }
- if (frame->type & BMI_EMUL_FRAME_MAG) {
- len += 8;
- }
- if (frame->type & BMI_EMUL_FRAME_GYR) {
- len += 6;
- }
-
- return len;
-}
-
-/**
- * @brief Set given FIFO @p frame as current frame in fifo field of emulator
- * data structure
- *
- * @param emul Pointer to BMI emulator
- * @param frame Pointer to FIFO frame
- * @param tag_time Indicate if sensor time should be included in empty frame
- * @param header Indicate if header should be included in frame
- * @param acc_shift How many bits should be right shifted from accelerometer
- * data
- * @param gyr_shift How many bits should be right shifted from gyroscope data
- */
-static void bmi_emul_set_current_frame(struct i2c_emul *emul,
- struct bmi_emul_frame *frame,
- bool tag_time, bool header,
- int acc_shift, int gyr_shift)
-{
- struct bmi_emul_data *data;
- int i = 0;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- data->fifo_frame_byte = 0;
- data->fifo_frame_len = bmi_emul_get_frame_len(emul, frame, tag_time,
- header);
- /* Empty FIFO frame */
- if (frame == NULL) {
- if (tag_time && header) {
- /* Header */
- data->fifo[0] = BMI_EMUL_FIFO_HEAD_TIME;
- bmi_emul_set_sensortime_reg(emul, &(data->fifo[1]));
- i = 4;
- }
-
- /* Empty header */
- data->fifo[i] = BMI_EMUL_FIFO_HEAD_EMPTY;
-
- return;
- }
-
- /* Config FIFO frame */
- if (frame->type & BMI_EMUL_FRAME_CONFIG) {
- /* Header */
- data->fifo[0] = BMI_EMUL_FIFO_HEAD_CONFIG;
- data->fifo[1] = frame->config;
- if (data->type_data->sensortime_follow_config_frame) {
- bmi_emul_set_sensortime_reg(emul, &(data->fifo[2]));
- }
-
- return;
- }
-
- /* Sensor data FIFO frame */
- if (header) {
- data->fifo[0] = BMI_EMUL_FIFO_HEAD_DATA;
- data->fifo[0] |= frame->type & BMI_EMUL_FRAME_MAG ?
- BMI_EMUL_FIFO_HEAD_DATA_MAG : 0;
- data->fifo[0] |= frame->type & BMI_EMUL_FRAME_GYR ?
- BMI_EMUL_FIFO_HEAD_DATA_GYR : 0;
- data->fifo[0] |= frame->type & BMI_EMUL_FRAME_ACC ?
- BMI_EMUL_FIFO_HEAD_DATA_ACC : 0;
- data->fifo[0] |= frame->tag & BMI_EMUL_FIFO_HEAD_DATA_TAG_MASK;
- i = 1;
- }
-
- if (frame->type & BMI_EMUL_FRAME_MAG) {
- bmi_emul_set_data_reg(emul, frame->mag_x, &(data->fifo[i]), 0);
- i += 2;
- bmi_emul_set_data_reg(emul, frame->mag_y, &(data->fifo[i]), 0);
- i += 2;
- bmi_emul_set_data_reg(emul, frame->mag_z, &(data->fifo[i]), 0);
- i += 2;
- bmi_emul_set_data_reg(emul, frame->rhall, &(data->fifo[i]), 0);
- i += 2;
- }
-
- if (frame->type & BMI_EMUL_FRAME_GYR) {
- bmi_emul_set_data_reg(emul, frame->gyr_x, &(data->fifo[i]),
- gyr_shift);
- i += 2;
- bmi_emul_set_data_reg(emul, frame->gyr_y, &(data->fifo[i]),
- gyr_shift);
- i += 2;
- bmi_emul_set_data_reg(emul, frame->gyr_z, &(data->fifo[i]),
- gyr_shift);
- i += 2;
- }
-
- if (frame->type & BMI_EMUL_FRAME_ACC) {
- bmi_emul_set_data_reg(emul, frame->acc_x, &(data->fifo[i]),
- acc_shift);
- i += 2;
- bmi_emul_set_data_reg(emul, frame->acc_y, &(data->fifo[i]),
- acc_shift);
- i += 2;
- bmi_emul_set_data_reg(emul, frame->acc_z, &(data->fifo[i]),
- acc_shift);
- i += 2;
- }
-}
-
-/**
- * @brief Update internal sensors offset values using values from emulated
- * registers.
- *
- * @param emul Pointer to BMI emulator
- */
-static void bmi_emul_updata_int_off(struct i2c_emul *emul)
-{
- struct bmi_emul_data *data;
- uint16_t gyr_nvm;
- uint8_t gyr98;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- data->off_acc_x = bmi_emul_acc_nvm_to_off(
- data->reg[data->type_data->acc_off_reg]);
- data->off_acc_y = bmi_emul_acc_nvm_to_off(
- data->reg[data->type_data->acc_off_reg + 1]);
- data->off_acc_z = bmi_emul_acc_nvm_to_off(
- data->reg[data->type_data->acc_off_reg + 2]);
-
- gyr98 = data->reg[data->type_data->gyr98_off_reg];
-
- gyr_nvm = data->reg[data->type_data->gyr_off_reg];
- gyr_nvm |= (gyr98 & 0x3) << 8;
- data->off_gyr_x = bmi_emul_gyr_nvm_to_off(gyr_nvm);
- gyr_nvm = data->reg[data->type_data->gyr_off_reg + 1];
- gyr_nvm |= (gyr98 & 0xc) << 6;
- data->off_gyr_y = bmi_emul_gyr_nvm_to_off(gyr_nvm);
- gyr_nvm = data->reg[data->type_data->gyr_off_reg + 2];
- gyr_nvm |= (gyr98 & 0x30) << 4;
- data->off_gyr_z = bmi_emul_gyr_nvm_to_off(gyr_nvm);
-}
-
-/**
- * @brief Restore registers backed in NVM to emulator's registers. Each model
- * of BMI may have different set of NVM backed registers.
- *
- * @param emul Pointer to BMI emulator
- */
-static void bmi_emul_restore_nvm(struct i2c_emul *emul)
-{
- struct bmi_emul_data *data;
- int i;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- ASSERT(data->type_data->nvm_len <= BMI_EMUL_MAX_NVM_REGS);
-
- /* Restore registers values */
- for (i = 0; i < data->type_data->nvm_len; i++) {
- data->reg[data->type_data->nvm_reg[i]] = data->nvm[i];
- }
-
- bmi_emul_updata_int_off(emul);
-}
-
-/** Check description in emul_bmi.h */
-void bmi_emul_flush_fifo(struct i2c_emul *emul, bool tag_time, bool header)
-{
- struct bmi_emul_data *data;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- data->fifo_skip = 0;
- data->fifo_frame = NULL;
- /*
- * Gyroscope and accelerometer shift (last two arguments)
- * are not important for NULL (empty) FIFO frame.
- */
- bmi_emul_set_current_frame(emul, NULL, tag_time, header, 0, 0);
-}
-
-/** Check description in emul_bmi.h */
-void bmi_emul_reset_common(struct i2c_emul *emul, bool tag_time, bool header)
-{
- struct bmi_emul_data *data;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- /* Restore registers backed in NVM */
- bmi_emul_restore_nvm(emul);
-
- /* Flush FIFO */
- bmi_emul_flush_fifo(emul, tag_time, header);
-
- /* Reset sensor timer */
- data->zero_time = bmi_emul_get_sensortime();
-}
-
-/** Check description in emul_bmi.h */
-void bmi_emul_set_cmd_end_time(struct i2c_emul *emul, int time)
-{
- struct bmi_emul_data *data;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- data->cmd_end_time = k_uptime_get_32() + time;
-}
-
-/** Check description in emul_bmi.h */
-bool bmi_emul_is_cmd_end(struct i2c_emul *emul)
-{
- struct bmi_emul_data *data;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- /* We are simulating command execution time and it doesn't expired */
- if (data->simulate_command_exec_time &&
- data->cmd_end_time > k_uptime_get_32()) {
- return false;
- }
-
- return true;
-}
-
-/**
- * @brief Handle I2C write message. BMI model specific write function is called.
- * It is checked if accessed register isn't RO and reserved bits are set
- * to 0. Write set value of reg field of bmi emulator data ignoring
- * reserved bits. If required internal sensor offset values are updated.
- *
- * @param emul Pointer to BMI emulator
- * @param reg Register which is written
- * @param val Value being written to @p reg
- * @param byte Number of handled bytes in this write command
- *
- * @return 0 on success
- * @return -EIO on error
- */
-static int bmi_emul_handle_write(struct i2c_emul *emul, int reg, uint8_t val,
- int byte)
-{
- struct bmi_emul_data *data;
- uint8_t rsvd_mask;
- int ret;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- ret = data->type_data->handle_write(data->reg, emul, reg, byte, val);
- reg = data->type_data->access_reg(emul, reg, byte, false /* = read */);
- if (ret != 0) {
- if (ret == BMI_EMUL_ACCESS_E) {
- if (!data->error_on_ro_write) {
- return 0;
- }
- LOG_ERR("Writing to reg 0x%x which is RO", reg);
- }
-
- return -EIO;
- }
-
- rsvd_mask = data->type_data->rsvd_mask[reg];
-
- if (data->error_on_rsvd_write && rsvd_mask & val) {
- LOG_ERR("Writing 0x%x to reg 0x%x with rsvd bits mask 0x%x",
- val, reg, rsvd_mask);
- return -EIO;
- }
-
- /* Ignore all reserved bits */
- val &= ~rsvd_mask;
- val |= data->reg[reg] & rsvd_mask;
-
- data->reg[reg] = val;
-
- if ((reg >= data->type_data->acc_off_reg &&
- reg <= data->type_data->acc_off_reg + 2) ||
- (reg >= data->type_data->gyr_off_reg &&
- reg <= data->type_data->gyr_off_reg + 2) ||
- reg == data->type_data->gyr98_off_reg) {
- /*
- * Internal offset value should be updated to new value of
- * offset registers
- */
- bmi_emul_updata_int_off(emul);
- }
-
- return 0;
-}
-
-/** Check description in emul_bmi.h */
-void bmi_emul_state_to_reg(struct i2c_emul *emul, int acc_shift,
- int gyr_shift, int acc_reg, int gyr_reg,
- int sensortime_reg, bool acc_off_en,
- bool gyr_off_en)
-{
- struct bmi_emul_data *data;
- int32_t val[3];
- int i;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- if (gyr_off_en) {
- val[0] = data->gyr_x - data->off_gyr_x;
- val[1] = data->gyr_y - data->off_gyr_y;
- val[2] = data->gyr_z - data->off_gyr_z;
- } else {
- val[0] = data->gyr_x;
- val[1] = data->gyr_y;
- val[2] = data->gyr_z;
- }
-
- for (i = 0; i < 3; i++) {
- bmi_emul_set_data_reg(emul, val[i],
- &(data->reg[gyr_reg + i * 2]), gyr_shift);
- }
-
- if (acc_off_en) {
- val[0] = data->acc_x - data->off_acc_x;
- val[1] = data->acc_y - data->off_acc_y;
- val[2] = data->acc_z - data->off_acc_z;
- } else {
- val[0] = data->acc_x;
- val[1] = data->acc_y;
- val[2] = data->acc_z;
- }
-
- for (i = 0; i < 3; i++) {
- bmi_emul_set_data_reg(emul, val[i],
- &(data->reg[acc_reg + i * 2]), acc_shift);
- }
-
- bmi_emul_set_sensortime_reg(emul, &(data->reg[sensortime_reg]));
-}
-
-/** Check description in emul_bmi.h */
-void bmi_emul_append_frame(struct i2c_emul *emul, struct bmi_emul_frame *frame)
-{
- struct bmi_emul_data *data;
- struct bmi_emul_frame *tmp_frame;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- if (data->fifo_frame == NULL) {
- data->fifo_frame = frame;
- } else {
- tmp_frame = data->fifo_frame;
- while (tmp_frame->next != NULL) {
- tmp_frame = tmp_frame->next;
- }
- tmp_frame->next = frame;
- }
-}
-
-/** Check description in emul_bmi.h */
-uint16_t bmi_emul_fifo_len(struct i2c_emul *emul, bool tag_time, bool header)
-{
- struct bmi_emul_frame *frame;
- struct bmi_emul_data *data;
- uint16_t len = 0;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- if (data->fifo_skip != 0 && header) {
- len += 2;
- }
-
- frame = data->fifo_frame;
- while (frame != NULL) {
- len += bmi_emul_get_frame_len(emul, frame, tag_time, header);
- frame = frame->next;
- }
-
- len += bmi_emul_get_frame_len(emul, NULL, tag_time, header);
- /* Do not count last empty frame byte */
- len--;
-
- return len;
-}
-
-/** Check description in emul_bmi.h */
-uint8_t bmi_emul_get_fifo_data(struct i2c_emul *emul, int byte,
- bool tag_time, bool header, int acc_shift,
- int gyr_shift)
-{
- struct bmi_emul_data *data;
- int ret;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- if (byte == 0) {
- /* Repeat uncompleated read of frame */
- bmi_emul_set_current_frame(emul, data->fifo_frame, tag_time,
- header, acc_shift, gyr_shift);
-
- /* Return header for skip frame */
- if (data->fifo_skip != 0 && header) {
- return BMI_EMUL_FIFO_HEAD_SKIP;
- }
- }
-
- if (data->fifo_skip != 0 && byte == 1 && header) {
- /* Return number of skipped frames */
- ret = data->fifo_skip;
- data->fifo_skip = 0;
-
- return ret;
- }
-
- /* Get next valid frame */
- while (data->fifo_frame_byte >= data->fifo_frame_len) {
- /* No data */
- if (data->fifo_frame == NULL) {
- return 0;
- }
- data->fifo_frame = data->fifo_frame->next;
- bmi_emul_set_current_frame(emul, data->fifo_frame, tag_time,
- header, acc_shift, gyr_shift);
- }
-
- return data->fifo[data->fifo_frame_byte++];
-}
-
-/**
- * @brief Handle I2C read message. BMI model specific read function is called.
- * It is checked if accessed register isn't WO.
- *
- * @param emul Pointer to BMI emulator
- * @param reg Register address to read
- * @param buf Pointer where result should be stored
- * @param byte Byte which is accessed during block read
- *
- * @return 0 on success
- * @return -EIO on error
- */
-static int bmi_emul_handle_read(struct i2c_emul *emul, int reg, uint8_t *buf,
- int byte)
-{
- struct bmi_emul_data *data;
- int ret;
-
- data = BMI_DATA_FROM_I2C_EMUL(emul);
-
- ret = data->type_data->handle_read(data->reg, emul, reg, byte, buf);
- reg = data->type_data->access_reg(emul, reg, byte, true /* = read */);
- if (ret == BMI_EMUL_ACCESS_E && data->error_on_wo_read) {
- LOG_ERR("Reading reg 0x%x which is WO", reg);
- } else if (ret != 0) {
- return ret;
- }
-
- return 0;
-}
-
-/* Device instantiation */
-
-static struct i2c_emul_api bmi_emul_api = {
- .transfer = i2c_common_emul_transfer,
-};
-
-/**
- * @brief Set up a new BMI emulator
- *
- * This should be called for each BMI device that needs to be
- * emulated. It registers it with the I2C emulation controller.
- *
- * @param emul Emulation information
- * @param parent Device to emulate
- *
- * @return 0 indicating success (always)
- */
-static int bmi_emul_init(const struct emul *emul,
- const struct device *parent)
-{
- const struct i2c_common_emul_cfg *cfg = emul->cfg;
- struct i2c_common_emul_data *data = cfg->data;
- struct bmi_emul_data *bmi_data;
- int ret;
-
- data->emul.api = &bmi_emul_api;
- data->emul.addr = cfg->addr;
- data->i2c = parent;
- data->cfg = cfg;
- i2c_common_emul_init(data);
-
- bmi_data = CONTAINER_OF(data, struct bmi_emul_data, common);
-
- switch (bmi_data->type) {
- case BMI_EMUL_160:
- bmi_data->type_data = get_bmi160_emul_type_data();
- break;
- case BMI_EMUL_260:
- bmi_data->type_data = get_bmi260_emul_type_data();
- break;
- }
-
- /* Set callback access_reg to type specific function */
- data->access_reg = bmi_data->type_data->access_reg;
-
- ret = i2c_emul_register(parent, emul->dev_label, &data->emul);
-
- bmi_data->type_data->reset(bmi_data->reg, &data->emul);
-
- return ret;
-}
-
-#define BMI_EMUL(n) \
- static struct bmi_emul_data bmi_emul_data_##n = { \
- .error_on_ro_write = DT_INST_PROP(n, error_on_ro_write),\
- .error_on_wo_read = DT_INST_PROP(n, error_on_wo_read), \
- .error_on_rsvd_write = DT_INST_PROP(n, \
- error_on_reserved_bit_write), \
- .simulate_command_exec_time = DT_INST_PROP(n, \
- simulate_command_exec_time), \
- .type = DT_STRING_TOKEN(DT_DRV_INST(n), device_model), \
- .common = { \
- .start_write = NULL, \
- .write_byte = bmi_emul_handle_write, \
- .finish_write = NULL, \
- .start_read = NULL, \
- .read_byte = bmi_emul_handle_read, \
- .finish_read = NULL, \
- .access_reg = NULL, \
- }, \
- }; \
- \
- static const struct i2c_common_emul_cfg bmi_emul_cfg_##n = { \
- .i2c_label = DT_INST_BUS_LABEL(n), \
- .dev_label = DT_INST_LABEL(n), \
- .data = &bmi_emul_data_##n.common, \
- .addr = DT_INST_REG_ADDR(n), \
- }; \
- EMUL_DEFINE(bmi_emul_init, DT_DRV_INST(n), &bmi_emul_cfg_##n, \
- &bmi_emul_data_##n)
-
-DT_INST_FOREACH_STATUS_OKAY(BMI_EMUL)
-
-#define BMI_EMUL_CASE(n) \
- case DT_INST_DEP_ORD(n): return &bmi_emul_data_##n.common.emul;
-
-/** Check description in emul_bmi.h */
-struct i2c_emul *bmi_emul_get(int ord)
-{
- switch (ord) {
- DT_INST_FOREACH_STATUS_OKAY(BMI_EMUL_CASE)
-
- default:
- return NULL;
- }
-}
diff --git a/zephyr/emul/emul_bmi160.c b/zephyr/emul/emul_bmi160.c
deleted file mode 100644
index 2a68b688ff..0000000000
--- a/zephyr/emul/emul_bmi160.c
+++ /dev/null
@@ -1,770 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT zephyr_bmi
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <logging/log.h>
-LOG_MODULE_REGISTER(emul_bmi160);
-
-#include <device.h>
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-#include "emul/emul_bmi.h"
-
-#include "driver/accelgyro_bmi160.h"
-#include "driver/accelgyro_bmi_common.h"
-
-/** Mask reserved bits in each register of BMI160 */
-static const uint8_t bmi_emul_160_rsvd_mask[] = {
- [BMI160_CHIP_ID] = 0x00,
- [0x01] = 0xff, /* Reserved */
- [BMI160_ERR_REG] = 0x00,
- [BMI160_PMU_STATUS] = 0xc0,
- [BMI160_MAG_X_L_G] = 0x00,
- [BMI160_MAG_X_H_G] = 0x00,
- [BMI160_MAG_Y_L_G] = 0x00,
- [BMI160_MAG_Y_H_G] = 0x00,
- [BMI160_MAG_Z_L_G] = 0x00,
- [BMI160_MAG_Z_H_G] = 0x00,
- [BMI160_RHALL_L_G] = 0x00,
- [BMI160_RHALL_H_G] = 0x00,
- [BMI160_GYR_X_L_G] = 0x00,
- [BMI160_GYR_X_H_G] = 0x00,
- [BMI160_GYR_Y_L_G] = 0x00,
- [BMI160_GYR_Y_H_G] = 0x00,
- [BMI160_GYR_Z_L_G] = 0x00,
- [BMI160_GYR_Z_H_G] = 0x00,
- [BMI160_ACC_X_L_G] = 0x00,
- [BMI160_ACC_X_H_G] = 0x00,
- [BMI160_ACC_Y_L_G] = 0x00,
- [BMI160_ACC_Y_H_G] = 0x00,
- [BMI160_ACC_Z_L_G] = 0x00,
- [BMI160_ACC_Z_H_G] = 0x00,
- [BMI160_SENSORTIME_0] = 0x00,
- [BMI160_SENSORTIME_1] = 0x00,
- [BMI160_SENSORTIME_2] = 0x00,
- [BMI160_STATUS] = 0x01,
- [BMI160_INT_STATUS_0] = 0x00,
- [BMI160_INT_STATUS_1] = 0x03,
- [BMI160_INT_STATUS_2] = 0x00,
- [BMI160_INT_STATUS_3] = 0x00,
- [BMI160_TEMPERATURE_0] = 0x00,
- [BMI160_TEMPERATURE_1] = 0x00,
- [BMI160_FIFO_LENGTH_0] = 0x00,
- [BMI160_FIFO_LENGTH_1] = 0xf8,
- [BMI160_FIFO_DATA] = 0x00,
- [0x25 ... 0x3f] = 0xff, /* Reserved */
- [BMI160_ACC_CONF] = 0x00,
- [BMI160_ACC_RANGE] = 0xf0,
- [BMI160_GYR_CONF] = 0xc0,
- [BMI160_GYR_RANGE] = 0xf8,
- [BMI160_MAG_CONF] = 0xf0,
- [BMI160_FIFO_DOWNS] = 0x00,
- [BMI160_FIFO_CONFIG_0] = 0x00,
- [BMI160_FIFO_CONFIG_1] = 0x01,
- [0x48 ... 0x4a] = 0xff, /* Reserved */
- [BMI160_MAG_IF_0] = 0x01,
- [BMI160_MAG_IF_1] = 0x40,
- [BMI160_MAG_IF_2] = 0x00,
- [BMI160_MAG_IF_3] = 0x00,
- [BMI160_MAG_IF_4] = 0x00,
- [BMI160_INT_EN_0] = 0x08,
- [BMI160_INT_EN_1] = 0x80,
- [BMI160_INT_EN_2] = 0xf0,
- [BMI160_INT_OUT_CTRL] = 0x00,
- [BMI160_INT_LATCH] = 0xc0,
- [BMI160_INT_MAP_0] = 0x00,
- [BMI160_INT_MAP_1] = 0x00,
- [BMI160_INT_MAP_2] = 0x00,
- [BMI160_INT_DATA_0] = 0x77,
- [BMI160_INT_DATA_1] = 0x7f,
- [BMI160_INT_LOW_HIGH_0] = 0x00,
- [BMI160_INT_LOW_HIGH_1] = 0x00,
- [BMI160_INT_LOW_HIGH_2] = 0x3c,
- [BMI160_INT_LOW_HIGH_3] = 0x00,
- [BMI160_INT_LOW_HIGH_4] = 0x00,
- [BMI160_INT_MOTION_0] = 0x00,
- [BMI160_INT_MOTION_1] = 0x00,
- [BMI160_INT_MOTION_2] = 0x00,
- [BMI160_INT_MOTION_3] = 0xc0,
- [BMI160_INT_TAP_0] = 0x38,
- [BMI160_INT_TAP_1] = 0xe0,
- [BMI160_INT_ORIENT_0] = 0x00,
- [BMI160_INT_ORIENT_1] = 0x00,
- [BMI160_INT_FLAT_0] = 0xc0,
- [BMI160_INT_FLAT_1] = 0xc8,
- [BMI160_FOC_CONF] = 0x80,
- [BMI160_CONF] = 0xfd,
- [BMI160_IF_CONF] = 0xce,
- [BMI160_PMU_TRIGGER] = 0x80,
- [BMI160_SELF_TEST] = 0xe0,
- [0x6e] = 0xff, /* Reserved */
- [0x6f] = 0xff, /* Reserved */
- [BMI160_NV_CONF] = 0xf0,
- [BMI160_OFFSET_ACC70] = 0x00,
- [BMI160_OFFSET_ACC70 + 1] = 0x00,
- [BMI160_OFFSET_ACC70 + 2] = 0x00,
- [BMI160_OFFSET_GYR70] = 0x00,
- [BMI160_OFFSET_GYR70 + 1] = 0x00,
- [BMI160_OFFSET_GYR70 + 2] = 0x00,
- [BMI160_OFFSET_EN_GYR98] = 0x00,
- [BMI160_STEP_CNT_0] = 0x00,
- [BMI160_STEP_CNT_1] = 0x00,
- [BMI160_STEP_CONF_0] = 0x00,
- [BMI160_STEP_CONF_1] = 0xf0,
- [0x7c] = 0xff, /* Reserved */
- [0x7d] = 0xff, /* Reserved */
- [BMI160_CMD_REG] = 0x00,
-};
-
-/**
- * @brief Convert range in format of ACC_RANGE register to number of bits
- * that should be shifted right to obtain 16 bit reported accelerometer
- * value from internal 32 bit value
- *
- * @param range Value of ACC_RANGE register
- *
- * @return shift Number of LSB that should be ignored from internal
- * accelerometer value
- */
-static int bmi160_emul_acc_range_to_shift(uint8_t range)
-{
- switch (range & 0xf) {
- case BMI160_GSEL_2G:
- return 0;
- case BMI160_GSEL_4G:
- return 1;
- case BMI160_GSEL_8G:
- return 2;
- case BMI160_GSEL_16G:
- return 3;
- default:
- return 0;
- }
-}
-
-/**
- * @brief Convert range in format of GYR_RANGE register to number of bits
- * that should be shifted right to obtain 16 bit reported gyroscope
- * value from internal 32 bit value
- *
- * @param range Value of GYR_RANGE register
- *
- * @return shift Number of LSB that should be ignored from internal
- * gyroscope value
- */
-static int bmi160_emul_gyr_range_to_shift(uint8_t range)
-{
- switch (range & 0x7) {
- case BMI160_DPS_SEL_2000:
- return 4;
- case BMI160_DPS_SEL_1000:
- return 3;
- case BMI160_DPS_SEL_500:
- return 2;
- case BMI160_DPS_SEL_250:
- return 1;
- case BMI160_DPS_SEL_125:
- return 0;
- default:
- return 0;
- }
-}
-
-/**
- * @brief Reset registers to default values and restore registers backed by NVM
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- */
-static void bmi160_emul_reset(uint8_t *regs, struct i2c_emul *emul)
-{
- bool tag_time;
- bool header;
-
- regs[BMI160_CHIP_ID] = 0xd1;
- regs[BMI160_ERR_REG] = 0x00;
- regs[BMI160_PMU_STATUS] = 0x00;
- regs[BMI160_MAG_X_L_G] = 0x00;
- regs[BMI160_MAG_X_H_G] = 0x00;
- regs[BMI160_MAG_Y_L_G] = 0x00;
- regs[BMI160_MAG_Y_H_G] = 0x00;
- regs[BMI160_MAG_Z_L_G] = 0x00;
- regs[BMI160_MAG_Z_H_G] = 0x00;
- regs[BMI160_RHALL_L_G] = 0x00;
- regs[BMI160_RHALL_H_G] = 0x00;
- regs[BMI160_GYR_X_L_G] = 0x00;
- regs[BMI160_GYR_X_H_G] = 0x00;
- regs[BMI160_GYR_Y_L_G] = 0x00;
- regs[BMI160_GYR_Y_H_G] = 0x00;
- regs[BMI160_GYR_Z_L_G] = 0x00;
- regs[BMI160_GYR_Z_H_G] = 0x00;
- regs[BMI160_ACC_X_L_G] = 0x00;
- regs[BMI160_ACC_X_H_G] = 0x00;
- regs[BMI160_ACC_Y_L_G] = 0x00;
- regs[BMI160_ACC_Y_H_G] = 0x00;
- regs[BMI160_ACC_Z_L_G] = 0x00;
- regs[BMI160_ACC_Z_H_G] = 0x00;
- regs[BMI160_SENSORTIME_0] = 0x00;
- regs[BMI160_SENSORTIME_1] = 0x00;
- regs[BMI160_SENSORTIME_2] = 0x00;
- regs[BMI160_STATUS] = 0x01;
- regs[BMI160_INT_STATUS_0] = 0x00;
- regs[BMI160_INT_STATUS_1] = 0x00;
- regs[BMI160_INT_STATUS_2] = 0x00;
- regs[BMI160_INT_STATUS_3] = 0x00;
- regs[BMI160_TEMPERATURE_0] = 0x00;
- regs[BMI160_TEMPERATURE_1] = 0x00;
- regs[BMI160_FIFO_LENGTH_0] = 0x00;
- regs[BMI160_FIFO_LENGTH_1] = 0x00;
- regs[BMI160_FIFO_DATA] = 0x00;
- regs[BMI160_ACC_CONF] = 0x28;
- regs[BMI160_ACC_RANGE] = 0x03;
- regs[BMI160_GYR_CONF] = 0x28;
- regs[BMI160_GYR_RANGE] = 0x00;
- regs[BMI160_MAG_CONF] = 0x0b;
- regs[BMI160_FIFO_DOWNS] = 0x88;
- regs[BMI160_FIFO_CONFIG_0] = 0x80;
- regs[BMI160_FIFO_CONFIG_1] = 0x10;
- regs[BMI160_MAG_IF_0] = 0x20;
- regs[BMI160_MAG_IF_1] = 0x80;
- regs[BMI160_MAG_IF_2] = 0x42;
- regs[BMI160_MAG_IF_3] = 0x4c;
- regs[BMI160_MAG_IF_4] = 0x00;
- regs[BMI160_INT_EN_0] = 0x00;
- regs[BMI160_INT_EN_1] = 0x00;
- regs[BMI160_INT_EN_2] = 0x00;
- regs[BMI160_INT_OUT_CTRL] = 0x00;
- regs[BMI160_INT_LATCH] = 0x00;
- regs[BMI160_INT_MAP_0] = 0x00;
- regs[BMI160_INT_MAP_1] = 0x00;
- regs[BMI160_INT_MAP_2] = 0x00;
- regs[BMI160_INT_DATA_0] = 0x00;
- regs[BMI160_INT_DATA_1] = 0x00;
- regs[BMI160_INT_LOW_HIGH_0] = 0x07;
- regs[BMI160_INT_LOW_HIGH_1] = 0x30;
- regs[BMI160_INT_LOW_HIGH_2] = 0x81;
- regs[BMI160_INT_LOW_HIGH_3] = 0xdb;
- regs[BMI160_INT_LOW_HIGH_4] = 0xc0;
- regs[BMI160_INT_MOTION_0] = 0x00;
- regs[BMI160_INT_MOTION_1] = 0x14;
- regs[BMI160_INT_MOTION_2] = 0x14;
- regs[BMI160_INT_MOTION_3] = 0x24;
- regs[BMI160_INT_TAP_0] = 0x04;
- regs[BMI160_INT_TAP_1] = 0xda;
- regs[BMI160_INT_ORIENT_0] = 0x18;
- regs[BMI160_INT_ORIENT_1] = 0x48;
- regs[BMI160_INT_FLAT_0] = 0x08;
- regs[BMI160_INT_FLAT_1] = 0x11;
- regs[BMI160_FOC_CONF] = 0x00;
- regs[BMI160_CONF] = 0x00;
- regs[BMI160_IF_CONF] = 0x00;
- regs[BMI160_PMU_TRIGGER] = 0x00;
- regs[BMI160_SELF_TEST] = 0x00;
- regs[BMI160_STEP_CNT_0] = 0x00;
- regs[BMI160_STEP_CNT_1] = 0x00;
- regs[BMI160_STEP_CONF_0] = 0x00;
- regs[BMI160_STEP_CONF_1] = 0x15;
- regs[BMI160_CMD_REG] = 0x03;
-
- /* Call generic reset */
- tag_time = regs[BMI160_FIFO_CONFIG_1] & BMI160_FIFO_TAG_TIME_EN;
- header = regs[BMI160_FIFO_CONFIG_1] & BMI160_FIFO_HEADER_EN;
- bmi_emul_reset_common(emul, tag_time, header);
-}
-
-/**
- * @brief Clear all interrupt registers
- *
- * @param regs Pointer to array of emulator's registers
- */
-static void bmi160_emul_clear_int(uint8_t *regs)
-{
- regs[BMI160_INT_STATUS_0] = 0x00;
- regs[BMI160_INT_STATUS_1] = 0x00;
- regs[BMI160_INT_STATUS_2] = 0x00;
- regs[BMI160_INT_STATUS_3] = 0x00;
-}
-
-/**
- * @brief Get offset value for given gyroscope value. If gyroscope value is
- * above maximum (belowe minimum), then minimum -31,25°/s
- * (maximum 31,25°/s) offset value is returned.
- *
- * @param gyr Gyroscope value
- */
-static int16_t bmi160_emul_get_gyr_target_off(int32_t gyr)
-{
- if (gyr > (int32_t)BMI_EMUL_125_DEG_S / 4) {
- return -((int32_t)BMI_EMUL_125_DEG_S / 4);
- }
-
- if (gyr < -((int32_t)BMI_EMUL_125_DEG_S / 4)) {
- return BMI_EMUL_125_DEG_S / 4;
- }
-
- return -gyr;
-}
-
-/**
- * @brief Get offset value for given accelerometer value. If accelerometer
- * value - target is above maximum (belowe minimum), then minimum -0.5g
- * (maximum 0.5g) offset value is returned.
- *
- * @param acc Accelerometer value
- * @param target Target value in FOC configuration register format
- */
-static int16_t bmi160_emul_get_acc_target_off(int32_t acc, uint8_t target)
-{
- switch (target) {
- case BMI160_FOC_ACC_PLUS_1G:
- acc -= BMI_EMUL_1G;
- break;
- case BMI160_FOC_ACC_MINUS_1G:
- acc += BMI_EMUL_1G;
- break;
- }
-
- if (acc > (int32_t)BMI_EMUL_1G / 2) {
- return -((int32_t)BMI_EMUL_1G / 2);
- }
-
- if (acc < -((int32_t)BMI_EMUL_1G / 2)) {
- return BMI_EMUL_1G / 2;
- }
-
- return -acc;
-}
-
-/**
- * @brief Handle fast offset compensation. Check FOC configuration register
- * and sets gyroscope and/or accelerometer offset using current emulator
- * state.
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- */
-static void bmi160_emul_handle_off_comp(uint8_t *regs, struct i2c_emul *emul)
-{
- uint8_t target;
- int16_t off;
- int32_t val;
-
- if (regs[BMI160_FOC_CONF] & BMI160_FOC_GYRO_EN) {
- val = bmi_emul_get_value(emul, BMI_EMUL_GYR_X);
- off = bmi160_emul_get_gyr_target_off(val);
- bmi_emul_set_off(emul, BMI_EMUL_GYR_X, off);
- val = bmi_emul_get_value(emul, BMI_EMUL_GYR_Y);
- off = bmi160_emul_get_gyr_target_off(val);
- bmi_emul_set_off(emul, BMI_EMUL_GYR_Y, off);
- val = bmi_emul_get_value(emul, BMI_EMUL_GYR_Z);
- off = bmi160_emul_get_gyr_target_off(val);
- bmi_emul_set_off(emul, BMI_EMUL_GYR_Z, off);
- }
-
- target = (regs[BMI160_FOC_CONF] >> BMI160_FOC_ACC_X_OFFSET) & 0x3;
- if (target) {
- val = bmi_emul_get_value(emul, BMI_EMUL_ACC_X);
- off = bmi160_emul_get_acc_target_off(val, target);
- bmi_emul_set_off(emul, BMI_EMUL_ACC_X, off);
- }
-
- target = (regs[BMI160_FOC_CONF] >> BMI160_FOC_ACC_Y_OFFSET) & 0x3;
- if (target) {
- val = bmi_emul_get_value(emul, BMI_EMUL_ACC_Y);
- off = bmi160_emul_get_acc_target_off(val, target);
- bmi_emul_set_off(emul, BMI_EMUL_ACC_Y, off);
- }
-
- target = (regs[BMI160_FOC_CONF] >> BMI160_FOC_ACC_Z_OFFSET) & 0x3;
- if (target) {
- val = bmi_emul_get_value(emul, BMI_EMUL_ACC_Z);
- off = bmi160_emul_get_acc_target_off(val, target);
- bmi_emul_set_off(emul, BMI_EMUL_ACC_Z, off);
- }
-}
-
-/**
- * @brief Execute first part of command. Emulate state of device which is
- * during handling command (status bits etc). This function save time
- * on which command should end.
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- * @param cmd Command that is starting
- *
- * @return 0 on success
- * @return -EIO on failure
- */
-static int bmi160_emul_start_cmd(uint8_t *regs, struct i2c_emul *emul, int cmd)
-{
- int time;
-
- switch (cmd) {
- case BMI160_CMD_SOFT_RESET:
- time = 1;
- break;
- case BMI160_CMD_START_FOC:
- if ((regs[BMI160_FOC_CONF] & BMI160_FOC_GYRO_EN) &&
- ((regs[BMI160_PMU_STATUS] &
- (0x3 << BMI160_PMU_GYR_OFFSET)) !=
- BMI160_PMU_NORMAL << BMI160_PMU_GYR_OFFSET)) {
- LOG_ERR("Starting gyroscope FOC in low power mode");
- return -EIO;
- }
-
- if ((regs[BMI160_FOC_CONF] & ~BMI160_FOC_GYRO_EN) &&
- ((regs[BMI160_PMU_STATUS] &
- (0x3 << BMI160_PMU_ACC_OFFSET)) !=
- BMI160_PMU_NORMAL << BMI160_PMU_ACC_OFFSET)) {
- LOG_ERR("Starting accelerometer FOC in low power mode");
- return -EIO;
- }
-
- regs[BMI160_STATUS] &= ~BMI160_FOC_RDY;
- time = 250;
- break;
- case BMI160_CMD_ACC_MODE_SUSP:
- case BMI160_CMD_GYR_MODE_SUSP:
- case BMI160_CMD_MAG_MODE_SUSP:
- time = 0;
- break;
- /* Real hardware probably switch faster if not in suspend mode */
- case BMI160_CMD_ACC_MODE_NORMAL:
- case BMI160_CMD_ACC_MODE_LOWPOWER:
- time = 4;
- break;
- case BMI160_CMD_GYR_MODE_NORMAL:
- case BMI160_CMD_GYR_MODE_FAST_STARTUP:
- time = 80;
- break;
- case BMI160_CMD_MAG_MODE_NORMAL:
- case BMI160_CMD_MAG_MODE_LOWPOWER:
- time = 1;
- break;
- case BMI160_CMD_FIFO_FLUSH:
- time = 0;
- break;
- case BMI160_CMD_INT_RESET:
- time = 0;
- break;
- default:
- LOG_ERR("Unknown command 0x%x", cmd);
- return -EIO;
- }
-
- regs[BMI160_CMD_REG] = cmd;
- bmi_emul_set_cmd_end_time(emul, time);
-
- return 0;
-}
-
-/**
- * @brief Emulate end of ongoing command.
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- */
-static void bmi160_emul_end_cmd(uint8_t *regs, struct i2c_emul *emul)
-{
- uint8_t pmu_status;
- bool tag_time;
- bool header;
- int cmd;
-
- pmu_status = regs[BMI160_PMU_STATUS];
- cmd = regs[BMI160_CMD_REG];
- regs[BMI160_CMD_REG] = BMI160_CMD_NOOP;
- tag_time = regs[BMI160_FIFO_CONFIG_1] & BMI160_FIFO_TAG_TIME_EN;
- header = regs[BMI160_FIFO_CONFIG_1] & BMI160_FIFO_HEADER_EN;
-
- switch (cmd) {
- case BMI160_CMD_SOFT_RESET:
- bmi160_emul_reset(regs, emul);
- break;
- case BMI160_CMD_START_FOC:
- bmi160_emul_handle_off_comp(regs, emul);
- regs[BMI160_STATUS] |= BMI160_FOC_RDY;
- break;
- case BMI160_CMD_ACC_MODE_SUSP:
- pmu_status &= ~(0x3 << BMI160_PMU_ACC_OFFSET);
- pmu_status |= BMI160_PMU_SUSPEND << BMI160_PMU_ACC_OFFSET;
- break;
- case BMI160_CMD_ACC_MODE_NORMAL:
- pmu_status &= ~(0x3 << BMI160_PMU_ACC_OFFSET);
- pmu_status |= BMI160_PMU_NORMAL << BMI160_PMU_ACC_OFFSET;
- break;
- case BMI160_CMD_ACC_MODE_LOWPOWER:
- pmu_status &= ~(0x3 << BMI160_PMU_ACC_OFFSET);
- pmu_status |= BMI160_PMU_LOW_POWER << BMI160_PMU_ACC_OFFSET;
- break;
- case BMI160_CMD_GYR_MODE_SUSP:
- pmu_status &= ~(0x3 << BMI160_PMU_GYR_OFFSET);
- pmu_status |= BMI160_PMU_SUSPEND << BMI160_PMU_GYR_OFFSET;
- break;
- case BMI160_CMD_GYR_MODE_NORMAL:
- pmu_status &= ~(0x3 << BMI160_PMU_GYR_OFFSET);
- pmu_status |= BMI160_PMU_NORMAL << BMI160_PMU_GYR_OFFSET;
- break;
- case BMI160_CMD_GYR_MODE_FAST_STARTUP:
- pmu_status &= ~(0x3 << BMI160_PMU_GYR_OFFSET);
- pmu_status |= BMI160_PMU_FAST_STARTUP << BMI160_PMU_GYR_OFFSET;
- break;
- case BMI160_CMD_MAG_MODE_SUSP:
- pmu_status &= ~(0x3 << BMI160_PMU_MAG_OFFSET);
- pmu_status |= BMI160_PMU_SUSPEND << BMI160_PMU_MAG_OFFSET;
- break;
- case BMI160_CMD_MAG_MODE_NORMAL:
- pmu_status &= ~(0x3 << BMI160_PMU_MAG_OFFSET);
- pmu_status |= BMI160_PMU_NORMAL << BMI160_PMU_MAG_OFFSET;
- break;
- case BMI160_CMD_MAG_MODE_LOWPOWER:
- pmu_status &= ~(0x3 << BMI160_PMU_MAG_OFFSET);
- pmu_status |= BMI160_PMU_LOW_POWER << BMI160_PMU_MAG_OFFSET;
- break;
- case BMI160_CMD_FIFO_FLUSH:
- bmi_emul_flush_fifo(emul, tag_time, header);
- break;
- case BMI160_CMD_INT_RESET:
- bmi160_emul_clear_int(regs);
- break;
- }
-
- /* Clear FIFO on sensor on/off in headerless mode */
- if (pmu_status != regs[BMI160_PMU_STATUS] && !header) {
- bmi_emul_flush_fifo(emul, tag_time, header);
- }
-
- regs[BMI160_PMU_STATUS] = pmu_status;
-}
-
-/**
- * @brief BMI160 specific write function. It doesn't handle block writes.
- * Check if read only register is not accessed. Before writing value,
- * ongoing command is finished if possible. Write to CMD register is
- * handled by BMI160 specific function. On changing of FIFO
- * header/headerless mode, FIFO is flushed.
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- * @param reg Register address that is accessed
- * @param byte Number of handled bytes in this write command
- * @param val Value that is being written
- *
- * @return 0 on success
- * @return BMI_EMUL_ACCESS_E on RO register access
- * @return -EIO on error
- */
-static int bmi160_emul_handle_write(uint8_t *regs, struct i2c_emul *emul,
- int reg, int byte, uint8_t val)
-{
- bool tag_time;
- bool header;
-
- if (byte > 1) {
- LOG_ERR("Block writes are not allowed");
- return -EIO;
- }
-
- if (reg <= BMI160_FIFO_DATA ||
- (reg >= BMI160_STEP_CNT_0 && reg <= BMI160_STEP_CNT_1)) {
- return BMI_EMUL_ACCESS_E;
- }
-
- /* Stop on going command if required */
- if (regs[BMI160_CMD_REG] != BMI160_CMD_NOOP &&
- bmi_emul_is_cmd_end(emul)) {
- bmi160_emul_end_cmd(regs, emul);
- }
-
- switch (reg) {
- case BMI160_CMD_REG:
- if (regs[BMI160_CMD_REG] != BMI160_CMD_NOOP) {
- LOG_ERR("Issued command before previous end");
- return -EIO;
- }
-
- return bmi160_emul_start_cmd(regs, emul, val);
- case BMI160_FIFO_CONFIG_1:
- tag_time = regs[BMI160_FIFO_CONFIG_1] & BMI160_FIFO_TAG_TIME_EN;
- header = regs[BMI160_FIFO_CONFIG_1] & BMI160_FIFO_HEADER_EN;
- /*
- * Clear FIFO on transition between headerless and
- * header mode
- */
- if (!!(val & BMI160_FIFO_HEADER_EN) != header) {
- bmi_emul_flush_fifo(emul, tag_time, header);
- }
- break;
- }
-
- return 0;
-}
-
-/**
- * @brief Get currently accessed register. It is first register plus number of
- * handled bytes for all registers except BMI160_FIFO_DATA for which
- * address incrementation is disabled.
- *
- * @param emul Pointer to BMI emulator
- * @param reg First byte of last write message
- * @param bytes Number of bytes already handled from current message
- * @param read If currently handled is read message
- *
- * @return Currently accessed register
- */
-static int bmi160_emul_access_reg(struct i2c_emul *emul, int reg, int byte,
- bool read)
-{
- if (!read) {
- return reg;
- }
-
- /*
- * If register is FIFO data, then read data from FIFO.
- * Else block read access subsequent registers.
- */
- if (reg <= BMI160_FIFO_DATA && reg + byte >= BMI160_FIFO_DATA) {
- return BMI160_FIFO_DATA;
- }
-
- return reg + byte;
-}
-
-/**
- * @brief BMI160 specific read function. It handle block reads but only if
- * device is not suspended. FIFO data register is trap register, so
- * after reaching it, register address is not increased on block reads.
- * Before reading value, ongoing command is finished if possible.
- * Read of sensor data traps current emulator state in registers.
- * Read of FIFO length and FIFO data triggers default BMI functions.
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- * @param reg Register address that is accessed
- * @param byte Byte which is accessed during block read
- * @param buf Pointer where read byte should be stored
- *
- * @return 0 on success
- * @return BMI_EMUL_ACCESS_E on WO register access
- * @return -EIO on other error
- */
-static int bmi160_emul_handle_read(uint8_t *regs, struct i2c_emul *emul,
- int reg, int byte, char *buf)
-{
- uint16_t fifo_len;
- bool acc_off_en;
- bool gyr_off_en;
- bool tag_time;
- bool header;
- int gyr_shift;
- int acc_shift;
- int fifo_byte;
-
- /* Get number of bytes readed from FIFO */
- fifo_byte = byte - (reg - BMI160_FIFO_DATA);
-
- reg = bmi160_emul_access_reg(emul, reg, byte, true /* = read */);
-
- /* Stop on going command if required */
- if (regs[BMI160_CMD_REG] != BMI160_CMD_NOOP &&
- bmi_emul_is_cmd_end(emul)) {
- bmi160_emul_end_cmd(regs, emul);
- }
-
- /* Burst reads are not supported if all sensors are in suspend mode */
- if ((regs[BMI160_PMU_STATUS] & 0x3f) == 0 && byte > 0) {
- LOG_ERR("Block reads are not supported in suspend mode");
- return -EIO;
- }
-
- tag_time = regs[BMI160_FIFO_CONFIG_1] & BMI160_FIFO_TAG_TIME_EN;
- header = regs[BMI160_FIFO_CONFIG_1] & BMI160_FIFO_HEADER_EN;
- acc_off_en = regs[BMI160_OFFSET_EN_GYR98] & BMI160_OFFSET_ACC_EN;
- gyr_off_en = regs[BMI160_OFFSET_EN_GYR98] & BMI160_OFFSET_GYRO_EN;
- gyr_shift = bmi160_emul_gyr_range_to_shift(regs[BMI160_GYR_RANGE]);
- acc_shift = bmi160_emul_acc_range_to_shift(regs[BMI160_ACC_RANGE]);
-
- switch (reg) {
- case BMI160_GYR_X_L_G:
- case BMI160_GYR_X_H_G:
- case BMI160_GYR_Y_L_G:
- case BMI160_GYR_Y_H_G:
- case BMI160_GYR_Z_L_G:
- case BMI160_GYR_Z_H_G:
- case BMI160_ACC_X_L_G:
- case BMI160_ACC_X_H_G:
- case BMI160_ACC_Y_L_G:
- case BMI160_ACC_Y_H_G:
- case BMI160_ACC_Z_L_G:
- case BMI160_ACC_Z_H_G:
- case BMI160_SENSORTIME_0:
- case BMI160_SENSORTIME_1:
- case BMI160_SENSORTIME_2:
- /*
- * Snapshot of current emulator state is created on data read
- * and shouldn't be changed until next I2C operation
- */
- if (byte == 0) {
- bmi_emul_state_to_reg(emul, acc_shift, gyr_shift,
- BMI160_ACC_X_L_G,
- BMI160_GYR_X_L_G,
- BMI160_SENSORTIME_0,
- acc_off_en, gyr_off_en);
- }
- break;
- case BMI160_FIFO_LENGTH_0:
- case BMI160_FIFO_LENGTH_1:
- if (byte == 0) {
- fifo_len = bmi_emul_fifo_len(emul, tag_time, header);
- regs[BMI160_FIFO_LENGTH_0] = fifo_len & 0xff;
- regs[BMI160_FIFO_LENGTH_1] = (fifo_len >> 8) & 0x7;
- }
- break;
- case BMI160_FIFO_DATA:
- regs[reg] = bmi_emul_get_fifo_data(emul, fifo_byte, tag_time,
- header, acc_shift,
- gyr_shift);
- break;
- }
-
- *buf = regs[reg];
-
- return 0;
-}
-
-/** Registers backed in NVM by BMI160 */
-const int bmi160_nvm_reg[] = {BMI160_NV_CONF,
- BMI160_OFFSET_ACC70,
- BMI160_OFFSET_ACC70 + 1,
- BMI160_OFFSET_ACC70 + 2,
- BMI160_OFFSET_GYR70,
- BMI160_OFFSET_GYR70 + 1,
- BMI160_OFFSET_GYR70 + 2,
- BMI160_OFFSET_EN_GYR98};
-
-/** Confguration of BMI160 */
-struct bmi_emul_type_data bmi160_emul = {
- .sensortime_follow_config_frame = false,
- .handle_write = bmi160_emul_handle_write,
- .handle_read = bmi160_emul_handle_read,
- .access_reg = bmi160_emul_access_reg,
- .reset = bmi160_emul_reset,
- .rsvd_mask = bmi_emul_160_rsvd_mask,
- .nvm_reg = bmi160_nvm_reg,
- .nvm_len = ARRAY_SIZE(bmi160_nvm_reg),
- .gyr_off_reg = BMI160_OFFSET_GYR70,
- .acc_off_reg = BMI160_OFFSET_ACC70,
- .gyr98_off_reg = BMI160_OFFSET_EN_GYR98,
-};
-
-/** Check description in emul_bmi.h */
-const struct bmi_emul_type_data *get_bmi160_emul_type_data(void)
-{
- return &bmi160_emul;
-}
diff --git a/zephyr/emul/emul_bmi260.c b/zephyr/emul/emul_bmi260.c
deleted file mode 100644
index 235b1e219e..0000000000
--- a/zephyr/emul/emul_bmi260.c
+++ /dev/null
@@ -1,571 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT zephyr_bmi
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <logging/log.h>
-LOG_MODULE_REGISTER(emul_bmi260);
-
-#include <device.h>
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-#include "emul/emul_bmi.h"
-
-#include "driver/accelgyro_bmi260.h"
-#include "driver/accelgyro_bmi_common.h"
-
-/** Mask reserved bits in each register of BMI260 */
-static const uint8_t bmi_emul_260_rsvd_mask[] = {
- [BMI260_CHIP_ID] = 0x00,
- [0x01] = 0xff, /* Reserved */
- [BMI260_ERR_REG] = 0x20,
- [BMI260_STATUS] = 0x0b,
- [BMI260_AUX_X_L_G] = 0x00,
- [BMI260_AUX_X_H_G] = 0x00,
- [BMI260_AUX_Y_L_G] = 0x00,
- [BMI260_AUX_Y_H_G] = 0x00,
- [BMI260_AUX_Z_L_G] = 0x00,
- [BMI260_AUX_Z_H_G] = 0x00,
- [BMI260_AUX_R_L_G] = 0x00,
- [BMI260_AUX_R_H_G] = 0x00,
- [BMI260_ACC_X_L_G] = 0x00,
- [BMI260_ACC_X_H_G] = 0x00,
- [BMI260_ACC_Y_L_G] = 0x00,
- [BMI260_ACC_Y_H_G] = 0x00,
- [BMI260_ACC_Z_L_G] = 0x00,
- [BMI260_ACC_Z_H_G] = 0x00,
- [BMI260_GYR_X_L_G] = 0x00,
- [BMI260_GYR_X_H_G] = 0x00,
- [BMI260_GYR_Y_L_G] = 0x00,
- [BMI260_GYR_Y_H_G] = 0x00,
- [BMI260_GYR_Z_L_G] = 0x00,
- [BMI260_GYR_Z_H_G] = 0x00,
- [BMI260_SENSORTIME_0] = 0x00,
- [BMI260_SENSORTIME_1] = 0x00,
- [BMI260_SENSORTIME_2] = 0x00,
- [BMI260_EVENT] = 0xe2,
- [BMI260_INT_STATUS_0] = 0x00,
- [BMI260_INT_STATUS_1] = 0x18,
- [BMI260_SC_OUT_0] = 0x00,
- [BMI260_SC_OUT_1] = 0x00,
- [BMI260_ORIENT_ACT] = 0xe0,
- [BMI260_INTERNAL_STATUS] = 0x00,
- [BMI260_TEMPERATURE_0] = 0x00,
- [BMI260_TEMPERATURE_1] = 0x00,
- [BMI260_FIFO_LENGTH_0] = 0x00,
- [BMI260_FIFO_LENGTH_1] = 0xc0,
- [BMI160_FIFO_DATA] = 0x00,
- [0x27 ... 0x2e] = 0xff, /* Reserved */
- [BMI260_FEAT_PAGE] = 0xf8,
- [0x30 ... 0x3f] = 0x00, /* Features */
- [BMI260_ACC_CONF] = 0x00,
- [BMI260_ACC_RANGE] = 0xfc,
- [BMI260_GYR_CONF] = 0x00,
- [BMI260_GYR_RANGE] = 0xf0,
- [BMI260_AUX_CONF] = 0x00,
- [BMI260_FIFO_DOWNS] = 0x00,
- [BMI260_FIFO_WTM_0] = 0x00,
- [BMI260_FIFO_WTM_1] = 0xe0,
- [BMI260_FIFO_CONFIG_0] = 0xfc,
- [BMI260_FIFO_CONFIG_1] = 0x00,
- [BMI260_SATURATION] = 0xc0,
- [BMI260_AUX_DEV_ID] = 0x01,
- [BMI260_AUX_IF_CONF] = 0x30,
- [BMI260_AUX_RD_ADDR] = 0x00,
- [BMI260_AUX_WR_ADDR] = 0x00,
- [BMI260_AUX_WR_DATA] = 0x00,
- [0x50 ... 0x51] = 0xff, /* Reserved */
- [BMI260_ERR_REG_MSK] = 0x20,
- [BMI260_INT1_IO_CTRL] = 0xe1,
- [BMI260_INT2_IO_CTRL] = 0xe1,
- [BMI260_INT_LATCH] = 0xfe,
- [BMI260_INT1_MAP_FEAT] = 0x00,
- [BMI260_INT2_MAP_FEAT] = 0x00,
- [BMI260_INT_MAP_DATA] = 0x00,
- [BMI260_INIT_CTRL] = 0x00,
- [0x5a] = 0xff, /* Reserved */
- [BMI260_INIT_ADDR_0] = 0xf0,
- [BMI260_INIT_ADDR_1] = 0x00,
- [0x5d] = 0xff, /* Reserved */
- [BMI260_INIT_DATA] = 0x00,
- [BMI260_INTERNAL_ERROR] = 0xe9,
- [0x60 ... 0x67] = 0xff, /* Reserved */
- [BMI260_AUX_IF_TRIM] = 0xf8,
- [BMI260_GYR_CRT_CONF] = 0xf2,
- [BMI260_NVM_CONF] = 0xfd,
- [BMI260_IF_CONF] = 0xcc,
- [BMI260_DRV] = 0x00,
- [BMI260_ACC_SELF_TEST] = 0xf2,
- [BMI260_GYR_SELF_TEST_AXES] = 0xf0,
- [0x6f] = 0xff, /* Reserved */
- [BMI260_NV_CONF] = 0xf0,
- [BMI260_OFFSET_ACC70] = 0x00,
- [BMI260_OFFSET_ACC70 + 1] = 0x00,
- [BMI260_OFFSET_ACC70 + 2] = 0x00,
- [BMI260_OFFSET_GYR70] = 0x00,
- [BMI260_OFFSET_GYR70 + 1] = 0x00,
- [BMI260_OFFSET_GYR70 + 2] = 0x00,
- [BMI160_OFFSET_EN_GYR98] = 0x00,
- [0x78 ... 0x7b] = 0xff, /* Reserved */
- [BMI260_PWR_CONF] = 0xf8,
- [BMI260_PWR_CTRL] = 0xf0,
- [BMI260_CMD_REG] = 0x00,
-};
-
-/**
- * @brief Reset registers to default values and restore registers backed by NVM
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- */
-static void bmi260_emul_reset(uint8_t *regs, struct i2c_emul *emul)
-{
- bool tag_time;
- bool header;
-
- regs[BMI260_CHIP_ID] = 0x27;
- regs[BMI260_ERR_REG] = 0x00;
- regs[BMI260_STATUS] = 0x10;
- regs[BMI260_AUX_X_L_G] = 0x00;
- regs[BMI260_AUX_X_H_G] = 0x00;
- regs[BMI260_AUX_Y_L_G] = 0x00;
- regs[BMI260_AUX_Y_H_G] = 0x00;
- regs[BMI260_AUX_Z_L_G] = 0x00;
- regs[BMI260_AUX_Z_H_G] = 0x00;
- regs[BMI260_AUX_R_L_G] = 0x00;
- regs[BMI260_AUX_R_H_G] = 0x00;
- regs[BMI260_ACC_X_L_G] = 0x00;
- regs[BMI260_ACC_X_H_G] = 0x00;
- regs[BMI260_ACC_Y_L_G] = 0x00;
- regs[BMI260_ACC_Y_H_G] = 0x00;
- regs[BMI260_ACC_Z_L_G] = 0x00;
- regs[BMI260_ACC_Z_H_G] = 0x00;
- regs[BMI260_GYR_X_L_G] = 0x00;
- regs[BMI260_GYR_X_H_G] = 0x00;
- regs[BMI260_GYR_Y_L_G] = 0x00;
- regs[BMI260_GYR_Y_H_G] = 0x00;
- regs[BMI260_GYR_Z_L_G] = 0x00;
- regs[BMI260_GYR_Z_H_G] = 0x00;
- regs[BMI260_SENSORTIME_0] = 0x00;
- regs[BMI260_SENSORTIME_1] = 0x00;
- regs[BMI260_SENSORTIME_2] = 0x00;
- regs[BMI260_EVENT] = 0x01;
- regs[BMI260_INT_STATUS_0] = 0x00;
- regs[BMI260_INT_STATUS_1] = 0x00;
- regs[BMI260_SC_OUT_0] = 0x00;
- regs[BMI260_SC_OUT_1] = 0x00;
- regs[BMI260_ORIENT_ACT] = 0x00;
- regs[BMI260_INTERNAL_STATUS] = 0x00;
- regs[BMI260_TEMPERATURE_0] = 0x00;
- regs[BMI260_TEMPERATURE_1] = 0x80;
- regs[BMI260_FIFO_LENGTH_0] = 0x00;
- regs[BMI260_FIFO_LENGTH_1] = 0x00;
- regs[BMI160_FIFO_DATA] = 0x00;
- regs[BMI260_FEAT_PAGE] = 0x00;
- regs[BMI260_ACC_CONF] = 0xa8;
- regs[BMI260_ACC_RANGE] = 0x02;
- regs[BMI260_GYR_CONF] = 0xa9;
- regs[BMI260_GYR_RANGE] = 0x00;
- regs[BMI260_AUX_CONF] = 0x46;
- regs[BMI260_FIFO_DOWNS] = 0x88;
- regs[BMI260_FIFO_WTM_0] = 0x00;
- regs[BMI260_FIFO_WTM_1] = 0x02;
- regs[BMI260_FIFO_CONFIG_0] = 0x02;
- regs[BMI260_FIFO_CONFIG_1] = 0x10;
- regs[BMI260_SATURATION] = 0x00;
- regs[BMI260_AUX_DEV_ID] = 0x20;
- regs[BMI260_AUX_IF_CONF] = 0x83;
- regs[BMI260_AUX_RD_ADDR] = 0x42;
- regs[BMI260_AUX_WR_ADDR] = 0x4c;
- regs[BMI260_AUX_WR_DATA] = 0x02;
- regs[BMI260_ERR_REG_MSK] = 0x00;
- regs[BMI260_INT1_IO_CTRL] = 0x00;
- regs[BMI260_INT2_IO_CTRL] = 0x00;
- regs[BMI260_INT_LATCH] = 0x00;
- regs[BMI260_INT1_MAP_FEAT] = 0x00;
- regs[BMI260_INT2_MAP_FEAT] = 0x00;
- regs[BMI260_INT_MAP_DATA] = 0x00;
- regs[BMI260_INIT_CTRL] = 0x00;
- regs[BMI260_INIT_ADDR_0] = 0x00;
- regs[BMI260_INIT_ADDR_1] = 0x00;
- regs[BMI260_INIT_DATA] = 0x00;
- regs[BMI260_INTERNAL_ERROR] = 0x00;
- regs[BMI260_AUX_IF_TRIM] = 0x01;
- regs[BMI260_GYR_CRT_CONF] = 0x00;
- regs[BMI260_NVM_CONF] = 0x00;
- regs[BMI260_IF_CONF] = 0x00;
- regs[BMI260_DRV] = 0xff;
- regs[BMI260_ACC_SELF_TEST] = 0x00;
- regs[BMI260_GYR_SELF_TEST_AXES] = 0x00;
- regs[BMI260_PWR_CONF] = 0x03;
- regs[BMI260_PWR_CTRL] = 0x00;
- regs[BMI260_CMD_REG] = 0x00;
-
- /* Call generic reset */
- tag_time = regs[BMI260_FIFO_CONFIG_0] & BMI260_FIFO_TIME_EN;
- header = regs[BMI260_FIFO_CONFIG_1] & BMI260_FIFO_HEADER_EN;
- bmi_emul_reset_common(emul, tag_time, header);
-}
-
-/**
- * @brief Convert range in format of ACC_RANGE register to number of bits
- * that should be shifted right to obtain 16 bit reported accelerometer
- * value from internal 32 bit value
- *
- * @param range Value of ACC_RANGE register
- *
- * @return shift Number of LSB that should be ignored from internal
- * accelerometer value
- */
-static int bmi260_emul_acc_range_to_shift(uint8_t range)
-{
- switch (range & 0xf) {
- case BMI260_GSEL_2G:
- return 0;
- case BMI260_GSEL_4G:
- return 1;
- case BMI260_GSEL_8G:
- return 2;
- case BMI260_GSEL_16G:
- return 3;
- default:
- return 0;
- }
-}
-
-/**
- * @brief Convert range in format of GYR_RANGE register to number of bits
- * that should be shifted right to obtain 16 bit reported gyroscope
- * value from internal 32 bit value
- *
- * @param range Value of GYR_RANGE register
- *
- * @return shift Number of LSB that should be ignored from internal
- * gyroscope value
- */
-static int bmi260_emul_gyr_range_to_shift(uint8_t range)
-{
- switch (range & 0x7) {
- case BMI260_DPS_SEL_2000:
- return 4;
- case BMI260_DPS_SEL_1000:
- return 3;
- case BMI260_DPS_SEL_500:
- return 2;
- case BMI260_DPS_SEL_250:
- return 1;
- case BMI260_DPS_SEL_125:
- return 0;
- default:
- return 0;
- }
-}
-
-/**
- * @brief Execute first part of command. Emulate state of device which is
- * during handling command (status bits etc). This function save time
- * on which command should end.
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- * @param cmd Command that is starting
- *
- * @return 0 on success
- * @return -EIO on failure
- */
-static int bmi260_emul_start_cmd(uint8_t *regs, struct i2c_emul *emul, int cmd)
-{
- int time;
-
- switch (cmd) {
- case BMI260_CMD_SOFT_RESET:
- time = 1;
- break;
- case BMI260_CMD_FIFO_FLUSH:
- time = 0;
- break;
- default:
- LOG_ERR("Unknown command 0x%x", cmd);
- return -EIO;
- }
-
- regs[BMI260_CMD_REG] = cmd;
- bmi_emul_set_cmd_end_time(emul, time);
-
- return 0;
-}
-
-/**
- * @brief Emulate end of ongoing command.
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- */
-static void bmi260_emul_end_cmd(uint8_t *regs, struct i2c_emul *emul)
-{
- bool tag_time;
- bool header;
- int cmd;
-
- cmd = regs[BMI260_CMD_REG];
- regs[BMI260_CMD_REG] = 0;
- tag_time = regs[BMI260_FIFO_CONFIG_0] & BMI260_FIFO_TIME_EN;
- header = regs[BMI260_FIFO_CONFIG_1] & BMI260_FIFO_HEADER_EN;
-
- switch (cmd) {
- case BMI160_CMD_SOFT_RESET:
- bmi260_emul_reset(regs, emul);
- break;
- case BMI160_CMD_FIFO_FLUSH:
- bmi_emul_flush_fifo(emul, tag_time, header);
- break;
- }
-}
-
-/**
- * @brief Get currently accessed register. It is first register plus number of
- * handled bytes for all registers except BMI260_FIFO_DATA and
- * BMI260_INIT_DATA for which address incrementation is disabled.
- *
- * @param emul Pointer to BMI emulator
- * @param reg First byte of last write message
- * @param bytes Number of bytes already handled from current message
- * @param read If currently handled is read message
- *
- * @return Currently accessed register
- */
-static int bmi260_emul_access_reg(struct i2c_emul *emul, int reg, int byte,
- bool read)
-{
- /* Ignore first byte which sets starting register */
- if (!read) {
- byte -= 1;
- }
-
- /*
- * If register is FIFO data, then read data from FIFO.
- * Init data is also block, but it is not implemented in emulator.
- * Else block read access subsequent registers.
- */
- if (reg <= BMI260_FIFO_DATA && reg + byte >= BMI260_FIFO_DATA) {
- return BMI260_FIFO_DATA;
- } else if (reg <= BMI260_INIT_DATA &&
- reg + byte >= BMI260_INIT_DATA) {
- return BMI260_INIT_DATA;
- }
-
- return reg + byte;
-}
-
-/**
- * @brief BMI260 specific write function. It handle block writes. Init data
- * register is trap register, so after reaching it, register address
- * is not increased on block writes. Check if read only register is not
- * accessed. Before writing value, ongoing command is finished if
- * possible. Write to CMD register is handled by BMI260 specific
- * function. On changing of FIFO header/headerless mode or
- * enabling/disabling sensor in headerless mode FIFO is flushed.
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- * @param reg Register address that is accessed
- * @param byte Number of handled bytes in this write command
- * @param val Value that is being written
- *
- * @return 0 on success
- * @return BMI_EMUL_ACCESS_E on RO register access
- * @return -EIO on error
- */
-static int bmi260_emul_handle_write(uint8_t *regs, struct i2c_emul *emul,
- int reg, int byte, uint8_t val)
-{
- uint8_t mask;
- bool tag_time;
- bool header;
-
- reg = bmi260_emul_access_reg(emul, reg, byte, false /* = read */);
-
- if (reg <= BMI260_FIFO_DATA || reg == BMI260_GYR_SELF_TEST_AXES ||
- reg == BMI260_INTERNAL_ERROR || reg == BMI260_SATURATION) {
- return BMI_EMUL_ACCESS_E;
- }
-
-
- /* Stop on going command if required */
- if (regs[BMI260_CMD_REG] != 0 && bmi_emul_is_cmd_end(emul)) {
- bmi260_emul_end_cmd(regs, emul);
- }
-
- tag_time = regs[BMI260_FIFO_CONFIG_0] & BMI260_FIFO_TIME_EN;
- header = regs[BMI260_FIFO_CONFIG_1] & BMI260_FIFO_HEADER_EN;
-
- switch (reg) {
- case BMI260_CMD_REG:
- if (regs[BMI260_CMD_REG] != 0) {
- LOG_ERR("Issued command before previous end");
- return -EIO;
- }
-
- return bmi260_emul_start_cmd(regs, emul, val);
- case BMI260_FIFO_CONFIG_1:
- /*
- * Clear FIFO on transition between headerless and
- * header mode
- */
- if (!!(val & BMI260_FIFO_HEADER_EN) != header) {
- bmi_emul_flush_fifo(emul, tag_time, header);
- }
- break;
- case BMI260_PWR_CTRL:
- /*
- * Clear FIFO on enabling/disabling sensors in headerless
- * mode
- */
- mask = BMI260_AUX_EN & BMI260_GYR_EN & BMI260_ACC_EN;
- if ((val & mask) != (regs[BMI260_PWR_CTRL] & mask) && !header) {
- bmi_emul_flush_fifo(emul, tag_time, header);
- }
- break;
- }
-
- return 0;
-}
-
-/**
- * @brief BMI260 specific read function. It handle block reads. FIFO data
- * register and init data register are trap registers, so
- * after reaching it, register address is not increased on block reads.
- * Before reading value, ongoing command is finished if possible.
- * Read of sensor data traps current emulator state in registers.
- * Read of FIFO length and FIFO data triggers default BMI functions.
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- * @param reg Register address that is accessed
- * @param byte Byte which is accessed during block read
- * @param buf Pointer where read byte should be stored
- *
- * @return 0 on success
- * @return BMI_EMUL_ACCESS_E on WO register access
- * @return -EIO on other error
- */
-static int bmi260_emul_handle_read(uint8_t *regs, struct i2c_emul *emul,
- int reg, int byte, char *buf)
-{
- uint16_t fifo_len;
- bool acc_off_en;
- bool gyr_off_en;
- bool tag_time;
- bool header;
- int gyr_shift;
- int acc_shift;
- int fifo_byte;
-
- /* Get number of bytes readed from FIFO */
- fifo_byte = byte - (reg - BMI260_FIFO_DATA);
-
- reg = bmi260_emul_access_reg(emul, reg, byte, true /* = read */);
-
- if (reg == BMI260_CMD_REG) {
- *buf = 0;
-
- return BMI_EMUL_ACCESS_E;
- }
-
- /* Stop on going command if required */
- if (regs[BMI260_CMD_REG] != 0 && bmi_emul_is_cmd_end(emul)) {
- bmi260_emul_end_cmd(regs, emul);
- }
-
- tag_time = regs[BMI260_FIFO_CONFIG_0] & BMI260_FIFO_TIME_EN;
- header = regs[BMI260_FIFO_CONFIG_1] & BMI260_FIFO_HEADER_EN;
- acc_off_en = regs[BMI260_NV_CONF] & BMI260_ACC_OFFSET_EN;
- gyr_off_en = regs[BMI260_OFFSET_EN_GYR98] & BMI260_OFFSET_GYRO_EN;
- gyr_shift = bmi260_emul_gyr_range_to_shift(regs[BMI260_GYR_RANGE]);
- acc_shift = bmi260_emul_acc_range_to_shift(regs[BMI260_ACC_RANGE]);
-
- switch (reg) {
- case BMI260_GYR_X_L_G:
- case BMI260_GYR_X_H_G:
- case BMI260_GYR_Y_L_G:
- case BMI260_GYR_Y_H_G:
- case BMI260_GYR_Z_L_G:
- case BMI260_GYR_Z_H_G:
- case BMI260_ACC_X_L_G:
- case BMI260_ACC_X_H_G:
- case BMI260_ACC_Y_L_G:
- case BMI260_ACC_Y_H_G:
- case BMI260_ACC_Z_L_G:
- case BMI260_ACC_Z_H_G:
- case BMI260_SENSORTIME_0:
- case BMI260_SENSORTIME_1:
- case BMI260_SENSORTIME_2:
- /*
- * Snapshot of current emulator state is created on data read
- * and shouldn't be changed until next I2C operation
- */
- if (byte == 0) {
- bmi_emul_state_to_reg(emul, acc_shift, gyr_shift,
- BMI260_ACC_X_L_G,
- BMI260_GYR_X_L_G,
- BMI260_SENSORTIME_0,
- acc_off_en, gyr_off_en);
- }
- break;
- case BMI260_FIFO_LENGTH_0:
- case BMI260_FIFO_LENGTH_1:
- if (byte == 0) {
- fifo_len = bmi_emul_fifo_len(emul, tag_time, header);
- regs[BMI260_FIFO_LENGTH_0] = fifo_len & 0xff;
- regs[BMI260_FIFO_LENGTH_1] = (fifo_len >> 8) & 0x7;
- }
- break;
- case BMI260_FIFO_DATA:
- regs[reg] = bmi_emul_get_fifo_data(emul, fifo_byte, tag_time,
- header, acc_shift,
- gyr_shift);
- break;
- }
-
- *buf = regs[reg];
-
- return 0;
-}
-
-/** Registers backed in NVM by BMI260 */
-const int bmi260_nvm_reg[] = {BMI260_AUX_IF_TRIM,
- BMI260_NV_CONF,
- BMI260_DRV,
- BMI260_OFFSET_ACC70,
- BMI260_OFFSET_ACC70 + 1,
- BMI260_OFFSET_ACC70 + 2,
- BMI260_OFFSET_GYR70,
- BMI260_OFFSET_GYR70 + 1,
- BMI260_OFFSET_GYR70 + 2,
- BMI260_OFFSET_EN_GYR98};
-
-/** Confguration of BMI260 */
-struct bmi_emul_type_data bmi260_emul = {
- .sensortime_follow_config_frame = true,
- .handle_write = bmi260_emul_handle_write,
- .handle_read = bmi260_emul_handle_read,
- .access_reg = bmi260_emul_access_reg,
- .reset = bmi260_emul_reset,
- .rsvd_mask = bmi_emul_260_rsvd_mask,
- .nvm_reg = bmi260_nvm_reg,
- .nvm_len = ARRAY_SIZE(bmi260_nvm_reg),
- .gyr_off_reg = BMI260_OFFSET_GYR70,
- .acc_off_reg = BMI260_OFFSET_ACC70,
- .gyr98_off_reg = BMI260_OFFSET_EN_GYR98,
-};
-
-/** Check description in emul_bmi.h */
-const struct bmi_emul_type_data *get_bmi260_emul_type_data(void)
-{
- return &bmi260_emul;
-}
diff --git a/zephyr/emul/emul_common_i2c.c b/zephyr/emul/emul_common_i2c.c
deleted file mode 100644
index bd811f1424..0000000000
--- a/zephyr/emul/emul_common_i2c.c
+++ /dev/null
@@ -1,432 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <logging/log.h>
-LOG_MODULE_REGISTER(emul_common_i2c);
-
-#include <device.h>
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-#include "emul/emul_common_i2c.h"
-
-/** Check description in emul_common_i2c.h */
-int i2c_common_emul_lock_data(struct i2c_emul *emul, k_timeout_t timeout)
-{
- struct i2c_common_emul_data *data;
-
- data = CONTAINER_OF(emul, struct i2c_common_emul_data, emul);
-
- return k_mutex_lock(&data->data_mtx, timeout);
-}
-
-/** Check description in emul_common_i2c.h */
-int i2c_common_emul_unlock_data(struct i2c_emul *emul)
-{
- struct i2c_common_emul_data *data;
-
- data = CONTAINER_OF(emul, struct i2c_common_emul_data, emul);
-
- return k_mutex_unlock(&data->data_mtx);
-}
-
-/** Check description in emul_common_i2c.h */
-void i2c_common_emul_set_write_func(struct i2c_emul *emul,
- i2c_common_emul_write_func func, void *data)
-{
- struct i2c_common_emul_data *emul_data;
-
- emul_data = CONTAINER_OF(emul, struct i2c_common_emul_data, emul);
- emul_data->write_func = func;
- emul_data->write_func_data = data;
-}
-
-/** Check description in emul_common_i2c.h */
-void i2c_common_emul_set_read_func(struct i2c_emul *emul,
- i2c_common_emul_read_func func, void *data)
-{
- struct i2c_common_emul_data *emul_data;
-
- emul_data = CONTAINER_OF(emul, struct i2c_common_emul_data, emul);
- emul_data->read_func = func;
- emul_data->read_func_data = data;
-}
-
-/** Check description in emul_common_i2c.h */
-void i2c_common_emul_set_read_fail_reg(struct i2c_emul *emul, int reg)
-{
- struct i2c_common_emul_data *data;
-
- data = CONTAINER_OF(emul, struct i2c_common_emul_data, emul);
- data->read_fail_reg = reg;
-}
-
-/** Check description in emul_common_i2c.h */
-void i2c_common_emul_set_write_fail_reg(struct i2c_emul *emul, int reg)
-{
- struct i2c_common_emul_data *data;
-
- data = CONTAINER_OF(emul, struct i2c_common_emul_data, emul);
- data->write_fail_reg = reg;
-}
-
-/**
- * @brief Call start_write emulator callback if set. It handles first byte
- * of I2C write message.
- *
- * @param emul Pointer to emulator
- * @param data Pointer to emulator data
- *
- * @retval start_write emulator callback return code
- */
-static int i2c_common_emul_start_write(struct i2c_emul *emul,
- struct i2c_common_emul_data *data)
-{
- int ret = 0;
-
- data->msg_byte = 0;
-
- if (data->start_write) {
- k_mutex_lock(&data->data_mtx, K_FOREVER);
- ret = data->start_write(emul, data->cur_reg);
- k_mutex_unlock(&data->data_mtx);
- }
-
- return ret;
-}
-
-/**
- * @brief Call finish_write emulator callback if set. It is called after last
- * byte of I2C write message.
- *
- * @param emul Pointer to emulator
- * @param data Pointer to emulator data
- *
- * @retval finish_write emulator callback return code
- */
-static int i2c_common_emul_finish_write(struct i2c_emul *emul,
- struct i2c_common_emul_data *data)
-{
- int ret = 0;
-
- if (data->finish_write) {
- k_mutex_lock(&data->data_mtx, K_FOREVER);
- ret = data->finish_write(emul, data->cur_reg, data->msg_byte);
- k_mutex_unlock(&data->data_mtx);
- }
-
- return ret;
-}
-
-/**
- * @brief Call start_read emulator callback if set. It prepares emulator at
- * the beginning of I2C read message.
- *
- * @param emul Pointer to emulator
- * @param data Pointer to emulator data
- *
- * @retval start_read emulator callback return code
- */
-static int i2c_common_emul_start_read(struct i2c_emul *emul,
- struct i2c_common_emul_data *data)
-{
- int ret = 0;
-
- data->msg_byte = 0;
-
- if (data->start_read) {
- k_mutex_lock(&data->data_mtx, K_FOREVER);
- ret = data->start_read(emul, data->cur_reg);
- k_mutex_unlock(&data->data_mtx);
- }
-
- return ret;
-}
-
-/**
- * @brief Call finish_read emulator callback if set. It is called after last
- * byte of I2C read message.
- *
- * @param emul Pointer to emulator
- * @param data Pointer to emulator data
- *
- * @retval finish_read emulator callback return code
- */
-static int i2c_common_emul_finish_read(struct i2c_emul *emul,
- struct i2c_common_emul_data *data)
-{
- int ret = 0;
-
- if (data->finish_read) {
- k_mutex_lock(&data->data_mtx, K_FOREVER);
- ret = data->finish_read(emul, data->cur_reg, data->msg_byte);
- k_mutex_unlock(&data->data_mtx);
- }
-
- return ret;
-}
-
-/**
- * @brief Handle byte from I2C write message. First custom user handler is
- * called (if set). Next accessed register is compared with selected
- * by user fail register. Lastly, specific I2C device emulator handler
- * is called.
- *
- * @param emul Pointer to emulator
- * @param data Pointer to emulator data
- * @param val Value of current byte
- *
- * @retval 0 If successful
- * @retval -EIO General input / output error
- */
-static int i2c_common_emul_write_byte(struct i2c_emul *emul,
- struct i2c_common_emul_data *data,
- uint8_t val)
-{
- int reg, ret;
-
- /* Custom user handler */
- if (data->write_func) {
- ret = data->write_func(emul, 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(emul, data->cur_reg, data->msg_byte,
- false /* = read */);
- } else {
- /* Ignore first (register address) byte */
- reg = data->cur_reg + data->msg_byte - 1;
- }
-
- if (data->write_fail_reg == reg ||
- data->write_fail_reg == I2C_COMMON_EMUL_FAIL_ALL_REG) {
- return -EIO;
- }
- /* Emulator handler */
- if (data->write_byte) {
- k_mutex_lock(&data->data_mtx, K_FOREVER);
- ret = data->write_byte(emul, data->cur_reg, val,
- data->msg_byte);
- k_mutex_unlock(&data->data_mtx);
- if (ret) {
- return -EIO;
- }
- }
-
- return 0;
-}
-
-/**
- * @brief Handle byte from I2C read message. First custom user handler is
- * called (if set). Next accessed register is compared with selected
- * by user fail register. Lastly, specific I2C device emulator handler
- * is called.
- *
- * @param emul Pointer to emulator
- * @param data Pointer to emulator data
- * @param val Pointer to buffer where current response byte should be stored
- *
- * @retval 0 If successful
- * @retval -EIO General input / output error
- */
-static int i2c_common_emul_read_byte(struct i2c_emul *emul,
- struct i2c_common_emul_data *data,
- uint8_t *val)
-{
- int reg, ret;
-
- /* Custom user handler */
- if (data->read_func) {
- ret = data->read_func(emul, 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(emul, data->cur_reg, data->msg_byte,
- true /* = read */);
- } else {
- reg = data->cur_reg + data->msg_byte;
- }
-
- if (data->read_fail_reg == reg ||
- data->read_fail_reg == I2C_COMMON_EMUL_FAIL_ALL_REG) {
- return -EIO;
- }
- /* Emulator handler */
- if (data->read_byte) {
- k_mutex_lock(&data->data_mtx, K_FOREVER);
- ret = data->read_byte(emul, data->cur_reg, val, data->msg_byte);
- k_mutex_unlock(&data->data_mtx);
- if (ret) {
- return -EIO;
- }
- }
-
- return 0;
-}
-
-/** Check description in emul_common_i2c.h */
-int i2c_common_emul_transfer(struct i2c_emul *emul, struct i2c_msg *msgs,
- int num_msgs, int addr)
-{
- const struct i2c_common_emul_cfg *cfg;
- struct i2c_common_emul_data *data;
- bool read, stop;
- int ret, i;
-
- data = CONTAINER_OF(emul, struct i2c_common_emul_data, emul);
- cfg = data->cfg;
-
- if (cfg->addr != addr) {
- LOG_ERR("Address mismatch, expected %02x, got %02x", cfg->addr,
- addr);
- return -EIO;
- }
-
- i2c_dump_msgs(cfg->dev_label, msgs, num_msgs, addr);
-
- for (; num_msgs > 0; num_msgs--, msgs++) {
- read = msgs->flags & I2C_MSG_READ;
- stop = msgs->flags & I2C_MSG_STOP;
-
- switch (data->msg_state) {
- case I2C_COMMON_EMUL_IN_WRITE:
- if (read) {
- data->msg_state = I2C_COMMON_EMUL_NONE_MSG;
- ret = i2c_common_emul_finish_write(emul, data);
- if (ret) {
- return ret;
- }
- ret = i2c_common_emul_start_read(emul, data);
- if (ret) {
- return ret;
- }
- }
- break;
- case I2C_COMMON_EMUL_IN_READ:
- if (!read) {
- data->msg_state = I2C_COMMON_EMUL_NONE_MSG;
- ret = i2c_common_emul_finish_read(emul, data);
- if (ret) {
- return ret;
- }
- /* Wait for write message with acctual data */
- if (msgs->len == 0) {
- continue;
- }
- /* Dispatch command/register address */
- data->cur_reg = msgs->buf[0];
- ret = i2c_common_emul_start_write(emul, data);
- if (ret) {
- return ret;
- }
- }
- break;
- case I2C_COMMON_EMUL_NONE_MSG:
- if (read) {
- ret = i2c_common_emul_start_read(emul, data);
- if (ret) {
- return ret;
- }
- } else {
- /* Wait for write message with acctual data */
- if (msgs->len == 0) {
- continue;
- }
- /* Dispatch command/register address */
- data->cur_reg = msgs->buf[0];
- ret = i2c_common_emul_start_write(emul, data);
- if (ret) {
- return ret;
- }
- }
- }
-
- data->msg_state = read ? I2C_COMMON_EMUL_IN_READ
- : I2C_COMMON_EMUL_IN_WRITE;
-
- if (stop) {
- data->msg_state = I2C_COMMON_EMUL_NONE_MSG;
- }
-
- if (!read) {
- /*
- * All current emulators use first byte of write message
- * as command/register address for following write bytes
- * or read message. Skip first byte which was dispatched
- * already.
- */
- if (data->msg_byte == 0) {
- data->msg_byte = 1;
- i = 1;
- } else {
- i = 0;
- }
- /* Dispatch write command */
- for (; i < msgs->len; i++, data->msg_byte++) {
- ret = i2c_common_emul_write_byte(emul, data,
- msgs->buf[i]);
- if (ret) {
- return ret;
- }
- }
- /* Finish write command */
- if (stop) {
- ret = i2c_common_emul_finish_write(emul, data);
- if (ret) {
- return ret;
- }
- }
- } else {
- /* Dispatch read command */
- for (i = 0; i < msgs->len; i++, data->msg_byte++) {
- ret = i2c_common_emul_read_byte(emul, data,
- &(msgs->buf[i]));
- if (ret) {
- return ret;
- }
- }
-
- /* Finish read command */
- if (stop) {
- ret = i2c_common_emul_finish_read(emul, data);
- if (ret) {
- return ret;
- }
- }
- }
- }
-
- return 0;
-}
-
-/** Check description in emul_common_i2c.h */
-void i2c_common_emul_init(struct i2c_common_emul_data *data)
-{
- data->msg_state = I2C_COMMON_EMUL_NONE_MSG;
- data->msg_byte = 0;
- data->cur_reg = 0;
-
- data->write_func = NULL;
- data->read_func = NULL;
-
- data->write_fail_reg = I2C_COMMON_EMUL_NO_FAIL_REG;
- data->read_fail_reg = I2C_COMMON_EMUL_NO_FAIL_REG;
-
- k_mutex_init(&data->data_mtx);
-}
diff --git a/zephyr/emul/emul_lis2dw12.c b/zephyr/emul/emul_lis2dw12.c
deleted file mode 100644
index 6fa8b31cc9..0000000000
--- a/zephyr/emul/emul_lis2dw12.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT cros_lis2dw12_emul
-
-#include <device.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-#include <emul.h>
-#include <errno.h>
-#include <sys/__assert.h>
-
-#include "driver/accel_lis2dw12.h"
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_lis2dw12.h"
-#include "i2c.h"
-
-#include <logging/log.h>
-LOG_MODULE_REGISTER(lis2dw12_emul, CONFIG_LIS2DW12_EMUL_LOG_LEVEL);
-
-#define LIS2DW12_DATA_FROM_I2C_EMUL(_emul) \
- CONTAINER_OF(CONTAINER_OF(_emul, struct i2c_common_emul_data, emul), \
- struct lis2dw12_emul_data, common)
-
-struct lis2dw12_emul_data {
- /** Common I2C data */
- struct i2c_common_emul_data common;
- /** Emulated who-am-i register */
- uint8_t who_am_i_reg;
- /** Emulated ctrl2 register */
- uint8_t ctrl2_reg;
- /** Soft reset count */
- uint32_t soft_reset_count;
-};
-
-struct lis2dw12_emul_cfg {
- /** Common I2C config */
- struct i2c_common_emul_cfg common;
-};
-
-struct i2c_emul *lis2dw12_emul_to_i2c_emul(const struct emul *emul)
-{
- struct lis2dw12_emul_data *data = emul->data;
-
- return &(data->common.emul);
-}
-
-void lis2dw12_emul_reset(const struct emul *emul)
-{
- struct lis2dw12_emul_data *data = emul->data;
- struct i2c_emul *i2c_emul = lis2dw12_emul_to_i2c_emul(emul);
-
- i2c_common_emul_set_read_fail_reg(i2c_emul,
- I2C_COMMON_EMUL_NO_FAIL_REG);
- i2c_common_emul_set_write_fail_reg(i2c_emul,
- I2C_COMMON_EMUL_NO_FAIL_REG);
- i2c_common_emul_set_read_func(i2c_emul, NULL, NULL);
- i2c_common_emul_set_write_func(i2c_emul, NULL, NULL);
- data->who_am_i_reg = LIS2DW12_WHO_AM_I;
- data->ctrl2_reg = 0;
- data->soft_reset_count = 0;
-}
-
-void lis2dw12_emul_set_who_am_i(const struct emul *emul, uint8_t who_am_i)
-{
- struct lis2dw12_emul_data *data = emul->data;
-
- data->who_am_i_reg = who_am_i;
-}
-
-uint32_t lis2dw12_emul_get_soft_reset_count(const struct emul *emul)
-{
- struct lis2dw12_emul_data *data = emul->data;
-
- return data->soft_reset_count;
-}
-
-static int lis2dw12_emul_read_byte(struct i2c_emul *emul, int reg, uint8_t *val,
- int bytes)
-{
- struct lis2dw12_emul_data *data = LIS2DW12_DATA_FROM_I2C_EMUL(emul);
-
- switch (reg) {
- case LIS2DW12_WHO_AM_I_REG:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->who_am_i_reg;
- break;
- case LIS2DW12_CTRL2_ADDR:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->ctrl2_reg;
- break;
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-static int lis2dw12_emul_write_byte(struct i2c_emul *emul, int reg, uint8_t val,
- int bytes)
-{
- struct lis2dw12_emul_data *data = LIS2DW12_DATA_FROM_I2C_EMUL(emul);
-
- switch (reg) {
- case LIS2DW12_WHO_AM_I_REG:
- LOG_ERR("Can't write to who-am-i register");
- return -EINVAL;
- case LIS2DW12_CTRL2_ADDR:
- __ASSERT_NO_MSG(bytes == 1);
- if ((val & LIS2DW12_SOFT_RESET_MASK) != 0) {
- /* Soft reset */
- data->soft_reset_count++;
- }
- data->ctrl2_reg = val & ~LIS2DW12_SOFT_RESET_MASK;
- break;
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-static struct i2c_emul_api lis2dw12_emul_api_i2c = {
- .transfer = i2c_common_emul_transfer,
-};
-
-static int emul_lis2dw12_init(const struct emul *emul,
- const struct device *parent)
-{
- const struct lis2dw12_emul_cfg *lis2dw12_cfg = emul->cfg;
- const struct i2c_common_emul_cfg *cfg = &(lis2dw12_cfg->common);
- struct lis2dw12_emul_data *data = emul->data;
-
- data->common.emul.api = &lis2dw12_emul_api_i2c;
- data->common.emul.addr = cfg->addr;
- data->common.emul.parent = emul;
- data->common.i2c = parent;
- data->common.cfg = cfg;
- i2c_common_emul_init(&data->common);
-
- return i2c_emul_register(parent, emul->dev_label, &data->common.emul);
-}
-
-#define INIT_LIS2DW12(n) \
- static struct lis2dw12_emul_data lis2dw12_emul_data_##n = { \
- .common = { \
- .write_byte = lis2dw12_emul_write_byte, \
- .read_byte = lis2dw12_emul_read_byte, \
- }, \
- }; \
- static const struct lis2dw12_emul_cfg lis2dw12_emul_cfg_##n = { \
- .common = { \
- .i2c_label = DT_INST_BUS_LABEL(n), \
- .dev_label = DT_INST_LABEL(n), \
- .addr = DT_INST_REG_ADDR(n), \
- }, \
- }; \
- EMUL_DEFINE(emul_lis2dw12_init, DT_DRV_INST(n), \
- &lis2dw12_emul_cfg_##n, &lis2dw12_emul_data_##n)
-
-DT_INST_FOREACH_STATUS_OKAY(INIT_LIS2DW12)
diff --git a/zephyr/emul/emul_ln9310.c b/zephyr/emul/emul_ln9310.c
deleted file mode 100644
index d4eaa8e38d..0000000000
--- a/zephyr/emul/emul_ln9310.c
+++ /dev/null
@@ -1,388 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT cros_ln9310_emul
-
-#include <device.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-#include <emul.h>
-#include <errno.h>
-#include <sys/__assert.h>
-
-#include "driver/ln9310.h"
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_ln9310.h"
-#include "i2c.h"
-
-#include <logging/log.h>
-LOG_MODULE_REGISTER(ln9310_emul, CONFIG_LN9310_EMUL_LOG_LEVEL);
-
-#define LN9310_DATA_FROM_I2C_EMUL(_emul) \
- CONTAINER_OF(CONTAINER_OF(_emul, struct i2c_common_emul_data, emul), \
- struct ln9310_emul_data, common)
-
-struct ln9310_emul_data {
- /** Common I2C data */
- struct i2c_common_emul_data common;
- /** The current emulated battery cell type */
- enum battery_cell_type battery_cell_type;
- /** Emulated INT1 MSK register */
- uint8_t int1_msk_reg;
- /** Emulated Lion control register */
- uint8_t lion_ctrl_reg;
- /** Emulated startup control register */
- uint8_t startup_ctrl_reg;
- /** Emulated BC STST B register */
- uint8_t bc_sts_b_reg;
- /** Emulated BC STST C register */
- uint8_t bc_sts_c_reg;
- /** Emulated cfg 0 register */
- uint8_t cfg_0_reg;
- /** Emulated cfg 4 register */
- uint8_t cfg_4_reg;
- /** Emulated cfg 5 register */
- uint8_t cfg_5_reg;
- /** Emulated power control register */
- uint8_t power_ctrl_reg;
- /** Emulated timer control register */
- uint8_t timer_ctrl_reg;
- /** Emulated lower bound (LB) control register */
- uint8_t lower_bound_ctrl_reg;
- /** Emulated spare 0 register */
- uint8_t spare_0_reg;
- /** Emulated swap control 0 register */
- uint8_t swap_ctrl_0_reg;
- /** Emulated swap control 1 register */
- uint8_t swap_ctrl_1_reg;
- /** Emulated swap control 2 register */
- uint8_t swap_ctrl_2_reg;
- /** Emulated swap control 3 register */
- uint8_t swap_ctrl_3_reg;
- /** Emulated track control register */
- uint8_t track_ctrl_reg;
- /** Emulated mode change register */
- uint8_t mode_change_reg;
- /** Emulated system control register */
- uint8_t sys_ctrl_reg;
-};
-
-static const struct emul *singleton;
-
-void ln9310_emul_set_context(const struct emul *emulator)
-{
- singleton = emulator;
-}
-
-void ln9310_emul_reset(const struct emul *emulator)
-{
- struct ln9310_emul_data *data = emulator->data;
-
- data->lion_ctrl_reg = 0;
- data->startup_ctrl_reg = 0;
- data->bc_sts_b_reg = 0;
- data->cfg_0_reg = 0;
- data->cfg_4_reg = 0;
- data->cfg_5_reg = 0;
- data->power_ctrl_reg = 0;
- data->timer_ctrl_reg = 0;
- data->lower_bound_ctrl_reg = 0;
- data->spare_0_reg = 0;
- data->swap_ctrl_0_reg = 0;
- data->swap_ctrl_1_reg = 0;
- data->swap_ctrl_2_reg = 0;
- data->swap_ctrl_3_reg = 0;
- data->track_ctrl_reg = 0;
- data->mode_change_reg = 0;
- data->sys_ctrl_reg = 0;
-}
-
-void ln9310_emul_set_battery_cell_type(const struct emul *emulator,
- enum battery_cell_type type)
-{
- struct ln9310_emul_data *data = emulator->data;
-
- data->battery_cell_type = type;
-}
-
-void ln9310_emul_set_version(const struct emul *emulator, int version)
-{
- struct ln9310_emul_data *data = emulator->data;
-
- data->bc_sts_c_reg |= version & LN9310_BC_STS_C_CHIP_REV_MASK;
-}
-
-void ln9310_emul_set_vin_gt_10v(const struct emul *emulator, bool is_gt_10v)
-{
- struct ln9310_emul_data *data = emulator->data;
-
- if (is_gt_10v)
- data->bc_sts_b_reg |= LN9310_BC_STS_B_INFET_OUT_SWITCH_OK;
- else
- data->bc_sts_b_reg &= ~LN9310_BC_STS_B_INFET_OUT_SWITCH_OK;
-}
-
-bool ln9310_emul_is_init(const struct emul *emulator)
-{
- struct ln9310_emul_data *data = emulator->data;
-
- return (data->int1_msk_reg & LN9310_INT1_MODE) == 0;
-}
-
-enum battery_cell_type board_get_battery_cell_type(void)
-{
- struct ln9310_emul_data *data = singleton->data;
-
- return data->battery_cell_type;
-}
-
-static struct i2c_emul_api ln9310_emul_api_i2c = {
- .transfer = i2c_common_emul_transfer,
-};
-
-static int ln9310_emul_start_write(struct i2c_emul *emul, int reg)
-{
- return 0;
-}
-
-static int ln9310_emul_finish_write(struct i2c_emul *emul, int reg, int bytes)
-{
- return 0;
-}
-
-static int ln9310_emul_write_byte(struct i2c_emul *emul, int reg, uint8_t val,
- int bytes)
-{
- struct ln9310_emul_data *data = LN9310_DATA_FROM_I2C_EMUL(emul);
-
- switch (reg) {
- case LN9310_REG_INT1_MSK:
- __ASSERT_NO_MSG(bytes == 1);
- data->int1_msk_reg = val;
- break;
- case LN9310_REG_STARTUP_CTRL:
- __ASSERT_NO_MSG(bytes == 1);
- data->startup_ctrl_reg = val;
- break;
- case LN9310_REG_LION_CTRL:
- __ASSERT_NO_MSG(bytes == 1);
- data->lion_ctrl_reg = val;
- break;
- case LN9310_REG_BC_STS_B:
- __ASSERT_NO_MSG(bytes == 1);
- data->bc_sts_b_reg = val;
- break;
- case LN9310_REG_BC_STS_C:
- LOG_ERR("Can't write to BC STS C register");
- return -EINVAL;
- case LN9310_REG_CFG_0:
- __ASSERT_NO_MSG(bytes == 1);
- data->cfg_0_reg = val;
- break;
- case LN9310_REG_CFG_4:
- __ASSERT_NO_MSG(bytes == 1);
- data->cfg_4_reg = val;
- break;
- case LN9310_REG_CFG_5:
- __ASSERT_NO_MSG(bytes == 1);
- data->cfg_5_reg = val;
- break;
- case LN9310_REG_PWR_CTRL:
- __ASSERT_NO_MSG(bytes == 1);
- data->power_ctrl_reg = val;
- break;
- case LN9310_REG_TIMER_CTRL:
- __ASSERT_NO_MSG(bytes == 1);
- data->timer_ctrl_reg = val;
- break;
- case LN9310_REG_LB_CTRL:
- __ASSERT_NO_MSG(bytes = 1);
- data->lower_bound_ctrl_reg = val;
- break;
- case LN9310_REG_SPARE_0:
- __ASSERT_NO_MSG(bytes == 1);
- data->spare_0_reg = val;
- break;
- case LN9310_REG_SWAP_CTRL_0:
- __ASSERT_NO_MSG(bytes == 1);
- data->swap_ctrl_0_reg = val;
- break;
- case LN9310_REG_SWAP_CTRL_1:
- __ASSERT_NO_MSG(bytes == 1);
- data->swap_ctrl_1_reg = val;
- break;
- case LN9310_REG_SWAP_CTRL_2:
- __ASSERT_NO_MSG(bytes == 1);
- data->swap_ctrl_2_reg = val;
- break;
- case LN9310_REG_SWAP_CTRL_3:
- __ASSERT_NO_MSG(bytes == 1);
- data->swap_ctrl_3_reg = val;
- break;
- case LN9310_REG_TRACK_CTRL:
- __ASSERT_NO_MSG(bytes == 1);
- data->track_ctrl_reg = val;
- break;
- case LN9310_REG_MODE_CHANGE_CFG:
- __ASSERT_NO_MSG(bytes == 1);
- data->mode_change_reg = val;
- break;
- case LN9310_REG_SYS_CTRL:
- __ASSERT_NO_MSG(bytes == 1);
- data->sys_ctrl_reg = val;
- break;
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-static int ln9310_emul_start_read(struct i2c_emul *emul, int reg)
-{
- return 0;
-}
-
-static int ln9310_emul_finish_read(struct i2c_emul *emul, int reg, int bytes)
-{
- return 0;
-}
-
-static int ln9310_emul_read_byte(struct i2c_emul *emul, int reg, uint8_t *val,
- int bytes)
-{
- struct ln9310_emul_data *data = LN9310_DATA_FROM_I2C_EMUL(emul);
-
- switch (reg) {
- case LN9310_REG_INT1_MSK:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->int1_msk_reg;
- break;
- case LN9310_REG_STARTUP_CTRL:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->startup_ctrl_reg;
- break;
- case LN9310_REG_LION_CTRL:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->lion_ctrl_reg;
- break;
- case LN9310_REG_BC_STS_B:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->bc_sts_b_reg;
- break;
- case LN9310_REG_BC_STS_C:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->bc_sts_c_reg;
- break;
- case LN9310_REG_CFG_0:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->cfg_0_reg;
- break;
- case LN9310_REG_CFG_4:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->cfg_4_reg;
- break;
- case LN9310_REG_CFG_5:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->cfg_5_reg;
- break;
- case LN9310_REG_PWR_CTRL:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->power_ctrl_reg;
- break;
- case LN9310_REG_TIMER_CTRL:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->timer_ctrl_reg;
- break;
- case LN9310_REG_LB_CTRL:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->lower_bound_ctrl_reg;
- break;
- case LN9310_REG_SPARE_0:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->spare_0_reg;
- break;
- case LN9310_REG_SWAP_CTRL_0:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->swap_ctrl_0_reg;
- break;
- case LN9310_REG_SWAP_CTRL_1:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->swap_ctrl_1_reg;
- break;
- case LN9310_REG_SWAP_CTRL_2:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->swap_ctrl_2_reg;
- break;
- case LN9310_REG_SWAP_CTRL_3:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->swap_ctrl_3_reg;
- break;
- case LN9310_REG_TRACK_CTRL:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->track_ctrl_reg;
- break;
- case LN9310_REG_MODE_CHANGE_CFG:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->mode_change_reg;
- break;
- case LN9310_REG_SYS_CTRL:
- __ASSERT_NO_MSG(bytes == 0);
- *val = data->sys_ctrl_reg;
- break;
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-static int ln9310_emul_access_reg(struct i2c_emul *emul, int reg, int bytes,
- bool read)
-{
- return 0;
-}
-
-static int emul_ln9310_init(const struct emul *emul,
- const struct device *parent)
-{
- const struct i2c_common_emul_cfg *cfg = emul->cfg;
- struct ln9310_emul_data *data = emul->data;
-
- data->common.emul.api = &ln9310_emul_api_i2c;
- data->common.emul.addr = cfg->addr;
- data->common.emul.parent = emul;
- data->common.i2c = parent;
- data->common.cfg = cfg;
- i2c_common_emul_init(&data->common);
-
- singleton = emul;
-
- return i2c_emul_register(parent, emul->dev_label, &data->common.emul);
-}
-
-#define INIT_LN9310(n) \
- const struct ln9310_config_t ln9310_config = { \
- .i2c_port = NAMED_I2C(power), \
- .i2c_addr_flags = DT_INST_REG_ADDR(n), \
- }; \
- static struct ln9310_emul_data ln9310_emul_data_##n = { \
- .common = { \
- .start_write = ln9310_emul_start_write, \
- .write_byte = ln9310_emul_write_byte, \
- .finish_write = ln9310_emul_finish_write, \
- .start_read = ln9310_emul_start_read, \
- .read_byte = ln9310_emul_read_byte, \
- .finish_read = ln9310_emul_finish_read, \
- .access_reg = ln9310_emul_access_reg, \
- }, \
- }; \
- static const struct i2c_common_emul_cfg ln9310_emul_cfg_##n = { \
- .i2c_label = DT_INST_BUS_LABEL(n), \
- .dev_label = DT_INST_LABEL(n), \
- .addr = DT_INST_REG_ADDR(n), \
- }; \
- EMUL_DEFINE(emul_ln9310_init, DT_DRV_INST(n), &ln9310_emul_cfg_##n, \
- &ln9310_emul_data_##n)
-
-DT_INST_FOREACH_STATUS_OKAY(INIT_LN9310)
diff --git a/zephyr/emul/emul_pi3usb9201.c b/zephyr/emul/emul_pi3usb9201.c
deleted file mode 100644
index babef58c75..0000000000
--- a/zephyr/emul/emul_pi3usb9201.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT zephyr_pi3usb9201_emul
-
-#include <device.h>
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-#include "emul/emul_pi3usb9201.h"
-
-#include <logging/log.h>
-LOG_MODULE_REGISTER(emul_pi3usb9201, LOG_LEVEL_DBG);
-
-#define EMUL_REG_COUNT (PI3USB9201_REG_HOST_STS + 1)
-#define EMUL_REG_IS_VALID(reg) (reg >= 0 && reg < EMUL_REG_COUNT)
-
-/** Run-time data used by the emulator */
-struct pi3usb9201_emul_data {
- /** I2C emulator detail */
- struct i2c_emul emul;
- /** pi3usb9201 device being emulated */
- const struct device *i2c;
- /** Configuration information */
- const struct pi3usb9201_emul_cfg *cfg;
- /** Current state of all emulated pi3usb9201 registers */
- uint8_t reg[EMUL_REG_COUNT];
-};
-
-/** Static configuration for the emulator */
-struct pi3usb9201_emul_cfg {
- /** Label of the I2C bus this emulator connects to */
- const char *i2c_label;
- /** Pointer to run-time data */
- struct pi3usb9201_emul_data *data;
- /** Address of pi3usb9201 on i2c bus */
- uint16_t addr;
-};
-
-int pi3usb9201_emul_set_reg(struct i2c_emul *emul, int reg, uint8_t val)
-{
- struct pi3usb9201_emul_data *data;
-
- if (!EMUL_REG_IS_VALID(reg))
- return -EIO;
-
- data = CONTAINER_OF(emul, struct pi3usb9201_emul_data, emul);
- data->reg[reg] = val;
-
- return 0;
-}
-
-int pi3usb9201_emul_get_reg(struct i2c_emul *emul, int reg, uint8_t *val)
-{
- struct pi3usb9201_emul_data *data;
-
- if (!EMUL_REG_IS_VALID(reg))
- return -EIO;
-
- data = CONTAINER_OF(emul, struct pi3usb9201_emul_data, emul);
- *val = data->reg[reg];
-
- return 0;
-}
-
-static void pi3usb9201_emul_reset(struct i2c_emul *emul)
-{
- struct pi3usb9201_emul_data *data;
-
- data = CONTAINER_OF(emul, struct pi3usb9201_emul_data, emul);
-
- data->reg[PI3USB9201_REG_CTRL_1] = 0;
- data->reg[PI3USB9201_REG_CTRL_2] = 0;
- data->reg[PI3USB9201_REG_CLIENT_STS] = 0;
- data->reg[PI3USB9201_REG_HOST_STS] = 0;
-}
-
-/**
- * Emulate an I2C transfer to a pi3usb9201
- *
- * This handles simple reads and writes
- *
- * @param emul I2C emulation information
- * @param msgs List of messages to process
- * @param num_msgs Number of messages to process
- * @param addr Address of the I2C target device
- *
- * @retval 0 If successful
- * @retval -EIO General input / output error
- */
-static int pi3usb9201_emul_transfer(struct i2c_emul *emul, struct i2c_msg *msgs,
- int num_msgs, int addr)
-{
- const struct pi3usb9201_emul_cfg *cfg;
- struct pi3usb9201_emul_data *data;
-
- data = CONTAINER_OF(emul, struct pi3usb9201_emul_data, emul);
- cfg = data->cfg;
-
- if (cfg->addr != addr) {
- LOG_ERR("Address mismatch, expected %02x, got %02x", cfg->addr,
- addr);
- return -EIO;
- }
-
- i2c_dump_msgs("emul", msgs, num_msgs, addr);
-
- if (num_msgs == 1) {
- if (!(((msgs[0].flags & I2C_MSG_RW_MASK) == I2C_MSG_WRITE)
- && (msgs[0].len == 2))) {
- LOG_ERR("Unexpected write msgs");
- return -EIO;
- }
- return pi3usb9201_emul_set_reg(emul, msgs[0].buf[0],
- msgs[0].buf[1]);
- } else if (num_msgs == 2) {
- if (!(((msgs[0].flags & I2C_MSG_RW_MASK) == I2C_MSG_WRITE)
- && (msgs[0].len == 1)
- && ((msgs[1].flags & I2C_MSG_RW_MASK) == I2C_MSG_READ)
- && (msgs[1].len == 1))) {
- LOG_ERR("Unexpected read msgs");
- return -EIO;
- }
- return pi3usb9201_emul_get_reg(emul, msgs[0].buf[0],
- &(msgs[1].buf[0]));
- } else {
- LOG_ERR("Unexpected num_msgs");
- return -EIO;
- }
-
-}
-
-/* Device instantiation */
-
-static struct i2c_emul_api pi3usb9201_emul_api = {
- .transfer = pi3usb9201_emul_transfer,
-};
-
-/**
- * @brief Set up a new pi3usb9201 emulator
- *
- * This should be called for each pi3usb9201 device that needs to be
- * emulated. It registers it with the I2C emulation controller.
- *
- * @param emul Emulation information
- * @param parent Device to emulate
- *
- * @return 0 indicating success (always)
- */
-static int pi3usb9201_emul_init(const struct emul *emul,
- const struct device *parent)
-{
- const struct pi3usb9201_emul_cfg *cfg = emul->cfg;
- struct pi3usb9201_emul_data *data = cfg->data;
- int ret;
-
- data->emul.api = &pi3usb9201_emul_api;
- data->emul.addr = cfg->addr;
- data->i2c = parent;
- data->cfg = cfg;
-
- ret = i2c_emul_register(parent, emul->dev_label, &data->emul);
-
- pi3usb9201_emul_reset(&data->emul);
-
- return ret;
-}
-
-#define PI3USB9201_EMUL(n) \
- static struct pi3usb9201_emul_data pi3usb9201_emul_data_##n = {}; \
- static const struct pi3usb9201_emul_cfg pi3usb9201_emul_cfg_##n = { \
- .i2c_label = DT_INST_BUS_LABEL(n), \
- .data = &pi3usb9201_emul_data_##n, \
- .addr = DT_INST_REG_ADDR(n), \
- }; \
- EMUL_DEFINE(pi3usb9201_emul_init, DT_DRV_INST(n), \
- &pi3usb9201_emul_cfg_##n, &pi3usb9201_emul_data_##n)
-
-DT_INST_FOREACH_STATUS_OKAY(PI3USB9201_EMUL)
-
-#define PI3USB9201_EMUL_CASE(n) \
- case DT_INST_DEP_ORD(n): return &pi3usb9201_emul_data_##n.emul;
-
-struct i2c_emul *pi3usb9201_emul_get(int ord)
-{
- switch (ord) {
- DT_INST_FOREACH_STATUS_OKAY(PI3USB9201_EMUL_CASE)
-
- default:
- return NULL;
- }
-}
diff --git a/zephyr/emul/emul_smart_battery.c b/zephyr/emul/emul_smart_battery.c
deleted file mode 100644
index 4b1d87336e..0000000000
--- a/zephyr/emul/emul_smart_battery.c
+++ /dev/null
@@ -1,893 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT zephyr_smart_battery
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <logging/log.h>
-LOG_MODULE_REGISTER(smart_battery);
-
-#include <device.h>
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_smart_battery.h"
-
-#include "crc8.h"
-#include "battery_smart.h"
-
-#define SBAT_DATA_FROM_I2C_EMUL(_emul) \
- CONTAINER_OF(CONTAINER_OF(_emul, struct i2c_common_emul_data, emul), \
- struct sbat_emul_data, common)
-
-/** Run-time data used by the emulator */
-struct sbat_emul_data {
- /** Common I2C data */
- struct i2c_common_emul_data common;
-
- /** Data required to simulate battery */
- struct sbat_emul_bat_data bat;
- /** Command that should be handled next */
- int cur_cmd;
- /** Message buffer which is used to handle smb transactions */
- uint8_t msg_buf[MSG_BUF_LEN];
- /** Total bytes that were generated in response to smb read operation */
- int num_to_read;
-};
-
-/** Check description in emul_smart_battery.h */
-struct sbat_emul_bat_data *sbat_emul_get_bat_data(struct i2c_emul *emul)
-{
- struct sbat_emul_data *data;
-
- data = SBAT_DATA_FROM_I2C_EMUL(emul);
-
- return &data->bat;
-}
-
-/** Check description in emul_smart_battery.h */
-uint16_t sbat_emul_date_to_word(unsigned int day, unsigned int month,
- unsigned int year)
-{
- year -= MANUFACTURE_DATE_YEAR_OFFSET;
- year <<= MANUFACTURE_DATE_YEAR_SHIFT;
- year &= MANUFACTURE_DATE_YEAR_MASK;
- month <<= MANUFACTURE_DATE_MONTH_SHIFT;
- month &= MANUFACTURE_DATE_MONTH_MASK;
- day <<= MANUFACTURE_DATE_DAY_SHIFT;
- day &= MANUFACTURE_DATE_DAY_MASK;
-
- return day | month | year;
-}
-
-/**
- * @brief Compute CRC from the beginning of the message
- *
- * @param addr Smart battery address on SMBus
- * @param read If message for which CRC is computed is read. For read message
- * byte command and repeated address is added to CRC
- * @param cmd Command used in read message
- *
- * @return pec CRC from first bytes of message
- */
-static uint8_t sbat_emul_pec_head(uint8_t addr, int read, uint8_t cmd)
-{
- uint8_t pec;
-
- addr <<= 1;
-
- pec = cros_crc8(&addr, 1);
- if (!read) {
- return pec;
- }
-
- pec = cros_crc8_arg(&cmd, 1, pec);
- addr |= I2C_MSG_READ;
- pec = cros_crc8_arg(&addr, 1, pec);
-
- return pec;
-}
-
-/**
- * @brief Convert from 10mW power units to mA current under given mV voltage
- *
- * @param mw Power in 10mW units
- * @param mv Voltage in mV units
- *
- * @return Current in mA units
- */
-static uint16_t sbat_emul_10mw_to_ma(int mw, int mv)
-{
- /* Smart battery use 10mW units, convert to mW */
- mw *= 10;
- /* Multiple by 1000 to get mA instead of A */
- return 1000 * mw/mv;
-}
-
-/**
- * @brief Convert from mA current to 10mW power under given mV voltage
- *
- * @param ma Current in mA units
- * @param mv Voltage in mV units
- *
- * @return Power in 10mW units
- */
-static uint16_t sbat_emul_ma_to_10mw(int ma, int mv)
-{
- int mw;
- /* Divide by 1000 to get mW instead of uW */
- mw = ma * mv / 1000;
- /* Smart battery use 10mW units, convert to 10mW */
- return mw / 10;
-}
-
-/**
- * @brief Get time in minutes how long it will take to get given amount of
- * charge at given current flow
- *
- * @param bat Pointer to battery data to set error code in case of
- * over/under flow in time calculation
- * @param rate Rate of current in mAh
- * @param cap Required amount of charge in mA
- * @param time Pointer to memory where calculated time will be stored
- *
- * @return 0 on success
- * @return -EINVAL when over or under flow occurred
- */
-static int sbat_emul_get_time_to_complete(struct sbat_emul_bat_data *bat,
- int rate, int cap, uint16_t *ret_time)
-{
- int time;
-
- /* At negative rate process never ends, return maximum value */
- if (rate <= 0) {
- *ret_time = UINT16_MAX;
-
- return 0;
- }
- /* Convert capacity from mAh to mAmin */
- time = cap * 60 / rate;
- /* Check overflow */
- if (time >= UINT16_MAX) {
- *ret_time = UINT16_MAX;
- bat->error_code = STATUS_CODE_OVERUNDERFLOW;
-
- return -EINVAL;
- }
- /* Check underflow */
- if (time < 0) {
- *ret_time = 0;
- bat->error_code = STATUS_CODE_OVERUNDERFLOW;
-
- return -EINVAL;
- }
-
- *ret_time = time;
-
- return 0;
-}
-
-/**
- * @brief Get time in minutes how long it will take to charge battery
- *
- * @param bat Pointer to battery data
- * @param rate Rate of charging current in mAh
- * @param time Pointer to memory where calculated time will be stored
- *
- * @return 0 on success
- * @return -EINVAL when over or under flow occurred
- */
-static int sbat_emul_time_to_full(struct sbat_emul_bat_data *bat, int rate,
- uint16_t *time)
-{
- int cap;
-
- cap = bat->full_cap - bat->cap;
- return sbat_emul_get_time_to_complete(bat, rate, cap, time);
-}
-
-/**
- * @brief Get time in minutes how long it will take to discharge battery. Note,
- * that rate should be negative to indicate discharging.
- *
- * @param bat Pointer to battery data
- * @param rate Rate of charging current in mAh
- * @param time Pointer to memory where calculated time will be stored
- *
- * @return 0 on success
- * @return -EINVAL when over or under flow occurred
- */
-static int sbat_emul_time_to_empty(struct sbat_emul_bat_data *bat, int rate,
- uint16_t *time)
-{
- int cap;
-
- /* Reverse to have discharging rate instead of charging rate */
- rate = -rate;
- cap = bat->cap;
- return sbat_emul_get_time_to_complete(bat, rate, cap, time);
-}
-
-/**
- * @brief Check if battery can supply for 10 seconds additional power/current
- * set in at_rate register.
- *
- * @param bat Pointer to battery data
- * @param rate Rate of charging current in mAh
- * @param ok Pointer to memory where 0 is written if battery is able to supply
- * additional power/curent or 1 is written if battery is unable
- * to do so.
- *
- * @return 0 on success
- */
-static int sbat_emul_read_at_rate_ok(struct sbat_emul_bat_data *bat,
- uint16_t *ok)
-{
- int rem_time_s;
- int rate;
-
- rate = bat->at_rate;
- if (bat->mode & MODE_CAPACITY) {
- rate = sbat_emul_10mw_to_ma(rate, bat->design_mv);
- }
-
- /* Add current battery usage */
- rate += bat->cur;
- if (rate >= 0) {
- /* Battery will be charged */
- *ok = 1;
-
- return 0;
- }
- /* Reverse to have discharging rate instead of charging rate */
- rate = -rate;
-
- rem_time_s = bat->cap * 3600 / rate;
- if (rem_time_s > 10) {
- /*
- * Battery can support 10 seconds of additional at_rate
- * current/power
- */
- *ok = 1;
- } else {
- *ok = 0;
- }
-
- return 0;
-}
-
-/**
- * @brief Get battery status. This function use emulated status register and
- * set or clear some of the flags based on other properties of emulated
- * smart battery. Discharge bit, capacity alarm, time alarm, fully
- * discharged bit and error code are controlled by battery properties.
- * Terminate charge/discharge/overcharge alarms are set only if they are
- * set in emulated status register and battery is charging/discharging,
- * so they are partialy controlled by emulated status register.
- * Other bits are controlled by emulated status register
- *
- * @param emul Pointer to smart battery emulator
- *
- * @return value which equals to computed status register
- */
-static uint16_t sbat_emul_read_status(struct i2c_emul *emul)
-{
- uint16_t status, cap, rem_time, charge_percent;
- struct sbat_emul_bat_data *bat;
- struct sbat_emul_data *data;
-
- data = SBAT_DATA_FROM_I2C_EMUL(emul);
- bat = &data->bat;
-
- status = bat->status;
-
- /*
- * Over charged and terminate charger alarm cannot appear when battery
- * is not charged
- */
- if (bat->cur <= 0) {
- status &= ~(STATUS_TERMINATE_CHARGE_ALARM |
- STATUS_OVERCHARGED_ALARM);
- status |= STATUS_DISCHARGING;
- }
- /* Terminate discharge alarm cannot appear when battery is charged */
- if (bat->cur >= 0) {
- status &= ~(STATUS_TERMINATE_DISCHARGE_ALARM |
- STATUS_DISCHARGING);
- }
-
- sbat_emul_get_word_val(emul, SB_REMAINING_CAPACITY, &cap);
- if (bat->cap_alarm && cap < bat->cap_alarm) {
- status |= STATUS_REMAINING_CAPACITY_ALARM;
- } else {
- status &= ~STATUS_REMAINING_CAPACITY_ALARM;
- }
-
- sbat_emul_get_word_val(emul, SB_AVERAGE_TIME_TO_EMPTY, &rem_time);
- if (bat->time_alarm && rem_time < bat->time_alarm) {
- status |= STATUS_REMAINING_TIME_ALARM;
- } else {
- status &= ~STATUS_REMAINING_TIME_ALARM;
- }
-
- /* Unset fully discharged bit when charge is grater than 20% */
- sbat_emul_get_word_val(emul, SB_RELATIVE_STATE_OF_CHARGE,
- &charge_percent);
- if (charge_percent > 20) {
- status &= ~STATUS_FULLY_DISCHARGED;
- } else {
- status |= STATUS_FULLY_DISCHARGED;
- }
-
- status |= bat->error_code & STATUS_ERR_CODE_MASK;
-
- return status;
-}
-
-/** Check description in emul_smart_battery.h */
-int sbat_emul_get_word_val(struct i2c_emul *emul, int cmd, uint16_t *val)
-{
- struct sbat_emul_bat_data *bat;
- struct sbat_emul_data *data;
- int mode_mw;
- int rate;
-
- data = SBAT_DATA_FROM_I2C_EMUL(emul);
- bat = &data->bat;
- mode_mw = bat->mode & MODE_CAPACITY;
-
- switch (cmd) {
- case SB_MANUFACTURER_ACCESS:
- *val = bat->mf_access;
- return 0;
- case SB_REMAINING_CAPACITY_ALARM:
- *val = bat->cap_alarm;
- return 0;
- case SB_REMAINING_TIME_ALARM:
- *val = bat->time_alarm;
- return 0;
- case SB_BATTERY_MODE:
- *val = bat->mode;
- return 0;
- case SB_AT_RATE:
- *val = bat->at_rate;
- return 0;
- case SB_AT_RATE_TIME_TO_FULL:
- /* Support for reporting time to full in mW mode is optional */
- if (mode_mw && !bat->at_rate_full_mw_support) {
- bat->error_code = STATUS_CODE_OVERUNDERFLOW;
- *val = UINT16_MAX;
-
- return -EINVAL;
- }
-
- rate = bat->at_rate;
- if (mode_mw) {
- rate = sbat_emul_10mw_to_ma(rate, bat->design_mv);
- }
- return sbat_emul_time_to_full(bat, rate, val);
-
- case SB_AT_RATE_TIME_TO_EMPTY:
- rate = bat->at_rate;
- if (mode_mw) {
- rate = sbat_emul_10mw_to_ma(rate, bat->design_mv);
- }
- return sbat_emul_time_to_empty(bat, rate, val);
-
- case SB_AT_RATE_OK:
- return sbat_emul_read_at_rate_ok(bat, val);
- case SB_TEMPERATURE:
- *val = bat->temp;
- return 0;
- case SB_VOLTAGE:
- *val = bat->volt;
- return 0;
- case SB_CURRENT:
- *val = bat->cur;
- return 0;
- case SB_AVERAGE_CURRENT:
- *val = bat->avg_cur;
- return 0;
- case SB_MAX_ERROR:
- *val = bat->max_error;
- return 0;
- case SB_RELATIVE_STATE_OF_CHARGE:
- /* Percent of charge according to full capacity */
- *val = 100 * bat->cap / bat->full_cap;
- return 0;
- case SB_ABSOLUTE_STATE_OF_CHARGE:
- /* Percent of charge according to design capacity */
- *val = 100 * bat->cap / bat->design_cap;
- return 0;
- case SB_REMAINING_CAPACITY:
- if (mode_mw) {
- *val = sbat_emul_ma_to_10mw(bat->cap, bat->design_mv);
- } else {
- *val = bat->cap;
- }
- return 0;
- case SB_FULL_CHARGE_CAPACITY:
- if (mode_mw) {
- *val = sbat_emul_ma_to_10mw(bat->full_cap,
- bat->design_mv);
- } else {
- *val = bat->full_cap;
- }
- return 0;
- case SB_RUN_TIME_TO_EMPTY:
- rate = bat->cur;
- return sbat_emul_time_to_empty(bat, rate, val);
- case SB_AVERAGE_TIME_TO_EMPTY:
- rate = bat->avg_cur;
- return sbat_emul_time_to_empty(bat, rate, val);
- case SB_AVERAGE_TIME_TO_FULL:
- rate = bat->avg_cur;
- return sbat_emul_time_to_full(bat, rate, val);
- case SB_CHARGING_CURRENT:
- *val = bat->desired_charg_cur;
- return 0;
- case SB_CHARGING_VOLTAGE:
- *val = bat->desired_charg_volt;
- return 0;
- case SB_BATTERY_STATUS:
- *val = sbat_emul_read_status(emul);
- return 0;
- case SB_CYCLE_COUNT:
- *val = bat->cycle_count;
- return 0;
- case SB_DESIGN_CAPACITY:
- if (mode_mw) {
- *val = sbat_emul_ma_to_10mw(bat->design_cap,
- bat->design_mv);
- } else {
- *val = bat->design_cap;
- }
- return 0;
- case SB_DESIGN_VOLTAGE:
- *val = bat->design_mv;
- return 0;
- case SB_SPECIFICATION_INFO:
- *val = bat->spec_info;
- return 0;
- case SB_MANUFACTURE_DATE:
- *val = bat->mf_date;
- return 0;
- case SB_SERIAL_NUMBER:
- *val = bat->sn;
- return 0;
- default:
- /* Unknown command or return value is not word */
- return 1;
- }
-}
-
-/** Check description in emul_smart_battery.h */
-int sbat_emul_get_block_data(struct i2c_emul *emul, int cmd, uint8_t **blk,
- int *len)
-{
- struct sbat_emul_bat_data *bat;
- struct sbat_emul_data *data;
-
- data = SBAT_DATA_FROM_I2C_EMUL(emul);
- bat = &data->bat;
-
- switch (cmd) {
- case SB_MANUFACTURER_NAME:
- *blk = bat->mf_name;
- *len = bat->mf_name_len;
- return 0;
- case SB_DEVICE_NAME:
- *blk = bat->dev_name;
- *len = bat->dev_name_len;
- return 0;
- case SB_DEVICE_CHEMISTRY:
- *blk = bat->dev_chem;
- *len = bat->dev_chem_len;
- return 0;
- case SB_MANUFACTURER_DATA:
- *blk = bat->mf_data;
- *len = bat->mf_data_len;
- return 0;
- default:
- /* Unknown command or return value is not word */
- return 1;
- }
-}
-
-/**
- * @brief Append PEC to read command response if battery support it
- *
- * @param data Pointer to smart battery emulator data
- * @param cmd Command for which PEC is calculated
- */
-static void sbat_emul_append_pec(struct sbat_emul_data *data, int cmd)
-{
- uint8_t pec;
-
- if (BATTERY_SPEC_VERSION(data->bat.spec_info) ==
- BATTERY_SPEC_VER_1_1_WITH_PEC) {
- pec = sbat_emul_pec_head(data->common.cfg->addr, 1, cmd);
- pec = cros_crc8_arg(data->msg_buf, data->num_to_read, pec);
- data->msg_buf[data->num_to_read] = pec;
- data->num_to_read++;
- }
-}
-
-/** Check description in emul_smart_battery.h */
-void sbat_emul_set_response(struct i2c_emul *emul, int cmd, uint8_t *buf,
- int len, bool fail)
-{
- struct sbat_emul_data *data;
-
- data = SBAT_DATA_FROM_I2C_EMUL(emul);
-
- if (fail) {
- data->bat.error_code = STATUS_CODE_UNKNOWN_ERROR;
- data->num_to_read = 0;
- return;
- }
-
- data->num_to_read = MIN(len, MSG_BUF_LEN - 1);
- memcpy(data->msg_buf, buf, data->num_to_read);
- data->bat.error_code = STATUS_CODE_OK;
- sbat_emul_append_pec(data, cmd);
-}
-
-/**
- * @brief Function which handles read messages. It expects that data->cur_cmd
- * is set to command number which should be handled. It guarantee that
- * data->num_to_read is set to number of bytes in data->msg_buf on
- * successful handling read request. On error, data->num_to_read is
- * always set to 0.
- *
- * @param emul Pointer to smart battery emulator
- * @param reg Command selected by last write message. If data->cur_cmd is
- * different than SBAT_EMUL_NO_CMD, then reg should equal to
- * data->cur_cmd
- *
- * @return 0 on success
- * @return -EIO on error
- */
-static int sbat_emul_handle_read_msg(struct i2c_emul *emul, int reg)
-{
- struct sbat_emul_data *data;
- uint16_t word;
- uint8_t *blk;
- int ret, len;
-
- data = SBAT_DATA_FROM_I2C_EMUL(emul);
-
- if (data->cur_cmd == SBAT_EMUL_NO_CMD) {
- /* Unexpected read message without preceding command select */
- data->bat.error_code = STATUS_CODE_UNKNOWN_ERROR;
- return -EIO;
- }
- data->cur_cmd = SBAT_EMUL_NO_CMD;
- data->num_to_read = 0;
-
- /* Handle commands which return word */
- ret = sbat_emul_get_word_val(emul, reg, &word);
- if (ret < 0) {
- return -EIO;
- }
- if (ret == 0) {
- data->num_to_read = 2;
- data->msg_buf[0] = word & 0xff;
- data->msg_buf[1] = (word >> 8) & 0xff;
- data->bat.error_code = STATUS_CODE_OK;
- sbat_emul_append_pec(data, reg);
-
- return 0;
- }
-
- /* Handle commands which return block */
- ret = sbat_emul_get_block_data(emul, reg, &blk, &len);
- if (ret != 0) {
- if (ret == 1) {
- data->bat.error_code = STATUS_CODE_UNSUPPORTED;
- LOG_ERR("Unknown read command (0x%x)", reg);
- }
-
- return -EIO;
- }
-
- data->num_to_read = len + 1;
- data->msg_buf[0] = len;
- memcpy(&data->msg_buf[1], blk, len);
- data->bat.error_code = STATUS_CODE_OK;
- sbat_emul_append_pec(data, reg);
-
- return 0;
-}
-
-/**
- * @brief Function which finalize write messages.
- *
- * @param emul Pointer to smart battery emulator
- * @param reg First byte of write message, usually selected command
- * @param bytes Number of bytes received in data->msg_buf
- *
- * @return 0 on success
- * @return -EIO on error
- */
-static int sbat_emul_finalize_write_msg(struct i2c_emul *emul, int reg,
- int bytes)
-{
- struct sbat_emul_bat_data *bat;
- struct sbat_emul_data *data;
- uint16_t word;
- uint8_t pec;
-
- data = SBAT_DATA_FROM_I2C_EMUL(emul);
- bat = &data->bat;
-
- /*
- * Fail if:
- * - there are no bytes to handle
- * - there are too many bytes
- * - there is command byte and only one data byte
- */
- if (bytes <= 0 || bytes > 4 || bytes == 2) {
- data->bat.error_code = STATUS_CODE_BADSIZE;
- LOG_ERR("wrong write message size (%d)", bytes);
-
- return -EIO;
- }
-
- /* There is only command for read */
- if (bytes == 1) {
- data->cur_cmd = reg;
- return 0;
- }
-
- /* Handle PEC */
- data->msg_buf[0] = reg;
- if (bytes == 4) {
- if (BATTERY_SPEC_VERSION(data->bat.spec_info) !=
- BATTERY_SPEC_VER_1_1_WITH_PEC) {
- data->bat.error_code = STATUS_CODE_BADSIZE;
- LOG_ERR("Unexpected PEC; No support in this version");
-
- return -EIO;
- }
- pec = sbat_emul_pec_head(data->common.cfg->addr, 0, 0);
- pec = cros_crc8_arg(data->msg_buf, 3, pec);
- if (pec != data->msg_buf[3]) {
- data->bat.error_code = STATUS_CODE_UNKNOWN_ERROR;
- LOG_ERR("Wrong PEC 0x%x != 0x%x",
- pec, data->msg_buf[3]);
-
- return -EIO;
- }
- }
-
- word = ((int)data->msg_buf[2] << 8) | data->msg_buf[1];
-
- switch (data->msg_buf[0]) {
- case SB_MANUFACTURER_ACCESS:
- bat->mf_access = word;
- break;
- case SB_REMAINING_CAPACITY_ALARM:
- bat->cap_alarm = word;
- break;
- case SB_REMAINING_TIME_ALARM:
- bat->time_alarm = word;
- break;
- case SB_BATTERY_MODE:
- /* Allow to set only upper byte */
- bat->mode &= 0xff;
- bat->mode |= word & 0xff00;
- break;
- case SB_AT_RATE:
- bat->at_rate = word;
- break;
- default:
- data->bat.error_code = STATUS_CODE_ACCESS_DENIED;
- LOG_ERR("Unknown write command (0x%x)", data->msg_buf[0]);
-
- return -EIO;
- }
-
- data->bat.error_code = STATUS_CODE_OK;
-
- return 0;
-}
-
-/**
- * @brief Function called for each byte of write message which is saved in
- * data->msg_buf
- *
- * @param emul Pointer to smart battery emulator
- * @param reg First byte of write message, usually selected command
- * @param val Received byte of write message
- * @param bytes Number of bytes already received
- *
- * @return 0 on success
- */
-static int sbat_emul_write_byte(struct i2c_emul *emul, int reg, uint8_t val,
- int bytes)
-{
- struct sbat_emul_data *data;
-
- data = SBAT_DATA_FROM_I2C_EMUL(emul);
-
- if (bytes < MSG_BUF_LEN) {
- data->msg_buf[bytes] = val;
- }
-
- return 0;
-}
-
-/**
- * @brief Function called for each byte of read message. Byte from data->msg_buf
- * is copied to read message response.
- *
- * @param emul Pointer to smart battery emulator
- * @param reg First byte of last write message, usually selected command
- * @param val Pointer where byte to read should be stored
- * @param bytes Number of bytes already readed
- *
- * @return 0 on success
- */
-static int sbat_emul_read_byte(struct i2c_emul *emul, int reg, uint8_t *val,
- int bytes)
-{
- struct sbat_emul_data *data;
-
- data = SBAT_DATA_FROM_I2C_EMUL(emul);
-
- if (bytes < data->num_to_read) {
- *val = data->msg_buf[bytes];
- }
-
- return 0;
-}
-
-/**
- * @brief Get currently accessed register, which always equals to selected
- * command.
- *
- * @param emul Pointer to smart battery emulator
- * @param reg First byte of last write message, usually selected command
- * @param bytes Number of bytes already handled from current message
- * @param read If currently handled is read message
- *
- * @return Currently accessed register
- */
-static int sbat_emul_access_reg(struct i2c_emul *emul, int reg, int bytes,
- bool read)
-{
- return reg;
-}
-
-/* Device instantiation */
-
-static struct i2c_emul_api sbat_emul_api = {
- .transfer = i2c_common_emul_transfer,
-};
-
-/**
- * @brief Set up a new Smart Battery emulator
- *
- * This should be called for each Smart Battery device that needs to be
- * emulated. It registers it with the I2C emulation controller.
- *
- * @param emul Emulation information
- * @param parent Device to emulate
- *
- * @return 0 indicating success (always)
- */
-static int sbat_emul_init(const struct emul *emul,
- const struct device *parent)
-{
- const struct i2c_common_emul_cfg *cfg = emul->cfg;
- struct i2c_common_emul_data *data = cfg->data;
- int ret;
-
- data->emul.api = &sbat_emul_api;
- data->emul.addr = cfg->addr;
- data->i2c = parent;
- data->cfg = cfg;
- i2c_common_emul_init(data);
-
- ret = i2c_emul_register(parent, emul->dev_label, &data->emul);
-
- return ret;
-}
-
-#define SMART_BATTERY_EMUL(n) \
- static struct sbat_emul_data sbat_emul_data_##n = { \
- .bat = { \
- .mf_access = DT_INST_PROP(n, mf_access), \
- .at_rate_full_mw_support = DT_INST_PROP(n, \
- at_rate_full_mw_support), \
- .spec_info = ((DT_STRING_TOKEN(DT_DRV_INST(n), \
- version) << \
- BATTERY_SPEC_VERSION_SHIFT) & \
- BATTERY_SPEC_VERSION_MASK) | \
- ((DT_INST_PROP(n, vscale) << \
- BATTERY_SPEC_VSCALE_SHIFT) & \
- BATTERY_SPEC_VSCALE_MASK) | \
- ((DT_INST_PROP(n, ipscale) << \
- BATTERY_SPEC_IPSCALE_SHIFT) & \
- BATTERY_SPEC_IPSCALE_MASK) | \
- BATTERY_SPEC_REVISION_1, \
- .mode = (DT_INST_PROP(n, \
- int_charge_controller) * \
- MODE_INTERNAL_CHARGE_CONTROLLER) | \
- (DT_INST_PROP(n, primary_battery) * \
- MODE_PRIMARY_BATTERY_SUPPORT), \
- .design_mv = DT_INST_PROP(n, design_mv), \
- .design_cap = DT_INST_PROP(n, design_cap), \
- .temp = DT_INST_PROP(n, temperature), \
- .volt = DT_INST_PROP(n, volt), \
- .cur = DT_INST_PROP(n, cur), \
- .avg_cur = DT_INST_PROP(n, avg_cur), \
- .max_error = DT_INST_PROP(n, max_error), \
- .cap = DT_INST_PROP(n, cap), \
- .full_cap = DT_INST_PROP(n, full_cap), \
- .desired_charg_cur = DT_INST_PROP(n, \
- desired_charg_cur), \
- .desired_charg_volt = DT_INST_PROP(n, \
- desired_charg_volt), \
- .cycle_count = DT_INST_PROP(n, cycle_count), \
- .sn = DT_INST_PROP(n, serial_number), \
- .mf_name = DT_INST_PROP(n, mf_name), \
- .mf_name_len = sizeof( \
- DT_INST_PROP(n, mf_name)) - 1, \
- .mf_data = DT_INST_PROP(n, mf_data), \
- .mf_data_len = sizeof( \
- DT_INST_PROP(n, mf_data)) - 1, \
- .dev_name = DT_INST_PROP(n, dev_name), \
- .dev_name_len = sizeof( \
- DT_INST_PROP(n, dev_name)) - 1, \
- .dev_chem = DT_INST_PROP(n, dev_chem), \
- .dev_chem_len = sizeof( \
- DT_INST_PROP(n, dev_chem)) - 1, \
- .mf_date = 0, \
- .cap_alarm = 0, \
- .time_alarm = 0, \
- .at_rate = 0, \
- .status = STATUS_INITIALIZED, \
- .error_code = STATUS_CODE_OK, \
- }, \
- .cur_cmd = SBAT_EMUL_NO_CMD, \
- .common = { \
- .start_write = NULL, \
- .write_byte = sbat_emul_write_byte, \
- .finish_write = sbat_emul_finalize_write_msg, \
- .start_read = sbat_emul_handle_read_msg, \
- .read_byte = sbat_emul_read_byte, \
- .finish_read = NULL, \
- .access_reg = sbat_emul_access_reg, \
- }, \
- }; \
- \
- static const struct i2c_common_emul_cfg sbat_emul_cfg_##n = { \
- .i2c_label = DT_INST_BUS_LABEL(n), \
- .dev_label = DT_INST_LABEL(n), \
- .data = &sbat_emul_data_##n.common, \
- .addr = DT_INST_REG_ADDR(n), \
- }; \
- EMUL_DEFINE(sbat_emul_init, DT_DRV_INST(n), &sbat_emul_cfg_##n, \
- &sbat_emul_data_##n)
-
-DT_INST_FOREACH_STATUS_OKAY(SMART_BATTERY_EMUL)
-
-#define SMART_BATTERY_EMUL_CASE(n) \
- case DT_INST_DEP_ORD(n): return &sbat_emul_data_##n.common.emul;
-
-/** Check description in emul_smart_battery.h */
-struct i2c_emul *sbat_emul_get_ptr(int ord)
-{
- switch (ord) {
- DT_INST_FOREACH_STATUS_OKAY(SMART_BATTERY_EMUL_CASE)
-
- default:
- return NULL;
- }
-}
diff --git a/zephyr/emul/emul_syv682x.c b/zephyr/emul/emul_syv682x.c
deleted file mode 100644
index 3d76d10492..0000000000
--- a/zephyr/emul/emul_syv682x.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT zephyr_syv682x_emul
-
-#include <device.h>
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <logging/log.h>
-LOG_MODULE_REGISTER(syv682x);
-#include <stdint.h>
-#include <string.h>
-
-#include "emul/emul_syv682x.h"
-
-#define EMUL_REG_COUNT (SYV682X_CONTROL_4_REG + 1)
-#define EMUL_REG_IS_VALID(reg) (reg >= 0 && reg < EMUL_REG_COUNT)
-
-struct syv682x_emul_data {
- /** I2C emulator detail */
- struct i2c_emul emul;
- /** Smart battery device being emulated */
- const struct device *i2c;
- /** Configuration information */
- const struct syv682x_emul_cfg *cfg;
- /** Current state of all emulated SYV682x registers */
- uint8_t reg[EMUL_REG_COUNT];
- /**
- * Current state of conditions affecting interrupt bits, as distinct
- * from the current values of those bits stored in reg.
- */
- uint8_t status_cond;
- uint8_t control_4_cond;
-};
-
-/** Static configuration for the emulator */
-struct syv682x_emul_cfg {
- /** Label of the I2C bus this emulator connects to */
- const char *i2c_label;
- /** Address of smart battery on i2c bus */
- uint16_t addr;
- /** Pointer to runtime data */
- struct syv682x_emul_data *data;
-};
-
-int syv682x_emul_set_reg(struct i2c_emul *emul, int reg, uint8_t val)
-{
- struct syv682x_emul_data *data;
-
- if (!EMUL_REG_IS_VALID(reg))
- return -EIO;
-
- data = CONTAINER_OF(emul, struct syv682x_emul_data, emul);
- data->reg[reg] = val;
-
- return 0;
-}
-
-void syv682x_emul_set_status(struct i2c_emul *emul, uint8_t val)
-{
- struct syv682x_emul_data *data;
-
- data = CONTAINER_OF(emul, struct syv682x_emul_data, emul);
- data->status_cond = val;
- data->reg[SYV682X_STATUS_REG] |= val;
-}
-
-int syv682x_emul_get_reg(struct i2c_emul *emul, int reg, uint8_t *val)
-{
- struct syv682x_emul_data *data;
-
- if (!EMUL_REG_IS_VALID(reg))
- return -EIO;
-
- data = CONTAINER_OF(emul, struct syv682x_emul_data, emul);
- *val = data->reg[reg];
-
- return 0;
-}
-
-/**
- * Emulate an I2C transfer to an SYV682x. This handles simple reads and writes.
- *
- * @param emul I2C emulation information
- * @param msgs List of messages to process. For 'read' messages, this function
- * updates the 'buf' member with the data that was read
- * @param num_msgs Number of messages to process
- * @param addr Address of the I2C target device.
- *
- * @return 0 on success, -EIO on general input / output error
- */
-static int syv682x_emul_transfer(struct i2c_emul *emul, struct i2c_msg *msgs,
- int num_msgs, int addr)
-{
- const struct syv682x_emul_cfg *cfg;
- struct syv682x_emul_data *data;
- data = CONTAINER_OF(emul, struct syv682x_emul_data, emul);
- cfg = data->cfg;
-
- if (cfg->addr != addr) {
- LOG_ERR("Address mismatch, expected %02x, got %02x", cfg->addr,
- addr);
- return -EIO;
- }
-
- i2c_dump_msgs("emul", msgs, num_msgs, addr);
-
- if (num_msgs == 1) {
- if (!((msgs[0].flags & I2C_MSG_RW_MASK) == I2C_MSG_WRITE
- && msgs[0].len == 2)) {
- LOG_ERR("Unexpected write msgs");
- return -EIO;
- }
- return syv682x_emul_set_reg(emul, msgs[0].buf[0],
- msgs[0].buf[1]);
- } else if (num_msgs == 2) {
- int ret;
- int reg;
- uint8_t *buf;
-
- if (!((msgs[0].flags & I2C_MSG_RW_MASK) == I2C_MSG_WRITE
- && msgs[0].len == 1
- && (msgs[1].flags & I2C_MSG_RW_MASK) ==
- I2C_MSG_READ
- && (msgs[1].len == 1))) {
- LOG_ERR("Unexpected read msgs");
- return -EIO;
- }
-
- reg = msgs[0].buf[0];
- buf = &msgs[1].buf[0];
- ret = syv682x_emul_get_reg(emul, reg, buf);
-
- switch (reg) {
- /*
- * These registers are clear-on-read (if the underlying
- * condition has cleared).
- */
- case SYV682X_STATUS_REG:
- syv682x_emul_set_reg(emul, reg, data->status_cond);
- break;
- case SYV682X_CONTROL_4_REG:
- syv682x_emul_set_reg(emul, reg, data->control_4_cond);
- break;
- default:
- break;
- }
-
- return ret;
- } else {
- LOG_ERR("Unexpected num_msgs");
- return -EIO;
- }
-}
-
-/* Device instantiation */
-
-static struct i2c_emul_api syv682x_emul_api = {
- .transfer = syv682x_emul_transfer,
-};
-
-/**
- * @brief Set up a new SYV682x emulator
- *
- * This should be called for each SYV682x device that needs to be emulated. It
- * registers it with the I2C emulation controller.
- *
- * @param emul Emulation information
- * @param parent Device to emulate
- *
- * @return 0 indicating success (always)
- */
-static int syv682x_emul_init(const struct emul *emul,
- const struct device *parent)
-{
- const struct syv682x_emul_cfg *cfg = emul->cfg;
- struct syv682x_emul_data *data = cfg->data;
- int ret;
-
- data->emul.api = &syv682x_emul_api;
- data->emul.addr = cfg->addr;
- data->i2c = parent;
- data->cfg = cfg;
- memset(data->reg, 0, sizeof(data->reg));
-
- ret = i2c_emul_register(parent, emul->dev_label, &data->emul);
-
- return ret;
-}
-
-#define SYV682X_EMUL(n) \
- static struct syv682x_emul_data syv682x_emul_data_##n = {}; \
- static const struct syv682x_emul_cfg syv682x_emul_cfg_##n = { \
- .i2c_label = DT_INST_BUS_LABEL(n), \
- .data = &syv682x_emul_data_##n, \
- .addr = DT_INST_REG_ADDR(n), \
- }; \
- EMUL_DEFINE(syv682x_emul_init, DT_DRV_INST(n), &syv682x_emul_cfg_##n, \
- &syv682x_emul_data_##n)
-
-DT_INST_FOREACH_STATUS_OKAY(SYV682X_EMUL)
-
-#define SYV682X_EMUL_CASE(n) \
- case DT_INST_DEP_ORD(n): return &syv682x_emul_data_##n.emul;
-
-
-struct i2c_emul *syv682x_emul_get(int ord)
-{
- switch (ord) {
- DT_INST_FOREACH_STATUS_OKAY(SYV682X_EMUL_CASE)
-
- default:
- return NULL;
- }
-}
diff --git a/zephyr/emul/emul_tcs3400.c b/zephyr/emul/emul_tcs3400.c
deleted file mode 100644
index 0fc432e9ff..0000000000
--- a/zephyr/emul/emul_tcs3400.c
+++ /dev/null
@@ -1,650 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT zephyr_tcs3400
-
-#define LOG_LEVEL CONFIG_I2C_LOG_LEVEL
-#include <logging/log.h>
-LOG_MODULE_REGISTER(emul_tcs);
-
-#include <device.h>
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_tcs3400.h"
-
-#include "driver/als_tcs3400.h"
-
-#define TCS_DATA_FROM_I2C_EMUL(_emul) \
- CONTAINER_OF(CONTAINER_OF(_emul, struct i2c_common_emul_data, emul), \
- struct tcs_emul_data, common)
-
-/** Run-time data used by the emulator */
-struct tcs_emul_data {
- /** Common I2C data */
- struct i2c_common_emul_data common;
-
- /** Value of data byte in ongoing write message */
- uint8_t write_byte;
-
- /** Current state of emulated TCS3400 registers */
- uint8_t reg[TCS_EMUL_REG_COUNT];
- /** Return IR value instead of clear */
- bool ir_select;
- /** Internal values of light sensor registers */
- int red;
- int green;
- int blue;
- int clear;
- int ir;
-
- /** ID registers value */
- uint8_t revision;
- uint8_t id;
-
- /** Return error when trying to write to RO register */
- bool error_on_ro_write;
- /** Return error when trying to write 1 to reserved bit */
- bool error_on_rsvd_write;
- /** Return error when trying to access MSB before LSB */
- bool error_on_msb_first;
- /**
- * Flag set when LSB register is accessed and cleared when MSB is
- * accessed. Allows to track order of accessing data registers
- */
- bool lsb_r_read;
- bool lsb_g_read;
- bool lsb_b_read;
- bool lsb_c_ir_read;
-};
-
-/** Check description in emul_tcs3400.h */
-void tcs_emul_set_reg(struct i2c_emul *emul, int reg, uint8_t val)
-{
- struct tcs_emul_data *data;
-
- if (reg < TCS_EMUL_FIRST_REG || reg > TCS_EMUL_LAST_REG) {
- return;
- }
-
- reg -= TCS_EMUL_FIRST_REG;
- data = TCS_DATA_FROM_I2C_EMUL(emul);
- data->reg[reg] = val;
-}
-
-/** Check description in emul_tcs3400.h */
-uint8_t tcs_emul_get_reg(struct i2c_emul *emul, int reg)
-{
- struct tcs_emul_data *data;
-
- if (reg < TCS_EMUL_FIRST_REG || reg > TCS_EMUL_LAST_REG) {
- return 0;
- }
-
- data = TCS_DATA_FROM_I2C_EMUL(emul);
- reg -= TCS_EMUL_FIRST_REG;
-
- return data->reg[reg];
-}
-
-/** Check description in emul_tcs3400.h */
-int tcs_emul_get_val(struct i2c_emul *emul, enum tcs_emul_axis axis)
-{
- struct tcs_emul_data *data;
-
- data = TCS_DATA_FROM_I2C_EMUL(emul);
-
- switch (axis) {
- case TCS_EMUL_R:
- return data->red;
- case TCS_EMUL_G:
- return data->green;
- case TCS_EMUL_B:
- return data->blue;
- case TCS_EMUL_C:
- return data->clear;
- case TCS_EMUL_IR:
- return data->ir;
- }
-
- return 0;
-}
-
-/** Check description in emul_tcs3400.h */
-void tcs_emul_set_val(struct i2c_emul *emul, enum tcs_emul_axis axis, int val)
-{
- struct tcs_emul_data *data;
-
- data = TCS_DATA_FROM_I2C_EMUL(emul);
-
- switch (axis) {
- case TCS_EMUL_R:
- data->red = val;
- break;
- case TCS_EMUL_G:
- data->green = val;
- break;
- case TCS_EMUL_B:
- data->blue = val;
- break;
- case TCS_EMUL_C:
- data->clear = val;
- break;
- case TCS_EMUL_IR:
- data->ir = val;
- break;
- }
-}
-
-/** Check description in emul_tcs3400.h */
-void tcs_emul_set_err_on_ro_write(struct i2c_emul *emul, bool set)
-{
- struct tcs_emul_data *data;
-
- data = TCS_DATA_FROM_I2C_EMUL(emul);
- data->error_on_ro_write = set;
-}
-
-/** Check description in emul_tcs3400.h */
-void tcs_emul_set_err_on_rsvd_write(struct i2c_emul *emul, bool set)
-{
- struct tcs_emul_data *data;
-
- data = TCS_DATA_FROM_I2C_EMUL(emul);
- data->error_on_rsvd_write = set;
-}
-
-/** Check description in emul_tcs3400.h */
-void tcs_emul_set_err_on_msb_first(struct i2c_emul *emul, bool set)
-{
- struct tcs_emul_data *data;
-
- data = TCS_DATA_FROM_I2C_EMUL(emul);
- data->error_on_msb_first = set;
-}
-
-/** Mask reserved bits in registers of TCS3400 */
-static const uint8_t tcs_emul_rsvd_mask[] = {
- [TCS_I2C_ENABLE - TCS_EMUL_FIRST_REG] = 0xa4,
- [TCS_I2C_ATIME - TCS_EMUL_FIRST_REG] = 0x00,
- [0x2] = 0xff, /* Reserved */
- [TCS_I2C_WTIME - TCS_EMUL_FIRST_REG] = 0x00,
- [TCS_I2C_AILTL - TCS_EMUL_FIRST_REG] = 0x00,
- [TCS_I2C_AILTH - TCS_EMUL_FIRST_REG] = 0x00,
- [TCS_I2C_AIHTL - TCS_EMUL_FIRST_REG] = 0x00,
- [TCS_I2C_AIHTH - TCS_EMUL_FIRST_REG] = 0x00,
- [0x8 ... 0xb] = 0xff, /* Reserved */
- [TCS_I2C_PERS - TCS_EMUL_FIRST_REG] = 0xf0,
- [TCS_I2C_CONFIG - TCS_EMUL_FIRST_REG] = 0x81,
- [0xe] = 0xff, /* Reserved */
- [TCS_I2C_CONTROL - TCS_EMUL_FIRST_REG] = 0xfc,
- [TCS_I2C_AUX - TCS_EMUL_FIRST_REG] = 0xdf,
- [TCS_I2C_REVID - TCS_EMUL_FIRST_REG] = 0xf0,
- [TCS_I2C_ID - TCS_EMUL_FIRST_REG] = 0x00,
- [TCS_I2C_STATUS - TCS_EMUL_FIRST_REG] = 0x6e,
- [TCS_I2C_CDATAL - TCS_EMUL_FIRST_REG] = 0x00,
- [TCS_I2C_CDATAH - TCS_EMUL_FIRST_REG] = 0x00,
- [TCS_I2C_RDATAL - TCS_EMUL_FIRST_REG] = 0x00,
- [TCS_I2C_RDATAH - TCS_EMUL_FIRST_REG] = 0x00,
- [TCS_I2C_GDATAL - TCS_EMUL_FIRST_REG] = 0x00,
- [TCS_I2C_GDATAH - TCS_EMUL_FIRST_REG] = 0x00,
- [TCS_I2C_BDATAL - TCS_EMUL_FIRST_REG] = 0x00,
- [TCS_I2C_BDATAH - TCS_EMUL_FIRST_REG] = 0x00,
-};
-
-/**
- * @brief Reset registers to default values
- *
- * @param emul Pointer to TCS3400 emulator
- */
-static void tcs_emul_reset(struct i2c_emul *emul)
-{
- struct tcs_emul_data *data;
-
- data = TCS_DATA_FROM_I2C_EMUL(emul);
-
- data->reg[TCS_I2C_ENABLE - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_ATIME - TCS_EMUL_FIRST_REG] = 0xff;
- data->reg[TCS_I2C_WTIME - TCS_EMUL_FIRST_REG] = 0xff;
- data->reg[TCS_I2C_AILTL - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_AILTH - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_AIHTL - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_AIHTH - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_PERS - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_CONFIG - TCS_EMUL_FIRST_REG] = 0x40;
- data->reg[TCS_I2C_CONTROL - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_AUX - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_REVID - TCS_EMUL_FIRST_REG] = data->revision;
- data->reg[TCS_I2C_ID - TCS_EMUL_FIRST_REG] = data->id;
- data->reg[TCS_I2C_STATUS - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_CDATAL - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_CDATAH - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_RDATAL - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_RDATAH - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_GDATAL - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_GDATAH - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_BDATAL - TCS_EMUL_FIRST_REG] = 0x00;
- data->reg[TCS_I2C_BDATAH - TCS_EMUL_FIRST_REG] = 0x00;
-
- data->ir_select = false;
-}
-
-/**
- * @brief Convert gain in format of CONTROL register to multiplyer
- *
- * @param control Value of CONTROL register
- *
- * @return gain by which messured value should be multiplied
- */
-static int tcs_emul_get_gain(uint8_t control)
-{
- switch (control & TCS_I2C_CONTROL_MASK) {
- case 0:
- return 1;
- case 1:
- return 4;
- case 2:
- return 16;
- case 3:
- return 64;
- default:
- return -1;
- }
-}
-
-/**
- * @brief Convert number of cycles in format of ATIME register
- *
- * @param atime Value of ATIME register
- *
- * @return cycles count that should be used to obtain light sensor values
- */
-static int tcs_emul_get_cycles(uint8_t atime)
-{
- return TCS_EMUL_MAX_CYCLES - (int)atime;
-}
-
-/**
- * @brief Clear all interrupt registers
- *
- * @param emul Pointer to TCS3400 emulator
- */
-static void tcs_emul_clear_int(struct i2c_emul *emul)
-{
- struct tcs_emul_data *data;
-
- data = TCS_DATA_FROM_I2C_EMUL(emul);
-
- data->reg[TCS_I2C_STATUS - TCS_EMUL_FIRST_REG] = 0x00;
-}
-
-/**
- * @brief Handle I2C write message. It is checked if accessed register isn't RO
- * and reserved bits are set to 0. Write set value of reg field of TCS
- * emulator data ignoring reserved bits and write only bits. Some
- * commands are handled specialy.
- *
- * @param emul Pointer to TCS3400 emulator
- * @param reg Register which is written
- * @param bytes Number of bytes received in this write message
- *
- * @return 0 on success
- * @return -EIO on error
- */
-static int tcs_emul_handle_write(struct i2c_emul *emul, int reg, int bytes)
-{
- struct tcs_emul_data *data;
- uint8_t val;
-
- data = TCS_DATA_FROM_I2C_EMUL(emul);
-
- /* This write only selected register for I2C read message */
- if (bytes < 2) {
- return 0;
- }
-
- val = data->write_byte;
-
- /* Register is in data->reg */
- if (reg >= TCS_EMUL_FIRST_REG && reg <= TCS_EMUL_LAST_REG) {
- if (reg >= TCS_I2C_REVID && reg <= TCS_I2C_BDATAH) {
- if (data->error_on_ro_write) {
- LOG_ERR("Writing to reg 0x%x which is RO", reg);
- return -EIO;
- }
-
- return 0;
- }
-
- if (reg == TCS_I2C_CONFIG && data->error_on_rsvd_write &&
- !(BIT(6) & val)) {
- LOG_ERR("CONFIG reg bit 6 is write as 6 (writing 0x%x)",
- val);
- return -EIO;
- }
-
- reg -= TCS_EMUL_FIRST_REG;
- if (data->error_on_rsvd_write &&
- tcs_emul_rsvd_mask[reg] & val) {
- LOG_ERR("Writing 0x%x to reg 0x%x with rsvd mask 0x%x",
- val, reg + TCS_EMUL_FIRST_REG,
- tcs_emul_rsvd_mask[reg]);
- return -EIO;
- }
-
- /* Ignore all reserved bits */
- val &= ~tcs_emul_rsvd_mask[reg];
- val |= data->reg[reg] & tcs_emul_rsvd_mask[reg];
-
- data->reg[reg] = val;
-
- return 0;
- }
-
- switch (reg) {
- case TCS_I2C_IR:
- if (data->error_on_rsvd_write && 0x7f & val) {
- LOG_ERR("Writing 0x%x to reg 0x%x with rsvd mask 0x7f",
- val, reg);
- return -EIO;
- }
- data->ir_select = !!(val & BIT(7));
- break;
- case TCS_I2C_IFORCE:
- /* Interrupt generate is not supported */
- break;
- case TCS_I2C_CICLEAR:
- case TCS_I2C_AICLEAR:
- tcs_emul_clear_int(emul);
- break;
- default:
- /* Assume that other registers are RO */
- if (data->error_on_ro_write) {
- LOG_ERR("Writing to reg 0x%x which is RO (unknown)",
- reg);
- return -EIO;
- }
- }
-
- return 0;
-}
-
-/**
- * @brief Get set light sensor value for given register using internal
- * state @p val. In case of accessing MSB check if LSB was accessed first
- *
- * @param emul Pointer to TCS3400 emulator
- * @param reg LSB or MSB register address. LSB has to be aligned to 2
- * @param lsb_read Pointer to variable which represent if last access to this
- * accelerometer value was through LSB register
- * @param lsb True if now accessing LSB, Flase if now accessing MSB
- * @param val Internal value of accessed light sensor
- *
- * @return 0 on success
- * @return -EIO when accessing MSB before LSB
- */
-static int tcs_emul_get_reg_val(struct i2c_emul *emul, int reg,
- bool *lsb_read, bool lsb, unsigned int val)
-{
- struct tcs_emul_data *data;
- uint64_t reg_val;
- int msb_reg;
- int lsb_reg;
- int cycles;
- int gain;
-
- data = TCS_DATA_FROM_I2C_EMUL(emul);
-
- if (lsb) {
- *lsb_read = 1;
- } else {
- /*
- * If error on first accessing MSB is set and LSB wasn't
- * accessed before, then return error.
- */
- if (data->error_on_msb_first && !(*lsb_read)) {
- return -EIO;
- }
- *lsb_read = 0;
- /* LSB read should set correct value */
- return 0;
- }
-
- lsb_reg = (reg - TCS_EMUL_FIRST_REG) & ~(0x1);
- msb_reg = (reg - TCS_EMUL_FIRST_REG) | 0x1;
-
- gain = tcs_emul_get_gain(data->reg[TCS_I2C_CONTROL -
- TCS_EMUL_FIRST_REG]);
- cycles = tcs_emul_get_cycles(data->reg[TCS_I2C_ATIME -
- TCS_EMUL_FIRST_REG]);
- /*
- * Internal value is with 256 cycles and x64 gain, so divide it to get
- * registers value
- */
- reg_val = (uint64_t)val * cycles * gain / TCS_EMUL_MAX_CYCLES /
- TCS_EMUL_MAX_GAIN;
-
- if (reg_val > UINT16_MAX) {
- reg_val = UINT16_MAX;
- }
-
- data->reg[lsb_reg] = reg_val & 0xff;
- data->reg[msb_reg] = (reg_val >> 8) & 0xff;
-
- return 0;
-}
-
-/**
- * @brief Handle I2C read message. Response is obtained from reg field of TCS
- * emul data. When accessing light sensor value, register data is first
- * computed using internal emulator state.
- *
- * @param emul Pointer to TCS3400 emulator
- * @param reg First register address that is accessed in this read message
- * @param buf Pointer where result should be stored
- * @param bytes Number of bytes already handled in this read message
- *
- * @return 0 on success
- * @return -EIO on error
- */
-static int tcs_emul_handle_read(struct i2c_emul *emul, int reg, uint8_t *buf,
- int bytes)
-{
- struct tcs_emul_data *data;
- unsigned int c_ir;
- int ret;
-
- data = TCS_DATA_FROM_I2C_EMUL(emul);
-
- reg += bytes;
-
- if ((reg < TCS_EMUL_FIRST_REG || reg > TCS_EMUL_LAST_REG) &&
- reg != TCS_I2C_IR) {
- LOG_ERR("Accessing register 0x%x which cannot be read", reg);
- return -EIO;
- }
-
- switch (reg) {
- case TCS_I2C_CDATAL:
- /* Shouldn't fail for LSB */
- c_ir = data->ir_select ? data->ir : data->clear;
- ret = tcs_emul_get_reg_val(emul, reg, &data->lsb_c_ir_read,
- true, c_ir);
- break;
- case TCS_I2C_CDATAH:
- c_ir = data->ir_select ? data->ir : data->clear;
- ret = tcs_emul_get_reg_val(emul, reg, &data->lsb_c_ir_read,
- false, c_ir);
- if (ret) {
- LOG_ERR("MSB C read before LSB C");
- return -EIO;
- }
- break;
- case TCS_I2C_RDATAL:
- /* Shouldn't fail for LSB */
- ret = tcs_emul_get_reg_val(emul, reg, &data->lsb_r_read,
- true, data->red);
- break;
- case TCS_I2C_RDATAH:
- ret = tcs_emul_get_reg_val(emul, reg, &data->lsb_r_read,
- false, data->red);
- if (ret) {
- LOG_ERR("MSB R read before LSB R");
- return -EIO;
- }
- break;
- case TCS_I2C_GDATAL:
- /* Shouldn't fail for LSB */
- ret = tcs_emul_get_reg_val(emul, reg, &data->lsb_g_read,
- true, data->green);
- break;
- case TCS_I2C_GDATAH:
- ret = tcs_emul_get_reg_val(emul, reg, &data->lsb_g_read,
- false, data->green);
- if (ret) {
- LOG_ERR("MSB G read before LSB G");
- return -EIO;
- }
- break;
- case TCS_I2C_BDATAL:
- /* Shouldn't fail for LSB */
- ret = tcs_emul_get_reg_val(emul, reg, &data->lsb_b_read,
- true, data->blue);
- break;
- case TCS_I2C_BDATAH:
- ret = tcs_emul_get_reg_val(emul, reg, &data->lsb_b_read,
- false, data->blue);
- if (ret) {
- LOG_ERR("MSB B read before LSB B");
- return -EIO;
- }
- break;
- case TCS_I2C_IR:
- *buf = data->ir_select ? BIT(7) : 0;
-
- return 0;
- }
-
- *buf = data->reg[reg - TCS_EMUL_FIRST_REG];
-
- return 0;
-}
-
-/**
- * @brief Handle I2C write message. Check if message is not too long and saves
- * data that will be stored in register
- *
- * @param emul Pointer to TCS3400 emulator
- * @param reg Register address that is accessed
- * @param val Data to write to the register
- * @param bytes Number of bytes already handled in this read message
- *
- * @return 0 on success
- * @return -EIO on error
- */
-static int tcs_emul_write_byte(struct i2c_emul *emul, int reg, uint8_t val,
- int bytes)
-{
- struct tcs_emul_data *data;
-
- data = TCS_DATA_FROM_I2C_EMUL(emul);
-
- if (bytes > 1) {
- LOG_ERR("Too long write command");
- return -EIO;
- }
-
- data->write_byte = val;
-
- return 0;
-}
-
-/* Device instantiation */
-
-static struct i2c_emul_api tcs_emul_api = {
- .transfer = i2c_common_emul_transfer,
-};
-
-/**
- * @brief Set up a new TCS3400 emulator
- *
- * This should be called for each TCS3400 device that needs to be
- * emulated. It registers it with the I2C emulation controller.
- *
- * @param emul Emulation information
- * @param parent Device to emulate
- *
- * @return 0 indicating success (always)
- */
-static int tcs_emul_init(const struct emul *emul,
- const struct device *parent)
-{
- const struct i2c_common_emul_cfg *cfg = emul->cfg;
- struct i2c_common_emul_data *data = cfg->data;
- int ret;
-
- data->emul.api = &tcs_emul_api;
- data->emul.addr = cfg->addr;
- data->i2c = parent;
- data->cfg = cfg;
- i2c_common_emul_init(data);
-
- ret = i2c_emul_register(parent, emul->dev_label, &data->emul);
-
- tcs_emul_reset(&data->emul);
-
- return ret;
-}
-
-#define TCS3400_EMUL(n) \
- static struct tcs_emul_data tcs_emul_data_##n = { \
- .revision = DT_INST_PROP(n, revision), \
- .id = DT_STRING_TOKEN(DT_DRV_INST(n), device_id), \
- .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), \
- .error_on_msb_first = DT_INST_PROP(n, \
- error_on_msb_first_access), \
- .lsb_c_ir_read = 0, \
- .lsb_r_read = 0, \
- .lsb_g_read = 0, \
- .lsb_b_read = 0, \
- .common = { \
- .start_write = NULL, \
- .write_byte = tcs_emul_write_byte, \
- .finish_write = tcs_emul_handle_write, \
- .start_read = NULL, \
- .read_byte = tcs_emul_handle_read, \
- .finish_read = NULL, \
- .access_reg = NULL, \
- }, \
- }; \
- \
- static const struct i2c_common_emul_cfg tcs_emul_cfg_##n = { \
- .i2c_label = DT_INST_BUS_LABEL(n), \
- .dev_label = DT_INST_LABEL(n), \
- .data = &tcs_emul_data_##n.common, \
- .addr = DT_INST_REG_ADDR(n), \
- }; \
- EMUL_DEFINE(tcs_emul_init, DT_DRV_INST(n), &tcs_emul_cfg_##n, \
- &tcs_emul_data_##n)
-
-DT_INST_FOREACH_STATUS_OKAY(TCS3400_EMUL)
-
-#define TCS3400_EMUL_CASE(n) \
- case DT_INST_DEP_ORD(n): return &tcs_emul_data_##n.common.emul;
-
-/** Check description in emul_tcs3400.h */
-struct i2c_emul *tcs_emul_get(int ord)
-{
- switch (ord) {
- DT_INST_FOREACH_STATUS_OKAY(TCS3400_EMUL_CASE)
-
- default:
- return NULL;
- }
-}
diff --git a/zephyr/emul/i2c_mock.c b/zephyr/emul/i2c_mock.c
deleted file mode 100644
index 7c3722ad2e..0000000000
--- a/zephyr/emul/i2c_mock.c
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT cros_i2c_mock
-
-#include <device.h>
-#include "emul/emul_common_i2c.h"
-
-#include <logging/log.h>
-LOG_MODULE_REGISTER(i2c_mock, CONFIG_I2C_MOCK_LOG_LEVEL);
-
-struct i2c_emul *i2c_mock_to_i2c_emul(const struct emul *emul)
-{
- struct i2c_common_emul_data *data = emul->data;
-
- return &(data->emul);
-}
-
-void i2c_mock_reset(const struct emul *emul)
-{
- struct i2c_emul *i2c_emul = i2c_mock_to_i2c_emul(emul);
-
- i2c_common_emul_set_read_fail_reg(i2c_emul,
- I2C_COMMON_EMUL_NO_FAIL_REG);
- i2c_common_emul_set_write_fail_reg(i2c_emul,
- I2C_COMMON_EMUL_NO_FAIL_REG);
- i2c_common_emul_set_read_func(i2c_emul, NULL, NULL);
- i2c_common_emul_set_write_func(i2c_emul, NULL, NULL);
-}
-
-uint16_t i2c_mock_get_addr(const struct emul *emul)
-{
- const struct i2c_common_emul_cfg *cfg = emul->cfg;
-
- return cfg->addr;
-}
-
-static const struct i2c_emul_api i2c_mock_api = {
- .transfer = i2c_common_emul_transfer,
-};
-
-static int i2c_mock_init(const struct emul *emul,
- const struct device *parent)
-{
- const struct i2c_common_emul_cfg *cfg = emul->cfg;
- struct i2c_common_emul_data *data = emul->data;
-
- data->emul.api = &i2c_mock_api;
- data->emul.addr = cfg->addr;
- data->emul.parent = emul;
- data->i2c = parent;
- data->cfg = cfg;
- i2c_common_emul_init(data);
-
- return i2c_emul_register(parent, emul->dev_label, &data->emul);
-}
-
-#define INIT_I2C_MOCK(n) \
- static const struct i2c_common_emul_cfg i2c_mock_cfg_##n = { \
- .i2c_label = DT_INST_BUS_LABEL(n), \
- .dev_label = DT_INST_LABEL(n), \
- .addr = DT_INST_REG_ADDR(n), \
- }; \
- static struct i2c_common_emul_data i2c_mock_data_##n; \
- EMUL_DEFINE(i2c_mock_init, DT_DRV_INST(n), &i2c_mock_cfg_##n, \
- &i2c_mock_data_##n)
-
-DT_INST_FOREACH_STATUS_OKAY(INIT_I2C_MOCK)
diff --git a/zephyr/firmware_builder.py b/zephyr/firmware_builder.py
deleted file mode 100755
index 446ad20bee..0000000000
--- a/zephyr/firmware_builder.py
+++ /dev/null
@@ -1,226 +0,0 @@
-#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-"""Build and test all of the Zephyr boards.
-
-This is the entry point for the custom firmware builder workflow recipe.
-"""
-
-import argparse
-import multiprocessing
-import pathlib
-import subprocess
-import sys
-import zmake.project
-
-# TODO(crbug/1181505): Code outside of chromite should not be importing from
-# chromite.api.gen. Import json_format after that so we get the matching one.
-from chromite.api.gen.chromite.api import firmware_pb2
-from google.protobuf import json_format
-
-DEFAULT_BUNDLE_DIRECTORY = '/tmp/artifact_bundles'
-DEFAULT_BUNDLE_METADATA_FILE = '/tmp/artifact_bundle_metadata'
-
-
-def build(opts):
- """Builds all Zephyr firmware targets"""
- # TODO(b/169178847): Add appropriate metric information
- metrics = firmware_pb2.FwBuildMetricList()
- with open(opts.metrics, 'w') as f:
- f.write(json_format.MessageToJson(metrics))
-
- targets = [
- 'projects/kohaku',
- 'projects/posix-ec',
- 'projects/volteer/volteer',
- ]
- for target in targets:
- print('Building {}'.format(target))
- cmd = ['zmake', '-D', 'configure', '-b', target]
- rv = subprocess.run(cmd, cwd=pathlib.Path(__file__).parent).returncode
- if rv != 0:
- return rv
- return 0
-
-
-def bundle(opts):
- if opts.code_coverage:
- bundle_coverage(opts)
- else:
- bundle_firmware(opts)
-
-
-def get_bundle_dir(opts):
- """Get the directory for the bundle from opts or use the default.
-
- Also create the directory if it doesn't exist."""
- bundle_dir = (opts.output_dir
- if opts.output_dir else DEFAULT_BUNDLE_DIRECTORY)
- bundle_dir = pathlib.Path(bundle_dir)
- if not bundle_dir.is_dir():
- bundle_dir.mkdir()
- return bundle_dir
-
-
-def write_metadata(opts, info):
- """Write the metadata about the bundle."""
- bundle_metadata_file = (opts.metadata
- if opts.metadata else DEFAULT_BUNDLE_METADATA_FILE)
- with open(bundle_metadata_file, 'w') as f:
- f.write(json_format.MessageToJson(info))
-
-
-def bundle_coverage(opts):
- """Bundles the artifacts from code coverage into its own tarball."""
- info = firmware_pb2.FirmwareArtifactInfo()
- info.bcs_version_info.version_string = opts.bcs_version
- bundle_dir = get_bundle_dir(opts)
- zephyr_dir = pathlib.Path(__file__).parent
- platform_ec = zephyr_dir.resolve().parent
- build_dir = platform_ec / 'build/zephyr-coverage'
- tarball_name = 'coverage.tbz2'
- tarball_path = bundle_dir / tarball_name
- cmd = ['tar', 'cvfj', tarball_path, 'lcov.info']
- subprocess.run(cmd, cwd=build_dir, check=True)
- meta = info.objects.add()
- meta.file_name = tarball_name
- meta.lcov_info.type = firmware_pb2.FirmwareArtifactInfo.LcovTarballInfo.LcovType.LCOV
-
- write_metadata(opts, info)
-
-
-
-def bundle_firmware(opts):
- """Bundles the artifacts from each target into its own tarball."""
- info = firmware_pb2.FirmwareArtifactInfo()
- info.bcs_version_info.version_string = opts.bcs_version
- bundle_dir = get_bundle_dir(opts)
- zephyr_dir = pathlib.Path(__file__).parent
- platform_ec = zephyr_dir.resolve().parent
- for project in zmake.project.find_projects(zephyr_dir):
- build_dir = zmake.util.resolve_build_dir(platform_ec,
- project.project_dir, None)
- artifacts_dir = build_dir / 'output'
- # TODO(kmshelton): Remove once the build command does not rely
- # on a pre-defined list of targets.
- if not artifacts_dir.is_dir():
- continue
- project_identifier = '_'.join(
- project.project_dir.
- parts[project.project_dir.parts.index('projects') + 1:])
- tarball_name = '{}.firmware.tbz2'.format(project_identifier)
- tarball_path = bundle_dir.joinpath(tarball_name)
- cmd = ['tar', 'cvfj', tarball_path, '.']
- subprocess.run(cmd, cwd=artifacts_dir, check=True)
- meta = info.objects.add()
- meta.file_name = tarball_name
- meta.tarball_info.type = (
- firmware_pb2.FirmwareArtifactInfo.TarballInfo.FirmwareType.EC)
- # TODO(kmshelton): Populate the rest of metadata contents as it
- # gets defined in infra/proto/src/chromite/api/firmware.proto.
-
- write_metadata(opts, info)
-
-
-def test(opts):
- """Runs all of the unit tests for Zephyr firmware"""
- # TODO(b/169178847): Add appropriate metric information
- metrics = firmware_pb2.FwTestMetricList()
- with open(opts.metrics, 'w') as f:
- f.write(json_format.MessageToJson(metrics))
-
- zephyr_dir = pathlib.Path(__file__).parent.resolve()
-
- # Run zmake tests to ensure we have a fully working zmake before
- # proceeding.
- subprocess.run([zephyr_dir / 'zmake' / 'run_tests.sh'], check=True)
-
- subprocess.run(['zmake', '-D', 'testall'], check=True)
-
- # Run the test with coverage also, as sometimes they behave differently.
- platform_ec = zephyr_dir.parent
- build_dir = platform_ec / 'build/zephyr-coverage'
- return subprocess.run(
- ['zmake', '-D', 'coverage', build_dir], cwd=platform_ec).returncode
-
-
-def main(args):
- """Builds and tests all of the Zephyr targets and reports build metrics"""
- opts = parse_args(args)
-
- if not hasattr(opts, 'func'):
- print("Must select a valid sub command!")
- return -1
-
- # Run selected sub command function
- return opts.func(opts)
-
-
-def parse_args(args):
- parser = argparse.ArgumentParser(description=__doc__)
-
- parser.add_argument(
- '--cpus',
- default=multiprocessing.cpu_count(),
- help='The number of cores to use.',
- )
-
- parser.add_argument(
- '--metrics',
- dest='metrics',
- required=True,
- help='File to write the json-encoded MetricsList proto message.',
- )
-
- parser.add_argument(
- '--metadata',
- required=False,
- help=('Full pathname for the file in which to write build artifact '
- 'metadata.'),
- )
-
- parser.add_argument(
- '--output-dir',
- required=False,
- help=
- 'Full pathanme for the directory in which to bundle build artifacts.',
- )
-
- parser.add_argument(
- '--code-coverage',
- required=False,
- action='store_true',
- help='Build host-based unit tests for code coverage.',
- )
-
- parser.add_argument(
- '--bcs-version',
- dest='bcs_version',
- default='',
- required=False,
- # TODO(b/180008931): make this required=True.
- help='BCS version to include in metadata.',
- )
-
- # Would make this required=True, but not available until 3.7
- sub_cmds = parser.add_subparsers()
-
- build_cmd = sub_cmds.add_parser('build',
- help='Builds all firmware targets')
- build_cmd.set_defaults(func=build)
-
- build_cmd = sub_cmds.add_parser('bundle',
- help='Creates a tarball containing build '
- 'artifacts from all firmware targets')
- build_cmd.set_defaults(func=bundle)
-
- test_cmd = sub_cmds.add_parser('test', help='Runs all firmware unit tests')
- test_cmd.set_defaults(func=test)
-
- return parser.parse_args(args)
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv[1:]))
diff --git a/zephyr/fpu.cmake b/zephyr/fpu.cmake
deleted file mode 100644
index 5f1c698b15..0000000000
--- a/zephyr/fpu.cmake
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-#[[
-Disclaimer: the following example is pieced together from
-https://lemire.me/blog/2020/06/26/gcc-not-nearest/ along with other information
-found in GCC documentation.
-
-The following flags are needed to to ensure consistent FPU rounding in unit
-tests. For example using GNU GCC 7.5 rounds down. Note that at the time of
-writing, Clang 13.0.0 passes all the FPU unit tests without these flags.
-
-Some of the sensor logic which requires FPU support is susceptible to rounding
-errors. In GCC 7.5, as an example:
-
- double x = 50178230318.0;
- double y = 100000000000.0;
- double ratio = x/y;
-
-In this example, we would expect ratio to be 0.50178230318. Instead, using a
-64-bit float, it falls between:
-* The floating-point number 0.501782303179999944 == 4519653187245114 * 2 ** -53
-* The floating-point number 0.501782303180000055 == 4519653187245115 * 2 ** -53
-
-The real mantissa using the same logic should be:
-0.50178230318 = 4519653187245114.50011795456 * 2 ** -53
-
-Since the mantissa's decimal is just over 0.5, it should stand to reason that
-the correct solution is 0.501782303180000055. To force GCC to round correctly
-we must set the following modes:
-1. 'sse' - Generate SSE instructions.
-2. 'fpmath=sse' - Use scalar floating-point instructions present in the SSE
- instruction set.
-3. 'arch=pentium4' - Choose the Pentium4 because it's a stable choice that
- supports SSE and is known to work (there may be other good choices).
-]]
-if(DEFINED CONFIG_SOC_POSIX)
- zephyr_cc_option(-msse -mfpmath=sse -march=pentium4)
-endif()
diff --git a/zephyr/gcov.tmpl.sh b/zephyr/gcov.tmpl.sh
deleted file mode 100755
index 96bd82ab51..0000000000
--- a/zephyr/gcov.tmpl.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-exec ${CMAKE_GCOV} "$@"
diff --git a/zephyr/hayato_get_cfg.sh b/zephyr/hayato_get_cfg.sh
deleted file mode 100755
index 5ebe3dc364..0000000000
--- a/zephyr/hayato_get_cfg.sh
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/bin/bash
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# This is an example script showing how to compare configs on hayato
-
-# Usage of this script:
-# - set the three variables below
-# - set up the ecos.conf3 file as follows:
-# $ make print-configs BOARD=hayato >econ.conf
-# $ grep CONFIG ecos.conf |sort |uniq >ecos.conf2
-# $ cat ecos.conf2 |awk '{print $1}' >ecos.conf3
-# - configure and build hayato for zephyr
-# $ zmake configure -B /tmp/z/hay zephyr/projects/asurada/hayato/ -t zephyr -b
-# - run this script to check for CONFIG mismatches
-# $ zephyr/get_cfg.sh
-
-set -e
-
-dir=/tmp/z/hay
-subdir=build-singleimage
-in=~/cosarm/src/platform/ec/ecos.conf3
-
-cd "${dir}"
-pushd "${subdir}"
-
-# This is created by running:
-#
-# ninja -v -C /tmp/z/hay/build-singleimage
-#
-# then replacing '-C' by '-E -dM'
-# The idea is to get a list of the #defines used to compile the code
-ccache /opt/zephyr-sdk/riscv64-zephyr-elf/bin/riscv64-zephyr-elf-gcc -DBUILD_VERSION=zephyr-v2.5.0-101-g7a99b4a3ee12 -DCHROMIUM_EC -DCONFIG_ZEPHYR -DKERNEL -D_FORTIFY_SOURCE=2 -D__ZEPHYR__=1 -I/scratch/sglass/cosarm/src/platform/ec/zephyr/include -I/tmp/z/hay/modules/ec/zephyr/shim/include -I/tmp/z/hay/modules/ec/fuzz -I/tmp/z/hay/modules/ec/test -I/tmp/z/hay/modules/ec/include -I/tmp/z/hay/modules/ec/include/driver -I/tmp/z/hay/modules/ec/third_party -I/scratch/sglass/cosarm/src/platform/ec/zephyr/app/ec/include -I/scratch/sglass/cosarm/src/platform/ec/zephyr/shim/chip/it8xxx2/include -I/scratch/sglass/cosarm/src/third_party/zephyr/main/v2.5/include -Izephyr/include/generated -I/scratch/sglass/cosarm/src/third_party/zephyr/main/v2.5/soc/riscv/riscv-ite/it8xxx2 -I/scratch/sglass/cosarm/src/third_party/zephyr/main/v2.5/soc/riscv/riscv-ite/common/. -Iec/include/generated -I/scratch/sglass/cosarm/src/platform/ec/zephyr/projects/asurada/hayato/include -isystem /scratch/sglass/cosarm/src/third_party/zephyr/main/v2.5/lib/libc/minimal/include -isystem /opt/zephyr-sdk/riscv64-zephyr-elf/bin/../lib/gcc/riscv64-zephyr-elf/9.2.0/include -isystem /opt/zephyr-sdk/riscv64-zephyr-elf/bin/../lib/gcc/riscv64-zephyr-elf/9.2.0/include-fixed -Os -imacros /tmp/z/hay/build-singleimage/zephyr/include/generated/autoconf.h -ffreestanding -fno-common -g -mabi=ilp32 -march=rv32imac -imacros /scratch/sglass/cosarm/src/third_party/zephyr/main/v2.5/include/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-main -Wno-pointer-sign -Wpointer-arith -Wno-address-of-packed-member -Wno-unused-but-set-variable -Werror=implicit-int -fno-asynchronous-unwind-tables -fno-pie -fno-pic -fno-strict-overflow -fno-reorder-functions -fno-defer-pop -fmacro-prefix-map=/scratch/sglass/cosarm/src/platform/ec/zephyr/projects/asurada/hayato=CMAKE_SOURCE_DIR -fmacro-prefix-map=/scratch/sglass/cosarm/src/third_party/zephyr/main/v2.5=ZEPHYR_BASE -ffunction-sections -fdata-sections -march=rv32i -std=c99 -nostdinc -MD -MT CMakeFiles/app.dir/tmp/z/hay/modules/ec/common/virtual_battery.c.obj -MF CMakeFiles/app.dir/tmp/z/hay/modules/ec/common/virtual_battery.c.obj.d \
- -o /tmp/z/hay/zephyr.conf -E -dM \
- /tmp/z/hay/modules/ec/common/virtual_battery.c
-popd
-
-sort <zephyr.conf >zephyr.conf2
-
-# Only look at CONFIG_xxx where xxx does not start with PLATFORM_EC
-grep <zephyr.conf2 -P 'CONFIG_(?!PLATFORM_EC)[A-Z]+' | \
- awk '{print $2}' | \
- sort >zephyr.conf3
-comm -23 "${in}" zephyr.conf3
diff --git a/zephyr/include/cros/binman.dtsi b/zephyr/include/cros/binman.dtsi
deleted file mode 100644
index 82bb801e6c..0000000000
--- a/zephyr/include/cros/binman.dtsi
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/dts-v1/;
-
-/ {
- #address-cells = <1>;
- #size-cells = <1>;
- binman {
- filename = "zephyr.bin";
- pad-byte = <0x1d>;
- wp-ro {
- compatible = "cros-ec,flash-layout";
- type = "section";
- offset = <0x0>;
- size = <0x40000>;
- read-only;
- ec-ro {
- type = "section";
- ro-fw {
- type = "blob";
- filename = "zephyr_ro.bin";
- };
- fmap {
- };
- ro-frid {
- type = "text";
- size = <32>;
- text-label = "version";
- };
- };
- };
- ec-rw {
- compatible = "cros-ec,flash-layout";
- type = "section";
- offset = <0x40000>;
- size = <0x40000>;
- rw-fw {
- type = "blob";
- filename = "zephyr_rw.bin";
- };
- rw-fwid {
- type = "text";
- size = <32>;
- text-label = "version";
- };
- };
- };
-};
diff --git a/zephyr/include/cros/ite/it8xxx2.dtsi b/zephyr/include/cros/ite/it8xxx2.dtsi
deleted file mode 100644
index 54ca7f63e3..0000000000
--- a/zephyr/include/cros/ite/it8xxx2.dtsi
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <cros/binman.dtsi>
-
-/ {
- named-bbram-regions {
- compatible = "named-bbram-regions";
-
- scratchpad {
- offset = <0x08>;
- size = <0x04>;
- };
- saved-reset-flags {
- offset = <0x00>;
- size = <0x04>;
- };
- wake {
- offset = <0x08>;
- size = <0x04>;
- };
- pd0 {
- offset = <0x04>;
- size = <0x01>;
- };
- pd1 {
- offset = <0x05>;
- size = <0x01>;
- };
- try_slot {
- offset = <0x0e>;
- size = <0x01>;
- };
- pd2 {
- offset = <0x06>;
- size = <0x01>;
- };
- };
-
- soc {
- bbram: bb-ram@f02200 {
- #address-cells = <1>;
- #size-cells = <1>;
- compatible = "ite,it8xxx2-cros-bbram";
- status = "okay";
- reg = <0x00f02200 0xbf>;
- reg-names = "memory";
- label = "BBRAM";
- };
-
- shi: shi@f03a00 {
- compatible = "ite,it8xxx2-cros-shi";
- reg = <0x00f03a00 0x30>;
- label = "SHI";
- interrupts = <171 0>;
- interrupt-parent = <&intc>;
- pinctrl-0 = <&pinctrl_shi_mosi /* GPM0 */
- &pinctrl_shi_miso /* GPM1 */
- &pinctrl_shi_clk /* GPM4 */
- &pinctrl_shi_cs>; /* GPM5 */
- };
-
- fiu0: cros-flash@80000000 {
- compatible = "ite,it8xxx2-cros-flash";
- reg = <0x80000000 0x100000>;
- label = "FLASH";
- };
- };
-
- /* it8xxx2 has 1MB of flash. currently, we use 512KB from flash. */
- binman {
- wp-ro {
- offset = <0x0>;
- size = <0x40000>;
- };
- ec-rw {
- offset = <0x40000>;
- size = <0x40000>;
- };
- };
-};
diff --git a/zephyr/include/cros/nuvoton/npcx.dtsi b/zephyr/include/cros/nuvoton/npcx.dtsi
deleted file mode 100644
index 9c84d5712d..0000000000
--- a/zephyr/include/cros/nuvoton/npcx.dtsi
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2021 The Chromium OS Authors
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-/dts-v1/;
-
-#include <cros/binman.dtsi>
-#include <nuvoton/npcx.dtsi>
-
-/ {
-
- named-bbram-regions {
- compatible = "named-bbram-regions";
-
- scratchpad {
- offset = <0x00>;
- size = <0x04>;
- };
- saved-reset-flags {
- offset = <0x04>;
- size = <0x04>;
- };
- wake {
- offset = <0x08>;
- size = <0x04>;
- };
- pd0 {
- offset = <0x0c>;
- size = <0x01>;
- };
- pd1 {
- offset = <0x0d>;
- size = <0x01>;
- };
- try_slot {
- offset = <0x0e>;
- size = <0x01>;
- };
- pd2 {
- offset = <0x0f>;
- size = <0x01>;
- };
- ramlog {
- offset = <0x20>;
- size = <0x01>;
- };
- panic_flags {
- offset = <0x23>;
- size = <0x01>;
- };
- panic_bkup {
- offset = <0x24>;
- size = <0x1c>;
- };
- lct_time {
- offset = <0x40>;
- size = <0x04>;
- };
- };
-
- soc {
-
- cros_kb_raw: cros-kb-raw@400a3000 {
- compatible = "nuvoton,npcx-cros-kb-raw";
- reg = <0x400a3000 0x2000>;
- label = "CROS_KB_RAW_0";
- interrupts = <49 4>;
- clocks = <&pcc NPCX_CLOCK_BUS_APB1 NPCX_PWDWN_CTL1 0>;
- /*
- * No KSO2 (It's inverted and implemented by GPIO for
- * CONFIG_KEYBOARD_COL2_INVERTED.)
- */
- pinctrl-0 = <&alt7_no_ksi0_sl
- &alt7_no_ksi1_sl
- &alt7_no_ksi2_sl
- &alt7_no_ksi3_sl
- &alt7_no_ksi4_sl
- &alt7_no_ksi5_sl
- &alt7_no_ksi6_sl
- &alt7_no_ksi7_sl
- &alt8_no_kso00_sl
- &alt8_no_kso01_sl
- &alt8_no_kso03_sl
- &alt8_no_kso04_sl
- &alt8_no_kso05_sl
- &alt8_no_kso06_sl
- &alt8_no_kso07_sl
- &alt9_no_kso08_sl
- &alt9_no_kso09_sl
- &alt9_no_kso10_sl
- &alt9_no_kso11_sl
- &alt9_no_kso12_sl
- &alt9_no_kso13_sl
- &alt9_no_kso14_sl
- &alt9_no_kso15_sl
- &alta_no_kso16_sl
- &alta_no_kso17_sl
- >;
- wui_maps = <&wui_io31 &wui_io30 &wui_io27 &wui_io26
- &wui_io25 &wui_io24 &wui_io23 &wui_io22>;
- };
-
- mtc: mtc@400b7000 {
- compatible = "nuvoton,npcx-cros-mtc";
- reg = <0x400b7000 0x2000>;
- mtc-alarm = <&wui_mtc>;
- label = "MTC";
- };
-
- fiu0: cros-flash@40020000 {
- compatible = "nuvoton,npcx-cros-flash";
- reg = <0x40020000 0x2000>;
- clocks = <&pcc NPCX_CLOCK_BUS_APB3 NPCX_PWDWN_CTL1 2>;
- size = <0x80000>;
- label = "FLASH_INTERFACE_UNIT0";
- pinctrl-0 = <>;
- };
-
- shi: shi@4000f000 {
- compatible = "nuvoton,npcx-cros-shi";
- reg = <0x4000f000 0x120>;
- interrupts = <18 1>;
- clocks = <&pcc NPCX_CLOCK_BUS_APB3 NPCX_PWDWN_CTL5 1>;
- pinctrl-0 = <&altc_shi_sl>;
- shi-cs-wui =<&wui_io53>;
- label = "SHI";
- };
- };
-
- power-states {
- suspend_to_idle_instant: suspend_to_idle_instant {
- compatible = "zephyr,power-state";
- power-state-name = "suspend-to-idle";
- substate-id = <0>;
- min-residency-us = <500>;
- };
-
- suspend_to_idle_normal: suspend_to_idle_normal {
- compatible = "zephyr,power-state";
- power-state-name = "suspend-to-idle";
- substate-id = <1>;
- min-residency-us = <200100>;
- };
- };
-};
-
-&cpu0 {
- cpu-power-states = <&suspend_to_idle_instant &suspend_to_idle_normal>;
-};
-
-&bbram {
- status = "okay";
-};
-
-&mdc {
- status = "okay";
-};
diff --git a/zephyr/include/cros/nuvoton/npcx7.dtsi b/zephyr/include/cros/nuvoton/npcx7.dtsi
deleted file mode 100644
index 0526341e2c..0000000000
--- a/zephyr/include/cros/nuvoton/npcx7.dtsi
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2021 The Chromium OS Authors
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-/dts-v1/;
-
-#include <cros/nuvoton/npcx.dtsi>
-
-/ {
-
- soc {
-
- dbg: dbg@400c3074 {
- compatible = "nuvoton,npcx-cros-dbg";
- reg = <0x400c3074 0x0C>;
- pinctrl-0 = <&alt5_njen0_en>;
- label = "DBG";
- status = "disabled";
- };
- };
-
-};
diff --git a/zephyr/include/cros/nuvoton/npcx9.dtsi b/zephyr/include/cros/nuvoton/npcx9.dtsi
deleted file mode 100644
index de492d3306..0000000000
--- a/zephyr/include/cros/nuvoton/npcx9.dtsi
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (c) 2021 The Chromium OS Authors
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-/dts-v1/;
-
-#include <cros/nuvoton/npcx.dtsi>
-
-/ {
- soc {
-
- };
-};
diff --git a/zephyr/include/cros/thermistor/thermistor.dtsi b/zephyr/include/cros/thermistor/thermistor.dtsi
deleted file mode 100644
index 033d5639e2..0000000000
--- a/zephyr/include/cros/thermistor/thermistor.dtsi
+++ /dev/null
@@ -1,308 +0,0 @@
-/ {
- thermistor_3V3_30K9_47K_4050B: thermistor-3V3-30K9-47K-4050B {
- status = "disabled";
- compatible = "cros-ec,thermistor";
- scaling-factor = <11>;
- num-pairs = <10>;
- steinhart-reference-mv = <3300>;
- steinhart-reference-res = <30900>;
-
- /*
- * Data derived from Steinhart-Hart equation in a resistor
- * divider circuit with Vdd=3300mV, R = 30.9Kohm, and thermistor
- * (B = 4050, T0 = 298.15 K, nominal resistance (R0) = 47Kohm).
- */
- sample-datum-0 {
- milivolt = <(2753 / 11)>;
- temp = <0>;
- sample-index = <0>;
- };
- sample-datum-1 {
- milivolt = <(2487 / 11)>;
- temp = <10>;
- sample-index = <1>;
- };
- sample-datum-2 {
- milivolt = <(2165 / 11)>;
- temp = <20>;
- sample-index = <2>;
- };
- sample-datum-3 {
- milivolt = <(1813 / 11)>;
- temp = <30>;
- sample-index = <3>;
- };
- sample-datum-4 {
- milivolt = <(1145 / 11)>;
- temp = <50>;
- sample-index = <4>;
- };
- sample-datum-5 {
- milivolt = <(878 / 11)>;
- temp = <60>;
- sample-index = <5>;
- };
- sample-datum-6 {
- milivolt = <(665 / 11)>;
- temp = <70>;
- sample-index = <6>;
- };
- sample-datum-7 {
- milivolt = <(500 / 11)>;
- temp = <80>;
- sample-index = <7>;
- };
- sample-datum-8 {
- milivolt = <(375 / 11)>;
- temp = <90>;
- sample-index = <8>;
- };
- sample-datum-9 {
- milivolt = <(282 / 11)>;
- temp = <100>;
- sample-index = <9>;
- };
- };
-
-
- thermistor_3V0_22K6_47K_4050B: thermistor-3V0-22K6-47K-4050B {
- status = "disabled";
- compatible = "cros-ec,thermistor";
- scaling-factor = <11>;
- num-pairs = <13>;
- steinhart-reference-mv = <3000>;
- steinhart-reference-res = <22600>;
-
- /*
- * Data derived from Steinhart-Hart equation in a resistor
- * divider circuit with Vdd=3000mV, R = 22.6Kohm, and thermistor
- * (B = 4050, T0 = 298.15 K, nominal resistance (R0) = 47Kohm).
- */
- sample-datum-0 {
- milivolt = <( 2619 / 11)>;
- temp = <0>;
- sample-index = <0>;
- };
- sample-datum-1 {
- milivolt = <( 2421 / 11)>;
- temp = <10>;
- sample-index = <1>;
- };
- sample-datum-2 {
- milivolt = <( 2168 / 11)>;
- temp = <20>;
- sample-index = <2>;
- };
- sample-datum-3 {
- milivolt = <( 1875 / 11)>;
- temp = <30>;
- sample-index = <3>;
- };
- sample-datum-4 {
- milivolt = <( 1563 / 11)>;
- temp = <40>;
- sample-index = <4>;
- };
- sample-datum-5 {
- milivolt = <( 1262 / 11)>;
- temp = <50>;
- sample-index = <5>;
- };
- sample-datum-6 {
- milivolt = <( 994 / 11)>;
- temp = <60>;
- sample-index = <6>;
- };
- sample-datum-7 {
- milivolt = <( 769 / 11)>;
- temp = <70>;
- sample-index = <7>;
- };
- sample-datum-8 {
- milivolt = <( 588 / 11)>;
- temp = <80>;
- sample-index = <8>;
- };
- sample-datum-9 {
- milivolt = <( 513 / 11)>;
- temp = <85>;
- sample-index = <9>;
- };
- sample-datum-10 {
- milivolt = <( 448 / 11)>;
- temp = <90>;
- sample-index = <10>;
- };
- sample-datum-11 {
- milivolt = <( 390 / 11)>;
- temp = <95>;
- sample-index = <11>;
- };
- sample-datum-12 {
- milivolt = <( 340 / 11)>;
- temp = <100>;
- sample-index = <12>;
- };
- };
-
- thermistor_3V3_13K7_47K_4050B: thermistor-3V3-13K7-47K-4050B {
- status = "disabled";
- compatible = "cros-ec,thermistor";
- scaling-factor = <13>;
- num-pairs = <13>;
- steinhart-reference-mv = <3300>;
- steinhart-reference-res = <13700>;
-
- /*
- * Data derived from Steinhart-Hart equation in a resistor
- * divider circuit with Vdd=3300mV, R = 13.7Kohm, and thermistor
- * (B = 4050, T0 = 298.15 K, nominal resistance (R0) = 47Kohm).
- */
- sample-datum-0 {
- milivolt = <(3033 / 13)>;
- temp = <0>;
- sample-index = <0>;
- };
- sample-datum-1 {
- milivolt = <(2882 / 13)>;
- temp = <10>;
- sample-index = <1>;
- };
- sample-datum-2 {
- milivolt = <(2677 / 13)>;
- temp = <20>;
- sample-index = <2>;
- };
- sample-datum-3 {
- milivolt = <(2420 / 13)>;
- temp = <30>;
- sample-index = <3>;
- };
- sample-datum-4 {
- milivolt = <(2119 / 13)>;
- temp = <40>;
- sample-index = <4>;
- };
- sample-datum-5 {
- milivolt = <(1799 / 13)>;
- temp = <50>;
- sample-index = <5>;
- };
- sample-datum-6 {
- milivolt = <(1485 / 13)>;
- temp = <60>;
- sample-index = <6>;
- };
- sample-datum-7 {
- milivolt = <(1197 / 13)>;
- temp = <70>;
- sample-index = <7>;
- };
- sample-datum-8 {
- milivolt = <( 947 / 13)>;
- temp = <80>;
- sample-index = <8>;
- };
- sample-datum-9 {
- milivolt = <( 839 / 13)>;
- temp = <85>;
- sample-index = <9>;
- };
- sample-datum-10 {
- milivolt = <( 741 / 13)>;
- temp = <90>;
- sample-index = <10>;
- };
- sample-datum-11 {
- milivolt = <( 653 / 13)>;
- temp = <95>;
- sample-index = <11>;
- };
- sample-datum-12 {
- milivolt = <( 576 / 13)>;
- temp = <100>;
- sample-index = <12>;
- };
- };
-
-
- thermistor_3V3_51K1_47K_4050B: thermistor-3V3-51K1-47K-4050B {
- status = "disabled";
- compatible = "cros-ec,thermistor";
- scaling-factor = <11>;
- num-pairs = <13>;
- steinhart-reference-mv = <3300>;
- steinhart-reference-res = <51100>;
-
- /*
- * Data derived from Steinhart-Hart equation in a resistor
- * divider circuit with Vdd=3300mV, R = 51.1Kohm, and thermistor
- * (B = 4050, T0 = 298.15 K, nominal resistance (R0) = 47Kohm).
- */
- sample-datum-0 {
- milivolt = <(2484 / 11)>;
- temp = <0>;
- sample-index = <0>;
- };
- sample-datum-1 {
- milivolt = <(2142 / 11)>;
- temp = <10>;
- sample-index = <1>;
- };
- sample-datum-2 {
- milivolt = <(1767 / 11)>;
- temp = <20>;
- sample-index = <2>;
- };
- sample-datum-3 {
- milivolt = <(1400 / 11)>;
- temp = <30>;
- sample-index = <3>;
- };
- sample-datum-4 {
- milivolt = <(1072 / 11)>;
- temp = <40>;
- sample-index = <4>;
- };
- sample-datum-5 {
- milivolt = <( 802 / 11)>;
- temp = <50>;
- sample-index = <5>;
- };
- sample-datum-6 {
- milivolt = <( 593 / 11)>;
- temp = <60>;
- sample-index = <6>;
- };
- sample-datum-7 {
- milivolt = <( 436 / 11)>;
- temp = <70>;
- sample-index = <7>;
- };
- sample-datum-8 {
- milivolt = <( 321 / 11)>;
- temp = <80>;
- sample-index = <8>;
- };
- sample-datum-9 {
- milivolt = <( 276 / 11)>;
- temp = <85>;
- sample-index = <9>;
- };
- sample-datum-10 {
- milivolt = <( 237 / 11)>;
- temp = <90>;
- sample-index = <10>;
- };
- sample-datum-11 {
- milivolt = <( 204 / 11)>;
- temp = <95>;
- sample-index = <11>;
- };
- sample-datum-12 {
- milivolt = <( 177 / 11)>;
- temp = <100>;
- sample-index = <12>;
- };
- };
-};
diff --git a/zephyr/include/drivers/cros_cbi.h b/zephyr/include/drivers/cros_cbi.h
deleted file mode 100644
index aa55e03b77..0000000000
--- a/zephyr/include/drivers/cros_cbi.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * @file
- * @brief Chrome OS-specific API for access to Cros Board Info(CBI)
- */
-
-#ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_CBI_H_
-#define ZEPHYR_INCLUDE_DRIVERS_CROS_CBI_H_
-
-#include <kernel.h>
-#include <device.h>
-#include <devicetree.h>
-
-#define CBI_SSFC_VALUE_COMPAT named_cbi_ssfc_value
-#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, _) \
- CBI_SSFC_VALUE_ID_WITH_COMMA(DT_INST(inst, CBI_SSFC_VALUE_COMPAT))
-#define CROS_CBI_LABEL "cros_cbi"
-
-enum cbi_ssfc_value_id {
- UTIL_LISTIFY(DT_NUM_INST_STATUS_OKAY(CBI_SSFC_VALUE_COMPAT),
- CBI_SSFC_VALUE_INST_ENUM)
- CBI_SSFC_VALUE_COUNT
-};
-
-/**
- * @cond INTERNAL_HIDDEN
- *
- * cros cbi raw driver API definition and system call entry points
- *
- * (Internal use only.)
- */
-typedef int (*cros_cbi_api_init)(const struct device *dev);
-typedef int (*cros_cbi_api_ssfc_check_match)(const struct device *dev,
- enum cbi_ssfc_value_id value_id);
-
-__subsystem struct cros_cbi_driver_api {
- cros_cbi_api_init init;
- cros_cbi_api_ssfc_check_match ssfc_check_match;
-};
-
-/**
- * @endcond
- */
-
-/**
- * @brief Initialize CBI.
- *
- * @param dev Pointer to the device structure for the CBI instance.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_cbi_init(const struct device *dev);
-
-static inline int z_impl_cros_cbi_init(const struct device *dev)
-{
- const struct cros_cbi_driver_api *api =
- (const struct cros_cbi_driver_api *)dev->api;
-
- if (!api->init) {
- return -ENOTSUP;
- }
-
- return api->init(dev);
-}
-
-/**
- * @brief Check if the CBI SSFC value matches the one in the EEPROM
- *
- * @param dev Pointer to the device.
- *
- * @return 1 If matches, 0 if not.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_cbi_ssfc_check_match(const struct device *dev,
- enum cbi_ssfc_value_id value_id);
-
-static inline int
-z_impl_cros_cbi_ssfc_check_match(const struct device *dev,
- enum cbi_ssfc_value_id value_id)
-{
- const struct cros_cbi_driver_api *api =
- (const struct cros_cbi_driver_api *)dev->api;
-
- if (!api->ssfc_check_match) {
- return -ENOTSUP;
- }
-
- return api->ssfc_check_match(dev, value_id);
-}
-
-/**
- * @}
- */
-#include <syscalls/cros_cbi.h>
-#endif /* ZEPHYR_INCLUDE_DRIVERS_CROS_CBI_H_ */
diff --git a/zephyr/include/drivers/cros_flash.h b/zephyr/include/drivers/cros_flash.h
deleted file mode 100644
index 7f48cf7285..0000000000
--- a/zephyr/include/drivers/cros_flash.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-/**
- * @file
- * @brief Chrome OS-specific API for flash memory access
- * This exists only support the interface expected by the Chrome OS EC. It seems
- * better to implement this so we can make use of most of the existing code in
- * its keyboard_scan.c file and thus make sure we operate the same way.
- *
- * It provides raw access to flash memory module.
- */
-
-#ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_FLASH_H_
-#define ZEPHYR_INCLUDE_DRIVERS_CROS_FLASH_H_
-
-#include <kernel.h>
-#include <device.h>
-
-/**
- * @brief CROS Flash Driver APIs
- * @defgroup cros_flash_interface CROS Flash Driver APIs
- * @ingroup io_interfaces
- * @{
- */
-
-/**
- * @cond INTERNAL_HIDDEN
- *
- * cros keyboard raw driver API definition and system call entry points
- *
- * (Internal use only.)
- */
-typedef int (*cros_flash_api_init)(const struct device *dev);
-
-typedef int (*cros_flash_api_physical_read)(const struct device *dev,
- int offset, int size, char *data);
-
-typedef int (*cros_flash_api_physical_write)(const struct device *dev,
- int offset, int size,
- const char *data);
-
-typedef int (*cros_flash_api_physical_erase)(const struct device *dev,
- int offset, int size);
-
-typedef int (*cros_flash_api_physical_get_protect)(const struct device *dev,
- int bank);
-
-typedef uint32_t
-(*cros_flash_api_physical_get_protect_flags)(const struct device *dev);
-
-typedef int (*cros_flash_api_physical_protect_at_boot)(const struct device *dev,
- uint32_t new_flags);
-
-typedef int (*cros_flash_api_physical_protect_now)(const struct device *dev,
- int all);
-
-__subsystem struct cros_flash_driver_api {
- cros_flash_api_init init;
- cros_flash_api_physical_read physical_read;
- cros_flash_api_physical_write physical_write;
- cros_flash_api_physical_erase physical_erase;
- cros_flash_api_physical_get_protect physical_get_protect;
- cros_flash_api_physical_get_protect_flags physical_get_protect_flags;
- cros_flash_api_physical_protect_at_boot physical_protect_at_boot;
- cros_flash_api_physical_protect_now physical_protect_now;
-};
-
-/**
- * @endcond
- */
-
-/**
- * @brief Initialize physical flash.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_init(const struct device *dev);
-
-static inline int z_impl_cros_flash_init(const struct device *dev)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->init) {
- return -ENOTSUP;
- }
-
- return api->init(dev);
-}
-
-/**
- * @brief Read from physical flash.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- * @param offset Flash offset to read.
- * @param size Number of bytes to read.
- * @param data Destination buffer for data. Must be 32-bit aligned.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_physical_read(const struct device *dev, int offset,
- int size, char *data);
-
-static inline int z_impl_cros_flash_physical_read(const struct device *dev,
- int offset, int size,
- char *data)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_read) {
- return -ENOTSUP;
- }
-
- return api->physical_read(dev, offset, size, data);
-}
-
-/**
- * @brief Write to physical flash.
- *
- * Offset and size must be a multiple of CONFIG_FLASH_WRITE_SIZE.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- * @param offset Flash offset to write.
- * @param size Number of bytes to write.
- * @param data Destination buffer for data. Must be 32-bit aligned.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_physical_write(const struct device *dev, int offset,
- int size, const char *data);
-
-static inline int z_impl_cros_flash_physical_write(const struct device *dev,
- int offset, int size,
- const char *data)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_write) {
- return -ENOTSUP;
- }
-
- return api->physical_write(dev, offset, size, data);
-}
-
-/**
- * @brief Erase physical flash.
- *
- * Offset and size must be a multiple of CONFIG_FLASH_ERASE_SIZE.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- * @param offset Flash offset to erase.
- * @param size Number of bytes to erase.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_physical_erase(const struct device *dev, int offset,
- int size);
-
-static inline int z_impl_cros_flash_physical_erase(const struct device *dev,
- int offset, int size)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_erase) {
- return -ENOTSUP;
- }
-
- return api->physical_erase(dev, offset, size);
-}
-
-/**
- * @brief Read physical write protect setting for a flash bank.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- * @param bank Bank index to check.
- *
- * @return non-zero if bank is protected until reboot.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_physical_get_protect(const struct device *dev,
- int bank);
-
-static inline int
-z_impl_cros_flash_physical_get_protect(const struct device *dev, int bank)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_get_protect) {
- return -ENOTSUP;
- }
-
- return api->physical_get_protect(dev, bank);
-}
-
-/**
- * @brief Return flash protect state flags from the physical layer.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- *
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall
-uint32_t cros_flash_physical_get_protect_flags(const struct device *dev);
-
-static inline uint32_t
-z_impl_cros_flash_physical_get_protect_flags(const struct device *dev)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_get_protect_flags) {
- return -ENOTSUP;
- }
-
- return api->physical_get_protect_flags(dev);
-}
-
-/**
- * @brief Enable/disable protecting firmware/pstate at boot.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- * @param new_flags to protect (only EC_FLASH_PROTECT_*_AT_BOOT are
- * taken care of)
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_physical_protect_at_boot(const struct device *dev,
- uint32_t new_flags);
-
-static inline int
-z_impl_cros_flash_physical_protect_at_boot(const struct device *dev,
- uint32_t new_flags)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_protect_at_boot) {
- return -ENOTSUP;
- }
-
- return api->physical_protect_at_boot(dev, new_flags);
-}
-
-/**
- * @brief Protect now physical flash.
- *
- * @param dev Pointer to the device structure for the flash driver instance.
- * @param all Protect all (=1) or just read-only and pstate (=0).
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_flash_physical_protect_now(const struct device *dev,
- int all);
-
-static inline int
-z_impl_cros_flash_physical_protect_now(const struct device *dev, int all)
-{
- const struct cros_flash_driver_api *api =
- (const struct cros_flash_driver_api *)dev->api;
-
- if (!api->physical_protect_now) {
- return -ENOTSUP;
- }
-
- return api->physical_protect_now(dev, all);
-}
-
-/**
- * @}
- */
-#include <syscalls/cros_flash.h>
-#endif /* ZEPHYR_INCLUDE_DRIVERS_CROS_FLASH_H_ */
diff --git a/zephyr/include/drivers/cros_kb_raw.h b/zephyr/include/drivers/cros_kb_raw.h
deleted file mode 100644
index 1724f59d95..0000000000
--- a/zephyr/include/drivers/cros_kb_raw.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-/**
- * @file
- * @brief Chrome OS-specific API for raw keyboard access
- * This exists only support the interface expected by the Chrome OS EC. It seems
- * better to implement this so we can make use of most of the existing code in
- * its keyboard_scan.c file and thus make sure we operate the same way.
- *
- * It provides raw access to keyboard GPIOs.
- *
- * The keyboard matrix is read (by the caller, keyboard_scan.c in ECOS) by
- * driving output signals on the column lines and reading the row lines.
- *
- * This API and any drivers should be removed once we can safely move to using
- * the Zephyr kscan API.
- */
-
-#ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_KB_RAW_H_
-#define ZEPHYR_INCLUDE_DRIVERS_CROS_KB_RAW_H_
-
-#include <kernel.h>
-#include <device.h>
-
-/**
- * @brief CROS Keyboard Raw Driver APIs
- * @defgroup cros_kb_raw_interface CROS Keyboard Raw Driver APIs
- * @ingroup io_interfaces
- * @{
- */
-
-/**
- * @cond INTERNAL_HIDDEN
- *
- * cros keyboard raw driver API definition and system call entry points
- *
- * (Internal use only.)
- */
-typedef int (*cros_kb_raw_api_init)(const struct device *dev);
-
-typedef int (*cros_kb_raw_api_drive_column)(const struct device *dev, int col);
-
-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);
-
-__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;
-};
-
-/**
- * @endcond
- */
-
-/**
- * @brief Initialize the raw keyboard interface.
- *
- * Must be called before any other functions in this interface.
- *
- * @param dev Pointer to the device structure for the keyboard driver instance.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_kb_raw_init(const struct device *dev);
-
-static inline int z_impl_cros_kb_raw_init(const struct device *dev)
-{
- const struct cros_kb_raw_driver_api *api =
- (const struct cros_kb_raw_driver_api *)dev->api;
-
- if (!api->init) {
- return -ENOTSUP;
- }
-
- return api->init(dev);
-}
-
-/**
- * @brief Drive the specified column low.
- *
- * Other columns are tristated. See enum keyboard_column_index for special
- * values for <col>.
- *
- * @param dev Pointer to the device structure for the keyboard driver instance.
- * @param col Specified column is driven to low.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_kb_raw_drive_column(const struct device *dev, int col);
-static inline int z_impl_cros_kb_raw_drive_column(const struct device *dev,
- int col)
-{
- const struct cros_kb_raw_driver_api *api =
- (const struct cros_kb_raw_driver_api *)dev->api;
-
- if (!api->drive_colum) {
- return -ENOTSUP;
- }
-
- return api->drive_colum(dev, col);
-}
-
-/**
- * @brief Read raw row state.
- *
- * Bits are 1 if signal is present, 0 if not present.
- *
- * @param dev Pointer to the device structure for the keyboard driver instance.
- *
- * @return current raw row state value.
- */
-__syscall int cros_kb_raw_read_rows(const struct device *dev);
-static inline int z_impl_cros_kb_raw_read_rows(const struct device *dev)
-{
- const struct cros_kb_raw_driver_api *api =
- (const struct cros_kb_raw_driver_api *)dev->api;
-
- if (!api->read_rows) {
- return 0;
- }
-
- return api->read_rows(dev);
-}
-
-/**
- * @brief Enable or disable keyboard interrupts.
- *
- * Enabling interrupts will clear any pending interrupt bits. To avoid missing
- * any interrupts that occur between the end of scanning and then, you should
- * call cros_kb_raw_read_rows() after this. If it returns non-zero, disable
- * interrupts and go back to polling mode instead of waiting for an interrupt.
- *
- * @param dev Pointer to the device structure for the keyboard driver instance.
- * @param enable If 1, enable keyboard interrupt. Otherwise, disable it.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_kb_raw_enable_interrupt(const struct device *dev,
- int enable);
-
-static inline int z_impl_cros_kb_raw_enable_interrupt(const struct device *dev,
- int enable)
-{
- const struct cros_kb_raw_driver_api *api =
- (const struct cros_kb_raw_driver_api *)dev->api;
-
- if (!api->enable_interrupt) {
- return -ENOTSUP;
- }
-
- return api->enable_interrupt(dev, enable);
-}
-
-/**
- * @}
- */
-#include <syscalls/cros_kb_raw.h>
-#endif /* ZEPHYR_INCLUDE_DRIVERS_CROS_KB_RAW_H_ */
diff --git a/zephyr/include/drivers/cros_rtc.h b/zephyr/include/drivers/cros_rtc.h
deleted file mode 100644
index 695aabef73..0000000000
--- a/zephyr/include/drivers/cros_rtc.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * @file
- * @brief Chrome OS-specific API for real-time clock (RTC).
- * This exists only support the interface expected by the Chrome OS EC. It
- * provides raw access to RTC module.
- *
- * This API and any drivers should be removed once we can safely move to using
- * the Zephyr rtc API.
- */
-
-#ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_RTC_H_
-#define ZEPHYR_INCLUDE_DRIVERS_CROS_RTC_H_
-
-#include <kernel.h>
-#include <device.h>
-
-/**
- * @brief CROS Real-Time Clock (RTC) Driver APIs
- * @defgroup cros_rtc_interface CROS RTC Driver APIs
- * @ingroup io_interfaces
- * @{
- */
-
-/**
- * @brief RTC alarm callback
- *
- * @param dev Pointer to the device structure for the RTC driver instance.
- */
-typedef void (*cros_rtc_alarm_callback_t)(const struct device *dev);
-
-/**
- * @cond INTERNAL_HIDDEN
- *
- * cros real-time clock driver API definition and system call entry points
- *
- * (Internal use only.)
- */
-typedef int (*cros_rtc_api_configure)(const struct device *dev,
- cros_rtc_alarm_callback_t callback);
-
-typedef int (*cros_rtc_api_get_value)(const struct device *dev,
- uint32_t *value);
-
-typedef int (*cros_rtc_api_set_value)(const struct device *dev, uint32_t value);
-
-typedef int (*cros_rtc_api_get_alarm)(const struct device *dev,
- uint32_t *seconds,
- uint32_t *microseconds);
-
-typedef int (*cros_rtc_api_set_alarm)(const struct device *dev,
- uint32_t seconds, uint32_t microseconds);
-
-typedef int (*cros_rtc_api_reset_alarm)(const struct device *dev);
-
-__subsystem struct cros_rtc_driver_api {
- cros_rtc_api_configure configure;
- cros_rtc_api_get_value get_value;
- cros_rtc_api_set_value set_value;
- cros_rtc_api_get_alarm get_alarm;
- cros_rtc_api_set_alarm set_alarm;
- cros_rtc_api_reset_alarm reset_alarm;
-};
-
-/**
- * @endcond
- */
-
-/**
- * @brief Configure real-time clock callback func.
- *
- * @param dev Pointer to the device structure for the RTC driver instance.
- * @param callback Callback func when RTC alarm issued.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- * @retval -EINVAL Not valid callback func.
- */
-__syscall int cros_rtc_configure(const struct device *dev,
- cros_rtc_alarm_callback_t callback);
-static inline int z_impl_cros_rtc_configure(const struct device *dev,
- cros_rtc_alarm_callback_t callback)
-{
- const struct cros_rtc_driver_api *api =
- (const struct cros_rtc_driver_api *)dev->api;
-
- if (!api->configure) {
- return -ENOTSUP;
- }
-
- return api->configure(dev, callback);
-}
-
-/**
- * @brief Get the current real-time clock value.
- *
- * @param dev Pointer to the device structure for the RTC driver instance.
- * @param value Pointer to the number of current real-time clock value.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_rtc_get_value(const struct device *dev, uint32_t *value);
-static inline int z_impl_cros_rtc_get_value(const struct device *dev,
- uint32_t *value)
-{
- const struct cros_rtc_driver_api *api =
- (const struct cros_rtc_driver_api *)dev->api;
-
- if (!api->get_value) {
- return -ENOTSUP;
- }
-
- return api->get_value(dev, value);
-}
-
-/**
- * @brief Set a desired value to real-time clock.
- *
- * @param dev Pointer to the device structure for the RTC driver instance.
- * @param value Number of desired real-time clock value.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_rtc_set_value(const struct device *dev, uint32_t value);
-static inline int z_impl_cros_rtc_set_value(const struct device *dev,
- uint32_t value)
-{
- const struct cros_rtc_driver_api *api =
- (const struct cros_rtc_driver_api *)dev->api;
-
- if (!api->set_value) {
- return -ENOTSUP;
- }
-
- return api->set_value(dev, value);
-}
-
-/**
- * @brief Get a given time when an RTC alarm interrupt issued.
- *
- * @param dev Pointer to the device structure for the RTC driver instance.
- * @param seconds Pointer to number of seconds before RTC alarm issued.
- * @param microseconds Pointer to number of micro-secs before RTC alarm issued.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_rtc_get_alarm(const struct device *dev, uint32_t *seconds,
- uint32_t *microseconds);
-
-static inline int z_impl_cros_rtc_get_alarm(const struct device *dev,
- uint32_t *seconds,
- uint32_t *microseconds)
-{
- const struct cros_rtc_driver_api *api =
- (const struct cros_rtc_driver_api *)dev->api;
-
- if (!api->get_alarm) {
- return 0;
- }
-
- return api->get_alarm(dev, seconds, microseconds);
-}
-
-/**
- * @brief Set up an RTC alarm interrupt at a given time from now
- *
- * @param dev Pointer to the device structure for the RTC driver instance.
- * @param seconds Number of seconds before RTC alarm issued.
- * @param microseconds Number of microseconds before alarm RTC issued.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_rtc_set_alarm(const struct device *dev, uint32_t seconds,
- uint32_t microseconds);
-
-static inline int z_impl_cros_rtc_set_alarm(const struct device *dev,
- uint32_t seconds,
- uint32_t microseconds)
-{
- const struct cros_rtc_driver_api *api =
- (const struct cros_rtc_driver_api *)dev->api;
-
- if (!api->set_alarm) {
- return 0;
- }
-
- return api->set_alarm(dev, seconds, microseconds);
-}
-
-/**
- * @brief Disable and clear the RTC alarm interrupt.
- *
- * @param dev Pointer to the device structure for the RTC driver instance.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported api function.
- */
-__syscall int cros_rtc_reset_alarm(const struct device *dev);
-
-static inline int z_impl_cros_rtc_reset_alarm(const struct device *dev)
-{
- const struct cros_rtc_driver_api *api =
- (const struct cros_rtc_driver_api *)dev->api;
-
- if (!api->reset_alarm) {
- return -ENOTSUP;
- }
-
- return api->reset_alarm(dev);
-}
-
-/**
- * @}
- */
-#include <syscalls/cros_rtc.h>
-#endif /* ZEPHYR_INCLUDE_DRIVERS_CROS_RTC_H_ */
diff --git a/zephyr/include/drivers/cros_shi.h b/zephyr/include/drivers/cros_shi.h
deleted file mode 100644
index aab3507dd3..0000000000
--- a/zephyr/include/drivers/cros_shi.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * @file
- * @brief Chrome OS-specific API for Serial Host Interface (SHI)
- */
-
-#ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_SHI_H_
-#define ZEPHYR_INCLUDE_DRIVERS_CROS_SHI_H_
-
-/**
- * @brief CROS Serial Host Interface Driver APIs
- * @defgroup cros_shi_interface CROS Serial Host Interface Driver APIs
- * @ingroup io_interfaces
- * @{
- */
-
-#include <kernel.h>
-#include <device.h>
-
-/**
- * @cond INTERNAL_HIDDEN
- *
- * cros Serial Host Interface driver API definition and system call entry points
- *
- * (Internal use only.)
- */
-typedef int (*cros_shi_api_enable)(const struct device *dev);
-
-typedef int (*cros_shi_api_disable)(const struct device *dev);
-
-/** @brief Driver API structure. */
-__subsystem struct cros_shi_driver_api {
- cros_shi_api_enable enable;
- cros_shi_api_disable disable;
-};
-
-/**
- * @brief Enable SHI module.
- *
- * @param dev Pointer to the device structure for the driver instance.
- *
- * @retval non-negative if successful.
- * @retval Negative errno code if failure.
- */
-__syscall int cros_shi_enable(const struct device *dev);
-
-static inline int z_impl_cros_shi_enable(const struct device *dev)
-{
- const struct cros_shi_driver_api *api =
- (const struct cros_shi_driver_api *)dev->api;
-
- if (!api->enable) {
- return -ENOTSUP;
- }
-
- return api->enable(dev);
-}
-
-/**
- * @brief Disable SHI module.
- *
- * @param dev Pointer to the device structure for the driver instance.
- *
- * @retval no return if successful.
- * @retval Negative errno code if failure.
- */
-__syscall int cros_shi_disable(const struct device *dev);
-
-static inline int z_impl_cros_shi_disable(const struct device *dev)
-{
- const struct cros_shi_driver_api *api =
- (const struct cros_shi_driver_api *)dev->api;
-
- if (!api->disable) {
- return -ENOTSUP;
- }
-
- return api->disable(dev);
-}
-
-/**
- * @}
- */
-#include <syscalls/cros_shi.h>
-#endif /* ZEPHYR_INCLUDE_DRIVERS_CROS_SHI_H_ */
diff --git a/zephyr/include/drivers/cros_system.h b/zephyr/include/drivers/cros_system.h
deleted file mode 100644
index b0e06f1b59..0000000000
--- a/zephyr/include/drivers/cros_system.h
+++ /dev/null
@@ -1,302 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * @file
- * @brief Public API for cros system drivers
- */
-
-#ifndef ZEPHYR_INCLUDE_DRIVERS_CROS_SYSTEM_H_
-#define ZEPHYR_INCLUDE_DRIVERS_CROS_SYSTEM_H_
-
-/**
- * @brief cros system Interface
- * @defgroup cros_system_interface cros system Interface
- * @ingroup io_interfaces
- * @{
- */
-
-#include <kernel.h>
-#include <device.h>
-
-/**
- * @brief system_reset_cause enum
- * Identify the reset cause.
- */
-enum system_reset_cause {
- /* the reset is triggered by VCC power-up */
- POWERUP = 0,
- /* the reset is triggered by external VCC1 reset pin */
- VCC1_RST_PIN = 1,
- /* the reset is triggered by ICE debug reset request */
- DEBUG_RST = 2,
- /* the reset is triggered by watchdog */
- WATCHDOG_RST = 3,
- /* unknown reset type */
- UNKNOWN_RST,
-};
-
-/**
- * @brief Get a node from path '/hibernate_wakeup_pins' which has a property
- * 'wakeup-pins' contains GPIO list for hibernate wake-up
- *
- * @return node identifier with that path.
- */
-#define SYSTEM_DT_NODE_HIBERNATE_CONFIG DT_INST(0, cros_ec_hibernate_wake_pins)
-
-/**
- * @brief Get the length of 'wakeup-pins' property
- *
- * @return length of 'wakeup-pins' prop which type is 'phandles'
- */
-#define SYSTEM_DT_NODE_WAKEUP_PIN_LEN \
- DT_PROP_LEN(SYSTEM_DT_NODE_HIBERNATE_CONFIG, wakeup_pins)
-
-/**
- * @brief Get a node identifier from a phandle in property 'wakeup-pins' at
- * index i.
- *
- * @param i index of 'wakeup-pins' prop which type is 'phandles'
- * @return node identifier with that path.
- */
-#define SYSTEM_DT_NODE_WAKEUP_PIN_BY_IDX(i) \
- DT_PHANDLE_BY_IDX(SYSTEM_DT_NODE_HIBERNATE_CONFIG, wakeup_pins, i)
-
-/**
- * @brief Get the enum using in chromium system by index i in 'wakeup-pins'
- * list.
- *
- * @param i index of 'wakeup-pins' prop which type is 'phandles'
- * @return GPIO enumeration
- */
-#define SYSTEM_DT_WAKEUP_GPIO_ENUM_BY_IDX(i, _) \
- COND_CODE_1(DT_NODE_HAS_PROP(SYSTEM_DT_NODE_WAKEUP_PIN_BY_IDX(i), \
- enum_name), \
- (GPIO_SIGNAL(SYSTEM_DT_NODE_WAKEUP_PIN_BY_IDX(i)), ), ())
-
-/**
- * @typedef cros_system_get_reset_cause_api
- * @brief Callback API for getting reset cause instance.
- * See cros_system_get_reset_cause() for argument descriptions
- */
-typedef int (*cros_system_get_reset_cause_api)(const struct device *dev);
-
-/**
- * @typedef cros_system_soc_reset_api
- * @brief Callback API for soc-reset instance.
- * See cros_system_soc_reset() for argument descriptions
- */
-typedef int (*cros_system_soc_reset_api)(const struct device *dev);
-
-/**
- * @typedef cros_system_hibernate_api
- * @brief Callback API for entering hibernate state (lowest EC power state).
- * See cros_system_hibernate() for argument descriptions
- */
-typedef int (*cros_system_hibernate_api)(const struct device *dev,
- uint32_t seconds,
- uint32_t microseconds);
-
-/**
- * @typedef cros_system_chip_vendor_api
- * @brief Callback API for getting the chip vendor.
- * See cros_system_chip_vendor() for argument descriptions
- */
-typedef const char *(*cros_system_chip_vendor_api)(const struct device *dev);
-
-/**
- * @typedef cros_system_chip_name_api
- * @brief Callback API for getting the chip name.
- * See cros_system_chip_name() for argument descriptions
- */
-typedef const char *(*cros_system_chip_name_api)(const struct device *dev);
-
-/**
- * @typedef cros_system_chip_revision_api
- * @brief Callback API for getting the chip revision.
- * See cros_system_chip_revision() for argument descriptions
- */
-typedef const char *(*cros_system_chip_revision_api)(const struct device *dev);
-
-/**
- * @typedef cros_system_get_deep_sleep_ticks_api
- * @brief Callback API for getting number of ticks spent in deep sleep.
- * See cros_system_deep_sleep_ticks() for argument descriptions
- */
-typedef uint64_t (*cros_system_deep_sleep_ticks_api)(const struct device *dev);
-
-/** @brief Driver API structure. */
-__subsystem struct cros_system_driver_api {
- cros_system_get_reset_cause_api get_reset_cause;
- cros_system_soc_reset_api soc_reset;
- cros_system_hibernate_api hibernate;
- cros_system_chip_vendor_api chip_vendor;
- cros_system_chip_name_api chip_name;
- cros_system_chip_revision_api chip_revision;
- cros_system_deep_sleep_ticks_api deep_sleep_ticks;
-};
-
-/**
- * @brief Get the chip-reset cause
- *
- * @param dev Pointer to the device structure for the driver instance.
- *
- * @retval non-negative if successful.
- * @retval Negative errno code if failure.
- */
-__syscall int cros_system_get_reset_cause(const struct device *dev);
-
-static inline int z_impl_cros_system_get_reset_cause(const struct device *dev)
-{
- const struct cros_system_driver_api *api =
- (const struct cros_system_driver_api *)dev->api;
-
- if (!api->get_reset_cause) {
- return -ENOTSUP;
- }
-
- return api->get_reset_cause(dev);
-}
-
-/**
- * @brief reset the soc
- *
- * @param dev Pointer to the device structure for the driver instance.
- *
- * @retval no return if successful.
- * @retval Negative errno code if failure.
- */
-__syscall int cros_system_soc_reset(const struct device *dev);
-
-static inline int z_impl_cros_system_soc_reset(const struct device *dev)
-{
- const struct cros_system_driver_api *api =
- (const struct cros_system_driver_api *)dev->api;
-
- if (!api->soc_reset) {
- return -ENOTSUP;
- }
-
- return api->soc_reset(dev);
-}
-
-/**
- * @brief put the EC in hibernate (lowest EC power state).
- *
- * @param dev Pointer to the device structure for the driver instance.
- * @param seconds Number of seconds before EC enters hibernate state.
- * @param microseconds Number of micro-secs before EC enters hibernate state.
-
- * @retval no return if successful.
- * @retval Negative errno code if failure.
- */
-__syscall int cros_system_hibernate(const struct device *dev, uint32_t seconds,
- uint32_t microseconds);
-
-static inline int z_impl_cros_system_hibernate(const struct device *dev,
- uint32_t seconds,
- uint32_t microseconds)
-{
- const struct cros_system_driver_api *api =
- (const struct cros_system_driver_api *)dev->api;
-
- if (!api->hibernate) {
- return -ENOTSUP;
- }
-
- return api->hibernate(dev, seconds, microseconds);
-}
-
-/**
- * @brief Get the chip vendor.
- *
- * @param dev Pointer to the device structure for the driver instance.
- * @retval Chip vendor string if successful.
- * @retval Null string if failure.
- */
-__syscall const char *cros_system_chip_vendor(const struct device *dev);
-
-static inline const char *
-z_impl_cros_system_chip_vendor(const struct device *dev)
-{
- const struct cros_system_driver_api *api =
- (const struct cros_system_driver_api *)dev->api;
-
- if (!api->chip_vendor) {
- return "";
- }
-
- return api->chip_vendor(dev);
-}
-
-/**
- * @brief Get the chip name.
- *
- * @param dev Pointer to the device structure for the driver instance.
- * @retval Chip name string if successful.
- * @retval Null string if failure.
- */
-__syscall const char *cros_system_chip_name(const struct device *dev);
-
-static inline const char *z_impl_cros_system_chip_name(const struct device *dev)
-{
- const struct cros_system_driver_api *api =
- (const struct cros_system_driver_api *)dev->api;
-
- if (!api->chip_name) {
- return "";
- }
-
- return api->chip_name(dev);
-}
-
-/**
- * @brief Get the chip revision.
- *
- * @param dev Pointer to the device structure for the driver instance.
- * @retval Chip revision string if successful.
- * @retval Null string if failure.
- */
-__syscall const char *cros_system_chip_revision(const struct device *dev);
-
-static inline const char *
-z_impl_cros_system_chip_revision(const struct device *dev)
-{
- const struct cros_system_driver_api *api =
- (const struct cros_system_driver_api *)dev->api;
-
- if (!api->chip_revision) {
- return "";
- }
-
- return api->chip_revision(dev);
-}
-
-/**
- * @brief Get total number of ticks spent in deep sleep.
- *
- * @param dev Pointer to the device structure for the driver instance.
- * @retval Number of ticks spent in deep sleep.
- */
-__syscall uint64_t cros_system_deep_sleep_ticks(const struct device *dev);
-
-static inline uint64_t
-z_impl_cros_system_deep_sleep_ticks(const struct device *dev)
-{
- const struct cros_system_driver_api *api =
- (const struct cros_system_driver_api *)dev->api;
-
- if (!api->deep_sleep_ticks) {
- return 0;
- }
-
- return api->deep_sleep_ticks(dev);
-}
-
-/**
- * @}
- */
-#include <syscalls/cros_system.h>
-#endif /* ZEPHYR_INCLUDE_DRIVERS_CROS_SYSTEM_H_ */
diff --git a/zephyr/include/dt-bindings/charger/intersil_isl9241.h b/zephyr/include/dt-bindings/charger/intersil_isl9241.h
deleted file mode 100644
index 5a2742570e..0000000000
--- a/zephyr/include/dt-bindings/charger/intersil_isl9241.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CHARGER_INTERSIL_ISL9241_H_
-#define ZEPHYR_INCLUDE_DT_BINDINGS_CHARGER_INTERSIL_ISL9241_H_
-
-#define SWITCHING_FREQ_1420KHZ 0
-#define SWITCHING_FREQ_1180KHZ 1
-#define SWITCHING_FREQ_1020KHZ 2
-#define SWITCHING_FREQ_890KHZ 3
-#define SWITCHING_FREQ_808KHZ 4
-#define SWITCHING_FREQ_724KHZ 5
-#define SWITCHING_FREQ_656KHZ 6
-#define SWITCHING_FREQ_600KHZ 7
-
-#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CHARGER_INTERSIL_ISL9241_H_ */
diff --git a/zephyr/include/dt-bindings/cros-kb-raw/ite_cros_kb_raw.h b/zephyr/include/dt-bindings/cros-kb-raw/ite_cros_kb_raw.h
deleted file mode 100644
index f88efed949..0000000000
--- a/zephyr/include/dt-bindings/cros-kb-raw/ite_cros_kb_raw.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CROS_KB_RAW_ITE_CROS_KB_RAW_H_
-#define ZEPHYR_INCLUDE_DT_BINDINGS_CROS_KB_RAW_ITE_CROS_KB_RAW_H_
-
-#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CROS_KB_RAW_ITE_CROS_KB_RAW_H_ */
diff --git a/zephyr/include/dt-bindings/cros-kb-raw/npcx_cros_kb_raw.h b/zephyr/include/dt-bindings/cros-kb-raw/npcx_cros_kb_raw.h
deleted file mode 100644
index f979ae8481..0000000000
--- a/zephyr/include/dt-bindings/cros-kb-raw/npcx_cros_kb_raw.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * Copyright 2020 Google LLC
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CROS_KB_RAW_NPCX_CROS_KB_RAW_H_
-#define ZEPHYR_INCLUDE_DT_BINDINGS_CROS_KB_RAW_NPCX_CROS_KB_RAW_H_
-
-#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CROS_KB_RAW_NPCX_CROS_KB_RAW_H_ */
diff --git a/zephyr/include/dt-bindings/gpio_defines.h b/zephyr/include/dt-bindings/gpio_defines.h
deleted file mode 100644
index 37552b8d6c..0000000000
--- a/zephyr/include/dt-bindings/gpio_defines.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2020 Google LLC.
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-#ifndef DT_BINDINGS_GPIO_DEFINES_H_
-#define DT_BINDINGS_GPIO_DEFINES_H_
-
-#include <dt-bindings/gpio/gpio.h>
-
-/*
- * The GPIO_INPUT and GPIO_OUTPUT defines are normally not available to
- * the device tree. For GPIOs that are controlled by the platform/ec module, we
- * allow device tree to set the initial state.
- *
- * Note the raw defines (e.g. GPIO_OUTPUT) in this file are copies from
- * <drivers/gpio.h>
- *
- * The combined defined (e.g. GPIO_OUT_LOW) have been renamed to fit with
- * gpio defined in platform/ec codebase.
- */
-
-/** Enables pin as input. */
-#define GPIO_INPUT (1U << 8)
-
-/** Enables pin as output, no change to the output state. */
-#define GPIO_OUTPUT (1U << 9)
-
-/* Initializes output to a low state. */
-#define GPIO_OUTPUT_INIT_LOW (1U << 10)
-
-/* Initializes output to a high state. */
-#define GPIO_OUTPUT_INIT_HIGH (1U << 11)
-
-/* Configures GPIO pin as output and initializes it to a low state. */
-#define GPIO_OUTPUT_LOW (GPIO_OUTPUT | GPIO_OUTPUT_INIT_LOW)
-
-/* Configures GPIO pin as output and initializes it to a high state. */
-#define GPIO_OUTPUT_HIGH (GPIO_OUTPUT | GPIO_OUTPUT_INIT_HIGH)
-
-/* Configures GPIO pin as input with pull-up. */
-#define GPIO_INPUT_PULL_UP (GPIO_INPUT | GPIO_PULL_UP)
-
-/* Configures GPIO pin as input with pull-down. */
-#define GPIO_INPUT_PULL_DOWN (GPIO_INPUT | GPIO_PULL_DOWN)
-
-/** Configures GPIO pin as output and initializes it to a low state. */
-#define GPIO_OUT_LOW (GPIO_OUTPUT | GPIO_OUTPUT_INIT_LOW)
-
-/** Configures GPIO pin as output and initializes it to a high state. */
-#define GPIO_OUT_HIGH (GPIO_OUTPUT | GPIO_OUTPUT_INIT_HIGH)
-
-/** Configures GPIO pin as ODR output and initializes it to a low state. */
-#define GPIO_ODR_LOW (GPIO_OUT_LOW | GPIO_OPEN_DRAIN)
-
-/** Configures GPIO pin as ODR output and initializes it to a high state. */
-#define GPIO_ODR_HIGH (GPIO_OUT_HIGH | GPIO_OPEN_DRAIN)
-
-#endif /* DT_BINDINGS_GPIO_DEFINES_H_ */
diff --git a/zephyr/include/dt-bindings/motionsense/utils.h b/zephyr/include/dt-bindings/motionsense/utils.h
deleted file mode 100644
index 7f0e5f5fc8..0000000000
--- a/zephyr/include/dt-bindings/motionsense/utils.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * Copyright 2021 Google LLC.
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-#ifndef DT_BINDINGS_UTILS_H
-#define DT_BINDINGS_UTILS_H
-
-#define BIT(x) (1U << (x))
-#define ROUND_UP_FLAG BIT(31)
-#define USEC_PER_MSEC 1000
-
-#endif /* DT_BINDINGS_UTILS_H */
diff --git a/zephyr/include/dt-bindings/wake_mask_event_defines.h b/zephyr/include/dt-bindings/wake_mask_event_defines.h
deleted file mode 100644
index 0413fa249c..0000000000
--- a/zephyr/include/dt-bindings/wake_mask_event_defines.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2021 Google LLC.
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-#ifndef DT_BINDINGS_WAKE_MASK_EVENT_DEFINES_H_
-#define DT_BINDINGS_WAKE_MASK_EVENT_DEFINES_H_
-
-#ifndef BIT
-#define BIT(n) (1U << n)
-#endif
-
-/*
- * NOTE: The convention in the Zephyr code is to have the public header file
- * include the dt-binding header file to avoid duplicate definitions.
- * However, ec_commands.h is shared with the linux kernel so we can't do that.
- *
- * Please consult include/ec_commands.h for explanations of the macros
- * defined in this file.
- */
-
-#define MKBP_EVENT_KEY_MATRIX BIT(0)
-#define MKBP_EVENT_HOST_EVENT BIT(1)
-#define MKBP_EVENT_SENSOR_FIFO BIT(2)
-#define MKBP_EVENT_BUTTON BIT(3)
-#define MKBP_EVENT_SWITCH BIT(4)
-#define MKBP_EVENT_FINGERPRINT BIT(5)
-#define MKBP_EVENT_SYSRQ BIT(6)
-#define MKBP_EVENT_HOST_EVENT64 BIT(7)
-#define MKBP_EVENT_CEC_EVENT BIT(8)
-#define MKBP_EVENT_CEC_MESSAGE BIT(9)
-#define MKBP_EVENT_DP_ALT_MODE_ENTERED BIT(10)
-#define MKBP_EVENT_ONLINE_CALIBRATION BIT(11)
-#define MKBP_EVENT_PCHG BIT(12)
-
-#define HOST_EVENT_MASK(event) ((event) >> 1)
-
-#define HOST_EVENT_NONE BIT(0)
-#define HOST_EVENT_LID_CLOSED BIT(1)
-#define HOST_EVENT_LID_OPEN BIT(2)
-#define HOST_EVENT_POWER_BUTTON BIT(3)
-#define HOST_EVENT_AC_CONNECTED BIT(4)
-#define HOST_EVENT_AC_DISCONNECTED BIT(5)
-#define HOST_EVENT_BATTERY_LOW BIT(6)
-#define HOST_EVENT_BATTERY_CRITICAL BIT(7)
-#define HOST_EVENT_BATTERY BIT(8)
-#define HOST_EVENT_THERMAL_THRESHOLD BIT(9)
-#define HOST_EVENT_DEVICE BIT(10)
-#define HOST_EVENT_THERMAL BIT(11)
-#define HOST_EVENT_USB_CHARGER BIT(12)
-#define HOST_EVENT_KEY_PRESSED BIT(13)
-#define HOST_EVENT_INTERFACE_READY BIT(14)
-#define HOST_EVENT_KEYBOARD_RECOVERY BIT(15)
-#define HOST_EVENT_THERMAL_SHUTDOWN BIT(16)
-#define HOST_EVENT_BATTERY_SHUTDOWN BIT(17)
-#define HOST_EVENT_THROTTLE_START BIT(18)
-#define HOST_EVENT_THROTTLE_STOP BIT(19)
-#define HOST_EVENT_HANG_DETECT BIT(20)
-#define HOST_EVENT_HANG_REBOOT BIT(21)
-#define HOST_EVENT_PD_MCU BIT(22)
-#define HOST_EVENT_BATTERY_STATUS BIT(23)
-#define HOST_EVENT_PANIC BIT(24)
-#define HOST_EVENT_KEYBOARD_FASTBOOT BIT(25)
-#define HOST_EVENT_RTC BIT(26)
-#define HOST_EVENT_MKBP BIT(27)
-#define HOST_EVENT_USB_MUX BIT(28)
-#define HOST_EVENT_MODE_CHANGE BIT(29)
-#define HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT BIT(30)
-#define HOST_EVENT_WOV BIT(31)
-#define HOST_EVENT_INVALID BIT(32)
-
-#endif /* DT_BINDINGS_WAKE_MASK_EVENT_DEFINES_H_ */
-
diff --git a/zephyr/include/emul/emul_bb_retimer.h b/zephyr/include/emul/emul_bb_retimer.h
deleted file mode 100644
index c63cc651c0..0000000000
--- a/zephyr/include/emul/emul_bb_retimer.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * @file
- *
- * @brief Backend API for BB retimer emulator
- */
-
-#ifndef __EMUL_BB_RETIMER_H
-#define __EMUL_BB_RETIMER_H
-
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-/**
- * @brief BB retimer emulator backend API
- * @defgroup bb_emul BB retimer emulator
- * @{
- *
- * BB retimer emulator supports access to all its registers using I2C messages.
- * It supports not four bytes writes by padding zeros (the same as real
- * device), but show warning in that case.
- * Application may alter emulator state:
- *
- * - define a Device Tree overlay file to set default vendor ID and which
- * inadvisable driver behaviour should be treated as errors
- * - call @ref bb_emul_set_reg and @ref bb_emul_get_reg to set and get value
- * of BB retimers registers
- * - call bb_emul_set_err_* to change emulator behaviour on inadvisable driver
- * behaviour
- * - call functions from emul_common_i2c.h to setup custom handlers for I2C
- * messages
- */
-
-/**
- * @brief Get pointer to BB retimer emulator using device tree order number.
- *
- * @param ord Device tree order number obtained from DT_DEP_ORD macro
- *
- * @return Pointer to BB retimer emulator
- */
-struct i2c_emul *bb_emul_get(int ord);
-
-/**
- * @brief Set value of given register of BB retimer
- *
- * @param emul Pointer to BB retimer emulator
- * @param reg Register address which value will be changed
- * @param val New value of the register
- */
-void bb_emul_set_reg(struct i2c_emul *emul, int reg, uint32_t val);
-
-/**
- * @brief Get value of given register of BB retimer
- *
- * @param emul Pointer to BB retimer emulator
- * @param reg Register address
- *
- * @return Value of the register
- */
-uint32_t bb_emul_get_reg(struct i2c_emul *emul, int reg);
-
-/**
- * @brief Set if error should be generated when read only register is being
- * written
- *
- * @param emul Pointer to BB retimer emulator
- * @param set Check for this error
- */
-void bb_emul_set_err_on_ro_write(struct i2c_emul *emul, bool set);
-
-/**
- * @brief Set if error should be generated when reserved bits of register are
- * not set to 0 on write I2C message
- *
- * @param emul Pointer to BB retimer emulator
- * @param set Check for this error
- */
-void bb_emul_set_err_on_rsvd_write(struct i2c_emul *emul, bool set);
-
-/**
- * @}
- */
-
-#endif /* __EMUL_BB_RETIMER */
diff --git a/zephyr/include/emul/emul_bma255.h b/zephyr/include/emul/emul_bma255.h
deleted file mode 100644
index b2f71df88b..0000000000
--- a/zephyr/include/emul/emul_bma255.h
+++ /dev/null
@@ -1,191 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * @file
- *
- * @brief Backend API for BMA255 emulator
- */
-
-#ifndef __EMUL_BMA255_H
-#define __EMUL_BMA255_H
-
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-/**
- * @brief BMA255 emulator backend API
- * @defgroup bma_emul BMA255 emulator
- * @{
- *
- * BMA255 emulator supports responses to all write and read I2C messages.
- * Accelerometer registers are obtained from internal emulator state, range
- * register and offset. Only fast compensation is supported by default handler.
- * Registers backed in NVM are fully supported (GP0, GP1, offset). For proper
- * support for interrupts and FIFO, user needs to use custom handlers.
- * Application may alter emulator state:
- *
- * - define a Device Tree overlay file to set default NVM content, default
- * static accelerometer value and which inadvisable driver behaviour should
- * be treated as errors
- * - call @ref bma_emul_set_reg and @ref bma_emul_get_reg to set and get value
- * of BMA255 registers
- * - call @ref bma_emul_set_off and @ref bma_emul_set_off to set and get
- * internal offset value
- * - call @ref bma_emul_set_acc and @ref bma_emul_set_acc to set and get
- * accelerometer value
- * - call bma_emul_set_err_* to change emulator behaviour on inadvisable driver
- * behaviour
- * - call functions from emul_common_i2c.h to setup custom handlers for I2C
- * messages
- */
-
-/**
- * Axis argument used in @ref bma_emul_set_acc @ref bma_emul_get_acc
- * @ref bma_emul_set_off and @ref bma_emul_get_off
- */
-#define BMA_EMUL_AXIS_X 0
-#define BMA_EMUL_AXIS_Y 1
-#define BMA_EMUL_AXIS_Z 2
-
-/**
- * Acceleration 1g in internal emulator units. It is helpful for using
- * functions @ref bma_emul_set_acc @ref bma_emul_get_acc
- * @ref bma_emul_set_off and @ref bma_emul_get_off
- */
-#define BMA_EMUL_1G BIT(10)
-
-/**
- * @brief Get pointer to BMA255 emulator using device tree order number.
- *
- * @param ord Device tree order number obtained from DT_DEP_ORD macro
- *
- * @return Pointer to BMA255 emulator
- */
-struct i2c_emul *bma_emul_get(int ord);
-
-/**
- * @brief Set value of given register of BMA255
- *
- * @param emul Pointer to BMA255 emulator
- * @param reg Register address which value will be changed
- * @param val New value of the register
- */
-void bma_emul_set_reg(struct i2c_emul *emul, int reg, uint8_t val);
-
-/**
- * @brief Get value of given register of BMA255
- *
- * @param emul Pointer to BMA255 emulator
- * @param reg Register address
- *
- * @return Value of the register
- */
-uint8_t bma_emul_get_reg(struct i2c_emul *emul, int reg);
-
-/**
- * @brief Get internal value of offset for given axis
- *
- * @param emul Pointer to BMA255 emulator
- * @param axis Axis to access: 0 - X, 1 - Y, 2 - Z
- *
- * @return Offset of given axis. LSB is 0.97mg
- */
-int16_t bma_emul_get_off(struct i2c_emul *emul, int axis);
-
-/**
- * @brief Set internal value of offset for given axis
- *
- * @param emul Pointer to BMA255 emulator
- * @param axis Axis to access: 0 - X, 1 - Y, 2 - Z
- * @param val New value of offset. LSB is 0.97mg
- */
-void bma_emul_set_off(struct i2c_emul *emul, int axis, int16_t val);
-
-/**
- * @brief Get internal value of accelerometer for given axis
- *
- * @param emul Pointer to BMA255 emulator
- * @param axis Axis to access: 0 - X, 1 - Y, 2 - Z
- *
- * @return Acceleration of given axis. LSB is 0.97mg
- */
-int16_t bma_emul_get_acc(struct i2c_emul *emul, int axis);
-
-/**
- * @brief Set internal value of accelerometr for given axis
- *
- * @param emul Pointer to BMA255 emulator
- * @param axis Axis to access: 0 - X, 1 - Y, 2 - Z
- * @param val New value of accelerometer axis. LSB is 0.97mg
- */
-void bma_emul_set_acc(struct i2c_emul *emul, int axis, int16_t val);
-
-/**
- * @brief Set if error should be generated when fast compensation is triggered
- * when not ready flag is set
- *
- * @param emul Pointer to BMA255 emulator
- * @param set Check for this error
- */
-void bma_emul_set_err_on_cal_nrdy(struct i2c_emul *emul, bool set);
-
-/**
- * @brief Set if error should be generated when fast compensation is triggered
- * when range is not 2G
- *
- * @param emul Pointer to BMA255 emulator
- * @param set Check for this error
- */
-void bma_emul_set_err_on_cal_bad_range(struct i2c_emul *emul, bool set);
-
-/**
- * @brief Set if error should be generated when read only register is being
- * written
- *
- * @param emul Pointer to BMA255 emulator
- * @param set Check for this error
- */
-void bma_emul_set_err_on_ro_write(struct i2c_emul *emul, bool set);
-
-/**
- * @brief Set if error should be generated when reserved bits of register are
- * not set to 0 on write I2C message
- *
- * @param emul Pointer to BMA255 emulator
- * @param set Check for this error
- */
-void bma_emul_set_err_on_rsvd_write(struct i2c_emul *emul, bool set);
-
-/**
- * @brief Set if error should be generated when MSB register is accessed before
- * LSB register
- *
- * @param emul Pointer to BMA255 emulator
- * @param set Check for this error
- */
-void bma_emul_set_err_on_msb_first(struct i2c_emul *emul, bool set);
-
-/**
- * @brief Function calculate register that should be accessed when I2C message
- * started from @p reg register and now byte number @p bytes is handled.
- * This function is used in I2C common emulator code and can be used in
- * custom user functions.
- *
- * @param emul Pointer to BMA255 emulator
- * @param reg Starting register
- * @param bytes Number of bytes already processed in the I2C message handler
- * @param read If current I2C message is read
- *
- * @retval Register address that should be accessed
- */
-int bma_emul_access_reg(struct i2c_emul *emul, int reg, int bytes, bool read);
-
-/**
- * @}
- */
-
-#endif /* __EMUL_BMA255_H */
diff --git a/zephyr/include/emul/emul_bmi.h b/zephyr/include/emul/emul_bmi.h
deleted file mode 100644
index 9eac9c3f85..0000000000
--- a/zephyr/include/emul/emul_bmi.h
+++ /dev/null
@@ -1,431 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * @file
- *
- * @brief Backend API for BMI emulator
- */
-
-#ifndef __EMUL_BMI_H
-#define __EMUL_BMI_H
-
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-/**
- * @brief BMI emulator backend API
- * @defgroup bmi_emul BMI emulator
- * @{
- *
- * BMI emulator supports responses to all write and read I2C messages.
- * Accelerometer and gyroscope registers are obtained from internal emulator
- * state, range register and offset. FIFO is fully simulated. Emulator can be
- * extended to support more models of BMI.
- * Application may alter emulator state:
- *
- * - define a Device Tree overlay file to set which inadvisable driver behaviour
- * should be treated as errors and which model is emulated
- * - call @ref bmi_emul_set_reg and @ref bmi_emul_get_reg to set and get value
- * of BMI registers
- * - call @ref bmi_emul_set_off and @ref bmi_emul_get_off to set and get
- * internal offset value
- * - call @ref bmi_emul_set_value and @ref bmi_emul_get_value to set and get
- * accelerometer or gyroscope value
- * - call bmi_emul_set_err_* to change emulator behaviour on inadvisable driver
- * behaviour
- * - call @ref bmi_emul_simulate_cmd_exec_time to enable or disable simulation
- * of command execution time
- * - call @ref bmi_emul_append_frame to add frame to FIFO
- * - call @reg bmi_emul_set_skipped_frames to generate skip frame on next access
- * to FIFO
- * - call functions from emul_common_i2c.h to setup custom handlers for I2C
- * messages
- */
-
-/**
- * Axis argument used in @ref bmi_emul_set_value @ref bmi_emul_get_value
- * @ref bmi_emul_set_off and @ref bmi_emul_get_off
- */
-enum bmi_emul_axis {
- BMI_EMUL_ACC_X,
- BMI_EMUL_ACC_Y,
- BMI_EMUL_ACC_Z,
- BMI_EMUL_GYR_X,
- BMI_EMUL_GYR_Y,
- BMI_EMUL_GYR_Z,
-};
-
-/** BMI emulator models */
-#define BMI_EMUL_160 1
-#define BMI_EMUL_260 2
-
-/** Last register supported by emulator */
-#define BMI_EMUL_MAX_REG 0x80
-/** Maximum number of registers that can be backed in NVM */
-#define BMI_EMUL_MAX_NVM_REGS 10
-
-/** Headers used in FIFO frames */
-#define BMI_EMUL_FIFO_HEAD_SKIP 0x40
-#define BMI_EMUL_FIFO_HEAD_TIME 0x44
-#define BMI_EMUL_FIFO_HEAD_CONFIG 0x48
-#define BMI_EMUL_FIFO_HEAD_EMPTY 0x80
-#define BMI_EMUL_FIFO_HEAD_DATA 0x80
-#define BMI_EMUL_FIFO_HEAD_DATA_MAG BIT(4)
-#define BMI_EMUL_FIFO_HEAD_DATA_GYR BIT(3)
-#define BMI_EMUL_FIFO_HEAD_DATA_ACC BIT(2)
-#define BMI_EMUL_FIFO_HEAD_DATA_TAG_MASK 0x03
-
-/**
- * Acceleration 1g in internal emulator units. It is helpful for using
- * functions @ref bmi_emul_set_value @ref bmi_emul_get_value
- * @ref bmi_emul_set_off and @ref bmi_emul_get_off
- */
-#define BMI_EMUL_1G BIT(14)
-/**
- * Gyroscope 125°/s in internal emulator units. It is helpful for using
- * functions @ref bmi_emul_set_value @ref bmi_emul_get_value
- * @ref bmi_emul_set_off and @ref bmi_emul_get_off
- */
-#define BMI_EMUL_125_DEG_S BIT(15)
-
-/** Type of frames that can be added to the emulator frames list */
-#define BMI_EMUL_FRAME_CONFIG BIT(0)
-#define BMI_EMUL_FRAME_ACC BIT(1)
-#define BMI_EMUL_FRAME_MAG BIT(2)
-#define BMI_EMUL_FRAME_GYR BIT(3)
-
-/**
- * Code returned by model specific handle_read and handle_write functions, when
- * RO register is accessed on write or WO register is accessed on read
- */
-#define BMI_EMUL_ACCESS_E 1
-
-/** Structure used to describe single FIFO frame */
-struct bmi_emul_frame {
- /** Type of frame */
- uint8_t type;
- /** Tag added to data frame */
- uint8_t tag;
- /** Value used in config frame */
- uint8_t config;
- /** Accelerometer sensor values in internal emulator units */
- int32_t acc_x;
- int32_t acc_y;
- int32_t acc_z;
- /** Gyroscope sensor values in internal emulator units */
- int32_t gyr_x;
- int32_t gyr_y;
- int32_t gyr_z;
- /** Magnetometer/other sensor values in internal emulator units */
- int32_t mag_x;
- int32_t mag_y;
- int32_t mag_z;
- int32_t rhall;
-
- /** Pointer to next frame or NULL */
- struct bmi_emul_frame *next;
-};
-
-/** Structure describing specific BMI model */
-struct bmi_emul_type_data {
- /** Indicate if time frame should follow config frame */
- bool sensortime_follow_config_frame;
-
- /**
- * @brief Compute register address that acctually will be accessed, when
- * selected register is @p reg and there was @p byte handled in
- * the current I2C message
- *
- * @param emul Pointer to BMI emulator
- * @param reg Selected register
- * @param byte Number of handled bytes in the current I2C message
- * @param read If current I2C message is read
- *
- * @return Register address that will be accessed
- */
- int (*access_reg)(struct i2c_emul *emul, int reg, int byte, bool read);
-
- /**
- * @brief Model specific write function. It should modify state of
- * emulator if required.
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- * @param reg Selected register
- * @param byte Number of handled bytes in this write command
- * @param val Value that is being written
- *
- * @return 0 on success
- * @return BMI_EMUL_ACCESS_E on RO register access
- * @return other on error
- */
- int (*handle_write)(uint8_t *regs, struct i2c_emul *emul, int reg,
- int byte, uint8_t val);
- /**
- * @brief Model specific read function. It should modify state of
- * emulator if required. @p buf should be set to response value.
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- * @param reg Selected register
- * @param byte Byte which is accessed during block read
- * @param buf Pointer where read byte should be stored
- *
- * @return 0 on success
- * @return BMI_EMUL_ACCESS_E on WO register access
- * @return other on error
- */
- int (*handle_read)(uint8_t *regs, struct i2c_emul *emul, int reg,
- int byte, char *buf);
- /**
- * @brief Model specific reset function. It should modify state of
- * emulator to imitate after reset conditions.
- *
- * @param regs Pointer to array of emulator's registers
- * @param emul Pointer to BMI emulator
- */
- void (*reset)(uint8_t *regs, struct i2c_emul *emul);
-
- /** Array of reserved bits mask for each register */
- const uint8_t *rsvd_mask;
-
- /** Array of registers that are backed in NVM */
- const int *nvm_reg;
- /** Number of registers backed in NVM */
- int nvm_len;
-
- /** Gyroscope X axis register */
- int gyr_off_reg;
- /** Accelerometer X axis register */
- int acc_off_reg;
- /** Gyroscope 9 and 8 bits register */
- int gyr98_off_reg;
-};
-
-/**
- * @brief Get BMI160 model specific structure.
- *
- * @return Pointer to BMI160 specific structure
- */
-const struct bmi_emul_type_data *get_bmi160_emul_type_data(void);
-/**
- * @brief Get BMI260 model specific structure.
- *
- * @return Pointer to BMI260 specific structure
- */
-const struct bmi_emul_type_data *get_bmi260_emul_type_data(void);
-
-/**
- * @brief Get pointer to BMI emulator using device tree order number.
- *
- * @param ord Device tree order number obtained from DT_DEP_ORD macro
- *
- * @return Pointer to BMI emulator
- */
-struct i2c_emul *bmi_emul_get(int ord);
-
-/**
- * @brief Set value of given register of BMI
- *
- * @param emul Pointer to BMI emulator
- * @param reg Register address which value will be changed
- * @param val New value of the register
- */
-void bmi_emul_set_reg(struct i2c_emul *emul, int reg, uint8_t val);
-
-/**
- * @brief Get value of given register of BMI
- *
- * @param emul Pointer to BMI emulator
- * @param reg Register address
- *
- * @return Value of the register
- */
-uint8_t bmi_emul_get_reg(struct i2c_emul *emul, int reg);
-
-/**
- * @brief Get internal value of offset for given axis and sensor
- *
- * @param emul Pointer to BMI emulator
- * @param axis Axis to access
- *
- * @return Offset of given axis. LSB for accelerometer is 0.061mg and for
- * gyroscope is 0.0037°/s.
- */
-int16_t bmi_emul_get_off(struct i2c_emul *emul, enum bmi_emul_axis axis);
-
-/**
- * @brief Set internal value of offset for given axis and sensor
- *
- * @param emul Pointer to BMI emulator
- * @param axis Axis to access
- * @param val New value of given axis. LSB for accelerometer is 0.061mg and for
- * gyroscope is 0.0037°/s.
- */
-void bmi_emul_set_off(struct i2c_emul *emul, enum bmi_emul_axis axis,
- int16_t val);
-
-/**
- * @brief Get internal value of sensor for given axis
- *
- * @param emul Pointer to BMI emulator
- * @param axis Axis to access
- *
- * @return Sensor value of given axis. LSB for accelerometer is 0.061mg and for
- * gyroscope is 0.0037°/s.
- */
-int32_t bmi_emul_get_value(struct i2c_emul *emul, enum bmi_emul_axis axis);
-
-/**
- * @brief Set internal value of sensor for given axis
- *
- * @param emul Pointer to BMI emulator
- * @param axis Axis to access
- * @param val New value of given axis. LSB for accelerometer is 0.061mg and for
- * gyroscope is 0.0037°/s.
- */
-void bmi_emul_set_value(struct i2c_emul *emul, enum bmi_emul_axis axis,
- int32_t val);
-
-/**
- * @brief Set if error should be generated when read only register is being
- * written
- *
- * @param emul Pointer to BMI emulator
- * @param set Check for this error
- */
-void bmi_emul_set_err_on_ro_write(struct i2c_emul *emul, bool set);
-
-/**
- * @brief Set if error should be generated when reserved bits of register are
- * not set to 0 on write I2C message
- *
- * @param emul Pointer to BMI emulator
- * @param set Check for this error
- */
-void bmi_emul_set_err_on_rsvd_write(struct i2c_emul *emul, bool set);
-
-/**
- * @brief Set if error should be generated when write only register is read
- *
- * @param emul Pointer to BMI emulator
- * @param set Check for this error
- */
-void bmi_emul_set_err_on_wo_read(struct i2c_emul *emul, bool set);
-
-/**
- * @brief Set if effect of simulated command should take place after simulated
- * time pass from issuing command.
- *
- * @param emul Pointer to BMI emulator
- * @param set Simulate command execution time
- */
-void bmi_emul_simulate_cmd_exec_time(struct i2c_emul *emul, bool set);
-
-/**
- * @brief Set number of skipped frames. It will generate skip frame on next
- * access to FIFO. After that number of skipped frames is reset to 0.
- *
- * @param emul Pointer to BMI emulator
- * @param skip Number of skipped frames
- */
-void bmi_emul_set_skipped_frames(struct i2c_emul *emul, uint8_t skip);
-
-/**
- * @brief Clear all FIFO frames, set current frame to empty and reset fifo_skip
- * counter
- *
- * @param emul Pointer to BMI emulator
- * @param tag_time Indicate if sensor time should be included in empty frame
- * @param header Indicate if header should be included in frame
- */
-void bmi_emul_flush_fifo(struct i2c_emul *emul, bool tag_time, bool header);
-
-/**
- * @brief Restore registers backed by NVM, reset sensor time and flush FIFO
- *
- * @param emul Pointer to BMI emulator
- */
-void bmi_emul_reset_common(struct i2c_emul *emul, bool tag_time, bool header);
-
-/**
- * @brief Set command end time to @p time ms from now
- *
- * @param emul Pointer to BMI emulator
- * @param time After this amount of ms command should end
- */
-void bmi_emul_set_cmd_end_time(struct i2c_emul *emul, int time);
-
-/**
- * @brief Check if command should end
- *
- * @param emul Pointer to BMI emulator
- */
-bool bmi_emul_is_cmd_end(struct i2c_emul *emul);
-
-/**
- * @brief Append FIFO @p frame to the emulator list of frames. It can be read
- * using I2C interface.
- *
- * @param emul Pointer to BMI emulator
- * @param frame Pointer to new FIFO frame. Pointed data has to be valid while
- * emulator may use this frame (until flush of FIFO or reading
- * it out through I2C)
- */
-void bmi_emul_append_frame(struct i2c_emul *emul, struct bmi_emul_frame *frame);
-
-/**
- * @brief Get length of all frames that are on the emulator list of frames.
- *
- * @param emul Pointer to BMI emulator
- * @param tag_time Indicate if sensor time should be included in empty frame
- * @param header Indicate if header should be included in frame
- */
-uint16_t bmi_emul_fifo_len(struct i2c_emul *emul, bool tag_time, bool header);
-
-/**
- * @brief Get next byte that should be returned on FIFO data access.
- *
- * @param emul Pointer to BMI emulator
- * @param byte Which byte of block read command is currently handled
- * @param tag_time Indicate if sensor time should be included in empty frame
- * @param header Indicate if header should be included in frame
- * @param acc_shift How many bits should be right shifted from accelerometer
- * data
- * @param gyr_shift How many bits should be right shifted from gyroscope data
- *
- * @return FIFO data byte
- */
-uint8_t bmi_emul_get_fifo_data(struct i2c_emul *emul, int byte,
- bool tag_time, bool header, int acc_shift,
- int gyr_shift);
-
-/**
- * @brief Saves current internal state of sensors to emulator's registers.
- *
- * @param emul Pointer to BMI emulator
- * @param acc_shift How many bits should be right shifted from accelerometer
- * data
- * @param gyr_shift How many bits should be right shifted from gyroscope data
- * @param acc_reg Register which holds LSB of accelerometer sensor
- * @param gyr_reg Register which holds LSB of gyroscope sensor
- * @param sensortime_reg Register which holds LSB of sensor time
- * @param acc_off_en Indicate if accelerometer offset should be included to
- * sensor data value
- * @param gyr_off_en Indicate if gyroscope offset should be included to
- * sensor data value
- */
-void bmi_emul_state_to_reg(struct i2c_emul *emul, int acc_shift,
- int gyr_shift, int acc_reg, int gyr_reg,
- int sensortime_reg, bool acc_off_en,
- bool gyr_off_en);
-
-/**
- * @}
- */
-
-#endif /* __EMUL_BMI_H */
diff --git a/zephyr/include/emul/emul_common_i2c.h b/zephyr/include/emul/emul_common_i2c.h
deleted file mode 100644
index 0457842a71..0000000000
--- a/zephyr/include/emul/emul_common_i2c.h
+++ /dev/null
@@ -1,369 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * @file
- *
- * @brief Common code used by devices emulated on I2C bus
- */
-
-#ifndef __EMUL_COMMON_I2C_H
-#define __EMUL_COMMON_I2C_H
-
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-/**
- * @brief Common I2C API useb by emulators
- * @defgroup i2c_common_emul common I2C emulator's code
- * @{
- *
- * I2C common emulator functionality is dispatching I2C messages. It supports
- * setting custom user handler and selecting register on which access emulator
- * should fail. To use common I2C handling, emulator should call or setup
- * @ref i2c_common_emul_transfer as transfer callback of i2c_emul_api and
- * register emulator with @ref i2c_common_emul_data structure as data. In data
- * structure, emualtor should set callback called before read/write I2C message
- * (start_read, start_write), for each byte of I2C message (read_byte,
- * write_byte) and after I2C message (finish_read, finish_byte). If specific
- * function is not needed by emulator, than it can be set to NULL.
- *
- * @ref i2c_common_emul_lock_data and @ref i2c_common_emul_unlock_data functions
- * may be used to guard emulator data when accessed from multiple threads.
- *
- * User of emulator with common I2C code can use following API to define custom
- * behaviour of emulator:
- *
- * - call @ref i2c_common_emul_set_read_func and
- * @ref i2c_common_emul_set_write_func to setup custom handlers for I2C
- * messages
- * - call @ref i2c_common_emul_set_read_fail_reg and
- * @ref i2c_common_emul_set_write_fail_reg to configure emulator to fail on
- * given register read or write
- */
-
-/**
- * Special register values used in @ref i2c_common_emul_set_read_fail_reg and
- * @ref i2c_common_emul_set_write_fail_reg
- */
-#define I2C_COMMON_EMUL_FAIL_ALL_REG (-1)
-#define I2C_COMMON_EMUL_NO_FAIL_REG (-2)
-
-/**
- * Describe if there is no ongoing I2C message or if there is message handled
- * at the moment (last message doesn't ended with stop or write is not followed
- * by read).
- */
-enum i2c_common_emul_msg_state {
- I2C_COMMON_EMUL_NONE_MSG,
- I2C_COMMON_EMUL_IN_WRITE,
- I2C_COMMON_EMUL_IN_READ
-};
-
-/**
- * @brief Function type that is used by I2C device emulator for first byte of
- * I2C write message.
- *
- * @param emul Pointer to emulator
- * @param reg Address which is now accessed by write command (first byte of I2C
- * write message)
- *
- * @return 0 on success
- * @return -EIO on error
- */
-typedef int (*i2c_common_emul_start_write_func)(struct i2c_emul *emul, int reg);
-
-/**
- * @brief Function type that is used by I2C device emulator at the end of
- * I2C write message.
- *
- * @param emul Pointer to emulator
- * @param reg Address which is now accessed by write command (first byte of I2C
- * write message)
- * @param bytes Number of bytes received from the I2C write message
- *
- * @return 0 on success
- * @return -EIO on error
- */
-typedef int (*i2c_common_emul_finish_write_func)(struct i2c_emul *emul, int reg,
- int bytes);
-
-/**
- * @brief Function type that is used by I2C device emulator on each byte of
- * I2C write message (except first byte).
- *
- * @param emul Pointer to emulator
- * @param reg Address which is now accessed by write command (first byte of I2C
- * write message)
- * @param val Value of current byte
- * @param bytes Number of bytes already received from the I2C write message
- * (excluding current byte)
- *
- * @return 0 on success
- * @return -EIO on error
- */
-typedef int (*i2c_common_emul_write_byte_func)(struct i2c_emul *emul, int reg,
- uint8_t val, int bytes);
-
-/**
- * @brief Function type that is used by I2C device emulator before first byte of
- * I2C read message.
- *
- * @param emul Pointer to emulator
- * @param reg Address which is now accessed by read command (first byte of last
- * I2C write message)
- *
- * @return 0 on success
- * @return -EIO on error
- */
-typedef int (*i2c_common_emul_start_read_func)(struct i2c_emul *emul, int reg);
-
-/**
- * @brief Function type that is used by I2C device emulator at the end of
- * I2C read message.
- *
- * @param emul Pointer to emulator
- * @param reg Address which is now accessed by read command (first byte of last
- * I2C write message)
- * @param bytes Number of bytes responeded to the I2C read message
- *
- * @return 0 on success
- * @return -EIO on error
- */
-typedef int (*i2c_common_emul_finish_read_func)(struct i2c_emul *emul, int reg,
- int bytes);
-
-/**
- * @brief Function type that is used by I2C device emulator on each byte of
- * I2C read message.
- *
- * @param emul Pointer to emulator
- * @param reg Address which is now accessed by read command (first byte of last
- * I2C write message)
- * @param val Pointer to buffer where current response byte should be stored
- * @param bytes Number of bytes already responded to the I2C read message
- * (excluding current byte)
- *
- * @return 0 on success
- * @return -EIO on error
- */
-typedef int (*i2c_common_emul_read_byte_func)(struct i2c_emul *emul, int reg,
- uint8_t *val, int bytes);
-
-/**
- * @brief Function type that is used by I2C device emulator to select register
- * address that should be compared with fail register set by user using
- * @ref i2c_common_emul_set_read_fail_reg and
- * @ref i2c_common_emul_set_write_fail_reg
- *
- * @param emul Pointer to emulator
- * @param reg Address which is now accessed by read/write command (first byte
- * of last I2C write message)
- * @param bytes Number of bytes already processed in the I2C message handler
- * (excluding current byte)
- * @param read If current I2C message is read
- *
- * @return Register address that should be compared with user-defined fail
- * register
- */
-typedef int (*i2c_common_emul_access_reg_func)(struct i2c_emul *emul, int reg,
- int bytes, bool read);
-
-/**
- * @brief Custom function type that is used as user-defined callback in read
- * I2C messages handling.
- *
- * @param emul Pointer to emulator
- * @param reg Address which is now accessed by read command (first byte of last
- * I2C write message)
- * @param val Pointer to buffer where current response byte should be stored
- * @param bytes Number of bytes already responded to the I2C read message
- * (excluding current byte)
- * @param data Pointer to custom user data
- *
- * @return 0 on success
- * @return 1 continue with normal emulator handler
- * @return negative on error
- */
-typedef int (*i2c_common_emul_read_func)(struct i2c_emul *emul, int reg,
- uint8_t *val, int bytes, void *data);
-
-/**
- * @brief Custom function type that is used as user-defined callback in write
- * I2C messages handling.
- *
- * @param emul Pointer to emulator
- * @param reg Address which is now accessed by write command (first byte of I2C
- * write message)
- * @param val Value of current byte
- * @param bytes Number of bytes already received from the I2C write message
- * (excluding current byte)
- * @param data Pointer to custom user data
- *
- * @return 0 on success
- * @return 1 continue with normal emulator handler
- * @return negative on error
- */
-typedef int (*i2c_common_emul_write_func)(struct i2c_emul *emul, int reg,
- uint8_t val, int bytes, void *data);
-
-/** Static configuration, common for all i2c emulators */
-struct i2c_common_emul_cfg {
- /** Label of the I2C bus this emulator connects to */
- const char *i2c_label;
- /** Label of the I2C device being emulated */
- const char *dev_label;
- /** Pointer to run-time data */
- struct i2c_common_emul_data *data;
- /** Address of emulator on i2c bus */
- uint16_t addr;
-};
-
-/** Run-time data used by the emulator, common for all i2c emulators */
-struct i2c_common_emul_data {
- /** I2C emulator detail */
- struct i2c_emul emul;
- /** Emulator device */
- const struct device *i2c;
- /** Configuration information */
- const struct i2c_common_emul_cfg *cfg;
-
- /** Current state of I2C bus (if emulator is handling message) */
- enum i2c_common_emul_msg_state msg_state;
- /** Number of already handled bytes in ongoing message */
- int msg_byte;
- /** Register selected in last write command */
- uint8_t cur_reg;
-
- /** Custom write function called on I2C write opperation */
- i2c_common_emul_write_func write_func;
- /** Data passed to custom write function */
- void *write_func_data;
- /** Custom read function called on I2C read opperation */
- i2c_common_emul_read_func read_func;
- /** Data passed to custom read function */
- void *read_func_data;
-
- /** Control if read should fail on given register */
- int read_fail_reg;
- /** Control if write should fail on given register */
- int write_fail_reg;
-
- /** Emulator function, called for first byte of write message */
- i2c_common_emul_start_write_func start_write;
- /** Emulator function, called for each byte of write message */
- i2c_common_emul_write_byte_func write_byte;
- /** Emulator function, called at the end of write message */
- i2c_common_emul_finish_write_func finish_write;
-
- /** Emulator function, called before first byte of read message */
- i2c_common_emul_start_read_func start_read;
- /** Emulator function, called for each byte of read message */
- i2c_common_emul_read_byte_func read_byte;
- /** Emulator function, called at the end of read message */
- i2c_common_emul_finish_read_func finish_read;
-
- /**
- * Emulator function, called to get register that should be checked
- * if was selected by user in set_read/write_fail_reg.
- */
- i2c_common_emul_access_reg_func access_reg;
-
- /** Mutex used to control access to emulator data */
- struct k_mutex data_mtx;
-};
-
-/**
- * @brief Lock access to emulator properties. After acquiring lock, user
- * may change emulator behaviour in multi-thread setup.
- *
- * @param emul Pointer to emulator
- * @param timeout Timeout in getting lock
- *
- * @return k_mutex_lock return code
- */
-int i2c_common_emul_lock_data(struct i2c_emul *emul, k_timeout_t timeout);
-
-/**
- * @brief Unlock access to emulator properties.
- *
- * @param emul Pointer to emulator
- *
- * @return k_mutex_unlock return code
- */
-int i2c_common_emul_unlock_data(struct i2c_emul *emul);
-
-/**
- * @brief Set write handler for I2C messages. This function is called before
- * generic handler.
- *
- * @param emul Pointer to emulator
- * @param func Pointer to custom function
- * @param data User data passed on call of custom function
- */
-void i2c_common_emul_set_write_func(struct i2c_emul *emul,
- i2c_common_emul_write_func func,
- void *data);
-
-/**
- * @brief Set read handler for I2C messages. This function is called before
- * generic handler.
- *
- * @param emul Pointer to emulator
- * @param func Pointer to custom function
- * @param data User data passed on call of custom function
- */
-void i2c_common_emul_set_read_func(struct i2c_emul *emul,
- i2c_common_emul_read_func func, void *data);
-
-/**
- * @brief Setup fail on read of given register of emulator
- *
- * @param emul Pointer to emulator
- * @param reg Register address or one of special values
- * (I2C_COMMON_EMUL_FAIL_ALL_REG, I2C_COMMON_EMUL_NO_FAIL_REG)
- */
-void i2c_common_emul_set_read_fail_reg(struct i2c_emul *emul, int reg);
-
-/**
- * @brief Setup fail on write of given register of emulator
- *
- * @param emul Pointer to emulator
- * @param reg Register address or one of special values
- * (I2C_COMMON_EMUL_FAIL_ALL_REG, I2C_COMMON_EMUL_NO_FAIL_REG)
- */
-void i2c_common_emul_set_write_fail_reg(struct i2c_emul *emul, int reg);
-
-/**
- * @biref Emulate an I2C transfer to an emulator
- *
- * This is common function used by I2C device emulators. It handles dispatching
- * I2C message, calling user custom functions, failing on reading/writing
- * registers selected by user and calling device specific functions.
- *
- * @param emul I2C emulation information
- * @param msgs List of messages to process
- * @param num_msgs Number of messages to process
- * @param addr Address of the I2C target device
- *
- * @retval 0 If successful
- * @retval -EIO General input / output error
- */
-int i2c_common_emul_transfer(struct i2c_emul *emul, struct i2c_msg *msgs,
- int num_msgs, int addr);
-
-/**
- * @brief Initialize common emulator data structure
- *
- * @param data Pointer to emulator data
- */
-void i2c_common_emul_init(struct i2c_common_emul_data *data);
-
-/**
- * @}
- */
-
-#endif /* __EMUL_COMMON_I2C_H */
diff --git a/zephyr/include/emul/emul_lis2dw12.h b/zephyr/include/emul/emul_lis2dw12.h
deleted file mode 100644
index b136e24f0a..0000000000
--- a/zephyr/include/emul/emul_lis2dw12.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef ZEPHYR_INCLUDE_EMUL_EMUL_LIS2DW12_H_
-#define ZEPHYR_INCLUDE_EMUL_EMUL_LIS2DW12_H_
-
-#include <emul.h>
-#include <drivers/i2c_emul.h>
-
-/**
- * @brief The the i2c emulator pointer from the top level emul.
- *
- * @param emul The emulator to query
- * @return Pointer to the i2c emulator struct
- */
-struct i2c_emul *lis2dw12_emul_to_i2c_emul(const struct emul *emul);
-
-/**
- * @brief Reset the state of the lis2dw12 emulator.
- *
- * @param emul The emulator to reset.
- */
-void lis2dw12_emul_reset(const struct emul *emul);
-
-/**
- * @brief Set the who-am-i register value.
- *
- * By default the who-am-i register holds LIS2DW12_WHO_AM_I, this function
- * enables overriding that value in order to drive testing.
- *
- * @param emul The emulator to modify.
- * @param who_am_i The new who-am-i register value.
- */
-void lis2dw12_emul_set_who_am_i(const struct emul *emul, uint8_t who_am_i);
-
-/**
- * @brief Check the number of times the chip was soft reset.
- *
- * This value is reset by a call to lis2dw12_emul_reset().
- *
- * @param emul The emulator to query
- * @return The number of times that the chip was reset.
- */
-uint32_t lis2dw12_emul_get_soft_reset_count(const struct emul *emul);
-
-#endif /* ZEPHYR_INCLUDE_EMUL_EMUL_LIS2DW12_H_ */
diff --git a/zephyr/include/emul/emul_ln9310.h b/zephyr/include/emul/emul_ln9310.h
deleted file mode 100644
index dfa03eaa28..0000000000
--- a/zephyr/include/emul/emul_ln9310.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * @file
- *
- * @brief Backend API for LN9310 emulator
- */
-
-#ifndef ZEPHYR_INCLUDE_EMUL_EMUL_LN9310_H_
-#define ZEPHYR_INCLUDE_EMUL_EMUL_LN9310_H_
-
-#include <emul.h>
-#include "driver/ln9310.h"
-#include <stdbool.h>
-
-/**
- * @brief Select the current emulator to use.
- *
- * Currently, only a single ln9310 can be instantiated at any given instance due
- * to how the driver was written. Once this restriction is removed, there's
- * still an issue with the board_get_battery_cell_type() function as it doesn't
- * take a device pointer. This function selects the current LN9310 context which
- * will serve the data for that board function.
- *
- * @param emulator The LN9310 emulator to select.
- */
-void ln9310_emul_set_context(const struct emul *emulator);
-
-/**
- * @brief Clear all the emulator data.
- *
- * @param emulator The LN9310 emulator to clear.
- */
-void ln9310_emul_reset(const struct emul *emulator);
-
-/**
- * @brief Update the emulator's battery cell type.
- *
- * @param emulator The LN9310 emulator to update.
- * @param type The battery type to use.
- */
-void ln9310_emul_set_battery_cell_type(const struct emul *emulator,
- enum battery_cell_type type);
-
-/**
- * @brief Update the emulator's version number.
- *
- * @param emulator The LN9310 emulator to update.
- * @param version The LN9310 chip version number.
- */
-void ln9310_emul_set_version(const struct emul *emulator, int version);
-
-/**
- * @brief Update whether or not the LN9310 is currently getting more than 10V.
- *
- * @param emulator The LN9310 emulator to update.
- * @param is_gt_10v Whether or not the chip is currently getting more than 10V.
- */
-void ln9310_emul_set_vin_gt_10v(const struct emul *emulator, bool is_gt_10v);
-
-/**
- * @brief Get whether or not the LN9310 is initialized.
- *
- * @param emulator The LN9310 emulator to read.
- *
- * @return true if the LN9310 was correctly initialized.
- */
-bool ln9310_emul_is_init(const struct emul *emulator);
-
-#endif /* ZEPHYR_INCLUDE_EMUL_EMUL_LN9310_H_ */
diff --git a/zephyr/include/emul/emul_pi3usb9201.h b/zephyr/include/emul/emul_pi3usb9201.h
deleted file mode 100644
index b171cfefc9..0000000000
--- a/zephyr/include/emul/emul_pi3usb9201.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * @file
- *
- * @brief Backend API for pi3usb9201 emulator
- */
-
-#ifndef __EMUL_PI3USB9201_H
-#define __EMUL_PI3USB9201_H
-
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-#define PI3USB9201_REG_CTRL_1 0x0
-#define PI3USB9201_REG_CTRL_2 0x1
-#define PI3USB9201_REG_CLIENT_STS 0x2
-#define PI3USB9201_REG_HOST_STS 0x3
-
-/**
- * @brief Get pointer to pi3usb9201 emulator using device tree order number.
- *
- * @param ord Device tree order number obtained from DT_DEP_ORD macro
- *
- * @return Pointer to pi3usb9201 emulator
- */
-struct i2c_emul *pi3usb9201_emul_get(int ord);
-
-/**
- * @brief Set value of given register of pi3usb9201
- *
- * @param emul Pointer to pi3usb9201 emulator
- * @param reg Register address
- * @param val New value of the register
- *
- * @return 0 on success or error
- */
-int pi3usb9201_emul_set_reg(struct i2c_emul *emul, int reg, uint8_t val);
-
-/**
- * @brief Get value of given register of pi3usb9201
- *
- * @param emul Pointer to pi3usb9201 emulator
- * @param reg Register address
- * @param val Pointer to write current value of register
- *
- * @return 0 on success or error
- */
-int pi3usb9201_emul_get_reg(struct i2c_emul *emul, int reg, uint8_t *val);
-
-#endif /* __EMUL_PI3USB9201_H */
diff --git a/zephyr/include/emul/emul_smart_battery.h b/zephyr/include/emul/emul_smart_battery.h
deleted file mode 100644
index b48f836d66..0000000000
--- a/zephyr/include/emul/emul_smart_battery.h
+++ /dev/null
@@ -1,193 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * @file
- *
- * @brief Backend API for Smart Battery emulator
- */
-
-#ifndef __EMUL_SMART_BATTERY_H
-#define __EMUL_SMART_BATTERY_H
-
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-/**
- * @brief Smart Battery emulator backend API
- * @defgroup sbat_emul Smart Battery emulator
- * @{
- *
- * Smart Battery emulator handle static state of device. E.g. setting charging
- * current will not charge battery over time. Sending periodic status messages
- * and alarms to SMBus Host or charging voltage/current to Smart Battery Charger
- * is not supported. Behaviour of Smart Battery emulator is application-defined.
- * As-such, each application may
- *
- * - define a Device Tree overlay file to set the most of battery properties
- * - get battery properties calling @ref sbat_emul_get_bat_data Battery
- * properties can be changed through obtained pointer. In multithread
- * environment access to battery can be guarded by calling
- * @ref sbat_emul_lock_bat_data and @ref sbat_emul_unlock_bat_data
- * - call functions from emul_common_i2c.h to setup custom handlers for SMBus
- * messages
- */
-
-/* Value used to indicate that no command is selected */
-#define SBAT_EMUL_NO_CMD -1
-/* Maximum size of data that can be returned in SMBus block transaction */
-#define MAX_BLOCK_SIZE 32
-/* Maximum length of command to send is maximum size of data + len byte + PEC */
-#define MSG_BUF_LEN (MAX_BLOCK_SIZE + 2)
-
-/** @brief Emulated smart battery properties */
-struct sbat_emul_bat_data {
- /** Battery mode - bit field configuring some battery behaviours */
- uint16_t mode;
- /** Word returned on manufacturer access command */
- uint16_t mf_access;
- /** Capacity alarm value */
- uint16_t cap_alarm;
- /** Remaing time alarm value */
- uint16_t time_alarm;
- /** Rate of charge used in some commands */
- int16_t at_rate;
- /**
- * Flag indicating if AT_RATE_TIME_TO_FULL command supports mW
- * capacity mode
- */
- int at_rate_full_mw_support;
- /** Error code returned by last command */
- uint16_t error_code;
- /** Design battery voltage in mV */
- uint16_t design_mv;
- /** Battery temperature at the moment in Kelvins */
- uint16_t temp;
- /** Battery voltage at the moment in mV */
- uint16_t volt;
- /** Current charging (> 0) or discharging (< 0) battery in mA */
- int16_t cur;
- /** Average current from 1 minute */
- int16_t avg_cur;
- /** Maximum error of returned values in percent */
- uint16_t max_error;
- /** Capacity of the battery at the moment in mAh */
- uint16_t cap;
- /** Full capacity of the battery in mAh */
- uint16_t full_cap;
- /** Design battery capacity in mAh */
- uint16_t design_cap;
- /** Charging current requested by battery */
- uint16_t desired_charg_cur;
- /** Charging voltage requested by battery */
- uint16_t desired_charg_volt;
- /** Number of cycles */
- uint16_t cycle_count;
- /** Specification of battery */
- uint16_t spec_info;
- /** Status of battery */
- uint16_t status;
- /** Date of manufacturing */
- uint16_t mf_date;
- /** Serial number */
- uint16_t sn;
- /** Manufacturer name */
- uint8_t mf_name[MAX_BLOCK_SIZE];
- /** Manufacturer name length */
- int mf_name_len;
- /** Device name */
- uint8_t dev_name[MAX_BLOCK_SIZE];
- /** Device name length */
- int dev_name_len;
- /** Device chemistry */
- uint8_t dev_chem[MAX_BLOCK_SIZE];
- /** Device chemistry length */
- int dev_chem_len;
- /** Manufacturer data */
- uint8_t mf_data[MAX_BLOCK_SIZE];
- /** Manufacturer data length */
- int mf_data_len;
-};
-
-/**
- * @brief Get pointer to smart battery emulator using device tree order number.
- *
- * @param ord Device tree order number obtained from DT_DEP_ORD macro
- *
- * @return Pointer to smart battery emulator
- */
-struct i2c_emul *sbat_emul_get_ptr(int ord);
-
-/**
- * @brief Function which allows to get properties of emulated smart battery
- *
- * @param emul Pointer to smart battery emulator
- *
- * @return Pointer to smart battery properties
- */
-struct sbat_emul_bat_data *sbat_emul_get_bat_data(struct i2c_emul *emul);
-
-/**
- * @brief Convert date to format used by smart battery
- *
- * @param day Day
- * @param month Month
- * @param year Year
- *
- * @return Converted date
- */
-uint16_t sbat_emul_date_to_word(unsigned int day, unsigned int month,
- unsigned int year);
-
-/**
- * @brief Function which gets return value for read commands that returns word.
- * This function may be used to obtain battery properties that are
- * calculated e.g. time to empty/full.
- *
- * @param emul Pointer to smart battery emulator
- * @param cmd Read command
- * @param val Pointer to where word should be stored
- *
- * @return 0 on success
- * @return 1 if command is unknown or return type different then word
- * @return negative on error while reading value
- */
-int sbat_emul_get_word_val(struct i2c_emul *emul, int cmd, uint16_t *val);
-
-/**
- * @brief Function which gets return value for read commands that returns block
- * data
- *
- * @param emul Pointer to smart battery emulator
- * @param cmd Read command
- * @param blk Pointer to where data pointer should be stored
- * @param len Pointer to where data length should be stored
- *
- * @return 0 on success
- * @return 1 if command is unknown or return type different then word
- * @return negative on error while reading value
- */
-int sbat_emul_get_block_data(struct i2c_emul *emul, int cmd, uint8_t **blk,
- int *len);
-
-/**
- * @brief Set next response of emulator. This function may be used in user
- * custom read callback to setup response with calculated PEC.
- *
- * @param emul Pointer to smart battery emulator
- * @param cmd Read command
- * @param buf Buffer with the response
- * @param len Length of the response
- * @param fail If emulator should fail to send response
- */
-void sbat_emul_set_response(struct i2c_emul *emul, int cmd, uint8_t *buf,
- int len, bool fail);
-
-/**
- * @}
- */
-
-#endif /* __EMUL_SMART_BATTERY_H */
diff --git a/zephyr/include/emul/emul_syv682x.h b/zephyr/include/emul/emul_syv682x.h
deleted file mode 100644
index aa0d8840f7..0000000000
--- a/zephyr/include/emul/emul_syv682x.h
+++ /dev/null
@@ -1,143 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/** @file
- *
- * @brief Backend API for SYV682X emulator
- */
-
-#ifndef __EMUL_SYV682X_H
-#define __EMUL_SYV682X_H
-
-#include <drivers/i2c_emul.h>
-#include <stdint.h>
-
-/* Register info copied from syv682.h */
-
-/* SYV682x register addresses */
-#define SYV682X_STATUS_REG 0x00
-#define SYV682X_CONTROL_1_REG 0x01
-#define SYV682X_CONTROL_2_REG 0x02
-#define SYV682X_CONTROL_3_REG 0x03
-#define SYV682X_CONTROL_4_REG 0x04
-
-/* Status Register */
-#define SYV682X_STATUS_OC_HV BIT(7)
-#define SYV682X_STATUS_RVS BIT(6)
-#define SYV682X_STATUS_OC_5V BIT(5)
-#define SYV682X_STATUS_OVP BIT(4)
-#define SYV682X_STATUS_FRS BIT(3)
-#define SYV682X_STATUS_TSD BIT(2)
-#define SYV682X_STATUS_VSAFE_5V BIT(1)
-#define SYV682X_STATUS_VSAFE_0V BIT(0)
-#define SYV682X_STATUS_INT_MASK 0xfc
-
-/* Control Register 1 */
-#define SYV682X_CONTROL_1_CH_SEL BIT(1)
-#define SYV682X_CONTROL_1_HV_DR BIT(2)
-#define SYV682X_CONTROL_1_PWR_ENB BIT(7)
-
-#define SYV682X_5V_ILIM_MASK 0x18
-#define SYV682X_5V_ILIM_BIT_SHIFT 3
-#define SYV682X_5V_ILIM_1_25 0
-#define SYV682X_5V_ILIM_1_75 1
-#define SYV682X_5V_ILIM_2_25 2
-#define SYV682X_5V_ILIM_3_30 3
-
-#define SYV682X_HV_ILIM_MASK 0x60
-#define SYV682X_HV_ILIM_BIT_SHIFT 5
-#define SYV682X_HV_ILIM_1_25 0
-#define SYV682X_HV_ILIM_1_75 1
-#define SYV682X_HV_ILIM_3_30 2
-#define SYV682X_HV_ILIM_5_50 3
-
-/* Control Register 2 */
-#define SYV682X_OC_DELAY_MASK GENMASK(7, 6)
-#define SYV682X_OC_DELAY_SHIFT 6
-#define SYV682X_OC_DELAY_1MS 0
-#define SYV682X_OC_DELAY_10MS 1
-#define SYV682X_OC_DELAY_50MS 2
-#define SYV682X_OC_DELAY_100MS 3
-#define SYV682X_DSG_TIME_MASK GENMASK(5, 4)
-#define SYV682X_DSG_TIME_SHIFT 4
-#define SYV682X_DSG_TIME_50MS 0
-#define SYV682X_DSG_TIME_100MS 1
-#define SYV682X_DSG_TIME_200MS 2
-#define SYV682X_DSG_TIME_400MS 3
-#define SYV682X_DSG_RON_MASK GENMASK(3, 2)
-#define SYV682X_DSG_RON_SHIFT 2
-#define SYV682X_DSG_RON_200_OHM 0
-#define SYV682X_DSG_RON_400_OHM 1
-#define SYV682X_DSG_RON_800_OHM 2
-#define SYV682X_DSG_RON_1600_OHM 3
-#define SYV682X_CONTROL_2_SDSG BIT(1)
-#define SYV682X_CONTROL_2_FDSG BIT(0)
-
-/* Control Register 3 */
-#define SYV682X_BUSY BIT(7)
-#define SYV682X_RVS_MASK BIT(3)
-#define SYV682X_RST_REG BIT(0)
-#define SYV682X_OVP_MASK 0x70
-#define SYV682X_OVP_BIT_SHIFT 4
-#define SYV682X_OVP_06_0 0
-#define SYV682X_OVP_08_0 1
-#define SYV682X_OVP_11_1 2
-#define SYV682X_OVP_12_1 3
-#define SYV682X_OVP_14_2 4
-#define SYV682X_OVP_17_9 5
-#define SYV682X_OVP_21_6 6
-#define SYV682X_OVP_23_7 7
-
-/* Control Register 4 */
-#define SYV682X_CONTROL_4_CC1_BPS BIT(7)
-#define SYV682X_CONTROL_4_CC2_BPS BIT(6)
-#define SYV682X_CONTROL_4_VCONN1 BIT(5)
-#define SYV682X_CONTROL_4_VCONN2 BIT(4)
-#define SYV682X_CONTROL_4_VBAT_OVP BIT(3)
-#define SYV682X_CONTROL_4_VCONN_OCP BIT(2)
-#define SYV682X_CONTROL_4_CC_FRS BIT(1)
-#define SYV682X_CONTROL_4_INT_MASK 0x0c
-
-/**
- * @brief Get pointer to SYV682x emulator using device tree order number.
- *
- * @param ord Device tree order number obtained from DT_DEP_ORD macro
- *
- * @return Pointer to smart battery emulator
- */
-struct i2c_emul *syv682x_emul_get(int ord);
-
-/**
- * @brief Set the underlying interrupt conditions affecting the status register
- *
- * @param emul SYV682x emulator
- * @param val A status register value corresponding to the underlying
- * conditions
- */
-void syv682x_emul_set_status(struct i2c_emul *emul, uint8_t val);
-
-/**
- * @brief Set value of a register of SYV682x
- *
- * @param emul SYV682x emulator
- * @param reg Register address
- * @param val Value to write to the register
- *
- * @return 0 on success, error code on error
- */
-int syv682x_emul_set_reg(struct i2c_emul *emul, int reg, uint8_t val);
-
-/**
- * @brief Get value of a register of SYV682x
- *
- * @param emul SYV682x emulator
- * @param reg Register address
- * @param val Pointer at which to store current value of register
- *
- * @return 0 on success, error code on error
- */
-int syv682x_emul_get_reg(struct i2c_emul *emul, int reg, uint8_t *val);
-
-#endif /* __EMUL_SYV682X_H */
diff --git a/zephyr/include/emul/emul_tcs3400.h b/zephyr/include/emul/emul_tcs3400.h
deleted file mode 100644
index 49ec382a66..0000000000
--- a/zephyr/include/emul/emul_tcs3400.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * @file
- *
- * @brief Backend API for TCS3400 emulator
- */
-
-#ifndef __EMUL_TCS3400_H
-#define __EMUL_TCS3400_H
-
-#include <emul.h>
-#include <drivers/i2c.h>
-#include <drivers/i2c_emul.h>
-
-/**
- * @brief TCS3400 emulator backend API
- * @defgroup tcs_emul TCS3400 emulator
- * @{
- *
- * TCS3400 emulator supports responses to all write and read I2C messages.
- * Light sensor data registers are obtained from internal emulator state, gain
- * and acquisition time. Application may alter emulator state:
- *
- * - define a devicetree overlay file to set which inadvisable driver behaviour
- * should be treated as error and emulated device ID and revision
- * - call @ref tcs_emul_set_reg and @ref tcs_emul_get_reg to set and get value
- * of TCS3400 registers
- * - call @ref tcs_emul_set_val and @ref tcs_emul_set_val to set and get
- * light sensor value
- * - call tcs_emul_set_err_* to change emulator behaviour on inadvisable driver
- * behaviour
- * - call functions from emul_common_i2c.h to setup custom handlers for I2C
- * messages
- */
-
-/**
- * Maximum number of integration cycles (when ATIME is zero). Value read from
- * sensor is proportional to number of integration cycles, e.g. with constant
- * light, value obtainded with 128 cycles will be two times smaller than value
- * obtained with 256 cycles.
- */
-#define TCS_EMUL_MAX_CYCLES 256
-/**
- * Maximum gain supported by TCS3400. Value read from sensor is multiplied by
- * gain selected in CONTROL register.
- */
-#define TCS_EMUL_MAX_GAIN 64
-
-/**
- * Emulator units are value returned with gain x64 and 256 integration cycles.
- * Max value is 1024 returned when gain is x1 and 1 integration cycle. Max value
- * represented in emulator units is 1024 * 64 * 256
- */
-#define TCS_EMUL_MAX_VALUE (1024 * TCS_EMUL_MAX_GAIN * TCS_EMUL_MAX_CYCLES)
-
-/** Axis argument used in @ref tcs_emul_set_val @ref tcs_emul_get_val */
-enum tcs_emul_axis {
- TCS_EMUL_R,
- TCS_EMUL_G,
- TCS_EMUL_B,
- TCS_EMUL_C,
- TCS_EMUL_IR,
-};
-
-/**
- * Emulator saves only those registers in memory. IR select is stored sparately
- * and other registers are write only.
- */
-#define TCS_EMUL_FIRST_REG TCS_I2C_ENABLE
-#define TCS_EMUL_LAST_REG TCS_I2C_BDATAH
-#define TCS_EMUL_REG_COUNT (TCS_EMUL_LAST_REG - TCS_EMUL_FIRST_REG + 1)
-
-/**
- * @brief Get pointer to TCS3400 emulator using device tree order number.
- *
- * @param ord Device tree order number obtained from DT_DEP_ORD macro
- *
- * @return Pointer to TCS3400 emulator
- */
-struct i2c_emul *tcs_emul_get(int ord);
-
-/**
- * @brief Set value of given register of TCS3400
- *
- * @param emul Pointer to TCS3400 emulator
- * @param reg Register address which value will be changed
- * @param val New value of the register
- */
-void tcs_emul_set_reg(struct i2c_emul *emul, int reg, uint8_t val);
-
-/**
- * @brief Get value of given register of TCS3400
- *
- * @param emul Pointer to TCS3400 emulator
- * @param reg Register address
- *
- * @return Value of the register
- */
-uint8_t tcs_emul_get_reg(struct i2c_emul *emul, int reg);
-
-/**
- * @brief Get internal value of light sensor for given axis
- *
- * @param emul Pointer to TCS3400 emulator
- * @param axis Axis to access
- *
- * @return Value of given axis with gain x64 and 256 integration cycles
- */
-int tcs_emul_get_val(struct i2c_emul *emul, enum tcs_emul_axis axis);
-
-/**
- * @brief Set internal value of light sensor for given axis
- *
- * @param emul Pointer to TCS3400 emulator
- * @param axis Axis to access
- * @param val New value of light sensor for given axis with gain x64 and
- * 256 integration cycles
- */
-void tcs_emul_set_val(struct i2c_emul *emul, enum tcs_emul_axis axis, int val);
-
-/**
- * @brief Set if error should be generated when read only register is being
- * written
- *
- * @param emul Pointer to TCS3400 emulator
- * @param set Check for this error
- */
-void tcs_emul_set_err_on_ro_write(struct i2c_emul *emul, bool set);
-
-/**
- * @brief Set if error should be generated when reserved bits of register are
- * not set to 0 on write I2C message
- *
- * @param emul Pointer to TCS3400 emulator
- * @param set Check for this error
- */
-void tcs_emul_set_err_on_rsvd_write(struct i2c_emul *emul, bool set);
-
-/**
- * @brief Set if error should be generated when MSB register is accessed before
- * LSB register
- *
- * @param emul Pointer to TCS3400 emulator
- * @param set Check for this error
- */
-void tcs_emul_set_err_on_msb_first(struct i2c_emul *emul, bool set);
-
-/**
- * @}
- */
-
-#endif /* __EMUL_TCS3400_H */
diff --git a/zephyr/include/emul/i2c_mock.h b/zephyr/include/emul/i2c_mock.h
deleted file mode 100644
index e9e8d97252..0000000000
--- a/zephyr/include/emul/i2c_mock.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef ZEPHYR_INCLUDE_EMUL_I2C_MOCK_H_
-#define ZEPHYR_INCLUDE_EMUL_I2C_MOCK_H_
-
-#include <emul.h>
-#include <drivers/i2c_emul.h>
-
-/**
- * @brief reset the I2C mock.
- *
- * @param emul The mock device to reset.
- */
-void i2c_mock_reset(const struct emul *emul);
-
-/**
- * @brief Get the i2c emulator pointer from the top level mock.
- *
- * @param emul The mock device to query
- * @return Pointer to the i2c emulator struct
- */
-struct i2c_emul *i2c_mock_to_i2c_emul(const struct emul *emul);
-
-/**
- * @brief Get the I2C address of the mock
- *
- * @param emul The mock device to query
- * @return The address on the I2C bus
- */
-uint16_t i2c_mock_get_addr(const struct emul *emul);
-
-#endif /* ZEPHYR_INCLUDE_EMUL_I2C_MOCK_H_ */
diff --git a/zephyr/include/soc/ite_it8xxx2/reg_def_cros.h b/zephyr/include/soc/ite_it8xxx2/reg_def_cros.h
deleted file mode 100644
index 8d3b56878e..0000000000
--- a/zephyr/include/soc/ite_it8xxx2/reg_def_cros.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/*
- * @file
- * @brief ITE it8xxx2 register structure definitions used by the Chrome OS EC.
- */
-
-#ifndef _ITE_IT8XXX2_REG_DEF_CROS_H
-#define _ITE_IT8XXX2_REG_DEF_CROS_H
-
-/*
- * KBS (Keyboard Scan) device registers
- */
-struct kbs_reg {
- /* 0x000: Keyboard Scan Out */
- volatile uint8_t KBS_KSOL;
- /* 0x001: Keyboard Scan Out */
- volatile uint8_t KBS_KSOH1;
- /* 0x002: Keyboard Scan Out Control */
- volatile uint8_t KBS_KSOCTRL;
- /* 0x003: Keyboard Scan Out */
- volatile uint8_t KBS_KSOH2;
- /* 0x004: Keyboard Scan In */
- volatile uint8_t KBS_KSI;
- /* 0x005: Keyboard Scan In Control */
- volatile uint8_t KBS_KSICTRL;
- /* 0x006: Keyboard Scan In [7:0] GPIO Control */
- volatile uint8_t KBS_KSIGCTRL;
- /* 0x007: Keyboard Scan In [7:0] GPIO Output Enable */
- volatile uint8_t KBS_KSIGOEN;
- /* 0x008: Keyboard Scan In [7:0] GPIO Data */
- volatile uint8_t KBS_KSIGDAT;
- /* 0x009: Keyboard Scan In [7:0] GPIO Data Mirror */
- volatile uint8_t KBS_KSIGDMRR;
- /* 0x00A: Keyboard Scan Out [15:8] GPIO Control */
- volatile uint8_t KBS_KSOHGCTRL;
- /* 0x00B: Keyboard Scan Out [15:8] GPIO Output Enable */
- volatile uint8_t KBS_KSOHGOEN;
- /* 0x00C: Keyboard Scan Out [15:8] GPIO Data Mirror */
- volatile uint8_t KBS_KSOHGDMRR;
- /* 0x00D: Keyboard Scan Out [7:0] GPIO Control */
- volatile uint8_t KBS_KSOLGCTRL;
- /* 0x00E: Keyboard Scan Out [7:0] GPIO Output Enable */
- volatile uint8_t KBS_KSOLGOEN;
-};
-
-/* KBS register fields */
-#define IT8XXX2_KBS_KSOPU BIT(2)
-#define IT8XXX2_KBS_KSOOD BIT(0)
-#define IT8XXX2_KBS_KSIPU BIT(2)
-#define IT8XXX2_KBS_KSO2GCTRL BIT(2)
-#define IT8XXX2_KBS_KSO2GOEN BIT(2)
-
-/*
- * ECPM (EC Clock and Power Management) device registers
- */
-struct ecpm_reg {
- /* 0x000: Reserved1 */
- volatile uint8_t reserved1;
- /* 0x001: Clock Gating Control 1 */
- volatile uint8_t ECPM_CGCTRL1;
- /* 0x002: Clock Gating Control 2 */
- volatile uint8_t ECPM_CGCTRL2;
- /* 0x003: PLL Control */
- volatile uint8_t ECPM_PLLCTRL;
- /* 0x004: Auto Clock Gating */
- volatile uint8_t ECPM_AUTOCG;
- /* 0x005: Clock Gating Control 3 */
- volatile uint8_t ECPM_CGCTRL3;
- /* 0x006: PLL Frequency */
- volatile uint8_t ECPM_PLLFREQ;
- /* 0x007: Reserved2 */
- volatile uint8_t reserved2;
- /* 0x008: PLL Clock Source Status */
- volatile uint8_t ECPM_PLLCSS;
- /* 0x009: Clock Gating Control 4 */
- volatile uint8_t ECPM_CGCTRL4;
- /* 0x00A: Reserved3 */
- volatile uint8_t reserved3;
- /* 0x00B: Reserved4 */
- volatile uint8_t reserved4;
- /* 0x00C: System Clock Divide Control 0 */
- volatile uint8_t ECPM_SCDCR0;
- /* 0x00D: System Clock Divide Control 1 */
- volatile uint8_t ECPM_SCDCR1;
- /* 0x00E: System Clock Divide Control 2 */
- volatile uint8_t ECPM_SCDCR2;
- /* 0x00F: System Clock Divide Control 3 */
- volatile uint8_t ECPM_SCDCR3;
- /* 0x010: System Clock Divide Control 4 */
- volatile uint8_t ECPM_SCDCR4;
-};
-
-#endif /* _ITE_IT8XXX2_REG_DEF_CROS_H */
diff --git a/zephyr/include/soc/nuvoton_npcx/reg_def_cros.h b/zephyr/include/soc/nuvoton_npcx/reg_def_cros.h
deleted file mode 100644
index 8702502a13..0000000000
--- a/zephyr/include/soc/nuvoton_npcx/reg_def_cros.h
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright (c) 2020 Nuvoton Technology Corporation.
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-/*
- * @file
- * @brief Nuvoton NPCX register structure definitions used by the Chrome OS EC.
- */
-
-#ifndef _NUVOTON_NPCX_REG_DEF_CROS_H
-#define _NUVOTON_NPCX_REG_DEF_CROS_H
-
-/*
- * KBS (Keyboard Scan) device registers
- */
-struct kbs_reg {
- volatile uint8_t reserved1[4];
- /* 0x004: Keyboard Scan In */
- volatile uint8_t KBSIN;
- /* 0x005: Keyboard Scan In Pull-Up Enable */
- volatile uint8_t KBSINPU;
- /* 0x006: Keyboard Scan Out 0 */
- volatile uint16_t KBSOUT0;
- /* 0x008: Keyboard Scan Out 1 */
- volatile uint16_t KBSOUT1;
- /* 0x00A: Keyboard Scan Buffer Index */
- volatile uint8_t KBS_BUF_INDX;
- /* 0x00B: Keyboard Scan Buffer Data */
- volatile uint8_t KBS_BUF_DATA;
- /* 0x00C: Keyboard Scan Event */
- volatile uint8_t KBSEVT;
- /* 0x00D: Keyboard Scan Control */
- volatile uint8_t KBSCTL;
- /* 0x00E: Keyboard Scan Configuration Index */
- volatile uint8_t KBS_CFG_INDX;
- /* 0x00F: Keyboard Scan Configuration Data */
- volatile uint8_t KBS_CFG_DATA;
-};
-
-/* KBS register fields */
-#define NPCX_KBSBUFINDX 0
-#define NPCX_KBSEVT_KBSDONE 0
-#define NPCX_KBSEVT_KBSERR 1
-#define NPCX_KBSCTL_START 0
-#define NPCX_KBSCTL_KBSMODE 1
-#define NPCX_KBSCTL_KBSIEN 2
-#define NPCX_KBSCTL_KBSINC 3
-#define NPCX_KBSCTL_KBHDRV_FIELD FIELD(6, 2)
-#define NPCX_KBSCFGINDX 0
-/* Index of 'Automatic Scan' configuration register */
-#define KBS_CFG_INDX_DLY1 0 /* Keyboard Scan Delay T1 Byte */
-#define KBS_CFG_INDX_DLY2 1 /* Keyboard Scan Delay T2 Byte */
-#define KBS_CFG_INDX_RTYTO 2 /* Keyboard Scan Retry Timeout */
-#define KBS_CFG_INDX_CNUM 3 /* Keyboard Scan Columns Number */
-#define KBS_CFG_INDX_CDIV 4 /* Keyboard Scan Clock Divisor */
-
-/*
- * Flash Interface Unit (FIU) device registers
- */
-struct fiu_reg {
- /* 0x001: Burst Configuration */
- volatile uint8_t BURST_CFG;
- /* 0x002: FIU Response Configuration */
- volatile uint8_t RESP_CFG;
- volatile uint8_t reserved1[18];
- /* 0x014: SPI Flash Configuration */
- volatile uint8_t SPI_FL_CFG;
- volatile uint8_t reserved2;
- /* 0x016: UMA Code Byte */
- volatile uint8_t UMA_CODE;
- /* 0x017: UMA Address Byte 0 */
- volatile uint8_t UMA_AB0;
- /* 0x018: UMA Address Byte 1 */
- volatile uint8_t UMA_AB1;
- /* 0x019: UMA Address Byte 2 */
- volatile uint8_t UMA_AB2;
- /* 0x01A: UMA Data Byte 0 */
- volatile uint8_t UMA_DB0;
- /* 0x01B: UMA Data Byte 1 */
- volatile uint8_t UMA_DB1;
- /* 0x01C: UMA Data Byte 2 */
- volatile uint8_t UMA_DB2;
- /* 0x01D: UMA Data Byte 3 */
- volatile uint8_t UMA_DB3;
- /* 0x01E: UMA Control and Status */
- volatile uint8_t UMA_CTS;
- /* 0x01F: UMA Extended Control and Status */
- volatile uint8_t UMA_ECTS;
- /* 0x020: UMA Data Bytes 0-3 */
- volatile uint32_t UMA_DB0_3;
- volatile uint8_t reserved3[2];
- /* 0x026: CRC Control Register */
- volatile uint8_t CRCCON;
- /* 0x027: CRC Entry Register */
- volatile uint8_t CRCENT;
- /* 0x028: CRC Initialization and Result Register */
- volatile uint32_t CRCRSLT;
- volatile uint8_t reserved4[4];
- /* 0x030: FIU Read Command */
- volatile uint8_t FIU_RD_CMD;
- volatile uint8_t reserved5;
- /* 0x032: FIU Dummy Cycles */
- volatile uint8_t FIU_DMM_CYC;
- /* 0x033: FIU Extended Configuration */
- volatile uint8_t FIU_EXT_CFG;
-};
-
-/* FIU register fields */
-#define NPCX_RESP_CFG_IAD_EN 0
-#define NPCX_RESP_CFG_DEV_SIZE_EX 2
-#define NPCX_UMA_CTS_A_SIZE 3
-#define NPCX_UMA_CTS_C_SIZE 4
-#define NPCX_UMA_CTS_RD_WR 5
-#define NPCX_UMA_CTS_DEV_NUM 6
-#define NPCX_UMA_CTS_EXEC_DONE 7
-#define NPCX_UMA_ECTS_SW_CS0 0
-#define NPCX_UMA_ECTS_SW_CS1 1
-#define NPCX_UMA_ECTS_SEC_CS 2
-#define NPCX_UMA_ECTS_UMA_LOCK 3
-
-/* UMA fields selections */
-#define UMA_FLD_ADDR BIT(NPCX_UMA_CTS_A_SIZE) /* 3-bytes ADR field */
-#define UMA_FLD_NO_CMD BIT(NPCX_UMA_CTS_C_SIZE) /* No 1-Byte CMD field */
-#define UMA_FLD_WRITE BIT(NPCX_UMA_CTS_RD_WR) /* Write transaction */
-#define UMA_FLD_SHD_SL BIT(NPCX_UMA_CTS_DEV_NUM) /* Shared flash selected */
-#define UMA_FLD_EXEC BIT(NPCX_UMA_CTS_EXEC_DONE)
-
-#define UMA_FIELD_DATA_1 0x01
-#define UMA_FIELD_DATA_2 0x02
-#define UMA_FIELD_DATA_3 0x03
-#define UMA_FIELD_DATA_4 0x04
-
-/* UMA code for transaction */
-#define UMA_CODE_CMD_ONLY (UMA_FLD_EXEC | UMA_FLD_SHD_SL)
-#define UMA_CODE_CMD_ADR (UMA_FLD_EXEC | UMA_FLD_ADDR | \
- UMA_FLD_SHD_SL)
-#define UMA_CODE_CMD_RD_BYTE(n) (UMA_FLD_EXEC | UMA_FIELD_DATA_##n | \
- UMA_FLD_SHD_SL)
-#define UMA_CODE_RD_BYTE(n) (UMA_FLD_EXEC | UMA_FLD_NO_CMD | \
- UMA_FIELD_DATA_##n | UMA_FLD_SHD_SL)
-#define UMA_CODE_CMD_WR_ONLY (UMA_FLD_EXEC | UMA_FLD_WRITE | \
- UMA_FLD_SHD_SL)
-#define UMA_CODE_CMD_WR_BYTE(n) (UMA_FLD_EXEC | UMA_FLD_WRITE | \
- UMA_FIELD_DATA_##n | UMA_FLD_SHD_SL)
-#define UMA_CODE_CMD_WR_ADR (UMA_FLD_EXEC | UMA_FLD_WRITE | UMA_FLD_ADDR | \
- UMA_FLD_SHD_SL)
-
-#define UMA_CODE_CMD_ADR_WR_BYTE(n) (UMA_FLD_EXEC | UMA_FLD_WRITE | \
- UMA_FLD_ADDR | UMA_FIELD_DATA_##n | \
- UMA_FLD_SHD_SL)
-
-/*
- * Monotonic Counter (MTC) device registers
- */
-struct mtc_reg {
- /* 0x000: Timing Ticks Count Register */
- volatile uint32_t TTC;
- /* 0x004: Wake-Up Ticks Count Register */
- volatile uint32_t WTC;
-};
-
-/* MTC register fields */
-#define NPCX_WTC_PTO 30
-#define NPCX_WTC_WIE 31
-
-/* SHI (Serial Host Interface) registers */
-struct shi_reg {
- volatile uint8_t reserved1;
- /* 0x001: SHI Configuration 1 */
- volatile uint8_t SHICFG1;
- /* 0x002: SHI Configuration 2 */
- volatile uint8_t SHICFG2;
- volatile uint8_t reserved2[2];
- /* 0x005: Event Enable */
- volatile uint8_t EVENABLE;
- /* 0x006: Event Status */
- volatile uint8_t EVSTAT;
- /* 0x007: SHI Capabilities */
- volatile uint8_t CAPABILITY;
- /* 0x008: Status */
- volatile uint8_t STATUS;
- volatile uint8_t reserved3;
- /* 0x00A: Input Buffer Status */
- volatile uint8_t IBUFSTAT;
- /* 0x00B: Output Buffer Status */
- volatile uint8_t OBUFSTAT;
- /* 0x00C: SHI Configuration 3 */
- volatile uint8_t SHICFG3;
- /* 0x00D: SHI Configuration 4 */
- volatile uint8_t SHICFG4;
- /* 0x00E: SHI Configuration 5 */
- volatile uint8_t SHICFG5;
- /* 0x00F: Event Status 2 */
- volatile uint8_t EVSTAT2;
- /* 0x010: Event Enable 2 */
- volatile uint8_t EVENABLE2;
- volatile uint8_t reserved4[15];
- /* 0x20~0x9F: Output Buffer */
- volatile uint8_t OBUF[128];
- /* 0xA0~0x11F: Input Buffer */
- volatile uint8_t IBUF[128];
-};
-
-/* SHI register fields */
-#define NPCX_SHICFG1_EN 0
-#define NPCX_SHICFG1_MODE 1
-#define NPCX_SHICFG1_WEN 2
-#define NPCX_SHICFG1_AUTIBF 3
-#define NPCX_SHICFG1_AUTOBE 4
-#define NPCX_SHICFG1_DAS 5
-#define NPCX_SHICFG1_CPOL 6
-#define NPCX_SHICFG1_IWRAP 7
-#define NPCX_SHICFG2_SIMUL 0
-#define NPCX_SHICFG2_BUSY 1
-#define NPCX_SHICFG2_ONESHOT 2
-#define NPCX_SHICFG2_SLWU 3
-#define NPCX_SHICFG2_REEN 4
-#define NPCX_SHICFG2_RESTART 5
-#define NPCX_SHICFG2_REEVEN 6
-#define NPCX_EVENABLE_OBEEN 0
-#define NPCX_EVENABLE_OBHEEN 1
-#define NPCX_EVENABLE_IBFEN 2
-#define NPCX_EVENABLE_IBHFEN 3
-#define NPCX_EVENABLE_EOREN 4
-#define NPCX_EVENABLE_EOWEN 5
-#define NPCX_EVENABLE_STSREN 6
-#define NPCX_EVENABLE_IBOREN 7
-#define NPCX_EVSTAT_OBE 0
-#define NPCX_EVSTAT_OBHE 1
-#define NPCX_EVSTAT_IBF 2
-#define NPCX_EVSTAT_IBHF 3
-#define NPCX_EVSTAT_EOR 4
-#define NPCX_EVSTAT_EOW 5
-#define NPCX_EVSTAT_STSR 6
-#define NPCX_EVSTAT_IBOR 7
-#define NPCX_STATUS_OBES 6
-#define NPCX_STATUS_IBFS 7
-#define NPCX_SHICFG3_OBUFLVLDIS 7
-#define NPCX_SHICFG4_IBUFLVLDIS 7
-#define NPCX_SHICFG5_IBUFLVL2 FIELD(0, 6)
-#define NPCX_SHICFG5_IBUFLVL2DIS 7
-#define NPCX_EVSTAT2_IBHF2 0
-#define NPCX_EVSTAT2_CSNRE 1
-#define NPCX_EVSTAT2_CSNFE 2
-#define NPCX_EVENABLE2_IBHF2EN 0
-#define NPCX_EVENABLE2_CSNREEN 1
-#define NPCX_EVENABLE2_CSNFEEN 2
-
-#endif /* _NUVOTON_NPCX_REG_DEF_CROS_H */
diff --git a/zephyr/linker/CMakeLists.txt b/zephyr/linker/CMakeLists.txt
deleted file mode 100644
index 71955c6d9d..0000000000
--- a/zephyr/linker/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Add the fixed sections to the output image.
-zephyr_linker_sources(ROM_START SORT_KEY 1 fixed-sections.ld)
-
-# Support protection of part of the internal RAM
-zephyr_linker_sources(RWDATA SORT_KEY 1 iram_text.ld)
-
-# Compute the image size
-zephyr_linker_sources(RAM_SECTIONS image_size.ld)
-
-# Little FW with specific purposes used by NPCX EC
-zephyr_linker_sources_ifdef(CONFIG_SOC_FAMILY_NPCX ROM_START SORT_KEY 1
- npcx-lfw.ld)
-
-zephyr_linker_sources(DATA_SECTIONS iterables-ram.ld)
-zephyr_linker_sources(SECTIONS iterables-rom.ld)
diff --git a/zephyr/linker/fixed-sections.ld b/zephyr/linker/fixed-sections.ld
deleted file mode 100644
index 5046823713..0000000000
--- a/zephyr/linker/fixed-sections.ld
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#if defined(CONFIG_PLATFORM_EC) && !defined(CONFIG_ARCH_POSIX)
-*(.fixed.*)
-#endif
diff --git a/zephyr/linker/image_size.ld b/zephyr/linker/image_size.ld
deleted file mode 100644
index b1e401ae7f..0000000000
--- a/zephyr/linker/image_size.ld
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#if defined(CONFIG_CPU_CORTEX_M) || defined(CONFIG_CPU_CORTEX_R) || \
- defined(CONFIG_CPU_CORTEX_A)
-__image_size = _flash_used;
-#elif defined(CONFIG_RISCV)
-__image_size = __rom_region_size;
-#else
-/*
- * Intentionally set to 0. Some components, such as EFS2, need this value.
- * Having it be 0 will make it easier to find and add new cores.
- */
-__image_size = 0;
-#endif
diff --git a/zephyr/linker/iram_text.ld b/zephyr/linker/iram_text.ld
deleted file mode 100644
index 3ea3f4db7e..0000000000
--- a/zephyr/linker/iram_text.ld
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef CONFIG_ARCH_POSIX
-
-/* This code taken from core/cortex-m/ec.lds.S */
-
-#if defined(CONFIG_PLATFORM_EC_MPU)
-/* MPU regions must be aligned to a 32-byte boundary */
-#define _IRAM_ALIGN 32
-#else
-#define _IRAM_ALIGN 4
-#endif
-
- . = ALIGN(_IRAM_ALIGN);
- __iram_text_start = .;
- *(.iram.text)
- . = ALIGN(_IRAM_ALIGN);
- __iram_text_end = .;
-
-#endif /* CONFIG_ARCH_POSIX */
diff --git a/zephyr/linker/iterables-ram.ld b/zephyr/linker/iterables-ram.ld
deleted file mode 100644
index 58318a0e78..0000000000
--- a/zephyr/linker/iterables-ram.ld
+++ /dev/null
@@ -1,3 +0,0 @@
-#ifdef CONFIG_PLATFORM_EC_HOOKS
-ITERABLE_SECTION_RAM(zephyr_shim_hook_list, 4)
-#endif
diff --git a/zephyr/linker/iterables-rom.ld b/zephyr/linker/iterables-rom.ld
deleted file mode 100644
index b8e451a085..0000000000
--- a/zephyr/linker/iterables-rom.ld
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifdef CONFIG_PLATFORM_EC_HOSTCMD
-ITERABLE_SECTION_ROM(host_command, 4)
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_MKBP_EVENT
-ITERABLE_SECTION_ROM(mkbp_event_source, 4)
-#endif
diff --git a/zephyr/linker/npcx-lfw.ld b/zephyr/linker/npcx-lfw.ld
deleted file mode 100644
index a6de1df65a..0000000000
--- a/zephyr/linker/npcx-lfw.ld
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-. = ALIGN(4);
-__lfw_text_start = .;
-*(.lfw.*)
-. = ALIGN(4);
-__lfw_text_end = .;
-
-#ifdef CONFIG_PLATFORM_EC_EXTERNAL_STORAGE
-. = ALIGN(4);
-__flash_lpfw_start = .;
-/* Entering deep idle FW for better power consumption */
-KEEP(*(.lowpower_ram))
-. = ALIGN(4);
-__flash_lpfw_end = .;
-__flash_lplfw_start = .;
-/* GDMA utilities for better FW download speed */
-KEEP(*(.lowpower_ram2))
-. = ALIGN(4);
-__flash_lplfw_end = .;
-#endif /* CONFIG_PLATFORM_EC_EXTERNAL_STORAGE */
diff --git a/zephyr/module.yml b/zephyr/module.yml
deleted file mode 100644
index 66bfcd8d9f..0000000000
--- a/zephyr/module.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2020 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.
-
-build:
- cmake: zephyr/
- kconfig: zephyr/Kconfig
- settings:
- board_root: zephyr/
diff --git a/zephyr/projects/asurada/hayato/CMakeLists.txt b/zephyr/projects/asurada/hayato/CMakeLists.txt
deleted file mode 100644
index 660b0a9088..0000000000
--- a/zephyr/projects/asurada/hayato/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-add_compile_definitions(BOARD_HAYATO)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(hayato)
-
-zephyr_library_include_directories(include)
-
-set(PLATFORM_EC_BASEBOARD "${PLATFORM_EC}/baseboard/asurada" CACHE PATH
- "Path to the platform/ec baseboard directory")
-set(PLATFORM_EC_BOARD "${PLATFORM_EC}/board/hayato" CACHE PATH
- "Path to the platform/ec board directory")
-
-zephyr_library_sources(
- "${PLATFORM_EC_BASEBOARD}/board_chipset.c"
- "${PLATFORM_EC_BASEBOARD}/board_id.c"
- "${PLATFORM_EC_BASEBOARD}/hibernate.c"
- "${PLATFORM_EC_BASEBOARD}/regulator.c"
- "${PLATFORM_EC_BASEBOARD}/usbc_config.c"
- "${PLATFORM_EC_BASEBOARD}/usb_pd_policy.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C
- "src/i2c.c")
diff --git a/zephyr/projects/asurada/hayato/battery.dts b/zephyr/projects/asurada/hayato/battery.dts
deleted file mode 100644
index deb803bb8c..0000000000
--- a/zephyr/projects/asurada/hayato/battery.dts
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- batteries {
- default_battery: c235 {
- compatible = "as3gwrc3ka,c235-41";
- };
- };
-};
diff --git a/zephyr/projects/asurada/hayato/gpio.dts b/zephyr/projects/asurada/hayato/gpio.dts
deleted file mode 100644
index f04171651f..0000000000
--- a/zephyr/projects/asurada/hayato/gpio.dts
+++ /dev/null
@@ -1,347 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-gpios {
- compatible = "named-gpios";
-
- power_button_l: power_button_l {
- gpios = <&gpioe 4 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_POWER_BUTTON_L";
- label = "POWER_BUTTON_L";
- };
- lid_open: lid_open {
- gpios = <&gpioe 2 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- label = "LID_OPEN";
- };
- tablet_mode_l {
- gpios = <&gpioj 7 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- label = "TABLET_MODE_L";
- };
- ap_ec_warm_rst_req {
- gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_AP_EC_WARM_RST_REQ";
- label = "AP_EC_WARM_RST_REQ";
- };
- ap_ec_watchdog_l {
- gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_AP_EC_WATCHDOG_L";
- label = "AP_EC_WATCHDOG_L";
- };
- ap_in_sleep_l {
- gpios = <&gpiof 2 (GPIO_INPUT | GPIO_PULL_DOWN |
- GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_AP_IN_SLEEP_L";
- label = "AP_IN_SLEEP_L";
- };
- ap-xhci-init-done {
- gpios = <&gpiod 2 (GPIO_INPUT | GPIO_PULL_DOWN |
- GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_AP_XHCI_INIT_DONE";
- label = "AP_XHCI_INIT_DONE";
- };
- pmic_ec_pwrgd {
- gpios = <&gpiof 3 (GPIO_INPUT | GPIO_PULL_DOWN |
- GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_PMIC_EC_PWRGD";
- label = "PMIC_EC_PWRGD";
- };
- gpio_accel_gyro_int_l: base_imu_int_l {
- gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_EC_IMU_INT_L";
- label = "BASE_IMU_INT_L";
- };
- lid_accel_int_l {
- gpios = <&gpioj 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_LID_ACCEL_INT_L";
- label = "LID_ACCEL_INT_L";
- };
- als_rgb_int_odl {
- gpios = <&gpiof 0 GPIO_INPUT>;
- enum-name = "GPIO_ALS_RGB_INT_ODL";
- label = "ALS_RGB_INT_ODL";
- };
- usb_c0_ppc_int_odl {
- gpios = <&gpiod 1 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PPC_INT_ODL";
- label = "USB_C0_PPC_INT_ODL";
- };
- usb_c0_bc12_int_odl {
- gpios = <&gpioj 6 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_BC12_INT_ODL";
- label = "USB_C0_BC12_INT_ODL";
- };
- usb_c1_bc12_int_l {
- gpios = <&gpioj 4 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_BC12_INT_L";
- label = "USB_C1_BC12_INT_L";
- };
- volume_down_l {
- gpios = <&gpiod 5 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- label = "VOLUME_DOWN_L";
- };
- volume_up_l {
- gpios = <&gpiod 6 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_VOLUME_UP_L";
- label = "VOLUME_UP_L";
- };
- ac_present: ac_present {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- label = "AC_PRESENT";
- };
- wp {
- gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_WP";
- label = "WP";
- };
- spi0_cs {
- gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_SPI0_CS";
- label = "SPI0_CS";
- };
- x_ec_gpio2 {
- gpios = <&gpiob 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_X_EC_GPIO2";
- label = "X_EC_GPIO2";
- };
- ec_pmic_en_odl {
- gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_EC_PMIC_EN_ODL";
- label = "EC_PMIC_EN_ODL";
- };
- ec_pmic_watchdog_l {
- gpios = <&gpioh 0 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_EC_PMIC_WATCHDOG_L";
- label = "EC_PMIC_WATCHDOG_L";
- };
- en_pp5000_a {
- gpios = <&gpioc 6 GPIO_OUT_HIGH>;
- enum-name = "GPIO_EN_PP5000_A";
- label = "EN_PP5000_A";
- };
- pg_mt6315_proc_odl {
- gpios = <&gpioe 1 GPIO_INPUT>;
- enum-name = "GPIO_PG_MT6315_PROC_ODL";
- label = "PG_MT6315_PROC_ODL";
- };
- pg_mt6360_odl {
- gpios = <&gpiof 1 GPIO_INPUT>;
- enum-name = "GPIO_PG_MT6360_ODL";
- label = "PG_MT6360_ODL";
- };
- pg_pp5000_a_odl {
- gpios = <&gpioa 6 GPIO_INPUT>;
- enum-name = "GPIO_PG_PP5000_A_ODL";
- label = "PG_PP5000_A_ODL";
- };
- en_slp_z {
- gpios = <&gpioe 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_SLP_Z";
- label = "EN_SLP_Z";
- };
- sys_rst_odl {
- gpios = <&gpiob 6 GPIO_ODR_LOW>;
- enum-name = "GPIO_SYS_RST_ODL";
- label = "SYS_RST_ODL";
- };
- ec_bl_en_od {
- gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_EC_BL_EN_OD";
- label = "EC_BL_EN_OD";
- };
- ec_int_l {
- gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_EC_INT_L";
- label = "EC_INT_L";
- };
- dp_aux_path_sel {
- gpios = <&gpiog 0 GPIO_OUT_HIGH>;
- enum-name = "GPIO_DP_AUX_PATH_SEL";
- label = "DP_AUX_PATH_SEL";
- };
- ec_dpbrdg_hpd_odl {
- gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_EC_DPBRDG_HPD_ODL";
- label = "EC_DPBRDG_HPD_ODL";
- };
- en_pp5000_usb_a0_vbus {
- gpios = <&gpiob 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP5000_USB_A0_VBUS";
- label = "EN_PP5000_USB_A0_VBUS";
- };
- usb_c0_frs_en {
- gpios = <&gpioh 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_USB_C0_FRS_EN";
- label = "USB_C0_FRS_EN";
- };
- ec_batt_pres_odl {
- gpios = <&gpioc 0 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- label = "EC_BATT_PRES_ODL";
- };
- bc12_det_en {
- gpios = <&gpioj 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_BC12_DET_EN";
- label = "BC12_DET_EN";
- };
- en_ec_id_odl {
- gpios = <&gpioh 5 GPIO_ODR_LOW>;
- enum-name = "GPIO_EN_EC_ID_ODL";
- label = "EN_EC_ID_ODL";
- };
- entering_rw {
- gpios = <&gpioc 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- label = "ENTERING_RW";
- };
- en_5v_usm {
- gpios = <&gpiod 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_5V_USM";
- label = "EN_5V_USM";
- };
- i2c_b_scl {
- gpios = <&gpiob 3 GPIO_INPUT>;
- enum-name = "GPIO_I2C_B_SCL";
- label = "I2C_B_SCL";
- };
- i2c_b_sda {
- gpios = <&gpiob 4 GPIO_INPUT>;
- enum-name = "GPIO_I2C_B_SDA";
- label = "I2C_B_SDA";
- };
- i2c_c_scl {
- gpios = <&gpioc 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_I2C_C_SCL";
- label = "I2C_C_SCL";
- };
- i2c_c_sda {
- gpios = <&gpioc 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_I2C_C_SDA";
- label = "I2C_C_SDA";
- };
- i2c_e_scl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_I2C_E_SCL";
- label = "I2C_E_SCL";
- };
- i2c_e_sda {
- gpios = <&gpioe 7 GPIO_INPUT>;
- enum-name = "GPIO_I2C_E_SDA";
- label = "I2C_E_SDA";
- };
- i2c_f_scl {
- gpios = <&gpiof 6 GPIO_INPUT>;
- enum-name = "GPIO_I2C_F_SCL";
- label = "I2C_F_SCL";
- };
- i2c_f_sda {
- gpios = <&gpiof 7 GPIO_INPUT>;
- enum-name = "GPIO_I2C_F_SDA";
- label = "I2C_F_SDA";
- };
- ec_x_gpio1 {
- gpios = <&gpioh 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_X_GPIO1";
- label = "EC_X_GPIO1";
- };
- ec_x_gpio3 {
- gpios = <&gpioj 1 GPIO_INPUT>;
- enum-name = "GPIO_EC_X_GPIO3";
- label = "EC_X_GPIO3";
- };
- set_vmc_volt_at_1v8 {
- gpios = <&gpiod 4 (GPIO_INPUT | GPIO_PULL_DOWN |
- GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_SET_VMC_VOLT_AT_1V8";
- label = "SET_VMC_VOLT_AT_1V8";
- };
- en_pp3000_vmc_pmu {
- gpios = <&gpiod 2 (GPIO_INPUT | GPIO_PULL_DOWN |
- GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_EN_PP3000_VMC_PMU";
- label = "EN_PP3000_VMC_PMU";
- };
- packet_mode_en {
- gpios = <&gpioa 3 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- enum-name = "GPIO_PACKET_MODE_EN";
- label = "PACKET_MODE_EN";
- };
- usb_a0_fault_odl {
- gpios = <&gpioa 7 GPIO_INPUT>;
- enum-name = "GPIO_USB_A0_FAULT_ODL";
- label = "USB_A0_FAULT_ODL";
- };
- charger_prochot_odl {
- gpios = <&gpioc 3 GPIO_INPUT>;
- enum-name = "GPIO_CHARGER_PROCHOT_ODL";
- label = "CHARGER_PROCHOT_ODL";
- };
- pg_mt6315_gpu_odl {
- gpios = <&gpioh 6 GPIO_INPUT>;
- enum-name = "GPIO_PG_MT6315_GPU_ODL";
- label = "PG_MT6315_GPU_ODL";
- };
- en_pp3000_sd_u {
- gpios = <&gpiog 1 (GPIO_INPUT | GPIO_PULL_DOWN |
- GPIO_VOLTAGE_1P8)>;
- enum-name = "GPIO_EN_PP3000_SD_U";
- label = "EN_PP3000_SD_U";
- };
- ccd_mode_odl {
- gpios = <&gpioc 4 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- label = "CCD_MODE_ODL";
- };
- spi_clk_gpg6 {
- gpios = <&gpiog 6 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_SPI_CLK_GPG6";
- label = "SPI_CLK_GPG6";
- };
- spi_mosi_gpg4 {
- gpios = <&gpiog 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_SPI_MOSI_GPG4";
- label = "SPI_MOSI_GPG4";
- };
- spi_miso_gpg5 {
- gpios = <&gpiog 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_SPI_MISO_GPG5";
- label = "SPI_MISO_GPG5";
- };
- spi_cs_gpg7 {
- gpios = <&gpiog 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_SPI_CS_GPG7";
- label = "SPI_CS_GPG7";
- };
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-pins = <&ac_present
- &power_button_l
- &lid_open>;
- };
-
- unused-pins {
- compatible = "unused-gpios";
-
- unused-gpios =
- /* uart1_rx */
- <&gpiob 0 GPIO_INPUT>,
- /* nc_gpg3 */
- <&gpiog 3 GPIO_OUT_LOW>,
- /* nc_gpi7 */
- <&gpioi 7 GPIO_OUT_LOW>,
- /* nc_gpm2 */
- <&gpiom 2 (GPIO_INPUT | GPIO_PULL_DOWN)>,
- /* nc_gpm3 */
- <&gpiom 3 (GPIO_INPUT | GPIO_PULL_DOWN)>,
- /* nc_gpm6 */
- <&gpiom 6 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- };
-};
diff --git a/zephyr/projects/asurada/hayato/include/gpio_map.h b/zephyr/projects/asurada/hayato/include/gpio_map.h
deleted file mode 100644
index 5f01f290d2..0000000000
--- a/zephyr/projects/asurada/hayato/include/gpio_map.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-/*
- * TODO(b:188674805) create a driver to pull this information from DeviceTree
- */
-#include "power/mt8192.h"
-
-#define GPIO_ENTERING_RW GPIO_UNIMPLEMENTED
-#define GPIO_WP_L GPIO_UNIMPLEMENTED
-
-#ifdef CONFIG_PLATFORM_EC_GMR_TABLET_MODE
-#define GMR_TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L
-#endif
-
-/*
- * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items.
- *
- * Each GPIO_INT requires three parameters:
- * gpio_signal - The enum gpio_signal for the interrupt gpio
- * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH)
- * handler - The platform/ec interrupt handler.
- *
- * Ensure that this files includes all necessary headers to declare all
- * referenced handler functions.
- *
- * For example, one could use the follow definition:
- * #define EC_CROS_GPIO_INTERRUPTS \
- * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print)
- */
-#define EC_CROS_GPIO_INTERRUPTS \
- GPIO_INT(GPIO_LID_OPEN, \
- GPIO_INT_EDGE_BOTH, lid_interrupt) \
- GPIO_INT(GPIO_POWER_BUTTON_L, \
- GPIO_INT_EDGE_BOTH, power_button_interrupt) \
- GPIO_INT(GPIO_EC_IMU_INT_L, \
- GPIO_INT_EDGE_FALLING, bmi160_interrupt) \
- GPIO_INT(GPIO_LID_ACCEL_INT_L, \
- GPIO_INT_EDGE_FALLING, lis2dw12_interrupt) \
- GPIO_INT(GPIO_TABLET_MODE_L, \
- GPIO_INT_EDGE_BOTH, gmr_tablet_switch_isr) \
- GPIO_INT(GPIO_USB_C0_PPC_INT_ODL, \
- GPIO_INT_EDGE_BOTH, ppc_interrupt) \
- GPIO_INT(GPIO_USB_C0_BC12_INT_ODL, \
- GPIO_INT_EDGE_FALLING, bc12_interrupt) \
- GPIO_INT(GPIO_USB_C1_BC12_INT_L, \
- GPIO_INT_EDGE_FALLING, bc12_interrupt) \
- GPIO_INT(GPIO_AC_PRESENT, \
- GPIO_INT_EDGE_BOTH, extpower_interrupt) \
- GPIO_INT(GPIO_X_EC_GPIO2, \
- GPIO_INT_EDGE_FALLING, x_ec_interrupt) \
- GPIO_INT(GPIO_AP_XHCI_INIT_DONE, \
- GPIO_INT_EDGE_BOTH, usb_a0_interrupt) \
- GPIO_INT(GPIO_AP_EC_WATCHDOG_L, \
- GPIO_INT_EDGE_BOTH, chipset_watchdog_interrupt) \
- GPIO_INT(GPIO_AP_IN_SLEEP_L, \
- GPIO_INT_EDGE_BOTH, power_signal_interrupt) \
- GPIO_INT(GPIO_PMIC_EC_PWRGD, \
- GPIO_INT_EDGE_BOTH, power_signal_interrupt) \
- GPIO_INT(GPIO_AP_EC_WARM_RST_REQ, \
- GPIO_INT_EDGE_RISING, chipset_reset_request_interrupt) \
- GPIO_INT(GPIO_SPI0_CS, \
- GPIO_INT_EDGE_FALLING, spi_event)
-
-#define GPIO_EN_PP5000 GPIO_EN_PP5000_A
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
diff --git a/zephyr/projects/asurada/hayato/include/i2c_map.h b/zephyr/projects/asurada/hayato/include/i2c_map.h
deleted file mode 100644
index 898d5c398c..0000000000
--- a/zephyr/projects/asurada/hayato/include/i2c_map.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_I2C_MAP_H
-#define __ZEPHYR_I2C_MAP_H
-
-#include <devicetree.h>
-
-#include "i2c/i2c.h"
-
-#endif /* __ZEPHYR_I2C_MAP_H */
diff --git a/zephyr/projects/asurada/hayato/include/pwm_map.h b/zephyr/projects/asurada/hayato/include/pwm_map.h
deleted file mode 100644
index 0f74812827..0000000000
--- a/zephyr/projects/asurada/hayato/include/pwm_map.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_CHROME_PWM_MAP_H
-#define __ZEPHYR_CHROME_PWM_MAP_H
-
-#include <devicetree.h>
-
-#include "config.h"
-
-#include "pwm/pwm.h"
-
-/*
- * TODO(b/177452529): eliminate the dependency on enum pwm_channel
- * and configure this information directly from the device tree.
- */
-#define PWM_CH_LED1 NAMED_PWM(led1)
-#define PWM_CH_LED2 NAMED_PWM(led2)
-#define PWM_CH_LED3 NAMED_PWM(led3)
-
-#endif /* __ZEPHYR_CHROME_PWM_MAP_H */
diff --git a/zephyr/projects/asurada/hayato/motionsense.dts b/zephyr/projects/asurada/hayato/motionsense.dts
deleted file mode 100644
index 10128b0838..0000000000
--- a/zephyr/projects/asurada/hayato/motionsense.dts
+++ /dev/null
@@ -1,157 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <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.
- */
- bmi160-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 {
- label = "LID_MUTEX";
- };
-
- mutex_bmi160: bmi160-mutex {
- label = "BMI160_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)>;
- };
- };
-
- /*
- * 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 {
- bmi160_data: bmi160-drv-data {
- compatible = "cros-ec,drvdata-bmi160";
- status = "okay";
- };
-
- lis2dw12_data: lis2dw12-drv-data {
- compatible = "cros-ec,drvdata-lis2dw12";
- status = "okay";
- };
- };
-
- /*
- * List of motion sensors that creates motion_sensors array.
- * The label "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,lis2dw12";
- status = "okay";
-
- label = "Lid Accel";
- 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>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_accel: base-accel {
- compatible = "cros-ec,bmi160-accel";
- status = "okay";
-
- label = "Base Accel";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi160>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&bmi160_data>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base-gyro {
- compatible = "cros-ec,bmi160-gyro";
- status = "okay";
-
- label = "Base Gyro";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi160>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&bmi160_data>;
- };
- };
-
- motionsense-sensor-info {
- compatible = "cros-ec,motionsense-sensor-info";
-
- /*
- * list of GPIO interrupts that have to
- * be enabled at initial stage
- */
- sensor-irqs = <&gpio_accel_gyro_int_l>;
- /* list of sensors in force mode */
- accel-force-mode-sensors = <&lid_accel>;
- };
-};
diff --git a/zephyr/projects/asurada/hayato/prj.conf b/zephyr/projects/asurada/hayato/prj.conf
deleted file mode 100644
index 2faab291f2..0000000000
--- a/zephyr/projects/asurada/hayato/prj.conf
+++ /dev/null
@@ -1,120 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-CONFIG_SHIMMED_TASKS=y
-
-# Bring up options
-CONFIG_KERNEL_SHELL=y
-CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y
-CONFIG_PLATFORM_EC_CONSOLE_USES_PRINTK=y
-
-# Battery
-CONFIG_HAS_TASK_USB_CHG_P1=y
-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_CHARGE_MANAGER=y
-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_ISL9238C=y
-CONFIG_PLATFORM_EC_CHARGER_MAINTAIN_VBAT=y
-CONFIG_PLATFORM_EC_CHARGER_OTG=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
-
-# Host Commands
-CONFIG_PLATFORM_EC_HOSTCMD=y
-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_HOSTCMD_REGULATOR=y
-CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y
-
-# MKBP event mask
-CONFIG_PLATFORM_EC_MKBP_EVENT_WAKEUP_MASK=y
-CONFIG_PLATFORM_EC_MKBP_HOST_EVENT_WAKEUP_MASK=y
-
-# Sensors
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_ACCEL_INTERRUPTS=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_SWITCH=y
-CONFIG_PLATFORM_EC_TABLET_MODE=y
-CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y
-
-# Sensor Drivers
-CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y
-CONFIG_PLATFORM_EC_ACCEL_LIS2DW12_AS_BASE=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI160=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
-
-# USB-A
-CONFIG_PLATFORM_EC_USB_A_PORT_COUNT=1
-
-# USB-C
-CONFIG_HAS_TASK_PD_C1=y
-CONFIG_HAS_TASK_PD_INT_C1=n
-CONFIG_HAS_TASK_PD_INT_C0=n
-CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
-CONFIG_PLATFORM_EC_BC12_DETECT_MT6360=y
-CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n
-CONFIG_PLATFORM_EC_MT6360_BC12_GPIO=y
-CONFIG_PLATFORM_EC_SMBUS_PEC=y
-CONFIG_PLATFORM_EC_USBC_PPC_DEDICATED_INT=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_PS8743=y
-CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y
-CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=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_FRS_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_ITE_ACTIVE_PORT_COUNT=2
-CONFIG_PLATFORM_EC_USB_PD_LOGGING=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y
-CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n
-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_PORT_POWER_DUMB_CUSTOM_HOOK=y
-CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n
-CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n
-CONFIG_PLATFORM_EC_USB_PD_USB4=n
-CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n
-
-# USB ID
-# This is allocated for Asurada
-# http://google3/hardware/standards/usb/
-# TODO(b/183608112): Move to device tree
-CONFIG_PLATFORM_EC_USB_PID=0x5053
-
-# VBoot without EFS2
-CONFIG_PLATFORM_EC_VBOOT_EFS2=n
-CONFIG_PLATFORM_EC_VBOOT_HASH=y
-
-# TODO(b/180980668): bring these features up
-CONFIG_LTO=n
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
diff --git a/zephyr/projects/asurada/hayato/pwm.dts b/zephyr/projects/asurada/hayato/pwm.dts
deleted file mode 100644
index fc8e0b169b..0000000000
--- a/zephyr/projects/asurada/hayato/pwm.dts
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-pwms {
- compatible = "named-pwms";
- /* NOTE: &pwm number needs same with channel number */
- led1 {
- pwms = <&pwm0 PWM_CHANNEL_0 PWM_POLARITY_INVERTED>;
- label = "LED1";
- /*
- * If we need pwm output in ITE chip power saving
- * mode, then we should set frequency <=324Hz.
- */
- frequency = <324>;
- };
- led2 {
- pwms = <&pwm1 PWM_CHANNEL_1 PWM_POLARITY_INVERTED>;
- label = "LED2";
- frequency = <324>;
- };
- led3 {
- pwms = <&pwm2 PWM_CHANNEL_2 PWM_POLARITY_INVERTED>;
- label = "LED3";
- frequency = <324>;
- };
- };
-};
-
-/* LED1 */
-&pwm0 {
- status = "okay";
- prescaler-cx = <PWM_PRESCALER_C4>;
-};
-
-/* LED2 */
-&pwm1 {
- status = "okay";
- prescaler-cx = <PWM_PRESCALER_C4>;
-};
-
-/* LED3 */
-&pwm2 {
- status = "okay";
- prescaler-cx = <PWM_PRESCALER_C4>;
-};
diff --git a/zephyr/projects/asurada/hayato/src/i2c.c b/zephyr/projects/asurada/hayato/src/i2c.c
deleted file mode 100644
index 2c7a9c7130..0000000000
--- a/zephyr/projects/asurada/hayato/src/i2c.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c/i2c.h"
-#include "i2c.h"
-
-/* Hayato board specific i2c implementation */
-
-#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
-int board_allow_i2c_passthru(int port)
-{
- return (i2c_get_device_for_port(port) ==
- i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY));
-}
-#endif
diff --git a/zephyr/projects/asurada/hayato/zmake.yaml b/zephyr/projects/asurada/hayato/zmake.yaml
deleted file mode 100644
index f4e821d582..0000000000
--- a/zephyr/projects/asurada/hayato/zmake.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: asurada
-dts-overlays:
- - battery.dts
- - gpio.dts
- - motionsense.dts
- - pwm.dts
-supported-toolchains:
- - coreboot-sdk
- - zephyr
-supported-zephyr-versions:
- - v2.6
-output-type: binman
diff --git a/zephyr/projects/brya/brya/CMakeLists.txt b/zephyr/projects/brya/brya/CMakeLists.txt
deleted file mode 100644
index 59af20ebfe..0000000000
--- a/zephyr/projects/brya/brya/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(brya)
-
-zephyr_include_directories(include)
diff --git a/zephyr/projects/brya/brya/gpio.dts b/zephyr/projects/brya/brya/gpio.dts
deleted file mode 100644
index a472d7b8f7..0000000000
--- a/zephyr/projects/brya/brya/gpio.dts
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-gpios {
- compatible = "named-gpios";
-
- lid_open: lid_open {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- label = "LID_OPEN";
- };
-
- gsc_ec_pwr_btn_odl: power_btn {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- label = "GSC_EC_PWR_BTN_ODL";
- };
-
- wp_l {
- gpios = <&gpioa 1 GPIO_INPUT>;
- enum-name = "GPIO_WP_L";
- label = "EC_WP_ODL";
- };
-
- ec_chg_led_y_c1 {
- gpios = <&gpioc 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_CHG_LED_Y_C1";
- label = "EC_CHG_LED_Y_C1";
- };
-
- ec_chg_led_b_c1 {
- gpios = <&gpioc 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_CHG_LED_B_C1";
- label = "EC_CHG_LED_B_C1";
- };
-
- packet_mode_en {
- gpios = <&gpio7 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_PACKET_MODE_EN";
- label = "EC_GSC_PACKET_MODE";
- };
- acok_od: acok_od {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- label = "ACOK_OD";
- };
- ec_kso_02_inv {
- gpios = <&gpio1 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_KBD_KSO2";
- label = "EC_KSO_02_INV";
- };
- pch_wake_odl {
- gpios = <&gpiob 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_PCH_WAKE_ODL";
- label = "EC_PCH_WAKE_R_ODL";
- };
- pch_int_odl {
- gpios = <&gpiob 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- label = "EC_PCH_INT_ODL";
- };
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-pins = <
- &acok_od
- &gsc_ec_pwr_btn_odl
- &lid_open
- >;
- };
-};
diff --git a/zephyr/projects/brya/brya/include/gpio_map.h b/zephyr/projects/brya/brya/include/gpio_map.h
deleted file mode 100644
index 2bc104c6b9..0000000000
--- a/zephyr/projects/brya/brya/include/gpio_map.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-#define GPIO_ENTERING_RW GPIO_UNIMPLEMENTED
-#define GPIO_WP_L GPIO_UNIMPLEMENTED
-
-/*
- * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items.
- *
- * Each GPIO_INT requires three parameters:
- * gpio_signal - The enum gpio_signal for the interrupt gpio
- * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH)
- * handler - The platform/ec interrupt handler.
- *
- * Ensure that this files includes all necessary headers to declare all
- * referenced handler functions.
- *
- * For example, one could use the follow definition:
- * #define EC_CROS_GPIO_INTERRUPTS \
- * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print)
- */
-#define EC_CROS_GPIO_INTERRUPTS \
- GPIO_INT(GPIO_LID_OPEN, GPIO_INT_EDGE_BOTH, lid_interrupt) \
- GPIO_INT(GPIO_POWER_BUTTON_L, GPIO_INT_EDGE_BOTH, \
- power_button_interrupt) \
- GPIO_INT(GPIO_WP_L, GPIO_INT_EDGE_BOTH, switch_interrupt) \
- GPIO_INT(GPIO_AC_PRESENT, GPIO_INT_EDGE_BOTH, extpower_interrupt)
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
diff --git a/zephyr/projects/brya/brya/prj.conf b/zephyr/projects/brya/brya/prj.conf
deleted file mode 100644
index b9dd1de26f..0000000000
--- a/zephyr/projects/brya/brya/prj.conf
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-CONFIG_PLATFORM_EC_BRINGUP=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_I2C=y
-
-# eSPI, note that PLATFORM_EC_ESPI needs to be explicitly enabled because
-# CONFIG_AP is not yet enabled.
-CONFIG_ESPI=y
-CONFIG_PLATFORM_EC_ESPI=y
-
-# Host command
-CONFIG_PLATFORM_EC_HOSTCMD=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD=y
-CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042=y
-CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
-CONFIG_PLATFORM_EC_VOLUME_BUTTONS=n
-CONFIG_PLATFORM_EC_CMD_BUTTON=n
-CONFIG_CROS_KB_RAW_NPCX=y
-
-CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API=y
-
-CONFIG_SYSCON=y
-
-# TODO(b/188605676): bring these features up
-CONFIG_PLATFORM_EC_ADC=n
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=n
-CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n
diff --git a/zephyr/projects/brya/brya/zmake.yaml b/zephyr/projects/brya/brya/zmake.yaml
deleted file mode 100644
index 71687e0f3e..0000000000
--- a/zephyr/projects/brya/brya/zmake.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: brya
-dts-overlays:
- - gpio.dts
-supported-toolchains:
- - coreboot-sdk
- - zephyr
-supported-zephyr-versions:
- - v2.6
-output-type: npcx
diff --git a/zephyr/projects/guybrush/CMakeLists.txt b/zephyr/projects/guybrush/CMakeLists.txt
deleted file mode 100644
index b565aad308..0000000000
--- a/zephyr/projects/guybrush/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(guybrush)
-
-zephyr_library_include_directories(include)
-
-set(PLATFORM_EC_BASEBOARD "${PLATFORM_EC}/baseboard/guybrush" CACHE PATH
- "Path to the platform/ec baseboard directory")
-set(PLATFORM_EC_BOARD "${PLATFORM_EC}/board/guybrush" CACHE PATH
- "Path to the platform/ec board directory")
-
-zephyr_library_sources("power_signals.c")
diff --git a/zephyr/projects/guybrush/gpio.dts b/zephyr/projects/guybrush/gpio.dts
deleted file mode 100644
index 221b5f7182..0000000000
--- a/zephyr/projects/guybrush/gpio.dts
+++ /dev/null
@@ -1,336 +0,0 @@
-/ {
- named-gpios {
- compatible = "named-gpios";
-
- ec_wp_l {
- gpios = <&gpio5 0 GPIO_INPUT>;
- label = "EC_WP_L";
- enum-name = "GPIO_WP_L";
- };
- ccd_mode_odl {
- gpios = <&gpioc 6 GPIO_ODR_HIGH>;
- label = "CCD_MODE_ODL";
- };
- ec_gsc_packet_mode {
- gpios = <&gpiob 1 GPIO_OUT_LOW>;
- label = "EC_GSC_PACKET_MODE";
- };
- mech_pwr_btn_odl {
- gpios = <&gpiod 2 GPIO_INPUT>;
- label = "MECH_PWR_BTN_ODL";
- enum-name = "GPIO_POWER_BUTTON_L";
- };
- ec_pwr_btn_odl {
- gpios = <&gpio0 1 GPIO_INPUT>;
- label = "EC_PWR_BTN_ODL";
- enum-name = "GPIO_EC_PWR_BTN_ODL";
- };
- slp_s3_l {
- gpios = <&gpio6 1 GPIO_INPUT>;
- label = "SLP_S3_L";
- enum-name = "GPIO_PCH_SLP_S3_L";
- };
- slp_s5_l {
- gpios = <&gpio7 2 GPIO_INPUT>;
- label = "SLP_S5_L";
- enum-name = "GPIO_PCH_SLP_S5_L";
- };
- slp_s3_s0i3_l {
- gpios = <&gpio7 4 GPIO_INPUT>;
- label = "SLP_S3_S0I3_L";
- enum-name = "GPIO_PCH_SLP_S0_L";
- };
- pg_pwr_s5 {
- gpios = <&gpioc 0 GPIO_INPUT>;
- label = "PG_PWR_S5";
- enum-name = "GPIO_S5_PGOOD";
- };
- pg_pcore_s0_r_od {
- gpios = <&gpiob 6 GPIO_INPUT>;
- label = "PG_PCORE_S0_R_OD";
- enum-name = "GPIO_S0_PGOOD";
- };
- acok_od {
- gpios = <&gpio0 0 GPIO_INPUT>;
- label = "ACOK_OD";
- enum-name = "GPIO_AC_PRESENT";
- };
- ec_pcore_int_odl {
- gpios = <&gpiof 0 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_PCORE_INT_ODL";
- enum-name = "GPIO_EC_PCORE_INT_ODL";
- };
- pg_groupc_s0_od {
- gpios = <&gpioa 3 GPIO_INPUT>;
- label = "PG_GROUPC_S0_OD";
- enum-name = "GPIO_PG_GROUPC_S0_OD";
- };
- pg_lpddr4x_s3_od {
- gpios = <&gpio9 5 GPIO_INPUT>;
- label = "PG_LPDDR4X_S3_OD";
- enum-name = "GPIO_PG_LPDDR4X_S3_OD";
- };
- en_pwr_s5 {
- gpios = <&gpiob 7 GPIO_OUT_LOW>;
- label = "EN_PWR_S5";
- enum-name = "GPIO_EN_PWR_A";
- };
- en_pwr_s0_r {
- gpios = <&gpiof 1 GPIO_OUT_LOW>;
- label = "EN_PWR_S0_R";
- enum-name = "GPIO_EN_PWR_S0_R";
- };
- en_pwr_pcore_s0_r {
- gpios = <&gpioe 1 GPIO_OUT_LOW>;
- label = "EN_PWR_PCORE_S0_R";
- enum-name = "GPIO_EN_PWR_PCORE_S0_R";
- };
- ec_entering_rw {
- gpios = <&gpio6 6 GPIO_OUT_LOW>;
- label = "EC_ENTERING_RW";
- enum-name = "GPIO_ENTERING_RW";
- };
- ec_sys_rst_l {
- gpios = <&gpio7 6 GPIO_ODR_HIGH>;
- label = "EC_SYS_RST_L";
- enum-name = "GPIO_SYS_RESET_L";
- };
- ec_soc_rsmrst_l {
- gpios = <&gpioc 5 GPIO_OUT_LOW>;
- label = "EC_SOC_RSMRST_L";
- enum-name = "GPIO_PCH_RSMRST_L";
- };
- ec_clr_cmos {
- gpios = <&gpioa 1 GPIO_OUT_LOW>;
- label = "EC_CLR_CMOS";
- };
- ec_mem_event {
- gpios = <&gpioa 5 GPIO_OUT_LOW>;
- label = "EC_MEM_EVENT";
- };
- ec_soc_pwr_btn_l {
- gpios = <&gpio6 3 GPIO_OUT_HIGH>;
- label = "EC_SOC_PWR_BTN_L";
- enum-name = "GPIO_PCH_PWRBTN_L";
- };
- ec_soc_pwr_good {
- gpios = <&gpiod 3 GPIO_OUT_LOW>;
- label = "EC_SOC_PWR_GOOD";
- enum-name = "GPIO_PCH_SYS_PWROK";
- };
- ec_soc_wake_l {
- gpios = <&gpio0 3 GPIO_OUT_HIGH>;
- label = "EC_SOC_WAKE_L";
- enum-name = "GPIO_EC_PCH_WAKE_ODL";
- };
- ec_soc_int_l {
- gpios = <&gpio8 3 GPIO_OUT_HIGH>;
- label = "EC_SOC_INT_L";
- };
- prochot_odl {
- gpios = <&gpiod 5 GPIO_ODR_HIGH>;
- label = "PROCHOT_ODL";
- enum-name = "GPIO_CPU_PROCHOT";
- };
- soc_alert_ec_l {
- gpios = <&gpioe 2 GPIO_INPUT>;
- label = "SOC_ALERT_EC_L";
- };
- soc_thermtrip_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- label = "SOC_THERMTRIP_ODL";
- };
- usb_c0_tcpc_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- label = "USB_C0_TCPC_INT_ODL";
- };
- usb_c1_tcpc_int_odl {
- gpios = <&gpioc 7 GPIO_INPUT>;
- label = "USB_C1_TCPC_INT_ODL";
- };
- usb_c0_ppc_int_odl {
- gpios = <&gpio7 5 GPIO_INPUT>;
- label = "USB_C0_PPC_INT_ODL";
- };
- usb_c1_ppc_int_odl {
- gpios = <&gpiod 4 GPIO_INPUT>;
- label = "USB_C1_PPC_INT_ODL";
- };
- usb_c0_bc12_int_odl {
- gpios = <&gpioa 4 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "USB_C0_BC12_INT_ODL";
- };
- usb_c1_bc12_int_odl {
- gpios = <&gpio9 6 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "USB_C1_BC12_INT_ODL";
- };
- usb_c0_c1_fault_odl {
- gpios = <&gpio7 3 GPIO_ODR_HIGH>;
- label = "USB_C0_C1_FAULT_ODL";
- };
- usb_c0_tcpc_rst_l {
- gpios = <&gpio3 4 GPIO_OUT_HIGH>;
- label = "USB_C0_TCPC_RST_L";
- };
- usb_c1_tcpc_rst_l {
- gpios = <&gpio3 7 GPIO_OUT_HIGH>;
- label = "USB_C1_TCPC_RST_L";
- };
- usb_c0_hpd {
- gpios = <&gpiof 5 GPIO_OUT_LOW>;
- label = "USB_C0_HPD";
- };
- usb_c1_hpd {
- gpios = <&gpiof 4 GPIO_OUT_LOW>;
- label = "USB_C1_HPD";
- };
- 3axis_int_l {
- gpios = <&gpioa 2 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "3AXIS_INT_L";
- };
- lid_open {
- gpios = <&gpio0 2 GPIO_INPUT>;
- label = "LID_OPEN";
- enum-name = "GPIO_LID_OPEN";
- };
- voldn_btn_odl {
- gpios = <&gpioa 7 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "VOLDN_BTN_ODL";
- enum-name = "GPIO_VOLUME_DOWN_L";
- };
- volup_btn_odl {
- gpios = <&gpio9 3 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "VOLUP_BTN_ODL";
- enum-name = "GPIO_VOLUME_UP_L";
- };
- ec_batt_pres_odl {
- gpios = <&gpio9 4 GPIO_INPUT>;
- label = "EC_BATT_PRES_ODL";
- };
- ec_disable_disp_bl {
- gpios = <&gpioa 6 GPIO_OUT_HIGH>;
- label = "EC_DISABLE_DISP_BL";
- };
- ec_i2c_usb_a0_c0_scl {
- gpios = <&gpiob 5 GPIO_INPUT>;
- label = "EC_I2C_USB_A0_C0_SCL";
- };
- ec_i2c_usb_a0_c0_sda {
- gpios = <&gpiob 4 GPIO_INPUT>;
- label = "EC_I2C_USB_A0_C0_SDA";
- };
- ec_i2c_usb_a1_c1_scl {
- gpios = <&gpio9 0 GPIO_INPUT>;
- label = "EC_I2C_USB_A1_C1_SCL";
- };
- ec_i2c_usb_a1_c1_sda {
- gpios = <&gpio8 7 GPIO_INPUT>;
- label = "EC_I2C_USB_A1_C1_SDA";
- };
- ec_i2c_batt_scl {
- gpios = <&gpio9 2 GPIO_INPUT>;
- label = "EC_I2C_BATT_SCL";
- };
- ec_i2c_batt_sda {
- gpios = <&gpio9 1 GPIO_INPUT>;
- label = "EC_I2C_BATT_SDA";
- };
- ec_i2c_usbc_mux_scl {
- gpios = <&gpiod 1 GPIO_INPUT>;
- label = "EC_I2C_USBC_MUX_SCL";
- };
- ec_i2c_usbc_mux_sda {
- gpios = <&gpiod 0 GPIO_INPUT>;
- label = "EC_I2C_USBC_MUX_SDA";
- };
- ec_i2c_power_scl {
- gpios = <&gpiof 3 GPIO_INPUT>;
- label = "EC_I2C_POWER_SCL";
- };
- ec_i2c_power_sda {
- gpios = <&gpiof 2 GPIO_INPUT>;
- label = "EC_I2C_POWER_SDA";
- };
- ec_i2c_cbi_scl {
- gpios = <&gpio3 3 GPIO_INPUT>;
- label = "EC_I2C_CBI_SCL";
- };
- ec_i2c_cbi_sda {
- gpios = <&gpio3 6 GPIO_INPUT>;
- label = "EC_I2C_CBI_SDA";
- };
- ec_i2c_sensor_scl {
- gpios = <&gpioe 4 GPIO_INPUT>;
- label = "EC_I2C_SENSOR_SCL";
- };
- ec_i2c_sensor_sda {
- gpios = <&gpioe 3 GPIO_INPUT>;
- label = "EC_I2C_SENSOR_SDA";
- };
- ec_i2c_soc_sic {
- gpios = <&gpiob 3 GPIO_INPUT>;
- label = "EC_I2C_SOC_SIC";
- };
- ec_i2c_soc_sid {
- gpios = <&gpiob 2 GPIO_INPUT>;
- label = "EC_I2C_SOC_SID";
- };
- en_kb_bl {
- gpios = <&gpio9 7 GPIO_OUT_HIGH>;
- label = "EN_KB_BL";
- };
- ec_kso_02_inv {
- gpios = <&gpio1 7 GPIO_OUT_LOW>;
- label = "EC_KSO_02_INV";
- enum-name = "GPIO_KBD_KSO2";
- };
- ec_espi_rst_l {
- gpios = <&gpio5 4 GPIO_PULL_UP>;
- label = "EC_ESPI_RST_L";
- };
- 6axis_int_l {
- gpios = <&gpioa 0 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "6AXIS_INT_L";
- };
- tablet_mode {
- gpios = <&gpioc 1 GPIO_INPUT>;
- label = "TABLET_MODE";
- };
- ec_gpio56 {
- gpios = <&gpio5 6 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_GPIO56";
- };
- ec_ps2_clk {
- gpios = <&gpio6 7 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_PS2_CLK";
- };
- ec_ps2_dat {
- gpios = <&gpio7 0 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_PS2_DAT";
- };
- ec_ps2_rst {
- gpios = <&gpio6 2 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_PS2_RST";
- };
- ec_gpiob0 {
- gpios = <&gpiob 0 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_GPIOB0";
- };
- ec_gpio81 {
- gpios = <&gpio8 1 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_GPIO81";
- };
- ec_flprg2 {
- gpios = <&gpio8 6 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_FLPRG2";
- };
- ec_psl_gpo {
- gpios = <&gpiod 7 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_PSL_GPO";
- };
- ec_pwm7 {
- gpios = <&gpio6 0 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_PWM7";
- };
- };
-};
diff --git a/zephyr/projects/guybrush/include/gpio_map.h b/zephyr/projects/guybrush/include/gpio_map.h
deleted file mode 100644
index 5af244bead..0000000000
--- a/zephyr/projects/guybrush/include/gpio_map.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-/* Power input signals */
-enum power_signal {
- X86_SLP_S0_N, /* SOC -> SLP_S3_S0I3_L */
- X86_SLP_S3_N, /* SOC -> SLP_S3_L */
- X86_SLP_S5_N, /* SOC -> SLP_S5_L */
-
- X86_S0_PGOOD, /* PMIC -> S0_PWROK_OD */
- X86_S5_PGOOD, /* PMIC -> S5_PWROK */
-
- /* Number of X86 signals */
- POWER_SIGNAL_COUNT,
-};
-
-/*
- * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items.
- *
- * Each GPIO_INT requires three parameters:
- * gpio_signal - The enum gpio_signal for the interrupt gpio
- * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH)
- * handler - The platform/ec interrupt handler.
- *
- * Ensure that this files includes all necessary headers to declare all
- * referenced handler functions.
- *
- * For example, one could use the follow definition:
- * #define EC_CROS_GPIO_INTERRUPTS \
- * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print)
- */
-#define EC_CROS_GPIO_INTERRUPTS \
- GPIO_INT(GPIO_LID_OPEN, GPIO_INT_EDGE_BOTH, lid_interrupt) \
- GPIO_INT(GPIO_AC_PRESENT, GPIO_INT_EDGE_BOTH, extpower_interrupt) \
- GPIO_INT(GPIO_POWER_BUTTON_L, GPIO_INT_EDGE_BOTH, \
- power_button_interrupt) \
- GPIO_INT(GPIO_EC_PWR_BTN_ODL, GPIO_INT_EDGE_BOTH, \
- power_button_interrupt) \
- GPIO_INT(GPIO_PCH_SLP_S3_L, GPIO_INT_EDGE_BOTH, baseboard_en_pwr_s0) \
- GPIO_INT(GPIO_PCH_SLP_S5_L, GPIO_INT_EDGE_BOTH, \
- power_signal_interrupt) \
- GPIO_INT(GPIO_PCH_SLP_S0_L, GPIO_INT_EDGE_BOTH, \
- power_signal_interrupt) \
- GPIO_INT(GPIO_S5_PGOOD, GPIO_INT_EDGE_BOTH, baseboard_en_pwr_s0) \
- GPIO_INT(GPIO_S0_PGOOD, GPIO_INT_EDGE_BOTH, power_signal_interrupt) \
- GPIO_INT(GPIO_EC_PCORE_INT_ODL, GPIO_INT_EDGE_BOTH, \
- power_signal_interrupt) \
- GPIO_INT(GPIO_PG_GROUPC_S0_OD, GPIO_INT_EDGE_BOTH, \
- baseboard_en_pwr_pcore_s0) \
- GPIO_INT(GPIO_PG_LPDDR4X_S3_OD, GPIO_INT_EDGE_BOTH, \
- baseboard_en_pwr_pcore_s0) \
- GPIO_INT(GPIO_VOLUME_UP_L, GPIO_INT_EDGE_BOTH, button_interrupt) \
- GPIO_INT(GPIO_VOLUME_DOWN_L, GPIO_INT_EDGE_BOTH, button_interrupt)
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
diff --git a/zephyr/projects/guybrush/power_signals.c b/zephyr/projects/guybrush/power_signals.c
deleted file mode 100644
index 7d5781d0cb..0000000000
--- a/zephyr/projects/guybrush/power_signals.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "chipset.h"
-#include "config.h"
-#include "gpio.h"
-#include "power.h"
-#include "timer.h"
-
-/* Wake Sources */
-const enum gpio_signal hibernate_wake_pins[] = {
- GPIO_LID_OPEN,
- GPIO_AC_PRESENT,
- GPIO_POWER_BUTTON_L,
-};
-const int hibernate_wake_pins_used = ARRAY_SIZE(hibernate_wake_pins);
-
-/* Power Signal Input List */
-const struct power_signal_info power_signal_list[] = {
- [X86_SLP_S0_N] = {
- .gpio = GPIO_PCH_SLP_S0_L,
- .flags = POWER_SIGNAL_ACTIVE_HIGH,
- .name = "SLP_S0_DEASSERTED",
- },
- [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);
-
-/**
- * b/175324615: On G3->S5, wait for RSMRST_L to be deasserted before asserting
- * PCH_PWRBTN_L.
- */
-void board_pwrbtn_to_pch(int level)
-{
- timestamp_t start;
- const uint32_t timeout_rsmrst_rise_us = 30 * MSEC;
-
- /* Add delay for G3 exit if asserting PWRBTN_L and RSMRST_L is low. */
- if (!level && !gpio_get_level(GPIO_PCH_RSMRST_L)) {
- start = get_time();
- do {
- usleep(200);
- if (gpio_get_level(GPIO_PCH_RSMRST_L))
- break;
- } while (time_since32(start) < timeout_rsmrst_rise_us);
-
- if (!gpio_get_level(GPIO_PCH_RSMRST_L))
- ccprints("Error pwrbtn: RSMRST_L still low");
-
- msleep(16);
- }
- gpio_set_level(GPIO_PCH_PWRBTN_L, level);
-}
-
-void baseboard_en_pwr_pcore_s0(enum gpio_signal signal)
-{
-
- /* EC must AND signals PG_LPDDR4X_S3_OD and PG_GROUPC_S0_OD */
- gpio_set_level(GPIO_EN_PWR_PCORE_S0_R,
- gpio_get_level(GPIO_PG_LPDDR4X_S3_OD) &&
- gpio_get_level(GPIO_PG_GROUPC_S0_OD));
-}
-
-void baseboard_en_pwr_s0(enum gpio_signal signal)
-{
-
- /* EC must AND signals SLP_S3_L and PG_PWR_S5 */
- gpio_set_level(GPIO_EN_PWR_S0_R,
- gpio_get_level(GPIO_PCH_SLP_S3_L) &&
- gpio_get_level(GPIO_S5_PGOOD));
-
- /* Now chain off to the normal power signal interrupt handler. */
- power_signal_interrupt(signal);
-}
diff --git a/zephyr/projects/guybrush/prj.conf b/zephyr/projects/guybrush/prj.conf
deleted file mode 100644
index d9f2b31d2f..0000000000
--- a/zephyr/projects/guybrush/prj.conf
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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_AUTOCOMPLETION=y
-CONFIG_KERNEL_SHELL=y
-
-CONFIG_PLATFORM_EC_VBOOT_EFS2=n
-
-# 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_PORT80=y
-
-# Power button
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-
-# External power
-CONFIG_PLATFORM_EC_HOSTCMD=y
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-CONFIG_PLATFORM_EC_BACKLIGHT_LID=n
-CONFIG_PLATFORM_EC_SWITCH=n
-
-# Lid switch
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD=y
-CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
-CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y
-
-CONFIG_SYSCON=y
-
-# This is not yet supported
-CONFIG_PLATFORM_EC_ADC=n
-CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=n
-CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n
diff --git a/zephyr/projects/guybrush/zmake.yaml b/zephyr/projects/guybrush/zmake.yaml
deleted file mode 100644
index 386ff315bf..0000000000
--- a/zephyr/projects/guybrush/zmake.yaml
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: npcx9
-dts-overlays:
- - gpio.dts
-supported-toolchains:
- - coreboot-sdk
- - zephyr
-supported-zephyr-versions:
- - v2.6
-output-type: npcx
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/CMakeLists.txt b/zephyr/projects/herobrine/herobrine_npcx9/CMakeLists.txt
deleted file mode 100644
index dfccaf12c6..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(herobrine_npcx9)
-
-zephyr_library_include_directories(include)
-
-# 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_LED_COMMON
- "src/led.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C
- "src/i2c.c")
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/battery.dts b/zephyr/projects/herobrine/herobrine_npcx9/battery.dts
deleted file mode 100644
index ab4b28999a..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/battery.dts
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- batteries {
- default_battery: ap16l5j {
- compatible = "panasonic,ap16l5j";
- };
- };
-};
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/gpio.dts b/zephyr/projects/herobrine/herobrine_npcx9/gpio.dts
deleted file mode 100644
index 1f5052af04..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/gpio.dts
+++ /dev/null
@@ -1,388 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-gpios {
- compatible = "named-gpios";
-
- usb_c0_pd_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PD_INT_ODL";
- label = "USB_C0_PD_INT_ODL";
- };
- usb_c1_pd_int_odl {
- gpios = <&gpiof 5 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_PD_INT_ODL";
- label = "USB_C1_PD_INT_ODL";
- };
- usb_c0_swctl_int_odl {
- gpios = <&gpio0 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
- label = "USB_C0_SWCTL_INT_ODL";
- };
- usb_c1_swctl_int_odl {
- gpios = <&gpio4 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
- label = "USB_C1_SWCTL_INT_ODL";
- };
- usb_c0_bc12_int_l {
- gpios = <&gpio6 1 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_USB_C0_BC12_INT_L";
- label = "USB_C0_BC12_INT_L";
- };
- usb_c1_bc12_int_l {
- gpios = <&gpio8 2 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_USB_C1_BC12_INT_L";
- label = "USB_C1_BC12_INT_L";
- };
- usb_a0_oc_odl {
- gpios = <&gpiof 4 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_USB_A0_OC_ODL";
- label = "USB_A0_OC_ODL";
- };
- gpio_chg_acok_od: chg_acok_od {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- label = "CHG_ACOK_OD";
- };
- gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- label = "EC_PWR_BTN_ODL";
- };
- ec_voldn_btn_odl {
- gpios = <&gpio6 2 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- label = "EC_VOLDN_BTN_ODL";
- };
- ec_volup_btn_odl {
- gpios = <&gpioc 2 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_VOLUME_UP_L";
- label = "EC_VOLUP_BTN_ODL";
- };
- ec_wp_odl {
- gpios = <&gpiod 3 GPIO_INPUT>;
- enum-name = "GPIO_WP_L";
- label = "EC_WP_ODL";
- };
- gpio_lid_open_ec: lid_open_ec {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- label = "LID_OPEN_EC";
- };
- ap_rst_l {
- gpios = <&gpio5 1 GPIO_INPUT>;
- enum-name = "GPIO_AP_RST_L";
- label = "AP_RST_L";
- };
- ps_hold {
- gpios = <&gpioa 6 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- enum-name = "GPIO_PS_HOLD";
- label = "PS_HOLD";
- };
- ap_suspend {
- gpios = <&gpio5 7 GPIO_INPUT>;
- enum-name = "GPIO_AP_SUSPEND";
- label = "AP_SUSPEND";
- };
- power_good {
- gpios = <&gpio3 7 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- enum-name = "GPIO_POWER_GOOD";
- label = "MB_POWER_GOOD";
- };
- warm_reset_l {
- gpios = <&gpiob 0 GPIO_INPUT>;
- enum-name = "GPIO_WARM_RESET_L";
- label = "WARM_RESET_L";
- };
- ap_ec_spi_cs_l {
- gpios = <&gpio5 3 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "AP_EC_SPI_CS_L";
- };
- tablet_mode_l {
- gpios = <&gpioc 6 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- label = "TABLET_MODE_L";
- };
- gpio_accel_gyro_int_l: accel_gyro_int_l {
- gpios = <&gpioa 3 GPIO_INPUT>;
- enum-name = "GPIO_ACCEL_GYRO_INT_L";
- label = "ACCEL_GYRO_INT_L";
- };
- gpio_rtc_ec_wake_odl: rtc_ec_wake_odl {
- #gpio-cells = <0>;
- gpios = <&gpio0 2 GPIO_INPUT>;
- enum-name = "GPIO_EC_RST_ODL";
- label = "EC_RST_ODL";
- };
- ec_entering_rw {
- gpios = <&gpio7 2 GPIO_OUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- label = "EC_ENTERING_RW";
- };
- ccd_mode_odl {
- gpios = <&gpio6 3 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- label = "CCD_MODE_ODL";
- };
- ec_batt_pres_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- label = "EC_BATT_PRES_ODL";
- };
- ec_gsc_packet_mode {
- gpios = <&gpio8 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_PACKET_MODE_EN";
- label = "EC_GSC_PACKET_MODE";
- };
- pmic_resin_l {
- gpios = <&gpioa 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_RESIN_L";
- label = "PMIC_RESIN_L";
- };
- pmic_kpd_pwr_odl {
- gpios = <&gpioa 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_KPD_PWR_ODL";
- label = "PMIC_KPD_PWR_ODL";
- };
- ap_ec_int_l {
- gpios = <&gpio5 6 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- label = "AP_EC_INT_L";
- };
- gpio_switchcap_on: switchcap_on {
- gpios = <&gpiod 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_SWITCHCAP_ON";
- label = "SWITCHCAP_ON";
- };
- en_pp5000_s5 {
- gpios = <&gpio7 3 GPIO_OUT_HIGH>;
- enum-name = "GPIO_EN_PP5000";
- label = "EN_PP5000_S5";
- };
- ec_bl_disable_l {
- gpios = <&gpiob 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- label = "EC_BL_DISABLE_L";
- };
- lid_accel_int_l {
- gpios = <&gpioa 1 GPIO_INPUT>;
- enum-name = "GPIO_LID_ACCEL_INT_L";
- label = "LID_ACCEL_INT_L";
- };
- tp_int_gate {
- gpios = <&gpio7 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_TRACKPAD_INT_GATE";
- label = "TP_INT_GATE";
- };
- usb_c0_pd_rst_l {
- gpios = <&gpiof 1 GPIO_OUT_HIGH>;
- enum-name = "GPIO_USB_C0_PD_RST_L";
- label = "USB_C0_PD_RST_L";
- };
- usb_c1_pd_rst_l {
- gpios = <&gpioe 4 GPIO_OUT_HIGH>;
- enum-name = "GPIO_USB_C1_PD_RST_L";
- label = "USB_C1_PD_RST_L";
- };
- dp_mux_oe_l {
- gpios = <&gpiob 1 GPIO_ODR_HIGH>;
- enum-name = "GPIO_DP_MUX_OE_L";
- label = "DP_MUX_OE_L";
- };
- dp_mux_sel {
- gpios = <&gpio4 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_DP_MUX_SEL";
- label = "DP_MUX_SEL";
- };
- dp_hot_plug_det_r {
- gpios = <&gpio9 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_DP_HOT_PLUG_DET";
- label = "DP_HOT_PLUG_DET_R";
- };
- en_usb_a_5v {
- gpios = <&gpiof 0 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_USB_A_5V";
- label = "EN_USB_A_5V";
- };
- usb_a_cdp_ilim_en_l {
- gpios = <&gpio7 5 GPIO_OUT_HIGH>;
- label = "USB_A_CDP_ILIM_EN_L";
- };
- ec_chg_led_y_c0 {
- gpios = <&gpio6 0 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_CHG_LED_Y_C0";
- label = "EC_CHG_LED_Y_C0";
- };
- ec_chg_led_w_c0 {
- gpios = <&gpioc 0 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_CHG_LED_W_C0";
- label = "EC_CHG_LED_W_C0";
- };
- ec_chg_led_y_c1 {
- gpios = <&gpioc 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_CHG_LED_Y_C1";
- label = "EC_CHG_LED_Y_C1";
- };
- ec_chg_led_w_c1 {
- gpios = <&gpioc 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_CHG_LED_W_C1";
- label = "EC_CHG_LED_W_C1";
- };
- ap_ec_spi_mosi {
- gpios = <&gpio4 6 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "AP_EC_SPI_MOSI";
- };
- ap_ec_spi_miso {
- gpios = <&gpio4 7 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "AP_EC_SPI_MISO";
- };
- ap_ec_spi_clk {
- gpios = <&gpio5 5 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "AP_EC_SPI_CLK";
- };
- gpio_brd_id0: brd_id0 {
- gpios = <&gpio9 4 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION1";
- label = "BRD_ID0";
- };
- gpio_brd_id1: brd_id1 {
- gpios = <&gpio9 7 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION2";
- label = "BRD_ID1";
- };
- gpio_brd_id2: brd_id2 {
- gpios = <&gpioa 5 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION3";
- label = "BRD_ID2";
- };
- gpio_sku_id0: sku_id0 {
- gpios = <&gpio6 7 GPIO_INPUT>;
- enum-name = "GPIO_SKU_ID0";
- label = "SKU_ID0";
- };
- gpio_sku_id1: sku_id1 {
- gpios = <&gpio7 0 GPIO_INPUT>;
- enum-name = "GPIO_SKU_ID1";
- label = "SKU_ID1";
- };
- gpio_sku_id2: sku_id2 {
- gpios = <&gpioe 1 GPIO_INPUT>;
- enum-name = "GPIO_SKU_ID2";
- label = "SKU_ID2";
- };
- gpio_switchcap_pg: src_vph_pwr_pg {
- gpios = <&gpioe 2 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- enum-name = "GPIO_SWITCHCAP_PG";
- label = "SRC_VPH_PWR_PG";
- };
- arm_x86 {
- gpios = <&gpio6 6 GPIO_OUT_LOW>;
- label = "ARM_X86";
- };
- ec_kso_02_inv {
- gpios = <&gpio1 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_KBD_KSO2";
- label = "EC_KSO_02_INV";
- };
- };
-
- def-lvol-io-list {
- compatible = "nuvoton,npcx-lvolctrl-def";
- lvol-io-pads = <
- &lvol_iob3 /* EC_I2C_SENSOR_SCL */
- &lvol_iob2 /* EC_I2C_SENSOR_SDA */
- >;
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-pins = <
- &gpio_chg_acok_od
- &gpio_ec_pwr_btn_odl
- &gpio_lid_open_ec
- &gpio_rtc_ec_wake_odl
- >;
- };
-
- vsby-psl-in-list {
- /* Use PSL_IN1/2/3/4 as detection pins from hibernate mode */
- psl-in-pads = <&psl_in1 &psl_in2 &psl_in3 &psl_in4>;
- };
-
- sku {
- compatible = "cros-ec,gpio-id";
-
- bits = <
- &gpio_sku_id0
- &gpio_sku_id1
- &gpio_sku_id2
- >;
-
- system = "binary_first_base3";
- };
-
- 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 2 0>,
- <&gpio5 4 0>,
- <&gpio7 6 0>,
- <&gpioc 5 0>,
- <&gpiod 1 0>,
- <&gpiod 0 0>,
- <&gpioe 3 0>,
- <&gpioc 1 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>;
- };
-};
-
-/* Power switch logic input pads */
-&psl_in1 {
- /* ACOK_OD */
- flag = <NPCX_PSL_RISING_EDGE>;
-};
-
-&psl_in2 {
- /* EC_PWR_BTN_ODL */
- flag = <NPCX_PSL_FALLING_EDGE>;
-};
-
-&psl_in3 {
- /* LID_OPEN_EC */
- flag = <NPCX_PSL_RISING_EDGE>;
-};
-
-&psl_in4 {
- /* RTC_EC_WAKE_ODL */
- flag = <NPCX_PSL_FALLING_EDGE>;
-};
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/i2c.dts b/zephyr/projects/herobrine/herobrine_npcx9/i2c.dts
deleted file mode 100644
index 0821f8b806..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/i2c.dts
+++ /dev/null
@@ -1,160 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- 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";
-
- power {
- i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_POWER";
- label = "POWER";
- };
- battery {
- i2c-port = <&i2c0_0>;
- remote-port = <0>;
- enum-name = "I2C_PORT_BATTERY";
- label = "BATTERY";
- };
- virtual {
- i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_VIRTUAL";
- label = "VIRTUAL";
- };
- charger {
- i2c-port = <&i2c0_0>;
- enum-name = "I2C_PORT_CHARGER";
- label = "CHARGER";
- };
- tcpc0 {
- i2c-port = <&i2c1_0>;
- enum-name = "I2C_PORT_TCPC0";
- label = "TCPC0";
- };
- tcpc1 {
- i2c-port = <&i2c2_0>;
- enum-name = "I2C_PORT_TCPC1";
- label = "TCPC1";
- };
- rtc {
- i2c-port = <&i2c4_1>;
- enum-name = "I2C_PORT_RTC";
- label = "RTC";
- };
- eeprom {
- i2c-port = <&i2c5_0>;
- enum-name = "I2C_PORT_EEPROM";
- label = "EEPROM";
- };
- i2c_sensor: sensor {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_SENSOR";
- label = "SENSOR";
- };
- accel {
- i2c-port = <&i2c7_0>;
- enum-name = "I2C_PORT_ACCEL";
- label = "ACCEL";
- };
- };
-
-
-};
-
-&i2c0_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-
- isl9238: isl9238@9 {
- compatible = "intersil,isl9238";
- reg = <0x09>;
- label = "ISL9238_CHARGER";
- };
-};
-
-&i2c_ctrl0 {
- status = "okay";
-};
-
-&i2c1_0 {
- status = "okay";
- /*
- * TODO(b/200280341): PS8805 SPI ROM access
- *
- * The PS8805 supports 1 MHz during normal operation, but only
- * 400 Khz during firmware updates. The I2C passthru commands don't
- * currently support changing the I2C frequency or notifying the EC
- * that a programming operation is going to start. Lower the clock
- * rate to 400 kHz for all accesses.
- */
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl1 {
- status = "okay";
-};
-
-&i2c2_0 {
- status = "okay";
- /* TODO(b/200280341): PS8805 SPI ROM access */
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl2 {
- status = "okay";
-};
-
-&i2c3_0 {
- /* Not used as no WLC connected */
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl3 {
- status = "okay";
-};
-
-&i2c4_1 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-
- pcf85063a: pcf85063a@51 {
- compatible = "nxp,rtc-pcf85063a";
- reg = <0x51>;
- label = "RTC_PCF85063A";
- int-gpios = <&gpio_rtc_ec_wake_odl>;
- };
-};
-
-&i2c_ctrl4 {
- status = "okay";
-};
-
-&i2c5_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl5 {
- status = "okay";
-};
-
-&i2c7_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_FAST>;
-};
-
-&i2c_ctrl7 {
- status = "okay";
-};
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/include/gpio_map.h b/zephyr/projects/herobrine/herobrine_npcx9/include/gpio_map.h
deleted file mode 100644
index 00ab9bd98c..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/include/gpio_map.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-#ifdef CONFIG_PLATFORM_EC_GMR_TABLET_MODE
-#define GMR_TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L
-#endif
-
-/*
- * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items.
- *
- * Each GPIO_INT requires three parameters:
- * gpio_signal - The enum gpio_signal for the interrupt gpio
- * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH)
- * handler - The platform/ec interrupt handler.
- *
- * Ensure that this files includes all necessary headers to declare all
- * referenced handler functions.
- *
- * For example, one could use the follow definition:
- * #define EC_CROS_GPIO_INTERRUPTS \
- * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print)
- */
-#define EC_CROS_GPIO_INTERRUPTS \
- GPIO_INT(GPIO_AC_PRESENT, GPIO_INT_EDGE_BOTH, extpower_interrupt) \
- GPIO_INT(GPIO_LID_OPEN, GPIO_INT_EDGE_BOTH, lid_interrupt) \
- GPIO_INT(GPIO_WP_L, GPIO_INT_EDGE_BOTH, switch_interrupt) \
- GPIO_INT(GPIO_POWER_BUTTON_L, GPIO_INT_EDGE_BOTH, \
- power_button_interrupt) \
- GPIO_INT(GPIO_VOLUME_DOWN_L, GPIO_INT_EDGE_BOTH, button_interrupt) \
- GPIO_INT(GPIO_VOLUME_UP_L, GPIO_INT_EDGE_BOTH, button_interrupt) \
- GPIO_INT(GPIO_AP_RST_L, GPIO_INT_EDGE_BOTH, chipset_ap_rst_interrupt) \
- GPIO_INT(GPIO_AP_SUSPEND, GPIO_INT_EDGE_BOTH, power_signal_interrupt) \
- GPIO_INT(GPIO_POWER_GOOD, GPIO_INT_EDGE_BOTH, power_signal_interrupt) \
- GPIO_INT(GPIO_PS_HOLD, GPIO_INT_EDGE_BOTH, power_signal_interrupt) \
- GPIO_INT(GPIO_WARM_RESET_L, GPIO_INT_EDGE_BOTH, \
- power_signal_interrupt) \
- GPIO_INT(GPIO_USB_C0_PD_INT_ODL, GPIO_INT_EDGE_FALLING, \
- tcpc_alert_event) \
- GPIO_INT(GPIO_USB_C1_PD_INT_ODL, GPIO_INT_EDGE_FALLING, \
- tcpc_alert_event) \
- GPIO_INT(GPIO_USB_C0_SWCTL_INT_ODL, GPIO_INT_EDGE_FALLING, \
- ppc_interrupt) \
- GPIO_INT(GPIO_USB_C1_SWCTL_INT_ODL, GPIO_INT_EDGE_FALLING, \
- ppc_interrupt) \
- GPIO_INT(GPIO_USB_C0_BC12_INT_L, GPIO_INT_EDGE_FALLING, usb0_evt) \
- GPIO_INT(GPIO_USB_C1_BC12_INT_L, GPIO_INT_EDGE_FALLING, usb1_evt) \
- GPIO_INT(GPIO_USB_A0_OC_ODL, GPIO_INT_EDGE_BOTH, usba_oc_interrupt) \
- GPIO_INT(GPIO_ACCEL_GYRO_INT_L, GPIO_INT_EDGE_FALLING, \
- bmi260_interrupt) \
- GPIO_INT(GPIO_TABLET_MODE_L, GPIO_INT_EDGE_BOTH, gmr_tablet_switch_isr)
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/include/pwm_map.h b/zephyr/projects/herobrine/herobrine_npcx9/include/pwm_map.h
deleted file mode 100644
index e704b6d6d3..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/include/pwm_map.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_PWM_MAP_H
-#define __ZEPHYR_PWM_MAP_H
-
-#include <devicetree.h>
-
-#include "pwm/pwm.h"
-
-#define PWM_CH_KBLIGHT NAMED_PWM(kblight)
-#define PWM_CH_DISPLIGHT NAMED_PWM(displight)
-
-#endif /* __ZEPHYR_PWM_MAP_H */
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/motionsense.dts b/zephyr/projects/herobrine/herobrine_npcx9/motionsense.dts
deleted file mode 100644
index 977c27bfc3..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/motionsense.dts
+++ /dev/null
@@ -1,157 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#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.
- */
- bmi260-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 {
- label = "LID_MUTEX";
- };
-
- mutex_bmi260: bmi260-mutex {
- label = "BMI260_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 {
- bma255_data: bma255-drv-data {
- compatible = "cros-ec,drvdata-bma255";
- status = "okay";
- };
-
- bmi260_data: bmi260-drv-data {
- compatible = "cros-ec,drvdata-bmi260";
- status = "okay";
- };
- };
-
- /*
- * List of motion sensors that creates motion_sensors array.
- * The label "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,bma255";
- status = "okay";
-
- label = "Lid Accel";
- 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 = <&bma255_data>;
- i2c-spi-addr-flags = "BMA2x2_I2C_ADDR1_FLAGS";
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_accel: base-accel {
- compatible = "cros-ec,bmi260-accel";
- status = "okay";
-
- label = "Base Accel";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi260>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&bmi260_data>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base-gyro {
- compatible = "cros-ec,bmi260-gyro";
- status = "okay";
-
- label = "Base Gyro";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi260>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&bmi260_data>;
- };
- };
-
- motionsense-sensor-info {
- compatible = "cros-ec,motionsense-sensor-info";
-
- /*
- * list of GPIO interrupts that have to
- * be enabled at initial stage
- */
- sensor-irqs = <&gpio_accel_gyro_int_l>;
- /* list of sensors in force mode */
- accel-force-mode-sensors = <&lid_accel>;
- };
-};
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/prj.conf b/zephyr/projects/herobrine/herobrine_npcx9/prj.conf
deleted file mode 100644
index 8c8576c78f..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/prj.conf
+++ /dev/null
@@ -1,168 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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_I2C=y
-CONFIG_KERNEL_SHELL=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
-
-# Miscellaneous configs
-CONFIG_PLATFORM_EC_HIBERNATE_PSL=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_COMMON=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-CONFIG_PLATFORM_EC_PWM=y
-CONFIG_PLATFORM_EC_PWM_DISPLIGHT=y
-CONFIG_PLATFORM_EC_PWM_KBLIGHT=y
-
-# 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
-
-# TODO(b:193719620): Enable EC EFS2.
-CONFIG_PLATFORM_EC_VBOOT_EFS2=n
-
-# MKBP event mask
-CONFIG_PLATFORM_EC_MKBP_EVENT_WAKEUP_MASK=y
-CONFIG_PLATFORM_EC_MKBP_HOST_EVENT_WAKEUP_MASK=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_PLATFORM_EC_ADC=y
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
-# Battery
-CONFIG_HAS_TASK_USB_CHG_P1=y
-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_USB_A_PORT_COUNT=1
-
-# 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_PORT_MAX_COUNT=2
-CONFIG_PLATFORM_EC_USB_PD_REV30=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_PD_LOGGING=y
-CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB=y
-CONFIG_HAS_TASK_PD_C1=y
-CONFIG_HAS_TASK_PD_INT_C1=y
-
-# 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
-
-# Serial Host Interface (SHI) device.
-CONFIG_CROS_SHI_NPCX=y
-
-# Sensors
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_ACCEL_INTERRUPTS=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_BMI260=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=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/herobrine/herobrine_npcx9/src/i2c.c b/zephyr/projects/herobrine/herobrine_npcx9/src/i2c.c
deleted file mode 100644
index f78ea56513..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/src/i2c.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#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(int port)
-{
- return (i2c_get_device_for_port(port) ==
- i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY));
-}
-#endif
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/src/led.c b/zephyr/projects/herobrine/herobrine_npcx9/src/led.c
deleted file mode 100644
index 295c8effeb..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/src/led.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Power and battery LED control.
- */
-
-#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 "system.h"
-#include "util.h"
-
-#define BAT_LED_ON 1
-#define BAT_LED_OFF 0
-
-const enum ec_led_id supported_led_ids[] = {
- EC_LED_ID_RIGHT_LED,
- EC_LED_ID_LEFT_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 */
-};
-
-static void side_led_set_color(int port, enum led_color color)
-{
- gpio_set_level(port ? GPIO_EC_CHG_LED_Y_C1 : GPIO_EC_CHG_LED_Y_C0,
- (color == LED_AMBER) ? BAT_LED_ON : BAT_LED_OFF);
- gpio_set_level(port ? GPIO_EC_CHG_LED_W_C1 : GPIO_EC_CHG_LED_W_C0,
- (color == LED_WHITE) ? BAT_LED_ON : BAT_LED_OFF);
-}
-
-void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
-{
- brightness_range[EC_LED_COLOR_AMBER] = 1;
- brightness_range[EC_LED_COLOR_WHITE] = 1;
-}
-
-int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
-{
- int port;
-
- switch (led_id) {
- case EC_LED_ID_RIGHT_LED:
- port = 0;
- break;
- case EC_LED_ID_LEFT_LED:
- port = 1;
- break;
- default:
- return EC_ERROR_PARAM1;
- }
-
- if (brightness[EC_LED_COLOR_WHITE] != 0)
- side_led_set_color(port, LED_WHITE);
- else if (brightness[EC_LED_COLOR_AMBER] != 0)
- side_led_set_color(port, LED_AMBER);
- else
- side_led_set_color(port, LED_OFF);
-
- 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))
- side_led_set_color(0, (port == 0) ? color : LED_OFF);
- if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED))
- side_led_set_color(1, (port == 1) ? color : LED_OFF);
-}
-
-static void board_led_set_battery(void)
-{
- static int battery_ticks;
- uint32_t chflags = charge_get_flags();
-
- battery_ticks++;
-
- 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:
- if (led_auto_control_is_enabled(EC_LED_ID_RIGHT_LED)) {
- if (charge_get_percent() <= 10)
- side_led_set_color(0,
- (battery_ticks & 0x4) ? LED_WHITE : LED_OFF);
- else
- side_led_set_color(0, LED_OFF);
- }
-
- if (led_auto_control_is_enabled(EC_LED_ID_LEFT_LED))
- side_led_set_color(1, LED_OFF);
- break;
- case PWR_STATE_ERROR:
- set_active_port_color((battery_ticks & 0x2) ?
- LED_WHITE : 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 */
- if (chflags & CHARGE_FLAG_FORCE_IDLE)
- set_active_port_color((battery_ticks & 0x4) ?
- LED_AMBER : LED_OFF);
- else
- set_active_port_color(LED_WHITE);
- break;
- default:
- /* Other states don't alter LED behavior */
- break;
- }
-}
-
-/* Called by hook task every TICK */
-static void led_tick(void)
-{
- board_led_set_battery();
-}
-DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT);
-
-void led_control(enum ec_led_id led_id, enum ec_led_state state)
-{
- enum led_color color;
-
- if ((led_id != EC_LED_ID_RECOVERY_HW_REINIT_LED) &&
- (led_id != EC_LED_ID_SYSRQ_DEBUG_LED))
- return;
-
- if (state == LED_STATE_RESET) {
- led_auto_control(EC_LED_ID_LEFT_LED, 1);
- led_auto_control(EC_LED_ID_RIGHT_LED, 1);
- board_led_set_battery();
- return;
- }
-
- color = state ? LED_WHITE : LED_OFF;
-
- led_auto_control(EC_LED_ID_LEFT_LED, 0);
- led_auto_control(EC_LED_ID_RIGHT_LED, 0);
-
- side_led_set_color(0, color);
- side_led_set_color(1, color);
-}
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/src/usb_pd_policy.c b/zephyr/projects/herobrine/herobrine_npcx9/src/usb_pd_policy.c
deleted file mode 100644
index 7ca2688aef..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/src/usb_pd_policy.c
+++ /dev/null
@@ -1,262 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "charge_manager.h"
-#include "chipset.h"
-#include "console.h"
-#include "gpio.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_get_level(GPIO_EN_PP5000);
-}
-
-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)
-{
- enum gpio_signal hpd = 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_get_level(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_set_level(GPIO_DP_MUX_SEL, port == 1);
- gpio_set_level(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_set_level(GPIO_DP_MUX_OE_L, 1);
- gpio_set_level(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_set_level(hpd, 0);
- usleep(HPD_DSTREAM_DEBOUNCE_IRQ);
- gpio_set_level(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;
- } else {
- gpio_set_level(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_set_level(GPIO_DP_MUX_OE_L, 1);
- gpio_set_level(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_set_level(GPIO_DP_HOT_PLUG_DET, 0);
- }
-}
-#endif /* CONFIG_USB_PD_ALT_MODE_DFP */
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/src/usbc_config.c b/zephyr/projects/herobrine/herobrine_npcx9/src/usbc_config.c
deleted file mode 100644
index 20646c28c2..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/src/usbc_config.c
+++ /dev/null
@@ -1,365 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Herobrine board-specific USB-C configuration */
-
-#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 "gpio.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)
-
-
-/* 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);
-}
-
-void usb0_evt(enum gpio_signal signal)
-{
- task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_BC12);
-}
-
-void usb1_evt(enum gpio_signal signal)
-{
- task_set_event(TASK_ID_USB_CHG_P1, USB_CHG_EVENT_BC12);
-}
-
-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_get_level(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:
- sn5s330_interrupt(0);
- break;
- case GPIO_USB_C1_SWCTL_INT_ODL:
- sn5s330_interrupt(1);
- break;
- default:
- break;
- }
-}
-
-const struct charger_config_t chg_chips[] = {
- {
- .i2c_port = I2C_PORT_CHARGER,
- .i2c_addr_flags = ISL923X_ADDR_FLAGS,
- .drv = &isl923x_drv,
- },
-};
-
-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;
-}/* Power Path Controller */
-struct ppc_config_t ppc_chips[] = {
- {
- .i2c_port = I2C_PORT_TCPC0,
- .i2c_addr_flags = SN5S330_ADDR0_FLAGS,
- .drv = &sn5s330_drv
- },
- {
- .i2c_port = I2C_PORT_TCPC1,
- .i2c_addr_flags = SN5S330_ADDR0_FLAGS,
- .drv = &sn5s330_drv
- },
-};
-unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
-
-/* TCPC mux configuration */
-const struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_TCPC0,
- .addr_flags = PS8751_I2C_ADDR1_FLAGS,
- },
- .drv = &ps8xxx_tcpm_drv,
- },
- {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_TCPC1,
- .addr_flags = PS8751_I2C_ADDR1_FLAGS,
- },
- .drv = &ps8xxx_tcpm_drv,
- },
-};
-
-/*
- * 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 usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = {
- {
- .usb_port = 0,
- .driver = &tcpci_tcpm_usb_mux_driver,
- .hpd_update = &ps8xxx_tcpc_update_hpd_status,
- },
- {
- .usb_port = 1,
- .driver = &tcpci_tcpm_usb_mux_driver,
- .hpd_update = &ps8xxx_tcpc_update_hpd_status,
- }
-};
-
-const int usb_port_enable[USB_PORT_COUNT] = {
- GPIO_EN_USB_A_5V,
-};
-
-/* BC1.2 */
-const struct pi3usb9201_config_t pi3usb9201_bc12_chips[] = {
- {
- .i2c_port = I2C_PORT_POWER,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
- },
- {
- .i2c_port = I2C_PORT_EEPROM,
- .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS,
- },
-};
-
-/* Initialize board USC-C things */
-static void board_init_usbc(void)
-{
- /* Enable BC1.2 interrupts */
- gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_L);
- gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_L);
-
- /* Enable USB-A overcurrent interrupt */
- gpio_enable_interrupt(GPIO_USB_A0_OC_ODL);
-}
-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_interrupt(GPIO_USB_C0_SWCTL_INT_ODL);
-
- /* Enable TCPC interrupts */
- gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL);
- gpio_enable_interrupt(GPIO_USB_C1_PD_INT_ODL);
-
- /*
- * 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_INIT_I2C + 1);
-
-void board_reset_pd_mcu(void)
-{
- cprints(CC_USB, "Resetting TCPCs...");
- cflush();
-
- gpio_set_level(GPIO_USB_C0_PD_RST_L, 0);
- gpio_set_level(GPIO_USB_C1_PD_RST_L, 0);
- msleep(PS8XXX_RESET_DELAY_MS);
- gpio_set_level(GPIO_USB_C0_PD_RST_L, 1);
- gpio_set_level(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_get_level(GPIO_USB_C0_PD_INT_ODL))
- if (gpio_get_level(GPIO_USB_C0_PD_RST_L))
- status |= PD_STATUS_TCPC_ALERT_0;
- if (!gpio_get_level(GPIO_USB_C1_PD_INT_ODL))
- if (gpio_get_level(GPIO_USB_C1_PD_RST_L))
- status |= PD_STATUS_TCPC_ALERT_1;
-
- return status;
-}
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/switchcap.dts b/zephyr/projects/herobrine/herobrine_npcx9/switchcap.dts
deleted file mode 100644
index b246274a7a..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/switchcap.dts
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- switchcap {
- compatible = "switchcap-gpio";
- enable-pin = <&gpio_switchcap_on>;
- power-good-pin = <&gpio_switchcap_pg>;
- };
-};
diff --git a/zephyr/projects/herobrine/herobrine_npcx9/zmake.yaml b/zephyr/projects/herobrine/herobrine_npcx9/zmake.yaml
deleted file mode 100644
index 775ab65ead..0000000000
--- a/zephyr/projects/herobrine/herobrine_npcx9/zmake.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: herobrine_npcx9
-dts-overlays:
- - gpio.dts
- - battery.dts
- - i2c.dts
- - motionsense.dts
- - switchcap.dts
-supported-toolchains:
- - coreboot-sdk
- - zephyr
-supported-zephyr-versions:
- - v2.6
-output-type: npcx
diff --git a/zephyr/projects/it8xxx2_evb/CMakeLists.txt b/zephyr/projects/it8xxx2_evb/CMakeLists.txt
deleted file mode 100644
index dc2eb449b0..0000000000
--- a/zephyr/projects/it8xxx2_evb/CMakeLists.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(it8xxx2_evb)
-
-# Include board specific header files
-zephyr_include_directories(include)
diff --git a/zephyr/projects/it8xxx2_evb/include/gpio_map.h b/zephyr/projects/it8xxx2_evb/include/gpio_map.h
deleted file mode 100644
index c92b71d523..0000000000
--- a/zephyr/projects/it8xxx2_evb/include/gpio_map.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-#define GPIO_ENTERING_RW GPIO_UNIMPLEMENTED
-#define GPIO_WP_L GPIO_UNIMPLEMENTED
-
-/*
- * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items.
- *
- * Each GPIO_INT requires three parameters:
- * gpio_signal - The enum gpio_signal for the interrupt gpio
- * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH)
- * handler - The platform/ec interrupt handler.
- *
- * Ensure that this files includes all necessary headers to declare all
- * referenced handler functions.
- *
- * For example, one could use the follow definition:
- * #define EC_CROS_GPIO_INTERRUPTS \
- * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print)
- */
-#define EC_CROS_GPIO_INTERRUPTS \
- GPIO_INT(GPIO_LID_OPEN, GPIO_INT_EDGE_BOTH, lid_interrupt) \
- GPIO_INT(GPIO_POWER_BUTTON_L, \
- GPIO_INT_EDGE_BOTH, power_button_interrupt) \
- GPIO_INT(GPIO_SPI0_CS, \
- GPIO_INT_EDGE_FALLING, spi_event)
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
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 9d1fc1ca36..0000000000
--- a/zephyr/projects/it8xxx2_evb/include/i2c_map.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_CHROME_I2C_MAP_H
-#define __ZEPHYR_CHROME_I2C_MAP_H
-
-#include <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/include/pwm_map.h b/zephyr/projects/it8xxx2_evb/include/pwm_map.h
deleted file mode 100644
index 531b86ccf6..0000000000
--- a/zephyr/projects/it8xxx2_evb/include/pwm_map.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_CHROME_PWM_MAP_H
-#define __ZEPHYR_CHROME_PWM_MAP_H
-
-#include <devicetree.h>
-
-#include "config.h"
-
-#include "pwm/pwm.h"
-
-/*
- * TODO(b/177452529): eliminate the dependency on enum pwm_channel
- * and configure this information directly from the device tree.
- */
-#define PWM_CH_FAN NAMED_PWM(test0)
-#define PWM_CH_WITH_DSLEEP_FLAG NAMED_PWM(test1)
-
-#endif /* __ZEPHYR_CHROME_PWM_MAP_H */
diff --git a/zephyr/projects/it8xxx2_evb/prj.conf b/zephyr/projects/it8xxx2_evb/prj.conf
deleted file mode 100644
index 23a7ab2275..0000000000
--- a/zephyr/projects/it8xxx2_evb/prj.conf
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-CONFIG_SHIMMED_TASKS=y
-
-# SoC configuration
-CONFIG_AP=y
-CONFIG_AP_ARM_MTK_MT8192=y
-
-# ADC
-CONFIG_PLATFORM_EC_ADC=y
-
-# I2C
-CONFIG_PLATFORM_EC_I2C=y
-
-# Flash
-CONFIG_PLATFORM_EC_FLASH_CROS=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=y
-
-# Lid switch
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-
-# Power button
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-
-# Logging
-CONFIG_LOG=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
diff --git a/zephyr/projects/it8xxx2_evb/zmake.yaml b/zephyr/projects/it8xxx2_evb/zmake.yaml
deleted file mode 100644
index d05a938500..0000000000
--- a/zephyr/projects/it8xxx2_evb/zmake.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: it8xxx2_evb
-supported-toolchains:
- - coreboot-sdk
- - zephyr
-supported-zephyr-versions:
- - v2.6
-output-type: raw
diff --git a/zephyr/projects/kohaku/CMakeLists.txt b/zephyr/projects/kohaku/CMakeLists.txt
deleted file mode 100644
index 5a8c045731..0000000000
--- a/zephyr/projects/kohaku/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(kohaku)
-
-zephyr_library_include_directories(include)
diff --git a/zephyr/projects/kohaku/include/gpio_map.h b/zephyr/projects/kohaku/include/gpio_map.h
deleted file mode 100644
index 05fc93d5d5..0000000000
--- a/zephyr/projects/kohaku/include/gpio_map.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-/* Cometlake power sequencing requires this definition */
-#define PP5000_PGOOD_POWER_SIGNAL_MASK POWER_SIGNAL_MASK(X86_PP5000_A_PGOOD)
-
-/*
- * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items.
- *
- * Each GPIO_INT requires three parameters:
- * gpio_signal - The enum gpio_signal for the interrupt gpio
- * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH)
- * handler - The platform/ec interrupt handler.
- *
- * Ensure that this files includes all necessary headers to declare all
- * referenced handler functions.
- *
- * For example, one could use the follow definition:
- * #define EC_CROS_GPIO_INTERRUPTS \
- * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print)
- */
-#define EC_CROS_GPIO_INTERRUPTS \
- GPIO_INT(NAMED_GPIO(lid_open), GPIO_INT_EDGE_BOTH, lid_interrupt) \
- GPIO_INT(NAMED_GPIO(power_button_l), GPIO_INT_EDGE_BOTH, \
- power_button_interrupt) \
- GPIO_INT(NAMED_GPIO(acok_od), GPIO_INT_EDGE_BOTH, extpower_interrupt) \
- GPIO_INT(NAMED_GPIO(slp_s0_l), GPIO_INT_EDGE_BOTH, \
- power_signal_interrupt) \
- GPIO_INT(NAMED_GPIO(slp_s3_l), GPIO_INT_EDGE_BOTH, \
- power_signal_interrupt) \
- GPIO_INT(NAMED_GPIO(slp_s4_l), GPIO_INT_EDGE_BOTH, \
- power_signal_interrupt) \
- GPIO_INT(NAMED_GPIO(pg_ec_rsmrst_l), GPIO_INT_EDGE_BOTH, \
- intel_x86_rsmrst_signal_interrupt) \
- GPIO_INT(NAMED_GPIO(pg_ec_all_sys_pwrgd), GPIO_INT_EDGE_BOTH, \
- power_signal_interrupt) \
- GPIO_INT(NAMED_GPIO(pp5000_a_pg_od), GPIO_INT_EDGE_BOTH, \
- power_signal_interrupt)
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
diff --git a/zephyr/projects/kohaku/prj.conf b/zephyr/projects/kohaku/prj.conf
deleted file mode 100644
index 48d512fc39..0000000000
--- a/zephyr/projects/kohaku/prj.conf
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-CONFIG_SHIMMED_TASKS=y
-
-CONFIG_ESPI=y
-CONFIG_I2C=y
-
-CONFIG_PLATFORM_EC_VBOOT_EFS2=n
-
-# Power sequencing
-CONFIG_AP=y
-CONFIG_AP_X86_INTEL_CML=y
-CONFIG_PLATFORM_EC_POWERSEQ=y
-CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y
-
-# Power button
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-CONFIG_HAS_TASK_POWERBTN=y
-
-# External power
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-
-# Lid switch
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-
-CONFIG_PLATFORM_EC_KEYBOARD=n
-CONFIG_CROS_KB_RAW_NPCX=n
-
-# This is not yet supported
-CONFIG_PLATFORM_EC_ADC=n
-CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=n
-CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n
-
-CONFIG_SYSCON=y
diff --git a/zephyr/projects/kohaku/zmake.yaml b/zephyr/projects/kohaku/zmake.yaml
deleted file mode 100644
index 99e4f135fb..0000000000
--- a/zephyr/projects/kohaku/zmake.yaml
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: kohaku
-supported-toolchains:
- - coreboot-sdk
- - zephyr
-supported-zephyr-versions:
- - v2.6
-output-type: npcx
diff --git a/zephyr/projects/npcx_evb/npcx7/CMakeLists.txt b/zephyr/projects/npcx_evb/npcx7/CMakeLists.txt
deleted file mode 100644
index a61ddf6755..0000000000
--- a/zephyr/projects/npcx_evb/npcx7/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(npcx7)
-
-zephyr_include_directories(include)
diff --git a/zephyr/projects/npcx_evb/npcx7/fan.dts b/zephyr/projects/npcx_evb/npcx7/fan.dts
deleted file mode 100644
index de2852d73a..0000000000
--- a/zephyr/projects/npcx_evb/npcx7/fan.dts
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-fans {
- compatible = "named-fans";
-
- fan_0 {
- label = "FAN_0";
- pwm = <&pwm_fan>;
- rpm_min = <1000>;
- rpm_start = <1000>;
- rpm_max = <5200>;
- tach = <&tach1>;
- pgood_gpio = <&gpio_pgood_fan>;
- };
- };
-};
-
-/* Tachometer for fan speed measurement */
-&tach1 {
- status = "okay";
- pinctrl-0 = <&alt3_ta1_sl1>; /* Use TA1 as input pin */
- port = <NPCX_TACH_PORT_A>; /* port-A is selected */
- sample-clk = <NPCX_TACH_FREQ_LFCLK>; /* Use LFCLK as sampling clock */
- pulses-per-round = <2>; /* number of pulses per round of encoder */
-};
diff --git a/zephyr/projects/npcx_evb/npcx7/gpio.dts b/zephyr/projects/npcx_evb/npcx7/gpio.dts
deleted file mode 100644
index fb8f83803f..0000000000
--- a/zephyr/projects/npcx_evb/npcx7/gpio.dts
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-gpios {
- compatible = "named-gpios";
-
- recovery_l {
- gpios = <&gpio0 3 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "RECOVERY_L";
- };
- wp_l {
- gpios = <&gpio9 3 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_WP_L";
- label = "WP_L";
- };
- gpio_ac_present: ac_present {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- label = "AC_PRESENT";
- };
- gpio_power_button_l: power_button_l {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- label = "POWER_BUTTON_L";
- };
- gpio_lid_open: lid_open {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- label = "LID_OPEN";
- };
- entering_rw {
- gpios = <&gpio3 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- label = "ENTERING_RW";
- };
- pch_wake_l {
- gpios = <&gpio5 0 GPIO_OUT_HIGH>;
- enum-name = "GPIO_EC_PCH_WAKE_ODL";
- label = "PCH_WAKE_L";
- };
- gpio_pgood_fan: pgood_fan {
- gpios = <&gpioc 7 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_PGOOD_FAN";
- label = "PGOOD_FAN";
- };
- spi_cs_l {
- gpios = <&gpioa 5 GPIO_OUT_HIGH>;
- label = "SPI_CS_L";
- };
- board_version1 {
- gpios = <&gpio6 4 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION1";
- label = "BOARD_VERSION1";
- };
- board_version2 {
- gpios = <&gpio6 5 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION2";
- label = "BOARD_VERSION2";
- };
- board_version3 {
- gpios = <&gpio6 6 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION3";
- label = "BOARD_VERSION3";
- };
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-pins = <
- &gpio_ac_present
- &gpio_power_button_l
- &gpio_lid_open
- >;
- };
-};
diff --git a/zephyr/projects/npcx_evb/npcx7/include/gpio_map.h b/zephyr/projects/npcx_evb/npcx7/include/gpio_map.h
deleted file mode 100644
index 741cbd89a2..0000000000
--- a/zephyr/projects/npcx_evb/npcx7/include/gpio_map.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-#define GPIO_KBD_KSO2 GPIO_UNIMPLEMENTED
-
-/*
- * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items.
- *
- * Each GPIO_INT requires three parameters:
- * gpio_signal - The enum gpio_signal for the interrupt gpio
- * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH)
- * handler - The platform/ec interrupt handler.
- *
- * Ensure that this files includes all necessary headers to declare all
- * referenced handler functions.
- *
- * For example, one could use the follow definition:
- * #define EC_CROS_GPIO_INTERRUPTS \
- * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print)
- */
-#define EC_CROS_GPIO_INTERRUPTS \
- GPIO_INT(GPIO_AC_PRESENT, GPIO_INT_EDGE_BOTH, extpower_interrupt) \
- GPIO_INT(GPIO_LID_OPEN, GPIO_INT_EDGE_BOTH, lid_interrupt) \
- GPIO_INT(GPIO_POWER_BUTTON_L, GPIO_INT_EDGE_BOTH, \
- power_button_interrupt)
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
diff --git a/zephyr/projects/npcx_evb/npcx7/include/pwm_map.h b/zephyr/projects/npcx_evb/npcx7/include/pwm_map.h
deleted file mode 100644
index 371e95c116..0000000000
--- a/zephyr/projects/npcx_evb/npcx7/include/pwm_map.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_PWM_MAP_H
-#define __ZEPHYR_PWM_MAP_H
-
-#include <devicetree.h>
-
-#include "pwm/pwm.h"
-
-#define PWM_CH_FAN NAMED_PWM(fan)
-#define PWM_CH_KBLIGHT NAMED_PWM(kblight)
-
-#endif /* __ZEPHYR_PWM_MAP_H */
diff --git a/zephyr/projects/npcx_evb/npcx7/keyboard.dts b/zephyr/projects/npcx_evb/npcx7/keyboard.dts
deleted file mode 100644
index fdeee3c02c..0000000000
--- a/zephyr/projects/npcx_evb/npcx7/keyboard.dts
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- 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 */
- >;
- };
-};
diff --git a/zephyr/projects/npcx_evb/npcx7/prj.conf b/zephyr/projects/npcx_evb/npcx7/prj.conf
deleted file mode 100644
index d05c6174cf..0000000000
--- a/zephyr/projects/npcx_evb/npcx7/prj.conf
+++ /dev/null
@@ -1,55 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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_PLATFORM_EC_PWM=y
-
-# Fan
-CONFIG_SENSOR=y
-CONFIG_SENSOR_SHELL=n
-CONFIG_PLATFORM_EC_FAN=y
-
-# Console command
-CONFIG_PLATFORM_EC_CONSOLE_CMD_SCRATCHPAD=y
-
-# eSPI
-CONFIG_ESPI=y
-CONFIG_PLATFORM_EC_ESPI_VW_SLP_S3=y
-CONFIG_PLATFORM_EC_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
-
-# Zephyr feature
-CONFIG_ASSERT=y
-CONFIG_SHELL_MINIMAL=n
-CONFIG_LOG=y
-
-# Avoid underflow info from tachometer
-CONFIG_SENSOR_LOG_LEVEL_ERR=y
-
-# Avoid info storm from power management
-CONFIG_SOC_LOG_LEVEL_ERR=y
-
-CONFIG_SYSCON=y
diff --git a/zephyr/projects/npcx_evb/npcx7/pwm.dts b/zephyr/projects/npcx_evb/npcx7/pwm.dts
deleted file mode 100644
index 144b4d96b9..0000000000
--- a/zephyr/projects/npcx_evb/npcx7/pwm.dts
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-pwms {
- compatible = "named-pwms";
-
- pwm_fan: fan {
- pwms = <&pwm0 0 0>;
- label = "FAN";
- frequency = <25000>;
- };
- kblight {
- pwms = <&pwm2 0 0>;
- label = "KBLIGHT";
- frequency = <10000>;
- };
- };
-};
-
-/* fan */
-&pwm0 {
- status = "okay";
- drive-open-drain;
-};
-
-/* kblight */
-&pwm2 {
- status = "okay";
-};
diff --git a/zephyr/projects/npcx_evb/npcx7/zmake.yaml b/zephyr/projects/npcx_evb/npcx7/zmake.yaml
deleted file mode 100644
index e846e582e7..0000000000
--- a/zephyr/projects/npcx_evb/npcx7/zmake.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: npcx7_evb
-dts-overlays:
- - gpio.dts
- - pwm.dts
- - fan.dts
- - keyboard.dts
-supported-toolchains:
- - coreboot-sdk
- - zephyr
-supported-zephyr-versions:
- - v2.6
-output-type: npcx
diff --git a/zephyr/projects/npcx_evb/npcx9/CMakeLists.txt b/zephyr/projects/npcx_evb/npcx9/CMakeLists.txt
deleted file mode 100644
index a81ae87820..0000000000
--- a/zephyr/projects/npcx_evb/npcx9/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(npcx9)
-
-zephyr_include_directories(include)
diff --git a/zephyr/projects/npcx_evb/npcx9/fan.dts b/zephyr/projects/npcx_evb/npcx9/fan.dts
deleted file mode 100644
index de2852d73a..0000000000
--- a/zephyr/projects/npcx_evb/npcx9/fan.dts
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-fans {
- compatible = "named-fans";
-
- fan_0 {
- label = "FAN_0";
- pwm = <&pwm_fan>;
- rpm_min = <1000>;
- rpm_start = <1000>;
- rpm_max = <5200>;
- tach = <&tach1>;
- pgood_gpio = <&gpio_pgood_fan>;
- };
- };
-};
-
-/* Tachometer for fan speed measurement */
-&tach1 {
- status = "okay";
- pinctrl-0 = <&alt3_ta1_sl1>; /* Use TA1 as input pin */
- port = <NPCX_TACH_PORT_A>; /* port-A is selected */
- sample-clk = <NPCX_TACH_FREQ_LFCLK>; /* Use LFCLK as sampling clock */
- pulses-per-round = <2>; /* number of pulses per round of encoder */
-};
diff --git a/zephyr/projects/npcx_evb/npcx9/gpio.dts b/zephyr/projects/npcx_evb/npcx9/gpio.dts
deleted file mode 100644
index fb8f83803f..0000000000
--- a/zephyr/projects/npcx_evb/npcx9/gpio.dts
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-gpios {
- compatible = "named-gpios";
-
- recovery_l {
- gpios = <&gpio0 3 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "RECOVERY_L";
- };
- wp_l {
- gpios = <&gpio9 3 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_WP_L";
- label = "WP_L";
- };
- gpio_ac_present: ac_present {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- label = "AC_PRESENT";
- };
- gpio_power_button_l: power_button_l {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- label = "POWER_BUTTON_L";
- };
- gpio_lid_open: lid_open {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- label = "LID_OPEN";
- };
- entering_rw {
- gpios = <&gpio3 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- label = "ENTERING_RW";
- };
- pch_wake_l {
- gpios = <&gpio5 0 GPIO_OUT_HIGH>;
- enum-name = "GPIO_EC_PCH_WAKE_ODL";
- label = "PCH_WAKE_L";
- };
- gpio_pgood_fan: pgood_fan {
- gpios = <&gpioc 7 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_PGOOD_FAN";
- label = "PGOOD_FAN";
- };
- spi_cs_l {
- gpios = <&gpioa 5 GPIO_OUT_HIGH>;
- label = "SPI_CS_L";
- };
- board_version1 {
- gpios = <&gpio6 4 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION1";
- label = "BOARD_VERSION1";
- };
- board_version2 {
- gpios = <&gpio6 5 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION2";
- label = "BOARD_VERSION2";
- };
- board_version3 {
- gpios = <&gpio6 6 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION3";
- label = "BOARD_VERSION3";
- };
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-pins = <
- &gpio_ac_present
- &gpio_power_button_l
- &gpio_lid_open
- >;
- };
-};
diff --git a/zephyr/projects/npcx_evb/npcx9/include/gpio_map.h b/zephyr/projects/npcx_evb/npcx9/include/gpio_map.h
deleted file mode 100644
index 741cbd89a2..0000000000
--- a/zephyr/projects/npcx_evb/npcx9/include/gpio_map.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-#define GPIO_KBD_KSO2 GPIO_UNIMPLEMENTED
-
-/*
- * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items.
- *
- * Each GPIO_INT requires three parameters:
- * gpio_signal - The enum gpio_signal for the interrupt gpio
- * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH)
- * handler - The platform/ec interrupt handler.
- *
- * Ensure that this files includes all necessary headers to declare all
- * referenced handler functions.
- *
- * For example, one could use the follow definition:
- * #define EC_CROS_GPIO_INTERRUPTS \
- * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print)
- */
-#define EC_CROS_GPIO_INTERRUPTS \
- GPIO_INT(GPIO_AC_PRESENT, GPIO_INT_EDGE_BOTH, extpower_interrupt) \
- GPIO_INT(GPIO_LID_OPEN, GPIO_INT_EDGE_BOTH, lid_interrupt) \
- GPIO_INT(GPIO_POWER_BUTTON_L, GPIO_INT_EDGE_BOTH, \
- power_button_interrupt)
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
diff --git a/zephyr/projects/npcx_evb/npcx9/include/pwm_map.h b/zephyr/projects/npcx_evb/npcx9/include/pwm_map.h
deleted file mode 100644
index 371e95c116..0000000000
--- a/zephyr/projects/npcx_evb/npcx9/include/pwm_map.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_PWM_MAP_H
-#define __ZEPHYR_PWM_MAP_H
-
-#include <devicetree.h>
-
-#include "pwm/pwm.h"
-
-#define PWM_CH_FAN NAMED_PWM(fan)
-#define PWM_CH_KBLIGHT NAMED_PWM(kblight)
-
-#endif /* __ZEPHYR_PWM_MAP_H */
diff --git a/zephyr/projects/npcx_evb/npcx9/keyboard.dts b/zephyr/projects/npcx_evb/npcx9/keyboard.dts
deleted file mode 100644
index fdeee3c02c..0000000000
--- a/zephyr/projects/npcx_evb/npcx9/keyboard.dts
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- 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 */
- >;
- };
-};
diff --git a/zephyr/projects/npcx_evb/npcx9/prj.conf b/zephyr/projects/npcx_evb/npcx9/prj.conf
deleted file mode 100644
index ea383a600d..0000000000
--- a/zephyr/projects/npcx_evb/npcx9/prj.conf
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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_PLATFORM_EC_PWM=y
-
-# Fan
-CONFIG_SENSOR=y
-CONFIG_SENSOR_SHELL=n
-CONFIG_PLATFORM_EC_FAN=y
-
-# Console command
-CONFIG_PLATFORM_EC_CONSOLE_CMD_SCRATCHPAD=y
-
-# eSPI
-CONFIG_ESPI=y
-CONFIG_PLATFORM_EC_ESPI_VW_SLP_S3=y
-CONFIG_PLATFORM_EC_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
-
-# Zephyr feature
-CONFIG_ASSERT=y
-CONFIG_SHELL_MINIMAL=n
-CONFIG_LOG=y
-
-# Avoid underflow info from tachometer
-CONFIG_SENSOR_LOG_LEVEL_ERR=y
-
-# Avoid info storm from power management
-CONFIG_SOC_LOG_LEVEL_ERR=y
-
-CONFIG_SYSCON=y
diff --git a/zephyr/projects/npcx_evb/npcx9/pwm.dts b/zephyr/projects/npcx_evb/npcx9/pwm.dts
deleted file mode 100644
index 144b4d96b9..0000000000
--- a/zephyr/projects/npcx_evb/npcx9/pwm.dts
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-pwms {
- compatible = "named-pwms";
-
- pwm_fan: fan {
- pwms = <&pwm0 0 0>;
- label = "FAN";
- frequency = <25000>;
- };
- kblight {
- pwms = <&pwm2 0 0>;
- label = "KBLIGHT";
- frequency = <10000>;
- };
- };
-};
-
-/* fan */
-&pwm0 {
- status = "okay";
- drive-open-drain;
-};
-
-/* kblight */
-&pwm2 {
- status = "okay";
-};
diff --git a/zephyr/projects/npcx_evb/npcx9/zmake.yaml b/zephyr/projects/npcx_evb/npcx9/zmake.yaml
deleted file mode 100644
index 1d750cc813..0000000000
--- a/zephyr/projects/npcx_evb/npcx9/zmake.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: npcx9_evb
-dts-overlays:
- - gpio.dts
- - pwm.dts
- - fan.dts
- - keyboard.dts
-supported-toolchains:
- - coreboot-sdk
- - zephyr
-supported-zephyr-versions:
- - v2.6
-output-type: npcx
diff --git a/zephyr/projects/posix-ec/CMakeLists.txt b/zephyr/projects/posix-ec/CMakeLists.txt
deleted file mode 100644
index c4ac80228d..0000000000
--- a/zephyr/projects/posix-ec/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2020 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.
-# SPDX-License-Identifier: Apache-2.0
-
-cmake_minimum_required(VERSION 3.13.1)
-set(BOARD native_posix)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(posix-ec)
diff --git a/zephyr/projects/posix-ec/prj.conf b/zephyr/projects/posix-ec/prj.conf
deleted file mode 100644
index e79730789d..0000000000
--- a/zephyr/projects/posix-ec/prj.conf
+++ /dev/null
@@ -1,18 +0,0 @@
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-
-# Disable shimmed code. Can enabled selectively later
-CONFIG_SHIMMED_TASKS=n
-CONFIG_PLATFORM_EC_KEYBOARD=n
-CONFIG_PLATFORM_EC_HOSTCMD=n
-CONFIG_PLATFORM_EC_I2C=n
-
-# Define necessary program memory locations. These are meaning less though
-CONFIG_CROS_EC_PROGRAM_MEMORY_BASE=0x10090000
-CONFIG_CROS_EC_RAM_BASE=0x200c0000
-CONFIG_CROS_EC_DATA_RAM_SIZE=0x00010000
-CONFIG_CROS_EC_RAM_SIZE=0x0000f800
-CONFIG_CROS_EC_RO_MEM_OFF=0x0
-CONFIG_CROS_EC_RO_SIZE=0xb000
-CONFIG_CROS_EC_RW_MEM_OFF=0xb000
-CONFIG_CROS_EC_RW_SIZE=0x75000
diff --git a/zephyr/projects/posix-ec/zmake.yaml b/zephyr/projects/posix-ec/zmake.yaml
deleted file mode 100644
index e06fd99183..0000000000
--- a/zephyr/projects/posix-ec/zmake.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-board: native_posix
-supported-toolchains:
- - llvm
- - host
-supported-zephyr-versions:
- - v2.6
-output-type: elf
diff --git a/zephyr/projects/trogdor/lazor/CMakeLists.txt b/zephyr/projects/trogdor/lazor/CMakeLists.txt
deleted file mode 100644
index 7ab5d6a92e..0000000000
--- a/zephyr/projects/trogdor/lazor/CMakeLists.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(lazor)
-
-zephyr_library_include_directories(include)
-
-set(PLATFORM_EC_BASEBOARD "${PLATFORM_EC}/baseboard/trogdor" CACHE PATH
- "Path to the platform/ec baseboard directory")
-set(PLATFORM_EC_BOARD "${PLATFORM_EC}/board/lazor" CACHE PATH
- "Path to the platform/ec board directory")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "${PLATFORM_EC_BASEBOARD}/hibernate.c"
- "${PLATFORM_EC_BASEBOARD}/power.c"
- "${PLATFORM_EC_BASEBOARD}/usbc_config.c"
- "${PLATFORM_EC_BASEBOARD}/usb_pd_policy.c")
-
-zephyr_library_sources(
- "${PLATFORM_EC_BOARD}/hibernate.c"
- "${PLATFORM_EC_BOARD}/sku.c"
- "${PLATFORM_EC_BOARD}/switchcap.c"
- "${PLATFORM_EC_BOARD}/usbc_config.c")
-
-# Board specific implementation
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C
- "src/i2c.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON
- "src/led.c")
diff --git a/zephyr/projects/trogdor/lazor/battery.dts b/zephyr/projects/trogdor/lazor/battery.dts
deleted file mode 100644
index 52aa69d400..0000000000
--- a/zephyr/projects/trogdor/lazor/battery.dts
+++ /dev/null
@@ -1,24 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- batteries {
- default_battery: ap16l5j {
- compatible = "panasonic,ap16l5j";
- };
- ap16l5j_009 {
- compatible = "panasonic,ap16l5j-009";
- };
- ap16l8j {
- compatible = "lgc,ap16l8j";
- };
- lgc_ap18c8k {
- compatible = "lgc,ap18c8k";
- };
- murata_ap18c4k {
- compatible = "murata,ap18c4k";
- };
- };
-};
diff --git a/zephyr/projects/trogdor/lazor/gpio.dts b/zephyr/projects/trogdor/lazor/gpio.dts
deleted file mode 100644
index 282ea97bb4..0000000000
--- a/zephyr/projects/trogdor/lazor/gpio.dts
+++ /dev/null
@@ -1,446 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-gpios {
- compatible = "named-gpios";
-
- usb_c0_pd_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PD_INT_ODL";
- label = "USB_C0_PD_INT_ODL";
- };
- usb_c1_pd_int_odl {
- gpios = <&gpiof 5 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_PD_INT_ODL";
- label = "USB_C1_PD_INT_ODL";
- };
- usb_c0_swctl_int_odl {
- gpios = <&gpio0 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
- label = "USB_C0_SWCTL_INT_ODL";
- };
- usb_c1_swctl_int_odl {
- gpios = <&gpio4 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
- label = "USB_C1_SWCTL_INT_ODL";
- };
- usb_c0_bc12_int_l {
- gpios = <&gpio6 1 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_USB_C0_BC12_INT_L";
- label = "USB_C0_BC12_INT_L";
- };
- usb_c1_bc12_int_l {
- gpios = <&gpio8 2 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_USB_C1_BC12_INT_L";
- label = "USB_C1_BC12_INT_L";
- };
- usb_a0_oc_odl {
- gpios = <&gpiod 1 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_USB_A0_OC_ODL";
- label = "USB_A0_OC_ODL";
- };
- gpio_acok_od: acok_od {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- label = "ACOK_OD";
- };
- ccd_mode_odl {
- gpios = <&gpioe 3 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- label = "CCD_MODE_ODL";
- };
- gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- label = "EC_PWR_BTN_ODL";
- };
- ec_voldn_btn_odl {
- gpios = <&gpio7 0 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- label = "EC_VOLDN_BTN_ODL";
- };
- ec_volup_btn_odl {
- gpios = <&gpiof 2 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_VOLUME_UP_L";
- label = "EC_VOLUP_BTN_ODL";
- };
- ec_wp_odl {
- gpios = <&gpioa 1 GPIO_INPUT>;
- enum-name = "GPIO_WP_L";
- label = "EC_WP_ODL";
- };
- gpio_lid_open_ec: lid_open_ec {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- label = "LID_OPEN_EC";
- };
- ap_rst_l {
- gpios = <&gpioc 1 GPIO_INPUT>;
- enum-name = "GPIO_AP_RST_L";
- label = "AP_RST_L";
- };
- ps_hold {
- gpios = <&gpioa 4 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- enum-name = "GPIO_PS_HOLD";
- label = "PS_HOLD";
- };
- ap_suspend {
- gpios = <&gpio5 7 GPIO_INPUT>;
- enum-name = "GPIO_AP_SUSPEND";
- label = "AP_SUSPEND";
- };
- deprecated_ap_rst_req {
- gpios = <&gpioc 2 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- enum-name = "GPIO_DEPRECATED_AP_RST_REQ";
- label = "DEPRECATED_AP_RST_REQ";
- };
- power_good {
- gpios = <&gpio5 4 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- enum-name = "GPIO_POWER_GOOD";
- label = "POWER_GOOD";
- };
- warm_reset_l {
- gpios = <&gpiof 4 GPIO_INPUT>;
- enum-name = "GPIO_WARM_RESET_L";
- label = "WARM_RESET_L";
- };
- ap_ec_spi_cs_l {
- gpios = <&gpio5 3 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "AP_EC_SPI_CS_L";
- };
- tablet_mode_l {
- gpios = <&gpioc 6 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- label = "TABLET_MODE_L";
- };
- gpio_accel_gyro_int_l: accel_gyro_int_l {
- gpios = <&gpioa 0 GPIO_INPUT>;
- enum-name = "GPIO_ACCEL_GYRO_INT_L";
- label = "ACCEL_GYRO_INT_L";
- };
- da9313_gpio0 {
- gpios = <&gpioe 2 GPIO_INPUT>;
- enum-name = "GPIO_DA9313_GPIO0";
- label = "DA9313_GPIO0";
- };
- switchcap_pg_int_l {
- gpios = <&gpioe 2 GPIO_INPUT>;
- enum-name = "GPIO_SWITCHCAP_PG_INT_L";
- label = "SWITCHCAP_PG_INT_L";
- };
- gpio_ec_rst_odl: ec_rst_odl {
- gpios = <&gpio0 2 GPIO_INPUT>;
- enum-name = "GPIO_EC_RST_ODL";
- label = "EC_RST_ODL";
- };
- ec_entering_rw {
- gpios = <&gpioe 1 GPIO_OUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- label = "EC_ENTERING_RW";
- };
- ec_batt_pres_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- label = "EC_BATT_PRES_ODL";
- };
- pm845_resin_l {
- gpios = <&gpio3 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_RESIN_L";
- label = "PM845_RESIN_L";
- };
- pmic_kpd_pwr_odl {
- gpios = <&gpiod 6 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_KPD_PWR_ODL";
- label = "PMIC_KPD_PWR_ODL";
- };
- ec_int_l {
- gpios = <&gpioa 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- label = "EC_INT_L";
- };
- qsip_on {
- gpios = <&gpio5 0 GPIO_OUT_LOW>;
- enum-name = "GPIO_QSIP_ON";
- label = "QSIP_ON";
- };
- hibernate_l {
- gpios = <&gpio5 2 GPIO_OUT_HIGH>;
- enum-name = "GPIO_HIBERNATE_L";
- label = "HIBERNATE_L";
- };
- switchcap_on {
- gpios = <&gpiod 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_SWITCHCAP_ON";
- label = "SWITCHCAP_ON";
- };
- switchcap_on_l {
- gpios = <&gpiod 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_SWITCHCAP_ON_L";
- label = "SWITCHCAP_ON_L";
- };
- vbob_en {
- gpios = <&gpiod 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_VBOB_EN";
- label = "VBOB_EN";
- };
- en_pp3300_a {
- gpios = <&gpioa 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP3300_A";
- label = "EN_PP3300_A";
- };
- en_pp5000_a {
- gpios = <&gpio6 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP5000";
- label = "EN_PP5000_A";
- };
- ec_bl_disable_l {
- gpios = <&gpiob 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- label = "EC_BL_DISABLE_L";
- };
- lid_accel_int_l {
- gpios = <&gpio5 6 GPIO_INPUT>;
- enum-name = "GPIO_LID_ACCEL_INT_L";
- label = "LID_ACCEL_INT_L";
- };
- trackpad_int_gate {
- gpios = <&gpio7 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_TRACKPAD_INT_GATE";
- label = "TRACKPAD_INT_GATE";
- };
- usb_c0_pd_rst_l {
- gpios = <&gpiof 1 GPIO_ODR_HIGH>;
- enum-name = "GPIO_USB_C0_PD_RST_L";
- label = "USB_C0_PD_RST_L";
- };
- usb_c1_pd_rst_l {
- gpios = <&gpioe 4 GPIO_ODR_HIGH>;
- enum-name = "GPIO_USB_C1_PD_RST_L";
- label = "USB_C1_PD_RST_L";
- };
- dp_mux_oe_l {
- gpios = <&gpio9 6 GPIO_ODR_HIGH>;
- enum-name = "GPIO_DP_MUX_OE_L";
- label = "DP_MUX_OE_L";
- };
- dp_mux_sel {
- gpios = <&gpio4 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_DP_MUX_SEL";
- label = "DP_MUX_SEL";
- };
- dp_hot_plug_det {
- gpios = <&gpio9 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_DP_HOT_PLUG_DET";
- label = "DP_HOT_PLUG_DET";
- };
- en_usb_a_5v {
- gpios = <&gpio8 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_USB_A_5V";
- label = "EN_USB_A_5V";
- };
- usb_a_cdp_ilim_en {
- gpios = <&gpio7 5 GPIO_OUT_HIGH>;
- label = "USB_A_CDP_ILIM_EN";
- };
- ec_chg_led_y_c1 {
- gpios = <&gpioc 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_CHG_LED_Y_C1";
- label = "EC_CHG_LED_Y_C1";
- };
- ec_chg_led_b_c1 {
- gpios = <&gpioc 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_CHG_LED_B_C1";
- label = "EC_CHG_LED_B_C1";
- };
- ap_ec_spi_mosi {
- gpios = <&gpio4 6 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "AP_EC_SPI_MOSI";
- };
- ap_ec_spi_miso {
- gpios = <&gpio4 7 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "AP_EC_SPI_MISO";
- };
- ap_ec_spi_clk {
- gpios = <&gpio5 5 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "AP_EC_SPI_CLK";
- };
- kb_bl_pwm {
- gpios = <&gpio8 0 GPIO_INPUT>;
- label = "KB_BL_PWM";
- };
- edp_bkltctl {
- gpios = <&gpiob 7 GPIO_INPUT>;
- label = "EDP_BKLTCTL";
- };
- ppvar_boostin_sense {
- gpios = <&gpio4 4 GPIO_INPUT>;
- label = "PPVAR_BOOSTIN_SENSE";
- };
- charger_iadp {
- gpios = <&gpio4 3 GPIO_INPUT>;
- label = "CHARGER_IADP";
- };
- charger_pmon {
- gpios = <&gpio4 2 GPIO_INPUT>;
- label = "CHARGER_PMON";
- };
- ec_i2c_power_scl {
- gpios = <&gpiob 5 GPIO_INPUT>;
- label = "EC_I2C_POWER_SCL";
- };
- ec_i2c_power_sda {
- gpios = <&gpiob 4 GPIO_INPUT>;
- label = "EC_I2C_POWER_SDA";
- };
- ec_i2c_usb_c0_pd_scl {
- gpios = <&gpio9 0 GPIO_INPUT>;
- label = "EC_I2C_USB_C0_PD_SCL";
- };
- ec_i2c_usb_c0_pd_sda {
- gpios = <&gpio8 7 GPIO_INPUT>;
- label = "EC_I2C_USB_C0_PD_SDA";
- };
- ec_i2c_usb_c1_pd_scl {
- gpios = <&gpio9 2 GPIO_INPUT>;
- label = "EC_I2C_USB_C1_PD_SCL";
- };
- ec_i2c_usb_c1_pd_sda {
- gpios = <&gpio9 1 GPIO_INPUT>;
- label = "EC_I2C_USB_C1_PD_SDA";
- };
- ec_i2c_eeprom_scl {
- gpios = <&gpio3 3 GPIO_INPUT>;
- label = "EC_I2C_EEPROM_SCL";
- };
- ec_i2c_eeprom_sda {
- gpios = <&gpio3 6 GPIO_INPUT>;
- label = "EC_I2C_EEPROM_SDA";
- };
- ec_i2c_sensor_scl {
- gpios = <&gpiob 3 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C_SENSOR_SCL";
- label = "EC_I2C_SENSOR_SCL";
- };
- ec_i2c_sensor_sda {
- gpios = <&gpiob 2 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C_SENSOR_SDA";
- label = "EC_I2C_SENSOR_SDA";
- };
- gpio_brd_id0: brd_id0 {
- gpios = <&gpioc 7 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION1";
- label = "BRD_ID0";
- };
- gpio_brd_id1: brd_id1 {
- gpios = <&gpio9 3 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION2";
- label = "BRD_ID1";
- };
- gpio_brd_id2: brd_id2 {
- gpios = <&gpio6 3 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION3";
- label = "BRD_ID2";
- };
- gpio_sku_id0: sku_id0 {
- gpios = <&gpiof 0 GPIO_INPUT>;
- enum-name = "GPIO_SKU_ID0";
- label = "SKU_ID0";
- };
- gpio_sku_id1: sku_id1 {
- gpios = <&gpio4 1 GPIO_INPUT>;
- enum-name = "GPIO_SKU_ID1";
- label = "SKU_ID1";
- };
- gpio_sku_id2: sku_id2 {
- gpios = <&gpiod 4 GPIO_INPUT>;
- enum-name = "GPIO_SKU_ID2";
- label = "SKU_ID2";
- };
- arm_x86 {
- gpios = <&gpio6 6 GPIO_OUT_LOW>;
- label = "ARM_X86";
- };
- ec_kso_02_inv {
- gpios = <&gpio1 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_KBD_KSO2";
- label = "EC_KSO_02_INV";
- };
- };
-
- def-lvol-io-list {
- compatible = "nuvoton,npcx-lvolctrl-def";
- lvol-io-pads = <
- &lvol_ioc1 /* AP_RST_L */
- &lvol_ioc2 /* DEPRECATED_AP_RST_REQ */
- &lvol_iof4 /* WARM_RESET_L */
- &lvol_iob3 /* EC_I2C_SENSOR_SCL */
- &lvol_iob2 /* EC_I2C_SENSOR_SDA */
- >;
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-pins = <
- &gpio_acok_od
- &gpio_ec_pwr_btn_odl
- &gpio_lid_open_ec
- &gpio_ec_rst_odl
- >;
- };
-
- 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/include/gpio_map.h b/zephyr/projects/trogdor/lazor/include/gpio_map.h
deleted file mode 100644
index 00ee9c48e1..0000000000
--- a/zephyr/projects/trogdor/lazor/include/gpio_map.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-#ifdef CONFIG_PLATFORM_EC_GMR_TABLET_MODE
-#define GMR_TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L
-#endif
-
-/*
- * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items.
- *
- * Each GPIO_INT requires three parameters:
- * gpio_signal - The enum gpio_signal for the interrupt gpio
- * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH)
- * handler - The platform/ec interrupt handler.
- *
- * Ensure that this files includes all necessary headers to declare all
- * referenced handler functions.
- *
- * For example, one could use the follow definition:
- * #define EC_CROS_GPIO_INTERRUPTS \
- * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print)
- */
-#define EC_CROS_GPIO_INTERRUPTS \
- GPIO_INT(GPIO_AC_PRESENT, GPIO_INT_EDGE_BOTH, extpower_interrupt) \
- GPIO_INT(GPIO_LID_OPEN, GPIO_INT_EDGE_BOTH, lid_interrupt) \
- GPIO_INT(GPIO_WP_L, GPIO_INT_EDGE_BOTH, switch_interrupt) \
- GPIO_INT(GPIO_POWER_BUTTON_L, GPIO_INT_EDGE_BOTH, \
- power_button_interrupt) \
- GPIO_INT(GPIO_VOLUME_DOWN_L, GPIO_INT_EDGE_BOTH, button_interrupt) \
- GPIO_INT(GPIO_VOLUME_UP_L, GPIO_INT_EDGE_BOTH, button_interrupt) \
- GPIO_INT(GPIO_SWITCHCAP_PG_INT_L, GPIO_INT_EDGE_FALLING, \
- ln9310_interrupt) \
- GPIO_INT(GPIO_AP_RST_L, GPIO_INT_EDGE_BOTH, chipset_ap_rst_interrupt) \
- GPIO_INT(GPIO_AP_SUSPEND, GPIO_INT_EDGE_BOTH, power_signal_interrupt) \
- GPIO_INT(GPIO_DEPRECATED_AP_RST_REQ, GPIO_INT_EDGE_BOTH, \
- power_signal_interrupt) \
- GPIO_INT(GPIO_POWER_GOOD, GPIO_INT_EDGE_BOTH, \
- chipset_power_good_interrupt) \
- GPIO_INT(GPIO_PS_HOLD, GPIO_INT_EDGE_BOTH, power_signal_interrupt) \
- GPIO_INT(GPIO_WARM_RESET_L, GPIO_INT_EDGE_BOTH, \
- chipset_warm_reset_interrupt) \
- GPIO_INT(GPIO_USB_C0_PD_INT_ODL, GPIO_INT_EDGE_FALLING, \
- tcpc_alert_event) \
- GPIO_INT(GPIO_USB_C1_PD_INT_ODL, GPIO_INT_EDGE_FALLING, \
- tcpc_alert_event) \
- GPIO_INT(GPIO_USB_C0_SWCTL_INT_ODL, GPIO_INT_EDGE_FALLING, \
- ppc_interrupt) \
- GPIO_INT(GPIO_USB_C1_SWCTL_INT_ODL, GPIO_INT_EDGE_FALLING, \
- ppc_interrupt) \
- GPIO_INT(GPIO_USB_C0_BC12_INT_L, GPIO_INT_EDGE_FALLING, usb0_evt) \
- GPIO_INT(GPIO_USB_C1_BC12_INT_L, GPIO_INT_EDGE_FALLING, usb1_evt) \
- GPIO_INT(GPIO_USB_A0_OC_ODL, GPIO_INT_EDGE_BOTH, usba_oc_interrupt) \
- GPIO_INT(GPIO_CCD_MODE_ODL, GPIO_INT_EDGE_FALLING, \
- board_connect_c0_sbu) \
- GPIO_INT(GPIO_ACCEL_GYRO_INT_L, GPIO_INT_EDGE_FALLING, \
- bmi160_interrupt) \
- GPIO_INT(GPIO_TABLET_MODE_L, GPIO_INT_EDGE_BOTH, gmr_tablet_switch_isr)
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
diff --git a/zephyr/projects/trogdor/lazor/include/pwm_map.h b/zephyr/projects/trogdor/lazor/include/pwm_map.h
deleted file mode 100644
index e704b6d6d3..0000000000
--- a/zephyr/projects/trogdor/lazor/include/pwm_map.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_PWM_MAP_H
-#define __ZEPHYR_PWM_MAP_H
-
-#include <devicetree.h>
-
-#include "pwm/pwm.h"
-
-#define PWM_CH_KBLIGHT NAMED_PWM(kblight)
-#define PWM_CH_DISPLIGHT NAMED_PWM(displight)
-
-#endif /* __ZEPHYR_PWM_MAP_H */
diff --git a/zephyr/projects/trogdor/lazor/keyboard.dts b/zephyr/projects/trogdor/lazor/keyboard.dts
deleted file mode 100644
index 1b683d0eba..0000000000
--- a/zephyr/projects/trogdor/lazor/keyboard.dts
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- 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 */
- >;
- };
-};
diff --git a/zephyr/projects/trogdor/lazor/motionsense.dts b/zephyr/projects/trogdor/lazor/motionsense.dts
deleted file mode 100644
index 51d8505078..0000000000
--- a/zephyr/projects/trogdor/lazor/motionsense.dts
+++ /dev/null
@@ -1,193 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <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.
- */
- bmi160-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 {
- label = "LID_MUTEX";
- };
-
- mutex_bmi160: bmi160-mutex {
- label = "BMI160_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)>;
- };
- };
-
- /*
- * 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 {
- bma255_data: bma255-drv-data {
- compatible = "cros-ec,drvdata-bma255";
- status = "okay";
- };
-
- bmi160_data: bmi160-drv-data {
- compatible = "cros-ec,drvdata-bmi160";
- status = "okay";
- };
-
- kx022_data: kx022-drv-data {
- compatible = "cros-ec,drvdata-kionix";
- status = "okay";
- };
- };
-
- /*
- * List of motion sensors that creates motion_sensors array.
- * The label "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,bma255";
- status = "okay";
-
- label = "Lid Accel";
- active-mask = "SENSOR_ACTIVE_S0_S3_S5";
- location = "MOTIONSENSE_LOC_LID";
- mutex = <&lid_mutex>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&lid_rot_ref>;
- default-range = <2>;
- drv-data = <&bma255_data>;
- i2c-spi-addr-flags = "BMA2x2_I2C_ADDR1_FLAGS";
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_accel: base-accel {
- compatible = "cros-ec,bmi160-accel";
- status = "okay";
-
- label = "Base Accel";
- active-mask = "SENSOR_ACTIVE_S0_S3_S5";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi160>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&bmi160_data>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base-gyro {
- compatible = "cros-ec,bmi160-gyro";
- status = "okay";
-
- label = "Base Gyro";
- active-mask = "SENSOR_ACTIVE_S0_S3_S5";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi160>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&bmi160_data>;
- };
- };
-
- /*
- * List of alternative motion sensors that creates
- * motion_sensors_alt array.
- */
- motionsense-sensor-alt {
- alt_lid_accel {
- compatible = "cros-ec,kx022";
- status = "okay";
- label = "Lid Accel";
- active-mask = "SENSOR_ACTIVE_S0_S3_S5";
- location = "MOTIONSENSE_LOC_LID";
- mutex = <&lid_mutex>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&lid_rot_ref>;
- drv-data = <&kx022_data>;
- alternate-for = <&lid_accel>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | 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 = <&gpio_accel_gyro_int_l>;
- /* list of sensors in force mode */
- accel-force-mode-sensors = <&lid_accel>;
- };
-};
diff --git a/zephyr/projects/trogdor/lazor/prj.conf b/zephyr/projects/trogdor/lazor/prj.conf
deleted file mode 100644
index e16994e327..0000000000
--- a/zephyr/projects/trogdor/lazor/prj.conf
+++ /dev/null
@@ -1,165 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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_I2C=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_COMMON=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-CONFIG_PLATFORM_EC_PWM=y
-CONFIG_PLATFORM_EC_PWM_DISPLIGHT=y
-CONFIG_PLATFORM_EC_PWM_KBLIGHT=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 mask
-CONFIG_PLATFORM_EC_MKBP_EVENT_WAKEUP_MASK=y
-CONFIG_PLATFORM_EC_MKBP_HOST_EVENT_WAKEUP_MASK=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_VOLUME_BUTTONS=y
-CONFIG_PLATFORM_EC_CMD_BUTTON=y
-CONFIG_CROS_KB_RAW_NPCX=y
-
-# ADC
-CONFIG_PLATFORM_EC_ADC=y
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
-# Battery
-CONFIG_HAS_TASK_USB_CHG_P1=y
-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_USB_A_PORT_COUNT=1
-
-# 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_PORT_MAX_COUNT=2
-CONFIG_PLATFORM_EC_USB_PD_REV30=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_PD_LOGGING=y
-CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB=y
-CONFIG_HAS_TASK_PD_C1=y
-CONFIG_HAS_TASK_PD_INT_C1=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
-
-# Serial Host Interface (SHI) device.
-CONFIG_CROS_SHI_NPCX=y
-
-# Sensors
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_ACCEL_INTERRUPTS=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
-
-# 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/src/i2c.c b/zephyr/projects/trogdor/lazor/src/i2c.c
deleted file mode 100644
index a7ce970843..0000000000
--- a/zephyr/projects/trogdor/lazor/src/i2c.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c/i2c.h"
-#include "i2c.h"
-
-/* Lazor board specific i2c implementation */
-
-#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
-int board_allow_i2c_passthru(int port)
-{
- return (i2c_get_device_for_port(port) ==
- i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY));
-}
-#endif
diff --git a/zephyr/projects/trogdor/lazor/src/led.c b/zephyr/projects/trogdor/lazor/src/led.c
deleted file mode 100644
index e4b34576c8..0000000000
--- a/zephyr/projects/trogdor/lazor/src/led.c
+++ /dev/null
@@ -1,155 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Power and battery LED control.
- */
-
-#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 "system.h"
-#include "util.h"
-
-#define LED_ONE_SEC (1000 / HOOK_TICK_INTERVAL_MS)
-
-#define BAT_LED_ON 1
-#define BAT_LED_OFF 0
-
-const enum ec_led_id supported_led_ids[] = {
- EC_LED_ID_BATTERY_LED,
-};
-
-const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids);
-
-enum led_color {
- LED_OFF = 0,
- LED_AMBER,
- LED_BLUE,
- LED_COLOR_COUNT /* Number of colors, not a color itself */
-};
-
-static void led_set_color(enum led_color color)
-{
- gpio_set_level(GPIO_EC_CHG_LED_Y_C1,
- (color == LED_AMBER) ? BAT_LED_ON : BAT_LED_OFF);
- gpio_set_level(GPIO_EC_CHG_LED_B_C1,
- (color == LED_BLUE) ? BAT_LED_ON : BAT_LED_OFF);
-}
-
-void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
-{
- brightness_range[EC_LED_COLOR_AMBER] = 1;
- brightness_range[EC_LED_COLOR_BLUE] = 1;
-}
-
-int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness)
-{
- if (brightness[EC_LED_COLOR_BLUE] != 0)
- led_set_color(LED_BLUE);
- else if (brightness[EC_LED_COLOR_AMBER] != 0)
- led_set_color(LED_AMBER);
- else
- led_set_color(LED_OFF);
-
- return EC_SUCCESS;
-}
-
-static void board_led_set_battery(void)
-{
- static int battery_ticks;
- int color = LED_OFF;
- int period = 0;
- uint32_t chflags = charge_get_flags();
-
- battery_ticks++;
-
- switch (charge_get_state()) {
- case PWR_STATE_CHARGE:
- /* Always indicate amber on when charging. */
- color = LED_AMBER;
- break;
- case PWR_STATE_DISCHARGE:
- if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND)) {
- /* Discharging in S3: Amber 1 sec, off 3 sec */
- period = (1 + 3) * LED_ONE_SEC;
- battery_ticks = battery_ticks % period;
- if (battery_ticks < 1 * LED_ONE_SEC)
- color = LED_AMBER;
- else
- color = LED_OFF;
- } else if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
- /* Discharging in S5: off */
- color = LED_OFF;
- } else if (chipset_in_state(CHIPSET_STATE_ON)) {
- /* Discharging in S0: Blue on */
- color = LED_BLUE;
- }
- break;
- case PWR_STATE_ERROR:
- /* Battery error: Amber 1 sec, off 1 sec */
- period = (1 + 1) * LED_ONE_SEC;
- battery_ticks = battery_ticks % period;
- if (battery_ticks < 1 * LED_ONE_SEC)
- color = LED_AMBER;
- else
- color = LED_OFF;
- break;
- case PWR_STATE_CHARGE_NEAR_FULL:
- /* Full Charged: Blue on */
- color = LED_BLUE;
- break;
- case PWR_STATE_IDLE: /* External power connected in IDLE */
- if (chflags & CHARGE_FLAG_FORCE_IDLE) {
- /* Factory mode: Blue 2 sec, Amber 2 sec */
- period = (2 + 2) * LED_ONE_SEC;
- battery_ticks = battery_ticks % period;
- if (battery_ticks < 2 * LED_ONE_SEC)
- color = LED_BLUE;
- else
- color = LED_AMBER;
- } else
- color = LED_BLUE;
- break;
- default:
- /* Other states don't alter LED behavior */
- break;
- }
-
- led_set_color(color);
-}
-
-/* Called by hook task every TICK */
-static void led_tick(void)
-{
- if (led_auto_control_is_enabled(EC_LED_ID_BATTERY_LED))
- board_led_set_battery();
-}
-DECLARE_HOOK(HOOK_TICK, led_tick, HOOK_PRIO_DEFAULT);
-
-void led_control(enum ec_led_id led_id, enum ec_led_state state)
-{
- enum led_color color;
-
- if ((led_id != EC_LED_ID_RECOVERY_HW_REINIT_LED) &&
- (led_id != EC_LED_ID_SYSRQ_DEBUG_LED))
- return;
-
- if (state == LED_STATE_RESET) {
- led_auto_control(EC_LED_ID_BATTERY_LED, 1);
- board_led_set_battery();
- return;
- }
-
- color = state ? LED_BLUE : LED_OFF;
-
- led_auto_control(EC_LED_ID_BATTERY_LED, 0);
-
- led_set_color(color);
-}
diff --git a/zephyr/projects/trogdor/lazor/zmake.yaml b/zephyr/projects/trogdor/lazor/zmake.yaml
deleted file mode 100644
index c1c14d07d5..0000000000
--- a/zephyr/projects/trogdor/lazor/zmake.yaml
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: trogdor
-dts-overlays:
- - battery.dts
- - gpio.dts
- - keyboard.dts
- - motionsense.dts
-supported-toolchains:
- - coreboot-sdk
- - zephyr
-supported-zephyr-versions:
- - v2.6
-output-type: npcx
diff --git a/zephyr/projects/trogdor/trogdor/CMakeLists.txt b/zephyr/projects/trogdor/trogdor/CMakeLists.txt
deleted file mode 100644
index 99c72e1b81..0000000000
--- a/zephyr/projects/trogdor/trogdor/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(trogdor)
-
-zephyr_library_include_directories(include)
-
-set(PLATFORM_EC_BASEBOARD "${PLATFORM_EC}/baseboard/trogdor" CACHE PATH
- "Path to the platform/ec baseboard directory")
-set(PLATFORM_EC_BOARD "${PLATFORM_EC}/board/trogdor" CACHE PATH
- "Path to the platform/ec board directory")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "${PLATFORM_EC_BASEBOARD}/hibernate.c"
- "${PLATFORM_EC_BASEBOARD}/usbc_config.c"
- "${PLATFORM_EC_BASEBOARD}/usb_pd_policy.c")
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON
- "${PLATFORM_EC_BOARD}/led.c")
-
-zephyr_library_sources(
- "${PLATFORM_EC_BOARD}/hibernate.c"
- "${PLATFORM_EC_BOARD}/switchcap.c"
- "${PLATFORM_EC_BOARD}/usbc_config.c")
-
-# Board specific implementation
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C
- "src/i2c.c")
diff --git a/zephyr/projects/trogdor/trogdor/battery.dts b/zephyr/projects/trogdor/trogdor/battery.dts
deleted file mode 100644
index ab4b28999a..0000000000
--- a/zephyr/projects/trogdor/trogdor/battery.dts
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- batteries {
- default_battery: ap16l5j {
- compatible = "panasonic,ap16l5j";
- };
- };
-};
diff --git a/zephyr/projects/trogdor/trogdor/gpio.dts b/zephyr/projects/trogdor/trogdor/gpio.dts
deleted file mode 100644
index 956db72960..0000000000
--- a/zephyr/projects/trogdor/trogdor/gpio.dts
+++ /dev/null
@@ -1,370 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-gpios {
- compatible = "named-gpios";
-
- usb_c0_pd_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PD_INT_ODL";
- label = "USB_C0_PD_INT_ODL";
- };
- usb_c1_pd_int_odl {
- gpios = <&gpiof 5 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_PD_INT_ODL";
- label = "USB_C1_PD_INT_ODL";
- };
- usb_c0_swctl_int_odl {
- gpios = <&gpio0 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_SWCTL_INT_ODL";
- label = "USB_C0_SWCTL_INT_ODL";
- };
- usb_c1_swctl_int_odl {
- gpios = <&gpio4 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_SWCTL_INT_ODL";
- label = "USB_C1_SWCTL_INT_ODL";
- };
- usb_c0_bc12_int_l {
- gpios = <&gpio6 1 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_USB_C0_BC12_INT_L";
- label = "USB_C0_BC12_INT_L";
- };
- usb_c1_bc12_int_l {
- gpios = <&gpio8 2 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_USB_C1_BC12_INT_L";
- label = "USB_C1_BC12_INT_L";
- };
- usb_a0_oc_odl {
- gpios = <&gpiod 1 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_USB_A0_OC_ODL";
- label = "USB_A0_OC_ODL";
- };
- gpio_chg_acok_od: chg_acok_od {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- label = "CHG_ACOK_OD";
- };
- gpio_ec_pwr_btn_odl: ec_pwr_btn_odl {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- label = "EC_PWR_BTN_ODL";
- };
- ec_voldn_btn_odl {
- gpios = <&gpio7 0 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- label = "EC_VOLDN_BTN_ODL";
- };
- ec_volup_btn_odl {
- gpios = <&gpiof 2 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_VOLUME_UP_L";
- label = "EC_VOLUP_BTN_ODL";
- };
- ec_wp_odl {
- gpios = <&gpioa 1 GPIO_INPUT>;
- enum-name = "GPIO_WP_L";
- label = "EC_WP_ODL";
- };
- gpio_lid_open_ec: lid_open_ec {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- label = "LID_OPEN_EC";
- };
- ap_rst_l {
- gpios = <&gpioc 1 GPIO_INPUT>;
- enum-name = "GPIO_AP_RST_L";
- label = "AP_RST_L";
- };
- ps_hold {
- gpios = <&gpioa 4 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- enum-name = "GPIO_PS_HOLD";
- label = "PS_HOLD";
- };
- ap_suspend {
- gpios = <&gpio5 7 GPIO_INPUT>;
- enum-name = "GPIO_AP_SUSPEND";
- label = "AP_SUSPEND";
- };
- deprecated_ap_rst_req {
- gpios = <&gpioc 2 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- enum-name = "GPIO_DEPRECATED_AP_RST_REQ";
- label = "DEPRECATED_AP_RST_REQ";
- };
- power_good {
- gpios = <&gpio5 4 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- enum-name = "GPIO_POWER_GOOD";
- label = "POWER_GOOD";
- };
- warm_reset_l {
- gpios = <&gpiof 4 GPIO_INPUT>;
- enum-name = "GPIO_WARM_RESET_L";
- label = "WARM_RESET_L";
- };
- ap_ec_spi_cs_l {
- gpios = <&gpio5 3 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "AP_EC_SPI_CS_L";
- };
- tablet_mode_l {
- gpios = <&gpioc 6 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- label = "TABLET_MODE_L";
- };
- gpio_accel_gyro_int_l: accel_gyro_int_l {
- gpios = <&gpioa 0 GPIO_INPUT>;
- enum-name = "GPIO_ACCEL_GYRO_INT_L";
- label = "ACCEL_GYRO_INT_L";
- };
- gpio_ec_rst_odl: ec_rst_odl {
- gpios = <&gpio0 2 GPIO_INPUT>;
- enum-name = "GPIO_EC_RST_ODL";
- label = "EC_RST_ODL";
- };
- ec_entering_rw {
- gpios = <&gpioe 1 GPIO_OUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- label = "EC_ENTERING_RW";
- };
- ccd_mode_odl {
- gpios = <&gpioe 3 GPIO_INPUT>;
- enum-name = "GPIO_CCD_MODE_ODL";
- label = "CCD_MODE_ODL";
- };
- ec_batt_pres_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- label = "EC_BATT_PRES_ODL";
- };
- pmic_resin_l {
- gpios = <&gpio3 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_RESIN_L";
- label = "PMIC_RESIN_L";
- };
- pmic_kpd_pwr_odl {
- gpios = <&gpiod 6 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PMIC_KPD_PWR_ODL";
- label = "PMIC_KPD_PWR_ODL";
- };
- ec_int_l {
- gpios = <&gpioa 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- label = "EC_INT_L";
- };
- hibernate_l {
- gpios = <&gpio5 2 GPIO_ODR_HIGH>;
- enum-name = "GPIO_HIBERNATE_L";
- label = "HIBERNATE_L";
- };
- switchcap_on {
- gpios = <&gpiod 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_SWITCHCAP_ON";
- label = "SWITCHCAP_ON";
- };
- en_pp3300_a {
- gpios = <&gpioa 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP3300_A";
- label = "EN_PP3300_A";
- };
- en_pp5000_a {
- gpios = <&gpio6 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP5000";
- label = "EN_PP5000_A";
- };
- ec_bl_disable_l {
- gpios = <&gpiob 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- label = "EC_BL_DISABLE_L";
- };
- lid_accel_int_l {
- gpios = <&gpio5 6 GPIO_INPUT>;
- enum-name = "GPIO_LID_ACCEL_INT_L";
- label = "LID_ACCEL_INT_L";
- };
- trackpad_int_gate {
- gpios = <&gpio7 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_TRACKPAD_INT_GATE";
- label = "TRACKPAD_INT_GATE";
- };
- usb_c0_pd_rst_l {
- gpios = <&gpiof 1 GPIO_OUT_HIGH>;
- enum-name = "GPIO_USB_C0_PD_RST_L";
- label = "USB_C0_PD_RST_L";
- };
- usb_c1_pd_rst_l {
- gpios = <&gpioe 4 GPIO_OUT_HIGH>;
- enum-name = "GPIO_USB_C1_PD_RST_L";
- label = "USB_C1_PD_RST_L";
- };
- dp_mux_oe_l {
- gpios = <&gpio9 6 GPIO_ODR_HIGH>;
- enum-name = "GPIO_DP_MUX_OE_L";
- label = "DP_MUX_OE_L";
- };
- dp_mux_sel {
- gpios = <&gpio4 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_DP_MUX_SEL";
- label = "DP_MUX_SEL";
- };
- dp_hot_plug_det {
- gpios = <&gpio9 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_DP_HOT_PLUG_DET";
- label = "DP_HOT_PLUG_DET";
- };
- en_usb_a_5v {
- gpios = <&gpio8 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_USB_A_5V";
- label = "EN_USB_A_5V";
- };
- usb_a_cdp_ilim_en_l {
- gpios = <&gpio7 5 GPIO_OUT_HIGH>;
- label = "USB_A_CDP_ILIM_EN_L";
- };
- ec_chg_led_y_c0 {
- gpios = <&gpio6 0 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_CHG_LED_Y_C0";
- label = "EC_CHG_LED_Y_C0";
- };
- ec_chg_led_w_c0 {
- gpios = <&gpioc 0 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_CHG_LED_W_C0";
- label = "EC_CHG_LED_W_C0";
- };
- ec_chg_led_y_c1 {
- gpios = <&gpioc 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_CHG_LED_Y_C1";
- label = "EC_CHG_LED_Y_C1";
- };
- ec_chg_led_w_c1 {
- gpios = <&gpioc 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_CHG_LED_W_C1";
- label = "EC_CHG_LED_W_C1";
- };
- ap_ec_spi_mosi {
- gpios = <&gpio4 6 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "AP_EC_SPI_MOSI";
- };
- ap_ec_spi_miso {
- gpios = <&gpio4 7 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "AP_EC_SPI_MISO";
- };
- ap_ec_spi_clk {
- gpios = <&gpio5 5 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- label = "AP_EC_SPI_CLK";
- };
- kb_bl_pwm {
- gpios = <&gpio8 0 GPIO_INPUT>;
- label = "KB_BL_PWM";
- };
- edp_bkltctl {
- gpios = <&gpiob 7 GPIO_INPUT>;
- label = "EDP_BKLTCTL";
- };
- ppvar_boostin_sense {
- gpios = <&gpio4 4 GPIO_INPUT>;
- label = "PPVAR_BOOSTIN_SENSE";
- };
- charger_iadp {
- gpios = <&gpio4 3 GPIO_INPUT>;
- label = "CHARGER_IADP";
- };
- charger_pmon {
- gpios = <&gpio4 2 GPIO_INPUT>;
- label = "CHARGER_PMON";
- };
- brd_id0 {
- gpios = <&gpioc 7 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION1";
- label = "BRD_ID0";
- };
- brd_id1 {
- gpios = <&gpio9 3 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION2";
- label = "BRD_ID1";
- };
- brd_id2 {
- gpios = <&gpio6 3 GPIO_INPUT>;
- enum-name = "GPIO_BOARD_VERSION3";
- label = "BRD_ID2";
- };
- sku_id0 {
- gpios = <&gpiof 0 GPIO_INPUT>;
- enum-name = "GPIO_SKU_ID0";
- label = "SKU_ID0";
- };
- sku_id1 {
- gpios = <&gpio4 1 GPIO_INPUT>;
- enum-name = "GPIO_SKU_ID1";
- label = "SKU_ID1";
- };
- sku_id2 {
- gpios = <&gpiod 4 GPIO_INPUT>;
- enum-name = "GPIO_SKU_ID2";
- label = "SKU_ID2";
- };
- switchcap_gpio_1 {
- gpios = <&gpioe 2 (GPIO_INPUT | GPIO_PULL_DOWN)>;
- enum-name = "GPIO_SWITCHCAP_PG";
- label = "SWITCHCAP_GPIO_1";
- };
- arm_x86 {
- gpios = <&gpio6 6 GPIO_OUT_LOW>;
- label = "ARM_X86";
- };
- ec_kso_02_inv {
- gpios = <&gpio1 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_KBD_KSO2";
- label = "EC_KSO_02_INV";
- };
- };
-
- def-lvol-io-list {
- compatible = "nuvoton,npcx-lvolctrl-def";
- lvol-io-pads = <
- &lvol_ioc1 /* AP_RST_L */
- &lvol_ioc2 /* DEPRECATED_AP_RST_REQ */
- &lvol_iof4 /* WARM_RESET_L */
- &lvol_iob3 /* EC_I2C_SENSOR_SCL */
- &lvol_iob2 /* EC_I2C_SENSOR_SDA */
- >;
- };
-
- hibernate-wake-pins {
- compatible = "cros-ec,hibernate-wake-pins";
- wakeup-pins = <
- &gpio_chg_acok_od
- &gpio_ec_pwr_btn_odl
- &gpio_lid_open_ec
- &gpio_ec_rst_odl
- >;
- };
-
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios =
- <&gpio5 1 0>,
- <&gpiod 0 0>,
- <&gpiof 3 0>,
- <&gpio9 4 0>,
- <&gpio9 7 0>,
- <&gpioa 7 0>,
- <&gpiob 0 0>,
- <&gpioa 5 0>,
- <&gpio3 5 0>,
- <&gpio7 2 0>,
- <&gpio8 1 0>,
- <&gpio3 7 0>,
- <&gpio7 6 0>,
- <&gpio3 4 0>,
- <&gpioc 5 0>,
- <&gpio7 3 0>,
- <&gpiod 7 0>,
- <&gpioa 3 0>,
- <&gpio6 2 0>,
- <&gpio0 4 0>,
- <&gpio8 3 0>,
- <&gpiob 1 0>,
- <&gpio5 0 0>,
- <&gpiod 3 0>;
- };
-};
diff --git a/zephyr/projects/trogdor/trogdor/include/gpio_map.h b/zephyr/projects/trogdor/trogdor/include/gpio_map.h
deleted file mode 100644
index df4dcb0e25..0000000000
--- a/zephyr/projects/trogdor/trogdor/include/gpio_map.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-#ifdef CONFIG_PLATFORM_EC_GMR_TABLET_MODE
-#define GMR_TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L
-#endif
-
-/*
- * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items.
- *
- * Each GPIO_INT requires three parameters:
- * gpio_signal - The enum gpio_signal for the interrupt gpio
- * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH)
- * handler - The platform/ec interrupt handler.
- *
- * Ensure that this files includes all necessary headers to declare all
- * referenced handler functions.
- *
- * For example, one could use the follow definition:
- * #define EC_CROS_GPIO_INTERRUPTS \
- * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print)
- */
-#define EC_CROS_GPIO_INTERRUPTS \
- GPIO_INT(GPIO_AC_PRESENT, GPIO_INT_EDGE_BOTH, extpower_interrupt) \
- GPIO_INT(GPIO_LID_OPEN, GPIO_INT_EDGE_BOTH, lid_interrupt) \
- GPIO_INT(GPIO_WP_L, GPIO_INT_EDGE_BOTH, switch_interrupt) \
- GPIO_INT(GPIO_POWER_BUTTON_L, GPIO_INT_EDGE_BOTH, \
- power_button_interrupt) \
- GPIO_INT(GPIO_VOLUME_DOWN_L, GPIO_INT_EDGE_BOTH, button_interrupt) \
- GPIO_INT(GPIO_VOLUME_UP_L, GPIO_INT_EDGE_BOTH, button_interrupt) \
- GPIO_INT(GPIO_AP_RST_L, GPIO_INT_EDGE_BOTH, chipset_ap_rst_interrupt) \
- GPIO_INT(GPIO_AP_SUSPEND, GPIO_INT_EDGE_BOTH, power_signal_interrupt) \
- GPIO_INT(GPIO_DEPRECATED_AP_RST_REQ, GPIO_INT_EDGE_BOTH, \
- power_signal_interrupt) \
- GPIO_INT(GPIO_POWER_GOOD, GPIO_INT_EDGE_BOTH, \
- chipset_power_good_interrupt) \
- GPIO_INT(GPIO_PS_HOLD, GPIO_INT_EDGE_BOTH, power_signal_interrupt) \
- GPIO_INT(GPIO_WARM_RESET_L, GPIO_INT_EDGE_BOTH, \
- chipset_warm_reset_interrupt) \
- GPIO_INT(GPIO_USB_C0_PD_INT_ODL, GPIO_INT_EDGE_FALLING, \
- tcpc_alert_event) \
- GPIO_INT(GPIO_USB_C1_PD_INT_ODL, GPIO_INT_EDGE_FALLING, \
- tcpc_alert_event) \
- GPIO_INT(GPIO_USB_C0_SWCTL_INT_ODL, GPIO_INT_EDGE_FALLING, \
- ppc_interrupt) \
- GPIO_INT(GPIO_USB_C1_SWCTL_INT_ODL, GPIO_INT_EDGE_FALLING, \
- ppc_interrupt) \
- GPIO_INT(GPIO_USB_C0_BC12_INT_L, GPIO_INT_EDGE_FALLING, usb0_evt) \
- GPIO_INT(GPIO_USB_C1_BC12_INT_L, GPIO_INT_EDGE_FALLING, usb1_evt) \
- GPIO_INT(GPIO_USB_A0_OC_ODL, GPIO_INT_EDGE_BOTH, usba_oc_interrupt) \
- GPIO_INT(GPIO_ACCEL_GYRO_INT_L, GPIO_INT_EDGE_FALLING, \
- bmi160_interrupt) \
- GPIO_INT(GPIO_TABLET_MODE_L, GPIO_INT_EDGE_BOTH, gmr_tablet_switch_isr)
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
diff --git a/zephyr/projects/trogdor/trogdor/include/pwm_map.h b/zephyr/projects/trogdor/trogdor/include/pwm_map.h
deleted file mode 100644
index e704b6d6d3..0000000000
--- a/zephyr/projects/trogdor/trogdor/include/pwm_map.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_PWM_MAP_H
-#define __ZEPHYR_PWM_MAP_H
-
-#include <devicetree.h>
-
-#include "pwm/pwm.h"
-
-#define PWM_CH_KBLIGHT NAMED_PWM(kblight)
-#define PWM_CH_DISPLIGHT NAMED_PWM(displight)
-
-#endif /* __ZEPHYR_PWM_MAP_H */
diff --git a/zephyr/projects/trogdor/trogdor/motionsense.dts b/zephyr/projects/trogdor/trogdor/motionsense.dts
deleted file mode 100644
index 1f222c8f18..0000000000
--- a/zephyr/projects/trogdor/trogdor/motionsense.dts
+++ /dev/null
@@ -1,157 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#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.
- */
- bmi160-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 {
- label = "LID_MUTEX";
- };
-
- mutex_bmi160: bmi160-mutex {
- label = "BMI160_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 {
- bma255_data: bma255-drv-data {
- compatible = "cros-ec,drvdata-bma255";
- status = "okay";
- };
-
- bmi160_data: bmi160-drv-data {
- compatible = "cros-ec,drvdata-bmi160";
- status = "okay";
- };
- };
-
- /*
- * List of motion sensors that creates motion_sensors array.
- * The label "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,bma255";
- status = "okay";
-
- label = "Lid Accel";
- 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 = <&bma255_data>;
- i2c-spi-addr-flags = "BMA2x2_I2C_ADDR1_FLAGS";
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_accel: base-accel {
- compatible = "cros-ec,bmi160-accel";
- status = "okay";
-
- label = "Base Accel";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi160>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&bmi160_data>;
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base-gyro {
- compatible = "cros-ec,bmi160-gyro";
- status = "okay";
-
- label = "Base Gyro";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi160>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- drv-data = <&bmi160_data>;
- };
- };
-
- motionsense-sensor-info {
- compatible = "cros-ec,motionsense-sensor-info";
-
- /*
- * list of GPIO interrupts that have to
- * be enabled at initial stage
- */
- sensor-irqs = <&gpio_accel_gyro_int_l>;
- /* list of sensors in force mode */
- accel-force-mode-sensors = <&lid_accel>;
- };
-};
diff --git a/zephyr/projects/trogdor/trogdor/prj.conf b/zephyr/projects/trogdor/trogdor/prj.conf
deleted file mode 100644
index 59d87f54a1..0000000000
--- a/zephyr/projects/trogdor/trogdor/prj.conf
+++ /dev/null
@@ -1,152 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-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_I2C=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_COMMON=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-CONFIG_PLATFORM_EC_PWM=y
-CONFIG_PLATFORM_EC_PWM_DISPLIGHT=y
-CONFIG_PLATFORM_EC_PWM_KBLIGHT=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
-
-# 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 mask
-CONFIG_PLATFORM_EC_MKBP_EVENT_WAKEUP_MASK=y
-CONFIG_PLATFORM_EC_MKBP_HOST_EVENT_WAKEUP_MASK=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_VOLUME_BUTTONS=y
-CONFIG_PLATFORM_EC_CMD_BUTTON=y
-CONFIG_CROS_KB_RAW_NPCX=y
-
-# ADC
-CONFIG_PLATFORM_EC_ADC=y
-CONFIG_ADC=y
-CONFIG_ADC_SHELL=n
-
-# Battery
-CONFIG_HAS_TASK_USB_CHG_P1=y
-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_USB_A_PORT_COUNT=1
-
-# 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_PORT_MAX_COUNT=2
-CONFIG_PLATFORM_EC_USB_PD_REV30=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_PD_LOGGING=y
-CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB=y
-CONFIG_HAS_TASK_PD_C1=y
-CONFIG_HAS_TASK_PD_INT_C1=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
-
-# Serial Host Interface (SHI) device.
-CONFIG_CROS_SHI_NPCX=y
-
-# Sensors
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_ACCEL_INTERRUPTS=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
-
-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/trogdor/src/i2c.c b/zephyr/projects/trogdor/trogdor/src/i2c.c
deleted file mode 100644
index bd5fe82473..0000000000
--- a/zephyr/projects/trogdor/trogdor/src/i2c.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "i2c/i2c.h"
-#include "i2c.h"
-
-/* Trogdor board specific i2c implementation */
-
-#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
-int board_allow_i2c_passthru(int port)
-{
- return (i2c_get_device_for_port(port) ==
- i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY));
-}
-#endif
diff --git a/zephyr/projects/trogdor/trogdor/zmake.yaml b/zephyr/projects/trogdor/trogdor/zmake.yaml
deleted file mode 100644
index ef0e8a178e..0000000000
--- a/zephyr/projects/trogdor/trogdor/zmake.yaml
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: trogdor
-dts-overlays:
- - gpio.dts
- - battery.dts
- - motionsense.dts
-supported-toolchains:
- - coreboot-sdk
- - zephyr
-supported-zephyr-versions:
- - v2.6
-output-type: npcx
diff --git a/zephyr/projects/volteer/delbin/CMakeLists.txt b/zephyr/projects/volteer/delbin/CMakeLists.txt
deleted file mode 100644
index 0303ee7c62..0000000000
--- a/zephyr/projects/volteer/delbin/CMakeLists.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(delbin)
-
-set(PLATFORM_EC_BOARD "${PLATFORM_EC}/board/delbin" CACHE PATH
- "Path to the platform/ec board directory")
-set(PLATFORM_EC_BASEBOARD "${PLATFORM_EC}/baseboard/volteer" CACHE PATH
- "Path to the platform/ec baseboard directory")
-
-# Include board specific header files
-zephyr_library_include_directories(
- include
- "${PLATFORM_EC_BASEBOARD}"
- "${PLATFORM_EC_BOARD}")
-
-# Include selected EC source for the baseboard
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ
- "${PLATFORM_EC_BASEBOARD}/power.c")
diff --git a/zephyr/projects/volteer/delbin/gpio.dts b/zephyr/projects/volteer/delbin/gpio.dts
deleted file mode 100644
index 7d7a89d4f2..0000000000
--- a/zephyr/projects/volteer/delbin/gpio.dts
+++ /dev/null
@@ -1,349 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-gpios {
- compatible = "named-gpios";
-
- ec_lid_open {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- label = "EC_LID_OPEN";
- };
- ec_wp_l {
- gpios = <&gpioa 1 GPIO_INPUT>;
- enum-name = "GPIO_WP_L";
- label = "EC_WP_L";
- };
- h1_ec_pwr_btn_odl {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- label = "H1_EC_PWR_BTN_ODL";
- };
- acok_od {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- label = "ACOK_OD";
- };
- slp_s0_l {
- gpios = <&gpiod 5 GPIO_INPUT>;
- enum-name = "GPIO_PCH_SLP_S0_L";
- label = "SLP_S0_L";
- };
- slp_s3_l {
- gpios = <&gpioa 5 GPIO_INPUT>;
- enum-name = "GPIO_PCH_SLP_S3_L";
- label = "SLP_S3_L";
- };
- slp_sus_l {
- gpios = <&gpiod 7 GPIO_INPUT>;
- enum-name = "GPIO_SLP_SUS_L";
- label = "SLP_SUS_L";
- };
- pg_ec_rsmrst_odl {
- gpios = <&gpioe 2 GPIO_INPUT>;
- enum-name = "GPIO_PG_EC_RSMRST_ODL";
- label = "PG_EC_RSMRST_ODL";
- };
- rsmrst_l_pgood {
- gpios = <&gpioe 2 GPIO_INPUT>;
- enum-name = "GPIO_RSMRST_L_PGOOD";
- label = "RSMRST_L_PGOOD";
- };
- dsw_pwrok {
- gpios = <&gpioc 7 GPIO_INPUT>;
- enum-name = "GPIO_PG_EC_DSW_PWROK";
- label = "DSW_PWROK";
- };
- pg_ec_all_sys_pwrgd {
- gpios = <&gpiof 4 GPIO_INPUT>;
- enum-name = "GPIO_PG_EC_ALL_SYS_PWRGD";
- label = "PG_EC_ALL_SYS_PWRGD";
- };
- gpio_ec_imu_int_l: ec_imu_int_l {
- gpios = <&gpio5 6 GPIO_INPUT>;
- enum-name = "GPIO_EC_IMU_INT_L";
- label = "EC_IMU_INT_L";
- };
- tablet_mode_l {
- gpios = <&gpio9 5 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- label = "TABLET_MODE_L";
- };
- ec_accel_int {
- gpios = <&gpio8 1 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_ACCEL_INT";
- };
- usb_c0_tcpc_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- label = "USB_C0_TCPC_INT_ODL";
- };
- usb_c1_tcpc_int_odl {
- gpios = <&gpioa 2 GPIO_INPUT>;
- label = "USB_C1_TCPC_INT_ODL";
- };
- usb_c0_ppc_int_odl {
- gpios = <&gpio6 2 GPIO_INPUT>;
- label = "USB_C0_PPC_INT_ODL";
- };
- usb_c1_ppc_int_odl {
- gpios = <&gpiof 5 GPIO_INPUT>;
- label = "USB_C1_PPC_INT_ODL";
- };
- usb_c0_bc12_int_odl {
- gpios = <&gpioe 4 GPIO_INPUT>;
- label = "USB_C0_BC12_INT_ODL";
- };
- usb_c1_mix_int_odl {
- gpios = <&gpio0 3 GPIO_INPUT>;
- label = "USB_C1_MIX_INT_ODL";
- };
- ec_voldn_btn_odl {
- gpios = <&gpio9 3 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_VOLDN_BTN_ODL";
- };
- ec_volup_btn_odl {
- gpios = <&gpio9 7 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_VOLUP_BTN_ODL";
- };
- en_pp3300_a {
- gpios = <&gpioa 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP3300_A";
- label = "EN_PP3300_A";
- };
- en_pp5000_a {
- gpios = <&gpioa 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP5000";
- label = "EN_PP5000_A";
- };
- en_ppvar_vccin {
- gpios = <&gpio4 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PPVAR_VCCIN";
- label = "EN_PPVAR_VCCIN";
- };
- ec_rst_odl {
- gpios = <&gpio0 2 GPIO_INPUT>;
- label = "EC_RST_ODL";
- };
- ec_pch_sys_pwrok {
- gpios = <&gpio3 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_PCH_SYS_PWROK";
- label = "EC_PCH_SYS_PWROK";
- };
- ec_pch_rsmrst_odl {
- gpios = <&gpioa 6 GPIO_ODR_LOW>;
- enum-name = "GPIO_PCH_RSMRST_L";
- label = "EC_PCH_RSMRST_ODL";
- };
- ec_pch_pwr_btn_odl {
- gpios = <&gpioc 1 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PCH_PWRBTN_L";
- label = "EC_PCH_PWR_BTN_ODL";
- };
- ec_pch_rtcrst {
- gpios = <&gpio7 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_PCH_RTCRST";
- label = "EC_PCH_RTCRST";
- };
- ec_pch_wake_odl {
- gpios = <&gpio7 4 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_PCH_WAKE_ODL";
- label = "EC_PCH_WAKE_ODL";
- };
- ec_entering_rw {
- gpios = <&gpioe 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- label = "EC_ENTERING_RW";
- };
- ec_prochot_odl {
- gpios = <&gpio6 3 GPIO_ODR_HIGH>;
- enum-name = "GPIO_CPU_PROCHOT";
- label = "EC_PROCHOT_ODL";
- };
- ec_prochot_in_l {
- gpios = <&gpiof 0 GPIO_INPUT>;
- enum-name = "GPIO_EC_PROCHOT_IN_L";
- label = "EC_PROCHOT_IN_L";
- };
- sys_rst_odl {
- gpios = <&gpioc 5 GPIO_ODR_HIGH>;
- enum-name = "GPIO_SYS_RESET_L";
- label = "SYS_RST_ODL";
- };
- ec_pch_int_odl {
- gpios = <&gpiob 0 GPIO_ODR_HIGH>;
- label = "EC_PCH_INT_ODL";
- };
- en_pp5000_usba {
- gpios = <&gpioc 6 GPIO_OUT_LOW>;
- label = "EN_PP5000_USBA";
- };
- usb_a_low_pwr_od {
- gpios = <&gpio6 6 GPIO_ODR_LOW>;
- label = "USB_A_LOW_PWR_OD";
- };
- usb_c0_rt_rst_odl {
- gpios = <&gpiod 4 GPIO_ODR_LOW>;
- label = "USB_C0_RT_RST_ODL";
- };
- usb_c1_rt_rst_odl {
- gpios = <&gpio8 3 GPIO_ODR_LOW>;
- label = "USB_C1_RT_RST_ODL";
- };
- usb_c0_oc_odl {
- gpios = <&gpiob 1 GPIO_ODR_HIGH>;
- label = "USB_C0_OC_ODL";
- };
- usb_c1_oc_odl {
- gpios = <&gpio5 0 GPIO_ODR_HIGH>;
- label = "USB_C1_OC_ODL";
- };
- uart2_ec_rx {
- gpios = <&gpio7 5 GPIO_OUT_LOW>;
- label = "UART2_EC_RX";
- };
- led_1_l {
- gpios = <&gpioc 4 GPIO_OUT_HIGH>;
- label = "LED_1_L";
- };
- led_2_l {
- gpios = <&gpioc 3 GPIO_OUT_HIGH>;
- label = "LED_2_L";
- };
- led_3_l {
- gpios = <&gpioc 2 GPIO_OUT_HIGH>;
- label = "LED_3_L";
- };
- ccd_mode_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- label = "CCD_MODE_ODL";
- };
- ec_kb_bl_en {
- gpios = <&gpio8 6 GPIO_OUT_LOW>;
- label = "EC_KB_BL_EN";
- };
- unused_gpio34 {
- gpios = <&gpio3 4 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "UNUSED_GPIO34";
- };
- unused_gpio41 {
- gpios = <&gpio4 1 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "UNUSED_GPIO41";
- };
- unused_gpio72 {
- gpios = <&gpio7 2 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "UNUSED_GPIO72";
- };
- unused_gpio96 {
- gpios = <&gpio9 6 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "UNUSED_GPIO96";
- };
- unused_gpioa7 {
- gpios = <&gpioa 7 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "UNUSED_GPIOA7";
- };
- unused_gpioc0 {
- gpios = <&gpioc 0 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "UNUSED_GPIOC0";
- };
- unused_gpiof2 {
- gpios = <&gpiof 2 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "UNUSED_GPIOF2";
- };
- ec_edp_bl_en {
- gpios = <&gpiod 3 GPIO_OUT_HIGH>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- label = "EC_EDP_BL_EN";
- };
- ec_i2c0_sensor_scl {
- gpios = <&gpiob 5 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C0_SENSOR_SCL";
- label = "EC_I2C0_SENSOR_SCL";
- };
- ec_i2c0_sensor_sda {
- gpios = <&gpiob 4 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C0_SENSOR_SDA";
- label = "EC_I2C0_SENSOR_SDA";
- };
- ec_i2c1_usb_c0_scl {
- gpios = <&gpio9 0 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C1_USB_C0_SCL";
- label = "EC_I2C1_USB_C0_SCL";
- };
- ec_i2c1_usb_c0_sda {
- gpios = <&gpio8 7 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C1_USB_C0_SDA";
- label = "EC_I2C1_USB_C0_SDA";
- };
- ec_i2c2_usb_c1_scl {
- gpios = <&gpio9 2 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C2_USB_C1_SCL";
- label = "EC_I2C2_USB_C1_SCL";
- };
- ec_i2c2_usb_c1_sda {
- gpios = <&gpio9 1 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C2_USB_C1_SDA";
- label = "EC_I2C2_USB_C1_SDA";
- };
- ec_i2c3_usb_1_mix_scl {
- gpios = <&gpiod 1 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C3_USB_1_MIX_SCL";
- label = "EC_I2C3_USB_1_MIX_SCL";
- };
- ec_i2c3_usb_1_mix_sda {
- gpios = <&gpiod 0 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C3_USB_1_MIX_SDA";
- label = "EC_I2C3_USB_1_MIX_SDA";
- };
- ec_i2c5_power_scl {
- gpios = <&gpio3 3 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C5_BATTERY_SCL";
- label = "EC_I2C5_POWER_SCL";
- };
- ec_i2c5_power_sda {
- gpios = <&gpio3 6 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C5_BATTERY_SDA";
- label = "EC_I2C5_POWER_SDA";
- };
- ec_i2c7_eeprom_scl {
- gpios = <&gpiob 3 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C7_EEPROM_PWR_SCL_R";
- label = "EC_I2C7_EEPROM_SCL";
- };
- ec_i2c7_eeprom_sda {
- gpios = <&gpiob 2 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C7_EEPROM_PWR_SDA_R";
- label = "EC_I2C7_EEPROM_SDA";
- };
- ec_batt_pres_odl {
- gpios = <&gpioe 1 GPIO_INPUT>;
- label = "EC_BATT_PRES_ODL";
- };
- usb_c0_dp_hpd {
- gpios = <&gpiof 3 GPIO_INPUT>;
- label = "USB_C0_DP_HPD";
- };
- usb_c1_dp_hpd {
- gpios = <&gpio7 0 GPIO_INPUT>;
- label = "USB_C1_DP_HPD";
- };
- en_pp5000_fan {
- gpios = <&gpio6 1 GPIO_OUT_LOW>;
- label = "EN_PP5000_FAN";
- };
- ec_kso_02_inv {
- gpios = <&gpio1 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_KBD_KSO2";
- label = "EC_KSO_02_INV";
- };
- };
-
- def-lvol-io-list {
- compatible = "nuvoton,npcx-lvolctrl-def";
-
- /* I2C_SDA0 & SCL0 */
- lvol-io-pads = <&lvol_iob4 &lvol_iob5>;
- };
-};
diff --git a/zephyr/projects/volteer/delbin/include/gpio_map.h b/zephyr/projects/volteer/delbin/include/gpio_map.h
deleted file mode 100644
index 1f4b4e1ee0..0000000000
--- a/zephyr/projects/volteer/delbin/include/gpio_map.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-#define GPIO_PCH_DSW_PWROK GPIO_UNIMPLEMENTED
-#define GPIO_USB_C1_LS_EN GPIO_UNIMPLEMENTED
-
-#ifdef CONFIG_PLATFORM_EC_POWERSEQ
-#define POWER_SIGNAL_INT(gpio, edge) \
- GPIO_INT(gpio, edge, power_signal_interrupt)
-#define AP_PROCHOT_INT(gpio, edge) \
- GPIO_INT(gpio, edge, throttle_ap_prochot_input_interrupt)
-#else
-#define POWER_SIGNAL_INT(gpio, edge)
-#define AP_PROCHOT_INT(gpio, edge)
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI260
-#define BMI260_INT(gpio, edge) GPIO_INT(gpio, edge, bmi260_interrupt)
-#else
-#define BMI260_INT(gpio, edge)
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_GMR_TABLET_MODE
-#define GMR_TABLET_MODE_INT(gpio, edge) GPIO_INT(gpio, edge, \
- gmr_tablet_switch_isr)
-#define GMR_TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L
-#else
-#define GMR_TABLET_MODE_INT(gpio, edge)
-#endif
-
-/*
- * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items.
- *
- * Each GPIO_INT requires three parameters:
- * gpio_signal - The enum gpio_signal for the interrupt gpio
- * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH)
- * handler - The platform/ec interrupt handler.
- *
- * Ensure that this files includes all necessary headers to declare all
- * referenced handler functions.
- *
- * For example, one could use the follow definition:
- * #define EC_CROS_GPIO_INTERRUPTS \
- * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print)
- */
-#define EC_CROS_GPIO_INTERRUPTS \
- BMI260_INT(GPIO_EC_IMU_INT_L, GPIO_INT_EDGE_FALLING) \
- GMR_TABLET_MODE_INT(GPIO_TABLET_MODE_L, GPIO_INT_EDGE_BOTH) \
- GPIO_INT(GPIO_AC_PRESENT, GPIO_INT_EDGE_BOTH, extpower_interrupt) \
- GPIO_INT(GPIO_LID_OPEN, GPIO_INT_EDGE_BOTH, lid_interrupt) \
- GPIO_INT(GPIO_POWER_BUTTON_L, GPIO_INT_EDGE_BOTH, \
- power_button_interrupt) \
- GPIO_INT(GPIO_WP_L, GPIO_INT_EDGE_BOTH, switch_interrupt) \
- POWER_SIGNAL_INT(GPIO_PCH_SLP_S0_L, GPIO_INT_EDGE_BOTH) \
- POWER_SIGNAL_INT(GPIO_PCH_SLP_S3_L, GPIO_INT_EDGE_BOTH) \
- POWER_SIGNAL_INT(GPIO_PG_EC_DSW_PWROK, GPIO_INT_EDGE_BOTH) \
- POWER_SIGNAL_INT(GPIO_PG_EC_RSMRST_ODL, GPIO_INT_EDGE_BOTH) \
- POWER_SIGNAL_INT(GPIO_PG_EC_ALL_SYS_PWRGD, GPIO_INT_EDGE_BOTH) \
- POWER_SIGNAL_INT(GPIO_SLP_SUS_L, GPIO_INT_EDGE_BOTH) \
- AP_PROCHOT_INT(GPIO_EC_PROCHOT_IN_L, GPIO_INT_EDGE_BOTH)
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
diff --git a/zephyr/projects/volteer/delbin/motionsense.dts b/zephyr/projects/volteer/delbin/motionsense.dts
deleted file mode 100644
index badc21a5e7..0000000000
--- a/zephyr/projects/volteer/delbin/motionsense.dts
+++ /dev/null
@@ -1,162 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#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.
- */
- bmi260-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";
- mutex_bma255: bma255-mutex {
- label = "BMA255_MUTEX";
- };
-
- mutex_bmi260: bmi260-mutex {
- label = "BMI260_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>;
- };
- };
-
- /*
- * 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 {
- bma255_data: bma255-drv-data {
- compatible = "cros-ec,drvdata-bma255";
- status = "okay";
- };
-
- bmi260_data: bmi260-drv-data {
- compatible = "cros-ec,drvdata-bmi260";
- status = "okay";
- };
- };
-
- /*
- * List of motion sensors that creates motion_sensors array.
- * The label "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,bma255";
- status = "okay";
-
- label = "Lid Accel";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_LID";
- mutex = <&mutex_bma255>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&lid_rot_ref>;
- default-range = <2>;
- drv-data = <&bma255_data>;
- i2c-spi-addr-flags = "BMA2x2_I2C_ADDR1_FLAGS";
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_accel: base-accel {
- compatible = "cros-ec,bmi260-accel";
- status = "okay";
-
- label = "Base Accel";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi260>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- default-range = <4>;
- drv-data = <&bmi260_data>;
- i2c-spi-addr-flags = "BMI260_ADDR0_FLAGS";
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- ec-rate = <(100 * USEC_PER_MSEC)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | ROUND_UP_FLAG)>;
- ec-rate = <(100 * USEC_PER_MSEC)>;
- };
- };
- };
-
- base-gyro {
- compatible = "cros-ec,bmi260-gyro";
- status = "okay";
-
- label = "Base Gyro";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi260>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- default-range = <1000>; /* dps */
- drv-data = <&bmi260_data>;
- i2c-spi-addr-flags = "BMI260_ADDR0_FLAGS";
- };
- };
-
- motionsense-sensor-info {
- compatible = "cros-ec,motionsense-sensor-info";
-
- /*
- * list of GPIO interrupts that have to
- * be enabled at initial stage
- */
- sensor-irqs = <&gpio_ec_imu_int_l>;
- /* list of sensors in force mode */
- accel-force-mode-sensors = <&lid_accel>;
- };
-};
diff --git a/zephyr/projects/volteer/delbin/prj.conf b/zephyr/projects/volteer/delbin/prj.conf
deleted file mode 100644
index 1ef881f686..0000000000
--- a/zephyr/projects/volteer/delbin/prj.conf
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-CONFIG_PLATFORM_EC=y
-CONFIG_SHIMMED_TASKS=y
-CONFIG_I2C=y
-CONFIG_PLATFORM_EC_BRINGUP=y
-
-CONFIG_ARM_MPU=y
-
-CONFIG_PLATFORM_EC_VBOOT_EFS2=n
-
-CONFIG_ESPI=y
-CONFIG_PLATFORM_EC_ESPI_VW_SLP_S4=y
-
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-
-# Power sequencing
-CONFIG_AP=y
-CONFIG_AP_X86_INTEL_TGL=y
-CONFIG_PLATFORM_EC_POWERSEQ=y
-CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET=y
-CONFIG_PLATFORM_EC_THROTTLE_AP=y
-
-# TODO(b/180410072): bringup these features
-CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=n
-CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n
-CONFIG_PLATFORM_EC_VBOOT_HASH=n
-CONFIG_PLATFORM_EC_VSTORE=n
-
-# Sensors
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_ACCEL_INTERRUPTS=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
-
-# 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
diff --git a/zephyr/projects/volteer/delbin/zmake.yaml b/zephyr/projects/volteer/delbin/zmake.yaml
deleted file mode 100644
index dc5217e042..0000000000
--- a/zephyr/projects/volteer/delbin/zmake.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: volteer
-dts-overlays:
- - gpio.dts
- - motionsense.dts
-supported-toolchains:
- - coreboot-sdk
- - zephyr
-supported-zephyr-versions:
- - v2.6
-output-type: npcx
diff --git a/zephyr/projects/volteer/volteer/CMakeLists.txt b/zephyr/projects/volteer/volteer/CMakeLists.txt
deleted file mode 100644
index 8c01874b1b..0000000000
--- a/zephyr/projects/volteer/volteer/CMakeLists.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright 2020 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.
-# SPDX-License-Identifier: Apache-2.0
-
-cmake_minimum_required(VERSION 3.13.1)
-
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(volteer)
-
-set(PLATFORM_EC_BOARD "${PLATFORM_EC}/board/volteer" CACHE PATH
- "Path to the platform/ec board directory")
-set(PLATFORM_EC_BASEBOARD "${PLATFORM_EC}/baseboard/volteer" CACHE PATH
- "Path to the platform/ec baseboard directory")
-
-# Include board specific header files
-zephyr_library_include_directories(
- include
- "${PLATFORM_EC_BASEBOARD}"
- "${PLATFORM_EC_BOARD}")
-
-# Include selected EC source for the baseboard
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY
- "${PLATFORM_EC_BASEBOARD}/battery_presence.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CHARGE_MANAGER
- "${PLATFORM_EC_BASEBOARD}/charger.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM
- "${PLATFORM_EC_BASEBOARD}/cbi.c"
- "${PLATFORM_EC_BASEBOARD}/cbi_ec_fw_config.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_POWERSEQ
- "${PLATFORM_EC_BASEBOARD}/power.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USB_POWER_DELIVERY
- "${PLATFORM_EC_BASEBOARD}/usb_pd_policy.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "${PLATFORM_EC_BASEBOARD}/usbc_config.c")
-
-# Include selected EC source for the board
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY
- "${PLATFORM_EC_BOARD}/battery.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM
- "${PLATFORM_EC_BOARD}/cbi.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON
- "${PLATFORM_EC_BOARD}/led.c")
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC
- "${PLATFORM_EC_BOARD}/usbc_config.c")
diff --git a/zephyr/projects/volteer/volteer/bb_retimer.dts b/zephyr/projects/volteer/volteer/bb_retimer.dts
deleted file mode 100644
index 226356d030..0000000000
--- a/zephyr/projects/volteer/volteer/bb_retimer.dts
+++ /dev/null
@@ -1,18 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-&i2c3_0 {
- status = "okay";
- clock-frequency = <I2C_BITRATE_STANDARD>;
-
- usb_c1_bb_retimer: jhl8040r@40 {
- compatible = "intel,jhl8040r";
- reg = <0x40>;
- label = "USB_C1_BB_RETIMER";
- int-gpios = <&gpio_usb_c1_mix_int_odl>;
- reset-gpios = <&gpio_usb_c1_rt_rst_odl>;
- ls-en-gpios = <&gpio_unused_gpio41>;
- };
-};
diff --git a/zephyr/projects/volteer/volteer/cbi_eeprom.dts b/zephyr/projects/volteer/volteer/cbi_eeprom.dts
deleted file mode 100644
index 65248a5f48..0000000000
--- a/zephyr/projects/volteer/volteer/cbi_eeprom.dts
+++ /dev/null
@@ -1,68 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-&i2c7_0 {
- cbi_eeprom: eeprom@50 {
- compatible = "atmel,at24";
- reg = <0x50>;
- label = "EEPROM_CBI";
- size = <2048>;
- pagesize = <16>;
- address-width = <8>;
- timeout = <5>;
- wp-gpios = <&gpio_ec_wp_l>;
- };
-};
-
-&cbi_ssfc_base_sensor {
- base_sensor_bmi160: bmi160 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
-
- value = <1>;
- };
- base_sensor_icm426xx: icm426xx {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
-
- value = <2>;
- };
- base_sensor_kx022: kx022 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
-
- value = <3>;
- };
-};
-
-&cbi_ssfc_lid_sensor {
- lid_sensor_bma255: bma255 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
-
- value = <1>;
- };
- lid_sensor_kx022: kx022 {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
-
- value = <2>;
- };
-};
-
-&cbi_ssfc_lightbar {
- lightbar_10_led: 10_led {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
-
- value = <1>;
- };
- lightbar_12_led: 12_led {
- compatible = "named-cbi-ssfc-value";
- status = "okay";
-
- value = <2>;
- };
-};
diff --git a/zephyr/projects/volteer/volteer/fan.dts b/zephyr/projects/volteer/volteer/fan.dts
deleted file mode 100644
index e8fcc7194c..0000000000
--- a/zephyr/projects/volteer/volteer/fan.dts
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-fans {
- compatible = "named-fans";
-
- fan_0 {
- label = "FAN_0";
- pwm = <&pwm_fan>;
- rpm_min = <1900>;
- rpm_start = <1900>;
- rpm_max = <5900>;
- tach = <&tach1>;
- enable_gpio = <&gpio_en_pp5000_fan>;
- };
- };
-};
-
-/* Tachemeter for fan speed measurement */
-&tach1 {
- status = "okay";
- pinctrl-0 = <&alt3_ta1_sl1>; /* Use TA1 as input pin */
- port = <NPCX_TACH_PORT_A>; /* port-A is selected */
- sample-clk = <NPCX_TACH_FREQ_LFCLK>; /* Use LFCLK as sampling clock */
- pulses-per-round = <2>; /* number of pulses per round of encoder */
-};
diff --git a/zephyr/projects/volteer/volteer/gpio.dts b/zephyr/projects/volteer/volteer/gpio.dts
deleted file mode 100644
index 4466689481..0000000000
--- a/zephyr/projects/volteer/volteer/gpio.dts
+++ /dev/null
@@ -1,406 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-gpios {
- compatible = "named-gpios";
-
- ec_lid_open {
- gpios = <&gpiod 2 GPIO_INPUT>;
- enum-name = "GPIO_LID_OPEN";
- label = "EC_LID_OPEN";
- };
- gpio_ec_wp_l: ec_wp_l {
- #gpio-cells = <0>;
- gpios = <&gpioa 1 GPIO_INPUT>;
- enum-name = "GPIO_EC_WP_L";
- label = "EC_WP_L";
- };
- wp_l {
- gpios = <&gpioa 1 GPIO_INPUT>;
- enum-name = "GPIO_WP_L";
- label = "WP_L";
- };
- h1_ec_pwr_btn_odl {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_POWER_BUTTON_L";
- label = "H1_EC_PWR_BTN_ODL";
- };
- acok_od {
- gpios = <&gpio0 0 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- label = "ACOK_OD";
- };
- slp_s0_l {
- gpios = <&gpiod 5 GPIO_INPUT>;
- enum-name = "GPIO_PCH_SLP_S0_L";
- label = "SLP_S0_L";
- };
- slp_s3_l {
- gpios = <&gpioa 5 GPIO_INPUT>;
- enum-name = "GPIO_PCH_SLP_S3_L";
- label = "SLP_S3_L";
- };
- pch_slp_sus_l {
- gpios = <&gpiod 7 GPIO_INPUT>;
- enum-name = "GPIO_PCH_SLP_SUS_L";
- label = "PCH_SLP_SUS_L";
- };
- slp_sus_l {
- gpios = <&gpiod 7 GPIO_INPUT>;
- enum-name = "GPIO_SLP_SUS_L";
- label = "SLP_SUS_L";
- };
- pg_ec_rsmrst_odl {
- gpios = <&gpioe 2 GPIO_INPUT>;
- enum-name = "GPIO_PG_EC_RSMRST_ODL";
- label = "PG_EC_RSMRST_ODL";
- };
- rsmrst_l_pgood {
- gpios = <&gpioe 2 GPIO_INPUT>;
- enum-name = "GPIO_RSMRST_L_PGOOD";
- label = "RSMRST_L_PGOOD";
- };
- pg_ec_dsw_pwrok {
- gpios = <&gpioc 7 GPIO_INPUT>;
- enum-name = "GPIO_PG_EC_DSW_PWROK";
- label = "PG_EC_DSW_PWROK";
- };
- pg_ec_all_sys_pwrgd {
- gpios = <&gpiof 4 GPIO_INPUT>;
- enum-name = "GPIO_PG_EC_ALL_SYS_PWRGD";
- label = "PG_EC_ALL_SYS_PWRGD";
- };
- gpio_ec_imu_int_l: ec_imu_int_l {
- gpios = <&gpio5 6 GPIO_INPUT>;
- enum-name = "GPIO_EC_IMU_INT_L";
- label = "EC_IMU_INT_L";
- };
- gpio_ec_als_rgb_int_l: ec_als_rgb_int_l {
- gpios = <&gpiod 4 GPIO_INPUT>;
- enum-name = "GPIO_EC_ALS_RGB_INT_L";
- label = "EC_ALS_RGB_INT_L";
- };
- tablet_mode_l {
- gpios = <&gpio9 5 GPIO_INPUT>;
- enum-name = "GPIO_TABLET_MODE_L";
- label = "TABLET_MODE_L";
- };
- ec_accel_int {
- gpios = <&gpio8 1 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_EC_ACCEL_INT";
- label = "EC_ACCEL_INT";
- };
- usb_c0_tcpc_int_odl {
- gpios = <&gpioe 0 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_TCPC_INT_ODL";
- label = "USB_C0_TCPC_INT_ODL";
- };
- usb_c1_tcpc_int_odl {
- gpios = <&gpioa 2 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_TCPC_INT_ODL";
- label = "USB_C1_TCPC_INT_ODL";
- };
- usb_c0_ppc_int_odl {
- gpios = <&gpio6 2 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_PPC_INT_ODL";
- label = "USB_C0_PPC_INT_ODL";
- };
- usb_c1_ppc_int_odl {
- gpios = <&gpiof 5 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_PPC_INT_ODL";
- label = "USB_C1_PPC_INT_ODL";
- };
- usb_c0_bc12_int_odl {
- gpios = <&gpioe 4 GPIO_INPUT>;
- enum-name = "GPIO_USB_C0_BC12_INT_ODL";
- label = "USB_C0_BC12_INT_ODL";
- };
- gpio_usb_c1_mix_int_odl: usb_c1_mix_int_odl {
- #gpio-cells = <0>;
- gpios = <&gpio0 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_MIX_INT_ODL";
- label = "USB_C1_MIX_INT_ODL";
- };
- usb_c1_bc12_int_odl {
- #gpio-cells = <0>;
- gpios = <&gpio0 3 GPIO_INPUT>;
- enum-name = "GPIO_USB_C1_BC12_INT_ODL";
- label = "USB_C1_BC12_INT_ODL";
- };
- usb_c1_frs_en {
- gpios = <&gpio9 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_USB_C1_FRS_EN";
- label = "USB_C1_FRS_EN";
- };
- ec_voldn_btn_odl {
- gpios = <&gpio9 3 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_VOLUME_DOWN_L";
- label = "EC_VOLDN_BTN_ODL";
- };
- ec_volup_btn_odl {
- gpios = <&gpio9 7 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_VOLUME_UP_L";
- label = "EC_VOLUP_BTN_ODL";
- };
- en_pp3300_a {
- gpios = <&gpioa 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP3300_A";
- label = "EN_PP3300_A";
- };
- en_pp5000 {
- gpios = <&gpioa 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP5000";
- label = "EN_PP5000";
- };
- en_pp5000_a {
- gpios = <&gpioa 4 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP5000_A";
- label = "EN_PP5000_A";
- };
- en_ppvar_vccin {
- gpios = <&gpio4 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PPVAR_VCCIN";
- label = "EN_PPVAR_VCCIN";
- };
- ec_pch_dsw_pwrok {
- gpios = <&gpioc 0 GPIO_OUT_LOW>;
- enum-name = "GPIO_PCH_DSW_PWROK";
- label = "EC_PCH_DSW_PWROK";
- };
- ec_rst_odl {
- gpios = <&gpio0 2 GPIO_INPUT>;
- label = "EC_RST_ODL";
- };
- ec_pch_sys_pwrok {
- gpios = <&gpio3 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_EC_PCH_SYS_PWROK";
- label = "EC_PCH_SYS_PWROK";
- };
- ec_pch_rsmrst_odl {
- gpios = <&gpioa 6 GPIO_ODR_LOW>;
- enum-name = "GPIO_PCH_RSMRST_L";
- label = "EC_PCH_RSMRST_ODL";
- };
- ec_pch_pwr_btn_odl {
- gpios = <&gpioc 1 GPIO_ODR_HIGH>;
- enum-name = "GPIO_PCH_PWRBTN_L";
- label = "EC_PCH_PWR_BTN_ODL";
- };
- ec_pch_rtcrst {
- gpios = <&gpio7 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_PCH_RTCRST";
- label = "EC_PCH_RTCRST";
- };
- ec_pch_wake_odl {
- gpios = <&gpio7 4 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_PCH_WAKE_ODL";
- label = "EC_PCH_WAKE_ODL";
- };
- ec_entering_rw {
- gpios = <&gpioe 3 GPIO_OUT_LOW>;
- enum-name = "GPIO_ENTERING_RW";
- label = "EC_ENTERING_RW";
- };
- ec_prochot_odl {
- gpios = <&gpio6 3 GPIO_ODR_HIGH>;
- enum-name = "GPIO_CPU_PROCHOT";
- label = "EC_PROCHOT_ODL";
- };
- ec_prochot_in_l {
- gpios = <&gpiof 0 GPIO_INPUT>;
- enum-name = "GPIO_EC_PROCHOT_IN_L";
- label = "EC_PROCHOT_IN_L";
- };
- sys_rst_odl {
- gpios = <&gpioc 5 GPIO_ODR_HIGH>;
- enum-name = "GPIO_SYS_RESET_L";
- label = "SYS_RST_ODL";
- };
- ec_pch_int_odl {
- gpios = <&gpiob 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_EC_INT_L";
- label = "EC_PCH_INT_ODL";
- };
- en_pp5000_usba {
- gpios = <&gpioc 6 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP5000_USBA";
- label = "EN_PP5000_USBA";
- };
- usb_a_low_pwr_od {
- gpios = <&gpio6 6 GPIO_ODR_LOW>;
- enum-name = "GPIO_USB_A_LOW_PWR_OD";
- label = "USB_A_LOW_PWR_OD";
- };
- gpio_usb_c1_rt_rst_odl_boardid_0: usb_c1_rt_rst_odl_boardid_0 {
- #gpio-cells = <0>;
- gpios = <&gpio3 2 GPIO_ODR_LOW>;
- label = "USB_C1_RT_RST_ODL_BOARDID_0";
- };
- gpio_usb_c1_rt_rst_odl: usb_c1_rt_rst_odl {
- #gpio-cells = <0>;
- gpios = <&gpio8 3 GPIO_ODR_LOW>;
- enum-name = "GPIO_USB_C1_RT_RST_ODL";
- label = "USB_C1_RT_RST_ODL";
- };
- usb_c0_oc_odl {
- gpios = <&gpiob 1 GPIO_ODR_HIGH>;
- enum-name = "GPIO_USB_C0_OC_ODL";
- label = "USB_C0_OC_ODL";
- };
- usb_c1_oc_odl {
- gpios = <&gpio5 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_USB_C1_OC_ODL";
- label = "USB_C1_OC_ODL";
- };
- usb_c1_rt_int_odl {
- gpios = <&gpiof 3 GPIO_INPUT>;
- label = "USB_C1_RT_INT_ODL";
- };
- ec_h1_packet_mode {
- gpios = <&gpio7 5 GPIO_OUT_LOW>;
- enum-name = "GPIO_PACKET_MODE_EN";
- label = "EC_H1_PACKET_MODE";
- };
- m2_ssd_pln {
- gpios = <&gpioa 0 GPIO_ODR_HIGH>;
- enum-name = "GPIO_M2_SSD_PLN";
- label = "M2_SSD_PLN";
- };
- m2_ssd_pla {
- gpios = <&gpio7 0 GPIO_INPUT>;
- label = "M2_SSD_PLA";
- };
- ccd_mode_odl {
- gpios = <&gpioe 5 GPIO_INPUT>;
- label = "CCD_MODE_ODL";
- };
- ec_slp_s0ix {
- gpios = <&gpio7 2 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_SLP_S0IX";
- };
- gpio_unused_gpio41: unused_gpio41 {
- #gpio-cells = <0>;
- gpios = <&gpio4 1 (GPIO_INPUT | GPIO_PULL_UP)>;
- enum-name = "GPIO_USB_C1_LS_EN";
- label = "UNUSED_GPIO41";
- };
- ec_kb_bl_en {
- gpios = <&gpio8 6 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_KB_BL_EN";
- };
- ec_espi_alert_l {
- gpios = <&gpio5 7 (GPIO_INPUT | GPIO_PULL_UP)>;
- label = "EC_ESPI_ALERT_L";
- };
- ec_edp_bl_en {
- gpios = <&gpiod 3 GPIO_OUT_HIGH>;
- enum-name = "GPIO_ENABLE_BACKLIGHT";
- label = "EC_EDP_BL_EN";
- };
- ec_i2c0_sensor_scl {
- gpios = <&gpiob 5 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C0_SENSOR_SCL";
- label = "EC_I2C0_SENSOR_SCL";
- };
- ec_i2c0_sensor_sda {
- gpios = <&gpiob 4 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C0_SENSOR_SDA";
- label = "EC_I2C0_SENSOR_SDA";
- };
- ec_i2c1_usb_c0_scl {
- gpios = <&gpio9 0 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C1_USB_C0_SCL";
- label = "EC_I2C1_USB_C0_SCL";
- };
- ec_i2c1_usb_c0_sda {
- gpios = <&gpio8 7 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C1_USB_C0_SDA";
- label = "EC_I2C1_USB_C0_SDA";
- };
- ec_i2c2_usb_c1_scl {
- gpios = <&gpio9 2 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C2_USB_C1_SCL";
- label = "EC_I2C2_USB_C1_SCL";
- };
- ec_i2c2_usb_c1_sda {
- gpios = <&gpio9 1 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C2_USB_C1_SDA";
- label = "EC_I2C2_USB_C1_SDA";
- };
- ec_i2c3_usb_1_mix_scl {
- gpios = <&gpiod 1 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C3_USB_1_MIX_SCL";
- label = "EC_I2C3_USB_1_MIX_SCL";
- };
- ec_i2c3_usb_1_mix_sda {
- gpios = <&gpiod 0 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C3_USB_1_MIX_SDA";
- label = "EC_I2C3_USB_1_MIX_SDA";
- };
- ec_i2c5_battery_scl {
- gpios = <&gpio3 3 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C5_BATTERY_SCL";
- label = "EC_I2C5_BATTERY_SCL";
- };
- ec_i2c5_battery_sda {
- gpios = <&gpio3 6 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C5_BATTERY_SDA";
- label = "EC_I2C5_BATTERY_SDA";
- };
- ec_i2c7_eeprom_pwr_scl_r {
- gpios = <&gpiob 3 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C7_EEPROM_PWR_SCL_R";
- label = "EC_I2C7_EEPROM_PWR_SCL_R";
- };
- ec_i2c7_eeprom_pwr_sda_r {
- gpios = <&gpiob 2 GPIO_INPUT>;
- enum-name = "GPIO_EC_I2C7_EEPROM_PWR_SDA_R";
- label = "EC_I2C7_EEPROM_PWR_SDA_R";
- };
- /*
- * TODO(b:190743662) Cleanup to possibly remove the enum
- */
- ec_batt_pres_odl {
- gpios = <&gpioe 1 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- label = "EC_BATT_PRES_ODL";
- };
- gpio_en_pp5000_fan: en_pp5000_fan {
- gpios = <&gpio6 1 GPIO_OUT_LOW>;
- enum-name = "GPIO_EN_PP5000_FAN";
- label = "EN_PP5000_FAN";
- };
- ec_kso_02_inv {
- gpios = <&gpio1 7 GPIO_OUT_LOW>;
- enum-name = "GPIO_KBD_KSO2";
- label = "EC_KSO_02_INV";
- };
- };
-
- def-lvol-io-list {
- compatible = "nuvoton,npcx-lvolctrl-def";
- lvol-io-pads = <&lvol_iob4 &lvol_iob5>; /* I2C_SDA0 & SCL0 */
- };
-
- unused-pins {
- compatible = "unused-gpios";
- unused-gpios =
- <&gpio3 4 0>,
- <&gpio4 1 0>,
- <&gpio5 7 0>, /* EC_ESPI_ALERT_L not stuffed */
- <&gpio9 6 0>,
- <&gpio7 2 0>, /* EC_SLP_S0IX not stuffed */
- <&gpio8 6 0>, /* EC_KB_BL_EN not stuffed */
- <&gpioa 7 0>, /* EN_PP5000_USB_AG not stuffed */
- <&gpiof 2 0>,
- /*
- * GPIOB6 cannot be configured as an input.
- * Drive output low so signal level doesn't
- * depend on default setting of PxDOUT register.
- */
- <&gpiob 6 GPIO_OUTPUT_LOW>;
- };
-};
diff --git a/zephyr/projects/volteer/volteer/include/gpio_map.h b/zephyr/projects/volteer/volteer/include/gpio_map.h
deleted file mode 100644
index 2d6f5f87ee..0000000000
--- a/zephyr/projects/volteer/volteer/include/gpio_map.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-#include "extpower.h"
-#include "lid_switch.h"
-#include "power_button.h"
-
-/*
- * Without https://github.com/zephyrproject-rtos/zephyr/pull/29282, we need
- * to manually link GPIO_ defines that platform/ec code expects to the
- * enum gpio_signal values that are generated by device tree bindings.
- *
- * Note we only need to create aliases for GPIOs that are referenced in common
- * platform/ec code.
- */
-#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_PG_EC_DSW_PWROK
-
-/* Helper macros for generating CROS_EC_GPIO_INTERRUPTS */
-#ifdef CONFIG_PLATFORM_EC_POWERSEQ
-#define POWER_SIGNAL_INT(gpio, edge) \
- GPIO_INT(gpio, edge, power_signal_interrupt)
-#define AP_PROCHOT_INT(gpio, edge) \
- GPIO_INT(gpio, edge, throttle_ap_prochot_input_interrupt)
-#define POWER_BUTTON_INT(gpio, edge) \
- GPIO_INT(gpio, edge, power_button_interrupt)
-#else
-#define POWER_SIGNAL_INT(gpio, edge)
-#define AP_PROCHOT_INT(gpio, edge)
-#define POWER_BUTTON_INT(gpio, edge)
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_USBC
-#define TCPC_ALERT_INT(gpio, edge) GPIO_INT(gpio, edge, tcpc_alert_event)
-#define PPC_INT(gpio, edge) GPIO_INT(gpio, edge, ppc_interrupt)
-#define BC12_INT(gpio, edge) GPIO_INT(gpio, edge, bc12_interrupt)
-#else
-#define TCPC_ALERT_INT(gpio, edge)
-#define PPC_INT(gpio, edge)
-#define BC12_INT(gpio, edge)
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_ALS_TCS3400
-#define TCS3400_INT(gpio, edge) GPIO_INT(gpio, edge, tcs3400_interrupt)
-#else
-#define TCS3400_INT(gpio, edge)
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI260
-#define BMI260_INT(gpio, edge) GPIO_INT(gpio, edge, bmi260_interrupt)
-#else
-#define BMI260_INT(gpio, edge)
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_GMR_TABLET_MODE
-#define GMR_TABLET_MODE_INT(gpio, edge) GPIO_INT(gpio, edge, \
- gmr_tablet_switch_isr)
-#define GMR_TABLET_MODE_GPIO_L GPIO_TABLET_MODE_L
-#else
-#define GMR_TABLET_MODE_INT(gpio, edge)
-#endif
-
-#define GPIO_EC_BATT_PRES_ODL GPIO_BATT_PRES_ODL
-
-/*
- * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items.
- *
- * Each GPIO_INT requires three parameters:
- * gpio_signal - The enum gpio_signal for the interrupt gpio
- * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH)
- * handler - The platform/ec interrupt handler.
- *
- * Ensure that this files includes all necessary headers to declare all
- * referenced handler functions.
- *
- * For example, one could use the follow definition:
- * #define EC_CROS_GPIO_INTERRUPTS \
- * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print)
- */
-#define EC_CROS_GPIO_INTERRUPTS \
- BMI260_INT(GPIO_EC_IMU_INT_L, GPIO_INT_EDGE_FALLING) \
- GMR_TABLET_MODE_INT(GPIO_TABLET_MODE_L, GPIO_INT_EDGE_BOTH) \
- GPIO_INT(GPIO_AC_PRESENT, GPIO_INT_EDGE_BOTH, extpower_interrupt) \
- GPIO_INT(GPIO_LID_OPEN, GPIO_INT_EDGE_BOTH, lid_interrupt) \
- GPIO_INT(GPIO_EC_WP_L, GPIO_INT_EDGE_BOTH, switch_interrupt) \
- POWER_SIGNAL_INT(GPIO_PCH_SLP_S0_L, GPIO_INT_EDGE_BOTH) \
- POWER_SIGNAL_INT(GPIO_PCH_SLP_S3_L, GPIO_INT_EDGE_BOTH) \
- POWER_SIGNAL_INT(GPIO_PCH_SLP_SUS_L, GPIO_INT_EDGE_BOTH) \
- POWER_SIGNAL_INT(GPIO_PG_EC_DSW_PWROK, GPIO_INT_EDGE_BOTH) \
- POWER_SIGNAL_INT(GPIO_PG_EC_RSMRST_ODL, GPIO_INT_EDGE_BOTH) \
- POWER_SIGNAL_INT(GPIO_PCH_DSW_PWROK, GPIO_INT_EDGE_BOTH) \
- POWER_SIGNAL_INT(GPIO_PG_EC_ALL_SYS_PWRGD, GPIO_INT_EDGE_BOTH) \
- POWER_BUTTON_INT(GPIO_POWER_BUTTON_L, GPIO_INT_EDGE_BOTH) \
- TCPC_ALERT_INT(GPIO_USB_C0_TCPC_INT_ODL, GPIO_INT_EDGE_BOTH) \
- TCPC_ALERT_INT(GPIO_USB_C1_TCPC_INT_ODL, GPIO_INT_EDGE_BOTH) \
- TCS3400_INT(GPIO_EC_ALS_RGB_INT_L, GPIO_INT_EDGE_FALLING) \
- PPC_INT(GPIO_USB_C0_PPC_INT_ODL, GPIO_INT_EDGE_BOTH) \
- PPC_INT(GPIO_USB_C1_PPC_INT_ODL, GPIO_INT_EDGE_BOTH) \
- BC12_INT(GPIO_USB_C0_BC12_INT_ODL, GPIO_INT_EDGE_BOTH) \
- BC12_INT(GPIO_USB_C1_MIX_INT_ODL, GPIO_INT_EDGE_BOTH) \
- AP_PROCHOT_INT(GPIO_EC_PROCHOT_IN_L, GPIO_INT_EDGE_BOTH) \
- GPIO_INT(GPIO_VOLUME_DOWN_L, GPIO_INT_EDGE_BOTH, button_interrupt) \
- GPIO_INT(GPIO_VOLUME_UP_L, GPIO_INT_EDGE_BOTH, button_interrupt)
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
diff --git a/zephyr/projects/volteer/volteer/include/pwm_map.h b/zephyr/projects/volteer/volteer/include/pwm_map.h
deleted file mode 100644
index 67ab70936f..0000000000
--- a/zephyr/projects/volteer/volteer/include/pwm_map.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_CHROME_PWM_MAP_H
-#define __ZEPHYR_CHROME_PWM_MAP_H
-
-#include <devicetree.h>
-
-#include "config.h"
-
-#include "pwm/pwm.h"
-
-/*
- * TODO(b/177452529): eliminate the dependency on enum pwm_channel
- * and configure this information directly from the device tree.
- */
-#define PWM_CH_LED4_SIDESEL NAMED_PWM(led3_sidesel)
-
-#define PWM_CH_KBLIGHT NAMED_PWM(kblight)
-
-#define PWM_CH_FAN NAMED_PWM(fan)
-
-#endif /* __ZEPHYR_CHROME_PWM_MAP_H */
diff --git a/zephyr/projects/volteer/volteer/keyboard.dts b/zephyr/projects/volteer/volteer/keyboard.dts
deleted file mode 100644
index e9b5cdf0a1..0000000000
--- a/zephyr/projects/volteer/volteer/keyboard.dts
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- 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 */
- 0 /* C13 - for keypad */
- 0 /* C14 - for keypad */
- >;
- };
-};
diff --git a/zephyr/projects/volteer/volteer/motionsense.dts b/zephyr/projects/volteer/volteer/motionsense.dts
deleted file mode 100644
index e22d5571dc..0000000000
--- a/zephyr/projects/volteer/volteer/motionsense.dts
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 2020 The Chromium OS Authors
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-
-#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.
- */
- bmi260-int = &base_accel;
- tcs3400-int = &als_clear;
- };
-
- /*
- * 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";
- mutex_bma255: bma255-mutex {
- label = "BMA255_MUTEX";
- };
-
- mutex_bmi260: bmi260-mutex {
- label = "BMI260_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 = <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 {
- bma255_data: bma255-drv-data {
- compatible = "cros-ec,drvdata-bma255";
- status = "okay";
- };
-
- bmi260_data: bmi260-drv-data {
- compatible = "cros-ec,drvdata-bmi260";
- status = "okay";
- };
-
- tcs_clear_data: tcs3400-clear-drv-data {
- compatible = "cros-ec,drvdata-tcs3400-clear";
- status = "okay";
-
- als-drv-data {
- compatible = "cros-ec,accelgyro-als-drv-data";
- als-cal {
- scale = <1>;
- uscale = <0>;
- offset = <0>;
- als-channel-scale {
- compatible =
- "cros-ec,accelgyro-als-channel-scale";
- k-channel-scale = <1>;
- cover-scale = <1>;
- };
- };
- };
- };
-
- tcs_rgb_data: tcs3400-rgb-drv-data {
- compatible = "cros-ec,drvdata-tcs3400-rgb";
- status = "okay";
-
- /* node for rgb_calibration_t defined in accelgyro.h */
- rgb_calibration {
- compatible =
- "cros-ec,accelgyro-rgb-calibration";
-
- irt = <1>;
-
- rgb-cal-x {
- offset = <0>;
- coeff = <0 0 0 0>;
- als-channel-scale {
- compatible =
- "cros-ec,accelgyro-als-channel-scale";
- k-channel-scale = <1>;
- cover-scale = <1>;
- };
- };
- rgb-cal-y {
- offset = <0>;
- coeff = <0 0 0 0>;
- als-channel-scale {
- compatible =
- "cros-ec,accelgyro-als-channel-scale";
- k-channel-scale = <1>;
- cover-scale = <1>;
- };
- };
- rgb-cal-z {
- offset = <0>;
- coeff = <0 0 0 0>;
- als-channel-scale {
- compatible =
- "cros-ec,accelgyro-als-channel-scale";
- k-channel-scale = <1>;
- cover-scale = <1>;
- };
- };
- };
- };
- };
-
- /*
- * List of motion sensors that creates motion_sensors array.
- * The label "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,bma255";
- status = "okay";
-
- label = "Lid Accel";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_LID";
- mutex = <&mutex_bma255>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&lid_rot_ref>;
- default-range = <2>;
- drv-data = <&bma255_data>;
- i2c-spi-addr-flags = "BMA2x2_I2C_ADDR1_FLAGS";
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | ROUND_UP_FLAG)>;
- };
- };
- };
-
- base_accel: base-accel {
- compatible = "cros-ec,bmi260-accel";
- status = "okay";
-
- label = "Base Accel";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi260>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- default-range = <4>;
- drv-data = <&bmi260_data>;
- i2c-spi-addr-flags = "BMI260_ADDR0_FLAGS";
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- label = "SENSOR_CONFIG_EC_S0";
- odr = <(10000 | ROUND_UP_FLAG)>;
- ec-rate = <(100 * USEC_PER_MSEC)>;
- };
- ec-s3 {
- label = "SENSOR_CONFIG_EC_S3";
- odr = <(10000 | ROUND_UP_FLAG)>;
- ec-rate = <(100 * USEC_PER_MSEC)>;
- };
- };
- };
-
- base-gyro {
- compatible = "cros-ec,bmi260-gyro";
- status = "okay";
-
- label = "Base Gyro";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi260>;
- port = <&i2c_sensor>;
- rot-standard-ref = <&base_rot_ref>;
- default-range = <1000>; /* dps */
- drv-data = <&bmi260_data>;
- i2c-spi-addr-flags = "BMI260_ADDR0_FLAGS";
- };
-
- als_clear: base-als-clear {
- compatible = "cros-ec,tcs3400-clear";
- status = "okay";
-
- label = "Clear Light";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- port = <&i2c_sensor>;
- default-range = <0x10000>;
- drv-data = <&tcs_clear_data>;
- i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS";
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- /* Run ALS sensor in S0 */
- label = "SENSOR_CONFIG_EC_S0";
- odr = <1000>;
- };
- };
- };
-
- base-als-rgb {
- compatible = "cros-ec,tcs3400-rgb";
- status = "okay";
-
- label = "RGB Light";
- active-mask = "SENSOR_ACTIVE_S0_S3";
- location = "MOTIONSENSE_LOC_BASE";
- default-range = <0x10000>; /* scale = 1x, uscale = 0 */
- drv-data = <&tcs_rgb_data>;
- };
- };
-
- motionsense-sensor-info {
- compatible = "cros-ec,motionsense-sensor-info";
-
- /* list of entries for motion_als_sensors */
- als-sensors = <&als_clear>;
- /*
- * list of GPIO interrupts that have to
- * be enabled at initial stage
- */
- sensor-irqs = <&gpio_ec_imu_int_l &gpio_ec_als_rgb_int_l>;
- /* list of sensors in force mode */
- accel-force-mode-sensors = <&lid_accel &als_clear>;
- };
-};
diff --git a/zephyr/projects/volteer/volteer/prj.conf b/zephyr/projects/volteer/volteer/prj.conf
deleted file mode 100644
index 80bdc2ad44..0000000000
--- a/zephyr/projects/volteer/volteer/prj.conf
+++ /dev/null
@@ -1,152 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_CROS_EC=y
-
-CONFIG_WATCHDOG=y
-
-# SoC configuration
-CONFIG_AP=y
-CONFIG_AP_X86_INTEL_TGL=y
-CONFIG_FPU=y
-CONFIG_ARM_MPU=y
-
-# eSPI
-CONFIG_ESPI=y
-CONFIG_PLATFORM_EC_ESPI_VW_SLP_S4=y
-
-CONFIG_PLATFORM_EC=y
-CONFIG_SHIMMED_TASKS=y
-CONFIG_I2C=y
-CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y
-CONFIG_PLATFORM_EC_LID_SWITCH=y
-CONFIG_PLATFORM_EC_POWER_BUTTON=y
-CONFIG_PLATFORM_EC_CBI_EEPROM=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_HCDEBUG=n
-CONFIG_PLATFORM_EC_CONSOLE_CMD_CHGRAMP=n
-
-# Keyboard
-CONFIG_PLATFORM_EC_KEYBOARD=y
-CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y
-CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD=y
-CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y
-CONFIG_PLATFORM_EC_VOLUME_BUTTONS=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
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y
-CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y
-
-# Keyboard Backlight
-CONFIG_PLATFORM_EC_PWM_KBLIGHT=y
-
-# LED
-CONFIG_PLATFORM_EC_LED_COMMON=y
-CONFIG_PLATFORM_EC_LED_PWM=y
-CONFIG_PLATFORM_EC_CONSOLE_CMD_LEDTEST=n
-
-# Power Sequencing
-CONFIG_PLATFORM_EC_POWERSEQ=y
-CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET=y
-CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y
-CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y
-CONFIG_PLATFORM_EC_THROTTLE_AP=y
-
-# PWM
-CONFIG_PWM=y
-CONFIG_PWM_SHELL=n
-CONFIG_PLATFORM_EC_PWM=y
-
-# Fan
-CONFIG_PLATFORM_EC_FAN=y
-CONFIG_SENSOR=y
-CONFIG_SENSOR_SHELL=n
-CONFIG_TACH_NPCX=y
-
-# Sensors
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_ACCEL_INTERRUPTS=y
-CONFIG_PLATFORM_EC_ALS=y
-CONFIG_PLATFORM_EC_ALS_COUNT=1
-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
-
-# Sensor Drivers
-CONFIG_PLATFORM_EC_ACCEL_BMA255=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI260=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
-CONFIG_PLATFORM_EC_ALS_TCS3400=y
-
-# Temperature sensors
-CONFIG_PLATFORM_EC_TEMP_SENSOR=y
-CONFIG_PLATFORM_EC_THERMISTOR=y
-
-# Miscellaneous tasks
-CONFIG_HAS_TASK_KEYPROTO=y
-CONFIG_HAS_TASK_POWERBTN=y
-
-# Miscellaneous configs
-CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=y
-CONFIG_PLATFORM_EC_HIBERNATE_PSL=y
-
-# MKBP event
-CONFIG_PLATFORM_EC_MKBP_EVENT=y
-CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y
-
-# USB-C and charging
-CONFIG_HAS_TASK_CHARGER=y
-CONFIG_PLATFORM_EC_CHARGER_ISL9241=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_HAS_TASK_USB_CHG_P1=y
-CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y
-CONFIG_PLATFORM_EC_USB_PID=0x503e
-CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y
-CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=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_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_FRS=y
-CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y
-CONFIG_PLATFORM_EC_USB_PD_REV30=y
-CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=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=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_TUSB422=y
-CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX=y
-CONFIG_HAS_TASK_PD_C1=y
-CONFIG_HAS_TASK_PD_INT_C1=y
-CONFIG_PLATFORM_EC_USBC_PPC_DEDICATED_INT=y
-CONFIG_PLATFORM_EC_USB_A_PORT_COUNT=1
-CONFIG_PLATFORM_EC_CONSOLE_CMD_PPC_DUMP=n
-CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n
-
-# Flash
-CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH=n
-
-# RTC
-CONFIG_PLATFORM_EC_RTC=y
-
-CONFIG_SYSCON=y
diff --git a/zephyr/projects/volteer/volteer/pwm.dts b/zephyr/projects/volteer/volteer/pwm.dts
deleted file mode 100644
index f8a0fef7df..0000000000
--- a/zephyr/projects/volteer/volteer/pwm.dts
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-pwms {
- compatible = "named-pwms";
-
- led1_blue: led1_blue {
- #pwm-cells = <0>;
- pwms = <&pwm2 0 PWM_POLARITY_INVERTED>;
- label = "LED1_BLUE";
- frequency = <4800>;
- };
- led2_green: led2_green {
- #pwm-cells = <0>;
- pwms = <&pwm0 0 PWM_POLARITY_INVERTED>;
- label = "LED2_GREEN";
- frequency = <4800>;
- };
- led3_red: led3_red {
- #pwm-cells = <0>;
- pwms = <&pwm1 0 PWM_POLARITY_INVERTED>;
- label = "LED3_RED";
- frequency = <4800>;
- };
- led3_sidesel: led3_sidesel {
- #pwm-cells = <0>;
- pwms = <&pwm7 0 PWM_POLARITY_INVERTED>;
- label = "LED4_SIDESEL";
- frequency = <2400>;
- };
- kblight {
- pwms = <&pwm3 0 0>;
- label = "KBLIGHT";
- frequency = <2400>;
- };
- pwm_fan: fan {
- pwms = <&pwm5 0 0>;
- label = "FAN";
- frequency = <25000>;
- };
- };
-};
-
-/* Green LED */
-&pwm0 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
-};
-
-/* Red LED */
-&pwm1 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
-};
-
-/* Blue LED */
-&pwm2 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
-};
-
-/* Keyboard backlight */
-&pwm3 {
- status = "okay";
-};
-
-/* Fan control */
-&pwm5 {
- status = "okay";
- drive-open-drain;
-};
-
-/* Side selection LED */
-&pwm7 {
- status = "okay";
- clock-bus = "NPCX_CLOCK_BUS_LFCLK";
-};
diff --git a/zephyr/projects/volteer/volteer/pwm_leds.dts b/zephyr/projects/volteer/volteer/pwm_leds.dts
deleted file mode 100644
index 659cdecbf2..0000000000
--- a/zephyr/projects/volteer/volteer/pwm_leds.dts
+++ /dev/null
@@ -1,32 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- pwmleds {
- compatible = "pwm-leds";
- pwm_led0: pwm_led_0 {
- pwms = <&led3_red
- &led2_green
- &led1_blue
- &led3_sidesel
- >;
- };
- };
-
- cros-pwmleds {
- compatible = "cros-ec,pwm-leds";
-
- leds = <&pwm_led0>;
-
- color-map-red = <100 0 0>;
- color-map-green = < 0 100 0>;
- color-map-blue = < 0 0 100>;
- color-map-yellow = <100 70 0>;
- color-map-white = <100 70 100>;
- color-map-amber = <100 20 0>;
-
- brightness-range = <255 255 255 0 0 0>;
- };
-};
diff --git a/zephyr/projects/volteer/volteer/zmake.yaml b/zephyr/projects/volteer/volteer/zmake.yaml
deleted file mode 100644
index a89c0287af..0000000000
--- a/zephyr/projects/volteer/volteer/zmake.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: volteer
-dts-overlays:
- - bb_retimer.dts
- - cbi_eeprom.dts
- - fan.dts
- - gpio.dts
- - keyboard.dts
- - motionsense.dts
- - pwm.dts
- - pwm_leds.dts
-supported-toolchains:
- - coreboot-sdk
- - zephyr
-supported-zephyr-versions:
- - v2.6
-output-type: npcx
diff --git a/zephyr/shim/CMakeLists.txt b/zephyr/shim/CMakeLists.txt
deleted file mode 100644
index e36101756a..0000000000
--- a/zephyr/shim/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 2020 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.
-
-add_subdirectory("chip")
-add_subdirectory("core")
-add_subdirectory("src")
diff --git a/zephyr/shim/chip/CMakeLists.txt b/zephyr/shim/chip/CMakeLists.txt
deleted file mode 100644
index 5c76a4163a..0000000000
--- a/zephyr/shim/chip/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if (DEFINED CONFIG_SOC_FAMILY_NPCX)
- add_subdirectory(npcx)
-elseif (DEFINED CONFIG_SOC_FAMILY_RISCV_ITE)
- add_subdirectory(it8xxx2)
-elseif (DEFINED CONFIG_SOC_POSIX)
- add_subdirectory(posix)
-endif()
-
diff --git a/zephyr/shim/chip/it8xxx2/CMakeLists.txt b/zephyr/shim/chip/it8xxx2/CMakeLists.txt
deleted file mode 100644
index 7a92a3cfb6..0000000000
--- a/zephyr/shim/chip/it8xxx2/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-zephyr_library_include_directories(include)
-
-zephyr_library_sources(clock.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_EC system.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_EC pinmux.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_KB_RAW_ITE keyboard_raw.c)
diff --git a/zephyr/shim/chip/it8xxx2/clock.c b/zephyr/shim/chip/it8xxx2/clock.c
deleted file mode 100644
index 2bcf9e2899..0000000000
--- a/zephyr/shim/chip/it8xxx2/clock.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <device.h>
-#include <drivers/clock_control.h>
-#include <kernel.h>
-#include <logging/log.h>
-#include <soc.h>
-#include <zephyr.h>
-#include <soc/ite_it8xxx2/reg_def_cros.h>
-#include <sys/util.h>
-
-#include "module_id.h"
-
-LOG_MODULE_REGISTER(shim_clock, LOG_LEVEL_ERR);
-
-#define ECPM_NODE DT_INST(0, ite_it8xxx2_ecpm)
-#define HAL_ECPM_REG_BASE_ADDR \
- ((struct ecpm_reg *)DT_REG_ADDR_BY_IDX(ECPM_NODE, 0))
-#define PLLFREQ_MASK 0xf
-
-static const int pll_reg_to_freq[8] = {
- MHZ(8),
- MHZ(16),
- MHZ(24),
- MHZ(32),
- MHZ(48),
- MHZ(64),
- MHZ(72),
- MHZ(96)
-};
-
-int clock_get_freq(void)
-{
- struct ecpm_reg *const ecpm_base = HAL_ECPM_REG_BASE_ADDR;
- int reg_val = ecpm_base->ECPM_PLLFREQ & PLLFREQ_MASK;
-
- return pll_reg_to_freq[reg_val];
-}
diff --git a/zephyr/shim/chip/it8xxx2/include/flash_chip.h b/zephyr/shim/chip/it8xxx2/include/flash_chip.h
deleted file mode 100644
index e45a08296f..0000000000
--- a/zephyr/shim/chip/it8xxx2/include/flash_chip.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_FLASH_CHIP_H
-#define __CROS_EC_FLASH_CHIP_H
-
-/*
- * Flash size of IT81202 is 1MB.
- * We use only half space of flash to save time of erasing RW image from flash.
- */
-#define CONFIG_FLASH_SIZE_BYTES (DT_REG_SIZE(DT_NODELABEL(flash0)) / 2)
-/* Program is run directly from storage */
-#define CONFIG_MAPPED_STORAGE_BASE DT_REG_ADDR(DT_NODELABEL(flash0))
-/*
- * One page program instruction allows maximum 256 bytes (a page) of data
- * to be programmed.
- */
-#define CONFIG_FLASH_WRITE_IDEAL_SIZE 256
-/* Minimum write size */
-#define CONFIG_FLASH_WRITE_SIZE DT_PROP(DT_INST(0, soc_nv_flash), \
- write_block_size)
-/* Erase bank size */
-#define CONFIG_FLASH_ERASE_SIZE DT_PROP(DT_INST(0, soc_nv_flash), \
- erase_block_size)
-/* Protect bank size */
-#define CONFIG_FLASH_BANK_SIZE CONFIG_FLASH_ERASE_SIZE
-
-#define CONFIG_RO_STORAGE_OFF 0x0
-#define CONFIG_RW_STORAGE_OFF 0x0
-
-/*
- * The EC uses the one bank of flash to emulate a SPI-like write protect
- * register with persistent state.
- */
-#define CONFIG_FW_PSTATE_SIZE CONFIG_FLASH_BANK_SIZE
-#define CONFIG_FW_PSTATE_OFF (CONFIG_FLASH_SIZE_BYTES / 2 - \
- CONFIG_FW_PSTATE_SIZE)
-
-#endif /* __CROS_EC_FLASH_CHIP_H */
diff --git a/zephyr/shim/chip/it8xxx2/keyboard_raw.c b/zephyr/shim/chip/it8xxx2/keyboard_raw.c
deleted file mode 100644
index 0096798915..0000000000
--- a/zephyr/shim/chip/it8xxx2/keyboard_raw.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Functions needed by keyboard scanner module for Chrome EC */
-
-#include <device.h>
-#include <logging/log.h>
-#include <soc.h>
-#include <zephyr.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
- */
-int keyboard_raw_is_input_low(int port, int id)
-{
- /*
- * TODO: implement for factory testing KSI and KSO pin as GPIO
- * function.
- */
- return 0;
-}
diff --git a/zephyr/shim/chip/it8xxx2/pinmux.c b/zephyr/shim/chip/it8xxx2/pinmux.c
deleted file mode 100644
index fd8dc7fc8e..0000000000
--- a/zephyr/shim/chip/it8xxx2/pinmux.c
+++ /dev/null
@@ -1,112 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <init.h>
-#include <drivers/pinmux.h>
-#include <dt-bindings/pinctrl/it8xxx2-pinctrl.h>
-#include <soc.h>
-
-static int it8xxx2_pinmux_init(const struct device *dev)
-{
- ARG_UNUSED(dev);
-
-#if DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxb), okay) && \
- DT_NODE_HAS_STATUS(DT_NODELABEL(uart1), okay)
- const struct device *portb = DEVICE_DT_GET(DT_NODELABEL(pinmuxb));
-
- /* SIN0 */
- pinmux_pin_set(portb, 0, IT8XXX2_PINMUX_FUNC_3);
- /* SOUT0 */
- pinmux_pin_set(portb, 1, IT8XXX2_PINMUX_FUNC_3);
-#endif
-
- return 0;
-}
-SYS_INIT(it8xxx2_pinmux_init, PRE_KERNEL_1, CONFIG_PINMUX_INIT_PRIORITY);
-
-/*
- * Init priority is behind CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY to overwrite
- * GPIO_INPUT setting of i2c ports.
- */
-static int it8xxx2_pinmux_init_latr(const struct device *dev)
-{
- ARG_UNUSED(dev);
-
-#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c0), okay) && \
- DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxb), okay)
- {
- const struct device *portb =
- DEVICE_DT_GET(DT_NODELABEL(pinmuxb));
-
- /* I2C0 CLK */
- pinmux_pin_set(portb, 3, IT8XXX2_PINMUX_FUNC_1);
- /* I2C0 DAT */
- pinmux_pin_set(portb, 4, IT8XXX2_PINMUX_FUNC_1);
- }
-#endif
-#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c1), okay) && \
- DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxc), okay)
- {
- const struct device *portc =
- DEVICE_DT_GET(DT_NODELABEL(pinmuxc));
-
- /* I2C1 CLK */
- pinmux_pin_set(portc, 1, IT8XXX2_PINMUX_FUNC_1);
- /* I2C1 DAT */
- pinmux_pin_set(portc, 2, IT8XXX2_PINMUX_FUNC_1);
- }
-#endif
-#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c2), okay) && \
- DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxf), okay)
- {
- const struct device *portf =
- DEVICE_DT_GET(DT_NODELABEL(pinmuxf));
-
- /* I2C2 CLK */
- pinmux_pin_set(portf, 6, IT8XXX2_PINMUX_FUNC_1);
- /* I2C2 DAT */
- pinmux_pin_set(portf, 7, IT8XXX2_PINMUX_FUNC_1);
- }
-#endif
-#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c3), okay) && \
- DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxh), okay)
- {
- const struct device *porth =
- DEVICE_DT_GET(DT_NODELABEL(pinmuxh));
-
- /* I2C3 CLK */
- pinmux_pin_set(porth, 1, IT8XXX2_PINMUX_FUNC_3);
- /* I2C3 DAT */
- pinmux_pin_set(porth, 2, IT8XXX2_PINMUX_FUNC_3);
- }
-#endif
-#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c4), okay) && \
- DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxe), okay)
- {
- const struct device *porte =
- DEVICE_DT_GET(DT_NODELABEL(pinmuxe));
-
- /* I2C4 CLK */
- pinmux_pin_set(porte, 0, IT8XXX2_PINMUX_FUNC_3);
- /* I2C4 DAT */
- pinmux_pin_set(porte, 7, IT8XXX2_PINMUX_FUNC_3);
- }
-#endif
-#if DT_NODE_HAS_STATUS(DT_NODELABEL(i2c5), okay) && \
- DT_NODE_HAS_STATUS(DT_NODELABEL(pinmuxa), okay)
- {
- const struct device *porta =
- DEVICE_DT_GET(DT_NODELABEL(pinmuxa));
-
- /* I2C5 CLK */
- pinmux_pin_set(porta, 4, IT8XXX2_PINMUX_FUNC_3);
- /* I2C5 DAT */
- pinmux_pin_set(porta, 5, IT8XXX2_PINMUX_FUNC_3);
- }
-#endif
-
- return 0;
-}
-SYS_INIT(it8xxx2_pinmux_init_latr, POST_KERNEL, 52);
diff --git a/zephyr/shim/chip/it8xxx2/system.c b/zephyr/shim/chip/it8xxx2/system.c
deleted file mode 100644
index d9dcd7ccfb..0000000000
--- a/zephyr/shim/chip/it8xxx2/system.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "system.h"
-
-uintptr_t system_get_fw_reset_vector(uintptr_t base)
-{
- /*
- * Because our reset vector is at the beginning of image copy
- * (see init.S). So I just need to return 'base' here and EC will jump
- * to the reset vector.
- */
- return base;
-}
diff --git a/zephyr/shim/chip/npcx/CMakeLists.txt b/zephyr/shim/chip/npcx/CMakeLists.txt
deleted file mode 100644
index d3cd4b48fd..0000000000
--- a/zephyr/shim/chip/npcx/CMakeLists.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2020 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.
-
-# When building code coverage, the final Zephyr image isn't actually linked
-# and there's no valid image to program. Skip compiling and linking the NPCX
-# monitor when coverage is enabled.
-if (NOT DEFINED CONFIG_COVERAGE)
- add_subdirectory(npcx_monitor)
-endif()
-
-zephyr_library_include_directories(include)
-
-zephyr_library_sources(clock.c)
-zephyr_library_sources(gpio.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ESPI espi.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_KB_RAW_NPCX keyboard_raw.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_SHI_NPCX shi.c)
-zephyr_library_sources_ifdef(CONFIG_CROS_EC system.c)
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_EXTERNAL_STORAGE
- system_external_storage.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API
- system_download_from_flash.c)
-zephyr_library_sources_ifdef(CONFIG_PM_POLICY_APP power_policy.c)
diff --git a/zephyr/shim/chip/npcx/Kconfig.npcx b/zephyr/shim/chip/npcx/Kconfig.npcx
deleted file mode 100644
index b044912ae1..0000000000
--- a/zephyr/shim/chip/npcx/Kconfig.npcx
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if PLATFORM_EC
-
-config CROS_SYSTEM_NPCX_PRE_INIT_PRIORITY
- int "System pre-initialization priority"
- default 15
- range 10 19
- depends on SOC_FAMILY_NPCX
- help
- This sets the priority of the NPCX chip system initialization. The
- chip system initialization verifies the integrity of the BBRAM and
- must be a lower priority than CONFIG_BBRAM_INIT_PRIORITY and
- must be a higher priority than PLATFORM_EC_SYSTEM_PRE_INIT.
-
-endif # PLATFORM_EC
diff --git a/zephyr/shim/chip/npcx/clock.c b/zephyr/shim/chip/npcx/clock.c
deleted file mode 100644
index 8c8bad5596..0000000000
--- a/zephyr/shim/chip/npcx/clock.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <device.h>
-#include <drivers/clock_control.h>
-#include <dt-bindings/clock/npcx_clock.h>
-#include <kernel.h>
-#include <logging/log.h>
-#include <soc.h>
-#include <zephyr.h>
-
-#include "clock_chip.h"
-#include "module_id.h"
-
-LOG_MODULE_REGISTER(shim_clock, LOG_LEVEL_ERR);
-
-#define CDCG_NODE DT_INST(0, nuvoton_npcx_pcc)
-#define HAL_CDCG_REG_BASE_ADDR \
- ((struct cdcg_reg *)DT_REG_ADDR_BY_IDX(CDCG_NODE, 1))
-
-int clock_get_freq(void)
-{
- const struct device *clk_dev = DEVICE_DT_GET(NPCX_CLK_CTRL_NODE);
- const struct npcx_clk_cfg clk_cfg = {
- .bus = NPCX_CLOCK_BUS_CORE,
- };
- uint32_t rate;
-
- if (clock_control_get_rate(clk_dev, (clock_control_subsys_t *)&clk_cfg,
- &rate) != 0) {
- LOG_ERR("Get %s clock rate error", clk_dev->name);
- return -EIO;
- }
-
- return rate;
-}
-
-void clock_turbo(void)
-{
- struct cdcg_reg *const cdcg_base = HAL_CDCG_REG_BASE_ADDR;
-
- /* For NPCX7:
- * Increase CORE_CLK (CPU) as the same as OSC_CLK. Since
- * CORE_CLK > 66MHz, we also need to set AHB6DIV and FIUDIV as 1.
- */
- cdcg_base->HFCGP = 0x01;
- cdcg_base->HFCBCD = BIT(4);
-}
-
-void clock_normal(void)
-{
- struct cdcg_reg *const cdcg_base = HAL_CDCG_REG_BASE_ADDR;
-
- cdcg_base->HFCGP = ((FPRED_VAL << 4) | AHB6DIV_VAL);
- cdcg_base->HFCBCD = (FIUDIV_VAL << 4);
-}
-
-void clock_enable_module(enum module_id module, int enable)
-{
- /* Assume we have a single task using MODULE_FAST_CPU */
- if (module == MODULE_FAST_CPU) {
- if (enable)
- clock_turbo();
- else
- clock_normal();
- }
-}
diff --git a/zephyr/shim/chip/npcx/espi.c b/zephyr/shim/chip/npcx/espi.c
deleted file mode 100644
index 2115f388d6..0000000000
--- a/zephyr/shim/chip/npcx/espi.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <device.h>
-#include <sys/util.h>
-
-#include "drivers/espi.h"
-#include "soc_espi.h"
-#include "zephyr_espi_shim.h"
-
-bool is_acpi_command(uint32_t data)
-{
- struct espi_evt_data_acpi *acpi = (struct espi_evt_data_acpi *)&data;
-
- return acpi->type;
-}
-
-uint32_t get_acpi_value(uint32_t data)
-{
- struct espi_evt_data_acpi *acpi = (struct espi_evt_data_acpi *)&data;
-
- return acpi->data;
-}
-
-bool is_8042_ibf(uint32_t data)
-{
- struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data;
-
- return kbc->evt & HOST_KBC_EVT_IBF;
-}
-
-bool is_8042_obe(uint32_t data)
-{
- struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data;
-
- return kbc->evt & HOST_KBC_EVT_OBE;
-}
-
-uint32_t get_8042_type(uint32_t data)
-{
- struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data;
-
- return kbc->type;
-}
-
-uint32_t get_8042_data(uint32_t data)
-{
- struct espi_evt_data_kbc *kbc = (struct espi_evt_data_kbc *)&data;
-
- return kbc->data;
-}
diff --git a/zephyr/shim/chip/npcx/gpio.c b/zephyr/shim/chip/npcx/gpio.c
deleted file mode 100644
index 148e1a97c9..0000000000
--- a/zephyr/shim/chip/npcx/gpio.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <device.h>
-#include <kernel.h>
-
-#include <logging/log.h>
-
-#include "gpio.h"
-#include "gpio/gpio.h"
-
-LOG_MODULE_REGISTER(shim_cros_gpio, LOG_LEVEL_ERR);
-
-static const struct unused_pin_config unused_pin_configs[] = {
- UNUSED_GPIO_CONFIG_LIST
-};
-
-int gpio_config_unused_pins(void)
-{
- for (size_t i = 0; i < ARRAY_SIZE(unused_pin_configs); ++i) {
- int rv;
- int flags;
- const struct device *dev =
- device_get_binding(unused_pin_configs[i].dev_name);
-
- if (dev == NULL) {
- LOG_ERR("Not found (%s)",
- unused_pin_configs[i].dev_name);
- return -ENOTSUP;
- }
-
- /*
- * Set the default setting for the floating IOs. The floating
- * IOs cause the leakage current. Set unused pins as input with
- * internal PU to prevent extra power consumption.
- */
- if (unused_pin_configs[i].flags == 0)
- flags = GPIO_INPUT | GPIO_PULL_UP;
- else
- flags = unused_pin_configs[i].flags;
-
- rv = gpio_pin_configure(dev, unused_pin_configs[i].pin, flags);
-
- if (rv < 0) {
- LOG_ERR("Config failed %s-%d (%d)",
- unused_pin_configs[i].dev_name,
- unused_pin_configs[i].pin, rv);
- return rv;
- }
- }
-
- return 0;
-}
diff --git a/zephyr/shim/chip/npcx/include/clock_chip.h b/zephyr/shim/chip/npcx/include/clock_chip.h
deleted file mode 100644
index 0c39ed8174..0000000000
--- a/zephyr/shim/chip/npcx/include/clock_chip.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_CLOCK_CHIP_H
-#define __CROS_EC_CLOCK_CHIP_H
-
-/**
- * TODO(b:180112248) implement in zephyr's clock_control.h
- */
-void clock_turbo(void);
-
-#endif /* __CROS_EC_CLOCK_CHIP_H */
diff --git a/zephyr/shim/chip/npcx/include/flash_chip.h b/zephyr/shim/chip/npcx/include/flash_chip.h
deleted file mode 100644
index 622633c570..0000000000
--- a/zephyr/shim/chip/npcx/include/flash_chip.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_FLASH_CHIP_H
-#define __CROS_EC_FLASH_CHIP_H
-
-#define CONFIG_SPI_FLASH_W25Q80 /* Internal SPI flash type. */
-#ifdef CONFIG_FLASH_SIZE
-#define CONFIG_FLASH_SIZE_BYTES (CONFIG_FLASH_SIZE * 1024)
-#else
-#define CONFIG_FLASH_SIZE_BYTES 0x0
-#endif
-
-/* TODO(b:176490413): use DT_PROP(DT_INST(inst, DT_DRV_COMPAT), size) ? */
-#define CONFIG_MAPPED_STORAGE_BASE 0x64000000
-#define CONFIG_FLASH_WRITE_SIZE 0x1 /* minimum write size */
-#define CONFIG_FLASH_WRITE_IDEAL_SIZE 256 /* one page size for write */
-#define CONFIG_FLASH_ERASE_SIZE 0x10000
-#define CONFIG_FLASH_BANK_SIZE CONFIG_FLASH_ERASE_SIZE
-
-/* RO image resides at start of protected region, right after header */
-#define CONFIG_RO_STORAGE_OFF CONFIG_RO_HDR_SIZE
-
-#define CONFIG_RW_STORAGE_OFF 0
-
-/* Use 4k sector erase for NPCX monitor flash erase operations. */
-#define NPCX_MONITOR_FLASH_ERASE_SIZE 0x1000
-
-#endif /* __CROS_EC_FLASH_CHIP_H */
diff --git a/zephyr/shim/chip/npcx/include/rom_chip.h b/zephyr/shim/chip/npcx/include/rom_chip.h
deleted file mode 100644
index aab166e6f1..0000000000
--- a/zephyr/shim/chip/npcx/include/rom_chip.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_ROM_CHIP_H
-#define __CROS_EC_ROM_CHIP_H
-
-#include "common.h"
-
-/* Enumerations of ROM api functions */
-enum API_SIGN_OPTIONS_T {
- SIGN_NO_CHECK = 0,
- SIGN_CRC_CHECK = 1,
-};
-
-enum API_RETURN_STATUS_T {
- /* Successful download */
- API_RET_STATUS_OK = 0,
- /* Address is outside of flash or not 4 bytes aligned. */
- API_RET_STATUS_INVALID_SRC_ADDR = 1,
- /* Address is outside of RAM or not 4 bytes aligned. */
- API_RET_STATUS_INVALID_DST_ADDR = 2,
- /* Size is 0 or not 4 bytes aligned. */
- API_RET_STATUS_INVALID_SIZE = 3,
- /* Flash Address + Size is out of flash. */
- API_RET_STATUS_INVALID_SIZE_OUT_OF_FLASH = 4,
- /* RAM Address + Size is out of RAM. */
- API_RET_STATUS_INVALID_SIZE_OUT_OF_RAM = 5,
- /* Wrong sign option. */
- API_RET_STATUS_INVALID_SIGN = 6,
- /* Error during Code copy. */
- API_RET_STATUS_COPY_FAILED = 7,
- /* Execution Address is outside of RAM */
- API_RET_STATUS_INVALID_EXE_ADDR = 8,
- /* Bad CRC value */
- API_RET_STATUS_INVALID_SIGNATURE = 9,
-};
-
-/* Macro functions of ROM api functions */
-#define ADDR_DOWNLOAD_FROM_FLASH (*(volatile uint32_t *) 0x40)
-#define download_from_flash(src_offset, dest_addr, size, sign, exe_addr, \
- status) \
- (((download_from_flash_ptr) ADDR_DOWNLOAD_FROM_FLASH) \
- (src_offset, dest_addr, size, sign, exe_addr, status))
-
-/* Declarations of ROM api functions */
-typedef void (*download_from_flash_ptr) (
- uint32_t src_offset, /* The offset of the data to be downloaded */
- uint32_t dest_addr, /* The address of the downloaded data in the RAM*/
- uint32_t size, /* Number of bytes to download */
- enum API_SIGN_OPTIONS_T sign, /* Need CRC check or not */
- uint32_t exe_addr, /* jump to this address after download if not zero */
- enum API_RETURN_STATUS_T *status /* Status fo download */
-);
-
-#endif /* __CROS_EC_ROM_CHIP_H */
diff --git a/zephyr/shim/chip/npcx/include/system_chip.h b/zephyr/shim/chip/npcx/include/system_chip.h
deleted file mode 100644
index c77c2a8338..0000000000
--- a/zephyr/shim/chip/npcx/include/system_chip.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_SYSTEM_CHIP_H_
-#define __CROS_EC_SYSTEM_CHIP_H_
-
-#define SET_BIT(reg, bit) ((reg) |= (0x1 << (bit)))
-#define CLEAR_BIT(reg, bit) ((reg) &= (~(0x1 << (bit))))
-
-/* TODO(b:179900857) Clean this up too */
-#undef IS_BIT_SET
-#define IS_BIT_SET(reg, bit) (((reg) >> (bit)) & (0x1))
-
-/*****************************************************************************/
-/* Memory mapping */
-#define CONFIG_LPRAM_BASE 0x40001400 /* memory address of lpwr ram */
-#define CONFIG_LPRAM_SIZE 0x00000620 /* 1568B low power ram */
-
-/******************************************************************************/
-/* Optional M4 Registers */
-#define CPU_MPU_CTRL REG32(0xE000ED94)
-#define CPU_MPU_RNR REG32(0xE000ED98)
-#define CPU_MPU_RBAR REG32(0xE000ED9C)
-#define CPU_MPU_RASR REG32(0xE000EDA0)
-
-/*
- * Region assignment. 7 as the highest, a higher index has a higher priority.
- * For example, using 7 for .iram.text allows us to mark entire RAM XN except
- * .iram.text, which is used for hibernation.
- * Region assignment is currently wasteful and can be changed if more
- * regions are needed in the future. For example, a second region may not
- * be necessary for all types, and REGION_CODE_RAM / REGION_STORAGE can be
- * made mutually exclusive.
- */
-enum mpu_region {
- REGION_DATA_RAM = 0, /* For internal data RAM */
- REGION_DATA_RAM2 = 1, /* Second region for unaligned size */
- REGION_CODE_RAM = 2, /* For internal code RAM */
- REGION_CODE_RAM2 = 3, /* Second region for unaligned size */
- REGION_STORAGE = 4, /* For mapped internal storage */
- REGION_STORAGE2 = 5, /* Second region for unaligned size */
- REGION_DATA_RAM_TEXT = 6, /* Exempt region of data RAM */
- REGION_CHIP_RESERVED = 7, /* Reserved for use in chip/ */
- /* only for chips with MPU supporting 16 regions */
- REGION_UNCACHED_RAM = 8, /* For uncached data RAM */
- REGION_UNCACHED_RAM2 = 9, /* Second region for unaligned size */
- REGION_ROLLBACK = 10, /* For rollback */
-};
-
-/*
- * Configure the specific memory addresses in the the MPU
- * (Memory Protection Unit) for Nuvoton different chip series.
- */
-void system_mpu_config(void);
-
-/* The utilities and variables depend on npcx chip family */
-#if defined(CONFIG_SOC_SERIES_NPCX5) || \
- defined(CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API)
-/* Bypass for GMDA issue of ROM api utilities only on npcx5 series or if
- * CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API is defined.
- */
-void system_download_from_flash(uint32_t srcAddr, uint32_t dstAddr,
- uint32_t size, uint32_t exeAddr);
-
-/* Begin address for hibernate utility; defined in linker script */
-extern unsigned int __flash_lpfw_start;
-
-/* End address for hibernate utility; defined in linker script */
-extern unsigned int __flash_lpfw_end;
-
-/* Begin address for little FW; defined in linker script */
-extern unsigned int __flash_lplfw_start;
-
-/* End address for little FW; defined in linker script */
-extern unsigned int __flash_lplfw_end;
-#endif
-
-#endif // __CROS_EC_SYSTEM_CHIP_H_
diff --git a/zephyr/shim/chip/npcx/keyboard_raw.c b/zephyr/shim/chip/npcx/keyboard_raw.c
deleted file mode 100644
index aa075d2d56..0000000000
--- a/zephyr/shim/chip/npcx/keyboard_raw.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2020 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.
- */
-
-/* Functions needed by keyboard scanner module for Chrome EC */
-
-#include <device.h>
-#include <logging/log.h>
-#include <soc.h>
-#include <soc_gpio.h>
-#include <zephyr.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
- */
-int keyboard_raw_is_input_low(int port, int id)
-{
- const struct device *io_dev = npcx_get_gpio_dev(port);
-
- return gpio_pin_get_raw(io_dev, id) == 0;
-}
diff --git a/zephyr/shim/chip/npcx/npcx_monitor/CMakeLists.txt b/zephyr/shim/chip/npcx/npcx_monitor/CMakeLists.txt
deleted file mode 100644
index 661eb86e91..0000000000
--- a/zephyr/shim/chip/npcx/npcx_monitor/CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# The NPCX monitor source needs the chip type and flash layout information
-# provided by the board configuration. This is provided by
-# zephyr/shim/include/config_chip.h, so we need all the include directories
-# of the Zephyr application.
-zephyr_get_include_directories_for_lang(C zephyr_includes STRIP_PREFIX)
-
-# Something in the zephyr_get_compile_options_for_lang() output causes the
-# "-imacros" option to get dropped during expansion when passed to
-# target_compile_options(). Fetch the compile options directly from
-# zephyr_interface which works as expected.
-get_property(
- zephyr_compile_options
- TARGET zephyr_interface
- PROPERTY INTERFACE_COMPILE_OPTIONS
- )
-
-add_executable(npcx_monitor npcx_monitor.c)
-target_include_directories(npcx_monitor PRIVATE
- "${PLATFORM_EC}/zephyr/shim/include"
- "${PLATFORM_EC}/zephyr/shim/chip/npcx/include"
- )
-target_include_directories(npcx_monitor PRIVATE "${zephyr_includes}")
-target_compile_options(npcx_monitor PRIVATE "${zephyr_compile_options}")
-
-target_link_options(npcx_monitor BEFORE PRIVATE
- -nostdlib
- -g
- -mthumb
- -Wl,-T,${CMAKE_CURRENT_SOURCE_DIR}/npcx_monitor.ld
- )
-
-# Create the NPCX monitor binary, locate it the root of the build
-# directory as it needs to be found by the flash_util script
-set(npcx_monitor_elf ${CMAKE_CURRENT_BINARY_DIR}/npcx_monitor.elf)
-set(npcx_monitor_bin ${CMAKE_BINARY_DIR}/npcx_monitor.bin)
-
-add_custom_target(generate_npcx_monitor
- COMMAND ${CMAKE_OBJCOPY} -O binary ${npcx_monitor_elf} ${npcx_monitor_bin}
- BYPRODUCTS ${npcx_monitor_bin}
- DEPENDS npcx_monitor
- )
-
-add_dependencies(zephyr generate_npcx_monitor)
diff --git a/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c b/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c
deleted file mode 100644
index 2bd9455a91..0000000000
--- a/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * NPCX SoC spi flash update tool - monitor firmware
- */
-
-#include <stdint.h>
-#include <sys/util.h>
-#include "config_chip.h"
-#include "npcx_monitor.h"
-#include "registers.h"
-
-/*
- * TODO(b/197162681): This was copied from chip/npcx/spiflashfw but this
- * needs to be moved to Zephyr upstream
- */
-
-/*****************************************************************************/
-/* spi flash internal functions */
-void sspi_flash_pinmux(int enable)
-{
- if (enable)
- CLEAR_BIT(NPCX_DEVALT(0), NPCX_DEVALT0_NO_F_SPI);
- else
- SET_BIT(NPCX_DEVALT(0), NPCX_DEVALT0_NO_F_SPI);
-
- /* CS0/1 pinmux */
- if (enable) {
-#if (FIU_CHIP_SELECT == 1)
- SET_BIT(NPCX_DEVALT(0), NPCX_DEVALT0_F_SPI_CS1_1);
-#elif (FIU_CHIP_SELECT == 2)
- SET_BIT(NPCX_DEVALT(0), NPCX_DEVALT0_F_SPI_CS1_2);
-#endif
- } else {
- CLEAR_BIT(NPCX_DEVALT(0), NPCX_DEVALT0_F_SPI_CS1_1);
- CLEAR_BIT(NPCX_DEVALT(0), NPCX_DEVALT0_F_SPI_CS1_2);
- }
-}
-
-void sspi_flash_tristate(int enable)
-{
- if (enable) {
- /* Enable FIU pins to tri-state */
- SET_BIT(NPCX_DEVCNT, NPCX_DEVCNT_F_SPI_TRIS);
- } else {
- /* Disable FIU pins to tri-state */
- CLEAR_BIT(NPCX_DEVCNT, NPCX_DEVCNT_F_SPI_TRIS);
- }
-}
-
-void sspi_flash_execute_cmd(uint8_t code, uint8_t cts)
-{
- /* set UMA_CODE */
- NPCX_UMA_CODE = code;
- /* execute UMA flash transaction */
- NPCX_UMA_CTS = cts;
- while (IS_BIT_SET(NPCX_UMA_CTS, NPCX_UMA_CTS_EXEC_DONE))
- ;
-}
-
-void sspi_flash_cs_level(int level)
-{
- /* level is high */
- if (level) {
- /* Set chip select to high */
- SET_BIT(NPCX_UMA_ECTS, NPCX_UMA_ECTS_SW_CS1);
- } else { /* level is low */
- /* Set chip select to low */
- CLEAR_BIT(NPCX_UMA_ECTS, NPCX_UMA_ECTS_SW_CS1);
- }
-}
-
-void sspi_flash_wait_ready(void)
-{
- uint8_t mask = SPI_FLASH_SR1_BUSY;
-
- /* Chip Select down. */
- sspi_flash_cs_level(0);
- /* Command for Read status register */
- sspi_flash_execute_cmd(CMD_READ_STATUS_REG, MASK_CMD_ONLY);
- do {
- /* Read status register */
- NPCX_UMA_CTS = MASK_RD_1BYTE;
- while (IS_BIT_SET(NPCX_UMA_CTS, NPCX_UMA_CTS_EXEC_DONE))
- ;
- } while (NPCX_UMA_DB0 & mask); /* Wait for Busy clear */
- /* Chip Select high. */
- sspi_flash_cs_level(1);
-}
-
-int sspi_flash_write_enable(void)
-{
- uint8_t mask = SPI_FLASH_SR1_WEL;
- /* Write enable command */
- sspi_flash_execute_cmd(CMD_WRITE_EN, MASK_CMD_ONLY);
- /* Wait for flash is not busy */
- sspi_flash_wait_ready();
-
- if (NPCX_UMA_DB0 & mask)
- return 1;
- else
- return 0;
-}
-
-void sspi_flash_set_address(uint32_t dest_addr)
-{
- uint8_t *addr = (uint8_t *)&dest_addr;
- /* Write address */
- NPCX_UMA_AB2 = addr[2];
- NPCX_UMA_AB1 = addr[1];
- NPCX_UMA_AB0 = addr[0];
-}
-
-void sspi_flash_burst_write(unsigned int dest_addr, unsigned int bytes,
- const char *data)
-{
- unsigned int i;
- /* Chip Select down. */
- sspi_flash_cs_level(0);
- /* Set erase address */
- sspi_flash_set_address(dest_addr);
- /* Start write */
- sspi_flash_execute_cmd(CMD_FLASH_PROGRAM, MASK_CMD_WR_ADR);
- for (i = 0; i < bytes; i++) {
- sspi_flash_execute_cmd(*data, MASK_CMD_WR_ONLY);
- data++;
- }
- /* Chip Select up */
- sspi_flash_cs_level(1);
-}
-
-int sspi_flash_physical_clear_stsreg(void)
-{
- /* Disable tri-state */
- sspi_flash_tristate(0);
- /* Enable write */
- sspi_flash_write_enable();
-
- NPCX_UMA_DB0 = 0x0;
- NPCX_UMA_DB1 = 0x0;
-
- /* Write status register 1/2 */
- sspi_flash_execute_cmd(CMD_WRITE_STATUS_REG, MASK_CMD_WR_2BYTE);
-
- /* Wait writing completed */
- sspi_flash_wait_ready();
-
- /* Read status register 1/2 for checking */
- sspi_flash_execute_cmd(CMD_READ_STATUS_REG, MASK_CMD_RD_1BYTE);
- if (NPCX_UMA_DB0 != 0x00)
- return 0;
- sspi_flash_execute_cmd(CMD_READ_STATUS_REG2, MASK_CMD_RD_1BYTE);
- if (NPCX_UMA_DB0 != 0x00)
- return 0;
- /* Enable tri-state */
- sspi_flash_tristate(1);
-
- return 1;
-}
-
-void sspi_flash_physical_write(int offset, int size, const char *data)
-{
- int dest_addr = offset;
- const int sz_page = CONFIG_FLASH_WRITE_IDEAL_SIZE;
-
- /* Disable tri-state */
- sspi_flash_tristate(0);
-
- /* Write the data per CONFIG_FLASH_WRITE_IDEAL_SIZE bytes */
- for (; size >= sz_page; size -= sz_page) {
- /* Enable write */
- sspi_flash_write_enable();
- /* Burst UMA transaction */
- sspi_flash_burst_write(dest_addr, sz_page, data);
- /* Wait write completed */
- sspi_flash_wait_ready();
-
- data += sz_page;
- dest_addr += sz_page;
- }
-
- /* Handle final partial page, if any */
- if (size != 0) {
- /* Enable write */
- sspi_flash_write_enable();
- /* Burst UMA transaction */
- sspi_flash_burst_write(dest_addr, size, data);
-
- /* Wait write completed */
- sspi_flash_wait_ready();
- }
-
- /* Enable tri-state */
- sspi_flash_tristate(1);
-}
-
-void sspi_flash_physical_erase(int offset, int size)
-{
- /* Disable tri-state */
- sspi_flash_tristate(0);
-
- /* Alignment has been checked in upper layer */
- for (; size > 0; size -= NPCX_MONITOR_FLASH_ERASE_SIZE,
- offset += NPCX_MONITOR_FLASH_ERASE_SIZE) {
- /* Enable write */
- sspi_flash_write_enable();
- /* Set erase address */
- sspi_flash_set_address(offset);
- /* Start erase */
- sspi_flash_execute_cmd(CMD_SECTOR_ERASE, MASK_CMD_ADR);
-
- /* Wait erase completed */
- sspi_flash_wait_ready();
- }
-
- /* Enable tri-state */
- sspi_flash_tristate(1);
-}
-
-int sspi_flash_verify(int offset, int size, const char *data)
-{
- int i, result;
- uint8_t *ptr_flash;
- uint8_t *ptr_mram;
- uint8_t cmp_data;
-
- ptr_flash = (uint8_t *)(CONFIG_MAPPED_STORAGE_BASE + offset);
- ptr_mram = (uint8_t *)data;
- result = 1;
-
- /* Disable tri-state */
- sspi_flash_tristate(0);
-
- /* Start to verify */
- for (i = 0; i < size; i++) {
- cmp_data = ptr_mram ? ptr_mram[i] : 0xFF;
- if (ptr_flash[i] != cmp_data) {
- result = 0;
- break;
- }
- }
-
- /* Enable tri-state */
- sspi_flash_tristate(1);
- return result;
-}
-
-int sspi_flash_get_image_used(const char *fw_base)
-{
- const uint8_t *image;
- int size = MAX(CONFIG_RO_SIZE, CONFIG_RW_SIZE); /* max size is 128KB */
-
- image = (const uint8_t *)fw_base;
- /*
- * Scan backwards looking for 0xea byte, which is by definition the
- * last byte of the image. See ec.lds.S for how this is inserted at
- * the end of the image.
- */
- for (size--; size > 0 && image[size] != 0xea; size--)
- ;
-
- return size ? size + 1 : 0; /* 0xea byte IS part of the image */
-
-}
-
-/* Entry function of spi upload function */
-uint32_t __attribute__ ((section(".startup_text")))
-sspi_flash_upload(int spi_offset, int spi_size)
-{
- /*
- * Flash image has been uploaded to Code RAM
- */
- uint32_t sz_image;
- uint32_t uut_tag;
- const char *image_base;
- uint32_t *flag_upload = (uint32_t *)SPI_PROGRAMMING_FLAG;
- struct monitor_header_tag *monitor_header =
- (struct monitor_header_tag *)NPCX_MONITOR_HEADER_ADDR;
-
- *flag_upload = 0;
-
- uut_tag = monitor_header->tag;
- /* If it is UUT tag, read required parameters from header */
- if (uut_tag == NPCX_MONITOR_UUT_TAG) {
- sz_image = monitor_header->size;
- spi_offset = monitor_header->dest_addr;
- image_base = (const char *)(monitor_header->src_addr);
- } else {
- sz_image = spi_size;
- image_base = (const char *)CONFIG_PROGRAM_MEMORY_BASE;
- }
-
- /* Unlock & stop watchdog */
- NPCX_WDSDM = 0x87;
- NPCX_WDSDM = 0x61;
- NPCX_WDSDM = 0x63;
-
- /* UMA Unlock */
- CLEAR_BIT(NPCX_UMA_ECTS, NPCX_UMA_ECTS_UMA_LOCK);
-
- /*
- * If UUT is used, assuming the target is the internal flash.
- * Don't switch the pinmux and make sure bit 7 of DEVALT0 is set.
- */
- if (uut_tag == NPCX_MONITOR_UUT_TAG)
- SET_BIT(NPCX_DEVALT(0), NPCX_DEVALT0_NO_F_SPI);
- else
- /* Set pinmux first */
- sspi_flash_pinmux(1);
-
- /* Get size of image automatically */
- if (sz_image == 0)
- sz_image = sspi_flash_get_image_used(image_base);
-
- /* Clear status reg of spi flash for protection */
- if (sspi_flash_physical_clear_stsreg()) {
- /* Start to erase */
- sspi_flash_physical_erase(spi_offset, sz_image);
- /* Start to write */
- if (image_base != NULL)
- sspi_flash_physical_write(spi_offset, sz_image,
- image_base);
- /* Verify data */
- if (sspi_flash_verify(spi_offset, sz_image, image_base))
- *flag_upload |= 0x02;
- }
- if (uut_tag != NPCX_MONITOR_UUT_TAG)
- /* Disable pinmux */
- sspi_flash_pinmux(0);
-
- /* Mark we have finished upload work */
- *flag_upload |= 0x01;
-
- /* Return the status back to ROM code is required for UUT */
- if (uut_tag == NPCX_MONITOR_UUT_TAG)
- return *flag_upload;
-
- /* Infinite loop */
- for (;;)
- ;
-}
-
diff --git a/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.h b/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.h
deleted file mode 100644
index c5415d94db..0000000000
--- a/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#ifndef __CROS_EC_NPCX_MONITOR_H
-#define __CROS_EC_NPCX_MONITOR_H
-
-#include <stdint.h>
-
-#define NPCX_MONITOR_UUT_TAG 0xA5075001
-#define NPCX_MONITOR_HEADER_ADDR 0x200C3000
-
-/* Flag to record the progress of programming SPI flash */
-#define SPI_PROGRAMMING_FLAG 0x200C4000
-
-struct monitor_header_tag {
- /* offset 0x00: TAG NPCX_MONITOR_TAG */
- uint32_t tag;
- /* offset 0x04: Size of the binary being programmed (in bytes) */
- uint32_t size;
- /* offset 0x08: The RAM address of the binary to program into the SPI */
- uint32_t src_addr;
- /* offset 0x0C: The Flash address to be programmed (Absolute address) */
- uint32_t dest_addr;
- /* offset 0x10: Maximum allowable flash clock frequency */
- uint8_t max_clock;
- /* offset 0x11: SPI Flash read mode */
- uint8_t read_mode;
- /* offset 0x12: Reserved */
- uint16_t reserved;
-} __packed;
-
-#endif /* __CROS_EC_NPCX_MONITOR_H */
diff --git a/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.ld b/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.ld
deleted file mode 100644
index 03e38b0609..0000000000
--- a/zephyr/shim/chip/npcx/npcx_monitor/npcx_monitor.ld
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright 2017 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.
- *
- * NPCX SoC spi flash update tool
- */
-
-/* Memory Spaces Definitions */
-MEMORY
-{
- CODERAM (rx) : ORIGIN = 0x200C3020, LENGTH = 0xFE0
-}
-
-/*
- * The entry point is informative, for debuggers and simulators,
- * since the Cortex-M vector points to it anyway.
- */
-ENTRY(sspi_flash_upload)
-
-
-/* Sections Definitions */
-
-SECTIONS
-{
- .startup_text :
- {
- . = ALIGN(4);
- *(.startup_text ) /* Startup code */
- . = ALIGN(4);
- } >CODERAM
-
- /*
- * The program code is stored in the .text section,
- * which goes to CODERAM.
- */
- .text :
- {
- . = ALIGN(4);
- *(.text .text.*) /* all remaining code */
- *(.rodata .rodata.*) /* read-only data (constants) */
- } >CODERAM
-
- . = ALIGN(4);
- _etext = .;
-
- /*
- * This address is used by the startup code to
- * initialise the .data section.
- */
- _sidata = _etext;
-
-}
diff --git a/zephyr/shim/chip/npcx/npcx_monitor/registers.h b/zephyr/shim/chip/npcx/npcx_monitor/registers.h
deleted file mode 100644
index cc0a6b96fe..0000000000
--- a/zephyr/shim/chip/npcx/npcx_monitor/registers.h
+++ /dev/null
@@ -1,360 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- *
- * Register map for NPCX processor
- *
- * This is meant to be temporary until the NPCX monitor support is moved
- * to Zephyr upstream
- */
-
-#ifndef __CROS_EC_REGISTERS_H
-#define __CROS_EC_REGISTERS_H
-
-/*
- * The monitor code doesn't build cleanly under the Zephyr environment if
- * include/common.h is included. Replicate the register access macros until
- * this code is moved upstream.
- */
-
-/* Macros to access registers */
-#define REG64_ADDR(addr) ((volatile uint64_t *)(addr))
-#define REG32_ADDR(addr) ((volatile uint32_t *)(addr))
-#define REG16_ADDR(addr) ((volatile uint16_t *)(addr))
-#define REG8_ADDR(addr) ((volatile uint8_t *)(addr))
-
-#define REG64(addr) (*REG64_ADDR(addr))
-#define REG32(addr) (*REG32_ADDR(addr))
-#define REG16(addr) (*REG16_ADDR(addr))
-#define REG8(addr) (*REG8_ADDR(addr))
-
-/* Standard macros / definitions */
-#define GENERIC_MAX(x, y) ((x) > (y) ? (x) : (y))
-#define GENERIC_MIN(x, y) ((x) < (y) ? (x) : (y))
-#ifndef MAX
-#define MAX(a, b) \
- ({ \
- __typeof__(a) temp_a = (a); \
- __typeof__(b) temp_b = (b); \
- \
- GENERIC_MAX(temp_a, temp_b); \
- })
-#endif
-#ifndef MIN
-#define MIN(a, b) \
- ({ \
- __typeof__(a) temp_a = (a); \
- __typeof__(b) temp_b = (b); \
- \
- GENERIC_MIN(temp_a, temp_b); \
- })
-#endif
-#ifndef NULL
-#define NULL ((void *)0)
-#endif
-
-/******************************************************************************/
-/*
- * Macro Functions
- */
-/* Bit functions */
-#define SET_BIT(reg, bit) ((reg) |= (0x1 << (bit)))
-#define CLEAR_BIT(reg, bit) ((reg) &= (~(0x1 << (bit))))
-#define IS_BIT_SET(reg, bit) (((reg) >> (bit)) & (0x1))
-#define UPDATE_BIT(reg, bit, cond) { if (cond) \
- SET_BIT(reg, bit); \
- else \
- CLEAR_BIT(reg, bit); }
-/* Field functions */
-#define GET_POS_FIELD(pos, size) pos
-#define GET_SIZE_FIELD(pos, size) size
-#define FIELD_POS(field) GET_POS_##field
-#define FIELD_SIZE(field) GET_SIZE_##field
-/* Read field functions */
-#define GET_FIELD(reg, field) \
- _GET_FIELD_(reg, FIELD_POS(field), FIELD_SIZE(field))
-#define _GET_FIELD_(reg, f_pos, f_size) (((reg)>>(f_pos)) & ((1<<(f_size))-1))
-/* Write field functions */
-#define SET_FIELD(reg, field, value) \
- _SET_FIELD_(reg, FIELD_POS(field), FIELD_SIZE(field), value)
-#define _SET_FIELD_(reg, f_pos, f_size, value) \
- ((reg) = ((reg) & (~(((1 << (f_size))-1) << (f_pos)))) \
- | ((value) << (f_pos)))
-
-
-/* NPCX7 & NPCX9 */
-#define NPCX_DEVALT(n) REG8(NPCX_SCFG_BASE_ADDR + 0x010 + (n))
-
-/******************************************************************************/
-/*
- * NPCX (Nuvoton M4 EC) Register Definitions
- */
-
-/* Modules Map */
-#define NPCX_ESPI_BASE_ADDR 0x4000A000
-#define NPCX_MDC_BASE_ADDR 0x4000C000
-#define NPCX_PMC_BASE_ADDR 0x4000D000
-#define NPCX_SIB_BASE_ADDR 0x4000E000
-#define NPCX_SHI_BASE_ADDR 0x4000F000
-#define NPCX_SHM_BASE_ADDR 0x40010000
-#define NPCX_GDMA_BASE_ADDR 0x40011000
-#define NPCX_FIU_BASE_ADDR 0x40020000
-#define NPCX_KBSCAN_REGS_BASE 0x400A3000
-#define NPCX_WOV_BASE_ADDR 0x400A4000
-#define NPCX_APM_BASE_ADDR 0x400A4800
-#define NPCX_GLUE_REGS_BASE 0x400A5000
-#define NPCX_BBRAM_BASE_ADDR 0x400AF000
-#define NPCX_PS2_BASE_ADDR 0x400B1000
-#define NPCX_HFCG_BASE_ADDR 0x400B5000
-#define NPCX_LFCG_BASE_ADDR 0x400B5100
-#define NPCX_FMUL2_BASE_ADDR 0x400B5200
-#define NPCX_MTC_BASE_ADDR 0x400B7000
-#define NPCX_MSWC_BASE_ADDR 0x400C1000
-#define NPCX_SCFG_BASE_ADDR 0x400C3000
-#define NPCX_KBC_BASE_ADDR 0x400C7000
-#define NPCX_ADC_BASE_ADDR 0x400D1000
-#define NPCX_SPI_BASE_ADDR 0x400D2000
-#define NPCX_PECI_BASE_ADDR 0x400D4000
-#define NPCX_TWD_BASE_ADDR 0x400D8000
-
-/* Multi-Modules Map */
-#define NPCX_PWM_BASE_ADDR(mdl) (0x40080000 + ((mdl) * 0x2000L))
-#define NPCX_GPIO_BASE_ADDR(mdl) (0x40081000 + ((mdl) * 0x2000L))
-#define NPCX_ITIM_BASE_ADDR(mdl) (0x400B0000 + ((mdl) * 0x2000L))
-#define NPCX_MIWU_BASE_ADDR(mdl) (0x400BB000 + ((mdl) * 0x2000L))
-#define NPCX_MFT_BASE_ADDR(mdl) (0x400E1000 + ((mdl) * 0x2000L))
-#define NPCX_PM_CH_BASE_ADDR(mdl) (0x400C9000 + ((mdl) * 0x2000L))
-
-
-/******************************************************************************/
-/* System Configuration (SCFG) Registers */
-#define NPCX_DEVCNT REG8(NPCX_SCFG_BASE_ADDR + 0x000)
-#define NPCX_STRPST REG8(NPCX_SCFG_BASE_ADDR + 0x001)
-#define NPCX_RSTCTL REG8(NPCX_SCFG_BASE_ADDR + 0x002)
-#define NPCX_DEV_CTL4 REG8(NPCX_SCFG_BASE_ADDR + 0x006)
-#define NPCX_LFCGCALCNT REG8(NPCX_SCFG_BASE_ADDR + 0x021)
-#define NPCX_PUPD_EN0 REG8(NPCX_SCFG_BASE_ADDR + 0x028)
-#define NPCX_PUPD_EN1 REG8(NPCX_SCFG_BASE_ADDR + 0x029)
-#define NPCX_SCFG_VER REG8(NPCX_SCFG_BASE_ADDR + 0x02F)
-
-#define TEST_BKSL REG8(NPCX_SCFG_BASE_ADDR + 0x037)
-#define TEST0 REG8(NPCX_SCFG_BASE_ADDR + 0x038)
-#define BLKSEL 0
-
-/* SCFG register fields */
-#define NPCX_DEVCNT_F_SPI_TRIS 6
-#define NPCX_DEVCNT_HIF_TYP_SEL_FIELD FIELD(2, 2)
-#define NPCX_DEVCNT_JEN1_HEN 5
-#define NPCX_DEVCNT_JEN0_HEN 4
-#define NPCX_STRPST_TRIST 1
-#define NPCX_STRPST_TEST 2
-#define NPCX_STRPST_JEN1 4
-#define NPCX_STRPST_JEN0 5
-#define NPCX_STRPST_SPI_COMP 7
-#define NPCX_RSTCTL_VCC1_RST_STS 0
-#define NPCX_RSTCTL_DBGRST_STS 1
-#define NPCX_RSTCTL_VCC1_RST_SCRATCH 3
-#define NPCX_RSTCTL_LRESET_PLTRST_MODE 5
-#define NPCX_RSTCTL_HIPRST_MODE 6
-#define NPCX_DEV_CTL4_F_SPI_SLLK 2
-#define NPCX_DEV_CTL4_SPI_SP_SEL 4
-#define NPCX_DEV_CTL4_WP_IF 5
-#define NPCX_DEV_CTL4_VCC1_RST_LK 6
-#define NPCX_DEVPU0_I2C0_0_PUE 0
-#define NPCX_DEVPU0_I2C0_1_PUE 1
-#define NPCX_DEVPU0_I2C1_0_PUE 2
-#define NPCX_DEVPU0_I2C2_0_PUE 4
-#define NPCX_DEVPU0_I2C3_0_PUE 6
-#define NPCX_DEVPU1_F_SPI_PUD_EN 7
-
-/* DEVALT */
-/* pin-mux for SPI/FIU */
-#define NPCX_DEVALT0_SPIP_SL 0
-#define NPCX_DEVALT0_GPIO_NO_SPIP 3
-#define NPCX_DEVALT0_F_SPI_CS1_2 4
-#define NPCX_DEVALT0_F_SPI_CS1_1 5
-#define NPCX_DEVALT0_F_SPI_QUAD 6
-#define NPCX_DEVALT0_NO_F_SPI 7
-
-/******************************************************************************/
-/* Flash Interface Unit (FIU) Registers */
-#define NPCX_FIU_CFG REG8(NPCX_FIU_BASE_ADDR + 0x000)
-#define NPCX_BURST_CFG REG8(NPCX_FIU_BASE_ADDR + 0x001)
-#define NPCX_RESP_CFG REG8(NPCX_FIU_BASE_ADDR + 0x002)
-#define NPCX_SPI_FL_CFG REG8(NPCX_FIU_BASE_ADDR + 0x014)
-#define NPCX_UMA_CODE REG8(NPCX_FIU_BASE_ADDR + 0x016)
-#define NPCX_UMA_AB0 REG8(NPCX_FIU_BASE_ADDR + 0x017)
-#define NPCX_UMA_AB1 REG8(NPCX_FIU_BASE_ADDR + 0x018)
-#define NPCX_UMA_AB2 REG8(NPCX_FIU_BASE_ADDR + 0x019)
-#define NPCX_UMA_DB0 REG8(NPCX_FIU_BASE_ADDR + 0x01A)
-#define NPCX_UMA_DB1 REG8(NPCX_FIU_BASE_ADDR + 0x01B)
-#define NPCX_UMA_DB2 REG8(NPCX_FIU_BASE_ADDR + 0x01C)
-#define NPCX_UMA_DB3 REG8(NPCX_FIU_BASE_ADDR + 0x01D)
-#define NPCX_UMA_CTS REG8(NPCX_FIU_BASE_ADDR + 0x01E)
-#define NPCX_UMA_ECTS REG8(NPCX_FIU_BASE_ADDR + 0x01F)
-#define NPCX_UMA_DB0_3 REG32(NPCX_FIU_BASE_ADDR + 0x020)
-#define NPCX_FIU_RD_CMD REG8(NPCX_FIU_BASE_ADDR + 0x030)
-#define NPCX_FIU_DMM_CYC REG8(NPCX_FIU_BASE_ADDR + 0x032)
-#define NPCX_FIU_EXT_CFG REG8(NPCX_FIU_BASE_ADDR + 0x033)
-#define NPCX_FIU_UMA_AB0_3 REG32(NPCX_FIU_BASE_ADDR + 0x034)
-
-/* FIU register fields */
-#define NPCX_RESP_CFG_IAD_EN 0
-#define NPCX_RESP_CFG_DEV_SIZE_EX 2
-#define NPCX_UMA_CTS_A_SIZE 3
-#define NPCX_UMA_CTS_C_SIZE 4
-#define NPCX_UMA_CTS_RD_WR 5
-#define NPCX_UMA_CTS_DEV_NUM 6
-#define NPCX_UMA_CTS_EXEC_DONE 7
-#define NPCX_UMA_ECTS_SW_CS0 0
-#define NPCX_UMA_ECTS_SW_CS1 1
-#define NPCX_UMA_ECTS_SEC_CS 2
-#define NPCX_UMA_ECTS_UMA_LOCK 3
-
-/******************************************************************************/
-/* KBC Registers */
-#define NPCX_HICTRL REG8(NPCX_KBC_BASE_ADDR + 0x000)
-#define NPCX_HIIRQC REG8(NPCX_KBC_BASE_ADDR + 0x002)
-#define NPCX_HIKMST REG8(NPCX_KBC_BASE_ADDR + 0x004)
-#define NPCX_HIKDO REG8(NPCX_KBC_BASE_ADDR + 0x006)
-#define NPCX_HIMDO REG8(NPCX_KBC_BASE_ADDR + 0x008)
-#define NPCX_KBCVER REG8(NPCX_KBC_BASE_ADDR + 0x009)
-#define NPCX_HIKMDI REG8(NPCX_KBC_BASE_ADDR + 0x00A)
-#define NPCX_SHIKMDI REG8(NPCX_KBC_BASE_ADDR + 0x00B)
-
-/* KBC register field */
-#define NPCX_HICTRL_OBFKIE 0 /* Automatic Serial IRQ1 for KBC */
-#define NPCX_HICTRL_OBFMIE 1 /* Automatic Serial IRQ12 for Mouse*/
-#define NPCX_HICTRL_OBECIE 2 /* KBC OBE interrupt enable */
-#define NPCX_HICTRL_IBFCIE 3 /* KBC IBF interrupt enable */
-#define NPCX_HICTRL_PMIHIE 4 /* Automatic Serial IRQ11 for PMC1 */
-#define NPCX_HICTRL_PMIOCIE 5 /* PMC1 OBE interrupt enable */
-#define NPCX_HICTRL_PMICIE 6 /* PMC1 IBF interrupt enable */
-#define NPCX_HICTRL_FW_OBF 7 /* Firmware control over OBF */
-
-#define NPCX_HIKMST_OBF 0 /* KB output buffer is full */
-
-/******************************************************************************/
-/* Timer Watch Dog (TWD) Registers */
-#define NPCX_TWCFG REG8(NPCX_TWD_BASE_ADDR + 0x000)
-#define NPCX_TWCP REG8(NPCX_TWD_BASE_ADDR + 0x002)
-#define NPCX_TWDT0 REG16(NPCX_TWD_BASE_ADDR + 0x004)
-#define NPCX_T0CSR REG8(NPCX_TWD_BASE_ADDR + 0x006)
-#define NPCX_WDCNT REG8(NPCX_TWD_BASE_ADDR + 0x008)
-#define NPCX_WDSDM REG8(NPCX_TWD_BASE_ADDR + 0x00A)
-#define NPCX_TWMT0 REG16(NPCX_TWD_BASE_ADDR + 0x00C)
-#define NPCX_TWMWD REG8(NPCX_TWD_BASE_ADDR + 0x00E)
-#define NPCX_WDCP REG8(NPCX_TWD_BASE_ADDR + 0x010)
-
-/* TWD register fields */
-#define NPCX_TWCFG_LTWCFG 0
-#define NPCX_TWCFG_LTWCP 1
-#define NPCX_TWCFG_LTWDT0 2
-#define NPCX_TWCFG_LWDCNT 3
-#define NPCX_TWCFG_WDCT0I 4
-#define NPCX_TWCFG_WDSDME 5
-#define NPCX_TWCFG_WDRST_MODE 6
-#define NPCX_TWCFG_WDC2POR 7
-#define NPCX_T0CSR_RST 0
-#define NPCX_T0CSR_TC 1
-#define NPCX_T0CSR_WDLTD 3
-#define NPCX_T0CSR_WDRST_STS 4
-#define NPCX_T0CSR_WD_RUN 5
-#define NPCX_T0CSR_TESDIS 7
-
-/******************************************************************************/
-/* SPI Register */
-#define NPCX_SPI_DATA REG16(NPCX_SPI_BASE_ADDR + 0x00)
-#define NPCX_SPI_CTL1 REG16(NPCX_SPI_BASE_ADDR + 0x02)
-#define NPCX_SPI_STAT REG8(NPCX_SPI_BASE_ADDR + 0x04)
-
-/* SPI register fields */
-#define NPCX_SPI_CTL1_SPIEN 0
-#define NPCX_SPI_CTL1_SNM 1
-#define NPCX_SPI_CTL1_MOD 2
-#define NPCX_SPI_CTL1_EIR 5
-#define NPCX_SPI_CTL1_EIW 6
-#define NPCX_SPI_CTL1_SCM 7
-#define NPCX_SPI_CTL1_SCIDL 8
-#define NPCX_SPI_CTL1_SCDV 9
-#define NPCX_SPI_STAT_BSY 0
-#define NPCX_SPI_STAT_RBF 1
-
-/******************************************************************************/
-/* Flash Utiltiy definition */
-/*
- * Flash commands for the W25Q16CV SPI flash
- */
-#define CMD_READ_ID 0x9F
-#define CMD_READ_MAN_DEV_ID 0x90
-#define CMD_WRITE_EN 0x06
-#define CMD_WRITE_STATUS 0x50
-#define CMD_READ_STATUS_REG 0x05
-#define CMD_READ_STATUS_REG2 0x35
-#define CMD_WRITE_STATUS_REG 0x01
-#define CMD_FLASH_PROGRAM 0x02
-#define CMD_SECTOR_ERASE 0x20
-#define CMD_BLOCK_32K_ERASE 0x52
-#define CMD_BLOCK_64K_ERASE 0xd8
-#define CMD_PROGRAM_UINT_SIZE 0x08
-#define CMD_PAGE_SIZE 0x00
-#define CMD_READ_ID_TYPE 0x47
-#define CMD_FAST_READ 0x0B
-
-/*
- * Status registers for the W25Q16CV SPI flash
- */
-#define SPI_FLASH_SR2_SUS BIT(7)
-#define SPI_FLASH_SR2_CMP BIT(6)
-#define SPI_FLASH_SR2_LB3 BIT(5)
-#define SPI_FLASH_SR2_LB2 BIT(4)
-#define SPI_FLASH_SR2_LB1 BIT(3)
-#define SPI_FLASH_SR2_QE BIT(1)
-#define SPI_FLASH_SR2_SRP1 BIT(0)
-#define SPI_FLASH_SR1_SRP0 BIT(7)
-#define SPI_FLASH_SR1_SEC BIT(6)
-#define SPI_FLASH_SR1_TB BIT(5)
-#define SPI_FLASH_SR1_BP2 BIT(4)
-#define SPI_FLASH_SR1_BP1 BIT(3)
-#define SPI_FLASH_SR1_BP0 BIT(2)
-#define SPI_FLASH_SR1_WEL BIT(1)
-#define SPI_FLASH_SR1_BUSY BIT(0)
-
-
-/* 0: F_CS0 1: F_CS1_1(GPIO86) 2:F_CS1_2(GPIOA6) */
-#define FIU_CHIP_SELECT 0
-/* Create UMA control mask */
-#define MASK(bit) (0x1 << (bit))
-#define A_SIZE 0x03 /* 0: No ADR field 1: 3-bytes ADR field */
-#define C_SIZE 0x04 /* 0: 1-Byte CMD field 1:No CMD field */
-#define RD_WR 0x05 /* 0: Read 1: Write */
-#define DEV_NUM 0x06 /* 0: PVT is used 1: SHD is used */
-#define EXEC_DONE 0x07
-#define D_SIZE_1 0x01
-#define D_SIZE_2 0x02
-#define D_SIZE_3 0x03
-#define D_SIZE_4 0x04
-#define FLASH_SEL MASK(DEV_NUM)
-
-#define MASK_CMD_ONLY (MASK(EXEC_DONE) | FLASH_SEL)
-#define MASK_CMD_ADR (MASK(EXEC_DONE) | FLASH_SEL | MASK(A_SIZE))
-#define MASK_CMD_ADR_WR (MASK(EXEC_DONE) | FLASH_SEL | MASK(RD_WR) \
- |MASK(A_SIZE) | D_SIZE_1)
-#define MASK_RD_1BYTE (MASK(EXEC_DONE) | FLASH_SEL | MASK(C_SIZE) | D_SIZE_1)
-#define MASK_RD_2BYTE (MASK(EXEC_DONE) | FLASH_SEL | MASK(C_SIZE) | D_SIZE_2)
-#define MASK_RD_3BYTE (MASK(EXEC_DONE) | FLASH_SEL | MASK(C_SIZE) | D_SIZE_3)
-#define MASK_RD_4BYTE (MASK(EXEC_DONE) | FLASH_SEL | MASK(C_SIZE) | D_SIZE_4)
-#define MASK_CMD_RD_1BYTE (MASK(EXEC_DONE) | FLASH_SEL | D_SIZE_1)
-#define MASK_CMD_RD_2BYTE (MASK(EXEC_DONE) | FLASH_SEL | D_SIZE_2)
-#define MASK_CMD_RD_3BYTE (MASK(EXEC_DONE) | FLASH_SEL | D_SIZE_3)
-#define MASK_CMD_RD_4BYTE (MASK(EXEC_DONE) | FLASH_SEL | D_SIZE_4)
-#define MASK_CMD_WR_ONLY (MASK(EXEC_DONE) | FLASH_SEL | MASK(RD_WR))
-#define MASK_CMD_WR_1BYTE (MASK(EXEC_DONE) | FLASH_SEL | MASK(RD_WR) \
- | MASK(C_SIZE) | D_SIZE_1)
-#define MASK_CMD_WR_2BYTE (MASK(EXEC_DONE) | FLASH_SEL | MASK(RD_WR) \
- | MASK(C_SIZE) | D_SIZE_2)
-#define MASK_CMD_WR_ADR (MASK(EXEC_DONE) | FLASH_SEL | MASK(RD_WR) \
- | MASK(A_SIZE))
-
-
-#endif /* __CROS_EC_REGISTERS_H */
diff --git a/zephyr/shim/chip/npcx/power_policy.c b/zephyr/shim/chip/npcx/power_policy.c
deleted file mode 100644
index 803ac51e9b..0000000000
--- a/zephyr/shim/chip/npcx/power_policy.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <pm/pm.h>
-#include <soc.h>
-
-#include "console.h"
-#include "cros_version.h"
-#include "system.h"
-
-static const struct pm_state_info pm_min_residency[] =
- PM_STATE_INFO_DT_ITEMS_LIST(DT_NODELABEL(cpu0));
-
-/* CROS PM policy handler */
-struct pm_state_info pm_policy_next_state(int32_t ticks)
-{
- /* Deep sleep is allowed and console is not in use. */
- if (DEEP_SLEEP_ALLOWED != 0 && !npcx_power_console_is_in_use()) {
- for (int i = ARRAY_SIZE(pm_min_residency) - 1; i >= 0; i--) {
- /* Find suitable power state by residency time */
- if (ticks == K_TICKS_FOREVER ||
- ticks >= k_us_to_ticks_ceil32(
- pm_min_residency[i]
- .min_residency_us)) {
- return pm_min_residency[i];
- }
- }
- }
-
- return (struct pm_state_info){ PM_STATE_ACTIVE, 0, 0 };
-}
diff --git a/zephyr/shim/chip/npcx/shi.c b/zephyr/shim/chip/npcx/shi.c
deleted file mode 100644
index 22b153a806..0000000000
--- a/zephyr/shim/chip/npcx/shi.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Functions needed by Serial Host Interface module for Chrome EC */
-
-#include <device.h>
-#include <dt-bindings/clock/npcx_clock.h>
-#include <logging/log.h>
-#include <soc.h>
-#include <zephyr.h>
-
-#include "chipset.h"
-#include "drivers/cros_shi.h"
-#include "hooks.h"
-#include "host_command.h"
-#include "system.h"
-
-LOG_MODULE_REGISTER(shim_cros_shi, LOG_LEVEL_DBG);
-
-#define SHI_NODE DT_NODELABEL(shi)
-
-static void shi_enable(void)
-{
- const struct device *cros_shi_dev = DEVICE_DT_GET(SHI_NODE);
-
- if (!device_is_ready(cros_shi_dev)) {
- LOG_ERR("Error: device %s is not ready", cros_shi_dev->name);
- return;
- }
-
- LOG_INF("%s", __func__);
- cros_shi_enable(cros_shi_dev);
-}
-#ifdef CONFIG_CHIPSET_RESUME_INIT_HOOK
-DECLARE_HOOK(HOOK_CHIPSET_RESUME_INIT, shi_enable, HOOK_PRIO_DEFAULT);
-#else
-DECLARE_HOOK(HOOK_CHIPSET_RESUME, shi_enable, HOOK_PRIO_DEFAULT);
-#endif
-
-static void shi_reenable_on_sysjump(void)
-{
- if (IS_ENABLED(CONFIG_CROS_SHI_NPCX_DEBUG) ||
- (system_jumped_late() && chipset_in_state(CHIPSET_STATE_ON))) {
- shi_enable();
- }
-}
-/* Call hook after chipset sets initial power state */
-DECLARE_HOOK(HOOK_INIT, shi_reenable_on_sysjump, HOOK_PRIO_INIT_CHIPSET + 1);
-
-static void shi_disable(void)
-{
- const struct device *cros_shi_dev = DEVICE_DT_GET(SHI_NODE);
-
- if (!device_is_ready(cros_shi_dev)) {
- LOG_ERR("Error: device %s is not ready", cros_shi_dev->name);
- return;
- }
-
- LOG_INF("%s", __func__);
- cros_shi_disable(cros_shi_dev);
-}
-#ifdef CONFIG_CHIPSET_RESUME_INIT_HOOK
-DECLARE_HOOK(HOOK_CHIPSET_SUSPEND_COMPLETE, shi_disable, HOOK_PRIO_DEFAULT);
-#else
-DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, shi_disable, HOOK_PRIO_DEFAULT);
-#endif
-DECLARE_HOOK(HOOK_SYSJUMP, shi_disable, HOOK_PRIO_DEFAULT);
-
-/* Get protocol information */
-static enum ec_status shi_get_protocol_info(struct host_cmd_handler_args *args)
-{
- struct ec_response_get_protocol_info *r = args->response;
-
- memset(r, '\0', sizeof(*r));
- r->protocol_versions = BIT(3);
- r->max_request_packet_size = CONFIG_CROS_SHI_MAX_REQUEST;
- r->max_response_packet_size = CONFIG_CROS_SHI_MAX_RESPONSE;
- r->flags = EC_PROTOCOL_INFO_IN_PROGRESS_SUPPORTED;
-
- args->response_size = sizeof(*r);
-
- return EC_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_GET_PROTOCOL_INFO, shi_get_protocol_info,
- EC_VER_MASK(0));
diff --git a/zephyr/shim/chip/npcx/system.c b/zephyr/shim/chip/npcx/system.c
deleted file mode 100644
index 9809e138d5..0000000000
--- a/zephyr/shim/chip/npcx/system.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <drivers/bbram.h>
-#include <logging/log.h>
-
-#include "system.h"
-#include "system_chip.h"
-
-LOG_MODULE_REGISTER(shim_npcx_system, LOG_LEVEL_ERR);
-
-static void chip_bbram_status_check(void)
-{
- const struct device *bbram_dev;
- int res;
-
- bbram_dev = DEVICE_DT_GET(DT_NODELABEL(bbram));
- if (!device_is_ready(bbram_dev)) {
- LOG_ERR("Error: device %s is not ready", bbram_dev->name);
- return;
- }
-
- res = bbram_check_invalid(bbram_dev);
- if (res != 0 && res != -ENOTSUP)
- LOG_INF("VBAT power drop!");
-
- res = bbram_check_standby_power(bbram_dev);
- if (res != 0 && res != -ENOTSUP)
- LOG_INF("VSBY power drop!");
-
- res = bbram_check_power(bbram_dev);
- if (res != 0 && res != -ENOTSUP)
- LOG_INF("VCC1 power drop!");
-}
-
-/*
- * Configure address 0x40001600 (Low Power RAM) in the the MPU
- * (Memory Protection Unit) as a "regular" memory
- */
-void system_mpu_config(void)
-{
- if (!IS_ENABLED(CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API))
- return;
-
- /*
- * npcx9 Rev.1 has the problem for download_from_flash API.
- * Workaround it by implementing the system_download_from_flash function
- * in the suspend RAM. The functions will do the same, but will provide
- * a software solution similar to what's done in the npcx5.
- */
- /* Enable MPU */
- CPU_MPU_CTRL = 0x7;
-
- /* Create a new MPU Region to allow execution from low-power ram */
- CPU_MPU_RNR = REGION_CHIP_RESERVED;
- CPU_MPU_RASR = CPU_MPU_RASR & 0xFFFFFFFE; /* Disable region */
- CPU_MPU_RBAR = CONFIG_LPRAM_BASE; /* Set region base address */
- /*
- * Set region size & attribute and enable region
- * [31:29] - Reserved.
- * [28] - XN (Execute Never) = 0
- * [27] - Reserved.
- * [26:24] - AP = 011 (Full access)
- * [23:22] - Reserved.
- * [21:19,18,17,16] - TEX,S,C,B = 001000 (Normal memory)
- * [15:8] - SRD = 0 (Subregions enabled)
- * [7:6] - Reserved.
- * [5:1] - SIZE = 01001 (1K)
- * [0] - ENABLE = 1 (enabled)
- */
- CPU_MPU_RASR = 0x03080013;
-}
-
-static int chip_system_init(const struct device *unused)
-{
- ARG_UNUSED(unused);
-
- /*
- * Check BBRAM power status.
- */
- chip_bbram_status_check();
-
- system_mpu_config();
-
- return 0;
-}
-/*
- * The priority should be lower than CROS_BBRAM_NPCX_INIT_PRIORITY.
- */
-#if (CONFIG_CROS_SYSTEM_NPCX_PRE_INIT_PRIORITY <= CONFIG_BBRAM_INIT_PRIORITY)
-#error CONFIG_CROS_SYSTEM_NPCX_PRE_INIT_PRIORITY must greater than \
- CONFIG_BBRAM_INIT_PRIORITY
-#endif
-SYS_INIT(chip_system_init, PRE_KERNEL_1,
- CONFIG_CROS_SYSTEM_NPCX_PRE_INIT_PRIORITY);
diff --git a/zephyr/shim/chip/npcx/system_download_from_flash.c b/zephyr/shim/chip/npcx/system_download_from_flash.c
deleted file mode 100644
index 28ec22962c..0000000000
--- a/zephyr/shim/chip/npcx/system_download_from_flash.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-#include <dt-bindings/clock/npcx_clock.h>
-#include <stdnoreturn.h>
-#include <sys/__assert.h>
-
-#include "common.h"
-#include "soc.h"
-#include "system_chip.h"
-
-/* Modules Map */
-#define NPCX_PMC_BASE_ADDR 0x4000D000
-#define NPCX_GDMA_BASE_ADDR 0x40011000
-
-/******************************************************************************/
-/* GDMA (General DMA) Registers */
-#define NPCX_GDMA_CTL REG32(NPCX_GDMA_BASE_ADDR + 0x000)
-#define NPCX_GDMA_SRCB REG32(NPCX_GDMA_BASE_ADDR + 0x004)
-#define NPCX_GDMA_DSTB REG32(NPCX_GDMA_BASE_ADDR + 0x008)
-#define NPCX_GDMA_TCNT REG32(NPCX_GDMA_BASE_ADDR + 0x00C)
-
-/******************************************************************************/
-/* GDMA register fields */
-#define NPCX_GDMA_CTL_GDMAEN 0
-#define NPCX_GDMA_CTL_GDMAMS FIELD(2, 2)
-#define NPCX_GDMA_CTL_DADIR 4
-#define NPCX_GDMA_CTL_SADIR 5
-#define NPCX_GDMA_CTL_SAFIX 7
-#define NPCX_GDMA_CTL_SIEN 8
-#define NPCX_GDMA_CTL_BME 9
-#define NPCX_GDMA_CTL_SBMS 11
-#define NPCX_GDMA_CTL_TWS FIELD(12, 2)
-#define NPCX_GDMA_CTL_DM 15
-#define NPCX_GDMA_CTL_SOFTREQ 16
-#define NPCX_GDMA_CTL_TC 18
-#define NPCX_GDMA_CTL_GDMAERR 20
-#define NPCX_GDMA_CTL_BLOCK_BUG_CORRECTION_DISABLE 26
-
-/******************************************************************************/
-/* Low Power RAM definitions */
-#define NPCX_LPRAM_CTRL REG32(0x40001044)
-
-/******************************************************************************/
-/* Sysjump utilities in low power ram for npcx series. */
-noreturn void __keep __attribute__ ((section(".lowpower_ram2")))
-__start_gdma(uint32_t exeAddr)
-{
- /* Enable GDMA now */
- SET_BIT(NPCX_GDMA_CTL, NPCX_GDMA_CTL_GDMAEN);
-
- /* Start GDMA */
- SET_BIT(NPCX_GDMA_CTL, NPCX_GDMA_CTL_SOFTREQ);
-
- /* Wait for transfer to complete/fail */
- while (!IS_BIT_SET(NPCX_GDMA_CTL, NPCX_GDMA_CTL_TC) &&
- !IS_BIT_SET(NPCX_GDMA_CTL, NPCX_GDMA_CTL_GDMAERR))
- ;
-
- /* Disable GDMA now */
- CLEAR_BIT(NPCX_GDMA_CTL, NPCX_GDMA_CTL_GDMAEN);
-
- /*
- * Failure occurs during GMDA transaction. Let watchdog issue and
- * boot from RO region again.
- */
- if (IS_BIT_SET(NPCX_GDMA_CTL, NPCX_GDMA_CTL_GDMAERR))
- while (1)
- ;
-
- /*
- * Jump to the exeAddr address if needed. Setting bit 0 of address to
- * indicate it's a thumb branch for cortex-m series CPU.
- */
- ((void (*)(void))(exeAddr | 0x01))();
-
- /* Should never get here */
- while (1)
- ;
-}
-
-/* Begin address of Suspend RAM for little FW (GDMA utilities). */
-#define LFW_OFFSET 0x160
-uintptr_t __lpram_lfw_start = CONFIG_LPRAM_BASE + LFW_OFFSET;
-
-void system_download_from_flash(uint32_t srcAddr, uint32_t dstAddr,
- uint32_t size, uint32_t exeAddr)
-{
- int i;
- uint8_t chunkSize = 16; /* 4 data burst mode. ie.16 bytes */
- /*
- * GDMA utility in Suspend RAM. Setting bit 0 of address to indicate
- * it's a thumb branch for cortex-m series CPU.
- */
- void (*__start_gdma_in_lpram)(uint32_t) =
- (void(*)(uint32_t))(__lpram_lfw_start | 0x01);
-
- /*
- * Before enabling burst mode for better performance of GDMA, it's
- * important to make sure srcAddr, dstAddr and size of transactions
- * are 16 bytes aligned in case failure occurs.
- */
- __ASSERT_NO_MSG((size % chunkSize) == 0 && (srcAddr % chunkSize) == 0 &&
- (dstAddr % chunkSize) == 0);
-
- /* Check valid address for jumpiing */
- __ASSERT_NO_MSG(exeAddr != 0x0);
-
- /* Enable power for the Low Power RAM */
- CLEAR_BIT(NPCX_PWDWN_CTL(NPCX_PMC_BASE_ADDR, NPCX_PWDWN_CTL6), 6);
-
- /* Enable Low Power RAM */
- NPCX_LPRAM_CTRL = 1;
-
- /*
- * Initialize GDMA for flash reading.
- * [31:21] - Reserved.
- * [20] - GDMAERR = 0 (Indicate GMDA transfer error)
- * [19] - Reserved.
- * [18] - TC = 0 (Terminal Count. Indicate operation is end.)
- * [17] - Reserved.
- * [16] - SOFTREQ = 0 (Don't trigger here)
- * [15] - DM = 0 (Set normal demand mode)
- * [14] - Reserved.
- * [13:12] - TWS. = 10 (One double-word for every GDMA transaction)
- * [11:10] - Reserved.
- * [9] - BME = 1 (4-data ie.16 bytes - Burst mode enable)
- * [8] - SIEN = 0 (Stop interrupt disable)
- * [7] - SAFIX = 0 (Fixed source address)
- * [6] - Reserved.
- * [5] - SADIR = 0 (Source address incremented)
- * [4] - DADIR = 0 (Destination address incremented)
- * [3:2] - GDMAMS = 00 (Software mode)
- * [1] - Reserved.
- * [0] - ENABLE = 0 (Don't enable yet)
- */
- NPCX_GDMA_CTL = 0x00002200;
-
- /* Set source base address */
- NPCX_GDMA_SRCB = CONFIG_MAPPED_STORAGE_BASE + srcAddr;
-
- /* Set destination base address */
- NPCX_GDMA_DSTB = dstAddr;
-
- /* Set number of transfers */
- NPCX_GDMA_TCNT = (size / chunkSize);
-
- /* Clear Transfer Complete event */
- SET_BIT(NPCX_GDMA_CTL, NPCX_GDMA_CTL_TC);
-
- /* Copy the __start_gdma_in_lpram instructions to LPRAM */
- for (i = 0; i < &__flash_lplfw_end - &__flash_lplfw_start; i++)
- *((uint32_t *)__lpram_lfw_start + i) =
- *(&__flash_lplfw_start + i);
-
- /* Start GDMA in Suspend RAM */
- __start_gdma_in_lpram(exeAddr);
-}
diff --git a/zephyr/shim/chip/npcx/system_external_storage.c b/zephyr/shim/chip/npcx/system_external_storage.c
deleted file mode 100644
index 373a4a48f7..0000000000
--- a/zephyr/shim/chip/npcx/system_external_storage.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <devicetree.h>
-#include <drivers/syscon.h>
-
-#include "clock_chip.h"
-#include "common.h"
-#include "rom_chip.h"
-#include "system.h"
-#include "system_chip.h"
-
-/* TODO (b:179900857) Make this implementation not npcx specific. */
-
-static const struct device *mdc_dev = DEVICE_DT_GET(DT_NODELABEL(mdc));
-
-#ifdef CONFIG_SOC_SERIES_NPCX7
-#define NPCX_FWCTRL 0x007
-#define NPCX_FWCTRL_RO_REGION 0
-#define NPCX_FWCTRL_FW_SLOT 1
-#elif defined(CONFIG_SOC_SERIES_NPCX9)
-#define NPCX_FWCTRL 0x009
-#define NPCX_FWCTRL_RO_REGION 6
-#define NPCX_FWCTRL_FW_SLOT 7
-#else
-#error "Unsupported NPCX SoC series."
-#endif
-
-void system_jump_to_booter(void)
-{
- enum API_RETURN_STATUS_T status __attribute__((unused));
- static uint32_t flash_offset;
- static uint32_t flash_used;
- static uint32_t addr_entry;
-
- /*
- * Get memory offset and size for RO/RW regions.
- * Both of them need 16-bytes alignment since GDMA burst mode.
- */
- switch (system_get_shrspi_image_copy()) {
- case EC_IMAGE_RW:
- flash_offset = CONFIG_EC_WRITABLE_STORAGE_OFF +
- CONFIG_RW_STORAGE_OFF;
- flash_used = CONFIG_RW_SIZE;
- break;
-#ifdef CONFIG_RW_B
- case EC_IMAGE_RW_B:
- flash_offset = CONFIG_EC_WRITABLE_STORAGE_OFF +
- CONFIG_RW_B_STORAGE_OFF;
- flash_used = CONFIG_RW_SIZE;
- break;
-#endif
- case EC_IMAGE_RO:
- default: /* Jump to RO by default */
- flash_offset = CONFIG_EC_PROTECTED_STORAGE_OFF +
- CONFIG_RO_STORAGE_OFF;
- flash_used = CONFIG_RO_SIZE;
- break;
- }
-
- /* Make sure the reset vector is inside the destination image */
- addr_entry = *(uintptr_t *)(flash_offset +
- CONFIG_MAPPED_STORAGE_BASE + 4);
-
- /*
- * Speed up FW download time by increasing clock freq of EC. It will
- * restore to default in clock_init() later.
- */
- clock_turbo();
-
-/*
- * npcx9 Rev.1 has the problem for download_from_flash API.
- * Workwaroud it by executing the system_download_from_flash function
- * in the suspend RAM like npcx5.
- * TODO: Removing npcx9 when Rev.2 is available.
- */
- /* Bypass for GMDA issue of ROM api utilities */
-#if defined(CONFIG_SOC_SERIES_NPCX5) || \
- defined(CONFIG_PLATFORM_EC_WORKAROUND_FLASH_DOWNLOAD_API)
- system_download_from_flash(
- flash_offset, /* The offset of the data in spi flash */
- CONFIG_PROGRAM_MEMORY_BASE, /* RAM Addr of downloaded data */
- flash_used, /* Number of bytes to download */
- addr_entry /* jump to this address after download */
- );
-#else
- download_from_flash(
- flash_offset, /* The offset of the data in spi flash */
- CONFIG_PROGRAM_MEMORY_BASE, /* RAM Addr of downloaded data */
- flash_used, /* Number of bytes to download */
- SIGN_NO_CHECK, /* Need CRC check or not */
- addr_entry, /* jump to this address after download */
- &status /* Status fo download */
- );
-#endif
-}
-
-uint32_t system_get_lfw_address()
-{
- /*
- * In A3 version, we don't use little FW anymore
- * We provide the alternative function in ROM
- */
- uint32_t jump_addr = (uint32_t)system_jump_to_booter;
- return jump_addr;
-}
-
-enum ec_image system_get_shrspi_image_copy(void)
-{
- uint32_t fwctrl = 0;
-
- syscon_read_reg(mdc_dev, NPCX_FWCTRL, &fwctrl);
- if (IS_BIT_SET(fwctrl, NPCX_FWCTRL_RO_REGION)) {
- /* RO image */
-#ifdef CHIP_HAS_RO_B
- if (!IS_BIT_SET(fwctrl, NPCX_FWCTRL_FW_SLOT))
- return EC_IMAGE_RO_B;
-#endif
- return EC_IMAGE_RO;
- } else {
-#ifdef CONFIG_RW_B
- /* RW image */
- if (!IS_BIT_SET(fwctrl, NPCX_FWCTRL_FW_SLOT))
- /* Slot A */
- return EC_IMAGE_RW_B;
-#endif
- return EC_IMAGE_RW;
- }
-}
-
-void system_set_image_copy(enum ec_image copy)
-{
- uint32_t fwctrl = 0;
-
- syscon_read_reg(mdc_dev, NPCX_FWCTRL, &fwctrl);
- switch (copy) {
- case EC_IMAGE_RW:
- CLEAR_BIT(fwctrl, NPCX_FWCTRL_RO_REGION);
- SET_BIT(fwctrl, NPCX_FWCTRL_FW_SLOT);
- break;
-#ifdef CONFIG_RW_B
- case EC_IMAGE_RW_B:
- CLEAR_BIT(fwctrl, NPCX_FWCTRL_RO_REGION);
- CLEAR_BIT(fwctrl, NPCX_FWCTRL_FW_SLOT);
- break;
-#endif
- default:
- /* Fall through to EC_IMAGE_RO */
- case EC_IMAGE_RO:
- SET_BIT(fwctrl, NPCX_FWCTRL_RO_REGION);
- SET_BIT(fwctrl, NPCX_FWCTRL_FW_SLOT);
- break;
- }
- syscon_write_reg(mdc_dev, NPCX_FWCTRL, fwctrl);
-}
diff --git a/zephyr/shim/chip/posix/CMakeLists.txt b/zephyr/shim/chip/posix/CMakeLists.txt
deleted file mode 100644
index 70e8b6269a..0000000000
--- a/zephyr/shim/chip/posix/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ESPI espi.c) \ No newline at end of file
diff --git a/zephyr/shim/chip/posix/espi.c b/zephyr/shim/chip/posix/espi.c
deleted file mode 100644
index cf348744d7..0000000000
--- a/zephyr/shim/chip/posix/espi.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <sys/util.h>
-#include "zephyr_espi_shim.h"
-
-#define ACPI_TYPE_POS 0U
-#define ACPI_DATA_POS 8U
-
-/* 8042 event data format */
-#define POSIX_8042_EVT_POS 16U
-#define POSIX_8042_DATA_POS 8U
-#define POSIX_8042_TYPE_POS 0U
-
-/* 8042 event type format */
-#define POSIX_8042_EVT_IBF BIT(0)
-#define POSIX_8042_EVT_OBE BIT(1)
-
-bool is_acpi_command(uint32_t data)
-{
- return (data >> ACPI_TYPE_POS) & 0x01;
-}
-
-uint32_t get_acpi_value(uint32_t data)
-{
- return (data >> ACPI_TYPE_POS) & 0xff;
-}
-
-bool is_POSIX_8042_ibf(uint32_t data)
-{
- return (data >> POSIX_8042_EVT_POS) & POSIX_8042_EVT_IBF;
-}
-
-bool is_POSIX_8042_obe(uint32_t data)
-{
- return (data >> POSIX_8042_EVT_POS) & POSIX_8042_EVT_OBE;
-}
-
-uint32_t get_POSIX_8042_type(uint32_t data)
-{
- return (data >> POSIX_8042_TYPE_POS) & 0xFF;
-}
-
-uint32_t get_POSIX_8042_data(uint32_t data)
-{
- return (data >> POSIX_8042_DATA_POS) & 0xFF;
-}
diff --git a/zephyr/shim/core/CMakeLists.txt b/zephyr/shim/core/CMakeLists.txt
deleted file mode 100644
index e1b13f21f4..0000000000
--- a/zephyr/shim/core/CMakeLists.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-if (DEFINED CONFIG_CPU_CORTEX_M)
- add_subdirectory(cortex-m)
-endif()
diff --git a/zephyr/shim/core/cortex-m/CMakeLists.txt b/zephyr/shim/core/cortex-m/CMakeLists.txt
deleted file mode 100644
index 01e5673f9e..0000000000
--- a/zephyr/shim/core/cortex-m/CMakeLists.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_MPU mpu.c)
diff --git a/zephyr/shim/core/cortex-m/mpu.c b/zephyr/shim/core/cortex-m/mpu.c
deleted file mode 100644
index 24d7948143..0000000000
--- a/zephyr/shim/core/cortex-m/mpu.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "config.h"
-#include "mpu.h"
-#include "logging/log.h"
-#include <arch/arm/aarch32/cortex_m/cmsis.h>
-#include <arch/cpu.h>
-#include <init.h>
-
-LOG_MODULE_REGISTER(shim_mpu, LOG_LEVEL_ERR);
-
-void mpu_enable(void)
-{
- for (int index = 0; index < mpu_config.num_regions; index++) {
- MPU->RNR = index;
- MPU->RASR |= MPU_RASR_ENABLE_Msk;
- LOG_DBG("[%d] %08x %08x", index, MPU->RBAR, MPU->RASR);
- }
-}
-
-static int mpu_disable_fixed_regions(const struct device *dev)
-{
- /* MPU is configured and enabled by the Zephyr init code, disable the
- * fixed sections by default.
- */
- for (int index = 0; index < mpu_config.num_regions; index++) {
- MPU->RNR = index;
- MPU->RASR &= ~MPU_RASR_ENABLE_Msk;
- LOG_DBG("[%d] %08x %08x", index, MPU->RBAR, MPU->RASR);
- }
-
- return 0;
-}
-
-SYS_INIT(mpu_disable_fixed_regions, PRE_KERNEL_1, 50);
diff --git a/zephyr/shim/include/adc_chip.h b/zephyr/shim/include/adc_chip.h
deleted file mode 100644
index c51cdfbb30..0000000000
--- a/zephyr/shim/include/adc_chip.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/*
- * This file is left intentionally blank. It is required since the
- * platform/ec/common/adc.c file includes it. Normally, this file
- * would define chip specific ADC configs and would reside under
- * platform/ec/chip/...
- */
-
-#ifndef __CROS_EC_ADC_CHIP_H
-#define __CROS_EC_ADC_CHIP_H
-
-#endif /* __CROS_EC_ADC_CHIP_H */
diff --git a/zephyr/shim/include/atomic.h b/zephyr/shim/include/atomic.h
deleted file mode 100644
index ad534d116b..0000000000
--- a/zephyr/shim/include/atomic.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __CROS_EC_ATOMIC_H
-#define __CROS_EC_ATOMIC_H
-
-#include <sys/atomic.h>
-
-static inline atomic_val_t atomic_clear_bits(atomic_t *addr, atomic_val_t bits)
-{
- return atomic_and(addr, ~bits);
-}
-
-#endif /* __CROS_EC_ATOMIC_H */
diff --git a/zephyr/shim/include/battery_enum.h b/zephyr/shim/include/battery_enum.h
deleted file mode 100644
index a461829a31..0000000000
--- a/zephyr/shim/include/battery_enum.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_CONFIG_CHIP_H
-#error "This file must only be included from config_chip.h and it should be" \
- "included in all zephyr builds automatically"
-#endif
-
-#define BATTERY_ENUM(val) DT_CAT(BATTERY_, val)
-#define BATTERY_TYPE(id) BATTERY_ENUM(DT_STRING_UPPER_TOKEN(id, enum_name))
-#define BATTERY_TYPE_WITH_COMMA(id) BATTERY_TYPE(id),
-
-/* This produces a list of BATTERY_<ENUM_NAME> identifiers */
-#if DT_NODE_EXISTS(DT_PATH(batteries))
-
-enum battery_type {
- DT_FOREACH_CHILD(DT_PATH(batteries), BATTERY_TYPE_WITH_COMMA)
-
- BATTERY_TYPE_COUNT,
-};
-
-#else /* DT_NODE_EXISTS(DT_PATH(batteries)) */
-
-enum battery_type {
-#if DT_NODE_EXISTS(DT_PATH(named_batteries))
- DT_FOREACH_CHILD(DT_PATH(named_batteries), BATTERY_TYPE_WITH_COMMA)
-#endif
-
- BATTERY_TYPE_COUNT,
-};
-
-#endif /* DT_NODE_EXISTS(DT_PATH(batteries)) */
-
-#undef BATTERY_TYPE_WITH_COMMA
diff --git a/zephyr/shim/include/bbram.h b/zephyr/shim/include/bbram.h
deleted file mode 100644
index 3eba4b157b..0000000000
--- a/zephyr/shim/include/bbram.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef ZEPHYR_SHIM_INCLUDE_BBRAM_H_
-#define ZEPHYR_SHIM_INCLUDE_BBRAM_H_
-
-#include <devicetree.h>
-
-#define BBRAM_SIZE DT_REG_SIZE_BY_NAME(DT_NODELABEL(bbram), memory)
-#define BBRAM_ADDR DT_REG_ADDR_BY_NAME(DT_NODELABEL(bbram), memory)
-#define BBRAM(offset) REG8(BBRAM_ADDR + offset)
-#define BBRAM_BKUP_STS BBRAM(CONFIG_BBRAM_BKUP_STS)
-
-#endif /* ZEPHYR_SHIM_INCLUDE_BBRAM_H_ */
diff --git a/zephyr/shim/include/board.h b/zephyr/shim/include/board.h
deleted file mode 100644
index df3ef33c0e..0000000000
--- a/zephyr/shim/include/board.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __BOARD_H
-#define __BOARD_H
-
-#include <devicetree.h>
-
-/* Included shimed version of gpio signal. */
-#include "gpio_signal.h"
-
-/* Include board specific gpio mapping/aliases if named_pgios node exists */
-#if DT_NODE_EXISTS(DT_PATH(named_gpios))
-#include "gpio_map.h"
-#endif
-
-/* Include board specific i2c mapping if I2C is enabled. */
-#if defined(CONFIG_I2C)
-#include "i2c/i2c.h"
-#endif
-
-#ifdef CONFIG_PWM
-#include "pwm_map.h"
-#endif
-
-/* Include board specific sensor configuration if motionsense is enabled */
-#ifdef CONFIG_MOTIONSENSE
-#include "motionsense_sensors.h"
-#endif
-
-#endif /* __BOARD_H */
diff --git a/zephyr/shim/include/builtin/assert.h b/zephyr/shim/include/builtin/assert.h
deleted file mode 100644
index 21a6c5b3d7..0000000000
--- a/zephyr/shim/include/builtin/assert.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __CROS_EC_ASSERT_H
-#define __CROS_EC_ASSERT_H
-
-#include <sys/__assert.h>
-
-#undef ASSERT
-#undef assert
-#define ASSERT __ASSERT_NO_MSG
-#define assert __ASSERT_NO_MSG
-
-#endif /* __CROS_EC_ASSERT_H */
diff --git a/zephyr/shim/include/config_chip.h b/zephyr/shim/include/config_chip.h
deleted file mode 100644
index 04d2ca1d5d..0000000000
--- a/zephyr/shim/include/config_chip.h
+++ /dev/null
@@ -1,1811 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __CROS_EC_CONFIG_CHIP_H
-#define __CROS_EC_CONFIG_CHIP_H
-
-#include <devicetree.h>
-#include <autoconf.h>
-
-/*
- * The battery enum is used in various drivers and these assume that it is
- * always available (defined in board.h). With Zephyr we don't include board.h
- * so we have a battery_enum.h header in the shim which defines
- * enum battery_type based on settings in the device tree. Include that here.
- */
-#ifdef CONFIG_PLATFORM_EC_BATTERY
-#include "battery_enum.h"
-#endif
-
-/*
- * This file translates Kconfig options to platform/ec options.
- *
- * Options which are from Zephyr platform/ec module (Kconfig) start
- * with CONFIG_PLATFORM_EC_, and can be found in the Kconfig file.
- *
- * Options which are for the platform/ec configuration can be found in
- * common/config.h.
- */
-
-/*
- * Obsolete configs - these are options that are not needed, either because
- * Zephyr features directly replace the option, or because the config option
- * will not be used with Zephyr OS.
- */
-
-/*
- * ROM resident support. The ROM resident capabilities in the Chromium OS
- * code are used with EC chipsets that provide more flash space than
- * executable RAM. These options allow storing the initialized data into
- * an unused area of flash where it is copied directly from flash into data
- * RAM by the early boot code.
- *
- * When ROM resident is disabled, the initialized data is stored in the main
- * image, copied from flash to executable RAM by the chip boot loader, and
- * then copied from executable RAM to data RAM by the early boot code.
- *
- * Supporting this under Zephyr would require linker changes to the common
- * Zephyr linking.
- */
-#undef CONFIG_CHIP_DATA_IN_INIT_ROM
-#undef CONFIG_CHIP_INIT_ROM_REGION
-#undef CONFIG_RO_ROM_RESIDENT_MEM_OFF
-#undef CONFIG_RO_ROM_RESIDENT_SIZE
-#undef CONFIG_RW_ROM_RESIDENT_MEM_OFF
-#undef CONFIG_RW_ROM_RESIDENT_SIZE
-
-/*
- * ECOS specific options, not used in Zephyr.
- */
-#undef CONFIG_CONSOLE_UART /* Only used by the Chromium EC chip drivers */
-#undef CONFIG_I2C_MULTI_PORT_CONTROLLER /* Not required by I2C shim */
-#undef CONFIG_IRQ_COUNT /* Only used by Chromium EC core drivers */
-#undef CONFIG_KEYBOARD_KSO_HIGH_DRIVE /* Used by the Chromium EC chip drivers */
-#undef CONFIG_LTO /* Link time optimization enabled by Zephyr build system */
-#undef CONFIG_STACK_SIZE /* Only used in Chromium EC core init code */
-#ifndef CONFIG_FPU
-#undef CONFIG_FPU /* Used in Zephyr as well, enabled in Kconfig directly */
-#endif
-#ifndef CONFIG_WATCHDOG
-#undef CONFIG_WATCHDOG /* Used in Zephyr as well, enabled in Kconfig directly */
-#endif
-
-/*
- * The Zephyr I2C shell command provides the same functionality as the Chromium
- * EC i2cscan and i2cxfer commands, so they are always disabled.
- */
-#undef CONFIG_CMD_I2C_SCAN
-#undef CONFIG_CMD_I2C_XFER
-
-/*
- * This not used by the Zephyr code since we always make cros_crc8() available.
- * Define it here to reduce the delta from the ECOS CONFIG.
- */
-#undef CONFIG_CRC8
-#define CONFIG_CRC8
-
-/*
- * This is not used by the Zephyr code.
- * Define it here to reduce the delta from the ECOS CONFIG.
- */
-#undef CONFIG_CHIP_PRE_INIT
-#define CONFIG_CHIP_PRE_INIT
-
-#undef CONFIG_BC12_SINGLE_DRIVER
-#ifdef CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER
-#define CONFIG_BC12_SINGLE_DRIVER
-#endif
-
-#undef CONFIG_CHARGER_SINGLE_CHIP
-#define CONFIG_CHARGER_SINGLE_CHIP
-
-/* EC chipset configuration */
-#define HOOK_TICK_INTERVAL CONFIG_CROS_EC_HOOK_TICK_INTERVAL
-#define HOOK_TICK_INTERVAL_MS (HOOK_TICK_INTERVAL / 1000)
-
-/* Chipset and power configuration */
-#ifdef CONFIG_AP_ARM_QUALCOMM_SC7180
-#define CONFIG_CHIPSET_SC7180
-#endif
-
-#ifdef CONFIG_AP_ARM_QUALCOMM_SC7280
-#define CONFIG_CHIPSET_SC7280
-#endif
-
-#ifdef CONFIG_AP_X86_INTEL_CML
-#define CONFIG_CHIPSET_COMETLAKE
-#define CONFIG_CHIPSET_HAS_PRE_INIT_CALLBACK
-#endif
-
-#ifdef CONFIG_AP_X86_INTEL_TGL
-#define CONFIG_CHIPSET_TIGERLAKE
-#endif
-
-#undef CONFIG_THROTTLE_AP
-#ifdef CONFIG_PLATFORM_EC_THROTTLE_AP
-#define CONFIG_THROTTLE_AP
-#endif
-
-#undef CONFIG_CHIPSET_CAN_THROTTLE
-#ifdef CONFIG_PLATFORM_EC_CHIPSET_CAN_THROTTLE
-#define CONFIG_CHIPSET_CAN_THROTTLE
-#endif
-
-#undef CONFIG_CMD_APTHROTTLE
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_APTHROTTLE
-#define CONFIG_CMD_APTHROTTLE
-#endif
-
-#undef CONFIG_BACKLIGHT_LID
-#ifdef CONFIG_PLATFORM_EC_BACKLIGHT_LID
-#define CONFIG_BACKLIGHT_LID
-#endif
-
-/* Battery configuration */
-#undef CONFIG_BATTERY
-#undef CONFIG_BATTERY_FUEL_GAUGE
-#ifdef CONFIG_PLATFORM_EC_BATTERY
-#define CONFIG_BATTERY
-#define CONFIG_BATTERY_FUEL_GAUGE
-
-#endif /* CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE */
-
-#undef CONFIG_BATTERY_SMART
-#ifdef CONFIG_PLATFORM_EC_BATTERY_SMART
-#define CONFIG_BATTERY_SMART
-#endif
-
-#undef CONFIG_I2C_VIRTUAL_BATTERY
-#undef I2C_PORT_VIRTUAL_BATTERY
-#ifdef CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY
-#define CONFIG_I2C_VIRTUAL_BATTERY
-#define I2C_PORT_VIRTUAL_BATTERY I2C_PORT_BATTERY
-#endif
-
-#undef CONFIG_I2C_PASSTHRU_RESTRICTED
-#ifdef CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED
-#define CONFIG_I2C_PASSTHRU_RESTRICTED
-#endif
-
-#undef CONFIG_CMD_I2C_SPEED
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED
-#define CONFIG_CMD_I2C_SPEED
-#endif
-
-#undef CONFIG_BATTERY_PRESENT_CUSTOM
-#ifdef CONFIG_PLATFORM_EC_BATTERY_PRESENT_CUSTOM
-#define CONFIG_BATTERY_PRESENT_CUSTOM
-#endif
-
-#undef CONFIG_BATTERY_PRESENT_GPIO
-#ifdef CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO
-/* This is always GPIO_BATT_PRES_ODL with Zephyr */
-#define CONFIG_BATTERY_PRESENT_GPIO GPIO_BATT_PRES_ODL
-#endif
-
-#undef CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF
-#ifdef CONFIG_PLATFORM_EC_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF
-#define CONFIG_BATTERY_CRITICAL_SHUTDOWN_CUT_OFF
-#endif
-
-#undef CONFIG_BATTERY_CHECK_CHARGE_TEMP_LIMITS
-#ifdef CONFIG_PLATFORM_EC_BATTERY_CHECK_CHARGE_TEMP_LIMITS
-#define CONFIG_BATTERY_CHECK_CHARGE_TEMP_LIMITS
-#endif
-
-#undef CONFIG_BATTERY_CUT_OFF
-#ifdef CONFIG_PLATFORM_EC_BATTERY_CUT_OFF
-#define CONFIG_BATTERY_CUT_OFF
-#endif
-
-#undef CONFIG_BATTERY_HW_PRESENT_CUSTOM
-#ifdef CONFIG_PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM
-#define CONFIG_BATTERY_HW_PRESENT_CUSTOM
-#endif
-
-#undef CONFIG_BATTERY_REVIVE_DISCONNECT
-#ifdef CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT
-#define CONFIG_BATTERY_REVIVE_DISCONNECT
-#endif
-
-#undef CONFIG_BATTERY_MEASURE_IMBALANCE
-#ifdef CONFIG_PLATFORM_EC_BATTERY_MEASURE_IMBALANCE
-
-#define CONFIG_BATTERY_MEASURE_IMBALANCE
-#define CONFIG_BATTERY_MAX_IMBALANCE_MV \
- CONFIG_PLATFORM_EC_BATTERY_MAX_IMBALANCE_MV
-#define CONFIG_CHARGER_MIN_BAT_PCT_IMBALANCED_POWER_ON \
- CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_IMBALANCED_POWER_ON
-
-#endif
-
-#undef CONFIG_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV
-#if defined(CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV) && \
- (CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV > 0)
-#define CONFIG_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV \
- CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV
-#endif
-
-#undef CONFIG_BOARD_RESET_AFTER_POWER_ON
-#ifdef CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON
-#define CONFIG_BOARD_RESET_AFTER_POWER_ON
-#endif
-
-#undef CONFIG_CHARGER_ISL9241
-#ifdef CONFIG_PLATFORM_EC_CHARGER_ISL9241
-#define CONFIG_CHARGER_ISL9241
-#endif
-
-/*
- * Note - ISL9241 chargers for all channels are configured with the same
- * switching frequency. Use the first ISL9241 instance found in the device tree.
- */
-#undef CONFIG_ISL9241_SWITCHING_FREQ
-#define ISL9241_NODE DT_INST(0, intersil_isl9241)
-#if DT_NODE_EXISTS(ISL9241_NODE) && \
- DT_NODE_HAS_PROP(ISL9241_NODE, switching_frequency)
-#define CONFIG_ISL9241_SWITCHING_FREQ \
- DT_PROP(ISL9241_NODE, switching_frequency)
-#endif
-
-#undef CONFIG_CHARGER_ISL9237
-#ifdef CONFIG_PLATFORM_EC_CHARGER_ISL9237
-#define CONFIG_CHARGER_ISL9237
-#endif
-
-#undef CONFIG_CHARGER_ISL9238
-#ifdef CONFIG_PLATFORM_EC_CHARGER_ISL9238
-#define CONFIG_CHARGER_ISL9238
-#endif
-
-#undef CONFIG_CHARGER_ISL9238C
-#ifdef CONFIG_PLATFORM_EC_CHARGER_ISL9238C
-#define CONFIG_CHARGER_ISL9238C
-#endif
-
-#undef CONFIG_CHARGER_MAINTAIN_VBAT
-#ifdef CONFIG_PLATFORM_EC_CHARGER_MAINTAIN_VBAT
-#define CONFIG_CHARGER_MAINTAIN_VBAT
-#endif
-
-#undef CONFIG_CHARGER_NARROW_VDC
-#ifdef CONFIG_PLATFORM_EC_CHARGER_NARROW_VDC
-#define CONFIG_CHARGER_NARROW_VDC
-#endif
-
-#undef CONFIG_CHARGER_OTG
-#ifdef CONFIG_PLATFORM_EC_CHARGER_OTG
-#define CONFIG_CHARGER_OTG
-#endif
-
-#undef CONFIG_CHIPSET_RESET_HOOK
-#ifdef CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK
-#define CONFIG_CHIPSET_RESET_HOOK
-#endif
-
-#undef CONFIG_CHIPSET_RESUME_INIT_HOOK
-#ifdef CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK
-#define CONFIG_CHIPSET_RESUME_INIT_HOOK
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_EXTPOWER_GPIO
-#define CONFIG_EXTPOWER_GPIO
-
-/* This always needs to be defined for this option to work */
-#define CONFIG_EXTPOWER
-#endif
-
-/* Bringup configuration */
-#ifdef CONFIG_PLATFORM_EC_BRINGUP
-#define CONFIG_BRINGUP
-#endif
-
-#undef CONFIG_EMULATED_SYSRQ
-#ifdef CONFIG_PLATFORM_EC_EMULATED_SYSRQ
-#define CONFIG_EMULATED_SYSRQ
-#endif
-
-/* eSPI configuration */
-#ifdef CONFIG_PLATFORM_EC_ESPI
-
-#ifdef CONFIG_PLATFORM_EC_HOSTCMD
-#define CONFIG_HOSTCMD_ESPI
-#endif
-
-/* eSPI signals */
-#ifdef CONFIG_PLATFORM_EC_ESPI_VW_SLP_S3
-#define CONFIG_HOSTCMD_ESPI_VW_SLP_S3
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_ESPI_VW_SLP_S4
-#define CONFIG_HOSTCMD_ESPI_VW_SLP_S4
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_ESPI_RESET_SLP_SX_VW_ON_ESPI_RST
-#define CONFIG_HOSTCMD_ESPI_RESET_SLP_SX_VW_ON_ESPI_RST
-#endif
-
-#endif /* CONFIG_PLATFORM_EC_ESPI */
-
-#if DT_NODE_EXISTS(DT_NODELABEL(flash0))
-#define CONFIG_PROGRAM_MEMORY_BASE DT_REG_ADDR(DT_NODELABEL(flash0))
-#else
-#define CONFIG_PROGRAM_MEMORY_BASE 0X0
-#endif
-
-#if DT_NODE_EXISTS(DT_NODELABEL(sram0))
-#define CONFIG_RAM_BASE DT_REG_ADDR(DT_NODELABEL(sram0))
-#define CONFIG_DATA_RAM_SIZE DT_REG_SIZE(DT_NODELABEL(sram0))
-#else
-#define CONFIG_RAM_BASE 0x0
-#define CONFIG_DATA_RAM_SIZE 0x0
-#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
-#define CONFIG_RW_MEM_SIZE CONFIG_CROS_EC_RW_MEM_SIZE
-
-#define CONFIG_WP_STORAGE_OFF CONFIG_EC_PROTECTED_STORAGE_OFF
-#define CONFIG_WP_STORAGE_SIZE CONFIG_EC_PROTECTED_STORAGE_SIZE
-#define CONFIG_RO_SIZE CONFIG_CROS_EC_RO_SIZE
-#define CONFIG_RW_SIZE CONFIG_CROS_EC_RW_SIZE
-
-/* Flash settings */
-#undef CONFIG_EXTERNAL_STORAGE
-#undef CONFIG_INTERNAL_STORAGE
-#undef CONFIG_MAPPED_STORAGE
-#undef CONFIG_FLASH_PSTATE
-#undef CONFIG_FLASH_SIZE_BYTES
-#ifdef CONFIG_PLATFORM_EC_FLASH_CROS
-#include "flash_chip.h"
-#define CONFIG_FLASH_CROS
-
-/* Internal, don't use outside this header */
-#define _BINMAN_RO_PATH DT_PATH(binman, wp_ro)
-#define _BINMAN_RW_PATH DT_PATH(binman, ec_rw)
-
-#define CONFIG_EC_PROTECTED_STORAGE_OFF DT_PROP(_BINMAN_RO_PATH, offset)
-#define CONFIG_EC_PROTECTED_STORAGE_SIZE DT_PROP(_BINMAN_RO_PATH, size)
-#define CONFIG_EC_WRITABLE_STORAGE_OFF DT_PROP(_BINMAN_RW_PATH, offset)
-#define CONFIG_EC_WRITABLE_STORAGE_SIZE DT_PROP(_BINMAN_RW_PATH, size)
-
-#define CONFIG_RAM_SIZE CONFIG_DATA_RAM_SIZE
-
-#ifdef CONFIG_PLATFORM_EC_EXTERNAL_STORAGE
-#define CONFIG_EXTERNAL_STORAGE
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_INTERNAL_STORAGE
-#define CONFIG_INTERNAL_STORAGE
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_MAPPED_STORAGE
-#define CONFIG_MAPPED_STORAGE
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_FLASH_PSTATE
-#define CONFIG_FLASH_PSTATE
-#endif
-
-#undef CONFIG_CMD_FLASH
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH
-#define CONFIG_CMD_FLASH
-#endif
-
-#undef CONFIG_CMD_FLASHINFO
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASHINFO
-#define CONFIG_CMD_FLASHINFO
-#endif
-
-#undef CONFIG_CMD_FLASH_WP
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_FLASH_WP
-#define CONFIG_CMD_FLASH_WP
-#endif
-
-#endif /* CONFIG_PLATFORM_EC_FLASH_CROS */
-
-#undef CONFIG_ADC
-#ifdef CONFIG_PLATFORM_EC_ADC
-#define CONFIG_ADC
-#endif
-
-#undef CONFIG_ADC_CHANNELS_RUNTIME_CONFIG
-#ifdef CONFIG_PLATFORM_EC_ADC_CHANNELS_RUNTIME_CONFIG
-#define CONFIG_ADC_CHANNELS_RUNTIME_CONFIG
-#endif
-
-#undef CONFIG_CMD_ADC
-#ifdef CONFIG_PLATFORM_EC_ADC_CMD
-#define CONFIG_CMD_ADC
-#endif
-
-#undef CONFIG_TEMP_SENSOR
-#ifdef CONFIG_PLATFORM_EC_TEMP_SENSOR
-#define CONFIG_TEMP_SENSOR
-#endif
-
-#undef CONFIG_THERMISTOR
-#ifdef CONFIG_PLATFORM_EC_THERMISTOR
-#define CONFIG_THERMISTOR
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_I2C
-/* Also see shim/include/i2c/i2c.h which defines the ports enum */
-#define CONFIG_I2C_CONTROLLER
-#endif
-
-#undef CONFIG_I2C_DEBUG
-#ifdef CONFIG_PLATFORM_EC_I2C_DEBUG
-#define CONFIG_I2C_DEBUG
-#endif
-
-#undef CONFIG_I2C_DEBUG_PASSTHRU
-#ifdef CONFIG_PLATFORM_EC_I2C_DEBUG_PASSTHRU
-#define CONFIG_I2C_DEBUG_PASSTHRU
-#endif
-
-#undef CONFIG_SMBUS_PEC
-#ifdef CONFIG_PLATFORM_EC_SMBUS_PEC
-#define CONFIG_SMBUS_PEC
-#endif
-
-#undef CONFIG_KEYBOARD_PROTOCOL_8042
-#ifdef CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042
-#define CONFIG_KEYBOARD_PROTOCOL_8042
-#endif /* CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_8042 */
-
-#undef CONFIG_KEYBOARD_PROTOCOL_MKBP
-#ifdef CONFIG_PLATFORM_EC_KEYBOARD_PROTOCOL_MKBP
-#define CONFIG_KEYBOARD_PROTOCOL_MKBP
-#endif
-
-#undef CONFIG_MKBP_INPUT_DEVICES
-#ifdef CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES
-#define CONFIG_MKBP_INPUT_DEVICES
-#endif
-
-#undef CONFIG_MKBP_EVENT_WAKEUP_MASK
-#if defined(CONFIG_PLATFORM_EC_MKBP_EVENT_WAKEUP_MASK) && \
- DT_NODE_EXISTS(DT_PATH(ec_mkbp_event_wakeup_mask))
-#define CONFIG_MKBP_EVENT_WAKEUP_MASK \
- DT_PROP(DT_PATH(ec_mkbp_event_wakeup_mask), wakeup_mask)
-#endif
-
-#undef CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK
-#if defined(CONFIG_PLATFORM_EC_MKBP_HOST_EVENT_WAKEUP_MASK) && \
- DT_NODE_EXISTS(DT_PATH(ec_mkbp_host_event_wakeup_mask))
-#define CONFIG_MKBP_HOST_EVENT_WAKEUP_MASK \
- DT_PROP(DT_PATH(ec_mkbp_host_event_wakeup_mask), wakeup_mask)
-#endif
-
-#undef CONFIG_CMD_KEYBOARD
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_KEYBOARD
-#define CONFIG_CMD_KEYBOARD
-#endif
-
-#undef CONFIG_KEYBOARD_COL2_INVERTED
-#ifdef CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED
-#define CONFIG_KEYBOARD_COL2_INVERTED
-#endif /* CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED */
-
-#undef CONFIG_KEYBOARD_REFRESH_ROW3
-#ifdef CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3
-#define CONFIG_KEYBOARD_REFRESH_ROW3
-#endif /* CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3 */
-
-#undef CONFIG_KEYBOARD_KEYPAD
-#ifdef CONFIG_PLATFORM_EC_KEYBOARD_KEYPAD
-#define CONFIG_KEYBOARD_KEYPAD
-#endif
-
-#undef CONFIG_KEYBOARD_VIVALDI
-#ifdef CONFIG_PLATFORM_EC_KEYBOARD_VIVALDI
-#define CONFIG_KEYBOARD_VIVALDI
-#endif
-
-#undef CONFIG_KEYBOARD_PWRBTN_ASSERTS_KSI2
-#ifdef CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2
-#define CONFIG_KEYBOARD_PWRBTN_ASSERTS_KSI2
-#endif
-
-#undef CONFIG_KEYBOARD_PWRBTN_ASSERTS_KSI3
-#ifdef CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3
-#define CONFIG_KEYBOARD_PWRBTN_ASSERTS_KSI3
-#endif
-
-#undef CONFIG_VOLUME_BUTTONS
-#ifdef CONFIG_PLATFORM_EC_VOLUME_BUTTONS
-#define CONFIG_VOLUME_BUTTONS
-#endif
-
-#undef CONFIG_CMD_BUTTON
-#ifdef CONFIG_PLATFORM_EC_CMD_BUTTON
-#define CONFIG_CMD_BUTTON
-#endif
-
-#undef CONFIG_PWM_KBLIGHT
-#undef CONFIG_KEYBOARD_BACKLIGHT
-#ifdef CONFIG_PLATFORM_EC_PWM_KBLIGHT
-#define CONFIG_PWM_KBLIGHT
-#define CONFIG_KEYBOARD_BACKLIGHT
-#endif
-
-#undef CONFIG_LED_COMMON
-#ifdef CONFIG_PLATFORM_EC_LED_COMMON
-#define CONFIG_LED_COMMON
-#endif
-
-#undef CONFIG_LED_PWM
-#ifdef CONFIG_PLATFORM_EC_LED_PWM
-#define CONFIG_LED_PWM
-#endif
-
-#undef CONFIG_LED_PWM_COUNT
-#if DT_HAS_COMPAT_STATUS_OKAY(cros_ec_pwm_leds)
-#define CONFIG_LED_PWM_COUNT DT_PROP_LEN(DT_INST(0, cros_ec_pwm_leds), leds)
-#endif
-
-#undef CONFIG_CMD_LEDTEST
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_LEDTEST
-#define CONFIG_CMD_LEDTEST
-#endif
-
-#undef CONFIG_PWM_DISPLIGHT
-#ifdef CONFIG_PLATFORM_EC_PWM_DISPLIGHT
-#define CONFIG_PWM_DISPLIGHT
-#endif
-
-#undef CONFIG_CPU_PROCHOT_ACTIVE_LOW
-#ifdef CONFIG_PLATFORM_EC_POWERSEQ_CPU_PROCHOT_ACTIVE_LOW
-#define CONFIG_CPU_PROCHOT_ACTIVE_LOW
-#endif
-
-#undef CONFIG_POWER_TRACK_HOST_SLEEP_STATE
-#ifdef CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP
-#define CONFIG_POWER_TRACK_HOST_SLEEP_STATE
-#endif
-
-#undef CONFIG_POWER_SLEEP_FAILURE_DETECTION
-#ifdef CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION
-#define CONFIG_POWER_SLEEP_FAILURE_DETECTION
-#endif
-
-#undef CONFIG_HOSTCMD_AP_RESET
-#ifdef CONFIG_PLATFORM_EC_HOSTCMD_AP_RESET
-#define CONFIG_HOSTCMD_AP_RESET
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_POWERSEQ_RSMRST_DELAY
-#define CONFIG_CHIPSET_X86_RSMRST_DELAY
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_POWERSEQ_SLP_S3_L_OVERRIDE
-#define CONFIG_CHIPSET_SLP_S3_L_OVERRIDE
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_POWERSEQ_PP3300_RAIL_FIRST
-#define CONFIG_CHIPSET_PP3300_RAIL_FIRST
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_POWERSEQ_RTC_RESET
-#define CONFIG_BOARD_HAS_RTC_RESET
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL
-#define CONFIG_POWER_PP5000_CONTROL
-#endif
-
-#undef CONFIG_POWER_S0IX
-#ifdef CONFIG_PLATFORM_EC_POWERSEQ_S0IX
-#define CONFIG_POWER_S0IX
-#endif
-
-#undef CONFIG_POWER_BUTTON_X86
-#ifdef CONFIG_PLATFORM_EC_POWERSEQ_INTEL
-#define CONFIG_POWER_BUTTON_X86
-#endif
-
-#undef CONFIG_FAKE_SHMEM
-#ifdef CONFIG_ARCH_POSIX
-#define CONFIG_FAKE_SHMEM
-#endif
-
-#undef CONFIG_PWM
-#ifdef CONFIG_PLATFORM_EC_PWM
-#define CONFIG_PWM
-#endif
-
-#undef CONFIG_CMD_S5_TIMEOUT
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_S5_TIMEOUT
-#define CONFIG_CMD_S5_TIMEOUT
-#endif
-
-#undef CONFIG_CMD_SHMEM
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_SHMEM
-#define CONFIG_CMD_SHMEM
-#endif
-
-#undef CONFIG_CROS_FWID_VERSION
-#ifdef CONFIG_PLATFORM_EC_CROS_FWID_VERSION
-#define CONFIG_CROS_FWID_VERSION
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_TIMER
-#define CONFIG_HWTIMER_64BIT
-#define CONFIG_HW_SPECIFIC_UDELAY
-
-#undef CONFIG_CMD_GETTIME
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_GETTIME
-#define CONFIG_CMD_GETTIME
-#endif /* CONFIG_PLATFORM_EC_CONSOLE_CMD_GETTIME */
-
-#undef CONFIG_CMD_TIMERINFO
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_TIMERINFO
-#define CONFIG_CMD_TIMERINFO
-#endif /* CONFIG_PLATFORM_EC_CONSOLE_CMD_TIMERINFO */
-
-#undef CONFIG_CMD_WAITMS
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_WAITMS
-#define CONFIG_CMD_WAITMS
-#endif /* CONFIG_PLATFORM_EC_CONSOLE_CMD_TIMERINFO */
-
-#endif /* CONFIG_PLATFORM_EC_TIMER */
-
-/* USB-C things */
-#ifdef CONFIG_PLATFORM_EC_USBC
-
-/* Zephyr only supports v2 so we always define this */
-#define CONFIG_USB_PD_TCPMV2
-
-/*
- * Define these here for now. They are not actually CONFIG options in the EC
- * code base. Ideally they would be defined in the devicetree (perhaps for a
- * 'board' driver if not in the USB chip driver itself).
- *
- * SN5S30 PPC supports up to 24V VBUS source and sink, however 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
-
-/* TODO: b/144165680 - measure and check these values on Volteer */
-#define PD_POWER_SUPPLY_TURN_ON_DELAY 30000 /* us */
-#define PD_POWER_SUPPLY_TURN_OFF_DELAY 30000 /* us */
-#endif
-
-#undef CONFIG_CMD_PPC_DUMP
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_PPC_DUMP
-#define CONFIG_CMD_PPC_DUMP
-#endif
-
-#undef CONFIG_CMD_TCPC_DUMP
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP
-#define CONFIG_CMD_TCPC_DUMP
-#endif
-
-#undef CONFIG_USB_POWER_DELIVERY
-#ifdef CONFIG_PLATFORM_EC_USB_POWER_DELIVERY
-#define CONFIG_USB_POWER_DELIVERY
-#endif
-
-#undef CONFIG_CHARGER
-#undef CONFIG_CHARGE_MANAGER
-#ifdef CONFIG_PLATFORM_EC_CHARGE_MANAGER
-#define CONFIG_CHARGE_MANAGER
-#define CONFIG_CHARGER
-
-/* TODO: Put these charger defines in the devicetree? */
-#define CONFIG_CHARGER_SENSE_RESISTOR 10
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC 10
-
-#endif
-
-#undef CONFIG_CHARGER_INPUT_CURRENT
-#ifdef CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT
-#define CONFIG_CHARGER_INPUT_CURRENT CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT
-#endif
-
-#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
-#ifdef CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON \
- CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON
-#endif
-
-#undef CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC
-#ifdef CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC
-#define CONFIG_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC \
- CONFIG_PLATFORM_EC_CHARGER_MIN_BAT_PCT_FOR_POWER_ON_WITH_AC
-#endif
-
-#undef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT
-#ifdef CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT
-#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT \
- CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON_WITH_BATT
-#endif
-
-#undef CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON
-#ifdef CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON
-#define CONFIG_CHARGER_MIN_POWER_MW_FOR_POWER_ON \
- CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON
-#endif
-
-#undef CONFIG_CHARGE_RAMP_SW
-#ifdef CONFIG_PLATFORM_EC_CHARGE_RAMP_SW
-#define CONFIG_CHARGE_RAMP_SW
-#endif
-
-#undef CONFIG_CHARGE_RAMP_HW
-#ifdef CONFIG_PLATFORM_EC_CHARGE_RAMP_HW
-#define CONFIG_CHARGE_RAMP_HW
-#endif
-
-#undef CONFIG_CMD_CHGRAMP
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_CHGRAMP
-#define CONFIG_CMD_CHGRAMP
-#endif
-
-#undef CONFIG_USB_PID
-#ifdef CONFIG_PLATFORM_EC_USB_PID
-#define CONFIG_USB_PID CONFIG_PLATFORM_EC_USB_PID
-#endif
-
-#undef CONFIG_USB_BCD_DEV
-#ifdef CONFIG_PLATFORM_EC_USB_BCD_DEV
-#define CONFIG_USB_BCD_DEV CONFIG_PLATFORM_EC_USB_BCD_DEV
-#endif
-
-#undef CONFIG_USB_VID
-#ifdef CONFIG_PLATFORM_EC_USB_VID
-#define CONFIG_USB_VID CONFIG_PLATFORM_EC_USB_VID
-#endif
-
-/* VBUS-voltage measurement */
-#undef CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT
-#undef CONFIG_USB_PD_VBUS_MEASURE_CHARGER
-#undef CONFIG_USB_PD_VBUS_MEASURE_TCPC
-#undef CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT
-#undef CONFIG_USB_PD_VBUS_MEASURE_BY_BOARD
-#ifdef CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_NOT_PRESENT
-#define CONFIG_USB_PD_VBUS_MEASURE_NOT_PRESENT
-#elif defined(CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER)
-#define CONFIG_USB_PD_VBUS_MEASURE_CHARGER
-#elif defined(CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC)
-#define CONFIG_USB_PD_VBUS_MEASURE_TCPC
-#elif defined(CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT)
-#define CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT
-#elif defined(CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_BY_BOARD)
-#define CONFIG_USB_PD_VBUS_MEASURE_BY_BOARD
-#endif /* VBUS-voltage measurement */
-
-#undef CONFIG_USB_CHARGER
-#ifdef CONFIG_PLATFORM_EC_USB_CHARGER
-#define CONFIG_USB_CHARGER
-#endif
-
-#define USB_PORT_COUNT CONFIG_PLATFORM_EC_USB_A_PORT_COUNT
-
-#undef CONFIG_USB_PORT_POWER_DUMB
-#ifdef CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB
-#define CONFIG_USB_PORT_POWER_DUMB
-#endif
-
-#undef CONFIG_USB_PORT_POWER_DUMB_CUSTOM_HOOK
-#ifdef CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB_CUSTOM_HOOK
-#define CONFIG_USB_PORT_POWER_DUMB_CUSTOM_HOOK
-#endif
-
-#undef CONFIG_BC12_DETECT_PI3USB9201
-#ifdef CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201
-#define CONFIG_BC12_DETECT_PI3USB9201
-#endif
-
-#undef CONFIG_BC12_DETECT_MT6360
-#ifdef CONFIG_PLATFORM_EC_BC12_DETECT_MT6360
-#define CONFIG_BC12_DETECT_MT6360
-#endif
-
-#undef CONFIG_MT6360_BC12_GPIO
-#ifdef CONFIG_PLATFORM_EC_MT6360_BC12_GPIO
-#define CONFIG_MT6360_BC12_GPIO
-#endif
-
-#undef CONFIG_HOSTCMD_REGULATOR
-#ifdef CONFIG_PLATFORM_EC_HOSTCMD_REGULATOR
-#define CONFIG_HOSTCMD_REGULATOR
-#endif
-
-#undef CONFIG_USB_PD_DUAL_ROLE
-#ifdef CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE
-#define CONFIG_USB_PD_DUAL_ROLE
-#endif
-
-#undef CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
-#ifdef CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE
-#define CONFIG_USB_PD_DUAL_ROLE_AUTO_TOGGLE
-#endif
-
-#undef CONFIG_USB_PD_DISCHARGE_PPC
-#ifdef CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC
-#define CONFIG_USB_PD_DISCHARGE_PPC
-#endif
-
-#undef CONFIG_USB_PD_LOGGING
-#ifdef CONFIG_PLATFORM_EC_USB_PD_LOGGING
-#define CONFIG_USB_PD_LOGGING
-#endif
-
-#undef CONFIG_USBC_OCP
-#ifdef CONFIG_PLATFORM_EC_USBC_OCP
-#define CONFIG_USBC_OCP
-#endif
-
-#undef CONFIG_USB_PD_CONSOLE_CMD
-#ifdef CONFIG_PLATFORM_EC_USB_PD_CONSOLE_CMD
-#define CONFIG_USB_PD_CONSOLE_CMD
-#endif
-
-#undef CONFIG_USB_PD_HOST_CMD
-#ifdef CONFIG_PLATFORM_EC_USB_PD_HOST_CMD
-#define CONFIG_USB_PD_HOST_CMD
-#endif
-
-#undef CONFIG_USB_PD_REV30
-#ifdef CONFIG_PLATFORM_EC_USB_PD_REV30
-#define CONFIG_USB_PD_REV30
-
-/*
- * Support USB PD 3.0 Extended Messages. Note that Chromebooks disabling this
- * config item are non-compliant with PD 3.0, because they have batteries but do
- * not support Get_Battery_Cap or Get_Battery_Status.
- */
-#define CONFIG_USB_PD_EXTENDED_MESSAGES
-#endif
-
-#undef CONFIG_USB_PD_VBUS_DETECT_TCPC
-#undef CONFIG_USB_PD_VBUS_DETECT_CHARGER
-#undef CONFIG_USB_PD_VBUS_DETECT_GPIO
-#undef CONFIG_USB_PD_VBUS_DETECT_PPC
-#undef CONFIG_USB_PD_VBUS_DETECT_NONE
-#ifdef CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC
-#define CONFIG_USB_PD_VBUS_DETECT_TCPC
-#endif
-#ifdef CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_CHARGER
-#define CONFIG_USB_PD_VBUS_DETECT_CHARGER
-#endif
-#ifdef CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC
-#define CONFIG_USB_PD_VBUS_DETECT_PPC
-#endif
-#ifdef CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_NONE
-#define CONFIG_USB_PD_VBUS_DETECT_NONE
-#endif
-
-#undef CONFIG_USB_PD_5V_EN_CUSTOM
-#ifdef CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM
-#define CONFIG_USB_PD_5V_EN_CUSTOM
-#endif
-
-#undef CONFIG_USB_TYPEC_SM
-#ifdef CONFIG_PLATFORM_EC_USB_TYPEC_SM
-#define CONFIG_USB_TYPEC_SM
-#endif
-
-#undef CONFIG_USB_PRL_SM
-#ifdef CONFIG_PLATFORM_EC_USB_PRL_SM
-#define CONFIG_USB_PRL_SM
-#endif
-
-#undef CONFIG_USB_PE_SM
-#ifdef CONFIG_PLATFORM_EC_USB_PE_SM
-#define CONFIG_USB_PE_SM
-#endif
-
-#undef CONFIG_USB_PD_DECODE_SOP
-#ifdef CONFIG_PLATFORM_EC_USB_PD_DECODE_SOP
-#define CONFIG_USB_PD_DECODE_SOP
-#endif
-
-#undef CONFIG_USB_VPD
-#ifdef CONFIG_PLATFORM_EC_USB_VPD
-#define CONFIG_USB_VPD
-#endif
-
-#undef CONFIG_USB_CTVPD
-#ifdef CONFIG_PLATFORM_EC_USB_CTVPD
-#define CONFIG_USB_CTVPD
-#endif
-
-#undef CONFIG_USB_DRP_ACC_TRYSRC
-#ifdef CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC
-#define CONFIG_USB_DRP_ACC_TRYSRC
-#endif
-
-#undef CONFIG_USB_PD_TCPM_PS8751
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8751
-#define CONFIG_USB_PD_TCPM_PS8751
-#endif
-
-#undef CONFIG_USB_PD_TCPM_PS8805
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805
-#define CONFIG_USB_PD_TCPM_PS8805
-#endif
-
-#undef CONFIG_USB_PD_TCPM_PS8805_FORCE_DID
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8805_FORCE_DID
-#define CONFIG_USB_PD_TCPM_PS8805_FORCE_DID
-#endif
-
-#undef CONFIG_USB_PD_TCPM_PS8815
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815
-#define CONFIG_USB_PD_TCPM_PS8815
-#endif
-
-#undef CONFIG_USB_PD_TCPM_PS8815_FORCE_DID
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_PS8815_FORCE_DID
-#define CONFIG_USB_PD_TCPM_PS8815_FORCE_DID
-#endif
-
-#undef CONFIG_USB_PD_TCPM_MULTI_PS8XXX
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_MULTI_PS8XXX
-#define CONFIG_USB_PD_TCPM_MULTI_PS8XXX
-#endif
-
-#undef CONFIG_USB_PD_TCPM_RT1715
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1715
-#define CONFIG_USB_PD_TCPM_RT1715
-#endif
-
-#undef CONFIG_USB_PD_TCPM_TUSB422
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_TUSB422
-#define CONFIG_USB_PD_TCPM_TUSB422
-#endif
-
-#undef CONFIG_USB_PD_TCPM_TCPCI
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI
-#define CONFIG_USB_PD_TCPM_TCPCI
-#endif
-
-#undef CONFIG_USB_PD_TCPM_ITE_ON_CHIP
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP
-#define CONFIG_USB_PD_TCPM_ITE_ON_CHIP
-
-/* TODO(b:189855648): hard-code a few things here; move to zephyr? */
-#define IT83XX_USBPD_PHY_PORT_COUNT 2
-#endif
-
-#undef CONFIG_USB_PD_TCPM_DRIVER_IT8XXX2
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2
-#define CONFIG_USB_PD_TCPM_DRIVER_IT8XXX2
-#endif
-
-#undef CONFIG_USB_PD_TCPM_DRIVER_IT83XX
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT83XX
-#define CONFIG_USB_PD_TCPM_DRIVER_IT83XX
-#endif
-
-#undef CONFIG_USB_PD_PORT_MAX_COUNT
-#ifdef CONFIG_PLATFORM_EC_USB_PD_PORT_MAX_COUNT
-#define CONFIG_USB_PD_PORT_MAX_COUNT CONFIG_PLATFORM_EC_USB_PD_PORT_MAX_COUNT
-#endif
-
-#undef CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT
-#ifdef CONFIG_PLATFORM_EC_USB_PD_ITE_ACTIVE_PORT_COUNT
-#define CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT \
- CONFIG_PLATFORM_EC_USB_PD_ITE_ACTIVE_PORT_COUNT
-#endif
-
-#undef CONFIG_USBC_PPC
-#ifdef CONFIG_PLATFORM_EC_USBC_PPC
-#define CONFIG_USBC_PPC
-#endif
-
-#undef CONFIG_USBC_PPC_SN5S330
-#ifdef CONFIG_PLATFORM_EC_USBC_PPC_SN5S330
-#define CONFIG_USBC_PPC_SN5S330
-#endif
-
-#undef CONFIG_USBC_PPC_SYV682X
-#ifdef CONFIG_PLATFORM_EC_USBC_PPC_SYV682X
-#define CONFIG_USBC_PPC_SYV682X
-#endif
-
-#undef CONFIG_USBC_PPC_SYV682C
-#ifdef CONFIG_PLATFORM_EC_USBC_PPC_SYV682C
-#define CONFIG_USBC_PPC_SYV682C
-#endif
-
-#undef CONFIG_USBC_PPC_SYV682X_NO_CC
-#ifdef CONFIG_PLATFORM_EC_USBC_PPC_SYV682X_NO_CC
-#define CONFIG_USBC_PPC_SYV682X_NO_CC
-#endif
-
-#undef CONFIG_USBC_PPC_SYV682X_SMART_DISCHARGE
-#ifdef CONFIG_PLATFORM_EC_USBC_PPC_SYV682X_SMART_DISCHARGE
-#define CONFIG_USBC_PPC_SYV682X_SMART_DISCHARGE
-#endif
-
-#undef CONFIG_USB_PD_TCPC_RUNTIME_CONFIG
-#undef CONFIG_USB_MUX_RUNTIME_CONFIG
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG
-#define CONFIG_USB_PD_TCPC_RUNTIME_CONFIG
-
-#ifdef CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG
-#define CONFIG_USB_MUX_RUNTIME_CONFIG
-#endif /* CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG */
-
-#endif /* CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG */
-
-#undef CONFIG_USB_PD_ALT_MODE
-#ifdef CONFIG_PLATFORM_EC_USB_PD_ALT_MODE
-#define CONFIG_USB_PD_ALT_MODE
-#endif
-
-#undef CONFIG_USB_PD_ALT_MODE_DFP
-#ifdef CONFIG_PLATFORM_EC_USB_PD_ALT_MODE_DFP
-#define CONFIG_USB_PD_ALT_MODE_DFP
-#endif
-
-#undef CONFIG_USB_PD_ALT_MODE_UFP
-#ifdef CONFIG_PLATFORM_EC_USB_PD_ALT_MODE_UFP
-#define CONFIG_USB_PD_ALT_MODE_UFP
-#endif
-
-#undef CONFIG_USB_PD_DPS
-#ifdef CONFIG_PLATFORM_EC_USB_PD_DPS
-#define CONFIG_USB_PD_DPS
-#endif
-
-#undef CONFIG_DP_REDRIVER_TDP142
-#ifdef CONFIG_PLATFORM_EC_DP_REDRIVER_TDP142
-#define CONFIG_DP_REDRIVER_TDP142
-#endif
-
-#undef CONFIG_USBC_RETIMER_FW_UPDATE
-#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_FW_UPDATE
-#define CONFIG_USBC_RETIMER_FW_UPDATE
-#endif
-
-#undef CONFIG_USBC_RETIMER_INTEL_BB
-#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB
-
-#define USBC_PORT_C1_BB_RETIMER_I2C_ADDR \
- DT_REG_ADDR(DT_NODELABEL(usb_c1_bb_retimer))
-#define CONFIG_USBC_RETIMER_INTEL_BB
-#endif
-
-#undef CONFIG_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG
-#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG
-#define CONFIG_USBC_RETIMER_INTEL_BB_RUNTIME_CONFIG
-#endif
-
-#undef CONFIG_USBC_RETIMER_ANX7451
-#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7451
-#define CONFIG_USBC_RETIMER_ANX7451
-#endif
-
-#undef CONFIG_USBC_RETIMER_PS8811
-#ifdef CONFIG_PLATFORM_EC_USBC_RETIMER_PS8811
-#define CONFIG_USBC_RETIMER_PS8811
-#endif
-
-#undef CONFIG_USBC_SS_MUX
-#ifdef CONFIG_PLATFORM_EC_USBC_SS_MUX
-#define CONFIG_USBC_SS_MUX
-#endif
-
-#undef CONFIG_USBC_SS_MUX_DFP_ONLY
-#ifdef CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY
-#define CONFIG_USBC_SS_MUX_DFP_ONLY
-#endif
-
-#undef CONFIG_USB_MUX_IT5205
-#ifdef CONFIG_PLATFORM_EC_USB_MUX_IT5205
-#define CONFIG_USB_MUX_IT5205
-#endif
-
-#undef CONFIG_USB_MUX_PS8743
-#ifdef CONFIG_PLATFORM_EC_USB_MUX_PS8743
-#define CONFIG_USB_MUX_PS8743
-#endif
-
-#undef CONFIG_USB_MUX_VIRTUAL
-#ifdef CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL
-#define CONFIG_USB_MUX_VIRTUAL
-#endif
-
-#undef CONFIG_USB_PD_TCPM_MUX
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_MUX
-#define CONFIG_USB_PD_TCPM_MUX
-#endif
-
-#undef CONFIG_USBC_PPC_DEDICATED_INT
-#ifdef CONFIG_PLATFORM_EC_USBC_PPC_DEDICATED_INT
-#define CONFIG_USBC_PPC_DEDICATED_INT
-#endif
-
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_PD
-#define CONFIG_CONSOLE_CMD_PD
-#endif
-
-#ifdef CONFIG_HAS_TASK_PD_INT_C0
-/* This must be defined if any task is active */
-#define CONFIG_HAS_TASK_PD_INT
-#endif
-
-#undef CONFIG_MKBP_EVENT
-#undef CONFIG_MKBP_USE_GPIO
-#undef CONFIG_MKBP_USE_HOST_EVENT
-#undef CONFIG_MKBP_USE_GPIO_AND_HOST_EVENT
-#undef CONFIG_MKBP_USE_CUSTOM
-#ifdef CONFIG_PLATFORM_EC_MKBP_EVENT
-#define CONFIG_MKBP_EVENT
-#ifdef CONFIG_PLATFORM_EC_MKBP_USE_GPIO
-#define CONFIG_MKBP_USE_GPIO
-#elif defined(CONFIG_PLATFORM_EC_MKBP_USE_HOST_EVENT)
-#define CONFIG_MKBP_USE_HOST_EVENT
-#elif defined(CONFIG_PLATFORM_EC_MKBP_USE_GPIO_AND_HOST_EVENT)
-#define CONFIG_MKBP_USE_GPIO_AND_HOST_EVENT
-#elif defined(CONFIG_PLATFORM_EC_MKBP_USE_CUSTOM)
-#define CONFIG_MKBP_USE_CUSTOM
-#endif
-#endif /* CONFIG_PLATFORM_EC_MKBP_EVENT */
-
-#undef CONFIG_USB_PD_TCPC_LOW_POWER
-#undef CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER
-#define CONFIG_USB_PD_TCPC_LOW_POWER
-#define CONFIG_USB_PD_TCPC_LPM_EXIT_DEBOUNCE \
- CONFIG_PLATFORM_EC_USB_PD_TCPC_LPM_EXIT_DEBOUNCE_US
-#endif /* CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER */
-
-#undef CONFIG_USB_PD_DEBUG_LEVEL
-#ifdef CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL
-#define CONFIG_USB_PD_DEBUG_LEVEL CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL
-#endif
-
-#undef CONFIG_USBC_VCONN
-#ifdef CONFIG_PLATFORM_EC_USBC_VCONN
-#define CONFIG_USBC_VCONN
-
-/* This must be defined as well */
-#define CONFIG_USBC_VCONN_SWAP
-#endif /* CONFIG_PLATFORM_EC_USBC_VCONN */
-
-#undef CONFIG_USB_PD_TRY_SRC
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TRY_SRC
-#define CONFIG_USB_PD_TRY_SRC
-#endif
-
-#undef CONFIG_USBC_PPC_POLARITY
-#ifdef CONFIG_PLATFORM_EC_USBC_PPC_POLARITY
-#define CONFIG_USBC_PPC_POLARITY
-#endif
-
-#undef CONFIG_USBC_PPC_SBU
-#ifdef CONFIG_PLATFORM_EC_USBC_PPC_SBU
-#define CONFIG_USBC_PPC_SBU
-#endif
-
-#undef CONFIG_USBC_PPC_VCONN
-#ifdef CONFIG_PLATFORM_EC_USBC_PPC_VCONN
-#define CONFIG_USBC_PPC_VCONN
-#endif
-
-#undef CONFIG_USB_PD_USB32_DRD
-#ifdef CONFIG_PLATFORM_EC_USB_PD_USB32_DRD
-#define CONFIG_USB_PD_USB32_DRD
-#endif
-
-#undef CONFIG_HOSTCMD_PD_CONTROL
-#ifdef CONFIG_PLATFORM_EC_HOSTCMD_PD_CONTROL
-#define CONFIG_HOSTCMD_PD_CONTROL
-#endif
-
-#undef CONFIG_CMD_HCDEBUG
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_HCDEBUG
-#define CONFIG_CMD_HCDEBUG
-#endif
-
-#undef CONFIG_CMD_USB_PD_PE
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_USB_PD_PE
-#define CONFIG_CMD_USB_PD_PE
-#endif
-
-#undef CONFIG_CMD_USB_PD_CABLE
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_USB_PD_CABLE
-#define CONFIG_CMD_USB_PD_CABLE
-#endif
-
-#undef CONFIG_USB_PD_TBT_COMPAT_MODE
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE
-#define CONFIG_USB_PD_TBT_COMPAT_MODE
-#endif
-
-#undef CONFIG_USB_PD_USB4
-#ifdef CONFIG_PLATFORM_EC_USB_PD_USB4
-#define CONFIG_USB_PD_USB4
-#endif
-
-#undef CONFIG_USB_PD_FRS
-#ifdef CONFIG_PLATFORM_EC_USB_PD_FRS
-#define CONFIG_USB_PD_FRS
-#endif
-
-#undef CONFIG_USB_PD_FRS_TCPC
-#ifdef CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC
-#define CONFIG_USB_PD_FRS_TCPC
-#endif
-
-#undef CONFIG_USB_PD_FRS_PPC
-#ifdef CONFIG_PLATFORM_EC_USB_PD_FRS_PPC
-#define CONFIG_USB_PD_FRS_PPC
-#endif
-
-#undef CONFIG_VSTORE
-#undef VSTORE_SLOT_COUNT
-#ifdef CONFIG_PLATFORM_EC_VSTORE
-#define CONFIG_VSTORE
-#define CONFIG_VSTORE_SLOT_COUNT CONFIG_PLATFORM_EC_VSTORE_SLOT_COUNT
-#endif
-
-/* motion sense */
-#undef CONFIG_MOTIONSENSE
-#ifdef CONFIG_PLATFORM_EC_MOTIONSENSE
-#define CONFIG_MOTIONSENSE
-
-#undef CONFIG_ACCEL_FIFO
-#undef CONFIG_ACCEL_FIFO_SIZE
-#undef CONFIG_ACCEL_FIFO_THRES
-#ifdef CONFIG_PLATFORM_EC_ACCEL_FIFO
-#define CONFIG_ACCEL_FIFO
-#define CONFIG_ACCEL_FIFO_SIZE CONFIG_PLATFORM_EC_ACCEL_FIFO_SIZE
-#define CONFIG_ACCEL_FIFO_THRES CONFIG_PLATFORM_EC_ACCEL_FIFO_THRES
-#endif /* CONFIG_PLATFORM_EC_ACCEL_FIFO */
-
-#undef CONFIG_CMD_ACCELS
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS
-#define CONFIG_CMD_ACCELS
-#endif
-
-#undef CONFIG_CMD_ACCEL_INFO
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO
-#define CONFIG_CMD_ACCEL_INFO
-#endif
-
-#undef CONFIG_ACCEL_SPOOF_MODE
-#ifdef CONFIG_PLATFORM_EC_ACCEL_SPOOF_MODE
-#define CONFIG_ACCEL_SPOOF_MODE
-#endif
-
-#undef CONFIG_CMD_ACCEL_SPOOF
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_SPOOF
-#define CONFIG_CMD_ACCEL_SPOOF
-#endif
-
-#undef CONFIG_SENSOR_TIGHT_TIMESTAMPS
-#ifdef CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS
-#define CONFIG_SENSOR_TIGHT_TIMESTAMPS
-#endif
-
-#undef CONFIG_ACCEL_INTERRUPTS
-#ifdef CONFIG_PLATFORM_EC_ACCEL_INTERRUPTS
-#define CONFIG_ACCEL_INTERRUPTS
-#endif
-
-#undef CONFIG_ALS
-#undef CONFIG_ALS_COUNT
-#ifdef CONFIG_PLATFORM_EC_ALS
-#define CONFIG_ALS
-#define ALS_COUNT CONFIG_PLATFORM_EC_ALS_COUNT
-#else
-#define ALS_COUNT 0
-#endif
-
-#undef CONFIG_DYNAMIC_MOTION_SENSOR_COUNT
-#ifdef CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT
-#define CONFIG_DYNAMIC_MOTION_SENSOR_COUNT
-#endif
-
-#undef CONFIG_LID_ANGLE
-#ifdef CONFIG_PLATFORM_EC_LID_ANGLE
-#define CONFIG_LID_ANGLE
-#endif
-
-#undef CONFIG_LID_ANGLE_UPDATE
-#ifdef CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE
-#define CONFIG_LID_ANGLE_UPDATE
-#endif
-
-#undef CONFIG_TABLET_MODE
-#ifdef CONFIG_PLATFORM_EC_TABLET_MODE
-#define CONFIG_TABLET_MODE
-#endif
-
-#undef CONFIG_TABLET_MODE_SWITCH
-#ifdef CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH
-#define CONFIG_TABLET_MODE_SWITCH
-#endif
-
-#undef CONFIG_GMR_TABLET_MODE
-#ifdef CONFIG_PLATFORM_EC_GMR_TABLET_MODE
-#define CONFIG_GMR_TABLET_MODE
-#endif
-
-/* sensors */
-#undef CONFIG_ACCELGYRO_BMI160
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI160
-#define CONFIG_ACCELGYRO_BMI160
-#endif
-
-#undef CONFIG_ACCELGYRO_BMI260
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI260
-#define CONFIG_ACCELGYRO_BMI260
-#endif
-
-#undef CONFIG_ACCELGYRO_BMI3XX
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX
-#define CONFIG_ACCELGYRO_BMI3XX
-#endif
-
-#undef CONFIG_ACCEL_BMA255
-#ifdef CONFIG_PLATFORM_EC_ACCEL_BMA255
-#define CONFIG_ACCEL_BMA255
-#endif
-
-#undef CONFIG_ACCEL_BMA4XX
-#ifdef CONFIG_PLATFORM_EC_ACCEL_BMA4XX
-#define CONFIG_ACCEL_BMA4XX
-#endif
-
-#undef CONFIG_ACCEL_KX022
-#ifdef CONFIG_PLATFORM_EC_ACCEL_KX022
-#define CONFIG_ACCEL_KX022
-#endif
-
-#undef CONFIG_ALS_TCS3400
-#ifdef CONFIG_PLATFORM_EC_ALS_TCS3400
-#define CONFIG_ALS_TCS3400
-#endif
-
-#undef CONFIG_ACCELGYRO_ICM426XX
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_ICM426XX
-#define CONFIG_ACCELGYRO_ICM426XX
-#endif
-
-#undef CONFIG_ACCELGYRO_ICM42607
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_ICM42607
-#define CONFIG_ACCELGYRO_ICM42607
-#endif
-
-#endif /* CONFIG_PLATFORM_EC_MOTIONSENSE */
-
-#undef CONFIG_HOSTCMD_GET_UPTIME_INFO
-#ifdef CONFIG_PLATFORM_EC_HOSTCMD_GET_UPTIME_INFO
-#define CONFIG_HOSTCMD_GET_UPTIME_INFO
-#endif
-
-#undef CONFIG_CMD_AP_RESET_LOG
-#ifdef CONFIG_PLATFORM_EC_AP_RESET_LOG
-#define CONFIG_CMD_AP_RESET_LOG
-#endif
-
-#undef CONFIG_POWER_BUTTON
-#ifdef CONFIG_PLATFORM_EC_POWER_BUTTON
-#define CONFIG_POWER_BUTTON
-#endif
-
-#undef CONFIG_COMMON_PANIC_OUTPUT
-#ifdef CONFIG_PLATFORM_EC_PANIC
-#define CONFIG_COMMON_PANIC_OUTPUT
-#endif
-
-#undef CONFIG_SOFTWARE_PANIC
-#ifdef CONFIG_PLATFORM_EC_SOFTWARE_PANIC
-#define CONFIG_SOFTWARE_PANIC
-#endif
-
-#undef CONFIG_CMD_CRASH
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_CRASH
-#define CONFIG_CMD_CRASH
-#endif
-
-#undef CONFIG_CMD_STACKOVERFLOW
-#ifdef CONFIG_PLATFORM_EC_STACKOVERFLOW
-#define CONFIG_CMD_STACKOVERFLOW
-#endif
-
-#undef CONFIG_CMD_MEM
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_MEM
-#define CONFIG_CMD_MEM
-#endif
-
-#undef CONFIG_CMD_MD
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_MD
-#define CONFIG_CMD_MD
-#endif
-
-#undef CONFIG_CMD_RW
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_RW
-#define CONFIG_CMD_RW
-#endif
-
-#undef CONFIG_RTC
-#ifdef CONFIG_PLATFORM_EC_RTC
-#define CONFIG_RTC
-#endif
-
-#undef CONFIG_CMD_RTC
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC
-#define CONFIG_CMD_RTC
-#endif
-
-#undef CONFIG_CMD_RTC_ALARM
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC_ALARM
-#define CONFIG_CMD_RTC_ALARM
-#endif
-
-#undef CONFIG_HOSTCMD_RTC
-#ifdef CONFIG_PLATFORM_EC_HOSTCMD_RTC
-#define CONFIG_HOSTCMD_RTC
-#endif
-
-#undef CONFIG_HOST_COMMAND_STATUS
-#ifdef CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS
-#define CONFIG_HOST_COMMAND_STATUS
-#endif
-
-#undef CONFIG_SWITCH
-#ifdef CONFIG_PLATFORM_EC_SWITCH
-#define CONFIG_SWITCH
-#endif
-
-#undef CONFIG_LN9310
-#ifdef CONFIG_PLATFORM_EC_SWITCHCAP_LN9310
-#define CONFIG_LN9310
-#endif
-
-#undef CONFIG_BOARD_VERSION_CBI
-#ifdef CONFIG_PLATFORM_EC_BOARD_VERSION_CBI
-#define CONFIG_BOARD_VERSION_CBI
-#endif
-
-#undef CONFIG_BOARD_VERSION_GPIO
-#ifdef CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO
-#define CONFIG_BOARD_VERSION_GPIO
-#endif
-
-#undef CONFIG_CBI_EEPROM
-#ifdef CONFIG_PLATFORM_EC_CBI_EEPROM
-#define CONFIG_CBI_EEPROM
-#define I2C_ADDR_EEPROM_FLAGS DT_REG_ADDR(DT_NODELABEL(cbi_eeprom))
-#endif
-
-#undef CONFIG_CBI_GPIO
-#ifdef CONFIG_PLATFORM_EC_CBI_GPIO
-#define CONFIG_CBI_GPIO
-#endif
-
-#undef CONFIG_VBOOT_HASH
-#ifdef CONFIG_PLATFORM_EC_VBOOT_HASH
-#define CONFIG_VBOOT_HASH
-#endif
-
-#undef CONFIG_SHA256_HW_ACCELERATE
-#ifdef CONFIG_PLATFORM_EC_SHA256_HW_ACCELERATE
-#define CONFIG_SHA256_HW_ACCELERATE
-#endif
-
-#undef CONFIG_RO_HDR_MEM_OFF
-#ifdef CONFIG_PLATFORM_EC_RO_HEADER_OFFSET
-#define CONFIG_RO_HDR_MEM_OFF CONFIG_PLATFORM_EC_RO_HEADER_OFFSET
-#else
-#define CONFIG_RO_HDR_MEM_OFF 0
-#endif
-
-#undef CONFIG_RO_HDR_SIZE
-#ifdef CONFIG_PLATFORM_EC_RO_HEADER_SIZE
-#define CONFIG_RO_HDR_SIZE CONFIG_PLATFORM_EC_RO_HEADER_SIZE
-#else
-#define CONFIG_RO_HDR_SIZE 0
-#endif
-
-#undef CONFIG_SYSTEM_UNLOCKED
-#ifdef CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED
-#define CONFIG_SYSTEM_UNLOCKED
-#endif
-
-#undef CONFIG_BYPASS_CBI_EEPROM_WP_CHECK
-#ifdef CONFIG_PLATFORM_EC_BYPASS_CBI_EEPROM_WP_CHECK
-#define CONFIG_BYPASS_CBI_EEPROM_WP_CHECK
-#endif
-
-#undef CONFIG_SPI_FLASH_REGS
-#ifdef CONFIG_PLATFORM_EC_SPI_FLASH_REGS
-#define CONFIG_SPI_FLASH_REGS
-#endif
-
-#undef CONFIG_CMD_CHARGEN
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGEN
-#define CONFIG_CMD_CHARGEN
-#endif
-
-#undef CONFIG_DEBUG_ASSERT
-#ifdef CONFIG_PLATFORM_EC_DEBUG_ASSERT
-#define CONFIG_DEBUG_ASSERT
-#endif
-
-#undef CONFIG_DEBUG_ASSERT_BRIEF
-#ifdef CONFIG_PLATFORM_EC_DEBUG_ASSERT_BRIEF
-#define CONFIG_DEBUG_ASSERT_BRIEF
-#endif
-
-#undef CONFIG_DEBUG_ASSERT_REBOOTS
-#ifdef CONFIG_PLATFORM_EC_DEBUG_ASSERT_REBOOTS
-#define CONFIG_DEBUG_ASSERT_REBOOTS
-#endif
-
-#undef CONFIG_MPU
-#ifdef CONFIG_PLATFORM_EC_MPU
-#define CONFIG_MPU
-#endif
-
-#undef CONFIG_CMD_SYSINFO
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO
-#define CONFIG_CMD_SYSINFO
-#endif
-
-#undef CONFIG_CMD_SCRATCHPAD
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_SCRATCHPAD
-#define CONFIG_CMD_SCRATCHPAD
-#endif
-
-#undef CONFIG_CMD_SYSJUMP
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSJUMP
-#define CONFIG_CMD_SYSJUMP
-#endif
-
-#undef CONFIG_WATCHDOG_PERIOD_MS
-#ifdef CONFIG_PLATFORM_EC_WATCHDOG_PERIOD_MS
-#define CONFIG_WATCHDOG_PERIOD_MS CONFIG_PLATFORM_EC_WATCHDOG_PERIOD_MS
-#endif
-
-#undef CONFIG_WATCHDOG_WARNING_LEADING_TIME_MS
-#if defined(CONFIG_PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS) || \
- defined(CONFIG_WDT_NPCX_DELAY_CYCLES) || \
- defined(CONFIG_WDT_ITE_WARNING_LEADING_TIME_MS)
-/*
- * Note:
- * NPCX wdt driver uses CONFIG_WDT_NPCX_DELAY_CYCLES to set the leading
- * time of the watchdog warning timer.
- * IT8XXX2 WDT driver uses CONFIG_WDT_ITE_WARNING_LEADING_TIME_MS period
- * between watchdog warning and reset.
- */
-#ifdef CONFIG_WDT_NPCX_DELAY_CYCLES
-#define CONFIG_WATCHDOG_WARNING_LEADING_TIME_MS \
- (CONFIG_WDT_NPCX_DELAY_CYCLES * 31)
-#elif CONFIG_WDT_ITE_WARNING_LEADING_TIME_MS
-#define CONFIG_WATCHDOG_WARNING_LEADING_TIME_MS \
- CONFIG_WDT_ITE_WARNING_LEADING_TIME_MS
-#else
-#define CONFIG_WATCHDOG_WARNING_LEADING_TIME_MS \
- CONFIG_PLATFORM_EC_WATCHDOG_WARNING_LEADING_TIME_MS
-#endif
-#endif
-
-#undef CONFIG_VBOOT_EFS
-#undef CONFIG_VBOOT_EFS2
-#ifdef CONFIG_PLATFORM_EC_VBOOT_EFS2
-#define CONFIG_VBOOT_EFS2
-#endif
-
-#undef CONFIG_USB_PD_TCPC_VCONN
-#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPC_VCONN
-#define CONFIG_USB_PD_TCPC_VCONN
-#endif
-
-#undef CONFIG_DPTF
-#ifdef CONFIG_PLATFORM_EC_DPTF
-#define CONFIG_DPTF
-#endif
-
-#undef CONFIG_CHARGER_BQ25710
-#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25710
-#define CONFIG_CHARGER_BQ25710
-#endif
-
-#undef CONFIG_CHARGER_BQ25720
-#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25720
-#define CONFIG_CHARGER_BQ25720
-#endif
-
-#undef CONFIG_CHARGER_BQ25720_VSYS_TH2_DV
-#ifdef CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_CUSTOM
-#define CONFIG_CHARGER_BQ25720_VSYS_TH2_DV \
- CONFIG_PLATFORM_EC_CHARGER_BQ25720_VSYS_TH2_DV
-#endif
-
-#undef CONFIG_HIBERNATE_PSL
-#ifdef CONFIG_PLATFORM_EC_HIBERNATE_PSL
-#define CONFIG_HIBERNATE_PSL
-#endif
-
-#undef CONFIG_BATTERY_DEVICE_CHEMISTRY
-#ifdef CONFIG_PLATFORM_EC_USE_BATTERY_DEVICE_CHEMISTRY
-#define CONFIG_BATTERY_DEVICE_CHEMISTRY \
- CONFIG_PLATFORM_EC_BATTERY_DEVICE_CHEMISTRY
-#endif
-
-#undef CONFIG_CHARGER_DISCHARGE_ON_AC
-#ifdef CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC
-#define CONFIG_CHARGER_DISCHARGE_ON_AC
-#endif
-
-#undef CONFIG_CHARGER_DISCHARGE_ON_AC_CUSTOM
-#ifdef CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CUSTOM
-#define CONFIG_CHARGER_DISCHARGE_ON_AC_CUSTOM
-#endif
-
-#undef CONFIG_CHARGER_SENSE_RESISTOR
-#ifdef CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR
-#define CONFIG_CHARGER_SENSE_RESISTOR \
- CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR
-#endif
-
-#undef CONFIG_CHARGER_SENSE_RESISTOR_AC
-#ifdef CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC
-#define CONFIG_CHARGER_SENSE_RESISTOR_AC \
- CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC
-#endif
-
-#undef CONFIG_CHARGER_PROFILE_OVERRIDE
-#ifdef CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE
-#define CONFIG_CHARGER_PROFILE_OVERRIDE
-#endif
-
-#undef CONFIG_CHARGER_PSYS
-#ifdef CONFIG_PLATFORM_EC_CHARGER_PSYS
-#define CONFIG_CHARGER_PSYS
-#endif
-
-#undef CONFIG_CHARGER_PSYS_READ
-#ifdef CONFIG_PLATFORM_EC_CHARGER_PSYS_READ
-#define CONFIG_CHARGER_PSYS_READ
-#endif
-
-#undef CONFIG_CMD_CHARGER_ADC_AMON_BMON
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON
-#define CONFIG_CMD_CHARGER_ADC_AMON_BMON
-#endif
-
-#undef CONFIG_USB_PD_ONLY_FIXED_PDOS
-#ifdef CONFIG_PLATFORM_EC_USB_PD_ONLY_FIXED_PDOS
-#define CONFIG_USB_PD_ONLY_FIXED_PDOS
-#endif
-
-#undef CONFIG_MP2964
-#ifdef CONFIG_PLATFORM_EC_MP2964
-#define CONFIG_MP2964
-#endif
-
-#undef CONFIG_ACCELGYRO_ICM_COMM_SPI
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_ICM_COMM_SPI
-#define CONFIG_ACCELGYRO_ICM_COMM_SPI
-#endif
-
-#undef CONFIG_ACCELGYRO_ICM_COMM_I2C
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_ICM_COMM_I2C
-#define CONFIG_ACCELGYRO_ICM_COMM_I2C
-#endif
-
-#undef CONFIG_ACCELGYRO_BMI_COMM_SPI
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_SPI
-#define CONFIG_ACCELGYRO_BMI_COMM_SPI
-#endif
-
-#undef CONFIG_ACCELGYRO_BMI_COMM_I2C
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C
-#define CONFIG_ACCELGYRO_BMI_COMM_I2C
-#endif
-
-#undef CONFIG_CMD_SLEEPMASK
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_SLEEPMASK
-#define CONFIG_CMD_SLEEPMASK
-#endif
-
-#undef CONFIG_CMD_SLEEPMASK_SET
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_SLEEPMASK_SET
-#define CONFIG_CMD_SLEEPMASK_SET
-#endif
-
-#undef CONFIG_LOW_POWER_IDLE
-#ifdef CONFIG_PLATFORM_EC_LOW_POWER_IDLE
-#define CONFIG_LOW_POWER_IDLE
-#endif
-
-#undef CONFIG_PORT80_4_BYTE
-#ifdef CONFIG_PLATFORM_EC_PORT80_4_BYTE
-#define CONFIG_PORT80_4_BYTE
-#endif
-
-#undef CONFIG_ASSERT_CCD_MODE_ON_DTS_CONNECT
-#ifdef CONFIG_PLATFORM_EC_ASSERT_CCD_MODE_ON_DTS_CONNECT
-#define CONFIG_ASSERT_CCD_MODE_ON_DTS_CONNECT
-#endif
-
-#undef CONFIG_CCD_USBC_PORT_NUMBER
-#ifdef CONFIG_PLATFORM_EC_CCD_USBC_PORT_NUMBER
-#define CONFIG_CCD_USBC_PORT_NUMBER CONFIG_PLATFORM_EC_CCD_USBC_PORT_NUMBER
-#endif
-
-#undef CONFIG_ACCEL_LIS2DW12
-#ifdef CONFIG_PLATFORM_EC_ACCEL_LIS2DW12
-#define CONFIG_ACCEL_LIS2DW12
-#endif
-
-#undef CONFIG_ACCEL_LIS2DW_AS_BASE
-#ifdef CONFIG_PLATFORM_EC_ACCEL_LIS2DW12_AS_BASE
-#define CONFIG_ACCEL_LIS2DW_AS_BASE
-#endif
-
-#undef CONFIG_CONSOLE_CHANNEL
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CHANNEL
-#define CONFIG_CONSOLE_CHANNEL
-#endif
-
-#undef CONFIG_USB_PD_DP_HPD_GPIO
-#ifdef CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO
-#define CONFIG_USB_PD_DP_HPD_GPIO
-#endif
-
-#undef CONFIG_USB_PD_DP_HPD_GPIO_CUSTOM
-#ifdef CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO_CUSTOM
-#define CONFIG_USB_PD_DP_HPD_GPIO_CUSTOM
-#endif
-
-#undef CONSOLE_CMD_MFALLOW
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_MFALLOW
-#define CONSOLE_CMD_MFALLOW
-#endif
-
-#undef CONFIG_TEMP_SENSOR_FIRST_READ_DELAY_MS
-#ifdef CONFIG_PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY
-#define CONFIG_TEMP_SENSOR_FIRST_READ_DELAY_MS \
- CONFIG_PLATFORM_EC_TEMP_SENSOR_FIRST_READ_DELAY_MS
-#endif
-
-#undef CONFIG_CMD_S5_TIMEOUT
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_S5_TIMEOUT
-#define CONFIG_CMD_S5_TIMEOUT
-#endif
-
-#undef CONFIG_FW_RESET_VECTOR
-#ifdef CONFIG_PLATFORM_EC_FW_RESET_VECTOR
-#define CONFIG_FW_RESET_VECTOR
-#endif
-
-#undef CONFIG_HOSTCMD_DEBUG_MODE
-#if defined(CONFIG_HCDEBUG_OFF)
-#define CONFIG_HOSTCMD_DEBUG_MODE 0
-#elif defined(CONFIG_HCDEBUG_NORMAL)
-#define CONFIG_HOSTCMD_DEBUG_MODE 1
-#elif defined(CONFIG_HCDEBUG_EVERY)
-#define CONFIG_HOSTCMD_DEBUG_MODE 2
-#elif defined(CONFIG_HCDEBUG_PARAMS)
-#define CONFIG_HOSTCMD_DEBUG_MODE 3
-#endif
-
-#undef CONFIG_AMD_SB_RMI
-#ifdef CONFIG_PLATFORM_EC_AMD_SB_RMI
-#define CONFIG_AMD_SB_RMI
-#endif
-
-#undef CONFIG_AMD_STT
-#ifdef CONFIG_PLATFORM_EC_AMD_STT
-#define CONFIG_AMD_STT
-#endif
-
-#endif /* __CROS_EC_CONFIG_CHIP_H */
diff --git a/zephyr/shim/include/cpu.h b/zephyr/shim/include/cpu.h
deleted file mode 100644
index 617f644fa9..0000000000
--- a/zephyr/shim/include/cpu.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_CPU_H
-#define __CROS_EC_CPU_H
-
-/* Do nothing for Zephyr */
-static inline void cpu_init(void)
-{
-}
-
-#endif /* __CROS_EC_CPU_H */
diff --git a/zephyr/shim/include/ec_tasks.h b/zephyr/shim/include/ec_tasks.h
deleted file mode 100644
index 6f75bd577e..0000000000
--- a/zephyr/shim/include/ec_tasks.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __CROS_EC_EC_TASKS_H
-#define __CROS_EC_EC_TASKS_H
-
-/*
- * The lowest preemptive thread priority is (CONFIG_NUM_PREEMT_PRIORITIES-1)
- * while the lowest cooperative thread priority is -1.
- *
- * https://docs.zephyrproject.org/latest/reference/kernel/threads/index.html#thread-priorities
- */
-#define LOWEST_THREAD_PRIORITY \
- COND_CODE_1(CONFIG_PREEMPT_ENABLED, \
- (CONFIG_NUM_PREEMPT_PRIORITIES - 1), (-1))
-
-/** Starts all of the shimmed EC tasks. Requires CONFIG_SHIMMED_TASKS=y. */
-void start_ec_tasks(void);
-
-#ifdef TEST_BUILD
-/**
- * Set TASK_ID_TEST_RUNNER to current thread tid. Some functions that are tested
- * require to run in any task context.
- */
-void set_test_runner_tid(void);
-#endif
-
-#endif /* __CROS_EC_EC_TASKS_H */
diff --git a/zephyr/shim/include/fpu.h b/zephyr/shim/include/fpu.h
deleted file mode 100644
index da36f50492..0000000000
--- a/zephyr/shim/include/fpu.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_FPU_H
-#define __CROS_EC_FPU_H
-
-/*
- * These functions are available in newlib but we are are using Zephyr's
- * minimal library at present.
- *
- * This file is not called math.h to avoid a conflict with the toolchain's
- * built-in version.
- *
- * This code is taken from core/cortex-m/include/fpu.h
- */
-
-#ifdef CONFIG_PLATFORM_EC_FPU
-
-/* Implementation for Cortex-M */
-#ifdef CONFIG_CPU_CORTEX_M
-static inline float sqrtf(float v)
-{
- float root;
-
- /* Use the CPU instruction */
- __asm__ volatile(
- "fsqrts %0, %1"
- : "=w" (root)
- : "w" (v)
- );
-
- return root;
-}
-
-static inline float fabsf(float v)
-{
- float root;
-
- /* Use the CPU instruction */
- __asm__ volatile(
- "fabss %0, %1"
- : "=w" (root)
- : "w" (v)
- );
-
- return root;
-}
-#else
-#error "Unsupported core: please add an implementation"
-#endif /* CONFIG_CPU_CORTEX_M */
-
-#endif /* CONFIG_PLATFORM_EC_FPU */
-
-#endif /* __CROS_EC_MATH_H */
diff --git a/zephyr/shim/include/gpio/gpio.h b/zephyr/shim/include/gpio/gpio.h
deleted file mode 100644
index 18089e8a8e..0000000000
--- a/zephyr/shim/include/gpio/gpio.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef ZEPHYR_SHIM_INCLUDE_GPIO_GPIO_H_
-#define ZEPHYR_SHIM_INCLUDE_GPIO_GPIO_H_
-
-#include <device.h>
-#include <devicetree.h>
-
-/* Information about each unused pin in the 'unused-pins' device tree node. */
-struct unused_pin_config {
- /* Device name of a unused gpio pin */
- const char *dev_name;
- /* Bit number of pin within a unused gpio pin */
- gpio_pin_t pin;
- /* Config flags of unused gpio pin */
- gpio_flags_t flags;
-};
-
-/**
- * @brief Set proper configuration for all unused pins.
- *
- * This function loops through all unused GPIOs in the node of "unused-gpios"
- * in the device tree file to set proper configuration. If the GPIO flag is 0,
- * set the GPIOs default setting for floating IOs to improve the power
- * consumption.
- *
- * @return 0 If successful.
- * @retval -ENOTSUP Not supported gpio device.
- * @retval -EIO I/O error when accessing an external GPIO chip.
- */
-int gpio_config_unused_pins(void) __attribute__((weak));
-
-#if DT_NODE_EXISTS(DT_PATH(unused_pins))
-/**
- * @brief Get a node from path '/unused-pins' which has a prop 'unused-gpios'.
- * It contains unused GPIOs and chip vendor needs to configure them for
- * better power consumption in the lowest power state.
- *
- * @return node identifier with that path.
- */
-#define UNUSED_PINS_LIST DT_PATH(unused_pins)
-
-/**
- * @brief Length of 'unused-gpios' property
- *
- * @return length of 'unused-gpios' prop which type is 'phandle-array'
- */
-#define UNUSED_GPIOS_LIST_LEN DT_PROP_LEN(UNUSED_PINS_LIST, unused_gpios)
-
-/**
- * @brief Construct a unused_pin_config structure from 'unused-gpios' property
- * at index 'i'
- *
- * @param i index of 'unused-gpios' prop which type is 'phandles-array'
- * @return unused_pin_config item at index 'i'
- */
-#define UNUSED_GPIO_CONFIG_BY_IDX(i, _) \
- { \
- .dev_name = DT_GPIO_LABEL_BY_IDX(UNUSED_PINS_LIST, \
- unused_gpios, i), \
- .pin = DT_GPIO_PIN_BY_IDX(UNUSED_PINS_LIST, unused_gpios, i), \
- .flags = DT_GPIO_FLAGS_BY_IDX(UNUSED_PINS_LIST, unused_gpios, \
- i), \
- },
-
-/**
- * @brief Macro function to construct a list of unused_pin_config items by
- * UTIL_LISTIFY func.
- *
- * Example devicetree fragment:
- * / {
- * unused-pins {
- * compatible = "unused-gpios";
- * unused-gpios = <&gpio5 1 0>,
- * <&gpiod 0 0>,
- * <&gpiof 3 0>;
- * };
- *
- * Example usage:
- * static const struct unused_pin_config unused_pin_configs[] = {
- * UNUSED_GPIO_CONFIG_LIST
- * };
- *
- * @return a list of unused_pin_config items
- */
-#define UNUSED_GPIO_CONFIG_LIST \
- UTIL_LISTIFY(UNUSED_GPIOS_LIST_LEN, UNUSED_GPIO_CONFIG_BY_IDX, _)
-
-#else
-#define UNUSED_GPIO_CONFIG_LIST /* Nothing if no 'unused-pins' node */
-#endif /* unused_pins */
-#endif /* ZEPHYR_SHIM_INCLUDE_GPIO_GPIO_H_ */
diff --git a/zephyr/shim/include/i2c/i2c.h b/zephyr/shim/include/i2c/i2c.h
deleted file mode 100644
index d945732856..0000000000
--- a/zephyr/shim/include/i2c/i2c.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef ZEPHYR_CHROME_I2C_I2C_H
-#define ZEPHYR_CHROME_I2C_I2C_H
-
-#include <device.h>
-#include <devicetree.h>
-
-#ifdef CONFIG_PLATFORM_EC_I2C
-#if DT_NODE_EXISTS(DT_PATH(named_i2c_ports))
-
-#define I2C_PORT(id) DT_STRING_UPPER_TOKEN(id, enum_name)
-#define I2C_PORT_WITH_COMMA(id) I2C_PORT(id),
-
-enum i2c_ports {
- DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), I2C_PORT_WITH_COMMA)
- I2C_PORT_COUNT
-};
-#define NAMED_I2C(name) I2C_PORT(DT_PATH(named_i2c_ports, name))
-#endif /* named_i2c_ports */
-#endif /* CONFIG_PLATFORM_EC_I2C */
-
-/**
- * @brief Adaptation of platform/ec's port IDs which map a port/bus to a device.
- *
- * This function should be implemented per chip and should map the enum value
- * defined for the chip for encoding each valid port/bus combination. For
- * example, the npcx chip defines the port/bus combinations NPCX_I2C_PORT* under
- * chip/npcx/registers-npcx7.h.
- *
- * Thus, the npcx shim should implement this function to map the enum values
- * to the correct devicetree device.
- *
- * @param port The port to get the device for.
- * @return Pointer to the device struct or {@code NULL} if none are available.
- */
-const struct device *i2c_get_device_for_port(const int port);
-
-/**
- * @brief Get a port number for a received remote port number.
- *
- * This function translate a received port number via the I2C_PASSTHRU host
- * command to a port number used in ZephyrEC based on remote_port property in
- * dts. The first port which matches the remote port number is returned.
- *
- * @param port The received remote port.
- * @return Port number used in EC. -1 if the remote port is not defined
- */
-int i2c_get_port_from_remote_port(int remote_port);
-
-#endif /* ZEPHYR_CHROME_I2C_I2C_H */
diff --git a/zephyr/shim/include/linker.h b/zephyr/shim/include/linker.h
deleted file mode 100644
index 335f4f0f19..0000000000
--- a/zephyr/shim/include/linker.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __CROS_EC_LINKER_H
-#define __CROS_EC_LINKER_H
-
-/* Put the start of shared memory after all allocated RAM symbols */
-#define __shared_mem_buf _image_ram_end
-
-#endif
diff --git a/zephyr/shim/include/motionsense_sensors.h b/zephyr/shim/include/motionsense_sensors.h
deleted file mode 100644
index bdec8e79bd..0000000000
--- a/zephyr/shim/include/motionsense_sensors.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_MOTIONSENSE_SENSORS_H
-#define __CROS_EC_MOTIONSENSE_SENSORS_H
-
-#include <devicetree.h>
-
-#define SENSOR_NODE DT_PATH(motionsense_sensor)
-#define SENSOR_INFO_NODE DT_PATH(motionsense_sensor_info)
-#define SENSOR_ALT_NODE DT_PATH(motionsense_sensor_alt)
-
-#define SENSOR_ID(id) DT_CAT(SENSOR_, id)
-
-/* Define the SENSOR_ID if:
- * DT_NODE_HAS_STATUS(id, okay) && !DT_NODE_HAS_PROP(id, alternate_for)
- */
-#define SENSOR_ID_WITH_COMMA(id) \
- IF_ENABLED(DT_NODE_HAS_STATUS(id, okay), \
- (COND_CODE_0(DT_NODE_HAS_PROP(id, alternate_for), \
- (SENSOR_ID(id), ), ())))
-
-enum sensor_id {
-#if DT_NODE_EXISTS(SENSOR_NODE)
- DT_FOREACH_CHILD(SENSOR_NODE, SENSOR_ID_WITH_COMMA)
-#endif
- SENSOR_COUNT,
-};
-
-#undef SENSOR_ID_WITH_COMMA
-/* Define the SENSOR_ID if:
- * DT_NODE_HAS_STATUS(id, okay) && DT_NODE_HAS_PROP(id, alternate_for)
- */
-#define SENSOR_ID_WITH_COMMA(id) \
- IF_ENABLED(DT_NODE_HAS_STATUS(id, okay), \
- (COND_CODE_1(DT_NODE_HAS_PROP(id, alternate_for), \
- (SENSOR_ID(id), ), ())))
-enum sensor_alt_id {
-#if DT_NODE_EXISTS(SENSOR_ALT_NODE)
- DT_FOREACH_CHILD(SENSOR_ALT_NODE, SENSOR_ID_WITH_COMMA)
-#endif
- SENSOR_ALT_COUNT,
-};
-
-/*
- * Find the accelerometers for lid angle calculation.
- *
- * The angle calculation requires two accelerometers. One is on the lid
- * and the other one is on the base. So we need to specify which sensor is
- * on the lid and which one is on the base. We use two labels "lid_accel"
- * and "base_accel".
- *
- * base_accel - label for the accelerometer sensor on the base.
- * lid_accel - label for the accelerometer sensor on the lid.
- *
- * e.g) below shows BMA255 is the accelerometer on the lid and bmi260 is
- * the accelerometer on the base.
- *
- * motionsense-sensor {
- * lid_accel: lid-accel {
- * compatible = "cros-ec,bma255";
- * status = "okay";
- * :
- * :
- * };
- *
- * base_accel: base-accel {
- * compatible = "cros-ec,bmi260";
- * status = "okay";
- * :
- * :
- * };
- * };
- */
-#ifdef CONFIG_LID_ANGLE
-#define CONFIG_LID_ANGLE_SENSOR_LID SENSOR_ID(DT_NODELABEL(lid_accel))
-#define CONFIG_LID_ANGLE_SENSOR_BASE SENSOR_ID(DT_NODELABEL(base_accel))
-#endif
-
-/*
- * Get the sensors running in force mode from DT and create a bit mask for it.
- *
- * e.g) lid accel and als_clear are in accel_force_mode. The macro below finds
- * the corresponding bit for each sensor in bit mask and set it.
- * motionsense-sensor-info {
- * compatible = "cros-ec,motionsense-sensor-info";
- *
- * // list of sensors in force mode
- * accel-force-mode-sensors = <&lid_accel &als_clear>;
- * };
- */
-#if DT_NODE_HAS_PROP(SENSOR_INFO_NODE, accel_force_mode_sensors)
-#define SENSOR_IN_FORCE_MODE(i, id) \
- | BIT(SENSOR_ID(DT_PHANDLE_BY_IDX(id, accel_force_mode_sensors, i)))
-#define CONFIG_ACCEL_FORCE_MODE_MASK \
- (0 UTIL_LISTIFY(DT_PROP_LEN(SENSOR_INFO_NODE, \
- accel_force_mode_sensors), SENSOR_IN_FORCE_MODE, \
- SENSOR_INFO_NODE))
-#endif
-
-#endif /* __CROS_EC_MOTIONSENSE_SENSORS_H */
diff --git a/zephyr/shim/include/mpu.h b/zephyr/shim/include/mpu.h
deleted file mode 100644
index 3555ef0db1..0000000000
--- a/zephyr/shim/include/mpu.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_MPU_H
-#define __CROS_EC_MPU_H
-
-/* This matches up with core/cortex-m/include/mpu.h */
-
-/* Location of iram.text */
-extern char __iram_text_start;
-extern char __iram_text_end;
-
-/** Enable MPU */
-void mpu_enable(void);
-
-/**
- * Returns the value of MPU type register
- *
- * @returns 0 for now (always)
- */
-uint32_t mpu_get_type(void);
-
-/** Protect RAM from code execution */
-int mpu_protect_data_ram(void);
-
-/** Protect code RAM from being overwritten */
-int mpu_protect_code_ram(void);
-
-/** Protect internal mapped flash memory from code execution */
-int mpu_lock_ro_flash(void);
-int mpu_lock_rw_flash(void);
-
-#endif /* __CROS_EC_CPU_H */
diff --git a/zephyr/shim/include/pwm/pwm.h b/zephyr/shim/include/pwm/pwm.h
deleted file mode 100644
index 1bf4685837..0000000000
--- a/zephyr/shim/include/pwm/pwm.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef ZEPHYR_SHIM_INCLUDE_PWM_PWM_H_
-#define ZEPHYR_SHIM_INCLUDE_PWM_PWM_H_
-
-#include <device.h>
-#include <devicetree.h>
-
-#if DT_NODE_EXISTS(DT_PATH(named_pwms))
-
-#define PWM_CHANNEL(id) DT_CAT(PWM_, id)
-#define PWM_CHANNEL_WITH_COMMA(id) PWM_CHANNEL(id),
-
-enum pwm_channel {
- DT_FOREACH_CHILD(DT_PATH(named_pwms), PWM_CHANNEL_WITH_COMMA)
- PWM_CH_COUNT,
-};
-
-#define NAMED_PWM(name) PWM_CHANNEL(DT_PATH(named_pwms, name))
-
-#endif /* named_pwms */
-
-#endif /* ZEPHYR_SHIM_INCLUDE_PWM_PWM_H_ */
diff --git a/zephyr/shim/include/registers.h b/zephyr/shim/include/registers.h
deleted file mode 100644
index b693733a21..0000000000
--- a/zephyr/shim/include/registers.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __CROS_EC_REGISTERS_H
-#define __CROS_EC_REGISTERS_H
-
-/*
- * This file is left intentionally blank. It is required since many of the
- * shimmed files from platform/ec/common include it. Normally, this file
- * would define chip specific registers and would reside under
- * platform/ec/chip/...
- */
-
-#endif /* __CROS_EC_REGISTERS_H */
diff --git a/zephyr/shim/include/shimmed_task_id.h b/zephyr/shim/include/shimmed_task_id.h
deleted file mode 100644
index f56edf0806..0000000000
--- a/zephyr/shim/include/shimmed_task_id.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __CROS_EC_SHIMMED_TASK_ID_H
-#define __CROS_EC_SHIMMED_TASK_ID_H
-
-#include "common.h"
-
-/* Task identifier (8 bits) */
-typedef uint8_t task_id_t;
-
-/*
- * Highest priority on bottom -- same as in platform/ec. List of CROS_EC_TASK
- * items. See CONFIG_TASK_LIST in platform/ec's config.h for more information.
- * For tests that want their own custom tasks, use CONFIG_HAS_TEST_TASKS and not
- * CONFIG_SHIMMED_TASKS.
- */
-#ifdef CONFIG_SHIMMED_TASKS
-#define CROS_EC_TASK_LIST \
- COND_CODE_1(HAS_TASK_HOOKS, \
- (CROS_EC_TASK(HOOKS, hook_task, 0, \
- CONFIG_TASK_HOOKS_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_CHG_RAMP, \
- (CROS_EC_TASK(CHG_RAMP, chg_ramp_task, 0, \
- CONFIG_TASK_CHG_RAMP_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_USB_CHG_P0, \
- (CROS_EC_TASK(USB_CHG_P0, usb_charger_task, 0, \
- CONFIG_TASK_USB_CHG_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_USB_CHG_P1, \
- (CROS_EC_TASK(USB_CHG_P1, usb_charger_task, 0, \
- CONFIG_TASK_USB_CHG_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_USB_CHG_P2, \
- (CROS_EC_TASK(USB_CHG_P2, usb_charger_task, 0, \
- CONFIG_TASK_USB_CHG_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_CHARGER, \
- (CROS_EC_TASK(CHARGER, charger_task, 0, \
- CONFIG_TASK_CHARGER_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_CHIPSET, \
- (CROS_EC_TASK(CHIPSET, chipset_task, 0, \
- CONFIG_TASK_CHIPSET_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_MOTIONSENSE, \
- (CROS_EC_TASK(MOTIONSENSE, motion_sense_task, 0, \
- CONFIG_TASK_MOTIONSENSE_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_HOSTCMD, \
- (CROS_EC_TASK(HOSTCMD, host_command_task, 0, \
- CONFIG_TASK_HOSTCMD_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_KEYPROTO, \
- (CROS_EC_TASK(KEYPROTO, keyboard_protocol_task, 0, \
- CONFIG_TASK_KEYPROTO_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_POWERBTN, \
- (CROS_EC_TASK(POWERBTN, power_button_task, 0, \
- CONFIG_TASK_POWERBTN_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_KEYSCAN, \
- (CROS_EC_TASK(KEYSCAN, keyboard_scan_task, 0, \
- CONFIG_TASK_KEYSCAN_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_PD_C0, \
- (CROS_EC_TASK(PD_C0, pd_task, 0, \
- CONFIG_TASK_PD_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_PD_C1, \
- (CROS_EC_TASK(PD_C1, pd_task, 0, \
- CONFIG_TASK_PD_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_PD_C2, \
- (CROS_EC_TASK(PD_C2, pd_task, 0, \
- CONFIG_TASK_PD_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_PD_C3, \
- (CROS_EC_TASK(PD_C3, pd_task, 0, \
- CONFIG_TASK_PD_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_PD_INT_C0, \
- (CROS_EC_TASK(PD_INT_C0, pd_interrupt_handler_task, 0, \
- CONFIG_TASK_PD_INT_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_PD_INT_C1, \
- (CROS_EC_TASK(PD_INT_C1, pd_interrupt_handler_task, 1, \
- CONFIG_TASK_PD_INT_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_PD_INT_C2, \
- (CROS_EC_TASK(PD_INT_C2, pd_interrupt_handler_task, 2, \
- CONFIG_TASK_PD_INT_STACK_SIZE)), ()) \
- COND_CODE_1(HAS_TASK_PD_INT_C3, \
- (CROS_EC_TASK(PD_INT_C3, pd_interrupt_handler_task, 3, \
- CONFIG_TASK_PD_INT_STACK_SIZE)), ())
-#elif defined(CONFIG_HAS_TEST_TASKS)
-#include "shimmed_test_tasks.h"
-/*
- * There are two different ways to define a task list (because historical
- * reasons). Applications use CROS_EC_TASK_LIST to define their tasks, while
- * unit tests that need additional tasks use CONFIG_TEST_TASK_LIST. For
- * shimming a unit test, define CROS_EC_TASk_LIST as whatever
- * CONFIG_TEST_TASK_LIST expands to.
- */
-#if defined(CONFIG_TEST_TASK_LIST) && !defined(CROS_EC_TASK_LIST)
-#define CROS_EC_TASK_LIST CONFIG_TEST_TASK_LIST
-#endif /* CONFIG_TEST_TASK_LIST && !CROS_EC_TASK_LIST */
-#endif /* !CONFIG_ZTEST */
-
-#ifndef CROS_EC_TASK_LIST
-#define CROS_EC_TASK_LIST
-#endif /* CROS_EC_TASK_LIST */
-
-/*
- * Define the task_ids globally for all shimmed platform/ec code to use.
- * Note that unit test task lists use TASK_TEST, which we can just alias
- * into a regular CROS_EC_TASK.
- */
-#define CROS_EC_TASK(name, ...) TASK_ID_##name,
-#define TASK_TEST(name, ...) CROS_EC_TASK(name)
-enum {
- TASK_ID_IDLE = -1, /* We don't shim the idle task */
- CROS_EC_TASK_LIST
-#ifdef TEST_BUILD
- TASK_ID_TEST_RUNNER,
-#endif
- TASK_ID_COUNT,
- TASK_ID_INVALID = 0xff, /* Unable to find the task */
-};
-#undef CROS_EC_TASK
-#undef TASK_TEST
-
-#endif /* __CROS_EC_SHIMMED_TASK_ID_H */
diff --git a/zephyr/shim/include/shimmed_tasks.h b/zephyr/shim/include/shimmed_tasks.h
deleted file mode 100644
index 631b3fcb16..0000000000
--- a/zephyr/shim/include/shimmed_tasks.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __CROS_EC_SHIMMED_TASKS_H
-#define __CROS_EC_SHIMMED_TASKS_H
-
-#ifdef CONFIG_HAS_TASK_CHARGER
-#define HAS_TASK_CHARGER 1
-#endif /* CONFIG_HAS_TASK_CHARGER */
-
-#ifdef CONFIG_HAS_TASK_CHG_RAMP
-#define HAS_TASK_CHG_RAMP 1
-#endif /* CONFIG_HAS_TASK_CHG_RAMP */
-
-#ifdef CONFIG_HAS_TASK_CHIPSET
-#define HAS_TASK_CHIPSET 1
-#endif /* CONFIG_HAS_TASK_CHIPSET */
-
-#ifdef CONFIG_HAS_TASK_HOOKS
-#define HAS_TASK_HOOKS 1
-#endif /* CONFIG_HAS_TASK_HOOKS */
-
-#ifdef CONFIG_HAS_TASK_HOSTCMD
-#define HAS_TASK_HOSTCMD 1
-#define CONFIG_HOSTCMD_EVENTS
-#endif /* CONFIG_HAS_TASK_HOSTCMD */
-
-#ifdef CONFIG_HAS_TASK_KEYSCAN
-#define HAS_TASK_KEYSCAN 1
-#endif /* CONFIG_HAS_TASK_KEYSCAN */
-
-#ifdef CONFIG_HAS_TASK_KEYPROTO
-#define HAS_TASK_KEYPROTO 1
-#endif /* CONFIG_HAS_TASK_KEYPROTO */
-
-#ifdef CONFIG_HAS_TASK_MOTIONSENSE
-#define HAS_TASK_MOTIONSENSE 1
-#endif /* CONFIG_HAS_TASK_MOTIONSENSE */
-
-#ifdef CONFIG_HAS_TASK_PD_C0
-#define HAS_TASK_PD_C0 1
-#endif /* CONFIG_HAS_TASK_PD_C0 */
-
-#ifdef CONFIG_HAS_TASK_PD_C1
-#define HAS_TASK_PD_C1 1
-#endif /* CONFIG_HAS_TASK_PD_C1 */
-
-#ifdef CONFIG_HAS_TASK_PD_C2
-#define HAS_TASK_PD_C2 1
-#endif /* CONFIG_HAS_TASK_PD_C2 */
-
-#ifdef CONFIG_HAS_TASK_PD_C3
-#define HAS_TASK_PD_C3 1
-#endif /* CONFIG_HAS_TASK_PD_C3 */
-
-#ifdef CONFIG_HAS_TASK_PD_INT_C0
-#define HAS_TASK_PD_INT_C0 1
-#endif /* CONFIG_HAS_TASK_PD_INT_C0 */
-
-#ifdef CONFIG_HAS_TASK_PD_INT_C1
-#define HAS_TASK_PD_INT_C1 1
-#endif /* CONFIG_HAS_TASK_PD_INT_C1 */
-
-#ifdef CONFIG_HAS_TASK_PD_INT_C2
-#define HAS_TASK_PD_INT_C2 1
-#endif /* CONFIG_HAS_TASK_PD_INT_C2 */
-
-#ifdef CONFIG_HAS_TASK_PD_INT_C3
-#define HAS_TASK_PD_INT_C3 1
-#endif /* CONFIG_HAS_TASK_PD_INT_C3 */
-
-#ifdef CONFIG_HAS_TASK_POWERBTN
-#define HAS_TASK_POWERBTN 1
-#endif /* CONFIG_HAS_TASK_POWERBTN */
-
-#ifdef CONFIG_HAS_TASK_USB_CHG_P0
-#define HAS_TASK_USB_CHG_P0 1
-#endif /* CONFIG_HAS_TASK_USB_CHG_P0 */
-
-#ifdef CONFIG_HAS_TASK_USB_CHG_P1
-#define HAS_TASK_USB_CHG_P1 1
-#endif /* CONFIG_HAS_TASK_USB_CHG_P1 */
-
-#ifdef CONFIG_HAS_TASK_USB_CHG_P2
-#define HAS_TASK_USB_CHG_P2 1
-#endif /* CONFIG_HAS_TASK_USB_CHG_P2 */
-
-#endif /* __CROS_EC_SHIMMED_TASKS_H */
diff --git a/zephyr/shim/include/temp_sensor/temp_sensor.h b/zephyr/shim/include/temp_sensor/temp_sensor.h
deleted file mode 100644
index b0cadd4303..0000000000
--- a/zephyr/shim/include/temp_sensor/temp_sensor.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef ZEPHYR_SHIM_INCLUDE_TEMP_SENSOR_TEMP_SENSOR_H_
-#define ZEPHYR_SHIM_INCLUDE_TEMP_SENSOR_TEMP_SENSOR_H_
-
-#include <devicetree.h>
-
-#ifdef CONFIG_PLATFORM_EC_TEMP_SENSOR
-
-#define ZSHIM_TEMP_SENSOR_ID(node_id) DT_STRING_UPPER_TOKEN(node_id, enum_name)
-#define TEMP_SENSOR_ID_WITH_COMMA(node_id) ZSHIM_TEMP_SENSOR_ID(node_id),
-
-enum temp_sensor_id {
-#if DT_NODE_EXISTS(DT_PATH(named_temp_sensors))
- DT_FOREACH_CHILD(DT_PATH(named_temp_sensors),
- TEMP_SENSOR_ID_WITH_COMMA)
-#endif /* named_temp_sensors */
- TEMP_SENSOR_COUNT
-};
-
-#undef TEMP_SENSOR_ID_WITH_COMMA
-
-#endif /* CONFIG_PLATFORM_EC_TEMP_SENSOR */
-
-#endif /* ZEPHYR_SHIM_INCLUDE_TEMP_SENSOR_TEMP_SENSOR_H_ */
diff --git a/zephyr/shim/include/zephyr_adc.h b/zephyr/shim/include/zephyr_adc.h
deleted file mode 100644
index 7c0f3f3232..0000000000
--- a/zephyr/shim/include/zephyr_adc.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __CROS_EC_ZEPHYR_ADC_H
-#define __CROS_EC_ZEPHYR_ADC_H
-
-#include <drivers/adc.h>
-
-#ifdef CONFIG_PLATFORM_EC_ADC
-
-#define ZSHIM_ADC_ID(node_id) DT_STRING_UPPER_TOKEN(node_id, enum_name)
-#define ADC_ID_WITH_COMMA(node_id) ZSHIM_ADC_ID(node_id),
-
-enum adc_channel {
-#if DT_NODE_EXISTS(DT_INST(0, named_adc_channels))
- DT_FOREACH_CHILD(DT_INST(0, named_adc_channels), ADC_ID_WITH_COMMA)
-#endif /* named_adc_channels */
- ADC_CH_COUNT
-};
-
-#undef ADC_ID_WITH_COMMA
-
-struct adc_t {
- const char *name;
- uint8_t input_ch;
- int factor_mul;
- int factor_div;
- struct adc_channel_cfg channel_cfg;
-};
-
-extern const struct adc_t adc_channels[];
-#else
-/* Empty declaration to avoid warnings if adc.h is included */
-enum adc_channel {
- ADC_CH_COUNT
-};
-#endif /* CONFIG_PLATFORM_EC_ADC */
-
-#endif /* __CROS_EC_ZEPHYR_ADC_H */
diff --git a/zephyr/shim/include/zephyr_console_shim.h b/zephyr/shim/include/zephyr_console_shim.h
deleted file mode 100644
index b3c1f23922..0000000000
--- a/zephyr/shim/include/zephyr_console_shim.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __CROS_EC_ZEPHYR_CONSOLE_SHIM_H
-#define __CROS_EC_ZEPHYR_CONSOLE_SHIM_H
-
-#include <shell/shell.h>
-
-struct zephyr_console_command {
- /* Handler for the command. argv[0] will be the command name. */
- int (*handler)(int argc, char **argv);
-#ifdef CONFIG_SHELL_HELP
- /* Description of args */
- const char *argdesc;
- /* Short help for command */
- const char *help;
-#endif
-};
-
-#ifdef CONFIG_SHELL_HELP
-#define _HELP_ARGS(A, H) \
- .argdesc = A, \
- .help = H,
-#else
-#define _HELP_ARGS(A, H)
-#endif
-
-/**
- * zshim_run_ec_console_command() - Dispatch a CrOS EC console command
- * using Zephyr's shell
- *
- * @command: Pointer to a struct zephyr_console_command
- * @argc: The number of command line arguments.
- * @argv: The NULL-terminated list of arguments.
- *
- * Return: the return value from the handler.
- */
-int zshim_run_ec_console_command(const struct zephyr_console_command *command,
- size_t argc, char **argv);
-
-/* Internal wrappers for DECLARE_CONSOLE_COMMAND_* macros. */
-#define _ZEPHYR_SHELL_COMMAND_SHIM_2(NAME, ROUTINE_ID, ARGDESC, HELP, \
- WRAPPER_ID, ENTRY_ID) \
- static const struct zephyr_console_command ENTRY_ID = { \
- .handler = ROUTINE_ID, \
- _HELP_ARGS(ARGDESC, HELP) \
- }; \
- static int WRAPPER_ID(const struct shell *shell, size_t argc, \
- char **argv) \
- { \
- return zshim_run_ec_console_command(&ENTRY_ID, argc, argv); \
- } \
- SHELL_CMD_ARG_REGISTER(NAME, NULL, HELP, WRAPPER_ID, 0, \
- SHELL_OPT_ARG_MAX)
-
-#define _ZEPHYR_SHELL_COMMAND_SHIM(NAME, ROUTINE_ID, ARGDESC, HELP) \
- _ZEPHYR_SHELL_COMMAND_SHIM_2(NAME, ROUTINE_ID, ARGDESC, HELP, \
- UTIL_CAT(zshim_wrapper_, ROUTINE_ID), \
- UTIL_CAT(zshim_entry_, ROUTINE_ID))
-
-/* These macros mirror the macros provided by the CrOS EC. */
-#define DECLARE_CONSOLE_COMMAND(NAME, ROUTINE, ARGDESC, HELP) \
- _ZEPHYR_SHELL_COMMAND_SHIM(NAME, ROUTINE, ARGDESC, HELP)
-
-/*
- * TODO(jrosenth): implement flags and restricted commands? We just
- * discard this in the shim layer for now.
- */
-#define DECLARE_CONSOLE_COMMAND_FLAGS(NAME, ROUTINE, ARGDESC, HELP, FLAGS) \
- _ZEPHYR_SHELL_COMMAND_SHIM(NAME, ROUTINE, ARGDESC, HELP)
-#define DECLARE_SAFE_CONSOLE_COMMAND(NAME, ROUTINE, ARGDESC, HELP) \
- _ZEPHYR_SHELL_COMMAND_SHIM(NAME, ROUTINE, ARGDESC, HELP)
-
-/**
- * console_buf_notify_chars() - Notify the console host command buffer
- * of bytes on the console.
- *
- * @s: The pointer to the string.
- * @len: The size of the string.
- */
-void console_buf_notify_chars(const char *s, size_t len);
-
-#endif /* __CROS_EC_ZEPHYR_CONSOLE_SHIM_H */
diff --git a/zephyr/shim/include/zephyr_espi_shim.h b/zephyr/shim/include/zephyr_espi_shim.h
deleted file mode 100644
index a7b151cec8..0000000000
--- a/zephyr/shim/include/zephyr_espi_shim.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __CROS_EC_ZEPHYR_ESPI_SHIM_H
-#define __CROS_EC_ZEPHYR_ESPI_SHIM_H
-
-#include <stdbool.h>
-#include <stdint.h>
-
-/**
- * zephyr_shim_setup_espi() - initialize eSPI device
- *
- * Return: 0 upon success, or <0 upon failure.
- */
-int zephyr_shim_setup_espi(void);
-
-/**
- * Check if the message is an ACPI command.
- *
- * @param data The full ACPI event data.
- * @return True if the message is a command.
- */
-bool is_acpi_command(uint32_t data);
-
-/**
- * Get the value component of the ACPI message.
- *
- * @param data The full ACPI event data.
- * @return The value component of the ACPI message.
- */
-uint32_t get_acpi_value(uint32_t data);
-
-/**
- * Check if the 8042 event data contains an input-buffer-full (IBF) event.
- *
- * @param data The full 8042 event data.
- * @return True if the data contains an IBF event.
- */
-bool is_8042_ibf(uint32_t data);
-
-/**
- * Check if the 8042 event data contains an output-buffer-empty (OBE) event.
- *
- * @param data The full 8042 event data.
- * @return True if the data contains an OBE event.
- */
-bool is_8042_obe(uint32_t data);
-
-/**
- * Get the type of 8042 message.
- *
- * @param data The full 8042 event data.
- * @return The type component of the message.
- */
-uint32_t get_8042_type(uint32_t data);
-
-/**
- * Get the data from an 8042 message.
- *
- * @param data The full 8042 event data.
- * @return The data component of the message.
- */
-uint32_t get_8042_data(uint32_t data);
-
-#endif /* __CROS_EC_ZEPHYR_ESPI_SHIM_H */
diff --git a/zephyr/shim/include/zephyr_gpio_signal.h b/zephyr/shim/include/zephyr_gpio_signal.h
deleted file mode 100644
index 6c90db81f4..0000000000
--- a/zephyr/shim/include/zephyr_gpio_signal.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#if !defined(__CROS_EC_GPIO_SIGNAL_H) || defined(__CROS_EC_ZEPHYR_GPIO_SIGNAL_H)
-#error "This file must only be included from gpio_signal.h. Include gpio_signal.h directly."
-#endif
-#define __CROS_EC_ZEPHYR_GPIO_SIGNAL_H
-
-#include <devicetree.h>
-#include <toolchain.h>
-
-#define GPIO_SIGNAL(id) DT_STRING_UPPER_TOKEN(id, enum_name)
-#define GPIO_SIGNAL_WITH_COMMA(id) \
- COND_CODE_1(DT_NODE_HAS_PROP(id, enum_name), (GPIO_SIGNAL(id), ), ())
-enum gpio_signal {
- GPIO_UNIMPLEMENTED = -1,
-#if DT_NODE_EXISTS(DT_PATH(named_gpios))
- DT_FOREACH_CHILD(DT_PATH(named_gpios), GPIO_SIGNAL_WITH_COMMA)
-#endif
- GPIO_COUNT,
- GPIO_LIMIT = 0x0FFF,
-};
-#undef GPIO_SIGNAL_WITH_COMMA
-BUILD_ASSERT(GPIO_COUNT < GPIO_LIMIT);
-
-/** @brief Converts a node identifier under named gpios to enum
- *
- * Converts the specified node identifier name, which should be nested under
- * the named_gpios node, into the correct enum gpio_signal that can be used
- * with platform/ec gpio API
- */
-#define NAMED_GPIO(name) GPIO_SIGNAL(DT_PATH(named_gpios, name))
-
-/** @brief Obtain a named gpio enum from a label and property
- *
- * Obtains a valid enum gpio_signal that can be used with platform/ec gpio API
- * from the property of a labeled node. The property has to point to a
- * named_gpios node.
- */
-#define NAMED_GPIO_NODELABEL(label, prop) \
- GPIO_SIGNAL(DT_PHANDLE(DT_NODELABEL(label), prop))
-
-/*
- * While we don't support IO expanders at the moment, multiple
- * platform/ec headers (e.g., espi.h) require some of these constants
- * to be defined. Define them as a compatibility measure.
- */
-enum ioex_signal {
- IOEX_SIGNAL_START = GPIO_LIMIT + 1,
- IOEX_SIGNAL_END = IOEX_SIGNAL_START,
- IOEX_LIMIT = 0x1FFF,
-};
-BUILD_ASSERT(IOEX_SIGNAL_END < IOEX_LIMIT);
-
-#define IOEX_COUNT (IOEX_SIGNAL_END - IOEX_SIGNAL_START)
diff --git a/zephyr/shim/include/zephyr_hooks_shim.h b/zephyr/shim/include/zephyr_hooks_shim.h
deleted file mode 100644
index 96dcf9d8f4..0000000000
--- a/zephyr/shim/include/zephyr_hooks_shim.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#if !defined(__CROS_EC_HOOKS_H) || defined(__CROS_EC_ZEPHYR_HOOKS_SHIM_H)
-#error "This file must only be included from hooks.h. Include hooks.h directly."
-#endif
-#define __CROS_EC_ZEPHYR_HOOKS_SHIM_H
-
-#include <init.h>
-#include <kernel.h>
-#include <zephyr.h>
-
-#include "common.h"
-#include "cros_version.h"
-
-/**
- * The internal data structure stored for a deferred function.
- */
-struct deferred_data {
- struct k_work_delayable *work;
-};
-
-/**
- * See include/hooks.h for documentation.
- */
-int hook_call_deferred(const struct deferred_data *data, int us);
-
-#define DECLARE_DEFERRED(routine) \
- K_WORK_DELAYABLE_DEFINE(routine##_work_data, \
- (void (*)(struct k_work *))routine); \
- __maybe_unused const struct deferred_data routine##_data = { \
- .work = &routine##_work_data, \
- }
-
-/**
- * Internal linked-list structure used to store hook lists.
- */
-struct zephyr_shim_hook_list {
- void (*routine)(void);
- uint16_t priority; /* HOOK_PRIO_LAST = 9999 */
- enum hook_type type;
- struct zephyr_shim_hook_list *next;
-};
-
-/**
- * See include/hooks.h for documentation.
- */
-#define DECLARE_HOOK(_hooktype, _routine, _priority) \
- STRUCT_SECTION_ITERABLE(zephyr_shim_hook_list, \
- _cros_hook_##_hooktype##_##_routine) = { \
- .type = _hooktype, \
- .routine = _routine, \
- .priority = _priority, \
- }
diff --git a/zephyr/shim/include/zephyr_host_command.h b/zephyr/shim/include/zephyr_host_command.h
deleted file mode 100644
index ae8e1f9ee3..0000000000
--- a/zephyr/shim/include/zephyr_host_command.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#if !defined(__CROS_EC_HOST_COMMAND_H) || \
- defined(__CROS_EC_ZEPHYR_HOST_COMMAND_H)
-#error "This file must only be included from host_command.h. " \
- "Include host_command.h directly"
-#endif
-#define __CROS_EC_ZEPHYR_HOST_COMMAND_H
-
-#include <init.h>
-
-#ifdef CONFIG_PLATFORM_EC_HOSTCMD
-
-/**
- * See include/host_command.h for documentation.
- */
-#define DECLARE_HOST_COMMAND(_command, _routine, _version_mask) \
- STRUCT_SECTION_ITERABLE(host_command, _cros_hcmd_##_command) = { \
- .command = _command, \
- .handler = _routine, \
- .version_mask = _version_mask, \
- }
-#else /* !CONFIG_PLATFORM_EC_HOSTCMD */
-#ifdef __clang__
-#define DECLARE_HOST_COMMAND(command, routine, version_mask)
-#else
-#define DECLARE_HOST_COMMAND(command, routine, version_mask) \
- enum ec_status (routine)(struct host_cmd_handler_args *args) \
- __attribute__((unused))
-#endif /* __clang__ */
-#endif /* CONFIG_PLATFORM_EC_HOSTCMD */
diff --git a/zephyr/shim/include/zephyr_mkbp_event.h b/zephyr/shim/include/zephyr_mkbp_event.h
deleted file mode 100644
index 159aebc8e1..0000000000
--- a/zephyr/shim/include/zephyr_mkbp_event.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#if !defined(__CROS_EC_MKBP_EVENT_H) || \
- defined(__CROS_EC_ZEPHYR_MKBP_EVENT_H)
-#error "This file must only be included from mkbp_event.h. " \
- "Include mkbp_event.h directly"
-#endif
-#define __CROS_EC_ZEPHYR_MKBP_EVENT_H
-
-const struct mkbp_event_source *zephyr_find_mkbp_event_source(
- uint8_t event_type);
-
-/**
- * See include/mkbp_event.h for documentation.
- */
-#define DECLARE_EVENT_SOURCE(_type, _func) \
- STRUCT_SECTION_ITERABLE(mkbp_event_source, _cros_evtsrc_##_func) = { \
- .event_type = _type, \
- .get_data = _func, \
- }
diff --git a/zephyr/shim/src/CMakeLists.txt b/zephyr/shim/src/CMakeLists.txt
deleted file mode 100644
index e30671c6d6..0000000000
--- a/zephyr/shim/src/CMakeLists.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-zephyr_library_sources(console.c)
-zephyr_library_sources(crc.c)
-zephyr_library_sources(gpio.c)
-zephyr_library_sources(gpio_id.c)
-
-if (DEFINED CONFIG_ARCH_POSIX)
- zephyr_library_sources(ztest_system.c)
-else()
- zephyr_library_sources(system.c)
- zephyr_library_sources("${PLATFORM_EC}/common/system.c")
-endif()
-zephyr_library_sources_ifdef(no_libgcc libgcc_${ARCH}.S)
-
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_ADC adc.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE
- battery.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_EEPROM cbi.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_CBI_GPIO cbi.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_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_HOOKS hooks.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD host_command.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE
- console_buffer.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD keyboard_raw.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD keyscan.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_PLATFORM_EC_PWM pwm.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON 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)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TEMP_SENSOR temp_sensors.c
- thermal.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_TIMER hwtimer.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C i2c.c)
-zephyr_library_sources_ifdef(CONFIG_SHIMMED_TASKS tasks.c)
-zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_WATCHDOG watchdog.c)
diff --git a/zephyr/shim/src/adc.c b/zephyr/shim/src/adc.c
deleted file mode 100644
index 4f66774466..0000000000
--- a/zephyr/shim/src/adc.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <drivers/adc.h>
-#include <logging/log.h>
-#include "adc.h"
-#include "zephyr_adc.h"
-
-LOG_MODULE_REGISTER(shim_adc, LOG_LEVEL_ERR);
-
-#define ADC_NODE DT_NODELABEL(adc0)
-const struct device *adc_dev;
-
-#define HAS_NAMED_ADC_CHANNELS DT_NODE_EXISTS(DT_INST(0, named_adc_channels))
-
-#if HAS_NAMED_ADC_CHANNELS
-#define ADC_CHANNEL_COMMA(node_id) \
- [ZSHIM_ADC_ID(node_id)] = { \
- .name = DT_LABEL(node_id), \
- .input_ch = DT_PROP(node_id, channel), \
- .factor_mul = DT_PROP(node_id, mul), \
- .factor_div = DT_PROP(node_id, div), \
- .channel_cfg = { \
- .channel_id = DT_PROP(node_id, channel), \
- .gain = DT_STRING_TOKEN(node_id, gain), \
- .reference = DT_STRING_TOKEN(node_id, reference), \
- .acquisition_time = \
- DT_PROP(node_id, acquisition_time), \
- .differential = DT_PROP(node_id, differential), \
- }, \
- },
-#ifdef CONFIG_ADC_CHANNELS_RUNTIME_CONFIG
-struct adc_t adc_channels[] = { DT_FOREACH_CHILD(
- DT_INST(0, named_adc_channels), ADC_CHANNEL_COMMA) };
-#else
-const struct adc_t adc_channels[] = { DT_FOREACH_CHILD(
- DT_INST(0, named_adc_channels), ADC_CHANNEL_COMMA) };
-#endif
-#endif /* named_adc_channels */
-
-static int init_device_bindings(const struct device *device)
-{
- ARG_UNUSED(device);
- adc_dev = DEVICE_DT_GET(ADC_NODE);
-
- if (!device_is_ready(adc_dev)) {
- LOG_ERR("Error: device %s is not ready", adc_dev->name);
- return -1;
- }
-
-#if HAS_NAMED_ADC_CHANNELS
- for (int i = 0; i < ARRAY_SIZE(adc_channels); i++)
- adc_channel_setup(adc_dev, &adc_channels[i].channel_cfg);
-#endif
-
- return 0;
-}
-SYS_INIT(init_device_bindings, POST_KERNEL, 51);
-
-int adc_read_channel(enum adc_channel ch)
-{
- int ret = 0, rv;
- struct adc_sequence seq = {
- .options = NULL,
- .channels = BIT(adc_channels[ch].input_ch),
- .buffer = &ret,
- .buffer_size = sizeof(ret),
- .resolution = CONFIG_PLATFORM_EC_ADC_RESOLUTION,
- .oversampling = CONFIG_PLATFORM_EC_ADC_OVERSAMPLING,
- .calibrate = false,
- };
-
- rv = adc_read(adc_dev, &seq);
- if (rv)
- return rv;
-
- adc_raw_to_millivolts(adc_ref_internal(adc_dev), ADC_GAIN_1,
- CONFIG_PLATFORM_EC_ADC_RESOLUTION, &ret);
- ret = (ret * adc_channels[ch].factor_mul) / adc_channels[ch].factor_div;
- return ret;
-}
diff --git a/zephyr/shim/src/battery.c b/zephyr/shim/src/battery.c
deleted file mode 100644
index 6c4f211eda..0000000000
--- a/zephyr/shim/src/battery.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include<devicetree.h>
-#include"battery_fuel_gauge.h"
-
-#if DT_NODE_EXISTS(DT_PATH(batteries))
-
-#define NODE_FUEL_GAUGE(node) \
-{ \
- .manuf_name = DT_PROP(node, manuf_name), \
- .device_name = DT_PROP(node, device_name), \
- .ship_mode = { \
- .wb_support = DT_PROP_OR(node, ship_mode_wb_support, 0), \
- .reg_addr = DT_PROP(node, ship_mode_reg_addr), \
- .reg_data = DT_PROP(node, ship_mode_reg_data), \
- }, \
- .sleep_mode = { \
- .sleep_supported = DT_PROP_OR(node, sleep_mode_supported, 0), \
- .reg_addr = DT_PROP_OR(node, sleep_mode_reg_addr, 0), \
- .reg_data = DT_PROP_OR(node, sleep_mode_reg_data, 0), \
- }, \
- .fet = { \
- .mfgacc_support = DT_PROP_OR(node, fet_mgfacc_support, 0), \
- .reg_addr = DT_PROP_OR(node, fet_reg_addr, 0), \
- .reg_mask = DT_PROP(node, fet_reg_mask), \
- .disconnect_val = DT_PROP(node, fet_disconnect_val), \
- .cfet_mask = DT_PROP_OR(node, fet_cfet_mask, 0), \
- .cfet_off_val = DT_PROP_OR(node, fet_cfet_off_val, 0), \
- }, \
- COND_CODE_1(UTIL_AND(IS_ENABLED(CONFIG_BATTERY_MEASURE_IMBALANCE), \
- DT_NODE_HAS_PROP(node, imbalance_mv)), \
- (.imbalance_mv = DT_STRING_TOKEN(node, imbalance_mv),), ()) \
-},
-
-#define NODE_BATT_INFO(node) \
-{ \
- .voltage_max = DT_PROP(node, voltage_max), \
- .voltage_normal = DT_PROP(node, voltage_normal), \
- .voltage_min = DT_PROP(node, voltage_min), \
- .precharge_voltage = DT_PROP_OR(node, precharge_voltage, 0), \
- .precharge_current = DT_PROP_OR(node, precharge_current, 0), \
- .start_charging_min_c = DT_PROP(node, start_charging_min_c), \
- .start_charging_max_c = DT_PROP(node, start_charging_max_c), \
- .charging_min_c = DT_PROP(node, charging_min_c), \
- .charging_max_c = DT_PROP(node, charging_max_c), \
- .discharging_min_c = DT_PROP(node, discharging_min_c), \
- .discharging_max_c = DT_PROP(node, discharging_max_c), \
-},
-
-#define NODE_BATT_PARAMS(node) \
-{ \
- .fuel_gauge = NODE_FUEL_GAUGE(node) \
- .batt_info = NODE_BATT_INFO(node) \
-},
-
-const struct board_batt_params board_battery_info[] = {
- DT_FOREACH_CHILD(DT_PATH(batteries), NODE_BATT_PARAMS)
-};
-
-#if DT_NODE_EXISTS(DT_NODELABEL(default_battery))
-#define BAT_ENUM(node) DT_CAT(BATTERY_, node)
-const enum battery_type DEFAULT_BATTERY_TYPE =
- BATTERY_TYPE(DT_NODELABEL(default_battery));
-#endif
-
-#endif /* DT_NODE_EXISTS(DT_PATH(batteries)) */
diff --git a/zephyr/shim/src/cbi.c b/zephyr/shim/src/cbi.c
deleted file mode 100644
index e9d85b6088..0000000000
--- a/zephyr/shim/src/cbi.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <drivers/cros_cbi.h>
-#include <logging/log.h>
-#include "hooks.h"
-
-LOG_MODULE_REGISTER(shim_cbi, LOG_LEVEL_ERR);
-
-static void cbi_dev_init(void)
-{
- const struct device *dev = device_get_binding(CROS_CBI_LABEL);
-
- if (!dev)
- LOG_ERR("Fail to find %s", CROS_CBI_LABEL);
-
- cros_cbi_init(dev);
-}
-
-DECLARE_HOOK(HOOK_INIT, cbi_dev_init, HOOK_PRIO_FIRST);
diff --git a/zephyr/shim/src/console.c b/zephyr/shim/src/console.c
deleted file mode 100644
index 3fc3896ec2..0000000000
--- a/zephyr/shim/src/console.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <device.h>
-#include <drivers/uart.h>
-#include <shell/shell.h>
-#include <shell/shell_uart.h>
-#include <stdbool.h>
-#include <string.h>
-#include <sys/printk.h>
-#include <sys/ring_buffer.h>
-#include <zephyr.h>
-#include <logging/log.h>
-
-#include "console.h"
-#include "printf.h"
-#include "uart.h"
-#include "usb_console.h"
-#include "zephyr_console_shim.h"
-
-LOG_MODULE_REGISTER(shim_console, LOG_LEVEL_ERR);
-
-static const struct device *uart_shell_dev =
- DEVICE_DT_GET(DT_CHOSEN(zephyr_shell_uart));
-static const struct shell *shell_zephyr;
-static struct k_poll_signal shell_uninit_signal;
-static struct k_poll_signal shell_init_signal;
-RING_BUF_DECLARE(rx_buffer, CONFIG_UART_RX_BUF_SIZE);
-
-static void uart_rx_handle(const struct device *dev)
-{
- static uint8_t scratch;
- static uint8_t *data;
- static uint32_t len, rd_len;
-
- do {
- /* Get some bytes on the ring buffer */
- len = ring_buf_put_claim(&rx_buffer, &data, rx_buffer.size);
- if (len > 0) {
- /* Read from the FIFO up to `len` bytes */
- rd_len = uart_fifo_read(dev, data, len);
-
- /* Put `rd_len` bytes on the ring buffer */
- ring_buf_put_finish(&rx_buffer, rd_len);
- } else {
- /*
- * There's no room on the ring buffer, throw away 1
- * byte.
- */
- rd_len = uart_fifo_read(dev, &scratch, 1);
- }
- } while (rd_len != 0 && rd_len == len);
-}
-
-static void uart_callback(const struct device *dev, void *user_data)
-{
- uart_irq_update(dev);
-
- if (uart_irq_rx_ready(dev))
- uart_rx_handle(dev);
-}
-
-static void shell_uninit_callback(const struct shell *shell, int res)
-{
- if (!res) {
- /* Set the new callback */
- uart_irq_callback_user_data_set(uart_shell_dev, uart_callback,
- NULL);
-
- /*
- * Disable TX interrupts. We don't actually use TX but for some
- * reason none of this works without this line.
- */
- uart_irq_tx_disable(uart_shell_dev);
-
- /* Enable RX interrupts */
- uart_irq_rx_enable(uart_shell_dev);
- }
-
- /* Notify the uninit signal that we finished */
- k_poll_signal_raise(&shell_uninit_signal, res);
-}
-
-int uart_shell_stop(void)
-{
- struct k_poll_event event = K_POLL_EVENT_INITIALIZER(
- K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY,
- &shell_uninit_signal);
-
- /* Clear all pending input */
- uart_clear_input();
-
- /* Disable RX and TX interrupts */
- uart_irq_rx_disable(uart_shell_dev);
- uart_irq_tx_disable(uart_shell_dev);
-
- /* Initialize the uninit signal */
- k_poll_signal_init(&shell_uninit_signal);
-
- /* Stop the shell */
- shell_uninit(shell_backend_uart_get_ptr(), shell_uninit_callback);
-
- /* Wait for the shell to be turned off, the signal will wake us */
- k_poll(&event, 1, K_FOREVER);
-
- /* Event was signaled, return the result */
- return event.signal->result;
-}
-
-static void shell_init_from_work(struct k_work *work)
-{
- bool log_backend = CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL > 0;
- uint32_t level;
- ARG_UNUSED(work);
-
- if (CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL > LOG_LEVEL_DBG) {
- level = CONFIG_LOG_MAX_LEVEL;
- } else {
- level = CONFIG_SHELL_BACKEND_SERIAL_LOG_LEVEL;
- }
-
- /* Initialize the shell and re-enable both RX and TX */
- shell_init(shell_backend_uart_get_ptr(), uart_shell_dev, false,
- log_backend, level);
- uart_irq_rx_enable(uart_shell_dev);
- uart_irq_tx_enable(uart_shell_dev);
-
- /* Notify the init signal that initialization is complete */
- k_poll_signal_raise(&shell_init_signal, 0);
-}
-
-void uart_shell_start(void)
-{
- static struct k_work shell_init_work;
- struct k_poll_event event = K_POLL_EVENT_INITIALIZER(
- K_POLL_TYPE_SIGNAL, K_POLL_MODE_NOTIFY_ONLY,
- &shell_init_signal);
-
- /* Disable RX and TX interrupts */
- uart_irq_rx_disable(uart_shell_dev);
- uart_irq_tx_disable(uart_shell_dev);
-
- /* Initialize k_work to call shell init (this makes it thread safe) */
- k_work_init(&shell_init_work, shell_init_from_work);
-
- /* Initialize the init signal to make sure we're read to listen */
- k_poll_signal_init(&shell_init_signal);
-
- /* Submit the work to be run by the kernel */
- k_work_submit(&shell_init_work);
-
- /* Wait for initialization to be run, the signal will wake us */
- k_poll(&event, 1, K_FOREVER);
-}
-
-int zshim_run_ec_console_command(const struct zephyr_console_command *command,
- size_t argc, char **argv)
-{
- /*
- * The Zephyr shell only displays the help string and not
- * the argument descriptor when passing "-h" or "--help". Mimic the
- * cros-ec behavior by displaying both the user types "<command> help",
- */
-#ifdef CONFIG_SHELL_HELP
- for (int i = 1; i < argc; i++) {
- if (!command->help && !command->argdesc)
- break;
- if (!strcmp(argv[i], "help")) {
- if (command->help)
- printk("%s\n", command->help);
- if (command->argdesc)
- printk("Usage: %s\n", command->argdesc);
- return 0;
- }
- }
-#endif
-
- return command->handler(argc, argv);
-}
-
-#if defined(CONFIG_CONSOLE_CHANNEL) && DT_NODE_EXISTS(DT_PATH(ec_console))
-#define EC_CONSOLE DT_PATH(ec_console)
-
-static const char * const disabled_channels[] = DT_PROP(EC_CONSOLE, disabled);
-static const size_t disabled_channel_count = DT_PROP_LEN(EC_CONSOLE, disabled);
-static int init_ec_console(const struct device *unused)
-{
- for (size_t i = 0; i < disabled_channel_count; i++)
- console_channel_disable(disabled_channels[i]);
-
- return 0;
-} SYS_INIT(init_ec_console, PRE_KERNEL_1, 50);
-#endif /* CONFIG_CONSOLE_CHANNEL && DT_NODE_EXISTS(DT_PATH(ec_console)) */
-
-static int init_ec_shell(const struct device *unused)
-{
- shell_zephyr = shell_backend_uart_get_ptr();
- return 0;
-} SYS_INIT(init_ec_shell, PRE_KERNEL_1, 50);
-
-void uart_tx_start(void)
-{
-}
-
-int uart_tx_ready(void)
-{
- return 1;
-}
-
-int uart_tx_char_raw(void *context, int c)
-{
- uart_write_char(c);
- return 0;
-}
-
-void uart_write_char(char c)
-{
- printk("%c", c);
-
- if (IS_ENABLED(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE))
- console_buf_notify_chars(&c, 1);
-}
-
-void uart_flush_output(void)
-{
- shell_process(shell_zephyr);
- uart_tx_flush();
-}
-
-void uart_tx_flush(void)
-{
- while (!uart_irq_tx_complete(uart_shell_dev))
- ;
-}
-
-int uart_getc(void)
-{
- uint8_t c;
-
- if (ring_buf_get(&rx_buffer, &c, 1)) {
- return c;
- }
- return -1;
-}
-
-void uart_clear_input(void)
-{
- /* Clear any remaining shell processing. */
- shell_process(shell_zephyr);
- ring_buf_reset(&rx_buffer);
-}
-
-static void handle_sprintf_rv(int rv, size_t *len)
-{
- if (rv < 0) {
- LOG_ERR("Print buffer is too small");
- *len = CONFIG_SHELL_PRINTF_BUFF_SIZE;
- } else {
- *len += rv;
- }
-}
-
-static void zephyr_print(const char *buff, size_t size)
-{
- /*
- * shell_* functions can not be used in ISRs so use printk instead.
- * Also, console_buf_notify_chars uses a mutex, which may not be
- * locked in ISRs.
- */
- if (k_is_in_isr() || shell_zephyr->ctx->state != SHELL_STATE_ACTIVE) {
- printk("%s", buff);
- } else {
- /*
- * On some platforms, shell_* functions are not as fast
- * as printk and they need the added speed to avoid
- * timeouts.
- */
- if (IS_ENABLED(CONFIG_PLATFORM_EC_CONSOLE_USES_PRINTK))
- printk("%s", buff);
- else
- shell_fprintf(shell_zephyr, SHELL_NORMAL, "%s", buff);
- if (IS_ENABLED(CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE))
- console_buf_notify_chars(buff, size);
- }
-}
-
-#if defined(CONFIG_USB_CONSOLE) || defined(CONFIG_USB_CONSOLE_STREAM)
-BUILD_ASSERT(0, "USB console is not supported with Zephyr");
-#endif /* defined(CONFIG_USB_CONSOLE) || defined(CONFIG_USB_CONSOLE_STREAM) */
-
-int cputs(enum console_channel channel, const char *outstr)
-{
- /* Filter out inactive channels */
- if (console_channel_is_disabled(channel))
- return EC_SUCCESS;
-
- zephyr_print(outstr, strlen(outstr));
-
- return 0;
-}
-
-int cprintf(enum console_channel channel, const char *format, ...)
-{
- int rv;
- va_list args;
- size_t len = 0;
- char buff[CONFIG_SHELL_PRINTF_BUFF_SIZE];
-
- /* Filter out inactive channels */
- if (console_channel_is_disabled(channel))
- return EC_SUCCESS;
-
- va_start(args, format);
- rv = crec_vsnprintf(buff, CONFIG_SHELL_PRINTF_BUFF_SIZE, format, args);
- va_end(args);
- handle_sprintf_rv(rv, &len);
-
- zephyr_print(buff, len);
-
- return rv > 0 ? EC_SUCCESS : rv;
-}
-
-int cprints(enum console_channel channel, const char *format, ...)
-{
- int rv;
- va_list args;
- char buff[CONFIG_SHELL_PRINTF_BUFF_SIZE];
- size_t len = 0;
-
- /* Filter out inactive channels */
- if (console_channel_is_disabled(channel))
- return EC_SUCCESS;
-
- rv = crec_snprintf(buff, CONFIG_SHELL_PRINTF_BUFF_SIZE, "[%pT ",
- PRINTF_TIMESTAMP_NOW);
- handle_sprintf_rv(rv, &len);
-
- va_start(args, format);
- rv = crec_vsnprintf(buff + len, CONFIG_SHELL_PRINTF_BUFF_SIZE - len,
- format, args);
- va_end(args);
- handle_sprintf_rv(rv, &len);
-
- rv = crec_snprintf(buff + len, CONFIG_SHELL_PRINTF_BUFF_SIZE - len,
- "]\n");
- handle_sprintf_rv(rv, &len);
-
- zephyr_print(buff, len);
-
- return rv > 0 ? EC_SUCCESS : rv;
-}
diff --git a/zephyr/shim/src/console_buffer.c b/zephyr/shim/src/console_buffer.c
deleted file mode 100644
index 427ae47768..0000000000
--- a/zephyr/shim/src/console_buffer.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <kernel.h>
-#include <zephyr.h>
-
-#include "common.h"
-#include "console.h"
-#include "ec_commands.h"
-
-static char console_buf[CONFIG_PLATFORM_EC_HOSTCMD_CONSOLE_BUF_SIZE];
-static uint32_t previous_snapshot_idx;
-static uint32_t current_snapshot_idx;
-static uint32_t tail_idx;
-
-static inline uint32_t next_idx(uint32_t cur_idx)
-{
- return (cur_idx + 1) % ARRAY_SIZE(console_buf);
-}
-
-K_MUTEX_DEFINE(console_write_lock);
-
-void console_buf_notify_chars(const char *s, size_t len)
-{
- /*
- * This is just notifying of console characters for debugging
- * output, so if we are unable to lock the mutex immediately,
- * then just drop the string.
- */
- if (k_mutex_lock(&console_write_lock, K_NO_WAIT))
- return;
- /* We got the mutex. */
- while (len--) {
- /* Don't copy null byte into buffer */
- if (!(*s))
- continue;
-
- uint32_t new_tail = next_idx(tail_idx);
-
- /* Check if we are starting to overwrite our snapshot
- * heads
- */
- if (new_tail == previous_snapshot_idx)
- previous_snapshot_idx =
- next_idx(previous_snapshot_idx);
- if (new_tail == current_snapshot_idx)
- current_snapshot_idx =
- next_idx(current_snapshot_idx);
-
- console_buf[new_tail] = *s++;
- tail_idx = new_tail;
- }
- k_mutex_unlock(&console_write_lock);
-}
-
-enum ec_status uart_console_read_buffer_init(void)
-{
- if (k_mutex_lock(&console_write_lock, K_MSEC(100)))
- /* Failed to acquire console buffer mutex */
- return EC_RES_TIMEOUT;
-
- previous_snapshot_idx = current_snapshot_idx;
- current_snapshot_idx = tail_idx;
-
- k_mutex_unlock(&console_write_lock);
-
- return EC_RES_SUCCESS;
-}
-
-int uart_console_read_buffer(uint8_t type, char *dest, uint16_t dest_size,
- uint16_t *write_count_out)
-{
- uint32_t *head;
- uint16_t write_count = 0;
-
- switch (type) {
- case CONSOLE_READ_NEXT:
- /* Start from beginning of latest snapshot */
- head = &current_snapshot_idx;
- break;
- case CONSOLE_READ_RECENT:
- /* Start from end of previous snapshot */
- head = &previous_snapshot_idx;
- break;
- default:
- return EC_RES_INVALID_PARAM;
- }
-
- /* We need to make sure we have room for at least the null byte */
- if (dest_size == 0)
- return EC_RES_INVALID_PARAM;
-
- if (k_mutex_lock(&console_write_lock, K_MSEC(100)))
- /* Failed to acquire console buffer mutex */
- return EC_RES_TIMEOUT;
-
- if (*head == tail_idx) {
- /* No new data, return empty response */
- k_mutex_unlock(&console_write_lock);
- return EC_RES_SUCCESS;
- }
-
- do {
- if (write_count >= dest_size - 1)
- /* Buffer is full, minus the space for a null byte */
- break;
-
- dest[write_count] = console_buf[*head];
- write_count++;
- *head = next_idx(*head);
- } while (*head != tail_idx);
-
- dest[write_count] = '\0';
- write_count++;
-
- *write_count_out = write_count;
- k_mutex_unlock(&console_write_lock);
-
- return EC_RES_SUCCESS;
-}
-
-/* ECOS uart buffer, putc is blocking instead. */
-int uart_buffer_full(void)
-{
- return false;
-}
diff --git a/zephyr/shim/src/crc.c b/zephyr/shim/src/crc.c
deleted file mode 100644
index 5c726619ee..0000000000
--- a/zephyr/shim/src/crc.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <sys/crc.h>
-
-#include "crc8.h"
-
-/* Polynomial representation for x^8 + x^2 + x + 1 is 0x07 */
-#define SMBUS_POLYNOMIAL 0x07
-
-inline uint8_t cros_crc8(const uint8_t *data, int len)
-{
- return crc8(data, len, SMBUS_POLYNOMIAL, 0, false);
-}
-
-uint8_t cros_crc8_arg(const uint8_t *data, int len, uint8_t previous_crc)
-{
- return crc8(data, len, SMBUS_POLYNOMIAL, previous_crc, false);
-}
diff --git a/zephyr/shim/src/espi.c b/zephyr/shim/src/espi.c
deleted file mode 100644
index c064bd6157..0000000000
--- a/zephyr/shim/src/espi.c
+++ /dev/null
@@ -1,563 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <atomic.h>
-#include <device.h>
-#include <drivers/espi.h>
-#include <logging/log.h>
-#include <kernel.h>
-#include <stdint.h>
-#include <zephyr.h>
-
-#include "acpi.h"
-#include "chipset.h"
-#include "common.h"
-#include "espi.h"
-#include "gpio.h"
-#include "hooks.h"
-#include "i8042_protocol.h"
-#include "keyboard_protocol.h"
-#include "lpc.h"
-#include "port80.h"
-#include "power.h"
-#include "task.h"
-#include "timer.h"
-#include "zephyr_espi_shim.h"
-
-#define VWIRE_PULSE_TRIGGER_TIME 65
-
-LOG_MODULE_REGISTER(espi_shim, CONFIG_ESPI_LOG_LEVEL);
-
-/* host command packet handler structure */
-static struct host_packet lpc_packet;
-/*
- * For the eSPI host command, request & response use the same share memory.
- * This is for input request temp buffer.
- */
-static uint8_t params_copy[EC_LPC_HOST_PACKET_SIZE] __aligned(4);
-static bool init_done;
-
-/*
- * A mapping of platform/ec signals to Zephyr virtual wires.
- *
- * This should be a macro which takes a parameter M, and does a
- * functional application of M to 2-tuples of (platform/ec signal,
- * zephyr vwire).
- */
-#define VW_SIGNAL_TRANSLATION_LIST(M) \
- M(VW_SLP_S3_L, ESPI_VWIRE_SIGNAL_SLP_S3) \
- M(VW_SLP_S4_L, ESPI_VWIRE_SIGNAL_SLP_S4) \
- M(VW_SLP_S5_L, ESPI_VWIRE_SIGNAL_SLP_S5) \
- M(VW_SUS_STAT_L, ESPI_VWIRE_SIGNAL_SUS_STAT) \
- M(VW_PLTRST_L, ESPI_VWIRE_SIGNAL_PLTRST) \
- M(VW_OOB_RST_WARN, ESPI_VWIRE_SIGNAL_OOB_RST_WARN) \
- M(VW_OOB_RST_ACK, ESPI_VWIRE_SIGNAL_OOB_RST_ACK) \
- M(VW_WAKE_L, ESPI_VWIRE_SIGNAL_WAKE) \
- M(VW_PME_L, ESPI_VWIRE_SIGNAL_PME) \
- M(VW_ERROR_FATAL, ESPI_VWIRE_SIGNAL_ERR_FATAL) \
- M(VW_ERROR_NON_FATAL, ESPI_VWIRE_SIGNAL_ERR_NON_FATAL) \
- M(VW_PERIPHERAL_BTLD_STATUS_DONE, ESPI_VWIRE_SIGNAL_SLV_BOOT_DONE) \
- M(VW_SCI_L, ESPI_VWIRE_SIGNAL_SCI) \
- M(VW_SMI_L, ESPI_VWIRE_SIGNAL_SMI) \
- M(VW_HOST_RST_ACK, ESPI_VWIRE_SIGNAL_HOST_RST_ACK) \
- M(VW_HOST_RST_WARN, ESPI_VWIRE_SIGNAL_HOST_RST_WARN) \
- M(VW_SUS_ACK, ESPI_VWIRE_SIGNAL_SUS_ACK) \
- M(VW_SUS_WARN_L, ESPI_VWIRE_SIGNAL_SUS_WARN) \
- M(VW_SUS_PWRDN_ACK_L, ESPI_VWIRE_SIGNAL_SUS_PWRDN_ACK) \
- M(VW_SLP_A_L, ESPI_VWIRE_SIGNAL_SLP_A) \
- M(VW_SLP_LAN, ESPI_VWIRE_SIGNAL_SLP_LAN) \
- M(VW_SLP_WLAN, ESPI_VWIRE_SIGNAL_SLP_WLAN)
-
-/*
- * These two macros are intended to be used as as the M parameter to
- * the list above, generating case statements returning the
- * translation for the first parameter to the second, and the second
- * to the first, respectively.
- */
-#define CASE_CROS_TO_ZEPHYR(A, B) \
- case A: \
- return B;
-#define CASE_ZEPHYR_TO_CROS(A, B) CASE_CROS_TO_ZEPHYR(B, A)
-
-/* Translate a platform/ec signal to a Zephyr signal */
-static enum espi_vwire_signal signal_to_zephyr_vwire(enum espi_vw_signal signal)
-{
- switch (signal) {
- VW_SIGNAL_TRANSLATION_LIST(CASE_CROS_TO_ZEPHYR);
- default:
- LOG_ERR("Invalid virtual wire signal (%d)", signal);
- return -1;
- }
-}
-
-/* Translate a Zephyr vwire to a platform/ec signal */
-static enum espi_vw_signal zephyr_vwire_to_signal(enum espi_vwire_signal vwire)
-{
- switch (vwire) {
- VW_SIGNAL_TRANSLATION_LIST(CASE_ZEPHYR_TO_CROS);
- default:
- LOG_ERR("Invalid zephyr vwire (%d)", vwire);
- return -1;
- }
-}
-
-/*
- * Bit field for each signal which can have an interrupt enabled.
- * Note the interrupt is always enabled, it just depends whether we
- * route it to the power_signal_interrupt handler or not.
- */
-static atomic_t signal_interrupt_enabled;
-
-/* To be used with VW_SIGNAL_TRASLATION_LIST */
-#define CASE_CROS_TO_BIT(A, _) CASE_CROS_TO_ZEPHYR(A, BIT(A - VW_SIGNAL_START))
-
-/* Convert from an EC signal to the corresponding interrupt enabled bit. */
-static uint32_t signal_to_interrupt_bit(enum espi_vw_signal signal)
-{
- switch (signal) {
- VW_SIGNAL_TRANSLATION_LIST(CASE_CROS_TO_BIT);
- default:
- return 0;
- }
-}
-
-/* Callback for vwire received */
-static void espi_vwire_handler(const struct device *dev,
- struct espi_callback *cb,
- struct espi_event event)
-{
- int ec_signal = zephyr_vwire_to_signal(event.evt_details);
-
- if (IS_ENABLED(CONFIG_PLATFORM_EC_POWERSEQ) &&
- (signal_interrupt_enabled & signal_to_interrupt_bit(ec_signal))) {
- power_signal_interrupt(ec_signal);
- }
-}
-
-#ifdef CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK
-static void espi_chipset_reset(void)
-{
- hook_notify(HOOK_CHIPSET_RESET);
-}
-DECLARE_DEFERRED(espi_chipset_reset);
-
-/* Callback for reset */
-static void espi_reset_handler(const struct device *dev,
- struct espi_callback *cb,
- struct espi_event event)
-{
- hook_call_deferred(&espi_chipset_reset_data, MSEC);
-
-}
-#endif /* CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK */
-
-#define ESPI_NODE DT_NODELABEL(espi0)
-static const struct device *espi_dev;
-
-
-int espi_vw_set_wire(enum espi_vw_signal signal, uint8_t level)
-{
- int ret = espi_send_vwire(espi_dev, signal_to_zephyr_vwire(signal),
- level);
-
- if (ret != 0)
- LOG_ERR("Encountered error sending virtual wire signal");
-
- return ret;
-}
-
-int espi_vw_get_wire(enum espi_vw_signal signal)
-{
- uint8_t level;
-
- if (espi_receive_vwire(espi_dev, signal_to_zephyr_vwire(signal),
- &level) < 0) {
- LOG_ERR("Encountered error receiving virtual wire signal");
- return 0;
- }
-
- return level;
-}
-
-int espi_vw_enable_wire_int(enum espi_vw_signal signal)
-{
- atomic_or(&signal_interrupt_enabled, signal_to_interrupt_bit(signal));
- return 0;
-}
-
-int espi_vw_disable_wire_int(enum espi_vw_signal signal)
-{
- atomic_and(&signal_interrupt_enabled, ~signal_to_interrupt_bit(signal));
- return 0;
-}
-
-uint8_t *lpc_get_memmap_range(void)
-{
- uint32_t lpc_memmap = 0;
- int result = espi_read_lpc_request(espi_dev, EACPI_GET_SHARED_MEMORY,
- &lpc_memmap);
-
- if (result != EC_SUCCESS)
- LOG_ERR("Get lpc_memmap failed (%d)!\n", result);
-
- return (uint8_t *)lpc_memmap;
-}
-
-/**
- * Update the level-sensitive wake signal to the AP.
- *
- * @param wake_events Currently asserted wake events
- */
-static void lpc_update_wake(host_event_t wake_events)
-{
- /*
- * Mask off power button event, since the AP gets that through a
- * separate dedicated GPIO.
- */
- wake_events &= ~EC_HOST_EVENT_MASK(EC_HOST_EVENT_POWER_BUTTON);
-
- /* Signal is asserted low when wake events is non-zero */
- gpio_set_level(GPIO_EC_PCH_WAKE_ODL, !wake_events);
-}
-
-static void lpc_generate_smi(void)
-{
- /* Enforce signal-high for long enough to debounce high */
- espi_vw_set_wire(VW_SMI_L, 1);
- udelay(VWIRE_PULSE_TRIGGER_TIME);
- espi_vw_set_wire(VW_SMI_L, 0);
- udelay(VWIRE_PULSE_TRIGGER_TIME);
- espi_vw_set_wire(VW_SMI_L, 1);
-}
-
-static void lpc_generate_sci(void)
-{
- /* Enforce signal-high for long enough to debounce high */
- espi_vw_set_wire(VW_SCI_L, 1);
- udelay(VWIRE_PULSE_TRIGGER_TIME);
- espi_vw_set_wire(VW_SCI_L, 0);
- udelay(VWIRE_PULSE_TRIGGER_TIME);
- espi_vw_set_wire(VW_SCI_L, 1);
-}
-
-void lpc_update_host_event_status(void)
-{
- uint32_t enable;
- uint32_t status;
- int need_sci = 0;
- int need_smi = 0;
-
- if (!init_done)
- return;
-
- /* Disable PMC1 interrupt while updating status register */
- enable = 0;
- espi_write_lpc_request(espi_dev, ECUSTOM_HOST_SUBS_INTERRUPT_EN,
- &enable);
-
- espi_read_lpc_request(espi_dev, EACPI_READ_STS, &status);
- if (lpc_get_host_events_by_type(LPC_HOST_EVENT_SMI)) {
- /* Only generate SMI for first event */
- if (!(status & EC_LPC_STATUS_SMI_PENDING))
- need_smi = 1;
-
- status |= EC_LPC_STATUS_SMI_PENDING;
- espi_write_lpc_request(espi_dev, EACPI_WRITE_STS, &status);
- } else {
- status &= ~EC_LPC_STATUS_SMI_PENDING;
- espi_write_lpc_request(espi_dev, EACPI_WRITE_STS, &status);
- }
-
- espi_read_lpc_request(espi_dev, EACPI_READ_STS, &status);
- if (lpc_get_host_events_by_type(LPC_HOST_EVENT_SCI)) {
- /* Generate SCI for every event */
- need_sci = 1;
-
- status |= EC_LPC_STATUS_SCI_PENDING;
- espi_write_lpc_request(espi_dev, EACPI_WRITE_STS, &status);
- } else {
- status &= ~EC_LPC_STATUS_SCI_PENDING;
- espi_write_lpc_request(espi_dev, EACPI_WRITE_STS, &status);
- }
-
- *(host_event_t *)host_get_memmap(EC_MEMMAP_HOST_EVENTS) =
- lpc_get_host_events();
-
- enable = 1;
- espi_write_lpc_request(espi_dev, ECUSTOM_HOST_SUBS_INTERRUPT_EN,
- &enable);
-
- /* Process the wake events. */
- lpc_update_wake(lpc_get_host_events_by_type(LPC_HOST_EVENT_WAKE));
-
- /* Send pulse on SMI signal if needed */
- if (need_smi)
- lpc_generate_smi();
-
- /* ACPI 5.0-12.6.1: Generate SCI for SCI_EVT=1. */
- if (need_sci)
- lpc_generate_sci();
-}
-
-static void host_command_init(void)
-{
- /* We support LPC args and version 3 protocol */
- *(lpc_get_memmap_range() + EC_MEMMAP_HOST_CMD_FLAGS) =
- EC_HOST_CMD_FLAG_LPC_ARGS_SUPPORTED |
- EC_HOST_CMD_FLAG_VERSION_3;
-
- /* Sufficiently initialized */
- init_done = 1;
-
- lpc_update_host_event_status();
-}
-
-DECLARE_HOOK(HOOK_INIT, host_command_init, HOOK_PRIO_INIT_LPC);
-
-static void handle_acpi_write(uint32_t data)
-{
- uint8_t value, result;
- uint8_t is_cmd = is_acpi_command(data);
- uint32_t status;
-
- value = get_acpi_value(data);
-
- /* Handle whatever this was. */
- if (acpi_ap_to_ec(is_cmd, value, &result)) {
- data = result;
- espi_write_lpc_request(espi_dev, EACPI_WRITE_CHAR, &data);
- }
-
- /* Clear processing flag */
- espi_read_lpc_request(espi_dev, EACPI_READ_STS, &status);
- status &= ~EC_LPC_STATUS_PROCESSING;
- espi_write_lpc_request(espi_dev, EACPI_WRITE_STS, &status);
-
- /*
- * ACPI 5.0-12.6.1: Generate SCI for Input Buffer Empty / Output Buffer
- * Full condition on the kernel channel.
- */
- lpc_generate_sci();
-}
-
-static void lpc_send_response_packet(struct host_packet *pkt)
-{
- uint32_t data;
-
- /* TODO(b/176523211): check whether add EC_RES_IN_PROGRESS handle */
-
- /* Write result to the data byte. This sets the TOH status bit. */
- data = pkt->driver_result;
- espi_write_lpc_request(espi_dev, ECUSTOM_HOST_CMD_SEND_RESULT, &data);
-}
-
-static void handle_host_write(uint32_t data)
-{
- uint32_t shm_mem_host_cmd;
-
- if (EC_COMMAND_PROTOCOL_3 != (data & 0xff)) {
- LOG_ERR("Don't support this version of the host command");
- /* TODO:(b/175217186): error response for other versions */
- return;
- }
-
- espi_read_lpc_request(espi_dev, ECUSTOM_HOST_CMD_GET_PARAM_MEMORY,
- &shm_mem_host_cmd);
-
- lpc_packet.send_response = lpc_send_response_packet;
-
- lpc_packet.request = (const void *)shm_mem_host_cmd;
- lpc_packet.request_temp = params_copy;
- lpc_packet.request_max = sizeof(params_copy);
- /* Don't know the request size so pass in the entire buffer */
- lpc_packet.request_size = EC_LPC_HOST_PACKET_SIZE;
-
- lpc_packet.response = (void *)shm_mem_host_cmd;
- lpc_packet.response_max = EC_LPC_HOST_PACKET_SIZE;
- lpc_packet.response_size = 0;
-
- lpc_packet.driver_result = EC_RES_SUCCESS;
-
- host_packet_receive(&lpc_packet);
- return;
-}
-
-void lpc_set_acpi_status_mask(uint8_t mask)
-{
- uint32_t status;
- espi_read_lpc_request(espi_dev, EACPI_READ_STS, &status);
- status |= mask;
- espi_write_lpc_request(espi_dev, EACPI_WRITE_STS, &status);
-}
-
-void lpc_clear_acpi_status_mask(uint8_t mask)
-{
- uint32_t status;
- espi_read_lpc_request(espi_dev, EACPI_READ_STS, &status);
- status &= ~mask;
- espi_write_lpc_request(espi_dev, EACPI_WRITE_STS, &status);
-}
-
-/* Get protocol information */
-static enum ec_status lpc_get_protocol_info(struct host_cmd_handler_args *args)
-{
- struct ec_response_get_protocol_info *r = args->response;
-
- memset(r, 0, sizeof(*r));
- r->protocol_versions = BIT(3);
- r->max_request_packet_size = EC_LPC_HOST_PACKET_SIZE;
- r->max_response_packet_size = EC_LPC_HOST_PACKET_SIZE;
- r->flags = 0;
-
- args->response_size = sizeof(*r);
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_GET_PROTOCOL_INFO, lpc_get_protocol_info,
- EC_VER_MASK(0));
-
-/*
- * This function is needed only for the obsolete platform which uses the GPIO
- * for KBC's IRQ.
- */
-void lpc_keyboard_resume_irq(void) {}
-
-void lpc_keyboard_clear_buffer(void)
-{
- /* Clear OBF flag in host STATUS and HIKMST regs */
- espi_write_lpc_request(espi_dev, E8042_CLEAR_OBF, 0);
-}
-int lpc_keyboard_has_char(void)
-{
- uint32_t status;
-
- /* if OBF bit is '1', that mean still have a data in DBBOUT */
- espi_read_lpc_request(espi_dev, E8042_OBF_HAS_CHAR, &status);
- return status;
-}
-
-void lpc_keyboard_put_char(uint8_t chr, int send_irq)
-{
- uint32_t kb_char = chr;
-
- espi_write_lpc_request(espi_dev, E8042_WRITE_KB_CHAR, &kb_char);
- LOG_INF("KB put %02x", kb_char);
-}
-
-/* Put an aux char to host buffer by HIMDO and assert status bit 5. */
-void lpc_aux_put_char(uint8_t chr, int send_irq)
-{
- uint32_t kb_char = chr;
- uint32_t status = I8042_AUX_DATA;
-
- espi_write_lpc_request(espi_dev, E8042_SET_FLAG, &status);
- espi_write_lpc_request(espi_dev, E8042_WRITE_KB_CHAR, &kb_char);
- LOG_INF("AUX put %02x", kb_char);
-}
-
-static void kbc_ibf_obe_handler(uint32_t data)
-{
-#ifdef HAS_TASK_KEYPROTO
- uint8_t is_ibf = is_8042_ibf(data);
- uint32_t status = I8042_AUX_DATA;
-
- if (is_ibf) {
- keyboard_host_write(get_8042_data(data),
- get_8042_type(data));
- } else if (IS_ENABLED(CONFIG_8042_AUX)) {
- espi_write_lpc_request(espi_dev, E8042_CLEAR_FLAG, &status);
- }
- task_wake(TASK_ID_KEYPROTO);
-#endif
-}
-
-int lpc_keyboard_input_pending(void)
-{
- uint32_t status;
-
- /* if IBF bit is '1', that mean still have a data in DBBIN */
- espi_read_lpc_request(espi_dev, E8042_IBF_HAS_CHAR, &status);
- return status;
-}
-
-static void espi_peripheral_handler(const struct device *dev,
- struct espi_callback *cb,
- struct espi_event event)
-{
- uint16_t event_type = event.evt_details;
-
- if (IS_ENABLED(CONFIG_PLATFORM_EC_PORT80) &&
- event_type == ESPI_PERIPHERAL_DEBUG_PORT80) {
- port_80_write(event.evt_data);
- }
-
- if (IS_ENABLED(CONFIG_PLATFORM_EC_ACPI) &&
- event_type == ESPI_PERIPHERAL_HOST_IO) {
- handle_acpi_write(event.evt_data);
- }
-
- if (IS_ENABLED(CONFIG_PLATFORM_EC_HOSTCMD) &&
- event_type == ESPI_PERIPHERAL_EC_HOST_CMD) {
- handle_host_write(event.evt_data);
- }
-
- if (IS_ENABLED(CONFIG_ESPI_PERIPHERAL_8042_KBC) &&
- IS_ENABLED(HAS_TASK_KEYPROTO) &&
- event_type == ESPI_PERIPHERAL_8042_KBC) {
- kbc_ibf_obe_handler(event.evt_data);
- }
-}
-
-int zephyr_shim_setup_espi(void)
-{
- static struct {
- struct espi_callback cb;
- espi_callback_handler_t handler;
- enum espi_bus_event event_type;
- } callbacks[] = {
- {
- .handler = espi_vwire_handler,
- .event_type = ESPI_BUS_EVENT_VWIRE_RECEIVED,
- },
- {
- .handler = espi_peripheral_handler,
- .event_type = ESPI_BUS_PERIPHERAL_NOTIFICATION,
- },
-#ifdef CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK
- {
- .handler = espi_reset_handler,
- .event_type = ESPI_BUS_RESET,
- },
-#endif
- };
-
- struct espi_cfg cfg = {
- .io_caps = ESPI_IO_MODE_SINGLE_LINE,
- .channel_caps = ESPI_CHANNEL_VWIRE | ESPI_CHANNEL_PERIPHERAL |
- ESPI_CHANNEL_OOB,
- .max_freq = 20,
- };
-
- espi_dev = DEVICE_DT_GET(ESPI_NODE);
- if (!device_is_ready(espi_dev)) {
- LOG_ERR("Error: device %s is not ready", espi_dev->name);
- return -1;
- }
-
- /* Configure eSPI */
- if (espi_config(espi_dev, &cfg)) {
- LOG_ERR("Failed to configure eSPI device");
- return -1;
- }
-
- /* Setup callbacks */
- for (size_t i = 0; i < ARRAY_SIZE(callbacks); i++) {
- espi_init_callback(&callbacks[i].cb, callbacks[i].handler,
- callbacks[i].event_type);
- espi_add_callback(espi_dev, &callbacks[i].cb);
- }
-
- return 0;
-}
diff --git a/zephyr/shim/src/fan.c b/zephyr/shim/src/fan.c
deleted file mode 100644
index 932688fc9c..0000000000
--- a/zephyr/shim/src/fan.c
+++ /dev/null
@@ -1,380 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "fan.h"
-#include "pwm.h"
-#include "pwm/pwm.h"
-#include "system.h"
-#include "math_util.h"
-#include "hooks.h"
-#include "gpio_signal.h"
-#include "gpio.h"
-#include <logging/log.h>
-#include <sys/util_macro.h>
-#include <drivers/sensor.h>
-
-LOG_MODULE_REGISTER(fan_shim, LOG_LEVEL_ERR);
-
-#define FAN_CONFIGS(node_id) \
- const struct fan_conf node_id##_conf = { \
- .flags = (COND_CODE_1(DT_PROP(node_id, not_use_rpm_mode), \
- (0), (FAN_USE_RPM_MODE))) | \
- (COND_CODE_1(DT_PROP(node_id, use_fast_start), \
- (FAN_USE_FAST_START), (0))), \
- .ch = node_id, \
- .pgood_gpio = COND_CODE_1( \
- DT_NODE_HAS_PROP(node_id, pgood_gpio), \
- (GPIO_SIGNAL(DT_PHANDLE(node_id, pgood_gpio))), \
- (GPIO_UNIMPLEMENTED)), \
- .enable_gpio = COND_CODE_1( \
- DT_NODE_HAS_PROP(node_id, enable_gpio), \
- (GPIO_SIGNAL(DT_PHANDLE(node_id, enable_gpio))), \
- (GPIO_UNIMPLEMENTED)), \
- }; \
- const struct fan_rpm node_id##_rpm = { \
- .rpm_min = DT_PROP(node_id, rpm_min), \
- .rpm_start = DT_PROP(node_id, rpm_start), \
- .rpm_max = DT_PROP(node_id, rpm_max), \
- };
-
-#define FAN_INST(node_id) \
- [node_id] = { \
- .conf = &node_id##_conf, \
- .rpm = &node_id##_rpm, \
- },
-
-#define FAN_CONTROL_INST(node_id) \
- [node_id] = { \
- .pwm_id = PWM_CHANNEL(DT_PHANDLE(node_id, pwm)), \
- },
-
-#if DT_NODE_EXISTS(DT_INST(0, named_fans))
-DT_FOREACH_CHILD(DT_INST(0, named_fans), FAN_CONFIGS)
-#endif /* named_fan */
-
-const struct fan_t fans[] = {
-#if DT_NODE_EXISTS(DT_INST(0, named_fans))
- DT_FOREACH_CHILD(DT_INST(0, named_fans), FAN_INST)
-#endif /* named_fan */
-};
-
-#define TACHO_DEV_INIT(node_id) { \
- fan_control[node_id].tach = \
- DEVICE_DT_GET(DT_PHANDLE(node_id, tach)); \
- }
-
-/* 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 */
- FAN_RPM = 0,
- /* FAN duty mode */
- FAN_DUTY,
-};
-
-/* Fan status data structure */
-struct fan_status_t {
- /* Fan mode */
- enum fan_mode current_fan_mode;
- /* Actual rpm */
- int rpm_actual;
- /* Target rpm */
- int rpm_target;
- /* Fan config flags */
- unsigned int flags;
- /* Automatic fan status */
- enum fan_status auto_status;
-};
-
-/* Data structure to define tachometer. */
-struct fan_control_t {
- const struct device *tach;
- enum pwm_channel pwm_id;
-};
-
-static struct fan_status_t fan_status[FAN_CH_COUNT];
-static int rpm_pre[FAN_CH_COUNT];
-static struct fan_control_t fan_control[] = {
-#if DT_NODE_EXISTS(DT_INST(0, named_fans))
- DT_FOREACH_CHILD(DT_INST(0, named_fans), FAN_CONTROL_INST)
-#endif /* named_fan */
-};
-
-/**
- * Get fan rpm value
- *
- * @param ch operation channel
- * @return Actual rpm
- */
-static int fan_rpm(int ch)
-{
- struct sensor_value val = { 0 };
-
- sensor_sample_fetch_chan(fan_control[ch].tach, SENSOR_CHAN_RPM);
- sensor_channel_get(fan_control[ch].tach, SENSOR_CHAN_RPM, &val);
- return (int)val.val1;
-}
-
-/**
- * Check all fans are stopped
- *
- * @return 1: all fans are stopped. 0: else.
- */
-static int fan_all_disabled(void)
-{
- int ch;
-
- for (ch = 0; ch < fan_get_count(); ch++)
- if (fan_status[ch].auto_status != FAN_STATUS_STOPPED)
- return 0;
- return 1;
-}
-
-/**
- * Adjust fan duty by difference between target and actual rpm
- *
- * @param ch operation channel
- * @param rpm_diff difference between target and actual rpm
- * @param duty current fan duty
- */
-static void fan_adjust_duty(int ch, int rpm_diff, int duty)
-{
- int duty_step = 0;
-
- /* Find suitable duty step */
- if (ABS(rpm_diff) >= 2000)
- duty_step = 20;
- else if (ABS(rpm_diff) >= 1000)
- duty_step = 10;
- else if (ABS(rpm_diff) >= 500)
- duty_step = 5;
- else if (ABS(rpm_diff) >= 250)
- duty_step = 3;
- else
- duty_step = 1;
-
- /* Adjust fan duty step by step */
- if (rpm_diff > 0)
- duty = MIN(duty + duty_step, 100);
- else
- duty = MAX(duty - duty_step, 1);
-
- fan_set_duty(ch, duty);
-
- LOG_DBG("fan%d: duty %d, rpm_diff %d", ch, duty, rpm_diff);
-}
-
-/**
- * Smart fan control function.
- *
- * The function sets the pwm duty to reach the target rpm
- *
- * @param ch operation channel
- * @param rpm_actual actual operation rpm value
- * @param rpm_target target operation rpm value
- * @return current fan control status
- */
-enum fan_status fan_smart_control(int ch, int rpm_actual, int rpm_target)
-{
- int duty, rpm_diff;
-
- /* wait rpm is stable */
- if (ABS(rpm_actual - rpm_pre[ch]) > RPM_MARGIN(rpm_actual)) {
- rpm_pre[ch] = rpm_actual;
- return FAN_STATUS_CHANGING;
- }
-
- /* Record previous rpm */
- rpm_pre[ch] = rpm_actual;
-
- /* Adjust PWM duty */
- rpm_diff = rpm_target - rpm_actual;
- duty = fan_get_duty(ch);
- if (duty == 0 && rpm_target == 0)
- return FAN_STATUS_STOPPED;
-
- /* Increase PWM duty */
- if (rpm_diff > RPM_MARGIN(rpm_target)) {
- if (duty == 100)
- return FAN_STATUS_FRUSTRATED;
-
- fan_adjust_duty(ch, rpm_diff, duty);
- return FAN_STATUS_CHANGING;
- /* Decrease PWM duty */
- } else if (rpm_diff < -RPM_MARGIN(rpm_target)) {
- if (duty == 1 && rpm_target != 0)
- return FAN_STATUS_FRUSTRATED;
-
- fan_adjust_duty(ch, rpm_diff, duty);
- return FAN_STATUS_CHANGING;
- }
-
- return FAN_STATUS_LOCKED;
-}
-
-void fan_tick_func(void)
-{
- int ch;
-
- for (ch = 0; ch < FAN_CH_COUNT; ch++) {
- volatile struct fan_status_t *p_status = fan_status + ch;
- /* Make sure rpm mode is enabled */
- if (p_status->current_fan_mode != FAN_RPM) {
- /* Fan in duty mode still want rpm_actual being updated.
- */
- if (p_status->flags & FAN_USE_RPM_MODE) {
- p_status->rpm_actual = fan_rpm(ch);
- if (p_status->rpm_actual > 0)
- p_status->auto_status =
- FAN_STATUS_LOCKED;
- else
- p_status->auto_status =
- FAN_STATUS_STOPPED;
- continue;
- } else {
- if (fan_get_duty(ch) > 0)
- p_status->auto_status =
- FAN_STATUS_LOCKED;
- else
- p_status->auto_status =
- FAN_STATUS_STOPPED;
- }
- continue;
- }
- if (!fan_get_enabled(ch))
- continue;
- /* Get actual rpm */
- p_status->rpm_actual = fan_rpm(ch);
- /* Do smart fan stuff */
- p_status->auto_status = fan_smart_control(
- ch, p_status->rpm_actual, p_status->rpm_target);
- }
-}
-DECLARE_HOOK(HOOK_TICK, fan_tick_func, HOOK_PRIO_DEFAULT);
-
-int fan_get_duty(int ch)
-{
- enum pwm_channel pwm_id = fan_control[ch].pwm_id;
-
- /* Return percent */
- return pwm_get_duty(pwm_id);
-}
-
-int fan_get_rpm_mode(int ch)
-{
- return fan_status[ch].current_fan_mode == FAN_RPM ? 1 : 0;
-}
-
-void fan_set_rpm_mode(int ch, int rpm_mode)
-{
- if (rpm_mode && (fan_status[ch].flags & FAN_USE_RPM_MODE))
- fan_status[ch].current_fan_mode = FAN_RPM;
- else
- fan_status[ch].current_fan_mode = FAN_DUTY;
-}
-
-int fan_get_rpm_actual(int ch)
-{
- /* Check PWM is enabled first */
- if (fan_get_duty(ch) == 0)
- return 0;
-
- LOG_DBG("fan %d: get actual rpm = %d", ch, fan_status[ch].rpm_actual);
- return fan_status[ch].rpm_actual;
-}
-
-int fan_get_enabled(int ch)
-{
- enum pwm_channel pwm_id = fan_control[ch].pwm_id;
-
- return pwm_get_enabled(pwm_id);
-}
-
-void fan_set_enabled(int ch, int enabled)
-{
- enum pwm_channel pwm_id = fan_control[ch].pwm_id;
-
- if (!enabled)
- fan_status[ch].auto_status = FAN_STATUS_STOPPED;
- pwm_enable(pwm_id, enabled);
-}
-
-void fan_channel_setup(int ch, unsigned int flags)
-{
- volatile struct fan_status_t *p_status = fan_status + ch;
-
- if (flags & FAN_USE_RPM_MODE) {
- DT_FOREACH_CHILD(DT_INST(0, named_fans), TACHO_DEV_INIT)
- }
-
- p_status->flags = flags;
- /* Set default fan states */
- p_status->current_fan_mode = FAN_DUTY;
- p_status->auto_status = FAN_STATUS_STOPPED;
-}
-
-void fan_set_duty(int ch, int percent)
-{
- enum pwm_channel pwm_id = fan_control[ch].pwm_id;
-
- /* duty is zero */
- if (!percent) {
- fan_status[ch].auto_status = FAN_STATUS_STOPPED;
- if (fan_all_disabled())
- enable_sleep(SLEEP_MASK_FAN);
- } else
- disable_sleep(SLEEP_MASK_FAN);
-
- /* Set the duty cycle of PWM */
- pwm_set_duty(pwm_id, percent);
-}
-
-int fan_get_rpm_target(int ch)
-{
- return fan_status[ch].rpm_target;
-}
-
-enum fan_status fan_get_status(int ch)
-{
- return fan_status[ch].auto_status;
-}
-
-void fan_set_rpm_target(int ch, int rpm)
-{
- if (rpm == 0) {
- /* If rpm = 0, disable PWM immediately. Why?*/
- fan_set_duty(ch, 0);
- } else {
- /* This is the counterpart of disabling PWM above. */
- if (!fan_get_enabled(ch))
- fan_set_enabled(ch, 1);
- if (rpm > fans[ch].rpm->rpm_max)
- rpm = fans[ch].rpm->rpm_max;
- else if (rpm < fans[ch].rpm->rpm_min)
- rpm = fans[ch].rpm->rpm_min;
- }
-
- /* Set target rpm */
- fan_status[ch].rpm_target = rpm;
- LOG_DBG("fan %d: set target rpm = %d", ch, fan_status[ch].rpm_target);
-}
-
-int fan_is_stalled(int ch)
-{
- int is_pgood = 1;
-
- if (gpio_is_implemented(fans[ch].conf->enable_gpio))
- is_pgood = gpio_get_level(fans[ch].conf->enable_gpio);
-
- return fan_get_enabled(ch) && fan_get_duty(ch) &&
- !fan_get_rpm_actual(ch) && is_pgood;
-}
diff --git a/zephyr/shim/src/flash.c b/zephyr/shim/src/flash.c
deleted file mode 100644
index b72d7b5763..0000000000
--- a/zephyr/shim/src/flash.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <flash.h>
-#include <kernel.h>
-#include <logging/log.h>
-
-#include "console.h"
-#include "drivers/cros_flash.h"
-#include "registers.h"
-#include "task.h"
-#include "util.h"
-
-LOG_MODULE_REGISTER(shim_flash, LOG_LEVEL_ERR);
-
-#define CROS_FLASH_DEV DT_LABEL(DT_NODELABEL(fiu0))
-static const struct device *cros_flash_dev;
-
-K_MUTEX_DEFINE(flash_lock);
-
-/* TODO(b/174873770): Add calls to Zephyr code here */
-#ifdef CONFIG_EXTERNAL_STORAGE
-void crec_flash_lock_mapped_storage(int lock)
-{
- if (lock)
- mutex_lock(&flash_lock);
- else
- mutex_unlock(&flash_lock);
-}
-#endif
-
-int crec_flash_physical_write(int offset, int size, const char *data)
-{
- int rv;
-
- /* Fail if offset, size, and data aren't at least word-aligned */
- if ((offset | size | (uint32_t)(uintptr_t)data) &
- (CONFIG_FLASH_WRITE_SIZE - 1))
- return EC_ERROR_INVAL;
-
- /* Lock physical flash operations */
- crec_flash_lock_mapped_storage(1);
-
- rv = cros_flash_physical_write(cros_flash_dev, offset, size, data);
-
- /* Unlock physical flash operations */
- crec_flash_lock_mapped_storage(0);
-
- return rv;
-}
-
-int crec_flash_physical_erase(int offset, int size)
-{
- int rv;
-
- /* Lock physical flash operations */
- crec_flash_lock_mapped_storage(1);
-
- rv = cros_flash_physical_erase(cros_flash_dev, offset, size);
-
- /* Unlock physical flash operations */
- crec_flash_lock_mapped_storage(0);
-
- return rv;
-}
-
-int crec_flash_physical_get_protect(int bank)
-{
- return cros_flash_physical_get_protect(cros_flash_dev, bank);
-}
-
-uint32_t crec_flash_physical_get_protect_flags(void)
-{
- return cros_flash_physical_get_protect_flags(cros_flash_dev);
-}
-
-int crec_flash_physical_protect_at_boot(uint32_t new_flags)
-{
- return cros_flash_physical_protect_at_boot(cros_flash_dev, new_flags);
-}
-
-int crec_flash_physical_protect_now(int all)
-{
- return cros_flash_physical_protect_now(cros_flash_dev, all);
-}
-
-int crec_flash_physical_read(int offset, int size, char *data)
-{
- int rv;
-
- /* Lock physical flash operations */
- crec_flash_lock_mapped_storage(1);
- rv = cros_flash_physical_read(cros_flash_dev, offset, size, data);
-
- /* Unlock physical flash operations */
- crec_flash_lock_mapped_storage(0);
-
- return rv;
-}
-
-static int flash_dev_init(const struct device *unused)
-{
- ARG_UNUSED(unused);
-
- cros_flash_dev = device_get_binding(CROS_FLASH_DEV);
- if (!cros_flash_dev) {
- LOG_ERR("Fail to find %s", CROS_FLASH_DEV);
- return -ENODEV;
- }
- cros_flash_init(cros_flash_dev);
-
- return 0;
-}
-
-uint32_t crec_flash_physical_get_valid_flags(void)
-{
- return EC_FLASH_PROTECT_RO_AT_BOOT | EC_FLASH_PROTECT_RO_NOW |
- EC_FLASH_PROTECT_ALL_NOW;
-}
-
-uint32_t crec_flash_physical_get_writable_flags(uint32_t cur_flags)
-{
- uint32_t ret = 0;
-
- /* If RO protection isn't enabled, its at-boot state can be changed. */
- if (!(cur_flags & EC_FLASH_PROTECT_RO_NOW))
- ret |= EC_FLASH_PROTECT_RO_AT_BOOT;
-
- /*
- * If entire flash isn't protected at this boot, it can be enabled if
- * the WP GPIO is asserted.
- */
- if (!(cur_flags & EC_FLASH_PROTECT_ALL_NOW) &&
- (cur_flags & EC_FLASH_PROTECT_GPIO_ASSERTED))
- ret |= EC_FLASH_PROTECT_ALL_NOW;
-
- return ret;
-}
-
-/*
- * The priority flash_dev_init should be lower than GPIO initialization because
- * it calls gpio_get_level function.
- */
-#if CONFIG_PLATFORM_EC_FLASH_INIT_PRIORITY <= \
- CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY
-#error "Flash must be initialized after GPIOs"
-#endif
-SYS_INIT(flash_dev_init, POST_KERNEL, CONFIG_PLATFORM_EC_FLASH_INIT_PRIORITY);
diff --git a/zephyr/shim/src/gpio.c b/zephyr/shim/src/gpio.c
deleted file mode 100644
index 2bae272361..0000000000
--- a/zephyr/shim/src/gpio.c
+++ /dev/null
@@ -1,441 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <device.h>
-#include <init.h>
-#include <kernel.h>
-#include <logging/log.h>
-
-#include "gpio.h"
-#include "gpio/gpio.h"
-#include "sysjump.h"
-#include "cros_version.h"
-
-LOG_MODULE_REGISTER(gpio_shim, LOG_LEVEL_ERR);
-
-/*
- * Static information about each GPIO that is configured in the named_gpios
- * device tree node.
- */
-struct gpio_config {
- /* GPIO net name */
- const char *name;
- /* Set at build time for lookup */
- const struct device *dev;
- /* Bit number of pin within device */
- gpio_pin_t pin;
- /* From DTS, excludes interrupts flags */
- gpio_flags_t init_flags;
-};
-
-#define GPIO_CONFIG(id) \
- COND_CODE_1( \
- DT_NODE_HAS_PROP(id, enum_name), \
- ( \
- { \
- .name = DT_LABEL(id), \
- .dev = DEVICE_DT_GET(DT_PHANDLE(id, gpios)), \
- .pin = DT_GPIO_PIN(id, gpios), \
- .init_flags = DT_GPIO_FLAGS(id, gpios), \
- }, ), \
- ())
-static const struct gpio_config configs[] = {
-#if DT_NODE_EXISTS(DT_PATH(named_gpios))
- DT_FOREACH_CHILD(DT_PATH(named_gpios), GPIO_CONFIG)
-#endif
-};
-
-/* Runtime information for each GPIO that is configured in named_gpios */
-struct gpio_data {
- /* Runtime device for gpio port. Set during in init function */
- const struct device *dev;
-};
-
-#define GPIO_DATA(id) COND_CODE_1(DT_NODE_HAS_PROP(id, enum_name), ({}, ), ())
-static struct gpio_data data[] = {
-#if DT_NODE_EXISTS(DT_PATH(named_gpios))
- DT_FOREACH_CHILD(DT_PATH(named_gpios), GPIO_DATA)
-#endif
-};
-
-/* Maps platform/ec gpio callback information */
-struct gpio_signal_callback {
- /* The platform/ec gpio_signal */
- const enum gpio_signal signal;
- /* IRQ handler from platform/ec code */
- void (*const irq_handler)(enum gpio_signal signal);
- /* Interrupt-related gpio flags */
- const gpio_flags_t flags;
-};
-
-/*
- * Each zephyr project should define EC_CROS_GPIO_INTERRUPTS in their gpio_map.h
- * file if there are any interrupts that should be registered. The
- * corresponding handler will be declared here, which will prevent
- * needing to include headers with complex dependencies in gpio_map.h.
- *
- * EC_CROS_GPIO_INTERRUPTS is a space-separated list of GPIO_INT items.
- */
-
-/*
- * Validate interrupt flags are valid for the Zephyr GPIO driver.
- */
-#define IS_GPIO_INTERRUPT_FLAG(flag, mask) ((flag & mask) == mask)
-#define VALID_GPIO_INTERRUPT_FLAG(flag) \
- (IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_EDGE_RISING) || \
- IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_EDGE_FALLING) || \
- IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_EDGE_BOTH) || \
- IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_LEVEL_LOW) || \
- IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_LEVEL_HIGH) || \
- IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_EDGE_TO_INACTIVE) || \
- IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_EDGE_TO_ACTIVE) || \
- IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_LEVEL_INACTIVE) || \
- IS_GPIO_INTERRUPT_FLAG(flag, GPIO_INT_LEVEL_ACTIVE))
-
-#define GPIO_INT(sig, f, cb) \
- BUILD_ASSERT(VALID_GPIO_INTERRUPT_FLAG(f), \
- STRINGIFY(sig) " is not using Zephyr interrupt flags");
-#ifdef EC_CROS_GPIO_INTERRUPTS
-EC_CROS_GPIO_INTERRUPTS
-#endif
-#undef GPIO_INT
-
-/*
- * Create unique enum values for each GPIO_INT entry, which also sets
- * the ZEPHYR_GPIO_INT_COUNT value.
- */
-#define ZEPHYR_GPIO_INT_ID(sig) INT_##sig
-#define GPIO_INT(sig, f, cb) ZEPHYR_GPIO_INT_ID(sig),
-enum zephyr_gpio_int_id {
-#ifdef EC_CROS_GPIO_INTERRUPTS
- EC_CROS_GPIO_INTERRUPTS
-#endif
- ZEPHYR_GPIO_INT_COUNT,
-};
-#undef GPIO_INT
-
-/* Create prototypes for each GPIO IRQ handler */
-#define GPIO_INT(sig, f, cb) void cb(enum gpio_signal signal);
-#ifdef EC_CROS_GPIO_INTERRUPTS
-EC_CROS_GPIO_INTERRUPTS
-#endif
-#undef GPIO_INT
-
-/*
- * The Zephyr gpio_callback data needs to be updated at runtime, so allocate
- * into uninitialized data (BSS). The constant data pulled from
- * EC_CROS_GPIO_INTERRUPTS is stored separately in the gpio_interrupts[] array.
- */
-static struct gpio_callback zephyr_gpio_callbacks[ZEPHYR_GPIO_INT_COUNT];
-
-#define ZEPHYR_GPIO_CALLBACK_TO_INDEX(cb) \
- (int)(((int)(cb) - (int)&zephyr_gpio_callbacks) / \
- sizeof(struct gpio_callback))
-
-#define GPIO_INT(sig, f, cb) \
- { \
- .signal = sig, \
- .flags = f, \
- .irq_handler = cb, \
- },
-const static struct gpio_signal_callback
- gpio_interrupts[ZEPHYR_GPIO_INT_COUNT] = {
-#ifdef EC_CROS_GPIO_INTERRUPTS
- EC_CROS_GPIO_INTERRUPTS
-#endif
-#undef GPIO_INT
- };
-
-/* The single zephyr gpio handler that routes to appropriate platform/ec cb */
-static void gpio_handler_shim(const struct device *port,
- struct gpio_callback *cb, gpio_port_pins_t pins)
-{
- int callback_index = ZEPHYR_GPIO_CALLBACK_TO_INDEX(cb);
- const struct gpio_signal_callback *const gpio =
- &gpio_interrupts[callback_index];
-
- /* Call the platform/ec gpio interrupt handler */
- gpio->irq_handler(gpio->signal);
-}
-
-/**
- * get_interrupt_from_signal() - Translate a gpio_signal to the
- * corresponding gpio_signal_callback
- *
- * @signal The signal to convert.
- *
- * Return: A pointer to the corresponding entry in gpio_interrupts, or
- * NULL if one does not exist.
- */
-const static struct gpio_signal_callback *
-get_interrupt_from_signal(enum gpio_signal signal)
-{
- if (!gpio_is_implemented(signal))
- return NULL;
-
- for (size_t i = 0; i < ARRAY_SIZE(gpio_interrupts); i++) {
- if (gpio_interrupts[i].signal == signal)
- return &gpio_interrupts[i];
- }
-
- LOG_ERR("No interrupt defined for GPIO %s", configs[signal].name);
- return NULL;
-}
-
-int gpio_is_implemented(enum gpio_signal signal)
-{
- return signal >= 0 && signal < ARRAY_SIZE(configs);
-}
-
-int gpio_get_level(enum gpio_signal signal)
-{
- if (!gpio_is_implemented(signal))
- return 0;
-
- const int l = gpio_pin_get_raw(data[signal].dev, configs[signal].pin);
-
- if (l < 0) {
- LOG_ERR("Cannot read %s (%d)", configs[signal].name, l);
- return 0;
- }
- return l;
-}
-
-int gpio_get_ternary(enum gpio_signal signal)
-{
- int pd, pu;
- int flags = gpio_get_default_flags(signal);
-
- /* Read GPIO with internal pull-down */
- gpio_set_flags(signal, GPIO_INPUT | GPIO_PULL_DOWN);
- pd = gpio_get_level(signal);
- udelay(100);
-
- /* Read GPIO with internal pull-up */
- gpio_set_flags(signal, GPIO_INPUT | GPIO_PULL_UP);
- pu = gpio_get_level(signal);
- udelay(100);
-
- /* Reset GPIO flags */
- gpio_set_flags(signal, flags);
-
- /* Check PU and PD readings to determine tristate */
- return pu && !pd ? 2 : pd;
-}
-
-const char *gpio_get_name(enum gpio_signal signal)
-{
- if (!gpio_is_implemented(signal))
- return "UNIMPLEMENTED";
-
- return configs[signal].name;
-}
-
-void gpio_set_level(enum gpio_signal signal, int value)
-{
- if (!gpio_is_implemented(signal))
- return;
-
- int rv = gpio_pin_set_raw(data[signal].dev, configs[signal].pin, value);
-
- if (rv < 0) {
- LOG_ERR("Cannot write %s (%d)", configs[signal].name, rv);
- }
-}
-
-void gpio_set_level_verbose(enum console_channel channel,
- enum gpio_signal signal, int value)
-{
- cprints(channel, "Set %s: %d", gpio_get_name(signal), value);
- gpio_set_level(signal, value);
-}
-
-/* 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_INPUT | \
- GPIO_OUTPUT)
-
-static int convert_from_zephyr_flags(const gpio_flags_t zephyr)
-{
- /* Start out with the bits that are the same. */
- int ec_flags = zephyr & GPIO_CONVERSION_SAME_BITS;
- gpio_flags_t unhandled_flags = zephyr & ~GPIO_CONVERSION_SAME_BITS;
-
- /* TODO(b/173789980): handle conversion of more bits? */
- if (unhandled_flags) {
- LOG_WRN("Unhandled GPIO bits in zephyr->ec conversion: 0x%08X",
- unhandled_flags);
- }
-
- return ec_flags;
-}
-
-static gpio_flags_t convert_to_zephyr_flags(int ec_flags)
-{
- /* Start out with the bits that are the same. */
- gpio_flags_t zephyr_flags = ec_flags & GPIO_CONVERSION_SAME_BITS;
- int unhandled_flags = ec_flags & ~GPIO_CONVERSION_SAME_BITS;
-
- /* TODO(b/173789980): handle conversion of more bits? */
- if (unhandled_flags) {
- LOG_WRN("Unhandled GPIO bits in ec->zephyr conversion: 0x%08X",
- unhandled_flags);
- }
-
- return zephyr_flags;
-}
-
-int gpio_get_default_flags(enum gpio_signal signal)
-{
- if (!gpio_is_implemented(signal))
- return 0;
-
- return convert_from_zephyr_flags(configs[signal].init_flags);
-}
-
-static int init_gpios(const struct device *unused)
-{
- gpio_flags_t flags;
- struct jump_data *jdata;
- bool is_sys_jumped;
-
- ARG_UNUSED(unused);
-
- jdata = get_jump_data();
-
- if (jdata && jdata->magic == JUMP_DATA_MAGIC)
- is_sys_jumped = true;
- else
- is_sys_jumped = false;
-
- /* Loop through all GPIOs in device tree to set initial configuration */
- for (size_t i = 0; i < ARRAY_SIZE(configs); ++i) {
- data[i].dev = configs[i].dev;
- int rv;
-
- if (!device_is_ready(data[i].dev))
- LOG_ERR("Not found (%s)", configs[i].name);
-
- /*
- * The configs[i].init_flags variable is read-only, so the
- * following assignment is needed because the flags need
- * adjusting on a warm reboot.
- */
- flags = configs[i].init_flags;
-
- if (is_sys_jumped) {
- flags &=
- ~(GPIO_OUTPUT_INIT_LOW | GPIO_OUTPUT_INIT_HIGH);
- }
-
- rv = gpio_pin_configure(data[i].dev, configs[i].pin, flags);
- if (rv < 0) {
- LOG_ERR("Config failed %s (%d)", configs[i].name, rv);
- }
- }
-
- /*
- * Loop through all interrupt pins and set their callback.
- */
- for (size_t i = 0; i < ARRAY_SIZE(gpio_interrupts); ++i) {
- const enum gpio_signal signal = gpio_interrupts[i].signal;
- int rv;
-
- if (signal == GPIO_UNIMPLEMENTED)
- continue;
-
- gpio_init_callback(&zephyr_gpio_callbacks[i], gpio_handler_shim,
- BIT(configs[signal].pin));
- rv = gpio_add_callback(data[signal].dev,
- &zephyr_gpio_callbacks[i]);
-
- if (rv < 0) {
- LOG_ERR("Callback reg failed %s (%d)",
- configs[signal].name, rv);
- continue;
- }
- }
-
- /* Configure unused pins in chip driver for better power consumption */
- if (gpio_config_unused_pins) {
- int rv;
-
- rv = gpio_config_unused_pins();
- if (rv < 0) {
- return rv;
- }
- }
-
- return 0;
-}
-#if CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY <= CONFIG_KERNEL_INIT_PRIORITY_DEFAULT
-#error "GPIOs must initialize after the kernel default initialization"
-#endif
-SYS_INIT(init_gpios, POST_KERNEL, CONFIG_PLATFORM_EC_GPIO_INIT_PRIORITY);
-
-int gpio_enable_interrupt(enum gpio_signal signal)
-{
- int rv;
- const struct gpio_signal_callback *interrupt;
-
- interrupt = get_interrupt_from_signal(signal);
-
- if (!interrupt)
- return -1;
-
- /*
- * Config interrupt flags (e.g. INT_EDGE_BOTH) & enable interrupt
- * together.
- */
- rv = gpio_pin_interrupt_configure(data[signal].dev, configs[signal].pin,
- (interrupt->flags | GPIO_INT_ENABLE) &
- ~GPIO_INT_DISABLE);
- if (rv < 0) {
- LOG_ERR("Failed to enable interrupt on %s (%d)",
- configs[signal].name, rv);
- }
-
- return rv;
-}
-
-int gpio_disable_interrupt(enum gpio_signal signal)
-{
- int rv;
-
- if (!gpio_is_implemented(signal))
- return -1;
-
- rv = gpio_pin_interrupt_configure(data[signal].dev, configs[signal].pin,
- GPIO_INT_DISABLE);
- if (rv < 0) {
- LOG_ERR("Failed to disable interrupt on %s (%d)",
- configs[signal].name, rv);
- }
-
- return rv;
-}
-
-void gpio_reset(enum gpio_signal signal)
-{
- if (!gpio_is_implemented(signal))
- return;
-
- gpio_pin_configure(data[signal].dev, configs[signal].pin,
- configs[signal].init_flags);
-}
-
-void gpio_set_flags(enum gpio_signal signal, int flags)
-{
- if (!gpio_is_implemented(signal))
- return;
-
- gpio_pin_configure(data[signal].dev, configs[signal].pin,
- convert_to_zephyr_flags(flags));
-}
-
-int signal_is_gpio(int signal)
-{
- return true;
-}
diff --git a/zephyr/shim/src/gpio_id.c b/zephyr/shim/src/gpio_id.c
deleted file mode 100644
index 1dddac2c88..0000000000
--- a/zephyr/shim/src/gpio_id.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <devicetree.h>
-#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)
-
-#define CONVERT_NUMERAL_SYSTEM_EVAL(system, bits, nbits) \
- system##_from_bits(bits, nbits)
-#define CONVERT_NUMERAL_SYSTEM(system, bits, nbits) \
- CONVERT_NUMERAL_SYSTEM_EVAL(system, bits, nbits)
-
-#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
-
-__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,
- READ_PIN_FROM_PHANDLE)
- };
-
- if (sizeof(bits) == 0)
- return (uint32_t)-1;
-
- sku_id = CONVERT_NUMERAL_SYSTEM(DT_STRING_TOKEN(DT_PATH(sku),
- system),
- bits, ARRAY_SIZE(bits));
- }
-
- return sku_id;
-}
-
-#endif
-
-#if DT_NODE_EXISTS(DT_PATH(board)) && IS_BOARD_COMPATIBLE
-
-__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,
- READ_PIN_FROM_PHANDLE)
- };
-
- if (sizeof(bits) == 0)
- return -1;
-
- board_version = CONVERT_NUMERAL_SYSTEM(
- DT_STRING_TOKEN(DT_PATH(board), system), bits,
- ARRAY_SIZE(bits));
- }
-
- return board_version;
-}
-
-#endif
diff --git a/zephyr/shim/src/hooks.c b/zephyr/shim/src/hooks.c
deleted file mode 100644
index 79a611812f..0000000000
--- a/zephyr/shim/src/hooks.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <kernel.h>
-#include <zephyr.h>
-
-#include "common.h"
-#include "console.h"
-#include "ec_tasks.h"
-#include "hooks.h"
-#include "task.h"
-#include "timer.h"
-
-int hook_call_deferred(const struct deferred_data *data, int us)
-{
- struct k_work_delayable *work = data->work;
- int rv = 0;
-
- if (us == -1) {
- k_work_cancel_delayable(work);
- } else if (us >= 0) {
- rv = k_work_reschedule(work, K_USEC(us));
- if (rv == -EINVAL) {
- /* Already processing or completed. */
- return 0;
- } else if (rv < 0) {
- cprints(CC_HOOK,
- "Warning: deferred call not submitted, "
- "deferred_data=0x%pP, err=%d",
- data, rv);
- }
- } else {
- return EC_ERROR_PARAM2;
- }
-
- return rv;
-}
-
-static struct zephyr_shim_hook_list *hook_registry[HOOK_TYPE_COUNT];
-
-static int zephyr_shim_setup_hooks(const struct device *unused)
-{
- STRUCT_SECTION_FOREACH(zephyr_shim_hook_list, entry) {
- struct zephyr_shim_hook_list **loc = &hook_registry[entry->type];
-
- /* Find the correct place to put the entry in the registry. */
- while (*loc && (*loc)->priority < entry->priority)
- loc = &((*loc)->next);
-
- entry->next = *loc;
-
- /* Insert the entry. */
- *loc = entry;
- }
-
- return 0;
-}
-
-SYS_INIT(zephyr_shim_setup_hooks, APPLICATION, 1);
-
-void hook_notify(enum hook_type type)
-{
- struct zephyr_shim_hook_list *p;
-
- for (p = hook_registry[type]; p; p = p->next)
- p->routine();
-}
-
-static void check_hook_task_priority(k_tid_t thread)
-{
- /*
- * Numerically lower priorities take precedence, so verify the hook
- * related threads cannot preempt any of the shimmed tasks.
- */
- if (k_thread_priority_get(thread) < (TASK_ID_COUNT - 1))
- cprintf(CC_HOOK,
- "ERROR: %s has priority %d but must be >= %d\n",
- k_thread_name_get(thread),
- k_thread_priority_get(thread), (TASK_ID_COUNT - 1));
-}
-
-void hook_task(void *u)
-{
- /* Periodic hooks will be called first time through the loop */
- static uint64_t last_second = -SECOND;
- static uint64_t last_tick = -HOOK_TICK_INTERVAL;
-
- /*
- * Verify deferred routines are run at the lowest priority.
- */
- check_hook_task_priority(&k_sys_work_q.thread);
- check_hook_task_priority(k_current_get());
-
- while (1) {
- uint64_t t = get_time().val;
- int next = 0;
-
- if (t - last_tick >= HOOK_TICK_INTERVAL) {
- hook_notify(HOOK_TICK);
- last_tick = t;
- }
-
- if (t - last_second >= SECOND) {
- hook_notify(HOOK_SECOND);
- last_second = t;
- }
-
- /* Calculate when next tick needs to occur */
- t = get_time().val;
- if (last_tick + HOOK_TICK_INTERVAL > t)
- next = last_tick + HOOK_TICK_INTERVAL - t;
-
- /*
- * Sleep until next tick, unless we've already exceeded
- * HOOK_TICK_INTERVAL.
- */
- if (next > 0)
- task_wait_event(next);
- }
-}
diff --git a/zephyr/shim/src/host_command.c b/zephyr/shim/src/host_command.c
deleted file mode 100644
index bf863b48de..0000000000
--- a/zephyr/shim/src/host_command.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "host_command.h"
-
-struct host_command *zephyr_find_host_command(int command)
-{
- STRUCT_SECTION_FOREACH(host_command, cmd) {
- if (cmd->command == command)
- return cmd;
- }
-
- return NULL;
-}
diff --git a/zephyr/shim/src/hwtimer.c b/zephyr/shim/src/hwtimer.c
deleted file mode 100644
index 85c72c5c59..0000000000
--- a/zephyr/shim/src/hwtimer.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <kernel.h>
-#include <stdint.h>
-#include <zephyr.h>
-
-#include "hwtimer.h"
-
-uint64_t __hw_clock_source_read64(void)
-{
- return k_ticks_to_us_floor64(k_uptime_ticks());
-}
-
-uint32_t __hw_clock_event_get(void)
-{
- /*
- * CrOS EC event deadlines don't quite make sense in Zephyr
- * terms. Evaluate what to do about this later...
- */
- return 0;
-}
-
-void udelay(unsigned us)
-{
- k_busy_wait(us);
-}
diff --git a/zephyr/shim/src/i2c.c b/zephyr/shim/src/i2c.c
deleted file mode 100644
index 3dba7cde38..0000000000
--- a/zephyr/shim/src/i2c.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <sys/util.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
-
-/*
- * Initialize device bindings in i2c_devices.
- * This macro should be called from within DT_FOREACH_CHILD.
- */
-#define INIT_DEV_BINDING(id) \
- [I2C_PORT(id)] = DEVICE_DT_GET(DT_PHANDLE(id, i2c_port)),
-
-#define INIT_REMOTE_PORTS(id) \
- [I2C_PORT(id)] = DT_PROP_OR(id, remote_port, -1),
-
-#define I2C_PORT_INIT(id) \
- { \
- .name = DT_LABEL(id), \
- .port = I2C_PORT(id), \
- },
-/*
- * Long term we will not need these, for now they're needed to get things to
- * build since these extern symbols are usually defined in
- * board/${BOARD}/board.c.
- *
- * Since all the ports will eventually be handled by device tree. This will
- * be removed at that point.
- */
-const struct i2c_port_t i2c_ports[] = {
- DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), I2C_PORT_INIT)
-};
-const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
-static const int i2c_remote_ports[I2C_PORT_COUNT] = {
- DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), INIT_REMOTE_PORTS)
-};
-static int i2c_physical_ports[I2C_PORT_COUNT];
-
-static const struct device *i2c_devices[I2C_PORT_COUNT] = {
- DT_FOREACH_CHILD(DT_PATH(named_i2c_ports), INIT_DEV_BINDING)
-};
-
-static int init_device_bindings(const struct device *device)
-{
- ARG_UNUSED(device);
-
- /*
- * The EC application may lock the I2C bus for more than a single
- * I2C transaction. Initialize the i2c_physical_ports[] array to map
- * each named-i2c-ports child to the physical bus assignment.
- *
- * TODO(b/199918263): zephyr: Optimize I2C mutexes
- * Modify the port_mutex[] array defined by i2c_controller.c
- * so that only mutexes for unique physical ports are created to
- * save space.
- */
- i2c_physical_ports[0] = 0;
- for (int child = 1; child < I2C_PORT_COUNT; child++) {
- for (int phys_port = 0; phys_port < I2C_PORT_COUNT;
- phys_port++) {
- if (i2c_devices[child] == i2c_devices[phys_port]) {
- i2c_physical_ports[child] = phys_port;
- break;
- }
- }
- }
- return 0;
-}
-SYS_INIT(init_device_bindings, POST_KERNEL, 51);
-
-const struct device *i2c_get_device_for_port(const int port)
-{
- if (port < 0 || port >= I2C_PORT_COUNT)
- return NULL;
- return i2c_devices[port];
-}
-
-int i2c_get_port_from_remote_port(int remote_port)
-{
- for (int port = 0; port < I2C_PORT_COUNT; port++) {
- if (i2c_remote_ports[port] == remote_port)
- return port;
- }
-
- /*
- * Remote port is not defined, return 1:1 mapping to support TCPC
- * firmware updates, which always query the EC for the correct I2C
- * port number.
- */
- return remote_port;
-}
-
-int i2c_get_physical_port(int enum_port)
-{
- int i2c_port = i2c_physical_ports[enum_port];
-
- /*
- * Return -1 for caller if physical port is not defined or the
- * port number is out of port_mutex space.
- * Please ensure the caller won't change anything if -1 received.
- */
- return (i2c_port < I2C_PORT_COUNT) ? i2c_port : -1;
-}
-
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_PORTMAP
-static int command_i2c_portmap(int argc, char **argv)
-{
- int i;
-
- ccprintf("Zephyr physical I2C ports (%d):\n", I2C_PORT_COUNT);
- for (i = 0; i < I2C_PORT_COUNT; i++) {
- ccprintf(" %d : %d\n", i, i2c_physical_ports[i]);
- }
- ccprintf("Zephyr remote I2C ports (%d):\n", I2C_PORT_COUNT);
- for (i = 0; i < I2C_PORT_COUNT; i++) {
- ccprintf(" %d : %d\n", i, i2c_remote_ports[i]);
- }
-
- return EC_RES_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(i2c_portmap, command_i2c_portmap, NULL,
- "Show I2C port mapping");
-#endif /* CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_PORTMAP */
diff --git a/zephyr/shim/src/keyboard_raw.c b/zephyr/shim/src/keyboard_raw.c
deleted file mode 100644
index 8de585a78f..0000000000
--- a/zephyr/shim/src/keyboard_raw.c
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/* Functions needed by keyboard scanner module for Chrome EC */
-
-#include <device.h>
-#include <logging/log.h>
-#include <soc.h>
-#include <zephyr.h>
-
-#include "drivers/cros_kb_raw.h"
-#include "keyboard_raw.h"
-
-LOG_MODULE_REGISTER(shim_cros_kb_raw, LOG_LEVEL_ERR);
-
-#define CROS_KB_RAW_NODE DT_NODELABEL(cros_kb_raw)
-static const struct device *cros_kb_raw_dev;
-
-/**
- * Initialize the raw keyboard interface.
- */
-void keyboard_raw_init(void)
-{
- cros_kb_raw_dev = DEVICE_DT_GET(CROS_KB_RAW_NODE);
- if (!device_is_ready(cros_kb_raw_dev)) {
- LOG_ERR("Error: device %s is not ready", cros_kb_raw_dev->name);
- return;
- }
-
- LOG_INF("%s", __func__);
- cros_kb_raw_init(cros_kb_raw_dev);
-}
-
-/**
- * Finish initialization after task scheduling has started.
- */
-void keyboard_raw_task_start(void)
-{
- keyboard_raw_enable_interrupt(1);
-}
-
-/**
- * Drive the specified column low.
- */
-test_mockable void keyboard_raw_drive_column(int col)
-{
- if (cros_kb_raw_dev)
- cros_kb_raw_drive_column(cros_kb_raw_dev, col);
- else
- LOG_ERR("%s: no cros_kb_raw device!", __func__);
-}
-
-/**
- * Read raw row state.
- * Bits are 1 if signal is present, 0 if not present.
- */
-test_mockable int keyboard_raw_read_rows(void)
-{
- if (cros_kb_raw_dev)
- return cros_kb_raw_read_rows(cros_kb_raw_dev);
-
- LOG_ERR("%s: no cros_kb_raw device!", __func__);
- return -EIO;
-}
-
-/**
- * Enable or disable keyboard interrupts.
- */
-void keyboard_raw_enable_interrupt(int enable)
-{
- if (cros_kb_raw_dev)
- cros_kb_raw_enable_interrupt(cros_kb_raw_dev, enable);
- else
- LOG_ERR("%s: no cros_kb_raw device!", __func__);
-}
diff --git a/zephyr/shim/src/keyscan.c b/zephyr/shim/src/keyscan.c
deleted file mode 100644
index fa8fb11dd2..0000000000
--- a/zephyr/shim/src/keyscan.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT cros_keyscan
-
-#include <assert.h>
-#include <kernel.h>
-#include <soc.h>
-
-#include "keyboard_scan.h"
-
-#if DT_NODE_EXISTS(DT_INST(0, cros_keyscan))
-
-/* The keyboard matrix should have at least enough columns for the
- * standard keyboard with no keypad.
- */
-BUILD_ASSERT(DT_INST_PROP_LEN(0, actual_key_mask) >= KEYBOARD_COLS_NO_KEYPAD);
-
-/*
- * Override the default keyscan_config if the board defines a
- * cros-kb-raw-keyscan node.
- */
-__override struct keyboard_scan_config keyscan_config = {
- .output_settle_us = DT_INST_PROP(0, output_settle),
- .debounce_down_us = DT_INST_PROP(0, debounce_down),
- .debounce_up_us = DT_INST_PROP(0, debounce_up),
- .scan_period_us = DT_INST_PROP(0, scan_period),
- .min_post_scan_delay_us = DT_INST_PROP(0, min_post_scan_delay),
- .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/libgcc_arm.S b/zephyr/shim/src/libgcc_arm.S
deleted file mode 100644
index ffdbefc675..0000000000
--- a/zephyr/shim/src/libgcc_arm.S
+++ /dev/null
@@ -1,11 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "../../third_party/libaeabi-cortexm0/core/cortex-m/ldivmod.S"
-#include "../../third_party/libaeabi-cortexm0/core/cortex-m/uldivmod.S"
-
-exception_panic:
- mov r0, #3 @ K_ERR_KERNEL_OOPS
- b z_fatal_error
diff --git a/zephyr/shim/src/mkbp_event.c b/zephyr/shim/src/mkbp_event.c
deleted file mode 100644
index 39bcb001b8..0000000000
--- a/zephyr/shim/src/mkbp_event.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "mkbp_event.h"
-
-const struct mkbp_event_source *zephyr_find_mkbp_event_source(uint8_t type)
-{
- STRUCT_SECTION_FOREACH(mkbp_event_source, evtsrc) {
- if (evtsrc->event_type == type)
- return evtsrc;
- }
-
- return NULL;
-}
diff --git a/zephyr/shim/src/motionsense_driver/bma255-drvinfo.inc b/zephyr/shim/src/motionsense_driver/bma255-drvinfo.inc
deleted file mode 100644
index 7db46811ad..0000000000
--- a/zephyr/shim/src/motionsense_driver/bma255-drvinfo.inc
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "driver/accel_bma2x2_public.h"
-
-/*
- * CREATE_SENSOR_DATA which is defined in motionsense_sensors.c is
- * the helper to create sensor driver specific data.
- *
- * CREATE_SENSOR_DATA gets two arguments. One is the compatible
- * property value specified in device tree and the other one is the macro
- * that actually creates sensor driver specific data. The macro gets
- * node id and the name to be used for the sensor driver data.
- */
-
-/*
- * Create driver data for each BMI260 drvinfo instance in device tree.
- * (compatible = "cros-ec,drvdata-bma255")
- */
-/* Declare BMA255 driver data */
-#define CREATE_SENSOR_DATA_BMA255(id, drvdata_name) \
- static struct accelgyro_saved_data_t drvdata_name;
-
-CREATE_SENSOR_DATA(cros_ec_drvdata_bma255, CREATE_SENSOR_DATA_BMA255)
-
-/*
- * CREATE_MOTION_SENSOR which is defined in motionsense_sensors.c is
- * the macro to create an entry in motion_sensors array.
- * The macro gets value of compatible property of
- * the sensor in device tree and sensor specific values like chip ID,
- * type of sensor, name of driver, default min/max frequency.
- * Then using the values, it creates the corresponding motion_sense_t entry
- * in motion_sensors array.
- */
-
-/*
- * Create a motion_sensor_t entry for each BMA255
- * instance(compatible = "cros-ec,bma255") in device tree.
- */
-CREATE_MOTION_SENSOR(cros_ec_bma255, MOTIONSENSE_CHIP_BMA255, \
- MOTIONSENSE_TYPE_ACCEL, bma2x2_accel_drv, \
- BMA255_ACCEL_MIN_FREQ, BMA255_ACCEL_MAX_FREQ)
diff --git a/zephyr/shim/src/motionsense_driver/bmi160-drvinfo.inc b/zephyr/shim/src/motionsense_driver/bmi160-drvinfo.inc
deleted file mode 100644
index dd7b21641b..0000000000
--- a/zephyr/shim/src/motionsense_driver/bmi160-drvinfo.inc
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "driver/accelgyro_bmi_common_public.h"
-#include "driver/accelgyro_bmi160_public.h"
-
-/*
- * CREATE_SENSOR_DATA which is defined in motionsense_sensros.c is
- * the helper to create sensor driver specific data.
- *
- * CREATE_SENSOR_DATA gets two arguments. One is the compatible
- * property value specified in device tree and the other one is the macro
- * that actually creates sensor driver specific data. The macro gets
- * node id and the name to be used for the sensor driver data.
- */
-
-/*
- * Create driver data. It can be shared among the entries in
- * motion_sensors array which are using the same bmi160 driver.
- */
-#define CREATE_SENSOR_DATA_BMI160(id, drvdata_name) \
- static struct bmi_drv_data_t drvdata_name;
-
-/*
- * Create driver data for each BMI160 drvinfo instance in device tree.
- * (compatible = "cros-ec,drvdata-bmi160")
- */
-CREATE_SENSOR_DATA(cros_ec_drvdata_bmi160, CREATE_SENSOR_DATA_BMI160)
-/*
- * CREATE_MOTION_SENSOR which is defined in motionsense_sensors.c is
- * the macro to create an entry in motion_sensors array.
- * The macro gets value of compatible property of
- * the sensor in device tree and sensor specific values like chip ID,
- * type of sensor, name of driver, default min/max frequency.
- * Then using the values, it creates the corresponding motion_sense_t entry
- * in motion_sensors array.
- */
-
-/*
- * Here, we call CREATE_MOTION_SENSOR to create a motion_sensor_t entry
- * for each BMI160_accel instance(compatible = "cros-ec,bmi160-accel")
- * in device tree.
- */
-CREATE_MOTION_SENSOR(cros_ec_bmi160_accel, MOTIONSENSE_CHIP_BMI160, \
- MOTIONSENSE_TYPE_ACCEL, bmi160_drv, \
- BMI_ACCEL_MIN_FREQ, BMI_ACCEL_MAX_FREQ)
-
-/*
- * Here, we call CREATE_MOTION_SENSOR to create a motion_sensor_t entry
- * for each BMI260_gyro instance (compatible = "cros-ec,bmi160-gyro")
- * in device tree.
- */
-CREATE_MOTION_SENSOR(cros_ec_bmi160_gyro, MOTIONSENSE_CHIP_BMI160, \
- MOTIONSENSE_TYPE_GYRO, bmi160_drv, \
- BMI_GYRO_MIN_FREQ, BMI_GYRO_MAX_FREQ)
diff --git a/zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc b/zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc
deleted file mode 100644
index 2457fca31a..0000000000
--- a/zephyr/shim/src/motionsense_driver/bmi260-drvinfo.inc
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "driver/accelgyro_bmi_common_public.h"
-#include "driver/accelgyro_bmi260_public.h"
-
-/*
- * CREATE_SENSOR_DATA which is defined in motionsense_sensros.c is
- * the helper to create sensor driver specific data.
- *
- * CREATE_SENSOR_DATA gets two arguments. One is the compatible
- * property value specified in device tree and the other one is the macro
- * that actually creates sensor driver specific data. The macro gets
- * node id and the name to be used for the sensor driver data.
- */
-
-/*
- * Create driver data. It can be shared among the entries in
- * motion_sensors array which are using the same bmi260 driver.
- */
-#define CREATE_SENSOR_DATA_BMI260(id, drvdata_name) \
- static struct bmi_drv_data_t drvdata_name;
-
-/*
- * Create driver data for each BMI260 drvinfo instance in device tree.
- * (compatible = "cros-ec,drvdata-bmi260")
- */
-CREATE_SENSOR_DATA(cros_ec_drvdata_bmi260, CREATE_SENSOR_DATA_BMI260)
-/*
- * CREATE_MOTION_SENSOR which is defined in motionsense_sensros.c is
- * the macro to create an entry in motion_sensors array.
- * The macro gets value of compatible property of
- * the sensor in device tree and sensor specific values like chip ID,
- * type of sensor, name of driver, default min/max frequency.
- * Then using the values, it creates the corresponding motion_sense_t entry
- * in motion_sensors array.
- */
-
-/*
- * Here, we call CREATE_MOTION_SENSOR to create a motion_sensor_t entry
- * for each BMI260_accel instance(compatible = "cros-ec,bmi260-accel")
- * in device tree.
- */
-CREATE_MOTION_SENSOR(cros_ec_bmi260_accel, MOTIONSENSE_CHIP_BMI260, \
- MOTIONSENSE_TYPE_ACCEL, bmi260_drv, \
- BMI_ACCEL_MIN_FREQ, BMI_ACCEL_MAX_FREQ)
-
-/*
- * Here, we call CREATE_MOTION_SENSOR to create a motion_sensor_t entry
- * for each BMI260_gyro instance (compatible = "cros-ec,bmi260-gyro")
- * in device tree.
- */
-CREATE_MOTION_SENSOR(cros_ec_bmi260_gyro, MOTIONSENSE_CHIP_BMI260, \
- MOTIONSENSE_TYPE_GYRO, bmi260_drv, \
- BMI_GYRO_MIN_FREQ, BMI_GYRO_MAX_FREQ)
diff --git a/zephyr/shim/src/motionsense_driver/drvdata-accelgyro.h b/zephyr/shim/src/motionsense_driver/drvdata-accelgyro.h
deleted file mode 100644
index 069587f90f..0000000000
--- a/zephyr/shim/src/motionsense_driver/drvdata-accelgyro.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/*
- * Macros are to help creating driver data. A driver data that uses
- * any data structures defined in accelgyro.h should use the macros here
- * to utilize the information in device tree.
- *
- */
-#ifndef __ZEPHYR_SHIM_SRC_MOTIONSENSE_DRIVER_DRVDATA_ACCELGYRO_H
-#define __ZEPHYR_SHIM_SRC_MOTIONSENSE_DRIVER_DRVDATA_ACCELGYRO_H
-
-/*
- * compatible = "cros-ec,accelgyro-als-channel-scale"
- * als_channel_scale_t in accelgyro.h
- *
- * e.g) The following is the example in DT for als_channel_scale_t
- * als-channel-scale {
- * compatible = "cros-ec,accelgyro-als-channel-scale";
- * k-channel-scale = <1>;
- * cover-scale = <1>;
- * };
- */
-#define ACCELGYRO_ALS_CHANNEL_SCALE(id) \
- { \
- .k_channel_scale = \
- ALS_CHANNEL_SCALE(DT_PROP(id, k_channel_scale)),\
- .cover_scale = \
- ALS_CHANNEL_SCALE(DT_PROP(id, cover_scale)), \
- }
-
-#define ALS_CALIBRATION_CHANNEL_SCALE(id) \
- .als_cal.channel_scale = ACCELGYRO_ALS_CHANNEL_SCALE(id),
-
-#define ALS_CALIBRATION_SET(id) \
- .als_cal.scale = DT_PROP(id, scale), \
- .als_cal.uscale = DT_PROP(id, uscale), \
- .als_cal.offset = DT_PROP(id, offset), \
- ALS_CALIBRATION_CHANNEL_SCALE(DT_CHILD(id, als_channel_scale))
-
-/*
- * compatible = "cros-ec,accelgyro-als-drv-data"
- * als_drv_data_t in accelgyro.h
- *
- * e.g) The following is the example in DT for als_drv_data_t
- * als-drv-data {
- * compatible = "cros-ec,accelgyro-als-drv-data";
- * als-cal {
- * scale = <1>;
- * uscale = <0>;
- * offset = <0>;
- * als-channel-scale {
- * compatible = "cros-ec,accelgyro-als-channel-scale";
- * k-channel-scale = <1>;
- * cover-scale = <1>;
- * };
- * };
- * };
- */
-#define ACCELGYRO_ALS_DRV_DATA(id) \
- { \
- ALS_CALIBRATION_SET(DT_CHILD(id, als_cal)) \
- }
-
-#define RGB_CAL_RGB_SET_SCALE(id) \
- .scale = ACCELGYRO_ALS_CHANNEL_SCALE(id),
-
-#define RGB_CAL_RGB_SET_ONE(id, suffix) \
- .rgb_cal[suffix] = { \
- .offset = DT_PROP(id, offset), \
- .coeff[0] = FLOAT_TO_FP(DT_PROP_BY_IDX(id, coeff, 0)), \
- .coeff[1] = FLOAT_TO_FP(DT_PROP_BY_IDX(id, coeff, 1)), \
- .coeff[2] = FLOAT_TO_FP(DT_PROP_BY_IDX(id, coeff, 2)), \
- .coeff[3] = FLOAT_TO_FP(DT_PROP_BY_IDX(id, coeff, 3)), \
- RGB_CAL_RGB_SET_SCALE(DT_CHILD(id, als_channel_scale)) \
- },
-
-/*
- * compatible = "cros-ec,accelgyro-rgb-calibration"
- * rgb_calibration_t in accelgyro.h
- *
- * e.g) The following is the example in DT for rgb_calibration_t
- * rgb_calibration {
- * compatible = "cros-ec,accelgyro-rgb-calibration";
- *
- * irt = <1>;
- *
- * rgb-cal-x {
- * offset = <0>;
- * coeff = <0 0 0 0>;
- * als-channel-scale {
- * compatible = "cros-ec,accelgyro-als-channel-scale";
- * k-channel-scale = <1>;
- * cover-scale = <1>;
- * };
- * };
- * rgb-cal-y {
- * offset = <0>;
- * coeff = <0 0 0 0>;
- * als-channel-scale {
- * compatible = "cros-ec,accelgyro-als-channel-scale";
- * k-channel-scale = <1>;
- * cover-scale = <1>;
- * };
- * };
- * rgb-cal-z {
- * offset = <0>;
- * coeff = <0 0 0 0>;
- * als-channel-scale {
- * compatible = "cros-ec,accelgyro-als-channel-scale";
- * k-channel-scale = <1>;
- * cover-scale = <1>;
- * };
- * };
- * };
- */
-#define ACCELGYRO_RGB_CALIBRATION(id) \
- { \
- RGB_CAL_RGB_SET_ONE(DT_CHILD(id, rgb_cal_x), X) \
- RGB_CAL_RGB_SET_ONE(DT_CHILD(id, rgb_cal_y), Y) \
- RGB_CAL_RGB_SET_ONE(DT_CHILD(id, rgb_cal_z), Z) \
- .irt = INT_TO_FP(DT_PROP(id, irt)), \
- }
-
-#endif /* __ZEPHYR_SHIM_SRC_MOTIONSENSE_DRIVER_DRVDATA_ACCELGYRO_H */
diff --git a/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc b/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc
deleted file mode 100644
index 800a9a1543..0000000000
--- a/zephyr/shim/src/motionsense_driver/kx022-drvinfo.inc
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "driver/accel_kionix.h"
-
-/*
- * CREATE_SENSOR_DATA which is defined in motionsense_sensors.c is
- * the helper to create sensor driver specific data.
- *
- * CREATE_SENSOR_DATA gets two arguments. One is the compatible
- * property value specified in device tree and the other one is the macro
- * that actually creates sensor driver specific data. The macro gets
- * node id and the name to be used for the sensor driver data.
- */
-
-/*
- * Create driver data for each Kionix drvinfo instance in device tree.
- * (compatible = "cros-ec,drvdata-kionix")
- */
-/* Declare Kionix driver data */
-#define CREATE_SENSOR_DATA_KIONIX(id, drvdata_name) \
- static struct kionix_accel_data drvdata_name;
-
-CREATE_SENSOR_DATA(cros_ec_drvdata_kionix, CREATE_SENSOR_DATA_KIONIX)
-
-/*
- * CREATE_MOTION_SENSOR which is defined in motionsense_sensors.c is
- * the macro to create an entry in motion_sensors array.
- * The macro gets value of compatible property of
- * the sensor in device tree and sensor specific values like chip ID,
- * type of sensor, name of driver, default min/max frequency.
- * Then using the values, it creates the corresponding motion_sense_t entry
- * in motion_sensors array.
- */
-
-/*
- * Create a motion_sensor_t entry for each KX022
- * instance(compatible = "cros-ec,kx022") in device tree.
- */
-CREATE_MOTION_SENSOR(cros_ec_kx022, MOTIONSENSE_CHIP_KX022, \
- MOTIONSENSE_TYPE_ACCEL, kionix_accel_drv, \
- KX022_ACCEL_MIN_FREQ, KX022_ACCEL_MAX_FREQ)
diff --git a/zephyr/shim/src/motionsense_driver/lis2dw12-drvinfo.inc b/zephyr/shim/src/motionsense_driver/lis2dw12-drvinfo.inc
deleted file mode 100644
index 433a9d4192..0000000000
--- a/zephyr/shim/src/motionsense_driver/lis2dw12-drvinfo.inc
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "accel_lis2dw12_public.h"
-
-/*
- * CREATE_SENSOR_DATA which is defined in motionsense_sensors.c is
- * the helper to create sensor driver specific data.
- *
- * CREATE_SENSOR_DATA gets two arguments. One is the compatible
- * property value specified in device tree and the other one is the macro
- * that actually creates sensor driver specific data. The macro gets
- * node id and the name to be used for the sensor driver data.
- */
-
-/*
- * Create driver data for each Kionix drvinfo instance in device tree.
- * (compatible = "cros-ec,drvdata-lis2dw12")
- */
-/* Declare LIS2DW12 driver data */
-#define CREATE_SENSOR_DATA_LIS2DW12(id, drvdata_name) \
- static struct motion_sensor_t drvdata_name;
-
-CREATE_SENSOR_DATA(cros_ec_drvdata_lis2dw12, CREATE_SENSOR_DATA_LIS2DW12)
-
-/*
- * CREATE_MOTION_SENSOR which is defined in motionsense_sensors.c is
- * the macro to create an entry in motion_sensors array.
- * The macro gets value of compatible property of
- * the sensor in device tree and sensor specific values like chip ID,
- * type of sensor, name of driver, default min/max frequency.
- * Then using the values, it creates the corresponding motion_sense_t entry
- * in motion_sensors array.
- */
-
-/*
- * Create a motion_sensor_t entry for each LIS2DW12
- * instance(compatible = "cros-ec,lis2dw12") in device tree.
- */
-CREATE_MOTION_SENSOR(cros_ec_lis2dw12, MOTIONSENSE_CHIP_LIS2DW12, \
- MOTIONSENSE_TYPE_ACCEL, lis2dw12_drv, \
- LIS2DW12_ODR_MIN_VAL, LIS2DW12_ODR_MAX_VAL)
diff --git a/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc b/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc
deleted file mode 100644
index f8fa4b7e53..0000000000
--- a/zephyr/shim/src/motionsense_driver/sensor_drv_list.inc
+++ /dev/null
@@ -1,39 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/*
- * A driver should create <chip>-drvinfo.inc to create
- * driver-specific data and an motion sensor entry in
- * motion_sensors array that are used by motion sense task.
- *
- * This file includes the .inc file and is used by motionsense_sensrs.c to
- * create the sensor driver data and the entries in mostion_sensors array.
- *
- * e.g) bma255-drvinfo.inc is provided for BMA255 chip
- *
- * #ifdef CONFIG_ACCEL_BMA255
- * #include "bma255-drvinfo.inc"
- * #endif
- */
-
-/* supported sensor driver list */
-#ifdef CONFIG_PLATFORM_EC_ACCEL_BMA255
-#include "bma255-drvinfo.inc"
-#endif
-#ifdef CONFIG_PLATFORM_EC_ACCEL_KX022
-#include "kx022-drvinfo.inc"
-#endif
-#ifdef CONFIG_PLATFORM_EC_ACCEL_LIS2DW12
-#include "lis2dw12-drvinfo.inc"
-#endif
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI160
-#include "bmi160-drvinfo.inc"
-#endif
-#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_BMI260
-#include "bmi260-drvinfo.inc"
-#endif
-#ifdef CONFIG_PLATFORM_EC_ALS_TCS3400
-#include "tcs3400-drvinfo.inc"
-#endif
diff --git a/zephyr/shim/src/motionsense_driver/tcs3400-drvinfo.inc b/zephyr/shim/src/motionsense_driver/tcs3400-drvinfo.inc
deleted file mode 100644
index 346688d646..0000000000
--- a/zephyr/shim/src/motionsense_driver/tcs3400-drvinfo.inc
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "driver/als_tcs3400_public.h"
-
-/*
- * CREATE_SENSOR_DATA which is defined in motionsense_sensros.c is
- * the helper to create sensor driver specific data.
- *
- * CREATE_SENSOR_DATA gets two arguments. One is the compatible
- * property value specified in device tree and the other one is the macro
- * that actually creates sensor driver specific data. The macro gets
- * node id and the name to be used for the sensor driver data.
- */
-
-/* include macros for common data strutures from accelgyro.h */
-#include "drvdata-accelgyro.h"
-
-/* Create driver data for tcs3400 driver. */
-#define CREATE_SENSOR_DATA_TCS3400_CLEAR(id, drvdata_name) \
- static struct als_drv_data_t drvdata_name = \
- ACCELGYRO_ALS_DRV_DATA(DT_CHILD(id, als_drv_data));
-
-/*
- * Create driver data for each TCS3400-clear drvdata instance in device tree.
- * (compatible = "cros-ec,drvdata-tcs3400-clear")
- */
-CREATE_SENSOR_DATA(cros_ec_drvdata_tcs3400_clear, \
- CREATE_SENSOR_DATA_TCS3400_CLEAR)
-
-/* driver data for tcs3400 rgb */
-#define TCS3400_RGB_SATRURATION(id) \
- COND_CODE_1(DT_NODE_HAS_PROP(id, again), \
- (.saturation.again = DT_PROP(id, again),), \
- (.saturation.again = TCS_DEFAULT_AGAIN,)) \
- COND_CODE_1(DT_NODE_HAS_PROP(id, atime), \
- (.saturation.again = DT_PROP(id, atime),), \
- (.saturation.again = TCS_DEFAULT_ATIME,))
-
-#define CREATE_SENSOR_DATA_TCS3400_RGB(id, drvdata_name) \
- static struct tcs3400_rgb_drv_data_t drvdata_name = { \
- .calibration = ACCELGYRO_RGB_CALIBRATION( \
- DT_CHILD(id, rgb_calibration)), \
- TCS3400_RGB_SATRURATION(DT_CHILD(id, saturation)) \
- };
-
-/*
- * Create driver data for each TCS3400-rgb drvdata instance in device tree.
- * (compatible = "cros-ec,drvdata-tcs3400-rgb")
- */
-CREATE_SENSOR_DATA(cros_ec_drvdata_tcs3400_rgb, CREATE_SENSOR_DATA_TCS3400_RGB)
-/*
- * CREATE_MOTION_SENSOR which is defined in motionsense_sensros.c is
- * the macro to create an entry in motion_sensors array.
- * The macro gets value of compatible property of
- * the sensor in device tree and sensor specific values like chip ID,
- * type of sensor, name of driver, default min/max frequency.
- * Then using the values, it creates the corresponding motion_sense_t entry
- * in motion_sensors array.
- */
-
-/*
- * Here, we call CREATE_MOTION_SENSOR to create a motion_sensor_t entry
- * for each TCS3400 clear instance (compatible = "cros-ec,tcs3400-clear")
- * in device tree.
- */
-CREATE_MOTION_SENSOR(cros_ec_tcs3400_clear, MOTIONSENSE_CHIP_TCS3400, \
- MOTIONSENSE_TYPE_LIGHT, tcs3400_drv, \
- TCS3400_LIGHT_MIN_FREQ, TCS3400_LIGHT_MAX_FREQ)
-
-/*
- * Here, we call CREATE_MOTION_SENSOR to create a motion_sensor_t entry
- * for each TCS3400 RGB instance (compatible = "cros-ec,tcs3400-rgb")
- * in device tree.
- */
-CREATE_MOTION_SENSOR(cros_ec_tcs3400_rgb, MOTIONSENSE_CHIP_TCS3400, \
- MOTIONSENSE_TYPE_LIGHT_RGB, tcs3400_rgb_drv, 0, 0)
diff --git a/zephyr/shim/src/motionsense_sensors.c b/zephyr/shim/src/motionsense_sensors.c
deleted file mode 100644
index 0c54160e2e..0000000000
--- a/zephyr/shim/src/motionsense_sensors.c
+++ /dev/null
@@ -1,403 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "common.h"
-#include "accelgyro.h"
-#include "hooks.h"
-#include "drivers/cros_cbi.h"
-
-#define SENSOR_MUTEX_NODE DT_PATH(motionsense_mutex)
-#define SENSOR_MUTEX_NAME(id) DT_CAT(MUTEX_, id)
-
-#if DT_NODE_EXISTS(SENSOR_MUTEX_NODE)
-#define DECLARE_SENSOR_MUTEX(id) K_MUTEX_DEFINE(SENSOR_MUTEX_NAME(id));
-
-/*
- * Declare mutex for
- * each child node of "/motionsense-mutex" node in DT.
- *
- * A mutex can be shared among the motion sensors.
- */
-DT_FOREACH_CHILD(SENSOR_MUTEX_NODE, DECLARE_SENSOR_MUTEX)
-#endif /* DT_NODE_EXISTS(SENSOR_MUTEX_NODE) */
-
-#define SENSOR_ROT_REF_NODE DT_PATH(motionsense_rotation_ref)
-#define SENSOR_ROT_STD_REF_NAME(id) DT_CAT(ROT_REF_, id)
-#define MAT_ITEM(i, id) FLOAT_TO_FP((int32_t)(DT_PROP_BY_IDX(id, mat33, i)))
-#define DECLARE_SENSOR_ROT_REF(id) \
- static const mat33_fp_t SENSOR_ROT_STD_REF_NAME(id) = { \
- { \
- FOR_EACH_FIXED_ARG(MAT_ITEM, (,), id, 0, 1, 2) \
- }, \
- { \
- FOR_EACH_FIXED_ARG(MAT_ITEM, (,), id, 3, 4, 5) \
- }, \
- { \
- FOR_EACH_FIXED_ARG(MAT_ITEM, (,), id, 6, 7, 8) \
- }, \
- };
-
-/*
- * Declare 3x3 rotation matrix for
- * each child node of "/motionsense-rotation-ref" node in DT.
- *
- * A rotation matrix can be shared among the motion sensors.
- */
-#if DT_NODE_EXISTS(SENSOR_ROT_REF_NODE)
-DT_FOREACH_CHILD(SENSOR_ROT_REF_NODE, DECLARE_SENSOR_ROT_REF)
-#endif
-
-/*
- * Declare sensor driver data for
- * each child node with status = "okay" of
- * "/motionsense-sensor-data" node in DT.
- *
- * A driver data can be shared among the motion sensors.
- */
-#define SENSOR_DATA_NAME(id) DT_CAT(SENSOR_DAT_, id)
-#define SENSOR_DATA_NODE DT_PATH(motionsense_sensor_data)
-
-#define SENSOR_DATA(inst, compat, create_data_macro) \
- create_data_macro(DT_INST(inst, compat), \
- SENSOR_DATA_NAME(DT_INST(inst, compat)))
-
-/*
- * CREATE_SENSOR_DATA is a helper macro that gets
- * compat and create_data_macro as parameters.
- *
- * For each node with compatible = "compat",
- * CREATE_SENSOR_DATA expands "create_data_macro" macro with the node id and
- * the designated name for the sensor driver data to be created. The
- * "create_datda_macro" macro is responsible for creating the sensor driver
- * data with the name.
- *
- * Sensor drivers should provide <chip>-drvinfo.inc file and, in the file,
- * it should have the macro that creates its sensor driver data using device
- * tree and pass the macro via CREATE_SENSOR_DATA.
- *
- * e.g) The below is contents of tcs3400-drvinfo.inc file. The file has
- * CREATE_SENSOR_DATA_TCS3400_CLEAR that creates the static instance of
- * "struct als_drv_data_t" with the given name and initializes it
- * with device tree. Then use CREATE_SENSOR_DATA.
- *
- * ----------- bma255-drvinfo.inc -----------
- * #define CREATE_SENSOR_DATA_TCS3400_CLEAR(id, drvdata_name) \
- * static struct als_drv_data_t drvdata_name = \
- * ACCELGYRO_ALS_DRV_DATA(DT_CHILD(id, als_drv_data));
- *
- * CREATE_SENSOR_DATA(cros_ec_drvdata_tcs3400_clear, \
- * CREATE_SENSOR_DATA_TCS3400_CLEAR)
- */
-#define CREATE_SENSOR_DATA(compat, create_data_macro) \
- UTIL_LISTIFY(DT_NUM_INST_STATUS_OKAY(compat), SENSOR_DATA, \
- compat, create_data_macro)
-
-/*
- * sensor_drv_list.inc is included three times in this file. This is the first
- * time and it is for creating sensor driver-specific data. So we ignore
- * CREATE_MOTION_SENSOR() that creates motion sensor at this time.
- */
-#define CREATE_MOTION_SENSOR(s_compat, s_chip, s_type, s_drv, \
- s_min_freq, s_max_freq)
-
-/*
- * Here, we declare all sensor driver data. How to create the data is
- * defined in <chip>-drvinfo.inc file and ,in turn, the file is included
- * in sensor_drv_list.inc.
- */
-#if DT_NODE_EXISTS(SENSOR_DATA_NODE)
-#include "motionsense_driver/sensor_drv_list.inc"
-#endif
-
-/*
- * Get the address of the mutex which is referred by phandle.
- * See motionsense-sensor-base.yaml and cros-ec,motionsense-mutex.yaml
- * for DT example and details.
- */
-#define SENSOR_MUTEX(id) \
- IF_ENABLED(DT_NODE_HAS_PROP(id, mutex), \
- (.mutex = &SENSOR_MUTEX_NAME(DT_PHANDLE(id, mutex)),))
-
-/*
- * Get I2C port number which is referred by phandle.
- * See motionsense-sensor-base.yaml for DT example and details.
- */
-#define SENSOR_I2C_PORT(id) \
- IF_ENABLED(DT_NODE_HAS_PROP(id, port), \
- (.port = I2C_PORT(DT_PHANDLE(id, port)),))
-
-/*
- * Get I2C or SPI address.
- * See motionsense-sensor-base.yaml for DT example and details.
- */
-#define SENSOR_I2C_SPI_ADDR_FLAGS(id) \
- IF_ENABLED(DT_NODE_HAS_PROP(id, i2c_spi_addr_flags), \
- (.i2c_spi_addr_flags = \
- DT_STRING_TOKEN(id, i2c_spi_addr_flags), ))
-
-/*
- * Get the address of rotation matrix which is referred by phandle.
- * See motionsense-sensor-base.yaml and cros-ec,motionsense-rotation-ref.yaml
- * for DT example and details.
- */
-#define SENSOR_ROT_STD_REF(id) \
- IF_ENABLED(DT_NODE_HAS_PROP(id, rot_standard_ref), \
- (.rot_standard_ref = \
- &SENSOR_ROT_STD_REF_NAME(DT_PHANDLE(id, rot_standard_ref)),))
-
-/*
- * Get the address of driver-specific data which is referred by phandle.
- * See motionsense-sensor-base.yaml for DT example and details.
- */
-#define SENSOR_DRV_DATA(id) \
- IF_ENABLED(DT_NODE_HAS_PROP(id, drv_data), \
- (.drv_data = &SENSOR_DATA_NAME(DT_PHANDLE(id, drv_data)),))
-
-/*
- * Get odr and ec_rate for the motion sensor.
- * See motionsense-sensor-base.yaml and cros-ec,motionsense-sensor-config.yaml
- * for DT example and details.
- */
-#define SET_CONFIG_EC(cfg_id, cfg_suffix) \
- [SENSOR_CONFIG_##cfg_suffix] = { \
- IF_ENABLED(DT_NODE_HAS_PROP(cfg_id, odr), \
- (.odr = DT_PROP(cfg_id, odr),)) \
- IF_ENABLED(DT_NODE_HAS_PROP(cfg_id, ec_rate), \
- (.ec_rate = DT_PROP(cfg_id, ec_rate),)) \
- }
-
-/* Get configs */
-#define CREATE_SENSOR_CONFIG(cfgs_id) \
- .config = { \
- IF_ENABLED(DT_NODE_EXISTS(DT_CHILD(cfgs_id, ap)), \
- (SET_CONFIG_EC(DT_CHILD(cfgs_id, ap), AP),)) \
- IF_ENABLED(DT_NODE_EXISTS(DT_CHILD(cfgs_id, ec_s0)), \
- (SET_CONFIG_EC(DT_CHILD(cfgs_id, ec_s0), EC_S0),)) \
- IF_ENABLED(DT_NODE_EXISTS(DT_CHILD(cfgs_id, ec_s3)), \
- (SET_CONFIG_EC(DT_CHILD(cfgs_id, ec_s3), EC_S3),)) \
- IF_ENABLED(DT_NODE_EXISTS(DT_CHILD(cfgs_id, ec_s5)), \
- (SET_CONFIG_EC(DT_CHILD(cfgs_id, ec_s5), EC_S5),)) \
- }
-
-#define SENSOR_CONFIG(id) \
- IF_ENABLED(DT_NODE_EXISTS(DT_CHILD(id, configs)), \
- (CREATE_SENSOR_CONFIG(DT_CHILD(id, configs)),))
-
-/* Get and assign the basic information for a motion sensor */
-#define SENSOR_BASIC_INFO(id) \
- .name = DT_LABEL(id), \
- .active_mask = DT_STRING_TOKEN(id, active_mask), \
- .location = DT_STRING_TOKEN(id, location), \
- .default_range = DT_PROP(id, default_range), \
- SENSOR_I2C_SPI_ADDR_FLAGS(id) \
- SENSOR_MUTEX(id) \
- SENSOR_I2C_PORT(id) \
- SENSOR_ROT_STD_REF(id) \
- SENSOR_DRV_DATA(id) \
- SENSOR_CONFIG(id)
-
-/* Create motion sensor node with node ID */
-#define DO_MK_SENSOR_ENTRY( \
- id, s_chip, s_type, s_drv, s_min_freq, s_max_freq) \
- [SENSOR_ID(id)] = { \
- SENSOR_BASIC_INFO(id) \
- .chip = s_chip, \
- .type = s_type, \
- .drv = &s_drv, \
- .min_frequency = s_min_freq, \
- .max_frequency = s_max_freq \
- },
-
-/* Construct an entry iff the alternate_for property is missing. */
-#define MK_SENSOR_ENTRY(inst, s_compat, s_chip, s_type, s_drv, s_min_freq, \
- s_max_freq) \
- COND_CODE_0(DT_NODE_HAS_PROP(DT_INST(inst, s_compat), alternate_for), \
- (DO_MK_SENSOR_ENTRY(DT_INST(inst, s_compat), s_chip, \
- s_type, s_drv, s_min_freq, \
- s_max_freq)), \
- ())
-
-/* Construct an entry iff the alternate_for property exists. */
-#define MK_SENSOR_ALT_ENTRY(inst, s_compat, s_chip, s_type, s_drv, s_min_freq, \
- s_max_freq) \
- COND_CODE_1(DT_NODE_HAS_PROP(DT_INST(inst, s_compat), alternate_for), \
- (DO_MK_SENSOR_ENTRY(DT_INST(inst, s_compat), s_chip, \
- s_type, s_drv, s_min_freq, \
- s_max_freq)), \
- ())
-
-#undef CREATE_SENSOR_DATA
-/*
- * Sensor driver-specific data creation stage is already done. So this
- * time we ignore CREATE_SENSOR_DATA().
- */
-#define CREATE_SENSOR_DATA(compat, create_data_macro)
-#undef CREATE_MOTION_SENSOR
-
-/*
- * CREATE_MOTION_SENSOR is a help macro that read the sensor information from
- * device tree and creates an entry in motion_sensors array which is used
- * by motion sense task. The help macro gets compatible value of the
- * sensor node and several driver specific information like CHIP_ID,
- * SENSOR_TYPE, driver instance name, and min/max frequency.
- *
- * <chip>-drvinfo.inc file which is provided by sensor driver should use
- * CREATE_MOTION_SENSOR to provide driver specific information.
- *
- * e.g) The below is contents of tcs3400-drvinfo.inc file. The file has
- * CREATE_MOTION_SENSOR like below to create the sensor entry. The file uses
- * the help macro two times since the chip supports two functions
- * ALS clear and ALS RGB.
-
- * ------------- tcs3400-drvinfo.inc -------------
- * // Here, we call CREATE_MOTION_SENSOR to create a motion_sensor_t entry
- * // for each TCS3400 clear instance (compatible = "cros-ec,tcs3400-clear")
- * // in device tree.
- * CREATE_MOTION_SENSOR(cros_ec_tcs3400_clear, MOTIONSENSE_CHIP_TCS3400, \
- * MOTIONSENSE_TYPE_LIGHT, tcs3400_drv, \
- * TCS3400_LIGHT_MIN_FREQ, TCS3400_LIGHT_MAX_FREQ)
-
- *
- * // Here, we call CREATE_MOTION_SENSOR to create a motion_sensor_t entry
- * // for each TCS3400 RGB instance (compatible = "cros-ec,tcs3400-rgb")
- * // in device tree.
- *
- * CREATE_MOTION_SENSOR(cros_ec_tcs3400_rgb, MOTIONSENSE_CHIP_TCS3400, \
- * MOTIONSENSE_TYPE_LIGHT_RGB, tcs3400_rgb_drv, 0, 0)
- * -----------------------------------------------
- */
-#define CREATE_MOTION_SENSOR(s_compat, s_chip, s_type, s_drv, \
- s_min_freq, s_max_freq) \
- UTIL_LISTIFY(DT_NUM_INST_STATUS_OKAY(s_compat), MK_SENSOR_ENTRY,\
- s_compat, s_chip, s_type, s_drv, s_min_freq, s_max_freq)
-
-/*
- * Here, we include sensor_drv_list.inc AGAIN but this time it only
- * uses CREATE_MOTION_SENSOR to create the motion sensor entries.
- */
-struct motion_sensor_t motion_sensors[] = {
-#if DT_NODE_EXISTS(SENSOR_NODE)
-#include "motionsense_driver/sensor_drv_list.inc"
-#endif
-};
-
-/*
- * Remap the CREATE_MOTION_SENSOR to call MK_SENSOR_ALT_ENTRY to create a list
- * of alternate sensors that will be used at runtime.
- */
-#undef CREATE_MOTION_SENSOR
-#define CREATE_MOTION_SENSOR(s_compat, s_chip, s_type, s_drv, s_min_freq, \
- s_max_freq) \
- UTIL_LISTIFY(DT_NUM_INST_STATUS_OKAY(s_compat), MK_SENSOR_ALT_ENTRY, \
- s_compat, s_chip, s_type, s_drv, s_min_freq, s_max_freq)
-
-/*
- * The list of alternate motion sensors that may be used at runtime to replace
- * an entry in the motion_sensors array.
- */
-__maybe_unused struct motion_sensor_t motion_sensors_alt[] = {
-#if DT_NODE_EXISTS(SENSOR_ALT_NODE)
-#include "motionsense_driver/sensor_drv_list.inc"
-#endif
-};
-
-#ifdef CONFIG_DYNAMIC_MOTION_SENSOR_COUNT
-unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
-#else
-const unsigned int motion_sensor_count = ARRAY_SIZE(motion_sensors);
-#endif
-
-/*
- * Create a list of ALS sensors needed by motion sense
- *
- * The following example adds tcs3400 als sensor to motion_als_sensors array
- *
- * motionsense-sensors {
- * lid_accel: bma255 {
- * :
- * };
- * :
- * :
- * als_clear: tcs3400 {
- * :
- * };
- * };
- *
- * motionsense-sensor-info {
- * compatible = "cros-ec,motionsense-sensor-info";
- *
- * // list of entries for motion_als_sensors
- * als-sensors = <&als_clear>;
- * :
- * :
- * };
- */
-#if DT_NODE_HAS_PROP(SENSOR_INFO_NODE, als_sensors)
-#define ALS_SENSOR_ENTRY_WITH_COMMA(i, id) \
- &motion_sensors[SENSOR_ID(DT_PHANDLE_BY_IDX(id, als_sensors, i))],
-const struct motion_sensor_t *motion_als_sensors[] = {
- UTIL_LISTIFY(DT_PROP_LEN(SENSOR_INFO_NODE, als_sensors),
- ALS_SENSOR_ENTRY_WITH_COMMA, SENSOR_INFO_NODE)
-};
-BUILD_ASSERT(ARRAY_SIZE(motion_als_sensors) == ALS_COUNT);
-#endif
-
-/*
- * Enable interrupts for motion sensors
- *
- * e.g) list of named-gpio nodes
- * motionsense-sensor-info {
- * compatible = "cros-ec,motionsense-sensor-info";
- *
- * // list of GPIO interrupts that have to
- * // be enabled at initial stage
- * sensor-irqs = <&gpio_ec_imu_int_l &gpio_ec_als_rgb_int_l>;
- * };
- */
-#if DT_NODE_HAS_PROP(SENSOR_INFO_NODE, sensor_irqs)
-#define SENSOR_GPIO_ENABLE_INTERRUPT(i, id) \
- gpio_enable_interrupt( \
- GPIO_SIGNAL(DT_PHANDLE_BY_IDX(id, sensor_irqs, i)));
-static void sensor_enable_irqs(void)
-{
- UTIL_LISTIFY(DT_PROP_LEN(SENSOR_INFO_NODE, sensor_irqs),
- SENSOR_GPIO_ENABLE_INTERRUPT, SENSOR_INFO_NODE)
-}
-DECLARE_HOOK(HOOK_INIT, sensor_enable_irqs, HOOK_PRIO_DEFAULT);
-#endif
-
-/* Handle the alternative motion sensors */
-#define REPLACE_ALT_MOTION_SENSOR(new_id, old_id) \
- motion_sensors[SENSOR_ID(old_id)] = \
- motion_sensors_alt[SENSOR_ID(new_id)];
-
-#define CHECK_AND_REPLACE_ALT_MOTION_SENSOR(id) \
- do { \
- if (cros_cbi_ssfc_check_match( \
- dev, CBI_SSFC_VALUE_ID(DT_PHANDLE( \
- id, alternate_indicator)))) { \
- REPLACE_ALT_MOTION_SENSOR( \
- id, DT_PHANDLE(id, alternate_for)) \
- } \
- } while (0);
-
-#define ALT_MOTION_SENSOR_INIT_ID(id) \
- COND_CODE_1(UTIL_AND(DT_NODE_HAS_PROP(id, alternate_for), \
- DT_NODE_HAS_PROP(id, alternate_indicator)), \
- (CHECK_AND_REPLACE_ALT_MOTION_SENSOR(id)), ())
-
-void motion_sensors_init_alt(void)
-{
- const struct device *dev = device_get_binding("cros_cbi");
-
- if (dev == NULL)
- return;
-
-#if DT_NODE_EXISTS(SENSOR_ALT_NODE)
- DT_FOREACH_CHILD(SENSOR_ALT_NODE, ALT_MOTION_SENSOR_INIT_ID)
-#endif
-}
-
-DECLARE_HOOK(HOOK_INIT, motion_sensors_init_alt, HOOK_PRIO_INIT_I2C + 1);
diff --git a/zephyr/shim/src/panic.c b/zephyr/shim/src/panic.c
deleted file mode 100644
index 22322cc4ee..0000000000
--- a/zephyr/shim/src/panic.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <arch/cpu.h>
-#include <fatal.h>
-#include <logging/log.h>
-#include <logging/log_ctrl.h>
-#include <zephyr.h>
-
-#include "common.h"
-#include "panic.h"
-
-/*
- * Arch-specific configuration
- *
- * For each architecture, define:
- * - PANIC_ARCH, which should be the corresponding arch field of the
- * panic_data struct.
- * - PANIC_REG_LIST, which is a macro that takes a parameter M, and
- * applies M to 3-tuples of:
- * - zephyr esf field name
- * - panic_data struct field name
- * - human readable name
- */
-
-#if defined(CONFIG_ARM)
-#define PANIC_ARCH PANIC_ARCH_CORTEX_M
-#define PANIC_REG_LIST(M) \
- M(basic.r0, cm.frame[0], a1) \
- M(basic.r1, cm.frame[1], a2) \
- M(basic.r2, cm.frame[2], a3) \
- M(basic.r3, cm.frame[3], a4) \
- M(basic.r12, cm.frame[4], ip) \
- M(basic.lr, cm.frame[5], lr) \
- M(basic.pc, cm.frame[6], pc) \
- M(basic.xpsr, cm.frame[7], xpsr)
-#define PANIC_REG_EXCEPTION(pdata) pdata->cm.regs[1]
-#define PANIC_REG_REASON(pdata) pdata->cm.regs[3]
-#define PANIC_REG_INFO(pdata) pdata->cm.regs[4]
-#elif defined(CONFIG_RISCV) && !defined(CONFIG_64BIT)
-#define PANIC_ARCH PANIC_ARCH_RISCV_RV32I
-#define PANIC_REG_LIST(M) \
- M(ra, riscv.regs[1], ra) \
- M(tp, riscv.regs[3], tp) \
- M(a0, riscv.regs[4], a0) \
- M(a1, riscv.regs[5], a1) \
- M(a2, riscv.regs[6], a2) \
- M(a3, riscv.regs[7], a3) \
- M(a4, riscv.regs[8], a4) \
- M(a5, riscv.regs[9], a5) \
- M(a6, riscv.regs[10], a6) \
- M(a7, riscv.regs[11], a7) \
- M(t0, riscv.regs[12], t0) \
- M(t1, riscv.regs[13], t1) \
- M(t2, riscv.regs[14], t2) \
- M(t3, riscv.regs[15], t3) \
- M(t4, riscv.regs[16], t4) \
- M(t5, riscv.regs[17], t5) \
- M(t6, riscv.regs[18], t6) \
- M(mepc, riscv.mepc, mepc) \
- M(mstatus, riscv.mcause, mstatus)
-#define PANIC_REG_EXCEPTION(pdata) (pdata->riscv.mcause)
-#define PANIC_REG_REASON(pdata) (pdata->riscv.regs[11])
-#define PANIC_REG_INFO(pdata) (pdata->riscv.regs[10])
-#else
-/* Not implemented for this arch */
-#define PANIC_ARCH 0
-#define PANIC_REG_LIST(M)
-#ifdef CONFIG_PLATFORM_EC_SOFTWARE_PANIC
-static uint8_t placeholder_exception_reg;
-static uint32_t placeholder_reason_reg;
-static uint32_t placeholder_info_reg;
-#define PANIC_REG_EXCEPTION(unused) placeholder_exception_reg
-#define PANIC_REG_REASON(unused) placeholder_reason_reg
-#define PANIC_REG_INFO(unused) placeholder_info_reg
-#endif /* CONFIG_PLATFORM_EC_SOFTWARE_PANIC */
-#endif
-
-/* Macros to be applied to PANIC_REG_LIST as M */
-#define PANIC_COPY_REGS(esf_field, pdata_field, human_name) \
- pdata->pdata_field = esf->esf_field;
-#define PANIC_PRINT_REGS(esf_field, pdata_field, human_name) \
- panic_printf(" %-8s = 0x%08X\n", #human_name, pdata->pdata_field);
-
-void panic_data_print(const struct panic_data *pdata)
-{
- PANIC_REG_LIST(PANIC_PRINT_REGS);
-}
-
-#ifndef CONFIG_LOG
-static void copy_esf_to_panic_data(const z_arch_esf_t *esf,
- struct panic_data *pdata)
-{
- pdata->arch = PANIC_ARCH;
- pdata->struct_version = 2;
- pdata->flags = 0;
- pdata->reserved = 0;
- pdata->struct_size = sizeof(*pdata);
- pdata->magic = PANIC_DATA_MAGIC;
-
- PANIC_REG_LIST(PANIC_COPY_REGS);
-}
-
-void k_sys_fatal_error_handler(unsigned int reason, const z_arch_esf_t *esf)
-{
- panic_printf("Fatal error: %u\n", reason);
-
- if (PANIC_ARCH && esf) {
- copy_esf_to_panic_data(esf, get_panic_data_write());
- panic_data_print(panic_get_data());
- }
-
- LOG_PANIC();
- k_fatal_halt(reason);
- CODE_UNREACHABLE;
-}
-#endif /* CONFIG_LOG */
-
-#ifdef CONFIG_PLATFORM_EC_SOFTWARE_PANIC
-void panic_set_reason(uint32_t reason, uint32_t info, uint8_t exception)
-{
- struct panic_data * const pdata = get_panic_data_write();
-
- /* Setup panic data structure */
- memset(pdata, 0, CONFIG_PANIC_DATA_SIZE);
- pdata->magic = PANIC_DATA_MAGIC;
- pdata->struct_size = CONFIG_PANIC_DATA_SIZE;
- pdata->struct_version = 2;
- pdata->arch = PANIC_ARCH;
-
- /* Log panic cause */
- PANIC_REG_EXCEPTION(pdata) = exception;
- PANIC_REG_REASON(pdata) = reason;
- PANIC_REG_INFO(pdata) = info;
-
- /* Allow architecture specific logic */
- arch_panic_set_reason(reason, info, exception);
-}
-
-void panic_get_reason(uint32_t *reason, uint32_t *info, uint8_t *exception)
-{
- struct panic_data * const pdata = panic_get_data();
-
- if (pdata && pdata->struct_version == 2) {
- *exception = PANIC_REG_EXCEPTION(pdata);
- *reason = PANIC_REG_REASON(pdata);
- *info = PANIC_REG_INFO(pdata);
- } else {
- *exception = *reason = *info = 0;
- }
-}
-
-__overridable void arch_panic_set_reason(uint32_t reason, uint32_t info,
- uint8_t exception)
-{
- /* Default implementation, do nothing. */
-}
-#endif /* CONFIG_PLATFORM_EC_SOFTWARE_PANIC */
diff --git a/zephyr/shim/src/pwm.c b/zephyr/shim/src/pwm.c
deleted file mode 100644
index 39fd72007e..0000000000
--- a/zephyr/shim/src/pwm.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <device.h>
-#include <devicetree.h>
-#include <drivers/pwm.h>
-#include <logging/log.h>
-
-#include "common.h"
-#include "console.h"
-#include "ec_commands.h"
-#include "pwm.h"
-#include "util.h"
-
-#include "pwm/pwm.h"
-
-LOG_MODULE_REGISTER(pwm_shim, LOG_LEVEL_ERR);
-
-#define USECS_PER_SEC 1000000
-
-/*
- * Initialize the device bindings in pwm_channels.
- * This macro is called from within DT_FOREACH_CHILD
- */
-#define INIT_DEV_BINDING(id) { \
- pwm_configs[PWM_CHANNEL(id)].name = DT_LABEL(id); \
- pwm_configs[PWM_CHANNEL(id)].dev = DEVICE_DT_GET( \
- DT_PHANDLE(id, pwms)); \
- pwm_configs[PWM_CHANNEL(id)].pin = DT_PWMS_CHANNEL(id); \
- pwm_configs[PWM_CHANNEL(id)].flags = DT_PWMS_FLAGS(id); \
- pwm_configs[PWM_CHANNEL(id)].freq = DT_PROP(id, frequency); \
- }
-
-struct pwm_config {
- /* Name */
- const char *name;
- /* PWM pin */
- uint32_t pin;
- /* PWM channel flags. See dt-bindings/pwm/pwm.h */
- pwm_flags_t flags;
- /* PWM operating frequency. Configured by the devicetree */
- uint32_t freq;
-
- /* PWM period in microseconds. Automatically set to 1/frequency */
- uint32_t period_us;
- /* PWM pulse in microseconds. Set by pwm_set_raw_duty */
- uint32_t pulse_us;
- /* Saves whether the PWM channel is currently enabled */
- bool enabled;
-
- /* Runtime device for PWM */
- const struct device *dev;
-};
-
-static struct pwm_config pwm_configs[PWM_CH_COUNT];
-
-static int init_pwms(const struct device *unused)
-{
- struct pwm_config *pwm;
- int rv = 0;
-
- ARG_UNUSED(unused);
-
- /* Initialize PWM data from the device tree */
- DT_FOREACH_CHILD(DT_PATH(named_pwms), INIT_DEV_BINDING)
-
- /* Read the PWM operating frequency, set by the chip driver */
- for (size_t i = 0; i < PWM_CH_COUNT; ++i) {
- pwm = &pwm_configs[i];
-
- if (pwm->dev == NULL) {
- LOG_ERR("Not found (%s)", pwm->name);
- rv = -ENODEV;
- continue;
- }
-
- /*
- * TODO - check that devicetree frequency is less than 1/2
- * max frequency from the chip driver.
- */
- pwm->period_us = USECS_PER_SEC / pwm->freq;
- }
-
- return rv;
-}
-#if CONFIG_PLATFORM_EC_PWM_INIT_PRIORITY <= CONFIG_KERNEL_INIT_PRIORITY_DEVICE
-#error "PWM init priority must be > KERNEL_INIT_PRIORITY_DEVICE"
-#endif
-SYS_INIT(init_pwms, PRE_KERNEL_1, CONFIG_PLATFORM_EC_PWM_INIT_PRIORITY);
-
-static struct pwm_config* pwm_lookup(enum pwm_channel ch)
-{
- __ASSERT(ch < ARRAY_SIZE(pwm_configs), "Invalid PWM channel %d", ch);
-
- return &pwm_configs[ch];
-}
-
-void pwm_enable(enum pwm_channel ch, int enabled)
-{
- struct pwm_config *pwm;
- uint32_t pulse_us;
- int rv;
-
- pwm = pwm_lookup(ch);
- pwm->enabled = enabled;
-
- /*
- * The Zephyr API doesn't provide explicit enable and disable
- * commands. However, setting the pulse width to zero disables
- * the PWM.
- */
- if (enabled)
- pulse_us = pwm->pulse_us;
- else
- pulse_us = 0;
-
- rv = pwm_pin_set_usec(pwm->dev, pwm->pin, pwm->period_us, pulse_us,
- pwm->flags);
-
- if (rv)
- LOG_ERR("pwm_pin_set_usec() failed %s (%d)", pwm->name, rv);
-}
-
-int pwm_get_enabled(enum pwm_channel ch)
-{
- struct pwm_config *pwm;
-
- pwm = pwm_lookup(ch);
- return pwm->enabled;
-}
-
-void pwm_set_raw_duty(enum pwm_channel ch, uint16_t duty)
-{
- struct pwm_config *pwm;
- int rv;
-
- pwm = pwm_lookup(ch);
-
- pwm->pulse_us =
- DIV_ROUND_NEAREST(pwm->period_us * duty, EC_PWM_MAX_DUTY);
-
- LOG_DBG("PWM %s set raw duty (0x%04x), pulse %d", pwm->name, duty,
- pwm->pulse_us);
-
- rv = pwm_pin_set_usec(pwm->dev, pwm->pin, pwm->period_us, pwm->pulse_us,
- pwm->flags);
-
- if (rv)
- LOG_ERR("pwm_pin_set_usec() failed %s (%d)", pwm->name, rv);
-}
-
-uint16_t pwm_get_raw_duty(enum pwm_channel ch)
-{
- struct pwm_config *pwm;
-
- pwm = pwm_lookup(ch);
-
- return DIV_ROUND_NEAREST(pwm->pulse_us * EC_PWM_MAX_DUTY,
- pwm->period_us);
-}
-
-void pwm_set_duty(enum pwm_channel ch, int percent)
-{
- struct pwm_config *pwm;
- int rv;
-
- pwm = pwm_lookup(ch);
-
- pwm->pulse_us = DIV_ROUND_NEAREST(pwm->period_us * percent, 100);
-
- LOG_DBG("PWM %s set percent (%d), pulse %d", pwm->name, percent,
- pwm->pulse_us);
-
- rv = pwm_pin_set_usec(pwm->dev, pwm->pin, pwm->period_us, pwm->pulse_us,
- pwm->flags);
-
- if (rv)
- LOG_ERR("pwm_pin_set_usec() failed %s (%d)", pwm->name, rv);
-}
-
-int pwm_get_duty(enum pwm_channel ch)
-{
- struct pwm_config *pwm;
-
- pwm = pwm_lookup(ch);
-
- return DIV_ROUND_NEAREST(pwm->pulse_us * 100, pwm->period_us);
-}
diff --git a/zephyr/shim/src/pwm_led.c b/zephyr/shim/src/pwm_led.c
deleted file mode 100644
index 48565d2e56..0000000000
--- a/zephyr/shim/src/pwm_led.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#define DT_DRV_COMPAT cros_ec_pwm_leds
-
-#include <string.h>
-#include <devicetree.h>
-
-#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
-
-#include "led_pwm.h"
-#include "pwm.h"
-
-BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(cros_ec_pwm_leds) <= 1,
- "Multiple CrOS EC PWM LED instances defined");
-BUILD_ASSERT(DT_INST_PROP_LEN(0, leds) <= 2,
- "Unsupported number of LEDs defined");
-
-#define PWM_CHANNEL_BY_IDX(node_id, prop, idx, led_ch) \
- PWM_CHANNEL(DT_PWMS_CTLR_BY_IDX( \
- DT_PHANDLE_BY_IDX(node_id, prop, idx), led_ch))
-
-#define PWM_LED_INIT(node_id, prop, idx) \
- [PWM_LED##idx] = { \
- .ch0 = PWM_CHANNEL_BY_IDX(node_id, prop, idx, 0), \
- .ch1 = PWM_CHANNEL_BY_IDX(node_id, prop, idx, 1), \
- .ch2 = PWM_CHANNEL_BY_IDX(node_id, prop, idx, 2), \
- .enable = &pwm_enable, \
- .set_duty = &pwm_set_duty, \
- },
-
-struct pwm_led pwm_leds[] = {
- DT_INST_FOREACH_PROP_ELEM(0, leds, PWM_LED_INIT)
-};
-
-struct pwm_led_color_map led_color_map[EC_LED_COLOR_COUNT] = {
- [EC_LED_COLOR_RED] = DT_INST_PROP(0, color_map_red),
- [EC_LED_COLOR_GREEN] = DT_INST_PROP(0, color_map_green),
- [EC_LED_COLOR_BLUE] = DT_INST_PROP(0, color_map_blue),
- [EC_LED_COLOR_YELLOW] = DT_INST_PROP(0, color_map_yellow),
- [EC_LED_COLOR_WHITE] = DT_INST_PROP(0, color_map_white),
- [EC_LED_COLOR_AMBER] = DT_INST_PROP(0, color_map_amber),
-};
-
-BUILD_ASSERT(DT_INST_PROP_LEN(0, brightness_range) == EC_LED_COLOR_COUNT,
- "brightness_range must have exactly EC_LED_COLOR_COUNT values");
-
-static const uint8_t dt_brigthness_range[EC_LED_COLOR_COUNT] = DT_INST_PROP(
- 0, brightness_range);
-
-void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range)
-{
- /* led_id is ignored, same ranges for all LEDs */
- memcpy(brightness_range, dt_brigthness_range,
- sizeof(dt_brigthness_range));
-}
-
-#endif /* DT_HAS_COMPAT_STATUS_OKAY */
diff --git a/zephyr/shim/src/rtc.c b/zephyr/shim/src/rtc.c
deleted file mode 100644
index 002e60148d..0000000000
--- a/zephyr/shim/src/rtc.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <logging/log.h>
-#include <kernel.h>
-#include <zephyr.h>
-
-#include "console.h"
-#include "drivers/cros_rtc.h"
-#include "hooks.h"
-#include "host_command.h"
-#include "util.h"
-
-LOG_MODULE_REGISTER(shim_cros_rtc, LOG_LEVEL_ERR);
-
-#define CROS_RTC_NODE DT_CHOSEN(cros_rtc)
-static const struct device *cros_rtc_dev;
-
-#ifdef CONFIG_HOSTCMD_EVENTS
-static void set_rtc_host_event(void)
-{
- host_set_single_event(EC_HOST_EVENT_RTC);
-}
-DECLARE_DEFERRED(set_rtc_host_event);
-#endif
-
-void rtc_callback(const struct device *dev)
-{
- ARG_UNUSED(dev);
-
- if (IS_ENABLED(CONFIG_HOSTCMD_EVENTS)) {
- hook_call_deferred(&set_rtc_host_event_data, 0);
- }
-}
-
-/** Initialize the rtc. */
-static int system_init_rtc(const struct device *unused)
-{
- ARG_UNUSED(unused);
-
- cros_rtc_dev = DEVICE_DT_GET(CROS_RTC_NODE);
- if (!cros_rtc_dev) {
- LOG_ERR("Error: device %s is not ready", cros_rtc_dev->name);
- return -ENODEV;
- }
-
- /* set the RTC callback */
- cros_rtc_configure(cros_rtc_dev, rtc_callback);
-
- return 0;
-}
-SYS_INIT(system_init_rtc, APPLICATION, 1);
-
-uint32_t system_get_rtc_sec(void)
-{
- uint32_t seconds;
-
- cros_rtc_get_value(cros_rtc_dev, &seconds);
-
- return seconds;
-}
-
-void system_set_rtc(uint32_t seconds)
-{
- cros_rtc_set_value(cros_rtc_dev, seconds);
-}
-
-void system_reset_rtc_alarm(void)
-{
- if (!cros_rtc_dev) {
- /* TODO(b/183115086): check the error handler for NULL device */
- LOG_ERR("rtc_dev hasn't initialized.");
- return;
- }
-
- cros_rtc_reset_alarm(cros_rtc_dev);
-}
-
-/*
- * For NPCX series, The alarm counter only stores wakeup time in seconds.
- * Microseconds will be ignored.
- */
-void system_set_rtc_alarm(uint32_t seconds, uint32_t microseconds)
-{
- if (!cros_rtc_dev) {
- LOG_ERR("rtc_dev hasn't initialized.");
- return;
- }
-
- /* If time = 0, clear the current alarm */
- if (seconds == EC_RTC_ALARM_CLEAR && microseconds == 0) {
- system_reset_rtc_alarm();
- return;
- }
-
- seconds += system_get_rtc_sec();
-
- cros_rtc_set_alarm(cros_rtc_dev, seconds, microseconds);
-}
-
-/*
- * Return the seconds remaining before the RTC alarm goes off.
- * Returns 0 if alarm is not set.
- */
-uint32_t system_get_rtc_alarm(void)
-{
- uint32_t seconds, microseconds;
-
- cros_rtc_get_alarm(cros_rtc_dev, &seconds, &microseconds);
-
- /*
- * Return 0:
- * 1. If alarm is not set to go off, OR
- * 2. If alarm is set and has already gone off
- */
- if (seconds == 0) {
- return 0;
- }
-
- return seconds - system_get_rtc_sec();
-}
-
-/* Console commands */
-void print_system_rtc(enum console_channel ch)
-{
- uint32_t sec = system_get_rtc_sec();
-
- cprintf(ch, "RTC: 0x%08x (%d.00 s)\n", sec, sec);
-}
-
-/*
- * TODO(b/179055201): This is similar to the same function in some of the
- * chip-specific code. We should factor out the common parts.
- */
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC
-static int command_system_rtc(int argc, char **argv)
-{
- if (argc == 3 && !strcasecmp(argv[1], "set")) {
- char *e;
- unsigned int t = strtoi(argv[2], &e, 0);
-
- if (*e)
- return EC_ERROR_PARAM2;
-
- system_set_rtc(t);
- } else if (argc > 1) {
- return EC_ERROR_INVAL;
- }
-
- print_system_rtc(CC_COMMAND);
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(rtc, command_system_rtc, "[set <seconds>]",
- "Get/set real-time clock");
-
-#ifdef CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC_ALARM
-/**
- * Test the RTC alarm by setting an interrupt on RTC match.
- */
-static int command_rtc_alarm_test(int argc, char **argv)
-{
- int s = 1, us = 0;
- char *e;
-
- if (argc > 1) {
- s = strtoi(argv[1], &e, 10);
- if (*e)
- return EC_ERROR_PARAM1;
- }
- if (argc > 2) {
- us = strtoi(argv[2], &e, 10);
- if (*e)
- return EC_ERROR_PARAM2;
- }
-
- ccprintf("Setting RTC alarm\n");
-
- system_set_rtc_alarm(s, us);
-
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(rtc_alarm, command_rtc_alarm_test,
- "[seconds [microseconds]]", "Test alarm");
-#endif /* CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC_ALARM */
-#endif /* CONFIG_PLATFORM_EC_CONSOLE_CMD_RTC */
-
-#ifdef CONFIG_PLATFORM_EC_HOSTCMD_RTC
-static enum ec_status system_rtc_get_value(struct host_cmd_handler_args *args)
-{
- struct ec_response_rtc *r = args->response;
-
- r->time = system_get_rtc_sec();
- args->response_size = sizeof(*r);
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_RTC_GET_VALUE, system_rtc_get_value,
- EC_VER_MASK(0));
-
-static enum ec_status system_rtc_set_value(struct host_cmd_handler_args *args)
-{
- const struct ec_params_rtc *p = args->params;
-
- system_set_rtc(p->time);
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_RTC_SET_VALUE, system_rtc_set_value,
- EC_VER_MASK(0));
-
-static enum ec_status system_rtc_set_alarm(struct host_cmd_handler_args *args)
-{
- const struct ec_params_rtc *p = args->params;
-
- system_set_rtc_alarm(p->time, 0);
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_RTC_SET_ALARM, system_rtc_set_alarm,
- EC_VER_MASK(0));
-
-static enum ec_status system_rtc_get_alarm(struct host_cmd_handler_args *args)
-{
- struct ec_response_rtc *r = args->response;
-
- r->time = system_get_rtc_alarm();
- args->response_size = sizeof(*r);
-
- return EC_RES_SUCCESS;
-}
-DECLARE_HOST_COMMAND(EC_CMD_RTC_GET_ALARM, system_rtc_get_alarm,
- EC_VER_MASK(0));
-
-#endif /* CONFIG_PLATFORM_EC_HOSTCMD_RTC */
diff --git a/zephyr/shim/src/switchcap_gpio.c b/zephyr/shim/src/switchcap_gpio.c
deleted file mode 100644
index c635978b8b..0000000000
--- a/zephyr/shim/src/switchcap_gpio.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <devicetree.h>
-#include "common.h"
-#include "gpio.h"
-
-#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_PHANDLE \
- DT_PHANDLE_BY_IDX(DT_PATH(switchcap), enable_pin, 0)
-#define SC_PIN_ENABLE \
- GPIO_SIGNAL(SC_PIN_ENABLE_PHANDLE)
-
-#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_SIGNAL(SC_PIN_POWER_GOOD_PHANDLE)
-
-void board_set_switchcap_power(int enable)
-{
- gpio_set_level(SC_PIN_ENABLE, enable);
-}
-
-int board_is_switchcap_enabled(void)
-{
- return gpio_get_level(SC_PIN_ENABLE);
-}
-
-int board_is_switchcap_power_good(void)
-{
-#if SC_PIN_POWER_GOOD_EXISTS
- return gpio_get_level(SC_PIN_POWER_GOOD);
-#else
- return 1;
-#endif
-}
-
-#endif
diff --git a/zephyr/shim/src/switchcap_ln9310.c b/zephyr/shim/src/switchcap_ln9310.c
deleted file mode 100644
index 0647c2d9ae..0000000000
--- a/zephyr/shim/src/switchcap_ln9310.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <devicetree.h>
-#include "common.h"
-#include "gpio.h"
-#include "ln9310.h"
-
-#if DT_NODE_EXISTS(DT_PATH(switchcap))
-
-#if !DT_NODE_HAS_COMPAT(DT_PATH(switchcap), switchcap_ln9310)
-#error "Invalid /switchcap node in device tree"
-#endif
-
-#define SC_PIN_ENABLE_L_PHANDLE \
- DT_PHANDLE_BY_IDX(DT_PATH(switchcap), enable_l_pin, 0)
-#define SC_PIN_ENABLE_L \
- GPIO_SIGNAL(SC_PIN_ENABLE_L_PHANDLE)
-
-#define SC_PORT_PHANDLE \
- DT_PHANDLE(DT_PATH(switchcap), port)
-#define SC_PORT DT_STRING_UPPER_TOKEN(SC_PORT_PHANDLE, enum_name)
-
-#define SC_ADDR_FLAGS DT_STRING_UPPER_TOKEN(DT_PATH(switchcap), addr_flags)
-
-void board_set_switchcap_power(int enable)
-{
- gpio_set_level(SC_PIN_ENABLE_L, !enable);
- ln9310_software_enable(enable);
-}
-
-int board_is_switchcap_enabled(void)
-{
- return !gpio_get_level(SC_PIN_ENABLE_L);
-}
-
-int board_is_switchcap_power_good(void)
-{
- return ln9310_power_good();
-}
-
-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
deleted file mode 100644
index 8db8ba437a..0000000000
--- a/zephyr/shim/src/system.c
+++ /dev/null
@@ -1,378 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <device.h>
-#include <drivers/bbram.h>
-#include <drivers/cros_system.h>
-#include <logging/log.h>
-
-#include "bbram.h"
-#include "common.h"
-#include "console.h"
-#include "cros_version.h"
-#include "system.h"
-#include "watchdog.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)
-#define BBRAM_REGION_TRY_SLOT DT_PATH(named_bbram_regions, try_slot)
-
-#define GET_BBRAM_OFFSET(node) \
- DT_PROP(DT_PATH(named_bbram_regions, node), offset)
-#define GET_BBRAM_SIZE(node) DT_PROP(DT_PATH(named_bbram_regions, node), size)
-
-/* 2 second delay for waiting the H1 reset */
-#define WAIT_RESET_TIME \
- (CONFIG_PLATFORM_EC_PREINIT_HW_CYCLES_PER_SEC * 2 / \
- CONFIG_PLATFORM_EC_WAIT_RESET_CYCLES_PER_ITERATION)
-
-LOG_MODULE_REGISTER(shim_system, LOG_LEVEL_ERR);
-
-STATIC_IF_NOT(CONFIG_ZTEST) const struct device *bbram_dev;
-static const struct device *sys_dev;
-
-/* Map idx to a bbram offset/size, or return -1 on invalid idx */
-static int bbram_lookup(enum system_bbram_idx idx, int *offset_out,
- int *size_out)
-{
- switch (idx) {
- case SYSTEM_BBRAM_IDX_PD0:
- *offset_out = DT_PROP(BBRAM_REGION_PD0, offset);
- *size_out = DT_PROP(BBRAM_REGION_PD0, size);
- break;
- case SYSTEM_BBRAM_IDX_PD1:
- *offset_out = DT_PROP(BBRAM_REGION_PD1, offset);
- *size_out = DT_PROP(BBRAM_REGION_PD1, size);
- break;
- case SYSTEM_BBRAM_IDX_PD2:
- *offset_out = DT_PROP(BBRAM_REGION_PD2, offset);
- *size_out = DT_PROP(BBRAM_REGION_PD2, size);
- break;
- case SYSTEM_BBRAM_IDX_TRY_SLOT:
- *offset_out = DT_PROP(BBRAM_REGION_TRY_SLOT, offset);
- *size_out = DT_PROP(BBRAM_REGION_TRY_SLOT, size);
- break;
- default:
- return EC_ERROR_INVAL;
- }
- return EC_SUCCESS;
-}
-
-int system_get_bbram(enum system_bbram_idx idx, uint8_t *value)
-{
- int offset, size, rc;
-
- if (bbram_dev == NULL)
- return EC_ERROR_INVAL;
-
- rc = bbram_lookup(idx, &offset, &size);
- if (rc)
- return rc;
-
- rc = bbram_read(bbram_dev, offset, size, value);
-
- return rc ? EC_ERROR_INVAL : EC_SUCCESS;
-}
-
-void chip_save_reset_flags(uint32_t flags)
-{
- if (bbram_dev == NULL) {
- LOG_ERR("bbram_dev doesn't binding");
- return;
- }
-
- bbram_write(bbram_dev, GET_BBRAM_OFFSET(saved_reset_flags),
- GET_BBRAM_SIZE(saved_reset_flags), (uint8_t *)&flags);
-}
-
-uint32_t chip_read_reset_flags(void)
-{
- uint32_t flags;
-
- if (bbram_dev == NULL) {
- LOG_ERR("bbram_dev doesn't binding");
- return 0;
- }
-
- bbram_read(bbram_dev, GET_BBRAM_OFFSET(saved_reset_flags),
- GET_BBRAM_SIZE(saved_reset_flags), (uint8_t *)&flags);
-
- return flags;
-}
-
-int system_set_scratchpad(uint32_t value)
-{
- if (bbram_dev == NULL) {
- LOG_ERR("bbram_dev doesn't binding");
- return -EC_ERROR_INVAL;
- }
-
- return bbram_write(bbram_dev, GET_BBRAM_OFFSET(scratchpad),
- GET_BBRAM_SIZE(scratchpad), (uint8_t *)&value);
-}
-
-int system_get_scratchpad(uint32_t *value)
-{
- if (bbram_dev == NULL) {
- LOG_ERR("bbram_dev doesn't binding");
- return -EC_ERROR_INVAL;
- }
-
- if (bbram_read(bbram_dev, GET_BBRAM_OFFSET(scratchpad),
- GET_BBRAM_SIZE(scratchpad), (uint8_t *)value)) {
- return -EC_ERROR_INVAL;
- }
-
- return 0;
-}
-
-void system_hibernate(uint32_t seconds, uint32_t microseconds)
-{
- const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
- int err;
-
- /* Flush console before hibernating */
- cflush();
-
- if (board_hibernate)
- board_hibernate();
-
- /* Save 'wake-up from hibernate' reset flag */
- chip_save_reset_flags(chip_read_reset_flags() |
- EC_RESET_FLAG_HIBERNATE);
-
- err = cros_system_hibernate(sys_dev, seconds, microseconds);
- if (err < 0) {
- LOG_ERR("hibernate failed %d", err);
- return;
- }
-
- /* should never reach this point */
- while (1)
- continue;
-}
-
-#ifdef CONFIG_PM
-/**
- * Print low power idle statistics
- */
-static int command_idle_stats(int argc, char **argv)
-{
- const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
-
- timestamp_t ts = get_time();
- uint64_t deep_sleep_ticks = cros_system_deep_sleep_ticks(sys_dev);
-
- ccprintf("Time spent in deep-sleep: %.6llds\n",
- k_ticks_to_us_near64(deep_sleep_ticks));
- ccprintf("Total time on: %.6llds\n", ts.val);
- return EC_SUCCESS;
-}
-DECLARE_CONSOLE_COMMAND(idlestats, command_idle_stats,
- "",
- "Print last idle stats");
-#endif
-
-const char *system_get_chip_vendor(void)
-{
- const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
-
- return cros_system_chip_vendor(sys_dev);
-}
-
-const char *system_get_chip_name(void)
-{
- const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
-
- return cros_system_chip_name(sys_dev);
-}
-
-const char *system_get_chip_revision(void)
-{
- const struct device *sys_dev = device_get_binding("CROS_SYSTEM");
-
- return cros_system_chip_revision(sys_dev);
-}
-
-void system_reset(int flags)
-{
- int err;
- uint32_t save_flags;
-
- if (!sys_dev)
- LOG_ERR("sys_dev get binding failed");
-
- /* Disable interrupts to avoid task swaps during reboot */
- interrupt_disable_all();
-
- /* Get flags to be saved in BBRAM */
- system_encode_save_flags(flags, &save_flags);
-
- /* Store flags to battery backed RAM. */
- chip_save_reset_flags(save_flags);
-
- /* If WAIT_EXT is set, then allow 10 seconds for external reset */
- if (flags & SYSTEM_RESET_WAIT_EXT) {
- int i;
-
- /* Wait 10 seconds for external reset */
- for (i = 0; i < 1000; i++) {
- watchdog_reload();
- udelay(10000);
- }
- }
-
- err = cros_system_soc_reset(sys_dev);
-
- if (err < 0)
- LOG_ERR("soc reset failed");
-
- /* should never return */
- while (1)
- continue;
-}
-
-static int check_reset_cause(void)
-{
- uint32_t chip_flags = 0; /* used to write back to the BBRAM */
- uint32_t system_flags = chip_read_reset_flags(); /* system reset flag */
- int chip_reset_cause = 0; /* chip-level reset cause */
-
- chip_reset_cause = cros_system_get_reset_cause(sys_dev);
- if (chip_reset_cause < 0)
- return -1;
-
- /*
- * TODO(b/182876692): Implement CONFIG_POWER_BUTTON_INIT_IDLE &
- * CONFIG_BOARD_FORCE_RESET_PIN.
- */
-
- switch (chip_reset_cause) {
- case POWERUP:
- system_flags |= EC_RESET_FLAG_POWER_ON;
- /*
- * Power-on restart, so set a flag and save it for the next
- * imminent reset. Later code will check for this flag and wait
- * for the second reset. Waking from PSL hibernate is power-on
- * for EC but not for H1, so do not wait for the second reset.
- */
- if (IS_ENABLED(CONFIG_BOARD_RESET_AFTER_POWER_ON) &&
- ((system_flags & EC_RESET_FLAG_HIBERNATE) == 0)) {
- system_flags |= EC_RESET_FLAG_INITIAL_PWR;
- chip_flags |= EC_RESET_FLAG_INITIAL_PWR;
- }
- break;
-
- case VCC1_RST_PIN:
- /*
- * If configured, check the saved flags to see whether the
- * previous restart was a power-on, in which case treat this
- * restart as a power-on as well. This is to workaround the fact
- * that the H1 will reset the EC at power up.
- */
- if (IS_ENABLED(CONFIG_BOARD_RESET_AFTER_POWER_ON)) {
- if (system_flags & EC_RESET_FLAG_INITIAL_PWR) {
- /*
- * The previous restart was a power-on so treat
- * this restart as that, and clear the flag so
- * later code will not wait for the second
- * reset.
- */
- system_flags = (system_flags &
- ~EC_RESET_FLAG_INITIAL_PWR) |
- EC_RESET_FLAG_POWER_ON;
- } else {
- /*
- * No previous reset flag, so this is a
- * subsequent restart i.e any restarts after the
- * second restart caused by the H1.
- */
- system_flags |= EC_RESET_FLAG_RESET_PIN;
- }
- } else {
- system_flags |= EC_RESET_FLAG_RESET_PIN;
- }
- break;
-
- case DEBUG_RST:
- system_flags |= EC_RESET_FLAG_SOFT;
- break;
-
- case WATCHDOG_RST:
- /*
- * Don't set EC_RESET_FLAG_WATCHDOG flag if watchdog is issued
- * by system_reset or hibernate in order to distinguish reset
- * cause is panic reason or not.
- */
- if (!(system_flags & (EC_RESET_FLAG_SOFT | EC_RESET_FLAG_HARD |
- EC_RESET_FLAG_HIBERNATE)))
- system_flags |= EC_RESET_FLAG_WATCHDOG;
- break;
- }
-
- /* Clear & set the reset flags for the following reset. */
- chip_save_reset_flags(chip_flags);
-
- /* Set the system reset flags. */
- system_set_reset_flags(system_flags);
-
- return 0;
-}
-
-static int system_preinitialize(const struct device *unused)
-{
- ARG_UNUSED(unused);
-
-#if DT_NODE_EXISTS(DT_NODELABEL(bbram))
- bbram_dev = DEVICE_DT_GET(DT_NODELABEL(bbram));
- if (!device_is_ready(bbram_dev)) {
- LOG_ERR("Error: device %s is not ready", bbram_dev->name);
- return -1;
- }
-#endif
-
- sys_dev = device_get_binding("CROS_SYSTEM");
- if (!sys_dev) {
- /*
- * TODO(b/183022804): This should not happen in normal
- * operation. Check whether the error check can be change to
- * build-time error, or at least a fatal run-time error.
- */
- LOG_ERR("sys_dev gets binding failed");
- return -1;
- }
-
- /* check the reset cause */
- if (check_reset_cause() != 0) {
- LOG_ERR("check the reset cause failed");
- return -1;
- }
-
- /*
- * For some boards on power-on, the EC is reset by the H1 after
- * power-on, so the EC sees 2 resets. This config enables the EC to save
- * a flag on the first power-up restart, and then wait for the second
- * reset before any other setup is done (such as GPIOs, timers, UART
- * etc.) On the second reset, the saved flag is used to detect the
- * previous power-on, and treat the second reset as a power-on instead
- * of a reset.
- */
-#ifdef CONFIG_BOARD_RESET_AFTER_POWER_ON
- if (system_get_reset_flags() & EC_RESET_FLAG_INITIAL_PWR) {
- /*
- * The current initial stage couldn't use the kernel delay
- * function. Use CPU nop instruction to wait for the external
- * reset from H1.
- */
- for (uint32_t i = WAIT_RESET_TIME; i; i--)
- arch_nop();
- }
-#endif
- return 0;
-}
-
-SYS_INIT(system_preinitialize, PRE_KERNEL_1,
- CONFIG_PLATFORM_EC_SYSTEM_PRE_INIT_PRIORITY);
diff --git a/zephyr/shim/src/tasks.c b/zephyr/shim/src/tasks.c
deleted file mode 100644
index 2f1fec16d6..0000000000
--- a/zephyr/shim/src/tasks.c
+++ /dev/null
@@ -1,353 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <kernel.h>
-#include <init.h>
-#include <sys/atomic.h>
-#include <shell/shell.h>
-
-#include "common.h"
-#include "timer.h"
-#include "task.h"
-
-/* We need to ensure that is one lower priority for the deferred task */
-BUILD_ASSERT(CONFIG_NUM_PREEMPT_PRIORITIES + 1 >= TASK_ID_COUNT,
- "Must increase number of available preempt priorities");
-
-/* Declare all task stacks here */
-#define CROS_EC_TASK(name, e, p, size) \
- K_THREAD_STACK_DEFINE(name##_STACK, size);
-#define TASK_TEST(name, e, p, size) CROS_EC_TASK(name, e, p, size)
-CROS_EC_TASK_LIST
-#undef CROS_EC_TASK
-#undef TASK_TEST
-
-/* Forward declare all task entry point functions */
-#define CROS_EC_TASK(name, entry, ...) void entry(void *p);
-#define TASK_TEST(name, entry, ...) CROS_EC_TASK(name, entry)
-CROS_EC_TASK_LIST
-#undef CROS_EC_TASK
-#undef TASK_TEST
-
-/** Context for each CROS EC task that is run in its own zephyr thread */
-struct task_ctx {
-#ifdef CONFIG_THREAD_NAME
- /** Name of thread (for debugging) */
- const char *name;
-#endif
- /** Zephyr thread structure that hosts EC tasks */
- struct k_thread zephyr_thread;
- /** Zephyr thread id for above thread */
- k_tid_t zephyr_tid;
- /** Address of Zephyr thread's stack */
- k_thread_stack_t *stack;
- /** Usabled size in bytes of above thread stack */
- size_t stack_size;
- /** Task (platform/ec) entry point */
- void (*entry)(void *p);
- /** The parameter that is passed into the task entry point */
- intptr_t parameter;
- /** A wait-able event that is raised when a new task event is posted */
- struct k_poll_signal new_event;
- /** The current platform/ec events set for this task/thread */
- uint32_t event_mask;
- /**
- * The timer associated with this task, which can be set using
- * timer_arm().
- */
- struct k_timer timer;
-};
-
-#ifdef CONFIG_THREAD_NAME
-#define CROS_EC_TASK(_name, _entry, _parameter, _size) \
- { \
- .entry = _entry, \
- .parameter = _parameter, \
- .stack = _name##_STACK, \
- .stack_size = _size, \
- .name = #_name, \
- },
-#else
-#define CROS_EC_TASK(_name, _entry, _parameter, _size) \
- { \
- .entry = _entry, \
- .parameter = _parameter, \
- .stack = _name##_STACK, \
- .stack_size = _size, \
- },
-#endif /* CONFIG_THREAD_NAME */
-#define TASK_TEST(_name, _entry, _parameter, _size) \
- CROS_EC_TASK(_name, _entry, _parameter, _size)
-static struct task_ctx shimmed_tasks[] = {
- CROS_EC_TASK_LIST
-#ifdef TEST_BUILD
- [TASK_ID_TEST_RUNNER] = {},
-#endif
-};
-static int tasks_started;
-#undef CROS_EC_TASK
-#undef TASK_TEST
-
-task_id_t task_get_current(void)
-{
- for (size_t i = 0; i < ARRAY_SIZE(shimmed_tasks); ++i) {
- if (shimmed_tasks[i].zephyr_tid == k_current_get()) {
- return i;
- }
- }
-
-#if defined(HAS_TASK_HOOKS)
- /* Hooks ID should be returned for deferred calls */
- if (k_current_get() == &k_sys_work_q.thread) {
- return TASK_ID_HOOKS;
- }
-#endif /* HAS_TASK_HOOKS */
-
- __ASSERT(false, "Task index out of bound");
- return 0;
-}
-
-uint32_t *task_get_event_bitmap(task_id_t cros_task_id)
-{
- struct task_ctx *const ctx = &shimmed_tasks[cros_task_id];
-
- return &ctx->event_mask;
-}
-
-uint32_t task_set_event(task_id_t cros_task_id, uint32_t event)
-{
- struct task_ctx *const ctx = &shimmed_tasks[cros_task_id];
-
- atomic_or(&ctx->event_mask, event);
- k_poll_signal_raise(&ctx->new_event, 0);
-
- return 0;
-}
-
-uint32_t task_wait_event(int timeout_us)
-{
- struct task_ctx *const ctx = &shimmed_tasks[task_get_current()];
- const k_timeout_t timeout = (timeout_us == -1) ? K_FOREVER :
- K_USEC(timeout_us);
- const int64_t tick_deadline =
- k_uptime_ticks() + k_us_to_ticks_near64(timeout_us);
-
- struct k_poll_event poll_events[1] = {
- K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL,
- K_POLL_MODE_NOTIFY_ONLY,
- &ctx->new_event),
- };
-
- /* Wait for signal, then clear it before reading events */
- const int rv = k_poll(poll_events, ARRAY_SIZE(poll_events), timeout);
-
- k_poll_signal_reset(&ctx->new_event);
- uint32_t events = atomic_set(&ctx->event_mask, 0);
-
- if (rv == -EAGAIN) {
- events |= TASK_EVENT_TIMER;
- }
-
- /* If we didn't get an event, we need to wait again. There is a very
- * small change of us reading the event_mask one signaled event too
- * early. In that case, just wait again for the remaining timeout
- */
- if (events == 0) {
- const int64_t ticks_left = tick_deadline - k_uptime_ticks();
-
- if (ticks_left > 0) {
- return task_wait_event(
- k_ticks_to_us_near64(ticks_left));
- }
-
- events |= TASK_EVENT_TIMER;
- }
-
- return events;
-}
-
-uint32_t task_wait_event_mask(uint32_t event_mask, int timeout_us)
-{
- struct task_ctx *const ctx = &shimmed_tasks[task_get_current()];
- uint32_t events = 0;
- const int64_t tick_deadline =
- k_uptime_ticks() + k_us_to_ticks_near64(timeout_us);
-
- /* Need to return timeout flags if it occurs as well */
- event_mask |= TASK_EVENT_TIMER;
-
- while (!(event_mask & events)) {
- const int64_t ticks_left = tick_deadline - k_uptime_ticks();
-
- if (timeout_us != -1 && ticks_left <= 0) {
- events |= TASK_EVENT_TIMER;
- break;
- }
-
- struct k_poll_event poll_events[1] = {
- K_POLL_EVENT_INITIALIZER(K_POLL_TYPE_SIGNAL,
- K_POLL_MODE_NOTIFY_ONLY,
- &ctx->new_event),
- };
-
- /* Ensure to honor the -1 timeout as FOREVER */
- k_poll(poll_events, ARRAY_SIZE(poll_events),
- timeout_us == -1 ? K_FOREVER : K_TICKS(ticks_left));
- k_poll_signal_reset(&ctx->new_event);
- events |= atomic_set(&ctx->event_mask, 0);
- }
-
- /* Replace any events that weren't in the mask */
- if (events & ~event_mask) {
- atomic_or(&ctx->event_mask, events & ~event_mask);
- k_poll_signal_raise(&ctx->new_event, 0);
- }
-
- return events & event_mask;
-}
-
-static void task_entry(void *task_contex, void *unused1, void *unused2)
-{
- ARG_UNUSED(unused1);
- ARG_UNUSED(unused2);
-
- struct task_ctx *const ctx = (struct task_ctx *)task_contex;
-
-#ifdef CONFIG_THREAD_NAME
- /* Name thread for debugging */
- k_thread_name_set(ctx->zephyr_tid, ctx->name);
-#endif
-
- /* Call into task entry point */
- ctx->entry((void *)ctx->parameter);
-}
-
-/*
- * Callback function to use with k_timer_start to set the
- * TASK_EVENT_TIMER event on a task.
- */
-static void timer_expire(struct k_timer *timer_id)
-{
- struct task_ctx *const ctx =
- CONTAINER_OF(timer_id, struct task_ctx, timer);
- task_id_t cros_ec_task_id = ctx - shimmed_tasks;
-
- task_set_event(cros_ec_task_id, TASK_EVENT_TIMER);
-}
-
-int timer_arm(timestamp_t event, task_id_t cros_ec_task_id)
-{
- timestamp_t now = get_time();
- struct task_ctx *const ctx = &shimmed_tasks[cros_ec_task_id];
-
- if (event.val <= now.val) {
- /* Timer requested for now or in the past, fire right away */
- task_set_event(cros_ec_task_id, TASK_EVENT_TIMER);
- return EC_SUCCESS;
- }
-
- /* Check for a running timer */
- if (k_timer_remaining_get(&ctx->timer))
- return EC_ERROR_BUSY;
-
- k_timer_start(&ctx->timer, K_USEC(event.val - now.val), K_NO_WAIT);
- return EC_SUCCESS;
-}
-
-void timer_cancel(task_id_t cros_ec_task_id)
-{
- struct task_ctx *const ctx = &shimmed_tasks[cros_ec_task_id];
-
- k_timer_stop(&ctx->timer);
-}
-
-#ifdef TEST_BUILD
-void set_test_runner_tid(void)
-{
- shimmed_tasks[TASK_ID_TEST_RUNNER].zephyr_tid = k_current_get();
-}
-#endif
-
-void start_ec_tasks(void)
-{
- for (size_t i = 0; i < ARRAY_SIZE(shimmed_tasks); ++i) {
- struct task_ctx *const ctx = &shimmed_tasks[i];
-
- k_timer_init(&ctx->timer, timer_expire, NULL);
-
-#ifdef TEST_BUILD
- /* Do not create thread for test runner; it will be set later */
- if (i == TASK_ID_TEST_RUNNER) {
- ctx->zephyr_tid = NULL;
- continue;
- }
-#endif
- /*
- * TODO(b/172361873): Add K_FP_REGS for FPU tasks. See
- * comment in config.h for CONFIG_TASK_LIST for existing flags
- * implementation.
- */
- ctx->zephyr_tid = k_thread_create(
- &ctx->zephyr_thread, ctx->stack, ctx->stack_size,
- task_entry, ctx, NULL, NULL,
- K_PRIO_PREEMPT(TASK_ID_COUNT - i - 1), 0, K_NO_WAIT);
- }
- tasks_started = 1;
-}
-
-/*
- * Initialize all of the kernel objects before application code starts.
- * This allows us to set events on tasks before they even start, e.g. in
- * INIT_HOOKS.
- */
-int init_signals(const struct device *unused)
-{
- ARG_UNUSED(unused);
-
- for (size_t i = 0; i < ARRAY_SIZE(shimmed_tasks); ++i) {
- struct task_ctx *const ctx = &shimmed_tasks[i];
-
- /* Initialize the new_event structure */
- k_poll_signal_init(&ctx->new_event);
- }
-
- return 0;
-}
-SYS_INIT(init_signals, POST_KERNEL, 50);
-
-int task_start_called(void)
-{
- return tasks_started;
-}
-
-void task_disable_task(task_id_t tskid)
-{
- /* TODO(b/190203712): Implement this */
-}
-
-void task_clear_pending_irq(int irq)
-{
-#if CONFIG_ITE_IT8XXX2_INTC
- ite_intc_isr_clear(irq);
-#endif
-}
-
-void task_enable_irq(int irq)
-{
- arch_irq_enable(irq);
-}
-
-inline int in_interrupt_context(void)
-{
- return k_is_in_isr();
-}
-
-#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/temp_sensors.c b/zephyr/shim/src/temp_sensors.c
deleted file mode 100644
index 4d8be4fa42..0000000000
--- a/zephyr/shim/src/temp_sensors.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "temp_sensor.h"
-#include "temp_sensor/temp_sensor.h"
-#include "adc.h"
-#include "temp_sensor/thermistor.h"
-
-#if DT_NODE_EXISTS(DT_PATH(named_temp_sensors))
-static int thermistor_get_temp(const struct temp_sensor_t *sensor,
- int *temp_ptr)
-{
- return thermistor_get_temperature(sensor->idx, temp_ptr,
- sensor->thermistor);
-}
-
-#define GET_THERMISTOR_DATUM(node_sample_id) \
- [DT_PROP(node_sample_id, \
- sample_index)] = { .mv = DT_PROP(node_sample_id, milivolt), \
- .temp = DT_PROP(node_sample_id, temp) },
-
-#define DEFINE_THERMISTOR_DATA(node_id) \
- static const struct thermistor_data_pair DT_CAT( \
- node_id, _thermistor_data)[] = { \
- DT_FOREACH_CHILD(node_id, GET_THERMISTOR_DATUM) \
- };
-
-#define GET_THERMISTOR_INFO(node_id) \
- (&(struct thermistor_info){ \
- .scaling_factor = DT_PROP(node_id, scaling_factor), \
- .num_pairs = DT_PROP(node_id, num_pairs), \
- .data = DT_CAT(node_id, _thermistor_data), \
- })
-
-#define TEMP_THERMISTOR(node_id) \
- [ZSHIM_TEMP_SENSOR_ID(node_id)] = { \
- .name = DT_LABEL(node_id), \
- .read = &thermistor_get_temp, \
- .idx = ZSHIM_ADC_ID(DT_PHANDLE(node_id, adc)), \
- .type = TEMP_SENSOR_TYPE_BOARD, \
- .thermistor = \
- GET_THERMISTOR_INFO(DT_PHANDLE(node_id, thermistor)), \
- },
-
-DT_FOREACH_STATUS_OKAY(cros_ec_thermistor, DEFINE_THERMISTOR_DATA)
-
-const struct temp_sensor_t temp_sensors[] = {
- DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor, TEMP_THERMISTOR)
-};
-#endif /* named_temp_sensors */
diff --git a/zephyr/shim/src/test_util.c b/zephyr/shim/src/test_util.c
deleted file mode 100644
index 28be596043..0000000000
--- a/zephyr/shim/src/test_util.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright 2020 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.
- *
- * Test utilities.
- */
-
-#include "test_util.h"
-
-/* Linear congruential pseudo random number generator */
-uint32_t prng(uint32_t seed)
-{
- return 22695477 * seed + 1;
-}
-
-uint32_t prng_no_seed(void)
-{
- static uint32_t seed = 0x1234abcd;
- return seed = prng(seed);
-}
diff --git a/zephyr/shim/src/thermal.c b/zephyr/shim/src/thermal.c
deleted file mode 100644
index c31e2bfcc6..0000000000
--- a/zephyr/shim/src/thermal.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "temp_sensor.h"
-#include "temp_sensor/temp_sensor.h"
-#include "ec_commands.h"
-
-#define THERMAL_CONFIG(node_id) \
- [ZSHIM_TEMP_SENSOR_ID(node_id)] = { \
- .temp_host = { \
- [EC_TEMP_THRESH_WARN] = \
- C_TO_K(DT_PROP_OR(node_id, \
- temp_host_warn, \
- -273)), \
- [EC_TEMP_THRESH_HIGH] = \
- C_TO_K(DT_PROP_OR(node_id, \
- temp_host_high, \
- -273)), \
- [EC_TEMP_THRESH_HALT] = \
- C_TO_K(DT_PROP_OR(node_id, \
- temp_host_halt, \
- -273)), \
- }, \
- .temp_host_release = { \
- [EC_TEMP_THRESH_WARN] = C_TO_K( \
- DT_PROP_OR(node_id, \
- temp_host_release_warn, \
- -273)), \
- [EC_TEMP_THRESH_HIGH] = C_TO_K( \
- DT_PROP_OR(node_id, \
- temp_host_release_high, \
- -273)), \
- [EC_TEMP_THRESH_HALT] = C_TO_K( \
- DT_PROP_OR(node_id, \
- temp_host_release_halt, \
- -273)), \
- }, \
- .temp_fan_off = C_TO_K(DT_PROP_OR(node_id, \
- temp_fan_off, \
- -273)), \
- .temp_fan_max = C_TO_K(DT_PROP_OR(node_id, \
- temp_fan_max, \
- -273)), \
- },
-
-struct ec_thermal_config thermal_params[] = {
-#if DT_NODE_EXISTS(DT_PATH(named_temp_sensors))
- DT_FOREACH_CHILD(DT_PATH(named_temp_sensors), THERMAL_CONFIG)
-#endif /* named_temp_sensors */
-};
diff --git a/zephyr/shim/src/watchdog.c b/zephyr/shim/src/watchdog.c
deleted file mode 100644
index 4c78ac9b0f..0000000000
--- a/zephyr/shim/src/watchdog.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <device.h>
-#include <drivers/watchdog.h>
-#include <logging/log.h>
-#include <zephyr.h>
-
-#include "config.h"
-#include "hooks.h"
-#include "watchdog.h"
-
-LOG_MODULE_REGISTER(watchdog_shim, LOG_LEVEL_ERR);
-
-static void wdt_warning_handler(const struct device *wdt_dev, int channel_id)
-{
- /* TODO(b/176523207): watchdog warning message */
- printk("Watchdog deadline is close!\n");
-}
-
-int watchdog_init(void)
-{
- int err;
- const struct device *wdt;
- struct wdt_timeout_cfg wdt_config;
-
- wdt = DEVICE_DT_GET(DT_NODELABEL(twd0));
- if (!device_is_ready(wdt)) {
- LOG_ERR("Error: device %s is not ready", wdt->name);
- return -1;
- }
-
- /* Reset SoC when watchdog timer expires. */
- wdt_config.flags = WDT_FLAG_RESET_SOC;
-
- /*
- * Set the Warning timer as CONFIG_AUX_TIMER_PERIOD_MS.
- * Then the watchdog reset time = CONFIG_WATCHDOG_PERIOD_MS.
- */
- wdt_config.window.min = 0U;
- wdt_config.window.max = CONFIG_AUX_TIMER_PERIOD_MS;
- wdt_config.callback = wdt_warning_handler;
-
- err = wdt_install_timeout(wdt, &wdt_config);
-
- /* If watchdog is running, reinstall it. */
- if (err == -EBUSY) {
- wdt_disable(wdt);
- err = wdt_install_timeout(wdt, &wdt_config);
- }
-
- if (err < 0) {
- LOG_ERR("Watchdog install error");
- return err;
- }
-
- err = wdt_setup(wdt, 0);
- if (err < 0) {
- LOG_ERR("Watchdog setup error");
- return err;
- }
-
- return EC_SUCCESS;
-}
-
-void watchdog_reload(void)
-{
- const struct device *wdt;
-
- wdt = DEVICE_DT_GET(DT_NODELABEL(twd0));
- if (!device_is_ready(wdt))
- LOG_ERR("Error: device %s is not ready", wdt->name);
-
- wdt_feed(wdt, 0);
-}
-DECLARE_HOOK(HOOK_TICK, watchdog_reload, HOOK_PRIO_DEFAULT);
diff --git a/zephyr/shim/src/ztest_system.c b/zephyr/shim/src/ztest_system.c
deleted file mode 100644
index 14796b5bd5..0000000000
--- a/zephyr/shim/src/ztest_system.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "system.h"
-#include "cros_version.h"
-
-/* Ongoing actions preventing going into deep-sleep mode. */
-uint32_t sleep_mask;
-
-void system_common_pre_init(void)
-{
-}
-
-int system_add_jump_tag(uint16_t tag, int version, int size, const void *data)
-{
- return EC_SUCCESS;
-}
-
-const uint8_t *system_get_jump_tag(uint16_t tag, int *version, int *size)
-{
- return NULL;
-}
-
-int system_jumped_late(void)
-{
- return 0;
-}
-
-enum ec_image system_get_image_copy(void)
-{
- return EC_IMAGE_RW;
-}
-
-int system_is_locked(void)
-{
- return 0;
-}
-
-int system_is_in_rw(void)
-{
- return 1;
-}
-
-uint32_t system_get_reset_flags(void)
-{
- return 0;
-}
-
-void system_print_banner(void)
-{
- printk("Image: %s\n", build_info);
-}
-
-void system_set_reset_flags(uint32_t flags)
-{
-}
-
-struct jump_data *get_jump_data(void)
-{
- return NULL;
-}
-
-__attribute__((weak))
-void system_reset(int flags)
-{
- __builtin_unreachable();
-}
diff --git a/zephyr/test/accel_cal/CMakeLists.txt b/zephyr/test/accel_cal/CMakeLists.txt
deleted file mode 100644
index 14fd70e01a..0000000000
--- a/zephyr/test/accel_cal/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(accel_cal)
-
-# Ensure that we get the definitions from test_config.h
-zephyr_compile_definitions("TEST_ACCEL_CAL")
-
-# Include the local test directory for shimmed_test_tasks.h
-zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
-
-# Include test file and unit under test
-target_sources(app PRIVATE
- "${PLATFORM_EC}/test/accel_cal.c"
- "${PLATFORM_EC}/common/accel_cal.c"
- "${PLATFORM_EC}/common/kasa.c"
- "${PLATFORM_EC}/common/mat44.c"
- "${PLATFORM_EC}/common/math_util.c"
- "${PLATFORM_EC}/common/newton_fit.c"
- "${PLATFORM_EC}/common/stillness_detector.c"
- "${PLATFORM_EC}/common/vec3.c")
diff --git a/zephyr/test/accel_cal/prj.conf b/zephyr/test/accel_cal/prj.conf
deleted file mode 100644
index 5efe3ec6b7..0000000000
--- a/zephyr/test/accel_cal/prj.conf
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_ZTEST=y
-CONFIG_HAS_TEST_TASKS=y
-CONFIG_PLATFORM_EC=y
-CONFIG_CROS_EC=y
diff --git a/zephyr/test/accel_cal/shimmed_test_tasks.h b/zephyr/test/accel_cal/shimmed_test_tasks.h
deleted file mode 100644
index ff221a5ba3..0000000000
--- a/zephyr/test/accel_cal/shimmed_test_tasks.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "accel_cal.tasklist"
diff --git a/zephyr/test/accel_cal/zmake.yaml b/zephyr/test/accel_cal/zmake.yaml
deleted file mode 100644
index decc749ae1..0000000000
--- a/zephyr/test/accel_cal/zmake.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: native_posix
-supported-zephyr-versions:
- - v2.6
-supported-toolchains:
- - llvm
- - host
-output-type: elf
-is-test: true
diff --git a/zephyr/test/base32/CMakeLists.txt b/zephyr/test/base32/CMakeLists.txt
deleted file mode 100644
index 674ad0d244..0000000000
--- a/zephyr/test/base32/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(base32)
-
-target_sources(app PRIVATE "${PLATFORM_EC}/test/base32.c")
diff --git a/zephyr/test/base32/prj.conf b/zephyr/test/base32/prj.conf
deleted file mode 100644
index ec8c5035f5..0000000000
--- a/zephyr/test/base32/prj.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_ZTEST=y
-CONFIG_PLATFORM_EC=y
-CONFIG_CROS_EC=y
diff --git a/zephyr/test/base32/zmake.yaml b/zephyr/test/base32/zmake.yaml
deleted file mode 100644
index 6aa10c2661..0000000000
--- a/zephyr/test/base32/zmake.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: native_posix
-supported-zephyr-versions:
- - v2.6
-supported-toolchains:
- - llvm
- - host
-output-type: elf
-is-test: true
diff --git a/zephyr/test/crc/CMakeLists.txt b/zephyr/test/crc/CMakeLists.txt
deleted file mode 100644
index 0b46729578..0000000000
--- a/zephyr/test/crc/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2020 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.
-
-cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(crc)
-
-# Include the test source and the file under test
-target_sources(app PRIVATE main.c)
diff --git a/zephyr/test/crc/main.c b/zephyr/test/crc/main.c
deleted file mode 100644
index 34fec7199a..0000000000
--- a/zephyr/test/crc/main.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <kernel.h>
-#include <ztest.h>
-
-#include "crc8.h"
-
-/* Note this test makes the pure platform/ec test that uses the same value */
-static void test_crc8_known_data(void)
-{
- uint8_t buffer[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 8 };
-
- int crc = cros_crc8(buffer, 10);
-
- /* Verifies polynomial values of 0x07 representing x^8 + x^2 + x + 1 */
- zassert_equal(crc, 170, "CRC8 hash did not match");
-}
-
-void test_main(void)
-{
- ztest_test_suite(test_task_shim,
- ztest_unit_test(test_crc8_known_data));
- ztest_run_test_suite(test_task_shim);
-}
diff --git a/zephyr/test/crc/prj.conf b/zephyr/test/crc/prj.conf
deleted file mode 100644
index ec8c5035f5..0000000000
--- a/zephyr/test/crc/prj.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_ZTEST=y
-CONFIG_PLATFORM_EC=y
-CONFIG_CROS_EC=y
diff --git a/zephyr/test/crc/zmake.yaml b/zephyr/test/crc/zmake.yaml
deleted file mode 100644
index 6aa10c2661..0000000000
--- a/zephyr/test/crc/zmake.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: native_posix
-supported-zephyr-versions:
- - v2.6
-supported-toolchains:
- - llvm
- - host
-output-type: elf
-is-test: true
diff --git a/zephyr/test/drivers/CMakeLists.txt b/zephyr/test/drivers/CMakeLists.txt
deleted file mode 100644
index c90b334e60..0000000000
--- a/zephyr/test/drivers/CMakeLists.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(drivers)
-
-# 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")
-zephyr_include_directories("${PLATFORM_EC}/driver/ppc/")
-
-FILE(GLOB test_sources src/*.c)
-target_sources(app PRIVATE ${test_sources})
-
-target_sources(app PRIVATE "${PLATFORM_EC}/test/cbi.c")
diff --git a/zephyr/test/drivers/README.md b/zephyr/test/drivers/README.md
deleted file mode 100644
index 8ea3dcdde1..0000000000
--- a/zephyr/test/drivers/README.md
+++ /dev/null
@@ -1,50 +0,0 @@
-This is the combined driver test. The goal is to have many driver test suites
-in one binary, so that compile time will be faster than many small tests, and
-so we can test interactions between different subsystems easily.
-
-## Run all the test suites
-
-```bash
-(chroot) zmake configure --test zephyr/test/drivers
-```
-
-To see all the output of zmake (for example if the build fails)
-
-```bash
-(chroot) zmake -l DEBUG -j 1 configure --test zephyr/test/drivers
-```
-
-## Code coverage
-
-To calculate code coverage for this test only
-
-```bash
-(chroot) zmake configure --coverage --test zephyr/test/drivers
-(chroot) lcov --gcov-tool ~/trunk/src/platform/ec/util/llvm-gcov.sh -q \
- -o build/zephyr/test/drivers/lcov.info -c -d build/zephyr/test/drivers
-(chroot) genhtml -q -o build/zephyr/test/drivers/coverage_rpt \
- build/zephyr/test/drivers/lcov.info
-```
-
-The report will be in build/zephyr/test/drivers/coverage_rpt/index.html
-
-## Debugging
-
-You need the host version of gdb:
-
-```bash
-(chroot) sudo emerge -j sys-devel/gdb
-```
-
-Build the test
-```bash
-(chroot) zmake configure --build zephyr/test/drivers
-```
-
-Then run gdb
-
-```
-(chroot) gdb build/zephyr/test/drivers/build-singleimage/zephyr/zephyr.exe
-# Set breakpoints, run, etc.
-```
-
diff --git a/zephyr/test/drivers/include/gpio_map.h b/zephyr/test/drivers/include/gpio_map.h
deleted file mode 100644
index 1f67138bd2..0000000000
--- a/zephyr/test/drivers/include/gpio_map.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef __ZEPHYR_GPIO_MAP_H
-#define __ZEPHYR_GPIO_MAP_H
-
-#include <devicetree.h>
-#include <gpio_signal.h>
-
-/*
- * Without https://github.com/zephyrproject-rtos/zephyr/pull/29282, we need
- * to manually link GPIO_ defines that platform/ec code expects to the
- * enum gpio_signal values that are generated by device tree bindings.
- *
- * Note we only need to create aliases for GPIOs that are referenced in common
- * platform/ec code.
- */
-#define CONFIG_TEMP_SENSOR_POWER_GPIO GPIO_PG_EC_DSW_PWROK
-
-#define EC_CROS_GPIO_INTERRUPTS \
- GPIO_INT(GPIO_AC_PRESENT, GPIO_INT_EDGE_BOTH, extpower_interrupt)
-
-#endif /* __ZEPHYR_GPIO_MAP_H */
diff --git a/zephyr/test/drivers/include/stubs.h b/zephyr/test/drivers/include/stubs.h
deleted file mode 100644
index 1ae0f3a50d..0000000000
--- a/zephyr/test/drivers/include/stubs.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "power.h"
-
-enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT };
-
-void set_mock_power_state(enum power_state state);
diff --git a/zephyr/test/drivers/overlay.dts b/zephyr/test/drivers/overlay.dts
deleted file mode 100644
index b211d77caa..0000000000
--- a/zephyr/test/drivers/overlay.dts
+++ /dev/null
@@ -1,561 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <dt-bindings/gpio_defines.h>
-#include <cros/thermistor/thermistor.dtsi>
-
-/ {
- aliases {
- bmi260-int = &ms_bmi260_accel;
- bmi160-int = &ms_bmi160_accel;
- lis2dw12-int = &ms_lis2dw12_accel;
- tcs3400-int = &tcs3400_clear;
- };
- named-gpios {
- compatible = "named-gpios";
-
- ec_batt_pres_odl {
- gpios = <&gpio0 1 GPIO_INPUT>;
- enum-name = "GPIO_BATT_PRES_ODL";
- label = "EC_BATT_PRES_ODL";
- };
- acok_od {
- gpios = <&gpio0 2 GPIO_INPUT>;
- enum-name = "GPIO_AC_PRESENT";
- label = "ACOK_OD";
- };
- /* In test WP is output because CBI use it, but it is also
- * input, because test_all_tags set it to enable write
- * protection.
- */
- gpio_wp_l: wp_l {
- #gpio-cells = <0>;
- gpios = <&gpio0 3 (GPIO_INPUT | GPIO_OUTPUT)>;
- enum-name = "GPIO_WP_L";
- label = "WP_L";
- };
- pg_ec_dsw_pwrok {
- gpios = <&gpio0 4 GPIO_INPUT>;
- enum-name = "GPIO_PG_EC_DSW_PWROK";
- label = "PG_EC_DSW_PWROK";
- };
- ec_pch_wake_odl {
- gpios = <&gpio0 5 GPIO_OUT_HIGH>;
- enum-name = "GPIO_EC_PCH_WAKE_ODL";
- label = "EC_PCH_WAKE_ODL";
- };
- /* Setup USB C1 pin as output to check their state in test */
- usb_c1_ls_en {
- gpios = <&gpio0 6 (GPIO_INPUT | GPIO_PULL_UP |
- GPIO_OUTPUT)>;
- enum-name = "GPIO_USB_C1_LS_EN";
- label = "USB_C1_LS_EN";
- };
- usb_c1_rt_rst_odl {
- gpios = <&gpio0 7 (GPIO_OUTPUT | GPIO_INPUT)>;
- enum-name = "GPIO_USB_C1_RT_RST_ODL";
- label = "USB_C1_RT_RST_ODL";
- };
- };
- named-i2c-ports {
- compatible = "named-i2c-ports";
-
- usb-c0 {
- i2c-port = <&i2c0>;
- enum-name = "I2C_PORT_USB_C0";
- label = "USB_C0";
- };
- usb-c1 {
- i2c-port = <&i2c0>;
- enum-name = "I2C_PORT_USB_C1";
- label = "USB_C1";
- };
- battery {
- i2c-port = <&i2c0>;
- enum-name = "I2C_PORT_BATTERY";
- label = "BATTERY";
- };
- power {
- i2c-port = <&i2c0>;
- enum-name = "I2C_PORT_POWER";
- label = "POWER";
- };
- charger {
- i2c-port = <&i2c0>;
- enum-name = "I2C_PORT_CHARGER";
- label = "CHARGER";
- };
- eeprom {
- i2c-port = <&i2c0>;
- enum-name = "I2C_PORT_EEPROM";
- label = "EEPROM";
- };
- i2c_accel: accel {
- i2c-port = <&i2c0>;
- enum-name = "I2C_PORT_ACCEL";
- label = "ACCEL";
- };
- i2c_sensor: sensor {
- i2c-port = <&i2c1>;
- enum-name = "I2C_PORT_SENSOR";
- label = "SENSOR";
- };
- };
-
- named-batteries {
- compatible = "named-batteries";
-
- lgc011 {
- enum-name = "lgc011";
- };
- };
-
- adc0: adc {
- compatible = "zephyr,adc-emul";
- nchannels = <4>;
- ref-internal-mv = <3300>;
- #io-channel-cells = <1>;
- label = "ADC_0";
- status = "okay";
- };
-
- named-adc-channels {
- compatible = "named-adc-channels";
-
- adc_charger: charger {
- label = "ADC_TEMP_SENSOR_CHARGER";
- enum-name = "ADC_TEMP_SENSOR_CHARGER";
- channel = <0>;
- };
- adc_pp3300_regulator: pp3300-regulator {
- label = "ADC_TEMP_SENSOR_PP3300_REGULATOR";
- enum-name = "ADC_TEMP_SENSOR_PP3300_REGULATOR";
- channel = <1>;
- };
- adc_ddr_soc: ddr-soc {
- label = "ADC_TEMP_SENSOR_DDR_SOC";
- enum-name = "ADC_TEMP_SENSOR_DDR_SOC";
- channel = <2>;
- };
- adc_fan: fan {
- label = "ADC_TEMP_SENSOR_FAN";
- enum-name = "ADC_TEMP_SENSOR_FAN";
- channel = <3>;
- };
- };
-
- named-temp-sensors {
- charger {
- thermistor = <&thermistor_3V3_13K7_47K_4050B>;
- status = "okay";
- compatible = "cros-ec,temp-sensor";
- label = "TEMP_SENSOR_CHARGER";
- enum-name = "TEMP_SENSOR_CHARGER";
- temp_fan_off = <40>;
- temp_fan_max = <55>;
- temp_host_high = <75>;
- temp_host_halt = <80>;
- temp_host_release_high = <65>;
- adc = <&adc_charger>;
- };
- pp3300-regulator {
- thermistor = <&thermistor_3V3_30K9_47K_4050B>;
- status = "okay";
- compatible = "cros-ec,temp-sensor";
- label = "TEMP_SENSOR_PP3300_REGULATOR";
- enum-name = "TEMP_SENSOR_PP3300_REGULATOR";
- temp_fan_off = <40>;
- temp_fan_max = <55>;
- temp_host_high = <75>;
- temp_host_halt = <80>;
- temp_host_release_high = <65>;
- adc = <&adc_pp3300_regulator>;
- };
- ddr-soc {
- thermistor = <&thermistor_3V3_51K1_47K_4050B>;
- status = "okay";
- compatible = "cros-ec,temp-sensor";
- label = "TEMP_SENSOR_DDR_SOC";
- enum-name = "TEMP_SENSOR_DDR_SOC";
- temp_fan_off = <35>;
- temp_fan_max = <50>;
- temp_host_high = <70>;
- temp_host_halt = <80>;
- temp_host_release_high = <65>;
- adc = <&adc_ddr_soc>;
- };
- fan {
- thermistor = <&thermistor_3V0_22K6_47K_4050B>;
- status = "okay";
- compatible = "cros-ec,temp-sensor";
- label = "TEMP_SENSOR_FAN";
- enum-name = "TEMP_SENSOR_FAN";
- temp_fan_off = <35>;
- temp_fan_max = <50>;
- temp_host_high = <70>;
- temp_host_halt = <80>;
- temp_host_release_high = <65>;
- adc = <&adc_fan>;
- };
- };
-
- /*
- * 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";
- mutex_bmi260: bmi260-mutex {
- label = "BMI260_MUTEX";
- };
-
- mutex_bmi160: bmi160-mutex {
- label = "BMI160_MUTEX";
- };
-
- mutex_lis2dw12: lis2dw12-mutex {
- label = "LIS2DW12_MUTEX";
- };
- };
-
- /*
- * Driver specific data. A driver-specific data can be shared with
- * different motion sensors while they are using the same driver.
- */
- motionsense-sensor-data {
- bmi260_data: bmi260-drv-data {
- compatible = "cros-ec,drvdata-bmi260";
- status = "okay";
- };
-
- bmi160_data: bmi160-drv-data {
- compatible = "cros-ec,drvdata-bmi160";
- status = "okay";
- };
-
- lis2dw12_data: lis2dw12-drv-data {
- compatible = "cros-ec,drvdata-lis2dw12";
- status = "okay";
- };
-
- tcs_clear_data: tcs3400-clear-drv-data {
- compatible = "cros-ec,drvdata-tcs3400-clear";
- status = "okay";
-
- als-drv-data {
- compatible = "cros-ec,accelgyro-als-drv-data";
- als-cal {
- scale = <1>;
- uscale = <0>;
- offset = <0>;
- als-channel-scale {
- compatible =
- "cros-ec,accelgyro-als-channel-scale";
- k-channel-scale = <1>;
- cover-scale = <1>;
- };
- };
- };
- };
-
- tcs_rgb_data: tcs3400-rgb-drv-data {
- compatible = "cros-ec,drvdata-tcs3400-rgb";
- status = "okay";
-
- /* node for rgb_calibration_t defined in accelgyro.h */
- rgb_calibration {
- compatible =
- "cros-ec,accelgyro-rgb-calibration";
-
- irt = <1>;
-
- rgb-cal-x {
- offset = <0>;
- coeff = <0 1 0 0>;
- als-channel-scale {
- compatible =
- "cros-ec,accelgyro-als-channel-scale";
- k-channel-scale = <1>;
- cover-scale = <1>;
- };
- };
- rgb-cal-y {
- offset = <0>;
- coeff = <0 0 1 0>;
- als-channel-scale {
- compatible =
- "cros-ec,accelgyro-als-channel-scale";
- k-channel-scale = <1>;
- cover-scale = <1>;
- };
- };
- rgb-cal-z {
- offset = <0>;
- coeff = <0 0 0 1>;
- als-channel-scale {
- compatible =
- "cros-ec,accelgyro-als-channel-scale";
- k-channel-scale = <1>;
- cover-scale = <1>;
- };
- };
- };
- };
- };
-
- /*
- * List of motion sensors that creates motion_sensors array.
- * The label "lid_accel" and "base_accel" are used to indicate
- * motion sensor IDs for lid angle calculation.
- */
- motionsense-sensor {
- ms_bmi260_accel: ms-bmi260-accel {
- compatible = "cros-ec,bmi260-accel";
- status = "okay";
-
- label = "BMI260 emul accel";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi260>;
- port = <&i2c_accel>;
- drv-data = <&bmi260_data>;
- default-range = <4>;
- i2c-spi-addr-flags = "BMI260_ADDR0_FLAGS";
- };
-
- ms_bmi260_gyro: ms-bmi260-gyro {
- compatible = "cros-ec,bmi260-gyro";
- status = "okay";
-
- label = "BMI260 emul gyro";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi260>;
- port = <&i2c_accel>;
- drv-data = <&bmi260_data>;
- default-range = <1000>; /* dps */
- i2c-spi-addr-flags = "BMI260_ADDR0_FLAGS";
- };
-
- ms_bmi160_accel: ms-bmi160-accel {
- compatible = "cros-ec,bmi160-accel";
- status = "okay";
-
- label = "BMI160 emul accel";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi160>;
- port = <&i2c_sensor>;
- drv-data = <&bmi160_data>;
- default-range = <4>;
- i2c-spi-addr-flags = "BMI160_ADDR0_FLAGS";
- };
-
- ms_bmi160_gyro: ms-bmi160-gyro {
- compatible = "cros-ec,bmi160-gyro";
- status = "okay";
-
- label = "BMI160 emul gyro";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_bmi160>;
- port = <&i2c_sensor>;
- drv-data = <&bmi160_data>;
- default-range = <1000>; /* dps */
- i2c-spi-addr-flags = "BMI160_ADDR0_FLAGS";
- };
-
- ms_lis2dw12_accel: ms-lis2dw12-accel {
- compatible = "cros-ec,lis2dw12";
- status = "okay";
-
- label = "LIS2DW12";
- location = "MOTIONSENSE_LOC_BASE";
- mutex = <&mutex_lis2dw12>;
- port = <&i2c_accel>;
- drv-data = <&lis2dw12_data>;
- default-range = <2>;
- i2c-spi-addr-flags = "LIS2DWL_ADDR1_FLAGS";
- };
-
- tcs3400_clear: tcs3400-clear {
- compatible = "cros-ec,tcs3400-clear";
- status = "okay";
-
- label = "Clear Light";
- location = "MOTIONSENSE_LOC_BASE";
- port = <&i2c_sensor>;
- default-range = <0x10000>;
- drv-data = <&tcs_clear_data>;
- i2c-spi-addr-flags = "TCS3400_I2C_ADDR_FLAGS";
- configs {
- compatible =
- "cros-ec,motionsense-sensor-config";
- ec-s0 {
- /* Run ALS sensor in S0 */
- label = "SENSOR_CONFIG_EC_S0";
- odr = <1000>;
- };
- };
- };
-
- tcs3400_rgb: tcs3400-rgb {
- compatible = "cros-ec,tcs3400-rgb";
- status = "okay";
-
- label = "RGB Light";
- location = "MOTIONSENSE_LOC_BASE";
- default-range = <0x10000>; /* scale = 1x, uscale = 0 */
- drv-data = <&tcs_rgb_data>;
- };
- };
-
- /*
- * Second i2c bus is required, because there is already device with
- * address 0x68 on the first bus
- */
- i2c1: i2c@400 {
- status = "okay";
- compatible = "zephyr,i2c-emul-controller";
- clock-frequency = <I2C_BITRATE_STANDARD>;
- #address-cells = <1>;
- #size-cells = <0>;
- reg = <0x400 4>;
- label = "I2C_1";
-
- accel_bmi160: bmi160@68 {
- compatible = "zephyr,bmi";
- reg = <0x68>;
- label = "BMI160";
- device-model = "BMI_EMUL_160";
- error-on-ro-write;
- error-on-wo-read;
- error-on-reserved-bit-write;
- simulate-command-exec-time;
- };
-
- tcs_emul: tcs@39 {
- compatible = "zephyr,tcs3400";
- reg = <0x39>;
- label = "TCS_EMUL";
- error-on-ro-write;
- error-on-reserved-bit-write;
- error-on-msb-first-access;
- };
- };
-};
-
-&espi0 {
- espi-host@0 {
- status = "okay";
- compatible = "zephyr,espi-emul-espi-host";
- reg = <0x0>;
- label = "ESPI_HOST";
- };
-};
-
-&gpio0 {
- ngpios = <8>;
-};
-
-&i2c0 {
- cbi_eeprom: eeprom@56 {
- compatible = "atmel,at24";
- reg = <0x56>;
- label = "EEPROM_CBI";
- size = <512>;
- pagesize = <8>;
- address-width = <8>;
- timeout = <5>;
- wp-gpios = <&gpio_wp_l>;
- };
-
- battery: sb@b {
- compatible = "zephyr,smart-battery";
- reg = <0xb>;
- label = "BATTERY";
- cycle-count = <99>;
- version = "BATTERY_SPEC_VER_1_1_WITH_PEC";
- };
-
- bma_emul: bma@18 {
- compatible = "zephyr,bma255";
- reg = <0x18>;
- label = "BMA_EMUL";
- error-on-compensation-not-ready;
- error-on-ro-write;
- error-on-reserved-bit-write;
- error-on-msb-first-access;
- };
-
- pi3usb9201_emul: pi3usb9201@5f {
- compatible = "zephyr,pi3usb9201-emul";
- reg = <0x5f>;
- label = "PI3USB9201_EMUL";
- };
-
- syv682x_emul: syv682x@41 {
- compatible = "zephyr,syv682x-emul";
- reg = <0x41>;
- label = "SYV682X_EMUL";
- };
-
- accel_bmi260: bmi260@68 {
- compatible = "zephyr,bmi";
- reg = <0x68>;
- label = "BMI260";
- device-model = "BMI_EMUL_260";
- error-on-ro-write;
- error-on-wo-read;
- error-on-reserved-bit-write;
- simulate-command-exec-time;
- };
-
- usb_c1_bb_retimer_emul: bbretimer@42 {
- compatible = "cros,bb-retimer-emul";
- reg = <0x42>;
- label = "USB_C1_BB_RETIMER";
- vendor = "BB_RETIMER_VENDOR_ID_1";
- error-on-ro-write;
- error-on-reserved-bit-write;
- };
-
- ln9310: ln9310@80 {
- compatible = "cros,ln9310-emul";
- status = "okay";
- reg = <0x80>;
- label = "LN9310";
- };
-
- lis2dw12_emul: lis2dw12@19 {
- compatible = "cros,lis2dw12-emul";
- status = "okay";
- reg = <0x19>;
- label = "LIS2DW12_EMUL";
- };
-
- i2c_mock: i2c_mock@84 {
- compatible = "cros,i2c-mock";
- status = "okay";
- reg = <0x84>;
- label = "I2C_MOCK";
- };
-};
-
-/* Enable all thermistors for testing */
-&thermistor_3V3_30K9_47K_4050B {
- status = "okay";
-};
-
-&thermistor_3V0_22K6_47K_4050B {
- status = "okay";
-};
-
-&thermistor_3V3_13K7_47K_4050B {
- status = "okay";
-};
-
-&thermistor_3V3_51K1_47K_4050B {
- status = "okay";
-};
diff --git a/zephyr/test/drivers/prj.conf b/zephyr/test/drivers/prj.conf
deleted file mode 100644
index 99a275f9e2..0000000000
--- a/zephyr/test/drivers/prj.conf
+++ /dev/null
@@ -1,90 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Enabling this config will show all I2C traffic, do not commit with this line
-# uncommented, it is here to make it easy to find/enable.
-# CONFIG_I2C_LOG_LEVEL_DBG=y
-
-CONFIG_ZTEST=y
-CONFIG_ZTEST_ASSERT_VERBOSE=1
-CONFIG_ZTEST_MOCKING=y
-CONFIG_ZTEST_PARAMETER_COUNT=5
-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_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_HEAP_MEM_POOL_SIZE=1024
-CONFIG_EMUL_BMA255=y
-CONFIG_EMUL_BMI=y
-CONFIG_EMUL_TCS3400=y
-CONFIG_EMUL_BB_RETIMER=y
-
-CONFIG_PLATFORM_EC_POWERSEQ=y
-
-CONFIG_HAS_TASK_USB_CHG_P0=y
-CONFIG_HAS_TASK_USB_CHG_P1=y
-CONFIG_HAS_TASK_PD_C1=y
-
-CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y
-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_I2C=y
-CONFIG_PLATFORM_EC_BATTERY=y
-CONFIG_PLATFORM_EC_BATTERY_SMART=y
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10
-CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=10
-CONFIG_PLATFORM_EC_CHARGER_ISL9241=y
-CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=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_VIRTUAL=y
-CONFIG_PLATFORM_EC_USBC_PPC_SN5S330=y
-CONFIG_PLATFORM_EC_CBI_EEPROM=y
-CONFIG_PLATFORM_EC_ADC=y
-CONFIG_PLATFORM_EC_TEMP_SENSOR=y
-CONFIG_PLATFORM_EC_THERMISTOR=y
-CONFIG_PLATFORM_EC_SWITCHCAP_LN9310=y
-CONFIG_PLATFORM_EC_ACCEL_BMA255=y
-CONFIG_PLATFORM_EC_MOTIONSENSE=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI160=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI260=y
-CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y
-CONFIG_PLATFORM_EC_ACCEL_INTERRUPTS=y
-CONFIG_PLATFORM_EC_ACCEL_FIFO=y
-CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y
-CONFIG_PLATFORM_EC_ALS_TCS3400=y
-CONFIG_PLATFORM_EC_USBC_RETIMER_INTEL_BB=y
-
-CONFIG_ESPI=y
-CONFIG_ESPI_EMUL=y
-CONFIG_EMUL_ESPI_HOST=y
-CONFIG_PLATFORM_EC_ESPI=y
-CONFIG_ESPI_PERIPHERAL_ACPI_SHM_REGION=y
-CONFIG_ESPI_PERIPHERAL_CUSTOM_OPCODE=y
-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
diff --git a/zephyr/test/drivers/src/battery.c b/zephyr/test/drivers/src/battery.c
deleted file mode 100644
index 315f822985..0000000000
--- a/zephyr/test/drivers/src/battery.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-#include <drivers/gpio.h>
-#include <drivers/gpio/gpio_emul.h>
-
-#include "battery.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)
-
-static void test_battery_is_present_gpio(void)
-{
- const struct device *dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios));
-
- zassert_not_null(dev, NULL);
- /* ec_batt_pres_odl = 0 means battery present. */
- zassert_ok(gpio_emul_input_set(dev, GPIO_BATT_PRES_ODL_PORT, 0), NULL);
- zassert_equal(BP_YES, battery_is_present(), NULL);
- /* ec_batt_pres_odl = 1 means battery missing. */
- zassert_ok(gpio_emul_input_set(dev, GPIO_BATT_PRES_ODL_PORT, 1), NULL);
- zassert_equal(BP_NO, battery_is_present(), NULL);
-}
-
-void test_suite_battery(void)
-{
- ztest_test_suite(battery,
- ztest_user_unit_test(test_battery_is_present_gpio));
- ztest_run_test_suite(battery);
-}
diff --git a/zephyr/test/drivers/src/bb_retimer.c b/zephyr/test/drivers/src/bb_retimer.c
deleted file mode 100644
index cecee6020f..0000000000
--- a/zephyr/test/drivers/src/bb_retimer.c
+++ /dev/null
@@ -1,528 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-#include <drivers/gpio.h>
-#include <drivers/gpio/gpio_emul.h>
-
-#include "common.h"
-#include "ec_tasks.h"
-#include "emul/emul_bb_retimer.h"
-#include "emul/emul_common_i2c.h"
-#include "hooks.h"
-#include "i2c.h"
-#include "stubs.h"
-#include "usb_prl_sm.h"
-#include "usb_tc_sm.h"
-
-#include "driver/retimer/bb_retimer.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)
-#define GPIO_USB_C1_RT_RST_ODL_PATH DT_PATH(named_gpios, usb_c1_rt_rst_odl)
-#define GPIO_USB_C1_RT_RST_ODL_PORT \
- DT_GPIO_PIN(GPIO_USB_C1_RT_RST_ODL_PATH, gpios)
-#define EMUL_LABEL DT_NODELABEL(usb_c1_bb_retimer_emul)
-
-#define BB_RETIMER_ORD DT_DEP_ORD(EMUL_LABEL)
-
-/** Test is retimer fw update capable function. */
-static void test_bb_is_fw_update_capable(void)
-{
- /* BB retimer is fw update capable */
- zassert_true(bb_usb_retimer.is_retimer_fw_update_capable(), NULL);
-}
-
-/** Test is retimer fw update capable function. */
-static void test_bb_set_state(void)
-{
- struct pd_discovery *disc;
- uint32_t conn, exp_conn;
- struct i2c_emul *emul;
- bool ack_required;
-
- emul = bb_emul_get(BB_RETIMER_ORD);
-
- set_test_runner_tid();
-
- /* Setup emulator fail on write */
- i2c_common_emul_set_write_fail_reg(emul,
- BB_RETIMER_REG_CONNECTION_STATE);
-
- /* Test fail on reset register write */
- zassert_equal(EC_ERROR_INVAL,
- bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_NONE, &ack_required),
- NULL);
- zassert_false(ack_required, "ACK is never required for BB retimer");
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Set UFP role for whole test */
- tc_set_data_role(USBC_PORT_C1, PD_ROLE_UFP);
-
- /* Test none mode */
- bb_emul_set_reg(emul, BB_RETIMER_REG_CONNECTION_STATE, 0x12144678);
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_NONE,
- &ack_required), NULL);
- zassert_false(ack_required, "ACK is never required for BB retimer");
- conn = bb_emul_get_reg(emul, BB_RETIMER_REG_CONNECTION_STATE);
- /* Only UFP mode is set */
- exp_conn = BB_RETIMER_USB_DATA_ROLE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test USB3 gen1 mode */
- prl_set_rev(USBC_PORT_C1, TCPCI_MSG_SOP_PRIME, PD_REV10);
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_USB_ENABLED,
- &ack_required), NULL);
- 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_USB_3_CONNECTION;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test USB3 gen2 mode */
- disc = pd_get_am_discovery_and_notify_access(
- USBC_PORT_C1, TCPCI_MSG_SOP_PRIME);
- disc->identity.product_t1.p_rev20.ss = USB_R20_SS_U31_GEN1_GEN2;
- prl_set_rev(USBC_PORT_C1, TCPCI_MSG_SOP_PRIME, PD_REV30);
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_USB_ENABLED,
- &ack_required), NULL);
- 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_USB_3_CONNECTION |
- BB_RETIMER_USB_3_SPEED;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test TBT mode */
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_TBT_COMPAT_ENABLED,
- &ack_required), NULL);
- 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_TBT_CONNECTION;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test USB4 mode */
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_USB4_ENABLED,
- &ack_required), NULL);
- 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_USB4_ENABLED;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test USB4 mode with polarity inverted */
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_USB4_ENABLED |
- USB_PD_MUX_POLARITY_INVERTED,
- &ack_required), NULL);
- 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_CONNECTION_ORIENTATION |
- BB_RETIMER_USB4_ENABLED;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test DP mode */
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_DP_ENABLED,
- &ack_required), NULL);
- 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_DP_CONNECTION;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_DP_ENABLED |
- USB_PD_MUX_HPD_IRQ,
- &ack_required), NULL);
- 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_DP_CONNECTION |
- BB_RETIMER_IRQ_HPD;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_DP_ENABLED |
- USB_PD_MUX_HPD_LVL,
- &ack_required), NULL);
- 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_DP_CONNECTION |
- BB_RETIMER_HPD_LVL;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-}
-
-/** Test setting different options for DFP role */
-static void test_bb_set_dfp_state(void)
-{
- union tbt_mode_resp_device device_resp;
- union tbt_mode_resp_cable cable_resp;
- struct pd_discovery *disc, *dev_disc;
- uint32_t conn, exp_conn;
- struct i2c_emul *emul;
- bool ack_required;
-
- emul = bb_emul_get(BB_RETIMER_ORD);
-
- set_test_runner_tid();
-
- tc_set_data_role(USBC_PORT_C1, PD_ROLE_DFP);
-
- /* Test PD mux none mode with DFP should clear all bits in state */
- bb_emul_set_reg(emul, BB_RETIMER_REG_CONNECTION_STATE, 0x12144678);
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_NONE,
- &ack_required), NULL);
- zassert_false(ack_required, "ACK is never required for BB retimer");
- conn = bb_emul_get_reg(emul, BB_RETIMER_REG_CONNECTION_STATE);
- exp_conn = 0;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Set active cable type */
- disc = pd_get_am_discovery_and_notify_access(
- USBC_PORT_C1, TCPCI_MSG_SOP_PRIME);
- disc->identity.idh.product_type = IDH_PTYPE_ACABLE;
- disc->identity.product_t2.a2_rev30.active_elem = ACTIVE_RETIMER;
- prl_set_rev(USBC_PORT_C1, TCPCI_MSG_SOP_PRIME, PD_REV30);
-
- /* Set cable VDO */
- disc->svid_cnt = 1;
- disc->svids[0].svid = USB_VID_INTEL;
- disc->svids[0].discovery = PD_DISC_COMPLETE;
- disc->svids[0].mode_cnt = 1;
- cable_resp.tbt_alt_mode = TBT_ALTERNATE_MODE;
- cable_resp.tbt_cable_speed = TBT_SS_RES_0;
- cable_resp.tbt_rounded = TBT_GEN3_NON_ROUNDED;
- cable_resp.tbt_cable = TBT_CABLE_NON_OPTICAL;
- cable_resp.retimer_type = USB_NOT_RETIMER;
- cable_resp.lsrx_comm = BIDIR_LSRX_COMM;
- cable_resp.tbt_active_passive = TBT_CABLE_PASSIVE;
- disc->svids[0].mode_vdo[0] = cable_resp.raw_value;
-
- /* Set device VDO */
- dev_disc = pd_get_am_discovery_and_notify_access(
- USBC_PORT_C1, TCPCI_MSG_SOP);
- dev_disc->svid_cnt = 1;
- dev_disc->svids[0].svid = USB_VID_INTEL;
- dev_disc->svids[0].discovery = PD_DISC_COMPLETE;
- dev_disc->svids[0].mode_cnt = 1;
- device_resp.tbt_alt_mode = TBT_ALTERNATE_MODE;
- device_resp.tbt_adapter = TBT_ADAPTER_TBT3;
- device_resp.intel_spec_b0 = VENDOR_SPECIFIC_NOT_SUPPORTED;
- device_resp.vendor_spec_b0 = VENDOR_SPECIFIC_NOT_SUPPORTED;
- device_resp.vendor_spec_b1 = VENDOR_SPECIFIC_NOT_SUPPORTED;
- dev_disc->svids[0].mode_vdo[0] = device_resp.raw_value;
-
- /* Test USB mode with active cable */
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_USB_ENABLED,
- &ack_required), NULL);
- 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_DATA_CONNECTION_PRESENT |
- BB_RETIMER_USB_3_CONNECTION |
- BB_RETIMER_USB_3_SPEED |
- BB_RETIMER_RE_TIMER_DRIVER |
- BB_RETIMER_ACTIVE_PASSIVE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test TBT mode with active cable */
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_TBT_COMPAT_ENABLED,
- &ack_required), NULL);
- 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_DATA_CONNECTION_PRESENT |
- BB_RETIMER_TBT_CONNECTION |
- BB_RETIMER_ACTIVE_PASSIVE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test TBT mode with retimer */
- cable_resp.retimer_type = USB_RETIMER;
- disc->svids[0].mode_vdo[0] = cable_resp.raw_value;
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_TBT_COMPAT_ENABLED,
- &ack_required), NULL);
- 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_DATA_CONNECTION_PRESENT |
- BB_RETIMER_TBT_CONNECTION |
- BB_RETIMER_RE_TIMER_DRIVER |
- BB_RETIMER_ACTIVE_PASSIVE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test TBT mode with optical cable */
- cable_resp.retimer_type = USB_NOT_RETIMER;
- cable_resp.tbt_cable = TBT_CABLE_OPTICAL;
- disc->svids[0].mode_vdo[0] = cable_resp.raw_value;
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_TBT_COMPAT_ENABLED,
- &ack_required), NULL);
- 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_DATA_CONNECTION_PRESENT |
- BB_RETIMER_TBT_CONNECTION |
- BB_RETIMER_TBT_CABLE_TYPE |
- BB_RETIMER_ACTIVE_PASSIVE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test TBT mode with active link training */
- cable_resp.tbt_cable = TBT_CABLE_NON_OPTICAL;
- cable_resp.lsrx_comm = UNIDIR_LSRX_COMM;
- disc->svids[0].mode_vdo[0] = cable_resp.raw_value;
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_TBT_COMPAT_ENABLED,
- &ack_required), NULL);
- 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_DATA_CONNECTION_PRESENT |
- BB_RETIMER_TBT_CONNECTION |
- BB_RETIMER_TBT_ACTIVE_LINK_TRAINING |
- BB_RETIMER_ACTIVE_PASSIVE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test TBT mode with different cable speeds */
- cable_resp.lsrx_comm = BIDIR_LSRX_COMM;
- cable_resp.tbt_cable_speed = TBT_SS_U31_GEN1;
- disc->svids[0].mode_vdo[0] = cable_resp.raw_value;
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_TBT_COMPAT_ENABLED,
- &ack_required), NULL);
- 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_DATA_CONNECTION_PRESENT |
- BB_RETIMER_TBT_CONNECTION |
- BB_RETIMER_USB4_TBT_CABLE_SPEED_SUPPORT(1) |
- BB_RETIMER_ACTIVE_PASSIVE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- cable_resp.tbt_cable_speed = TBT_SS_U32_GEN1_GEN2;
- disc->svids[0].mode_vdo[0] = cable_resp.raw_value;
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_TBT_COMPAT_ENABLED,
- &ack_required), NULL);
- 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_DATA_CONNECTION_PRESENT |
- BB_RETIMER_TBT_CONNECTION |
- BB_RETIMER_USB4_TBT_CABLE_SPEED_SUPPORT(2) |
- BB_RETIMER_ACTIVE_PASSIVE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- cable_resp.tbt_cable_speed = TBT_SS_TBT_GEN3;
- disc->svids[0].mode_vdo[0] = cable_resp.raw_value;
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_TBT_COMPAT_ENABLED,
- &ack_required), NULL);
- 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_DATA_CONNECTION_PRESENT |
- BB_RETIMER_TBT_CONNECTION |
- BB_RETIMER_USB4_TBT_CABLE_SPEED_SUPPORT(3) |
- BB_RETIMER_ACTIVE_PASSIVE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test TBT mode with TBT gen4 cable */
- cable_resp.tbt_cable_speed = TBT_SS_RES_0;
- cable_resp.tbt_rounded = TBT_GEN3_GEN4_ROUNDED_NON_ROUNDED;
- disc->svids[0].mode_vdo[0] = cable_resp.raw_value;
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_TBT_COMPAT_ENABLED,
- &ack_required), NULL);
- 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_DATA_CONNECTION_PRESENT |
- BB_RETIMER_TBT_CONNECTION |
- BB_RETIMER_TBT_CABLE_GENERATION(1) |
- BB_RETIMER_ACTIVE_PASSIVE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test TBT mode with legacy TBT adapter */
- cable_resp.tbt_rounded = TBT_GEN3_NON_ROUNDED;
- disc->svids[0].mode_vdo[0] = cable_resp.raw_value;
- device_resp.tbt_adapter = TBT_ADAPTER_TBT2_LEGACY;
- dev_disc->svids[0].mode_vdo[0] = device_resp.raw_value;
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_TBT_COMPAT_ENABLED,
- &ack_required), NULL);
- 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_DATA_CONNECTION_PRESENT |
- BB_RETIMER_TBT_CONNECTION |
- BB_RETIMER_TBT_TYPE |
- BB_RETIMER_ACTIVE_PASSIVE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test TBT mode with Intel specific b0 */
- device_resp.tbt_adapter = TBT_ADAPTER_TBT3;
- device_resp.intel_spec_b0 = VENDOR_SPECIFIC_SUPPORTED;
- dev_disc->svids[0].mode_vdo[0] = device_resp.raw_value;
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_TBT_COMPAT_ENABLED,
- &ack_required), NULL);
- 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_DATA_CONNECTION_PRESENT |
- BB_RETIMER_TBT_CONNECTION |
- BB_RETIMER_VPRO_DOCK_DP_OVERDRIVE |
- BB_RETIMER_ACTIVE_PASSIVE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-
- /* Test TBT mode with vendor specific b1 */
- device_resp.intel_spec_b0 = VENDOR_SPECIFIC_NOT_SUPPORTED;
- device_resp.vendor_spec_b1 = VENDOR_SPECIFIC_SUPPORTED;
- dev_disc->svids[0].mode_vdo[0] = device_resp.raw_value;
- zassert_equal(EC_SUCCESS, bb_usb_retimer.set(&usb_muxes[USBC_PORT_C1],
- USB_PD_MUX_TBT_COMPAT_ENABLED,
- &ack_required), NULL);
- 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_DATA_CONNECTION_PRESENT |
- BB_RETIMER_TBT_CONNECTION |
- BB_RETIMER_VPRO_DOCK_DP_OVERDRIVE |
- BB_RETIMER_ACTIVE_PASSIVE;
- zassert_equal(exp_conn, conn, "Expected state 0x%lx, got 0x%lx",
- exp_conn, conn);
-}
-
-/** Test BB retimer init */
-static void test_bb_init(void)
-{
- const struct device *gpio_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_USB_C1_LS_EN_PATH, gpios));
- struct i2c_emul *emul;
-
- zassert_not_null(gpio_dev, "Cannot get GPIO device");
-
- emul = bb_emul_get(BB_RETIMER_ORD);
-
- /* Set AP to normal state and wait for chipset task */
- set_mock_power_state(POWER_S0);
- k_msleep(1);
-
- /* Setup emulator fail on read */
- i2c_common_emul_set_read_fail_reg(emul, BB_RETIMER_REG_VENDOR_ID);
- /* Test fail on vendor ID read */
- zassert_equal(EC_ERROR_INVAL,
- bb_usb_retimer.init(&usb_muxes[USBC_PORT_C1]), NULL);
- /* Enable pins should be set always after init, when AP is on */
- zassert_equal(1, gpio_emul_output_get(gpio_dev, GPIO_USB_C1_LS_EN_PORT),
- NULL);
- zassert_equal(1, gpio_emul_output_get(gpio_dev,
- GPIO_USB_C1_RT_RST_ODL_PORT),
- NULL);
-
- /* Setup wrong vendor ID */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- bb_emul_set_reg(emul, BB_RETIMER_REG_VENDOR_ID, 0x12144678);
- /* Test fail on wrong vendor ID */
- zassert_equal(EC_ERROR_INVAL,
- bb_usb_retimer.init(&usb_muxes[USBC_PORT_C1]), NULL);
- zassert_equal(1, gpio_emul_output_get(gpio_dev, GPIO_USB_C1_LS_EN_PORT),
- NULL);
- zassert_equal(1, gpio_emul_output_get(gpio_dev,
- GPIO_USB_C1_RT_RST_ODL_PORT),
- NULL);
-
- /* Setup emulator fail on device ID read */
- i2c_common_emul_set_read_fail_reg(emul, BB_RETIMER_REG_DEVICE_ID);
- bb_emul_set_reg(emul, BB_RETIMER_REG_VENDOR_ID, BB_RETIMER_VENDOR_ID_1);
- /* Test fail on device ID read */
- zassert_equal(EC_ERROR_INVAL,
- bb_usb_retimer.init(&usb_muxes[USBC_PORT_C1]), NULL);
- zassert_equal(1, gpio_emul_output_get(gpio_dev, GPIO_USB_C1_LS_EN_PORT),
- NULL);
- zassert_equal(1, gpio_emul_output_get(gpio_dev,
- GPIO_USB_C1_RT_RST_ODL_PORT),
- NULL);
-
- /* Setup wrong device ID */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- bb_emul_set_reg(emul, BB_RETIMER_REG_DEVICE_ID, 0x12144678);
- /* Test fail on wrong device ID */
- zassert_equal(EC_ERROR_INVAL,
- bb_usb_retimer.init(&usb_muxes[USBC_PORT_C1]), NULL);
- zassert_equal(1, gpio_emul_output_get(gpio_dev, GPIO_USB_C1_LS_EN_PORT),
- NULL);
- zassert_equal(1, gpio_emul_output_get(gpio_dev,
- GPIO_USB_C1_RT_RST_ODL_PORT),
- NULL);
-
- /* Test successful init */
- bb_emul_set_reg(emul, BB_RETIMER_REG_DEVICE_ID, BB_RETIMER_DEVICE_ID);
- zassert_equal(EC_SUCCESS, bb_usb_retimer.init(&usb_muxes[USBC_PORT_C1]),
- NULL);
- zassert_equal(1, gpio_emul_output_get(gpio_dev, GPIO_USB_C1_LS_EN_PORT),
- NULL);
- zassert_equal(1, gpio_emul_output_get(gpio_dev,
- GPIO_USB_C1_RT_RST_ODL_PORT),
- NULL);
-
- /* Set AP to off state and wait for chipset task */
- set_mock_power_state(POWER_G3);
- k_msleep(1);
-
- /* With AP off, init should fail and pins should be unset */
- zassert_equal(EC_ERROR_NOT_POWERED,
- bb_usb_retimer.init(&usb_muxes[USBC_PORT_C1]), NULL);
- zassert_equal(0, gpio_emul_output_get(gpio_dev, GPIO_USB_C1_LS_EN_PORT),
- NULL);
- zassert_equal(0, gpio_emul_output_get(gpio_dev,
- GPIO_USB_C1_RT_RST_ODL_PORT),
- NULL);
-}
-
-
-void test_suite_bb_retimer(void)
-{
- ztest_test_suite(bb_retimer,
- ztest_user_unit_test(test_bb_is_fw_update_capable),
- ztest_user_unit_test(test_bb_set_state),
- ztest_user_unit_test(test_bb_set_dfp_state),
- ztest_user_unit_test(test_bb_init));
- ztest_run_test_suite(bb_retimer);
-}
diff --git a/zephyr/test/drivers/src/bc12.c b/zephyr/test/drivers/src/bc12.c
deleted file mode 100644
index 4251448f2c..0000000000
--- a/zephyr/test/drivers/src/bc12.c
+++ /dev/null
@@ -1,280 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-#include <drivers/gpio.h>
-#include <drivers/gpio/gpio_emul.h>
-
-#include "emul/emul_pi3usb9201.h"
-
-#include "timer.h"
-#include "usb_charge.h"
-#include "battery.h"
-#include "extpower.h"
-#include "stubs.h"
-
-#include <logging/log.h>
-LOG_MODULE_REGISTER(test_drivers_bc12, LOG_LEVEL_DBG);
-
-#define EMUL_LABEL DT_NODELABEL(pi3usb9201_emul)
-
-#define PI3USB9201_ORD DT_DEP_ORD(EMUL_LABEL)
-
-/* 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)
-
-#define GPIO_ACOK_OD_PATH DT_PATH(named_gpios, acok_od)
-#define GPIO_ACOK_OD_PORT DT_GPIO_PIN(GPIO_ACOK_OD_PATH, gpios)
-
-static void test_bc12_pi3usb9201_host_mode(void)
-{
- struct i2c_emul *emul = pi3usb9201_emul_get(PI3USB9201_ORD);
- uint8_t a, b;
-
- /*
- * Pretend that the USB-C Port Manager (TCPMv2) has set the port data
- * role to DFP.
- */
- task_set_event(TASK_ID_USB_CHG_P0, 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, NULL);
-
- /* 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);
- task_set_event(TASK_ID_USB_CHG_P0, 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, NULL);
- 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);
- task_set_event(TASK_ID_USB_CHG_P0, 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, NULL);
- 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)
-{
- struct i2c_emul *emul = pi3usb9201_emul_get(PI3USB9201_ORD);
- 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);
- task_set_event(TASK_ID_USB_CHG_P0, 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, NULL);
- pi3usb9201_emul_get_reg(emul, PI3USB9201_REG_CTRL_2, &a);
- b = PI3USB9201_REG_CTRL_2_START_DET;
- zassert_equal(a, b, NULL);
-
- /* Pretend that detection completed. */
- msleep(500);
- pi3usb9201_emul_set_reg(emul, PI3USB9201_REG_CLIENT_STS,
- 1 << detect_result);
- task_set_event(TASK_ID_USB_CHG_P0, 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, NULL);
- 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;
- }
- zassert_equal(charge_manager_get_active_charge_port(),
- port, NULL);
- zassert_equal(charge_manager_get_supplier(),
- supplier, NULL);
- zassert_equal(charge_manager_get_charger_current(),
- current_limit, NULL);
- zassert_equal(charge_manager_get_charger_voltage(),
- voltage, NULL);
-
- /*
- * Pretend that the USB-C Port Manager (TCPMv2) has set the port data
- * role to disconnected.
- */
- msleep(500);
- task_set_event(TASK_ID_USB_CHG_P0, 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, NULL);
- /* 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, NULL);
- zassert_equal(charge_manager_get_charger_voltage(), 0, NULL);
-}
-
-/*
- * 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.
- */
-static void test_bc12_pi3usb9201(void)
-{
- const struct device *batt_pres_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_BATT_PRES_ODL_PATH, gpios));
- const struct device *acok_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_ACOK_OD_PATH, gpios));
- struct i2c_emul *emul = pi3usb9201_emul_get(PI3USB9201_ORD);
- 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(), NULL);
- zassert_ok(gpio_emul_input_set(acok_dev, GPIO_ACOK_OD_PORT, 1), NULL);
- msleep(CONFIG_EXTPOWER_DEBOUNCE_MS + 1);
- zassert_equal(1, extpower_is_present(), NULL);
-
- /* 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.
- */
- task_set_event(TASK_ID_USB_CHG_P0, USB_CHG_EVENT_CC_OPEN);
- task_set_event(TASK_ID_USB_CHG_P1, 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, NULL);
-
- 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);
- }
-}
-
-void test_suite_bc12(void)
-{
- ztest_test_suite(bc12,
- ztest_user_unit_test(test_bc12_pi3usb9201));
- ztest_run_test_suite(bc12);
-}
diff --git a/zephyr/test/drivers/src/bma2x2.c b/zephyr/test/drivers/src/bma2x2.c
deleted file mode 100644
index 8b77464b48..0000000000
--- a/zephyr/test/drivers/src/bma2x2.c
+++ /dev/null
@@ -1,926 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-
-#include "common.h"
-#include "i2c.h"
-#include "emul/emul_bma255.h"
-#include "emul/emul_common_i2c.h"
-
-#include "accelgyro.h"
-#include "motion_sense.h"
-#include "driver/accel_bma2x2.h"
-
-/** How accurate comparision of vectors should be. */
-#define V_EPS 8
-
-#define EMUL_LABEL DT_NODELABEL(bma_emul)
-
-#define BMA_ORD DT_DEP_ORD(EMUL_LABEL)
-
-/** Mutex for test motion sensor */
-static mutex_t sensor_mutex;
-
-/** Rotation used in some tests */
-static const mat33_fp_t test_rotation = {
- { 0, FLOAT_TO_FP(1), 0},
- { FLOAT_TO_FP(-1), 0, 0},
- { 0, 0, FLOAT_TO_FP(-1)}
-};
-
-/** Rotate given vector by test rotation */
-void rotate_int3v_by_test_rotation(int16_t *v)
-{
- int16_t t;
-
- t = v[0];
- v[0] = -v[1];
- v[1] = t;
- v[2] = -v[2];
-}
-
-static struct accelgyro_saved_data_t acc_data;
-
-/** Mock minimal motion sensor setup required for bma2x2 driver test */
-static struct motion_sensor_t ms = {
- .name = "bma_emul",
- .type = MOTIONSENSE_TYPE_ACCEL,
- .drv = &bma2x2_accel_drv,
- .mutex = &sensor_mutex,
- .drv_data = &acc_data,
- .port = NAMED_I2C(accel),
- .i2c_spi_addr_flags = DT_REG_ADDR(EMUL_LABEL),
- .rot_standard_ref = NULL,
- .current_range = 0,
-};
-
-/** Set emulator offset values to vector of three int16_t */
-static void set_emul_offset(struct i2c_emul *emul, int16_t *offset)
-{
- bma_emul_set_off(emul, BMA_EMUL_AXIS_X, offset[0]);
- bma_emul_set_off(emul, BMA_EMUL_AXIS_Y, offset[1]);
- bma_emul_set_off(emul, BMA_EMUL_AXIS_Z, offset[2]);
-}
-
-/** Save emulator offset values to vector of three int16_t */
-static void get_emul_offset(struct i2c_emul *emul, int16_t *offset)
-{
- offset[0] = bma_emul_get_off(emul, BMA_EMUL_AXIS_X);
- offset[1] = bma_emul_get_off(emul, BMA_EMUL_AXIS_Y);
- offset[2] = bma_emul_get_off(emul, BMA_EMUL_AXIS_Z);
-}
-
-/** Set emulator accelerometer values to vector of three int16_t */
-static void set_emul_acc(struct i2c_emul *emul, int16_t *acc)
-{
- bma_emul_set_acc(emul, BMA_EMUL_AXIS_X, acc[0]);
- bma_emul_set_acc(emul, BMA_EMUL_AXIS_Y, acc[1]);
- bma_emul_set_acc(emul, BMA_EMUL_AXIS_Z, acc[2]);
-}
-
-/** Convert accelerometer read to units used by emulator */
-static void drv_acc_to_emul(intv3_t drv, int range, int16_t *out)
-{
- const int scale = MOTION_SCALING_FACTOR / BMA_EMUL_1G;
-
- out[0] = drv[0] * range / scale;
- out[1] = drv[1] * range / scale;
- out[2] = drv[2] * range / scale;
-}
-
-/** Compare two vectors of three int16_t */
-static void compare_int3v_f(int16_t *exp_v, int16_t *v, int line)
-{
- int i;
-
- for (i = 0; i < 3; i++) {
- zassert_within(exp_v[i], v[i], V_EPS,
- "Expected [%d; %d; %d], got [%d; %d; %d]; line: %d",
- exp_v[0], exp_v[1], exp_v[2], v[0], v[1], v[2], line);
- }
-}
-#define compare_int3v(exp_v, v) compare_int3v_f(exp_v, v, __LINE__)
-
-/** Data for reset fail function */
-struct reset_func_data {
- /** Fail for given attempts */
- int fail_attempts;
- /** Do not fail for given attempts */
- int ok_before_fail;
- /** Reset register value after given attempts */
- int reset_value;
-};
-
-/**
- * Custom emulator function used in init test. It returns cmd soft when reset
- * register is accessed data.reset_value times. Error is returned after
- * accessing register data.ok_before_fail times. Error is returned during next
- * data.fail_attempts times.
- */
-static int emul_read_reset(struct i2c_emul *emul, int reg, uint8_t *buf,
- int bytes, void *data)
-{
- struct reset_func_data *d = data;
-
- reg = bma_emul_access_reg(emul, reg, bytes, true /* = read */);
- if (reg != BMA2x2_RST_ADDR) {
- return 1;
- }
-
- if (d->reset_value > 0) {
- d->reset_value--;
- bma_emul_set_reg(emul, BMA2x2_RST_ADDR, BMA2x2_CMD_SOFT_RESET);
- } else {
- bma_emul_set_reg(emul, BMA2x2_RST_ADDR, 0);
- }
-
- if (d->ok_before_fail > 0) {
- d->ok_before_fail--;
- return 1;
- }
-
- if (d->fail_attempts > 0) {
- d->fail_attempts--;
- return -EIO;
- }
-
- return 1;
-}
-
-/**
- * Test get offset with and without rotation. Also test behaviour on I2C error.
- */
-static void test_bma_get_offset(void)
-{
- struct i2c_emul *emul;
- int16_t ret_offset[3];
- int16_t exp_offset[3];
- int16_t temp;
-
- emul = bma_emul_get(BMA_ORD);
-
- /* Test fail on each axis */
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_OFFSET_X_AXIS_ADDR);
- zassert_equal(EC_ERROR_INVAL,
- ms.drv->get_offset(&ms, ret_offset, &temp), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_OFFSET_Y_AXIS_ADDR);
- zassert_equal(EC_ERROR_INVAL,
- ms.drv->get_offset(&ms, ret_offset, &temp), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_OFFSET_Z_AXIS_ADDR);
- zassert_equal(EC_ERROR_INVAL,
- ms.drv->get_offset(&ms, ret_offset, &temp), NULL);
-
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Set emulator offset */
- exp_offset[0] = BMA_EMUL_1G / 10;
- exp_offset[1] = BMA_EMUL_1G / 20;
- exp_offset[2] = -(int)BMA_EMUL_1G / 30;
- set_emul_offset(emul, exp_offset);
- /* Disable rotation */
- ms.rot_standard_ref = NULL;
-
- /* Test get offset without rotation */
- zassert_equal(EC_SUCCESS, ms.drv->get_offset(&ms, ret_offset, &temp),
- NULL);
- zassert_equal(temp, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- compare_int3v(exp_offset, ret_offset);
-
- /* Setup rotation and rotate expected offset */
- ms.rot_standard_ref = &test_rotation;
- rotate_int3v_by_test_rotation(exp_offset);
-
- /* Test get offset with rotation */
- zassert_equal(EC_SUCCESS, ms.drv->get_offset(&ms, ret_offset, &temp),
- NULL);
- zassert_equal(temp, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- compare_int3v(exp_offset, ret_offset);
-}
-
-/**
- * Test set offset with and without rotation. Also test behaviour on I2C error.
- */
-static void test_bma_set_offset(void)
-{
- struct i2c_emul *emul;
- int16_t ret_offset[3];
- int16_t exp_offset[3];
- int16_t temp = 0;
-
- emul = bma_emul_get(BMA_ORD);
-
- /* Test fail on each axis */
- i2c_common_emul_set_write_fail_reg(emul, BMA2x2_OFFSET_X_AXIS_ADDR);
- zassert_equal(EC_ERROR_INVAL, ms.drv->set_offset(&ms, exp_offset, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, BMA2x2_OFFSET_Y_AXIS_ADDR);
- zassert_equal(EC_ERROR_INVAL, ms.drv->set_offset(&ms, exp_offset, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, BMA2x2_OFFSET_Z_AXIS_ADDR);
- zassert_equal(EC_ERROR_INVAL, ms.drv->set_offset(&ms, exp_offset, temp),
- NULL);
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Set input offset */
- exp_offset[0] = BMA_EMUL_1G / 10;
- exp_offset[1] = BMA_EMUL_1G / 20;
- exp_offset[2] = -(int)BMA_EMUL_1G / 30;
- /* Disable rotation */
- ms.rot_standard_ref = NULL;
-
- /* Test set offset without rotation */
- zassert_equal(EC_SUCCESS, ms.drv->set_offset(&ms, exp_offset, temp),
- NULL);
- get_emul_offset(emul, ret_offset);
- compare_int3v(exp_offset, ret_offset);
-
- /* Setup rotation and rotate input for set_offset function */
- ms.rot_standard_ref = &test_rotation;
- ret_offset[0] = exp_offset[0];
- ret_offset[1] = exp_offset[1];
- ret_offset[2] = exp_offset[2];
- rotate_int3v_by_test_rotation(ret_offset);
-
- /* Test set offset with rotation */
- zassert_equal(EC_SUCCESS, ms.drv->set_offset(&ms, ret_offset, temp),
- NULL);
- get_emul_offset(emul, ret_offset);
- compare_int3v(exp_offset, ret_offset);
-}
-
-/*
- * Try to set range and check if expected range was set in driver and in
- * emulator.
- */
-static void check_set_range_f(struct i2c_emul *emul, int range, int rnd,
- int exp_range, int line)
-{
- uint8_t exp_range_reg;
- uint8_t range_reg;
-
- zassert_equal(EC_SUCCESS, ms.drv->set_range(&ms, range, rnd),
- "set_range failed; line: %d", line);
- zassert_equal(exp_range, ms.current_range,
- "Expected range %d, got %d; line %d",
- exp_range, ms.current_range, line);
- range_reg = bma_emul_get_reg(emul, BMA2x2_RANGE_SELECT_ADDR);
- range_reg &= BMA2x2_RANGE_SELECT_MSK;
-
- switch (exp_range) {
- case 2:
- exp_range_reg = BMA2x2_RANGE_2G;
- break;
- case 4:
- exp_range_reg = BMA2x2_RANGE_4G;
- break;
- case 8:
- exp_range_reg = BMA2x2_RANGE_8G;
- break;
- case 16:
- exp_range_reg = BMA2x2_RANGE_16G;
- break;
- default:
- /* Unknown expected range */
- zassert_unreachable(
- "Expected range %d not supported by device; line %d",
- exp_range, line);
- return;
- }
-
- zassert_equal(exp_range_reg, range_reg,
- "Expected range reg 0x%x, got 0x%x; line %d",
- exp_range_reg, range_reg, line);
-}
-#define check_set_range(emul, range, rnd, exp_range) \
- check_set_range_f(emul, range, rnd, exp_range, __LINE__)
-
-/** Test set range with and without I2C errors. */
-static void test_bma_set_range(void)
-{
- struct i2c_emul *emul;
- int start_range;
-
- emul = bma_emul_get(BMA_ORD);
-
- /* Setup starting range, shouldn't be changed on error */
- start_range = 2;
- ms.current_range = start_range;
- bma_emul_set_reg(emul, BMA2x2_RANGE_SELECT_ADDR, BMA2x2_RANGE_2G);
- /* Setup emulator fail on read */
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_RANGE_SELECT_ADDR);
-
- /* Test fail on read */
- zassert_equal(EC_ERROR_INVAL, ms.drv->set_range(&ms, 12, 0), NULL);
- zassert_equal(start_range, ms.current_range, NULL);
- zassert_equal(BMA2x2_RANGE_2G,
- bma_emul_get_reg(emul, BMA2x2_RANGE_SELECT_ADDR), NULL);
- zassert_equal(EC_ERROR_INVAL, ms.drv->set_range(&ms, 12, 1), NULL);
- zassert_equal(start_range, ms.current_range, NULL);
- zassert_equal(BMA2x2_RANGE_2G,
- bma_emul_get_reg(emul, BMA2x2_RANGE_SELECT_ADDR), NULL);
-
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Setup emulator fail on write */
- i2c_common_emul_set_write_fail_reg(emul, BMA2x2_RANGE_SELECT_ADDR);
-
- /* Test fail on write */
- zassert_equal(EC_ERROR_INVAL, ms.drv->set_range(&ms, 12, 0), NULL);
- zassert_equal(start_range, ms.current_range, NULL);
- zassert_equal(BMA2x2_RANGE_2G,
- bma_emul_get_reg(emul, BMA2x2_RANGE_SELECT_ADDR), NULL);
- zassert_equal(EC_ERROR_INVAL, ms.drv->set_range(&ms, 12, 1), NULL);
- zassert_equal(start_range, ms.current_range, NULL);
- zassert_equal(BMA2x2_RANGE_2G,
- bma_emul_get_reg(emul, BMA2x2_RANGE_SELECT_ADDR), NULL);
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test setting range with rounding down */
- check_set_range(emul, 1, 0, 2);
- check_set_range(emul, 2, 0, 2);
- check_set_range(emul, 3, 0, 2);
- check_set_range(emul, 4, 0, 4);
- check_set_range(emul, 5, 0, 4);
- check_set_range(emul, 6, 0, 4);
- check_set_range(emul, 7, 0, 4);
- check_set_range(emul, 8, 0, 8);
- check_set_range(emul, 9, 0, 8);
- check_set_range(emul, 15, 0, 8);
- check_set_range(emul, 16, 0, 16);
- check_set_range(emul, 17, 0, 16);
-
- /* Test setting range with rounding up */
- check_set_range(emul, 1, 1, 2);
- check_set_range(emul, 2, 1, 2);
- check_set_range(emul, 3, 1, 4);
- check_set_range(emul, 4, 1, 4);
- check_set_range(emul, 5, 1, 8);
- check_set_range(emul, 6, 1, 8);
- check_set_range(emul, 7, 1, 8);
- check_set_range(emul, 8, 1, 8);
- check_set_range(emul, 9, 1, 16);
- check_set_range(emul, 15, 1, 16);
- check_set_range(emul, 16, 1, 16);
- check_set_range(emul, 17, 1, 16);
-}
-
-/** Test init with and without I2C errors. */
-static void test_bma_init(void)
-{
- struct reset_func_data reset_func_data;
- struct i2c_emul *emul;
-
- emul = bma_emul_get(BMA_ORD);
-
- /* Setup emulator fail read function */
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_CHIP_ID_ADDR);
-
- /* Test fail on chip id read */
- zassert_equal(EC_ERROR_UNKNOWN, ms.drv->init(&ms), NULL);
-
- /* Disable failing on chip id read, but set wrong value */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- bma_emul_set_reg(emul, BMA2x2_CHIP_ID_ADDR, 23);
-
- /* Test wrong chip id */
- zassert_equal(EC_ERROR_ACCESS_DENIED, ms.drv->init(&ms), NULL);
-
- /* Set correct chip id, but fail on reset reg read */
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_RST_ADDR);
- bma_emul_set_reg(emul, BMA2x2_CHIP_ID_ADDR, BMA255_CHIP_ID_MAJOR);
-
- /* Test fail on reset register read */
- zassert_equal(EC_ERROR_INVAL, ms.drv->init(&ms), NULL);
-
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Setup emulator fail on write */
- i2c_common_emul_set_write_fail_reg(emul, BMA2x2_RST_ADDR);
-
- /* Test fail on reset register write */
- zassert_equal(EC_ERROR_INVAL, ms.drv->init(&ms), NULL);
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Setup emulator fail reset read function */
- reset_func_data.ok_before_fail = 1;
- reset_func_data.fail_attempts = 100;
- reset_func_data.reset_value = 0;
- i2c_common_emul_set_read_func(emul, emul_read_reset, &reset_func_data);
-
- /* Test fail on too many reset read errors */
- zassert_equal(EC_ERROR_TIMEOUT, ms.drv->init(&ms), NULL);
-
- /* Test success after reset read errors */
- reset_func_data.ok_before_fail = 1;
- reset_func_data.fail_attempts = 3;
- zassert_equal(EC_RES_SUCCESS, ms.drv->init(&ms), NULL);
-
- /* Test success without read errors */
- reset_func_data.fail_attempts = 0;
- zassert_equal(EC_RES_SUCCESS, ms.drv->init(&ms), NULL);
-
- /* Test fail on too many reset read wrong value */
- reset_func_data.fail_attempts = 0;
- reset_func_data.reset_value = 100;
- zassert_equal(EC_ERROR_TIMEOUT, ms.drv->init(&ms), NULL);
-
- /* Test success on few reset read wrong value */
- reset_func_data.fail_attempts = 0;
- reset_func_data.reset_value = 4;
- zassert_equal(EC_RES_SUCCESS, ms.drv->init(&ms), NULL);
-
- /* Remove custom emulator read function */
- i2c_common_emul_set_read_func(emul, NULL, NULL);
-}
-
-/*
- * Try to set data rate and check if expected rate was set in driver and in
- * emulator.
- */
-static void check_set_rate_f(struct i2c_emul *emul, int rate, int rnd,
- int exp_rate, int line)
-{
- uint8_t exp_rate_reg;
- uint8_t rate_reg;
- int drv_rate;
-
- zassert_equal(EC_SUCCESS, ms.drv->set_data_rate(&ms, rate, rnd),
- "set_data_rate failed; line: %d", line);
- drv_rate = ms.drv->get_data_rate(&ms);
- zassert_equal(exp_rate, drv_rate, "Expected rate %d, got %d; line %d",
- exp_rate, drv_rate, line);
- rate_reg = bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR);
- rate_reg &= BMA2x2_BW_MSK;
-
- switch (exp_rate) {
- case 7812:
- exp_rate_reg = BMA2x2_BW_7_81HZ;
- break;
- case 15625:
- exp_rate_reg = BMA2x2_BW_15_63HZ;
- break;
- case 31250:
- exp_rate_reg = BMA2x2_BW_31_25HZ;
- break;
- case 62500:
- exp_rate_reg = BMA2x2_BW_62_50HZ;
- break;
- case 125000:
- exp_rate_reg = BMA2x2_BW_125HZ;
- break;
- case 250000:
- exp_rate_reg = BMA2x2_BW_250HZ;
- break;
- case 500000:
- exp_rate_reg = BMA2x2_BW_500HZ;
- break;
- case 1000000:
- exp_rate_reg = BMA2x2_BW_1000HZ;
- break;
- default:
- /* Unknown expected rate */
- zassert_unreachable(
- "Expected rate %d not supported by device; line %d",
- exp_rate, line);
- return;
- }
-
- zassert_equal(exp_rate_reg, rate_reg,
- "Expected rate reg 0x%x, got 0x%x; line %d",
- exp_rate_reg, rate_reg, line);
-}
-#define check_set_rate(emul, rate, rnd, exp_rate) \
- check_set_rate_f(emul, rate, rnd, exp_rate, __LINE__)
-
-/** Test set and get rate with and without I2C errors. */
-static void test_bma_rate(void)
-{
- struct i2c_emul *emul;
- uint8_t reg_rate;
- int drv_rate;
-
- emul = bma_emul_get(BMA_ORD);
-
- /* Test setting rate with rounding down */
- check_set_rate(emul, 1, 0, 7812);
- check_set_rate(emul, 1, 0, 7812);
- check_set_rate(emul, 7811, 0, 7812);
- check_set_rate(emul, 7812, 0, 7812);
- check_set_rate(emul, 7813, 0, 7812);
- check_set_rate(emul, 15624, 0, 7812);
- check_set_rate(emul, 15625, 0, 15625);
- check_set_rate(emul, 15626, 0, 15625);
- check_set_rate(emul, 31249, 0, 15625);
- check_set_rate(emul, 31250, 0, 31250);
- check_set_rate(emul, 31251, 0, 31250);
- check_set_rate(emul, 62499, 0, 31250);
- check_set_rate(emul, 62500, 0, 62500);
- check_set_rate(emul, 62501, 0, 62500);
- check_set_rate(emul, 124999, 0, 62500);
- check_set_rate(emul, 125000, 0, 125000);
- check_set_rate(emul, 125001, 0, 125000);
- check_set_rate(emul, 249999, 0, 125000);
- check_set_rate(emul, 250000, 0, 250000);
- check_set_rate(emul, 250001, 0, 250000);
- check_set_rate(emul, 499999, 0, 250000);
- check_set_rate(emul, 500000, 0, 500000);
- check_set_rate(emul, 500001, 0, 500000);
- check_set_rate(emul, 999999, 0, 500000);
- check_set_rate(emul, 1000000, 0, 1000000);
- check_set_rate(emul, 1000001, 0, 1000000);
- check_set_rate(emul, 2000000, 0, 1000000);
-
- /* Test setting rate with rounding up */
- check_set_rate(emul, 1, 1, 7812);
- check_set_rate(emul, 1, 1, 7812);
- check_set_rate(emul, 7811, 1, 7812);
- check_set_rate(emul, 7812, 1, 7812);
- check_set_rate(emul, 7813, 1, 15625);
- check_set_rate(emul, 15624, 1, 15625);
- check_set_rate(emul, 15625, 1, 15625);
- check_set_rate(emul, 15626, 1, 31250);
- check_set_rate(emul, 31249, 1, 31250);
- check_set_rate(emul, 31250, 1, 31250);
- check_set_rate(emul, 31251, 1, 62500);
- check_set_rate(emul, 62499, 1, 62500);
- check_set_rate(emul, 62500, 1, 62500);
- check_set_rate(emul, 62501, 1, 125000);
- check_set_rate(emul, 124999, 1, 125000);
- check_set_rate(emul, 125000, 1, 125000);
- check_set_rate(emul, 125001, 1, 250000);
- check_set_rate(emul, 249999, 1, 250000);
- check_set_rate(emul, 250000, 1, 250000);
- check_set_rate(emul, 250001, 1, 500000);
- check_set_rate(emul, 499999, 1, 500000);
- check_set_rate(emul, 500000, 1, 500000);
- check_set_rate(emul, 500001, 1, 1000000);
- check_set_rate(emul, 999999, 1, 1000000);
- check_set_rate(emul, 1000000, 1, 1000000);
- check_set_rate(emul, 1000001, 1, 1000000);
- check_set_rate(emul, 2000000, 1, 1000000);
-
- /* Current rate shouldn't be changed on error */
- drv_rate = ms.drv->get_data_rate(&ms);
- reg_rate = bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR);
-
- /* Setup emulator fail on read */
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_BW_SELECT_ADDR);
-
- /* Test fail on read */
- zassert_equal(EC_ERROR_INVAL, ms.drv->set_data_rate(&ms, 15625, 0),
- NULL);
- zassert_equal(drv_rate, ms.drv->get_data_rate(&ms), NULL);
- zassert_equal(reg_rate, bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR),
- NULL);
- zassert_equal(EC_ERROR_INVAL, ms.drv->set_data_rate(&ms, 15625, 1),
- NULL);
- zassert_equal(drv_rate, ms.drv->get_data_rate(&ms), NULL);
- zassert_equal(reg_rate,
- bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR), NULL);
-
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Setup emulator fail on write */
- i2c_common_emul_set_write_fail_reg(emul, BMA2x2_BW_SELECT_ADDR);
-
- /* Test fail on write */
- zassert_equal(EC_ERROR_INVAL, ms.drv->set_data_rate(&ms, 15625, 0),
- NULL);
- zassert_equal(drv_rate, ms.drv->get_data_rate(&ms), NULL);
- zassert_equal(reg_rate, bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR),
- NULL);
- zassert_equal(EC_ERROR_INVAL, ms.drv->set_data_rate(&ms, 15625, 1),
- NULL);
- zassert_equal(drv_rate, ms.drv->get_data_rate(&ms), NULL);
- zassert_equal(reg_rate, bma_emul_get_reg(emul, BMA2x2_BW_SELECT_ADDR),
- NULL);
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-}
-
-/** Test read with and without I2C errors. */
-static void test_bma_read(void)
-{
- struct i2c_emul *emul;
- int16_t ret_acc[3];
- int16_t exp_acc[3];
- intv3_t ret_acc_v;
-
- emul = bma_emul_get(BMA_ORD);
-
- /* Set offset 0 to simplify test */
- bma_emul_set_off(emul, BMA_EMUL_AXIS_X, 0);
- bma_emul_set_off(emul, BMA_EMUL_AXIS_Y, 0);
- bma_emul_set_off(emul, BMA_EMUL_AXIS_Z, 0);
-
- /* Test fail on each axis */
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_X_AXIS_LSB_ADDR);
- zassert_equal(EC_ERROR_INVAL, ms.drv->read(&ms, ret_acc_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_X_AXIS_MSB_ADDR);
- zassert_equal(EC_ERROR_INVAL, ms.drv->read(&ms, ret_acc_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_Y_AXIS_LSB_ADDR);
- zassert_equal(EC_ERROR_INVAL, ms.drv->read(&ms, ret_acc_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_Y_AXIS_MSB_ADDR);
- zassert_equal(EC_ERROR_INVAL, ms.drv->read(&ms, ret_acc_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_Z_AXIS_LSB_ADDR);
- zassert_equal(EC_ERROR_INVAL, ms.drv->read(&ms, ret_acc_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMA2x2_Z_AXIS_MSB_ADDR);
- zassert_equal(EC_ERROR_INVAL, ms.drv->read(&ms, ret_acc_v), NULL);
-
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Set input accelerometer values */
- exp_acc[0] = BMA_EMUL_1G / 10;
- exp_acc[1] = BMA_EMUL_1G / 20;
- exp_acc[2] = -(int)BMA_EMUL_1G / 30;
- set_emul_acc(emul, exp_acc);
- /* Disable rotation */
- ms.rot_standard_ref = NULL;
- /* Set range to 2G */
- zassert_equal(EC_SUCCESS, ms.drv->set_range(&ms, 2, 0), NULL);
-
- /* Test read without rotation */
- zassert_equal(EC_SUCCESS, ms.drv->read(&ms, ret_acc_v), NULL);
- drv_acc_to_emul(ret_acc_v, 2, ret_acc);
- compare_int3v(exp_acc, ret_acc);
-
- /* Set range to 4G */
- zassert_equal(EC_SUCCESS, ms.drv->set_range(&ms, 4, 0), NULL);
-
- /* Test read without rotation */
- zassert_equal(EC_SUCCESS, ms.drv->read(&ms, ret_acc_v), NULL);
- drv_acc_to_emul(ret_acc_v, 4, ret_acc);
- compare_int3v(exp_acc, ret_acc);
-
- /* Setup rotation and rotate expected vector */
- ms.rot_standard_ref = &test_rotation;
- rotate_int3v_by_test_rotation(exp_acc);
- /* Set range to 2G */
- zassert_equal(EC_SUCCESS, ms.drv->set_range(&ms, 2, 0), NULL);
-
- /* Test read with rotation */
- zassert_equal(EC_SUCCESS, ms.drv->read(&ms, ret_acc_v), NULL);
- drv_acc_to_emul(ret_acc_v, 2, ret_acc);
- compare_int3v(exp_acc, ret_acc);
-
- /* Set range to 4G */
- zassert_equal(EC_SUCCESS, ms.drv->set_range(&ms, 4, 0), NULL);
-
- /* Test read with rotation */
- zassert_equal(EC_SUCCESS, ms.drv->read(&ms, ret_acc_v), NULL);
- drv_acc_to_emul(ret_acc_v, 4, ret_acc);
- compare_int3v(exp_acc, ret_acc);
-}
-
-/** Data for functions used in perform_calib test */
-struct calib_func_data {
- /** Time when offset compensation where triggered */
- int calib_start;
- /** Time how long offset cal ready should be unset */
- int time;
- /** Flag indicate if read should fail after compensation is triggered */
- int read_fail;
-};
-
-/**
- * Custom emulator read function used in perform_calib test. It controls if
- * cal ready bit in offset control register should be set. It is set after
- * data.time miliseconds passed from data.calib_start time. Function returns
- * error when offset control register is accessed when cal ready bit is not set
- * and data.read_fail is not zero.
- */
-static int emul_read_calib_func(struct i2c_emul *emul, int reg, uint8_t *val,
- int bytes, void *data)
-{
- struct calib_func_data *d = data;
- uint8_t reg_val;
- int cur_time;
-
- reg = bma_emul_access_reg(emul, reg, bytes, true /* = read */);
- if (reg != BMA2x2_OFFSET_CTRL_ADDR) {
- return 1;
- }
-
- reg_val = bma_emul_get_reg(emul, BMA2x2_OFFSET_CTRL_ADDR);
- cur_time = k_uptime_get_32();
- if (cur_time - d->calib_start < d->time) {
- if (d->read_fail) {
- return -EIO;
- }
- reg_val &= ~BMA2x2_OFFSET_CAL_READY;
- } else {
- reg_val |= BMA2x2_OFFSET_CAL_READY;
- }
- bma_emul_set_reg(emul, BMA2x2_OFFSET_CTRL_ADDR, reg_val);
-
- return 1;
-}
-
-/**
- * Custom emulator write function used in perform_calib test. It sets
- * calib_start field in data with time when offset compensation process was
- * triggerd.
- */
-static int emul_write_calib_func(struct i2c_emul *emul, int reg, uint8_t val,
- int bytes, void *data)
-{
- struct calib_func_data *d = data;
-
- reg = bma_emul_access_reg(emul, reg, bytes, false /* = read */);
- if (reg != BMA2x2_OFFSET_CTRL_ADDR) {
- return 1;
- }
-
- if (val & BMA2x2_OFFSET_TRIGGER_MASK) {
- d->calib_start = k_uptime_get_32();
- }
-
- return 1;
-}
-
-/** Test offset compensation with and without I2C errors. */
-static void test_bma_perform_calib(void)
-{
- struct calib_func_data func_data;
- struct i2c_emul *emul;
- int16_t start_off[3];
- int16_t exp_off[3];
- int16_t ret_off[3];
- int range;
- int rate;
- mat33_fp_t rot = {
- { FLOAT_TO_FP(1), 0, 0},
- { 0, FLOAT_TO_FP(1), 0},
- { 0, 0, FLOAT_TO_FP(-1)}
- };
-
- emul = bma_emul_get(BMA_ORD);
-
- /* Range and rate cannot change after calibration */
- range = 4;
- rate = 125000;
- zassert_equal(EC_SUCCESS, ms.drv->set_range(&ms, range, 0), NULL);
- zassert_equal(EC_SUCCESS, ms.drv->set_data_rate(&ms, rate, 0), NULL);
-
- /* Set offset 0 */
- start_off[0] = 0;
- start_off[1] = 0;
- start_off[2] = 0;
- set_emul_offset(emul, start_off);
-
- /* Set input accelerometer values */
- exp_off[0] = BMA_EMUL_1G / 10;
- exp_off[1] = BMA_EMUL_1G / 20;
- exp_off[2] = -(int)BMA_EMUL_1G / 30;
- set_emul_acc(emul, exp_off);
-
- /*
- * Expected offset is [-X, -Y, 1G - Z] for no rotation or positive
- * rotation on Z axis
- */
- exp_off[0] = -exp_off[0];
- exp_off[1] = -exp_off[1];
- exp_off[2] = BMA_EMUL_1G - exp_off[2];
-
- /* Setup emulator calibration functions */
- i2c_common_emul_set_read_func(emul, emul_read_calib_func, &func_data);
- i2c_common_emul_set_write_func(emul, emul_write_calib_func, &func_data);
-
- /* Setup emulator to fail on first access to offset control register */
- func_data.calib_start = k_uptime_get_32();
- func_data.read_fail = 1;
- func_data.time = 1000000;
-
- /* Test success on disabling calibration */
- zassert_equal(EC_SUCCESS, ms.drv->perform_calib(&ms, 0), NULL);
- zassert_equal(range, ms.current_range, NULL);
- zassert_equal(rate, ms.drv->get_data_rate(&ms), NULL);
-
- /* Test fail on first access to offset control register */
- zassert_equal(EC_ERROR_INVAL, ms.drv->perform_calib(&ms, 1), NULL);
- zassert_equal(range, ms.current_range, NULL);
- zassert_equal(rate, ms.drv->get_data_rate(&ms), NULL);
-
- /* Setup emulator to return cal not ready */
- func_data.calib_start = k_uptime_get_32();
- func_data.read_fail = 0;
- func_data.time = 1000000;
-
- /* Test fail on cal not ready */
- zassert_equal(EC_ERROR_ACCESS_DENIED, ms.drv->perform_calib(&ms, 1),
- NULL);
- zassert_equal(range, ms.current_range, NULL);
- zassert_equal(rate, ms.drv->get_data_rate(&ms), NULL);
-
- /*
- * Setup emulator to fail on access to offset control register after
- * triggering offset compensation
- */
- func_data.calib_start = 0;
- func_data.read_fail = 1;
- func_data.time = 160;
-
- /* Test fail on read during offset compensation */
- zassert_equal(EC_ERROR_INVAL, ms.drv->perform_calib(&ms, 1), NULL);
- zassert_equal(range, ms.current_range, NULL);
- zassert_equal(rate, ms.drv->get_data_rate(&ms), NULL);
-
- /*
- * Setup emulator to return cal not ready for 1s after triggering
- * offset compensation
- */
- func_data.calib_start = 0;
- func_data.read_fail = 0;
- func_data.time = 1000;
-
- zassert_equal(EC_RES_TIMEOUT, ms.drv->perform_calib(&ms, 1), NULL);
- zassert_equal(range, ms.current_range, NULL);
- zassert_equal(rate, ms.drv->get_data_rate(&ms), NULL);
-
- /*
- * Setup emulator to return cal not ready for 160ms after triggering
- * offset compensation
- */
- func_data.calib_start = 0;
- func_data.read_fail = 0;
- func_data.time = 160;
- /* Disable rotation */
- ms.rot_standard_ref = NULL;
-
- /* Test successful offset compenastion without rotation */
- zassert_equal(EC_SUCCESS, ms.drv->perform_calib(&ms, 1), NULL);
- zassert_equal(range, ms.current_range, NULL);
- zassert_equal(rate, ms.drv->get_data_rate(&ms), NULL);
- get_emul_offset(emul, ret_off);
- compare_int3v(exp_off, ret_off);
-
- func_data.calib_start = 0;
- /* Enable rotation with negative value on Z axis */
- ms.rot_standard_ref = &rot;
- /* Expected offset -1G - accelerometer[Z] */
- exp_off[2] = -((int)BMA_EMUL_1G) - bma_emul_get_acc(emul,
- BMA_EMUL_AXIS_Z);
-
- /* Test successful offset compenastion with negative Z rotation */
- zassert_equal(EC_SUCCESS, ms.drv->perform_calib(&ms, 1), NULL);
- zassert_equal(range, ms.current_range, NULL);
- zassert_equal(rate, ms.drv->get_data_rate(&ms), NULL);
- get_emul_offset(emul, ret_off);
- compare_int3v(exp_off, ret_off);
-
- func_data.calib_start = 0;
- /* Set positive rotation on Z axis */
- rot[2][2] = FLOAT_TO_FP(1);
- /* Expected offset 1G - accelerometer[Z] */
- exp_off[2] = BMA_EMUL_1G - bma_emul_get_acc(emul, BMA_EMUL_AXIS_Z);
-
- /* Test successful offset compenastion with positive Z rotation */
- zassert_equal(EC_SUCCESS, ms.drv->perform_calib(&ms, 1), NULL);
- zassert_equal(range, ms.current_range, NULL);
- zassert_equal(rate, ms.drv->get_data_rate(&ms), NULL);
- get_emul_offset(emul, ret_off);
- compare_int3v(exp_off, ret_off);
-
- /* Remove custom emulator functions */
- i2c_common_emul_set_read_func(emul, NULL, NULL);
- i2c_common_emul_set_write_func(emul, NULL, NULL);
-}
-
-/** Test get resolution. */
-static void test_bma_get_resolution(void)
-{
- /* Resolution should be always 12 bits */
- zassert_equal(12, ms.drv->get_resolution(&ms), NULL);
-}
-
-void test_suite_bma2x2(void)
-{
- k_mutex_init(&sensor_mutex);
-
- ztest_test_suite(bma2x2,
- ztest_user_unit_test(test_bma_get_offset),
- ztest_user_unit_test(test_bma_set_offset),
- ztest_user_unit_test(test_bma_set_range),
- ztest_user_unit_test(test_bma_init),
- ztest_user_unit_test(test_bma_rate),
- ztest_user_unit_test(test_bma_read),
- ztest_user_unit_test(test_bma_perform_calib),
- ztest_user_unit_test(test_bma_get_resolution));
- ztest_run_test_suite(bma2x2);
-}
diff --git a/zephyr/test/drivers/src/bmi160.c b/zephyr/test/drivers/src/bmi160.c
deleted file mode 100644
index ceb55896eb..0000000000
--- a/zephyr/test/drivers/src/bmi160.c
+++ /dev/null
@@ -1,1873 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-
-#include "common.h"
-#include "i2c.h"
-#include "emul/emul_bmi.h"
-#include "emul/emul_common_i2c.h"
-
-#include "motion_sense_fifo.h"
-#include "driver/accelgyro_bmi160.h"
-#include "driver/accelgyro_bmi_common.h"
-
-#define BMI_ORD DT_DEP_ORD(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))
-#define BMI_INT_EVENT \
- TASK_EVENT_MOTION_SENSOR_INTERRUPT(SENSOR_ID(DT_ALIAS(bmi160_int)))
-
-/** How accurate comparision of vectors should be */
-#define V_EPS 8
-
-/** Convert from one type of vector to another */
-#define convert_int3v_int16(v, r) do { \
- r[0] = v[0]; \
- r[1] = v[1]; \
- r[2] = v[2]; \
- } while (0)
-
-/** Rotation used in some tests */
-static const mat33_fp_t test_rotation = {
- { 0, FLOAT_TO_FP(1), 0},
- { FLOAT_TO_FP(-1), 0, 0},
- { 0, 0, FLOAT_TO_FP(-1)}
-};
-/** Rotate given vector by test rotation */
-static void rotate_int3v_by_test_rotation(intv3_t v)
-{
- int16_t t;
-
- t = v[0];
- v[0] = -v[1];
- v[1] = t;
- v[2] = -v[2];
-}
-
-/** Set emulator accelerometer offset values to intv3_t vector */
-static void set_emul_acc_offset(struct i2c_emul *emul, intv3_t offset)
-{
- bmi_emul_set_off(emul, BMI_EMUL_ACC_X, offset[0]);
- bmi_emul_set_off(emul, BMI_EMUL_ACC_Y, offset[1]);
- bmi_emul_set_off(emul, BMI_EMUL_ACC_Z, offset[2]);
-}
-
-/** Save emulator accelerometer offset values to intv3_t vector */
-static void get_emul_acc_offset(struct i2c_emul *emul, intv3_t offset)
-{
- offset[0] = bmi_emul_get_off(emul, BMI_EMUL_ACC_X);
- offset[1] = bmi_emul_get_off(emul, BMI_EMUL_ACC_Y);
- offset[2] = bmi_emul_get_off(emul, BMI_EMUL_ACC_Z);
-}
-
-/** Set emulator accelerometer values to intv3_t vector */
-static void set_emul_acc(struct i2c_emul *emul, intv3_t acc)
-{
- bmi_emul_set_value(emul, BMI_EMUL_ACC_X, acc[0]);
- bmi_emul_set_value(emul, BMI_EMUL_ACC_Y, acc[1]);
- bmi_emul_set_value(emul, BMI_EMUL_ACC_Z, acc[2]);
-}
-
-/** Set emulator gyroscope offset values to intv3_t vector */
-static void set_emul_gyr_offset(struct i2c_emul *emul, intv3_t offset)
-{
- bmi_emul_set_off(emul, BMI_EMUL_GYR_X, offset[0]);
- bmi_emul_set_off(emul, BMI_EMUL_GYR_Y, offset[1]);
- bmi_emul_set_off(emul, BMI_EMUL_GYR_Z, offset[2]);
-}
-
-/** Save emulator gyroscope offset values to intv3_t vector */
-static void get_emul_gyr_offset(struct i2c_emul *emul, intv3_t offset)
-{
- offset[0] = bmi_emul_get_off(emul, BMI_EMUL_GYR_X);
- offset[1] = bmi_emul_get_off(emul, BMI_EMUL_GYR_Y);
- offset[2] = bmi_emul_get_off(emul, BMI_EMUL_GYR_Z);
-}
-
-/** Set emulator gyroscope values to vector of three int16_t */
-static void set_emul_gyr(struct i2c_emul *emul, intv3_t gyr)
-{
- bmi_emul_set_value(emul, BMI_EMUL_GYR_X, gyr[0]);
- bmi_emul_set_value(emul, BMI_EMUL_GYR_Y, gyr[1]);
- bmi_emul_set_value(emul, BMI_EMUL_GYR_Z, gyr[2]);
-}
-
-/** Convert accelerometer read to units used by emulator */
-static void drv_acc_to_emul(intv3_t drv, int range, intv3_t out)
-{
- const int scale = MOTION_SCALING_FACTOR / BMI_EMUL_1G;
-
- out[0] = drv[0] * range / scale;
- out[1] = drv[1] * range / scale;
- out[2] = drv[2] * range / scale;
-}
-
-/** Convert gyroscope read to units used by emulator */
-static void drv_gyr_to_emul(intv3_t drv, int range, intv3_t out)
-{
- const int scale = MOTION_SCALING_FACTOR / BMI_EMUL_125_DEG_S;
-
- range /= 125;
- out[0] = drv[0] * range / scale;
- out[1] = drv[1] * range / scale;
- out[2] = drv[2] * range / scale;
-}
-
-/** Compare two vectors of intv3_t type */
-static void compare_int3v_f(intv3_t exp_v, intv3_t v, int eps, int line)
-{
- int i;
-
- for (i = 0; i < 3; i++) {
- zassert_within(exp_v[i], v[i], eps,
- "Expected [%d; %d; %d], got [%d; %d; %d]; line: %d",
- exp_v[0], exp_v[1], exp_v[2], v[0], v[1], v[2], line);
- }
-}
-#define compare_int3v_eps(exp_v, v, e) compare_int3v_f(exp_v, v, e, __LINE__)
-#define compare_int3v(exp_v, v) compare_int3v_eps(exp_v, v, V_EPS)
-
-/** Test get accelerometer offset with and without rotation */
-static void test_bmi_acc_get_offset(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- int16_t ret[3];
- intv3_t ret_v;
- intv3_t exp_v;
- int16_t temp;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Set emulator offset */
- exp_v[0] = BMI_EMUL_1G / 10;
- exp_v[1] = BMI_EMUL_1G / 20;
- exp_v[2] = -(int)BMI_EMUL_1G / 30;
- set_emul_acc_offset(emul, exp_v);
- /* BMI driver returns value in mg units */
- exp_v[0] = 1000 / 10;
- exp_v[1] = 1000 / 20;
- exp_v[2] = -1000 / 30;
-
- /* Test fail on offset read */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_ACC70);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_ACC70 + 1);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_ACC70 + 2);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
-
- /* Test get offset without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- zassert_equal(temp, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- convert_int3v_int16(ret, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Setup rotation and rotate expected offset */
- ms->rot_standard_ref = &test_rotation;
- rotate_int3v_by_test_rotation(exp_v);
-
- /* Test get offset with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- zassert_equal(temp, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- convert_int3v_int16(ret, ret_v);
- compare_int3v(exp_v, ret_v);
-}
-
-/** Test get gyroscope offset with and without rotation */
-static void test_bmi_gyr_get_offset(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- int16_t ret[3];
- intv3_t ret_v;
- intv3_t exp_v;
- int16_t temp;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Set emulator offset */
- exp_v[0] = BMI_EMUL_125_DEG_S / 100;
- exp_v[1] = BMI_EMUL_125_DEG_S / 200;
- exp_v[2] = -(int)BMI_EMUL_125_DEG_S / 300;
- set_emul_gyr_offset(emul, exp_v);
- /* BMI driver returns value in mdeg/s units */
- exp_v[0] = 125000 / 100;
- exp_v[1] = 125000 / 200;
- exp_v[2] = -125000 / 300;
-
- /* Test fail on offset read */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_GYR70);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_GYR70 + 1);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_GYR70 + 2);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_EN_GYR98);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
-
- /* Test get offset without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- zassert_equal(temp, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- convert_int3v_int16(ret, ret_v);
- compare_int3v_eps(exp_v, ret_v, 64);
-
- /* Setup rotation and rotate expected offset */
- ms->rot_standard_ref = &test_rotation;
- rotate_int3v_by_test_rotation(exp_v);
-
- /* Test get offset with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- zassert_equal(temp, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- convert_int3v_int16(ret, ret_v);
- compare_int3v_eps(exp_v, ret_v, 64);
-}
-
-/**
- * Test set accelerometer offset with and without rotation. Also test behaviour
- * on I2C error.
- */
-static void test_bmi_acc_set_offset(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- int16_t input_v[3];
- int16_t temp = 0;
- intv3_t ret_v;
- intv3_t exp_v;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Test fail on OFFSET EN GYR98 register read and write */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_EN_GYR98);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_EN_GYR98);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test fail on offset write */
- i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_ACC70);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_ACC70 + 1);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_ACC70 + 2);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Set input offset */
- exp_v[0] = BMI_EMUL_1G / 10;
- exp_v[1] = BMI_EMUL_1G / 20;
- exp_v[2] = -(int)BMI_EMUL_1G / 30;
- /* BMI driver accept value in mg units */
- input_v[0] = 1000 / 10;
- input_v[1] = 1000 / 20;
- input_v[2] = -1000 / 30;
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
-
- /* Test set offset without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->set_offset(ms, input_v, temp), NULL);
- get_emul_acc_offset(emul, ret_v);
- /*
- * Depending on used range, accelerometer values may be up to 6 bits
- * more accurate then offset value resolution.
- */
- compare_int3v_eps(exp_v, ret_v, 64);
- /* Accelerometer offset should be enabled */
- zassert_true(bmi_emul_get_reg(emul, BMI160_OFFSET_EN_GYR98) &
- BMI160_OFFSET_ACC_EN, NULL);
-
- /* Setup rotation and rotate input for set_offset function */
- ms->rot_standard_ref = &test_rotation;
- convert_int3v_int16(input_v, ret_v);
- rotate_int3v_by_test_rotation(ret_v);
- convert_int3v_int16(ret_v, input_v);
-
- /* Test set offset with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->set_offset(ms, input_v, temp), NULL);
- get_emul_acc_offset(emul, ret_v);
- compare_int3v_eps(exp_v, ret_v, 64);
- /* Accelerometer offset should be enabled */
- zassert_true(bmi_emul_get_reg(emul, BMI160_OFFSET_EN_GYR98) &
- BMI160_OFFSET_ACC_EN, NULL);
-}
-
-/**
- * Test set gyroscope offset with and without rotation. Also test behaviour
- * on I2C error.
- */
-static void test_bmi_gyr_set_offset(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- int16_t input_v[3];
- int16_t temp = 0;
- intv3_t ret_v;
- intv3_t exp_v;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Test fail on OFFSET EN GYR98 register read and write */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_EN_GYR98);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_EN_GYR98);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test fail on offset write */
- i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_GYR70);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_GYR70 + 1);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_GYR70 + 2);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Set input offset */
- exp_v[0] = BMI_EMUL_125_DEG_S / 100;
- exp_v[1] = BMI_EMUL_125_DEG_S / 200;
- exp_v[2] = -(int)BMI_EMUL_125_DEG_S / 300;
- /* BMI driver accept value in mdeg/s units */
- input_v[0] = 125000 / 100;
- input_v[1] = 125000 / 200;
- input_v[2] = -125000 / 300;
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
-
- /* Test set offset without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->set_offset(ms, input_v, temp), NULL);
- get_emul_gyr_offset(emul, ret_v);
- compare_int3v(exp_v, ret_v);
- /* Gyroscope offset should be enabled */
- zassert_true(bmi_emul_get_reg(emul, BMI160_OFFSET_EN_GYR98) &
- BMI160_OFFSET_GYRO_EN, NULL);
-
- /* Setup rotation and rotate input for set_offset function */
- ms->rot_standard_ref = &test_rotation;
- convert_int3v_int16(input_v, ret_v);
- rotate_int3v_by_test_rotation(ret_v);
- convert_int3v_int16(ret_v, input_v);
-
- /* Test set offset with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->set_offset(ms, input_v, temp), NULL);
- get_emul_gyr_offset(emul, ret_v);
- compare_int3v(exp_v, ret_v);
- zassert_true(bmi_emul_get_reg(emul, BMI160_OFFSET_EN_GYR98) &
- BMI160_OFFSET_GYRO_EN, NULL);
-}
-
-/**
- * Try to set accelerometer range and check if expected range was set
- * in driver and in emulator.
- */
-static void check_set_acc_range_f(struct i2c_emul *emul,
- struct motion_sensor_t *ms, int range,
- int rnd, int exp_range, int line)
-{
- uint8_t exp_range_reg;
- uint8_t range_reg;
-
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, range, rnd),
- "set_range failed; line: %d", line);
- zassert_equal(exp_range, ms->current_range,
- "Expected range %d, got %d; line %d",
- exp_range, ms->current_range, line);
- range_reg = bmi_emul_get_reg(emul, BMI160_ACC_RANGE);
-
- switch (exp_range) {
- case 2:
- exp_range_reg = BMI160_GSEL_2G;
- break;
- case 4:
- exp_range_reg = BMI160_GSEL_4G;
- break;
- case 8:
- exp_range_reg = BMI160_GSEL_8G;
- break;
- case 16:
- exp_range_reg = BMI160_GSEL_16G;
- break;
- default:
- /* Unknown expected range */
- zassert_unreachable(
- "Expected range %d not supported by device; line %d",
- exp_range, line);
- return;
- }
-
- zassert_equal(exp_range_reg, range_reg,
- "Expected range reg 0x%x, got 0x%x; line %d",
- exp_range_reg, range_reg, line);
-}
-#define check_set_acc_range(emul, ms, range, rnd, exp_range) \
- check_set_acc_range_f(emul, ms, range, rnd, exp_range, __LINE__)
-
-/** Test set accelerometer range with and without I2C errors */
-static void test_bmi_acc_set_range(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- int start_range;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Setup starting range, shouldn't be changed on error */
- start_range = 2;
- ms->current_range = start_range;
- bmi_emul_set_reg(emul, BMI160_ACC_RANGE, BMI160_GSEL_2G);
- /* Setup emulator fail on write */
- i2c_common_emul_set_write_fail_reg(emul, BMI160_ACC_RANGE);
-
- /* Test fail on write */
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 12, 0), NULL);
- zassert_equal(start_range, ms->current_range, NULL);
- zassert_equal(BMI160_GSEL_2G,
- bmi_emul_get_reg(emul, BMI160_ACC_RANGE), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 12, 1), NULL);
- zassert_equal(start_range, ms->current_range, NULL);
- zassert_equal(BMI160_GSEL_2G,
- bmi_emul_get_reg(emul, BMI160_ACC_RANGE), NULL);
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test setting range with rounding down */
- check_set_acc_range(emul, ms, 1, 0, 2);
- check_set_acc_range(emul, ms, 2, 0, 2);
- check_set_acc_range(emul, ms, 3, 0, 2);
- check_set_acc_range(emul, ms, 4, 0, 4);
- check_set_acc_range(emul, ms, 5, 0, 4);
- check_set_acc_range(emul, ms, 6, 0, 4);
- check_set_acc_range(emul, ms, 7, 0, 4);
- check_set_acc_range(emul, ms, 8, 0, 8);
- check_set_acc_range(emul, ms, 9, 0, 8);
- check_set_acc_range(emul, ms, 15, 0, 8);
- check_set_acc_range(emul, ms, 16, 0, 16);
- check_set_acc_range(emul, ms, 17, 0, 16);
-
- /* Test setting range with rounding up */
- check_set_acc_range(emul, ms, 1, 1, 2);
- check_set_acc_range(emul, ms, 2, 1, 2);
- check_set_acc_range(emul, ms, 3, 1, 4);
- check_set_acc_range(emul, ms, 4, 1, 4);
- check_set_acc_range(emul, ms, 5, 1, 8);
- check_set_acc_range(emul, ms, 6, 1, 8);
- check_set_acc_range(emul, ms, 7, 1, 8);
- check_set_acc_range(emul, ms, 8, 1, 8);
- check_set_acc_range(emul, ms, 9, 1, 16);
- check_set_acc_range(emul, ms, 15, 1, 16);
- check_set_acc_range(emul, ms, 16, 1, 16);
- check_set_acc_range(emul, ms, 17, 1, 16);
-}
-
-/**
- * Try to set gyroscope range and check if expected range was set in driver and
- * in emulator.
- */
-static void check_set_gyr_range_f(struct i2c_emul *emul,
- struct motion_sensor_t *ms, int range,
- int rnd, int exp_range, int line)
-{
- uint8_t exp_range_reg;
- uint8_t range_reg;
-
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, range, rnd),
- "set_range failed; line: %d", line);
- zassert_equal(exp_range, ms->current_range,
- "Expected range %d, got %d; line %d",
- exp_range, ms->current_range, line);
- range_reg = bmi_emul_get_reg(emul, BMI160_GYR_RANGE);
-
- switch (exp_range) {
- case 125:
- exp_range_reg = BMI160_DPS_SEL_125;
- break;
- case 250:
- exp_range_reg = BMI160_DPS_SEL_250;
- break;
- case 500:
- exp_range_reg = BMI160_DPS_SEL_500;
- break;
- case 1000:
- exp_range_reg = BMI160_DPS_SEL_1000;
- break;
- case 2000:
- exp_range_reg = BMI160_DPS_SEL_2000;
- break;
- default:
- /* Unknown expected range */
- zassert_unreachable(
- "Expected range %d not supported by device; line %d",
- exp_range, line);
- return;
- }
-
- zassert_equal(exp_range_reg, range_reg,
- "Expected range reg 0x%x, got 0x%x; line %d",
- exp_range_reg, range_reg, line);
-}
-#define check_set_gyr_range(emul, ms, range, rnd, exp_range) \
- check_set_gyr_range_f(emul, ms, range, rnd, exp_range, __LINE__)
-
-/** Test set gyroscope range with and without I2C errors */
-static void test_bmi_gyr_set_range(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- int start_range;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Setup starting range, shouldn't be changed on error */
- start_range = 250;
- ms->current_range = start_range;
- bmi_emul_set_reg(emul, BMI160_GYR_RANGE, BMI160_DPS_SEL_250);
- /* Setup emulator fail on write */
- i2c_common_emul_set_write_fail_reg(emul, BMI160_GYR_RANGE);
-
- /* Test fail on write */
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 125, 0), NULL);
- zassert_equal(start_range, ms->current_range, NULL);
- zassert_equal(BMI160_DPS_SEL_250,
- bmi_emul_get_reg(emul, BMI160_GYR_RANGE), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 125, 1), NULL);
- zassert_equal(start_range, ms->current_range, NULL);
- zassert_equal(BMI160_DPS_SEL_250,
- bmi_emul_get_reg(emul, BMI160_GYR_RANGE), NULL);
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test setting range with rounding down */
- check_set_gyr_range(emul, ms, 1, 0, 125);
- check_set_gyr_range(emul, ms, 124, 0, 125);
- check_set_gyr_range(emul, ms, 125, 0, 125);
- check_set_gyr_range(emul, ms, 126, 0, 125);
- check_set_gyr_range(emul, ms, 249, 0, 125);
- check_set_gyr_range(emul, ms, 250, 0, 250);
- check_set_gyr_range(emul, ms, 251, 0, 250);
- check_set_gyr_range(emul, ms, 499, 0, 250);
- check_set_gyr_range(emul, ms, 500, 0, 500);
- check_set_gyr_range(emul, ms, 501, 0, 500);
- check_set_gyr_range(emul, ms, 999, 0, 500);
- check_set_gyr_range(emul, ms, 1000, 0, 1000);
- check_set_gyr_range(emul, ms, 1001, 0, 1000);
- check_set_gyr_range(emul, ms, 1999, 0, 1000);
- check_set_gyr_range(emul, ms, 2000, 0, 2000);
- check_set_gyr_range(emul, ms, 2001, 0, 2000);
-
- /* Test setting range with rounding up */
- check_set_gyr_range(emul, ms, 1, 1, 125);
- check_set_gyr_range(emul, ms, 124, 1, 125);
- check_set_gyr_range(emul, ms, 125, 1, 125);
- check_set_gyr_range(emul, ms, 126, 1, 250);
- check_set_gyr_range(emul, ms, 249, 1, 250);
- check_set_gyr_range(emul, ms, 250, 1, 250);
- check_set_gyr_range(emul, ms, 251, 1, 500);
- check_set_gyr_range(emul, ms, 499, 1, 500);
- check_set_gyr_range(emul, ms, 500, 1, 500);
- check_set_gyr_range(emul, ms, 501, 1, 1000);
- check_set_gyr_range(emul, ms, 999, 1, 1000);
- check_set_gyr_range(emul, ms, 1000, 1, 1000);
- check_set_gyr_range(emul, ms, 1001, 1, 2000);
- check_set_gyr_range(emul, ms, 1999, 1, 2000);
- check_set_gyr_range(emul, ms, 2000, 1, 2000);
- check_set_gyr_range(emul, ms, 2001, 1, 2000);
-}
-
-/** Test get resolution of acclerometer and gyroscope sensor */
-static void test_bmi_get_resolution(void)
-{
- struct motion_sensor_t *ms;
-
- /* Test accelerometer */
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Resolution should be always 16 bits */
- zassert_equal(16, ms->drv->get_resolution(ms), NULL);
-
- /* Test gyroscope */
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Resolution should be always 16 bits */
- zassert_equal(16, ms->drv->get_resolution(ms), NULL);
-}
-
-/**
- * Try to set accelerometer data rate and check if expected rate was set
- * in driver and in emulator.
- */
-static void check_set_acc_rate_f(struct i2c_emul *emul,
- struct motion_sensor_t *ms, int rate, int rnd,
- int exp_rate, int line)
-{
- uint8_t exp_rate_reg;
- uint8_t rate_reg;
- int drv_rate;
-
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, rate, rnd),
- "set_data_rate failed; line: %d", line);
- drv_rate = ms->drv->get_data_rate(ms);
- zassert_equal(exp_rate, drv_rate, "Expected rate %d, got %d; line %d",
- exp_rate, drv_rate, line);
- rate_reg = bmi_emul_get_reg(emul, BMI160_ACC_CONF);
- rate_reg &= BMI_ODR_MASK;
-
- switch (exp_rate) {
- case 12500:
- exp_rate_reg = 0x5;
- break;
- case 25000:
- exp_rate_reg = 0x6;
- break;
- case 50000:
- exp_rate_reg = 0x7;
- break;
- case 100000:
- exp_rate_reg = 0x8;
- break;
- case 200000:
- exp_rate_reg = 0x9;
- break;
- case 400000:
- exp_rate_reg = 0xa;
- break;
- case 800000:
- exp_rate_reg = 0xb;
- break;
- case 1600000:
- exp_rate_reg = 0xc;
- break;
- default:
- /* Unknown expected rate */
- zassert_unreachable(
- "Expected rate %d not supported by device; line %d",
- exp_rate, line);
- return;
- }
-
- zassert_equal(exp_rate_reg, rate_reg,
- "Expected rate reg 0x%x, got 0x%x; line %d",
- exp_rate_reg, rate_reg, line);
-}
-#define check_set_acc_rate(emul, ms, rate, rnd, exp_rate) \
- check_set_acc_rate_f(emul, ms, rate, rnd, exp_rate, __LINE__)
-
-/** Test set and get accelerometer rate with and without I2C errors */
-static void test_bmi_acc_rate(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- uint8_t reg_rate;
- int pmu_status;
- int drv_rate;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Test setting rate with rounding down */
- check_set_acc_rate(emul, ms, 12500, 0, 12500);
- check_set_acc_rate(emul, ms, 12501, 0, 12500);
- check_set_acc_rate(emul, ms, 24999, 0, 12500);
- check_set_acc_rate(emul, ms, 25000, 0, 25000);
- check_set_acc_rate(emul, ms, 25001, 0, 25000);
- check_set_acc_rate(emul, ms, 49999, 0, 25000);
- check_set_acc_rate(emul, ms, 50000, 0, 50000);
- check_set_acc_rate(emul, ms, 50001, 0, 50000);
- check_set_acc_rate(emul, ms, 99999, 0, 50000);
- check_set_acc_rate(emul, ms, 100000, 0, 100000);
- check_set_acc_rate(emul, ms, 100001, 0, 100000);
- check_set_acc_rate(emul, ms, 199999, 0, 100000);
- check_set_acc_rate(emul, ms, 200000, 0, 200000);
- check_set_acc_rate(emul, ms, 200001, 0, 200000);
- check_set_acc_rate(emul, ms, 399999, 0, 200000);
- /*
- * We cannot test frequencies from 400000 to 1600000 because
- * CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ is set to 250000
- */
-
- /* Test setting rate with rounding up */
- check_set_acc_rate(emul, ms, 6251, 1, 12500);
- check_set_acc_rate(emul, ms, 12499, 1, 12500);
- check_set_acc_rate(emul, ms, 12500, 1, 12500);
- check_set_acc_rate(emul, ms, 12501, 1, 25000);
- check_set_acc_rate(emul, ms, 24999, 1, 25000);
- check_set_acc_rate(emul, ms, 25000, 1, 25000);
- check_set_acc_rate(emul, ms, 25001, 1, 50000);
- check_set_acc_rate(emul, ms, 49999, 1, 50000);
- check_set_acc_rate(emul, ms, 50000, 1, 50000);
- check_set_acc_rate(emul, ms, 50001, 1, 100000);
- check_set_acc_rate(emul, ms, 99999, 1, 100000);
- check_set_acc_rate(emul, ms, 100000, 1, 100000);
- check_set_acc_rate(emul, ms, 100001, 1, 200000);
- check_set_acc_rate(emul, ms, 199999, 1, 200000);
- check_set_acc_rate(emul, ms, 200000, 1, 200000);
-
- /* Test out of range rate with rounding down */
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 1, 0), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 12499, 0), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 400000, 0), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 2000000, 0), NULL);
-
- /* Test out of range rate with rounding up */
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 1, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 6250, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 200001, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 400000, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 2000000, 1), NULL);
-
- /* Current rate shouldn't be changed on error */
- drv_rate = ms->drv->get_data_rate(ms);
- reg_rate = bmi_emul_get_reg(emul, BMI160_ACC_CONF);
-
- /* Setup emulator fail on read */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_CONF);
-
- /* Test fail on read */
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_ACC_CONF), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_ACC_CONF), NULL);
-
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Setup emulator fail on write */
- i2c_common_emul_set_write_fail_reg(emul, BMI160_ACC_CONF);
-
- /* Test fail on write */
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_ACC_CONF), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_ACC_CONF), NULL);
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test disabling sensor */
- pmu_status = BMI160_PMU_NORMAL << BMI160_PMU_ACC_OFFSET;
- pmu_status |= BMI160_PMU_NORMAL << BMI160_PMU_GYR_OFFSET;
- bmi_emul_set_reg(emul, BMI160_PMU_STATUS, pmu_status);
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 0, 0), NULL);
-
- bmi_read8(ms->port, ms->i2c_spi_addr_flags, BMI160_PMU_STATUS,
- &pmu_status);
- zassert_equal(BMI160_PMU_NORMAL << BMI160_PMU_GYR_OFFSET, pmu_status,
- "Gyroscope should be still enabled");
-
- /* Test enabling sensor */
- bmi_emul_set_reg(emul, BMI160_PMU_STATUS, 0);
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 50000, 0), NULL);
-
- bmi_read8(ms->port, ms->i2c_spi_addr_flags, BMI160_PMU_STATUS,
- &pmu_status);
- zassert_equal(BMI160_PMU_NORMAL << BMI160_PMU_ACC_OFFSET, pmu_status,
- "Accelerometer should be enabled");
-}
-
-/**
- * Try to set gyroscope data rate and check if expected rate was set
- * in driver and in emulator.
- */
-static void check_set_gyr_rate_f(struct i2c_emul *emul,
- struct motion_sensor_t *ms, int rate, int rnd,
- int exp_rate, int line)
-{
- uint8_t exp_rate_reg;
- uint8_t rate_reg;
- int drv_rate;
-
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, rate, rnd),
- "set_data_rate failed; line: %d", line);
- drv_rate = ms->drv->get_data_rate(ms);
- zassert_equal(exp_rate, drv_rate, "Expected rate %d, got %d; line %d",
- exp_rate, drv_rate, line);
- rate_reg = bmi_emul_get_reg(emul, BMI160_GYR_CONF);
- rate_reg &= BMI_ODR_MASK;
-
- switch (exp_rate) {
- case 25000:
- exp_rate_reg = 0x6;
- break;
- case 50000:
- exp_rate_reg = 0x7;
- break;
- case 100000:
- exp_rate_reg = 0x8;
- break;
- case 200000:
- exp_rate_reg = 0x9;
- break;
- case 400000:
- exp_rate_reg = 0xa;
- break;
- case 800000:
- exp_rate_reg = 0xb;
- break;
- case 1600000:
- exp_rate_reg = 0xc;
- break;
- case 3200000:
- exp_rate_reg = 0xc;
- break;
- default:
- /* Unknown expected rate */
- zassert_unreachable(
- "Expected rate %d not supported by device; line %d",
- exp_rate, line);
- return;
- }
-
- zassert_equal(exp_rate_reg, rate_reg,
- "Expected rate reg 0x%x, got 0x%x; line %d",
- exp_rate_reg, rate_reg, line);
-}
-#define check_set_gyr_rate(emul, ms, rate, rnd, exp_rate) \
- check_set_gyr_rate_f(emul, ms, rate, rnd, exp_rate, __LINE__)
-
-/** Test set and get gyroscope rate with and without I2C errors */
-static void test_bmi_gyr_rate(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- uint8_t reg_rate;
- int pmu_status;
- int drv_rate;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Test setting rate with rounding down */
- check_set_gyr_rate(emul, ms, 25000, 0, 25000);
- check_set_gyr_rate(emul, ms, 25001, 0, 25000);
- check_set_gyr_rate(emul, ms, 49999, 0, 25000);
- check_set_gyr_rate(emul, ms, 50000, 0, 50000);
- check_set_gyr_rate(emul, ms, 50001, 0, 50000);
- check_set_gyr_rate(emul, ms, 99999, 0, 50000);
- check_set_gyr_rate(emul, ms, 100000, 0, 100000);
- check_set_gyr_rate(emul, ms, 100001, 0, 100000);
- check_set_gyr_rate(emul, ms, 199999, 0, 100000);
- check_set_gyr_rate(emul, ms, 200000, 0, 200000);
- check_set_gyr_rate(emul, ms, 200001, 0, 200000);
- check_set_gyr_rate(emul, ms, 399999, 0, 200000);
- /*
- * We cannot test frequencies from 400000 to 3200000 because
- * CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ is set to 250000
- */
-
- /* Test setting rate with rounding up */
- check_set_gyr_rate(emul, ms, 12501, 1, 25000);
- check_set_gyr_rate(emul, ms, 24999, 1, 25000);
- check_set_gyr_rate(emul, ms, 25000, 1, 25000);
- check_set_gyr_rate(emul, ms, 25001, 1, 50000);
- check_set_gyr_rate(emul, ms, 49999, 1, 50000);
- check_set_gyr_rate(emul, ms, 50000, 1, 50000);
- check_set_gyr_rate(emul, ms, 50001, 1, 100000);
- check_set_gyr_rate(emul, ms, 99999, 1, 100000);
- check_set_gyr_rate(emul, ms, 100000, 1, 100000);
- check_set_gyr_rate(emul, ms, 100001, 1, 200000);
- check_set_gyr_rate(emul, ms, 199999, 1, 200000);
- check_set_gyr_rate(emul, ms, 200000, 1, 200000);
-
- /* Test out of range rate with rounding down */
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 1, 0), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 24999, 0), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 400000, 0), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 4000000, 0), NULL);
-
- /* Test out of range rate with rounding up */
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 1, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 12499, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 200001, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 400000, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 4000000, 1), NULL);
-
- /* Current rate shouldn't be changed on error */
- drv_rate = ms->drv->get_data_rate(ms);
- reg_rate = bmi_emul_get_reg(emul, BMI160_GYR_CONF);
-
- /* Setup emulator fail on read */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_CONF);
-
- /* Test fail on read */
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_GYR_CONF), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_GYR_CONF), NULL);
-
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Setup emulator fail on write */
- i2c_common_emul_set_write_fail_reg(emul, BMI160_GYR_CONF);
-
- /* Test fail on write */
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_GYR_CONF), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI160_GYR_CONF), NULL);
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test disabling sensor */
- pmu_status = BMI160_PMU_NORMAL << BMI160_PMU_ACC_OFFSET;
- pmu_status |= BMI160_PMU_NORMAL << BMI160_PMU_GYR_OFFSET;
- bmi_emul_set_reg(emul, BMI160_PMU_STATUS, pmu_status);
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 0, 0), NULL);
-
- bmi_read8(ms->port, ms->i2c_spi_addr_flags, BMI160_PMU_STATUS,
- &pmu_status);
- zassert_equal(BMI160_PMU_NORMAL << BMI160_PMU_ACC_OFFSET, pmu_status,
- "Accelerometer should be still enabled");
-
- /* Test enabling sensor */
- bmi_emul_set_reg(emul, BMI160_PMU_STATUS, 0);
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 50000, 0), NULL);
-
- bmi_read8(ms->port, ms->i2c_spi_addr_flags, BMI160_PMU_STATUS,
- &pmu_status);
- zassert_equal(BMI160_PMU_NORMAL << BMI160_PMU_GYR_OFFSET, pmu_status,
- "Gyroscope should be enabled");
-}
-
-/**
- * Test setting and getting scale in accelerometer and gyroscope sensors.
- * Correct appling scale to results is checked in "read" test.
- */
-static void test_bmi_scale(void)
-{
- struct motion_sensor_t *ms;
- int16_t ret_scale[3];
- int16_t exp_scale[3] = {100, 231, 421};
- int16_t t;
-
- /* Test accelerometer */
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- zassert_equal(EC_SUCCESS, ms->drv->set_scale(ms, exp_scale, 0), NULL);
- zassert_equal(EC_SUCCESS, ms->drv->get_scale(ms, ret_scale, &t), NULL);
-
- zassert_equal(t, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- zassert_equal(exp_scale[0], ret_scale[0], NULL);
- zassert_equal(exp_scale[1], ret_scale[1], NULL);
- zassert_equal(exp_scale[2], ret_scale[2], NULL);
-
- /* Test gyroscope */
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- zassert_equal(EC_SUCCESS, ms->drv->set_scale(ms, exp_scale, 0), NULL);
- zassert_equal(EC_SUCCESS, ms->drv->get_scale(ms, ret_scale, &t), NULL);
-
- zassert_equal(t, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- zassert_equal(exp_scale[0], ret_scale[0], NULL);
- zassert_equal(exp_scale[1], ret_scale[1], NULL);
- zassert_equal(exp_scale[2], ret_scale[2], NULL);
-}
-
-/** Test reading temperature using accelerometer and gyroscope sensors */
-static void test_bmi_read_temp(void)
-{
- struct motion_sensor_t *ms_acc, *ms_gyr;
- struct i2c_emul *emul;
- int ret_temp;
- int exp_temp;
-
- emul = bmi_emul_get(BMI_ORD);
- ms_acc = &motion_sensors[BMI_ACC_SENSOR_ID];
- ms_gyr = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Setup emulator fail on read */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_TEMPERATURE_0);
- zassert_equal(EC_ERROR_NOT_POWERED,
- ms_acc->drv->read_temp(ms_acc, &ret_temp), NULL);
- zassert_equal(EC_ERROR_NOT_POWERED,
- ms_gyr->drv->read_temp(ms_gyr, &ret_temp), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_TEMPERATURE_1);
- zassert_equal(EC_ERROR_NOT_POWERED,
- ms_acc->drv->read_temp(ms_acc, &ret_temp), NULL);
- zassert_equal(EC_ERROR_NOT_POWERED,
- ms_gyr->drv->read_temp(ms_gyr, &ret_temp), NULL);
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Fail on invalid temperature */
- bmi_emul_set_reg(emul, BMI160_TEMPERATURE_0, 0x00);
- bmi_emul_set_reg(emul, BMI160_TEMPERATURE_1, 0x80);
- zassert_equal(EC_ERROR_NOT_POWERED,
- ms_acc->drv->read_temp(ms_acc, &ret_temp), NULL);
- zassert_equal(EC_ERROR_NOT_POWERED,
- ms_gyr->drv->read_temp(ms_gyr, &ret_temp), NULL);
-
- /*
- * Test correct values. Both motion sensors should return the same
- * temperature.
- */
- exp_temp = C_TO_K(23);
- bmi_emul_set_reg(emul, BMI160_TEMPERATURE_0, 0x00);
- bmi_emul_set_reg(emul, BMI160_TEMPERATURE_1, 0x00);
- zassert_equal(EC_SUCCESS, ms_acc->drv->read_temp(ms_acc, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
- zassert_equal(EC_SUCCESS, ms_gyr->drv->read_temp(ms_gyr, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
-
- exp_temp = C_TO_K(87);
- bmi_emul_set_reg(emul, BMI160_TEMPERATURE_0, 0xff);
- bmi_emul_set_reg(emul, BMI160_TEMPERATURE_1, 0x7f);
- zassert_equal(EC_SUCCESS, ms_acc->drv->read_temp(ms_acc, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
- zassert_equal(EC_SUCCESS, ms_gyr->drv->read_temp(ms_gyr, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
-
- exp_temp = C_TO_K(-41);
- bmi_emul_set_reg(emul, BMI160_TEMPERATURE_0, 0x01);
- bmi_emul_set_reg(emul, BMI160_TEMPERATURE_1, 0x80);
- zassert_equal(EC_SUCCESS, ms_acc->drv->read_temp(ms_acc, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
- zassert_equal(EC_SUCCESS, ms_gyr->drv->read_temp(ms_gyr, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
-
- exp_temp = C_TO_K(47);
- bmi_emul_set_reg(emul, BMI160_TEMPERATURE_0, 0x00);
- bmi_emul_set_reg(emul, BMI160_TEMPERATURE_1, 0x30);
- zassert_equal(EC_SUCCESS, ms_acc->drv->read_temp(ms_acc, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
- zassert_equal(EC_SUCCESS, ms_gyr->drv->read_temp(ms_gyr, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
-}
-
-/** Test reading accelerometer sensor data */
-static void test_bmi_acc_read(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- intv3_t ret_v;
- intv3_t exp_v;
- int16_t scale[3] = {MOTION_SENSE_DEFAULT_SCALE,
- MOTION_SENSE_DEFAULT_SCALE,
- MOTION_SENSE_DEFAULT_SCALE};
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Set offset 0 to simplify test */
- bmi_emul_set_off(emul, BMI_EMUL_ACC_X, 0);
- bmi_emul_set_off(emul, BMI_EMUL_ACC_Y, 0);
- bmi_emul_set_off(emul, BMI_EMUL_ACC_Z, 0);
-
- /* Fail on read status */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_STATUS);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
-
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* When not ready, driver should return saved raw value */
- exp_v[0] = 100;
- exp_v[1] = 200;
- exp_v[2] = 300;
- ms->raw_xyz[0] = exp_v[0];
- ms->raw_xyz[1] = exp_v[1];
- ms->raw_xyz[2] = exp_v[2];
-
- /* Status not ready */
- bmi_emul_set_reg(emul, BMI160_STATUS, 0);
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- compare_int3v(exp_v, ret_v);
-
- /* Status only GYR ready */
- bmi_emul_set_reg(emul, BMI160_STATUS, BMI160_DRDY_GYR);
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- compare_int3v(exp_v, ret_v);
-
- /* Status ACC ready */
- bmi_emul_set_reg(emul, BMI160_STATUS, BMI160_DRDY_ACC);
-
- /* Set input accelerometer values */
- exp_v[0] = BMI_EMUL_1G / 10;
- exp_v[1] = BMI_EMUL_1G / 20;
- exp_v[2] = -(int)BMI_EMUL_1G / 30;
- set_emul_acc(emul, exp_v);
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
- /* Set scale */
- zassert_equal(EC_SUCCESS, ms->drv->set_scale(ms, scale, 0), NULL);
- /* Set range to 2G */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 2, 0), NULL);
-
- /* Test read without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_acc_to_emul(ret_v, 2, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Set range to 4G */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 4, 0), NULL);
-
- /* Test read without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_acc_to_emul(ret_v, 4, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Setup rotation and rotate expected vector */
- ms->rot_standard_ref = &test_rotation;
- rotate_int3v_by_test_rotation(exp_v);
- /* Set range to 2G */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 2, 0), NULL);
-
- /* Test read with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_acc_to_emul(ret_v, 2, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Set range to 4G */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 4, 0), NULL);
-
- /* Test read with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_acc_to_emul(ret_v, 4, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Fail on read of data registers */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_X_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_X_H_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_Y_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_Y_H_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_Z_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_Z_H_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
-
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- ms->rot_standard_ref = NULL;
-}
-
-/** Test reading gyroscope sensor data */
-static void test_bmi_gyr_read(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- intv3_t ret_v;
- intv3_t exp_v;
- int16_t scale[3] = {MOTION_SENSE_DEFAULT_SCALE,
- MOTION_SENSE_DEFAULT_SCALE,
- MOTION_SENSE_DEFAULT_SCALE};
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Set offset 0 to simplify test */
- bmi_emul_set_off(emul, BMI_EMUL_GYR_X, 0);
- bmi_emul_set_off(emul, BMI_EMUL_GYR_Y, 0);
- bmi_emul_set_off(emul, BMI_EMUL_GYR_Z, 0);
-
- /* Fail on read status */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_STATUS);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
-
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* When not ready, driver should return saved raw value */
- exp_v[0] = 100;
- exp_v[1] = 200;
- exp_v[2] = 300;
- ms->raw_xyz[0] = exp_v[0];
- ms->raw_xyz[1] = exp_v[1];
- ms->raw_xyz[2] = exp_v[2];
-
- /* Status not ready */
- bmi_emul_set_reg(emul, BMI160_STATUS, 0);
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- compare_int3v(exp_v, ret_v);
-
- /* Status only ACC ready */
- bmi_emul_set_reg(emul, BMI160_STATUS, BMI160_DRDY_ACC);
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- compare_int3v(exp_v, ret_v);
-
- /* Status GYR ready */
- bmi_emul_set_reg(emul, BMI160_STATUS, BMI160_DRDY_GYR);
-
- /* Set input accelerometer values */
- exp_v[0] = BMI_EMUL_125_DEG_S / 10;
- exp_v[1] = BMI_EMUL_125_DEG_S / 20;
- exp_v[2] = -(int)BMI_EMUL_125_DEG_S / 30;
- set_emul_gyr(emul, exp_v);
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
- /* Set scale */
- zassert_equal(EC_SUCCESS, ms->drv->set_scale(ms, scale, 0), NULL);
- /* Set range to 125°/s */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 125, 0), NULL);
-
- /* Test read without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_gyr_to_emul(ret_v, 125, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Set range to 1000°/s */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 1000, 0), NULL);
-
- /* Test read without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_gyr_to_emul(ret_v, 1000, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Setup rotation and rotate expected vector */
- ms->rot_standard_ref = &test_rotation;
- rotate_int3v_by_test_rotation(exp_v);
- /* Set range to 125°/s */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 125, 0), NULL);
-
- /* Test read with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_gyr_to_emul(ret_v, 125, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Set range to 1000°/s */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 1000, 0), NULL);
-
- /* Test read with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_gyr_to_emul(ret_v, 1000, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Fail on read of data registers */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_X_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_X_H_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_Y_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_Y_H_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_Z_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_Z_H_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
-
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- ms->rot_standard_ref = NULL;
-}
-
-/**
- * Custom emulatro read function which always return not ready STATUS register.
- * Used in calibration test.
- */
-static int emul_nrdy(struct i2c_emul *emul, int reg, uint8_t *val, int byte,
- void *data)
-{
- if (reg == BMI160_STATUS) {
- bmi_emul_set_reg(emul, BMI160_STATUS, 0);
- *val = 0;
-
- return 0;
- }
-
- return 1;
-}
-
-/** Test acceleromtere calibration */
-static void test_bmi_acc_perform_calib(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- uint8_t pmu_status;
- intv3_t start_off;
- intv3_t exp_off;
- intv3_t ret_off;
- int range;
- int rate;
- mat33_fp_t rot = {
- { FLOAT_TO_FP(1), 0, 0},
- { 0, FLOAT_TO_FP(1), 0},
- { 0, 0, FLOAT_TO_FP(-1)}
- };
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Enable sensors */
- pmu_status = BMI160_PMU_NORMAL << BMI160_PMU_ACC_OFFSET;
- pmu_status |= BMI160_PMU_NORMAL << BMI160_PMU_GYR_OFFSET;
- bmi_emul_set_reg(emul, BMI160_PMU_STATUS, pmu_status);
-
- /* Range and rate cannot change after calibration */
- range = 4;
- rate = 50000;
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, range, 0), NULL);
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, rate, 0), NULL);
-
- /* Set offset 0 */
- start_off[0] = 0;
- start_off[1] = 0;
- start_off[2] = 0;
- set_emul_acc_offset(emul, start_off);
-
- /* Set input accelerometer values */
- exp_off[0] = BMI_EMUL_1G / 10;
- exp_off[1] = BMI_EMUL_1G / 20;
- exp_off[2] = BMI_EMUL_1G - (int)BMI_EMUL_1G / 30;
- set_emul_acc(emul, exp_off);
-
- /*
- * Expected offset is [-X, -Y, 1G - Z] for no rotation or positive
- * rotation on Z axis
- */
- exp_off[0] = -exp_off[0];
- exp_off[1] = -exp_off[1];
- exp_off[2] = BMI_EMUL_1G - exp_off[2];
-
- /* Test fail on rate set */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_ACC_CONF);
- zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /* Test fail on status read */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_STATUS);
- zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
- /* Stop fast offset compensation before next test */
- bmi_emul_set_reg(emul, BMI160_CMD_REG, BMI160_CMD_NOOP);
-
- /* Test fail on data not ready */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- i2c_common_emul_set_read_func(emul, emul_nrdy, NULL);
- zassert_equal(EC_RES_TIMEOUT, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
- /* Remove custom emulator read function */
- i2c_common_emul_set_read_func(emul, NULL, NULL);
- /* Stop fast offset compensation before next test */
- bmi_emul_set_reg(emul, BMI160_CMD_REG, BMI160_CMD_NOOP);
-
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
- /* Test successful offset compenastion without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
- get_emul_acc_offset(emul, ret_off);
- /*
- * Depending on used range, accelerometer values may be up to 6 bits
- * more accurate then offset value resolution.
- */
- compare_int3v_eps(exp_off, ret_off, 64);
- /* Acelerometer offset should be enabled */
- zassert_true(bmi_emul_get_reg(emul, BMI160_OFFSET_EN_GYR98) &
- BMI160_OFFSET_ACC_EN, NULL);
-
- /* Enable rotation with negative value on Z axis */
- ms->rot_standard_ref = &rot;
- /* Expected offset -1G - accelerometer[Z] */
- bmi_emul_set_value(emul, BMI_EMUL_ACC_Z, -(int)BMI_EMUL_1G - 1234);
- exp_off[2] = 1234;
-
- /* Test successful offset compenastion with negative Z rotation */
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
- get_emul_acc_offset(emul, ret_off);
- compare_int3v_eps(exp_off, ret_off, 64);
- /* Acelerometer offset should be enabled */
- zassert_true(bmi_emul_get_reg(emul, BMI160_OFFSET_EN_GYR98) &
- BMI160_OFFSET_ACC_EN, NULL);
-
- /* Set positive rotation on Z axis */
- rot[2][2] = FLOAT_TO_FP(1);
- /* Expected offset 1G - accelerometer[Z] */
- bmi_emul_set_value(emul, BMI_EMUL_ACC_Z, BMI_EMUL_1G - 1234);
- exp_off[2] = 1234;
-
- /* Test successful offset compenastion with positive Z rotation */
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
- get_emul_acc_offset(emul, ret_off);
- compare_int3v_eps(exp_off, ret_off, 64);
- /* Acelerometer offset should be enabled */
- zassert_true(bmi_emul_get_reg(emul, BMI160_OFFSET_EN_GYR98) &
- BMI160_OFFSET_ACC_EN, NULL);
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
-}
-
-/** Test gyroscope calibration */
-static void test_bmi_gyr_perform_calib(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- uint8_t pmu_status;
- intv3_t start_off;
- intv3_t exp_off;
- intv3_t ret_off;
- int range;
- int rate;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Enable sensors */
- pmu_status = BMI160_PMU_NORMAL << BMI160_PMU_ACC_OFFSET;
- pmu_status |= BMI160_PMU_NORMAL << BMI160_PMU_GYR_OFFSET;
- bmi_emul_set_reg(emul, BMI160_PMU_STATUS, pmu_status);
-
- /* Range and rate cannot change after calibration */
- range = 250;
- rate = 50000;
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, range, 0), NULL);
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, rate, 0), NULL);
-
- /* Set offset 0 */
- start_off[0] = 0;
- start_off[1] = 0;
- start_off[2] = 0;
- set_emul_gyr_offset(emul, start_off);
-
- /* Set input accelerometer values */
- exp_off[0] = BMI_EMUL_125_DEG_S / 100;
- exp_off[1] = BMI_EMUL_125_DEG_S / 200;
- exp_off[2] = -(int)BMI_EMUL_125_DEG_S / 300;
- set_emul_gyr(emul, exp_off);
-
- /* Expected offset is [-X, -Y, -Z] */
- exp_off[0] = -exp_off[0];
- exp_off[1] = -exp_off[1];
- exp_off[2] = -exp_off[2];
-
- /* Test success on disabling calibration */
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 0), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /* Test fail on rate set */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_GYR_CONF);
- zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /* Test fail on status read */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_STATUS);
- zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
- /* Stop fast offset compensation before next test */
- bmi_emul_set_reg(emul, BMI160_CMD_REG, BMI160_CMD_NOOP);
-
- /* Test fail on data not ready */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- i2c_common_emul_set_read_func(emul, emul_nrdy, NULL);
- zassert_equal(EC_RES_TIMEOUT, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
- /* Remove custom emulator read function */
- i2c_common_emul_set_read_func(emul, NULL, NULL);
- /* Stop fast offset compensation before next test */
- bmi_emul_set_reg(emul, BMI160_CMD_REG, BMI160_CMD_NOOP);
-
- /* Test successful offset compenastion */
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
- get_emul_gyr_offset(emul, ret_off);
- /*
- * Depending on used range, gyroscope values may be up to 4 bits
- * more accurate then offset value resolution.
- */
- compare_int3v_eps(exp_off, ret_off, 32);
- /* Gyroscope offset should be enabled */
- zassert_true(bmi_emul_get_reg(emul, BMI160_OFFSET_EN_GYR98) &
- BMI160_OFFSET_GYRO_EN, NULL);
-}
-
-/** Test init function of BMI160 accelerometer and gyroscope sensors */
-static void test_bmi_init(void)
-{
- struct motion_sensor_t *ms_acc, *ms_gyr;
- struct i2c_emul *emul;
-
- emul = bmi_emul_get(BMI_ORD);
- ms_acc = &motion_sensors[BMI_ACC_SENSOR_ID];
- ms_gyr = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Test successful init */
- zassert_equal(EC_RES_SUCCESS, ms_acc->drv->init(ms_acc), NULL);
-
- zassert_equal(EC_RES_SUCCESS, ms_gyr->drv->init(ms_gyr), NULL);
-}
-
-/** Data for custom emulator read function used in FIFO test */
-struct fifo_func_data {
- uint16_t interrupts;
-};
-
-/**
- * Custom emulator read function used in FIFO test. It sets interrupt registers
- * to value passed as additional data. It sets interrupt registers to 0 after
- * access.
- */
-static int emul_fifo_func(struct i2c_emul *emul, int reg, uint8_t *val,
- int byte, void *data)
-{
- struct fifo_func_data *d = data;
-
- if (reg + byte == BMI160_INT_STATUS_0) {
- bmi_emul_set_reg(emul, BMI160_INT_STATUS_0,
- d->interrupts & 0xff);
- d->interrupts &= 0xff00;
- } else if (reg + byte == BMI160_INT_STATUS_1) {
- bmi_emul_set_reg(emul, BMI160_INT_STATUS_1,
- (d->interrupts >> 8) & 0xff);
- d->interrupts &= 0xff;
- }
-
- return 1;
-}
-
-/**
- * Run irq handler on accelerometer sensor and check if committed data in FIFO
- * match what was set in FIFO frames in emulator.
- */
-static void check_fifo_f(struct motion_sensor_t *ms_acc,
- struct motion_sensor_t *ms_gyr,
- struct bmi_emul_frame *frame,
- int acc_range, int gyr_range,
- int line)
-{
- struct ec_response_motion_sensor_data vector;
- struct bmi_emul_frame *f_acc, *f_gyr;
- uint32_t event = BMI_INT_EVENT;
- uint16_t size;
- intv3_t exp_v;
- intv3_t ret_v;
-
- /* Find first frame of acc and gyr type */
- f_acc = frame;
- while (f_acc != NULL && !(f_acc->type & BMI_EMUL_FRAME_ACC)) {
- f_acc = f_acc->next;
- }
-
- f_gyr = frame;
- while (f_gyr != NULL && !(f_gyr->type & BMI_EMUL_FRAME_GYR)) {
- f_gyr = f_gyr->next;
- }
-
- /* Read FIFO in driver */
- zassert_equal(EC_SUCCESS, ms_acc->drv->irq_handler(ms_acc, &event),
- NULL);
-
- /* Read all data committed to FIFO */
- while (motion_sense_fifo_read(sizeof(vector), 1, &vector, &size)) {
- /* Ignore timestamp frames */
- if (vector.flags == MOTIONSENSE_SENSOR_FLAG_TIMESTAMP) {
- continue;
- }
-
- /* Check acclerometer frames */
- if (ms_acc - motion_sensors == vector.sensor_num) {
- if (f_acc == NULL) {
- zassert_unreachable(
- "Not expected acclerometer data in FIFO, line %d",
- line);
- }
-
- convert_int3v_int16(vector.data, ret_v);
- drv_acc_to_emul(ret_v, acc_range, ret_v);
- exp_v[0] = f_acc->acc_x;
- exp_v[1] = f_acc->acc_y;
- exp_v[2] = f_acc->acc_z;
- compare_int3v_f(exp_v, ret_v, V_EPS, line);
- f_acc = f_acc->next;
- }
-
- /* Check gyroscope frames */
- if (ms_gyr - motion_sensors == vector.sensor_num) {
- if (f_gyr == NULL) {
- zassert_unreachable(
- "Not expected gyroscope data in FIFO, line %d",
- line);
- }
-
- convert_int3v_int16(vector.data, ret_v);
- drv_gyr_to_emul(ret_v, gyr_range, ret_v);
- exp_v[0] = f_gyr->gyr_x;
- exp_v[1] = f_gyr->gyr_y;
- exp_v[2] = f_gyr->gyr_z;
- compare_int3v_f(exp_v, ret_v, V_EPS, line);
- f_gyr = f_gyr->next;
- }
- }
-
- /* Skip frames of different type at the end */
- while (f_acc != NULL && !(f_acc->type & BMI_EMUL_FRAME_ACC)) {
- f_acc = f_acc->next;
- }
-
- while (f_gyr != NULL && !(f_gyr->type & BMI_EMUL_FRAME_GYR)) {
- f_gyr = f_gyr->next;
- }
-
- /* All frames are readed */
- zassert_is_null(f_acc, "Not all accelerometer frames are read, line %d",
- line);
- zassert_is_null(f_gyr, "Not all gyroscope frames are read, line %d",
- line);
-}
-#define check_fifo(ms_acc, ms_gyr, frame, acc_range, gyr_range) \
- check_fifo_f(ms_acc, ms_gyr, frame, acc_range, gyr_range, __LINE__)
-
-/** Test irq handler of accelerometer sensor */
-static void test_bmi_acc_fifo(void)
-{
- struct motion_sensor_t *ms, *ms_gyr;
- struct fifo_func_data func_data;
- struct bmi_emul_frame f[3];
- struct i2c_emul *emul;
- int gyr_range = 125;
- int acc_range = 2;
- int event;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
- ms_gyr = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Need to be set to collect all data in FIFO */
- ms->oversampling_ratio = 1;
- ms_gyr->oversampling_ratio = 1;
- /* Only BMI event should be handled */
- event = 0x1234 & ~BMI_INT_EVENT;
- zassert_equal(EC_ERROR_NOT_HANDLED, ms->drv->irq_handler(ms, &event),
- NULL);
-
- event = BMI_INT_EVENT;
-
- /* Test fail to read interrupt status registers */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_INT_STATUS_0);
- zassert_equal(EC_ERROR_INVAL, ms->drv->irq_handler(ms, &event), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_INT_STATUS_1);
- zassert_equal(EC_ERROR_INVAL, ms->drv->irq_handler(ms, &event), NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test no interrupt */
- bmi_emul_set_reg(emul, BMI160_INT_STATUS_0, 0);
- bmi_emul_set_reg(emul, BMI160_INT_STATUS_1, 0);
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, NULL, acc_range, gyr_range);
-
- /* Set custom function for FIFO test */
- i2c_common_emul_set_read_func(emul, emul_fifo_func, &func_data);
- /* Enable sensor FIFO */
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 50000, 0), NULL);
- /* Set range */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, acc_range, 0), NULL);
- zassert_equal(EC_SUCCESS, ms_gyr->drv->set_range(ms_gyr, gyr_range, 0),
- NULL);
- /* Setup single accelerometer frame */
- f[0].type = BMI_EMUL_FRAME_ACC;
- f[0].acc_x = BMI_EMUL_1G / 10;
- f[0].acc_y = BMI_EMUL_1G / 20;
- f[0].acc_z = -(int)BMI_EMUL_1G / 30;
- f[0].next = NULL;
- bmi_emul_append_frame(emul, f);
- /* Setup interrupts register */
- func_data.interrupts = BMI160_FWM_INT;
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, f, acc_range, gyr_range);
-
- /* Setup second accelerometer frame */
- f[1].type = BMI_EMUL_FRAME_ACC;
- f[1].acc_x = -(int)BMI_EMUL_1G / 40;
- f[1].acc_y = BMI_EMUL_1G / 50;
- f[1].acc_z = BMI_EMUL_1G / 60;
- f[0].next = &(f[1]);
- f[1].next = NULL;
- bmi_emul_append_frame(emul, f);
- /* Setup interrupts register */
- func_data.interrupts = BMI160_FWM_INT;
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, f, acc_range, gyr_range);
-
- /* Enable sensor FIFO */
- zassert_equal(EC_SUCCESS, ms_gyr->drv->set_data_rate(ms_gyr, 50000, 0),
- NULL);
-
- /* Setup first gyroscope frame (after two accelerometer frames) */
- f[2].type = BMI_EMUL_FRAME_GYR;
- f[2].gyr_x = -(int)BMI_EMUL_125_DEG_S / 100;
- f[2].gyr_y = BMI_EMUL_125_DEG_S / 200;
- f[2].gyr_z = BMI_EMUL_125_DEG_S / 300;
- f[1].next = &(f[2]);
- f[2].next = NULL;
- bmi_emul_append_frame(emul, f);
- /* Setup interrupts register */
- func_data.interrupts = BMI160_FWM_INT;
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, f, acc_range, gyr_range);
-
- /* Setup second accelerometer frame to by gyroscope frame too */
- f[1].type |= BMI_EMUL_FRAME_GYR;
- f[1].gyr_x = -(int)BMI_EMUL_125_DEG_S / 300;
- f[1].gyr_y = BMI_EMUL_125_DEG_S / 400;
- f[1].gyr_z = BMI_EMUL_125_DEG_S / 500;
- bmi_emul_append_frame(emul, f);
- /* Setup interrupts register */
- func_data.interrupts = BMI160_FWM_INT;
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, f, acc_range, gyr_range);
-
- /* Skip frame should be ignored by driver */
- bmi_emul_set_skipped_frames(emul, 8);
- bmi_emul_append_frame(emul, f);
- /* Setup interrupts register */
- func_data.interrupts = BMI160_FWM_INT;
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, f, acc_range, gyr_range);
-
- /* Setup second frame as an config frame */
- f[1].type = BMI_EMUL_FRAME_CONFIG;
- /* Indicate that accelerometer range changed */
- f[1].config = 0x1;
- bmi_emul_append_frame(emul, f);
- /* Setup interrupts register */
- func_data.interrupts = BMI160_FWM_INT;
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, f, acc_range, gyr_range);
-
- /* Remove custom emulator read function */
- i2c_common_emul_set_read_func(emul, NULL, NULL);
-}
-
-/** Test irq handler of gyroscope sensor */
-static void test_bmi_gyr_fifo(void)
-{
- struct motion_sensor_t *ms;
- uint32_t event;
-
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Interrupt shuldn't be triggered for gyroscope motion sense */
- event = BMI_INT_EVENT;
- zassert_equal(EC_ERROR_NOT_HANDLED, ms->drv->irq_handler(ms, &event),
- NULL);
-}
-
-void test_suite_bmi160(void)
-{
- ztest_test_suite(bmi160,
- ztest_user_unit_test(test_bmi_acc_get_offset),
- ztest_user_unit_test(test_bmi_gyr_get_offset),
- ztest_user_unit_test(test_bmi_acc_set_offset),
- ztest_user_unit_test(test_bmi_gyr_set_offset),
- ztest_user_unit_test(test_bmi_acc_set_range),
- ztest_user_unit_test(test_bmi_gyr_set_range),
- ztest_user_unit_test(test_bmi_get_resolution),
- ztest_user_unit_test(test_bmi_acc_rate),
- ztest_user_unit_test(test_bmi_gyr_rate),
- ztest_user_unit_test(test_bmi_scale),
- ztest_user_unit_test(test_bmi_read_temp),
- ztest_user_unit_test(test_bmi_acc_read),
- ztest_user_unit_test(test_bmi_gyr_read),
- ztest_user_unit_test(test_bmi_acc_perform_calib),
- ztest_user_unit_test(test_bmi_gyr_perform_calib),
- ztest_user_unit_test(test_bmi_init),
- ztest_user_unit_test(test_bmi_acc_fifo),
- ztest_user_unit_test(test_bmi_gyr_fifo));
- ztest_run_test_suite(bmi160);
-}
diff --git a/zephyr/test/drivers/src/bmi260.c b/zephyr/test/drivers/src/bmi260.c
deleted file mode 100644
index 637e5f353b..0000000000
--- a/zephyr/test/drivers/src/bmi260.c
+++ /dev/null
@@ -1,1864 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-
-#include "common.h"
-#include "i2c.h"
-#include "emul/emul_bmi.h"
-#include "emul/emul_common_i2c.h"
-
-#include "motion_sense_fifo.h"
-#include "driver/accelgyro_bmi260.h"
-#include "driver/accelgyro_bmi_common.h"
-
-#define BMI_ORD DT_DEP_ORD(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))
-#define BMI_INT_EVENT \
- TASK_EVENT_MOTION_SENSOR_INTERRUPT(SENSOR_ID(DT_ALIAS(bmi260_int)))
-
-/** How accurate comparision of vectors should be */
-#define V_EPS 8
-
-/** Convert from one type of vector to another */
-#define convert_int3v_int16(v, r) do { \
- r[0] = v[0]; \
- r[1] = v[1]; \
- r[2] = v[2]; \
- } while (0)
-
-/** Rotation used in some tests */
-static const mat33_fp_t test_rotation = {
- { 0, FLOAT_TO_FP(1), 0},
- { FLOAT_TO_FP(-1), 0, 0},
- { 0, 0, FLOAT_TO_FP(-1)}
-};
-/** Rotate given vector by test rotation */
-static void rotate_int3v_by_test_rotation(intv3_t v)
-{
- int16_t t;
-
- t = v[0];
- v[0] = -v[1];
- v[1] = t;
- v[2] = -v[2];
-}
-
-/** Set emulator accelerometer offset values to intv3_t vector */
-static void set_emul_acc_offset(struct i2c_emul *emul, intv3_t offset)
-{
- bmi_emul_set_off(emul, BMI_EMUL_ACC_X, offset[0]);
- bmi_emul_set_off(emul, BMI_EMUL_ACC_Y, offset[1]);
- bmi_emul_set_off(emul, BMI_EMUL_ACC_Z, offset[2]);
-}
-
-/** Save emulator accelerometer offset values to intv3_t vector */
-static void get_emul_acc_offset(struct i2c_emul *emul, intv3_t offset)
-{
- offset[0] = bmi_emul_get_off(emul, BMI_EMUL_ACC_X);
- offset[1] = bmi_emul_get_off(emul, BMI_EMUL_ACC_Y);
- offset[2] = bmi_emul_get_off(emul, BMI_EMUL_ACC_Z);
-}
-
-/** Set emulator accelerometer values to intv3_t vector */
-static void set_emul_acc(struct i2c_emul *emul, intv3_t acc)
-{
- bmi_emul_set_value(emul, BMI_EMUL_ACC_X, acc[0]);
- bmi_emul_set_value(emul, BMI_EMUL_ACC_Y, acc[1]);
- bmi_emul_set_value(emul, BMI_EMUL_ACC_Z, acc[2]);
-}
-
-/** Set emulator gyroscope offset values to intv3_t vector */
-static void set_emul_gyr_offset(struct i2c_emul *emul, intv3_t offset)
-{
- bmi_emul_set_off(emul, BMI_EMUL_GYR_X, offset[0]);
- bmi_emul_set_off(emul, BMI_EMUL_GYR_Y, offset[1]);
- bmi_emul_set_off(emul, BMI_EMUL_GYR_Z, offset[2]);
-}
-
-/** Save emulator gyroscope offset values to intv3_t vector */
-static void get_emul_gyr_offset(struct i2c_emul *emul, intv3_t offset)
-{
- offset[0] = bmi_emul_get_off(emul, BMI_EMUL_GYR_X);
- offset[1] = bmi_emul_get_off(emul, BMI_EMUL_GYR_Y);
- offset[2] = bmi_emul_get_off(emul, BMI_EMUL_GYR_Z);
-}
-
-/** Set emulator gyroscope values to vector of three int16_t */
-static void set_emul_gyr(struct i2c_emul *emul, intv3_t gyr)
-{
- bmi_emul_set_value(emul, BMI_EMUL_GYR_X, gyr[0]);
- bmi_emul_set_value(emul, BMI_EMUL_GYR_Y, gyr[1]);
- bmi_emul_set_value(emul, BMI_EMUL_GYR_Z, gyr[2]);
-}
-
-/** Convert accelerometer read to units used by emulator */
-static void drv_acc_to_emul(intv3_t drv, int range, intv3_t out)
-{
- const int scale = MOTION_SCALING_FACTOR / BMI_EMUL_1G;
-
- out[0] = drv[0] * range / scale;
- out[1] = drv[1] * range / scale;
- out[2] = drv[2] * range / scale;
-}
-
-/** Convert gyroscope read to units used by emulator */
-static void drv_gyr_to_emul(intv3_t drv, int range, intv3_t out)
-{
- const int scale = MOTION_SCALING_FACTOR / BMI_EMUL_125_DEG_S;
-
- range /= 125;
- out[0] = drv[0] * range / scale;
- out[1] = drv[1] * range / scale;
- out[2] = drv[2] * range / scale;
-}
-
-/** Compare two vectors of intv3_t type */
-static void compare_int3v_f(intv3_t exp_v, intv3_t v, int eps, int line)
-{
- int i;
-
- for (i = 0; i < 3; i++) {
- zassert_within(exp_v[i], v[i], eps,
- "Expected [%d; %d; %d], got [%d; %d; %d]; line: %d",
- exp_v[0], exp_v[1], exp_v[2], v[0], v[1], v[2], line);
- }
-}
-#define compare_int3v_eps(exp_v, v, e) compare_int3v_f(exp_v, v, e, __LINE__)
-#define compare_int3v(exp_v, v) compare_int3v_eps(exp_v, v, V_EPS)
-
-/** Test get accelerometer offset with and without rotation */
-static void test_bmi_acc_get_offset(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- int16_t ret[3];
- intv3_t ret_v;
- intv3_t exp_v;
- int16_t temp;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Set emulator offset */
- exp_v[0] = BMI_EMUL_1G / 10;
- exp_v[1] = BMI_EMUL_1G / 20;
- exp_v[2] = -(int)BMI_EMUL_1G / 30;
- set_emul_acc_offset(emul, exp_v);
- /* BMI driver returns value in mg units */
- exp_v[0] = 1000 / 10;
- exp_v[1] = 1000 / 20;
- exp_v[2] = -1000 / 30;
-
- /* Test fail on offset read */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_ACC70);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_ACC70 + 1);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_ACC70 + 2);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
-
- /* Test get offset without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- zassert_equal(temp, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- convert_int3v_int16(ret, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Setup rotation and rotate expected offset */
- ms->rot_standard_ref = &test_rotation;
- rotate_int3v_by_test_rotation(exp_v);
-
- /* Test get offset with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- zassert_equal(temp, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- convert_int3v_int16(ret, ret_v);
- compare_int3v(exp_v, ret_v);
-}
-
-/** Test get gyroscope offset with and without rotation */
-static void test_bmi_gyr_get_offset(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- int16_t ret[3];
- intv3_t ret_v;
- intv3_t exp_v;
- int16_t temp;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Set emulator offset */
- exp_v[0] = BMI_EMUL_125_DEG_S / 100;
- exp_v[1] = BMI_EMUL_125_DEG_S / 200;
- exp_v[2] = -(int)BMI_EMUL_125_DEG_S / 300;
- set_emul_gyr_offset(emul, exp_v);
- /* BMI driver returns value in mdeg/s units */
- exp_v[0] = 125000 / 100;
- exp_v[1] = 125000 / 200;
- exp_v[2] = -125000 / 300;
-
- /* Test fail on offset read */
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_GYR70);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_GYR70 + 1);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_GYR70 + 2);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI160_OFFSET_EN_GYR98);
- zassert_equal(EC_ERROR_INVAL, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
-
- /* Test get offset without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- zassert_equal(temp, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- convert_int3v_int16(ret, ret_v);
- compare_int3v_eps(exp_v, ret_v, 64);
-
- /* Setup rotation and rotate expected offset */
- ms->rot_standard_ref = &test_rotation;
- rotate_int3v_by_test_rotation(exp_v);
-
- /* Test get offset with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->get_offset(ms, ret, &temp),
- NULL);
- zassert_equal(temp, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- convert_int3v_int16(ret, ret_v);
- compare_int3v_eps(exp_v, ret_v, 64);
-}
-
-/**
- * Test set accelerometer offset with and without rotation. Also test behaviour
- * on I2C error.
- */
-static void test_bmi_acc_set_offset(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- int16_t input_v[3];
- int16_t temp = 0;
- intv3_t ret_v;
- intv3_t exp_v;
- uint8_t nv_c;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Test fail on NV CONF register read and write */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_NV_CONF);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- i2c_common_emul_set_write_fail_reg(emul, BMI260_NV_CONF);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test fail on offset write */
- i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_ACC70);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_ACC70 + 1);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, BMI160_OFFSET_ACC70 + 2);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Setup NV_CONF register value */
- bmi_emul_set_reg(emul, BMI260_NV_CONF, 0x7);
- /* Set input offset */
- exp_v[0] = BMI_EMUL_1G / 10;
- exp_v[1] = BMI_EMUL_1G / 20;
- exp_v[2] = -(int)BMI_EMUL_1G / 30;
- /* BMI driver accept value in mg units */
- input_v[0] = 1000 / 10;
- input_v[1] = 1000 / 20;
- input_v[2] = -1000 / 30;
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
-
- /* Test set offset without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->set_offset(ms, input_v, temp), NULL);
- get_emul_acc_offset(emul, ret_v);
- /*
- * Depending on used range, accelerometer values may be up to 6 bits
- * more accurate then offset value resolution.
- */
- compare_int3v_eps(exp_v, ret_v, 64);
- nv_c = bmi_emul_get_reg(emul, BMI260_NV_CONF);
- /* Only ACC_OFFSET_EN bit should be changed */
- zassert_equal(0x7 | BMI260_ACC_OFFSET_EN, nv_c,
- "Expected 0x%x, got 0x%x",
- 0x7 | BMI260_ACC_OFFSET_EN, nv_c);
-
- /* Setup NV_CONF register value */
- bmi_emul_set_reg(emul, BMI260_NV_CONF, 0);
- /* Setup rotation and rotate input for set_offset function */
- ms->rot_standard_ref = &test_rotation;
- convert_int3v_int16(input_v, ret_v);
- rotate_int3v_by_test_rotation(ret_v);
- convert_int3v_int16(ret_v, input_v);
-
- /* Test set offset with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->set_offset(ms, input_v, temp), NULL);
- get_emul_acc_offset(emul, ret_v);
- compare_int3v_eps(exp_v, ret_v, 64);
- nv_c = bmi_emul_get_reg(emul, BMI260_NV_CONF);
- /* Only ACC_OFFSET_EN bit should be changed */
- zassert_equal(BMI260_ACC_OFFSET_EN, nv_c, "Expected 0x%x, got 0x%x",
- BMI260_ACC_OFFSET_EN, nv_c);
-}
-
-/**
- * Test set gyroscope offset with and without rotation. Also test behaviour
- * on I2C error.
- */
-static void test_bmi_gyr_set_offset(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- int16_t input_v[3];
- int16_t temp = 0;
- intv3_t ret_v;
- intv3_t exp_v;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Test fail on OFFSET EN GYR98 register read and write */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_OFFSET_EN_GYR98);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- i2c_common_emul_set_write_fail_reg(emul, BMI260_OFFSET_EN_GYR98);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test fail on offset write */
- i2c_common_emul_set_write_fail_reg(emul, BMI260_OFFSET_GYR70);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, BMI260_OFFSET_GYR70 + 1);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, BMI260_OFFSET_GYR70 + 2);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_offset(ms, input_v, temp),
- NULL);
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Set input offset */
- exp_v[0] = BMI_EMUL_125_DEG_S / 100;
- exp_v[1] = BMI_EMUL_125_DEG_S / 200;
- exp_v[2] = -(int)BMI_EMUL_125_DEG_S / 300;
- /* BMI driver accept value in mdeg/s units */
- input_v[0] = 125000 / 100;
- input_v[1] = 125000 / 200;
- input_v[2] = -125000 / 300;
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
-
- /* Test set offset without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->set_offset(ms, input_v, temp), NULL);
- get_emul_gyr_offset(emul, ret_v);
- /*
- * Depending on used range, gyroscope values may be up to 4 bits
- * more accurate then offset value resolution.
- */
- compare_int3v_eps(exp_v, ret_v, 32);
- /* Gyroscope offset should be enabled */
- zassert_true(bmi_emul_get_reg(emul, BMI260_OFFSET_EN_GYR98) &
- BMI260_OFFSET_GYRO_EN, NULL);
-
- /* Setup rotation and rotate input for set_offset function */
- ms->rot_standard_ref = &test_rotation;
- convert_int3v_int16(input_v, ret_v);
- rotate_int3v_by_test_rotation(ret_v);
- convert_int3v_int16(ret_v, input_v);
-
- /* Test set offset with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->set_offset(ms, input_v, temp), NULL);
- get_emul_gyr_offset(emul, ret_v);
- compare_int3v_eps(exp_v, ret_v, 32);
- zassert_true(bmi_emul_get_reg(emul, BMI260_OFFSET_EN_GYR98) &
- BMI260_OFFSET_GYRO_EN, NULL);
-}
-
-/**
- * Try to set accelerometer range and check if expected range was set
- * in driver and in emulator.
- */
-static void check_set_acc_range_f(struct i2c_emul *emul,
- struct motion_sensor_t *ms, int range,
- int rnd, int exp_range, int line)
-{
- uint8_t exp_range_reg;
- uint8_t range_reg;
-
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, range, rnd),
- "set_range failed; line: %d", line);
- zassert_equal(exp_range, ms->current_range,
- "Expected range %d, got %d; line %d",
- exp_range, ms->current_range, line);
- range_reg = bmi_emul_get_reg(emul, BMI260_ACC_RANGE);
-
- switch (exp_range) {
- case 2:
- exp_range_reg = BMI260_GSEL_2G;
- break;
- case 4:
- exp_range_reg = BMI260_GSEL_4G;
- break;
- case 8:
- exp_range_reg = BMI260_GSEL_8G;
- break;
- case 16:
- exp_range_reg = BMI260_GSEL_16G;
- break;
- default:
- /* Unknown expected range */
- zassert_unreachable(
- "Expected range %d not supported by device; line %d",
- exp_range, line);
- return;
- }
-
- zassert_equal(exp_range_reg, range_reg,
- "Expected range reg 0x%x, got 0x%x; line %d",
- exp_range_reg, range_reg, line);
-}
-#define check_set_acc_range(emul, ms, range, rnd, exp_range) \
- check_set_acc_range_f(emul, ms, range, rnd, exp_range, __LINE__)
-
-/** Test set accelerometer range with and without I2C errors */
-static void test_bmi_acc_set_range(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- int start_range;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Setup starting range, shouldn't be changed on error */
- start_range = 2;
- ms->current_range = start_range;
- bmi_emul_set_reg(emul, BMI260_ACC_RANGE, BMI260_GSEL_2G);
- /* Setup emulator fail on write */
- i2c_common_emul_set_write_fail_reg(emul, BMI260_ACC_RANGE);
-
- /* Test fail on write */
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 12, 0), NULL);
- zassert_equal(start_range, ms->current_range, NULL);
- zassert_equal(BMI260_GSEL_2G,
- bmi_emul_get_reg(emul, BMI260_ACC_RANGE), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 12, 1), NULL);
- zassert_equal(start_range, ms->current_range, NULL);
- zassert_equal(BMI260_GSEL_2G,
- bmi_emul_get_reg(emul, BMI260_ACC_RANGE), NULL);
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test setting range with rounding down */
- check_set_acc_range(emul, ms, 1, 0, 2);
- check_set_acc_range(emul, ms, 2, 0, 2);
- check_set_acc_range(emul, ms, 3, 0, 2);
- check_set_acc_range(emul, ms, 4, 0, 4);
- check_set_acc_range(emul, ms, 5, 0, 4);
- check_set_acc_range(emul, ms, 6, 0, 4);
- check_set_acc_range(emul, ms, 7, 0, 4);
- check_set_acc_range(emul, ms, 8, 0, 8);
- check_set_acc_range(emul, ms, 9, 0, 8);
- check_set_acc_range(emul, ms, 15, 0, 8);
- check_set_acc_range(emul, ms, 16, 0, 16);
- check_set_acc_range(emul, ms, 17, 0, 16);
-
- /* Test setting range with rounding up */
- check_set_acc_range(emul, ms, 1, 1, 2);
- check_set_acc_range(emul, ms, 2, 1, 2);
- check_set_acc_range(emul, ms, 3, 1, 4);
- check_set_acc_range(emul, ms, 4, 1, 4);
- check_set_acc_range(emul, ms, 5, 1, 8);
- check_set_acc_range(emul, ms, 6, 1, 8);
- check_set_acc_range(emul, ms, 7, 1, 8);
- check_set_acc_range(emul, ms, 8, 1, 8);
- check_set_acc_range(emul, ms, 9, 1, 16);
- check_set_acc_range(emul, ms, 15, 1, 16);
- check_set_acc_range(emul, ms, 16, 1, 16);
- check_set_acc_range(emul, ms, 17, 1, 16);
-}
-
-/**
- * Try to set gyroscope range and check if expected range was set in driver and
- * in emulator.
- */
-static void check_set_gyr_range_f(struct i2c_emul *emul,
- struct motion_sensor_t *ms, int range,
- int rnd, int exp_range, int line)
-{
- uint8_t exp_range_reg;
- uint8_t range_reg;
-
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, range, rnd),
- "set_range failed; line: %d", line);
- zassert_equal(exp_range, ms->current_range,
- "Expected range %d, got %d; line %d",
- exp_range, ms->current_range, line);
- range_reg = bmi_emul_get_reg(emul, BMI260_GYR_RANGE);
-
- switch (exp_range) {
- case 125:
- exp_range_reg = BMI260_DPS_SEL_125;
- break;
- case 250:
- exp_range_reg = BMI260_DPS_SEL_250;
- break;
- case 500:
- exp_range_reg = BMI260_DPS_SEL_500;
- break;
- case 1000:
- exp_range_reg = BMI260_DPS_SEL_1000;
- break;
- case 2000:
- exp_range_reg = BMI260_DPS_SEL_2000;
- break;
- default:
- /* Unknown expected range */
- zassert_unreachable(
- "Expected range %d not supported by device; line %d",
- exp_range, line);
- return;
- }
-
- zassert_equal(exp_range_reg, range_reg,
- "Expected range reg 0x%x, got 0x%x; line %d",
- exp_range_reg, range_reg, line);
-}
-#define check_set_gyr_range(emul, ms, range, rnd, exp_range) \
- check_set_gyr_range_f(emul, ms, range, rnd, exp_range, __LINE__)
-
-/** Test set gyroscope range with and without I2C errors */
-static void test_bmi_gyr_set_range(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- int start_range;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Setup starting range, shouldn't be changed on error */
- start_range = 250;
- ms->current_range = start_range;
- bmi_emul_set_reg(emul, BMI260_GYR_RANGE, BMI260_DPS_SEL_250);
- /* Setup emulator fail on write */
- i2c_common_emul_set_write_fail_reg(emul, BMI260_GYR_RANGE);
-
- /* Test fail on write */
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 125, 0), NULL);
- zassert_equal(start_range, ms->current_range, NULL);
- zassert_equal(BMI260_DPS_SEL_250,
- bmi_emul_get_reg(emul, BMI260_GYR_RANGE), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_range(ms, 125, 1), NULL);
- zassert_equal(start_range, ms->current_range, NULL);
- zassert_equal(BMI260_DPS_SEL_250,
- bmi_emul_get_reg(emul, BMI260_GYR_RANGE), NULL);
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test setting range with rounding down */
- check_set_gyr_range(emul, ms, 1, 0, 125);
- check_set_gyr_range(emul, ms, 124, 0, 125);
- check_set_gyr_range(emul, ms, 125, 0, 125);
- check_set_gyr_range(emul, ms, 126, 0, 125);
- check_set_gyr_range(emul, ms, 249, 0, 125);
- check_set_gyr_range(emul, ms, 250, 0, 250);
- check_set_gyr_range(emul, ms, 251, 0, 250);
- check_set_gyr_range(emul, ms, 499, 0, 250);
- check_set_gyr_range(emul, ms, 500, 0, 500);
- check_set_gyr_range(emul, ms, 501, 0, 500);
- check_set_gyr_range(emul, ms, 999, 0, 500);
- check_set_gyr_range(emul, ms, 1000, 0, 1000);
- check_set_gyr_range(emul, ms, 1001, 0, 1000);
- check_set_gyr_range(emul, ms, 1999, 0, 1000);
- check_set_gyr_range(emul, ms, 2000, 0, 2000);
- check_set_gyr_range(emul, ms, 2001, 0, 2000);
-
- /* Test setting range with rounding up */
- check_set_gyr_range(emul, ms, 1, 1, 125);
- check_set_gyr_range(emul, ms, 124, 1, 125);
- check_set_gyr_range(emul, ms, 125, 1, 125);
- check_set_gyr_range(emul, ms, 126, 1, 250);
- check_set_gyr_range(emul, ms, 249, 1, 250);
- check_set_gyr_range(emul, ms, 250, 1, 250);
- check_set_gyr_range(emul, ms, 251, 1, 500);
- check_set_gyr_range(emul, ms, 499, 1, 500);
- check_set_gyr_range(emul, ms, 500, 1, 500);
- check_set_gyr_range(emul, ms, 501, 1, 1000);
- check_set_gyr_range(emul, ms, 999, 1, 1000);
- check_set_gyr_range(emul, ms, 1000, 1, 1000);
- check_set_gyr_range(emul, ms, 1001, 1, 2000);
- check_set_gyr_range(emul, ms, 1999, 1, 2000);
- check_set_gyr_range(emul, ms, 2000, 1, 2000);
- check_set_gyr_range(emul, ms, 2001, 1, 2000);
-}
-
-/** Test get resolution of acclerometer and gyroscope sensor */
-static void test_bmi_get_resolution(void)
-{
- struct motion_sensor_t *ms;
-
- /* Test accelerometer */
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Resolution should be always 16 bits */
- zassert_equal(16, ms->drv->get_resolution(ms), NULL);
-
- /* Test gyroscope */
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Resolution should be always 16 bits */
- zassert_equal(16, ms->drv->get_resolution(ms), NULL);
-}
-
-/**
- * Try to set accelerometer data rate and check if expected rate was set
- * in driver and in emulator.
- */
-static void check_set_acc_rate_f(struct i2c_emul *emul,
- struct motion_sensor_t *ms, int rate, int rnd,
- int exp_rate, int line)
-{
- uint8_t exp_rate_reg;
- uint8_t rate_reg;
- int drv_rate;
-
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, rate, rnd),
- "set_data_rate failed; line: %d", line);
- drv_rate = ms->drv->get_data_rate(ms);
- zassert_equal(exp_rate, drv_rate, "Expected rate %d, got %d; line %d",
- exp_rate, drv_rate, line);
- rate_reg = bmi_emul_get_reg(emul, BMI260_ACC_CONF);
- rate_reg &= BMI_ODR_MASK;
-
- switch (exp_rate) {
- case 12500:
- exp_rate_reg = 0x5;
- break;
- case 25000:
- exp_rate_reg = 0x6;
- break;
- case 50000:
- exp_rate_reg = 0x7;
- break;
- case 100000:
- exp_rate_reg = 0x8;
- break;
- case 200000:
- exp_rate_reg = 0x9;
- break;
- case 400000:
- exp_rate_reg = 0xa;
- break;
- case 800000:
- exp_rate_reg = 0xb;
- break;
- case 1600000:
- exp_rate_reg = 0xc;
- break;
- default:
- /* Unknown expected rate */
- zassert_unreachable(
- "Expected rate %d not supported by device; line %d",
- exp_rate, line);
- return;
- }
-
- zassert_equal(exp_rate_reg, rate_reg,
- "Expected rate reg 0x%x, got 0x%x; line %d",
- exp_rate_reg, rate_reg, line);
-}
-#define check_set_acc_rate(emul, ms, rate, rnd, exp_rate) \
- check_set_acc_rate_f(emul, ms, rate, rnd, exp_rate, __LINE__)
-
-/** Test set and get accelerometer rate with and without I2C errors */
-static void test_bmi_acc_rate(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- uint8_t reg_rate;
- uint8_t pwr_ctrl;
- int drv_rate;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Test setting rate with rounding down */
- check_set_acc_rate(emul, ms, 12500, 0, 12500);
- check_set_acc_rate(emul, ms, 12501, 0, 12500);
- check_set_acc_rate(emul, ms, 24999, 0, 12500);
- check_set_acc_rate(emul, ms, 25000, 0, 25000);
- check_set_acc_rate(emul, ms, 25001, 0, 25000);
- check_set_acc_rate(emul, ms, 49999, 0, 25000);
- check_set_acc_rate(emul, ms, 50000, 0, 50000);
- check_set_acc_rate(emul, ms, 50001, 0, 50000);
- check_set_acc_rate(emul, ms, 99999, 0, 50000);
- check_set_acc_rate(emul, ms, 100000, 0, 100000);
- check_set_acc_rate(emul, ms, 100001, 0, 100000);
- check_set_acc_rate(emul, ms, 199999, 0, 100000);
- check_set_acc_rate(emul, ms, 200000, 0, 200000);
- check_set_acc_rate(emul, ms, 200001, 0, 200000);
- check_set_acc_rate(emul, ms, 399999, 0, 200000);
- /*
- * We cannot test frequencies from 400000 to 1600000 because
- * CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ is set to 250000
- */
-
- /* Test setting rate with rounding up */
- check_set_acc_rate(emul, ms, 6251, 1, 12500);
- check_set_acc_rate(emul, ms, 12499, 1, 12500);
- check_set_acc_rate(emul, ms, 12500, 1, 12500);
- check_set_acc_rate(emul, ms, 12501, 1, 25000);
- check_set_acc_rate(emul, ms, 24999, 1, 25000);
- check_set_acc_rate(emul, ms, 25000, 1, 25000);
- check_set_acc_rate(emul, ms, 25001, 1, 50000);
- check_set_acc_rate(emul, ms, 49999, 1, 50000);
- check_set_acc_rate(emul, ms, 50000, 1, 50000);
- check_set_acc_rate(emul, ms, 50001, 1, 100000);
- check_set_acc_rate(emul, ms, 99999, 1, 100000);
- check_set_acc_rate(emul, ms, 100000, 1, 100000);
- check_set_acc_rate(emul, ms, 100001, 1, 200000);
- check_set_acc_rate(emul, ms, 199999, 1, 200000);
- check_set_acc_rate(emul, ms, 200000, 1, 200000);
-
- /* Test out of range rate with rounding down */
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 1, 0), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 12499, 0), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 400000, 0), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 2000000, 0), NULL);
-
- /* Test out of range rate with rounding up */
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 1, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 6250, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 200001, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 400000, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 2000000, 1), NULL);
-
- /* Current rate shouldn't be changed on error */
- drv_rate = ms->drv->get_data_rate(ms);
- reg_rate = bmi_emul_get_reg(emul, BMI260_ACC_CONF);
-
- /* Setup emulator fail on read */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_CONF);
-
- /* Test fail on read */
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_ACC_CONF), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_ACC_CONF), NULL);
-
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Setup emulator fail on write */
- i2c_common_emul_set_write_fail_reg(emul, BMI260_ACC_CONF);
-
- /* Test fail on write */
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_ACC_CONF), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_ACC_CONF), NULL);
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test disabling sensor */
- bmi_emul_set_reg(emul, BMI260_PWR_CTRL,
- BMI260_AUX_EN | BMI260_GYR_EN | BMI260_ACC_EN);
- bmi_emul_set_reg(emul, BMI260_ACC_CONF, BMI260_FILTER_PERF);
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 0, 0), NULL);
-
- pwr_ctrl = bmi_emul_get_reg(emul, BMI260_PWR_CTRL);
- reg_rate = bmi_emul_get_reg(emul, BMI260_ACC_CONF);
- zassert_equal(BMI260_AUX_EN | BMI260_GYR_EN, pwr_ctrl, NULL);
- zassert_true(!(reg_rate & BMI260_FILTER_PERF), NULL);
-
- /* Test enabling sensor */
- bmi_emul_set_reg(emul, BMI260_PWR_CTRL, 0);
- bmi_emul_set_reg(emul, BMI260_ACC_CONF, 0);
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 50000, 0), NULL);
-
- pwr_ctrl = bmi_emul_get_reg(emul, BMI260_PWR_CTRL);
- reg_rate = bmi_emul_get_reg(emul, BMI260_ACC_CONF);
- zassert_equal(BMI260_ACC_EN, pwr_ctrl, NULL);
- zassert_true(reg_rate & BMI260_FILTER_PERF, NULL);
-}
-
-/**
- * Try to set gyroscope data rate and check if expected rate was set
- * in driver and in emulator.
- */
-static void check_set_gyr_rate_f(struct i2c_emul *emul,
- struct motion_sensor_t *ms, int rate, int rnd,
- int exp_rate, int line)
-{
- uint8_t exp_rate_reg;
- uint8_t rate_reg;
- int drv_rate;
-
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, rate, rnd),
- "set_data_rate failed; line: %d", line);
- drv_rate = ms->drv->get_data_rate(ms);
- zassert_equal(exp_rate, drv_rate, "Expected rate %d, got %d; line %d",
- exp_rate, drv_rate, line);
- rate_reg = bmi_emul_get_reg(emul, BMI260_GYR_CONF);
- rate_reg &= BMI_ODR_MASK;
-
- switch (exp_rate) {
- case 25000:
- exp_rate_reg = 0x6;
- break;
- case 50000:
- exp_rate_reg = 0x7;
- break;
- case 100000:
- exp_rate_reg = 0x8;
- break;
- case 200000:
- exp_rate_reg = 0x9;
- break;
- case 400000:
- exp_rate_reg = 0xa;
- break;
- case 800000:
- exp_rate_reg = 0xb;
- break;
- case 1600000:
- exp_rate_reg = 0xc;
- break;
- case 3200000:
- exp_rate_reg = 0xc;
- break;
- default:
- /* Unknown expected rate */
- zassert_unreachable(
- "Expected rate %d not supported by device; line %d",
- exp_rate, line);
- return;
- }
-
- zassert_equal(exp_rate_reg, rate_reg,
- "Expected rate reg 0x%x, got 0x%x; line %d",
- exp_rate_reg, rate_reg, line);
-}
-#define check_set_gyr_rate(emul, ms, rate, rnd, exp_rate) \
- check_set_gyr_rate_f(emul, ms, rate, rnd, exp_rate, __LINE__)
-
-/** Test set and get gyroscope rate with and without I2C errors */
-static void test_bmi_gyr_rate(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- uint8_t reg_rate;
- uint8_t pwr_ctrl;
- int drv_rate;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Test setting rate with rounding down */
- check_set_gyr_rate(emul, ms, 25000, 0, 25000);
- check_set_gyr_rate(emul, ms, 25001, 0, 25000);
- check_set_gyr_rate(emul, ms, 49999, 0, 25000);
- check_set_gyr_rate(emul, ms, 50000, 0, 50000);
- check_set_gyr_rate(emul, ms, 50001, 0, 50000);
- check_set_gyr_rate(emul, ms, 99999, 0, 50000);
- check_set_gyr_rate(emul, ms, 100000, 0, 100000);
- check_set_gyr_rate(emul, ms, 100001, 0, 100000);
- check_set_gyr_rate(emul, ms, 199999, 0, 100000);
- check_set_gyr_rate(emul, ms, 200000, 0, 200000);
- check_set_gyr_rate(emul, ms, 200001, 0, 200000);
- check_set_gyr_rate(emul, ms, 399999, 0, 200000);
- /*
- * We cannot test frequencies from 400000 to 3200000 because
- * CONFIG_EC_MAX_SENSOR_FREQ_MILLIHZ is set to 250000
- */
-
- /* Test setting rate with rounding up */
- check_set_gyr_rate(emul, ms, 12501, 1, 25000);
- check_set_gyr_rate(emul, ms, 24999, 1, 25000);
- check_set_gyr_rate(emul, ms, 25000, 1, 25000);
- check_set_gyr_rate(emul, ms, 25001, 1, 50000);
- check_set_gyr_rate(emul, ms, 49999, 1, 50000);
- check_set_gyr_rate(emul, ms, 50000, 1, 50000);
- check_set_gyr_rate(emul, ms, 50001, 1, 100000);
- check_set_gyr_rate(emul, ms, 99999, 1, 100000);
- check_set_gyr_rate(emul, ms, 100000, 1, 100000);
- check_set_gyr_rate(emul, ms, 100001, 1, 200000);
- check_set_gyr_rate(emul, ms, 199999, 1, 200000);
- check_set_gyr_rate(emul, ms, 200000, 1, 200000);
-
- /* Test out of range rate with rounding down */
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 1, 0), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 24999, 0), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 400000, 0), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 4000000, 0), NULL);
-
- /* Test out of range rate with rounding up */
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 1, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 12499, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 200001, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 400000, 1), NULL);
- zassert_equal(EC_RES_INVALID_PARAM,
- ms->drv->set_data_rate(ms, 4000000, 1), NULL);
-
- /* Current rate shouldn't be changed on error */
- drv_rate = ms->drv->get_data_rate(ms);
- reg_rate = bmi_emul_get_reg(emul, BMI260_GYR_CONF);
-
- /* Setup emulator fail on read */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_CONF);
-
- /* Test fail on read */
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_GYR_CONF), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_GYR_CONF), NULL);
-
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Setup emulator fail on write */
- i2c_common_emul_set_write_fail_reg(emul, BMI260_GYR_CONF);
-
- /* Test fail on write */
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 0),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_GYR_CONF), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 50000, 1),
- NULL);
- zassert_equal(drv_rate, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(reg_rate, bmi_emul_get_reg(emul, BMI260_GYR_CONF), NULL);
-
- /* Do not fail on write */
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test disabling sensor */
- bmi_emul_set_reg(emul, BMI260_PWR_CTRL,
- BMI260_AUX_EN | BMI260_GYR_EN | BMI260_ACC_EN);
- bmi_emul_set_reg(emul, BMI260_GYR_CONF,
- BMI260_FILTER_PERF | BMI260_GYR_NOISE_PERF);
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 0, 0), NULL);
-
- pwr_ctrl = bmi_emul_get_reg(emul, BMI260_PWR_CTRL);
- reg_rate = bmi_emul_get_reg(emul, BMI260_GYR_CONF);
- zassert_equal(BMI260_AUX_EN | BMI260_ACC_EN, pwr_ctrl, NULL);
- zassert_true(!(reg_rate & (BMI260_FILTER_PERF | BMI260_GYR_NOISE_PERF)),
- NULL);
-
- /* Test enabling sensor */
- bmi_emul_set_reg(emul, BMI260_PWR_CTRL, 0);
- bmi_emul_set_reg(emul, BMI260_GYR_CONF, 0);
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 50000, 0), NULL);
-
- pwr_ctrl = bmi_emul_get_reg(emul, BMI260_PWR_CTRL);
- reg_rate = bmi_emul_get_reg(emul, BMI260_GYR_CONF);
- zassert_equal(BMI260_GYR_EN, pwr_ctrl, NULL);
- zassert_true(reg_rate & (BMI260_FILTER_PERF | BMI260_GYR_NOISE_PERF),
- NULL);
-}
-
-/**
- * Test setting and getting scale in accelerometer and gyroscope sensors.
- * Correct appling scale to results is checked in "read" test.
- */
-static void test_bmi_scale(void)
-{
- struct motion_sensor_t *ms;
- int16_t ret_scale[3];
- int16_t exp_scale[3] = {100, 231, 421};
- int16_t t;
-
- /* Test accelerometer */
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- zassert_equal(EC_SUCCESS, ms->drv->set_scale(ms, exp_scale, 0), NULL);
- zassert_equal(EC_SUCCESS, ms->drv->get_scale(ms, ret_scale, &t), NULL);
-
- zassert_equal(t, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- zassert_equal(exp_scale[0], ret_scale[0], NULL);
- zassert_equal(exp_scale[1], ret_scale[1], NULL);
- zassert_equal(exp_scale[2], ret_scale[2], NULL);
-
- /* Test gyroscope */
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- zassert_equal(EC_SUCCESS, ms->drv->set_scale(ms, exp_scale, 0), NULL);
- zassert_equal(EC_SUCCESS, ms->drv->get_scale(ms, ret_scale, &t), NULL);
-
- zassert_equal(t, (int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, NULL);
- zassert_equal(exp_scale[0], ret_scale[0], NULL);
- zassert_equal(exp_scale[1], ret_scale[1], NULL);
- zassert_equal(exp_scale[2], ret_scale[2], NULL);
-}
-
-/** Test reading temperature using accelerometer and gyroscope sensors */
-static void test_bmi_read_temp(void)
-{
- struct motion_sensor_t *ms_acc, *ms_gyr;
- struct i2c_emul *emul;
- int ret_temp;
- int exp_temp;
-
- emul = bmi_emul_get(BMI_ORD);
- ms_acc = &motion_sensors[BMI_ACC_SENSOR_ID];
- ms_gyr = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Setup emulator fail on read */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_TEMPERATURE_0);
- zassert_equal(EC_ERROR_NOT_POWERED,
- ms_acc->drv->read_temp(ms_acc, &ret_temp), NULL);
- zassert_equal(EC_ERROR_NOT_POWERED,
- ms_gyr->drv->read_temp(ms_gyr, &ret_temp), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI260_TEMPERATURE_1);
- zassert_equal(EC_ERROR_NOT_POWERED,
- ms_acc->drv->read_temp(ms_acc, &ret_temp), NULL);
- zassert_equal(EC_ERROR_NOT_POWERED,
- ms_gyr->drv->read_temp(ms_gyr, &ret_temp), NULL);
- /* Do not fail on read */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Fail on invalid temperature */
- bmi_emul_set_reg(emul, BMI260_TEMPERATURE_0, 0x00);
- bmi_emul_set_reg(emul, BMI260_TEMPERATURE_1, 0x80);
- zassert_equal(EC_ERROR_NOT_POWERED,
- ms_acc->drv->read_temp(ms_acc, &ret_temp), NULL);
- zassert_equal(EC_ERROR_NOT_POWERED,
- ms_gyr->drv->read_temp(ms_gyr, &ret_temp), NULL);
-
- /*
- * Test correct values. Both motion sensors should return the same
- * temperature.
- */
- exp_temp = C_TO_K(23);
- bmi_emul_set_reg(emul, BMI260_TEMPERATURE_0, 0x00);
- bmi_emul_set_reg(emul, BMI260_TEMPERATURE_1, 0x00);
- zassert_equal(EC_SUCCESS, ms_acc->drv->read_temp(ms_acc, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
- zassert_equal(EC_SUCCESS, ms_gyr->drv->read_temp(ms_gyr, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
-
- exp_temp = C_TO_K(87);
- bmi_emul_set_reg(emul, BMI260_TEMPERATURE_0, 0xff);
- bmi_emul_set_reg(emul, BMI260_TEMPERATURE_1, 0x7f);
- zassert_equal(EC_SUCCESS, ms_acc->drv->read_temp(ms_acc, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
- zassert_equal(EC_SUCCESS, ms_gyr->drv->read_temp(ms_gyr, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
-
- exp_temp = C_TO_K(-41);
- bmi_emul_set_reg(emul, BMI260_TEMPERATURE_0, 0x01);
- bmi_emul_set_reg(emul, BMI260_TEMPERATURE_1, 0x80);
- zassert_equal(EC_SUCCESS, ms_acc->drv->read_temp(ms_acc, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
- zassert_equal(EC_SUCCESS, ms_gyr->drv->read_temp(ms_gyr, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
-
- exp_temp = C_TO_K(47);
- bmi_emul_set_reg(emul, BMI260_TEMPERATURE_0, 0x00);
- bmi_emul_set_reg(emul, BMI260_TEMPERATURE_1, 0x30);
- zassert_equal(EC_SUCCESS, ms_acc->drv->read_temp(ms_acc, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
- zassert_equal(EC_SUCCESS, ms_gyr->drv->read_temp(ms_gyr, &ret_temp),
- NULL);
- zassert_equal(exp_temp, ret_temp, NULL);
-}
-
-/** Test reading accelerometer sensor data */
-static void test_bmi_acc_read(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- intv3_t ret_v;
- intv3_t exp_v;
- int16_t scale[3] = {MOTION_SENSE_DEFAULT_SCALE,
- MOTION_SENSE_DEFAULT_SCALE,
- MOTION_SENSE_DEFAULT_SCALE};
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Set offset 0 to simplify test */
- bmi_emul_set_off(emul, BMI_EMUL_ACC_X, 0);
- bmi_emul_set_off(emul, BMI_EMUL_ACC_Y, 0);
- bmi_emul_set_off(emul, BMI_EMUL_ACC_Z, 0);
-
- /* Fail on read status */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_STATUS);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
-
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* When not ready, driver should return saved raw value */
- exp_v[0] = 100;
- exp_v[1] = 200;
- exp_v[2] = 300;
- ms->raw_xyz[0] = exp_v[0];
- ms->raw_xyz[1] = exp_v[1];
- ms->raw_xyz[2] = exp_v[2];
-
- /* Status not ready */
- bmi_emul_set_reg(emul, BMI260_STATUS, 0);
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- compare_int3v(exp_v, ret_v);
-
- /* Status only GYR ready */
- bmi_emul_set_reg(emul, BMI260_STATUS, BMI260_DRDY_GYR);
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- compare_int3v(exp_v, ret_v);
-
- /* Status ACC ready */
- bmi_emul_set_reg(emul, BMI260_STATUS, BMI260_DRDY_ACC);
-
- /* Set input accelerometer values */
- exp_v[0] = BMI_EMUL_1G / 10;
- exp_v[1] = BMI_EMUL_1G / 20;
- exp_v[2] = -(int)BMI_EMUL_1G / 30;
- set_emul_acc(emul, exp_v);
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
- /* Set scale */
- zassert_equal(EC_SUCCESS, ms->drv->set_scale(ms, scale, 0), NULL);
- /* Set range to 2G */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 2, 0), NULL);
-
- /* Test read without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_acc_to_emul(ret_v, 2, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Set range to 4G */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 4, 0), NULL);
-
- /* Test read without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_acc_to_emul(ret_v, 4, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Setup rotation and rotate expected vector */
- ms->rot_standard_ref = &test_rotation;
- rotate_int3v_by_test_rotation(exp_v);
- /* Set range to 2G */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 2, 0), NULL);
-
- /* Test read with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_acc_to_emul(ret_v, 2, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Set range to 4G */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 4, 0), NULL);
-
- /* Test read with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_acc_to_emul(ret_v, 4, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Fail on read of data registers */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_X_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_X_H_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_Y_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_Y_H_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_Z_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_Z_H_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
-
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- ms->rot_standard_ref = NULL;
-}
-
-/** Test reading gyroscope sensor data */
-static void test_bmi_gyr_read(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- intv3_t ret_v;
- intv3_t exp_v;
- int16_t scale[3] = {MOTION_SENSE_DEFAULT_SCALE,
- MOTION_SENSE_DEFAULT_SCALE,
- MOTION_SENSE_DEFAULT_SCALE};
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Set offset 0 to simplify test */
- bmi_emul_set_off(emul, BMI_EMUL_GYR_X, 0);
- bmi_emul_set_off(emul, BMI_EMUL_GYR_Y, 0);
- bmi_emul_set_off(emul, BMI_EMUL_GYR_Z, 0);
-
- /* Fail on read status */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_STATUS);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
-
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* When not ready, driver should return saved raw value */
- exp_v[0] = 100;
- exp_v[1] = 200;
- exp_v[2] = 300;
- ms->raw_xyz[0] = exp_v[0];
- ms->raw_xyz[1] = exp_v[1];
- ms->raw_xyz[2] = exp_v[2];
-
- /* Status not ready */
- bmi_emul_set_reg(emul, BMI260_STATUS, 0);
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- compare_int3v(exp_v, ret_v);
-
- /* Status only ACC ready */
- bmi_emul_set_reg(emul, BMI260_STATUS, BMI260_DRDY_ACC);
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- compare_int3v(exp_v, ret_v);
-
- /* Status GYR ready */
- bmi_emul_set_reg(emul, BMI260_STATUS, BMI260_DRDY_GYR);
-
- /* Set input accelerometer values */
- exp_v[0] = BMI_EMUL_125_DEG_S / 10;
- exp_v[1] = BMI_EMUL_125_DEG_S / 20;
- exp_v[2] = -(int)BMI_EMUL_125_DEG_S / 30;
- set_emul_gyr(emul, exp_v);
- /* Disable rotation */
- ms->rot_standard_ref = NULL;
- /* Set scale */
- zassert_equal(EC_SUCCESS, ms->drv->set_scale(ms, scale, 0), NULL);
- /* Set range to 125°/s */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 125, 0), NULL);
-
- /* Test read without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_gyr_to_emul(ret_v, 125, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Set range to 1000°/s */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 1000, 0), NULL);
-
- /* Test read without rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_gyr_to_emul(ret_v, 1000, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Setup rotation and rotate expected vector */
- ms->rot_standard_ref = &test_rotation;
- rotate_int3v_by_test_rotation(exp_v);
- /* Set range to 125°/s */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 125, 0), NULL);
-
- /* Test read with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_gyr_to_emul(ret_v, 125, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Set range to 1000°/s */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 1000, 0), NULL);
-
- /* Test read with rotation */
- zassert_equal(EC_SUCCESS, ms->drv->read(ms, ret_v), NULL);
- drv_gyr_to_emul(ret_v, 1000, ret_v);
- compare_int3v(exp_v, ret_v);
-
- /* Fail on read of data registers */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_X_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_X_H_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_Y_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_Y_H_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_Z_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_Z_H_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, ret_v), NULL);
-
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- ms->rot_standard_ref = NULL;
-}
-
-/** Test acceleromtere calibration */
-static void test_bmi_acc_perform_calib(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- intv3_t start_off;
- intv3_t exp_off;
- intv3_t ret_off;
- int range;
- int rate;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
-
- /* Range and rate cannot change after calibration */
- range = 4;
- rate = 50000;
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, range, 0), NULL);
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, rate, 0), NULL);
-
- /* Set offset 0 */
- start_off[0] = 0;
- start_off[1] = 0;
- start_off[2] = 0;
- set_emul_acc_offset(emul, start_off);
-
- /* Set input accelerometer values */
- exp_off[0] = BMI_EMUL_1G / 10;
- exp_off[1] = BMI_EMUL_1G / 20;
- exp_off[2] = BMI_EMUL_1G - (int)BMI_EMUL_1G / 30;
- set_emul_acc(emul, exp_off);
-
- /* Expected offset is [-X, -Y, 1G - Z] */
- exp_off[0] = -exp_off[0];
- exp_off[1] = -exp_off[1];
- exp_off[2] = BMI_EMUL_1G - exp_off[2];
-
- /* Test success on disabling calibration */
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 0), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /* Test fail on rate read */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_CONF);
- zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /* Test fail on status read */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_STATUS);
- zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /* Test fail on data not ready */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- bmi_emul_set_reg(emul, BMI260_STATUS, 0);
- zassert_equal(EC_ERROR_TIMEOUT, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /* Setup data status ready for rest of the test */
- bmi_emul_set_reg(emul, BMI260_STATUS, BMI260_DRDY_ACC);
-
- /* Test fail on data read */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_ACC_X_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /* Test fail on setting offset */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_NV_CONF);
- zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test successful offset compenastion */
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
- get_emul_acc_offset(emul, ret_off);
- /*
- * Depending on used range, accelerometer values may be up to 6 bits
- * more accurate then offset value resolution.
- */
- compare_int3v_eps(exp_off, ret_off, 64);
-}
-
-/** Test gyroscope calibration */
-static void test_bmi_gyr_perform_calib(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- intv3_t start_off;
- intv3_t exp_off;
- intv3_t ret_off;
- int range;
- int rate;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Range and rate cannot change after calibration */
- range = 125;
- rate = 50000;
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, range, 0), NULL);
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, rate, 0), NULL);
-
- /* Set offset 0 */
- start_off[0] = 0;
- start_off[1] = 0;
- start_off[2] = 0;
- set_emul_gyr_offset(emul, start_off);
-
- /* Set input accelerometer values */
- exp_off[0] = BMI_EMUL_125_DEG_S / 100;
- exp_off[1] = BMI_EMUL_125_DEG_S / 200;
- exp_off[2] = -(int)BMI_EMUL_125_DEG_S / 300;
- set_emul_gyr(emul, exp_off);
-
- /* Expected offset is [-X, -Y, -Z] */
- exp_off[0] = -exp_off[0];
- exp_off[1] = -exp_off[1];
- exp_off[2] = -exp_off[2];
-
- /* Test success on disabling calibration */
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 0), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /* Test fail on rate read */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_CONF);
- zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /* Test fail on status read */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_STATUS);
- zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /* Test fail on data not ready */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- bmi_emul_set_reg(emul, BMI260_STATUS, 0);
- zassert_equal(EC_ERROR_TIMEOUT, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /*
- * Setup data status ready for rest of the test. Gyroscope calibration
- * should check DRDY_GYR bit, but current driver check only for ACC.
- */
- bmi_emul_set_reg(emul, BMI260_STATUS,
- BMI260_DRDY_ACC | BMI260_DRDY_GYR);
-
- /* Test fail on data read */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_GYR_X_L_G);
- zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- /* Test fail on setting offset */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_OFFSET_EN_GYR98);
- zassert_equal(EC_ERROR_INVAL, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
-
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test successful offset compenastion */
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(range, ms->current_range, NULL);
- zassert_equal(rate, ms->drv->get_data_rate(ms), NULL);
- get_emul_gyr_offset(emul, ret_off);
- /*
- * Depending on used range, gyroscope values may be up to 4 bits
- * more accurate then offset value resolution.
- */
- compare_int3v_eps(exp_off, ret_off, 32);
-}
-
-/**
- * Custom emulatro read function which always return INIT OK status in
- * INTERNAL STATUS register. Used in init test.
- */
-static int emul_init_ok(struct i2c_emul *emul, int reg, uint8_t *val, int byte,
- void *data)
-{
- bmi_emul_set_reg(emul, BMI260_INTERNAL_STATUS, BMI260_INIT_OK);
-
- return 1;
-}
-
-/** Test init function of BMI260 accelerometer and gyroscope sensors */
-static void test_bmi_init(void)
-{
- struct motion_sensor_t *ms_acc, *ms_gyr;
- struct i2c_emul *emul;
-
- emul = bmi_emul_get(BMI_ORD);
- ms_acc = &motion_sensors[BMI_ACC_SENSOR_ID];
- ms_gyr = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /*
- * Test successful init. It is needed custom function to set value of
- * BMI260_INTERNAL_STATUS register, because init function triggers reset
- * which clears value set in this register before test.
- */
- i2c_common_emul_set_read_func(emul, emul_init_ok, NULL);
- zassert_equal(EC_RES_SUCCESS, ms_acc->drv->init(ms_acc), NULL);
-
- zassert_equal(EC_RES_SUCCESS, ms_gyr->drv->init(ms_gyr), NULL);
-
- /* Remove custom emulator read function */
- i2c_common_emul_set_read_func(emul, NULL, NULL);
-}
-
-/** Data for custom emulator read function used in FIFO test */
-struct fifo_func_data {
- uint16_t interrupts;
-};
-
-/**
- * Custom emulator read function used in FIFO test. It sets interrupt registers
- * to value passed as additional data. It sets interrupt registers to 0 after
- * access.
- */
-static int emul_fifo_func(struct i2c_emul *emul, int reg, uint8_t *val,
- int byte, void *data)
-{
- struct fifo_func_data *d = data;
-
- if (reg + byte == BMI260_INT_STATUS_0) {
- bmi_emul_set_reg(emul, BMI260_INT_STATUS_0,
- d->interrupts & 0xff);
- d->interrupts &= 0xff00;
- } else if (reg + byte == BMI260_INT_STATUS_1) {
- bmi_emul_set_reg(emul, BMI260_INT_STATUS_1,
- (d->interrupts >> 8) & 0xff);
- d->interrupts &= 0xff;
- }
-
- return 1;
-}
-
-/**
- * Run irq handler on accelerometer sensor and check if committed data in FIFO
- * match what was set in FIFO frames in emulator.
- */
-static void check_fifo_f(struct motion_sensor_t *ms_acc,
- struct motion_sensor_t *ms_gyr,
- struct bmi_emul_frame *frame,
- int acc_range, int gyr_range,
- int line)
-{
- struct ec_response_motion_sensor_data vector;
- struct bmi_emul_frame *f_acc, *f_gyr;
- uint32_t event = BMI_INT_EVENT;
- uint16_t size;
- intv3_t exp_v;
- intv3_t ret_v;
-
- /* Find first frame of acc and gyr type */
- f_acc = frame;
- while (f_acc != NULL && !(f_acc->type & BMI_EMUL_FRAME_ACC)) {
- f_acc = f_acc->next;
- }
-
- f_gyr = frame;
- while (f_gyr != NULL && !(f_gyr->type & BMI_EMUL_FRAME_GYR)) {
- f_gyr = f_gyr->next;
- }
-
- /* Read FIFO in driver */
- zassert_equal(EC_SUCCESS, ms_acc->drv->irq_handler(ms_acc, &event),
- NULL);
-
- /* Read all data committed to FIFO */
- while (motion_sense_fifo_read(sizeof(vector), 1, &vector, &size)) {
- /* Ignore timestamp frames */
- if (vector.flags == MOTIONSENSE_SENSOR_FLAG_TIMESTAMP) {
- continue;
- }
-
- /* Check acclerometer frames */
- if (ms_acc - motion_sensors == vector.sensor_num) {
- if (f_acc == NULL) {
- zassert_unreachable(
- "Not expected acclerometer data in FIFO, line %d",
- line);
- }
-
- convert_int3v_int16(vector.data, ret_v);
- drv_acc_to_emul(ret_v, acc_range, ret_v);
- exp_v[0] = f_acc->acc_x;
- exp_v[1] = f_acc->acc_y;
- exp_v[2] = f_acc->acc_z;
- compare_int3v_f(exp_v, ret_v, V_EPS, line);
- f_acc = f_acc->next;
- }
-
- /* Check gyroscope frames */
- if (ms_gyr - motion_sensors == vector.sensor_num) {
- if (f_gyr == NULL) {
- zassert_unreachable(
- "Not expected gyroscope data in FIFO, line %d",
- line);
- }
-
- convert_int3v_int16(vector.data, ret_v);
- drv_gyr_to_emul(ret_v, gyr_range, ret_v);
- exp_v[0] = f_gyr->gyr_x;
- exp_v[1] = f_gyr->gyr_y;
- exp_v[2] = f_gyr->gyr_z;
- compare_int3v_f(exp_v, ret_v, V_EPS, line);
- f_gyr = f_gyr->next;
- }
- }
-
- /* Skip frames of different type at the end */
- while (f_acc != NULL && !(f_acc->type & BMI_EMUL_FRAME_ACC)) {
- f_acc = f_acc->next;
- }
-
- while (f_gyr != NULL && !(f_gyr->type & BMI_EMUL_FRAME_GYR)) {
- f_gyr = f_gyr->next;
- }
-
- /* All frames are readed */
- zassert_is_null(f_acc, "Not all accelerometer frames are read, line %d",
- line);
- zassert_is_null(f_gyr, "Not all gyroscope frames are read, line %d",
- line);
-}
-#define check_fifo(ms_acc, ms_gyr, frame, acc_range, gyr_range) \
- check_fifo_f(ms_acc, ms_gyr, frame, acc_range, gyr_range, __LINE__)
-
-/** Test irq handler of accelerometer sensor */
-static void test_bmi_acc_fifo(void)
-{
- struct motion_sensor_t *ms, *ms_gyr;
- struct fifo_func_data func_data;
- struct bmi_emul_frame f[3];
- struct i2c_emul *emul;
- int gyr_range = 125;
- int acc_range = 2;
- int event;
-
- emul = bmi_emul_get(BMI_ORD);
- ms = &motion_sensors[BMI_ACC_SENSOR_ID];
- ms_gyr = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Need to be set to collect all data in FIFO */
- ms->oversampling_ratio = 1;
- ms_gyr->oversampling_ratio = 1;
- /* Only BMI event should be handled */
- event = 0x1234 & ~BMI_INT_EVENT;
- zassert_equal(EC_ERROR_NOT_HANDLED, ms->drv->irq_handler(ms, &event),
- NULL);
-
- event = BMI_INT_EVENT;
-
- /* Test fail to read interrupt status registers */
- i2c_common_emul_set_read_fail_reg(emul, BMI260_INT_STATUS_0);
- zassert_equal(EC_ERROR_INVAL, ms->drv->irq_handler(ms, &event), NULL);
- i2c_common_emul_set_read_fail_reg(emul, BMI260_INT_STATUS_1);
- zassert_equal(EC_ERROR_INVAL, ms->drv->irq_handler(ms, &event), NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test no interrupt */
- bmi_emul_set_reg(emul, BMI260_INT_STATUS_0, 0);
- bmi_emul_set_reg(emul, BMI260_INT_STATUS_1, 0);
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, NULL, acc_range, gyr_range);
-
- /* Set custom function for FIFO test */
- i2c_common_emul_set_read_func(emul, emul_fifo_func, &func_data);
- /* Enable sensor FIFO */
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 50000, 0), NULL);
- /* Set range */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, acc_range, 0), NULL);
- zassert_equal(EC_SUCCESS, ms_gyr->drv->set_range(ms_gyr, gyr_range, 0),
- NULL);
- /* Setup single accelerometer frame */
- f[0].type = BMI_EMUL_FRAME_ACC;
- f[0].acc_x = BMI_EMUL_1G / 10;
- f[0].acc_y = BMI_EMUL_1G / 20;
- f[0].acc_z = -(int)BMI_EMUL_1G / 30;
- f[0].next = NULL;
- bmi_emul_append_frame(emul, f);
- /* Setup interrupts register */
- func_data.interrupts = BMI260_FWM_INT;
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, f, acc_range, gyr_range);
-
- /* Setup second accelerometer frame */
- f[1].type = BMI_EMUL_FRAME_ACC;
- f[1].acc_x = -(int)BMI_EMUL_1G / 40;
- f[1].acc_y = BMI_EMUL_1G / 50;
- f[1].acc_z = BMI_EMUL_1G / 60;
- f[0].next = &(f[1]);
- f[1].next = NULL;
- bmi_emul_append_frame(emul, f);
- /* Setup interrupts register */
- func_data.interrupts = BMI260_FWM_INT;
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, f, acc_range, gyr_range);
-
- /* Enable sensor FIFO */
- zassert_equal(EC_SUCCESS, ms_gyr->drv->set_data_rate(ms_gyr, 50000, 0),
- NULL);
-
- /* Setup first gyroscope frame (after two accelerometer frames) */
- f[2].type = BMI_EMUL_FRAME_GYR;
- f[2].gyr_x = -(int)BMI_EMUL_125_DEG_S / 100;
- f[2].gyr_y = BMI_EMUL_125_DEG_S / 200;
- f[2].gyr_z = BMI_EMUL_125_DEG_S / 300;
- f[1].next = &(f[2]);
- f[2].next = NULL;
- bmi_emul_append_frame(emul, f);
- /* Setup interrupts register */
- func_data.interrupts = BMI260_FWM_INT;
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, f, acc_range, gyr_range);
-
- /* Setup second accelerometer frame to by gyroscope frame too */
- f[1].type |= BMI_EMUL_FRAME_GYR;
- f[1].gyr_x = -(int)BMI_EMUL_125_DEG_S / 300;
- f[1].gyr_y = BMI_EMUL_125_DEG_S / 400;
- f[1].gyr_z = BMI_EMUL_125_DEG_S / 500;
- bmi_emul_append_frame(emul, f);
- /* Setup interrupts register */
- func_data.interrupts = BMI260_FWM_INT;
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, f, acc_range, gyr_range);
-
- /* Skip frame should be ignored by driver */
- bmi_emul_set_skipped_frames(emul, 8);
- bmi_emul_append_frame(emul, f);
- /* Setup interrupts register */
- func_data.interrupts = BMI260_FWM_INT;
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, f, acc_range, gyr_range);
-
- /* Setup second frame as an config frame */
- f[1].type = BMI_EMUL_FRAME_CONFIG;
- /* Indicate that accelerometer range changed */
- f[1].config = 0x1;
- bmi_emul_append_frame(emul, f);
- /* Setup interrupts register */
- func_data.interrupts = BMI260_FWM_INT;
-
- /* Trigger irq handler and check results */
- check_fifo(ms, ms_gyr, f, acc_range, gyr_range);
-
- /* Remove custom emulator read function */
- i2c_common_emul_set_read_func(emul, NULL, NULL);
-}
-
-/** Test irq handler of gyroscope sensor */
-static void test_bmi_gyr_fifo(void)
-{
- struct motion_sensor_t *ms;
- uint32_t event;
-
- ms = &motion_sensors[BMI_GYR_SENSOR_ID];
-
- /* Interrupt shuldn't be triggered for gyroscope motion sense */
- event = BMI_INT_EVENT;
- zassert_equal(EC_ERROR_NOT_HANDLED, ms->drv->irq_handler(ms, &event),
- NULL);
-}
-
-void test_suite_bmi260(void)
-{
- ztest_test_suite(bmi260,
- ztest_user_unit_test(test_bmi_acc_get_offset),
- ztest_user_unit_test(test_bmi_gyr_get_offset),
- ztest_user_unit_test(test_bmi_acc_set_offset),
- ztest_user_unit_test(test_bmi_gyr_set_offset),
- ztest_user_unit_test(test_bmi_acc_set_range),
- ztest_user_unit_test(test_bmi_gyr_set_range),
- ztest_user_unit_test(test_bmi_get_resolution),
- ztest_user_unit_test(test_bmi_acc_rate),
- ztest_user_unit_test(test_bmi_gyr_rate),
- ztest_user_unit_test(test_bmi_scale),
- ztest_user_unit_test(test_bmi_read_temp),
- ztest_user_unit_test(test_bmi_acc_read),
- ztest_user_unit_test(test_bmi_gyr_read),
- ztest_user_unit_test(test_bmi_acc_perform_calib),
- ztest_user_unit_test(test_bmi_gyr_perform_calib),
- ztest_user_unit_test(test_bmi_init),
- ztest_user_unit_test(test_bmi_acc_fifo),
- ztest_user_unit_test(test_bmi_gyr_fifo));
- ztest_run_test_suite(bmi260);
-}
diff --git a/zephyr/test/drivers/src/espi.c b/zephyr/test/drivers/src/espi.c
deleted file mode 100644
index c852f1b771..0000000000
--- a/zephyr/test/drivers/src/espi.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-
-#include "ec_commands.h"
-#include "host_command.h"
-
-static void test_host_command_get_protocol_info(void)
-{
- struct ec_response_get_protocol_info response;
- struct host_cmd_handler_args args =
- BUILD_HOST_COMMAND(EC_CMD_GET_PROTOCOL_INFO, 0, response);
-
- zassert_ok(host_command_process(&args), NULL);
- zassert_ok(args.result, NULL);
- zassert_equal(args.response_size, sizeof(response), NULL);
- zassert_equal(response.protocol_versions, BIT(3), NULL);
- zassert_equal(response.max_request_packet_size, EC_LPC_HOST_PACKET_SIZE,
- NULL);
- zassert_equal(response.max_response_packet_size,
- EC_LPC_HOST_PACKET_SIZE, NULL);
- zassert_equal(response.flags, 0, NULL);
-}
-
-void test_suite_espi(void)
-{
- ztest_test_suite(espi,
- ztest_user_unit_test(
- test_host_command_get_protocol_info));
- ztest_run_test_suite(espi);
-}
diff --git a/zephyr/test/drivers/src/lis2dw12.c b/zephyr/test/drivers/src/lis2dw12.c
deleted file mode 100644
index 287430e65b..0000000000
--- a/zephyr/test/drivers/src/lis2dw12.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <ztest.h>
-#include <drivers/emul.h>
-#include "driver/accel_lis2dw12.h"
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_lis2dw12.h"
-
-#define LIS2DW12_NODELABEL DT_NODELABEL(ms_lis2dw12_accel)
-#define LIS2DW12_SENSOR_ID SENSOR_ID(LIS2DW12_NODELABEL)
-#define EMUL_LABEL DT_LABEL(DT_NODELABEL(lis2dw12_emul))
-
-#include <stdio.h>
-static void lis2dw12_setup(void)
-{
- lis2dw12_emul_reset(emul_get_binding(EMUL_LABEL));
-}
-
-static void test_lis2dw12_init__fail_read_who_am_i(void)
-{
- const struct emul *emul = emul_get_binding(EMUL_LABEL);
- struct motion_sensor_t *ms = &motion_sensors[LIS2DW12_SENSOR_ID];
- int rv;
-
- i2c_common_emul_set_read_fail_reg(lis2dw12_emul_to_i2c_emul(emul),
- LIS2DW12_WHO_AM_I_REG);
- rv = ms->drv->init(ms);
- zassert_equal(EC_ERROR_INVAL, rv, NULL);
-}
-
-static void test_lis2dw12_init__fail_who_am_i(void)
-{
- const struct emul *emul = emul_get_binding(EMUL_LABEL);
- struct motion_sensor_t *ms = &motion_sensors[LIS2DW12_SENSOR_ID];
- int rv;
-
- lis2dw12_emul_set_who_am_i(emul, ~LIS2DW12_WHO_AM_I);
-
- rv = ms->drv->init(ms);
- zassert_equal(EC_ERROR_ACCESS_DENIED, rv,
- "init returned %d but was expecting %d", rv,
- EC_ERROR_ACCESS_DENIED);
-}
-
-static void test_lis2dw12_init__fail_write_soft_reset(void)
-{
- const struct emul *emul = emul_get_binding(EMUL_LABEL);
- struct motion_sensor_t *ms = &motion_sensors[LIS2DW12_SENSOR_ID];
- int rv;
-
- i2c_common_emul_set_write_fail_reg(lis2dw12_emul_to_i2c_emul(emul),
- LIS2DW12_SOFT_RESET_ADDR);
- rv = ms->drv->init(ms);
- zassert_equal(EC_ERROR_INVAL, rv, NULL);
-}
-
-static void test_lis2dw12_init__timeout_read_soft_reset(void)
-{
- const struct emul *emul = emul_get_binding(EMUL_LABEL);
- struct motion_sensor_t *ms = &motion_sensors[LIS2DW12_SENSOR_ID];
- int rv;
-
- i2c_common_emul_set_read_fail_reg(lis2dw12_emul_to_i2c_emul(emul),
- LIS2DW12_SOFT_RESET_ADDR);
- rv = ms->drv->init(ms);
- zassert_equal(EC_ERROR_TIMEOUT, rv, "init returned %d but expected %d",
- rv, EC_ERROR_TIMEOUT);
-}
-
-static int lis2dw12_test_mock_write_fail_set_bdu(struct i2c_emul *emul, int reg,
- uint8_t val, int bytes,
- void *data)
-{
- if (reg == LIS2DW12_BDU_ADDR && bytes == 1 &&
- (val & LIS2DW12_BDU_MASK) != 0) {
- return -EIO;
- }
- return 1;
-}
-
-static void test_lis2dw12_init__fail_set_bdu(void)
-{
- const struct emul *emul = emul_get_binding(EMUL_LABEL);
- struct motion_sensor_t *ms = &motion_sensors[LIS2DW12_SENSOR_ID];
- int rv;
-
- i2c_common_emul_set_write_func(lis2dw12_emul_to_i2c_emul(emul),
- lis2dw12_test_mock_write_fail_set_bdu,
- NULL);
- rv = ms->drv->init(ms);
- zassert_equal(EC_ERROR_INVAL, rv, "init returned %d but expected %d",
- rv, EC_ERROR_INVAL);
- zassert_true(lis2dw12_emul_get_soft_reset_count(emul) > 0,
- "expected at least one soft reset");
-}
-
-void test_suite_lis2dw12(void)
-{
- ztest_test_suite(lis2dw12,
- ztest_unit_test_setup_teardown(
- test_lis2dw12_init__fail_read_who_am_i,
- lis2dw12_setup, unit_test_noop),
- ztest_unit_test_setup_teardown(
- test_lis2dw12_init__fail_who_am_i,
- lis2dw12_setup, unit_test_noop),
- ztest_unit_test_setup_teardown(
- test_lis2dw12_init__fail_write_soft_reset,
- lis2dw12_setup, unit_test_noop),
- ztest_unit_test_setup_teardown(
- test_lis2dw12_init__timeout_read_soft_reset,
- lis2dw12_setup, unit_test_noop),
- ztest_unit_test_setup_teardown(
- test_lis2dw12_init__fail_set_bdu,
- lis2dw12_setup, unit_test_noop));
- ztest_run_test_suite(lis2dw12);
-}
diff --git a/zephyr/test/drivers/src/ln9310.c b/zephyr/test/drivers/src/ln9310.c
deleted file mode 100644
index 0033931039..0000000000
--- a/zephyr/test/drivers/src/ln9310.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <ztest.h>
-#include <drivers/emul.h>
-#include "driver/ln9310.h"
-#include "emul/emul_ln9310.h"
-
-void test_ln9310_2s_no_startup__passes_init(void)
-{
- const struct emul *emulator =
- emul_get_binding(DT_LABEL(DT_NODELABEL(ln9310)));
-
- zassert_not_null(emulator, NULL);
-
- ln9310_emul_set_context(emulator);
- ln9310_emul_reset(emulator);
- ln9310_emul_set_battery_cell_type(emulator, BATTERY_CELL_TYPE_2S);
- ln9310_emul_set_version(emulator, LN9310_BC_STS_C_CHIP_REV_FIXED);
-
- zassert_ok(ln9310_init(), NULL);
- zassert_true(ln9310_emul_is_init(emulator), NULL);
-}
-
-void test_ln9310_3s_no_startup__passes_init(void)
-{
- const struct emul *emulator =
- emul_get_binding(DT_LABEL(DT_NODELABEL(ln9310)));
-
- zassert_not_null(emulator, NULL);
-
- ln9310_emul_set_context(emulator);
- ln9310_emul_reset(emulator);
- ln9310_emul_set_battery_cell_type(emulator, BATTERY_CELL_TYPE_3S);
- ln9310_emul_set_version(emulator, LN9310_BC_STS_C_CHIP_REV_FIXED);
-
- zassert_ok(ln9310_init(), NULL);
- zassert_true(ln9310_emul_is_init(emulator), NULL);
-}
-
-void test_suite_ln9310(void)
-{
- ztest_test_suite(
- ln9310,
- ztest_unit_test(test_ln9310_2s_no_startup__passes_init),
- ztest_unit_test(test_ln9310_3s_no_startup__passes_init));
- ztest_run_test_suite(ln9310);
-}
diff --git a/zephyr/test/drivers/src/main.c b/zephyr/test/drivers/src/main.c
deleted file mode 100644
index 8d40bc4373..0000000000
--- a/zephyr/test/drivers/src/main.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-#include "ec_app_main.h"
-
-extern void test_suite_battery(void);
-extern void test_suite_cbi(void);
-extern void test_suite_smart_battery(void);
-extern void test_suite_thermistor(void);
-extern void test_suite_temp_sensor(void);
-extern void test_suite_bma2x2(void);
-extern void test_suite_bc12(void);
-extern void test_suite_ppc(void);
-extern void test_suite_bmi260(void);
-extern void test_suite_bmi160(void);
-extern void test_suite_tcs3400(void);
-extern void test_suite_espi(void);
-extern void test_suite_bb_retimer(void);
-extern void test_suite_ln9310(void);
-extern void test_suite_lis2dw12(void);
-extern void test_suite_stm_mems_common(void);
-
-void test_main(void)
-{
- /* Test suites to run before ec_app_main.*/
-
- ec_app_main();
-
- /* Test suites to run after ec_app_main.*/
- test_suite_battery();
- test_suite_cbi();
- test_suite_smart_battery();
- test_suite_thermistor();
- test_suite_temp_sensor();
- test_suite_bma2x2();
- test_suite_bc12();
- test_suite_ppc();
- test_suite_bmi260();
- test_suite_bmi160();
- test_suite_tcs3400();
- test_suite_espi();
- test_suite_bb_retimer();
- test_suite_ln9310();
- test_suite_lis2dw12();
- test_suite_stm_mems_common();
-}
diff --git a/zephyr/test/drivers/src/ppc.c b/zephyr/test/drivers/src/ppc.c
deleted file mode 100644
index dced25c227..0000000000
--- a/zephyr/test/drivers/src/ppc.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-#include <ztest_assert.h>
-
-#include "emul/emul_syv682x.h"
-
-#include "stubs.h"
-#include "syv682x.h"
-#include "timer.h"
-#include "usbc_ppc.h"
-
-#define SYV682X_ORD DT_DEP_ORD(DT_NODELABEL(syv682x_emul))
-
-static const int syv682x_port = 1;
-
-static void test_ppc_syv682x_vbus_enable(void)
-{
- struct i2c_emul *emul = syv682x_emul_get(SYV682X_ORD);
- uint8_t reg;
-
- zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_1_REG, &reg),
- "Reading CONTROL_1 failed");
- zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB,
- SYV682X_CONTROL_1_PWR_ENB, "VBUS sourcing disabled");
- zassert_false(ppc_is_sourcing_vbus(syv682x_port),
- "PPC sourcing VBUS at beginning of test");
-
- zassert_ok(ppc_vbus_source_enable(syv682x_port, true),
- "VBUS enable failed");
- zassert_ok(syv682x_emul_get_reg(emul, SYV682X_CONTROL_1_REG, &reg),
- "Reading CONTROL_1 failed");
- zassert_equal(reg & SYV682X_CONTROL_1_PWR_ENB, 0,
- "VBUS sourcing disabled");
- zassert_true(ppc_is_sourcing_vbus(syv682x_port),
- "PPC is not sourcing VBUS after VBUS enabled");
-}
-
-static void test_ppc_syv682x_interrupt(void)
-{
- struct i2c_emul *emul = syv682x_emul_get(SYV682X_ORD);
-
- syv682x_emul_set_status(emul, SYV682X_STATUS_OC_5V);
- syv682x_interrupt(syv682x_port);
-
- /* An OC event less than 100 ms should not cause VBUS to turn off. */
- msleep(50);
- syv682x_interrupt(syv682x_port);
- zassert_true(ppc_is_sourcing_vbus(syv682x_port),
- "PPC is not sourcing VBUS after 50 ms OC");
- /* But one greater than 100 ms should. */
- msleep(60);
- syv682x_interrupt(syv682x_port);
- zassert_false(ppc_is_sourcing_vbus(syv682x_port),
- "PPC is sourcing VBUS after 100 ms OC");
-
- syv682x_emul_set_status(emul, 0x0);
- /*
- * TODO(b/190519131): Organize the tests to be more hermetic and avoid
- * the following issue: The driver triggers overcurrent protection. If
- * overcurrent protection is triggered 3 times, the TC won't turn the
- * port back on without a detach. This could frustrate efforts to test
- * the TC.
- */
-}
-
-static void test_ppc_syv682x(void)
-{
- zassert_ok(ppc_init(syv682x_port), "PPC init failed");
-
- test_ppc_syv682x_vbus_enable();
- test_ppc_syv682x_interrupt();
-}
-
-void test_suite_ppc(void)
-{
- ztest_test_suite(ppc,
- ztest_user_unit_test(test_ppc_syv682x));
- ztest_run_test_suite(ppc);
-}
diff --git a/zephyr/test/drivers/src/smart.c b/zephyr/test/drivers/src/smart.c
deleted file mode 100644
index 7c053f1c23..0000000000
--- a/zephyr/test/drivers/src/smart.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-
-#include "common.h"
-#include "i2c.h"
-#include "emul/emul_common_i2c.h"
-#include "emul/emul_smart_battery.h"
-
-#include "battery.h"
-#include "battery_smart.h"
-
-#define BATTERY_ORD DT_DEP_ORD(DT_NODELABEL(battery))
-
-/** Test all simple getters */
-static void test_battery_getters(void)
-{
- struct sbat_emul_bat_data *bat;
- struct i2c_emul *emul;
- char block[32];
- int expected;
- int word;
-
- emul = sbat_emul_get_ptr(BATTERY_ORD);
- bat = sbat_emul_get_bat_data(emul);
-
- zassert_equal(EC_SUCCESS, battery_get_mode(&word), NULL);
- zassert_equal(bat->mode, word, "%d != %d", bat->mode, word);
-
- expected = 100 * bat->cap / bat->design_cap;
- zassert_equal(EC_SUCCESS, battery_state_of_charge_abs(&word), NULL);
- zassert_equal(expected, word, "%d != %d", expected, word);
-
- zassert_equal(EC_SUCCESS, battery_remaining_capacity(&word), NULL);
- zassert_equal(bat->cap, word, "%d != %d", bat->cap, word);
- zassert_equal(EC_SUCCESS, battery_full_charge_capacity(&word), NULL);
- zassert_equal(bat->full_cap, word, "%d != %d", bat->full_cap, word);
- zassert_equal(EC_SUCCESS, battery_cycle_count(&word), NULL);
- zassert_equal(bat->cycle_count, word, "%d != %d",
- bat->cycle_count, word);
- zassert_equal(EC_SUCCESS, battery_design_capacity(&word), NULL);
- zassert_equal(bat->design_cap, word, "%d != %d", bat->design_cap, word);
- zassert_equal(EC_SUCCESS, battery_design_voltage(&word), NULL);
- zassert_equal(bat->design_mv, word, "%d != %d", bat->design_mv, word);
- zassert_equal(EC_SUCCESS, battery_serial_number(&word), NULL);
- zassert_equal(bat->sn, word, "%d != %d", bat->sn, word);
- zassert_equal(EC_SUCCESS, get_battery_manufacturer_name(block, 32),
- NULL);
- zassert_mem_equal(block, bat->mf_name, bat->mf_name_len,
- "%s != %s", block, bat->mf_name);
- zassert_equal(EC_SUCCESS, battery_device_name(block, 32), NULL);
- zassert_mem_equal(block, bat->dev_name, bat->dev_name_len,
- "%s != %s", block, bat->dev_name);
- zassert_equal(EC_SUCCESS, battery_device_chemistry(block, 32), NULL);
- zassert_mem_equal(block, bat->dev_chem, bat->dev_chem_len,
- "%s != %s", block, bat->dev_chem);
- word = battery_get_avg_current();
- zassert_equal(bat->avg_cur, word, "%d != %d", bat->avg_cur, word);
-
- bat->avg_cur = 200;
- expected = (bat->full_cap - bat->cap) * 60 / bat->avg_cur;
- zassert_equal(EC_SUCCESS, battery_time_to_full(&word), NULL);
- zassert_equal(expected, word, "%d != %d", expected, word);
-
- bat->cur = -200;
- expected = bat->cap * 60 / (-bat->cur);
- zassert_equal(EC_SUCCESS, battery_run_time_to_empty(&word), NULL);
- zassert_equal(expected, word, "%d != %d", expected, word);
-
- bat->avg_cur = -200;
- expected = bat->cap * 60 / (-bat->avg_cur);
- zassert_equal(EC_SUCCESS, battery_time_to_empty(&word), NULL);
- zassert_equal(expected, word, "%d != %d", expected, word);
-}
-
-/** Test battery status */
-static void test_battery_status(void)
-{
- struct sbat_emul_bat_data *bat;
- struct i2c_emul *emul;
- int expected;
- int status;
-
- emul = sbat_emul_get_ptr(BATTERY_ORD);
- bat = sbat_emul_get_bat_data(emul);
-
- bat->status = 0;
- bat->cur = -200;
- bat->cap_alarm = 0;
- bat->time_alarm = 0;
- bat->cap = bat->full_cap / 2;
- bat->error_code = STATUS_CODE_OVERUNDERFLOW;
-
- expected = 0;
- expected |= STATUS_DISCHARGING;
- expected |= STATUS_CODE_OVERUNDERFLOW;
-
- zassert_equal(EC_SUCCESS, battery_status(&status), NULL);
- zassert_equal(expected, status, "%d != %d", expected, status);
-}
-
-/** Test wait for stable function */
-static void test_battery_wait_for_stable(void)
-{
- struct i2c_emul *emul;
-
- emul = sbat_emul_get_ptr(BATTERY_ORD);
-
- /* Should fail when read function always fail */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_FAIL_ALL_REG);
- zassert_equal(EC_ERROR_NOT_POWERED, battery_wait_for_stable(), NULL);
-
- /* Should be ok with default handler */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- zassert_equal(EC_SUCCESS, battery_wait_for_stable(), NULL);
-}
-
-/** Test manufacture date */
-static void test_battery_manufacture_date(void)
-{
- struct sbat_emul_bat_data *bat;
- struct i2c_emul *emul;
- int day, month, year;
- int exp_month = 5;
- int exp_year = 2018;
- int exp_day = 19;
- uint16_t date;
-
- emul = sbat_emul_get_ptr(BATTERY_ORD);
- bat = sbat_emul_get_bat_data(emul);
-
- date = sbat_emul_date_to_word(exp_day, exp_month, exp_year);
- bat->mf_date = date;
-
- zassert_equal(EC_SUCCESS, battery_manufacture_date(&year, &month, &day),
- NULL);
- zassert_equal(exp_day, day, "%d != %d", exp_day, day);
- zassert_equal(exp_month, month, "%d != %d", exp_month, month);
- zassert_equal(exp_year, year, "%d != %d", exp_year, year);
-}
-
-/** Test time at rate */
-static void test_battery_time_at_rate(void)
-{
- struct sbat_emul_bat_data *bat;
- struct i2c_emul *emul;
- int expect_time;
- int minutes;
- int rate;
-
- emul = sbat_emul_get_ptr(BATTERY_ORD);
- bat = sbat_emul_get_bat_data(emul);
-
- /* 3000mAh at rate 300mA will be discharged in 10h */
- bat->cap = 3000;
- rate = -300;
- expect_time = 600;
-
- zassert_equal(EC_SUCCESS, battery_time_at_rate(rate, &minutes), NULL);
- zassert_equal(expect_time, minutes, "%d != %d", expect_time, minutes);
-
- /* 1000mAh at rate 1000mA will be charged in 1h */
- bat->cap = bat->full_cap - 1000;
- rate = 1000;
- /* battery_time_at_rate report time to full as negative number */
- expect_time = -60;
-
- zassert_equal(EC_SUCCESS, battery_time_at_rate(rate, &minutes), NULL);
- zassert_equal(expect_time, minutes, "%d != %d", expect_time, minutes);
-}
-
-/** Test battery get params */
-static void test_battery_get_params(void)
-{
- struct sbat_emul_bat_data *bat;
- struct batt_params batt;
- struct i2c_emul *emul;
- int flags;
-
- emul = sbat_emul_get_ptr(BATTERY_ORD);
- bat = sbat_emul_get_bat_data(emul);
-
- /* Battery wants to charge */
- bat->desired_charg_cur = 1000;
- bat->desired_charg_volt = 5000;
-
- /* Fail temperature read */
- i2c_common_emul_set_read_fail_reg(emul, SB_TEMPERATURE);
- flags = BATT_FLAG_WANT_CHARGE | BATT_FLAG_RESPONSIVE |
- BATT_FLAG_BAD_TEMPERATURE;
- battery_get_params(&batt);
- zassert_equal(flags, batt.flags, "0x%x != 0x%x", flags, batt.flags);
-
- /* Fail state of charge read; want charge cannot be set */
- i2c_common_emul_set_read_fail_reg(emul, SB_RELATIVE_STATE_OF_CHARGE);
- flags = BATT_FLAG_RESPONSIVE | BATT_FLAG_BAD_STATE_OF_CHARGE;
- battery_get_params(&batt);
- zassert_equal(flags, batt.flags, "0x%x != 0x%x", flags, batt.flags);
-
- /* Fail voltage read */
- i2c_common_emul_set_read_fail_reg(emul, SB_VOLTAGE);
- flags = BATT_FLAG_WANT_CHARGE | BATT_FLAG_RESPONSIVE |
- BATT_FLAG_BAD_VOLTAGE;
- battery_get_params(&batt);
- zassert_equal(flags, batt.flags, "0x%x != 0x%x", flags, batt.flags);
-
- /* Fail current read */
- i2c_common_emul_set_read_fail_reg(emul, SB_CURRENT);
- flags = BATT_FLAG_WANT_CHARGE | BATT_FLAG_RESPONSIVE |
- BATT_FLAG_BAD_CURRENT;
- battery_get_params(&batt);
- zassert_equal(flags, batt.flags, "0x%x != 0x%x", flags, batt.flags);
-
- /* Fail average current read */
- i2c_common_emul_set_read_fail_reg(emul, SB_AVERAGE_CURRENT);
- flags = BATT_FLAG_WANT_CHARGE | BATT_FLAG_RESPONSIVE |
- BATT_FLAG_BAD_AVERAGE_CURRENT;
- battery_get_params(&batt);
- zassert_equal(flags, batt.flags, "0x%x != 0x%x", flags, batt.flags);
-
- /* Fail charging voltage read; want charge cannot be set */
- i2c_common_emul_set_read_fail_reg(emul, SB_CHARGING_VOLTAGE);
- flags = BATT_FLAG_RESPONSIVE | BATT_FLAG_BAD_DESIRED_VOLTAGE;
- battery_get_params(&batt);
- zassert_equal(flags, batt.flags, "0x%x != 0x%x", flags, batt.flags);
-
- /* Fail charging voltage read; want charge cannot be set */
- i2c_common_emul_set_read_fail_reg(emul, SB_CHARGING_CURRENT);
- flags = BATT_FLAG_RESPONSIVE | BATT_FLAG_BAD_DESIRED_CURRENT;
- battery_get_params(&batt);
- zassert_equal(flags, batt.flags, "0x%x != 0x%x", flags, batt.flags);
-
- /* Fail remaining capacity read */
- i2c_common_emul_set_read_fail_reg(emul, SB_REMAINING_CAPACITY);
- flags = BATT_FLAG_WANT_CHARGE | BATT_FLAG_RESPONSIVE |
- BATT_FLAG_BAD_REMAINING_CAPACITY;
- battery_get_params(&batt);
- zassert_equal(flags, batt.flags, "0x%x != 0x%x", flags, batt.flags);
-
- /* Fail full capacity read */
- i2c_common_emul_set_read_fail_reg(emul, SB_FULL_CHARGE_CAPACITY);
- flags = BATT_FLAG_WANT_CHARGE | BATT_FLAG_RESPONSIVE |
- BATT_FLAG_BAD_FULL_CAPACITY;
- battery_get_params(&batt);
- zassert_equal(flags, batt.flags, "0x%x != 0x%x", flags, batt.flags);
-
- /* Fail status read */
- i2c_common_emul_set_read_fail_reg(emul, SB_BATTERY_STATUS);
- flags = BATT_FLAG_WANT_CHARGE | BATT_FLAG_RESPONSIVE |
- BATT_FLAG_BAD_STATUS;
- battery_get_params(&batt);
- zassert_equal(flags, batt.flags, "0x%x != 0x%x", flags, batt.flags);
-
- /* Fail all */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_FAIL_ALL_REG);
- flags = BATT_FLAG_BAD_ANY;
- battery_get_params(&batt);
- zassert_equal(flags, batt.flags, "0x%x != 0x%x", flags, batt.flags);
-
- /* Use default handler, everything should be ok */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- flags = BATT_FLAG_WANT_CHARGE | BATT_FLAG_RESPONSIVE;
- battery_get_params(&batt);
- zassert_equal(flags, batt.flags, "0x%x != 0x%x", flags, batt.flags);
-}
-
-void test_suite_smart_battery(void)
-{
- ztest_test_suite(smart_battery,
- ztest_user_unit_test(test_battery_getters),
- ztest_user_unit_test(test_battery_status),
- ztest_user_unit_test(test_battery_wait_for_stable),
- ztest_user_unit_test(test_battery_manufacture_date),
- ztest_user_unit_test(test_battery_time_at_rate),
- ztest_user_unit_test(test_battery_get_params));
- ztest_run_test_suite(smart_battery);
-}
diff --git a/zephyr/test/drivers/src/stm_mems_common.c b/zephyr/test/drivers/src/stm_mems_common.c
deleted file mode 100644
index 3085007f4d..0000000000
--- a/zephyr/test/drivers/src/stm_mems_common.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <ztest.h>
-#include <device.h>
-#include <devicetree.h>
-#include <errno.h>
-
-#include "common.h"
-#include "driver/stm_mems_common.h"
-#include "emul/emul_common_i2c.h"
-#include "emul/i2c_mock.h"
-#include "i2c/i2c.h"
-
-#define MOCK_EMUL emul_get_binding(DT_LABEL(DT_NODELABEL(i2c_mock)))
-
-static void setup(void)
-{
- i2c_mock_reset(MOCK_EMUL);
-}
-
-static int mock_read_fn(struct i2c_emul *emul, int reg, uint8_t *val, int bytes,
- void *data)
-{
- ztest_check_expected_value(reg);
- ztest_check_expected_value(bytes);
- return ztest_get_return_value();
-}
-
-static void test_st_raw_read_n(void)
-{
- const struct emul *emul = MOCK_EMUL;
- struct i2c_emul *i2c_emul = i2c_mock_to_i2c_emul(emul);
- int rv;
-
- i2c_common_emul_set_read_func(i2c_emul, mock_read_fn, NULL);
- ztest_expect_value(mock_read_fn, reg, 0x80);
- ztest_expect_value(mock_read_fn, bytes, 0);
- ztest_returns_value(mock_read_fn, -EIO);
-
- rv = st_raw_read_n(I2C_PORT_POWER, i2c_mock_get_addr(emul), 0, NULL, 2);
- /* The shim layer translates -EIO to EC_ERROR_INVAL. */
- zassert_equal(rv, EC_ERROR_INVAL, "rv was %d but expected %d", rv,
- EC_ERROR_INVAL);
-}
-
-void test_suite_stm_mems_common(void)
-{
- ztest_test_suite(stm_mems_common,
- ztest_unit_test_setup_teardown(
- test_st_raw_read_n,
- setup, unit_test_noop));
- ztest_run_test_suite(stm_mems_common);
-}
diff --git a/zephyr/test/drivers/src/stubs.c b/zephyr/test/drivers/src/stubs.c
deleted file mode 100644
index 6dab320b9a..0000000000
--- a/zephyr/test/drivers/src/stubs.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "battery.h"
-#include "battery_fuel_gauge.h"
-#include "bc12/pi3usb9201_public.h"
-#include "charge_ramp.h"
-#include "charger.h"
-#include "charger/isl9241_public.h"
-#include "config.h"
-#include "i2c/i2c.h"
-#include "power.h"
-#include "ppc/sn5s330_public.h"
-#include "ppc/syv682x_public.h"
-#include "retimer/bb_retimer_public.h"
-#include "stubs.h"
-#include "tcpm/tusb422_public.h"
-#include "tcpm/tusb422_public.h"
-#include "usb_mux.h"
-#include "usb_pd_tcpm.h"
-#include "usbc_ppc.h"
-
-/* All of these definitions are just to get the test to link. None of these
- * functions are useful or behave as they should. Please remove them once the
- * real code is able to be added. Most of the things here should either be
- * in emulators or in the native_posix board-specific code or part of the
- * 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);
-
-/* Charger Chip Configuration */
-const struct charger_config_t chg_chips[] = {
- {
- .i2c_port = I2C_PORT_CHARGER,
- .i2c_addr_flags = ISL9241_ADDR_FLAGS,
- .drv = &isl9241_drv,
- },
-};
-
-const struct board_batt_params board_battery_info[] = {
- /* LGC\011 L17L3PB0 Battery Information */
- /*
- * Battery info provided by ODM on b/143477210, comment #11
- */
- [BATTERY_LGC011] = {
- .fuel_gauge = {
- .manuf_name = "LGC",
- .ship_mode = {
- .reg_addr = 0x00,
- .reg_data = { 0x10, 0x10 },
- },
- .fet = {
- .reg_addr = 0x0,
- .reg_mask = 0x6000,
- .disconnect_val = 0x6000,
- }
- },
- .batt_info = {
- .voltage_max = TARGET_WITH_MARGIN(13200, 5),
- .voltage_normal = 11550, /* 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 = 0,
- .discharging_max_c = 75,
- },
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT);
-
-const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_LGC011;
-
-int board_set_active_charge_port(int port)
-{
- return EC_SUCCESS;
-}
-
-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)
-{
-}
-
-struct tcpc_config_t tcpc_config[] = {
- [USBC_PORT_C0] = {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C0,
- .addr_flags = TUSB422_I2C_ADDR_FLAGS,
- },
- .drv = &tusb422_tcpm_drv,
- },
- [USBC_PORT_C1] = {
- .bus_type = EC_BUS_TYPE_I2C,
- .i2c_info = {
- .port = I2C_PORT_USB_C1,
- .addr_flags = TUSB422_I2C_ADDR_FLAGS,
- },
- .drv = &tusb422_tcpm_drv,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(tcpc_config) == USBC_PORT_COUNT);
-BUILD_ASSERT(CONFIG_USB_PD_PORT_MAX_COUNT == USBC_PORT_COUNT);
-
-int board_is_sourcing_vbus(int port)
-{
- return 0;
-}
-
-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 usb_muxes[] = {
- [USBC_PORT_C0] = {
- .usb_port = USBC_PORT_C0,
- .driver = &virtual_usb_mux_driver,
- .hpd_update = &virtual_hpd_update,
- },
- [USBC_PORT_C1] = {
- .usb_port = USBC_PORT_C1,
- .driver = &bb_usb_retimer,
- .hpd_update = bb_retimer_hpd_update,
- .next_mux = &usbc1_virtual_usb_mux,
- .i2c_port = I2C_PORT_USB_C1,
- .i2c_addr_flags = DT_REG_ADDR(DT_NODELABEL(
- usb_c1_bb_retimer_emul)),
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(usb_muxes) == USBC_PORT_COUNT);
-
-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_USB_C1_LS_EN,
- .retimer_rst_gpio = GPIO_USB_C1_RT_RST_ODL,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(bb_controls) == USBC_PORT_COUNT);
-
-void pd_power_supply_reset(int port)
-{
-}
-
-int pd_check_vconn_swap(int port)
-{
- return 0;
-}
-
-int pd_set_power_supply_ready(int port)
-{
- return EC_SUCCESS;
-}
-
-/* USBC PPC configuration */
-struct ppc_config_t ppc_chips[] = {
- [USBC_PORT_C0] = {
- .i2c_port = I2C_PORT_USB_C0,
- .i2c_addr_flags = SN5S330_ADDR0_FLAGS,
- .drv = &sn5s330_drv,
- },
- [USBC_PORT_C1] = {
- .i2c_port = I2C_PORT_USB_C1,
- .i2c_addr_flags = SYV682X_ADDR1_FLAGS,
- /* TODO(b/190519131): Add FRS GPIO, test FRS */
- .drv = &syv682x_drv,
- },
-};
-BUILD_ASSERT(ARRAY_SIZE(ppc_chips) == USBC_PORT_COUNT);
-unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips);
-
-void system_hibernate(uint32_t seconds, uint32_t microseconds)
-{
-}
-
-uint16_t tcpc_get_alert_status(void)
-{
- return 0;
-}
-
-enum power_state power_chipset_init(void)
-{
- return POWER_G3;
-}
-
-enum power_state mock_state = POWER_G3;
-
-void set_mock_power_state(enum power_state state)
-{
- mock_state = state;
- task_wake(TASK_ID_CHIPSET);
-}
-
-enum power_state power_handle_state(enum power_state state)
-{
- return mock_state;
-}
-
-void chipset_reset(enum chipset_reset_reason reason)
-{
-}
-
-void chipset_force_shutdown(enum chipset_shutdown_reason reason)
-{
-}
-
-/* Power signals list. Must match order of enum power_signal. */
-const struct power_signal_info power_signal_list[] = {};
diff --git a/zephyr/test/drivers/src/tcs3400.c b/zephyr/test/drivers/src/tcs3400.c
deleted file mode 100644
index c20137c1ad..0000000000
--- a/zephyr/test/drivers/src/tcs3400.c
+++ /dev/null
@@ -1,622 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-
-#include "common.h"
-#include "i2c.h"
-#include "emul/emul_tcs3400.h"
-#include "emul/emul_common_i2c.h"
-
-#include "motion_sense.h"
-#include "motion_sense_fifo.h"
-#include "driver/als_tcs3400.h"
-
-#define TCS_ORD DT_DEP_ORD(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))
-#define TCS_INT_EVENT \
- TASK_EVENT_MOTION_SENSOR_INTERRUPT(SENSOR_ID(DT_ALIAS(tcs3400_int)))
-
-/** How accurate comparision of rgb sensors should be */
-#define V_EPS 8
-
-/** Test initialization of light sensor driver and device */
-static void test_tcs_init(void)
-{
- struct motion_sensor_t *ms, *ms_rgb;
- struct i2c_emul *emul;
-
- emul = tcs_emul_get(TCS_ORD);
- ms = &motion_sensors[TCS_CLR_SENSOR_ID];
- ms_rgb = &motion_sensors[TCS_RGB_SENSOR_ID];
-
- /* RGB sensor initialization is always successful */
- zassert_equal(EC_SUCCESS, ms_rgb->drv->init(ms_rgb), NULL);
-
- /* Fail init on communication errors */
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_FAIL_ALL_REG);
- zassert_equal(EC_ERROR_INVAL, ms->drv->init(ms), NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Fail on bad ID */
- tcs_emul_set_reg(emul, TCS_I2C_ID, 0);
- zassert_equal(EC_ERROR_ACCESS_DENIED, ms->drv->init(ms), NULL);
- /* Restore ID */
- tcs_emul_set_reg(emul, TCS_I2C_ID,
- DT_STRING_TOKEN(DT_NODELABEL(tcs_emul), device_id));
-
- /* Test successful init. ATIME and AGAIN should be changed on init */
- zassert_equal(EC_SUCCESS, ms->drv->init(ms), NULL);
- zassert_equal(TCS_DEFAULT_ATIME,
- tcs_emul_get_reg(emul, TCS_I2C_ATIME), NULL);
- zassert_equal(TCS_DEFAULT_AGAIN,
- tcs_emul_get_reg(emul, TCS_I2C_CONTROL), NULL);
-}
-
-/** Test if read function leaves device in correct mode to accuire data */
-static void test_tcs_read(void)
-{
- struct motion_sensor_t *ms;
- struct i2c_emul *emul;
- uint8_t enable;
- intv3_t v;
-
- emul = tcs_emul_get(TCS_ORD);
- ms = &motion_sensors[TCS_CLR_SENSOR_ID];
-
- /* Test error on writing registers */
- i2c_common_emul_set_write_fail_reg(emul, TCS_I2C_ATIME);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, v), NULL);
- i2c_common_emul_set_write_fail_reg(emul, TCS_I2C_CONTROL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, v), NULL);
- i2c_common_emul_set_write_fail_reg(emul, TCS_I2C_ENABLE);
- zassert_equal(EC_ERROR_INVAL, ms->drv->read(ms, v), NULL);
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test starting read with calibration */
- tcs_emul_set_reg(emul, TCS_I2C_ATIME, 0);
- tcs_emul_set_reg(emul, TCS_I2C_CONTROL, 0);
- tcs_emul_set_reg(emul, TCS_I2C_ENABLE, 0);
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 1), NULL);
- zassert_equal(EC_RES_IN_PROGRESS, ms->drv->read(ms, v), NULL);
- zassert_equal(TCS_CALIBRATION_ATIME,
- tcs_emul_get_reg(emul, TCS_I2C_ATIME), NULL);
- zassert_equal(TCS_CALIBRATION_AGAIN,
- tcs_emul_get_reg(emul, TCS_I2C_CONTROL), NULL);
- enable = tcs_emul_get_reg(emul, TCS_I2C_ENABLE);
- zassert_true(enable & TCS_I2C_ENABLE_POWER_ON, NULL);
- zassert_true(enable & TCS_I2C_ENABLE_ADC_ENABLE, NULL);
- zassert_true(enable & TCS_I2C_ENABLE_INT_ENABLE, NULL);
-
- /* Test starting read without calibration */
- tcs_emul_set_reg(emul, TCS_I2C_ATIME, 0);
- tcs_emul_set_reg(emul, TCS_I2C_CONTROL, 0);
- tcs_emul_set_reg(emul, TCS_I2C_ENABLE, 0);
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 0), NULL);
- zassert_equal(EC_RES_IN_PROGRESS, ms->drv->read(ms, v), NULL);
- enable = tcs_emul_get_reg(emul, TCS_I2C_ENABLE);
- zassert_true(enable & TCS_I2C_ENABLE_POWER_ON, NULL);
- zassert_true(enable & TCS_I2C_ENABLE_ADC_ENABLE, NULL);
- zassert_true(enable & TCS_I2C_ENABLE_INT_ENABLE, NULL);
-}
-
-/** Check if FIFO for RGB and clear sensor is empty */
-static void check_fifo_empty_f(struct motion_sensor_t *ms,
- struct motion_sensor_t *ms_rgb, int line)
-{
- struct ec_response_motion_sensor_data vector;
- uint16_t size;
-
- /* Read all data committed to FIFO */
- while (motion_sense_fifo_read(sizeof(vector), 1, &vector, &size)) {
- /* Ignore timestamp frames */
- if (vector.flags == MOTIONSENSE_SENSOR_FLAG_TIMESTAMP) {
- continue;
- }
-
- if (ms - motion_sensors == vector.sensor_num) {
- zassert_unreachable(
- "Unexpected frame for clear sensor");
- }
-
- if (ms_rgb - motion_sensors == vector.sensor_num) {
- zassert_unreachable("Unexpected frame for rgb sensor");
- }
- }
-}
-#define check_fifo_empty(ms, ms_rgb) \
- check_fifo_empty_f(ms, ms_rgb, __LINE__)
-
-/**
- * Test different conditions where irq handler fail or commit no data
- * to fifo
- */
-static void test_tcs_irq_handler_fail(void)
-{
- struct motion_sensor_t *ms, *ms_rgb;
- struct i2c_emul *emul;
- uint32_t event;
-
- emul = tcs_emul_get(TCS_ORD);
- ms = &motion_sensors[TCS_CLR_SENSOR_ID];
- ms_rgb = &motion_sensors[TCS_RGB_SENSOR_ID];
-
- /* Fail on wrong event */
- event = 0x1234 & ~TCS_INT_EVENT;
- zassert_equal(EC_ERROR_NOT_HANDLED, ms->drv->irq_handler(ms, &event),
- NULL);
- check_fifo_empty(ms, ms_rgb);
-
- event = TCS_INT_EVENT;
- /* Test error on reading status */
- i2c_common_emul_set_read_fail_reg(emul, TCS_I2C_STATUS);
- zassert_equal(EC_ERROR_INVAL, ms->drv->irq_handler(ms, &event), NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- check_fifo_empty(ms, ms_rgb);
-
- /* Test fail on changing device power state */
- i2c_common_emul_set_write_fail_reg(emul, TCS_I2C_ENABLE);
- zassert_equal(EC_ERROR_INVAL, ms->drv->irq_handler(ms, &event), NULL);
- i2c_common_emul_set_write_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
- check_fifo_empty(ms, ms_rgb);
-
- /* Test that no data is committed when status is 0 */
- tcs_emul_set_reg(emul, TCS_I2C_STATUS, 0);
- zassert_equal(EC_SUCCESS, ms->drv->irq_handler(ms, &event), NULL);
- check_fifo_empty(ms, ms_rgb);
-}
-
-/**
- * Check if last data committed to FIFO for RGB and clear sensor equals to
- * expected value.
- */
-static void check_fifo_f(struct motion_sensor_t *ms,
- struct motion_sensor_t *ms_rgb,
- int *exp_v, int eps, int line)
-{
- struct ec_response_motion_sensor_data vector;
- uint16_t size;
- int ret_v[4] = {-1, -1, -1, -1};
- int i;
-
- /* Read all data committed to FIFO */
- while (motion_sense_fifo_read(sizeof(vector), 1, &vector, &size)) {
- /* Ignore timestamp frames */
- if (vector.flags == MOTIONSENSE_SENSOR_FLAG_TIMESTAMP) {
- continue;
- }
-
- /* Get clear frame */
- if (ms - motion_sensors == vector.sensor_num) {
- ret_v[0] = vector.udata[0];
- }
-
- /* Get rgb frame */
- if (ms_rgb - motion_sensors == vector.sensor_num) {
- ret_v[1] = vector.udata[0];
- ret_v[2] = vector.udata[1];
- ret_v[3] = vector.udata[2];
- }
- }
-
- if (ret_v[0] == -1) {
- zassert_unreachable("No frame for clear sensor, line %d", line);
- }
-
- if (ret_v[1] == -1) {
- zassert_unreachable("No frame for rgb sensor, line %d", line);
- }
-
- /* Compare with last committed data */
- for (i = 0; i < 4; i++) {
- zassert_within(exp_v[i], ret_v[i], eps,
- "Expected [%d; %d; %d; %d], got [%d; %d; %d; %d]; line: %d",
- exp_v[0], exp_v[1], exp_v[2], exp_v[3],
- ret_v[0], ret_v[1], ret_v[2], ret_v[3], line);
- }
-}
-#define check_fifo(ms, ms_rgb, exp_v, eps) \
- check_fifo_f(ms, ms_rgb, exp_v, eps, __LINE__)
-
-/** Test calibration mode reading of light sensor values */
-static void test_tcs_read_calibration(void)
-{
- struct motion_sensor_t *ms, *ms_rgb;
- struct i2c_emul *emul;
- uint32_t event = TCS_INT_EVENT;
- int emul_v[4];
- int exp_v[4];
- intv3_t v;
-
- emul = tcs_emul_get(TCS_ORD);
- ms = &motion_sensors[TCS_CLR_SENSOR_ID];
- ms_rgb = &motion_sensors[TCS_RGB_SENSOR_ID];
-
- /* Need to be set to collect all data in FIFO */
- ms->oversampling_ratio = 1;
- ms_rgb->oversampling_ratio = 1;
- /* Enable calibration mode */
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 1), NULL);
- /* Setup AGAIN and ATIME for calibration */
- zassert_equal(EC_RES_IN_PROGRESS, ms->drv->read(ms, v), NULL);
-
- /* Test data that are in calibration range */
- exp_v[0] = 12;
- exp_v[1] = 123;
- exp_v[2] = 1234;
- exp_v[3] = 12345;
- /*
- * Emulator value is with gain 64, while expected value is
- * with gain 16
- */
- emul_v[0] = exp_v[0] * 64 / 16;
- emul_v[1] = exp_v[1] * 64 / 16;
- emul_v[2] = exp_v[2] * 64 / 16;
- emul_v[3] = exp_v[3] * 64 / 16;
- tcs_emul_set_val(emul, TCS_EMUL_C, emul_v[0]);
- tcs_emul_set_val(emul, TCS_EMUL_R, emul_v[1]);
- tcs_emul_set_val(emul, TCS_EMUL_G, emul_v[2]);
- tcs_emul_set_val(emul, TCS_EMUL_B, emul_v[3]);
- /* Set status to show valid data */
- tcs_emul_set_reg(emul, TCS_I2C_STATUS, TCS_I2C_STATUS_RGBC_VALID);
-
- zassert_equal(EC_SUCCESS, ms->drv->irq_handler(ms, &event), NULL);
- /* In calibration mode check for exact match */
- check_fifo(ms, ms_rgb, exp_v, 1);
-
- /* Test data that are outside of calibration range */
- exp_v[0] = 0;
- exp_v[1] = UINT16_MAX;
- exp_v[2] = UINT16_MAX;
- exp_v[3] = 213;
- /*
- * Emulator value is with gain 64, while expected value is
- * with gain 16
- */
- emul_v[0] = 0;
- emul_v[1] = exp_v[1] * 64 / 16;
- emul_v[2] = (UINT16_MAX + 23) * 64 / 16;
- emul_v[3] = exp_v[3] * 64 / 16;
- tcs_emul_set_val(emul, TCS_EMUL_C, emul_v[0]);
- tcs_emul_set_val(emul, TCS_EMUL_R, emul_v[1]);
- tcs_emul_set_val(emul, TCS_EMUL_G, emul_v[2]);
- tcs_emul_set_val(emul, TCS_EMUL_B, emul_v[3]);
- /* Set status to show valid data */
- tcs_emul_set_reg(emul, TCS_I2C_STATUS, TCS_I2C_STATUS_RGBC_VALID);
-
- zassert_equal(EC_SUCCESS, ms->drv->irq_handler(ms, &event), NULL);
- /* In calibration mode check for exact match */
- check_fifo(ms, ms_rgb, exp_v, 1);
-}
-
-/**
- * Set emulator internal value using expected output value returned by
- * the driver. First element of expected vector is IR value used in
- * calculations. Based on that clear light value is calculated.
- * First element of expected vector is updated by this function.
- */
-static void set_emul_val_from_exp(int *exp_v, uint16_t *scale,
- struct i2c_emul *emul)
-{
- int emul_v[4];
- int ir;
-
- /* We use exp_v[0] as IR value */
- ir = exp_v[0];
- /* Driver will return lux value as calculated blue light value */
- exp_v[0] = exp_v[2];
-
- /*
- * Driver takes care of different ATIME and AGAIN value, so expected
- * value is always normalized to ATIME 256 and AGAIN 16. Convert it
- * to internal emulator value (ATIME 256, AGAIN 64) and add expected IR
- * value. Clear light is the sum of rgb light and IR component.
- */
- emul_v[1] = (exp_v[1] + ir) * 64 / 16;
- emul_v[2] = (exp_v[2] + ir) * 64 / 16;
- emul_v[3] = (exp_v[3] + ir) * 64 / 16;
- emul_v[0] = (exp_v[1] + exp_v[2] + exp_v[3] + ir) * 64 / 16;
-
- /* Apply scale, driver should divide by this value */
- emul_v[0] = SENSOR_APPLY_SCALE(emul_v[0], scale[0]);
- emul_v[1] = SENSOR_APPLY_SCALE(emul_v[1], scale[1]);
- emul_v[2] = SENSOR_APPLY_SCALE(emul_v[2], scale[2]);
- emul_v[3] = SENSOR_APPLY_SCALE(emul_v[3], scale[3]);
-
- /* Set emulator values */
- tcs_emul_set_val(emul, TCS_EMUL_C, emul_v[0]);
- tcs_emul_set_val(emul, TCS_EMUL_R, emul_v[1]);
- tcs_emul_set_val(emul, TCS_EMUL_G, emul_v[2]);
- tcs_emul_set_val(emul, TCS_EMUL_B, emul_v[3]);
-}
-
-/** Test normal mode reading of light sensor values */
-static void test_tcs_read_xyz(void)
-{
- struct motion_sensor_t *ms, *ms_rgb;
- struct i2c_emul *emul;
- uint32_t event = TCS_INT_EVENT;
- /* Expected data to test: IR, R, G, B */
- int exp_v[][4] = {
- {200, 1110, 870, 850},
- {300, 1110, 10000, 8500},
- {600, 50000, 40000, 30000},
- {1000, 3000, 40000, 2000},
- {1000, 65000, 65000, 65000},
- {100, 214, 541, 516},
- {143, 2141, 5414, 5163},
- {100, 50000, 40000, 30000},
- {1430, 2141, 5414, 5163},
- {10000, 50000, 40000, 30000},
- {10000, 214, 541, 516},
- {15000, 50000, 40000, 30000},
- };
- uint16_t scale[4] = {
- MOTION_SENSE_DEFAULT_SCALE, MOTION_SENSE_DEFAULT_SCALE,
- MOTION_SENSE_DEFAULT_SCALE, MOTION_SENSE_DEFAULT_SCALE
- };
- int i, test;
- intv3_t v;
-
- emul = tcs_emul_get(TCS_ORD);
- ms = &motion_sensors[TCS_CLR_SENSOR_ID];
- ms_rgb = &motion_sensors[TCS_RGB_SENSOR_ID];
-
- /* Need to be set to collect all data in FIFO */
- ms->oversampling_ratio = 1;
- ms_rgb->oversampling_ratio = 1;
- /* Disable calibration mode */
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 0), NULL);
- /* Setup AGAIN and ATIME for normal mode */
- zassert_equal(EC_RES_IN_PROGRESS, ms->drv->read(ms, v), NULL);
-
- /* Test different data in supported range */
- for (test = 0; test < ARRAY_SIZE(exp_v); test++) {
- set_emul_val_from_exp(exp_v[test], scale, emul);
-
- /* Run few times to allow driver change gain */
- for (i = 0; i < 5; i++) {
- tcs_emul_set_reg(emul, TCS_I2C_STATUS,
- TCS_I2C_STATUS_RGBC_VALID);
- zassert_equal(EC_SUCCESS,
- ms->drv->irq_handler(ms, &event), NULL);
- }
- check_fifo(ms, ms_rgb, exp_v[test], V_EPS);
- }
-
- /* Test data that are outside of supported range */
- exp_v[0][0] = 3000;
- exp_v[0][1] = UINT16_MAX;
- exp_v[0][2] = UINT16_MAX * 32;
- exp_v[0][3] = 200;
- set_emul_val_from_exp(exp_v[0], scale, emul);
-
- /* Run few times to allow driver change gain */
- for (i = 0; i < 10; i++) {
- tcs_emul_set_reg(emul, TCS_I2C_STATUS,
- TCS_I2C_STATUS_RGBC_VALID);
- zassert_equal(EC_SUCCESS, ms->drv->irq_handler(ms, &event),
- NULL);
- }
- /*
- * If saturation value is exceeded on any rgb sensor, than data
- * shouldn't be committed to FIFO.
- */
- check_fifo_empty(ms, ms_rgb);
-}
-
-/**
- * Test getting and setting scale of light sensor. Checks if collected values
- * are scaled properly.
- */
-static void test_tcs_scale(void)
-{
- struct motion_sensor_t *ms, *ms_rgb;
- struct i2c_emul *emul;
- uint32_t event = TCS_INT_EVENT;
- /* Expected data to test: IR, R, G, B */
- int exp_v[][4] = {
- {200, 1110, 870, 850},
- {300, 1110, 10000, 8500},
- {600, 5000, 4000, 3000},
- {100, 3000, 4000, 2000},
- {100, 1000, 1000, 1000},
- };
- /* Scale for each test */
- uint16_t exp_scale[][4] = {
- {MOTION_SENSE_DEFAULT_SCALE, MOTION_SENSE_DEFAULT_SCALE,
- MOTION_SENSE_DEFAULT_SCALE, MOTION_SENSE_DEFAULT_SCALE},
- {MOTION_SENSE_DEFAULT_SCALE + 300,
- MOTION_SENSE_DEFAULT_SCALE + 300,
- MOTION_SENSE_DEFAULT_SCALE + 300,
- MOTION_SENSE_DEFAULT_SCALE + 300},
- {MOTION_SENSE_DEFAULT_SCALE - 300,
- MOTION_SENSE_DEFAULT_SCALE - 300,
- MOTION_SENSE_DEFAULT_SCALE - 300,
- MOTION_SENSE_DEFAULT_SCALE - 300},
- {MOTION_SENSE_DEFAULT_SCALE + 345,
- MOTION_SENSE_DEFAULT_SCALE - 5423,
- MOTION_SENSE_DEFAULT_SCALE - 30,
- MOTION_SENSE_DEFAULT_SCALE + 400},
- {MOTION_SENSE_DEFAULT_SCALE - 345,
- MOTION_SENSE_DEFAULT_SCALE + 5423,
- MOTION_SENSE_DEFAULT_SCALE + 30,
- MOTION_SENSE_DEFAULT_SCALE - 400},
- {MOTION_SENSE_DEFAULT_SCALE, MOTION_SENSE_DEFAULT_SCALE,
- MOTION_SENSE_DEFAULT_SCALE, MOTION_SENSE_DEFAULT_SCALE}
- };
- uint16_t scale[3];
- int16_t temp;
- int i, test;
- intv3_t v;
-
- emul = tcs_emul_get(TCS_ORD);
- ms = &motion_sensors[TCS_CLR_SENSOR_ID];
- ms_rgb = &motion_sensors[TCS_RGB_SENSOR_ID];
-
- /* Need to be set to collect all data in FIFO */
- ms->oversampling_ratio = 1;
- ms_rgb->oversampling_ratio = 1;
- /* Disable calibration mode */
- zassert_equal(EC_SUCCESS, ms->drv->perform_calib(ms, 0), NULL);
- /* Setup AGAIN and ATIME for normal mode */
- zassert_equal(EC_RES_IN_PROGRESS, ms->drv->read(ms, v), NULL);
-
- /* Test different data in supported range */
- for (test = 0; test < ARRAY_SIZE(exp_v); test++) {
- /* Set and test clear sensor scale */
- zassert_equal(EC_SUCCESS,
- ms->drv->set_scale(ms, exp_scale[test], 0),
- "test %d", test);
- zassert_equal(EC_SUCCESS,
- ms->drv->get_scale(ms, scale, &temp),
- "test %d", test);
- zassert_equal((int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, temp,
- "test %d, %d", test, temp);
- zassert_equal(exp_scale[test][0], scale[0], "test %d", test);
-
- /* Set and test RGB sensor scale */
- zassert_equal(EC_SUCCESS, ms_rgb->drv->set_scale(ms_rgb,
- &(exp_scale[test][1]), 0),
- "test %d", test);
- zassert_equal(EC_SUCCESS,
- ms_rgb->drv->get_scale(ms_rgb, scale, &temp),
- "test %d", test);
- zassert_equal((int16_t)EC_MOTION_SENSE_INVALID_CALIB_TEMP, temp,
- "test %d", test);
- zassert_equal(exp_scale[test][1], scale[0], "test %d", test);
- zassert_equal(exp_scale[test][2], scale[1], "test %d", test);
- zassert_equal(exp_scale[test][3], scale[2], "test %d", test);
-
- set_emul_val_from_exp(exp_v[test], exp_scale[test], emul);
-
- /* Run few times to allow driver change gain */
- for (i = 0; i < 5; i++) {
- tcs_emul_set_reg(emul, TCS_I2C_STATUS,
- TCS_I2C_STATUS_RGBC_VALID);
- zassert_equal(EC_SUCCESS,
- ms->drv->irq_handler(ms, &event), NULL);
- }
- check_fifo(ms, ms_rgb, exp_v[test], V_EPS);
- }
-
- /* Test fail if scale equals 0 */
- scale[0] = 0;
- scale[1] = MOTION_SENSE_DEFAULT_SCALE;
- scale[2] = MOTION_SENSE_DEFAULT_SCALE;
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_scale(ms, scale, 0), NULL);
-
- zassert_equal(EC_ERROR_INVAL, ms_rgb->drv->set_scale(ms_rgb, scale, 0),
- NULL);
- scale[0] = MOTION_SENSE_DEFAULT_SCALE;
- scale[1] = 0;
- scale[2] = MOTION_SENSE_DEFAULT_SCALE;
- zassert_equal(EC_ERROR_INVAL, ms_rgb->drv->set_scale(ms_rgb, scale, 0),
- NULL);
- scale[0] = MOTION_SENSE_DEFAULT_SCALE;
- scale[1] = MOTION_SENSE_DEFAULT_SCALE;
- scale[2] = 0;
- zassert_equal(EC_ERROR_INVAL, ms_rgb->drv->set_scale(ms_rgb, scale, 0),
- NULL);
-}
-
-/** Test setting and getting data rate of light sensor */
-static void test_tcs_data_rate(void)
-{
- struct motion_sensor_t *ms, *ms_rgb;
- struct i2c_emul *emul;
- uint8_t enable;
-
- emul = tcs_emul_get(TCS_ORD);
- ms = &motion_sensors[TCS_CLR_SENSOR_ID];
- /* RGB sensor doesn't set rate, but return rate of clear sesnor */
- ms_rgb = &motion_sensors[TCS_RGB_SENSOR_ID];
-
- /* Test fail on reading device power state */
- i2c_common_emul_set_read_fail_reg(emul, TCS_I2C_ENABLE);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 0, 0), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 0, 1), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 100, 0), NULL);
- zassert_equal(EC_ERROR_INVAL, ms->drv->set_data_rate(ms, 100, 1), NULL);
- i2c_common_emul_set_read_fail_reg(emul, I2C_COMMON_EMUL_NO_FAIL_REG);
-
- /* Test setting 0 rate disables device */
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 0, 0), NULL);
- zassert_equal(0, tcs_emul_get_reg(emul, TCS_I2C_ENABLE), NULL);
- zassert_equal(0, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(0, ms_rgb->drv->get_data_rate(ms_rgb), NULL);
-
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 0, 1), NULL);
- zassert_equal(0, tcs_emul_get_reg(emul, TCS_I2C_ENABLE), NULL);
- zassert_equal(0, tcs_emul_get_reg(emul, TCS_I2C_ENABLE), NULL);
- zassert_equal(0, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(0, ms_rgb->drv->get_data_rate(ms_rgb), NULL);
-
-
- /* Test setting non-zero rate enables device */
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 100, 0), NULL);
- enable = tcs_emul_get_reg(emul, TCS_I2C_ENABLE);
- zassert_true(enable & TCS_I2C_ENABLE_POWER_ON, NULL);
- zassert_true(enable & TCS_I2C_ENABLE_ADC_ENABLE, NULL);
- zassert_true(enable & TCS_I2C_ENABLE_INT_ENABLE, NULL);
- zassert_equal(100, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(100, ms_rgb->drv->get_data_rate(ms_rgb), NULL);
-
- zassert_equal(EC_SUCCESS, ms->drv->set_data_rate(ms, 100, 1), NULL);
- enable = tcs_emul_get_reg(emul, TCS_I2C_ENABLE);
- zassert_true(enable & TCS_I2C_ENABLE_POWER_ON, NULL);
- zassert_true(enable & TCS_I2C_ENABLE_ADC_ENABLE, NULL);
- zassert_true(enable & TCS_I2C_ENABLE_INT_ENABLE, NULL);
- zassert_equal(100, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(100, ms_rgb->drv->get_data_rate(ms_rgb), NULL);
-
- /* Test RGB sensor doesn't change data rate */
- zassert_equal(EC_SUCCESS, ms_rgb->drv->set_data_rate(ms_rgb, 300, 0),
- NULL);
- zassert_equal(100, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(100, ms_rgb->drv->get_data_rate(ms_rgb), NULL);
-
- zassert_equal(EC_SUCCESS, ms_rgb->drv->set_data_rate(ms_rgb, 300, 1),
- NULL);
- zassert_equal(100, ms->drv->get_data_rate(ms), NULL);
- zassert_equal(100, ms_rgb->drv->get_data_rate(ms_rgb), NULL);
-}
-
-/** Test set range function of clear and RGB sensors */
-static void test_tcs_set_range(void)
-{
- struct motion_sensor_t *ms, *ms_rgb;
- struct i2c_emul *emul;
-
- emul = tcs_emul_get(TCS_ORD);
- ms = &motion_sensors[TCS_CLR_SENSOR_ID];
- ms_rgb = &motion_sensors[TCS_RGB_SENSOR_ID];
-
- /* RGB sensor doesn't set anything */
- zassert_equal(EC_SUCCESS, ms_rgb->drv->set_range(ms_rgb, 1, 0), NULL);
-
- /* Clear sensor doesn't change anything on device to set range */
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 0x12300, 1), NULL);
- zassert_equal(0x12300, ms->current_range, NULL);
-
- zassert_equal(EC_SUCCESS, ms->drv->set_range(ms, 0x10000, 0), NULL);
- zassert_equal(0x10000, ms->current_range, NULL);
-}
-
-void test_suite_tcs3400(void)
-{
- ztest_test_suite(tcs3400,
- ztest_user_unit_test(test_tcs_init),
- ztest_user_unit_test(test_tcs_read),
- ztest_user_unit_test(test_tcs_irq_handler_fail),
- ztest_user_unit_test(test_tcs_read_calibration),
- ztest_user_unit_test(test_tcs_read_xyz),
- ztest_user_unit_test(test_tcs_scale),
- ztest_user_unit_test(test_tcs_data_rate),
- ztest_user_unit_test(test_tcs_set_range));
- ztest_run_test_suite(tcs3400);
-}
diff --git a/zephyr/test/drivers/src/temp_sensor.c b/zephyr/test/drivers/src/temp_sensor.c
deleted file mode 100644
index 83a343e572..0000000000
--- a/zephyr/test/drivers/src/temp_sensor.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-#include <drivers/adc.h>
-#include <drivers/adc/adc_emul.h>
-#include <drivers/gpio.h>
-#include <drivers/gpio/gpio_emul.h>
-
-#include <math.h>
-
-#include "common.h"
-#include "temp_sensor.h"
-#include "temp_sensor/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)
-
-#define ADC_DEVICE_NODE DT_NODELABEL(adc0)
-#define ADC_CHANNELS_NUM DT_PROP(DT_NODELABEL(adc0), nchannels)
-
-/** Test error code when invalid sensor is passed to temp_sensor_read() */
-static void test_temp_sensor_wrong_id(void)
-{
- int temp;
-
- zassert_equal(EC_ERROR_INVAL, temp_sensor_read(TEMP_SENSOR_COUNT,
- &temp),
- NULL);
-}
-
-/** Test error code when temp_sensor_read() is called with powered off ADC */
-static void test_temp_sensor_adc_error(void)
-{
- const struct device *gpio_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_PG_EC_DSW_PWROK_PATH, gpios));
- int temp;
-
- zassert_not_null(gpio_dev, "Cannot get GPIO device");
-
- /*
- * pg_ec_dsw_pwrok = 0 means ADC is not powered.
- * adc_read will return error
- */
- zassert_ok(gpio_emul_input_set(gpio_dev, GPIO_PG_EC_DSW_PWROK_PORT, 0),
- NULL);
-
- zassert_equal(EC_ERROR_NOT_POWERED,
- temp_sensor_read(TEMP_SENSOR_CHARGER, &temp), NULL);
- zassert_equal(EC_ERROR_NOT_POWERED,
- temp_sensor_read(TEMP_SENSOR_DDR_SOC, &temp), NULL);
- zassert_equal(EC_ERROR_NOT_POWERED,
- temp_sensor_read(TEMP_SENSOR_FAN, &temp), NULL);
- zassert_equal(EC_ERROR_NOT_POWERED,
- temp_sensor_read(TEMP_SENSOR_PP3300_REGULATOR, &temp),
- NULL);
-
- /* power ADC */
- zassert_ok(gpio_emul_input_set(gpio_dev, GPIO_PG_EC_DSW_PWROK_PORT, 1),
- NULL);
-}
-
-/** Simple ADC emulator custom function which always return error */
-static int adc_error_func(const struct device *dev, unsigned int channel,
- void *param, uint32_t *result)
-{
- return -EINVAL;
-}
-
-/**
- * Set valid response only for ADC channel connected with tested sensor.
- * Check if temp_sensor_read() from tested sensor returns EC_SUCCESS and
- * valid temperature. Set invalid response on ADC channel for next test.
- */
-static void check_valid_temperature(const struct device *adc_dev, int sensor)
-{
- int temp;
-
- /* ADC channel of tested sensor return valid value */
- zassert_ok(adc_emul_const_value_set(adc_dev, temp_sensors[sensor].idx,
- 1000),
- "adc_emul_const_value_set() failed (sensor %d)", sensor);
- zassert_equal(EC_SUCCESS, temp_sensor_read(sensor, &temp), NULL);
- zassert_within(temp, 273 + 50, 51,
- "Expected temperature in 0*C-100*C, got %d*C (sensor %d)",
- temp - 273, sensor);
- /* Return error on ADC channel of tested sensor */
- zassert_ok(adc_emul_value_func_set(adc_dev, temp_sensors[sensor].idx,
- adc_error_func, NULL),
- "adc_emul_value_func_set() failed (sensor %d)", sensor);
-}
-
-/** Test if temp_sensor_read() returns temperature on success */
-static void test_temp_sensor_read(void)
-{
- const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
- int chan;
-
- zassert_not_null(adc_dev, "Cannot get ADC device");
-
- /* Return error on all ADC channels */
- for (chan = 0; chan < ADC_CHANNELS_NUM; chan++) {
- zassert_ok(adc_emul_value_func_set(adc_dev, chan,
- adc_error_func, NULL),
- "channel %d adc_emul_value_func_set() failed", chan);
- }
-
- check_valid_temperature(adc_dev, TEMP_SENSOR_CHARGER);
- check_valid_temperature(adc_dev, TEMP_SENSOR_DDR_SOC);
- check_valid_temperature(adc_dev, TEMP_SENSOR_FAN);
- check_valid_temperature(adc_dev, TEMP_SENSOR_PP3300_REGULATOR);
-
- /* Return correct value on all ADC channels */
- for (chan = 0; chan < ADC_CHANNELS_NUM; chan++) {
- zassert_ok(adc_emul_const_value_set(adc_dev, chan, 1000),
- "channel %d adc_emul_const_value_set() failed",
- chan);
- }
-}
-
-void test_suite_temp_sensor(void)
-{
- const struct device *dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_PG_EC_DSW_PWROK_PATH, gpios));
-
- zassert_not_null(dev, NULL);
- /* Before tests make sure that power pin is set. */
- zassert_ok(gpio_emul_input_set(dev, GPIO_PG_EC_DSW_PWROK_PORT, 1),
- NULL);
-
- ztest_test_suite(temp_sensor,
- ztest_user_unit_test(test_temp_sensor_wrong_id),
- ztest_user_unit_test(test_temp_sensor_adc_error),
- ztest_user_unit_test(test_temp_sensor_read));
- ztest_run_test_suite(temp_sensor);
-}
diff --git a/zephyr/test/drivers/src/thermistor.c b/zephyr/test/drivers/src/thermistor.c
deleted file mode 100644
index a7137d5f19..0000000000
--- a/zephyr/test/drivers/src/thermistor.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr.h>
-#include <ztest.h>
-#include <drivers/adc.h>
-#include <drivers/adc/adc_emul.h>
-#include <drivers/gpio.h>
-#include <drivers/gpio/gpio_emul.h>
-#include <temp_sensor.h>
-
-#include "common.h"
-#include "../driver/temp_sensor/thermistor.h"
-#include "temp_sensor/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)
-
-#define ADC_DEVICE_NODE DT_NODELABEL(adc0)
-
-/* TODO replace counting macros with DT macro when
- * https://github.com/zephyrproject-rtos/zephyr/issues/38715 lands
- */
-#define _ACCUMULATOR(x)
-#define NAMED_TEMP_SENSORS_SIZE \
- DT_FOREACH_CHILD(DT_PATH(named_temp_sensors), _ACCUMULATOR) \
- 0
-#define TEMP_SENSORS_ENABLED_SIZE \
- DT_FOREACH_STATUS_OKAY(cros_ec_temp_sensor, _ACCUMULATOR) 0
-
-/* Conversion of temperature doesn't need to be 100% accurate */
-#define TEMP_EPS 2
-
-#define A_VALID_VOLTAGE 1000
-/**
- * Test if get temp function return expected error when ADC is not powered
- * (indicated as GPIO pin set to low) and return success after powering on ADC.
- */
-static void test_thermistor_power_pin(void)
-{
- int temp;
- int sensor_idx;
-
- const struct device *gpio_dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_PG_EC_DSW_PWROK_PATH, gpios));
- const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
-
- zassert_not_null(gpio_dev, "Cannot get GPIO device");
- zassert_not_null(adc_dev, "Cannot get ADC device");
-
- /* Make sure that ADC return a valid value */
- for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE;
- sensor_idx++) {
- const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
-
- zassert_ok(adc_emul_const_value_set(adc_dev,
- sensor->idx,
- A_VALID_VOLTAGE),
- "adc_emul_value_func_set() failed on %s",
- sensor->name);
- }
-
- /* pg_ec_dsw_pwrok = 0 means ADC is not powered. */
- zassert_ok(gpio_emul_input_set(gpio_dev, GPIO_PG_EC_DSW_PWROK_PORT, 0),
- NULL);
-
- for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE;
- sensor_idx++) {
- const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
-
- zassert_equal(EC_ERROR_NOT_POWERED, sensor->read(sensor, &temp),
- "%s failed", sensor->name);
- }
-
- /* pg_ec_dsw_pwrok = 1 means ADC is powered. */
- zassert_ok(gpio_emul_input_set(gpio_dev, GPIO_PG_EC_DSW_PWROK_PORT, 1),
- NULL);
-
- for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE;
- sensor_idx++) {
- const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
-
- zassert_equal(EC_SUCCESS, sensor->read(sensor, &temp),
- "%s failed", sensor->name);
- }
-}
-
-/* Simple ADC emulator custom function which always return error */
-static int adc_error_func(const struct device *dev, unsigned int channel,
- void *param, uint32_t *result)
-{
- return -EINVAL;
-}
-
-/** Test if get temp function return expected error on ADC malfunction */
-static void test_thermistor_adc_read_error(void)
-{
- int temp;
- int sensor_idx;
-
- const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
-
- zassert_not_null(adc_dev, "Cannot get ADC device");
-
- /* Return error on all ADC channels */
- for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE;
- sensor_idx++) {
- const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
-
- zassert_ok(adc_emul_value_func_set(adc_dev, sensor->idx,
- adc_error_func, NULL),
- "adc_emul_value_func_set() failed on %s",
- sensor->name);
- }
-
- for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE;
- sensor_idx++) {
- const struct temp_sensor_t *sensor = &temp_sensors[sensor_idx];
-
- zassert_equal(EC_ERROR_UNKNOWN, sensor->read(sensor, &temp),
- "%s failed", sensor->name);
- }
-}
-
-/** Get resistance of thermistor for given temperature */
-static int resistance_47kohm_B4050(int t)
-{
- /* Thermistor manufacturer resistance lookup table*/
- int r_table[] = {
- 155700, 147900, 140600, 133700, 127200, /* 0*C - 4*C */
- 121000, 115100, 109600, 104300, 99310, /* 5*C - 9*C */
- 94600, 90130, 85890, 81870, 78070, /* 10*C - 14*C */
- 74450, 71020, 67770, 64680, 61750, /* 15*C - 19*C */
- 58970, 56320, 53810, 51430, 49160, /* 20*C - 24*C */
- 47000, 44950, 42990, 41130, 39360, /* 25*C - 29*C */
- 37680, 36070, 34540, 33080, 31690, /* 30*C - 34*C */
- 30360, 29100, 27900, 26750, 25650, /* 35*C - 39*C */
- 24610, 23610, 22660, 21750, 20880, /* 40*C - 44*C */
- 20050, 19260, 18500, 17780, 17090, /* 45*C - 49*C */
- 16430, 15800, 15200, 14620, 14070, /* 50*C - 54*C */
- 13540, 13030, 12550, 12090, 11640, /* 55*C - 59*C */
- 11210, 10800, 10410, 10040, 9676, /* 60*C - 64*C */
- 9331, 8999, 8680, 8374, 8081, /* 65*C - 69*C */
- 7799, 7528, 7268, 7018, 6777, /* 70*C - 74*C */
- 6546, 6324, 6111, 5906, 5708, /* 75*C - 79*C */
- 5518, 5335, 5160, 4990, 4827, /* 80*C - 84*C */
- 4671, 4519, 4374, 4233, 4098, /* 85*C - 89*C */
- 3968, 3842, 3721, 3605, 3492, /* 90*C - 94*C */
- 3384, 3279, 3179, 3082, 2988, /* 95*C - 99*C */
- 2898 /* 100*C */
- };
-
- t -= 273;
- if (t < 0)
- return r_table[0] + 10000;
-
- if (t >= ARRAY_SIZE(r_table))
- return r_table[ARRAY_SIZE(r_table) - 1] - 100;
-
- return r_table[t];
-}
-
-/**
- * Calculate output voltage in voltage divider circuit using formula
- * Vout = Vs * r2 / (r1 + r2)
- */
-static int volt_divider(int vs, int r1, int r2)
-{
- return vs * r2 / (r1 + r2);
-}
-
-struct thermistor_state {
- const int v;
- const int r;
- int temp_expected;
-};
-
-/** ADC emulator function which calculate output voltage for given thermistor */
-static int adc_temperature_func(const struct device *dev, unsigned int channel,
- void *param, uint32_t *result)
-{
- struct thermistor_state *s = (struct thermistor_state *)param;
-
- *result = volt_divider(s->v,
- s->r,
- resistance_47kohm_B4050(s->temp_expected));
-
- return 0;
-}
-
-/** Test conversion from ADC raw value to temperature */
-static void do_thermistor_test(const struct temp_sensor_t *temp_sensor,
- int reference_mv, int reference_ohms)
-{
- int temp_expected;
- int temp;
-
- const struct device *adc_dev = DEVICE_DT_GET(ADC_DEVICE_NODE);
- struct thermistor_state state = {
- .v = reference_mv,
- .r = reference_ohms,
- };
-
- zassert_not_null(adc_dev, "Cannot get ADC device");
-
- /* Setup ADC channel */
- zassert_ok(adc_emul_value_func_set(adc_dev,
- temp_sensor->idx,
- adc_temperature_func, &state),
- "adc_emul_value_func_set() failed on %s", temp_sensor->name);
-
- /* Makes sure that reference voltage is correct for given thermistor */
- zassert_ok(adc_emul_ref_voltage_set(adc_dev, ADC_REF_INTERNAL, state.v),
- "adc_emul_ref_voltage_set() failed %s on ",
- temp_sensor->name);
-
- /* Test whole supported range from 0*C to 100*C (273*K to 373*K) */
- for (temp_expected = 273; temp_expected <= 373; temp_expected++) {
- state.temp_expected = temp_expected;
- zassert_equal(EC_SUCCESS, temp_sensor->read(temp_sensor, &temp),
- "failed on %s", temp_sensor->name);
- zassert_within(temp_expected, temp, TEMP_EPS,
- "Expected %d*K, got %d*K on %s", temp_expected,
- temp, temp_sensor->name);
- }
-
- /* Temperatures below 0*C should be reported as 0*C */
- state.temp_expected = -15 + 273;
- zassert_equal(EC_SUCCESS, temp_sensor->read(temp_sensor, &temp),
- "failed on %s", temp_sensor->name);
- zassert_equal(273, temp, "Expected %d*K, got %d*K on %s", 273, temp,
- temp_sensor->name);
-
- /* Temperatures above 100*C should be reported as 100*C */
- state.temp_expected = 115 + 273;
- zassert_equal(EC_SUCCESS, temp_sensor->read(temp_sensor, &temp),
- "failed on %s", temp_sensor->name);
- zassert_equal(373, temp, "Expected %d*K, got %d*K on %s", 373, temp,
- temp_sensor->name);
-}
-
-#define GET_THERMISTOR_REF_MV(node_id) \
- [ZSHIM_TEMP_SENSOR_ID(node_id)] = DT_PROP( \
- DT_PHANDLE(node_id, thermistor), steinhart_reference_mv),
-
-#define GET_THERMISTOR_REF_RES(node_id) \
- [ZSHIM_TEMP_SENSOR_ID(node_id)] = DT_PROP( \
- DT_PHANDLE(node_id, thermistor), steinhart_reference_res),
-
-static void test_thermistors_adc_temperature_conversion(void)
-{
- int sensor_idx;
-
- const static int reference_mv_arr[] = { DT_FOREACH_STATUS_OKAY(
- cros_temp_sensor, GET_THERMISTOR_REF_MV) };
- const static int reference_res_arr[] = { DT_FOREACH_STATUS_OKAY(
- cros_temp_sensor, GET_THERMISTOR_REF_RES) };
-
- for (sensor_idx = 0; sensor_idx < NAMED_TEMP_SENSORS_SIZE; sensor_idx++)
- do_thermistor_test(&temp_sensors[sensor_idx],
- reference_mv_arr[sensor_idx],
- reference_res_arr[sensor_idx]);
-}
-
-static void test_device_nodes_enabled(void)
-{
- zassert_equal(NAMED_TEMP_SENSORS_SIZE, TEMP_SENSORS_ENABLED_SIZE,
- "Temperature sensors in device tree and "
- "those enabled for test differ");
-
- /* Thermistor nodes being enabled are already tested by compilation. */
-}
-
-void test_suite_thermistor(void)
-{
- const struct device *dev =
- DEVICE_DT_GET(DT_GPIO_CTLR(GPIO_PG_EC_DSW_PWROK_PATH, gpios));
-
- zassert_not_null(dev, NULL);
- /* Before tests make sure that power pin is set. */
- zassert_ok(gpio_emul_input_set(dev, GPIO_PG_EC_DSW_PWROK_PORT, 1),
- NULL);
-
- ztest_test_suite(thermistor,
- ztest_user_unit_test(test_device_nodes_enabled),
- ztest_user_unit_test(test_thermistor_power_pin),
- ztest_user_unit_test(test_thermistor_adc_read_error),
- ztest_user_unit_test(
- test_thermistors_adc_temperature_conversion));
-
- ztest_run_test_suite(thermistor);
-}
diff --git a/zephyr/test/drivers/zmake.yaml b/zephyr/test/drivers/zmake.yaml
deleted file mode 100644
index 31d8523e8e..0000000000
--- a/zephyr/test/drivers/zmake.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: native_posix
-supported-zephyr-versions:
- - v2.6
-supported-toolchains:
- - llvm
- - host
-output-type: elf
-is-test: true
-dts-overlays:
- - overlay.dts
diff --git a/zephyr/test/ec_app/CMakeLists.txt b/zephyr/test/ec_app/CMakeLists.txt
deleted file mode 100644
index 8ee9a554a7..0000000000
--- a/zephyr/test/ec_app/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(ec_app)
-
-FILE(GLOB app_sources src/*.c)
-target_sources(app PRIVATE ${app_sources})
diff --git a/zephyr/test/ec_app/prj.conf b/zephyr/test/ec_app/prj.conf
deleted file mode 100644
index b398d0dd8c..0000000000
--- a/zephyr/test/ec_app/prj.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_ZTEST=y
-CONFIG_PLATFORM_EC=y
-CONFIG_CROS_EC=y
diff --git a/zephyr/test/ec_app/src/main.c b/zephyr/test/ec_app/src/main.c
deleted file mode 100644
index 6aa2d6c1b9..0000000000
--- a/zephyr/test/ec_app/src/main.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Copyright 2021 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <ztest.h>
-#include "ec_app_main.h"
-#include "hooks.h"
-
-static void test_init_reset_log(void)
-{
-#ifdef CONFIG_CMD_AP_RESET_LOG
- zassert_unreachable("TODO: Implement this test.");
-#else
- ztest_test_skip();
-#endif
-}
-
-static void test_lpc_init_mask(void)
-{
-#ifdef CONFIG_HOSTCMD_X86
- zassert_unreachable("TODO: Implement this test.");
-#else
- ztest_test_skip();
-#endif
-}
-
-static void test_keyboard_scan_init(void)
-{
-#ifdef HAS_TASK_KEYSCAN
- zassert_unreachable("TODO: Implement this test.");
-#else
- ztest_test_skip();
-#endif
-}
-
-static void test_button_init(void)
-{
-#if defined(CONFIG_DEDICATED_RECOVERY_BUTTON) || defined(CONFIG_VOLUME_BUTTONS)
- zassert_unreachable("TODO: Implement this test.");
-#else
- ztest_test_skip();
-#endif
-}
-
-static void test_setup_espi(void)
-{
-#ifdef CONFIG_PLATFORM_EC_ESPI
- zassert_unreachable("TODO: Implement this test.");
-#else
- ztest_test_skip();
-#endif
-}
-
-static void test_watchdog_init(void)
-{
-#ifdef CONFIG_PLATFORM_EC_WATCHDOG
- zassert_unreachable("TODO: Implement this test.");
-#else
- ztest_test_skip();
-#endif
-}
-
-static void test_vboot_main(void)
-{
-#ifdef CONFIG_PLATFORM_EC_VBOOT_EFS2
- zassert_unreachable("TODO: Implement this test.");
-#else
- ztest_test_skip();
-#endif
-}
-
-#ifdef CONFIG_PLATFORM_EC_HOOKS
-static int sample_init_hook_count;
-/**
- * Just a sample hook.
- */
-static void sample_init_hook(void)
-{
- printk("Running hook.\n");
- sample_init_hook_count++;
-}
-DECLARE_HOOK(HOOK_INIT, sample_init_hook, HOOK_PRIO_DEFAULT);
-
-/**
- * @brief Test EC App main runs hooks of type HOOK_INIT.
- *
- * This test installs a hook, runs main and verifies that the hook ran.
- *
- */
-static void test_hook_notify_init(void)
-{
- sample_init_hook_count = 0;
- ec_app_main();
- zassert_equal(1, sample_init_hook_count,
- "Expected sample_init_hook to run once.");
-}
-#else
-static void test_hook_notify_init(void)
-{
- ztest_test_skip();
-}
-#endif
-
-static void test_start_ec_tasks(void)
-{
-#ifdef CONFIG_SHIMMED_TASKS
- zassert_unreachable("TODO: Implement this test.");
-#else
- ztest_test_skip();
-#endif
-}
-
-void test_main(void)
-{
- ztest_test_suite(ec_app_tests, ztest_unit_test(test_init_reset_log),
- ztest_unit_test(test_lpc_init_mask),
- ztest_unit_test(test_keyboard_scan_init),
- ztest_unit_test(test_button_init),
- ztest_unit_test(test_setup_espi),
- ztest_unit_test(test_watchdog_init),
- ztest_unit_test(test_vboot_main),
- ztest_unit_test(test_hook_notify_init),
- ztest_unit_test(test_start_ec_tasks));
-
- ztest_run_test_suite(ec_app_tests);
-}
diff --git a/zephyr/test/ec_app/zmake.yaml b/zephyr/test/ec_app/zmake.yaml
deleted file mode 100644
index decc749ae1..0000000000
--- a/zephyr/test/ec_app/zmake.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: native_posix
-supported-zephyr-versions:
- - v2.6
-supported-toolchains:
- - llvm
- - host
-output-type: elf
-is-test: true
diff --git a/zephyr/test/hooks/CMakeLists.txt b/zephyr/test/hooks/CMakeLists.txt
deleted file mode 100644
index 81ff57d69d..0000000000
--- a/zephyr/test/hooks/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2020 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.
-
-cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(hooks)
-
-target_sources(app PRIVATE hooks.c)
diff --git a/zephyr/test/hooks/hooks.c b/zephyr/test/hooks/hooks.c
deleted file mode 100644
index a9e0982e46..0000000000
--- a/zephyr/test/hooks/hooks.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <stdbool.h>
-#include <ztest.h>
-
-#include "hooks.h"
-
-static bool h1_called;
-static bool h2_called;
-static bool h3_called;
-
-static void h1(void)
-{
- zassert_false(h1_called, "h1 was called, but should not have been");
- zassert_false(h2_called, "h2 was called, but should not have been");
- zassert_false(h3_called, "h3 was called, but should not have been");
- h1_called = true;
-}
-DECLARE_HOOK(HOOK_TEST_1, h1, HOOK_PRIO_FIRST);
-
-static void h2(void)
-{
- zassert_true(h1_called, "h1 was not called, but should have been");
- zassert_false(h2_called, "h2 was called, but should not have been");
- zassert_false(h3_called, "h3 was called, but should not have been");
- h2_called = true;
-}
-DECLARE_HOOK(HOOK_TEST_1, h2, HOOK_PRIO_DEFAULT);
-
-static void h3(void)
-{
- zassert_true(h1_called, "h1 was not called, but should have been");
- zassert_true(h2_called, "h2 was not called, but should have been");
- zassert_false(h3_called, "h3 was called, but should not have been");
- h3_called = true;
-}
-DECLARE_HOOK(HOOK_TEST_1, h3, HOOK_PRIO_LAST);
-
-static void test_hook_list_multiple(void)
-{
- hook_notify(HOOK_TEST_1);
- zassert_true(h1_called, "h1 was not called, but should have been");
- zassert_true(h2_called, "h2 was not called, but should have been");
- zassert_true(h3_called, "h3 was not called, but should have been");
-}
-
-static bool h4_called;
-
-static void h4(void)
-{
- zassert_false(h4_called, "h4 was called, but should not have been");
- h4_called = true;
-}
-DECLARE_HOOK(HOOK_TEST_2, h4, HOOK_PRIO_DEFAULT);
-
-static void test_hook_list_single(void)
-{
- hook_notify(HOOK_TEST_2);
- zassert_true(h4_called, "h4 was not called, but should have been");
-}
-
-static void test_hook_list_empty(void)
-{
- hook_notify(HOOK_TEST_3);
-}
-
-static bool deferred_func_called;
-
-#define DEFERRED_DELAY_US (500 * 1000)
-static void deferred_func(void)
-{
- deferred_func_called = true;
-}
-DECLARE_DEFERRED(deferred_func);
-
-static void test_deferred_func(void)
-{
- zassert_false(
- deferred_func_called,
- "The deferred function was called, but should not have been");
- hook_call_deferred(&deferred_func_data, DEFERRED_DELAY_US);
- zassert_false(
- deferred_func_called,
- "The deferred function was called, but should not have been");
- k_usleep(DEFERRED_DELAY_US * 2);
- zassert_true(
- deferred_func_called,
- "The deferred function was not called, but should have been");
-}
-
-static bool deferred_func_2_called;
-
-static void deferred_func_2(void)
-{
- deferred_func_2_called = true;
-}
-DECLARE_DEFERRED(deferred_func_2);
-
-/*
- * Test that repeated calls to hook_call_deferred result in the
- * function being pushed out.
- */
-static void test_deferred_func_push_out(void)
-{
- zassert_false(
- deferred_func_2_called,
- "The deferred function was called, but should not have been");
- hook_call_deferred(&deferred_func_2_data, DEFERRED_DELAY_US);
- hook_call_deferred(&deferred_func_2_data, DEFERRED_DELAY_US * 3);
- k_usleep(DEFERRED_DELAY_US * 2);
- zassert_false(
- deferred_func_2_called,
- "The deferred function was called, but should not have been");
- k_usleep(DEFERRED_DELAY_US * 2);
- zassert_true(
- deferred_func_called,
- "The deferred function was not called, but should have been");
-}
-
-static bool deferred_func_3_called;
-
-static void deferred_func_3(void)
-{
- deferred_func_3_called = true;
-}
-DECLARE_DEFERRED(deferred_func_3);
-
-static void test_deferred_func_cancel(void)
-{
- zassert_false(
- deferred_func_3_called,
- "The deferred function was called, but should not have been");
- hook_call_deferred(&deferred_func_3_data, DEFERRED_DELAY_US);
- hook_call_deferred(&deferred_func_3_data, -1);
- k_usleep(DEFERRED_DELAY_US * 2);
- zassert_false(
- deferred_func_3_called,
- "The deferred function was called, but should not have been");
-}
-
-void test_main(void)
-{
- ztest_test_suite(
- hooks_tests,
- ztest_unit_test(test_hook_list_multiple),
- ztest_unit_test(test_hook_list_single),
- ztest_unit_test(test_hook_list_empty),
- ztest_unit_test(test_deferred_func),
- ztest_unit_test(test_deferred_func_push_out),
- ztest_unit_test(test_deferred_func_cancel));
-
- ztest_run_test_suite(hooks_tests);
-}
diff --git a/zephyr/test/hooks/prj.conf b/zephyr/test/hooks/prj.conf
deleted file mode 100644
index c0c02e22ca..0000000000
--- a/zephyr/test/hooks/prj.conf
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_ZTEST=y
-CONFIG_PLATFORM_EC=y
-CONFIG_PLATFORM_EC_HOOKS=y
-CONFIG_CROS_EC=y
diff --git a/zephyr/test/hooks/zmake.yaml b/zephyr/test/hooks/zmake.yaml
deleted file mode 100644
index 6aa10c2661..0000000000
--- a/zephyr/test/hooks/zmake.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: native_posix
-supported-zephyr-versions:
- - v2.6
-supported-toolchains:
- - llvm
- - host
-output-type: elf
-is-test: true
diff --git a/zephyr/test/i2c/CMakeLists.txt b/zephyr/test/i2c/CMakeLists.txt
deleted file mode 100644
index 214177013f..0000000000
--- a/zephyr/test/i2c/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2020 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.
-
-cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(i2c)
-
-target_sources(app PRIVATE src/main.c)
diff --git a/zephyr/test/i2c/overlay.dts b/zephyr/test/i2c/overlay.dts
deleted file mode 100644
index 2c56ee3b7a..0000000000
--- a/zephyr/test/i2c/overlay.dts
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-i2c-ports {
- compatible = "named-i2c-ports";
- accel-0 {
- i2c-port = <&bmi_i2c>;
- enum-name = "I2C_PORT_ACCEL";
- label = "ACCEL_0";
- };
- };
-};
-
-&i2c0 {
- bmi_i2c: bmi@68 {
- compatible = "bosch,bmi160";
- reg = <0x68>;
- label = "accel-i2c";
- };
-};
diff --git a/zephyr/test/i2c/prj.conf b/zephyr/test/i2c/prj.conf
deleted file mode 100644
index 8023c0492b..0000000000
--- a/zephyr/test/i2c/prj.conf
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_ZTEST=y
-CONFIG_LOG=y
-
-CONFIG_EMUL=y
-CONFIG_I2C=y
-CONFIG_I2C_EMUL=y
-CONFIG_BMI160=y
-CONFIG_EMUL_BMI160=y
-CONFIG_SENSOR=y
-CONFIG_BMI160_TRIGGER_NONE=y
-
-CONFIG_PLATFORM_EC=y
-CONFIG_PLATFORM_EC_I2C=y
-CONFIG_CROS_EC=y
-
-# TODO(b/173711210) figure out why SPI is required here when we're not using it.
-CONFIG_SPI=y
-CONFIG_SPI_EMUL=y
diff --git a/zephyr/test/i2c/src/main.c b/zephyr/test/i2c/src/main.c
deleted file mode 100644
index 064ce78816..0000000000
--- a/zephyr/test/i2c/src/main.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <devicetree.h>
-#include <ztest.h>
-
-#include "common.h"
-#include "i2c/i2c.h"
-
-/* Unused: required for shimming i2c. */
-void watchdog_reload(void)
-{
-}
-
-static void test_i2c_port_count(void)
-{
- zassert_equal(NAMED_I2C(accel_0), 0,
- "accel_0 expected to be 0 but was %d",
- NAMED_I2C(accel_0));
- zassert_equal(I2C_PORT_COUNT, 1,
- "I2C_PORT_COUNT expected to be 1 but was %d",
- I2C_PORT_COUNT);
-}
-
-/* Test case main entry. */
-void test_main(void)
-{
- ztest_test_suite(test_i2c,
- ztest_user_unit_test(test_i2c_port_count));
- ztest_run_test_suite(test_i2c);
-}
-
diff --git a/zephyr/test/i2c/zmake.yaml b/zephyr/test/i2c/zmake.yaml
deleted file mode 100644
index f5e794c0f8..0000000000
--- a/zephyr/test/i2c/zmake.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: native_posix
-supported-zephyr-versions:
- - v2.6
-supported-toolchains:
- - llvm
- - host
-output-type: elf
-is-test: true
-dts-overlays:
- - overlay.dts
diff --git a/zephyr/test/i2c_dts/CMakeLists.txt b/zephyr/test/i2c_dts/CMakeLists.txt
deleted file mode 100644
index eea2834af1..0000000000
--- a/zephyr/test/i2c_dts/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2020 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.
-
-cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(i2c_test)
-
-FILE(GLOB app_sources src/*.c)
-target_sources(app PRIVATE ${app_sources})
diff --git a/zephyr/test/i2c_dts/overlay.dts b/zephyr/test/i2c_dts/overlay.dts
deleted file mode 100644
index 2c56ee3b7a..0000000000
--- a/zephyr/test/i2c_dts/overlay.dts
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-i2c-ports {
- compatible = "named-i2c-ports";
- accel-0 {
- i2c-port = <&bmi_i2c>;
- enum-name = "I2C_PORT_ACCEL";
- label = "ACCEL_0";
- };
- };
-};
-
-&i2c0 {
- bmi_i2c: bmi@68 {
- compatible = "bosch,bmi160";
- reg = <0x68>;
- label = "accel-i2c";
- };
-};
diff --git a/zephyr/test/i2c_dts/prj.conf b/zephyr/test/i2c_dts/prj.conf
deleted file mode 100644
index a08cdbb7fb..0000000000
--- a/zephyr/test/i2c_dts/prj.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-CONFIG_ZTEST=y
-CONFIG_LOG=y
-
-CONFIG_EMUL=y
-CONFIG_I2C=y
-CONFIG_I2C_EMUL=y
-CONFIG_BMI160=y
-CONFIG_EMUL_BMI160=y
-CONFIG_SENSOR=y
-CONFIG_BMI160_TRIGGER_NONE=y
-
-# TODO(b/173711210) figure out why SPI is required here when we're not using it.
-CONFIG_SPI=y
-CONFIG_SPI_EMUL=y
diff --git a/zephyr/test/i2c_dts/src/main.c b/zephyr/test/i2c_dts/src/main.c
deleted file mode 100644
index ccd58dde67..0000000000
--- a/zephyr/test/i2c_dts/src/main.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <device.h>
-#include <devicetree.h>
-#include <ztest.h>
-
-static void test_i2c_get_device(void)
-{
- const struct device *accel0 = DEVICE_DT_GET(
- DT_PHANDLE(DT_PATH(named_i2c_ports, accel_0),
- i2c_port));
- const struct device *bmi_i2c = DEVICE_DT_GET(
- DT_NODELABEL(bmi_i2c));
-
- zassert_not_null(accel0, "accel0 was NULL");
- zassert_not_null(bmi_i2c, "bmi_i2c was NULL");
- zassert_equal(accel0, bmi_i2c,
- "named_i2c_ports/accel0 and bmi_i2c should resolve to the same device");
-}
-
-/* test case main entry */
-void test_main(void)
-{
- ztest_test_suite(test_i2c_bindings,
- ztest_user_unit_test(test_i2c_get_device));
- ztest_run_test_suite(test_i2c_bindings);
-}
diff --git a/zephyr/test/i2c_dts/zmake.yaml b/zephyr/test/i2c_dts/zmake.yaml
deleted file mode 100644
index c3fca2272e..0000000000
--- a/zephyr/test/i2c_dts/zmake.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: native_posix
-supported-zephyr-versions:
- - v2.6
-output-type: elf
-supported-toolchains:
- - llvm
- - host
-is-test: true
-dts-overlays:
- - overlay.dts
diff --git a/zephyr/test/system/CMakeLists.txt b/zephyr/test/system/CMakeLists.txt
deleted file mode 100644
index f91786841e..0000000000
--- a/zephyr/test/system/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2020 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.
-
-cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(system_test)
-
-target_sources(app PRIVATE test_system.c
- ${PLATFORM_EC}/zephyr/shim/src/system.c)
diff --git a/zephyr/test/system/overlay.dts b/zephyr/test/system/overlay.dts
deleted file mode 100644
index 37bac97680..0000000000
--- a/zephyr/test/system/overlay.dts
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/ {
- named-bbram-regions {
- compatible = "named-bbram-regions";
- pd0 {
- offset = <0x00>;
- size = <0x01>;
- };
- pd1 {
- offset = <0x01>;
- size = <0x02>;
- };
- try_slot {
- offset = <0x03>;
- size = <0x04>;
- };
- pd2 {
- offset = <0x07>;
- size = <0x05>;
- };
- scratchpad {
- offset = <0x0c>;
- size = <0x04>;
- };
- saved-reset-flags {
- offset = <0x10>;
- size = <0x04>;
- };
- };
-};
diff --git a/zephyr/test/system/prj.conf b/zephyr/test/system/prj.conf
deleted file mode 100644
index 03357fa10f..0000000000
--- a/zephyr/test/system/prj.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG_ZTEST=y
-CONFIG_PLATFORM_EC=y
-CONFIG_CROS_EC=y
-CONFIG_LOG=y
diff --git a/zephyr/test/system/test_system.c b/zephyr/test/system/test_system.c
deleted file mode 100644
index e8eba44fc8..0000000000
--- a/zephyr/test/system/test_system.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <device.h>
-#include <drivers/bbram.h>
-#include <logging/log.h>
-#include <ztest.h>
-
-#include "bbram.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!@";
-
-static int mock_bbram_read(const struct device *unused, size_t offset,
- size_t size, uint8_t *data)
-{
- if (offset < 0 || offset + size >= ARRAY_SIZE(mock_data))
- return -1;
- memcpy(data, mock_data + offset, size);
- return EC_SUCCESS;
-}
-
-static const struct bbram_driver_api bbram_api = {
- .read = mock_bbram_read,
-};
-
-static const struct device bbram_dev_instance = {
- .name = "TEST_BBRAM_DEV",
- .config = NULL,
- .api = &bbram_api,
- .data = NULL,
-};
-
-const struct device *bbram_dev = &bbram_dev_instance;
-
-static void test_bbram_get(void)
-{
- uint8_t output[10];
- int rc;
-
- rc = system_get_bbram(SYSTEM_BBRAM_IDX_PD0, output);
- zassert_equal(rc, 0, NULL);
- 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_equal(rc, 0, NULL);
- 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_equal(rc, 0, NULL);
- 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_equal(rc, 0, NULL);
- zassert_mem_equal(output, mock_data + BBRAM_REGION_OFF(try_slot),
- BBRAM_REGION_SIZE(try_slot), NULL);
-}
-
-void test_main(void)
-{
- ztest_test_suite(system, ztest_unit_test(test_bbram_get));
- ztest_run_test_suite(system);
-}
diff --git a/zephyr/test/system/zmake.yaml b/zephyr/test/system/zmake.yaml
deleted file mode 100644
index c3fca2272e..0000000000
--- a/zephyr/test/system/zmake.yaml
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: native_posix
-supported-zephyr-versions:
- - v2.6
-output-type: elf
-supported-toolchains:
- - llvm
- - host
-is-test: true
-dts-overlays:
- - overlay.dts
diff --git a/zephyr/test/tasks/CMakeLists.txt b/zephyr/test/tasks/CMakeLists.txt
deleted file mode 100644
index f5ea76e67e..0000000000
--- a/zephyr/test/tasks/CMakeLists.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2020 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.
-
-cmake_minimum_required(VERSION 3.13.1)
-find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(tasks)
-
-# Include the local test directory for shimmed_test_tasks.h
-zephyr_include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
-
-target_sources(app PRIVATE
- main.c
- "${CMAKE_CURRENT_SOURCE_DIR}/../../shim/src/tasks.c") \ No newline at end of file
diff --git a/zephyr/test/tasks/main.c b/zephyr/test/tasks/main.c
deleted file mode 100644
index 91216b9518..0000000000
--- a/zephyr/test/tasks/main.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/* Copyright 2020 The Chromium OS Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <kernel.h>
-#include <stdbool.h>
-#include <ztest.h>
-
-#include "ec_tasks.h"
-#include "task.h"
-#include "timer.h"
-
-/* Second for platform/ec task API (in microseconds). */
-#define TASK_SEC(s) (s * 1000 * 1000)
-
-K_SEM_DEFINE(task_done1, 0, 1);
-K_SEM_DEFINE(task_done2, 0, 1);
-K_SEM_DEFINE(test_ready1, 0, 1);
-K_SEM_DEFINE(test_ready2, 0, 1);
-
-static void (*task1)(void);
-static void (*task2)(void);
-
-static void run_test(void (*task1_run)(void), void (*task2_run)(void))
-{
- task1 = task1_run;
- task2 = task2_run;
- k_sem_give(&test_ready1);
- k_sem_give(&test_ready2);
- k_sem_take(&task_done1, K_FOREVER);
- k_sem_take(&task_done2, K_FOREVER);
-}
-
-void task1_entry(void *p)
-{
- while (1) {
- k_sem_take(&test_ready1, K_FOREVER);
- task1();
- k_sem_give(&task_done1);
- }
-}
-
-void task2_entry(void *p)
-{
- while (1) {
- k_sem_take(&test_ready2, K_FOREVER);
- task2();
- k_sem_give(&task_done2);
- }
-}
-
-/*
- * Unlike Tasks 1 & 2, it is allowed to run Task 3 more than once per
- * call to run_test(). It will call task3_entry_func if set, and wait
- * for the next event. This is useful to test things like timers,
- * which you are expecting the event to fire at some point in the
- * future, and you want to test that it happens.
- */
-static void (*task3_entry_func)(uint32_t event_mask);
-
-void task3_entry(void *p)
-{
- uint32_t events = 0;
-
- for (;;) {
- if (task3_entry_func)
- task3_entry_func(events);
- events = task_wait_event(-1);
- }
-}
-
-static void set_event_before_task_start1(void)
-{
- const uint32_t events = task_wait_event(TASK_SEC(2));
-
- zassert_equal(events, 0xAAAA, "Should have 0xAAAA events");
-}
-
-static void set_event_before_task_start2(void)
-{
- /* Do nothing */
-}
-
-static void test_set_event_before_task_start(void)
-{
- /* Send event before tasks start */
- task_set_event(TASK_ID_TASK_1, 0xAAAA);
-
- start_ec_tasks();
-
- run_test(set_event_before_task_start1, set_event_before_task_start2);
-}
-
-static void task_get_current1(void)
-{
- zassert_equal(task_get_current(), TASK_ID_TASK_1, "ID matches");
-}
-
-static void task_get_current2(void)
-{
- zassert_equal(task_get_current(), TASK_ID_TASK_2, "ID matches");
-}
-
-static void test_task_get_current(void)
-{
- run_test(&task_get_current1, &task_get_current2);
-}
-
-
-static void timeout1(void)
-{
- const uint32_t start_ms = k_uptime_get();
- const uint32_t events = task_wait_event(TASK_SEC(2));
- const uint32_t end_ms = k_uptime_get();
-
- zassert_equal(events, TASK_EVENT_TIMER, "Should have timeout event");
- zassert_within(end_ms - start_ms, 2000, 100, "Timeout for 2 seconds");
-}
-
-static void timeout2(void)
-{
- /* Do nothing */
-}
-
-static void test_timeout(void)
-{
- run_test(&timeout1, &timeout2);
-}
-
-/*
- * Timer test:
- * 1. Task 1 arms a timer for Task 3 in expiring 2 seconds.
- * 2. Task 2 does nothing.
- * 3. Task 3 validates that the it receives a TASK_EVENT_TIMER event
- * 2 seconds after Task 1 armed the timer (within 100ms
- * tolerance).
- */
-static timestamp_t timer_armed_at;
-K_SEM_DEFINE(check_timer_finished, 0, 1);
-
-static void check_timer(uint32_t event_mask)
-{
- timestamp_t now = get_time();
-
- zassert_equal(event_mask & TASK_EVENT_TIMER, TASK_EVENT_TIMER,
- "Timer event mask should be set");
- zassert_within(now.val - timer_armed_at.val, TASK_SEC(2),
- TASK_SEC(1) / 10,
- "Timer should expire at 2 seconds from arm time");
- k_sem_give(&check_timer_finished);
-}
-
-static void timer_task_1(void)
-{
- timestamp_t timer_timeout;
-
- timer_armed_at = get_time();
-
- timer_timeout.val = timer_armed_at.val + TASK_SEC(2);
-
- task3_entry_func = check_timer;
- zassert_equal(timer_arm(timer_timeout, TASK_ID_TASK_3), EC_SUCCESS,
- "Setting timer should succeed");
-}
-
-static void timer_task_2(void)
-{
- /* Do nothing */
-}
-
-static void test_timer(void)
-{
- run_test(timer_task_1, timer_task_2);
- zassert_equal(k_sem_take(&check_timer_finished, K_SECONDS(4 * 1000)), 0,
- "Task 3 did not finish within timeout");
- zassert_equal(task3_entry_func, check_timer,
- "check_timer should have been enabled");
- task3_entry_func = NULL;
-}
-
-static void event_delivered1(void)
-{
- const uint32_t start_ms = k_uptime_get();
- const uint32_t events = task_wait_event(-1);
- const uint32_t end_ms = k_uptime_get();
-
- zassert_equal(events, 0x1234, "Verify event bits");
- zassert_within(end_ms - start_ms, 5000, 100, "Waited for 5 seconds");
-}
-
-static void event_delivered2(void)
-{
- k_sleep(K_SECONDS(5));
-
- task_set_event(TASK_ID_TASK_1, 0x1234);
-}
-
-static void test_event_delivered(void)
-{
- run_test(&event_delivered1, &event_delivered2);
-}
-
-
-static void event_mask_not_delivered1(void)
-{
- task_set_event(TASK_ID_TASK_2, 0x007F);
-}
-
-static void event_mask_not_delivered2(void)
-{
- const uint32_t start_ms = k_uptime_get();
- const uint32_t events = task_wait_event_mask(0x0080, TASK_SEC(7));
- const uint32_t end_ms = k_uptime_get();
-
- zassert_equal(events, TASK_EVENT_TIMER, "Should have timeout event");
- zassert_within(end_ms - start_ms, 7000, 100, "Timeout for 7 seconds");
-
- const uint32_t leftover_events = task_wait_event(0);
-
- zassert_equal(leftover_events, 0x007F, "All events should be waiting");
-}
-
-static void test_event_mask_not_delivered(void)
-{
- run_test(&event_mask_not_delivered1, &event_mask_not_delivered2);
-}
-
-
-static void event_mask_extra1(void)
-{
- k_sleep(K_SECONDS(1));
-
- task_set_event(TASK_ID_TASK_2, 0x00FF);
-}
-
-static void event_mask_extra2(void)
-{
- const uint32_t start_ms = k_uptime_get();
- const uint32_t events = task_wait_event_mask(0x0001, TASK_SEC(10));
- const uint32_t end_ms = k_uptime_get();
-
- zassert_equal(events, 0x0001, "Verify only waited for event");
- zassert_within(end_ms - start_ms, 1000, 100, "Timeout for 1 second");
-
- const uint32_t leftover_events = task_wait_event(0);
-
- zassert_equal(leftover_events, 0x00FE, "All events should be waiting");
-}
-
-static void test_event_mask_extra(void)
-{
- run_test(&event_mask_extra1, &event_mask_extra2);
-}
-
-
-static void empty_set_mask1(void)
-{
- k_sleep(K_SECONDS(1));
- /*
- * It is generally invalid to set a 0 event, but this simulates a race
- * condition and exercises fallback code in task_wait_event
- */
- task_set_event(TASK_ID_TASK_2, 0);
- k_sleep(K_SECONDS(1));
- task_set_event(TASK_ID_TASK_2, 0x1234);
-}
-
-static void empty_set_mask2(void)
-{
- const uint32_t start_ms = k_uptime_get();
- const uint32_t events = task_wait_event_mask(0x1234, TASK_SEC(10));
- const uint32_t end_ms = k_uptime_get();
-
- zassert_equal(events, 0x1234, "Verify only waited for event");
- zassert_within(end_ms - start_ms, 2000, 100, "Timeout for 2 seconds");
-}
-
-static void test_empty_set_mask(void)
-{
- run_test(&empty_set_mask1, &empty_set_mask2);
-}
-
-
-void test_main(void)
-{
- /* Note that test_set_event_before_task_start calls start_ec_tasks */
- ztest_test_suite(test_task_shim,
- ztest_unit_test(test_set_event_before_task_start),
- ztest_unit_test(test_task_get_current),
- ztest_unit_test(test_timeout),
- ztest_unit_test(test_timer),
- ztest_unit_test(test_event_delivered),
- ztest_unit_test(test_event_mask_not_delivered),
- ztest_unit_test(test_event_mask_extra),
- ztest_unit_test(test_empty_set_mask));
- ztest_run_test_suite(test_task_shim);
-}
diff --git a/zephyr/test/tasks/prj.conf b/zephyr/test/tasks/prj.conf
deleted file mode 100644
index f5ddf014a7..0000000000
--- a/zephyr/test/tasks/prj.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_ZTEST=y
-CONFIG_HAS_TEST_TASKS=y
-CONFIG_PLATFORM_EC=y
-CONFIG_CROS_EC=y
-CONFIG_HAS_TASK_HOOKS=n
diff --git a/zephyr/test/tasks/shimmed_test_tasks.h b/zephyr/test/tasks/shimmed_test_tasks.h
deleted file mode 100644
index b7d72b59d5..0000000000
--- a/zephyr/test/tasks/shimmed_test_tasks.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* Copyright 2020 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.
- */
-
-#ifndef __CROS_EC_SHIMMED_TEST_TASKS_H
-#define __CROS_EC_SHIMMED_TEST_TASKS_H
-
-/*
- * Manually define these HAS_TASK_* defines. There is a build time assert
- * to at least verify we have the minimum set defined correctly. */
-#define HAS_TASK_TASK_1 1
-#define HAS_TASK_TASK_2 1
-#define HAS_TASK_TASK_3 1
-
-/* Highest priority on bottom same as in platform/ec */
-#define CROS_EC_TASK_LIST \
- CROS_EC_TASK(TASK_1, task1_entry, 0, 512) \
- CROS_EC_TASK(TASK_2, task2_entry, 0, 512) \
- CROS_EC_TASK(TASK_3, task3_entry, 0, 512)
-
-#endif /* __CROS_EC_SHIMMED_TEST_TASKS_H */
diff --git a/zephyr/test/tasks/zmake.yaml b/zephyr/test/tasks/zmake.yaml
deleted file mode 100644
index 6aa10c2661..0000000000
--- a/zephyr/test/tasks/zmake.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2020 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-board: native_posix
-supported-zephyr-versions:
- - v2.6
-supported-toolchains:
- - llvm
- - host
-output-type: elf
-is-test: true
diff --git a/zephyr/zmake/.flake8 b/zephyr/zmake/.flake8
deleted file mode 100644
index 0a0a9c29ab..0000000000
--- a/zephyr/zmake/.flake8
+++ /dev/null
@@ -1,9 +0,0 @@
-[flake8]
-max-line-length = 88
-extend-ignore = E203
-exclude =
- .hypothesis,
- .pytest_cache,
- __pycache__,
- build,
- dist
diff --git a/zephyr/zmake/.isort.cfg b/zephyr/zmake/.isort.cfg
deleted file mode 100644
index b9fb3f3e8c..0000000000
--- a/zephyr/zmake/.isort.cfg
+++ /dev/null
@@ -1,2 +0,0 @@
-[settings]
-profile=black
diff --git a/zephyr/zmake/run_tests.sh b/zephyr/zmake/run_tests.sh
deleted file mode 100755
index 60e93cdf1a..0000000000
--- a/zephyr/zmake/run_tests.sh
+++ /dev/null
@@ -1,35 +0,0 @@
-#!/bin/bash
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-# Run tests for zmake itself (not including Zephyr builds).
-
-# Show commands being run.
-set -x
-
-# Exit if any command exits non-zero.
-set -e
-
-# cd to the directory containing this script.
-cd "$(dirname "$(realpath -e "${BASH_SOURCE[0]}")")"
-
-# Test the copy in-tree, instead of what setuptools or the ebuild
-# installed.
-export PYTHONPATH="${PWD}"
-
-# Run pytest.
-# TODO(jrosenth): --hypothesis-profile=cq is very likely to be
-# unnecessary, as this was only needed when we were heavily taxing the
-# CPU by running pytest alongside all the ninjas, which no longer
-# happens. Remove this flag.
-pytest --hypothesis-profile=cq .
-
-# Check import sorting.
-isort --check .
-
-# Check black formatting.
-black --check --diff .
-
-# Check flake8 reports no issues.
-flake8 .
diff --git a/zephyr/zmake/setup.py b/zephyr/zmake/setup.py
deleted file mode 100644
index 4328dc48d7..0000000000
--- a/zephyr/zmake/setup.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2020 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.
-
-import setuptools
-
-setuptools.setup(
- name="zephyr-chrome-utils",
- version="0.1",
- description="CrOS Zephyr Utilities",
- long_description="Utilities used for working on a Zephyr-based EC",
- url="https://chromium.googlesource.com/chromiumos/platform/ec",
- author="Chromium OS Authors",
- author_email="chromiumos-dev@chromium.org",
- license="BSD",
- # What does your project relate to?
- keywords="chromeos",
- # You can just specify the packages manually here if your project is
- # simple. Or you can use find_packages().
- packages=["zmake"],
- python_requires=">=3.6, <4",
- # List run-time dependencies here. These will be installed by pip when
- # your project is installed. For an analysis of "install_requires" vs pip's
- # requirements files see:
- # https://packaging.python.org/en/latest/requirements.html
- install_requires=[
- "jsonschema>=3.2.0",
- "pyyaml>=3.13",
- ],
- # To provide executable scripts, use entry points in preference to the
- # "scripts" keyword. Entry points provide cross-platform support and allow
- # pip to create the appropriate form of executable for the target platform.
- entry_points={
- "console_scripts": [
- "zmake=zmake.__main__:main",
- ],
- },
-)
diff --git a/zephyr/zmake/tests/conftest.py b/zephyr/zmake/tests/conftest.py
deleted file mode 100644
index 4572e23ffe..0000000000
--- a/zephyr/zmake/tests/conftest.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import hypothesis
-
-hypothesis.settings.register_profile(
- "cq", suppress_health_check=hypothesis.HealthCheck.all()
-)
diff --git a/zephyr/zmake/tests/files/sample_err.txt b/zephyr/zmake/tests/files/sample_err.txt
deleted file mode 100644
index d627885a6f..0000000000
--- a/zephyr/zmake/tests/files/sample_err.txt
+++ /dev/null
@@ -1,321 +0,0 @@
-Building /tmp/z/vol:ro: /usr/bin/ninja -C /tmp/z/vol/build-ro
-Running /usr/bin/ninja -C /tmp/z/vol/build-ro
-ninja: Entering directory `/tmp/z/vol/build-ro'
-devicetree error: 'adc' is marked as required in 'properties:' in /home/sjg/c/src/platform/ec/zephyr/dts/bindings/temp/temp-3v3-30k9-47k-4050b.yaml, but does not appear in <Node /named-temp-sensors/ddr_soc in 'volteer.dts.pre.tmp'>
-[1/310] Preparing syscall dependency handling
-[2/310] Generating misc/generated/syscalls_subdirs.trigger
-[3/310] Generating ../../ec/include/generated/ec_version.h
-[4/310] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json
-[5/310] Generating include/generated/syscall_dispatch.c, include/generated/syscall_list.h
-[6/310] Generating include/generated/kobj-types-enum.h, include/generated/otype-to-str.h
-[7/310] Generating include/generated/driver-validation.h
-[8/310] Building C object zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj
-[9/310] Generating include/generated/offsets.h
-[10/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/app/ec/main_shim.c.obj
-[11/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_bbram/cros_bbram_npcx.c.obj
-[12/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/app/ec/ec_app_main.c.obj
-[13/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_flash/cros_flash_npcx.c.obj
-[14/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c.obj
-[15/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_rtc/cros_rtc_npcx.c.obj
-[16/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_system/cros_system_npcx.c.obj
-[17/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/chip/npcx/clock.c.obj
-[18/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/chip/npcx/keyboard_raw.c.obj
-[19/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/crc.c.obj
-[20/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/chip/npcx/system.c.obj
-[21/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/core/cortex-m/software_panic.c.obj
-[22/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/chip/npcx/system_external_storage.c.obj
-[23/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/console.c.obj
-[24/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/util.c.obj
-[25/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/gpio.c.obj
-[26/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/system.c.obj
-[27/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/system.c.obj
-[28/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/adc.c.obj
-[29/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/espi.c.obj
-[30/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/fan.c.obj
-[31/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/flash.c.obj
-[32/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/hooks.c.obj
-[33/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/host_command.c.obj
-[34/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/console_buffer.c.obj
-[35/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/mkbp_event.c.obj
-[36/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/mpu.c.obj
-[37/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/motionsense_sensors.c.obj
-[38/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/panic.c.obj
-[39/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/pwm.c.obj
-[40/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/temp_sensors.c.obj
-[41/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/rtc.c.obj
-[42/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/thermal.c.obj
-[43/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/hwtimer.c.obj
-[44/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/i2c.c.obj
-[45/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/tasks.c.obj
-[46/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/watchdog.c.obj
-[47/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/base32.c.obj
-[48/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/console_output.c.obj
-[49/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/ec_features.c.obj
-[50/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/gpio_commands.c.obj
-[51/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/peripheral.c.obj
-[52/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/printf.c.obj
-[53/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/queue.c.obj
-[54/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/shared_mem.c.obj
-[55/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/uart_printf.c.obj
-[56/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/accel_bma2x2.c.obj
-[57/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/math_util.c.obj
-[58/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/accelgyro_bmi_common.c.obj
-[59/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/accelgyro_bmi260.c.obj
-[60/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/motion_sense_fifo.c.obj
-[61/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/adc.c.obj
-[62/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/als_tcs3400.c.obj
-[63/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/acpi.c.obj
-[64/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/backlight_lid.c.obj
-[65/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/battery.c.obj
-[66/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/battery_fuel_gauge.c.obj
-[67/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/battery/smart.c.obj
-[68/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/bc12/pi3usb9201.c.obj
-[69/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/charger/isl9241.c.obj
-[70/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charger.c.obj
-[71/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_alt_mode_ufp.c.obj
-[72/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charge_manager.c.obj
-[73/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charge_state_v2.c.obj
-[74/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charge_ramp.c.obj
-[75/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charge_ramp_sw.c.obj
-[76/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/cbi.c.obj
-[77/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/memory_commands.c.obj
-[78/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/dptf.c.obj
-[79/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/chipset.c.obj
-[80/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/espi.c.obj
-[81/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/extpower_common.c.obj
-[82/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/extpower_gpio.c.obj
-[83/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/fan.c.obj
-[84/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/flash.c.obj
-[85/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/spi_flash_reg.c.obj
-[86/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/host_command.c.obj
-[87/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/host_event_commands.c.obj
-[88/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/uart_hostcmd.c.obj
-[89/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/uptime.c.obj
-[90/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_scan.c.obj
-[91/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/i2c_controller.c.obj
-[92/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_8042_sharedlib.c.obj
-[93/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_vivaldi.c.obj
-[94/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_backlight.c.obj
-[95/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_8042.c.obj
-[96/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/pwm_kblight.c.obj
-[97/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/led_common.c.obj
-[98/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/led_pwm.c.obj
-[99/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/motion_lid.c.obj
-[100/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/lid_angle.c.obj
-[101/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/lid_switch.c.obj
-[102/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/motion_sense.c.obj
-[103/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/mkbp_event.c.obj
-[104/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/port80.c.obj
-[105/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/power_button.c.obj
-[106/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/power/common.c.obj
-[107/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/power_button_x86.c.obj
-[108/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/power/icelake.c.obj
-[109/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/power/intel_x86.c.obj
-[110/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/power/host_sleep.c.obj
-[111/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/panic_output.c.obj
-[112/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/pwm.c.obj
-[113/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/sha256.c.obj
-[114/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/switch.c.obj
-[115/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/tablet_mode.c.obj
-[116/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/thermal.c.obj
-[117/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/temp_sensor.c.obj
-[118/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/temp_sensor/thermistor.c.obj
-[119/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/throttle_ap.c.obj
-[120/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/timer.c.obj
-[121/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_charger.c.obj
-[122/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_port_power_dumb.c.obj
-[123/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_common.c.obj
-[124/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usbc_task.c.obj
-[125/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pd_timer.c.obj
-[126/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_sm.c.obj
-[127/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc_intr_task.c.obj
-[128/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pd_console.c.obj
-[129/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_retimer_fw_update.c.obj
-[130/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/retimer/bb_retimer.c.obj
-[131/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/usb_mux/usb_mux.c.obj
-[132/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/usb_mux/virtual.c.obj
-[133/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_mode.c.obj
-[134/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/tbt_alt_mode.c.obj
-[135/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc_ocp.c.obj
-[136/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_alt_mode_dfp.c.obj
-[137/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_console_cmd.c.obj
-[138/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_dual_role.c.obj
-[139/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pd_host.c.obj
-[140/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_host_cmd.c.obj
-[141/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_tc_drp_acc_trysrc_sm.c.obj
-[142/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pe_drp_sm.c.obj
-[143/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/dp_alt_mode.c.obj
-[144/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pd_dpm.c.obj
-[145/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/tcpm/ps8xxx.c.obj
-[146/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_prl_sm.c.obj
-[147/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/tcpm/rt1715.c.obj
-[148/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/tcpm/tusb422.c.obj
-[149/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/tcpm/tcpci.c.obj
-[150/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc_ppc.c.obj
-[151/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/ppc/sn5s330.c.obj
-[152/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/ppc/syv682x.c.obj
-[153/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/vboot_hash.c.obj
-[154/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/button.c.obj
-[155/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/vboot/efs2.c.obj
-[156/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/vstore.c.obj
-[157/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/battery_presence.c.obj
-[158/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/charger.c.obj
-[159/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/cbi.c.obj
-[160/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/cbi_ec_fw_config.c.obj
-[161/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/power.c.obj
-[162/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/usb_pd_policy.c.obj
-[163/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/usbc_config.c.obj
-[164/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/battery.c.obj
-[165/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/cbi.c.obj
-[166/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc32_sw.c.obj
-[167/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/keyboard.c.obj
-[168/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/led.c.obj
-[169/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/usbc_config.c.obj
-[170/310] Building C object CMakeFiles/app.dir/src/sensors.c.obj
-[171/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf.c.obj
-[172/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc16_sw.c.obj
-[173/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc8_sw.c.obj
-[174/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc7_sw.c.obj
-[175/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/dec.c.obj
-[176/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/fdtable.c.obj
-[177/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/hex.c.obj
-[178/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/notify.c.obj
-[179/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/printk.c.obj
-[180/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/onoff.c.obj
-[181/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/rb.c.obj
-[182/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/sem.c.obj
-[183/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/timeutil.c.obj
-[184/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/thread_entry.c.obj
-[185/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/work_q.c.obj
-[186/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap.c.obj
-[187/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_nano.c.obj
-[188/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/ring_buffer.c.obj
-[189/310] Building C object zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj
-[190/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap-validate.c.obj
-[191/310] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/nuvoton_npcx/common/scfg.c.obj
-[192/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell.c.obj
-[193/310] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/nuvoton_npcx/npcx7/soc.c.obj
-[194/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_fprintf.c.obj
-[195/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_utils.c.obj
-[196/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_ops.c.obj
-[197/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_uart.c.obj
-[198/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/console/uart_console.c.obj
-[199/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/clock_control/clock_control_npcx.c.obj
-[200/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/watchdog/wdt_npcx.c.obj
-[201/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/timer/sys_clock_init.c.obj
-[202/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/interrupt_controller/intc_miwu.c.obj
-[203/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/timer/npcx_itim_timer.c.obj
-[204/310] Building C object zephyr/arch/common/CMakeFiles/arch__common.dir/sw_isr_common.c.obj
-[205/310] Building C object zephyr/arch/common/CMakeFiles/isr_tables.dir/isr_tables.c.obj
-[206/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/swap.c.obj
-[207/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/swap_helper.S.obj
-[208/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/cpu_idle.S.obj
-[209/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/irq_manage.c.obj
-[210/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/thread.c.obj
-[211/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/fatal.c.obj
-[212/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/nmi_on_reset.S.obj
-[213/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/nmi.c.obj
-[214/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/prep_c.c.obj
-[215/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/vector_table.S.obj
-[216/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/isr_wrapper.S.obj
-[217/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/reset.S.obj
-[218/310] Linking C static library zephyr/arch/common/libisr_tables.a
-[219/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/fault_s.S.obj
-[220/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/fault.c.obj
-[221/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/exc_exit.S.obj
-[222/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/version.c.obj
-[223/310] Generating linker.cmd
-[224/310] Linking C static library zephyr/libzephyr.a
-[225/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/scb.c.obj
-[226/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/irq_init.c.obj
-[227/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/thread_abort.c.obj
-[228/310] Linking C static library zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a
-[229/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/mpu/CMakeFiles/arch__arm__core__aarch32__cortex_m__mpu.dir/arm_core_mpu.c.obj
-[230/310] Building C object zephyr/CMakeFiles/zephyr_prebuilt.dir/misc/empty_file.c.obj
-[231/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/atoi.c.obj
-[232/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/mpu/CMakeFiles/arch__arm__core__aarch32__cortex_m__mpu.dir/arm_mpu.c.obj
-[233/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/abort.c.obj
-[234/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/strtol.c.obj
-[235/310] Linking C static library zephyr/arch/common/libarch__common.a
-[236/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/strtoul.c.obj
-[237/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/bsearch.c.obj
-[238/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strncasecmp.c.obj
-[239/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/string.c.obj
-[240/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/malloc.c.obj
-[241/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/exit.c.obj
-[242/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strstr.c.obj
-[243/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strspn.c.obj
-[244/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/stdout_console.c.obj
-[245/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/sprintf.c.obj
-[246/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/fprintf.c.obj
-[247/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/time/gmtime.c.obj
-[248/310] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/pthread_common.c.obj
-[249/310] Building C object zephyr/soc/arm/common/cortex_m/CMakeFiles/soc__arm__common__cortex_m.dir/arm_mpu_regions.c.obj
-[250/310] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/nanosleep.c.obj
-[251/310] Building C object zephyr/drivers/adc/CMakeFiles/drivers__adc.dir/adc_common.c.obj
-[252/310] Linking C static library zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a
-[253/310] Linking C static library zephyr/arch/arch/arm/core/aarch32/cortex_m/mpu/libarch__arm__core__aarch32__cortex_m__mpu.a
-[254/310] Building C object zephyr/drivers/adc/CMakeFiles/drivers__adc.dir/adc_npcx.c.obj
-[255/310] Building C object zephyr/drivers/gpio/CMakeFiles/drivers__gpio.dir/gpio_npcx.c.obj
-[256/310] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_common.c.obj
-[257/310] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_shell.c.obj
-[258/310] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_npcx_controller.c.obj
-[259/310] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_npcx_port.c.obj
-[260/310] Linking C static library zephyr/lib/posix/liblib__posix.a
-[261/310] Building C object zephyr/drivers/pwm/CMakeFiles/drivers__pwm.dir/pwm_npcx.c.obj
-[262/310] Linking C static library zephyr/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a
-[263/310] Building C object zephyr/drivers/sensor/nuvoton_tach_npcx/CMakeFiles/drivers__sensor__nuvoton_tach_npcx.dir/tach_nuvoton_npcx.c.obj
-[264/310] Building C object zephyr/drivers/espi/CMakeFiles/drivers__espi.dir/espi_npcx.c.obj
-[265/310] Linking C static library zephyr/lib/libc/minimal/liblib__libc__minimal.a
-[266/310] Building C object zephyr/drivers/espi/CMakeFiles/drivers__espi.dir/host_subs_npcx.c.obj
-[267/310] Building C object zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/uart_npcx.c.obj
-[268/310] Linking C static library zephyr/drivers/adc/libdrivers__adc.a
-[269/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/device.c.obj
-[270/310] Linking C static library zephyr/drivers/gpio/libdrivers__gpio.a
-[271/310] Linking C static library zephyr/drivers/i2c/libdrivers__i2c.a
-[272/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/errno.c.obj
-[273/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/fatal.c.obj
-[274/310] Linking C static library zephyr/drivers/pwm/libdrivers__pwm.a
-[275/310] Linking C static library zephyr/drivers/sensor/nuvoton_tach_npcx/libdrivers__sensor__nuvoton_tach_npcx.a
-[276/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/idle.c.obj
-[277/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/kheap.c.obj
-[278/310] Linking C static library app/libapp.a
-[279/310] Linking C static library zephyr/drivers/serial/libdrivers__serial.a
-[280/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/init.c.obj
-[281/310] Linking C static library zephyr/drivers/espi/libdrivers__espi.a
-[282/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mailbox.c.obj
-[283/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mem_slab.c.obj
-[284/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/msg_q.c.obj
-[285/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mutex.c.obj
-[286/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/pipes.c.obj
-[287/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/queue.c.obj
-[288/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/sched.c.obj
-[289/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/sem.c.obj
-[290/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/stack.c.obj
-[291/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/system_work_q.c.obj
-[292/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/thread.c.obj
-[293/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/thread_abort.c.obj
-[294/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/version.c.obj
-[295/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/work_q.c.obj
-[296/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/condvar.c.obj
-[297/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/smp.c.obj
-[298/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/banner.c.obj
-[299/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/xip.c.obj
-[300/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/timeout.c.obj
-[301/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mempool.c.obj
-[302/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/timer.c.obj
-[303/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/poll.c.obj
-[304/310] Linking C static library zephyr/kernel/libkernel.a
-[305/310] Linking C executable zephyr/zephyr_prebuilt.elf
-[306/310] Generating linker_pass_final.cmd
-[307/310] Generating isr_tables.c
-[308/310] Building C object zephyr/CMakeFiles/zephyr_final.dir/misc/empty_file.c.obj
-[309/310] Building C object zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj
-[310/310] Linking C executable zephyr/zephyr.elf
-Memory region Used Size Region Size %age Used
-FLASH: 241868 B 512 KB 46.13%
-SRAM: 48632 B 62 KB 76.60%
-IDT_LIST: 0 GB 2 KB 0.00%
-******************************
-*** SUCCESS ***
-******************************
diff --git a/zephyr/zmake/tests/files/sample_ro.txt b/zephyr/zmake/tests/files/sample_ro.txt
deleted file mode 100644
index 0042b5f724..0000000000
--- a/zephyr/zmake/tests/files/sample_ro.txt
+++ /dev/null
@@ -1,318 +0,0 @@
-ninja: Entering directory `/tmp/z/vol/build-ro'
-[1/310] Preparing syscall dependency handling
-[2/310] Generating misc/generated/syscalls_subdirs.trigger
-[3/310] Generating ../../ec/include/generated/ec_version.h
-[4/310] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json
-[5/310] Generating include/generated/syscall_dispatch.c, include/generated/syscall_list.h
-[6/310] Generating include/generated/kobj-types-enum.h, include/generated/otype-to-str.h
-[7/310] Generating include/generated/driver-validation.h
-[8/310] Building C object zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj
-[9/310] Generating include/generated/offsets.h
-[10/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/app/ec/main_shim.c.obj
-[11/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_bbram/cros_bbram_npcx.c.obj
-[12/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/app/ec/ec_app_main.c.obj
-[13/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_flash/cros_flash_npcx.c.obj
-[14/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c.obj
-[15/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_rtc/cros_rtc_npcx.c.obj
-[16/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_system/cros_system_npcx.c.obj
-[17/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/chip/npcx/clock.c.obj
-[18/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/chip/npcx/keyboard_raw.c.obj
-[19/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/crc.c.obj
-[20/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/chip/npcx/system.c.obj
-[21/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/core/cortex-m/software_panic.c.obj
-[22/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/chip/npcx/system_external_storage.c.obj
-[23/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/console.c.obj
-[24/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/util.c.obj
-[25/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/gpio.c.obj
-[26/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/system.c.obj
-[27/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/system.c.obj
-[28/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/adc.c.obj
-[29/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/espi.c.obj
-[30/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/fan.c.obj
-[31/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/flash.c.obj
-[32/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/hooks.c.obj
-[33/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/host_command.c.obj
-[34/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/console_buffer.c.obj
-[35/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/mkbp_event.c.obj
-[36/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/mpu.c.obj
-[37/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/motionsense_sensors.c.obj
-[38/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/panic.c.obj
-[39/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/pwm.c.obj
-[40/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/temp_sensors.c.obj
-[41/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/rtc.c.obj
-[42/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/thermal.c.obj
-[43/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/hwtimer.c.obj
-[44/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/i2c.c.obj
-[45/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/tasks.c.obj
-[46/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/watchdog.c.obj
-[47/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/base32.c.obj
-[48/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/console_output.c.obj
-[49/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/ec_features.c.obj
-[50/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/gpio_commands.c.obj
-[51/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/peripheral.c.obj
-[52/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/printf.c.obj
-[53/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/queue.c.obj
-[54/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/shared_mem.c.obj
-[55/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/uart_printf.c.obj
-[56/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/accel_bma2x2.c.obj
-[57/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/math_util.c.obj
-[58/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/accelgyro_bmi_common.c.obj
-[59/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/accelgyro_bmi260.c.obj
-[60/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/motion_sense_fifo.c.obj
-[61/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/adc.c.obj
-[62/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/als_tcs3400.c.obj
-[63/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/acpi.c.obj
-[64/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/backlight_lid.c.obj
-[65/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/battery.c.obj
-[66/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/battery_fuel_gauge.c.obj
-[67/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/battery/smart.c.obj
-[68/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/bc12/pi3usb9201.c.obj
-[69/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/charger/isl9241.c.obj
-[70/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charger.c.obj
-[71/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_alt_mode_ufp.c.obj
-[72/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charge_manager.c.obj
-[73/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charge_state_v2.c.obj
-[74/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charge_ramp.c.obj
-[75/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charge_ramp_sw.c.obj
-[76/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/cbi.c.obj
-[77/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/memory_commands.c.obj
-[78/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/dptf.c.obj
-[79/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/chipset.c.obj
-[80/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/espi.c.obj
-[81/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/extpower_common.c.obj
-[82/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/extpower_gpio.c.obj
-[83/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/fan.c.obj
-[84/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/flash.c.obj
-[85/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/spi_flash_reg.c.obj
-[86/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/host_command.c.obj
-[87/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/host_event_commands.c.obj
-[88/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/uart_hostcmd.c.obj
-[89/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/uptime.c.obj
-[90/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_scan.c.obj
-[91/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/i2c_controller.c.obj
-[92/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_8042_sharedlib.c.obj
-[93/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_vivaldi.c.obj
-[94/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_backlight.c.obj
-[95/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_8042.c.obj
-[96/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/pwm_kblight.c.obj
-[97/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/led_common.c.obj
-[98/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/led_pwm.c.obj
-[99/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/motion_lid.c.obj
-[100/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/lid_angle.c.obj
-[101/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/lid_switch.c.obj
-[102/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/motion_sense.c.obj
-[103/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/mkbp_event.c.obj
-[104/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/port80.c.obj
-[105/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/power_button.c.obj
-[106/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/power/common.c.obj
-[107/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/power_button_x86.c.obj
-[108/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/power/icelake.c.obj
-[109/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/power/intel_x86.c.obj
-[110/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/power/host_sleep.c.obj
-[111/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/panic_output.c.obj
-[112/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/pwm.c.obj
-[113/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/sha256.c.obj
-[114/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/switch.c.obj
-[115/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/tablet_mode.c.obj
-[116/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/thermal.c.obj
-[117/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/temp_sensor.c.obj
-[118/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/temp_sensor/thermistor.c.obj
-[119/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/throttle_ap.c.obj
-[120/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/timer.c.obj
-[121/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_charger.c.obj
-[122/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_port_power_dumb.c.obj
-[123/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_common.c.obj
-[124/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usbc_task.c.obj
-[125/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pd_timer.c.obj
-[126/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_sm.c.obj
-[127/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc_intr_task.c.obj
-[128/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pd_console.c.obj
-[129/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_retimer_fw_update.c.obj
-[130/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/retimer/bb_retimer.c.obj
-[131/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/usb_mux/usb_mux.c.obj
-[132/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/usb_mux/virtual.c.obj
-[133/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_mode.c.obj
-[134/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/tbt_alt_mode.c.obj
-[135/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc_ocp.c.obj
-[136/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_alt_mode_dfp.c.obj
-[137/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_console_cmd.c.obj
-[138/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_dual_role.c.obj
-[139/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pd_host.c.obj
-[140/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_host_cmd.c.obj
-[141/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_tc_drp_acc_trysrc_sm.c.obj
-[142/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pe_drp_sm.c.obj
-[143/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/dp_alt_mode.c.obj
-[144/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pd_dpm.c.obj
-[145/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/tcpm/ps8xxx.c.obj
-[146/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_prl_sm.c.obj
-[147/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/tcpm/rt1715.c.obj
-[148/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/tcpm/tusb422.c.obj
-[149/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/tcpm/tcpci.c.obj
-[150/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc_ppc.c.obj
-[151/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/ppc/sn5s330.c.obj
-[152/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/ppc/syv682x.c.obj
-[153/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/vboot_hash.c.obj
-[154/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/button.c.obj
-[155/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/vboot/efs2.c.obj
-[156/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/vstore.c.obj
-[157/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/battery_presence.c.obj
-[158/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/charger.c.obj
-[159/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/cbi.c.obj
-[160/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/cbi_ec_fw_config.c.obj
-[161/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/power.c.obj
-[162/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/usb_pd_policy.c.obj
-[163/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/usbc_config.c.obj
-[164/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/battery.c.obj
-[165/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/cbi.c.obj
-[166/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc32_sw.c.obj
-[167/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/keyboard.c.obj
-[168/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/led.c.obj
-[169/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/usbc_config.c.obj
-[170/310] Building C object CMakeFiles/app.dir/src/sensors.c.obj
-[171/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf.c.obj
-[172/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc16_sw.c.obj
-[173/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc8_sw.c.obj
-[174/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc7_sw.c.obj
-[175/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/dec.c.obj
-[176/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/fdtable.c.obj
-[177/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/hex.c.obj
-[178/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/notify.c.obj
-[179/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/printk.c.obj
-[180/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/onoff.c.obj
-[181/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/rb.c.obj
-[182/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/sem.c.obj
-[183/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/timeutil.c.obj
-[184/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/thread_entry.c.obj
-[185/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/work_q.c.obj
-[186/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap.c.obj
-[187/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_nano.c.obj
-[188/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/ring_buffer.c.obj
-[189/310] Building C object zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj
-[190/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap-validate.c.obj
-[191/310] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/nuvoton_npcx/common/scfg.c.obj
-[192/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell.c.obj
-[193/310] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/nuvoton_npcx/npcx7/soc.c.obj
-[194/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_fprintf.c.obj
-[195/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_utils.c.obj
-[196/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_ops.c.obj
-[197/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_uart.c.obj
-[198/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/console/uart_console.c.obj
-[199/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/clock_control/clock_control_npcx.c.obj
-[200/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/watchdog/wdt_npcx.c.obj
-[201/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/timer/sys_clock_init.c.obj
-[202/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/interrupt_controller/intc_miwu.c.obj
-[203/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/timer/npcx_itim_timer.c.obj
-[204/310] Building C object zephyr/arch/common/CMakeFiles/arch__common.dir/sw_isr_common.c.obj
-[205/310] Building C object zephyr/arch/common/CMakeFiles/isr_tables.dir/isr_tables.c.obj
-[206/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/swap.c.obj
-[207/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/swap_helper.S.obj
-[208/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/cpu_idle.S.obj
-[209/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/irq_manage.c.obj
-[210/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/thread.c.obj
-[211/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/fatal.c.obj
-[212/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/nmi_on_reset.S.obj
-[213/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/nmi.c.obj
-[214/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/prep_c.c.obj
-[215/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/vector_table.S.obj
-[216/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/isr_wrapper.S.obj
-[217/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/reset.S.obj
-[218/310] Linking C static library zephyr/arch/common/libisr_tables.a
-[219/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/fault_s.S.obj
-[220/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/fault.c.obj
-[221/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/exc_exit.S.obj
-[222/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/version.c.obj
-[223/310] Generating linker.cmd
-[224/310] Linking C static library zephyr/libzephyr.a
-[225/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/scb.c.obj
-[226/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/irq_init.c.obj
-[227/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/thread_abort.c.obj
-[228/310] Linking C static library zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a
-[229/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/mpu/CMakeFiles/arch__arm__core__aarch32__cortex_m__mpu.dir/arm_core_mpu.c.obj
-[230/310] Building C object zephyr/CMakeFiles/zephyr_prebuilt.dir/misc/empty_file.c.obj
-[231/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/atoi.c.obj
-[232/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/mpu/CMakeFiles/arch__arm__core__aarch32__cortex_m__mpu.dir/arm_mpu.c.obj
-[233/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/abort.c.obj
-[234/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/strtol.c.obj
-[235/310] Linking C static library zephyr/arch/common/libarch__common.a
-[236/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/strtoul.c.obj
-[237/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/bsearch.c.obj
-[238/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strncasecmp.c.obj
-[239/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/string.c.obj
-[240/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/malloc.c.obj
-[241/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/exit.c.obj
-[242/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strstr.c.obj
-[243/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strspn.c.obj
-[244/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/stdout_console.c.obj
-[245/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/sprintf.c.obj
-[246/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/fprintf.c.obj
-[247/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/time/gmtime.c.obj
-[248/310] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/pthread_common.c.obj
-[249/310] Building C object zephyr/soc/arm/common/cortex_m/CMakeFiles/soc__arm__common__cortex_m.dir/arm_mpu_regions.c.obj
-[250/310] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/nanosleep.c.obj
-[251/310] Building C object zephyr/drivers/adc/CMakeFiles/drivers__adc.dir/adc_common.c.obj
-[252/310] Linking C static library zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a
-[253/310] Linking C static library zephyr/arch/arch/arm/core/aarch32/cortex_m/mpu/libarch__arm__core__aarch32__cortex_m__mpu.a
-[254/310] Building C object zephyr/drivers/adc/CMakeFiles/drivers__adc.dir/adc_npcx.c.obj
-[255/310] Building C object zephyr/drivers/gpio/CMakeFiles/drivers__gpio.dir/gpio_npcx.c.obj
-[256/310] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_common.c.obj
-[257/310] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_shell.c.obj
-[258/310] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_npcx_controller.c.obj
-[259/310] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_npcx_port.c.obj
-[260/310] Linking C static library zephyr/lib/posix/liblib__posix.a
-[261/310] Building C object zephyr/drivers/pwm/CMakeFiles/drivers__pwm.dir/pwm_npcx.c.obj
-[262/310] Linking C static library zephyr/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a
-[263/310] Building C object zephyr/drivers/sensor/nuvoton_tach_npcx/CMakeFiles/drivers__sensor__nuvoton_tach_npcx.dir/tach_nuvoton_npcx.c.obj
-[264/310] Building C object zephyr/drivers/espi/CMakeFiles/drivers__espi.dir/espi_npcx.c.obj
-[265/310] Linking C static library zephyr/lib/libc/minimal/liblib__libc__minimal.a
-[266/310] Building C object zephyr/drivers/espi/CMakeFiles/drivers__espi.dir/host_subs_npcx.c.obj
-[267/310] Building C object zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/uart_npcx.c.obj
-[268/310] Linking C static library zephyr/drivers/adc/libdrivers__adc.a
-[269/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/device.c.obj
-[270/310] Linking C static library zephyr/drivers/gpio/libdrivers__gpio.a
-[271/310] Linking C static library zephyr/drivers/i2c/libdrivers__i2c.a
-[272/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/errno.c.obj
-[273/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/fatal.c.obj
-[274/310] Linking C static library zephyr/drivers/pwm/libdrivers__pwm.a
-[275/310] Linking C static library zephyr/drivers/sensor/nuvoton_tach_npcx/libdrivers__sensor__nuvoton_tach_npcx.a
-[276/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/idle.c.obj
-[277/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/kheap.c.obj
-[278/310] Linking C static library app/libapp.a
-[279/310] Linking C static library zephyr/drivers/serial/libdrivers__serial.a
-[280/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/init.c.obj
-[281/310] Linking C static library zephyr/drivers/espi/libdrivers__espi.a
-[282/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mailbox.c.obj
-[283/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mem_slab.c.obj
-[284/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/msg_q.c.obj
-[285/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mutex.c.obj
-[286/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/pipes.c.obj
-[287/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/queue.c.obj
-[288/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/sched.c.obj
-[289/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/sem.c.obj
-[290/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/stack.c.obj
-[291/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/system_work_q.c.obj
-[292/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/thread.c.obj
-[293/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/thread_abort.c.obj
-[294/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/version.c.obj
-[295/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/work_q.c.obj
-[296/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/condvar.c.obj
-[297/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/smp.c.obj
-[298/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/banner.c.obj
-[299/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/xip.c.obj
-[300/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/timeout.c.obj
-[301/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mempool.c.obj
-[302/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/timer.c.obj
-[303/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/poll.c.obj
-[304/310] Linking C static library zephyr/kernel/libkernel.a
-[305/310] Linking C executable zephyr/zephyr_prebuilt.elf
-[306/310] Generating linker_pass_final.cmd
-[307/310] Generating isr_tables.c
-[308/310] Building C object zephyr/CMakeFiles/zephyr_final.dir/misc/empty_file.c.obj
-[309/310] Building C object zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj
-[310/310] Linking C executable zephyr/zephyr.elf
-Memory region Used Size Region Size %age Used
-FLASH: 241868 B 512 KB 46.13%
-SRAM: 48632 B 62 KB 76.60%
-IDT_LIST: 0 GB 2 KB 0.00%
-******************************
-*** SUCCESS ***
-******************************
diff --git a/zephyr/zmake/tests/files/sample_ro_INFO.txt b/zephyr/zmake/tests/files/sample_ro_INFO.txt
deleted file mode 100644
index 0e350873fc..0000000000
--- a/zephyr/zmake/tests/files/sample_ro_INFO.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Memory region Used Size Region Size %age Used
-FLASH: 241868 B 512 KB 46.13%
-SRAM: 48632 B 62 KB 76.60%
-IDT_LIST: 0 GB 2 KB 0.00%
diff --git a/zephyr/zmake/tests/files/sample_rw.txt b/zephyr/zmake/tests/files/sample_rw.txt
deleted file mode 100644
index 38a8c54544..0000000000
--- a/zephyr/zmake/tests/files/sample_rw.txt
+++ /dev/null
@@ -1,315 +0,0 @@
-ninja: Entering directory `/tmp/z/vol/build-rw'
-[1/310] Preparing syscall dependency handling
-[2/310] Generating misc/generated/syscalls_subdirs.trigger
-[3/310] Generating ../../ec/include/generated/ec_version.h
-[4/310] Generating misc/generated/syscalls.json, misc/generated/struct_tags.json
-[5/310] Generating include/generated/syscall_dispatch.c, include/generated/syscall_list.h
-[6/310] Generating include/generated/driver-validation.h
-[7/310] Generating include/generated/kobj-types-enum.h, include/generated/otype-to-str.h
-[8/310] Building C object zephyr/CMakeFiles/offsets.dir/arch/arm/core/offsets/offsets.c.obj
-[9/310] Generating include/generated/offsets.h
-[10/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/app/ec/main_shim.c.obj
-[11/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_bbram/cros_bbram_npcx.c.obj
-[12/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_system/cros_system_npcx.c.obj
-[13/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_flash/cros_flash_npcx.c.obj
-[14/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_kb_raw/cros_kb_raw_npcx.c.obj
-[15/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/drivers/cros_rtc/cros_rtc_npcx.c.obj
-[16/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/app/ec/ec_app_main.c.obj
-[17/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/chip/npcx/clock.c.obj
-[18/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/chip/npcx/keyboard_raw.c.obj
-[19/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/crc.c.obj
-[20/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/chip/npcx/system.c.obj
-[21/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/chip/npcx/system_external_storage.c.obj
-[22/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/core/cortex-m/software_panic.c.obj
-[23/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/gpio.c.obj
-[24/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/console.c.obj
-[25/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/util.c.obj
-[26/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/system.c.obj
-[27/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/system.c.obj
-[28/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/adc.c.obj
-[29/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/espi.c.obj
-[30/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/fan.c.obj
-[31/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/flash.c.obj
-[32/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/hooks.c.obj
-[33/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/host_command.c.obj
-[34/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/console_buffer.c.obj
-[35/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/mkbp_event.c.obj
-[36/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/motionsense_sensors.c.obj
-[37/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/mpu.c.obj
-[38/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/panic.c.obj
-[39/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/pwm.c.obj
-[40/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/rtc.c.obj
-[41/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/temp_sensors.c.obj
-[42/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/thermal.c.obj
-[43/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/hwtimer.c.obj
-[44/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/i2c.c.obj
-[45/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/tasks.c.obj
-[46/310] Building C object CMakeFiles/app.dir/home/sjg/c/src/platform/ec/zephyr/shim/src/watchdog.c.obj
-[47/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/base32.c.obj
-[48/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/console_output.c.obj
-[49/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/ec_features.c.obj
-[50/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/gpio_commands.c.obj
-[51/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/peripheral.c.obj
-[52/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/printf.c.obj
-[53/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/queue.c.obj
-[54/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/shared_mem.c.obj
-[55/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/uart_printf.c.obj
-[56/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/accel_bma2x2.c.obj
-[57/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/math_util.c.obj
-[58/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/accelgyro_bmi_common.c.obj
-[59/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/accelgyro_bmi260.c.obj
-[60/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/motion_sense_fifo.c.obj
-[61/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/adc.c.obj
-[62/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/als_tcs3400.c.obj
-[63/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/acpi.c.obj
-[64/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/backlight_lid.c.obj
-[65/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/battery.c.obj
-[66/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/battery_fuel_gauge.c.obj
-[67/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/battery/smart.c.obj
-[68/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/bc12/pi3usb9201.c.obj
-[69/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/charger/isl9241.c.obj
-[70/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charger.c.obj
-[71/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charge_manager.c.obj
-[72/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_alt_mode_ufp.c.obj
-[73/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charge_state_v2.c.obj
-[74/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charge_ramp.c.obj
-[75/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/charge_ramp_sw.c.obj
-[76/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/cbi.c.obj
-[77/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/memory_commands.c.obj
-[78/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/dptf.c.obj
-[79/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/chipset.c.obj
-[80/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/espi.c.obj
-[81/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/extpower_gpio.c.obj
-[82/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/extpower_common.c.obj
-[83/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/fan.c.obj
-[84/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/spi_flash_reg.c.obj
-[85/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/flash.c.obj
-[86/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/host_command.c.obj
-[87/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/host_event_commands.c.obj
-[88/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/uart_hostcmd.c.obj
-[89/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/uptime.c.obj
-[90/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/i2c_controller.c.obj
-[91/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_scan.c.obj
-[92/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_8042.c.obj
-[93/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_8042_sharedlib.c.obj
-[94/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_vivaldi.c.obj
-[95/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/keyboard_backlight.c.obj
-[96/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/pwm_kblight.c.obj
-[97/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/led_common.c.obj
-[98/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/led_pwm.c.obj
-[99/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/motion_lid.c.obj
-[100/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/lid_angle.c.obj
-[101/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/lid_switch.c.obj
-[102/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/motion_sense.c.obj
-[103/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/mkbp_event.c.obj
-[104/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/port80.c.obj
-[105/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/power_button.c.obj
-[106/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/power/common.c.obj
-[107/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/power/icelake.c.obj
-[108/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/power_button_x86.c.obj
-[109/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/power/intel_x86.c.obj
-[110/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/power/host_sleep.c.obj
-[111/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/sha256.c.obj
-[112/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/panic_output.c.obj
-[113/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/pwm.c.obj
-[114/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/switch.c.obj
-[115/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/tablet_mode.c.obj
-[116/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/thermal.c.obj
-[117/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/temp_sensor.c.obj
-[118/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/temp_sensor/thermistor.c.obj
-[119/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/throttle_ap.c.obj
-[120/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/timer.c.obj
-[121/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_charger.c.obj
-[122/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_port_power_dumb.c.obj
-[123/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_common.c.obj
-[124/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usbc_task.c.obj
-[125/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pd_timer.c.obj
-[126/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_sm.c.obj
-[127/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc_intr_task.c.obj
-[128/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pd_console.c.obj
-[129/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_retimer_fw_update.c.obj
-[130/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/retimer/bb_retimer.c.obj
-[131/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/usb_mux/usb_mux.c.obj
-[132/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/usb_mux/virtual.c.obj
-[133/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/tbt_alt_mode.c.obj
-[134/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_mode.c.obj
-[135/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc_ocp.c.obj
-[136/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_alt_mode_dfp.c.obj
-[137/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_console_cmd.c.obj
-[138/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_dual_role.c.obj
-[139/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usb_pd_host_cmd.c.obj
-[140/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pd_host.c.obj
-[141/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_tc_drp_acc_trysrc_sm.c.obj
-[142/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pe_drp_sm.c.obj
-[143/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/dp_alt_mode.c.obj
-[144/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_pd_dpm.c.obj
-[145/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/tcpm/ps8xxx.c.obj
-[146/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc/usb_prl_sm.c.obj
-[147/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/tcpm/rt1715.c.obj
-[148/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/tcpm/tusb422.c.obj
-[149/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/tcpm/tcpci.c.obj
-[150/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/usbc_ppc.c.obj
-[151/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/ppc/sn5s330.c.obj
-[152/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/driver/ppc/syv682x.c.obj
-[153/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/vboot_hash.c.obj
-[154/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/button.c.obj
-[155/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/vboot/efs2.c.obj
-[156/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/vstore.c.obj
-[157/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/battery_presence.c.obj
-[158/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/charger.c.obj
-[159/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/cbi_ec_fw_config.c.obj
-[160/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/cbi.c.obj
-[161/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/power.c.obj
-[162/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/usb_pd_policy.c.obj
-[163/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/baseboard/volteer/usbc_config.c.obj
-[164/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/battery.c.obj
-[165/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc32_sw.c.obj
-[166/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/cbi.c.obj
-[167/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/keyboard.c.obj
-[168/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/led.c.obj
-[169/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf.c.obj
-[170/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/board/volteer/usbc_config.c.obj
-[171/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc16_sw.c.obj
-[172/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc8_sw.c.obj
-[173/310] Building C object CMakeFiles/app.dir/src/sensors.c.obj
-[174/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/crc7_sw.c.obj
-[175/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/dec.c.obj
-[176/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/fdtable.c.obj
-[177/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/hex.c.obj
-[178/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/notify.c.obj
-[179/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/printk.c.obj
-[180/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/onoff.c.obj
-[181/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/rb.c.obj
-[182/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/sem.c.obj
-[183/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/thread_entry.c.obj
-[184/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/timeutil.c.obj
-[185/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap.c.obj
-[186/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/heap-validate.c.obj
-[187/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/work_q.c.obj
-[188/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/cbprintf_nano.c.obj
-[189/310] Building C object zephyr/CMakeFiles/zephyr.dir/misc/generated/configs.c.obj
-[190/310] Building C object zephyr/CMakeFiles/zephyr.dir/lib/os/ring_buffer.c.obj
-[191/310] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/nuvoton_npcx/common/scfg.c.obj
-[192/310] Building C object zephyr/CMakeFiles/zephyr.dir/soc/arm/nuvoton_npcx/npcx7/soc.c.obj
-[193/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell.c.obj
-[194/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_fprintf.c.obj
-[195/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_utils.c.obj
-[196/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_ops.c.obj
-[197/310] Building C object zephyr/CMakeFiles/zephyr.dir/subsys/shell/shell_uart.c.obj
-[198/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/console/uart_console.c.obj
-[199/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/interrupt_controller/intc_miwu.c.obj
-[200/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/clock_control/clock_control_npcx.c.obj
-[201/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/watchdog/wdt_npcx.c.obj
-[202/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/timer/sys_clock_init.c.obj
-[203/310] Building C object zephyr/CMakeFiles/zephyr.dir/drivers/timer/npcx_itim_timer.c.obj
-[204/310] Building C object zephyr/arch/common/CMakeFiles/arch__common.dir/sw_isr_common.c.obj
-[205/310] Building C object zephyr/arch/common/CMakeFiles/isr_tables.dir/isr_tables.c.obj
-[206/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/swap.c.obj
-[207/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/swap_helper.S.obj
-[208/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/irq_manage.c.obj
-[209/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/thread.c.obj
-[210/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/cpu_idle.S.obj
-[211/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/nmi_on_reset.S.obj
-[212/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/fatal.c.obj
-[213/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/nmi.c.obj
-[214/310] Building C object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/prep_c.c.obj
-[215/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/vector_table.S.obj
-[216/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/CMakeFiles/arch__arm__core__aarch32.dir/isr_wrapper.S.obj
-[217/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/reset.S.obj
-[218/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/fault_s.S.obj
-[219/310] Generating linker.cmd
-[220/310] Linking C static library zephyr/arch/common/libisr_tables.a
-[221/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/fault.c.obj
-[222/310] Building ASM object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/exc_exit.S.obj
-[223/310] Building C object CMakeFiles/app.dir/tmp/z/vol/modules/ec/common/version.c.obj
-[224/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/scb.c.obj
-[225/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/irq_init.c.obj
-[226/310] Building C object zephyr/CMakeFiles/zephyr_prebuilt.dir/misc/empty_file.c.obj
-[227/310] Linking C static library zephyr/libzephyr.a
-[228/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/CMakeFiles/arch__arm__core__aarch32__cortex_m.dir/thread_abort.c.obj
-[229/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/mpu/CMakeFiles/arch__arm__core__aarch32__cortex_m__mpu.dir/arm_core_mpu.c.obj
-[230/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/abort.c.obj
-[231/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/atoi.c.obj
-[232/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/strtol.c.obj
-[233/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/strtoul.c.obj
-[234/310] Linking C static library zephyr/arch/arch/arm/core/aarch32/libarch__arm__core__aarch32.a
-[235/310] Building C object zephyr/arch/arch/arm/core/aarch32/cortex_m/mpu/CMakeFiles/arch__arm__core__aarch32__cortex_m__mpu.dir/arm_mpu.c.obj
-[236/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/bsearch.c.obj
-[237/310] Linking C static library zephyr/arch/common/libarch__common.a
-[238/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/malloc.c.obj
-[239/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdlib/exit.c.obj
-[240/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strncasecmp.c.obj
-[241/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strstr.c.obj
-[242/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/string.c.obj
-[243/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/string/strspn.c.obj
-[244/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/stdout_console.c.obj
-[245/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/sprintf.c.obj
-[246/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/stdout/fprintf.c.obj
-[247/310] Building C object zephyr/lib/libc/minimal/CMakeFiles/lib__libc__minimal.dir/source/time/gmtime.c.obj
-[248/310] Building C object zephyr/soc/arm/common/cortex_m/CMakeFiles/soc__arm__common__cortex_m.dir/arm_mpu_regions.c.obj
-[249/310] Linking C static library zephyr/arch/arch/arm/core/aarch32/cortex_m/libarch__arm__core__aarch32__cortex_m.a
-[250/310] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/pthread_common.c.obj
-[251/310] Building C object zephyr/lib/posix/CMakeFiles/lib__posix.dir/nanosleep.c.obj
-[252/310] Building C object zephyr/drivers/adc/CMakeFiles/drivers__adc.dir/adc_common.c.obj
-[253/310] Building C object zephyr/drivers/adc/CMakeFiles/drivers__adc.dir/adc_npcx.c.obj
-[254/310] Building C object zephyr/drivers/gpio/CMakeFiles/drivers__gpio.dir/gpio_npcx.c.obj
-[255/310] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_common.c.obj
-[256/310] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_shell.c.obj
-[257/310] Linking C static library zephyr/arch/arch/arm/core/aarch32/cortex_m/mpu/libarch__arm__core__aarch32__cortex_m__mpu.a
-[258/310] Linking C static library zephyr/soc/arm/common/cortex_m/libsoc__arm__common__cortex_m.a
-[259/310] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_npcx_controller.c.obj
-[260/310] Linking C static library zephyr/lib/libc/minimal/liblib__libc__minimal.a
-[261/310] Linking C static library zephyr/lib/posix/liblib__posix.a
-[262/310] Linking C static library zephyr/drivers/gpio/libdrivers__gpio.a
-[263/310] Building C object zephyr/drivers/i2c/CMakeFiles/drivers__i2c.dir/i2c_npcx_port.c.obj
-[264/310] Building C object zephyr/drivers/pwm/CMakeFiles/drivers__pwm.dir/pwm_npcx.c.obj
-[265/310] Building C object zephyr/drivers/sensor/nuvoton_tach_npcx/CMakeFiles/drivers__sensor__nuvoton_tach_npcx.dir/tach_nuvoton_npcx.c.obj
-[266/310] Linking C static library zephyr/drivers/adc/libdrivers__adc.a
-[267/310] Building C object zephyr/drivers/espi/CMakeFiles/drivers__espi.dir/espi_npcx.c.obj
-[268/310] Building C object zephyr/drivers/espi/CMakeFiles/drivers__espi.dir/host_subs_npcx.c.obj
-[269/310] Building C object zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/uart_npcx.c.obj
-[270/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/device.c.obj
-[271/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/errno.c.obj
-[272/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/fatal.c.obj
-[273/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/idle.c.obj
-[274/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/init.c.obj
-[275/310] Linking C static library zephyr/drivers/i2c/libdrivers__i2c.a
-[276/310] Linking C static library zephyr/drivers/pwm/libdrivers__pwm.a
-[277/310] Linking C static library zephyr/drivers/sensor/nuvoton_tach_npcx/libdrivers__sensor__nuvoton_tach_npcx.a
-[278/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/kheap.c.obj
-[279/310] Linking C static library app/libapp.a
-[280/310] Linking C static library zephyr/drivers/serial/libdrivers__serial.a
-[281/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mailbox.c.obj
-[282/310] Linking C static library zephyr/drivers/espi/libdrivers__espi.a
-[283/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mem_slab.c.obj
-[284/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mutex.c.obj
-[285/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/msg_q.c.obj
-[286/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/pipes.c.obj
-[287/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/queue.c.obj
-[288/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/sched.c.obj
-[289/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/stack.c.obj
-[290/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/sem.c.obj
-[291/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/system_work_q.c.obj
-[292/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/version.c.obj
-[293/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/thread.c.obj
-[294/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/thread_abort.c.obj
-[295/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/work_q.c.obj
-[296/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/condvar.c.obj
-[297/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/smp.c.obj
-[298/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/banner.c.obj
-[299/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/xip.c.obj
-[300/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/poll.c.obj
-[301/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/timer.c.obj
-[302/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/timeout.c.obj
-[303/310] Building C object zephyr/kernel/CMakeFiles/kernel.dir/mempool.c.obj
-[304/310] Linking C static library zephyr/kernel/libkernel.a
-[305/310] Linking C executable zephyr/zephyr_prebuilt.elf
-[306/310] Generating linker_pass_final.cmd
-[307/310] Generating isr_tables.c
-[308/310] Building C object zephyr/CMakeFiles/zephyr_final.dir/misc/empty_file.c.obj
-[309/310] Building C object zephyr/CMakeFiles/zephyr_final.dir/isr_tables.c.obj
-[310/310] Linking C executable zephyr/zephyr.elf
-Memory region Used Size Region Size %age Used
-FLASH: 241868 B 512 KB 46.13%
-SRAM: 48632 B 62 KB 76.60%
-IDT_LIST: 0 GB 2 KB 0.00%
diff --git a/zephyr/zmake/tests/files/sample_rw_INFO.txt b/zephyr/zmake/tests/files/sample_rw_INFO.txt
deleted file mode 100644
index 0e350873fc..0000000000
--- a/zephyr/zmake/tests/files/sample_rw_INFO.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-Memory region Used Size Region Size %age Used
-FLASH: 241868 B 512 KB 46.13%
-SRAM: 48632 B 62 KB 76.60%
-IDT_LIST: 0 GB 2 KB 0.00%
diff --git a/zephyr/zmake/tests/test_build_config.py b/zephyr/zmake/tests/test_build_config.py
deleted file mode 100644
index bf69b8a1fa..0000000000
--- a/zephyr/zmake/tests/test_build_config.py
+++ /dev/null
@@ -1,202 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import argparse
-import os
-import pathlib
-import string
-import tempfile
-
-import hypothesis
-import hypothesis.strategies as st
-import pytest
-
-import zmake.jobserver
-import zmake.util as util
-from zmake.build_config import BuildConfig
-
-# Strategies for use with hypothesis
-filenames = st.text(
- alphabet=set(string.printable) - {"/", ";"}, min_size=1, max_size=254
-).filter(lambda name: name not in (".", ".."))
-paths = st.builds(
- lambda parts: pathlib.Path("/", *parts), st.iterables(filenames, min_size=1)
-)
-config_keys = st.text(alphabet=set(string.ascii_uppercase) | {"_"}, min_size=1)
-config_values = st.builds(str, st.just("y") | st.just("n") | st.integers())
-config_dicts = st.dictionaries(keys=config_keys, values=config_values)
-config_dicts_at_least_one_entry = st.dictionaries(
- keys=config_keys, values=config_values, min_size=1
-)
-
-build_configs = st.builds(
- BuildConfig,
- environ_defs=config_dicts,
- cmake_defs=config_dicts,
- kconfig_defs=config_dicts,
- kconfig_files=st.lists(paths),
-)
-build_configs_no_kconfig = st.builds(
- BuildConfig, environ_defs=config_dicts, cmake_defs=config_dicts
-)
-build_configs_with_at_least_one_kconfig = st.builds(
- BuildConfig,
- environ_defs=config_dicts,
- cmake_defs=config_dicts,
- kconfig_defs=config_dicts_at_least_one_entry,
-)
-
-
-@hypothesis.given(st.data(), build_configs)
-def test_merge(coins, combined):
- """Test that when splitting a config in half and merging the two
- halves, we get the original config back.
- """
-
- def split(iterable):
- left = []
- right = []
- bools = st.booleans()
- for item in iterable:
- if coins.draw(bools):
- left.append(item)
- else:
- right.append(item)
- return left, right
-
- # Split the original config into two
- env1, env2 = split(combined.environ_defs.items())
- cmake1, cmake2 = split(combined.cmake_defs.items())
- kconf1, kconf2 = split(combined.kconfig_defs.items())
- files1, files2 = split(combined.kconfig_files)
-
- c1 = BuildConfig(
- environ_defs=dict(env1),
- cmake_defs=dict(cmake1),
- kconfig_defs=dict(kconf1),
- kconfig_files=files1,
- )
- c2 = BuildConfig(
- environ_defs=dict(env2),
- cmake_defs=dict(cmake2),
- kconfig_defs=dict(kconf2),
- kconfig_files=files2,
- )
-
- # Merge the split configs
- merged = c1 | c2
-
- # Assert that the merged split configs is the original config
- assert merged.environ_defs == combined.environ_defs
- assert merged.cmake_defs == combined.cmake_defs
- assert merged.kconfig_defs == combined.kconfig_defs
- assert set(merged.kconfig_files) == set(combined.kconfig_files)
-
-
-class FakeJobClient(zmake.jobserver.JobClient):
- """Simple job client to capture argv/environ."""
-
- def __init__(self):
- self.captured_argv = []
- self.captured_env = {}
-
- def get_job(self):
- return zmake.jobserver.JobHandle(lambda: None)
-
- def popen(self, argv, env={}, **kwargs):
- self.captured_argv = [str(arg) for arg in argv]
- self.captured_env = {str(k): str(v) for k, v in env.items()}
-
-
-def parse_cmake_args(argv):
- """Parse command line arguments like cmake does.
-
- This is an intenionally minimal implementation, which only
- understands the subset of arguments actually used by zmake.
-
- Args:
- argv: The argument list.
-
- Returns:
- A 2-tuple of a namespace from argparse and the corresponding
- parsed Cmake definitions.
- """
- assert argv[0] == "/usr/bin/cmake"
-
- parser = argparse.ArgumentParser(add_help=False)
- parser.add_argument("-S", dest="source_dir", type=pathlib.Path)
- parser.add_argument("-B", dest="build_dir", type=pathlib.Path)
- parser.add_argument("-G", dest="generator")
- parser.add_argument("-D", dest="defs", action="append", default=[])
- args = parser.parse_args(argv[1:])
-
- # Build the definition dictionary
- cmake_defs = {}
- for defn in args.defs:
- key, sep, val = defn.partition("=")
- if not sep:
- val = "1"
- assert key not in cmake_defs
- cmake_defs[key] = val
-
- return args, cmake_defs
-
-
-@hypothesis.given(build_configs_no_kconfig, paths, paths)
-@hypothesis.settings(deadline=60000)
-def test_popen_cmake_no_kconfig(conf, project_dir, build_dir):
- """Test popen_cmake for a config with no kconfig definitions."""
- job_client = FakeJobClient()
- conf.popen_cmake(job_client, project_dir, build_dir)
-
- args, cmake_defs = parse_cmake_args(job_client.captured_argv)
-
- assert cmake_defs == conf.cmake_defs
- assert job_client.captured_env == conf.environ_defs
-
-
-@hypothesis.given(build_configs_with_at_least_one_kconfig, paths, paths)
-@hypothesis.settings(deadline=60000)
-def test_popen_cmake_kconfig_but_no_file(conf, project_dir, build_dir):
- """Test that running popen_cmake with Kconfig definitions to write
- out, but no path to do so, should raise an error.
- """
- job_client = FakeJobClient()
-
- with pytest.raises(ValueError):
- conf.popen_cmake(job_client, project_dir, build_dir)
-
-
-@hypothesis.given(build_configs, paths, paths)
-@hypothesis.settings(deadline=60000)
-def test_popen_cmake_kconfig(conf, project_dir, build_dir):
- job_client = FakeJobClient()
-
- with tempfile.NamedTemporaryFile("w", delete=False) as f:
- temp_path = f.name
-
- try:
- conf.popen_cmake(
- job_client, project_dir, build_dir, kconfig_path=pathlib.Path(temp_path)
- )
-
- args, cmake_defs = parse_cmake_args(job_client.captured_argv)
-
- expected_kconfig_files = set(str(f) for f in conf.kconfig_files)
- expected_kconfig_files.add(temp_path)
-
- if expected_kconfig_files:
- kconfig_files = set(cmake_defs.pop("CONF_FILE").split(";"))
- else:
- assert "CONF_FILE" not in cmake_defs
- kconfig_files = set()
-
- assert cmake_defs == conf.cmake_defs
- assert job_client.captured_env == conf.environ_defs
- assert kconfig_files == expected_kconfig_files
-
- kconfig_defs = util.read_kconfig_file(temp_path)
- assert kconfig_defs == conf.kconfig_defs
- finally:
- os.unlink(temp_path)
diff --git a/zephyr/zmake/tests/test_modules.py b/zephyr/zmake/tests/test_modules.py
deleted file mode 100644
index 87e5d7bfc9..0000000000
--- a/zephyr/zmake/tests/test_modules.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import pathlib
-import tempfile
-
-import hypothesis
-import hypothesis.strategies as st
-
-import zmake.modules
-
-module_lists = st.lists(
- st.one_of(*map(st.just, zmake.modules.known_modules)), unique=True
-)
-
-
-@hypothesis.given(module_lists)
-@hypothesis.settings(deadline=None)
-def test_locate_in_directory(modules):
- """Test the basic functionality of locate_from_directory"""
-
- with tempfile.TemporaryDirectory() as modules_dir:
- modules_dir = pathlib.Path(modules_dir).resolve()
-
- expected_modules = {}
-
- for module in modules:
- module_dir = modules_dir / module
- zephyr_dir = module_dir / "zephyr"
- zephyr_dir.mkdir(parents=True)
-
- module_yml = zephyr_dir / "module.yml"
- module_yml.write_bytes(b"")
-
- expected_modules[module] = module_dir
-
- assert zmake.modules.locate_from_directory(modules_dir) == expected_modules
diff --git a/zephyr/zmake/tests/test_multiproc_executor.py b/zephyr/zmake/tests/test_multiproc_executor.py
deleted file mode 100644
index ebc2be5e4f..0000000000
--- a/zephyr/zmake/tests/test_multiproc_executor.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-import threading
-
-import zmake.multiproc
-
-
-def test_single_function_executor_success():
- executor = zmake.multiproc.Executor()
- executor.append(lambda: 0)
- assert executor.wait() == 0
-
-
-def test_single_function_executor_fail():
- executor = zmake.multiproc.Executor()
- executor.append(lambda: -2)
- assert executor.wait() == -2
-
-
-def test_single_function_executor_raise():
- executor = zmake.multiproc.Executor()
- executor.append(lambda: 1 / 0)
- assert executor.wait() != 0
-
-
-def _lock_step(cv, predicate, step, return_value=0):
- with cv:
- cv.wait_for(predicate=lambda: step[0] == predicate)
- step[0] += 1
- cv.notify_all()
- return return_value
-
-
-def test_two_function_executor_wait_for_both():
- cv = threading.Condition()
- step = [0]
- executor = zmake.multiproc.Executor()
- executor.append(lambda: _lock_step(cv=cv, predicate=0, step=step))
- executor.append(lambda: _lock_step(cv=cv, predicate=1, step=step))
- assert executor.wait() == 0
- assert step[0] == 2
-
-
-def test_two_function_executor_one_fails():
- cv = threading.Condition()
- step = [0]
- executor = zmake.multiproc.Executor()
- executor.append(lambda: _lock_step(cv=cv, predicate=0, step=step, return_value=-1))
- executor.append(lambda: _lock_step(cv=cv, predicate=1, step=step))
- assert executor.wait() == -1
- assert step[0] == 2
diff --git a/zephyr/zmake/tests/test_multiproc_logging.py b/zephyr/zmake/tests/test_multiproc_logging.py
deleted file mode 100644
index 2eac9326d3..0000000000
--- a/zephyr/zmake/tests/test_multiproc_logging.py
+++ /dev/null
@@ -1,106 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-import io
-import logging
-import os
-import threading
-import unittest.mock as mock
-
-import zmake.multiproc
-
-
-def test_read_output_from_pipe():
- semaphore = threading.Semaphore(0)
- pipe = os.pipe()
- fd = io.TextIOWrapper(os.fdopen(pipe[0], "rb"), encoding="utf-8")
- logger = mock.Mock(spec=logging.Logger)
- logger.log.side_effect = lambda log_lvl, line: semaphore.release()
- zmake.multiproc.log_output(logger, logging.DEBUG, fd, job_id="")
- os.write(pipe[1], "Hello\n".encode("utf-8"))
- semaphore.acquire()
- logger.log.assert_called_with(logging.DEBUG, "Hello")
-
-
-def test_read_output_change_log_level():
- semaphore = threading.Semaphore(0)
- pipe = os.pipe()
- fd = io.TextIOWrapper(os.fdopen(pipe[0], "rb"), encoding="utf-8")
- logger = mock.Mock(spec=logging.Logger)
- logger.log.side_effect = lambda log_lvl, line: semaphore.release()
- # This call will log output from fd (the file descriptor) to DEBUG, though
- # when the line starts with 'World', the logging level will be switched to
- # CRITICAL (see the content of the log_lvl_override_func).
- zmake.multiproc.log_output(
- logger=logger,
- log_level=logging.DEBUG,
- file_descriptor=fd,
- log_level_override_func=lambda line, lvl: logging.CRITICAL
- if line.startswith("World")
- else lvl,
- job_id="",
- )
- os.write(pipe[1], "Hello\n".encode("utf-8"))
- semaphore.acquire()
- os.write(pipe[1], "World\n".encode("utf-8"))
- semaphore.acquire()
- os.write(pipe[1], "Bye\n".encode("utf-8"))
- semaphore.acquire()
- logger.log.assert_has_calls(
- [
- mock.call(logging.DEBUG, "Hello"),
- mock.call(logging.CRITICAL, "World"),
- mock.call(logging.CRITICAL, "Bye"),
- ]
- )
-
-
-def test_read_output_from_second_pipe():
- """Test that we can read from more than one pipe.
-
- This is particularly important since we will block on a read/select once we
- have a file descriptor. It is important that we break from the select and
- start it again with the updated list when a new one is added.
- """
- semaphore = threading.Semaphore(0)
- pipes = [os.pipe(), os.pipe()]
- fds = [
- io.TextIOWrapper(os.fdopen(pipes[0][0], "rb"), encoding="utf-8"),
- io.TextIOWrapper(os.fdopen(pipes[1][0], "rb"), encoding="utf-8"),
- ]
-
- logger = mock.Mock(spec=logging.Logger)
- logger.log.side_effect = lambda log_lvl, fmt, id, line: semaphore.release()
-
- zmake.multiproc.log_output(logger, logging.DEBUG, fds[0], job_id="0")
- zmake.multiproc.log_output(logger, logging.ERROR, fds[1], job_id="1")
-
- os.write(pipes[1][1], "Hello\n".encode("utf-8"))
- semaphore.acquire()
- logger.log.assert_called_with(logging.ERROR, "[%s]%s", "1", "Hello")
-
-
-def test_read_output_after_another_pipe_closed():
- """Test processing output from a pipe after closing another.
-
- Since we don't want to complicate the API. File descriptors are
- automatically pruned away when closed. Make sure that the other descriptors
- remain functional when that happens.
- """
- semaphore = threading.Semaphore(0)
- pipes = [os.pipe(), os.pipe()]
- fds = [
- io.TextIOWrapper(os.fdopen(pipes[0][0], "rb"), encoding="utf-8"),
- io.TextIOWrapper(os.fdopen(pipes[1][0], "rb"), encoding="utf-8"),
- ]
-
- logger = mock.Mock(spec=logging.Logger)
- logger.log.side_effect = lambda log_lvl, fmt, id, line: semaphore.release()
-
- zmake.multiproc.log_output(logger, logging.DEBUG, fds[0], job_id="0")
- zmake.multiproc.log_output(logger, logging.ERROR, fds[1], job_id="1")
-
- fds[0].close()
- os.write(pipes[1][1], "Hello\n".encode("utf-8"))
- semaphore.acquire()
- logger.log.assert_called_with(logging.ERROR, "[%s]%s", "1", "Hello")
diff --git a/zephyr/zmake/tests/test_packers.py b/zephyr/zmake/tests/test_packers.py
deleted file mode 100644
index 1709c68098..0000000000
--- a/zephyr/zmake/tests/test_packers.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import pathlib
-import tempfile
-import unittest.mock as mock
-
-import hypothesis
-import hypothesis.strategies as st
-import pytest
-
-import zmake.output_packers as packers
-
-# Strategies for use with hypothesis
-absolute_path = st.from_regex(regex=r"\A/[\w/]*\Z")
-
-
-@hypothesis.given(absolute_path)
-@hypothesis.settings(deadline=60000)
-def test_file_size_unbounded(path):
- packer = packers.BasePacker(project=None)
- packer._is_size_bound = mock.Mock(name="_is_size_bound", return_value=False)
- file = pathlib.Path(path) / "zephyr.bin"
- assert packer._check_packed_file_size(file=file, dirs={}) == file
- packer._is_size_bound.assert_called_once_with(file)
-
-
-@hypothesis.given(st.binary(min_size=5, max_size=100))
-@hypothesis.settings(deadline=60000)
-def test_file_size_in_bounds(data):
- packer = packers.BasePacker(project=None)
- packer._is_size_bound = mock.Mock(name="_is_size_bound", return_value=True)
- packer._get_max_image_bytes = mock.Mock(
- name="_get_max_image_bytes", return_value=100
- )
- with tempfile.TemporaryDirectory() as temp_dir_name:
- file = pathlib.Path(temp_dir_name) / "zephyr.bin"
- with open(file, "wb") as f:
- f.write(data)
- assert packer._check_packed_file_size(file=file, dirs={}) == file
-
-
-@hypothesis.given(st.binary(min_size=101, max_size=200))
-@hypothesis.settings(deadline=60000)
-def test_file_size_out_of_bounds(data):
- packer = packers.BasePacker(project=None)
- packer._is_size_bound = mock.Mock(name="_is_size_bound", return_value=True)
- packer._get_max_image_bytes = mock.Mock(
- name="_get_max_image_bytes", return_value=100
- )
- with tempfile.TemporaryDirectory() as temp_dir_name:
- file = pathlib.Path(temp_dir_name) / "zephyr.bin"
- with open(file, "wb") as f:
- f.write(data)
- with pytest.raises(RuntimeError):
- packer._check_packed_file_size(file=file, dirs={})
diff --git a/zephyr/zmake/tests/test_project.py b/zephyr/zmake/tests/test_project.py
deleted file mode 100644
index 2442ceedf6..0000000000
--- a/zephyr/zmake/tests/test_project.py
+++ /dev/null
@@ -1,173 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import pathlib
-import string
-import tempfile
-
-import hypothesis
-import hypothesis.strategies as st
-import pytest
-
-import zmake.modules
-import zmake.project
-
-board_names = st.text(alphabet=set(string.ascii_lowercase) | {"_"}, min_size=1)
-sets_of_board_names = st.lists(st.lists(board_names, unique=True))
-
-
-class TemporaryProject(tempfile.TemporaryDirectory):
- """A temporary project wrapper.
-
- Args:
- config: The config dictionary to be used with the project.
- """
-
- def __init__(self, config):
- self.config = config
- super().__init__()
-
- def __enter__(self):
- project_path = pathlib.Path(super().__enter__())
- return zmake.project.Project(project_path, config_dict=self.config)
-
-
-@hypothesis.given(sets_of_board_names)
-@hypothesis.settings(deadline=None)
-def test_find_dts_overlays(modules):
- """Test the functionality of find_dts_overlays with multiple
- modules, each with sets of board names."""
-
- # Recursive function to wind up all the temporary directories and
- # call the actual test.
- def setup_modules_and_dispatch(modules, test_fn, module_list=()):
- if modules:
- boards = modules[0]
- with tempfile.TemporaryDirectory() as modpath:
- modpath = pathlib.Path(modpath)
- for board in boards:
- dts_path = zmake.project.module_dts_overlay_name(modpath, board)
- dts_path.parent.mkdir(parents=True, exist_ok=True)
- dts_path.touch()
- setup_modules_and_dispatch(
- modules[1:], test_fn, module_list=module_list + (modpath,)
- )
- else:
- test_fn(module_list)
-
- # The actual test case, once temp modules have been setup.
- def testcase(module_paths):
- # Maps board_name→overlay_files
- board_file_mapping = {}
- for modpath, board_list in zip(module_paths, modules):
- for board in board_list:
- file_name = zmake.project.module_dts_overlay_name(modpath, board)
- files = board_file_mapping.get(board, set())
- board_file_mapping[board] = files | {file_name}
-
- for board, expected_dts_files in board_file_mapping.items():
- with TemporaryProject(
- {
- "board": board,
- "output-type": "elf",
- "supported-toolchains": ["llvm"],
- "supported-zephyr-versions": ["v2.6"],
- }
- ) as project:
- config = project.find_dts_overlays(dict(enumerate(module_paths)))
-
- actual_dts_files = set(
- config.cmake_defs.get("DTC_OVERLAY_FILE", "").split(";")
- )
-
- assert actual_dts_files == set(map(str, expected_dts_files))
-
- setup_modules_and_dispatch(modules, testcase)
-
-
-module_lists = st.lists(
- st.one_of(*map(st.just, zmake.modules.known_modules)), unique=True
-)
-
-
-@hypothesis.given(module_lists)
-@hypothesis.settings(deadline=None)
-def test_prune_modules(modules):
- """Test the Project.prune_modules method in the usual case (all
- modules available)."""
- module_paths = {
- name: pathlib.Path("/fake/module/path", name)
- for name in zmake.modules.known_modules
- }
-
- with TemporaryProject(
- {
- "board": "native_posix",
- "output-type": "elf",
- "supported-toolchains": ["coreboot-sdk"],
- "supported-zephyr-versions": ["v2.6"],
- "modules": modules,
- }
- ) as project:
- assert set(project.prune_modules(module_paths)) == set(modules)
-
-
-def test_prune_modules_unavailable():
- """The Project.prune_modules method should raise a KeyError when
- not all modules are available."""
-
- # Missing 'cmsis'
- module_paths = {
- "hal_stm32": pathlib.Path("/mod/halstm"),
- }
-
- with TemporaryProject(
- {
- "board": "native_posix",
- "output-type": "elf",
- "supported-toolchains": ["coreboot-sdk"],
- "supported-zephyr-versions": ["v2.6"],
- "modules": ["hal_stm32", "cmsis"],
- }
- ) as project:
- with pytest.raises(KeyError):
- project.prune_modules(module_paths)
-
-
-def test_find_projects_empty(tmp_path):
- """Test the find_projects method when there are no projects."""
- projects = list(zmake.project.find_projects(tmp_path))
- assert len(projects) == 0
-
-
-YAML_FILE = """
-supported-zephyr-versions:
- - v2.6
-supported-toolchains:
- - coreboot-sdk
-output-type: npcx
-"""
-
-
-def test_find_projects(tmp_path):
- """Test the find_projects method when there are projects."""
- dir = tmp_path.joinpath("one")
- dir.mkdir()
- dir.joinpath("zmake.yaml").write_text("board: one\n" + YAML_FILE)
- tmp_path.joinpath("two").mkdir()
- dir = tmp_path.joinpath("two/a")
- dir.mkdir()
- dir.joinpath("zmake.yaml").write_text("board: twoa\nis-test: true\n" + YAML_FILE)
- dir = tmp_path.joinpath("two/b")
- dir.mkdir()
- dir.joinpath("zmake.yaml").write_text("board: twob\n" + YAML_FILE)
- projects = list(zmake.project.find_projects(tmp_path))
- projects.sort(key=lambda x: x.project_dir)
- assert len(projects) == 3
- assert projects[0].project_dir == tmp_path.joinpath("one")
- assert projects[1].project_dir == tmp_path.joinpath("two/a")
- assert projects[2].project_dir == tmp_path.joinpath("two/b")
- assert not projects[0].config.is_test
- assert projects[1].config.is_test
- assert not projects[2].config.is_test
diff --git a/zephyr/zmake/tests/test_reexec.py b/zephyr/zmake/tests/test_reexec.py
deleted file mode 100644
index 9f25b5a834..0000000000
--- a/zephyr/zmake/tests/test_reexec.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-"""Test the zmake re-exec functionality."""
-
-import os
-import sys
-import unittest.mock as mock
-
-import pytest
-
-import zmake.__main__ as main
-
-
-@pytest.fixture
-def fake_env(monkeypatch):
- environ = {}
- monkeypatch.setattr(os, "environ", environ)
- return environ
-
-
-@pytest.fixture
-def mock_execve():
- with mock.patch("os.execve", autospec=True) as mocked_function:
- yield mocked_function
-
-
-def test_out_of_chroot(fake_env, mock_execve):
- # When CROS_WORKON_SRCROOT is not set, we should not re-exec.
- main.maybe_reexec(["--help"])
- mock_execve.assert_not_called()
-
-
-def test_pythonpath_set(fake_env, mock_execve):
- # With PYTHONPATH set, we should not re-exec.
- fake_env["CROS_WORKON_SRCROOT"] = "/mnt/host/source"
- fake_env["PYTHONPATH"] = "/foo/bar/baz"
- main.maybe_reexec(["--help"])
- mock_execve.assert_not_called()
-
-
-def test_zmake_does_not_exist(fake_env, mock_execve):
- # When zmake is not at src/platform/ec/zephyr/zmake, don't re-exec.
- fake_env["CROS_WORKON_SRCROOT"] = "/this/does/not/exist"
- main.maybe_reexec(["--help"])
- mock_execve.assert_not_called()
-
-
-def test_zmake_reexec(fake_env, mock_execve):
- # Nothing else applies? The re-exec should happen.
- fake_env["CROS_WORKON_SRCROOT"] = "/mnt/host/source"
- main.maybe_reexec(["--help"])
- new_env = dict(fake_env)
- new_env["PYTHONPATH"] = "/mnt/host/source/src/platform/ec/zephyr/zmake"
- mock_execve.assert_called_once_with(
- sys.executable,
- [sys.executable, "-m", "zmake", "--help"],
- new_env,
- )
diff --git a/zephyr/zmake/tests/test_toolchains.py b/zephyr/zmake/tests/test_toolchains.py
deleted file mode 100644
index 515f54a112..0000000000
--- a/zephyr/zmake/tests/test_toolchains.py
+++ /dev/null
@@ -1,155 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import os
-import pathlib
-
-import pytest
-
-import zmake.project as project
-import zmake.toolchains as toolchains
-
-
-@pytest.fixture
-def mockfs(monkeypatch, tmp_path):
- """Setup a fake fs root for pathlib objects at tmp_path/mockfs."""
- mockfs_dir = pathlib.PosixPath(tmp_path / "mockfs")
- mockfs_dir.mkdir()
-
- class FakePath(pathlib.Path):
- def __new__(cls, *args, **kwargs):
- parts = pathlib.PosixPath(*args).relative_to("/").parts
- # Make sure we don't double up our mocked directory.
- mock_dir_parts = mockfs_dir.relative_to("/").parts
- if parts[: len(mock_dir_parts)] == mock_dir_parts:
- return pathlib.PosixPath(*args)
- return pathlib.PosixPath("/", *mock_dir_parts, *parts)
-
- monkeypatch.setattr(pathlib, "Path", FakePath)
- return mockfs_dir
-
-
-@pytest.fixture
-def coreboot_sdk_exists(mockfs):
- coreboot_sdk_dir = mockfs / "opt" / "coreboot-sdk"
- coreboot_sdk_dir.mkdir(parents=True)
-
-
-@pytest.fixture
-def llvm_exists(mockfs):
- llvm_file = mockfs / "usr" / "bin" / "x86_64-pc-linux-gnu-clang"
- llvm_file.parent.mkdir(parents=True)
- llvm_file.write_text("")
-
-
-@pytest.fixture
-def host_toolchain_exists(mockfs, monkeypatch):
- monkeypatch.setattr(os, "environ", {})
-
- gcc_file = mockfs / "usr" / "bin" / "gcc"
- gcc_file.parent.mkdir(parents=True)
- gcc_file.write_text("")
-
-
-@pytest.fixture
-def zephyr_exists(mockfs):
- zephyr_sdk_version_file = mockfs / "opt" / "zephyr-sdk" / "sdk_version"
- zephyr_sdk_version_file.parent.mkdir(parents=True)
- zephyr_sdk_version_file.write_text("")
-
-
-@pytest.fixture
-def fake_project(tmp_path):
- return project.Project(
- tmp_path,
- config_dict={
- "board": "foo",
- "supported-zephyr-versions": ["v2.6"],
- "supported-toolchains": [
- "coreboot-sdk",
- "host",
- "llvm",
- "zephyr",
- ],
- "output-type": "raw",
- },
- )
-
-
-module_paths = {
- "ec": pathlib.Path("/mnt/host/source/src/platform/ec"),
-}
-
-
-def test_coreboot_sdk(fake_project, coreboot_sdk_exists):
- tc = fake_project.get_toolchain(module_paths)
- assert isinstance(tc, toolchains.CorebootSdkToolchain)
-
- config = tc.get_build_config()
- assert config.cmake_defs == {
- "ZEPHYR_TOOLCHAIN_VARIANT": "coreboot-sdk",
- "TOOLCHAIN_ROOT": "/mnt/host/source/src/platform/ec/zephyr",
- }
-
-
-def test_llvm(fake_project, llvm_exists):
- tc = fake_project.get_toolchain(module_paths)
- assert isinstance(tc, toolchains.LlvmToolchain)
-
- config = tc.get_build_config()
- assert config.cmake_defs == {
- "ZEPHYR_TOOLCHAIN_VARIANT": "llvm",
- "TOOLCHAIN_ROOT": "/mnt/host/source/src/platform/ec/zephyr",
- }
-
-
-def test_zephyr(fake_project, zephyr_exists):
- tc = fake_project.get_toolchain(module_paths)
- assert isinstance(tc, toolchains.ZephyrToolchain)
-
- config = tc.get_build_config()
- assert config.cmake_defs == {
- "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
- "ZEPHYR_SDK_INSTALL_DIR": str(pathlib.Path("/opt/zephyr-sdk")),
- }
- assert config.environ_defs == {
- "ZEPHYR_SDK_INSTALL_DIR": str(pathlib.Path("/opt/zephyr-sdk")),
- }
-
-
-def test_zephyr_from_env(mockfs, monkeypatch, fake_project):
- zephyr_sdk_path = mockfs / "zsdk"
- zephyr_sdk_path.mkdir()
-
- environ = {"ZEPHYR_SDK_INSTALL_DIR": str(zephyr_sdk_path)}
- monkeypatch.setattr(os, "environ", environ)
-
- tc = fake_project.get_toolchain(module_paths)
- assert isinstance(tc, toolchains.ZephyrToolchain)
-
- config = tc.get_build_config()
- assert config.cmake_defs == {
- "ZEPHYR_TOOLCHAIN_VARIANT": "zephyr",
- "ZEPHYR_SDK_INSTALL_DIR": str(zephyr_sdk_path),
- }
- assert config.environ_defs == {
- "ZEPHYR_SDK_INSTALL_DIR": str(zephyr_sdk_path),
- }
-
-
-def test_host_toolchain(fake_project, host_toolchain_exists):
- tc = fake_project.get_toolchain(module_paths)
- assert isinstance(tc, toolchains.HostToolchain)
-
- config = tc.get_build_config()
- assert config.cmake_defs == {
- "ZEPHYR_TOOLCHAIN_VARIANT": "host",
- }
-
-
-def test_toolchain_override(mockfs, fake_project):
- tc = fake_project.get_toolchain(module_paths, override="foo")
- config = tc.get_build_config()
- assert isinstance(tc, toolchains.GenericToolchain)
- assert config.cmake_defs == {"ZEPHYR_TOOLCHAIN_VARIANT": "foo"}
diff --git a/zephyr/zmake/tests/test_util.py b/zephyr/zmake/tests/test_util.py
deleted file mode 100644
index 0c4cd4dda5..0000000000
--- a/zephyr/zmake/tests/test_util.py
+++ /dev/null
@@ -1,107 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import pathlib
-import re
-import tempfile
-
-import hypothesis
-import hypothesis.strategies as st
-import pytest
-
-import zmake.util as util
-
-# Strategies for use with hypothesis
-relative_path = st.from_regex(
- regex=re.compile(r"\A\w{1,255}(/\w{1,255}){0,15}\Z", re.ASCII)
-)
-
-
-@hypothesis.given(relative_path, relative_path, relative_path)
-@hypothesis.settings(deadline=60000)
-def test_resolve_build_dir_with_build_dir(
- platform_ec_subdir, project_subdir, build_subdir
-):
- with tempfile.TemporaryDirectory() as temp_dir_name:
- platform_ec_dir = pathlib.Path(temp_dir_name) / platform_ec_subdir
- build_dir = util.resolve_build_dir(
- platform_ec_dir=platform_ec_dir,
- project_dir=platform_ec_dir / project_subdir,
- build_dir=platform_ec_dir / build_subdir,
- )
-
- assert build_dir == platform_ec_dir / build_subdir
-
-
-@hypothesis.given(relative_path, relative_path)
-@hypothesis.settings(deadline=60000)
-def test_resolve_build_dir_invalid_project(platform_ec_subdir, project_subdir):
- try:
- with tempfile.TemporaryDirectory() as temp_dir_name:
- platform_ec_dir = pathlib.Path(temp_dir_name) / platform_ec_subdir
- util.resolve_build_dir(
- platform_ec_dir=platform_ec_dir,
- project_dir=platform_ec_dir / project_subdir,
- build_dir=None,
- )
- pytest.fail()
- except Exception:
- pass
-
-
-@hypothesis.given(relative_path, relative_path)
-@hypothesis.settings(deadline=60000)
-def test_resolve_build_dir_from_project(platform_ec_subdir, project_subdir):
- with tempfile.TemporaryDirectory() as temp_dir_name:
- platform_ec_dir = pathlib.Path(temp_dir_name) / platform_ec_subdir
- project_dir = platform_ec_dir / project_subdir
- project_dir.mkdir(parents=True)
- (project_dir / "zmake.yaml").touch()
- build_dir = util.resolve_build_dir(
- platform_ec_dir=platform_ec_dir, project_dir=project_dir, build_dir=None
- )
- assert build_dir == platform_ec_dir / "build" / project_subdir
-
-
-version_integers = st.integers(min_value=0)
-version_tuples = st.tuples(version_integers, version_integers, version_integers)
-
-
-@hypothesis.given(version_tuples)
-@hypothesis.settings(deadline=60000)
-def test_read_zephyr_version(version_tuple):
- with tempfile.TemporaryDirectory() as zephyr_base:
- with open(pathlib.Path(zephyr_base) / "VERSION", "w") as f:
- for name, value in zip(
- ("VERSION_MAJOR", "VERSION_MINOR", "PATCHLEVEL"), version_tuple
- ):
- f.write("{} = {}\n".format(name, value))
-
- assert util.read_zephyr_version(zephyr_base) == version_tuple
-
-
-@hypothesis.given(st.integers())
-@hypothesis.settings(deadline=60000)
-def test_read_kconfig_autoconf_value(value):
- with tempfile.TemporaryDirectory() as dir:
- path = pathlib.Path(dir)
- with open(path / "autoconf.h", "w") as f:
- f.write("#define TEST {}".format(value))
- read_value = util.read_kconfig_autoconf_value(path, "TEST")
- assert int(read_value) == value
-
-
-@pytest.mark.parametrize(
- ["input_str", "expected_result"],
- [
- ("", '""'),
- ("TROGDOR ABC-123", '"TROGDOR ABC-123"'),
- ("hello world", '"hello world"'),
- ("hello\nworld", r'"hello\nworld"'),
- ('hello"world', r'"hello\"world"'),
- ("hello\\world", '"hello\\\\world"'),
- ],
-)
-def test_c_str(input_str, expected_result):
- assert util.c_str(input_str) == expected_result
diff --git a/zephyr/zmake/tests/test_version.py b/zephyr/zmake/tests/test_version.py
deleted file mode 100644
index a238a8ac02..0000000000
--- a/zephyr/zmake/tests/test_version.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import datetime
-import subprocess
-import unittest.mock as mock
-
-import pytest
-
-import zmake.project
-import zmake.version as version
-
-
-def _git_init(repo):
- """Create a new git repository."""
- repo.mkdir()
- subprocess.run(
- ["git", "-c", "init.defaultBranch=main", "-C", repo, "init"], check=True
- )
-
-
-def _git_add(repo, path, contents="example!\n"):
- """Write contents and stage a file."""
- path.write_text(contents)
- subprocess.run(["git", "-C", repo, "add", path], check=True)
-
-
-def _git_commit(repo, message="message!"):
- env = {
- "GIT_AUTHOR_NAME": "Alyssa P. Hacker",
- "GIT_AUTHOR_EMAIL": "aphacker@example.org",
- "GIT_AUTHOR_DATE": "Thu, 07 Apr 2005 22:13:13 +0200",
- "GIT_COMMITTER_NAME": "Ben Bitdiddle",
- "GIT_COMMITTER_EMAIL": "bitdiddle@example.org",
- "GIT_COMMITTER_DATE": "Tue, 30 Aug 2005 10:50:30 -0700",
- }
- subprocess.run(["git", "-C", repo, "commit", "-m", message], check=True, env=env)
-
-
-def _setup_example_repos(tmp_path):
- """Setup temporary project, zephyr base, and module repos.
-
- Args:
- tmp_path: Directory to set up files in.
-
- Returns:
- A 3-tuple of project, zephyr_base, modules_dict.
- """
- project_path = tmp_path / "prj"
- project_path.mkdir()
-
- project = zmake.project.Project(
- project_path,
- config_dict={
- "board": "foo",
- "output-type": "raw",
- "supported-toolchains": ["coreboot-sdk"],
- "supported-zephyr-versions": ["v2.6"],
- },
- )
- # Has one commit.
- zephyr_base = tmp_path / "zephyr_base"
- _git_init(zephyr_base)
- _git_add(
- zephyr_base,
- zephyr_base / "VERSION",
- "VERSION_MAJOR=2\nVERSION_MINOR=6\nPATCHLEVEL=99\n",
- )
- _git_commit(zephyr_base, "Added version file")
-
- # Has one commit.
- mod1 = tmp_path / "mod1"
- _git_init(mod1)
- _git_add(mod1, mod1 / "file1")
- _git_commit(mod1)
-
- # Has two commits.
- mod2 = tmp_path / "ec"
- _git_init(mod2)
- _git_add(mod2, mod2 / "file2")
- _git_commit(mod2)
- _git_add(mod2, mod2 / "file3")
- _git_commit(mod2)
-
- return project, zephyr_base, {"mod1": mod1, "ec": mod2}
-
-
-def test_version_string(tmp_path):
- project, zephyr_base, modules = _setup_example_repos(tmp_path)
- assert (
- version.get_version_string(project, zephyr_base, modules)
- == "prj_v2.6.4-ec:b5991f,os:377d26,mod1:02fd7a"
- )
-
-
-def test_version_string_static(tmp_path):
- project, zephyr_base, modules = _setup_example_repos(tmp_path)
- assert (
- version.get_version_string(project, zephyr_base, modules, static=True)
- == "prj_v2.6.0-STATIC"
- )
-
-
-@pytest.fixture
-def fake_user_hostname():
- with mock.patch("getpass.getuser", return_value="toukmond", autospec=True):
- with mock.patch("platform.node", return_value="pokey", autospec=True):
- yield
-
-
-@pytest.fixture
-def fake_date():
- fixed_date = datetime.datetime(2021, 6, 28, 3, 18, 53)
- with mock.patch("datetime.datetime") as mock_datetime:
- mock_datetime.now.return_value = fixed_date
- yield
-
-
-HEADER_VERSION_STR = "trogdor_v2.6.1004-cmsis:0dead0,hal_stm32:0beef0,os:ad00da"
-EXPECTED_HEADER = (
- "/* This file is automatically generated by zmake */\n"
- '#define VERSION "trogdor_v2.6.1004-cmsis:0dead0,hal_stm32:0beef0,os:ad00da"\n'
- '#define CROS_EC_VERSION32 "trogdor_v2.6.1004-cmsis:0dead0,"\n'
- '#define BUILDER "toukmond@pokey"\n'
- '#define DATE "2021-06-28 03:18:53"\n'
- '#define CROS_FWID_MISSING_STR "CROS_FWID_MISSING"\n'
- "#define CROS_FWID32 CROS_FWID_MISSING_STR\n"
-)
-HEADER_VERSION_STR_STATIC = "trogdor_v2.6.0-STATIC"
-EXPECTED_HEADER_STATIC = (
- "/* This file is automatically generated by zmake */\n"
- '#define VERSION "trogdor_v2.6.0-STATIC"\n'
- '#define CROS_EC_VERSION32 "trogdor_v2.6.0-STATIC"\n'
- '#define BUILDER "reproducible@build"\n'
- '#define DATE "STATIC_VERSION_DATE"\n'
- '#define CROS_FWID_MISSING_STR "CROS_FWID_MISSING"\n'
- "#define CROS_FWID32 CROS_FWID_MISSING_STR\n"
-)
-
-
-def test_header_gen(fake_user_hostname, fake_date, tmp_path):
- # Test the simple case (static=False, no existing header).
- output_file = tmp_path / "ec_version.h"
- version.write_version_header(HEADER_VERSION_STR, output_file)
- assert output_file.read_text() == EXPECTED_HEADER
-
-
-def test_header_gen_reproducible_build(tmp_path):
- # With static=True this time.
- output_file = tmp_path / "ec_version.h"
- version.write_version_header(HEADER_VERSION_STR_STATIC, output_file, static=True)
- assert output_file.read_text() == EXPECTED_HEADER_STATIC
-
-
-def test_header_gen_exists_not_changed(fake_user_hostname, fake_date, tmp_path):
- # Test we don't overwrite if no changes needed.
- output_file = tmp_path / "ec_version.h"
-
- # First time, write and record mtime.
- version.write_version_header(HEADER_VERSION_STR, output_file)
- expected_mtime = output_file.stat().st_mtime
-
- # Do another write (contents should be unchanged).
- version.write_version_header(HEADER_VERSION_STR, output_file)
-
- # Assert we didn't write again.
- assert output_file.stat().st_mtime == expected_mtime
-
-
-def test_header_gen_exists_needs_changes(fake_user_hostname, fake_date, tmp_path):
- # Test we overwrite when it exists already and changes are needed.
- output_file = tmp_path / "ec_version.h"
-
- # First time, write and save contents.
- version.write_version_header(HEADER_VERSION_STR, output_file)
- original_contents = output_file.read_text()
-
- # Do another write (contents should be changed).
- version.write_version_header(HEADER_VERSION_STR_STATIC, output_file, static=True)
-
- # Assert we overwrote.
- assert output_file.read_text() != original_contents
diff --git a/zephyr/zmake/tests/test_zmake.py b/zephyr/zmake/tests/test_zmake.py
deleted file mode 100644
index 641f9f3db9..0000000000
--- a/zephyr/zmake/tests/test_zmake.py
+++ /dev/null
@@ -1,224 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-"""Do a run of 'zmake build' and check the output"""
-
-import logging
-import os
-import pathlib
-import re
-import tempfile
-import unittest
-import unittest.mock as mock
-from unittest.mock import patch
-
-from testfixtures import LogCapture
-
-import zmake.build_config
-import zmake.jobserver
-import zmake.multiproc as multiproc
-import zmake.project
-import zmake.toolchains
-import zmake.zmake as zm
-
-OUR_PATH = os.path.dirname(os.path.realpath(__file__))
-
-
-class FakeProject:
- """A fake project which requests two builds and does no packing"""
-
- # pylint: disable=too-few-public-methods
-
- def __init__(self):
- self.packer = mock.Mock()
- self.packer.pack_firmware = mock.Mock(return_value=[])
- self.project_dir = pathlib.Path("FakeProjectDir")
-
- self.config = mock.Mock()
- self.config.supported_zephyr_versions = [(2, 5)]
-
- @staticmethod
- def iter_builds():
- """Yield the two builds that zmake normally does"""
- yield "build-ro", zmake.build_config.BuildConfig()
- yield "build-rw", zmake.build_config.BuildConfig()
-
- def prune_modules(self, paths):
- return {} # pathlib.Path('path')]
-
- def find_dts_overlays(self, module_paths):
- return zmake.build_config.BuildConfig()
-
- def get_toolchain(self, module_paths, override=None):
- return zmake.toolchains.GenericToolchain(
- override or "foo",
- modules=module_paths,
- )
-
-
-class FakeJobserver(zmake.jobserver.GNUMakeJobServer):
- """A fake jobserver which just runs 'cat' on the provided files"""
-
- def __init__(self, fnames):
- """Start up a jobserver with two jobs
-
- Args:
- fnames: Dict of regexp to filename. If the regexp matches the
- command, then the filename will be returned as the output.
- """
- super().__init__()
- self.jobserver = zmake.jobserver.GNUMakeJobServer(jobs=2)
- self.fnames = fnames
-
- def get_job(self):
- """Fake implementation of get_job(), which returns a real JobHandle()"""
- return zmake.jobserver.JobHandle(mock.Mock())
-
- # pylint: disable=arguments-differ
- def popen(self, cmd, *args, **kwargs):
- """Ignores the provided command and just runs 'cat' instead"""
- for pattern, filename in self.fnames.items():
- # Convert to a list of strings
- cmd = [isinstance(c, pathlib.PosixPath) and c.as_posix() or c for c in cmd]
- if pattern.match(" ".join(cmd)):
- new_cmd = ["cat", filename]
- break
- else:
- raise Exception('No pattern matched "%s"' % " ".join(cmd))
- kwargs.pop("env", None)
- return self.jobserver.popen(new_cmd, *args, **kwargs)
-
-
-def get_test_filepath(suffix):
- """Get the filepath for a particular test file
-
- Args:
- suffix: Suffix of the file to read, e.g. 'ro' or 'ro_INFO'
-
- Returns:
- Full path to the test file
- """
- return os.path.join(OUR_PATH, "files", "sample_{}.txt".format(suffix))
-
-
-def do_test_with_log_level(log_level, use_configure=False, fnames=None):
- """Test filtering using a particular log level
-
- Args:
- log_level: Level to use
- use_configure: Run the 'configure' subcommand instead of 'build'
- fnames: Dict of regexp to filename. If the regexp matches the
- command, then the filename will be returned as the output.
- (None to use default ro/rw output)
-
- Returns:
- tuple:
- - List of log strings obtained from the run
- - Temporary directory used for build
- """
- if fnames is None:
- fnames = {
- re.compile(r".*build-ro"): get_test_filepath("ro"),
- re.compile(r".*build-rw"): get_test_filepath("rw"),
- }
- zephyr_base = mock.Mock()
-
- zmk = zm.Zmake(
- jobserver=FakeJobserver(fnames),
- zephyr_base=zephyr_base,
- )
-
- with LogCapture(level=log_level) as cap:
- with tempfile.TemporaryDirectory() as tmpname:
- with open(os.path.join(tmpname, "VERSION"), "w") as fd:
- fd.write(
- """VERSION_MAJOR = 2
-VERSION_MINOR = 5
-PATCHLEVEL = 0
-VERSION_TWEAK = 0
-EXTRAVERSION =
-"""
- )
- zephyr_base.resolve = mock.Mock(return_value=pathlib.Path(tmpname))
- with patch("zmake.version.get_version_string", return_value="123"):
- with patch.object(zmake.project, "Project", return_value=FakeProject()):
- if use_configure:
- zmk.configure(
- pathlib.Path(tmpname), build_dir=pathlib.Path("build")
- )
- else:
- with patch("zmake.version.write_version_header", autospec=True):
- zmk.build(pathlib.Path(tmpname))
- multiproc.wait_for_log_end()
-
- recs = [rec.getMessage() for rec in cap.records]
- return recs, tmpname
-
-
-class TestFilters(unittest.TestCase):
- """Test filtering of stdout and stderr"""
-
- def test_filter_normal(self):
- """Test filtering of a normal build (with no errors)"""
- recs, _ = do_test_with_log_level(logging.ERROR)
- self.assertFalse(recs)
-
- def test_filter_info(self):
- """Test what appears on the INFO level"""
- recs, tmpname = do_test_with_log_level(logging.INFO)
- # TODO: Remove sets and figure out how to check the lines are in the
- # right order.
- expected = {
- "Building {}:build-ro: /usr/bin/ninja -C {}/build-build-ro".format(
- tmpname, tmpname
- ),
- "Building {}:build-rw: /usr/bin/ninja -C {}/build-build-rw".format(
- tmpname, tmpname
- ),
- }
- for suffix in ["ro", "rw"]:
- with open(get_test_filepath("%s_INFO" % suffix)) as f:
- for line in f:
- expected.add(
- "[{}:build-{}]{}".format(tmpname, suffix, line.strip())
- )
- # This produces an easy-to-read diff if there is a difference
- self.assertEqual(expected, set(recs))
-
- def test_filter_debug(self):
- """Test what appears on the DEBUG level"""
- recs, tmpname = do_test_with_log_level(logging.DEBUG)
- # TODO: Remove sets and figure out how to check the lines are in the
- # right order.
- expected = {
- "Building {}:build-ro: /usr/bin/ninja -C {}/build-build-ro".format(
- tmpname, tmpname
- ),
- "Building {}:build-rw: /usr/bin/ninja -C {}/build-build-rw".format(
- tmpname, tmpname
- ),
- "Running cat {}/files/sample_ro.txt".format(OUR_PATH),
- "Running cat {}/files/sample_rw.txt".format(OUR_PATH),
- }
- for suffix in ["ro", "rw"]:
- with open(get_test_filepath(suffix)) as f:
- for line in f:
- expected.add(
- "[{}:build-{}]{}".format(tmpname, suffix, line.strip())
- )
- # This produces an easy-to-read diff if there is a difference
- self.assertEqual(expected, set(recs))
-
- def test_filter_devicetree_error(self):
- """Test that devicetree errors appear"""
- recs, tmpname = do_test_with_log_level(
- logging.ERROR, True, {re.compile(r".*"): get_test_filepath("err")}
- )
-
- dt_errs = [rec for rec in recs if "adc" in rec]
- assert "devicetree error: 'adc' is marked as required" in list(dt_errs)[0]
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/zephyr/zmake/zmake/__init__.py b/zephyr/zmake/zmake/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/zephyr/zmake/zmake/__init__.py
+++ /dev/null
diff --git a/zephyr/zmake/zmake/__main__.py b/zephyr/zmake/zmake/__main__.py
deleted file mode 100644
index 31f0436b5a..0000000000
--- a/zephyr/zmake/zmake/__main__.py
+++ /dev/null
@@ -1,273 +0,0 @@
-# Copyright 2020 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.
-
-"""The entry point into zmake."""
-import argparse
-import inspect
-import logging
-import os
-import pathlib
-import sys
-
-import zmake.multiproc as multiproc
-import zmake.zmake as zm
-
-
-def maybe_reexec(argv):
- """Re-exec zmake from the EC source tree, if possible and desired.
-
- Zmake installs into the users' chroot, which makes it convenient
- to execute, but can sometimes become tedious when zmake changes
- land and users haven't upgraded their chroots yet.
-
- We can partially subvert this problem by re-execing zmake from the
- source if it's available. This won't make it so developers never
- need to upgrade their chroots (e.g., a toolchain upgrade could
- require chroot upgrades), but at least makes it slightly more
- convenient for an average repo sync.
-
- Args:
- argv: The argument list passed to the main function, not
- including the executable path.
-
- Returns:
- None, if the re-exec did not happen, or never returns if the
- re-exec did happen.
- """
- # We only re-exec if we are inside of a chroot (since if installed
- # standalone using pip, there's already an "editable install"
- # feature for that in pip.)
- env = dict(os.environ)
- srcroot = env.get("CROS_WORKON_SRCROOT")
- if not srcroot:
- return
-
- # If for some reason we decide to move zmake in the future, then
- # we don't want to use the re-exec logic.
- zmake_path = (
- pathlib.Path(srcroot) / "src" / "platform" / "ec" / "zephyr" / "zmake"
- ).resolve()
- if not zmake_path.is_dir():
- return
-
- # If PYTHONPATH is set, it is either because we just did a
- # re-exec, or because the user wants to run a specific copy of
- # zmake. In either case, we don't want to re-exec.
- if "PYTHONPATH" in env:
- return
-
- # Set PYTHONPATH so that we run zmake from source.
- env["PYTHONPATH"] = str(zmake_path)
-
- os.execve(sys.executable, [sys.executable, "-m", "zmake", *argv], env)
-
-
-def call_with_namespace(func, namespace):
- """Call a function with arguments applied from a Namespace.
-
- Args:
- func: The callable to call.
- namespace: The namespace to apply to the callable.
-
- 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():
- pyname = name.replace("-", "_")
- if pyname in names:
- kwds[pyname] = value
- return func(**kwds)
-
-
-# Dictionary used to map log level strings to their corresponding int values.
-log_level_map = {
- "DEBUG": logging.DEBUG,
- "INFO": logging.INFO,
- "WARNING": logging.WARNING,
- "ERROR": logging.ERROR,
- "CRITICAL": logging.CRITICAL,
-}
-
-
-def main(argv=None):
- """The main function.
-
- Args:
- argv: Optionally, the command-line to parse, not including argv[0].
-
- Returns:
- Zero upon success, or non-zero upon failure.
- """
- if argv is None:
- argv = sys.argv[1:]
-
- maybe_reexec(argv)
-
- parser = argparse.ArgumentParser()
- parser.add_argument(
- "--checkout", type=pathlib.Path, help="Path to ChromiumOS checkout"
- )
- parser.add_argument(
- "-D",
- "--debug",
- action="store_true",
- default=False,
- help=("Turn on debug features (e.g., stack trace, " "verbose logging)"),
- )
- parser.add_argument(
- "-j",
- "--jobs",
- # TODO(b/178196029): ninja doesn't know how to talk to a
- # jobserver properly and spams our CPU on all cores. Default
- # to -j1 to execute sequentially until we switch to GNU Make.
- default=1,
- type=int,
- help="Degree of multiprogramming to use",
- )
- parser.add_argument(
- "-l",
- "--log-level",
- choices=list(log_level_map.keys()),
- dest="log_level",
- help="Set the logging level (default=INFO)",
- )
- parser.add_argument(
- "-L",
- "--no-log-label",
- action="store_false",
- help="Turn off logging labels",
- dest="log_label",
- default=None,
- )
- parser.add_argument(
- "--log-label",
- action="store_true",
- help="Turn on logging labels",
- dest="log_label",
- default=None,
- )
- parser.add_argument(
- "--modules-dir",
- type=pathlib.Path,
- help="The path to a directory containing all modules "
- "needed. If unspecified, zmake will assume you have "
- "a Chrome OS checkout and try locating them in the "
- "checkout.",
- )
- parser.add_argument(
- "--zephyr-base", type=pathlib.Path, help="Path to Zephyr OS repository"
- )
-
- sub = parser.add_subparsers(dest="subcommand", help="Subcommand")
- sub.required = True
-
- configure = sub.add_parser("configure")
- configure.add_argument(
- "--ignore-unsupported-zephyr-version",
- action="store_true",
- help="Don't warn about using an unsupported Zephyr version",
- )
- configure.add_argument("-t", "--toolchain", help="Name of toolchain to use")
- configure.add_argument(
- "--bringup",
- action="store_true",
- dest="bringup",
- help="Enable bringup debugging features",
- )
- configure.add_argument(
- "-B", "--build-dir", type=pathlib.Path, help="Build directory"
- )
- configure.add_argument(
- "-b",
- "--build",
- action="store_true",
- dest="build_after_configure",
- help="Run the build after configuration",
- )
- configure.add_argument(
- "--test",
- action="store_true",
- dest="test_after_configure",
- help="Test the .elf file after configuration",
- )
- configure.add_argument(
- "project_dir", type=pathlib.Path, help="Path to the project to build"
- )
- configure.add_argument(
- "-c",
- "--coverage",
- action="store_true",
- dest="coverage",
- help="Enable CONFIG_COVERAGE Kconfig.",
- )
-
- build = sub.add_parser("build")
- build.add_argument(
- "build_dir",
- type=pathlib.Path,
- help="The build directory used during configuration",
- )
- build.add_argument(
- "-w",
- "--fail-on-warnings",
- action="store_true",
- help="Exit with code 2 if warnings are detected",
- )
-
- test = sub.add_parser("test")
- test.add_argument(
- "build_dir",
- type=pathlib.Path,
- help="The build directory used during configuration",
- )
-
- sub.add_parser("testall")
-
- coverage = sub.add_parser("coverage")
- coverage.add_argument(
- "build_dir",
- type=pathlib.Path,
- help="The build directory used during configuration",
- )
-
- opts = parser.parse_args(argv)
-
- # Default logging
- log_level = logging.INFO
- log_label = False
-
- if opts.log_level:
- log_level = log_level_map[opts.log_level]
- log_label = True
- elif opts.debug:
- log_level = logging.DEBUG
- log_label = True
-
- if opts.log_label is not None:
- log_label = opts.log_label
- if log_label:
- log_format = "%(levelname)s: %(message)s"
- else:
- log_format = "%(message)s"
- multiproc.log_job_names = False
-
- logging.basicConfig(format=log_format, level=log_level)
-
- if not opts.debug:
- sys.tracebacklimit = 0
-
- try:
- zmake = call_with_namespace(zm.Zmake, opts)
- subcommand_method = getattr(zmake, opts.subcommand.replace("-", "_"))
- result = call_with_namespace(subcommand_method, opts)
- return result
- finally:
- multiproc.wait_for_log_end()
-
-
-if __name__ == "__main__":
- sys.exit(main())
diff --git a/zephyr/zmake/zmake/build_config.py b/zephyr/zmake/zmake/build_config.py
deleted file mode 100644
index 9a9c7f36a2..0000000000
--- a/zephyr/zmake/zmake/build_config.py
+++ /dev/null
@@ -1,100 +0,0 @@
-# Copyright 2020 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.
-"""Encapsulation of a build configuration."""
-
-
-import zmake.util as util
-
-
-class BuildConfig:
- """A container for build configurations.
-
- A build config is a tuple of environment variables, cmake
- variables, kconfig definitons, and kconfig files.
- """
-
- def __init__(
- self, environ_defs={}, cmake_defs={}, kconfig_defs={}, kconfig_files=[]
- ):
- self.environ_defs = dict(environ_defs)
- self.cmake_defs = dict(cmake_defs)
- self.kconfig_defs = dict(kconfig_defs)
- self.kconfig_files = kconfig_files
-
- def popen_cmake(
- self, jobclient, project_dir, build_dir, kconfig_path=None, **kwargs
- ):
- """Run Cmake with this config using a jobclient.
-
- Args:
- jobclient: A JobClient instance.
- project_dir: The project directory.
- build_dir: Directory to use for Cmake build.
- kconfig_path: The path to write out Kconfig definitions.
- kwargs: forwarded to popen.
- """
- kconfig_files = list(self.kconfig_files)
- if kconfig_path:
- util.write_kconfig_file(kconfig_path, self.kconfig_defs)
- kconfig_files.append(kconfig_path)
- elif self.kconfig_defs:
- raise ValueError(
- "Cannot start Cmake on a config with Kconfig items without a "
- "kconfig_path"
- )
-
- if kconfig_files:
- base_config = BuildConfig(
- environ_defs=self.environ_defs, cmake_defs=self.cmake_defs
- )
- conf_file_config = BuildConfig(
- cmake_defs={
- "CONF_FILE": ";".join(str(p.resolve()) for p in kconfig_files)
- }
- )
- return (base_config | conf_file_config).popen_cmake(
- jobclient, project_dir, build_dir, **kwargs
- )
-
- kwargs["env"] = dict(**kwargs.get("env", {}), **self.environ_defs)
- return jobclient.popen(
- [
- "/usr/bin/cmake",
- "-S",
- project_dir,
- "-B",
- build_dir,
- "-GNinja",
- *("-D{}={}".format(*pair) for pair in self.cmake_defs.items()),
- ],
- **kwargs
- )
-
- def __or__(self, other):
- """Combine two BuildConfig instances."""
- if not isinstance(other, BuildConfig):
- raise TypeError(
- "Unsupported operation | for {} and {}".format(type(self), type(other))
- )
-
- return BuildConfig(
- environ_defs=dict(**self.environ_defs, **other.environ_defs),
- cmake_defs=dict(**self.cmake_defs, **other.cmake_defs),
- kconfig_defs=dict(**self.kconfig_defs, **other.kconfig_defs),
- kconfig_files=list({*self.kconfig_files, *other.kconfig_files}),
- )
-
- def __repr__(self):
- return "BuildConfig({})".format(
- ", ".join(
- "{}={!r}".format(name, getattr(self, name))
- for name in [
- "environ_defs",
- "cmake_defs",
- "kconfig_defs",
- "kconfig_files",
- ]
- if getattr(self, name)
- )
- )
diff --git a/zephyr/zmake/zmake/jobserver.py b/zephyr/zmake/zmake/jobserver.py
deleted file mode 100644
index 69199a2dc8..0000000000
--- a/zephyr/zmake/zmake/jobserver.py
+++ /dev/null
@@ -1,144 +0,0 @@
-# Copyright 2020 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.
-"""Module for job counters, limiting the amount of concurrent executions."""
-
-import logging
-import multiprocessing
-import os
-import re
-import select
-import subprocess
-
-import zmake
-
-
-class JobHandle:
- """Small object to handle claim of a job."""
-
- def __init__(self, release_func, *args, **kwargs):
- self.release_func = release_func
- self.args = args
- self.kwargs = kwargs
-
- def __enter__(self):
- pass
-
- def __exit__(self, exc_type, exc_value, traceback):
- self.release_func(*self.args, **self.kwargs)
-
-
-class JobClient:
- """Abstract base class for all job clients."""
-
- def get_job(self):
- """Claim a job."""
- raise NotImplementedError("Abstract method not implemented")
-
- def env(self):
- """Get the environment variables necessary to share the job server."""
- return {}
-
- def popen(self, *args, **kwargs):
- """Start a process using subprocess.Popen
-
- All other arguments are passed to subprocess.Popen.
-
- Returns:
- A Popen object.
- """
- kwargs.setdefault("env", os.environ)
- kwargs["env"].update(self.env())
-
- logger = logging.getLogger(self.__class__.__name__)
- logger.debug("Running %s", zmake.util.repr_command(*args))
- return subprocess.Popen(*args, **kwargs)
-
- def run(self, *args, claim_job=True, **kwargs):
- """Run a process using subprocess.run, optionally claiming a job.
-
- Args:
- claim_job: True if a job should be claimed.
-
- All other arguments are passed to subprocess.run.
-
- Returns:
- A CompletedProcess object.
- """
- if claim_job:
- with self.get_job():
- return self.run(*args, claim_job=False, **kwargs)
-
- kwargs.setdefault("env", os.environ)
- kwargs["env"].update(self.env())
-
- return subprocess.run(*args, **kwargs)
-
-
-class JobServer(JobClient):
- """Abstract Job Server."""
-
- def __init__(self, jobs=0):
- raise NotImplementedError("Abstract method not implemented")
-
-
-class GNUMakeJobClient(JobClient):
- def __init__(self, read_fd, write_fd):
- self._pipe = [read_fd, write_fd]
-
- @classmethod
- def from_environ(cls, env=None):
- """Create a job client from an environment with the MAKEFLAGS variable.
-
- If we are started under a GNU Make Job Server, we can search
- the environment for a string "--jobserver-auth=R,W", where R
- and W will be the read and write file descriptors to the pipe
- respectively. If we don't find this environment variable (or
- the string inside of it), this will raise an OSError.
-
- Args:
- env: Optionally, the environment to search.
-
- Returns:
- A GNUMakeJobClient configured appropriately.
- """
- if env is None:
- env = os.environ
- makeflags = env.get("MAKEFLAGS")
- if not makeflags:
- raise OSError("MAKEFLAGS is not set in the environment")
- 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)
-
- def get_job(self):
- """Claim a job.
-
- Returns:
- A JobHandle object.
- """
- byte = os.read(self._pipe[0], 1)
- return JobHandle(lambda: os.write(self._pipe[1], byte))
-
- def env(self):
- """Get the environment variables necessary to share the job server."""
- return {"MAKEFLAGS": "--jobserver-auth={},{}".format(*self._pipe)}
-
-
-class GNUMakeJobServer(JobServer, GNUMakeJobClient):
- """Implements a GNU Make POSIX Job Server.
-
- See https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html
- for specification.
- """
-
- def __init__(self, jobs=0):
- if not jobs:
- jobs = multiprocessing.cpu_count()
- elif jobs > select.PIPE_BUF:
- jobs = select.PIPE_BUF
-
- self._pipe = os.pipe()
- os.write(self._pipe[1], b"+" * jobs)
diff --git a/zephyr/zmake/zmake/modules.py b/zephyr/zmake/zmake/modules.py
deleted file mode 100644
index 5ba0ef73f8..0000000000
--- a/zephyr/zmake/zmake/modules.py
+++ /dev/null
@@ -1,99 +0,0 @@
-# Copyright 2020 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.
-"""Registry of known Zephyr modules."""
-
-import zmake.build_config as build_config
-import zmake.util as util
-
-
-def third_party_module(name, checkout):
- """Common callback in registry for all third_party/zephyr modules.
-
- Args:
- name: The name of the module.
- checkout: The path to the chromiumos source.
-
- Return:
- The path to the module module.
- """
- return checkout / "src" / "third_party" / "zephyr" / name
-
-
-known_modules = {
- "hal_stm32": third_party_module,
- "cmsis": third_party_module,
- "ec": lambda name, checkout: (checkout / "src" / "platform" / "ec"),
- "nanopb": third_party_module,
-}
-
-
-def locate_from_checkout(checkout_dir):
- """Find modules from a Chrome OS checkout.
-
- Important: this function should only conditionally be called if a
- checkout exists. Zmake *can* be used without a Chrome OS source
- tree. You should call locate_from_directory if outside of a
- Chrome OS source tree.
-
- Args:
- checkout_dir: The path to the chromiumos source.
-
- Returns:
- A dictionary mapping module names to paths.
- """
- result = {}
- for name, locator in known_modules.items():
- result[name] = locator(name, checkout_dir)
- return result
-
-
-def locate_from_directory(directory):
- """Create a modules dictionary from a directory.
-
- This takes a directory, and searches for the known module names
- located in it.
-
- Args:
- directory: the directory to search in.
-
- Returns:
- A dictionary mapping module names to paths.
- """
- result = {}
-
- for name in known_modules:
- modpath = (directory / name).resolve()
- if (modpath / "zephyr" / "module.yml").is_file():
- result[name] = modpath
-
- return result
-
-
-def setup_module_symlinks(output_dir, modules):
- """Setup a directory with symlinks to modules.
-
- Args:
- output_dir: The directory to place the symlinks in.
- modules: A dictionary of module names mapping to paths.
-
- Returns:
- The resultant BuildConfig that should be applied to use each
- of these modules.
- """
- if not output_dir.exists():
- output_dir.mkdir(parents=True)
-
- module_links = []
-
- for name, path in modules.items():
- link_path = output_dir.resolve() / name
- util.update_symlink(path, link_path)
- module_links.append(link_path)
-
- if module_links:
- return build_config.BuildConfig(
- cmake_defs={"ZEPHYR_MODULES": ";".join(map(str, module_links))}
- )
- else:
- return build_config.BuildConfig()
diff --git a/zephyr/zmake/zmake/multiproc.py b/zephyr/zmake/zmake/multiproc.py
deleted file mode 100644
index 5e98374c8c..0000000000
--- a/zephyr/zmake/zmake/multiproc.py
+++ /dev/null
@@ -1,322 +0,0 @@
-# Copyright 2020 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.
-import collections
-import logging
-import os
-import select
-import threading
-
-"""Zmake multiprocessing utility module.
-
-This module is used to aid in zmake's multiprocessing. It contains tools
-available to log output from multiple processes on the fly. This means that a
-process does not need to finish before the output is available to the developer
-on the screen.
-"""
-
-# 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()
-# A condition variable used to synchronize logging operations.
-_logging_cv = threading.Condition()
-# A map of file descriptors to their LogWriter
-_logging_map = {}
-# Should we log job names or not
-log_job_names = True
-
-
-def reset():
- """Reset this module to its starting state (useful for tests)"""
- global _logging_map
-
- _logging_map = {}
-
-
-class LogWriter:
- """Contains information about a file descriptor that is producing output
-
- There is typically one of these for each file descriptor that a process is
- writing to while running (stdout and stderr).
-
- Properties:
- _logger: The logger object to use.
- _log_level: The logging level to use.
- _override_func: A function used to override the log level. The
- function will be called once per line prior to logging and will be
- passed the arguments of the line and the default log level.
- _written_at_level: dict:
- key: log_level
- value: True if output was written at that level
- _job_id: The name to prepend to logged lines
- _file_descriptor: The file descriptor being logged.
- """
-
- def __init__(
- self, logger, log_level, log_level_override_func, job_id, file_descriptor
- ):
- self._logger = logger
- self._log_level = log_level
- self._override_func = log_level_override_func
- # A map whether output was printed at each logging level
- self._written_at_level = collections.defaultdict(lambda: False)
- self._job_id = job_id
- self._file_descriptor = file_descriptor
-
- def log_line(self, line):
- """Log a line of output
-
- If the log-level override function requests a change in log level, that
- causes self._log_level to be updated accordingly.
-
- Args:
- line: Text line to log
- """
- if self._override_func:
- # Get the new log level and update the default. The reason we
- # want to update the default is that if we hit an error, all
- # future logging should be moved to the new logging level. This
- # greatly simplifies the logic that is needed to update the log
- # level.
- self._log_level = self._override_func(line, self._log_level)
- if self._job_id and log_job_names:
- self._logger.log(self._log_level, "[%s]%s", self._job_id, line)
- else:
- self._logger.log(self._log_level, line)
- self._written_at_level[self._log_level] = True
-
- def has_written(self, log_level):
- """Check if output was written at a certain log level
-
- Args:
- log_level: log level to check
-
- Returns:
- True if any output was written at that log level, False if not
- """
- return self._written_at_level[log_level]
-
- def wait(self):
- """Wait for this LogWriter to finish.
-
- This method will block execution until all the logs have been flushed out.
- """
- with _logging_cv:
- _logging_cv.wait_for(lambda: self._file_descriptor not in _logging_map)
-
-
-def _log_fd(fd):
- """Log information from a single file descriptor.
-
- This function is BLOCKING. It will read from the given file descriptor until
- either the end of line is read or EOF. Once EOF is read it will remove the
- file descriptor from _logging_map so it will no longer be used.
- Additionally, in some cases, the file descriptor will be closed (caused by
- a call to Popen.wait()). In these cases, the file descriptor will also be
- removed from the map as it is no longer valid.
- """
- with _logging_cv:
- writer = _logging_map[fd]
- if fd.closed:
- del _logging_map[fd]
- _logging_cv.notify_all()
- return
- line = fd.readline()
- if not line:
- # EOF
- del _logging_map[fd]
- _logging_cv.notify_all()
- return
- line = line.rstrip("\n")
- if line:
- writer.log_line(line)
-
-
-def _prune_logging_fds():
- """Prune the current file descriptors under _logging_map.
-
- This function will iterate over the logging map and check for closed file
- descriptors. Every closed file descriptor will be removed.
- """
- with _logging_cv:
- remove = [fd for fd in _logging_map.keys() if fd.closed]
- for fd in remove:
- del _logging_map[fd]
- if remove:
- _logging_cv.notify_all()
-
-
-def _logging_loop():
- """The primary logging thread loop.
-
- This is the entry point of the logging thread. It will listen for (1) any
- new data on the output file descriptors that were added via log_output() and
- (2) any new file descriptors being added by log_output(). Once a file
- descriptor is ready to be read, this function will call _log_fd to perform
- the actual read and logging.
- """
- while True:
- with _logging_cv:
- _logging_cv.wait_for(lambda: _logging_map)
- keys = list(_logging_map.keys()) + [_logging_interrupt_pipe[0]]
- try:
- fds, _, _ = select.select(keys, [], [])
- except ValueError:
- # One of the file descriptors must be closed, prune them and try
- # again.
- _prune_logging_fds()
- continue
- if _logging_interrupt_pipe[0] in fds:
- # We got a dummy byte sent by log_output(), this is a signal used to
- # break out of the blocking select.select call to tell us that the
- # file descriptor set has changed. We just need to read the byte and
- # remove this descriptor from the list. If we actually have data
- # that should be read it will be read in the for loop below.
- os.read(_logging_interrupt_pipe[0], 1)
- fds.remove(_logging_interrupt_pipe[0])
- for fd in fds:
- _log_fd(fd)
-
-
-_logging_thread = None
-
-
-def log_output(
- logger, log_level, file_descriptor, log_level_override_func=None, job_id=None
-):
- """Log the output from the given file descriptor.
-
- Args:
- logger: The logger object to use.
- log_level: The logging level to use.
- file_descriptor: The file descriptor to read from.
- log_level_override_func: A function used to override the log level. The
- function will be called once per line prior to logging and will be
- passed the arguments of the line and the default log level.
-
- Returns:
- LogWriter object for the resulting output
- """
- with _logging_cv:
- global _logging_thread
- if _logging_thread is None or not _logging_thread.is_alive():
- # First pass or thread must have died, create a new one.
- _logging_thread = threading.Thread(target=_logging_loop, daemon=True)
- _logging_thread.start()
-
- writer = LogWriter(
- logger, log_level, log_level_override_func, job_id, file_descriptor
- )
- _logging_map[file_descriptor] = writer
- # Write a dummy byte to the pipe to break the select so we can add the
- # new fd.
- os.write(_logging_interrupt_pipe[1], b"x")
- # Notify the condition so we can run the select on the current fds.
- _logging_cv.notify_all()
- return writer
-
-
-def wait_for_log_end():
- """Wait for all the logs to be printed.
-
- This method will block execution until all the logs have been flushed out.
- """
- with _logging_cv:
- _logging_cv.wait_for(lambda: not _logging_map)
-
-
-class Executor:
- """Parallel executor helper class.
-
- This class is used to run multiple functions in parallel. The functions MUST
- return an integer result code (or throw an exception). This class will start
- a thread per operation and wait() for all the threads to resolve.
-
- Attributes:
- lock: The condition variable used to synchronize across threads.
- threads: A list of threading.Thread objects currently under this
- Executor.
- results: A list of result codes returned by each of the functions called
- by this Executor.
- """
-
- def __init__(self):
- self.lock = threading.Condition()
- self.threads = []
- self.results = []
- self.logger = logging.getLogger(self.__class__.__name__)
-
- def append(self, func):
- """Append the given function to the wait list.
-
- Once added, the function's return value will be used to determine the
- Executor's final result value. The function must return an int result
- code or throw an exception. For example: If two functions were added
- to the Executor, they will both be run in parallel and their results
- will determine whether or not the Executor succeeded. If both functions
- returned 0, then the Executor's wait function will also return 0.
-
- Args:
- func: A function which returns an int result code or throws an
- exception.
- """
- with self.lock:
- thread = threading.Thread(target=lambda: self._run_fn(func), daemon=True)
- thread.start()
- self.threads.append(thread)
-
- def wait(self):
- """Wait for a result to be available.
-
- This function waits for the executor to resolve (i.e., all
- threads have finished).
-
- Returns:
- An integer result code of either the first failed function or 0 if
- they all succeeded.
- """
- with self.lock:
- self.lock.wait_for(predicate=lambda: self._is_finished)
- return self._result
-
- def _run_fn(self, func):
- """Entry point to each running thread.
-
- This function will run the function provided in the append() function.
- The result value of the function will be used to determine the
- Executor's result value. If the function throws any exception it will be
- caught and -1 will be used as the assumed result value.
-
- Args:
- func: The function to run.
- """
- try:
- result = func()
- except Exception as ex:
- self.logger.exception(ex)
- result = -1
- with self.lock:
- self.results.append(result)
- self.lock.notify_all()
-
- @property
- def _is_finished(self):
- """Whether or not the Executor is considered to be done.
-
- Returns:
- True if the Executor is considered done.
- """
- if len(self.threads) == len(self.results):
- return True
- return False
-
- @property
- def _result(self):
- """The result code of the Executor.
-
- Note that _is_finished must be True for this to have any meaning.
-
- Returns:
- An int representing the result value of the underlying functions.
- """
- return next((result for result in self.results if result), 0)
diff --git a/zephyr/zmake/zmake/output_packers.py b/zephyr/zmake/zmake/output_packers.py
deleted file mode 100644
index 1ba38cf96c..0000000000
--- a/zephyr/zmake/zmake/output_packers.py
+++ /dev/null
@@ -1,230 +0,0 @@
-# Copyright 2020 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.
-"""Types which provide many builds and composite them into a single binary."""
-import logging
-import shutil
-import subprocess
-
-import zmake.build_config as build_config
-import zmake.multiproc
-import zmake.util as util
-
-
-class BasePacker:
- """Abstract base for all packers."""
-
- def __init__(self, project):
- self.project = project
-
- def configs(self):
- """Get all of the build configurations necessary.
-
- Yields:
- 2-tuples of config name and a BuildConfig.
- """
- yield "singleimage", build_config.BuildConfig()
-
- def pack_firmware(self, work_dir, jobclient, version_string=""):
- """Pack a firmware image.
-
- Config names from the configs generator are passed as keyword
- arguments, with each argument being set to the path of the
- build directory.
-
- Args:
- work_dir: A directory to write outputs and temporary files
- into.
- jobclient: A JobClient object to use.
- version_string: The version string, which may end up in
- certain parts of the outputs.
-
- Yields:
- 2-tuples of the path of each file in the work_dir (or any
- other directory) which should be copied into the output
- directory, and the output filename.
- """
- raise NotImplementedError("Abstract method not implemented")
-
- def _get_max_image_bytes(self):
- """Get the maximum allowed image size (in bytes).
-
- This value will generally be found in CONFIG_FLASH_SIZE but may vary
- depending on the specific way things are being packed.
-
- Returns:
- The maximum allowed size of the image in bytes.
- """
- raise NotImplementedError("Abstract method not implemented")
-
- def _is_size_bound(self, path):
- """Check whether the given path should be constrained by size.
-
- Generally, .elf files will be unconstrained while .bin files will be
- constrained.
-
- Args:
- path: A file's path to test.
-
- Returns:
- True if the file size should be checked. False otherwise.
- """
- return path.suffix == ".bin"
-
- def _check_packed_file_size(self, file, dirs):
- """Check that a packed file passes size constraints.
-
- Args:
- file: A file to test.
- dirs: A map of the arguments to pass to _get_max_image_bytes
-
- Returns:
- The file if it passes the test.
- """
- if not self._is_size_bound(
- file
- ) or file.stat().st_size <= self._get_max_image_bytes(**dirs):
- return file
- raise RuntimeError("Output file ({}) too large".format(file))
-
-
-class ElfPacker(BasePacker):
- """Raw proxy for ELF output of a single build."""
-
- def pack_firmware(self, work_dir, jobclient, singleimage, version_string=""):
- yield singleimage / "zephyr" / "zephyr.elf", "zephyr.elf"
-
-
-class RawBinPacker(BasePacker):
- """Raw proxy for zephyr.bin output of a single build."""
-
- def pack_firmware(self, work_dir, jobclient, singleimage, version_string=""):
- yield singleimage / "zephyr" / "zephyr.bin", "zephyr.bin"
-
-
-class BinmanPacker(BasePacker):
- """Packer for RO/RW image to generate a .bin build using FMAP."""
-
- ro_file = "zephyr.bin"
- rw_file = "zephyr.bin"
-
- def __init__(self, project):
- self.logger = logging.getLogger(self.__class__.__name__)
- super().__init__(project)
-
- def configs(self):
- yield "ro", build_config.BuildConfig(kconfig_defs={"CONFIG_CROS_EC_RO": "y"})
- yield "rw", build_config.BuildConfig(kconfig_defs={"CONFIG_CROS_EC_RW": "y"})
-
- def pack_firmware(self, work_dir, jobclient, ro, rw, version_string=""):
- """Pack RO and RW sections using Binman.
-
- Binman configuration is expected to be found in the RO build
- device-tree configuration.
-
- Args:
- work_dir: The directory used for packing.
- jobclient: The client used to run subprocesses.
- ro: Directory containing the RO image build.
- rw: Directory containing the RW image build.
- version_string: The version string to use in FRID/FWID.
-
- Yields:
- 2-tuples of the path of each file in the work_dir that
- should be copied into the output directory, and the output
- filename.
- """
- dts_file_path = ro / "zephyr" / "zephyr.dts"
-
- # Copy the inputs into the work directory so that Binman can
- # find them under a hard-coded name.
- shutil.copy2(ro / "zephyr" / self.ro_file, work_dir / "zephyr_ro.bin")
- shutil.copy2(rw / "zephyr" / self.rw_file, work_dir / "zephyr_rw.bin")
-
- # Version in FRID/FWID can be at most 31 bytes long (32, minus
- # one for null character).
- if len(version_string) > 31:
- version_string = version_string[:31]
-
- proc = jobclient.popen(
- [
- "binman",
- "-v",
- "5",
- "build",
- "-a",
- "version={}".format(version_string),
- "-d",
- dts_file_path,
- "-m",
- "-O",
- work_dir,
- ],
- cwd=work_dir,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- encoding="utf-8",
- )
-
- zmake.multiproc.log_output(self.logger, logging.DEBUG, proc.stdout)
- zmake.multiproc.log_output(self.logger, logging.ERROR, proc.stderr)
- if proc.wait(timeout=60):
- raise OSError("Failed to run binman")
-
- yield work_dir / "zephyr.bin", "zephyr.bin"
- yield ro / "zephyr" / "zephyr.elf", "zephyr.ro.elf"
- yield rw / "zephyr" / "zephyr.elf", "zephyr.rw.elf"
-
-
-class NpcxPacker(BinmanPacker):
- """Packer for RO/RW image to generate a .bin build using FMAP.
-
- This expects that the build is setup to generate a
- zephyr.npcx.bin for the RO image, which should be packed using
- Nuvoton's loader format.
- """
-
- ro_file = "zephyr.npcx.bin"
- npcx_monitor = "npcx_monitor.bin"
-
- # TODO(b/192401039): CONFIG_FLASH_SIZE is nuvoton-only. Since
- # binman already checks sizes, perhaps we can just remove this
- # code?
- def _get_max_image_bytes(self, ro, rw):
- ro_size = util.read_kconfig_autoconf_value(
- ro / "zephyr" / "include" / "generated", "CONFIG_FLASH_SIZE"
- )
- rw_size = util.read_kconfig_autoconf_value(
- ro / "zephyr" / "include" / "generated", "CONFIG_FLASH_SIZE"
- )
- return max(int(ro_size, 0), int(rw_size, 0)) * 1024
-
- # This can probably be removed too and just rely on binman to
- # check the sizes... see the comment above.
- def pack_firmware(self, work_dir, jobclient, ro, rw, version_string=""):
- for path, output_file in super().pack_firmware(
- work_dir,
- jobclient,
- ro,
- rw,
- version_string=version_string,
- ):
- if output_file == "zephyr.bin":
- yield (
- self._check_packed_file_size(path, {"ro": ro, "rw": rw}),
- "zephyr.bin",
- )
- else:
- yield path, output_file
-
- # Include the NPCX monitor file as an output artifact.
- yield ro / self.npcx_monitor, self.npcx_monitor
-
-
-# A dictionary mapping packer config names to classes.
-packer_registry = {
- "binman": BinmanPacker,
- "elf": ElfPacker,
- "npcx": NpcxPacker,
- "raw": RawBinPacker,
-}
diff --git a/zephyr/zmake/zmake/project.py b/zephyr/zmake/zmake/project.py
deleted file mode 100644
index 84151a90b3..0000000000
--- a/zephyr/zmake/zmake/project.py
+++ /dev/null
@@ -1,248 +0,0 @@
-# Copyright 2020 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.
-"""Module for project config wrapper object."""
-
-import logging
-import pathlib
-import warnings
-
-import yaml
-
-import zmake.build_config as build_config
-import zmake.modules as modules
-import zmake.output_packers as packers
-import zmake.toolchains as toolchains
-import zmake.util as util
-
-# The version of jsonschema in the chroot has a bunch of
-# DeprecationWarnings that fire when we import it. Suppress these
-# during the import to keep the noise down.
-with warnings.catch_warnings():
- warnings.simplefilter("ignore")
- import jsonschema
-
-
-def module_dts_overlay_name(modpath, board_name):
- """Given a board name, return the expected DTS overlay path.
-
- Args:
- modpath: the module path as a pathlib.Path object
- board_name: the name of the board
-
- Returns:
- A pathlib.Path object to the expected overlay path.
- """
- return modpath / "zephyr" / "dts" / "board-overlays" / "{}.dts".format(board_name)
-
-
-def find_projects(root_dir):
- """Finds all zmake projects in root_dir.
-
- Args:
- root_dir: the root dir as a pathlib.Path object
-
- Yields:
- Project: The next project found.
- """
- logging.info("Finding zmake targets under '%s'.", root_dir)
- for path in pathlib.Path(root_dir).rglob("zmake.yaml"):
- yield Project(path.parent)
-
-
-class ProjectConfig:
- """An object wrapping zmake.yaml."""
-
- validator = jsonschema.Draft7Validator
- schema = {
- "type": "object",
- "required": [
- "board",
- "output-type",
- "supported-toolchains",
- "supported-zephyr-versions",
- ],
- "properties": {
- "supported-zephyr-versions": {
- "type": "array",
- "items": {
- "type": "string",
- "enum": ["v2.6"],
- },
- "minItems": 1,
- "uniqueItems": True,
- },
- "board": {
- "type": "string",
- },
- "modules": {
- "type": "array",
- "items": {
- "type": "string",
- "enum": list(modules.known_modules),
- },
- },
- "output-type": {
- "type": "string",
- "enum": list(packers.packer_registry),
- },
- "supported-toolchains": {
- "type": "array",
- "items": {
- "type": "string",
- "enum": list(toolchains.support_classes),
- },
- },
- "is-test": {
- "type": "boolean",
- },
- "dts-overlays": {
- "type": "array",
- "items": {
- "type": "string",
- },
- },
- },
- }
-
- def __init__(self, config_dict):
- self.validator.check_schema(self.schema)
- jsonschema.validate(config_dict, self.schema, cls=self.validator)
- self.config_dict = config_dict
-
- @property
- def supported_zephyr_versions(self):
- return [
- util.parse_zephyr_version(x)
- for x in self.config_dict["supported-zephyr-versions"]
- ]
-
- @property
- def board(self):
- return self.config_dict["board"]
-
- @property
- def modules(self):
- return self.config_dict.get("modules", list(modules.known_modules))
-
- @property
- def output_packer(self):
- return packers.packer_registry[self.config_dict["output-type"]]
-
- @property
- def supported_toolchains(self):
- return self.config_dict["supported-toolchains"]
-
- @property
- def is_test(self):
- return self.config_dict.get("is-test", False)
-
- @property
- def dts_overlays(self):
- return self.config_dict.get("dts-overlays", [])
-
-
-class Project:
- """An object encapsulating a project directory."""
-
- def __init__(self, project_dir, config_dict=None):
- self.project_dir = project_dir.resolve()
- if not config_dict:
- with open(self.project_dir / "zmake.yaml") as f:
- config_dict = yaml.safe_load(f)
- self.config = ProjectConfig(config_dict)
- self.packer = self.config.output_packer(self)
-
- def iter_builds(self):
- """Iterate thru the build combinations provided by the project's packer.
-
- Yields:
- 2-tuples of a build configuration name and a BuildConfig.
- """
- conf = build_config.BuildConfig(cmake_defs={"BOARD": self.config.board})
- prj_conf = self.project_dir / "prj.conf"
- if prj_conf.is_file():
- conf |= build_config.BuildConfig(kconfig_files=[prj_conf])
- for build_name, packer_config in self.packer.configs():
- yield build_name, conf | packer_config
-
- def find_dts_overlays(self, modules):
- """Find appropriate dts overlays from registered modules.
-
- Args:
- modules: A dictionary of module names mapping to paths.
-
- Returns:
- A BuildConfig with relevant configurations to enable the
- found DTS overlay files.
- """
- overlays = []
- for module_path in modules.values():
- dts_path = module_dts_overlay_name(module_path, self.config.board)
- if dts_path.is_file():
- overlays.append(dts_path.resolve())
-
- overlays.extend(self.project_dir / f for f in self.config.dts_overlays)
-
- if overlays:
- return build_config.BuildConfig(
- cmake_defs={"DTC_OVERLAY_FILE": ";".join(map(str, overlays))}
- )
- else:
- return build_config.BuildConfig()
-
- def prune_modules(self, module_paths):
- """Reduce a modules dict to the ones required by this project.
-
- If this project does not define a modules list in the
- configuration, it is assumed that all known modules to Zmake
- are required. This is typically inconsequential as Zephyr
- module design conventions require a Kconfig option to actually
- enable most modules.
-
- Args:
- module_paths: A dictionary mapping module names to their
- paths. This dictionary is not modified.
-
- Returns:
- A new module_paths dictionary with only the modules
- required by this project.
-
- Raises:
- A KeyError, if a required module is unavailable.
- """
- result = {}
- for module in self.config.modules:
- try:
- result[module] = module_paths[module]
- except KeyError as e:
- raise KeyError(
- "The {!r} module is required by the {} project, but is not "
- "available.".format(module, self.project_dir)
- ) from e
- return result
-
- def get_toolchain(self, module_paths, override=None):
- if override:
- if override not in self.config.supported_toolchains:
- logging.warning(
- "Toolchain %r isn't supported by this project. You're on your own.",
- override,
- )
- support_class = toolchains.support_classes.get(
- override, toolchains.GenericToolchain
- )
- return support_class(name=override, modules=module_paths)
- else:
- for name in self.config.supported_toolchains:
- support_class = toolchains.support_classes[name]
- toolchain = support_class(name=name, modules=module_paths)
- if toolchain.probe():
- logging.info("Toolchain %r selected by probe function.", toolchain)
- return toolchain
- raise OSError(
- "No supported toolchains could be found on your system. If you see "
- "this message in the chroot, it indicates a bug. Otherwise, you'll "
- "either want to setup your system with a supported toolchain, or "
- "manually select an unsupported toolchain with the -t flag."
- )
diff --git a/zephyr/zmake/zmake/toolchains.py b/zephyr/zmake/zmake/toolchains.py
deleted file mode 100644
index 924448aec5..0000000000
--- a/zephyr/zmake/zmake/toolchains.py
+++ /dev/null
@@ -1,154 +0,0 @@
-# Copyright 2020 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.
-"""Definitions of toolchain variables."""
-
-import os
-import pathlib
-
-import zmake.build_config as build_config
-
-
-class GenericToolchain:
- """Default toolchain if not known to zmake.
-
- Simply pass ZEPHYR_TOOLCHAIN_VARIANT=name to the build, with
- nothing extra.
- """
-
- def __init__(self, name, modules=None):
- self.name = name
- self.modules = modules or {}
-
- def probe(self):
- """Probe if the toolchain is available on the system."""
- # Since the toolchain is not known to zmake, we have no way to
- # know if it's installed. Simply return False to indicate not
- # installed. An unknown toolchain would only be used if -t
- # was manually passed to zmake, and is not valid to put in a
- # zmake.yaml file.
- return False
-
- def get_build_config(self):
- """Get the build configuration for the toolchain.
-
- Returns:
- A build_config.BuildConfig to be applied to the build.
- """
- return build_config.BuildConfig(
- cmake_defs={
- "ZEPHYR_TOOLCHAIN_VARIANT": self.name,
- },
- )
-
-
-class CorebootSdkToolchain(GenericToolchain):
- def probe(self):
- # For now, we always assume it's at /opt/coreboot-sdk, since
- # that's where it's installed in the chroot. We may want to
- # consider adding support for a coreboot-sdk built in the
- # user's home directory, for example, which happens if a
- # "make crossgcc" is done from the coreboot repository.
- return pathlib.Path("/opt/coreboot-sdk").is_dir()
-
- def get_build_config(self):
- return (
- build_config.BuildConfig(
- cmake_defs={
- "TOOLCHAIN_ROOT": str(self.modules["ec"] / "zephyr"),
- },
- )
- | super().get_build_config()
- )
-
-
-class ZephyrToolchain(GenericToolchain):
- def __init__(self, *args, **kwargs):
- self.zephyr_sdk_install_dir = self._find_zephyr_sdk()
- super().__init__(*args, **kwargs)
-
- @staticmethod
- def _find_zephyr_sdk():
- """Find the Zephyr SDK, if it's installed.
-
- Returns:
- The path to the Zephyr SDK, using the search rules defined by
- https://docs.zephyrproject.org/latest/getting_started/installation_linux.html,
- or None, if one cannot be found on the system.
- """
- from_env = os.getenv("ZEPHYR_SDK_INSTALL_DIR")
- if from_env:
- return pathlib.Path(from_env)
-
- def _gen_sdk_paths():
- for prefix in (
- "~",
- "~/.local",
- "~/.local/opt",
- "~/bin",
- "/opt",
- "/usr",
- "/usr/local",
- ):
- prefix = pathlib.Path(os.path.expanduser(prefix))
- yield prefix / "zephyr-sdk"
- yield from prefix.glob("zephyr-sdk-*")
-
- for path in _gen_sdk_paths():
- if (path / "sdk_version").is_file():
- return path
-
- return None
-
- def probe(self):
- return bool(self.zephyr_sdk_install_dir)
-
- def get_build_config(self):
- assert self.zephyr_sdk_install_dir
- tc_vars = {
- "ZEPHYR_SDK_INSTALL_DIR": str(self.zephyr_sdk_install_dir),
- }
- return (
- build_config.BuildConfig(
- environ_defs=tc_vars,
- cmake_defs=tc_vars,
- )
- | super().get_build_config()
- )
-
-
-class LlvmToolchain(GenericToolchain):
- def probe(self):
- # TODO: differentiate chroot llvm path vs. something more
- # generic?
- return pathlib.Path("/usr/bin/x86_64-pc-linux-gnu-clang").exists()
-
- def get_build_config(self):
- # TODO: this contains custom settings for the chroot. Plumb a
- # toolchain for "generic-llvm" for external uses?
- return (
- build_config.BuildConfig(
- cmake_defs={
- "TOOLCHAIN_ROOT": str(self.modules["ec"] / "zephyr"),
- },
- )
- | super().get_build_config()
- )
-
-
-class HostToolchain(GenericToolchain):
- def probe(self):
- # "host" toolchain for Zephyr means GCC.
- for search_path in os.getenv("PATH", "/usr/bin").split(":"):
- if (pathlib.Path(search_path) / "gcc").exists():
- return True
- return False
-
-
-# Mapping of toolchain names -> support class
-support_classes = {
- "coreboot-sdk": CorebootSdkToolchain,
- "host": HostToolchain,
- "llvm": LlvmToolchain,
- "zephyr": ZephyrToolchain,
-}
diff --git a/zephyr/zmake/zmake/util.py b/zephyr/zmake/zmake/util.py
deleted file mode 100644
index 455cb7c9d6..0000000000
--- a/zephyr/zmake/zmake/util.py
+++ /dev/null
@@ -1,255 +0,0 @@
-# Copyright 2020 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.
-"""Common miscellaneous utility functions for zmake."""
-
-import os
-import pathlib
-import re
-import shlex
-
-
-def c_str(input_str):
- """Make a string that can be included as a literal in C source code.
-
- Args:
- input_str: The string to process.
-
- Returns:
- A string which can be included in C source code.
- """
-
- def c_chr(char):
- # Convert a char in a string to the C representation. Per the
- # C standard, we can use all characters but quote, newline,
- # and backslash directly with no replacements.
- return {
- '"': r"\"",
- "\n": r"\n",
- "\\": "\\\\",
- }.get(char, char)
-
- return '"{}"'.format("".join(map(c_chr, input_str)))
-
-
-def locate_cros_checkout():
- """Find the path to the ChromiumOS checkout.
-
- Returns:
- The first directory found with a .repo directory in it,
- starting by checking the CROS_WORKON_SRCROOT environment
- variable, then scanning upwards from the current directory,
- and finally from a known set of common paths.
- """
-
- def propose_checkouts():
- yield os.getenv("CROS_WORKON_SRCROOT")
-
- path = pathlib.Path.cwd()
- while path.resolve() != pathlib.Path("/"):
- yield path
- path = path / ".."
-
- yield "/mnt/host/source"
- yield pathlib.Path.home() / "trunk"
- yield pathlib.Path.home() / "chromiumos"
-
- for path in propose_checkouts():
- if not path:
- continue
- path = pathlib.Path(path)
- if (path / ".repo").is_dir():
- return path.resolve()
-
- raise FileNotFoundError("Unable to locate a ChromiumOS checkout")
-
-
-def locate_zephyr_base(checkout, version):
- """Locate the path to the Zephyr RTOS in a ChromiumOS checkout.
-
- Args:
- checkout: The path to the ChromiumOS checkout.
- version: The requested zephyr version, as a tuple of integers.
-
- Returns:
- The path to the Zephyr source.
- """
- return (
- checkout
- / "src"
- / "third_party"
- / "zephyr"
- / "main"
- / "v{}.{}".format(*version[:2])
- )
-
-
-def read_kconfig_file(path):
- """Parse a Kconfig file.
-
- Args:
- path: The path to open.
-
- Returns:
- A dictionary of kconfig items to their values.
- """
- result = {}
- with open(path) as f:
- for line in f:
- line, _, _ = line.partition("#")
- line = line.strip()
- if line:
- name, _, value = line.partition("=")
- result[name.strip()] = value.strip()
- return result
-
-
-def read_kconfig_autoconf_value(path, key):
- """Parse an autoconf.h file for a resolved kconfig value
-
- Args:
- path: The path to the autoconf.h file.
- key: The define key to lookup.
-
- Returns:
- The value associated with the key or nothing if the key wasn't found.
- """
- prog = re.compile(r"^#define\s{}\s(\S+)$".format(key))
- with open(path / "autoconf.h") as f:
- for line in f:
- m = prog.match(line)
- if m:
- return m.group(1)
-
-
-def write_kconfig_file(path, config, only_if_changed=True):
- """Write out a dictionary to Kconfig format.
-
- Args:
- path: The path to write to.
- config: The dictionary to write.
- only_if_changed: Set to True if the file should not be written
- unless it has changed.
- """
- if only_if_changed:
- if path.exists() and read_kconfig_file(path) == config:
- return
- with open(path, "w") as f:
- for name, value in config.items():
- f.write("{}={}\n".format(name, value))
-
-
-def parse_zephyr_version(version_string):
- """Parse a human-readable version string (e.g., "v2.4") as a tuple.
-
- Args:
- version_string: The human-readable version string.
-
- Returns:
- A 2-tuple or 3-tuple of integers representing the version.
- """
- match = re.fullmatch(r"v?(\d+)[._](\d+)(?:[._](\d+))?", version_string)
- if not match:
- raise ValueError(
- "{} does not look like a Zephyr version.".format(version_string)
- )
- return tuple(int(x) for x in match.groups() if x is not None)
-
-
-def read_zephyr_version(zephyr_base):
- """Read the Zephyr version from a Zephyr OS checkout.
-
- Args:
- zephyr_base: path to the Zephyr OS repository.
-
- Returns:
- A 3-tuple of the version number (major, minor, patchset).
- """
- version_file = pathlib.Path(zephyr_base) / "VERSION"
-
- file_vars = {}
- with open(version_file) as f:
- for line in f:
- key, sep, value = line.partition("=")
- file_vars[key.strip()] = value.strip()
-
- return (
- int(file_vars["VERSION_MAJOR"]),
- int(file_vars["VERSION_MINOR"]),
- int(file_vars["PATCHLEVEL"]),
- )
-
-
-def repr_command(argv):
- """Represent an argument array as a string.
-
- Args:
- argv: The arguments of the command.
-
- Returns:
- A string which could be pasted into a shell for execution.
- """
- return " ".join(shlex.quote(str(arg)) for arg in argv)
-
-
-def update_symlink(target_path, link_path):
- """Create a symlink if it does not exist, or links to a different path.
-
- Args:
- target_path: A Path-like object of the desired symlink path.
- link_path: A Path-like object of the symlink.
- """
- target = target_path.resolve()
- if (
- not link_path.is_symlink()
- or pathlib.Path(os.readlink(link_path)).resolve() != target
- ):
- if link_path.exists():
- link_path.unlink()
- link_path.symlink_to(target)
-
-
-def log_multi_line(logger, level, message):
- """Log a potentially multi-line message to the logger.
-
- Args:
- logger: The Logger object to log to.
- level: The logging level to use when logging.
- message: The (potentially) multi-line message to log.
- """
- for line in message.splitlines():
- if line:
- logger.log(level, line)
-
-
-def resolve_build_dir(platform_ec_dir, project_dir, build_dir):
- """Resolve the build directory using platform/ec/build/... as default.
-
- Args:
- platform_ec_dir: The path to the chromiumos source's platform/ec
- directory.
- project_dir: The directory of the project.
- build_dir: The directory to build in (may be None).
- Returns:
- The resolved build directory (using build_dir if not None).
- """
- if build_dir:
- return build_dir
-
- if not pathlib.Path.exists(project_dir / "zmake.yaml"):
- raise OSError("Invalid configuration")
-
- # Resolve project_dir to absolute path.
- project_dir = project_dir.resolve()
-
- # Compute the path of project_dir relative to platform_ec_dir.
- project_relative_path = pathlib.Path.relative_to(project_dir, platform_ec_dir)
-
- # Make sure that the project_dir is a subdirectory of platform_ec_dir.
- if platform_ec_dir / project_relative_path != project_dir:
- raise OSError(
- "Can't resolve project directory {} which is not a subdirectory"
- " of the platform/ec directory {}".format(project_dir, platform_ec_dir)
- )
-
- return platform_ec_dir / "build" / project_relative_path
diff --git a/zephyr/zmake/zmake/version.py b/zephyr/zmake/zmake/version.py
deleted file mode 100644
index 47aba6d804..0000000000
--- a/zephyr/zmake/zmake/version.py
+++ /dev/null
@@ -1,166 +0,0 @@
-# Copyright 2021 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import datetime
-import getpass
-import io
-import os
-import platform
-import subprocess
-
-import zmake.util as util
-
-
-def _get_num_commits(repo):
- """Get the number of commits that have been made.
-
- If a Git repository is available, return the number of commits that have
- been made. Otherwise return a fixed count.
-
- Args:
- repo: The path to the git repo.
-
- Returns:
- An integer, the number of commits that have been made.
- """
- try:
- result = subprocess.run(
- ["git", "-C", repo, "rev-list", "HEAD", "--count"],
- check=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.DEVNULL,
- encoding="utf-8",
- )
- except subprocess.CalledProcessError:
- commits = "9999"
- else:
- commits = result.stdout
-
- return int(commits)
-
-
-def _get_revision(repo):
- """Get the current revision hash.
-
- If a Git repository is available, return the hash of the current index.
- Otherwise return the hash of the VCSID environment variable provided by
- the packaging system.
-
- Args:
- repo: The path to the git repo.
-
- Returns:
- A string, of the current revision.
- """
- try:
- result = subprocess.run(
- ["git", "-C", repo, "log", "-n1", "--format=%H"],
- check=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.DEVNULL,
- encoding="utf-8",
- )
- except subprocess.CalledProcessError:
- # Fall back to the VCSID provided by the packaging system.
- # Format is 0.0.1-r425-032666c418782c14fe912ba6d9f98ffdf0b941e9 for
- # releases and 9999-032666c418782c14fe912ba6d9f98ffdf0b941e9 for
- # 9999 ebuilds.
- vcsid = os.environ.get("VCSID", "9999-unknown")
- revision = vcsid.rsplit("-", 1)[1]
- else:
- revision = result.stdout
-
- return revision
-
-
-def get_version_string(project, zephyr_base, modules, static=False):
- """Get the version string associated with a build.
-
- Args:
- project: a zmake.project.Project object
- zephyr_base: the path to the zephyr directory
- modules: a dictionary mapping module names to module paths
- static: if set, create a version string not dependent on git
- commits, thus allowing binaries to be compared between two
- commits.
-
- Returns:
- A version string which can be placed in FRID, FWID, or used in
- the build for the OS.
- """
- major_version, minor_version, *_ = util.read_zephyr_version(zephyr_base)
- project_id = project.project_dir.parts[-1]
- num_commits = 0
-
- if static:
- vcs_hashes = "STATIC"
- else:
- repos = {
- "os": zephyr_base,
- **modules,
- }
-
- for repo in repos.values():
- num_commits += _get_num_commits(repo)
-
- vcs_hashes = ",".join(
- "{}:{}".format(name, _get_revision(repo)[:6])
- for name, repo in sorted(
- repos.items(),
- # Put the EC module first, then Zephyr OS kernel, as
- # these are probably the most important hashes to
- # developers.
- key=lambda p: (p[0] != "ec", p[0] != "os", p),
- )
- )
-
- return "{}_v{}.{}.{}-{}".format(
- project_id, major_version, minor_version, num_commits, vcs_hashes
- )
-
-
-def write_version_header(version_str, output_path, static=False):
- """Generate a version header and write it to the specified path.
-
- Generate a version header in the format expected by the EC build
- system, and write it out only if the version header does not exist
- or changes. We don't write in the case that the version header
- does exist and was unchanged, which allows "zmake build" commands
- on an unchanged tree to be an effective no-op.
-
- Args:
- version_str: The version string to be used in the header, such
- as one generated by get_version_string.
- output_path: The file path to write at (a pathlib.Path
- object).
- static: If true, generate a header which does not include
- information like the username, hostname, or date, allowing
- the build to be reproducible.
- """
- output = io.StringIO()
- output.write("/* This file is automatically generated by zmake */\n")
-
- def add_def(name, value):
- output.write("#define {} {}\n".format(name, util.c_str(value)))
-
- def add_def_unquoted(name, value):
- output.write("#define {} {}\n".format(name, value))
-
- add_def("VERSION", version_str)
- add_def("CROS_EC_VERSION32", version_str[:31])
-
- if static:
- add_def("BUILDER", "reproducible@build")
- add_def("DATE", "STATIC_VERSION_DATE")
- else:
- add_def("BUILDER", "{}@{}".format(getpass.getuser(), platform.node()))
- add_def("DATE", datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))
-
- add_def("CROS_FWID_MISSING_STR", "CROS_FWID_MISSING")
- # TODO(b/198475757): Add zmake support for getting CROS_FWID32
- add_def_unquoted("CROS_FWID32", "CROS_FWID_MISSING_STR")
-
- contents = output.getvalue()
- if not output_path.exists() or output_path.read_text() != contents:
- output_path.write_text(contents)
diff --git a/zephyr/zmake/zmake/zmake.py b/zephyr/zmake/zmake/zmake.py
deleted file mode 100644
index 1b60e66f66..0000000000
--- a/zephyr/zmake/zmake/zmake.py
+++ /dev/null
@@ -1,757 +0,0 @@
-# Copyright 2020 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.
-
-"""Module encapsulating Zmake wrapper object."""
-import logging
-import os
-import pathlib
-import re
-import shutil
-import subprocess
-import tempfile
-
-import zmake.build_config
-import zmake.jobserver
-import zmake.modules
-import zmake.multiproc
-import zmake.project
-import zmake.util as util
-import zmake.version
-
-ninja_warnings = re.compile(r"^(\S*: )?warning:.*")
-ninja_errors = re.compile(r"error:.*")
-
-
-def ninja_stdout_log_level_override(line, current_log_level):
- """Update the log level for ninja builds if we hit an error.
-
- Ninja builds prints everything to stdout, but really we want to start
- logging things to CRITICAL
-
- Args:
- line: The line that is about to be logged.
- current_log_level: The active logging level that would be used for the
- line.
- """
- # Output lines from Zephyr that are not normally useful
- # Send any lines that start with these strings to INFO
- cmake_suppress = [
- "-- ", # device tree messages
- "Loaded configuration",
- "Including boilerplate",
- "Parsing ",
- "No change to configuration",
- "No change to Kconfig header",
- ]
-
- # Herewith a long list of things which are really for debugging, not
- # development. Return logging.DEBUG for each of these.
-
- # ninja puts progress information on stdout
- if line.startswith("["):
- return logging.DEBUG
- # we don't care about entering directories since it happens every time
- if line.startswith("ninja: Entering directory"):
- return logging.DEBUG
- # we know the build stops from the compiler messages and ninja return code
- if line.startswith("ninja: build stopped"):
- return logging.DEBUG
- # someone prints a *** SUCCESS *** message which we don't need
- if line.startswith("***"):
- return logging.DEBUG
- # dopey ninja puts errors on stdout, so fix that. It does not look
- # likely that it will be fixed upstream:
- # https://github.com/ninja-build/ninja/issues/1537
- # Try to drop output about the device tree
- if any(line.startswith(x) for x in cmake_suppress):
- return logging.INFO
- # this message is a bit like make failing. We already got the error output.
- if line.startswith("FAILED: CMakeFiles"):
- return logging.INFO
- # if a particular file fails it shows the build line used, but that is not
- # useful except for debugging.
- if line.startswith("ccache"):
- return logging.DEBUG
- if ninja_warnings.match(line):
- return logging.WARNING
- if ninja_errors.match(line):
- return logging.ERROR
- # When we see "Memory region" go into INFO, and stay there as long as the
- # line starts with \S+:
- if line.startswith("Memory region"):
- return logging.INFO
- if current_log_level == logging.INFO and line.split()[0].endswith(":"):
- return current_log_level
- if current_log_level == logging.WARNING:
- return current_log_level
- return logging.ERROR
-
-
-def cmake_log_level_override(line, default_log_level):
- """Update the log level for cmake output if we hit an error.
-
- Cmake prints some messages that are less than useful during
- development.
-
- Args:
- line: The line that is about to be logged.
- default_log_level: The default logging level that will be used for the
- line.
- """
- # Strange output from Zephyr that we normally ignore
- if line.startswith("Including boilerplate"):
- return logging.DEBUG
- elif line.startswith("devicetree error:"):
- return logging.ERROR
- if ninja_warnings.match(line):
- return logging.WARNING
- if ninja_errors.match(line):
- return logging.ERROR
- return default_log_level
-
-
-def get_process_failure_msg(proc):
- """Creates a suitable failure message if something exits badly
-
- Args:
- proc: subprocess.Popen object containing the thing that failed
-
- Returns:
- Failure message as a string:
- """
- return "Execution failed (return code={}): {}\n".format(
- proc.returncode, util.repr_command(proc.args)
- )
-
-
-class Zmake:
- """Wrapper class encapsulating zmake's supported operations.
-
- The invocations of the constructor and the methods actually comes
- from the main function. The command line arguments are translated
- such that dashes are replaced with underscores and applied as
- keyword arguments to the constructor and the method, and the
- subcommand invoked becomes the method run.
-
- As such, you won't find documentation for each method's parameters
- here, as it would be duplicate of the help strings from the
- command line. Run "zmake --help" for full documentation of each
- parameter.
-
- Properties:
- executor: a zmake.multiproc.Executor object for submitting
- tasks to.
- _sequential: True to check the results of each build job sequentially,
- before launching more, False to just do this after all jobs complete
- """
-
- def __init__(
- self, checkout=None, jobserver=None, jobs=0, modules_dir=None, zephyr_base=None
- ):
- zmake.multiproc.reset()
- self._checkout = checkout
- self._zephyr_base = zephyr_base
-
- if modules_dir:
- self.module_paths = zmake.modules.locate_from_directory(modules_dir)
- else:
- self.module_paths = zmake.modules.locate_from_checkout(self.checkout)
-
- if jobserver:
- self.jobserver = jobserver
- else:
- try:
- self.jobserver = zmake.jobserver.GNUMakeJobClient.from_environ()
- except OSError:
- self.jobserver = zmake.jobserver.GNUMakeJobServer(jobs=jobs)
-
- self.logger = logging.getLogger(self.__class__.__name__)
- self.executor = zmake.multiproc.Executor()
- self._sequential = jobs == 1
-
- @property
- def checkout(self):
- if not self._checkout:
- self._checkout = util.locate_cros_checkout()
- return self._checkout.resolve()
-
- def locate_zephyr_base(self, version):
- """Locate the Zephyr OS repository.
-
- Args:
- version: If a Zephyr OS base was not supplied to Zmake,
- which version to search for as a tuple of integers.
- This argument is ignored if a Zephyr base was supplied
- to Zmake.
- Returns:
- A pathlib.Path to the found Zephyr OS repository.
- """
- if self._zephyr_base:
- return self._zephyr_base
-
- return util.locate_zephyr_base(self.checkout, version)
-
- def configure(
- self,
- project_dir,
- build_dir=None,
- toolchain=None,
- ignore_unsupported_zephyr_version=False,
- build_after_configure=False,
- test_after_configure=False,
- bringup=False,
- coverage=False,
- ):
- """Set up a build directory to later be built by "zmake build"."""
- project = zmake.project.Project(project_dir)
- supported_versions = project.config.supported_zephyr_versions
-
- zephyr_base = self.locate_zephyr_base(max(supported_versions)).resolve()
-
- # Ignore the patchset from the Zephyr version.
- zephyr_version = util.read_zephyr_version(zephyr_base)[:2]
-
- if (
- not ignore_unsupported_zephyr_version
- and zephyr_version not in supported_versions
- ):
- raise ValueError(
- "The Zephyr OS version (v{}.{}) is not supported by the "
- "project. You may wish to either configure zmake.yaml to "
- "support this version, or pass "
- "--ignore-unsupported-zephyr-version.".format(*zephyr_version)
- )
-
- # Resolve build_dir if needed.
- build_dir = util.resolve_build_dir(
- platform_ec_dir=self.module_paths["ec"],
- project_dir=project_dir,
- build_dir=build_dir,
- )
- # Make sure the build directory is clean.
- if os.path.exists(build_dir):
- self.logger.info("Clearing old build directory %s", build_dir)
- shutil.rmtree(build_dir)
-
- generated_include_dir = (build_dir / "include").resolve()
- base_config = zmake.build_config.BuildConfig(
- environ_defs={"ZEPHYR_BASE": str(zephyr_base), "PATH": "/usr/bin"},
- cmake_defs={
- "DTS_ROOT": str(self.module_paths["ec"] / "zephyr"),
- "SYSCALL_INCLUDE_DIRS": str(
- self.module_paths["ec"] / "zephyr" / "include" / "drivers"
- ),
- "ZMAKE_INCLUDE_DIR": str(generated_include_dir),
- },
- )
-
- # 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(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()
-
- 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 not build_dir.exists():
- build_dir = build_dir.mkdir()
- if not generated_include_dir.exists():
- generated_include_dir.mkdir()
- processes = []
- self.logger.info("Building %s in %s.", project_dir, build_dir)
- for build_name, build_config in project.iter_builds():
- self.logger.info("Configuring %s:%s.", project_dir, build_name)
- config = (
- base_config
- | toolchain_config
- | module_config
- | dts_overlay_config
- | build_config
- )
- output_dir = build_dir / "build-{}".format(build_name)
- kconfig_file = build_dir / "kconfig-{}.conf".format(build_name)
- proc = config.popen_cmake(
- self.jobserver,
- project_dir,
- output_dir,
- kconfig_file,
- stdin=subprocess.DEVNULL,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- encoding="utf-8",
- errors="replace",
- )
- job_id = "{}:{}".format(project_dir, build_name)
- zmake.multiproc.log_output(
- self.logger,
- logging.DEBUG,
- proc.stdout,
- log_level_override_func=cmake_log_level_override,
- job_id=job_id,
- )
- zmake.multiproc.log_output(
- self.logger,
- logging.ERROR,
- proc.stderr,
- log_level_override_func=cmake_log_level_override,
- job_id=job_id,
- )
- 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))
-
- # Create symlink to project
- util.update_symlink(project_dir, build_dir / "project")
-
- if test_after_configure:
- return self.test(build_dir=build_dir)
- elif build_after_configure:
- return self.build(build_dir=build_dir)
-
- def build(self, build_dir, output_files_out=None, fail_on_warnings=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))
-
- # Let all output be produced before exiting
- for writer in writers:
- writer.wait()
- if fail_on_warnings and any(
- w.has_written(logging.WARNING) or w.has_written(logging.ERROR)
- for w in writers
- ):
- self.logger.warning("zmake: Warnings detected in build: aborting")
- return False
- return True
-
- procs = []
- log_writers = []
- dirs = {}
-
- build_dir = build_dir.resolve()
- project = zmake.project.Project(build_dir / "project")
-
- # Compute the version string.
- version_string = zmake.version.get_version_string(
- project,
- build_dir / "zephyr_base",
- zmake.modules.locate_from_directory(build_dir / "modules"),
- )
-
- # 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",
- )
-
- for build_name, build_config in project.iter_builds():
- with self.jobserver.get_job():
- dirs[build_name] = build_dir / "build-{}".format(build_name)
- cmd = ["/usr/bin/ninja", "-C", dirs[build_name].as_posix()]
- self.logger.info(
- "Building %s:%s: %s",
- build_dir,
- build_name,
- zmake.util.repr_command(cmd),
- )
- proc = self.jobserver.popen(
- cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- encoding="utf-8",
- errors="replace",
- )
- job_id = "{}:{}".format(build_dir, build_name)
- out = zmake.multiproc.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,
- )
- err = zmake.multiproc.log_output(
- self.logger,
- logging.ERROR,
- proc.stderr,
- job_id=job_id,
- )
-
- 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 d in output_dir, packer_work_dir:
- if not d.exists():
- d.mkdir()
-
- if output_files_out is None:
- output_files_out = []
- for output_file, output_name in project.packer.pack_firmware(
- packer_work_dir, self.jobserver, version_string=version_string, **dirs
- ):
- shutil.copy2(output_file, output_dir / output_name)
- self.logger.debug("Output file '%s' created.", output_file)
- output_files_out.append(output_file)
-
- return 0
-
- def test(self, build_dir):
- """Test a build directory."""
- procs = []
- output_files = []
- self.build(build_dir, output_files_out=output_files)
-
- # If the project built but isn't a test, just bail.
- project = zmake.project.Project(build_dir / "project")
- if not project.config.is_test:
- return 0
-
- for output_file in output_files:
- self.logger.info("Running tests in %s.", output_file)
- with self.jobserver.get_job():
- proc = self.jobserver.popen(
- [output_file],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- encoding="utf-8",
- errors="replace",
- )
- job_id = "test {}".format(output_file)
- zmake.multiproc.log_output(
- self.logger,
- logging.DEBUG,
- proc.stdout,
- job_id=job_id,
- )
- zmake.multiproc.log_output(
- self.logger,
- logging.ERROR,
- proc.stderr,
- job_id=job_id,
- )
- procs.append(proc)
-
- for idx, proc in enumerate(procs):
- if proc.wait():
- raise OSError(get_process_failure_msg(proc))
- return 0
-
- def testall(self):
- """Test all the valid test targets"""
- tmp_dirs = []
- for project in zmake.project.find_projects(self.module_paths["ec"] / "zephyr"):
- is_test = project.config.is_test
- temp_build_dir = tempfile.mkdtemp(
- suffix="-{}".format(os.path.basename(project.project_dir.as_posix())),
- prefix="zbuild-",
- )
- tmp_dirs.append(temp_build_dir)
- # Configure and run the test.
- self.executor.append(
- func=lambda: self.configure(
- project_dir=project.project_dir,
- build_dir=pathlib.Path(temp_build_dir),
- build_after_configure=True,
- test_after_configure=is_test,
- )
- )
-
- rv = self.executor.wait()
- for tmpdir in tmp_dirs:
- shutil.rmtree(tmpdir)
- return rv
-
- def _run_lcov(self, build_dir, lcov_file, initial=False, gcov=""):
- gcov = os.path.abspath(gcov)
- with self.jobserver.get_job():
- if initial:
- self.logger.info("Running (initial) lcov on %s.", build_dir)
- else:
- self.logger.info("Running lcov on %s.", build_dir)
- cmd = [
- "/usr/bin/lcov",
- "--gcov-tool",
- gcov,
- "-q",
- "-o",
- "-",
- "-c",
- "-d",
- build_dir,
- "-t",
- lcov_file.stem,
- "--exclude",
- "*/build-*/zephyr/*/generated/*",
- "--exclude",
- "*/ec/test/*",
- "--exclude",
- "*/ec/zephyr/shim/chip/npcx/npcx_monitor/*",
- "--exclude",
- "*/ec/zephyr/emul/*",
- "--exclude",
- "*/ec/zephyr/test/*",
- "--exclude",
- "*/testsuite/*",
- "--exclude",
- "*/subsys/emul/*",
- ]
- if initial:
- cmd += ["-i"]
- proc = self.jobserver.popen(
- cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- encoding="utf-8",
- errors="replace",
- )
- zmake.multiproc.log_output(
- self.logger,
- logging.WARNING,
- proc.stderr,
- job_id="{}-lcov".format(build_dir),
- )
-
- with open(lcov_file, "w") as outfile:
- for line in proc.stdout:
- if line.startswith("SF:"):
- path = line[3:].rstrip()
- outfile.write("SF:%s\n" % os.path.realpath(path))
- else:
- outfile.write(line)
- if proc.wait():
- raise OSError(get_process_failure_msg(proc))
-
- return 0
-
- def _coverage_compile_only(self, project, build_dir, lcov_file):
- self.logger.info("Building %s in %s", project.project_dir, build_dir)
- rv = self.configure(
- project_dir=project.project_dir,
- build_dir=build_dir,
- build_after_configure=False,
- test_after_configure=False,
- coverage=True,
- )
- if rv:
- return rv
-
- # Compute the version string.
- version_string = zmake.version.get_version_string(
- project,
- build_dir / "zephyr_base",
- zmake.modules.locate_from_directory(build_dir / "modules"),
- )
-
- # 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",
- )
-
- # Use ninja to compile the all.libraries target.
- build_project = zmake.project.Project(build_dir / "project")
-
- procs = []
- dirs = {}
- gcov = "gcov.sh-not-found"
- for build_name, build_config in build_project.iter_builds():
- self.logger.info("Building %s:%s all.libraries.", build_dir, build_name)
- dirs[build_name] = build_dir / "build-{}".format(build_name)
- gcov = dirs[build_name] / "gcov.sh"
- proc = self.jobserver.popen(
- ["/usr/bin/ninja", "-C", dirs[build_name], "all.libraries"],
- # Ninja will connect as a job client instead and claim
- # many jobs.
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- encoding="utf-8",
- errors="replace",
- )
- job_id = "{}:{}".format(build_dir, build_name)
- zmake.multiproc.log_output(
- logger=self.logger,
- log_level=logging.DEBUG,
- file_descriptor=proc.stdout,
- log_level_override_func=ninja_stdout_log_level_override,
- job_id=job_id,
- )
- zmake.multiproc.log_output(
- self.logger,
- logging.ERROR,
- proc.stderr,
- job_id=job_id,
- )
- if self._sequential:
- if proc.wait():
- raise OSError(get_process_failure_msg(proc))
- else:
- procs.append(proc)
-
- for proc in procs:
- if proc.wait():
- raise OSError(get_process_failure_msg(proc))
-
- return self._run_lcov(build_dir, lcov_file, initial=True, gcov=gcov)
-
- def _coverage_run_test(self, project, build_dir, lcov_file):
- self.logger.info("Running test %s in %s", project.project_dir, build_dir)
- rv = self.configure(
- project_dir=project.project_dir,
- build_dir=build_dir,
- build_after_configure=True,
- test_after_configure=True,
- coverage=True,
- )
- if rv:
- return rv
- gcov = "gcov.sh-not-found"
- for build_name, build_config in project.iter_builds():
- gcov = build_dir / "build-{}".format(build_name) / "gcov.sh"
- return self._run_lcov(build_dir, lcov_file, initial=False, gcov=gcov)
-
- def coverage(self, build_dir):
- """Builds all targets with coverage enabled, and then runs the tests."""
- all_lcov_files = []
- root_dir = self.module_paths["ec"] / "zephyr"
- for project in zmake.project.find_projects(root_dir):
- is_test = project.config.is_test
- rel_path = project.project_dir.relative_to(root_dir)
- project_build_dir = pathlib.Path(build_dir).joinpath(rel_path)
- lcov_file = pathlib.Path(build_dir).joinpath(
- str(rel_path).replace("/", "_") + ".info"
- )
- all_lcov_files.append(lcov_file)
- if is_test:
- # Configure and run the test.
- self.executor.append(
- func=lambda: self._coverage_run_test(
- project, project_build_dir, lcov_file
- )
- )
- else:
- # Configure and compile the non-test project.
- self.executor.append(
- func=lambda: self._coverage_compile_only(
- project, project_build_dir, lcov_file
- )
- )
- if self._sequential:
- rv = self.executor.wait()
- if rv:
- return rv
-
- rv = self.executor.wait()
- if rv:
- return rv
-
- with self.jobserver.get_job():
- # Merge info files into a single lcov.info
- self.logger.info("Merging coverage data into %s.", build_dir / "lcov.info")
- cmd = ["/usr/bin/lcov", "-o", build_dir / "lcov.info"]
- 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.log_output(
- self.logger, logging.ERROR, proc.stderr, job_id="lcov"
- )
- zmake.multiproc.log_output(
- self.logger, logging.DEBUG, proc.stdout, job_id="lcov"
- )
- if proc.wait():
- raise OSError(get_process_failure_msg(proc))
-
- # Find the common root dir
- prefixdir = os.path.commonprefix(list(self.module_paths.values()))
-
- # Merge into a nice html report
- self.logger.info("Creating coverage report %s.", build_dir / "coverage_rpt")
- proc = self.jobserver.popen(
- [
- "/usr/bin/genhtml",
- "-q",
- "-o",
- build_dir / "coverage_rpt",
- "-t",
- "Zephyr EC Unittest",
- "-p",
- prefixdir,
- "-s",
- ]
- + all_lcov_files,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- encoding="utf-8",
- errors="replace",
- )
- zmake.multiproc.log_output(
- self.logger, logging.ERROR, proc.stderr, job_id="genhtml"
- )
- zmake.multiproc.log_output(
- self.logger, logging.DEBUG, proc.stdout, job_id="genhtml"
- )
- if proc.wait():
- raise OSError(get_process_failure_msg(proc))
- return 0