138780Snsouch/*-
238780Snsouch * Copyright (c) 1998 Nicolas Souchu
338780Snsouch * All rights reserved.
438780Snsouch *
538780Snsouch * Redistribution and use in source and binary forms, with or without
638780Snsouch * modification, are permitted provided that the following conditions
738780Snsouch * are met:
838780Snsouch * 1. Redistributions of source code must retain the above copyright
938780Snsouch *    notice, this list of conditions and the following disclaimer.
1038780Snsouch * 2. Redistributions in binary form must reproduce the above copyright
1138780Snsouch *    notice, this list of conditions and the following disclaimer in the
1238780Snsouch *    documentation and/or other materials provided with the distribution.
1338780Snsouch *
1438780Snsouch * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1538780Snsouch * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1638780Snsouch * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1738780Snsouch * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1838780Snsouch * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1938780Snsouch * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2038780Snsouch * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2138780Snsouch * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2238780Snsouch * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2338780Snsouch * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2438780Snsouch * SUCH DAMAGE.
2538780Snsouch *
2650477Speter * $FreeBSD$
2738780Snsouch *
2838780Snsouch */
2938780Snsouch#ifndef __IIC_H
3038780Snsouch#define __IIC_H
3138780Snsouch
3238780Snsouch#include <sys/ioccom.h>
3338780Snsouch
34160372Simp/* Designed to be compatible with linux's struct i2c_msg */
35160372Simpstruct iic_msg
36160372Simp{
37160372Simp	uint16_t	slave;
38160372Simp	uint16_t	flags;
39164714Simp#define	IIC_M_WR	0	/* Fake flag for write */
40164714Simp#define	IIC_M_RD	0x0001	/* read vs write */
41208839Snwhitehorn#define	IIC_M_NOSTOP	0x0002	/* do not send a I2C stop after message */
42208839Snwhitehorn#define	IIC_M_NOSTART	0x0004	/* do not send a I2C start before message */
43210998Sjoel	uint16_t	len;	/* msg length */
44160372Simp	uint8_t *	buf;
45160372Simp};
46160372Simp
4742442Snsouchstruct iiccmd {
4842442Snsouch	u_char slave;
4942442Snsouch	int count;
5042442Snsouch	int last;
5142442Snsouch	char *buf;
5242442Snsouch};
5338780Snsouch
54160372Simpstruct iic_rdwr_data {
55160372Simp	struct iic_msg *msgs;
56160372Simp	uint32_t nmsgs;
57160372Simp};
58160372Simp
5942442Snsouch#define I2CSTART	_IOW('i', 1, struct iiccmd)	/* start condition */
6042442Snsouch#define I2CSTOP		_IO('i', 2)			/* stop condition */
6142442Snsouch#define I2CRSTCARD	_IOW('i', 3, struct iiccmd)	/* reset the card */
6242442Snsouch#define I2CWRITE	_IOW('i', 4, struct iiccmd)	/* send data */
6342442Snsouch#define I2CREAD		_IOW('i', 5, struct iiccmd)	/* receive data */
64160372Simp#define I2CRDWR		_IOW('i', 6, struct iic_rdwr_data)	/* General read/write interface */
65187709Sraj#define I2CRPTSTART	_IOW('i', 7, struct iiccmd)	/* repeated start */
6642442Snsouch
6738780Snsouch#endif
68