xref: /linux/include/uapi/linux/virtio_i2c.h (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
13cfc8838SJie Deng /* SPDX-License-Identifier: GPL-2.0-or-later WITH Linux-syscall-note */
23cfc8838SJie Deng /*
33cfc8838SJie Deng  * Definitions for virtio I2C Adpter
43cfc8838SJie Deng  *
53cfc8838SJie Deng  * Copyright (c) 2021 Intel Corporation. All rights reserved.
63cfc8838SJie Deng  */
73cfc8838SJie Deng 
83cfc8838SJie Deng #ifndef _UAPI_LINUX_VIRTIO_I2C_H
93cfc8838SJie Deng #define _UAPI_LINUX_VIRTIO_I2C_H
103cfc8838SJie Deng 
113cfc8838SJie Deng #include <linux/const.h>
123cfc8838SJie Deng #include <linux/types.h>
133cfc8838SJie Deng 
14*dcce1625SViresh Kumar /* Virtio I2C Feature bits */
15*dcce1625SViresh Kumar #define VIRTIO_I2C_F_ZERO_LENGTH_REQUEST	0
16*dcce1625SViresh Kumar 
173cfc8838SJie Deng /* The bit 0 of the @virtio_i2c_out_hdr.@flags, used to group the requests */
183cfc8838SJie Deng #define VIRTIO_I2C_FLAGS_FAIL_NEXT	_BITUL(0)
193cfc8838SJie Deng 
20*dcce1625SViresh Kumar /* The bit 1 of the @virtio_i2c_out_hdr.@flags, used to mark a buffer as read */
21*dcce1625SViresh Kumar #define VIRTIO_I2C_FLAGS_M_RD		_BITUL(1)
22*dcce1625SViresh Kumar 
233cfc8838SJie Deng /**
243cfc8838SJie Deng  * struct virtio_i2c_out_hdr - the virtio I2C message OUT header
253cfc8838SJie Deng  * @addr: the controlled device address
263cfc8838SJie Deng  * @padding: used to pad to full dword
273cfc8838SJie Deng  * @flags: used for feature extensibility
283cfc8838SJie Deng  */
293cfc8838SJie Deng struct virtio_i2c_out_hdr {
303cfc8838SJie Deng 	__le16 addr;
313cfc8838SJie Deng 	__le16 padding;
323cfc8838SJie Deng 	__le32 flags;
333cfc8838SJie Deng };
343cfc8838SJie Deng 
353cfc8838SJie Deng /**
363cfc8838SJie Deng  * struct virtio_i2c_in_hdr - the virtio I2C message IN header
373cfc8838SJie Deng  * @status: the processing result from the backend
383cfc8838SJie Deng  */
393cfc8838SJie Deng struct virtio_i2c_in_hdr {
403cfc8838SJie Deng 	__u8 status;
413cfc8838SJie Deng };
423cfc8838SJie Deng 
433cfc8838SJie Deng /* The final status written by the device */
443cfc8838SJie Deng #define VIRTIO_I2C_MSG_OK	0
453cfc8838SJie Deng #define VIRTIO_I2C_MSG_ERR	1
463cfc8838SJie Deng 
473cfc8838SJie Deng #endif /* _UAPI_LINUX_VIRTIO_I2C_H */
48