Reviewed-by: Glenn Miles <[email protected]>

Thanks,

Glenn

On Thu, 2026-07-09 at 17:23 +0200, Emmanuel Blot wrote:
> Introduce a qtest for the PCA9555 16-bit I/O port expander.
> 
> This first set covers the power-on reset defaults and the read/write
> behaviour of the OUTPUT, CONFIG and POLARITY register pairs.
> 
> Signed-off-by: Emmanuel Blot <[email protected]>
> ---
>  tests/qtest/meson.build    |  1 +
>  tests/qtest/pca9555-test.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 45 insertions(+)
> 
> diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
> index 56ff860e21..2c283708a5 100644
> --- a/tests/qtest/meson.build
> +++ b/tests/qtest/meson.build
> @@ -318,6 +318,7 @@ qos_test_ss.add(
>    'tulip-test.c',
>    'nvme-test.c',
>    'pca9552-test.c',
> +  'pca9555-test.c',
>    'pci-test.c',
>    'pcnet-test.c',
>    'rs5c372-test.c',
> diff --git a/tests/qtest/pca9555-test.c b/tests/qtest/pca9555-test.c
> new file mode 100644
> index 0000000000..5945c3441e
> --- /dev/null
> +++ b/tests/qtest/pca9555-test.c
> @@ -0,0 +1,44 @@
> +/*
> + * QTest testcase for the PCA9555 16-bit I/O port expander
> + *
> + * Copyright (c) Meta Platforms, Inc. and affiliates.
> + *
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + */
> +
> +#include "qemu/osdep.h"
> +#include "hw/gpio/pca9552_regs.h"
> +#include "libqos/i2c.h"
> +#include "libqos/qgraph.h"
> +
> +#define PCA9555_TEST_ADDR 0x20
> +
> +/* Verify power-on reset defaults match the PCA9555 datasheet. */
> +static void test_reset_defaults(void *obj, void *data, QGuestAllocator 
> *alloc)
> +{
> +    QI2CDevice *dev = (QI2CDevice *)obj;
> +
> +    g_assert_cmphex(i2c_get8(dev, PCA9535_INPUT0), ==, 0xFF);
> +    g_assert_cmphex(i2c_get8(dev, PCA9535_INPUT1), ==, 0xFF);
> +    g_assert_cmphex(i2c_get8(dev, PCA9535_OUTPUT0), ==, 0xFF);
> +    g_assert_cmphex(i2c_get8(dev, PCA9535_OUTPUT1), ==, 0xFF);
> +    g_assert_cmphex(i2c_get8(dev, PCA9535_POLARITY0), ==, 0x00);
> +    g_assert_cmphex(i2c_get8(dev, PCA9535_POLARITY1), ==, 0x00);
> +    g_assert_cmphex(i2c_get8(dev, PCA9535_CONFIG0), ==, 0xFF);
> +    g_assert_cmphex(i2c_get8(dev, PCA9535_CONFIG1), ==, 0xFF);
> +}
> +
> +static void pca9555_register_nodes(void)
> +{
> +    QOSGraphEdgeOptions opts = {
> +        .extra_device_opts = "address=0x20"
> +    };
> +    add_qi2c_address(&opts, &(QI2CAddress) { PCA9555_TEST_ADDR });
> +
> +    qos_node_create_driver("pca9555", i2c_device_create);
> +    qos_node_consumes("pca9555", "i2c-bus", &opts);
> +
> +    qos_add_test("reset-defaults", "pca9555", test_reset_defaults, NULL);
> +}
> +
> +libqos_init(pca9555_register_nodes);
> 


Reply via email to