/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* The max1617 I2C is a temp acquisition device. As implemented on some
* processor modules, it contains both a local and a remote temp. The
* local temp measures the ambient (room) temperature, while the remote
* sensor is connected to the processor die. There are ioctl's for retrieving
* temperatures, and setting temperature alarm ranges.
*/
/*
* cb ops (only need ioctl)
*/
/*
* dev ops
*/
void **result);
max1617_open, /* open */
max1617_close, /* close */
nodev, /* strategy */
nodev, /* print */
nodev, /* dump */
nodev, /* read */
nodev, /* write */
max1617_ioctl, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* cb_prop_op */
NULL, /* streamtab */
CB_REV, /* rev */
nodev, /* int (*cb_aread)() */
nodev /* int (*cb_awrite)() */
};
0,
NULL,
NULL,
ddi_quiesce_not_supported, /* devo_quiesce */
};
&mod_driverops, /* type of module - driver */
"max1617 device driver",
};
0
};
static int max1617_debug = 0;
static void *max1617_soft_statep;
int
_init(void)
{
int error;
if (error == 0) {
(void) ddi_soft_state_init(&max1617_soft_statep,
sizeof (struct max1617_unit), 1);
}
return (error);
}
int
_fini(void)
{
int error;
if (error == 0) {
}
return (error);
}
int
{
}
/* ARGSUSED */
static int
{
int instance;
if (infocmd == DDI_INFO_DEVT2INSTANCE) {
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
static int
{
int instance;
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static int
{
NULL) {
return (DDI_FAILURE);
}
ret = DDI_FAILURE;
goto done;
}
ret = DDI_FAILURE;
goto done;
}
ret = DDI_FAILURE;
goto done;
}
ret = DDI_FAILURE;
goto done;
}
ret = DDI_FAILURE;
goto done;
}
ret = DDI_FAILURE;
goto done;
}
done:
unitp->max1617_flags = 0;
return (ret);
}
static int
{
switch (cmd) {
case DDI_ATTACH:
return (max1617_do_attach(dip));
case DDI_RESUME:
return (max1617_do_resume(dip));
default:
return (DDI_FAILURE);
}
}
static int
{
int instance;
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static int
{
NULL) {
return (DDI_FAILURE);
}
/*
* Block new transactions during CPR
*/
}
ret = DDI_FAILURE;
goto done;
}
ret = DDI_FAILURE;
goto done;
}
ret = DDI_FAILURE;
goto done;
}
ret = DDI_FAILURE;
goto done;
}
ret = DDI_FAILURE;
goto done;
}
ret = DDI_FAILURE;
goto done;
}
done:
if (ret == DDI_FAILURE) {
unitp->max1617_flags = 0;
}
return (ret);
}
static int
{
switch (cmd) {
case DDI_DETACH:
return (max1617_do_detach(dip));
case DDI_SUSPEND:
return (max1617_do_suspend(dip));
default:
return (DDI_FAILURE);
}
}
static int
{
struct max1617_unit *unitp;
int instance;
int err = 0;
if (instance < 0) {
return (ENXIO);
}
unitp = (struct max1617_unit *)
return (ENXIO);
}
return (EINVAL);
}
if (unitp->max1617_oflag != 0) {
} else {
}
} else {
} else {
}
}
done:
return (err);
}
static int
{
struct max1617_unit *unitp;
if (instance < 0) {
return (ENXIO);
}
unitp = (struct max1617_unit *)
return (ENXIO);
}
unitp->max1617_oflag = 0;
return (DDI_SUCCESS);
}
int
int mode)
{
int err = 0;
DDI_SUCCESS) {
return (EFAULT);
}
}
return (err);
}
int
int mode)
{
int err = 0;
/*
* This double cast is required so that the sign is preserved
* when expanding the 8 bit value to 16.
*/
mode) != DDI_SUCCESS) {
}
} else {
}
return (err);
}
static int
{
struct max1617_unit *unitp;
int err = 0;
unitp = (struct max1617_unit *)
if (max1617_debug) {
}
/*
* Serialize here, in order to block transacations during CPR.
* This is not a bottle neck since i2c_transfer would serialize
* anyway.
*/
&unitp->max1617_mutex) <= 0) {
return (EINTR);
}
}
switch (cmd) {
/*
* I2C_GET_TEMPERATURE reads a temperature from the device and
* copies a single byte representing the celcius temp
* to user space.
*/
case I2C_GET_TEMPERATURE:
switch (fcn) {
case MAX1617_AMB_TEMP:
break;
case MAX1617_CPU_TEMP:
break;
default:
goto done;
}
/*
* This double cast is needed so that the sign bit
* is preserved when casting from unsigned char to
* signed 16 bit value.
*/
}
} else {
}
break;
case MAX1617_GET_STATUS:
}
} else {
}
break;
case MAX1617_GET_CONFIG:
}
} else {
}
break;
case MAX1617_GET_CONV_RATE:
}
} else {
}
break;
case MAX1617_GET_HIGH_LIMIT:
switch (fcn) {
case MAX1617_AMB_TEMP:
break;
case MAX1617_CPU_TEMP:
break;
default:
break;
}
break;
case MAX1617_GET_LOW_LIMIT:
switch (fcn) {
case MAX1617_AMB_TEMP:
break;
case MAX1617_CPU_TEMP:
break;
default:
}
break;
case MAX1617_SET_CONV_RATE:
2, 0, I2C_SLEEP);
break;
}
}
break;
case MAX1617_SET_CONFIG:
2, 0, I2C_SLEEP);
break;
}
}
break;
case MAX1617_SET_HIGH_LIMIT:
switch (fcn) {
case MAX1617_AMB_TEMP:
break;
case MAX1617_CPU_TEMP:
break;
default:
}
break;
case MAX1617_SET_LOW_LIMIT:
switch (fcn) {
case MAX1617_AMB_TEMP:
break;
case MAX1617_CPU_TEMP:
break;
default:
}
break;
case MAX1617_ONE_SHOT_CMD:
}
break;
default:
}
done:
unitp->max1617_flags = 0;
return (err);
}