/*
* Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/*
* Copyright (c) 2012 Intel Corporation. All rights reserved.
*/
#ifndef __DRM_I2C_H__
#define __DRM_I2C_H__
#include <sys/ksynch.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/cmn_err.h>
#include "drm.h"
struct i2c_adapter;
struct i2c_msg;
struct i2c_algorithm {
int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
u32 (*functionality) (struct i2c_adapter *);
};
extern struct i2c_algorithm i2c_bit_algo;
struct i2c_adapter {
struct i2c_algorithm *algo;
kmutex_t bus_lock;
clock_t timeout;
int retries;
char name[64];
void *data;
void (*setsda) (void *data, int state);
void (*setscl) (void *data, int state);
int (*getsda) (void *data);
int (*getscl) (void *data);
void *algo_data;
clock_t udelay;
};
#define I2C_M_RD 0x01
#define I2C_M_NOSTART 0x02
struct i2c_msg {
u16 addr;
u16 flags;
u16 len;
u8 *buf;
};
extern int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num);
extern int i2c_bit_add_bus(struct i2c_adapter *adap);
#endif /* __DRM_I2C_H__ */