diff options
author | Andrew McRae <amcrae@google.com> | 2022-01-23 15:19:43 +1100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-01-27 09:00:57 +0000 |
commit | d9b5f462795bf9f474edc9d2631d61e5fcd60463 (patch) | |
tree | 4ad3fb3ca5bda9d8b993562126337f17c0d26b79 | |
parent | 3ea46e5eeba51d946e4900c923e2b38c7dd3a76c (diff) | |
download | chrome-ec-d9b5f462795bf9f474edc9d2631d61e5fcd60463.tar.gz |
corsola: Migrate interrupt config to new framework
Migrate the corsola projects {kingler, krabby} to
the new interrupt config framework.
BUG=b:215258549
TEST=zmake configure -b {kingler,krabby}
BRANCH=none
Signed-off-by: Andrew McRae <amcrae@google.com>
Change-Id: I11fd96022199a56768c12a81ee813177f5bfa0bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3413593
Reviewed-by: Eric Yilun Lin <yllin@google.com>
-rw-r--r-- | zephyr/projects/corsola/BUILD.py | 2 | ||||
-rw-r--r-- | zephyr/projects/corsola/gpio_kingler.dts | 39 | ||||
-rw-r--r-- | zephyr/projects/corsola/gpio_krabby.dts | 15 | ||||
-rw-r--r-- | zephyr/projects/corsola/include/gpio_map.h | 170 | ||||
-rw-r--r-- | zephyr/projects/corsola/interrupts_kingler.dts | 86 | ||||
-rw-r--r-- | zephyr/projects/corsola/interrupts_krabby.dts | 86 | ||||
-rw-r--r-- | zephyr/projects/corsola/src/kingler/usbc_config.c | 20 | ||||
-rw-r--r-- | zephyr/projects/corsola/src/krabby/usbc_config.c | 29 | ||||
-rw-r--r-- | zephyr/projects/corsola/src/usbc_config.c | 5 |
9 files changed, 264 insertions, 188 deletions
diff --git a/zephyr/projects/corsola/BUILD.py b/zephyr/projects/corsola/BUILD.py index c24220d241..a03dfe7ebe 100644 --- a/zephyr/projects/corsola/BUILD.py +++ b/zephyr/projects/corsola/BUILD.py @@ -30,6 +30,7 @@ register_corsola_project( here / "battery_krabby.dts", here / "gpio_krabby.dts", here / "i2c_krabby.dts", + here / "interrupts_krabby.dts", here / "cbi_eeprom.dts", here / "motionsense_krabby.dts", here / "pwm_krabby.dts", @@ -44,6 +45,7 @@ register_corsola_project( here / "adc_kingler.dts", here / "battery_kingler.dts", here / "i2c_kingler.dts", + here / "interrupts_kingler.dts", here / "cbi_eeprom.dts", here / "gpio_kingler.dts", here / "motionsense_kingler.dts", diff --git a/zephyr/projects/corsola/gpio_kingler.dts b/zephyr/projects/corsola/gpio_kingler.dts index 84284b72f9..d3dc66124d 100644 --- a/zephyr/projects/corsola/gpio_kingler.dts +++ b/zephyr/projects/corsola/gpio_kingler.dts @@ -25,16 +25,19 @@ gpios = <&gpio4 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; }; ap_ec_warm_rst_req: ap_ec_warm_rst_req { + #gpio-cells = <0>; gpios = <&gpio5 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | GPIO_ACTIVE_HIGH)>; enum-name = "GPIO_AP_EC_WARM_RST_REQ"; }; ap_ec_wdtrst_l: ap_ec_wdtrst_l { + #gpio-cells = <0>; gpios = <&gpio5 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_EC_WDTRST_L"; }; ap_in_sleep_l: ap_in_sleep_l { + #gpio-cells = <0>; gpios = <&gpio5 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_IN_SLEEP_L"; @@ -86,6 +89,7 @@ enum-name = "GPIO_EC_PEN_CHG_DIS_ODL"; }; gpio_ec_wp_l: ec_wp_odl { + #gpio-cells = <0>; gpios = <&gpioe 3 (GPIO_OPEN_DRAIN)>; enum-name = "GPIO_WP_L"; }; @@ -105,7 +109,8 @@ gpios = <&gpio1 7 GPIO_OUT_LOW>; enum-name = "GPIO_KBD_KSO2"; }; - usb_c0_bc12_int_odl { + gpio_usb_c0_bc12_int_odl: usb_c0_bc12_int_odl { + #gpio-cells = <0>; gpios = <&gpio8 3 GPIO_INPUT>; enum-name = "GPIO_USB_C0_BC12_INT_ODL"; }; @@ -121,15 +126,18 @@ gpios = <&gpio7 7 GPIO_INPUT>; enum-name = "GPIO_EC_RST_ODL"; }; - lid_open { + gpio_lid_open: lid_open { + #gpio-cells = <0>; gpios = <&gpiod 2 GPIO_INPUT>; enum-name = "GPIO_LID_OPEN"; }; - acok_od { + gpio_acok_od: acok_od { + #gpio-cells = <0>; gpios = <&gpio0 0 GPIO_INPUT>; enum-name = "GPIO_AC_PRESENT"; }; - gsc_ec_pwr_btn_odl { + gpio_gsc_ec_pwr_btn_odl: gsc_ec_pwr_btn_odl { + #gpio-cells = <0>; gpios = <&gpio0 1 GPIO_INPUT>; enum-name = "GPIO_POWER_BUTTON_L"; }; @@ -141,20 +149,25 @@ gpios = <&gpio0 2 GPIO_OUT_LOW>; enum-name = "GPIO_PACKET_MODE_EN"; }; - x_ec_gpio2 { + gpio_x_ec_gpio2: x_ec_gpio2 { + #gpio-cells = <0>; + #gpio-cells = <0>; gpios = <&gpiod 4 GPIO_INPUT>; enum-name = "GPIO_X_EC_GPIO2"; }; ap_sysrst_odl_r: ap_sysrst_odl_r { + #gpio-cells = <0>; gpios = <&gpioa 1 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_EC_SYSRST_ODL"; }; - ap_xhci_init_done { + gpio_ap_xhci_init_done: ap_xhci_init_done { + #gpio-cells = <0>; gpios = <&gpioa 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; enum-name = "GPIO_AP_XHCI_INIT_DONE"; }; - usb_c0_ppc_int_odl { + gpio_usb_c0_ppc_int_odl: usb_c0_ppc_int_odl { + #gpio-cells = <0>; gpios = <&gpio6 7 GPIO_INPUT>; enum-name = "GPIO_USB_C0_PPC_INT_ODL"; }; @@ -178,7 +191,8 @@ gpios = <&gpiod 3 GPIO_OUT_LOW>; enum-name = "GPIO_EC_X_GPIO3"; }; - usb_c0_tcpc_int_odl { + gpio_usb_c0_tcpc_int_odl: usb_c0_tcpc_int_odl { + #gpio-cells = <0>; gpios = <&gpio7 3 GPIO_INPUT>; enum-name = "GPIO_USB_C0_TCPC_INT_ODL"; }; @@ -198,7 +212,8 @@ gpios = <&gpio3 4 GPIO_OUT_HIGH>; enum-name = "GPIO_EN_PP5000_Z2"; }; - usb_c1_tcpc_int_odl { + gpio_usb_c1_tcpc_int_odl: usb_c1_tcpc_int_odl { + #gpio-cells = <0>; gpios = <&gpioe 1 GPIO_INPUT>; enum-name = "GPIO_USB_C1_TCPC_INT_ODL"; }; @@ -218,11 +233,13 @@ gpios = <&gpio7 4 (GPIO_ODR_HIGH | GPIO_VOLTAGE_1P8)>; enum-name = "GPIO_EC_PMIC_EN_ODL"; }; - ec_volup_btn_odl { + gpio_ec_volup_btn_odl: ec_volup_btn_odl { + #gpio-cells = <0>; gpios = <&gpiod 5 GPIO_INPUT>; enum-name = "GPIO_VOLUME_UP_L"; }; - ec_voldn_btn_odl { + gpio_ec_voldn_btn_odl: ec_voldn_btn_odl { + #gpio-cells = <0>; gpios = <&gpioe 2 GPIO_INPUT>; enum-name = "GPIO_VOLUME_DOWN_L"; }; diff --git a/zephyr/projects/corsola/gpio_krabby.dts b/zephyr/projects/corsola/gpio_krabby.dts index 9cf4e8fd35..6682f240a3 100644 --- a/zephyr/projects/corsola/gpio_krabby.dts +++ b/zephyr/projects/corsola/gpio_krabby.dts @@ -11,56 +11,69 @@ compatible = "named-gpios"; power_button_l: power_button_l { + #gpio-cells = <0>; gpios = <&gpioe 4 GPIO_INPUT>; enum-name = "GPIO_POWER_BUTTON_L"; }; lid_open: lid_open { + #gpio-cells = <0>; gpios = <&gpioe 2 GPIO_INPUT>; enum-name = "GPIO_LID_OPEN"; }; tablet_mode_l: tablet_mode_l { + #gpio-cells = <0>; gpios = <&gpioj 7 GPIO_INPUT>; enum-name = "GPIO_TABLET_MODE_L"; }; ap_ec_warm_rst_req: ap_ec_warm_rst_req { + #gpio-cells = <0>; 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 { + #gpio-cells = <0>; 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 { + #gpio-cells = <0>; gpios = <&gpiom 3 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; enum-name = "GPIO_BASE_IMU_INT_L"; }; lid_accel_int_l: lid_accel_int_l { + #gpio-cells = <0>; gpios = <&gpiom 2 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; enum-name = "GPIO_LID_ACCEL_INT_L"; }; volume_down_l: volume_down_l { + #gpio-cells = <0>; gpios = <&gpiod 5 GPIO_INPUT>; enum-name = "GPIO_VOLUME_DOWN_L"; }; volume_up_l: volume_up_l { + #gpio-cells = <0>; gpios = <&gpiod 6 GPIO_INPUT>; enum-name = "GPIO_VOLUME_UP_L"; }; ap_xhci_init_done: ap_xhci_init_done { + #gpio-cells = <0>; gpios = <&gpioj 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; enum-name = "GPIO_AP_XHCI_INIT_DONE"; }; ac_present: ac_present { + #gpio-cells = <0>; gpios = <&gpioe 5 GPIO_INPUT>; enum-name = "GPIO_AC_PRESENT"; }; ec_flash_wp_odl: ec_flash_wp_odl { + #gpio-cells = <0>; gpios = <&gpioi 4 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; enum-name = "GPIO_WP_L"; }; spi0_cs: spi0_cs { + #gpio-cells = <0>; gpios = <&gpiom 5 (GPIO_INPUT | GPIO_VOLTAGE_1P8)>; enum-name = "GPIO_SPI0_CS"; }; @@ -97,11 +110,13 @@ enum-name = "GPIO_EC_BL_EN_OD"; }; ap_sysrst_odl_r: ap_ec_sysrst_odl { + #gpio-cells = <0>; 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 { + #gpio-cells = <0>; gpios = <&gpioc 7 (GPIO_INPUT | GPIO_VOLTAGE_1P8 | GPIO_ACTIVE_LOW)>; enum-name = "GPIO_AP_EC_WDTRST_L"; diff --git a/zephyr/projects/corsola/include/gpio_map.h b/zephyr/projects/corsola/include/gpio_map.h index 701dbeb88c..262951f00b 100644 --- a/zephyr/projects/corsola/include/gpio_map.h +++ b/zephyr/projects/corsola/include/gpio_map.h @@ -6,6 +6,7 @@ #ifndef __ZEPHYR_GPIO_MAP_H #define __ZEPHYR_GPIO_MAP_H + #include <devicetree.h> #include <gpio_signal.h> @@ -19,179 +20,10 @@ #define GPIO_USB_C1_DP_IN_HPD GPIO_EC_X_GPIO3 #define GPIO_PS185_PWRDN_ODL GPIO_EC_X_GPIO3 -#ifdef CONFIG_PLATFORM_EC_POWER_BUTTON - #define PWRBTN_INT() GPIO_INT(GPIO_POWER_BUTTON_L, \ - GPIO_INT_EDGE_BOTH, \ - power_button_interrupt) -#else - #define PWRBTN_INT() -#endif - -#ifdef CONFIG_PLATFORM_EC_VOLUME_BUTTONS - #define VOLBTN_INT(pin) GPIO_INT(pin, \ - GPIO_INT_EDGE_BOTH, \ - button_interrupt) -#else - #define VOLBTN_INT(pin) -#endif - -#ifdef CONFIG_SOC_IT8XXX2 - #define AP_SPI_INT() GPIO_INT(GPIO_SPI0_CS, \ - GPIO_INT_EDGE_BOTH, \ - spi_event) - #define TCPC_C0_INT() - #define TCPC_C1_INT() - #define PPC_C0_INT() - #define BC12_C0_INT() -#elif defined(CONFIG_SOC_NPCX9M3F) - /* The interrupt is configured by dts */ - #define AP_SPI_INT() - #define TCPC_C0_INT() GPIO_INT(GPIO_USB_C0_TCPC_INT_ODL, \ - GPIO_INT_EDGE_FALLING, \ - tcpc_alert_event) - #define TCPC_C1_INT() GPIO_INT(GPIO_USB_C1_TCPC_INT_ODL, \ - GPIO_INT_EDGE_FALLING, \ - tcpc_alert_event) - #define PPC_C0_INT() GPIO_INT(GPIO_USB_C0_PPC_INT_ODL, \ - GPIO_INT_EDGE_FALLING, \ - ppc_interrupt) - #define BC12_C0_INT() GPIO_INT(GPIO_USB_C0_BC12_INT_ODL, \ - GPIO_INT_EDGE_FALLING, \ - bc12_interrupt) -#endif - -#ifdef CONFIG_PLATFORM_EC_TABLET_MODE - #define GMR_TABLET_INT() GPIO_INT(GPIO_TABLET_MODE_L, \ - GPIO_INT_EDGE_BOTH, \ - gmr_tablet_switch_isr) -#else - #define GMR_TABLET_INT() -#endif - -#ifdef CONFIG_PLATFORM_EC_POWERSEQ_MT8186 - #define WARM_RST_REQ_INT() GPIO_INT(GPIO_AP_EC_WARM_RST_REQ, \ - GPIO_INT_EDGE_RISING, \ - chipset_reset_request_interrupt) - - #define AP_IN_SLEEP_INT() GPIO_INT(GPIO_AP_IN_SLEEP_L, \ - GPIO_INT_EDGE_BOTH, \ - power_signal_interrupt) - - #define AP_IN_RST_INT() GPIO_INT(GPIO_AP_EC_SYSRST_ODL, \ - GPIO_INT_EDGE_BOTH, \ - power_signal_interrupt) - - #define AP_EC_WDTRST_INT() GPIO_INT(GPIO_AP_EC_WDTRST_L, \ - GPIO_INT_EDGE_BOTH, \ - power_signal_interrupt) -#else - #define WARM_RST_REQ_INT() - #define AP_IN_SLEEP_INT() - #define AP_IN_RST_INT() - #define AP_EC_WDTRST_INT() -#endif - -#ifdef CONFIG_PLATFORM_EC_ACCEL_LIS2DW12 - #define LID_ACCEL_INT() GPIO_INT(GPIO_LID_ACCEL_INT_L, \ - GPIO_INT_EDGE_FALLING, \ - lis2dw12_interrupt) -#else - #define LID_ACCEL_INT() -#endif - -#ifdef CONFIG_PLATFORM_EC_EXTPOWER_GPIO - #define EXTPWR_INT() GPIO_INT(GPIO_AC_PRESENT, \ - GPIO_INT_EDGE_BOTH, \ - extpower_interrupt) -#else - #define EXTPWR_INT() -#endif - -#ifdef CONFIG_PLATFORM_EC_LID_SWITCH - #define LID_SWITCH_INT() GPIO_INT(GPIO_LID_OPEN, \ - GPIO_INT_EDGE_BOTH, \ - lid_interrupt) -#else - #define LID_SWITCH_INT() -#endif - -#ifdef CONFIG_PLATFORM_EC_SWITCH - #define SWITCH_INT() GPIO_INT(GPIO_WP_L, \ - GPIO_INT_EDGE_BOTH, \ - switch_interrupt) -#else - #define SWITCH_INT() -#endif - -#ifdef CONFIG_VARIANT_CORSOLA_DB_DETECTION - #define X_EC_GPIO2_INT() GPIO_INT(GPIO_X_EC_GPIO2, \ - GPIO_INT_EDGE_BOTH, \ - x_ec_interrupt) -#else - #define X_EC_GPIO2_INT() -#endif - -#ifdef CONFIG_VARIANT_CORSOLA_USBA - #define USBA_INT() GPIO_INT(GPIO_AP_XHCI_INIT_DONE, \ - GPIO_INT_EDGE_BOTH, \ - usb_a0_interrupt) -#else - #define USBA_INT() -#endif - -#ifdef CONFIG_PLATFORM_EC_ACCELGYRO_ICM42607 - #define BASE_IMU_INT() GPIO_INT(GPIO_BASE_IMU_INT_L, \ - GPIO_INT_EDGE_FALLING, \ - icm42607_interrupt) -#elif defined(CONFIG_PLATFORM_EC_ACCELGYRO_BMI3XX) - #define BASE_IMU_INT() GPIO_INT(GPIO_BASE_IMU_INT_L, \ - GPIO_INT_EDGE_FALLING, \ - bmi3xx_interrupt) -#else - #define BASE_IMU_INT() -#endif - #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 -/* - * Set EC_CROS_GPIO_INTERRUPTS to a space-separated list of GPIO_INT items. - * - * Each GPIO_INT requires three parameters: - * gpio_signal - The enum gpio_signal for the interrupt gpio - * interrupt_flags - The interrupt-related flags (e.g. GPIO_INT_EDGE_BOTH) - * handler - The platform/ec interrupt handler. - * - * Ensure that this files includes all necessary headers to declare all - * referenced handler functions. - * - * For example, one could use the follow definition: - * #define EC_CROS_GPIO_INTERRUPTS \ - * GPIO_INT(NAMED_GPIO(h1_ec_pwr_btn_odl), GPIO_INT_EDGE_BOTH, button_print) - */ -#define EC_CROS_GPIO_INTERRUPTS \ - PWRBTN_INT() \ - VOLBTN_INT(GPIO_VOLUME_DOWN_L) \ - VOLBTN_INT(GPIO_VOLUME_UP_L) \ - LID_SWITCH_INT() \ - WARM_RST_REQ_INT() \ - AP_IN_SLEEP_INT() \ - AP_IN_RST_INT() \ - AP_EC_WDTRST_INT() \ - GMR_TABLET_INT() \ - BASE_IMU_INT() \ - LID_ACCEL_INT() \ - USBA_INT() \ - EXTPWR_INT() \ - SWITCH_INT() \ - AP_SPI_INT() \ - TCPC_C0_INT() \ - TCPC_C1_INT() \ - PPC_C0_INT() \ - BC12_C0_INT() \ - X_EC_GPIO2_INT() - #endif /* __ZEPHYR_GPIO_MAP_H */ diff --git a/zephyr/projects/corsola/interrupts_kingler.dts b/zephyr/projects/corsola/interrupts_kingler.dts new file mode 100644 index 0000000000..fa5790cd7e --- /dev/null +++ b/zephyr/projects/corsola/interrupts_kingler.dts @@ -0,0 +1,86 @@ +/* Copyright 2022 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-gpio = <&gpio_gsc_ec_pwr_btn_odl>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-gpio = <&gpio_ec_volup_btn_odl>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-gpio = <&gpio_ec_voldn_btn_odl>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "button_interrupt"; + }; + int_lid_open: lid_open { + irq-gpio = <&gpio_lid_open>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "lid_interrupt"; + }; + int_warm_rst: warm_rst { + irq-gpio = <&ap_ec_warm_rst_req>; + flags = <GPIO_INT_EDGE_RISING>; + handler = "chipset_reset_request_interrupt"; + }; + int_ap_in_sleep: ap_in_sleep { + irq-gpio = <&ap_in_sleep_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_signal_interrupt"; + }; + int_ap_in_rst: ap_in_rst { + irq-gpio = <&ap_sysrst_odl_r>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_signal_interrupt"; + }; + int_ap_wdtrst: ap_wdtrst { + irq-gpio = <&ap_ec_wdtrst_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_signal_interrupt"; + }; + int_ac_present: ac_present { + irq-gpio = <&gpio_acok_od>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "extpower_interrupt"; + }; + int_wp: wp { + irq-gpio = <&gpio_ec_wp_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "switch_interrupt"; + }; + int_usb_c0_tcpc: usb_c0_tcpc { + irq-gpio = <&gpio_usb_c0_tcpc_int_odl>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "tcpc_alert_event"; + }; + int_usb_c1_tcpc: usb_c1_tcpc { + irq-gpio = <&gpio_usb_c1_tcpc_int_odl>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "tcpc_alert_event"; + }; + int_usb_c0_ppc: usb_c0_ppc { + irq-gpio = <&gpio_usb_c0_ppc_int_odl>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "ppc_interrupt"; + }; + int_usb_c0_bc12: usb_c0_bc12 { + irq-gpio = <&gpio_usb_c0_bc12_int_odl>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "bc12_interrupt"; + }; + int_x_ec_gpio2: x_ec_gpio2 { + irq-gpio = <&gpio_x_ec_gpio2>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "x_ec_interrupt"; + }; + }; +}; diff --git a/zephyr/projects/corsola/interrupts_krabby.dts b/zephyr/projects/corsola/interrupts_krabby.dts new file mode 100644 index 0000000000..2560df5c7b --- /dev/null +++ b/zephyr/projects/corsola/interrupts_krabby.dts @@ -0,0 +1,86 @@ +/* Copyright 2022 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/ { + gpio-interrupts { + compatible = "cros-ec,gpio-interrupts"; + + int_power_button: power_button { + irq-gpio = <&power_button_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_button_interrupt"; + }; + int_volume_up: volume_up { + irq-gpio = <&volume_up_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "button_interrupt"; + }; + int_volume_down: volume_down { + irq-gpio = <&volume_down_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "button_interrupt"; + }; + int_lid_open: lid_open { + irq-gpio = <&lid_open>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "lid_interrupt"; + }; + int_warm_rst: warm_rst { + irq-gpio = <&ap_ec_warm_rst_req>; + flags = <GPIO_INT_EDGE_RISING>; + handler = "chipset_reset_request_interrupt"; + }; + int_ap_in_sleep: ap_in_sleep { + irq-gpio = <&ap_in_sleep_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_signal_interrupt"; + }; + int_ap_in_rst: ap_in_rst { + irq-gpio = <&ap_sysrst_odl_r>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_signal_interrupt"; + }; + int_ap_wdtrst: ap_wdtrst { + irq-gpio = <&ap_ec_wdtrst_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "power_signal_interrupt"; + }; + int_tablet_mode: tablet_mode { + irq-gpio = <&tablet_mode_l>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "gmr_tablet_switch_isr"; + }; + int_base_imu: base_imu { + irq-gpio = <&base_imu_int_l>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "icm42607_interrupt"; + }; + int_accel: accel { + irq-gpio = <&lid_accel_int_l>; + flags = <GPIO_INT_EDGE_FALLING>; + handler = "lis2dw12_interrupt"; + }; + int_ac_present: ac_present { + irq-gpio = <&ac_present>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "extpower_interrupt"; + }; + int_usba: usba { + irq-gpio = <&ap_xhci_init_done>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "usb_a0_interrupt"; + }; + int_wp: wp { + irq-gpio = <&ec_flash_wp_odl>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "switch_interrupt"; + }; + int_spi0_cs: spi0_cs { + irq-gpio = <&spi0_cs>; + flags = <GPIO_INT_EDGE_BOTH>; + handler = "spi_event"; + }; + }; +}; diff --git a/zephyr/projects/corsola/src/kingler/usbc_config.c b/zephyr/projects/corsola/src/kingler/usbc_config.c index 289b5d1e2c..e0cc32f9a6 100644 --- a/zephyr/projects/corsola/src/kingler/usbc_config.c +++ b/zephyr/projects/corsola/src/kingler/usbc_config.c @@ -14,6 +14,7 @@ #include "driver/tcpm/anx7447.h" #include "driver/tcpm/rt1718s.h" #include "driver/usb_mux/ps8743.h" +#include "gpio/gpio_int.h" #include "hooks.h" #include "timer.h" #include "usb_charge.h" @@ -125,17 +126,26 @@ void board_tcpc_init(void) } /* Enable PPC interrupts */ - gpio_enable_interrupt(GPIO_USB_C0_TCPC_INT_ODL); + /* + * The original code says GPIO_USB_C0_TCPC_INT_ODL but + * the comments say PPC interrupt, so perhaps + * this should be int_usb_c0_ppc. + * Since int_usb_c0_tcpc is enabled further down, this + * does look like a typo. + */ + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); if (corsola_get_db_type() == CORSOLA_DB_TYPEC) - gpio_enable_interrupt(GPIO_USB_C1_PPC_INT_ODL); + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_x_ec_gpio2)); /* Enable TCPC interrupts */ - gpio_enable_interrupt(GPIO_USB_C0_TCPC_INT_ODL); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); if (corsola_get_db_type() == CORSOLA_DB_TYPEC) - gpio_enable_interrupt(GPIO_USB_C1_TCPC_INT_ODL); + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_usb_c1_tcpc)); /* Enable BC1.2 interrupts. */ - gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_ODL); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); /* * Initialize HPD to low; after sysjump SOC needs to see diff --git a/zephyr/projects/corsola/src/krabby/usbc_config.c b/zephyr/projects/corsola/src/krabby/usbc_config.c index 578881a8ba..28ce147b1a 100644 --- a/zephyr/projects/corsola/src/krabby/usbc_config.c +++ b/zephyr/projects/corsola/src/krabby/usbc_config.c @@ -71,18 +71,43 @@ void bc12_interrupt(enum gpio_signal signal) static void board_sub_bc12_init(void) { +/* + * This function seems quite broken, so leave it out for now. + */ +#ifndef CONFIG_ZEPHYR if (corsola_get_db_type() == CORSOLA_DB_TYPEC) - gpio_enable_interrupt(GPIO_USB_C1_BC12_CHARGER_INT_ODL); + /* + * The original code had: + * + * gpio_enable_interrupt(GPIO_USB_C1_BC12_CHARGER_INT_ODL); + * + * But this interrupt was defined out in gpio_map.h for + * this EC type. + */ else /* If this is not a Type-C subboard, disable the task. */ + /* + * And this function is not implemented in zephyr + */ task_disable_task(TASK_ID_USB_CHG_P1); +#endif } /* Must be done after I2C and subboard */ DECLARE_HOOK(HOOK_INIT, board_sub_bc12_init, HOOK_PRIO_INIT_I2C + 1); static void board_usbc_init(void) { - gpio_enable_interrupt(GPIO_USB_C0_PPC_BC12_INT_ODL); + /* + * Original code was: + * + * gpio_enable_interrupt(GPIO_USB_C0_PPC_BC12_INT_ODL); + * + * But this interrupt is defined out in gpio_map.h for + * CONFIG_SOC_IT8XXX2 + */ +#ifdef CONFIG_SOC_NPCX9M3F + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); +#endif } DECLARE_HOOK(HOOK_INIT, board_usbc_init, HOOK_PRIO_DEFAULT-1); diff --git a/zephyr/projects/corsola/src/usbc_config.c b/zephyr/projects/corsola/src/usbc_config.c index ed1da07c1a..5db1ab8a94 100644 --- a/zephyr/projects/corsola/src/usbc_config.c +++ b/zephyr/projects/corsola/src/usbc_config.c @@ -14,6 +14,7 @@ #include "ec_commands.h" #include "extpower.h" #include "gpio.h" +#include "gpio/gpio_int.h" #include "hooks.h" #include "i2c.h" #include "lid_switch.h" @@ -38,7 +39,9 @@ /* Baseboard */ static void baseboard_init(void) { - gpio_enable_interrupt(GPIO_AP_XHCI_INIT_DONE); +#ifdef CONFIG_VARIANT_CORSOLA_USBA + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usba)); +#endif } DECLARE_HOOK(HOOK_INIT, baseboard_init, HOOK_PRIO_DEFAULT-1); |