diff options
author | linyuny <linyuny@google.com> | 2023-03-21 17:25:29 +0000 |
---|---|---|
committer | Holmes Chou <holmeschou@google.com> | 2023-04-14 13:33:34 +0000 |
commit | f51349f33ed7ff261298295c97820a0d646b3f8d (patch) | |
tree | d0725652e2471de1ffa542e3d762e8c621358058 | |
parent | 6e6bed066f87e89556cc3ace1b2ae6db25267daf (diff) | |
download | lwis-f51349f33ed7ff261298295c97820a0d646b3f8d.tar.gz |
LWIS: test infra refactor: implement the lwis_test device read the interrupt info from dts tree.
Hardcode the fake injection number to 999 based on the reference from dt-bindings/interrupt-controller/zuma.
Bug: 259134778
Test: atest LwisClientAndroidTest
Change-Id: I86f6e5864db1c751f5f7fbcd44e8c36496eab5dd
Signed-off-by: linyuny <linyuny@google.com>
-rw-r--r-- | lwis_device_test.h | 2 | ||||
-rw-r--r-- | lwis_dt.c | 21 | ||||
-rw-r--r-- | lwis_interrupt.h | 3 | ||||
-rw-r--r-- | lwis_ioctl.c | 1 |
4 files changed, 24 insertions, 3 deletions
diff --git a/lwis_device_test.h b/lwis_device_test.h index 4012954..93b19b7 100644 --- a/lwis_device_test.h +++ b/lwis_device_test.h @@ -16,6 +16,8 @@ #include "lwis_device.h" #define SCRATCH_TEST_DEV_MEMORY_SIZE 32 +#define TEST_DEVICE_IRQ_CNT 1 +#define TEST_DEVICE_FAKE_INJECTION_IRQ 999 /* * struct lwis_test_device @@ -635,7 +635,12 @@ static int parse_interrupts(struct lwis_device *lwis_dev) plat_dev = lwis_dev->plat_dev; dev_node = plat_dev->dev.of_node; - count = platform_irq_count(plat_dev); + /* Test device type DEVICE_TYPE_TEST used for test, platform independent. */ + if (lwis_dev->type == DEVICE_TYPE_TEST) { + count = TEST_DEVICE_IRQ_CNT; + } else { + count = platform_irq_count(plat_dev); + } /* No interrupts found, just return */ if (count <= 0) { @@ -645,7 +650,11 @@ static int parse_interrupts(struct lwis_device *lwis_dev) lwis_dev->irqs = lwis_interrupt_list_alloc(lwis_dev, count); if (IS_ERR(lwis_dev->irqs)) { - pr_err("Failed to allocate IRQ list\n"); + if (lwis_dev->type == DEVICE_TYPE_TEST) { + pr_err("Failed to allocate injection\n"); + } else { + pr_err("Failed to allocate IRQ list\n"); + } return PTR_ERR(lwis_dev->irqs); } @@ -749,6 +758,8 @@ static int parse_interrupts(struct lwis_device *lwis_dev) irq_type = AGGREGATE_INTERRUPT; } else if (strcmp(irq_type_str, "leaf") == 0) { irq_type = LEAF_INTERRUPT; + } else if (strcmp(irq_type_str, "injection") == 0) { + irq_type = FAKEEVENT_INTERRUPT; } else { pr_err("Invalid irq-type from dt: %s\n", irq_type_str); return ret; @@ -767,6 +778,12 @@ static int parse_interrupts(struct lwis_device *lwis_dev) pr_err("Cannot set irq %s\n", name); goto error_event_infos; } + } else if (irq_type == FAKEEVENT_INTERRUPT) { + /* + * Hardcode the fake injection irq number to + * TEST_DEVICE_FAKE_INJECTION_IRQ + */ + lwis_dev->irqs->irq[i].irq = TEST_DEVICE_FAKE_INJECTION_IRQ; } /* Parse event info */ diff --git a/lwis_interrupt.h b/lwis_interrupt.h index 345fa3f..e12c160 100644 --- a/lwis_interrupt.h +++ b/lwis_interrupt.h @@ -24,7 +24,8 @@ enum lwis_interrupt_types { REGULAR_INTERRUPT, AGGREGATE_INTERRUPT, LEAF_INTERRUPT, - GPIO_HW_INTERRUPT + GPIO_HW_INTERRUPT, + FAKEEVENT_INTERRUPT }; /* diff --git a/lwis_ioctl.c b/lwis_ioctl.c index dda5d03..debeb4d 100644 --- a/lwis_ioctl.c +++ b/lwis_ioctl.c @@ -24,6 +24,7 @@ #include "lwis_device_dpm.h" #include "lwis_device_i2c.h" #include "lwis_device_ioreg.h" +#include "lwis_device_test.h" #include "lwis_event.h" #include "lwis_fence.h" #include "lwis_i2c.h" |