summaryrefslogtreecommitdiff
path: root/zephyr/shim/src/bc12_rt9490.c
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/shim/src/bc12_rt9490.c')
-rw-r--r--zephyr/shim/src/bc12_rt9490.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/zephyr/shim/src/bc12_rt9490.c b/zephyr/shim/src/bc12_rt9490.c
index abecfcfa3a..df10fb5570 100644
--- a/zephyr/shim/src/bc12_rt9490.c
+++ b/zephyr/shim/src/bc12_rt9490.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.
*/
@@ -19,20 +19,25 @@ static void rt9490_bc12_enable_irqs(void)
}
DECLARE_HOOK(HOOK_INIT, rt9490_bc12_enable_irqs, HOOK_PRIO_DEFAULT);
-#define GPIO_SIGNAL_FROM_INST(inst) \
- GPIO_SIGNAL(DT_PHANDLE(DT_INST_PHANDLE(inst, irq), irq_pin))
+#define RT9490_DISPATCH_INTERRUPT(usbc_id, bc12_id) \
+ IF_ENABLED(DT_NODE_HAS_PROP(bc12_id, irq), \
+ (case GPIO_SIGNAL( \
+ DT_PHANDLE(DT_PHANDLE(bc12_id, irq), irq_pin)) \
+ : rt9490_interrupt(USBC_PORT_NEW(usbc_id)); \
+ break;))
-#define RT9490_DISPATCH_INTERRUPT(inst) \
- IF_ENABLED(DT_INST_NODE_HAS_PROP(inst, irq), \
- (case GPIO_SIGNAL_FROM_INST(inst): \
- rt9490_interrupt(USBC_PORT_FROM_INST(inst)); \
- break; \
- ))
+#define RT9490_CHECK(usbc_id, bc12_id) \
+ COND_CODE_1(DT_NODE_HAS_COMPAT(bc12_id, richtek_rt9490_bc12), \
+ (RT9490_DISPATCH_INTERRUPT(usbc_id, bc12_id)), ())
+
+#define RT9490_INTERRUPT(usbc_id) \
+ COND_CODE_1(DT_NODE_HAS_PROP(usbc_id, bc12), \
+ (RT9490_CHECK(usbc_id, DT_PHANDLE(usbc_id, bc12))), ())
void rt9490_bc12_dt_interrupt(enum gpio_signal signal)
{
switch (signal) {
- DT_INST_FOREACH_STATUS_OKAY(RT9490_DISPATCH_INTERRUPT);
+ DT_FOREACH_STATUS_OKAY(named_usbc_port, RT9490_INTERRUPT)
default:
break;
}