/*
*
* 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,
* 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.
*/
#include "drmP.h"
do { \
if (ret) { \
/* Other master keeps the clock low. */ \
/* Free the bus. */ \
i2c_setsda(adap); \
i2c_udelay(adap); \
return ret; \
} \
} while (*"\0");
static inline void
{
}
static inline int
{
}
static inline void
{
}
static inline void
{
}
static inline int
{
}
static inline void
{
}
static int
{
/* Clock Synchronization */
start = ddi_get_lbolt();
while (!i2c_getscl(adap)) {
/* FIXME: Does ddi_get_lbolt() return negative
* value? If so, leave me.
*/
return -ETIMEDOUT;
}
return 0;
}
static int
{
int ret = 0;
/* Step 1: free the bus. */
if (ret) {
/* Other master keeps the clock low.
* The bus is busy.
*/
return ret;
}
if (!i2c_getsda(adap)) {
/* The bus is busy. */
return -EBUSY;
}
/* Step 3: free the clock. */
return 0;
}
static int
{
int ret;
if (i2c_getscl(adap)) {
/* Stop() must be called after start() or any
* transfer routines, which all free the clock
* before returning.
*/
return -ENOTSUP;
}
/* Step 1: Free the data */
/* Step 2: Hold the clock */
/* Step 3: (P) condition */
if (!i2c_getsda(adap)) {
/* Other master keeps the data low.
* The bus is busy.
*/
return -EBUSY;
}
return 0;
}
static int
{
int needARB = 0;
int ret = 0, i;
if (i2c_getscl(adap)) {
/* Write() must be called after start() or any
* transfer routines, which all free the clock
* before returning.
*/
return -ENOTSUP;
}
for (i = 7; i >= 0; i--) {
/* Step 1: set data. */
if (c & (1 << i)) {
needARB = 1;
} else {
needARB = 0;
}
/* Step 2: hold the clock. */
/* Do arbitration: lose the bus. */
return -EBUSY;
}
/* Double delay. */
/* Do arbitration: someone performs (S) condition. */
return -EBUSY;
}
/* Step 3: free the clock. */
}
return 0;
}
static int
{
int ret, r, i;
if (i2c_getscl(adap)) {
/* Read() must be called after start() or any
* transfer routines, which all free the clock
* before returning.
*/
return -ENOTSUP;
}
*cp = 0;
for (i = 7; i >= 0; i--) {
/* Step 1: hold the clock. */
r = i2c_getsda(adap);
/* Step 2: read the data. */
if (r != i2c_getsda(adap)) {
return -EBUSY;
}
if (r)
*cp |= (1 << i);
/* Step 3: free the clock */
}
return 0;
}
static int
{
int ret;
if (i2c_getscl(adap)) {
/* Ack() must be called after start() or any
* transfer routines, which all free the clock
* before returning.
*/
return -ENOTSUP;
}
/* Step 1: free the data. */
/* Step 2: hold the clock. */
/* Step 3: free the clock */
return 0;
}
static int
{
int ret;
if (i2c_getscl(adap)) {
/* Nak() must be called after start() or any
* transfer routines, which all free the clock
* before returning.
*/
return -ENOTSUP;
}
/* Step 1: hold the data. */
/* Step 2: hold the clock. */
if (!i2c_getsda(adap)) {
/* Other master keeps the data low. */
return -EBUSY;
}
if (!i2c_getsda(adap)) {
return -EBUSY;
}
/* Step 3: free the clock */
return 0;
}
static int
{
int ret;
if (i2c_getscl(adap)) {
/* Wack() must be called after start() or any
* transfer routines, which all free the clock
* before returning.
*/
return -ENOTSUP;
}
/* Step 1: hold the data. */
/* Step 2: hold the clock. */
/* Step 3: read the data. */
/* Step 4: free the clock */
return ret;
}
static int
{
int i, ret;
if (ret)
return ret;
if (ret == 1)
continue;
else if (ret == 0)
return -ENXIO;
else
return ret;
}
return 0;
}
static int
{
unsigned char c;
int i, ret;
if (ret)
return ret;
else
if (ret)
return ret;
}
return 0;
}
static int
{
unsigned char addr;
int ret;
addr |= 1;
if (ret)
return ret;
if (ret == 1)
return 0;
else if (ret == 0)
return -ENXIO;
return ret;
}
static int
{
int i, ret = 0;
for (i = 0; i < num; i++) {
if (ret)
return ret;
if (ret)
return ret;
}
else
if (ret)
return ret;
}
if (ret)
return ret;
return num;
}
.functionality = NULL,
};
int
{
return -EINVAL;
return 0;
}
int
{
int i, ret = 0;
start = ddi_get_lbolt();
switch (ret) {
case 0:
case ETIMEDOUT:
goto do_exit;
default:
break;
}
/* FIXME: Does ddi_get_lbolt() return negative
* value? If so, leave me.
*/
break;
}
return ret;
}