maa: Refactor maa build system and partly implement i2c
* API headers moved to api/ * smbus file added from libi2c and kernel i2c header cleaned up * fix compilation of swig and use i2c.h header Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -7,12 +7,6 @@
|
||||
*** structures, and macros generated from the original header, and thus,
|
||||
*** contains no copyrightable information.
|
||||
***
|
||||
*** To edit the content of this header, modify the corresponding
|
||||
*** source file (e.g. under external/kernel-headers/original/) then
|
||||
*** run bionic/libc/kernel/tools/update_all.py
|
||||
***
|
||||
*** Any manual change here will be lost the next time this script will
|
||||
*** be run. You've been warned!
|
||||
***
|
||||
****************************************************************************
|
||||
****************************************************************************/
|
||||
@@ -20,30 +14,83 @@
|
||||
#define _UAPI_LINUX_I2C_DEV_H
|
||||
#include <linux/types.h>
|
||||
#include <linux/compiler.h>
|
||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||
|
||||
#define I2C_RETRIES 0x0701
|
||||
#define I2C_TIMEOUT 0x0702
|
||||
#define I2C_SLAVE 0x0703
|
||||
#define I2C_SLAVE_FORCE 0x0706
|
||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||
|
||||
#define I2C_TENBIT 0x0704
|
||||
#define I2C_FUNCS 0x0705
|
||||
#define I2C_RDWR 0x0707
|
||||
#define I2C_PEC 0x0708
|
||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||
|
||||
#define I2C_SMBUS 0x0720
|
||||
|
||||
struct i2c_smbus_ioctl_data {
|
||||
__u8 read_write;
|
||||
char read_write;
|
||||
__u8 command;
|
||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||
__u32 size;
|
||||
int size;
|
||||
union i2c_smbus_data __user *data;
|
||||
};
|
||||
struct i2c_rdwr_ioctl_data {
|
||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||
struct i2c_msg __user *msgs;
|
||||
__u32 nmsgs;
|
||||
int nmsgs;
|
||||
};
|
||||
|
||||
#define I2C_SMBUS_BLOCK_MAX 32
|
||||
#define I2C_SMBUS_I2C_BLOCK_MAX 32
|
||||
union i2c_smbus_data {
|
||||
__u8 byte;
|
||||
__u16 word;
|
||||
__u8 block[I2C_SMBUS_BLOCK_MAX + 2];
|
||||
};
|
||||
|
||||
#define I2C_RDRW_IOCTL_MAX_MSGS 42
|
||||
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
|
||||
|
||||
struct i2c_msg {
|
||||
__u16 addr;
|
||||
unsigned short flags;
|
||||
#define I2C_M_TEN 0x10
|
||||
#define I2C_M_RD 0x01
|
||||
#define I2C_M_NOSTART 0x4000
|
||||
#define I2C_M_REV_DIR_ADDR 0x2000
|
||||
#define I2C_M_IGNORE_NAK 0x1000
|
||||
#define I2C_M_NO_RD_ACK 0x0800
|
||||
short len;
|
||||
char *buf;
|
||||
};
|
||||
|
||||
#define I2C_NOCMD 0
|
||||
#define I2C_SMBUS_READ 1
|
||||
#define I2C_SMBUS_WRITE 0
|
||||
|
||||
#define I2C_SMBUS_QUICK 0
|
||||
#define I2C_SMBUS_BYTE 1
|
||||
#define I2C_SMBUS_BYTE_DATA 2
|
||||
#define I2C_SMBUS_WORD_DATA 3
|
||||
#define I2C_SMBUS_PROC_CALL 4
|
||||
#define I2C_SMBUS_BLOCK_DATA 5
|
||||
#define I2C_SMBUS_I2C_BLOCK_BROKEN 6
|
||||
#define I2C_SMBUS_BLOCK_PROC_CALL 7
|
||||
#define I2C_SMBUS_I2C_BLOCK_DATA 8
|
||||
|
||||
#define I2C_FUNC_I2C 0x00000001
|
||||
#define I2C_FUNC_10BIT_ADDR 0x00000002
|
||||
#define I2C_FUNC_PROTOCOL_MANGLING 0x00000004
|
||||
#define I2C_FUNC_SMBUS_PEC 0x00000008
|
||||
#define I2C_FUNC_SMBUS_BLOCK_PROC_CALL 0x00008000
|
||||
#define I2C_FUNC_SMBUS_QUICK 0x00010000
|
||||
#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000
|
||||
#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
|
||||
#define I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
|
||||
#define I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
|
||||
#define I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
|
||||
#define I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
|
||||
#define I2C_FUNC_SMBUS_PROC_CALL 0x00800000
|
||||
#define I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
|
||||
#define I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
|
||||
#define I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000
|
||||
#define I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000
|
||||
|
||||
#endif
|
||||
|
||||
93
include/smbus.h
Normal file
93
include/smbus.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Author: Robin Knight (robin.knight@roadnarrows.com)
|
||||
*
|
||||
* Copyright © 2009 RoadNarrows LLC.
|
||||
*
|
||||
* Permission is hereby granted, without written agreement and without
|
||||
* license or royalty fees, to use, copy, modify, and distribute this
|
||||
* software and its documentation for any purpose, provided that
|
||||
* (1) The above copyright notice and the following two paragraphs
|
||||
* appear in all copies of the source code and (2) redistributions
|
||||
* including binaries reproduces these notices in the supporting
|
||||
* documentation. Substantial modifications to this software may be
|
||||
* copyrighted by their authors and need not follow the licensing terms
|
||||
* described here, provided that the new terms are clearly indicated in
|
||||
* all files where they apply.
|
||||
*
|
||||
* IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY MEMBERS/EMPLOYEES
|
||||
* OF ROADNARROW LLC OR DISTRIBUTORS OF THIS SOFTWARE BE LIABLE TO ANY
|
||||
* PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
|
||||
* DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION,
|
||||
* EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* THE AUTHOR AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
|
||||
* "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
|
||||
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "linux/i2c-dev.h"
|
||||
|
||||
typedef union i2c_smbus_data_union
|
||||
{
|
||||
uint8_t byte; ///< data byte
|
||||
unsigned short word; ///< data short word
|
||||
uint8_t block[I2C_SMBUS_BLOCK_MAX + 2];
|
||||
///< block[0] is used for length and one more for PEC
|
||||
} i2c_smbus_data_t;
|
||||
|
||||
typedef struct i2c_smbus_ioctl_data_struct
|
||||
{
|
||||
uint8_t read_write; ///< operation direction
|
||||
uint8_t command; ///< ioctl command
|
||||
int size; ///< data size
|
||||
i2c_smbus_data_t *data; ///< data
|
||||
} i2c_smbus_ioctl_data_t;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Prototypes
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
extern int i2c_smbus_access(int fd, uint8_t read_write, uint8_t command,
|
||||
int size, i2c_smbus_data_t *data);
|
||||
|
||||
extern int i2c_smbus_write_quick(int fd, uint8_t value);
|
||||
|
||||
extern int i2c_smbus_read_byte(int fd);
|
||||
|
||||
extern int i2c_smbus_write_byte(int fd, uint8_t value);
|
||||
|
||||
extern int i2c_smbus_read_byte_data(int fd, uint8_t command);
|
||||
|
||||
extern int i2c_smbus_write_byte_data(int fd, uint8_t command, uint8_t value);
|
||||
|
||||
extern int i2c_smbus_read_word_data(int fd, uint8_t command);
|
||||
|
||||
extern int i2c_smbus_write_word_data(int fd, uint8_t command, unsigned short value);
|
||||
|
||||
extern int i2c_smbus_process_call(int fd, uint8_t command, unsigned short value);
|
||||
|
||||
extern int i2c_smbus_read_block_data(int fd, uint8_t command, uint8_t *values);
|
||||
|
||||
extern int i2c_smbus_write_block_data(int fd, uint8_t command, uint8_t length,
|
||||
const uint8_t *values);
|
||||
extern int i2c_smbus_read_i2c_block_data(int fd, uint8_t command,
|
||||
uint8_t *values);
|
||||
|
||||
extern int i2c_smbus_write_i2c_block_data(int fd, uint8_t command, uint8_t length,
|
||||
const uint8_t *values);
|
||||
|
||||
extern int i2c_smbus_block_process_call(int fd, uint8_t command, uint8_t length,
|
||||
uint8_t *values);
|
||||
8
include/smbus.hpp
Normal file
8
include/smbus.hpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
// This header is required to remove the issues with g++ name mangling
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "smbus.h"
|
||||
}
|
||||
Reference in New Issue
Block a user