diff options
Diffstat (limited to 'zephyr/projects/corsola')
90 files changed, 3774 insertions, 1245 deletions
diff --git a/zephyr/projects/corsola/BUILD.py b/zephyr/projects/corsola/BUILD.py index 83ad865cb1..32ccd9ebf1 100644 --- a/zephyr/projects/corsola/BUILD.py +++ b/zephyr/projects/corsola/BUILD.py @@ -1,15 +1,15 @@ -# Copyright 2021 The Chromium OS Authors. All rights reserved. +# Copyright 2021 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. """Define zmake projects for corsola.""" -# Default chip is it8xxx2, some variants will use NPCX9X. +# Default chip is it81202bx, some variants will use NPCX9X. def register_corsola_project( project_name, - chip="it8xxx2", + chip="it81202bx", extra_dts_overlays=(), extra_kconfig_files=(), ): @@ -39,12 +39,14 @@ register_corsola_project( here / "gpio_krabby.dts", here / "i2c_krabby.dts", here / "interrupts_krabby.dts", - here / "cbi_eeprom.dts", here / "led_krabby.dts", here / "motionsense_krabby.dts", here / "usbc_krabby.dts", ], - extra_kconfig_files=[here / "prj_krabby.conf"], + extra_kconfig_files=[ + here / "prj_it81202_base.conf", + here / "prj_krabby.conf", + ], ) register_corsola_project( @@ -56,7 +58,6 @@ register_corsola_project( here / "host_interface_npcx.dts", here / "i2c_kingler.dts", here / "interrupts_kingler.dts", - here / "cbi_eeprom.dts", here / "gpio_kingler.dts", here / "npcx_keyboard.dts", here / "led_kingler.dts", @@ -64,7 +65,10 @@ register_corsola_project( here / "usbc_kingler.dts", here / "default_gpio_pinctrl_kingler.dts", ], - extra_kconfig_files=[here / "prj_kingler.conf"], + extra_kconfig_files=[ + here / "prj_npcx993_base.conf", + here / "prj_kingler.conf", + ], ) register_corsola_project( @@ -76,9 +80,10 @@ register_corsola_project( here / "host_interface_npcx.dts", here / "i2c_kingler.dts", here / "interrupts_kingler.dts", - here / "cbi_eeprom.dts", + here / "cbi_steelix.dts", here / "gpio_steelix.dts", here / "npcx_keyboard.dts", + here / "keyboard_steelix.dts", here / "led_steelix.dts", here / "motionsense_kingler.dts", here / "motionsense_steelix.dts", @@ -87,7 +92,47 @@ register_corsola_project( here / "default_gpio_pinctrl_kingler.dts", ], extra_kconfig_files=[ - here / "prj_kingler.conf", + here / "prj_npcx993_base.conf", here / "prj_steelix.conf", ], ) + + +register_corsola_project( + "tentacruel", + extra_dts_overlays=[ + here / "adc_tentacruel.dts", + here / "battery_tentacruel.dts", + here / "cbi_tentacruel.dts", + here / "gpio_tentacruel.dts", + here / "i2c_tentacruel.dts", + here / "interrupts_tentacruel.dts", + here / "led_tentacruel.dts", + here / "motionsense_tentacruel.dts", + here / "usbc_tentacruel.dts", + here / "thermistor_tentacruel.dts", + ], + extra_kconfig_files=[ + here / "prj_it81202_base.conf", + here / "prj_tentacruel.conf", + ], +) + +register_corsola_project( + "magikarp", + extra_dts_overlays=[ + here / "adc_magikarp.dts", + here / "battery_magikarp.dts", + here / "cbi_magikarp.dts", + here / "gpio_magikarp.dts", + here / "i2c_magikarp.dts", + here / "interrupts_magikarp.dts", + here / "led_magikarp.dts", + here / "motionsense_magikarp.dts", + here / "usbc_magikarp.dts", + ], + extra_kconfig_files=[ + here / "prj_it81202_base.conf", + here / "prj_magikarp.conf", + ], +) diff --git a/zephyr/projects/corsola/CMakeLists.txt b/zephyr/projects/corsola/CMakeLists.txt index 2bd50910ee..f92bb2b702 100644 --- a/zephyr/projects/corsola/CMakeLists.txt +++ b/zephyr/projects/corsola/CMakeLists.txt @@ -1,10 +1,10 @@ -# Copyright 2021 The Chromium OS Authors. All rights reserved. +# Copyright 2021 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. cmake_minimum_required(VERSION 3.13.1) -find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +find_package(Zephyr REQUIRED HINTS "${ZEPHYR_BASE}") cros_ec_library_include_directories(include) @@ -24,8 +24,6 @@ if(DEFINED CONFIG_BOARD_KRABBY) zephyr_library_sources("src/krabby/hooks.c" "src/krabby/charger_workaround.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c") - zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON - "src/krabby/led.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/krabby/usb_pd_policy.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC @@ -43,6 +41,7 @@ elseif(DEFINED CONFIG_BOARD_KINGLER) "src/kingler/button.c") elseif(DEFINED CONFIG_BOARD_STEELIX) project(steelix) + zephyr_library_sources("src/kingler/board_steelix.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/kingler/i2c.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_LED_COMMON "src/kingler/led_steelix.c") @@ -50,5 +49,28 @@ elseif(DEFINED CONFIG_BOARD_STEELIX) "src/kingler/usb_pd_policy.c") zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/kingler/usbc_config.c") + +elseif(DEFINED CONFIG_BOARD_TENTACRUEL) + project(tentacruel) + zephyr_library_sources("src/krabby/hooks.c" + "src/krabby/charger_workaround.c" + "src/krabby/sensor_tentacruel.c" + "src/krabby/temp_tentacruel.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/krabby/usb_pd_policy.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/krabby/usbc_config_tentacruel.c") + +elseif(DEFINED CONFIG_BOARD_MAGIKARP) + project(magikarp) + zephyr_library_sources("src/krabby/hooks.c" + "src/krabby/sensor_magikarp.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_I2C "src/krabby/i2c.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/krabby/usb_pd_policy.c") + zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC + "src/krabby/usbc_config.c") + endif() diff --git a/zephyr/projects/corsola/Kconfig b/zephyr/projects/corsola/Kconfig index b05d68acc1..4f66601c20 100644 --- a/zephyr/projects/corsola/Kconfig +++ b/zephyr/projects/corsola/Kconfig @@ -1,4 +1,4 @@ -# Copyright 2021 The Chromium OS Authors. All rights reserved. +# 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. @@ -20,6 +20,18 @@ config BOARD_STEELIX Build Google Steelix variant board. Steelix is a variant of Kingler and has MediaTek MT8186 SoC with NPCX993FA0BX EC. +config BOARD_TENTACRUEL + bool "Google Tentacruel Board" + help + Build Google Tentacruel variant board. Tentacruel is a variant of Krabby + and has MediaTek MT8186 SoC with ITE it81202-bx EC. + +config BOARD_MAGIKARP + bool "Google Magikarp Board" + help + Build Google Magikarp variant board. Magikarp is a variant of Krabby + and has MediaTek MT8186 SoC with ITE it81202-bx EC. + config VARIANT_CORSOLA_DB_DETECTION bool "Corsola Platform Runtime Daughter Board Detection" depends on PLATFORM_EC_USB_PD_TCPC_RUNTIME_CONFIG diff --git a/zephyr/projects/corsola/adc_kingler.dts b/zephyr/projects/corsola/adc_kingler.dts index e7e70caa70..7b69abe48a 100644 --- a/zephyr/projects/corsola/adc_kingler.dts +++ b/zephyr/projects/corsola/adc_kingler.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -12,7 +12,6 @@ compatible = "named-adc-channels"; adc_charger_pmon_r { - label = "ADC_CHARGER_PMON_R"; enum-name = "ADC_PSYS"; io-channels = <&adc0 0>; /* @@ -21,17 +20,14 @@ mul = <21043>; }; adc_ec_id0 { - label = "ADC_EC_ID0"; enum-name = "ADC_ID_0"; io-channels = <&adc0 1>; }; adc_ec_id1 { - label = "ADC_EC_ID1"; enum-name = "ADC_ID_1"; io-channels = <&adc0 2>; }; adc_charger_amon_r { - label = "ADC_AMON_R"; enum-name = "ADC_AMON_BMON"; io-channels = <&adc0 3>; mul = <1000>; diff --git a/zephyr/projects/corsola/adc_krabby.dts b/zephyr/projects/corsola/adc_krabby.dts index 68336f0a70..be65e9eea7 100644 --- a/zephyr/projects/corsola/adc_krabby.dts +++ b/zephyr/projects/corsola/adc_krabby.dts @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ @@ -8,23 +8,19 @@ compatible = "named-adc-channels"; adc_vbus_c0 { - label = "VBUS_C0"; enum-name = "ADC_VBUS_C0"; io-channels = <&adc0 0>; mul = <10>; }; adc_board_id0 { - label = "BOARD_ID_0"; enum-name = "ADC_BOARD_ID_0"; io-channels = <&adc0 1>; }; adc_board_id1 { - label = "BOARD_ID_1"; enum-name = "ADC_BOARD_ID_1"; io-channels = <&adc0 2>; }; adc_vbus_c1 { - label = "VBUS_C1"; enum-name = "ADC_VBUS_C1"; io-channels = <&adc0 7>; mul = <10>; diff --git a/zephyr/projects/corsola/adc_magikarp.dts b/zephyr/projects/corsola/adc_magikarp.dts new file mode 100644 index 0000000000..358af6f0f4 --- /dev/null +++ b/zephyr/projects/corsola/adc_magikarp.dts @@ -0,0 +1,63 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <cros/thermistor/thermistor.dtsi> + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + adc_vbus_c0 { + enum-name = "ADC_VBUS_C0"; + io-channels = <&adc0 0>; + mul = <10>; + }; + adc_board_id0 { + enum-name = "ADC_BOARD_ID_0"; + io-channels = <&adc0 1>; + }; + adc_board_id1 { + enum-name = "ADC_BOARD_ID_1"; + io-channels = <&adc0 2>; + }; + adc_vbus_c1 { + enum-name = "ADC_VBUS_C1"; + io-channels = <&adc0 7>; + mul = <10>; + }; + adc_ambient: ambient { + enum-name = "ADC_TEMP_SENSOR_2_AMBIENT"; + io-channels = <&adc0 5>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_ch0_gpi0_default + &adc0_ch1_gpi1_default + &adc0_ch2_gpi2_default + &adc0_ch5_gpi5_default + &adc0_ch7_gpi7_default>; + pinctrl-names = "default"; +}; + +/ { + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>; + adc = <&adc_ambient>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + ambient { + sensor = <&temp_ambient>; + }; + }; +}; + +&thermistor_3V3_30K9_47K_NCP15WB { + status = "okay"; +}; diff --git a/zephyr/projects/corsola/adc_tentacruel.dts b/zephyr/projects/corsola/adc_tentacruel.dts new file mode 100644 index 0000000000..1b5e849589 --- /dev/null +++ b/zephyr/projects/corsola/adc_tentacruel.dts @@ -0,0 +1,66 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <cros/thermistor/thermistor.dtsi> + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + adc_vbus_c0 { + enum-name = "ADC_VBUS_C0"; + io-channels = <&adc0 0>; + mul = <10>; + }; + adc_board_id0 { + enum-name = "ADC_BOARD_ID_0"; + io-channels = <&adc0 1>; + }; + adc_board_id1 { + enum-name = "ADC_BOARD_ID_1"; + io-channels = <&adc0 2>; + }; + adc_vbus_c1 { + enum-name = "ADC_VBUS_C1"; + io-channels = <&adc0 7>; + mul = <10>; + }; + adc_ambient: ambient { + enum-name = "ADC_TEMP_SENSOR_2_AMBIENT"; + io-channels = <&adc0 5>; + }; + }; +}; + +&adc0 { + status = "okay"; + pinctrl-0 = <&adc0_ch0_gpi0_default + &adc0_ch1_gpi1_default + &adc0_ch2_gpi2_default + &adc0_ch5_gpi5_default + &adc0_ch7_gpi7_default>; + pinctrl-names = "default"; +}; + +/ { + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_NCP15WB>; + adc = <&adc_ambient>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + ambient { + sensor = <&temp_ambient>; + }; + temp_charger: charger { + sensor = <&charger>; + }; + }; +}; + +&thermistor_3V3_30K9_47K_NCP15WB { + status = "okay"; +}; diff --git a/zephyr/projects/corsola/battery_kingler.dts b/zephyr/projects/corsola/battery_kingler.dts index 63d3b7ea21..b01fb8a46d 100644 --- a/zephyr/projects/corsola/battery_kingler.dts +++ b/zephyr/projects/corsola/battery_kingler.dts @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ diff --git a/zephyr/projects/corsola/battery_krabby.dts b/zephyr/projects/corsola/battery_krabby.dts index f80550c76b..ce41859182 100644 --- a/zephyr/projects/corsola/battery_krabby.dts +++ b/zephyr/projects/corsola/battery_krabby.dts @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ @@ -6,7 +6,7 @@ / { batteries { default_battery: c235 { - compatible = "as3gwrc3ka,c235-41", "battery-smart"; + compatible = "celxpert,c235-41", "battery-smart"; }; }; }; diff --git a/zephyr/projects/corsola/battery_magikarp.dts b/zephyr/projects/corsola/battery_magikarp.dts new file mode 100644 index 0000000000..bbdd6ac0c5 --- /dev/null +++ b/zephyr/projects/corsola/battery_magikarp.dts @@ -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: smp_c31n1915 { + compatible = "smp,c31n1915", "battery-smart"; + }; + }; +}; diff --git a/zephyr/projects/corsola/battery_steelix.dts b/zephyr/projects/corsola/battery_steelix.dts index 63d3b7ea21..594c83478c 100644 --- a/zephyr/projects/corsola/battery_steelix.dts +++ b/zephyr/projects/corsola/battery_steelix.dts @@ -1,15 +1,24 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ / { batteries { - default_battery: smp_l20m3pg2 { - compatible = "smp,l20m3pg2", "battery-smart"; + default_battery: byd_l22b3pg0 { + compatible = "byd,l22b3pg0", "battery-smart"; }; - lgc_l20l3pg2 { - compatible = "lgc,l20l3pg2", "battery-smart"; + celxpert_l22c3pg0 { + compatible = "celxpert,l22c3pg0", "battery-smart"; + }; + cosmx_l22x3pg0 { + compatible = "cosmx,l22x3pg0", "battery-smart"; + }; + smp_l22m3pg0 { + compatible = "smp,l22m3pg0", "battery-smart"; + }; + sunwoda_l22d3pg0 { + compatible = "sunwoda,l22d3pg0", "battery-smart"; }; }; }; diff --git a/zephyr/projects/corsola/battery_tentacruel.dts b/zephyr/projects/corsola/battery_tentacruel.dts new file mode 100644 index 0000000000..f116c20a51 --- /dev/null +++ b/zephyr/projects/corsola/battery_tentacruel.dts @@ -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: dynapack_c140254 { + compatible = "dynapack,c140254", "battery-smart"; + }; + }; +}; diff --git a/zephyr/projects/corsola/cbi_eeprom.dts b/zephyr/projects/corsola/cbi_eeprom.dts deleted file mode 100644 index 7f95e2ed6d..0000000000 --- a/zephyr/projects/corsola/cbi_eeprom.dts +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - - &i2c_pwr_cbi { - cbi_eeprom: eeprom@50 { - compatible = "atmel,at24"; - reg = <0x50>; - label = "EEPROM_CBI"; - size = <2048>; - pagesize = <16>; - address-width = <8>; - timeout = <5>; - }; -}; diff --git a/zephyr/projects/corsola/cbi_magikarp.dts b/zephyr/projects/corsola/cbi_magikarp.dts new file mode 100644 index 0000000000..5eac6b82c6 --- /dev/null +++ b/zephyr/projects/corsola/cbi_magikarp.dts @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* magikarp-specific fw_config fields. */ + magikarp-fw-config { + compatible = "cros-ec,cbi-fw-config"; + /* + * FW_CONFIG field to describe mainboard orientation in chassis. + */ + base-gyro { + enum-name = "FW_BASE_GYRO"; + start = <0>; + size = <2>; + + None { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_NONE"; + value = <0>; + }; + icm42607 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_ICM42607"; + value = <1>; + default; + }; + bmi323 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_BMI323"; + value = <2>; + }; + }; + }; +}; diff --git a/zephyr/projects/corsola/cbi_steelix.dts b/zephyr/projects/corsola/cbi_steelix.dts new file mode 100644 index 0000000000..e282eb25ab --- /dev/null +++ b/zephyr/projects/corsola/cbi_steelix.dts @@ -0,0 +1,54 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + steelix-fw-config { + compatible = "cros-ec,cbi-fw-config"; + + /* + * FW_CONFIG field to indicate the device is clamshell + * or convertible. + */ + form_factor { + enum-name = "FORM_FACTOR"; + start = <13>; + size = <3>; + + convertible { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "CONVERTIBLE"; + value = <1>; + }; + clamshell { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "CLAMSHELL"; + value = <0>; + }; + }; + + /* FW_CONFIG field to indicate which DB is attached. */ + db_config: db { + enum-name = "DB"; + start = <0>; + size = <4>; + + sub-board-1 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "DB_NONE"; + value = <0>; + }; + sub-board-2 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "DB_USBA_HDMI"; + value = <1>; + }; + sub-board-3 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "DB_USBA_HDMI_LTE"; + value = <2>; + }; + }; + }; +}; diff --git a/zephyr/projects/corsola/cbi_tentacruel.dts b/zephyr/projects/corsola/cbi_tentacruel.dts new file mode 100644 index 0000000000..2cd4594417 --- /dev/null +++ b/zephyr/projects/corsola/cbi_tentacruel.dts @@ -0,0 +1,36 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + /* tentacruel-specific fw_config fields. */ + tentacruel-fw-config { + compatible = "cros-ec,cbi-fw-config"; + /* + * FW_CONFIG field to describe mainboard orientation in chassis. + */ + base-gyro { + enum-name = "FW_BASE_GYRO"; + start = <8>; + size = <2>; + + None { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_NONE"; + value = <0>; + }; + icm42607 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_ICM42607"; + value = <1>; + default; + }; + bmi323 { + compatible = "cros-ec,cbi-fw-config-value"; + enum-name = "FW_BASE_BMI323"; + value = <2>; + }; + }; + }; +}; diff --git a/zephyr/projects/corsola/common.dts b/zephyr/projects/corsola/common.dts index 52c8eeddf2..001dcc7ce3 100644 --- a/zephyr/projects/corsola/common.dts +++ b/zephyr/projects/corsola/common.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/projects/corsola/default_gpio_pinctrl_kingler.dts b/zephyr/projects/corsola/default_gpio_pinctrl_kingler.dts index d25b388726..604658a145 100644 --- a/zephyr/projects/corsola/default_gpio_pinctrl_kingler.dts +++ b/zephyr/projects/corsola/default_gpio_pinctrl_kingler.dts @@ -1,44 +1,44 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ /* Adds the &alt1_no_lpc_espi setting over the NPCX9 default setting. */ &{/def-io-conf-list} { - pinctrl-0 = <&alt0_gpio_no_spip - &alt0_gpio_no_fpip - &alt1_no_pwrgd - &alt1_no_lpc_espi - &alta_no_peci_en - &altd_npsl_in1_sl - &altd_npsl_in2_sl - &altd_psl_in3_sl - &altd_psl_in4_sl - &alt7_no_ksi0_sl - &alt7_no_ksi1_sl - &alt7_no_ksi2_sl - &alt7_no_ksi3_sl - &alt7_no_ksi4_sl - &alt7_no_ksi5_sl - &alt7_no_ksi6_sl - &alt7_no_ksi7_sl - &alt8_no_kso00_sl - &alt8_no_kso01_sl - &alt8_no_kso02_sl - &alt8_no_kso03_sl - &alt8_no_kso04_sl - &alt8_no_kso05_sl - &alt8_no_kso06_sl - &alt8_no_kso07_sl - &alt9_no_kso08_sl - &alt9_no_kso09_sl - &alt9_no_kso10_sl - &alt9_no_kso11_sl - &alt9_no_kso12_sl - &alt9_no_kso13_sl - &alt9_no_kso14_sl - &alt9_no_kso15_sl - &alta_no_kso16_sl - &alta_no_kso17_sl - &altg_psl_gpo_sl>; + pinmux = <&alt0_gpio_no_spip + &alt0_gpio_no_fpip + &alt1_no_pwrgd + &alt1_no_lpc_espi + &alta_no_peci_en + &altd_npsl_in1_sl + &altd_npsl_in2_sl + &altd_psl_in3_sl + &altd_psl_in4_sl + &alt7_no_ksi0_sl + &alt7_no_ksi1_sl + &alt7_no_ksi2_sl + &alt7_no_ksi3_sl + &alt7_no_ksi4_sl + &alt7_no_ksi5_sl + &alt7_no_ksi6_sl + &alt7_no_ksi7_sl + &alt8_no_kso00_sl + &alt8_no_kso01_sl + &alt8_no_kso02_sl + &alt8_no_kso03_sl + &alt8_no_kso04_sl + &alt8_no_kso05_sl + &alt8_no_kso06_sl + &alt8_no_kso07_sl + &alt9_no_kso08_sl + &alt9_no_kso09_sl + &alt9_no_kso10_sl + &alt9_no_kso11_sl + &alt9_no_kso12_sl + &alt9_no_kso13_sl + &alt9_no_kso14_sl + &alt9_no_kso15_sl + &alta_no_kso16_sl + &alta_no_kso17_sl + &altg_psl_gpo_sl>; }; diff --git a/zephyr/projects/corsola/gpio_kingler.dts b/zephyr/projects/corsola/gpio_kingler.dts index 0199f985fa..d3a4c1be90 100644 --- a/zephyr/projects/corsola/gpio_kingler.dts +++ b/zephyr/projects/corsola/gpio_kingler.dts @@ -1,10 +1,11 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ / { aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; gpio-wp = &gpio_ec_wp_l; gpio-kbd-kso2 = &gpio_ec_kso_02_inv; }; @@ -12,34 +13,36 @@ named-gpios { compatible = "named-gpios"; + /* + * In npcx9 series, gpio46, gpio47, and the whole gpio5 port + * belong to VHIF power well. On kingler, it is connencted to + * 1.8V. + */ base_imu_int_l: base_imu_int_l { - gpios = <&gpio5 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + gpios = <&gpio5 6 GPIO_INPUT>; }; spi_ap_clk_ec { - gpios = <&gpio5 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + gpios = <&gpio5 5 GPIO_INPUT>; }; spi_ap_cs_ec_l { - gpios = <&gpio5 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + gpios = <&gpio5 3 GPIO_INPUT>; }; spi_ap_do_ec_di { - gpios = <&gpio4 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + gpios = <&gpio4 6 GPIO_INPUT>; }; spi_ap_di_ec_do { - gpios = <&gpio4 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + gpios = <&gpio4 7 GPIO_INPUT>; }; ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpio5 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_HIGH)>; + gpios = <&gpio5 1 (GPIO_INPUT | GPIO_ACTIVE_HIGH)>; enum-name = "GPIO_AP_EC_WARM_RST_REQ"; }; ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpio5 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; + gpios = <&gpio5 2 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_EC_WDTRST_L"; }; ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpio5 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; + gpios = <&gpio5 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_IN_SLEEP_L"; }; gpio_en_ulp: en_ulp { @@ -85,8 +88,12 @@ ec_pen_chg_dis_odl { gpios = <&gpioe 4 GPIO_INPUT>; }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio8 0 GPIO_OUTPUT_LOW>; + }; gpio_ec_wp_l: ec_wp_odl { - gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW | + GPIO_VOLTAGE_1P8)>; }; lid_accel_int_l { gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; @@ -108,7 +115,6 @@ }; ec_entering_rw { gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; }; charger_prochot_odl { gpios = <&gpiob 1 GPIO_INPUT>; @@ -138,13 +144,17 @@ gpio_x_ec_gpio2: x_ec_gpio2 { gpios = <&gpiod 4 GPIO_INPUT>; }; + /* + * In npcx9 series, gpio93-97, the whole gpioa port, and gpiob0 + * belong to VSPI power rail. On kingler, it is connencted to + * 1.8V. + */ ap_sysrst_odl_r: ap_sysrst_odl_r { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_EC_SYSRST_ODL"; }; gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioa 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + gpios = <&gpioa 3 GPIO_INPUT>; }; gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { gpios = <&gpio6 7 GPIO_INPUT>; @@ -172,9 +182,8 @@ gpio_usb_c0_tcpc_rst: usb_c0_tcpc_rst { gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus_x { + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PP5000_USB_A0_VBUS"; }; gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { gpios = <&gpio3 7 GPIO_INPUT>; @@ -193,7 +202,7 @@ gpios = <&gpioc 7 GPIO_INPUT>; }; ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpio6 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + gpios = <&gpio6 1 GPIO_ODR_HIGH>; }; ec_pmic_en_odl { gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; @@ -211,6 +220,10 @@ gpios = <&gpioe 5 GPIO_INPUT>; enum-name = "GPIO_CCD_MODE_ODL"; }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; }; /* @@ -233,12 +246,4 @@ &int_lid_open >; }; - - def-lvol-io-list { - compatible = "nuvoton,npcx-lvolctrl-def"; - lvol-io-pads = < - &lvol_ioe3 /* GPIOE3 GPIO_EC_WP_L */ - &lvol_io40 /* GPIO40 GPIO_EC_BL_EN_OD */ - >; - }; }; diff --git a/zephyr/projects/corsola/gpio_krabby.dts b/zephyr/projects/corsola/gpio_krabby.dts index 7246e8a40c..32498ab606 100644 --- a/zephyr/projects/corsola/gpio_krabby.dts +++ b/zephyr/projects/corsola/gpio_krabby.dts @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ @@ -7,6 +7,7 @@ / { aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; gpio-wp = &ec_flash_wp_odl; }; @@ -56,6 +57,9 @@ gpios = <&gpioe 5 GPIO_INPUT>; enum-name = "GPIO_AC_PRESENT"; }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; ec_flash_wp_odl: ec_flash_wp_odl { gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | GPIO_ACTIVE_LOW)>; @@ -111,7 +115,6 @@ }; en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PP5000_USB_A0_VBUS"; }; usb_c0_ppc_frsinfo: usb_c0_ppc_frsinfo { gpios = <&gpiof 0 GPIO_INPUT>; @@ -183,7 +186,6 @@ <&gpioa 3 GPIO_INPUT_PULL_DOWN>, <&gpioa 6 GPIO_INPUT_PULL_DOWN>, <&gpioa 7 GPIO_INPUT_PULL_DOWN>, - <&gpioc 3 GPIO_INPUT_PULL_DOWN>, <&gpiod 7 GPIO_INPUT_PULL_DOWN>, <&gpiof 1 GPIO_INPUT_PULL_DOWN>, <&gpioh 0 GPIO_INPUT_PULL_DOWN>, diff --git a/zephyr/projects/corsola/gpio_magikarp.dts b/zephyr/projects/corsola/gpio_magikarp.dts new file mode 100644 index 0000000000..aeaeab2431 --- /dev/null +++ b/zephyr/projects/corsola/gpio_magikarp.dts @@ -0,0 +1,238 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <dt-bindings/gpio_defines.h> + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &ec_flash_wp_odl; + }; + + named-gpios { + compatible = "named-gpios"; + + power_button_l: power_button_l { + gpios = <&gpioe 4 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + lid_open: lid_open { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + tablet_mode_l: tablet_mode_l { + gpios = <&gpioj 7 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ap_ec_warm_rst_req: ap_ec_warm_rst_req { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_HIGH)>; + enum-name = "GPIO_AP_EC_WARM_RST_REQ"; + }; + ap_in_sleep_l: ap_in_sleep_l { + gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_IN_SLEEP_L"; + }; + base_imu_int_l: base_imu_int_l { + gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + lid_accel_int_l: lid_accel_int_l { + gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + volume_down_l: volume_down_l { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + volume_up_l: volume_up_l { + gpios = <&gpiod 6 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ap_xhci_init_done: ap_xhci_init_done { + gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ac_present: ac_present { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + ec_flash_wp_odl: ec_flash_wp_odl { + gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + }; + spi0_cs: spi0_cs { + gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_x_ec_gpio2: x_ec_gpio2 { + gpios = <&gpiob 2 GPIO_INPUT>; + }; + usb_c0_ppc_bc12_int_odl: usb_c0_ppc_bc12_int_odl { + gpios = <&gpiod 1 GPIO_INPUT>; + }; + usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { + gpios = <&gpioj 4 GPIO_INPUT>; + }; + ec_pmic_en_odl: ec_pmic_en_odl { + gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_PMIC_EN_ODL"; + }; + en_pp5000_z2: en_pp5000_z2 { + gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; + }; + gpio_en_ulp: en_ulp { + gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; + }; + sys_rst_odl: sys_rst_odl { + gpios = <&gpiog 1 GPIO_ODR_LOW>; + enum-name = "GPIO_SYS_RST_ODL"; + }; + gpio_ec_bl_en_od: ec_bl_en_od { + gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + }; + ap_sysrst_odl_r: ap_ec_sysrst_odl { + gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_SYSRST_ODL"; + }; + ap_ec_wdtrst_l: ap_ec_wdtrst_l { + gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_WDTRST_L"; + }; + ec_int_l: ec_int_l { + gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_INT_L"; + }; + dp_aux_path_sel: dp_aux_path_sel { + gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; + }; + ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { + gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + }; + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; + }; + usb_c0_ppc_frsinfo: usb_c0_ppc_frsinfo { + gpios = <&gpiof 0 GPIO_INPUT>; + }; + ec_batt_pres_odl: ec_batt_pres_odl { + gpios = <&gpioc 0 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + en_ec_id_odl: en_ec_id_odl { + gpios = <&gpioh 5 GPIO_ODR_HIGH>; + }; + entering_rw: entering_rw { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_en_5v_usm: en_5v_usm { + gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; + }; + usb_a0_fault_odl: usb_a0_fault_odl { + gpios = <&gpioj 6 GPIO_INPUT>; + }; + gpio_ec_x_gpio1: ec_x_gpio1 { + gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; + }; + gpio_ec_x_gpio3: ec_x_gpio3 { + gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; + }; + gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { + gpios = <&gpioj 3 GPIO_INPUT>; + }; + gpio_packet_mode_en: packet_mode_en { + gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + ccd_mode_odl { + gpios = <&gpioc 4 GPIO_INPUT>; + enum-name = "GPIO_CCD_MODE_ODL"; + }; + }; + + /* + * aliases for sub-board GPIOs + */ + aliases { + gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; + gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; + gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; + gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; + gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; + gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = <&int_ac_present + &int_power_button + &int_lid_open>; + }; + + unused-pins { + compatible = "unused-gpios"; + + unused-gpios = + /* pg_pp5000_z2_od */ + <&gpiod 2 GPIO_INPUT>, + /* pg_mt6315_proc_b_odl */ + <&gpioe 1 GPIO_INPUT>, + /* ec_pen_chg_dis_odl */ + <&gpioh 3 GPIO_ODR_HIGH>, + /* unnamed nc pins */ + <&gpioa 3 GPIO_INPUT_PULL_DOWN>, + <&gpioa 6 GPIO_INPUT_PULL_DOWN>, + <&gpioa 7 GPIO_INPUT_PULL_DOWN>, + <&gpiof 1 GPIO_INPUT_PULL_DOWN>, + /* reserved for b:241345809 */ + <&gpiod 7 GPIO_OUTPUT_LOW>, + <&gpiog 2 GPIO_INPUT_PULL_DOWN>, + <&gpioh 0 GPIO_INPUT_PULL_DOWN>, + <&gpioh 6 GPIO_INPUT_PULL_DOWN>, + <&gpioi 3 GPIO_INPUT_PULL_DOWN>, + <&gpioi 6 GPIO_INPUT_PULL_DOWN>, + <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, + /* spi_clk_gpg6 */ + <&gpiog 6 GPIO_INPUT_PULL_UP>, + /* spi_mosi_gpg4 */ + <&gpiog 4 GPIO_OUTPUT_LOW>, + /* spi_miso_gpg5 */ + <&gpiog 5 GPIO_OUTPUT_LOW>, + /* spi_cs_gpg7 */ + <&gpiog 7 GPIO_OUTPUT_LOW>; + }; +}; + +&pinctrl { + /* I2C property setting */ + i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { + gpio-voltage = "1v8"; + }; + i2c0_data_gpb4_default: i2c0_data_gpb4_default { + gpio-voltage = "1v8"; + }; + i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { + gpio-voltage = "1v8"; + }; + i2c3_data_gpf3_default: i2c3_data_gpf3_default { + gpio-voltage = "1v8"; + }; + /* SHI property setting */ + shi_mosi_gpm0_default: shi_mosi_gpm0_default { + gpio-voltage = "1v8"; + }; + shi_miso_gpm1_default: shi_miso_gpm1_default { + gpio-voltage = "1v8"; + }; + shi_clk_gpm4_default: shi_clk_gpm4_default { + gpio-voltage = "1v8"; + }; + shi_cs_gpm5_default: shi_cs_gpm5_default { + gpio-voltage = "1v8"; + }; +}; diff --git a/zephyr/projects/corsola/gpio_steelix.dts b/zephyr/projects/corsola/gpio_steelix.dts index 3e0375564f..299d809583 100644 --- a/zephyr/projects/corsola/gpio_steelix.dts +++ b/zephyr/projects/corsola/gpio_steelix.dts @@ -1,10 +1,11 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ / { aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; gpio-wp = &gpio_ec_wp_l; gpio-kbd-kso2 = &gpio_ec_kso_02_inv; }; @@ -12,34 +13,36 @@ named-gpios { compatible = "named-gpios"; + /* + * In npcx9 series, gpio46, gpio47, and the whole gpio5 port + * belong to VHIF power well. On steelix, it is connencted to + * 1.8V. + */ base_imu_int_l: base_imu_int_l { - gpios = <&gpio5 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + gpios = <&gpio5 6 GPIO_INPUT>; }; spi_ap_clk_ec { - gpios = <&gpio5 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + gpios = <&gpio5 5 GPIO_INPUT>; }; spi_ap_cs_ec_l { - gpios = <&gpio5 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + gpios = <&gpio5 3 GPIO_INPUT>; }; spi_ap_do_ec_di { - gpios = <&gpio4 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + gpios = <&gpio4 6 GPIO_INPUT>; }; spi_ap_di_ec_do { - gpios = <&gpio4 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + gpios = <&gpio4 7 GPIO_INPUT>; }; ap_ec_warm_rst_req: ap_ec_warm_rst_req { - gpios = <&gpio5 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_HIGH)>; + gpios = <&gpio5 1 (GPIO_INPUT | GPIO_ACTIVE_HIGH)>; enum-name = "GPIO_AP_EC_WARM_RST_REQ"; }; ap_ec_wdtrst_l: ap_ec_wdtrst_l { - gpios = <&gpio5 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; + gpios = <&gpio5 2 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_EC_WDTRST_L"; }; ap_in_sleep_l: ap_in_sleep_l { - gpios = <&gpio5 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; + gpios = <&gpio5 4 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_IN_SLEEP_L"; }; gpio_en_ulp: en_ulp { @@ -84,7 +87,6 @@ }; en_pp5000_usb_a1_vbus: en_pp5000_usb_a1_vbus_x { gpios = <&gpiof 5 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PP5000_USB_A1_VBUS"; }; usb_a1_fault_odl { gpios = <&gpiof 4 GPIO_INPUT>; @@ -92,8 +94,12 @@ ec_pen_chg_dis_odl { gpios = <&gpioe 4 GPIO_INPUT>; }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpio8 0 GPIO_OUTPUT_LOW>; + }; gpio_ec_wp_l: ec_wp_odl { - gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; + gpios = <&gpioe 3 (GPIO_INPUT | GPIO_ACTIVE_LOW | + GPIO_VOLTAGE_1P8)>; }; lid_accel_int_l { gpios = <&gpiob 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; @@ -115,7 +121,6 @@ }; ec_entering_rw { gpios = <&gpio0 3 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_ENTERING_RW"; }; charger_prochot_odl { gpios = <&gpiob 1 GPIO_INPUT>; @@ -145,13 +150,17 @@ gpio_x_ec_gpio2: x_ec_gpio2 { gpios = <&gpiod 4 GPIO_INPUT>; }; + /* + * In npcx9 series, gpio93-97, the whole gpioa port, and gpiob0 + * belong to VSPI power well. On steelix, it is connencted to + * 1.8V. + */ ap_sysrst_odl_r: ap_sysrst_odl_r { - gpios = <&gpioa 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | - GPIO_ACTIVE_LOW)>; + gpios = <&gpioa 1 (GPIO_INPUT | GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_EC_SYSRST_ODL"; }; gpio_ap_xhci_init_done: ap_xhci_init_done { - gpios = <&gpioa 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + gpios = <&gpioa 3 GPIO_INPUT>; }; gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { gpios = <&gpio6 7 GPIO_INPUT>; @@ -179,9 +188,8 @@ gpio_usb_c0_tcpc_rst: usb_c0_tcpc_rst { gpios = <&gpioc 0 GPIO_OUTPUT_LOW>; }; - en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus_x { + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { gpios = <&gpio6 0 GPIO_OUTPUT_LOW>; - enum-name = "GPIO_EN_PP5000_USB_A0_VBUS"; }; gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { gpios = <&gpio3 7 GPIO_INPUT>; @@ -200,7 +208,7 @@ gpios = <&gpioc 7 GPIO_INPUT>; }; ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { - gpios = <&gpio6 1 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + gpios = <&gpio6 1 GPIO_ODR_HIGH>; }; ec_pmic_en_odl { gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; @@ -218,6 +226,10 @@ gpios = <&gpioe 5 GPIO_INPUT>; enum-name = "GPIO_CCD_MODE_ODL"; }; + /* unimplemented GPIOs */ + entering-rw { + enum-name = "GPIO_ENTERING_RW"; + }; }; /* @@ -240,12 +252,4 @@ &int_lid_open >; }; - - def-lvol-io-list { - compatible = "nuvoton,npcx-lvolctrl-def"; - lvol-io-pads = < - &lvol_ioe3 /* GPIOE3 GPIO_EC_WP_L */ - &lvol_io40 /* GPIO40 GPIO_EC_BL_EN_OD */ - >; - }; }; diff --git a/zephyr/projects/corsola/gpio_tentacruel.dts b/zephyr/projects/corsola/gpio_tentacruel.dts new file mode 100644 index 0000000000..75607cb561 --- /dev/null +++ b/zephyr/projects/corsola/gpio_tentacruel.dts @@ -0,0 +1,239 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <dt-bindings/gpio_defines.h> + +/ { + aliases { + gpio-cbi-wp = &gpio_ec_cbi_wp; + gpio-wp = &ec_flash_wp_odl; + }; + + named-gpios { + compatible = "named-gpios"; + + power_button_l: power_button_l { + gpios = <&gpioe 4 GPIO_INPUT>; + enum-name = "GPIO_POWER_BUTTON_L"; + }; + lid_open: lid_open { + gpios = <&gpioe 2 GPIO_INPUT>; + enum-name = "GPIO_LID_OPEN"; + }; + tablet_mode_l: tablet_mode_l { + gpios = <&gpioj 7 GPIO_INPUT>; + enum-name = "GPIO_TABLET_MODE_L"; + }; + ap_ec_warm_rst_req: ap_ec_warm_rst_req { + gpios = <&gpiod 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_HIGH)>; + enum-name = "GPIO_AP_EC_WARM_RST_REQ"; + }; + ap_in_sleep_l: ap_in_sleep_l { + gpios = <&gpiob 6 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_IN_SLEEP_L"; + }; + base_imu_int_l: base_imu_int_l { + gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + lid_accel_int_l: lid_accel_int_l { + gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + volume_down_l: volume_down_l { + gpios = <&gpiod 5 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_DOWN_L"; + }; + volume_up_l: volume_up_l { + gpios = <&gpiod 6 GPIO_INPUT>; + enum-name = "GPIO_VOLUME_UP_L"; + }; + gpio_ap_xhci_init_done: ap_xhci_init_done { + gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + ac_present: ac_present { + gpios = <&gpioe 5 GPIO_INPUT>; + enum-name = "GPIO_AC_PRESENT"; + }; + gpio_ec_cbi_wp: ec_cbi_wp { + gpios = <&gpioc 3 GPIO_OUTPUT_LOW>; + }; + ec_flash_wp_odl: ec_flash_wp_odl { + gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + }; + spi0_cs: spi0_cs { + gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; + }; + gpio_x_ec_gpio2: x_ec_gpio2 { + gpios = <&gpiob 2 GPIO_INPUT>; + }; + usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + gpios = <&gpiod 1 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_PPC_INT_ODL"; + }; + usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + gpios = <&gpiof 1 GPIO_INPUT>; + enum-name = "GPIO_USB_C0_BC12_INT_ODL"; + }; + usb_c1_bc12_charger_int_odl: usb_c1_bc12_charger_int_odl { + gpios = <&gpioj 4 GPIO_INPUT>; + }; + ec_pmic_en_odl: ec_pmic_en_odl { + gpios = <&gpiod 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_PMIC_EN_ODL"; + }; + en_pp5000_z2: en_pp5000_z2 { + gpios = <&gpioc 6 GPIO_OUTPUT_HIGH>; + }; + gpio_en_ulp: en_ulp { + gpios = <&gpioe 3 GPIO_OUTPUT_LOW>; + }; + sys_rst_odl: sys_rst_odl { + gpios = <&gpiog 1 GPIO_ODR_LOW>; + enum-name = "GPIO_SYS_RST_ODL"; + }; + gpio_ec_bl_en_od: ec_bl_en_od { + gpios = <&gpiob 5 (GPIO_ODR_LOW | GPIO_VOLTAGE_1P8)>; + }; + ap_sysrst_odl_r: ap_ec_sysrst_odl { + gpios = <&gpioj 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_SYSRST_ODL"; + }; + ap_ec_wdtrst_l: ap_ec_wdtrst_l { + gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | + GPIO_ACTIVE_LOW)>; + enum-name = "GPIO_AP_EC_WDTRST_L"; + }; + ec_int_l: ec_int_l { + gpios = <&gpioe 6 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + enum-name = "GPIO_EC_INT_L"; + }; + dp_aux_path_sel: dp_aux_path_sel { + gpios = <&gpiog 0 GPIO_OUTPUT_HIGH>; + }; + ec_ap_dp_hpd_odl: ec_ap_dp_hpd_odl { + gpios = <&gpioj 0 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; + }; + en_pp5000_usb_a0_vbus: en_pp5000_usb_a0_vbus { + gpios = <&gpiob 7 GPIO_OUTPUT_LOW>; + }; + usb_c0_frs_en: usb_c0_frs_en { + gpios = <&gpiof 0 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_USB_C0_FRS_EN"; + }; + ec_batt_pres_odl: ec_batt_pres_odl { + gpios = <&gpioc 0 GPIO_INPUT>; + enum-name = "GPIO_BATT_PRES_ODL"; + }; + en_ec_id_odl: en_ec_id_odl { + gpios = <&gpioh 5 GPIO_ODR_HIGH>; + }; + entering_rw: entering_rw { + gpios = <&gpioc 5 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_ENTERING_RW"; + }; + gpio_en_5v_usm: en_5v_usm { + gpios = <&gpiog 3 GPIO_OUTPUT_LOW>; + }; + usb_a0_fault_odl: usb_a0_fault_odl { + gpios = <&gpioj 6 GPIO_INPUT>; + }; + gpio_ec_x_gpio1: ec_x_gpio1 { + gpios = <&gpioh 4 GPIO_OUTPUT_LOW>; + }; + gpio_ec_x_gpio3: ec_x_gpio3 { + gpios = <&gpioj 1 GPIO_OUTPUT_LOW>; + }; + gpio_hdmi_prsnt_odl: hdmi_prsnt_odl { + gpios = <&gpioj 3 GPIO_INPUT>; + }; + gpio_packet_mode_en: packet_mode_en { + gpios = <&gpiod 4 GPIO_OUTPUT_LOW>; + enum-name = "GPIO_PACKET_MODE_EN"; + }; + }; + + /* + * aliases for sub-board GPIOs + */ + aliases { + gpio-en-hdmi-pwr = &gpio_ec_x_gpio1; + gpio-usb-c1-frs-en = &gpio_ec_x_gpio1; + gpio-usb-c1-ppc-int-odl = &gpio_x_ec_gpio2; + gpio-ps185-ec-dp-hpd = &gpio_x_ec_gpio2; + gpio-usb-c1-dp-in-hpd = &gpio_ec_x_gpio3; + gpio-ps185-pwrdn-odl = &gpio_ec_x_gpio3; + }; + + hibernate-wake-pins { + compatible = "cros-ec,hibernate-wake-pins"; + wakeup-irqs = <&int_ac_present + &int_power_button + &int_lid_open>; + }; + + unused-pins { + compatible = "unused-gpios"; + + unused-gpios = + /* pg_pp5000_z2_od */ + <&gpiod 2 GPIO_INPUT>, + /* pg_mt6315_proc_b_odl */ + <&gpioe 1 GPIO_INPUT>, + /* ec_pen_chg_dis_odl */ + <&gpioh 3 GPIO_ODR_HIGH>, + /* ccd_mode_odl */ + <&gpioc 4 GPIO_INPUT>, + /* unnamed nc pins */ + <&gpioa 3 GPIO_INPUT_PULL_DOWN>, + <&gpioa 6 GPIO_INPUT_PULL_DOWN>, + <&gpioa 7 GPIO_INPUT_PULL_DOWN>, + <&gpiod 7 GPIO_INPUT_PULL_DOWN>, + <&gpioh 0 GPIO_INPUT_PULL_DOWN>, + <&gpioh 6 GPIO_INPUT_PULL_DOWN>, + <&gpioi 3 GPIO_INPUT_PULL_DOWN>, + <&gpioi 6 GPIO_INPUT_PULL_DOWN>, + <&gpiom 6 (GPIO_INPUT_PULL_DOWN | GPIO_VOLTAGE_1P8)>, + /* spi_clk_gpg6 */ + <&gpiog 6 GPIO_INPUT_PULL_UP>, + /* spi_mosi_gpg4 */ + <&gpiog 4 GPIO_OUTPUT_LOW>, + /* spi_miso_gpg5 */ + <&gpiog 5 GPIO_OUTPUT_LOW>, + /* spi_cs_gpg7 */ + <&gpiog 7 GPIO_OUTPUT_LOW>; + }; +}; + +&pinctrl { + /* I2C property setting */ + i2c0_clk_gpb3_default: i2c0_clk_gpb3_default { + gpio-voltage = "1v8"; + }; + i2c0_data_gpb4_default: i2c0_data_gpb4_default { + gpio-voltage = "1v8"; + }; + i2c3_clk_gpf2_default: i2c3_clk_gpf2_default { + gpio-voltage = "1v8"; + }; + i2c3_data_gpf3_default: i2c3_data_gpf3_default { + gpio-voltage = "1v8"; + }; + /* SHI property setting */ + shi_mosi_gpm0_default: shi_mosi_gpm0_default { + gpio-voltage = "1v8"; + }; + shi_miso_gpm1_default: shi_miso_gpm1_default { + gpio-voltage = "1v8"; + }; + shi_clk_gpm4_default: shi_clk_gpm4_default { + gpio-voltage = "1v8"; + }; + shi_cs_gpm5_default: shi_cs_gpm5_default { + gpio-voltage = "1v8"; + }; +}; diff --git a/zephyr/projects/corsola/host_interface_npcx.dts b/zephyr/projects/corsola/host_interface_npcx.dts index 9c6a498940..14efa3c6b2 100644 --- a/zephyr/projects/corsola/host_interface_npcx.dts +++ b/zephyr/projects/corsola/host_interface_npcx.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/projects/corsola/i2c_kingler.dts b/zephyr/projects/corsola/i2c_kingler.dts index c832e55d2e..4bcbeb6950 100644 --- a/zephyr/projects/corsola/i2c_kingler.dts +++ b/zephyr/projects/corsola/i2c_kingler.dts @@ -1,8 +1,10 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ +#include <dt-bindings/usb_pd_tcpm.h> + /* * Kingler and Steelix use the same dts, take care of this when modify it. */ @@ -13,42 +15,29 @@ i2c_sensor: sensor { i2c-port = <&i2c0_0>; - enum-name = "I2C_PORT_SENSOR"; + enum-names = "I2C_PORT_SENSOR"; }; i2c_usb_c0: usb-c0 { i2c-port = <&i2c1_0>; remote-port = <7>; - enum-name = "I2C_PORT_USB_C0"; + enum-names = "I2C_PORT_USB_C0"; }; i2c_usb_c1: usb-c1 { i2c-port = <&i2c2_0>; - enum-name = "I2C_PORT_USB_C1"; - }; - tcpc1 { - i2c-port = <&i2c2_0>; - enum-name = "I2C_PORT_USB_C1_TCPC"; - }; - ppc1 { - i2c-port = <&i2c2_0>; - enum-name = "I2C_PORT_USB_C1_PPC"; - }; - eeprom { - i2c-port = <&i2c3_0>; - enum-name = "I2C_PORT_EEPROM"; + enum-names = "I2C_PORT_USB_C1", + "I2C_PORT_USB_C1_TCPC", + "I2C_PORT_USB_C1_PPC"; }; i2c_charger: charger { i2c-port = <&i2c3_0>; - enum-name = "I2C_PORT_POWER"; + enum-names = "I2C_PORT_POWER", + "I2C_PORT_EEPROM"; }; battery { i2c-port = <&i2c5_0>; remote-port = <1>; - enum-name = "I2C_PORT_BATTERY"; - }; - virtual-battery { - i2c-port = <&i2c5_0>; - remote-port = <1>; - enum-name = "I2C_PORT_VIRTUAL_BATTERY"; + enum-names = "I2C_PORT_BATTERY", + "I2C_PORT_VIRTUAL_BATTERY"; }; }; }; @@ -71,6 +60,30 @@ clock-frequency = <I2C_BITRATE_FAST_PLUS>; pinctrl-0 = <&i2c1_0_sda_scl_gp87_90>; pinctrl-names = "default"; + + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + + tcpc_port0: anx7447-tcpc@2c { + compatible = "anologix,anx7447-tcpc"; + status = "okay"; + reg = <0x2c>; + tcpc-flags = <( + TCPC_FLAGS_VBUS_MONITOR | + TCPC_FLAGS_ALERT_OD | + TCPC_FLAGS_CONTROL_VCONN | + TCPC_FLAGS_CONTROL_FRS)>; + }; + + ppc_port0: nx20p348x@72 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x72>; + }; }; &i2c_ctrl1 { @@ -83,18 +96,60 @@ clock-frequency = <I2C_BITRATE_FAST_PLUS>; pinctrl-0 = <&i2c2_0_sda_scl_gp91_92>; pinctrl-names = "default"; + + bc12_port1: rt1718s-bc12@40 { + compatible = "richtek,rt1718s-bc12"; + status = "okay"; + reg = <0x40>; + }; + + tcpc_port1: rt1718s-tcpc@40 { + compatible = "richtek,rt1718s-tcpc"; + reg = <0x40>; + tcpc-flags = <( + TCPC_FLAGS_ALERT_OD | + TCPC_FLAGS_CONTROL_VCONN | + TCPC_FLAGS_CONTROL_FRS)>; + }; + + ppc_port1: nx20p348x@72 { + compatible = "nxp,nx20p348x"; + status = "okay"; + reg = <0x72>; + }; + + ps8743_mux_1: ps8743-mux-1@10 { + compatible = "parade,ps8743"; + reg = <0x10>; + board-init = "ps8743_mux_1_board_init"; + }; }; &i2c_ctrl2 { status = "okay"; }; -i2c_pwr_cbi: &i2c3_0 { +&i2c3_0 { label = "I2C_PWR_CBI"; status = "okay"; clock-frequency = <I2C_BITRATE_FAST>; pinctrl-0 = <&i2c3_0_sda_scl_gpd0_d1>; pinctrl-names = "default"; + + charger: isl923x@9 { + compatible = "intersil,isl923x"; + status = "okay"; + reg = <0x9>; + }; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; }; &i2c_ctrl3 { diff --git a/zephyr/projects/corsola/i2c_krabby.dts b/zephyr/projects/corsola/i2c_krabby.dts index 75cf3834eb..4b3c46ffe4 100644 --- a/zephyr/projects/corsola/i2c_krabby.dts +++ b/zephyr/projects/corsola/i2c_krabby.dts @@ -1,103 +1,21 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ -/ { - named-i2c-ports { - compatible = "named-i2c-ports"; +#include "i2c_krabby_tentacruel.dtsi" - battery { - i2c-port = <&i2c1>; - remote-port = <1>; - enum-name = "I2C_PORT_BATTERY"; - }; - virtual-battery { - i2c-port = <&i2c1>; - enum-name = "I2C_PORT_VIRTUAL_BATTERY"; - }; - eeprom { - i2c-port = <&i2c0>; - enum-name = "I2C_PORT_EEPROM"; - }; - i2c_charger: charger { - i2c-port = <&i2c0>; - enum-name = "I2C_PORT_CHARGER"; - }; - i2c_sensor: sensor { - i2c-port = <&i2c3>; - enum-name = "I2C_PORT_SENSOR"; - }; - i2c_usb_c0: usb-c0 { - i2c-port = <&i2c2>; - enum-name = "I2C_PORT_USB_C0"; - }; - i2c_usb_c1: usb-c1 { - i2c-port = <&i2c4>; - enum-name = "I2C_PORT_USB_C1"; - }; - i2c_usb_mux0: usb-mux0 { - i2c-port = <&i2c2>; - enum-name = "I2C_PORT_USB_MUX0"; - }; - i2c_usb_mux1: usb-mux1 { - i2c-port = <&i2c4>; - enum-name = "I2C_PORT_USB_MUX1"; - }; +&i2c0 { + charger: rt9490@53 { + compatible = "richtek,rt9490"; + status = "okay"; + reg = <0x53>; }; - -}; - -i2c_pwr_cbi: &i2c0 { - /* EC_I2C_PWR_CBI */ - label = "I2C_PWR_CBI"; - status = "okay"; - clock-frequency = <I2C_BITRATE_FAST>; - pinctrl-0 = <&i2c0_clk_gpb3_default - &i2c0_data_gpb4_default>; - pinctrl-names = "default"; -}; - -&i2c1 { - /* EC_I2C_BATTERY */ - label = "I2C_BATTERY"; - status = "okay"; - clock-frequency = <50000>; - pinctrl-0 = <&i2c1_clk_gpc1_default - &i2c1_data_gpc2_default>; - pinctrl-names = "default"; -}; - -&i2c2 { - /* EC_I2C_USB_C0 */ - label = "I2C_USB_C0"; - status = "okay"; - clock-frequency = <I2C_BITRATE_FAST>; - pinctrl-0 = <&i2c2_clk_gpf6_default - &i2c2_data_gpf7_default>; - pinctrl-names = "default"; -}; - -&i2c3 { - /* EC_I2C_SENSOR */ - label = "I2C_SENSOR"; - status = "okay"; - clock-frequency = <I2C_BITRATE_FAST>; - scl-gpios = <&gpiof 2 0>; - sda-gpios = <&gpiof 3 0>; - pinctrl-0 = <&i2c3_clk_gpf2_default - &i2c3_data_gpf3_default>; - pinctrl-names = "default"; - prescale-scl-low = <1>; }; &i2c4 { - /* EC_I2C_USB_C1 */ - label = "I2C_USB_C1"; - status = "okay"; - clock-frequency = <I2C_BITRATE_FAST>; - pinctrl-0 = <&i2c4_clk_gpe0_default - &i2c4_data_gpe7_default>; - pinctrl-names = "default"; - prescale-scl-low = <1>; + tusb1064_mux_1: tusb1064-mux-1@44 { + compatible = "ti,tusb1064"; + reg = <0x44>; + }; }; diff --git a/zephyr/projects/corsola/i2c_krabby_tentacruel.dtsi b/zephyr/projects/corsola/i2c_krabby_tentacruel.dtsi new file mode 100644 index 0000000000..377eaafbca --- /dev/null +++ b/zephyr/projects/corsola/i2c_krabby_tentacruel.dtsi @@ -0,0 +1,136 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + named-i2c-ports { + compatible = "named-i2c-ports"; + + battery { + i2c-port = <&i2c1>; + remote-port = <1>; + enum-names = "I2C_PORT_BATTERY", + "I2C_PORT_VIRTUAL_BATTERY"; + }; + i2c_charger: charger { + i2c-port = <&i2c0>; + enum-names = "I2C_PORT_CHARGER", + "I2C_PORT_EEPROM"; + }; + i2c_sensor: sensor { + i2c-port = <&i2c3>; + enum-names = "I2C_PORT_SENSOR"; + }; + i2c_usb_c0: usb-c0 { + i2c-port = <&i2c2>; + enum-names = "I2C_PORT_USB_C0", + "I2C_PORT_USB_MUX0"; + }; + i2c_usb_c1: usb-c1 { + i2c-port = <&i2c4>; + enum-names = "I2C_PORT_USB_C1", + "I2C_PORT_USB_MUX1"; + }; + }; + +}; + +&pinctrl { + i2c3_clk_gpf2_sleep: i2c3_clk_gpf2_sleep { + pinmuxs = <&pinctrlf 2 IT8XXX2_ALT_DEFAULT>; + }; + i2c3_data_gpf3_sleep: i2c3_data_gpf3_sleep { + pinmuxs = <&pinctrlf 3 IT8XXX2_ALT_DEFAULT>; + }; +}; + +&i2c0 { + /* EC_I2C_PWR_CBI */ + label = "I2C_PWR_CBI"; + status = "okay"; + clock-frequency = <I2C_BITRATE_FAST>; + pinctrl-0 = <&i2c0_clk_gpb3_default + &i2c0_data_gpb4_default>; + pinctrl-names = "default"; + + cbi_eeprom: eeprom@50 { + compatible = "atmel,at24"; + reg = <0x50>; + size = <2048>; + pagesize = <16>; + address-width = <8>; + timeout = <5>; + }; + + bc12_port1: rt9490-bc12@53 { + compatible = "richtek,rt9490-bc12"; + status = "okay"; + reg = <0x53>; + irq = <&int_usb_c1_bc12_charger>; + }; +}; + +&i2c1 { + /* EC_I2C_BATTERY */ + label = "I2C_BATTERY"; + status = "okay"; + clock-frequency = <50000>; + pinctrl-0 = <&i2c1_clk_gpc1_default + &i2c1_data_gpc2_default>; + pinctrl-names = "default"; +}; + +&i2c2 { + /* EC_I2C_USB_C0 */ + label = "I2C_USB_C0"; + status = "okay"; + clock-frequency = <I2C_BITRATE_FAST>; + pinctrl-0 = <&i2c2_clk_gpf6_default + &i2c2_data_gpf7_default>; + pinctrl-names = "default"; + + bc12_ppc_port0: rt1739@70 { + compatible = "richtek,rt1739"; + status = "okay"; + reg = <0x70>; + }; + + it5205_mux_0: it5205-mux-0@48 { + compatible = "ite,it5205"; + reg = <0x48>; + }; +}; + +&i2c3 { + /* EC_I2C_SENSOR */ + label = "I2C_SENSOR"; + status = "okay"; + clock-frequency = <I2C_BITRATE_FAST>; + scl-gpios = <&gpiof 2 0>; + sda-gpios = <&gpiof 3 0>; + pinctrl-0 = <&i2c3_clk_gpf2_default + &i2c3_data_gpf3_default>; + pinctrl-1 = <&i2c3_clk_gpf2_sleep + &i2c3_data_gpf3_sleep>; + pinctrl-names = "default", "sleep"; + prescale-scl-low = <1>; +}; + +&i2c4 { + /* EC_I2C_USB_C1 */ + label = "I2C_USB_C1"; + status = "okay"; + clock-frequency = <I2C_BITRATE_FAST>; + pinctrl-0 = <&i2c4_clk_gpe0_default + &i2c4_data_gpe7_default>; + pinctrl-names = "default"; + prescale-scl-low = <1>; + + ppc_port1: syv682x@40 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x40>; + frs_en_gpio = <&gpio_ec_x_gpio1>; + }; +}; diff --git a/zephyr/projects/corsola/i2c_magikarp.dts b/zephyr/projects/corsola/i2c_magikarp.dts new file mode 100644 index 0000000000..2039398974 --- /dev/null +++ b/zephyr/projects/corsola/i2c_magikarp.dts @@ -0,0 +1,21 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "i2c_krabby_tentacruel.dtsi" + +&i2c0 { + charger: rt9490@53 { + compatible = "richtek,rt9490"; + status = "okay"; + reg = <0x53>; + }; +}; + +&i2c4 { + ps8743_mux_1: ps8743-mux-1@10 { + compatible = "parade,ps8743"; + reg = <0x10>; + }; +}; diff --git a/zephyr/projects/corsola/i2c_tentacruel.dts b/zephyr/projects/corsola/i2c_tentacruel.dts new file mode 100644 index 0000000000..e40dc02318 --- /dev/null +++ b/zephyr/projects/corsola/i2c_tentacruel.dts @@ -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 "i2c_krabby_tentacruel.dtsi" + +&i2c0 { + charger: rt9490@53 { + compatible = "richtek,rt9490"; + status = "okay"; + reg = <0x53>; + thermistor = <&thermistor_rt9490>; + }; +}; + +&i2c2 { + bc12_port0: pi3usb9201@5f { + compatible = "pericom,pi3usb9201"; + status = "okay"; + reg = <0x5f>; + irq = <&int_usb_c0_bc12>; + }; + ppc_port0: syv682x@40 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x40>; + frs_en_gpio = <&usb_c0_frs_en>; + }; +}; + +&i2c4 { + ps8743_mux_1: ps8743-mux-1@10 { + compatible = "parade,ps8743"; + reg = <0x10>; + }; +}; diff --git a/zephyr/projects/corsola/include/baseboard_usbc_config.h b/zephyr/projects/corsola/include/baseboard_usbc_config.h index eb09a86865..a29fd93f54 100644 --- a/zephyr/projects/corsola/include/baseboard_usbc_config.h +++ b/zephyr/projects/corsola/include/baseboard_usbc_config.h @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ @@ -8,20 +8,19 @@ #ifndef __CROS_EC_BASEBOARD_USBC_CONFIG_H #define __CROS_EC_BASEBOARD_USBC_CONFIG_H +#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S +#define GPIO_EN_USB_C1_SINK RT1718S_GPIO1 +#define GPIO_EN_USB_C1_SOURCE RT1718S_GPIO2 +#define GPIO_EN_USB_C1_FRS RT1718S_GPIO3 +#endif + void ppc_interrupt(enum gpio_signal signal); /* USB-A ports */ -enum usba_port { - USBA_PORT_A0 = 0, - USBA_PORT_COUNT -}; +enum usba_port { USBA_PORT_A0 = 0, USBA_PORT_COUNT }; /* USB-C ports */ -enum usbc_port { - USBC_PORT_C0 = 0, - USBC_PORT_C1, - USBC_PORT_COUNT -}; +enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT); /** diff --git a/zephyr/projects/corsola/include/gpio_map.h b/zephyr/projects/corsola/include/gpio_map.h deleted file mode 100644 index 562671b685..0000000000 --- a/zephyr/projects/corsola/include/gpio_map.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef __ZEPHYR_GPIO_MAP_H -#define __ZEPHYR_GPIO_MAP_H - - -#include <zephyr/devicetree.h> -#include <gpio_signal.h> - -#define GPIO_ENTERING_RW GPIO_UNIMPLEMENTED - -#ifdef CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S -#define GPIO_EN_USB_C1_SINK RT1718S_GPIO1 -#define GPIO_EN_USB_C1_SOURCE RT1718S_GPIO2 -#define GPIO_EN_USB_C1_FRS RT1718S_GPIO3 -#endif - -#endif /* __ZEPHYR_GPIO_MAP_H */ diff --git a/zephyr/projects/corsola/include/i2c_map.h b/zephyr/projects/corsola/include/i2c_map.h deleted file mode 100644 index e2f6c53ed2..0000000000 --- a/zephyr/projects/corsola/include/i2c_map.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef __ZEPHYR_I2C_MAP_H -#define __ZEPHYR_I2C_MAP_H - -#include <zephyr/devicetree.h> - -#include "i2c/i2c.h" - -#endif /* __ZEPHYR_I2C_MAP_H */ diff --git a/zephyr/projects/corsola/include/variant_db_detection.h b/zephyr/projects/corsola/include/variant_db_detection.h index 40853016f8..285ff327f2 100644 --- a/zephyr/projects/corsola/include/variant_db_detection.h +++ b/zephyr/projects/corsola/include/variant_db_detection.h @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ @@ -9,7 +9,8 @@ #define __CROS_EC_CORSOLA_DB_DETECTION_H enum corsola_db_type { - CORSOLA_DB_NONE = -1, + CORSOLA_DB_UNINIT = -1, + CORSOLA_DB_NONE, CORSOLA_DB_TYPEC, CORSOLA_DB_HDMI, CORSOLA_DB_COUNT, diff --git a/zephyr/projects/corsola/interrupts_kingler.dts b/zephyr/projects/corsola/interrupts_kingler.dts index b33251624d..38b8c2e24d 100644 --- a/zephyr/projects/corsola/interrupts_kingler.dts +++ b/zephyr/projects/corsola/interrupts_kingler.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/projects/corsola/interrupts_krabby.dts b/zephyr/projects/corsola/interrupts_krabby.dts index 900ce1611e..7f2df00937 100644 --- a/zephyr/projects/corsola/interrupts_krabby.dts +++ b/zephyr/projects/corsola/interrupts_krabby.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/projects/corsola/interrupts_magikarp.dts b/zephyr/projects/corsola/interrupts_magikarp.dts new file mode 100644 index 0000000000..06458e1063 --- /dev/null +++ b/zephyr/projects/corsola/interrupts_magikarp.dts @@ -0,0 +1,105 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + int-wp = &int_wp; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&power_button_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&volume_up_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&volume_down_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "button_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&lid_open>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "lid_interrupt"; + }; + int_warm_rst: warm_rst { + irq-pin = <&ap_ec_warm_rst_req>; + flags = <GPIO_INT_EDGE_RISING>; + handler = "chipset_reset_request_interrupt"; + }; + int_ap_in_sleep: ap_in_sleep { + irq-pin = <&ap_in_sleep_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_signal_interrupt"; + }; + int_ap_in_rst: ap_in_rst { + irq-pin = <&ap_sysrst_odl_r>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_signal_interrupt"; + }; + int_ap_wdtrst: ap_wdtrst { + irq-pin = <&ap_ec_wdtrst_l>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "chipset_watchdog_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&tablet_mode_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "gmr_tablet_switch_isr"; + }; + int_base_imu: base_imu { + irq-pin = <&base_imu_int_l>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "motion_interrupt"; + }; + int_lid_imu: lid_imu { + irq-pin = <&lid_accel_int_l>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "lis2dw12_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&ac_present>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "extpower_interrupt"; + }; + int_usba: usba { + irq-pin = <&gpio_ap_xhci_init_done>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "usb_a0_interrupt"; + }; + int_wp: wp { + irq-pin = <&ec_flash_wp_odl>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "switch_interrupt"; + }; + int_spi0_cs: spi0_cs { + irq-pin = <&spi0_cs>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "spi_event"; + }; + int_x_ec_gpio2: x_ec_gpio2 { + irq-pin = <&gpio_x_ec_gpio2>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "x_ec_interrupt"; + }; + int_usb_c0_ppc_bc12: usb_c0_ppc_bc12 { + irq-pin = <&usb_c0_ppc_bc12_int_odl>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "c0_bc12_interrupt"; + }; + int_usb_c1_bc12_charger: usb_c1_bc12_charger { + irq-pin = <&usb_c1_bc12_charger_int_odl>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "rt9490_bc12_dt_interrupt"; + }; + }; +}; diff --git a/zephyr/projects/corsola/interrupts_tentacruel.dts b/zephyr/projects/corsola/interrupts_tentacruel.dts new file mode 100644 index 0000000000..c35461304e --- /dev/null +++ b/zephyr/projects/corsola/interrupts_tentacruel.dts @@ -0,0 +1,110 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + aliases { + int-wp = &int_wp; + }; + + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-pin = <&power_button_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-pin = <&volume_up_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-pin = <&volume_down_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "button_interrupt"; + }; + int_lid_open: lid_open { + irq-pin = <&lid_open>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "lid_interrupt"; + }; + int_warm_rst: warm_rst { + irq-pin = <&ap_ec_warm_rst_req>; + flags = <GPIO_INT_EDGE_RISING>; + handler = "chipset_reset_request_interrupt"; + }; + int_ap_in_sleep: ap_in_sleep { + irq-pin = <&ap_in_sleep_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_signal_interrupt"; + }; + int_ap_in_rst: ap_in_rst { + irq-pin = <&ap_sysrst_odl_r>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_signal_interrupt"; + }; + int_ap_wdtrst: ap_wdtrst { + irq-pin = <&ap_ec_wdtrst_l>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "chipset_watchdog_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-pin = <&tablet_mode_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "gmr_tablet_switch_isr"; + }; + int_base_imu: base_imu { + irq-pin = <&base_imu_int_l>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "motion_interrupt"; + }; + int_lid_imu: lid_imu { + irq-pin = <&lid_accel_int_l>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "lis2dw12_interrupt"; + }; + int_ac_present: ac_present { + irq-pin = <&ac_present>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "extpower_interrupt"; + }; + int_usba: usba { + irq-pin = <&gpio_ap_xhci_init_done>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "usb_a0_interrupt"; + }; + int_wp: wp { + irq-pin = <&ec_flash_wp_odl>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "switch_interrupt"; + }; + int_spi0_cs: spi0_cs { + irq-pin = <&spi0_cs>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "spi_event"; + }; + int_x_ec_gpio2: x_ec_gpio2 { + irq-pin = <&gpio_x_ec_gpio2>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "x_ec_interrupt"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-pin = <&usb_c0_ppc_int_odl>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-pin = <&usb_c0_bc12_int_odl>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "bc12_interrupt"; + }; + int_usb_c1_bc12_charger: usb_c1_bc12_charger { + irq-pin = <&usb_c1_bc12_charger_int_odl>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "rt9490_bc12_dt_interrupt"; + }; + }; +}; diff --git a/zephyr/projects/corsola/keyboard_steelix.dts b/zephyr/projects/corsola/keyboard_steelix.dts new file mode 100644 index 0000000000..9a0dca3e05 --- /dev/null +++ b/zephyr/projects/corsola/keyboard_steelix.dts @@ -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. + */ + +/ { + cros-keyscan { + compatible = "cros-keyscan"; + + debounce-down = <15000>; + debounce-up = <15000>; + + actual-key-mask = < + 0x1c /* C0 */ + 0xff /* C1 */ + 0xff /* C2 */ + 0xff /* C3 */ + 0xff /* C4 */ + 0xf5 /* C5 */ + 0xff /* C6 */ + 0xa4 /* C7 */ + 0xff /* C8 */ + 0xfe /* C9 */ + 0x55 /* C10 */ + 0xfa /* C11 */ + 0xca /* C12 */ + >; + }; +}; diff --git a/zephyr/projects/corsola/led_it81202_base.dtsi b/zephyr/projects/corsola/led_it81202_base.dtsi new file mode 100644 index 0000000000..dce7bb4f95 --- /dev/null +++ b/zephyr/projects/corsola/led_it81202_base.dtsi @@ -0,0 +1,184 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include <dt-bindings/battery.h> + +/ { + led_colors: led-colors { + compatible = "cros-ec,led-policy"; + + bat-power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + + color-0 { + led-color = <&color_battery_amber>; + }; + }; + + bat-power-state-near-full { + charge-state = "PWR_STATE_CHARGE_NEAR_FULL"; + + color-0 { + led-color = <&color_battery_white>; + }; + }; + + bat-power-state-discharge { + charge-state = "PWR_STATE_DISCHARGE"; + + color-0 { + led-color = <&color_battery_off>; + }; + }; + + bat-power-state-discharge-s0-bat-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + batt-lvl = <BATTERY_LEVEL_EMPTY BATTERY_LEVEL_LOW>; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-error { + charge-state = "PWR_STATE_ERROR"; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <1000>; + }; + }; + + pwr-power-state-off { + color-0 { + led-color = <&color_power_off>; + }; + }; + + pwr-power-state-on { + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_power_white>; + }; + }; + + pwr-power-state-s3 { + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_power_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_power_off>; + period-ms = <3000>; + }; + }; + }; + + pwmleds { + compatible = "cros-ec,pwm-pin-config"; + + /* NOTE: &pwm number needs same with channel number */ + led_power_white: ec_led1_odl { + #led-pin-cells = <1>; + pwms = <&pwm0 + PWM_CHANNEL_0 + PWM_HZ(324) + PWM_POLARITY_INVERTED>; + }; + led_battery_amber: ec_led2_odl { + #led-pin-cells = <1>; + pwms = <&pwm1 + PWM_CHANNEL_1 + PWM_HZ(324) + PWM_POLARITY_INVERTED>; + }; + led_battery_white: ec_led3_odl { + #led-pin-cells = <1>; + pwms = <&pwm2 + PWM_CHANNEL_2 + PWM_HZ(324) + PWM_POLARITY_INVERTED>; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + color_power_off: color-power-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&led_power_white 0>; + }; + + color_power_white: color-power-white { + led-color = "LED_WHITE"; + br-color = "EC_LED_COLOR_WHITE"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&led_power_white 100>; + }; + + color_battery_off: color-battery-off { + led-color = "LED_OFF"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&led_battery_amber 0>, + <&led_battery_white 0>; + }; + + color_battery_amber: color-battery-amber { + led-color = "LED_AMBER"; + br-color = "EC_LED_COLOR_AMBER"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&led_battery_amber 100>, + <&led_battery_white 0>; + }; + + color_battery_white: color-battery-white { + led-color = "LED_WHITE"; + br-color = "EC_LED_COLOR_WHITE"; + led-id = "EC_LED_ID_BATTERY_LED"; + led-pins = <&led_battery_amber 0>, + <&led_battery_white 100>; + }; + }; +}; + +/* LED1 */ +&pwm0 { + status = "okay"; + prescaler-cx = <PWM_PRESCALER_C4>; + pinctrl-0 = <&pwm0_gpa0_default>; + pinctrl-names = "default"; +}; + +/* LED2 */ +&pwm1 { + status = "okay"; + prescaler-cx = <PWM_PRESCALER_C4>; + pinctrl-0 = <&pwm1_gpa1_default>; + pinctrl-names = "default"; +}; + +/* LED3 */ +&pwm2 { + status = "okay"; + prescaler-cx = <PWM_PRESCALER_C4>; + pinctrl-0 = <&pwm2_gpa2_default>; + pinctrl-names = "default"; +}; diff --git a/zephyr/projects/corsola/led_kingler.dts b/zephyr/projects/corsola/led_kingler.dts index 56a54862e6..92f6c4d4fe 100644 --- a/zephyr/projects/corsola/led_kingler.dts +++ b/zephyr/projects/corsola/led_kingler.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -17,7 +17,6 @@ compatible = "cros-ec,pwm-leds"; leds = <&pwm_led0>; - frequency = <100>; color-map-red = <100 0 0>; color-map-green = < 0 100 0>; diff --git a/zephyr/projects/corsola/led_krabby.dts b/zephyr/projects/corsola/led_krabby.dts index 9ee879b404..b16bff3cac 100644 --- a/zephyr/projects/corsola/led_krabby.dts +++ b/zephyr/projects/corsola/led_krabby.dts @@ -1,44 +1,5 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ - -/ { - pwmleds { - compatible = "pwm-leds"; - /* NOTE: &pwm number needs same with channel number */ - led_power_white: ec_led1_odl { - pwms = <&pwm0 PWM_CHANNEL_0 PWM_HZ(324) PWM_POLARITY_INVERTED>; - }; - led_battery_amber: ec_led2_odl { - pwms = <&pwm1 PWM_CHANNEL_1 PWM_HZ(324) PWM_POLARITY_INVERTED>; - }; - led_battery_white: ec_led3_odl { - pwms = <&pwm2 PWM_CHANNEL_2 PWM_HZ(324) PWM_POLARITY_INVERTED>; - }; - }; -}; - -/* LED1 */ -&pwm0 { - status = "okay"; - prescaler-cx = <PWM_PRESCALER_C4>; - pinctrl-0 = <&pwm0_gpa0_default>; - pinctrl-names = "default"; -}; - -/* LED2 */ -&pwm1 { - status = "okay"; - prescaler-cx = <PWM_PRESCALER_C4>; - pinctrl-0 = <&pwm1_gpa1_default>; - pinctrl-names = "default"; -}; - -/* LED3 */ -&pwm2 { - status = "okay"; - prescaler-cx = <PWM_PRESCALER_C4>; - pinctrl-0 = <&pwm2_gpa2_default>; - pinctrl-names = "default"; -}; +#include "led_it81202_base.dtsi" diff --git a/zephyr/projects/corsola/led_magikarp.dts b/zephyr/projects/corsola/led_magikarp.dts new file mode 100644 index 0000000000..0e2b0aca52 --- /dev/null +++ b/zephyr/projects/corsola/led_magikarp.dts @@ -0,0 +1,136 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "led_it81202_base.dtsi" + +/ { + led_colors: led-colors { + compatible = "cros-ec,led-policy"; + + /* Magikarp LED bat charge */ + bat-power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= Empty, <= 94%) */ + batt-lvl = <BATTERY_LEVEL_EMPTY + (BATTERY_LEVEL_NEAR_FULL - 3)>; + color-0 { + led-color = <&color_battery_amber>; + }; + }; + + bat-power-state-charge-near-full { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= 95%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2) + BATTERY_LEVEL_FULL>; + color-0 { + led-color = <&color_battery_white>; + }; + }; + + /* Magikarp LED bat discharge */ + bat-power-state-discharge-s0 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= 11%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_battery_white>; + }; + }; + + + bat-power-state-discharge-s0-bat-low { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= Empty, <= 10%) */ + batt-lvl = <BATTERY_LEVEL_EMPTY BATTERY_LEVEL_LOW>; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + color-0 { + led-color = <&color_battery_off>; + }; + }; + + /* Magikarp LED bat error */ + bat-power-state-error { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <1000>; + }; + }; + + bat-power-state-error-s3 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-error-s5 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_battery_off>; + }; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + /* Overwrite Power LED white to off */ + color_power_white: color-power-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&led_power_white 0>; + }; + }; +}; diff --git a/zephyr/projects/corsola/led_steelix.dts b/zephyr/projects/corsola/led_steelix.dts index 31d17958d4..6a25929327 100644 --- a/zephyr/projects/corsola/led_steelix.dts +++ b/zephyr/projects/corsola/led_steelix.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/projects/corsola/led_tentacruel.dts b/zephyr/projects/corsola/led_tentacruel.dts new file mode 100644 index 0000000000..5569a956f6 --- /dev/null +++ b/zephyr/projects/corsola/led_tentacruel.dts @@ -0,0 +1,118 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ +#include "led_it81202_base.dtsi" + +/ { + led_colors: led-colors { + compatible = "cros-ec,led-policy"; + + /* Tentacruel LED bat charge */ + bat-power-state-charge { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= Empty, <= 94%) */ + batt-lvl = <BATTERY_LEVEL_EMPTY + (BATTERY_LEVEL_NEAR_FULL - 3)>; + color-0 { + led-color = <&color_battery_amber>; + }; + }; + + bat-power-state-charge-near-full { + charge-state = "PWR_STATE_CHARGE"; + /* Battery percent range (>= 95%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_NEAR_FULL - 2) + BATTERY_LEVEL_FULL>; + color-0 { + led-color = <&color_battery_white>; + }; + }; + + /* Tentacruel LED bat discharge */ + bat-power-state-discharge { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S0"; + /* Battery percent range (>= 11%, <= Full) */ + batt-lvl = <(BATTERY_LEVEL_LOW + 1) BATTERY_LEVEL_FULL>; + + color-0 { + led-color = <&color_battery_white>; + }; + }; + + bat-power-state-discharge-s3 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-discharge-s5 { + charge-state = "PWR_STATE_DISCHARGE"; + chipset-state = "POWER_S5"; + color-0 { + led-color = <&color_battery_off>; + }; + }; + + /* Tentacruel LED bat error */ + bat-power-state-error { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S0"; + + color-0 { + led-color = <&color_battery_amber>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <1000>; + }; + }; + + bat-power-state-error-s3 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S3"; + + color-0 { + led-color = <&color_battery_white>; + period-ms = <1000>; + }; + + color-1 { + led-color = <&color_battery_off>; + period-ms = <3000>; + }; + }; + + bat-power-state-error-s5 { + charge-state = "PWR_STATE_ERROR"; + chipset-state = "POWER_S5"; + + color-0 { + led-color = <&color_battery_off>; + }; + }; + }; + + pwm-led-pins { + compatible = "cros-ec,pwm-led-pins"; + + /* Overwrite Power LED white to off */ + color_power_white: color-power-white { + led-color = "LED_WHITE"; + led-id = "EC_LED_ID_POWER_LED"; + led-pins = <&led_power_white 0>; + }; + }; +}; diff --git a/zephyr/projects/corsola/motionsense_kingler.dts b/zephyr/projects/corsola/motionsense_kingler.dts index 4667635da0..a7f674e01f 100644 --- a/zephyr/projects/corsola/motionsense_kingler.dts +++ b/zephyr/projects/corsola/motionsense_kingler.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -29,10 +29,8 @@ motionsense-mutex { compatible = "cros-ec,motionsense-mutex"; lid_mutex: lid-mutex { - label = "LID_MUTEX"; }; base_mutex: base-mutex { - label = "BASE_MUTEX"; }; }; @@ -73,7 +71,7 @@ /* * List of motion sensors that creates motion_sensors array. - * The label "lid_accel" and "base_accel" are used to indicate + * The nodelabel "lid_accel" and "base_accel" are used to indicate * motion sensor IDs for lid angle calculation. */ motionsense-sensor { @@ -81,7 +79,6 @@ compatible = "cros-ec,bma4xx"; status = "okay"; - label = "Lid Accel"; active-mask = "SENSOR_ACTIVE_S0_S3"; location = "MOTIONSENSE_LOC_LID"; mutex = <&lid_mutex>; @@ -93,11 +90,9 @@ compatible = "cros-ec,motionsense-sensor-config"; ec-s0 { - label = "SENSOR_CONFIG_EC_S0"; odr = <(12500 | ROUND_UP_FLAG)>; }; ec-s3 { - label = "SENSOR_CONFIG_EC_S3"; odr = <(12500 | ROUND_UP_FLAG)>; }; }; @@ -107,7 +102,6 @@ compatible = "cros-ec,bmi3xx-accel"; status = "okay"; - label = "Base Accel"; active-mask = "SENSOR_ACTIVE_S0_S3"; location = "MOTIONSENSE_LOC_BASE"; mutex = <&base_mutex>; @@ -118,12 +112,10 @@ compatible = "cros-ec,motionsense-sensor-config"; ec-s0 { - label = "SENSOR_CONFIG_EC_S0"; odr = <(12500 | ROUND_UP_FLAG)>; ec-rate = <(100 * USEC_PER_MSEC)>; }; ec-s3 { - label = "SENSOR_CONFIG_EC_S3"; odr = <(12500 | ROUND_UP_FLAG)>; ec-rate = <0>; }; @@ -134,7 +126,6 @@ compatible = "cros-ec,bmi3xx-gyro"; status = "okay"; - label = "Base Gyro"; active-mask = "SENSOR_ACTIVE_S0_S3"; location = "MOTIONSENSE_LOC_BASE"; mutex = <&base_mutex>; diff --git a/zephyr/projects/corsola/motionsense_krabby.dts b/zephyr/projects/corsola/motionsense_krabby.dts index d369db460a..1c7d5b2df4 100644 --- a/zephyr/projects/corsola/motionsense_krabby.dts +++ b/zephyr/projects/corsola/motionsense_krabby.dts @@ -1,4 +1,4 @@ -/* Copyright 2020 The Chromium OS Authors. All rights reserved. +/* Copyright 2020 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -27,11 +27,9 @@ motionsense-mutex { compatible = "cros-ec,motionsense-mutex"; lid_mutex: lid-mutex { - label = "LID_MUTEX"; }; base_mutex: icm42607-mutex { - label = "ICM42607_MUTEX"; }; }; @@ -74,7 +72,7 @@ /* * List of motion sensors that creates motion_sensors array. - * The label "lid_accel" and "base_accel" are used to indicate + * The nodelabel "lid_accel" and "base_accel" are used to indicate * motion sensor IDs for lid angle calculation. */ motionsense-sensor { @@ -82,7 +80,6 @@ compatible = "cros-ec,lis2dw12"; status = "okay"; - label = "Lid Accel"; active-mask = "SENSOR_ACTIVE_S0_S3"; location = "MOTIONSENSE_LOC_LID"; mutex = <&lid_mutex>; @@ -94,11 +91,9 @@ compatible = "cros-ec,motionsense-sensor-config"; ec-s0 { - label = "SENSOR_CONFIG_EC_S0"; odr = <(10000 | ROUND_UP_FLAG)>; }; ec-s3 { - label = "SENSOR_CONFIG_EC_S3"; odr = <(10000 | ROUND_UP_FLAG)>; }; }; @@ -108,7 +103,6 @@ compatible = "cros-ec,icm42607-accel"; status = "okay"; - label = "Base Accel"; active-mask = "SENSOR_ACTIVE_S0_S3"; location = "MOTIONSENSE_LOC_BASE"; mutex = <&base_mutex>; @@ -119,11 +113,9 @@ compatible = "cros-ec,motionsense-sensor-config"; ec-s0 { - label = "SENSOR_CONFIG_EC_S0"; odr = <(10000 | ROUND_UP_FLAG)>; }; ec-s3 { - label = "SENSOR_CONFIG_EC_S3"; odr = <(10000 | ROUND_UP_FLAG)>; }; }; @@ -133,7 +125,6 @@ compatible = "cros-ec,icm42607-gyro"; status = "okay"; - label = "Base Gyro"; active-mask = "SENSOR_ACTIVE_S0_S3"; location = "MOTIONSENSE_LOC_BASE"; mutex = <&base_mutex>; diff --git a/zephyr/projects/corsola/motionsense_magikarp.dts b/zephyr/projects/corsola/motionsense_magikarp.dts new file mode 100644 index 0000000000..92e73bd2c6 --- /dev/null +++ b/zephyr/projects/corsola/motionsense_magikarp.dts @@ -0,0 +1,199 @@ +/* Copyright 2020 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <dt-bindings/motionsense/utils.h> + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + icm42607-int = &base_accel; + lis2dw12-int = &lid_accel; + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: icm42607-mutex { + }; + + base_mutex_bmi323: bmi323-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 (-1)>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref_bmi: base-rotation-ref-bmi { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + icm42607_data: icm42607-drv-data { + compatible = "cros-ec,drvdata-icm42607"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + + bmi323_data: bmi323-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,icm42607-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,icm42607-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + }; + }; + + 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 = <&base_mutex_bmi323>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_accel>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_gyro: alt-base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_gyro>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_base_imu &int_lid_imu>; + }; +}; diff --git a/zephyr/projects/corsola/motionsense_steelix.dts b/zephyr/projects/corsola/motionsense_steelix.dts index 70aa3679fb..c8cbc95e48 100644 --- a/zephyr/projects/corsola/motionsense_steelix.dts +++ b/zephyr/projects/corsola/motionsense_steelix.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/projects/corsola/motionsense_tentacruel.dts b/zephyr/projects/corsola/motionsense_tentacruel.dts new file mode 100644 index 0000000000..68b2c023df --- /dev/null +++ b/zephyr/projects/corsola/motionsense_tentacruel.dts @@ -0,0 +1,199 @@ +/* Copyright 2020 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include <dt-bindings/motionsense/utils.h> + + +/ { + aliases { + /* + * motion sense's <>_INT_EVENT is handled + * by alias. Using the alias, each driver creates + * its own <>_INT_EVENT. + */ + icm42607-int = &base_accel; + lis2dw12-int = &lid_accel; + bmi3xx-int = &base_accel; + }; + + /* + * Declare mutexes used by sensor drivers. + * A mutex node is used to create an instance of mutex_t. + * A mutex node is referenced by a sensor node if the + * corresponding sensor driver needs to use the + * instance of the mutex. + */ + motionsense-mutex { + compatible = "cros-ec,motionsense-mutex"; + lid_mutex: lid-mutex { + }; + + base_mutex: icm42607-mutex { + }; + + base_mutex_bmi323: bmi323-mutex { + }; + }; + + /* Rotation matrix used by drivers. */ + motionsense-rotation-ref { + compatible = "cros-ec,motionsense-rotation-ref"; + lid_rot_ref: lid-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref: base-rotation-ref { + mat33 = <1 0 0 + 0 1 0 + 0 0 1>; + }; + + base_rot_ref_bmi: base-rotation-ref-bmi { + mat33 = <0 1 0 + (-1) 0 0 + 0 0 1>; + }; + }; + + /* + * Driver specific data. A driver-specific data can be shared with + * different motion sensors while they are using the same driver. + * + * If a node's compatible starts with "cros-ec,accelgyro-", it is for + * a common structure defined in accelgyro.h. + * e.g) compatible = "cros-ec,accelgyro-als-drv-data" is for + * "struct als_drv_data_t" in accelgyro.h + */ + motionsense-sensor-data { + icm42607_data: icm42607-drv-data { + compatible = "cros-ec,drvdata-icm42607"; + status = "okay"; + }; + + lis2dw12_data: lis2dw12-drv-data { + compatible = "cros-ec,drvdata-lis2dw12"; + status = "okay"; + }; + + bmi323_data: bmi323-drv-data { + compatible = "cros-ec,drvdata-bmi3xx"; + status = "okay"; + }; + }; + + /* + * List of motion sensors that creates motion_sensors array. + * The nodelabel "lid_accel" and "base_accel" are used to indicate + * motion sensor IDs for lid angle calculation. + */ + motionsense-sensor { + lid_accel: lid-accel { + compatible = "cros-ec,lis2dw12"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_LID"; + mutex = <&lid_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&lid_rot_ref>; + default-range = <2>; + drv-data = <&lis2dw12_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_accel: base-accel { + compatible = "cros-ec,icm42607-accel"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + base_gyro: base-gyro { + compatible = "cros-ec,icm42607-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref>; + drv-data = <&icm42607_data>; + }; + }; + + 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 = <&base_mutex_bmi323>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_accel>; + configs { + compatible = + "cros-ec,motionsense-sensor-config"; + ec-s0 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + ec-s3 { + odr = <(10000 | ROUND_UP_FLAG)>; + }; + }; + }; + + alt_base_gyro: alt-base-gyro { + compatible = "cros-ec,bmi3xx-gyro"; + status = "okay"; + + active-mask = "SENSOR_ACTIVE_S0_S3"; + location = "MOTIONSENSE_LOC_BASE"; + mutex = <&base_mutex_bmi323>; + port = <&i2c_sensor>; + rot-standard-ref = <&base_rot_ref_bmi>; + drv-data = <&bmi323_data>; + alternate-for = <&base_gyro>; + }; + }; + + motionsense-sensor-info { + compatible = "cros-ec,motionsense-sensor-info"; + + /* + * list of GPIO interrupts that have to + * be enabled at initial stage + */ + sensor-irqs = <&int_base_imu &int_lid_imu>; + }; +}; diff --git a/zephyr/projects/corsola/npcx_keyboard.dts b/zephyr/projects/corsola/npcx_keyboard.dts index d3fd354b8f..f9e46de1f2 100644 --- a/zephyr/projects/corsola/npcx_keyboard.dts +++ b/zephyr/projects/corsola/npcx_keyboard.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/projects/corsola/power_signal.dts b/zephyr/projects/corsola/power_signal.dts index 2603a53bb4..181d7cf96e 100644 --- a/zephyr/projects/corsola/power_signal.dts +++ b/zephyr/projects/corsola/power_signal.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/projects/corsola/prj.conf b/zephyr/projects/corsola/prj.conf index b26c01461e..110b91bbbb 100644 --- a/zephyr/projects/corsola/prj.conf +++ b/zephyr/projects/corsola/prj.conf @@ -1,4 +1,4 @@ -# Copyright 2021 The Chromium OS Authors. All rights reserved. +# 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. # @@ -6,6 +6,33 @@ # http://google3/hardware/standards/usb/ CONFIG_PLATFORM_EC_USB_PID=0x505C +# CROS EC +CONFIG_CROS_EC=y +CONFIG_PLATFORM_EC=y +CONFIG_PLATFORM_EC_SWITCH=y +CONFIG_SHIMMED_TASKS=y + +# AP SoC configuration +CONFIG_AP=y +CONFIG_AP_ARM_MTK_MT8186=y + +# Variant config +CONFIG_VARIANT_CORSOLA_DB_DETECTION=y + +# Shell features +CONFIG_KERNEL_SHELL=y +CONFIG_SHELL_HELP=y +CONFIG_SHELL_HISTORY=y +CONFIG_SHELL_TAB=y +CONFIG_SHELL_TAB_AUTOCOMPLETION=y + +# CBI +CONFIG_EEPROM=y +CONFIG_EEPROM_AT24=y +CONFIG_EEPROM_SHELL=n +CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y +CONFIG_PLATFORM_EC_CBI_EEPROM=y + # I2C CONFIG_I2C=y @@ -24,14 +51,51 @@ CONFIG_PLATFORM_EC_VBOOT_EFS2=y # USB CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n +CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n CONFIG_PLATFORM_EC_USB_PD_USB4=n -# TODO(b/226411332): fix single task USB_CHG for Corsola -CONFIG_PLATFORM_EC_USB_CHARGER_SINGLE_TASK=n +CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB_CUSTOM_HOOK=y + +# USB-C +CONFIG_PLATFORM_EC_USBC=y +CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y +CONFIG_PLATFORM_EC_USB_PD_DPS=y +CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y +CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO_CUSTOM=y +CONFIG_PLATFORM_EC_USB_PD_FRS=y # Power Seq CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK=y +CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y +CONFIG_PLATFORM_EC_POWERSEQ=y CONFIG_PLATFORM_EC_POWERSEQ_HOST_SLEEP=y +CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n CONFIG_PLATFORM_EC_POWER_SLEEP_FAILURE_DETECTION=y # Optional features CONFIG_FLASH_SHELL=n + +# EEPROM +CONFIG_PLATFORM_EC_EEPROM_CBI_WP=y + +# Host Commands +CONFIG_PLATFORM_EC_HOSTCMD=y + +# Battery +CONFIG_PLATFORM_EC_BATTERY=y +CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y +CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y +CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y +CONFIG_PLATFORM_EC_BATTERY_SMART=y +CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV=9000 +CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y +CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y + +# Charger +CONFIG_PLATFORM_EC_BC12_CLIENT_MODE_ONLY_PI3USB9201=y +CONFIG_PLATFORM_EC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGE_MANAGER=y + +# Button +CONFIG_PLATFORM_EC_CMD_BUTTON=y +CONFIG_PLATFORM_EC_POWER_BUTTON=y +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y diff --git a/zephyr/projects/corsola/prj_it81202_base.conf b/zephyr/projects/corsola/prj_it81202_base.conf new file mode 100644 index 0000000000..38e0acd7a8 --- /dev/null +++ b/zephyr/projects/corsola/prj_it81202_base.conf @@ -0,0 +1,92 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Bring up options +CONFIG_SHELL_HISTORY_BUFFER=256 +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y +CONFIG_PLATFORM_EC_BRINGUP=y + +# Power Sequencing +CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y + +# Lid Switch +CONFIG_PLATFORM_EC_LID_SWITCH=y + +# Charger +CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y +CONFIG_PLATFORM_EC_CHARGER_RT9490=y +CONFIG_PLATFORM_EC_CHARGER_MAINTAIN_VBAT=y +CONFIG_PLATFORM_EC_CHARGER_OTG=y +CONFIG_PLATFORM_EC_CHARGER_PSYS=y +CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y +# BOARD_RS2 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +# BOARD_RS1 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y + +# Host Commands +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y +CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y + +# LED +CONFIG_PLATFORM_EC_LED_DT=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +# Sensors +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y +CONFIG_PLATFORM_EC_MAX_SENSOR_FREQ_MILLIHZ=100000 + +# Sensor Drivers +CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y +CONFIG_PLATFORM_EC_ACCELGYRO_ICM42607=y +CONFIG_PLATFORM_EC_ACCELGYRO_ICM_COMM_I2C=y + +# Tasks +CONFIG_TASK_CHARGER_STACK_SIZE=1024 +CONFIG_TASK_CHIPSET_STACK_SIZE=1440 +CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1024 +CONFIG_TASK_PD_STACK_SIZE=1280 + +# USB-A +CONFIG_PLATFORM_EC_USBA=y + +# USB-C +CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n +CONFIG_PLATFORM_EC_SMBUS_PEC=y +CONFIG_PLATFORM_EC_USBC_PPC_DEDICATED_INT=y +CONFIG_PLATFORM_EC_USBC_PPC_RT1739=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y +CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y +CONFIG_PLATFORM_EC_USB_MUX_IT5205=y +CONFIG_PLATFORM_EC_USB_MUX_TUSB546=y +CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y +CONFIG_PLATFORM_EC_USB_PD_LOGGING=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT=y +CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n + +# TODO(b/180980668): bring these features up +CONFIG_LTO=n +CONFIG_PLATFORM_EC_BACKLIGHT_LID=n diff --git a/zephyr/projects/corsola/prj_kingler.conf b/zephyr/projects/corsola/prj_kingler.conf index 525d94a886..d7de991e93 100644 --- a/zephyr/projects/corsola/prj_kingler.conf +++ b/zephyr/projects/corsola/prj_kingler.conf @@ -1,139 +1,12 @@ -# Copyright 2021 The Chromium OS Authors. All rights reserved. +# Copyright 2021 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. -# Cros EC -CONFIG_CROS_EC=y -CONFIG_PLATFORM_EC=y -CONFIG_PLATFORM_EC_BRINGUP=y -CONFIG_SHIMMED_TASKS=y -CONFIG_PLATFORM_EC_SWITCH=y - # Variant config CONFIG_BOARD_KINGLER=y -CONFIG_VARIANT_CORSOLA_DB_DETECTION=y - -# Shell features -CONFIG_KERNEL_SHELL=y -CONFIG_SHELL_HELP=y -CONFIG_SHELL_TAB=y -CONFIG_SHELL_TAB_AUTOCOMPLETION=y -CONFIG_SHELL_HISTORY=y - -# Bring up options -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y - -# ADC -CONFIG_ADC=y -CONFIG_PLATFORM_EC_ADC=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y -CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y - -# CBI -CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y -CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y -CONFIG_PLATFORM_EC_CBI_EEPROM=y - -# Charger -CONFIG_PLATFORM_EC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y -CONFIG_PLATFORM_EC_CHARGER_PSYS=y -CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CHARGE_MANAGER=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y - -# Host command -CONFIG_PLATFORM_EC_HOSTCMD=y - -# PWM -CONFIG_PWM=y -CONFIG_PWM_SHELL=n # LED -CONFIG_PLATFORM_EC_LED_COMMON=y -CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y CONFIG_PLATFORM_EC_LED_PWM=y -# Math -CONFIG_PLATFORM_EC_MATH_UTIL=y - -# Power sequencing -CONFIG_AP=y -CONFIG_AP_ARM_MTK_MT8186=y -CONFIG_PLATFORM_EC_POWERSEQ_MT8186=y -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWERSEQ_S4=n -CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n - -# Button -CONFIG_PLATFORM_EC_POWER_BUTTON=y -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y -CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y - -# Sensors -CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y -CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y -CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_LID_SWITCH=y -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y - -# USBA -CONFIG_PLATFORM_EC_USBA=y - -# USBC -CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y -CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n -CONFIG_PLATFORM_EC_USBC=y -CONFIG_PLATFORM_EC_USBC_PPC=y -CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y -CONFIG_PLATFORM_EC_USBC_PPC_RT1718S=y -CONFIG_PLATFORM_EC_USBC_SS_MUX_DFP_ONLY=y -CONFIG_PLATFORM_EC_USB_MUX_PS8743=y -CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y -CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y -CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO_CUSTOM=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=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_DEBUG_FIXED_LEVEL=y -CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=2 -CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_BY_BOARD=y - -# External power -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y - # Keyboard -CONFIG_CROS_KB_RAW_NPCX=y -CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y - -CONFIG_SYSCON=y - -CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y diff --git a/zephyr/projects/corsola/prj_krabby.conf b/zephyr/projects/corsola/prj_krabby.conf index 741f07b436..c4cde05c16 100644 --- a/zephyr/projects/corsola/prj_krabby.conf +++ b/zephyr/projects/corsola/prj_krabby.conf @@ -1,140 +1,9 @@ -# Copyright 2021 The Chromium OS Authors. All rights reserved. +# 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 - +# Variant config CONFIG_BOARD_KRABBY=y -# AP SoC configuration -CONFIG_AP=y -CONFIG_AP_ARM_MTK_MT8186=y - -# Bring up options -CONFIG_KERNEL_SHELL=y -CONFIG_SHELL_HISTORY_BUFFER=256 -CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y -CONFIG_PLATFORM_EC_BRINGUP=y - -# VARIANT config -CONFIG_VARIANT_CORSOLA_DB_DETECTION=y - -# CBI -CONFIG_EEPROM=y -CONFIG_EEPROM_AT24=y -CONFIG_EEPROM_SHELL=n -CONFIG_PLATFORM_EC_BOARD_VERSION_CBI=y -CONFIG_PLATFORM_EC_CBI_EEPROM=y - -# Power Sequencing -CONFIG_PLATFORM_EC_POWERSEQ=y -CONFIG_PLATFORM_EC_POWERSEQ_PP5000_CONTROL=n -CONFIG_PLATFORM_EC_EXTPOWER_GPIO=y -CONFIG_PLATFORM_EC_CHIPSET_RESET_HOOK=y - -# Lid Switch -CONFIG_PLATFORM_EC_LID_SWITCH=y - -# Battery -CONFIG_PLATFORM_EC_BATTERY=y -CONFIG_PLATFORM_EC_BATTERY_CUT_OFF=y -CONFIG_PLATFORM_EC_BATTERY_FUEL_GAUGE=y -CONFIG_PLATFORM_EC_BATTERY_PRESENT_GPIO=y -CONFIG_PLATFORM_EC_BATTERY_SMART=y -CONFIG_PLATFORM_EC_BATT_FULL_CHIPSET_OFF_INPUT_LIMIT_MV=9000 -CONFIG_PLATFORM_EC_I2C_PASSTHRU_RESTRICTED=y -CONFIG_PLATFORM_EC_I2C_VIRTUAL_BATTERY=y - -# Charger -CONFIG_PLATFORM_EC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGE_MANAGER=y -CONFIG_PLATFORM_EC_CHARGE_RAMP_HW=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y -CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC_CHARGER=y -CONFIG_PLATFORM_EC_CHARGER_RT9490=y -CONFIG_PLATFORM_EC_CHARGER_MAINTAIN_VBAT=y -CONFIG_PLATFORM_EC_CHARGER_OTG=y -CONFIG_PLATFORM_EC_CHARGER_PSYS=y -CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y -# BOARD_RS2 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 -# BOARD_RS1 -CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_DUMP=y - -# Host Commands -CONFIG_PLATFORM_EC_HOSTCMD=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y -CONFIG_PLATFORM_EC_CONSOLE_CMD_SYSINFO=y -CONFIG_PLATFORM_EC_HOST_COMMAND_STATUS=y - -# LED -CONFIG_PLATFORM_EC_LED_COMMON=y -CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y -CONFIG_PLATFORM_EC_LED_ONOFF_STATES_BAT_LOW=10 - # Keyboard -CONFIG_PLATFORM_EC_VOLUME_BUTTONS=y -CONFIG_PLATFORM_EC_CMD_BUTTON=y - -# Sensors -CONFIG_PLATFORM_EC_MOTIONSENSE=y -CONFIG_PLATFORM_EC_ACCEL_FIFO=y -CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y -CONFIG_PLATFORM_EC_LID_ANGLE=y -CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y -CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y -CONFIG_PLATFORM_EC_SWITCH=y -CONFIG_PLATFORM_EC_TABLET_MODE=y -CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y - -# Sensor Drivers -CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=y -CONFIG_PLATFORM_EC_ACCELGYRO_ICM42607=y -CONFIG_PLATFORM_EC_ACCELGYRO_ICM_COMM_I2C=y - -# Tasks -CONFIG_TASK_CHARGER_STACK_SIZE=1024 -CONFIG_TASK_CHIPSET_STACK_SIZE=1440 -CONFIG_TASK_MOTIONSENSE_STACK_SIZE=1024 -CONFIG_TASK_PD_STACK_SIZE=1280 - -# USB-A -CONFIG_PLATFORM_EC_USBA=y - -# USB-C -CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n -CONFIG_PLATFORM_EC_SMBUS_PEC=y -CONFIG_PLATFORM_EC_USBC=y -CONFIG_PLATFORM_EC_USBC_PPC_DEDICATED_INT=y -CONFIG_PLATFORM_EC_USBC_PPC_RT1739=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682C=y -CONFIG_PLATFORM_EC_USBC_PPC_SYV682X=y -CONFIG_PLATFORM_EC_USB_MUX_IT5205=y -CONFIG_PLATFORM_EC_USB_MUX_TUSB546=y -CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y -CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y -CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO=y -CONFIG_PLATFORM_EC_USB_PD_DP_HPD_GPIO_CUSTOM=y -CONFIG_PLATFORM_EC_USB_PD_FRS=y -CONFIG_PLATFORM_EC_USB_PD_FRS_PPC=y -CONFIG_PLATFORM_EC_USB_PD_ITE_ACTIVE_PORT_COUNT=2 -CONFIG_PLATFORM_EC_USB_PD_LOGGING=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_DRIVER_IT8XXX2=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_ITE_ON_CHIP=y -CONFIG_PLATFORM_EC_USB_PD_TCPM_TCPCI=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_PPC=y -CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_ADC_EACH_PORT=y -CONFIG_PLATFORM_EC_USB_PORT_POWER_DUMB_CUSTOM_HOOK=y -CONFIG_PLATFORM_EC_USB_PD_DUAL_ROLE_AUTO_TOGGLE=n -CONFIG_PLATFORM_EC_USB_PD_USB32_DRD=n -CONFIG_PLATFORM_EC_USB_PD_USB4=n -CONFIG_PLATFORM_EC_USB_PD_TBT_COMPAT_MODE=n - -# TODO(b/180980668): bring these features up -CONFIG_LTO=n -CONFIG_PLATFORM_EC_BACKLIGHT_LID=n +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI2=y diff --git a/zephyr/projects/corsola/prj_magikarp.conf b/zephyr/projects/corsola/prj_magikarp.conf new file mode 100644 index 0000000000..72d7ea59f7 --- /dev/null +++ b/zephyr/projects/corsola/prj_magikarp.conf @@ -0,0 +1,22 @@ +# Copyright 2022 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Variant config +CONFIG_BOARD_MAGIKARP=y + +# USB-C +CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n +CONFIG_PLATFORM_EC_USB_MUX_PS8743=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y + +# Sensor +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + +# Temperature sensors +CONFIG_PLATFORM_EC_TEMP_SENSOR=y +CONFIG_PLATFORM_EC_THERMISTOR=y diff --git a/zephyr/projects/corsola/prj_npcx993_base.conf b/zephyr/projects/corsola/prj_npcx993_base.conf new file mode 100644 index 0000000000..f3b220898e --- /dev/null +++ b/zephyr/projects/corsola/prj_npcx993_base.conf @@ -0,0 +1,95 @@ +# Copyright 2022 The ChromiumOS Authors. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + + +# Bring up options +CONFIG_PLATFORM_EC_SYSTEM_UNLOCKED=y + +# Debug options and features; can be disabled to save memory or once bringup +# is complete. +CONFIG_SHELL_MINIMAL=n +CONFIG_LOG=y +CONFIG_LOG_MODE_MINIMAL=y + +# ADC +CONFIG_ADC=y + +# Charger +CONFIG_PLATFORM_EC_CHARGER_DISCHARGE_ON_AC=y +CONFIG_PLATFORM_EC_CHARGER_ISL9238C=y +CONFIG_PLATFORM_EC_CHARGER_PSYS=y +CONFIG_PLATFORM_EC_CHARGER_PSYS_READ=y +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR=10 +CONFIG_PLATFORM_EC_CHARGER_SENSE_RESISTOR_AC=20 +CONFIG_PLATFORM_EC_CONSOLE_CMD_CHARGER_ADC_AMON_BMON=y + +# PWM +CONFIG_PWM=y +CONFIG_PWM_SHELL=n + +# LED +CONFIG_PLATFORM_EC_LED_COMMON=y +CONFIG_PLATFORM_EC_LED_ONOFF_STATES=y + +# Math +CONFIG_PLATFORM_EC_MATH_UTIL=y + +# Power sequencing +CONFIG_PLATFORM_EC_POWERSEQ_MT8186=y +CONFIG_PLATFORM_EC_POWERSEQ_S4=n + +# Button +CONFIG_PLATFORM_EC_BUTTONS_RUNTIME_CONFIG=y + +# Sensors +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y +CONFIG_PLATFORM_EC_ACCEL_BMA4XX=y +CONFIG_PLATFORM_EC_ACCEL_FIFO=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=y +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=y +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=y +CONFIG_PLATFORM_EC_LID_ANGLE=y +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=y +CONFIG_PLATFORM_EC_LID_SWITCH=y +CONFIG_PLATFORM_EC_MOTIONSENSE=y +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=y +CONFIG_PLATFORM_EC_TABLET_MODE=y +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=y + +# USBA +CONFIG_PLATFORM_EC_USBA=y + +# USBC +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_BC12_SINGLE_DRIVER=n +CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_OFF_DELAY=15000 +CONFIG_PLATFORM_EC_PD_POWER_SUPPLY_TURN_ON_DELAY=15000 +CONFIG_PLATFORM_EC_USBC_PPC=y +CONFIG_PLATFORM_EC_USBC_PPC_NX20P3483=y +CONFIG_PLATFORM_EC_USBC_PPC_RT1718S=y +CONFIG_PLATFORM_EC_USB_MUX_PS8743=y +CONFIG_PLATFORM_EC_USB_MUX_VIRTUAL=y +CONFIG_PLATFORM_EC_USB_PD_DISCHARGE_PPC=y +CONFIG_PLATFORM_EC_USB_PD_FRS_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_LOGGING=y +CONFIG_PLATFORM_EC_USB_PD_DEBUG_FIXED_LEVEL=y +CONFIG_PLATFORM_EC_USB_PD_DEBUG_LEVEL=2 +CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_ANX7447_AUX_PU_PD=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_RT1718S=y +CONFIG_PLATFORM_EC_USB_PD_TCPM_SBU=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_DETECT_TCPC=y +CONFIG_PLATFORM_EC_USB_PD_VBUS_MEASURE_BY_BOARD=y + +# External power +CONFIG_PLATFORM_EC_BACKLIGHT_LID=n + +# Keyboard +CONFIG_CROS_KB_RAW_NPCX=y +CONFIG_CROS_KB_RAW_NPCX_KSO_HIGH_DRIVE=y + +CONFIG_SYSCON=y + +CONFIG_PLATFORM_EC_BOARD_VERSION_GPIO=n diff --git a/zephyr/projects/corsola/prj_steelix.conf b/zephyr/projects/corsola/prj_steelix.conf index 48971c9ed4..265a1a4cc4 100644 --- a/zephyr/projects/corsola/prj_steelix.conf +++ b/zephyr/projects/corsola/prj_steelix.conf @@ -1,13 +1,21 @@ -# Copyright 2022 The Chromium OS Authors. All rights reserved. +# Copyright 2022 The ChromiumOS Authors # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. # Variant config -CONFIG_BOARD_KINGLER=n CONFIG_BOARD_STEELIX=y # steelix only use D2, drop the workaround config for H1 CONFIG_PLATFORM_EC_BOARD_RESET_AFTER_POWER_ON=n -# LED -CONFIG_PLATFORM_EC_LED_PWM=n +# Motion sensor +CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y +CONFIG_PLATFORM_EC_KEYBOARD_STRICT_DEBOUNCE=y + +# USBC +CONFIG_PLATFORM_EC_PD_MAX_CURRENT_MA=3250 +CONFIG_PLATFORM_EC_PD_MAX_POWER_MW=65000 diff --git a/zephyr/projects/corsola/prj_tentacruel.conf b/zephyr/projects/corsola/prj_tentacruel.conf new file mode 100644 index 0000000000..71cc9d9694 --- /dev/null +++ b/zephyr/projects/corsola/prj_tentacruel.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. + +# Variant config +CONFIG_BOARD_TENTACRUEL=y + +# USB-C +CONFIG_PLATFORM_EC_BC12_DETECT_PI3USB9201=y +CONFIG_PLATFORM_EC_USB_MUX_TUSB546=n +CONFIG_PLATFORM_EC_USB_MUX_PS8743=y + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y + +# Sensor +CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX=y +CONFIG_PLATFORM_EC_ACCELGYRO_BMI_COMM_I2C=y + +# Temperature sensors +CONFIG_PLATFORM_EC_TEMP_SENSOR=y +CONFIG_PLATFORM_EC_THERMISTOR=y + +# Battery +CONFIG_PLATFORM_EC_CHARGER_PROFILE_OVERRIDE=y diff --git a/zephyr/projects/corsola/src/board_chipset.c b/zephyr/projects/corsola/src/board_chipset.c index ca8f3b0507..54e96bc631 100644 --- a/zephyr/projects/corsola/src/board_chipset.c +++ b/zephyr/projects/corsola/src/board_chipset.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ diff --git a/zephyr/projects/corsola/src/hibernate.c b/zephyr/projects/corsola/src/hibernate.c index afd22fd3e7..56c085e077 100644 --- a/zephyr/projects/corsola/src/hibernate.c +++ b/zephyr/projects/corsola/src/hibernate.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ diff --git a/zephyr/projects/corsola/src/kingler/board_steelix.c b/zephyr/projects/corsola/src/kingler/board_steelix.c new file mode 100644 index 0000000000..c8ba0e7e74 --- /dev/null +++ b/zephyr/projects/corsola/src/kingler/board_steelix.c @@ -0,0 +1,51 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Board re-init for Rusty board + * Rusty shares the firmware with Steelix. + * Steelix is convertible but Rusty is clamshell + * so some functions should be disabled for clamshell. + */ +#include <zephyr/logging/log.h> +#include <zephyr/drivers/gpio.h> + +#include "cros_cbi.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "motion_sense.h" +#include "tablet_mode.h" + +LOG_MODULE_REGISTER(board_init, LOG_LEVEL_ERR); + +static bool board_is_clamshell; + +static void board_setup_init(void) +{ + int ret; + uint32_t val; + + ret = cros_cbi_get_fw_config(FORM_FACTOR, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR); + return; + } + if (val == CLAMSHELL) { + board_is_clamshell = true; + motion_sensor_count = 0; + gmr_tablet_switch_disable(); + } +} +DECLARE_HOOK(HOOK_INIT, board_setup_init, HOOK_PRIO_PRE_DEFAULT); + +static void disable_base_imu_irq(void) +{ + if (board_is_clamshell) { + gpio_disable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_base_imu)); + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(base_imu_int_l), + GPIO_INPUT | GPIO_PULL_UP); + } +} +DECLARE_HOOK(HOOK_INIT, disable_base_imu_irq, HOOK_PRIO_POST_DEFAULT); diff --git a/zephyr/projects/corsola/src/kingler/button.c b/zephyr/projects/corsola/src/kingler/button.c index d10d771950..920069bef6 100644 --- a/zephyr/projects/corsola/src/kingler/button.c +++ b/zephyr/projects/corsola/src/kingler/button.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/projects/corsola/src/kingler/i2c.c b/zephyr/projects/corsola/src/kingler/i2c.c index 6236d42714..f2bbff3749 100644 --- a/zephyr/projects/corsola/src/kingler/i2c.c +++ b/zephyr/projects/corsola/src/kingler/i2c.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -12,6 +12,10 @@ int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc) { return (i2c_get_device_for_port(cmd_desc->port) == - i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY)); + i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY) || + i2c_get_device_for_port(cmd_desc->port) == + i2c_get_device_for_port(I2C_PORT_EEPROM) || + i2c_get_device_for_port(cmd_desc->port) == + i2c_get_device_for_port(I2C_PORT_USB_C0)); } #endif diff --git a/zephyr/projects/corsola/src/kingler/led.c b/zephyr/projects/corsola/src/kingler/led.c index 045ddb5be1..4e2c5b12fb 100644 --- a/zephyr/projects/corsola/src/kingler/led.c +++ b/zephyr/projects/corsola/src/kingler/led.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -13,20 +13,25 @@ __override const int led_charge_lvl_1 = 5; __override const int led_charge_lvl_2 = 97; __override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_RED, LED_INDEFINITE} }, - [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, - [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_GREEN, LED_INDEFINITE} }, - [STATE_DISCHARGE_S0] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S0_BAT_LOW] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, - {LED_OFF, 3 * LED_ONE_SEC} }, - [STATE_DISCHARGE_S3] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S5] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_BATTERY_ERROR] = {{EC_LED_COLOR_RED, 1 * LED_ONE_SEC}, - {LED_OFF, 1 * LED_ONE_SEC} }, - [STATE_FACTORY_TEST] = {{EC_LED_COLOR_RED, 2 * LED_ONE_SEC}, - {EC_LED_COLOR_GREEN, 2 * LED_ONE_SEC} }, -}; + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S0_BAT_LOW] = { { EC_LED_COLOR_AMBER, + 1 * LED_ONE_SEC }, + { LED_OFF, 3 * LED_ONE_SEC } }, + [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, + { EC_LED_COLOR_GREEN, + 2 * LED_ONE_SEC } }, + }; __override void led_set_color_battery(enum ec_led_colors color) { diff --git a/zephyr/projects/corsola/src/kingler/led_steelix.c b/zephyr/projects/corsola/src/kingler/led_steelix.c index 2d2e1431a1..87b76128e8 100644 --- a/zephyr/projects/corsola/src/kingler/led_steelix.c +++ b/zephyr/projects/corsola/src/kingler/led_steelix.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. * @@ -10,6 +10,7 @@ #include "board_led.h" #include "common.h" +#include "cros_cbi.h" #include "led_common.h" #include "led_onoff_states.h" #include "util.h" @@ -28,29 +29,36 @@ static const struct board_led_pwm_dt_channel board_led_power_white = __override const int led_charge_lvl_1 = 5; __override const int led_charge_lvl_2 = 97; __override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_RED, LED_INDEFINITE} }, - [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, - [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_GREEN, LED_INDEFINITE} }, - [STATE_DISCHARGE_S0] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S0_BAT_LOW] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S3] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S5] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_BATTERY_ERROR] = {{EC_LED_COLOR_RED, 1 * LED_ONE_SEC}, - {LED_OFF, 1 * LED_ONE_SEC} }, - [STATE_FACTORY_TEST] = {{EC_LED_COLOR_RED, 2 * LED_ONE_SEC}, - {EC_LED_COLOR_GREEN, 2 * LED_ONE_SEC} }, -}; + led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { + [STATE_CHARGING_LVL_1] = { { EC_LED_COLOR_RED, + LED_INDEFINITE } }, + [STATE_CHARGING_LVL_2] = { { EC_LED_COLOR_AMBER, + LED_INDEFINITE } }, + [STATE_CHARGING_FULL_CHARGE] = { { EC_LED_COLOR_GREEN, + LED_INDEFINITE } }, + [STATE_DISCHARGE_S0] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S0_BAT_LOW] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S3] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_DISCHARGE_S5] = { { LED_OFF, LED_INDEFINITE } }, + [STATE_BATTERY_ERROR] = { { EC_LED_COLOR_RED, 1 * LED_ONE_SEC }, + { LED_OFF, 1 * LED_ONE_SEC } }, + [STATE_FACTORY_TEST] = { { EC_LED_COLOR_RED, 2 * LED_ONE_SEC }, + { EC_LED_COLOR_GREEN, + 2 * LED_ONE_SEC } }, + }; __override const struct led_descriptor - led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { - [PWR_LED_STATE_ON] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, - [PWR_LED_STATE_SUSPEND_AC] = {{EC_LED_COLOR_WHITE, 3 * LED_ONE_SEC}, - {LED_OFF, 0.5 * LED_ONE_SEC} }, - [PWR_LED_STATE_SUSPEND_NO_AC] = {{EC_LED_COLOR_WHITE, 3 * LED_ONE_SEC}, - {LED_OFF, 0.5 * LED_ONE_SEC} }, - [PWR_LED_STATE_OFF] = {{LED_OFF, LED_INDEFINITE} }, -}; + led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { + [PWR_LED_STATE_ON] = { { EC_LED_COLOR_WHITE, LED_INDEFINITE } }, + [PWR_LED_STATE_SUSPEND_AC] = { { EC_LED_COLOR_WHITE, + 3 * LED_ONE_SEC }, + { LED_OFF, 0.5 * LED_ONE_SEC } }, + [PWR_LED_STATE_SUSPEND_NO_AC] = { { EC_LED_COLOR_WHITE, + 3 * LED_ONE_SEC }, + { LED_OFF, + 0.5 * LED_ONE_SEC } }, + [PWR_LED_STATE_OFF] = { { LED_OFF, LED_INDEFINITE } }, + }; const enum ec_led_id supported_led_ids[] = { EC_LED_ID_BATTERY_LED, @@ -72,8 +80,8 @@ static void board_led_pwm_set_duty(const struct board_led_pwm_dt_channel *ch, pulse_ns = DIV_ROUND_NEAREST(BOARD_LED_PWM_PERIOD_NS * percent, 100); - LOG_DBG("Board LED PWM %s set percent (%d), pulse %d", - ch->dev->name, percent, pulse_ns); + LOG_DBG("Board LED PWM %s set percent (%d), pulse %d", ch->dev->name, + percent, pulse_ns); rv = pwm_set(ch->dev, ch->channel, BOARD_LED_PWM_PERIOD_NS, pulse_ns, ch->flags); @@ -82,6 +90,20 @@ static void board_led_pwm_set_duty(const struct board_led_pwm_dt_channel *ch, } } +static bool device_is_clamshell(void) +{ + int ret; + uint32_t val; + + ret = cros_cbi_get_fw_config(FORM_FACTOR, &val); + if (ret != 0) { + LOG_ERR("Error retrieving CBI FW_CONFIG field %d", FORM_FACTOR); + return false; + } + + return val == CLAMSHELL; +} + __override void led_set_color_battery(enum ec_led_colors color) { switch (color) { @@ -106,13 +128,17 @@ __override void led_set_color_battery(enum ec_led_colors color) __override void led_set_color_power(enum ec_led_colors color) { - switch (color) { - case EC_LED_COLOR_WHITE: - board_led_pwm_set_duty(&board_led_power_white, 100); - break; - default: + if (device_is_clamshell()) { board_led_pwm_set_duty(&board_led_power_white, 0); - break; + } else { + switch (color) { + case EC_LED_COLOR_WHITE: + board_led_pwm_set_duty(&board_led_power_white, 100); + break; + default: + board_led_pwm_set_duty(&board_led_power_white, 0); + break; + } } } @@ -123,7 +149,11 @@ void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) brightness_range[EC_LED_COLOR_GREEN] = 1; brightness_range[EC_LED_COLOR_AMBER] = 1; } else if (led_id == EC_LED_ID_POWER_LED) { - brightness_range[EC_LED_COLOR_WHITE] = 1; + if (device_is_clamshell()) { + brightness_range[EC_LED_COLOR_WHITE] = 0; + } else { + brightness_range[EC_LED_COLOR_WHITE] = 1; + } } } diff --git a/zephyr/projects/corsola/src/kingler/usb_pd_policy.c b/zephyr/projects/corsola/src/kingler/usb_pd_policy.c index 51a05598b9..3de2857ad1 100644 --- a/zephyr/projects/corsola/src/kingler/usb_pd_policy.c +++ b/zephyr/projects/corsola/src/kingler/usb_pd_policy.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -14,8 +14,8 @@ #include "baseboard_usbc_config.h" -#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ## args) +#define CPRINTS(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBCHARGE, format, ##args) void pd_power_supply_reset(int port) { @@ -39,7 +39,6 @@ void pd_power_supply_reset(int port) pd_send_host_event(PD_EVENT_POWER_CHANGE); } - int pd_set_power_supply_ready(int port) { int rv; diff --git a/zephyr/projects/corsola/src/kingler/usbc_config.c b/zephyr/projects/corsola/src/kingler/usbc_config.c index 42aa0a31d6..8c0ca86454 100644 --- a/zephyr/projects/corsola/src/kingler/usbc_config.c +++ b/zephyr/projects/corsola/src/kingler/usbc_config.c @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -31,57 +31,16 @@ #endif #include "gpio.h" - -#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) - -struct tcpc_config_t tcpc_config[CONFIG_USB_PD_PORT_MAX_COUNT] = { - [USBC_PORT_C0] = { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C0, - .addr_flags = AN7447_TCPC0_I2C_ADDR_FLAGS, - }, - .drv = &anx7447_tcpm_drv, - /* Alert is active-low, open-drain */ - .flags = TCPC_FLAGS_ALERT_OD | TCPC_FLAGS_VBUS_MONITOR | - TCPC_FLAGS_CONTROL_FRS, - }, - [USBC_PORT_C1] = { - .bus_type = EC_BUS_TYPE_I2C, - .i2c_info = { - .port = I2C_PORT_USB_C1, - .addr_flags = RT1718S_I2C_ADDR2_FLAGS, - }, - .drv = &rt1718s_tcpm_drv, - /* Alert is active-low, open-drain */ - .flags = TCPC_FLAGS_ALERT_OD | TCPC_FLAGS_VBUS_MONITOR | - TCPC_FLAGS_CONTROL_FRS, - } -}; - -struct ppc_config_t ppc_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = { - [USBC_PORT_C0] = { - .i2c_port = I2C_PORT_USB_C0, - .i2c_addr_flags = NX20P3483_ADDR2_FLAGS, - .drv = &nx20p348x_drv - }, - [USBC_PORT_C1] = { - .i2c_port = I2C_PORT_USB_C1, - .i2c_addr_flags = NX20P3483_ADDR2_FLAGS, - .drv = &nx20p348x_drv - } -}; -unsigned int ppc_cnt = ARRAY_SIZE(ppc_chips); +#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) /* USB Mux */ /* USB Mux C1 : board_init of PS8743 */ -static int ps8743_tune_mux(const struct usb_mux *me) +int ps8743_mux_1_board_init(const struct usb_mux *me) { - ps8743_tune_usb_eq(me, - PS8743_USB_EQ_TX_3_6_DB, - PS8743_USB_EQ_RX_16_0_DB); + ps8743_tune_usb_eq(me, PS8743_USB_EQ_TX_3_6_DB, + PS8743_USB_EQ_RX_16_0_DB); return EC_SUCCESS; } @@ -90,61 +49,13 @@ void board_usb_mux_init(void) { if (corsola_get_db_type() == CORSOLA_DB_TYPEC) { /* Disable DCI function. This is not needed for ARM. */ - ps8743_field_update(&usb_muxes[1], - PS8743_REG_DCI_CONFIG_2, - PS8743_AUTO_DCI_MODE_MASK, - PS8743_AUTO_DCI_MODE_FORCE_USB); + ps8743_field_update(usb_muxes[1].mux, PS8743_REG_DCI_CONFIG_2, + PS8743_AUTO_DCI_MODE_MASK, + PS8743_AUTO_DCI_MODE_FORCE_USB); } } DECLARE_HOOK(HOOK_INIT, board_usb_mux_init, HOOK_PRIO_INIT_I2C + 1); -const struct usb_mux usbc0_virtual_mux = { - .usb_port = USBC_PORT_C0, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, -}; - -const struct usb_mux usbc1_virtual_mux = { - .usb_port = USBC_PORT_C1, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, -}; - -struct usb_mux usb_muxes[CONFIG_USB_PD_PORT_MAX_COUNT] = { - [USBC_PORT_C0] = { - .usb_port = USBC_PORT_C0, - .driver = &anx7447_usb_mux_driver, - .hpd_update = &anx7447_tcpc_update_hpd_status, - .next_mux = &usbc0_virtual_mux, - }, - [USBC_PORT_C1] = { - .usb_port = USBC_PORT_C1, - .i2c_port = I2C_PORT_USB_C1, - .i2c_addr_flags = PS8743_I2C_ADDR0_FLAG, - .driver = &ps8743_usb_mux_driver, - .next_mux = &usbc1_virtual_mux, - .board_init = &ps8743_tune_mux, - }, -}; - -struct bc12_config bc12_ports[CONFIG_USB_PD_PORT_MAX_COUNT] = { - [USBC_PORT_C0] = { - .drv = &pi3usb9201_drv, - }, - [USBC_PORT_C1] = { - .drv = &rt1718s_bc12_drv, - } -}; - -const struct pi3usb9201_config_t - pi3usb9201_bc12_chips[CONFIG_USB_PD_PORT_MAX_COUNT] = { - [USBC_PORT_C0] = { - .i2c_port = I2C_PORT_USB_C0, - .i2c_addr_flags = PI3USB9201_I2C_ADDR_3_FLAGS, - }, - [USBC_PORT_C1] = { /* unused */ } -}; - void board_tcpc_init(void) { /* Only reset TCPC if not sysjump */ @@ -169,7 +80,7 @@ void board_tcpc_init(void) */ for (int port = 0; port < CONFIG_USB_PD_PORT_MAX_COUNT; ++port) { usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | - USB_PD_MUX_HPD_IRQ_DEASSERTED); + USB_PD_MUX_HPD_IRQ_DEASSERTED); } } DECLARE_HOOK(HOOK_INIT, board_tcpc_init, HOOK_PRIO_POST_I2C); @@ -188,20 +99,28 @@ __override int board_rt1718s_init(int port) /* gpio1 low, gpio2 output high when receiving frs signal */ RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_GPIO1_VBUS_CTRL, - RT1718S_GPIO1_VBUS_CTRL_FRS_RX_VBUS, 0)); + RT1718S_GPIO1_VBUS_CTRL_FRS_RX_VBUS, + 0)); RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_GPIO2_VBUS_CTRL, - RT1718S_GPIO2_VBUS_CTRL_FRS_RX_VBUS, 0xFF)); + RT1718S_GPIO2_VBUS_CTRL_FRS_RX_VBUS, + 0xFF)); /* Trigger GPIO 1/2 change when FRS signal received */ - RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_FRS_CTRL3, - RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO2 | + RETURN_ERROR(rt1718s_update_bits8( + port, RT1718S_FRS_CTRL3, + RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO2 | RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO1, - RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO2 | + RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO2 | RT1718S_FRS_CTRL3_FRS_RX_WAIT_GPIO1)); /* Set FRS signal detect time to 46.875us */ RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_FRS_CTRL1, - RT1718S_FRS_CTRL1_FRSWAPRX_MASK, - 0xFF)); + RT1718S_FRS_CTRL1_FRSWAPRX_MASK, + 0xFF)); + + /* Disable BC1.2 SRC mode */ + RETURN_ERROR(rt1718s_update_bits8(port, RT1718S_RT2_BC12_SRC_FUNC, + RT1718S_RT2_BC12_SRC_FUNC_BC12_SRC_EN, + 0)); return EC_SUCCESS; } @@ -215,13 +134,12 @@ __override int board_rt1718s_set_frs_enable(int port, int enable) * FRS path. */ rt1718s_gpio_set_flags(port, GPIO_EN_USB_C1_FRS, - enable ? GPIO_OUT_HIGH : GPIO_OUT_LOW); + enable ? GPIO_OUT_HIGH : GPIO_OUT_LOW); return EC_SUCCESS; } void board_reset_pd_mcu(void) { - CPRINTS("Resetting TCPCs..."); /* reset C0 ANX3447 */ /* Assert reset */ @@ -315,15 +233,15 @@ uint16_t tcpc_get_alert_status(void) uint16_t status = 0; if (!gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl))) { + GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_int_odl))) { if (!gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst))) { + GPIO_DT_FROM_NODELABEL(gpio_usb_c0_tcpc_rst))) { status |= PD_STATUS_TCPC_ALERT_0; } } if (!gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl))) { + GPIO_DT_FROM_NODELABEL(gpio_usb_c1_tcpc_int_odl))) { return status |= PD_STATUS_TCPC_ALERT_1; } return status; diff --git a/zephyr/projects/corsola/src/krabby/battery.c b/zephyr/projects/corsola/src/krabby/battery.c deleted file mode 100644 index 0c0efc8200..0000000000 --- a/zephyr/projects/corsola/src/krabby/battery.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "battery.h" -#include "battery_fuel_gauge.h" -#include "battery_smart.h" -#include "charge_manager.h" -#include "chipset.h" -#include "hooks.h" -#include "system.h" -#include "usb_pd.h" - -const struct board_batt_params board_battery_info[] = { - [BATTERY_C235] = { - .fuel_gauge = { - .manuf_name = "AS3GWRc3KA", - .device_name = "C235-41", - .ship_mode = { - .reg_addr = 0x0, - .reg_data = { 0x10, 0x10 }, - }, - .fet = { - .reg_addr = 0x99, - .reg_mask = 0x0c, - .disconnect_val = 0x0c, - } - }, - .batt_info = { - .voltage_max = 8800, - .voltage_normal = 7700, - .voltage_min = 6000, - .precharge_current = 256, - .start_charging_min_c = 0, - .start_charging_max_c = 45, - .charging_min_c = 0, - .charging_max_c = 60, - .discharging_min_c = 0, - .discharging_max_c = 60, - }, - }, -}; -BUILD_ASSERT(ARRAY_SIZE(board_battery_info) == BATTERY_TYPE_COUNT); - -const enum battery_type DEFAULT_BATTERY_TYPE = BATTERY_C235; diff --git a/zephyr/projects/corsola/src/krabby/charger_workaround.c b/zephyr/projects/corsola/src/krabby/charger_workaround.c index 373917db56..dda91fccb5 100644 --- a/zephyr/projects/corsola/src/krabby/charger_workaround.c +++ b/zephyr/projects/corsola/src/krabby/charger_workaround.c @@ -1,22 +1,30 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ +#include <zephyr/sys/util.h> + #include "charger.h" #include "driver/charger/rt9490.h" #include "hooks.h" #include "i2c.h" #include "system.h" +/* + * This workaround and the board id checks only apply to krabby and early + * tentacruel devices. + * Newer project should have all of these fixed. + */ +BUILD_ASSERT(IS_ENABLED(CONFIG_BOARD_KRABBY) || + IS_ENABLED(CONFIG_BOARD_TENTACRUEL) || IS_ENABLED(CONFIG_TEST)); + static void enter_hidden_mode(void) { i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, - chg_chips[CHARGER_SOLO].i2c_addr_flags, - 0xF1, 0x69); + chg_chips[CHARGER_SOLO].i2c_addr_flags, 0xF1, 0x69); i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, - chg_chips[CHARGER_SOLO].i2c_addr_flags, - 0xF2, 0x96); + chg_chips[CHARGER_SOLO].i2c_addr_flags, 0xF2, 0x96); } /* b/194967754#comment5: work around for IBUS ADC unstable issue */ @@ -28,48 +36,33 @@ static void ibus_adc_workaround(void) i2c_update8(chg_chips[CHARGER_SOLO].i2c_port, chg_chips[CHARGER_SOLO].i2c_addr_flags, - RT9490_REG_ADC_CHANNEL0, - RT9490_VSYS_ADC_DIS, - MASK_SET); + RT9490_REG_ADC_CHANNEL0, RT9490_VSYS_ADC_DIS, MASK_SET); enter_hidden_mode(); /* undocumented registers... */ i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, - chg_chips[CHARGER_SOLO].i2c_addr_flags, - 0x52, 0xC4); + chg_chips[CHARGER_SOLO].i2c_addr_flags, 0x52, 0xC4); i2c_update8(chg_chips[CHARGER_SOLO].i2c_port, chg_chips[CHARGER_SOLO].i2c_addr_flags, - RT9490_REG_ADC_CHANNEL0, - RT9490_VSYS_ADC_DIS, - MASK_CLR); + RT9490_REG_ADC_CHANNEL0, RT9490_VSYS_ADC_DIS, MASK_CLR); } /* b/214880220#comment44: lock i2c at 400khz */ static void i2c_speed_workaround(void) { - /* - * This workaround can be applied to all version of RT9490 in our cases - * no need to identify chip version. - */ + if (system_get_board_version() >= 3) { + return; + } + enter_hidden_mode(); /* Set to Auto mode, default run at 400kHz */ i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, - chg_chips[CHARGER_SOLO].i2c_addr_flags, - 0x71, 0x22); + chg_chips[CHARGER_SOLO].i2c_addr_flags, 0x71, 0x22); /* Manually select for 400kHz, valid only when 0x71[7] == 1 */ i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, - chg_chips[CHARGER_SOLO].i2c_addr_flags, - 0xF7, 0x14); -} - -static void pwm_freq_workaround(void) -{ - /* Reduce SW freq from 1.5MHz to 1MHz - * for 10% higher current rating b/215294785 - */ - rt9490_enable_pwm_1mhz(CHARGER_SOLO, true); + chg_chips[CHARGER_SOLO].i2c_addr_flags, 0xF7, 0x14); } static void eoc_deglitch_workaround(void) @@ -81,16 +74,27 @@ static void eoc_deglitch_workaround(void) /* set end-of-charge deglitch time to 2ms */ i2c_update8(chg_chips[CHARGER_SOLO].i2c_port, chg_chips[CHARGER_SOLO].i2c_addr_flags, - RT9490_REG_ADD_CTRL0, - RT9490_TD_EOC, - MASK_CLR); + RT9490_REG_ADD_CTRL0, RT9490_TD_EOC, MASK_CLR); +} + +static void disable_safety_timer(void) +{ + if (system_get_board_version() >= 2) { + return; + } + /* Disable charge timer */ + i2c_write8(chg_chips[CHARGER_SOLO].i2c_port, + chg_chips[CHARGER_SOLO].i2c_addr_flags, + RT9490_REG_SAFETY_TMR_CTRL, + RT9490_EN_TRICHG_TMR | RT9490_EN_PRECHG_TMR | + RT9490_EN_FASTCHG_TMR); } static void board_rt9490_workaround(void) { ibus_adc_workaround(); i2c_speed_workaround(); - pwm_freq_workaround(); eoc_deglitch_workaround(); + disable_safety_timer(); } DECLARE_HOOK(HOOK_INIT, board_rt9490_workaround, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/corsola/src/krabby/hooks.c b/zephyr/projects/corsola/src/krabby/hooks.c index 9fae7c8bb5..1eb4f600f2 100644 --- a/zephyr/projects/corsola/src/krabby/hooks.c +++ b/zephyr/projects/corsola/src/krabby/hooks.c @@ -1,10 +1,11 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* Copyright 2021 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include <zephyr/init.h> #include <zephyr/drivers/gpio.h> +#include <zephyr/drivers/pinctrl.h> #include <ap_power/ap_power.h> #include "charger.h" @@ -13,22 +14,21 @@ #include "gpio.h" #include "hooks.h" +#define I2C3_NODE DT_NODELABEL(i2c3) +PINCTRL_DT_DEFINE(I2C3_NODE); + static void board_i2c3_ctrl(bool enable) { - if (DEVICE_DT_GET(DT_GPIO_CTLR_BY_IDX(DT_NODELABEL(i2c3), - scl_gpios, 0)) == DEVICE_DT_GET(DT_NODELABEL(gpiof))) { - /* - * TODO(b/226296649): - * Use pinctrl APIs to enable/disable an interface. - */ - struct gctrl_it8xxx2_regs *const gctrl_base = - (struct gctrl_it8xxx2_regs *) - DT_REG_ADDR(DT_NODELABEL(gctrl)); + if (DEVICE_DT_GET( + DT_GPIO_CTLR_BY_IDX(DT_NODELABEL(i2c3), scl_gpios, 0)) == + DEVICE_DT_GET(DT_NODELABEL(gpiof))) { + const struct pinctrl_dev_config *pcfg = + PINCTRL_DT_DEV_CONFIG_GET(I2C3_NODE); if (enable) { - gctrl_base->GCTRL_PMER3 |= IT8XXX2_GCTRL_SMB3PSEL; + pinctrl_apply_state(pcfg, PINCTRL_STATE_DEFAULT); } else { - gctrl_base->GCTRL_PMER3 &= ~IT8XXX2_GCTRL_SMB3PSEL; + pinctrl_apply_state(pcfg, PINCTRL_STATE_SLEEP); } } } diff --git a/zephyr/projects/corsola/src/krabby/i2c.c b/zephyr/projects/corsola/src/krabby/i2c.c index 3b5108e115..a83af77dbd 100644 --- a/zephyr/projects/corsola/src/krabby/i2c.c +++ b/zephyr/projects/corsola/src/krabby/i2c.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ @@ -12,6 +12,8 @@ int board_allow_i2c_passthru(const struct i2c_cmd_desc_t *cmd_desc) { return (i2c_get_device_for_port(cmd_desc->port) == - i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY)); + i2c_get_device_for_port(I2C_PORT_VIRTUAL_BATTERY) || + i2c_get_device_for_port(cmd_desc->port) == + i2c_get_device_for_port(I2C_PORT_EEPROM)); } #endif diff --git a/zephyr/projects/corsola/src/krabby/led.c b/zephyr/projects/corsola/src/krabby/led.c deleted file mode 100644 index c001615402..0000000000 --- a/zephyr/projects/corsola/src/krabby/led.c +++ /dev/null @@ -1,147 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include <zephyr/drivers/pwm.h> -#include <zephyr/logging/log.h> - -#include "board_led.h" -#include "common.h" -#include "led_common.h" -#include "led_onoff_states.h" -#include "util.h" - -LOG_MODULE_REGISTER(board_led, LOG_LEVEL_ERR); - -/*If we need pwm output in ITE chip power saving mode, then we should set - * frequency <= 324Hz. - */ -#define BOARD_LED_PWM_PERIOD_NS BOARD_LED_HZ_TO_PERIOD_NS(324) - -static const struct board_led_pwm_dt_channel board_led_power_white = - BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_power_white)); -static const struct board_led_pwm_dt_channel board_led_battery_amber = - BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_battery_amber)); -static const struct board_led_pwm_dt_channel board_led_battery_white = - BOARD_LED_PWM_DT_CHANNEL_INITIALIZER(DT_NODELABEL(led_battery_white)); - -__override const int led_charge_lvl_1 = 5; -__override const int led_charge_lvl_2 = 95; - -__override struct led_descriptor - led_bat_state_table[LED_NUM_STATES][LED_NUM_PHASES] = { - [STATE_CHARGING_LVL_1] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, - [STATE_CHARGING_LVL_2] = {{EC_LED_COLOR_AMBER, LED_INDEFINITE} }, - [STATE_CHARGING_FULL_CHARGE] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, - [STATE_DISCHARGE_S0] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S0_BAT_LOW] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, - {LED_OFF, 3 * LED_ONE_SEC} }, - [STATE_DISCHARGE_S3] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_DISCHARGE_S5] = {{LED_OFF, LED_INDEFINITE} }, - [STATE_BATTERY_ERROR] = {{EC_LED_COLOR_AMBER, 1 * LED_ONE_SEC}, - {LED_OFF, 1 * LED_ONE_SEC} }, - [STATE_FACTORY_TEST] = {{EC_LED_COLOR_WHITE, 2 * LED_ONE_SEC}, - {EC_LED_COLOR_AMBER, 2 * LED_ONE_SEC} }, -}; - -__override const struct led_descriptor - led_pwr_state_table[PWR_LED_NUM_STATES][LED_NUM_PHASES] = { - [PWR_LED_STATE_ON] = {{EC_LED_COLOR_WHITE, LED_INDEFINITE} }, - [PWR_LED_STATE_SUSPEND_AC] = {{EC_LED_COLOR_WHITE, 1 * LED_ONE_SEC}, - {LED_OFF, 3 * LED_ONE_SEC} }, - [PWR_LED_STATE_SUSPEND_NO_AC] = {{EC_LED_COLOR_WHITE, 1 * LED_ONE_SEC}, - {LED_OFF, 3 * LED_ONE_SEC} }, - [PWR_LED_STATE_OFF] = {{LED_OFF, LED_INDEFINITE} }, -}; - -const enum ec_led_id supported_led_ids[] = { - EC_LED_ID_BATTERY_LED, - EC_LED_ID_POWER_LED, -}; - -const int supported_led_ids_count = ARRAY_SIZE(supported_led_ids); - -static void board_led_pwm_set_duty(const struct board_led_pwm_dt_channel *ch, - int percent) -{ - uint32_t pulse_ns; - int rv; - - if (!device_is_ready(ch->dev)) { - LOG_ERR("PWM device %s not ready", ch->dev->name); - return; - } - - pulse_ns = DIV_ROUND_NEAREST(BOARD_LED_PWM_PERIOD_NS * percent, 100); - - LOG_DBG("Board LED PWM %s set percent (%d), pulse %d", - ch->dev->name, percent, pulse_ns); - - rv = pwm_set(ch->dev, ch->channel, BOARD_LED_PWM_PERIOD_NS, pulse_ns, - ch->flags); - if (rv) { - LOG_ERR("pwm_set() failed %s (%d)", ch->dev->name, rv); - } -} - -__override void led_set_color_battery(enum ec_led_colors color) -{ - switch (color) { - case EC_LED_COLOR_AMBER: - board_led_pwm_set_duty(&board_led_battery_amber, 100); - board_led_pwm_set_duty(&board_led_battery_white, 0); - break; - case EC_LED_COLOR_WHITE: - board_led_pwm_set_duty(&board_led_battery_amber, 0); - board_led_pwm_set_duty(&board_led_battery_white, 100); - break; - default: - board_led_pwm_set_duty(&board_led_battery_amber, 0); - board_led_pwm_set_duty(&board_led_battery_white, 0); - break; - } -} - -__override void led_set_color_power(enum ec_led_colors color) -{ - switch (color) { - case EC_LED_COLOR_WHITE: - board_led_pwm_set_duty(&board_led_power_white, 100); - break; - default: - board_led_pwm_set_duty(&board_led_power_white, 0); - break; - } -} - -void led_get_brightness_range(enum ec_led_id led_id, uint8_t *brightness_range) -{ - if (led_id == EC_LED_ID_BATTERY_LED) { - brightness_range[EC_LED_COLOR_AMBER] = 1; - brightness_range[EC_LED_COLOR_WHITE] = 1; - } else if (led_id == EC_LED_ID_POWER_LED) { - brightness_range[EC_LED_COLOR_WHITE] = 1; - } -} - -int led_set_brightness(enum ec_led_id led_id, const uint8_t *brightness) -{ - if (led_id == EC_LED_ID_BATTERY_LED) { - if (brightness[EC_LED_COLOR_AMBER] != 0) { - led_set_color_battery(EC_LED_COLOR_AMBER); - } else if (brightness[EC_LED_COLOR_WHITE] != 0) { - led_set_color_battery(EC_LED_COLOR_WHITE); - } else { - led_set_color_battery(LED_OFF); - } - } else if (led_id == EC_LED_ID_POWER_LED) { - if (brightness[EC_LED_COLOR_WHITE] != 0) { - led_set_color_power(EC_LED_COLOR_WHITE); - } else { - led_set_color_power(LED_OFF); - } - } - - return EC_SUCCESS; -} diff --git a/zephyr/projects/corsola/src/krabby/sensor_magikarp.c b/zephyr/projects/corsola/src/krabby/sensor_magikarp.c new file mode 100644 index 0000000000..269bc26fae --- /dev/null +++ b/zephyr/projects/corsola/src/krabby/sensor_magikarp.c @@ -0,0 +1,41 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "accelgyro.h" +#include "cros_cbi.h" +#include "driver/accelgyro_bmi323.h" +#include "driver/accelgyro_icm42607.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +void motion_interrupt(enum gpio_signal signal) +{ + uint32_t val; + + cros_cbi_get_fw_config(FW_BASE_GYRO, &val); + if (val == FW_BASE_ICM42607) { + icm42607_interrupt(signal); + } else if (val == FW_BASE_BMI323) { + bmi3xx_interrupt(signal); + } +} + +static void motionsense_init(void) +{ + uint32_t val; + + cros_cbi_get_fw_config(FW_BASE_GYRO, &val); + if (val == FW_BASE_ICM42607) { + ccprints("BASE ACCEL is ICM42607"); + } else if (val == FW_BASE_BMI323) { + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel); + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro); + ccprints("BASE ACCEL IS BMI323"); + } else { + ccprints("no motionsense"); + } +} +DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/corsola/src/krabby/sensor_tentacruel.c b/zephyr/projects/corsola/src/krabby/sensor_tentacruel.c new file mode 100644 index 0000000000..269bc26fae --- /dev/null +++ b/zephyr/projects/corsola/src/krabby/sensor_tentacruel.c @@ -0,0 +1,41 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "common.h" +#include "accelgyro.h" +#include "cros_cbi.h" +#include "driver/accelgyro_bmi323.h" +#include "driver/accelgyro_icm42607.h" +#include "hooks.h" +#include "motionsense_sensors.h" + +void motion_interrupt(enum gpio_signal signal) +{ + uint32_t val; + + cros_cbi_get_fw_config(FW_BASE_GYRO, &val); + if (val == FW_BASE_ICM42607) { + icm42607_interrupt(signal); + } else if (val == FW_BASE_BMI323) { + bmi3xx_interrupt(signal); + } +} + +static void motionsense_init(void) +{ + uint32_t val; + + cros_cbi_get_fw_config(FW_BASE_GYRO, &val); + if (val == FW_BASE_ICM42607) { + ccprints("BASE ACCEL is ICM42607"); + } else if (val == FW_BASE_BMI323) { + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_accel); + MOTIONSENSE_ENABLE_ALTERNATE(alt_base_gyro); + ccprints("BASE ACCEL IS BMI323"); + } else { + ccprints("no motionsense"); + } +} +DECLARE_HOOK(HOOK_INIT, motionsense_init, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/corsola/src/krabby/temp_tentacruel.c b/zephyr/projects/corsola/src/krabby/temp_tentacruel.c new file mode 100644 index 0000000000..53a8312be6 --- /dev/null +++ b/zephyr/projects/corsola/src/krabby/temp_tentacruel.c @@ -0,0 +1,126 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "charger.h" +#include "charge_state.h" +#include "common.h" +#include "config.h" +#include "console.h" +#include "driver/charger/rt9490.h" +#include "hooks.h" +#include "temp_sensor/temp_sensor.h" +#include "thermal.h" +#include "util.h" + +#define NUM_CURRENT_LEVELS ARRAY_SIZE(current_table) +#define TEMP_THRESHOLD 55 +#define TEMP_BUFF_SIZE 60 +#define KEEP_TIME 5 + +/* calculate current average temperature */ +static int average_tempature(void) +{ + static int temp_history_buffer[TEMP_BUFF_SIZE]; + static int buff_ptr; + static int temp_sum; + static int past_temp; + static int avg_temp; + int cur_temp, t; + + temp_sensor_read(TEMP_SENSOR_ID(DT_NODELABEL(temp_charger)), &t); + cur_temp = K_TO_C(t); + past_temp = temp_history_buffer[buff_ptr]; + temp_history_buffer[buff_ptr] = cur_temp; + temp_sum = temp_sum + temp_history_buffer[buff_ptr] - past_temp; + buff_ptr++; + if (buff_ptr >= TEMP_BUFF_SIZE) { + buff_ptr = 0; + } + /* Calculate per minute temperature. + * It's expected low temperature when the first 60 seconds. + */ + avg_temp = temp_sum / TEMP_BUFF_SIZE; + return avg_temp; +} + +static int current_level; + +/* Limit charging current table : 3600/3000/2400/1800 + * note this should be in descending order. + */ +static uint16_t current_table[] = { + 3600, + 3000, + 2400, + 1800, +}; + +/* Called by hook task every hook second (1 sec) */ +static void current_update(void) +{ + int temp; + static uint8_t uptime; + static uint8_t dntime; + + temp = average_tempature(); + if (charge_get_state() == PWR_STATE_DISCHARGE) { + current_level = 0; + uptime = 0; + dntime = 0; + return; + } + if (temp >= TEMP_THRESHOLD) { + dntime = 0; + if (uptime < KEEP_TIME) { + uptime++; + } else { + uptime = 0; + current_level++; + } + } else if (current_level != 0 && temp < TEMP_THRESHOLD) { + uptime = 0; + if (dntime < KEEP_TIME) { + dntime++; + } else { + dntime = 0; + current_level--; + } + } else { + uptime = 0; + dntime = 0; + } + if (current_level > NUM_CURRENT_LEVELS) { + current_level = NUM_CURRENT_LEVELS; + } +} +DECLARE_HOOK(HOOK_SECOND, current_update, HOOK_PRIO_DEFAULT); + +int charger_profile_override(struct charge_state_data *curr) +{ + /* + * Precharge must be executed when communication is failed on + * dead battery. + */ + if (!(curr->batt.flags & BATT_FLAG_RESPONSIVE)) + return 0; + if (current_level != 0) { + if (curr->requested_current > current_table[current_level - 1]) + curr->requested_current = + current_table[current_level - 1]; + } + return 0; +} + +enum ec_status charger_profile_override_get_param(uint32_t param, + uint32_t *value) +{ + return EC_RES_INVALID_PARAM; +} + +enum ec_status charger_profile_override_set_param(uint32_t param, + uint32_t value) +{ + return EC_RES_INVALID_PARAM; +} diff --git a/zephyr/projects/corsola/src/krabby/usb_pd_policy.c b/zephyr/projects/corsola/src/krabby/usb_pd_policy.c index 5f9ae83a19..8f2a2c3515 100644 --- a/zephyr/projects/corsola/src/krabby/usb_pd_policy.c +++ b/zephyr/projects/corsola/src/krabby/usb_pd_policy.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ diff --git a/zephyr/projects/corsola/src/krabby/usbc_config.c b/zephyr/projects/corsola/src/krabby/usbc_config.c index 73ecd2f7bd..01686119cc 100644 --- a/zephyr/projects/corsola/src/krabby/usbc_config.c +++ b/zephyr/projects/corsola/src/krabby/usbc_config.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ @@ -23,25 +23,15 @@ #include "variant_db_detection.h" -#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ## args) -#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args) +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) void c0_bc12_interrupt(enum gpio_signal signal) { rt1739_interrupt(0); } -static void board_sub_bc12_init(void) -{ - if (corsola_get_db_type() == CORSOLA_DB_HDMI) { - /* If this is not a Type-C subboard, disable the task. */ - task_disable_task(TASK_ID_USB_CHG_P1); - } -} -/* Must be done after I2C and subboard */ -DECLARE_HOOK(HOOK_INIT, board_sub_bc12_init, HOOK_PRIO_POST_I2C); - static void board_usbc_init(void) { gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc_bc12)); @@ -58,12 +48,12 @@ void ppc_interrupt(enum gpio_signal signal) int ppc_get_alert_status(int port) { if (port == 0) { - return gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(usb_c0_ppc_bc12_int_odl)) == 0; + return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL( + usb_c0_ppc_bc12_int_odl)) == 0; } if (port == 1 && corsola_get_db_type() == CORSOLA_DB_TYPEC) { - return gpio_pin_get_dt( - GPIO_DT_FROM_ALIAS(gpio_usb_c1_ppc_int_odl)) == 0; + return gpio_pin_get_dt(GPIO_DT_FROM_ALIAS( + gpio_usb_c1_ppc_int_odl)) == 0; } return 0; @@ -73,15 +63,19 @@ const struct cc_para_t *board_get_cc_tuning_parameter(enum usbpd_port port) { const static struct cc_para_t cc_parameter[CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT] = { - { - .rising_time = IT83XX_TX_PRE_DRIVING_TIME_1_UNIT, - .falling_time = IT83XX_TX_PRE_DRIVING_TIME_2_UNIT, - }, - { - .rising_time = IT83XX_TX_PRE_DRIVING_TIME_1_UNIT, - .falling_time = IT83XX_TX_PRE_DRIVING_TIME_2_UNIT, - }, - }; + { + .rising_time = + IT83XX_TX_PRE_DRIVING_TIME_1_UNIT, + .falling_time = + IT83XX_TX_PRE_DRIVING_TIME_2_UNIT, + }, + { + .rising_time = + IT83XX_TX_PRE_DRIVING_TIME_1_UNIT, + .falling_time = + IT83XX_TX_PRE_DRIVING_TIME_2_UNIT, + }, + }; return &cc_parameter[port]; } @@ -169,10 +163,10 @@ int board_set_active_charge_port(int port) enum adc_channel board_get_vbus_adc(int port) { if (port == 0) { - return ADC_VBUS_C0; + return ADC_VBUS_C0; } if (port == 1) { - return ADC_VBUS_C1; + return ADC_VBUS_C1; } CPRINTSUSB("Unknown vbus adc port id: %d", port); return ADC_VBUS_C0; diff --git a/zephyr/projects/corsola/src/krabby/usbc_config_tentacruel.c b/zephyr/projects/corsola/src/krabby/usbc_config_tentacruel.c new file mode 100644 index 0000000000..691a28d50f --- /dev/null +++ b/zephyr/projects/corsola/src/krabby/usbc_config_tentacruel.c @@ -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. + */ + +/* Tentacruel board-specific USB-C configuration */ + +#include "adc.h" +#include "baseboard_usbc_config.h" +#include "bc12/pi3usb9201_public.h" +#include "charge_manager.h" +#include "charger.h" +#include "console.h" +#include "cros_board_info.h" +#include "driver/charger/rt9490.h" +#include "driver/ppc/rt1739.h" +#include "driver/tcpm/it83xx_pd.h" +#include "driver/usb_mux/ps8743.h" +#include "gpio/gpio_int.h" +#include "hooks.h" +#include "ppc/syv682x_public.h" +#include "usb_mux/it5205_public.h" +#include "usbc_ppc.h" +#include "usbc/ppc.h" + +#include "variant_db_detection.h" +#include <zephyr/logging/log.h> + +#define CPRINTSUSB(format, args...) cprints(CC_USBCHARGE, format, ##args) +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) + +LOG_MODULE_REGISTER(alt_dev_replacement); + +#define BOARD_VERSION_UNKNOWN 0xffffffff + +/* Check board version to decide which ppc/bc12 is used. */ +static bool board_has_syv_ppc(void) +{ + static uint32_t board_version = BOARD_VERSION_UNKNOWN; + + if (board_version == BOARD_VERSION_UNKNOWN) { + if (cbi_get_board_version(&board_version) != EC_SUCCESS) { + LOG_ERR("Failed to get board version."); + board_version = 0; + } + } + + return (board_version >= 3); +} + +static void check_alternate_devices(void) +{ + /* Configure the PPC driver */ + if (board_has_syv_ppc()) + /* Arg is the USB port number */ + PPC_ENABLE_ALTERNATE(0); +} +DECLARE_HOOK(HOOK_INIT, check_alternate_devices, HOOK_PRIO_DEFAULT); + +void bc12_interrupt(enum gpio_signal signal) +{ + usb_charger_task_set_event(0, USB_CHG_EVENT_BC12); +} + +static void board_usbc_init(void) +{ + if (board_has_syv_ppc()) { + /* Enable PPC interrupts. */ + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); + + /* Enable BC1.2 interrupts. */ + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); + } else { + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_usb_c0_ppc)); + } +} +DECLARE_HOOK(HOOK_INIT, board_usbc_init, HOOK_PRIO_POST_DEFAULT); + +void ppc_interrupt(enum gpio_signal signal) +{ + if (signal == GPIO_SIGNAL(DT_NODELABEL(usb_c0_ppc_int_odl))) { + if (board_has_syv_ppc()) { + syv682x_interrupt(0); + } else { + rt1739_interrupt(0); + } + } + if (signal == GPIO_SIGNAL(DT_ALIAS(gpio_usb_c1_ppc_int_odl))) { + syv682x_interrupt(1); + } +} + +int ppc_get_alert_status(int port) +{ + if (port == 0) { + return gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(usb_c0_ppc_int_odl)) == 0; + } + if (port == 1 && corsola_get_db_type() == CORSOLA_DB_TYPEC) { + return gpio_pin_get_dt(GPIO_DT_FROM_ALIAS( + gpio_usb_c1_ppc_int_odl)) == 0; + } + + return 0; +} + +const struct cc_para_t *board_get_cc_tuning_parameter(enum usbpd_port port) +{ + const static struct cc_para_t + cc_parameter[CONFIG_USB_PD_ITE_ACTIVE_PORT_COUNT] = { + { + .rising_time = + IT83XX_TX_PRE_DRIVING_TIME_1_UNIT, + .falling_time = + IT83XX_TX_PRE_DRIVING_TIME_2_UNIT, + }, + { + .rising_time = + IT83XX_TX_PRE_DRIVING_TIME_1_UNIT, + .falling_time = + IT83XX_TX_PRE_DRIVING_TIME_2_UNIT, + }, + }; + + return &cc_parameter[port]; +} + +void board_overcurrent_event(int port, int is_overcurrented) +{ + /* TODO: check correct operation for Corsola */ +} + +uint16_t tcpc_get_alert_status(void) +{ + /* + * C0 & C1: TCPC is embedded in the EC and processes interrupts in the + * chip code (it83xx/intc.c) + */ + return 0; +} + +void board_reset_pd_mcu(void) +{ + /* + * C0 & C1: TCPC is embedded in the EC and processes interrupts in the + * chip code (it83xx/intc.c) + */ +} + +int board_set_active_charge_port(int port) +{ + int i; + int is_valid_port = (port >= 0 && port < board_get_usb_pd_port_count()); + + if (!is_valid_port && port != CHARGE_PORT_NONE) { + return EC_ERROR_INVAL; + } + + if (port == CHARGE_PORT_NONE) { + CPRINTS("Disabling all charger ports"); + + /* Disable all ports. */ + for (i = 0; i < ppc_cnt; i++) { + /* + * Do not return early if one fails otherwise we can + * get into a boot loop assertion failure. + */ + if (ppc_vbus_sink_enable(i, 0)) { + CPRINTS("Disabling C%d as sink failed.", i); + } + } + + return EC_SUCCESS; + } + + /* Check if the port is sourcing VBUS. */ + if (ppc_is_sourcing_vbus(port)) { + CPRINTS("Skip enable C%d", port); + return EC_ERROR_INVAL; + } + + CPRINTS("New charge port: C%d", port); + + /* + * Turn off the other ports' sink path FETs, before enabling the + * requested charge port. + */ + for (i = 0; i < ppc_cnt; i++) { + if (i == port) { + continue; + } + + if (ppc_vbus_sink_enable(i, 0)) { + CPRINTS("C%d: sink path disable failed.", i); + } + } + + /* Enable requested charge port. */ + if (ppc_vbus_sink_enable(port, 1)) { + CPRINTS("C%d: sink path enable failed.", port); + return EC_ERROR_UNKNOWN; + } + + return EC_SUCCESS; +} + +#ifdef CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT +enum adc_channel board_get_vbus_adc(int port) +{ + if (port == 0) { + return ADC_VBUS_C0; + } + if (port == 1) { + return ADC_VBUS_C1; + } + CPRINTSUSB("Unknown vbus adc port id: %d", port); + return ADC_VBUS_C0; +} +#endif /* CONFIG_USB_PD_VBUS_MEASURE_ADC_EACH_PORT */ diff --git a/zephyr/projects/corsola/src/regulator.c b/zephyr/projects/corsola/src/regulator.c deleted file mode 100644 index 35670bda82..0000000000 --- a/zephyr/projects/corsola/src/regulator.c +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "common.h" -#include "bc12/mt6360_public.h" - -/* SD Card */ -int board_regulator_get_info(uint32_t index, char *name, - uint16_t *num_voltages, uint16_t *voltages_mv) -{ - enum mt6360_regulator_id id = index; - - return mt6360_regulator_get_info(id, name, num_voltages, - voltages_mv); -} - -int board_regulator_enable(uint32_t index, uint8_t enable) -{ - enum mt6360_regulator_id id = index; - - return mt6360_regulator_enable(id, enable); -} - -int board_regulator_is_enabled(uint32_t index, uint8_t *enabled) -{ - enum mt6360_regulator_id id = index; - - return mt6360_regulator_is_enabled(id, enabled); -} - -int board_regulator_set_voltage(uint32_t index, uint32_t min_mv, - uint32_t max_mv) -{ - enum mt6360_regulator_id id = index; - - return mt6360_regulator_set_voltage(id, min_mv, max_mv); -} - -int board_regulator_get_voltage(uint32_t index, uint32_t *voltage_mv) -{ - enum mt6360_regulator_id id = index; - - return mt6360_regulator_get_voltage(id, voltage_mv); -} diff --git a/zephyr/projects/corsola/src/usb_pd_policy.c b/zephyr/projects/corsola/src/usb_pd_policy.c index c9015de776..6aa1381c1d 100644 --- a/zephyr/projects/corsola/src/usb_pd_policy.c +++ b/zephyr/projects/corsola/src/usb_pd_policy.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ @@ -20,8 +20,8 @@ #error Corsola reference must have at least one 3.0 A port #endif -#define CPRINTS(format, args...) cprints(CC_USBPD, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ## args) +#define CPRINTS(format, args...) cprints(CC_USBPD, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_USBPD, format, ##args) static int active_aux_port = -1; @@ -78,7 +78,6 @@ void svdm_set_hpd_gpio(int port, int en) } } - __override int svdm_dp_config(int port, uint32_t *payload) { int opos = pd_alt_mode(port, TCPCI_MSG_SOP, USB_SID_DISPLAYPORT); @@ -101,11 +100,11 @@ __override int svdm_dp_config(int port, uint32_t *payload) * (3) plug a monitor to the port-1 dongle. */ - payload[0] = VDO(USB_SID_DISPLAYPORT, 1, - CMD_DP_CONFIG | VDO_OPOS(opos)); - payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */ - 1, /* DPv1.3 signaling */ - 2); /* UFP connected */ + payload[0] = + VDO(USB_SID_DISPLAYPORT, 1, CMD_DP_CONFIG | VDO_OPOS(opos)); + payload[1] = VDO_DP_CFG(pin_mode, /* pin mode */ + 1, /* DPv1.3 signaling */ + 2); /* UFP connected */ return 2; }; @@ -122,9 +121,9 @@ __override void svdm_dp_post_config(int port) */ if (port == active_aux_port) { usb_mux_set(port, mux_mode, USB_SWITCH_CONNECT, - polarity_rm_dts(pd_get_polarity(port))); + polarity_rm_dts(pd_get_polarity(port))); usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL | - USB_PD_MUX_HPD_IRQ_DEASSERTED); + USB_PD_MUX_HPD_IRQ_DEASSERTED); } dp_flags[port] |= DP_FLAGS_DP_ON; @@ -165,17 +164,14 @@ __override int svdm_dp_attention(int port, uint32_t *payload) if (lvl) { set_dp_aux_path_sel(port); - usb_mux_set(port, USB_PD_MUX_DOCK, - USB_SWITCH_CONNECT, + usb_mux_set(port, USB_PD_MUX_DOCK, USB_SWITCH_CONNECT, polarity_rm_dts(pd_get_polarity(port))); } else { - usb_mux_set(port, USB_PD_MUX_USB_ENABLED, - USB_SWITCH_CONNECT, + usb_mux_set(port, USB_PD_MUX_USB_ENABLED, USB_SWITCH_CONNECT, polarity_rm_dts(pd_get_polarity(port))); } - if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && - (irq || lvl)) { + if (chipset_in_state(CHIPSET_STATE_ANY_SUSPEND) && (irq || lvl)) { /* * Wake up the AP. IRQ or level high indicates a DP sink is now * present. @@ -185,14 +181,6 @@ __override int svdm_dp_attention(int port, uint32_t *payload) } } - /* Its initial DP status message prior to config */ - if (!(dp_flags[port] & DP_FLAGS_DP_ON)) { - if (lvl) { - dp_flags[port] |= DP_FLAGS_HPD_HI_PENDING; - } - return 1; - } - #ifdef CONFIG_USB_PD_DP_HPD_GPIO if (irq && !lvl) { /* diff --git a/zephyr/projects/corsola/src/usbc_config.c b/zephyr/projects/corsola/src/usbc_config.c index 1f927dbc21..daf3e5a5cc 100644 --- a/zephyr/projects/corsola/src/usbc_config.c +++ b/zephyr/projects/corsola/src/usbc_config.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ @@ -32,12 +32,13 @@ #include "usb_mux.h" #include "usb_pd_tcpm.h" #include "usb_tc_sm.h" +#include "usbc/usb_muxes.h" #include "usbc_ppc.h" #include "variant_db_detection.h" -#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args) +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) /* a flag for indicating the tasks are inited. */ static bool tasks_inited; @@ -59,6 +60,8 @@ __override uint8_t board_get_usb_pd_port_count(void) } else { return CONFIG_USB_PD_PORT_MAX_COUNT - 1; } + } else if (corsola_get_db_type() == CORSOLA_DB_NONE) { + return CONFIG_USB_PD_PORT_MAX_COUNT - 1; } return CONFIG_USB_PD_PORT_MAX_COUNT; @@ -67,9 +70,10 @@ __override uint8_t board_get_usb_pd_port_count(void) /* USB-A */ void usb_a0_interrupt(enum gpio_signal signal) { - enum usb_charge_mode mode = gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_ap_xhci_init_done)) ? - USB_CHARGE_MODE_ENABLED : USB_CHARGE_MODE_DISABLED; + enum usb_charge_mode mode = gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL( + gpio_ap_xhci_init_done)) ? + USB_CHARGE_MODE_ENABLED : + USB_CHARGE_MODE_DISABLED; const int xhci_stat = gpio_get_level(signal); @@ -96,16 +100,15 @@ void usb_a0_interrupt(enum gpio_signal signal) __override enum pd_dual_role_states pd_get_drp_state_in_s0(void) { - if (gpio_pin_get_dt( - GPIO_DT_FROM_NODELABEL(gpio_ap_xhci_init_done))) { + if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_ap_xhci_init_done))) { return PD_DRP_TOGGLE_ON; } else { return PD_DRP_FORCE_SINK; } } -void board_set_charge_limit(int port, int supplier, int charge_ma, - int max_ma, int charge_mv) +void board_set_charge_limit(int port, int supplier, int charge_ma, int max_ma, + int charge_mv) { charge_set_input_current_limit( MAX(charge_ma, CONFIG_CHARGER_INPUT_CURRENT), charge_mv); @@ -127,8 +130,8 @@ int debounced_hpd; static void ps185_hdmi_hpd_deferred(void) { - const int new_hpd = gpio_pin_get_dt( - GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); + const int new_hpd = + gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); /* HPD status not changed, probably a glitch, just return. */ if (debounced_hpd == new_hpd) { @@ -155,8 +158,7 @@ static void ps185_hdmi_hpd_deferred(void) 0, /* power low? ... no */ (!!DP_FLAGS_DP_ON)); /* update C1 virtual mux */ - usb_mux_set(USBC_PORT_C1, - USB_PD_MUX_DP_ENABLED, + usb_mux_set(USBC_PORT_C1, USB_PD_MUX_DP_ENABLED, USB_SWITCH_DISCONNECT, 0 /* polarity, don't care */); @@ -171,8 +173,8 @@ DECLARE_DEFERRED(ps185_hdmi_hpd_deferred); static void ps185_hdmi_hpd_disconnect_deferred(void) { - const int new_hpd = gpio_pin_get_dt( - GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); + const int new_hpd = + gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd)); if (debounced_hpd == new_hpd && !new_hpd) { dp_status[USBC_PORT_C1] = @@ -188,7 +190,6 @@ static void ps185_hdmi_hpd_disconnect_deferred(void) USB_SWITCH_DISCONNECT, 0 /* polarity, don't care */); } - } DECLARE_DEFERRED(ps185_hdmi_hpd_disconnect_deferred); @@ -256,6 +257,11 @@ static void baseboard_x_ec_gpio2_init(void) static struct tcpm_drv virtual_tcpc_drv = { 0 }; static struct bc12_drv virtual_bc12_drv = { 0 }; + /* no sub board */ + if (corsola_get_db_type() == CORSOLA_DB_NONE) { + return; + } + /* type-c: USB_C1_PPC_INT_ODL / hdmi: PS185_EC_DP_HPD */ gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2)); @@ -281,11 +287,7 @@ static void baseboard_x_ec_gpio2_init(void) bc12_ports[USBC_PORT_C1] = (const struct bc12_config){ .drv = &virtual_bc12_drv }; /* Use virtual mux to notify AP the mainlink direction. */ - usb_muxes[USBC_PORT_C1] = (struct usb_mux){ - .usb_port = USBC_PORT_C1, - .driver = &virtual_usb_mux_driver, - .hpd_update = &virtual_hpd_update, - }; + USB_MUX_ENABLE_ALTERNATIVE(usb_mux_chain_1_hdmi_db); /* * If a HDMI DB is attached, C1 port tasks will be exiting in that diff --git a/zephyr/projects/corsola/src/variant_db_detection.c b/zephyr/projects/corsola/src/variant_db_detection.c index e5058bdcd5..6099d86bdd 100644 --- a/zephyr/projects/corsola/src/variant_db_detection.c +++ b/zephyr/projects/corsola/src/variant_db_detection.c @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ @@ -7,13 +7,14 @@ #include <zephyr/drivers/gpio.h> #include "console.h" +#include "cros_cbi.h" #include "gpio/gpio_int.h" #include "hooks.h" #include "variant_db_detection.h" -#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ## args) -#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ## args) +#define CPRINTS(format, args...) cprints(CC_SYSTEM, format, ##args) +#define CPRINTF(format, args...) cprintf(CC_SYSTEM, format, ##args) static void corsola_db_config(enum corsola_db_type type) { @@ -21,7 +22,7 @@ static void corsola_db_config(enum corsola_db_type type) case CORSOLA_DB_HDMI: /* EC_X_GPIO1 */ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_en_hdmi_pwr), - GPIO_OUTPUT_HIGH); + GPIO_OUTPUT_HIGH); /* X_EC_GPIO2 */ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_ec_dp_hpd), GPIO_INPUT); @@ -29,7 +30,7 @@ static void corsola_db_config(enum corsola_db_type type) GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2)); /* EC_X_GPIO3 */ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_ps185_pwrdn_odl), - GPIO_OUTPUT_HIGH | GPIO_OPEN_DRAIN); + GPIO_OUTPUT_HIGH | GPIO_OPEN_DRAIN); return; case CORSOLA_DB_TYPEC: /* EC_X_GPIO1 */ @@ -42,9 +43,17 @@ static void corsola_db_config(enum corsola_db_type type) gpio_enable_dt_interrupt( GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2)); /* EC_X_GPIO3 */ - gpio_pin_configure_dt( - GPIO_DT_FROM_ALIAS(gpio_usb_c1_dp_in_hpd), - GPIO_OUTPUT_LOW); + gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_dp_in_hpd), + GPIO_OUTPUT_LOW); + return; + case CORSOLA_DB_NONE: + /* Set floating pins as input with PU to prevent leakage */ + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_x_gpio1), + GPIO_INPUT | GPIO_PULL_UP); + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_x_ec_gpio2), + GPIO_INPUT | GPIO_PULL_UP); + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_ec_x_gpio3), + GPIO_INPUT | GPIO_PULL_UP); return; default: break; @@ -53,9 +62,13 @@ static void corsola_db_config(enum corsola_db_type type) enum corsola_db_type corsola_get_db_type(void) { - static enum corsola_db_type db = CORSOLA_DB_NONE; +#if DT_NODE_EXISTS(DT_NODELABEL(db_config)) + int ret; + uint32_t val; +#endif + static enum corsola_db_type db = CORSOLA_DB_UNINIT; - if (db != CORSOLA_DB_NONE) { + if (db != CORSOLA_DB_UNINIT) { return db; } @@ -65,9 +78,33 @@ enum corsola_db_type corsola_get_db_type(void) db = CORSOLA_DB_TYPEC; } +/* Detect for no sub board case by FW_CONFIG */ +#if DT_NODE_EXISTS(DT_NODELABEL(db_config)) + ret = cros_cbi_get_fw_config(DB, &val); + if (ret != 0) { + CPRINTS("Error retrieving CBI FW_CONFIG field %d", DB); + } else if (val == DB_NONE) { + db = CORSOLA_DB_NONE; + } +#endif + corsola_db_config(db); - CPRINTS("Detect %s DB", db == CORSOLA_DB_HDMI ? "HDMI" : "TYPEC"); + switch (db) { + case CORSOLA_DB_NONE: + CPRINTS("Detect %s DB", "NONE"); + break; + case CORSOLA_DB_TYPEC: + CPRINTS("Detect %s DB", "TYPEC"); + break; + case CORSOLA_DB_HDMI: + CPRINTS("Detect %s DB", "HDMI"); + break; + default: + CPRINTS("DB UNINIT"); + break; + } + return db; } diff --git a/zephyr/projects/corsola/thermistor_tentacruel.dts b/zephyr/projects/corsola/thermistor_tentacruel.dts new file mode 100644 index 0000000000..f9e5306f24 --- /dev/null +++ b/zephyr/projects/corsola/thermistor_tentacruel.dts @@ -0,0 +1,140 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + thermistor_rt9490: thermistor-rt9490 { + status = "okay"; + compatible = "cros-ec,thermistor"; + scaling-factor = <3>; + num-pairs = <21>; + steinhart-reference-mv = <4900>; + steinhart-reference-res = <10000>; + + sample-datum-0 { + milivolt = <(731 / 3)>; + temp = <0>; + sample-index = <0>; + }; + + sample-datum-1 { + milivolt = <(708 / 3)>; + temp = <5>; + sample-index = <1>; + }; + + sample-datum-2 { + milivolt = <(682 / 3)>; + temp = <10>; + sample-index = <2>; + }; + + sample-datum-3 { + milivolt = <(653 / 3)>; + temp = <15>; + sample-index = <3>; + }; + + sample-datum-4 { + milivolt = <(622 / 3)>; + temp = <20>; + sample-index = <4>; + }; + + sample-datum-5 { + milivolt = <(589 / 3)>; + temp = <25>; + sample-index = <5>; + }; + + sample-datum-6 { + milivolt = <(554 / 3)>; + temp = <30>; + sample-index = <6>; + }; + + sample-datum-7 { + milivolt = <(519 / 3)>; + temp = <35>; + sample-index = <7>; + }; + + sample-datum-8 { + milivolt = <(483 / 3)>; + temp = <40>; + sample-index = <8>; + }; + + sample-datum-9 { + milivolt = <(446 / 3)>; + temp = <45>; + sample-index = <9>; + }; + + sample-datum-10 { + milivolt = <(411 / 3)>; + temp = <50>; + sample-index = <10>; + }; + sample-datum-11 { + milivolt = <(376 / 3)>; + temp = <55>; + sample-index = <11>; + }; + + sample-datum-12 { + milivolt = <(343 / 3)>; + temp = <60>; + sample-index = <12>; + }; + + sample-datum-13 { + milivolt = <(312 / 3)>; + temp = <65>; + sample-index = <13>; + }; + + sample-datum-14 { + milivolt = <(284 / 3)>; + temp = <70>; + sample-index = <14>; + }; + + sample-datum-15 { + milivolt = <(257 / 3)>; + temp = <75>; + sample-index = <15>; + }; + + sample-datum-16 { + milivolt = <(232 / 3)>; + temp = <80>; + sample-index = <16>; + }; + + sample-datum-17 { + milivolt = <(209 / 3)>; + temp = <85>; + sample-index = <17>; + }; + + sample-datum-18 { + milivolt = <(188 / 3)>; + temp = <90>; + sample-index = <18>; + }; + + sample-datum-19 { + milivolt = <(169 / 3)>; + temp = <95>; + sample-index = <19>; + }; + + sample-datum-20 { + milivolt = <(152 / 3)>; + temp = <100>; + sample-index = <20>; + }; + }; +}; diff --git a/zephyr/projects/corsola/usba.dts b/zephyr/projects/corsola/usba.dts index 13c900b1b6..2ecb3b7d5a 100644 --- a/zephyr/projects/corsola/usba.dts +++ b/zephyr/projects/corsola/usba.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/projects/corsola/usba_steelix.dts b/zephyr/projects/corsola/usba_steelix.dts index 0671457fe9..0ddd67f664 100644 --- a/zephyr/projects/corsola/usba_steelix.dts +++ b/zephyr/projects/corsola/usba_steelix.dts @@ -1,4 +1,4 @@ -/* Copyright 2022 The Chromium OS Authors. All rights reserved. +/* Copyright 2022 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ diff --git a/zephyr/projects/corsola/usbc_kingler.dts b/zephyr/projects/corsola/usbc_kingler.dts index 6703498ad5..18bc6ce303 100644 --- a/zephyr/projects/corsola/usbc_kingler.dts +++ b/zephyr/projects/corsola/usbc_kingler.dts @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ @@ -8,23 +8,49 @@ #address-cells = <1>; #size-cells = <0>; - /* TODO(b/227359727): kingler: convert USB-C configuration to - * devicetree - */ port0@0 { compatible = "named-usbc-port"; reg = <0>; + bc12 = <&bc12_port0>; + tcpc = <&tcpc_port0>; + ppc = <&ppc_port0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&anx7447_mux_0 &virtual_mux_0>; + }; + }; - chg { - compatible = "intersil,isl923x"; - status = "okay"; - port = <&i2c_charger>; + port0-muxes { + anx7447_mux_0: anx7447-mux-0 { + compatible = "analogix,usbc-mux-anx7447"; + }; + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; }; }; port1@1 { compatible = "named-usbc-port"; reg = <1>; + bc12 = <&bc12_port1>; + tcpc = <&tcpc_port1>; + ppc = <&ppc_port1>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; + }; + usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; }; }; }; diff --git a/zephyr/projects/corsola/usbc_krabby.dts b/zephyr/projects/corsola/usbc_krabby.dts index 2156782dbc..a72864da35 100644 --- a/zephyr/projects/corsola/usbc_krabby.dts +++ b/zephyr/projects/corsola/usbc_krabby.dts @@ -1,4 +1,4 @@ -/* Copyright 2021 The Chromium OS Authors. All rights reserved. +/* 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. */ @@ -11,32 +11,16 @@ port0@0 { compatible = "named-usbc-port"; reg = <0>; - bc12 { - compatible = "richtek,rt1739-bc12"; - status = "okay"; + bc12 = <&bc12_ppc_port0>; + ppc = <&bc12_ppc_port0>; + tcpc = <&usbpd0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&it5205_mux_0 &virtual_mux_0>; }; - ppc { - compatible = "richtek,rt1739-ppc"; - status = "okay"; - port = <&i2c_usb_c0>; - i2c-addr-flags = "RT1739_ADDR1_FLAGS"; - }; - tcpc { - compatible = "ite,it8xxx2-tcpc"; - }; - chg { - compatible = "richtek,rt9490"; - status = "okay"; - port = <&i2c_charger>; - }; - usb-muxes = <&it5205_mux_0 &virtual_mux_0>; }; port0-muxes { - it5205_mux_0: it5205-mux-0 { - compatible = "ite,it5205"; - port = <&i2c_usb_mux0>; - i2c-addr-flags = "IT5205_I2C_ADDR1_FLAGS"; - }; virtual_mux_0: virtual-mux-0 { compatible = "cros-ec,usbc-mux-virtual"; }; @@ -45,32 +29,31 @@ port1@1 { compatible = "named-usbc-port"; reg = <1>; - bc12 { - compatible = "richtek,rt9490-bc12"; - status = "okay"; - irq = <&int_usb_c1_bc12_charger>; - }; - ppc { - compatible = "silergy,syv682x"; - status = "okay"; - port = <&i2c_usb_c1>; - i2c-addr-flags = "SYV682X_ADDR0_FLAGS"; - frs_en_gpio = <&gpio_ec_x_gpio1>; - }; - tcpc { - compatible = "ite,it8xxx2-tcpc"; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&usbpd1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&tusb1064_mux_1 &virtual_mux_1>; + }; + usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; }; - usb-muxes = <&tusb1064_mux_1 &virtual_mux_1>; }; port1-muxes { - tusb1064_mux_1: tusb1064-mux-1 { - compatible = "ti,tusb1064"; - port = <&i2c_usb_mux1>; - i2c-addr-flags = "TUSB1064_I2C_ADDR0_FLAGS"; - }; virtual_mux_1: virtual-mux-1 { compatible = "cros-ec,usbc-mux-virtual"; }; }; }; }; + +&usbpd0 { + status = "okay"; +}; + +&usbpd1 { + status = "okay"; +}; diff --git a/zephyr/projects/corsola/usbc_magikarp.dts b/zephyr/projects/corsola/usbc_magikarp.dts new file mode 100644 index 0000000000..0e0473cd86 --- /dev/null +++ b/zephyr/projects/corsola/usbc_magikarp.dts @@ -0,0 +1,59 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_ppc_port0>; + ppc = <&bc12_ppc_port0>; + tcpc = <&usbpd0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&it5205_mux_0 &virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&usbpd1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; + }; + usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; + +&usbpd0 { + status = "okay"; +}; + +&usbpd1 { + status = "okay"; +}; diff --git a/zephyr/projects/corsola/usbc_tentacruel.dts b/zephyr/projects/corsola/usbc_tentacruel.dts new file mode 100644 index 0000000000..bb105a8e08 --- /dev/null +++ b/zephyr/projects/corsola/usbc_tentacruel.dts @@ -0,0 +1,60 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + usbc { + #address-cells = <1>; + #size-cells = <0>; + + port0@0 { + compatible = "named-usbc-port"; + reg = <0>; + bc12 = <&bc12_port0>; + ppc = <&bc12_ppc_port0>; + ppc_alt = <&ppc_port0>; + tcpc = <&usbpd0>; + chg = <&charger>; + usb-mux-chain-0 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&it5205_mux_0 &virtual_mux_0>; + }; + }; + port0-muxes { + virtual_mux_0: virtual-mux-0 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + + port1@1 { + compatible = "named-usbc-port"; + reg = <1>; + bc12 = <&bc12_port1>; + ppc = <&ppc_port1>; + tcpc = <&usbpd1>; + usb-mux-chain-1 { + compatible = "cros-ec,usb-mux-chain"; + usb-muxes = <&ps8743_mux_1 &virtual_mux_1>; + }; + usb_mux_chain_1_hdmi_db: usb-mux-chain-1-hdmi-db { + compatible = "cros-ec,usb-mux-chain"; + alternative-chain; + usb-muxes = <&virtual_mux_1>; + }; + }; + port1-muxes { + virtual_mux_1: virtual-mux-1 { + compatible = "cros-ec,usbc-mux-virtual"; + }; + }; + }; +}; + +&usbpd0 { + status = "okay"; +}; + +&usbpd1 { + status = "okay"; +}; |