iic.h revision 160372
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: head/sys/dev/iicbus/iic.h 160372 2006-07-14 23:15:06Z imp $ 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; 39160372Simp#define IIC_M_RD 0x0001 /* read vs write */ 40160372Simp uint16_t len; /* msg legnth */ 41160372Simp uint8_t * buf; 42160372Simp}; 43160372Simp 4442442Snsouchstruct iiccmd { 4542442Snsouch u_char slave; 4642442Snsouch int count; 4742442Snsouch int last; 4842442Snsouch char *buf; 4942442Snsouch}; 5038780Snsouch 51160372Simpstruct iic_rdwr_data { 52160372Simp struct iic_msg *msgs; 53160372Simp uint32_t nmsgs; 54160372Simp}; 55160372Simp 5642442Snsouch#define I2CSTART _IOW('i', 1, struct iiccmd) /* start condition */ 5742442Snsouch#define I2CSTOP _IO('i', 2) /* stop condition */ 5842442Snsouch#define I2CRSTCARD _IOW('i', 3, struct iiccmd) /* reset the card */ 5942442Snsouch#define I2CWRITE _IOW('i', 4, struct iiccmd) /* send data */ 6042442Snsouch#define I2CREAD _IOW('i', 5, struct iiccmd) /* receive data */ 61160372Simp#define I2CRDWR _IOW('i', 6, struct iic_rdwr_data) /* General read/write interface */ 6242442Snsouch 6338780Snsouch#endif 64