From 0e580733f98bbc62be8ec3c7bfdad9300fb2cb9f Mon Sep 17 00:00:00 2001 From: wen zhang Date: Wed, 12 Apr 2023 20:06:19 +0800 Subject: screebo: Initial Zephyr EC image Create the initial Zephyr EC image for the screebo variant based on the rex reference board. More changes will be added later. BUG=b:276814951 BRANCH=none TEST=zmake build screebo Change-Id: I5a3f921b01bf35976c01de26acd23a2248eaea6c Signed-off-by: wen zhang Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4416520 Reviewed-by: YH Lin Reviewed-by: caveh jalali Reviewed-by: Siyu Qin --- zephyr/dts/bindings/adc/named-adc-channels.yaml | 2 + zephyr/program/rex/BUILD.py | 4 + zephyr/program/rex/CMakeLists.txt | 3 + zephyr/program/rex/Kconfig | 6 + zephyr/program/rex/screebo/CMakeLists.txt | 6 + zephyr/program/rex/screebo/project.conf | 34 +++++ zephyr/program/rex/screebo/project.overlay | 191 ++++++++++++++++++++++++ zephyr/program/rex/screebo/src/keyboard.c | 28 ++++ zephyr/program/rex/screebo/src/usb_config.c | 29 ++++ zephyr/program/rex/screebo/temp_sensors.dtsi | 103 +++++++++++++ 10 files changed, 406 insertions(+) create mode 100644 zephyr/program/rex/screebo/CMakeLists.txt create mode 100644 zephyr/program/rex/screebo/project.conf create mode 100644 zephyr/program/rex/screebo/project.overlay create mode 100644 zephyr/program/rex/screebo/src/keyboard.c create mode 100644 zephyr/program/rex/screebo/src/usb_config.c create mode 100644 zephyr/program/rex/screebo/temp_sensors.dtsi diff --git a/zephyr/dts/bindings/adc/named-adc-channels.yaml b/zephyr/dts/bindings/adc/named-adc-channels.yaml index 55c7b59a88..17e51c7c32 100644 --- a/zephyr/dts/bindings/adc/named-adc-channels.yaml +++ b/zephyr/dts/bindings/adc/named-adc-channels.yaml @@ -98,6 +98,8 @@ child-binding: - ADC_TEMP_SENSOR_2 - ADC_TEMP_SENSOR_3 - ADC_TEMP_SENSOR_4 + - ADC_TEMP_SENSOR_5 + - ADC_TEMP_SENSOR_6 - ADC_TEMP_SENSOR_CHARGER - ADC_TEMP_SENSOR_DDR_SOC - ADC_TEMP_SENSOR_FAN diff --git a/zephyr/program/rex/BUILD.py b/zephyr/program/rex/BUILD.py index 89aee8b06d..1b0fe31509 100644 --- a/zephyr/program/rex/BUILD.py +++ b/zephyr/program/rex/BUILD.py @@ -44,3 +44,7 @@ register_rex_project( here / "rex-sans-sensors" / "project.conf", ], ) + +register_rex_project( + project_name="screebo", +) diff --git a/zephyr/program/rex/CMakeLists.txt b/zephyr/program/rex/CMakeLists.txt index 1962569692..2790a99146 100644 --- a/zephyr/program/rex/CMakeLists.txt +++ b/zephyr/program/rex/CMakeLists.txt @@ -13,4 +13,7 @@ zephyr_library_sources_ifdef(CONFIG_PLATFORM_EC_USBC "src/usb_pd_policy.c") if(DEFINED CONFIG_BOARD_REX) project(rex) add_subdirectory(rex) +elseif(DEFINED CONFIG_BOARD_SCREEBO) + project(screebo) + add_subdirectory(screebo) endif() diff --git a/zephyr/program/rex/Kconfig b/zephyr/program/rex/Kconfig index f61e27ad7d..723febc6d4 100644 --- a/zephyr/program/rex/Kconfig +++ b/zephyr/program/rex/Kconfig @@ -8,6 +8,12 @@ config BOARD_REX Build Google Rex reference board. The board uses Nuvoton NPCX9 chip as the EC. +config BOARD_SCREEBO + bool "Google Screebo Board" + help + Build Google Screebo variant board. The board uses Nuvoton + NPCX9 chip as the EC. + module = REX module-str = Rex board-specific code source "subsys/logging/Kconfig.template.log_config" diff --git a/zephyr/program/rex/screebo/CMakeLists.txt b/zephyr/program/rex/screebo/CMakeLists.txt new file mode 100644 index 0000000000..16a5240f3d --- /dev/null +++ b/zephyr/program/rex/screebo/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright 2023 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +cros_ec_library_include_directories_ifdef(CONFIG_BOARD_SCREEBO include) +zephyr_library_sources("src/keyboard.c" "src/usb_config.c") diff --git a/zephyr/program/rex/screebo/project.conf b/zephyr/program/rex/screebo/project.conf new file mode 100644 index 0000000000..c3ee418874 --- /dev/null +++ b/zephyr/program/rex/screebo/project.conf @@ -0,0 +1,34 @@ +# Copyright 2023 The ChromiumOS Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# Screebo-NPCX9 variant-board-specific Kconfig settings. +CONFIG_BOARD_SCREEBO=y + +# Battery Configuration +CONFIG_PLATFORM_EC_BATT_HOST_FULL_FACTOR=99 +CONFIG_PLATFORM_EC_I2C_NACK_RETRY_COUNT=10 +CONFIG_PLATFORM_EC_SMBUS_PEC=y + +# Buttons +CONFIG_PLATFORM_EC_VOLUME_BUTTONS=n + +# Keyboard +CONFIG_PLATFORM_EC_KEYBOARD_REFRESH_ROW3=y +CONFIG_PLATFORM_EC_KEYBOARD_PWRBTN_ASSERTS_KSI3=y + +# No sensors +CONFIG_PLATFORM_EC_ACCELGYRO_LSM6DSO=n +CONFIG_PLATFORM_EC_ACCEL_LIS2DW12=n +CONFIG_PLATFORM_EC_ACCEL_FIFO=n +CONFIG_PLATFORM_EC_ALS_TCS3400=n +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCELS=n +CONFIG_PLATFORM_EC_CONSOLE_CMD_ACCEL_INFO=n +CONFIG_PLATFORM_EC_CONSOLE_CMD_I2C_SPEED=n +CONFIG_PLATFORM_EC_DYNAMIC_MOTION_SENSOR_COUNT=n +CONFIG_PLATFORM_EC_GMR_TABLET_MODE=n +CONFIG_PLATFORM_EC_LID_ANGLE=n +CONFIG_PLATFORM_EC_LID_ANGLE_UPDATE=n +CONFIG_PLATFORM_EC_SENSOR_TIGHT_TIMESTAMPS=n +CONFIG_PLATFORM_EC_TABLET_MODE=n +CONFIG_PLATFORM_EC_TABLET_MODE_SWITCH=n diff --git a/zephyr/program/rex/screebo/project.overlay b/zephyr/program/rex/screebo/project.overlay new file mode 100644 index 0000000000..35156be4f4 --- /dev/null +++ b/zephyr/program/rex/screebo/project.overlay @@ -0,0 +1,191 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Rex program common DTSI includes */ +#include "../fan.dtsi" +#include "../generated.dtsi" +#include "../interrupts.dtsi" +#include "../keyboard.dtsi" +#include "../power_signals.dtsi" +#include "../rex.dtsi" +#include "../usbc.dtsi" + +/* Screebo project DTS includes */ +#include "temp_sensors.dtsi" + +/ { + named-gpios { + /delete-node/ led_3_l; + /delete-node/ led_4_l; + /delete-node/ ec-i2c-sensor-scl; + /delete-node/ ec-i2c-sensor-sda; + /delete-node/ ec_imu_int_r_l; + /delete-node/ ec_als_rgb_int_r_l; + /delete-node/ ec_accel_int_r_l; + /delete-node/ ec_volup_btn_odl; + /delete-node/ ec_voldn_btn_odl; + /delete-node/ tablet_mode_l; + /delete-node/ ec_spare_gpiob1; + /delete-node/ ec_spare_gpioa2; + /delete-node/ usb_c1_rst_odl; + + gpio_usb_c1_rt_3p3_sx_en: usb_c1_rt_3p3_sx_en { + gpios = <&gpiob 1 GPIO_OUTPUT_LOW>; + }; + gpio_usb_c1_rst_odl: usb_c1_rst_odl { + gpios = <&gpio3 7 (GPIO_ODR_HIGH | GPIO_ACTIVE_LOW)>; + }; + gpio_usb_c1_rt_int_odl: usb_c1_rt_int_odl { + gpios = <&gpio7 2 GPIO_INPUT>; + }; + gpio_usb_a1_oc_pu_en: usb_a1_oc_pu_en { + gpios = <&gpioc 2 GPIO_OUTPUT_LOW>; + }; + gpio_usb_a_low_pwr_od: usb_a_low_pwr_od { + gpios = <&gpioa 2 GPIO_OUTPUT_LOW>; + }; + ioex_usb_c1_rt_rst_ls_l: usb_c1_rt_rst_ls_l { + gpios = <&ioex_c1_port0 7 GPIO_OUTPUT>; + }; + ioex_usb_c1_frs_en: usb_c1_frs_en { + gpios = <&ioex_c1_port0 6 GPIO_OUTPUT_LOW>; + }; + + }; + + unused-pins { + compatible = "unused-gpios"; + + unused-gpios = + <&gpiob 4 0>, + <&gpiob 5 0>, + <&gpio5 6 0>, + <&gpiod 4 0>, + <&gpio8 1 0>, + <&gpio9 7 0>, + <&gpio9 3 0>, + <&gpio9 5 0>, + <&gpio6 0 0>; + }; + + gpio-interrupts { + /delete-node/ ec_imu; + /delete-node/ ec_als_rgb; + /delete-node/ ec_accel; + /delete-node/ volume_up; + /delete-node/ volume_down; + usb_c0_ppc { + handler = "screebo_ppc_interrupt"; + }; + usb_c1_ppc { + handler = "screebo_ppc_interrupt"; + }; + }; + + named-i2c-ports { + /delete-node/ ec_i2c_sensor_scl_r; + }; + + batteries { + default_battery: cdt_c340152 { + compatible = "cdt,c340152", "battery-smart"; + }; + }; +}; + +/* ADC and GPIO alt-function specifications */ +&adc0 { + pinctrl-0 = <&adc0_chan0_gp45 + &adc0_chan1_gp44 + &adc0_chan3_gp42 + &adc0_chan7_gpe1 + &adc0_chan8_gpf1 + &adc0_chan11_gpc7>; + pinctrl-names = "default"; +}; + +&i2c0_0 { + status = "disabled"; +}; +&i2c_ctrl0 { + status = "disabled"; +}; + +&i2c3_0 { + usb_c1_hb_retimer: jhl9040r-c0@58 { + compatible = "intel,jhl9040r"; + reg = <0x58>; + ls-en-pin = <&gpio_usb_c1_rt_3p3_sx_en>; + int-pin = <&gpio_usb_c1_rt_int_odl>; + reset-pin = <&ioex_usb_c1_rt_rst_ls_l>; + }; +}; + +&i2c4_1 { + /delete-node/ ps8xxx@b; + + tcpc_port1: nct38xx@73 { + compatible = "nuvoton,nct38xx"; + gpio-dev = <&nct3807_C1>; + reg = <0x73>; + tcpc-flags = <( + TCPC_FLAGS_TCPCI_REV2_0 | + TCPC_FLAGS_TCPCI_REV2_0_NO_VSAFE0V)>; + /* a duplicate of the <&gpio_usb_c1_tcpc_int_odl> node in + * "named-gpios". This is the Zephyr preferred style, + * the "named-gpios" node will be dealt with at a later date. + */ + irq-gpios = <&gpio3 4 GPIO_ACTIVE_LOW>; + /* a duplicate of the <&gpio_usb_c1_rst_odl> node in + * "named-gpios". This is the Zephyr preferred style, + * the "named-gpios" node will be dealt with at a later date. + */ + rst-gpios = <&gpio3 7 (GPIO_OPEN_DRAIN | GPIO_ACTIVE_LOW)>; + }; + + nct3807_C1: nct3807_C1@73 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nuvoton,nct38xx-gpio"; + reg = <0x73>; + label = "NCT3807_C1"; + + ioex_c1_port0: gpio@0 { + compatible = "nuvoton,nct38xx-gpio-port"; + reg = <0x0>; + label = "NCT3807_C1_GPIO0"; + gpio-controller; + #gpio-cells = <2>; + ngpios = <8>; + pin_mask = <0xff>; + pinmux_mask = <0xf7>; + }; + }; + + nct3808_alert_1 { + compatible = "nuvoton,nct38xx-gpio-alert"; + irq-gpios = <&gpio3 4 GPIO_ACTIVE_LOW>; + nct38xx-dev = <&nct3807_C1>; + label = "NCT3807_ALERT_0"; + }; +}; + +&i2c6_1 { + /delete-node/ nx20p348x@72; + + ppc_port1_syv: ppc_syv@40 { + compatible = "silergy,syv682x"; + status = "okay"; + reg = <0x40>; + frs_en_gpio = <&ioex_usb_c1_frs_en>; + }; +}; + +&usbc_port1 { + ppc = <&ppc_port1_syv>; + usb-mux-chain-1 { + usb-muxes = <&usb_c1_hb_retimer &virtual_mux_c1>; + }; +}; diff --git a/zephyr/program/rex/screebo/src/keyboard.c b/zephyr/program/rex/screebo/src/keyboard.c new file mode 100644 index 0000000000..5a9818ba7a --- /dev/null +++ b/zephyr/program/rex/screebo/src/keyboard.c @@ -0,0 +1,28 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" + +static const struct ec_response_keybd_config screebo_kb = { + .num_top_row_keys = 10, + .action_keys = { + TK_BACK, /* T1 */ + TK_REFRESH, /* T2 */ + TK_FULLSCREEN, /* T3 */ + TK_OVERVIEW, /* T4 */ + TK_SNAPSHOT, /* T5 */ + TK_BRIGHTNESS_DOWN, /* T6 */ + TK_BRIGHTNESS_UP, /* T7 */ + TK_VOL_MUTE, /* T8 */ + TK_VOL_DOWN, /* T9 */ + TK_VOL_UP, /* T10 */ + }, +}; + +__override const struct ec_response_keybd_config * +board_vivaldi_keybd_config(void) +{ + return &screebo_kb; +} diff --git a/zephyr/program/rex/screebo/src/usb_config.c b/zephyr/program/rex/screebo/src/usb_config.c new file mode 100644 index 0000000000..41653832bd --- /dev/null +++ b/zephyr/program/rex/screebo/src/usb_config.c @@ -0,0 +1,29 @@ +/* Copyright 2023 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Screebo board-specific USB-C configuration */ + +#include "ppc/syv682x_public.h" +#include "usbc_ppc.h" + +#include + +/* USB-C ports */ +enum usbc_port { USBC_PORT_C0 = 0, USBC_PORT_C1, USBC_PORT_COUNT }; +BUILD_ASSERT(USBC_PORT_COUNT == CONFIG_USB_PD_PORT_MAX_COUNT); + +void screebo_ppc_interrupt(enum gpio_signal signal) +{ + switch (signal) { + case GPIO_USB_C0_PPC_INT_ODL: + syv682x_interrupt(USBC_PORT_C0); + break; + case GPIO_USB_C1_PPC_INT_ODL: + syv682x_interrupt(USBC_PORT_C1); + break; + default: + break; + } +} diff --git a/zephyr/program/rex/screebo/temp_sensors.dtsi b/zephyr/program/rex/screebo/temp_sensors.dtsi new file mode 100644 index 0000000000..f4747b96a5 --- /dev/null +++ b/zephyr/program/rex/screebo/temp_sensors.dtsi @@ -0,0 +1,103 @@ +/* Copyright 2022 The ChromiumOS Authors + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include + +/ { + named-adc-channels { + /delete-node/ temp_sensor_1; + /delete-node/ temp_sensor_2; + /delete-node/ temp_sensor_3; + /delete-node/ temp_sensor_4; + + adc_ddr_soc: ddr_soc { + enum-name = "ADC_TEMP_SENSOR_1"; + io-channels = <&adc0 0>; + }; + adc_vcc: vcc { + enum-name = "ADC_TEMP_SENSOR_2"; + io-channels = <&adc0 1>; + }; + adc_ambient: ambient { + enum-name = "ADC_TEMP_SENSOR_3"; + io-channels = <&adc0 8>; + }; + adc_charger: charger { + enum-name = "ADC_TEMP_SENSOR_4"; + io-channels = <&adc0 7>; + }; + adc_hw_shutdown: hw_shutdown { + enum-name = "ADC_TEMP_SENSOR_5"; + io-channels = <&adc0 3>; + }; + adc_typec: typec { + enum-name = "ADC_TEMP_SENSOR_6"; + io-channels = <&adc0 11>; + }; + }; + + temp_ddr_soc: ddr_soc { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_ddr_soc>; + }; + temp_ambient: ambient { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_ambient>; + }; + temp_charger: charger { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_charger>; + }; + temp_vcc: vcc { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_vcc>; + }; + temp_hw_shutdown: hw_shutdown { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_hw_shutdown>; + }; + temp_typec: typec { + compatible = "cros-ec,temp-sensor-thermistor"; + thermistor = <&thermistor_3V3_30K9_47K_4050B>; + adc = <&adc_typec>; + }; + + named-temp-sensors { + compatible = "cros-ec,temp-sensors"; + ddr_soc { + temp_fan_off = <35>; + temp_fan_max = <60>; + temp_host_high = <90>; + temp_host_halt = <95>; + temp_host_release_high = <85>; + sensor = <&temp_ddr_soc>; + }; + ambient { + temp_fan_off = <30>; + temp_fan_max = <50>; + temp_host_high = <65>; + temp_host_halt = <75>; + temp_host_release_high = <60>; + sensor = <&temp_ambient>; + }; + charger { + temp_fan_off = <35>; + temp_fan_max = <85>; + temp_host_high = <100>; + temp_host_halt = <110>; + temp_host_release_high = <95>; + sensor = <&temp_charger>; + }; + }; +}; + +&thermistor_3V3_30K9_47K_4050B { + status = "okay"; +}; -- cgit v1.2.1