Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:11

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @brief RTEMS Port of Linux I2C Device API
0007  *
0008  * @ingroup I2CLinux
0009  */
0010 
0011 /*
0012  * Copyright (c) 2014 embedded brains GmbH & Co. KG
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #ifndef _UAPI_LINUX_I2C_DEV_H
0037 #define _UAPI_LINUX_I2C_DEV_H
0038 
0039 #include <stdint.h>
0040 
0041 /**
0042  * @addtogroup I2CLinux
0043  *
0044  * @{
0045  */
0046 
0047 /**
0048  * @name I2C IO Control Commands
0049  *
0050  * @{
0051  */
0052 
0053 /**
0054  * @brief Sets the count of transfer retries in case a slave
0055  * device does not acknowledge a transaction.
0056  *
0057  * The argument type is unsigned long.
0058  */
0059 #define I2C_RETRIES 0x701
0060 
0061 /**
0062  * @brief Sets the transfer timeout in 10ms units.
0063  *
0064  * The argument type is unsigned long.
0065  */
0066 #define I2C_TIMEOUT 0x702
0067 
0068 /**
0069  * @brief Sets the slave address.
0070  *
0071  * It is an error to set a slave address already used by another slave device.
0072  *
0073  * The argument type is unsigned long.
0074  */
0075 #define I2C_SLAVE 0x703
0076 
0077 /**
0078  * @brief Forces setting the slave address.
0079  *
0080  * The argument type is unsigned long.
0081  */
0082 #define I2C_SLAVE_FORCE 0x706
0083 
0084 /**
0085  * @brief Enables 10-bit addresses if argument is non-zero, otherwise
0086  * disables 10-bit addresses.
0087  *
0088  * The argument type is unsigned long.
0089  */
0090 #define I2C_TENBIT 0x704
0091 
0092 /**
0093  * @brief Gets the I2C controller functionality information.
0094  *
0095  * The argument type is a pointer to an unsigned long.
0096  */
0097 #define I2C_FUNCS 0x705
0098 
0099 /**
0100  * @brief Performs a combined read/write transfer.
0101  *
0102  * Only one stop condition is signalled.
0103  *
0104  * The argument type is a pointer to struct i2c_rdwr_ioctl_data.
0105  */
0106 #define I2C_RDWR 0x707
0107 
0108 /**
0109  * @brief Enables System Management Bus (SMBus) Packet Error Checking (PEC)
0110  * if argument is non-zero, otherwise disables PEC.
0111  *
0112  * The argument type is unsigned long.
0113  */
0114 #define I2C_PEC 0x708
0115 
0116 /**
0117  * @brief Performs an SMBus transfer.
0118  *
0119  * The argument type is a pointer to struct i2c_smbus_ioctl_data.
0120  */
0121 #define I2C_SMBUS 0x720
0122 
0123 /** @} */
0124 
0125 /**
0126  * @brief Argument type for I2C_SMBUS IO control call.
0127  */
0128 struct i2c_smbus_ioctl_data {
0129   uint8_t read_write;
0130   uint8_t command;
0131   uint32_t size;
0132   union i2c_smbus_data *data;
0133 };
0134 
0135 /**
0136  * @brief Argument type for I2C_RDWR IO control call.
0137  */
0138 struct i2c_rdwr_ioctl_data {
0139   struct i2c_msg *msgs;
0140   uint32_t nmsgs;
0141 };
0142 
0143 /**
0144  * @brief Maximum count of messages for one IO control call.
0145  */
0146 #define I2C_RDRW_IOCTL_MAX_MSGS 42
0147 
0148 /** @} */
0149 
0150 #endif /* _UAPI_LINUX_I2C_DEV_H */