From nobody Mon Feb 9 09:24:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1627945591; cv=none; d=zohomail.com; s=zohoarc; b=O/1/iV7HhtefqezNK5fjpsUMN5LGb249kqmKfADTACJVOrOdEq0JRZ0wwTDMPBy/r5QwSXFVwLIJz2pCb5pnFdg4jPzph871LMRNzp2lhQtn3u7JMJhB3XlZvtPvzz5KBMOZ88zRqlPDP5uMhKmvr2D3aJVFs9oxwPYu5Yh5rsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627945591; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e/dTbrxSAOETGr5gU6Sr7f/b7cvGQLB7erwbwnHaelY=; b=TN4z9Jp8Q3FOVYrWsaXVPAPjlK8owiaz21Ixkt1WGdHfU2E7EeFjvNgsn8EH8gQWe3KoBjUWMg8V+S2Bwysr533oX5TNhHfQLF6qBO9yPfyhbqWjYcoSHYxeo1W6R8+SX7MYwUi4GD6HOHy6iUOsgdxzfUQAInw+IjofbDztiXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1627945591654371.45414297811794; Mon, 2 Aug 2021 16:06:31 -0700 (PDT) Received: from localhost ([::1]:46286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAh0w-0004Pv-E0 for importer@patchew.org; Mon, 02 Aug 2021 19:06:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58178) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3xXkIYQUKCugcdWKYQYYQVO.MYWaOWe-NOfOVXYXQXe.YbQ@flex--stmao.bounces.google.com>) id 1mAgyD-0001Lb-Mv for qemu-devel@nongnu.org; Mon, 02 Aug 2021 19:03:41 -0400 Received: from mail-qv1-xf49.google.com ([2607:f8b0:4864:20::f49]:35574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <3xXkIYQUKCugcdWKYQYYQVO.MYWaOWe-NOfOVXYXQXe.YbQ@flex--stmao.bounces.google.com>) id 1mAgy7-00062p-2m for qemu-devel@nongnu.org; Mon, 02 Aug 2021 19:03:41 -0400 Received: by mail-qv1-xf49.google.com with SMTP id j13-20020a0cf30d0000b029032dd803a7edso14092556qvl.2 for ; Mon, 02 Aug 2021 16:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=e/dTbrxSAOETGr5gU6Sr7f/b7cvGQLB7erwbwnHaelY=; b=teOf0SNHRsj4Oj3jxpLfz5cUn5WyoCw9pq6IcM0cO9q4ZLNj0GcKaf5GZg2kjsaCfF Bpc2eZs7uCJmMwe+lZV+g8+vWjHqsm5KnLE4EYinOeWaV1JXxm76QVITSGQgWlK/e6AN 6c/aOMv6On65kEw+DQn4w9P7pETCbJ4+Ec8muw9GGC8BH6LpmWUPq26yT/RpAAW2a+Q1 hchdIBc1SvedZ4BxFSpVCn+UXxwCnuGhx25GR1+xuvUZuSKMHoqQvaJPE2whPGybwUJh Ck5Za/lIhCntvxNOE+WHEnA8vqYeMRnH9GTrYCrL2zRS4FWoTk5KonAvdfwtiTTOjkyF kc7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=e/dTbrxSAOETGr5gU6Sr7f/b7cvGQLB7erwbwnHaelY=; b=BGGyF9NwH7EX9Y2FIL1+xKJhHEObejFzEW7Ofvb7VTlb5V8RlwgK0HBMKXAOe8J7uz DhwvjPvTOw3VZBT4SOPC7C1XUZXsiyGGPJA8wqgnfjCRGcwesGfWzE9DpQorhKq/v1Sw KTm/BGV4+mNAAaZtkczeAseHHpqQv7/c7EKexhplTypk7g/u3byiI1AL83k4DU/CW/RA 2l7PN/4B/72FUab6Z2GPmRJ97FzSo1+qeRy6N8G+Qb69pb2uSYyPR31JjeiemJVEFhDb N/ixbzPjq5/i06PwwZNMYWVLXmsjd96Noa5vYcpihqLCn+0DYw0fWWDDnX7Ut+TW/SfE Z1/Q== X-Gm-Message-State: AOAM530BVz5rlN5EIi4IpoGbizZouzSBAttfG/aXDIfJ+JgIw2gKqHlX RuSTDDgQDWnYctbH4loGoeIu0jTkrA== X-Google-Smtp-Source: ABdhPJxKemMK6QY4Ckfpe0hnGaY4Iz10S82hFb/Csi9y/+in2//USPpTmA7qkpxUlApEsBOIH4QzaSL6rQ== X-Received: from smvm.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2d5f]) (user=stmao job=sendgmr) by 2002:ad4:4ae6:: with SMTP id cp6mr18722197qvb.23.1627945413734; Mon, 02 Aug 2021 16:03:33 -0700 (PDT) Date: Mon, 2 Aug 2021 23:03:21 +0000 In-Reply-To: <20210802230323.1164787-1-stmao@google.com> Message-Id: <20210802230323.1164787-2-stmao@google.com> Mime-Version: 1.0 References: <20210802230323.1164787-1-stmao@google.com> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [PATCH 1/1] hw/i2c: add remote I2C device From: Shengtan Mao To: cminyard@mvista.com Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, stmao@google.com, crauer@google.com, wuhaotsh@google.com, venture@google.com, maoshengtan2011@gmail.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f49; envelope-from=3xXkIYQUKCugcdWKYQYYQVO.MYWaOWe-NOfOVXYXQXe.YbQ@flex--stmao.bounces.google.com; helo=mail-qv1-xf49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1627945593763100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch adds the remote I2C device, which supports the usage of external I2C devices. Signed-off-by: Shengtan Mao --- hw/arm/Kconfig | 1 + hw/i2c/Kconfig | 4 + hw/i2c/meson.build | 1 + hw/i2c/remote-i2c.c | 117 ++++++++++++++++++ tests/qtest/meson.build | 1 + tests/qtest/remote-i2c-test.c | 216 ++++++++++++++++++++++++++++++++++ 6 files changed, 340 insertions(+) create mode 100644 hw/i2c/remote-i2c.c create mode 100644 tests/qtest/remote-i2c-test.c diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 90b19c0861..58fdfab90d 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -392,6 +392,7 @@ config NPCM7XX select MAX34451 select PL310 # cache controller select PMBUS + select REMOTE_I2C select SERIAL select SSI select UNIMP diff --git a/hw/i2c/Kconfig b/hw/i2c/Kconfig index 8217cb5041..278156991d 100644 --- a/hw/i2c/Kconfig +++ b/hw/i2c/Kconfig @@ -1,6 +1,10 @@ config I2C bool =20 +config REMOTE_I2C + bool + select I2C + config SMBUS bool select I2C diff --git a/hw/i2c/meson.build b/hw/i2c/meson.build index d3df273251..ba0215db61 100644 --- a/hw/i2c/meson.build +++ b/hw/i2c/meson.build @@ -6,6 +6,7 @@ i2c_ss.add(when: 'CONFIG_ACPI_X86_ICH', if_true: files('smb= us_ich9.c')) i2c_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_i2c.c')) i2c_ss.add(when: 'CONFIG_BITBANG_I2C', if_true: files('bitbang_i2c.c')) i2c_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_i2c.c')) +i2c_ss.add(when: 'CONFIG_REMOTE_I2C', if_true: files('remote-i2c.c')) i2c_ss.add(when: 'CONFIG_IMX_I2C', if_true: files('imx_i2c.c')) i2c_ss.add(when: 'CONFIG_MPC_I2C', if_true: files('mpc_i2c.c')) i2c_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('microbit_i2c.c')) diff --git a/hw/i2c/remote-i2c.c b/hw/i2c/remote-i2c.c new file mode 100644 index 0000000000..083eaf2210 --- /dev/null +++ b/hw/i2c/remote-i2c.c @@ -0,0 +1,117 @@ +/* + * Remote I2C Device + * + * Copyright (c) 2021 Google LLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "qemu/osdep.h" + +#include "chardev/char-fe.h" +#include "hw/i2c/i2c.h" +#include "hw/qdev-properties-system.h" + +#define TYPE_REMOTE_I2C "remote-i2c" +#define REMOTE_I2C(obj) OBJECT_CHECK(RemoteI2CState, (obj), TYPE_REMOTE_I2= C) +#define ONE_BYTE 1 + +typedef struct { + I2CSlave parent_obj; + CharBackend chr; +} RemoteI2CState; + +typedef enum { + REMOTE_I2C_START_RECV =3D 0, + REMOTE_I2C_START_SEND =3D 1, + REMOTE_I2C_FINISH =3D 2, + REMOTE_I2C_NACK =3D 3, + REMOTE_I2C_RECV =3D 4, + REMOTE_I2C_SEND =3D 5, +} RemoteI2CCommand; + +static uint8_t remote_i2c_recv(I2CSlave *s) +{ + RemoteI2CState *i2c =3D REMOTE_I2C(s); + uint8_t resp =3D 0; + uint8_t type =3D REMOTE_I2C_RECV; + qemu_chr_fe_write_all(&i2c->chr, &type, ONE_BYTE); + + qemu_chr_fe_read_all(&i2c->chr, &resp, ONE_BYTE); + return resp; +} + +static int remote_i2c_send(I2CSlave *s, uint8_t data) +{ + RemoteI2CState *i2c =3D REMOTE_I2C(s); + uint8_t type =3D REMOTE_I2C_SEND; + uint8_t resp =3D 1; + qemu_chr_fe_write_all(&i2c->chr, &type, ONE_BYTE); + qemu_chr_fe_write_all(&i2c->chr, &data, ONE_BYTE); + + qemu_chr_fe_read_all(&i2c->chr, &resp, ONE_BYTE); + return resp ? -1 : 0; +} + +/* Returns non-zero when no response from the device. */ +static int remote_i2c_event(I2CSlave *s, enum i2c_event event) +{ + RemoteI2CState *i2c =3D REMOTE_I2C(s); + uint8_t type; + uint8_t resp =3D 1; + switch (event) { + case I2C_START_RECV: + type =3D REMOTE_I2C_START_RECV; + break; + case I2C_START_SEND: + type =3D REMOTE_I2C_START_SEND; + break; + case I2C_FINISH: + type =3D REMOTE_I2C_FINISH; + break; + case I2C_NACK: + type =3D REMOTE_I2C_NACK; + } + qemu_chr_fe_write_all(&i2c->chr, &type, ONE_BYTE); + qemu_chr_fe_read_all(&i2c->chr, &resp, ONE_BYTE); + return resp ? -1 : 0; +} + +static Property remote_i2c_props[] =3D { + DEFINE_PROP_CHR("chardev", RemoteI2CState, chr), + DEFINE_PROP_END_OF_LIST(), +}; + +static void remote_i2c_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + I2CSlaveClass *k =3D I2C_SLAVE_CLASS(klass); + + k->recv =3D &remote_i2c_recv; + k->send =3D &remote_i2c_send; + k->event =3D &remote_i2c_event; + device_class_set_props(dc, remote_i2c_props); +} + +static const TypeInfo remote_i2c_type =3D { + .name =3D TYPE_REMOTE_I2C, + .parent =3D TYPE_I2C_SLAVE, + .instance_size =3D sizeof(RemoteI2CState), + .class_size =3D sizeof(I2CSlaveClass), + .class_init =3D remote_i2c_class_init, +}; + +static void remote_i2c_register(void) +{ + type_register_static(&remote_i2c_type); +} + +type_init(remote_i2c_register) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index e22a0792c5..95faa2c379 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -218,6 +218,7 @@ qos_test_ss.add( 'pca9552-test.c', 'pci-test.c', 'pcnet-test.c', + 'remote-i2c-test.c', 'sdhci-test.c', 'spapr-phb-test.c', 'tmp105-test.c', diff --git a/tests/qtest/remote-i2c-test.c b/tests/qtest/remote-i2c-test.c new file mode 100644 index 0000000000..b6ab210e4c --- /dev/null +++ b/tests/qtest/remote-i2c-test.c @@ -0,0 +1,216 @@ +/* + * QTests for Remote I2C Device + * + * Copyright (c) 2021 Google LLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "qemu/osdep.h" + +#include "qemu/config-file.h" +#include "sysemu/sysemu.h" +#include "libqos/qgraph.h" +#include "libqos/i2c.h" + +#include + +#define TEST_ID "remote-i2c-test" +#define TEST_ADDR (0x62) +#define QEMU_CMD_CHR = \ + " -chardev socket,id=3Di2c-chardev,host=3Dlocalhost,port=3D%d,reconnec= t=3D10" + +typedef enum { + REMOTE_I2C_START_RECV =3D 0, + REMOTE_I2C_START_SEND =3D 1, + REMOTE_I2C_FINISH =3D 2, + REMOTE_I2C_NACK =3D 3, + REMOTE_I2C_RECV =3D 4, + REMOTE_I2C_SEND =3D 5, +} RemoteI2CCommand; + +static int setup_fd(int *sock) +{ + fd_set readfds; + int fd; + + FD_ZERO(&readfds); + FD_SET(*sock, &readfds); + g_assert(select((*sock) + 1, &readfds, NULL, NULL, NULL) =3D=3D 1); + + fd =3D accept(*sock, NULL, 0); + g_assert(fd >=3D 0); + + return fd; +} + +static void test_recv(QI2CDevice *i2cdev, int fd, uint8_t *msg, uint16_t l= en) +{ + uint16_t buf_size =3D len + 2; + uint8_t *buf =3D g_new(uint8_t, buf_size); + uint16_t bytes_read =3D 0; + uint8_t zero =3D 0; + ssize_t rv; + + /* write device responses to socket */ + rv =3D write(fd, &zero, 1); + g_assert_cmpint(rv, =3D=3D, 1); + rv =3D write(fd, msg, len); + g_assert_cmpint(rv, =3D=3D, len); + rv =3D write(fd, &zero, 1); + g_assert_cmpint(rv, =3D=3D, 1); + + /* check received value */ + qi2c_recv(i2cdev, buf, len); + for (int i =3D 0; i < len; ++i) { + g_assert_cmphex(buf[i], =3D=3D, msg[i]); + } + + /* check controller writes to chardev */ + do { + bytes_read +=3D read(fd, buf + bytes_read, buf_size - bytes_read); + } while (bytes_read < buf_size); + + g_assert_cmphex(buf[0], =3D=3D, REMOTE_I2C_START_RECV); + for (int i =3D 1; i < len - 1; ++i) { + g_assert_cmphex(buf[i], =3D=3D, REMOTE_I2C_RECV); + } + g_assert_cmphex(buf[buf_size - 1], =3D=3D, REMOTE_I2C_FINISH); + + g_free(buf); +} + +static void test_send(QI2CDevice *i2cdev, int fd, uint8_t *msg, uint16_t l= en) +{ + uint16_t buf_size =3D len * 2 + 2; + uint8_t *buf =3D g_new0(uint8_t, buf_size); + uint16_t bytes_read =3D 0; + ssize_t rv; + int j =3D 0; + + /* write device ACKs to socket*/ + rv =3D write(fd, buf, len + 2); + g_assert_cmpint(rv, =3D=3D, len + 2); + + qi2c_send(i2cdev, msg, len); + + /* check controller writes to chardev */ + do { + bytes_read +=3D read(fd, buf + bytes_read, buf_size - bytes_read); + } while (bytes_read < buf_size); + + g_assert_cmphex(buf[0], =3D=3D, REMOTE_I2C_START_SEND); + for (int i =3D 1; i < buf_size - 1; i +=3D 2) { + g_assert_cmphex(buf[i], =3D=3D, REMOTE_I2C_SEND); + g_assert_cmphex(buf[i + 1], =3D=3D, msg[j++]); + } + g_assert_cmphex(buf[buf_size - 1], =3D=3D, REMOTE_I2C_FINISH); + + g_free(buf); +} + +static void test_remote_i2c_recv(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + int *sock =3D (int *)data; + int fd =3D setup_fd(sock); + + uint8_t msg[] =3D {0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4= F}; + + test_recv(i2cdev, fd, msg, 1); + test_recv(i2cdev, fd, msg, 2); + test_recv(i2cdev, fd, msg, 3); + test_recv(i2cdev, fd, msg, 4); + test_recv(i2cdev, fd, msg, 5); + test_recv(i2cdev, fd, msg, 6); + test_recv(i2cdev, fd, msg, 7); + test_recv(i2cdev, fd, msg, 8); + test_recv(i2cdev, fd, msg, 9); +} + +static void test_remote_i2c_send(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + int *sock =3D (int *)data; + int fd =3D setup_fd(sock); + + uint8_t msg[] =3D {0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4= F}; + + test_send(i2cdev, fd, msg, 1); + test_send(i2cdev, fd, msg, 2); + test_send(i2cdev, fd, msg, 3); + test_send(i2cdev, fd, msg, 4); + test_send(i2cdev, fd, msg, 5); + test_send(i2cdev, fd, msg, 6); + test_send(i2cdev, fd, msg, 7); + test_send(i2cdev, fd, msg, 8); + test_send(i2cdev, fd, msg, 9); +} + +static in_port_t open_socket(int *sock) +{ + struct sockaddr_in myaddr; + socklen_t addrlen; + + myaddr.sin_family =3D AF_INET; + myaddr.sin_addr.s_addr =3D htonl(INADDR_LOOPBACK); + myaddr.sin_port =3D 0; + + *sock =3D socket(AF_INET, SOCK_STREAM, 0); + g_assert(*sock !=3D -1); + g_assert(bind(*sock, (struct sockaddr *)&myaddr, sizeof(myaddr)) !=3D = -1); + + addrlen =3D sizeof(myaddr); + g_assert(getsockname(*sock, (struct sockaddr *)&myaddr, &addrlen) !=3D= -1); + g_assert(listen(*sock, 1) !=3D -1); + + return ntohs(myaddr.sin_port); +} + +static void remote_i2c_test_cleanup(void *socket) +{ + int *s =3D socket; + + close(*s); + qos_invalidate_command_line(); + g_free(s); +} + +static void *remote_i2c_test_setup(GString *cmd_line, void *arg) +{ + int *sock =3D g_new(int, 1); + + g_string_append_printf(cmd_line, QEMU_CMD_CHR, open_socket(sock)); + g_test_queue_destroy(remote_i2c_test_cleanup, sock); + return sock; +} + +static void register_remote_i2c_test(void) +{ + QOSGraphEdgeOptions edge =3D { + .extra_device_opts =3D "id=3D" TEST_ID ",address=3D0x62,chardev=3D= i2c-chardev"}; + add_qi2c_address(&edge, &(QI2CAddress){TEST_ADDR}); + + qos_node_create_driver("remote-i2c", i2c_device_create); + qos_node_consumes("remote-i2c", "i2c-bus", &edge); + + QOSGraphTestOptions opts =3D { + .before =3D remote_i2c_test_setup, + }; + qemu_add_opts(&qemu_chardev_opts); + qos_add_test("test_remote_i2c_recv", "remote-i2c", test_remote_i2c_rec= v, + &opts); + qos_add_test("test_remote_i2c_send", "remote-i2c", test_remote_i2c_sen= d, + &opts); +} +libqos_init(register_remote_i2c_test); --=20 2.32.0.554.ge1b32706d8-goog From nobody Mon Feb 9 09:24:07 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=google.com ARC-Seal: i=1; a=rsa-sha256; t=1627945695; cv=none; d=zohomail.com; s=zohoarc; b=ATsWQawv72oK2xM5UDeApXIJsoU3IU/mz1sb/1WIPI+PtqqOKBk132H9/SVTYyCj5qos2n/hm8X08ys5l2rgkFuJCvM5NtVrLs/8eP+6Ud7lwhSYaV74mxl/31eRKcF+44OiIIk3lKW9T0BjAUL1elUVyjTgKp/rPPvjWriP05U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1627945695; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e/dTbrxSAOETGr5gU6Sr7f/b7cvGQLB7erwbwnHaelY=; b=IUNaZ3tMJHmI8zmvA5MGTBngGPohekFHih3hed6DH+02UNWPq7Ych1j01v1vNtOyY7ZjndrHMoEkGnGpnHID1Gx12M4PWDESOBqHDe9O/D2KSpwFBPrU7LOUO8PEhFb/OVZkdYCuhoobI4pkH5U0KC26TkZOOtPfwH24/zBn7Mk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1627945695706654.5892678627752; Mon, 2 Aug 2021 16:08:15 -0700 (PDT) Received: from localhost ([::1]:48722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mAh2c-00062l-Ko for importer@patchew.org; Mon, 02 Aug 2021 19:08:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <30HkIYQUKCvMnohVjbjjbgZ.XjhlZhp-YZqZgijibip.jmb@flex--stmao.bounces.google.com>) id 1mAgyL-0001j7-Ti for qemu-devel@nongnu.org; Mon, 02 Aug 2021 19:03:49 -0400 Received: from mail-vs1-xe49.google.com ([2607:f8b0:4864:20::e49]:41864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <30HkIYQUKCvMnohVjbjjbgZ.XjhlZhp-YZqZgijibip.jmb@flex--stmao.bounces.google.com>) id 1mAgyI-00069z-PC for qemu-devel@nongnu.org; Mon, 02 Aug 2021 19:03:49 -0400 Received: by mail-vs1-xe49.google.com with SMTP id b25-20020a67d3990000b029029d56014516so3308119vsj.8 for ; Mon, 02 Aug 2021 16:03:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=e/dTbrxSAOETGr5gU6Sr7f/b7cvGQLB7erwbwnHaelY=; b=bEFLGOOygpyBDQdFgTo3oxHwY3cHssCYVaOU1/9wKQ96XlaTO0c9vTvU685KIqab9U uUXOTjQ/ULHL+PpJo9oUs0wIeoYXh8qPGZsCAuw++4cX8vE1Szg+mD50+K4ChzEW868o MyPcKoeFRs0WJrqZIOdqYgnBwf+o27paEWF4zl0Wt/S+qKR0unEy2lgbV/QUS35thqev 3yo0Ox8TXPrqjifQPQwKK53nOWndsXw4VOW+qy2nYTCEXYaunftaMQz++0XO8xwbTYzp STmMqL1CkenqX3oOPmkx7Dzuc9Uztc1OVXmWyWry3V6wcrtkuPgoCdM8tOAB5tyq3bnI QLQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=e/dTbrxSAOETGr5gU6Sr7f/b7cvGQLB7erwbwnHaelY=; b=I0dqzKlC4Dj5cwLSQe9oXk9V+b6ws7J3l39Z3qfxdOaokNgAN8ADbaJt9ulT/t15WE OJbehf2XNFfefGMJ+nh9/6+FTdeGA7+v9CAX9aZf6JYQkA58NrQitVwqgFKWceyrkDMb gcVtwHvE5T7lr1W5Jbd9zYSrGi7Hfg92klDhmm885E7fov+I2M05hfevlglVA9qt9bG+ dlx9n94vkVHh28/hIjawvMYCUhbu12ejagd8Ig+aHSuAvge3KZsdHSNXX1bqIfJk0KY4 9sjMETzynQGVNMhQRIuwRLGJcVdF7KjWXTG9i2DzB12UkHZOM3/N1W0E92Jv9jmXXFTi t++g== X-Gm-Message-State: AOAM532k7Bp0DwP5WJGvZBmDoA/YWK1/5aBoRkMCQ7x+AqgtD+7TQWc4 TJ8NReSKDqkLI0Tm+mRMYxzk2dXF5A== X-Google-Smtp-Source: ABdhPJy+Q2z5kUk9x0n7UmeMo9ZVCMNSzjGr+Wix4u/ylyBcBNaPLTuIgpuVVZxil63S0djZuCpOGeYO/g== X-Received: from smvm.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2d5f]) (user=stmao job=sendgmr) by 2002:a67:c394:: with SMTP id s20mr3839577vsj.42.1627945424307; Mon, 02 Aug 2021 16:03:44 -0700 (PDT) Date: Mon, 2 Aug 2021 23:03:23 +0000 In-Reply-To: <20210802230323.1164787-1-stmao@google.com> Message-Id: <20210802230323.1164787-4-stmao@google.com> Mime-Version: 1.0 References: <20210802230323.1164787-1-stmao@google.com> X-Mailer: git-send-email 2.32.0.554.ge1b32706d8-goog Subject: [PATCH v2 1/1] hw/i2c: add remote I2C device From: Shengtan Mao To: cminyard@mvista.com Cc: qemu-arm@nongnu.org, qemu-devel@nongnu.org, stmao@google.com, crauer@google.com, wuhaotsh@google.com, venture@google.com, maoshengtan2011@gmail.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e49; envelope-from=30HkIYQUKCvMnohVjbjjbgZ.XjhlZhp-YZqZgijibip.jmb@flex--stmao.bounces.google.com; helo=mail-vs1-xe49.google.com X-Spam_score_int: -95 X-Spam_score: -9.6 X-Spam_bar: --------- X-Spam_report: (-9.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1627945695994100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch adds the remote I2C device, which supports the usage of external I2C devices. Signed-off-by: Shengtan Mao --- hw/arm/Kconfig | 1 + hw/i2c/Kconfig | 4 + hw/i2c/meson.build | 1 + hw/i2c/remote-i2c.c | 117 ++++++++++++++++++ tests/qtest/meson.build | 1 + tests/qtest/remote-i2c-test.c | 216 ++++++++++++++++++++++++++++++++++ 6 files changed, 340 insertions(+) create mode 100644 hw/i2c/remote-i2c.c create mode 100644 tests/qtest/remote-i2c-test.c diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig index 90b19c0861..58fdfab90d 100644 --- a/hw/arm/Kconfig +++ b/hw/arm/Kconfig @@ -392,6 +392,7 @@ config NPCM7XX select MAX34451 select PL310 # cache controller select PMBUS + select REMOTE_I2C select SERIAL select SSI select UNIMP diff --git a/hw/i2c/Kconfig b/hw/i2c/Kconfig index 8217cb5041..278156991d 100644 --- a/hw/i2c/Kconfig +++ b/hw/i2c/Kconfig @@ -1,6 +1,10 @@ config I2C bool =20 +config REMOTE_I2C + bool + select I2C + config SMBUS bool select I2C diff --git a/hw/i2c/meson.build b/hw/i2c/meson.build index d3df273251..ba0215db61 100644 --- a/hw/i2c/meson.build +++ b/hw/i2c/meson.build @@ -6,6 +6,7 @@ i2c_ss.add(when: 'CONFIG_ACPI_X86_ICH', if_true: files('smb= us_ich9.c')) i2c_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_i2c.c')) i2c_ss.add(when: 'CONFIG_BITBANG_I2C', if_true: files('bitbang_i2c.c')) i2c_ss.add(when: 'CONFIG_EXYNOS4', if_true: files('exynos4210_i2c.c')) +i2c_ss.add(when: 'CONFIG_REMOTE_I2C', if_true: files('remote-i2c.c')) i2c_ss.add(when: 'CONFIG_IMX_I2C', if_true: files('imx_i2c.c')) i2c_ss.add(when: 'CONFIG_MPC_I2C', if_true: files('mpc_i2c.c')) i2c_ss.add(when: 'CONFIG_NRF51_SOC', if_true: files('microbit_i2c.c')) diff --git a/hw/i2c/remote-i2c.c b/hw/i2c/remote-i2c.c new file mode 100644 index 0000000000..083eaf2210 --- /dev/null +++ b/hw/i2c/remote-i2c.c @@ -0,0 +1,117 @@ +/* + * Remote I2C Device + * + * Copyright (c) 2021 Google LLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "qemu/osdep.h" + +#include "chardev/char-fe.h" +#include "hw/i2c/i2c.h" +#include "hw/qdev-properties-system.h" + +#define TYPE_REMOTE_I2C "remote-i2c" +#define REMOTE_I2C(obj) OBJECT_CHECK(RemoteI2CState, (obj), TYPE_REMOTE_I2= C) +#define ONE_BYTE 1 + +typedef struct { + I2CSlave parent_obj; + CharBackend chr; +} RemoteI2CState; + +typedef enum { + REMOTE_I2C_START_RECV =3D 0, + REMOTE_I2C_START_SEND =3D 1, + REMOTE_I2C_FINISH =3D 2, + REMOTE_I2C_NACK =3D 3, + REMOTE_I2C_RECV =3D 4, + REMOTE_I2C_SEND =3D 5, +} RemoteI2CCommand; + +static uint8_t remote_i2c_recv(I2CSlave *s) +{ + RemoteI2CState *i2c =3D REMOTE_I2C(s); + uint8_t resp =3D 0; + uint8_t type =3D REMOTE_I2C_RECV; + qemu_chr_fe_write_all(&i2c->chr, &type, ONE_BYTE); + + qemu_chr_fe_read_all(&i2c->chr, &resp, ONE_BYTE); + return resp; +} + +static int remote_i2c_send(I2CSlave *s, uint8_t data) +{ + RemoteI2CState *i2c =3D REMOTE_I2C(s); + uint8_t type =3D REMOTE_I2C_SEND; + uint8_t resp =3D 1; + qemu_chr_fe_write_all(&i2c->chr, &type, ONE_BYTE); + qemu_chr_fe_write_all(&i2c->chr, &data, ONE_BYTE); + + qemu_chr_fe_read_all(&i2c->chr, &resp, ONE_BYTE); + return resp ? -1 : 0; +} + +/* Returns non-zero when no response from the device. */ +static int remote_i2c_event(I2CSlave *s, enum i2c_event event) +{ + RemoteI2CState *i2c =3D REMOTE_I2C(s); + uint8_t type; + uint8_t resp =3D 1; + switch (event) { + case I2C_START_RECV: + type =3D REMOTE_I2C_START_RECV; + break; + case I2C_START_SEND: + type =3D REMOTE_I2C_START_SEND; + break; + case I2C_FINISH: + type =3D REMOTE_I2C_FINISH; + break; + case I2C_NACK: + type =3D REMOTE_I2C_NACK; + } + qemu_chr_fe_write_all(&i2c->chr, &type, ONE_BYTE); + qemu_chr_fe_read_all(&i2c->chr, &resp, ONE_BYTE); + return resp ? -1 : 0; +} + +static Property remote_i2c_props[] =3D { + DEFINE_PROP_CHR("chardev", RemoteI2CState, chr), + DEFINE_PROP_END_OF_LIST(), +}; + +static void remote_i2c_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + I2CSlaveClass *k =3D I2C_SLAVE_CLASS(klass); + + k->recv =3D &remote_i2c_recv; + k->send =3D &remote_i2c_send; + k->event =3D &remote_i2c_event; + device_class_set_props(dc, remote_i2c_props); +} + +static const TypeInfo remote_i2c_type =3D { + .name =3D TYPE_REMOTE_I2C, + .parent =3D TYPE_I2C_SLAVE, + .instance_size =3D sizeof(RemoteI2CState), + .class_size =3D sizeof(I2CSlaveClass), + .class_init =3D remote_i2c_class_init, +}; + +static void remote_i2c_register(void) +{ + type_register_static(&remote_i2c_type); +} + +type_init(remote_i2c_register) diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index e22a0792c5..95faa2c379 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -218,6 +218,7 @@ qos_test_ss.add( 'pca9552-test.c', 'pci-test.c', 'pcnet-test.c', + 'remote-i2c-test.c', 'sdhci-test.c', 'spapr-phb-test.c', 'tmp105-test.c', diff --git a/tests/qtest/remote-i2c-test.c b/tests/qtest/remote-i2c-test.c new file mode 100644 index 0000000000..b6ab210e4c --- /dev/null +++ b/tests/qtest/remote-i2c-test.c @@ -0,0 +1,216 @@ +/* + * QTests for Remote I2C Device + * + * Copyright (c) 2021 Google LLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "qemu/osdep.h" + +#include "qemu/config-file.h" +#include "sysemu/sysemu.h" +#include "libqos/qgraph.h" +#include "libqos/i2c.h" + +#include + +#define TEST_ID "remote-i2c-test" +#define TEST_ADDR (0x62) +#define QEMU_CMD_CHR = \ + " -chardev socket,id=3Di2c-chardev,host=3Dlocalhost,port=3D%d,reconnec= t=3D10" + +typedef enum { + REMOTE_I2C_START_RECV =3D 0, + REMOTE_I2C_START_SEND =3D 1, + REMOTE_I2C_FINISH =3D 2, + REMOTE_I2C_NACK =3D 3, + REMOTE_I2C_RECV =3D 4, + REMOTE_I2C_SEND =3D 5, +} RemoteI2CCommand; + +static int setup_fd(int *sock) +{ + fd_set readfds; + int fd; + + FD_ZERO(&readfds); + FD_SET(*sock, &readfds); + g_assert(select((*sock) + 1, &readfds, NULL, NULL, NULL) =3D=3D 1); + + fd =3D accept(*sock, NULL, 0); + g_assert(fd >=3D 0); + + return fd; +} + +static void test_recv(QI2CDevice *i2cdev, int fd, uint8_t *msg, uint16_t l= en) +{ + uint16_t buf_size =3D len + 2; + uint8_t *buf =3D g_new(uint8_t, buf_size); + uint16_t bytes_read =3D 0; + uint8_t zero =3D 0; + ssize_t rv; + + /* write device responses to socket */ + rv =3D write(fd, &zero, 1); + g_assert_cmpint(rv, =3D=3D, 1); + rv =3D write(fd, msg, len); + g_assert_cmpint(rv, =3D=3D, len); + rv =3D write(fd, &zero, 1); + g_assert_cmpint(rv, =3D=3D, 1); + + /* check received value */ + qi2c_recv(i2cdev, buf, len); + for (int i =3D 0; i < len; ++i) { + g_assert_cmphex(buf[i], =3D=3D, msg[i]); + } + + /* check controller writes to chardev */ + do { + bytes_read +=3D read(fd, buf + bytes_read, buf_size - bytes_read); + } while (bytes_read < buf_size); + + g_assert_cmphex(buf[0], =3D=3D, REMOTE_I2C_START_RECV); + for (int i =3D 1; i < len - 1; ++i) { + g_assert_cmphex(buf[i], =3D=3D, REMOTE_I2C_RECV); + } + g_assert_cmphex(buf[buf_size - 1], =3D=3D, REMOTE_I2C_FINISH); + + g_free(buf); +} + +static void test_send(QI2CDevice *i2cdev, int fd, uint8_t *msg, uint16_t l= en) +{ + uint16_t buf_size =3D len * 2 + 2; + uint8_t *buf =3D g_new0(uint8_t, buf_size); + uint16_t bytes_read =3D 0; + ssize_t rv; + int j =3D 0; + + /* write device ACKs to socket*/ + rv =3D write(fd, buf, len + 2); + g_assert_cmpint(rv, =3D=3D, len + 2); + + qi2c_send(i2cdev, msg, len); + + /* check controller writes to chardev */ + do { + bytes_read +=3D read(fd, buf + bytes_read, buf_size - bytes_read); + } while (bytes_read < buf_size); + + g_assert_cmphex(buf[0], =3D=3D, REMOTE_I2C_START_SEND); + for (int i =3D 1; i < buf_size - 1; i +=3D 2) { + g_assert_cmphex(buf[i], =3D=3D, REMOTE_I2C_SEND); + g_assert_cmphex(buf[i + 1], =3D=3D, msg[j++]); + } + g_assert_cmphex(buf[buf_size - 1], =3D=3D, REMOTE_I2C_FINISH); + + g_free(buf); +} + +static void test_remote_i2c_recv(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + int *sock =3D (int *)data; + int fd =3D setup_fd(sock); + + uint8_t msg[] =3D {0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4= F}; + + test_recv(i2cdev, fd, msg, 1); + test_recv(i2cdev, fd, msg, 2); + test_recv(i2cdev, fd, msg, 3); + test_recv(i2cdev, fd, msg, 4); + test_recv(i2cdev, fd, msg, 5); + test_recv(i2cdev, fd, msg, 6); + test_recv(i2cdev, fd, msg, 7); + test_recv(i2cdev, fd, msg, 8); + test_recv(i2cdev, fd, msg, 9); +} + +static void test_remote_i2c_send(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QI2CDevice *i2cdev =3D (QI2CDevice *)obj; + int *sock =3D (int *)data; + int fd =3D setup_fd(sock); + + uint8_t msg[] =3D {0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4= F}; + + test_send(i2cdev, fd, msg, 1); + test_send(i2cdev, fd, msg, 2); + test_send(i2cdev, fd, msg, 3); + test_send(i2cdev, fd, msg, 4); + test_send(i2cdev, fd, msg, 5); + test_send(i2cdev, fd, msg, 6); + test_send(i2cdev, fd, msg, 7); + test_send(i2cdev, fd, msg, 8); + test_send(i2cdev, fd, msg, 9); +} + +static in_port_t open_socket(int *sock) +{ + struct sockaddr_in myaddr; + socklen_t addrlen; + + myaddr.sin_family =3D AF_INET; + myaddr.sin_addr.s_addr =3D htonl(INADDR_LOOPBACK); + myaddr.sin_port =3D 0; + + *sock =3D socket(AF_INET, SOCK_STREAM, 0); + g_assert(*sock !=3D -1); + g_assert(bind(*sock, (struct sockaddr *)&myaddr, sizeof(myaddr)) !=3D = -1); + + addrlen =3D sizeof(myaddr); + g_assert(getsockname(*sock, (struct sockaddr *)&myaddr, &addrlen) !=3D= -1); + g_assert(listen(*sock, 1) !=3D -1); + + return ntohs(myaddr.sin_port); +} + +static void remote_i2c_test_cleanup(void *socket) +{ + int *s =3D socket; + + close(*s); + qos_invalidate_command_line(); + g_free(s); +} + +static void *remote_i2c_test_setup(GString *cmd_line, void *arg) +{ + int *sock =3D g_new(int, 1); + + g_string_append_printf(cmd_line, QEMU_CMD_CHR, open_socket(sock)); + g_test_queue_destroy(remote_i2c_test_cleanup, sock); + return sock; +} + +static void register_remote_i2c_test(void) +{ + QOSGraphEdgeOptions edge =3D { + .extra_device_opts =3D "id=3D" TEST_ID ",address=3D0x62,chardev=3D= i2c-chardev"}; + add_qi2c_address(&edge, &(QI2CAddress){TEST_ADDR}); + + qos_node_create_driver("remote-i2c", i2c_device_create); + qos_node_consumes("remote-i2c", "i2c-bus", &edge); + + QOSGraphTestOptions opts =3D { + .before =3D remote_i2c_test_setup, + }; + qemu_add_opts(&qemu_chardev_opts); + qos_add_test("test_remote_i2c_recv", "remote-i2c", test_remote_i2c_rec= v, + &opts); + qos_add_test("test_remote_i2c_send", "remote-i2c", test_remote_i2c_sen= d, + &opts); +} +libqos_init(register_remote_i2c_test); --=20 2.32.0.554.ge1b32706d8-goog