From f8de1825d4e008c0059f8c995b948c3ffc457423 Mon Sep 17 00:00:00 2001 From: Jason Yuan Date: Thu, 17 Nov 2022 13:30:03 -0800 Subject: zephyr: Project organization - skyrim Organized the skyrim program into folders for projects. Similar .dtsi files in project directory will be merged into program directory in a followup CL. BUG=b:254097911 TEST=Ran zmake compare-builds BRANCH=none Signed-off-by: Jason Yuan Change-Id: I1e0b9b4ea096f2e4ffa97067fe8aecdea171fc00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4035057 Tested-by: zhi cheng yuan Reviewed-by: Diana Z Reviewed-by: Keith Short Commit-Queue: zhi cheng yuan Code-Coverage: Zoss --- zephyr/program/skyrim/BUILD.py | 67 +--- zephyr/program/skyrim/CMakeLists.txt | 46 +-- zephyr/program/skyrim/adc.dts | 82 ----- zephyr/program/skyrim/adc.dtsi | 82 +++++ zephyr/program/skyrim/battery_crystaldrift.dts | 15 - zephyr/program/skyrim/battery_frostflow.dts | 12 - zephyr/program/skyrim/battery_morthal.dts | 15 - zephyr/program/skyrim/battery_skyrim.dts | 15 - zephyr/program/skyrim/battery_winterhold.dts | 33 -- zephyr/program/skyrim/crystaldrift.dts | 209 ------------ zephyr/program/skyrim/crystaldrift/CMakeLists.txt | 12 + zephyr/program/skyrim/crystaldrift/battery.dtsi | 15 + .../program/skyrim/crystaldrift/crystaldrift.dtsi | 209 ++++++++++++ zephyr/program/skyrim/crystaldrift/led_pins.dtsi | 61 ++++ zephyr/program/skyrim/crystaldrift/led_policy.dtsi | 103 ++++++ .../program/skyrim/crystaldrift/motionsense.dtsi | 135 ++++++++ zephyr/program/skyrim/crystaldrift/project.conf | 26 ++ zephyr/program/skyrim/crystaldrift/project.overlay | 19 ++ .../program/skyrim/crystaldrift/src/alt_charger.c | 31 ++ zephyr/program/skyrim/crystaldrift/src/fan.c | 62 ++++ .../program/skyrim/crystaldrift/src/form_factor.c | 38 +++ .../program/skyrim/crystaldrift/src/ppc_config.c | 46 +++ .../skyrim/crystaldrift/src/usb_mux_config.c | 142 ++++++++ zephyr/program/skyrim/fan.dts | 39 --- zephyr/program/skyrim/fan.dtsi | 39 +++ zephyr/program/skyrim/frostflow.dts | 223 ------------- zephyr/program/skyrim/frostflow/CMakeLists.txt | 15 + zephyr/program/skyrim/frostflow/battery.dtsi | 12 + zephyr/program/skyrim/frostflow/frostflow.dtsi | 223 +++++++++++++ .../frostflow/include/keyboard_customization.h | 78 +++++ zephyr/program/skyrim/frostflow/led_pins.dtsi | 59 ++++ zephyr/program/skyrim/frostflow/led_policy.dtsi | 122 +++++++ zephyr/program/skyrim/frostflow/motionsense.dtsi | 135 ++++++++ zephyr/program/skyrim/frostflow/project.conf | 33 ++ zephyr/program/skyrim/frostflow/project.overlay | 19 ++ zephyr/program/skyrim/frostflow/src/keyboard.c | 74 +++++ .../skyrim/frostflow/src/keyboard_customization.c | 85 +++++ zephyr/program/skyrim/frostflow/src/ppc_config.c | 46 +++ zephyr/program/skyrim/frostflow/src/thermal.c | 109 ++++++ .../program/skyrim/frostflow/src/usb_mux_config.c | 62 ++++ zephyr/program/skyrim/gpio.dts | 370 --------------------- zephyr/program/skyrim/gpio.dtsi | 370 +++++++++++++++++++++ zephyr/program/skyrim/i2c.dtsi | 294 ++++++++++++++++ zephyr/program/skyrim/i2c_common.dtsi | 294 ---------------- .../include/frostflow/keyboard_customization.h | 78 ----- .../skyrim/include/keyboard_customization.h | 78 +++++ zephyr/program/skyrim/interrupts.dts | 146 -------- zephyr/program/skyrim/interrupts.dtsi | 146 ++++++++ zephyr/program/skyrim/keyboard.dts | 48 --- zephyr/program/skyrim/keyboard.dtsi | 48 +++ zephyr/program/skyrim/led_pins_crystaldrift.dts | 61 ---- zephyr/program/skyrim/led_pins_frostflow.dts | 59 ---- zephyr/program/skyrim/led_pins_morthal.dts | 59 ---- zephyr/program/skyrim/led_pins_skyrim.dts | 59 ---- zephyr/program/skyrim/led_pins_winterhold.dts | 59 ---- zephyr/program/skyrim/led_policy_crystaldrift.dts | 103 ------ zephyr/program/skyrim/led_policy_frostflow.dts | 122 ------- zephyr/program/skyrim/led_policy_morthal.dts | 103 ------ zephyr/program/skyrim/led_policy_skyrim.dts | 103 ------ zephyr/program/skyrim/led_policy_winterhold.dts | 103 ------ zephyr/program/skyrim/morthal.dts | 185 ----------- zephyr/program/skyrim/morthal/CMakeLists.txt | 8 + zephyr/program/skyrim/morthal/battery.dtsi | 15 + zephyr/program/skyrim/morthal/led_pins.dtsi | 59 ++++ zephyr/program/skyrim/morthal/led_policy.dtsi | 103 ++++++ zephyr/program/skyrim/morthal/morthal.dtsi | 185 +++++++++++ zephyr/program/skyrim/morthal/motionsense.dtsi | 135 ++++++++ zephyr/program/skyrim/morthal/project.conf | 23 ++ zephyr/program/skyrim/morthal/project.overlay | 19 ++ zephyr/program/skyrim/morthal/src/ppc_config.c | 46 +++ zephyr/program/skyrim/morthal/src/usb_mux_config.c | 142 ++++++++ zephyr/program/skyrim/motionsense.dts | 135 -------- zephyr/program/skyrim/motionsense.dtsi | 135 ++++++++ zephyr/program/skyrim/motionsense_crystaldrift.dts | 135 -------- zephyr/program/skyrim/motionsense_frostflow.dts | 135 -------- zephyr/program/skyrim/motionsense_morthal.dts | 135 -------- zephyr/program/skyrim/motionsense_skyrim.dts | 135 -------- zephyr/program/skyrim/motionsense_winterhold.dts | 124 ------- zephyr/program/skyrim/prj.conf | 140 -------- zephyr/program/skyrim/prj_crystaldrift.conf | 26 -- zephyr/program/skyrim/prj_frostflow.conf | 33 -- zephyr/program/skyrim/prj_morthal.conf | 23 -- zephyr/program/skyrim/prj_skyrim.conf | 26 -- zephyr/program/skyrim/prj_winterhold.conf | 47 --- zephyr/program/skyrim/program.conf | 140 ++++++++ zephyr/program/skyrim/skyrim.dts | 209 ------------ zephyr/program/skyrim/skyrim/CMakeLists.txt | 13 + zephyr/program/skyrim/skyrim/battery.dtsi | 15 + zephyr/program/skyrim/skyrim/led_pins.dtsi | 59 ++++ zephyr/program/skyrim/skyrim/led_policy.dtsi | 103 ++++++ zephyr/program/skyrim/skyrim/motionsense.dtsi | 135 ++++++++ zephyr/program/skyrim/skyrim/project.conf | 26 ++ zephyr/program/skyrim/skyrim/project.overlay | 19 ++ zephyr/program/skyrim/skyrim/skyrim.dtsi | 209 ++++++++++++ zephyr/program/skyrim/skyrim/skyrim_vif.xml | 346 +++++++++++++++++++ zephyr/program/skyrim/skyrim/src/alt_charger.c | 31 ++ zephyr/program/skyrim/skyrim/src/fan.c | 62 ++++ zephyr/program/skyrim/skyrim/src/form_factor.c | 38 +++ zephyr/program/skyrim/skyrim/src/keyboard.c | 29 ++ zephyr/program/skyrim/skyrim/src/ppc_config.c | 46 +++ zephyr/program/skyrim/skyrim/src/usb_mux_config.c | 142 ++++++++ zephyr/program/skyrim/skyrim_vif.xml | 346 ------------------- .../program/skyrim/src/crystaldrift/alt_charger.c | 31 -- zephyr/program/skyrim/src/crystaldrift/fan.c | 62 ---- .../program/skyrim/src/crystaldrift/form_factor.c | 38 --- .../program/skyrim/src/crystaldrift/ppc_config.c | 46 --- .../skyrim/src/crystaldrift/usb_mux_config.c | 142 -------- zephyr/program/skyrim/src/frostflow/keyboard.c | 74 ----- .../skyrim/src/frostflow/keyboard_customization.c | 85 ----- zephyr/program/skyrim/src/frostflow/ppc_config.c | 46 --- zephyr/program/skyrim/src/frostflow/thermal.c | 109 ------ .../program/skyrim/src/frostflow/usb_mux_config.c | 62 ---- zephyr/program/skyrim/src/morthal/ppc_config.c | 46 --- zephyr/program/skyrim/src/morthal/usb_mux_config.c | 142 -------- zephyr/program/skyrim/src/skyrim/alt_charger.c | 31 -- zephyr/program/skyrim/src/skyrim/fan.c | 62 ---- zephyr/program/skyrim/src/skyrim/form_factor.c | 38 --- zephyr/program/skyrim/src/skyrim/keyboard.c | 29 -- zephyr/program/skyrim/src/skyrim/ppc_config.c | 46 --- zephyr/program/skyrim/src/skyrim/usb_mux_config.c | 142 -------- .../skyrim/src/winterhold/battery_present.c | 81 ----- .../program/skyrim/src/winterhold/kb_backlight.c | 34 -- zephyr/program/skyrim/src/winterhold/keyboard.c | 29 -- zephyr/program/skyrim/src/winterhold/ppc_config.c | 27 -- zephyr/program/skyrim/src/winterhold/sensor.c | 37 --- .../program/skyrim/src/winterhold/usb_mux_config.c | 146 -------- zephyr/program/skyrim/usbc.dts | 26 -- zephyr/program/skyrim/usbc.dtsi | 26 ++ zephyr/program/skyrim/winterhold.dts | 168 ---------- zephyr/program/skyrim/winterhold/CMakeLists.txt | 12 + zephyr/program/skyrim/winterhold/battery.dtsi | 33 ++ zephyr/program/skyrim/winterhold/led_pins.dtsi | 59 ++++ zephyr/program/skyrim/winterhold/led_policy.dtsi | 103 ++++++ zephyr/program/skyrim/winterhold/motionsense.dtsi | 124 +++++++ zephyr/program/skyrim/winterhold/project.conf | 47 +++ zephyr/program/skyrim/winterhold/project.overlay | 19 ++ .../skyrim/winterhold/src/battery_present.c | 81 +++++ .../program/skyrim/winterhold/src/kb_backlight.c | 34 ++ zephyr/program/skyrim/winterhold/src/keyboard.c | 29 ++ zephyr/program/skyrim/winterhold/src/ppc_config.c | 27 ++ zephyr/program/skyrim/winterhold/src/sensor.c | 37 +++ .../program/skyrim/winterhold/src/usb_mux_config.c | 146 ++++++++ zephyr/program/skyrim/winterhold/winterhold.dtsi | 168 ++++++++++ 143 files changed, 6268 insertions(+), 6124 deletions(-) delete mode 100644 zephyr/program/skyrim/adc.dts create mode 100644 zephyr/program/skyrim/adc.dtsi delete mode 100644 zephyr/program/skyrim/battery_crystaldrift.dts delete mode 100644 zephyr/program/skyrim/battery_frostflow.dts delete mode 100644 zephyr/program/skyrim/battery_morthal.dts delete mode 100644 zephyr/program/skyrim/battery_skyrim.dts delete mode 100644 zephyr/program/skyrim/battery_winterhold.dts delete mode 100644 zephyr/program/skyrim/crystaldrift.dts create mode 100644 zephyr/program/skyrim/crystaldrift/CMakeLists.txt create mode 100644 zephyr/program/skyrim/crystaldrift/battery.dtsi create mode 100644 zephyr/program/skyrim/crystaldrift/crystaldrift.dtsi create mode 100644 zephyr/program/skyrim/crystaldrift/led_pins.dtsi create mode 100644 zephyr/program/skyrim/crystaldrift/led_policy.dtsi create mode 100644 zephyr/program/skyrim/crystaldrift/motionsense.dtsi create mode 100644 zephyr/program/skyrim/crystaldrift/project.conf create mode 100644 zephyr/program/skyrim/crystaldrift/project.overlay create mode 100644 zephyr/program/skyrim/crystaldrift/src/alt_charger.c create mode 100644 zephyr/program/skyrim/crystaldrift/src/fan.c create mode 100644 zephyr/program/skyrim/crystaldrift/src/form_factor.c create mode 100644 zephyr/program/skyrim/crystaldrift/src/ppc_config.c create mode 100644 zephyr/program/skyrim/crystaldrift/src/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/fan.dts create mode 100644 zephyr/program/skyrim/fan.dtsi delete mode 100644 zephyr/program/skyrim/frostflow.dts create mode 100644 zephyr/program/skyrim/frostflow/CMakeLists.txt create mode 100644 zephyr/program/skyrim/frostflow/battery.dtsi create mode 100644 zephyr/program/skyrim/frostflow/frostflow.dtsi create mode 100644 zephyr/program/skyrim/frostflow/include/keyboard_customization.h create mode 100644 zephyr/program/skyrim/frostflow/led_pins.dtsi create mode 100644 zephyr/program/skyrim/frostflow/led_policy.dtsi create mode 100644 zephyr/program/skyrim/frostflow/motionsense.dtsi create mode 100644 zephyr/program/skyrim/frostflow/project.conf create mode 100644 zephyr/program/skyrim/frostflow/project.overlay create mode 100644 zephyr/program/skyrim/frostflow/src/keyboard.c create mode 100644 zephyr/program/skyrim/frostflow/src/keyboard_customization.c create mode 100644 zephyr/program/skyrim/frostflow/src/ppc_config.c create mode 100644 zephyr/program/skyrim/frostflow/src/thermal.c create mode 100644 zephyr/program/skyrim/frostflow/src/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/gpio.dts create mode 100644 zephyr/program/skyrim/gpio.dtsi create mode 100644 zephyr/program/skyrim/i2c.dtsi delete mode 100644 zephyr/program/skyrim/i2c_common.dtsi delete mode 100644 zephyr/program/skyrim/include/frostflow/keyboard_customization.h create mode 100644 zephyr/program/skyrim/include/keyboard_customization.h delete mode 100644 zephyr/program/skyrim/interrupts.dts create mode 100644 zephyr/program/skyrim/interrupts.dtsi delete mode 100644 zephyr/program/skyrim/keyboard.dts create mode 100644 zephyr/program/skyrim/keyboard.dtsi delete mode 100644 zephyr/program/skyrim/led_pins_crystaldrift.dts delete mode 100644 zephyr/program/skyrim/led_pins_frostflow.dts delete mode 100644 zephyr/program/skyrim/led_pins_morthal.dts delete mode 100644 zephyr/program/skyrim/led_pins_skyrim.dts delete mode 100644 zephyr/program/skyrim/led_pins_winterhold.dts delete mode 100644 zephyr/program/skyrim/led_policy_crystaldrift.dts delete mode 100644 zephyr/program/skyrim/led_policy_frostflow.dts delete mode 100644 zephyr/program/skyrim/led_policy_morthal.dts delete mode 100644 zephyr/program/skyrim/led_policy_skyrim.dts delete mode 100644 zephyr/program/skyrim/led_policy_winterhold.dts delete mode 100644 zephyr/program/skyrim/morthal.dts create mode 100644 zephyr/program/skyrim/morthal/CMakeLists.txt create mode 100644 zephyr/program/skyrim/morthal/battery.dtsi create mode 100644 zephyr/program/skyrim/morthal/led_pins.dtsi create mode 100644 zephyr/program/skyrim/morthal/led_policy.dtsi create mode 100644 zephyr/program/skyrim/morthal/morthal.dtsi create mode 100644 zephyr/program/skyrim/morthal/motionsense.dtsi create mode 100644 zephyr/program/skyrim/morthal/project.conf create mode 100644 zephyr/program/skyrim/morthal/project.overlay create mode 100644 zephyr/program/skyrim/morthal/src/ppc_config.c create mode 100644 zephyr/program/skyrim/morthal/src/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/motionsense.dts create mode 100644 zephyr/program/skyrim/motionsense.dtsi delete mode 100644 zephyr/program/skyrim/motionsense_crystaldrift.dts delete mode 100644 zephyr/program/skyrim/motionsense_frostflow.dts delete mode 100644 zephyr/program/skyrim/motionsense_morthal.dts delete mode 100644 zephyr/program/skyrim/motionsense_skyrim.dts delete mode 100644 zephyr/program/skyrim/motionsense_winterhold.dts delete mode 100644 zephyr/program/skyrim/prj.conf delete mode 100644 zephyr/program/skyrim/prj_crystaldrift.conf delete mode 100644 zephyr/program/skyrim/prj_frostflow.conf delete mode 100644 zephyr/program/skyrim/prj_morthal.conf delete mode 100644 zephyr/program/skyrim/prj_skyrim.conf delete mode 100644 zephyr/program/skyrim/prj_winterhold.conf create mode 100644 zephyr/program/skyrim/program.conf delete mode 100644 zephyr/program/skyrim/skyrim.dts create mode 100644 zephyr/program/skyrim/skyrim/CMakeLists.txt create mode 100644 zephyr/program/skyrim/skyrim/battery.dtsi create mode 100644 zephyr/program/skyrim/skyrim/led_pins.dtsi create mode 100644 zephyr/program/skyrim/skyrim/led_policy.dtsi create mode 100644 zephyr/program/skyrim/skyrim/motionsense.dtsi create mode 100644 zephyr/program/skyrim/skyrim/project.conf create mode 100644 zephyr/program/skyrim/skyrim/project.overlay create mode 100644 zephyr/program/skyrim/skyrim/skyrim.dtsi create mode 100644 zephyr/program/skyrim/skyrim/skyrim_vif.xml create mode 100644 zephyr/program/skyrim/skyrim/src/alt_charger.c create mode 100644 zephyr/program/skyrim/skyrim/src/fan.c create mode 100644 zephyr/program/skyrim/skyrim/src/form_factor.c create mode 100644 zephyr/program/skyrim/skyrim/src/keyboard.c create mode 100644 zephyr/program/skyrim/skyrim/src/ppc_config.c create mode 100644 zephyr/program/skyrim/skyrim/src/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/skyrim_vif.xml delete mode 100644 zephyr/program/skyrim/src/crystaldrift/alt_charger.c delete mode 100644 zephyr/program/skyrim/src/crystaldrift/fan.c delete mode 100644 zephyr/program/skyrim/src/crystaldrift/form_factor.c delete mode 100644 zephyr/program/skyrim/src/crystaldrift/ppc_config.c delete mode 100644 zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/src/frostflow/keyboard.c delete mode 100644 zephyr/program/skyrim/src/frostflow/keyboard_customization.c delete mode 100644 zephyr/program/skyrim/src/frostflow/ppc_config.c delete mode 100644 zephyr/program/skyrim/src/frostflow/thermal.c delete mode 100644 zephyr/program/skyrim/src/frostflow/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/src/morthal/ppc_config.c delete mode 100644 zephyr/program/skyrim/src/morthal/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/src/skyrim/alt_charger.c delete mode 100644 zephyr/program/skyrim/src/skyrim/fan.c delete mode 100644 zephyr/program/skyrim/src/skyrim/form_factor.c delete mode 100644 zephyr/program/skyrim/src/skyrim/keyboard.c delete mode 100644 zephyr/program/skyrim/src/skyrim/ppc_config.c delete mode 100644 zephyr/program/skyrim/src/skyrim/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/src/winterhold/battery_present.c delete mode 100644 zephyr/program/skyrim/src/winterhold/kb_backlight.c delete mode 100644 zephyr/program/skyrim/src/winterhold/keyboard.c delete mode 100644 zephyr/program/skyrim/src/winterhold/ppc_config.c delete mode 100644 zephyr/program/skyrim/src/winterhold/sensor.c delete mode 100644 zephyr/program/skyrim/src/winterhold/usb_mux_config.c delete mode 100644 zephyr/program/skyrim/usbc.dts create mode 100644 zephyr/program/skyrim/usbc.dtsi delete mode 100644 zephyr/program/skyrim/winterhold.dts create mode 100644 zephyr/program/skyrim/winterhold/CMakeLists.txt create mode 100644 zephyr/program/skyrim/winterhold/battery.dtsi create mode 100644 zephyr/program/skyrim/winterhold/led_pins.dtsi create mode 100644 zephyr/program/skyrim/winterhold/led_policy.dtsi create mode 100644 zephyr/program/skyrim/winterhold/motionsense.dtsi create mode 100644 zephyr/program/skyrim/winterhold/project.conf create mode 100644 zephyr/program/skyrim/winterhold/project.overlay create mode 100644 zephyr/program/skyrim/winterhold/src/battery_present.c create mode 100644 zephyr/program/skyrim/winterhold/src/kb_backlight.c create mode 100644 zephyr/program/skyrim/winterhold/src/keyboard.c create mode 100644 zephyr/program/skyrim/winterhold/src/ppc_config.c create mode 100644 zephyr/program/skyrim/winterhold/src/sensor.c create mode 100644 zephyr/program/skyrim/winterhold/src/usb_mux_config.c create mode 100644 zephyr/program/skyrim/winterhold/winterhold.dtsi diff --git a/zephyr/program/skyrim/BUILD.py b/zephyr/program/skyrim/BUILD.py index 654c2bf630..08c76c1f13 100644 --- a/zephyr/program/skyrim/BUILD.py +++ b/zephyr/program/skyrim/BUILD.py @@ -7,97 +7,42 @@ def register_skyrim_project( project_name, - extra_dts_overlays=(), - extra_kconfig_files=(), ): """Register a variant of skyrim.""" register_npcx_project( project_name=project_name, zephyr_board="npcx9m3f", dts_overlays=[ + here / project_name / "project.overlay", + ], + kconfig_files=[ # Common to all projects. - here / "adc.dts", - here / "fan.dts", - here / "gpio.dts", - here / "interrupts.dts", - here / "keyboard.dts", - here / "usbc.dts", - # Project-specific DTS customizations. - *extra_dts_overlays, + here / "program.conf", + # Project-specific KConfig customization. + here / project_name / "project.conf", ], - kconfig_files=[here / "prj.conf", *extra_kconfig_files], ) register_skyrim_project( project_name="morthal", - extra_dts_overlays=[ - here / "morthal.dts", - here / "battery_morthal.dts", - here / "led_pins_morthal.dts", - here / "led_policy_morthal.dts", - here / "motionsense_morthal.dts", - ], - extra_kconfig_files=[ - here / "prj_morthal.conf", - ], ) register_skyrim_project( project_name="skyrim", - extra_dts_overlays=[ - here / "skyrim.dts", - here / "battery_skyrim.dts", - here / "led_pins_skyrim.dts", - here / "led_policy_skyrim.dts", - here / "motionsense_skyrim.dts", - ], - extra_kconfig_files=[ - here / "prj_skyrim.conf", - ], ) register_skyrim_project( project_name="winterhold", - extra_dts_overlays=[ - here / "winterhold.dts", - here / "battery_winterhold.dts", - here / "led_pins_winterhold.dts", - here / "led_policy_winterhold.dts", - here / "motionsense_winterhold.dts", - ], - extra_kconfig_files=[ - here / "prj_winterhold.conf", - ], ) register_skyrim_project( project_name="frostflow", - extra_dts_overlays=[ - here / "frostflow.dts", - here / "battery_frostflow.dts", - here / "led_pins_frostflow.dts", - here / "led_policy_frostflow.dts", - here / "motionsense_frostflow.dts", - ], - extra_kconfig_files=[ - here / "prj_frostflow.conf", - ], ) register_skyrim_project( project_name="crystaldrift", - extra_dts_overlays=[ - here / "crystaldrift.dts", - here / "battery_crystaldrift.dts", - here / "led_pins_crystaldrift.dts", - here / "led_policy_crystaldrift.dts", - here / "motionsense_crystaldrift.dts", - ], - extra_kconfig_files=[ - here / "prj_crystaldrift.conf", - ], ) diff --git a/zephyr/program/skyrim/CMakeLists.txt b/zephyr/program/skyrim/CMakeLists.txt index 375099717e..bb1bde51a8 100644 --- a/zephyr/program/skyrim/CMakeLists.txt +++ b/zephyr/program/skyrim/CMakeLists.txt @@ -19,59 +19,25 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_AMD_STT if(DEFINED CONFIG_BOARD_MORTHAL) project(morthal) - zephyr_library_sources( - "src/morthal/ppc_config.c" - "src/morthal/usb_mux_config.c" -) + add_subdirectory(morthal) endif() if(DEFINED CONFIG_BOARD_SKYRIM) project(skyrim) - cros_ec_library_include_directories_ifdef(CONFIG_BOARD_SKYRIM include) - zephyr_library_sources( - "src/skyrim/usb_mux_config.c" - "src/skyrim/ppc_config.c" - "src/skyrim/form_factor.c" - "src/skyrim/alt_charger.c" - "src/skyrim/keyboard.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/skyrim/fan.c") + add_subdirectory(skyrim) endif() if(DEFINED CONFIG_BOARD_WINTERHOLD) project(winterhold) - zephyr_library_sources( - "src/winterhold/usb_mux_config.c" - "src/winterhold/ppc_config.c" - "src/winterhold/kb_backlight.c" - "src/winterhold/keyboard.c" - "src/winterhold/sensor.c" - "src/winterhold/battery_present.c" - ) + add_subdirectory(winterhold) endif() if(DEFINED CONFIG_BOARD_FROSTFLOW) project(frostflow) - cros_ec_library_include_directories_ifdef(CONFIG_BOARD_FROSTFLOW include) - zephyr_include_directories("include/frostflow") - zephyr_library_sources( - "src/frostflow/usb_mux_config.c" - "src/frostflow/ppc_config.c" - "src/frostflow/thermal.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION - "src/frostflow/keyboard.c" - "src/frostflow/keyboard_customization.c") + add_subdirectory(frostflow) endif() if(DEFINED CONFIG_BOARD_CRYSTALDRIFT) project(crystaldrift) - cros_ec_library_include_directories_ifdef(CONFIG_BOARD_CRYSTALDRIFT include) - zephyr_library_sources( - "src/crystaldrift/usb_mux_config.c" - "src/crystaldrift/ppc_config.c" - "src/crystaldrift/form_factor.c" - "src/crystaldrift/alt_charger.c" - ) - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/crystaldrift/fan.c") -endif() \ No newline at end of file + add_subdirectory(crystaldrift) +endif() diff --git a/zephyr/program/skyrim/adc.dts b/zephyr/program/skyrim/adc.dts deleted file mode 100644 index 952e5db1d0..0000000000 --- a/zephyr/program/skyrim/adc.dts +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -/ { - named-adc-channels { - compatible = "named-adc-channels"; - - adc_temp_charger: temp-charger { - enum-name = "ADC_TEMP_SENSOR_CHARGER"; - io-channels = <&adc0 1>; - }; - adc_temp_memory: temp-memory { - enum-name = "ADC_TEMP_SENSOR_MEMORY"; - io-channels = <&adc0 2>; - }; - adc_core_imon1: core-imon1 { - enum-name = "ADC_CORE_IMON1"; - io-channels = <&adc0 3>; - }; - adc_core_imon2: core-imon2 { - enum-name = "ADC_SOC_IMON2"; - io-channels = <&adc0 4>; - }; - }; - - temp_charger_thermistor: charger-thermistor { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_temp_charger>; - }; - - temp_memory_thermistor: memory-thermistor { - compatible = "cros-ec,temp-sensor-thermistor"; - thermistor = <&thermistor_3V3_30K9_47K_4050B>; - adc = <&adc_temp_memory>; - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - temp_sensor_charger: charger-thermistor { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - sensor = <&temp_charger_thermistor>; - }; - - temp_sensor_memory: memory-thermistor { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&temp_memory_thermistor>; - }; - - temp_sensor_cpu: cpu { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_fan_off = <60>; - temp_fan_max = <90>; - power-good-pin = <&gpio_s0_pgood>; - sensor = <&temp_cpu>; - }; - }; -}; - -&adc0 { - status = "okay"; - pinctrl-0 = <&adc0_chan1_gp44 - &adc0_chan2_gp43 - &adc0_chan3_gp42 - &adc0_chan4_gp41>; - pinctrl-names = "default"; -}; - -&thermistor_3V3_30K9_47K_4050B { - status = "okay"; -}; diff --git a/zephyr/program/skyrim/adc.dtsi b/zephyr/program/skyrim/adc.dtsi new file mode 100644 index 0000000000..952e5db1d0 --- /dev/null +++ b/zephyr/program/skyrim/adc.dtsi @@ -0,0 +1,82 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + adc_temp_charger: temp-charger { + enum-name = "ADC_TEMP_SENSOR_CHARGER"; + io-channels = <&adc0 1>; + }; + adc_temp_memory: temp-memory { + enum-name = "ADC_TEMP_SENSOR_MEMORY"; + io-channels = <&adc0 2>; + }; + adc_core_imon1: core-imon1 { + enum-name = "ADC_CORE_IMON1"; + io-channels = <&adc0 3>; + }; + adc_core_imon2: core-imon2 { + enum-name = "ADC_SOC_IMON2"; + io-channels = <&adc0 4>; + }; + }; + + temp_charger_thermistor: charger-thermistor { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_temp_charger>; + }; + + temp_memory_thermistor: memory-thermistor { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_temp_memory>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + temp_sensor_charger: charger-thermistor { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + sensor = <&temp_charger_thermistor>; + }; + + temp_sensor_memory: memory-thermistor { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&temp_memory_thermistor>; + }; + + temp_sensor_cpu: cpu { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_fan_off = <60>; + temp_fan_max = <90>; + power-good-pin = <&gpio_s0_pgood>; + sensor = <&temp_cpu>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_chan1_gp44 + &adc0_chan2_gp43 + &adc0_chan3_gp42 + &adc0_chan4_gp41>; + pinctrl-names = "default"; +}; + +&thermistor_3V3_30K9_47K_4050B { + status = "okay"; +}; diff --git a/zephyr/program/skyrim/battery_crystaldrift.dts b/zephyr/program/skyrim/battery_crystaldrift.dts deleted file mode 100644 index 6b1799c233..0000000000 --- a/zephyr/program/skyrim/battery_crystaldrift.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: aec_5477109 { - compatible = "aec,5477109", "battery-smart"; - }; - smp_l20m3pg1 { - compatible = "smp,l20m3pg1", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/skyrim/battery_frostflow.dts b/zephyr/program/skyrim/battery_frostflow.dts deleted file mode 100644 index 2d6b28de70..0000000000 --- a/zephyr/program/skyrim/battery_frostflow.dts +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: cdt_c340152 { - compatible = "cdt,c340152", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/skyrim/battery_morthal.dts b/zephyr/program/skyrim/battery_morthal.dts deleted file mode 100644 index 8c87cef7f9..0000000000 --- a/zephyr/program/skyrim/battery_morthal.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: aec_5477109 { - compatible = "aec,5477109", "battery-smart"; - }; - smp_l20m3pg1 { - compatible = "smp,l20m3pg1", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/skyrim/battery_skyrim.dts b/zephyr/program/skyrim/battery_skyrim.dts deleted file mode 100644 index 8c87cef7f9..0000000000 --- a/zephyr/program/skyrim/battery_skyrim.dts +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: aec_5477109 { - compatible = "aec,5477109", "battery-smart"; - }; - smp_l20m3pg1 { - compatible = "smp,l20m3pg1", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/skyrim/battery_winterhold.dts b/zephyr/program/skyrim/battery_winterhold.dts deleted file mode 100644 index 8e82e0d1f2..0000000000 --- a/zephyr/program/skyrim/battery_winterhold.dts +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - batteries { - default_battery: lgc_xphx8 { - compatible = "lgc,xphx8", "battery-smart"; - }; - smp_atlxdy9k { - compatible = "smp,atlxdy9k", "battery-smart"; - }; - smp_cosxdy9k { - compatible = "smp,cosxdy9k", "battery-smart"; - }; - byd_wv3k8 { - compatible = "byd,wv3k8", "battery-smart"; - }; - cosmx_mvk11 { - compatible = "cosmx,mvk11", "battery-smart"; - }; - sunwoda_atlvkyjx { - compatible = "sunwoda,atlvkyjx", "battery-smart"; - }; - sunwoda_cosvkyjx { - compatible = "sunwoda,cosvkyjx", "battery-smart"; - }; - atl_cfd72 { - compatible = "atl,cfd72", "battery-smart"; - }; - }; -}; diff --git a/zephyr/program/skyrim/crystaldrift.dts b/zephyr/program/skyrim/crystaldrift.dts deleted file mode 100644 index 36e5b58e13..0000000000 --- a/zephyr/program/skyrim/crystaldrift.dts +++ /dev/null @@ -1,209 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Crystaldrift-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - temp_fan_off = <35>; - temp_fan_max = <70>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - amb-pct2075 { - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* - * Note this is expected to vary per-board, so we keep it in the board - * dts files. - */ - crystaldrift-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - form-factor { - enum-name = "FW_FORM_FACTOR"; - start = <0>; - size = <1>; - - ff-clamshell { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CLAMSHELL"; - value = <0>; - }; - ff-convertible { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CONVERTIBLE"; - value = <1>; - default; - }; - }; - io-db { - enum-name = "FW_IO_DB"; - start = <6>; - size = <2>; - - io-db-ps8811-ps8818 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_PS8811_PS8818"; - value = <0>; - }; - io-db-none-anx7483 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_NONE_ANX7483"; - value = <1>; - default; - }; - }; - - /* - * FW_CONFIG field to enable fan or not. - */ - fan { - enum-name = "FW_FAN"; - start = <10>; - size = <1>; - - no-fan { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_NOT_PRESENT"; - value = <0>; - }; - fan-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_PRESENT"; - value = <1>; - /* - * Set as default so that unprovisioned - * configs will run the fan regardless. - */ - default; - }; - }; - - charger-option { - enum-name = "FW_CHARGER"; - start = <11>; - size = <2>; - - charger-option-isl9241 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_CHARGER_ISL9241"; - value = <0>; - default; - }; - charger-option-isl9538 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_CHARGER_ISL9538"; - value = <1>; - }; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - - lid_rot_ref1: lid-rotation-ref1 { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - ppc_port0: aoz1380 { - compatible = "aoz,aoz1380"; - status = "okay"; - }; -}; - -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - flags = ; - }; -}; - -&i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - flags = ; - }; - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; - ps8818_port1: ps8818@28 { - compatible = "parade,ps8818"; - reg = <0x28>; - flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; - board-set = "board_c1_ps8818_mux_set"; - }; -}; - -&i2c4_1 { - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; - alt_charger: isl9538@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&usbc_port0 { - chg_alt = <&alt_charger>; - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; - usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &ps8818_port1>; - alternative-chain; - }; -}; diff --git a/zephyr/program/skyrim/crystaldrift/CMakeLists.txt b/zephyr/program/skyrim/crystaldrift/CMakeLists.txt new file mode 100644 index 0000000000..6e50c3d40e --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cros_ec_library_include_directories_ifdef(CONFIG_BOARD_CRYSTALDRIFT include) +zephyr_library_sources( + "src/usb_mux_config.c" + "src/ppc_config.c" + "src/form_factor.c" + "src/alt_charger.c" +) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/fan.c") diff --git a/zephyr/program/skyrim/crystaldrift/battery.dtsi b/zephyr/program/skyrim/crystaldrift/battery.dtsi new file mode 100644 index 0000000000..6b1799c233 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/battery.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: aec_5477109 { + compatible = "aec,5477109", "battery-smart"; + }; + smp_l20m3pg1 { + compatible = "smp,l20m3pg1", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/crystaldrift/crystaldrift.dtsi b/zephyr/program/skyrim/crystaldrift/crystaldrift.dtsi new file mode 100644 index 0000000000..812f97a7c7 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/crystaldrift.dtsi @@ -0,0 +1,209 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "../i2c.dtsi" + +/ { + named-gpios { + /* Crystaldrift-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + temp_fan_off = <35>; + temp_fan_max = <70>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* + * Note this is expected to vary per-board, so we keep it in the board + * dts files. + */ + crystaldrift-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + form-factor { + enum-name = "FW_FORM_FACTOR"; + start = <0>; + size = <1>; + + ff-clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CLAMSHELL"; + value = <0>; + }; + ff-convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CONVERTIBLE"; + value = <1>; + default; + }; + }; + io-db { + enum-name = "FW_IO_DB"; + start = <6>; + size = <2>; + + io-db-ps8811-ps8818 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_PS8811_PS8818"; + value = <0>; + }; + io-db-none-anx7483 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_NONE_ANX7483"; + value = <1>; + default; + }; + }; + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <10>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; + + charger-option { + enum-name = "FW_CHARGER"; + start = <11>; + size = <2>; + + charger-option-isl9241 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_CHARGER_ISL9241"; + value = <0>; + default; + }; + charger-option-isl9538 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_CHARGER_ISL9538"; + value = <1>; + }; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + lid_rot_ref1: lid-rotation-ref1 { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + ppc_port0: aoz1380 { + compatible = "aoz,aoz1380"; + status = "okay"; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + flags = ; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + flags = ; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; +}; + +&i2c4_1 { + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; + alt_charger: isl9538@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + chg_alt = <&alt_charger>; + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; +}; diff --git a/zephyr/program/skyrim/crystaldrift/led_pins.dtsi b/zephyr/program/skyrim/crystaldrift/led_pins.dtsi new file mode 100644 index 0000000000..f778a24a51 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/led_pins.dtsi @@ -0,0 +1,61 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + + pwm_y: pwm_y { + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + + pwm_w: pwm_w { + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/crystaldrift/led_policy.dtsi b/zephyr/program/skyrim/crystaldrift/led_policy.dtsi new file mode 100644 index 0000000000..a075c6b0d2 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/led_policy.dtsi @@ -0,0 +1,103 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + /* White 2 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Amber 2 sec, White 2 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_white>; + period-ms = <2000>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/crystaldrift/motionsense.dtsi b/zephyr/program/skyrim/crystaldrift/motionsense.dtsi new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/motionsense.dtsi @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/crystaldrift/project.conf b/zephyr/program/skyrim/crystaldrift/project.conf new file mode 100644 index 0000000000..e9339c1c3c --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/project.conf @@ -0,0 +1,26 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Crystaldrift reference-board-specific Kconfig settings. +CONFIG_BOARD_CRYSTALDRIFT=y + +# CBI WP pin present +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Crystaldrfit is capable of sinking 100W +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Enable alternative charger chip +CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y +CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/crystaldrift/project.overlay b/zephyr/program/skyrim/crystaldrift/project.overlay new file mode 100644 index 0000000000..1192bb0d16 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/project.overlay @@ -0,0 +1,19 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim program common DTS includes */ +#include "../adc.dtsi" +#include "../fan.dtsi" +#include "../gpio.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../usbc.dtsi" + +/* Crystaldrift project DTS includes*/ +#include "crystaldrift.dtsi" +#include "battery.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" diff --git a/zephyr/program/skyrim/crystaldrift/src/alt_charger.c b/zephyr/program/skyrim/crystaldrift/src/alt_charger.c new file mode 100644 index 0000000000..a429457136 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/src/alt_charger.c @@ -0,0 +1,31 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "charger_chips.h" +#include "common.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "hooks.h" + +#include +#include + +LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); + +static void alt_charger_init(void) +{ + int ret; + uint32_t val; + + ret = cros_cbi_get_fw_config(FW_CHARGER, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER); + return; + } + + if (val == FW_CHARGER_ISL9538) + CHG_ENABLE_ALTERNATE(0); +} +DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/skyrim/crystaldrift/src/fan.c b/zephyr/program/skyrim/crystaldrift/src/fan.c new file mode 100644 index 0000000000..6645e2a495 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/src/fan.c @@ -0,0 +1,62 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" + +#include +#include +#include + +LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Skyrim fan support + */ +static void fan_init(void) +{ + int ret; + uint32_t val; + uint32_t board_version; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + + ret = cbi_get_board_version(&board_version); + if (ret != EC_SUCCESS) { + LOG_ERR("Error retrieving CBI board version"); + return; + } + + if ((board_version >= 3) && (val != FW_FAN_PRESENT)) { + /* Disable the fan */ + fan_set_count(0); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); + +/* + * Pcore OCP support + * Note: early boards should note enable this interrupt as they are not + * correctly configured for it. + */ +__override bool board_supports_pcore_ocp(void) +{ + uint32_t board_version; + + if (cbi_get_board_version(&board_version) == EC_SUCCESS && + board_version > 3) + return true; + + return false; +} diff --git a/zephyr/program/skyrim/crystaldrift/src/form_factor.c b/zephyr/program/skyrim/crystaldrift/src/form_factor.c new file mode 100644 index 0000000000..688765617b --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/src/form_factor.c @@ -0,0 +1,38 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "accelgyro.h" +#include "common.h" +#include "cros_board_info.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +#include +#include + +LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Mainboard orientation support. + */ + +#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1)) +#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel)) + +static void form_factor_init(void) +{ + int ret; + uint32_t val; + /* + * If the board version >=4 + * use ver1 rotation matrix. + */ + ret = cbi_get_board_version(&val); + if (ret == EC_SUCCESS && val >= 4) { + LOG_INF("Switching to ver1 lid"); + motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT; + } +} +DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/skyrim/crystaldrift/src/ppc_config.c b/zephyr/program/skyrim/crystaldrift/src/ppc_config.c new file mode 100644 index 0000000000..3913fda4dc --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/src/ppc_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Crystaldrift board-specific PPC code */ + +#include "driver/ppc/aoz1380_public.h" +#include "driver/ppc/nx20p348x.h" +#include "usbc_ppc.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * In the AOZ1380 PPC, there are no programmable features. We use + * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 + * current limits. + */ +int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv = EC_SUCCESS; + + rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), + (rp == TYPEC_RP_3A0) ? 1 : 0); + + return rv; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + aoz1380_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/crystaldrift/src/usb_mux_config.c b/zephyr/program/skyrim/crystaldrift/src/usb_mux_config.c new file mode 100644 index 0000000000..0e08431360 --- /dev/null +++ b/zephyr/program/skyrim/crystaldrift/src/usb_mux_config.c @@ -0,0 +1,142 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Crystaldrift board-specific USB-C mux configuration */ + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } + + return EC_SUCCESS; +} + +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + CPRINTSUSB("C1: PS8818 mux using default tuning"); + + /* Once a DP connection is established, we need to set IN_HPD */ + if (mux_state & USB_PD_MUX_DP_ENABLED) + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + else + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + + return 0; +} + +static void setup_mux(void) +{ + uint32_t val; + + if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) + CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); + /* Val will have our dts default on error, so continue setup */ + + if (val == FW_IO_DB_PS8811_PS8818) { + CPRINTSUSB("C1: Setting PS8818 mux"); + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); + } else if (val == FW_IO_DB_NONE_ANX7483) { + CPRINTSUSB("C1: Setting ANX7483 mux"); + } else { + CPRINTSUSB("Unexpected DB_IO board: %d", val); + } +} +DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/fan.dts b/zephyr/program/skyrim/fan.dts deleted file mode 100644 index dff26bcb29..0000000000 --- a/zephyr/program/skyrim/fan.dts +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - fans { - compatible = "cros-ec,fans"; - - fan0: fan_0 { - pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; - rpm_min = <3100>; - rpm_start = <3100>; - rpm_max = <8000>; - tach = <&tach1>; - pgood_gpio = <&gpio_s0_pgood>; - }; - }; -}; - -/* Tachemeter for fan speed measurement */ -&tach1 { - status = "okay"; - pinctrl-0 = <&ta1_1_in_gp40>; - pinctrl-names = "default"; - port = ; /* port-A is selected */ - sample-clk = ; /* Use LFCLK as sampling clock */ - pulses-per-round = <2>; /* number of pulses per round of encoder */ -}; - -&pwm0_gpc3 { - drive-open-drain; -}; - -&pwm0 { - status = "okay"; - pinctrl-0 = <&pwm0_gpc3>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/fan.dtsi b/zephyr/program/skyrim/fan.dtsi new file mode 100644 index 0000000000..dff26bcb29 --- /dev/null +++ b/zephyr/program/skyrim/fan.dtsi @@ -0,0 +1,39 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + fans { + compatible = "cros-ec,fans"; + + fan0: fan_0 { + pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; + rpm_min = <3100>; + rpm_start = <3100>; + rpm_max = <8000>; + tach = <&tach1>; + pgood_gpio = <&gpio_s0_pgood>; + }; + }; +}; + +/* Tachemeter for fan speed measurement */ +&tach1 { + status = "okay"; + pinctrl-0 = <&ta1_1_in_gp40>; + pinctrl-names = "default"; + port = ; /* port-A is selected */ + sample-clk = ; /* Use LFCLK as sampling clock */ + pulses-per-round = <2>; /* number of pulses per round of encoder */ +}; + +&pwm0_gpc3 { + drive-open-drain; +}; + +&pwm0 { + status = "okay"; + pinctrl-0 = <&pwm0_gpc3>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/frostflow.dts b/zephyr/program/skyrim/frostflow.dts deleted file mode 100644 index 5e4a21ae57..0000000000 --- a/zephyr/program/skyrim/frostflow.dts +++ /dev/null @@ -1,223 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Frostflow-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - temp_soc: soc-pct2075 { - temp_host_high = <75>; - temp_host_halt = <80>; - temp_host_release_high = <65>; - temp_host_release_halt = <70>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - temp_amb: amb-pct2075 { - temp_host_high = <65>; - temp_host_halt = <70>; - temp_host_release_high = <55>; - temp_host_release_halt = <60>; - temp_fan_off = <32>; - temp_fan_max = <45>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <1 0 0 - 0 1 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - 1 0 0 - 0 0 (-1)>; - }; - }; - - ppc_port0: aoz1380 { - compatible = "aoz,aoz1380"; - status = "okay"; - }; - - fan_steps_clamshell: fan-steps-clamshell { - compatible = "cros-ec,fan-steps"; - level_0 { - temp_on = <(-1) (-1) (-1) (-1) 31>; - temp_off = <(-1) (-1) (-1) (-1) 99>; - rpm_target = <0>; - }; - level_1 { - temp_on = <(-1) (-1) (-1) (-1) 32>; - temp_off = <(-1) (-1) (-1) (-1) 30>; - rpm_target = <2600>; - }; - level_2 { - temp_on = <(-1) (-1) (-1) (-1) 34>; - temp_off = <(-1) (-1) (-1) (-1) 31>; - rpm_target = <2900>; - }; - level_3 { - temp_on = <(-1) (-1) (-1) (-1) 36>; - temp_off = <(-1) (-1) (-1) (-1) 33>; - rpm_target = <3600>; - }; - level_4 { - temp_on = <(-1) (-1) (-1) (-1) 38>; - temp_off = <(-1) (-1) (-1) (-1) 35>; - rpm_target = <4200>; - }; - level_5 { - temp_on = <(-1) (-1) (-1) (-1) 45>; - temp_off = <(-1) (-1) (-1) (-1) 37>; - rpm_target = <4600>; - }; - }; - - fan_steps_tablet: fan-steps-tablet { - compatible = "cros-ec,fan-steps"; - level_0 { - temp_on = <(-1) (-1) (-1) (-1) 31>; - temp_off = <(-1) (-1) (-1) (-1) 99>; - rpm_target = <0>; - }; - level_1 { - temp_on = <(-1) (-1) (-1) (-1) 32>; - temp_off = <(-1) (-1) (-1) (-1) 30>; - rpm_target = <2600>; - }; - level_2 { - temp_on = <(-1) (-1) (-1) (-1) 34>; - temp_off = <(-1) (-1) (-1) (-1) 31>; - rpm_target = <2900>; - }; - level_3 { - temp_on = <(-1) (-1) (-1) (-1) 36>; - temp_off = <(-1) (-1) (-1) (-1) 33>; - rpm_target = <3600>; - }; - level_4 { - temp_on = <(-1) (-1) (-1) (-1) 38>; - temp_off = <(-1) (-1) (-1) (-1) 35>; - rpm_target = <4200>; - }; - level_5 { - temp_on = <(-1) (-1) (-1) (-1) 45>; - temp_off = <(-1) (-1) (-1) (-1) 37>; - rpm_target = <4600>; - }; - }; -}; - -&i2c1_0 { - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; - ps8818_port1: ps8818@28 { - compatible = "parade,ps8818"; - reg = <0x28>; - flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; - board-set = "board_c1_ps8818_mux_set"; - }; -}; - -&i2c4_1 { - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; -}; - -&amd_fp6_port0 { - board-set = "board_c0_amd_fp6_mux_set"; -}; - -&usbc_port0 { - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-ps8818 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &ps8818_port1>; - }; -}; - -&cros_kb_raw { - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - &kso13_gp04 - &kso14_gp82 - >; -}; - -&temp_sensor_charger { - temp_host_high = <75>; - temp_host_halt = <80>; - temp_host_release_high = <65>; - temp_host_release_halt = <70>; -}; - -&temp_sensor_memory { - temp_host_high = <75>; - temp_host_halt = <80>; - temp_host_release_high = <65>; - temp_host_release_halt = <70>; -}; - -&temp_sensor_cpu { - /delete-property/ temp_host_high; - /delete-property/ temp_host_halt; - /delete-property/ temp_host_release_high; - /delete-property/ temp_fan_off; - /delete-property/ temp_fan_max; -}; - -&fan0 { - pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; - rpm_min = <2400>; - rpm_start = <2600>; - rpm_max = <4600>; -}; diff --git a/zephyr/program/skyrim/frostflow/CMakeLists.txt b/zephyr/program/skyrim/frostflow/CMakeLists.txt new file mode 100644 index 0000000000..dd7eae2384 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cros_ec_library_include_directories_ifdef(CONFIG_BOARD_FROSTFLOW include) +zephyr_include_directories("include") +zephyr_library_sources( + "src/usb_mux_config.c" + "src/ppc_config.c" + "src/thermal.c" +) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION + "src/keyboard.c" + "src/keyboard_customization.c" +) diff --git a/zephyr/program/skyrim/frostflow/battery.dtsi b/zephyr/program/skyrim/frostflow/battery.dtsi new file mode 100644 index 0000000000..2d6b28de70 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/battery.dtsi @@ -0,0 +1,12 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: cdt_c340152 { + compatible = "cdt,c340152", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/frostflow/frostflow.dtsi b/zephyr/program/skyrim/frostflow/frostflow.dtsi new file mode 100644 index 0000000000..1cadf7ee2d --- /dev/null +++ b/zephyr/program/skyrim/frostflow/frostflow.dtsi @@ -0,0 +1,223 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "../i2c.dtsi" + +/ { + named-gpios { + /* Frostflow-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + temp_soc: soc-pct2075 { + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + temp_host_release_halt = <70>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + temp_amb: amb-pct2075 { + temp_host_high = <65>; + temp_host_halt = <70>; + temp_host_release_high = <55>; + temp_host_release_halt = <60>; + temp_fan_off = <32>; + temp_fan_max = <45>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + 1 0 0 + 0 0 (-1)>; + }; + }; + + ppc_port0: aoz1380 { + compatible = "aoz,aoz1380"; + status = "okay"; + }; + + fan_steps_clamshell: fan-steps-clamshell { + compatible = "cros-ec,fan-steps"; + level_0 { + temp_on = <(-1) (-1) (-1) (-1) 31>; + temp_off = <(-1) (-1) (-1) (-1) 99>; + rpm_target = <0>; + }; + level_1 { + temp_on = <(-1) (-1) (-1) (-1) 32>; + temp_off = <(-1) (-1) (-1) (-1) 30>; + rpm_target = <2600>; + }; + level_2 { + temp_on = <(-1) (-1) (-1) (-1) 34>; + temp_off = <(-1) (-1) (-1) (-1) 31>; + rpm_target = <2900>; + }; + level_3 { + temp_on = <(-1) (-1) (-1) (-1) 36>; + temp_off = <(-1) (-1) (-1) (-1) 33>; + rpm_target = <3600>; + }; + level_4 { + temp_on = <(-1) (-1) (-1) (-1) 38>; + temp_off = <(-1) (-1) (-1) (-1) 35>; + rpm_target = <4200>; + }; + level_5 { + temp_on = <(-1) (-1) (-1) (-1) 45>; + temp_off = <(-1) (-1) (-1) (-1) 37>; + rpm_target = <4600>; + }; + }; + + fan_steps_tablet: fan-steps-tablet { + compatible = "cros-ec,fan-steps"; + level_0 { + temp_on = <(-1) (-1) (-1) (-1) 31>; + temp_off = <(-1) (-1) (-1) (-1) 99>; + rpm_target = <0>; + }; + level_1 { + temp_on = <(-1) (-1) (-1) (-1) 32>; + temp_off = <(-1) (-1) (-1) (-1) 30>; + rpm_target = <2600>; + }; + level_2 { + temp_on = <(-1) (-1) (-1) (-1) 34>; + temp_off = <(-1) (-1) (-1) (-1) 31>; + rpm_target = <2900>; + }; + level_3 { + temp_on = <(-1) (-1) (-1) (-1) 36>; + temp_off = <(-1) (-1) (-1) (-1) 33>; + rpm_target = <3600>; + }; + level_4 { + temp_on = <(-1) (-1) (-1) (-1) 38>; + temp_off = <(-1) (-1) (-1) (-1) 35>; + rpm_target = <4200>; + }; + level_5 { + temp_on = <(-1) (-1) (-1) (-1) 45>; + temp_off = <(-1) (-1) (-1) (-1) 37>; + rpm_target = <4600>; + }; + }; +}; + +&i2c1_0 { + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; +}; + +&i2c4_1 { + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; +}; + +&amd_fp6_port0 { + board-set = "board_c0_amd_fp6_mux_set"; +}; + +&usbc_port0 { + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-ps8818 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + }; +}; + +&cros_kb_raw { + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + &kso13_gp04 + &kso14_gp82 + >; +}; + +&temp_sensor_charger { + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + temp_host_release_halt = <70>; +}; + +&temp_sensor_memory { + temp_host_high = <75>; + temp_host_halt = <80>; + temp_host_release_high = <65>; + temp_host_release_halt = <70>; +}; + +&temp_sensor_cpu { + /delete-property/ temp_host_high; + /delete-property/ temp_host_halt; + /delete-property/ temp_host_release_high; + /delete-property/ temp_fan_off; + /delete-property/ temp_fan_max; +}; + +&fan0 { + pwms = <&pwm0 0 PWM_KHZ(25) PWM_POLARITY_NORMAL>; + rpm_min = <2400>; + rpm_start = <2600>; + rpm_max = <4600>; +}; diff --git a/zephyr/program/skyrim/frostflow/include/keyboard_customization.h b/zephyr/program/skyrim/frostflow/include/keyboard_customization.h new file mode 100644 index 0000000000..2d2a997f91 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/include/keyboard_customization.h @@ -0,0 +1,78 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Keyboard configuration */ + +#ifndef __KEYBOARD_CUSTOMIZATION_H +#define __KEYBOARD_CUSTOMIZATION_H + +/* + * KEYBOARD_COLS_MAX has the build time column size. It's used to allocate + * exact spaces for arrays. Actual keyboard scanning is done using + * keyboard_cols, which holds a runtime column size. + */ +#ifdef CONFIG_KEYBOARD_CUSTOMIZATION +#undef KEYBOARD_COLS_MAX +#undef KEYBOARD_ROWS + +#define KEYBOARD_COLS_MAX 15 +#define KEYBOARD_ROWS 8 +#endif + +/* + * WARNING: Do not directly modify it. You should call keyboard_raw_set_cols, + * instead. It checks whether you're eligible or not. + */ +extern uint8_t keyboard_cols; + +#define KEYBOARD_ROW_TO_MASK(r) (1 << (r)) + +/* Columns and masks for keys we particularly care about */ +#define KEYBOARD_COL_DOWN 11 +#define KEYBOARD_ROW_DOWN 5 +#define KEYBOARD_MASK_DOWN KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_DOWN) +#define KEYBOARD_COL_ESC 1 +#define KEYBOARD_ROW_ESC 1 +#define KEYBOARD_MASK_ESC KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_ESC) +#define KEYBOARD_COL_KEY_H 6 +#define KEYBOARD_ROW_KEY_H 1 +#define KEYBOARD_MASK_KEY_H KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_H) +#define KEYBOARD_COL_KEY_R 3 +#define KEYBOARD_ROW_KEY_R 7 +#define KEYBOARD_MASK_KEY_R KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_R) +#define KEYBOARD_COL_LEFT_ALT 10 +#define KEYBOARD_ROW_LEFT_ALT 6 +#define KEYBOARD_MASK_LEFT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_ALT) +#define KEYBOARD_COL_REFRESH 2 +#define KEYBOARD_ROW_REFRESH 3 +#define KEYBOARD_MASK_REFRESH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_REFRESH) +#define KEYBOARD_COL_RIGHT_ALT 10 +#define KEYBOARD_ROW_RIGHT_ALT 0 +#define KEYBOARD_MASK_RIGHT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_ALT) +#define KEYBOARD_DEFAULT_COL_VOL_UP 4 +#define KEYBOARD_DEFAULT_ROW_VOL_UP 1 +#define KEYBOARD_COL_LEFT_CTRL 0 +#define KEYBOARD_ROW_LEFT_CTRL 2 +#define KEYBOARD_MASK_LEFT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_CTRL) +#define KEYBOARD_COL_RIGHT_CTRL 0 +#define KEYBOARD_ROW_RIGHT_CTRL 4 +#define KEYBOARD_MASK_RIGHT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_CTRL) +#define KEYBOARD_COL_SEARCH 0 +#define KEYBOARD_ROW_SEARCH 3 +#define KEYBOARD_MASK_SEARCH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_SEARCH) +#define KEYBOARD_COL_KEY_0 9 +#define KEYBOARD_ROW_KEY_0 0 +#define KEYBOARD_MASK_KEY_0 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_0) +#define KEYBOARD_COL_KEY_1 1 +#define KEYBOARD_ROW_KEY_1 7 +#define KEYBOARD_MASK_KEY_1 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_1) +#define KEYBOARD_COL_KEY_2 4 +#define KEYBOARD_ROW_KEY_2 6 +#define KEYBOARD_MASK_KEY_2 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_2) +#define KEYBOARD_COL_LEFT_SHIFT 7 +#define KEYBOARD_ROW_LEFT_SHIFT 1 +#define KEYBOARD_MASK_LEFT_SHIFT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_SHIFT) + +#endif /* __KEYBOARD_CUSTOMIZATION_H */ diff --git a/zephyr/program/skyrim/frostflow/led_pins.dtsi b/zephyr/program/skyrim/frostflow/led_pins.dtsi new file mode 100644 index 0000000000..78b9a59c40 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/led_pins.dtsi @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_y: pwm_y { + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + pwm_w: pwm_w { + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/frostflow/led_policy.dtsi b/zephyr/program/skyrim/frostflow/led_policy.dtsi new file mode 100644 index 0000000000..e5875640fb --- /dev/null +++ b/zephyr/program/skyrim/frostflow/led_policy.dtsi @@ -0,0 +1,122 @@ +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= Empty, <= 94%) */ + batt-lvl = <0 94>; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-charge-lvl-2 { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= 95%, <= Near Full) */ + batt-lvl = <95 97>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= 11%, <= Full) */ + batt-lvl = <11 100>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= 10%) */ + batt-lvl = <0 10>; + + /* Amber 1 sec, off 3 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 3 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error-s0 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S0"; + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-error-s3 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S3"; + /* White 1 sec, off 3 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <3000>; + }; + }; + + power-state-error-s5 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/frostflow/motionsense.dtsi b/zephyr/program/skyrim/frostflow/motionsense.dtsi new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/motionsense.dtsi @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/frostflow/project.conf b/zephyr/program/skyrim/frostflow/project.conf new file mode 100644 index 0000000000..02da02d35d --- /dev/null +++ b/zephyr/program/skyrim/frostflow/project.conf @@ -0,0 +1,33 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Frostflow reference-board-specific Kconfig settings. +CONFIG_BOARD_FROSTFLOW=y +CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=10 + +# TODO(b/215404321): Remove later in board development +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Frostflow is capable of sinking 45W +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3000 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15000 + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION=y + +# Frostflow not have the USB HUB +CONFIG_BOARD_USB_HUB_RESET=n + +# Battery +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y + +# Fan +CONFIG_PLATFORM_EC_FAN=y +CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL=y diff --git a/zephyr/program/skyrim/frostflow/project.overlay b/zephyr/program/skyrim/frostflow/project.overlay new file mode 100644 index 0000000000..a1bc7dbb5e --- /dev/null +++ b/zephyr/program/skyrim/frostflow/project.overlay @@ -0,0 +1,19 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim program common DTS includes */ +#include "../adc.dtsi" +#include "../fan.dtsi" +#include "../gpio.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../usbc.dtsi" + +/* Frostflow project DTS includes*/ +#include "frostflow.dtsi" +#include "battery.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" diff --git a/zephyr/program/skyrim/frostflow/src/keyboard.c b/zephyr/program/skyrim/frostflow/src/keyboard.c new file mode 100644 index 0000000000..2905f17941 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/src/keyboard.c @@ -0,0 +1,74 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" +#include "keyboard_scan.h" +#include "timer.h" + +/* Keyboard scan setting */ +__override struct keyboard_scan_config keyscan_config = { + /* Increase from 50 us, because KSO_02 passes through the H1. */ + .output_settle_us = 80, + /* Other values should be the same as the default configuration. */ + .debounce_down_us = 9 * MSEC, + .debounce_up_us = 30 * MSEC, + .scan_period_us = 3 * MSEC, + .min_post_scan_delay_us = 1000, + .poll_timeout_us = 100 * MSEC, + .actual_key_mask = { + 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0x86, 0xff, 0xff, 0x55, 0xff, 0xff, 0xff, 0xff, /* full set */ + }, +}; + +static const struct ec_response_keybd_config frostflow_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &frostflow_kb; +} + +/* + * Row Column info for Top row keys T1 - T15. + * on frostflow_kb keyboard Row Column is customization + * need define row col to mapping matrix layout. + */ +__override const struct key { + uint8_t row; + uint8_t col; +} vivaldi_keys[] = { + { .row = 4, .col = 2 }, /* T1 */ + { .row = 3, .col = 2 }, /* T2 */ + { .row = 2, .col = 2 }, /* T3 */ + { .row = 1, .col = 2 }, /* T4 */ + { .row = 4, .col = 4 }, /* T5 */ + { .row = 3, .col = 4 }, /* T6 */ + { .row = 2, .col = 4 }, /* T7 */ + { .row = 2, .col = 9 }, /* T8 */ + { .row = 1, .col = 9 }, /* T9 */ + { .row = 1, .col = 4 }, /* T10 */ + { .row = 0, .col = 4 }, /* T11 */ + { .row = 1, .col = 5 }, /* T12 */ + { .row = 3, .col = 5 }, /* T13 */ + { .row = 2, .col = 1 }, /* T14 */ + { .row = 0, .col = 1 }, /* T15 */ +}; +BUILD_ASSERT(ARRAY_SIZE(vivaldi_keys) == MAX_TOP_ROW_KEYS); diff --git a/zephyr/program/skyrim/frostflow/src/keyboard_customization.c b/zephyr/program/skyrim/frostflow/src/keyboard_customization.c new file mode 100644 index 0000000000..bd02940e03 --- /dev/null +++ b/zephyr/program/skyrim/frostflow/src/keyboard_customization.c @@ -0,0 +1,85 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "gpio.h" +#include "keyboard_customization.h" +#include "keyboard_protocol.h" +#include "keyboard_raw.h" + +#include + +static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { + { 0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0x0000, 0x0000, 0x0000 }, + { 0x001f, 0x0076, 0x0017, 0x000e, 0x001c, 0x003a, 0x000d, 0x0016 }, + { 0x006c, 0xe024, 0xe01d, 0xe020, 0xe038, 0xe071, 0x0026, 0x002a }, + { 0x0032, 0x0034, 0x002c, 0x002e, 0x002b, 0x0029, 0x0025, 0x002d }, + { 0x0078, 0xe032, 0xe035, 0xe02c, 0xe02d, 0x0041, 0x001e, 0x001d }, + { 0x0051, 0x0007, 0x005b, 0x000f, 0x0042, 0x0022, 0x003e, 0x0043 }, + { 0x0031, 0x0033, 0x0035, 0x0036, 0x003b, 0x001b, 0x003d, 0x003c }, + { 0x0000, 0x0012, 0x0061, 0x0000, 0x0000, 0x0000, 0x0000, 0x0059 }, + { 0x0055, 0x0052, 0x0054, 0x004e, 0x004c, 0x0024, 0x0044, 0x004d }, + { 0x0045, 0xe021, 0xe023, 0x002f, 0x004b, 0x0049, 0x0046, 0x001a }, + { 0xe011, 0x0000, 0x006a, 0x0000, 0x005d, 0x0000, 0x0011, 0x0000 }, + { 0xe07a, 0x005d, 0xe075, 0x006b, 0x005a, 0xe072, 0x004a, 0x0066 }, + { 0xe06b, 0xe074, 0xe069, 0x0067, 0xe06c, 0x0064, 0x0015, 0xe07d }, + { 0x0073, 0x007c, 0x007b, 0x0074, 0x0071, 0xe04a, 0x0070, 0x0021 }, + { 0x0023, 0xe05a, 0x0075, 0x0079, 0x007a, 0x0072, 0x007d, 0x0069 }, +}; + +uint16_t get_scancode_set2(uint8_t row, uint8_t col) +{ + if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) + return scancode_set2[col][row]; + return 0; +} + +void set_scancode_set2(uint8_t row, uint8_t col, uint16_t val) +{ + if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) + scancode_set2[col][row] = val; +} + +#ifdef CONFIG_KEYBOARD_DEBUG +static char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { + { 'c', KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO }, + { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, + { 'q', KLLI_UNKNO, KLLI_UNKNO, KLLI_TAB, '`', '1', KLLI_UNKNO, 'a' }, + { KLLI_R_ALT, KLLI_L_ALT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, + { KLLI_UNKNO, KLLI_SPACE, 'e', KLLI_F4, KLLI_SEARC, '3', KLLI_F3, + KLLI_UNKNO }, + { 'x', 'z', KLLI_F2, KLLI_F1, 's', '2', 'w', KLLI_ESC }, + { 'v', 'b', 'g', 't', '5', '4', 'r', 'f' }, + { 'm', 'n', 'h', 'y', '6', '7', 'u', 'j' }, + { '.', KLLI_DOWN, '\\', 'o', KLLI_F10, '9', KLLI_UNKNO, 'l' }, + { KLLI_R_SHT, KLLI_L_SHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, + { ',', KLLI_UNKNO, KLLI_F7, KLLI_F6, KLLI_F5, '8', 'i', 'k' }, + { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_F9, KLLI_UNKNO, KLLI_UNKNO, + KLLI_LEFT, KLLI_UNKNO }, + { KLLI_R_CTR, KLLI_L_CTR, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, + { '/', KLLI_UP, '-', KLLI_UNKNO, '0', 'p', '[', ';' }, + { '\'', KLLI_ENTER, KLLI_UNKNO, KLLI_UNKNO, '=', KLLI_B_SPC, ']', 'd' }, + { KLLI_UNKNO, KLLI_F8, KLLI_RIGHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, + KLLI_UNKNO, KLLI_UNKNO }, +}; + +char get_keycap_label(uint8_t row, uint8_t col) +{ + if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) + return keycap_label[col][row]; + return KLLI_UNKNO; +} + +void set_keycap_label(uint8_t row, uint8_t col, char val) +{ + if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) + keycap_label[col][row] = val; +} +#endif diff --git a/zephyr/program/skyrim/frostflow/src/ppc_config.c b/zephyr/program/skyrim/frostflow/src/ppc_config.c new file mode 100644 index 0000000000..513c025dec --- /dev/null +++ b/zephyr/program/skyrim/frostflow/src/ppc_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Frostflow board-specific PPC code */ + +#include "driver/ppc/aoz1380_public.h" +#include "driver/ppc/nx20p348x.h" +#include "usbc_ppc.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * In the AOZ1380 PPC, there are no programmable features. We use + * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 + * current limits. + */ +int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv = EC_SUCCESS; + + rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), + (rp == TYPEC_RP_3A0) ? 1 : 0); + + return rv; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + aoz1380_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/frostflow/src/thermal.c b/zephyr/program/skyrim/frostflow/src/thermal.c new file mode 100644 index 0000000000..eae8aac25d --- /dev/null +++ b/zephyr/program/skyrim/frostflow/src/thermal.c @@ -0,0 +1,109 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "chipset.h" +#include "fan.h" +#include "tablet_mode.h" +#include "temp_sensor/temp_sensor.h" +#include "thermal.h" +#include "util.h" +#include "console.h" + +#define TEMP_AMB TEMP_SENSOR_ID(DT_NODELABEL(temp_amb)) + +struct fan_step { + /* + * Sensor 0~4 trigger point, set -1 if we're not using this + * sensor to determine fan speed. + */ + int on[TEMP_SENSOR_COUNT]; + /* + * Sensor 0~4 release point, set -1 if we're not using this + * sensor to determine fan speed. + */ + int off[TEMP_SENSOR_COUNT]; + /* Fan rpm */ + uint16_t rpm[FAN_CH_COUNT]; +}; + +#define FAN_TABLE_ENTRY(nd) \ + { \ + .on = DT_PROP(nd, temp_on), \ + .off = DT_PROP(nd, temp_off), \ + .rpm = DT_PROP(nd, rpm_target), \ + }, + +static const struct fan_step fan_table_clamshell[] = { DT_FOREACH_CHILD( + DT_NODELABEL(fan_steps_clamshell), FAN_TABLE_ENTRY) }; + +static const struct fan_step fan_table_tablet[] = { DT_FOREACH_CHILD( + DT_NODELABEL(fan_steps_tablet), FAN_TABLE_ENTRY) }; + +static const struct fan_step *fan_step_table; +#define NUM_FAN_LEVELS ARRAY_SIZE(fan_table_clamshell) + +BUILD_ASSERT(ARRAY_SIZE(fan_table_clamshell) == ARRAY_SIZE(fan_table_tablet)); + +int fan_table_to_rpm(int fan, int *temp) +{ + /* current fan level */ + static int current_level; + /* previous sensor temperature */ + static int prev_tmp[TEMP_SENSOR_COUNT]; + int i; + + if (tablet_get_mode()) + fan_step_table = fan_table_tablet; + else + fan_step_table = fan_table_clamshell; + + /* + * Compare the current and previous temperature, we have + * the three paths : + * 1. decreasing path. (check the release point) + * 2. increasing path. (check the trigger point) + * 3. invariant path. (return the current RPM) + */ + + if (temp[TEMP_AMB] < prev_tmp[TEMP_AMB]) { + for (i = current_level; i > 0; i--) { + if (temp[TEMP_AMB] < fan_step_table[i].off[TEMP_AMB]) + current_level = i - 1; + else + break; + } + } else if (temp[TEMP_AMB] > prev_tmp[TEMP_AMB]) { + for (i = current_level; i < NUM_FAN_LEVELS; i++) { + if (temp[TEMP_AMB] > fan_step_table[i].on[TEMP_AMB]) + current_level = i + 1; + else + break; + } + } + + if (current_level < 0) + current_level = 0; + + if (current_level >= NUM_FAN_LEVELS) + current_level = NUM_FAN_LEVELS - 1; + + for (i = 0; i < TEMP_SENSOR_COUNT; ++i) + prev_tmp[i] = temp[i]; + + return fan_step_table[current_level].rpm[fan]; +} + +void board_override_fan_control(int fan, int *temp) +{ + /* + * In common/fan.c pwm_fan_stop() will turn off fan + * when chipset suspend or shutdown. + */ + if (chipset_in_state(CHIPSET_STATE_ON)) { + fan_set_rpm_mode(fan, 1); + fan_set_rpm_target(fan, fan_table_to_rpm(fan, temp)); + } +} diff --git a/zephyr/program/skyrim/frostflow/src/usb_mux_config.c b/zephyr/program/skyrim/frostflow/src/usb_mux_config.c new file mode 100644 index 0000000000..2ec1dda0be --- /dev/null +++ b/zephyr/program/skyrim/frostflow/src/usb_mux_config.c @@ -0,0 +1,62 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Frostflow board-specific USB-C mux configuration */ + +#include "ioexpander.h" +#include "usbc/usb_muxes.h" + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ps8815 DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_c0_amd_fp6_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return EC_SUCCESS; +} + +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + CPRINTSUSB("C1: PS8818 mux using default tuning"); + + /* Once a DP connection is established, we need to set IN_HPD */ + if (mux_state & USB_PD_MUX_DP_ENABLED) + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + else + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + + return 0; +} diff --git a/zephyr/program/skyrim/gpio.dts b/zephyr/program/skyrim/gpio.dts deleted file mode 100644 index 2b79bad222..0000000000 --- a/zephyr/program/skyrim/gpio.dts +++ /dev/null @@ -1,370 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - aliases { - gpio-wp = &gpio_wp; - gpio-cbi-wp = &gpio_cbi_wp; - gpio-kbd-kso2 = &gpio_ec_kso_02_inv; - }; - - /* GPIOs shared by all boards */ - named-gpios { - compatible = "named-gpios"; - - ccd_mode_odl { - gpios = <&gpioc 6 GPIO_ODR_HIGH>; - }; - ec_gsc_packet_mode { - gpios = <&gpiob 1 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PACKET_MODE_EN"; - }; - gpio_mech_pwr_btn_odl: mech_pwr_btn_odl { - gpios = <&gpiod 2 GPIO_INPUT>; - enum-name = "GPIO_POWER_BUTTON_L"; - }; - gpio_slp_s3_l: slp_s3_l { - gpios = <&gpio6 1 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S3_L"; - alias = "GPIO_PCH_SLP_S0_L"; - }; - gpio_slp_s5_l: slp_s5_l { - gpios = <&gpio7 2 GPIO_INPUT>; - enum-name = "GPIO_PCH_SLP_S5_L"; - }; - gpio_pg_pwr_s5: pg_pwr_s5 { - gpios = <&gpioc 0 GPIO_INPUT>; - enum-name = "GPIO_S5_PGOOD"; - }; - gpio_s0_pgood: pg_pcore_s0_r_od { - gpios = <&gpiob 6 GPIO_INPUT>; - enum-name = "GPIO_S0_PGOOD"; - }; - gpio_acok_od: acok_od { - gpios = <&gpio0 0 GPIO_INPUT>; - enum-name = "GPIO_AC_PRESENT"; - }; - gpio_en_pwr_s5: en_pwr_s5 { - gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PWR_A"; - }; - gpio_en_pwr_s0_r: en_pwr_s0_r { - gpios = <&gpiof 1 GPIO_OUTPUT_LOW>; - }; - gpio_en_pwr_pcore_s0_r: en_pwr_pcore_s0_r { - gpios = <&gpioe 1 GPIO_OUTPUT_LOW>; - }; - ec_sys_rst_l { - gpios = <&gpio7 6 GPIO_ODR_HIGH>; - enum-name = "GPIO_SYS_RESET_L"; - }; - gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { - gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_PCH_RSMRST_L"; - }; - gpio_ec_pch_wake_odl: ec_soc_wake_l { - gpios = <&gpio0 3 GPIO_OUTPUT_HIGH>; - }; - prochot_odl { - gpios = <&gpiod 5 GPIO_ODR_HIGH>; - enum-name = "GPIO_CPU_PROCHOT"; - }; - soc_alert_ec_l { - gpios = <&gpioe 2 GPIO_INPUT>; - }; - gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { - gpios = <&gpioe 0 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; - }; - gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { - gpios = <&gpioc 7 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_TCPC_INT_ODL"; - }; - gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { - gpios = <&gpio7 5 GPIO_INPUT>; - enum-name = "GPIO_USB_C0_PPC_INT_ODL"; - }; - gpio_usb_c1_ppc_int_odl: usb_c1_ppc_int_odl { - gpios = <&gpiod 4 GPIO_INPUT>; - enum-name = "GPIO_USB_C1_PPC_INT_ODL"; - }; - gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { - gpios = <&gpioa 4 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_USB_C0_BC12_INT_ODL"; - }; - gpio_usb_c1_bc12_int_odl: usb_c1_bc12_int_odl { - gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_USB_C1_BC12_INT_ODL"; - }; - gpio_usb_c0_tcpc_rst_l: usb_c0_tcpc_rst_l { - gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_USB_C0_TCPC_RST_L"; - }; - gpio_usb_c1_tcpc_rst_l: usb_c1_tcpc_rst_l { - gpios = <&gpio3 7 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_USB_C1_TCPC_RST_L"; - }; - usb_c0_hpd { - gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C0_DP_HPD"; - }; - usb_c1_hpd { - gpios = <&gpiof 4 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_USB_C1_DP_HPD"; - }; - gpio_lid_open: lid_open { - gpios = <&gpio0 2 GPIO_INPUT>; - enum-name = "GPIO_LID_OPEN"; - }; - gpio_ec_batt_pres_odl: ec_batt_pres_odl { - gpios = <&gpio9 4 GPIO_INPUT>; - enum-name = "GPIO_BATT_PRES_ODL"; - }; - gpio_ec_disable_disp_bl: ec_disable_disp_bl { - gpios = <&gpioa 6 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_ENABLE_BACKLIGHT_L"; - }; - gpio_usb_fault_odl: usb_fault_odl { - gpios = <&gpio5 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; - }; - gpio_en_pwr_s3: en_pwr_s3 { - gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; - }; - gpio_pg_groupc_s0_od: pg_groupc_s0_od { - gpios = <&gpiof 0 GPIO_INPUT>; - }; - gpio_ec_i2c_usbc_pd_int: ec_i2c_usbc_pd_int { - gpios = <&gpioa 3 GPIO_INPUT>; - }; - gpio_soc_thermtrip_odl: soc_thermtrip_odl { - gpios = <&gpio9 5 GPIO_INPUT>; - }; - gpio_hub_rst: hub_rst { - gpios = <&gpio6 6 GPIO_OUTPUT_HIGH>; - }; - ec_soc_int_l { - gpios = <&gpioa 1 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EC_INT_L"; - }; - gpio_ec_soc_pwr_good: ec_soc_pwr_good { - gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; - }; - gpio_pcore_ocp_r_l: pcore_ocp_r_l { - gpios = <&gpioa 5 GPIO_INPUT>; - }; - gpio_usb_hub_fault_q_odl: usb_hub_fault_q_odl { - gpios = <&gpioe 5 GPIO_INPUT_PULL_UP>; - }; - gpio_pg_lpddr5_s3_od: pg_lpddr5_s3_od { - gpios = <&gpio7 3 GPIO_INPUT>; - }; - 3axis_int_l { - gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; - }; - gpio_ec_soc_pwr_btn_l: ec_soc_pwr_btn_l { - gpios = <&gpioa 7 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_PCH_PWRBTN_L"; - }; - gpio_volup_btn_odl: volup_btn_odl { - gpios = <&gpio6 7 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_UP_L"; - }; - gpio_voldn_btn_odl: voldn_btn_odl { - gpios = <&gpio7 0 GPIO_INPUT_PULL_UP>; - enum-name = "GPIO_VOLUME_DOWN_L"; - }; - ec_sc_rst { - gpios = <&gpiob 0 GPIO_OUTPUT_LOW>; - }; - gpio_cbi_wp: ec_cbi_wp { - gpios = <&gpio8 1 GPIO_OUTPUT_LOW>; - }; - gpio_wp: ec_wp_l { - gpios = <&gpiod 7 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; - }; - gpio_pg_lpddr5_s0_od: pg_lpddr5_s0_od { - gpios = <&gpio6 0 GPIO_INPUT>; - }; - ec_espi_rst_l { - gpios = <&gpio5 4 GPIO_PULL_DOWN>; - }; - gpio_accel_gyro_int_l: accel_gyro_int_l { - gpios = <&gpioa 0 GPIO_INPUT>; - }; - /* unimplemented GPIOs */ - entering-rw { - enum-name = "GPIO_ENTERING_RW"; - }; - pch-sys-prwok { - enum-name = "GPIO_PCH_SYS_PWROK"; - }; - ec_i2c_usb_a0_c0_scl { - gpios = <&gpiob 5 GPIO_INPUT>; - }; - ec_i2c_usb_a0_c0_sda { - gpios = <&gpiob 4 GPIO_INPUT>; - }; - ec_i2c_usb_a1_c1_scl { - gpios = <&gpio9 0 GPIO_INPUT>; - }; - ec_i2c_usb_a1_c1_sda { - gpios = <&gpio8 7 GPIO_INPUT>; - }; - ec_i2c_batt_scl { - gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_batt_sda { - gpios = <&gpio9 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_usbc_mux_scl { - gpios = <&gpiod 1 GPIO_INPUT>; - }; - ec_i2c_usbc_mux_sda { - gpios = <&gpiod 0 GPIO_INPUT>; - }; - ec_i2c_power_scl { - gpios = <&gpiof 3 GPIO_INPUT>; - }; - ec_i2c_power_sda { - gpios = <&gpiof 2 GPIO_INPUT>; - }; - ec_i2c_cbi_scl { - gpios = <&gpio3 3 GPIO_INPUT>; - }; - ec_i2c_cbi_sda { - gpios = <&gpio3 6 GPIO_INPUT>; - }; - ec_i2c_sensor_scl { - gpios = <&gpioe 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_sensor_sda { - gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_soc_sic { - gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - ec_i2c_soc_sid { - gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; - }; - en_kb_bl { - gpios = <&gpio9 7 GPIO_OUTPUT_HIGH>; - enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; - }; - gpio_ec_kso_02_inv: ec_kso_02_inv { - gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; - }; - tablet_mode_l { - gpios = <&gpioc 1 GPIO_INPUT>; - enum-name = "GPIO_TABLET_MODE_L"; - }; - ec_gpio56 { - gpios = <&gpio5 6 GPIO_INPUT_PULL_UP>; - }; - ec_flprg2 { - gpios = <&gpio8 6 GPIO_INPUT_PULL_UP>; - }; - - usb_c0_tcpc_fastsw_ctl_en { - gpios = <&ioex_c0_port0 4 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_TCPC_FASTSW_CTL_EN"; - }; - usb_c0_ppc_en_l { - gpios = <&ioex_c0_port1 0 GPIO_OUTPUT_LOW>; - }; - ioex_usb_c0_ilim_3a_en: usb_c0_ppc_ilim_3a_en { - gpios = <&ioex_c0_port1 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_PPC_ILIM_3A_EN"; - }; - ioex_usb_c0_sbu_fault_odl: usb_c0_sbu_fault_odl { - gpios = <&ioex_c0_port1 2 GPIO_INPUT>; - }; - ioex_en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { - gpios = <&ioex_c0_port1 5 GPIO_OUTPUT_LOW>; - }; - ioex_usb_a0_fault_odl: usb_a0_fault_odl { - gpios = <&ioex_c0_port1 6 GPIO_INPUT>; - }; - ioex_usb_c0_sbu_flip: usb_c0_sbu_flip { - gpios = <&ioex_c0_port1 7 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C0_SBU_FLIP"; - }; - - usb_a1_retimer_en { - gpios = <&ioex_c1_port0 0 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_A1_RETIMER_EN"; - }; - usb_a1_retimer_rst { - gpios = <&ioex_c1_port0 1 GPIO_OUTPUT_LOW>; - }; - usb_c1_in_hpd { - gpios = <&ioex_c1_port0 3 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_HPD_IN_DB"; - }; - usb_c1_tcpc_fastsw_ctl_en { - gpios = <&ioex_c1_port0 4 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_TCPC_FASTSW_CTL_EN"; - }; - usb_c1_ppc_en_l { - gpios = <&ioex_c1_port1 0 GPIO_OUTPUT_LOW>; - }; - usb_c1_ppc_ilim_3a_en { - gpios = <&ioex_c1_port1 1 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_PPC_ILIM_3A_EN"; - }; - ioex_usb_c1_sbu_fault_odl: usb_c1_sbu_fault_odl { - gpios = <&ioex_c1_port1 2 GPIO_INPUT>; - enum-name = "IOEX_USB_C1_FAULT_ODL"; - }; - ioex_en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus { - gpios = <&ioex_c1_port1 5 GPIO_OUTPUT_LOW>; - }; - ioex_usb_a1_fault_db_odl: usb_a1_fault_db_odl { - gpios = <&ioex_c1_port1 6 GPIO_INPUT>; - }; - ioex_usb_c1_sbu_flip: usb_c1_sbu_flip { - gpios = <&ioex_c1_port1 7 GPIO_OUTPUT_LOW>; - enum-name = "IOEX_USB_C1_SBU_FLIP"; - }; - }; - - usba-port-enable-list { - compatible = "cros-ec,usba-port-enable-pins"; - enable-pins = <&ioex_en_pp5000_usb_a0_vbus - &ioex_en_pp5000_usb_a1_vbus>; - }; -}; - -/* PSL input pads*/ -&psl_in1_gpd2 { - /* MECH_PWR_BTN_ODL */ - psl-in-mode = "edge"; - psl-in-pol = "low-falling"; -}; - -&psl_in2_gp00 { - /* ACOK_OD */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -&psl_in4_gp02 { - /* LID_OPEN */ - psl-in-mode = "edge"; - psl-in-pol = "high-rising"; -}; - -/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ -&power_ctrl_psl { - status = "okay"; - pinctrl-names = "sleep"; - pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in4_gp02>; -}; - -/* host interface */ -&espi0 { - status = "okay"; - pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/gpio.dtsi b/zephyr/program/skyrim/gpio.dtsi new file mode 100644 index 0000000000..2b79bad222 --- /dev/null +++ b/zephyr/program/skyrim/gpio.dtsi @@ -0,0 +1,370 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + gpio-wp = &gpio_wp; + gpio-cbi-wp = &gpio_cbi_wp; + gpio-kbd-kso2 = &gpio_ec_kso_02_inv; + }; + + /* GPIOs shared by all boards */ + named-gpios { + compatible = "named-gpios"; + + ccd_mode_odl { + gpios = <&gpioc 6 GPIO_ODR_HIGH>; + }; + ec_gsc_packet_mode { + gpios = <&gpiob 1 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + gpio_mech_pwr_btn_odl: mech_pwr_btn_odl { + gpios = <&gpiod 2 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + gpio_slp_s3_l: slp_s3_l { + gpios = <&gpio6 1 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S3_L"; + alias = "GPIO_PCH_SLP_S0_L"; + }; + gpio_slp_s5_l: slp_s5_l { + gpios = <&gpio7 2 GPIO_INPUT>; + enum-name = "GPIO_PCH_SLP_S5_L"; + }; + gpio_pg_pwr_s5: pg_pwr_s5 { + gpios = <&gpioc 0 GPIO_INPUT>; + enum-name = "GPIO_S5_PGOOD"; + }; + gpio_s0_pgood: pg_pcore_s0_r_od { + gpios = <&gpiob 6 GPIO_INPUT>; + enum-name = "GPIO_S0_PGOOD"; + }; + gpio_acok_od: acok_od { + gpios = <&gpio0 0 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_en_pwr_s5: en_pwr_s5 { + gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_EN_PWR_A"; + }; + gpio_en_pwr_s0_r: en_pwr_s0_r { + gpios = <&gpiof 1 GPIO_OUTPUT_LOW>; + }; + gpio_en_pwr_pcore_s0_r: en_pwr_pcore_s0_r { + gpios = <&gpioe 1 GPIO_OUTPUT_LOW>; + }; + ec_sys_rst_l { + gpios = <&gpio7 6 GPIO_ODR_HIGH>; + enum-name = "GPIO_SYS_RESET_L"; + }; + gpio_ec_soc_rsmrst_l: ec_soc_rsmrst_l { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PCH_RSMRST_L"; + }; + gpio_ec_pch_wake_odl: ec_soc_wake_l { + gpios = <&gpio0 3 GPIO_OUTPUT_HIGH>; + }; + prochot_odl { + gpios = <&gpiod 5 GPIO_ODR_HIGH>; + enum-name = "GPIO_CPU_PROCHOT"; + }; + soc_alert_ec_l { + gpios = <&gpioe 2 GPIO_INPUT>; + }; + gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { + gpios = <&gpioe 0 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; + }; + gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { + gpios = <&gpioc 7 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_TCPC_INT_ODL"; + }; + gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpio7 5 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + gpio_usb_c1_ppc_int_odl: usb_c1_ppc_int_odl { + gpios = <&gpiod 4 GPIO_INPUT>; + enum-name = "GPIO_USB_C1_PPC_INT_ODL"; + }; + gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpioa 4 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + gpio_usb_c1_bc12_int_odl: usb_c1_bc12_int_odl { + gpios = <&gpio9 6 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_USB_C1_BC12_INT_ODL"; + }; + gpio_usb_c0_tcpc_rst_l: usb_c0_tcpc_rst_l { + gpios = <&gpio3 4 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_USB_C0_TCPC_RST_L"; + }; + gpio_usb_c1_tcpc_rst_l: usb_c1_tcpc_rst_l { + gpios = <&gpio3 7 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_USB_C1_TCPC_RST_L"; + }; + usb_c0_hpd { + gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_DP_HPD"; + }; + usb_c1_hpd { + gpios = <&gpiof 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C1_DP_HPD"; + }; + gpio_lid_open: lid_open { + gpios = <&gpio0 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + gpio_ec_batt_pres_odl: ec_batt_pres_odl { + gpios = <&gpio9 4 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + gpio_ec_disable_disp_bl: ec_disable_disp_bl { + gpios = <&gpioa 6 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_ENABLE_BACKLIGHT_L"; + }; + gpio_usb_fault_odl: usb_fault_odl { + gpios = <&gpio5 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + }; + gpio_en_pwr_s3: en_pwr_s3 { + gpios = <&gpio7 4 GPIO_OUTPUT_LOW>; + }; + gpio_pg_groupc_s0_od: pg_groupc_s0_od { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + gpio_ec_i2c_usbc_pd_int: ec_i2c_usbc_pd_int { + gpios = <&gpioa 3 GPIO_INPUT>; + }; + gpio_soc_thermtrip_odl: soc_thermtrip_odl { + gpios = <&gpio9 5 GPIO_INPUT>; + }; + gpio_hub_rst: hub_rst { + gpios = <&gpio6 6 GPIO_OUTPUT_HIGH>; + }; + ec_soc_int_l { + gpios = <&gpioa 1 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EC_INT_L"; + }; + gpio_ec_soc_pwr_good: ec_soc_pwr_good { + gpios = <&gpiod 3 GPIO_OUTPUT_LOW>; + }; + gpio_pcore_ocp_r_l: pcore_ocp_r_l { + gpios = <&gpioa 5 GPIO_INPUT>; + }; + gpio_usb_hub_fault_q_odl: usb_hub_fault_q_odl { + gpios = <&gpioe 5 GPIO_INPUT_PULL_UP>; + }; + gpio_pg_lpddr5_s3_od: pg_lpddr5_s3_od { + gpios = <&gpio7 3 GPIO_INPUT>; + }; + 3axis_int_l { + gpios = <&gpioa 2 GPIO_INPUT_PULL_UP>; + }; + gpio_ec_soc_pwr_btn_l: ec_soc_pwr_btn_l { + gpios = <&gpioa 7 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_PCH_PWRBTN_L"; + }; + gpio_volup_btn_odl: volup_btn_odl { + gpios = <&gpio6 7 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_voldn_btn_odl: voldn_btn_odl { + gpios = <&gpio7 0 GPIO_INPUT_PULL_UP>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + ec_sc_rst { + gpios = <&gpiob 0 GPIO_OUTPUT_LOW>; + }; + gpio_cbi_wp: ec_cbi_wp { + gpios = <&gpio8 1 GPIO_OUTPUT_LOW>; + }; + gpio_wp: ec_wp_l { + gpios = <&gpiod 7 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + }; + gpio_pg_lpddr5_s0_od: pg_lpddr5_s0_od { + gpios = <&gpio6 0 GPIO_INPUT>; + }; + ec_espi_rst_l { + gpios = <&gpio5 4 GPIO_PULL_DOWN>; + }; + gpio_accel_gyro_int_l: accel_gyro_int_l { + gpios = <&gpioa 0 GPIO_INPUT>; + }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; + pch-sys-prwok { + enum-name = "GPIO_PCH_SYS_PWROK"; + }; + ec_i2c_usb_a0_c0_scl { + gpios = <&gpiob 5 GPIO_INPUT>; + }; + ec_i2c_usb_a0_c0_sda { + gpios = <&gpiob 4 GPIO_INPUT>; + }; + ec_i2c_usb_a1_c1_scl { + gpios = <&gpio9 0 GPIO_INPUT>; + }; + ec_i2c_usb_a1_c1_sda { + gpios = <&gpio8 7 GPIO_INPUT>; + }; + ec_i2c_batt_scl { + gpios = <&gpio9 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_batt_sda { + gpios = <&gpio9 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_usbc_mux_scl { + gpios = <&gpiod 1 GPIO_INPUT>; + }; + ec_i2c_usbc_mux_sda { + gpios = <&gpiod 0 GPIO_INPUT>; + }; + ec_i2c_power_scl { + gpios = <&gpiof 3 GPIO_INPUT>; + }; + ec_i2c_power_sda { + gpios = <&gpiof 2 GPIO_INPUT>; + }; + ec_i2c_cbi_scl { + gpios = <&gpio3 3 GPIO_INPUT>; + }; + ec_i2c_cbi_sda { + gpios = <&gpio3 6 GPIO_INPUT>; + }; + ec_i2c_sensor_scl { + gpios = <&gpioe 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_sensor_sda { + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_soc_sic { + gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ec_i2c_soc_sid { + gpios = <&gpiob 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + en_kb_bl { + gpios = <&gpio9 7 GPIO_OUTPUT_HIGH>; + enum-name = "GPIO_EN_KEYBOARD_BACKLIGHT"; + }; + gpio_ec_kso_02_inv: ec_kso_02_inv { + gpios = <&gpio1 7 (GPIO_OUTPUT_LOW | GPIO_ACTIVE_LOW)>; + }; + tablet_mode_l { + gpios = <&gpioc 1 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ec_gpio56 { + gpios = <&gpio5 6 GPIO_INPUT_PULL_UP>; + }; + ec_flprg2 { + gpios = <&gpio8 6 GPIO_INPUT_PULL_UP>; + }; + + usb_c0_tcpc_fastsw_ctl_en { + gpios = <&ioex_c0_port0 4 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_TCPC_FASTSW_CTL_EN"; + }; + usb_c0_ppc_en_l { + gpios = <&ioex_c0_port1 0 GPIO_OUTPUT_LOW>; + }; + ioex_usb_c0_ilim_3a_en: usb_c0_ppc_ilim_3a_en { + gpios = <&ioex_c0_port1 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_PPC_ILIM_3A_EN"; + }; + ioex_usb_c0_sbu_fault_odl: usb_c0_sbu_fault_odl { + gpios = <&ioex_c0_port1 2 GPIO_INPUT>; + }; + ioex_en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&ioex_c0_port1 5 GPIO_OUTPUT_LOW>; + }; + ioex_usb_a0_fault_odl: usb_a0_fault_odl { + gpios = <&ioex_c0_port1 6 GPIO_INPUT>; + }; + ioex_usb_c0_sbu_flip: usb_c0_sbu_flip { + gpios = <&ioex_c0_port1 7 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C0_SBU_FLIP"; + }; + + usb_a1_retimer_en { + gpios = <&ioex_c1_port0 0 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_A1_RETIMER_EN"; + }; + usb_a1_retimer_rst { + gpios = <&ioex_c1_port0 1 GPIO_OUTPUT_LOW>; + }; + usb_c1_in_hpd { + gpios = <&ioex_c1_port0 3 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_HPD_IN_DB"; + }; + usb_c1_tcpc_fastsw_ctl_en { + gpios = <&ioex_c1_port0 4 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_TCPC_FASTSW_CTL_EN"; + }; + usb_c1_ppc_en_l { + gpios = <&ioex_c1_port1 0 GPIO_OUTPUT_LOW>; + }; + usb_c1_ppc_ilim_3a_en { + gpios = <&ioex_c1_port1 1 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_PPC_ILIM_3A_EN"; + }; + ioex_usb_c1_sbu_fault_odl: usb_c1_sbu_fault_odl { + gpios = <&ioex_c1_port1 2 GPIO_INPUT>; + enum-name = "IOEX_USB_C1_FAULT_ODL"; + }; + ioex_en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus { + gpios = <&ioex_c1_port1 5 GPIO_OUTPUT_LOW>; + }; + ioex_usb_a1_fault_db_odl: usb_a1_fault_db_odl { + gpios = <&ioex_c1_port1 6 GPIO_INPUT>; + }; + ioex_usb_c1_sbu_flip: usb_c1_sbu_flip { + gpios = <&ioex_c1_port1 7 GPIO_OUTPUT_LOW>; + enum-name = "IOEX_USB_C1_SBU_FLIP"; + }; + }; + + usba-port-enable-list { + compatible = "cros-ec,usba-port-enable-pins"; + enable-pins = <&ioex_en_pp5000_usb_a0_vbus + &ioex_en_pp5000_usb_a1_vbus>; + }; +}; + +/* PSL input pads*/ +&psl_in1_gpd2 { + /* MECH_PWR_BTN_ODL */ + psl-in-mode = "edge"; + psl-in-pol = "low-falling"; +}; + +&psl_in2_gp00 { + /* ACOK_OD */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +&psl_in4_gp02 { + /* LID_OPEN */ + psl-in-mode = "edge"; + psl-in-pol = "high-rising"; +}; + +/* Power domain device controlled by PSL (Power Switch Logic) IO pads */ +&power_ctrl_psl { + status = "okay"; + pinctrl-names = "sleep"; + pinctrl-0 = <&psl_in1_gpd2 &psl_in2_gp00 &psl_in4_gp02>; +}; + +/* host interface */ +&espi0 { + status = "okay"; + pinctrl-0 = <&espi_lpc_gp46_47_51_52_53_54_55_57>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/i2c.dtsi b/zephyr/program/skyrim/i2c.dtsi new file mode 100644 index 0000000000..460a6bcfd2 --- /dev/null +++ b/zephyr/program/skyrim/i2c.dtsi @@ -0,0 +1,294 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + + #include + +/ { + aliases { + i2c-0 = &i2c0_0; + i2c-1 = &i2c1_0; + i2c-2 = &i2c2_0; + i2c-3 = &i2c3_0; + i2c-4 = &i2c4_1; + i2c-5 = &i2c5_0; + i2c-7 = &i2c7_0; + }; + + named-i2c-ports { + compatible = "named-i2c-ports"; + + i2c_tcpc0: tcpc0 { + i2c-port = <&i2c0_0>; + enum-names = "I2C_PORT_TCPC0"; + }; + + i2c_tcpc1: tcpc1 { + i2c-port = <&i2c1_0>; + enum-names = "I2C_PORT_TCPC1"; + }; + + battery { + i2c-port = <&i2c2_0>; + remote-port = <0>; + enum-names = "I2C_PORT_BATTERY"; + }; + + usb-mux { + i2c-port = <&i2c3_0>; + enum-names = "I2C_PORT_USB_MUX"; + }; + + i2c_charger: charger { + i2c-port = <&i2c4_1>; + enum-names = "I2C_PORT_CHARGER"; + }; + + eeprom { + i2c-port = <&i2c5_0>; + enum-names = "I2C_PORT_EEPROM"; + }; + + i2c_sensor: sensor { + i2c-port = <&i2c6_1>; + enum-names = "I2C_PORT_SENSOR"; + }; + + i2c_soc_thermal: soc-thermal { + i2c-port = <&i2c7_0>; + enum-names = "I2C_PORT_THERMAL_AP"; + }; + }; + + +}; + +&i2c0_0 { + status = "okay"; + label = "I2C_TCPC0"; + clock-frequency = ; + pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; + pinctrl-names = "default"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + + tcpc_port0: nct38xx@70 { + compatible = "nuvoton,nct38xx"; + reg = <0x70>; + gpio-dev = <&nct3807_C0>; + tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; + }; + + nct3807_C0: nct3807_C0@70 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nuvoton,nct38xx-gpio"; + reg = <0x70>; + label = "NCT3807_C0"; + + ioex_c0_port0: gpio@0 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x0>; + label = "NCT3807_C0_GPIO0"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + pinmux_mask = <0xf7>; + }; + ioex_c0_port1: gpio@1 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x1>; + label = "NCT3807_C0_GPIO1"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + }; + }; + + nct3808_alert_0 { + compatible = "nuvoton,nct38xx-gpio-alert"; + irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>; + nct38xx-dev = <&nct3807_C0>; + label = "NCT3807_ALERT_0"; + }; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c1_0 { + status = "okay"; + label = "I2C_TCPC1"; + clock-frequency = ; + pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; + pinctrl-names = "default"; + + bc12_port1: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c1_bc12>; + }; + + tcpc_port1: nct38xx@70 { + compatible = "nuvoton,nct38xx"; + reg = <0x70>; + gpio-dev = <&nct3807_C1>; + tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; + }; + + nct3807_C1: nct3807_C1@70 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nuvoton,nct38xx-gpio"; + reg = <0x70>; + label = "NCT3807_C1"; + + ioex_c1_port0: gpio@0 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x0>; + label = "NCT3807_C1_GPIO0"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + pinmux_mask = <0xf7>; + }; + ioex_c1_port1: gpio@1 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x1>; + label = "NCT3807_C1_GPIO1"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + }; + }; + + nct3808_alert_1 { + compatible = "nuvoton,nct38xx-gpio-alert"; + irq-gpios = <&gpioc 7 GPIO_ACTIVE_LOW>; + nct38xx-dev = <&nct3807_C1>; + label = "NCT3807_ALERT_1"; + }; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c2_0 { + status = "okay"; + label = "I2C_BATTERY"; + clock-frequency = ; + pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; + pinctrl-names = "default"; +}; + +&i2c_ctrl2 { + status = "okay"; +}; + +&i2c3_0 { + status = "okay"; + label = "I2C_USB_MUX"; + clock-frequency = ; + pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; + pinctrl-names = "default"; + + amd_fp6_port0: amd_fp6@5c { + compatible = "amd,usbc-mux-amd-fp6"; + status = "okay"; + reg = <0x5c>; + }; + amd_fp6_port1: amd_fp6@52 { + compatible = "amd,usbc-mux-amd-fp6"; + status = "okay"; + reg = <0x52>; + }; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c4_1 { + status = "okay"; + label = "I2C_CHARGER"; + clock-frequency = ; + pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; + pinctrl-names = "default"; +}; + +&i2c_ctrl4 { + status = "okay"; +}; + +&i2c5_0 { + status = "okay"; + label = "I2C_EEPROM"; + clock-frequency = ; + pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; + pinctrl-names = "default"; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c6_1 { + status = "okay"; + label = "I2C_SENSOR"; + clock-frequency = ; + pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>; + pinctrl-names = "default"; + + soc_pct2075: soc-pct2075@48 { + compatible = "nxp,pct2075"; + reg = <0x48>; + }; + + amb_pct2075: amb-pct2075@4f { + compatible = "nxp,pct2075"; + reg = <0x4f>; + }; +}; + +&i2c_ctrl6 { + status = "okay"; +}; + +&i2c7_0 { + status = "okay"; + label = "I2C_THERMAL_AP"; + clock-frequency = ; + pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; + pinctrl-names = "default"; + + temp_cpu: cpu@4c { + compatible = "amd,sb-tsi"; + reg = <0x4c>; + }; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/program/skyrim/i2c_common.dtsi b/zephyr/program/skyrim/i2c_common.dtsi deleted file mode 100644 index 460a6bcfd2..0000000000 --- a/zephyr/program/skyrim/i2c_common.dtsi +++ /dev/null @@ -1,294 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - #include - -/ { - aliases { - i2c-0 = &i2c0_0; - i2c-1 = &i2c1_0; - i2c-2 = &i2c2_0; - i2c-3 = &i2c3_0; - i2c-4 = &i2c4_1; - i2c-5 = &i2c5_0; - i2c-7 = &i2c7_0; - }; - - named-i2c-ports { - compatible = "named-i2c-ports"; - - i2c_tcpc0: tcpc0 { - i2c-port = <&i2c0_0>; - enum-names = "I2C_PORT_TCPC0"; - }; - - i2c_tcpc1: tcpc1 { - i2c-port = <&i2c1_0>; - enum-names = "I2C_PORT_TCPC1"; - }; - - battery { - i2c-port = <&i2c2_0>; - remote-port = <0>; - enum-names = "I2C_PORT_BATTERY"; - }; - - usb-mux { - i2c-port = <&i2c3_0>; - enum-names = "I2C_PORT_USB_MUX"; - }; - - i2c_charger: charger { - i2c-port = <&i2c4_1>; - enum-names = "I2C_PORT_CHARGER"; - }; - - eeprom { - i2c-port = <&i2c5_0>; - enum-names = "I2C_PORT_EEPROM"; - }; - - i2c_sensor: sensor { - i2c-port = <&i2c6_1>; - enum-names = "I2C_PORT_SENSOR"; - }; - - i2c_soc_thermal: soc-thermal { - i2c-port = <&i2c7_0>; - enum-names = "I2C_PORT_THERMAL_AP"; - }; - }; - - -}; - -&i2c0_0 { - status = "okay"; - label = "I2C_TCPC0"; - clock-frequency = ; - pinctrl-0 = <&i2c0_0_sda_scl_gpb4_b5>; - pinctrl-names = "default"; - - bc12_port0: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c0_bc12>; - }; - - tcpc_port0: nct38xx@70 { - compatible = "nuvoton,nct38xx"; - reg = <0x70>; - gpio-dev = <&nct3807_C0>; - tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; - }; - - nct3807_C0: nct3807_C0@70 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "nuvoton,nct38xx-gpio"; - reg = <0x70>; - label = "NCT3807_C0"; - - ioex_c0_port0: gpio@0 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x0>; - label = "NCT3807_C0_GPIO0"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - pinmux_mask = <0xf7>; - }; - ioex_c0_port1: gpio@1 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x1>; - label = "NCT3807_C0_GPIO1"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - }; - }; - - nct3808_alert_0 { - compatible = "nuvoton,nct38xx-gpio-alert"; - irq-gpios = <&gpioe 0 GPIO_ACTIVE_LOW>; - nct38xx-dev = <&nct3807_C0>; - label = "NCT3807_ALERT_0"; - }; -}; - -&i2c_ctrl0 { - status = "okay"; -}; - -&i2c1_0 { - status = "okay"; - label = "I2C_TCPC1"; - clock-frequency = ; - pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; - pinctrl-names = "default"; - - bc12_port1: pi3usb9201@5f { - compatible = "pericom,pi3usb9201"; - status = "okay"; - reg = <0x5f>; - irq = <&int_usb_c1_bc12>; - }; - - tcpc_port1: nct38xx@70 { - compatible = "nuvoton,nct38xx"; - reg = <0x70>; - gpio-dev = <&nct3807_C1>; - tcpc-flags = <(TCPC_FLAGS_TCPCI_REV2_0)>; - }; - - nct3807_C1: nct3807_C1@70 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "nuvoton,nct38xx-gpio"; - reg = <0x70>; - label = "NCT3807_C1"; - - ioex_c1_port0: gpio@0 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x0>; - label = "NCT3807_C1_GPIO0"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - pinmux_mask = <0xf7>; - }; - ioex_c1_port1: gpio@1 { - compatible = "nuvoton,nct38xx-gpio-port"; - reg = <0x1>; - label = "NCT3807_C1_GPIO1"; - gpio-controller; - #gpio-cells = <2>; - ngpios = <8>; - pin_mask = <0xff>; - }; - }; - - nct3808_alert_1 { - compatible = "nuvoton,nct38xx-gpio-alert"; - irq-gpios = <&gpioc 7 GPIO_ACTIVE_LOW>; - nct38xx-dev = <&nct3807_C1>; - label = "NCT3807_ALERT_1"; - }; -}; - -&i2c_ctrl1 { - status = "okay"; -}; - -&i2c2_0 { - status = "okay"; - label = "I2C_BATTERY"; - clock-frequency = ; - pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; - pinctrl-names = "default"; -}; - -&i2c_ctrl2 { - status = "okay"; -}; - -&i2c3_0 { - status = "okay"; - label = "I2C_USB_MUX"; - clock-frequency = ; - pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; - pinctrl-names = "default"; - - amd_fp6_port0: amd_fp6@5c { - compatible = "amd,usbc-mux-amd-fp6"; - status = "okay"; - reg = <0x5c>; - }; - amd_fp6_port1: amd_fp6@52 { - compatible = "amd,usbc-mux-amd-fp6"; - status = "okay"; - reg = <0x52>; - }; -}; - -&i2c_ctrl3 { - status = "okay"; -}; - -&i2c4_1 { - status = "okay"; - label = "I2C_CHARGER"; - clock-frequency = ; - pinctrl-0 = <&i2c4_1_sda_scl_gpf2_f3>; - pinctrl-names = "default"; -}; - -&i2c_ctrl4 { - status = "okay"; -}; - -&i2c5_0 { - status = "okay"; - label = "I2C_EEPROM"; - clock-frequency = ; - pinctrl-0 = <&i2c5_0_sda_scl_gp33_36>; - pinctrl-names = "default"; - - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; - -&i2c_ctrl5 { - status = "okay"; -}; - -&i2c6_1 { - status = "okay"; - label = "I2C_SENSOR"; - clock-frequency = ; - pinctrl-0 = <&i2c6_1_sda_scl_gpe3_e4>; - pinctrl-names = "default"; - - soc_pct2075: soc-pct2075@48 { - compatible = "nxp,pct2075"; - reg = <0x48>; - }; - - amb_pct2075: amb-pct2075@4f { - compatible = "nxp,pct2075"; - reg = <0x4f>; - }; -}; - -&i2c_ctrl6 { - status = "okay"; -}; - -&i2c7_0 { - status = "okay"; - label = "I2C_THERMAL_AP"; - clock-frequency = ; - pinctrl-0 = <&i2c7_0_sda_scl_gpb2_b3>; - pinctrl-names = "default"; - - temp_cpu: cpu@4c { - compatible = "amd,sb-tsi"; - reg = <0x4c>; - }; -}; - -&i2c_ctrl7 { - status = "okay"; -}; diff --git a/zephyr/program/skyrim/include/frostflow/keyboard_customization.h b/zephyr/program/skyrim/include/frostflow/keyboard_customization.h deleted file mode 100644 index 2d2a997f91..0000000000 --- a/zephyr/program/skyrim/include/frostflow/keyboard_customization.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Keyboard configuration */ - -#ifndef __KEYBOARD_CUSTOMIZATION_H -#define __KEYBOARD_CUSTOMIZATION_H - -/* - * KEYBOARD_COLS_MAX has the build time column size. It's used to allocate - * exact spaces for arrays. Actual keyboard scanning is done using - * keyboard_cols, which holds a runtime column size. - */ -#ifdef CONFIG_KEYBOARD_CUSTOMIZATION -#undef KEYBOARD_COLS_MAX -#undef KEYBOARD_ROWS - -#define KEYBOARD_COLS_MAX 15 -#define KEYBOARD_ROWS 8 -#endif - -/* - * WARNING: Do not directly modify it. You should call keyboard_raw_set_cols, - * instead. It checks whether you're eligible or not. - */ -extern uint8_t keyboard_cols; - -#define KEYBOARD_ROW_TO_MASK(r) (1 << (r)) - -/* Columns and masks for keys we particularly care about */ -#define KEYBOARD_COL_DOWN 11 -#define KEYBOARD_ROW_DOWN 5 -#define KEYBOARD_MASK_DOWN KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_DOWN) -#define KEYBOARD_COL_ESC 1 -#define KEYBOARD_ROW_ESC 1 -#define KEYBOARD_MASK_ESC KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_ESC) -#define KEYBOARD_COL_KEY_H 6 -#define KEYBOARD_ROW_KEY_H 1 -#define KEYBOARD_MASK_KEY_H KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_H) -#define KEYBOARD_COL_KEY_R 3 -#define KEYBOARD_ROW_KEY_R 7 -#define KEYBOARD_MASK_KEY_R KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_R) -#define KEYBOARD_COL_LEFT_ALT 10 -#define KEYBOARD_ROW_LEFT_ALT 6 -#define KEYBOARD_MASK_LEFT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_ALT) -#define KEYBOARD_COL_REFRESH 2 -#define KEYBOARD_ROW_REFRESH 3 -#define KEYBOARD_MASK_REFRESH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_REFRESH) -#define KEYBOARD_COL_RIGHT_ALT 10 -#define KEYBOARD_ROW_RIGHT_ALT 0 -#define KEYBOARD_MASK_RIGHT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_ALT) -#define KEYBOARD_DEFAULT_COL_VOL_UP 4 -#define KEYBOARD_DEFAULT_ROW_VOL_UP 1 -#define KEYBOARD_COL_LEFT_CTRL 0 -#define KEYBOARD_ROW_LEFT_CTRL 2 -#define KEYBOARD_MASK_LEFT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_CTRL) -#define KEYBOARD_COL_RIGHT_CTRL 0 -#define KEYBOARD_ROW_RIGHT_CTRL 4 -#define KEYBOARD_MASK_RIGHT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_CTRL) -#define KEYBOARD_COL_SEARCH 0 -#define KEYBOARD_ROW_SEARCH 3 -#define KEYBOARD_MASK_SEARCH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_SEARCH) -#define KEYBOARD_COL_KEY_0 9 -#define KEYBOARD_ROW_KEY_0 0 -#define KEYBOARD_MASK_KEY_0 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_0) -#define KEYBOARD_COL_KEY_1 1 -#define KEYBOARD_ROW_KEY_1 7 -#define KEYBOARD_MASK_KEY_1 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_1) -#define KEYBOARD_COL_KEY_2 4 -#define KEYBOARD_ROW_KEY_2 6 -#define KEYBOARD_MASK_KEY_2 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_2) -#define KEYBOARD_COL_LEFT_SHIFT 7 -#define KEYBOARD_ROW_LEFT_SHIFT 1 -#define KEYBOARD_MASK_LEFT_SHIFT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_SHIFT) - -#endif /* __KEYBOARD_CUSTOMIZATION_H */ diff --git a/zephyr/program/skyrim/include/keyboard_customization.h b/zephyr/program/skyrim/include/keyboard_customization.h new file mode 100644 index 0000000000..2d2a997f91 --- /dev/null +++ b/zephyr/program/skyrim/include/keyboard_customization.h @@ -0,0 +1,78 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Keyboard configuration */ + +#ifndef __KEYBOARD_CUSTOMIZATION_H +#define __KEYBOARD_CUSTOMIZATION_H + +/* + * KEYBOARD_COLS_MAX has the build time column size. It's used to allocate + * exact spaces for arrays. Actual keyboard scanning is done using + * keyboard_cols, which holds a runtime column size. + */ +#ifdef CONFIG_KEYBOARD_CUSTOMIZATION +#undef KEYBOARD_COLS_MAX +#undef KEYBOARD_ROWS + +#define KEYBOARD_COLS_MAX 15 +#define KEYBOARD_ROWS 8 +#endif + +/* + * WARNING: Do not directly modify it. You should call keyboard_raw_set_cols, + * instead. It checks whether you're eligible or not. + */ +extern uint8_t keyboard_cols; + +#define KEYBOARD_ROW_TO_MASK(r) (1 << (r)) + +/* Columns and masks for keys we particularly care about */ +#define KEYBOARD_COL_DOWN 11 +#define KEYBOARD_ROW_DOWN 5 +#define KEYBOARD_MASK_DOWN KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_DOWN) +#define KEYBOARD_COL_ESC 1 +#define KEYBOARD_ROW_ESC 1 +#define KEYBOARD_MASK_ESC KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_ESC) +#define KEYBOARD_COL_KEY_H 6 +#define KEYBOARD_ROW_KEY_H 1 +#define KEYBOARD_MASK_KEY_H KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_H) +#define KEYBOARD_COL_KEY_R 3 +#define KEYBOARD_ROW_KEY_R 7 +#define KEYBOARD_MASK_KEY_R KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_R) +#define KEYBOARD_COL_LEFT_ALT 10 +#define KEYBOARD_ROW_LEFT_ALT 6 +#define KEYBOARD_MASK_LEFT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_ALT) +#define KEYBOARD_COL_REFRESH 2 +#define KEYBOARD_ROW_REFRESH 3 +#define KEYBOARD_MASK_REFRESH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_REFRESH) +#define KEYBOARD_COL_RIGHT_ALT 10 +#define KEYBOARD_ROW_RIGHT_ALT 0 +#define KEYBOARD_MASK_RIGHT_ALT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_ALT) +#define KEYBOARD_DEFAULT_COL_VOL_UP 4 +#define KEYBOARD_DEFAULT_ROW_VOL_UP 1 +#define KEYBOARD_COL_LEFT_CTRL 0 +#define KEYBOARD_ROW_LEFT_CTRL 2 +#define KEYBOARD_MASK_LEFT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_CTRL) +#define KEYBOARD_COL_RIGHT_CTRL 0 +#define KEYBOARD_ROW_RIGHT_CTRL 4 +#define KEYBOARD_MASK_RIGHT_CTRL KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_RIGHT_CTRL) +#define KEYBOARD_COL_SEARCH 0 +#define KEYBOARD_ROW_SEARCH 3 +#define KEYBOARD_MASK_SEARCH KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_SEARCH) +#define KEYBOARD_COL_KEY_0 9 +#define KEYBOARD_ROW_KEY_0 0 +#define KEYBOARD_MASK_KEY_0 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_0) +#define KEYBOARD_COL_KEY_1 1 +#define KEYBOARD_ROW_KEY_1 7 +#define KEYBOARD_MASK_KEY_1 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_1) +#define KEYBOARD_COL_KEY_2 4 +#define KEYBOARD_ROW_KEY_2 6 +#define KEYBOARD_MASK_KEY_2 KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_KEY_2) +#define KEYBOARD_COL_LEFT_SHIFT 7 +#define KEYBOARD_ROW_LEFT_SHIFT 1 +#define KEYBOARD_MASK_LEFT_SHIFT KEYBOARD_ROW_TO_MASK(KEYBOARD_ROW_LEFT_SHIFT) + +#endif /* __KEYBOARD_CUSTOMIZATION_H */ diff --git a/zephyr/program/skyrim/interrupts.dts b/zephyr/program/skyrim/interrupts.dts deleted file mode 100644 index de4e87986a..0000000000 --- a/zephyr/program/skyrim/interrupts.dts +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - gpio-interrupts { - compatible = "cros-ec,gpio-interrupts"; - - int_lid_open: lid_open { - irq-pin = <&gpio_lid_open>; - flags = ; - handler = "lid_interrupt"; - }; - int_ac_present: ac_present { - irq-pin = <&gpio_acok_od>; - flags = ; - handler = "extpower_interrupt"; - }; - int_power_button: power_button { - irq-pin = <&gpio_mech_pwr_btn_odl>; - flags = ; - handler = "power_button_interrupt"; - }; - int_slp_s3: slp_s3 { - irq-pin = <&gpio_slp_s3_l>; - flags = ; - handler = "baseboard_en_pwr_s0"; - }; - int_slp_s5: slp_s5 { - irq-pin = <&gpio_slp_s5_l>; - flags = ; - handler = "baseboard_set_en_pwr_s3"; - }; - int_s5_pgood: s5_pgood { - irq-pin = <&gpio_pg_pwr_s5>; - flags = ; - handler = "baseboard_s5_pgood"; - }; - int_pg_groupc_s0: pg_groupc_s0 { - irq-pin = <&gpio_pg_groupc_s0_od>; - flags = ; - handler = "baseboard_set_en_pwr_pcore"; - }; - int_pg_lpddr_s3: pg_lpddr_s3 { - irq-pin = <&gpio_pg_lpddr5_s3_od>; - flags = ; - handler = "baseboard_set_en_pwr_pcore"; - }; - int_pg_lpddr_s0: pg_lpddr_s0 { - irq-pin = <&gpio_pg_lpddr5_s0_od>; - flags = ; - handler = "baseboard_set_soc_pwr_pgood"; - }; - int_s0_pgood: s0_pgood { - irq-pin = <&gpio_s0_pgood>; - flags = ; - handler = "baseboard_s0_pgood"; - }; - int_soc_thermtrip: soc_thermtrip { - irq-pin = <&gpio_soc_thermtrip_odl>; - flags = ; - handler = "baseboard_soc_thermtrip"; - }; - int_soc_pcore_ocp: soc_pcore_ocp { - irq-pin = <&gpio_pcore_ocp_r_l>; - flags = ; - handler = "baseboard_soc_pcore_ocp"; - }; - int_volume_up: volume_up { - irq-pin = <&gpio_volup_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_volume_down: volume_down { - irq-pin = <&gpio_voldn_btn_odl>; - flags = ; - handler = "button_interrupt"; - }; - int_usb_a0_fault: a0_fault { - irq-pin = <&ioex_usb_a0_fault_odl>; - flags = ; - handler = "usb_fault_interrupt"; - }; - int_usb_a1_fault: a1_fault { - irq-pin = <&ioex_usb_a1_fault_db_odl>; - flags = ; - handler = "usb_fault_interrupt"; - }; - int_usb_c0_sbu_fault: c0_sbu_fault { - irq-pin = <&ioex_usb_c0_sbu_fault_odl>; - flags = ; - handler = "sbu_fault_interrupt"; - }; - int_usb_c1_sbu_fault: c1_sbu_fault { - irq-pin = <&ioex_usb_c1_sbu_fault_odl>; - flags = ; - handler = "sbu_fault_interrupt"; - }; - int_usb_c0_tcpc: usb_c0_tcpc { - irq-pin = <&gpio_usb_c0_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c1_tcpc: usb_c1_tcpc { - irq-pin = <&gpio_usb_c1_tcpc_int_odl>; - flags = ; - handler = "tcpc_alert_event"; - }; - int_usb_c0_ppc: usb_c0_ppc { - irq-pin = <&gpio_usb_c0_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c1_ppc: usb_c1_ppc { - irq-pin = <&gpio_usb_c1_ppc_int_odl>; - flags = ; - handler = "ppc_interrupt"; - }; - int_usb_c0_bc12: usb_c0_bc12 { - irq-pin = <&gpio_usb_c0_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_c1_bc12: usb_c1_bc12 { - irq-pin = <&gpio_usb_c1_bc12_int_odl>; - flags = ; - handler = "bc12_interrupt"; - }; - int_usb_hub_fault: hub_fault { - irq-pin = <&gpio_usb_hub_fault_q_odl>; - flags = ; - handler = "usb_fault_interrupt"; - }; - int_usb_pd_soc: usb_pd_soc { - irq-pin = <&gpio_ec_i2c_usbc_pd_int>; - flags = ; - handler = "usb_pd_soc_interrupt"; - }; - int_accel_gyro: accel_gyro { - irq-pin = <&gpio_accel_gyro_int_l>; - flags = ; - handler = "bmi3xx_interrupt"; - }; - }; -}; diff --git a/zephyr/program/skyrim/interrupts.dtsi b/zephyr/program/skyrim/interrupts.dtsi new file mode 100644 index 0000000000..de4e87986a --- /dev/null +++ b/zephyr/program/skyrim/interrupts.dtsi @@ -0,0 +1,146 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_lid_open: lid_open { + irq-pin = <&gpio_lid_open>; + flags = ; + handler = "lid_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&gpio_acok_od>; + flags = ; + handler = "extpower_interrupt"; + }; + int_power_button: power_button { + irq-pin = <&gpio_mech_pwr_btn_odl>; + flags = ; + handler = "power_button_interrupt"; + }; + int_slp_s3: slp_s3 { + irq-pin = <&gpio_slp_s3_l>; + flags = ; + handler = "baseboard_en_pwr_s0"; + }; + int_slp_s5: slp_s5 { + irq-pin = <&gpio_slp_s5_l>; + flags = ; + handler = "baseboard_set_en_pwr_s3"; + }; + int_s5_pgood: s5_pgood { + irq-pin = <&gpio_pg_pwr_s5>; + flags = ; + handler = "baseboard_s5_pgood"; + }; + int_pg_groupc_s0: pg_groupc_s0 { + irq-pin = <&gpio_pg_groupc_s0_od>; + flags = ; + handler = "baseboard_set_en_pwr_pcore"; + }; + int_pg_lpddr_s3: pg_lpddr_s3 { + irq-pin = <&gpio_pg_lpddr5_s3_od>; + flags = ; + handler = "baseboard_set_en_pwr_pcore"; + }; + int_pg_lpddr_s0: pg_lpddr_s0 { + irq-pin = <&gpio_pg_lpddr5_s0_od>; + flags = ; + handler = "baseboard_set_soc_pwr_pgood"; + }; + int_s0_pgood: s0_pgood { + irq-pin = <&gpio_s0_pgood>; + flags = ; + handler = "baseboard_s0_pgood"; + }; + int_soc_thermtrip: soc_thermtrip { + irq-pin = <&gpio_soc_thermtrip_odl>; + flags = ; + handler = "baseboard_soc_thermtrip"; + }; + int_soc_pcore_ocp: soc_pcore_ocp { + irq-pin = <&gpio_pcore_ocp_r_l>; + flags = ; + handler = "baseboard_soc_pcore_ocp"; + }; + int_volume_up: volume_up { + irq-pin = <&gpio_volup_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&gpio_voldn_btn_odl>; + flags = ; + handler = "button_interrupt"; + }; + int_usb_a0_fault: a0_fault { + irq-pin = <&ioex_usb_a0_fault_odl>; + flags = ; + handler = "usb_fault_interrupt"; + }; + int_usb_a1_fault: a1_fault { + irq-pin = <&ioex_usb_a1_fault_db_odl>; + flags = ; + handler = "usb_fault_interrupt"; + }; + int_usb_c0_sbu_fault: c0_sbu_fault { + irq-pin = <&ioex_usb_c0_sbu_fault_odl>; + flags = ; + handler = "sbu_fault_interrupt"; + }; + int_usb_c1_sbu_fault: c1_sbu_fault { + irq-pin = <&ioex_usb_c1_sbu_fault_odl>; + flags = ; + handler = "sbu_fault_interrupt"; + }; + int_usb_c0_tcpc: usb_c0_tcpc { + irq-pin = <&gpio_usb_c0_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c1_tcpc: usb_c1_tcpc { + irq-pin = <&gpio_usb_c1_tcpc_int_odl>; + flags = ; + handler = "tcpc_alert_event"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&gpio_usb_c0_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c1_ppc: usb_c1_ppc { + irq-pin = <&gpio_usb_c1_ppc_int_odl>; + flags = ; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&gpio_usb_c0_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_c1_bc12: usb_c1_bc12 { + irq-pin = <&gpio_usb_c1_bc12_int_odl>; + flags = ; + handler = "bc12_interrupt"; + }; + int_usb_hub_fault: hub_fault { + irq-pin = <&gpio_usb_hub_fault_q_odl>; + flags = ; + handler = "usb_fault_interrupt"; + }; + int_usb_pd_soc: usb_pd_soc { + irq-pin = <&gpio_ec_i2c_usbc_pd_int>; + flags = ; + handler = "usb_pd_soc_interrupt"; + }; + int_accel_gyro: accel_gyro { + irq-pin = <&gpio_accel_gyro_int_l>; + flags = ; + handler = "bmi3xx_interrupt"; + }; + }; +}; diff --git a/zephyr/program/skyrim/keyboard.dts b/zephyr/program/skyrim/keyboard.dts deleted file mode 100644 index aaf305c725..0000000000 --- a/zephyr/program/skyrim/keyboard.dts +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - kblight { - compatible = "cros-ec,kblight-pwm"; - pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_NORMAL>; - }; -}; - -&pwm1 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm1_gpc2>; - pinctrl-names = "default"; -}; - -&cros_kb_raw { - status = "okay"; - /* No KSO2 (it's inverted and implemented by GPIO) */ - pinctrl-0 = < - &ksi0_gp31 - &ksi1_gp30 - &ksi2_gp27 - &ksi3_gp26 - &ksi4_gp25 - &ksi5_gp24 - &ksi6_gp23 - &ksi7_gp22 - &kso00_gp21 - &kso01_gp20 - &kso03_gp16 - &kso04_gp15 - &kso05_gp14 - &kso06_gp13 - &kso07_gp12 - &kso08_gp11 - &kso09_gp10 - &kso10_gp07 - &kso11_gp06 - &kso12_gp05 - &kso13_gp04 - &kso14_gp82 - >; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/keyboard.dtsi b/zephyr/program/skyrim/keyboard.dtsi new file mode 100644 index 0000000000..aaf305c725 --- /dev/null +++ b/zephyr/program/skyrim/keyboard.dtsi @@ -0,0 +1,48 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + kblight { + compatible = "cros-ec,kblight-pwm"; + pwms = <&pwm1 0 PWM_HZ(100) PWM_POLARITY_NORMAL>; + }; +}; + +&pwm1 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm1_gpc2>; + pinctrl-names = "default"; +}; + +&cros_kb_raw { + status = "okay"; + /* No KSO2 (it's inverted and implemented by GPIO) */ + pinctrl-0 = < + &ksi0_gp31 + &ksi1_gp30 + &ksi2_gp27 + &ksi3_gp26 + &ksi4_gp25 + &ksi5_gp24 + &ksi6_gp23 + &ksi7_gp22 + &kso00_gp21 + &kso01_gp20 + &kso03_gp16 + &kso04_gp15 + &kso05_gp14 + &kso06_gp13 + &kso07_gp12 + &kso08_gp11 + &kso09_gp10 + &kso10_gp07 + &kso11_gp06 + &kso12_gp05 + &kso13_gp04 + &kso14_gp82 + >; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/led_pins_crystaldrift.dts b/zephyr/program/skyrim/led_pins_crystaldrift.dts deleted file mode 100644 index f778a24a51..0000000000 --- a/zephyr/program/skyrim/led_pins_crystaldrift.dts +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - - pwm_y: pwm_y { - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - - pwm_w: pwm_w { - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <100 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/led_pins_frostflow.dts b/zephyr/program/skyrim/led_pins_frostflow.dts deleted file mode 100644 index 78b9a59c40..0000000000 --- a/zephyr/program/skyrim/led_pins_frostflow.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_y: pwm_y { - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - pwm_w: pwm_w { - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <100 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/led_pins_morthal.dts b/zephyr/program/skyrim/led_pins_morthal.dts deleted file mode 100644 index 78b9a59c40..0000000000 --- a/zephyr/program/skyrim/led_pins_morthal.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_y: pwm_y { - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - pwm_w: pwm_w { - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <100 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/led_pins_skyrim.dts b/zephyr/program/skyrim/led_pins_skyrim.dts deleted file mode 100644 index 78b9a59c40..0000000000 --- a/zephyr/program/skyrim/led_pins_skyrim.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_y: pwm_y { - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - pwm_w: pwm_w { - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <100 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/led_pins_winterhold.dts b/zephyr/program/skyrim/led_pins_winterhold.dts deleted file mode 100644 index 78b9a59c40..0000000000 --- a/zephyr/program/skyrim/led_pins_winterhold.dts +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - pwmleds { - compatible = "pwm-leds"; - pwm_y: pwm_y { - pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - pwm_w: pwm_w { - pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; - }; - }; - - pwm-led-pins { - compatible = "cros-ec,pwm-led-pins"; - - color_off: color-off { - led-color = "LED_OFF"; - led-id = "EC_LED_ID_BATTERY_LED"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 0>; - }; - - color_amber: color-amber { - led-color = "LED_AMBER"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_AMBER"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <100 0>; - }; - - color_white: color-white { - led-color = "LED_WHITE"; - led-id = "EC_LED_ID_BATTERY_LED"; - br-color = "EC_LED_COLOR_WHITE"; - led-pwms = <&pwm_y &pwm_w>; - led-values = <0 100>; - }; - }; -}; - -/* Amber "battery charging" LED */ -&pwm2 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm2_gpc4>; - pinctrl-names = "default"; -}; - -/* White "battery full" LED */ -&pwm3 { - status = "okay"; - clock-bus = "NPCX_CLOCK_BUS_LFCLK"; - pinctrl-0 = <&pwm3_gp80>; - pinctrl-names = "default"; -}; diff --git a/zephyr/program/skyrim/led_policy_crystaldrift.dts b/zephyr/program/skyrim/led_policy_crystaldrift.dts deleted file mode 100644 index a075c6b0d2..0000000000 --- a/zephyr/program/skyrim/led_policy_crystaldrift.dts +++ /dev/null @@ -1,103 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - /* White 2 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* White 1 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Amber 2 sec, White 2 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_white>; - period-ms = <2000>; - }; - }; - }; -}; diff --git a/zephyr/program/skyrim/led_policy_frostflow.dts b/zephyr/program/skyrim/led_policy_frostflow.dts deleted file mode 100644 index e5875640fb..0000000000 --- a/zephyr/program/skyrim/led_policy_frostflow.dts +++ /dev/null @@ -1,122 +0,0 @@ -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= Empty, <= 94%) */ - batt-lvl = <0 94>; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-charge-lvl-2 { - charge-state = "PWR_STATE_CHARGE"; - /* Battery percent range (>= 95%, <= Near Full) */ - batt-lvl = <95 97>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= 11%, <= Full) */ - batt-lvl = <11 100>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= 10%) */ - batt-lvl = <0 10>; - - /* Amber 1 sec, off 3 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* White 1 sec, off 3 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error-s0 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S0"; - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-error-s3 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S3"; - /* White 1 sec, off 3 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <3000>; - }; - }; - - power-state-error-s5 { - charge-state = "PWR_STATE_ERROR"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - }; -}; diff --git a/zephyr/program/skyrim/led_policy_morthal.dts b/zephyr/program/skyrim/led_policy_morthal.dts deleted file mode 100644 index a075c6b0d2..0000000000 --- a/zephyr/program/skyrim/led_policy_morthal.dts +++ /dev/null @@ -1,103 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - /* White 2 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* White 1 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Amber 2 sec, White 2 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_white>; - period-ms = <2000>; - }; - }; - }; -}; diff --git a/zephyr/program/skyrim/led_policy_skyrim.dts b/zephyr/program/skyrim/led_policy_skyrim.dts deleted file mode 100644 index a075c6b0d2..0000000000 --- a/zephyr/program/skyrim/led_policy_skyrim.dts +++ /dev/null @@ -1,103 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - /* White 2 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - - /* White 1 sec, off 1 sec */ - color-0 { - led-color = <&color_white>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Amber 2 sec, White 2 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_white>; - period-ms = <2000>; - }; - }; - }; -}; diff --git a/zephyr/program/skyrim/led_policy_winterhold.dts b/zephyr/program/skyrim/led_policy_winterhold.dts deleted file mode 100644 index f1f8aa31ed..0000000000 --- a/zephyr/program/skyrim/led_policy_winterhold.dts +++ /dev/null @@ -1,103 +0,0 @@ -#include - -/ { - led-colors { - compatible = "cros-ec,led-policy"; - - power-state-charge { - charge-state = "PWR_STATE_CHARGE"; - color-0 { - led-color = <&color_white>; - }; - }; - - power-state-discharge-s0 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-discharge-s0-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S0"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s3 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - /* Battery percent range (> Low, <= Full) */ - batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-discharge-s3-batt-low { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S3"; - /* Battery percent range (>= Empty, <= Low) */ - batt-lvl = ; - - color-0 { - led-color = <&color_amber>; - }; - }; - - power-state-discharge-s5 { - charge-state = "PWR_STATE_DISCHARGE"; - chipset-state = "POWER_S5"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-error { - charge-state = "PWR_STATE_ERROR"; - - /* Amber 1 sec, off 1 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <1000>; - }; - color-1 { - led-color = <&color_off>; - period-ms = <1000>; - }; - }; - - power-state-near-full { - charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; - - color-0 { - led-color = <&color_off>; - }; - }; - - power-state-forced-idle { - charge-state = "PWR_STATE_FORCED_IDLE"; - - /* Amber 2 sec, White 2 sec */ - color-0 { - led-color = <&color_amber>; - period-ms = <2000>; - }; - color-1 { - led-color = <&color_white>; - period-ms = <2000>; - }; - }; - }; -}; diff --git a/zephyr/program/skyrim/morthal.dts b/zephyr/program/skyrim/morthal.dts deleted file mode 100644 index a0c89e1d5c..0000000000 --- a/zephyr/program/skyrim/morthal.dts +++ /dev/null @@ -1,185 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Morthal-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - temp_fan_off = <0>; - temp_fan_max = <70>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - amb-pct2075 { - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* - * Note this is expected to vary per-board, so we keep it in the board - * dts files. - */ - morthal-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - form-factor { - enum-name = "FW_FORM_FACTOR"; - start = <0>; - size = <1>; - - ff-clamshell { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CLAMSHELL"; - value = <0>; - }; - ff-convertible { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CONVERTIBLE"; - value = <1>; - default; - }; - }; - io-db { - enum-name = "FW_IO_DB"; - start = <6>; - size = <2>; - - io-db-ps8811-ps8818 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_PS8811_PS8818"; - value = <0>; - }; - io-db-none-anx7483 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_NONE_ANX7483"; - value = <1>; - default; - }; - }; - - /* - * FW_CONFIG field to enable fan or not. - */ - fan { - enum-name = "FW_FAN"; - start = <10>; - size = <1>; - - no-fan { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_NOT_PRESENT"; - value = <0>; - }; - fan-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_PRESENT"; - value = <1>; - /* - * Set as default so that unprovisioned - * configs will run the fan regardless. - */ - default; - }; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - - lid_rot_ref1: lid-rotation-ref1 { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - ppc_port0: aoz1380 { - compatible = "aoz,aoz1380"; - status = "okay"; - }; -}; - -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - flags = ; - }; -}; - -&i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - flags = ; - }; - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; - ps8818_port1: ps8818@28 { - compatible = "parade,ps8818"; - reg = <0x28>; - flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; - board-set = "board_c1_ps8818_mux_set"; - }; -}; - -&i2c4_1 { - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; -}; - -&usbc_port0 { - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; - usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &ps8818_port1>; - alternative-chain; - }; -}; diff --git a/zephyr/program/skyrim/morthal/CMakeLists.txt b/zephyr/program/skyrim/morthal/CMakeLists.txt new file mode 100644 index 0000000000..b4819f1e73 --- /dev/null +++ b/zephyr/program/skyrim/morthal/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +zephyr_library_sources( + "src/ppc_config.c" + "src/usb_mux_config.c" +) diff --git a/zephyr/program/skyrim/morthal/battery.dtsi b/zephyr/program/skyrim/morthal/battery.dtsi new file mode 100644 index 0000000000..8c87cef7f9 --- /dev/null +++ b/zephyr/program/skyrim/morthal/battery.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: aec_5477109 { + compatible = "aec,5477109", "battery-smart"; + }; + smp_l20m3pg1 { + compatible = "smp,l20m3pg1", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/morthal/led_pins.dtsi b/zephyr/program/skyrim/morthal/led_pins.dtsi new file mode 100644 index 0000000000..78b9a59c40 --- /dev/null +++ b/zephyr/program/skyrim/morthal/led_pins.dtsi @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_y: pwm_y { + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + pwm_w: pwm_w { + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/morthal/led_policy.dtsi b/zephyr/program/skyrim/morthal/led_policy.dtsi new file mode 100644 index 0000000000..a075c6b0d2 --- /dev/null +++ b/zephyr/program/skyrim/morthal/led_policy.dtsi @@ -0,0 +1,103 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + /* White 2 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Amber 2 sec, White 2 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_white>; + period-ms = <2000>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/morthal/morthal.dtsi b/zephyr/program/skyrim/morthal/morthal.dtsi new file mode 100644 index 0000000000..99a062220d --- /dev/null +++ b/zephyr/program/skyrim/morthal/morthal.dtsi @@ -0,0 +1,185 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "../i2c.dtsi" + +/ { + named-gpios { + /* Morthal-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + temp_fan_off = <0>; + temp_fan_max = <70>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* + * Note this is expected to vary per-board, so we keep it in the board + * dts files. + */ + morthal-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + form-factor { + enum-name = "FW_FORM_FACTOR"; + start = <0>; + size = <1>; + + ff-clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CLAMSHELL"; + value = <0>; + }; + ff-convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CONVERTIBLE"; + value = <1>; + default; + }; + }; + io-db { + enum-name = "FW_IO_DB"; + start = <6>; + size = <2>; + + io-db-ps8811-ps8818 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_PS8811_PS8818"; + value = <0>; + }; + io-db-none-anx7483 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_NONE_ANX7483"; + value = <1>; + default; + }; + }; + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <10>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + lid_rot_ref1: lid-rotation-ref1 { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + ppc_port0: aoz1380 { + compatible = "aoz,aoz1380"; + status = "okay"; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + flags = ; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + flags = ; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; +}; + +&i2c4_1 { + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; +}; diff --git a/zephyr/program/skyrim/morthal/motionsense.dtsi b/zephyr/program/skyrim/morthal/motionsense.dtsi new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/morthal/motionsense.dtsi @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/morthal/project.conf b/zephyr/program/skyrim/morthal/project.conf new file mode 100644 index 0000000000..8a22f58ab8 --- /dev/null +++ b/zephyr/program/skyrim/morthal/project.conf @@ -0,0 +1,23 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Morthal reference-board-specific Kconfig settings. +CONFIG_BOARD_MORTHAL=y + +# TODO(b/215404321): Remove later in board development +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Morthal is capable of sinking 100W +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/morthal/project.overlay b/zephyr/program/skyrim/morthal/project.overlay new file mode 100644 index 0000000000..a41d358cce --- /dev/null +++ b/zephyr/program/skyrim/morthal/project.overlay @@ -0,0 +1,19 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim program common DTS includes */ +#include "../adc.dtsi" +#include "../fan.dtsi" +#include "../gpio.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../usbc.dtsi" + +/* Morthal project DTS includes*/ +#include "morthal.dtsi" +#include "battery.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" diff --git a/zephyr/program/skyrim/morthal/src/ppc_config.c b/zephyr/program/skyrim/morthal/src/ppc_config.c new file mode 100644 index 0000000000..8108742fdc --- /dev/null +++ b/zephyr/program/skyrim/morthal/src/ppc_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Morthal board-specific PPC code */ + +#include "driver/ppc/aoz1380_public.h" +#include "driver/ppc/nx20p348x.h" +#include "usbc_ppc.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * In the AOZ1380 PPC, there are no programmable features. We use + * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 + * current limits. + */ +int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv = EC_SUCCESS; + + rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), + (rp == TYPEC_RP_3A0) ? 1 : 0); + + return rv; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + aoz1380_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/morthal/src/usb_mux_config.c b/zephyr/program/skyrim/morthal/src/usb_mux_config.c new file mode 100644 index 0000000000..f4b6502b35 --- /dev/null +++ b/zephyr/program/skyrim/morthal/src/usb_mux_config.c @@ -0,0 +1,142 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Morthal board-specific USB-C mux configuration */ + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } + + return EC_SUCCESS; +} + +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + CPRINTSUSB("C1: PS8818 mux using default tuning"); + + /* Once a DP connection is established, we need to set IN_HPD */ + if (mux_state & USB_PD_MUX_DP_ENABLED) + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + else + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + + return 0; +} + +static void setup_mux(void) +{ + uint32_t val; + + if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) + CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); + /* Val will have our dts default on error, so continue setup */ + + if (val == FW_IO_DB_PS8811_PS8818) { + CPRINTSUSB("C1: Setting PS8818 mux"); + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); + } else if (val == FW_IO_DB_NONE_ANX7483) { + CPRINTSUSB("C1: Setting ANX7483 mux"); + } else { + CPRINTSUSB("Unexpected DB_IO board: %d", val); + } +} +DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/motionsense.dts b/zephyr/program/skyrim/motionsense.dts deleted file mode 100644 index f943bea4c8..0000000000 --- a/zephyr/program/skyrim/motionsense.dts +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi3xx: bmi3xx-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - drv-data = <&bma4xx_data>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/program/skyrim/motionsense.dtsi b/zephyr/program/skyrim/motionsense.dtsi new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/motionsense.dtsi @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/motionsense_crystaldrift.dts b/zephyr/program/skyrim/motionsense_crystaldrift.dts deleted file mode 100644 index f943bea4c8..0000000000 --- a/zephyr/program/skyrim/motionsense_crystaldrift.dts +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi3xx: bmi3xx-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - drv-data = <&bma4xx_data>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/program/skyrim/motionsense_frostflow.dts b/zephyr/program/skyrim/motionsense_frostflow.dts deleted file mode 100644 index f943bea4c8..0000000000 --- a/zephyr/program/skyrim/motionsense_frostflow.dts +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi3xx: bmi3xx-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - drv-data = <&bma4xx_data>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/program/skyrim/motionsense_morthal.dts b/zephyr/program/skyrim/motionsense_morthal.dts deleted file mode 100644 index f943bea4c8..0000000000 --- a/zephyr/program/skyrim/motionsense_morthal.dts +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi3xx: bmi3xx-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - drv-data = <&bma4xx_data>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/program/skyrim/motionsense_skyrim.dts b/zephyr/program/skyrim/motionsense_skyrim.dts deleted file mode 100644 index f943bea4c8..0000000000 --- a/zephyr/program/skyrim/motionsense_skyrim.dts +++ /dev/null @@ -1,135 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - compatible = "cros-ec,motionsense-mutex"; - lid_mutex: lid-mutex { - }; - - mutex_bmi3xx: bmi3xx-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bma4xx_data: bma4xx-drv-data { - compatible = "cros-ec,drvdata-bma4xx"; - status = "okay"; - }; - - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - lid_accel: lid-accel { - compatible = "cros-ec,bma4xx"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_LID"; - mutex = <&lid_mutex>; - port = <&i2c_sensor>; - drv-data = <&bma4xx_data>; - rot-standard-ref = <&lid_rot_ref>; - default-range = <2>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base_accel: base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - - base-gyro { - compatible = "cros-ec,bmi3xx-gyro"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - - /* list of sensors in force mode */ - accel-force-mode-sensors = <&lid_accel>; - }; -}; diff --git a/zephyr/program/skyrim/motionsense_winterhold.dts b/zephyr/program/skyrim/motionsense_winterhold.dts deleted file mode 100644 index 60d345c0a2..0000000000 --- a/zephyr/program/skyrim/motionsense_winterhold.dts +++ /dev/null @@ -1,124 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - - -/ { - aliases { - /* - * motion sense's <>_INT_EVENT is handled - * by alias. Using the alias, each driver creates - * its own <>_INT_EVENT. - */ - bmi3xx-int = &base_accel; - lis2dw12-int = &base_accel; - - /* Use base accelerometer for on-body sensor */ - on-body-sensor = &base_accel; - }; - - /* - * Declare mutexes used by sensor drivers. - * A mutex node is used to create an instance of mutex_t. - * A mutex node is referenced by a sensor node if the - * corresponding sensor driver needs to use the - * instance of the mutex. - */ - motionsense-mutex { - mutex_bmi3xx: bmi3xx-mutex { - }; - mutex_lis2dw12: lis2dw12-mutex { - }; - }; - - /* - * Driver specific data. A driver-specific data can be shared with - * different motion sensors while they are using the same driver. - * - * If a node's compatible starts with "cros-ec,accelgyro-", it is for - * a common structure defined in accelgyro.h. - * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for - * "struct als_drv_data_t" in accelgyro.h - */ - motionsense-sensor-data { - bmi3xx_data: bmi3xx-drv-data { - compatible = "cros-ec,drvdata-bmi3xx"; - status = "okay"; - }; - lis2dw12_data: lis2dw12-drv-data { - compatible = "cros-ec,drvdata-lis2dw12"; - status = "okay"; - }; - }; - - /* - * List of motion sensors that creates motion_sensors array. - * The nodelabel "lid_accel" and "base_accel" are used to indicate - * motion sensor IDs for lid angle calculation. - */ - motionsense-sensor { - base_accel: base-accel { - compatible = "cros-ec,lis2dw12"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_lis2dw12>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - default-range = <2>; - drv-data = <&lis2dw12_data>; - i2c-spi-addr-flags = "LIS2DWL_ADDR1_FLAGS"; - - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - }; - - motionsense-sensor-alt { - alt_base_accel: alt-base-accel { - compatible = "cros-ec,bmi3xx-accel"; - status = "okay"; - - active-mask = "SENSOR_ACTIVE_S0_S3"; - location = "MOTIONSENSE_LOC_BASE"; - mutex = <&mutex_bmi3xx>; - port = <&i2c_sensor>; - rot-standard-ref = <&base_rot_ref>; - drv-data = <&bmi3xx_data>; - alternate-for = <&base_accel>; - configs { - compatible = - "cros-ec,motionsense-sensor-config"; - ec-s0 { - odr = <(12500 | ROUND_UP_FLAG)>; - ec-rate = <100>; - }; - ec-s3 { - odr = <(12500 | ROUND_UP_FLAG)>; - }; - }; - }; - }; - - motionsense-sensor-info { - compatible = "cros-ec,motionsense-sensor-info"; - - /* - * list of GPIO interrupts that have to - * be enabled at initial stage - */ - sensor-irqs = <&int_accel_gyro>; - }; -}; diff --git a/zephyr/program/skyrim/prj.conf b/zephyr/program/skyrim/prj.conf deleted file mode 100644 index e879e1153b..0000000000 --- a/zephyr/program/skyrim/prj.conf +++ /dev/null @@ -1,140 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -CONFIG_CROS_EC=y -CONFIG_PLATFORM_EC=y -CONFIG_SHIMMED_TASKS=y -CONFIG_ESPI=y - -# Shell features -CONFIG_SHELL_HELP=y -CONFIG_SHELL_HISTORY=y -CONFIG_SHELL_TAB=y -CONFIG_SHELL_TAB_AUTOCOMPLETION=y -CONFIG_KERNEL_SHELL=y - -# Power sequencing -CONFIG_AP=y -CONFIG_AP_X86_AMD=y -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWER_BUTTON_TO_PCH_CUSTOM=y -CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y -CONFIG_PLATFORM_EC_POWERSEQ_RSMRST_DELAY=y -CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y -CONFIG_PLATFORM_EC_PORT80=y - -# Power button -CONFIG_PLATFORM_EC_POWER_BUTTON=y - -# CBI -CONFIG_EEPROM=y -CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y - -# Temperature Sensors -CONFIG_PLATFORM_EC_AMD_SB_RMI=y -CONFIG_PLATFORM_EC_AMD_STT=y -CONFIG_PLATFORM_EC_THROTTLE_AP=y - -# External power -CONFIG_PLATFORM_EC_HOSTCMD=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_PLATFORM_EC_BACKLIGHT_LID=y -CONFIG_PLATFORM_EC_BACKLIGHT_LID_ACTIVE_LOW=y - -# Sensors -CONFIG_SENSOR=y -CONFIG_SENSOR_SHELL=n - -# Lid switch -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_LID_SWITCH=y - -# Keyboard -CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y -CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y -CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y -CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y - -# Syscon -CONFIG_SYSCON=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y - -# Charger -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT=512 -CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512 -CONFIG_PLATFORM_EC_CHARGER_ISL9241=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000 - -# USB-C -CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y -CONFIG_PLATFORM_EC_USBC_PPC_AOZ1380=y -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7451=y -CONFIG_PLATFORM_EC_USBC_RETIMER_PS8811=y -CONFIG_PLATFORM_EC_USBC_RETIMER_PS8818=y -CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y -CONFIG_PLATFORM_EC_USB_MUX_AMD_FP6=y -CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y -CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y -CONFIG_PLATFORM_EC_USB_PID=0x505F -CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y -CONFIG_PLATFORM_EC_USB_PD_FRS=y -CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_LOGGING=y -CONFIG_PLATFORM_EC_USB_PD_REV30=y -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n -CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y -CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n -CONFIG_PLATFORM_EC_USB_PD_USB4=n -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y -# Give ourselves enough task space to use i2ctrace -CONFIG_TASK_PD_STACK_SIZE=1280 - -# Motion sense -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y - -CONFIG_PLATFORM_EC_MKBP_EVENT=y -CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y -CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y - -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y - -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y - -# Misc. -CONFIG_PLATFORM_EC_I2C_DEBUG=y -CONFIG_PLATFORM_EC_PORT80_4_BYTE=y - -# These are debug options that happen to be expensive in terms of flash space. -# Turn on as needed based on demand. -CONFIG_FLASH_PAGE_LAYOUT=n # 1876 bytes -CONFIG_FLASH_SHELL=n # 1852 bytes -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n # 656 bytes -CONFIG_PLATFORM_EC_CONSOLE_CMD_MEM=n # 896 bytes -# CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n # 1180 bytes -CONFIG_PLATFORM_EC_CONSOLE_CMD_USB_PD_CABLE=n # 1104 bytes -CONFIG_THREAD_MONITOR=n # 1548 bytes diff --git a/zephyr/program/skyrim/prj_crystaldrift.conf b/zephyr/program/skyrim/prj_crystaldrift.conf deleted file mode 100644 index e9339c1c3c..0000000000 --- a/zephyr/program/skyrim/prj_crystaldrift.conf +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Crystaldrift reference-board-specific Kconfig settings. -CONFIG_BOARD_CRYSTALDRIFT=y - -# CBI WP pin present -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Crystaldrfit is capable of sinking 100W -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 -CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 - -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - -# Enable alternative charger chip -CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y -CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/prj_frostflow.conf b/zephyr/program/skyrim/prj_frostflow.conf deleted file mode 100644 index 02da02d35d..0000000000 --- a/zephyr/program/skyrim/prj_frostflow.conf +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Frostflow reference-board-specific Kconfig settings. -CONFIG_BOARD_FROSTFLOW=y -CONFIG_PLATFORM_EC_CHARGER_INPUT_CURRENT_DERATE_PCT=10 - -# TODO(b/215404321): Remove later in board development -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=n - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Frostflow is capable of sinking 45W -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=45000 -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3000 -CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 -CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=15000 - -# Keyboard -CONFIG_PLATFORM_EC_KEYBOARD_CUSTOMIZATION=y - -# Frostflow not have the USB HUB -CONFIG_BOARD_USB_HUB_RESET=n - -# Battery -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y - -# Fan -CONFIG_PLATFORM_EC_FAN=y -CONFIG_PLATFORM_EC_CUSTOM_FAN_CONTROL=y diff --git a/zephyr/program/skyrim/prj_morthal.conf b/zephyr/program/skyrim/prj_morthal.conf deleted file mode 100644 index 8a22f58ab8..0000000000 --- a/zephyr/program/skyrim/prj_morthal.conf +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Morthal reference-board-specific Kconfig settings. -CONFIG_BOARD_MORTHAL=y - -# TODO(b/215404321): Remove later in board development -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Morthal is capable of sinking 100W -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 -CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 - -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/prj_skyrim.conf b/zephyr/program/skyrim/prj_skyrim.conf deleted file mode 100644 index 67b3f0f142..0000000000 --- a/zephyr/program/skyrim/prj_skyrim.conf +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2021 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Skyrim reference-board-specific Kconfig settings. -CONFIG_BOARD_SKYRIM=y - -# CBI WP pin present -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -# Skyrim is capable of sinking 100W -CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 -CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 -CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 - -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - -# Enable alternative charger chip -CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y -CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/prj_winterhold.conf b/zephyr/program/skyrim/prj_winterhold.conf deleted file mode 100644 index 84be72ec0e..0000000000 --- a/zephyr/program/skyrim/prj_winterhold.conf +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2022 The ChromiumOS Authors -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Winterhold reference-board-specific Kconfig settings. -CONFIG_BOARD_WINTERHOLD=y - -# TODO(b/215404321): Remove later in board development -CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y - -# LED -CONFIG_PLATFORM_EC_LED_DT=y - -CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y - -# Enable charger chip -CONFIG_PLATFORM_EC_CHARGER_ISL9238=y -CONFIG_PLATFORM_EC_CHARGER_ISL9241=n - -# Get the vbus voltage from TCPC -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=n -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y - -# Remove unused sensor -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=n - -# Support LIS2DW12 sensor -CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y - -# Disable lid configuration -CONFIG_PLATFORM_EC_LID_ANGLE=n -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n - -# Disable tablet mode configuration -CONFIG_PLATFORM_EC_TABLET_MODE=n -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n - -# Battery -CONFIG_PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM=y - -# Body detection configuration -CONFIG_PLATFORM_EC_BODY_DETECTION=y -CONFIG_PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0=y -CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE=y -CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTION=y diff --git a/zephyr/program/skyrim/program.conf b/zephyr/program/skyrim/program.conf new file mode 100644 index 0000000000..e879e1153b --- /dev/null +++ b/zephyr/program/skyrim/program.conf @@ -0,0 +1,140 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +CONFIG_CROS_EC=y +CONFIG_PLATFORM_EC=y +CONFIG_SHIMMED_TASKS=y +CONFIG_ESPI=y + +# Shell features +CONFIG_SHELL_HELP=y +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_TAB=y +CONFIG_SHELL_TAB_AUTOCOMPLETION=y +CONFIG_KERNEL_SHELL=y + +# Power sequencing +CONFIG_AP=y +CONFIG_AP_X86_AMD=y +CONFIG_PLATFORM_EC_POWERSEQ=y +CONFIG_PLATFORM_EC_POWER_BUTTON_TO_PCH_CUSTOM=y +CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y +CONFIG_PLATFORM_EC_POWERSEQ_RSMRST_DELAY=y +CONFIG_PLATFORM_EC_POWERSEQ_S0IX=y +CONFIG_PLATFORM_EC_PORT80=y + +# Power button +CONFIG_PLATFORM_EC_POWER_BUTTON=y + +# CBI +CONFIG_EEPROM=y +CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y + +# Temperature Sensors +CONFIG_PLATFORM_EC_AMD_SB_RMI=y +CONFIG_PLATFORM_EC_AMD_STT=y +CONFIG_PLATFORM_EC_THROTTLE_AP=y + +# External power +CONFIG_PLATFORM_EC_HOSTCMD=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_PLATFORM_EC_BACKLIGHT_LID=y +CONFIG_PLATFORM_EC_BACKLIGHT_LID_ACTIVE_LOW=y + +# Sensors +CONFIG_SENSOR=y +CONFIG_SENSOR_SHELL=n + +# Lid switch +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_LID_SWITCH=y + +# Keyboard +CONFIG_PLATFORM_EC_KBLIGHT_ENABLE_PIN=y +CONFIG_PLATFORM_EC_KEYBOARD_COL2_INVERTED=y +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y + +# Syscon +CONFIG_SYSCON=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_REVIVE_DISCONNECT=y + +# Charger +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_DEFAULT_CURRENT_LIMIT=512 +CONFIG_PLATFORM_EC_CHARGER_MIN_INPUT_CURRENT_LIMIT=512 +CONFIG_PLATFORM_EC_CHARGER_ISL9241=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 +CONFIG_PLATFORM_EC_CHARGER_MIN_POWER_MW_FOR_POWER_ON=50000 + +# USB-C +CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y +CONFIG_PLATFORM_EC_USBC_PPC_AOZ1380=y +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7451=y +CONFIG_PLATFORM_EC_USBC_RETIMER_PS8811=y +CONFIG_PLATFORM_EC_USBC_RETIMER_PS8818=y +CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y +CONFIG_PLATFORM_EC_USB_MUX_AMD_FP6=y +CONFIG_PLATFORM_EC_USB_MUX_RUNTIME_CONFIG=y +CONFIG_PLATFORM_EC_USB_DRP_ACC_TRYSRC=y +CONFIG_PLATFORM_EC_USB_PID=0x505F +CONFIG_PLATFORM_EC_USB_PD_5V_EN_CUSTOM=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y +CONFIG_PLATFORM_EC_USB_PD_FRS=y +CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_LOGGING=y +CONFIG_PLATFORM_EC_USB_PD_REV30=y +CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n +CONFIG_PLATFORM_EC_USB_PD_TCPC_LOW_POWER=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_NCT38XX=y +CONFIG_PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG=n +CONFIG_PLATFORM_EC_USB_PD_USB4=n +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=y +# Give ourselves enough task space to use i2ctrace +CONFIG_TASK_PD_STACK_SIZE=1280 + +# Motion sense +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y + +CONFIG_PLATFORM_EC_MKBP_EVENT=y +CONFIG_PLATFORM_EC_MKBP_INPUT_DEVICES=y +CONFIG_PLATFORM_EC_MKBP_USE_GPIO=y + +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y + +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + +# Misc. +CONFIG_PLATFORM_EC_I2C_DEBUG=y +CONFIG_PLATFORM_EC_PORT80_4_BYTE=y + +# These are debug options that happen to be expensive in terms of flash space. +# Turn on as needed based on demand. +CONFIG_FLASH_PAGE_LAYOUT=n # 1876 bytes +CONFIG_FLASH_SHELL=n # 1852 bytes +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n # 656 bytes +CONFIG_PLATFORM_EC_CONSOLE_CMD_MEM=n # 896 bytes +# CONFIG_PLATFORM_EC_CONSOLE_CMD_TCPC_DUMP=n # 1180 bytes +CONFIG_PLATFORM_EC_CONSOLE_CMD_USB_PD_CABLE=n # 1104 bytes +CONFIG_THREAD_MONITOR=n # 1548 bytes diff --git a/zephyr/program/skyrim/skyrim.dts b/zephyr/program/skyrim/skyrim.dts deleted file mode 100644 index c19f8a5949..0000000000 --- a/zephyr/program/skyrim/skyrim.dts +++ /dev/null @@ -1,209 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Skyrim-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <100>; - temp_host_halt = <105>; - temp_host_release_high = <80>; - temp_host_release_halt = <80>; - temp_fan_off = <35>; - temp_fan_max = <70>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - amb-pct2075 { - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* - * Note this is expected to vary per-board, so we keep it in the board - * dts files. - */ - skyrim-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - form-factor { - enum-name = "FW_FORM_FACTOR"; - start = <0>; - size = <1>; - - ff-clamshell { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CLAMSHELL"; - value = <0>; - }; - ff-convertible { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FF_CONVERTIBLE"; - value = <1>; - default; - }; - }; - io-db { - enum-name = "FW_IO_DB"; - start = <6>; - size = <2>; - - io-db-ps8811-ps8818 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_PS8811_PS8818"; - value = <0>; - }; - io-db-none-anx7483 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_IO_DB_NONE_ANX7483"; - value = <1>; - default; - }; - }; - - /* - * FW_CONFIG field to enable fan or not. - */ - fan { - enum-name = "FW_FAN"; - start = <10>; - size = <1>; - - no-fan { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_NOT_PRESENT"; - value = <0>; - }; - fan-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_FAN_PRESENT"; - value = <1>; - /* - * Set as default so that unprovisioned - * configs will run the fan regardless. - */ - default; - }; - }; - - charger-option { - enum-name = "FW_CHARGER"; - start = <11>; - size = <2>; - - charger-option-isl9241 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_CHARGER_ISL9241"; - value = <0>; - default; - }; - charger-option-isl9538 { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_CHARGER_ISL9538"; - value = <1>; - }; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - - lid_rot_ref1: lid-rotation-ref1 { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; - - ppc_port0: aoz1380 { - compatible = "aoz,aoz1380"; - status = "okay"; - }; -}; - -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - flags = ; - }; -}; - -&i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - flags = ; - }; - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; - ps8818_port1: ps8818@28 { - compatible = "parade,ps8818"; - reg = <0x28>; - flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; - board-set = "board_c1_ps8818_mux_set"; - }; -}; - -&i2c4_1 { - charger: isl9241@9 { - compatible = "intersil,isl9241"; - status = "okay"; - reg = <0x9>; - }; - alt_charger: isl9538@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&usbc_port0 { - chg_alt = <&alt_charger>; - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; - usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &ps8818_port1>; - alternative-chain; - }; -}; diff --git a/zephyr/program/skyrim/skyrim/CMakeLists.txt b/zephyr/program/skyrim/skyrim/CMakeLists.txt new file mode 100644 index 0000000000..fef1c72a31 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/CMakeLists.txt @@ -0,0 +1,13 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cros_ec_library_include_directories_ifdef(CONFIG_BOARD_SKYRIM include) +zephyr_library_sources( + "src/usb_mux_config.c" + "src/ppc_config.c" + "src/form_factor.c" + "src/alt_charger.c" + "src/keyboard.c" +) +zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_FAN "src/fan.c") diff --git a/zephyr/program/skyrim/skyrim/battery.dtsi b/zephyr/program/skyrim/skyrim/battery.dtsi new file mode 100644 index 0000000000..8c87cef7f9 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/battery.dtsi @@ -0,0 +1,15 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: aec_5477109 { + compatible = "aec,5477109", "battery-smart"; + }; + smp_l20m3pg1 { + compatible = "smp,l20m3pg1", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/skyrim/led_pins.dtsi b/zephyr/program/skyrim/skyrim/led_pins.dtsi new file mode 100644 index 0000000000..78b9a59c40 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/led_pins.dtsi @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_y: pwm_y { + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + pwm_w: pwm_w { + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/skyrim/led_policy.dtsi b/zephyr/program/skyrim/skyrim/led_policy.dtsi new file mode 100644 index 0000000000..a075c6b0d2 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/led_policy.dtsi @@ -0,0 +1,103 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + /* White 2 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + /* White 1 sec, off 1 sec */ + color-0 { + led-color = <&color_white>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Amber 2 sec, White 2 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_white>; + period-ms = <2000>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/skyrim/motionsense.dtsi b/zephyr/program/skyrim/skyrim/motionsense.dtsi new file mode 100644 index 0000000000..f943bea4c8 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/motionsense.dtsi @@ -0,0 +1,135 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + mutex_bmi3xx: bmi3xx-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bma4xx_data: bma4xx-drv-data { + compatible = "cros-ec,drvdata-bma4xx"; + status = "okay"; + }; + + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,bma4xx"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + drv-data = <&bma4xx_data>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + + base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + + /* list of sensors in force mode */ + accel-force-mode-sensors = <&lid_accel>; + }; +}; diff --git a/zephyr/program/skyrim/skyrim/project.conf b/zephyr/program/skyrim/skyrim/project.conf new file mode 100644 index 0000000000..67b3f0f142 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/project.conf @@ -0,0 +1,26 @@ +# Copyright 2021 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Skyrim reference-board-specific Kconfig settings. +CONFIG_BOARD_SKYRIM=y + +# CBI WP pin present +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# Skyrim is capable of sinking 100W +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=100000 +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=5000 +CONFIG_PLATFORM_EC_PD_MAX_VOLTAGE_MV=20000 + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Enable alternative charger chip +CONFIG_PLATFORM_EC_CHARGER_RUNTIME_CONFIG=y +CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y diff --git a/zephyr/program/skyrim/skyrim/project.overlay b/zephyr/program/skyrim/skyrim/project.overlay new file mode 100644 index 0000000000..9b61b2ac9b --- /dev/null +++ b/zephyr/program/skyrim/skyrim/project.overlay @@ -0,0 +1,19 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim program common DTS includes */ +#include "../adc.dtsi" +#include "../fan.dtsi" +#include "../gpio.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../usbc.dtsi" + +/* Skyrim project DTS includes*/ +#include "skyrim.dtsi" +#include "battery.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" diff --git a/zephyr/program/skyrim/skyrim/skyrim.dtsi b/zephyr/program/skyrim/skyrim/skyrim.dtsi new file mode 100644 index 0000000000..1037df1c8c --- /dev/null +++ b/zephyr/program/skyrim/skyrim/skyrim.dtsi @@ -0,0 +1,209 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "../i2c.dtsi" + +/ { + named-gpios { + /* Skyrim-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <100>; + temp_host_halt = <105>; + temp_host_release_high = <80>; + temp_host_release_halt = <80>; + temp_fan_off = <35>; + temp_fan_max = <70>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* + * Note this is expected to vary per-board, so we keep it in the board + * dts files. + */ + skyrim-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + form-factor { + enum-name = "FW_FORM_FACTOR"; + start = <0>; + size = <1>; + + ff-clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CLAMSHELL"; + value = <0>; + }; + ff-convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FF_CONVERTIBLE"; + value = <1>; + default; + }; + }; + io-db { + enum-name = "FW_IO_DB"; + start = <6>; + size = <2>; + + io-db-ps8811-ps8818 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_PS8811_PS8818"; + value = <0>; + }; + io-db-none-anx7483 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_IO_DB_NONE_ANX7483"; + value = <1>; + default; + }; + }; + + /* + * FW_CONFIG field to enable fan or not. + */ + fan { + enum-name = "FW_FAN"; + start = <10>; + size = <1>; + + no-fan { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_NOT_PRESENT"; + value = <0>; + }; + fan-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_FAN_PRESENT"; + value = <1>; + /* + * Set as default so that unprovisioned + * configs will run the fan regardless. + */ + default; + }; + }; + + charger-option { + enum-name = "FW_CHARGER"; + start = <11>; + size = <2>; + + charger-option-isl9241 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_CHARGER_ISL9241"; + value = <0>; + default; + }; + charger-option-isl9538 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_CHARGER_ISL9538"; + value = <1>; + }; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + lid_rot_ref1: lid-rotation-ref1 { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + ppc_port0: aoz1380 { + compatible = "aoz,aoz1380"; + status = "okay"; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + flags = ; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + flags = ; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; + ps8818_port1: ps8818@28 { + compatible = "parade,ps8818"; + reg = <0x28>; + flags = <(USB_MUX_FLAG_RESETS_IN_G3)>; + board-set = "board_c1_ps8818_mux_set"; + }; +}; + +&i2c4_1 { + charger: isl9241@9 { + compatible = "intersil,isl9241"; + status = "okay"; + reg = <0x9>; + }; + alt_charger: isl9538@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + chg_alt = <&alt_charger>; + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; + usb_mux_chain_ps8818_port1: usb-mux-chain-1-ps { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &ps8818_port1>; + alternative-chain; + }; +}; diff --git a/zephyr/program/skyrim/skyrim/skyrim_vif.xml b/zephyr/program/skyrim/skyrim/skyrim_vif.xml new file mode 100644 index 0000000000..28d6f19049 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/skyrim_vif.xml @@ -0,0 +1,346 @@ + + + 3.22 + + USB-IF + VIF Editor + 3.4.2.0 + + Google + skyrim + FIX-ME + 65535 + Port Product + End Product + + + + + + + + + 0 + Type-C® + + + DRP + DRP + + Both + + + + + + + + + Revision 3 + + + + + + + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 22500 mW + Shared + CPower + 22500 mW + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 1500 mW + + + + 3A @ 5V + + + + + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + + + + + + 100000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 20000 mV + + + + Variable + 4750 mV + 20000 mV + 5000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505F + 0000 + + + + + + + 1 + Type-C® + + + DRP + DRP + + Both + + + + + + + + + Revision 3 + + + + + + + + + + + + + USB Type-C® Receptacle + + + + + + + + + + + + No Interruption Possible + + + + + + + + + + + + + + 1.5A + + Both + + + + + + + 22500 mW + Shared + CPower + 22500 mW + + + + + USB 3.2 Gen 1x1 + + + + + + + + + CDP + + + + 15000 mW + + + + 3A @ 5V + + + + + + + + + Fixed + 100% IOC + 5000 mV + 3000 mA + + + + + + 100000 mW + + + + + FR_Swap not supported + + + + + + Fixed + 5000 mV + 3000 mA + + + + Battery + 15000 mW + 4750 mV + 20000 mV + + + + Variable + 4750 mV + 20000 mV + 5000 mA + + + + + + + + + + + + + + + + + Undefined + PDUSB Host + + + 18D1 + 505F + 0000 + + diff --git a/zephyr/program/skyrim/skyrim/src/alt_charger.c b/zephyr/program/skyrim/skyrim/src/alt_charger.c new file mode 100644 index 0000000000..91e5af8426 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/src/alt_charger.c @@ -0,0 +1,31 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "charger_chips.h" +#include "common.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "hooks.h" + +#include +#include + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +static void alt_charger_init(void) +{ + int ret; + uint32_t val; + + ret = cros_cbi_get_fw_config(FW_CHARGER, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER); + return; + } + + if (val == FW_CHARGER_ISL9538) + CHG_ENABLE_ALTERNATE(0); +} +DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/skyrim/skyrim/src/fan.c b/zephyr/program/skyrim/skyrim/src/fan.c new file mode 100644 index 0000000000..c584022a92 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/src/fan.c @@ -0,0 +1,62 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "fan.h" +#include "gpio/gpio.h" +#include "hooks.h" + +#include +#include +#include + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Skyrim fan support + */ +static void fan_init(void) +{ + int ret; + uint32_t val; + uint32_t board_version; + /* + * Retrieve the fan config. + */ + ret = cros_cbi_get_fw_config(FW_FAN, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); + return; + } + + ret = cbi_get_board_version(&board_version); + if (ret != EC_SUCCESS) { + LOG_ERR("Error retrieving CBI board version"); + return; + } + + if ((board_version >= 3) && (val != FW_FAN_PRESENT)) { + /* Disable the fan */ + fan_set_count(0); + } +} +DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); + +/* + * Pcore OCP support + * Note: early boards should note enable this interrupt as they are not + * correctly configured for it. + */ +__override bool board_supports_pcore_ocp(void) +{ + uint32_t board_version; + + if (cbi_get_board_version(&board_version) == EC_SUCCESS && + board_version > 3) + return true; + + return false; +} diff --git a/zephyr/program/skyrim/skyrim/src/form_factor.c b/zephyr/program/skyrim/skyrim/src/form_factor.c new file mode 100644 index 0000000000..b13d905364 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/src/form_factor.c @@ -0,0 +1,38 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "accelgyro.h" +#include "common.h" +#include "cros_board_info.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +#include +#include + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +/* + * Mainboard orientation support. + */ + +#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1)) +#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel)) + +static void form_factor_init(void) +{ + int ret; + uint32_t val; + /* + * If the board version >=4 + * use ver1 rotation matrix. + */ + ret = cbi_get_board_version(&val); + if (ret == EC_SUCCESS && val >= 4) { + LOG_INF("Switching to ver1 lid"); + motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT; + } +} +DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/skyrim/skyrim/src/keyboard.c b/zephyr/program/skyrim/skyrim/src/keyboard.c new file mode 100644 index 0000000000..e261321e86 --- /dev/null +++ b/zephyr/program/skyrim/skyrim/src/keyboard.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config skyrim_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &skyrim_kb; +} diff --git a/zephyr/program/skyrim/skyrim/src/ppc_config.c b/zephyr/program/skyrim/skyrim/src/ppc_config.c new file mode 100644 index 0000000000..047103baee --- /dev/null +++ b/zephyr/program/skyrim/skyrim/src/ppc_config.c @@ -0,0 +1,46 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim board-specific PPC code */ + +#include "driver/ppc/aoz1380_public.h" +#include "driver/ppc/nx20p348x.h" +#include "usbc_ppc.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * In the AOZ1380 PPC, there are no programmable features. We use + * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 + * current limits. + */ +int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) +{ + int rv = EC_SUCCESS; + + rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), + (rp == TYPEC_RP_3A0) ? 1 : 0); + + return rv; +} + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + aoz1380_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/skyrim/src/usb_mux_config.c b/zephyr/program/skyrim/skyrim/src/usb_mux_config.c new file mode 100644 index 0000000000..8d409dffdd --- /dev/null +++ b/zephyr/program/skyrim/skyrim/src/usb_mux_config.c @@ -0,0 +1,142 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim board-specific USB-C mux configuration */ + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } + + return EC_SUCCESS; +} + +int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + CPRINTSUSB("C1: PS8818 mux using default tuning"); + + /* Once a DP connection is established, we need to set IN_HPD */ + if (mux_state & USB_PD_MUX_DP_ENABLED) + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); + else + ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); + + return 0; +} + +static void setup_mux(void) +{ + uint32_t val; + + if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) + CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); + /* Val will have our dts default on error, so continue setup */ + + if (val == FW_IO_DB_PS8811_PS8818) { + CPRINTSUSB("C1: Setting PS8818 mux"); + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); + } else if (val == FW_IO_DB_NONE_ANX7483) { + CPRINTSUSB("C1: Setting ANX7483 mux"); + } else { + CPRINTSUSB("Unexpected DB_IO board: %d", val); + } +} +DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/skyrim_vif.xml b/zephyr/program/skyrim/skyrim_vif.xml deleted file mode 100644 index 28d6f19049..0000000000 --- a/zephyr/program/skyrim/skyrim_vif.xml +++ /dev/null @@ -1,346 +0,0 @@ - - - 3.22 - - USB-IF - VIF Editor - 3.4.2.0 - - Google - skyrim - FIX-ME - 65535 - Port Product - End Product - - - - - - - - - 0 - Type-C® - - - DRP - DRP - - Both - - - - - - - - - Revision 3 - - - - - - - - - - - - - USB Type-C® Receptacle - - - - - - - - - - - - No Interruption Possible - - - - - - - - - - - - - - 1.5A - - Both - - - - - - - 22500 mW - Shared - CPower - 22500 mW - - - - - USB 3.2 Gen 1x1 - - - - - - - - - CDP - - - - 1500 mW - - - - 3A @ 5V - - - - - - - - - Fixed - 100% IOC - 5000 mV - 3000 mA - - - - - - 100000 mW - - - - - FR_Swap not supported - - - - - - Fixed - 5000 mV - 3000 mA - - - - Battery - 15000 mW - 4750 mV - 20000 mV - - - - Variable - 4750 mV - 20000 mV - 5000 mA - - - - - - - - - - - - - - - - - Undefined - PDUSB Host - - - 18D1 - 505F - 0000 - - - - - - - 1 - Type-C® - - - DRP - DRP - - Both - - - - - - - - - Revision 3 - - - - - - - - - - - - - USB Type-C® Receptacle - - - - - - - - - - - - No Interruption Possible - - - - - - - - - - - - - - 1.5A - - Both - - - - - - - 22500 mW - Shared - CPower - 22500 mW - - - - - USB 3.2 Gen 1x1 - - - - - - - - - CDP - - - - 15000 mW - - - - 3A @ 5V - - - - - - - - - Fixed - 100% IOC - 5000 mV - 3000 mA - - - - - - 100000 mW - - - - - FR_Swap not supported - - - - - - Fixed - 5000 mV - 3000 mA - - - - Battery - 15000 mW - 4750 mV - 20000 mV - - - - Variable - 4750 mV - 20000 mV - 5000 mA - - - - - - - - - - - - - - - - - Undefined - PDUSB Host - - - 18D1 - 505F - 0000 - - diff --git a/zephyr/program/skyrim/src/crystaldrift/alt_charger.c b/zephyr/program/skyrim/src/crystaldrift/alt_charger.c deleted file mode 100644 index a429457136..0000000000 --- a/zephyr/program/skyrim/src/crystaldrift/alt_charger.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "charger_chips.h" -#include "common.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "hooks.h" - -#include -#include - -LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); - -static void alt_charger_init(void) -{ - int ret; - uint32_t val; - - ret = cros_cbi_get_fw_config(FW_CHARGER, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER); - return; - } - - if (val == FW_CHARGER_ISL9538) - CHG_ENABLE_ALTERNATE(0); -} -DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/skyrim/src/crystaldrift/fan.c b/zephyr/program/skyrim/src/crystaldrift/fan.c deleted file mode 100644 index 6645e2a495..0000000000 --- a/zephyr/program/skyrim/src/crystaldrift/fan.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "fan.h" -#include "gpio/gpio.h" -#include "hooks.h" - -#include -#include -#include - -LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); - -/* - * Skyrim fan support - */ -static void fan_init(void) -{ - int ret; - uint32_t val; - uint32_t board_version; - /* - * Retrieve the fan config. - */ - ret = cros_cbi_get_fw_config(FW_FAN, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); - return; - } - - ret = cbi_get_board_version(&board_version); - if (ret != EC_SUCCESS) { - LOG_ERR("Error retrieving CBI board version"); - return; - } - - if ((board_version >= 3) && (val != FW_FAN_PRESENT)) { - /* Disable the fan */ - fan_set_count(0); - } -} -DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); - -/* - * Pcore OCP support - * Note: early boards should note enable this interrupt as they are not - * correctly configured for it. - */ -__override bool board_supports_pcore_ocp(void) -{ - uint32_t board_version; - - if (cbi_get_board_version(&board_version) == EC_SUCCESS && - board_version > 3) - return true; - - return false; -} diff --git a/zephyr/program/skyrim/src/crystaldrift/form_factor.c b/zephyr/program/skyrim/src/crystaldrift/form_factor.c deleted file mode 100644 index 688765617b..0000000000 --- a/zephyr/program/skyrim/src/crystaldrift/form_factor.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "accelgyro.h" -#include "common.h" -#include "cros_board_info.h" -#include "hooks.h" -#include "motionsense_sensors.h" - -#include -#include - -LOG_MODULE_DECLARE(crystaldrift, CONFIG_SKYRIM_LOG_LEVEL); - -/* - * Mainboard orientation support. - */ - -#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1)) -#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel)) - -static void form_factor_init(void) -{ - int ret; - uint32_t val; - /* - * If the board version >=4 - * use ver1 rotation matrix. - */ - ret = cbi_get_board_version(&val); - if (ret == EC_SUCCESS && val >= 4) { - LOG_INF("Switching to ver1 lid"); - motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT; - } -} -DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/skyrim/src/crystaldrift/ppc_config.c b/zephyr/program/skyrim/src/crystaldrift/ppc_config.c deleted file mode 100644 index 3913fda4dc..0000000000 --- a/zephyr/program/skyrim/src/crystaldrift/ppc_config.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Crystaldrift board-specific PPC code */ - -#include "driver/ppc/aoz1380_public.h" -#include "driver/ppc/nx20p348x.h" -#include "usbc_ppc.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * In the AOZ1380 PPC, there are no programmable features. We use - * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 - * current limits. - */ -int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv = EC_SUCCESS; - - rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), - (rp == TYPEC_RP_3A0) ? 1 : 0); - - return rv; -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - aoz1380_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c b/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c deleted file mode 100644 index 0e08431360..0000000000 --- a/zephyr/program/skyrim/src/crystaldrift/usb_mux_config.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Crystaldrift board-specific USB-C mux configuration */ - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" -#include "ioexpander.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return anx7483_set_default_tuning(me, mux_state); -} - -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } - - return EC_SUCCESS; -} - -int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - CPRINTSUSB("C1: PS8818 mux using default tuning"); - - /* Once a DP connection is established, we need to set IN_HPD */ - if (mux_state & USB_PD_MUX_DP_ENABLED) - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); - else - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); - - return 0; -} - -static void setup_mux(void) -{ - uint32_t val; - - if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) - CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); - /* Val will have our dts default on error, so continue setup */ - - if (val == FW_IO_DB_PS8811_PS8818) { - CPRINTSUSB("C1: Setting PS8818 mux"); - USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); - } else if (val == FW_IO_DB_NONE_ANX7483) { - CPRINTSUSB("C1: Setting ANX7483 mux"); - } else { - CPRINTSUSB("Unexpected DB_IO board: %d", val); - } -} -DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/src/frostflow/keyboard.c b/zephyr/program/skyrim/src/frostflow/keyboard.c deleted file mode 100644 index 2905f17941..0000000000 --- a/zephyr/program/skyrim/src/frostflow/keyboard.c +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" -#include "keyboard_scan.h" -#include "timer.h" - -/* Keyboard scan setting */ -__override struct keyboard_scan_config keyscan_config = { - /* Increase from 50 us, because KSO_02 passes through the H1. */ - .output_settle_us = 80, - /* Other values should be the same as the default configuration. */ - .debounce_down_us = 9 * MSEC, - .debounce_up_us = 30 * MSEC, - .scan_period_us = 3 * MSEC, - .min_post_scan_delay_us = 1000, - .poll_timeout_us = 100 * MSEC, - .actual_key_mask = { - 0x1c, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x86, 0xff, 0xff, 0x55, 0xff, 0xff, 0xff, 0xff, /* full set */ - }, -}; - -static const struct ec_response_keybd_config frostflow_kb = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &frostflow_kb; -} - -/* - * Row Column info for Top row keys T1 - T15. - * on frostflow_kb keyboard Row Column is customization - * need define row col to mapping matrix layout. - */ -__override const struct key { - uint8_t row; - uint8_t col; -} vivaldi_keys[] = { - { .row = 4, .col = 2 }, /* T1 */ - { .row = 3, .col = 2 }, /* T2 */ - { .row = 2, .col = 2 }, /* T3 */ - { .row = 1, .col = 2 }, /* T4 */ - { .row = 4, .col = 4 }, /* T5 */ - { .row = 3, .col = 4 }, /* T6 */ - { .row = 2, .col = 4 }, /* T7 */ - { .row = 2, .col = 9 }, /* T8 */ - { .row = 1, .col = 9 }, /* T9 */ - { .row = 1, .col = 4 }, /* T10 */ - { .row = 0, .col = 4 }, /* T11 */ - { .row = 1, .col = 5 }, /* T12 */ - { .row = 3, .col = 5 }, /* T13 */ - { .row = 2, .col = 1 }, /* T14 */ - { .row = 0, .col = 1 }, /* T15 */ -}; -BUILD_ASSERT(ARRAY_SIZE(vivaldi_keys) == MAX_TOP_ROW_KEYS); diff --git a/zephyr/program/skyrim/src/frostflow/keyboard_customization.c b/zephyr/program/skyrim/src/frostflow/keyboard_customization.c deleted file mode 100644 index bd02940e03..0000000000 --- a/zephyr/program/skyrim/src/frostflow/keyboard_customization.c +++ /dev/null @@ -1,85 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "gpio.h" -#include "keyboard_customization.h" -#include "keyboard_protocol.h" -#include "keyboard_raw.h" - -#include - -static uint16_t scancode_set2[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { - { 0x0000, 0x0000, 0x0014, 0xe01f, 0xe014, 0x0000, 0x0000, 0x0000 }, - { 0x001f, 0x0076, 0x0017, 0x000e, 0x001c, 0x003a, 0x000d, 0x0016 }, - { 0x006c, 0xe024, 0xe01d, 0xe020, 0xe038, 0xe071, 0x0026, 0x002a }, - { 0x0032, 0x0034, 0x002c, 0x002e, 0x002b, 0x0029, 0x0025, 0x002d }, - { 0x0078, 0xe032, 0xe035, 0xe02c, 0xe02d, 0x0041, 0x001e, 0x001d }, - { 0x0051, 0x0007, 0x005b, 0x000f, 0x0042, 0x0022, 0x003e, 0x0043 }, - { 0x0031, 0x0033, 0x0035, 0x0036, 0x003b, 0x001b, 0x003d, 0x003c }, - { 0x0000, 0x0012, 0x0061, 0x0000, 0x0000, 0x0000, 0x0000, 0x0059 }, - { 0x0055, 0x0052, 0x0054, 0x004e, 0x004c, 0x0024, 0x0044, 0x004d }, - { 0x0045, 0xe021, 0xe023, 0x002f, 0x004b, 0x0049, 0x0046, 0x001a }, - { 0xe011, 0x0000, 0x006a, 0x0000, 0x005d, 0x0000, 0x0011, 0x0000 }, - { 0xe07a, 0x005d, 0xe075, 0x006b, 0x005a, 0xe072, 0x004a, 0x0066 }, - { 0xe06b, 0xe074, 0xe069, 0x0067, 0xe06c, 0x0064, 0x0015, 0xe07d }, - { 0x0073, 0x007c, 0x007b, 0x0074, 0x0071, 0xe04a, 0x0070, 0x0021 }, - { 0x0023, 0xe05a, 0x0075, 0x0079, 0x007a, 0x0072, 0x007d, 0x0069 }, -}; - -uint16_t get_scancode_set2(uint8_t row, uint8_t col) -{ - if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) - return scancode_set2[col][row]; - return 0; -} - -void set_scancode_set2(uint8_t row, uint8_t col, uint16_t val) -{ - if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) - scancode_set2[col][row] = val; -} - -#ifdef CONFIG_KEYBOARD_DEBUG -static char keycap_label[KEYBOARD_COLS_MAX][KEYBOARD_ROWS] = { - { 'c', KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO }, - { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, - { 'q', KLLI_UNKNO, KLLI_UNKNO, KLLI_TAB, '`', '1', KLLI_UNKNO, 'a' }, - { KLLI_R_ALT, KLLI_L_ALT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, - { KLLI_UNKNO, KLLI_SPACE, 'e', KLLI_F4, KLLI_SEARC, '3', KLLI_F3, - KLLI_UNKNO }, - { 'x', 'z', KLLI_F2, KLLI_F1, 's', '2', 'w', KLLI_ESC }, - { 'v', 'b', 'g', 't', '5', '4', 'r', 'f' }, - { 'm', 'n', 'h', 'y', '6', '7', 'u', 'j' }, - { '.', KLLI_DOWN, '\\', 'o', KLLI_F10, '9', KLLI_UNKNO, 'l' }, - { KLLI_R_SHT, KLLI_L_SHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, - { ',', KLLI_UNKNO, KLLI_F7, KLLI_F6, KLLI_F5, '8', 'i', 'k' }, - { KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, KLLI_F9, KLLI_UNKNO, KLLI_UNKNO, - KLLI_LEFT, KLLI_UNKNO }, - { KLLI_R_CTR, KLLI_L_CTR, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO }, - { '/', KLLI_UP, '-', KLLI_UNKNO, '0', 'p', '[', ';' }, - { '\'', KLLI_ENTER, KLLI_UNKNO, KLLI_UNKNO, '=', KLLI_B_SPC, ']', 'd' }, - { KLLI_UNKNO, KLLI_F8, KLLI_RIGHT, KLLI_UNKNO, KLLI_UNKNO, KLLI_UNKNO, - KLLI_UNKNO, KLLI_UNKNO }, -}; - -char get_keycap_label(uint8_t row, uint8_t col) -{ - if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) - return keycap_label[col][row]; - return KLLI_UNKNO; -} - -void set_keycap_label(uint8_t row, uint8_t col, char val) -{ - if (col < KEYBOARD_COLS_MAX && row < KEYBOARD_ROWS) - keycap_label[col][row] = val; -} -#endif diff --git a/zephyr/program/skyrim/src/frostflow/ppc_config.c b/zephyr/program/skyrim/src/frostflow/ppc_config.c deleted file mode 100644 index 513c025dec..0000000000 --- a/zephyr/program/skyrim/src/frostflow/ppc_config.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Frostflow board-specific PPC code */ - -#include "driver/ppc/aoz1380_public.h" -#include "driver/ppc/nx20p348x.h" -#include "usbc_ppc.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * In the AOZ1380 PPC, there are no programmable features. We use - * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 - * current limits. - */ -int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv = EC_SUCCESS; - - rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), - (rp == TYPEC_RP_3A0) ? 1 : 0); - - return rv; -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - aoz1380_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/program/skyrim/src/frostflow/thermal.c b/zephyr/program/skyrim/src/frostflow/thermal.c deleted file mode 100644 index eae8aac25d..0000000000 --- a/zephyr/program/skyrim/src/frostflow/thermal.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "chipset.h" -#include "fan.h" -#include "tablet_mode.h" -#include "temp_sensor/temp_sensor.h" -#include "thermal.h" -#include "util.h" -#include "console.h" - -#define TEMP_AMB TEMP_SENSOR_ID(DT_NODELABEL(temp_amb)) - -struct fan_step { - /* - * Sensor 0~4 trigger point, set -1 if we're not using this - * sensor to determine fan speed. - */ - int on[TEMP_SENSOR_COUNT]; - /* - * Sensor 0~4 release point, set -1 if we're not using this - * sensor to determine fan speed. - */ - int off[TEMP_SENSOR_COUNT]; - /* Fan rpm */ - uint16_t rpm[FAN_CH_COUNT]; -}; - -#define FAN_TABLE_ENTRY(nd) \ - { \ - .on = DT_PROP(nd, temp_on), \ - .off = DT_PROP(nd, temp_off), \ - .rpm = DT_PROP(nd, rpm_target), \ - }, - -static const struct fan_step fan_table_clamshell[] = { DT_FOREACH_CHILD( - DT_NODELABEL(fan_steps_clamshell), FAN_TABLE_ENTRY) }; - -static const struct fan_step fan_table_tablet[] = { DT_FOREACH_CHILD( - DT_NODELABEL(fan_steps_tablet), FAN_TABLE_ENTRY) }; - -static const struct fan_step *fan_step_table; -#define NUM_FAN_LEVELS ARRAY_SIZE(fan_table_clamshell) - -BUILD_ASSERT(ARRAY_SIZE(fan_table_clamshell) == ARRAY_SIZE(fan_table_tablet)); - -int fan_table_to_rpm(int fan, int *temp) -{ - /* current fan level */ - static int current_level; - /* previous sensor temperature */ - static int prev_tmp[TEMP_SENSOR_COUNT]; - int i; - - if (tablet_get_mode()) - fan_step_table = fan_table_tablet; - else - fan_step_table = fan_table_clamshell; - - /* - * Compare the current and previous temperature, we have - * the three paths : - * 1. decreasing path. (check the release point) - * 2. increasing path. (check the trigger point) - * 3. invariant path. (return the current RPM) - */ - - if (temp[TEMP_AMB] < prev_tmp[TEMP_AMB]) { - for (i = current_level; i > 0; i--) { - if (temp[TEMP_AMB] < fan_step_table[i].off[TEMP_AMB]) - current_level = i - 1; - else - break; - } - } else if (temp[TEMP_AMB] > prev_tmp[TEMP_AMB]) { - for (i = current_level; i < NUM_FAN_LEVELS; i++) { - if (temp[TEMP_AMB] > fan_step_table[i].on[TEMP_AMB]) - current_level = i + 1; - else - break; - } - } - - if (current_level < 0) - current_level = 0; - - if (current_level >= NUM_FAN_LEVELS) - current_level = NUM_FAN_LEVELS - 1; - - for (i = 0; i < TEMP_SENSOR_COUNT; ++i) - prev_tmp[i] = temp[i]; - - return fan_step_table[current_level].rpm[fan]; -} - -void board_override_fan_control(int fan, int *temp) -{ - /* - * In common/fan.c pwm_fan_stop() will turn off fan - * when chipset suspend or shutdown. - */ - if (chipset_in_state(CHIPSET_STATE_ON)) { - fan_set_rpm_mode(fan, 1); - fan_set_rpm_target(fan, fan_table_to_rpm(fan, temp)); - } -} diff --git a/zephyr/program/skyrim/src/frostflow/usb_mux_config.c b/zephyr/program/skyrim/src/frostflow/usb_mux_config.c deleted file mode 100644 index 2ec1dda0be..0000000000 --- a/zephyr/program/skyrim/src/frostflow/usb_mux_config.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Frostflow board-specific USB-C mux configuration */ - -#include "ioexpander.h" -#include "usbc/usb_muxes.h" - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ps8815 DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_c0_amd_fp6_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return EC_SUCCESS; -} - -int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - CPRINTSUSB("C1: PS8818 mux using default tuning"); - - /* Once a DP connection is established, we need to set IN_HPD */ - if (mux_state & USB_PD_MUX_DP_ENABLED) - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); - else - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); - - return 0; -} diff --git a/zephyr/program/skyrim/src/morthal/ppc_config.c b/zephyr/program/skyrim/src/morthal/ppc_config.c deleted file mode 100644 index 8108742fdc..0000000000 --- a/zephyr/program/skyrim/src/morthal/ppc_config.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Morthal board-specific PPC code */ - -#include "driver/ppc/aoz1380_public.h" -#include "driver/ppc/nx20p348x.h" -#include "usbc_ppc.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * In the AOZ1380 PPC, there are no programmable features. We use - * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 - * current limits. - */ -int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv = EC_SUCCESS; - - rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), - (rp == TYPEC_RP_3A0) ? 1 : 0); - - return rv; -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - aoz1380_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/program/skyrim/src/morthal/usb_mux_config.c b/zephyr/program/skyrim/src/morthal/usb_mux_config.c deleted file mode 100644 index f4b6502b35..0000000000 --- a/zephyr/program/skyrim/src/morthal/usb_mux_config.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Morthal board-specific USB-C mux configuration */ - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" -#include "ioexpander.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return anx7483_set_default_tuning(me, mux_state); -} - -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } - - return EC_SUCCESS; -} - -int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - CPRINTSUSB("C1: PS8818 mux using default tuning"); - - /* Once a DP connection is established, we need to set IN_HPD */ - if (mux_state & USB_PD_MUX_DP_ENABLED) - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); - else - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); - - return 0; -} - -static void setup_mux(void) -{ - uint32_t val; - - if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) - CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); - /* Val will have our dts default on error, so continue setup */ - - if (val == FW_IO_DB_PS8811_PS8818) { - CPRINTSUSB("C1: Setting PS8818 mux"); - USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); - } else if (val == FW_IO_DB_NONE_ANX7483) { - CPRINTSUSB("C1: Setting ANX7483 mux"); - } else { - CPRINTSUSB("Unexpected DB_IO board: %d", val); - } -} -DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/src/skyrim/alt_charger.c b/zephyr/program/skyrim/src/skyrim/alt_charger.c deleted file mode 100644 index 91e5af8426..0000000000 --- a/zephyr/program/skyrim/src/skyrim/alt_charger.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "charger_chips.h" -#include "common.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "hooks.h" - -#include -#include - -LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); - -static void alt_charger_init(void) -{ - int ret; - uint32_t val; - - ret = cros_cbi_get_fw_config(FW_CHARGER, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_CHARGER); - return; - } - - if (val == FW_CHARGER_ISL9538) - CHG_ENABLE_ALTERNATE(0); -} -DECLARE_HOOK(HOOK_INIT, alt_charger_init, HOOK_PRIO_POST_FIRST); diff --git a/zephyr/program/skyrim/src/skyrim/fan.c b/zephyr/program/skyrim/src/skyrim/fan.c deleted file mode 100644 index c584022a92..0000000000 --- a/zephyr/program/skyrim/src/skyrim/fan.c +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "fan.h" -#include "gpio/gpio.h" -#include "hooks.h" - -#include -#include -#include - -LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); - -/* - * Skyrim fan support - */ -static void fan_init(void) -{ - int ret; - uint32_t val; - uint32_t board_version; - /* - * Retrieve the fan config. - */ - ret = cros_cbi_get_fw_config(FW_FAN, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_FAN); - return; - } - - ret = cbi_get_board_version(&board_version); - if (ret != EC_SUCCESS) { - LOG_ERR("Error retrieving CBI board version"); - return; - } - - if ((board_version >= 3) && (val != FW_FAN_PRESENT)) { - /* Disable the fan */ - fan_set_count(0); - } -} -DECLARE_HOOK(HOOK_INIT, fan_init, HOOK_PRIO_POST_FIRST); - -/* - * Pcore OCP support - * Note: early boards should note enable this interrupt as they are not - * correctly configured for it. - */ -__override bool board_supports_pcore_ocp(void) -{ - uint32_t board_version; - - if (cbi_get_board_version(&board_version) == EC_SUCCESS && - board_version > 3) - return true; - - return false; -} diff --git a/zephyr/program/skyrim/src/skyrim/form_factor.c b/zephyr/program/skyrim/src/skyrim/form_factor.c deleted file mode 100644 index b13d905364..0000000000 --- a/zephyr/program/skyrim/src/skyrim/form_factor.c +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "accelgyro.h" -#include "common.h" -#include "cros_board_info.h" -#include "hooks.h" -#include "motionsense_sensors.h" - -#include -#include - -LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); - -/* - * Mainboard orientation support. - */ - -#define ALT_MAT SENSOR_ROT_STD_REF_NAME(DT_NODELABEL(lid_rot_ref1)) -#define LID_ACCEL SENSOR_ID(DT_NODELABEL(lid_accel)) - -static void form_factor_init(void) -{ - int ret; - uint32_t val; - /* - * If the board version >=4 - * use ver1 rotation matrix. - */ - ret = cbi_get_board_version(&val); - if (ret == EC_SUCCESS && val >= 4) { - LOG_INF("Switching to ver1 lid"); - motion_sensors[LID_ACCEL].rot_standard_ref = &ALT_MAT; - } -} -DECLARE_HOOK(HOOK_INIT, form_factor_init, HOOK_PRIO_POST_I2C); diff --git a/zephyr/program/skyrim/src/skyrim/keyboard.c b/zephyr/program/skyrim/src/skyrim/keyboard.c deleted file mode 100644 index e261321e86..0000000000 --- a/zephyr/program/skyrim/src/skyrim/keyboard.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" - -static const struct ec_response_keybd_config skyrim_kb = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &skyrim_kb; -} diff --git a/zephyr/program/skyrim/src/skyrim/ppc_config.c b/zephyr/program/skyrim/src/skyrim/ppc_config.c deleted file mode 100644 index 047103baee..0000000000 --- a/zephyr/program/skyrim/src/skyrim/ppc_config.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Skyrim board-specific PPC code */ - -#include "driver/ppc/aoz1380_public.h" -#include "driver/ppc/nx20p348x.h" -#include "usbc_ppc.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * In the AOZ1380 PPC, there are no programmable features. We use - * the attached NCT3807 to control a GPIO to indicate 1A5 or 3A0 - * current limits. - */ -int board_aoz1380_set_vbus_source_current_limit(int port, enum tcpc_rp_value rp) -{ - int rv = EC_SUCCESS; - - rv = gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(ioex_usb_c0_ilim_3a_en), - (rp == TYPEC_RP_3A0) ? 1 : 0); - - return rv; -} - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - aoz1380_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/program/skyrim/src/skyrim/usb_mux_config.c b/zephyr/program/skyrim/src/skyrim/usb_mux_config.c deleted file mode 100644 index 8d409dffdd..0000000000 --- a/zephyr/program/skyrim/src/skyrim/usb_mux_config.c +++ /dev/null @@ -1,142 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Skyrim board-specific USB-C mux configuration */ - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" -#include "ioexpander.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return anx7483_set_default_tuning(me, mux_state); -} - -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } - - return EC_SUCCESS; -} - -int board_c1_ps8818_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - CPRINTSUSB("C1: PS8818 mux using default tuning"); - - /* Once a DP connection is established, we need to set IN_HPD */ - if (mux_state & USB_PD_MUX_DP_ENABLED) - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 1); - else - ioex_set_level(IOEX_USB_C1_HPD_IN_DB, 0); - - return 0; -} - -static void setup_mux(void) -{ - uint32_t val; - - if (cros_cbi_get_fw_config(FW_IO_DB, &val) != 0) - CPRINTSUSB("Error finding FW_DB_IO in CBI FW_CONFIG"); - /* Val will have our dts default on error, so continue setup */ - - if (val == FW_IO_DB_PS8811_PS8818) { - CPRINTSUSB("C1: Setting PS8818 mux"); - USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_ps8818_port1); - } else if (val == FW_IO_DB_NONE_ANX7483) { - CPRINTSUSB("C1: Setting ANX7483 mux"); - } else { - CPRINTSUSB("Unexpected DB_IO board: %d", val); - } -} -DECLARE_HOOK(HOOK_INIT, setup_mux, HOOK_PRIO_INIT_I2C); diff --git a/zephyr/program/skyrim/src/winterhold/battery_present.c b/zephyr/program/skyrim/src/winterhold/battery_present.c deleted file mode 100644 index 290955a242..0000000000 --- a/zephyr/program/skyrim/src/winterhold/battery_present.c +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ -#include "battery.h" -#include "battery_smart.h" -#include "common.h" - -#include - -static enum battery_present batt_pres_prev = BP_NOT_SURE; - -__overridable bool board_battery_is_initialized(void) -{ - int batt_status; - - return battery_status(&batt_status) != EC_SUCCESS ? - false : - !!(batt_status & STATUS_INITIALIZED); -} - -/* - * Physical detection of battery. - */ -static enum battery_present battery_check_present_status(void) -{ - enum battery_present batt_pres; - - if (battery_is_cut_off()) - return BP_NO; - - /* Get the physical hardware status */ - batt_pres = battery_hw_present(); - - /* - * If the battery is not physically connected, then no need to perform - * any more checks. - */ - if (batt_pres == BP_NO) - return BP_NO; - - /* - * If the battery is present now and was present last time we checked, - * return early. - */ - if ((batt_pres == BP_YES) && (batt_pres == batt_pres_prev)) - return BP_YES; - - /* - * Check battery initialization. If the battery is not initialized, - * then return BP_NOT_SURE. Battery could be in ship - * mode and might require pre-charge current to wake it up. BP_NO is not - * returned here because charger state machine will not provide - * pre-charge current assuming that battery is not present. - */ - if (!board_battery_is_initialized()) - return BP_NOT_SURE; - - return BP_YES; -} - -enum battery_present battery_is_present(void) -{ - batt_pres_prev = battery_check_present_status(); - return batt_pres_prev; -} - -enum battery_present battery_hw_present(void) -{ - const struct gpio_dt_spec *batt_pres; - - batt_pres = GPIO_DT_FROM_NODELABEL(gpio_ec_batt_pres_odl); - - /* - * The GPIO is low when the battery is physically present. - * But if battery cell voltage < 2.5V, it will not able to - * pull down EC_BATT_PRES_ODL. So we need to set pre-charge - * current even EC_BATT_PRES_ODL is high. - */ - return gpio_pin_get_dt(batt_pres) ? BP_NOT_SURE : BP_YES; -} diff --git a/zephyr/program/skyrim/src/winterhold/kb_backlight.c b/zephyr/program/skyrim/src/winterhold/kb_backlight.c deleted file mode 100644 index cbbfc0a4e9..0000000000 --- a/zephyr/program/skyrim/src/winterhold/kb_backlight.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "board_config.h" -#include "common.h" -#include "cros_board_info.h" -#include "cros_cbi.h" - -#include -#include - -LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); - -__override uint32_t board_override_feature_flags0(uint32_t flags0) -{ - int ret; - uint32_t val; - - /* - * Remove keyboard backlight feature for devices that don't support it. - */ - ret = cros_cbi_get_fw_config(FW_KB_BL, &val); - if (ret != 0) { - LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_KB_BL); - return flags0; - } - - if (val == FW_KB_BL_NOT_PRESENT) - return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB)); - else - return flags0; -} diff --git a/zephyr/program/skyrim/src/winterhold/keyboard.c b/zephyr/program/skyrim/src/winterhold/keyboard.c deleted file mode 100644 index d3aebe0f2e..0000000000 --- a/zephyr/program/skyrim/src/winterhold/keyboard.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "ec_commands.h" - -static const struct ec_response_keybd_config winterhold_kb = { - .num_top_row_keys = 10, - .action_keys = { - TK_BACK, /* T1 */ - TK_REFRESH, /* T2 */ - TK_FULLSCREEN, /* T3 */ - TK_OVERVIEW, /* T4 */ - TK_SNAPSHOT, /* T5 */ - TK_BRIGHTNESS_DOWN, /* T6 */ - TK_BRIGHTNESS_UP, /* T7 */ - TK_VOL_MUTE, /* T8 */ - TK_VOL_DOWN, /* T9 */ - TK_VOL_UP, /* T10 */ - }, - .capabilities = KEYBD_CAP_SCRNLOCK_KEY, -}; - -__override const struct ec_response_keybd_config * -board_vivaldi_keybd_config(void) -{ - return &winterhold_kb; -} diff --git a/zephyr/program/skyrim/src/winterhold/ppc_config.c b/zephyr/program/skyrim/src/winterhold/ppc_config.c deleted file mode 100644 index d6adb145ff..0000000000 --- a/zephyr/program/skyrim/src/winterhold/ppc_config.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Winterhold board-specific PPC code */ - -#include "driver/ppc/nx20p348x.h" -#include "usbc_ppc.h" - -#include - -void ppc_interrupt(enum gpio_signal signal) -{ - switch (signal) { - case GPIO_USB_C0_PPC_INT_ODL: - nx20p348x_interrupt(0); - break; - - case GPIO_USB_C1_PPC_INT_ODL: - nx20p348x_interrupt(1); - break; - - default: - break; - } -} diff --git a/zephyr/program/skyrim/src/winterhold/sensor.c b/zephyr/program/skyrim/src/winterhold/sensor.c deleted file mode 100644 index 52cd201705..0000000000 --- a/zephyr/program/skyrim/src/winterhold/sensor.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "cros_board_info.h" -#include "driver/accel_lis2dw12.h" -#include "driver/accelgyro_bmi3xx.h" -#include "hooks.h" -#include "motionsense_sensors.h" - -void base_accel_interrupt(enum gpio_signal signal) -{ - int ret; - uint32_t val; - - ret = cbi_get_board_version(&val); - - if (ret == EC_SUCCESS && val < 1) - bmi3xx_interrupt(signal); - else - lis2dw12_interrupt(signal); -} - -static void motionsense_init(void) -{ - int ret; - uint32_t val; - - ret = cbi_get_board_version(&val); - - if (ret == EC_SUCCESS && val < 1) { - MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel); - } -} -DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/skyrim/src/winterhold/usb_mux_config.c b/zephyr/program/skyrim/src/winterhold/usb_mux_config.c deleted file mode 100644 index 19153eb676..0000000000 --- a/zephyr/program/skyrim/src/winterhold/usb_mux_config.c +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/* Winterhold board-specific USB-C mux configuration */ - -#include "console.h" -#include "cros_board_info.h" -#include "cros_cbi.h" -#include "driver/retimer/anx7483_public.h" -#include "hooks.h" -#include "ioexpander.h" -#include "usb_mux.h" -#include "usbc/usb_muxes.h" - -#include - -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) -#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) - -/* - * USB C0 (general) and C1 (just ANX DB) use IOEX pins to - * indicate flipped polarity to a protection switch. - */ -static int ioex_set_flip(int port, mux_state_t mux_state) -{ - if (port == 0) { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), - 0); - } else { - if (mux_state & USB_PD_MUX_POLARITY_INVERTED) - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 1); - else - gpio_pin_set_dt( - GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), - 0); - } - - return EC_SUCCESS; -} - -int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - return anx7483_set_default_tuning(me, mux_state); -} - -int board_anx7483_c1_fg_defalut_tuning(const struct usb_mux *me) -{ - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_URX1, ANX7483_FG_SETTING_1_2DB)); - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_URX2, ANX7483_FG_SETTING_1_2DB)); - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_UTX1, ANX7483_FG_SETTING_1_2DB)); - RETURN_ERROR( - anx7483_set_fg(me, ANX7483_PIN_UTX2, ANX7483_FG_SETTING_1_2DB)); - - return EC_SUCCESS; -} - -int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) -{ - bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; - - /* Set the SBU polarity mux */ - RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); - - /* Remove flipped from the state for easier compraisons */ - mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; - - RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); - - /* - * Set the Flat Gain to default every time, to prevent DP only mode's - * Flat Gain change in the last plug. - */ - RETURN_ERROR(board_anx7483_c1_fg_defalut_tuning(me)); - - if (mux_state == USB_PD_MUX_USB_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - } else if (mux_state == USB_PD_MUX_DP_ENABLED) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX1, - ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX2, - ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX1, - ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX2, - ANX7483_FG_SETTING_0_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX2, - ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX2, - ANX7483_FG_SETTING_0_5DB)); - } else if (mux_state == USB_PD_MUX_DOCK && flipped) { - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, - ANX7483_EQ_SETTING_8_4DB)); - RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, - ANX7483_EQ_SETTING_12_5DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX1, - ANX7483_FG_SETTING_0_5DB)); - RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX1, - ANX7483_FG_SETTING_0_5DB)); - } - - return EC_SUCCESS; -} diff --git a/zephyr/program/skyrim/usbc.dts b/zephyr/program/skyrim/usbc.dts deleted file mode 100644 index 8486927e8d..0000000000 --- a/zephyr/program/skyrim/usbc.dts +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright 2022 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -/ { - usbc { - #address-cells = <1>; - #size-cells = <0>; - - usbc_port0: port0@0 { - compatible = "named-usbc-port"; - reg = <0>; - bc12 = <&bc12_port0>; - tcpc = <&tcpc_port0>; - chg = <&charger>; - }; - - usbc_port1: port1@1 { - compatible = "named-usbc-port"; - reg = <1>; - bc12 = <&bc12_port1>; - tcpc = <&tcpc_port1>; - }; - }; -}; diff --git a/zephyr/program/skyrim/usbc.dtsi b/zephyr/program/skyrim/usbc.dtsi new file mode 100644 index 0000000000..8486927e8d --- /dev/null +++ b/zephyr/program/skyrim/usbc.dtsi @@ -0,0 +1,26 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + usbc_port0: port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + tcpc = <&tcpc_port0>; + chg = <&charger>; + }; + + usbc_port1: port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + tcpc = <&tcpc_port1>; + }; + }; +}; diff --git a/zephyr/program/skyrim/winterhold.dts b/zephyr/program/skyrim/winterhold.dts deleted file mode 100644 index 356aca07e2..0000000000 --- a/zephyr/program/skyrim/winterhold.dts +++ /dev/null @@ -1,168 +0,0 @@ -/* Copyright 2021 The ChromiumOS Authors - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include - -#include "i2c_common.dtsi" - -/ { - named-gpios { - /* Winterhold-specific GPIO customizations */ - }; - - named-temp-sensors { - compatible = "cros-ec,temp-sensors"; - soc-pct2075 { - temp_host_high = <105>; - temp_host_halt = <110>; - temp_host_release_high = <95>; - temp_host_release_halt = <100>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&soc_pct2075>; - }; - amb-pct2075 { - temp_host_warn = <50>; - temp_host_high = <105>; - temp_host_halt = <110>; - temp_host_release_warn = <45>; - temp_host_release_high = <95>; - temp_host_release_halt = <100>; - temp_fan_off = <35>; - temp_fan_max = <40>; - power-good-pin = <&gpio_pg_pwr_s5>; - sensor = <&amb_pct2075>; - }; - }; - - /* - * Note this is expected to vary per-board, so we keep it in the board - * dts files. - */ - Winterhold-fw-config { - compatible = "cros-ec,cbi-fw-config"; - - /* - * FW_CONFIG field to enable KB back light or not. - */ - kb-bl { - enum-name = "FW_KB_BL"; - start = <1>; - size = <1>; - - no-kb-bl { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_BL_NOT_PRESENT"; - value = <0>; - }; - kb-bl-present { - compatible = "cros-ec,cbi-fw-config-value"; - enum-name = "FW_KB_BL_PRESENT"; - value = <1>; - }; - }; - }; - - /* Rotation matrices for motion sensors. */ - motionsense-rotation-ref { - compatible = "cros-ec,motionsense-rotation-ref"; - lid_rot_ref: lid-rotation-ref { - mat33 = <0 (-1) 0 - 1 0 0 - 0 0 1>; - }; - - base_rot_ref: base-rotation-ref { - mat33 = <0 1 0 - (-1) 0 0 - 0 0 1>; - }; - }; -}; - -&i2c0_0 { - anx7483_port0: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c0_mux_set"; - flags = ; - }; - ppc_port0: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; -}; - -&i2c1_0 { - anx7483_port1: anx7483@3e { - compatible = "analogix,anx7483"; - reg = <0x3e>; - board-set = "board_anx7483_c1_mux_set"; - flags = ; - }; - ppc_port1: nx20p348x@71 { - compatible = "nxp,nx20p348x"; - status = "okay"; - reg = <0x71>; - }; -}; - -&i2c4_1 { - charger: isl9238@9 { - compatible = "intersil,isl923x"; - status = "okay"; - reg = <0x9>; - }; -}; - -&usbc_port0 { - ppc = <&ppc_port0>; - usb-mux-chain-0 { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port0 &anx7483_port0>; - }; -}; - -&usbc_port1 { - ppc = <&ppc_port1>; - usb-mux-chain-1-anx { - compatible = "cros-ec,usb-mux-chain"; - usb-muxes = <&amd_fp6_port1 &anx7483_port1>; - }; -}; - -&fan0 { - pwms = <&pwm0 0 PWM_KHZ(2) PWM_POLARITY_NORMAL>; - rpm_min = <2100>; - rpm_start = <2600>; - rpm_max = <4800>; -}; - -&temp_sensor_charger { - temp_host_high = <100>; - temp_host_halt = <110>; - temp_host_release_high = <90>; - temp_host_release_halt = <100>; -}; - -&temp_sensor_memory { - temp_host_high = <91>; - temp_host_halt = <96>; - temp_host_release_high = <81>; - temp_host_release_halt = <86>; -}; - -&temp_sensor_cpu { - /delete-property/ temp_host_high; - /delete-property/ temp_host_halt; - /delete-property/ temp_host_release_high; - /delete-property/ temp_fan_off; - /delete-property/ temp_fan_max; -}; - -/* Override handler */ -&int_accel_gyro { - handler = "base_accel_interrupt"; -}; diff --git a/zephyr/program/skyrim/winterhold/CMakeLists.txt b/zephyr/program/skyrim/winterhold/CMakeLists.txt new file mode 100644 index 0000000000..ebd01a87e6 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +zephyr_library_sources( + "src/usb_mux_config.c" + "src/ppc_config.c" + "src/kb_backlight.c" + "src/keyboard.c" + "src/sensor.c" + "src/battery_present.c" +) diff --git a/zephyr/program/skyrim/winterhold/battery.dtsi b/zephyr/program/skyrim/winterhold/battery.dtsi new file mode 100644 index 0000000000..8e82e0d1f2 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/battery.dtsi @@ -0,0 +1,33 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + batteries { + default_battery: lgc_xphx8 { + compatible = "lgc,xphx8", "battery-smart"; + }; + smp_atlxdy9k { + compatible = "smp,atlxdy9k", "battery-smart"; + }; + smp_cosxdy9k { + compatible = "smp,cosxdy9k", "battery-smart"; + }; + byd_wv3k8 { + compatible = "byd,wv3k8", "battery-smart"; + }; + cosmx_mvk11 { + compatible = "cosmx,mvk11", "battery-smart"; + }; + sunwoda_atlvkyjx { + compatible = "sunwoda,atlvkyjx", "battery-smart"; + }; + sunwoda_cosvkyjx { + compatible = "sunwoda,cosvkyjx", "battery-smart"; + }; + atl_cfd72 { + compatible = "atl,cfd72", "battery-smart"; + }; + }; +}; diff --git a/zephyr/program/skyrim/winterhold/led_pins.dtsi b/zephyr/program/skyrim/winterhold/led_pins.dtsi new file mode 100644 index 0000000000..78b9a59c40 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/led_pins.dtsi @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + pwmleds { + compatible = "pwm-leds"; + pwm_y: pwm_y { + pwms = <&pwm2 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + pwm_w: pwm_w { + pwms = <&pwm3 0 PWM_HZ(100) PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_off: color-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 0>; + }; + + color_amber: color-amber { + led-color = "LED_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_AMBER"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <100 0>; + }; + + color_white: color-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + br-color = "EC_LED_COLOR_WHITE"; + led-pwms = <&pwm_y &pwm_w>; + led-values = <0 100>; + }; + }; +}; + +/* Amber "battery charging" LED */ +&pwm2 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm2_gpc4>; + pinctrl-names = "default"; +}; + +/* White "battery full" LED */ +&pwm3 { + status = "okay"; + clock-bus = "NPCX_CLOCK_BUS_LFCLK"; + pinctrl-0 = <&pwm3_gp80>; + pinctrl-names = "default"; +}; diff --git a/zephyr/program/skyrim/winterhold/led_policy.dtsi b/zephyr/program/skyrim/winterhold/led_policy.dtsi new file mode 100644 index 0000000000..f1f8aa31ed --- /dev/null +++ b/zephyr/program/skyrim/winterhold/led_policy.dtsi @@ -0,0 +1,103 @@ +#include + +/ { + led-colors { + compatible = "cros-ec,led-policy"; + + power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + color-0 { + led-color = <&color_white>; + }; + }; + + power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-discharge-s0-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + /* Battery percent range (> Low, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-discharge-s3-batt-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + /* Battery percent range (>= Empty, <= Low) */ + batt-lvl = ; + + color-0 { + led-color = <&color_amber>; + }; + }; + + power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-error { + charge-state = "PWR_STATE_ERROR"; + + /* Amber 1 sec, off 1 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <1000>; + }; + color-1 { + led-color = <&color_off>; + period-ms = <1000>; + }; + }; + + power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_off>; + }; + }; + + power-state-forced-idle { + charge-state = "PWR_STATE_FORCED_IDLE"; + + /* Amber 2 sec, White 2 sec */ + color-0 { + led-color = <&color_amber>; + period-ms = <2000>; + }; + color-1 { + led-color = <&color_white>; + period-ms = <2000>; + }; + }; + }; +}; diff --git a/zephyr/program/skyrim/winterhold/motionsense.dtsi b/zephyr/program/skyrim/winterhold/motionsense.dtsi new file mode 100644 index 0000000000..60d345c0a2 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/motionsense.dtsi @@ -0,0 +1,124 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + bmi3xx-int = &base_accel; + lis2dw12-int = &base_accel; + + /* Use base accelerometer for on-body sensor */ + on-body-sensor = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + mutex_bmi3xx: bmi3xx-mutex { + }; + mutex_lis2dw12: lis2dw12-mutex { + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + bmi3xx_data: bmi3xx-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + base_accel: base-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_lis2dw12>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + i2c-spi-addr-flags = "LIS2DWL_ADDR1_FLAGS"; + + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + }; + + motionsense-sensor-alt { + alt_base_accel: alt-base-accel { + compatible = "cros-ec,bmi3xx-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&mutex_bmi3xx>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&bmi3xx_data>; + alternate-for = <&base_accel>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(12500 | ROUND_UP_FLAG)>; + ec-rate = <100>; + }; + ec-s3 { + odr = <(12500 | ROUND_UP_FLAG)>; + }; + }; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_accel_gyro>; + }; +}; diff --git a/zephyr/program/skyrim/winterhold/project.conf b/zephyr/program/skyrim/winterhold/project.conf new file mode 100644 index 0000000000..84be72ec0e --- /dev/null +++ b/zephyr/program/skyrim/winterhold/project.conf @@ -0,0 +1,47 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Winterhold reference-board-specific Kconfig settings. +CONFIG_BOARD_WINTERHOLD=y + +# TODO(b/215404321): Remove later in board development +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +CONFIG_PLATFORM_EC_USBC_RETIMER_ANX7483=y + +# Enable charger chip +CONFIG_PLATFORM_EC_CHARGER_ISL9238=y +CONFIG_PLATFORM_EC_CHARGER_ISL9241=n + +# Get the vbus voltage from TCPC +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_CHARGER=n +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_TCPC=y + +# Remove unused sensor +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=n + +# Support LIS2DW12 sensor +CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y + +# Disable lid configuration +CONFIG_PLATFORM_EC_LID_ANGLE=n +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n + +# Disable tablet mode configuration +CONFIG_PLATFORM_EC_TABLET_MODE=n +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n + +# Battery +CONFIG_PLATFORM_EC_BATTERY_HW_PRESENT_CUSTOM=y + +# Body detection configuration +CONFIG_PLATFORM_EC_BODY_DETECTION=y +CONFIG_PLATFORM_EC_BODY_DETECTION_ALWAYS_ENABLE_IN_S0=y +CONFIG_PLATFORM_EC_BODY_DETECTION_NOTIFY_MODE_CHANGE=y +CONFIG_PLATFORM_EC_GESTURE_HOST_DETECTION=y diff --git a/zephyr/program/skyrim/winterhold/project.overlay b/zephyr/program/skyrim/winterhold/project.overlay new file mode 100644 index 0000000000..9a13a1a3cd --- /dev/null +++ b/zephyr/program/skyrim/winterhold/project.overlay @@ -0,0 +1,19 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Skyrim program common DTS includes */ +#include "../adc.dtsi" +#include "../fan.dtsi" +#include "../gpio.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../usbc.dtsi" + +/* winterhold project DTS includes*/ +#include "winterhold.dtsi" +#include "battery.dtsi" +#include "led_pins.dtsi" +#include "led_policy.dtsi" +#include "motionsense.dtsi" diff --git a/zephyr/program/skyrim/winterhold/src/battery_present.c b/zephyr/program/skyrim/winterhold/src/battery_present.c new file mode 100644 index 0000000000..290955a242 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/battery_present.c @@ -0,0 +1,81 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "battery.h" +#include "battery_smart.h" +#include "common.h" + +#include + +static enum battery_present batt_pres_prev = BP_NOT_SURE; + +__overridable bool board_battery_is_initialized(void) +{ + int batt_status; + + return battery_status(&batt_status) != EC_SUCCESS ? + false : + !!(batt_status & STATUS_INITIALIZED); +} + +/* + * Physical detection of battery. + */ +static enum battery_present battery_check_present_status(void) +{ + enum battery_present batt_pres; + + if (battery_is_cut_off()) + return BP_NO; + + /* Get the physical hardware status */ + batt_pres = battery_hw_present(); + + /* + * If the battery is not physically connected, then no need to perform + * any more checks. + */ + if (batt_pres == BP_NO) + return BP_NO; + + /* + * If the battery is present now and was present last time we checked, + * return early. + */ + if ((batt_pres == BP_YES) && (batt_pres == batt_pres_prev)) + return BP_YES; + + /* + * Check battery initialization. If the battery is not initialized, + * then return BP_NOT_SURE. Battery could be in ship + * mode and might require pre-charge current to wake it up. BP_NO is not + * returned here because charger state machine will not provide + * pre-charge current assuming that battery is not present. + */ + if (!board_battery_is_initialized()) + return BP_NOT_SURE; + + return BP_YES; +} + +enum battery_present battery_is_present(void) +{ + batt_pres_prev = battery_check_present_status(); + return batt_pres_prev; +} + +enum battery_present battery_hw_present(void) +{ + const struct gpio_dt_spec *batt_pres; + + batt_pres = GPIO_DT_FROM_NODELABEL(gpio_ec_batt_pres_odl); + + /* + * The GPIO is low when the battery is physically present. + * But if battery cell voltage < 2.5V, it will not able to + * pull down EC_BATT_PRES_ODL. So we need to set pre-charge + * current even EC_BATT_PRES_ODL is high. + */ + return gpio_pin_get_dt(batt_pres) ? BP_NOT_SURE : BP_YES; +} diff --git a/zephyr/program/skyrim/winterhold/src/kb_backlight.c b/zephyr/program/skyrim/winterhold/src/kb_backlight.c new file mode 100644 index 0000000000..cbbfc0a4e9 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/kb_backlight.c @@ -0,0 +1,34 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "board_config.h" +#include "common.h" +#include "cros_board_info.h" +#include "cros_cbi.h" + +#include +#include + +LOG_MODULE_DECLARE(skyrim, CONFIG_SKYRIM_LOG_LEVEL); + +__override uint32_t board_override_feature_flags0(uint32_t flags0) +{ + int ret; + uint32_t val; + + /* + * Remove keyboard backlight feature for devices that don't support it. + */ + ret = cros_cbi_get_fw_config(FW_KB_BL, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FW_KB_BL); + return flags0; + } + + if (val == FW_KB_BL_NOT_PRESENT) + return (flags0 & ~EC_FEATURE_MASK_0(EC_FEATURE_PWM_KEYB)); + else + return flags0; +} diff --git a/zephyr/program/skyrim/winterhold/src/keyboard.c b/zephyr/program/skyrim/winterhold/src/keyboard.c new file mode 100644 index 0000000000..d3aebe0f2e --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/keyboard.c @@ -0,0 +1,29 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config winterhold_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, + .capabilities = KEYBD_CAP_SCRNLOCK_KEY, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &winterhold_kb; +} diff --git a/zephyr/program/skyrim/winterhold/src/ppc_config.c b/zephyr/program/skyrim/winterhold/src/ppc_config.c new file mode 100644 index 0000000000..d6adb145ff --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/ppc_config.c @@ -0,0 +1,27 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Winterhold board-specific PPC code */ + +#include "driver/ppc/nx20p348x.h" +#include "usbc_ppc.h" + +#include + +void ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + nx20p348x_interrupt(0); + break; + + case GPIO_USB_C1_PPC_INT_ODL: + nx20p348x_interrupt(1); + break; + + default: + break; + } +} diff --git a/zephyr/program/skyrim/winterhold/src/sensor.c b/zephyr/program/skyrim/winterhold/src/sensor.c new file mode 100644 index 0000000000..52cd201705 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/sensor.c @@ -0,0 +1,37 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "cros_board_info.h" +#include "driver/accel_lis2dw12.h" +#include "driver/accelgyro_bmi3xx.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +void base_accel_interrupt(enum gpio_signal signal) +{ + int ret; + uint32_t val; + + ret = cbi_get_board_version(&val); + + if (ret == EC_SUCCESS && val < 1) + bmi3xx_interrupt(signal); + else + lis2dw12_interrupt(signal); +} + +static void motionsense_init(void) +{ + int ret; + uint32_t val; + + ret = cbi_get_board_version(&val); + + if (ret == EC_SUCCESS && val < 1) { + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel); + } +} +DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/program/skyrim/winterhold/src/usb_mux_config.c b/zephyr/program/skyrim/winterhold/src/usb_mux_config.c new file mode 100644 index 0000000000..19153eb676 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/src/usb_mux_config.c @@ -0,0 +1,146 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Winterhold board-specific USB-C mux configuration */ + +#include "console.h" +#include "cros_board_info.h" +#include "cros_cbi.h" +#include "driver/retimer/anx7483_public.h" +#include "hooks.h" +#include "ioexpander.h" +#include "usb_mux.h" +#include "usbc/usb_muxes.h" + +#include + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTFUSB(format, args...) cprintf(CC_USBCHARGE, format, ##args) + +/* + * USB C0 (general) and C1 (just ANX DB) use IOEX pins to + * indicate flipped polarity to a protection switch. + */ +static int ioex_set_flip(int port, mux_state_t mux_state) +{ + if (port == 0) { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c0_sbu_flip), + 0); + } else { + if (mux_state & USB_PD_MUX_POLARITY_INVERTED) + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 1); + else + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(ioex_usb_c1_sbu_flip), + 0); + } + + return EC_SUCCESS; +} + +int board_anx7483_c0_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + return anx7483_set_default_tuning(me, mux_state); +} + +int board_anx7483_c1_fg_defalut_tuning(const struct usb_mux *me) +{ + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_URX1, ANX7483_FG_SETTING_1_2DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_URX2, ANX7483_FG_SETTING_1_2DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_UTX1, ANX7483_FG_SETTING_1_2DB)); + RETURN_ERROR( + anx7483_set_fg(me, ANX7483_PIN_UTX2, ANX7483_FG_SETTING_1_2DB)); + + return EC_SUCCESS; +} + +int board_anx7483_c1_mux_set(const struct usb_mux *me, mux_state_t mux_state) +{ + bool flipped = mux_state & USB_PD_MUX_POLARITY_INVERTED; + + /* Set the SBU polarity mux */ + RETURN_ERROR(ioex_set_flip(me->usb_port, mux_state)); + + /* Remove flipped from the state for easier compraisons */ + mux_state = mux_state & ~USB_PD_MUX_POLARITY_INVERTED; + + RETURN_ERROR(anx7483_set_default_tuning(me, mux_state)); + + /* + * Set the Flat Gain to default every time, to prevent DP only mode's + * Flat Gain change in the last plug. + */ + RETURN_ERROR(board_anx7483_c1_fg_defalut_tuning(me)); + + if (mux_state == USB_PD_MUX_USB_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + } else if (mux_state == USB_PD_MUX_DP_ENABLED) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX1, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX2, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX1, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX2, + ANX7483_FG_SETTING_0_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && !flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX1, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX2, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX2, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX2, + ANX7483_FG_SETTING_0_5DB)); + } else if (mux_state == USB_PD_MUX_DOCK && flipped) { + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX1, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_URX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_UTX1, + ANX7483_EQ_SETTING_8_4DB)); + RETURN_ERROR(anx7483_set_eq(me, ANX7483_PIN_DRX2, + ANX7483_EQ_SETTING_12_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_URX1, + ANX7483_FG_SETTING_0_5DB)); + RETURN_ERROR(anx7483_set_fg(me, ANX7483_PIN_UTX1, + ANX7483_FG_SETTING_0_5DB)); + } + + return EC_SUCCESS; +} diff --git a/zephyr/program/skyrim/winterhold/winterhold.dtsi b/zephyr/program/skyrim/winterhold/winterhold.dtsi new file mode 100644 index 0000000000..a831cd9500 --- /dev/null +++ b/zephyr/program/skyrim/winterhold/winterhold.dtsi @@ -0,0 +1,168 @@ +/* Copyright 2021 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +#include "../i2c.dtsi" + +/ { + named-gpios { + /* Winterhold-specific GPIO customizations */ + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + soc-pct2075 { + temp_host_high = <105>; + temp_host_halt = <110>; + temp_host_release_high = <95>; + temp_host_release_halt = <100>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&soc_pct2075>; + }; + amb-pct2075 { + temp_host_warn = <50>; + temp_host_high = <105>; + temp_host_halt = <110>; + temp_host_release_warn = <45>; + temp_host_release_high = <95>; + temp_host_release_halt = <100>; + temp_fan_off = <35>; + temp_fan_max = <40>; + power-good-pin = <&gpio_pg_pwr_s5>; + sensor = <&amb_pct2075>; + }; + }; + + /* + * Note this is expected to vary per-board, so we keep it in the board + * dts files. + */ + Winterhold-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + /* + * FW_CONFIG field to enable KB back light or not. + */ + kb-bl { + enum-name = "FW_KB_BL"; + start = <1>; + size = <1>; + + no-kb-bl { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BL_NOT_PRESENT"; + value = <0>; + }; + kb-bl-present { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_KB_BL_PRESENT"; + value = <1>; + }; + }; + }; + + /* Rotation matrices for motion sensors. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <0 (-1) 0 + 1 0 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; +}; + +&i2c0_0 { + anx7483_port0: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c0_mux_set"; + flags = ; + }; + ppc_port0: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; +}; + +&i2c1_0 { + anx7483_port1: anx7483@3e { + compatible = "analogix,anx7483"; + reg = <0x3e>; + board-set = "board_anx7483_c1_mux_set"; + flags = ; + }; + ppc_port1: nx20p348x@71 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x71>; + }; +}; + +&i2c4_1 { + charger: isl9238@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; +}; + +&usbc_port0 { + ppc = <&ppc_port0>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port0 &anx7483_port0>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1>; + usb-mux-chain-1-anx { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&amd_fp6_port1 &anx7483_port1>; + }; +}; + +&fan0 { + pwms = <&pwm0 0 PWM_KHZ(2) PWM_POLARITY_NORMAL>; + rpm_min = <2100>; + rpm_start = <2600>; + rpm_max = <4800>; +}; + +&temp_sensor_charger { + temp_host_high = <100>; + temp_host_halt = <110>; + temp_host_release_high = <90>; + temp_host_release_halt = <100>; +}; + +&temp_sensor_memory { + temp_host_high = <91>; + temp_host_halt = <96>; + temp_host_release_high = <81>; + temp_host_release_halt = <86>; +}; + +&temp_sensor_cpu { + /delete-property/ temp_host_high; + /delete-property/ temp_host_halt; + /delete-property/ temp_host_release_high; + /delete-property/ temp_fan_off; + /delete-property/ temp_fan_max; +}; + +/* Override handler */ +&int_accel_gyro { + handler = "base_accel_interrupt"; +}; -- cgit v1.2.1