summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew McRae <amcrae@google.com>2022-02-01 08:50:08 +1100
committerCommit Bot <commit-bot@chromium.org>2022-02-01 02:19:39 +0000
commit713d53c5c50be80e9c9765b30d2def8bcb676f7c (patch)
treeb015504486100251dbbfb5ff6e9452bdafeaf969
parent0c3f7e2d4446a7f1d862d62cdf78de4c0190aba3 (diff)
downloadchrome-ec-713d53c5c50be80e9c9765b30d2def8bcb676f7c.tar.gz
nissa: Use aliases for sub-board GPIOs
Use GPIO aliases for sub-board GPIOs BUG=none TEST=zmake configure -b {nivviks,nereid} BRANCH=none Signed-off-by: Andrew McRae <amcrae@google.com> Change-Id: I9816ba1b44f209e10a8f5235498d43e5626d95e6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3428599 Reviewed-by: Peter Marheine <pmarheine@chromium.org>
-rw-r--r--zephyr/projects/nissa/nereid_overlay.dts49
-rw-r--r--zephyr/projects/nissa/nivviks_overlay.dts54
-rw-r--r--zephyr/projects/nissa/src/nereid/board_config.c10
-rw-r--r--zephyr/projects/nissa/src/nereid/usbc.c4
-rw-r--r--zephyr/projects/nissa/src/nivviks/board_config.c10
-rw-r--r--zephyr/projects/nissa/src/nivviks/usbc.c35
6 files changed, 87 insertions, 75 deletions
diff --git a/zephyr/projects/nissa/nereid_overlay.dts b/zephyr/projects/nissa/nereid_overlay.dts
index b1dbc58923..058dbfdf42 100644
--- a/zephyr/projects/nissa/nereid_overlay.dts
+++ b/zephyr/projects/nissa/nereid_overlay.dts
@@ -44,7 +44,7 @@
handler = "usb_c0_interrupt";
};
int_usb_c1: usb_c1 {
- irq-pin = <&gpio_usb_c1_int_odl>;
+ irq-pin = <&gpio_sb_1>;
flags = <GPIO_INT_EDGE_FALLING>;
handler = "usb_c1_interrupt";
};
@@ -56,47 +56,50 @@
};
named-gpios {
- /*
- * Input GPIO when used with type-C port 1
- */
- gpio_usb_c1_int_odl: usb_c1_int_odl {
+ gpio_sb_1: sb_1 {
#gpio-cells = <0>;
gpios = <&gpioe 6 GPIO_INPUT_PULL_UP>;
no-auto-init;
};
- /*
- * Output GPIO when used with type-A port 1
- */
- gpio_en_sub_usb_a1_vbus: en_sub_usb_a1_vbus {
+ gpio_sb_2: sb_2 {
#gpio-cells = <0>;
gpios = <&gpiof 0 GPIO_OUTPUT>;
no-auto-init;
};
- /*
- * Output GPIO when used with HDMI port
- */
- gpio_en_sub_rails_odl: en_sub_rails_odl {
- #gpio-cells = <0>;
- gpios = <&gpioe 6 GPIO_OUTPUT>;
- no-auto-init;
- };
- /*
- * Alternative use for I2C_PORT_USB_C1_TCPC
- * when HDMI sub-board connected.
- */
- gpio_hdmi_en_sub_odl: hdmi_en_sub_odl {
+ gpio_sb_3: sb_3 {
#gpio-cells = <0>;
gpios = <&gpioe 7 GPIO_OPEN_DRAIN>;
no-auto-init;
};
- gpio_hpd_sub_odl: hdmi_hpd_sub_odl {
+ gpio_sb_4: sb_4 {
#gpio-cells = <0>;
gpios = <&gpioe 0 GPIO_INPUT>;
no-auto-init;
};
};
+ /*
+ * Aliases used for sub-board GPIOs.
+ */
+ aliases {
+ /*
+ * Input GPIO when used with type-C port 1
+ * Output when used with HDMI sub-board
+ */
+ gpio-usb-c1-int-odl = &gpio_sb_1;
+ gpio-en-rails-odl = &gpio_sb_1;
+ /*
+ * Sub-board with type A USB, enable.
+ */
+ gpio-en-usb-a1-vbus = &gpio_sb_2;
+ /*
+ * HPD pins for HDMI sub-board.
+ */
+ gpio-hdmi-en-odl = &gpio_sb_3;
+ gpio-hpd-odl = &gpio_sb_4;
+ };
+
named-temp-sensors {
memory {
compatible = "cros-ec,temp-sensor-thermistor";
diff --git a/zephyr/projects/nissa/nivviks_overlay.dts b/zephyr/projects/nissa/nivviks_overlay.dts
index 83374cf6fe..1359025d9a 100644
--- a/zephyr/projects/nissa/nivviks_overlay.dts
+++ b/zephyr/projects/nissa/nivviks_overlay.dts
@@ -59,7 +59,7 @@
handler = "usb_interrupt";
};
int_usb_c1: usb_c1 {
- irq-pin = <&gpio_usb_c1_int_odl>;
+ irq-pin = <&gpio_sb_1>;
flags = <GPIO_INT_EDGE_FALLING>;
handler = "usb_interrupt";
};
@@ -71,51 +71,51 @@
};
named-gpios {
- /*
- * The following 2 nodes refer to the same pin, but have
- * different configuration depending on the sub-board.
- *
- * Input GPIO when used with type-C port 1
- */
- gpio_usb_c1_int_odl: usb_c1_int_odl {
- #gpio-cells = <0>;
- gpios = <&gpio0 2 GPIO_INPUT_PULL_UP>;
- no-auto-init;
- };
- /*
- * Output GPIO when used with HDMI port
- */
- gpio_en_sub_rails_odl: en_sub_rails_odl {
+ gpio_sb_1: sb_1 {
#gpio-cells = <0>;
- gpios = <&gpio0 2 GPIO_OUTPUT>;
+ gpios = <&gpio0 2 GPIO_PULL_UP>;
no-auto-init;
};
- /*
- * Enable USB-A port 1 vbus (on sub-board)
- */
- gpio_en_sub_usb_a1_vbus: en_sub_usb_a1_vbus {
+ gpio_sb_2: sb_2 {
#gpio-cells = <0>;
gpios = <&gpiod 4 GPIO_OUTPUT>;
no-auto-init;
};
- /*
- * Alternative use for I2C_PORT_USB_C1_TCPC
- * when HDMI sub-board connected.
- */
- gpio_hdmi_en_sub_odl: hdmi_en_sub_odl {
+ gpio_sb_3: sb_3 {
#gpio-cells = <0>;
gpios = <&gpiof 4 GPIO_OPEN_DRAIN>;
no-auto-init;
};
- gpio_hpd_sub_odl: hdmi_hpd_sub_odl {
+ gpio_sb_4: sb_4 {
#gpio-cells = <0>;
gpios = <&gpiof 5 GPIO_INPUT>;
no-auto-init;
};
};
+ /*
+ * Aliases used for sub-board GPIOs.
+ */
+ aliases {
+ /*
+ * Input GPIO when used with type-C port 1
+ * Output when used with HDMI sub-board
+ */
+ gpio-usb-c1-int-odl = &gpio_sb_1;
+ gpio-en-rails-odl = &gpio_sb_1;
+ /*
+ * Sub-board with type A USB, enable.
+ */
+ gpio-en-usb-a1-vbus = &gpio_sb_2;
+ /*
+ * HPD pins for HDMI sub-board.
+ */
+ gpio-hdmi-en-odl = &gpio_sb_3;
+ gpio-hpd-odl = &gpio_sb_4;
+ };
+
named-temp-sensors {
memory {
compatible = "cros-ec,temp-sensor-thermistor";
diff --git a/zephyr/projects/nissa/src/nereid/board_config.c b/zephyr/projects/nissa/src/nereid/board_config.c
index 955bcb5bc8..54480d1177 100644
--- a/zephyr/projects/nissa/src/nereid/board_config.c
+++ b/zephyr/projects/nissa/src/nereid/board_config.c
@@ -33,13 +33,13 @@ static void nereid_subboard_init(void)
GPIO_DT_FROM_NODELABEL(gpio_sub_usb_a1_ilimit_sdp),
GPIO_DISCONNECTED);
gpio_pin_configure_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_sub_usb_a1_vbus),
+ GPIO_DT_FROM_ALIAS(gpio_en_usb_a1_vbus),
GPIO_DISCONNECTED);
}
if (sb == NISSA_SB_C_A || sb == NISSA_SB_C_LTE) {
/* Enable type-C port 1 */
gpio_pin_configure_dt(
- GPIO_DT_FROM_NODELABEL(gpio_usb_c1_int_odl),
+ GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl),
GPIO_INPUT);
}
if (sb == NISSA_SB_HDMI_A) {
@@ -47,14 +47,14 @@ static void nereid_subboard_init(void)
/* TODO(b:212490923): Use pinctrl to switch from I2C */
/* Enable HDMI GPIOs */
gpio_pin_configure_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_sub_rails_odl),
+ GPIO_DT_FROM_ALIAS(gpio_en_rails_odl),
GPIO_OUTPUT | GPIO_OUTPUT_INIT_HIGH);
gpio_pin_configure_dt(
- GPIO_DT_FROM_NODELABEL(gpio_hdmi_en_sub_odl),
+ GPIO_DT_FROM_ALIAS(gpio_hdmi_en_odl),
GPIO_OUTPUT | GPIO_OUTPUT_INIT_HIGH);
/* Configure the interrupt separately */
gpio_pin_configure_dt(
- GPIO_DT_FROM_NODELABEL(gpio_hpd_sub_odl),
+ GPIO_DT_FROM_ALIAS(gpio_hpd_odl),
GPIO_INPUT);
}
}
diff --git a/zephyr/projects/nissa/src/nereid/usbc.c b/zephyr/projects/nissa/src/nereid/usbc.c
index 7975b7a8a6..8c4462ddba 100644
--- a/zephyr/projects/nissa/src/nereid/usbc.c
+++ b/zephyr/projects/nissa/src/nereid/usbc.c
@@ -84,7 +84,7 @@ uint16_t tcpc_get_alert_status(void)
/* Is the C1 port present and its IRQ line asserted? */
if (board_get_usb_pd_port_count() == 2 &&
- !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_int_odl))) {
+ !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
/*
* C1 IRQ is shared between BC1.2 and TCPC; poll TCPC to see if
* it asserted the IRQ.
@@ -164,7 +164,7 @@ static void check_c1_line(void)
* If line is still being held low, see if there's more to process from
* one of the chips.
*/
- if (!gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_int_odl))) {
+ if (!gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
notify_c1_chips();
hook_call_deferred(&check_c1_line_data, INT_RECHECK_US);
}
diff --git a/zephyr/projects/nissa/src/nivviks/board_config.c b/zephyr/projects/nissa/src/nivviks/board_config.c
index 8b62a5cb03..0c0ec6b9ce 100644
--- a/zephyr/projects/nissa/src/nivviks/board_config.c
+++ b/zephyr/projects/nissa/src/nivviks/board_config.c
@@ -33,13 +33,13 @@ static void nivviks_subboard_init(void)
GPIO_DT_FROM_NODELABEL(gpio_sub_usb_a1_ilimit_sdp),
GPIO_DISCONNECTED);
gpio_pin_configure_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_sub_usb_a1_vbus),
+ GPIO_DT_FROM_ALIAS(gpio_en_usb_a1_vbus),
GPIO_DISCONNECTED);
}
if (sb == NISSA_SB_C_A || sb == NISSA_SB_C_LTE) {
/* Enable type-C port 1 */
gpio_pin_configure_dt(
- GPIO_DT_FROM_NODELABEL(gpio_usb_c1_int_odl),
+ GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl),
GPIO_INPUT);
} else {
/* Disable the port 1 charger task */
@@ -50,13 +50,13 @@ static void nivviks_subboard_init(void)
/* TODO(b:212490923): Use pinctrl to switch from I2C */
/* Enable HDMI GPIOs */
gpio_pin_configure_dt(
- GPIO_DT_FROM_NODELABEL(gpio_en_sub_rails_odl),
+ GPIO_DT_FROM_ALIAS(gpio_en_rails_odl),
GPIO_OUTPUT_HIGH);
gpio_pin_configure_dt(
- GPIO_DT_FROM_NODELABEL(gpio_hdmi_en_sub_odl),
+ GPIO_DT_FROM_ALIAS(gpio_hdmi_en_odl),
GPIO_OUTPUT_HIGH);
/* Configure the interrupt separately */
- gpio_pin_configure_dt(GPIO_DT_FROM_NODELABEL(gpio_hpd_sub_odl),
+ gpio_pin_configure_dt(GPIO_DT_FROM_ALIAS(gpio_hpd_odl),
GPIO_INPUT);
}
}
diff --git a/zephyr/projects/nissa/src/nivviks/usbc.c b/zephyr/projects/nissa/src/nivviks/usbc.c
index 76061b1223..52ad94861d 100644
--- a/zephyr/projects/nissa/src/nivviks/usbc.c
+++ b/zephyr/projects/nissa/src/nivviks/usbc.c
@@ -154,7 +154,7 @@ uint16_t tcpc_get_alert_status(void)
}
if (board_get_usb_pd_port_count() == 2 &&
- !gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_usb_c1_int_odl))) {
+ !gpio_pin_get_dt(GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl))) {
if (!tcpc_read16(1, TCPC_REG_ALERT, &regval)) {
/* TCPCI spec Rev 1.0 says to ignore bits 14:12. */
if (!(tcpc_config[1].flags & TCPC_FLAGS_TCPCI_REV2_0))
@@ -234,20 +234,29 @@ static void usbc_interrupt_trigger(int port)
task_set_event(USB_CHG_PORT_TO_TASK_ID(port), USB_CHG_EVENT_BC12);
}
-#define USBC_INT_POLL(port) \
- static void poll_c ## port ## _int (void) \
- { \
- if (!gpio_pin_get_dt( \
- GPIO_DT_FROM_NODELABEL \
- (gpio_usb_c ## port ## _int_odl))) { \
- usbc_interrupt_trigger(port); \
- hook_call_deferred(&poll_c ## port ## _int_data, \
- USBC_INT_POLL_DELAY_US); \
- } \
+static inline void poll_usb_gpio(int port,
+ const struct gpio_dt_spec *gpio,
+ const struct deferred_data *ud)
+{
+ if (!gpio_pin_get_dt(gpio)) {
+ usbc_interrupt_trigger(port);
+ hook_call_deferred(ud, USBC_INT_POLL_DELAY_US);
}
+}
-USBC_INT_POLL(0)
-USBC_INT_POLL(1)
+static void poll_c0_int (void)
+{
+ poll_usb_gpio(0,
+ GPIO_DT_FROM_NODELABEL(gpio_usb_c0_int_odl),
+ &poll_c0_int_data);
+}
+
+static void poll_c1_int (void)
+{
+ poll_usb_gpio(1,
+ GPIO_DT_FROM_ALIAS(gpio_usb_c1_int_odl),
+ &poll_c1_int_data);
+}
void usb_interrupt(enum gpio_signal signal)
{