34#include <sys/module.h>
35#include <sys/callout.h>
39#include <sys/kernel.h>
40#include <sys/reboot.h>
42#include <sys/sysctl.h>
43#include <sys/limits.h>
45#include <machine/bus.h>
46#include <machine/md_var.h>
51#include <dev/ofw/openfirm.h>
52#include <dev/ofw/ofw_bus.h>
53#include <powerpc/powermac/powermac_thermal.h>
56#define DS1775_TEMP 0x0
114 device_printf(
dev,
"iicbus read failed\n");
117 pause(
"ds1775_read_2", hz);
124 const char *name, *compatible;
127 name = ofw_bus_get_name(
dev);
128 compatible = ofw_bus_get_compat(
dev);
133 if (strcmp(name,
"temp-monitor") != 0 ||
134 (strcmp(compatible,
"ds1775") != 0 &&
135 strcmp(compatible,
"lm75") != 0))
138 sc = device_get_softc(
dev);
142 device_set_desc(
dev,
"Temp-Monitor DS1775");
152 sc = device_get_softc(
dev);
165 if (config_intrhook_establish(&sc->
enum_hook) != 0)
176 struct sysctl_oid *oid, *sensroot_oid;
177 struct sysctl_ctx_list *ctx;
180 char sysctl_name[40], sysctl_desc[40];
182 device_t
dev = (device_t)xdev;
184 sc = device_get_softc(
dev);
186 child = ofw_bus_get_node(
dev);
188 ctx = device_get_sysctl_ctx(
dev);
189 sensroot_oid = SYSCTL_ADD_NODE(ctx,
190 SYSCTL_CHILDREN(device_get_sysctl_tree(
dev)), OID_AUTO,
"sensor",
191 CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"DS1775 Sensor Information");
193 if (OF_getprop(child,
"hwsensor-zone", &sc->
sc_sensor.zone,
197 plen = OF_getprop(child,
"hwsensor-location", sc->
sc_sensor.name,
201 strcpy(sysctl_name,
"sensor");
203 for (i = 0; i < strlen(sc->
sc_sensor.name); i++) {
204 sysctl_name[i] = tolower(sc->
sc_sensor.name[i]);
205 if (isspace(sysctl_name[i]))
206 sysctl_name[i] =
'_';
213 sc->
sc_sensor.target_temp = 500 + ZERO_C_TO_K;
214 sc->
sc_sensor.max_temp = 600 + ZERO_C_TO_K;
217 sc->
sc_sensor.target_temp = 300 + ZERO_C_TO_K;
218 sc->
sc_sensor.max_temp = 600 + ZERO_C_TO_K;
223 pmac_thermal_sensor_register(&sc->
sc_sensor);
225 sprintf(sysctl_desc,
"%s %s", sc->
sc_sensor.name,
"(C)");
226 oid = SYSCTL_ADD_NODE(ctx, SYSCTL_CHILDREN(sensroot_oid),
227 OID_AUTO, sysctl_name, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
228 "Sensor Information");
229 SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(oid), OID_AUTO,
"temp",
230 CTLTYPE_INT | CTLFLAG_RD | CTLFLAG_MPSAFE,
dev,
233 config_intrhook_disestablish(&sc->
enum_hook);
252 return (((int16_t)(
read) >> 7) * 5 + ZERO_C_TO_K);
264 sc = device_get_softc(
dev);
270 error = sysctl_handle_int(oidp, &temp, 0, req);
DRIVER_MODULE(ds1775, iicbus, ds1775_driver, ds1775_devclass, 0, 0)
static int ds1775_sensor_sysctl(SYSCTL_HANDLER_ARGS)
static int ds1775_attach(device_t)
static int ds1775_probe(device_t)
static devclass_t ds1775_devclass
static void ds1775_start(void *xdev)
static device_method_t ds1775_methods[]
static int ds1775_sensor_read(struct ds1775_softc *sc)
static driver_t ds1775_driver
static int ds1775_read_2(device_t dev, uint32_t addr, uint8_t reg, uint16_t *data)
int iicbus_transfer(device_t bus, struct iic_msg *msgs, uint32_t nmsgs)
struct intr_config_hook enum_hook
struct pmac_therm sc_sensor