diff options
author | Andrew McRae <amcrae@google.com> | 2022-02-02 18:36:05 +1100 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2022-02-03 09:30:22 +0000 |
commit | fa8ceb713d1cd6ef7a7c326804823b27986c1ca6 (patch) | |
tree | ef268d1e8230615e5c75d4d89e712d5639077340 /zephyr/projects/trogdor | |
parent | 5e40375e82678e87eb63d52f802067a2df9f51c3 (diff) | |
download | chrome-ec-fa8ceb713d1cd6ef7a7c326804823b27986c1ca6.tar.gz |
lazor: Use Zephyr APIs for migrated code
Use the zephyr APIs for lazor board-specific code.
BUG=b:217460464
TEST=zmake configure -b lazor
BRANCH=none
Signed-off-by: Andrew McRae <amcrae@google.com>
Change-Id: Ica1fbccab29d7d2c05ced32815099329735ac42e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3431606
Reviewed-by: Abe Levkoy <alevkoy@chromium.org>
Diffstat (limited to 'zephyr/projects/trogdor')
-rw-r--r-- | zephyr/projects/trogdor/lazor/BUILD.py | 5 | ||||
-rw-r--r-- | zephyr/projects/trogdor/lazor/adc.dts | 43 | ||||
-rw-r--r-- | zephyr/projects/trogdor/lazor/gpio.dts | 48 | ||||
-rw-r--r-- | zephyr/projects/trogdor/lazor/i2c.dts | 109 | ||||
-rw-r--r-- | zephyr/projects/trogdor/lazor/pwm.dts | 29 | ||||
-rw-r--r-- | zephyr/projects/trogdor/lazor/src/hibernate.c | 12 | ||||
-rw-r--r-- | zephyr/projects/trogdor/lazor/src/power.c | 8 | ||||
-rw-r--r-- | zephyr/projects/trogdor/lazor/src/switchcap.c | 48 | ||||
-rw-r--r-- | zephyr/projects/trogdor/lazor/src/usb_pd_policy.c | 29 | ||||
-rw-r--r-- | zephyr/projects/trogdor/lazor/src/usbc_config.c | 40 |
10 files changed, 302 insertions, 69 deletions
diff --git a/zephyr/projects/trogdor/lazor/BUILD.py b/zephyr/projects/trogdor/lazor/BUILD.py index d871f0db83..2f79e9905d 100644 --- a/zephyr/projects/trogdor/lazor/BUILD.py +++ b/zephyr/projects/trogdor/lazor/BUILD.py @@ -4,13 +4,16 @@ register_npcx_project( project_name="lazor", - zephyr_board="trogdor", + zephyr_board="npcx7", dts_overlays=[ + "adc.dts", "battery.dts", "gpio.dts", + "i2c.dts", "interrupts.dts", "keyboard.dts", "led.dts", "motionsense.dts", + "pwm.dts", ], ) diff --git a/zephyr/projects/trogdor/lazor/adc.dts b/zephyr/projects/trogdor/lazor/adc.dts new file mode 100644 index 0000000000..52ea1d9493 --- /dev/null +++ b/zephyr/projects/trogdor/lazor/adc.dts @@ -0,0 +1,43 @@ +/* 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. + */ + +#include <dt-bindings/adc/adc.h> + +/ { + named-adc-channels { + compatible = "named-adc-channels"; + + vbus { + label = "VBUS"; + enum-name = "ADC_VBUS"; + io-channels = <&adc0 1>; + /* Measure VBUS through a 1/10 voltage divider */ + mul = <10>; + }; + amon_bmon { + label = "AMON_BMON"; + enum-name = "ADC_AMON_BMON"; + io-channels = <&adc0 2>; + /* + * Adapter current output or battery charging/ + * discharging current (uV) 18x amplification on + * charger side. + */ + mul = <1000>; + div = <18>; + }; + psys { + label = "PSYS"; + enum-name = "ADC_PSYS"; + io-channels = <&adc0 3>; + /* + * ISL9238 PSYS output is 1.44 uA/W over 5.6K resistor, + * to read 0.8V @ 99 W, i.e. 124000 uW/mV. + */ + mul = <124000>; + }; + }; + +}; diff --git a/zephyr/projects/trogdor/lazor/gpio.dts b/zephyr/projects/trogdor/lazor/gpio.dts index 3a555d6420..edcabaf149 100644 --- a/zephyr/projects/trogdor/lazor/gpio.dts +++ b/zephyr/projects/trogdor/lazor/gpio.dts @@ -3,6 +3,8 @@ * found in the LICENSE file. */ +#include <dt-bindings/wake_mask_event_defines.h> + / { named-gpios { compatible = "named-gpios"; @@ -98,7 +100,7 @@ gpios = <&gpioa 0 GPIO_INPUT>; enum-name = "GPIO_ACCEL_GYRO_INT_L"; }; - da9313_gpio0 { + gpio_da9313_gpio0: da9313_gpio0 { gpios = <&gpioe 2 GPIO_INPUT>; enum-name = "GPIO_DA9313_GPIO0"; }; @@ -133,27 +135,27 @@ qsip_on { gpios = <&gpio5 0 GPIO_OUT_LOW>; }; - hibernate_l { + gpio_hibernate_l: hibernate_l { gpios = <&gpio5 2 GPIO_OUT_HIGH>; enum-name = "GPIO_HIBERNATE_L"; }; - switchcap_on { + gpio_switchcap_on: switchcap_on { gpios = <&gpiod 5 GPIO_OUT_LOW>; enum-name = "GPIO_SWITCHCAP_ON"; }; - switchcap_on_l { + gpio_switchcap_on_l: switchcap_on_l { gpios = <&gpiod 5 GPIO_OUT_LOW>; enum-name = "GPIO_SWITCHCAP_ON_L"; }; - vbob_en { + gpio_vbob_en: vbob_en { gpios = <&gpiod 3 GPIO_OUT_LOW>; enum-name = "GPIO_VBOB_EN"; }; - en_pp3300_a { + gpio_en_pp3300_a: en_pp3300_a { gpios = <&gpioa 6 GPIO_OUT_LOW>; enum-name = "GPIO_EN_PP3300_A"; }; - en_pp5000_a { + gpio_en_pp5000_a: en_pp5000_a { gpios = <&gpio6 7 GPIO_OUT_LOW>; enum-name = "GPIO_EN_PP5000"; }; @@ -161,30 +163,30 @@ gpios = <&gpiob 6 GPIO_OUT_LOW>; enum-name = "GPIO_ENABLE_BACKLIGHT"; }; - lid_accel_int_l { + gpio_lid_accel_int_l: lid_accel_int_l { gpios = <&gpio5 6 GPIO_INPUT>; enum-name = "GPIO_LID_ACCEL_INT_L"; }; trackpad_int_gate { gpios = <&gpio7 4 GPIO_OUT_LOW>; }; - usb_c0_pd_rst_l { + gpio_usb_c0_pd_rst_l: usb_c0_pd_rst_l { gpios = <&gpiof 1 GPIO_ODR_HIGH>; enum-name = "GPIO_USB_C0_PD_RST_L"; }; - usb_c1_pd_rst_l { + gpio_usb_c1_pd_rst_l: usb_c1_pd_rst_l { gpios = <&gpioe 4 GPIO_ODR_HIGH>; enum-name = "GPIO_USB_C1_PD_RST_L"; }; - dp_mux_oe_l { + gpio_dp_mux_oe_l: dp_mux_oe_l { gpios = <&gpio9 6 GPIO_ODR_HIGH>; enum-name = "GPIO_DP_MUX_OE_L"; }; - dp_mux_sel { + gpio_dp_mux_sel: dp_mux_sel { gpios = <&gpio4 5 GPIO_OUT_LOW>; enum-name = "GPIO_DP_MUX_SEL"; }; - dp_hot_plug_det { + gpio_dp_hot_plug_det: dp_hot_plug_det { gpios = <&gpio9 5 GPIO_OUT_LOW>; enum-name = "GPIO_DP_HOT_PLUG_DET"; }; @@ -310,6 +312,26 @@ >; }; + ec-mkbp-host-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <( + HOST_EVENT_LID_OPEN | + HOST_EVENT_POWER_BUTTON | + HOST_EVENT_AC_CONNECTED | + HOST_EVENT_AC_DISCONNECTED | + HOST_EVENT_HANG_DETECT | + HOST_EVENT_RTC | + HOST_EVENT_MODE_CHANGE | + HOST_EVENT_DEVICE)>; + }; + + ec-mkbp-event-wakeup-mask { + compatible = "ec-wake-mask-event"; + wakeup-mask = <(MKBP_EVENT_KEY_MATRIX | + MKBP_EVENT_HOST_EVENT | + MKBP_EVENT_SENSOR_FIFO)>; + }; + sku { compatible = "cros-ec,gpio-id"; diff --git a/zephyr/projects/trogdor/lazor/i2c.dts b/zephyr/projects/trogdor/lazor/i2c.dts new file mode 100644 index 0000000000..1ba02b383a --- /dev/null +++ b/zephyr/projects/trogdor/lazor/i2c.dts @@ -0,0 +1,109 @@ +/* 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. + */ + +/ { + named-i2c-ports { + compatible = "named-i2c-ports"; + + power { + i2c-port = <&i2c0_0>; + enum-name = "I2C_PORT_POWER"; + }; + battery { + i2c-port = <&i2c0_0>; + remote-port = <0>; + enum-name = "I2C_PORT_BATTERY"; + }; + virtual-battery { + i2c-port = <&i2c0_0>; + enum-name = "I2C_PORT_VIRTUAL_BATTERY"; + }; + charger { + i2c-port = <&i2c0_0>; + enum-name = "I2C_PORT_CHARGER"; + }; + tcpc0 { + i2c-port = <&i2c1_0>; + enum-name = "I2C_PORT_TCPC0"; + }; + tcpc1 { + i2c-port = <&i2c2_0>; + enum-name = "I2C_PORT_TCPC1"; + }; + eeprom { + i2c-port = <&i2c5_0>; + enum-name = "I2C_PORT_EEPROM"; + }; + i2c_sensor: sensor { + i2c-port = <&i2c7_0>; + enum-name = "I2C_PORT_SENSOR"; + }; + accel { + i2c-port = <&i2c7_0>; + enum-name = "I2C_PORT_ACCEL"; + }; + }; + +}; + +&i2c0_0 { + status = "okay"; + clock-frequency = <I2C_BITRATE_STANDARD>; + + isl9238: isl9238@9 { + compatible = "intersil,isl9238"; + reg = <0x09>; + label = "ISL9238_CHARGER"; + }; +}; + +&i2c_ctrl0 { + status = "okay"; +}; + +&i2c1_0 { + status = "okay"; + clock-frequency = <I2C_BITRATE_FAST_PLUS>; +}; + +&i2c_ctrl1 { + status = "okay"; +}; + +&i2c2_0 { + status = "okay"; + clock-frequency = <I2C_BITRATE_FAST_PLUS>; +}; + +&i2c_ctrl2 { + status = "okay"; +}; + +&i2c3_0 { + /* Not used as no WLC connected */ + clock-frequency = <I2C_BITRATE_FAST>; +}; + +&i2c_ctrl3 { + status = "okay"; +}; + +&i2c5_0 { + status = "okay"; + clock-frequency = <I2C_BITRATE_FAST>; +}; + +&i2c_ctrl5 { + status = "okay"; +}; + +&i2c7_0 { + status = "okay"; + clock-frequency = <I2C_BITRATE_FAST>; +}; + +&i2c_ctrl7 { + status = "okay"; +}; diff --git a/zephyr/projects/trogdor/lazor/pwm.dts b/zephyr/projects/trogdor/lazor/pwm.dts new file mode 100644 index 0000000000..a06860d923 --- /dev/null +++ b/zephyr/projects/trogdor/lazor/pwm.dts @@ -0,0 +1,29 @@ +/* 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. + */ + +/ { + named-pwms { + compatible = "named-pwms"; + + kblight: kb_bl_pwm { + pwms = <&pwm3 0 0>; + frequency = <10000>; + }; + displight: edp_bkltctl { + pwms = <&pwm5 0 0>; + frequency = <4800>; + }; + }; +}; + +/* Keyboard backlight */ +&pwm3 { + status = "okay"; +}; + +/* Display backlight */ +&pwm5 { + status = "okay"; +}; diff --git a/zephyr/projects/trogdor/lazor/src/hibernate.c b/zephyr/projects/trogdor/lazor/src/hibernate.c index ab7cd8b727..5ad97a8c48 100644 --- a/zephyr/projects/trogdor/lazor/src/hibernate.c +++ b/zephyr/projects/trogdor/lazor/src/hibernate.c @@ -17,10 +17,12 @@ void board_hibernate(void) * Sensors are unpowered in hibernate. Apply PD to the * interrupt lines such that they don't float. */ - gpio_set_flags(GPIO_ACCEL_GYRO_INT_L, - GPIO_INPUT | GPIO_PULL_DOWN); - gpio_set_flags(GPIO_LID_ACCEL_INT_L, - GPIO_INPUT | GPIO_PULL_DOWN); + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL( + gpio_accel_gyro_int_l), + GPIO_DISCONNECTED); + gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL( + gpio_lid_accel_int_l), + GPIO_DISCONNECTED); } /* @@ -42,5 +44,5 @@ void board_hibernate(void) void board_hibernate_late(void) { /* Set the hibernate GPIO to turn off the rails */ - gpio_set_level(GPIO_HIBERNATE_L, 0); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_hibernate_l), 0); } diff --git a/zephyr/projects/trogdor/lazor/src/power.c b/zephyr/projects/trogdor/lazor/src/power.c index 354bfabbfd..a14b8fc7eb 100644 --- a/zephyr/projects/trogdor/lazor/src/power.c +++ b/zephyr/projects/trogdor/lazor/src/power.c @@ -11,13 +11,13 @@ void board_chipset_pre_init(void) { /* Turn on the 3.3V rail */ - gpio_set_level(GPIO_EN_PP3300_A, 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp3300_a), 1); /* Turn on the 5V rail. */ #ifdef CONFIG_POWER_PP5000_CONTROL power_5v_enable(task_get_current(), 1); #else /* !defined(CONFIG_POWER_PP5000_CONTROL) */ - gpio_set_level(GPIO_EN_PP5000, 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a), 1); #endif /* defined(CONFIG_POWER_PP5000_CONTROL) */ } DECLARE_HOOK(HOOK_CHIPSET_PRE_INIT, board_chipset_pre_init, HOOK_PRIO_DEFAULT); @@ -28,11 +28,11 @@ void board_chipset_shutdown_complete(void) #ifdef CONFIG_POWER_PP5000_CONTROL power_5v_enable(task_get_current(), 0); #else /* !defined(CONFIG_POWER_PP5000_CONTROL) */ - gpio_set_level(GPIO_EN_PP5000, 0); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a), 0); #endif /* defined(CONFIG_POWER_PP5000_CONTROL) */ /* Turn off the 3.3V and 5V rails. */ - gpio_set_level(GPIO_EN_PP3300_A, 0); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp3300_a), 0); } DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN_COMPLETE, board_chipset_shutdown_complete, HOOK_PRIO_DEFAULT); diff --git a/zephyr/projects/trogdor/lazor/src/switchcap.c b/zephyr/projects/trogdor/lazor/src/switchcap.c index f362ec8a69..e30771b90a 100644 --- a/zephyr/projects/trogdor/lazor/src/switchcap.c +++ b/zephyr/projects/trogdor/lazor/src/switchcap.c @@ -8,6 +8,7 @@ #include "console.h" #include "driver/ln9310.h" #include "gpio.h" +#include "gpio/gpio_int.h" #include "hooks.h" #include "i2c.h" #include "power/qcom.h" @@ -32,20 +33,24 @@ static void switchcap_init(void) * When the chip in power down mode, it outputs high-Z. * Set pull-down to avoid floating. */ - gpio_set_flags(GPIO_DA9313_GPIO0, GPIO_INPUT | GPIO_PULL_DOWN); + gpio_pin_configure_dt( + GPIO_DT_FROM_NODELABEL(gpio_da9313_gpio0), + GPIO_INPUT | GPIO_PULL_DOWN); /* * Configure DA9313 enable, push-pull output. Don't set the * level here; otherwise, it will override its value and * shutdown the switchcap when sysjump to RW. */ - gpio_set_flags(GPIO_SWITCHCAP_ON, GPIO_OUTPUT); + gpio_pin_configure_dt( + GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), + GPIO_OUTPUT); } else if (board_has_ln9310()) { CPRINTS("Use switchcap: LN9310"); - /* Configure and enable interrupt for LN9310 */ - gpio_set_flags(GPIO_SWITCHCAP_PG_INT_L, GPIO_INT_FALLING); - gpio_enable_interrupt(GPIO_SWITCHCAP_PG_INT_L); + /* Enable interrupt for LN9310 */ + gpio_enable_dt_interrupt( + GPIO_INT_FROM_NODELABEL(int_switchcap_pg)); /* * Configure LN9310 enable, open-drain output. Don't set the @@ -65,8 +70,9 @@ static void switchcap_init(void) * (6) GPIO init according to gpio.inc -> push-pull LOW * (7) This function configures it -> open-drain LOW */ - gpio_set_flags(GPIO_SWITCHCAP_ON_L, - GPIO_OUTPUT | GPIO_OPEN_DRAIN); + gpio_pin_configure_dt( + GPIO_DT_FROM_NODELABEL(gpio_switchcap_on_l), + GPIO_OUTPUT | GPIO_OPEN_DRAIN); /* Only configure the switchcap if not sysjump */ if (!system_jumped_late()) { @@ -75,7 +81,9 @@ static void switchcap_init(void) * switchcap won't be enabled after the switchcap is * configured from standby mode to switching mode. */ - gpio_set_level(GPIO_SWITCHCAP_ON_L, 1); + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_switchcap_on_l), + 1); ln9310_init(); } } else if (board_has_buck_ic()) { @@ -89,30 +97,40 @@ DECLARE_HOOK(HOOK_INIT, switchcap_init, HOOK_PRIO_DEFAULT); void board_set_switchcap_power(int enable) { if (board_has_da9313()) { - gpio_set_level(GPIO_SWITCHCAP_ON, enable); + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_switchcap_on), + enable); } else if (board_has_ln9310()) { - gpio_set_level(GPIO_SWITCHCAP_ON_L, !enable); + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_switchcap_on_l), + !enable); ln9310_software_enable(enable); } else if (board_has_buck_ic()) { - gpio_set_level(GPIO_VBOB_EN, enable); + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_vbob_en), + enable); } } int board_is_switchcap_enabled(void) { if (board_has_da9313()) - return gpio_get_level(GPIO_SWITCHCAP_ON); + return gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_switchcap_on)); else if (board_has_ln9310()) - return !gpio_get_level(GPIO_SWITCHCAP_ON_L); + return !gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_switchcap_on_l)); /* Board has buck ic*/ - return gpio_get_level(GPIO_VBOB_EN); + return gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_vbob_en)); } int board_is_switchcap_power_good(void) { if (board_has_da9313()) - return gpio_get_level(GPIO_DA9313_GPIO0); + return gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_da9313_gpio0)); else if (board_has_ln9310()) return ln9310_power_good(); diff --git a/zephyr/projects/trogdor/lazor/src/usb_pd_policy.c b/zephyr/projects/trogdor/lazor/src/usb_pd_policy.c index be9cc92589..108e3827b3 100644 --- a/zephyr/projects/trogdor/lazor/src/usb_pd_policy.c +++ b/zephyr/projects/trogdor/lazor/src/usb_pd_policy.c @@ -18,7 +18,7 @@ int pd_check_vconn_swap(int port) { /* In G3, do not allow vconn swap since PP5000 rail is off */ - return gpio_get_level(GPIO_EN_PP5000); + return gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_en_pp5000_a)); } static uint8_t vbus_en[CONFIG_USB_PD_PORT_MAX_COUNT]; @@ -143,10 +143,11 @@ static int is_dp_muxable(int port) __override int svdm_dp_attention(int port, uint32_t *payload) { - enum gpio_signal hpd = GPIO_DP_HOT_PLUG_DET; + const struct gpio_dt_spec *hpd = + GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det); int lvl = PD_VDO_DPSTS_HPD_LVL(payload[1]); int irq = PD_VDO_DPSTS_HPD_IRQ(payload[1]); - int cur_lvl = gpio_get_level(hpd); + int cur_lvl = gpio_pin_get_dt(hpd); mux_state_t mux_state; dp_status[port] = payload[1]; @@ -173,8 +174,9 @@ __override int svdm_dp_attention(int port, uint32_t *payload) * TODO(waihong): Better to move switching DP mux to * the usb_mux abstraction. */ - gpio_set_level(GPIO_DP_MUX_SEL, port == 1); - gpio_set_level(GPIO_DP_MUX_OE_L, 0); + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), port == 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 0); /* Connect the SBU lines in PPC chip. */ if (IS_ENABLED(CONFIG_USBC_PPC_SBU)) @@ -192,8 +194,8 @@ __override int svdm_dp_attention(int port, uint32_t *payload) polarity_rm_dts(pd_get_polarity(port))); } else { /* Disconnect the DP port selection mux. */ - gpio_set_level(GPIO_DP_MUX_OE_L, 1); - gpio_set_level(GPIO_DP_MUX_SEL, 0); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0); /* Disconnect the SBU lines in PPC chip. */ if (IS_ENABLED(CONFIG_USBC_PPC_SBU)) @@ -226,9 +228,9 @@ __override int svdm_dp_attention(int port, uint32_t *payload) usleep(svdm_hpd_deadline[port] - now); /* Generate IRQ_HPD pulse */ - gpio_set_level(hpd, 0); + gpio_pin_set_dt(hpd, 0); usleep(HPD_DSTREAM_DEBOUNCE_IRQ); - gpio_set_level(hpd, 1); + gpio_pin_set_dt(hpd, 1); /* Set the minimum time delay (2ms) for the next HPD IRQ */ svdm_hpd_deadline[port] = get_time().val + @@ -237,7 +239,7 @@ __override int svdm_dp_attention(int port, uint32_t *payload) CPRINTF("ERR:HPD:IRQ&LOW\n"); return 0; } - gpio_set_level(hpd, lvl); + gpio_pin_set_dt(hpd, lvl); /* Set the minimum time delay (2ms) for the next HPD IRQ */ svdm_hpd_deadline[port] = get_time().val + HPD_USTREAM_DEBOUNCE_LVL; @@ -248,13 +250,14 @@ __override void svdm_exit_dp_mode(int port) { if (is_dp_muxable(port)) { /* Disconnect the DP port selection mux. */ - gpio_set_level(GPIO_DP_MUX_OE_L, 1); - gpio_set_level(GPIO_DP_MUX_SEL, 0); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_oe_l), 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_dp_mux_sel), 0); /* Signal AP for the HPD low event */ usb_mux_hpd_update(port, USB_PD_MUX_HPD_LVL_DEASSERTED | USB_PD_MUX_HPD_IRQ_DEASSERTED); - gpio_set_level(GPIO_DP_HOT_PLUG_DET, 0); + gpio_pin_set_dt( + GPIO_DT_FROM_NODELABEL(gpio_dp_hot_plug_det), 0); } } #endif /* CONFIG_USB_PD_ALT_MODE_DFP */ diff --git a/zephyr/projects/trogdor/lazor/src/usbc_config.c b/zephyr/projects/trogdor/lazor/src/usbc_config.c index a9d5bb153a..2a4e3c99fd 100644 --- a/zephyr/projects/trogdor/lazor/src/usbc_config.c +++ b/zephyr/projects/trogdor/lazor/src/usbc_config.c @@ -15,6 +15,7 @@ #include "config.h" #include "driver/ln9310.h" #include "gpio.h" +#include "gpio/gpio_int.h" #include "hooks.h" #include "ppc/sn5s330_public.h" #include "system.h" @@ -90,7 +91,8 @@ static void usba_oc_deferred(void) { /* Use next number after all USB-C ports to indicate the USB-A port */ board_overcurrent_event(CONFIG_USB_PD_PORT_MAX_COUNT, - !gpio_get_level(GPIO_USB_A0_OC_ODL)); + !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL( + gpio_usb_a0_oc_odl))); } DECLARE_DEFERRED(usba_oc_deferred); @@ -102,10 +104,10 @@ void usba_oc_interrupt(enum gpio_signal signal) void ppc_interrupt(enum gpio_signal signal) { switch (signal) { - case GPIO_USB_C0_SWCTL_INT_ODL: + case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c0_swctl_int_odl)): sn5s330_interrupt(0); break; - case GPIO_USB_C1_SWCTL_INT_ODL: + case GPIO_SIGNAL(DT_NODELABEL(gpio_usb_c1_swctl_int_odl)): sn5s330_interrupt(1); break; default: @@ -236,17 +238,17 @@ __override int board_get_default_battery_type(void) static void board_init_usbc(void) { /* Enable BC1.2 interrupts */ - gpio_enable_interrupt(GPIO_USB_C0_BC12_INT_L); - gpio_enable_interrupt(GPIO_USB_C1_BC12_INT_L); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_bc12)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c1_bc12)); /* Enable USB-A overcurrent interrupt */ - gpio_enable_interrupt(GPIO_USB_A0_OC_ODL); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_a0_oc)); /* * The H1 SBU line for CCD are behind PPC chip. The PPC internal FETs * for SBU may be disconnected after DP alt mode is off. Should enable * the CCD_MODE_ODL interrupt to make sure the SBU FETs are connected. */ - gpio_enable_interrupt(GPIO_CCD_MODE_ODL); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_ccd_mode)); } DECLARE_HOOK(HOOK_INIT, board_init_usbc, HOOK_PRIO_DEFAULT); @@ -259,11 +261,11 @@ void board_tcpc_init(void) } /* Enable PPC interrupts */ - gpio_enable_interrupt(GPIO_USB_C0_SWCTL_INT_ODL); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_swctl)); /* Enable TCPC interrupts */ - gpio_enable_interrupt(GPIO_USB_C0_PD_INT_ODL); - gpio_enable_interrupt(GPIO_USB_C1_PD_INT_ODL); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); + gpio_enable_dt_interrupt(GPIO_INT_FROM_NODELABEL(int_usb_c0_tcpc)); /* * Initialize HPD to low; after sysjump SOC needs to see @@ -280,11 +282,11 @@ void board_reset_pd_mcu(void) cprints(CC_USB, "Resetting TCPCs..."); cflush(); - gpio_set_level(GPIO_USB_C0_PD_RST_L, 0); - gpio_set_level(GPIO_USB_C1_PD_RST_L, 0); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 0); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 0); msleep(PS8XXX_RESET_DELAY_MS); - gpio_set_level(GPIO_USB_C0_PD_RST_L, 1); - gpio_set_level(GPIO_USB_C1_PD_RST_L, 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l), 1); + gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l), 1); } void board_set_tcpc_power_mode(int port, int mode) @@ -392,11 +394,13 @@ uint16_t tcpc_get_alert_status(void) { uint16_t status = 0; - if (!gpio_get_level(GPIO_USB_C0_PD_INT_ODL)) - if (gpio_get_level(GPIO_USB_C0_PD_RST_L)) + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl))) + if (gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_rst_l))) status |= PD_STATUS_TCPC_ALERT_0; - if (!gpio_get_level(GPIO_USB_C1_PD_INT_ODL)) - if (gpio_get_level(GPIO_USB_C1_PD_RST_L)) + if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c0_pd_int_odl))) + if (gpio_pin_get_dt( + GPIO_DT_FROM_NODELABEL(gpio_usb_c1_pd_rst_l))) status |= PD_STATUS_TCPC_ALERT_1; return status; |