1*920Sjbeloro /* 2*920Sjbeloro * CDDL HEADER START 3*920Sjbeloro * 4*920Sjbeloro * The contents of this file are subject to the terms of the 5*920Sjbeloro * Common Development and Distribution License, Version 1.0 only 6*920Sjbeloro * (the "License"). You may not use this file except in compliance 7*920Sjbeloro * with the License. 8*920Sjbeloro * 9*920Sjbeloro * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*920Sjbeloro * or http://www.opensolaris.org/os/licensing. 11*920Sjbeloro * See the License for the specific language governing permissions 12*920Sjbeloro * and limitations under the License. 13*920Sjbeloro * 14*920Sjbeloro * When distributing Covered Code, include this CDDL HEADER in each 15*920Sjbeloro * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*920Sjbeloro * If applicable, add the following below this CDDL HEADER, with the 17*920Sjbeloro * fields enclosed by brackets "[]" replaced with your own identifying 18*920Sjbeloro * information: Portions Copyright [yyyy] [name of copyright owner] 19*920Sjbeloro * 20*920Sjbeloro * CDDL HEADER END 21*920Sjbeloro */ 22*920Sjbeloro /* 23*920Sjbeloro * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*920Sjbeloro * Use is subject to license terms. 25*920Sjbeloro */ 26*920Sjbeloro 27*920Sjbeloro #ifndef _ADM1026_IMPL_H 28*920Sjbeloro #define _ADM1026_IMPL_H 29*920Sjbeloro 30*920Sjbeloro #pragma ident "%Z%%M% %I% %E% SMI" 31*920Sjbeloro 32*920Sjbeloro #ifdef __cplusplus 33*920Sjbeloro extern "C" { 34*920Sjbeloro #endif 35*920Sjbeloro 36*920Sjbeloro 37*920Sjbeloro #include <sys/i2c/clients/i2c_client.h> 38*920Sjbeloro 39*920Sjbeloro typedef struct adm1026_unit { 40*920Sjbeloro kmutex_t adm1026_mutex; 41*920Sjbeloro int adm1026_oflag; 42*920Sjbeloro i2c_client_hdl_t adm1026_hdl; 43*920Sjbeloro } adm1026_unit_t; 44*920Sjbeloro 45*920Sjbeloro /* 46*920Sjbeloro * ADM1026 has 4 GPIO Config registers used to set Polarity and Direction. 47*920Sjbeloro * To config a particular GPIO, the low 16 bits of the reg_mask member 48*920Sjbeloro * of the i2c_gpio_t struct is used as a logical mask to indicate which 49*920Sjbeloro * GPIO pin(s) to access and the reg_val member is used to set/clear those 50*920Sjbeloro * GPIO pins' P or D bit(s). 51*920Sjbeloro * 52*920Sjbeloro * GPIO# 3 2 1 0 53*920Sjbeloro * +--+--+--+--+ 54*920Sjbeloro * |PD|PD|PD|PD| <-- ADM1026_GPIO_CFG1 55*920Sjbeloro * +--+--+--+--+ Logical Mask: 0x000f 56*920Sjbeloro * 57*920Sjbeloro * GPIO# 7 6 5 4 58*920Sjbeloro * +--+--+--+--+ 59*920Sjbeloro * |PD|PD|PD|PD| <-- ADM1026_GPIO_CFG2 60*920Sjbeloro * +--+--+--+--+ Logical Mask: 0x00f0 61*920Sjbeloro * 62*920Sjbeloro * GPIO# 11 10 9 8 63*920Sjbeloro * +--+--+--+--+ 64*920Sjbeloro * |PD|PD|PD|PD| <-- ADM1026_GPIO_CFG3 65*920Sjbeloro * +--+--+--+--+ Logical Mask: 0x0f00 66*920Sjbeloro * 67*920Sjbeloro * GPIO# 15 14 13 12 68*920Sjbeloro * +--+--+--+--+ 69*920Sjbeloro * |PD|PD|PD|PD| <-- ADM1026_GPIO_CFG4 70*920Sjbeloro * +--+--+--+--+ Logical Mask: 0xf000 71*920Sjbeloro */ 72*920Sjbeloro 73*920Sjbeloro #define ADM1026_GPIO_CFG1 0x08 /* Config GPIO 03-00 in/out + hi/lo */ 74*920Sjbeloro #define ADM1026_GPIO_CFG2 0x09 /* Config GPIO 07-04 in/out + hi/lo */ 75*920Sjbeloro #define ADM1026_GPIO_CFG3 0x0a /* Config GPIO 11-08 in/out + hi/lo */ 76*920Sjbeloro #define ADM1026_GPIO_CFG4 0x0b /* Config GPIO 15-12 in/out + hi/lo */ 77*920Sjbeloro 78*920Sjbeloro /* 79*920Sjbeloro * ADM1026 has 2 GPIO Output registers to set GPIO pins. 80*920Sjbeloro * To set a particular GPIO pin, the low 16 bits of the reg_mask member 81*920Sjbeloro * of the i2c_gpio_t struct is used as a 1:1 mask of the 16 GPIO pin(s) 82*920Sjbeloro * to access and the reg_val member is used to set/clear the GPIO pin(s). 83*920Sjbeloro * 84*920Sjbeloro * GPIO# 76 54 32 10 85*920Sjbeloro * 86*920Sjbeloro * +--+--+--+--+ 87*920Sjbeloro * |xx|xx|xx|xx| <-- ADM1026_STS_REG5 88*920Sjbeloro * +--+--+--+--+ Logical Mask: 0x00ff 89*920Sjbeloro * 90*920Sjbeloro * GPIO# 11 11 11 98 91*920Sjbeloro * 54 32 10 92*920Sjbeloro * +--+--+--+--+ 93*920Sjbeloro * |xx|xx|xx|xx| <-- ADM1026_STS_REG6 94*920Sjbeloro * +--+--+--+--+ Logical Mask: 0xff00 95*920Sjbeloro */ 96*920Sjbeloro 97*920Sjbeloro #define ADM1026_STS_REG5 0x24 /* GPIO 07-00 */ 98*920Sjbeloro #define ADM1026_STS_REG6 0x25 /* GPIO 15-08 */ 99*920Sjbeloro 100*920Sjbeloro #define OUTPUT_SHIFT 8 101*920Sjbeloro #define BITSPERCFG 2 /* Polarity + Dir bits per GPIO cfg */ 102*920Sjbeloro 103*920Sjbeloro #define DIR_BIT 1 /* Dir bit = lo bit of GPIO cfg */ 104*920Sjbeloro #define POLARITY_BIT 2 /* Polarity bit = hi bit GPIO cfg */ 105*920Sjbeloro 106*920Sjbeloro #define BYTES_PER_OUTPUT 2 107*920Sjbeloro 108*920Sjbeloro #define BYTES_PER_CONFIG 4 109*920Sjbeloro 110*920Sjbeloro #define NUMBER_OF_GPIOS 16 111*920Sjbeloro 112*920Sjbeloro #define GPIOS_PER_CFG_BYTE 4 113*920Sjbeloro 114*920Sjbeloro #define GPIO_CFG_MASK 0xf 115*920Sjbeloro 116*920Sjbeloro 117*920Sjbeloro #ifdef DEBUG 118*920Sjbeloro 119*920Sjbeloro static int adm1026_dbg = 0; 120*920Sjbeloro #define D1CMN_ERR(ARGS) { if (adm1026_dbg & 0x1) cmn_err ARGS; } 121*920Sjbeloro #define D2CMN_ERR(ARGS) { if (adm1026_dbg & 0x2) cmn_err ARGS; } 122*920Sjbeloro 123*920Sjbeloro #else 124*920Sjbeloro 125*920Sjbeloro #define D1CMN_ERR(ARGS) 126*920Sjbeloro #define D2CMN_ERR(ARGS) 127*920Sjbeloro 128*920Sjbeloro #endif 129*920Sjbeloro 130*920Sjbeloro #ifdef __cplusplus 131*920Sjbeloro } 132*920Sjbeloro #endif 133*920Sjbeloro 134*920Sjbeloro #endif /* _ADM1026_IMPL_H */ 135