pic16f747.c revision d619c1b841dc484317f6c06b2392a6b2ae991810
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Driver to map the PIC for the chicago platform.
*/
#include <sys/pic16f747.h>
/* dev_ops and cb_ops entry point function declarations */
struct cb_ops pic_cb_ops = {
nodev, /* dump */
nodev, /* devmap */
ddi_segmap, /* segmap */
NULL, /* for STREAMS drivers */
};
static struct dev_ops pic_dev_ops = {
DEVO_REV, /* driver build version */
0, /* device reference count */
nulldev, /* probe */
nulldev, /* reset */
nulldev /* power */
};
/*
* Fans' and sensors' node names and register offsets
*/
{NULL, 0, 0}, /* Reserved */
};
/*
* Soft state
*/
struct pic_softc {
};
/* module configuration stuff */
static void *statep;
extern struct mod_ops mod_driverops;
"pic_client driver (v.%I%) ",
};
static struct modlinkage modlinkage = {
&modldrv,
0
};
int
_init(void)
{
int e;
return (e);
}
if ((e = mod_install(&modlinkage)) != 0)
return (e);
}
int
_fini(void)
{
int e;
if ((e = mod_remove(&modlinkage)) != 0)
return (e);
return (DDI_SUCCESS);
}
int
{
}
/*ARGSUSED*/
static int
{
int inst;
int retval = DDI_SUCCESS;
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
} else
break;
case DDI_INFO_DEVT2INSTANCE:
break;
default:
}
return (retval);
}
static int
{
int inst;
int i;
char *minor_name;
int minor;
char name[80];
int res;
switch (cmd) {
case DDI_ATTACH:
if (inst >= MAX_PIC_INSTANCES) {
return (DDI_FAILURE);
}
"ddi_create_minor_node() failed for inst %d\n",
inst);
return (DDI_FAILURE);
}
/* Allocate a soft state structure for this instance */
"for inst %d\n", inst);
goto attach_failed;
}
/* Setup soft state */
/* Setup device attributes */
/*
* The RF_COMMAND/RF_STATUS and RF_IND_DATA/RF_IND_ADDR
* register pairs are mapped as one register set starting
* from 0x0 and length 0x42.
*/
if (res != DDI_SUCCESS) {
goto attach_failed;
}
/* Set up fans' and sensors' device minor nodes */
for (i = 1; i < N_PIC_NODES; i++) {
"%s:%d ddi_create_minor_node failed",
return (DDI_FAILURE);
}
}
/* Create main environmental node */
return (DDI_SUCCESS);
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
/* Free soft state, if allocated. remove minor node if added earlier */
if (softc)
return (DDI_FAILURE);
}
static int
{
int inst;
switch (cmd) {
case DDI_DETACH:
return (ENXIO);
/* Free the soft state and remove minor node added earlier */
return (DDI_SUCCESS);
case DDI_SUSPEND:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/*ARGSUSED*/
static int
{
}
/*ARGSUSED*/
static int
{
}
/*ARGSUSED*/
static int
{
int inst;
int node;
return (ENXIO);
mode) != DDI_SUCCESS) {
return (EFAULT);
}
return (ENXIO);
}
switch (cmd) {
case PIC_GET_TEMPERATURE:
drv_usecwait(10);
/* select the temp sensor */
/* retrieve temperature data */
if (tempr == 0xff)
return (EIO);
/*
* The temp is passed in as a uint8 value, we need to convert
* it to a signed 16 bit value to be able to handle the range
* of -64 to 190 degrees.
*/
tempr -= 64;
return (0);
case PIC_GET_FAN_SPEED:
drv_usecwait(10);
/* select fan */
/* retrieve fan data */
if (in_command == 0xff)
return (EIO);
return (0);
case PIC_SET_FAN_SPEED:
/* select fan */
/* send the fan data */
return (0);
case PIC_GET_STATUS:
/* we don't read the status reg anymore */
in_command = 0;
return (0);
case PIC_GET_FAN_STATUS:
drv_usecwait(10);
/* read ffault register */
/* retrieve fan failure status */
if (in_command == 0xff)
return (EIO);
return (0);
case PIC_SET_ESTAR_MODE:
return (0);
default:
return (EINVAL);
}
}