1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22/* 23 * Copyright (c) 2000 by Sun Microsystems, Inc. 24 * All rights reserved. 25 */ 26 27#ifndef _PCF8574_IMPL_H 28#define _PCF8574_IMPL_H 29 30#pragma ident "%Z%%M% %I% %E% SMI" 31 32#ifdef __cplusplus 33extern "C" { 34#endif 35 36#include <sys/i2c/clients/i2c_client.h> 37 38/* 39 * PCF8574_BIT_READ_MASK takes in a byte from the device and the bit that 40 * the user wants to read. I shifts the byte over so that the bit that we 41 * want is in the 1's bit and masks out the rest of the byte. 42 */ 43#define PCF8574_BIT_READ_MASK(byte, bit) ((byte >> bit) & 0x01) 44 45/* 46 * PCF8574_BIT_WRITE_MASK takes in a byte from the device, the bit that the 47 * user wants to read write, and the value that the user wants put into that 48 * bit. It zero's out the bit that we are writing to in the byte and then or's 49 * the value(which was shifted to the bit location we wanted) to fill in only 50 * that bit in the byte 51 */ 52#define PCF8574_BIT_WRITE_MASK(byte, bit, value)\ 53 ((value << bit) | (byte & (~(0x01 << bit)))) 54 55struct pcf8574_unit { 56 kmutex_t pcf8574_mutex; 57 uint8_t pcf8574_flags; 58 int pcf8574_oflag; 59 i2c_client_hdl_t pcf8574_hdl; 60 char pcf8574_name[24]; 61}; 62 63#ifdef DEBUG 64 65static int pcf8574debug = 0; 66#define D1CMN_ERR(ARGS) if (pcf8574debug & 0x1) cmn_err ARGS; 67#define D2CMN_ERR(ARGS) if (pcf8574debug & 0x2) cmn_err ARGS; 68 69#else 70 71#define D1CMN_ERR(ARGS) 72#define D2CMN_ERR(ARGS) 73 74#endif 75 76 77#ifdef __cplusplus 78} 79#endif 80 81#endif /* _PCF8574_IMPL_H */ 82