/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2011 Bayard G. Bell. All rights reserved.
*/
#include <sys/ddi_impldefs.h>
#include <sys/sysmacros.h>
#include <sys/autoconf.h>
/* Useful debugging Stuff */
#include <sys/nexusdebug.h>
/*
* Function prototypes
*/
static void overtemp_wakeup(void *);
static void environ_overtemp_poll(void);
/*
* Configuration data structures
*/
nulldev, /* open */
nulldev, /* close */
nulldev, /* strategy */
nulldev, /* print */
nodev, /* dump */
nulldev, /* read */
nulldev, /* write */
nulldev, /* ioctl */
nodev, /* devmap */
nodev, /* mmap */
nodev, /* segmap */
nochpoll, /* poll */
ddi_prop_op, /* cb_prop_op */
0, /* streamtab */
CB_REV, /* rev */
nodev, /* cb_aread */
nodev /* cb_awrite */
};
DEVO_REV, /* devo_rev, */
0, /* refcnt */
ddi_no_info, /* getinfo */
nulldev, /* identify */
nulldev, /* probe */
environ_attach, /* attach */
environ_detach, /* detach */
nulldev, /* reset */
&environ_cb_ops, /* cb_ops */
(struct bus_ops *)0, /* bus_ops */
nulldev, /* power */
ddi_quiesce_not_needed, /* quiesce */
};
/*
* Mutex used to protect the soft state list and their data.
*/
/* The CV is used to wakeup the thread when needed. */
/* linked list of all environ soft states */
/* overtemp polling routine timeout delay */
/* Should the environ_overtemp_poll thread be running? */
/* Indicates whether or not the overtemp thread has been started */
static int environ_overtemp_thread_started = 0;
extern struct mod_ops mod_driverops;
&mod_driverops, /* module type, this one is a driver */
"Environment Leaf", /* name of module */
&environ_ops, /* driver ops */
};
(void *)&modldrv,
};
/*
* These are the module initialization routines.
*/
int
_init(void)
{
int error;
sizeof (struct environ_soft_state), 1)) != 0)
return (error);
return (mod_install(&modlinkage));
}
int
_fini(void)
{
int error;
return (error);
return (0);
}
int
{
}
static int
{
int instance;
switch (cmd) {
case DDI_ATTACH:
break;
case DDI_RESUME:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
return (DDI_FAILURE);
/* Set the dip in the soft state */
/*
* The DDI documentation on ddi_getprop() routine says that
* you should always use the real dev_t when calling it,
* but all calls found in uts use either DDI_DEV_T_ANY
* or DDI_DEV_T_NONE. No notes either on how to find the real
* dev_t. So we are doing it in two steps.
*/
goto bad;
}
/*
* Init the temperature device here. We start the overtemp
* polling thread here.
*/
goto bad;
"pm-hardware-state", "no-suspend-resume");
if (environ_overtemp_thread_started == 0) {
/*
* set up the overtemp mutex and condition variable before
* starting the thread.
*/
/* Start the overtemp polling thread now. */
}
return (DDI_SUCCESS);
bad:
return (DDI_FAILURE);
}
/* ARGSUSED */
static int
{
int instance;
/* get the instance of this devi */
/* get the soft state pointer for this device node */
switch (cmd) {
case DDI_SUSPEND:
return (DDI_SUCCESS);
case DDI_DETACH:
break;
else
/* FALLTHROUGH */
default:
return (DDI_FAILURE);
}
/* remove the environmental kstats if they were allocated */
if (softsp->environ_ksp)
if (softsp->environ_oksp)
/*
* remove from soft state pointer from the singly linked list of
* soft state pointers for temperature monitoring.
*/
/*
* find the soft state for this instance in the soft state list
* and remove it from the list
*/
break;
}
}
/* unmap the registers (if they have been mapped) */
/* deallocate the soft state instance */
return (DDI_SUCCESS);
}
static int
{
/*
* If this environment node is on a CPU-less system board, i.e.,
* board type MEM_TYPE, then we do not want to map in, read
* the temperature register, create the polling entry for
* the overtemp polling thread, or create a kstat entry.
*
* The reason for this is that when no CPU modules are present
* and the output of the A/D convertor is the max 8 bit value (0xFF)
*/
return (DDI_SUCCESS);
}
/*
* Map in the temperature register. Once the temperature register
* is mapped, the timeout thread can read the temperature and
* update the temperature in the softsp.
*/
return (DDI_FAILURE);
}
/* Initialize the temperature */
/*
* Do a priming read on the ADC, and throw away the first value
* read. This is a feature of the ADC hardware. After a power cycle
* it does not contains valid data until a read occurs.
*/
/* Wait 30 usec for ADC hardware to stabilize. */
DELAY(30);
#ifdef lint
#endif
/*
* Now add this soft state structure to the front of the linked list
* of soft state structures.
*/
/* Create kstats for this instance of the environ driver */
return (DDI_SUCCESS);
}
/* ARGSUSED */
static void
{
/*
* grab mutex to guarantee that our wakeup call
* arrives after we go to sleep -- so we can't sleep forever.
*/
}
/*
* This function polls all the system board digital temperature registers
* and stores them in the history buffers using the fhc driver support
* routines.
* The temperature detected must then be checked against our current
* policy for what to do in the case of overtemperature situations. We
* must also allow for manufacturing's use of a heat chamber.
*/
static void
environ_overtemp_poll(void)
{
/* The overtemp data strcutures are protected by a mutex. */
while (environ_do_overtemp_thread) {
/*
* for each environment node that has been attached,
* read it and check for overtemp.
*/
continue;
}
}
/* now have this thread sleep for a while */
}
thread_exit();
/* NOTREACHED */
}
void
{
/*
* Create the overtemp kstat required for the environment driver.
* The kstat instances are tagged with the physical board number
* instead of ddi instance number.
*/
} else {
}
/*
* Create the temperature override kstat, for testability.
* The kstat instances are tagged with the physical board number
* instead of ddi instance number.
*/
} else {
}
}